akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
#define int long long
#define endl "\n"
#define fast ios_base::sync_with_stdio(false); cin.tie(NULL);

using namespace std;

const int N = 1e6+7, mod = 1e9 + 7;
int n, k, a[N], comp_cnt[N], right_cnt[N];

int32_t main()
{
	fast;

	cin >> n >> k;
	for(int i = 1; i <= n; i++)
		cin >> a[i];

	for(int i = 1; i <= n; i++)
	{
		for(int j = 1; j <= n; j++)
			if(a[j] < a[i])
				comp_cnt[j]++;
		for(int j = i+1; j <= n; j++)
			if(a[j] < a[i])
				right_cnt[j]++;
	}

	int prod = (((k-1)*(k))/2) % mod;
	int ans = 0;
	for(int i = 1; i <= n; i++)
	{
		ans += (prod*comp_cnt[i]) % mod;
		ans %= mod;
		ans += (k*right_cnt[i]) % mod;
		ans %= mod;
	}

	cout << ans;
	return 0;
}

Measured memory_bytes: 4352
N = int(input())
S = input()
R = []
G = []
B = []
for i in range(N):
    if S[i] == 'R':
        R.append(i)
    elif S[i] == 'G':
        G.append(i)
    elif S[i] == 'B':
        B.append(i)
ans = len(R)*len(G)*len(B)
for i in range(1,(N+1)//2):
    for j in range(i,N-i):
        if S[j] != S[j-i] and S[j] != S[j+i] and S[j-i] != S[j+i]:
            ans -= 1
print(ans)


Measured memory_bytes: 9212
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <string>
#include <queue>
#include <fstream>
#include <string>
#include <math.h>
#include <set>
#include <string>
#include <bitset>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;
//typedef pair<ll, P> T;

#define rep(i, n) for (ll i = 0; i < (n); i++)
#define revrep(i, n) for (ll i = (n) - 1; i >= 0; i--)
#define f first
#define s second
#define pb push_back

ll mod = 1000000007;
const ll INF = 100000000000010000;
//const ull B = 998244353;

//ll bit[200010];
//ll kai[3010];
//ll Cnt[10010];

//void pres(double A, ll x = 20) { printf("%.20f\n", x); }



/*ll sum(ll i)
{
	i += 1;
	ll t = 0;
	while (i > 0)
	{
		t += bit[i];
		i -= i & -i;
	}
	return t;
}

void add(ll i, ll x)
{
	i += 1;
	while (i <= 200005)
	{
		bit[i] += x;
		i += i & -i;
	}
}*/

/*`ll SAIKI(ll S) {
	for (ll T = S; ; T = (T - 1) & S) {

	}
}*/



void test() {
	cout << "888888888888888888888888" << endl;
}

ll gcd(ll x, ll y) {
	if (y == 0) return x;
	return gcd(y, x % y);
}

ll pow_mod(ll x, ll k) {
	x %= mod;
	ll res = 1;
	while (k > 0) {
		if (k % 2) {
			res *= x; res %= mod;
		}
		x *= x; x %= mod;
		k /= 2;
	}
	return res;
}

ll div_mod(ll x) {
	return pow_mod(x, mod - 2);
}

//コンビネーション
const int MAXcomb = 1000010;
ll fac[MAXcomb], finv[MAXcomb], inv[MAXcomb];
//facはn!,finvは1/n!
//invは逆元
void COMinit() {
	fac[0] = fac[1] = 1;
	finv[0] = finv[1] = 1;
	inv[1] = 1;
	for (int i = 2; i < MAXcomb; i++) {
		fac[i] = fac[i - 1] * i % mod;
		inv[i] = mod - inv[mod%i] * (mod / i) % mod;
		finv[i] = finv[i - 1] * inv[i] % mod;
	}
}
ll comb(int n, int k) {
	if (n < k) return 0;
	if (n < 0 || k < 0) return 0;
	return fac[n] * finv[k] % mod * finv[n - k] % mod;
}


/*map<ll, ll> pres;
ll ct;

void makePrimeList(ll x) {
	ll X = x;
	for (ll j = 2; j * j <= x; j++) {
		ll cnt = 0;
		while (X % j == 0) {
			cnt++;
			X /= j;
		}
		if (cnt) {
			if (pres[j] == 0) {
				ct++;
				pres[j] = ct;
			}
			Cnt[pres[j]] += cnt;
		}
	}
	if (X != 1) {
		if (pres[X] == 0) {
			ct++;
			pres[X] = ct;
		}
		Cnt[pres[X]] += 1;
	}
}*/

ll dp[110][2][4];
string N;
ll K;

void solve() {
	cin >> N >> K;
	ll len = N.length();
	dp[0][0][0] = 1;
	rep(i, len)rep(j, 2)rep(k, 4) {
		if (N[i] == '0') dp[i + 1][j][k] += dp[i][j][k];
		else dp[i + 1][1][k] += dp[i][j][k];
		for (ll l = 1; l <= 9; l++) if (k != 3){
			if (l < N[i] - '0') dp[i + 1][1][k + 1] += dp[i][j][k];
			else if (l == N[i] - '0') dp[i + 1][j][k + 1] += dp[i][j][k];
			else if (j == 1) dp[i + 1][j][k + 1] += dp[i][j][k];
		}
	}
	cout << dp[len][0][K] + dp[len][1][K] << endl;
}

int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	solve();
	ll N;
	cin >> N;
}

Measured memory_bytes: 256
import java.io.*;
import java.io.IOException;
import java.util.*;

@SuppressWarnings({"rawtypes", "unchecked"})
class Main {
    final static int INF = 1 << 28;
    final static long LNF = 1L << 60;
    final static double EPS = 1e-9;
    final static double GOLDEN_RATIO = (1.0 + Math.sqrt(5)) / 2.0;

    static final long MOD = 1_000_000_007;

    public static void main(String[] args) throws Exception {
        final MyScanner sc = new MyScanner();
        long K;
        K = sc.nextLong();
        long N;
        N = sc.nextLong();
        long[] A = new long[(int)(N)];
        for(int i = 0 ; i < N ; i++){
                A[i] = sc.nextLong();
        }
        solve(K, N, A);
    }

    static void solve(long K, long N, long[] A){
        long max = 0;
        for (int i = 0; i < N - 1; i++) {
            max = Math.max(max, A[i+1] - A[i]);
        }
        max = Math.max(max,K - A[(int)N-1] + A[0]);
        System.out.println(K - max);
    }


    static class MyScanner {
 
        BufferedReader br;
        StringTokenizer st;
 
        MyScanner(FileReader fileReader) {
            br = new BufferedReader(fileReader);
        }
 
        MyScanner() {
            br = new BufferedReader(new InputStreamReader(System.in));
        }
 
        String nn() {
            while (st == null || !st.hasMoreElements()) {
                try {
                    st = new StringTokenizer(br.readLine());
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }
 
        String next() {
            return nn();
        }

        String nextLine() {
            String ans = "";
            try {
                ans = br.readLine();
            } catch (IOException ex) {
                ex.printStackTrace();
            }
            return ans;
        }
 
        char nextChar() {
            return nn().charAt(0);
        }
 
        int nextInt() {
            return Integer.parseInt(nn());
        }
 
        long nextLong() {
            return Long.parseLong(nn());
        }
 
        double nextDouble() {
            return Double.parseDouble(nn());
        }
 
        Integer[] niArr0(int n) {
            Integer[] ar = new Integer[n];
            for (int i = 0; i < n; i++) {
                ar[i] = nextInt();
            }
            return ar;
        }
 
        Integer[] niArr1(int n) {
            Integer[] ar = new Integer[n + 1];
            for (int i = 1; i <= n; i++) {
                ar[i] = nextInt();
            }
            return ar;
        }
 
        Long[] nlArr0(int n) {
            Long[] ar = new Long[n];
            for (int i = 0; i < n; i++) {
                ar[i] = nextLong();
            }
            return ar;
        }
 
        Long[] nlArr1(int n) {
            Long[] ar = new Long[n + 1];
            for (int i = 1; i <= n; i++) {
                ar[i] = nextLong();
            }
            return ar;
        }
    }

}


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

int count = 0;
char N[4];
int main() {
    cin >> N;
    if(N[0] == N[1] && N[1] == N[2]) {
        cout << "Yes" << endl;
    } else if(N[1] == N[2] && N[2] == N[3]) {
        cout << "Yes" << endl;       
    } else {
        cout << "No" << endl;       
    }
}

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

using namespace std;

typedef long long LL;

const int N = 100010;

int a, b, c, d;

int main()
{
    cin >> a >> b >> c >> d;
    
    if(a > c)
    {
        swap(a, c);
        swap(b, d);
    }

    cout << max(0, min(d, b) - c) << endl;
    return 0;
}


Measured memory_bytes: 384
#include<stdio.h>
#include<iostream>
#include<stack>
#include<vector>
#include<algorithm>
using namespace std;
int main(){
    stack<int>s1;
    stack<pair<int,int> >s2;
    char a;
    int sum=0,su,j;
    for(int i=1;cin>>a;i++){
        if(a=='\\'){
            s1.push(i);
        }else
        if(a=='/'&&s1.size()>0){
            j=s1.top();s1.pop();
            su=i-j;
            sum+=su;
            while(s2.size()>0&&s2.top().first>j){
                    su+=s2.top().second;s2.pop();
            }
            s2.push(make_pair(j,su));
        }
    }
    vector<int>ans;
    while(s2.size()>0){
        ans.push_back(s2.top().second);s2.pop();
    }
    reverse(ans.begin(),ans.end());
    printf("%d\n%d",sum,ans.size());
    for(int i=0;i<ans.size();i++){
        printf(" %d",ans[i]);
    }
    printf("\n");
    return 0;
}

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

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

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

#ifdef DBG
void debug_(){ cout << endl; }
template<typename T, typename... Args>
void debug_(T&& x, Args&&... xs){
	cout << x << " "; debug_(forward<Args>(xs)...);
}
#define dbg(...) debug_(__VA_ARGS__)
#else
#define dbg(...)
#endif

int main() {
	ios_base::sync_with_stdio(false);
	cout << setprecision(20) << fixed;

	int n; cin >> n;
	vector<ll> a(n); cin >> a;

	ll sum = 0;
	for(int i=0; i<n; i++) sum = sum ^ a[i];

	vector<ll> ans(n);
	for(int i=0; i<n; i++){
		ans[i] = sum^a[i];
	}
	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 6328
from collections import deque

h,w = map(int,input().split())
maze = []

for _ in range(h):
    maze.append(input())

ans = 0

move = [[1,0],[-1,0],[0,1],[0,-1]]

for i in range(h):
    for j in range(w):
        if(maze[i][j]=="."):
            dist = [ [99999999]*w for _ in range(h) ]
            
            dq = deque()
            y=i
            x=j
            d=0
            dist[y][x]=0
            dq.append((y,x,d))
            
            while(len(dq)):
                
                y,x,d = dq.popleft()
                
                for m in move:
                    if((0<=x+m[0]<w) and (0<=y+m[1]<h) and
                        (dist[y+m[1]][x+m[0]] > d+1) and
                            (maze[y+m[1]][x+m[0]] == ".")):
                                dist[y+m[1]][x+m[0]]=d+1
                                dq.append((y+m[1],x+m[0],d+1))
                                
            ans = max(ans,d)
            # print(d,i,j)
print(ans)

Measured memory_bytes: 9368
//39
#include<iostream>
#include<algorithm>
#include<vector>
#include<set>

using namespace std;

int main(){
  for(long long x,y;cin>>x>>y,x|y;){
    vector<long long> v;
    bool ap[1000001]={};
    while(x){
      if(ap[x]++)break;
      v.push_back(x);
      x*=10;
      x%=y;
    }
    if(x){
      int d=find(v.begin(),v.end(),x)-v.begin();
      cout<<d<<' '<<v.size()-d<<endl;
    }else{
      cout<<v.size()<<" 0"<<endl;
    }
  }
  return 0;
}
      

Measured memory_bytes: 18500
#pragma GCC optimize(2)
#include<bits/stdc++.h>
#define ll long long
#define maxn 305
#define inf 1e18
#define pb push_back
using namespace std;

inline ll read()
{
	ll x=0,w=1; char c=getchar();
	while(c<'0'||c>'9') {if(c=='-') w=-1; c=getchar();}
	while(c<='9'&&c>='0') {x=(x<<1)+(x<<3)+c-'0'; c=getchar();}
	return w==1?x:-x;
}

ll n,m,l,Q[maxn][maxn],dep[maxn],vis[maxn],d[maxn][maxn];

inline void bfs(int x)
{
	for(int i=1;i<=n;i++) vis[i]=0,Q[x][i]=-1;
	queue <int> q; q.push(x); vis[x]=1; Q[x][x]=0;
	while(!q.empty())
	{
		int u=q.front(); q.pop();
		for(int i=1;i<=n;i++)
		{
			if(Q[x][i]!=-1) continue;
			if(d[u][i]<=l) q.push(i),Q[x][i]=Q[x][u]+1;
		}
	}
}

int main()
{
	n=read(); m=read(); l=read();
	for(int i=1;i<=n;i++) for(int j=1;j<=n;j++) d[i][j]=inf;
	for(int i=1;i<=n;i++) d[i][i]=0;
	for(int i=1;i<=m;i++)
	{
		int u=read(),v=read(),w=read();
		d[u][v]=d[v][u]=w;
	}
	for(int k=1;k<=n;k++) for(int i=1;i<=n;i++) for(int j=1;j<=n;j++)
		d[i][j]=min(d[i][j],d[i][k]+d[k][j]);
	
	for(int i=1;i<=n;i++) bfs(i);
	int T=read();
	while(T--)
	{
		int u=read(),v=read();
		if(Q[u][v]==-1) puts("-1"); else printf("%d\n",Q[u][v]-1);
	}
	return 0;
}

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

#define pii pair<int,int>
#define ll long long
#define F first
#define S second
#define mp make_pair

using namespace std;

const int N = 1e5 + 123;

int n;

int a[N], cnt1[N], cnt2[N], ans = N;

pii x, y, p;

set <pii> s, t;

int main () {
    cin >> n;
    for (int i = 1;i <= n;i ++) {
        cin >> a[i];
    }
    for (int i = 1;i < n;i += 2) {
        cnt1[a[i]] ++;
        cnt2[a[i + 1]] ++;
    }
    for (int i = 1;i < n;i += 2) {
        s.insert (mp (cnt1[a[i]], a[i]));
        t.insert (mp (cnt2[a[i + 1]], a[i + 1]));
    }
    x = *s.rbegin ();
    y = *t.rbegin ();
    s.erase (*s.rbegin ());
    t.erase (*t.rbegin ());
    if (x.S == y.S) {
        if (!t.empty ()) {
            p = *t.rbegin ();
            ans = min (n - (x.F + p.F), ans );
        }if (!s.empty ()) {
            p = *s.rbegin ();
            ans = min (ans, n - (y.F + p.F));
        }
        if (!t.empty () && !s.empty ()) {
            x = *s.rbegin ();
            y = *t.rbegin ();
            ans = min (ans, n - (x.F + y.F));
        }
        if (t.empty () && s.empty ()) {
            ans = n / 2;
        }
    }else {
        ans = n - (x.F + y.F);
    }cout << ans;
}


Measured memory_bytes: 6144
///In the name of GOD
#include<bits/stdc++.h>
using namespace std;

typedef long long ll;
const ll MXN = 5e3 + 10;
ll q, n, a, b, c, d;
map<ll, ll> dp;
ll Cal(ll x){
    if(x == 0) return 0;
    if(x == 1) return d;
    if(dp[x]) return dp[x];
    ll now = 8e18;
    if(now / d >= n) now = x * d;

    if(x % 2)   now = min({now, Cal(x / 2) + d + a, Cal(x / 2 + 1) + d + a});
    else        now = min(now, Cal(x / 2) + a);

    if(x % 3)   now = min({now, Cal(x / 3) + (x % 3) * d + b, Cal(x / 3 + 1) + (3 - (x % 3)) * d + b});
    else        now = min(now, Cal(x / 3) + b);

    if(x % 5)   now = min({now, Cal(x / 5) + (x % 5) * d + c, Cal(x / 5 + 1) + (5 - (x % 5)) * d + c});
    else        now = min(now, Cal(x / 5) + c);

    return dp[x] = now;
}
void solve(){
    cin >> n >> a >> b >> c >> d;
    dp.clear();
    cout << Cal(n) << '\n';
}
int main(){
    ios::sync_with_stdio(0);cin.tie(0); cout.tie(0);
    cin >> q;
    while(q --) solve();
    return 0;
}
/*!
    I CHOOSE TO HAVE FAITH,
    BECAUSE WITHOUT THAT,
    I HAVE NOTHING....
    ITS THE ONLY THING THAT'S KEEPING ME GOING.
*/
//! N.N


Measured memory_bytes: 4356
#include<bits/stdc++.h>
using namespace std;
int n, m, a, b;
deque<int> path;
int mem[100001];
	vector<vector<int> > v;
	
int dfs(int z, bool f) {
	mem[z] = 1;
	for(int i = 0; i < v[z].size(); i++) {
		if(mem[v[z][i]] == 0) {
			if(f) {
				path.push_back(v[z][i]);
			} else {
				path.push_front(v[z][i]);
			}
			return dfs(v[z][i], f);
		}
	}
	return 0;	
 }

int main() {
	cin >> n >> m;
	vector<int> vec;
	for(int i = 0; i < n; i++) {
		v.push_back(vec);
	}
	for(int i = 0; i < m; i++) {
		cin >> a >> b;
		v[a - 1].push_back(b - 1);
		v[b - 1].push_back(a - 1);
	}
	mem[0] = 1;
	b = v[0][0];
	mem[b] = 1;
	path.push_back(0);
	path.push_front(b);
	for(int i = 0; i < v[0].size(); i++) {
		if(mem[v[0][i]] == 0) {
			mem[v[0][i]] = 1;	
			path.push_back(v[0][i]);
			dfs(v[0][i], 1);
			break;		
		}
	}
	for(int i = 0; i < v[b].size(); i++) {
		if(mem[v[b][i]] == 0) {
			mem[v[b][i]] = 1;
			path.push_front(v[b][i]);
			dfs(v[b][i], 0);
			break;
		}
	}
	cout << path.size() << endl;
	for(int i = 0; i < path.size(); i++) {
		cout << path[i] + 1<< " ";	
	}
}


Measured memory_bytes: 7152
import sys
import math

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

res = 0.0

for i in range(1,n+1):
  if k <= i :
    res = res + 1
    continue
  for j in range(1,math.floor(math.log2(k))+2):
    if (i * (2 ** j)) >= k :
      res += 0.5 ** j
      break
res = res / n
print(res)

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

using VS = vector<string>;    using LL = long long;
using VI = vector<int>;       using VVI = vector<VI>;
using PII = pair<int, int>;   using PLL = pair<LL, LL>;
using VL = vector<LL>;        using VVL = vector<VL>;

#define ALL(a)  begin((a)),end((a))
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define SZ(a) int((a).size())
#define SORT(c) sort(ALL((c)))
#define RSORT(c) sort(RALL((c)))
#define UNIQ(c) (c).erase(unique(ALL((c))), end((c)))
#define FOR(i, s, e) for (int(i) = (s); (i) < (e); (i)++)
#define FORR(i, s, e) for (int(i) = (s); (i) > (e); (i)--)
#define debug(x) cerr << #x << ": " << x << endl
const int INF = 1e9;                          const LL LINF = 1e16;
const LL MOD = 1000000007;                    const double PI = acos(-1.0);
int DX[8] = { 0, 0, 1, -1, 1, 1, -1, -1 };    int DY[8] = { 1, -1, 0, 0, 1, -1, 1, -1 };

/* -----  2018/02/23  Problem: 081_arc_b / Link: https://abc071.contest.atcoder.jp/tasks/arc081_b?lang=en  ----- */
/* ------問題------

2×N のマス目があります． すぬけ君は，このマス目に N 個のドミノを，重ならないように敷き詰めました． ここで，ドミノは，1×2 または 2×1 のマス目を覆うことができます．
すぬけ君は，赤色，水色，緑色の 3 色を使って，これらのドミノを塗ることにしました． このとき，辺で接しているドミノは異なる色で塗るようにします． ここで，必ずしも 3 色すべてを使う必要はありません．
このような塗り方が何通りあるかを mod 1000000007 で求めてください．
ただし，ドミノの敷き詰め方は，文字列 S1,S2 を用いて，次のようにして与えられます．
各ドミノは，それぞれ異なる英小文字または英大文字で表される．
Si の j 文字目は，マス目の上から i 番目，左から j 番目のマスにどのドミノがあるかを表す．

-----問題ここまで----- */
/* -----解説等-----

状態が4通りしか無いので全部書く。
最初だけ塗れる色の数が違うので気をつける。

----解説ここまで---- */

LL N;

LL ans = 0LL;

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

	cin >> N;
	string s1, s2;
	cin >> s1 >> s2;
	ans = 1;
	int mode = -1;
	FOR(i, 0, N) {
		if (mode == -1) {//init
			if (s1[i] == s2[i]) {
				mode = 0; ans = 3;
			}
			else {
				mode = 1; ans = 6;
			}
		}
		else if (mode == 0) {// :
			if (s1[i] == s2[i]) {
				mode = 0; ans *= 2;
			}
			else {
				mode = 1; ans *= 2;
			}
		}
		else if (mode == 1) {// =L

			mode = 2;
		}
		else if (mode == 2) {// =R
			if (s1[i] == s2[i]) {
				mode = 0; ans *= 1;
			}
			else {
				mode = 1; ans *= 3;
			}
		}

		ans %= MOD;
	}
	cout << ans << "\n";

	return 0;
}


Measured memory_bytes: 256
import sys

s = str(input())
A = s[0]
B = s[1]
C = s[2]
D = s[3]

signs = ['+' , '-']

for i in range(2):
    for j in range(2):
        for k in range(2):
            ans = A+signs[i]+B+signs[j] + C + signs[k] + D
            if eval(ans) == 7:
                print(ans + '=7')
                sys.exit()


Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
#define REP(i,n) for (ll i = 0; i < (n); ++i)

struct mint{
    static const long long MOD = 1000000007;

    long long v;

    mint() : v(0) {}
    mint(long long x){
        x = x % MOD;
        if(x < 0){ x += MOD; }
        v = x;
    }
    mint& operator+=(mint a){
        v += a.v;
        if(v >= MOD){ v -= MOD; }
        return *this;
    }
    mint& operator*=(mint a){
        v *= a.v;
        v %= MOD;
        return *this;
    }
    mint& operator-=(mint a){
        v -= a.v;
        if(v < 0){ v += MOD; }
        return *this;
    }
    mint& operator/=(mint a){
        return (*this) *= a.inv();
    }

    mint operator*(mint a) const{
        return mint(v) *= a;
    }

    mint operator+(mint a) const {
        return mint(v) += a;
    }

    mint operator-(mint a) const {
        return mint(v) -= a;
    }

    mint operator/(mint a) const {
        return mint(v) /= a;
    }

    mint pow(long long k) const {
        mint res(1),tmp(v);
        while(k){
            if(k&1) res *= tmp;
            tmp *= tmp;
            k >>= 1;
        }
        return res;
    }
    mint inv(){return pow(MOD - 2); }

    static mint comb(long long n, int k){
        mint res(1);
        for(int i = 0; i < k; ++i){
            res *= mint(n - i);
            res /= mint(i + 1);
        }
        return res;
    }

    static mint factorial(long long n){
        mint res(1);
        for(int i = n; i > 1; --i){
            res *= mint(i);
        }
        return res;
    }

    bool operator<(const mint &a) const {
        return v < a.v;
    };
};

mint operator*(long long l, mint r){ return r * l; }

std::ostream& operator<<(std::ostream& stream, const mint& m){
    stream << m.v;
    return stream;
}


void solve(long long n, long long a, long long b){
    mint ans = 0;
    ans += mint(2).pow(n) - 1;
    ans -= mint::comb(n, a);
    ans -= mint::comb(n, b);
    cout << ans << endl;
}

// Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools
int main(){
    long long n;
    scanf("%lld",&n);
    long long a;
    scanf("%lld",&a);
    long long b;
    scanf("%lld",&b);
    solve(n, a, b);
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main() 
{
	int n,m;
	cin>>n>>m;
	int ans=0;
	if(n>=2)
	{
		ans+=(n-1)*n/2;
	}
	if(m>=2)
	{
		ans+=(m-1)*m/2;
	}
	cout<<ans<<endl;
}

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

int main() {
    int n;
    cin >> n;
    vector<int> a(n);
    for (auto& e : a) cin >> e;

    int ans = 0;
    for (auto& e : a) {
        while (e % 2 == 0) ans++, e /= 2;
    }

    cout << ans << endl;
}


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

using namespace std;
using ll = long long;
using P = pair<int,int>;
inline int ri() {
	int r; cin >> r; return r;
}


int main()
{
	int n, m;
	cin >> n >> m;
	vector<int> a(n), b(n),  c(m), d(m);
	for(int i = 0; i < n; i++)cin >> a[i] >> b[i];
	for(int i = 0; i < m; i++)cin >> c[i] >> d[i];
	vector<int> cnt(m);

	for(int i = 0; i < n; i++) {
		int po = -1, dist = 1e9;
		for(int j = 0; j < m; j++) {
			if(abs(a[i] - c[j]) + abs(b[i] - d[j]) < dist) {
				dist = abs(a[i] - c[j]) + abs(b[i] - d[j]);
				po = j;
			}
		}
		cout << po + 1 << endl;
	}
//	for(int i = 0; i < m; i++)cout << cnt[i] << endl;
}

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

#define clock_starts() clock_t begin = clock()
#define clock_ends() clock_t end = clock()
#define print_running_time() double elapsed_secs = double(end - begin) / CLOCKS_PER_SEC; \
printf("Elapsed Time : %.10f second(s)\n", elapsed_secs)
#define readfile(s) freopen(s, "r", stdin)
#define writefile(s) freopen(s, "w", stdout)
#define debug(s) cout<< #s <<" = "<< s <<endl
#define all(v) v.begin(), v.end()
#define cin_cout_is_cool ios_base::sync_with_stdio(false); cin.tie(NULL)
#define printBinary(n) cout << #n << " = " << bitset<64>(n) << endl
#define min_pq priority_queue<int, vector<int>, greater<int> >
#define MEMSET(a,val) memset(a, val, sizeof a)
#define PB push_back
#define endl '\n'
#define cin(n) scanf("%d", &n)

template<typename T>T max(T a_,T b_,T c_) { return max(a_,max(b_,c_)); }
template<typename T>T min(T a_,T b_,T c_) { return min(a_,min(b_,c_)); }

typedef pair<int, int> ii;
typedef pair<long, long> pll;
typedef pair<double, double> pdd;

#define ceil(num,d) 		( (int)(num/d) + (num%d>0 ? 1 : 0) )
#define block_no(idx) 		( ceil(idx, BLOCK_SIZE) )
#define block_starting(idx) ( ((block_no(idx)-1) * BLOCK_SIZE) +1 )
#define block_ending(idx) 	( min(n, block_no(idx)*BLOCK_SIZE) )
#define block_ranking(idx) 	((idx%BLOCK_SIZE==0)?BLOCK_SIZE:idx%BLOCK_SIZE)

int a, b;
char s[1000];

int check() {
	for(int i=1; i<=a; i++) if(!('0' <= s[i] and s[i] <= '9')) return 0;
	if(s[a+1] != '-') return 0;
	for(int i=a+2; i<=a+b+1; i++) if(!('0' <= s[i] and s[i] <= '9')) return 0;
	return 1;
}

int32_t main () {
	//readfile("input.in");
	//writefile("output.out");
	cin>>a>>b;
	scanf("%s", s+1);
	int temp = check();
	if(temp) {
		cout<<"Yes"<<endl;
	}
	else {
		cout<<"No"<<endl;
	}
	return 0;
}

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

class Program
{
	static void Main(string[] args)
	{
		int N = int.Parse(Console.ReadLine());
		string S = Console.ReadLine();
		int cnt = 0;
		for(int i = 0;i < N - 2; i++)
        {
			if ("ABC" == S.Substring(i, 3))
				cnt++;
        }
		Console.WriteLine(cnt);
	}
}


//string s = Console.ReadLine();
//int[] intArray = Console.ReadLine().Split(' ').Select(i => int.Parse(i)).ToArray();
//int H = intArray[0];
//int W = intArray[1];
//int N = int.Parse(Console.ReadLine());
//List<int> A = new List<int>(Console.ReadLine().Split(' ').Select(i => int.Parse(i)).ToArray());
//Boolean ok = false;

//Console.WriteLine(ans);
//Console.WriteLine("Yes");
//Console.WriteLine("No");
//Console.ReadKey();
//Console.WriteLine(cnt);

//string[] strArray = Console.ReadLine().Split(' ').ToArray();
//string S = strArray[0];
//string T = strArray[1];


Measured memory_bytes: 13140
object Main{
  def main(args: Array[String]) : Unit = {
val arr1 = io.StdIn.readLine().split(' ')
    val n = arr1(0).toInt
    var mm = scala.collection.mutable.HashMap.empty[String, Long]

    (0 until n).foreach{
      i =>
        val s = io.StdIn.readLine().toString
        val str = s.sorted

        if(mm.contains(str)){
          mm(str) = mm(str) + 1L
        }else{
          mm.update(str, 0L)
        }
    }

    var max: Long = mm.values.map(i => (0L to i).sum).sum

    println(max)
  }
}

Measured memory_bytes: 56236
#include <bits/stdc++.h>
using namespace std;
int main(void){
    // Your code here!
    char a[3];
    
    cin>>a;
    
    for(int i=0;i<3;i++){
    if(a[i]=='1')a[i]='9';
    else a[i]='1';
    }
    cout<<a<<endl;
    return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include <cassert>
#include <cctype>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstring>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <tuple>
#include <vector>
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
//#define cerr if(false) cerr
#ifdef DEBUG
#define show(...) cerr << #__VA_ARGS__ << " = ", debug(__VA_ARGS__);
#else
#define show(...) 42
#endif
using namespace std;
using ll = long long;
using pii = pair<int, int>;
template <typename T, typename S>
ostream &operator<<(ostream &os, pair<T, S> a) {
    os << '(' << a.first << ',' << a.second << ')';
    return os;
}
template <typename T>
ostream &operator<<(ostream &os, vector<T> v) {
    for (auto x : v) os << x << ' ';
    return os;
}
void debug() {
    cerr << '\n';
}
template <typename H, typename... T>
void debug(H a, T... b) {
    cerr << a;
    if (sizeof...(b)) cerr << ", ";
    debug(b...);
}
template <typename T>
vector<T> divisor(T n) {
    vector<T> res;
    for (T i = 1; i * i <= n; i++) {
        if (n % i == 0) {
            res.push_back(i);
            if (i * i != n) {
                res.push_back(n / i);
            }
        }
    }
    sort(res.begin(), res.end());
    return res;
}
template <typename T>
map<T, int> prime_factor(T n) {
    map<T, int> res;
    for (T i = 2; i * i <= n; i++) {
        while (n % i == 0) {
            res[i]++;
            n /= i;
        }
    }
    if (n != 1) {
        res[n]++;
    }
    return res;
}
template <typename T>
T gcd(T a, T b) {
    while (b) {
        a %= b;
        swap(a, b);
    }
    return a;
}
template <typename T>
T lcm(T a, T b) {
    return a / gcd(a, b) * b;
}
ll f(ll a, ll c){
    return a / c;
}
int main(){
    ll a,b,c,d;
    cin >> a >> b >> c >> d;
    cout << b-(f(b,c)+f(b,d)-f(b,lcm(c,d)))-(a-1-(f(a-1,c)+f(a-1,d)-f(a-1,lcm(c,d)))) << endl;
}

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


int main()
{

  string s,t;
  cin>>s;
  cin>>t;
  int l1=s.length();
  int l2=t.length() ;
  int dp[l1+1][l2+1];

  for(int i=0; i<l1+1 ;i++)
  {
    for(int j=0;j<l2+1;j++)
    {
      dp[i][j]=0;
    }
  }
int y=0;
int z=0;
 string ans;
  for(int i=0; i<l1+1 ;i++)
  {
    for(int j=0;j<l2+1;j++)
    {  
      if(i==0 or j==0)
      dp[i][j]=0;
      else if(s[i-1]==t[j-1]) 
      {
      dp[i][j]=1+dp[i-1][j-1];
      }
      else 
      dp[i][j]=max(dp[i-1][j] ,dp[i][j-1]) ;
    }
  }
 

  int   lll=dp[l1][l2];
  char  ans_string[lll+1];
  ans_string[lll]='\0' ;
  int index=lll-1;
  int i=l1;int j=l2;
  while(i>0 and j>0)
  {
    if( s[i-1]==t[j-1])
       {
         ans_string[index]=s[i-1];
         index--;
         i--;
         j--;
       }
       else
       {
          if(dp[i-1][j]>dp[i][j-1])
              i=i-1 ;
          else
          {
            j=j-1 ;
          }
          
       }
       
  }
  cout<<ans_string<<endl;
  return 0;
}











Measured memory_bytes: 35456
import sys

readline = sys.stdin.readline
readall = sys.stdin.read
ns = lambda: readline().rstrip()
ni = lambda: int(readline().rstrip())
nm = lambda: map(int, readline().split())
nl = lambda: list(map(int, readline().split()))
prn = lambda x: print(*x, sep='\n')

def solve():
    n = ni()
    a = n * (n + 1) * (n + 2) // 6
    for _ in range(n-1):
        u, v = nm()
        if u > v:
            u, v = v, u
        a -= u * (n - v + 1)
    print(a)
    return

solve()


Measured memory_bytes: 9124
#include<bits/stdc++.h>
#define ll long long
#define pb push_back
#define rep(i,a,b) for(i=a;i<b;i++)
#define all(v) (v).begin(),(v).end()
#define mod 10e9
using namespace std;
void cicada()
{
    ll i,j,k,l,m,n;
    cin>>n>>m;
    vector<ll>v(n);
    rep(i,0,n)
    cin>>v[i];
    sort(all(v));
    j=0;
    rep(i,0,n-m)
    j+=v[i];
    cout<<j;
}
int main()
{
    ll test=1;
    while(test--)
    {
        cicada();
    }
}

Measured memory_bytes: 1792
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
const int INF = 1e9;
const ll LINF = 1e18;

int main(void) {
    cin.tie(0); ios_base::sync_with_stdio(false);
    string s; cin >> s;
    sort(s.begin(),s.end());
    if(s == "abc") cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0;
}


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

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	string s;
	cin >> s;
	rep(op1,2){
		rep(op2,2){
			rep(op3,2){
				int num = (s[0] - '0');
				if(op1) num += (s[1] - '0');
				else num -= (s[1] - '0');
				if(op2) num += (s[2] - '0');
				else num -= (s[2] - '0');
				if(op3) num += (s[3] - '0');
				else num -= (s[3] - '0');
				if(num != 7) continue;
				cout << s[0] << (op1 ? "+" : "-");
				cout << s[1] << (op2 ? "+" : "-");
				cout << s[2] << (op3 ? "+" : "-");
				cout << s[3] << "=7" << endl;
				return 0;
			}
		}
	}
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<stack>
#include<queue>
#include<map>
#include<functional>
#include<math.h>
using namespace std;
#define rep(i,n) for(ll i=0;i<(n);i++)
#define pf(n) printf("%d\n",n)
#define pff(a,b) printf("%d  %d\n",a,b);
typedef long long ll;
typedef pair<ll, ll> p;
const int INF = 1001001001;
const double PI = acos(-1);

int main() {
	string s;
	cin >> s;

	int sum = 0;
	rep(i, s.size()) {
		sum += s[i] - '0';
	}
	//cout << sum << endl;
	if (sum % 9==0)puts("Yes");
	else puts("No");

	return 0;
}

Measured memory_bytes: 3728
#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>
#include<numeric>
using namespace std;

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

typedef unsigned long long ul;
typedef unsigned int ui;
ll mod = 1000000007;
const ll INF = mod * mod;
typedef pair<int, int>P;
#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++)
#define all(v) (v).begin(),(v).end()
typedef pair<ll, ll> LP;
typedef long double ld;
typedef pair<ld, ld> LDP;
const ld eps = 1e-12;
const ld pi = acos(-1.0);

ll mod_pow(ll a, ll n, ll m = mod) {
	ll res = 1;
	while (n) {
		if (n & 1)res = res * a%m;
		a = a * a%m; n >>= 1;
	}
	return res;
}

struct modint {
	ll n;
	modint() :n(0) { ; }
	modint(ll m) :n(m) {
		if (n >= mod)n %= mod;
		else if (n < 0)n = (n%mod + mod) % mod;
	}
	operator int() { return n; }
};
bool operator==(modint a, modint b) { return a.n == b.n; }
modint operator+=(modint &a, modint b) { a.n += b.n; if (a.n >= mod)a.n -= mod; return a; }
modint operator-=(modint &a, modint b) { a.n -= b.n; if (a.n < 0)a.n += mod; return a; }
modint operator*=(modint &a, modint b) { a.n = ((ll)a.n*b.n) % mod; return a; }
modint operator+(modint a, modint b) { return a += b; }
modint operator-(modint a, modint b) { return a -= b; }
modint operator*(modint a, modint b) { return a *= b; }
modint operator^(modint a, int n) {
	if (n == 0)return modint(1);
	modint res = (a*a) ^ (n / 2);
	if (n % 2)res = res * a;
	return res;
}

ll inv(ll a, ll p) {
	return (a == 1 ? 1 : (1 - p * inv(p%a, a)) / a + p);
}
modint operator/(modint a, modint b) { return a * modint(inv(b, mod)); }
const int max_n = 10000;
modint fact[max_n], factinv[max_n];
void init_f() {
	fact[0] = modint(1);
	for (int i = 0; i < max_n - 1; i++) {
		fact[i + 1] = fact[i] * modint(i + 1);
	}
	factinv[max_n - 1] = modint(1) / fact[max_n - 1];
	for (int i = max_n - 2; i >= 0; i--) {
		factinv[i] = factinv[i + 1] * modint(i + 1);
	}
}
modint comb(int a, int b) {
	if (a < 0 || b < 0 || a < b)return 0;
	return fact[a] * factinv[b] * factinv[a - b];
}

int dx[4] = { 0,1,0,-1 };
int dy[4] = { 1,0,-1,0 };


ll cnt[1 << 18];
void solve() {
	int n; cin >> n;
	vector<int> a(n);
	rep(i, n) {
		cin >> a[i];
		cnt[a[i]]++;
	}
	ll sum = 0;
	rep1(i, n) {
		sum += cnt[i] * (cnt[i] - 1) / 2;
	}
	rep(i, n) {
		ll ans = sum;
		ans -= cnt[a[i]] * (cnt[a[i]] - 1) / 2;
		ans += (cnt[a[i]] - 1)*(cnt[a[i]] - 2) / 2;
		cout << ans << "\n";
	}
}


signed main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	cout << fixed << setprecision(7);
	//init_f();
	//init();
	//int t; cin >> t; rep(i, t)solve();
	solve();
	stop
		return 0;
}

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

int main(){
    int N, M;
    cin >> N >> M;
    vector<int> A(M), B(M);
    for(int i=0; i<M; i++) cin >> A.at(i) >> B.at(i);
    queue<int> decide;
    set<int> no_decide;
    vector<int> torch(N - 1);
    decide.push(1);
    for(int i = 2; i<=N; i++) no_decide.insert(i);

    vector<set<int> > path(N);
    int a, b;
    for(int i=0; i<M; i++){
        a = A.at(i);
        b = B.at(i);
        path.at(a-1).insert(b);
        path.at(b-1).insert(a);
    }
    
    int t, u;
    while(!decide.empty() && !no_decide.empty()){
        t = decide.front();
        decide.pop();
        for(auto i=path.at(t-1).begin();i!=path.at(t-1).end();i++){
            u = *i;
            if(no_decide.find(u) != no_decide.end()){
                no_decide.erase(u);
                    decide.push(u);
                    torch.at(u - 2) = t;
            }
        }
    }
    if(!no_decide.empty()) cout << "No" << endl;
    else{
        cout << "Yes" << endl;
        for(int i=0; i<N-1; i++) cout << torch.at(i) << endl;
    }
}

Measured memory_bytes: 33272
#include<stdio.h>

int main()
{

  int i,j,n,minj,a[100],count=0,t;

  scanf("%d",&n);
  for(i=0;i<n;i++)
    {
      scanf("%d",&a[i]);
    }

  for(i=0;i<n;i++){
	  minj=i;
    for(j=i;j<n;j++)
	{
	  if(a[j]< a[minj])
	    {
	      minj=j;
	    } 
	}  
    if(i!=minj)
      {
	t=a[i];
	a[i]=a[minj];
	a[minj]=t;
	count++;
      }
    }

  for(i=0;i<n-1;i++)
    {
      printf("%d ",a[i]); 
    }
  printf("%d\n",a[i]);
  printf("%d\n",count);

  return 0;
}

Measured memory_bytes: 600
import Control.Applicative

main = do 
    [a,b,c,x,y] <- map read . words <$> getLine
    print $ solve a b c x y

solve :: Int -> Int -> Int -> Int -> Int -> Int
solve a b c x y = z*d + e*(x-z) + f*(y-z)
    where z = min x y
          d = min (2*c) (a+b)
          e = min (2*c) a
          f = min (2*c) b


Measured memory_bytes: 508
#include<bits/stdc++.h>
using namespace std;
const int N=1e5+10,M=5e5+10;
int n,m,d[M],cnt;
map<int,int>g[N];
deque<int>Q;
int head[M],to[M<<2],nxt[M<<2],w[M<<2],tot;

inline int rd()
{
	char ch=getchar();int x=0,f=1;
	while(!isdigit(ch)){if(ch=='-') f=-1;ch=getchar();}
	while(isdigit(ch)){x=x*10+(ch^48);ch=getchar();}
	return x*f;
}

inline int get(int x,int y)
{
	if(g[x].find(y)!=g[x].end()) return g[x][y];
	else return (g[x][y]=++cnt);
}

inline void lk(int u,int v,int cc)
{to[++tot]=v;nxt[tot]=head[u];head[u]=tot;w[tot]=cc;}

int main(){
	int i,j,x0,y0,xc,yc,ix,iy,iz;
	memset(d,0x3f,sizeof(d));
	n=rd();m=rd();
	for(i=1;i<=n;++i) g[i][0]=++cnt;
	for(;m;m--){
	    ix=rd();iy=rd();iz=rd();
	    x0=get(ix,0);y0=get(iy,0);
	    xc=get(ix,iz);yc=get(iy,iz);
	    lk(xc,yc,0);lk(yc,xc,0);
	    lk(x0,yc,1);lk(yc,x0,1);
	    lk(xc,y0,1);lk(y0,xc,1);
	}
	d[1]=0;
	Q.push_back(1);
	for(;!Q.empty();){
		ix=Q.back();Q.pop_back();
		for(i=head[ix];i;i=nxt[i]){
			j=to[i];
			if(d[j]>d[ix]+w[i]){
				d[j]=d[ix]+w[i];
				if(w[i]==1) Q.push_front(j);
				else Q.push_back(j);
			}
		}
	}
	if(d[n]>M) puts("-1");
	else printf("%d\n",d[n]>>1);
}

Measured memory_bytes: 54144
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int n, m;
	cin>>n>>m;
	vector<int> vectS(m);
	vector<int> vectC(m);
	for(int i=0; i<m;i++)
	{
		int s, c;
		cin>>s>>c;
		vectS[i] = s;
		vectC[i] = c;
	}
	for(int i=0; i<1000;i++)
	{
		bool flag = true;
		string num = to_string(i);
		if(num.size()!=n)
			continue;
		for(int j=0; j<m;j++)
		{
			int digit = vectS[j]-1;
			int temp = stoi(num.substr(digit,1));
			if(temp!=vectC[j])
				flag = false;
		}
		if(flag)
		{
			cout<<i<<"\n";
			return 0;
		}
	}
	cout<<"-1\n";
	return 0;
}

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

int main()
{

    long N, M;
    long task=0;
    cin >> N >> M;
    for (int i = 0; i < M; i++)
    {
        long tmp;
        cin >> tmp;
        task += tmp;
    }
    cout << max(-1L, N - task) << endl;
}

Measured memory_bytes: 3616
#include <bits/stdc++.h>
#define rep(i, a, n) for (int i = a; i < n; i++)
#define repr(i, a, n) for (int i = n - 1; i >= a; i--)
using namespace std;
using ll = long long;
using P = pair<int, int>;
template <typename T> void chmin(T &a, T b) { a = min(a, b); }
template <typename T> void chmax(T &a, T b) { a = max(a, b); }

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

  const int dy[4] = {0, 1, 0, -1};
  const int dx[4] = {1, 0, -1, 0};

  int h, w;
  cin >> h >> w;
  vector<string> map_vec(h);
  rep(i, 0, h) cin >> map_vec[i];

  int ans = 0;
  rep(i, 0, h) {
    rep(j, 0, w) {
      int maxv = 0;
      if (map_vec[i][j] == '#')
        continue;
      vector<vector<int>> dist(h, vector<int>(w, -1));
      dist[i][j] = 0;
      queue<pair<int, int>> que;
      que.push(make_pair(i, j));
      while (!que.empty()) {
        auto cur = que.front();
        int y = cur.first;
        int x = cur.second;
        que.pop();

        rep(k, 0, 4) {
          int next_y = y + dy[k];
          int next_x = x + dx[k];
          if (next_y < 0 || next_y >= h || next_x < 0 || next_x >= w)
            continue;
          if (map_vec[next_y][next_x] == '#')
            continue;

          if (dist[next_y][next_x] == -1) {
            que.push(make_pair(next_y, next_x));
            dist[next_y][next_x] = dist[y][x] + 1;
          }
        }
      }

      rep(y, 0, h) rep(x, 0, w) chmax(maxv, dist[y][x]);
      chmax(ans, maxv);
    }
  }

  cout << ans << endl;
}


Measured memory_bytes: 3572
import numpy as np
import math

a,b,h,m=map(int,input().split(' '))
a_angle=(360/12)*(h+m/60)
b_angle=(360/60)*m
theta=math.radians(abs(a_angle - b_angle))
print((a**2+b**2-2*a*b*np.cos(theta))**(1/2))

Measured memory_bytes: 27172
N = int(input())
A = list(map(int, input().split()))

Ai = dict()
ans = 0
for i, v in enumerate(A):
    ai = i + v
    if ai in Ai:
        Ai[ai].append(i)
    else:
        Ai[ai] = [i]
for i, v in enumerate(A):
    aj = i - v
    if aj in Ai:
        ans += len(Ai[aj])
print(ans)

Measured memory_bytes: 60620
#include<stdio.h>
#include<limits.h>
int main(){
	int n,temp,a,i;
	long sum=0,min=LONG_MAX,max=LONG_MIN;
	scanf("%d",&n);
	for(i=0;i<n;i++){
		scanf("%d",&a);
		sum+=a;
		if(min>a){
			min=a;
		}
		if(max<a){
			max=a;
		}
	}
	printf("%ld %ld %ld\n",min,max,sum);
}


Measured memory_bytes: 2140
package main

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

type paint struct {
	graph, result map[int]map[int]bool
	colors        []int
}

func main() {
	N := nextInt()
	M := nextInt()

	as, bs := make([]int, M), make([]int, M)
	graph, result := map[int]map[int]bool{}, map[int]map[int]bool{}
	for i := 0; i < M; i++ {
		as[i] = nextInt() - 1
		bs[i] = nextInt() - 1

		if graph[as[i]] == nil {
			graph[as[i]] = map[int]bool{}
		}
		if graph[bs[i]] == nil {
			graph[bs[i]] = map[int]bool{}
		}
		graph[as[i]][bs[i]], graph[bs[i]][as[i]] = true, true
	}
	Q := nextInt()
	vs, ds, cs := make([]int, Q), make([]int, Q), make([]int, Q)
	for i := 0; i < Q; i++ {
		vs[i] = nextInt() - 1
		ds[i] = nextInt()
		cs[i] = nextInt()
	}

	p := paint{graph: graph, result: result, colors: make([]int, N)}

	for i := Q - 1; i >= 0; i-- {
		p.dp(vs[i], ds[i], cs[i])
	}

	for _, c := range p.colors {
		fmt.Println(c)
	}
}

func (p *paint) dp(v, d, c int) {
	if p.result[v] == nil {
		p.result[v] = map[int]bool{}
	}

	if p.result[v][d] {
		return
	}

	p.result[v][d] = true

	if d == 0 {
		p.colors[v] = c
		return
	}

	p.dp(v, d-1, c)

	for u, exist := range p.graph[v] {
		if exist {
			p.dp(u, d-1, c)
		}
	}
}

// Input. ----------

var sc = bufio.NewScanner(os.Stdin)

func init() {
	sc.Buffer([]byte{}, math.MaxInt64)
	sc.Split(bufio.ScanWords)
}

func nextInt() int {
	sc.Scan()
	i, err := strconv.Atoi(sc.Text())
	if err != nil {
		panic(err)
	}

	return i
}

func nextString() string {
	sc.Scan()
	if err := sc.Err(); err != nil {
		panic(err)
	}

	return sc.Text()
}

// ---------- Input.

// Util. ----------

func min(x, y int) int {
	if x < y {
		return x
	}

	return y
}

func max(x, y int) int {
	if x > y {
		return x
	}

	return y
}

func abs(x int) int {
	return int(math.Abs(float64(x)))
}

// ---------- Util.


Measured memory_bytes: 73472
//
//  atcoder.cpp
//
//
///
#include <bits/stdc++.h>
#include <boost/optional.hpp>
#include <boost/range/irange.hpp>
#include <boost/range/algorithm.hpp>
#include <boost/range/numeric.hpp>
#include <boost/bimap/bimap.hpp>
#include <boost/bimap/multiset_of.hpp>
#include <boost/multi_array.hpp>
#include <boost/integer/common_factor_rt.hpp>
#include <boost/algorithm/string.hpp>
#include <boost/icl/interval_map.hpp>

#define REPI(i, S, N) for(int i=int(S); i<int(N); i++)
#define REP(i, N) REPI(i, 0, N)
#define REC(f, ...) (void)0; const auto f = [&](const auto f, __VA_ARGS__)
using namespace std;
using namespace boost::integer;

using ll = long long;
namespace bst = boost;
namespace icl = boost::icl;
template<typename T> class in {
    T value;
public:
    in() { cin >> value; }
    operator const T&() const { return value; }
    operator T&() { return value; }
    in& operator=(T source) { value = source; return *this; }
};
template<> class in<string> : public string {
public:
    in() { cin >> *this; }
};
template<class T> class inseq : public T {
public:
    template<typename... Arg> inseq(Arg... arg) : T(forward<Arg>(arg)...) { for (auto&& i : *this) cin >> i; }
};
template<class T> using invec = inseq<vector<T>>;

auto solve() {
  in<ll> N;
  invec<ll> L(N);
  ll r = 0;
  bst::sort(L);
  REP(i,N)
    for (int j = i + 1; j<N;j++)
      for (int k = j + 1; k<N;k++)
        if (L[k]!=L[i]&&L[i]!=L[j]&&L[j]!=L[k]&&L[k]<L[i]+L[j])
          r++;


  return r;
}

template<typename T> void plot(const T& func) { cout << setprecision(9) << func() << endl; }
template<> void plot<void()>(void(&func)()) { func(); }

int main() {
  plot(solve);

  return 0;
}



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

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int a;
    cin>>a;
    a= a - (a/10)*10;
    if(a==2 || a == 4 || a==5 || a== 7 || a== 9)
        cout<<"hon";
    else if(a== 3)
        cout<<"bon";
    else
        cout<<"pon";
    return 0;
}


Measured memory_bytes: 3624
// ABC 085 B- Kagami Mochi

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

int main() {
  int N;
  cin >> N;
  // Kagami Mochi 配列
  vector<int> vec(N);
  for (int i = 0; i < N; i++) {
    cin >> vec.at(i);
  }
  // 大きい順に並べる
  sort(vec.begin(), vec.end());
  reverse(vec.begin(), vec.end());

  // 同じ大きさがないか確認
  int count = 1;
  if (N == 1) {
    cout << count << endl;
  }
  else {
    for (int i = 0; i < N-1; i++) {
      if (vec.at(i) != vec.at(i+1)) {
        count++;
      }
    }
  cout << count << endl;
  }
}


Measured memory_bytes: 3656
#include<bits/stdc++.h>
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0); cout.precision(30);
#define ll long long
#define pi 3.14159265359
using namespace std;

int main()
{
    IOS;
    int x,n;
    cin>>x>>n;
    if(n==0) return cout<<x,0;
    int p[n];
    int t=0,ta,tb;
    for(int i=0;i<n;i++){
        cin>>p[i];
        if(p[i]==x) t=1;
    }
    if(t==0) return cout<<x,0;
    int a=x,b=x;
    while(true){
        a--;
        b++;
        ta=0;
        tb=0;
        for(int i=0;i<n;i++){
            if(p[i]==a) ta=1;
            if(p[i]==b) tb=1;
        }
        if(!ta) return cout<<a,0;
        if(!tb) return cout<<b,0;
    }
}


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

int main(){
    int a,b,c;
    int x = 0;
    cin >> a >> b >> c; 
    for (int y = a; y <= b; ++y){
        if (c % y == 0){
            ++x;
        }
    }
    cout << x << endl;
    
    return 0;
}


Measured memory_bytes: 3116
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
#define pb push_back
#define mp make_pair
#define deb(x) cout<< #x << " " << x << "\n";
#define INF 9223372036854775807
const ll mod=998244353;



int main() {
    
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    
    ll n,k;
    cin>>n>>k;
    vector<ll> a(n);
    for(ll i=0;i<n;i++)
        cin>>a[i];
    sort(a.begin(),a.end());
    ll sum=0;
    for(ll i=0;i<k;i++)
        sum+=a[i];
    cout<<sum;

    return 0;
}


Measured memory_bytes: 3664
import sys
N,Y = map(int,input().split())
for x in range(N+1):
    for y in range(N-x+1):
        if 10000*x+5000*y+(N-x-y)*1000==Y:
            print(x,y,N-x-y)
            sys.exit()
print("-1 -1 -1")

Measured memory_bytes: 2940
#include <bits/stdc++.h>
#define rep0(i,n) for (int i = 0; i < (n); ++i)
#define rep1(i,n) for (int i = 1; i < (n); ++i)
#define REP(i,a,b) for (int i = a; i < (b); ++i)
#define mREP(i,a,b) for (int i = a; i > (b); --i)
#define all(x) (x).begin(),(x).end()
const int INF = 1000000007;
typedef long long ll;
using namespace std;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
ll gcd(ll a, ll b) { return b ? gcd(b, a%b) : a; }
int main(){
  string a,b;
  cin>>a>>b;
  if(a == "H" && b == "H")cout<<"H"<<endl;
  else if(a == "D" && b == "H")cout<<"D"<<endl;
  else if(a == "D" && b == "D")cout<<"H"<<endl;
  else cout<<"D"<<endl;
  return 0;
}

Measured memory_bytes: 256
N,L = map(int,input().split())

apple = [L+i-1 for i in range(1,N+1)]

al = sum(apple)

pies = [al-a for a in apple]

if 0 in apple :
    ans = al
elif abs(al - pies[0]) < abs(al - pies[-1]) :
    ans = pies[0]
else :
    ans = pies[-1]

print(ans)


Measured memory_bytes: 3060
package main

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

func newScanner() *bufio.Scanner {
	scanner := bufio.NewScanner(os.Stdin)
	scanner.Split(bufio.ScanWords)
	// buf := make([]byte, 10000)
	// scanner.Buffer(buf, 1000000)
	return scanner
}

func scanInt(s *bufio.Scanner) int {
	if s.Scan() {
		t := s.Text()
		v, err := strconv.Atoi(t)
		if err == nil {
			return v
		}
		panic(err)
	} else {
		panic(s.Err())
	}
}

func main() {
	sc := newScanner()
	n := scanInt(sc)
	m := [10][10]int{}

	res := 0
	for i := 1; i <= n; i++ {
		e := i % 10
		if e == 0 {
			continue
		}

		s := i
		for s >= 10 {
			s /= 10
		}
		if s == 0 {
			continue
		}

		res += m[s][e] * 2
		if s == e {
			res++
		}
		m[e][s]++
	}

	fmt.Println(res)
}


Measured memory_bytes: 640