akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<string>
#include<cstdio>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<ciso646>
#include<random>
#include<map>
#include<set>
#include<bitset>
#include<stack>
#include<unordered_map>
#include<utility>
#include<cassert>
#include<complex>
using namespace std;

//#define int long long
typedef long long ll;

typedef unsigned long long ul;
typedef unsigned int ui;
const ll mod = 998244353;
const ll INF = mod * mod;
typedef pair<int, int>P;
typedef pair<int, bool> sP;
#define stop char nyaa;cin>>nyaa;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
typedef pair<ll, ll> LP;
typedef vector<ll> vec;
typedef long double ld;
typedef pair<ld, ld> LDP;
const ld eps = 1e-8;
const ld pi = acos(-1.0);
typedef vector<vector<ll>> mat;
typedef vector<ll> vec;


void solve() {
	int n; cin >> n;
	vector<int> l(n);
	rep(i, n)cin >> l[i];
	sort(l.begin(), l.end());
	int ans = 0;
	rep(i, n)Rep(j, i + 1, n)Rep(k, j + 1, n)ans += (l[i] + l[j] > l[k]);
	cout << ans << endl;
}


signed main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	//cout << fixed << setprecision(7);
	//init();
	solve();
	//stop
	return 0;
}



Measured memory_bytes: 256
from sys import stdout
import bisect
printn = lambda x: stdout.write(x)
inn = lambda : int(input())
inl   = lambda: list(map(int, input().split()))
inm   = lambda:      map(int, input().split())
DBG = True # and False
BIG = 999999999
R = 10**9 + 7

def ddprint(x):
  if DBG:
    print(x)

def f(x):
    sm = 0
    for i in range(n-1,-1,-1):
        j = bisect.bisect_left(a,x-a[i])
        sm += n-j
        if sm>=m:
            return True
    return False

n,m = inm()
a = inl()
a.sort()
acc = [0]*(n+1)
for i in range(n-1,-1,-1):
    acc[i] = acc[i+1]+a[i]
mn = 2*min(a)
mx = 2*max(a)+1
while mx-mn>=2:
    mid = (mx+mn)//2
    if f(mid):
        mn = mid
    else:
        mx = mid
# mn is the m-th
# sum and cnt upto mn+1
sm = cnt = 0
for i in range(n):
    j = bisect.bisect_left(a,mx-a[i])
    sm += acc[j]+(n-j)*a[i]
    cnt += n-j
print(sm+mn*(m-cnt))


Measured memory_bytes: 55704
#pragma GCC optimize ("O3")
#pragma GCC target ("avx")

#include <bits/stdc++.h>

using namespace std;


using int64 = long long;
const int mod = (1e9 + 7);

const int64 infll = (1LL << 62) - 1;
const int inf = (1 << 30) - 1;

struct IoSetup {
  IoSetup() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(10);
    cerr << fixed << setprecision(10);
  }
} iosetup;


template< typename T1, typename T2 >
ostream &operator<<(ostream &os, const pair< T1, T2 > &p) {
  os << p.first << " " << p.second;
  return os;
}

template< typename T1, typename T2 >
istream &operator>>(istream &is, pair< T1, T2 > &p) {
  is >> p.first >> p.second;
  return is;
}

template< typename T >
ostream &operator<<(ostream &os, const vector< T > &v) {
  for(int i = 0; i < (int) v.size(); i++) {
    os << v[i] << (i + 1 != v.size() ? " " : "");
  }
  return os;
}

template< typename T >
istream &operator>>(istream &is, vector< T > &v) {
  for(T &in : v) is >> in;
  return is;
}

template< typename T1, typename T2 >
inline bool chmax(T1 &a, T2 b) { return a < b && (a = b, true); }

template< typename T1, typename T2 >
inline bool chmin(T1 &a, T2 b) { return a > b && (a = b, true); }

template< typename T = int64 >
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);
}

template< typename F >
struct FixPoint : F {
  FixPoint(F &&f) : F(forward< F >(f)) {}

  template< typename... Args >
  decltype(auto) operator()(Args &&... args) const {
    return F::operator()(*this, forward< Args >(args)...);
  }
};

template< typename F >
inline decltype(auto) MFP(F &&f) {
  return FixPoint< F >{forward< F >(f)};
}


int main() {
  string S;
  cin >> S;
  if(S == "RRR") cout << 3 << "\n";
  else if(S == "RRS" || S == "SRR") cout << 2 << "\n";
  else if(S == "SSS") cout << 0 << "\n";
  else cout << 1 << "\n";
}


Measured memory_bytes: 3636
import sys
input=sys.stdin.readline
n=int(input())
s=input().rstrip()
r=0
l=0
for i in s:
    if i=='(':
        r+=1
    else:
        if r>0:
            r-=1
        else:
            l+=1
ans='('*l+s+')'*r
print(ans)








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

#define rep(i,a,n) for (int i=a;i<=n;i++)
#define per(i,a,n) for (int i=n;i>=a;i--)
#define vi vector<int>
#define pii pair<int,int>
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define all(x) (x).begin(),(x).end()
#define fi first
#define se second
#define sz(x) ((int)(x).size())
#define mod(x) ((x)%MOD)
#define o(X) (1<<(X))
#define oL(X) (1LL<<(X))
#define LL long long
#define ppt(x) __builtin_popcount(x)
using namespace std;
const int INF=0x3f3f3f3f,N=1e6+5,MOD=1e9+7;
const LL INF_LL=0x3f3f3f3f3f3f3f3fLL;

template<typename T>
inline int getplc(T x,int y) { return (x>>y)&1; }
template<typename T>
T square(T x) {return x*x;}

LL qpow(LL a,LL b=MOD-2,LL _MOD=MOD){
	LL res=1;
	for(;b;b>>=1,a=a*a%_MOD){
		if(b&1)res=res*a%_MOD;
	}
	return res;
}

template <typename T>
T Smax(T x) { return x; }
template<typename T, typename... Args>
T Smax(T a, Args... args) {
	return max(a, Smax(args...));
}
template <typename T>
T Smin(T x) { return x; }
template<typename T, typename... Args>
T Smin(T a, Args... args) {
	return min(a, Smin(args...));
}

template <typename T>
#define errorl(args...) {  \
	string _s = #args;   \
	replace(_s.begin(), _s.end(), ',', ' ');  \
    stringstream _ss(_s);  \
    istream_iterator<string> _it(_ss);  \
    errl(_it, args);  \
}
void errl(istream_iterator<string> it) {}
template<typename T, typename... Args>
void errl(istream_iterator<string> it, T a, Args... args) {
	cerr << *it << " = " << a << endl;
	errl(++it, args...);
}
#define error(args...) {  \
    string _s = #args;  \
    replace(_s.begin(), _s.end(), ',', ' ');  \
    stringstream _ss(_s);  \
    istream_iterator<string> _it(_ss);  \
    err(_it, args);  \
    cerr<<endl; \
}
void err(istream_iterator<string> it) {}
template<typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args) {
	cerr << *it << "=" << a << " # ";
	err(++it, args...);
}


char s[10][10];
int suc;
int n, m;

void dfs(int x, int y) {
	if (s[x][y] != '#') return ;
	s[x][y] = '.';
	if (x == n && y == m) {
		suc = 1;
		return ;
	}
	if (s[x][y + 1] == '#') dfs(x, y + 1);
	else if (s[x + 1][y] == '#') dfs(x + 1, y);
}

void Solve() {
	cin >> n >> m;
	for (int i = 1; i <= n; i++) {
		cin >> s[i] + 1;
	}
	dfs(1, 1);

	for (int i = 1; i <= n; i++) {
		for (int j = 1; j <= m; j++) if (s[i][j] == '#') suc = 0;
	}

	if (suc) cout << "Possible" << '\n';
	else cout << "Impossible" << '\n';
}


int main() {
#ifndef ONLINE_JUDGE
	freopen("in.txt","r",stdin);
//  freopen("o1.txt","w",stdout);
#endif
	ios::sync_with_stdio(false);cin.tie(0),cout.tie(0);
	Solve();
	return 0;
}


Measured memory_bytes: 3632
import java.util.*;
public class Main {
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    
    int a = sc.nextInt();
    int b = sc.nextInt();
    
	int aPlusB = a + b;
    
    if (a % 3 == 0 || b % 3 == 0 || aPlusB % 3 == 0) {
      System.out.println("Possible");
    } else {
      System.out.println("Impossible");
    }
  }
}

Measured memory_bytes: 23764
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <string>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <list>
using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define p(x) cout << x << endl;

#define MOD 1000000007
#define PI 3.14159265359

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

    ll n;
    cin >> n;
    vector<ll> l;

    l.push_back(2);
    l.push_back(1);

    for(int i = 2; i <= n; i++){
        ll num = l[i - 2] + l[i - 1];
        l.push_back(num);
    }

    p(l[n]);
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N, X;
  cin >> N;
  for (int i = 0;i < N;i++){
    int L,R;
    cin >> L >> R;
    X = X + (R - L) + 1;
  }
  cout << X << endl;
}

Measured memory_bytes: 256
S = input()
T = input()

flag = 1

lengthS = len(S)
lengthT = len(T)

if lengthT - lengthS != 1:
  flag = 0
else:
  for i in range(lengthS):
    if S[i] != T[i]:
      flag = 0

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

Measured memory_bytes: 9056
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		try (Scanner sc = new Scanner(System.in)) {
			int w = sc.nextInt();
			int n = sc.nextInt();
			int[] values = new int[w];
			for (int i = 0; i < values.length; i++) {
				values[i] = i + 1;
			}
			for (int i = 0; i < n; i++) {
				String str = sc.next();
				String[] ab = str.split(",");
				int a = Integer.parseInt(ab[0]) - 1;
				int b = Integer.parseInt(ab[1]) - 1;
				int temp;
				temp = values[a];
				values[a] = values[b];
				values[b] = temp;

			}
			for (int i = 0; i < w; i++) {
				System.out.println(values[i]);
			}
		}
	}

}


Measured memory_bytes: 26216
#include <iostream>
#include <string>

using namespace std;

int main(){
  string s;
  cin >> s;
  int counter = 0;
  if (s[0] == '1') ++counter;
  if (s[1] == '1') ++counter;
  if (s[2] == '1') ++counter;

  cout << counter << endl;

}

Measured memory_bytes: 256
# Reference: https://note.nkmk.me/python-union-find/
class UnionFind:
    # if x is root: self.parents[x] = -(the number of the group nodes)
    # else: self.parents[x] = the parent of x
    def __init__(self, n):
        self.n = n
        self.parents = [-1] * n

    # return the parent of x
    def find(self, x):
        history = []
        while self.parents[x] >= 0:
            history.append(x)
            x = self.parents[x]
        for node in history:
            self.parents[node] = x
        return x

    # merge the group of x and the group of y
    def union(self, x, y):
        x = self.find(x)
        y = self.find(y)
        if x == y:
            return
        if self.parents[x] > self.parents[y]:
            x, y = y, x
        self.parents[x] += self.parents[y]
        self.parents[y] = x

    # return the size of the group of x
    def size(self, x):
        return -self.parents[self.find(x)]

from sys import stdin
input = stdin.buffer.readline

def main():
    n = int(input())

    l = [0] * n
    for i in range(n):
        x, y = map(int, input().split())
        l[x-1] = (y-1, i)

    uf = UnionFind(n)
    roots = []

    for y, i in l:
        if len(roots) == 0 or roots[-1][0] > y:
            roots.append((y, i))
        else:
            new_y = roots[-1][0]
            while len(roots) > 0 and roots[-1][0] < y:
                old_y, old_i = roots.pop()
                uf.union(i, old_i)
            roots.append((new_y, i))

    # O(uf.size(i)) = 1
    for i in range(n):
        print(uf.size(i))

main()


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

using namespace std;

#define all(v)				((v).begin()), ((v).end())
#define allr(v)				((v).rbegin()), ((v).rend())
#define sz(v)				((int)((v).size()))
#define ll long long
#define pb					push_back
#define fIO ios_base::sync_with_stdio(0);cin.tie(0);

const ll oo = 1e8;
const double pi = 3.1415926535897;


const double EPS = (1e-7);
int dcmp(double x, double y) {	return fabs(x-y) <= EPS ? 0 : x < y ? -1 : 1;	}


typedef vector<int>                vi;
typedef vector<pair<int,int>>      vii;
typedef vector<ll>                 vll;
typedef vector<double>             vd;
typedef vector< vi >               vvi;
typedef vector< vd >               vvd;
typedef vector<string>             vs;
typedef pair<int, int>             pii;

/**
    * PLEASEEE READDD PROBLEEEM CARFULLY ****
    * Always check for OVERFLOW ll vs int
    * Always check for array bounds
    * Check for function return
    * READ OUTPUT SECTION AGAIN!!!
**/

struct edge{
    int from, to, w;

    edge(){}
    edge(int x, int y, int we): from(x), to(y), w(we){}

    bool operator < (const edge &rhs) const{
        return w > rhs.w;
    }

};

const int N = 2999 + 5;

double dp[N][N];
double p[N];
int n;

double sol(int i, int hd) {
    if(i == n) {
        if(hd > n - hd) return 1.0;
        return 0;
    }

    double &ret = dp[i][hd];
    if(ret < 1.8) return ret;

    ret = (1 - p[i]) * sol(i + 1, hd);
    ret += p[i] * sol(i + 1, hd + 1);

    return ret;
}

int main(){
    fIO

//    freopen("", "r", stdin);
//    freopen("", "w", stdout);

    for(int i = 0; i < N; i++) for(int j = 0; j < N; j++) dp[i][j] = 2.0;
    cin >> n;
    for(int i = 0; i < n; i++) cin >> p[i];

    cout << fixed << setprecision(12) << sol(0, 0) << "\n";
}








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

const int MOD = 1000000007;
int C[2001][2001];
int n, k;
void pre() {
  for (int i = 0; i <= n; ++i) {
    for (int j = 0; j <= i; ++j) {
      if (j == 0 || j == i) {
        C[i][j] = 1;
      } else {
        C[i][j] = (C[i - 1][j - 1] + C[i - 1][j]) % MOD;
      }
    }
  }
}

int H(int i, int j) {
  if (i == 0 && j == 0) return 1;
  if (i <= 0 || j <= 0) return 0;
  if (i < j) return 0;
  return C[i - 1][j - 1];
}

int main() {
  cin >> n >> k;
  pre();
  for (int j = 1; j <= k; ++j) {
    int sum = 0;
    sum = (sum + (long)H(k, j) * H(n - k, j - 1) % MOD) % MOD;
    sum = (sum + (long)H(k, j) * H(n - k, j) % MOD) % MOD;
    sum = (sum + (long)H(k, j) * H(n - k, j) % MOD) % MOD;
    sum = (sum + (long)H(k, j) * H(n - k, j + 1) % MOD) % MOD;
    cout << sum << endl;
  }
}

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

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

  //ここから
  int x;
  for (int i = 1; i <= 5; i++)
  {
    std::cin >> x;
    if (x == 0)
    {
      std::cout << i;
      break;
    }
  }
}

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

main(){
int N,a,b,c,d;
  a = 0;
  b = 0;
  c = 0;
  d = 0;
  cin >> N;
  a = N /1000;
  N -= 1000* a;
  b = N /100;
  N -= 100*b;
  c = N /10;
  N -= 10*c;
  d = N;
  
  if ((a-b)*(b-c)*(c-d) == 0){
    cout << "Bad" << endl;
  }else{
    cout << "Good" << endl;
  }
  
  //cout << N << a << b << c << d << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
    char ch[100005];
    int cnt=0,cnt2=0,cnt3=0,op=0,b,i;
    cin>>ch;
    b=strlen(ch);
    for(i=0;i<b;i++)
    {
        if(ch[i]=='0')
        {
            cnt=5;
        }
        if(ch[i]=='1')
        {
            cnt=10;
        }
        if(cnt==5)
        {
            cnt2++;
        }
        if(cnt==10)
        {
            cnt3++;
        }
        if(cnt2==1 && cnt3== 1 && ch[i]!=ch[i+1])
        {
            cnt2=0;
            cnt3=0;
        }
        if(cnt2>1)
        {
            op++;
            ch[i]='1';
            cnt2=0;
            cnt3=1;
        }
        if(cnt3>1)
        {
            op++;
            ch[i]='0';
            cnt2=1;
            cnt3=0;
        }

    }
    cout<<op<<endl;

}


Measured memory_bytes: 384
import java.util.*;

class Main{
  public static void main(String[] args){
    Scanner sc=new Scanner(System.in);
    int n=sc.nextInt();
    int[] a=new int[n];
    for(int i=0;i<n;i++){
      a[i]=sc.nextInt();
    }
    long ans=Long.MAX_VALUE;
    for(int t=-100;t<=100;t++){
      long cost=0;
      for(int i=0;i<n;i++){
        cost+=(a[i]-t)*(a[i]-t);
      }
      ans=Math.min(ans,cost);
    }
    System.out.println(ans);
  }
}

Measured memory_bytes: 21588
def solve(s,p):
    if s[0]!='[':
        return[p//1000,p//100%10,p//10%10,p%10][ord(s[0])-ord('a')]
    i=3
    cs=s[2]=='['
    ce=0
    while cs!=ce:
        if s[i]=='[':
            cs+=1
        elif s[i]==']':
            ce+=1
        i+=1
    j=i+1
    cs=s[i]=='['
    ce=0
    while cs!=ce:
        if s[j]=='[':
            cs+=1
        elif s[j]==']':
            ce+=1
        j+=1
    l=solve(s[2:i],p)
    r=solve(s[i:j],p)
    if s[1]=='+':
        return l|r
    elif s[1]=='*':
        return l&r
    else:
        return l^r
while True:
    s=input()
    if s=='.':break
    p=int(input())
    a=solve(s,p)
    c=0
    for i in range(10000):
        if solve(s,i)==a:
            c+=1
    print(a,c)


Measured memory_bytes: 5612
//Never stop chasing!-MdSourav.
#include <bits/stdc++.h>

#define yes            cout<<"YES"<<endl
#define no             cout<<"NO"<<endl
#define sz(x)          x.size()
#define ll                    long long int
#define ls             long int
#define start          ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define test           int t;cin>>t;while(t--)
#define f(i, a, n)     for(int i=a; i<n;i++)
#define gcd(a,b)       __gcd(a,b)
#define lcd(a,b)       (a*b)/gcd(a,b)
#define pb             push_back
#define mp(x,y)        make_pair(x,y)
#define rsrt(v)        sort(v.begin(),v.end(),greater<int>())
#define srt(v)         sort(v.begin(),v.end())
#define basrt(a,n)     sort(a,a+n,greater<int>())
#define asrt(a,n)      sort(a,a+n)
#define fact(n)        ll x=1;for(ll i=1;i<=n;i++){x=(x*i);}
#define F              first
#define S              second
#define deb(x)         cout << #x << ": " << x << endl;
#define enter(v,n)     for(ll i=0;i<n;i++){ll x;cin>>x;v.pb(x);}
#define INF 	       1000000007
#define unique(v)      v.erase(unique(v.begin(),v.end()),v.end())
using namespace std;

double pi=3.14159265358979323846;
typedef vector<ll> vll ;
typedef vector<int> vii ;

template<typename T>
ostream& operator<<(ostream &os, const vector<T> &v)
{
    os << '{';
    for (const auto &x : v) os << " " << x;
        return os << '}';
}

void solve()
{

	 ll n;
	 cin>>n;
	 string s="";
	 while(n>0)
	 {
	 	ll x=n%26;
	 	n=n/26;
	 	if(x==0)
		{
			n--;
			s=s+'z';
			//deb(s);
		}
		else
		{
			s=s+char(97+x-1);
			//deb(s);
		}
	 }
	 reverse(s.begin(),s.end());
	 cout << s;




}
int main()
{
    ios_base::sync_with_stdio(0); cin.tie(0);cout.tie(0);
    ll test_case=1;
    //cin>>test_case;
    while(test_case--)
	{
		solve();
	}

	return 0;
}

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


using namespace std;  
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,n) for(int i=0;i<(n);i++)  
typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
#define pii pair<int,int>
#define piii pair<int,pii>
#define mp make_pair
#define pb push_back  
#define ALL(a) (a).begin(),(a).end()
#define FST first
#define SEC second  
const int INF = (INT_MAX/2);
const double eps = 1e-14;
const double PI = M_PI;  
#define DEB cout<<"!"<<endl
#define SHOW(a,b) cout<<(a)<<" "<<(b)<<endl  
#define DIV 1000000007

int main(){
	int a,b,c;
	cin >> a >> b >> c;
	
	cout << ((a <= c && b >= c)?("Yes"):("No")) << endl;
	
	return 0;
}

Measured memory_bytes: 256
class UnionFind():
    def __init__(self, n):
        self.n = n
        self.parents = [-1] * n

    def find(self, x):
        if self.parents[x] < 0:
            return x
        else:
            self.parents[x] = self.find(self.parents[x])
            return self.parents[x]

    def union(self, x, y):
        x = self.find(x)
        y = self.find(y)

        if x == y:
            return

        if self.parents[x] > self.parents[y]:
            x, y = y, x

        self.parents[x] += self.parents[y]
        self.parents[y] = x

    def size(self, x):
        return -self.parents[self.find(x)]

    def same(self, x, y):
        return self.find(x) == self.find(y)

    def members(self, x):
        root = self.find(x)
        return [i for i in range(self.n) if self.find(i) == root]

    def roots(self):
        return [i for i, x in enumerate(self.parents) if x < 0]

    def group_count(self):
        return len(self.roots())

    def all_group_members(self):
        return {r: self.members(r) for r in self.roots()}

    def __str__(self):
        return '\n'.join('{}: {}'.format(r, self.members(r)) for r in self.roots())
    
def main():    
    N, M = map(int, input().split())
    AB = [[int(x) for x in input().split()] for _ in range(M)]
    
    uf = UnionFind(N)
    
    for a, b in AB:
        uf.union(a - 1, b - 1)
        
    print(uf.group_count() - 1)
    
if __name__ == '__main__':
    main()

Measured memory_bytes: 27740
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<bitset>
#include<set>
#include<map>
#include<stack>
#include<queue>
#include<deque>
#include<list>
#include<iomanip>
#include<cmath>
#include<cstring>
#include<functional>
#include<cstdio>
#include<cstdlib>
using namespace std;

#define repr(i, a, b) for (int i = (int)(a); i < (int)(b); i++)
#define rep(i, n) repr(i, 0, n)
#define INF 2e9
#define MOD 1000000007
//#define MOD 998244353
#define LINF (long long)4e18
#define jck 3.141592

const double EPS = 1e-10;

using ll = long long;
using Pi = pair<int,int>;
using Pl = pair<ll,ll>;

struct Combination{
    vector<long long> _fac,_finv,_inv;
    const int m = MOD;

    Combination(int sz) : _fac(sz),_finv(sz),_inv(sz){
        _fac[0] = _fac[1] = 1;
        _finv[0] = _finv[1] = 1;
        _inv[1] = 1;
        for(int i = 2; i <= sz; i++){
            _fac[i] = _fac[i-1]*i%m;
            _inv[i] = m-_inv[m%i]*(m/i)%m;
            _finv[i] = _finv[i-1]*_inv[i]%m;
        }
    }

    inline long long fac(int n){return _fac[n];}
    inline long long inv(int n){return _inv[n];}
    inline long long finv(int n){return _finv[n];}

    long long comb(int n,int k){
        if(n < k) return 0;
        if(n < 0 || k < 0) return 0;
        return _fac[n]*(_finv[k]*_finv[n-k]%m)%m;
    }
};

Combination C(3000000);

ll f(int a, int b) {
    return C.comb(a+b,b);
}

ll g(int a, int b) {
    ll res = 0;
    repr(i,1,a+1){
        res += f(i,b);
        res %= MOD;
    }
    rep(i,b+1){
        res += f(a,i);
        res %= MOD;
    }
    return res;
}

int main(){
    int r1,c1,r2,c2; cin >> r1 >> c1 >> r2 >> c2;
    ll ans = ((g(r2,c2)-g(r1-1,c2)-g(r2,c1-1))%MOD+g(r1-1,c1-1))%MOD;
    if(ans < 0) ans += MOD;
    cout << ans << endl;

}



Measured memory_bytes: 73288
#include <bits/stdc++.h>
using namespace std;
#define fi first
#define se second
#define mp make_pair
#define gc getchar
#define pb push_back
#define eb emplace_back
#define all(x) (x).begin(),(x).end()
#define x1 uvuvwevwevwe
#define y1 onyetenyevwe
#define x2 ugwemubwem
#define y2 ossas
typedef long long LL;
typedef long double LD;
typedef pair<int,int> pii;
template <typename T> void scan(T &angka){
	angka=0;char input=gc();T kali=1;
	while(!(48<=input&&input<=57)){	if(input=='-')	kali=-1;input=gc();}
	while(48<=input&&input<=57)	angka=(angka<<3)+(angka<<1)+input-48,input=gc();angka*=kali;
}
template <typename T1,typename T2> void scan(T1 &angka1,T2 &angka2){
	scan(angka1);scan(angka2);
}
int n,a,b;
int main()
{
	scan(n);
	scan(a,b);
	if((abs(b-a)+1)%2==0)
		cout<<"Borys"<<endl;
	else
		cout<<"Alice"<<endl;
}

Measured memory_bytes: 256
#include <cstdio>
const long long mod = 1000000007;
long long sum[200010], p[200010];
long long dp[200010];
int main() {
    int n, c;
    scanf("%d",&n);
    dp[0] = 1;
    for(int i = 1; i <= n; i++) {
        scanf("%d",&c);
        
        if(p[c] == 0) {
            p[c] = i;
            
            dp[i] += dp[i - 1];
            dp[i] %= mod;
        }
        else if(i - p[c] > 1) {
            sum[c] += dp[p[c] - 1];
            sum[c] %= mod;
            
            dp[i] += sum[c];
            dp[i] %= mod;
            
            p[c] = i;
            
            dp[i] += dp[i - 1];
            dp[i] %= mod;
        }
        else {
            n--;
            i--;
        }
    }
    printf("%lld\n", dp[n]);
    return 0;
}

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

int main() {

  int k, a, b;
  cin >> k >> a >> b;
  
  if(b - a + 2 > k){
    cout << "OK";
  }
  
  else{
  int c, d;
  c = a % k;
  d = b % k;
     if(c == 0 || d == 0) {
       cout << "OK";
     }
     else if(c <= d) {
       cout << "NG";
     }
    else if(d < c) {
       cout << "OK";
     }
       
    
    
    
    
  }
  
}

Measured memory_bytes: 3588
#include<bits/stdc++.h>
using namespace std;
int main () {
  int N;
  cin >> N;
  int count = 0;
  for (int i = 0; i < N; i ++){
    int li, ri;
    cin >> li >> ri;
    count += ri - li + 1;
  }
  cout << count << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef priority_queue<int>PQ;
typedef long long LL;
int main(void){
	int n,m;
	int i;
	int x;
	PQ que;
	LL sum;
	cin>>n>>m;
	for(i=0;i<n;i++){
		cin>>x;
		que.push(x);
	}
	for(i=0;i<m;i++){
		x=que.top();
		que.pop();
		x/=2;
		que.push(x);
	}
	sum=0;
	while(!que.empty()){
		sum+=(LL)que.top();
		que.pop();
	}
	cout<<sum<<endl;
	return 0;
}

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

int main(){
  int n;
  int ans = 0;
  while(1){
    ans = 0;
    cin >> n;
    if(n == 0)break;
    while(n){
      n = n/5;
      ans += n;
    }
    cout << ans << endl;

  }
}

Measured memory_bytes: 1160
a = [list(map(int,input().split()))for i in range(3)]
x = [10,0,0]
y = [0,0,0]

for i in range(3):
    y[i] = a[0][i]-x[0]

for i in range(3):
    x[i] = a[i][0]-y[0]

flag = True

for i in range(3):
    for j in range(3):
        if a[i][j] != x[i]+y[j]:
            flag=False

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



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

using namespace std;

using ll = long long int;
using ld = long double;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
template<typename Q_temp>
using smaller_queue = priority_queue <Q_temp, vector<Q_temp>, greater<Q_temp> >;

const int INF = 1000000000;
const ll LINF = (ll) 4000000000000000000;
const ll MOD = (ll) 1000000007;
const double PI = acos(-1.0);
const int limit = 100010;

#define REP(i,m,n) for(ll i = m; i < (ll)(n); ++i)
#define rep(i,n) REP(i, 0, n)
#define MP make_pair
#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 NP(v) next_permutation(v.begin(),v.end())
//------------------------------------------------------

class UnionFind {
public:
    vector<int> par, sizes;

    UnionFind(int n) : par(n), sizes(n, 1) {
        rep(i, n) par[i] = i;
    }

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

    void unite(int x, int y) {
        x = root(x);
        y = root(y);
        if (x == y) return;
        if (sizes[x] < sizes[y]) swap(x, y);
        par[y] = x;
        sizes[x] += sizes[y];
    }

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

    int size(int x) {
        return sizes[root(x)];
    }
};

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

    ll n, m;
    cin >> n >> m;
    if (m == n - 1) {
        printf("0\n");
        return 0;
    }

    UnionFind uf(n);
    ll a[n];
    rep(i, n) cin >> a[i];

    rep(i, m) {
        int x, y;
        cin >> x >> y;
        uf.unite(x, y);
    }

    set<int> root_set;
    map<ll, smaller_queue<pll> > mp_s;
    smaller_queue<pll> all;
    bool used[n] = {};

    rep(i, n) {
        root_set.insert(uf.root(i));
        mp_s[uf.root(i)].push(MP(a[i], i));
        all.push(MP(a[i], i));
    }

    for (auto r : root_set) {
        int t = mp_s[r].top().second;
        used[t] = true;
    }
    int used_cnt = root_set.size();

    rep(i, n) {
        if (used_cnt == 2 * (n - m - 1)) break;
        ll t = all.top().second;
        all.pop();
        if (used[t]) continue;
        used[t] = true;
        used_cnt++;
    }

    ll cost = 0;
    rep(i, n) if (used[i]) cost += a[i];

    if (used_cnt < 2 * (n - m - 1)) cout << "Impossible" << endl;
    else cout << cost << endl;
    return 0;

}



Measured memory_bytes: 19056
package main

import (
  "fmt"
  "math"
)

func main() {
  var N float64
  fmt.Scan(&N)
  tmp := math.Floor(N/1.08)
  var i float64
  i = 0
  for {
    if math.Floor(float64(tmp+i)*1.08) == N {
      fmt.Println(tmp+i)
      break
    }
    i += 1
    if math.Floor(float64(tmp+i)*1.08) > N {
      fmt.Println(":(")
      break
    }
  }
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using P = pair<ll, ll>;
using Pld = pair<ld, ld>;
using Vec = vector<ll>;
using VecP = vector<P>;
using VecB = vector<bool>;
using VecC = vector<char>;
using VecD = vector<ld>;
using VecS = vector<string>;
using Graph = vector<VecP>;
template <typename T>
using Vec1 = vector<T>;
template <typename T>
using Vec2 = vector<Vec1<T> >;
#define REP(i, m, n) for(ll i = (m); i < (n); ++i)
#define REPN(i, m, n) for(ll i = (m); i <= (n); ++i)
#define REPR(i, m, n) for(ll i = (m)-1; i >= (n); --i)
#define REPNR(i, m, n) for(ll i = (m); i >= (n); --i)
#define rep(i, n) REP(i, 0, n)
#define repn(i, n) REPN(i, 1, n)
#define repr(i, n) REPR(i, n, 0)
#define repnr(i, n) REPNR(i, n, 1)
#define all(s) (s).begin(), (s).end()
#define pb push_back
#define fs first
#define sc second
template <typename T>
bool chmax(T &a, const T b){if(a < b){a = b; return true;} return false;}
template <typename T>
bool chmin(T &a, const T b){if(a > b){a = b; return true;} return false;}
template <typename T>
ll pow2(const T n){return (1LL << n);}
template <typename T>
void cosp(const T n){cout << n << ' ';}
void co(void){cout << '\n';}
template <typename T>
void co(const T n){cout << n << '\n';}
template <typename T1, typename T2>
void co(pair<T1, T2> p){cout << p.fs << ' ' << p.sc << '\n';}
template <typename T>
void co(const Vec1<T> &v){for(T i : v) cosp(i); co();}
template <typename T>
void co(initializer_list<T> v){for(T i : v) cosp(i); co();}
template <typename T>
void ce(const T n){cerr << n << endl;}
void sonic(){ios::sync_with_stdio(false); cin.tie(0);}
void setp(const ll n){cout << fixed << setprecision(n);}
constexpr int INF = 1e9+1;
constexpr ll LINF = 1e18+1;
constexpr ll MOD = 1e9+7;
// constexpr ll MOD = 998244353;
constexpr ld EPS = 1e-11;
const double PI = acos(-1);

int main(void){
	ll n;
	cin >> n;
	string s;
	cin >> s;

	ll l = 0, r = n - 1, ans = 0;
	while (l < r) {
		while (l < n && s[l] == 'R') {
			l++;
		}
		while (r >= 0 && s[r] == 'W') {
			r--;
		}

		if (l < r) {
			ans++;
			l++;
			r--;
		}
	}
	co(ans);

	return 0;
}


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

const int N = (int) 2e6 + 10 ;
const int inf = (int) 2e9 ;

long long n , k , cnt[N] ;

int main(){
    scanf("%lld %lld" , &n , &k ) ;
    memset(cnt , 0 , sizeof(cnt)) ;
    for( int i = 1 ; i <= n ; i++ ) ++cnt[i % k] ;
    long long ans = 0 ;
    for( long long i = 1 ; i <= n ; i++ ) {
        long long b = (1000000LL * k - i) % k ;
        long long c = (1000000LL * k - i) % k ;
        if( (b + c) % k == 0 ) {
            ans += (cnt[b] * cnt[c]) ;
        }
    }
    printf("%lld\n" , ans ) ;
    return 0 ;
}


Measured memory_bytes: 15872
#include <bits/stdc++.h>
#define rep(i,n) for (int i = (0); i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define rng(x) (x).begin(),(x).end()
#define rrng(x) (x).rbegin(),(x).rend()
#define limit(x,l,r) max(l,min(x,r))
#define lims(x,l,r) (x = max(l,min(x,r)))
#define isin(x,l,r) ((l) <= (x) && (x) < (r))
#define show(x) cout << #x << " = " << (x) << endl
#define show2(x,y) cout << #x << " = " << (x) << ", " << #y << " = " << (y) << endl
#define show3(x,y,z) cout << #x << " = " << (x) << ", " << #y << " = " << (y) <<  ", " << #z << " = " << (z) << endl
#define showv(v) rep(i,v.size()) printf("%d%c", v[i], i==v.size()-1?'\n':' ')
#define showv2(v) rep(j,v.size()) showv(v[j])
#define showt(t,n) rep(i,n) printf("%d%c", t[i], i==n-1?'\n':' ')
#define showt2(t,r,c) rep(j,r) showt(t[j],c)
#define showvp(p) rep(i,p.size()) printf("%d %d\n", p[i].first, p[i].second);
#define printv(v) rep(i,v.size()) printf("%d\n", v[i])
#define printt(t,n) rep(i,n) printf("%d\n", t[i])
#define incl(v,x) find(rng(v),x)!=v.end()
#define incls(s,c) s.find(c)!=string::npos
#define fi first
#define se second
#define pb push_back
#define eb emplace_back
#define sz(x) (int)(x).size()
#define pcnt __builtin_popcountll
#define bit(n,k) ((n>>k)&1) // nのk bit目
#define bn(x) ((1<<x)-1)
#define dup(x,y) (((x)+(y)-1)/(y))
#define newline puts("")
#define uni(x) x.erase(unique(rng(x)),x.end())
#define SP << " " <<
#define v(T) vector<T>
#define vv(T) v(v(T))
using namespace std;
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vl = vector<ll>;
using vs = vector<string>;
using P = pair<int, int>;
using T = tuple<int, int, int>;
using vp = vector<P>;
using vt = vector<T>;
const int mod = 1000000007;
const double EPS = 1e-9;
const int INF = (1<<30)-1;
//const ll INF = (1LL<<62)-1;
#define dame { puts("No"); return 0;}
#define yn {puts("Yes");}else{puts("No");}
inline int in() { int x; scanf("%d",&x); return x;}
template<typename T>inline ll suma(const v(T)& a) { ll res(0); for (auto&& x : a) res += x; return res;}
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; }

int main () {
  int n;
  cin >> n;
  vi a(n);
  rep(i,n) cin >> a[i];
  
  rep(i,n) {
    if (a[i]%2 == 0) {
      if (a[i]%3 != 0 && a[i]%5 != 0) {
        puts("DENIED");
        return 0;
      }
    }
  }
  puts("APPROVED");
  return 0;
}

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


int main() {
    string o, e;
    cin >> o >> e;
    for (int i = 0; i < o.size(); i++) {
        cout << o[i];
        if (i < e.size()) {
            cout << e[i];
        }
    }
    return 0;
}


Measured memory_bytes: 256
N=int(input())
S=[int(input()) for i in range(N)]
mod=998244353
def add(a,b):
    return (a+b)%mod
def sub(a,b):
    return (a-b)%mod
def mul(a,b):
    return ((a%mod)*(b%mod))%mod
def pow(x,y):
    if y==0:
        return 1
    elif y==1:
        return x%mod
    elif y%2==0:
        return pow(x,y//2)**2 % mod
    else:
        return pow(x,y//2)**2 * x % mod
def div(a,b):
    return mul(a,pow(b,mod-2))

sum_S=sum(S)
dp=[[0]*(sum_S+1) for i in range(N)]
dp2=[[0]*(sum_S//2+1) for i in range(N)]

dp[0][0]=2
dp[0][S[0]]=1
dp2[0][0]=1
dp2[0][S[0]]=1
for i in range(1,N):
    for j in range(sum_S+1):
        dp[i][j]=mul(dp[i-1][j],2)
        if j-S[i]>=0 and dp[i-1][j-S[i]]!=0:
            dp[i][j]=add(dp[i][j],dp[i-1][j-S[i]])

        if j<=sum_S//2:
            dp2[i][j]=dp2[i-1][j]
            if j-S[i]>=0 and dp2[i-1][j-S[i]]!=0:
                dp2[i][j]=add(dp2[i][j],dp2[i-1][j-S[i]])

if sum_S%2==0:
    print((pow(3,N)-sum(dp[N-1][sum_S//2:])*3+dp2[N-1][-1]*3)%mod)
else:
    print((pow(3,N)-sum(dp[N-1][sum_S//2+1:])*3)%mod)


Measured memory_bytes: 351496
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
#define rrep(i,n) for(int i=1;i<=n;i++)
# define ALL(x) (x).begin(), (x).end()
# define SZ(x) ((int)(x).size())
# define pb push_back
using namespace std;

int n;
vector<int> q(30);
bool rec(int d,int t){
    if(t==0) return true;
    if(d==n || t<0) return false;
    return rec(d+1,t)||rec(d+1,t-q[d]);
}


int main(){
    cin>>n;
    rep(i,n) cin>>q[i];
    int m;
    cin>>m;
    vector<int> a(m);
    rep(i,m) cin>>a[i];

    rep(i,m) cout<<(rec(0,a[i])?"yes":"no")<<endl;
    
    return 0;
}


Measured memory_bytes: 3100
#include<bits/stdc++.h>
#define inf 10000007
#define xx first
#define yy second
using namespace std;
int cst[1003][1003];
char str[1003][1003];
typedef pair<int, int>pi;
deque<pi>dq;
int main()
{
    int n, m, r1, c1, r2, c2;
    scanf("%d %d %d %d %d %d", &n, &m, &r1, &c1, &r2, &c2);
    for(int i=0; i<n; i++)scanf("%s", str[i]);
    r1--, c1--;
    r2--, c2--;
    for(int i=0; i<n; i++)
    for(int j=0; j<m; j++)
    cst[i][j]= inf;
    dq.push_front({r2, c2});
    cst[r2][c2]= 0;
    while(!dq.empty())
    {
        pi p= dq.front();
        dq.pop_front();
        int x= p.xx;
        int y= p.yy;
        for(int i=-2; i<=2; i++)
        for(int j=-2; j<=2; j++)
        if(x+i>=0 && x+i<n && y+j>=0 && y+j<m && str[x+i][y+j]=='.' && cst[x+i][y+j]>cst[x][y]+((abs(i)+abs(j))>1))
        {
            cst[x+i][y+j]= cst[x][y]+((abs(i)+abs(j))>1);
            if((abs(i)+abs(j))>1)dq.push_back({x+i, y+j});
            else dq.push_front({x+i, y+j});
        }
    }
    if(cst[r1][c1]==inf)cst[r1][c1]= -1;
    printf("%d\n", cst[r1][c1]);
    return 0;
}


Measured memory_bytes: 8728
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
using namespace __gnu_pbds;
using namespace std;
 
#define ff                  first
#define ss                  second
#define endl                "\n"
#define loop(i,s,e)         for(int i=s;i<e;i++)
#define int                 long long
#define vi                  vector<int> 
#define S(v)                sort(v.begin(),v.end())
#define RS(v)               sort(v.rbegin(),v.rend())
#define R(v)                reverse(v.begin(),v.end())
#define mxpq(T)             priority_queue <T>
#define mnpq(T)             priority_queue<T,vector<T>,greater<T>>
#define prv(v)              for(auto &x : v)cout << x << " ";
#define piirv(v)            for(auto &x : v)cout << x.ff << " " << x.ss << endl;
#define prvv(v)             for(auto &x : v)for(auto &y : x.ss)cout << y << " ";
#define mp                  make_pair
#define pii                 pair<int,int>
#define mset(a,f)           memset(a , f , sizeof(a))
#define pb                  push_back
#define inf                 INT_MAX
#define INF                 LLONG_MAX
typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update> oset;
 
const int N = 2e6 + 6;
const int M = 1e9+7;
int A[N];
int n , m;

void alpha(int rt)
{
	 string res = "";
	 int ok  =  1;
	 while (rt >= 0)
	 {
	    if (rt == 0)ok = 0;
	    int j = rt % 26;
	    res = (char)('a' + j ) + res;
	    rt /= 26;
	    rt--;
	 }

	 cout << res;
}

void solve()
{
	 int n;
	 cin >> n;
	 int rt = n - 1;

	 alpha(rt);
}			
 
int32_t main()
{
 
cout<<fixed<<setprecision(16);
 
ios_base:: sync_with_stdio(false);
cin.tie(NULL); cout.tie(NULL);
 	
 
 	int t = 1;
 	// cin >> t;
 	while(t--)solve();
  
}

Measured memory_bytes: 3668
#include <bits/stdc++.h>
using namespace std;
// define
#define int long long
#define UNIQUE(v) v.erase(unique(all(v)), v.end());
#define ZIP(v) sort(all(v)),UNIQUE(v)
#define ADD(a, b) a = (a + b) % mod
#define SUB(a, b) a = (a+mod-b)%mod
#define MUL(a, b) a = (((a)%mod) * ((b)%mod)) % mod
#define rollcall cout << "I'm Sucu." << endl;
#define repi(i,m,n) for(int i = m;i < n;i++)
#define drep(i,n,m) for(int i = n;i >= m;i--)
#define rep(i,n) repi(i,0,n)
#define rrep(i,n) repi(i,1,n+1)
#define chmin(x,y) x = min(x,y)
#define chmax(x,y) x = max(x,y)
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(), v.rend()
#define dmp(x,y) make_pair(x,y)
#define pb(x) push_back(x)
#define pf(x) push_front(x)
#define fi first
#define se second
// typedef
typedef complex<double> Point;
typedef pair<int, int> P;
typedef pair<int, P> PP;
typedef pair<P, int> Pi;
typedef vector<int> vi;
typedef deque<int> dq;
const int inf = 1e9+7;
const int INF = 1e18+7;
const int mod = 1e9+7;
// int sum = accumulate(a, a+n, 0LL);
// int mx = max_element(a, a+n);
// int mn = min_element(a, a+n);
// int cnt = count(a, a+n, k);

int N;
int x[10], y[10];
 
double dist(int i, int j) {
    double dx = x[i] - x[j];
    double dy = y[i] - y[j];
    return pow(dx * dx + dy * dy, 0.5);
}
 
void solve() {
    cin >> N;
    for(int i = 1; i <= N; i++) cin >> x[i] >> y[i];
    double sum = 0.0;
    vector<int> v(N);
    for(int i = 0; i < N; i++) v[i] = i + 1;
    do {
        for(int i = 0; i < N - 1; i++) sum += dist(v[i], v[i+1]);
    } while(next_permutation(v.begin(), v.end()));
    int Factorial = 1;
    for(int i = 2; i <= N; i++) Factorial *= i;
    cout << fixed << setprecision(10) << sum / Factorial << endl;
    return;
}
 
signed main() {
    solve();
    return 0;
}

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

int main() {
  int n;cin>>n;
  int an[n];rep(i,n)cin>>an[i];
  sort(an, an+n);
  cout << (an[n-1] - an[0]);
}


Measured memory_bytes: 256
n = int(input())
d = {}
for _ in range(n):
    s = str(input())
    d[s] = 1 if s not in d else d[s] + 1
M = max(d.values())
L = [k for k, v in d.items() if v == M]
L.sort()
for x in L:
    print(x)


Measured memory_bytes: 35324
l=list(input())
if l[0]=='R':
  if l[1]=='R':
    if l[2]=='R':
      print(3)
    else:
      print(2)
  else:
      print(1)
else:
  if l[1]=='R':
    if l[2]=='R':
      print(2)
    else:
      print(1)
  else:
    if l[2]=='R':
      print(1)
    else:
      print(0)

Measured memory_bytes: 9060
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < n; i++)
#define repp(i, m, n) for(int i = m; i < n; i++)
#define reps(i, n) for(int i = 1; i <= n; i++)
const int    INF = 100000000;
const double EPS = 1e-10;
const int    MOD = 1000000007;
using namespace std;
typedef long long ll;
typedef pair<int, int> pai;
typedef pair<ll,ll> pal;

int n, m, a, b, c, sum;
int d[1010][1010];
int q[1010];
vector<pair<int, int>> edge[1010];

void dj(int s)
{
	reps(i, n) q[i]=1;
	sum=n;
	while(sum>0)
	{
		int mn=100010, vm=1;
		reps(i, n)
		{
			if(q[i]==1)
			{
				if(mn>=d[s][i])
				{
					mn=d[s][i];
					vm=i;
				}
			}
		}
		q[vm]=0;
		sum--;
		rep(i, edge[vm].size())
		{
			if(d[s][edge[vm][i].first]>d[s][vm]+edge[vm][i].second)
			{
				d[s][edge[vm][i].first]=d[s][vm]+edge[vm][i].second;
			}
		}
	}
}

int main()
{
	cin >> n >> m;
	reps(i, n) reps(j, n)
	{
		if(i==j) d[i][j]=0;
		else d[i][j]=100010;
	}	
	rep(i, m)
	{
		cin >> a >> b >> c;
		edge[a].push_back(make_pair(b, c));
		edge[b].push_back(make_pair(a, c));
	}
	reps(i, n) dj(i);
	int ans=0;
	reps(i, n) rep(j, edge[i].size())
	{
		a=i;
		b=edge[i][j].first;
		c=edge[i][j].second;
		if(c!=d[a][b]) ans+=1;
	}
	cout << (ans/2) << endl;;
}

Measured memory_bytes: 640
#include<iostream>
#include<string>
#include<cstdio>
#include<algorithm>
#include<stack>
#include<queue>
#include<vector>
#include<cmath>
#include<utility>
#include<set>
#include<complex>
#include<map>
#define vi vector<int>
#define vvi vector<vector<int> >
#define ll long long int
#define vl vector<ll>
#define vvl vector<vector<ll>>
#define vb vector<bool>
#define vc vector<char>
#define vs vector<string>
#define ld long double
#define INF 1e9
#define EPS 0.0000000001
#define rep(i,n) for(int i=0;i<n;i++)
#define loop(i,s,n) for(int i=s;i<n;i++)
#define all(in) in.begin(), in.end()
#define MAX 9999999
using namespace std;
typedef pair<int, int> pii;
typedef pair<double,double>pdd;
typedef pair<ll,ll>pll;
int main(){
    int a,b,c; cin>>a>>b>>c;
    cout<<(a+b)*c/2<<endl;
}

Measured memory_bytes: 256
isPrime = [True for i in range(100001)]
isPrime[0] = False
isPrime[1] = False

for i in range(2, 100001):
    if isPrime[i]:
        j = 2
        while i*j <= 100000:
            isPrime[i*j] = False
            j += 1

isSimilar = [True for i in range(100001)]
for i in range(100001):
    if isPrime[i] and isPrime[(i+1)//2]:
        pass
    else:
        isSimilar[i] = False

cnt = [0 for i in range(1, 100010)]
for i in range(1, 100001):
    cnt[i] = cnt[i-1] + [0, 1][isSimilar[i]]

q = int(input())
lrs = list()
for i in range(q):
    lrs.append(list(map(int, input().split())))

for l, r in lrs:
    print(cnt[r]-cnt[l-1])


Measured memory_bytes: 32768
using System;
using System.Text;
using System.Linq;
using System.Collections;
using System.Collections.Generic;
using static System.Console;
using static System.Math;

namespace AtCoder
{
    class Program
    {
        static void Main(string[] args)
        {
            new ABC121().SolveB(new ConsoleInput(Console.In, ' '));
        }
    }

    public class ConsoleInput
    {
        private readonly System.IO.TextReader _stream;
        private char _separator = ' ';
        private Queue<string> inputStream;
        public ConsoleInput(System.IO.TextReader stream, char separator = ' ')
        {
            this._separator = separator;
            this._stream = stream;
            inputStream = new Queue<string>();
        }
        public string Read
        {
            get
            {
                if (inputStream.Count != 0) return inputStream.Dequeue();
                string[] tmp = _stream.ReadLine().Split(_separator);
                for (int i = 0; i < tmp.Length; ++i)
                    inputStream.Enqueue(tmp[i]);
                return inputStream.Dequeue();
            }
        }
        public string ReadLine { get { return _stream.ReadLine(); } }
        public int ReadInt { get { return int.Parse(Read); } }
        public long ReadLong { get { return long.Parse(Read); } }
        public double ReadDouble { get { return double.Parse(Read); } }
        public string[] ReadStrArray(long N) { var ret = new string[N]; for (long i = 0; i < N; ++i) ret[i] = Read; return ret; }
        public int[] ReadIntArray(long N) { var ret = new int[N]; for (long i = 0; i < N; ++i) ret[i] = ReadInt; return ret; }
        public long[] ReadLongArray(long N) { var ret = new long[N]; for (long i = 0; i < N; ++i) ret[i] = ReadLong; return ret; }
    }

    class ABC121
    {
        public void SolveB(ConsoleInput cin)
        {
            var n = cin.ReadInt;
            var m = cin.ReadInt;
            var c = cin.ReadInt;
            var B = cin.ReadIntArray(m);
            var A = new int[n, m];
            for (int i = 0; i < n; i++)
            {
                for (int k = 0; k < m; k++)
                {
                    A[i, k] = cin.ReadInt;
                }
            }
            int count = 0;
            for (int i = 0; i < n; i++)
            {
                int sum = 0;
                for (int k = 0; k < m; k++)
                {
                    sum += A[i, k] * B[k];
                }
                if (sum + c > 0) count++;
            }
            WriteLine(count);
            ReadLine();
        }
    }
}

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

using namespace std;
typedef long long int LL;
typedef long long int LLint;
typedef pair<int,int> intpair;
typedef pair<bool,bool> boolpair;
typedef pair<string,string> strpair;
typedef pair<LL,LL> LLpair;
typedef pair<double,double> doublepair;
typedef pair<float,float> floatpair;
typedef vector<int> intvector;
typedef vector<bool> boolvector;
typedef vector<string> strvector;
typedef vector<LL> LLvector;
typedef vector<double> doublevector;
typedef vector<float> floatvector;
#define wait(sec) usleep((sec) * 1000000)
#define ED return 0;
#define TEST cout << "OK" << endl;
#define UP(a,b) ((a+(b-1))/b)
#define SORT(vec) sort(vec.begin(),vec.end());
#define DOUBLECHANGE(count) cout << setprecision(count);
#define REV(vec) reverse(vec.begin(),vec.end());
#define ipow(x,y) LL(pow(x,y))
#define INF 999999999
#define PI 3.14159265358979323846
const long long mod = 1000000007;

int main(){
    //    random_device rnd;
    //    mt19937 mt(rnd());
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N;
    string S;
    cin >> N >> S;

    if(N%2==0 && S.substr(0,N/2) == S.substr(N/2,N/2)){
        cout << "Yes" << endl;
    }
    else{
        cout << "No" << endl;
    }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<int,int>;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(v) v.begin(), v.end()
#define INF 10**9

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

Measured memory_bytes: 3600