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

int main(){
  int A,B,C,D,E,F;
    cin >> A >> B >> C >> D;
  E = A+B;
  F = C+D;
    if (E>F)
    {
      cout <<"Left"<< endl;
    }
  else if(E==F)
  {
    cout <<"Balanced"<< endl;
  }
  else if (E<F)
  {
    cout << "Right" <<endl;
  }
}


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

int main(){
  int n;
  cin>> n;
  vector<int> d(n);
  for (int i=0; i<n; i++) cin>> d[i];
  int ans=0;
  for (int i=0; i<n-1; i++){
    for (int j=i+1; j<n; j++){
      ans+=d[i]*d[j];
    }
  }
  cout<< ans <<endl;
}

Measured memory_bytes: 256
n = int(input())
mt = 0
ma = 0
for i in range(n):
    t , a = map(int, input().split())
    if t>=mt and a>=ma:
        mt = t
        ma = a
    elif t<mt or a<ma:
        k1 = mt//t
        k2 = ma//a
        k=max(k1,k2)
        while t*k < mt or a*k <ma:
            k+=1
        mt=t*k
        ma=a*k
print(mt+ma)


Measured memory_bytes: 3060
#include <bits/stdc++.h>
#define watch(x) cout << (#x) << " is " << (x) << endl
#define eps 1e-9

typedef long long ll;

using namespace std;

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

int main()

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

    int a, b;

    cin >> a >> b;

    if (a < 10 && b < 10) cout << a*b;
    else cout << "-1";

    return 0;
}


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

void vprint(vector<int> a){
cout << "\n";
for (int it = 1; it< a.size();it++){
cout << a[it] << " ";
}
}

int main(){
int n, k;
cin >> n >> k;
vector <int> a(n+1);
a[0] = 0;
for (int i = 1; i<= n; i++){
cin >> a[i];
}
vector<int> s(n+1);
s[0] = 0;
s[1] = 0;
s[2] = abs(a[2] - a[1]);
for (int i = 3; i<=n;i++){
s[i] = s[i-1] + abs(a[i-1] - a[i]);
if (i<=k+1){
for (int j = 1; j<i;j++){
s[i] = min(s[i], s[j]+abs(a[j]-a[i]));
}
}else{
for (int j = 2; j<=k;j++){
s[i] = min(s[i], s[i-j] + abs(a[i-j] - a[i]));
}
}
}


//vprint(s);
cout << s[n] << "\n";
return 0;
}


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

using namespace std;

#define pb push_back
#define mp make_pair
#define forn(i, n) for (int i = 0; i < (int)(n); ++i)
typedef long long LL;
typedef pair<int, int> PII;

int n;
int a[13];
vector<int> vec;

int solve() {
    int best = 24;
    forn(i, vec.size()) forn(j, i) {
        int x = vec[i];
        int y = vec[j];
        best = min(best, min(abs(x - y), 24 - abs(x - y)));
    }
    return best;
}

int main() {
    cin >> n;
    forn(i, n) {
        int x;
        cin >> x;
        ++a[x];
    }
    if (a[0] > 0 || a[12] > 1) {
        cout << 0 << endl;
        return 0;
    }
    forn(i, 12) if (a[i] > 2) {
        cout << 0 << endl;
        return 0;
    }
    int ans = 0;
    for (int mask = 0; mask < (1 << 12); mask += 2) {
        vec.clear();
        vec.pb(0);
        if (a[12] == 1) vec.pb(12);
        for (int i = 1; i < 12; ++i) {
            if (a[i] == 1) {
                if (mask & (1 << i)) {
                    vec.pb(i);
                } else {
                    vec.pb(24 - i);
                }
            } else if (a[i] == 2) {
                vec.pb(i);
                vec.pb(24 - i);
            }
        }
        ans = max(ans, solve());
    }
    cout << ans << endl;
    return 0;
}


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

int count(int n) {
  int i, count=0;
  
  for(i=n; i>0; i/=10) {
    count++;
  }
  
  return count;
  
}

int main() {
  int i,N,sum=0;
  
  cin >> N;
  
  for(i=1; i<=N; i++) {
    if(count(i)%2 == 1) sum++;
  }
  
  cout << sum << endl;
  
  return 0;
}

Measured memory_bytes: 3600
import collections
N = int(input())
x = [0 for i in range(N)]
for i in range(N):
    x[i] = list(map(int, input().split()))
x.sort(key=lambda x: (x[0],x[1]))
salist = []
if N >= 2:
    for i in range(1,N):
        for k in range(1,N):
            if i >= k:
                lb, mb = x[i-k]
                l, m = x[i]
                salist.append((l-lb,m-mb))
    #print(salist)
    c = collections.Counter(salist)
    print( N - c.most_common()[0][1])
else:
    print(1)

Measured memory_bytes: 3572
#include"bits/stdc++.h"
using namespace std;
typedef struct range
{
	int left;
	int right;
	int value;
	bool operator < (const struct range & t)const
	{
		return right<t.right;
	}
}RANGE,*PRANGE;
int n,m;
RANGE arr[1<<18];
long long tree[1<<19],lazy[1<<19];
int cnt=0;
long long search(int index,int lb,int rb,int lq,int rq)
{
	if(rb==rq&&lb==lq)
		return tree[index];
	if(lazy[index]!=0)
	{
		tree[index<<1]+=lazy[index];
		lazy[index<<1]+=lazy[index];
		tree[index<<1|1]+=lazy[index];
		lazy[index<<1|1]+=lazy[index];
		lazy[index]=0;
	}
	int mid=(lb+rb)>>1;
	if(rq<=mid)
		return search(index<<1,lb,mid,lq,rq);
	else if(lq>mid)
		return search(index<<1|1,mid+1,rb,lq,rq);
	else
		return max(search(index<<1,lb,mid,lq,mid),search(index<<1|1,mid+1,rb,mid+1,rq));
}
void update(int index,int lb,int rb,int lq,int rq,long long value)
{
	if(lb==lq&&rb==rq)
	{
		tree[index]+=value;
		lazy[index]+=value;
		return ;
	}
	if(lazy[index]!=0)
	{
		tree[index<<1]+=lazy[index];
		lazy[index<<1]+=lazy[index];
		tree[index<<1|1]+=lazy[index];
		lazy[index<<1|1]+=lazy[index];
		lazy[index]=0;
	}
	int mid=(lb+rb)>>1;
	if(rq<=mid)
		update(index<<1,lb,mid,lq,rq,value);
	else if(lq>mid)
		update(index<<1|1,mid+1,rb,lq,rq,value);
	else
	{
		update(index<<1,lb,mid,lq,mid,value);
		update(index<<1|1,mid+1,rb,mid+1,rq,value);
	}
	tree[index]=max(tree[index<<1],tree[index<<1|1]);
}
int main()
{
	scanf("%d%d",&n,&m);
	for(int i=0;i<m;i++)
		scanf("%d%d%d",&arr[i].left,&arr[i].right,&arr[i].value);
	sort(arr,arr+m);
	for(int i=1;i<=n;i++)
	{
		update(1,0,n,i,i,search(1,0,n,0,i-1));
		while(i==arr[cnt].right&&cnt<m)
		{
			update(1,0,n,arr[cnt].left,arr[cnt].right,(long long)arr[cnt].value);
			cnt++;
		}
	}
	printf("%lld",search(1,0,n,0,n));
}

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

using namespace std;

#define PB push_back
#define SZ(a) (int)a.size()
#define MP make_pair

typedef long long ll;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef pair<int,int> PII;

int main() {

	char s[10];

	fgets(s, 10, stdin);

	if (s[2]==s[3] && s[4]==s[5]) printf("Yes\n");
	else printf("No\n");

	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long
using namespace std;
int f[100009],a[100009];
main(){
    int n,q;
    cin >> n;
    ll s = 0;
    for(int i = 1; i <= n; i++){
        cin >> a[i];
        f[a[i]] ++;
        s += a[i];
    }
    cin>>q;
    while(q--){
        int b, c;
        cin>>b>>c;
        s += f[b] * (c - b);
        f[c] += f[b];
        f[b] = 0;
        cout<<s<<endl;
    }
}


Measured memory_bytes: 4416
day_count = int(input())
decline = list(map(int,input().split()))
score_list = []
for i in range(day_count):
    score_list.append(list(map(int,input().split())))

schedule = [0] * 26
total_score = 0

result = [0] * day_count

for i in range(day_count):

    for j in range(len(schedule)):
        schedule[j] += 1
        total_score -= schedule[j] * decline[j] 

    high_score = 0
    best_contest = 0

    for k in range(26):
        
        temp = score_list[i][k] + schedule[k] * decline[k]
        if temp > high_score :
            high_score = temp
            best_contest = k

    total_score += high_score
    
    result[i] = best_contest
    schedule[best_contest] = 0
    
for i in result:
    print(i + 1)

Measured memory_bytes: 9432
li=list(input())
A=int(li[0])
B=int(li[1])
C=int(li[2])
D=int(li[3])
if A+B+C+D==7:
  print(li[0]+'+'+li[1]+'+'+li[2]+'+'+li[3]+'=7')
  
elif A+B+C-D==7:
  print(li[0]+'+'+li[1]+'+'+li[2]+'-'+li[3]+'=7')
  
elif A+B-C+D==7:
  print(li[0]+'+'+li[1]+'-'+li[2]+'+'+li[3]+'=7')

elif A+B-C-D==7:
  print(li[0]+'+'+li[1]+'-'+li[2]+'-'+li[3]+'=7')

elif A-B+C+D==7:
  print(li[0]+'-'+li[1]+'+'+li[2]+'+'+li[3]+'=7')
  
elif A-B+C-D==7:
  print(li[0]+'-'+li[1]+'+'+li[2]+'-'+li[3]+'=7')
  
elif A-B-C+D==7:
  print(li[0]+'-'+li[1]+'-'+li[2]+'+'+li[3]+'=7')

elif A-B-C-D==7:
  print(li[0]+'-'+li[1]+'-'+li[2]+'-'+li[3]+'=7')


Measured memory_bytes: 3192
# -*- coding: utf-8 -*-
import numpy as np
import sys
from collections import deque
from collections import defaultdict
import heapq
import collections
import itertools
import bisect


def zz():
    return list(map(int, sys.stdin.readline().split()))


def z():
    return int(sys.stdin.readline())


def S():
    return sys.stdin.readline()


def C(line):
    return [sys.stdin.readline() for _ in range(line)]


D = z()
C = zz()
S = defaultdict(list)
for i in range(D):
    S[i + 1] = zz()
# やらなくていいコンテストはやらないC=0
never_held = []

arr = list(range(1, 27))
C, arr = zip(*sorted(zip(C, arr), reverse=True))
for i in range(D):
    print(arr[i % 26])


Measured memory_bytes: 27628
#include <iostream>
#include <vector>
#include <cstdio>
#include <algorithm>
#include <cassert>
#include <utility>
#include <string>
#include <cmath>
#include <set>
#include <functional>
#include <map>
#include <queue>
#include <stack>
#include <iomanip>
#include <climits>
#include <unordered_map>
#include <numeric>
#include <cstring>
using namespace std;
#define rep(i,n) for(int i = 0; i < n; ++i)
#define show(x) cout << #x << " = " << x << endl;
typedef long long ll;
typedef pair<int,int> pii;
int main(){
    int n,t;
    cin >> n >> t;
    int ans = 1e9;
    rep(i,n){
        int a,b;
        cin >> a >> b;
        if(b<=t){
            ans = min(a,ans);
        }
    }
    if(ans!=1e9){
        cout << ans << endl;
    }else{
        cout << "TLE" << endl;
    }
}


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

using namespace std;

int n, q;
string s;
vector<char> d, t;

int pos(int now)
{
  for (int i = 0; i < q; i++)
    if (s[now] == d[i])
    {
      if (t[i] == 'L')
        now--;
      else
        now++;
      if (now < 0)
        return -1;
      if (n <= now)
        return 1;
    }
  return 0;
}

int main()
{
  cin >> n >> q >> s;
  d.resize(q);
  t.resize(q);
  for (int i = 0; i < q; i++)
    cin >> d[i] >> t[i];
  int l, r;
  int ok = n, ng = -1;
  while (ok - ng > 1)
  {
    int mid = (ok + ng) / 2;
    if (pos(mid) == -1)
      ng = mid;
    else
      ok = mid;
  }
  l = ok;
  ok = -1, ng = n;
  while (ng - ok > 1)
  {
    int mid = (ok + ng) / 2;
    if (pos(mid) == 1)
      ng = mid;
    else
      ok = mid;
  }
  r = ok;
  cout << r - l + 1 << endl;

  return 0;
}

Measured memory_bytes: 900
import java.util.*;
     
    public class Main{
      public static void main(String []args){
        Scanner in = new Scanner(System.in);
        int n = in.nextInt();
        int m = in.nextInt();
        int sum = 0;
        for(int i = 0 ; i < m; i++)sum += in.nextInt();
        
        System.out.println((sum > n) ? -1 : n - sum);
      }
    }

Measured memory_bytes: 46032
#include <bits/stdc++.h>
#define ss second
#define ff first
#define all(x) x.begin(), x.end()

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

const ll oo = 1e18;
const ll mod = 1e9 + 7,maxn = 1000010;
const double PI = acos(-1);
vector<ll> fat(maxn), inv(maxn);
ll memo[30][30];

ll fexp(ll base, ll p){
    ll ans = 1;

    while (p){
        if(p&1) ans = (ans * base)%mod;
        base = (base * base)% mod;
        p = p >> 1;
    }
    return ans;
}

void init(){
    fat[0] = fat[1] = inv[1] = 1;
    for (ll i=2; i<maxn; i++){
        fat[i] = (fat[i-1] * i)%mod;
        inv[i] = fexp(fat[i], mod-2);
    }
}

ll combina(ll n, ll k){
    if (n == k || k == 0) return 1;
    if (n < k) return 0;

    return (((fat[n] * inv[k])%mod)*inv[n - k])%mod;
}

int main (){
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    ll a, b, n;
    cin >> n >> a >> b;

    if (a == 0){
        cout << "0" << endl;
        return 0;
    }
    else if (b == 0){
        cout << n << endl;
    }
    else {
        cout << ((n/(a+b))*a) + min(a, n%(a+b)) << endl;
    }
    return 0;
}

Measured memory_bytes: 18620
import java.util.*;
public class Main {
public static void main(String[] args) {
	Scanner re=new Scanner(System.in);
		int A1=re.nextInt();
		int B1=re.nextInt();
		System.out.println(Math.max(Math.max((A1+B1), (A1-B1)), (A1*B1)));
}
}

Measured memory_bytes: 21844
#include <iostream>
#include <map>
#include <algorithm>
#include <string>
#include <vector> 
#include <numeric>
#include <cmath>
#include <queue>
#include <iomanip>
#include <functional>


#define CHMAX(a,b) a = std::max(a,b)
#define CHMIN(a,b) a = std::min(a,b)
#define CHABS(a) a = std::abs(a) 
#define COUT(a) std::cout << a << std::endl
#define CERR(a) std::cerr << a << std::endl
#define FOR(n) for(lli i = 0; i < n; i++)

using namespace std;
using lli = long long int;
using pll = pair<lli, lli>;
using tlll = tuple<lli, lli, lli>;
using vll = vector<lli>;

lli mod197 = 1000000007LL;
lli INF = 10000000000000;

// ax + by = gcd(a,b) 最大公約数
template< typename T >
T extgcd(T a, T b, T& x, T& y) {
	T d = a;
	if (b != 0) {
		d = extgcd(b, a % b, y, x);
		y -= (a / b) * x;
	}
	else {
		x = 1;
		y = 0;
	}
	return d;
}

int main(void) {

	lli a;
	string s;
	cin >> a >> s;

	if (a >= 3200)
		cout << s << endl;
	else
		cout << "red" << endl;


	return 0;
}

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

// B - Common Raccoon vs Monster
int main() {
    long long H, N;
    cin >> H >> N;
    long long A;
    for (long long i = 0; i < N; i++) {
        cin >> A;
        H -= A;
        if (H <= 0) {
            break;
        }
    }
    if (H <= 0) cout << "Yes";
    else cout << "No";
}


Measured memory_bytes: 3628
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<char> vchar;
typedef vector<vector<char>> vvchar;
typedef vector<int> vint;
typedef vector<vector<int>> vvint;
typedef vector<long long> vll;
typedef vector<vector<long long>> vvll;
typedef priority_queue<long long> prque;
#define ain(i,n,a) for(long long i=0;i<(long long)(n);i++){cin>>a[i];}
#define aout(i,n,a) for(long long i=0;i<(long long)(n);i++){if(i){cout<<" ";}cout<<a[i];if(i==n-1){cout<<endl;}}
#define rep(i,n) for(long long i=0;i<(long long)(n);i++)
#define vsort(v) sort((v).begin(),(v).end())
#define vrsort(v) sort((v).rbegin(),(v).rend())
#define vreverse(v) reverse((v).begin(),(v).end())
#define pf(a) push_front(a)
#define pb(a) push_back(a)
#define INF 1998021900
#define MOD 1000000007
int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  //input
  string h,j;cin>>h>>j;ll ans=0;
  rep(i,3){if(h[i] ==j[i]){ans++;}}
  cout<<ans<<endl;
  //caricurate
  //output
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define mp make_pair
#define pb push_back
#define IOS ios::sync_with_stdio(false); cin.tie(0);
#define sd(n) scanf("%d",&n)
#define sl(n) scanf("%lld",&n)
#define pd(n) printf("%d",n)
#define pl(n) printf("%lld",n)
#define psp printf(" ")
#define endc printf("\n")

using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;

const int maxn = 2e5 + 7; 
//const int md = 1e9 + 7;

int main() {
	ll q,h,s,d,x; cin>>q>>h>>s>>d>>x;
	q *= 4; h *= 2; ll z = min(q,min(h,s));
	ll ans = 0;
	if (d < z*2) { ans += d*(x/2); x%=2; }
	ans += z*x;
	cout<<ans<<endl;
}


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

int main()
{
    int a, b, c;
    cin>>a>>b>>c;
    rewind(stdin);
    cin>>a>>b>>c; // 念のためもう一度入力する

    cout<<9*max({a, b, c})+a+b+c<<endl;
}


Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Map;
import java.util.Set;


public class Main {
    private static final Map<Integer,Boolean> happy = new HashMap<>();
    public static void main(String args[]) throws Exception {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        String[] tokens = br.readLine().split(" ");
        int a= Integer.parseInt(tokens[0]);
        int b= Integer.parseInt(tokens[1]);
        System.out.println(a*b);
    }


}

Measured memory_bytes: 25380
import java.io.IOException;
import java.io.InputStream;
import java.util.NoSuchElementException;

public class Main {
	public static void main(String[] args) {
		FastScanner sc = new FastScanner();
		char[] S = sc.next().toCharArray();
		String ans = "AC";
		if (S[0] != 'A') ans = "WA";
		int c = 0;
		for (int i = 2; i < S.length - 1; i++) {
			if (S[i] == 'C') {
				c++;
			}
		}
		if (c != 1) ans = "WA";
		for (int i = 1; i < S.length; i++) {
			if (!(S[i] >= 'a' && S[i] <= 'z' || S[i] == 'C')) ans ="WA";
		}
		System.out.println(ans);
	}

	public static long gcd(long a, long b) {
		long remainder = a % b;
		if (remainder == 0) {
			return b;
		} else {
			return gcd(b, remainder);
		}
	}
}

class FastScanner {
    private final InputStream in = System.in;
    private final byte[] buffer = new byte[1024];
    private int ptr = 0;
    private int buflen = 0;
    private boolean hasNextByte() {
        if (ptr < buflen) {
            return true;
        } else {
            ptr = 0;
            try {
                buflen = in.read(buffer);
            } catch (IOException e) {
                e.printStackTrace();
            }
            if (buflen <= 0) {
                return false;
            }
        }
        return true;
    }

    private int readByte() {
        if (hasNextByte())
            return buffer[ptr++];
        else
            return -1;
    }

    private static boolean isPrintableChar(int c) {
        return 33 <= c && c <= 126;
    }

    public boolean hasNext() {
        while (hasNextByte() && !isPrintableChar(buffer[ptr]))
            ptr++;
        return hasNextByte();
    }

    public String next() {
        if (!hasNext())
            throw new NoSuchElementException();
        StringBuilder sb = new StringBuilder();
        int b = readByte();
        while (isPrintableChar(b)) {
            sb.appendCodePoint(b);
            b = readByte();
        }
        return sb.toString();
    }

    public long nextLong() {
        if (!hasNext())
            throw new NoSuchElementException();
        long n = 0;
        boolean minus = false;
        int b = readByte();
        if (b == '-') {
            minus = true;
            b = readByte();
        }
        if (b < '0' || '9' < b) {
            throw new NumberFormatException();
        }
        while (true) {
            if ('0' <= b && b <= '9') {
                n *= 10;
                n += b - '0';
            } else if (b == -1 || !isPrintableChar(b)) {
                return minus ? -n : n;
            } else {
                throw new NumberFormatException();
            }
            b = readByte();
        }
    }

    public int nextInt() {
        long nl = nextLong();
        if (nl < Integer.MIN_VALUE || nl > Integer.MAX_VALUE)
            throw new NumberFormatException();
        return (int) nl;
    }

    public double nextDouble() {
        return Double.parseDouble(next());
    }
}


Measured memory_bytes: 21204
#include<iostream>
#include<numeric>
#include<math.h>
#include<vector>
#include<algorithm>
#include<iomanip>
#include<set>
#include<map>
#include<queue>
#include<climits>
#define fi first
#define se second
#define pb push_back
#define pii pair<int,int>
#define ll long long
#define mkp make_pair
#define pll pair<ll,ll>
#define rep(i,from,to) for(int i=from;i<to;i++)
#define repd(i,from,till) for(int i=from;i>=till;i--)
#define waste ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define inf 1e9+1
#define mod 1e9+7
#define inf1 1e18+1
#define pie 3.14159265358979323846
#define N 100005
using namespace std;
/*
ll bin(ll i,ll j){
	ll mid=(i+j)/2;
	if(a[mid]==x)reutrn mid;
	else if(ans>x)return bin(i,mid-1);
	else return bin(mid+1,j);
}/*
ll power(ll base,ll power){
    ll res=1;
    base=base%mod;
    while(power>0){
    	if(power&1){
    		res=(res*base)%mod;
		}
		power=power>>1;
		base=(base*base)%mod;
	}
	return res;
}
*/
/*
int nCr(int x, int y){
	if(y>x)return 0;
	int num=fact[x];
	num*=invfact[y];
	num%=mod;
	num*=invfact[x-y];
	num%=mod;
	return num;
}
*/
/*bool prime[n+1];
void SieveOfEratosthenes(int n){
	rep(i,0,n+1)prime[i]=true
    for (int p=2;p*p<=n;p++)
        if (prime[p])
            for (int i=p*p;i<=n;i+=p)prime[i]=false;
}*/
/*
int gcd(int a,int b){
	if(b==0)return a;
	else return gcd(b,a%b);
}
*/
int solve(){
    double n;
    cin>>n;
    double a=n/3;
    double b=n/3;
    double c=n-(a+b);
	double ans=a*b*c;
	cout<<fixed<<setprecision(8)<<ans<<endl;
	return 0;
}
int main(){
    waste;
    int t;
    //cin>>t;
    t=1;
    while(t--){
       	solve();
    }
}


Measured memory_bytes: 256
#include<stdio.h>


int main(){
	int a,b;
	char op;
	int ans;
	
	for(;scanf("%d %c %d",&a,&op,&b),op!='?';){
		switch (op){
			case '+':
				ans=a+b;
				break;
				
			case '-':
				ans=a-b;
				break;
			
			case '*':
				ans=a*b;
				break;
			
			case '/':
				ans=a/b;
				break;
				
			default :
				break;
		}
		printf("%d\n",ans);
	}
	return 0;
}

Measured memory_bytes: 600
#include <iostream>
#include <string>
#include <algorithm>

using namespace std;

#define ll long long;
#define REP(i, n) for(int i = 0; i < (int)(n); i++)

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

    cin >> a >> b;
    cout << (a + b + 1) / 2 << endl;

}



Measured memory_bytes: 256
#include <bits/stdc++.h>
#define pb push_back
#define ff first
#define ss second
using namespace std;
using ll = long long;
using vi = vector<int>;
using pii = pair<ll, ll>;
int main() {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  cout.tie(nullptr);
  int x;
  cin >> x;
  int t = x;
  int sum = 0;
  while (t) {
    sum += t % 10;
    t /= 10;
  }
  cout << (x % sum == 0 ? "Yes" : "No") << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <fstream>
#include <set>
#include <map>
#include <string>
#include <vector>
#include <queue>
#include <deque>
#include <stack>
#include <functional>
#include <algorithm>
#include <climits>
#include <cmath>
#include <iomanip>
using namespace std;
#define ll long long int
#define rep(i,n) for( int i = 0; i < n; i++ )
#define rrep(i,n) for( int i = n; i >= 0; i-- )
#define REP(i,s,t) for( int i = s; i <= t; i++ )
#define RREP(i,s,t) for( int i = s; i >= t; i-- )
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define INF 2000000000
#define mod 1000000007
#define INF2 1000000000000000000
const int MAX_N = 100010;

int par[MAX_N];
int Rank[MAX_N];
int size;

void init(int n) {
    for (int i = 0; i < n; i++) {
        par[i] = i;
        Rank[i] = 0;
    }
    size = n;
}

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

void unite(int x, int y) {
    x = find(x);
    y = find(y);
    if (x == y) return;

    size--;
    if (Rank[x] < Rank[y]) {
        par[x] = y;
    } else {
        par[y] = x;
        if (Rank[x] == Rank[y]) {
            Rank[x]++;
        }
    }
}
bool same(int x, int y) {
    return find(x) == find(y);
}
int main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n, m;
    cin >> n >> m;
    init(n);
    rep(i, m) {
        int x, y, z;
        cin >> x >> y >> z;
        x--; y--;
        unite(x, y);
    }
    cout << size << endl;

    return 0;
}


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

int main() {
	// your code goes here
	int n;
	cin >> n;
	int minm = 1e9+7,c= 0;
	for(int i = 0 ; i < n ; i++)
	{
		int inp;
		cin >> inp;
		if(inp <= minm)
		{
			c++;
			minm = inp;
		}
	}
	cout << c;
	
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <queue>
#include <cmath>
#include <algorithm>

#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define INF 999999999
using namespace std;

int main() {
  int N,M,C,num = 0,result;
  cin >> N >> M >> C;
  int B[M];
  int A[N][M];
  for (int i = 0; i < M; i++) {
    cin >> B[i];
  }
  for (int i=0; i<N; i++) {
    for (int j = 0; j < M; j++) {
      cin >> A[i][j];
    }
  }
  for (int i = 0; i < N; i++) {
    result = C;
    for (int j = 0; j < M; j++) {
      result += A[i][j] * B[j];
    }
    if(result > 0) num++;
  }
  cout <<  num << endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
typedef long long ll;
const int INF = 1e9;
using namespace std;

int dig_cnt(int n){
    int num = 0;
    for (int i = 0; i < 15; ++i) {
        if(n>>i & 1){
            num++;
        }
    }
    return num;
}

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

    vector<int> a(n);
    int xy[15][15][2];

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

    int ans = 0;
    for (int i = 0; i < (1 << n); ++i) {
        bool flag = true;
        for (int j = 0; j < n; ++j) {
            if(i & (1<<j)){
                for (int k = 0; k < a[j]; ++k) {
                    if(xy[j][k][1] ^ ((i >> (xy[j][k][0]-1)) & 1)){
                        flag = false;
                    }
                }
            }
        }
        if(flag){
            ans = max(ans, dig_cnt(i));
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <climits>
#include <algorithm>
#include <cmath>
#include <map>
#include <set>
#include <string>
#include <bitset>
#include <utility>
#include <numeric>
#include <queue>
#include <stack>

using ll = long long;
using namespace std;

constexpr int MOD = 1e9 + 7;
constexpr ll MOD_LL = ll(1e9 + 7);

int main(void) {
	int n, k;
	cin >> n >> k;
	
	vector<double> sum(n + 1, 0.0);
	for(int i = 0; i < n; ++i) {
		int p;
		//cin >> p;
		scanf("%d", &p);
		sum[i + 1] = sum[i] + (double)((p + 1)) / 2.0;
	}
	
	double ans = 0.0;
	for(int i = 0; i < n - k + 1; ++i) {
		ans = max(ans, (sum[i + k] - sum[i]));
	}		

	printf("%.12f\n", ans);
	
	return 0;
}


Measured memory_bytes: 1792
#include<iostream>
#include<stdio.h>
#include<string.h>
#include <algorithm>
#include <numeric>
#include <vector>


using namespace std;


char a;
string st;

int main(){

cin>>st;

for(int i=0;i<st.length();i++){
	if(st[i]==st[i+1]){
		printf("%d %d\n",i+1,i+2);
		return 0;
	}
	if(st[i]==st[i+2]&&i<st.length()-1){
		printf("%d %d\n",i+1,i+3);
		return 0;
	}
}

printf("-1 -1\n");
return 0;
}



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

int N;
const int MAX_N = 1.0e5 + 100;
ll A[MAX_N];

int main() {
    cin >> N;
    A[0] = 0;
    for (int i = 1; i <= N; i++) cin >> A[i];
    A[N+1] = 0;

    ll ans = 0;
    for (int i = 1; i <= N; i++) {
        ans += A[i]/2;
        A[i] = A[i]%2;
        if (A[i-1] == 1 && A[i] == 1) {
            ans++;
            A[i-1] = 0;
            A[i] = 0;
        }
        else if (A[i] == 1 && A[i+1] > 0) {
            ans++;
            A[i] = 0;
            A[i+1]--;
        }
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 1024
import sys
sys.setrecursionlimit(1000003)
input=sys.stdin.readline
n,m=map(int,input().split())
bridges=[list(map(int,input().split())) for i in range(m)][::-1]
inconv=[n*(n-1)//2]*m
class UnionFind(object):
    def __init__(self, N):
        self.parent = [i for i in range(N)]
        self.size = [1 for i in range(N)]
 
    def merge(self, a, b):
        if self.issame(a,b):
            return
        pa = self.root(a)
        pb = self.root(b)
        self.parent[pa] = pb
        self.size[pb] += self.size[pa]
    
    def root(self, x):
        p = self.parent[x]
        if p == x:
            return x
        else:
            r = self.root(p)
            self.parent[x] = r
            return r
        
    def issame(self, x, y):
        return self.root(x) == self.root(y)
    
    def getsize(self, x):
        return self.size[self.root(x)]
uf = UnionFind(n)
for i in range(m-1):
    if uf.issame(bridges[i][0]-1,bridges[i][1]-1):
        inconv[i+1]=inconv[i]
        continue
    inconv[i+1]=inconv[i]-uf.getsize(bridges[i][0]-1)*uf.getsize(bridges[i][1]-1)
    uf.merge(bridges[i][0]-1,bridges[i][1]-1)
for i in range(m):
    print(inconv[m-i-1])


Measured memory_bytes: 48144
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
#define mod 1000000007
#define f(i,a,b) for(ll i=a;i<b;i++)
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define ii pair<ll,ll>
#define vii vector<ii>
#define F first
#define S second
#define pb push_back
#define mp make_pair
#define MAX 1e9
 
ll modpow(ll base, ll exp, ll modulus) {base %= modulus;ll result = 1;while (exp > 0) {if (exp & 1) result = (result * base) % modulus;base = (base * base) % modulus;exp >>= 1;}return result;}
const ld pi=acos(-1);

int main(){
    IOS;
    ll n;cin>>n;
    ll a[n];f(i,0,n)cin>>a[i];ll c=0;ll maxi=0;
    f(i,1,n){
        if(a[i]<=a[i-1]){c++;maxi=max(maxi,c);}
        else c=0;
    }
    maxi=max(maxi,c);
    cout<<maxi;
    return 0;
}   

Measured memory_bytes: 1024
M = int(input())

if M >= 400 and M <= 599:
  print(8)
elif M>=600 and M<=799:
  print(7)
elif M>=800 and M<=999:
  print(6)
elif M>=1000 and M<=1199:
  print(5)
elif M>=1200 and M<=1399:
  print(4)
elif M>=1400 and M<=1599:
  print(3)
elif M>=1600 and M<=1799:
  print(2)
elif M>=1800 and M<=1999:
  print(1)

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

int main(){
  int n;
  string m;
  while(cin >> n >> m, n||m!="0"){
    long long M = 0,k = 1;
    for(int i=(int)m.size()-1;i>=0;i--){
      if('0'<= m[i] && m[i]<='9')M += (m[i]-'0')*k;
      else M += (m[i]-'A' + 10)*k;
      k *= n;
    }

    int f[11];
    int pr[] = {2,3,5,7,11,13,17,19,23,29,31};
    
    for(int i=0;i<11;i++){
      int tmp = n;
      f[i] = 0;
      while(!(tmp%pr[i])){
	tmp/=pr[i];
	f[i]++;
      }
    }

    long long ans = 1LL<<62;
    for(int i=0;i<11;i++){
      if(f[i]){
	long long tmp = M,sum = 0;
	while(pr[i]<=tmp){
	  sum += tmp/pr[i];
	  tmp /= pr[i];
	}
	ans = min(ans, sum/f[i]);
      }
    }
    cout << ans << endl;
  }
}

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

#define fst(t) std::get<0>(t)
#define snd(t) std::get<1>(t)
#define thd(t) std::get<2>(t)
#define unless(p) if(!(p))
#define until(p) while(!(p))

using ll = std::int64_t;
using P = std::tuple<int,int>;

int A, B;

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

  std::cin >> A >> B;

  int n = 1, m = 0;

  until(n >= B){
      n -= 1;
      n += A;
      m += 1;
  }

  std::cout << m << std::endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<int,int>;
int main() {
    ll a; string s; cin >> a >> s;
    ll ans = a*(s[0]-'0') + (a/10)*(s[2]-'0') + (a/100)*(s[3]-'0');
    ans += ((a%10)*(s[2]-'0') + (a%100)*(s[3]-'0')/10)/10;
    cout << ans;
}


Measured memory_bytes: 3600
#include <bits/stdc++.h>
using namespace std;
#define fi first
#define se second
#define all(a) a.begin(), a.end()
#define pb push_back
#define mp make_pair
typedef long long ll;
typedef pair<ll,ll> P;
typedef pair<ll,int> pli;
typedef pair<int,int> pii;
typedef long double ld;
#define rep(i,a,b) for(ll i=a ; i<b ; i++)
#define qrep(que, ite) for(auto ite=begin(que) ; ite!=end(que) ; ite++)
const int max_n = 1e5;
const ll mod = 1e9+7;
const ll INF = 1LL<<60;
const int inf = 1e5;
//typedef long double ld;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
int dx[4] = {0,0,1,-1};
int dy[4] = {1,-1,0,0};
struct UnionFind {
    vector<int> par;

    UnionFind(int n) : par(n, -1) { }
    void init(int n) { par.assign(n, -1); }

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

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

    bool merge(int x, int y) {
        x = root(x); y = root(y);
        if (x == y) return false;
        if (par[x] > par[y]) swap(x, y); // merge technique
        par[x] += par[y];
        par[y] = x;
        return true;
    }

    int size(int x) {
        return -par[root(x)];
    }
};
int main(){
  string s; cin>>s;
  bool ok=false;
  rep(i,0,s.size()){
    if(s[i]=='7') ok=true;
  }
  if(ok){
    cout <<"Yes" << endl;
  }else{
    cout << "No" << endl;
  }
  return 0;
}


Measured memory_bytes: 3628
//start of jonathanirvings' template v3.0.3 (BETA)

#include <bits/stdc++.h>
using namespace std;

typedef long long LL;
typedef pair<int,int> pii;
typedef pair<LL,LL> pll;
typedef pair<string,string> pss;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<pii> vii;
typedef vector<LL> vl;
typedef vector<vl> vvl;

double EPS = 1e-9;
int INF = 1000000005;
long long INFF = 1000000000000000005LL;
double PI = acos(-1);
int dirx[8] = {-1,0,0,1,-1,-1,1,1};
int diry[8] = {0,1,-1,0,-1,1,-1,1};

#ifdef TESTING
  #define DEBUG fprintf(stderr,"====TESTING====\n")
  #define VALUE(x) cerr << "The value of " << #x << " is " << x << endl
  #define debug(...) fprintf(stderr, __VA_ARGS__)
#else
  #define DEBUG 
  #define VALUE(x)
  #define debug(...)
#endif

#define FOR(a,b,c) for (int (a)=(b);(a)<(c);++(a))
#define FORN(a,b,c) for (int (a)=(b);(a)<=(c);++(a))
#define FORD(a,b,c) for (int (a)=(b);(a)>=(c);--(a))
#define FORSQ(a,b,c) for (int (a)=(b);(a)*(a)<=(c);++(a))
#define FORC(a,b,c) for (char (a)=(b);(a)<=(c);++(a))
#define FOREACH(a,b) for (auto &(a) : (b))
#define REP(i,n) FOR(i,0,n)
#define REPN(i,n) FORN(i,1,n)
#define MAX(a,b) a = max(a,b)
#define MIN(a,b) a = min(a,b)
#define SQR(x) ((LL)(x) * (x))
#define RESET(a,b) memset(a,b,sizeof(a))
#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define ALL(v) v.begin(),v.end()
#define ALLA(arr,sz) arr,arr+sz
#define SIZE(v) (int)v.size()
#define SORT(v) sort(ALL(v))
#define REVERSE(v) reverse(ALL(v))
#define SORTA(arr,sz) sort(ALLA(arr,sz))
#define REVERSEA(arr,sz) reverse(ALLA(arr,sz))
#define PERMUTE next_permutation
#define TC(t) while(t--)

inline string IntToString(LL a){
  char x[100];
  sprintf(x,"%lld",a); string s = x;
  return s;
}

inline LL StringToInt(string a){
  char x[100]; LL res;
  strcpy(x,a.c_str()); sscanf(x,"%lld",&res);
  return res;
}

inline string GetString(void){
  char x[1000005];
  scanf("%s",x); string s = x;
  return s;
}

inline string uppercase(string s){
  int n = SIZE(s); 
  REP(i,n) if (s[i] >= 'a' && s[i] <= 'z') s[i] = s[i] - 'a' + 'A';
  return s;
}

inline string lowercase(string s){
  int n = SIZE(s); 
  REP(i,n) if (s[i] >= 'A' && s[i] <= 'Z') s[i] = s[i] - 'A' + 'a';
  return s;
}

inline void OPEN (string s) {
  freopen ((s + ".in").c_str (), "r", stdin);
  freopen ((s + ".out").c_str (), "w", stdout);
}

//end of jonathanirvings' template v3.0.3 (BETA)


LL f(int i,int o,int t,int j, int l,int s,int z)
{
  LL risan = 0;
  risan += (i/2)*2;
  risan += o;
  risan += (j/2)*2;
  risan += (l/2)*2;
  return risan;
}

int i,o,t,j,l,s,z;
LL risan = 0;

int main()
{
  scanf("%d %d %d %d %d %d %d",&i,&o,&t,&j,&l,&s,&z);
  MAX(risan,f(i,o,t,j,l,s,z));
  if (i >= 1 && j >= 1 && l >= 1)
  {
    MAX(risan,f(i-1,o,t,j-1,l-1,s,z) + 3);
  }
  printf("%lld\n",risan);
  return 0;
}










Measured memory_bytes: 384
n = gets.chomp.to_i

counts = Array.new(n, 0)
for i in 1...100 do
  for j in i...100 do
    for k in j...100 do
      n1 = i * i + j * j + k * k +
           i * j + j * k + k * i
      break if n1 > n
      gain = 1
      if i == j
        if j == k
          gain = 1
        else
          gain = 3
        end
      else
        if j == k
          gain = 3
        else
          gain = 6
        end
      end
      counts[n1 - 1] += gain
    end
  end
end

puts counts


Measured memory_bytes: 14404
def cp(a,b,c,d,e,f,g,h):
    A = a*d-b*c
    B = e*h-f*g
    C = d-b
    D = e-g
    E = c-a
    F = f-h
    det = C*D - E*F
    return [(A*D + B*E)/det,(A*F + B*C)/det]

q = int(input())
for i in range(q):
    a,b,c,d,e,f,g,h = [int(i) for i in input().split()]
    P = cp(a,b,c,d,e,f,g,h)
    print(P[0],P[1])

Measured memory_bytes: 7760
#![allow(unused_imports)]
#![allow(non_snake_case)]
use std::cmp::*;
use std::collections::*;
use std::io::Write;

#[allow(unused_macros)]
macro_rules! debug {
    ($($e:expr),*) => {
        #[cfg(debug_assertions)]
        $({
            let (e, mut err) = (stringify!($e), std::io::stderr());
            writeln!(err, "{} = {:?}", e, $e).unwrap()
        })*
    };
}

fn main() {
    let n = read::<usize>();
    let mut a = vec![0i64; n];
    for i in 0..n {
        a[i] = read();
    }
    let mut current_counter = 1;
    let mut ans = a[0] - 1;
    for i in 1..n {
        if a[i] == current_counter + 1 {
            current_counter = a[i];
            continue;
        }
        ans += (a[i] - 1) / (current_counter + 1);
    }
    println!("{}", ans);
}

fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}

fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    read::<String>()
        .split_whitespace()
        .map(|e| e.parse().ok().unwrap())
        .collect()
}


Measured memory_bytes: 4476
import sys
#input = sys.stdin.buffer.readline

def main():
    N,K = map(int,input().split())
    s = str(input())
    
    count = 0
    change = 0
    for i in range(N-1):
        if s[i+1] == s[i]:
            count += 1
        else:
            change += 1

    if change//2 >= K:
        print(count+2*K)
    else:
        print(N-1)

if __name__ == "__main__":
    main()

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

using namespace std;


bool iscon(string s){
    int b=0;
    for(int i=b;i<s.size();i++){
        if(s[i]=='e'){
            if(s.substr(i,5)=="erase"){
                if(s[i+5]=='r') i=i+5;
                else i=i+4;
                continue;
            }
            else return false;
        }else if(s[i]=='d'){
            if(s.substr(i,5)=="dream"){
                if(s.substr(i+5,3)=="era") i=i+4; //dream
                else if(s.substr(i+5,2)=="er") i=i+6;   //dreamer
                else i=i+4; //ream
                continue;
            }
            else return false;
        }else return false;
    }
    return true;
}

void test1(){
    string s;
    cin>>s;
    if(iscon(s))cout<<"YES"<<endl;
    else cout<<"NO"<<endl;
}
int main()
{
    //freopen("data","r",stdin);
    //for(int i=0;i<10;i++) test1();
    test1();
    return 0;
}


Measured memory_bytes: 512
#include <iostream>
#include <algorithm>
#include <cstring>
#include <string>
#include <cmath>
#include <vector>
#define ll long long
#define si(n) scanf("%d",&n)
#define sl(n) scanf("%lld",&n)
#define pi(n) prllf("%d",n)
#define pl(n) prllf("%d",n)
using namespace std;

int main(){
  int n;
  cin>>n;
  string s;
  cin>>s;
  int opti_left = 0,opti_right = 0;
  int index_left = 0,index_right = n-1;
  int max_left = 0,max_right = 0;
  int final_index=0;
  for(int i=0;i<n;i++){
    if(s[i]=='E') opti_left++;
    else opti_left--;

    if(opti_left>max_left){
      max_left = opti_left;
      index_left = i;
    }
  }
  for(int i=n-1;i>=0;i--){
    if(s[i]=='W') opti_right++;
    else opti_right--;

    if(opti_right>max_right){
      max_right = opti_right;
      index_right = i;
    }
  }
  int m = max(max_left,max_right);
  if(m==max_left){
    final_index = index_left;
  }else{
    final_index = index_right;
  }
  int count = 0;
  for(int i=0;i<final_index;i++){
    if(s[i]=='W') count++;
  }
  for(int i=final_index+1;i<n;i++){
    if(s[i]=='E') count++;
  }
  cout<<count<<endl;
}


Measured memory_bytes: 900
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define FOR(i,a,b) for(ll i=a;i<=b;i++)
#define FORD(i,a,b) for(ll i=a;i>=b;i--)
#define ALL(a)  (a).begin(),(a).end()
#define SZ(a) int((a).size())
#define SORT(c) sort((c).begin(),(c).end())
#define PB push_back
#define MP make_pair
#define MEMSET(v, h) memset((v), h, sizeof(v))
#define sqr(x)  ((x) * (x)) 
#define cub(x)  ((x) * (x) * (x))
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
// 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;}

ll stock[10][10];

int main() {
  ll n; cin >> n;
  ll ans = 0;

  FOR(i,1,n){
    vector<int> v;
    ll tmp = i;
    while(tmp>0){
      v.PB(tmp%10);
      tmp /= 10;
    }

    ans += 2 * stock[v[SZ(v)-1]][v[0]];
    ++stock[v[0]][v[SZ(v)-1]];
    if(v[0]==v[SZ(v)-1]) ++ans;
  }

  cout << ans << endl;

}

Measured memory_bytes: 256
def main():
    N = int(input())
    S = input().rstrip()
    current_char = S[0]
    ans = 1
    for idx in range(1, N):
        if S[idx] != current_char:
            ans += 1
            current_char = S[idx]
    print(ans)


if __name__ == '__main__':
    main()


Measured memory_bytes: 68344
N, Y = map(int,input().split())
flag = False
for x in range(N+1):
  for y in range(N+1-x):
    if Y == x*10000 + y*5000 + (N-x-y)*1000:
      print(x, y, N-x-y)
      flag = True
      exit()
if flag == False:
  print(-1,-1,-1)

Measured memory_bytes: 3060
use std::io::*;
use std::str::FromStr;

use std::cmp::{max, min};

pub fn read<T: FromStr>() -> T {
  let stdin = stdin();
  let stdin = stdin.lock();
  let token: String = stdin
    .bytes()
    .map(|c| c.expect("failed to read char") as char)
    .skip_while(|c| c.is_whitespace())
    .take_while(|c| !c.is_whitespace())
    .collect();
  token.parse().ok().expect("failed to parse token")
}

fn main() {
  let n = read::<i32>();
  let a = read::<i32>();
  let b = read::<i32>();
  let c = read::<i32>();
  let mut l = vec![];

  for _ in 0..n {
    let value = read::<i32>();
    l.push(value);
  }

  println!("{}", dfs(0, 0, 0, 0, n, a, b, c, &l))
}

fn dfs(
  cur: i32,
  a_v: i32,
  b_v: i32,
  c_v: i32,
  n: i32,
  a: i32,
  b: i32,
  c: i32,
  l: &Vec<i32>,
) -> i32 {
  if cur == n {
    return if min(a_v, min(b_v, c_v)) > 0 {
      (a_v - a).abs() + (b_v - b).abs() + (c_v - c).abs() - 30
    } else {
      (10 as i32).pow(9)
    };
  }

  let ret0 = dfs(cur + 1, a_v, b_v, c_v, n, a, b, c, l);
  let ret1 = dfs(cur + 1, a_v + l[cur as usize], b_v, c_v, n, a, b, c, l) + 10;
  let ret2 = dfs(cur + 1, a_v, b_v + l[cur as usize], c_v, n, a, b, c, l) + 10;
  let ret3 = dfs(cur + 1, a_v, b_v, c_v + l[cur as usize], n, a, b, c, l) + 10;
  return min(min(ret0, ret1), min(ret2, ret3));
}


Measured memory_bytes: 4352
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef std::pair<int,int> pair2;
typedef std::pair<int,pair2> pair3;
const ll INF = 1LL<<60;

int main(){
ll N,M;
  cin>>N>>M;
  ll X[M],Y[M],Z[M];
  vector<vector<ll>> fri(N+1,vector<ll>(0,0));
  
  for(ll i=0;i<M;i++){
  cin>>X[i]>>Y[i]>>Z[i];
    //Z[i]=Z[i]%2;
  fri[X[i]].push_back(Y[i]);
  fri[Y[i]].push_back(X[i]);
  }

  vector<ll> dist(N+1,-1);
  queue<ll> que;
  ll ans=0;
  
  for(ll i=1;i<N+1;i++){
    if(dist[i]!=-1)continue;
    que.push(i);
    dist[i]=0;
    ans++;
    
    while(!que.empty()){
    	ll num=que.front();
    	que.pop();
    
      for(ll j=0;j<(ll)fri[num].size();j++){
        if(dist[fri[num][j]]!=-1)continue;
        que.push(fri[num][j]);
        dist[fri[num][j]]=0;
        
      }
      
    }
  
  }
  
  
  
  

  cout<<ans<<endl;
  
}


Measured memory_bytes: 13436
//Utkarsh.25dec
#include <bits/stdc++.h>
#define ll long long int 
#define ull unsigned long long int
#define pb push_back
#define mp make_pair
#define mod 1000000007
#define rep(i,n) for(ll i=0;i<n;i++)
#define loop(i,a,b) for(ll i=a;i<=b;i++)
#define vi vector <int>
#define vs vector <string>
#define vc vector <char>
#define vl vector <ll>
#define all(c) (c).begin(),(c).end()
#define max3(a,b,c) max(max(a,b),c)
#define min3(a,b,c) min(min(a,b),c)
using namespace std;
const int N=500023;
bool vis[N];
vector <int> adj[N];
void solve()
{
    ll n;
    cin>>n;
    vl v;
    v.pb(0);
    ll ans[n+1]={0};
    rep(i,n)
    {
        ll c;
        cin>>c;
        v.pb(c);
    }
    vl pos;
    for(int i=n;i>=1;i--)
    {
        ll count=0;
        for(int j=2*i;j<=n;j+=i)
        {
            if(ans[j]==1)
                count++;
        }
        if(count%2==v[i])
            ans[i]=0;
        else
        {
            ans[i]=1;
            pos.pb(i);
        }
    }
    cout<<pos.size()<<'\n';
    for(int i=0;i<pos.size();i++)
    {
        cout<<pos[i]<<' ';
    }
}
int main()
{
    ios_base::sync_with_stdio(false); 
    cin.tie(NULL);
    int T=1;
    //cin>>T;
    int t=0;
    while(t++<T)
    {
        //cout<<"Case #"<<t<<":"<<' ';
        solve();
        //cout<<'\n';
    }
}

Measured memory_bytes: 17648
#include <iostream>
#include <stdlib.h>
#include <utility>
#include <math.h>
#include <stdexcept>
using namespace std;
int int_sort(const void*a,const void *b) {
    return *( int *) b - *(int *) a;
    //qsort(b, a, sizeof(long long int), int_sort);
}

int main() {

    double n,a;
    cin >> n>>a;
    
   cout<<n/a;

    return 0;
}


Measured memory_bytes: 256
/*
power code taken from geeks for geeks
*/

#include <bits/stdc++.h>
#define MODD 998244353LL
#define MAX_SIZE 100000000
#define MAX_N 200001
using namespace std;
typedef long long ll;

ll max(ll a,ll b){return a>b?a:b;}
ll min(ll a,ll b){return a<b?a:b;}
double max(double a,double b){return a>b?a:b;}
double min(double a,double b){return a<b?a:b;}

ll modd(ll a){if(a<0LL) return a*-1LL;return a;}
double modd(double a){if(a<0.0) return a*-1.0;return a;}

ll modulo(ll a){return a % MODD; }

ll power(ll k, ll p){
    if (p == 0)
        return 1LL;
 
    ll P = power(k, p/2LL);
    P = (P * P) % MODD;
 
    if (p % 2 == 1)
        P = (P * k) % MODD;
 
    return P;
}

ll power(ll k, ll p, bool m){
    if (p == 0)
        return 1LL;
 
    ll P = power(k, p/2LL);
    P = (P * P);
 
    if (p % 2 == 1)
        P = (P * k);
 
    return P;
}


void swap(string& s1, string &s2){
    string temp=s1;
    s1=s2;
    s2=temp;
}

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


bool comp(p_str& a, p_str& b){
    return a.a>b.a;
}



void solve(){
    ll s,w;
    cin>>s>>w;
    if(w>=s){
        cout<<"unsafe"<<endl;
    }
    else{
        cout<<"safe"<<endl;
    }
}


int main(){

    #ifndef ONLINE_JUDGE 

    // For getting input from input.txt file 
    freopen("input.txt", "r", stdin); 

    // Printing the Output to output.txt file 
    freopen("output.txt", "w", stdout); 
    #endif 

    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    

    ll t=1;
    
    // cin>>t;
    while(t--){
        solve();
    }


    return 0;
}


Measured memory_bytes: 3652
#include<cstdio>
#include<iostream>
#include<sstream>
#include<cmath>
#include<algorithm>
#include<map>
#include<set>
#include<list>
#include<vector>
#include<stack>
#include<queue>
#include<string>
#include<iomanip>
#include<fstream>
#include<ctime>
using namespace std;
typedef vector<int> VI;
typedef pair <int,int> ii;
typedef long long LL;
#define pb push_back
const int INF = 2147483647;
const int N = 305;

int tab[N][N], bat[N][N], i, n, j, res;
char t[N];

void move(int r, int c) {
	for (int i=0;i<n;i++) {
		int newr = (i + r) % n;
		for (int j=0;j<n;j++) bat[newr][(j + c) % n] = tab[i][j];
	}
}

bool ok() {
	for (int i=0;i<n;i++) for (int j=i+1;j<n;j++) if (bat[i][j] != bat[j][i]) return false;
	return true;
}

int main() {
scanf("%d", &n);
for (i=0;i<n;i++) {
	scanf("%s", t);
	for (j=0;j<n;j++) tab[i][j] = int(t[j]) - 'a';
}
res = 0;
for (i=1;i<n;i++) {
	move(i, 0);
	if (ok()) res += (n - i);
	move(0, i);
	if (ok()) res += (n - i);
}
move(0, 0);
if (ok()) res += n;
printf("%d\n", res);
return 0;
}



Measured memory_bytes: 1024