akhauriyash/Code-Regression huggingface dataset:
N, M = map(int, input().split())
edges = [list(map(int, input().split())) for _ in range(M)]
D = {i: [] for i in range(N)}
for i in edges:
  i[0] -= 1
  i[1] -= 1
  D[i[0]].append(i[1])
  D[i[1]].append(i[0])
cnt = 0
L = [0 for _ in range(N)]
base = [1 for _ in range(N)]
for i in edges:
  L[0] = 1
  p = [0]
  f = [i[0], i[1]]
  while p != []:
    n = len(p)
    for j in range(n):
      X = D[p[j]][:]
      for k in X:
        if L[k] == 0 and (p[j] != f[1] or k != f[0]) and (p[j] != f[0] or k != f[1]):
          L[k] = 1
          p.append(k)
    p = p[n:]
  if L != base:
    cnt += 1
  L = [0 for _ in range(N)]
print(cnt)

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

const int INF = pow(2, 31) - 1;
#define ll long long
#define DEBUG(x) cout << "DEBUG>" << #x << ":" << x << endl;
#define REP(i,n) for(ll i=0;i<(n);i++)
#define FOR(i,a,b) for(ll i=(a);i<=(b);i++)
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}

int main() {
  int N;
  cin >> N;
  vector<string> S(N);
  vector<ll> count(5, 0);
  REP(i, N) {
    cin >> S[i];
    if(S[i][0] == 'M') {
      count[0]++;
    } else if(S[i][0] == 'A') {
      count[1]++;
    } else if(S[i][0] == 'R') {
      count[2]++;
    } else if(S[i][0] == 'C') {
      count[3]++;
    } else if(S[i][0] == 'H') {
      count[4]++;
    }
  }
  ll ans = 0;
  REP(i, pow(2, 5)) {
    string s = "";
    int c = 0;
    REP(j, 5) {
      if(i >> j & 1) {
        s += "1";
        c++;
      } else {
        s += "0";
      }
    }
    if(c == 3) {
      ll comb = 1;
      REP(j, 5) {
        if(s[j] == '1') {
          comb *= count[j];
        }
      }
      ans += comb;
    }
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 6144
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		double a = sc.nextInt();
		double b = sc.nextInt();
		double c = sc.nextInt();
		double cos = Math.cos(c / 360 * 2 * Math.PI);
		double sin = Math.sin(c / 360 * 2 * Math.PI);
		double l = a + b + Math.sqrt(Math.pow(a, 2) + Math.pow(b, 2) - (2 * a * b * cos));
		double s = (a * b) / 2 * sin;
		double h = b * sin;
		System.out.println(s);
		System.out.println(l);
		System.out.println(h);
	}
}



Measured memory_bytes: 26296
#include <iostream>
#include <string>
#include <vector>
#include <list>
#include <map>
#include <queue>
#include <stack>
#include <algorithm>
#include <fstream>
#include <sstream>
#include <iomanip>
#define ll long long

using namespace std;

long long MOD = 1000000007;

int main(){
    ll N, D;
    cin >> N >> D;

    int ans=0;
    for(int i=0; i<N; i++){
        ll x, y;
        cin >> x >> y;
        if(x*x+y*y<=D*D){
            ans++;
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 3596
import java.util.*;
public class Main{
	public static void main(String[] args){
      Scanner sc = new Scanner(System.in);
      int a = sc.nextInt();
      int b = sc.nextInt();
      int c = sc.nextInt();
      if(a==b)System.out.println(c);
      else if(b==c)System.out.println(a);
      else System.out.println(b);
    }
}

Measured memory_bytes: 21716
#include <bits/stdc++.h>
typedef long long int ll;
using namespace std;
const ll N = 2000009;
const ll p = 31;
const ll m = 1e9 + 7;
const ll inf= 1e14;
ll mod = 1e9+7;
ll powm(ll a, ll b) { ll res = 1; while (b) { if (b & 1) res = (res * a) % mod; a = (a * a) % mod; b >>= 1; } return res; }
// ll fact[N];


// ll ncr(ll n,ll r){
//      return (((fact[n]*powm(fact[r],mod-2))%mod)*powm(fact[n-r],mod-2))%mod;
// }
 int main() {   
     ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    
     // #ifndef ONLINE_JUDGE
     // freopen("input.txt", "r", stdin);
     // freopen("output.txt", "w", stdout);
     // #endif
     ll t = 1;
     // cin>>t;
     while(t--){
          ll a,b;cin>>a>>b;
          ll g = __gcd(a,b);
          // cout<<g;111
          ll ans = 1     ;
          for(ll i =2;i*i<=g;i++){
               if(g%i == 0){
                    ans++;
                    while(g%i == 0){
                         g = g/i;
                    }
               }
          }
          if(g!=1){
               ans++;
          }
          cout<<ans;
     }
}            


Measured memory_bytes: 256
#include <bits/stdc++.h>
 
using namespace std;
 
//#define MD 1
#define MD 1000000007
 
int main(){
   string s;
    cin>>s;
    int k;
    cin>>k;
    set<string> t;
    for(int i=1;i<=k;i++){
        for(int j=0;j+i-1<s.length();j++){
            string u=s.substr(j,i);
            t.insert(u);
        }
    }
   
    auto it=t.begin();
    for(int i=0;i<k-1;i++){
        it++;
    }
    cout<<*it<<endl;
    return 0;
}

Measured memory_bytes: 1664
object Main extends App {

  import scala.io.StdIn._
  import scala.math._


  val Array(n, s) = readLine.trim.split(' ').map(_.toInt)
  val planets = Array.tabulate(n){i ⇒
    val Array(l, r) = readLine.trim.split(' ').map(_.toInt)
    Time(l, r)
  }
  val distance = Array.tabulate(n){_ ⇒ readLine.trim.split(' ').map(_.toLong)}
  for (k ← distance.indices){
    for {i ← distance.indices
         j ← distance.indices if i != j} {
      if (distance(i)(j) > distance(i)(k) + distance(k)(j))
        distance(i)(j) = distance(i)(k) + distance(k)(j)
    }
  }
  for (i ← planets.indices){
    if (planets(i).from < distance(s - 1)(i))
      planets(i) = planets(i).copy(from = distance(s - 1)(i))
  }
  val maxTime = Array.tabulate(n){_ ⇒ 0L}

  for ((p, i) ← planets.zipWithIndex.sortBy(_._1.to)){
    if (p.to >= p.to) {
      if (maxTime(i) < p.to - p.from)
        maxTime(i) = p.to - p.from
      for ((q, j) ← planets.zipWithIndex if i != j) {
        if (q.to + distance(j)(i) <= p.from) {
          if (maxTime(i) < maxTime(j) + p.to - p.from) maxTime(i) = maxTime(j) + p.to - p.from
        } else if (q.to + distance(j)(i) <= p.to) {
          if (maxTime(i) < maxTime(j) + p.to - q.to - distance(j)(i)) maxTime(i) = maxTime(j) + p.to - q.to - distance(j)(i)
        }
      }
    }
  }
  println(
    maxTime.max
  )

  case class Planet(id: Int, time: Time)
  case class Time(from: Long, to: Long)
  implicit class Extension[T](val value :T){
    def also(func: T ⇒ Unit): T = {
      func(value)
      value
    }
    def let[R](func: T ⇒ R): R = func(value)
  }
}


Measured memory_bytes: 448840
#include <bits/stdc++.h>
#define int long long
#define double long double
#define rep(i, a, n) for(int i = (int)(a);(i) < (int)(n);++(i))
#define repe(i, a, n) for(int i = (int)(a);(i) <= (int)(n);++(i))
#define repif(i, a, x) for(int i = (int)(a);(x);++(i))
#define repr(i, a, n) for(int i = ((int)(a)-1);(i) >= (int)(n);--(i))
#define reper(i, a, n) for(int i = (int)(a);(i) >= (int)(n);--(i))
#define SZ(x) ((int)(x).size())
#define ALL(x) begin(x), end(x)
#define CEIL(x) ((int)ceil(((double)x)))
#define POW(x, y) ((int)pow(x, y))
#define UNIQUE(x) (x).erase(unique(ALL((x))), end(x))
#define gcd(x, y) __gcd(x, y)
#define lcm(x, y) ((x)/gcd(x,y)*(y))
#define isin(x, l, r) ((l) <= (x) and (x) < (r))
#define fcout(n) cout << fixed << setprecision(n)
#define rcout(n) cout << right << setw(n)
#define pb push_back
#define eb emplace_back
#define lb lower_bound
#define ub upper_bound
#define PI (acosl(-1))
#define EPS (1e-10)
#define INF LLONG_MAX
#define INF32 INT32_MAX
#define MOD 1000000007LL
using namespace std;
using VI = vector<int>;
using VVI = vector<vector<int>>;
using PII = pair<int, int>;
using TIII = tuple<int, int, int>;
using VPII = vector<pair<int, int>>;
using VTIII = vector<tuple<int, int, int>>;
using Complex = complex<double>;
template<typename T, template<typename> typename C = less> using PQ = priority_queue<T, vector<T>, C<T>>;
template<typename T> inline bool chmax(T& a, const T& b, bool t = false){ if(a<b or (t and a == b)){ a=b; return true; } return false; }
template<typename T> inline bool chmin(T& a, const T& b, bool t = false){ if(a>b or (t and a == b)){ a=b; return true; } return false; }


int N;


signed main(){
    cin >> N;

    int s = 0;
    repe(i, 1, N){
        if(i%3 == 0 and i%5 == 0) continue;
        if(i%3 == 0) continue;
        if(i%5 == 0) continue;
        s += i;
    }

    cout << s << endl;

    return 0;
}

Measured memory_bytes: 3604
def insertionSort(list1,g):
  cnt=0
  for i in range(g,len(list1)):
    value = list1[i]
    j = i-g
    while j>=0 and list1[j]>value:
      list1[j+g] = list1[j]
      j = j-g
      cnt +=1
    list1[j+g]=value
    
  return cnt
    
def shellSort(list1):
  cnt = 0
  G = []
  n1 = len(list1)
  while int(n1/3)>0:
    n1 = int(n1/3)+1
    G.append(n1)
  G.append(1)
  for i in range(len(G)):
    cnt+=insertionSort(list1,G[i])
  print(len(G))
  print(*G)
  print(cnt)  
    
    
  

n = int(input())
list1 = []
for i in range(n):
  list1.append(int(input()))

shellSort(list1)


for i in range(n):
  print(list1[i])


Measured memory_bytes: 45512
#include <cstdio>
#include <iostream>
#include <algorithm>
using namespace std;
const int Q=1<<18;
int n;
void Inv(int a[],int b[])
{
    for(int i=1;i<=n;i++)
        b[a[i]]=i;
}
int tmp[Q],cmp[Q];
void Mul(int a[],int b[],int c[])
{
    for(int i=1;i<=n;i++)
        tmp[i]=a[b[i]];
    for(int i=1;i<=n;i++)
        c[i]=tmp[i];
}
int p[Q],q[Q];
void R(int a[])
{
    for(int i=1;i<=n;i++)
        scanf("%d",&a[i]);
}
int owo[10][Q],cc[Q];
void F(int p[],int q[],int f[])
{
    Inv(p,cc);
    Mul(q,cc,f);
}
void Ksm(int a[],int b)
{
    for(int i=1;i<=n;i++)cmp[i]=i,cc[i]=a[i];
    for(;b;b>>=1,Mul(cc,cc,cc))
        if(b&1)Mul(cmp,cc,cmp);
    for(int i=1;i<=n;i++)
        a[i]=cmp[i];
}
int A[Q],ip[Q],iq[Q],IA[Q];
int main()
{
    int k;
    scanf("%d%d",&n,&k);
    R(p),R(q);
    for(int i=1;i<=n;i++)
        owo[1][i]=p[i],owo[2][i]=q[i],owo[0][i]=i;
    for(int i=3;i<=6;i++)
        F(owo[i-2],owo[i-1],owo[i]);
    int rel=(k-1)%6+1;
    for(int i=1;i<=n;i++)A[i]=q[i];
    Inv(p,ip),Inv(q,iq);
    Mul(A,ip,A);
    Mul(A,iq,A);
    Mul(A,p,A);
    Inv(A,IA);
    Ksm(A,(k-1)/6),Ksm(IA,(k-1)/6);
    Mul(A,owo[rel],A);
    Mul(A,IA,A);
    for(int i=1;i<=n;i++)
        printf("%d ",A[i]);
    return 0;
}
/*
10 6
7 10 6 5 4 2 9 1 3 8
4 1 9 2 3 7 8 10 6 5
*/

Measured memory_bytes: 16384
#include<iostream>

using namespace std;

int main(){
    int N,n,sum=0;
    cin>>N;
    n=N;
        while(n>0){
            sum+=n%10;
            n/=10;
        }
            if(N%sum==0){
                cout<<"Yes";
            }else{
                cout<<"No";
            }
}

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

const long double pi = acosl(-1);
int n, L, t[3033];
long double sx = 0, sy = 0;
int main() {
  scanf("%d%d", &n, &L);
  for (int i = 1; i <= n; i++) {
    scanf("%d", &t[i]);
  }
  for (int i = 1; i <= n; i++) {
    for (int j = i + 1; j <= n; j++) {
      long double x = cosl(pi * (t[i] + t[j]) / L);
      long double y = sinl(pi * (t[i] + t[j]) / L);
      sx += x * (n - j + i - 1);
      sy += y * (n - j + i - 1);
      sx -= x * (j - i - 1);
      sy -= y * (j - i - 1);
    }
  }
  sx = sx * 6 / n / (n - 1) / (n - 2);
  sy = sy * 6 / n / (n - 1) / (n - 2);
  printf("%.10lf %.10lf\n", (double) sx, (double) sy);
}


Measured memory_bytes: 384
import java.util.*;
public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = Integer.parseInt(sc.nextLine());
        int maxCakeNum = N / 4;
        int maxDonutsNum = N / 7;
        for(int i = 0; i <= maxCakeNum; i++) {
            for(int j = 0; j <= maxDonutsNum; j++) {
                if((i*4)+(j*7) == N) {
                    System.out.println("Yes");
                    return;
                }
            }
        }
        System.out.println("No");
    }
}

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

int main()
{
  int N; cin >> N;
  if (N < 10) cout << N << endl;
  else if (N < 100) cout << 9 << endl;
  else if (N < 1000) cout << 9 + (N - 99) << endl;
  else if (N < 10000) cout << 9 + 900 << endl;
  else if (N < 100000) cout << 9 + 900 + (N - 9999) << endl;
  else cout << 9 + 900 + 90000 << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>                                           
 
#define int long long
//#pragma GCC optimize("Ofast")
//#pragma comment(linker, "/stack:200000000")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4")
 
 
#define file(s) freopen(s".in","r",stdin); freopen(s".out","w",stdout);
#define forev(i, b, a) for(int i = (b); i >= (a); --i)
#define forn(i, a, b) for(int i = (a); i <= (b); ++i)
#define all(x) x.begin(), x.end()
#define sz(s) (int)s.size()
#define pb push_back
#define ppb pop_back
#define mp make_pair
#define s second
#define f first
 
 
using namespace std;
 
 
typedef pair < long long, long long > pll;    
typedef pair < int, int > pii;
typedef unsigned long long ull;         
typedef vector < pii > vpii;
typedef vector < int > vi;
typedef long double ldb;  
typedef long long ll;  
typedef double db;                             
 
 
const int inf = 1e9, maxn = 4e5 + 148, mod = 1e9 + 7, N = 1e5 + 211;
const int dx[] = {1, -1, 0, 0}, dy[] = {0, 0, 1, -1}, block = 555;
const pii base = mp(1171, 3307), Mod = mp(1e9 + 7, 1e9 + 9);
const db eps = 1e-12, pi = 3.14159265359;
const ll INF = 1e18;


	
int n, ans;

main () {
	cin >> n;
	for (int i = 2; i * i <= n; ++i) {
		if (n % i)
			continue;
		int cnt = 0;
		while (!(n % i)) {
			++cnt;
			n /= i;
		}
		int x = 1;
		while (cnt >= x)  {
			cnt -= x;
			++ans;		
			++x;
		}
	}

	if (n > 1)
		++ans;

	cout << ans << endl;
}





Measured memory_bytes: 3624
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(n);i++) 
#define all(x) (x).begin(),(x).end()
using namespace std;
using ll = long long;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<string> vs;
typedef pair<int, int> pii;


int main() {

	int a,b,c;
	cin >> a >> b >> c;


	cout << c<<" "<< a<< " "<<b << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(n);++i)
using ll=long long;
using namespace std;
int main(){
 int n,m;
  cin>>n>>m;
  int h[n];
  int a[m],b[m];//道mが結ぶ展望台
 
  //展望台iから一本の道を使ってたどりつける展望台の標高の最大値　よりも展望台iの標高が高いことを示す。
  int d[n]={0};//展望台が良い展望台かどうか？
  rep(i,n){
  cin>>h[i];//各展望台の高さ
  }
  rep(i,m){
  cin>>a[i]>>b[i];//道mはどこ(何番目の展望台)とどこを結んでるの?
    if(h[a[i]-1]>h[b[i]-1]){
    d[b[i]-1]=1;//b[i]番目の展望台は良い展望台ではない
    }
    else if(h[b[i]-1]>h[a[i]-1]){
    d[a[i]-1]=1;//a[i]番目の展望台は良い展望台ではない
    }
    else//両方同じ高さ
    {
      d[b[i]-1]=1;
      d[a[i]-1]=1;
    }
     
  }
int cnt=0;
  rep(i,n){
 //   cout<<d[i]<<endl;
  if(d[i]==0){
  cnt++;
  }
  }
  cout<<cnt<<endl;
                 }

Measured memory_bytes: 5072
#include <bits/stdc++.h>
#define mp make_pair
#define eb emplace_back
#define fi first
#define se second
#define bit(n) 1 << n
using namespace std;
using cd = complex <double>;

typedef pair <int, int> pii;
typedef vector <int> vi;
typedef vector <pair <int, int> > vii;
typedef map <int, int> mii;

const int Inf = 1000000007;
const int mod = 1000000007;
const double Pi = acos(-1);

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

int n, ans = 0, temp = 1;
string s;
int c[2023];

void Solve()
{
	c[0] = 1;
	cin >> s;
	for(int i = s.length() - 1; i >= 0; i--)
	{
		n += (s[i] - '0') * temp;
		n %= 2019;
		temp *= 10;
		temp %= 2019;
		ans += c[n];
		c[n]++;	
	}	
	cout << ans;
}

int main()
{
//	freopen("PARK.inp", "r", stdin);
//	freopen("PARK.out", "w", stdout);
	Fastio();
	Solve();
}

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

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define irep(i,a,n) for(int i = a;i < (int)(n);i++)
using namespace std;
typedef long long ll;

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

    int N = S.size();
    int index = 0;

    vector<int> ans(N,0);

    while(index < N){
        int RCount = 0;
        while(S[index] == 'R' && index < N){
            index++;
            RCount++;
        }

        int LCount = 0;
        while(S[index] == 'L' && index < N){
            index++;
            LCount++;
        }

        ans[index-LCount-1] = (RCount + LCount) / 2;
        ans[index-LCount] = (RCount + LCount) / 2;

        if((RCount + LCount) % 2 == 1){
            if(RCount % 2 == 1){
                ans[index-LCount-1]++;
            }else{
                ans[index-LCount]++;
            }
        }
    }

    rep(i,N){
        cout << ans[i] << " ";
    }
    cout << endl;
}

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

#define fi first
#define se second
#define repl(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define rep(i,n) repl(i,0,n)
#define each(itr,v) for(auto itr:v)
#define pb(s) push_back(s)
#define mp(a,b) make_pair(a,b)
#define all(x) (x).begin(),(x).end()
#define dbg(x) cout<<#x"="<<x<<endl
#define maxch(x,y) x=max(x,y)
#define minch(x,y) x=min(x,y)
#define uni(x) x.erase(unique(all(x)),x.end())
#define exist(x,y) (find(all(x),y)!=x.end())
#define bcnt(x) bitset<32>(x).count()

typedef long long ll;
typedef unsigned long long ull;
typedef pair<char, int> P;
typedef pair<P, int> PPI;
typedef pair<ll, ll> PL;
typedef pair<P, ll> PPL;

#define INF INT_MAX/3

#define MAX_N 1000

int n,l;
PPI ants[22];

int main(){
	cin.sync_with_stdio(false);
	while(1){
		cin>>n>>l;
		if(n==0)break;
		rep(i,n){
			cin>>ants[i].fi.fi>>ants[i].fi.se;
			ants[i].se=i;
		}
		int last=0,cnt=0;
		repl(t,1,l+1){
			rep(i,n){
				if(ants[i].fi.fi=='L'){
					ants[i].fi.se--;
					if(ants[i].fi.se==0){
						last=t;
						cnt++;
					}
				}else{
					ants[i].fi.se++;
					if(ants[i].fi.se==l){
						last=t;
						cnt++;
					}
				}
			}
			if(cnt==n)break;
			rep(i,n)rep(j,i){
				if(ants[i].fi.se==ants[j].fi.se){
					swap(ants[i].se,ants[j].se);
				}
			}
		}
		int idx;
		rep(i,n){
			if(ants[i].fi.se==l)idx=ants[i].se;
		}
		rep(i,n){
			if(ants[i].fi.se==0)idx=ants[i].se;
		}
		cout<<last<<" "<<idx+1<<endl;
	}
	return 0;
}

Measured memory_bytes: 3108
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        double a = scanner.nextDouble();

        String s = String.format("%.10f %.10f", a * a * Math.PI, a * 2 * Math.PI);
        System.out.println(s);
    }
}


Measured memory_bytes: 28424
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef string str;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector <pii> vpii;
typedef vector <pll> vpll;
typedef map <str,int> mapsi;
typedef map <str,int> :: iterator mapsitr;
typedef map <int , int> mint;
typedef map <ll , ll> mll;
typedef set <int> si;
typedef set <ll> sll;
typedef si :: iterator sitr;
typedef si :: reverse_iterator rsitr;
typedef sll :: iterator sltr;
typedef sll :: reverse_iterator rsltr;
#define mset multiset
typedef mset <int> msi;
typedef mset <ll> msll;
typedef msi :: iterator msitr;
typedef msi :: reverse_iterator msritr;
typedef msll :: iterator msltr;
typedef msll :: reverse_iterator mslritr;
#define mp make_pair
#define pb push_back
#define pob pop_back
#define fi first
#define se second
#define fs first.second
#define ss second.second
#define ff first.first
#define sf second.first
#define newl '\n'
char to_upper (char x){
    if( 97 <= int(x) && int(x) <= 126)return char(x-32);
    else if( 65 <= int(x) && int(x) <= 90)return x;
}
char to_lower (char x){
    if( 97 <= int(x) && int(x) <= 126)return x;
    else if( 65 <= int(x) && int(x) <= 90)return char(x+32);
}
int numerize (char x){
    if(48 <= int(x) && int(x) <= 57)return int(x-'0');
    else if( 97 <= int(x) && int(x) <= 126)return int(x-96);
    else if( 65 <= int(x) && int(x) <= 90)return int(x-64);
}
//void IO(){
//	#ifndef ONLINE_JUDGE
//	    freopen("input.txt", "r", stdin);
//	    freopen("output.txt", "w", stdout);
//	#endif
//}
// end of Template

int n,k,p1,temp,ans;
int main(){
	//IO();
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cin>>n>>k;
    for(int i=1;i<=n;i++){
        cin>>temp;
        if(temp==1){p1=i;}
    }

    int idx;
    if(k>=p1){
        idx = k;
        ans ++;
        while(idx<n){
            ans++;
            idx += k-1;
        }
    }
    else if(p1 > (n-k)){
        idx = n-k+1;
        ans++;
        while(idx>1){
            ans++;
            idx -= k-1;
        }
    }
    else{
        int mn;
        int l = p1 - k + 1;
        int r = p1;
        ans = INT_MAX;
        for(int i=p1-k+1;i<=p1;i++){
            l = i;
            r = l + k - 1;
            temp = l-1;
            mn = 1;
            mn += temp / (k-1);
            if(temp % (k-1) != 0)mn ++;
            temp = n-r;
            mn += temp / (k-1);
            if(temp % (k-1) != 0)mn ++;
            ans = min(ans,mn);
        }

    }
    cout<<ans<<newl;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int a = sc.nextInt();
		int b = sc.nextInt();
		for(int i = 0; i < 20; i++) {
			if(a*i-(i-1) >= b) {
				System.out.println(i);
				break;
			}
		}
	}
}

Measured memory_bytes: 21844
#include<stdio.h>

int main(void){
	int H,W,i,j;
	
	while(1){
		scanf("%d %d",&H,&W);
		if(H==0&&W==0){
			break;
		}
		for(i=0;i<H;i++){
			for(j=0;j<W;j++){
				printf("#");
			}
			printf("\n");
		}
		printf("\n");
	}
	return 0;
}

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

#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)


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

    if(a>=3200) cout << s << endl;
    else cout << "red" << endl;



}

Measured memory_bytes: 3588
#include <bits/stdc++.h>
#define int long long
#pragma GCC optimize("O3")

#define fi first
#define se second
#define em emplace
#define eb emplace_back
#define mp make_pair
#define pi pair<int,int>
#define vi vector<int>
#define vpi vector<pair<int,int>>
#define vll vector<ll>
#define vpll vector<pair<ll,ll>>
#define endl '\n'

#define si(v) int((v).size())
#define all(v) (v).begin(), (v).end()
#define rep(i, n) for (ll i = 0; i < (ll)(n); ++i) 
#define rep2(i, n, m) for (ll i = n; i <= (ll)(m); ++i)
#define rep3(i, n, m) for (ll i = n; i >= (ll)(m); --i)

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

using ll = long long;
using ld = long double;
using namespace std;

constexpr ll MOD = 1000000007;

class mint {
  private: 
    ll x;

  public:
    constexpr mint(const ll x = 0) noexcept : x((x % MOD + MOD) % MOD) {}
    constexpr ll value() noexcept { return x; }
    constexpr mint operator += (const mint right) noexcept {
      if ((x += right.x) >= MOD) x -= MOD;
      return *this;
    }
    constexpr mint operator -= (const mint right) noexcept {
      if ((x += MOD - right.x) >= MOD) x -= MOD;
      return *this;
    }
    constexpr mint operator *= (const mint right) noexcept {
      x = x * right.x % MOD;
      return *this;
    }
    constexpr mint operator /= (const mint right) noexcept {
      return *this *= right.inv();
    }
    constexpr mint operator + (const mint right) const noexcept {
      return mint(*this) += right;
    }
    constexpr mint operator - (const mint right) const noexcept {
      return mint(*this) -= right;
    }
    constexpr mint operator / (const mint right) const noexcept {
      return mint(*this) /= right;
    }
    constexpr mint operator * (const mint right) const noexcept {
      return mint(*this) *= right;
    }
    constexpr mint inv() const {
      return pow(MOD-2);
    }
    constexpr mint pow(ll n) const {
      if (n == 0) return 1;
      mint a = pow(n>>1);
      a *= a;
      if (n & 1) a *= *this;
      return a;
    }
};

mint dp[2020];

signed main()
{
  cout << fixed << setprecision(20);
  ios::sync_with_stdio(false);
  cin.tie(0);

  dp[0] = 1;

  int s; cin >> s;
  rep(i, s) rep2(j, i+3, s) dp[j] += dp[i];

  cout << dp[s].value() << endl;

  return (0);
}


Measured memory_bytes: 3660
import java.io.*;
import java.util.*;
import java.util.function.*;

final class Solver {
	static final Solver INSTANCE = new Solver();

	void solve(Supplier<String> sc) {
		int N = Integer.parseInt(sc.get());
		int[] A = new int[N];
		Arrays.setAll(A, $ -> Integer.parseInt(sc.get()));
		var R = new long[N];

		for (int i = 0; i < A.length; i++) {
			var r = i - A[i];
			if (r < 0) continue;
			R[r]++;
		}

		long count = 0;
		for (int i = 0; i < A.length; i++) {
			var l = i + A[i];
			if (l >= R.length) continue;
			count += R[l];
		}

		System.out.println(count);
	}
}

class Main {
	public static void main(String... args) {
		System.setOut(new PrintStream(new BufferedOutputStream(System.out)));
		var reader = new BufferedReader(new InputStreamReader(System.in));
		Solver.INSTANCE.solve(new Supplier<>() {
			StringTokenizer line;

			public String get() {
				while (line == null || !line.hasMoreTokens()) try {
					line = new StringTokenizer(reader.readLine());
				} catch (IOException e) {
					throw new UncheckedIOException(e);
				}
				return line.nextToken();
			}
		});
		System.out.flush();
	}
}

Measured memory_bytes: 54916
#include <stdio.h>
#include <string.h>
int main() {
	char vetor[5];
	scanf("%s",vetor);
	
	if(strcmp(vetor,"SUN")==0)
	    printf("7\n");
	else if(strcmp(vetor,"MON")==0)
	    printf("6\n");
	else if(strcmp(vetor,"TUE")==0)
	    printf("5\n");
	else if(strcmp(vetor,"WED")==0)
	    printf("4\n");
	else if(strcmp(vetor,"THU")==0)
	    printf("3\n");
	else if(strcmp(vetor,"FRI")==0)
	    printf("2\n");
	else
        printf("1\n");
	return 0;
}

Measured memory_bytes: 128
N, A, B = list(map(int, input().split()))
S = input()
passed_all = 0
passed_foreign = 0

for s in S:
    if s == 'a':
        if passed_all < A + B:
            passed_all += 1
            print('Yes')
        else:
            print('No')
    elif s == 'b':
        if passed_all < A + B and passed_foreign < B:
            passed_all += 1
            passed_foreign += 1
            print('Yes')
        else:
            print('No')
    elif s == 'c':
        print('No')

Measured memory_bytes: 4016
import java.util.Scanner;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    long n = sc.nextLong();
    int ans = String.valueOf(n).length();
    
    for (long i = 1; i * i <= n; i++) {
      final int length = String.valueOf(n / i).length();
      if (n % i == 0 && length < ans) {
        ans = length;
      }
    }
    System.out.println(ans);
  }
}


Measured memory_bytes: 28500
#include<iostream>
#include<stdio.h>
//#include <bits/stdc++.h>
#include<vector>
#include<float.h>
#include<iomanip>
#include<algorithm>
#include<string>
#include<cstring>
#include<math.h>
#include<cmath>
#include<sstream>
#include<set>
#include<map>
#include<queue>
#include <cassert>
#include <cmath>
#include<cstdint>

#define INF 1e9
#define rep(i,n)for(int i=0;(i)<(int)(n);i++)
#define REP(i,a,b)for(int i=(int)(a);(i)<=(int)(b);i++)
#define VEC(type, c, n) std::vector<type> c(n);for(auto& i:c)std::cin>>i;
#define vec(type,n) vector<type>(n)
#define vvec(m,n) vector<vector<int>> (int(m),vector<int>(n))
#define ALL(a)  (a).begin(),(a).end()

using namespace std;
using ll = long long;
using Graph = vector<vector<int>>;
using P = pair<int,int>;

vector<int>bitSearch(int bit,int n){
    vector<int>S;
    rep(i,n)if(bit&(1<<i))S.push_back(i);
    return S;
}


int d[3] = {-1,0,1};
int main(){
   int a,b,c;cin>>a>>b>>c;
   cout<<(c>=a && c<=b?"Yes":"No");
}



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

using namespace std;

typedef long long ll;
#define REP(i, n) for(int i = 0; i < (int)(n); ++i)
#define REPe(i, n) for(int i = 0; i <= (int)(n); ++i)
#define REPi(i, a, b) for(int i = int(a); i < int(b); ++i)
#define REPei(i, a, b) for(int i = int(a); i <= int(b); ++i)

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

    int a, b, c;
    cin >> a >> b;
    if(a & 1 && b & 1) cout << "Yes" << endl;
    else cout << "No" << endl;

}



Measured memory_bytes: 256
import collections

n = int(input())

s = []

for _ in range(n):
    s.append(input())

s_total = dict(collections.Counter(s))

print("AC x", s_total.get("AC", default=0))
print("WA x", s_total.get("WA", default=0))
print("TLE x", s_total.get("TLE", default=0))
print("RE x", s_total.get("RE", default=0))

Measured memory_bytes: 78596
if __name__ == "__main__":
    N, M = map(int, input().split())
    ksl = list()
    for _ in range(M):
        ksl.append(list(map(int, input().split())))
    p = list(map(int, input().split()))

    ans = 0
    for i in range(2 ** N):
        flag = str(format(i, 'b').zfill(N))
        flag = flag[::-1]
        is_Lightup = True
        for j in range(M):
            count = 0
            for k in range(ksl[j][0]):
                count += int(flag[ksl[j][k+1] - 1])
            if count % 2 != p[j]:
                is_Lightup = False
                break
        if is_Lightup:
            ans += 1

    print(ans)


Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
int main() {
  int N;
  cin >> N;
  int a[2][N];
  rep(i, 2){
  	rep(j, N) cin >> a[i][j];
  }
  
  int max = 0;
  rep(i, N){
  	int sum = 0;
    rep(j, N){
    	if(i == j) sum = sum + a[0][j] + a[1][j];
        else if(j < i) sum += a[0][j];
      	else sum += a[1][j];
    }
    if(max < sum) max = sum;
  }
  
  cout << max << endl;
  return 0;
  
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define maxN 305
using namespace std;
long long sp[maxN*maxN];
int h,w,d,x;
int sol[maxN*maxN];
pair<int,int> p[maxN*maxN];
int main()
{
    cin>>h>>w>>d;
    for(int i=1;i<=h;i++)
        for(int j=1;j<=w;j++)
    {
        cin>>x;
        p[x]={i,j};
    }


    for(int i=1;i<=(h*w-d);i++)
    {
        sol[i]=abs(p[i].first-p[i+d].first)+abs(p[i].second-p[i+d].second);
    }

    for(int i=1;i<=d;i++)
    {
        for(int j=i+d;j<=h*w;j+=d)
            sp[j]=(sp[j-d]+1LL*sol[j-d]);
    }
    int q,l,r;
     cin>>q;
    for(int i=1;i<=q;i++)
    {
        cin>>l>>r;
        cout<<sp[r]-sp[l]<<'\n';
    }
    return 0;
}


Measured memory_bytes: 2944
#include<stdio.h>
    int main()
    {
       int ara[100000],n,k;
       scanf("%d%d",&n,&k);
       for(int i=0;i<n;i++){
        scanf("%d",&ara[i]);
       }
       for(int j=0;j<n;j++){
        int temp,index=j;
        for(int k=j+1;k<n;k++){
            if(ara[k]<ara[index]) index=k;
        }
        if(index!=j){
            temp=ara[j];
            ara[j]=ara[index];
            ara[index]=temp;
        }
       }
       int sum=0;
       for(int l=0;l<k;l++){
        sum=sum+ara[l];
       }
       printf("%d",sum);
        return 0;
    }


Measured memory_bytes: 1724
#include<cstdio>
#include<algorithm>
#include<functional>
using namespace std;
int main()
{
	int n,a[200000],b[200000],x,y,i;
	scanf("%d",&n);
	for(i=0;i<n;i++){
		scanf("%d",&a[i]);
		b[i]=a[i];
	}
	sort(b,b+n,greater<int>());
	x=b[0];
	y=b[1];
	for(i=0;i<n;i++){
		if(a[i]==x)	printf("%d\n",y);
		else	printf("%d\n",x);
	}
	return 0;
}

Measured memory_bytes: 3072
#include<bits/stdc++.h>
#define r(i,n) for(int i=0;i<n;i++)
using namespace std;
typedef pair<vector<int>,int>P;
vector<int>v[13],s(13),t(13);
map<vector<int>,int>m;

int has[14];


void init(){

    v[0].push_back(2);

    v[1].push_back(2);
    v[1].push_back(5);

    v[2].push_back(0);
    v[2].push_back(1);
    v[2].push_back(3);
    v[2].push_back(6);

    v[3].push_back(2);
    v[3].push_back(7);

    v[4].push_back(5);

    v[5].push_back(1);
    v[5].push_back(4);
    v[5].push_back(6);
    v[5].push_back(9);

    v[6].push_back(2);
    v[6].push_back(5);
    v[6].push_back(7);
    v[6].push_back(10);

    v[7].push_back(3);
    v[7].push_back(6);
    v[7].push_back(8);
    v[7].push_back(11);

    v[8].push_back(7);

    v[9].push_back(5);
    v[9].push_back(10);

    v[10].push_back(6);
    v[10].push_back(9);
    v[10].push_back(11);
    v[10].push_back(12);

    v[11].push_back(7);
    v[11].push_back(10);

    v[12].push_back(10);

    int a=20;
    int p=1;

    r(i,13){
        has[i]=p;
        p*=a;
    }
}

int ha(vector<int> &x){

    int re=0;

    r(i,13){
        re+=x[i]*has[i];
    }

    return re;
}

vector<int> ah(int x){
    vector<int>y(13);
    r(i,13){
        y[i]=x%20;
        x/=20;
    }
    return y;
}

void BFS1(){
    s[0]=0;
    s[12]=0;
    r(i,11)s[i+1]=i+1;
    set<vector<int> >st;
    st.insert(s);
    m[s]=0;
    queue<P>q;
    q.push(P(s,0));
    while(1){
        vector<int> now=q.front().first;
        int cost=q.front().second;
        q.pop();
        if(cost==10)break;
        //cout<<m.size()<<' '<<cost<<endl;
        r(i,13)if(now[i]==0){
            r(j,v[i].size()){
                swap(now[i],now[v[i][j]]);
                if(!st.count(now)){
                    st.insert(now);
                    m[now]=cost+1;
                    q.push(P(now,cost+1));
                }
                swap(now[i],now[v[i][j]]);
            }
        }
    }
}

void BFS2(){
    set<vector<int> >st;
    st.insert(t);
    queue<P>q;
    q.push(P(t,0));
    while(1){
        vector<int>now=q.front().first;
        int cost=q.front().second;
        q.pop();
        if(m.count(now)){
            cout<<m[now]+cost<<endl;
            return ;
        }
        if(cost==10)break;
        r(i,13)if(now[i]==0){
            r(j,v[i].size()){
                swap(now[i],now[v[i][j]]);
                if(!st.count(now)){
                    st.insert(now);
                    if(m.count(now)){
                        cout<<m[now]+cost+1<<endl;
                        return ;
                    }
                    q.push(P(now,cost+1));
                }
                swap(now[i],now[v[i][j]]);
            }
        }
    }
    cout<<"NA"<<endl;
}


signed main(){
    init();
    BFS1();
    while(cin>>t[0],t[0]!=-1){
        r(i,12)cin>>t[i+1];
        BFS2();
    }
}


Measured memory_bytes: 8280
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for (int i = 0; i < static_cast<int>(n); ++i)
#define REPR(i, n) for (int i = static_cast<int>(n) - 1; i >= 0; --i)
#define FOR(i, a, b) \
  for (int i = static_cast<int>(a); i < static_cast<int>(b); ++i)
#define FORR(i, a, b) \
  for (int i = static_cast<int>(b) - 1; i >= static_cast<int>(a); --i)
#define ALL(f, x, ...) \
  ([&](auto& y) { return (f)(begin(y), end(y), ##__VA_ARGS__); })(x)
auto INDEX = [](auto& x, auto& xs) { return &x - &xs[0]; };
void async_io() {
  cin.tie(0);
  ios::sync_with_stdio(false);
}
const auto inf = INT_MAX / 3;
const auto pi = 2 * std::acos(0.0);
const auto eps = 1e-14;
using ll = signed long long;
using ull = unsigned long long;

signed main() {
  async_io();
  int n;
  while (true) {
    cin >> n;
    if (n == 0) return 0;
    auto sum = 0;
    for (int i = 2;; i++) {
      auto base = i * (i + 1) / 2;
      if (base > n) break;
      if ((base - n) % i == 0) sum++;
    }
    cout << sum << "\n";
  }
}

Measured memory_bytes: 3152
#include <float.h>
#include <math.h>
#include <stdio.h>
#include <stdlib.h>

int main (void) {
    int     i;
    int     n, t, a;
    int     h;
    float   temp, diff, min_diff=FLT_MAX;
    int     ans;

    scanf("%d%d%d", &n, &t, &a);

    for ( i=0; i<n; i++ ) {
        scanf("%d", &h);
        temp = t - h * 0.006;
        diff = fabs(a-temp);
        if ( diff < min_diff ) {
            min_diff = diff;
            ans = i;
        }
    }

    printf("%d\n", ans+1);
    return EXIT_SUCCESS;
}


Measured memory_bytes: 128
#include <iostream>

class Dice
{
public:
    Dice(int s1, int s2, int s3, int s4, int s5, int s6);
    void rollE();
    void rollN();
    void rollS();
    void rollW();
    void rollR();
    void rollL();
    bool rollToTop(int v);
    bool rollToFrontHorizontal(int v);
    int getTop();
    int getRight();
private:
    int ms1, ms2, ms3, ms4, ms5, ms6;
};

Dice::Dice(int s1, int s2, int s3, int s4, int s5, int s6)
: ms1(s1), ms2(s2), ms3(s3), ms4(s4), ms5(s5), ms6(s6)
{}

void Dice::rollE() {
    int tmp = ms1;
    ms1 = ms4;
    ms4 = ms6;
    ms6 = ms3;
    ms3 = tmp;
}

void Dice::rollN() {
    int tmp = ms1;
    ms1 = ms2;
    ms2 = ms6;
    ms6 = ms5;
    ms5 = tmp;
}

void Dice::rollS() {
    int tmp = ms1;
    ms1 = ms5;
    ms5 = ms6;
    ms6 = ms2;
    ms2 = tmp;
}

void Dice::rollW() {
    int tmp = ms1;
    ms1 = ms3;
    ms3 = ms6;
    ms6 = ms4;
    ms4 = tmp;
}

void Dice::rollR() {
    int tmp = ms2;
    ms2 = ms4;
    ms4 = ms5;
    ms5 = ms3;
    ms3 = tmp;
}

void Dice::rollL() {
    int tmp = ms2;
    ms2 = ms3;
    ms3 = ms5;
    ms5 = ms4;
    ms4 = tmp;
}

bool Dice::rollToTop(int v) {
    bool ret = true;
    if (v == ms1) {
        // NOP
    } else if (v == ms2) {
        rollN();
    } else if (v == ms3) {
        rollW();
    } else if (v == ms4) {
        rollE();
    } else if (v == ms5) {
        rollS();
    } else if (v == ms6) {
        rollN();
        rollN();
    } else {
        ret = false;
    }
    return ret;
}

bool Dice::rollToFrontHorizontal(int v) {
    bool ret = true;
    if (v == ms1) {
        ret = false;
    } else if (v == ms2) {
        // NOP
    } else if (v == ms3) {
        rollL();
    } else if (v == ms4) {
        rollR();
    } else if (v == ms5) {
        rollR();
        rollR();
    } else if (v == ms6) {
        ret = false;
    } else {
        ret = false;
    }
    return ret;
}

int Dice::getTop() {
    return ms1;
}

int Dice::getRight() {
    return ms3;
}

int main(int argc, const char *argv[]) {
    int s1, s2, s3, s4, s5, s6;
    std::cin >> s1 >> s2 >> s3 >> s4 >> s5 >> s6;
    Dice dice(s1, s2, s3, s4, s5, s6);
    int q;
    std::cin >> q;
    int v1, v2;
    for (int i = 0; i < q; i++) {
        std::cin >> v1 >> v2;
        dice.rollToTop(v1);
        dice.rollToFrontHorizontal(v2);
        std::cout << dice.getRight() << std::endl;
    }
    return 0;
}

Measured memory_bytes: 3052
#include <iostream>

int gcd(int m,int n)
{
  if(m<n)
  {
    int t=m;
    m=n;
    n=t;
  }
  
  for(;;)
  {
    if(n==0)
      return m;
    
    int t=m%n;
    m=n;
    n=t;
  }
}

int main()
{
  int A,B,K;
  std::cin>>A>>B>>K;
  
  int g=gcd(A,B);
  
  int count=0;
  for(int i=g;i!=0;i--)
  {
    if(g%i==0)
    {
      count++;
      if(count==K)
      {
        std::cout<<i<<std::endl;
        break;
      }
    }
  }
  
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
// #include <boost/multiprecision/cpp_int.hpp> 

#define gc getchar//_unlocked
#define pc putchar//_unlocked
#define ll long long
#define ld long double
#define pb push_back
#define mp make_pair
#define pp pair<int,int>
#define ppl pair<ll,ll>
#define bigint boost::multiprecision::cpp_int
#define finp ios_base::sync_with_stdio(0);cin.tie(0);
#define bc __builtin_popcountll
#define afor(i,a,b) for(int i=a;i<=b;++i)
#define bfor(i,a,b) for(int i=a;i>=b;--i)
#define vi vector<int>
#define vpp vector<pp>
#define vll vector<ll>

using namespace std;
using namespace __gnu_pbds;

char putnb[20];
void putn(ll n) {if(!n)pc('0');if(n<0)pc('-'),n=0-n;int pi=0;while(n)putnb[pi++]=(n%10)+'0',n/=10;while(pi)pc(putnb[--pi]);}
void sci(int *x) {register char c = gc();*x = 0;for(; (c<48)||(c>57);c = gc());for(; (c>47)&&(c<58);c = gc())*x = (int)((((*x)<<1) + ((*x)<<3)) + c - 48);}
void scll(ll *x)  {register char c = gc();*x = 0;for(; (c<48)||(c>57);c = gc());for(; (c>47)&&(c<58);c = gc())*x =  (ll)((((*x)<<1) + ((*x)<<3)) + c - 48);}
ll fp(ll a,ll b,ll c) {if(b==0)return 1%c; if(b==1)return a%c; ll ret=fp(a,b/2,c); ret=(ret*ret)%c; if(b&1)ret=(ret*a)%c; return ret;}

const ll mod=1e9 +7;
const ll mod2=1999999973;
const ll inf=1e18;
const int infs=1e9 + 1000;
const int N=100000;
const long double PI = acos(-1);

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


int main()
{
  finp;
 string s1,s2,s3;
 cin>>s1>>s2>>s3;
 cout<<"A"<<s2[0]<<"C"; 
return 0;
}

Measured memory_bytes: 256
import numpy as np

N = int(input())
A = list(map(int, input().split()))
A.sort()
cumsum = np.cumsum(A)
ans = 1

for i in range(N - 2, -1, -1):
    if cumsum[i] * 2 >= A[i + 1]:
        ans += 1
    else:
        break

print(ans)


Measured memory_bytes: 23088
#include<bits/stdc++.h>
#define int long long // at least int64 > 9*10^18
#define ENDL '\n'
#define rep(i,n) for(int i = 0; i < (n); i++)
#define print(i) std::cout << (i) << '\n'
#define all(v) (v).begin(), (v).end()
using namespace std;
signed main(){
  int k,n;
  cin>>k>>n;
  vector<int> a(n);
  vector<int> b(n);
  rep(i,n){
    cin>>a[i];
  }
  a.push_back(k+a[0]);
  
  rep(i,n){
    b[i]=a[i+1]-a[i];
  }
  sort(all(b));
  reverse(all(b));
  int d=k-b[0];
  cout<<d<<endl;
}

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

using namespace std;

#define ll long long

int main()
{
	ll N;
	cin >> N;
	vector < ll > a(N);
	for (int i = 0; i < N; i++) {
		cin >> a[i];
	}

	ll ans = 0;
	for (int i = 0; i < N; i++) {
		ans += a[i] - 1;
	}

	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 256
fun main(args: Array<String>) {
    agc032a()
}

fun agc032a() {
    val n = readLine()!!.toInt()
    val bList = readLine()!!.split(" ").map { it.toInt() }
        .toMutableList()

    val manipulation = mutableListOf<Int>()
    while (bList.isNotEmpty()) {
        val target = bList.withIndex().findLast { iv ->
            val (index, b) = iv
            index + 1 == b
        }
        if (target != null) {
            bList.removeAt(target.index)
            manipulation.add(target.value)
        } else return println(-1)
    }

    println(manipulation.reversed().joinToString(System.lineSeparator()))
}


Measured memory_bytes: 37936
#include<bits/stdc++.h>
using namespace std;
#define ll long long 
#define INF 999999999
#define rep(i,n) for(int i=0;i<n;i++)
const int MOD = 1000000007;

int main(){
    ll l,r; cin >> l >> r;
    ll minimam=INF;
    if(r-l>=2018){
        cout << 0 << endl;
        return 0;
    }

        for(ll i=l;i<=r;i++){
            for(ll j=i+1;j<=r;j++){

                if( (i*j) % 2019 < minimam){
                    minimam = (i*j) % 2019;
                }
                

            }
        }

    
    cout << minimam << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
using namespace std;
typedef long long ll;
int main(){
  ll q;
  cin>>q;
  for(ll i=0;i<q;i++){
    ll a,b;
    cin>>a>>b;
    if(a==1&&b==1){
      cout<<0<<endl;
      continue;
    }
    if(a<b) swap(a,b);
    ll ans=b-1,lb=0,rb=a-1,sk=a*b-1;
    while(rb-lb>1){
      ll mid=(lb+rb)/2;
      if(mid*mid+mid<=sk){
        lb=mid;
      }
      else rb=mid;
    }
    ans+=lb;
    ans+=(sk/rb)-b;
    cout<<ans<<endl;
  }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define SORT(a) sort((a).begin(), (a).end())
#define RSORT(a) reverse((a).begin(), (a).end())
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
typedef long long ll;
const long long INF = 1LL << 60;

int main() {
  int N, M;
  cin >> N >> M;
  vector<vector<int> > s(M);
  for (int i = 0; i < M; ++i) {
    int k;
    cin >> k;
    for (int j = 0; j < k; ++j) {
      int a;
      cin >> a;
      --a;
      s[i].push_back(a);
    }
  }
  vector<int> p(M);
  for (int i = 0; i < M; ++i) cin >> p[i];

  long long res = 0;
  for (int bit = 0; bit < (1 << N); ++bit) {
    bool ok = true;
    for (int i = 0; i < M; ++i) {
      int con = 0;
      for (auto v : s[i]) {
        if (bit & (1 << v)) ++con;
      }
      if (con % 2 != p[i]) ok = false;
    }
    if (ok) ++res;
  }
  cout << res << endl;
}

Measured memory_bytes: 256
def calcTmp(T, height):
    Tmp = T - (0.006 * height)
    return Tmp

def main():
    N = int(input())
    (T, targetTMP) = map(int,input().split())
    heightlist = list(map(int,input().split()))
    nearestTmpdef = 1145141919
    nearestIdx = 0

    for i in range(N):
        tmp = calcTmp(T,heightlist[i])
        tmp_deff = abs(targetTMP - tmp)
        if tmp_deff < nearestTmpdef:
            nearestTmpdef = tmp_deff
            nearestIdx = i
    print(nearestIdx+1)

main()


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

int main() {
  int N, K;
  cin >> N >> K;

  int sum = 0; // 合計点を表す変数
  int x;       // 入力を受け取る変数
  int i = 0;   // カウンタ変数

  while (i < N) {
    cin >> x;
    if (x >= K) {
      sum++;
    }
    i++;
  }

  cout << sum << endl;
}


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

int main() {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  int n;
  cin >> n;
  vector<int> a(n), b(n);
  for(int i = 0; i < n; ++i) {
    cin >> a[i];
  }
  for(int i = 0; i < n; ++i) {
    cin >> b[i];
  }
  set<pair<int, int>> same;
  for(int i = 0; i < n; ++i) {
    if(a[i] == b[i]) {
      same.insert({a[i], i});
    }
  }
  while(same.size() && same.begin()->first != same.rbegin()->first) {
    assert(same.size() >= 2);
    swap(b[same.begin()->second], b[same.rbegin()->second]);
    same.erase(same.begin());
    same.erase(prev(same.end()));
  }
  if(same.size()) {
    int x = same.begin()->first;
    vector<int> free;
    for(int i = 0; i < n; ++i) {
      if(a[i] != x && b[i] != x) free.push_back(i);
    }
    if(same.size() > free.size()) {
      cout << "No\n";
      return 0;
    }
    for(auto [x_, i] : same) {
      swap(b[i], b[free.back()]);
      free.pop_back();
    }
  }
  cout << "Yes\n";
  for(int i = 0; i < n; ++i) {
    cout << b[i] << ' ';
  }
  cout << '\n';
}

Measured memory_bytes: 14284