akhauriyash/Code-Regression huggingface dataset:
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

func main() {
	n, r := ScanInt64(), ScanInt64()
	inner := int64(0)
	if n >= 10 {
		inner = r
	} else {
		inner = r + 100*(10-n)
	}
	fmt.Println(inner)
}

/*********************** I/O ***********************/

var in *bufio.Scanner

func init() {

	in = bufio.NewScanner(os.Stdin)
	in.Buffer(make([]byte, 1024), int(1e+9))
	in.Split(bufio.ScanWords)

	writer := bufio.NewWriter(os.Stdout)
	go func() {
		defer writer.Flush()

	}()
}

func ScanWord() string { in.Scan(); return in.Text() }
func ScanInt() int     { i, _ := strconv.Atoi(ScanWord()); return i }
func ScanInt64() int64 { i, _ := strconv.ParseInt(ScanWord(), 10, 64); return i }


Measured memory_bytes: 640
import numpy as np

X = int(input())

x = np.arange(-300, 300, dtype=np.int64)

x5 = x**5
diff = np.subtract.outer(x5, x5)

i = np.where(diff == X)


x, y = i[0][0], i[0][1]
x -= 300
y -= 300

print(x, -y)


Measured memory_bytes: 29992
#include<iostream>
#include<algorithm>
#include<math.h>
#include<stdio.h>
#include<string>
#include<vector>
using namespace std;

int main() {
	string s;
	cin >> s;
	int size = 0;
	size = s.size();
	int ans = 0;
	for (int i = 0; i < size / 2; i++)
	{
		if (s[i] != s[size - i - 1])ans++;
	}
	cout << ans << endl;
	return 0;
}

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

struct Swimmer{
    int idx,t,c;
    int reach;
};
const int INF=1e9;
bool operator<(Swimmer lhs,Swimmer rhs){
    return lhs.t<rhs.t;
}
int solve(int n){
    vector<Swimmer> swimmer(n);
    for(int i=0;i<n;i++){
        int t,c;
        cin>>t>>c;
        swimmer[i]=Swimmer{i,t,c,t};
    }
    sort(swimmer.begin(),swimmer.end());
    queue<Swimmer> fque;
    queue<Swimmer> bque;
    for(auto &s:swimmer) fque.push(s);

    int res=0;
    while(!(fque.empty() && bque.empty())){
        int ft=(fque.empty() ? INF : fque.front().reach);
        int bt=(bque.empty() ? INF : bque.front().reach);
        if(ft<bt){
            auto s=fque.front();
            int t=s.reach;
            vector<Swimmer> goals;
            while(!fque.empty() && fque.front().reach<=s.reach){
                goals.push_back(fque.front());
                fque.pop();
            }
            sort(goals.begin(),goals.end());
            for(auto &e:goals){
                bque.push(Swimmer{e.idx,e.t,e.c,t+e.t});
            }
            res=t;
        }
        else{
            auto s=bque.front();
            int t=s.reach;
            vector<Swimmer> goals;
            while(!bque.empty() && bque.front().reach<=s.reach){
                goals.push_back(bque.front());
                bque.pop();
            }
            sort(goals.begin(),goals.end());
            for(auto &e:goals){
                if(e.c-1>0) fque.push(Swimmer{e.idx,e.t,e.c-1,t+e.t});
            }
            res=t;
        }
    }
    return res;
}
int main(){
    int n;
    while(cin>>n,n){
        cout<<solve(n)<<endl;
    }
    return 0;
}


Measured memory_bytes: 3128
n = int(input())
a = [int(input()) for i in range(n)]
ans = 0
for i in range(n-1):
  if a[i]%2==0:
    ans+=a[i]//2
  elif a[i+1]>0:
    ans+=1
    a[i]-=1
    ans+=a[i]//2
    a[i+1]-=1
  else:
    ans+=a[i]//2    
  #print(ans)
  
ans+=a[n-1]//2
print(ans)

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

#include <bits/stdc++.h>

using namespace std;

int solve(int a, int b, int c) {
	if (a > b) {
		swap(a, b);
	}
	if (a > c) {
		swap(a, c);
	}
	if (b > c) {
		swap(b, c);
	}
	return a != b && b != c && a + b > c;
}
int main()
{
#ifdef _MSC_VER
	freopen("b.in", "r", stdin);
#endif
	std::ios::sync_with_stdio(false);
	int n;
	cin >> n;
	vector<int> a(n);
	for (int i = 0; i < n; ++i) {
		cin >> a[i];
	}
	int ret = 0;
	for (int i = 0; i < n; ++i) {
		for (int j = i + 1; j < n; ++j) {
			for (int k = j + 1; k < n; k++) {
				if (solve(a[i], a[j], a[k])) {
					++ret;
				}
			}
		}
	}
	cout << ret << endl;
	return 0;
}


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

int main() {
  int h, w;
  cin >> h >> w;
  vector<vector<char>> v(h,vector<char>(w));
  for(int i=0;i<h;i++){
    for (int j=0;j<w;j++){
      cin>>v.at(i).at(j);
    }
  }
  for(int i=0;i<h;i++){
    int c=0;
    for(int j=0;j<w;j++){
      if(v.at(i).at(j)=='#'){
        c++;
      }
    }
    if(c==0){
      for(int j=0;j<w;j++){
        v.at(i).at(j)=' ';
      }
    }
  }
  for(int j=0;j<w;j++){
    int c=0;
    for(int l=0;l<h;l++){
      if(v.at(l).at(j)=='#'){
        c++;
      }
    }
    if(c==0){
      for(int l=0;l<h;l++){
        v.at(l).at(j)=' ';
      }
    }
  }
  for(int m=0;m<h;m++){
    int count=0;
    for(int p=0;p<w;p++){
      if(v.at(m).at(p)==' '){
        count++;
      }
    }
    if(count!=w){
      for(int n=0;n<w-1;n++){
      if(v.at(m).at(n)=='#'){
         cout<<"#";
      }
      else if(v.at(m).at(n)=='.'){
        cout<<".";
      }
    }
    if(v.at(m).at(w-1)=='#'){
         cout<<"#"<<endl;
    }
    else if(v.at(m).at(w-1)=='.'){
        cout<<"."<<endl;
    }
    else if(v.at(m).at(w-1)==' '){
      cout<<endl;
    }
    }
  }
}


Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main(void){
    // Your code here!
    int a,b,c,ans=0;
    cin>>a>>b>>c;
    
    for (int i=a;i<=b;i++){
        if (c%i==0){
            ans=ans+1;
        }
    }
    cout<<ans<<endl;
    return 0;
}



Measured memory_bytes: 3112
#include <bits/stdc++.h>
typedef long long ll;

using namespace std;

const ll inf=1000000007;

inline int read()
{
    int x=0,f=1;
    char ch=getchar();
    while(ch<'0'||ch>'9')
    {
        if(ch=='-')
            f=-1;
        ch=getchar();
    }
    while(ch>='0'&&ch<='9')
    {
        x=(x<<1)+(x<<3)+(ch^48);
        ch=getchar();
    }
    return x*f;
}

int main()
{
    string s, t;
    cin >> s >> t;
    int ans=inf;
    for(int i=0;i+t.length()-1<s.length();i++)
    {
        int p=0;
        for(int j=i;j<i+t.length();j++)
        {
            if(s[j]!=t[j-i])
            {
                p++;
            }
        }
        ans=min(ans,p);
    }
    cout << ans << endl;
    return 0;
}


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

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

	vector<int> a( N );
	vector<int> b( N );

	for( int i = 0; i < N; ++i ) {
		cin >> a.at( i );
	}

	int count = 0;
	int push = 0;

	for( ;; ) {
		count++;
		b.at( push ) += 1;

		push = a.at( push ) - 1;

		if( push == 1 ) {
			break;
		}
		else if( b.at(push) > 1 ) {
			count = -1;
			break;
		}
	}

	cout << count << endl;
}


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

//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())
//repetition
//------------------------------------------
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
//conversion
//------------------------------------------
inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}

//debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;
//math
//-------------------------------------------
template<class T> inline T sqr(T x) {return x*x;}

typedef long long LL;
const LL mod=1000000007;
#define MAX 10000
#define NIL -1
const double PI  = acos(-1.0);
const int INF = 1e9 + 7;
//-------------------------------------------


int main(){

    cin.tie(0);
    ios::sync_with_stdio(false);

    string s;
    cin >> s;

    if( s[0] == s[1] || s[0] == s[2] || s[2] == s[1]){
        cout << "No" << endl;
    }
    else{
        cout << "Yes" << endl;
    }

    return 0;
}


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

int n,m,a[505][505];
struct st{
    int x1,y1,x2,y2;
};

vector<st> b;
void f(st p){
    a[p.x2][p.y2]++;
    b.push_back(p);
}

int main() {
    int i,j,k;
    cin>>n>>m;
    for(i=1;i<=n;i++){
        for(j=1;j<=m;j++){
            cin>>a[i][j];
        }
    }
    for(i=1;i<=n;i++){
        for(j=1;j<=m;j++){
            if(a[i][j]%2==0 || (i==n && j==m)) continue;
            if(i<n) f({i,j,i+1,j});
            else f({i,j,i,j+1});
        }
    }
    cout<<b.size()<<endl;
    for(i=0;i<b.size();i++){
        cout<<b[i].x1<<" "<<b[i].y1<<" "<<b[i].x2<<" "<<b[i].y2<<endl;
    }
    
}

Measured memory_bytes: 5232
#include<bits/stdc++.h>
#define MAX 301
#define inf 1<<29
#define linf (1e16)
#define eps (1e-8)
#define Eps (1e-12)
#define mod 1000000007
#define pi acos(-1.0)
#define phi (1.0+sqrt(5.0))/2.0
#define f first
#define s second
#define mp make_pair
#define pb push_back
#define all(a) (a).begin(),(a).end()
#define pd(a) printf("%.10f\n",(double)(a))
#define pld(a) printf("%.10Lf\n",(ld)(a))
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define RFOR(i,a,b) for(int i=(a)-1;(b)<=i;i--)
#define Unique(v) v.erase(unique(all(v)),v.end())
#define equals(a,b) (fabs((a)-(b))<eps)
using namespace std;
typedef long double ld;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef pair<int,double> pid;
typedef pair<double,int> pdi;
typedef pair<double,double> pdd;
typedef vector<int> vi;
typedef vector<pii> vpi;

struct edge{ int to,cap,cost,rev; };

int v;
vector<edge> e[MAX];
int h[MAX];
int dist[MAX];
int prevv[MAX],preve[MAX];

void add_edge(int from,int to,int cap,int cost){
  e[from].push_back((edge){to,cap,cost,(int)e[to].size()});
  e[to].push_back((edge){from,0,-cost,(int)e[from].size()-1});
}
 
int min_cost_flow(int s,int t,int f){
  int res=0;
  fill(h,h+v,0);
  fill(prevv,prevv+MAX,0);
  fill(preve,preve+MAX,0);
  while(f>0){
    priority_queue<pii,vector<pii>,greater<pii> > pq;
    fill(dist,dist+v,inf);
    dist[s]=0;
    pq.push(pii(0,s));
    while(pq.size()){
      pii p=pq.top();
      pq.pop();
      int u=p.second;
      if(dist[u]<p.first)continue;
      for(int i=0;i<e[u].size();i++){
        edge &E=e[u][i];
        if(E.cap>0 && dist[E.to]>dist[u]+E.cost+h[u]-h[E.to]){
          dist[E.to]=dist[u]+E.cost+h[u]-h[E.to];
          prevv[E.to]=u;
          preve[E.to]=i;
          pq.push(pii(dist[E.to],E.to));
        }
      }
    }
    if(dist[t]==inf)return -1;
    for(int i=0;i<v;i++)h[i]+=dist[i];
 
    int d=f;
    for(int u=t;u!=s;u=prevv[u]){
      d=min(d,e[prevv[u]][preve[u]].cap);
    }
    f-=d;
    res+=d*h[t];
    for(int u=t;u!=s;u=prevv[u]){
      edge &E=e[prevv[u]][preve[u]];
      E.cap-=d;
      e[u][E.rev].cap+=d;
    }
  }
  return res;
}

int n;
vector<vector<int> > dolls;
int vol[MAX];

void init(){
  dolls.clear();
  FOR(i,0,MAX)e[i].clear();
}

bool containable(vector<int> a,vector<int> b){
  FOR(i,0,3)if(b[i]<=a[i])return false;
  return true;
}

int solve(){
  int sum = 0;
  FOR(i,0,n){
    vol[i] = dolls[i][0]*dolls[i][1]*dolls[i][2];
    sum += vol[i];
  }
  FOR(i,0,n){
    FOR(j,0,n){
      if(i==j)continue;
      if(containable(dolls[i],dolls[j]))add_edge(i,j+n,1,-vol[i]);
    }
  }
  int s=n+n,t=s+1,u=t+1;;
  v = t+2;
  FOR(i,0,n)add_edge(s,i,1,0);
  FOR(i,0,n)add_edge(i+n,t,1,0);
  add_edge(s,u,inf,0);
  add_edge(u,t,inf,0);
  int res = min_cost_flow(s,t,inf);
  return sum+res;
}

int main()
{
  while(cin>>n && n){
    init();
    FOR(i,0,n){
      vector<int> v;
      v.resize(3);
      cin>>v[0]>>v[1]>>v[2];
      sort(all(v));
      dolls.pb(v);
    }
    cout<<solve()<<endl;
  }
  return 0;
}


Measured memory_bytes: 3240
#include <bits/stdc++.h>
using namespace std;
  
#define ll long long
#define all(aaa) aaa.begin(), aaa.end()

const int N = 12;
string s[N];
bool used[N];
int a[N];
int n, m, len = 0;

bool is_pal(string t) {
    for (int i = 0; i < t.size(); i++)
        if (t[i] != t[t.size() - i - 1])
            return false;
    return true;
}

bool rec(int i, int ct) {
    if (ct == n) {
        multiset<string> st;
        for (int j = 0; j < m; j++) {
            string t;
            for (int k = 0; k < n; k++) {
                t.push_back(s[a[k]][j]);
            }
            st.insert(t);
        }
        bool mid = false;
        while (st.size() > 1) {
            string t = *st.begin();
            st.erase(st.begin());
            reverse(all(t));

            if (st.count(t)) {
                st.erase(st.find(t));
            }
            else {
                if (m % 2) {
                    if (mid)
                        return false;
                    if (!is_pal(t))
                        return false;
                    mid = true;
                }
                else {
                    return false;
                }
            }
        }
        if (st.size() == 1)
            return is_pal(*st.begin());
        return true;
    }
    else if (used[i]) {
        if (rec(i + 1, ct))
            return true;
        return false;
    }
    else {
        used[i] = true;
        for (int j = i + 1; j < n; j++) {
            if (!used[j]) {
                used[j] = true;
                a[len] = i;
                a[n - len - 1] = j;
                len++;
                if (rec(i + 1, ct + 2))
                    return true;
                len--;
                used[j] = false;
            }
        }
        used[i] = false;
        return false;
    }
}

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

    cin >> n >> m;

    for (int i = 0; i < n; i++) {
        cin >> s[i];
    }

    if (n % 2) {
        for (int i = 0; i < n; i++) {
            used[i] = true;
            a[n / 2] = i;
            if (rec(0, 1)) {
                cout << "YES\n";
                return 0;
            }
            used[i] = false;
        }
        cout << "NO\n";
    }
    else if (rec(0, 0)) {
        cout << "YES\n";
    }
    else {
        cout << "NO\n";
    }

    return 0;
}

Measured memory_bytes: 256
s=input()
a=int(s[0:2])
b=int(s[2:])
if a>12 or a == 0:
    if b>=1 and b<=12:
        print('YYMM')
    else:
        print('NA')
else:
    if b>=1 and b<=12:
        print('AMBIGUOUS')
    else:
        print('MMYY')

Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
typedef unsigned long long ul;
typedef signed long long ll;
ul over = 1000000007;

int main(void)
{
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << fixed;
  ul n, k;
  cin >> n >> k;
  if (k%2==1) {
    ul ans = (n/k) * (n/k) * (n/k);
    cout << ans << endl;
    return 0;
  }
  ul ans = (n/k) * (n/k) * (n/k);
  ul t = n/(k/2) - n/k;
  ans += t*t*t;
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<cmath>
#include<cstring>
#include<string>
#include<stack>
#include<functional>
#include<queue>
#include<vector>
#include<algorithm>
#include<iomanip>
#include<utility>
#include<chrono>
#include<set>
#include<unordered_set>
#include<map>
#include<unordered_map>
typedef long long int ll;
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,n) for(int i=0;i<signed(n);i++)
#define EREP(i,n) for(int i=1;i<=signed(n);i++)
#define ALL(a) (a).begin(),(a).end()
using namespace std;
//#define EVEL 1
#ifdef EVEL
#define DEB(X) cout << #X <<":" <<X<<" " ;
#define TF(f) f ? cout<<"true  " : cout<<"false ";
#define END cout<<"\n";
#else
#define DEB(X) {}
#define TF(f) {}
#define END {}
#endif
const ll MOD = 1000000007;
const ll INF = 9e14;
typedef std::pair<ll,ll> P;
struct edge{ int to,cost; };
#define VMAX 100000

ll N,M,K;
ll A[100010],B,C,D,X,Y;
ll ans=0;
ll G[100010];
string S,T,U;
ll F[100010];
bool ok=true;
std::queue<ll> Q;
ll Z[]={1,2,3,6,7,8,9,0};

int main(){
    char a;
    cin>>a;
    if(a>='a'&& 'z'>=a)cout<<'a';
    else cout<<'A';
}


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

int main() {
  long long n;
  cin >> n;
  
  for(int i = 1; i < 3501; i++){
    for(int j = i; j < 3501; j++){
      long long now = n * i * j;
      long long c = 4 * i * j - n * i - n * j;
      if(c <= 0) continue;
      if(now % c ) continue;
      cout << i << " " << j << " " << now / c << endl;
      return 0;
    }
  }
}

Measured memory_bytes: 3588
#include <stdio.h>
#include <string.h>
#include <math.h>
#include <stdlib.h>

int main(){
    long long int x,count=0,ans=0;
    scanf("%ld",&x);
    ans = 2 *  (x / 11);
    if(x % 11 == 0){
        printf("%lld",ans);
        return 0;
    }
    if(x % 11 > 6){
        printf("%lld",ans+2);
        return 0;
    }
    else printf("%lld",ans+1);
    return 0;
}

Measured memory_bytes: 128
/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */

/* 
 * File:   main.cpp
 * Author: baisganon
 *
 * Created on 2017/06/04, 17:44
 */

#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;

struct card{
    int num;
    char name;
    bool operator<(const card& right)const{
        return num<right.num;
    }
    bool operator<=(const card& right)const{
        return num<=right.num;
    }bool operator==(const card& right)const{
        return num==right.num&&name==right.name;
    }
};

int partition(card A[],int p,int r){
	card x = A[r];
	int i = p-1;
	for(int j=p;j<r;j++){
		if(A[j]<=x){
			i++;
			card tmp = A[i];
			A[i] = A[j];
			A[j] = tmp;
		}
	}
	card tmp = A[i+1];
	A[i+1] = A[r];
	A[r] = tmp;
	return i+1;
}

void quicksort(card A[],int p,int r){
    if(p>=r)return;
    int q=partition(A,p,r);
    quicksort(A,p,q-1);
    quicksort(A,q+1,r);
}

int main(){
	int size;
	cin >> size;
	card S[size];
        vector<card> V;
	for(int i=0;i<size;i++){
		cin >> S[i].name >> S[i].num;
                V.push_back(S[i]);
	}

	quicksort(S,0,size-1);
        stable_sort(V.begin(),V.end());

        vector<card>::iterator c=V.begin();
        bool isStable=true;
        for(int i=0;i<size;i++){
            if(!(*c==S[i]))isStable=false;
            c++;
        }
        
        cout << (isStable==true?"Stable":"Not stable") <<endl;
	for(int i=0;i<size;i++){
            cout << S[i].name << " " << S[i].num << endl; 
            //if(i!=size-1)cout<<" ";
	}
        int xxx;
        cin >> xxx;
	return 0; 
}

Measured memory_bytes: 4760
x = int(input())
a = 0
while True:
    n = (a**5)-x
    s2 = -1 if n < 0 else 1
    if s2 == -1:
        n = n * -1
    b = n**0.2
    if a**5-(int(b)*s2)**5==x:
        end = 1
        print(a, int(b) * s2)
        break
    a = a+1

Measured memory_bytes: 62364
using System;
using System.Collections.Generic;
using System.Linq;
using System.IO;
using System.Text;
using static System.Math;
using static System.Array;


namespace AtCoder
{
    class AC
    {
        const int mod = 1000000007;
        const int INF = int.MaxValue / 2;
        const long SINF = long.MaxValue / 2;


        static void Main(string[] args)
        {
            //var sw = new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
            //Console.SetOut(sw);
            var cin = new Scanner();
            var p = cin.SplitReader();
            int K = p[1];
            var h = cin.SplitReader();
            Console.WriteLine(h.Count(x => x >= K));

            
            
            //Console.Out.Flush();
        }

        struct Edge
        {
            public int _to;
            public long _distance;

            public Edge(int t, long d)
            {
                _to = t;
                _distance = d;
            }
        }


    }
    public class Scanner
    {
        public int[] SplitReader()
        {
            int[] array = Console.ReadLine().Split().Select(int.Parse).ToArray();
            return array;
        }
        public long[] SplitReaderL()
        {
            long[] array = Console.ReadLine().Split().Select(long.Parse).ToArray();
            return array;
        }
    }

   public static class Tool
        {
            static public void Initialize<T>(ref T[] array, T initialvalue)
            {
                for (var i = 0; i < array.Length; i++)
                {
                    array[i] = initialvalue;
                }
            }
            static public long ModuloP(long value, long mod)
            {
                long r = value % mod;

                if (r * mod < 0)
                {
                    r += mod;
                }
                return r;
            }

        }

   struct Pair<T> : IComparable<Pair<T>> where T : IComparable<T>
   {
        public T variable;
        public int index;

        public Pair(T val, int i)
        {
            variable = val;
            index = i;
        }

        public int CompareTo(Pair<T> otherPair)
        {
            return variable.CompareTo(otherPair.variable);
        }

        public int CompareIndex(Pair<T> otherPair)
        {
            return index.CompareTo(otherPair.index);
        }
   }

    


}






Measured memory_bytes: 17248
#include <iostream>
#include <algorithm>
#include <cmath>

using namespace std ;

int arr [ 100000 ] ;

int main()
{
    int n , cntp = 0 , cntn = 0 ; long long sum = 0 ;
    cin >> n ;
    for ( int i = 0 ; i < n ; i ++ )
    {
        cin >> arr [ i ] ;
        if ( arr [ i ] > 0 )
        {
            cntp ++ ;
            sum += arr [ i ] ;
        }
        else
        {
            cntn ++ ;
            sum -= arr [ i ] ;
        }
    }
    sort ( arr , arr + n ) ;
    if ( cntp && cntn )
    {
        cout << sum << endl ;
        for ( int i = cntn ; i < n - 1 ; i ++ )
        {
            cout << arr [ 0 ] << " " << arr [ i ] << endl ;
            arr [ 0 ] -= arr [ i ] ;
        }
        for ( int i = 0 ; i < cntn ; i ++ )
        {
            cout << arr [ n - 1 ] << " " << arr [ i ] << endl ;
            arr [ n - 1 ] -= arr [ i ] ;
        }
    }
    else if ( cntn == 0 )
    {
        sum -= 2 * arr [ 0 ] ;
        cout << sum << endl ;
        for ( int i = 1 ; i < n - 1 ; i ++ )
        {
            cout << arr [ 0 ] << " " << arr [ i ] << endl ;
            arr [ 0 ] -= arr [ i ] ;
        }
        cout << arr [ n - 1 ] << " " << arr [ 0 ] << endl ;
    }
    else
    {
        sum += 2 * arr [ n - 1 ] ;
        cout <<sum <<endl ;
        for ( int i = 0 ; i < n - 1 ; i ++ )
        {
            cout << arr [ n - 1 ] << " " << arr [ i ] << endl ;
            arr [ n - 1 ] -= arr [ i ] ;
        }
    }


}


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

        int l = (x >= y) ? x:y;
        int s = (x < y) ? y:x;

        int min = Integer.MAX_VALUE;
        int sum;

        //単品
        sum = a*x + b*y;
        min = sum;

        //少ない方全部ハーフピザ＋残り単品
        if(x<=y) {
            sum = c*x*2 + b*(y-x);
        } else {
            sum = c*y*2 + a*(x-y);
        }
        min = sum<min ? sum:min;
        
        //多い方の全部ハーフピザ
        if(x>=y) {
            sum = c*x*2;
        } else {
            sum = c*y*2;
        }

        min = sum<min ? sum:min;

        System.out.println(min);
        

    }
}

Measured memory_bytes: 22996
#include "bits/stdc++.h"
#define FOR(i, a, b) for (int i = a; i < b; i++)
#define mFOR(i, a, b) for (int i = a; i > b; i--)
#define MP make_pair
#define PB push_back
#define ALL(v) v.begin(), v.end()
#define N 100007
#define INF 1000000007
using namespace std;

typedef long long ll;

ll gcd(ll a, ll b) { return b == 0 ? a : gcd(b, a % b); }
ll fceil(ll a, ll b) { return (a % b == 0 ? a / b : a / b + 1); }
int main()
{
   int a, b;
   cin >> a >> b;
   cout << (a - 1) * (b - 1) << endl;
   return 0;
}


Measured memory_bytes: 256
while gets
  l=$_.split.map(&:to_i)
  fj=[1,4,1,4,1,2,1,2]
  max,ans=0,[0]
  8.times do |i|
    count=0
    8.times do |j|
      count+=[fj[j],l[j]].min
    end
    fj.rotate!(1)
    if count > max
      max = count
      ans = [i]
    elsif count == max
      ans << i
    end
  end
  if ans.size > 1
    mnum = []
    ans.each do |a|
      mnum << fj.rotate(a).join.to_i
    end
    puts "#{fj.rotate(ans[mnum.index(mnum.min)]).join(" ")}"
  else
    puts "#{fj.rotate(ans[0]).join(" ")}"
  end
end

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

		int M1 = sc.nextInt();
		int D1 = sc.nextInt();
		int M2 = sc.nextInt();
		int D2 = sc.nextInt();
		if( D2==1 ){
			System.out.println("1");
		}else{
			System.out.println("0");
		}
	}
}


Measured memory_bytes: 22996
import math

X = int(input())

serach_number = 100003

def sieve_of_eratosthenes(target):
    dest = int(math.sqrt(target))
    target_list = list(range(2, target + 1))
    prime_list = []

    while True:
        num_min = min(target_list)
        if num_min >= dest:
            prime_list.extend(target_list)
            break
        prime_list.append(num_min)

        i = 0

        while True:
            if i >= len(target_list):
                break
            elif target_list[i] % num_min == 0:
                target_list.pop(i)
            i += 1

    for i in range(10**5):
        if prime_list[i] < X:
            continue
        elif prime_list[i] >= X:
            print(prime_list[i])
            break

sieve_of_eratosthenes(serach_number)

Measured memory_bytes: 6900
import sys

n, k = map(int, input().split())
h_list = list(map(int, input().split()))

cost = [sys.maxsize] * n
cost[0] = 0

for i in range(n-1):
    for j in range(1, k+1):
        if i+j < n:
            diff = int(abs(h_list[i] - h_list[i+j]))
            cost[i+j] = min(cost[i]+diff, cost[i+j])
print(cost[n-1])

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

using namespace std;

#define all(x) x.begin(), x.end()
typedef vector<int> vi;
typedef pair<int,int> ii;
typedef long long ll;

const ll inf = 3e18 + 5;

const int MAXN = 1 << 19;
int N = 400000;
int seg[2 * MAXN], A[MAXN];
typedef vector<vi> vvi;

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

    int a,b,h;
    cin >> a >> b >> h;
    cout << (a+b)*h/2;
    
}

Measured memory_bytes: 256
#include<stdio.h>
int main()
{
  char s[3];
  scanf("%s",s);
  if(s[1] == 'B')
  {
    printf("ARC\n");
  }
  else if(s[1] == 'R')
  {
     printf("ABC\n");
  }
  return 0;
}


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

using namespace std;
#define ll long long


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

    ll a,v,b,w,t;
    cin>>a>>v>>b>>w>>t;

    if( a< b)
    {
        if((a + v*t) >= (b + w*t))
            cout<<"YES"<<endl;
        else
            cout<<"NO"<<endl;
    }
    else
    {
        if( (a- v*t) <= (b - w*t) )
            cout<<"YES"<<endl;
        else
            cout<<"NO"<<endl;
    }
    return 0;
}


Measured memory_bytes: 3648
#include "bits/stdc++.h"
using namespace std;
int main(){
  int a,b,c;
  cin >> a >> b >> c;
  for (int i=a;i<=(a*b);i+=a){
    if(i%b == c){
      cout << "YES";
      return 0;
    }
  }
  cout << "NO";
}


Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <utility>
#include <string>
#include <algorithm>
#include <map>
#include <vector>
#include <climits>
#include <numeric>
#include<stdio.h>
#include <queue>
#include <iomanip>
#include <float.h>
#include <set>
#include<functional>
#include <stack>
#include <time.h>
#include <climits>
#include <bitset>
#include <fstream>
using namespace std;
typedef pair<long long,long long>p;
long long gcd(long long a, long long b) {
	if (b == 0) return a;
	return gcd(b, a % b);
}
vector<long long> divisor(long long n) {
	vector< long long> ret;
	for (long long i = 1; i * i <= n; i++) {
		if (n % i == 0) {
			ret.push_back(i);
			if (i * i != n) ret.push_back(n / i);
		}
	}
	sort(begin(ret), end(ret));
	return (ret);
}
long long mod = 1e9 + 7;
signed main()
{
	cin.tie(0);
	ios::sync_with_stdio(false);
	int n, k;
	cin >> n >> k;
	string s;
	cin >> s;
	s[k - 1] = tolower(s[k - 1]);
	cout << s;
}

Measured memory_bytes: 256
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>

using namespace std;

const int Maxn=100000+10;
int n,a[Maxn];

int main()
{
    for ( ; scanf("%d",&n)!=EOF; )
    {
        for (int i=1; i<=n; i++) scanf("%d",&a[i]);
        sort(a+1,a+n+1);
        int ans=0,p=1;
        for (int i=2; i<=n; i++) if (a[i]==a[i-1]) p++; else
        {
            if (p%2==1) ans++;
            p=1;
        }
        if (p%2==1) ans++;
        printf("%d\n",ans);
    }
    return 0;
}


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

using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
#define a first
#define b second
#define sz(x) (ll)((x).size())
#define pb push_back
#define mp make_pair 
#define bg begin()
#define ed end()
#define all(x) (x).bg,(x).ed
#define rep(i,n) for(ll i=0;i<n;i++)
#define rep1(i,n) for(ll i=1;i<=n;i++)

int main(){
	ll N; cin>>N;
	ll ans=0;
	set<P> B;
	set<P,greater<P>> R;

	//赤(y大きい順)
	rep(i,N){
		ll x,y; cin>>x>>y;
		R.insert(mp(y,x));
	}

	//青(x小さい順)
	rep(i,N){
		ll x,y; cin>>x>>y;
		B.insert(mp(x,y));
	}

	for(auto itr=B.bg;itr!=B.ed;itr++){
		ll x=(*itr).a,y=(*itr).b;
		for(auto it=R.bg;it!=R.ed;it++){
			ll rx=(*it).b,ry=(*it).a;
			if(ry<y && rx<x){
				ans++;
				R.erase(it);
				break;
			}
		}
	}
	cout<<ans;
}

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

#define ll long long int
void fast()
{
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
}
double dp[3001][3001];
bool vis[3001][3001];
double go(ll n,vector<double> &v,ll t=0,ll h=0)
{
	if(vis[t][h])
	return dp[t][h];
	vis[t][h]=true;
	if(h+t==n)
	{
		if(h<=t)
		return dp[t][h]=0;
		else
		return dp[t][h]=1;
	}
	
	if(n<0)
	return dp[t][h]=0;
	return dp[t][h]=(double)(v[h+t]*go(n,v,t,h+1))+(double)(1-v[h+t])*go(n,v,t+1,h);
}
int main()
{
	fast();
	ll n;
	cin>>n;
	vector<double> v(n);
	memset(vis,false,sizeof(vis));
	for(auto &i:v)
	cin>>i;
	cout<<fixed<<setprecision(11)<<go(n,v);
}

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

template < typename Container, typename Value = typename Container::value_type, std::enable_if_t<!std::is_same< Container, std::string >::value, std::nullptr_t> = nullptr>
std::istream& operator>> (std::istream& is, Container& v)
  { for (auto & x : v) { is >> x; } return is; }

template < typename Container, typename Value = typename Container::value_type, std::enable_if_t<!std::is_same< Container, std::string >::value, std::nullptr_t> = nullptr >
std::ostream& operator<< (std::ostream& os, Container const& v) {
 os << "{";
  for (auto it = v.begin(); it != v.end(); it++)
    {os << (it != v.begin() ? "," : "") << *it;}
  return os << "}";
}

int main() {
  std::cin.tie(0); std::cin.sync_with_stdio(false);
  constexpr long long linf = 1LL << 60;
  int n, m; std::cin >> n >> m;
  auto N = 1 << n;
  std::vector< lint > dp(N, linf);
  dp.at(0) = 0;
  loop(m) {
    int a, b; std::cin >> a >> b;
    auto cs = 0;
    loop(b) {
      int x; std::cin >> x;
      x--;
      cs |= 1 << x;
      for (auto i = N - 1; i >= 0; i--) {
        if (dp.at(i) != linf)
          { cmn(dp.at(i | cs), dp.at(i) + a); }
      }
    }
    // debug(dp);
  }
  auto ret = dp.back();
  if (ret == linf)
    { ret = -1; }
  std::cout << ret << std::endl;
  return 0;
}


Measured memory_bytes: 384
#include <iostream>
#include <iomanip>
using namespace std;
typedef long long ll;
int main() {
	ll a, n, min, max, sum;
	min = 1000005;
	max = -1000005;
	sum=0;
	cin>> a;
	for (int i=0; i<a; i++) {
		cin>> n;
		if(n > max)
            max=n;
        if(n < min)
            min=n;
        sum= sum + n;
    }	
    cout << min << " " << max << " " << sum <<endl;
    return 0;
}


Measured memory_bytes: 3100
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
ll n,q,c,up,low,t,x,y,arr[4],a,b;
double ff;
bool f;

int main()
{
    cin >> a >> b;
    if (b>=a)
        cout << 1 << endl;
    else
    {
        ff=(a*1.0)/b;
        x=a/b;
        if (ff>x)
            cout << x+1 << endl;
        else
            cout << x << endl;
    }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define pb push_back
#define SZ(x) ((int)(x.size()))
#define FOR(i,s,n) for (ll i = (s); (i) < (n); ++i)
#define FORD(i,s,l) for (ll i = (s); (i) >= l; --i)
#define F first
#define S second
#define TC int __tc; cin >> __tc; FOR(case_num,1,__tc+1)
#define TEST(x,i) ((x)&(1ll<<(i)))
#define SET(x,i) ((x)|(1ll<<(i)))
#define FLIP(x,i) ((x)^(1ll<<(i)))
#define CLEAR(x,i) ((x)&~(1ll<<(i)))

const double pi = 4 * atan(1);
using namespace std;
typedef long long ll;

const ll MOD = 1000000007;
const int MAXN = 200005;


int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	
	int n;
	cin >> n;
	
	ll p = 1;
	for (int i = 1; i <= n/2; i++) {
		p = (p*2)%MOD;
	}
	
	map<int,int> expected;
	for (int i = 0; i< n; i++) {
		expected[llabs(i - (n-i-1))]++;
	}
	
	map<int,int> found;
	while(n--) {
		int x;
		cin >> x;
		found[x]++;
	}
	
	cout << ((expected == found) ?  p : 0) << "\n";	

}


Measured memory_bytes: 8900
n=int(input())
a=[0]+list(map(int,input().split()))
from itertools import accumulate
from collections import defaultdict
acc=list(accumulate(a))
d=defaultdict(int)
for i in acc:
    d[i]+=1

ans=0
for k in d.keys():
    ans+=d[k]*(d[k]-1)//2
print(ans)

Measured memory_bytes: 114424
#include <bits/stdc++.h>
#define ll long long
#define pb push_back
#define f first
#define s second
using namespace std;

int main(){
   int n;
   ll res = 0;
  	cin >> n;
  	for(int i = 1; i <= n; i++){
  	 	int x; cin >> x;
  	 	if(x&1)continue;
  	 	int cnt = 0;
  	 	while(x > 0){
  	 	 	if(x&1)break;
  	 	 	cnt++;
  	 	 	x/=2;
  	 	}
  	 	res += cnt;
  	}
  	cout << res << endl;
   return 0;
}                  


Measured memory_bytes: 3624
#include<iostream>
#include<iomanip>
#include<string>
#include<vector>
#include<algorithm>
#include<utility>
#include<tuple>
#include<map>
#include<queue>
#include<set>
#include<stack>
#include<numeric>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>

using namespace std;

using ll = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;

#define BIL ((ll)1e9)
#define MOD ((ll)1e9+7)
#define INF (1LL<<60)           //1LL<<63でオーバーフロー
#define inf (1<<29)             //1<<29でオーバーフロー

int main(int argc,char* argv[]){
    cin.tie(0);
    ios::sync_with_stdio(0);
    cout << fixed << setprecision(20);

    int n;
    cin >> n;

    vector<pii> d(n);
    for(auto &x:d){
        cin >> x.first >> x.second;
    }

    bool ans=false;
    for(int i=0;i<n-2;i++){
        if(d[i].first==d[i].second && d[i+1].first==d[i+1].second && d[i+2].first==d[i+2].second)
            ans=true;
    }

    if(ans)cout << "Yes" << endl;
    else cout << "No" << endl;

    return 0;
}


Measured memory_bytes: 3648
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

var sc *bufio.Scanner = func() *bufio.Scanner {
	sc := bufio.NewScanner(os.Stdin)
	sc.Split(bufio.ScanWords)
	return sc
}()

func nextInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}
func nextInts(n int) []int {
	ints := make([]int, n)
	for i := 0; i < n; i++ {
		ints[i] = nextInt()
	}
	return ints
}
func sum(takoyakis []int) (total int) {
	n := len(takoyakis)
	for i := 0; i < n; i++ {
		for j := 0; j < n; j++ {
			if j <= i {
				continue
			}
			total += takoyakis[i] * takoyakis[j]
		}
	}
	return
}

func main() {
	n := nextInt()
	ints := nextInts(n)
	total := sum(ints)
	fmt.Println(total)
}


Measured memory_bytes: 640
#include <iostream>
using namespace std;
int main(void) {
	int N,D,X;
	int count = 0;
	cin >> N >> D >> X;
	for (int i = 0;i < N;i++) {
		int A;
		cin >> A;
		for (int j = 1;j <= D;j += A)
			count++;
	}
	cout << count + X << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
#define pb push_back
#define mp make_pair
using namespace std;
const int maxbit = 50;
const int maxn = 100100;
ll cnt[maxbit], n, k;
ll arr[maxn];

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cin>>n>>k;
    ll result = 0LL, sumb = 0LL;
    for(int i=1;i<=n;i++) {
        cin>>arr[i];
        result += arr[i];
        for(ll j=0LL;j<=45;j++) {
            if((1LL<<j)&arr[i]) {
                cnt[j]++;
            }
        }
        sumb += (arr[i] ^ k);
    }
    result = max(result, sumb);
    for(ll i=45LL;i>=0LL;i--) {
        // if i is one
        // make this one -> zero
        // on right keep all ones, on left fill optimaly

        if(!(k&(1LL<<i))) continue;
        ll temp = (1LL << i) * cnt[i];
        for(ll j=45LL;j>i;j--) {
            if(k&(1LL<<j)) {
                temp += (1LL << j) * (n - cnt[j]);
            }
            else {
                temp += (1LL << j) * cnt[j];
            }
        }
        for(ll j=i-1;j>=0LL;j--) {
            ll curr = (1LL << j) * max(cnt[j], n - cnt[j]);
            temp += curr;
        }
        result = max(result, temp);
    }
    cout<<result<<"\n";
    return 0;
}

Measured memory_bytes: 1024
<?php
  
  list($n, $m) = explode(' ', trim(fgets(STDIN)));

  $o = 0;
  $c = 0;
  $ac = [];
  for($i=0; $i<$m; $i++){
    
    list($p, $s) = explode(' ', trim(fgets(STDIN)));  
    
    if (isset($ac[$p]) && $ac[$p] == 'a'){
      
      continue;
      
    } else if ($s == "WA"){
      
      if (isset($ac[$p])) {
        $ac[$p]++;
      } else {
        $ac[$p] = 1;
      }
      
    } else if ($s == "AC"){
      
      $c++;
      if (isset($ac[$p])) $o += $ac[$p];
      $ac[$p] = 'a';
      
    }
    
  }


  echo $c;
  echo " ";
  echo $o;
  
  
?>

Measured memory_bytes: 13048
#66c
n = int(input())
a_list = [int(e) for e in input().split()]

#空の数列 b に対して、以下の操作を n回行うことを考えます。
#i回目には数列の i番目の要素 ai を bの末尾に追加する。
#bを逆向きに並び替える。

#愚直解
#b = []
#for i in range(n): #n 2 * 10**5
#    b.append(a_list[i])
#    b = b[::-1]
#print(b)

#高速解
b = []

#for i in range(0,n,2):
#    b.append(a_list[n-1-i])

b = [a_list[n-1-i] for i in range(0,n,2)]
#print(b)

if n%2==0:
    #for i in range(0,n//2,1):
    #    b.append(a_list[i*2])
    after_b = [a_list[i*2] for i in range(0,n//2,1)]
else:
    #for i in range(0,n//2,1):
    #    b.append(a_list[i*2+1])
    after_b = [a_list[i*2+1] for i in range(0,n//2,1)]
    
print(' '.join(map(str, b + after_b)))

Measured memory_bytes: 31300
#include <iostream>
#include <cmath>

using namespace std;

int X;

int ipow(int b, int p) {
    int r = 1;
    for (int i = 0; i < p;) {
        if (p > 2 * i) {
            r *= r;
            i += r;
        } else {
            r *= b;
            i += 1;
        }
    }
    return r;
}

int main() {
    cin >> X;
    int b = (int)sqrt(X);
    int p = 2;
    int m = 1;
    for (; b > 1; b--) {
        while (true) {
            int tmp = ipow(b, p);
            if (tmp <= X) {
                m = tmp > m ? tmp : m;
                p++;
            } else {
                p--;
                break;
            }
        }
    }
    cout << m << endl;
}

Measured memory_bytes: 888
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <list>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <stack>
#include <bitset>
#include <typeinfo>
#include <functional>
using namespace std;

#define INF 1000000
#define REP(i,n) for(int i=0;i<(int)n;++i)

#ifdef _MSC_VER
#define FOR(i,c) for(auto i=(c).begin();i!=(c).end();++i)
#else
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)
#endif

#define ALL(c) (c).begin(), (c).end()



int main()
{
	//char a[100], b[100], c[100];

	string abc[3];
	cin >> abc[0] >> abc[1] >> abc[2];
	int id[3];
	int len[3];
	int num = 0;
	for (int i = 0; i < 3; i++){
		id[i] = 0;
		len[i] = abc[i].size();
	}

	while (1){
		if (len[num] == id[num]){
			if (num == 0){
				cout << "A" << endl;
			}
			else if (num == 1){
				cout << "B" << endl;
			}
			else{
				cout << "C" << endl;
			}
			break;
		}
		id[num]++;
		num = abc[num].at(id[num]-1) - 'a';

	}

	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include<vector>
using namespace std;
bool vis[100005];
vector<long long>v[100050];

void dfs(long long x)
{
	int i;
	vis[x]=true;
	for(i=0;i<v[x].size();i++)
	{
		if (vis[v[x][i]]==false)dfs(v[x][i]);
	}
}
int main()
{
	long long a, b, n,k,i,s=0;
	cin >>n>>k;
	for(i=0;i<k;i++)
	{
		cin>>a>>b;
		v[a].push_back(b);
		v[b].push_back(a);
	}
	for(i=1;i<=n;i++)
	{
		if (vis[i]==false)
		{
			s++;
			dfs(i);
		}
	}
	cout<<s-1;

}

Measured memory_bytes: 10408
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<ll, ll>;
const ll INF = 100000000;
#define rep1(i, n) for (ll i=0; i<(n); i++) 
#define rep2(i, k, n) for (ll i=k; i<(n); i++)
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 main() {
    ll n;
    cin >> n;
    vector<ll> d(n, 0);
    rep1(i, n) cin >> d[i];
    sort(d.begin(), d.end());
    ll ans = d[n/2] - d[n/2-1];
    cout << ans << endl;
}

Measured memory_bytes: 4032
"use strict"

function main(input) {
    let nums = input.split(' ')
    nums = nums.map(x => +x)//reduce( (x, y) => x - y , 0 )
    nums.sort().reverse()
    //let fst = nums.shift()
    //nums.unshift(0)

    // 0 + (3 - 6 ) + (1 - 3) 
    // 0 3(-6 = 3) 1() 
    // 6 + 3 + 1 - ( 3 + 2 ) = 9 - 6
    let num = 0;
    //let num = nums.reduce((prev, curr) => (curr - prev ),0) //+ nums[0]
    for (let i=0; i<nums.length;i++) {
        let red = (i >= 1) ? nums[i - 1] : 0
        num += Math.abs(nums[i] - red)

        //console.log(num, nums[i], red)
    }
    num -= nums[0]
    console.log(num)
}
main(require('fs').readFileSync('/dev/stdin', 'utf8'));


Measured memory_bytes: 11468
#include <iostream>
#include <algorithm>
using namespace std;
#define N 100000


int main(void){
    int numTeam , i;
    long long ans = 0;
    int a[3 * N];
    cin >> numTeam;

    for (i = 0; i < 3 * numTeam; i++) cin >> a[i];

    sort(a, a + 3 * numTeam, greater<int>());
    for(int j = 0; j < numTeam; ++j){
        ans += a[2*j + 1];
        // cout << "the process of ans is " << ans << endl;
    }

    cout << ans << endl;
}

Measured memory_bytes: 1408
/*input
5
0.42 0.01 0.42 0.99 0.42
*/
#include <bits/stdc++.h>
using namespace std;

#define pb push_back
#define f first
#define s second
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define int long long
int const mod = 1e9+7;
int power(int x, int y, int mod = 2e18){ int ans = 1;x %= mod;while(y){if(y&1)ans = (x * ans) % mod;x = (x * x) % mod;y >>= 1;}return ans;}
int gcd(int a , int b){if(a==0)return b;return gcd(b%a,a);}
double a[3001];
double dp[3001][3001];
int n;
double solve(int i,int h){
	if(i==n){
		int h1 ;
		if(n%2==0)
			h1 = n/2;
		else
			h1 = (n-1)/2;
		if(h>h1){
			return 1;
		}
		else
			return 0;
	}
	if(dp[i][h]>-1)
		return dp[i][h];
	return dp[i][h] = a[i]*solve(i+1,h+1) + (1-a[i])*solve(i+1,h); 
}
signed main() {
	IOS;
	cin>>n;
	for(int i=0;i<n;i++)cin>>a[i];
	memset(dp,-2,sizeof(dp));
	cout<<setprecision(9);
	cout<<solve(0,0);
return 0;
}

Measured memory_bytes: 70784
#pragma GCC optimize("Ofast","unroll-loops","omit-frame-pointer","inline") //Optimization flags
#pragma GCC option("arch=native","tune=native","no-zero-upper") //Enable AVX
#pragma GCC target("avx2") //Enable AVX

#include <bits/stdc++.h>

using namespace std;

#define db(x) cout << (x) << '\n';
#define all(x) x.begin(),x.end()
#define UNIQUE(x) sort(all(x)),x.resize(unique(all(x))-x.begin())
#define LB(v,x) lower_bound(all(v),x)
#define UB(v,x) upper_bound(all(v),x)
#define endl "\n"
#define F first
#define S second
#define PB push_back
#define PF push_front
#define int long long
#define double long double
#define trick int m = (l+r)>>1,lc=n<<1,rc=lc|1

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

int dy[]={0,1,1,1,0,-1,-1,-1};
int dx[]={-1,-1,0,1,1,1,0,-1};
const int maxn = 1e5;
const int OO = 1e18;
const int mod = 1e9 + 7;
const double PI = acos(-1);

void maxself(int &a,int b)
{a=max(a,b);}
void minself(int &a,int b)
{a=min(a,b);}


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

    int t;
    t = 1;
    while(t--)
    {
        string s;
        cin >> s;
        int sum = 0;
        for(int i=0;i<s.size();i++)
            sum+=s[i]-'0',sum%=9;
        if(sum==0)
            cout << "Yes";
        else
            cout << "No";
    }

	return 0;
}



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

bool ball[100001];
int N,M;
int size[100001];

int main()
{
  cin>>N>>M;
  ball[1]=true;
  for (int i=1;i<=N;i++)
    size[i]=1;
  for (int i=0;i<M;i++){
    int X,Y;
    cin>>X>>Y;
    if (ball[X]){
      ball[Y]=true;
      if (size[X]==1)
	ball[X]=false;
    }
    size[X]--;
    size[Y]++;
  }
  int ans=0;
  for (int i=1;i<=N;i++)
    if (ball[i])
      ans++;
  cout<<ans<<endl;
}


Measured memory_bytes: 768
use std::io;
use std::str::FromStr;


fn naive(xs : &Vec<i32>) -> i32 {
  let n = xs.len();
  let mut ans = (xs[0] - xs[1]).abs();
  for i in 0..n {
    for j in 0..i {
      ans = std::cmp::max(ans, (xs[i] - xs[j]).abs());
    }
  }
  ans
}

fn solve(xs : &Vec<i32>) -> i32 {
  xs.iter().max().unwrap().clone() - xs.iter().min().unwrap().clone()
}

fn main() {
  let _ : i32 = read();
  let xs : Vec<i32> = reads();
  assert_eq!(naive(&xs), solve(&xs));
  println!("{}", solve(&xs));
}


#[allow(dead_code)]
fn read<T>() -> T where T : FromStr {
  let mut ln = String::new();
  io::stdin().read_line(&mut ln).ok();
  ln.trim().parse().ok().unwrap()
}

#[allow(dead_code)]
fn reads<T>() -> Vec<T> where T : FromStr {
  let mut ln = String::new();
  io::stdin().read_line(&mut ln).ok();
  ln.trim().split_whitespace().map(|x| x.parse().ok().unwrap()).collect()
}



Measured memory_bytes: 4352
N = int(input())
S = [input() for _ in range(N)]

a = 0
b = 0
a_b = 0

for s in S:
    if s[-1] == "A" and s[0] == "B":
        a_b += 1
    elif s[-1] == "A":
        a += 1
    elif s[0] == "B":
        b += 1

ans = 0
if a_b > 0:
    ans += a_b - 1
    if a > 0:
        ans += 1
        a -= 1
    if b > 0:
        ans += 1
        b -= 1

ans += min(a,b)

for line in S:
    for i in range(len(line)-1):
        if (line[i],line[i+1]) == ("A","B"):
            ans += 1
print(ans)

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

int main(){
  int N;
  cin >> N;
  
  vector<int> A(N-1);
  for(int i=0; i<N-1; i++) cin >> A.at(i);
  
  vector<int> ans(N, 0);
  for(int i=0; i<N-1; i++){
    ans.at(A.at(i)-1)++;
  }
  
  for(int i=0; i<N; i++){
    cout << ans.at(i) << endl;
  }
}
  

Measured memory_bytes: 4820
N=int(input())

A=list(map(int,input().split()))

o=0

for i in range(N):
    if A[i]<0:
        o+=1

for i in range(N):
    if A[i]<0:
        A[i]=A[i]*(-1)

if o%2==0:
    print(sum(A))
else:
    A.sort()
    print(sum(A)-A[0]*2)
    
    

Measured memory_bytes: 14224