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

using namespace std;
typedef long long  ll;
#define rep(i,s,n)for(ll i = s;i<n;i++)

int digit(ll n) {
	int d = 1;
	while ((n /= 10) > 0)d++;
	return d;
}

int main() {
	ll N; cin >> N;
	ll minv = 1 << 30;
	for (ll i = 1; i * i <= N; i++) {
		if (N % i == 0) {
			ll a = N / i;
			ll F = (digit(a) > digit(i)) ? digit(a) : digit(i);
			minv = (minv > F) ? F : minv;
		}
	}

	cout << minv << endl;
	return 0;
}

Measured memory_bytes: 256
def is_palindrome(string):
    return string == string[::-1]

string = input()

is_string_palindrome = 'No'
left_substring = string[0:len(string)//2]
right_substring = string[(len(string)//2) + 1:]
if is_palindrome(string) and is_palindrome(left_substring) and is_palindrome(right_substring):
    is_string_palindrome = 'Yes'

print(is_string_palindrome)

Measured memory_bytes: 3064
#include<stdio.h>
#include<string.h>
using namespace std;
char ans[5][5010];
void insert(char* c,int n){
    char tmp[6];
    for(int i=0;i<n;i++)tmp[i]=c[i];
    tmp[n]='\0';
    int idx=4;
    for(int i=0;i<5;i++)if(strcmp(tmp,ans[i])==0)return;
    while(idx>=0&&strcmp(tmp,ans[idx])<=0)idx--;
    for(int i=4;i>idx+1;i--){
        strcpy(ans[i],ans[i-1]);
    }
    strcpy(ans[idx+1],tmp);

}
int main(){
    char s[5010];
    char t[5010];
    scanf("%s",s);
    int k;
    scanf("%d",&k);
    for(int i=0;i<5;i++){
        for(int j=0;j<5010;j++)ans[i][j]='z';
        ans[i][5009]='\0';
    }
    int l=strlen(s);
    for(int i=0;i<l;i++){
        for(int j=1;j<6&&i+j<=l;j++){
            insert(s+i,j);
        }
    }
    printf("%s\n",ans[k-1]);
}


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

typedef long long LL;
void solve(long long A, long long B, long long C, long long D) {
  int a = B/C - A/C;
  int b = B/D - A/D;
  int c = B/(C*D) - A/(C*D);
  cout<<a+b-c<<endl;
}
bool IsPrime(int num){
    if (num < 2) return false;
    else if (num == 2) return true;
    else if (num % 2 == 0) return false;
    double sqrtNum = sqrt(num);
    for (int i = 3; i <= sqrtNum; i += 2){
        if (num % i == 0)
        {
            return false;
        }
    }
    return true;
}
LL gcd(LL m, LL n){
    LL temp;
    while(n!=0){
    temp=n;
    n=m%n;
    m=temp;
  }
  return m;
}
LL lcm(LL m,LL n){
  return m*n/gcd(m,n);
}
int main(){
  LL A,B;
  LL C,D;
  cin>>A>>B>>C>>D;
  A--;
  A-=(A/C)+(A/D)-A/lcm(C,D);
  B-=(B/C)+(B/D)-B/lcm(C,D);
  cout<<B-A<<endl;
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<iomanip>
using namespace std;
typedef long long ll;
typedef long  l;
typedef pair<int,int> P;
#define rep(i,n) for(int i=0;i<n;i++)
#define fs first
#define sc second
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define ALL(A) A.begin(),A.end()
const int INF=1000000001;
const double PI=3.141592653589;
const ll LMAX=1000000000000001;
ll gcd(ll a,ll b){if(a<b)swap(a,b);while((a%b)!=0){a=b;b=a%b;}return b;}
int dx[]={-1,0,1,0};
int dy[]={0,1,0,-1};



int main(){
  int a,b,c; cin>>a>>b>>c;
  if(c>=a&&c<=b)
  puts("Yes");
  else
  puts("No");

  return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <math.h>
int main(){
    
  int n,a[100000],i,j,f,count=0;
  scanf("%d",&n);
  for(i=0;i<n;i++){
    scanf("%d",&a[i]);
    if(a[i]<2 && 1000000<a[i]) break;
  }
    
  for(i=0;i<n;i++){
    f=0;
    if(a[i]==2) f=0;

    else if(a[i]%2==0)f=1;

    else{
      for(j=3;j<=sqrt(a[i]);j=j+2){
	if(a[i]%j==0) {
	  f=1;
	  break;
	}
       
      }
    }
    if(f==0)count++;
  }
 
  printf("%d\n",count);
    
  return 0;
}

Measured memory_bytes: 636
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();

        int val = 0;
        int[] V=new int[N];
        int[] C=new int[N];
        for (int i = 0; i < N; i++) {
            V[i]=sc.nextInt();
        }
        for (int i = 0; i < N; i++) {
            C[i]=sc.nextInt();
        }

        for (int i = 0; i < N; i++) {
            int v = V[i]-C[i];
            if(v > 0 ){
                val += v;
            }
        }


        System.out.println(val);
    }

}

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

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

  int a, b, c, d, e, f;
  cin >> a >> b >> c >> d >> e >> f;

  int ansT = 0;
  double ansC = -1;
  int ansS = 0;
  for (int i = 0; i <= 30; i++) {
    for (int j = 0; j <= 30; j++) {
      int water = i * a * 100 + j * b * 100;
      int limSugar = (i * a + j * b) * e;

      for (int x = 0; x * c <= limSugar; x++) {
        for (int y = 0; x * c + y * d <= limSugar; y++) {
          int sugar = x * c + y * d;

          int total = water + sugar;

          if (total > f) break;

          double calc = sugar * 100.0 / (water + sugar);

          if (calc > ansC) {
            ansC = calc;
            ansT = total;
            ansS = sugar;
          }
        }
      }
    }
  }

  cout << ansT << " " << ansS << endl;

  return 0;
}

Measured memory_bytes: 256
z='abcdefghijklmnopqrstuvwxyz'
for _ in[0]*int(input()):
 e=input()
 for i in range(1,26,2):
  for j in range(26):
   a=''
   for c in e:
    a+=z[(z.index(c)*i+j)%26]if c in z else c
   if'that'in a or'this'in a:print(a);break


Measured memory_bytes: 5596
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int maxn = 1e5 + 5;
ll a[maxn], b[maxn];
int main() {
	int n;
	scanf("%d", &n);
	for (int i = 1; i <= n; i++) {
		scanf("%lld", &a[i]);
	}
	long long sum = 0, flag = 1;
	for (int i = 1; i <= n - 1; i++) {
		sum += flag * a[i];
		flag = -flag;
	}
	b[1] = sum + a[n];
	for (int i = 1; i <= n - 1; i++) {
		b[i + 1] = 2 * a[i] - b[i];
	}
	for (int i = 1; i <= n; i++) {
		printf("%lld ", b[i]);
	}
	printf("\n");
	return 0;
}
/*
y1 y2 y3 y4 y5
y1 = x1/2 + x2/2
y2 = x2/2 + x3/2
y3 = x3/2 + x4/2
...
yn-1 = xn-1/2 + xn/2
yn = x1/2 + xn/2
t = x1/2 - xn/2
x1 = yn + t
*/

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

int main(){
  int H, N;
  cin >> H >> N;
  vector<int> dp(H+1,1e9);
  dp[0]=0;
  for(int i=1; i<=N; i++){
    int A, B; cin >> A >> B;
    for(int j=1; j<=H;j++){
      if(j-A<0) dp[j]=min(dp[j], B);
      else dp[j]=min(dp[j], dp[j-A]+B);
    }
  }
  cout << dp[H] << endl;
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int, int> P;
typedef pair<ll, ll> Pll;
using Graph = vector<vector<int>>;
using Graphl = vector<vector<ll>>;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define Rep(i, k, n) for (int i = k; i < (int)(n); i++)
#define RRep(i, k, n) for (int i = k; i > (int)(n); i--)
#define FOR(itr, v) for (auto itr = (v).begin(); itr != (v).end(); ++itr)
#define COUT(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << endl
#define ALL(a)  (a).begin(),(a).end()
#define rALL(a)  (a).rbegin(),(a).rend()
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
template<class T> void PrintVector(const vector<T> &vec) {for (auto val : vec) cout << val << " "; cout << endl;}
const long long INF = 1LL << 60;
const long long minusINF = -(1LL << 40);
const int MOD = 1000000007;
const double PI = acos(-1); //3.14~
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};

int main()
{
    int n, k; cin >> n >> k;
    if (n % k > 0) cout << 1 << endl;
    else cout << 0 << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define int long long
void read (int &x) {
    char ch = getchar(); int f = 0; x = 0;
    while (!isdigit(ch)) { if (ch == '-') f = 1; ch = getchar(); }
    while (isdigit(ch)) x = x * 10 + ch - 48, ch = getchar(); if (f) x = -x;
} const int N = 2e5 + 10, mod = 1e9 + 7;
int n, k;
pair<int, int> p[N];
#define x first
#define y second
int res = 1, _, mna = -1, mnb = -1, mxa = -1, mxb = -1;
int Pow (int x, int y) {
    int tmp = 1;
    while (y) {
        if (y & 1) tmp = tmp * x % mod;
        x = x * x % mod, y >>= 1;
    } return tmp;
}
signed main() {
    read (n), read (k);
    for (int i = 1, x; i <= n; ++i)
        read (x), p[i] = make_pair (labs (x), (x < 0));
    sort (p + 1, p + n + 1);
    for (int i = n; i >= n - k + 1; --i)
        res = res * p[i].x % mod, _ ^= p[i].y;
    if (!_) return printf ("%lld\n", res), 0; // 结果已经为正，直接输出
    //否则调整res，尽量使其为正
    for (int i = n - k + 1; i <= n; ++i) {
        if (p[i].y && mnb == -1) mnb = p[i].x;
        if (!p[i].y && mna == -1) mna = p[i].x;
    }
    for (int i = n - k; i >= 1; --i) {
        if (p[i].y && mxb == -1) mxb = p[i].x;
        if (!p[i].y && mxa == -1) mxa = p[i].x;
    }
    int sa = 0, sb = 0;
    if (mxb >= 0 && mna >= 0) {
        if (mxa >= 0 && mnb >= 0) {
            if (mxa * mna >= mxb * mnb) res = res * Pow (mnb, mod - 2) % mod * mxa % mod;
            else res = res * Pow (mna, mod - 2) % mod * mxb % mod;
        } else  res = res * Pow (mna, mod - 2) % mod * mxb % mod;
    } else {
        if (mxa >= 0 && mnb >= 0) res = res * Pow (mnb, mod - 2) % mod * mxa % mod;
        else {
            res = -1; for (int i = 1; i <= k; ++i) res = res * p[i].x % mod;
            res = (res + mod) % mod;
        }
    }
    return printf ("%lld\n", res), 0;
}


Measured memory_bytes: 6896
Q = int(input())
L = [0]*Q
R = [0]*Q
for i in range(Q):
    L[i], R[i] = map(int, input().split())
    
N = 10**5+1
prime = [1]*N
prime[0] = 0
prime[1] = 0
for i in range(2, N):
    if prime[i] == 1:
        j = 2*i
        while j < N:
            prime[j] = 0
            j += i

S = [0]*N
i = 3
temp = 0
while i < N:
    if i%2 == 1:
        if prime[i] == 1 and prime[(i+1)//2] == 1:
            temp += 1
    S[i] = temp
    i += 1
    
for i in range(Q):
    print(S[R[i]]-S[L[i]-1])

Measured memory_bytes: 13348
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
#define eps 1e-9
#define maxp 220000
#define mod 1000000007
#define pi 3.141592653589793238
#define sin(s) scanf("%lld",&s);
#define sout(s) printf("%lld\n",s);
#define in(s) cin>>s
#define in2(a,b) cin>>a>>b
#define in3(a,b,c) cin>>a>>b>>c
#define vll vector<ll>
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define endl '\n'
#define sp ' '
#define gear_change ios_base::sync_with_stdio(false),cin.tie(0)
#define nfl(i,n) for(i=0;i<n;i++)
#define sfl(i,s,e) for(i=s;i<e;i++)
#define ufl(i,n) for(i=n-1;i>=0;i--)
ll power(ll x,ll y){
    ll ret=1;
    while(y>0){
        if(y&1)
            ret=(ret*x);
        y/=2;
        x=(x*x);
    }
    return ret;
}
vector<ll> divs(ll n){
	vector<ll>ret;
	for(int i=1;i*i<=n;i++){
		if(n%i==0){
			if(i*i==n){
				ret.push_back(i);
			}
			else{
				ret.push_back(i);
				ret.push_back(n/i);
			}
		}
	}
	return ret;
}
void solve(){
	ll r,g,b,k;
	in3(r,g,b);
	in(k);
	ll cnt=0;
	while(g<=r){
		g*=2;
		cnt++;
	}
	while(b<=g){
		b*=2;
		cnt++;
	}
	if(cnt<=k)cout<<"Yes\n";
	else cout<<"No\n";
}	
int main(){
	gear_change;
	ll test=1;
	// in(test);
	while(test--){
		solve();
	}
}	

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

typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<double> vd;
typedef vector<ll> vl;
typedef vector<vi> vvi;
typedef vector<vl> vvl;
typedef pair<int,int> pii;
typedef pair<double, double> pdd;
typedef pair<ll, ll> pll;
typedef vector<pii> vii;
typedef vector<pll> vll;
typedef vector<pdd> vdd;

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define mem(a,b) memset(a, b, sizeof(a) )
#define all(x) (x).begin(),(x).end()
#define INF 1000000000000
#define MOD 1000000007
#define PB push_back
#define MP make_pair
#define F first
#define S second

inline void normal(ll &a) { a %= MOD; (a < 0) && (a += MOD); }
inline ll modMul(ll a, ll b) { a %= MOD, b %= MOD; normal(a), normal(b); return (a*b)%MOD; }
inline ll modAdd(ll a, ll b) { a %= MOD, b %= MOD; normal(a), normal(b); return (a+b)%MOD; }
inline ll modSub(ll a, ll b) { a %= MOD, b %= MOD; normal(a), normal(b); a -= b; normal(a); return a; }
inline ll modPow(ll b, ll p) { ll r = 1; while(p) { if(p&1) r = modMul(r, b); b = modMul(b, b); p >>= 1; } return r; }
inline ll modInverse(ll a) { return modPow(a, MOD-2); }
inline ll modDiv(ll a, ll b) { return modMul(a, modInverse(b)); }

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

int ctoi(char c) {
	if (c >= '0' && c <= '9') {
		return c - '0';
	}
	return 0;
}

int main(){
    int a,b,c;
    cin>>a>>b>>c;
    for(int i=1;i<=b;++i){
        int d=a%b;
        d*=i;
        if(d%b==c){
            cout<<"YES"<<endl;
            return 0;
        }
    }
    cout<<"NO"<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define REP(i,n) for(int i=0; i<(n); i++)
#define FOR(i,x,n) for(int i=x; i<(n); i++)
#define ALL(n) begin(n),end(n)
#define MOD 1000000007
 
typedef long long ll;
typedef unsigned int ui;
typedef unsigned long long ull;
template <class T>
void print(T& x){printf("%d\n", x);}

struct Item{
    int v;
    int w;
    double b;
};

bool compare(Item &x, Item &y){
    return x.b > y.b;
}
 
int main()
{
    int N, W_int;
    scanf("%d %d", &N, &W_int);

    double W=(double)W_int;
    Item items[N];
    REP(i, N) scanf("%d %d", &items[i].v, &items[i].w);
    REP(i, N) items[i].b = (double)items[i].v / items[i].w;

    sort(items, items+N, compare);

    // printf("W=%lf, item=%lf\n", W, items[0].b);


    int item=0;
    double ans=0;
    while(W>0 && item<N){
        if(W>items[item].w){
            ans += (double)items[item].v;
            W -= items[item].w;
        }else{
            ans += items[item].v * W / items[item].w;
            W = 0;
        }
        item++;
    }
    printf("%lf\n", ans);

    return 0;
}


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

int main(void){
    int n;
    cin>>n;
    vector<int> v(n+2);
    v[0]=0;
    rep(i, n) cin>>v[i+1];
    v[n+1]=0;
    vector<int> diff(n+1);
    rep(i, n+1){
        diff[i]=abs(v[i+1]-v[i]);
    }
    ll sum=accumulate(diff.begin(), diff.end(), 0LL);
    for(int i=1;i<=n;i++){
        ll ans=sum-diff[i-1]-diff[i]+(ll)abs(v[i+1]-v[i-1]);
        cout<<ans<<endl;
    }
    return 0;
    
}

Measured memory_bytes: 2048
#include<iostream>
#include<cstdio>
#include<cmath>
#include<algorithm>
#include<string>
#include<cstring>
#include<cstdlib>
#include<utility>
#include<map>
#include<vector>
#include<stack>
#include<queue>
#define loop(i,a,b) for(int i=a;i<b;i++)
#define rep(i,a) loop(i,0,a)
#define pi acos(-1)
#define pb push_back
using namespace std;
typedef pair<int,int> p;
typedef long long ll;

int main(){
	int a,b,c;
	cin>>a>>b>>c;
	if(a==b)cout<<c<<endl;
	else if(a==c)cout<<b<<endl;
	else cout<<a<<endl;
	return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;
import java.util.regex.Pattern;

public class Main {

	public static void main(String[] args) {
		Scanner inPut = new Scanner(System.in);
		String s = inPut.nextLine();

		String pattern = "^YAKI.*";
		boolean isMatch = Pattern.matches(pattern, s);
		if(isMatch==true ){
			System.out.println("Yes");
		}
		else{
			System.out.println("No");
		}

	}

}


Measured memory_bytes: 22868
/*================================================================
*
*   创 建 者： badcw
*   创建日期： 2020/6/21 20:00
*
================================================================*/
#include <bits/stdc++.h>

#define ll long long
using namespace std;

const int maxn = 10;
const int mod = 1e9+7;
ll qp(ll a, ll n, ll mod = ::mod) {
    ll res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}

int main(int argc, char* argv[]) {
    char t = getchar();
    puts(islower(t) ? "a" : "A");
    return 0;
}

Measured memory_bytes: 3628
def show (a,n):
  for i in range(n):
    if i > 0:
      print("",end=" ")
    print(a[i],end="")
  print("")

def selectionSort(a,n):
  count = 0
  for i in range(n):
    minj = i
    for j in range(i,n):
      if a[j] < a[minj]:
        minj = j
    a[minj],a[i] = a[i],a[minj]
    if minj != i:
      count += 1
  show(a,n)
  print(count)

n = int(input())
a = list(map(int,input().split()))

selectionSort(a,n)


Measured memory_bytes: 5624
object Main extends App {
  val inputs: Seq[String] = scala.io.Source.stdin.getLines().toList
  // val inputs = Seq("10 10 5", "1 6 1", "4 1 3", "6 9 4", "9 4 2", "3 1 3")
  val nums   = inputs.head.split(" ").map(_.toInt)
  val pointSeq = inputs.tail
  val width  = nums(0)
  val height = nums(1)
  val point  = nums(2)

  println(solve(width, height, pointSeq))

  private def solve(w: Int, h: Int, points: Seq[String]): Int = {
    val hash = scala.collection.mutable.HashMap((1,0), (2, w), (3, 0), (4 ,h))

    points.foreach { str =>
      val inputs = str.split(" ").map(_.toInt)
      val x = inputs(0)
      val y = inputs(1)
      val a = inputs(2)

      a match {
        case 1 if(hash(a) < x) => hash.update(a, x)
        case 2 if(hash(a) > x) => hash.update(a, x)
        case 3 if(hash(a) < y) => hash.update(a, y)
        case 4 if(hash(a) > y) => hash.update(a, y)
        case _ => ()
      }
    }
    val whiteX = hash(2) - hash(1)
    val whiteY = hash(4) - hash(3)

    (whiteX, whiteY) match {
      case (x, y) if (0 < x && 0 < y) => x * y
      case _ => 0
    }
  }
}

Measured memory_bytes: 27332
#include <iostream>
#include <vector>

using namespace std;

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

    return false;
}

int main(void) {
    int H, W;
    vector<vector<int>> c(10, vector<int>(10, 0));
    vector<vector<int>> dp(10, vector<int>(10, 0));

    cin >> H >> W;

    vector<vector<int>> A(H, vector<int>(W, 0));

    for (int i = 0; i < 10; i++) {
        for (int j = 0; j < 10; j++) {
            cin >> c[i][j];
            dp[i][j] = c[i][j];
        }
    }

    for (int i = 0; i < H; i++) {
        for (int j = 0; j < W; j++) {
            cin >> A[i][j];
        }
    }

    for (int k = 0; k < 10; k++) {
        for (int j = 0; j < 10; j++) {
            for (int i = 0; i < 10; i++) {
                chmin(dp[i][j], dp[i][k] + dp[k][j]);
            }
        }
    }

    int sum = 0;

    for (int i = 0; i < H; i++) {
        for (int j = 0; j < W; j++) {
            if (A[i][j] != -1) {
                sum += dp[A[i][j]][1];
            }
        }
    }

    cout << sum << endl;

    return 0;
}


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

typedef long long ll;
using namespace std;

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

	cout.setf(std::ios_base::fixed,std::ios_base::floatfield);

	int n;cin >> n;
	int s[n];

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

	sort(s,s+n);

	double ans = -1;

	for (int c = 0;c < n;c++){
		for (int d = c;d < n;d++){
			if(c == d) continue;
			int a = -1, b= -1;
			for (int i = n-1;i >= 0;i--){
				if(i == c || i == d) continue;
				if(a == -1) a = i;
				else{ b = i; break;}
			}
			double val = (double)(s[a]+s[b])/(s[d]-s[c]);
			ans = max(ans,val);
		}
	}

	cout << ans << endl;

	return 0;

}



Measured memory_bytes: 3248
import numpy as np

def abc(num):
    ret = 1
    for i in range(1,num+1):
        ret *= i
    #print(num,ret)
    return ret

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

tmp = (n-1) * (abc(n-1)) / (abc(n-1)+(n-1))
tmp = (tmp * 2 + tmp * 2 * (abc(n-2))) / (abc(n))

ans = 0

for i in range(n):
    for j in range(i+1,n):
        ans += np.sqrt((x[i]-x[j]) **2 + (y[i]-y[j]) **2)
print(ans * tmp)

Measured memory_bytes: 12476
import java.util.Scanner;
public class Main {
    public static void main(String [] args){
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int [] S = new int[n];
        int opt = 0;
        for(int i=0;i<n;i++) S[i] = sc.nextInt();
        opt = mergesort(S,opt,0,n);
        for(int i=0;i<n;i++){
            System.out.print(S[i]);
            if(i!=n-1) System.out.print(" ");
        }
        System.out.println();
        System.out.println(opt);
    }
    public static int  mergesort(int [] S,int sum,int left,int right){
        if(left+1<right){
            int mid = (left+right)/2;
            sum=mergesort(S,sum,left,mid);
            sum=mergesort(S,sum,mid,right);
            sum=merge(S,left,right,mid,sum);
        }
        return sum;
    }
    public static int merge(int [] S,int left,int right,int mid,int sum){
        int n1 = mid-left;
        int n2 = right-mid;
        int L[] = new int[n1+1];
        int R[] = new int[n2+1];
        for(int i=0;i<n1;i++)L[i] = S[left+i];
        for(int i=0;i<n2;i++)R[i] = S[mid+i];
        L[n1]=999999999;
        R[n2]=999999999;
        int i=0,j=0;
        for(int k=left;k<right;k++){
            if(L[i]<=R[j]){
                S[k] = L[i];
                i++;
                sum++;
            }
            else{
                S[k] = R[j];
                j++;
                sum++;
            }
        }
        return sum;
    }
}


Measured memory_bytes: 167592
#include <stdio.h>

int main(void)
{
    int n, count = 0;
    int flag = 0;
    
    scanf("%d", &n);
    int num[n];

    for (int i = 0; i < n; i++){
        scanf("%d", &num[i]);
        if (num[i] % 2 == 0){
            count++;
            if (num[i] % 3 == 0 || num[i] % 5 == 0)
                flag++;
        }
    }

    if (flag == count)
        printf("APPROVED");
    else
        printf("DENIED");

    return 0;
}

Measured memory_bytes: 128
n,a[100],b[100],cost[100][100];
i,j;
C(s,e){
	int mc,i,c;
	if(s==e)
		return 0;
	if(cost[s][e])
		return cost[s][e];
	mc=0x7fffffff;
	for(i=s;i<e;i++){
		c=C(s,i)+C(i+1,e)+a[s]*b[i]*a[i+1]*b[e];
		if(c<mc)
			mc=c;
	}
	return cost[s][e]=mc;
}
main(){
	scanf("%d",&n);
	for(i=0;i<n;i++)
		scanf("%d%d",a+i,b+i);
	printf("%d\n",C(0,n-1));
	exit(0);
}

Measured memory_bytes: 0
#include<stdio.h>

int main(void) {
    int y = 700, i;
    char s[3];

    scanf("%s", s);

    for(i = 0; i < 3; i++) {
        if(s[i] == 'o') y += 100;
    }

    printf("%d", y);

    return 0;
}



Measured memory_bytes: 128
#include <bits/stdc++.h>
using i64 = long long;
using std::cout;
using std::endl;
using std::cin;

int main() {
	int a, b; scanf("%d%d", &a, &b);
	
	if(a % 3 and b % 3 and (a + b) % 3) printf("Impossible\n");
	else printf("Possible\n");
	return 0;
}


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

mod = 10**9 + 7
H, W, A, B = map(int, input().split())

fct = [1]
inv = [1]
for i in range(1, H + W - 1):
    fct.append((fct[-1] * i) % mod)
    inv.append(pow(fct[i], mod - 2, mod))

def comb(n, k):
    return (fct[n] * inv[n - k] * inv[k]) % mod

ans = 0
for i in range(B, W):
    c1 = comb(H - A - 1 + i, i)
    c2 = comb(A - 1 + W - i - 1, W - i - 1)
    ans = (ans + c1 * c2) % mod
print(ans)


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

int main()
{
  int64_t N, M, a, n, x, ans = 0;
  cin >> N >> M;
  vector<int64_t> S(N + 1, 0); // S[r] - S[l] : l~rの和
  map<int64_t, int64_t> mp;
  for (int i = 0; i < N; i++)
  {
    cin >> a;
    S.at(i + 1) = (S.at(i) + (a % M)) % M;
    mp[S.at(i + 1)]++;
    if (S.at(i + 1) == 0)
      ans++;
  }
  for (auto p : mp)
  {
    tie(n, x) = p;
    ans += x * (x - 1) / 2;
  }
  cout << ans << endl;
}

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

int main() {
  string S;
  cin >> S;
  int count =0;
  
    if (S.at(0) == 'R' && S.at(1) == 'R' && S.at(2) == 'R') {
      count =+ 3;
    }
    else if (S.at(0) == 'R' && S.at(1) == 'R' && S.at(2) == 'S') {
      count =+2;
    }
    else if (S.at(0) == 'S' && S.at(1) == 'R' && S.at(2) == 'R') {
      count =+2;
    }
  	else if (S.at(0) == 'R' || S.at(1) == 'R' || S.at(2) == 'R') {
      count =+1;
    }
  cout << count << endl;
}



Measured memory_bytes: 3592
import java.util.Scanner;
public class Main {
    public static void main(String[] args){
       Scanner sc= new Scanner(System.in);
       while(true){
       int h = sc.nextInt();
       int w = sc.nextInt();

       if(h==0 && w==0) break;

        for(int i=0;i<h;i++) {
            for(int j=0;j<w;j++){
               if(i%2==1){ 
                if(j%2==0){
                    System.out.print(".");
                }else {
                     System.out.print("#");
                }   
               
               
            }
              else{
                  if(j%2==0){
                    System.out.print("#");
                  }else{
                    System.out.print(".");
                  }
             }
               }  
               System.out.println();
            }
            System.out.println();  
        }

       sc.close();
       }
    }



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

#define rep(i,n) for(long long i = 0; i < (long long)(n); i++)
using ll = long long; using vll = vector<ll>;
static const long long mo = 1e9+7;

int main(void) {
    ll n; cin >> n;
    vll a(n); rep(i, n) cin >> a[i];

    ll ret = 1, c = 0;
    rep(i, n) 
        if (a[i] < 2*(i-c)+1) 
            (ret *= i + 1 - c) %= mo, c++;

    rep(i, n-c) (ret *= (i + 1)) %= mo;
    cout << ret << endl;

    return 0;
}


Measured memory_bytes: 1024
import java.util.Scanner;
 
public class Main {
	public static Scanner sc = new Scanner(System.in);
	public static void main(String[] args) {
		new Main();
	}
	public Main() {
		new aoj217().doIt();
	}
	class aoj217{
		void doIt() {
			while(true){
				int n = sc.nextInt();
				if(n == 0)break;
				int ansn = 0;
				int ansd = -1;
				for(int i = 0;i < n;i++){
					int num = sc.nextInt();
					int d1 = sc.nextInt();
					int d2 = sc.nextInt();
					if(ansd < d1 + d2){
						ansn = num;
						ansd = d1 + d2;
					}
				}
				System.out.println(ansn+" "+ansd);
			}
		}
	}
}

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

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

#define sq(x)   (x)*(x)
#define PI      acos(-1.0)
#define all(x) x.begin(),x.end()
#define nl      '\n'

typedef long long int ll;
typedef unsigned long long int  llu;

int main()
{
    ll ans=0, n;
    cin >> n;
    ll A[n+1]={};
    for(int i=1; i<=n; i++)
    {
        for(int j=0; j<=n; j+=i)
        {
            A[j]++;
        }
    }

    for(int i=1; i<=n; i++)
    {
        ans+=A[i]*i;
    }
    cout <<ans<<nl;
    return 0;
}

Measured memory_bytes: 81748
#include <bits/stdc++.h>
using namespace std;
int n,k,pos;
int main()
{
	scanf("%d%d",&n,&k);
	for (int i=1;i<=n;i++)
	{
		int x;
		scanf("%d",&x);
		if (x==1) pos=i;
	}
	int lx=1,rx=n;
	int ans=0;
	while (lx+k-1<pos)
	{
		++ans;
		lx+=k-1;
	}
	while (rx-k+1>pos)
	{
		++ans;
		rx-=k-1;
	}
	if (rx-lx+1>k) ans+=2; else ++ans;
	printf("%d\n",ans);
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <map>
#include <vector>
#include <cmath>
#include <string>
#include <cstring>
#include <algorithm>
#include <climits>
#include <stack>
#include <queue>
#include <set>
#include <cctype>
#include <bitset>
#include <type_traits>

#include <list>
using namespace std;

#define REP(i, n) for (int i = 0; i < (n); ++i)
#define rep(i, a, b) for (int i = a; i < (b); ++i)
#define YES(j) cout << (j ? "YES" : "NO") << endl;
#define Yes(j) std::cout << (j ? "Yes" : "No") << endl;
#define yes(j) std::cout << (j ? "yes" : "no") << endl;

int main(void)
{
    int x, y;
    cin >> x >> y;
    cout << x * y << " " << 2 * x + 2 * y << endl;
}


Measured memory_bytes: 3116
#include<iostream>
#include<vector>
#include<queue>
#include<cmath>
#include<algorithm>
using namespace std;
using Graph = vector<vector<int>>;

const int INF = 1e9;
typedef long long ll;

int main(){
    double a, b, x;
    cin >> a >> b >> x;
    double y = 2.0 * x/(a * a) - b;
    double t = b - y;
    if(y < 0){
        y = 2.0 * x/(a * b);
        t = b;
      	printf("%.8f", atan(t/y) *180/M_PI);
      	return 0;
    }
    printf("%.8f", atan(t/a) *180/M_PI);
}


Measured memory_bytes: 512
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define ALL(v) v.begin(), v.end()
typedef long long ll;

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

int main(){
  int n;
  cin>>n;
  
  for(int i=1;i<=n;i++){
    if(i%3==0){
      cout<<" "<<i;
      continue;
    }
    for(int x=i;x>0;x/=10){
      if(x%10==3){
        cout<<" "<<i;
        break;
      }
    }
  }
  cout<<endl;
 
  return 0;
}


Measured memory_bytes: 3108
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using vb=vector<bool>;
using vvb=vector<vb>;
using vd=vector<double>;
using vvd=vector<vd>;
using vi=vector<int>;
using vvi=vector<vi>;
using vl=vector<ll>;
using vvl=vector<vl>;
using pll=pair<ll,ll>;
using tll=tuple<ll,ll>;
using tlll=tuple<ll,ll,ll>;
using vs=vector<string>;
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define rep(i,n) range(i,0,n)
#define rrep(i,n) for(ll i=(n)-1;i>=0;i--)
#define range(i,a,n) for(ll i=(a);i<(n);i++)
#define LINF ((ll)1ll<<60)
#define INF ((int)1<<30)
#define EPS (1e-9)
#define MOD (1000000007ll)
#define fcout(a) cout<<setprecision(a)<<fixed
#define fs first
#define sc second
#define PI (3.1415926535897932384)

int dx[]={1,0,-1,0,1,-1,-1,1},dy[]={0,1,0,-1,1,1,-1,-1};
template<class T>bool chmax(T&a,T b){if(a<b){a=b; return true;}return false;}
template<class T>bool chmin(T&a,T b){if(a>b){a=b; return true;}return false;}
template<class S>S sum(vector<S>&a){return accumulate(all(a),S());}
template<class S>S max(vector<S>&a){return *max_element(all(a));}
template<class S>S min(vector<S>&a){return *min_element(all(a));}
ll max(int a,ll b){return max((ll)a,b);} ll max(ll a,int b){return max(a,(ll)b);}

template<class T>void puta(T&&t){cout<<t<<"\n";}
template<class H,class...T>void puta(H&&h,T&&...t){cout<<h<<' ';puta(t...);}
template<class S,class T>void tf(bool b,S t,T f){if(b)puta(t);else puta(f);}
void YN(bool b){tf(b,"YES","NO");}
void Yn(bool b){tf(b,"Yes","No");}
void yn(bool b){tf(b,"yes","no");}
template<class S,class T>ostream&operator<<(ostream&os,pair<S,T>p){os<<"["<<p.first<<", "<<p.second<<"]";return os;};
template<class S>auto&operator<<(ostream&os,vector<S>t){bool a=1;for(auto s:t){os<<(a?"":" ")<<s;a=0;}return os;}
template<class S>auto&operator>>(istream&is,vector<S>&t){for(S&a:t)cin>>a;return is;}

/*他のライブラリを入れる場所*/


int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	string s;
	cin>>s;
	s+="X";
	ll ans=0,cnt=0;
	for(auto&c:s){
		if("ATGC"s.find(c)==-1){
			chmax(ans,cnt);
			cnt=0;
		}else cnt++;
	}
	puta(ans);
	return 0;
}

Measured memory_bytes: 256
N = int(input())
W = list(map(int, input().split()))
S2 = sum(W)
S1 = 0
W_abs = 200
while True:
    S1 += W[0]
    S2 -= W[0]
    W = W[1:]
    if S2-S1 <= 0:
        tmp_abs = W_abs
        W_abs = abs(S2-S1)
        print(min(W_abs, tmp_abs))
        break
    W_abs = abs(S2-S1)


Measured memory_bytes: 3060
#include<cstdio>
#include<cstring>
#include<iostream>
#include<string>
#include<map>
#include<vector>
#include<queue>
#include<set>
#include<sstream>
#include<cmath>
#include<algorithm>
using namespace std;
typedef long long ll;
const int N=100+10;
int a[N],b[N];
bool cmp1(int a1,int a2){
    return a1>a2;
}
bool cmp2(int a1,int a2){
    return a1<a2;
}
int main()
{
    string s1,s2;
    while(cin>>s1>>s2){
        int l1=s1.size(),l2=s2.size();
        for(int i=0;i<l1;i++){
            a[i]=s1[i]-'a';
        }
        for(int i=0;i<l2;i++){
            b[i]=s2[i]-'a';
        }
        sort(a,a+l1,cmp2);
        sort(b,b+l2,cmp1);
        int  flag=-1;
        for(int i=0;i<min(l1,l2);i++){
            if(b[i]>a[i]) {flag=1;break;}
            else if(b[i]<a[i]) {flag=0;break; }
        }
        if((flag==-1&&l2>l1)||flag==1){
            printf("Yes\n");

        }
        else printf("No\n");
    }


    return 0;
}




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

typedef long long ll;
typedef unsigned long long ull;
typedef vector<ll> vll;
const int SIZE = 100005;
const int INF = int (1e9) + int (1e5);
const ll INFL = ll(2e18) + ll(1e10);
const ll MOD = 1E9 + 7;
#define rep(i,n) for (long long i=0;i<(n);++i)
#define repp(i,a,b) for (long long i=(a);i<(b);++i)
#define per(i,x) for(long long i = (x) ; i >= 0 ; --i)
#define perr(i,x,y) for(long long i = (x) ; i >= (y) ; --i)
#define mp make_pair
#define pb push_back
#define f first
#define s second
#define all(a) (a).begin(),(a).end()
#define lla(a) (a).rbegin(),(a).rend()
#define p(x) cout<<x<<" "
#define pn(x) cout<<x<<"\n"
#define p2(x,y) cout<<x<<" "<<y<<"\n"
#define p3(x,y,z) cout<<x<<" "<<y<<" "<<z<<"\n"
#define p4(x,y,z,w) cout<<x<<" "<<y<<" "<<z<<" "<<w<<"\n"
#define p5(x,y,z,w,s) cout<<x<<" "<<y<<" "<<z<<" "<<w<<" "<<s<<"\n"
#define FAST ios_base::sync_with_stdio(false); cin.tie(0)

#define TRACE
#ifdef TRACE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
    template <typename Arg1>
    void __f(const char* name, Arg1&& arg1){
        cout << name << " : " << arg1 << std::endl;
        //use cerr if u want to display at the bottom
    }
    template <typename Arg1, typename... Args>
    void __f(const char* names, Arg1&& arg1, Args&&... args){
        const char* comma = strchr(names + 1, ','); cout.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
    }
#else
#define trace(...)
#endif


//template<class T>
//bool isPrime(T n){
//	if(n==1)return false;
//	T i = 2;
//	while(i*i<=n){
//	   if(n%i==0)return false;
//	   i+=1;
//	}
//    return true;
//}

// bool prime[100005];
// void seive()
// {
// 	memset(prime,true,sizeof(prime));
// 	prime[0]=0;
// 	prime[1]=0;
// 	for(ll p=2;p*p<=100000;p++)
// 	{
// 		if(prime[p]==true)
// 		{
// 			for(ll i=p*2;i<=100000;i+=p)
// 			prime[i]=false;
// 		}
// 	}	
// }

// ll power(ll n,ll k, ll mod){
// 	if(k==0)
// 		return 1;
// 	if(k==1)
// 		return n%mod;

// 	ll get=power(n,k/2,mod);
// 	ll ret = ((get%mod)*(get%mod))%mod;

// 	if(k%2)
// 		ret = ((ret%mod)*(n%mod))%mod;

// 	return ret%mod;
// }

ll dp[SIZE];
ll a[SIZE];
int main(){
    
    // freopen("input.txt","r",stdin);
    // freopen("output.txt","w",stdout);

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

	rep(i,n)cin>>a[i];
	dp[0] = false;
	repp(i,1,k+1){
		rep(j,n){
			if(a[j]<=i && !dp[i-a[j]])dp[i]=true;
		}
	}
	(dp[k] ? p("First"):p("Second"));
}

Measured memory_bytes: 1024
import java.util.*;
public class Main {
  public static void main(String[] args){

    Scanner sc = new Scanner(System.in);
    String N = sc.next();
    String Ns = N.substring(0,1);
    String Ne = N.substring(N.length() - 1);

    if (Ns.equals("9") || Ne.equals("9")) {
      System.out.println("Yes");
    } else {
      System.out.println("No");
    }

  }
}

Measured memory_bytes: 21844
n, m = map(int, input().split())
a = [input() for _ in range(n)]
b = [input() for _ in range(m)]

from itertools import permutations
import sys

def match(lt):
    if m == 1:
        rng = [(0, 0)]
    else:
        rng = permutations(range(m), 2)
    for b_x, b_y in rng:
        a_x = lt[0] + b_x
        a_y = lt[1] + b_y
        if a[a_y][a_x] != b[b_y][b_x]:
            return False

    return True

cnt = 0
for i in range(n - m + 1):
    for j in range(n - m + 1):
        if match((i, j)):
            print("Yes")
            sys.exit()

print("No")


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

int main(){
    int n, k;
    cin >> n >> k;
    vector<ll> v(n);
    for(int i = 0; i < n; i++)  cin >> v[i];
    sort(v.rbegin(), v.rend());
    ll ret = 0;
    for(int i = 0; i < n; i++){
        if(k){
            k--;
            continue;
        }
        ret += v[i];
    }
    cout << ret << endl;
    return 0;
}

Measured memory_bytes: 1920
#include<bits/stdc++.h>
#define mx 1e10
using namespace std ;
int arr[100001] ;
//int res[100001] ;

int main(){
   // freopen("in.txt","r",stdin) ;
int n ;scanf("%d",&n) ;
for(int i=0 ; i<n ;i++){
    scanf("%d",&arr[i]) ;
}
sort(arr, arr+n) ;
/*for(int i=0 ; i<n ; i++){
    cout << arr[i] << " " ;

}*/
int a = arr[n-1] ;
int k  ; int mn = mx ;
for(int i=0 ; i<n-1 ; i++){
     if(abs(a-2*arr[i])< mn){
        k=arr[i] ;
        mn=abs(a-2*k) ;
       //printf("%d  %d\n",k,mn) ;
     }
}
printf("%d %d",a,k) ;




return 0 ;
}


Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
int main()
{
    ios_base :: sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    long int n, k; cin>>n>>k;
    long int h[n]; for(int i = 0; i < n; i++) cin>>h[i];
    if(k >= n)
    {
        cout<<0<<'\n';
        return 0;
    }
    sort(h, h + n);
    long int sum = 0;
    for(int i = 0; i < n - k; i++) sum += h[i];
    cout<<sum<<'\n';
    return 0;
}

Measured memory_bytes: 1792
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <climits>
#include <cfloat>
#include <ctime>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>
#include <numeric>
#include <list>

using namespace std;

#ifdef _MSC_VER
#define __typeof__ decltype
template <class T> int __builtin_popcount(T n) { return n ? 1 + __builtin_popcount(n & (n - 1)) : 0; }
#endif

#define foreach(it, c) for (__typeof__((c).begin()) it=(c).begin(); it != (c).end(); ++it)
#define all(c) (c).begin(), (c).end()
#define rall(c) (c).rbegin(), (c).rend()
#define popcount __builtin_popcount
           
#define rep(i, n) for (int i = 0; i < n; ++i)

template <class T> void max_swap(T& a, const T& b) { a = max(a, b); }
template <class T> void min_swap(T& a, const T& b) { a = min(a, b); }

const double EPS = 1e-10;
typedef long long ll;
typedef pair<int, int> pint;


int main()
{
    int n, m;
    while (scanf("%d%d", &n, &m), n | m)
    {
	int w = n + m;
	vector<int> t;
	t.push_back(0);
	rep (i, w)
	{
	    int a;
	    scanf("%d", &a);
	    t.push_back(a);
	}
	sort(all(t));
	int res = -1;
	for (int i = 1; i < t.size(); ++i)
	    max_swap(res, t[i] - t[i - 1]);
	printf("%d\n", res);
    }
}

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

int main(){
  int N,M;
  cin >> N >> M;
  vector<int> s(M),c(M),ans(N);
  bool flag=true;
  for(int i=0;i<N;i++){
    ans.at(i)=-1;
  }
  for(int i=0;i<M;i++){
    cin >> s.at(i) >> c.at(i);
    if(s.at(i)==1 && c.at(i)==0 && N!=1) flag=false;
    if(ans.at(s.at(i)-1)==-1){
      ans.at(s.at(i)-1)=c.at(i);
    } else {
        if(ans.at(s.at(i)-1)!=c.at(i)){
          flag=false;
        }
    }
  }

  for(int i=0;i<N;i++){
    if(ans.at(i)==-1){
      N==1 ? ans.at(i)=0
      : i==0 ? ans.at(i)=1 :ans.at(i)=0;
    }
  }
  
  if(flag){
    for(int i=0;i<N;i++){
      cout << ans.at(i);
    }
    cout << endl;
  } else {
      cout << -1 << endl;
  }
}

Measured memory_bytes: 256
W, a, b = list(map(int, input().split()))

if a < b:
    ans = b - (a + W)
    if ans < 0:
        print(0)
    else:
        print(ans)

else:
    ans = a - (b + W)
    if ans < 0:
        print(0)
    else:
        print(ans)


Measured memory_bytes: 2940
#include<stdio.h>
#include<math.h>
long n,k,l,x,min;
long sum = 0;
int main() {
	scanf("%ld %ld", &n,&k);
	min = n;
	for (long i = 1; i <= n;i++) {
		scanf("%ld", &l);
		if (l == 1) {
			sum += i / (k - 1);
			x = sum*(k - 1) + 1;
			while (1) {
				sum++;
				min -= k - 1;
				if (min <= x)break;
			}
		}
	}
	printf("%ld", sum);
}

Measured memory_bytes: 128
#include "iostream"
#include "climits"
#include "list"
#include "queue"
#include "stack"
#include "set"
#include "functional"
#include "algorithm"
#include "string"
#include "map"
#include "unordered_map"
#include "unordered_set"
#include "iomanip"
#include "cmath"
#include "random"
#include "bitset"
#include "cstdio"
#include "numeric"
#include "cassert"
#include "ctime"

using namespace std;

//constexpr long long int MOD = 1000000007;
constexpr int MOD = 1000000007;
//constexpr int MOD = 998244353;
//constexpr long long int MOD = 998244353;
constexpr double EPS = 1e-8;

//int N, M, K, H, W, L, R;
long long int N, M, K, H, W, L, R;

long long int power(long long int x, long long int n, long long int M) {
	long long int ret = 1;
	long long int by = x;
	while (n) {
		if (n & 1) {
			ret *= by;
			ret %= M;
		}
		by *= by;
		by %= M;
		n >>= 1;
	}
	return ret;
}

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

	cin >> N >> M;
	if (N == 1) {
		cout << 1 << endl;
		return 0;
	}
	if (M == 1) {
		cout << power(2, N - 2, MOD) << endl;
		return 0;
	}
	vector<long long int>by(2*N + 1, 1);
	vector<long long int>rev(2*N + 1, 1);
	for (int i = 2; i <= N * 2; i++) {
		by[i] = by[i - 1] * i;
		by[i] %= MOD;
		rev[i] = power(by[i], MOD - 2, MOD);
	}
	vector<vector<long long int>>twolis(N, vector<long long int>(N));
	twolis[0][0] = 1;
	twolis[1][1] = 1;
	for (int i = 1; i < N - 1; i++) {
		for (int j = 1; j <= i; j++) {
			twolis[i + 1][j + 1] += twolis[i][j];
			twolis[i + 1][j + 1] %= MOD;
		}
		long long int sum = 0;
		for (int j = i; j >= 1; j--) {
			sum += twolis[i][j];
			twolis[i + 1][j] += sum;
			twolis[i + 1][j] %= MOD;
		}
	}
	long long int ans = 0;
	long long int bef = 0;
	for (int i = 0; i < M; i++) {
		long long int num = 1;
		num = by[N - 1 - i] * rev[M - 1 - i];
		num %= MOD;
		num *= rev[N - M];
		num %= MOD;
		long long int add = 1;
		add *= by[M - 1 + i];
		add %= MOD;
		add *= rev[i];
		add %= MOD;
		add *= rev[M - 1];
		add %= MOD;
		add *= M - i;
		add %= MOD;
		add *= power(M, MOD - 2, MOD);
		add %= MOD;
		//cout << "i= " << i << endl;
		//cout << num << " " << add << endl;
		add += MOD-bef;
		add %= MOD;
		bef += add;
		bef %= MOD;
		num *= add;
		ans += num;
		ans %= MOD;
	}
	if (N - M - 1 >= 0)ans *= power(2, N - M - 1, MOD);
	ans %= MOD;
	cout << ans << endl;
}

Measured memory_bytes: 31616
#include <bits/stdc++.h>
#define arep(a,i,n) for(ll i=(a);i<(n);i++)
#define rep(i,n) for(ll i=0;i<(n);i++)
#define cinf(x,n) for(ll i=0;i<(n);i++)cin>>x[i];
#define coutf(x,n) for(ll i=0;i<(n);i++)cout<<x[i]<<endl;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;

using namespace std;

int main(){
	ll n;
	cin >> n;
	ll a[n];
	cinf(a,n);
	if(n==1){
		cout << a[0] << endl;
		return 0;
	}
	else if(n%2==0){
		for(ll i=n-1;i>=0;i-=2){
			cout << a[i] << ' ';
		}
		for(ll i=0;i<n-2;i+=2){
			cout << a[i] << ' ';
		}
	}else{
		for(ll i=n-1;i>=0;i-=2){
			cout << a[i] << ' ';
		}
		for(ll i=1;i<n-2;i+=2){
			cout << a[i] << ' ';
		}
	}
	cout << a[n-2] << endl;
}

Measured memory_bytes: 5120
//by yjz
#include<bits/stdc++.h>
#define FF first
#define SS second
#define MP make_pair
#define PB push_back
typedef long long ll;
using namespace std;
int n;
char c;
string ans;
void solve(string s, int K)
{
	char c = s.back();
	int l = n;
	for (int i=0; i<K; i++)
	{
		while (l>0&&s[l-1]==c) l--;
		string ns;
		for (int j=l; j<n; j++) ns += s[j];
		for (int j=n-1; j>=n-l; j--) ns += s[j];
		s = ns;
		if (i!=K-1) reverse(s.begin(), s.end());
	}
	ans = min(ans, s);
}
string s;
int K;

string solve_bf(string s, int K)
{
	int n = s.size();
	set<string> st, nst;
	st.insert(s);
	for (int i=0; i<K; i++)
	{
		nst.clear();
		for (auto x : st)
		{
			for (int j=0; j<=n; j++)
			{
				string t;
				for (int l=j; l<j+n; l++)
				{
					if (l<n) t.PB(x[l]); else t.PB(x[n+n-1-l]);
				}
				nst.insert(t);
			}
		}
		st = nst;
	}
	return *st.begin();
}
string solve0(string s, int K)
{
	ans.clear();
	ans.PB(char('z'+1));
	c = s[0];
	for (int i=1; i<n; i++) c = min(c, s[i]);
	string t = s;
	reverse(t.begin(), t.end());
	string ss = s+t;
	for (int i=0; i<=n; i++)
	{
		solve(ss.substr(i, n), K-1);
	}
	return ans;
}
int main()
{
/*
	n = 20;
	while (true)
	{
		K = rand()%4+1;
		string s;
		for (int i=0; i<n; i++) s.PB(rand()%3+'a');
		string a0 = solve0(s, K);
		string aa = solve_bf(s, K);
		if (a0!=aa)
		{
			cout<<K<<endl<<s<<endl<<a0<<endl<<aa<<endl;
			return 0;
		}
	}
 */
	cin>>n>>K;
	cin>>s;
	K = min(K, 14);
	cout<<solve0(s, K)<<endl;
//	cout<<solve_bf(s, K)<<endl;
	return 0;
}

Measured memory_bytes: 384
#include <iostream>
#include <vector>

using namespace std;

typedef long long ll;

const ll MAX_LIM = 55555+10;

bool IsPrime(long long int n){
  for (long long int i = 2; i * i <= n; i++) {
    if (n % i == 0) return false;
  }
  return n != 1;
}

int main(int argc, char const *argv[]) {
  long long int N;
  cin >> N;
  vector<int> ans;
  int i = 2;
  while(ans.size() < N){
    if (IsPrime(i) && i%5==1) ans.push_back(i);
    i++;
  }

  for (int i = 0; i < N; ++i) cout << ans[i] << ' ';
  cout << endl;

  return 0;
}


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

int solve(vector<int> vec, int Q){
    int i = max_element(vec.begin(), vec.end()) - vec.begin();
    if(vec[i] < Q){
        return 0;
    }else{
        return i;
    }
}

int main(){
    int N, Q;
    while(cin >> N >> Q, N|Q){
        vector<int> vec(110);
        
        for(int i=0; i<N; i++){
            int m; cin >> m;
            for(int j=0; j<m; j++){
                int d; cin >> d;
                vec[d]++;
            }
        }
        
        cout << solve(vec, Q) << endl;
    }
    
    return 0;
}

Measured memory_bytes: 3032
N, M = map(int, input().split())
K = 0
list1 = []
list2 = []
list1 = list(map(int, input().split()))
list1 = list1[1:]
for i in range(N-1):
  list2 = list(map(int, input().split()))
  list1 = list(set(list2[1:]) & set(list1))
  if len(list1) == 0:
    break
print(len(list1))

Measured memory_bytes: 3064
import sys
from collections import deque

def dfs(start, dest, pre, d):
    if d[start][dest] > 0:
        return d[start][dest]

    for i in range(len(d)):
        if d[start][i] > 0 and i != pre:
            c = dfs(i, dest, start, d)
            if c > 0:
                return d[start][i] + dfs(i, dest, start, d)

    return 0

def main():
    input = sys.stdin.readline
    N = int(input())
    
    d = [[] for _ in range(N)]
    for _ in range(N-1):
        a, b, c = map(int, input().split())
        a, b = a - 1, b - 1
        
        d[a].append((b, c))
        d[b].append((a, c))

    Q, K = map(int, input().split())
    K -= 1

    k_dist = [0 for _ in range(N)]
    start = deque()
    start.append(K)
    while len(start) > 0:
        s = start.popleft()
        for dest, cost in d[s]:
            if k_dist[dest] > 0:
                continue

            k_dist[dest] = k_dist[s] + cost
            start.append(dest)

    for _ in range(Q):
        x, y = map(int, input().split())
        x, y = x - 1, y - 1

        print(int(k_dist[x] + k_dist[y]))


if __name__ == '__main__':
    main()


Measured memory_bytes: 43736
// ABC170A - 

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

typedef unsigned long long int ull;
typedef long long int ll;

int main() {
	int x;
	for (int i = 0; i < 5; i++) {
		cin >> x;
		if (x == 0) {
			cout << i + 1 << endl;
			return 0;
		}
	}

	return 0;
}


Measured memory_bytes: 3620