akhauriyash/Code-Regression huggingface dataset:
#include <stdio.h>
#include <cstdlib>
#include <cassert>
#include <iostream>
#include <set>
#include <vector>
#include <cstring>
#include <string>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <complex>
#include <map>
#include <queue>
#include <array>
#include <bitset>
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vi> vvi;
typedef vector<vl> vvl;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef pair<int, int> pii;
typedef pair<double, double> pdd;
typedef vector<pii> vii;
typedef vector<string> vs;

int d[301][301];
int p[301][301];

int f(const string & a, const string & b) {
  int n = a.size();
  memset(p, 0, sizeof(p));
  memset(d, 0, sizeof(d));
  for (int i = 1; i <= n; ++i) for (int j = 1; j <= n; ++j) {
    p[i][j] = p[i-1][j-1] + (int)(a[i-1] == b[j-1]);
  }
  for (int i = 1; i <= n; ++i) for (int j = 1; j <= n; ++j) {
    d[i][j] = p[i][j] + min(d[i-1][j], d[i][j-1]);
  }
  return d[n][n];
}

int main() {
  int n, m;
  cin >> n >> m;
  vs s(n);
  int res = 0;
  for (int i = 0; i < n; ++i) {
    cin >> s[i];
  }
  for (int i = 1; i < m; ++i) {
    string a = "", b = "";
    for (int j = 0; j < n; ++j) {
      a += s[j][i-1];
      b += s[j][i];
    }
    res += f(a, b);
  }
  cout << res << endl;
  return 0;
}

Measured memory_bytes: 1152
#pragma GCC optimize("O3")
#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize("unroll-loops")

#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace std;
using namespace __gnu_pbds; 

#define int long long
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define all(v) (v).begin(),(v).end()
#define rall(v) (v).rbegin(),(v).rend()
#define f first
#define s second
#define sz(x) (int)x.size()
#define endl '\n'
#define forn(i,n) for(int i=0;i<n;++i)
#define fore(i,l,r) for(int i=int(l);i<=int(r);++i)
#define rep(i,begin,end) for(__typeof(end) i=(begin);i!=(end);i++)
#define fill(a,value) memset(a,value,sizeof(a));
#define gcd(a,b) __gcd((a),(b))
#define watch1(x) cout << (x) << endl
#define watch2(x,y) cout << (x) << " " << (y) << endl
#define watch3(x,y,z) cout << (x) << " " << (y) << " " << (z) << endl
#define fastio ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);

typedef long long ll;
typedef long double ld; 
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<pii> vpii;
typedef tree<pii,null_type,less<pii>,rb_tree_tag,tree_order_statistics_node_update> oset;

// find_by_order(k) returns iterator to kth element starting from 0;
// order_of_key(k) returns count of elements strictly smaller than k;

const int mod = 1e9 + 7;
const int inf = 9e18;
const int N = 2e5 + 5;

int i,n;

void solve(){
    string s;
    cin>>s;
    if(s=="ABC")
        cout<<"ARC";
    else
        cout<<"ABC";
}

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

Measured memory_bytes: 3608
/**************************************************************************
Coded by: Saba Karimi(_VINTAGE)
Institution: AIT PUNE
***************************************************************************/
#include<bits/stdc++.h>
using namespace std;
#define fast ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define pb push_back 
#define all(a) a.begin(),a.end()
#define lb lower_bound
#define ub upper_bound
#define pii pair<int,int>
#define ld long double
#define int long long int 
/***************************************************************************/
signed main()
{   
    fast; 
    int n;
    cin>>n;
    map<string,int> mp;
    map<string,int> ::iterator it;
    for(int i=0;i<n;i++)
    {
       string s;
       cin>>s;
       sort(all(s));
       mp[s]++;
    }
    int ans = 0;
    for(it = mp.begin();it!=mp.end();it++)
    {
        if(it->second>0)
        {
            int x = it->second;
            ans+=(x*(x-1))/2;
        }
    }
    cout<<ans;
}   

Measured memory_bytes: 11264
n = int(input())
h = list(map(int, input().split()))

dp = [0, abs(h[0] - h[1])]
for i in range(2,n):
    dp.append(min(dp[i-1] + abs(h[i] - h [i-1]), dp[i-2] + abs(h[i] - h[i-2])))
    
print(dp[-1])

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

using namespace std;

long long mypow(long long x, long long y) {
	long long tot = 1LL;
	while (y) {
		if (y & 1) tot = tot * x;
		y >>= 1;
		x = x * x;
	}
	return tot;
}

int main() {
	long long n;
	scanf("%lld", &n);
	
	long long res = 0;
	
	// p = 0
	int v = sqrt(n - 1);
	if (n - 1 >= 2) res++;
	for (int i = 2; i <= v; i++) {
		if ((n - 1) % i == 0) {
			res++;
			if ((n - 1) / i != i && (n - 1) / i >= 2) res++;
		}
	}
	
	// p = 1 to 39
	for (int i = 1; i <= 39; i++) {
		long long lim = (long long)pow(n, 1.0 / i);
		if (mypow(lim + 1, i) <= n) lim++;
		if (mypow(lim, i) == n) res++;
		
		lim = (long long)pow(n, 1.0 / (i + 1));
		
		for (int j = 2; j <= lim; j++) {
			if (n - mypow(j, i) > 0 && (n - mypow(j, i)) % mypow(j, i + 1) == 0) res++;
		}
	}
	
	printf("%lld\n", res);
}


Measured memory_bytes: 4128
//gcc test.c -o test.out
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <math.h>

int citynum = 0;
int x[8],y[8];
double all_distance = 0;
int all_number = 0;

void city_path(int present,int next,double total_distance,char* isvisited){
	double d = 0;
	isvisited[present] = 1;
	if(present!=next){
		double dx = (x[present]-x[next]);
		double dy = (y[present]-y[next]);
		d = sqrt(dx*dx + dy*dy);
	}
	//printf("%d->%d:%lf\n",present,next,d);
	int isallvisited = 1;
	for(int i=0;i<citynum;i++){
		if(isvisited[i]==0 && next!=i){
			char isv[8];
			memcpy(isv,isvisited,citynum);
			city_path(next,i,total_distance+d,isv);
			isallvisited = 0;
		}
	}
	if(isallvisited){
		//printf("%lf\n",total_distance+d);
		all_distance+=(total_distance+d);
		all_number++;
	}
}

int main(void){
	scanf("%d",&citynum);
	for(int i=0;i<citynum;i++){
		scanf("%d %d",&x[i],&y[i]);
	}

	char isvisited[8][8];
	for(int i=0;i<citynum;i++){
		for(int j=0;j<citynum;j++){
			isvisited[i][j] = 0;
		}
	}
	for(int i=0;i<citynum;i++){
		city_path(i,i,0,isvisited[i]);
	}

	printf("%lf",(double)all_distance/all_number);
	return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <cmath>
#include <map>
#include <queue>
#include <iomanip>
#define MOD 1000000007
typedef long long ll;
using namespace std;

int main(){
  ll k,a,b;
  cin>>k>>a>>b;

  ll ans=k+1;
  if(k<=a||b<=a){
    cout<<ans<<endl;
    return 0;
  }
  ll cnt=a;
  ll times=a-1;
  times+=2;
  cnt=b;
  if((k-times)%2){
    cnt=cnt+(b-a)*((k-times)/2)+1;
  }else{
    cnt=cnt+(b-a)*((k-times)/2);
  }
  ans=max(ans,cnt);
  cout<<ans<<endl;
  

  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n,k,q;
    cin>>n>>k>>q;
    int dp[n+5]={0};
//    for(int i=0;i<=n;i++)
//        dp[i] = k;
    for(int i=0,x;i<q;i++)
    {
        cin>>x;
        dp[x]++;
        dp[0]--;
        dp[x+1]--;
    }
    for(int i=1;i<=n;i++)
    {
        dp[i] += dp[i-1];
        if(dp[i]+k<=0)
            cout<<"No\n";
        else
            cout<<"Yes\n";
    }
    return 0;
}


Measured memory_bytes: 1024
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <deque>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <cstring>
#include <iomanip>
#include <utility>

#define rep(i,n) for(int i=0;i<(n);i++)
#define reps(i,n) for(int i=1;i<=(n);i++)
#define lol long long
const int INF = 0x3f3f3f3f;
const long long LINF = 0x3f3f3f3f3f3f3f3fLL;

using namespace std;

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

    int n,h[100005];
    cin>>n;
    reps(i,n){
	cin>>h[i];
    }
    h[0]=INF;

    int sum[100005]={};
    for(int i=2;i<=n;i++){
	sum[i]=min(sum[i-1]+abs(h[i]-h[i-1]),sum[i-2]+abs(h[i]-h[i-2]));
    }

    cout<<sum[n]<<'\n';
    return 0;
}


Measured memory_bytes: 1024
n = gets.to_i
evi = n.times.map do
  a = gets.to_i
  a.times.map{gets.split.map(&:to_i)}
end

ans = 0
(2**n).times do |bit|
  cnt = 0
  n.times do |i|
    if bit[i] == 1
      flg = false
      evi[i].each do |x,y|
        flg = true if bit[x-1] != y
      end
      if flg
        cnt = 0
        break
      end
      cnt += 1
    end
  end
  ans = cnt if cnt > ans
end

puts ans

Measured memory_bytes: 1788
N = int(input())
A = list(map(int, input().split()))

length = 0
L = sum(A)

for i in range(N):
    length += A[i]
    if length >= L / 2:
        cut = i
        break    

sum_left1 = length
sum_right1 = L - length

sum_left2 = length - A[cut]
sum_right2 = sum_right1 + A[cut]

ans = min(abs(sum_left1 - sum_right1),abs(sum_left2-sum_right2))
print(ans)

Measured memory_bytes: 26220
import std.stdio, std.array, std.string, std.conv, std.algorithm;
import std.typecons, std.range, std.random, std.math, std.container;
import std.numeric, std.bigint, core.bitop, core.stdc.string;

immutable long MOD = 998244353;

int[] gcd(int[] a, int[] b) {
    while (true) {
        if (a.length < b.length) swap(a, b);
        if (b.length == 0) return a.dup;
        ulong msb = a.length;

        foreach (i; 0..a.length) {
            if (i < b.length) {
                a[i] ^= b[i];
            }
            if (a[i]) {
                msb = min(i, msb);
            }
        }

        a = a[msb..$];
    }
}

void main() {
    auto s = readln.split;
    auto N = s[0].to!int;
    auto X = s[1].map!(a => to!int(a == '1')).array;
    auto P = N.iota.map!(_ => readln.chomp.map!(a => to!int(a == '1')).array).array;

    auto G = P.front.dup;
    foreach (i; 1..N) G = gcd(G, P[i].dup);

    long ans = 0;

    for (long i = X.length.to!long - G.length.to!long, tmp = 1; i >= 0; i -= 1, tmp = tmp * 2 % MOD) {
        if (X[i]) {
            ans = (ans + tmp) % MOD;
        }
    }


    auto M = new int[](X.length);

    for (int i = 0; i + G.length <= M.length; ++i) {
        if (M[i] != X[i]) {
            for (int j = 0; j < G.length; ++j) {
                M[i+j] ^= G[j];
            }
        }
    }

    if (M <= X) {
        ans = (ans + 1)  % MOD;
    }

    ans.writeln;
}


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

// Shrotening
#define fst first
#define snd second
#define pb push_back

#define REP(i,a) for(long i=0;i<(a);++i)
#define EACH(i,a) for(auto (i)=(a).begin(),_END=(a).end();i!=_END;++i)

typedef long long Weight;
const Weight WEIGHT_INF = std::numeric_limits<Weight>::max()/4;

struct Edge {
    int src, dst;
    Weight weight;
};
bool operator<(const Edge& a, const Edge& b) {
    return (a.weight < b.weight);
};
bool operator>(const Edge& a, const Edge& b) {
    return (a.weight > b.weight);
};
typedef std::vector<Edge> Edges;
typedef std::vector<Edges> Graph;

//Bellman-ford
Graph g;
std::vector<Weight> costs;
std::vector<int> trace;
bool bellmanFord(int start) {
    int n = g.size();
    costs.resize(n, WEIGHT_INF);
    trace.resize(n, -2);
    costs[start] = 0;
    trace[start] = -1;

    bool negativeCycle = false;
    REP(k, n) REP(i, n) if(costs[i] != WEIGHT_INF) EACH(e, g[i]) {
        if(costs[e->dst] > costs[e->src] + e->weight){
            costs[e->dst] = costs[e->src] + e->weight;
            trace[e->dst] = e->src;
            if(k == n-1){
                costs[e->dst] = -WEIGHT_INF;
                negativeCycle = true;
            }
        }
    }
    return !negativeCycle;
}

int N, M;
int main() {
    std::cin >> N >> M;
    g.resize(N);
    REP(i, M) {
        int a, b, c;
        std::cin >> a >> b >> c;
        a -= 1;
        b -= 1;
        c *= -1;
        
        Edge e{a, b, c};
        g[a].pb(e);
    }
    bellmanFord(0);
    if(costs[N-1] == -WEIGHT_INF) {
        std::cout << "inf" << std::endl;
    } else {
        std::cout << -costs[N-1] << std::endl;
    }
}

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


    

    char c;
    cin>> c;

    if(islower(c)) cout <<"a"<< endl;
    else cout <<"A"<< endl;
    return 0 ;

//    cout <<"Bojan"
}

Measured memory_bytes: 3552
//#define judge
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> PII;
const int inf = 0x3f3f3f3f;
const int ninf = 0xcfcfcfcf;
const double pi = acos(-1.0);
int a, b, c;

int main() {
  cin >> a >> b >> c;
  if (a == b && b != c || a == c && a != b || b == c && a != b) {
    puts("Yes");
  } else {
    puts("No");
  }
  return 0;
}

Measured memory_bytes: 256
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
 
def main():
    n = int(readline())
    a = [int(i) for i in readline().split()]
    for i in a:
        if i == 0:
            print(0)
            return
    ans = 1
    INF = int(1e18)
    for i in a:
        ans *= i
        if ans > INF:
            print(-1)
            return
    print(ans)
if __name__ == '__main__':
    main()


Measured memory_bytes: 85640
#include <bits/stdc++.h>
using namespace std;
struct point{double x;double y;};
int i,j,k,count1=0,count2=0;

int main(void){
    int n;
    cin>>n;
    vector<int> vec(3*n);
    for(i=0;i<3*n;i++){
        cin>>vec[i];
        cerr<<vec[i]<<" ";
    }
    sort(vec.rbegin(),vec.rend());
    cerr<<endl;
    for(i=0;i<3*n;i++){
        cerr<<vec[i]<<" ";
    }
    cerr<<endl;
    long long int ans=0;
    for(i=1;i<2*n;i++){
        ans+=vec[i];
        i++;
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 1408
#include <iostream>
#include <string>
#include <vector>
#include <cstdlib>
#include <cstdio>
#include <cmath>
#include <algorithm>
#include <map>
#include <stack>
#include <queue>
#include <set>
#include <cstring>

using namespace std;
// ascending order
#define vsort(v) sort(v.begin(), v.end())
// descending order
#define vsort_r(v) sort(v.begin(), v.end(), greater<int>())
#define vunique(v) unique(v.begin(), v.end())
#define mp make_pair
#define ts(x) to_string(x)
#define rep(i, a, b) for(int i = (int)a; i < (int)b; i++)
#define repm(i, a, b) for(int i = (int)a; i > (int)b; i--)
#define bit(a) bitset<8>(a)
#define des_priority_queue priority_queue<int, vector<int>, greater<int> >
typedef long long ll;
typedef pair<int, int> P;
const ll INF = 1e18;

#define MAX_V 1000000

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

	int N;
	cin >> N;
	ll num[5];
	memset(num, 0, sizeof(num));

	rep(i, 0, N) {
		string s;
		cin >> s;
		if(s[0] == 'M') num[0]++;
		else if(s[0] == 'A') num[1]++;
		else if(s[0] == 'R') num[2]++;
		else if(s[0] == 'C') num[3]++;
		else if(s[0] == 'H') num[4]++;
	}

	ll res = 0;
	rep(i, 0, 5) rep(j, i + 1, 5) rep(k, j + 1, 5) res += (num[i] * num[j] * num[k]);

	cout << res << endl;


}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define int long long
#define FOR(i, a, b) for (int i = a; i < b; ++i)
#define rep(N) for (int i = 0; i < N; ++i)
#define Rep(a, b) for (int i = a; i < b; ++i)
#define For(i, N) for (int i = 0; i < N; ++i)
#define all(v) v.begin(), v.end()
#define rev(v) v.rbegin(), v.rend()
#define makei(N) int N; cin >> N;
#define makes(s) string s; cin >> s;
#define maked(d) double d; cin >> d;
#define makev(v, N) vi v(N); rep(N)cin >> v[i];
#define mod 1000000007

using namespace std;
using ll = long long;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using vll = vector<ll>;
using vb = vector<bool>;
using vvb = vector<vector<bool>>;
using vs = vector<string>;
using pii = pair<int, int>;
using pis = pair<int, string>;
using msi = map<string, int>;

template<typename T>
void say(T s) {
	cout << s << "\n";
}

template<typename T>
void say(vector<T> s) {
	auto itr = s.begin();
	cout << *(itr++);
	while (itr != s.end()) {
		cout << " " << *(itr++);
	}
	cout << "\n";
}

void yn(bool b) {
	if (b)say("yes");
	else say("no");
}

void Yn(bool b) {
	if (b)say("Yes");
	else say("No");
}

void YN(bool b) {
	if (b)say("YES");
	else say("NO");
}

template<typename T>
void maxi(T& a, T b) {
	a = max(a, b);
}

template<typename T>
void mini(T& a, T b) {
	a = min(a, b);
}

void exact_say(double x) {
	cout << setprecision(numeric_limits<double>::max_digits10) << x << endl;
}

template<class T> void getVector(vector<T>& v) {
	for (int i = 0; i < v.size(); ++i)
		cin >> v[i];
}

std::string revString(std::string s) {
	string ret;
	auto it = s.rend();
	while (it != s.rbegin()) {
		ret.push_back(*it);
		++it;
	}
	return ret;
}

signed main() {
	while (true) {
		makei(h);
		makei(w);
		if (h == 0 && w == 0)break;
		string s1, s2;
		rep(w)s1.push_back('#');
		s2.push_back('#');
		rep(w - 2)s2.push_back('.');
		s2.push_back('#');
		cout << s1 << endl;
		rep(h - 2)cout << s2 << endl;
		cout << s1 << endl;
		cout << endl;

	}
}


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

int main() {
    int X; cin >> X;
    bitset<100010> dp;
    dp[0] = 1;
    rep(i, 6) rep(_, 1010) dp |= dp << (100 + i);
    if(dp[X]) cout << 1 << '\n';
    else cout << 0 << '\n';
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
#define fast_io()  ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);

int main() {
	fast_io();
	ll t=1; //cin>>t;
	while(t--){
	    ll n,i; cin>>n;
	    vector<char> a(26);
	    for(i=1;i<26;i++)
	        a[i]+=('a'+i-1);
	    a[0]='z';
	    string ans;
	    while(n){
	        ans+=a[n%26];
	        n=(n-1)/26;
	    }
	    for(i=ans.size()-1;i>=0;i--)
	        cout<<ans[i];
	}
	return 0;
}


Measured memory_bytes: 3608
#include<iostream>
#include<fstream>
#include<algorithm>
#include<list>
using namespace std;

int main() {
	int i, j, n;
	long long int x;
	list<long long int> l;
	list<long long int>::iterator itl;
	//ifstream fin("ALDS1_3_C-in10.txt");
	//if (!fin) {
	//	cout << "failed to open the file\n";
	//	return 1;
	//}
	//ofstream fout("out.txt");
	cin >> n;
	for (i = 0; i < n; i++) {
		char com[15] = {};
		cin >> com;
		if (com[0] == 'i') {
			cin >> x;
			l.push_front(x);
		}
		else if (com[6] == 'F')l.pop_front();
		else if (com[6] == 'L')l.pop_back();
		else if (com[0] == 'd') {
			cin >> x;
			for (itl = l.begin(); itl != l.end(); itl++) {
				if (*itl == x) {
					l.erase(itl);
					break;
				}
			}
		}
	}
	for (itl = l.begin(); itl != l.end(); itl++) {
		if (itl != l.begin())cout << " ";
		cout << *itl;
	}
	cout << endl;
	//fin.close();
	//fout.close();
	return 0;
}

Measured memory_bytes: 32448
#include <limits.h>
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <algorithm>
#include <cassert>
#include <cfloat>
#include <complex>
#include <functional>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <vector>

using namespace std;

#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
#define rep(i, n) for (ll i = 0; i < (n); ++i)
#define Sort(v) sort(v.begin(), v.end())
#define Reverse(v) reverse(v.begin(), v.end())
#define Lower_bound(v, x) \
  distance(v.begin(), lower_bound(v.begin(), v.end(), x))
#define Upper_bound(v, x) \
  distance(v.begin(), upper_bound(v.begin(), v.end(), x))

using ll = long long;
using ull = unsigned long long;
using P = pair<ll, ll>;
using T = tuple<ll, ll, ll>;
using vll = vector<ll>;
using vP = vector<P>;
using vT = vector<T>;
using vvll = vector<vector<ll>>;
using vvP = vector<vector<P>>;
using dqll = deque<ll>;

ll dx[9] = {-1, 1, 0, 0, -1, -1, 1, 1, 0};
ll dy[9] = {0, 0, -1, 1, -1, 1, -1, 1, 0};

const ll INF = 1LL << 50;

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

  vll bcum(n + 1, 0);
  vll wcum(n + 1, 0);
  rep(i, n) {
    if (s[i] == '.') {
      wcum[i + 1] = wcum[i] + 1;
      bcum[i + 1] = bcum[i];
    } else {
      wcum[i + 1] = wcum[i];
      bcum[i + 1] = bcum[i] + 1;
    }
  }
  ll ans = LONG_LONG_MAX;
  rep(i, n + 1) {
    ll w = bcum[i];
    ll b = wcum[n] - wcum[i];
    chmin(ans, w + b);
  }

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 3716
[m,n] = list(map(int, input().split()))
s = input()
t = input()
ans = -1

for i in range(m):
	if m%(i+1) == 0 and n%(i+1) ==0:
		gcd = i+1

m1 = m//gcd
n1 = n//gcd

flag = 1
for i in range(gcd):
	if s[i*m1]!=t[i*n1]:
		flag = 0
	
	
if flag == 1:
	ans = m*n//gcd

print(ans)

Measured memory_bytes: 3316
n, a, b = map(int, input().split())
total = 0


def calc(n):
    sum = 0
    while n > 0:
        sum += n % 10
        n = n // 10
    return sum

for i in range(n+1):
    if a <= calc(i) & calc(i) <= b:
        total += i

print(total)


Measured memory_bytes: 2940
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <string>
#include <cstring>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <cmath>
#include <iomanip>
#include <cassert>
#include <bitset>
using namespace std;

typedef pair<int, int> P;
#define rep(i, n) for (int i=0; i<(n); i++)
#define all(c) (c).begin(), (c).end()
#define uniq(c) c.erase(unique(all(c)), (c).end())
#define index(xs, x) (int)(lower_bound(all(xs), x) - xs.begin())
#define _1 first
#define _2 second
#define pb push_back
#define INF 1145141919
#define MOD 1000000007
inline void chmax(int &x, int v) { if (x < v) x = v; }
struct UF {
  int N;
  int U[15], R[15];
  UF(int N) : N(N) {
    rep(i, N) U[i] = i, R[i] = 1;
  }
  int find(int x) {
    if (U[x] == x) return x;
    return U[x] = find(U[x]);
  }
  void unite(int x, int y) {
    x = find(x), y = find(y);
    if (x == y) return;
    if (R[x] < R[y]) swap(x, y);
    U[y] = x;
    R[x] += R[y];
  }
};

int N, M;
int G[15][15];
int IN[1<<15];
int dp[1<<15][15];

signed main() {
  ios::sync_with_stdio(false); cin.tie(0);
  cin >> N >> M;
  rep(i, N) rep(j, N) G[i][j] = -1;
  int all = 0;
  rep(i, M) {
    int a, b, c;
    cin >> a >> b >> c;
    a--, b--;
    G[a][b] = G[b][a] = c;
    all += c;
  }
  rep(S, 1<<N) {
    UF uf(N);
    int repr = -1;
    rep(i, N) rep(j, i) if ((((S>>i)&1) && (S>>j)&1) && G[i][j] != -1) {
      repr = i;
      uf.unite(i, j);
      IN[S] += G[i][j];
    }
    int c = __builtin_popcount(S);
    if (c > 1 && (repr == -1 || uf.R[uf.find(repr)] < c)) IN[S] = -INF;
  }

  rep(i, 1<<N) rep(j, N) dp[i][j] = -INF;
  dp[0][0] = 0;
  rep(S, 1<<N) {
    rep(pos, N) if ((S>>pos)&1) {
      for (int T=S; T>0; T=(T-1)&S) if ((T>>pos)&1) {
        if (dp[S^T][pos] == -INF || IN[T] == -INF) continue;
        chmax(dp[S][pos], dp[S^T][pos] + IN[T]);
      }
      if (dp[S][pos] == -INF) continue;
      rep(next, N) if (((S>>next)&1) == 0 && G[pos][next] != -1) {
        chmax(dp[S][next], dp[S][pos] + G[pos][next]);
      }
    }
  }
  int m = 0;
  rep(i, 1<<N) if ((i>>(N-1))&1) chmax(m, dp[i][N-1]);
  cout << all-m << "\n";
  return 0;
}


Measured memory_bytes: 2304
#include<iostream>
#include<algorithm>
#include<vector>
#include<functional>
#include<string>
#include<cmath>
#include<map>
#include<set>
#include<queue>
#include<stack>
#include<cstdio>
using namespace std;
using ll = long long;
int main(){
  string s;
  cin >> s;
  for(int i = 0; i<19; i++){
    if(i == 5 || i == 13){
      cout << " ";
    }else{
      cout << s[i];
    }
  }
  cout << endl;
  return 0;
}

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

int main() {
  string s;
  cin >> s;
  char ch[26];
  rep(i,26) ch[i] = 'a'+ i;
  int num[26] = {};
  sort(s.begin(), s.end());
  string ans = "None";
  
  for (int i = 0; i < s.size(); ++i){
    for (int j = 0; j < 26; ++j){
      if(s[i] == ch[j]) num[j]++;
    }
  }
  for (int i = 0; i < 26; ++i){
    if(num[i]==0) {ans = ch[i]; break;}
  }
  cout << ans << endl;
  return 0;
}


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

#define rep(i, m, n) for(int(i) = (int)(m); i < (int)(n); ++i)
#define rep2(i, m, n) for(int(i) = (int)(n)-1; i >= (int)(m); --i)
#define REP(i, n) rep(i, 0, n)
#define REP2(i, n) rep2(i, 0, n)
#define all(hoge) (hoge).begin(), (hoge).end()
#define en '\n'
using ll = long long;
using ull = unsigned long long;
template <class T>
using vec = vector<T>;
template <class T>
using vvec = vector<vec<T>>;
typedef pair<ll, ll> P;
constexpr long long INF = 1LL << 60;
constexpr int INF_INT = 1 << 25;
constexpr long long MOD = (ll)1e9 + 7;
//constexpr long long MOD = 998244353LL;
using ld = long double;
static const ld pi = 3.141592653589793L;
typedef vector<ll> Array;
typedef vector<Array> Matrix;

template <class T>
inline bool chmin(T &a, T b) {
    if(a > b) {
        a = b;
        return true;
    }
    return false;
}
template <class T>
inline bool chmax(T &a, T b) {
    if(a < b) {
        a = b;
        return true;
    }
    return false;
}

struct Edge {
    ll to, rev;
    long double cap;
    Edge(ll _to, long double _cap, ll _rev) {
        to = _to;
        cap = _cap;
        rev = _rev;
    }
};
using Edges = vector<Edge>;
using Graph = vector<Edges>;

void add_edge(Graph &G, ll from, ll to, long double cap, bool revFlag,
              long double revCap) {
    G[from].push_back(Edge(to, cap, (ll)G[to].size()));
    if(revFlag)
        G[to].push_back(Edge(from, revCap, (ll)G[from].size() - 1));
}

void solve() {
    ll n, m;
    cin >> n >> m;
    vec<ll> sw(n, 0);
    REP(i, m) {
        ll k;
        cin >> k;
        REP(j, k) {
            ll s;
            cin >> s;
            s--;
            sw[s] += (1LL << i);
        }
    }
    vec<ll> p(m);
    REP(i, m) {
        cin >> p[i];
    }

    ll ans = 0;
    ll all = 1LL << n;
    REP(bit, all) {
        ll state = 0;
        REP(i, n) {
            if((bit >> i) & 1) {
                state ^= sw[i];
            }
        }
        ll con = 0;
        REP(i, m) {
            if((state >> i) & 1) {
                if(p[i])
                    con++;
            } else {
                if(!p[i])
                    con++;
            }
        }
        if(con == m)
            ans++;
    }
    cout << ans << en;
}

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

    solve();

    /*
    ll t;
    cin >> t;
    REP(i, t) { solve();}
    */

    return 0;
}


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

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

#define FOR(i, n, m) for (ll(i) = (m); (i) < (n); ++(i))
#define REP(i, n) FOR(i, n, 0)
#define OF64 std::setprecision(10)

const ll MOD = 1000000007;
const ll INF = (ll)1e15;

int main()
{
    ll A;
    string S;
    cin >> A >> S;
    if (A >= 3200)
        cout << S << endl;
    else
        cout << "red" << endl;
    return 0;
}

Measured memory_bytes: 764
#include<iostream>
#include<vector>

using namespace std;

int main()
{
    int H, W;
    int count;
    vector<int> h, w;

    while(1)
    {
        cin >> H >> W;
        if(H == 0 && W == 0)
            break;
        else
        {
            h.push_back(H);
            w.push_back(W);
            count++;
        }
    }

    for(int i = 0; i < count; i++)
    {
        for(int j = 0; j < h[i]; j++)
        {
            for(int k = 0; k < w[i]; k++)
            {
                if(j % 2 == 0)
                {
                    if(k % 2 == 0)
                    {
                        cout << "#";
                    }
                    else
                    {
                        cout << ".";
                    }
                }
                else
                {    
                    if(k % 2 == 0)
                    {
                        cout << ".";
                    }
                    else
                    {
                        cout << "#";
                    } 
                }
            }
            cout << endl;
        }
        cout << endl;
    }
    return 0;
} 

Measured memory_bytes: 1212
#include <iostream>
#include <cstdio>
#include <vector>
#include <stack>
#include <math.h>

using namespace std;

typedef long long int ll;
typedef long double ld;

#define rep(i,n) for(int i = 0; i < (n); ++i)
#define vsort(a) sort(a.begin(), a.end())
#define rev(a) reverse(a.begin(), a.end())

const int MOD = 1000000007;
const int INF = INT_MAX;



int main(){

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

    ll e = c*d;
    ll r = c % d;
    ll cc = c;
    ll dd = d;
    while (r != 0){
        cc = dd;
        dd = r;
        r = cc % dd;
    }
    e /= dd;

    cout << b - (a-1) -b/c + (a-1)/c - b/d + (a-1)/d + b/e - (a-1)/e << endl;
    

}





//              g++ -std=c++1z

Measured memory_bytes: 888
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
const int N=5010;
ll dist[N][N],circle[N],mark[N];
bool st[N];
int pos[N],n;
ll k;
int main()
{
    cin>>n>>k;
    for(int i=1;i<=n;i++) cin>>pos[i];
    for(int i=1;i<=n;i++) cin>>mark[i];
    for(int i=1;i<=n;i++)
    {
        memset(st,0,sizeof st);
        int j=pos[i],idx=0;
        while(!st[j])
        {
            st[j]=1;
            idx++;
            dist[i][idx]=dist[i][idx-1]+mark[j];
            j=pos[j];
        }
        circle[i]=idx;
        
    }
    ll res=-1e18;
    for(int i=1;i<=n;i++)
        for(int j=1;j<=circle[i];j++)
        {
            ll x=dist[i][j];
            if(k<j) break;
            if(dist[i][circle[i]]>=0) x+=(k-j)/circle[i]*dist[i][circle[i]];
            res=max(res,x);
        }
    cout<<res<<endl;
    return 0;
}


Measured memory_bytes: 199416
#include<bits/stdc++.h>
using namespace std;
double ans;
int a[200005],sum[200005];
int n,k,x,ans1,tmp;
int main(){
   cin>>n>>k;
   for(int i=1;i<=n;i++)
    {
    	cin>>a[i];
    	sum[i]=sum[i-1]+a[i];
    }
    for(int i=1;i<=n-k+1;i++) //从i开始的连续 k个数的和 ，即从i,i+1,...i+k-1 
    {
    	if(sum[i+k-1]-sum[i-1]>=ans1)
		  ans1=sum[i+k-1]-sum[i-1],tmp=i;
    }  
      for(int i=tmp;i<=tmp+k-1;i++)
    	   ans+=(1+a[i])/2.0; 
    printf("%.12lf",ans);
	return 0;
}


Measured memory_bytes: 1792
def main():
  x,a,b = map(int,input().split())
  sumb = (x - a) + b - x
  if x >= sumb:
    ans = "safe"
  if 0 >= sumb:
    ans = "delicious"
  if x < sumb:
    ans = "dangerous"
  print(ans)
if __name__ == '__main__':
  main()

Measured memory_bytes: 3064
n = int(input())
a = list(map(int, input().split()))
count_t = list(filter(lambda x: x < 0, a))
count = len(count_t)
s = []
for i in a:
    if i < 0:
        s.append(i * -1)
    else:
        s.append(i)

if count % 2 == 0 or a.count(0) > 0:
    print(sum(s))
else:
    print(sum(s) - min(s) * 2)


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

int main() {
  int INF = 1001001001;
  int N, M, X;
  cin >> N >> M >> X;
  vector<int> nedan(N);
  vector<vector<int>> rikai(N, vector<int>(M));
  for(int i=0; i < N; i++) {
    cin >> nedan.at(i);
    for(int j=0; j < M; j++) {
      cin >> rikai.at(i).at(j);
    }
  }
  int ans = INF;
  for(int i=0; i < (1<<N); i++) {
    int cost = 0;
    vector<int> und(M, 0);
    for(int j=0; j < N; j++) {
      if(i>>j&1) {
        cost += nedan.at(j);
        for (int k=0; k < M; k++) {
          und.at(k) += rikai.at(j).at(k);
        }
      }
    }
    bool ok = true;
    for(int i=0; i < M; i++) {
      if (und.at(i) < X) {
        ok = false;
      }
    }
    if(ok) {
      ans = min(ans, cost);
    }
  }
  if(ans == INF) {
    cout << -1 << endl;
  } else {
    cout << ans << endl;
  }
}

Measured memory_bytes: 3636
import java.util.*;
class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int x = 0;
        int y = 0;

        while(true){
            x = sc.nextInt();
            y = sc.nextInt();
            if(x == 0 && y == 0){
                break;
            }
            if(x < y){
                System.out.println(x + " " + y);
            } else {
                System.out.println(y + " " + x);
            }
        }
    }
}


Measured memory_bytes: 35172
n,x=map(int,input().split())
a=list(map(int,input().split()))
ans=0
for i in range(n-1):
    if a[i]+a[i+1]>x:
        if a[i]>x:
            ans+=a[i+1]
            a[i+1]=0
            ans+=a[i]-x
            a[i]=x
        else:
            ans+=a[i]+a[i+1]-x
            a[i+1]=x-a[i]
print(ans)


Measured memory_bytes: 14060
//#include <cstdio>
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <map>
#include <set>
#include <queue>
//#include <stack>
#include <cstring>
#include <cassert>

using namespace std;

#ifdef LOCAL_DEBUG
#include <local_debug.h>
#define DEBUG(...) DBG2::print(#__VA_ARGS__, __LINE__, __VA_ARGS__)
#else
#define DEBUG(...)
#endif

#define SZ(a) int((a).size())
#define REP(i,n) for(int i=0,_n=(n);i<_n;++i)
#define FOR(i,a,b) for(int i=(a),_b=(b);i<=_b;++i)

typedef long long llong;
typedef vector<int> VI;
typedef vector<VI> VVI;

struct Pos {
   int row, col;
};

int dr[] = {-1, 0, 0, 1};
int dc[] = {0, -1, 1, 0};

int R, C;
char B[1004][1004];
bool vis[1004][1004];
int D[1004][1004];

const int INF = 100000000;

int main(int argc, char* argv[]) {
   ios_base::sync_with_stdio(false); 
   cin.tie(nullptr);

   memset(B, '#', sizeof(B));
   cin >> R >> C;

   Pos src, dst;
   cin >> src.row >> src.col;
   cin >> dst.row >> dst.col;

   FOR(r, 1, R) {
      cin >> (B[r]+1);
      B[r][C+1] = '#';
      B[r][C+2] = 0;
   }
   B[0][C+2] = 0;
   B[R+1][C+2] = 0;

   FOR(r, 1, R)
      FOR(c, 1, C)
         D[r][c] = INF;
   D[src.row][src.col] = 0;

   deque<Pos> q;
   q.push_back(src);
   
   while (!q.empty()) {
      Pos cur = q.front();
      q.pop_front();
      int dist = D[cur.row][cur.col];

      DEBUG(cur.row, cur.col, dist);

      if (cur.row == dst.row && cur.col == dst.col) {
         cout << dist << '\n';
         return 0;
      }
      if (vis[cur.row][cur.col])
         continue;
      vis[cur.row][cur.col] = true;
      REP(k, 4) {
         Pos nxt = {cur.row + dr[k], cur.col + dc[k]};
         if (B[nxt.row][nxt.col] == '#') continue;
         if (D[nxt.row][nxt.col] > dist) {
            D[nxt.row][nxt.col] = dist;
            q.push_front(nxt);
         }
      }
      FOR(r, max(cur.row-2,1), min(cur.row+2,R)) {
         FOR(c, max(cur.col-2,1), min(cur.col+2,C)) {
            Pos nxt = {r, c};
            if (B[nxt.row][nxt.col] == '#') continue;
            if (D[nxt.row][nxt.col] > dist + 1) {
               D[nxt.row][nxt.col] = dist + 1;
               q.push_back(nxt);
            }
         }
      }
   }
   cout << "-1\n";

   return 0;
}


Measured memory_bytes: 9616
def abc116_b():
    s = int(input())
    a = [None] * 1000000
    a[0] = s
    for i in range(1, 1000000):
        if a[i - 1] % 2:
            a[i] = 3 * a[i - 1] + 1
        else:
            a[i] = a[i - 1] // 2
        if a[i] in a[:i - 1]:
            print(i + 1)
            break


abc116_b()

Measured memory_bytes: 10868
import java.util.*;

public class Main {

    public static void main(String[] args) {
        // write your code here
        Scanner sc = new Scanner(System.in);

        int n = sc.nextInt();

        long ans = 1;

        PriorityQueue<Long> queue = new PriorityQueue<>(Comparator.reverseOrder());

        for (int i = 0; i < n; i++) {
            queue.add(sc.nextLong());
        }

        for (int i = 0; i < n; i++) {
            ans = lcm(queue.poll(), ans);
        }

        System.out.println(ans);
    }

    private static long lcm(long a, long b) {
        return Math.max(a, b) / gcd(a, b) * Math.min(a, b);
    }

    private static long gcd(long a, long b) {
        long temp;
        while ((temp = a % b) != 0) {
            a = b;
            b = temp;
        }
        return b;
    }
}

Measured memory_bytes: 21844
#include <bits/stdc++.h>
using namespace std;
#define in ({int x=0;int c=getchar(),n=0;for(;!isdigit(c);c=getchar()) n=(c=='-');for(;isdigit(c);c=getchar()) x=x*10+c-'0';n?-x:x;})
#define forinc(i,a,b) for(int i=a;i<=b;i++)
#define fordec(i,a,b) for(int i=a;i>=b;i--)
#define pii pair<int,int>
#define int long long
#define fi first
#define se second
#define getbit(i,x) ((x>>i)&1ll)

const int maxn=2e5+10,mod=2019;
int n,pw[maxn];
string s;
int T[maxn],cnt[maxn];
main()
{
  //  freopen("test.inp","r",stdin);
    ios_base::sync_with_stdio(false);
    cin>>s;
    n=s.size();
    pw[0]=1;
    forinc(i,1,n) pw[i]=pw[i-1]*10%mod;
    s=' '+s;
    T[n+1]=0;
    fordec(i,n,1){
        T[i]=((s[i]-'0')*pw[n-i]%mod+T[i+1])%mod;
      //  cout<<T[i]<<" ";
        cnt[T[i]]++;
    }
    //return 0;
    int ret=0;
    forinc(i,0,2018){
        if(i==0) ret+=(cnt[i]*(cnt[i]+1))/2;
        else ret+=(cnt[i]*(cnt[i]-1))/2;
    }
    cout<<ret;
}


Measured memory_bytes: 6832
import scala.io.StdIn._
object Main extends App {
  val x = readInt
  println(count(1, 0))

  @scala.annotation.tailrec
  def count(i: Int, sum: Int): Int = i + sum match {
    case n if n >= x => i
    case n => count(i + 1, n)
  }
}

Measured memory_bytes: 25548
#include<cstdio>
#include<iostream>
#include<cmath>
#include<algorithm>
#include<cstring>
#include<queue>
#include<map> 
#include<bitset>
#include<vector>
using namespace std;
#define int long long
#define re register int
inline int read(){
    int x=0,ff=1;char c=getchar();
    while(c<'0'||c>'9'){if(c=='-')ff=-1;c=getchar();}
    while(c>='0'&&c<='9'){x=(x<<1)+(x<<3)+(c^48);c=getchar();}
    return x*ff;
}
int n,k,a[200005],s;
signed main(){
	n=read();k=read();
	for(re i=1;i<=n;i++)a[i]=read();
	sort(a+1,a+n+1);
	for(re i=1;i<=n-k;i++)s+=a[i];
		cout<<s<<endl;
   	return 0;
}


Measured memory_bytes: 1792
#include <bits/stdc++.h>
#define fi first
#define se second
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define rng(a) a.begin(),a.end()
#define maxs(x,y) (x = max(x,y))
#define mins(x,y) (x = min(x,y))
#define limit(x,l,r) max(l,min(x,r))
#define lims(x,l,r) (x = max(l,min(x,r)))
#define isin(x,l,r) ((l) <= (x) && (x) < (r))
#define pb push_back
#define sz(x) (int)(x).size()
#define pcnt __builtin_popcountll
#define uni(x) x.erase(unique(rng(x)),x.end())
#define snuke srand((unsigned)clock()+(unsigned)time(NULL));
#define show(x) cout<<#x<<" = "<<x<<endl;
#define PQ(T) priority_queue<T,v(T),greater<T> >
#define bn(x) ((1<<x)-1)
#define dup(x,y) (((x)+(y)-1)/(y))
#define newline puts("")
#define v(T) vector<T>
#define vv(T) v(v(T))
using namespace std;
typedef long long int ll;
typedef unsigned uint;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
inline int in() { int x; scanf("%d",&x); return x;}
template<typename T>inline istream& operator>>(istream&i,v(T)&v)
{rep(j,sz(v))i>>v[j];return i;}
template<typename T>string join(const v(T)&v)
{stringstream s;rep(i,sz(v))s<<' '<<v[i];return s.str().substr(1);}
template<typename T>inline ostream& operator<<(ostream&o,const v(T)&v)
{if(sz(v))o<<join(v);return o;}
template<typename T1,typename T2>inline istream& operator>>(istream&i,pair<T1,T2>&v)
{return i>>v.fi>>v.se;}
template<typename T1,typename T2>inline ostream& operator<<(ostream&o,const pair<T1,T2>&v)
{return o<<v.fi<<","<<v.se;}
template<typename T>inline ll suma(const v(T)& a) { ll res(0); for (auto&& x : a) res += x; return res;}
const double eps = 1e-10;
const ll LINF = 1001002003004005006ll;
const int INF = 1001001001;
#define dame { puts("-1"); return 0;}
#define yn {puts("Yes");}else{puts("No");}
const int MX = 200005;
#define RET(ans) {cout<<ans<<endl;return 0;} 

    // 二次元ベクターの基本
    /*
    vector<vector<int>> dp; // 宣言
    dp.resize(n); // 1次元めの要素数決定
    dp[i].push_back(int); // プッシュバック
    rep(i,n){
        sort(dp[i].begin(),dp[i].end()); // 二次元めを昇順ソート
    }
    */

    // 整数スキャン（複数）
    /*
    int x,y,z;
    scanf("%d%d%d",&x,&y,&z);

    // n個の整数のスキャン
    /*
    ll a[n] = {};
    rep(i,n){
        scanf("%lld",&a[i]);
    }
    */

    // 文字列スキャン
    /*
    string s; cin >> s;
    */

    // n個の文字列スキャン
    /*
    vector<string> slist;
    rep(i,n){
        string s; cin >> s;
        slist.push_back(s);
    }
    */

int main() {
    string s;
    cin >> s;
    ll a[256] = {};
    rep(i,s.size()){
        a[(int)s[i]]++;
    }


    ll ans = (s.size()*(s.size()-1))/2 + 1;

    rep(i,256){
        ans -= a[i]*(a[i]-1)/2;
    }
    
    cout << ans << endl;
    return 0;
}
 
 


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

using namespace std;
typedef long long int ll;
typedef pair<int, int> ii;

struct fastio {
    fastio() {
        ios::sync_with_stdio(false);
        cout << setprecision(10) << fixed;
        cin.tie(0);
    }
};

fastio _fast_io;

int n, a, b;

int main() {
    cin >> n >> a >> b;
    cout << min(n * a, b) << endl;
    return 0;
}


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

#define dump(...) cout<<"# "<<#__VA_ARGS__<<'='<<(__VA_ARGS__)<<endl
#define repi(i,a,b) for(int i=int(a);i<int(b);i++)
#define peri(i,a,b) for(int i=int(b);i-->int(a);)
#define rep(i,n) repi(i,0,n)
#define per(i,n) peri(i,0,n)
#define all(c) begin(c),end(c)
#define mp make_pair
#define mt make_tuple

using uint=unsigned;
using ll=long long;
using ull=unsigned long long;
using vi=vector<int>;
using vvi=vector<vi>;
using vl=vector<ll>;
using vvl=vector<vl>;
using vd=vector<double>;
using vvd=vector<vd>;
using vs=vector<string>;

template<typename T1,typename T2>
ostream& operator<<(ostream& os,const pair<T1,T2>& p){
	return os<<'('<<p.first<<','<<p.second<<')';
}

template<typename Tuple>
void print_tuple(ostream&,const Tuple&){}
template<typename Car,typename... Cdr,typename Tuple>
void print_tuple(ostream& os,const Tuple& t){
	print_tuple<Cdr...>(os,t);
	os<<(sizeof...(Cdr)?",":"")<<get<sizeof...(Cdr)>(t);
}
template<typename... Args>
ostream& operator<<(ostream& os,const tuple<Args...>& t){
	print_tuple<Args...>(os<<'(',t);
	return os<<')';
}

template<typename Ch,typename Tr,typename C>
basic_ostream<Ch,Tr>& operator<<(basic_ostream<Ch,Tr>& os,const C& c){
	os<<'[';
	for(auto i=begin(c);i!=end(c);++i)
		os<<(i==begin(c)?"":" ")<<*i;
	return os<<']';
}

constexpr int INF=1e9;
constexpr int MOD=1e9+7;
constexpr double EPS=1e-9;

int main()
{
	for(int n,l;cin>>n>>l && n|l;){
		vi a(n);
		rep(i,n) cin>>a[i];
		vi res;
		rep(i,n-1) if(a[i]+a[i+1]>=l){
			rep(j,i)
				res.push_back(j);
			peri(j,i,n-1)
				res.push_back(j);
			break;
		}
		if(res.size()){
			cout<<"Possible"<<endl;
			for(int x:res) cout<<x+1<<endl;
		}
		else
			cout<<"Impossible"<<endl;
	}
}


Measured memory_bytes: 1784
//============================
// ABC136b Uneven Numbers
//
// 2019/08/13
//============================

#include <iostream>
#include <string>
#include <math.h>
#include <map>
#include <algorithm>
#include <functional>

using namespace std;

int main(int argc, char* argv[])
{
  int N;
  cin >> N;

  int ans;
  for(int i=1; i<=6; i++)
  {
    if(N/pow(10,i))
    {

    }
  }

  if(N / 100000)
  {
    ans = 9 + 900 + 90000;
  }
  else if(N / 10000)
  {
    ans = 9 + 900 + (N-9999);
  }
  else if (N/1000)
  {
    ans = 9 + 900;
  }
  else if (N/100)
  {
    ans = 9 + (N-99);
  }
  else if (N/10)
  {
    ans = 9;
  }
  else
  {
    ans = N;
  } 

  cout << ans << endl;

  return 0;
}

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

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

  int idx = 0, ans = 0;
  for (int i = 0; i < s.size(); ++i) {
    int to = (s[i] - 'A');
    idx++;
    if (idx == 26) {
      idx = 0;
      ans++;
    }
    while (idx != to) {
      idx++;
      if (idx == 26) {
        idx = 0;
        ans++;
      }
    }
  }

  cout << ans << endl;
}

Measured memory_bytes: 3156
#include<iostream>
#include<vector>
#include<algorithm>

using namespace  std;

int main()
{
    double N;
    cin>>N;
    vector<double>v(N);
    for(int i=0;i<N;i++){
        cin>>v[i];
    }
    sort(v.begin(),v.end());
    for(int i=0;i<N-1;i++){
        v[i+1]=(v[i]+v[i+1])/2;
    }
    cout<<v[N-1]<<endl;
}

Measured memory_bytes: 256
/*~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=
*$* WRITER:kakitamasziru/OxOmisosiru *$*
~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=*/
#ifdef LOCAL_JUDGE
#define _GLIBCXX_DEBUG //FOR THE DEBUG! COMMENT OUT THIS WHEN SUBMITTING!
#endif
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <iomanip>
#include <limits>//setprecision
//#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
//#include <unordered_set> //unordered_set
#include <stack> // stack
#include <deque> // deque
#include <math.h>//pow,,,
#include <cmath>//abs,,,
#include <bitset> // bitset
//It is so troublesome that I include bits/stdc++.h !
using namespace std;

template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
const long long INF = 100100100100;
const long long MOD = 1000000007;
typedef pair<int,int> P;

//Solve N^M. This, mod_pow use Iterative Square Method.
long long mod_pow(long long N, long long M) {
    if (M == 0) return 1;
    long long res = mod_pow((N * N) % MOD, M / 2);
    //最下位ビット(*N)が1の時は単独でNをかける
    if (M & 1) res = (res * N) % MOD;

    return res %= MOD;
}

long long gcd(long long a, long long b) {
    if (b == 0) return a;
    else return gcd(b, a % b);
}
long long lcm(long long a, long long b) {
    return a * b / gcd(a, b);
}

int main() {
    string S;cin >> S;
    for(int i = 0;i<S.size()-1;i++){
        if(S.at(i) == 'A' && S.at(i+1) == 'C'){
            cout << "Yes" << endl;
            return 0;
        }
    }
    cout << "No" << endl;
}


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

typedef long long ll ;
#define rep (i , n ) for ( int i =0; i < n ; i++)
#define _sort(arg) sort(begin(arg), end(arg))
#define MOD 1000000007
#define pb push_back
#define DEBUG(x) cout << #x << ": " << x << endl;

/*
__attribute__((constructor))
void initial()
{
	cin.tie(NULL);
	ios::sync_with_stdio(false);
}
*/

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

	int A, B;
	char op;
	cin >> A >> op >> B;

	if (op == '+')
	{
		cout << A + B << endl;
	}
	else if (op == '-')
	{
		cout << A - B << endl;
	}

	
	return 0;
}

Measured memory_bytes: 256
import java.io.*;

public class Main {
    public static void main(String[] args){
        try(BufferedReader r = new BufferedReader(new InputStreamReader(System.in))) {
            int S = Integer.parseInt(r.readLine());
            int hour = S / 3600;
            int min = (S % 3600) / 60;
            int sec = S % 60;
            System.out.println(String.format("%d:%d:%d", hour, min, sec));
        }catch(IOException e){
            e.printStackTrace();
        }
    }
}



Measured memory_bytes: 24524
from sys import exit
N,M = [int(n) for n in input().split()]
P = [0]*M
Y = [0]*M
l = [0]*M
dic = dict(zip(range(1,N+1),[0]*N))
for i in range(M):
    P[i], Y[i] = [int(n) for n in input().split()]
    l[i] = [i,P[i], Y[i], str(P[i]).zfill(6)]

l = sorted(l,key=lambda x:x[2])
for i in range(M):
    dic[l[i][1]]+=1
    l[i][3]+=str(dic[l[i][1]]).zfill(6)
l = sorted(l,key=lambda x:x[0])
for i in range(M):
    print(l[i][3])
# a = [int(input()) for _ in range(N)]
# S = str(input())
# L = len(S)
# T = str(input())


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

using namespace std;

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    
    long n;
    cin >> n;
    // char s[n];
    string s;
    // scanf("%s", &s);
    cin >> s;
    long right_e = 0;
    for (long i = 0; i < n; i++) if (s[i] == 'E') right_e++;
    // for (long i = 1; i < n; i++) if (s[i] == 'E') right_e++;
    long min_count = right_e;
    long left_w = 0;
    for (long i = 0; i < n; i++) {
    // for (long i = 1; i < n; i++) {
        if (!min_count) break;
        if (s[i] == 'E') {
            right_e--;
        } else {
            right_e++;
        }
        // if (s[i ] == 'W') right_e++;
        // if (s[i -1] == 'W') left_w++;
        min_count = min(min_count, right_e);
    }
    cout << min_count << endl;
    
    return 0;
}

Measured memory_bytes: 720