akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>

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

  int a, b;
  cin >> a >> b;
  if (max(a, b) <= 8) {
    cout << "Yay!" << endl;
  } else {
    cout << ":(" << endl;
  }

  return 0;
}

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

int main() {
    ll N;
    cin >> N;
    ll r = sqrt(N);
    map<ll, ll> mp;
    for (ll i = 2; i <= r; i++) {
        if (N%i == 0) {
            ll pcnt = 0;
            while (N%i == 0) {
                N /= i;
                pcnt++;
            }
            mp[i] = pcnt;
        }
    }
    if (N > 1) mp[N] = 1;
    
    ll ans = 0;
    for (auto p : mp) {
        ll t = 1;
        while ((t+1)*(t+2)/2 <= p.second) t++;
        ans += t;
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 3724
N=int(input())
T,A=map(int,input().split())

tikasa=100000
motto=100000
answer=100
H=list(map(int,input().split()))

for i in range(len(H)):
  tempature=T-H[i]*0.006
  tikasa=abs(tempature-A)
  if tikasa<motto:
    motto=tikasa
    answer=i+1
print(answer)

Measured memory_bytes: 3064
n,d=map(int,input().split())
data=[]
for i in range(n):
    x=list(map(int,input().split()))
    data.append(x)
ans=0
for i in range(n-1):
    x_i=data[i]
    for j in range(i+1,n):
        x_j=data[j]
        dd=0
        for k in range(d):
            dd+=(x_i[k]-x_j[k])**2
        if (dd**0.5).is_integer()==True:
            ans+=1
print(ans)

Measured memory_bytes: 3188
n = int(input())
xs = list(map(int, input().split()))
A = max(xs)
dp = [0] * (A+1)
MOD = 1000000007

r = 1
zc = 0
for x in xs:
    if x == 0:
        zc += 1
    else:
        r = r * dp[x-1] % MOD
        dp[x-1] -= 1
    dp[x] += 1
if zc == 0 or zc >= 4:
    rr = 0
elif zc == 1:
    rr = 3
else:
    rr = 6
print(r * rr % MOD)
#print(MOD)
#print(115295190)


Measured memory_bytes: 52972
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
#define pb push_back
#define pf push_front
#define all(t) t.begin(), t.end()
#define inrange(i, a, b) (((i)>= min((a), (b))) && ((i) <= max((a), (b))))
typedef vector<ll> vi;
#define fi first
#define se second
#define show(x) cout << #x << " is " << x << "\n";
const ll inf = 9e18;
const ll mod = 1e9 + 7;
const ld pi = 3.141592653589793238462643383279502884;

void print(ll a[], ll n){for(ll i=0;i<n;i++){cout<<a[i]<<" ";}cout<<"\n";}
ll power(ll x, ll y, ll M = inf){
	if(y<=0) return 1;
    ll ans = 1;
    x %= M;
    while(y){
        if(y&1)
            ans = (x * ans) % M;

        x = (x * x) % M;
        y >>= 1;
    }
    return ans;
}
ll modInverse(ll n) {return power(n, mod-2, mod);}
inline ll mul(ll a, ll b){ return (a * b) % mod; }
inline ll sub(ll a, ll b){ ll c = a - b; if(c < 0) c += mod; return c; }
inline ll add(ll a, ll b){ ll c = a + b; if(c > mod) c -= mod; return c; }
inline ll divi(ll a, ll b){ return mul(a, modInverse(b)); }

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

//const ll N = 1e5 + 1;
//vector<ll> adj[N];
//bool visited[N];

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL); cout.tie(NULL);
    cout<<fixed<<setprecision(10);

	ll n;
	cin>>n;
	ll a[n];
	ll max1 = -1;
	ll max2 = -1;
	//map<ll, ll>
	for(int i=0;i<n;i++){
		cin>>a[i];
		if(a[i] > max1){
			max2 = max1;
			max1 = a[i];
		}
		else if(a[i] > max2){
			max2 = a[i];
		}
	}
	for(int i=0;i<n;i++){
		if(a[i]!=max1) cout<<max1<<"\n";
		else cout<<max2<<"\n";
	}


    return 0;
}


Measured memory_bytes: 3200
#include <bits/stdc++.h>
using namespace std;
#pragma GCC optimize("unroll-loops") 
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp> 
#define int long long
#define fr(i,a,b) for(int i = a ; i <= b ; ++i)
#define rep(i, a, b) for(int i = a; i < (b); ++i)
#define trav(a, x) for(auto& a : x)
#define all(x) begin(x), end(x)
#define rall(x) (x).rbegin(), (x).rend()
#define sz(x) (int)(x).size()
#define pb push_back
#define fst first
#define snd second
using namespace __gnu_pbds;
using ordered_set =
 tree<int, null_type,less<int>,
 rb_tree_tag,tree_order_statistics_node_update>;
//find_by_order(k):returns iterator to kth element starting from 0
//order_of_key(k):returns count of elements strictly smaller than k
typedef long long ll;typedef pair<int, int> pii;
typedef vector<int> vi;typedef long double ld;
template<class T>
using min_heap = priority_queue<T,vector<T>,greater<T>>; 
template<typename T> T gcd(T a, T b){return(b?__gcd(a,b):a);}
template<typename T> T lcm(T a, T b){return(a*(b/gcd(a,b)));}
template<class T> void re(T& x) { cin >> x; }
template<typename T> 
void remdup(vector<T>& v) {
	sort(all(v)); v.erase(unique(all(v)), v.end());
}
template<typename T> void re(vector<T> &v) {trav(i,v) cin >> i;}
template<class H, class... T> void re(H& h, T&... t) { re(h); re(t...); }
void unsyncIO() { ios_base::sync_with_stdio(0); cin.tie(0); }
#ifdef np
#include "/home/o_o/MyCodes/pr.h"
#else
#define trace(...)
#endif

#define MOD 1000000007  
//ref~ https://github.com/bqi343/USACO/blob/master/Implementations/content/graphs%20(12)/DSU/DSU%20(7.6).h
struct DSU {
	vi e; void init(int n) { e = vi(n,-1); }
	int find(int x) { return e[x] < 0 ? x : e[x] = find(e[x]); } 
	bool sameSet(int a, int b) { return find(a) == find(b); }
	int size(int x) { return -e[find(x)]; }
	bool unite(int x, int y) { // union-by-rank
		x = find(x), y = find(y); if (x == y) return 0;
		if (e[x] > e[y]) swap(x,y);
		e[x] += e[y]; e[y] = x; return 1;
	}
};
/**template<class T> T kruskal(int n, vector<pair<T,pii>> ed) {
	sort(all(ed));
	T ans = 0; DSU D; D.init(n+1); // edges that unite are in MST
	trav(a,ed) if (D.unite(a.s.f,a.s.s)) ans += a.f; 
	return ans;
}*/

void solve(){
	int n , m ;
	re(n,m);
	DSU d;
	d.init(n);
	while(m--){
		int a , b; 
		re(a,b);
		a--;b--;
		d.unite(a,b);
	}
	int cnt =0 ; 
	rep(i,0,n){
		cnt = max(cnt,d.size(i));
	}
	cout << cnt << endl; 
}

signed main() {
	unsyncIO();
	int tt =1 ;
	// cin >> tt;
	rep(i,0,tt) solve();













#ifdef np
	cout <<endl<<endl<< "Time elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " s.\n";
#endif
	return 0;
}


Measured memory_bytes: 4784
#include<iostream>
#include<stdio.h>

using namespace std;

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

	while (1) {

		cin >> a >> op >> b;

		switch (op)
		{
		case '+':
			cout << a + b << endl;
			break;

		case '-':
			cout << a - b << endl;
			break;

		case '*':
			cout << a * b << endl;
			break;

		case '/':
			cout << a / b << endl;
			break;

		default:
			break;
		}
		if (op == '?') {
			break;
		}
	}
	return 0;
}

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

int main() {
    while(true) {
        long N;
        cin >>N;
        if (0==N)
            break;
        long S=0;
        long D=0;
        for (long i=0; i<N; i++) {
            long s;
            cin >>s;
            S +=s;
            D +=s*s;
        }
        double STD=D*N-S*S;
        STD /=N;
        STD /=N;
        STD =sqrt(STD);
        cout <<fixed <<setprecision(10) <<STD <<endl;
    }
    return 0;
}


Measured memory_bytes: 3244
#include<bits/stdc++.h>
using namespace std;
#define lowbit(x) ((x)&-(x))
int main(){
	int n,m,i,j;
	cin >> n >> m;
	for(i=1;i<(1<<n);++i){
		for(j=1;j<(1<<m);++j)
			putchar((lowbit(i)==lowbit(j))+'0');
		puts("");
	}
	return 0;
}

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

using namespace std;

#define sz(v)           ((int)((v).size()))
#define clr(v, d)       memset(v, d, sizeof(v))
#define rep(i, v)       for(int i=0; i<sz(v); ++i)
#define lp(i, n)        for(int i=0; i<(int)(n); ++i)
#define lpi(i, j, n)    for(int i=(j); i<(int)(n); ++i)
#define lpd(i, j, n)    for(int i=(j); i>=(int)(n); --i)
#define INF             1000000000

typedef long long ll;
typedef pair<int, int> ii;
typedef vector<ii> vii;
typedef vector<int> vi;

void init() {
	std::ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
}

const int N = 1e5+5;

int main() {
	init();
	int n, m, max_l = 1, min_r = N;
	cin >> n >> m;
	for(int i = 0; i < m; ++i){
		int l, r;
		cin >> l >> r;
		max_l = max(max_l, l);
		min_r = min(min_r, r);
	}
	cout << max(0, min_r - max_l + 1);
	return 0;
}


Measured memory_bytes: 256
# -*- coding: utf-8 -*-
from decimal import Decimal
# input
n = int(input())
a = list(map(int, input().split()))
out = 1
if 0 in a:
    print(0)
    quit()
for i in range(n):
    out = Decimal(out * a[i])
    if out > Decimal(10**18):
        print(-1)
        quit()
print(out)

Measured memory_bytes: 22572
import java.util.*;

class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int K = sc.nextInt();
        int X = sc.nextInt();
        int Y = sc.nextInt();
        if (N > K) {
            System.out.println(K * X + (N - K) * Y);
        } else {
            System.out.println(N * X);
        }
    }
}

Measured memory_bytes: 21844
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using static System.Console;
using static System.Math;

namespace AtCoder
{
    class Program
    {
        static void Main(string[] args)
        {
            var c = Read();
            var cc = Read();
            if (c[0] == cc[2] && c[1] == cc[1] && c[2] == cc[0])
            {
                WriteLine("YES");
            }
            else
            {
                WriteLine("NO");
            }
        }
        private static string Read() { return ReadLine(); }
        private static string[] Reads() { return (Read().Split()); }
        private static int ReadInt() { return int.Parse(Read()); }
        private static long ReadLong() { return long.Parse(Read()); }
        private static double ReadDouble() { return double.Parse(Read()); }
        private static int[] ReadInts() { return Array.ConvertAll(Read().Split(), int.Parse); }
        private static long[] ReadLongs() { return Array.ConvertAll(Read().Split(), long.Parse); }
        private static double[] ReadDoubles() { return Array.ConvertAll(Read().Split(), double.Parse); }
    }
}


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

int main() {
    int x;
    int HP = 0;
    bool FUCK = false;
    
    cin >> x;

    if(x < 5){
        cout << 0 << endl;
        FUCK = true;
    }
    
    while(x >= 500){
        HP += 1000;
        x -= 500;
    }
    
    while(x >= 5){
        HP += 5;
        x -= 5;
    }
        
    if(FUCK == false){
        cout << HP << endl;
    }
    
}

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

int main()
{
	ll n, r;
	cin>>n>>r;
	if(n>=10)
		cout<<r<<endl;
	else
	{
		ll rat = r + 100*(10-n);
		cout<<rat<<endl;
	}
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <cstdio>
using namespace std;
 
int main(){
    string a,b;
    cin >> a >> b;
    int SizeA = a.size();
    int SizeB = b.size();
    if(SizeA < SizeB) return 0;
    for (int i = 0; i < SizeA-SizeB +1 ; ++i) {
        if(a[i]== b[0]){
            if(a.substr(i,SizeB) == b) printf("%d\n",i);
        }
    }
    return 0;
}

Measured memory_bytes: 2048
#include <bits/stdc++.h>
#include<cmath>
using namespace std;
typedef long long int l1;
typedef vector <int> vi;
typedef vector <long long int> v1;
#define pb push_back
#define iter(i,a,b) for(i=a;i<b;i++)

int main()
{
    ios_base::sync_with_stdio(false);      //for fast cin and cout streams
    cin.tie(NULL);
    cout.tie(NULL);
    int test=1;
    while(test--)
{
int n,k,i;
      cin>>n>>k;
      int a[n];
      iter(i,0,n)
        cin>>a[i];
      sort(a,a+n);
      int c=0;
      iter(i,0,k)
        c+=a[i];
      cout<<c;


    
   

}

return 0;
}






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

using namespace std;
using ll = long long;

#pragma region Macros
#define FOR(i, m, n) for (ll i = (ll)(m); i < (ll)(n); i++)
#define rep(i, n) FOR(i, 0, n)

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

template <class T> string join(const T &v, const string delim = ",")
{
    if (v.empty())
        return "";

    ostringstream res;
    res << v[0];
    for (int i = 1; i < v.size(); i++)
    {
        res << delim << v[i];
    }
    return res.str();
}

#ifdef LOCAL
#define dbg(x) cerr << __LINE__ << ":" << #x << " = " << (x) << endl;
#else
#define dbg
#endif

#pragma endregion Macros

int main()
{
    ll N;
    cin >> N;
    vector<ll> A(N);
    rep(i, N) {
        double x;
        cin >> x;
        A[i] = llround(x * 1000000000);
    }

    vector<ll> p2(N,0), p5(N,0);

    rep(i,N){
        ll a = A[i];
        while (a % 2 == 0) {
            p2[i]++;
            a /= 2; 
        }
        while (a % 5 == 0) {
            p5[i]++;
            a /= 5;
        }
    }

    vector<vector<ll>> d(100, vector<ll>(100, 0));
    rep(i,N){
        d[p2[i]][p5[i]]++;
    }

    for (int i = 99; i >= 0;i--){
        for (int j = 99; j > 0;j--){
            d[i][j-1] += d[i][j];
        }
    }

    for (int j = 99; j >= 0;j--){
        for (int i = 99; i > 0;i--){
            d[i-1][j] += d[i][j];
        }
    }

    ll ans = 0;

    rep(i,N){
        ll n2 = max(18 - p2[i], 0LL);
        ll n5 = max(18 - p5[i], 0LL);

        ll z = d[max(18 - p2[i], 0LL)][max(18 - p5[i], 0LL)];
        if (n2 <= p2[i] && n5 <= p5[i]) z--;

        ans += z;
    }

    ans/=2; 

    cout << ans << endl;
}


Measured memory_bytes: 7944
// Aizu Vol-1 0100: Sale Result
// 2017.8.2

#include <stdio.h>
#include <stdlib.h>
#include <ctype.h>

#define MAX  4000
long long et[MAX + 5];
int id[MAX + 5], end;
char buf[100], *p;

int getInt(void)
{
	int n = 0;
	while (isspace(*p)) p++;
	while (isdigit(*p)) n = 10 * n + (*p++ - '0');
	return n;
}

int main()
{
	int i, n, e;
	long long v;

	while (1) {
		gets(p = buf), n = getInt();
		if (!n) break;

		for (i = 0; i <= MAX; i++) et[i] = -1;
		for (i = end = 0; i < n; i++) {
			gets(p = buf), e = getInt(), v = getInt(), v *= getInt();
			if (et[e] < 0) id[end++] = e, et[e] = v;
			else et[e] += v;
		}
		for (e = i = 0; e < end; e++) {
			if (et[id[e]] >= 1000000) {
				i = 1;
				printf("%d\n", id[e]);
			}
		}
		if (!i) puts("NA");
	}
	return 0;
}

Measured memory_bytes: 556
N, K = list(map(int, input().split()))

point = 1/float(N)
coin = 0.5
win = 0
for i in range(N):
  if(K == 1):
    win = 1.0
    break
  if(i+1 >= K):
    win += point
  else:
    tmp = coin
    j = 1
    while ((i + 1) * pow(2,j) < K):
      tmp = tmp * coin
      j += 1
    win += point * tmp
print(win)

Measured memory_bytes: 3064
#ifdef _MSC_VER
#define _CRT_SECURE_NO_WARNINGS
#endif

#include <bits/stdc++.h>

using namespace std;

int main()
{
#ifdef _MSC_VER
	freopen("c.in", "r", stdin);
#endif
	std::ios::sync_with_stdio(false);
	int n;
	long long last = 0;
	long long ret = 0;
	cin >> n;
	for (int i = 0; i < n; i++) {
		int a;
		cin >> a;
		if (a < last) {
			ret += (last - a);
		}
		else {
			last = a;
		}
	}
	cout << ret << endl;
	return 0;
}


Measured memory_bytes: 3652
#include<stdio.h>
int main()
{
    int w[1000],h[1000],i;
    for(i=0;;i++)
    {
        scanf("%d%d",&h[i],&w[i]);
        if(w[i]==0 && h[i]==0)
            break;
    }
    for(i=0;;i++)
    {
        int a,b;
        for(a=1;a<=h[i];a++)
        {
            if(a%2!=0)
            {
                for(b=1;b<=w[i];b++)
            {
                if(b%2!=0)
                    printf("#");
                else
                    printf(".");
            }
            printf("\n");
            }
            else
            {
                for(b=1;b<=w[i];b++)
                {
                    if(b%2!=0)
                        printf(".");
                    else
                        printf("#");
                }
                printf("\n");
            }
        }
        if(h[i]==0 && w[i]==0)
            break;
            printf("\n");
    }
    return 0;
}



Measured memory_bytes: 2064
N = int(input())
SP = []
for idx in range(N):
	tmp = input().split()
	tmp[1] = int(tmp[1])
	tmp.append(idx+1)
	SP.append(tmp)

sorted_items = sorted(
  SP,
  key = lambda sp: (sp[0], -1 * sp[1])
)
for item in sorted_items:
	print(item[2])

Measured memory_bytes: 38256
#include <bits/stdc++.h>
using namespace std;using ll=long long;using uint=unsigned int;using pii=pair<int,int>;using pll=pair<ll,ll>;using ull = unsigned long long;using ld=long double;template<typename T>void _(const char*s,T h){cerr<<s<<" = "<<h<<"\n";}template<typename T,typename...Ts>void _(const char*s,T h,Ts...t){int b=0;while(((b+=*s=='(')-=*s==')')!=0||*s!=',')cerr<<*s++;cerr<<" = "<<h<<",";_(s+1,t...);}// break continue pop_back 998244353
#define int ll
#define pii pll
#define f first
#define s second
#define pb emplace_back
#define forn(i,n) for(int i=0;i<(n);++i)
#define sz(a)((int)(a).size())
#define sqr(x) ((x)*(x))
struct init{init(){cin.tie(0);iostream::sync_with_stdio(0);cout<<fixed<<setprecision(10);cerr<<fixed<<setprecision(5);}~init(){
#ifdef LOCAL
#define dbg(...) _(#__VA_ARGS__,__VA_ARGS__)
cerr<<"Time elapsed: "<<(double)clock()/CLOCKS_PER_SEC<<"s.\n";
#else
#define dbg(...) 
#endif
}}init;template<typename T,typename U>void upx(T&x,U y){if(x<y)x=y;}template<typename T,typename U>void upn(T&x,U y){if(x>y)x=y;}mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());const int D=4,dx[]={+1,0,-1,0},dy[]={0,+1,0,-1};
const int N=1e5;
int a[N+N+1];
int b[N+N+1];
int32_t main(){
    int n;
    cin>>n;
    forn(i,n){
        int l,r;
        cin>>l>>r;
        a[l+N]++;
        b[r+N]++;
    }
    int ans=0,l=0,r=n;
    forn(i,N+N+1){
        r-=a[i];
        l+=b[i];
        // if(abs(i-N)<=7)dbg(i-N,l,r);
        if(i-N<0){
            if(l&&r){
                if(l<=r)ans+=l*2;
                else ans+=(r+1)*2;
            }else if(l)ans+=2;
        }else{
            if(l&&r){
                if(l>=r)ans+=r*2;
                else ans+=(l+1)*2;
            }else if(r)ans+=2;
        }
    }
    cout<<ans<<'\n';
    return 0;
}

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

using namespace std;

const int N = 1e5 + 5;
const int INF = 1e9+5;

int dp[N];
bool vis[N];
vector<int> adj[N];
int mx=0;

int calc(int x) {
	
	if (x <1 ) return -1 *INF;
	if (vis[x]) return dp[x];
	
	vis[x] = 1;
	
	int mx_dist = 0;
	if (adj[x].size() ) 
		for (auto i : adj[x]) {
			mx_dist = max(mx_dist, calc(i) + 1);
		}
	
	return dp[x] = max(dp[x],mx_dist);
}
		
int main () {
	
	ios::sync_with_stdio(false);
	cin.tie(0);
	
	int n,m;
	cin>>n>>m;
	
	for (int i=0;i<m;i++) {
		int x,y;
		cin>>x>>y;
		
		adj[x].push_back(y);
	}
	
	for (int i=1;i<=n;i++) {
		if (!vis[i]) calc(i);
		
		mx=max(mx,dp[i]);
	}
	
	cout<<mx<<'\n';
}


Measured memory_bytes: 11524
# import sys
# input = sys.stdin.readline
import collections
import itertools


def main():
    n = int(input())
    x = input_list()
    sx = list(sorted(x))
    h = n//2
    a1 = sx[h-1]
    a2 = sx[h]
    for v in x:
        if v <= a1:
            print(a2)
        else:
            print(a1)


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


def input_list_str():
    return list(map(str, input().split()))


if __name__ == "__main__":
    main()


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

// https://atcoder.jp/contests/abc106/tasks/abc106_b

int f(int n) {
  int cnt = 0;
  rep(i, n) {
    int num = i+1;
    if(n % num == 0) cnt++;
  }
  return cnt;
}

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

  int cnt = 0;
  rep(i, n) {
    int num = i+1;
    if(num % 2 == 0) continue;
    if(f(num) != 8) continue;
    cnt++;
  }

  cout << cnt << endl;
  return 0;
}


Measured memory_bytes: 256
n, k = gets.split.map(&:to_i)
aa = gets.split.map(&:to_i)
sorted = aa.sort

cnt = 0
MOD = 10**9+7

temp = (1+(k-1))*(k-1)/2

# n個間の中でカウント。その後nk間のカウントを足す
0.upto(n-1) do |i|
  (i+1).upto(n-1) do |j|
    cnt+=k if aa[i]>aa[j]
    #puts cnt
  end

  cnt += temp * sorted.index(aa[i])
  #puts cnt
end
puts cnt % MOD

Measured memory_bytes: 1912
import java.io.*;
import java.util.HashMap;
import java.util.HashSet;
import java.util.StringTokenizer;

//solution classes here

public class Main {

    //main solution here

    static Scanner sc = new Scanner(System.in);
    static PrintWriter out = new PrintWriter(System.out);
    static long mod = (long)1e9+7;
    static long MOD = 998244353;
    //static ArrayList<Integer> list[] = new ArrayList[(int)1e6+1];
    //static int color[] = new int[(int)1e6+1];
    //static int visit[] = new int[(int)1e5+1];
    //static Deque<Integer> q = new ArrayDeque<>();

    public static void main(String[] args) throws IOException {
        int n = sc.nextInt();
        String s = sc.next();
        char ch[] = s.toCharArray();
        long ans=0;
        for(int i=0;i<n;i++) {
            HashSet<Integer> set1 = new HashSet<>();
            HashSet<Integer> set2 = new HashSet<>();
            HashMap<Character, Integer> map = new HashMap<>();
            for(int j=i+1;j<n;j++) {
                if(ch[j]!=ch[i]) {
                    set1.add(j);
                }
            }
            for(int j=i-1;j>=0;j--) {
                if(ch[j]!=ch[i]) {
                    set2.add(j);
                    map.put(ch[j],map.getOrDefault(ch[j],0)+1);
                }
            }

            for(int it:set1) {
                ans+=set2.size();
                if(map.containsKey(ch[it])) {
                    ans-=map.get(ch[it]);
                }
                if(set2.contains(2*i-it)) {
                    if(ch[it]!=ch[2*i-it]) {
                        ans--;
                    }
                }
            }
        }

        out.println(ans);

        out.flush();
        out.close();
    }
    //solution functions here

    static class Scanner {
        StringTokenizer st;
        BufferedReader br;

        public Scanner(InputStream s) {
            br = new BufferedReader(new InputStreamReader(s));
        }

        public Scanner(FileReader fileReader) {
            br = new BufferedReader(fileReader);
        }

        public String next() throws IOException {
            while (st == null || !st.hasMoreTokens())
                st = new StringTokenizer(br.readLine());
            return st.nextToken();
        }

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

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

        public String nextLine() throws IOException {
            return br.readLine();
        }

        public boolean ready() throws IOException {
            return br.ready();
        }
    }
}

/* *****************************************************************************************************************************
 * I'M NOT IN DANGER, I'M THE DANGER!!!
 * *****************************************************************************************************************************
 */

Measured memory_bytes: 59928
#![allow(
    non_snake_case,
    unused_variables,
    unused_assignments,
    unused_mut,
    dead_code
)]
//use permutohedron::LexicalPermutation as _;
use proconio::input;
use proconio::marker::Chars;
//use proconio::marker::Usize1;
//use std::collections::HashSet;
//use std::collections::HashMap;
//use std::collections::BTreeMap;
//use std::collections::VecDeque;
//use std::cmp::*;
//use std::num;

fn main() {
    input! {
        n:usize, k:usize,c:usize,s:Chars
    }
    let mut L: Vec<usize> = vec![0; k];
    let mut R: Vec<usize> = vec![0; k];
    let mut i = 0;
    for j in 0..k {
        loop {
            if s[i] != 'x' {
                L[j] = i;
                break;
            } else {
                i += 1;
                if i >= n {
                    // 働けるパターンが存在しないので、出力無し
                    return;
                }
            }
        }
        i += c + 1;
    }
    let mut i = n - 1;
    for j in (0..k).rev() {
        loop {
            if s[i] != 'x' {
                R[j] = i;
                break;
            } else {
                i -= 1;
            }
        }
        if j > 0 {
            i -= c + 1
        };
    }
    // println!("L:{:?}", L);
    //  println!("R:{:?}", R);
    for j in 0..k {
        if L[j] == R[j] {
            println!("{}", L[j] + 1);
        }
    }
}


Measured memory_bytes: 6164
#include "iostream"
#include "climits"
#include "list"
#include "queue"
#include "stack"
#include "set"
#include "functional"
#include "algorithm"
#include "string"
#include "map"
#include "unordered_map"
#include "unordered_set"
#include "iomanip"
#include "cmath"
#include "random"
#include "bitset"
#include "cstdio"
#include "numeric"
#include "cassert"
#include "ctime"
 
using namespace std;
 
constexpr long long int MOD = 1000000007;
//constexpr int MOD = 1000000007;
//constexpr int MOD = 998244353;
//constexpr long long int MOD = 998244353;
constexpr double EPS = 1e-12;
 
//int N, M, K, T, H, W, L, R;
long long int N, M, K, T, H, W, L, R;
 
 
int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
 
	cin >> H >> W;
	int sy, sx, gy, gx;
	cin >> sy >> sx >> gy >> gx;
	sy--, sx--, gy--, gx--;
	vector<string>s(H);
	for (auto &i : s)cin >> i;
	vector<vector<int>>dis(H, vector<int>(W,MOD));
	deque<pair<int, int>>Q;
	Q.push_back({ sy,sx });
	dis[sy][sx] = 0;
	int dir[] = { 1,0,-1,0,1 };
	while (!Q.empty()) {
		int cy, cx;
		tie(cy, cx) = Q.front();
		Q.pop_front();
		for (int i = 0; i < 4; i++) {
			int ny = cy + dir[i];
			int nx = cx + dir[i + 1];
			if (ny < 0 || nx < 0 || ny >= H || nx >= W)continue;
			if (s[ny][nx] == '#')continue;
			if (dis[ny][nx] > dis[cy][cx]) {
				dis[ny][nx] = dis[cy][cx];
				Q.push_front({ ny,nx });
			}
		}
		for (int i = -2; i <= 2; i++) {
			for (int j = -2; j <= 2; j++) {
				int ny = cy + i;
				int nx = cx + j;
				if (ny < 0 || nx < 0 || ny >= H || nx >= W)continue;
				if (s[ny][nx] == '#')continue;
				if (dis[ny][nx] > dis[cy][cx] + 1) {
					dis[ny][nx] = dis[cy][cx] + 1;
					Q.push_back({ ny,nx });
				}
			}
		}
	}
	if (dis[gy][gx] == MOD)dis[gy][gx] = -1;
	cout << dis[gy][gx] << endl;
}

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

using namespace std;

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

    vector<int> as(N);

    for (int i = 0; i < N; i++)
        cin >> as[i];

    int ans = 0;
    for (int i = 1; i < N - 1; i++)
    {   
        if ((as[i - 1] < as[i] and as[i + 1] > as[i]) or (as[i - 1] > as[i] and as[i + 1] < as[i]))
            ++ans;

    }

    cout << ans << '\n';
    return 0;
}

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

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

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

int main() {
    int N;
    cin >> N;
    vl T(N);
    rep (i, N) {
        cin >> T[i];
    }

    if (N == 1) {
        cout << T[0] << endl;
        return 0;
    }

    ll res = lcm(T[0], T[1]);
    for (int i = 2; i < N; i++) {
        res = lcm(res, T[i]);
    }

    cout << res << endl;
}

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

#define REP(i, e) for(int (i) = 0; (i) < (e); ++(i))
#define FOR(i, b, e) for(int (i) = (b); (i) < (e); ++(i))
#define ALL(c) (c).begin(), (c).end()
#define ACC(c) (accumulate(ALL(c), 0LL))
#define PRINT(x) cout << (x) << "\n"

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

inline int in(int& a) {return scanf("%d", &a);}
auto pint_compare = [](pint x, pint y) -> bool{return (x.first < y.first);};


signed main(){
    ll N;
    cin >> N;
    PRINT((N - 1) * N / 2);
    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
int f(int a,int r){
  if(r)return f(r,a%r);
  return a;
}
int main(){
  int a,b,t;
  while(scanf("%d %d",&a,&b)!=EOF){
    if(a<b){
      t=a;
      a=b;
      b=t;
    }
    printf("%d\n",f(a,b));
  }
  return 0;
}

Measured memory_bytes: 596
from sys import stdin
def main():
    N = int(stdin.readline())
    ans = c = 0
    for _ in range(N):
        a = int(stdin.readline())
        if a:
            c += a
        else:
            ans += c >> 1
            c = 0
    print(ans + (c >> 1))
if __name__ == "__main__":
    main()

Measured memory_bytes: 40428
import sys

N, M = map(int, input().split())
A = [list(input()) for _ in range(N)]
B = [list(input()) for _ in range(M)]

def solve(i, j):
    for a in range(M):
        for b in range(M):
            if A[i+a][j+b] != B[a][b]:
                return False
            else:
                continue
    return True

for i in range(N - M + 1):
    for j in range(N - M + 1):
        if solve(i, j):
            print("Yes")
            sys.exit()
print("No")

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

int main(void) {
    int q, h, s, d, n;
    cin >> q >> h >> s >> d >> n;
    h = min(h, q * 2);
    s = min(s, h * 2);
    if (d > s * 2) cout << (long long)(n) * s << endl;
    else cout << (long long)(n) / 2 * d + n % 2 * s << endl;
}


Measured memory_bytes: 764
n = int(input())
a = list(map(int, input().split()))
a = sorted(a, reverse=True)
s = 1
count = 0
after = False

for i in range(len(a)-1):
	if after:
		after = False
		pass
	else:
		if count == 2:
			break
		else:
			if a[i] == a[i+1]:
				s = s * a[i]
				count += 1
				after = True

if count == 2:
	print(s)
else:
	print(0)

Measured memory_bytes: 14244
import java.util.*;

public class Main {
  public static void main(String[] args) {
    long mod=1000000000+7;
    Scanner sc=new Scanner(System.in);
    int N=sc.nextInt();
    String S1=sc.next();
    String S2=sc.next();
    long ans=1;
    
    for(int i=0;i<N;i++){
      if(S1.charAt(i)==S2.charAt(i)){
        if(i==0){
          ans*=3;
        }else if(S1.charAt(i-1)==S2.charAt(i-1)){
          ans*=2;
        }
        ans%=mod;
      }
      if(i<N-1 && S1.charAt(i)==S1.charAt(i+1)){
        if(i==0){
          ans*=6;
        }else{
          if(S1.charAt(i-1)!=S2.charAt(i-1)){
            ans*=3;
          }else{
            ans*=2;
          }
        }
        ans%=mod;
      }
    }
    System.out.println(ans);
  }
}

        
        

Measured memory_bytes: 23252
import Data.List

fOdd :: Int->Int->Int
fOdd m x=if x<=m then m-x else x-m-1
 
fEve :: Int -> Int -> Int
fEve m x=if x<=m then m-x else x-m
 
f ::(Int->Int->Int)-> Int->(Int,Int)-> [Int]->Int
f _ _ (_,ans) []=ans
f f2 m (d,ans) (x:xs)=
    let d1=f2 m x
    in if d1<=d then f f2 m (d1,x) xs else f f2 m (d,ans) xs
 
 
main =do
      e<-getLine
      es<-getLine
      let n=read e::Int
          xs=map read (words es)::[Int]
          m1=maximum xs
          m2=m1 `div` 2
          xs2=delete m1 xs
      putStr $ (show m1) ++ " "
      putStrLn $ show $ if n `mod` 2==0 then f fEve m2 (m1,m1) xs2 else f fOdd m2 (m1,m1) xs2

Measured memory_bytes: 36604
#include <iostream>
#include <vector>
#include <stack>
#include <algorithm>
#include <numeric>
#include <unordered_map>
#include <cmath>
#include <iomanip>
#include <map>
#include <unordered_set>

#define rep(i,n) for (int i = 0; i < (n); ++i)

using namespace std;
using ll = long long;
using P = pair<int,int>;
ll gcd(ll a, ll b) { return b?gcd(b,a%b):a;}
ll lcm(ll a, ll b) { return a/gcd(a,b)*b;}

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;
}
template <typename T>
T GCD(T x, T y)
{
    return (y ? GCD<T>(y, x % y) : x);
}


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

    string S;
    vector<int> l(Q);
    vector<int> r(Q);

    cin>>S;
    rep(i,Q){
        cin>>l[i]>>r[i];
    }

    vector<int> sum(N,0);
    char last=S[0];

    rep(i,N){
        if(i==0)
            continue;
        if(last=='A' and S[i]=='C')
            sum[i]=sum[i-1]+1;
        else
            sum[i]=sum[i-1];
        last=S[i];
    }

    rep(i,Q){
        cout<<sum[r[i]-1]-sum[l[i]-1]<<endl;
    }

}



Measured memory_bytes: 2176
#include <iostream>
#include <sstream>
#include <algorithm>
#include <functional>
#include <iterator>
#include <bitset>
#include <string>
#include <list>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>

#define __DEBUG__ 1

typedef   signed long long int slli;
typedef unsigned long long int ulli;
const slli MAX_SLLI = 0x7FFFFFFFFFFFFFFF;
const slli MIN_SLLI = 0x8000000000000000;
const ulli MAX_ULLI = 0xFFFFFFFFFFFFFFFF;
const ulli MIN_ULLI = 0x0000000000000000;

#define N_TIMES(i, n)     for (ulli i = 0;     i <  n; ++i)
#define N_TIMES_REV(i, n) for (slli i = n - 1; i >= 0; --i)

#ifdef __DEBUG__
template<typename T>
std::ostream& operator<<(std::ostream &os, const std::list<T> &list)
{
  const std::string delim = ", ";
  typename std::list<T>::const_iterator itr = list.begin();
  while (itr != list.end()) {
    os << *itr;
    ++itr;
    if(itr != list.end()) os << delim;
  }
  return os;
}

template<typename T>
std::ostream& operator<<(std::ostream &os, const std::vector<T> &v)
{
  const std::string delim = ", ";
  for (unsigned n = 0; n < v.size(); ++n) {
    os << v[n];
    if((n + 1) < v.size()) os << delim;
  }
  return os;
}
#endif

bool match(
  const std::vector<std::string> &A,
  const std::vector<std::string> &B,
  unsigned p, unsigned q
)
{
  unsigned M = B.size();

  for (unsigned x = 0; x < M; ++x) {
    for (unsigned y = 0; y < M; ++y) {
      if (A[q + y][p + x] != B[y][x]) return false;
    }
  }

  return true;
}

bool match(
  const std::vector<std::string> &A,
  const std::vector<std::string> &B
)
{
  unsigned D = A.size() - B.size();

  for (unsigned x = 0; x <= D; ++x) {
    for (unsigned y = 0; y <= D; ++y) {
      if (match(A, B, x, y)) return true;
    }
  }
  
  return false;
}

int main()
{
  unsigned N, M;
  std::cin >> N >> M;

  std::vector<std::string> A(N), B(M);
  N_TIMES(n, N) std::cin >> A[n];
  N_TIMES(m, M) std::cin >> B[m];

  std::cout << (match(A, B) ? "Yes" : "No") << std::endl;

  return 0;
}

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

int N;
int L[8];
int A, B, C;

int dfs(int k, int a, int b, int c) {
    if (k == N) {
        if (a == 0 || b == 0 || c == 0) return 1e9;
        return abs(a - A) + abs(b - B) + abs(c - C);
    }
    int ans = 1e9;
    ans = min(ans, dfs(k + 1, a + L[k], b, c) + (a > 0 ? 10 : 0));
    ans = min(ans, dfs(k + 1, a, b + L[k], c) + (b > 0 ? 10 : 0));
    ans = min(ans, dfs(k + 1, a, b, c + L[k]) + (c > 0 ? 10 : 0));
    ans = min(ans, dfs(k + 1, a, b, c));
    return ans;
}

int main() {
    cin >> N >> A >> B >> C;
    for (int i = 0; i < 8; i++) {
        cin >> L[i];
    }
    cout << dfs(0, 0, 0, 0) << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <fstream>
#include <stdio.h>
#include <math.h>
#include <time.h>
#include <string>
#include <tuple>
#include <vector>
#include <map>
#include <unordered_map>
#include <list>
#include <set>
#include <stack>
#include <queue>
#include <cstdlib>
#include <algorithm>
#include <random>
#include <cassert>
using namespace std;
#define LL long long
#define MP(a, b) make_pair(a, b)
#define POWER9 1000000000
#define MOD POWER9+7
#undef INT_MIN
#undef INT_MAX
#define INT_MIN -2147483647
#define INT_MAX 2147483647
#define LL_MIN (LL)-9223372036854775807
#define LL_MAX (LL)9223372036854775807
#define PI 3.14159265359
int L;
LL A[200000];
LL dp[200000][5];
LL solve(int now, int state){
	if(now == L) return 0;
	if(dp[now][state] != -1) return dp[now][state];
	LL re = LL_MAX;
	if(state != 4) re = min(re, solve(now, state+1));
	if(state == 0) re = min(re, solve(now+1, state)+A[now]);
	if(state == 1){
		if(A[now] == 0) re = min(re, solve(now+1, state)+2);
		else re = min(re, solve(now+1, state)+(A[now]%2==0?0:1));
	}
	if(state == 2) re = min(re, solve(now+1, state)+(A[now]%2==0?1:0));
	if(state == 3){
		if(A[now] == 0) re = min(re, solve(now+1, state)+2);
		else re = min(re, solve(now+1, state)+(A[now]%2==0?0:1));
	}
	if(state == 4) re = min(re, solve(now+1, state)+A[now]);
	//cout << now << " " << state << " " << re << endl;
	//if(now == 0 && state == 1) cout << solve(now, state+1) << " " << solve(now+1, state)+A[now] << endl;
	return dp[now][state] = re;
}
int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	cout << setprecision(9);

	cin >> L;
	for(int i=0; i<L; i++){
		cin >> A[i];
		for(int j=0; j<5; j++) dp[i][j] = -1;
	}
	cout << solve(0,0) << endl;

	return 0;
}

/*

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



return 0;
}
*/

/*

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



return 0;
}
*/

/*

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



return 0;
}
*/

/*

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



return 0;
}
*/

/*

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



return 0;
}
*/

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

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

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

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

	ll n,k,i,j;

	cin >> n >> k;

	ll a[n],b[n];
	memset(a,0,sizeof(a));

	for(i=0;i<n;i++)
		cin >> b[i];

	a[0] = 0;

	for(i=1;i<n;i++)
	{
		a[i] = abs(b[i] - b[i-1]) + a[i-1];
		for(j=2;j<k+1;j++)
		{
			if(i-j > -1)
			{
				a[i] = min(a[i], abs(b[i] - b[i-j]) + a[i-j]);
			}
			else
				break;
		}
	}

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

}

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

// types
typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef pair<ld,ld> pdd;

// macros
#define ALL(a) a.begin(),a.end()
#define SZ(a) ((int)a.size())
#define FI first
#define SE second
#define REP(i,n) for(int i=0;i<((int)n);i++)
#define REP1(i,n) for(int i=1;i<((int)n);i++)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define PB push_back
#define EB emplace_back
#define MP(a,b) make_pair(a,b)
#define SORT_UNIQUE(c) (sort(c.begin(),c.end()), c.resize(distance(c.begin(),unique(c.begin(),c.end()))))
#define GET_POS(c,x) (lower_bound(c.begin(),c.end(),x)-c.begin())
#define Decimal fixed<<setprecision(20)
#define INF 1000000000
#define LLINF 1000000000000000000LL

// constants
const int inf = 1e9;
const ll linf = 1LL << 50;
const double eps = 1e-10;
const int mod = 1e9 + 7;
const int dx[4] = {-1, 0, 1, 0};
const int dy[4] = {0, -1, 0, 1};

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

  ll n;
  cin >> n;

  vector<ll> a(n);
  ll sum = 0;
  REP(i, n){
    cin >> a[i];
    sum += a[i];
  }

  REP(i, n/2){
    //cout << sum << endl;
    sum -= 2*a[2*i];
  }

  vector<ll> rain(n, 0);
  rain[n-1] = sum;
  
  //cout << sum << endl;
  REP1(i, n){
    rain[n-1-i] = 2*a[n-1-i] - rain[n-i];
  }

  REP(i, n)
    cout << rain[i] << " ";
  cout << endl;

}


Measured memory_bytes: 2944
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
#define ld long double
#define ff first
#define ss second
#define pb emplace_back
#define mp make_pair
#define MOD 1000000007
#define FAST ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0);srand(time(NULL))
int main()
{
    ll n,m;
    cin>>n>>m;
    if(n>9 || m>9)   cout<<"-1";
    else          cout<<n*m;
}

Measured memory_bytes: 256
#include<iostream>
#include<map>
using namespace std;
#define inf 1e18
long long int n,ww;
long long v[105],w[105];
long long dp[105][100005];
int main(){
	cin>>n;
	cin>>ww;
	int sum[n];
	for(int i=0;i<n;i++){
		cin>>w[i]>>v[i];
		if(i>0)sum[i]=sum[i-1]+v[i];
		else sum[i]=v[i];
	}
	for(int i=0;i<n;i++)for(int j=0;j<=sum[n-1];j++){
		if(j==0)dp[i][j]=0;
		else dp[i][j]=inf;
	}
	dp[0][v[0]]=w[0];
	for(int i=1;i<n;i++){
		for(int j=0;j<=sum[i];j++)dp[i][j]=dp[i-1][j];
		for(int j=0;j<=sum[i];j++){
			if(j==0)dp[i][v[i]]=min(dp[i][v[i]],w[i]);
			else dp[i][j+v[i]]=min(dp[i-1][j+v[i]],w[i]+dp[i-1][j]);
		}
	}
	for(int i=sum[n-1];i>=0;i--){
		if(dp[n-1][i]<=ww){
			cout<<i;
			return 0;
		}
	}
}

Measured memory_bytes: 80128
#include <bits/stdc++.h>
using namespace std;
int main(){
  long long N,a;
  int b;
  cin>>N;
  vector<char> ans(0);
  while(N>=1){
    a=N/26,b=N%26;
    if(b==0){b=26;}
    b+=96;
    char c=b;
    ans.push_back(c);
    N/=26;
    if(b==122){N--;}
  }
  for(int i=0;i<(int)ans.size();i++){
    cout<<ans.at((int)ans.size()-1-i);
  }
}

Measured memory_bytes: 3556
#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define intput(i) cout << i << endl
#define ll long long
#define stringput(s) cout << (string)(s) << endl

int main(){
  int N;
  cin >> N;
  vector <int> d(N);
  ll k = 0;
  int j = 0;
  rep(i,N) cin >> d[i];
  rep(i,N-1){
      j = 1;
    while(i+j<N){
      k += d[i]*d[i+j];
      j++;
    }
  }
  cout << k << endl;
}



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

int main(void){
    stack<int> S1;
    stack<pair<int ,int> > S2;
    char ch;
    int sum=0;
    for(int i=0;cin >> ch;i++){
        if(ch=='\\') S1.push(i);
        else if(ch=='/'&&S1.size()>0){
            int j=S1.top(); S1.pop();
            sum+=i-j;
            int a=i-j;
            while(S2.size()>0&&S2.top().first>j){
                a+=S2.top().second; S2.pop();
            }
            S2.push(make_pair(j,a));
        }
    }
    vector<int> ans;
    while(S2.size()>0){
        ans.push_back(S2.top().second); S2.pop();
    }
    reverse(ans.begin(),ans.end());
    cout << sum << endl;
    cout << ans.size();
    for(int i=0;i<ans.size();i++){
        cout << " ";
        cout << ans[i];
    }
    cout << endl;
}


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

using namespace std;
#define rep(i, s, n) for (int i = s; i < (int)(n); i++)

int main()
{
    int input;
    cin >> input;
    vector<int> operand(4);

    int i = 0;
    while (input > 0) {
        operand.at(i) = input % 10;
        input /= 10;
        i++;
    }

    vector<char> ans(3);

    for (int tmp = 0; tmp < (1 << 3); tmp++) {
        int sum = operand.at(3);
        bitset<3> s(tmp);
        if (s.test(2)) {
            sum += operand.at(2);
            ans.at(2) = '+';
        } else {
            sum -= operand.at(2);
            ans.at(2) = '-';
        }
        if (s.test(1)) {
            sum += operand.at(1);
            ans.at(1) = '+';
        } else {
            sum -= operand.at(1);
            ans.at(1) = '-';
        }
        if (s.test(0)) {
            sum += operand.at(0);
            ans.at(0) = '+';
        } else {
            sum -= operand.at(0);
            ans.at(0) = '-';
        }
        if (sum == 7) {
            break;
        }
    }
    cout << operand.at(3) << ans.at(2) << operand.at(2) << ans.at(1) << operand.at(1) << ans.at(0) << operand.at(0) << "=7";
}


Measured memory_bytes: 256
N = int(input())
S = input()
t_min = min(S.count("#"), S.count("."))
S_first = 0
S_second = S.count(".")
for i in range(0,N):
    if S[i] == "#":
        S_first += 1
    else:
        S_second -= 1
    t = S_first + S_second
    t_min = min(t_min, t)
print(t_min)

Measured memory_bytes: 40672
#include <iostream>
#include <list>
#include <string>
#include <stdio.h>
using namespace std;

int main() {
	// your code goes here
	ios::sync_with_stdio(false);
    cin.tie(0);
	int n;
	cin>>n;
	
	
	string command;
	int x;
	list<int> list;
	while(n--){
		cin>>command;
		if(command=="insert"){
				cin>>x;
				list.push_front(x);
		}else if(command=="delete"){
				cin>>x;
				std::list<int>::iterator itr;
				for(itr=list.begin();itr!=list.end();itr++){
					if(*itr==x){
						list.erase(itr);
						break;
					}
				}
		}else if(command=="deleteFirst"){
				list.pop_front();
		}else if(command=="deleteLast"){
				list.pop_back();
		}
		
	}
	int size = list.size();
	for(int i=0;i<size;i++){
		if(i>0)cout<<" ";
		cout<<list.front();
		list.pop_front();
	}
	cout<<endl;
	return 0;
}

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



int main() {
    int N, K;
    cin >> N >> K;
    vector<int> a(N);
    rep(i,N) cin >> a.at(i);
    long ans = INFINITY;
    for (int bit = 0; bit < (1<<N-1); ++bit) {
        if (__builtin_popcount(bit) == K-1) {
            bool ok = true;
            long sum = 0;
            int left = a.at(0);
            for (int i = 0; i < N-1; ++i) {
                if (bit & (1<<i)) {
                    long add = max(left+1, a.at(i+1)) - left;
                    sum += left + add - a.at(i+1);
                    left += add;
                } else {
                    if (a.at(i+1) > left) {
                        ok = false;
                        break;
                    }
                }
            }
            if (ok) ans = min(ans, sum);
        }
    }
    cout << ans << endl;
}



Measured memory_bytes: 3636
using System;

public class Test {
  public struct Point {
    public Double x;
    public Double y;
  };
  
  public static int Main(){
    string line = Console.ReadLine();
    string[] n = line.Split();
    Int32 N, D;
    int ans = 0;
    
    N = Int32.Parse(n[0]);
    D = Int32.Parse(n[1]);
    Point[] p = new Point[N];
    for (int i = 0; i < N; i++) {
      line = Console.ReadLine();
      n = line.Split();
      p[i].x = Double.Parse(n[0]);
      p[i].y = Double.Parse(n[1]);
    }
    for (int i = 0; i < N; i++) {
      if (Math.Sqrt(p[i].x * p[i].x + p[i].y * p[i].y) <= D) {
        ans++;
      }
    }
    Console.WriteLine(ans);
    return 0;
  }
}

Measured memory_bytes: 49448
#include<stdio.h>
#include<iostream>
#include<algorithm>
#include<string>
#include<string.h>
#include<math.h>
#include<stdlib.h>
#include<vector>
#include<queue>
#include<map>
#include<iomanip>
#include<set>
#include<bitset>
#define rep(index,num) for(int index=0;index<num;index++)
#define rep1(index,num) for(int index=1;index<=num;index++)
#define brep(index,num) for(int index=num-1;index>=0;index--)
#define brep1(index,num) for(int index=num;index>0;index--)
#define scan(argument) cin>>argument
#define prin(argument) cout<<argument<<endl
#define kaigyo cout<<endl
#define eps 1e-7
#define mp(a1,a2) make_pair(a1,a2)
#define ALL(a) (a).begin(),(a).end()
#define rALL(a) (a).rbegin(),(a).rend()
typedef long long ll;
typedef long double ld;
using namespace std;
typedef pair<ll,ll> pll;
typedef pair<int,int> pint;
typedef vector<int> vint;
typedef vector<ll> vll;
typedef vector<pint> vpint;
typedef vector<pll> vpll;
ll INFl=1e+18+1;
int INF=1e+9+1;
int main(){
	ll I,O,T,J,L,S,Z;
	scan(I>>O>>T>>J>>L>>S>>Z);
	ll ans=O;
	int oddnum=I%2+J%2+L%2;
	if(oddnum>=2&&min({I,J,L})>=1){
		ans+=3;
		I--; J--; L--;
	}
	ans+=I/2*2+J/2*2+L/2*2;
	prin(ans);
	return 0;
}


Measured memory_bytes: 256
<?php

while (true) {
    fscanf(STDIN, '%s', $talon);
    if (isEnd($talon)) { break; }

    fscanf(STDIN, '%d', $shuffleCount);
    for ($i = 0; $i < $shuffleCount; $i++) {
        $talon = shuffleTalon($talon);
    }
    $result[] = $talon;
}

echo implode(PHP_EOL, $result), PHP_EOL;


function shuffleTalon($talon)
{
    fscanf(STDIN, '%d', $pos);
    return substr($talon, $pos) . substr($talon, 0, $pos);
}

function isEnd($talon)
{
    return ($talon == '-');
}

Measured memory_bytes: 6592
#include <bits/stdc++.h>
using namespace std;
int main() {

string A, B, C;
cin>>A >>B >>C;
  
  A[0]= toupper(A[0]);
  B[0]= toupper(B[0]);
  C[0]= toupper(C[0]);
  
  cout<<A[0]<<B[0]<<C[0];
}


Measured memory_bytes: 3616