akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
#define mo 1000000007
#define ni2 500000004
#define N 200010
#define ll long long
using namespace std;
ll po(ll x,ll y){ll z=1;while(y){if(y%2)z=x*z%mo;x=x*x%mo;y/=2;}return z;}
struct fs{ll x;int y;}q[N],p[N];
fs operator *(fs x,ll y){if (y==0) x.y++;else x.x=x.x*y%mo;return x;}
fs operator *(fs x,fs y){fs z;z.y=x.y+y.y;z.x=x.x*y.x%mo;return z;}
fs operator /(fs x,fs y){fs z;z.y=x.y-y.y;z.x=x.x*po(y.x,mo-2)%mo;return z;}
fs operator +(fs x,fs y){
	if (x.y>y.y) swap(x,y);
	if (x.y==y.y)x.x=x.x+y.x;
	if (x.x%mo==0){x.y++;x.x/=mo;}
	x.x%=mo;
	return x;
}
ll zh(fs x){if (x.y==0)return x.x;return 0;}
ll sum,a[N],g[N],ans;
int n;
void work(int l,int r){
	if (l>=r) return ;
	int mid=(l+r)/2;
	work(l,mid);work(mid+1,r);
	fs x;x=(fs){0,n+1};
	for (int i=mid,j=r;i>=l;i--){
		while (a[j]>=a[i]&&j>mid){x=x+p[a[j]];j--;}
		ans=(ans+(sum*zh(x/p[a[i]])%mo)*ni2)%mo;
	}
	x=(fs){0,n+1};
	for (int j=r,i=mid;j>mid;j--){
		while (a[i]>a[j]&&i>=l){x=x+p[a[i]];i--;}
		ans=(ans+sum*(mid-i+mo-zh(x/p[a[j]])*ni2%mo))%mo;
	}
	sort(a+l,a+r+1);
}
int main(){
	cin>>n;
	for (int i=1;i<=n;i++){cin>>a[i];g[a[i]]++;}
	for (int i=n;i>=1;i--)g[i]+=g[i+1];
	for (int i=1;i<=n;i++)g[i]=g[i]-n+i;
	for (int i=1;i<=n;i++)if (g[i]<=0){puts("0");return 0;}
	q[0]=(fs){1,0};for (int i=1;i<=n;i++)q[i]=q[i-1]*g[i];
	p[0]=(fs){1,0};for (int i=1;i<=n;i++)p[i]=p[i-1]*(g[i]-1);
	for (int i=1;i<=n;i++)p[i]=p[i]/q[i];
	sum=q[n].x;
	work(1,n);
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 9600
#include<bits/stdc++.h>
using namespace std;
int main(){
  int N,f1,f2,f3,f4,f5,f6,f7,f8;
  cin >> N;
  
  f1 = N / 10000000;
  f2 = N / 1000000 - f1 * 10;
  f3 = N / 100000 - f1 * 100 - f2 * 10;
  f4 = N / 10000 - f1 * 1000 - f2 * 100 - f3 * 10;
  f5 = N / 1000 - f1 * 10000 - f2 * 1000 - f3 * 100 - f4 * 10;
  f6 = N / 100 - f1 * 100000 - f2 * 10000 - f3 * 1000 - f4 * 100 - f5 * 10;
  f7 = N / 10 - f1 * 1000000 - f2 * 100000 - f3 * 10000 - f4 * 1000 - f5 * 100 - f6 * 10;
  f8 = N - f1 * 10000000 - f2 * 1000000 - f3 * 100000 - f4 * 10000 - f5 * 1000 - f6 * 100 - f7 * 10;
  
  N = N % (f1 + f2 + f3 + f4 + f5 + f6 + f7 + f8);
  
  if(N == 0){
    cout << "Yes" << endl;
  }
  else{
    cout << "No" << endl;
  }
}

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

dp = [[0 for _ in range(N)] for _ in range(N)]

for _ in range(M):
    l,r = map(int,input().split())
    l -= 1
    r -= 1
    
    dp[l][r] += 1

for l in range(N):
    for r in range(N-1):
        dp[l][r+1] += dp[l][r]

for r in range(N):
    for l in range(N-1):
        dp[l+1][r] += dp[l][r]

     
for _ in range(Q):
    p,q = map(int,input().split())
    p -= 1
    q -= 1
    
    if p >= 1:
        print(dp[N-1][q]-dp[p-1][q])
    else:
        print(dp[N-1][q])

Measured memory_bytes: 13428
#include <bits/stdc++.h>
using namespace std;
	bool f(int x){
    	int keta=0;
      while(x){
      	keta++;
        x/=10;
      }
      return keta%2==1;
    }
int main(){
int N;
  cin>>N;
int ans=0;
  for(int i=1;i<=N;i++){
  	if(f(i)){
    ans++;
    }
  }
  cout<<ans<<endl;
}

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

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

    int n; cin >> n;
    int a[100005];
    int ans = 0;
    rep(i, n) {
        cin >> a[i];
    ans += a[i]-1;
    }
    cout << ans << endl;
    return 0;
}

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

const string YES = "YES";
void yes() {
  cout << YES << endl;
  exit(0);
}

const string NO = "NO";
void no() {
  cout << NO << endl;
  exit(0);
}

string S;

void solve() {
  for(int i = 0 ; i < S.size() ; i++){
    for(int j = i ; j <= S.size() ; j++){
      string t = S.substr(0, i) + S.substr(j);
      if( t == "keyence") yes();
    }
  }
  no();
}

void input() {
  S = string();
  cin >> S;
}

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


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

typedef long long int LL;

int main() {
  LL N;
  cin >> N;
  LL A[N];
  for (LL i = 0; i < N; i++) {
    cin >> A[i];
  }
  
  LL n1[61];
  LL n0[61];
  
  for (LL i = 0; i < 61; i++) {
    n1[i] = n0[i] = 0;
    for (LL j = 0; j < N; j++) {
      if ((A[j] >> i) & 1) {n1[i]++;}
      else {n0[i]++;}
    }
  }
  
  LL ans = 0;
  const LL mod = 1000000007;
  
  for (LL i = 0; i < 61; i++) {
    ans += (((1LL << i) % mod) * ((n1[i] * n0[i]) % mod)) % mod;
    ans = ans % mod;
  }
  
  cout << ans << endl;
  
}

Measured memory_bytes: 2560
def main():
    """
    N<=8, M<=N(N-1)/2
    →全探索?
    """
    N, M = map(int, input().split())

    # 無向グラフ
    g = [
        [False] * N
        for _ in range(N)
    ]
    for _ in range(M):
        a, b = map(int, input().split())
        g[a - 1][b - 1] = True
        g[b - 1][a - 1] = True

    # 訪問状態
    visited = [False for _ in range(N)]
    visited[0] = True

    def dfs(v, N, visited):
        if all(visited):
            return 1

        ret = 0
        for i in range(N):
            # 経路存在と訪問済み確認
            if not g[v][i] or visited[i]:
                continue

            # 再帰後に元に戻す
            visited[i] = True
            ret += dfs(i, N, visited)
            visited[i] = False

        return ret

    ans = dfs(0, N, visited)

    print(ans)

if __name__ == '__main__':
    main()


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

#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define ALL(obj) (obj).begin(), (obj).end()
#define INF 1e9
typedef long long ll;


int main() {
    string a,b,c; cin >> a >> b >> c;
    cout << a[0] << b[1] << c[2] << endl;
    return 0;
}

Measured memory_bytes: 3568
import sys

def main():
    input = sys.stdin.read()
    data = list(map(int, input.split()))

    n = data[0]
    data = data[1:]

    sum = 0
    for i in data:
        sum += i
    ans, cnt = 0, 0

    for i in data:
        # cnt += i
        sum -= i
        ans += sum * i
        ans = ans % 1000000007
        # print(ans,sum)
    print(ans)


if __name__ == '__main__':
    main()


Measured memory_bytes: 32888
#include <stdio.h>
int main()
{
    long long  i, j, GCD, LCM, t, x, y;
    while((scanf("%lld %lld", &i, &j))!=EOF){
            x=i;
            y=j;
        if(i==0) GCD=j;
        else if(j==0) GCD=j;
        else{
            while(j!=0){
                t=j;
                j=i%j;
                i=t;
            }
          GCD=i;
        }
        LCM=(x*y)/GCD;
        printf("%lld %lld\n",GCD,LCM);
    }
    return 0;
}

Measured memory_bytes: 592
#include <bits/stdc++.h>
using namespace std;
#include<chrono>
#define ll long long
#define ld long double
#define eb emplace_back
#define pb push_back
#define mt make_tuple
#define tc  ll t; cin>>t; while(t--)
#define io ios::sync_with_stdio(false),cin.tie(NULL),cout.tie(NULL);
#define F first
#define S second
#define vi vector<ll>
#define pii pair<ll,ll>
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define vii vector<pair<ll,ll>>
ll gcd(ll n,ll m)
{
    if(n==0)
            return m;
    return gcd(m%n,n);
}
bool ifprime(ll n)
{
if(n==1)
return false;
    ll i;
for(i=2;i*i<=n;i++)
{
if(n%i==0)
return false;
 
}
return true;
}
void disp(vi v)
{
    for(auto u:v)
    cout<<u<<" ";
    cout<<"\n";
}
void remleadzero(vector<int> &v)
{
    vector<int> u;
    int i=0;
    while(v[i]==0)
        i++;
    while(i<v.size())
    {
        u.push_back(v[i]);
        i++;
    }
    v=u;
}
#define mod 1000000007LL
/*
void myscanf(long long *n)
{
    register long long c=getchar_unlocked();
    *n=0;
    for(;(c<48 ||c>57);c=getchar_unlocked())
        ;
    for(;(c>47 && c<58);c=getchar_unlocked())
    {
        *n=(*n<<1)+(*n<<3)+(c&15);
    }
 
}
void fastscan(long long &number)
{
    bool negative = false;
    register long long c;
 
    number = 0;
 
    c = getchar_unlocked();
    if (c=='-')
    {
 
        negative = true;
 
        c = getchar_unlocked();
    }
 
 
    for (; (c>47 && c<58); c=getchar_unlocked())
        number = number *10 + c - 48;
 
 
    if (negative)
        number *= -1;
}
*/
ll fast_expo(ll n,ll m, ll md)
{
    ll a=1;
    while(m>0)
    {
        if(m&1) a=(a*n)%md;
        n=(n*n)%md;
        m/=2;
    }
    return a%md;
}
long long sqroot(long long n){
    long double N = n;
    N = sqrtl(N);
    long long sq = N-2;
    sq = max(sq,0LL);
    while(sq*sq<n){
        sq++;
    } 
    if((sq*sq)==n)
        return sq;
    return -1;
}
int dig(int n){
    int ret=0;
    while(n>0){
        n/=10;
        ret++;
    }
    return ret;
}
long long fac[100005],inv[100005];
int main()
{
    io;
    long long n,k;

    cin>>n>>k;
    long long a[n+1];
    for(int i=1;i<=n;i++){
        cin>>a[i];
    }
    sort(a+1,a+n+1);
    fac[0]=1;
    inv[0] = fast_expo(fac[0],mod-2,mod);
    for(int i=1;i<=100000;i++){
        fac[i] = (fac[i-1]*i)%mod;
        inv[i] = fast_expo(fac[i],mod-2,mod);
    }
    long long ans=0;
    for(int i=k;i<=n;i++){
        ans = ans + ((((((inv[k-1]*fac[i-1])%mod)*inv[i-k])%mod)*(a[i]))%mod);
        ans%=mod;
        ans+=(2LL*mod);
        ans%=mod;
        // cout<<i<<' '<<a[i]<<' '<<ans<<'\n';
    }
    // cout<<ans<<' ';
    for(int i=1;i<=n-k+1;i++){
        ans-=(a[i]*((((fac[n-i]*inv[k-1])%mod)*inv[n+1-k-i])%mod))%mod;
        ans%=mod;
        ans+=(2LL*mod);
        ans%=mod;
    }
    cout<<ans;
    return 0;
}


Measured memory_bytes: 2560
import java.util.Scanner;
public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String s = sc.next();
        String s1 = "Sunny";
        String s2 = "Cloudy";
        String s3 = "Rainy";
        
        if(s.equals(s1))System.out.println("Cloudy");
        else if(s.equals(s2))System.out.println("Rainy");
        else if(s.equals(s3)) System.out.println("Sunny");
        
        
        
    }
}


Measured memory_bytes: 22996
import java.util.Scanner;

public class Main{
public static void main(String[] args){
  Scanner sc = new Scanner(System.in);
  int n;
  int[] s = new int[1000];
 
  while(true){
  double m=0,l=0,a2;
  n = sc.nextInt();
  if(n==0) break;
  for(int i=0;i<n;i++){
    s[i] = sc.nextInt();
    m += s[i];
    l += s[i]*s[i];
  }
    m /=n;
    l /=n;
    a2 = l-m*m;
    System.out.printf("%f\n",Math.sqrt(a2));
}
  sc.close();
}
}


Measured memory_bytes: 31776
import java.util.*;
public class Main {
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    String s = sc.next();
   
    System.out.println(c(s));
    
  }
  
  //再帰
  static Long c(String s){
    Long num = Long.parseLong(s);

    for(int i = 1 ; i < s.length() ; ++i){
      String s_l = s.substring(0, i);
      Long num_l = Long.parseLong(s_l);
      num += num_l * (int)Math.pow(2,(s.length()-i-1));
      String s_r = s.substring(i);
      num += c(s_r);
     
    }
    return num;
  }
}


Measured memory_bytes: 35800
#include <iostream>
#include <iomanip>
#include <vector>
#include <stack>
#include <set>
#include <map>
#include <algorithm>
#include <cstdio>
#include <utility>
#include <string>
#include <cmath>
#include <cstdlib>
#include <cstring>
 
using namespace std;
 
typedef uint64_t u64;
typedef int64_t s64;
typedef uint32_t u32;
typedef int32_t s32;
 
#define MAX(x, y) ((x) < (y) ? (y) : (x))
#define MIN(x, y) ((x) > (y) ? (y) : (x))
 
#define rep(i, N) for(int i = 0; i < N; ++i)
 
#define CEIL(x, y) (((x) + (y) - 1) / (y))
#define MOD 1000000007ULL
 
#define NOT_FOUND (-1)
int binary_search(const int *A, const int size, const int key);
 
int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
 
    int n, q;
    int *S;
    int T;
 
    cin >> n;
    S = new int[n];
    rep (i, n)
    {
        cin >> S[i];
    }
 
    int ret = 0;
    cin >> q;
    rep (i, q)
    {
        cin >> T;
        if (binary_search(S, n, T) != NOT_FOUND)
        {
            ++ret;
        }
    }
 
    cout << ret << "\n";
 
    return 0;
}
 
int binary_search(const int *A, const int size, const int key)
{
    int left = 0, right = size - 1;
    while (left < right)
    {
        int index = (left + right) / 2;
        if (A[index] == key)
        {
            return index;
        }
        else if (A[index] < key)
        {
            left = index + 1;
        }
        else if (A[index] > key)
        {
            right = index - 1;
        }
    }
    return (A[left] == key) ? left : NOT_FOUND;
}



Measured memory_bytes: 3524
h, w = [int(i) for i in input().split()]

s = [input() for i in range(h)]

light = [[0 for i in range(w)] for j in range(h)]

for j in range(h):
    point = 0
    for i in range(w):
        if s[j][i] == ".":
            point += 1
            light[j][i] += point
        else:
            point = 0

    point = 0
    for i in range(w):
        if s[j][-1-i] == ".":
            point += 1
            light[j][-1-i] += point
        else:
            point = 0

for j in range(w):
    point = 0
    for i in range(h):
        if s[i][j] == ".":
            point += 1
            light[i][j] += point
        else:
            point = 0

    point = 0
    for i in range(h):
        if s[-1-i][j] == ".":
            point += 1
            light[-1-i][j] += point
        else:
            point = 0

ans = 0
for i in range(h):
    ans = max(ans, max(light[i]))
print(ans-3)

Measured memory_bytes: 97880
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n)  for(long long i=0;i<(long long)(n);i++)
#define REP(i,k,n) for(long long i=k;i<(long long)(n);i++)
#define all(a) a.begin(),a.end()
#define pb push_back
#define eb emplace_back
#define lb(v,k) (lower_bound(all(v),k)-v.begin())
#define ub(v,k) (upper_bound(all(v),k)-v.begin())
#define fi first
#define se second
#define pi M_PI
#define PQ(T) priority_queue<T>
#define SPQ(T) priority_queue<T,vector<T>,greater<T>>
#define dame(a) {out(a);return 0;}
#define decimal cout<<fixed<<setprecision(15);
typedef long long ll;
typedef pair<ll,ll> P;
typedef tuple<ll,ll,ll> PP;
typedef tuple<ll,ll,ll,ll> PPP;
typedef multiset<ll> S;
using vi=vector<ll>;
using vvi=vector<vi>;
using vvvi=vector<vvi>;
using vp=vector<P>;
using vvp=vector<vp>;
using vb=vector<bool>;
using vvb=vector<vb>;
const ll inf=1001001001001001;
const int INF=1001001001;
const int mod=1000000007;
const double eps=1e-10;
template<class T> bool chmin(T&a,T b){if(a>b){a=b;return true;}return false;}
template<class T> bool chmax(T&a,T b){if(a<b){a=b;return true;}return false;}
template<class T> void out(T a){if((ll)(a)==inf)cout<<"inf"<<'\n';else if((ll)(a)==-inf)cout<<"-inf"<<'\n';else cout<<a<<'\n';}
template<class T> void outp(T a){cout<<'('<<a.fi<<','<<a.se<<')'<<'\n';}
template<class T> void outvp(T v){rep(i,v.size())cout<<'('<<v[i].fi<<','<<v[i].se<<')';cout<<'\n';}
template<class T> void outvvp(T v){rep(i,v.size())outvp(v[i]);}
template<class T> void outv(T v){rep(i,v.size()){if(i)cout<<' ';if((ll)(v[i])==inf)cout<<"inf";else if((ll)(v[i])==-inf)cout<<"-inf";else cout<<(ll)(v[i]);}cout<<'\n';}
template<class T> void outvv(T v){rep(i,v.size())outv(v[i]);}
template<class T> bool isin(T x,T l,T r){return (l)<=(x)&&(x)<=(r);}
template<class T> void yesno(T b){if(b)out("yes");else out("no");}
template<class T> void YesNo(T b){if(b)out("Yes");else out("No");}
template<class T> void YESNO(T b){if(b)out("YES");else out("NO");}
template<class T> void noyes(T b){if(b)out("no");else out("yes");}
template<class T> void NoYes(T b){if(b)out("No");else out("Yes");}
template<class T> void NOYES(T b){if(b)out("NO");else out("YES");}
ll gcd(ll a,ll b){if(b==0)return a;return gcd(b,a%b);}
ll modpow(ll a,ll b){a%=mod;if(b==0)return 1;if(b&1)return a*modpow(a,b-1)%mod;ll k=modpow(a,b/2);return k*k%mod;}
vvi wf(ll n,vvp g){
    vvi dis(n,vi(n,inf));
    rep(i,n)dis[i][i]=0;
    rep(i,n)for(auto x:g[i])chmin(dis[i][x.fi],x.se);
    rep(k,n)rep(i,n)rep(j,n)chmin(dis[i][j],dis[i][k]+dis[k][j]);
    return dis;
}
int main(){
    ll n,m,l;cin>>n>>m>>l;
    vvp g(n);
    rep(i,m){
        ll a,b,c;cin>>a>>b>>c;
        a--;b--;
        g[a].eb(b,c);
        g[b].eb(a,c);
    }
    vvi dis=wf(n,g);
    vvp g2(n);
    rep(i,n)rep(j,n)if(dis[i][j]<=l)g2[i].eb(j,1);
    vvi dis2=wf(n,g2);
    ll q;cin>>q;
    rep(tt,q){
        ll s,t;cin>>s>>t;s--;t--;
        if(dis2[s][t]==inf)out(-1);
        else out(dis2[s][t]-1);
    }
}

Measured memory_bytes: 8064
X,Y = map(int,input().split())
if X*4 < Y or X*2 > Y:
  print("No")
else:
  if Y == X*2:
    print("Yes")
  else:
    if (Y-X*2)%2==0:
      print('Yes')
    elif (Y-X*2)%2!=0:
      print('No')

Measured memory_bytes: 9204
//submitted by HimJ
#include<bits/stdc++.h>
#define ll long long
#define mod 1000000007
#define pb push_back
#define fi first
#define se second
#define fr(i,s,e) for(i=s;i<e;i++)
#define ms(arr,val) memset(arr,val,sizeof(arr))
using namespace std;
const int mxn=1e5+1;
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
  ll t=1;
  //cin>>t;
    while(t--){
            int n,i;
    cin>>n;
    ll arr[n],ans=0,himj=0,tarr[n];
    fr(i,0,n)
    {
        cin>>arr[i];
        arr[i]-=(i+1);
        tarr[i]=arr[i];
    }
    sort(tarr,tarr+n);
    if(n%2)
    {
        himj=tarr[n/2];
    }
    else
        himj=(tarr[n/2-1]+tarr[n/2])/2;
    fr(i,0,n)
    {
        ans+=abs(arr[i]-himj);
    }
    cout<<ans;
    }
  return 0;
  }



Measured memory_bytes: 3328
#include<bits/stdc++.h>
using namespace std;
using lint = long long int;
using pint = pair<int, int>;
using plint = pair<lint, lint>;
struct fast_ios { fast_ios(){ cin.tie(0); ios::sync_with_stdio(false); cout << fixed << setprecision(20); }; } fast_ios_;
#define ALL(x) (x).begin(), (x).end()
#define SZ(x) ((lint)(x).size())
#define POW2(n) (1LL << (n))
#define FOR(i, begin, end) for(int i=(begin),i##_end_=(end);i<i##_end_;i++)
#define IFOR(i, begin, end) for(int i=(end)-1,i##_begin_=(begin);i>=i##_begin_;i--)
#define REP(i, n) FOR(i,0,n)
#define IREP(i, n) IFOR(i,0,n)
const lint mod=1e9+7;

int main()
{
  char alph;
  cin >> alph;

  int x = (int)alph + 1;
  cout << (char)x << "\n";
  return 0;
}


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

typedef long long ll;
typedef pair<int,int> pi;
typedef vector <ll> vi;
typedef vector <pi> vpi;
#define f first
#define s second
#define FOR(i,s,e) for(int i=s;i<=int(e);++i)
#define DEC(i,s,e) for(int i=s;i>=int(e);--i)
#define pb push_back
#define all(x) (x).begin(), (x).end()
#define lbd(x, y) lower_bound(all(x), y)
#define ubd(x, y) upper_bound(all(x), y)
#define aFOR(i,x) for (auto i: x)
#define mem(x,i) memset(x,i,sizeof x)
#define fast ios_base::sync_with_stdio(false),cin.tie(0)
typedef pair<pi,int> pii;

int H,W,K,x3,x2,y3,y2;

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

inline int readInt() {
    int x = 0;
    char ch = getchar_unlocked();
    while (ch < '0' || ch > '9') ch = getchar_unlocked();
    while (ch >= '0' && ch <= '9'){
		x = (x << 3) + (x << 1) + ch - '0';
		ch = getchar_unlocked();
	}
    return x;
}

inline char readChar() {
    int x = 0;
    char ch = getchar_unlocked();
    while (ch != '.' && ch != '@') ch = getchar_unlocked();
    return ch;
}
int main(){
	fast;
	
	H = readInt(); W = readInt(); K = readInt(); x3 = readInt(); y3 = readInt(); x2 = readInt(); y2 = readInt();
	
	char grid[H+1][W+1];
	int dist[H+1][W+1];
	mem(dist,-1);
	FOR(i,1,H) FOR(j,1,W) grid[i][j] = readChar();

	queue <pi> q;
	
	q.push(pi(x3,y3));
	dist[x3][y3] = 0;
	while (!q.empty()){
		pi cur = q.front(); q.pop();
		
		//if (dist[cur.f][cur.s] != -1) continue;

		FOR(i,0,3){
			int nx = cur.f, ny = cur.s;
			FOR(j,1,K){
				nx += dx[i]; ny += dy[i];

				if (nx < 1 || ny < 1 || nx > H || ny > W) break;
				if ((dist[nx][ny] != -1 && dist[nx][ny] < dist[cur.f][cur.s] + 1) || grid[nx][ny] == '@') break;
				
				
				if (dist[nx][ny] != dist[cur.f][cur.s] + 1) q.push(pi(nx,ny));
				dist[nx][ny] = dist[cur.f][cur.s] + 1;
			}
		}
	}
	cout<<dist[x2][y2];
}



Measured memory_bytes: 12444
#include <iostream>
#include <string>
#include <vector>
#include <cmath>
#include <queue>
#include <map>
#include <set>
#include<algorithm>
#include<sstream>
#include<iomanip>


using namespace std;

typedef long long ll;

const ll MOD_CONST = 1000000007;

int main() {

	int n;
	cin >> n;
	int sum = 0;
	int min = 100;
	for (int i = 0; i < n; i++) {
		int s;
		cin >> s;
		sum += s;
		if (s < min && s%10 !=0) {
			min = s;
		}
	}

	int ans;
	if (sum % 10 == 0) {
		if (min % 10 != 0) {
			ans = sum - min;
		}
		else {
			ans = 0;
		}
	}
	else {
		ans = sum;
	}

	cout << ans << endl;
}


Measured memory_bytes: 256
INT_MAX=10**11+7
MOD=10**9+7
def INPUT():return list(int(i) for i in input().split())
def LIST_1D_ARRAY(n):return [0 for _ in range(n)]
def LIST_2D_ARRAY(m,n):return [[0 for _ in range(n)]for _ in range(m)]
#=======================================================================
s,w=INPUT()
if w>=s:
    print("unsafe")
else:print("safe")


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


int main()
{
    string s;
    cin>>s;
    int k;
    cin>>k;
    int index =0;
    int ans =0;
    for(int i=0;i<s.length();i++)
    {
        if( s[i]!='1')
        {
            ans = s[i] -'0';
            break;
        }
        else index++;
    }
    if( index>= k)
        cout<<1;
    else cout<<ans;
}

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

using namespace std;

const int MAXN = 1e5 + 7;

int n;
bool a[MAXN];
void read() {
    string s;
    cin >> s;
    n = s.size();
    for (int i = 1; i <= n; ++i) {
        a[i] = (s[i - 1] == '1');
    }
}

vector <pair <int, int> > e;

int curr = 0;

void solve() {
    if (a[n]) {
        cout << "-1\n";
        exit(0);
    }

    if (!a[1]) {
        cout << "-1\n";
        exit(0);
    }

    for (int i = 1; i < n; ++i) {
        if (a[i] ^ a[n - i]) {
            cout << "-1\n";
            exit(0);
        }
    }

    int last = 1;
    for (int i = 2; i * 2 <= n; ++i) {
        if (a[i]) {
            int add = i - last;
            //cout << "kek " << i << ' ' << add << '\n';
            e.push_back({curr, curr + add});
            for (int t = 0; t < add - 1; ++t) {
                e.push_back({curr + t + 1, curr + add});
            }
            curr += add;
            last = i;
        }
    }
    
    e.push_back({curr, curr + 1});
    ++curr;
    for (int i = 0; i < n - 1 - curr; ++i) {
        e.push_back({curr, curr + i + 1});
    }
}

void print() {
    for (auto ne : e) cout << ne.first + 1 << ' ' << ne.second + 1 << '\n';
}

signed main() {
    //freopen("input.txt", "r", stdin);

    ios_base::sync_with_stdio(0);
    cin.tie(0);

    read();
    solve();
    print();

    return 0;
}

Measured memory_bytes: 2404
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define rep(i, c) for (int i = 0; i < (int)c; i++)
#define all(v) v.begin(), v.end()
const int inf = 1000000000; //10^9
using ll = long long;
using P = pair<int, int>;
//加算代入演算子は+=！！！！！

int main()
{
    string a, b, c, next = "a";
    int alen, blen, clen, acount = 0, bcount = 0, ccount = 0;
    int check = 1;
    cin >> a >> b >> c;
    alen = a.size();
    blen = b.size();
    clen = c.size();
    while (check)
    {
        if (next == "a")
        {
            if (acount >= alen)
            {
                cout << "A" << endl;
                break;
            }
            next = a.at(acount++);
        }
        else if (next == "b")
        {
            if (bcount >= blen)
            {
                cout << "B" << endl;
                break;
            }
            next = b.at(bcount++);
        }
        else
        {
            if (ccount >= clen)
            {
                cout << "C" << endl;
                break;
            }
            next = c.at(ccount++);
        }
    }
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
#pragma comment (linker, "/STACK:526000000")
#define  _CRT_SECURE_NO_WARNINGS

using namespace std;
typedef string::const_iterator State;
#define eps 1e-11L
#define MAX_MOD 1000000007LL
#define GYAKU 500000004LL

#define MOD 998244353LL
#define seg_size 262144*2LL
#define pb push_back
#define mp make_pair
typedef long long ll;
#define REP(a,b) for(long long (a) = 0;(a) < (b);++(a))
#define ALL(x) (x).begin(),(x).end()

void init() {
	iostream::sync_with_stdio(false);
	cout << fixed << setprecision(20);
}

string next(string geko) {
	ll ans = 0;
	for (int q = 0; q < geko.size()-1; ++q) {
		string a, b;
		REP(j, geko.size()) {
			if (j <= q) {
				a.push_back(geko[j]);
			}
			else {
				b.push_back(geko[j]);
			}
		}
		ans = max(ans, (long long)stoll(a) * (long long)stoll(b));
	}
	return to_string(ans);
}

void solve(){
	int query;
	cin >> query;
	REP(i, query) {
		string s;
		cin >> s;
		set<string> inputs;
		int cnt = 0;
		while (true) {
			if (s.length() == 1) break;
			string go = next(s);
			if (go.length() > 10) {
				cnt = -1;
				break;
			}
			cnt++;
			s = go;
		}
		cout << cnt << endl;
	}
}

#undef int
int main() {
	init();
	solve();
}


Measured memory_bytes: 3292
def is_ok(x):
    result = 0
    for i in range(N):
        t = x // F[i]
        if t < A[i]:
            result += A[i] - t
    return result <= K


N, K = map(int, input().split())
A = list(map(int, input().split()))
F = list(map(int, input().split()))

A.sort()
F.sort(reverse=True)

l = -1
r = A[-1] * F[0] + 1

while r - l > 1:
    m = l + (r - l) // 2
    if is_ok(m):
        r = m
    else:
        l = m
print(r)


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

using namespace std;

int main() {
    int N;
    cin >> N;
    for (size_t i = 0; i < 10000; i++)
    {
        if((N-4*i)%7 == 0) {
            
        cout << "Yes" << endl;
        break;
        } 
        if(N<4*i+4){
            cout << "No" << endl;
            break;
        }
    }
    

    return 0;
}

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

char s;
int a, b;

int main()
{
	cin >> s;
	if (s == '1')
	{
		cout << "Hello World" << endl;
		return 0;
	}
	else
	{
		cin >> a >> b;
		cout << a + b << endl;
		return 0;
	}
}

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

template<typename T>
void out(T x) { cout << x << endl; exit(0); }
#define watch(x) cout << (#x) << " is " << (x) << endl





using ll = long long;


const int maxn = 1e6 + 5;


ll n;

int main() {
    ios_base::sync_with_stdio(false); cin.tie(0);  cout.tie(0);
    
    cin>>n;
    ll res = 0;
    for (ll a=1; a<n; a++) {
	ll cnt = n/a;
	if (n%a==0) cnt--;
	res += cnt;
    }

    out(res);
    
    
    return 0;
}


Measured memory_bytes: 3628
def paint(s, i, j):
    check = 0
    for jj in range(-1,2,2):
        if s[i][j+jj] == "#":
            check += 1
    for ii in range(-1,2,2):
        if s[i+ii][j] == "#":
            check += 1

    return check

h, w = map(int, input().split())
s = ['.'*(w+2)]
for i in range(h):
    s.append("."+input()+".")
s.append('.'*(w+2))

for i in range(1,h+1):
    for j in range(1,w+1):
        if s[i][j] == "#":
            if paint(s, i, j) == 0:
                print("No")
                exit()
print("Yes")

Measured memory_bytes: 3064
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)*}
    };
}

macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

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

macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

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

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

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

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

fn main() {
    input!
    {
        a: usize,
    }

    let ret = a + a.pow(2) + a.pow(3);
    println!("{}", ret);
}


Measured memory_bytes: 2092
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
const int MAXN=500005;
int read(){int x;scanf("%d",&x);return x;}
struct node{
	int ch[2];
	int val,id;
}t[MAXN<<2];
int tot,N,K,num;
int a[MAXN],b[MAXN];
void PU(int u){
	t[u].val=max(t[t[u].ch[0]].val,t[t[u].ch[1]].val);
	t[u].id=t[t[u].ch[0]].val==t[u].val?t[t[u].ch[0]].id:t[t[u].ch[1]].id;
}
void insert(int u,int tl,int tr,int p,int val){
	if(tl==tr){t[u].val=val,t[u].id=p;return;}
	int mid=(tl+tr)>>1;
	if(p<=mid){
		if(!t[u].ch[0]) t[u].ch[0]=++tot;
		insert(t[u].ch[0],tl,mid,p,val);
	}
	else{
		if(!t[u].ch[1]) t[u].ch[1]=++tot;
		insert(t[u].ch[1],mid+1,tr,p,val);
	}
	PU(u);
}
pair<int,int>Query(int u,int tl,int tr,int l,int r){
//	cout<<u<<" "<<tl<<" "<<tr<<" "<<t[u].val<<endl;
	if(l>r) return make_pair(0,0);
	if(!u) return make_pair(0,0);
	if(tl>=l&&tr<=r) return make_pair(t[u].val,t[u].id);
	if(tr<l||tl>r) return make_pair(0,0);
	int mid=(tl+tr)>>1;
	pair<int,int>x,y;
	x=Query(t[u].ch[0],tl,mid,l,r),y=Query(t[u].ch[1],mid+1,tr,l,r);
	return x.first>y.first?x:y;
}
int head[MAXN],du[MAXN];
priority_queue<int>Q;  
struct line{int nxt,to;}e[MAXN<<1];
int Ans[MAXN],p[MAXN],cnt;
void add(int u,int v){e[num]=(line){head[u],v};head[u]=num,num++,du[v]++;}
int main(){
	memset(head,-1,sizeof(head));
	N=read(),K=read(),tot=1;
	for(int i=1;i<=N;i++) a[i]=read(),b[a[i]]=i;
	for(int i=1;i<=N;i++){
		insert(1,1,N,b[i],i);
		int x=Query(1,1,N,b[i]-K+1,b[i]-1).second,y=Query(1,1,N,b[i]+1,b[i]+K-1).second;
	//	cout<<x<<" "<<y<<" "<<b[i]<<endl;
		if(x) add(b[i],x);if(y) add(b[i],y);
	}
	for(int i=1;i<=N;i++) if(!du[i]) Q.push(i);
	cnt=N;
	while(!Q.empty()){
		int x=Q.top();Q.pop();
		Ans[cnt--]=x;
		for(int i=head[x];~i;i=e[i].nxt){
			du[e[i].to]--;
			if(!du[e[i].to]) Q.push(e[i].to);	
		}
	}
	for(int i=1;i<=N;i++) p[Ans[i]]=i;
	for(int i=1;i<=N;i++) printf("%d\n",p[i]);
	return 0;
}


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

long long int n,n1,n2,n3,a,sm,c,ar[300005];
int main()
{
    cin>>n;
    n1=3*n;
    for(a=0; a<n1; a++)
    {
        cin>>ar[a];
    }
    sort(ar+0,ar+0+n1);
    n2=2*n;
    n3=n/2;
    sm=0;

    for(a=n; a<n1; a=a+2)
    {
        sm=sm+ar[a];


    }


    cout<<sm<<endl;
    return 0;
}


Measured memory_bytes: 2560
#include <bits/stdc++.h>
#define all(x) (x).begin(), (x).end()
using namespace std;
typedef long long ll;
const int MOD = 1e9 + 7;

int main() {
  int n;
  cin >> n;
  vector<pair<int, int>> town(n);
  for (int i = 0; i < n; i++) {
    cin >> town[i].first >> town[i].second;
  }
  vector<int> v(n);
  iota(v.begin(), v.end(), 0);
  int fact = 0;
  double ans = 0;
  do {
    fact++;
    double cnt = 0;
    for (int i = 0; i < n - 1; i++) {
      cnt += sqrt(pow((town[v[i]].first - town[v[i + 1]].first), 2) +
                  pow((town[v[i]].second - town[v[i + 1]].second), 2));
    }
    ans += cnt;
  } while (next_permutation(v.begin(), v.end()));
  cout << fixed << setprecision(10) << ans / fact << endl;
  return 0;
}

Measured memory_bytes: 256
def main3():
        K = int(input())

        record = []

        def rec(d, val, record):
                # store
                record.append(val)
                # finish if val>10^10
                if d==10:
                        return
                # 末尾に適切な数をくっつけて桁をあげる
                for i in range(-1,2):
                        add = (val%10)+i
                        if add>=0 and add<=9:
                                rec(d+1,val*10+add,record)

        for v in range(1,10):
                rec(1, v, record)

        record.sort()

        print("{}".format(record[K-1]))



if __name__=="__main__":
        main3()

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

using namespace std;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define MIN(a,b) ((a)>(b)? (b): (a))
#define MAX(a,b) ((a)<(b)? (b): (a))

const long long INF = 1LL << 60;

typedef unsigned long long ll;

const long long MOD = 1000000000 + 7;

template<class T> inline bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template<class T> inline bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}

int main(){
    int h,w;
    cin >> h >> w;
    string line;
    vector<vector<char>> rslt;
    rep(i,h){
        cin >> line;
        vector<char> input;
        rep(j,w){
            input.push_back(line[j]);
        }
        rslt.push_back(input);
        rslt.push_back(input);
    }
    
    rep(i,2*h){
        rep(j,w){
            cout << rslt[i][j];
        }
        cout << endl;
    }
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
#define MAX_N 100000
#define MAX_M 100000
#define vec vector<int>
#define vecll vector<ll>
#define vecllvec vector<vector<ll>>
#define vecb vector<bool>
#define vecbvecb vector<vector<bool>>
#define vecst vector<string>
#define vecch vector<char>
#define vecf vector<float>
#define vecvec vector<vector<int>>
#define vecHvec vector<vector<char>>
#define all(x) (x).begin(),(x).end()
const int INF = 1e9;
#define PI 3.141592653589793
// cout << setprecision(15) << std::fixed;

int main() {
  int n,ans;
  cin>>n;
  cout<<n*n<<endl;
}


Measured memory_bytes: 764
#include <algorithm>
#include <iostream>
#include <cstdint>
#include <vector>

using namespace std;

int main() {
	int n;
	cin >> n;
	vector<int64_t> a( n ), b( n );
	for ( int i = 0; i < n; i++ ) cin >> a[i];
	int c = 0;
	for ( int i = 0; i < n; i++ ) {
		b[i] = a[i] < 0 ? -a[i] : a[i];
		if ( a[i] < 0 ) c++;
	}
	sort( b.begin(), b.end() );
	if ( c % 2 ) b[0] = -b[0];
	int64_t r = 0;
	for ( int i = 0; i < n; i++ ) r += b[i];
	cout << r << endl;
	return 0;
}


Measured memory_bytes: 1792
n = int(input())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
c = 0
for i in range(len(b)):
    c_i = 0
    c_i = min(a[i], b[i])
    c += c_i
    b[i] -= c_i
    c_i_1 = 0
    c_i_1 = min(a[i+1], b[i])
    c += c_i_1
    a[i+1] -= c_i_1
print(c)

Measured memory_bytes: 18624
ans = 0
a, b, c, x, y = map(int, input().split())
if a+b <= 2*c:
    ans += a * x
    ans += b * y
else:
    if y > x:
        x, y = y, x
        a, b = b, a

    ans += c * y * 2
    x -= y
    y = 0
    if a * x > 2 * c * x:
        ans += 2 * c * x
    else:
        ans += a * x
print(ans)


Measured memory_bytes: 3060
const input=require('fs').readFileSync('/dev/stdin','utf8').split(/[\s]/);const tn=():number=>{const a=input[0];input.shift();return Number(a)};const tnn=(n:number):number[]=>{const a=[];for(let i=0;i<n;i++){a.push(tn())}return a};const ts=():string=>{const a=input[0];input.shift();return String(a)};const tss=(n:number):string[]=>{const a=[];for(let i=0;i<n;i++){a.push(ts())}return a};const tc=():string=>{let a=input[0].split('');const b=a[0];a.shift();if(a.length>0){input[0]=a.join('')}else{input.shift()}return String(b)};const tcc=(n:number):string[]=>{const a=[];for(let i=0;i<n;i++){a.push(tc())}return a};const to=(...arg)=>{console.log(...arg)};const abs=(a)=>{return Math.abs(a)};const min=(...a)=>{return Math.min(...a)};const max=(...a)=>{return Math.max(...a)};const floor=(a)=>{return Math.floor(a)};const asc=(ar:number[])=>{return ar.sort((a,b)=>{return a-b})};const desc=(ar:number[])=>{return ar.sort((a,b)=>{return b-a})};const sw=(a,arr:any[],op:'=='|'>='|'>'|'<='|'<'='==')=>{for(let i=0;i<arr.length-1;i+=2){if(eval(a+op+arr[i])){return arr[i+1];}}return arr[arr.length-1]};const near=(n:number,arr:number[]):number=>{let ne=arr[0],ni=0;for(let i=1;i<arr.length;i++){if(Math.abs(n-ne)>Math.abs(n-arr[i])){ne=arr[i];ni=i}}return ni};const objvs =(a)=>{const b=[];for(const v in a){b.push(a[v])}return b};
const main=()=>{
  let [h,w]=[tn(),tn()]
  let g=tss(h)
  
  for(let i=h-1;0<=i;i--){
    let c=true
    for(let j=w-1;0<=j;j--){
      if(g[i][j]!='.')c=false
    }
    if(c){
      g.splice(i,1)
      h--
    }
  }
  for(let j=w-1;0<=j;j--){
    let c=true
    for(let i=h-1;0<=i;i--){
      if(g[i][j]!='.')c=false
    }
    if(c){
      for(let i=h-1;0<=i;i--){
        let y = g[i].split('')
        y.splice(j,1)
        g[i]=y.join('') 
      }
      w--
    }
  }
  for(let i=0;i<h;i++){
    to(g[i])
  }
}
main()


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

ll gcd(ll a,ll b){
  if(b == 0) return a;
  return gcd(b, a % b);
}
const ll P =  1000000007;
ll factorial(ll n){
   ll ans = 1;
   for(int i = n;i>=1;i--){
     ans *= i;
     ans %= P;
   }
   return ans;
}
using Graph = vector<vector<int>>;

ll kzyou(ll a,ll k){//aのk乗を返す
    ll zyou = 1;
    for(ll i = 1;i<=k;i++){
        zyou *= a;
    }
    return zyou;
}

int main(){
  string S,T;
  cin >> S >> T;
  int A,B;
  cin >> A >> B;
  string U;
  cin >> U;
  if(U == S) cout << A-1 << " " << B << endl;
  else cout << A << " " << B-1 << endl;
 }


Measured memory_bytes: 256
#include <stdio.h>
int main (void){
    int sx,sy,tx,ty;
    scanf("%d %d %d %d",&sx,&sy,&tx,&ty);
    int dif_x=tx-sx;
    int dif_y=ty-sy;
    int loop1;
    //1周目前半
    for(loop1=0;loop1<dif_y;loop1++){
        printf("U");
    }
    for(loop1=0;loop1<dif_x;loop1++){
        printf("R");
    }
    //1周目後半
    for(loop1=0;loop1<dif_y;loop1++){
        printf("D");
    }
    for(loop1=0;loop1<dif_x;loop1++){
        printf("L");
    }
    //2周目前半
    printf("L");
    for(loop1=0;loop1<dif_y+1;loop1++){
        printf("U");
    }
    for(loop1=0;loop1<dif_x+1;loop1++){
        printf("R");
    }
    printf("D");
    //2周目後半
    printf("R");
    for(loop1=0;loop1<dif_y+1;loop1++){
        printf("D");
    }
    for(loop1=0;loop1<dif_x+1;loop1++){
        printf("L");
    }
    printf("U\n");
    return 0;
    
}

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


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

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

using namespace std;
using ll = long long;
// #define int ll
using PII = pair<ll, ll>;

#define FOR(i, a, n) for (ll i = (ll)a; i < (ll)n; ++i)
#define REP(i, n) FOR(i, 0, n)
#define ALL(x) x.begin(), x.end()

template<typename T> T &chmin(T &a, const T &b) { return a = min(a, b); }
template<typename T> T &chmax(T &a, const T &b) { return a = max(a, b); }
template<typename T> bool IN(T a, T b, T x) { return a<=x&&x<b; }
template<typename T> T ceil(T a, T b) { return a/b + !!(a%b); }

template<typename T> vector<T> make_v(size_t a) { return vector<T>(a); }
template<typename T,typename... Ts>
auto make_v(size_t a,Ts... ts) {
    return vector<decltype(make_v<T>(ts...))>(a,make_v<T>(ts...));
}
template<typename T,typename V> typename enable_if<is_class<T>::value==0>::type
fill_v(T &t, const V &v) { t=v; }
template<typename T,typename V> typename enable_if<is_class<T>::value!=0>::type
fill_v(T &t, const V &v ) { for(auto &e:t) fill_v(e,v); }

template<class S,class T>
ostream &operator <<(ostream& out,const pair<S,T>& a) {
    out<<'('<<a.first<<','<<a.second<<')'; return out;
}
template<class T>
ostream &operator <<(ostream& out,const vector<T>& a){
    out<<'[';
    for(const T &i: a) out<<i<<',';
    out<<']';
    return out;
}
template<class T>
ostream &operator <<(ostream& out, const set<T>& a) {
    out<<'{';
    for(const T &i: a) out<<i<<',';
    out<<'}';
    return out;
}
template<class T, class S>
ostream &operator <<(ostream& out, const map<T,S>& a) {
    out<<'{';
    for(auto &i: a) out<<i<<',';
    out<<'}';
    return out;
}

int dx[] = {0, 1, 0, -1}, dy[] = {1, 0, -1, 0}; // DRUL
const int INF = 1<<30;
const ll LLINF = 1LL<<60;
const ll MOD = 1000000007;

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

    ll r, g, b, n;
    cin >> r >> g >> b >> n;

    ll ret = 0;
    REP(i, n+1) REP(j, n+1) {
        ll k = n - i*r - j*g;
        if(k<0 || k%b) continue;
        // cout << i << " " << j << endl;
        ret++;
    }
    cout << ret << endl;

    return 0;
}


Measured memory_bytes: 256
// Daniel Grzegorzewski
// while (clock()<=69*CLOCKS_PER_SEC)
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
// #pragma GCC optimize("Ofast")
// #pragma GCC target("avx,avx2,fma")

#define MP make_pair
#define PB push_back
#define ST first
#define ND second
#define int long long

using namespace __gnu_pbds;
using namespace std;

template <typename T>
using ordered_set =
    tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

//X.find_by_order(k); - zwraca iterator na k-ty element (numeracja od zerowego)
//X.order_of_key(k); - zwraca liczbę elementów ostro mniejszych niż k

typedef pair<int, int> PII;
typedef vector<int> VI;
typedef vector<PII> VII;
typedef long long LL;

void init_ios() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
}

int n, res;

signed main() {
  init_ios();
  cin >> n;
  for (int i = 2; i*i <= n; ++i)
    if (n%i == 0) {
      int cnt = 0;
      while (n%i == 0) {
        ++cnt;
        n /= i;
      }
      int ile = 0;
      while (cnt >= ile+1) {
        ++ile;
        cnt -= ile;
      }
      res += ile;
    }
  if (n > 1)
    ++res;
  cout<<res<<"\n";
}

Measured memory_bytes: 3652
import os
import sys
from atexit import register
from io import BytesIO
sys.stdin = BytesIO(os.read(0, os.fstat(0).st_size))
sys.stdout = BytesIO()
register(lambda: os.write(1, sys.stdout.getvalue()))
input = lambda: sys.stdin.readline().rstrip('\r\n')
raw_input = lambda: sys.stdin.readline().rstrip('\r\n')

n,k = (int(x) for x in input().split())
seq = sorted((int(x) for x in input().split()))
print(sum(seq[:k]))

Measured memory_bytes: 85132
package main

import "fmt"

func main() {
	var S string

	fmt.Scan(&S)

	switch S {
	case "SUN":
		fmt.Println(7)
	case "MON":
		fmt.Println(6)
	case "TUE":
		fmt.Println(5)
	case "WED":
		fmt.Println(4)
	case "THU":
		fmt.Println(3)
	case "FRI":
		fmt.Println(2)
	case "SAT":
		fmt.Println(1)
	}
}


Measured memory_bytes: 512
#include<stdio.h>
int main()
{
int n,i,x=0,t=0;
char st[100];
scanf("%d",&n);
scanf("%s",st);
for(i=0;i<n;i++)
{
if(st[i]=='I')
x++;
else
if(st[i]=='D')
x--;
if(x>t)
t=x;
}
printf("%d",t);
return 0;
}

Measured memory_bytes: 128
#include<iostream>
#include<cstdio>
#include<string>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<ciso646>
#include<random>
#include<map>
#include<set>
#include<complex>
using namespace std;
typedef long long ll;
const ll MOD = 1000000007;
const ll INF = (ll)1000000007 * 1000000007;
const double EPS = 1e-9;
typedef pair<int, int> P;
typedef unsigned int ui;
#define stop char nyaa;cin>>nyaa;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
typedef long double ld;
typedef complex<ld> Point;
const ld eps = 1e-8;
const ld pi = acos(-1.0);
int main() {
	int n; cin >> n; string s; cin >> s;
	int le = 0; int ri = n-1;
	while (le < n&&s[le] == '<')le++;
	while (ri >= 0 && s[ri] == '>')ri--;
	cout << n - min(n-1-ri, le) << endl;
	return 0;
}


Measured memory_bytes: 3348
# coding: utf-8
# Your code here!

A = int(input())
B = int(input())
C = int(input())
X = int(input())
count = 0
for i in range(A+1):
    for j in range(B+1):
        for k in range(C+1):
            total = 500*i + 100*j + 50*k
            if total == X:
                count += 1
print(count)

Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std;
int main(){
  int a,b,c,d,e;
  cin>>a>>b>>c>>d>>e;
  int time;
  int A,B,C,D,E;
  A=10-a%10;
  B=10-b%10;
  C=10-c%10;
  D=10-d%10;
  E=10-e%10;
  if(A==10){
    A=0;
  }
  else{
  }
  if(B==10){
    B=0;
  }
  else{
  }
  if(C==10){
    C=0;
  }
  else{
  }
  if(D==10){
    D=0;
  }
  else{
  }
  if(E==10){
    E=0;
  }
  else{
  }
  int F,G,H,I;
  F=max(A,B);
  G=max(F,C);
  H=max(G,D);
  I=max(H,E);
  time=a+b+c+d+e;
  if(I==A){
    cout<<B+C+D+E+time<<endl;
  }
  else if(I==B){
    cout<<A+C+D+E+time<<endl;
  }
  else if(I==C){
    cout<<A+B+D+E+time<<endl;
  }
  else if(I==D){
    cout<<A+B+E+C+time<<endl;
  }
  else{
    cout<<A+B+D+C+time<<endl;
  }
}

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

using namespace std;


int main() {
    int a[3];
    
    cin >> a[0] >> a[1] >> a[2];
    
    sort(a,a+3);
    
    if (a[0]==5 && a[1]==5 && a[2]==7){
        cout << "YES" << endl;
    }else{
        cout << "NO" << endl;
    }
	
	return 0;
}


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

#ifdef LOCAL
#define debug(var) cerr << (#var) << " = " << (var) << endl;
#else
#define debug(var)
#endif

void init() {
    ios_base::sync_with_stdio(0);
    cin.tie(0); cout.tie(0);
}

void solve() {
    int n, m, x; scanf("%d%d%d", &n, &m, &x);
    int c1 = 0, c2 = 0;
    for (int i = 0; i < m; ++i) {
        int a; scanf("%d", &a);
        if (a < x) ++c1;
        else ++c2;
    }
    printf("%d", min(c1, c2));
}

int main() {
    init();
    int t = 1; //scanf("%d", &t);
    while (t--) {
        solve();
    }
    return 0;
}

Measured memory_bytes: 256
var input = require("fs").readFileSync("/dev/stdin", "utf8").trim().split("\n");
var obj = {
  "list" : input,
  "index" : 0,
  "max" : input.length,
  "next" : function(){
    if(!this.hasNext()){throw "NoSuchElementException:次に要素は無いよ";}
    var returnObj = this.list[this.index];
    this.index++;
    return returnObj;
  },
  "hasNext" : function(){return (this.index < this.max);}
}
Main();
function next(){return obj.next();}
function nextInt(){return myconv(next(),1);}
function nextStrArray(){return myconv(next(),2);}//半角スペース分割
function nextIntArray(){return myconv(next(),4);}//半角スペース + 数値化
function nextCharArray(){return myconv(next(),6);}//1文字分割
function hasNext(){return obj.hasNext();}
function myout(t){console.log(t);}//標準出力
function myerr(t){console.error(t);}//標準エラー出力
//[no]要素の扱い。数値型
//不明値、異常時:引数そのまま返す　1:数値へ変換
//2:半角SPで分割 4:半角SPで分割し、数値配列へ
//6:1文字で分割  7:1文字で分割し、数値配列へ
//8:半角SPで結合 9:改行で結合 0:文字なしで結合
function myconv(i,no){try{switch(no){case 1:return parseInt(i);case 2:return i.split(" ");case 4:return i.split(" ").map((a)=>Number(a));case 6:return i.split("");case 7:return i.split("").map((a)=>Number(a));case 8:return i.join(" ");case 9:return i.join("\n");case 0:return i.join("");default:return i;}}catch(e){return i;}}
function Main(){
  var one = nextStrArray();
  var X = one[0];
  var t = one[1];
  myout(Math.max(X - t,0));
}

Measured memory_bytes: 7372