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

using namespace std;
int main()
{
	int a, b, c, x, d;
	cin >> a >> b >> c >> x;
	d = 0;
	for (int i = 0; i <= a; i++) {
		for (int j = 0; j <= b; j++) {
		for (int k = 0; k <= c; k++) {
			if (i * 500 + j * 100 + k * 50 == x) { d++; }
		}
		}
	}
	cout << d << endl;






    return 0;
}



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

int main() {
    long long const mod = 1000000007;
    long long N, K; cin >> N >> K;
    long long res = 0;
    for(long long k=K; k<=N+1; ++k) {
        res = (res + 1 + k * (N - k + 1) % mod) % mod;
    }
    cout << res << '\n';
}

Measured memory_bytes: 3636
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <limits>
#include <map>
#include <queue>
#include <set>
#include <tuple>
#include <vector>

using namespace std;

#define rep(i, n) for (int64_t i = 0; i < (n); i++)
#define irep(i, n) for (int64_t i = 0; i <= (n); i++)
#define rrep(i, n) for (int64_t i = (n)-1; i >= 0; i--)
#define rirep(i, n) for (int64_t i = n; i >= 0; i--)

using V = tuple<int64_t, int>;

vector<tuple<int64_t, int>> neighbor[2 * 100'000];
int64_t dist[2 * 100'000];

const int64_t DMAX = 1e15;

int main()
{
    int n, m, s, t;
    cin >> n >> m >> s >> t;
    s--;
    t--;

    rep(i, m)
    {
        int u, v;
        int64_t a, b;
        cin >> u >> v >> a >> b;
        u--;
        v--;
        neighbor[u].push_back(make_tuple(a, v));
        neighbor[v].push_back(make_tuple(a, u));
        neighbor[u + n].push_back(make_tuple(b, v + n));
        neighbor[v + n].push_back(make_tuple(b, u + n));
    }

    vector<int64_t> ans;

    priority_queue<V, vector<V>, greater<V>> q;
    q.push(make_tuple(0, s));
    q.push(make_tuple(0, t + n));
    fill(dist, dist + 2 * n, DMAX + 1);
    dist[s] = 0;
    dist[t + n] = 0;

    while (!q.empty()) {
        int64_t d;
        int v;
        tie(d, v) = q.top();
        q.pop();
        if (d > dist[v]) {
            continue;
        }

        for (const auto& n : neighbor[v]) {
            int nv;
            int64_t w;
            tie(w, nv) = n;
            if (dist[nv] > d + w) {
                dist[nv] = d + w;
                q.push(make_tuple(d + w, nv));
            }
        }
    }

    int64_t prev = 0;
    rrep(i, n)
    {
        int64_t cost = dist[i] + dist[i + n];
        prev = max(prev, DMAX - cost);
        ans.push_back(prev);
    }

    rrep(i, n)
    {
        cout << ans[i] << endl;
    }

    return 0;
}

Measured memory_bytes: 19960
n, cap = map(int, input().split())
dp = [0] * (cap + 1)

for _ in range(n):
    v, w = map(int, input().split())
    for k in range(cap - w + 1):
        new_v = dp[k] + v
        if dp[k + w] < new_v:
            dp[k + w] = new_v

print(max(dp))

Measured memory_bytes: 7884
S = input()
ans = 0
tmpl = 0
tmpr = 0
for i in range(len(S) - 1):
  if S[i] == '<':
    tmpl += 1
  else:
    tmpr += 1
    if S[i + 1] == '<':
      x = max(tmpl, tmpr)
      y = min(tmpl, tmpr)
      ans += (1 + x) * x // 2 + y * (y - 1) // 2
      tmpl = 0
      tmpr = 0

if S[-1] == '<':
  tmpl += 1
else:
  tmpr += 1
x = max(tmpl, tmpr)
y = min(tmpl, tmpr)
ans += (1 + x) * x // 2 + y * (y - 1) // 2
print(ans)

Measured memory_bytes: 4212
#include<stdio.h>
#include<iostream>
#include<string>
#include<vector>
#include<map>
#include<algorithm>
#include<cmath>
#include<bitset>
 
#define Vsort(a) sort(a.begin(), a.end())
#define Vreverse(a) reverse(a.begin(), a.end())
#define Srep(n) for(int i = 0; i < (n); i++)
#define Lrep(i,a,n) for(int i = (a); i < (n); i++)
#define Brep(n) for(int bit = 0; bit < (1<<n); bit++)
#define rep2nd(n,m) Srep(n) Lrep(j,0,m)
#define vi vector<int>
#define vi64 vector<int64_t>
#define vvi vector<vector<int>>
#define vvi64 vector<vector<int64_t>>
#define P pair<int,int>
#define F first
#define S second

using namespace std;

int main(){
  vi input(3);
  Srep(3) cin >> input[i];
  Vsort(input);
  if((input[0] == 5)&&(input[1] == 5)&&(input[2] == 7)) cout << "YES" << endl;
  else cout << "NO" << endl;
} 


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

int main() {
  int n;
  cin >> n;
  long long int ans = 1;
  long long int w = 10;
  for (int k = 0; k < 8; k++) w *= 10;
  w += 7;


  for (int k = 1; k <= n; k++) {
    ans *= k;
    ans = ans % w;
  }

  cout << ans << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <vector>
#include <string>
#include <algorithm>
#include <utility>
#include <set>
#include <map>
#include <cmath>

using namespace std;

void out() {
     cout.flush();
    int n;
    cin >> n;
    exit(0);
}

void solve() {
     int n;
     cin >> n;
     int x1 = 0, x2 = 0, x4 = 0;
     for (int i = 0; i < n; ++i) {
         int x;
         cin >> x;
         if (x % 4 == 0)
            ++x4;
         else if (x % 2 == 0)
              ++x2;
         else
            ++x1;
     }
     
     if (x2 > 0) {
        ++x1;
        x2 = 0;
     }
     
     cout << ((x4 + 1 >= x1) ? "Yes\n" : "No\n");     
}

int main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    
    solve();
    out();
    return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
#include<math.h>

int main(){
    int x[10000];
    int n,i,j,flag;
    int cnt = 0;
    
    scanf("%d",&n);
    
    for(i=0;i<n;i++){
        scanf("%d",&x[i]);
    }
    
    for(i=0;i<n;i++){
        flag = 1;
        for(j=2;j<=(int)(sqrt(x[i]));j++){
            if(x[i]%j == 0){
                flag = 0;
                break;
            }
        }
        if(flag == 1) cnt++;
    }
    
    printf("%d\n",cnt);
}


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

using namespace std;
typedef long long ll;
const int maxn=1e5+7;
int a[maxn];
int main() {
    int n,h,t,s=0;
	scanf("%d%d", &h,&n);
	for(int i=0;i<n;i++){
        scanf("%d",&t);
        s+=t;
	}
	printf("%s\n",s>=h?"Yes":"No");
	return 0;
}


Measured memory_bytes: 256
n = gets.to_i
a, b = Array.new(n) { gets.split.map(&:to_i) }.transpose
mod = 10**9 + 7
h = Hash.new(0)
arr = []
ans = 0

a.zip(b).each do |i, j|
  if i == 0 && j == 0
    ans += 1
  elsif i == 0
    h[[0, 1]] += 1
  elsif j == 0
    h[[-1, 0]] += 1
  else
    gcd = i.gcd(j)
    i *= -1 if j < 0
    h[[i / gcd, j.abs / gcd]] += 1
  end
end

h.each do |(i, j), v|
  if i >= 0
    arr << 2**v + 2**h[[-j, i]] - 1
    h.delete([-j, i])
  else
    arr << 2**v + 2**h[[j, -i]] - 1
    h.delete([j, -i])
  end
end

ans = (ans + arr.inject { |i, j| i * j % mod } - 1) unless arr.empty?

puts ans % mod

Measured memory_bytes: 57856
#include <bits/stdc++.h>
using namespace std;
int main(){
  int N;
  cin>>N;
  if(N<1||N>32){
    return 0;
  }
  vector<int>S={1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
  cout<<S.at(N-1)<<endl;
}



Measured memory_bytes: 256
// </> : towhid1zaman

#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef pair< int, int > pii;
typedef pair< pii, int > ppi;
#define fill(a,b) memset(a,b,sizeof(a))
#define all(v) (v).begin(),(v).end()
#define sp(k) cout<<setprecision(k)<<fixed;
#define rep(i,a) for(int i=0;i<a;i++)
#define rep1(i,a,b) for(int i=(a);i<=(b);++i)
#define irep(i,b,a) for(int i=(b);i>=(a);--i)
#define minv(v) *min_element(all(v))
#define maxv(v) *max_element(all(v))
#define unq(v) sort(all(v)),(v).erase(unique(all(v)),(v).end())
#define _ ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define endl "\n"
#define sqr(a) ((a)*(a))
#define sz(a) int(a.size())
#define ff first
#define ss second
#define pb push_back

const double pi = acos(-1.0);
const int mod = 1000000007; // (int)1e9+7
const int inf = 0x3f3f3f3f;// (int)3e18;
const int maxn = 2000100;



int main(){
        _
        int n,m; cin >> n  >> m;
        vi a(n);
        rep(i,n){
            cin >> a[i];
        }
        int ans = 0;
        sort(all(a));
        rep(i,n-1){
            if(m>=a[i]){
                m-=a[i];
                ans++;
            }
        }
        if(m==a[n-1])ans++;
        cout<<ans<<endl;



return 0;
}




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

using namespace std;

int main(){
  int w,h,T;
  cin >> w >> h >> T;
  int p;
  int a[h][w];
  for(int i = 0;i < h;i++){
    for(int j = 0;j < w;j++)
      a[i][j] = 0;
  }
  cin >> p;
  for(int i = 0;i < p;i++){
    int x,y,t;
    cin >> x >> y >>t;
    a[y][x]++;
    
  }
  char s[h][w];
  for(int i=0;i<h;i++){
    for(int j = 0;j<w;j++)
      cin >> s[i][j];
  }
  int sum = 0;
  for(int i = 0;i < h;i++){
    for(int j = 0;j < w;j++){
      if(s[i][j] == '1')
	sum += a[i][j];
    }
  }
  cout << sum << endl;
}

Measured memory_bytes: 3092
N = int(input())
if N%2==0 or N%5==0:
  print(-1)
  
else:
  j = 1 
  mod = 7%N
  flag=True
  while flag:
    if mod==0:
      print(j)
      break
    elif mod>0:
      n = mod*10+7
      mod = n%N
      j+=1

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



int main(){
ll n,x,d;
cin>>n>>x>>d;
if (d==0){
  if (x==0){
    cout<<1;return 0;
  }
  cout<<n+1;
  return 0;
}
if (d<0){
  d=-d;
  x=-x;
}

map<ll,vector<P>> mp;
rep(i,n+1){
  ll s=x*i;
  ll q=s%d;
  if(q<0)q+=d;

  ll l=(i-1)*i/2;
  ll r=(n*2-i-1)*i/2;
  ll front=(s-q)/d+l;
  ll len=r-l;
  mp[q].emplace_back(front,len);
//  cout<<s<<"S"<<q<<"q"<<front<<"front"<<len<<"len"<<endl;
}
ll cntall=0;
for(auto a:mp){
  auto A=a.second;
  sort(A.begin(),A.end());
  ll start=A[0].first;
  ll now=start-1;
  ll cnt=0;
  for (ll i=0;i<A.size();i++){
    if (now>=A[i].first+A[i].second)continue;
    if (now>=A[i].first)cnt-=(now+1-A[i].first);
    now=A[i].first+A[i].second;
    cnt+=A[i].second+1;
  //  cout<<cnt<<endl;
  }

  cntall+=cnt;
}
cout<<cntall<<endl;
return 0;
}


Measured memory_bytes: 22144
import numpy as n;i=n.int32;p=input;q=n.searchsorted;N=int(p());A=i(p().split());B=i(p().split());c=0;
for k in range(29):
  a,b=n.sort(n.hstack((A%(1<<k+1),A%(1<<k+1)-2**(k+1)))),B%(1<<k+1);c+=(n.sum(q(a,2**(k+1)-b)-q(a,2**k-b)))%2*2**k
print(c)


Measured memory_bytes: 35900
abk = [int(i) for i in input().split()]
a = abk[0]
b = abk[1]
k = abk[2]

anss = []
for i in range(1,min(a,b)+1):
  if a%i==0 and b%i==0:
    anss.append(i)
    
anss.sort(reverse=True)
print(anss[k-1])


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

int N, K;

int main(void){
    // Your code here!
    cin >> N >> K;
    
    int X[N];
    for(int i = 0; i < N; i++) cin >> X[i];
    
    
    int ans = 1e9;
    for(int left = 0; left <= N - K; left++){
        int tmp = min(abs(X[left]) + abs(X[left+K - 1] - X[left]), abs(X[left+K - 1]) + abs(X[left+ K - 1] - X[left]));
        ans = min(ans, tmp);
    }
    
    cout << ans << endl;
}


Measured memory_bytes: 640
/** 
 *  Author : Parth Prajapati
 * 	Institute : Pandit Deendayal Petroleum University
**/
#include<bits/stdc++.h>

using namespace std; 

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    int n, x, y, i, j;
	cin>>n>>x>>y;
	long long dp[n+1][n+1];
	for(i=1;i<n+1;++i)
    {
		for(j=1;j<n+1;++j)
        {
			dp[i][j] = abs(i-j);
		}
	}
	for(i=1;i<n+1;++i)
    {
        for(j=1;j<n+1;++j)
        {
			dp[i][j] = min(dp[i][j], dp[i][x]+1+dp[y][j]);
			dp[i][j] = min(dp[i][j], dp[i][y]+1+dp[x][j]);
		}
	}
    vector<long long> ans(n+1,0);
    for(i=0;i<n+1;++i)
    {
        for(j=1;j<i;++j)
        {
			++ans[dp[i][j]];
		}
	}
    for(i=1;i<n;++i)
    {
		cout<<ans[i]<<"\n";	
	}
    return 0;
}

Measured memory_bytes: 31616
using System;

class Program
{
	static void Main(string[] args)
	{
		int n = int.Parse(Console.ReadLine());
		string[] input = Console.ReadLine().Split(' ');

		int[] a = new int[n];

		for(int i=0; i<n; i++)
		{
			a[i] = int.Parse(input[i]);
		}

		InsertionSort(a);
	}

	static void InsertionSort(int[] a)
	{
		for(int i=0; i<a.Length; i++)
		{
			int v = a[i];
			int j = i - 1;

			while(j>=0 && a[j]>v)
			{
				a[j + 1] = a[j];
				j--;
			}

			a[j + 1] = v;

			for(int k=0; k<a.Length; k++)
			{
				Console.Write((k>0?" ":"") + a[k]);
			}
			Console.WriteLine();
		}
	}
}

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

#define fa(x,v) for(auto x:v)
#define f(i,a,b) for(ll i=(ll)a;i<=(ll)b;i++)
#define rf(i,a,b) for(ll i=(ll)a;i>=(ll)b;i--)
#define spc " "
#define endl '\n'
#define ll long long
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define len(s) (ll)int(s.length())
#define sz(v) (ll)int(v.size())
#define MOD 1000000007

void Fast_IO() {
    ios::sync_with_stdio(0);
    cin.tie(0);
    #ifndef ONLINE_JUDGE
    freopen("input.in","r",stdin);
    freopen("output.out","w",stdout);
    freopen("debug.out","w",stderr);
    #endif
} 

// Code Here

int main()
{
    // Fast_IO();
    ll n; cin >> n;
    ll a[n]; f(i,0,n-1) cin >> a[i];
    sort(a, a+n);
    reverse(a,a+n);
    vector <ll> v;
    v.pb(a[0]);
    f(i,1,n-1) v.pb(a[i]), v.pb(a[i]);
    ll ans = 0;
    f(i,0,n-2) ans += v[i];
    cout << ans;
    return 0;
}

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

int main()
{
	int n,T;
	cin >> n >> T;
	int ans = 1e9;
	rep(i,n)
	{
		int c,t;
		cin >> c >> t;
		if (t <= T && c < ans)
		{
			ans = c;
		}
	}
	if (ans == 1e9) cout << "TLE" << endl;
	else cout << ans << endl;
	return 0;
}

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

ll ans = 0;
vector<ll> v;

void sliding_window(string s) {
    int left = 0, right = 0;
    while(left < s.size()) {
        while(right+1<s.size() && s[left]==s[right+1]) {
            right++;
        }
        v.push_back(right-left+1);
        left = right+1;
        right = left;
    }
}

ll sol(string s, int n, ll k) {
    if(n==1) {  // only 1 char in string
        ans = k/2;  // works for length of T is even and odd
        return ans;
    }
    if(n==v[0]) {
        return (k*n)/2;
    }
    // each v[i] is the number of same consecutive letters
    for(ll i=0; i<v.size(); i++) {
        ans += v[i]/2;
    }
    ans *= k;

    if(s[0]==s[n-1] && v[0]%2!=0 && v[v.size()-1]%2!=0) {    // odd occurences
        ans+=k-1;
    }
    return ans;
}

int main() {
    string s;
    int n;
    ll k;
    cin >> s >> k;
    n = s.size();

    sliding_window(s);
    cout << sol(s, n, k) << endl;
}

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

int main() {
    int n;
    cin >> n;
    int ans = 1;
    while(ans*ans <= n) ans++;
    ans--;
    cout << ans*ans << endl;
}

Measured memory_bytes: 384
import math
from itertools import permutations
N = int(input())
coodinate = [list(map(int,input().split())) for _ in range(N)]
f_N = math.factorial(N)
SumDistance = 0
j = 0
for val in permutations(coodinate):
    #if j >= math.factorial(N) // 2:
    #    break
    #print(val)
    for i in range(N-1):
        SumDistance += ((val[i+1][0] - val[i][0]) ** 2 + (val[i+1][1] - val[i][1]) ** 2) ** (1 / 2)
    #j += 1

print(SumDistance / math.factorial(N))

Measured memory_bytes: 40684
#include <stdio.h>
#define min(a, b) ((a) < (b) ? (a) : (b))

long count_zero(long n);

int main(int argc, const char *argv[])
{
  long n;
  while(scanf("%ld", &n) == 1){
    if(!n) break;
    printf("%ld\n",count_zero(n));
  }
  return 0;
}

long count_zero(long n)
{
  long tmp;
  long div_2 = 0, div_5 = 0;
  
  while(n){
    tmp = n;
    while(!(tmp % 2)){
      div_2++;
      tmp /= 2;
    }
    while(!(tmp % 5)){
      div_5++;
      tmp /= 5;
    }
    n--;
  }

  return min(div_2, div_5);
}

Measured memory_bytes: 600
#include "bits/stdc++.h"
using namespace std;
#define rep(i,n) for(ll i = 0; i < (n); i++)
typedef long long ll;
const ll MOD = 1000000007;
int main()
{
    int a, b;
    cin >> a >> b;
    if(a != 1 && b != 1) cout << 1 << endl;
    else if(a != 2 && b != 2) cout << 2 << endl;
    else cout << 3 << endl;
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cmath>
#include<cctype>
#include<math.h>
#include<string>
#include<string.h>
#include<stack>
#include<queue>
#include<vector>
#include<utility>
#include<set>
#include<map>
#include<stdlib.h>
#include<iomanip>
#include<complex>

using namespace std;

#define ll long long
#define ld long double
#define INF 1e9
#define LINF (ll)INF*INF
#define MOD 1000000007
#define rep(i,n) for(int i=0;i<(n);i++)
#define loop(i,a,n) for(int i=a;i<(n);i++)
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)

#define int ll //!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

const double PI=acos(-1);
const double EPS=1e-9; //うまくいかなかったらゆるめる

typedef vector<int> vi;
typedef vector<string> vs;
typedef pair<int,int> pii;
typedef pair<pii,int> ppi;
typedef pair<int,pii> pip;
typedef vector<pii> vp;
typedef vector<vi> vvi;

int gcd(int a, int b){if(b==0) return a;return gcd(b,a%b);}
int lcm(int a, int b){return a/gcd(a,b)*b;}

class UnionFind{

private:
    vector<int> data;
    int num;
  public:
      UnionFind(){};
      UnionFind(int size){
          data = vector<int>(size, -1);
          num = size;
      }

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

    bool unite(int x, int y){
        if(same(x,y)) return(false);
        x = find(x);
        y = find(y);
        if(data[x] > data[y]) swap(x, y);
        data[x] += data[y];
        data[y] = x;
        num--;
        return(true);
    }

    int find(int x){
        if(data[x] < 0) return(x);
        return(data[x] = find(data[x]));
    }

    int size(int x){
        return(-data[find(x)]);
    }

    int count(){
        return num;
    }
};


signed main(void) {
    int n,m,k;
    cin >> n >> m >> k;
    UnionFind uf(n);
    vi ans(n,0);
    rep(i,m){
        int a,b;
        cin >> a >> b;
        a--,b--;
        ans[a]--,ans[b]--;
        uf.unite(a,b);
    }
    rep(i,n){
        ans[i] += uf.size(i)-1;
    }
    rep(i,k){
        int c,d;
        cin >> c >> d;
        c--,d--;
        if(uf.same(c,d)){
            ans[c]--,ans[d]--;
        }
    }
    rep(i,n)cout << ans[i] << endl;
}


Measured memory_bytes: 2432
n = int(input())
a = list(map(int, input().split()))
a1 = []
a2 = []
for i in range(n):
    if i % 2 == 0:
        a1.append(a[i])
    else:
        a2.append(a[i])
if n % 2 == 0:
    a2.reverse()
    print(*a2+a1)
else:
    a1.reverse()
    print(*a1+a2)


Measured memory_bytes: 26020
import sys
input=sys.stdin.readline
k=int(input())
l=[[1,2,3,4,5,6,7,8,9]]
c=9
i=1
l0=[0]
while c<k:
    temp=[]
    for j in l0:
        temp.append(1*10*i+j)
    for j in l[-1]:
        t=j//i
        if t==1:
            temp.append(1 * 10 *i + j)
            temp.append(2*10*i+j)
            l0.append(j)
        elif t==9:
            temp.append(8*10*i+j)
            temp.append(9 * 10 *i + j)
        else:
            temp.append((t+1) * 10 *i+ j)
            temp.append(t * 10 *i + j)
            temp.append((t-1) * 10 *i + j)
    i=i*10
    c+=len(temp)
    l.append(temp)
all=[]
for i in l:
    for j in i:
        all.append(j)
all.sort()
print(all[k-1])
















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

#define rep(i, a, b) for (ll i = (a); i < (b); i++)
typedef uint64_t ull;
typedef int64_t ll;
typedef std::pair<ll, ll> PLL;

signed main() {
    ll Q;
    cin>>Q;
    while(Q--){
        ll A,B;
        cin>>A>>B;
        ll C = sqrt(A*B);
        if (C*C==A*B)
            C--;
        if (A>B)
            swap(A, B);
        ll ans = 0;
        if (A==B){
            ans = 2*A-2;
        } else if (A+1==B){
            ans = 2*A-2;
        } else if (C*(C+1) >= A*B){
            ans = 2*C-2;
        } else{
            ans = 2*C-1;
        }
        cout<<ans<<endl;
    }
    return 0;
}


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

int main() {
  int N;
  cin >> N;
  int i = 0;
  int sum = 0;
  int num0 = N % 10;
  int num1 = (N / 10) % 10;
  int num2 = (N / 100) % 10;
  int num3 = (N / 1000) % 10;
  int num4 = (N / 10000) % 10;
  int num5 = (N / 100000) % 10;
  int num6 = (N / 1000000) % 10;
  int num7 = (N / 10000000) % 10;
  int num8 = (N / 100000000) % 10;
    sum = num0 + num1 + num2 + num3 + num4 + num5 + num6 + num7 + num8;
    if(N % sum == 0){
    cout << "Yes" << endl;
    }
     else{
       cout << "No" << endl;
  }
  
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); i++)
typedef long long ll;
using namespace std;
ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; } // 最大公約数

int main()
{
  ll x, y;
  cin >> x >> y;
  cout << gcd(x, y) << endl;
  return 0;
}


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

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

#define p_ary(ary,a,b,i) do { cout << "["; for (int (i) = (a);(i) < (b);++(i)) cout << ary[(i)] << ((b)-1 == (i) ? "" : ", "); cout << "]\n"; } while(0)
#define p_map(map,it) do {cout << "{";for (auto (it) = map.begin();;++(it)) {if ((it) == map.end()) {cout << "}\n";break;}else cout << "" << (it)->first << "=>" << (it)->second << ", ";}}while(0)

int main() {
    int n,m;
    cin >> n >> m;
    priority_queue<int> que;
    for (int i = 0;i < n;++i) {
        int a;
        cin >> a;
        que.push(a);
    }
    for (int i = 0;i < m;++i) {
        int t = que.top();
        que.pop();
        t /= 2;
        que.push(t);
    }
    ll ans = 0;
    for (int i = 0;i < n;++i) {
        ans += que.top();
        que.pop();
    }
    cout << ans << endl;
}

Measured memory_bytes: 892
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<int> vint;
typedef pair<int,int> pint;
typedef vector<pint> vpint;
#define rep(i,n) for(int i=0;i<(n);i++)
#define REP(i,n) for(int i=n-1;i>=(0);i--)
#define reps(i,f,n) for(int i=(f);i<(n);i++)
#define each(it,v) for(__typeof((v).begin()) it=(v).begin();it!=(v).end();it++)
#define all(v) (v).begin(),(v).end()
#define eall(v) unique(all(v), v.end())
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define chmax(a, b) a = (((a)<(b)) ? (b) : (a))
#define chmin(a, b) a = (((a)>(b)) ? (b) : (a))
const int MOD = 1e9 + 7;
const int INF = 1e9;
const ll INFF = 1e18;

int cnt[30];
int main(void) {
	string s; cin >> s;
	for(auto u : s){
		cnt[u - 'a']++;
	}
	bool flag = true;
	rep(i, 26)if(cnt[i] > 1) flag = false;
	if(flag)printf("yes\n");
	else printf("no\n");
	return 0;
}

Measured memory_bytes: 256
<>;$s=<>;chop$s;@S=split//,$s;
foreach(@S){
    if('('eq$_){$l++}else{$r++}
    $-=$r-$l;$x=$->$x?$-:$x;
}
foreach(reverse(@S)){
    if(')'eq$_){$p++}else{$q++}
    $-=$q-$p;$y=$->$y?$-:$y;
}
print '('x$x,$s,')'x$y

Measured memory_bytes: 512
#include <bits/stdc++.h>
#include <cstdlib>
#include <cmath>
#include <algorithm>
using namespace std;
using ll = long long;
using P = pair<ll,ll>;
using Graph= vector<vector<ll>>;
struct edge{ll to ; ll cost ;} ;
using graph =vector<vector<edge>> ;
#define rep(i,n) for (ll i=0; i < (n); ++i)
#define rep2(i,n,m) for(ll i=n;i<=m;i++)
#define rep3(i,n,m) for(ll i=n;i>=m;i--)
#define pb push_back
#define eb emplace_back
#define ppb pop_back
#define mpa make_pair
#define fi first
#define se second 
#define set20 cout<<fixed<<setprecision(20) ;
const ll INF=1e18 ;
inline void chmax(ll& a,ll b){a=max(a,b);}
inline void chmin(ll& a,ll b){a=min(a,b);}
double pi=acos(-1) ;
ll gcd(ll a, ll b) { return b?gcd(b,a%b):a;}
ll lcm(ll a, ll b) { return a/gcd(a,b)*b;}
 

 int main(){
  ll n ; cin>> n ;
  string s ; cin>> s ;
  ll dp[n+1][n+1] ;
  rep2(i,1,n-1){
    if(s[i-1]==s[n-1]) dp[n][i]=1 ;
    else dp[n][i]=0 ;
  }
 
  rep3(i,n-1,2){
    rep2(j,1,i-1){
      if(s[i-1]==s[j-1]) dp[i][j]=dp[i+1][j+1]+1 ;
      else dp[i][j]=0 ;
    }
  }
 ll ans=0 ;
  rep2(i,2,n){
    rep2(j,1,i-1){
      chmax(ans,min(dp[i][j],i-j)) ;
    }
  }
  cout<<ans<<endl ;
   return 0 ;
 }



Measured memory_bytes: 120300
#include <iostream>
#include <vector>
#include <algorithm>
#include <ctime>
#include <cmath>
#include <string>
#include <stdlib.h>
#include <fstream>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <deque>
#include <iterator>
#include <iomanip>
using namespace std;


int main(){
    long long n, a, ans = 0, k;
    cin >> n >> k;
    deque<long long> d;
    for(int i = 0; i < n; ++i){
        cin >> a;
        d.push_back(a);
    }
    for(int l = 0; l <= k; ++l){
        for(int r = 0; r <= k - l; ++r){
            long long del = k - l - r, sum = 0, n_l = l, n_r = r;
            multiset<long long> m;
            deque<long long> now = d;
            while(n_l > 0 && !now.empty()){
                m.insert(now.back());
                sum += now.back();
                now.pop_back();
                n_l--;
            }
            while(n_r > 0 && !now.empty()){
                m.insert(now.front());
                sum += now.front();
                now.pop_front();
                n_r--;
            }
            while(del > 0 && !m.empty() && *m.begin() < 0){
                sum -= *m.begin();
                m.erase(m.begin());
                del--;
            }
            ans = max(ans, sum);
        }
    }
    cout << ans;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
using namespace std;
int main()
{
    string S;
    cin >> S;

    if (S[0] == S[1] && S[1] == S[2])
    {
        cout << "No" << endl;
    }
    else 
    {
        cout << "Yes" << endl;
    }
    


    return 0;
}

Measured memory_bytes: 256
// Best practice
 
#include<bits/stdc++.h>
 
#define int         long long
#define pb          push_back
#define pf          emplace_front
#define all(a)      (a).begin(),(a).end()
#define rall(a)     (a).rbegin(),(a).rend()
#define pii 		pair<int,int>
#define psi 		pair<string,int>
#define vi 			vector<int>
#define vpii  		vector<pii>
#define vvi 		vector<vi>
#define sz(x)	    (int)(x).size()
#define x           first
#define y           second
#define endl        '\n'
#define tezz        ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define MOD         1000000007
#define hell        998244353
#define prec(n) 	fixed<<setprecision(n)
#define ini(a, i) 	memset(a, i, sizeof(a))
#define output(x)   cout << (x ? "YES" : "NO")<<endl;
using namespace std;
 
#define debug(vec) cout<<(#vec)<<" : [ "; for (auto& i: vec) cout<<i<<" "; cout<< "]" << endl
#define debugp(vec) cout<<(#vec)<<" : [ "; for (auto& i: vec) cout<<"("<<i.x<<","<<i.y<<")"<<" "; cout<< "]" << endl
#define trace(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args);cout << endl; }
void err(istream_iterator<string> it) {}
template<typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args) {
    cout << "[" << *it << ": " << a << "]\t";
    err(++it, args...);
}
 
// const int dx[4] = { -1, 1, 0, 0};
// const int dy[4] = {0, 0, -1, 1};
// int dX[] = { -1, -1, -1, 0, 0, 1, 1, 1 };
// int dY[] = { -1, 0, 1, -1, 1, -1, 0, 1 };
 
 
// Code from Here -------------------------------------------------------------------------------


signed main() {
	tezz
 
	// #ifndef ONLINE_JUDGE
	// 	freopen("input.txt", "r", stdin);
	// 	freopen("output.txt", "w", stdout);
	// #endif

	int n, k;
	cin >> n >> k;
	int a[n];
	for(int i=0; i<n; i++)cin >> a[i];
	int dp[k+1], pre[k+1];
	ini(pre, 0);
	ini(dp, 0);
	dp[0]=1;
	pre[0]=1;
	for(int i=0; i<n; i++){
		for(int j=1; j<=k; j++){
			pre[j] = (pre[j-1] + dp[j])%MOD;
		}
		for(int j=k; j>0; j--){
			dp[j] = (pre[j] - ((j-a[i]-1>=0) ? pre[j-a[i]-1] : 0)+MOD)%MOD;
		}		
	}
	cout << dp[k] << endl;
 
	return 0;
}  

Measured memory_bytes: 5204
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <sstream>
#include <cstring>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <numeric>
#include <cctype>
#include <cassert>

// BEGIN CUT HERE
#ifdef _MSC_VER
#include <agents.h>
#endif
// END CUT HERE 

#define FOR(i, a, b) for(int i = (a); i < (int)(b); ++i)
#define rep(i, n) FOR(i, 0, n)
#define ALL(v) v.begin(), v.end()
#define REV(v) v.rbegin(), v.rend()
#define MEMSET(v, s) memset(v, s, sizeof(v))
#define MP make_pair
#define MT make_tuple
#define X first
#define Y second

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> P;

int main(){
	int n;
	cin >> n;
	vector<vector<int>> C(n, vector<int>(n, 0));
	rep(i, n) rep(j, n) cin >> C[i][j];
	ll ans = 0;
	rep(i, n) rep(j, n) ans += min(C[i][j], C[j][i]);
	cout << ans / 2 << endl;

	return 0;
}

Measured memory_bytes: 1248
/*
 *  Created on: 8 / 5 / 2020
 *  Author:     Eslam Waheed
 */
#include <bits/stdc++.h>
//#include <bits/BIGINT.h>
//#include <bits/Int128.h>
using namespace std;

//#define _CRT_SECURE_NO_WARNINGS
//#define __USE_MINGW_ANSI_STDIO
#define Eslam__Waheed ios_base::sync_with_stdio(false);cout.tie(NULL);cin.tie(NULL);

#define ll   long long
#define ull  unsigned ll
#define dd   double
#define ld   long dd
#define ss   string

#define pb      push_back
#define all(c)  c.begin(), c.end()
#define rall(c) c.rbegin(), c.rend()
#define stp(n)  cout << fixed << setprecision(n);
#define iq(v)   v.resize(unique(v.begin(),v.end())-v.begin())
#define sz(s)   (ll)(s.size())
#define endl    '\n'

#define loop(i,m,n)  for(ll i=m;i<n;i++)

ll gcd(ll a, ll b) { return !b ? abs(a) : gcd(b, a % b); }
ll lcm(ll a, ll b) { return abs(a / gcd(a, b)) * b; }

//const ll mod = 1e9 + 7;
//__int128
/*
 you can ^_^ (•‿•)

( إن الله وملائكته يصلون على النبي يا أيها الذين آمنوا صلوا عليه وسلموا تسليما )
*/
int main()
{
    //stp(0)
    Eslam__Waheed
        ss a, b; cin >> a >> b;
    a += b.back();
    cout << ((a == b) ? "Yes" : "No");
}

Measured memory_bytes: 3656
package main

import (
	"fmt"
)

func main() {
	var L, N int
	fmt.Scanf("%d%d", &L, &N)
	A, B := 0, 0
	X := make([]int, N+1)
	for i := 1; i <= N/2; i++ {
		fmt.Scanf("%d", &X[i])
		A += 2 * X[i]
		B += 2 * X[i]
	}
	if N%2 == 1 {
		fmt.Scanf("%d", &X[(N+1)/2])
		A += X[(N+1)/2]
		B += (L - X[(N+1)/2])
	}
	for i := 1; i <= N/2; i++ {
		fmt.Scanf("%d", &X[(N+1)/2+i])
		A += 2 * (L - X[(N+1)/2+i])
		B += 2 * (L - X[(N+1)/2+i])
	}
	if N%2 == 0 {
		A -= L - X[N/2+1]
		B -= X[N/2]
	}
	ans := A
	if ans < B {
		ans = B
	}
	for i := 0; i < N/2; i++ {
		if (N-i)%2 == 0 {
			A += -2*X[1+i] - (L - X[(N-i)/2+1+i]) + X[(N-i)/2+1+i]
			B += -2*(L-X[N-i]) - X[(N-i)/2] + (L - X[(N-i)/2])
		} else {
			A += -2*X[1+i] - (L - X[(N+1-i)/2+1+i]) + X[(N+1-i)/2+i]
			B += -2*(L-X[N-i]) - X[(N-i)/2] + (L - X[(N+1-i)/2])
		}
		if ans < A {
			ans = A
		}
		if ans < B {
			ans = B
		}
	}
	fmt.Printf("%d\n", ans)
}


Measured memory_bytes: 6400
#include <bits/stdc++.h>
using namespace std;
#define rep(i,a,n) for (int i=a;i<n;i++)
#define per(i,a,n) for (int i=n-1;i>=a;i--)
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define fi first
#define se second
#define SZ(x) ((int)(x).size())
typedef vector<int> VI;
typedef long long ll;
typedef pair<int,int> PII;
typedef double db;
mt19937 mrand(random_device{}()); 
const ll mod=1000000007;
int rnd(int x) { return mrand() % x;}
ll powmod(ll a,ll b) {ll res=1;a%=mod; assert(b>=0); for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}
ll gcd(ll a,ll b) { return b?gcd(b,a%b):a;}
// head

const int N=201000;
int n,k,a[N],cnt[N];
int main() {
	scanf("%d%d",&n,&k);
	rep(i,1,n+1) {
		scanf("%d",a+i);
	}
	rep(r,0,k) {
		rep(i,1,n+1) cnt[i]=0;
		rep(i,1,n+1) {
			cnt[max(i-a[i],1)]++;
			cnt[min(i+a[i]+1,n+1)]--;
		}
		VI p(a+1,a+n+1);
		rep(i,1,n+1) cnt[i]+=cnt[i-1],a[i]=cnt[i];
		VI q(a+1,a+n+1);
		if (p==q) break;
	}
	rep(i,1,n+1) printf("%d ",a[i]); puts("");
}


Measured memory_bytes: 6416
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)(n);i++)
using namespace std;
using ll = long long ;
using P = pair<int,int> ;
using pll = pair<long long,long long>;
constexpr int INF = 1e9;
constexpr long long LINF = 1e17;
constexpr int MOD = 1000000007;
constexpr double PI = 3.14159265358979323846;

int main(){
    stack<int> st;
    string s;
    while(cin >> s){
        if(s=="+"){
            int r = st.top();
            st.pop();
            int l = st.top();
            st.pop();
            st.push(l+r);
        }else if(s=="-"){
            int r = st.top();
            st.pop();
            int l = st.top();
            st.pop();
            st.push(l-r);
        }else if(s=="*"){
            int r = st.top();
            st.pop();
            int l = st.top();
            st.pop();
            st.push(l*r);
        }else{
            st.push(stoi(s));
        }
    }
    cout << st.top() << endl;
    return 0;
}


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

int main()
{
    int n;
    while(cin>>n)
    {
        if(n==1)
            printf("%f\n",1.0);
        else if(n%2)
            printf("%f\n",(n+1.0)/(2.0*n));
        else
            printf("%f\n",0.5);
    }
    return 0;
}



Measured memory_bytes: 256
#include <cstdio>
#include <iostream>

using namespace std;

bool o(string S) {
    if (S[0] != S[1]) {
        if (S[0] == S[3]) {
            if (S[1] == S[2]) {
                cout << "Yes" << endl;
                return true;
            } else {
                return false;
            }
        } else if (S[0] == S[2]) {
            if (S[1] == S[3]) {
                cout << "Yes" << endl;
                return true;
            } else {
                return false;
            }
        }
    } else {
        if (S[2] == S[3]) {
            if (S[2] != S[0]) {
                cout << "Yes" << endl;
                return true;
            }
        } else {
            return false;
        }
    }
    return false;
}

int main() {
    string S;
    cin >> S;
    if (!o(S)) cout << "No" << endl;
}

Measured memory_bytes: 256
/* 考察欄 : 元の盤面を M1, 新しい盤面を M2とすると
          for (i, j) in [n]^2:
              M2[i, j]=M2[j, i] <===> M1[i-A, j-B] = M1[j-A, i-B]
          i-A = x, j-B = y とし, z = A-Bとすれば
                                <===> M1[x, y] = M1[x-z,y+z]
          したがって, 候補は高々 -n < A-B < n で O(n)個 : O(n^2)で調べることが可能
          ~~~~~> 全体で O(n^3)でおk
*/
#include <stdio.h>
#include <cstring>

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

constexpr int N = 300;
char str[N][N+10];

bool judge(int n, int d){
    REP(x, n) REP(y, n) if(str[x][y] != str[(y+n+d)%n][(x+n-d)%n]) return false;
    return true;
}

int main(void){
    int n; scanf("%d", &n);
    REP(i, n) scanf("%s", str[i]);
    int res = 0;
    for(int d = -(n-1); d < n; ++d) if(judge(n, d))
                            res += n - (d < 0 ? -d : d);
    
    printf("%d\n", res);
    
    
    return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;
public class Main {
	@SuppressWarnings("resource")
	public static void main(String[] args) {
		Scanner scanner=new Scanner(System.in);
		long peopleNum=0;
		long moveMax[]=new long[5];
		long tmp=0;
		peopleNum=scanner.nextLong();
		for(int i=0;i<moveMax.length;i++) {
			moveMax[i]=scanner.nextLong();
		}
		for(int j=0;j<4;j++) {
		for(int i=0;i<4;i++) {
			if(moveMax[i]>moveMax[i+1]) {
				tmp=moveMax[i];
				moveMax[i]=moveMax[i+1];
				moveMax[i+1]=tmp;
			}
		}}
		long count=peopleNum/moveMax[0];
		if(peopleNum%moveMax[0]!=0) {
			count++;
		}
		System.out.println(count+4);
	}
}

Measured memory_bytes: 23892
//Reference https://qiita.com/hatoo@github/items/fa14ad36a1b568d14f3e
 use std::cmp::max;
macro_rules! get {
      ($t:ty) => {
          {
              let mut line: String = String::new();
              std::io::stdin().read_line(&mut line).unwrap();
              line.trim().parse::<$t>().unwrap()
          }
      };
      ($($t:ty),*) => {
          {
              let mut line: String = String::new();
              std::io::stdin().read_line(&mut line).unwrap();
              let mut iter = line.split_whitespace();
              (
                  $(iter.next().unwrap().parse::<$t>().unwrap(),)*
              )
          }
      };
      ($t:ty; $n:expr) => {
          (0..$n).map(|_|
              get!($t)
          ).collect::<Vec<_>>()
      };
      ($($t:ty),*; $n:expr) => {
          (0..$n).map(|_|
              get!($($t),*)
          ).collect::<Vec<_>>()
      };
      ($t:ty ;;) => {
          {
              let mut line: String = String::new();
              std::io::stdin().read_line(&mut line).unwrap();
              line.split_whitespace()
                  .map(|t| t.parse::<$t>().unwrap())
                  .collect::<Vec<_>>()
          }
      };
      ($t:ty ;; $n:expr) => {
          (0..$n).map(|_| get!($t ;;)).collect::<Vec<_>>()
      };
}

fn main(){
    let(p, q, r) = get!(usize, usize, usize);
    let mut ans;
    ans = p + q + r - max(p, max(q, r));
    println!("{}", ans);


}

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

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

    int arr[n];
    int arr1[n];
    

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


    sort(arr1, arr1+n);
    int c= 0;
    for (int i =0;i<n;i++)
    {
        if (arr[i]==arr1[i])
            continue;
            else
            {
                c++;
               
            }
    }
    if (c>2)
    {
        cout<<"NO"<<endl;
    }
    else if (c==2)
    {
        cout<<"YES"<<endl;
    }
else
{
    cout<<"YES"<<endl;
}






}


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

typedef long long ll;
const int N = 2000054, mod = 1000000007;

int x1, x2, x3, x4, x5, x6;
int y1, y2, y3, y4, y5, y6;
int fact[N], finv[N];

ll PowerMod(ll a, int n, ll c = 1) {for (; n; n >>= 1, a = a * a % mod) if (n & 1) c = c * a % mod; return c;}

void init() {
	int i;
	for (*fact = i = 1; i < N; ++i) fact[i] = (ll)fact[i - 1] * i % mod;
	--i, finv[i] = PowerMod(fact[i], mod - 2);
	for (; i; --i) finv[i - 1] = (ll)finv[i] * i % mod;
}

inline ll Ct(int a, int b) {return (ll)fact[a + b] * finv[a] % mod * finv[b] % mod;}

int solve(int xL, int yL, int xR, int yR) {
	int x, y, ret = 0;
	for (x = x3; x <= x4; ++x)
		ret = (ret - Ct(x - xL, y3 - yL - 1) * Ct(xR - x, yR - y3) % mod * (x + y3)) % mod,
		ret = (ret + Ct(x - xL, y4 - yL) * Ct(xR - x, yR - y4 - 1) % mod * (x + y4 + 1)) % mod;
	for (y = y3; y <= y4; ++y)
		ret = (ret - Ct(x3 - xL - 1, y - yL) * Ct(xR - x3, yR - y) % mod * (x3 + y)) % mod,
		ret = (ret + Ct(x4 - xL, y - yL) * Ct(xR - x4 - 1, yR - y) % mod * (x4 + y + 1)) % mod;
	return ret + (ret >> 31 & mod);
}

int main() {
	ll ans = 0; init();
	scanf("%d%d%d%d%d%d%d%d%d%d%d%d", &x1, &x2, &x3, &x4, &x5, &x6, &y1, &y2, &y3, &y4, &y5, &y6);
	ans = (ll)solve(x1 - 1, y1 - 1, x5,     y5    )
			- solve(x1 - 1, y1 - 1, x5,     y6 + 1)
			- solve(x1 - 1, y1 - 1, x6 + 1, y5    )
			+ solve(x1 - 1, y1 - 1, x6 + 1, y6 + 1)
			- solve(x1 - 1, y2,     x5,     y5    )
			+ solve(x1 - 1, y2,     x5,     y6 + 1)
			+ solve(x1 - 1, y2,     x6 + 1, y5    )
			- solve(x1 - 1, y2,     x6 + 1, y6 + 1)
			- solve(x2,     y1 - 1, x5,     y5    )
			+ solve(x2,     y1 - 1, x5,     y6 + 1)
			+ solve(x2,     y1 - 1, x6 + 1, y5    )
			- solve(x2,     y1 - 1, x6 + 1, y6 + 1)
			+ solve(x2,     y2,     x5,     y5    )
			- solve(x2,     y2,     x5,     y6 + 1)
			- solve(x2,     y2,     x6 + 1, y5    )
			+ solve(x2,     y2,     x6 + 1, y6 + 1);
	ans %= mod, ans += ans >> 63 & mod;
	printf("%d\n", (int)ans);
	return 0;
}

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

typedef double du ;
typedef string st ;
typedef long long ll ;
typedef long double ld ;
typedef long long int lli ;

#define vi vector <lli>
#define loop(num) for (lli i = 0 ; i < num ; i ++ )
#define loopcin(num , ar ) for (lli i = 0 ; i < num ; i ++ ) {cin >> ar [i] ;}
#define loopcout(num , ar) for (lli i = 0 ; i < num ; i ++ ) {cout << ar [i] << ' '; }

#define forr(num1 , num2) for (lli i = num1 ; i < num2 ; i ++ )
#define forrcin(num1 , num2 , ar ) for (lli i = num1 ; i < num2 ; i ++ ) {cin >> ar [i] ;}
#define forrcout(num1 , num2 , ar) for (lli i = num1 ; i < num2 ; i ++ ) {cout << ar [i] << ' '; }

#define D2forrcin(num1_1 , num1_2 , num2_1 , num2_2 , A ) for (lli i = num1_1 ; i < num1_2 ; i ++){ for (lli j = num2_1 ; j < num2_2 ; j++){cin >> A[i][j] ;}}
#define D2forrcout(num1_1 , num1_2 , num2_1 , num2_2 , A ) for (lli i = num1_1 ; i < num1_2 ; i ++){ for (lli j = num2_1 ; j < num2_2 ; j++){cout << A[i][j] << ' ' ;}cout << endl ;}

#define YES cout << "YES" << endl
#define Yes cout << "Yes" << endl
#define NO cout << "NO" << endl
#define No cout << "No" << endl

#define F first
#define S second

#define fastio ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);

int main ()
{
    fastio
    st s1 , s2 ;
    lli cnt = 0 ;
    cin >> s1 >> s2 ;
    for (lli i = 0 , j = 2 ; i < 3 ; i ++ , j --)
        if (s1[i] == s2[j])
            cnt ++ ;

    (cnt == 3 ? YES : NO) ;
    return 0 ;
}

/*___________________________________________________________________functions___________________________________________________________________________*/



Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main (){
int w, h, x, y, r;
cin >> w >> h >> x >> y >> r;
if (x - r < 0){
	cout << "No" << endl;
}else{
	if (x + r > w){
		cout << "No" << endl;
	}else{
		if (y - r < 0){
			cout << "No" << endl;
		}else{
			if (y + r > h){
				cout << "No" << endl;
			}else{
				cout << "Yes" << endl;
			}
		}
	}
}

}



Measured memory_bytes: 3096
from collections import deque
h,w=[int(i) for i in input().split()]
a=[[i for i in input()] for _ in range(h)]
right_count=sum([sum([1 for j in range(w) if a[i][j]=="#"]) for i in range(h)])
pattern=[(1,0),(0,1)]
queue=deque([(0,0)])
def bfs():
    cnt=1
    while queue:
        (x,y)=queue.popleft()
        if (x,y)==(w-1,h-1):
            return cnt
        around=False
        for i,j in pattern:
            if y+i<h and x+j<w:
                if a[y+i][x+j]=="#":
                    queue.append((x+j,y+i))
                    around=True
                    cnt+=1
        if around==False:
            return False
print("Possible" if bfs()==right_count else "Impossible")

Measured memory_bytes: 3564
#ifdef HIRO
#include "../stdc++.h"
#define d(f_, ...) printf((f_), ##__VA_ARGS__)
#else
#include <bits/stdc++.h>
#define d(f_, ...)
#endif

using namespace std;
typedef long long ll;

int main() {
#ifdef HIRO
  string file_path(QUIZ);
  ifstream cin(file_path + "/input.txt");
  std::cin.rdbuf(cin.rdbuf());
#endif
  int n;
  int m;
  string s;
  cin >> n;
  cin >> m;
  cin >> s;
  s[m - 1] = s[m - 1] - 'A' + 'a'; 


  cout << s << endl;
  return 0;
}



Measured memory_bytes: 256
import math

N = int(input())
D = []
for i in range(N):
    D.append(list(map(int, input().split())))
s = 0
while len(D) > 1:
    a = D[0]
    for d in D[1:]:
        s += ((a[0] - d[0]) ** 2 + (a[1] - d[1]) ** 2) ** 0.5
    D = D[1:]
print((s * (math.factorial(N - 1) * 2)) / (math.factorial(N)))

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
#define forn(i, n) for (int i = 0; i < (int)(n); ++i)
#define fore(i, b, e) for (int i = (int)(b); i <= (int)(e); ++i)
#define ford(i, n) for (int i = (int)(n) - 1; i >= 0; --i)
#define pb push_back
#define fi first
#define se second
#define all(x) (x).begin(), (x).end()
typedef vector<int> vi;
typedef pair<int, int> pii;
typedef long long i64;
typedef unsigned long long u64;
typedef long double ld;
typedef long long ll;
// #define sz(x) int((x).size())

int main() {
#ifdef LOCAL
//     freopen("a.in", "r", stdin);
#endif

    int n;
    string a, b;
    cin >> n >> a >> b;
    for (int len = 0;; ++len) {
        string s = a.substr(0, len) + b;
        bool ok = true;
        forn(i, n) {
            if (s[i] != a[i]) ok = false;
            if (s[len+i] != b[i]) ok = false;
        }
        if (ok) {
            cout << s.size() << endl;
            return 0;
        }
    }

#ifdef LOCAL
    cerr << "Time elapsed: " << clock() / 1000 << " ms" << endl;
#endif
    return 0;
}


Measured memory_bytes: 256
n = int(input())
groups = [0] * 5
for _ in range(n):
    s = input()
    if s[0] == "M":
        groups[0] += 1
    elif s[0] == "A":
        groups[1] += 1
    elif s[0] == "R":
        groups[2] += 1
    elif s[0] == "C":
        groups[3] += 1
    elif s[0] == "H":
        groups[4] += 1
ans = 0
for i in range(5):
    for j in range(5):
        for k in range(5):
            if i != j and j != k and k != i:
                ans += groups[i] * groups[j] * groups[k]
print(ans//6)

Measured memory_bytes: 3064
from collections import Counter


def main():
    n = int(input())
    m = n
    factorization_p = []
    while m % 2 == 0:
        factorization_p.append(2)
        m //= 2
    prime_num = 3
    while prime_num * prime_num <= m:
        if m % prime_num == 0:
            factorization_p.append(prime_num)
            m //= prime_num
        else:
            prime_num += 2
    if m != 1:
        factorization_p.append(m)
    factorization_p = Counter(factorization_p)
    answer = 0
    for _, p in factorization_p.items():
        i = 1
        p *= 2
        while i * (i + 1) <= p:
            answer += 1
            i += 1
    print(answer)


if __name__ == '__main__':
    main()



Measured memory_bytes: 9436
Input1 = [int(_) for _ in input().split(" ")]
Input2 = [(int(i)+1)/2 for i in input().split(" ")]

sum_ = sum(Input2[:Input1[1]])
Max = sum_
for j in range(Input1[0]-Input1[1]):
    sum_ = sum_-Input2[j]+Input2[j+Input1[1]]
    if Max  < sum_:
        Max = sum_
        
print(Max)

Measured memory_bytes: 23588
#include <iostream>

int main()
{
    int N;
    std::cin >> N;

    auto count{0};

    for (auto i = 1; i <= N; i++) {
        int a;
        std::cin >> a;

        if (i % 2 == 1 && a % 2 == 1) {
            count++;
        }
    }

    std::cout << count << std::endl;

    return 0;
}


Measured memory_bytes: 3632
n = int(input())
dic = {}
for i in range(n):
    p = list(input())
    p.sort()
    p = ''.join(p)
    if p in dic.keys():
        dic[p] += 1
    else:   
        dic[p] = 1

ans = 0
for i in dic.keys():
    if dic[i] == 1:
        continue
    else:
        ans += (dic[i]*(dic[i] - 1))//2

print(ans)

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

int main(){
  int N,K;
  cin >> N >> K;
  vector<int> h(N);
  for(int i = 0; i < N; i++){
    cin >> h[i];
  }
  vector<int> dp(N);
  dp[1] = abs(h[1]-h[0]);
  for(int i = 2; i < N; i++){
    vector<int> range = {};
    int m = 1000000000;
    for(int j = 0; j < K; j++){
      if(i-1-j < 0) break;
      m = min(m,dp[i-1-j]+abs(h[i-1-j]-h[i]));
    }
    dp[i] = m;
  }
  cout << dp[N-1] << endl;
}

Measured memory_bytes: 3988