akhauriyash/Code-Regression huggingface dataset:
import math
from math import gcd,pi,sqrt
INF = float("inf")
MOD = 10**9 + 7

import sys
sys.setrecursionlimit(10**6)
import itertools
import bisect
from collections import Counter,deque
def i_input(): return int(input())
def i_map(): return map(int, input().split())
def i_list(): return list(i_map())
def i_row(N): return [i_input() for _ in range(N)]
def i_row_list(N): return [i_list() for _ in range(N)]
def s_input(): return input()
def s_map(): return input().split()
def s_list(): return list(s_map())
def s_row(N): return [s_input for _ in range(N)]
def s_row_str(N): return [s_list() for _ in range(N)]
def s_row_list(N): return [list(s_input()) for _ in range(N)]


def main():
    N = i_input()
    N = math.factorial(N)

    def prime_decomposition(n):
        i = 2
        table = []
        while i * i <= n: # sqrt(n)で計算が済む
            while n % i == 0:
                n //= i
                table.append(i)
            i += 1
        if n > 1:
            table.append(n)
        return table

    N = sorted(prime_decomposition(N))
    ans = 1
    for i,k in itertools.groupby(N):
        ans *= len(list(k)) + 1
    print(ans%MOD)



if __name__=="__main__":
    main()


Measured memory_bytes: 71028
# -*- coding: utf-8 -*-

import math

class Point_Class():
    def __init__(self, x, y):
        self.x = x
        self.y = y

def calcCenter(p1, p2, p3):
    p = ((p1.y-p2.y)*(p3.x*p3.x+p1.y*p2.y)+(p2.y-p3.y)*(p1.x*p1.x+p2.y*p3.y)+(p3.y-p1.y)*(p2.x*p2.x+p3.y*p1.y)) / ((-2)*(p1.y*(p2.x-p3.x)+p2.y*(p3.x-p1.x)+p3.y*(p1.x-p2.x)))
    q = ((p1.x-p2.x)*(p3.y*p3.y+p1.x*p2.x)+(p2.x-p3.x)*(p1.y*p1.y+p2.x*p3.x)+(p3.x-p1.x)*(p2.y*p2.y+p3.x*p1.x)) / ((-2)*(p1.x*(p2.y-p3.y)+p2.x*(p3.y-p1.y)+p3.x*(p1.y-p2.y)))
    return Point_Class(p, q)

def calcRadius(p, pc):
    return math.sqrt(pow((p.x-pc.x), 2)+pow((p.y-pc.y), 2))

n = int(raw_input())
for i in range(n):
    x1, y1, x2, y2, x3, y3 = map(float, raw_input().split())
    p1 = Point_Class(x1, y1)
    p2 = Point_Class(x2, y2)
    p3 = Point_Class(x3, y3)
    pc = calcCenter(p1, p2, p3)
    r = calcRadius(p1, pc)
    print "%.3f %.3f %.3f" %(pc.x, pc.y, r)

Measured memory_bytes: 6524
/// However long the night,
///     The dawn will break
/// ICPC next year

#include<bits/stdc++.h>
using namespace std ;
const int N = 2e5+5 ;

int n ,a[N] ,cnt[N][22] ;
int main(){
    scanf("%d",&n);
    for(int i=1;i<=n;++i){
        scanf("%d",a+i);
        vector<int> v ,cur ;
        for(int j=0;j<22;++j){
            cnt[i][j] = cnt[i-1][j] ;
            if((1<<j)>a[i]) continue ;
            if(a[i] & (1<<j)) ++cnt[i][j] ;
        }
    }
    long long ans = 0 ;
    for(int i=0;i<n;++i){
        int st=i+1 ,en=n ;
        while(st<en){
            int mid = (st+en+1)/2 ;
            int mx = 0 ;
            for(int j=0;j<22 && mx<2;++j) mx = max(mx,cnt[mid][j]-cnt[i][j]);
            if(mx<2) st=mid ;
            else en=mid-1;
        }
        ans += st-i ;
    }
    cout << ans;
    return 0;
}


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

using i64 = long long int;

int dp[103][10005]={0};

int main(){
    int n, w;
    cin >> n >> w;
    vector<pair<int, int>> v;
    for(int i=0;i<n;++i){
        int a, b;
        cin >> a >> b;
        v.emplace_back(a, b);
    }

    for(int i=0;i<n;++i){
        for(int j=0;j<=w;++j){
            dp[i+1][j] = max(dp[i+1][j], dp[i][j]);
            if(j+v[i].second <= w)
                dp[i+1][j+v[i].second] = max(dp[i+1][j+v[i].second], dp[i][j] + v[i].first);
        }
    }

    cout << dp[n][w] << endl;

    return 0;
}



Measured memory_bytes: 7000
#include <bits/stdc++.h>
using namespace std;
/*{{{*/  //template
#define rep(i,n) for(int i=0;i<(int)(n);i++)
constexpr int INF = numeric_limits<int>::max()/2;
constexpr long long LINF = numeric_limits<long long>::max()/3;
#define mp make_pair
#define pb push_back
#define eb emplace_back
#define fi first
#define se second
#define all(v) (v).begin(),(v).end()
#define sz(x) (int)(x).size()
#define debug(x) cerr<<#x<<":"<<x<<endl
#define debug2(x,y) cerr<<#x<<","<<#y":"<<x<<","<<y<<endl
//struct fin{ fin(){ cin.tie(0); ios::sync_with_stdio(false); } } fin_;
struct Double{ double d; explicit Double(double x) : d(x){} };
ostream& operator<<(ostream& os,const Double x){ os << fixed << setprecision(20) << x.d; return os; }
template<typename T> ostream& operator<<(ostream& os,const vector<T>& vec){ os << "["; for(const auto& v : vec){ os << v << ","; } os << "]"; return os; }
template<typename T,typename U> ostream& operator<<(ostream& os,const pair<T,U>& p){ os << "(" << p.first << ","<< p.second <<")"; return os; }
template<typename T> ostream& operator<<(ostream& os,const set<T>& st){ os<<"{"; for(T v:st) os<<v<<","; os <<"}"; return os; }
template<typename T,typename U> inline void chmax(T &x,U y){ if(y>x) x = y; }
template<typename T,typename U> inline void chmin(T &x,U y){ if(y<x) x = y; }
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<vi> vvi;
ll gcd(ll a,ll b){ if(b==0) return a; else return gcd(b,a%b); }
//constexpr double eps = 1e-14; 
constexpr double eps = 1e-10; 
constexpr ll mod = 1e9+7;
const int dx[]={1,0,-1,0} ,dy[] = {0,1,0,-1};
/*}}}*/

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


Measured memory_bytes: 256
n=int(input())
e = [[int(i) for i in input().split()] for i in range(n)]
h=0
for a in range(n):
    if e[a][2]>0:
        s=a
        break
for x in range(0,101):
    for y in range(0,101):
            k=abs(x-e[s][0])+abs(y-e[s][1])+e[s][2]
            for i in range(0,n):
                if e[i][2]!=max(k-abs(x-e[i][0])-abs(y-e[i][1]),0):
                    break
            else:
                print(x,y,k)

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


int main(){
    int n;
    cin >> n;
    vector<ll> a(n);
    rep(i,n){
        cin >> a[i];
        if(a[i]==0){
            cout << 0 << endl;
            return 0;
        }
    }
    ll now = 1;
    ll lim = 1e18;
    rep(i,n){
        if(a[i] > lim/now){
            cout << -1 << endl;
            return 0;
        }
        else{
            now*=a[i];
        }
    }
    cout << now << endl;
    return 0;
}

Measured memory_bytes: 4032
from collections import defaultdict
def main():
    N = int(input())
    d = defaultdict(int)
    for _ in range(N):
        S = input()
        d[S] += 1

    for s in ['AC','WA','TLE','RE']:
        print(s + ' x ' + str(d[s]))
    



if __name__ == "__main__":
    main()

Measured memory_bytes: 9468
from collections import Counter
n = int(input())
vn = list(map(int,input().split()))
v0 = [0]*(n//2)
v1 = [0]*(n//2)
for i in range(n//2):
  v0[i] = vn[i*2+0]
  v1[i] = vn[i*2+1]
v0 = Counter(v0)
v1 = Counter(v1)
v0c0 = v0.most_common()[0]
v1c0 = v1.most_common()[0]
v0c1 = [0,0] if (len(v0.most_common()) == 1) else v0.most_common()[1]
v1c1 = [0,0] if (len(v1.most_common()) == 1) else v1.most_common()[1]

if v0c0[0] != v1c0[0]:
  print(n-v0c0[1]-v1c0[1])
elif v0c0[1] < v1c0[1]:
  print(n-v0c1[1]-v1c0[1])
elif v0c0[1] > v1c0[1]:
  print(n-v0c0[1]-v1c1[1])
elif v0c1[1] < v1c1[1]:
  print(n-v0c0[1]-v1c1[1])
elif v0c1[1] > v1c1[1]:
  print(n-v0c1[1]-v1c0[1])
else:
  print(n-v0c0[1]-v1c1[1])


Measured memory_bytes: 18784
n = int(input())
s = [""]*n
for i in range(n):
    s[i] = input()
import collections
s = collections.Counter(s)
m = int(input())
for j in range(m):
    t = input()
    if t in s:
        s[t] -= 1
print(max(0, s.most_common()[0][1]))

Measured memory_bytes: 9364
#include<bits/stdc++.h>
typedef long long int l1;
using namespace std;
#define pb push_back
#define input l1 t;cin>>t;while(t--)
int main(){
  string s;
 cin>>s;
  if((s[2]==s[3])&&(s[4]==s[5]))
    	cout<<"Yes\n";
 else
   cout<<"No\n";
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<vector>
#include<stack>
#include<map>
#include<set>
#include<queue>
#include<cstdio>
#include<climits>
#include<cmath>
#include<cstring>
#include<string>
#include<sstream>
#include<numeric>

#define f first
#define s second
#define mp make_pair

#define REP(i,n) for(int i=0; i<(int)(n); i++)
#define FOR(i,c) for(__typeof((c).begin()) i=(c).begin(); i!=(c).end(); i++)
#define ALL(c) (c).begin(), (c).end()

using namespace std;

typedef unsigned int uint;
typedef long long ll;

int getInt(){
  int ret = 0,c;
  c = getchar();
  while(!isdigit(c)) c = getchar();
  while(isdigit(c)){
    ret *= 10;
    ret += c - '0';
    c = getchar();
  }
  return ret;
}

pair<int,int> c[10000];
int cnt;

int test(int i, int j){
  int ret = 0;

  if(c[i].f == c[j].f){
    int sum = c[i].s + c[j].s;
    if(sum >= 4) ret += 4;
    i++; j--;
  }else{
    if(c[i].s >= 4) ret += c[i++].s;
    if(c[j].s >= 4) ret += c[j--].s;
  }

  if(j >= 0  && c[j].s == 0) j--;
  if(i < cnt && c[i].s == 0) i++;

  while(j >= 0 && i < cnt){
    if(c[i].f != c[j].f) break;
    int sum = c[i].s + c[j].s;
    if(sum >= 4){
      ret += sum;
      i++; j--;
    }else{
      break;
    }
  }

  return ret;
}

int main(){
  int n;
  while(n = getInt()){
    cnt = 0;
    REP(i,n){
      int tmp = getInt();
      if(cnt == 0){
        c[cnt].f = tmp;
        c[cnt].s = 1;
        cnt++;
      }else{
        if(c[cnt-1].f == tmp)
          c[cnt-1].s++;
        else{
          c[cnt].f = tmp;
          c[cnt].s = 1;
          cnt++;
        }
      }
    }

    int ans = n;
    //REP(i,cnt) printf("%d: %d\n",c[i].f, c[i].s);

    REP(i,cnt){
      if(i != 0){
        c[i-1].s++;
        c[i].s--;
        ans = min(ans, n-test(i,i-1));
        c[i].s++;
        c[i-1].s--;
      }
      if(i != cnt-1){
        c[i+1].s++;
        c[i].s--;
        ans = min(ans, n-test(i+1,i));
        c[i].s++;
        c[i+1].s--;
      }
      //printf("%d: ans=%d\n",i,ans);
    }

    printf("%d\n",ans);
  }
  return 0;
}

Measured memory_bytes: 0
#pragma warning(disable:4996)
#pragma comment(linker, "/STACK:336777216")
#pragma GCC optimize("Ofast")

#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <functional>

using namespace std;
using namespace __gnu_pbds;

typedef long long ll;
#define int long long int
typedef complex<long double> cd;
const long double pi=acos(-1);
typedef double db;
typedef long double ldb;
typedef pair <int, int> pii;
typedef pair <db, db> pdd;
typedef vector<int> vi;
typedef vector<vector<int> > matrix;

#define m1 make_pair
#define pb push_back
#define flush fflush(stdout)
#define IOS std::ios::sync_with_stdio(false); cin.tie(NULL);cout.tie(NULL);
#define reset(x,v) memset(x,v,sizeof(x))

#define fi first
#define se second
#define endl "\n"
#define debug(x) (cerr << #x << ": " << x << "\n")
#define setbits(x) __builtin_popcount(x)
#define setbitsll(x) __builtin_popcountll(x)
#define all(x) x.begin(),x.end()
#define pii pair<int,int>

inline ll gcd(ll a,ll b){if(a==0) return b;return gcd(b%a,a);}
inline ll power(ll a,ll n,ll m){if(n==0)return 1;ll p=power(a,n/2,m);p=(p%m*p%m)%m;if(n%2) return (p%m*a%m)%m;else return p;}
const double EPS = 1e-9;
const ll MOD =998244353;
const ll hell=1000000007;
const int INF = 1e18;
const ll LL_INF = 0x3f3f3f3f3f3f3f3f;
template<typename T>
using ordered_set=tree<T, null_type, less<T>, rb_tree_tag,tree_order_statistics_node_update>;

auto seed = chrono::high_resolution_clock::now().time_since_epoch().count();
std::mt19937 rng(seed);

double startTime;
double getCurrentTime() {
    return ((double)clock() - startTime) / CLOCKS_PER_SEC;
}
const int dx[] = { -1, 0, 1, 0 };
const int dy[] = { 0, 1, 0, -1 };

const int N=200005;

int cnt1[N+1],cnt2[N+1];

void solve()
{
    int n;
    cin>>n;
    int a[n],b[n];
    for(int i=0;i<n;i++)
    {
        cin>>a[i];
        cnt1[a[i]]++;
    }
    for(int i=0;i<n;i++)
    {
        cin>>b[i];
        cnt2[b[i]]++;
    }
    int th=n/2+1;
    set<pair<int,int>> s;
    for(int i=1;i<=N;i++)
    {
        if((cnt1[i]+cnt2[i])>n)
        {
            cout<<"No"<<endl;
            return;
        }
        if(cnt2[i])
        {
            s.insert(m1(cnt1[i]+cnt2[i],i));
        }
    }
    cout<<"Yes"<<endl;
    int ans[n];
    for(int i=0;i<n;i++)
    {
        auto it=(--s.end());
        pair<int,int> p=(*it);
        if(p.se==a[i])
        {
            
            it--;
            p=(*it);
        }
        cnt2[p.se]--;
        s.erase(it);
        ans[i]=p.se;
        if(cnt2[p.se])
            s.insert(m1(cnt1[p.se]+cnt2[p.se],p.se));
        if(s.find(m1(cnt1[a[i]]+cnt2[a[i]],a[i]))!=s.end())
            s.erase(s.find(m1(cnt1[a[i]]+cnt2[a[i]],a[i])));
            cnt1[a[i]]--;
        if(cnt2[a[i]])
        {
            s.insert(m1(cnt1[a[i]]+cnt2[a[i]],a[i]));
        }
    }
    for(int i=0;i<n;i++)
        cout<<ans[i]<<" ";
    cout<<endl;
    
    
    
}

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







Measured memory_bytes: 23892
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        int b = sc.nextInt();
        if ((a * b) % 2 == 0)
            System.out.println("Even");
        else
            System.out.println("Odd");
    }

}


Measured memory_bytes: 21076
n = int(input())
fs = [list(map(int, input().split())) for _ in range(n)]
ps = [list(map(int, input().split())) for _ in range(n)]

anss = []
for i in range(1, 2**10):
  l = [0]*n
  for j in range(10):
    if  (i >> j) & 1:
      for k in range(n):
        l[k] += fs[k][j]
  ans = 0
  for m in range(n):
    ans += ps[m][l[m]]
  anss.append(ans)
  
anss.sort(reverse=True)
print(anss[0])


Measured memory_bytes: 41968
input_line = input()
#print(input_line)
charlist = list(input_line)
index = 0
for i in range(3):
    if(charlist[i]=="R"):
        index += 1
    
if index==2:
    if charlist[1]=="S":
        print(1)
        
    else:
        print(index)
        
else:
    print(index)

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

int main(){
  int m1,d1,m2,d2;
  cin >> m1 >> d1 >> m2 >> d2;
  if(d2==1){
    cout << 1 << endl;
  }else{
    cout << 0 << endl;
  }
}

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

int main() {
  
  int s;
  cin >> s;
  
  map<int, int> Map;
  
  int count = 1;
  while(true) { 
    if (Map[s]) {
      cout << count << endl;
      return 0;
    }
    
    if (s % 2) {
      Map[s] = count;
      s = 3 * s + 1;   
      count++;
      
    } else {
      Map[s] = count;
      s /= 2;
      count++;
    }
  }
}

Measured memory_bytes: 256
// khodaya khodet komak kon
#include <bits/stdc++.h>
#define pb push_back
#define ers erase
#define ins insert
#define F first
#define S second
#define all(x) x.begin(), x.end()
#define debug(x)  cerr << #x << " = " << x << endl
#define kill(x) return cout << x, 0;
#define IOS ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#pragma GCC optimize ("Ofast")
using namespace std;

typedef long long ll;
typedef long double ld;
typedef string str;
typedef pair<ll, ll> pll;
typedef vector<ll> vl;
typedef vector<pll> vpl;

const ld Pi = 3.14159265359;
const ll MOD = 1000 * 1000 * 1000 + 7;
const ll N = 2e5 + 10;
const ll INF = 1e18;
const ll LOG = 20;

int main(){
	IOS;
	ll ans = 0;
	ll n;
	cin >> n;
	for (ll i = 1; i * i <= n; i++){
		if (n % i == 0){
			ll Now = i - 1;
			if (Now != 0) if (n / Now == n % Now) ans += Now;
			Now = n / i - 1;
			if (Now != 0)if (n / Now == n % Now) ans += Now;
		}
	}	
	cout << ans;
	
	
	
	
	
	
	return 0;
}






/*
     ,---,           ___                 ,--,
    '  .' \        ,--.'|_             ,--.'|                             ,--,
   /  ;    '.      |  | :,'            |  | :                           ,--.'|    ,---.        ,---,
  :  :       \     :  : ' :            :  : '                 .--.--.   |  |,    '   ,'\   ,-+-. /  |
  :  |   /\   \  .;__,'  /    ,--.--.  |  ' |     ,--.--.    /  /    '  `--'_   /   /   | ,--.'|'   |
  |  :  ' ;.   : |  |   |    /       \ '  | |    /       \  |  :  /`./  ,' ,'| .   ; ,. :|   |  ,"' |
  |  |  ;/  \   \:__,'| :   .--.  .-. ||  | :   .--.  .-. | |  :  ;_    '  | | '   | |: :|   | /  | |
  '  :  | \  \ ,'  '  : |__  \__\/: . .'  : |__  \__\/: . .  \  \    `. |  | : '   | .; :|   | |  | |
  |  |  '  '--'    |  | '.'| ," .--.; ||  | '.'| ," .--.; |   `----.   \'  : |_|   :    ||   | |  |/
  |  :  :          ;  :    ;/  /  ,.  |;  :    ;/  /  ,.  |  /  /`--'  /|  | '.'\   \  / |   | |--'
  |  | ,'          |  ,   /;  :   .'   \  ,   /;  :   .'   \'--'.     / ;  :    ;`----'  |   |/
  `--''             ---`-' |  ,     .-./---`-' |  ,     .-./  `--'---'  |  ,   /         '---'
                            `--`---'            `--`---'                 ---`-'
*/




Measured memory_bytes: 256
#include <iostream>                                             
#include <cstdio>                                               
#include <cctype>                                               
using namespace std;                                            
                                                                
int main(void) {                                                
  char ch;                                                      
  while ((ch = getchar()) != EOF) {                             
    if (islower(ch)) {                                          
      ch = toupper(ch);                                         
    } else {                                                    
      ch = tolower(ch);                                         
    }                                                           
    cout << ch << flush;                                        
  }                                                             
  return 0;                                                     
}                                                               

Measured memory_bytes: 3000
import math
a,b,h,m=map(int,input().split())
#1分間に進む分針 360/60=6度
#1時間に進む時針 360/12=30度
#1分間に進む時針 30/60=0.5度
r=abs((h*30+m*0.5)-(m*6))
s=math.sqrt(a**2+b**2-(2*a*b*(math.cos(math.radians(r)))))
print(s)

Measured memory_bytes: 9496
#include <bits/stdc++.h>
const int INF = 1e9;
const int MODk = 1e9+7;
using LL = long long;
const LL LINF = 1e18;
const double EPS = 1e-10;
using namespace std;
#define COUT(v) cout<<(v)<<endl
#define COUTDOUBLE(v) cout << std::setprecision(10)<<(v)<<endl;
#define CIN(n)  int(n);cin >> (n)
#define LCIN(n) LL(n);cin >> (n)
#define SCIN(n) string(n);cin >> (n)
#define YES(n) cout<<((n)? "YES" : "NO")<<endl
#define Yes(n) cout<<((n)? "Yes" : "No")<<endl
#define POSSIBLE(n) cout << ((n) ? "POSSIBLE" : "IMPOSSIBLE"  ) << endl
#define Possible(n) cout << ((n) ? "Possible" : "Impossible"  ) <<endl

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) for(int i=0;i<(n);++i)
#define REPR(i,n) for(int i=n;i>=0;i--)

#define FOREACH(x,a) for(auto& (x) : (a) )

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

#define P pair<LL,LL>
#define I vector<int>
#define pb(v) push_back(v)
#define V vector
#define rt return
#define rmsame(a) sort(ALL(a)),a.erase(unique(ALL(a)), a.end())
#define ENDL cout<<endl
#define f first
#define s second

typedef string::const_iterator State;
class PalseError {};
class Edge{
public:
    int from,to,value;
    Edge(LL a,LL b,LL c){
        from = a;
        to = b;
        value = c;
    }
    Edge(LL a,LL b){
        from = a;
        to = b;
    }
};


class UnionFind{
private:
    vector<int> vec;
public:
    void init(int N){
        vec.resize(N);
        for(int a = 0;a < N;a++)
        {
            vec[a]=-1;
        }
    }
    int root(int a)
    {
        if(vec[a] < 0)return a;
        else return vec[a] = root(vec[a]);
    }
    bool connect(int a,int b)
    {
        a = root(a);
        b = root(b);
        if(a==b)return false;
        if(vec[a] > vec[b])swap(a,b);
        vec[a] += vec[b];
        vec[b] = a;
        return true;
    }
    bool check(int a,int b){
        a = root(a);
        b = root(b);
        if(a==b)return true;
        else return false;
    }
};
bool comp(const Edge& e1, const Edge& e2){
    return e1.value < e2.value;
}
LL kruskal(V<Edge> Edges,int N){
    sort(ALL(Edges), comp);
    UnionFind Uni;
    Uni.init(N);
    LL ans = 0LL;
    for(int a = 0;a < Edges.size();a++){
        Edge e = Edges.at(a);
        if(!Uni.check(e.from,e.to)){
            Uni.connect(e.from,e.to);
            ans += e.value;
        }
    }
    return ans;
}


int main(){
    LCIN(N);
    V<Edge> Edges;
    V<P> mati,mati2;
    REP(a,N){
        LCIN(b);LCIN(c);
        mati.push_back(P(b,a));
        mati2.push_back(P(c,a));
    }
    sort(ALL(mati));
    sort(ALL(mati2));
    REP(a,N-1){
        Edge e(mati.at(a).s,mati.at(a+1).s,abs(mati.at(a).f-mati.at(a+1).f));
        Edge w(mati2.at(a).s,mati2.at(a+1).s,abs(mati2.at(a).f-mati2.at(a+1).f));
        Edges.push_back(e);
        Edges.push_back(w);
    }
    COUT(kruskal(Edges,N));
    return 0;
}


Measured memory_bytes: 10208
from sys import stdin

s = stdin.readline().rstrip()

if s == 'SUN':
  print(7)
elif s == 'MON':
  print(6)
elif s == 'TUE':
  print(5)
elif s == 'WED':
  print(4)
elif s == 'THU':
  print(3)
elif s == 'FRI':
  print(2)
elif s == 'SAT':
  print(1)

Measured memory_bytes: 3060
#include <iostream>
#include <vector>
#include <string>
#include <cmath>
#include <algorithm>

using namespace std;

int main(){
	string S;
	cin >> S;
	for(int i=0;i<4;i++){
		cout <<S[i];
	}
	cout << " ";
	for(int i=4;i<12;i++){
		cout <<S[i];
	}
	cout << endl;
	return 0;
}

Measured memory_bytes: 256
import sys
sys.setrecursionlimit(10**7) #再帰関数の上限,10**5以上の場合python
import math
from copy import copy, deepcopy
from copy import deepcopy as dcp
from operator import itemgetter
from bisect import bisect_left, bisect, bisect_right#2分探索
#bisect_left(l,x), bisect(l,x)#aはソート済みである必要あり。aの中からx未満の要素数を返す。rightだと以下
from collections import deque
#deque(l), pop(), append(x), popleft(), appendleft(x)
##listでqueの代用をするとO(N)の計算量がかかってしまうので注意
from collections import Counter#文字列を個数カウント辞書に、
#S=Counter(l),S.most_common(x),S.keys(),S.values(),S.items()
from itertools import accumulate,combinations,permutations#累積和
#list(accumulate(l))
from heapq import heapify,heappop,heappush
#heapify(q),heappush(q,a),heappop(q) #q=heapify(q)としないこと、返り値はNone
#import fractions#古いatcoderコンテストの場合GCDなどはここからimportする
from functools import lru_cache#pypyでもうごく
#@lru_cache(maxsize = None)#maxsizeは保存するデータ数の最大値、2**nが最も高効率
from decimal import Decimal

def input(): 
    x=sys.stdin.readline()
    return x[:-1] if x[-1]=="\n" else x
def printl(li): _=print(*li, sep="\n") if li else None
def argsort(s, return_sorted=False): 
    inds=sorted(range(len(s)), key=lambda k: s[k])
    if return_sorted: return inds, [s[i] for i in inds]
    return inds
def alp2num(c,cap=False): return ord(c)-97 if not cap else ord(c)-65
def num2alp(i,cap=False): return chr(i+97) if not cap else chr(i+65)
def matmat(A,B):
    K,N,M=len(B),len(A),len(B[0])
    return [[sum([(A[i][k]*B[k][j]) for k in range(K)]) for j in range(M)] for i in range(N)]
def matvec(M,v):
    N,size=len(v),len(M)
    return [sum([M[i][j]*v[j] for j in range(N)]) for i in range(size)]
def T(M):
    n,m=len(M),len(M[0])
    return [[M[j][i] for j in range(n)] for i in range(m)]
def main():
    mod = 1000000007
    #w.sort(key=itemgetter(1),reversed=True)  #二個目の要素で降順並び替え

    #N = int(input())
    N, K = map(int, input().split())
    H = list(map(int, input().split())) #1行ベクトル
    #L = tuple(int(input()) for i in range(N)) #改行ベクトル
    #S = tuple(tuple(map(int, input().split())) for i in range(N)) #改行行列
    if K>=len(H):
        print(0)
        return
    if K==0:
        print(sum(H))
        return 
    H.sort()
    H=H[:-K]
    print(sum(H))




if __name__ == "__main__":
    main()

Measured memory_bytes: 33152
//入力マクロここから
//https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8
macro_rules ! input_inner { ( $ next : expr ) => { } ; ( $ next : expr , ) => { } ; ( $ next : expr , $ var : ident : $ t : tt $ ( $ r : tt ) * ) => { let $ var = read_value ! ( $ next , $ t ) ; input_inner ! { $ next $ ( $ r ) * } } ; }
macro_rules ! read_value { ( $ next : expr , ( $ ( $ t : tt ) ,* ) ) => { ( $ ( read_value ! ( $ next , $ t ) ) ,* ) } ; ( $ next : expr , [ $ t : tt ; $ len : expr ] ) => { ( 0 ..$ len ) . map ( | _ | read_value ! ( $ next , $ t ) ) . collect ::< Vec < _ >> ( ) } ; ( $ next : expr , chars ) => { read_value ! ( $ next , String ) . chars ( ) . collect ::< Vec < char >> ( ) } ; ( $ next : expr , usize1 ) => { read_value ! ( $ next , usize ) - 1 } ; ( $ next : expr , $ t : ty ) => { $ next ( ) . parse ::<$ t > ( ) . expect ( "Parse error" ) } ; }
macro_rules ! input { ( source = $ s : expr , $ ( $ r : tt ) * ) => { let mut iter = $ s . split_whitespace ( ) ; let mut next = || { iter . next ( ) . unwrap ( ) } ; input_inner ! { next , $ ( $ r ) * } } ; ( $ ( $ r : tt ) * ) => { let stdin = std :: io :: stdin ( ) ; let mut bytes = std :: io :: Read :: bytes ( std :: io :: BufReader :: new ( stdin . lock ( ) ) ) ; let mut next = move || -> String { bytes . by_ref ( ) . map ( | r | r . unwrap ( ) as char ) . skip_while ( | c | c . is_whitespace ( ) ) . take_while ( | c |! c . is_whitespace ( ) ) . collect ( ) } ; input_inner ! { next , $ ( $ r ) * } } ; }
//入力マクロここまで

fn main() {
    input! {
        xs: [u64;3],
    }

    if xs.iter().sum::<u64>() >= 22 {
        println!("bust");
    } else {
        println!("win");
    }
}


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

int main() {
    int N;
    cin >> N;
    set<int> cnt;
    for (int i = 0; i < N; i++) {
        int a;
        cin >> a;
        cnt.insert(a);
    }

    if (cnt.size() % 2 == 0) {
        cout << cnt.size() - 1 << endl;
    } else {
        cout << cnt.size() << endl;
    }
    return 0;
}

Measured memory_bytes: 4992
class Combination:
    def __init__(self, n_max, mod=10 ** 9 + 7):
        # O(n_max + log(mod))
        self.mod = mod
        f = 1
        self.fac = fac = [f]
        for i in range(1, n_max + 1):
            f = f * i % mod
            fac.append(f)
        f = pow(f, mod - 2, mod)
        self.facinv = facinv = [f]
        for i in range(n_max, 0, -1):
            f = f * i % mod
            facinv.append(f)
        facinv.reverse()

    # "n 要素" は区別できる n 要素
    # "k グループ" はちょうど k グループ

    def __call__(self, n, r):  # self.C と同じ
        return self.fac[n] * self.facinv[r] % self.mod * self.facinv[n - r] % self.mod

    def nCr(self, n, r):
        if not 0 <= r <= n:
            return 0
        return self.fac[n] * self.facinv[r] % self.mod * self.facinv[n - r] % self.mod

    def nPr(self, n, r):
        if not 0 <= r <= n:
            return 0
        return self.fac[n] * self.facinv[n - r] % self.mod

MOD = 10**9+7
def resolve():
    N, M = map(int, input().split())
    cmb = Combination(5 * 10**5)

    ans = 0
    for p in range(N+1):
        ans += (-1)**p * cmb.nCr(N, p) * cmb.nPr(M-p, N-p)
        ans %= MOD

    ans *= cmb.nPr(M, N)
    ans %= MOD

    print(ans)


if __name__ == "__main__":
    resolve()


Measured memory_bytes: 48756
#include <bits/stdc++.h>
using namespace std;
#define IOS ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define ll long long
#define vll vector<ll>
#define vi vector<int>
#define pb push_back
#define fi first
#define se second
#define pii pair<int,int>
#define pll pair<ll,ll>
#define mii map<int,int>
#define mll map<ll,ll>
#define all(x) (x).begin(),(x).end()
#define S(x) (int)(x).size()
#define L(x) (int)(x).length()
#define debug(x) cerr << #x << " " << x << endl;
#define debug_p(x) cerr << #x << " [" << x.fi << " " << x.se << "]"<<endl;
#define debug_v(x) {cerr << #x << " "; for (auto ioi : x) cerr << ioi << " "; cerr << endl;}
#define debug_vp(x) {cerr << #x << " "; for (auto ioi : x) cerr << '[' << ioi.fi << " " << ioi.se << ']'; cerr << endl;}
#define debug_v_v(x) {cerr << #x << "/*\n"; for (auto ioi : x) { for (auto ioi2 : ioi) cerr << ioi2 << " "; cerr << '\n';} cerr << "*/" << #x << endl;}
#define gen_clock(x) ll x = clock(); cerr << "Clock " << #x << " created" << endl;
#define check_clock(x) cerr << "Time spent in " << #x << ": " << (double)(clock() - x)/CLOCKS_PER_SEC << endl; x = clock();
#define reset_clock(x) x = clock()
 
const int mod = 1e9+7;
const ll infl = 0x3f3f3f3f3f3f3f3fLL;
const int infi = 0x3f3f3f3f;
 
void solve()
{
	ll n;
	ll d;
	cin>>n>>d;
	ll a[n],b[n];
	for(ll i=0;i<n;i++)
	cin>>a[i]>>b[i];
	ll ct=0;
	for(ll i=0;i<n;i++)
	{
		if(ceil(sqrt((a[i]*a[i])+(b[i]*b[i])))<=d)
		ct++;
		//cout<<ceil(sqrt((a[i]*a[i])+(b[i]*b[i])))<<" ";
	}
	cout<<ct;
	
}
 
int main()
{
	IOS
	int t=1;
	//cin>>t;
	while(t--)
	{
		solve();
	}
}

Measured memory_bytes: 6776
#include<stdio.h>

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

int main (void) {
    int n = 0;
    scanf("%d", &n);
    int ac = 0, wa = 0, tle = 0, re = 0;
    char text[4];
    rep(i, n){
        scanf("%s", text);
        //printf("text = %s\n", text);
        if (strcmp(text, "AC") == 0) {
            ac += 1;
        }
        else if (strcmp(text, "WA") == 0) {
            wa += 1;
        }
        else if (strcmp(text, "TLE") == 0) {
            tle += 1;
        }
        else if (strcmp(text, "RE") == 0) {
            re += 1;
        }
        else {
            //void
        }
    }

    printf("AC x %d\n", ac);
    printf("WA x %d\n", wa);
    printf("TLE x %d\n", tle);
    printf("RE x %d\n", re);

    return 0;
}

Measured memory_bytes: 1732
#include <iostream>
#include <string>
#include <map>
using namespace std;

int main()
{
    int x,y;
    cin >> x >> y;
    string res;
    
    for(int i = 0; i <= x; i++){
        int a = i;
        int b = x - i;
        if(2*a+4*b==y){
            cout << "Yes" << endl;
            return 0;
        }
    }
    cout << "No" << endl;
}


Measured memory_bytes: 3588
#include <iostream>
#include <fstream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <string>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <deque>
#include <bitset>
#include <algorithm>
#include <complex>
#include <array>
#include <functional>
using namespace std;
 
#define REP(i,n) for(int i=0; i<n; ++i)
#define FOR(i,a,b) for(int i=a; i<=b; ++i)
#define FORR(i,a,b) for (int i=a; i>=b; --i)
#define ALL(c) (c).begin(), (c).end()
 
typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<double> VD;
typedef vector<VI> VVI;
typedef vector<VL> VVL;
typedef vector<VD> VVD;
typedef pair<int,int> P;
typedef pair<ll,ll> PL;

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

int in() { int x; scanf("%d", &x); return x; }
ll lin() { ll x; scanf("%lld", &x); return x; }

const ll mod = 998244353;

ll calc(ll x, ll n){
    ll ret = 0;
    ll y = x;
    do{
        ret++;
        if (y % 2) y /= 2;
        else y = y / 2 + (1LL << (n - 1));
    }while (y != x);
    return ret;
}

ll count(VI &a, ll c){
    ll n = a.size(), m = n / c;
    VVL dp(c + 1, VL(2));
    dp[0][0] = 1;
    REP(i,c) REP(f,2) REP(x,2){
        if (!f && x > a[i]) continue;
        int ff = f | (x < a[i]);
        (dp[i+1][ff] += dp[i][f]) %= mod;
    }
    // REP(i,c+1){
    //     REP(f,2){
    //         cout << dp[i][f] << " ";
    //     }
    //     cout << endl;
    // }
    ll ret = 0;
    REP(f,2){
        ret = (ret + dp[c][f]) % mod;        
    }
    VI b;
    REP(i,n){
        int p = (i / c) % 2;
        b.push_back(a[i % c] ^ p);
    }
    if (b > a) ret = (ret - 1 + mod) % mod;
    return ret;
}

int main() {
    ll n;
    string s;
    cin >> n >> s;
    VI a(n);
    REP(i,n){
        a[i] = s[i] - '0';
    }

    // ll cnt = 0;
    // REP(i,n){
    //     cnt = (2 * cnt + a[i]) % mod;
    // }
    // cnt = (cnt + 1) % mod;

    VL d;
    FOR(c,1,n){
        if (n % c) continue;
        if ((n / c) % 2 == 0) continue;
        d.push_back(c);
    }
    ll m = d.size();

    VL dp(m);
    REP(i,m){
        dp[i] = count(a, d[i]);
        // cout << d[i] << " " << dp[i] << endl;
        REP(j,i){
            if (d[i] % d[j] == 0 && (d[i] / d[j]) % 2 == 1){
                dp[i] = (dp[i] - dp[j] + mod) % mod;
            }
        }
    }

    ll ans = 0;
    REP(i,m){
        ans = (ans + dp[i] * 2 * d[i]) % mod;
    }
    // ans = (ans + all * 2 * n) % mod;
    cout << ans << endl;

    // ll tmp = 0;
    // REP(x,cnt){
    //     ll c = calc(x, n);
    //     if (c != 2 * n) cout << x << " " << c << endl;
    //     tmp += c;
    // }
    // cout << cnt << endl;
    // cout << tmp << endl;

    return 0;
}


Measured memory_bytes: 13976
a = input()
b = a[::-1]
s ,t ,r= 0,0,0

while s+t<len(a):
    if a[s] == b[t]:
        s+=1
        t+=1
    elif a[s] =="x":
        r+=1
        s+=1
    elif b[t] =="x":
        r+=1
        t+=1
    else:
        print(-1)
        exit()
print(r)


Measured memory_bytes: 3316
#include<bits/stdc++.h>
#define ll long long
#define pa pair<int,int>
using namespace std;
vector<pa>ans;
set<int>tr;
int n;
void output(){
    for(int i=0;i<ans.size();i++)printf("%d %d\n",ans[i].first,ans[i].second);
}
int main(){
    ans.clear();
    scanf("%d",&n);
    int p=1;
    while(p<=n){
        if(n==p)return puts("No"),0;
        p<<=1;
    }
    puts("Yes");
    bool flag=0;
    if(n%2==0){
        flag=1;
    }
    for(int i=1;i<3;i++){
        ans.push_back(make_pair(i,i+1));
        ans.push_back(make_pair(i+n,i+1+n));
    }
    ans.push_back(make_pair(3,n+1));
    for(int i=4;i+1<=n;i+=2){
        ans.push_back(make_pair(1,i));
        ans.push_back(make_pair(i,i+1));
        ans.push_back(make_pair(1,i+1+n));
        ans.push_back(make_pair(i+n,i+1+n));
    }

    if(flag){
        tr.clear();
        for(int i=1;i<n;i++)tr.insert(i);
        for(int i=2;i<n;i++){
            if(tr.count(n^i^1)){
                int a=n^i^1,b=i;
                if(a==b)continue;
                if(a&1){
                    ans.push_back(make_pair(a+n,n));
                }
                else{
                    ans.push_back(make_pair(a,n));
                }
                if(b&1){
                    ans.push_back(make_pair(b+n,2*n));
                }
                else{
                    ans.push_back(make_pair(b,2*n));
                }
                output();
                return 0;
            }
        }
    }
    else{
        output();
    }
    return 0;
}


Measured memory_bytes: 8560
#include<stdio.h>
#include<string.h>


int main(void){

	int i,n;
	char *p;
	char a[1002];
	char word[]="Hoshino";
	scanf("%d\n",&n);
	for(i = 0;i < n;i++){
        fgets(a,sizeof(a),stdin);
        while((p = strstr(a,word))!=NULL){
            p[6] = 'a';
        }
                printf("%s",a);

    }


return 0;
}

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

ll a[N],b[N];
string s;
int main()
{
    int n,k;
    scanf("%d%d",&n,&k);
    cin>>s;
    int i=0,la=0,lb=0;
    ll x=0,y=0;
    while(i<s.size())
    {
        while(s[i]=='1')
            x++,i++;
        if(x!=0)
            a[++la]=x,x=0;

        while(s[i]=='0')
            y++,i++;
        if(y!=0)
            b[++lb]=y,y=0;
    }
    for(int i=1;i<=la;i++)a[i]+=a[i-1];
    for(int i=1;i<=lb;i++)b[i]+=b[i-1];

    ll ans=0;
    if(k>=lb)
        ans=a[la]+b[lb];
    else
    {
        for(int i=1;i+k-1<=lb;i++)
        {
            int vb=b[i+k-1]-b[i-1];
            int l,r;
            if(s[0]=='1')
                l=i,r=min(i+k,la);
            else
                l=max(1,i-1),r=min(i+k-1,la);
            ans=max(ans,vb+a[r]-a[l-1]);
        }
    }
        cout<<ans;
    return 0;
}


Measured memory_bytes: 1280
using System;
using System.Linq;
using System.Collections.Generic;
using static System.Console;
using System.Text;
using System.IO;
using static System.Math;
namespace AtCoder
{
    class Program
    {
        static public long[] Sarray() { return ReadLine().Split().Select(long.Parse).ToArray(); }
        static public List<long> Slist() { return ReadLine().Split().Select(long.Parse).ToList(); }

        static long Mod = (long)1e9 + 7;
        static void Main(string[] args)
        {
            //SetOut(new StreamWriter(OpenStandardOutput()) { AutoFlush = false });            var N = Sarray()[0];
            var N = Sarray()[0];
            var Li = Slist();
            Li.Sort();
            var ans = 0L;
            for(var i=N-1;0<=i;--i)
            {
                for(var j=i-1;0<=j;--j)
                {
                    var c = Li[(int)i] - Li[(int)j] + 1;
                    var num = j - ~Li.BinarySearch(c, new lb());
                    if (0 < num)
                        ans += num;
                }
            }
            WriteLine(ans);
            //Out.Flush();
        }
        public class lb : IComparer<long>
        {
            public int Compare(long x, long y)
            { return 0 <= x.CompareTo(y) ? 1 : -1; }
        }
    }
}

Measured memory_bytes: 19652
import java.io.IOException;

import java.io.BufferedReader;
import java.io.InputStreamReader;

import java.util.Arrays;

public class Main {
    public static void main(String[] args) throws IOException {
        try (
            BufferedReader reader = new BufferedReader(
                new InputStreamReader(System.in))) {
            final String s = reader.readLine();

            int alp = 26;
            int num = alp;
            int[] a = new int[num];

            Arrays.fill(a, 0);

            for (int i = 0; i < s.length(); i++) {
                if (num == 0) break;
                if (0 == a[s.charAt(i) - 'a']) {
                    num--;
                    a[s.charAt(i) - 'a'] = 1;
                }
            }

            if (num == 0) {
                System.out.println("None");
            } else {
                for (int i = 0; i < alp; i++) {
                    if (a[i] == 0) {
                        System.out.println((char)('a' + i));
                        break;
                    }
                }
            }
        }
    }
}


Measured memory_bytes: 23124
using System;

namespace ABC047_C
{
    class Program
    {
        static void Main(string[] args)
        {
            var s = Console.ReadLine();

            var cnt = 0;
            char current = s[0];
            for (int i = 1; i < s.Length; i++)
            {
                if (current != s[i])
                {
                    current = s[i];
                    cnt++;
                }
            }
            Console.WriteLine(cnt);
        }
    }
}


Measured memory_bytes: 11232
qty, total_money = gets.chomp.split.map(&:to_i)

flag = false
0.upto(qty) do |num_10000|
  break if flag
  0.upto(qty) do |num_5000|
    break if flag
    num_1000 = qty - (num_10000 + num_5000)
    next if num_1000 < 0
    check_money = 10000*num_10000 + 5000*num_5000 + 1000*num_1000
    check_qty = num_10000 + num_5000 + num_1000
    if check_qty == qty && check_money == total_money
      puts "#{num_10000} #{num_5000} #{num_1000}"
      flag = true
    end
    break if flag
  end
end
unless flag
  puts "-1 -1 -1"
end

Measured memory_bytes: 1916
#include<cstdio>
#include<algorithm>
#include<cstring>
#include<iostream>
#include<vector>
#include<cmath>
#include<map> 
#include<string>
#include<queue>
#include<stack> 
#include<bitset>
#include<list>
#include<set>
#include<utility>
#include<iomanip>
#define IO ios::sync_with_stdio(false)
#define eps 1e-7
#define int long long
using namespace std;
int f[1000006],k,n,pos;
char ans[1000006];
int kuai(int x,int y)
{
	int anss=1;
	while(y)
	{
		if(y%2)
		{
			anss=anss*x;
		}
		y/=2;
		x=x*x;
	}
	return anss;
}
signed main()
{
	IO;
	cin>>n;
	while(n)
	{
		k=n%26;
		if(k==0)k=26;
		n-=k;
		ans[++pos]='a'+k-1;
		n/=26;
	}
	for(int i=pos;i>=1;i--)
	{
		cout<<ans[i];
	}
}

Measured memory_bytes: 3652
#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<b;i++)
#define rrep(i,a,b) for(int i=a;i>=b;i--)
#define fore(i,a) for(auto &i:a)
#define all(x) (x).begin(),(x).end()
//#pragma GCC optimize ("-O3")
using namespace std; void _main(); int main() { cin.tie(0); ios::sync_with_stdio(false); _main(); }
typedef long long ll; const int inf = INT_MAX / 2; const ll infl = 1LL << 60;
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; }
//---------------------------------------------------------------------------------------------------
/*---------------------------------------------------------------------------------------------------
　　　　　　　　　　　 ∧＿∧
　　　　　 ∧＿∧ 　（´<_｀ ）　 Welcome to My Coding Space!
　　　　 （ ´_ゝ`）　/　 ⌒i     @hamayanhamayan0
　　　　／　　　＼　 　  |　|
　　　 /　　 /￣￣￣￣/　　|
　 ＿_(__ﾆつ/　    ＿/ .| .|＿＿＿＿
　 　　　＼/＿＿＿＿/　（u　⊃
---------------------------------------------------------------------------------------------------*/














int N, U[201010], V[201010];
//---------------------------------------------------------------------------------------------------
void _main() {
    cin >> N;
    rep(i, 0, N - 1) cin >> U[i] >> V[i];

    ll ans = 0;
    rep(L, 1, N + 1) ans += 1LL * L * (L + 1) / 2;
    rep(i, 0, N - 1) {
        if (U[i] > V[i]) swap(U[i], V[i]);
        ans -= 1LL * U[i] * (N - V[i] + 1);
    }
    cout << ans << endl;
}







Measured memory_bytes: 5204
N,A,B = list(map(int,input().split()))
l=list(map(int,input().split()))

def nCr(n, r):
    """
    Calculate the number of combination (nCr = nPr/r!).
    The parameters need to meet the condition of n >= r >= 0.
    It returns 1 if r == 0, which means there is one pattern
    to choice 0 items out of the number of n.
    """

    # 10C7 = 10C3
    r = min(r, n-r)

    # Calculate the numerator.
    numerator = 1
    for i in range(n, n-r, -1):
        numerator *= i

    # Calculate the denominator. Should use math.factorial?
    denominator = 1
    for i in range(r, 1, -1):
        denominator *= i

    return numerator // denominator

l.sort(reverse = True)
masd = {}
for i in l:
	masd[i] = 0
for i in l:
	masd[i] += 1

res = 0

maxave = 0

task = []

for i in range(A,B+1):
	if maxave < sum(l[:i])/i:
		maxave = sum(l[:i])/i
		task = [i]
	elif maxave == sum(l[:i])/i:
		task.append(i)

for i in task:
	c = 1
	d = {}
	for j in l[:i]:
		d[j] = 0
	for j in l[:i]:
		d[j] += 1

	for j in d.keys():
		c *= nCr(masd[j],d[j])
	res += c

print(maxave)
print(res)










Measured memory_bytes: 3064
n,y=gets.split.map(&:to_i)
a,b,c=0,0,0
i=0
if y>10000*n
  puts "-1 -1 -1"
elsif y<1000*n
  puts "-1 -1 -1"
else
  while y>=n do 
	a,b,c=0,0,0
    if n*10000==y
      a=n
      break
    elsif (n-i)*10000 < y
      a=n-i
      if a<0
        a,b,c=-1,-1,-1
        break
      end
      i.times do |j|
        if a*10000+i*5000 == y
          b=i
          break
        elsif a*10000+j*5000 > y
          a,b,c=-1,-1,-1
          break
        elsif a*10000+j*5000 <= y
	      b=j
          if a*10000+b*5000+(i-j)*1000 == y
            c=i-j
            break
          end
        end
  	  end
      break if a*10000+b*5000+c*1000 == y && a+b+c==n
    end
    i+=1
  end
puts "#{a} #{b} #{c}"
end

Measured memory_bytes: 1916
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef pair <int, int> P;
#define rep( i, n, m ) for(int i = ( n ); i < ( m ); i++)
#define rep_d( i, n, m ) for(int i = ( n ) - 1; i >= ( m ); i--)
#define sort_asc( X ) sort(( X ).begin(), ( X ).end())
#define sort_desc( X ) sort(( X ).begin(), ( X ).end(), greater <>())

template <class T> bool chmax( T& a, T b );
template <class T> bool chmin( T& a, T b );
int* eratosthenes( int N );
bool bit_search( int pattern, int N );
template <class T> void cumulative_sum( T array, size_t N );

const ll INF = 1LL << 60;
const int k_mod = 1e9 + 7;

typedef struct {
	vector <int> to;
	int cost;
	bool is_visited;
} edge;
int main( void ){
	int N; cin >> N;
	rep(i,0,N+1){
		if ((int)((double)i*1.08)==N){
			cout << i << endl;
			return 0;
		}
	}
	cout << ":(\n";
}

int* eratosthenes( int N ){
	int* prime_array = new int[ N + 1 ];
	int lim = N;
	prime_array[ 0 ] = 0;
	prime_array[ 1 ] = 0;
	rep( i, 2, N + 1 ){
		prime_array[ i ] = 1;
	}
	rep( i, 2, lim ){
		if (prime_array[ i ] == 0)
			continue;
		lim = N / i;
		for(int j = i * 2; j < N + 1; j += i){
			prime_array[ j ] = 0;
		}
	}
	return prime_array;
}
template <class T> void cumulative_sum( T array, size_t N ) {
	rep( i, 1, N + 1 ){
		array[ i ] += array[ i - 1 ];
	}
}
template <class T> bool chmax( T& a, T b ) {
	if (a < b){
		a = b; return true;
	}
	return false;
}
template <class T> bool chmin( T& a, T b ) {
	if (a > b){
		a = b; return true;
	}
	return false;
}
bool bit_search( int pattern, int N ){
	int cnt = 0;
	rep( bit, 0, N ){
		if (pattern & ( 1 << bit )){
			cnt++;
		}
	}
	return true;
}


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

int main()
{
    int N, M;

    cin >> N >> M;

    int L[M + 1];
    int R[M + 1];

    for (int i = 1; i <= M; i++)
    {
        cin >> L[i] >> R[i];
    }

    int Lmax = 0;
    int Rmin = pow(10, 5) + 1;

    for (int i = 1; i <= M; i++)
    {
        if (L[i] > Lmax)
        {
            Lmax = L[i];
        }
        if (R[i] < Rmin)
        {
            Rmin = R[i];
        }
    }

    int ans;

    if (Lmax <= Rmin)
    {
        ans = Rmin - Lmax + 1;
    }
    else
    {
        ans = 0;
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 1024
// Q from "https://atcoder.jp/contests/abc085/tasks/abc085_c"

#include<bits/stdc++.h>
using namespace std;
#define INF 1e9
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define ALL(x) (x).begin(), (x).end()
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int, int> pii;
template<typename T1,typename T2> inline void chmin(T1 &a,T2 b){if(a>b) a=b;}
template<typename T1,typename T2> inline void chmax(T1 &a,T2 b){if(a<b) a=b;}
const int MOD = 1000000007;

void solve() {
  int n, y;
  cin >> n >> y;
  rep(i, n+1) {
    rep(j, n+1) {
      if (i + j <= n && 10000 * i + 5000 * j + (1000 * (n - i - j)) == y) {
        cout << i << " " << j << " " << n - i - j;
        return;
      }
    }
  }

  cout << -1 << " " << -1 << " " << -1 << endl;
}

int main() {
  solve();
  return 0;
}

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

int a[3];

signed main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int n;
    cin >> n;
    string s, t;
    cin >> s >> t;
    for (int i = 0; i < n; ++i) {
        cout << s[i] << t[i];
    }
    cout << endl;
    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
    int main(){
        int i=0,x=0,y=0,k;
        int data1[3000];
        int data2[3000];
        int data3[3000];
        int data4[3000];
        while(1){
            x++;
            y++;
            scanf("%d %d",&data1[x],&data2[y]);
            if(data1[x]>=data2[y]){
                data3[x]=data2[y];
                data4[y]=data1[x];
            }if(data1[x]<=data2[y]){
                data3[x]=data1[x];
                data4[y]=data2[y];
            }
            i=i+1;
            if(data1[x] == 0 && data2[y] == 0)break;
        }
        for(k=1;k<i;k++){
            printf("%d %d\n",data3[k],data4[k]);
    }
    return 0;
}

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

int main(){
  string str;
  cin >> str;
  if(str[0] == str[1] || str[1] == str[2] || str[2] == str[3])
    cout << "Bad" << endl;
  else
    cout << "Good" << endl;
  
  return 0;
}

Measured memory_bytes: 256