akhauriyash/Code-Regression huggingface dataset:
//C
#include <cassert>
#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <ccomplex>
#include <cfenv>
#include <cinttypes>
#include <cstdalign>
#include <cstdbool>
#include <cstdint>
#include <ctgmath>
#include <cwchar>
#include <cwctype>

//C++
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#include <array>
#include <atomic>
#include <chrono>
#include <condition_variable>
#include <forward_list>
#include <future>
#include <initializer_list>
#include <mutex>
#include <random>
#include <ratio>
#include <regex>
#include <scoped_allocator>
#include <system_error>
#include <thread>
#include <tuple>
#include <typeindex>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>

//Others
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;
}
const int dx[8] = { -1,0,1,-1,1,-1,0,1 };
const int dy[8] = { 1,1,1,0,0,-1,-1,-1 };


//LOVE NyantakoGG	https://www.youtube.com/channel/UC6XdFs8T6Ei54O0FYl3PVVA


using namespace std;

bool check(vector<int>a, vector<int>b) {
	for (int i = 0; i < a.size(); i++) {
		if (a[i] != b[i]) {
			return false;
		}
	}
	return true;
}

int main() {
	int N;
	cin >> N;
	vector<int>P(N), Q(N), v(N);
	for (int i = 0; i < N; i++) {
		cin >> P[i];
	}
	for (int i = 0; i < N; i++) {
		cin >> Q[i];
	}
	for (int i = 0; i < N; i++) {
		v[i] = i + 1;
	}
	int a, b, id;
	id = 1;
	do {
		if (check(P, v)) {
			a = id;
		}
		if (check(Q, v)) {
			b = id;
		}
		id++;
	} while (next_permutation(v.begin(), v.end()));
	cout << abs(a - b) << endl;
}


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

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

int main() {
    int t;
    cin >> t;
    while (t--) {
        ll a, b, c, d;
        cin >> a >> b >> c >> d;
        // cant tolerate the very first day
        if (a < b) {
            cout << "No" << endl;
            continue;
        }
        // cant keep up with the buy
        if (b > d) {
            cout << "No" << endl;
            continue;
        }
        // the threshold is too high; cant buy more than the stock
        if (b < c) {
            cout << "Yes" << endl;
            continue;
        }
        ll g = gcd(b, d);
        ll thrs = b - g + (a % g);
        puts(thrs > c ? "No" : "Yes");
    }
}

Measured memory_bytes: 256
#include <vector>
#include <list>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <cstring>
using namespace std;
vector<pair<int,int> >a;
int main(){
	int n;
	cin>>n;
	if(n%2)cout<<2*n<<endl;else cout<<n<<endl;
}


Measured memory_bytes: 256
import java.util.*;

public class Main {
    public static void main(String[] args){
        Scanner scan = new Scanner(System.in);
        int n = scan.nextInt();
        int k = scan.nextInt();
        int out = (int) (Math.pow(k - 1, n - 1) * k);
        System.out.println(out);
    }
}

Measured memory_bytes: 21844
package main

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

var sc = bufio.NewScanner(os.Stdin)

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

func main() {
	buf := make([]byte, 0)
	sc.Buffer(buf, 1000000007)
	sc.Split(bufio.ScanWords)
	n, _ := strconv.Atoi(Scanner())
	m, _ := strconv.Atoi(Scanner())
	nx := n * (n - 1) / 2
	mx := m * (m - 1) / 2
	fmt.Println(nx + mx)
}


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

using namespace std;

int dp[5400];
int n, k;
int a[5400];
bool noneed(int ind){
  for(int i = 0;i < 5400;i++)dp[i] = 0;
  dp[0] = 1;
  
  for(int i = 0;i < n;i++){
    if(i == ind)continue;
    for(int j = 5250;j-a[i] >= 0;j--){
      if(dp[j-a[i]])dp[j] = 1;
    }
  }
  for(int i = max(0, k - a[ind]);i < k;i++){
    if(dp[i])return false;
  }
  return true;
}

int main(){
  cin >> n >> k;
  for(int i = 0;i < n;i++)cin >> a[i];
  sort(a, a + n);
  
  if(!noneed(0)){
    cout << 0 << endl;
    return 0;
  }

  int bottom = 0, top = n;
  while(top - bottom > 1){
    int mid = (top + bottom) / 2;
    if(noneed(mid))bottom = mid;
    else top = mid;
  }
  cout << bottom + 1 << endl;
  return 0;
}

Measured memory_bytes: 384
#include <iostream>
#include <cstring>
#include <algorithm>
#include <vector>
#include <string>
#include <math.h>
#include <iomanip>
#include <limits>
#include <list>
#include <queue>
#include <tuple>
#include <map>
#include <stack>
#include <set>
#include <bitset>
using namespace std;
#define fast_io ios_base::sync_with_stdio (false) ; cin.tie(0) ; cout.tie(0) ;
#define MOD (long long int)(1e9+7)
#define ll long long int
#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define reps(i,n) for(int i=1; i<=(int)(n); i++)
#define REP(i,n) for(int i=n-1; i>=0; i--)
#define REPS(i,n) for(int i=n; i>0; i--)
#define INF (int)(1123456789)
#define LINF (long long int)(112345678901234567)
#define chmax(a, b) a = (((a)<(b)) ? (b) : (a))
#define chmin(a, b) a = (((a)>(b)) ? (b) : (a))
#define all(v) v.begin(), v.end()

typedef pair<int, int> Pii;
typedef pair<ll, ll> Pll;

ll mpow(ll a, ll b){
  if(b==0) return 1;
  else if(b%2==0){ll memo = mpow(a,b/2); return memo*memo%MOD;}
  else return mpow(a,b-1) * a % MOD;
}
ll lpow(ll a, ll b){
  if(b==0) return 1;
  else if(b%2==0){ll memo = lpow(a,b/2); return memo*memo;}
  else return lpow(a,b-1) * a;
}
ll gcd(ll a, ll b){
  if(b==0) return a;
  else return gcd(b, a%b);
}
vector<ll> kaijo_memo;
ll kaijo(ll n){
  if(kaijo_memo.size() > n) return kaijo_memo[n];
  if(kaijo_memo.size() == 0) kaijo_memo.push_back(1);
  while(kaijo_memo.size() <= n) kaijo_memo.push_back(kaijo_memo[kaijo_memo.size()-1] * kaijo_memo.size() % MOD);
  return kaijo_memo[n];
}
vector<ll> gyaku_kaijo_memo;
ll gyaku_kaijo(ll n){
  if(gyaku_kaijo_memo.size() > n) return gyaku_kaijo_memo[n];
  if(gyaku_kaijo_memo.size() == 0) gyaku_kaijo_memo.push_back(1);
  while(gyaku_kaijo_memo.size() <= n) gyaku_kaijo_memo.push_back(gyaku_kaijo_memo[gyaku_kaijo_memo.size()-1] * mpow(gyaku_kaijo_memo.size(), MOD-2) % MOD);
  return gyaku_kaijo_memo[n];
}

ll nCr(ll n, ll r){
  if(n == r) return 1;//0個の丸と-1個の棒みたいな時に時に効く？不安.
  if(n < r || r < 0) return 0;
  ll ret = 1;
  ret *= kaijo(n); ret %= MOD;
  ret *= gyaku_kaijo(r); ret %= MOD;
  ret *= gyaku_kaijo(n-r); ret %= MOD;
  return ret;
}

int main(void){
  fast_io
  cout<<fixed<<setprecision(15);

  ll h,w,a,b;cin>>h>>w>>a>>b;
  ll ans = 0;
  rep(i,1e7){
    ll y = h - a - 1 - i;
    ll x = b + i;
    if(x >= w || y <= -1) break;

    ans += nCr(y+x, y) * nCr(h-1-y+w-1-x, h-1-y) % MOD;
    ans %= MOD;
  }
  cout<<ans<<endl;
  return 0;
}

Measured memory_bytes: 3312
#include<iostream>
#define rep(i,n) for(int i=0;i<n;i++)
using namespace std;
int main()
{
    int a,b;
    cin>>a>>b;
    if(a>=13)cout<<b<<endl;
    else if(a>=6 && a<=12)cout<<b/2<<endl;
    else if(a<=5) cout<<0<<endl;

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define ff first
#define ss second
#define pii pair <int,int>
#define pll pair <ll,ll>
#define testcase() int t; cin>>t; while(t--)
#define forn(i,n) for(int i=0;i<n;i++)
#define forn1(i,n) for(int i=1;i<=n;i++)
#define vll vector <ll>
#define vi vector <int>
#define all(v) v.begin(),v.end()

ll M = 1e9 + 7;
double pi = acos(-1.0);
ll powerm(ll x,ll y){ ll res=1; while(y){ if(y&1) res=(res*x)%M; y=y>>1; x=(x*x)%M;} return res%M; }
ll power(ll x,ll y){ ll res=1; while(y){ if(y&1) res=(res*x); y=y>>1; x=(x*x);} return res; }
ll gcd(ll a,ll b){if(b>a)return gcd(b,a); if(b==0)return a; return gcd(b,a%b);}

int main() {
	
	//ifstream cin("input.txt");
	//ofstream cout("output.txt");
	ios_base::sync_with_stdio(false); 
    cin.tie(NULL); 
	
	int n,k; cin>>n>>k;
    vll a(n);
    forn(i,n) cin>>a[i];
    sort(all(a));
    if(k&1 && a[n-1]==0){ cout<<0; return 0; }
    if(k&1 && a[n-1]<0)
    {
        ll p = 1;
        for(int i=n-1;i>=n-k;i--)
        {
            p = ((p*a[i])%M + M)%M;
        }
        cout<<p; return 0;
    }
    ll p = 1;
    int id1 = 0, id2 = n-1;
    if(k&1)
    {
        p = a[id2];
        id2--; k--;
    }
    k /= 2;
    forn(i,k)
    {
        ll h1 = a[id1]*a[id1+1];
        ll h2 = a[id2]*a[id2-1];
        if(h1>h2)
        {
            h1 %= M;
            p = ((p*h1)%M + M)%M;
            id1 += 2;
        }
        else
        {
            h2 %= M;
            p = ((p*h2)%M + M)%M;
            id2 -= 2;
        }
        
    }
    cout<<p;

	return 0;
}


Measured memory_bytes: 4760
// 2020-08-15 00:13:45
#include<bits/stdc++.h>
#ifdef LOCAL
#include "lib/debug.hpp"
#else
#define debug(...) 1
#endif
#define ALL(a) (a).begin(), (a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define rep(i, n) REP(i, 0, (n))
#define repc(i, n) REPC(i, 0, (n))
#define REP(i, n, m) for (int i = (int)(n); i < (int)(m); i++)
#define REPC(i, n, m) for (int i = (int)(n); i <= (int)(m); i++)
#define REPCM(i, n, m) for (int i = (int)(n); i >= (int)(m); i--)
using namespace std;
using ll = long long;
using ld = long double;
using pr = pair<ll, ll>;
using vll = vector<ll>;
using vpr = vector<pr>;
using P = pair<int, int>;
template<class T> inline bool chmin(T& a, const T& b) { if (a > b) { a = b; return true; } else return false; }
template<class T> inline bool chmax(T& a, const T& b) { if (a < b) { a = b; return true; } else return false; }

void answer() {
  int n;
  cin >> n;
  vector<int> a(1<<n), s;
  rep(i, 1<<n) cin >> a[i];
  sort(RALL(a));
  s.push_back(a[0]);
  a[0] = -1;
  rep(_, n) {
    vector<int> p = s;
    sort(ALL(p));
    rep(i, a.size()) {
      if(p.size() == 0) break;
      if(a[i] == -1) continue;
      if(p.back() > a[i]) {
        p.pop_back();
        s.push_back(a[i]);
        a[i] = -1;
      }
    }
    if(p.size() > 0) {
      puts("No");
      return;
    }
  }
  puts("Yes");
}
int main() {
  std::ios::sync_with_stdio(false);
  std::cin.tie(0);
  answer();
  return 0;
}

Measured memory_bytes: 5796
#include <bits/stdc++.h>
#define fi first
#define se second
#define pb push_back
using namespace std;
typedef long long LL;
typedef vector<int> vi;
typedef pair<int,int> pii;

const int mxsz = 1e5 + 5;
int n, m;
map<pii, int> mp;
vi pi[mxsz];
pii req[mxsz];

int main(){
	//ios_base::sync_with_stdio(false);
	//cin.tie(0); cout.tie(0);
	
	cin >> n >> m;
	for (int i = 1; i <= m; i++){
		cin >> req[i].fi >> req[i].se;
		pi[req[i].fi].pb(req[i].se);
	}
	for (int i = 1; i <= n; i++){
		if (!pi[i].empty()){
			sort(pi[i].begin(), pi[i].end());
			for (int j = 1; j <= pi[i].size(); j++){
				pii tmp = {i,pi[i][j-1]};
				mp[tmp] = j;
			}
		}
	}
	for (int i = 1; i <= m; i++){
		pii tmp = {req[i].fi, req[i].se};
		printf("%06d%06d\n",req[i].fi, mp[tmp]);
	}
	return 0;
}


Measured memory_bytes: 13952
*c, = map(int,open(0).read().split())
for i in range(2):
    if( (c[1+i]-c[0+i])!=(c[4+i]-c[3+i]) or (c[1+i]-c[0+i])!=(c[7+i]-c[6+i])
       or (c[3+i*3]-c[i*3])!=(c[4+i*3]-c[1+i*3]) or (c[3+i*3]-c[i*3])!=(c[5+i*3]-c[2+i*3]) ):
        print("No")
        break
else:
    print("Yes") 

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

using namespace std;

int main() {
    double a, b, c;
    cin >> a >> b >> c;
    double s, l, h;
    double th = c * M_PI / 180;
    s = 0.5 * a * b * sin(th);
    double d = sqrt(a * a + b * b - 2 * a * b * cos(th));
    l = a + b + d;
    h = s * 2 / a;
    cout << fixed << setprecision(10);
    cout << s << endl;
    cout << l << endl;
    cout << h << endl;
    return 0;
}



Measured memory_bytes: 3520
st = gets.chomp.split("")

st.each_with_index do |e, i|
  if i == 0 || i % 2 == 0
    if e == "L"
      puts "No"
      exit
    end
  else
    if e == "R"
    puts "No"
    exit
    end
  end
end

puts "Yes"


Measured memory_bytes: 3836
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Text;

class Program
{

	static void Main(string[] args)
	{
		string[] input = Console.ReadLine().Split(' ');
		int N = int.Parse(input[0]);
		int K = int.Parse(input[1]);

		string[] input_A = Console.ReadLine().Split(' ');

		var A = new int[N];

		for (int i = 0; i < N; i++){
			A[i] = int.Parse(input_A[i]);
		}

		for (int i = K; i < N; i++)
		{
			if(A[i - K] >= A[i])
            {
				Console.WriteLine("No");
            }
            else
            {
				Console.WriteLine("Yes");
			}
		}
    }
}

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

namespace GCD
{
    internal class Program
    {
        public static void Main(string[] args)
        {
            var input = Console.ReadLine().Split(' ').Select(int.Parse).ToArray();
            Console.WriteLine(Gcd(input[0], input[1]));
        }

        static int Gcd(int m, int n)
        {
            if (m <= n)
            {
                var tmp = m;
                m = n;
                n = tmp;
            }

            while (m % n != 0)
            {
                var tmp = n;
                n = m % n;
                m = tmp;
            }

            return n;
        }
    }
}


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

int main(){
    ll x,k,d;
    cin >> x >> k >> d;
    x = abs(x);
    ll ans;
    if(x/d > k){
        ans = x - d*k;
    }else{
        ll e = x/d;
        k -= e;
        x -= e*d;
        if(k%2 == 1)
        x = abs(x-d);
        ans = x;
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 3632
from fractions import gcd
def func(a, b):
    if a < 0:
        return (-a, -b)
    return a, b
while True:
    a, b, c = map(int, raw_input().split())
    if (a, b, c) == (0, 0, 0):
        break
    try:
        d = (b**2 - 4*a*c)**0.5
        if not int(d) == d:
            raise
        e,f = map(int,(-b+d, -b-d))
        g = 2*a
        h = gcd(e, g)
        i = gcd(f, g)
        p, q = func(g/h, -e/h)
        r, s = func(g/i, -f/i)
        if (p < r) or (p == r and q < s):
            p, q, r, s = r, s, p, q
        print p, q, r, s
    except:
        print "Impossible"

Measured memory_bytes: 5988
#include <stdio.h>
#include <stdlib.h>

#define HASH 100003

typedef struct List {
	struct List *next;
	long long v, l, r;
} list;

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

int main()
{
	long long N, X, D;
	scanf("%lld %lld %lld", &N, &X, &D);
	if (X == 0 || D == 0) {
		if (X == 0 && D == 0) printf("1\n");
		else if (D == 0) printf("%lld\n", N + 1);
		else printf("%lld\n", N * (N - 1) / 2 + 1);
		fflush(stdout);
		return 0;
	}
	
	long long G = gcd(llabs(X), llabs(D)), Y;
	X /= G;
	D /= G;
	if (D < 0) {
		Y = X;
		X = X + D * (N - 1);
		D *= -1;
	} else Y = X + D * (N - 1);
	
	int h, i;
	long long V, L, R;
	list *hash[HASH] = {}, d[200001], *p;
	d[0].v = 0;
	d[0].l = 0;
	d[0].r = D;
	d[0].next = NULL;
	hash[0] = &(d[0]);
	for (i = 1; i <= N; i++) {
		L = (X * 2 + D * (i - 1)) * i / 2;
		R = (Y * 2 - D * (i - 1)) * i / 2 + D;
		V = (L % D + D) % D;
		h = V % HASH;
		for (p = hash[h]; p != NULL; p = p->next) if (p->v == V && p->l <= R && p->r >= L) break;
		if (p == NULL) {
			d[i].v = V;
			d[i].l = L;
			d[i].r = R;
			d[i].next = hash[h];
			hash[h] = &(d[i]);
		} else {
			p->l = (p->l < L)? p->l: L;
			p->r = (p->r > R)? p->r: R;
		}
	}
	
	long long ans = 0;
	for (h = 0; h < HASH; h++) {
		for (p = hash[h]; p != NULL; p = p->next) ans += (p->r - p->l) / D;
	}
	printf("%lld\n", ans);
	fflush(stdout);
	return 0;
}

Measured memory_bytes: 8764
from collections import deque

N, M = map(int, input().split())
G = [[] for _ in range(3 * N)]

for _ in range(M):
    u, v = map(int, input().split())
    u, v = u - 1, v - 1

    # 状態を3倍化して保存
    G[3 * u].append(3 * v + 1)
    G[3 * u + 1].append(3 * v + 2)
    G[3 * u + 2].append(3 * v)

S, T = map(int, input().split())
S, T = 3 * (S - 1), 3 * (T - 1)


def bfs():
    cnt = 0
    q = deque()
    visited = [False for _ in range(3 * N)]
    q.append(S)
    visited[S] = True
    while len(q) > 0:
        new_q = deque()
        cnt += 1
        while(len(q) > 0):
            u = q.pop()
            for v in G[u]:
                if visited[v]:
                    continue
                if v == T:
                    return cnt // 3

                visited[v] = True
                new_q.append(v)
        q = new_q
    return -1


print(bfs())


Measured memory_bytes: 50880
#include <algorithm>
#include <cstdint>
#include <iostream>
#include <numeric>
#include <vector>

using namespace std;
using myui = uint64_t;
using myint = int64_t;

template<typename T>
T diff(const T& a, const T& b) {
    return a > b ? a - b : b - a;
}

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

    {
        myui n, ts[5] = {};
        cin >> n;

        for(auto& t : ts) {
            cin >> t;
        }

        myui min = ts[0];
        myui min_i = 0;
        for(myui i = 1; i < 5; i++) {
            if (min > ts[i]) {
                min = ts[i];
                min_i = i;
            }
        }

        myui former = min_i;
        myui req_m = (n+(min-1))/min;
        myui latter = 4-min_i;

        cout << former+req_m+latter << endl;


    }

    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<boost/multiprecision/cpp_int.hpp>
using namespace std;
using namespace boost::multiprecision;
#define BEGIN ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define END return EXIT_SUCCESS
#define rep(I,N) for(auto I=0;I<(N);++I)
#define up(I,A,B) for(auto I=(A);I<=(B);++I)
#define dw(I,A,B) for(auto I=(A);I>=(B);--I)
#define all(C) (C).begin(),(C).end()
#define rall(C) (C).rbegin(),(C).rend()
#define ft first
#define sd second
#define mp make_pair
#define mt make_tuple
#define pf push_front
#define pb push_back
#define eb emplace_back
#define lb lower_bound
#define ub upper_bound
#define rs resize
typedef long long ll;
typedef unsigned long long ull;
template<class T>inline void                                      in(T &p){cin>>p;}
template<class T1,class T2>inline void                            in(T1 &p1,T2 &p2){cin>>p1>>p2;}
template<class T1,class T2,class T3>inline void                   in(T1 &p1,T2 &p2,T3 &p3){cin>>p1>>p2>>p3;}
template<class T1,class T2,class T3,class T4>inline void          in(T1 &p1,T2 &p2,T3 &p3,T4 &p4){cin>>p1>>p2>>p3>>p4;}
template<class T1,class T2,class T3,class T4,class T5>inline void in(T1 &p1,T2 &p2,T3 &p3,T4 &p4,T5 &p5){cin>>p1>>p2>>p3>>p4>>p5;}
template<class T>inline void                                      ins(T &p){for_each(all(p),in<decltype(p[0])>);}
template<class T>inline void                             out(T p){cout<<p<<endl;}
template<class T1,class T2>inline void                   out(T1 p1,T2 p2){cout<<p1<<" "<<p2<<endl;}
template<class T1,class T2,class T3>inline void          out(T1 p1,T2 p2,T3 p3){cout<<p1<<" "<<p2<<" "<<p3<<endl;}
template<class T1,class T2,class T3,class T4>inline void out(T1 p1,T2 p2,T3 p3,T4 p4){cout<<p1<<" "<<p2<<" "<<p3<<" "<<p4<<endl;}
inline                                              void out(double p){printf("%.10f\n",p);}
template<class T>inline                             void outs(T p){for_each(all(p),out<decltype(p[0])>);}

inline void solve(void){
  int N;
  string S;
  in(N,S);
  int cnt=0;
  rep(i,N-2){
    if(S[i]=='A'&&S[i+1]=='B'&&S[i+2]=='C')cnt++;
  }
  out(cnt);
}
int main(int argc,char**argv){
  BEGIN;
  solve();
  END;
}


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

int main(void) {
	int n, u, k, s;
	cin >> n;
	bool table[102][102] = {};

	for (int i = 0;i <= n - 1;i++) {
		cin >> u >> k;
		for (int j = 0;j <= k - 1;j++) {
			cin >> s;
			table[u-1][s-1] = 1;
		}
	}

	for (int i = 0;i <= n - 1;i++) {
		for (int j = 0;j <= n - 1;j++) {
			if (j > 0) cout << " ";
			cout << table[i][j];
		}
		cout << endl;
	}

	return 0;
}

Measured memory_bytes: 3124
#include<bits/stdc++.h>
#define ll long long int

using namespace std;

const ll mod=1000000007;
const ll inf=1e18;

int main(){

  ll x,y,z,k;
  cin >> x >> y >> z >> k;
  ll a[x],b[y],c[z];

  for(int i=0;i<x;i++)cin >> a[i];
  for(int i=0;i<y;i++)cin >> b[i];
  for(int i=0;i<z;i++)cin >> c[i];

  sort(c,c+z);
  reverse(c,c+z);

  vector<ll> v;
  for(int i=0;i<x;i++){
    for(int j=0;j<y;j++){
      v.push_back(a[i]+b[j]);
    }
  }

  sort(v.begin(),v.end());
  reverse(v.begin(),v.end());

  vector<ll> u;

  for(int i=0;i<min(k,x*y);i++){
    for(int j=0;j<z;j++){
      u.push_back(v[i]+c[j]);
    }
  }

  sort(u.begin(),u.end());
  reverse(u.begin(),u.end());

  for(int i=0;i<k;i++)cout << u[i] << endl;
  
  

  

}

Measured memory_bytes: 44132
#include<bits/stdc++.h>   //https://atcoder.jp/contests/dp/tasks/dp_i
using namespace std;
double dp[3000][3000],arr[3000],sum;
int n;
int main()
{
	cin>>n;
	dp[0][0]=1;
	for(int i=1;i<=n;++i){cin>>arr[i];dp[i][0]=dp[i-1][0]*arr[i];}
	int t=(n-1)/2;
	for(int i=1;i<=n;++i)
	{
		for(int j=1;j<=i&&j<=t;++j)
		{
			dp[i][j]=dp[i-1][j-1]*(1-arr[i])+dp[i-1][j]*arr[i];
		}
	}
	for(int i=0;i<=t;++i)sum+=dp[n][i];
	printf("%.10lf",sum);
}

Measured memory_bytes: 68736
#include <iostream>
using namespace std;
int n, ans;
string s;

int main() {
    cin >> n >> s;
    for (int i = 0; i <= 999; i++) {
        int c[3] = {i / 100, i / 10 % 10, i % 10};
        int ok = 0;
        for (int j = 0; j < n; j++) {
            if (s[j] == c[ok] + '0') ok++;
            if (ok == 3) break;
        }
        if (ok == 3) ans++;
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define pb push_back
#define ll long long int
#define pp pair<int,int>
#define pl pair<ll,ll>
#define fi first
#define si second
using namespace std;
int main() {
	int k,n;
	cin>>k>>n;
	int a[n],ans=k;
	for(int i=0;i<n;i++){
		cin>>a[i];
	}
	for(int i=0;i<n;i++){
		if(i==0){
			ans=min(ans,a[n-1]-a[i]);
		}else{
			ans=min(ans,k-(a[i]-a[i-1]));
		}
	}
	cout<<ans<<endl;
    return 0;
}




Measured memory_bytes: 1024
#include<iostream>
#include<cstdio>
#include<cstring>
#include<cmath>
using namespace std;
inline void rd(int &x)
{
	x=0;register char k=getchar();int s=1;
	while(k>'9'|k<'0'){if(k=='-')s=-1;k=getchar();}
	while(k>='0'&&k<='9')x=x*10+k-48,k=getchar();x*=s;
}
int main()
{
	int r,g,b,n,ans=0;
	cin>>r>>g>>b>>n;
	for(int i=0;i<=n;i++)
	{
		for(int j=0;j<=n;j++)
		{
			int now=n-i*r-j*g;
			if(now%b||now<0)continue;ans++;//cout<<i<<" "<<j<<" "<<now/b<<endl;
		}
	}cout<<ans;
}

Measured memory_bytes: 256
import sys
from math import sqrt
from collections import Counter, defaultdict, deque

input = sys.stdin.readline


def I():
    return int(input())


def MI():
    return map(int, input().split())


def LI():
    return list(MI())


def LIN(n: int):
    return [I() for _ in range(n)]


inf = float("inf")
mod = 10 ** 9 + 7


def devisor(n):
    ret = []
    for i in range(1, int(n ** 0.5) + 1):
        if n % i == 0:
            ret.append(i)
            if n // i != i:
                ret.append(n // i)
    return ret


def main():
    n = I()

    divs1 = devisor(n)
    divs2 = devisor(n - 1)
    c = len(divs2) - 1
    for val in divs1:
        if val != 1:
            tmp = n
            while tmp % val == 0:
                tmp = tmp // val
            if tmp % val == 1:
                c += 1
    print(c)


if __name__ == "__main__":
    main()



Measured memory_bytes: 39732
/*
	Created by Faisal Ahmed
*/

#include <bits/stdc++.h>
 
using namespace std;
 
typedef long long int ll;
typedef long double ld;

int main()
{
	ios_base::sync_with_stdio(0);
	cin.tie(0);cout.tie(NULL);
	
	ll a, b, k;
	
	cin >> a >> b >> k;
	
	ll d = min(a, k);
	
	a -= d;
	k -= d;
	
	d = min(b, k);
	
	b -= d;
	k -= d;
	
	cout << a << " " << b << endl;
	
	return 0;
} 

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<cstring>
#include<numeric>
#include<vector>
#include<tuple>
using namespace std;

#define int long long

#ifdef lioraju
	#define ndbg(x) 
#else
	#define ndbg(x) x
#endif

typedef tuple<int, int> p2i;

const int mxsz = 3e3 + 5;

string va, vb;

int dp[mxsz][mxsz];
bool vis[mxsz][mxsz];
int fr[mxsz][mxsz];

int d(int n, int m)
{
	if (n<0||m<0) return 0;
	if (vis[n][m]) return dp[n][m];
	
	vis[n][m] = 1;
	p2i mxn = max(p2i{d(n-1, m), 1}, p2i{d(n, m-1), 2});
	if (va[n]==vb[m]) mxn = max(mxn, p2i{d(n-1, m-1)+1, 3});
	
	return tie(dp[n][m], fr[n][m]) = mxn, dp[n][m];
}

signed main()
{
	ndbg( ios::sync_with_stdio(0); cin.tie(0); );
	cin>>va>>vb;
	
	int n = va.size(), m = vb.size();
	d(n-1, m-1);
	
	string ans;
	int i = n-1, j = m-1;
	while (1)
	{
		if (i<0||j<0) break;
		int f = fr[i][j];
		if (f==1) tie(i, j) = p2i{i-1, j};
		else if (f==2) tie(i, j) = p2i{i, j-1};
		else ans = ans + va[i], tie(i, j) = p2i{i-1, j-1};
	}
	
	reverse(ans.begin(), ans.end());
	cout<<ans<<'\n';
}

Measured memory_bytes: 150656
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cctype>
#include <cmath>
#include <cstdint>
#include <cstdio>
#include <cstring>
#include <deque>
#include <fstream>
#include <functional>
#include <iostream>
#include <limits>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <vector>
using namespace std;
using ll = long long;
#define fst first
#define snd second

/* clang-format off */
template <class T, size_t D> struct _vec { using type = vector<typename _vec<T, D - 1>::type>; };
template <class T> struct _vec<T, 0> { using type = T; };
template <class T, size_t D> using vec = typename _vec<T, D>::type;
template <class T> vector<T> make_v(size_t size, const T& init) { return vector<T>(size, init); }
template <class... Ts> auto make_v(size_t size, Ts... rest) { return vector<decltype(make_v(rest...))>(size, make_v(rest...)); }
template <class T> inline void chmin(T &a, const T& b) { if (b < a) a = b; }
template <class T> inline void chmax(T &a, const T& b) { if (b > a) a = b; }
/* clang-format on */

int main() {
#ifdef DEBUG
  ifstream ifs("in.txt");
  cin.rdbuf(ifs.rdbuf());
#endif
  int N;
  while (cin >> N) {
    vector<int> p(N);
    for (int &x : p) cin >> x, --x;
    int cnt = 0;
    for (int i = 0; i < N; i++) {
      if (p[i] != i) ++cnt;
    }
    bool res = cnt <= 2;
    cout << (res ? "YES" : "NO") << endl;
  }
  return 0;
}


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

int main()
{
	int n;
	cin >> n;
	vector<int> h(n);
	for(int i=0;i<n;i++)
		cin >> h[i];
	
	int mx=0,count=0;
	for(int i=0;i<n;i++)
		if(mx<=h[i])
		{
			count++;
			mx=h[i];
		}

	cout << count << endl;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <iostream>
#include <cstring>
#include <vector>
#include <algorithm>
#include <cstdlib>
#include <cmath>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <ctime>
#include <string.h>
#include <assert.h>
#include <complex>
#include <random>

#define all(a) (a).begin(), (a).end()
#define sz(a) (int)(a).size()
#define pb push_back

using namespace std;

typedef long long ll;
mt19937 rr(random_device{}());

vector<vector<int>> g;

int dfs(int v) {
    vector<int> h;
    for (int u : g[v]) {
        h.push_back(dfs(u));
    }
    int k = sz(g[v]);

    int ans = k;
    sort(all(h));
    for (int i = k - 1; i >= 0; --i) 
        ans = max(ans, h[i] + k - i);
    
    return ans;
}

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

    int n;
    cin >> n;
    vector<int> a(n);
    g.resize(n);
    for (int i = 1; i < n; ++i) {
        cin >> a[i];
        --a[i];
        g[a[i]].push_back(i);
    }

    cout << dfs(0) << endl;


    return 0;
}


Measured memory_bytes: 15488
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int INF = 1000000007;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(v) v.begin(), v.end()

// #include <boost/multiprecision/cpp_dec_float.hpp>
// #include <boost/multiprecision/cpp_int.hpp>
// namespace mp = boost::multiprecision;
// using Bint = mp::cpp_int;
// using Real = mp::number<mp::cpp_dec_float<1024>>;

int main(){
    int N;
    cin >> N;
    vector<int> dp(100010, INF);
    dp.at(0) = 0;
    for(int i = 1; i<= N; i++){
        for(int c6 = 1; i - c6 >=0; c6 *= 6){
            dp.at(i) = min(dp.at(i), dp.at(i - c6) + 1);
        }
        for(int c9 = 1; i - c9 >=0; c9 *= 9){
            dp.at(i) = min(dp.at(i), dp.at(i - c9) + 1);
        }
    }

    cout << dp.at(N) << endl;
}

Measured memory_bytes: 640
/*****************************************************************\
    |     IN THE NAME OF ALLAH, MOST GRACIOUS AND MOST MERCIFUL       |
    |                                                                 |
    |     Author     : Mahabub Rahman                                 |
    |     Email      : mahabubrahman618@gmail.com                     |
    |     University : Comilla University, Bangladesh		          |
    |                  Department of Computer Science & Engineering   |
    \*****************************************************************/


    /*...................................Data_Types............................................*/
    #include<bits/stdc++.h>

    using namespace std;
    #define FastIO ios::sync_with_stdio(false); cin.tie(0);cout.tie(0)
    #define       ll                  long long int
    #define       ull                  unsigned long long int
    #define       veci                 vector<int>
    #define       vecc                 vector<char>
    #define       vecs                 vector<string>
    #define       vecl                 vector<long long int>
    #define       vecp                 vector<  pair<int,int> >
    #define       mapstrint            map< string , int >
    #define       mapstrstr            map< string , string >
    #define       mapint               map< int, int >
    #define       pb                   push_back
    #define       pob                  pop_back
    #define       mp                   make_pair
    ////============ CONSTANT ===============////
    #define mx9   1000000009
    #define mx7   10000007
    #define mx6   1000006
    #define mx5   100005
    #define inf   1<<30                                           //infinity value
    #define eps   1e-9
    #define mx    (65540)
    #define mod   1000000007
    ////=====================================////

    long double PI = acosl(-1);
    bool compare_int(int a, int b) //This function is use for descending order.
    {
        return (a>b);
    }
    bool compare_string (string a, string b)
    {
        return a.size() < b.size();
    }
    bool compare_pair(const pair<int,int> &a,
                  const pair<int,int> &b)
    {
        if(a.second==b.second) return a.first>b.first;
        else return (a.second > b.second);
    }
    ll fact(ll n)
    {
        if(n==0 || n==1) return 1;
        else return n*fact(n-1);
    }

    ////======================================////
    /*bool check(int n)
    {
        for(int i=2; i<=sqrt(n); i++)
        {
            if(n%i==0)
            {
                return false;
            }
        }
        return true;
    }*/

    int32_t main()
    {
        FastIO;
        ll n, a, b;
        cin >> n >> a >> b;
        ll cnt = (n/(a+b))*a;
        ll re = n%(a+b);
        if(re>=a) cnt+=a;
        else cnt +=re;
        cout << cnt << endl;
    }


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

int main() {
  string S;
  cin >> S;
  int count = 0;
  for (int i = 0; i < S.size() / 2; i++){
    if( S.at(i) != S.at(S.size() - 1 - i)){
      count++;
    }
  }
  cout << count << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<ll,ll>;
const int mod = 1e9 + 7;
//const int mod = 998244353;
const ll infll = (1LL << 62) - 1;
const int inf = (1 << 30) - 1;
void YesNo(bool j){cout << (j ? "Yes" : "No") << endl; return;}
void yesno(bool j){cout << (j ? "yes" : "no") << endl; return;}
template<class Head> void pt(Head&& head){cout << head << endl; return;}



int main() {
    int x, y;
  cin >>x >> y;
  pt(x*y);
    return 0;
}

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

#include <boost/multiprecision/cpp_int.hpp>
#define rep(i, n) for (int i = 0; i < (n); i++)
using namespace std;
typedef long long ll;
const int INF = 1e9;
using boost::multiprecision::cpp_int;

int main() {
  cpp_int x, k, d, ans, mod, num;
  cin >> x >> k >> d;
  if (abs(x) <= k * d) {
    mod = abs(x) % d;
    num = abs(x) / d;
    if (num % 2 == k % 2)
      ans = abs(x) % d;
    else
      ans = abs(abs(x) % d - d);
  } else {
    ans = abs(x) - k * d;
  }

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


Measured memory_bytes: 3708
import sys
from math import ceil, floor

A_B = str(sys.stdin.readline()).strip().split()
A, B = int(A_B[0]), int(A_B[1])

def max_num_outlets(num_outlets_each, num_sockets):
    max_num_outlets = 1 + (num_outlets_each - 1) * num_sockets
    return max_num_outlets

for i in range(B):
    if B <= max_num_outlets(A, i):
        print(i)
        break


Measured memory_bytes: 2940
#include<iostream>
#include<algorithm>
using namespace std;
int n,q,L,x[1<<17];
int d[20][1<<17];
main()
{
	cin>>n;
	for(int i=0;i<n;i++)cin>>x[i];
	cin>>L;
	for(int i=0;i<n;i++)
	{
		d[0][i]=upper_bound(x,x+n,x[i]+L)-x-1;
	}
	for(int k=1;k<20;k++)
	{
		for(int i=0;i<n;i++)
		{
			d[k][i]=d[k-1][d[k-1][i]];
		}
	}
	cin>>q;
	for(;q--;)
	{
		int a,b;cin>>a>>b;
		a--,b--;
		if(a>b)swap(a,b);
		int ans=0;
		for(int k=20;k--;)
		{
			if(d[k][a]<b)
			{
				ans+=1<<k;
				a=d[k][a];
			}
		}
		cout<<ans+1<<endl;
	}
}

Measured memory_bytes: 11008
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repr(i, a, b) for(int i = a; i < b; i++)
#define  all(x) (x).begin(),(x).end()     // 昇順ソート
#define  rall(v) (v).rbegin(), (v).rend() // 降順ソート
#define  FastIO ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0)
typedef long long ll;
typedef long long int lli;
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return true; } return false; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return true; } return false; }

int main(){
    int a, b;
    cin >> a >> b;
    int ans = a - (b*2);
    cout << max(ans, 0) << endl;
}

Measured memory_bytes: 256
#include <algorithm>
#include <bitset>
#include <complex>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <valarray>
#include <vector>

#include <cctype>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>

using namespace std;

#define all(c) c.begin(), c.end()
#define repeat(i, n) for (int i = 0; i < static_cast<int>(n); i++)
#define debug(x) #x << "=" << (x)
#define dump(x) cerr << debug(x) << " (L:" << __LINE__ << ")" << endl

typedef long long ll;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<long> vl;
typedef vector<vector<long>> vvl;
typedef vector<string> vs;

template <typename T>
ostream& operator<<(ostream& os, const vector<T>& vec)
{
    os << "[";
    for (int i = 0; i < vec.size(); i++) {
        os << vec[i] << ",";
    }
    os << "]";
    return os;
}

template <typename T>
T input()
{
    T t;
    cin >> t;
    return t;
}

template <typename T>
vector<T> input(const int N)
{
    vector<T> v(N);
    repeat(i, N) cin >> v[i];
    return v;
}

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

long long lcm(long long a, long long b)
{
    return (a / gcd(a, b)) * b;
}

long long mul(const long long& a, const long long& b, const long long& mod)
{
    return ((a % mod) * (b % mod)) % mod;
}

long long power(const long long& x, const long long& y, const long long& mod)
{
    if (y == 0) {
        return 1;
    } else if (y == 1) {
        return x % mod;
    } else {
        long long value = power(x, y / 2, mod);
        if (y % 2 == 0) {
            return mul(value, value, mod);
        } else {
            return mul(value, value, mod) * x % mod;
        }
    }
}

long long div(const long long& a, const long long& b, const long long& mod)
{
    return mul(a, power(b, mod - 2, mod), mod);
}

map<long long, long long> factorials;
long long factorial(const long long& n, const long long& mod)
{
    if (n == 0 || n == 1) {
        return 1;
    }
    if (factorials[n] != 0) {
        return factorials[n];
    }
    factorials[n] = n * factorial(n - 1, mod) % mod;
    return factorials[n] % mod;
}

long long combination(const long long& n, const long long& x, const long long& mod)
{
    long long numerator = 1;
    long long denominator = 1;
    repeat(i, x)
    {
        numerator *= (n - i) % mod;
        numerator %= mod;
        denominator *= (i + 1) % mod;
        denominator %= mod;
    }
    return div(numerator, denominator, mod);
}

int main()
{
    int R, G, B, N;
    cin >> R >> G >> B >> N;

    long long count = 0;
    for (int r = 0; r <= N; ++r) {
        if (N < r * R) {
            break;
        }
        for (int g = 0; g <= N; ++g) {
            long long sum = r * R + g * G;
            if (N < sum) {
                break;
            }
            if ((N - sum) % B == 0) {
                count++;
            }
        }
    }
    cout << count << endl;
    return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>
using std::cerr;
using std::cin;
using std::cout;
using std::endl;

int main(void) {
  cout << std::fixed << std::setprecision(10);
  cin.tie(0);
  std::ios::sync_with_stdio(false);

  int a, b;
  cin >> a >> b;
  if (a >= 13) {
    cout << b;
  } else if (a >= 6) {
    cout << b / 2;
  } else {
    cout << 0;
  }
  cout << endl;

  return 0;
}


Measured memory_bytes: 888
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, a, b) for (int i = a; i < b; i++)
#define all(v) v.begin(), v.end()
const int MOD = 1e9 + 7;
const int INF = 2e9;
//'A' = 65, 'Z' = 90, 'a' = 97, 'z' = 122

int main() {
    string s;
    cin >> s;
    int k;
    cin >> k;

    int len = s.size();
    set<string> st;
    rep(i, 1, 6) {
        rep(j, 0, len - i + 1) {
            st.insert(s.substr(j, i));
        }
    }

    vector<string> v;
    for (auto i : st) {
        v.push_back(i);
    }
    cout << v[k - 1] << endl;
    return 0;
}


Measured memory_bytes: 1920
s = input()
q = int(input())
a = [list(map(str, input().split())) for i in range(q)]

head = 1
ss = ''

for i in range(q):
    if(a[i][0] == '1'):
        head *= -1
    else:
        if(a[i][1] == '2' and head == 1):
            s = s + a[i][2]
        elif(a[i][1] == '1' and head == -1):
            s = s + a[i][2]    
        else:
            ss = ss + a[i][2]
if(head == 1):
    print(ss[::-1] + s)
else:
    print(s[::-1] + ss)


Measured memory_bytes: 40436
#include<iostream>
#include<algorithm>
#define ios ios::sync_with_stdio(false),cin.tie(0),cout.tie(0);
using namespace std;
typedef long long ll;
ll a,b,c,d;

int main()
{
	ios;
	cin>>a>>b>>c>>d;
	ll m1,m2,m3,m4,maxn;
	m1=a*c,m2=a*d;
	m3=b*c,m4=b*d;
	maxn=max(max(max(m1,m2),m3),m4);
	cout<<maxn<<"\n";
	return 0;
}

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

#include <atcoder/all>
#define For(i, a, b) for (int(i) = (int)(a); (i) < (int)(b); ++(i))
#define rFor(i, a, b) for (int(i) = (int)(a)-1; (i) >= (int)(b); --(i))
#define rep(i, n) For((i), 0, (n))
#define rrep(i, n) rFor((i), (n), 0)
#define fi first
#define se second
using namespace std;
using namespace atcoder;
typedef long long lint;
typedef unsigned long long ulint;
typedef pair<int, int> pii;
typedef pair<lint, lint> pll;
template <class T>
bool chmax(T &a, const T &b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
template <class T>
bool chmin(T &a, const T &b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template <class T>
T div_floor(T a, T b) {
    if (b < 0) a *= -1, b *= -1;
    return a >= 0 ? a / b : (a + 1) / b - 1;
}
template <class T>
T div_ceil(T a, T b) {
    if (b < 0) a *= -1, b *= -1;
    return a > 0 ? (a - 1) / b + 1 : a / b;
}

constexpr lint mod = 1000000007;
constexpr lint INF = mod * mod;
constexpr int MAX = 200010;

int main() {
    int n, m;
    scanf("%d%d", &n, &m);
    vector<lint> a(n), b(m);
    for (auto &i : a) scanf("%lld", &i);
    for (auto &i : b) scanf("%lld", &i);
    auto c = convolution(a, b);
    for (auto i : c) printf("%lld ", i);
    printf("\n");
}

Measured memory_bytes: 27276
#include<bits/stdc++.h>
#include<string>
using namespace std;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
 
int main(){
    string s;
    cin >> s;
 
    
 
    cout << s[0] << s[1] << s[2] << endl;
}

Measured memory_bytes: 3608
package main

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

func main() {
	n := readInt()
	q := readInt()

	results := make([]int, n+1)
	parents := make([]int, n+1)

	for i := 0; i < n-1; i++ {
		a := readInt()
		b := readInt()
		parents[b] = a
	}

	for i := 0; i < q; i++ {
		p := readInt()
		x := readInt()
		results[p] += x
	}

	for i := 1; i <= n; i++ {
		results[i] += results[parents[i]]
	}

	for i := 1; i <= n; i++ {
		writeInt(results[i])
		if i != n {
			writeString(" ")
		}
	}
	writeNewLineAndFlush()
}

const (
	ioBufferSize = 1 * 1024 * 1024 // 1 MB
)

var stdinScanner = func() *bufio.Scanner {
	result := bufio.NewScanner(os.Stdin)
	result.Buffer(make([]byte, ioBufferSize), ioBufferSize)
	result.Split(bufio.ScanWords)
	return result
}()

var stdoutWriter = bufio.NewWriter(os.Stdout)

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

func readInt() int {
	result, _ := strconv.Atoi(readString())
	return result
}

func writeString(s string) {
	stdoutWriter.WriteString(s)
}

func writeInt(i int) {
	writeString(strconv.Itoa(i))
}

func writeNewLineAndFlush() {
	stdoutWriter.WriteString("\n")
	stdoutWriter.Flush()
}


Measured memory_bytes: 11520
import std;

alias sread = () => readln.chomp();
alias lread = () => readln.chomp.to!long();
alias aryread(T = long) = () => readln.split.to!(T[]);
//aryread!string();
//auto PS = new Tuple!(long,string)[](M);
//x[]=1;でlong[]全要素1に初期化
void main()
{
    long h, w;
    scan(h, w);
    auto a = new string[](h);
    foreach (i; 0 .. h)
    {
        a[i] = sread();
    }
    // writeln(a);

    bool[] row = new bool[](h);
    bool[] col = new bool[](w);
    foreach (y; 0 .. h)
    {
        // writeln(a[y]);
        foreach (x; 0 .. w)
        {
            if (a[y][x] == '.')
            {
                continue;
            }
            else
            {
                row[y] = true;
                break;
            }
        }
    }

    // writeln(row);
    foreach (x; 0 .. w)
    {
        foreach (y; 0 .. h)
        {
            if (a[y][x] == '.')
            {
                continue;
            }
            else
            {
                col[x] = true;
                break;
            }
        }
    }
    // writeln(col);
    foreach (y; 0 .. h)
    {
        foreach (x; 0 .. w)
        {
            if (row[y] && col[x])
            {
                write(a[y][x]);
            }
        }
        if (row[y])
        {
            writeln();
        }
    }

}

void scan(L...)(ref L A)
{
    auto l = readln.split;
    foreach (i, T; L)
    {
        A[i] = l[i].to!T;
    }
}

void arywrite(T)(T a)
{
    a.map!text.join(' ').writeln;
}


Measured memory_bytes: 3672
#include <bits/stdc++.h>
using namespace std;
typedef unsigned long long ull;
typedef long long ll;
#define fastio() ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define test() ull t;cin>>t;while(t--)
#define pb push_back
#define mkp make_pair
#define nl cout<<endl
#define MOD 1000000007
#define loop(i,start,end) for(ll i=start;i<end;i++)
#define N 100001
#define all(v) v.begin(),v.end()
#define oa(a,n) for(int i=0;i<n;i++)cout<<a[i]<<" ";nl
#define ov(a) for(int i=0;i<a.size();i++)cout<<a[i]<<" ";nl
int n,m,mx=0;
vector<int>con[N],vis(N,0);

int dfs(int node)
{
  if(vis[node])return vis[node];
  int xx = 0;
  for(auto i:con[node])
    xx = max(xx,dfs(i));
  vis[node] = xx+1;
  return xx+1;
}

int main() 
{
    fastio();


  cin>>n>>m;
  while(m--)
  {
    int u,v;cin>>u>>v;
    u--;v--;
    con[u].pb(v);
  }
  for(int i = 0;i<n;i++)
  {
    if(!vis[i])
      mx = max(mx,dfs(i));
  }
  cout<<mx-1<<endl;


  return 0;
}

Measured memory_bytes: 8192
N = int(input())
T = 0
X = 0
Y = 0
flag = True

for i in range(N):
	t, x, y = map(int, input().split())
	d = abs(X - x) + abs(Y - y)
	if t - T < d or (t - T) % 2 != d % 2:
		flag = False
		break
	else:
		T = t
		X = x
		Y = y

if flag == True:
	print('Yes')
else:
	print('No')

Measured memory_bytes: 3064
#include<stdio.h>
#include<algorithm>
using namespace std;
double eps=1e-12;
int K;
double L,R,P,E,T;
double ABS(double a){return max(a,-a);}
double calc(int d,double l,double r,double p){
	//printf("%d %f %f %f\n",d,l,r,p);
	if(l-eps>T-E&&T+E-eps>r)return p;
	if(T+E<l||r<T-E)return 0;
	double m=(l+r)/2;
	if(K==d){
		if(T-E<eps+m&&m<T+E+eps)return p;
		return 0;
	}
	if(T-eps>m)return calc(d+1,l,m,p*P)+calc(d+1,m,r,p*(1.0-P));
	return calc(d+1,m,r,p*P)+calc(d+1,l,m,p*(1.0-P));
}
int main(){
	scanf("%d%lf%lf%lf%lf%lf",&K,&L,&R,&P,&E,&T);
	printf("%.12f\n",calc(0,L,R,1.0));
}

Measured memory_bytes: 1084
import collections
n = int(input())
moji = []
ans = 0
for i in range(n):
    tmp = list(input())
    tmp.sort()
    moji.append(''.join(tmp))
cnt = collections.Counter(moji)
for i in cnt.values():
    if i != 1:
        ans += i*(i-1)//2
print(ans)

Measured memory_bytes: 19732
#include<bits/stdc++.h>
using namespace std;
 
using lint=long long;

template<typename T> T LargestRectangle(vector<T>& h)
{
   // be careful not to overflow
   int N=h.size();
   vector<int> l(N),r(N);
   stack<int> S;
   for(int i=0;i<N;i++){
      while(!S.empty() and h[S.top()]>=h[i]) S.pop();
      l[i]=(S.empty()? 0:S.top()+1); S.push(i);
   }
   S=stack<int>();
   for(int i=N-1;i>=0;i--){
      while(!S.empty() and h[S.top()]>=h[i]) S.pop();
      r[i]=(S.empty()? N:S.top()); S.push(i);
   }
   T res=0;
   for(int i=0;i<N;i++) res=max(res,h[i]*(r[i]-l[i]));
   return res;
}

int main()
{
   int N; cin>>N;
   vector<lint> h(N);
   for(int i=0;i<N;i++) cin>>h[i];
   cout<<LargestRectangle(h)<<endl;
   return 0;
}



Measured memory_bytes: 4992
using System;
using System.Linq;//リストの使用
using System.Collections.Generic;
using System.Text;//テキストの高速出力に必要
class Program
{
	static void Main()
	{
		string stringUp = Console.ReadLine();
    string stringDown = Console.ReadLine();
    long[,] dp = new long[stringUp.Length+1, stringDown.Length+1];

    for(int i = 0; i <= stringUp.Length; i++) dp[i,0] = i;
    for(int i = 0; i <= stringDown.Length; i++) dp[0,i] = i;

    for(int i = 1; i <= stringUp.Length; i++)
    {
      for(int j = 1; j <= stringDown.Length; j++)
      {
        dp[i,j] = Math.Min(dp[i-1,j]+1, dp[i,j-1]+1);
        if(stringUp[i-1] == stringDown[j-1])
        {
          dp[i,j] = Math.Min(dp[i,j], dp[i-1,j-1]);
        }else
        {
          dp[i,j] = Math.Min(dp[i,j], dp[i-1,j-1]+1);
        }
      }
    }
    
		Console.WriteLine(dp[stringUp.Length, stringDown.Length]);//WriteLineをWriteとすると、改行なしで出力。
	}
}


Measured memory_bytes: 25152