akhauriyash/Code-Regression huggingface dataset:
#include <iostream>


enum{
  LOSE,
  DRAW,
  WIN,
};


int strlen (char *str) {
  int len = 0;
  while (*str != '\0') {
    str++;
    len++;
  }
  return len;
}


int strcmp(char *s, char *p, int size) {
  int ascii_sub;
  bool sb, pb;
  for (int i = 0; i < size; i ++) {
    ascii_sub = (int)s[i] - (int)p[i];
    if (ascii_sub > 0) return WIN;
    else if (ascii_sub < 0) return LOSE;
    sb = s[i] == '\0';
    pb = p[i] == '\0'; 
    if (sb || pb) {
      if (sb && !pb)  return LOSE;
      else if (!pb && sb) return WIN;
      else return DRAW;

    }

  }
  return DRAW;
}


int main() {
  int n, length;
  char taro[101], hanako[101];
  int taro_point = 0, hanako_point = 0;
  int result;
  std::cin >> n;
  for (int i = 0; i < n; i ++) {
    std::cin >> taro >> hanako;
    result = strcmp(taro, hanako, 100);
    taro_point += result == WIN ? 3 : result;
    hanako_point += result == LOSE ? 3 : (result % 2);
    //std::cout << taro << " " << hanako << " " << result << "\n";
  }
  std::cout << taro_point << " " << hanako_point << std::endl;
  return 0;
}



Measured memory_bytes: 3052
#include <algorithm>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <iostream>
#include <vector>
#include <string>
#include <stack>
#include <queue>
#include <map>
#include <set>

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

using namespace std;

typedef long long ll;

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

  long long n, a, b;
  cin >> n >> a >> b;
  vector<long long> x(n);

  rep(i, n) { cin >> x[i]; }

  long long ans = 0;
  rep(i, n-1) {
    ans += min( abs(x[i]-x[i+1])*a, b );
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
int main()
{
    long long int i,j,k,l,m,n,total_vote=0,flag=0;;
    cin>>n>>m;
    vector<long long int>v,v1;
    for(i=0;i<n;i++)
    {
        cin>>k;
        v.push_back(k);
        total_vote+=k;
    }
    sort(v.begin(),v.end());
    for(i=0;i<m;i++)
    {
        if(v[n-1-i]*4*m<total_vote)
        {
            flag=1;
            break;
        }
    }
    if(flag==0)
    {
        cout<<"Yes"<<endl;
    }
    else
    {
        cout<<"No"<<endl;
    }
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <map>
#include <algorithm>
#include <cmath>
#include <string>
#include <iomanip>
#include <deque>
#include <queue>
#include <stack>
#include <set>
#include <complex>
#include <ctime>


using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef int itn;
const ll LINF = 1e18;
const int INF = 1e9;

//マクロ定義
#define vvint(vec,n,m,l) vector<vector<int>> vec(n, vector<int>(m,l));	// lで初期化
#define vvll(vec,n,m,l) vector<vector<ll>> vec(n,vector<ll>(m,l));
#define vint vector<int>
#define pint pair<int,int>
#define rep(i,a) for(ll i=0;i<(a);i++)
#define all(x) (x).begin(),(x).end()
#define debug system("pause")				//デバッグ用
#define ret return 0

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

using Graph = vector<vector<ll>>;

#define ketasitei setprecision(15) //15桁表示

const ll MOD = 1000000007;
const double PI = 3.1415926535897932;


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

	ll x, n;
	cin >> x >> n;
	map<ll, ll> p;
	ll tmp = 0;
	rep(i, n)
	{
		cin >> tmp;
		p[tmp]++;
	}
	ll ans = 0;
	ll dis = INF;
	for (int i = 0; i <= 101; i++)
	{
		if (p[i] > 0)
		{
			continue;
		}
		else
		{
			ll h = abs(i - x);
			if (h < dis)
				ans = i;
			dis = min(dis, h);
		}
	}
	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 3616
#include <cstdio>
#include <cstring>
#include <iostream>
#include <algorithm>
#define MAXN 200002
#define LL long long
using namespace std;
LL a,b,c,d,t1,t2;
int main()
{
    cin>>t1>>t2>>a>>b>>c>>d;
    
    LL A=(a-c)*t1;
    LL B=A+(b-d)*t2;
    
    if(B==0)
    {
        printf("infinity\n");
    }
    else if((B>0&&A>0)||(B<0&&A<0))
    {
        cout<<0<<endl;
    }
    else
    {
        cout<<-(A/B)*2+(A%B!=0)<<endl;
    }
    
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main()
{
    string s, t;
    int ans = 1000, count;
    cin >> s >> t;
    for (int i = 0; i <= s.size() - t.size(); i++) {
        count = 0;
        for (int j = 0; j < t.size(); j++) {
            if (s[i+j] != t[j]) count++;
        }
        if (ans > count) ans = count;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3636
#include <iostream>
using namespace std;
int main()
{
int a;
cin>>a;
int b=a/100;
int c=(a/10)%10;
int d=a%10;
int count=0;
if(b==1)
count++;
if(c==1)
count++;
if(d==1)
count++;
cout<<count;
return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
 
#define FLASH cin.tie(0); cout.tie(0); ios_base::sync_with_stdio(false);
#define pb push_back
#define int long long
#define fr(i,a,b) for(int i=a;i<b;i++)
#define mod 1000000007
#define FILEIO  freopen("C:\\Users\\sourav\\Documents\\cp files\\input.txt", "r", stdin); freopen("C:\\Users\\sourav\\Documents\\cp files\\output.txt", "w", stdout); 
#define maxn 1000000
 
using namespace __gnu_pbds;
using namespace std;
 
typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update>ordered_set;


signed main()
{
	
 	FLASH
 	int n;
 	cin>>n;
 	int arr[n];
 	for (int i = 0; i < n; ++i)
 			{
 				/* code */
 				cin>>arr[i];
 			}		
 			int dp[n];
 			dp[0] = 0;
 			dp[1] = abs(arr[1] - arr[0]);
 			for(int i = 2; i < n; i++)
 			{
 				dp[i] = min(dp[i - 1] + abs(arr[i] - arr[i - 1]) , dp[i - 2] + abs(arr[i]-arr[i - 2])); 
 			}
 			cout<<dp[n - 1];
}

Measured memory_bytes: 1792
N = int(input())
A_ = input().split()
A = [int(i) for i in A_]

S = 0
a = A[0]
for i in range(len(A)-1):
    if a > A[i+1]:
        S += a-A[i+1]
    else:
        a = A[i+1]
print(S)

Measured memory_bytes: 32108
#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#include <vector>
#include <cstring>
#include <queue>
#include <string>
#include <algorithm>
#include <set>
using namespace std;
string s;

int main(){
    cin >> s;
    int n = s.length();
    long long ans = 0, na = 0;
    for(int i = 0; i < n - 1; i++){
        if(s[i] == 'A'){
            na++;
        }
        else if(s[i] == 'B' && s[i + 1] == 'C'){
            ans += na;
            i++;
        }
        else{
            na = 0;
        }
    }
    cout << ans;
    return 0;
}


Measured memory_bytes: 640
import java.io.*;
class Main
{
    public static void main(String args[])throws IOException
    {
	BufferedReader input=new BufferedReader(new InputStreamReader(System.in));
	String str;
	while(true)
	    {
		str=input.readLine();
		int a[]=new int[2];
		String ary[]=str.split(" ");
		if(ary[0].equals("0") && ary[1].equals("0"))break;
		for(int i=0;i<2;i++)
		    {
			a[i]=Integer.parseInt(ary[i]);
		    }
		int day=0,j=31,f=29+j,mr=31+f,ap=30+mr,my=31+ap,jn=30+my,jl=31+jn,au=31+jl,s=30+au,o=31+s,n=30+o;
		switch(a[0])
		    {
		    case 1:
			day=a[1];
			break;
		    case 2:
			day=j+a[1];
			break;
		    case 3:
			day=f+a[1];
			break;
		    case 4:
			day=mr+a[1];
			break;
		    case 5:
			day=ap+a[1];
			break;
		    case 6:
			day=my+a[1];
			break;
		    case 7:
			day=jn+a[1];
			break;
		    case 8:
			day=jl+a[1];
			break;
		    case 9:
			day=au+a[1];
			break;
		    case 10:
			day=s+a[1];
			break;
		    case 11:
			day=o+a[1];
			break;
		    case 12:
			day=n+a[1];
			break;
		    }
		if(day%7==1)System.out.println("Thursday");
		else if(day%7==2)System.out.println("Friday");
		else if(day%7==3)System.out.println("Saturday");
		else if(day%7==4)System.out.println("Sunday");
		else if(day%7==5)System.out.println("Monday");
		else if(day%7==6)System.out.println("Tuesday");
		else if(day%7==0)System.out.println("Wednesday");
		
	    }
    }
}

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

bool is_prime(int n){
  if(n <= 1)
    return false;

  for(int i=2;i*i<=n;i++){
    if(n%i == 0)
      return false;
  }
  return true;
}

int main(){
    int n;

    bool is_prime[1000000];
    is_prime[0] = is_prime[1] = false;
    for(int i=2; i<1000000;i++){
      is_prime[i] = true;
    }
    for(int i=2; i*i<1000000; i++){
      if(is_prime[i]){
        for(int j=i*i;j<1000000; j+=i){
          is_prime[j] = false;
        }
      }
    }

    int n_prime[1000000];

    int cnt = 0;
    for(int i=0;i<1000000;i++){
      if(is_prime[i]){
        cnt++;
      }
      n_prime[i] = cnt;
    }

    while(1){
      int primen;
      cin >> n;
      if(cin.eof())
        break;

      for(int i=n-1;;i--){
        if(is_prime[i]){
          cout << i << ' ';
          break;
        }
      }

      for(int i=n+1;;i++){
        if(is_prime[i]){
          cout << i << endl;
          break;
        }
      }
    }

}



Measured memory_bytes: 4044
#include <bits/stdc++.h>
#include <ctime>
#include <sstream>
#define weewoo ios::sync_with_stdio(false);cin.tie(0)
#define pii pair<int,int>
#define pll pair<ll,ll>
#define ld long double
#define ll long long
#define se second
#define fi first
#define ctoi(x) (x-'0')
#define pi (acos(-1))
#define llputin(a,n) for(int i=0;i<n;i++){ll x;cin >> x;a.push_back(x);}
#define iputin(a,n) for(int i=0;i<n;i++){int x;cin >> x;a.push_back(x);}

#define MOD ((ll) 1e9 + (ll) 7)
using namespace std;

ll pw(ll x,ll a){
    if(a==0)
        return 1;
    ll t = pw(x,a/2);
    if(a%2==0)
        return(t*t);
    else
        return(t*t*x);
}

bool prime(int x)
{
    if(x < 2) return false;
        for(int i=2; i<= sqrt(x); i++) {
            if ((x%i) == 0) return false;
    }
    return true;
}

bool cmp(const pair<int , int> &a , const pair<int , int> &b){
    return (a.first < b.first);
}

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



int main()
{
    weewoo;
    ll n;
    cin >> n;
    for(int i=1;i<=9;i++){
        if(n%i==0 && n/i <=9)
            return cout <<"Yes",0;
    }
    cout << "No" << endl;
    return 0;
}


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

#define each(i, c) for (auto& i : c)

typedef long long ll;
typedef unsigned long long ull;
const ll MOD = 1e9+7;

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

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

  ll ans = 0;
  each (i, a) {
    ans += (i - 1);
  }

  cout << ans << endl;

  return 0;
}

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

typedef long long ll;

int
main(void)
{

  int numSwitch; cin >> numSwitch;
  int numElec; cin >> numElec;
  vector<int> conditions[numElec];
  int p[numElec];
  rep(i, 0, numElec){
    int tmp; cin >> tmp;
    rep(j, 0, tmp){
      int x;
      cin >> x; --x;
      conditions[i].push_back(x);
    }
  }

  rep(i, 0, numElec) cin >> p[i];
  
  int ans = 0;
  for(int bit = 0; bit < (1 << numSwitch); bit++){
    int lightings = 0;
    rep(i, 0, numElec){
      int count = 0;
      for(auto x: conditions[i]){
        if(bit & (1 << x)) count++;
      }
      if(count % 2 == p[i]) lightings++;
    }
    if(lightings == numElec) ans++;
  }

  cout << ans << endl;

  return 0;
}


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

int main() {
	ll X;
  	cin>>X;
  	int flag=0;
  	int a,b;
  	rep(i,1000){
     	for(int j=-1000;j<1000;j++){
         	 if(pow(i,5)-pow(j,5)==X) {
              	 flag=1;
               	 a=i,b=j;
               	 break;
             }
        }
      	if(flag) break;
    }
  	
  	cout<<a<<" "<<b<<endl;
}

Measured memory_bytes: 4020
#define _USE_MATH_DEFINES

#include <cstdio>
#include <cstdlib>
#include <iostream>
#include <cmath>
#include <cstring>
#include <algorithm>
#include <vector>
#include <queue>
#include <map>
#include <unordered_map>

using namespace std;

typedef pair<long long int, long long int> P;

long long int INF = 1e18;
long long int MOD = 1e9 + 7;

int main(){
    string s;
    cin >> s;
    s += "D";
    vector<int> v;
    int i = 0;
    for(i = 0; i < s.size() - 1; i++){
        if(s[i] == 'A'){
            v.push_back(1);
        }else if(s[i] == 'B' && s[i + 1] == 'C'){
            v.push_back(2);
            i += 1;
        }else{
            v.push_back(0);
        }
    }
    long long int ans = 0;
    long long int cnt1 = 0, cnt2 = 0;
    for(int num : v){
        if(num == 1){
            cnt1 += 1;
        }else if(num == 2){
            cnt2 += 1;
            ans += cnt1;
        }else{
            cnt1 = cnt2 = 0;
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 1532
#include<iostream>
#include<algorithm>

using namespace std;

int main(){

  int Ai,Am,As,Ae;
  int Bi,Bm,Bs,Be;

  int S,T;

  cin >> Ai >> Am >> As >> Ae >> Bi >>Bm >> Bs >> Be;

  S=Ai+Am+As+Ae;
  T=Bi+Bm+Bs+Be;

  if(S>=T){
    cout << S << endl;
  }
  else{
    cout << T << endl;
  }
  
  return 0;
}

Measured memory_bytes: 3104
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define ll long long
#define fi first
#define se second
#define pb push_back
#define rep(i, s, n) for (int i = s; i < n; i++)
#define rrep(i, s, n) for (int i = (n)-1; i >= (s); i--)
#define all(a) a.begin(),a.end()
typedef pair<int,int>pint;
typedef vector<int>vint;
typedef vector<pint>vpint;
const long long MOD = 1000000007, INF = 1e17;
 
#define endl '\n'
#define IOS() ios_base::sync_with_stdio(0);cin.tie(0)
 
template<class T>inline bool chmax(T& a,T b){if(a<b){a=b;return true;}return false;}
template<class T>inline bool chmin(T& a,T b){if(a>b){a=b;return true;}return false;}
 
template<typename T>vector<T>
make_v(size_t a){return vector<T>(a);}
template<typename T,typename... Ts>
auto make_v(size_t a,Ts... ts){
	return vector<decltype(make_v<T>(ts...))>(a,make_v<T>(ts...));
}
template<typename T,typename V>
typename enable_if<is_class<T>::value==0>::type
fill_v(T &t,const V &v){t=v;}
template<typename T,typename V>
typename enable_if<is_class<T>::value!=0>::type
fill_v(T &t,const V &v){
	for(auto &e:t) fill_v(e,v);
}

int A,B,C,D,E,F,G,N,M,R,Q,X,Y,Z;
string s,t;

signed main()
{
	IOS();
	cin>>A>>B;
	if(A>=13)cout<<B<<endl;
	else if(A>=6)cout<<B/2<<endl;
	else cout<<0<<endl;
}

Measured memory_bytes: 764
import java.util.*;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int a = sc.nextInt(), b = sc.nextInt(), c = sc.nextInt(), d = sc.nextInt();
    System.out.println((Math.abs(a - c) <= d || Math.abs(a - b) <= d && Math.abs(b - c) <= d) ? "Yes" : "No");
  }
}

Measured memory_bytes: 21844
import java.util.Scanner;
 
public class Main {
	static int[][] land(int[][] f,int h,int w,int hh,int ww){
		f[h][w]=0;
		for(int i=-1;i<2;i++) {
			for(int j=-1;j<2;j++) {
				if(i==-1 && h==0)continue;
				if(j==-1 && w==0)continue;
				if(i==1 && h==hh-1)continue;
				if(j==1 && w==ww-1)continue;
				
				if(f[h+i][w+j]==1) {
					land(f,h+i,w+j,hh,ww);
				}
			}
		}
		
		return f;
	}
	
    public static void main(String[] args) {
        try(Scanner sc = new Scanner(System.in)){
        	while(sc.hasNext()) {
        		int w = sc.nextInt();
        		int h = sc.nextInt();
        		if(w+h==0)break;
        		int[][] f = new int[h+1][w+1];
        		for(int i=0;i<h;i++) {
        			for(int j=0;j<w;j++) {
        				f[i][j] = sc.nextInt();
        			}
        		}
        		
        		int cnt = 0;
        		for(int i=0;i<h;i++) {
        			for(int j=0;j<w;j++) {
        				if(f[i][j]==1) {
        					cnt++;
        					land(f,i,j,h,w);	//land関数で１つの島につき１一つに纏める
        					f[i][j]=1;
        				}
        			}
        		}
        		
        		System.out.println(cnt);
        	}
        }
    }
}





Measured memory_bytes: 44296
#include <iostream>
#include <sstream>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <string>
#include <vector>
#include <list>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <bitset>
#include <numeric>
#include <climits>
#include <cfloat>
using namespace std;

double const EPS = 1.0e-10;

class Point
{
public:
    double y, x;
    Point(){
        y = x = 0.0;
    }
    Point(double y0, double x0){
        y = y0;
        x = x0;
    }
    double dot(const Point& p) const{
        return y * p.y + x * p.x; // |a|*|b|*cosÆ
    }
    double cross(const Point& p) const{
        return x * p.y - y * p.x; // |a|*|b|*sinÆ
    }
    Point operator+(const Point& p) const{
        return Point(y + p.y, x + p.x);
    }
    Point operator-(const Point& p) const{
        return Point(y - p.y, x - p.x);
    }
    Point operator*(double a) const{
        return Point(y * a, x * a);
    }
    Point operator/(double a) const{
        return Point(y / a, x / a);
    }
};

class Line
{
public:
    double a, b, c; // a*x + b*y + c = 0
    Line(double a0, double b0, double c0){
        a = a0;
        b = b0;
        c = c0;
    }
    Line(const Point& p1, const Point& p2){
        double dy = p2.y - p1.y;
        double dx = p2.x - p1.x;
        if(abs(dy / dx) < EPS){
            a = 0.0;
            b = 1.0;
            c = -p1.y;
        }else if(abs(dx / dy) < EPS){
            a = 1.0;
            b = 0.0;
            c = -p1.x;
        }else{
            a = - dy / dx;
            b = 1.0;
            c = dy / dx * p1.x - p1.y;
        }
    }
};

vector<Point> circleLineIntersection(const Point& p, double r, const Line& l)
{
    double s = l.a * p.x + l.b * p.y + l.c;
    double t = (l.a*l.a + l.b*l.b) * r*r - s*s;

    if(t < -EPS)
        return vector<Point>(0);
    if(t < EPS)
        return vector<Point>(1, Point(l.b, l.a) * (-s / (l.a*l.a + l.b*l.b)) + p);

    vector<Point> ret(2, Point(l.a, -l.b) * sqrt(t));
    ret[1] = ret[1] * -1;
    for(int i=0; i<2; ++i)
        ret[i] = (ret[i] - Point(l.b, l.a) * s) / (l.a*l.a + l.b*l.b) + p;
    return ret;
}

int main()
{
    for(;;){
        int n;
        cin >> n;
        if(n == 0)
            return 0;

        vector<Point> center(n);
        vector<double> r(n);
        for(int i=0; i<n; ++i)
            cin >> center[i].x >> center[i].y >> r[i];

        int m;
        cin >> m;

        while(--m >= 0){
            Point p1, p2;
            cin >> p1.x >> p1.y >> p2.x >> p2.y;
            Line l(p1, p2);

            bool safe = false;
            for(int i=0; i<n; ++i){
                vector<Point> p = circleLineIntersection(center[i], r[i], l);
                for(unsigned j=0; j<p.size(); ++j){
                    if(min(p1.y, p2.y) - EPS < p[j].y && p[j].y < max(p1.y, p2.y) + EPS
                           && min(p1.x, p2.x) - EPS < p[j].x && p[j].x < max(p1.x, p2.x) + EPS)
                        safe = true;
                }
            }

            if(safe)
                cout << "Safe" << endl;
            else
                cout << "Danger" << endl;
        }
    }
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
#define F(i, a, b) for (int i = (a); i < (b); ++i)
#define F2(i, a, b) for (int i = (a); i <= (b); ++i)
#define dF(i, a, b) for (int i = (a); i > (b); --i)
#define dF2(i, a, b) for (int i = (a); i >= (b); --i)
using namespace std;
typedef long long LL;
int main() {
    int n,d,x,y;
    scanf("%d%d%d", &n, &d, &x);
    F(i, 0, n) {
        scanf("%d", &y);
        x += (d-1)/y+1;
    }
    printf("%d\n", x);
    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>

int main( void ) {
	int n, y, m, d, tmp;

	scanf( "%d", &n );

	while ( n-- ) {
		scanf( "%d %d %d", &y, &m, &d );

		tmp = 0;
		tmp += ( y - 1 ) / 3 * 590;
		tmp += ( y - 1 ) % 3 * 195;
		if ( y % 3 ) {
			tmp += ( m - 1 ) / 2 * 39;
			if ( ( m - 1 ) % 2 )
				tmp += 20;
		} else 
			tmp += ( m - 1 ) * 20;
		tmp += d - 1;

		printf( "%d\n", 196470 - tmp );
	}

	return 0;
}

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

using namespace std;

typedef long long int ll;

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

  int n;
  cin >> n;
  ll ans = 0;
  for (int i = 1; i <= n; i++) {
    ans += ((ll)i * (i + 1)) / 2;
  }

  for (int i = 0; i < n - 1; i++) {
    int u, v;
    cin >> u >> v;
    if (u > v) swap (u, v);
    ans -= ((ll)u * (n - v + 1));
  }

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


Measured memory_bytes: 3636
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using ll = long long;
int main() {
  string s;
  cin >> s;
  int n = s.size();
  int cnt = 0;
  if(n % 2 != 0){
    rep(i,(n-1)/2){
      if(s.at(i) != s.at(n-1-i)) cnt++;
    }
  }else{
    rep(i,n/2){
      if(s.at(i) != s.at(n-1-i)) cnt++;
    }
  }
  cout << cnt << endl;
  }


Measured memory_bytes: 256
import java.util.*;
public class Main{
 
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        int n = in.nextInt();
        int[] r = new int[n];
        boolean[] b = new boolean[n];
        
        for(int i= 0; i < n; i++) {
            r[i] = in.nextInt() - 1;
        }
        
        int ans = 0;
        
        for(int i = 0; i < n; i++) {
            if(!b[i] && i == r[r[i]]) {
                b[i] = b[r[i]] = true;
                ans++;
            }
        }
        
        System.out.println(ans);
    }
}

Measured memory_bytes: 50224
#include <bits/stdc++.h>
using namespace std;
#define min(a,b) ((a)<(b)?(a):(b))
#define max(a,b) ((a)>(b)?(a):(b))
#define REP(i,n) for(ll i=0;i<n;i++)
#define FOR(i,n1,n2) for(ll i=n1;i<n2;i++)
#define bFOR(i,n1,n2) for(ll i=n1;i>=n2;i--)
#define speed_up    ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);

typedef long long int ll;
typedef pair<ll,ll> Pi;
typedef tuple<ll,ll,ll> Tu;
const int INF=(ll)(1LL<<30)-1;
const double INFd=100000000000.0;
const ll INFl=(ll)9223372036854775807;
const int MAX=10000;
const ll MOD=(ll)1e9+7;
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b){return a/gcd(a, b)*b;}
int dx[4]={0,-1,0,1},dy[4]={-1,0,1,0};
int mdx[8]={0,1,0,-1,1,1,-1,-1},mdy[8]={-1,0,1,0,1,-1,1,-1};


template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
    std::fill( (T*)array, (T*)(array+N), val );
}

ll n,m;
vector<ll> ab[100100];

int main(){
	cin>>n>>m;
	REP(i,n){
		ll a,b;
		cin>>a>>b;
		//each_max[a]=max(each_max[a],b);
		ab[a].push_back(b);
	}
	/*for(ll i=1;i<=n;i++){
		sort(ab[i].begin(),ab[i].end(),greater<ll>());
	}*/
	ll ans=0;
	//ll t=-1,s=-1;
	multiset<ll> m1;
	for(ll i=1;i<=m;i++){
		/*cout<<i<<endl;
		cout<<ab[i].size()<<endl;*/
		if(ab[i].size()!=0){
			for(ll j=0;j<ab[i].size();j++){
				m1.insert(ab[i][j]);
			}
		}
		if(m1.size()){
		ans+=*m1.rbegin();
		m1.erase(--m1.end());
		}
		//cout<<i<<endl;
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 8192
#include<stdio.h>
#include<algorithm>
using namespace std;
int t[110][110];
int main(){
	int a,b,c;scanf("%d%d%d",&a,&b,&c);
	for(int i=0;i<c;i++){
		int p,q,r;scanf("%d%d%d",&p,&q,&r);
		if(r==1){
			for(int j=0;j<p;j++)for(int k=0;k<b;k++)t[j][k]=1;
		}
		if(r==2){
			for(int j=p;j<a;j++)for(int k=0;k<b;k++)t[j][k]=1;
		}
		if(r==3){
			for(int j=0;j<a;j++)for(int k=0;k<q;k++)t[j][k]=1;
		}
		if(r==4){
			for(int j=0;j<a;j++)for(int k=q;k<b;k++)t[j][k]=1;
		}
	}
	
	int ret=0;
	for(int i=0;i<a;i++)for(int j=0;j<b;j++)if(t[i][j]==0)ret++;
	printf("%d\n",ret);
}

Measured memory_bytes: 256
#include<iostream>
#include<iomanip>
#include<math.h>
#include<algorithm>
#include<string>
#include<vector>
#include<queue>
#include<stack>
#include<set>
#include<map>
#define REP(i, N) for(ll i = 0; i < N; ++i)
#define FOR(i, a, b) for(ll i = a; i < b; ++i)
#define ALL(a) (a).begin(),(a).end()
#define pb push_back
#define INF (long long)1000000000
#define MOD 1000000007
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};

int main(void) {
	int H, W;
	cin>>H>>W;
	vector<string> a(H);
	REP(i, H) cin>>a[i];
	REP(i, W + 2) cout<<'#';
	cout<<endl;
	REP(i, H) {
		cout<<'#';
		cout<<a[i];
		cout<<'#'<<endl;
	}
	REP(i, W + 2) cout<<'#';
	cout<<endl;
}

Measured memory_bytes: 256
//{
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef double lf;
typedef pair<ll,ll> ii;
#define REP(i,n) for(ll i=0;i<n;i++)
#define REP1(i,n) for(ll i=1;i<=n;i++)
#define FILL(i,n) memset(i,n,sizeof i)
#define X first
#define Y second
#define SZ(_a) (int)_a.size()
#define ALL(_a) _a.begin(),_a.end()
#define pb push_back
#ifdef brian
#define debug(...) do{\
    fprintf(stderr,"%s - %d (%s) = ",__PRETTY_FUNCTION__,__LINE__,#__VA_ARGS__);\
    _do(__VA_ARGS__);\
}while(0)
template<typename T>void _do(T &&_x){cerr<<_x<<endl;}
template<typename T,typename ...S> void _do(T &&_x,S &&..._t){cerr<<_x<<" ,";_do(_t...);}
template<typename _a,typename _b> ostream& operator << (ostream &_s,const pair<_a,_b> &_p){return _s<<"("<<_p.X<<","<<_p.Y<<")";}
template<typename It> ostream& _OUTC(ostream &_s,It _ita,It _itb)
{
    _s<<"{";
    for(It _it=_ita;_it!=_itb;_it++)
    {
        _s<<(_it==_ita?"":",")<<*_it;
    }
    _s<<"}";
    return _s;
}
template<typename _a> ostream &operator << (ostream &_s,vector<_a> &_c){return _OUTC(_s,ALL(_c));}
template<typename _a> ostream &operator << (ostream &_s,set<_a> &_c){return _OUTC(_s,ALL(_c));}
template<typename _a,typename _b> ostream &operator << (ostream &_s,map<_a,_b> &_c){return _OUTC(_s,ALL(_c));}
template<typename _t> void pary(_t _a,_t _b){_OUTC(cerr,_a,_b);cerr<<endl;}
#define IOS()
#else
#define debug(...)
#define pary(...)
#define endl '\n'
#define IOS() ios_base::sync_with_stdio(0);cin.tie(0);
#endif // brian
//}


const ll MAXn=1e5+5,MAXlg=__lg(MAXn)+2;
const ll MOD=1000000007;
const ll INF=ll(1e15);

int main()
{
    IOS();
    ll t = 0;
    string s;
    cin>>s;
    for(char c:s)if(c=='+')t++;else t--;
    cout<<t<<endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
int main() {
  int n;
  long long k;
  cin >> n >> k;
  vector<int> a(n), f(n);
  for (int i = 0; i < n; ++i) {
    cin >> a.at(i);
  }
  for (int i = 0; i < n; ++i) {
    cin >> f.at(i);
  }
  sort(a.begin(), a.end());
  sort(f.rbegin(), f.rend());
  long long l = -1, r = 1e12;
  while (l + 1 < r) {
    long long m = (l + r) / 2;
    long long s = 0;
    for (int i = 0; i < n; ++i) {
      s += max(0ll, a.at(i) - m / f.at(i));
    }
    if (s <= k) r = m;
    else l = m;
  }
  cout << r << endl;
  return 0;
}

Measured memory_bytes: 1792
#include <iostream>
#include <cstdio>
#include <string.h>
#include <map>
#include <algorithm>
using namespace std;

int s[100005];
int ss[100005];

int main()
{
   	int n, m;
   	cin >> n >> m;
   	for (int i = 0; i < m; i++) {
   		cin >> s[i];	
	}
   	sort(s, s+m);
   	for (int i = 0; i < m-1; i++) {
   		ss[i] = s[i+1]-s[i];	
	}
   	sort(ss, ss+m-1);
   	long long sum = 0;
   	for (int i = 0; i < m-n; i++) {
   		sum += ss[i];	
	}
   	cout << sum;
   	
	return 0;
}


Measured memory_bytes: 1024
# coding:utf-8

def main():
    A,B = map(int,input().split())
    ans = 0
    if A > B:
        ans += A
        A -= 1
    else:
        ans += B
        B -= 1
    if A > B:
        ans += A
        A -= 1
    else:
        ans += B
        B -= 1
    print(ans)

if __name__ == "__main__":
    main()

Measured memory_bytes: 2940
s=input()
x,y=map(int,input().split())
xx,yy=[],[]
w=[0,0]
ans=chk=0
f=0
for i in s:
    if f==0 and i=='F':
        w[0]+=1
    elif f==0 and i=='T':
        f=1
    elif f==1 and i=='F':
        chk+=1
    elif f==1 and i=='T':
        yy.append(chk)
        chk=0
        f=2
    elif f==2 and i=='F':
        chk+=1
    elif f==2 and i=='T':
        xx.append(chk)
        chk=0
        f=1
if chk and f==1:
    yy.append(chk)
elif chk and f==2:
    xx.append(chk)
xx.sort()
yy.sort()
for i in xx[::-1]:
    if w[0]<=x:
        w[0]+=i
    else:
        w[0]-=i
for i in yy[::-1]:
    if w[1]<=y:
        w[1]+=i
    else:
        w[1]-=i
print("Yes" if w[0]==x and w[1]==y else "No")

Measured memory_bytes: 40688
a,b=map(int,input().split())
ans=str()
cnt=0
if a==b:
    while(cnt<b):
        ans+=str(b)
        cnt+=1
    print(ans)
    exit()

elif a>b:
    while(cnt<a):
       ans+=str(b)
       cnt+=1
    print(ans)
    exit()

else:
    while(cnt<b):
        ans+=str(a)
        cnt+=1
    print(ans)
    exit()

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

int diff(string a,string b){
    int ans=0;
    rep(i,a.size())if(a[i]!=b[i])++ans;
    return ans;
}

int main(){
    string S,T;
    cin>>S>>T;
    
    int ans=INT_MAX;
    rep(i,S.size()-T.size()+1)ans=min(ans,diff(S.substr(i,T.size()),T));
    
    cout<<ans<<endl;
}


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

int minRemovals(int n, vector<int> &a) {
	int ans=0;
	unordered_map<int, int> freq;
	for(int i=0; i<n; i++)
		freq[a[i]]++;
	for(auto m: freq) {
		int a=m.first, b=m.second;
		if(b<a) ans+=b;
		else ans+=b-a;
	}
	return ans;
}

signed main() {
	// your code goes here
	int n, input;
	cin>>n;
	vector<int> a;
	for(int i=0; i<n; i++) {
		cin>>input;
		a.push_back(input);
	}
	cout<<minRemovals(n, a);
	return 0;
}

Measured memory_bytes: 4980
#include "bits/stdc++.h"
#ifndef err
#define err(...)(void)0
#endif
using namespace std;
using ll = long long;
using ull = decltype(1ull);
template<class T>int size(T&&a) { return a.size(); }
#define REP(t,a)for(typename make_signed<decltype(a.second)>::type t=a.first,_l##t=a.second;t<_l##t;t++)
#define RREP(t,a)for(typename make_signed<decltype(a.second)>::type t=a.second-1,_l##t=a.first;t>=_l##t;t--)
template<class B>pair<int, B>make_pair(B b) { return{ 0,b }; }
#define rep(t,...)REP(t,make_pair(__VA_ARGS__))
#define rrep(t,...)RREP(t,make_pair(__VA_ARGS__))
#define all(a)begin(a),end(a)
#define rall(a)a.rbegin(),a.rend()

void Calc();
int main() {
  ios::sync_with_stdio(false);
  cin.tie(nullptr); cin.exceptions(istream::failbit | istream::badbit);
  cout << fixed << setprecision(15); Calc(); cout.flush(); return 0;
}
template<class A>void amax(A&a, A b) { a = max(a, b); }
template<class A>void amin(A&a, A b) { a = min(a, b); }
struct Scanner {
  template<class A = string>A Next() { A a; cin >> a; return a; }
  template<class A = int>vector<A>Array(int n) { vector<A>a(n); for (A&i : a) cin >> i; return a; }
  string Line() const { string s; getline(cin, s); return s; }
  template<class A>Scanner&operator,(A&a) { a = Next<A>(); return *this; }
  template<class A>operator A() { return Next<A>(); }
}in;

/*---------------------------------------------------------------------*/


void Calc() {

  ll n = in;
  const int INF = 1e9 - 1;

  int ans = INF;
  rep(j, 1, (int)sqrt(n) + 100) {
    if (n % j == 0) {
      amin(ans, (int)max(to_string(j).size(), to_string(n / j).size()));
    }
  }
  cout << (ans) << endl;

}


Measured memory_bytes: 256
#pragma GCC optimize("Ofast")

#include <algorithm>      //sort,二分探索,など
#include <bitset>         //固定長bit集合
#include <cmath>          //pow,logなど
#include <complex>        //複素数
#include <deque>          //両端アクセスのキュー
#include <functional>     //sortのgreater
#include <iomanip>        //setprecision(浮動小数点の出力の誤差)
#include <iostream>       //入出力
#include <iterator>       //集合演算(積集合,和集合,差集合など)
#include <map>            //map(辞書)
#include <numeric>        //iota(整数列の生成),gcdとlcm(c++17)
#include <queue>          //キュー
#include <set>            //集合
#include <stack>          //スタック
#include <string>         //文字列
#include <unordered_map>  //イテレータあるけど順序保持しないmap
#include <unordered_set>  //イテレータあるけど順序保持しないset
#include <utility>        //pair
#include <vector>         //可変長配列
#include <list>           //双方向連結リスト

using namespace std;

constexpr int INF = numeric_limits<int>::max();

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

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

    int x = a[n-1];
    int i = -1;
    for(int j = 0; j < n - 1; ++j){
        if(a[j] <= x){
            ++i;
            swap(a[i], a[j]);
        }
    }
    swap(a[i+1], a[n-1]);
    ++i;
    for(int k = 0; k < i; ++k){
        cout << a[k] << " ";
    }
    cout << "[" << a[i] << "]";
    for(int k = i + 1; k < n; ++k){
        if(k != 0) cout << " ";
        cout << a[k];
    }
    cout << "\n";

	return 0;
}


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

// @@ !! LIM()

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

  ll R; cin >> R;
  cout << M_PI * R * 2.0 << endl;

  return 0;
}



Measured memory_bytes: 3792
#include <bits/stdc++.h>
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
// const bool debug=true;
const bool debug=false;
#define DEBUG if(debug==true)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
const ll MOD = 1000000007;

int main(void) {
    string s;cin>>s;
    ll cnt[3]={};
    rep(i,s.size()){
        cnt[s.at(i)-'a']++;
    }
    ll a=cnt[0],b=cnt[0];
    rep(i,3){
        a=max(a,cnt[i]);
        b=min(b,cnt[i]);
    }
    cout << (a-b>1 ? "NO" : "YES") << endl;
    return 0;
}


Measured memory_bytes: 512
#include<bits/stdc++.h>
#define mod 1000000007
#define fr first
#define se second
#define ll long long
#define PI 3.1415926535 
#define pb push_back
#define mpr make_pair
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define senky_bansal ios_base::sync_with_stdio(false);
#define IIIT_ALLAHABAD    cin.tie(NULL);cout.tie(NULL);
using namespace std;
ll fac[2000005];
ll power(ll a,ll b){ll res=1;while(b){if(b&1) res=(res*a)%mod;a=(a*a)%mod;b=b/2;}return res%mod;}
ll ncr(ll n,ll r){return ((fac[n]*power(fac[r],mod-2))%mod*power(fac[n-r],mod-2))%mod;}
void pre(){fac[0]=1;fac[1]=1;for(int i=2;i<2000005;i++)fac[i]=(i*fac[i-1])%mod;}
signed main()
{   

      senky_bansal
      IIIT_ALLAHABAD
      
      ll t;
     // cin>>t;
      t=1;
      while(t--)
      {
          ll n;
        cin>>n;
        string s;
        cin>>s;
        string p1 = s.substr(0,n/2);
        string p2=s.substr(n/2,n/2);
        if(p1==p2 && n%2==0) cout<<"Yes";
        else cout<<"No";
          
          
      }
 

}


















Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long int
#define mk make_pair
#define pb push_back
#define pf push_front
#define fi first
#define se second
#define mod 1000000007
using namespace std;

void fast(){
    ios_base::sync_with_stdio(0);
    cin.tie(0);cout.tie(0);
}

int main(){
    fast();
    ll t=1;
//    cin>>t;
    while(t--){
    	ll n,x,t;
    	cin>>n>>x>>t;
    	ll val=(n+x-1)/x;
    	cout<<val*t;
	}
}

Measured memory_bytes: 3636
from sys import exit, stdin

S = list(stdin.readline().rstrip())
ls = len(S)

candidates = []
for i in range(ls-1):
    if S[i] == 'R' and S[i+1] == 'L':
        candidates.append(i)
lc = len(candidates)

ans = [0 for _ in S]

for i in range(lc):
    l_index, r_index = candidates[i], candidates[i]+1

    while l_index > 0 and S[l_index - 1] == 'R':
        l_index -= 1
    while r_index + 1 < ls and S[r_index + 1] == 'L':
        r_index += 1

    even, odd = 0, 0
    idx = candidates[i]

    for j in range(l_index, idx):
        if (idx-j) % 2 == 0:
            even += 1
        else:
            odd += 1
    for j in range(idx, r_index+1):
        if (j-idx) % 2 == 0:
            even += 1
        else:
            odd += 1
    
    ans[idx] += even
    ans[idx+1] += odd

print(*ans)

Measured memory_bytes: 55928
def acinput():
    return list(map(int, input().split(" ")))



import numpy as np
#from functools import reduce
import math
import string
import itertools
import fractions
import heapq
import collections
import re
import array
import bisect
import sys
import random
import time
import copy
import functools

S,T=input().split()
A,B=acinput()
U=input()

d={}
d[S]=A
d[T]=B
d[U]-=1
print(d[S],d[T])



Measured memory_bytes: 14152
class UnionFindTree():
    # Union find tree
    # 2つの効率化　経路圧縮、ランク
    # つなげることはできるか分離することはできないので、木をつなげる方向に利用する
    # 
    def __init__(self, node_size):
        # node_num: 全体のノード数
        # parent: ノードがrootなら-1、親がいれば親の番号を入れる
        # size:
        # rank:  
        # self.parent =[-1] * node_size
        self.parent =[x for x in range(node_size)]
        self.node_size = node_size
        self.size = [1] * node_size
        self.rank = [1] * node_size

        # self.node_list = np.array([x for x in range(node_size)])
        self.member_dict = {}
    
    def find_root(self,node):
        # node属する木のrootを探す
        # たどった経路に含まれるnodeの親をrootにつなぎ替える
        if self.parent[node] == node:             # 自身がrootの場合
            root = node
        else:                                   # 自身がrootでない場合
            root = self.find_root(self.parent[node]) # 再帰的にrootを探す
            self.parent[node] = root            # たどった経路に含まれるnodeの親をrootにつなぎ替える(経路圧縮)
        return root

    def unite(self,node0, node1):
        # node0とnode1が含まれる木を結合する
        
        #node0 node1のrootを求める
        root_node0 = self.find_root(node0) 
        root_node1 = self.find_root(node1)

        if root_node0 != root_node1:
            # rankを比較しrankが小さい方の木を大きい方の木のrootにつなげる
            # rank is sameのときのみrankが増える

            # node1のグループをnode0のグループに結合
            if self.rank[root_node0] == self.rank[root_node1]: # rank is same
                self.parent[root_node1] = root_node0
                self.rank[root_node0] += 1
                self.size[root_node0] += self.size[root_node1]

            # node1のグループをnode0のグループに結合
            elif self.rank[root_node0] > self.rank[root_node1]:
                self.parent[root_node1] = root_node0
                self.size[root_node0] += self.size[root_node1]

            # node0のグループをnode1のグループに結合
            else:
                self.parent[root_node0] = root_node1
                self.size[root_node1] += self.size[root_node0]

    def same(self,node0,node1):
        #同じグループか確かめる
        return self.find_root(node0)==self.find_root(node1)




N,K,L = map(int,input().split())

road_uft = UnionFindTree(N)
train_uft = UnionFindTree(N)

for _ in range(K):
    p,q = map(int,input().split())
    p -=1
    q -=1
    road_uft.unite(p,q)

for _ in range(L):
    r,s = map(int,input().split())
    r-=1
    s-=1
    train_uft.unite(r,s)


pair_dict = {}
pair_list = []
for i in range(N):
    road_root = road_uft.find_root(i)
    train_root = train_uft.find_root(i)
    pair = (road_root,train_root)
    pair_list.append(pair)
    if pair in pair_dict:
        pair_dict[pair] +=1
    else:
        pair_dict[pair] = 1

ans = ""
for i in range(N):
    pair = pair_list[i]
    ans += str(pair_dict[pair]) + " "
print(ans)


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

int main()
{
  int N, A=0;
  cin >> N;
  for(int i=1; i<=9; i++){
    for(int j=1; j<=9; j++){
      if(i*j==N){
        A=1;
        break;
      }
    }
  }
  if(A==1) cout << "Yes" << endl;
  else cout << "No" << endl;
}

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

long long calcCombination(long long x, long long y)
{
    if (x < y)
    {
        return 0;
    }

    if ((x - y) < y)
    {
        y = x - y;
    }

    long long ans = 1;
    for (long long i = 1; i <= y; i++)
    {
        ans *= x;
        ans /= i;
        x--;
    }
    return ans;
}

int main()
{
    int N, A, B;
    cin >> N >> A >> B;

    vector<long long> v(N);
    for (int i = 0; i < N; i++)
    {
        cin >> v[i];
    }
    sort(v.rbegin(), v.rend());

    int count = 0;
    int kind = 0;
    long long sum = 0;
    long long current_value = LONG_LONG_MAX;
    for (int i = 0; i < A; i++)
    {
        sum += v[i];
        if (current_value != v[i])
        {
            count = 0;
            current_value = v[i];
            kind++;
        }
        count++;
    }

    long long variation = 0;
    if (kind == 1)
    {
        for (int i = A; i < N; i++)
        {
            if (v[i] == current_value)
            {
                count++;
            }
        }
        for (int i = A; i <= B; i++)
        {
            variation += calcCombination(count, i);
        }
    }
    else
    {
        variation = count;
        for (int i = A; i < N; i++)
        {
            if (v[i] == current_value)
            {
                variation++;
            }
        }
        variation = calcCombination(variation, count);
    }

    cout << fixed << setprecision(6) << (double)sum / A << endl;
    cout << variation << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <cassert>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define ok() puts(ok?"Yes":"No");
#define chmax(x,y) x = max(x,y)
#define chmin(x,y) x = min(x,y)
using namespace std;
using ll = long long;
using vi = vector<int>;
using vll = vector<ll>;
using ii = pair<int, int>;
using vvi = vector<vi>;
using vii = vector<ii>;
using gt = greater<int>;
using minq = priority_queue<int, vector<int>, gt>;
using P = pair<ll,ll>;
const ll LINF = 1e18L + 1;
const int INF = 1e9 + 1;
//clang++ -std=c++11 -stdlib=libc++ 

int solve(int n) {
    int ans =0;
    for (int a=1; a<=100; a++) {
      if (a*a > n) break;
      for (int b=1; b<=100; b++) {
        if (a*a+b*b+a*b > n) break;
        for (int c=1; c<=100; c++) {
          int poly = a*a + b*b + c*c + a*b + a*c + b*c;
          if (poly == n) ans++;
          if (poly > n) break;
        }
      }
    }
    return ans;
}

int main() {
  int n; cin >> n;
  rep(i,n) cout << solve(i+1) << endl;
  return 0;
}

Measured memory_bytes: 3592
#include<bits/stdc++.h>
using namespace std;
int main()
{ int H,W,N,x,t;
 scanf("%d",&H);
 scanf("%d",&W);
 scanf("%d",&N);
 x=H;
 if(W>H) x=W;

 t=N/x;
 if(N%x==0) printf("%d",t);
 else printf("%d",t+1);


return 0;


}


Measured memory_bytes: 256
D=[1<<99]*K=gets.to_i
D[1]=1
q=[1]
while n=q.shift
	[[n*10%K,0,:unshift],[(n+1)%K,1,:<<]].each{|e,d,m|
		if D[e]>D[n]+d
			D[e]=D[n]+d
			q.send(m,e)
		end
	}
end
p D[0]

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


int main(){
	int N;
	cin >> N;
	vector<int> a(N);
	double sum;
	for (int i = 0; i < N; ++i) {
		cin >> a[i];
		sum += a[i];
	}
	sum /= N;
	int ans;
	double tmp = 100;
	for(int i = 0; i < N; ++i){
		if(tmp > abs(sum - a[i])) {
			tmp = abs(sum - a[i]);
			ans = i;
		}
	}
	cout << ans << endl;

}










Measured memory_bytes: 3588
#include <iostream>
using namespace std;
typedef long long ll;

int N;
string S;
ll dp[3010][3010] = {},inf = 1e9+7;

int main(){
	cin >> N >> S;
	for(int i=0;i<N;i++){
		dp[0][i] = i+1;
	}
	for(int i=1;i<N;i++){
		for(int j=0;j<N-i;j++){
			if(S[i-1]=='<'){
				dp[i][j] = dp[i-1][j];
			}else{
				dp[i][j] = (dp[i-1][N-i]-dp[i-1][j]+inf)%inf;		
			}
		}
		for(int j=1;j<=N;j++){
			(dp[i][j] += dp[i][j-1])%=inf;
		}
	}
	cout << dp[N-1][0] << endl;
}

Measured memory_bytes: 70784
n = int(input())
arr = [float(i) for i in input().split(" ")]

def Alch(arr):
  arr.sort()
  n1 = arr[0]
  n2 = arr[1]
  new_val = (n1 + n2) / 2
  arr[1] = new_val
  return arr[1:]

for i in range(n-1):
  arr = Alch(arr)

print(arr[0])

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

using namespace std;
using ll = long long;

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);
  ll a, b, k;
  cin >> a >> b >> k;
  ll p = min(a, k);
  k -= p;
  a -= p;
  p = min(b, k);
  b -= p;
  cout << a << ' ' << b << '\n';
  return 0;
}


Measured memory_bytes: 256
h, w = map(int, input().split())
s = [list(input()) for i in range(h)]
delta = [[-1, -1], [0, -1], [1, -1],
         [-1, 0], [1, 0],
         [-1, 1], [0, 1], [1, 1]]

for y in range(h):
  for x in range(w):
    if s[y][x] =='.':
      cnt = 0
      for dx, dy in delta:
        if 0 <= x + dx < w and 0<= y + dy < h and s[y + dy][x + dx] == '#':
          cnt += 1
      s[y][x] = str(cnt)

for si in s:
  print(''.join(si))

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

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

  int r;
  cin >> r;
  cout << 3 * r * r << endl;
}


Measured memory_bytes: 256
/* package whatever; // don't place package name! */

import java.util.*;
import java.lang.*;
import java.io.*;

/* Name of the class has to be "Main" only if the class is public. */
public class Main
{
	public static void main (String[] args) throws java.lang.Exception
	{
		Scanner in=new Scanner(System.in);
		int n=in.nextInt();
		long t=2;
		if(n%2!=0){
			System.out.println(t*n);	
		}
		else{
			System.out.println(n);
		}
	}
}

Measured memory_bytes: 21844
using System;
using System.Linq;
using System.Collections.Generic;

namespace Algorithm
{
    class Program
    {
        static void Main(string[] args)
        {
            var l = Console.ReadLine().Split().Select(int.Parse).ToArray();
            int K = l[0], S = l[1];

            var count = 0;
            for (var x = 0; x <= K; x++)
                for (var y = 0; y <= K; y++)
                    if (x + y <= S && x + y >= S - K) count++;

            Console.WriteLine(count);
        }
    }
}


Measured memory_bytes: 11220
using System;
using System.Linq;
public class Program {
  public static void Main() {
    int[] input1 = Console.ReadLine().Split(' ').Select(int.Parse).ToArray();
    int N = input1[0];
    int X = input1[1];
    int[] m = new int[N];
    for (int i = 0; i < N; i++) {
      m[i] = int.Parse(Console.ReadLine());
    }
    m = m.OrderBy(x => x).ToArray();
    Console.WriteLine(N + (X-m.Sum())/m[0]);
  }
}


Measured memory_bytes: 13396
#include <iostream>
#include <string>
#include <cmath>
#include<algorithm>
#include<stack>
#include<queue>
#include<map>
#include<set>
#include<iomanip>
#define _USE_MATH_DEFINES
#include <math.h>
#include <functional>
using namespace std;

#define rep(i,x) for(ll i=0;i<x;i++)
#define repn(i,x) for(ll i=1;i<=x;i++)

typedef long long ll;
const ll INF = 1e17;
const ll MOD = 1000000007;
const ll MAX = 1000001;

ll max(ll a, ll b) {
	if (a > b) { return a; }
	return b;
}

ll min(ll a, ll b) {
	if (a > b) { return b; }
	return a;
}

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

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

struct edge {
	ll ind;
	ll fr;
	ll to;
	ll d;
};


///////////////////////////

int main() {
	ll N, K;
	cin >> N >> K;

	vector<ll> a(N + 1);
	repn(i, N) cin >> a[i];

	vector<ll> s(N + 1, 0);
	repn(i, N) s[i] = s[i - 1] + a[i];

	vector<ll> b[51];
	rep(i, N) {
		for (ll j = i + 1; j <= N; j++) {
			b[0].push_back(s[j] - s[i]);
		}
	}

	ll M = b[0].size();
	vector<ll> c(M);

	ll ans = 0;

	rep(k, 50) {
		ll one = 0;
		rep(j, b[k].size()) {
			c[j] = (b[k][j] >> (49-k)) % 2;
			if (c[j] == 1) { one++; }
		}

		
		if (one >= K) {
			ans += 1ull << (49 - k);
			rep(j, b[k].size()) {
				if (c[j] == 1) { b[k + 1].push_back(b[k][j]); }
			}
		}

		else {
			rep(j, b[k].size()) {
				b[k + 1].push_back(b[k][j]);
			}
		}

	}


	cout << ans;
	system("PAUSE");
}


Measured memory_bytes: 64360
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  string  s;
  cin >> s;
  for(int i = 0;i<3;i++){
    if(s.at(i) == '1'){
      s.at(i) = '9';
    }
    else if( s.at(i) == '9'){
      s.at(i) = '1';
    }
  }
  cout << s;
}

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

int main(){
  int N;
  string S;
  cin >> N >> S;
  int Ans=0;
  for(int i=0; i<N; i++){
    if(S.at(i)=='R'){
      Ans++;
    }
    else{
      Ans--;
    }
  }
  if(Ans>0){
    cout << "Yes" << endl;
  }
  else{
    cout << "No" << endl;
  }
}

Measured memory_bytes: 256