akhauriyash/Code-Regression huggingface dataset:
//大文字->小文字 tolower(),逆はtoupper()
//int a = stoi(c); 文字列をintへ
//途中の出力をそのまま残さない
//数値計算 個数以外はdouble
//map<キー,値> p は辞書。p[キー] = 値
//map 全探索
//auto begin = p.begin(), end = p.end();
//for (auto it = begin; it != end; it++) {}
//mapのキー：it->first mapのバリュー：it->second
//絶対値 abs()
//入力は空白で切れる
//大文字判定 isupper(文字) 小文字判定 islower(文字)
//do{}while(next_permutation(ALL(配列)))
//while(N)で回すとき、Nはコピーを作っておく
//小文字に対応する文字コード：S[i] - 'a'
//文字コード→小文字：(char)(数字+'a')
//グラフの距離:隣接行列で扱う
//等価なものに変換する思考
//bool型　初期値はTrue
//島渡りの問題：中間ノードに着目
#include <bits/stdc++.h>
#define rep(i,N) for(int i = 0; i < N;i++)
#define ALL(a) (a).begin(),(a).end()
#define ll long long int
using namespace std;

// K進数でのNの桁数
ll dig(ll N,ll K) {
	ll dig = 0;
	while (N) {
		dig++;
		N /= K;
	}
	return dig;
}
// a,bの最大公約数
ll gcd(ll a, ll b) {
	if (b == 0) return a;
	return gcd(b,a%b);
}

ll lcm(ll a, ll b) {
	ll g = gcd(a, b);
	return a / g * b;
}

//nC2の計算
ll C(ll N) {
	return N * (N - 1) / 2;
}

//円周率
const double PI = 3.14159265358979323846;

int main() {
	ll N; cin >> N;
	vector<ll> a(N); rep(i, N)cin >> a[i];

	sort(ALL(a));

	vector<ll> cnt(a[N-1]+1);//0~a[N-1]
	rep(i, N) cnt[a[i]]++;
	

	ll mx = cnt[0] + cnt[1];
	for (int i = 1; i <= a[N - 1]; i++) {
		if (i == a[N - 1]) {
			mx = max(mx, cnt[i - 1] + cnt[i]);
			continue;
		}
		mx = max(mx, cnt[i - 1] + cnt[i] + cnt[i + 1]);
	}

	cout << mx << endl;
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
 
int main() {
	int64_t a, b, c, k;
  	cin >> a >> b >> c >> k;
  	if(a >= k){cout << k << endl; return 0;}
  	else if(a < k && b >= (k - a)){cout << a << endl; return 0;}
  	else if( a + b < k ) {cout << 2*a+b-k << endl; return 0;}
}

Measured memory_bytes: 3644
#include <bits/stdc++.h>
#define watch(x) cerr << (#x) << " is " << (x) << endl;
using namespace std;
const int MAXN = 100001;
const int INF = 1234567890;
using ll = long long;

int n, m;
vector<int> adj[MAXN];
int par[MAXN];

void bfs(int root){
	queue<int> frontier; frontier.push(root);
	par[root] = 0;
	while(not frontier.empty()){
		int u = frontier.front(); frontier.pop();
		for (int v : adj[u]){
			if (par[v] == -1){
				par[v] = u;
				frontier.push(v);
			} 
		}
	}
}

int main(){
	ios_base::sync_with_stdio(false); cin.tie(NULL);
	cin >> n >> m;
	int a, b;
	while(m--){
		cin >> a >> b;
		adj[a].push_back(b);
		adj[b].push_back(a);
	}
	memset(par, -1, sizeof par);
	bfs(1);
	bool invalid = any_of(par + 1, par + n + 1, [](int i){
		return i == -1;
	});
	if (invalid){
		cout << "No" << '\n';
	}
	else{
		cout << "Yes" << '\n';
		for (int i = 2; i <= n; ++i){
			cout << par[i] << '\n';
		}
	}
	return 0;
}


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

typedef long long ll;
typedef pair<int, int> ii;

vector<vector<ii>> g;
vector<int> ans;
int mx = 0;
void dfs(int u, int p, int usedColor)
{
    int idx = 1;
    for (auto cur : g[u]) {
        int v = cur.first;
        int edgeNumber = cur.second;
        if (v == p) // skip parent
            continue;
        if (p == -1) {
            ans[edgeNumber] = idx;
            mx = max(mx, idx);
            dfs(v, u, idx);
            idx++;
        } else {
            if (usedColor == idx)
                idx++;
            mx = max(mx, idx);
            ans[edgeNumber] = idx;
            dfs(v, u, idx);
            idx++;
        }
    }
}

int main()
{
    int n;
    scanf("%d", &n);

    g = vector<vector<ii>>(n, vector<ii>());
    ans = vector<int>(n - 1, -1);
    for (int i = 0; i < n - 1; i++) {
        int u, v;
        scanf("%d %d", &u, &v);
        u--;
        v--;

        g[u].push_back(ii(v, i));
        g[v].push_back(ii(u, i));
    }

    dfs(0, -1, -1);

    printf("%d\n", mx);
    for (int i = 0; i < n - 1; i++)
        printf("%d\n", ans[i]);

    return 0;
}


Measured memory_bytes: 8320
#include <stdio.h>
#include <string.h>
#include <stdlib.h>

#define MOD 1000000007

int main(void){

    int n;
    int i;
    long long ans = 0;

    scanf("%d",&n);

    long long p[n];
    long long b[n+1];

    b[1] = 0;

    for(i=0;i<n;i++){
        scanf("%lld",&p[i]);
        b[i + 1] = b[i] + p[i];
    }

    i = 0;
    do{
        long long sum = (b[n]-b[i+1]) % MOD;
        ans += p[i] * sum;
        ans %= MOD;
        i++;
    }while(i<n-1);

    printf("%lld",ans);
    return 0;
}

Measured memory_bytes: 4852
#include <iostream>
#include <stdio.h>
#include <vector>
#include <algorithm>
#include <cmath>
#define rep(i,cc,n) for(int i=cc;i<=n;++i)
#define drep(i,cc,n) for(int i=cc;i>=n;--i)
typedef long long ll;
using namespace std;
int main(){
    string s;
    cin>>s;
    int cnt=0;
    bool flag=true;
    char ans[30];
    for(char i='a';i<='z';i++){
        flag = true;
        for(int j=0;j<s.size();j++){
            if(s[j] == i){
                flag = false;
                break;
            }
        }
        if(flag==true){
            ans[cnt] = i;
            cnt++;
        }
    }
    //cout<<cnt<<endl;
    if(cnt==0) cout<<"None"<<endl;
    else cout<<ans[0]<<endl;
    return 0;
}

Measured memory_bytes: 512
#include<bits/stdc++.h>
using namespace std;
#define forn(i, n)             for(int i = 0; i < n; i ++)
#define forn1(i, n)            for(int i = 1; i <= n; i ++)
#define loop(i, sta, end, inc) for(int i = sta; i <= end; i += inc)
#define itr(it, l)             for(auto it = l.begin(); it != l.end(); it ++)
#define in(a, b, c)            assert( b <= a && a <= c)
#define pb push_back
#define ll long long int
#define fi first
#define se second
#define ii  pair<long long int, long long int>
#define vi  vector <long long int>
#define vii vector <pair <long long int, long long int > >
#define all(cont)  cont.begin(), cont.end()
#define rall(cont) cont.end(), cont.begin()
#define what_is(x) cerr<<#x<<" ="<<x<<" ";
#define error(args...)  { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args); }
#define LINT_MAX  9223372036854775807
#define LINT_MIN -9223372036854775808
#define EPS 1e-9
#define MOD 1000000007
#define DEBUG 0

template<typename T, typename U> inline void amin(T &x, U y) { if(y < x) x = y; }
template<typename T, typename U> inline void amax(T &x, U y) { if(x < y) x = y; }
void err(istream_iterator<string> it) { cerr<<endl;}
template<typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args) {
    if(DEBUG == 0)return;
	cerr << *it << " = " << a <<" ";
	err(++it, args...);
}

vector<int> A[1000001];
long long dp[100001][2];
int visited[100001];

void fun(int x,int rt){
	visited[x]=1;
	for(int i=0;i<A[x].size();i++)
	{
		if(visited[A[x][i]]==0){
			fun(A[x][i],rt);
			dp[x][0]=(dp[x][0]%MOD*(dp[A[x][i]][0]+dp[A[x][i]][1])%MOD)%MOD;
			dp[x][1]=(dp[x][1]%MOD*(dp[A[x][i]][0]%MOD))%MOD;
		}
	}
}
int main(){
   // freopen("test.txt", "r", stdin);
    int n;cin>>n;
    forn(i,n-1){
    	int x,y;cin>>x>>y;
    	A[x].push_back(y);
  		A[y].push_back(x);
    }
    forn(i,n+1){visited[100001]=0;forn(j,2)dp[i][j]=1;}
    fun(1,1);
    cout<<(dp[1][1]%MOD+dp[1][0]%MOD)%MOD<<endl;

    
    return 0;
}



Measured memory_bytes: 34304
////////////////////////// Author
////////////////////////// Nasim Hossain Rabbi
////////////////////////// JU-CSE28
////////////////////////// CF - imnasim3.1415
////////////////////////// UVA - imnasim3.1415
////////////////////////// Mail - imnasim3.1415@gmail.com
#include<bits/stdc++.h>
using namespace std;
#define sz size()
#define mk make_pair
#define clr clear()
#define B begin()
#define E end()
#define EM empty()
#define mem(a,b) memset(a,b,sizeof(a))
#define rep(i,n) for(i=0;i<n;i++)
#define Rep(i,n) for(i=1;i<=n;i++)
#define all(cont) cont.begin(),cont.end()
#define pb push_back
string en="\n";
string t="hello";
#define sqr(a) ((a) * (a))
#define fast ios_base::sync_with_stdio(false); cin.tie(NULL);cout.tie(NULL)
#define pi 3.1415926535897932384626433832795
#define vi vector<int>
#define vl vector<long long>
#define vs vector<string>
#define vp(vi,x) cin>>x; vi.pb(x);
#define LB(a,x) (lower_bound(aov(a),x)-a.begin())
#define UB(a,x) (upper_bound(aov(a),x)-a.begin())
typedef long long LL;
typedef unsigned long long ULL;
bool isVowel(char ch){ ch=toupper(ch); if(ch=='A'||ch=='U'||ch=='I'||ch=='O'||ch=='E') return true; return false;}
int toInt(string s){int sm;stringstream ss(s);ss>>sm;return sm;}
template<typename T>inline T gcd(T a,T b){if(a<0)return gcd(-a,b);if(b<0)return gcd(a,-b);return (b==0)?a:gcd(b,a%b);}
template<typename T>inline T lcm(T a,T b) {if(a<0)return lcm(-a,b);if(b<0)return lcm(a,-b);return a*(b/gcd(a,b));}
int main()
{
//    fast;
    LL i,j,k,n,m,l,s=0,x,y,tc=1,c=0;
    while(cin>>i>>j>>k>>x>>y)
    {
        s=0;
        c=INT_MAX;
        l=min(x,y);
        s=l*2*k;
        s+=(x-l)*i;
        s+=(y-l)*j;
        if(s<c) c=s;
        s=i*x+j*y;
        if(s<c) c=s;
        l=max(x,y);
        s=k*l*2;
        if(s<c) c=s;
        cout<<c<<en;
    }
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
const int Maxn = 200 + 100;
int A[Maxn];
int N;
int main()
{
#ifdef hk_cnyali
	freopen("A.in", "r", stdin);
	freopen("A.out", "w", stdout);
#endif
	scanf("%d", &N);
	N *= 2;
	for (int i = 1; i <= N; ++i)
		scanf("%d", &A[i]);
	sort(A + 1, A + N + 1);
	int Ans = 0;
	for (int i = 1; i <= N; i += 2)
		Ans += A[i];
	cout<<Ans<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <stdlib.h>
#include <utility>
#include <math.h>
#include <stdexcept>
#include <algorithm>
#define   FOR(i,n) for(int i=0;i<n;i++)

using namespace std;
int int_sort(const void*a,const void *b) {
    return *(  int *) b - *(int *) a;
    //qsort(b, a, sizeof(long long int), int_sort);
}

int main() {
    int N, max, sum = 0;
    cin >> N;
    int L[1000];
    FOR(i, N) {
        cin >> L[i];
        sum+=L[i];
        if (i == 0)
            max = L[i];
        else if (max < L[i])
                max = L[i];
    }
    if (sum - max > max) {
        cout <<"Yes";
        return 0;
    } else {
    cout << "No";
    return 0;
}
}







Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <stack>
#include <map>
#include <tuple>
#include <cmath>
#include <cstdio>
#include <cassert>
#include <functional>
#define _LIBCPP_DEBUG 0
using namespace std;


int main(void){
    int n,k,q;
    cin >> n >> k >> q;

    vector<int> ans_num(n);
    for (int i = 0; i < q; i++)
    {
        int a;
        cin >> a;
        ans_num.at(a-1)++;
    }
    
    for (int i = 0; i < n; i++)
    {
        if (k-(q-ans_num.at(i))>0)
        {
            cout << "Yes" << endl;
        }
        else
        {
            cout << "No" << endl;
        }
        
    }
    
    
}


Measured memory_bytes: 3792
#include <bits/stdc++.h>
#define ll long long
#define pb push_back
#define f first
#define s second
using namespace std;
	
int main(){
	double a, b, c, d;
	cin >> a>> b>>c>>d;
	cout << (a*b)/2 << " ";
	if(c+c == a && d+d == b)cout << 1 << endl;
	else cout << 0 << endl;
	return 0;
}                  
















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

#define INF 0x7fffffff

int main() {
	long long		a,b,c,i,j,k,n,m,x,y,ans1 , ans = 0;
	string	str;
	
	cin >> n;
	map<int,int> mmp;
	vector<int> aa(n);
	
	for(i=0;i<n;i++) {
		cin >> aa[i];
		mmp[ aa[i] ]++;
	}
	
	for ( auto pp : mmp) {
		long long j = pp.second;
		ans += j*(j-1)/2;
	}
	
	
	for(i=0;i<n;i++) {
		long long j = mmp[ aa[i] ];
		if (j>=2) {
			ans1 = ans - j*(j-1)/2 + (j-1)*(j-2)/2;
		} else {
			ans1 = ans;
		}
		cout << ans1 << endl;
	}

}


Measured memory_bytes: 8320
n=int(input())
l=[]
for i in range(n):
  l.append(list(map(int,input().split())))
ans=0
if n==2:
  print(((l[0][0]-l[1][0])**2+(l[0][1]-l[1][1])**2)**(1/2))
else:
  for i in range(n-1):
    for j in range(i+1,n):
      ans+=((l[i][0]-l[j][0])**2+(l[i][1]-l[j][1])**2)**(1/2)
  print(2*ans/n)

Measured memory_bytes: 3064
#include <iostream>
using namespace std;
int main(){
    int n,z;cin>>n>>z;
    if(n){
        if(n==1){
            cout << 1867+z << endl;
        }else if(n==2){
            cout << 1911+z << endl;
        }else if(n==3){
            cout << 1925+z << endl;
        }else{
            cout << 1988+z << endl;
        }
    }else{
        if(z < 1912){
            cout << "M" << z-1867 << endl;
        }else if(z < 1926){
            cout << "T" << z-1911 << endl;
        }else if(z < 1989){
            cout << "S" << z-1925 << endl;
        }else{
            cout << "H" << z-1988 << endl;
        }
    }
}


Measured memory_bytes: 3112
#!/usr/bin/env python3
# -*- coding: utf-8 -*-

import array
from bisect import *
from collections import *
import fractions
import heapq 
from itertools import *
import math
import random
import re
import string

def solve():
    N = int(input())
    t, x, y = 0, 0, 0
    for _ in range(N):
        nt, nx, ny = map(int, input().split())
        # print("{} {} {} -> {} {} {}".format(t, x, y, nt, nx, ny))
        dt = nt - t
        if abs(nx - x) + abs(ny - y) > dt or \
           (abs(nx - x) + abs(ny - y) - dt) % 2 == 1:
            return False
        else:
            t, x, y = nt, nx, ny
    return True


if solve():
    print("Yes")
else:
    print("No")



Measured memory_bytes: 7968
#include<stdio.h>
int main(){
	double a,b,c,d,e,f;
	while(scanf("%lf%lf%lf%lf%lf%lf",&a,&b,&c,&d,&e,&f)!=-1){
		printf("%.3lf %.3lf\n",(c*e-f*b)==0?0:(c*e-f*b)/(a*e-d*b),(c*d-a*f)==0?0:(c*d-a*f)/(b*d-a*e));
	}
	return 0;
}

Measured memory_bytes: 2676
#include<iostream>
#include<cstdio>
#include<algorithm>
using namespace std;
int main(void)
{
	int N[31]={0},a=0;
	for(int i=1;i<29;i++)
	{
		scanf("%d",&a);
		N[a]=1;
	}
	for(int i=1;i<31;i++)
	{
		if(N[i]!=1){printf("%d\n",i);}
	}
	return 0;
}
//前回記録31:37.770クリア
//3分25秒クリア


Measured memory_bytes: 3220
#include <iostream>
#include <algorithm>
#include <string>
#define rep(i, a, n) for(int i = a;i < n;i++)
using namespace std;


int a, b;
string s;


bool solve(){
	rep(i, 0, a)
		if(!('0' <= s[i] && s[i] <= '9'))
			return false;
	if(s[a] != '-') return false;
	rep(i, a+1, a+b+1){
		if (!('0' <= s[i] && s[i] <= '9'))
			return false;
	}
	return true;
}


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

	if(solve()) cout << "Yes" << endl;
	else cout << "No" << endl;

	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <cmath>
#include <functional>
#include <set>
#include <numeric>
#define ll long long int
#define rep(i,n) for(int i=0;i<n;i++)
using namespace std;

int main() {
	ll a, ans = 0;
	double b, x;

	cin >> a >> b;

	x = 100*b+0.5;
	ans = (a*(ll)x)/100;
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 3724
#include <iostream>
#include <algorithm>
#include <cstring>
using namespace std;

int n, c;
int a[31], b[31];
int dp[31][1 << 16];

void solve(){
  memset(dp, -1, sizeof(dp));
  dp[0][0] = 0;

  for(int i = 0; i < n; i++){
    for(int j = 0; j < (1 << 16); j++){
      if(dp[i][j] == -1) continue;

      int nj = (j | a[i]);

      for(int k = 0; k < c; k++){
        int cal = (nj & b[k]);
        int pop = __builtin_popcount(cal);
        dp[i + 1][nj - cal] = max(dp[i + 1][nj - cal], dp[i][j] + pop);
      }
    }
  }

  int ans = 0;
  for(int i = 0; i < (1 << 16); i++){
    ans = max(ans, dp[n][i]);
  }
  cout << ans << endl;
}

int main(){
  while(cin >> n >> c, n){
    for(int i = 0; i < n; i++){
      a[i] = 0;
      for(int j = 0; j < 16; j++){
        int x;
        cin >> x;
        a[i] = (a[i] << 1) + x;
      }
    }

    for(int i = 0; i < c; i++){
      b[i] = 0;
      for(int j = 0; j < 16; j++){
        int x;
        cin >> x;
        b[i] = (b[i] << 1) + x;
      }
    }

    solve();
  }
}

Measured memory_bytes: 9108
N=gets.to_i
M=10**9+7
*F=I=[r=1,1]
*R=I
2.upto(N){|i|I<<z=M/i*-I[M%i]%M;F<<r=r*i%M;R<<z*R[-1]%M}
(-~N/2...N).each{|i|r-=F[i-1]*R[2*i-N]*F[i]%M}
p r%M
###############################################
###############################################
###############################################
###############################################
###############################################

Measured memory_bytes: 27244
N = int(input())
H = list(map(int, input().split()))

is_fail = False

for i in list(range(1, N))[::-1]:
    if H[i-1] <= H[i]:
        continue
    elif H[i-1] == H[i] + 1:
        H[i-1]  -= 1
    if H[i-1] > H[i]:
        is_fail = True
        break

if not is_fail:
    print('Yes')
else:
    print('No')


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

int main(){
    int n,k;
    cin >> n >>k;
    vector<int64_t> h(n);
    int64_t ans=0;
    for(int i=0;i<n;i++){
        cin >> h.at(i);
        //cout << "h.at({0})=" << h.at(i) << endl;
    }

    if(n<k) {cout << 0 << endl; return 0;}
    else{
        sort(h.begin(),h.end(),greater<int>());
        ans=accumulate(h.begin()+k,h.end(),0LL);
        cout << ans << endl;
        return 0;
    }
}

Measured memory_bytes: 1792
package main

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

func main() {
	a, b, c := getInt(), getInt(), getInt()
	x, y := getInt(), getInt()
	ab := c * 2

	ans := 1 << 60
	for z := 0; z <= max(x, y); z++ {
		cand := ab*z + max(0, a*(x-z)) + max(0, b*(y-z))
		ans = min(ans, cand)
	}

	fmt.Println(ans)
}

func min(ns ...int) int {
	min := ns[0]
	for i := 1; i < len(ns); i++ {
		if min > ns[i] {
			min = ns[i]
		}
	}
	return min
}

func max(a, b int) int {
	if a > b {
		return a
	}
	return b
}

// -----------------------------------------

var sc = bufio.NewScanner(os.Stdin)

func init() {
	// buf := 200001
	// sc.Buffer(make([]byte, buf), buf)
	sc.Split(bufio.ScanWords)
}

func getInt() int {
	i, err := strconv.Atoi(getString())
	if err != nil {
		panic(err)
	}
	return i
}

func getString() string {
	sc.Scan()
	s := sc.Text()
	return s
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
#define For(i, a, b) for(int (i)=(a); (i)<(b); ++(i))
#define rFor(i, a, b) for(int (i)=(a)-1; (i)>=(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;
typedef long long lint;
typedef pair<int, int> pii;
typedef pair<pii, int> ppi;
typedef struct UnionFindTree{
    int n;
    vector<int> par;

    UnionFindTree(int n_){
        n = n_;
        par.resize(n, -1);
    }

    int find(int x){
        if(par[x] < 0) return x;
        return par[x] = find(par[x]);
    }

    bool unite(int x, int y){
        x = find(x);
        y = find(y);
        if(x == y) return false;
        if(par[x] < par[y]){
            par[x] += par[y];
            par[y] = x;
        }
        else{
            par[y] += par[x];
            par[x] = y;
        }
        return true;
    }
}UF;

int h, w;
char grid[410][410];
UF uf(200000);

int main(){
    scanf("%d%d", &h, &w);
    rep(i, h)rep(j, w) scanf(" %c", &grid[i][j]);
    rep(i, h)rep(j, w-1)if(grid[i][j] != grid[i][j+1]) uf.unite(i*w+j, i*w+j+1);
    rep(i, h-1)rep(j, w)if(grid[i][j] != grid[i+1][j]) uf.unite(i*w+j, (i+1)*w+j);
    lint ans = 0;
    lint cnt[h*w][2];
    rep(i, h*w)rep(j, 2) cnt[i][j] = 0LL;
    rep(i, h)rep(j, w) ++cnt[uf.find(i*w+j)][grid[i][j]=='.' ? 0 : 1];
    rep(i, h)rep(j, w)if(uf.par[i*w+j] < 0){
        ans += cnt[i*w+j][0] * cnt[i*w+j][1];
    }
    printf("%lld\n", ans);
}

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

using namespace std;

int main(){
    int n;
    cin>>n;
    string s;
    cin>>s;
    int count=0;
    for(int i=0;i<n-2;i++) {
        if (s[i] == 'A' && s[i + 1] == 'B' && s[i + 2] == 'C')
            count++;
    }
    cout<<count;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<string,int>;
using T = tuple<string,int,int>;

int main(){
  string s; cin >> s;
  sort(s.begin(), s.end());
  if(s[0] == s[1] && s[2] == s[3] && s[1] != s[2]){
    cout << "Yes" << endl;
  }else{
    cout << "No" << endl;
  }
  return 0;
}


Measured memory_bytes: 256
#include <cstdio>

void call(int x) 
{
	int i = x;
	if (i % 3 == 0)
		printf(" %d", x);
	else {
		do {
			if (i % 10 == 3) {
				printf(" %d", x);
				break;
			}	
			i /= 10;
		} while(i);
	}
}

int main()
{
	int i = 1;
	int n;

	scanf("%d", &n);

	for (i = 1; i <= n; i++)
		call(i);

	printf("\n");

	return 0;
}


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

long long int MOD = 1000000007;

int main() {
  long long int N, M;
  cin >> N >> M;
  
  if (abs(N - M) >= 2) cout << 0 << endl;
  
  else if (abs(N - M) == 1) {
    long long int fN = 1, fM = 1;
    for (long long int i = 1; i <= N; i++) {
      fN *= i;
      fN %= MOD;
    }
    for (long long int i = 1; i <= M; i++) {
      fM *= i;
      fM %= MOD;
    }
    cout << fN * fM % MOD;
  }
  
  else {
    long long int fN = 1;
    for (long long int i = 1; i <= N; i++) {
      fN *= i;
      fN %= MOD;
    }
    cout << fN * fN * 2 % MOD << endl;
  }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
 
#ifndef LOCAL_
#define fprintf if( false ) fprintf
#endif // LOCAL_
#define dump() fprintf(stderr, "#%s.%d\n", __func__, __LINE__);
#define dumpl(x1) fprintf(stderr, "#%s.%d (%s) = (%ld)\n", __func__, __LINE__, #x1, x1);
#define dumpll(x1, x2) fprintf(stderr, "#%s.%d (%s, %s) = (%ld, %ld)\n", __func__, __LINE__, #x1, #x2, x1, x2);
#define dumplll(x1, x2, x3) fprintf(stderr, "#%s.%d (%s, %s, %s) = (%ld, %ld, %ld)\n", __func__, __LINE__, #x1, #x2, #x3, x1, x2, x3);
#define dumpd(x1) fprintf(stderr, "#%s.%d (%s) = (%lf)\n", __func__, __LINE__, #x1, x1);
#define dumpdd(x1, x2) fprintf(stderr, "#%s.%d (%s, %s) = (%lf, %lf)\n", __func__, __LINE__, #x1, #x2, x1, x2);
#define loop for(;;)
 
struct S002 {
  int n;
  S002& operator > (long& x) {
    n = x;
    return *this;
  }
  S002& operator > (long&& x) {
    n = x;
    return *this;
  }
  S002& operator >= (long& x) {
    if( scanf("%ld", &x) <= 0 ) exit(0);
    return *this;
  }
  S002& operator >= (double& x) {
    if( scanf("%lf", &x) <= 0 ) exit(0);
    return *this;
  }
  S002& operator >= (std::string& s) {
    if( not (std::cin >> s) ) exit(0);
    return *this;
  }
  template<typename a>
  S002& operator >= (std::vector<a>& v) {
    v.resize(n);
    for(long i = 0; i < n; ++i) {
      *this >= v[i];
    }
    return *this;
  }
  template<typename a, std::size_t s>
  S002& operator >= (std::array<a, s>& x) {
    for(long i = 0; i < (long)s; ++i) {
      *this >= x[i];
    }
    return *this;
  }
};

struct Solver {
  long x, y;
  Solver() {
    S002 reader;
    reader >= x >= y;
    // reader >= n >n>= ys;
  }
  long sign(long x) {
    if( x > 0 ) return 1;
    if( x < 0 ) return -1;
    return 0;
  }
  long game(long x, long y) {
    if( x > y ) return game(y, x);
    for(long i = 1; i < x / 2; ++i) {
      if( game(x - 2 * i, y + i) < 0 ) return 1;
    }
    for(long i = 1; i < y / 2; ++i) {
      if( game(x + i, y - 2 * i) < 0 ) return 1;
    }
    return -1;
  }
  void solve() {
    puts(((x <= 3 and y <= 3) or std::abs(x-y) <= 1 ) ? "Brown" : "Alice");
        
    // for(long x = 0; x < 20; ++x) {
    //   for(long y = 0; y < 20; ++y) {
    //     printf("%2ld ", game(x, y));
    //   }
    //   printf("\n");
    // }
    // long res = std::min(solve1(), solve2());
    // printf("%ld\n", res);
  }    
  ~Solver() { fprintf(stderr, "--end--\n"); }
};
 

int main() {
  loop std::unique_ptr<Solver>(new Solver())->solve();
  return 0;
}

Measured memory_bytes: 256
import java.io.*;

public class Main
{
	public static void main(String[] args)throws IOException
	{
		BufferedReader br=
		new BufferedReader(new InputStreamReader(System.in));
		
		String str1=br.readLine();
		String[] strs=str1.split(" ",2);
		long[] nums =new long[2];
		for(int i=0;i<2;i++){
			nums[i]=Long.parseLong(strs[i]);
		}
		if(nums[0]>nums[1]){
			nums[0]=nums[0]%nums[1];}
		
		System.out.println(Math.min(nums[0],(nums[1]-nums[0])));
	}
}


Measured memory_bytes: 21200
#include <iostream>
using namespace std;
int main(void){
    int n;
    cin >> n;
    int a[n];
    for(int i=0;i<n;i++){
        cin >> a[i];
    }
    
    for(int i=1;i<=n;i++){
        if(i==n){
            cout << a[n-i];
        }
        else{
            cout << a[n-i] << " ";
        }
    }
    cout << endl;
}



Measured memory_bytes: 3076
#include<bits/stdc++.h>
using namespace std;
#define fi first
#define se second
#define fastio ios_base::sync_with_stdio(false); cin.tie(0)
#define loop(i, a, b) for(lli i=a; i<b; i++)
#define loopb(i, a, b) for(lli i=a; i>=b; i--)
#define pb push_back
#define umap unordered_map
typedef long long int lli;
typedef pair<lli, lli> pii;
typedef vector<lli> vll;
// use to avoid collision
struct custom_hash {
    static uint64_t splitmix64(uint64_t x) {
        // http://xorshift.di.unimi.it/splitmix64.c
        x += 0x9e3779b97f4a7c15;
        x = (x ^ (x >> 30)) * 0xbf58476d1ce4e5b9;
        x = (x ^ (x >> 27)) * 0x94d049bb133111eb;
        return x ^ (x >> 31);
    }
 
    size_t operator()(uint64_t x) const {
        static const uint64_t FIXED_RANDOM = chrono::steady_clock::now().time_since_epoch().count();
        return splitmix64(x + FIXED_RANDOM);
    }
};
// for pair in unordered_map
struct hash_pair {
    static uint64_t splitmix64(uint64_t x) {
    // http://xorshift.di.unimi.it/splitmix64.c
    x += 0x9e3779b97f4a7c15;
    x = (x ^ (x >> 30)) * 0xbf58476d1ce4e5b9;
    x = (x ^ (x >> 27)) * 0x94d049bb133111eb;
    return x ^ (x >> 31);
	}
    template <class T1, class T2>
    size_t operator()(const pair<T1, T2>& p) const{
        auto hash1 = hash<T1>{}(p.first);
        auto hash2 = hash<T2>{}(p.second);
        uint64_t x = hash1 ^ hash2;
        static const uint64_t FIXED_RANDOM = chrono::steady_clock::now().time_since_epoch().count();
        return splitmix64(x + FIXED_RANDOM);
    }
};
lli M = 1e9 + 7;
lli power(lli x, lli y){
    lli res = 1;
    x = x ;
    while (y > 0) {
        if (y & 1)
            res = (res*x)%M;
        y = y>>1;
        x = (x*x)%M;
    }
    return res%M;
}
lli solve(){
	lli m, n;
	cin>>m>>n;
	if(m == n)
		cout<<"Yes\n";
	else
		cout<<"No\n";
}
int main(){
	fastio;
	lli t;
	// cin>>t;
	t = 1;
	while(t>0){
		t--;
		solve();
	}
}

Measured memory_bytes: 256
import java.util.*;
import javax.lang.model.util.ElementScanner6;

public class Main {

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

        // 入力
        int n = sc.nextInt();
        int k = sc.nextInt();

        // 処理
        int out = 0;
        while (n >= k) {
            n /= k;
            out++;
        }
        out += 1;


        // 出力
        System.out.println(out);
    }

}

Measured memory_bytes: 21588
#include <bits/stdc++.h>
using namespace std;
int main()
{
    long long n, k;
    cin >> n >> k;
    pair<int, int> p[n];
    for (int i = 0; i < n; i++)
    {
        cin >> p[i].first >> p[i].second;
    }
    sort(p, p + n);
    long long ans = -1;
    long long i = 0;
    while (k > 0)
    {
        ans = p[i].first;
        k -= p[i].second;
        i++;
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 1024
#include<bits/stdc++.h>
#define ll long long
using namespace std;
const int N=1005;
struct st{
	ll x,y,z;
}s[N];
ll ans,n,m,i,j,k;
inline bool cmp(st a,st b){return a.x*i+a.y*j+a.z*k>b.x*i+b.y*j+b.z*k;}
int main()
{
	cin>>n>>m;
	for(i=0;i<n;i++)cin>>s[i].x>>s[i].y>>s[i].z;
	for(i=-1;i<=1;i+=2)
	{
		for(j=-1;j<=1;j+=2)
		{
			for(k=-1;k<=1;k+=2)
			{
				sort(s,s+n,cmp);
				ll resa=0,resb=0,resc=0;
				for(int l=0;l<m;l++)
				{
					resa+=s[l].x;
					resb+=s[l].y;
					resc+=s[l].z;
				}
				ll res=abs(resa)+abs(resb)+abs(resc);
				ans=max(ans,res);
			}
		}
	}
	cout<<ans<<endl;
	return 0;
}

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

using namespace std;

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

    int n;
    long long a[100010];
    long long cnt = 1;
    long long ans = 0;

    cin >> n;

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

    sort(a,a+n);

    
    for (int i = 1;i < n;i++){
        if (a[i] == a[i-1]) cnt++;
        else{
            if (a[i-1] > cnt) ans += cnt;
            else ans += cnt - a[i-1];
            cnt = 1;
        } 
    }
    if (a[n-1] > cnt) ans += cnt;
    else ans += cnt - a[n-1];

    cout << ans << endl;

    return 0;

}

Measured memory_bytes: 1024
#include <cstdio>

int k,s,ans;

int main()
{
    scanf("%d%d",&k,&s);
    for(int i=0;i<=k;++i)
        for(int j=0;j<=k;++j)
            if(i+j<=s&&s<=i+j+k)
                ++ans;
    printf("%d",ans);
}

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

using namespace std;
typedef long long ll;
const ll INF = 1e9;
 
int main(void) {
    string S; cin >> S;
    bool flag = true;

    for (int i = 0; i < S.size(); i++) {
        char Si = S[i];
        if (i % 2 == 0) {
            if (Si == 'L')
                flag = false;
        } else {
            if (Si == 'R')
                flag = false;
        }
    }

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

Measured memory_bytes: 256
n = int(input())
a = list(map(int, input().split()))
l = [0]*(10**5+3)
for i in range(n):
  l[a[i]] += 1
  l[a[i]+1] += 1
  l[a[i]+2] += 1
max_ = 0
for e in l:
  max_ = max(max_, e)
print(max_)

Measured memory_bytes: 84548
#include <iostream>
#include <vector>
#include <cstring>
typedef long long ll;

using namespace std;
int N, M; //boxes, keys
ll dp[2][1<<12];
ll unlock;
ll INF = 0x3f3f3f3f3f3f3f3f;
int main() {
    scanf("%d %d", &N, &M);
    ll a, b;
    memset(dp, INF, sizeof(dp));
    dp[0][0] = 0;
    for (int i=1; i<=M; i++){
        scanf("%lld %lld", &a, &b);
        unlock = 0;
        ll c;
        for (ll j=0; j<b; j++){
            scanf("%lld", &c);
            unlock |= (1<<(c-1));
        }
        for (int j=0; j<=(1<<N)-1; j++) dp[i%2][j] = dp[(i+1)%2][j];
        for (ll j=1; j<=(1<<N)-1; j++){
                if (unlock & j) {
                    dp[i%2][j] = min(dp[i%2][j], dp[(i + 1)%2][j ^ (unlock & j)] + a);
                }
        }
    }
    if (dp[M%2][(1<<N)-1] == INF) printf("-1\n");
    else printf("%lld\n", dp[M%2][(1<<N)-1]);
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
	int a,b,c,d,e,f;
	cin>>a>>b>>c>>d>>e>>f;
	bool x[3001]={},y[3001]={};
	for(int i=0;100*a*i<=f;i++)
		for(int j=0;100*a*i+100*b*j<=f;j++)
			x[100*a*i+100*b*j]=true;
	for(int i=0;c*i<=f;i++)
		for(int j=0;c*i+d*j<=f;j++)
			y[c*i+d*j]=true;
	int ans1=100*a,ans2=0;
	for(int i=0;i<=f;i++)
		for(int j=0;j<=f;j++)
			if(x[i]&&y[j]&&ans2*(i+j)<j*ans1&&j*(e+100)<=(i+j)*e&&i+j<=f)
				ans1=i+j,ans2=j;
	cout<<ans1<<' '<<ans2<<endl;
}


Measured memory_bytes: 384
s = '0' + input()
m = len(s)
up = 0
cnt = 0
y = []
for i in range(-1, -m-1, -1):
    cs = int(s[i]) + up
    if cs < 5 or (cs == 5 and int(s[i-1]) < 5):
        cnt += cs
        y.append([cs, s[i]])
        up = 0
    else:
        cnt += 10 - cs
        y.append([10 - cs, s[i]])
        up = 1
        
print(cnt)

Measured memory_bytes: 272140
import sys
import math
import collections
import itertools
import array
import inspect

# Set max recursion limit
sys.setrecursionlimit(1000000)


# Debug output
def chkprint(*args):
    names = {
        id(v): k
        for k, v in inspect.currentframe().f_back.f_locals.items()
    }
    print(', '.join(
        names.get(id(arg), '???') + ' = ' + repr(arg) for arg in args))


# Binary converter
def to_bin(x):
    return bin(x)[2:]


def li_input():
    return [int(_) for _ in sys.stdin.readline().split()]


def gcd(n, m):
    if n % m == 0:
        return m
    else:
        return gcd(m, n % m)


def gcd_list(L):
    v = L[0]

    for i in range(1, len(L)):
        v = gcd(v, L[i])

    return v


def lcm(n, m):
    return (n * m) // gcd(n, m)


def lcm_list(L):
    v = L[0]

    for i in range(1, len(L)):
        v = lcm(v, L[i])

    return v

def comb(n, r):
    if n - r < r: r = n - r
    if r == 0: return 1
    if r == 1: return n

    numerator = [n - r + k + 1 for k in range(r)]
    denominator = [k + 1 for k in range(r)]

    for p in range(2, r + 1):
        pivot = denominator[p - 1]
        if pivot > 1:
            offset = (n - r) % p
            for k in range(p - 1, r, p):
                numerator[k - offset] /= pivot
                denominator[k] /= pivot

    result = 1
    for k in range(r):
        if numerator[k] > 1:
            result *= int(numerator[k])

    return result

def bisearch(L, target):
    low = 0
    high = len(L) - 1
    
    while low <= high:
        mid = (low + high) // 2
        guess = L[mid]
        if guess == target:
            return True
        elif guess < target:
            low = mid + 1
        elif guess > target:
            high = mid - 1
    if guess != target:
        return False

# --------------------------------------------

dp = None


def main():
    N = int(input())
    A = li_input()
    B = [abs(a) for a in A]

    n_negative = len([a for a in A if a < 0])

    if n_negative % 2 == 1:
        print(sum(B) - 2 * min(B))
    else:
        print(sum(B))


main()


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

int main()
{
    int k,n;
    cin >> k >> n;
    vector<int> a(n);

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

    //差を求めて一番大きいところを探す
    int longest = 0;
    rep(i,n -1) {
        int dis = abs(a[i + 1] - a[i]);
        if(longest < dis)
        {
            longest = dis;
        } 
    }

    int lastdis = abs(k - a[n -1] + a[0]);
    if(longest < lastdis)
    {
        longest = lastdis;
    } 

    cout << k - longest << endl;
}

Measured memory_bytes: 1024
s=gets.chomp.split("")
t=gets.chomp.split("")

idx=Hash.new { |h, k| h[k] = [] }

s=s+s
s.each_with_index do |c,i|
  idx[c] << i
end
l = []
t.each do |c|
  if idx[c].size == 0
    puts -1
    exit
  end

  if l.size == 0
    prev = -1
  else
    prev = l[-1]
  end
  
  tmp = idx[c].bsearch {|x| x >  prev}
  if tmp == nil
    l << idx[c][0]
  else
    l << tmp
  end
end

prev=Float::INFINITY
cnt = 0
l.each do |v|
  if prev > v
    cnt += 1
  end
  prev = v
end
puts s.size * (cnt-1) + l[-1] + 1

Measured memory_bytes: 19068
n_row, n_col = map(int, input().split(" "))
list_list_n = []
for i in range(n_row):
    list_list_n.append([int(_) for _ in map(int, input().split())])
    list_list_n[i].append(sum(list_list_n[i]))


list_sum = [0 for _ in range(n_col + 1)]
for list_n in list_list_n:
    for i, num in enumerate(list_n):
        if i == len(list_n) - 1:
            print(num, end="")
        else:
            print(num, end=" ")
        list_sum[i] += num
    print()

for j, sum_n in enumerate(list_sum):
    if j == len(list_sum) - 1:
        print(sum_n, end="")
    else:
        print(sum_n, end=" ")
print()


Measured memory_bytes: 6248
#include <iostream>
using namespace std;
int main(void){
    int a,b,c,d;
    int e,f,g,h;
    cin>>a>>b>>c>>d;
    cin>>e>>f>>g>>h;
    
    int S=a+b+c+d;
    int T=e+f+g+h;
    
    if(S>T){
        cout<<S<<endl;
    }
    
    else{
        cout<<T<<endl;
    }
}



Measured memory_bytes: 3100
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <map>
#include <set>
#include <cstdio>
#include <cmath>
#include <cstring>
#include <string>
#include <time.h>
 
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define FFOR(i,a,b) for(int i=(a);i<=(b);i++)
#define REP(i,b) FOR(i,0,b)
#define RREP(i,b) FFOR(i,1,b)
#define PB push_back
#define F first
#define S second
#define BE(c) c.begin(),c.end()
using namespace std;
typedef long long LL;
typedef double ut;
typedef long double ld;
typedef pair<ut,ut> pr;
typedef vector<pr> Vpr;
typedef vector<ut> VI;
typedef pair<ut,pr> ppr;
typedef priority_queue<pr,Vpr, greater<pr> > PQ;
const int SIZE=5+3*1e+4;
const ut INF=1<<30;
const ld eps=1e-6;
const LL mod=1e+9 + 7;

int main() {
	int n;
	cin >> n;
	FOR(i,1,100001){
		int cnt = 0;
		for(int j = 1; j <= i; ++j){
			if(i % j == 0)
				cnt++;
		}
		if(cnt == n){
			cout << i << endl;
			break;
		}
	}
	return 0;
}

Measured memory_bytes: 1160
#include<bits/stdc++.h>
using namespace std;
int main()
{
  string s,t;
  cin>>s>>t;
  if(t.length()!=s.length()+1)
  {
    cout<<"No";
    return 0;
  }
  if(t.substr(0,(int)s.length())==s)
     cout<<"Yes";
     else
     cout<<"No";
}

Measured memory_bytes: 3588
#include<bits/stdc++.h>
using namespace std;
int dp[100001];
int main(){
	#ifdef EVAL
	freopen("input.txt","r",stdin);
	freopen("output.txt","w",stdout);
	#endif
	int N;
	cin>>N;
	int vet[N];
	for(int i=0;i<N;i++){
		cin>>vet[i];
	}
	fill(dp,dp+N,INT_MAX);
	dp[0]=0;
	for(int i=0;i<N;i++){
		dp[i+1]=min(dp[i+1],dp[i]+abs(vet[i]-vet[i+1]));
		dp[i+2]=min(dp[i+2],dp[i]+abs(vet[i]-vet[i+2]));
	}
	cout<<dp[N-1];
}


Measured memory_bytes: 1024
# -*- coding: utf-8 -*-
n, m = map(int, input().split())
ck = set()
pe = 0
ac = 0
penalty = 0
cp = [0] * (n+1)
for i in range(m):
    p, s = input().split()
    p = int(p)
    if p in ck:
        continue

    if s == 'WA':
        cp[p] += 1
    else:
        penalty += cp[p]
        pe = 0
        ac += 1
        ck.add(p)

print(ac, penalty)


Measured memory_bytes: 18212
n,k = map(int,input().split())
a = [0]+list(map(int,input().split()))

def bin(arr,val):
    left,right = 0,len(arr)-1
    while left<=right:
        mid = (left+right)//2
        if arr[mid]==val: return 1
        elif arr[mid]<val: left = mid + 1
        else: right = mid - 1
    return 0

know = []
now = 1
while not bin(know, now):
    know.append(now)
    now = a[now]

start = a[know[-1]]
for i,num in enumerate(know):
    if num == start: loop = know[i:] ; break

#print(know,start,loop)

if k < len(know):
    ans = know[k]
else:
    k -= len(know)
    ans = loop[k%len(loop)]

print(ans)


Measured memory_bytes: 32388
#include<bits/stdc++.h>
using namespace std;
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
using namespace __gnu_pbds;   
#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>
#define ld double
#define ff first
#define ss second
#define pb push_back
#define mp make_pair
#define all(a) a.begin(),a.end()
#define sz(a) (ll)(a.size())
typedef long long ll;
typedef unsigned long long ull;
typedef pair <ll, ll> pll;
typedef vector<pll> vplll;
ll mod = 1e9+7;
ll m[105][100005];
ll cost(ll ar[][2], ll x, ll ans, ll k, ll n)
{
	if(m[k][x]!=-1)
		return m[k][x];
	if(k==n)
		return 0;
	if(x<ar[k][0])
		return cost(ar,x,ans,k+1,n);
	ll t,p;
	t = max(p=cost(ar,x,ans,k+1,n),ar[k][1]+cost(ar,x-ar[k][0],ans,k+1,n));
	if(t==p)
	m[k][x]= m[k+1][x];
	else
	m[k][x] = ans+t;
	return ans + t;
}
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    long long int a,b,c,x,n,t; 
    for(int j=0;j<105;j++)
    for(int i=0;i<100005;i++)
    	m[j][i]=-1;
    cin>>n>>x;
    ll ar[n][2];
    for(int i=0;i<n;i++)
    	cin>>ar[i][0]>>ar[i][1];
    a = cost(ar,x,0,0,n);
    cout<<a<<endl;
    return 0;
}

Measured memory_bytes: 82304
#include<unordered_map>
#include<unordered_set>
#include<algorithm>
#include<iostream>
#include<string>
using namespace std;

int func(int num){

    int sum = 0;
    int i = 1;

    while(num >= i*i){
        if(num % i == 0){
            if(num / i == i){
                sum += 1;
            }
            else{
                sum += 2;
            }
        }
        i++;
    }

    return sum;
}

int main(){
    
    int N = 0;

    cin>>N;

    int count = 0;

    for(int i = 1; i < N; i++){
        count += func(N - i);
    }

    cout<<count<<endl;
    return 0;
}

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

class Program
{
  public static void Main(string[] args)
  {
    int[] s = Console.ReadLine().Split().Select(int.Parse).ToArray();
    int n = s[0];
    int y = s[1];
    int a = 0;
    int b = 0;
    int c = 0;
    for (int i = 0; i <= n; i ++) {
      for (int j = 0; j <= n-i; j ++) {
        if (y == 10000 * i + 5000 * j + 1000 * (n-i-j) && n-i-j >= 0) {
          Console.WriteLine("{0} {1} {2}", i, j, n-i-j);
          goto end;
        }
        if (i == n && j == n-i) Console.WriteLine("-1 -1 -1");
      }
    }
    end:;
  }
}


Measured memory_bytes: 13396
n = int(input()) #このnは使わない
*A, = map(int, input().split())
maxA = max(A)

# 連想配列 [key : value]
# C[a : count]
C = {a : 0 for a in A}
#要素を見つけるたびに1増える
#重複がある場合はC[a] >= 2になる
#例えば5が4つ見つかると C[5] = 4
for a in A:
    C[a] += 1


D = {a : 0 for a in A}
#Aの数値をkeyとして扱う
for a in A:
    if C[a] > 0:
        t = 2
        while a*t <=maxA:
            #aの倍数にフラグを立てる
            # D[2]が存在する場合, D[4]やD[6]は約数が存在することになる
            D[a*t] = 1
            t += 1

ans = 0
for a in A:
    # 重複がないもので,約数が存在しないものが答え
    if C[a] == 1 and D[a] == 0:
        ans += 1
print(ans)


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

int main()
{
    int N, M ,C;
    int count = 0;
    int sum;
    cin >> N >> M >> C;
    int Aij;
    int j;
    vector<int> B(M);
    for(j =0; j< M; j++)
    {
        cin >> B.at(j);
    }
    for(int i=0; i < N; i++)
    {   
        sum = 0;
        for(j=0; j< M; j++)
        {
            cin >> Aij;
            sum += Aij * B.at(j);
        }
        sum += C;
        if(sum > 0)
        {
            count += 1;
        }
    }

    cout << count << endl;

    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <math.h>
 
int main(){
    int w, h;
    int i, j;
     
    while (1){
        scanf("%d %d", &h ,&w);
        if (w == 0 && h == 0) break;
 
 
        for (i = 0;i < h; i++){
            for (j = 0; j < w; j++){
                if ((i + j)%2==0){
                    printf("#");
                }else{
                    printf(".");
                }
            }
            printf("\n");
        }
 
        printf("\n");
    }
    return 0;
}

Measured memory_bytes: 572
# -*- coding: utf-8 -*-
n = int(input())
p = []
for i in range(n):
    q = input()
    p.append(q)
print("AC x "+str(p.count("AC")))
print("WA x "+str(p.count("WA")))
print("TLE x "+str(p.count("TLE")))
print("RE x "+str(p.count("RE")))

Measured memory_bytes: 16184
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <functional>

using namespace std;
 
#define mod 1000000007
#define FOR(x,to) for(int x=0;x<(to);x++)
#define FORR(x,arr) for(auto& x:arr)
#define ALL(a) (a.begin()),(a.end())
#define ZERO(a) memset(a,0,sizeof(a))
#define MINUS(a) memset(a,0xff,sizeof(a))
#define long long long
inline int rei(){int x;cin>>x;return x;}
inline long rel(){long x;cin>>x;return x;}
inline string res(){string x;cin>>x;return x;}
//------------------------------------------------------- 
void Calc(){
	string S = res();
	if(S[0] == S[1] || S[1] == S[2] || S[2] == S[3]){
		cout << "Bad" << endl;
	}
	else{
		cout << "Good" << endl;
	}
}
int main(int argc,char** argv){
	ios::sync_with_stdio(false), cin.tie(0);
	cout.tie(0); Calc(); return 0;
}

Measured memory_bytes: 256
using System;
using System.Collections;
using System.Collections.Generic;
using System.IO;
using System.Linq;

namespace C
{
    public class Program
    {
        static void Main(string[] args)
        {
            var sw = new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
            Console.SetOut(sw);
            Solve();
            Console.Out.Flush();
        }

        public static void Solve()
        {
            var n = long.Parse(Console.ReadLine());
            var capacities = new long[5];
            for (var i = 0; i < capacities.Length; i++)
            {
                capacities[i] = long.Parse(Console.ReadLine());
            }
            var time = 0L;
            // var current = new long[6];
            // current[0] = n;
            // while (current[5] < n)
            // {
            //     for (var i = current.Length - 1; i > 0; i--)
            //     {
            //         var move = Math.Min(current[i - 1], capacities[i - 1]);
            //         current[i] += move;
            //         current[i - 1] -= move;
            //     }
            //     time++;
            // }
            var min = capacities.Min();
            time = (long)Math.Ceiling(n / (double)min) + 4;

            Console.WriteLine(time);
        }
    }
}


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

#define int long long
#define rep(i, n) for (int i = 0; i < (n); i++)
#define reps(i, n) for (int i = 1; i <= (n); i++)
#define all(x) begin(x), end(x)
#define uniq(x) (x).erase(unique(all(x)), end(x))
#define bit(n) (1LL << (n))
#define cdiv(a, b) (((a) - 1) / (b) + 1)
#define dump(x) cerr << #x " = " << (x) << endl
using vint = vector<int>;
using vvint = vector<vint>;
using pint = pair<int, int>;
using vpint = vector<pint>;
template<typename T> using priority_queue_rev = priority_queue<T, vector<T>, greater<T>>;
constexpr long double PI = 3.1415926535897932384626433832795028L;
constexpr int DY[8] = {0, 1, 0, -1, 1, 1, -1, -1};
constexpr int DX[8] = {1, 0, -1, 0, 1, -1, -1, 1};
int gcd(int a, int b) {
    while (b) { swap(a %= b, b); }
    return a;
}
int lcm(int a, int b) { return a / gcd(a, b) * b; }
template<typename T> void fin(T mes) {
    cout << mes << endl;
    exit(0);
}
template<typename T, typename U> bool chmax(T &a, const U &b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
template<typename T, typename U> bool chmin(T &a, const U &b) {
    if (b < a) {
        a = b;
        return true;
    }
    return false;
}
template<typename T, typename U> ostream &operator<<(ostream &os, const pair<T, U> &rhs) {
    os << "(" << rhs.first << ", " << rhs.second << ")";
    return os;
}
template<typename T> ostream &operator<<(ostream &os, const vector<T> &rhs) {
    os << "{";
    for (auto itr = rhs.begin(); itr != rhs.end(); itr++) {
        os << *itr << (next(itr) != rhs.end() ? ", " : "");
    }
    os << "}";
    return os;
}
struct setup {
    static constexpr int PREC = 20;
    setup() {
        cout << fixed << setprecision(PREC);
        cerr << fixed << setprecision(PREC);
    };
} setup;

int K;
int N = 50;
int a[55];
signed main() {
    cin >> K;
    if (K < 550000) {
        if (K == 1) {
            fin("3\n1 0 3");
        }
        cout << 2 << endl;
        cout << 1 + K / 2 + 2 * (K % 2) << " " << 1 + K / 2 - 2 * (K % 2) << endl;
        return 0;
    }
    rep(i, K % 50) {
        a[i] += 51;
    }
    rep(i, 50) {
        a[i] += 49 + (K - K % 50 * 51) / 50;
    }
    cout << 50 << endl;
    rep(i, 50) { cout << a[i] << endl; }

}


Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<cstring>

const int N=301000;
int s[N];
int n,k;

void dec()
{
	int pos=n;
	while(s[pos]==0)pos--;
	s[pos]--;
	if(s[pos]==0)
	{
		
	}
	else for(int i=pos+1;i<=n;i++)
		s[i]=k;
}

int main()
{
	scanf("%d%d",&k,&n);
	if(k==1)
	{
		for(int i=1;i<=(n+1)/2;i++)printf("%d ",k);
		printf("\n");
	}
	else if(k%2==0)
	{
		printf("%d ",k/2);
		for(int i=2;i<=n;i++)
			printf("%d ",k);
		printf("\n");
	}
	else 
	{
		for(int i=1;i<=n;i++)
		{
			s[i]=(k+1)/2;
		}
		int tmp=n/2;
		while(tmp--)dec();
		for(int i=1;i<=n&& s[i];i++)
		{
			printf("%d ",s[i]);
		}
		printf("\n");
	}
	return 0;
}


Measured memory_bytes: 3456
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, s, n) for (int i = (s); i < (int)(n); i++)
#define all(x) (x).begin(), (x).end()

int main() {
    int N;
    cin >> N;
    int ans = 0;
    for (int j = 1; j <= N; j += 2) {
        int num = 0;
        rep(i,1,N+1) {
            if (j % i == 0) num++;
        }
        if (num == 8) ans++;
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
def solve():
    N = int(input())
    S = list(input())
    ans = 0

    i_tmp = []
    j_tmp = []
    for i in range(N-2):
        if S[i] in i_tmp:
            continue
        else:
            i_tmp.append(S[i])
            j_tmp.clear()
        for j in range(i+1, N-1):
            if S[j] in j_tmp:
                continue
            else:
                j_tmp.append(S[j])
                ans += len(set(S[j+1:]))
    print(ans)


if __name__ == '__main__':
    solve()

Measured memory_bytes: 3572