akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>

using namespace std;
using ll = long long;

int main(int argc, const char *argv[]) {
  int n, k;
  cin >> n >> k;

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

  ll ans = -1;
  for (int i = 0; i < vx.size() - k + 1; ++i) {
    int dist = vx[i + k - 1] - vx[i];
    if (vx[i] >= 0) {
      dist += abs(vx[i]);
    } else if (vx[i + k - 1] <= 0) {
      dist += abs(vx[i + k - 1]);
    } else {
      dist += min(abs(vx[i]), abs(vx[i + k - 1]));
    }

    if (ans < 0 || ans > dist) {
      ans = dist;
    }
  }

  cout << ans << '\n';

  return 0;
}

Measured memory_bytes: 4016
#define __USE_MINGW_ANSI_STDIO 0
#include <bits/stdc++.h>
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl '\n'
#define rep(i, a, b) for (int i = a; i < b; i++)
#define ff first
#define pii pair<int, int>
#define vii vector< pair<int,int> >
#define vi vector<int>
#define vvi vector< vector< int> >
#define ss second
#define MOD 998244353LL
#define mod 1000000007
#define pb push_back
#define mp make_pair
#define int long long
#define all(a) a.begin(), a.end()
#define inf (1LL<<61)
#define ull unsigned long long
#define trace1(x)                cout<<#x<<": "<<x<<endl
#define trace2(x, y)             cout<<#x<<": "<<x<<" | "<<#y<<": "<<y<<endl
#define trace4(x, y, z, d)          cout<<#x<<":" <<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<" | "<<#d<<": "<<d<<endl

#define trace3(x, y, z)          cout<<#x<<":" <<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<endl
#define debug1(x) cerr << #x << ": " << x <<'\n'
#define debug2(x, y) cerr << #x << ": " << x << '\t' << #y << ": " << y <<'\n'
#define debug3(x, y, z) cerr << #x << ": " << x << '\t' << #y << ": " << y << '\t' << #z << ": " << z <<'\n'
using namespace std;
int dx[]={1,0,-1, 0};int dy[]={0,1,0, -1}; //4 Direction
//int dx[]={1,1,0,-1,-1,-1,0,1};int dy[]={0,1,1,1,0,-1,-1,-1};//8 direction
bool compare(const pair<int,int> &a,
             const pair<int,int> &b)
{
    if(a.ff == b.ff) {
        return (b.ss < a.ss);
    }
    return (a.ff<b.ff);
}

bool prime[1000001];
void SieveOfEratosthenes(int n) 
{
    // Create a boolean array "prime[0..n]" and initialize
    // all entries it as true. A value in prime[i] will
    // finally be false if i is Not a prime, else true.

    memset(prime, true, sizeof(prime));

    for (int p=2; p*p<=n; p++)
    {
        if (prime[p] == true)
        {
            for (int i=p*p; i<=n; i += p)
                prime[i] = false;
        }
    }
}
int cnt[100000] = {0};
int32_t main()
{
    IOS;
    // #ifndef ONLINE_JUDGE
    // freopen("input.txt","r",stdin);
    // freopen("output.txt","w",stdout);
    // #endif
    /********************* From here ***********************/
    int n,m;
    cin >> n;
    cnt[n] = 1;
    int i = 1;
    int ans = 0;
    while(1){
    	//trace2(n , i);
    	if(n%2==0){
    		n = n/2;
    	}
    	else{
    		n = 3*n+1;
    	}
    	if(cnt[n]==1){
    		ans = i;
    		break;
    	}
    	cnt[n] = 1;
    	i++;
    }

    cout << ans+1;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
#define rep(i,b) for(ll i=0;i<b;i++)
#define ll long long
using namespace std;
#define vl vector<ll>
#define vvl vector<vector<ll>>
#define vvvl vector<vector<vector<ll>>>
#define debug(x) cerr<<#x<<" "<<x<<'\n';
bool cmp(pair<ll,ll> a, pair<ll,ll> b) { return a.second < b.second; }
ll mod = 1e9+7;
signed main() {
    vl ret; ll n; cin>>n;
    for(ll i = 1; i * i <= n; i++) {
        if(n % i == 0) {
            ret.push_back(i);
            if(i * i != n) ret.push_back(n / i);
        }
    }
    cout<<to_string(ret[ret.size()-1]).length()<<endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <sstream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <ctime>
#include <cstring>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <bitset>
#include <numeric>
#include <utility>
#include <iomanip>
#include <algorithm>
#include <functional>
using namespace std;

typedef long long ll;
typedef vector<int> vint;
typedef vector<long long> vll;
typedef pair<int,int> pint;
typedef pair<long long, long long> pll;

#define MP make_pair
#define PB push_back
#define ALL(s) (s).begin(),(s).end()
#define EACH(i, s) for (__typeof__((s).begin()) i = (s).begin(); i != (s).end(); ++i)
#define COUT(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << endl

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; }
template<class T1, class T2> ostream& operator << (ostream &s, pair<T1,T2> P) 
{ return s << '<' << P.first << ", " << P.second << '>'; }
template<class T> ostream& operator << (ostream &s, vector<T> P) 
{ for (int i = 0; i < P.size(); ++i) { if (i > 0) { s << " "; } s << P[i]; } return s << endl; }
template<class T1, class T2> ostream& operator << (ostream &s, map<T1,T2> P) 
{ EACH(it, P) { s << "<" << it->first << "->" << it->second << "> "; } return s << endl; }



double a, b, c, d, e, f, g, h;

int main() {
    while (cin >> a >> b >> c >> d >> e >> f >> g >> h) {
        double x1 = c-a, y1 = d-b, x2 = g-e, y2 = h-f;
        double pro = x1 * x2 + y1 * y2;
        
        if (abs(pro) < 1e-12) puts("YES");
        else puts("NO");
    }
    
    return 0;
}


Measured memory_bytes: 1184
n=int(input())
a=list(map(int,input().split()))
l=[]
for i in range(max(a)+3):
  l.append(0)
for j in range(n):
  l[a[j]+1]+=1
m=[]
for i in range(1,max(a)+2):
  m.append(l[i-1]+l[i]+l[i+1])
print(max(m))

Measured memory_bytes: 13964
#include <bits/stdc++.h>
#define fi first
#define se second
#define m_p make_pair
#define p_b push_back
#define e_b emplace_back
#define all(x) (x).begin(),(x).end()
#define sz(x) ((int)(x).size())
using namespace std;
using ll = long long;
using ld = long double;
template<class T> bool chmax(T &a,T b){if(a<b){a=b;return true;}return false;}
template<class T> bool chmin(T &a,T b){if(a>b){a=b;return true;}return false;}

int main(){
  ios_base::sync_with_stdio(false);cin.tie(0);
  int N;
  cin >> N;
  vector<ll> A(N),B(N);
  for(int i=0;i<N;i++)  cin >> A.at(i) >> B.at(i);

  sort(all(A));
  sort(all(B));
  reverse(all(B));
  if(N%2==1){
    ll mi=A.at(N/2);
    ll ma=B.at(N/2);
    cout << ma-mi+1 << endl;
  }
  else{
    ll mi1=A.at(N/2-1);
    ll mi2=A.at(N/2);
    ll ma1=B.at(N/2-1);
    ll ma2=B.at(N/2);
    cout << (ma1+ma2)-(mi1+mi2)+1 << endl;
  }

  return 0;
}

Measured memory_bytes: 6364
#include <iostream>
#include <vector>
#include <algorithm>
#include <stack>
#include <string>
#include <cmath>
#include <cstdio>
using namespace std;

#define PI 4*atan(1);

int main(){
  int n, m;
  while(cin >> n >> m && n, m){
    int start = 1, cnt = 0;
    vector<int> masu, saikoro;
    for(int i = 0; i < n; i++){
      int tmp;
      cin >> tmp;
      masu.push_back(tmp);
    }
    for(int i = 0; i < m; i++){
      int tmp;
      cin >> tmp;
      saikoro.push_back(tmp);
    }
    for(int i = 0; i < m; i++){
      start += saikoro[i];
      cnt++;
      if(start >= n){
        cout << cnt << endl;
        break;
      }
      start += masu[start - 1];
      if(start >= n){
        cout << cnt << endl;
        break;
      }
    }
  }
}

Measured memory_bytes: 1228
s = input()
t = input()

lens = len(s)
lent = len(t)
cnt_min = 10**5
for i in range(lens-lent+1):
  tmp = 0
  for j in range(lent):
    if s[i+j] != t[j]:
      tmp += 1
  if tmp < cnt_min:
    cnt_min = tmp
    
print(cnt_min)

Measured memory_bytes: 9128
#include <vector>
#include <string>
#include <iostream>
#include <queue>
#include <algorithm>
#include <functional>
#include <map>
#include <array>
#include <cmath>
#include <set>

long long PRIME = 1e9 + 7;
long long PRIME2 = 998244353;

using namespace std;


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

    string S;
    cin >> S;

    vector<bool> one(10, false);
    vector<bool> second(100, false);
    vector<bool> third(1000, false);

    int num = S[0] - '0';
    one[num] = true;

    num = S[1] - '0';
    for(int i = 0; i < 10; ++i){
        if(one[i]){
            second[i * 10 + num] = true;
        }
    }
    one[num] = true;

    for(int i = 2; i < N; ++i){
        num = S[i] - '0';

        for(int j = 0; j < 100; ++j){
            if(second[j]){
                third[j * 10 + num] = true;
            }
        }
        for(int j = 0; j < 10; ++j){
            if(one[j]){
                second[j * 10 + num] = true;
            }
        }
        one[num] = true;
    }

    int sum = 0;
    for(int i = 0; i < 1000; ++i){
        if(third[i]){
            ++sum;
        }
    }
    cout << sum;
}



Measured memory_bytes: 256
import scala.io.{StdIn => in}
import scala.collection.{mutable => mu}

object Main extends App {
  val INF = 2L << 40
  val Array(a, b, q) = in.readLine.split(" ").map(_.toInt)
  val s = Iterator.continually(in.readLong)
    .take(a)
    .to[mu.ArrayBuffer]
  -INF +=: s
  s += INF
  // val s = s.toArray

  val t = Iterator.continually(in.readLong)
    .take(b)
    .to[mu.ArrayBuffer]
  -INF +=: t
  t += INF
  // val t = t.toArray

  val out = new java.io.PrintWriter(System.out)
  Iterator.continually(in.readLong)
    .take(q)
    .foreach(x => {
      var dist = Long.MaxValue
      for {
        k <- 0 until 2
        arrA = if(k == 0) s else t
        arrB = if(k == 0) t else s
        i <- 0 until 2
        posA = math.min(binarySearch(arrA, x) + i, arrA.size-1)
        ax = arrA(posA)
        j <- 0 until 2
        posB = math.min(binarySearch(arrB, ax) + j, arrB.size-1)
        bx = arrB(posB)
      } {
        val a = ( x - ax).abs
        val b = (ax - bx).abs
        dist = math.min(dist, a + b)
      }
      out.println(dist)
    })
  out.flush

    def binarySearch(arr:mu.ArrayBuffer[Long], x:Long):Int = {
    var left = 0
    var right = arr.size

    def loop(left:Int, right:Int):Int = {
      if(right - left < 2) left
      else {
        val mid = (left + right) / 2
        if(arr(mid) <= x) loop(mid,right)
        else loop(left, mid)
      }
    }
    loop(left, right)
  }
}

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

typedef pair<int,int> P;

vector<P> ans;


int main() {

  int n,k;
  cin >> n >> k;

  int max2 = (n - 1) * (n - 2) / 2;

  if(max2 < k) {
    cout << -1 << endl;
    return 0;
  }

  for(int i = 1; i < n; i++) ans.push_back(P(i,n));

  
  for(int i = 1; i < n; i++) {
    for(int j = i + 1; j < n; j++) {
      if(max2 == k) {
	cout << ans.size() << endl;
	for(int l = 0; l < ans.size(); l++) {
	  cout << ans[l].first <<' '<< ans[l].second << endl;
	}
	return 0;
      }
      ans.push_back(P(i,j));
      max2--;
    }
  }

  	cout << ans.size() << endl;
	for(int l = 0; l < ans.size(); l++) {
	  cout << ans[l].first <<' '<< ans[l].second << endl;
	}
	return 0;
}

  


Measured memory_bytes: 384
from collections import defaultdict, deque
from heapq import heappush, heappop


def bfs(V, s, t):
    q = deque([(0, s)])
    used = set()
    
    while q:
        dist, a = q.popleft()
        used.add(a)
        if a == t:
            break
        for b in V[a]:
            if b in used: continue
            q.append((dist+1, b))
    
    if a != t:
        dist = -1
    else:
        dist = -1 if dist%3 else dist//3
    return dist

def dijkstra1(V, n, source):
    # O(ElogV)

    inf = float("inf")
    dist = [inf] * (n+1)
    dist[source] = 0
    q = [(0, source)]

    while q:
        cost, u = heappop(q)
        if dist[u] < cost:
            continue
        for c, v in V[u]:
            if dist[v] > dist[u] + c:
                dist[v] = dist[u] + c
                heappush(q, (dist[v], v))

    return dist


if __name__ == "__main__":
    V = defaultdict(list)
    N, M = map(int, input().split())
    for _ in range(M):
        u, v = map(int, input().split())
        V[u].append((1, v+(N)))
        V[u+(N)].append((1, v+(2*N)))
        V[u+(2*N)].append((1, v))

    S, T = map(int, input().split())
    dist = dijkstra1(V, 3*N, S)[T]
    print(-1 if dist==float("inf") else dist//3)

Measured memory_bytes: 125144
#include <bits/stdc++.h>
#define ll long long
#define mk make_pair
using namespace std;

const int N = 3e5 + 5;

int n, l, t, ne, po, w[N], x[N], y[N], z[N];

int main() {
	cin >> n >> l >> t;
	for (int i = 1; i <= n; i++) scanf("%d %d", x + i, w + i);
	for (int i = 1; i <= n; i++) {
		if (w[i] == 2) w[i] = -1;
		y[i] = x[i] + w[i] * t;
		y[i] %= l;
		y[i] += l;
		y[i] %= l;
	}
	int p = y[1];
	sort(y + 1, y + 1 + n);
	if (w[1] == 1) {
		t *= 2;
		int tmp = 0;
		for (int i = 1; i <= n; i++) {
			if (w[i] == 1) continue;
			tmp += t / l % n;
			int tt = (x[i] - x[1] + l) % l;
			if (t % l > tt) tmp++;
			tmp %= n;
		}
		int s = 1 + n, id = 1 + tmp;
		for (int i = 1; i <= n; i++) y[i + n] = y[i + n + n] = y[i];
		for (int i = 1 + n; i <= n + n; i++) {
			if (y[i] == p && y[i - 1] != p) {
				s = i;
				break;
			}
		}
		for (int i = s -id + 1; i < s - id + 1 + n; i++) printf("%d\n", y[i]);
	} else {
		t *= 2;
		int tmp = 0;
		for (int i = 1; i <= n; i++) {
			if (w[i] == -1) continue;
			tmp += t / l % n;
			int tt = l - (x[i] - x[1] + l) % l;
			if (t % l > tt) tmp++;
			tmp %= n;
		}
		int s = 1 + n, id = 1 + n - tmp;
		if (id > n) id = 1;
		for (int i = 1; i <= n; i++) y[i + n] = y[i + n + n] = y[i];
		for (int i = 1 + n; i <= n + n; i++) {
			if (y[i] == p && y[i + 1] != p) {
				s = i;
				break;
			}
		}
		for (int i = s -id + 1; i < s - id + 1 + n; i++) printf("%d\n", y[i]);
	}
}

Measured memory_bytes: 4096
#include <algorithm>
#include <fstream>
#include <iomanip>
#include <iostream>
#include <map>
#include <math.h>
#include <set>
#include <stdio.h>
#include <string>
#include <utility>
#include <vector>

using namespace std;

int main() {
  int n;
  cin >> n;
  long long a[301][301] = {0};
  bool b[301][301] = {0};
  for (int i = 0; i < n; i++)
    for (int j = 0; j < n; j++)
      cin >> a[i][j];
  long long ans = 0;
  for (int k = 0; k < n; k++)
    for (int i = 0; i < n; i++)
      for (int j = 0; j < n; j++)
        if (a[i][j] > a[i][k] + a[k][j]) {
          cout << -1 << endl;
          return 0;
        }
  for (int i = 0; i < n; i++)
    for (int j = 0; j < n; j++)
      for (int k = 0; k < n; k++) {
        if (i == k || j == k)
          continue;
        if (a[i][j] == a[i][k] + a[k][j])
          b[i][j] = true;
      }
  for (int i = 0; i < n; i++)
    for (int j = i + 1; j < n; j++)
      if (!b[i][j])
        ans += a[i][j];
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 1024
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <algorithm>
#include <numeric>
#include <queue>

using namespace std;

void AGC033A()
{
	string str1, str2;
	cin >> str1 >> str2;
	int H = stoi(str1);
	int W = stoi(str2);

	vector<pair<int, int> > black;

	for (int i = 0; i < H; ++i)
	{
		cin >> str1;
		for (int j = 0; j < W; ++j)
		{
			if (str1[j] == '#')
			{
				black.push_back(make_pair(i, j));
			}
		}
	}

	queue<pair<int, int> > qu;
	vector<vector<int> > ct(H, vector<int>(W, -1));
	for (const auto& x : black)
	{
		qu.push(x);
		ct[x.first][x.second] = 0;
	}
	int distance = 0;
	vector<pair<int, int> > delta = { {-1,0},{1,0},{0,-1},{0,1} };
	while(!qu.empty())
	{
		auto x = qu.front();
		qu.pop();
		int baseCt = ct[x.first][x.second];
		for (auto& dx : delta)
		{
			int xx = x.first + dx.first;
			int yy = x.second + dx.second;
			if (xx > -1 && xx < H && yy > -1 && yy < W && ct[xx][yy] == -1)
			{
				ct[xx][yy] = baseCt + 1;
				qu.push(make_pair(xx, yy));
				distance = max(distance, baseCt + 1);
			}
		}
	}
	cout << distance << endl;
}

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

Measured memory_bytes: 20204
# -*- coding: utf-8 -*-
n = int(input())
s = list(input())

l = ['A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z']

ans = []
for ss in s:
    ind = l.index(ss) + 1
    n_ind = ind + n
    r = n_ind % 26 - 1
    ans.append(l[r])

print("".join(map(str,ans)))


Measured memory_bytes: 3316
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define F first
#define S second
#define pii pair<int, int>
#define eb emplace_back
#define all(v) v.begin(), v.end()
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rep3(i, l, n) for (int i = l; i < (n); ++i)
#define sz(v) (int)v.size()
const int inf = 1e9 + 7;
const ll INF = 1e18;
#define abs(x) (x >= 0 ? x : -(x))
#define lb(v, x) (int)(lower_bound(all(v), x) - v.begin())
#define ub(v, x) (int)(upper_bound(all(v), x) - v.begin())
template<typename T1, typename T2> inline bool chmin(T1 &a, T2 b) { if (a > b) { a = b; return 1; } return 0; }
template<typename T1, typename T2> inline bool chmax(T1 &a, T2 b) { if (a < b) { a = b; return 1; } return 0; }
template<typename T> T gcd(T a, T b) { if (b == 0) return a; return gcd(b, a % b); }
template<typename T> T lcm(T a, T b) { return a / gcd(a, b) * b; }
template<typename T> T pow(T a, int b) { return b ? pow(a * a, b / 2) * (b % 2 ? a : 1) : 1; }
const int mod = 1000000007;
ll modpow(ll a, int b) { return b ? modpow(a * a % mod, b / 2) * (b % 2 ? a : 1) % mod : 1; }
template<class T> ostream& operator<<(ostream& os, const vector<T>& vec) { for (auto &vi: vec) os << vi << " "; return os; }
template<class T, class U> ostream& operator<<(ostream& os, const pair<T, U>& p) { os << p.F << " " << p.S; return os; }
template<class T> inline void add(T &a, int b) { a += b; if (a >= mod) a -= mod; }



void solve();

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

    int T;
    // cin >> T;
    T = 1;

    while (T--) {
        solve();
    }
}

void solve() {
  int n;
  cin >> n;
  vector<double> p(n);
  rep(i, n) cin >> p[i];

  vector<double> dp(n + 1); // 表が出た回数と確率
  dp[0] = 1;
  rep(i, n) {
    vector<double> dp2(n + 1);
    rep(j, n + 1) {
      dp2[j + 1] += dp[j] * p[i];
      dp2[j] += dp[j] * (1 - p[i]);
    }
    dp = dp2;
    // cout << dp << endl;
  }
  cout << fixed << setprecision(10);
  cout << accumulate(dp.begin() + (n + 2) / 2, dp.end(), 0.0) << endl;
}


Measured memory_bytes: 384
#include <stdio.h>
int main() {
  int abc[3], n, max = 0, i = 0, ans;
  for (i = 0; i < 3; i++) {
    scanf("%d", &abc[i]);
    if (max < abc[i]) {
      max = abc[i];
      n = i;
    }
  }
  ans = max * 10;
  for (i = 0; i < 3; i++) {
    ans += abc[i];
  }
  ans -= abc[n];
  printf("%d", ans);
}

Measured memory_bytes: 128
def conv(x, n):
    if x < 0: return None
    if n < 2 or 16 < n: return None

    if x == 0: return 0

    nchar = '0123456789ABCDEF'
    digit = 0

    result = ''

    while x > 0:
        result = nchar[x % n] + result
        x = x // n

    return result

n,k=map(int,input().split())
ans=conv(n,k)
print(len(ans))


Measured memory_bytes: 38256
#include<bits/stdc++.h>
using namespace std;
int main()
{

    int n;
    cin>>n;
    long double sum=0.0000;
    while(n--)
    {
       long double n;
        string s;
        cin>>n;
        cin>>s;
        if(s[0]=='B' && s[1]=='T' && s[2]=='C')
        {
            n=n*380000.0;


        }
        sum=sum+n;


    }
    cout<<sum<<endl;

}


Measured memory_bytes: 256
MOD=10**9+7
n,a,b=map(int,input().split())
def modpow(a, p, mod=MOD):
    # return a**p (mod MOD) O(log p)
    if p==0: return 1
    if p%2==0:
        half = modpow(a, p//2, mod)
        return half*half % mod
    else:
        return a * modpow(a, p-1, mod) % mod

ret=modpow(2,n)
class ModInt:
    def __init__(self, x):
        self.x = x % MOD

    def __str__(self):
        return str(self.x)

    __repr__ = __str__

    def __add__(self, other):
        return (
            ModInt(self.x + other.x) if isinstance(other, ModInt) else
            ModInt(self.x + other)
        )

    def __sub__(self, other):
        return (
            ModInt(self.x - other.x) if isinstance(other, ModInt) else
            ModInt(self.x - other)
        )

    def __mul__(self, other):
        return (
            ModInt(self.x * other.x) if isinstance(other, ModInt) else
            ModInt(self.x * other)
        )

    def __truediv__(self, other):
        return (
            ModInt(
                self.x * pow(other.x, MOD - 2, MOD)
            ) if isinstance(other, ModInt) else
            ModInt(self.x * pow(other, MOD - 2, MOD))
        )

    def __pow__(self, other):
        return (
            ModInt(pow(self.x, other.x, MOD)) if isinstance(other, ModInt) else
            ModInt(pow(self.x, other, MOD))
        )

    __radd__ = __add__

    def __rsub__(self, other):
        return (
            ModInt(other.x - self.x) if isinstance(other, ModInt) else
            ModInt(other - self.x)
        )

    __rmul__ = __mul__

    def __rtruediv__(self, other):
        return (
            ModInt(
                other.x * pow(self.x, MOD - 2, MOD)
            ) if isinstance(other, ModInt) else
            ModInt(other * pow(self.x, MOD - 2, MOD))
        )

    def __rpow__(self, other):
        return (
            ModInt(pow(other.x, self.x, MOD)) if isinstance(other, ModInt) else
            ModInt(pow(other, self.x, MOD))
        )
def comb(x,n):
    divd=1
    for i in range(n):
        divd*=ModInt(x-i)
    for i in range(n):
        divd/=ModInt(i+1)
    return divd

print(ret-1-comb(n,a)-comb(n,b))

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

int main() {
  int a, b, C;
  cin >> a >> b >> C;
  double h = b * sin(M_PI / 180 * C);
  double S = a * h / 2;
  double cb = b * cos(M_PI / 180 * C);
  double L = a + b + sqrt((a - cb) * (a - cb) + h * h);
  cout << fixed << setprecision(8);
  cout << S << endl;
  cout << L << endl;
  cout << h << endl;
}



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

S = input()
B = list(map(int, S.split(' ')))

maximal = B[0] + B[N-2]
for i in range(N-2):
    if B[i]>B[i+1]:
        maximal += B[i+1]
    else:
        maximal += B[i]

print(maximal)
         

Measured memory_bytes: 3060
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cctype>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iostream>
#include <iterator>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>
using namespace std;

#define dump(a) (cerr << (#a) << " = " << (a) << endl)
#define FOR(it,c) for(__typeof((c).begin())it=(c).begin(); it!=(c).end();++it)
#define RFOR(it,c) for(__typeof((c).rbegin())it=(c).rbegin(); it!=(c).rend();++it)
#define exist(c, v) (find((c).begin(), (c).end(), (v)) != (c).end())

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

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

template<typename T> ostream& operator<<(ostream& os, const vector<T>& v) {
	copy(v.begin(), v.end(), ostream_iterator<T>(os, " "));
	return os;
}

string s;
string::iterator it;
const int LIMIT = 10000;

complex<int> expr();

bool is_overflow(const complex<int>& x) {
	return abs(x.real()) > LIMIT || abs(x.imag()) > LIMIT;
}

complex<int> number() {
	string::iterator start = it;
	int res = 0;
	char c;
	while((c = *it) && isdigit(c)) {
		++it;
		res = res * 10 + (int)(c - '0');
		if(is_overflow(res))
			throw "";
	}

	if(c == 'i') {
		if(res == 0 && it == start)
			res = 1;
		++it;
		return complex<int>(0, res);
	}
	else {
		return complex<int>(res, 0);
	}
}

complex<int> fact() {
	char c = *it;
	if(c == '(') {
		++it;
		const complex<int> res = expr();
		++it;
		return res;
	}
	else {
		return number();
	}
}

complex<int> term() {
	complex<int> res = fact();
	char c;
	while((c = *it) && (c == '*')) {
		++it;
		res *= fact();
		if(is_overflow(res))
			throw "";
	}

	return res;
}

complex<int> expr() {
	complex<int> res = term();
	char c;
	while((c = *it) && (c == '+' || c == '-')) {
		++it;
		if(c == '+')
			res += term();
		else
			res -= term();

		if(is_overflow(res))
			throw "";
	}

	return res;
}

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

	while(cin >> s) {
		it = s.begin();
		try {
			const complex<int> result = expr();
			if(result.imag() == 0)
				cout << result.real() << endl;
			else if(result.real() == 0)
				cout << result.imag() << 'i' << endl;
			else if(result.imag() < 0)
				cout << result.real() << result.imag() << 'i' << endl;
			else
				cout << result.real() << '+' << result.imag() << 'i' << endl;
		} catch(...) {
			cout << "overflow" << endl;
		}
	}

	return EXIT_SUCCESS;
}

Measured memory_bytes: 1256
#include<bits/stdc++.h>
using namespace std;
const int maxn=1e5+5;
int a[maxn];
int main()
{
    int n,k;
    scanf("%d%d",&n,&k);
    for(int i=0;i<n;i++)
        scanf("%d",&a[i]);
    sort(a,a+n);
    int ans=1e9;
    for(int i=0;(i+k-1)<n;i++)
    {
        int kk=a[i+k-1]-a[i];
        ans=min(ans,kk);
    }
    printf("%d\n",ans);
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
int main() {
  long long int a,b,n,m,y=0;
  long long int h[100002];
  long long int x[100002];
  cin >> n >> m;
  for(int i=1;i<=100000;i++){
    h[i]=0;
  }
  for(int i=1;i<=n;i++){
    cin >> h[i];
  }
  for(int i=1;i<=100001;i++){
    x[i]=0;
  }
  for(int i=1;i<=m;i++){
    cin >> a;
    cin >> b;
    if(h[a]<=h[b]){
      x[a]=1;
    }
    if(h[b]<=h[a]){
      x[b]=1;
    }
  }
  for(int i=1;i<=n;i++){
    if(x[i]==0){
      y++;
    }
  }
  cout << y << endl;
  return 0;
}

Measured memory_bytes: 5192
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define P pair<int,int>
using ll=int64_t;
using namespace std;
#define ketasuu(n) fixed<<setprecision(n)
#define btoe(p) p.begin(),p.end()
#define etob(p) p.rbegin(),p.rend()




int main(){
    int k,g;
    cin>>k;
    int ans=0;
    rep(i,k){
        rep(j,k){
            rep(l,k){
                g=gcd(i+1,j+1);
                g=gcd(g,l+1);
                ans+=g;
            }
        }
    }
    cout<<ans<<endl;    
}

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

int main() {
  int A, B, K;
  cin >> A >> B >> K;
  set<int> st;
  for (int i = A; i < A + K && i <= B; ++i) {
    st.insert(i);
  }
  for (int i = B; i > B - K && i >= A; --i) {
    st.insert(i);
  }
  vector<int> ans(st.begin(), st.end());
  for (int i = 0; i < ans.size(); ++i) {
    cout << ans.at(i) << endl;
  }
}


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

inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}

template<class T> inline T sqr(T x) {return x*x;}

typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> P;
typedef long long ll;

#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())
#define REVERSE(c) reverse((c).begin(),(c).end())

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

const double EPS = 1e-10;
const double PI  = acos(-1.0);
const int INT_INF = 2147483647;
const long long LL_INF = 1LL<<60;
const long long MOD = 1000000007;

#define CLR(a) memset((a), 0 ,sizeof(a))

#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

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(void){
    int a,b; cin >> a >> b;
    cout << (a>b ? a-1 : a) << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
const int INF = 0x3f3f3f3f;

int main() {
  int n, m, x;
  cin >> n >> m >> x;
  vector<int> c(n);
  vector<vector<int>> a(n, vector<int>(m));
  for (int i = 0; i < n; i++) {
    cin >> c[i];
    for (int j = 0; j < m; j++) {
      cin >> a[i][j];
    }
  }

  int ans = INF;
  for (int i = 0; i < 1 << n; i++) {
    vector<int> v(m, 0);
    int cost = 0;
    for (int j = 0; j < n; j++) {
      if (i >> j & 1) {
        for (int k = 0; k < m; k++) {
          v[k] += a[j][k];
        }
        cost += c[j];
      }
    }
    bool ok = true;
    for (int j = 0; j < m; j++) {
      if (v[j] < x) ok = false;
    }
    if (ok) ans = min(ans, cost);
  }
  if (ans == INF) {
    cout << -1 << endl;
  } else {
    cout << ans << endl;
  }

  return 0;
}


Measured memory_bytes: 3656
## coding: UTF-8
from decimal import *
from itertools import permutations, combinations,combinations_with_replacement,product
import math

#input
#N
#A1 A2 ... AN
N = int(input())


def yakusuu(n):
    #約数全列挙
    l = []
    border = int(math.sqrt(n))
    #print(border) #ここまでしか考えなくて良い
    for i in range(1, border+1):
        #print(i)
        if(n % i == 0):
            l.append(i)
            l.append(int(n/i))
    return l

#print(yakusuu(N))
#print(yakusuu(N-1))
N_yaku = yakusuu(N)
N_1_yaku = yakusuu(N-1)
if(len(N_yaku) != 1):
    del N_yaku[0]
if(len(N_yaku) >= 2 and N_yaku[-1] == N_yaku[-2]):
    del N_yaku[-1]
if(len(N_1_yaku) != 1):
    del N_1_yaku[0]
if(len(N_1_yaku) >= 2 and N_1_yaku[-1] == N_1_yaku[-2]):
    del N_1_yaku[-1]
#print('N_yaku:{}'.format(N_yaku))
#print('N_1_yaku:{}'.format(N_1_yaku))
counter = 0
#N-1の約数であるとき→Nの約数でなければOK
#NとN-1は互いに素なので気にしなくてよかった
'''
for i in N_1_yaku:
    #print(i)
    #print(i in N_yaku)
    if( (i in N_yaku) == False ) :
        print('false_hit:i:{}'.format(i))
        counter += 1
'''
counter += len(N_1_yaku)



#Nの約数であるとき
def hantei_Nyaku(k):
    rep_N = N
    #count = 0
    while True:
        if(rep_N % k == 0):
            rep_N = int(rep_N / k)
            #print(rep_N)
        else:
            break
    if((rep_N - 1) % k == 0):
        return 'Yes'
    else:
        return 'No'



for i in N_yaku:
    #print('i:{}'.format(i))
    #print(hantei_Nyaku(i))
    if(hantei_Nyaku(i) == 'Yes'):
        #print('true_hit')
        counter+=1

if(N == 2):
    counter = 1
print(counter)

Measured memory_bytes: 5200
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<int, int>;
using vint = vector<int>;
using vvint = vector<vint>;
using vll = vector<ll>;
using vvll = vector<vll>;
using vchar = vector<char>;
using vvchar = vector<vchar>;

#define rep(i, n) for (int i = 0; i < n; ++i)
#pragma region Debug
istream &operator>>(istream &is, P &a)
{
    return is >> a.first >> a.second;
}
ostream &operator<<(ostream &os, const P &a) { return os << "(" << a.first << "," << a.second << ")"; }

template <typename T>
void view(const std::vector<T> &v)
{
    for (const auto &e : v)
    {
        std::cout << e << " ";
    }
    std::cout << std::endl;
}
template <typename T>
void view(const std::vector<std::vector<T>> &vv)
{
    for (const auto &v : vv)
    {
        view(v);
    }
}
#pragma endregion

#pragma region UnionFind
struct UnionFind
{
    vector<int> d;
    // d[x] is the index of the parent of x
    // d[x] is -size if x is a root

    UnionFind(int n) : d(vector<int>(n, -1)) {}
    int root(int x)
    {
        if (d[x] < 0)
        {
            return x;
        }
        return d[x] = root(d[x]);
    }

    bool unite(int x, int y)
    {
        x = root(x);
        y = root(y);
        if (x == y)
        {
            return false;
        }
        if (d[x] > d[y])
            swap(x, y); // x always bigger tree

        d[x] += d[y];
        d[y] = x;
        return true;
    }

    bool same(int x, int y)
    {
        return root(x) == root(y);
    }
    int size(int x) { return -d[root(x)]; }
};
#pragma endregion

struct edge
{
    int d, s, t;
    edge(int dd = -1, int ss = -1, int tt = -1) : d(dd), s(ss), t(tt) {}
    bool operator>(const edge &r) const { return d > r.d; }
};

int main()
{
    int v, e;
    cin >> v >> e;
    priority_queue<edge, vector<edge>, greater<edge>> g;
    UnionFind uft(v);
    rep(i, e)
    {
        edge k;
        cin >> k.s >> k.t >> k.d;
        g.push(k);
    }

    ll ans = 0;
    while (g.size())
    {
        edge k = g.top();
        g.pop();
        if (uft.unite(k.s, k.t))
        {
            ans += k.d;
        }
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 4508
import java.util.*;

public class Main {
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int a = sc.nextInt();
        int b = sc.nextInt();

        String s = Integer.toBinaryString(n);
        long ans = powerMOD(2,n);
        long A = comMOD(n,a);
        long B = comMOD(n,b);
        System.out.println((ans-1-A-B+1000000007*2)%1000000007);
    }

    static long powerMOD(long r, long n){
        String s = Long.toBinaryString(n);
        long ans = 1;
        if (r==1||r==0)return r;
        for (int i=s.length()-1;i>=0;i--){
            if (s.charAt(i)!='0')ans=(ans*r*(s.charAt(i)-'0'))%1000000007;
            r=r*r%1000000007;
        }
        return ans;
    }
    static long e97Div(long n, long y){
        return (n*powerMOD(y, 1000000005L))%1000000007;
    }
    static long comMOD(int n, int r){
        r = Math.min(r,n-r);
        long MOD = 1000000007;
        long ans = 1;
        for (int i=0;i<r;i++){
            ans=ans*(n-i)%MOD;
        }
        for (int i=r;i>0;i--){
            ans = e97Div(ans,i);
        }
        return ans;
    }
}


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

int main() {
  string s;
  cin >> s;
  int a = 0, r = 0;
  for(int i = 0; i < s.size(); i++){
    if(s.at(i) == 'A' || s.at(i) == 'C' || s.at(i) == 'G' || s.at(i) == 'T'){
      a++;
      r = max(a, r);
    }
    else
      a = 0;
  }  
  cout << r << endl;
}

Measured memory_bytes: 256
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
#define ll long long int
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
static const ll MAX = 1000000000000000;
static const int NIL = -1;
using namespace std;
const long double EPS = 0.0000000001;
const long double PI = (acos(-1));
const int MOD = 1000000007;

int main() {
  string s;
  int cnt = 0;
  cin >> s;
  if (s[0] == 'R') {
    cnt++;
    if (s[1] == 'R') {
      cnt++;
      if (s[2] == 'R') cnt++;
    } else if (s[2] == 'R')
      cnt = 1;
  } else {
    if (s[1] == 'R') {
      cnt++;
      if (s[2] == 'R') cnt++;
    } else if (s[2] == 'R')
      cnt = 1;
  }
  cout << cnt << endl;
}


Measured memory_bytes: 3620
N,M = map(int, input().split())

INF = 0x3f3f3f3f
dp = [[INF for i in range(110)] for j in range(110)]
v = [(0,0,0) for i in range(M)]

for i in range(M):
	a,b,c = map(int, input().split())
	a -= 1
	b -= 1
	dp[a][b] = dp[b][a] = c
	v[i] = (a,b,c)

for i in range(N):
	dp[i][i] = 0

for k in range(N):
	for i in range(N):
		for j in range(N):
			dp[i][j] = min(dp[i][j], dp[i][k] + dp[k][j])

ans = 0
for i in range(M):
	if dp[v[i][0]][v[i][1]] < v[i][2]:
		ans += 1

print(ans)

Measured memory_bytes: 42348
"""
author : halo2halo
date : 24, Jan, 2020
"""

import sys

# import itertools
# import numpy as np

read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
sys.setrecursionlimit(10 ** 7)

N, M, *A = map(int, read().split())
X = A[0]
A.append(N)
A.sort()
num = A.index(X)

print(min(len(A[:num]), len(A[num+1:-1])))



Measured memory_bytes: 3188
#include <bits/stdc++.h>
using namespace std;
int main(){
	vector<pair<int,int> > v;
	int n; cin >> n;
	for(int i = 0; i < n; i++){
		int a, b; cin >> a >> b;
		v.push_back({b, a});
	}
	sort(v.begin(), v.end());
	long long t = 0;
	for(int i = 0; i < n; i++){
		int a, b; tie(b, a) = v[i];
		if(t + a <= b) t += a;
		else return cout << "No" << endl, 0;
	}
	cout << "Yes" << endl;
	return 0;
}




Measured memory_bytes: 2420
#include<bits/stdc++.h>
#define For(i,x,y) for (register int i=(x);i<=(y);i++)
#define FOR(i,x,y) for (register int i=(x);i<(y);i++)
#define Dow(i,x,y) for (register int i=(x);i>=(y);i--)
#define Debug(v) for (auto i:v) printf("%lld ",i);puts("")
#define mp make_pair
#define fi first
#define se second
#define pb push_back
#define ep emplace_back
#define siz(x) ((int)(x).size())
#define all(x) (x).begin(),(x).end()
#define fil(a,b) memset((a),(b),sizeof(a))
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pa;
typedef pair<ll,ll> PA;
typedef vector<int> poly;
inline ll read(){
    ll x=0,f=1;char c=getchar();
    while ((c<'0'||c>'9')&&(c!='-')) c=getchar();
    if (c=='-') f=-1,c=getchar();
    while (c>='0'&&c<='9') x=x*10+c-'0',c=getchar();
    return x*f;
}

char s[50];

int main(){
	scanf("%s",s+1);
	For(i,1,3) printf("%c",s[i]);
}

Measured memory_bytes: 3628
#!usr/bin/env python3

import sys


def main():
    # S: spades
    # H: hearts
    # C: clubs
    # D: diamonds
    card_deck = {'S': [], 'H': [], 'C': [], 'D': []}
    card_symbols = ['S', 'H', 'C', 'D']

    n = int(sys.stdin.readline())
    for i in range(n):
        lst = [card for card in sys.stdin.readline().split()]
        card_deck[lst[0]].append(lst[1])

    for key, value in card_deck.items():
        card_deck[key].sort()

    for i in card_symbols:
        for card in range(1, 14):
            if not str(card) in card_deck[i]:
                print(i, card)


if __name__ == '__main__':
    main()

Measured memory_bytes: 7776
#include <iostream>
 
using namespace std;
 
int64_t gcd(long long a,long long b) {
    if(b == 0) {return a;}
    return gcd(b, a % b);
}

int main() {
    int64_t A, B;
    cin >> A >> B;
    int64_t g = gcd(A, B);
    int64_t ans = 0;
    for(int64_t i = 2; i <= g / i; ++i) {
        if(g % i == 0){
            ++ans;
            while(g % i == 0) { g /= i; }
        }
    }
    if(g > 1) { ans++; }
    cout << ans+1 <<endl;
    return 0;
}

Measured memory_bytes: 256
n, m = map(int, input().split())

if m == 2 or n == 2:
    print(0)
elif n == 1:
    if m == 1:
        print(1)
    else:
        print(m-2)
elif m == 1:
    if n == 1:
        print(1)
    else:
        print(n-2)
else:
    print((n-2)*(m-2))

Measured memory_bytes: 3060
#include <stdio.h>

int main(void)
{
    int a;
    int b;
    int c;

    scanf("%d %d %d", &a, &b, &c);

    if ( (a < b) && (b < c) ) {
        printf("Yes\n");
    } else {
        printf("No\n");
    }

    return 0;
}


Measured memory_bytes: 2120
#include "bits/stdc++.h"
using namespace std;
#define all(v) (v).begin(), (v).end()
#define io ios::sync_with_stdio(0)
#define rep(i, a, b) for (int i = a; i <= b; i++)
#define rson rt << 1 | 1, mid + 1, r
#define lson rt << 1, l, mid
#define lll __int128
#define pii pair<int, int>
#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define int long long
const int mod = 1e9 + 7;
inline int ksm(int a, int b)
{
	int ans = 1;
	for (; b; b >>= 1, a = a * a % mod)
		if (b & 1)
			ans = ans * a % mod;
	return ans;
}

int a[200][2000];
int cal(int x){
	if(!x)return 1;
	int ans=0;
	while(x)ans++,x/=10;
	return ans;
}
pii b[2000];
signed main()
{
	io;
	int n,m;
	int ans=1e9;
	cin>>n>>m;
	int p[20];p[0]=1;
	rep(i,1,3)p[i]=p[i-1]*10;
	rep(i,1,m)cin>>b[i].fi>>b[i].se;
	rep(i,1,m)b[i].fi = n-b[i].fi + 1;
	rep(i,0,999){
		if(cal(i)==n){
			int cnt=0;
			rep(j,1,m){
				cnt += b[j].se == (i/p[b[j].fi-1])%10;
			}
			if(cnt == m){
				ans=min(ans,i);
			}
		}
	}
	if(ans==1e9)cout<<-1;
	else cout<<ans<<endl;
	getchar(); //
	getchar();
}

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

// Begin {{{
using namespace std;

#define all(x) x.begin(), x.end()
#define rep(i, n) for (i64 i = 0; i < (n); ++i)
#define reps(i, b, e) for (i64 i = (b); i <= (e); ++i)
#define repr(i, b, e) for (i64 i = (b); i >= (e); --i)
#define var(Type, ...) Type __VA_ARGS__; input(__VA_ARGS__)

#ifdef DEBUG
#define dump(...) dump_(#__VA_ARGS__, __VA_ARGS__);
#else
#define dump(...)
#endif

using i64 = int_fast64_t;
using pii = pair<i64, i64>;

template <class A, class B>
inline bool chmax(A &a, const B &b) { return b > a && (a = b, true); }

template <class A, class B>
inline bool chmin(A &a, const B &b) { return b < a && (a = b, true); }

constexpr int INF = 0x3f3f3f3f;
constexpr i64 LINF = 0x3f3f3f3f3f3f3f3fLL;
constexpr int MOD = int(1e9) + 7;

// input
void input() {}
template <class Head, class... Tail>
void input(Head&& head, Tail&&... tail) {
  cin >> head;
  input(forward<Tail>(tail)...);
}

// outs
void outs() {}
template <class Head, class... Tail>
void outs(Head&& head, Tail&&... tail) {
  cout << head << " \n"[sizeof...(tail)==0];
  outs(forward<Tail>(tail)...);
}

template <class T>
void outs(vector<T> &vec) { for (auto &e : vec) cout << e << " \n"[&e==&vec.back()]; }

template <class T>
void outs(vector<vector<T>> &df) { for (auto &vec : df) OUTS(vec); }

// outl
void outl() {}
template <class Head, class... Tail>
void outl(Head&& head, Tail&&... tail) {
  cout << head << "\n";
  outl(forward<Tail>(tail)...);
}

template <class T>
void outl(vector<T> &vec) { for (auto &e : vec) cout << e << "\n"; }

// outn
void outn() {}
template <class Head, class... Tail>
void outn(Head&& head, Tail&&... tail) {
  cout << head;
  outn(forward<Tail>(tail)...);
}

template <class T>
void outn(vector<T> &vec) { for (auto &e : vec) cout << e; }

// dump
template <class T>
void dump_(const char *s, T&& x) {
  clog << '{';
  while(*s != '\0') clog << *(s++);
  clog << ": " << x << '}' << "\n";
}

template <class Head, class... Tail>
void dump_(const char *s, Head&& head, Tail&&... tail) {
  clog << '{';
  while(*s != ',') clog << *(s++);
  clog << ": " << head << "}, ";
  for (++s; !isgraph(*s); ++s);
  dump_(s, forward<Tail>(tail)...);
}
// }}} End

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

  var(int, n, h, w);
  outl((n - h + 1) * (n - w + 1));

  return 0;
}


Measured memory_bytes: 256
/* C++ program to find next prime number of a given number ?

can anyone code and explain it !!

https://www.sololearn.com/Discuss/815900/c-program-to-find-next-prime-number-of-a-given-number
*/


#include <iostream>
using namespace std;
bool isPrime (int); // a function which will tell us if the number is prime (true) or not (false)

int main() {
    int number, i;
    //cout<<"Enter a number\n";
    cin>>number;
    for (i=number; !isPrime(i);i++);
    // this cycle goes until we find a prime number. It starts from the number we entered because we need number that is higher. When the cycle finds a number that is prime, it stops and i has its value.
    cout<<i;
    return 0;
}

bool isPrime (int a)
{
    int counter=0; //counter for numbers which devided by the number give reminder 0 (are divisors of the number)
    for (int i=2; i<=a/2; i++) //we start from 2 because 1 is divisor to all numbers. Also we go to the number devided by 2 because there isn't number higher than this that can be devider and give a integer as a result. For example 6: 6/1=6; 6/6=1 --> this is for all numbers;    6/3=2 but 6/4 is not integer. We do not need to count 6 as a devider or check if the range (6/2..6)
    if (a%i==0) //checking if the number is devisor
    counter++; //if there is a devisor we count it

    if (counter==0) //if the counter is equal to 0 that means the number doesn't have any other integer devisors other than 1 and itself therefore it is a prime number and we retrun true
    return true;
    else //the counter is not 0, which means the number has other devisors other than 1 and itself therefore it is not a prime number
    return false;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int n;
int main() {
    cin >> n;
    int cnt = 0;
    vector<vector<int>> check(10, vector<int>(10, 0));
    
    for(int i = 1; i <= n; ++i) {
        string tar = to_string(i);
        int tarlen = tar.length();
        if(tarlen == 1) {
            int input = tar.at(0) - '0';
            check.at(input).at(input)++;
        }else {
            int infst = tar.at(0) - '0';
            int inlst = tar.at(tarlen-1) - '0';
            check.at(infst).at(inlst)++;
        }
    }

    for(int i = 1; i < 10; ++i) {
        for(int j = 1; j < 10; ++j) {
            cnt += check.at(i).at(j) * check.at(j).at(i);
        }
    }

    cout << cnt << endl;
}

Measured memory_bytes: 256
#[allow(unused_macros)]
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };

    ($next:expr, mut $var:ident : $t:tt $($r:tt)*) => {
        let mut $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, bytes) => {
        read_value!($next, String).into_bytes()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

fn main() {
    input! {
        mut s: chars,
    }

    if s.len() < 3 {
        println!("0");
        return;
    }

    let mut ans: i64 = 0;

    let mut bcs = 0;
    let mut prev_bc = false;
    for i in (0..s.len() as i64 - 1).rev() {
        if s[i as usize] == 'A' {
            if prev_bc {
                // dbg!((i, bcs));
                ans += bcs;
            } else {
                bcs = 0;
                prev_bc = false;
            }
        }
        if s[i as usize] == 'B' {
            if s[i as usize +1] == 'C' {
                bcs += 1;
                prev_bc = true;
            } else {
                bcs = 0;
                prev_bc = false;
            }
        }
        if s[i as usize] == 'C' {
            if prev_bc {
                prev_bc = false;
            } else {
                bcs = 0;
                prev_bc = false;
            }
        }
    }

    println!("{}", ans);
}

// AACBACBCBACB


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

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

    vector<long double> ans(2 * N + 1), prev(2 * N + 1);
    ans[N] = 1;

    {
        long double p;
        for(auto i = 0; i < N; ++i){
            cin >> p;

            swap(ans, prev);
            fill(ans.begin(), ans.end(), 0);

            for(auto j = 0; j < 2 * N; ++j)
                ans[j] += prev[j + 1] * p;
            for(auto j = 1; j <= 2 * N; ++j)
                ans[j] += prev[j - 1] * (1 - p);
        }
    }

    printf("%.12Lf\n", accumulate(ans.begin(), ans.begin() + N, (long double)(0)));

    return 0;
}

Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std; 
int main() 
{long long n,p;cin>>n>>p;
 string s;cin>>s;
 long long cur=1,mod=0,ans=0;
 map<long long,long long>f;
 f[0]++;
 if(p==2 || p==5){
   for(long long i=n-1;i>=0;i--)
 {
 if((s[i]-'0')%p==0)ans+=(i+1);
 }
                 }
 else{
 for(long long i=n-1;i>=0;i--)
 {
   mod=(mod+cur*(s[i]-'0'))%p;
   cur=(cur*10)%p;
   ans+=f[mod];
   f[mod]++;
 }
 }
 cout<<ans;
 return 0; 
}


Measured memory_bytes: 1028