akhauriyash/Code-Regression huggingface dataset:
s=input()
a=0
ab=0
abc=0
total=1
mod=10**9+7
for i in range(len(s)):
    if s[i]=='A':
        a+=total
    elif s[i]=='B':
        ab+=a
    elif s[i]=='C':
        abc+=ab
    else:
        abc=3*abc+ab
        ab=3*ab+a
        a=3*a+total
        total*=3
    a%=mod
    ab%=mod
    abc%=mod
    total%=mod
print(abc)

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

using namespace std;
typedef long long ll;

const int MOD = 1e9+7;

int main() {
    int n;
    cin >> n;
    int flag = 1;
    for(int i = 0; i < n; i++){
        int a;
        cin >> a;
        if(a%2==0){
            if(a%3!=0 && a%5 !=0) flag = 0;
        }
    }
    cout << (flag ? "APPROVED" : "DENIED") << endl;
    
    return 0;
}

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

int main() {
  int n, m;
  cin >> n >> m;
  string ans = "No";
  if (n == m) ans = "Yes";
  cout << ans << endl;
}

Measured memory_bytes: 256
import java.util.*;

public class Main {

  static Scanner sc = new Scanner(System.in);

  public static void main(String[] args) {

    String S = sc.next();

    char[] ch = S.toCharArray();

    ArrayList list = new ArrayList();
    for (int i=0; i<ch.length; i++) {
      list.add(ch[i]);
    }

    for (int i=0; i<=list.size()-2; i++) {
      if (i<0) i = 0;
      if (list.get(i) != list.get(i+1)) {
        list.remove(i+1);
        list.remove(i);
        i -= 2;
      }
    }

    System.out.println(ch.length - list.size());

  }
}

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

int dfs(int H, int W, int K, char field[6][6+1], int h, int w) {
    int ans = 0;
    if (h == H) {
        if (w == W) {
            int s = 0;
            for (int i = 0; i < H; i++) {
                for (int j = 0; j < W; j++) {
                    if (field[i][j] == '#') {
                        s++;
                    }
                    // cout << field[i][j];
                }
                // cout << endl;
            }
            // cout << endl;
            return s == K;
        }
        ans += dfs(H, W, K, field, h, w+1);

        for (int i = 0; i < H; i++) {
            field[i][w] ^= 0x20;
        }
        ans += dfs(H, W, K, field, h, w+1);
        for (int i = 0; i < H; i++) {
            field[i][w] ^= 0x20;
        }
    } else {
        ans += dfs(H, W, K, field, h+1, w);

        for (int j = 0; j < W; j++) {
            field[h][j] ^= 0x10;
        }
        ans += dfs(H, W, K, field, h+1, w);
        for (int j = 0; j < W; j++) {
            field[h][j] ^= 0x10;
        }
    }

    return ans;
}

void solve(int H, int W, int K, char field[6][6+1]) {
    cout << dfs(H, W, K, field, 0, 0) << endl;
}

// Generated by 1.1.7.1 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
int main(){
    int H, W, K;
    cin >> H >> W >> K;
    char field[6][6+1];
    for (int i = 0; i < H; i++) {
        string s;
        cin >> s;
        strcpy(field[i], s.c_str());
    }
    solve(H, W, K, field);
    return 0;
}


Measured memory_bytes: 3632
# coding: utf-8
# util functions

# debug
$debugFlag = ( ARGV[0] != nil )
p "==== DEBUG MODE ====" if $debugFlag

def pd(str)
  p str if $debugFlag
end

def printd(str)
  print str if $debugFlag
end

# input
inputs = []
lc = 0
while l = $stdin.gets do
  if false
    inputs << l.chomp.split(" ").map(&:to_s)
  else
    inputs << l.chomp.split(" ").map(&:to_i)
  end
  lc += 1
end

# input check
if $debugFlag
  p "--- INPUT (begin) ---"
  inputs.each do |l_i|
    p l_i
  end
  p "--- INPUT (end) ---"
  print "\n"
end

nn = inputs[0][0]

# body
if $debugFlag
end

prime_list = [2,	3,	5,	7,	11,	13,	17,	19,	23,	29,	31,	37,	41,	43,	47,	53,	59,	61,	67,	71,
73,	79,	83,	89,	97,	101,	103,	107,	109,	113,	127,	131,	137,	139,	149,	151,	157,	163,	167,	173,
179,	181,	191,	193,	197,	199,	211,	223,	227,	229,	233,	239,	241,	251,	257,	263,	269,	271,	277,	281,
283,	293,	307,	311,	313,	317,	331,	337,	347,	349,	353,	359,	367,	373,	379,	383,	389,	397,	401,	409,
419,	421,	431,	433,	439,	443,	449,	457,	461,	463,	467,	479,	487,	491,	499,	503,	509,	521,	523,	541,
547,	557,	563,	569,	571,	577,	587,	593,	599,	601,	607,	613,	617,	619,	631,	641,	643,	647,	653,	659,
661,	673,	677,	683,	691,	701,	709,	719,	727,	733,	739,	743,	751,	757,	761,	769,	773,	787,	797,	809,
811,	821,	823,	827,	829,	839,	853,	857,	859,	863,	877,	881,	883,	887,	907,	911,	919,	929,	937,	941,
947,	953,	967,	971,	977,	983,	991,	997]

hash = {}
prime_list.each do |p_i|
  i = 1
  cur = p_i
  hash[p_i] = 0
  while cur <= nn
    if nn / cur
      hash[p_i] += nn/cur
    end
    cur *= p_i
  end
end

ans = 1
hash.each do |k, v|
  ans *= v + 1
  ans %= 1000000007
end

puts ans


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

const int MAX = 510000;
const int MOD = 1000000007;

long long fac[MAX], finv[MAX], inv[MAX];

// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

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

int main() {
    // 前処理
    COMinit();
    int s,m;
    cin>>s;
    m=s/3;
    long long ans=0;
    for(int i=0;i<=m;++i){
        ans+=COM(i+s-3*(i+1),i);
        ans%=MOD;
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 15544
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
using namespace std;

void solve1() {
	vector<long long> a(3);
	cin >> a[0] >> a[1] >> a[2];
	sort(a.begin(), a.end());
	//cout << a[2];
		if (a[2] % 2 == 0) {
		cout << 0 << endl;
	}
	else {
	
		cout << a[1]*a[0] << endl;
		
 	}
	
}

int main() {
	solve1();
	return 0;
}

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

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

ll H,W,N;
map<P,ll> um;

int main(){
    cin >> H >> W >> N;
    for(int i=0;i<N;i++){
        ll a,b;
        cin >> a >> b;
        for(int j=0;j<3;j++){
            for(int k=0;k<3;k++){
                ll aa = a - j;
                ll bb = b - k;
                if(aa >= 1 && bb >= 1 && aa <= H-2 && bb <= W-2){
                    um[make_pair(aa,bb)]++;
                }
            }
        }
    }
    vector<ll> ans(9,0);
    ll total = 0;
    for(auto &e : um){
        ans[e.second-1]++;
        total++;
    }
    cout << (H-2) * (W-2) - total << endl;
    for(auto &e : ans) cout << e << endl;
    return 0;
}

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

int main(){
	string n; cin>>n;
	int cnt=0;
	rep(i,4){
		if(n[i]=='2') cnt++;
	}
	cout<<cnt<<endl;
}

Measured memory_bytes: 3624
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<queue>
#include<deque>
#include<cmath>
#include<map>
#include<unordered_map>
#include<set>
#include<cstring>
#include<iomanip> //cout << fixed << setprecision(15) << x << endl;

using namespace std;
typedef long long ll;
const ll INF = 1e9 + 6;
const ll MOD = 1e9 + 7;
const ll LLINF = 1LL<<60;
#define Pint pair<int, int>
#define rng(i,a,b) for(int i=int(a);i<int(b);i++)
#define rep(i,b) rng(i,0,b)
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(),(x).end()
/* -- template -- */

int main() {
    int N; cin >> N;
    string s[N]; int t[N];
    int sum = 0;
    rep(i, N) cin >> s[i] >> t[i], sum += t[i];
    string X; cin >> X;
    int sum_X = 0;
    rep(i, N) {
        sum_X += t[i];
        if(s[i] == X) {
            cout << sum - sum_X << endl;
            return 0;
        }
    }
}


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

int main() {

	ll n, d; cin >> n >> d;
	ll ans = 0;
	for (ll i = 0; i < n; i++) {
		ll x, y; cin >> x >> y;
		if (x * x + y * y <= d * d) ans++;
	}
	cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3624
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
const int N = 17;
int main()
{
	int n,i,j;
	scanf("%d",&n);
	ll p[n+2];
	for(i=1;i<=n;++i)
	{
		scanf("%lld",&p[i]);
	}
	ll dist;
	scanf("%lld",&dist);
	int l[n+1],r[n+1];
	for(i=1;i<=n;++i)
	{
		l[i] = -1;
		int le = 1,ri = i;
		while(le <= ri)
		{
			int mid = (le+ri)/2;
			if(p[i] - p[mid] <= dist)
			{
				l[i] = mid;
				ri = mid-1;
			}
			else	le = mid+1;
		}
	}
	for(i=1;i<=n;++i)
	{
		r[i] = -1;
		int le = i,ri = n;
		while(le <= ri)
		{
			int mid = (le+ri)/2;
			if(p[mid] - p[i] <= dist)
			{
				r[i] = mid;
				le = mid+1;
			}
			else	ri = mid-1;
		}
	}
	int left[N][n+1],right[N][n+1];
	for(i=1;i<=n;++i)
	{
		left[0][i] = l[i];
		right[0][i] = r[i];
	}
	for(i=1;i<N;++i)
	{
		for(j=1;j<=n;++j)
		{
			left[i][j] = left[i-1][left[i-1][j]];
			right[i][j] = right[i-1][right[i-1][j]];
		}
	}
	int q,x,y;
	scanf("%d",&q);
	while(q--)
	{
		scanf("%d %d",&x,&y);
		if(x < y)		swap(x,y);
		int le = 1,ri = n,ans=n;
		while(le<=ri)
		{
			int mid = (le+ri)/2;
			int cur = x;
			for(i=0;i<N;++i)
			{
				if(((1<<i) & mid) != 0)
				{
					cur = left[i][cur];
				}
			}
			if(cur<=y)
			{
				ans = mid;
				ri = mid-1;
			}
			else	le = mid+1;
		}
		printf("%d\n",ans);
	}
}

Measured memory_bytes: 18584
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#define rep(i,n) for(int i=0;i<(n);i++)
typedef long long ll;

using namespace std;
int main() {
	int n, k;
	cin >> n >> k;
	if (k != 1) cout << n - k << endl;
	else cout << 0 << endl;
	return 0;
}

Measured memory_bytes: 256
import copy
N,M,Q=map(int,input().split())

matrix=[]
for i in range(Q):
    matrix.append(list(map(int,input().split())))

line=[1]
ans=0

def dfs(A):
    global ans
    if len(A)==N:
        now=0
        for i in range(Q):
            if A[matrix[i][1]-1]-A[matrix[i][0]-1]==matrix[i][2]:
                now+=matrix[i][3]
        ans=max(ans,now)
        return
    A.append(A[-1])
    while(A[-1]<=M):
        dfs(copy.copy(A))
        A[-1]+=1

dfs(line)
print(ans)
    

Measured memory_bytes: 9280
n = int(input())
a = [int(m) for m in input().split()]
p = []
for i in range(n):
    if i == n - 1:
        p.append(a[0] - a[n - 1])
    else:
        p.append(a[i + 1] - a[i])

k = sum(a) / ((n * (n + 1)) // 2)
if int(k) != k:
    print("NO")
    exit()
m = []
for i in range(n):
    mi = (k - p[i]) / n
    if int(mi) != mi or mi < 0:
        print("NO")
        exit()
    else:
        m.append(mi)

if sum(m) == k:
    print("YES")
else:
    print("NO")

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

#define sz(x) int(x.size())
#define pii pair<int, int>
#define Task "abc"
#define For(i, a, b) for(int i = (a), _b = (b); i <= b; ++i)
#define Debug(X) cout << #X << " = " << X << '\n'
#define All(x) (x).begin(), (x).end()
#define mp make_pair

typedef unsigned long long ull;
typedef long long ll;

const int maxn = 1e5 + 10;
const int inf = 0x3f3f3f3f;
const ll mod = 1e9 + 7;

vector<int> adj[maxn], bl[maxn];
int n, m, k;
int ngraph[maxn], vis[maxn], id[maxn];

int dfs(int u){
  int ret = 1;
  vis[u] = 1;
  for (auto v : adj[u]){
    if (!vis[v]) ret += dfs(v);
  }
  return ret;
}

void mark(int u, int cur, int cnt){
  vis[u] = 2;
  ngraph[u] = cur; id[u] = cnt;
  for (auto v : adj[u]){
    if (vis[v] == 1) mark(v, cur, cnt);
  }
}

int main(){
  ios_base::sync_with_stdio(0); cin.tie(0);cout.tie(0);
//  freopen(Task".inp", "r", stdin);
//  freopen(Task".out", "w", stdout);
  cin >> n >> m >> k;

  for (int i = 0; i < m; ++i){
    int u, v; cin >> u >> v;
    adj[u].push_back(v); adj[v].push_back(u);
  }
  for (int i = 0; i < k; ++i){
    int u, v; cin >> u >> v;
    bl[u].push_back(v); bl[v].push_back(u);
  }
  int cnt = 0;
  for (int u = 1; u <= n; ++u){
    if (!vis[u]){
      int cur = dfs(u);
      ++cnt;
      mark(u, cur, cnt);
    }
  }

  for (int u = 1; u <= n; ++u){
    int cur = ngraph[u] - 1;
    for (auto v : adj[u]){
      if (id[u] == id[v]) --cur;
    }
    for (auto v : bl[u]){
      if (id[u] == id[v]) --cur;
    }
    cout << cur <<' ';
  }
}



Measured memory_bytes: 13440
#include <iostream>
#include <fstream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <cstring>
#include <string>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <algorithm>
using namespace std;
 
#define REP(i,n) for(int i=0; i<n; ++i)
#define FOR(i,a,b) for(int i=a; i<=b; ++i)
#define FORR(i,a,b) for (int i=a; i>=b; --i)
#define pi M_PI
 
typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<VI> VVI;
typedef pair<int,int> P;
typedef pair<ll,ll> PL;

int main() {
    int n;
    cin >> n;
    VI p(n);
    REP(i,n) cin >> p[i];
    VI dist(n, -1);
    queue<int> que;
    dist[0] = 0;
    que.push(0);
    while (dist[n-1] == -1){
        int x = que.front();
        que.pop();
        REP(i,6){
            int next = min(n-1, x+i+1);
            while (1) {
                if (dist[next] >= 0) break;
                dist[next] = dist[x] + 1;
                if (p[next] == 0){
                    que.push(next);
                    break;
                }
                next += p[next];
            }
        }
    }

    cout << dist[n-1] << endl;

    return 0;
}

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

public class Main {
    public static void main(String[] args) {
        MyScanner sc = new MyScanner();

        int n = sc.nextInt();
        char[] s = sc.next().toCharArray();

        int[][] cnt = new int[n][2];
        for (int i = 0; i < n; i++) {
            if (s[i] == 'E')
                cnt[i][0]++;
            else
                cnt[i][1]++;

            if (i > 0) {
                cnt[i][0] += cnt[i-1][0];
                cnt[i][1] += cnt[i-1][1];
            }
        }

        int min = Math.min(cnt[n-1][0], cnt[n-1][1]);
        for (int i = 1; i < n-1; i++) {
            int tmp = cnt[i-1][1] + (cnt[n-1][0] - cnt[i][0]);
            min = Math.min(tmp, min);
        }

        System.out.println(min);
    }

    static class MyScanner {
        BufferedReader reader = new BufferedReader(new InputStreamReader(System.in), 1 << 15);
        StringTokenizer tokenizer;

        String next() {
            try {
                while (tokenizer == null || !tokenizer.hasMoreTokens()) {
                    tokenizer = new StringTokenizer(reader.readLine());
                }
            } catch (IOException ignored) {
            }
            return tokenizer.nextToken();
        }

        int nextInt() {
            return Integer.parseInt(next());
        }

        long nextLong() {
            return Long.parseLong(next());
        }
    }
}

Measured memory_bytes: 34560
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <cassert>
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define RFOR(i,a,b) for(int i=(b)-1;i>=(a);i--)
#define REP(i,n) FOR(i,0,n)
#define rep(i,n) FOR(i,0,n)
#define DEBUG(x) cout<<#x<<": "<<x<<endl
#define vint vector<int>
#define vdouble vector<double>
#define vstring vector<string>
using namespace std;

#include<map>
#include<set>
#include<queue>

typedef long long ll;
typedef unsigned long long ull;

ll insertionSort(int A[], int N, int g){
	ll c = 0;

	for (int i = g; i < N; i++){
		int v = A[i];
		int j = i - g;
		while (j >= 0 && A[j] > v){
			A[j + g] = A[j];
			j -= g;
			c++;
		}
		A[j + g] = v;
	}

	return c;
}

void shellSort(int A[], int N){

	// create G vector
	vint G;
	int h = 1;
	G.push_back(h);
	h = 3 * h + 1;
	
	while (h < N){
		G.push_back(h);
		h = 3 * h + 1;
	}

	ll ct = 0;
	RFOR(i, 0, G.size()){
		ct += insertionSort(A, N, G[i]);
	}

	cout << G.size() << endl;
	RFOR(i, 0, G.size()){ 
		cout << G[i];
		if (i > 0) cout << ' ';
	}
	cout << endl;
	cout << ct << endl;

	rep(i, N){
		cout << A[i] << endl;
	}

}

const int MAX_N = 1000000;
int A[MAX_N];

int main() {

	int N;
	cin >> N;

	rep(i, N){ cin >> A[i]; }

	shellSort(A, N);

}

Measured memory_bytes: 6992
#include <cstdio>
#include <bits/stdc++.h>
#include <algorithm>
#include <iostream>
#include <string>
#include <cmath>
#include <functional>
#include <vector>
#include <stack>
#include <queue>
#include <map>
using ll = long long;
#define rep(i,n) for (ll i=0;i<n;i++)
using namespace std;

void solve(){

}
int main (){
    ios::sync_with_stdio(0);
    cin.tie(0);
    ll mod = 1000000007;

    ll n;
    cin >> n;


    ll ans;

    ll a=1,b=1,c=1;
    rep(i,n){
        a*=10;
        a%=mod;
        b*=9;
        b%=mod;
        c*=8;
        c%=mod;
    }

    ll ans1 = (a)+2*mod;

    // ll ans2  = (-b)%mod;
    

    ans = ans1 - b;
    ans = ans - b;
    ans += c;
    ans%=mod;

    cout << ans;

    return 0;
}

Measured memory_bytes: 3636
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
typedef long long int lli;
lli mod = 1e9 +7;

lli modpow(lli a, lli p){
	lli ret = 1;
	for(int i=63; i>=0; i--){
		ret *= ret;
		ret %= mod;
		if((1LL<<i & p) != 0){
			ret *= a;
			ret %= mod;
		}
	}
	return ret;
}

int main(){


	string s;
	cin >> s;
	int n = s.length();
	vector<lli> l(n), r(n);
	{
		lli all=0, a=0;
		for(int i=1; i<n; i++){
			if(s[i-1] == 'A') a++;
			if(s[i-1] == '?') all++;
			l[i] = a*modpow(3, all)%mod;
			if(all != 0){
				l[i] += all*modpow(3, all-1)%mod;
				l[i] %= mod;
			}
		}
	}
	{
		lli all=0, c=0;
		for(int i=n-2; i>=0; i--){
			if(s[i+1] == 'C') c++;
			if(s[i+1] == '?') all++;
			r[i] = c*modpow(3, all)%mod;
			if(all != 0){
				r[i] += all*modpow(3, all-1)%mod;
				r[i] %= mod;
			}
		}
	}
	lli ans = 0;
	for(int i=1; i<n-1; i++){
		if(s[i]=='B' or s[i]=='?'){
			ans += l[i]*r[i] %mod;
			ans %= mod;
		}
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 2048
//#define _GLIBCXX_DEBUG

#include<bits/stdc++.h>
#define PI 3.14159265359
using namespace std;
const int INF= 1e9+5;
typedef long long ll;
typedef vector<int> vi;
typedef vector<vector<int>>vvi;


int main(){
  int n,m;
  cin>>n>>m;
  vi a(n);
  vi b(n);
  vi c(m);
  vi d(m);
  vi ans(n);
  for(int i=0;i<n;i++)cin>>a[i]>>b[i];
  for(int i=0;i<m;i++)cin>>c[i]>>d[i];
  for(int i=0;i<n;i++){
    int MIN=INF;
    for(int j=0;j<m;j++){
      int k=abs(c[j]-a[i])+abs(b[i]-d[j]);
      if(k<MIN){
        MIN=k;
        ans[i]=j+1;
      }
    }
  }
  for(int i=0;i<n;i++)cout<<ans[i]<<endl;
}
        
      

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

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

      vector<pair<long long,long long>> robots;

      for (int i = 0; i < N; i++) {
            long long x,l;
            cin >> x >> l;
            robots.push_back(make_pair(x + l, x - l));
      }
      sort(robots.begin(), robots.end());


      int ans = 1;
      long long a=robots.at(0).first;
      for (int i = 1; i < N; i++) {
            if ( a <= robots.at(i).second) {
                  ans++;
            a = robots.at(i).first;
            }
      }

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


Measured memory_bytes: 2420
/*
23280701537353
*/
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> // Common file
#include <ext/pb_ds/tree_policy.hpp>
#define sz(v)   ((int)(v).size())
#define  all(v)    ((v).begin()),((v).end())
#define  allr(v)    ((v).rbegin()),((v).rend())
#define   pb         push_back
#define   mp         make_pair
#define   mt         make_tuple
//#define   Y            imag()
//#define   X            real()
#define    clr(v,d)      memset( v, d ,sizeof(v))
#define   angle(n)      atan2((n.imag()),(n.real()))
#define   vec(a,b)       ((b)-(a))
//#define   length(a)      hypot( (a.imag()),(a.real()) )
#define   normalize(a)      (a)/(length(a))
//#define    dp(a,b)          (((conj(a))*(b)).real())
//#define    cp(a,b)          (((conj(a))*(b)).imag())
#define    lengthsqrt(a)       dp(a,a)
#define    rotate0( a,ang)    ((a)*exp( point(0,ang) ))
#define    rotateA(about,p,ang)   (rotate0(vec(about,p),ang)+about)
#define    reflection0(m,v)         (conj((v)/(m))*(m))
#define     reflectionA(m,v,p0)     (conj( (vec(p0,v))/(vec(p0,m)) ) * (vec(p0,m)) ) + p0
//#define     same(p1,p2)               ( dp(  vec(p1,p2),vec(p1,p2)) < eps )
#define     PT                    complex<double>
#define outfile freopen("out.out", "w", stdout);
#define infile  freopen("in.in", "r", stdin);
#define PI acos(-1)
typedef  long long     ll ;
typedef  unsigned long long ull;
const double eps= (1e-9);
using namespace std;
using namespace __gnu_pbds;
int dcmp(double a,double b){   return fabs(a-b)<=eps ? 0: (a>b)? 1:-1  ;}
int getBit(int num, int idx) {return ((num >> idx) & 1) == 1;}
ll setBit1(ll num, int idx) {return num | (1ll<<idx);}
ll setBit0(ll num, int idx) {return num & ~(1ll<<idx);}
ll flipBit(int num, int idx) {return num ^ (1<<idx);}
void FS(){ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);}
ll s;
int main()
{
    cin>>s;
    ll x1,x2,x3,y1,y2,y3;
    x1=y1=0;
    x2=1000000000;
    y2=1;
    y3= s/x2 + (s%x2!=0);
    x3= (y3*x2)-s;
    cout<<x1<<" "<<y1<<" "<<x2<<" "<<y2<<" "<<x3<<" "<<y3<<endl;
}





























Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
#define rep(i, begin, end) for (__typeof(end) i = (begin) - ((begin) > (end)); i != (end) - ((begin) > (end)); i += 1 - 2 * ((begin) > (end))) // rep(i, 1, 5) --> {1,2,3,4} // rep(i, 5, 1) --> {4,3,2,1} // rep(it, end(v), begin(v)) --> *it

using namespace std;

int main()
{
    int r;
    cin >> r;
    float pi = 3.14159265358979323846264338327950288419716939937;
    cout << 2*r*pi;
    return 0;
}

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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef set<int> si;

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

    int a, b;
    cin >> a >> b;
    int t = (a * 10 + b * 10) / 2;
    if (t % 10 >= 5)
        t = t / 10 + 1;
    else
        t /= 10;
    cout << t << endl;

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <string.h>
#include <vector>
//s#define rep(i, n) for (int i = 0; i < (n); i++)
#define MAX 10000

using namespace std;

#define inf    0x3f3f3f3f
#define ll long long
#define pb push_back
#define mp make_pair
#define all(a) (a).begin(),(a).end()
#define rep(i,a,n) for(int i=a; i<n; i++)
#define INF (int)1e15
#define MOD 1000000007

#define access(i) a[i/3][i%3]

 int main(){

  ll a,b,c,d;
  cin>>a>>b>>c>>d;

  ll ans = max(a*c , max(a*d ,max(b*c,b*d)));

  cout<<ans<<endl;

  return 0;
 }

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

using namespace std;

int main()
{
    int N;
    while (true) {
        cin >> N;
        if (N == 0) break;

        int cards[10] = {0}, ba = 0;
        char card;
        for (int i = 0; i < 100; i++) {
            cin >> card;
            if (card == 'S') {
                ba += cards[i % N] + 1;
                cards[i % N] = 0;
            } else if (card == 'L') {
                cards[i % N] += ba + 1;
                ba = 0;
            } else {
                cards[i % N]++;
            }

        }

        sort(cards, cards + N);
        for (int i = 0; i < N; i++) cout << cards[i] << " ";
        cout << ba << endl;
    }

    return 0;
}

Measured memory_bytes: 1184
#include <iostream>
using namespace std;
int main() {

  int c[3][3];
  for (int i = 0; i < 3; i++) {
    for (int j = 0; j < 3 ;j++) {
      cin >> c[i][j];
    }
  }
  if ( c[0][0] + c[2][2] == c[0][2] + c[2][0] &&
       c[1][1] + c[2][2] == c[1][2] + c[2][1] &&
       c[0][0] + c[1][1] == c[0][1] + c[1][0]
  ) {
    cout << "Yes" << endl;
  }else {
    cout << "No" << endl;
  }
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define exrep(i, a, b) for(long long i = a; i <= b; i++)
#define rep(i,n)for(long long i=0;i<(long long)(n);i++)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
using namespace std;
typedef unsigned long long ull;
typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> P;
typedef vector<ll> vl;
typedef vector<string> vs;
typedef vector<P> vp;
typedef vector<vector<ll> > vvl;
typedef vector<vector<P> > vvp;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
 
const ll MOD=1e9+7;
const ll INF=1e18;
const int MAX=510000;
const double pi=acos(-1);
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};

template<class Abel> struct UnionFind {
    vector<int> par;
    vector<int> rank;
    vector<Abel> diff_weight;

    UnionFind(int n = 1, Abel SUM_UNITY = 0) {
        init(n, SUM_UNITY);
    }

    void init(int n = 1, Abel SUM_UNITY = 0) {
        par.resize(n); rank.resize(n); diff_weight.resize(n);
        for (int i = 0; i < n; ++i) par[i] = i, rank[i] = 0, diff_weight[i] = SUM_UNITY;
    }

    int root(int x) {
        if (par[x] == x) {
            return x;
        }
        else {
            int r = root(par[x]);
            diff_weight[x] += diff_weight[par[x]];
            return par[x] = r;
        }
    }

    Abel weight(int x) {
        root(x);
        return diff_weight[x];
    }

    bool issame(int x, int y) {
        return root(x) == root(y);
    }

    bool merge(int x, int y, Abel w) {
        w += weight(x); w -= weight(y);
        x = root(x); y = root(y);
        if (x == y) return false;
        if (rank[x] < rank[y]) swap(x, y), w = -w;
        if (rank[x] == rank[y]) ++rank[x];
        par[y] = x;
        diff_weight[y] = w;
        return true;
    }

    Abel diff(int x, int y) {
        return weight(y) - weight(x);
    }
};
int main(){
  cin.tie(0);
  ios::sync_with_stdio(false); 
  
  int n,k;
  cin >> n >> k;
  cout << (n-1+k-1-1)/(k-1) << endl;
      
  return 0;     
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define MN 300000
#define ll long long
#define mod 998244353
using namespace std;
inline int read()
{
    int x=0,f=1;char ch=getchar();
    while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}
    while(ch>='0'&&ch<='9'){x=x*10+ch-'0';ch=getchar();}
    return x*f;
}
int n,A,B,p[MN+5],inv[MN+5],ans;
ll K;
inline int C(int n,int m){return 1LL*p[n]*inv[m]%mod*inv[n-m]%mod;}
int main()
{
    n=read();A=read();B=read();cin>>K;
    p[0]=p[1]=inv[0]=inv[1]=1;
    for(int i=2;i<=n;++i) p[i]=1LL*p[i-1]*i%mod,inv[i]=1LL*(mod-mod/i)*inv[mod%i]%mod;
    for(int i=2;i<=n;++i) inv[i]=1LL*inv[i-1]*inv[i]%mod;
    for(int i=0;i<=n;++i)
    {
        ll left=K-1LL*i*A;
        if(left>=0&&left%B==0&&left/B<=n) ans=(ans+1LL*C(n,i)*C(n,left/B))%mod;
    }
    cout<<ans;
    return 0;
}

Measured memory_bytes: 2560
#include <bits/stdc++.h>
    #include <ext/pb_ds/assoc_container.hpp>
    #include <ext/pb_ds/tree_policy.hpp>
    #include <ext/pb_ds/detail/standard_policies.hpp>
    using namespace std;
    using namespace __gnu_pbds;
    #define endl "\n"
    #define fi first
    #define se second
    #define pb push_back
    #define ll long long
    #define ld long double
    #define pii pair<ll,ll>
    #define read(t) ll t;cin>>t;
    #define all(x) x.begin(),x.end()
    #define f(a,b,c) for(ll a=b;a<c;a++)
    #define For(i,n) for(ll i=0;i<n;i++)
    #define what(x) cerr << #x << " is " << x << endl;
    #define fast ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL) ;
    typedef tree<pair<ll,ll>, null_type,less<pair<ll,ll>>, rb_tree_tag,tree_order_statistics_node_update> ordered_mset;
    typedef tree<long long,null_type,less<long long>,rb_tree_tag,tree_order_statistics_node_update> ordered_set;
    typedef tree<long long,null_type,greater<long long>,rb_tree_tag,tree_order_statistics_node_update> ordered_set1;
/*.....................................................................................................................*/

    const ll mod=(ll)1e9+7;
    ll add(ll x,ll y) {return (x+y)%mod;}
    ll mult(ll x, ll y){return ((x%mod )* (y%mod)) % mod;}
    long long binpow(long long x, long long p) 
    {
        if (p == 0) {return 1;}
    	if (p == 2 || (p & 1)) {return mult(x, binpow(x, p - 1));}
    	return binpow(binpow(x, p / 2), 2);
    }
    ll modinv(ll a) {return binpow(a,mod-2);}
    double pi=3.141592653589793238462641;
    ll dx[4]={1,-1,0,0},dy[4]={0,0,1,-1};
    const ll man=(ll)1e5+5;
/*........................................................................................................................*/

signed main()
{
    fast;
    ll n;
    cin>>n;
    ll ans=0;
    map<pii,ll>mp;
    f(i,1,n+1)
    {
        pii x;
        x.fi=i%10;
        ll v=i;
        while(v)
        {
            x.se=v%10;
            v/=10;
        }
        mp[x]++;
    }
    for(auto x:mp)
    {
        pii p1=x.fi;
        pii p2={x.fi.se,x.fi.fi};
        ans+=mp[p1]*mp[p2];
    }
    cout<<ans<<endl;
}   


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

#define int long long
typedef vector<int>vint;
typedef pair<int,int>pint;
typedef vector<pint>vpint;
#define rep(i,n) for(int i=0;i<(n);i++)
#define reps(i,f,n) for(int i=(f);i<(n);i++)
#define all(v) (v).begin(),(v).end()
#define each(it,v) for(__typeof((v).begin()) it=(v).begin();it!=(v).end();it++)
#define pb push_back
#define fi first
#define se second
template<typename A,typename B>inline void chmin(A &a,B b){if(a>b)a=b;}
template<typename A,typename B>inline void chmax(A &a,B b){if(a<b)a=b;}


signed main(){
    int xl=0,xr,yl=0,yr,N;
    cin>>xr>>yr>>N;
    rep(i,N){
        int x,y,a;
        cin>>x>>y>>a;
        if(a==1)chmax(xl,x);
        if(a==2)chmin(xr,x);
        if(a==3)chmax(yl,y);
        if(a==4)chmin(yr,y);
    }
    cout<<max(xr-xl,0ll)*max(yr-yl,0ll)<<endl;
}


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

const lint MOD = (lint)998244353;
lint dp1[305][90005], dp2[305][90005];
int A[305];

lint& mod_add(lint &a, lint b){
    return a = (a+b) % MOD;
}

lint& mod_sub(lint &a, lint b){
    return a = ((a-b)%MOD+MOD) % MOD;
}

lint mod_pow(lint n, lint x){
    lint res = 1;
    while(x){
        if(x & 1) res = res * n % MOD;
        x >>= 1; n = n * n  % MOD;
    }
    return res;
}

int main(){
    ios::sync_with_stdio(false), cin.tie(nullptr);
    int N, S = 0; cin >> N;
    for(int i=0;i<N;i++) {cin >> A[i]; S += A[i];}

    dp1[0][0] = dp2[0][0] = 1;
    for(int i=0;i<N;i++){
        for(int j=0;j<=S;j++){
            mod_add(dp1[i+1][j], dp1[i][j]*2);
            mod_add(dp1[i+1][j+A[i]], dp1[i][j]);
            mod_add(dp2[i+1][j], dp2[i][j]);
            mod_add(dp2[i+1][j+A[i]], dp2[i][j]);
        }
    }

    lint sub = 0, add = (S%2) ? 0 : dp2[N][S/2];
    for(int i=(S+1)/2;i<=S;i++) mod_add(sub, dp1[N][i]);

    lint ans = mod_pow(3, N);
    cout << mod_add(mod_sub(ans, 3*sub), 3*add) << endl;
    return 0;
}

Measured memory_bytes: 427648
a,b,c,x,y = map(int,input().split())
if x >y:
    mini = [b,y]
    maxi = [a,x]
else:
    maxi = [b,y]
    mini = [a,x]

cost = 0
if a+b > 2*c:
    cost += c*mini[1]*2
    dif = maxi[1]-mini[1]
    if dif*maxi[0] > c*2*dif:
        cost += c*2*dif
    else:
        cost += dif * maxi[0]
else :
    cost += mini[0]*mini[1] + maxi[0]*maxi[1]

print(cost)

Measured memory_bytes: 3064
#include <iostream>
#include <algorithm>
#include <iomanip>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <numeric>
#include <bitset>
#include <cmath>

static const int MOD = 1000000007;
using ll = long long;
using u32 = uint32_t;
using namespace std;

template<class T> constexpr T INF = ::numeric_limits<T>::max()/32*15+208;

template <class T, class U>
vector<T> make_v(U size, const T& init){ return vector<T>(static_cast<size_t>(size), init); }

template<class... Ts, class U>
auto make_v(U size, Ts... rest) { return vector<decltype(make_v(rest...))>(static_cast<size_t>(size), make_v(rest...)); }

template<class T> void chmin(T &a, const T &b){ a = (a < b ? a : b); }
template<class T> void chmax(T &a, const T &b){ a = (a > b ? a : b); }


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

template <class L, class R>
ostream& operator<<(ostream& os, pair<L, R> p) {
    return os << "{" << p.first << ", " << p.second << "}";
}


int main() {
    int h, w;
    cin >> h >> w;
    auto v = make_v(h+2, w+2, 0);
    auto dp = make_v(h+2, w+2, -1);
    vector<pair<int, int>> u(h*w);
    for (int i = 0; i < h; ++i) {
        for (int j = 0; j < w; ++j) {
            scanf("%d", &v[i+1][j+1]);
            u[i*w+j] = {i+1, j+1};
        }
    }
    using P = pair<int, int>;
    sort(u.begin(),u.end(), [&v](P a, P b){
        return v[a.first][a.second] < v[b.first][b.second];
    });
    array<int, 4> dy{-1, 1, 0, 0}, dx{0, 0, 1, -1};
    int ans = 0;
    for (int i = 0; i < h*w; ++i) {
        int y, x; tie(y, x) = u[i];
        for (int k = 0; k < 4; ++k) {
            if(dp[y+dy[k]][x+dx[k]] == -1) continue;
            else if(dp[y+dy[k]][x+dx[k]] == -2) dp[y][x] = -2;
            else if(dp[y][x] >= 0 && dp[y+dy[k]][x+dx[k]] != dp[y][x]){
                dp[y][x] = -2;
            } else dp[y][x] = dp[y+dy[k]][x+dx[k]];
            if(dp[y][x] == -2) break;
        }
        if(dp[y][x] == -1) dp[y][x] = v[y][x];
        if(dp[y][x] == -2) ans++;
    }
    cout << ans << "\n";
    return 0;
}


Measured memory_bytes: 18656
s = input()
check = True
count = 0
for i in s:
    if check:
        if i != "0":
            count += 1
    else:
        if i != "1":
            count += 1
    check = not check
check = False
count2 = 0
for i in s:
    if check:
        if i != "0":
            count2 += 1
    else:
        if i != "1":
            count2 += 1
    check = not check
print(min(count, count2))

Measured memory_bytes: 3188
#include <iostream>
#include <iomanip>
#include <vector>
#include <string>
#include <algorithm>
#include <cmath>
#include <stack>
#include <queue>
#include <functional>
#include <limits.h>
#include <set>
#include <map>
#include <tuple>
using namespace std;



#define ll long long
#define ull unsigned long long
#define rep(i,N) for (ll i=0;i<N;i++)
#define loop(i,N,M) for(ll i=N;i<M;i++)
#define MAX(v) *max_element(v.begin(),v.end())
#define MIN(v) *min_element(v.begin(),v.end())
#define SORTL2S(type,v) sort(v.begin(),v.end(),greater<type>())
#define SORTS2L(type,v) sort(v.begin(),v.end())
#define SORTMF(v,func) sort(v.begin(),v.end(),func)

ll debugFlag = false;
template<typename T> void debug(T&);
template<typename T> void debug(T&, bool);
template<typename T> void debug(vector<T>&);
template<typename T> void debug(vector<T>&, bool);
template<typename T, typename U> void debug(pair<T, U>&);
template<typename T, typename U> void debug(pair<T, U>&, bool);

template<typename T>
void debug(T& obj) {
	debug(obj, true);
}

template<typename T>
void debug(T& obj, bool lnFlag) {
	if (!debugFlag) return;
	cout << obj;
	if (lnFlag) cout << endl;
}

template<typename T>
void debug(vector<T>& obj) {
	debug(obj, true);
}

template<typename T>
void debug(vector<T>& obj, bool lnFlag) {
	if (!debugFlag) return;
	cout << "[";
	rep(i, obj.size()) {
		if (i != 0) cout << ",";
		debug(obj[i], false);
	}
	cout << "]";
	if (lnFlag) cout << endl;
}

template<typename T, typename U>
void debug(pair<T, U>& obj) {
	debug(obj, true);
}

template<typename T, typename U>
void debug(pair<T, U>& obj, bool lnFlag) {
	if (!debugFlag) return;
	cout << "(";
	debug(obj.first, false);
	cout << ",";
	debug(obj.second, false);
	cout << ")";
	if (lnFlag) cout << endl;
}

void solve() {

	ll N;
	cin >> N;

	vector<ll> jun(N);

	rep(i, N) {
		ll a;
		cin >> a;
		jun[a-1] = i;
	}

	rep(i, N) {
		cout << jun[i] + 1 << " ";
	}

}


int main(int argc, char* argv[]) {
	if (argc == 2 && string(argv[1]) == "debug") debugFlag = true;
	solve();
	return 0;
}


Measured memory_bytes: 1664
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<math.h>
#include<iomanip>
#include<set>
#include<numeric>
#include<cstring>
#include<cstdio>
#include<functional>
#include<bitset>
#include<limits.h>
#include<iterator>
#include<complex>
#include<stack>
using namespace std;
string s;
using MIte = multimap<int, int>::iterator;

int main() {
	int X, K;
	cin >> K >> X;

	int first = X - K + 1;
	if (first < -1000000) {
		first = -1000000;
	}
	int last = X + K - 1;
	if (first > 1000000) {
		first = 1000000;
	}

	for (int i = first; i != (last+1); i++) {
		cout << i << " ";
	}
	cout << endl;
	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(void)
{
    int n;
    char str[5];
    int i;

    scanf("%s", str);

    n = 0;
    for(i = 0; str[i] != '\0'; i++){
        if(str[i] == '+'){
            n++;
        }
        else{
            n--;
        }
    }

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

    return(0);
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
 
#define rep(i,n) for(ll i=0;i<n;++i)
#define all_map(itr,mp) for(auto itr=mp.begin();itr!=mp.end();itr++)
#define ALL(a) (a).begin(),(a).end()

using namespace std;
using ll  = long long;
using pll = pair<ll, ll>;

const ll MOD  = 1e9 + 7;
const ll LINF = 1LL << 62;
const int INF = 1e9 + 7;

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

    vector<ll> a(5);
    rep(i, 5)cin >> a[i];
    sort(ALL(a));

    if(a[0] >= n){
        cout << 5 << endl;
        return 0;
    }

    ll ans = n / a[0] + 5;

    if(n % a[0] == 0)ans--;

    cout << ans << endl;
}

Measured memory_bytes: 3632
#include <stdio.h>
int main()
{
  int a,b,c,k;
  scanf("%d%d%d%d",&a,&b,&c,&k);
  int i;
  i = 0;
  while (i < k)
  {
    if (b <= a)
      b *= 2;
    else if (c <= b)
      c *= 2;
    i++;
  }
  if (a < b && b < c)
    printf("Yes");
  else
    printf("No");
}

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

std::vector<pair<int, int> > stamp(101);
std::vector<std::vector<int> > v(101);
bool isCheckd[101];
int cnt = 0;

void dfs(int k){
	cnt++;
	isCheckd[k] = true;
	stamp[k].first = cnt;
	for(int i=0;i<v[k].size();i++){
		int next = v[k][i];
		if(!isCheckd[next]){
			dfs(next);
		}
	}
	cnt++;
	stamp[k].second = cnt;
}

int main(){
	int n;

	fill(isCheckd,isCheckd+101,false);
	isCheckd[0] = true;
	cin >> n;

	for(int i=0;i<n;i++){
		int u,k;
		cin >> u >> k;
		for(int j=0;j<k;j++){
			int in;
			cin >> in;
			v[u].push_back(in);
		}
	}

	for(int i=0;i<n;i++){
		if(!isCheckd[i])
			dfs(i);
	}


	for(int i=0;i<n;i++){
		cout << i+1 <<" "<< stamp[i+1].first <<" " <<stamp[i+1].second<< endl;
	}

	return 0;
}

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

int main() {
  int N,M; cin >> N >> M; 
  vector<long> H(N); vector<int> A(M); vector<int> B(M);
  for (int i =0; i<N; i++) cin >> H.at(i);
  for (int i =0; i<M; i++) cin >> A.at(i) >> B.at(i);
  
  vector<bool> check(N,true); 
  for (int i =0; i<M; i++) {
    if (H.at(A.at(i)-1) > H.at(B.at(i)-1)) {
      check.at(B.at(i)-1) = false;
    } else if (H.at(A.at(i)-1) < H.at(B.at(i)-1)) {
      check.at(A.at(i)-1) = false;
    } else {
      check.at(B.at(i)-1) = false;
      check.at(A.at(i)-1) = false;
    } 
  }

  int ans =0;
  for (int i =0; i<N; i++) {
    if (check.at(i)) ans++;
  }
  cout << ans << endl; 
}
  

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

using namespace std;

int freq[26];

int main()
{
    string a;
    cin >> a;
    int n = (int) a.length();
    long long ans = 1;
    for (int i = 0; i < n; i++)
    {
        int key = a[i] - 'a';
        ans += i - freq[key];
        freq[key]++;
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
#define ll long long
using namespace std;
ll MOD = 1e9+7;
ll H, N, M, L, K, W, X, Y, Z;
ll ans = 0;
int main() {
	cin >> N >> M >> X >> Y;
	int maxX = -100;
	int minY = 100;
	for (int i = 0; i < N; i++) {
		int x;
		cin >> x;
		maxX = max(x, maxX);
	}
	maxX = max(int(X), maxX);
	for (int i = 0; i < M; i++) {
		int y;
		cin >> y;
		minY = min(y, minY);
	}
	minY = min(int(Y), minY);
	if (maxX<minY)cout << "No War" << endl;
	else cout << "War" << endl;
}


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

int main() {
	int n;
	cin >> n;
	vector<int>a(n);
	for (int i = 0; i < n; i++)cin >> a.at(i);
	ll tot = 0;
	ll tpo = 0;
	for (int i = 0; i <= n; i++) {
		if (i == 0) {
			tot += abs(0 - a.at(i));
			tpo = a.at(i);
		}
		else if (i == n) tot += abs(0 - tpo);
		else {
			tot += abs(a.at(i) - tpo);
			tpo = a.at(i);
		}
	}
	for (int i = 0; i < n; i++) {
		ll ans = tot;
		if (i == 0) ans = ans - abs(0 - a.at(i)) - abs(a.at(i) - a.at(i + 1)) + abs(0 - a.at(i + 1));
		else if (i == n - 1) ans = ans - abs(a.at(i) - a.at(i - 1)) - abs(0 - a.at(i)) + abs(0 - a.at(i - 1));
		else ans = ans - abs(a.at(i) - a.at(i - 1)) - abs(a.at(i) - a.at(i + 1)) + abs(a.at(i - 1) - a.at(i + 1));
		cout << ans << endl;
	}
}

Measured memory_bytes: 1664
#include <stdio.h>

#define MAX 100005
#define NIL -1

typedef struct { int p, l, r;} Node;

Node T[MAX];
int n, D[MAX];

void print(int u) {
  int i,c;
  printf("node %d: ",u);
  printf("parent = %d, ",T[u].p);
  printf("depth = %d, ",D[u]);

  if( T[u].p == NIL ) printf("root, ");
  else if( T[u].l == NIL ) printf("leaf, ");
  else printf("internal node, ");

  printf("[");

  for(i=0, c=T[u].l; c != NIL; i++, c=T[c].r) {
    if(i) printf(", ");
    printf("%d",c);
  }
  printf("]\n");
}

void rec(int u, int p) {
  D[u] = p;
  if(T[u].r != NIL) rec(T[u].r,p);
  if(T[u].l != NIL) rec(T[u].l,p+1);
}

int main(void) {
  int i,j,d,v,c,l,r;
  scanf("%d",&n);
  for(i=0;i<n;i++) T[i].p = T[i].l = T[i].r = NIL;
  for(i=0;i<n;i++) {
    scanf("%d %d",&v,&d);
    for(j=0;j<d;j++) {
      scanf("%d",&c);
      if(j==0) T[v].l=c;
      else T[l].r =c;
      l = c;
      T[c].p = v;
    }
  }
  for(i=0;i<n;i++) {
    if(T[i].p == NIL) r = i;
  }
  
  rec(r,0);
  
  for(i=0;i<n;i++) print(i);
  
  return 0;
}


Measured memory_bytes: 7368
function Main(input) {
	input = input.trim("");
  	let result = "";
 	for(let i = 0 ; i<input.length; i++){
		result += "x";
      }
  
	console.log(result);
}
//*この行以降は編集しないでください（標準入出力から一度に読み込み、Mainを呼び出します）
Main(require("fs").readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 29616
#include <bits/stdc++.h>
#define loop(n) for (int ngtkana_is_a_genius = 0; ngtkana_is_a_genius < int(n); ngtkana_is_a_genius++)
#define rep(i, begin, end) for (int i = int(begin); (i) < int(end); i++)
#define all(v) v.begin(), v.end()
#define rand(l, r) std::uniform_int_distribution<>(l, r)(mt)
using lint = long long;
auto mt = std::mt19937_64(std::random_device{}());
auto cmn = [](auto& a, auto b){ if (a > b) {a = b; return true;} return false; };
auto cmx = [](auto& a, auto b){ if (a < b) {a = b; return true;} return false; };
void debug_impl() { std::cerr << std::endl; }
template <typename Head, typename... Tail>
void debug_impl(Head head, Tail... tail) { std::cerr << " " << head; debug_impl(tail...); }
#ifndef STOPIT
#define debug(...)\
  do {\
    std::cerr << std::boolalpha << "[" << #__VA_ARGS__ << "]:";\
    debug_impl(__VA_ARGS__);\
    std::cerr << std::noboolalpha;\
  } while (false)
#else
#define debug(...) 0;
#endif

int main() {
  std::cin.tie(0); std::cin.sync_with_stdio(false);
  struct node_type {
    node_type * left;
    node_type * right;
    std::int32_t value;
  };
  node_type * top = nullptr;
  auto insert = [&] (std::int32_t x) {
    if (!top) {
      top = ::new node_type{ nullptr, nullptr, x };
    } else {
      node_type * node = top;
      while (true) {
        node_type * & next = (x <= node->value ? node->left : node->right);
        if (next) node = next;
        else {
          next = ::new node_type{ nullptr, nullptr, x };
          break;
        }
      }
    }
  };

  auto print = [&] {
    std::vector< int > pre;
    std::vector< int > mid;
    auto dfs = [&](auto&& dfs, node_type * now) -> void {
      pre.emplace_back(now->value);
      if (now->left) dfs(dfs, now->left);
      mid.emplace_back(now->value);
      if (now->right) dfs(dfs, now->right);
    };
    dfs(dfs, top);
    for (int x : mid) std::cout << " " << x;
    std::cout << std::endl;
    for (int x : pre) std::cout << " " << x;
    std::cout << std::endl;
  };

  int n; std::cin >> n;
  loop(n){
    std::string s; std::cin >> s;
    switch (s.front()) {
      case 'i' : {
        int x; std::cin >> x;
        insert(x);
        break;
      }
      case 'p' : {
        print();
        break;
      }
    }
  }
  return 0;
}


Measured memory_bytes: 22688
/*氏名：保坂優介, 学籍番号：200441141
  概要：最小 最大 合計を求める*/

#include<stdio.h>

int main(void)
{
    int i, n, a, max = -1000001, min = 1000001;
    long total=0;
    
    scanf("%d", &n);

    for (i = 0; i < n; i++)
    {
        scanf("%d", &a);

        if (max < a)
        {
            max = a;
        }

        if (min > a)
        {
            min = a;
        }
        total = total + a;
    }

    printf("%d %d %ld\n", min, max, total);
   

    return 0;
}


Measured memory_bytes: 2100
class BIT:
    def __init__(self, n):
        self.size = n
        self.tree = [0] * (n + 1)
        self.depth = n.bit_length()
 
    def sum(self, i):
        s = 0
        while i > 0:
            s += self.tree[i]
            i -= i & -i
        return s
 
    def add(self, i, x):
        while i <= self.size:
            self.tree[i] += x
            i += i & -i
 
    def lower_bound(self, x):
        sum_ = 0
        pos = 0
        for i in range(self.depth + 1)[::-1]:
            k = pos + (1 << i)
            if k <= self.size and sum_ + self.tree[k] < x:
                sum_ += self.tree[k]
                pos += 1 << i
        return pos + 1, sum_


N = int(input())
l = [(j, i) for i, j in enumerate(map(int, input().split()))]
l.sort(key=lambda x:-x[0])
tree = BIT(N)
m = [0]*N
ans = 0

for value, idx in l:
    v = tree.sum(idx + 1)

    a = tree.lower_bound(v - 1)[0] if v>1 else 0
    b = tree.lower_bound(v - 0)[0] if v else 0
    c = tree.lower_bound(v + 1)[0] 
    d = tree.lower_bound(v + 2)[0]

    tree.add(idx + 1, 1)
    idx += 1
    ans += ((b-a)*(c-idx)+(d-c)*(idx-b)) * value

print(ans)

Measured memory_bytes: 62828