akhauriyash/Code-Regression huggingface dataset:
N = int(input())
a = []
exp = {1}
for i in range(N):
  a.append(int(input()))
r = a[0]
flag = 0
ans = 0
while True:
  if(r in exp):
    flag = -1
    break
  if(r == 2):
    flag = 1
    break
  exp.add(r)
  r = a[r- 1]
  ans+= 1
  
if(flag == -1):
  print("-1")
else:
  print(ans+ 1)

Measured memory_bytes: 13220
#include"bits/stdc++.h"
#define int long long
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=(a);i<(b);++i)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define itr(i,x) for(auto i=(x).begin();i!=(x).end();++i)
#define All(x) (x).begin(),(x).end()
#define rAll(x) (x).rbegin(),(x).rend()
using namespace std;
using Graph=vector<vector<int>>;
typedef pair<int,int> P;
typedef vector<int> vi;
typedef vector<vi> vvi;
const int mod=1000000007;
int gcd(int x,int y){return y?gcd(y,x%y):x;}
int lcm(int x,int y){return x*y/gcd(x,y);}
int roundup(int a,int b){return	(a-1)/b+1;}
void YN(bool flg){cout<<(flg?"YES":"NO")<<endl;}
void Yn(bool flg){cout<<(flg?"Yes":"No")<<endl;}
void yn(bool flg){cout<<(flg?"yes":"no")<<endl;}


signed main(){
	int n;cin>>n;
	vector<P> dish(n);
	rep(i,n) {
		cin>>dish[i].first>>dish[i].second;
	}
	vector<int> orda(n);
	iota(All(orda),0);
	sort(All(orda),[&](int x,int y){return dish[x].first+dish[x].second>dish[y].first+dish[y].second;});
	int ans=0;
	rep(i,n){
		int now=orda[i];
		if(i%2==0) ans+=dish[now].first;
		else ans-=dish[now].second;
	}
	cout<<ans<<endl;
}


Measured memory_bytes: 2560
# coding=utf-8

def print_list(X):
    first_flag = True
    for val in X:
        if first_flag:
            print_line = str(val)
            first_flag = False
        else:
            print_line = print_line + ' ' + str(val)
    print(print_line)

def combine_list(A_suit, A_rank, N):
    A_after = []
    for i in range(N):
        A_after.append(A_suit[i] + str(A_rank[i]))
    return A_after


def bubble_sort(A, index_list, N):
    #print_list(A)
    #flag: ???????????????????????????True???????´?
    flag = True
    i = 0
    while flag:
        flag = False
        for j in range(N-1, i, -1):
            if A[j] < A[j-1]:
                A[j-1], A[j] = A[j], A[j-1]
                index_list[j-1], index_list[j] = index_list[j], index_list[j-1]
                flag = True
        i += 1
    return A, index_list

def selection_sort(A, index_list, N):
    for i in range(N):
        min_j = i
        for j in range(i, N):
            if A[j] < A[min_j]:
                min_j = j
        if i != min_j:
            A[i], A[min_j] = A[min_j], A[i]
            index_list[i], index_list[min_j] = index_list[min_j], index_list[i]
    return A, index_list

def main():
    N = int(input())
    A = list(input().split())
    A_suit = []
    A_rank = []
    index_list = [x for x in range(N)]
    A_after_bubble = []
    A_after_selection = []

    for element in A:
        val = list(element)
        val_suit = val[0]
        val_rank = int(val[1])
        A_suit.append(val_suit)
        A_rank.append(val_rank)
    A_suit_after_bubble = [0 for x in range(N)]
    A_suit_after_selection = [0 for x in range(N)]

    A_rank_after_bubble, index_list_after_bubble = bubble_sort(A_rank.copy(), index_list.copy(), N)
    A_rank_after_selection, index_list_after_selection = selection_sort(A_rank.copy(), index_list.copy(), N)

    for index_before, index_after in enumerate(index_list_after_bubble):
        A_suit_after_bubble[index_before] = A_suit[index_after]

    for index_before, index_after in enumerate(index_list_after_selection):
        A_suit_after_selection[index_before] = A_suit[index_after]

    A_after_bubble = combine_list(A_suit_after_bubble, A_rank_after_bubble, N)
    A_after_selection = combine_list(A_suit_after_selection, A_rank_after_selection, N)

    print_list(A_after_bubble)
    print("Stable")
    print_list(A_after_selection)
    if A_after_selection == A_after_bubble:
        print("Stable")
    else:
        print("Not stable")



if __name__ == '__main__':
    main()

Measured memory_bytes: 7852
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <string>
#include <vector>
#include <queue>
#include <map>
#include <set>
#include <functional>
#include <cmath>
#include <complex>
#include <cctype>
#include <cassert>
#include <sstream>
#include <ctime>
#include <cstdlib>
#include <cstring>
#include <deque>

using namespace std;

#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) (v).begin(),(v).end()
#define fi first
#define se second

template<typename A, typename B> inline bool chmax(A &a, B b) { if (a<b) { a=b; return 1; } return 0; }
template<typename A, typename B> inline bool chmin(A &a, B b) { if (a>b) { a=b; return 1; } return 0; }

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

const ll INF = 1ll<<29;
const ll MOD = 1000000007;
const double EPS = 1e-10;

string b[10] = {
	"0111111",
	"0000110",
	"1011011",
	"1001111",
	"1100110",
	"1101101",
	"1111101",
	"0100111",
	"1111111",
	"1101111"
};

int main() {
	int n;
	while (cin >> n, n != -1) {
		string now = "0000000";
		
		REP(t, n) {
			int num; scanf("%d", &num);
			
			REP(i, 7) {
				putchar(now[i] != b[num][i] ? '1' : '0');
				now[i] = b[num][i];
			}
			puts("");
		}
	}
	return 0;
}

Measured memory_bytes: 3088
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <algorithm>
#include <string>
#include <cmath>
#include <cstdio>
#include <iomanip>
#include <fstream>
#include <cassert>
#include <cstring>
#include <unordered_set>
#include <unordered_map>
#include <numeric>
#include <ctime>
#include <bitset>
#include <complex>
#include <chrono>
#include <random>
#include <functional>

using namespace std;

#define int long long

signed main() {
	ios_base::sync_with_stdio(false);
	cin.tie(0);	

	int n;
	cin >> n;
	vector<int> a(n);
	vector<int> b(n);
	int sa = 0;
	int sb = 0;
	for (auto &t : a) {
		cin >> t;
		sa += t;
	}
	for (auto &t : b) {
		cin >> t;
		sb += t;
	}
	int c = 0;
	for (int i = 0; i < n; i++) {
		if (a[i] <= b[i]) {
			c += (b[i] - a[i] + 1) / 2;
		}
	}
	if (c <= sb - sa) {
		cout << "Yes\n";
	} else {
		cout << "No\n";
	}
}


Measured memory_bytes: 3256
#include<stdio.h>

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

  if(n%10==3)
    printf("bon\n");
  else if(n%10==0 || n%10==1 || n%10==6 || n%10==8)
    printf("pon\n");
  else
    printf("hon\n");

  return 0;
}


Measured memory_bytes: 1652
INF=10000050

N,M,X=map(int,input().split())

A=[]
C=[]
for i in range(N):
    array=list(map(int,input().split()))
    C.append(array[0])
    A.append(array[1:])

combination=[i for i in range(2**N)]

min_price=INF

for i in range(2**N):
    price=0
    knowledge=[0 for i in range(M)]
    for j in range(N):
        if combination[i]%(2**(j+1)):
            price+=C[j]
            for k in range(M):
                knowledge[k]+=A[j][k]
            combination[i]-=2**j
    if min(knowledge)>=X:
        min_price=min(min_price,price)

if min_price==INF:
    print("-1")
else:
    print(min_price)

Measured memory_bytes: 9320
#include<bits/stdc++.h>
#define int long long
#define pb emplace_back
#define mp make_pair
#define mt make_tuple
#define all(v) v.begin(),v.end()
#define rep(i,start,lim) for(long long (i)=(start);i<(lim);i++)
#define revrep(i,n) for(long long i=n-1;i>=0;i--)
#define boost ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define osit ostream_iterator<int> output (cout," ")
#define endl '\n'
#define f first
#define s second
#define PI 3.141592653589793
#define MOD 1000000007
#define set0(x) memset(x,0,sizeof(x))
#define set1(x) memset(x,1,sizeof(x))
using namespace std;
typedef vector<int> vi;
typedef list<int> li;
typedef pair<int,int> ii;
typedef vector<ii> vii;
typedef tuple<int, int, int> iii;
template<typename T> T gcd(T a,T b){if(a==0) return b; return gcd(b%a,a);}
template<typename P> P dectobin(P a){if(a==0)return 0; else return(a%2 + 10*dectobin(a/2));}
template<typename Y> Y bintodec(Y a){int ans=0,b=1,t=a; while (t){int ld=t%10; t/=10;ans+=ld* b;b=b*2;} return ans; }
template<typename H> H modExp(H x, H n){ int r=1; while(n>0){if(n%2==1){r=(r*x)%MOD;}x=(x*x)%MOD;n/=2;}return r;}
template<typename T> T isPowerOfTwo(T x){return x && (!(x & (x - 1)));}	
template<typename T> T lcm(T a,T b) {return a*b/gcd(a,b);}
//template<typename T> T extendedEuclid(T A,T B){if(B==0){d=A; x=1;y=0;}else{ extendedEuclid(B,A%B);int temp=x; x=y; y=temp-(A
//B)*y;}}
int32_t main(){
	boost;osit;
	int n;
	cin>>n;
	int k=n%10;
	if(k==3) cout<<"bon";
	else if(k==0 || k==1 || k==6 || k==8) cout<<"pon";
	else cout<<"hon";
	return 0;
}

Measured memory_bytes: 3652
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define endl "\n"
const int dx[] = { -1 , -1 , -1 , 0 , 0 , 0 , 1 , 1 , 1 };
const int dy[] = { -1 , 0 , 1 , -1 , 0 , 1 , -1 , 0 , 1 };
const ll integer = pow(2, 32) - 1; // 4294967295
#define N 8010000
#define TC int t;cin>>t;for(int T=1;T<=t;T++)
#define mod 1000000007
#define PI acos(-1)
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
void AIA() { ios::sync_with_stdio(0); cin.tie(0); cout.tie(0); }
bool isprime(ll n) {
	for (ll i = 2; i * i <= n; i++) {
		if (n % i == 0)return 0;
	}
	return (n!=1);
}

/*
 _____________              __                ___        ___       ___________________________     ____        ____
|             |            /\ \              |   |      |   |     |                           |    \   \      /   /
|   __________|           / /\ \             |   |      |   |     |      _____      _____     |     \   \    /   /
|  |                     / /  \ \            |   |      |   |     |     |     |    |     |    |      \   \  /   /
|  |                    / /    \ \           |   |      |   |     |     |     |    |     |    |       \   \/   /
|  |______             / /      \ \          |   |______|   |     |     |     |    |     |    |        \      /
|         |           / /        \ \         |              |     |     |     |    |     |    |         \    /
|   ______|          / /          \ \        |    ______    |     |     |     |    |     |    |          |  |
|  |                / /============\ \       |   |      |   |     |     |     |    |     |    |          |  |
|  |               / /==============\ \      |   |      |   |     |     |     |    |     |    |          |  |
|  |              / /                \ \     |   |      |   |     |     |     |    |     |    |          |  |
|  |             / /                  \ \    |   |      |   |     |     |     |    |     |    |          |  |
|__|            /_/                    \_\   |___|      |___|     |_____|     |____|     |____|          |__|

										  <<<<<<<<<<< NEVER GIVE UP !! >>>>>>>>>>>
										<<<<<<<< YOU CAN DO IT IF YOU WANT !! >>>>>>>>
										 <<<<<<<<< BELIEVE IN YOURSELF !! >>>>>>>>>

*/
int main() {
	//cout << fixed << setprecision(9);
	//freopen("stand.in","r",stdin);
	//freopen("stand.out","w",stdout);
	AIA();
	int n,c=0;
	cin>>n;
	vector<int>v(n);
	for(int i = 1 ; i <= n ;i++){
		cin>>v[i];
		if(i%2 && v[i]%2){
			c++;
		}
	}
	cout<<c;
	return 0;
}

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

void solve(int N, std::string S)
{
  char prev = S.front();
  int count = 1;
  for(const auto& s: S)
  {
    if(s != prev){
      count++;
      prev = s;
    }
  }
  std::cout << count << std::endl;
}

int main(void)
{
  int N;
  std::string S;
  std::cin >> N;
  std::cin >> S;
  solve(N,S);
  return 0;
}


Measured memory_bytes: 512
#include<iostream>
#include<cstdlib>
#include<cstdio>
#include<string>
#include<iomanip>
#include<algorithm>
#include<vector>
#include<math.h>
#include<utility>
using namespace std;

long long int a, b, c, k;
long long int res = 0;
int main(){
    
    cin >> a >> b >> c >> k;

    if(a >= k){
        res += k;
        cout << res << endl;
        return 0;
    } else {
        res += a;
        k -= a;
        if(b >= k){
            cout << res << endl;
            return 0;
        } else {
            k-=b;
            res-=k;
            cout << res << endl;
        }
    }
}

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

int main()
{
  int list[7][7]={
    {0,300,500,600,700,1350,1650},
    {6,0,350,450,600,1150,1500},
    {13,7,0,250,400,1000,1350},
    {18,12,5,0,250,850,1300},
    {23,17,10,5,0,600,1150},
    {43,37,30,25,20,0,500},
    {58,52,45,40,35,15,0}
  };
  int in,out,h,m,start,end,fee;
  bool half;
  while(cin>>in,in){
    cin>>h>>m;
    start=100*h+m;
    cin>>out>>h>>m;
    end=100*h+m;
    if(in>out)swap(in,out);
    in--;out--;
    if( (1730<=start && start<=1930) || (1730<=end && end<=1930) )half=true;
    else half=false;
    if(list[out][in]>40)half=false;
    fee=list[in][out];
    if(half){
      fee/=2;
      fee+=25;
      fee/=50;
      fee*=50;
    }
    cout<<fee<<endl;
  }
}

Measured memory_bytes: 0
/*g++ main.cpp -o main.out*/
/*./main.out*/
/*std::ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);*/

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

#define LL long long
#define Mod 1000000007
#define L_Mod 17100000013

const double eps = 1e-9;
const int INF = 0x3f3f3f3f;
const double PI = 3.1415926535;

#define NO_TLE std::ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);

#define ree(n,a) memset(n,a,sizeof(n));

#define rep(i,n) for(int (i)=0;(i)<(int)(n);++(i))
#define rer(i,l,u) for(int (i)=(int)(l);(i)<=(int)(u);++(i))
#define red(i,l,u) for(int (i)=(int)(l);(i)>=(int)(u);--(i))

int main()
{
    int a,b;
    cin>>a>>b;
    int t=1,ans=0;
    while(t<b)
    {
        t--;
        t+=a;
        ans++;
    }
    cout<<ans<<endl;
    return 0;
}


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

class Card{
    private:
        char suit;
        int num;
    public:
        void setCard(char suit, int num){
            this->suit = suit;
            this->num = num;
        }
        char getSuit(){
            return this->suit;
        }
        int getNum(){
            return this->num;
        }
};

void bubbleSort(Card card[], int N){
    for(int i = 0; i < N; i++){
        for(int j = N - 1; j > i; j--){
            if(card[j].getNum() < card[j-1].getNum()){
                swap(card[j], card[j-1]);
            }
        }
    }
}

void selectionSort(Card card[], int N){
    int minj;
    for(int i = 0; i < N; i++){
        minj = i;
        for(int j = i; j < N; j++){
            if(card[j].getNum() < card[minj].getNum()){
                minj = j;
            }
        }
        swap(card[i], card[minj]);
    }
}

void showCard(Card card[], int N){
    for(int i = 0; i < N; i++){
        if(i != 0) cout << " ";
        cout << card[i].getSuit();
        cout << card[i].getNum();
    }
    cout << endl;
}

bool isStable(Card card[], Card card2[], int N){
    for(int i = 0; i < N; i++){
        if (card[i].getSuit() != card2[i].getSuit()){
            return false;
        }
    }
    return true;
}


int main(){
    int N;
    cin >> N;
    char suit;
    int num;
    Card* card = new Card[N];
    Card* card2 = new Card[N];
    Card* compCard = new Card[N];
    for(int i = 0; i < N; i++){
        cin >> suit;
        cin >> num;
        card[i].setCard(suit, num);
        card2[i].setCard(suit, num);
        compCard[i].setCard(suit, num);
    }
    bubbleSort(card, N);
    selectionSort(card2, N);
    showCard(card, N);
    cout << "Stable" << endl;
    showCard(card2, N);
    if(isStable(card, card2, N)){
        cout << "Stable" << endl;
    }else{
        cout << "Not stable" << endl;
    }
    return 0;
}



Measured memory_bytes: 3112
import itertools
import math

n = int(input())
p = list(map(int,input().split()))
q = list(map(int,input().split()))

li = [0] * n
for i in range(n):
    li[i] = i + 1

sub = list(itertools.permutations(li, n))

pans = 0
qans = 0
so = math.factorial(n)
for i in range(so):
    for j in range(n):
        if sub[i][j] != p[j]:
            break
        if j == n - 1:
            pans = i + 1

for i in range(so):
    for j in range(n):
        if sub[i][j] != q[j]:
            break
        if j == n - 1:
            qans = i + 1

print(max(pans, qans) - min(pans, qans))

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


struct Card { char letter, value;};
    
void bubble(struct Card A[], int N){    
    for(int i=0; i<N; i++){
        for(int j = N-1; j>= i+1; j--){
            if(A[j].value < A[j-1].value){
                
                Card x= A[j];
                A[j] = A[j-1];
                A[j-1] = x;
            }
        }
    }
}

void selection(struct Card A[], int N){
    for(int i=0; i<N; i++){
        int minj =i;
        for(int j=i; j<N; j++){
            if(A[j].value < A[minj].value){
                minj =j;
            }
        }
        Card x = A[i];
        A[i] = A[minj];
        A[minj] = x;
        
    }
}


void print(struct Card A[], int N){
    for(int k=0; k<N; k++){
        if(k != 0){
            cout << " ";
        }
        cout << A[k].letter << A[k].value;
    }
    cout << endl;
}

bool Stable(struct Card C1[], struct Card C2[], int N){
    for(int i=0; i<N; i++){
        if(C1[i].letter != C2[i].letter) return false;
    }
    return true;
}
    
int main(){

Card C1[100], C2[100];    
int N;
char  letter;

cin >> N;
    for(int i=0; i<N; i++){
        cin >> C1[i].letter >> C1[i].value;
    }
    
    for(int i=0; i<N; i++){
        C2[i] = C1[i];
    }
    
    bubble(C1, N);
    selection(C2, N);
    
    print(C1, N);
    cout << "Stable" << endl;
    
    print(C2, N);
    if( Stable(C1, C2, N)){
        cout << "Stable" << endl;
    }else{
        cout << "Not stable" << endl;
    }
    
    return 0;
}



Measured memory_bytes: 3108
#include <stdio.h>

int main(){
    int n;scanf("%d",&n);
    if(n<105) printf("%d",0);
    else if(n<135) printf("%d",1);
    else if(n<165) printf("%d",2);
    else if(n<189) printf("%d",3);
    else if(n<195) printf("%d",4);
    else printf("%d",5);
    return 0;
} 

Measured memory_bytes: 256
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
        long mod = (long)Math.pow(10,9)+7;
        long n = sc.nextLong();
        long k = sc.nextLong();
        long[] a = new long[(int)n];
        for(long i = 0; i < n; i++){
            a[(int)i] = sc.nextLong();
        }
        long ans = 0;
        for(long i = 0; i < n; i++){
            for(long j = i-1; j >= 0; j--){
                if(a[(int)i] > a[(int)j]){
                    ans += ((k-1)*k)/2%mod;
                    ans %= mod;
                }
            }
            for(long j = i+1; j < n; j++){
                if(a[(int)i] > a[(int)j]){
                    ans += k*(k+1)/2%mod;
                    ans %= mod;
                }
            }
        }
        System.out.println(ans);
    }
}


Measured memory_bytes: 25260
#include<iostream>
#include<string>
#include<cstdio>
#include<vector>
#include<algorithm>

using namespace std;

int main(){
	vector<string> ans;
	int n,l,a;
	string h,t,m,d,rt,rh;
	vector<string> p,q;
   
	cin>>n;
	while(n--){
		cin>>m;
		l=m.size();
		ans.clear();
		
		for(int i=1;i<l;i++){
			p.clear();
		    q.clear();
			rh=h=m.substr(0,i);
			rt=t=m.substr(i);
			reverse(rt.begin(),rt.end());
			reverse(rh.begin(),rh.end());

			p.push_back(h);
			q.push_back(t);
			p.push_back(rh);
			q.push_back(rt);
		
			for(int j=0;j<2;j++){
				for(int k=0;k<2;k++){
					d=p[j]+q[k];
					for(a=0;a<ans.size();a++)
						if(ans[a]==d) break;
					if(a==ans.size())
						ans.push_back(d);
				}
			}

			
			for(int j=0;j<2;j++){
				for(int k=0;k<2;k++){
					d=q[j]+p[k];
					for(a=0;a<ans.size();a++)
						if(ans[a]==d) break;
					if(a==ans.size())
						ans.push_back(d);
				}
			}
		}

		cout<<ans.size()<<endl;
	}

	return 0;
}

Measured memory_bytes: 1280
#include <bits/stdc++.h>
#include<algorithm>
#include<cstring>
#include<cmath>
#include<cstdlib>
#include<string.h>
using namespace std;
#define pb push_back
#define all(v) v. begin(),v. end()
#define  rep(i,n,v) for(i=n;i<v;i++)
#define per(i,n,v) for(i=n;i>v;i--)
#define ff first 
#define ss second 
#define pp pair<ll,ll>
#define ll  long long
#define endl '\n'
void solve()
{
  ll n, a,m=0,b=1, c,k=0, i, j,l=1e9+7;
  string s, r, y;
  getline(cin,s);
  cout<<s[0];
   rep(i,1,s.length())
   {
     if(s[i-1]==' ') cout<<s[i];
   }
   cout<<endl;
}
int main()
{
 ios_base::sync_with_stdio(false);
  cin. tie(0);cout. tie(0);
    ll t=1;
   //cin>>t;
    while(t--)
    {
      solve();
    }
    return 0;
}

Measured memory_bytes: 3660
//
//  CPlibrary
//
//  Created by Tanmay Singh on 3/03/2020.
// INDIAN INSTITUTE OF TECHNOLOGY (BHU) , VARANASI
//  Copyright © 2020 Tanmay Singh. All rights reserved.
//#pragma GCC target ("avx2")
#pragma GCC optimization ("O3")
//#pragma GCC optimization ("unroll-loops")
 
#include <algorithm>
#include <bitset>
#include <cassert>
#include <chrono>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <climits>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <random>
#include <ratio>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>
 
#define FAST(); ios_base::sync_with_stdio(false);cin.tie(NULL);
#define endl "\n"
#define mod 1000000007
typedef long long int  bigint ;
typedef std::vector< int > vi;
typedef std::vector< long long int > vll;
typedef std::vector< vi > vvi;
 
using namespace std;

int main(){
    FAST() ;
    string str ; cin >> str ;
    bigint N = str.length() ;
    bigint pref[N] ;
    memset(pref, 0, sizeof(pref)) ;
    if( str[0] == 'B' )
        pref[0] = 1 ;
    for( int i = 1 ; i < N ; i++ ){
        pref[i] = pref[i-1] ;
        if( str[i] == 'B' )
            pref[i] ++ ;
    }
    bigint ans = 0 ;
    for( int i = 0 ; i < N ; i++ ){
        if( str[i] == 'W' )
            ans += pref[i] ;
    }
    cout << ans << endl ;
    return 0 ;
}


Measured memory_bytes: 2196
#include<stdio.h>

int n,A[50];

int solve(int i,int m){
  if(m == 0) return 1;
  if(i >=n ) return 0;
  int res = solve(i + 1,m) || solve(i + 1,m - A[i]);
  return res;
}

  int main(){
  int q,M,i;

  scanf("%d", &n);
  for(i = 0; i < n; i++)
  scanf("%d",&A[i]);
  scanf("%d", &q);
  for(i = 0;i < q; i++){
  scanf("%d", &M);
  if(solve(0,M)) printf("yes\n");
  else printf("no\n");
}
  return 0;
}

Measured memory_bytes: 1740
function Main(input){
	var a = input.split("\n");
  var b = a[0].split(" ");
  var N = b[0]*1;
  var T = b[1]*1;
  var minCost = 10000;
  for(var i = 1; i <= N ; i++){
  	var d = a[i].split(" ");
    var c = d[0]*1;
    var t = d[1]*1;
    if(t > T){
    	continue;
    }
		if(c < minCost){
  	  minCost = c;
    }
  }
  if(minCost == 10000){
  	return "TLE";
  }
  return minCost;
}
console.log(Main(require("fs").readFileSync("/dev/stdin", "utf8")));

Measured memory_bytes: 21064
#include<stdio.h>
#include<stdlib.h>

struct Node {
  int v;
  Node* prev;
  Node* next;
};

Node *nil;

void init() {
  nil = (Node *)malloc(sizeof(Node));
  nil->prev = nil;
  nil->next = nil;
}

void insertNode(int x) {
  Node *node = (Node *)malloc(sizeof(Node));
  node->v = x;
  nil->next->prev = node;
  node->next = nil->next;
  nil->next = node;
  node->prev = nil;
}

Node* search(int x) {
  Node *node = nil->next;
  while(node != nil) {
    if(node->v == x) return node;
    node = node->next;
  }
  return nil;
}

void deleteNode(Node* node) {
  if ( node != nil ) {
    node->prev->next = node->next;
    node->next->prev = node->prev;
    free(node);
  }
}

void deleteAt(int x) {
  deleteNode(search(x));
}

void deleteFirst() {
  deleteNode(nil->next);
}

void deleteLast() {
  deleteNode(nil->prev);
}

int main() {
  int n, v;
  char com[12];

  scanf("%d", &n);
  init();

  while ( scanf("%s %d", com, &v) != EOF ) {
    if ( com[0] == 'i' ) {
      insertNode(v);
    } else if ( com[0] == 'd' ) {
      if ( com[6] == 'F' ) {
        deleteFirst();
      } else if ( com[6] == 'L' ) {
        deleteLast();
      } else {
        deleteAt(v);
      }
    }
  }

  Node *node = nil->next;
  int i = 0;
  while(node != nil) {
    if (i) printf(" ");
    printf("%d", node->v);
    node = node->next;
    i++;
  }

  printf("\n");

  return 0;
}



Measured memory_bytes: 33836
#include <bits/stdc++.h>
 
using namespace std;
 
typedef long long ll;
typedef pair<int,int> ii;
 
int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n, t;
    cin >> n;
    int rez = 0;
    for (int ctr1 = 0; ctr1 < n; ++ctr1)
        cin >> t, rez += t != ctr1 + 1;
    if (rez <= 2) 
        cout << "YES";
    else
        cout << "NO";
    return 0;
}

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


int main(){
    cout<<fixed<<setprecision(10);

    ll n;cin>>n;
    vint a(n); rep(i,n)cin>>a[n-1-i];
    
    rep(i,n-1) cout<<a[i]<<" ";
    cout<<a.back()<<endl;

    

    return 0;
}







Measured memory_bytes: 3056
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
typedef long long ll;
const int INT_INF = 2147483647;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
typedef pair<int,int> P;

int main(){
  int n;
  cin >> n;
  map<int,int> a;
  rep(i,n){
    int t;
    cin >> t;
    a[t]++;
  }
  if(a.size()==n){
    cout << "YES" << endl;
  }else{
    cout << "NO" << endl;
  }
}


Measured memory_bytes: 9600
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Numerics;

class _Class
{
  void _Do()
  {
    var _ = Split.ints();
    int K = _[0];
    int A = _[1];
    int B = _[2];

    if (A+2 >= B)
    {
      Console.WriteLine(K+1);
      return;
    }
    long b = 1;
    int m = 0;
    for (int i=0;i<K ; i++)
    {
      if(m==1)
      {
        b += B;
        m = 0;
      }
      else if (b>=A)
      {
        if (i==K-1)
        {
          b +=1;
        }
        else
        {
          m = 1;
          b -=A;
        }
      } else 
        b+=1;
    }
    Console.WriteLine(b);
  }

  static void Main(string[] args)
  {
    _(args);
    new _Class()._Do();
  }

  [Conditional("DEBUG")]
  static void _(string[] args)
  {
    if (args.Length != 0 && File.Exists(args[0]))
      Console.SetIn(new StreamReader(args[0]));
    else
      Console.Error.WriteLine("in");
  }
}

static class Split
{ 

  // 1
  public static string[] strings()
  {
    return Console.ReadLine().Split();
  }


  // [2.1] -2,147,483,648 ~ +2,147,483,647
  public static int[] ints()
  {
    var _s = Console.ReadLine().Split();

    var x = new int[_s.Length];
    for (var i = 0; i < _s.Length; i++)
      x[i] = int.Parse(_s[i]);

    return x;
  }

  // [2.2] 
  // -9,223,372,036,854,775,808 ~ 
  // +9,223,372,036,854,775,807
  public static long[] longs()
  {
    var _s = Console.ReadLine().Split();

    var x = new long[_s.Length];
    for (var i = 0; i < _s.Length; i++)
      x[i] = long.Parse(_s[i]);

    return x;
  }

  public static double[] doubles()
  {
    var _s = Console.ReadLine().Split();

    var x = new double[_s.Length];
    for (var i = 0; i < _s.Length; i++)
      x[i] = double.Parse(_s[i]);

    return x;
  }

  public static BigInteger[] bigs()
  {
    var _s = Console.ReadLine().Split();

    var x = new BigInteger[_s.Length];
    for (var i = 0; i < _s.Length; i++)
      x[i] = BigInteger.Parse(_s[i]);

    return x;
  }
}




Measured memory_bytes: 11092
#include <algorithm>
#include <cmath>
#include <complex>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <vector>
#include <functional>
#include <cstring>
#include <regex>
#include <random>
#include <cassert>
#include <stack>
#include <climits>
#include <chrono>
#include <fstream>
using namespace std;

#pragma region

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repr(i, s, n) for (int i = (s); i < (int)(n); i++)
#define revrep(i, n) for (int i = (n) - 1; i >= 0; i--)
#define revrepr(i, s, n) for (int i = (n) - 1; i >= s; i--)
#define debug(x) cerr << #x << ": " << x << "\n"
#define popcnt(x) __builtin_popcount(x)

const double PI = acos(-1.0);

using ll = long long;
using P = pair<int, int>;

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; }

template<class T>
istream& operator >>(istream &is, vector<T> &v) {
    for (int i = 0; i < (int)v.size(); i++) cin >> v.at(i);
    return is;
}

template<class T, class U>
ostream& operator <<(ostream &os, pair<T, U> p) {
    cout << '(' << p.first << ", " << p.second << ')';
    return os;
}

template<class T>
void print(const vector<T> &v, const string &delimiter = " ") { rep(i, v.size()) cout << (0 < i ? delimiter : "") << v.at(i); cout << endl; }

template<class T>
void print(const vector<vector<T>> &vv, const string &delimiter) { for (const auto &v: vv) print(v, delimiter); }

#pragma endregion


int main() {
    int n;
    cin >> n;
    vector<int> a(n);
    cin >> a;
    rep(i, n) a[i]--;
    int cnt = 0;
    rep(i, n) {
        if (a[a[i]] == i) cnt++;
    }
    cout << cnt / 2 << endl;
}

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

signed main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	int n;
	cin >> n;
	string s[3];
	cin >> s[0] >> s[1] >> s[2];
	int ans = 0;
	char c[3];
	for (int i = 0; i < n; i++) {
		for (int j = 0; j < 3; j++) {
			c[j] = s[j][i];
		}
		sort(c, c + 3);
		if (c[0] != c[1] && c[1] != c[2]) ans += 2;
		else if (c[0] == c[1] && c[1] != c[2]) ans++;
		else if (c[0] != c[1] && c[1] == c[2]) ans++;
	}
	cout << ans << endl;
	return 0;	
}

Measured memory_bytes: 384
#include<stdio.h>
#include<vector>
typedef long long ll;
int main()
{
	const int N=4001;
	int n,i,p,q;
	while(scanf("%d",&n),n)
	{
		ll e[N]={0};
		std::vector<int>d;
		while(n--)
		{
			scanf("%d%d%d",&i,&p,&q);
			if(!e[i])d.push_back(i);
			e[i]+=(ll)p*q;
		}
		for(i=n=0;i<d.size();++i)if(e[d[i]]>=1000000)n=printf("%d\n",d[i]);
		if(!n)puts("NA");
	}
	return 0;
}

Measured memory_bytes: 0
#include<iostream>
#include<iomanip>
#include<string>
#include<algorithm>
#include<vector>
#include<utility>
#include<tuple>
#include<map>
#include<queue>
#include<stack>
#include<deque>
#include<bitset>
#include<math.h>
using namespace std;
using ll = int64_t;
using Graph = vector<vector<int> >;
const ll M = 1000000007;

int main(){
    int n,m;
    cin >> n >> m;
    vector<int> x;
    for(int i=0;i<m;i++){
        int y;
        cin >> y;
        x.push_back(y);
    }

    sort(x.begin(),x.end());

    //for(int i=0;i<m;i++) cout << x.at(i) << " ";

    if(n>=m){
        cout << 0 << endl;
        return 0;
    }

    vector<int> d;
    for(int i=1;i<m;i++) d.push_back(x.at(i)-x.at(i-1)-1);

    sort(d.begin(),d.end());

    //for(int i=0;i<d.size();i++) cout << d.at(i) << " ";
    //cout << endl;

    int ans=m-n;
    for(int i=0;i<m-n;i++) ans+=d.at(i);

    cout << ans << endl;
}

Measured memory_bytes: 4224
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0; i < (n);i++)
#define sz(x) int(x.size());
typedef long long ll;
typedef pair<int,int> P;
const long double EPS = 0.0000000001;
const long double PI = acos(-1);
long double a, b, x;

bool ok(long double theta){
  if (theta > PI / 2.0 - EPS) return true;
  long double ret;
  if (a * tan(theta) <= b) {
    ret = a * a * b - a * a * a * tan(theta) / 2.0;
  } else {
    ret = b * b / tan(theta) * a / 2.0;
  }
  return ret < x;
}


int main(){
  
  cin >> a >> b >> x;
  long double l = 0, r = PI / 2.0;
  rep(i,100000){
    long double mid = (r + l) / 2.0; 
    if (ok(mid)) r = mid;
    else l = mid;
  }
 cout << fixed << setprecision(10) << r / PI * 180 << endl;
  
  return 0;
} 

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

int main(){
    ll n,a,b,c,d;
    cin >> n >> a >> b >> c >> d;
    string ans = "NO";
    for(int i = 0;i < n;i ++){
        if(a-i*d+(n-1-i)*c<=b&&b<=a-i*c+(n-1-i)*d) {ans = "YES";break;}
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <fstream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <string>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <deque>
#include <bitset>
#include <algorithm>
#include <complex>
#include <array>
#include <iomanip>
using namespace std;

#define REP(i,n) for(int i=0; i<n; ++i)
#define FOR(i,a,b) for(int i=a; i<=b; ++i)
#define FORR(i,a,b) for (int i=a; i>=b; --i)
#define ALL(c) (c).begin(), (c).end()

typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<long double> VD;
typedef vector<VI> VVI;
typedef vector<VL> VVL;
typedef vector<VD> VVD;
typedef pair<int,int> P;
typedef pair<ll,ll> PL;

template<typename T> void chmin(T &a, T b) { if (a > b) a = b; }
template<typename T> void chmax(T &a, T b) { if (a < b) a = b; }

int in() { int x; scanf("%d", &x); return x; }
ll lin() { ll x; scanf("%lld", &x); return x; }
#define INF 1LL<<60

int main() {
    int N, K;
    cin >> N >> K;
    vector<int> a(N);
    for(int i=0; i<N; i++) cin >> a[i];

    // dp[k]: 残りの石がk個の時どちらが勝つか 0 or 1
    vector<int> dp(K+1);
    for(int k=0; k<=K; k++) {
        vector<int> flag(N);

        for(int i=0; i<N; i++) {
            if(k-a[i]<0) flag[i] = 1;
            else if(dp[k-a[i]] == 0) flag[i] = 1;
            else flag[i] = 0;
        }
        int flag_max, flag_min;
        flag_max = *max_element(flag.begin(), flag.end());
        flag_min = *min_element(flag.begin(), flag.end());

        if(flag_max==1 && flag_min==1)
            dp[k] = 1;
        else
            dp[k] = 0;
    }
    if(dp[K]==0)
        cout << "First" << endl;
    else
        cout << "Second" << endl;
    return 0;
}

Measured memory_bytes: 640
from collections import deque

h,w = list(map(int,input().split()))
par = [[x for x in input()] for _ in range(h)]

dh = [1,0,-1,0]
dw= [0,1,0,-1]

def bfs():
  m = [[float('inf')]*w for _ in range(h)]
  que = deque([])
  que.append([0,0])
  m[0][0] = 0
  
  while que:
    cur = que.popleft()
    #if cur[0] == h and cur[1] == w:
    #  break
    
    for i in range(4):
      nh = cur[0] + dh[i]
      nw = cur [1] + dw[i]
      
      if nh >= 0 and nh < h and nw >= 0 and nw < w and \
          m[nh][nw] == float('inf') and par[nh][nw] == '.':
        que.append([nh,nw])
        m[nh][nw] = m[cur[0]][cur[1]] + 1
        
  return m

m = bfs()

if m[h-1][w-1] == float('inf'):
  print(-1)
  exit()

cnt = 0
for i in range(h):
  for j in range(w):
    if par[i][j] == '.':
      cnt += 1

print(cnt - m[h-1][w-1] -1)


Measured memory_bytes: 3316
#include <iostream>
#include <vector>
#include <queue>
using namespace std;
int main()
{
    int n, a, b, c, q, k, x, y;
    pair<int, int> p;
    queue<int> u;
    cin >> n;
    vector<vector<pair<int, int>>> d(n+1);
    vector<long long> e(n+1, -1);
    for(int i = 0; i < n-1; i++) {
        scanf("%d%d%d", &a, &b, &c);
        d[a].push_back(make_pair(b, c));
        d[b].push_back(make_pair(a, c));
    }
    cin >> q >> k;
    u.push(k);
    e[k] = 0;
    while(u.empty() == false) {
        for(int i = 0; i < d[u.front()].size(); i++) {
            p = d[u.front()][i];
            if(e[p.first] == -1) {
                u.push(p.first);
                e[p.first] = e[u.front()] + p.second;
            }
        }
        u.pop();
    }
    for(int i = 0; i < q; i++) {
        scanf("%d%d", &x, &y);
        printf("%lld\n", e[x] + e[y]);
    }
    return 0;
}

Measured memory_bytes: 8820
s=input()
t=input()
tmp=s
flag=False
if(len(s)==2 and s[0]==t[1] and s[1]==t[0]):flag=True
    
for i in range(len(s)):
    if(t==tmp):
        flag=True
        break
    tmp=""
    for j in range(len(s)):
        c=i+j
        if(c>=len(s)):
            c-=len(s)
        tmp+=s[c]


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

Measured memory_bytes: 3064
#pragma GCC optimize("O3")
#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")
#pragma GCC target("avx,avx2")
#include<stdio.h>
#include<algorithm>
#include<math.h>
#include<vector>
#include<set>
#include<unordered_map>
#include<assert.h>
#include<time.h>
#include<stdlib.h>
#include<random>
#include<queue>
using namespace std;
using lld = long long int;
using pll = pair<lld, lld>;
using lf = double;
using pff = pair<lf, lf>;
using pif = pair<int, lf>;
using pii = pair<int, int>;
using pli = pair<lld, int>;
using pil = pair<int, lld>;
using piii = pair<int, pii>;
#define M 998244353
int n, m;
char a[1000009];
int main() {
	int i, j, k, l;
	int t = 1, tv = 0;
	//scanf("%d", &t);
	while (t--) {
		scanf("%s", a);
		for (n = 0; a[n]; n++) {

		}
		printf("%s", a);
		if (a[n - 1] == 's') {
			printf("es");
		}
		else{
			printf("s");
		}
	}
	return 0;
}

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

#define db(x) cout<<x<<'\n'
#define db1(x) cout<<#x<<"="<<x<<'\n'
#define db2(x,y) cout<<#x<<"="<<x<<","<<#y<<"="<<y<<'\n'
#define db3(x,y,z) cout<<#x<<"="<<x<<","<<#y<<"="<<y<<","<<#z<<"="<<z<<'\n'
#define repi(i,n) for(int i=0;i<(n);++i)
//#define repA(i,a,n) for(int i=a;i<=(n);++i)
//#define repD(i,a,n) for(int i=a;i>=(n);--i)
#define ll long long int
#define endl '\n'
#define lld long long double
#define vi vector<int> 
#define vl vector<ll> 
#define vb vector<bool> 
#define vvi vector<vector<int>  >
#define err(t) cout<<"Error : "<<t<<endl;
#define all(v) v.begin(),v.end()
#define mp make_pair
#define MD 1000000007 //998244353
#define pb push_back
#define rep(i,a,b) for(ll i = a; i <= (b); i++)
#define pii pair<int,int>
#define pll pair<ll,ll> 
#define vec(a) vector<a >
#define se second
#define fi first
#define inf 0xffffffff
#define inchar getchar_unlocked
#define outchar(x) putchar_unlocked(x)
//template <typename T>
//using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
ll binpow(ll a,ll b){	if(a==0) return 0; if(b==0) return 1;ll ans=1;while(b>0){if(b&1) ans=ans*a; a=a*a; b=b>>1;}	return ans;}
template <typename T> 
T Min(T a,T b){ return a<b?a:b; }
template <typename T>
T Max(T a,T b){ return a>b?a:b; }

int32_t main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);cout.tie(NULL);
	// int n;cin>>n;
	// string s;cin>>s;
	
	//ll n;cin>>n; vl a(n); repi(i,n) cin>>a[i];
	ll n,x,M,ans=0;
	cin>>n>>x>>M;
	if(M==1) {db(0);return 0;}
	vector<int> m(1e5+1,0);auto ne=m;
	vl a;
	ll b=x;int q=n;
	while(m[x]==0&&q){
		if(a.size()==0) a.push_back(x);
		else a.push_back(a.back()+x);
		m[x]=1;
		x*=x;
		x%=M;
		q--;
	}
	if(q==0)
	db(a.back());
	else{
	int t=0;
	vl p;
	while(ne[x]==0) {
	
		if(p.size()) p.push_back(p.back()+x); else p.push_back(x);
		ne[x]=1,x*=x,x%=M,t++;
	}
		n-=a.size();
		ans=a.back();
		
		ans+=n/p.size()*p.back();
		if(n%p.size()) ans+=p[n%p.size()-1];
		db(ans);
	}
	/*
	int test1;cin>>test1;while(test1--){ 
		
	 }
	 //*/
return 0;
}



Measured memory_bytes: 5032
#include<bits/stdc++.h>
#define F first
#define S second
#define pb push_back
#define mp make_pair
#define full(a) a.begin(),a.end()
#define rfull(a) a.rbegin(),a.rend()

using namespace std;
const double pi=acos(-1.0);
const double pii=2*pi;
const double eps=1e-6;
const long long MOD=1e9+7;

void solve(){
    int x;
    cin>>x;
    vector<pair<int,int>> kyu{{400,599},{600,799},{800,999},{1000,1199},{1200,1399},{1400,1599},{1600,1799},{1800,1999}};
    for(int i=0;i<kyu.size();i++){
        if(kyu[i].first<=x && x<=kyu[i].second){
            cout<<(8-i)<<"\n";
            return;
        }
    }
}

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

    int t=1;
    // cin >> t;
    while(t--){
        solve();
    }
    return 0;
}

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

using namespace std;

#define YES cout << "YES" << endl;
#define NO  cout << "NO"  << endl;
#define Yes cout << "Yes" << endl;
#define No  cout << "No"  << endl;
 
#define INF INT_MAX
#define MOD 1000000007
#define PI  acos(-1)

using ll  = long long;
using ull = unsigned long long;
using Pii = pair<int, int>;
using Pll = pair<ll, ll>;

#define rep(i, n) for (ll i = 0; i < (n); i++)
#define rrep(i, n) for (ll i = (n)-1; i >= 0; i--)

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

    ll X, Y;
    cin >> X >> Y;

    if (abs(X-Y) > 1) {
        cout << "Alice" << endl;
    } else {
        cout << "Brown" << endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <math.h>
int main(void) 
{
    double x, y, a, b;
    scanf("%lf%lf%lf%lf", &x, &y, &a, &b);
    printf("%lf\n", sqrt((x - a) * (x - a) + (y - b) * (y - b)));

    return 0;
}


Measured memory_bytes: 2104
n=list(map(int,input().split()))
a=n[0]
b=n[1]
k=n[2]
if(a<=k):
    k=k-a
    a=0
    if(b<=k):
        b=0
    else:
        b=b-k
else:
    a=a-k
print('{0} {1}'.format(a,b))

Measured memory_bytes: 3060
import java.util.*;
import java.lang.Math;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();
    int ans = -n;
    
    for(int i = 0; i < n;i++) ans += sc.nextInt();
    	
    System.out.println(ans);
  }
}


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

ll absll(ll a){
  if(a<0){
    return a * -1;
  }
  return a;
}

int main() {
  ll n;
  cin >> n;
  vector<ll> a(n,0);
  ll count = 0;
  ll sum = 0;
  for (int i = 0; i < n; i++) {
    cin >> a[i];
    if(a[i]<0){
      count++;
      sum += a[i] * -1;
      a[i] *= -1;
    }else{
      sum += a[i];
    }
  }
  sort(a.begin(), a.end());
  if(count%2==0){
    cout << sum << endl;
  }else{
    cout << sum + a[0]*-2 << endl;
  }
  return 0;
}


Measured memory_bytes: 4048
#include<bits/stdc++.h>
using namespace std;
#define endl '\n'
#define ll long long int
#define FIO ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define all(in) in.begin(), in.end()

int main(){
    FIO;
    ll n, k, q;
    cin >> n >> k >> q;
    ll arr[n+1];
    for(ll i = 1 ; i <= n ; i++){
        arr[i] = k;
    }
    ll tmp = q;
    while(q--){
        ll x;   cin >> x;
        arr[x]++;
    }
    q = tmp;
    for(ll i = 1 ; i <= n ; i++){
        arr[i] -= q;
        if(arr[i] > 0){
            cout << "Yes" << endl;
        }else{
            cout << "No" << endl;
        }
    }
    return 0;
}


Measured memory_bytes: 1408
#include <bits/stdc++.h>
using namespace std;
int main(){
 int X,A,B;
 cin>>X>>A>>B;

 if(B-A>X){
  cout<<"dangerous"<<endl;
 }
 else if(B>A){
     cout<<"safe"<<endl;
 }
 else
 {
     cout<<"delicious"<<endl;
 }
 
}


Measured memory_bytes: 3632
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner scan=new Scanner(System.in);
		int a=scan.nextInt();
		int b=scan.nextInt();
		if(a<b)
		System.out.println("a < b");
		else if(a>b)
		System.out.println("a > b");
		else if(a==b)
		System.out.println("a == b");
		scan.close();
	}
	
}


Measured memory_bytes: 26288
#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
#define pi 3.141592653589793238
#define int long long
using namespace __gnu_pbds;
using namespace std;
template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

signed main()
{
     ios_base::sync_with_stdio(false);
     cin.tie(NULL);  
     cout.tie(0);   
 #ifndef ONLINE_JUDGE
    if(fopen("INPUT.txt","r"))
    {
    freopen ("INPUT.txt" , "r" , stdin);
    freopen ("OUTPUT.txt" , "w" , stdout);
    }
 #endif
 
// -------------------------------------Code starts here---------------------------------------------------------------------     

   int n,k;
   cin>>n>>k;
   n%=k;
   cout<<min(n,k-n);
   
// -------------------------------------Code ends here------------------------------------------------------------------
     clock_t clk;
 	clk = clock();
 
    clk = clock() - clk;
 	cerr << fixed << setprecision(6) << "Time: " << ((double)clk)/CLOCKS_PER_SEC << "\n";
 	return 0;
 }
 

Measured memory_bytes: 256
#include <iostream>
#include <cstdlib>
#include <cstdio>
#include <cmath>
#include<ctime>
#include<random>
#include<cstring>
#include<cstdlib>
#include<cstdint>
#include<fstream>
#include<strstream>
#include<vector>
#include<string>

//#include "D:\Code\C++\Headers\zle_CSV.h"

#define ll long long
#define US unsigned
#define UINT unsigned int
#define e18 1000000000000000000
#define e9  1000000000
using namespace std;



int main() {
	int a, b, c, d, e;
	cin >> a>>b>>c>>d>>e;
	if (a == 0) {
		cout << 1;
	}
	if (b == 0) {
		cout << 2;
	}
	if (c == 0) {
		cout << 3;
	}
	if (d == 0) {
		cout << 4;
	}
	if (e == 0) {
		cout << 5;
	}

	return 0;
}

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

void dfs(string s, char maxc)
{
  if (s.size() == N)
  {
    cout << s << endl;
    return;
  }
  char last = (s[s.size() - 1] == maxc ? maxc + 1 : maxc);
  for (char c = 'a'; c <= last; c++)
  {
    string next_s = s + c;
    dfs(next_s, last);
  }
}

int main()
{
  cin >> N;
  string S = "a";
  dfs(S, 'a');
}


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

using namespace std;

int N;
long long int sum = 0;
vector<long long int> A,B,C;

int main(void) {
    cin>>N;

    for(int i = 0;i < N;i++) {
        int temp;
        cin>>temp;
        A.push_back(temp);
    }

    for(int i = 0;i < N;i++) {
        int temp;
        cin>>temp;
        B.push_back(temp);
    }

    for(int i = 0;i < N;i++) {
        int temp;
        cin>>temp;
        C.push_back(temp);
    }

    sort(A.begin(),A.end());
    sort(C.begin(),C.end());

    for(int i = 0;i < N;i++) {
        long long int l,r;
        l = (lower_bound(A.begin(),A.end(),B[i]) - A.begin());
        r = (C.end() - upper_bound(C.begin(),C.end(),B[i]));
        sum += l*r;
    }

    cout<<sum<<endl;

    return 0;
}


Measured memory_bytes: 3316
#include<cstdio>
#include<cstring>
#include<cmath>
#include<bitset>
#include<iostream>
#include<algorithm>
#include<string>
#include<utility>
#include<tuple>
#include<vector>
#include<list>
#include<map>
#include<set>
#include<queue>
#include<stack>
#include<numeric>
#include<functional>
#include<iomanip>
#include<random>

#define IOS ios::sync_with_stdio(false),cin.tie(0)
#define REP(i,n) for(int i = 0;i < n;i++)
#define FOR(i,a,b) for(int i = a;i < b;i++)
#define MEM(a,b) memset(a,b,sizeof(a))
#define ALL(x) (x).begin(),(x).end()
#define LMAX 9223372036854775807
#define LMIN -9223372036854775808

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;
typedef pair<ull, ull> UP;
typedef tuple<int, int, int> T;

struct UnionFind {
	vector<int> data;
	UnionFind(int size) : data(size, -1) {}
	void unionSet(int x, int y) {
		x = root(x), y = root(y);
		if (x != y) {
			if (data[y] < data[x])swap(x, y);
			data[x] += data[y]; data[y] = x;
		}
	}
	bool findSet(int x, int y) {
		return root(x) == root(y);
	}
	int root(int x) {
		return data[x] < 0 ? x : data[x] = root(data[x]);
	}
	int size(int x) {
		return -data[root(x)];
	}
};

int gcd(int a, int b) {
	if (a < b)swap(a, b);
	int k = a % b;
	if (k == 1)return 1;
	if (k == 0)return b;
	int ans = gcd(b, k);
	return ans;
}
int digisum(ll a) {
	int sum = 0;
	while (a) {
		sum += a % 10;
		a /= 10;
	}
	return sum;
}


int main() {
	int n;
	cin >> n;
	cout << n / 3 << endl;
}



Measured memory_bytes: 256