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

using namespace std;

int main()
{
  int N, M, x;
  vector<int> X, D;

  cin >> N >> M;
  while (M--) {
    cin >> x;
    X.push_back(x);
  }
  sort(X.begin(), X.end());
  for (int i = 1; i < X.size(); i++) {
    D.push_back(X[i] - X[i - 1]);
  }
  sort(D.begin(), D.end());
  int result = 0;
  for (int i = 0; i < (int) (X.size() - N); i++) {
    result += D[i];
  }
  cout << result;
}


Measured memory_bytes: 1400
N,M=map(int,input().split())
X=list(map(int,input().split()))
from collections import defaultdict
r=[defaultdict(int) for i in range(M)]
for x in X:
    r[x%M][x]+=1
a=sum(r[0].values())//2
for m in range(1,-(-M//2)):
    v1,v2=sum(r[m].values()),sum(r[M-m].values())
    if v1>v2:
        p=sum([e//2 for e in r[m].values()])
        a+=v2+min(p,(v1-v2)//2)
    else:
        p=sum([e//2 for e in r[M-m].values()])
        a+=v1+min(p,(v2-v1)//2)
if M%2==0:
    a+=sum(r[M//2].values())//2
print(a)

Measured memory_bytes: 38652
#include<iostream>
#include<vector>
#include<string>

using namespace std;
int main() {
    string s; cin >> s;
    string t; cin >> t;
    int n = s.size();
    int m = t.size();
    vector<vector<int>> dp((n+1), vector<int>(m+1));
    for (int i = 0; i < n; ++i) {   
        for (int j = 0; j < m; ++j) {
            if (s[i] == t[j]) {
                dp[i+1][j+1] = dp[i][j] + 1;
            } else {
                dp[i+1][j+1] = max(dp[i+1][j], dp[i][j+1]);
            }
        }
    }
    string ans = "";
    int i = n;
    int j = m;
    while (i > 0 && j > 0) {
        if (dp[i][j] == dp[i][j-1]) {
            --j;
        } else if (dp[i][j] == dp[i-1][j]) {
            --i;
        } else {
            ans = s[i-1] + ans;
            --i;
            --j;
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 35584
#include <iostream>
#include <vector>
#include <map>
#include <queue>
#include <string>
#include <algorithm>
#include <cmath>
#include <climits>
#define REP(i, n) for(int i=0; i<(n); i++)
#define FOR(i, a, n) for(int i=(a); i<(n); i++)
using namespace std;

int main(){
    int a,p;
    cin >> a >> p;
    cout << (3*a + p)/2 << endl;
    return 0;
}

Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.Closeable;
import java.io.FileInputStream;
import java.io.FileWriter;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.*;
import java.util.Map.Entry;
import java.util.stream.IntStream;

public class Main {
    static ContestScanner in;
    static Writer out;
    public static void main(String[] args) {
        Main main = new Main();
        try {
            in = new ContestScanner();
            out = new Writer();
            main.solve();
            out.close();
            in.close();
        } catch (IOException e) {
            e.printStackTrace();
        }
    }

    void solve() throws IOException {
        int n = in.nextInt();
        long T = in.nextLong();
        long pre = Integer.MIN_VALUE;
        long sum = 0;
        for(int i = 0; i < n; i++) {
            long t = in.nextInt();
            if(pre + T < t) {
                sum += T;
            } else {
                sum += t - pre;
            }
            pre = t;
        }
        System.out.println(sum);
    }
}


class Writer extends PrintWriter{
    public Writer(String filename)throws IOException
    {super(new BufferedWriter(new FileWriter(filename)));}
    public Writer()throws IOException{super(System.out);}
}
class ContestScanner implements Closeable{
    private BufferedReader in;private int c=-2;
    public ContestScanner()throws IOException
    {in=new BufferedReader(new InputStreamReader(System.in));}
    public ContestScanner(String filename)throws IOException
    {in=new BufferedReader(new InputStreamReader(new FileInputStream(filename)));}
    public String nextToken()throws IOException {
        StringBuilder sb=new StringBuilder();
        while((c=in.read())!=-1&&Character.isWhitespace(c));
        while(c!=-1&&!Character.isWhitespace(c)){sb.append((char)c);c=in.read();}
        return sb.toString();
    }
    public String readLine()throws IOException{
        StringBuilder sb=new StringBuilder();if(c==-2)c=in.read();
        while(c!=-1&&c!='\n'&&c!='\r'){sb.append((char)c);c=in.read();}
        return sb.toString();
    }
    public long nextLong()throws IOException,NumberFormatException
    {return Long.parseLong(nextToken());}
    public int nextInt()throws NumberFormatException,IOException
    {return(int)nextLong();}
    public double nextDouble()throws NumberFormatException,IOException
    {return Double.parseDouble(nextToken());}
    public void close() throws IOException {in.close();}
}

Measured memory_bytes: 41324
#include <cmath>
#include <cstdio>
#include <cstring>
#include <iostream>
#include <algorithm>
#define DB double
#define SG string
#define LL long long
#define Fp(A,B,C,D) for(A=B;A<=C;A+=D)
#define Fm(A,B,C,D) for(A=B;A>=C;A-=D)
using namespace std;
const LL Mod=1e9+7;
const LL Max=1e3+5;
const LL Inf=1e18;
inline LL Read(){
	LL X=0;char CH=getchar();bool F=0;
	while(CH>'9'||CH<'0'){if(CH=='-')F=1;CH=getchar();}
	while(CH>='0'&&CH<='9'){X=(X<<1)+(X<<3)+CH-'0';CH=getchar();}
	return F?-X:X;
}
inline void Write(LL X){
	if(X<0)X=-X,putchar('-');
	if(X>9)Write(X/10);
	putchar(X%10+48);
}
int main(){
	LL I,J,K;
	LL A=Read(),B=Read();
	Write(max(A-B,max(A+B,A*B)));
	return 0;
}


Measured memory_bytes: 256
import bisect

n, d, a = map(int, input().split())
xh = []
for i in range(n):
    xh.append(list(map(int, input().split())))
xh.sort()
x = [xh[i][0] for i in range(n)]
h = [xh[i][1] for i in range(n)]
count = 0
min_x = 0
acm = [0] * (n + 1)
dif = [0] * (n + 1)
while min_x < n:
    place = x[min_x] + d
    num = (h[min_x] - acm[min_x + 1] - 1) // a + 1
    count += num
    dif[min_x] += num
    dif[bisect.bisect(x, place + d)] -= num
    for i in range(min_x, bisect.bisect(x, place + d)):
        acm[i + 1] = acm[i] + dif[i] * a
        if acm[i + 1] >= h[i]:
            min_x += 1
            continue
        else:
            break
print(count)

Measured memory_bytes: 67700
#coding: utf-8
import sys
def input():
    return sys.stdin.readline()[:-1]
"""
整数 Nが9の倍数であることと、Nを十進法で表したときの各桁の数の和が9の倍数であることは同値です。
Nが9の倍数であるか判定してください。
"""
N = int(input())
N = str(N)
v = 0
for n in N:
    v += int(n)
if v%9==0:
    print("Yes")
else:
    print("No")

Measured memory_bytes: 70944
#include <math.h>
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <assert.h>
#include <limits.h>
#include <stdbool.h>

int main(){
	int w,al,bl;
	int ar,br;
	scanf("%d%d%d",&w,&al,&bl);
	ar=al+w;
	br=bl+w;
	
	if(bl>=al && bl<=ar){
		puts("0");
	}else if(br>=al&&br<=ar){
		puts("0");
	}else if(bl>ar){
		printf("%d\n",bl-ar);
	}else if(br<al){
		printf("%d\n",al-br);
	}
	
    return 0;
}


Measured memory_bytes: 128
import itertools

n=int(input())
p=input().split()
q=input().split()

str_p = ''.join(p)
str_q = ''.join(q)

n_list=[]
for _ in range(1,n+1):
  n_list.append(str(_))
list_t= list(itertools.permutations(n_list))

str_list=['']*len(list_t)
for i in range(len(list_t)):
  _temp = list_t[i]
  _str=''.join(_temp)
  str_list[i]=_str
str_list.sort()

dif=abs(str_list.index(str_p)-str_list.index(str_q))
print(dif)

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

int main() {
    int N;
    cin >> N;
    vector<int> a(N);
    rep(i, N) cin >> a.at(i);

    sort(a.begin(), a.end());

    int AliceSum = 0, BobSum = 0;
    while (true) {
        AliceSum += a.back();
        a.pop_back();
        if (a.size() == 0) break;

        BobSum += a.back();
        a.pop_back();
        if (a.size() == 0) break;
    }

    int ans = AliceSum - BobSum;

    cout << ans << endl;

    return 0;
}


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

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

    string S;
    cin >> S;
    int N = S.size();

    int ans = N;
    for (int i = 1; i < N; ++i) {
        if (S.at(i - 1) != S.at(i)) {
            ans = min(ans, max(i, N - i));
        }
    }
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 512
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cctype>
#include <cmath>
#include <cstdint>
#include <cstdio>
#include <cstring>
#include <deque>
#include <fstream>
#include <functional>
#include <iostream>
#include <limits>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <vector>
using namespace std;
using ll = long long;
#define fst first
#define snd second

/* clang-format off */
template <class T, size_t D> struct _vec { using type = vector<typename _vec<T, D - 1>::type>; };
template <class T> struct _vec<T, 0> { using type = T; };
template <class T, size_t D> using vec = typename _vec<T, D>::type;
template <class T> vector<T> make_v(size_t size, const T& init) { return vector<T>(size, init); }
template <class... Ts> auto make_v(size_t size, Ts... rest) { return vector<decltype(make_v(rest...))>(size, make_v(rest...)); }
template <class T> inline void chmin(T &a, const T& b) { if (b < a) a = b; }
template <class T> inline void chmax(T &a, const T& b) { if (b > a) a = b; }
/* clang-format on */

int main() {
#ifdef DEBUG
  ifstream ifs("in.txt");
  cin.rdbuf(ifs.rdbuf());
#endif
  int N, K;
  while (cin >> N >> K) {
    if (K > (N - 2) * (N - 1) / 2) {
      cout << -1 << endl;
      continue;
    }
    int s = 0;
    vec<int, 2> G(N);
    int M = 0;
    for (int i = 1; i < N; i++) G[0].push_back(i), ++M;
    int num = (N - 2) * (N - 1) / 2;
    for (int i = 1; i < N; i++) {
      for (int j = i + 1; j < N && num > K; j++) {
        G[i].push_back(j);
        --num;
        ++M;
      }
    }
    cout << M << endl;
    for (int i = 0; i < N; i++) {
      for (int j : G[i]) {
        cout << i + 1 << " " << j + 1 << endl;
      }
    }
  }
  return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<cctype>
#include<stdio.h>
using namespace std;

int main(){

  char ch;

  while(1){
    scanf("%c",&ch);
    if(isalpha(ch)){
  
    if(isupper(ch)){

      printf("%c",tolower(ch));
    }

  else if(islower(ch)){

      printf("%c",toupper(ch));

    }
  }
   else cout << ch;

    if(ch == '\n') break;
}
}

Measured memory_bytes: 1116
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <cmath>
#include <queue>
#include <climits>
#include <set>
#include <map>
#include <stack>
#include <iomanip>
#include <tuple>
#define ll long long
#define rep(i,s,n) for(ll i = (ll)(s); i < (ll)(n); i++)
#define all(a) (a).begin(),a.end()
using namespace std;
using graph =vector<vector<ll>>;
/*階乗*/
ll factorial(ll n){
    if(n==0){
        return 1;
    }
    else{
        return n*factorial(n-1);
    }
}

/* ユークリッドの互除法 最大公約数*/
ll gcd(ll a, ll b) {
	ll r;
	r = a % b;
	while (r != 0) {
		a = b;
		b = r;
		r = a % b;
	}
	return b;
}



/*最小公倍数*/

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


/*二点間の距離*/
double dist(pair<double,double> a,pair<double,double> b){
	return sqrt(pow((a.first - b.first) ,2) + pow((a.second - b.second),2));
}

//繰り返し自乗法
double ism(double aa,ll p){
    double ap=aa;
    double ans=1;
    while(p>0){
        //cout<<"p="<<p<<",ap="<<ap<<endl;
        if(p&1){//奇数が真
            ans*=ap;
        }
        p/=2;
        ap=ap*ap;
    }
    return ans;

}
//繰り返し自乗法(アマリトリバージョン)
ll ismm(ll aa,ll p,ll m){
    ll ap=aa;
    ll ans=1;
    while(p>0){
        //cout<<"p="<<p<<",ap="<<ap<<endl;
        if(p&1){//奇数が真
            ans=(ans*ap)%m;    
        }
        p/=2;              
        ap=(ap*ap)%m;
    }
    return ans;

}
/*
ll solve(ll i,ll m,vector<ll>t,ll n){
    if(m==0){
        return 1;
    }
    if(i>=n){
        return 0;
    }
    
    
    cout<<i+1<<" "<<m<<endl;
    cout<<i+1<<" "<<m-t[i]<<endl;
    ll res=solve(i+1,m,t,n)||solve(i+1,m-t[i],t,n);
    return res;
}
*/

//小数点12桁
struct all_init
{
    all_init()
    {
        cout << fixed << setprecision(12);
    }
} All_init;


int main()
{
    ll a1,b1,m;
    cin>>a1>>b1>>m;
    vector<ll>a(a1),b(b1);
    for(ll i=0;i<a1;i++){
        cin>>a[i];
    }
    for(ll i=0;i<b1;i++){
        cin>>b[i];
    }
    vector<ll>x(m),y(m),c(m);
    for(ll i=0;i<m;i++){
        cin>>x[i]>>y[i]>>c[i];
    }
    ll t;
    ll ma=LLONG_MAX;
    ll mb=LLONG_MAX;
    ll o=LLONG_MAX;
    for(ll i=0;i<a1;i++){
       ma=min(ma,a[i]);
    }

    for(ll j=0;j<b1;j++){
        mb=min(mb,b[j]);
    }
    for(ll i=0;i<m;i++){

            //cout<<o<<endl;
        o=min({a[x[i]-1]+b[y[i]-1]-c[i],o,ma+mb});
        
    }
    //cout<<a[0]+b[1]<<endl;
    cout<<o<<endl;


    

}


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


int main (){
    int N, K;
    cin>>N>>K;
    if(N<6){
        cout<<0<<endl;
    }
    else if(N<13){
        cout<<K/2<<endl;
    }
    else{
        cout<<K<<endl;
    }
    
}

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

using namespace std;

vector<char> word;

void remainder(long long int n){
    if(n!=0){
    if(n/26<1){
        word.push_back('a'+n%26-1);
    }
    else if(n/26>=1){
        if((n%26)==0){
            word.push_back('z');
            if(n>26)
            remainder((n-26)/26);
            else
            return;
        }
        else{
            word.push_back('a'+n%26-1);
            remainder(n/26);
        }
    }
    }
    else
    {
        return;
    }
}

int main(){
    long long int num;
    cin>>num;
    remainder(num);
    for(int i=word.size()-1; i>=0; i--)
    cout<<word[i];
    return 0;
}

Measured memory_bytes: 3572
import java.util.*;

public class Main{
  
  public static void main(String[] args){
    
    Scanner sc = new Scanner(System.in);
    
    int H = sc.nextInt();
    int W = sc.nextInt();
    String[] str = new String[H];
    for(int i = 0; i < H; i++){
      str[i] = sc.next();
    }
  
    char[][] wb = new char[H][W];
   
    for(int i = 0; i < H; i++){
      String s = str[i];
      for(int j = 0; j < W; j++){
        wb[i][j] = s.charAt(j);
      }
    }
  
  int count1 = 0;
  for(int i = 0; i < H; i++){
    for(int j = 0; j < W; j++){
        if(wb[i][j] == '.'){
          count1++;
        }
     }
    if(count1 == W){
      for(int k = 0; k < W; k++){
        wb[i][k] = '&';
      }
    }
    count1 = 0;
  }
     
  int count2 = 0;
  for(int j = 0; j < W; j++){
    for(int g= 0; g < H; g++){
        if(wb[g][j] == '.' || wb[g][j] == '&'){
          count2++;
        }
      }
    if(count2 == H){
      for(int k = 0; k < H; k++){
        wb[k][j] = '&';
      }
    }
    count2 = 0;
  } 
    int countAnd = 0;
    for(int h = 0; h < H; h++){
        for(int j = 0;j < W; j++){
          if(wb[h][j] == '&'){
            countAnd++;
          }else{
            System.out.print(wb[h][j]);
          }
        }
      
      if(countAnd == W){
        
      }else{
        System.out.println();
      }
      
      countAnd = 0;
    }
    
  }  
}

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

int main(void){
  int sum, price[10], pay;
  while(1){
    sum = 0;
    scanf("%d", &pay);
    if(pay == 0) break;
    for(int i = 0; i < 9; i++){
      scanf("%d", &price[i]);
      sum += price[i];
    }
    price[9] = pay - sum;
    printf("%d\n", price[9]);
  }
  return 0;
}

Measured memory_bytes: 1188
def gcd(a, b):
    while a > 0:
        if a < b:
            a, b = b, a
        a = a % b
    return b

n, x = map(int, input().split())
town = list(map(int, input().split()))

res = abs(town[0] - x)
for t in town[1:]:
    d = abs(t - x)
    res = gcd(res, d)

print(res)

Measured memory_bytes: 14224
#include <algorithm>
#include <iostream>

using namespace std;

int main() {
  for (;;) {
    int n;
    cin >> n;
    if (!n) return 0;
    pair<int, pair<int, long long> > es[4001];
    for (int i = 1; i <= 4000; i++) {
      es[i].first = 5000;
      es[i].second.first = i;
      es[i].second.second = 0;
    }
    for (int i = 0; i < n; i++) {
      int id;
      long long v, c;
      cin >> id >> v >> c;
      es[id].first = min(es[id].first, i);
      es[id].second.second += v * c;
    }
    sort(es+1, es+4001);
    bool f = false;
    for (int i = 1; i <= 4000; i++)
      if (es[i].second.second >= 1000000) {
        f = true;
        cout << es[i].second.first << endl;
      }
    if (!f)
      cout << "NA" << endl;
  }
}

Measured memory_bytes: 0
import java.util.Arrays;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int M = sc.nextInt();
		int X = sc.nextInt();
		int Y = sc.nextInt();
		int x[] = new int[N];
		int y[] = new int[M];
		for (int i=0;i<N;i++) {
			x[i] = sc.nextInt();
		}
		for (int i=0;i<M;i++) {
			y[i] = sc.nextInt();
		}
		Arrays.parallelSort(x);
		Arrays.parallelSort(y);
		for (int i=X+1;i<=Y;i++) {
			if (x[N-1]<i&&y[0]>=i) {
				System.out.println("No War");
				return ;
			}
		}
		System.out.println("War");
	}
}

Measured memory_bytes: 36236
import bisect, collections, copy, heapq, itertools, math, string, sys
input = lambda: sys.stdin.readline().rstrip() 
sys.setrecursionlimit(10**7)
INF = float('inf')
MOD = 10**9 + 7
def I(): return int(input())
def F(): return float(input())
def SS(): return input()
def LI(): return [int(x) for x in input().split()]
def LI_(): return [int(x)-1 for x in input().split()]
def LF(): return [float(x) for x in input().split()]
def LSS(): return input().split()

def resolve():
    n, k = LI()

    dp = [[0] * (k + 1) for _ in range(n + 1)]
    for i in range(k + 1):
        dp[0][i] = 1

    for i in range(n):
        for j in range(k):
            if i - j >= 0:
                dp[i+1][j+1] = dp[i+1][j] + dp[i-j][j+1]
            else:
                dp[i+1][j+1] = dp[i+1][j]
            dp[i+1][j+1] %= MOD

    print(dp[-1][-1])

if __name__ == '__main__':
    resolve()



Measured memory_bytes: 45724
#include <iostream>
#include <string>
using namespace std;
int main() {
	string s;
	cin >> s;
	for (int i = 0; i < 8; i++) {
		int num = s[0] - '0';
		for (int j = 0; j < 3; j++) {
			if (i & 1 << j)
				num += s[j + 1] - '0';
			else
				num -= s[j + 1] - '0';
		}
		if (num == 7) {
			for (int j = 0; j < 3; j++)
				cout << s[j] << (i & 1 << j ? '+' : '-');
			cout << s[3] << "=7\n";
			return 0;
		}
	}
}

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

using namespace std;

int main() {
  int ret = 0;
  char ch;
  for (bool i = false; std::cin >> ch; i = !i) {
    if (i) {
      if (ch == 'g') {
        ret++;
      }
    } else {
      if (ch == 'p') {
        ret--;
      }
    }
  }
  std::cout << ret << std::endl;
  return 0;
}


Measured memory_bytes: 256
import java.util.*;
public class Main {
    public static void main(String args[]) {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int[] nums = new int[10];
        for(int i=0;i<N;i++)
        {
            int a=0;
            int b = 0;
            boolean flag = true;
            for(int j=0;j<10;j++)
            {
                int t = sc.nextInt();
                if(t>a&& t> b)
                {
                    if(a>b)
                        a = t;
                    else
                        b = t;
                }   
                else if(t>a)
                    a = t;
                else if(t>b)
                    b = t;
                else
                    flag = false;
            }
            if(flag)
            {
                System.out.println("YES");
            }
            else
            {
                System.out.println("NO");
            }
        }
    }
}



Measured memory_bytes: 26228
import java.util.*;

class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int P = sc.nextInt();
        int[] A = new int[n];
        for(int i=0;i<n;i++) A[i]=sc.nextInt();
        long[] odd = new long[n];
        long[] even = new long[n];
        odd[0]=A[0]%2==1?1:0;
        even[0]=A[0]%2==1?0:1;
        for(int i=1;i<n;i++){
            odd[i]=odd[i-1];
            even[i]=even[i-1];
            if(A[i]%2==1){
                even[i]+=odd[i-1];
                odd[i]+=even[i-1]+1;
            }else{
                even[i]+=even[i-1]+1;
                odd[i]+=odd[i-1];
            }
        }
        long ans = P==1?odd[n-1]:even[n-1]+1;
        System.out.println(ans);
    }
}


Measured memory_bytes: 23764
n = int(input())
if 2 <= n < 4:
  print(2)
elif 4 <= n < 8:
  print(4)
elif 8 <= n < 16:
  print(8)
elif 16 <= n < 32:
  print(16)
elif 32 <= n < 64:
  print(32)
elif 64 <= n:
  print(64)
else:
  print(1)

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

using namespace std;

#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 each(i,c) for(__typeof((c).begin()) i = (c).begin(); i != (c).end(); ++i)
#define all(v) v.begin(), v.end()
#define mset(a, n) memset(a, n, sizeof(a))

typedef long long ll;

const int INF = 1000000000;
const int MOD = 1000000007;

int main (){
	double n, k;
	cin >> n >> k;
	vector<int> a(n);
	rep(i, n) cin >> a[i];
	n--, k--;
	cout << ceil(n / k) << endl;
}



Measured memory_bytes: 640
'use strict'
function main(input) {
  input = input.trim().split('\n')
  const N = Number(input.shift())
  input = input[0].split(' ').map(v => Number(v)).sort((a, b) => a - b)

  const gcd = (a, b) => {
    return b ? gcd(b, a % b) : a
  }

  let ans = input[0]
  for (let i = 1; i < N; i++) {
    ans = gcd(ans, input[i])
  }
  console.log(ans)
}
main(require('fs').readFileSync('/dev/stdin', 'utf8'));


Measured memory_bytes: 30520
#include <bits/stdc++.h>
using namespace std ;
int main() {
  	int n ;
    cin >> n ;
  	if(n%2==0) cout << "0.5000000000" << endl ;
  	else cout << setprecision(11) << (double)(1.*(n+1)/2 / n) ;
	return 0 ;
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<cstring>
#include<vector>
using namespace std;
#define rep(i,j) for(int i = 0; i < (j); i++)
typedef vector<int> vi;
vi G[100];
bool memo[101];
int func(int s, int n) {
	int ret = n;
	if(memo[s]) return ret;
	memo[s] = true;
	rep(i, G[s].size()) {
		ret = max(ret, func(G[s][i], n + 1));
	}
	memo[s] = false;
	return ret;
}
int main() {
	int n;
	while(cin >> n,n) {
		rep(i, 100)G[i].clear();
		rep(i, n) {
			int a,b;
			cin >> a >> b;
			a--;b--;
			G[a].push_back(b);
			G[b].push_back(a);
		}
		int ans = -1;
		rep(i, 100) {
			memset(memo, 0, sizeof(memo));
			ans = max(ans, func(i, 0));
		}
		cout << ans << endl;
	}
	return 0;
}

Measured memory_bytes: 1216
#include<bits/stdc++.h>
#define rep(i, x, n) for(int i = x; i < n; i++)
#define repr(i, x, n) for(int i = x; i > n; i--)
#define pii pair<int,int>
#define ll long long
const long long iinf = 1e18;
const int inf = 1e9;
const int MOD = (1e6+3);
int dir4[4][2] = {{1,0},{-1,0},{0,1},{0,-1}};
int knight[8][2] = {{2,1},{2,-1},{-2,1},{-2,-1},{1,2},{-1,2},{1,-2},{-1,-2}};

using namespace std;

void solve()
{
    int n, k;
    cin >> n >> k;
    int ans = 0;
    int arr[n+5];
    for(int i = 0; i < n; i++) cin >> arr[i];
    sort(arr, arr+n);
    for(int i = 0; i < k; i++) ans += arr[i];
    cout << ans;
}
//new line is printed in the main

int main()
{
    int t = 1;
        // cin >> t; // comment out if no test case is required
    // int i = 1;
    while(t--){
        //cout << "Case " << i++ << ": ";
        solve();
        // printf("\n");
    }
    return 0;
}


Measured memory_bytes: 3636
void main() {
	auto ip = readAs!(long[]), a = ip[0], b = ip[1], c = ip[2];
	if(2*sqrt((a*b).to!real) + a + b - c < 0) writeln("Yes");
	else writeln("No");
}

// ===================================

import std.stdio;
import std.string;
import std.functional;
import std.algorithm;
import std.range;
import std.traits;
import std.math;
import std.container;
import std.bigint;
import std.numeric;
import std.conv;
import std.typecons;
import std.uni;
import std.ascii;
import std.bitmanip;
import core.bitop;

T readAs(T)() if (isBasicType!T) {
	return readln.chomp.to!T;
}
T readAs(T)() if (isArray!T) {
	return readln.split.to!T;
}

T[][] readMatrix(T)(uint height, uint width) if (!isSomeChar!T) {
	auto res = new T[][](height, width);
	foreach(i; 0..height) {
		res[i] = readAs!(T[]);
	}
	return res;
}

T[][] readMatrix(T)(uint height, uint width) if (isSomeChar!T) {
	auto res = new T[][](height, width);
	foreach(i; 0..height) {
		auto s = rs;
		foreach(j; 0..width) res[i][j] = s[j].to!T;
	}
	return res;
}

int ri() {
	return readAs!int;
}

double rd() {
	return readAs!double;
}

string rs() {
	return readln.chomp;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define rep(i, n) for(int i=0;i<(int)n;i++)
#define PI acos(-1)
#define fast_io ios_base::sync_with_stdio(false) ; cin.tie(0); cout.tie(0);
ll mod=1e9+7;

int main(){
    fast_io
    
    int n, k;
    cin>>n>>k;
    int a[n];
    rep(i,n) cin>>a[i];

    int ans=(n-2)/(k-1)+1;
    cout<<ans<<endl;
    return 0;
}

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

int main(){
    int a, b, c;
    scanf("%d %d %d", &a, &b, &c);
    double PI = acos(-1);
    double rad = c * PI / 180.0;
    double s = (a * b * sin(rad)) / 2;
    double l = a + b + sqrt(pow(a, 2) + pow(b, 2) - 2 * a * b * cos(rad)); 
    double v = 2 * s / a;
    printf("%lf %lf %lf", s, l, v);
}


Measured memory_bytes: 3444
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define ll long long
#define all(x) (x).begin(),(x).end()
template<class T> inline bool chmax(T& a, T b) {if (a < b) {a = b;return true;}return false;}
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
const int INF = 1000000000;

int main() {
    int a;
    cin >> a;
    int ans = a + a*a + a*a*a;

    cout << ans << endl;
}

Measured memory_bytes: 3644
n=int(input())
a=list(map(int,input().split()))

num1=0
num4=0
num2=0
for i in range(n):
    if a[i]%4==0:
        num4+=1
    elif a[i]%2==0:
        num2+=1
    else:
        num1+=1

if num2>0:
    num1+=1

if num4>=num1-1:
    print("Yes")
else:
    print("No")


Measured memory_bytes: 85316
use std::collections::*;
use std::*;
// template {{{
macro_rules ! get {($ ($ t : tt ) ,*; $ n : expr ) => {{let stdin = std :: io :: stdin () ; let ret = std :: io :: BufRead :: lines (stdin . lock () ) . take ($ n ) . map (| line | {let line = line . unwrap () ; let mut it = line . split_whitespace () ; _get ! (it ; $ ($ t ) ,* ) } ) . collect ::< Vec < _ >> () ; ret } } ; ($ ($ t : tt ) ,* ) => {{let mut line = String :: new () ; std :: io :: stdin () . read_line (& mut line ) . unwrap () ; let mut it = line . split_whitespace () ; _get ! (it ; $ ($ t ) ,* ) } } ; }
macro_rules ! _get {($ it : ident ; [char ] ) => {_get ! ($ it ; String ) . chars () . collect ::< Vec < _ >> () } ; ($ it : ident ; [u8 ] ) => {_get ! ($ it ; String ) . bytes () . collect ::< Vec < _ >> () } ; ($ it : ident ; usize1 ) => {$ it . next () . unwrap () . parse ::< usize > () . unwrap_or_else (| e | panic ! ("{}" , e ) ) - 1 } ; ($ it : ident ; [usize1 ] ) => {$ it . map (| s | s . parse ::< usize > () . unwrap_or_else (| e | panic ! ("{}" , e ) ) - 1 ) . collect ::< Vec < _ >> () } ; ($ it : ident ; [$ t : ty ] ) => {$ it . map (| s | s . parse ::<$ t > () . unwrap_or_else (| e | panic ! ("{}" , e ) ) ) . collect ::< Vec < _ >> () } ; ($ it : ident ; $ t : ty ) => {$ it . next () . unwrap () . parse ::<$ t > () . unwrap_or_else (| e | panic ! ("{}" , e ) ) } ; ($ it : ident ; $ ($ t : tt ) ,+ ) => {($ (_get ! ($ it ; $ t ) ) ,* ) } ; }
// }}}

fn main() {
    let n = get!(usize);
    let d = get!(i32,i32;n);
    let mut zoro = vec![false; n];
    for i in 0..n {
        if d[i].0 == d[i].1 {
            zoro[i] = true;
        }
    }
    let mut count = 0;
    let mut ans = false;
    for i in 0..n {
        if zoro[i] {
            count += 1;
        } else {
            count = 0;
        }
        if count >= 3 {
            ans = true;
        }
    }
    println!("{}", if ans { "Yes" } else { "No" });
}


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

int main() {
  int N,K;
  cin>>N>>K;
  string S;
  cin>>S;
  string ret;
  char x;
  if(S.at(K-1)=='A') S.at(K-1)='a';
  else  if(S.at(K-1)=='B') S.at(K-1)='b';
  else if(S.at(K-1)=='C') S.at(K-1)='c';

  cout<<S<<endl;
}


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

int main()
{
    int N, A, B;
    scanf("%d", &N);
    if(N==1)
    {
        printf("Hello World");
    }
    else if (N==2)
    {
        scanf("%d %d", &A, &B);
        printf("%d", A+B);
    }
    return 0;
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main() {
	int A, B, C, K;
	cin >> A >> B >> C >> K;

	if (K <= A) cout << K << endl;
	else if (K <= A + B) cout << A << endl;
	else cout << A - (K - A - B) << endl;

	return 0;
}


Measured memory_bytes: 3616
import java.util.*;

class Main{
	static Scanner scan = new Scanner(System.in);
	static void programmingEducation(){
		int age = scan.nextInt();
		if(age == 1){
			System.out.println("Hello World");
		}
		else{
			int a = scan.nextInt(), b = scan.nextInt();
			System.out.println(a+b);
		}
		
	}
	
	static void timeLimit(){
		int n = scan.nextInt(), t = scan.nextInt();
		ArrayList<Integer> costs = new ArrayList<>();
		for(int i=0;i<n;i++){
			int input = scan.nextInt(), time = scan.nextInt();
			if(time<=t)
				costs.add(input);
		}
		Collections.sort(costs);
		if(costs.isEmpty())
			System.out.println("TLE");
		else{
			int cost = costs.get(0);
			System.out.println(cost);
		}
	}
	
	public static void main(String[] argv){
		//programmingEducation();
		timeLimit();
	}
	
}

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

int main()
{
    int n;
    cin >> n;
    map<int,int> m;
    while(n > 0){
        int a;
        cin >> a;
        if(m.count(a) > 0){
            map<int,int>::iterator itr = m.find(a);
            itr->second = itr->second + 1;
        } else {
            m.insert(make_pair(a,1));
        }
        n--;
    }
    int sum = 0;
    for(map<int,int>::iterator it = m.begin();it!=m.end();it++){
        if(it->second != it->first){
        if(it->second - it->first > 0){
            sum += (it->second - it->first);
        } else {
            sum += (it->first - abs(it->second - it->first));
        }
        }
    }
    cout << sum;
    return 0;
}


Measured memory_bytes: 4736
#vacation
n=int(input())
a=[0 for i in range(n)]
b=[0 for i in range(n)]
c=[0 for i in range(n)]
for i in range(n):
    x,y,z=map(int,input().split())
    a[i]=x
    b[i]=y
    c[i]=z
max_a=[0 for i in range(n+1)]
max_b=[0 for i in range(n+1)]
max_c=[0 for i in range(n+1)]

#max_a[i]=i日めにちょうどaの過ごし方をしたときの、考えうる最小の値
max_a[1]=a[0]
max_b[1]=b[0]
max_c[1]=c[0]
for i in range(2,n+1):
    max_a[i]=max(max_b[i-1]+a[i-1],max_c[i-1]+a[i-1])
    max_b[i]=max(max_a[i-1]+b[i-1],max_c[i-1]+b[i-1])
    max_c[i]=max(max_a[i-1]+c[i-1],max_b[i-1]+c[i-1])
print(max(max_a[-1],max_b[-1],max_c[-1]))

Measured memory_bytes: 26868
#include<bits/stdc++.h>
using namespace std;
int main(){
	int N,M;cin>>N>>M;
	int K[M];vector<vector<int>> S(N,vector<int>(0));int P[M];
	int temp;
	for(int i=0;i<M;i++){
		cin>>K[i];
		for(int j=0;j<K[i];j++){
			cin>>temp;temp--;
			S[temp].push_back(i);
		}
	}for(int i=0;i<M;i++){
		cin>>P[i];
	}
    /*for(int i=0;i<N;i++){
        for(int j=0;j<S[i].size();j++){
            cout<<S[i][j]<<endl;
        }
    }*/
	int ans=0;
	for(int i=0;i<(1<<N);i++){
		bool flag=true;
		int sum[M]={0};
		for(int j=0;j<N;j++){
			if(i&(1<<j)){
				for(int k=0;k<S[j].size();k++){
					sum[S[j][k]]++;
				}
			}
		}for(int j=0;j<M;j++){
			if((sum[j]%2)!=P[j]){
				flag=false;
			}
		}if(flag){
			ans++;
		}
	}cout<<ans<<endl;
}

Measured memory_bytes: 256
#include <cstdio>
#include <algorithm>
using namespace std;

#define SQ(x) ((x)*(x))
const int MAX_N=10;

int N, D;
int board[MAX_N][MAX_N];

bool isInterger(int a, int b)
{
  int sum = 0;
  for (int i=0; i<D; i++)
    sum += SQ(board[a][i]-board[b][i]);
  for (int i=0; i<127; i++)
    if (sum == i*i) return true;
  return false;
}

int main()
{
  scanf("%d%d", &N, &D);
  for (int i=0; i<N; i++)
    for (int j=0; j<D; j++)
      scanf("%d", &board[i][j]);
  
  int ret = 0;
  for (int i=0; i<N; i++)
    for (int j=i+1; j<N; j++)
      if (isInterger(i, j))
        ret++;
  printf("%d\n", ret);
  return 0;
}

Measured memory_bytes: 128
#include <fstream>
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <queue>
#include <set>
#include <cmath>
#include <climits>
#include <map>
#include <unordered_map>
#include <set>
#include <unordered_set>
#include <numeric>
#include <sstream>

#define rep(i,n) for (int i = 0; i < (n); ++i)
#define sz(x) int(x.size())

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

int main() {
#ifdef RUN_LOCAL
  ifstream in("../input.txt");
  cin.rdbuf(in.rdbuf());
#endif

  cin.tie(0);
  ios::sync_with_stdio(false);

  ld ra, rb, h, m;
  cin >> ra >> rb >> h >> m;

  ld tm = 60 * h + m;
  ld tha = - 2 * M_PI / (60 * 12) * tm + M_PI / 2;
  ld thb = - 2 * M_PI / 60 * tm + M_PI / 2;
  ld xa = ra * cos(tha);
  ld ya = ra * sin(tha);
  ld xb = rb * cos(thb);
  ld yb = rb * sin(thb);
  ld di = sqrt((xa-xb)*(xa-xb) + (ya-yb)*(ya-yb));

  std::cout << std::fixed;
  std::cout << std::setprecision(std::numeric_limits<ld>::max_digits10);
  cout << di << endl;


  return 0;
}


Measured memory_bytes: 3560
#include <iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<cmath>
#include<deque>
using namespace std;

int main(){
    string s;
    cin >> s;
    deque<char> t;
    for(char c : s){
        t.push_back(c);
    }
    int q;
    cin >> q;
    int ti,fi;
    char ci;
    bool flag=false;
    for(int i=0;i<q;i++){
        cin >> ti;
        if(ti==1){
            flag=!flag;
        }else{
            cin >> fi >> ci;
            if(flag) fi = 3-fi;
            if(fi==1){
                t.push_front(ci);
            }else{
                t.push_back(ci);
            }
        }
    }
    if(flag) reverse(t.begin(),t.end());
    string ans;
    for(char c : t) ans += c;
    cout << ans << endl;
}

Measured memory_bytes: 1412
#include <iostream>

using namespace std;

int N;
long long tt, ta;

int main() {
    int u, v;
    long long a, b, c, d;
    cin >> N;
    for (int i = 0; i < N; ++i) {
        cin >> u >> v;
        if (u >= tt && v >= ta) {
            tt = u;
            ta = v;
        } else {
            a = 0;
            if (tt >= u) {
                b = (tt + u - 1) / u;
                a = b * u;
                b = b * v;
                if (b < ta) {
                    a = 0;
                }
            }
            c = 0;
            if (ta >= v) {
                d = (ta + v - 1) / v;
                c = d * u;
                d = d * v;
                if (c < tt) {
                    c = 0;
                }
            }
            tt = a;
            ta = b;
            if (!tt || (c && tt + ta > c + d)) {
                tt = c;
                ta = d;
            }
        }
    }
    cout << tt + ta << endl;
    return 0;
}

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

int main(){
	long long a, b, k;
	cin >> a >> b >> k;
	
	long tmp = a-k;
	if(tmp >= 0){
		cout << tmp << " " << b << endl;
	} else {
		if(b+tmp >= 0) cout << 0 << " " << b+tmp << endl;
		else cout << 0 << " " << 0 << endl;
	}
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0; i < (n); i++)
#define REP1(i, n) for(int i = 1; i <= (n); i++)
#define ALL(v) (v).begin(), (v).end()
using namespace std;
typedef long long ll;
typedef vector<string> vs;
typedef vector<int> vi;
typedef vector<vi> vivi;
typedef vector<ll> vll;
typedef vector<vll> vllvll;
typedef pair<int, int> Pi;
typedef queue<Pi> QPi;
typedef pair<ll, ll> Pll;
typedef queue<Pll> QPll;
typedef vector<vi> Graph;
const int mod = 1000000007;
// 小数点　<< fixed << setprecision(0) <<
// sort降順　sort(ALL(),greater<int>());
// 文字判定　isupper islower
// 順列　do {} while(next_permutation(ALL(X)));
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};
struct edge {
    int from; //出発点
    int to;   //到達点
    int cost; //移動コスト
};
typedef struct edge se;
typedef vector<edge> ve;
unsigned euclidean_gcd(unsigned a, unsigned b) {
  if(a < b) return euclidean_gcd(b, a);
  unsigned r;
  while ((r=a%b)) {
    a = b;
    b = r;
  }
  return b;
}

int main() {
  while(1) {
    int n,x,cnt=0;
    cin >> n >> x;
    if(n==0&&x==0) break;
    REP1(i,n-2) {
      for(int j=i+1;j<=n-1;j++) {
        for(int k=j+1;k<=n;k++) {
          if(i+j+k==x) cnt++;
        }
      }
    }
    cout << cnt << endl;
  }
  return 0;
}



Measured memory_bytes: 3120
#define _USE_MATH_DEFINES
#define _CRT_SECURE_NO_WARNINGS
#include<stdio.h>
#include<string>
#include<iostream>
#include<cctype>
#include<cstdio>
#include<vector>
#include<stack>
#include<queue>
#include <algorithm>
#include<math.h>
#include<set>
#include<map>
#include <sstream>
#include<iomanip>
#include <ctype.h>

//#include<bits/stdc++.h>




using namespace std;
int main() {

	int t;
	cin >> t;
	cout << 24 - t + 24 << endl;

	return 0;
}

Measured memory_bytes: 256
#pragma GCC optimize("O3")
#include<bits/stdc++.h> 
using namespace std;
using ll=long long;
using P=pair<int,int>;
template<class T> using V=vector<T>; 
#define fi first
#define se second
#define all(v) (v).begin(),(v).end()
const ll inf=(1e18);
const ll mod=1000000007;
ll gcd(ll a,ll b) {return b ? gcd(b,a%b):a;}
ll lcm(ll c,ll d){return c/gcd(c,d)*d;}
struct __INIT{__INIT(){cin.tie(0);ios::sync_with_stdio(false);cout<<fixed<<setprecision(15);}} __init;
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return 1; } return 0; }
struct edge{ll to,cost;};
vector<vector<edge>> graph;
vector<vector<bool>> used;
 int n,m;
 V<ll> d1;
void dijkstra(ll s){
    d1.resize(n);
    for(int i=0;i<n;i++)d1[i]=inf;//訪れていない頂点をinfで初期化
    d1[s]=0;
    priority_queue<P,vector<P>,greater<P>> q;
    q.push(P(0,s));//始点を０で置く
    while(!q.empty()){
        P a=q.top();
        q.pop();
        if(d1[a.se]<a.fi)continue;
        for(int i=0;i<graph[a.se].size();i++){
            edge e=graph[a.se][i];
            if(d1[e.to]>d1[a.se]+e.cost){
                d1[e.to]=d1[a.se]+e.cost;//訪れていないorより低いコストの経路を発見した時、値を更新
                q.push(P(d1[e.to],e.to));//コストの低いところ優先のbfs
            }
        }
    }
    q.push(P(0,s));
    while(!q.empty()){//経路復元
        P a=q.top();
        q.pop();
        if(d1[a.se]<a.fi)continue;
        for(int i=0;i<graph[a.se].size();i++){
            edge e=graph[a.se][i];
            if(d1[e.to]==d1[a.se]+e.cost){
                used[a.se][e.to]=false;
                used[e.to][a.se]=false;
                q.push(P(d1[e.to],e.to));
            }
        }
    }
    return;
}
int main(){
  cin>>n>>m;
  used.assign(n,V<bool>(n,false));
  graph.resize(n);
  for(int i=0;i<m;i++){
     ll a,b,c;
     cin>>a>>b>>c;
     --a;--b;
     graph[a].push_back(edge{b,c});
     graph[b].push_back(edge{a,c});
     used[a][b]=true;
     used[b][a]=true;
  }
  for(int i=0;i<n;i++)dijkstra(i);
  ll ans=0;
  for(int i=0;i<n-1;i++)for(int j=i+1;j<n;j++)if(used[i][j])ans++;
  cout<<ans<<endl;
}

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

const int MOD=1000000007;
const int INF=0x3f3f3f3f;
const ll INFL=0x3f3f3f3f3f3f3f3f;

int a[300000];
int main(){
	int n,K;cin>>n>>K;
	rep(i,n)scanf("%d",&a[i]);
	set<int>se;
	deque<P>que;
	int cnt=0;
	rep(i,K){
		se.insert(a[i]);
		if(!que.empty()&&que.back().first>a[i]){
			que.clear();
		}
		que.push_back(P(a[i],i));
	}
	bool F=false;
	if(que.front().second>0){
		cnt=1;
	}
	else F=true;
	for(int i=K;i<n;i++){//[i-K+1,i]
		bool flag=false;
		if(a[i-K]!=*se.begin()){
			flag=true;
		}
		se.erase(a[i-K]);
		if(*se.rbegin()>a[i]){
			flag=true;
		}
		se.insert(a[i]);
		if(!que.empty()&&que.back().first>a[i])que.clear();
		que.push_back(P(a[i],i));
		if(que.front().second>i-K+1){
			cnt+=flag;
		}
		else F=true;
	}
	cout<<cnt+F<<endl;
}

Measured memory_bytes: 12032
#include <stdio.h>
#include <string>
#include <cstring>
#include <stdlib.h>
#include <math.h>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <iterator>
#pragma warning(disable:4996)
 
typedef long long ll;
#define MIN(a, b) ((a)>(b)? (b): (a))
#define MAX(a, b) ((a)<(b)? (b): (a))
#define LINF 9223300000000000000
#define INF 2140000000
#define MOD 1000000007
using namespace std;

int main(int argc, char* argv[])
{
    long n, t;
    scanf("%ld%ld", &n, &t);

    vector<long> a(n);
    long i;
    for(i=0; i<n; i++) {
        scanf("%ld", &a[i]);
    }

    long count=0;
    long best=0;
    long min=INF;
    for(i=0; i<n; i++) {
        if(best < a[i]-min) {
            best = a[i]-min;
            count = 1;
        }
        else if(best == a[i]-min) {
            count++;
        }

        min = MIN(min, a[i]);
    }
    printf("%ld\n", count);

    return 0;
}



Measured memory_bytes: 1024
cnt = 0


def insSort(A, n, g):
    global cnt

    for i in range(g, n):
        v = A[i]
        j = i - g
        while j >= 0 and A[j] > v:
            A[j+g] = A[j]
            j = j - g
            cnt += 1
        A[j+g] = v


def shellSort(A, n):
    G = []
    i = 1
    while True:
        G.append(i)
        i = i * 3 + 1
        if i > n - 2:
            break
    G.reverse()

    print(len(G))
    print(*G)

    for i in G:
        insSort(A, n, i)


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

shellSort(arr, n)

print(cnt)

for s in arr:
    print(s)



Measured memory_bytes: 45512
N = gets.to_i
MOD = 10 ** 9 + 7

s = ["A", "C", "G", "T"]
ex = ["AGC", "ACG", "GAC"]
c = Hash.new{|h, k| h[k] = 0}
["A", "C", "G", "T"].repeated_permutation(3).each{|a|
  c[a.join] = 1
}
ex.each{|a| c[a] = 0}

wk = 3
while wk < N do
  nxt = Hash.new{|h, k| h[k] = 0}
  c.each{|k, v|
    s.each{|t|
      next if /A.GC|AG.C/ =~ k+t
      nxt[k[1,2] + t] += v
    }
  }
  c = nxt.map{|k, v| [k, ex.include?(k) ? 0 : v % MOD]}
  wk += 1
end

puts c.inject(0){|r, (k, v)| r + v} % MOD


Measured memory_bytes: 2172
def main():
    n = int(input())
    a = list(map(int, input().split()))
    mod = 10**9+7
    ans = 0
    fact = 1
    for i in range(2, n):
        fact = fact*i % mod

    fact_2 = [fact]
    for i in range(2, n):
        fact_2.append((fact_2[-1] + fact * pow(i, mod-2, mod) % mod))

    for i in range(n-1):
        ans = (ans + (a[i+1]-a[i])*fact_2[i]) % mod
    print(ans % mod)


main()


Measured memory_bytes: 19920
#include <stdio.h>
#include <math.h>
#define Aa 1000
int isprime(int);
int main(){
  int A[Aa];
  int n=0,i=0,j=0,v=0,k=0,x,y,r,sum=0;
  scanf("%d",&n);
  for(i = 0; i < n; i++){
    scanf("%d",&k);
    sum+= isprime(k);
  }
  printf("%d\n",sum);

  return 0;
}

int isprime(int x){
  int i,flg=0;
  if(x == 2)return 1;
  if(x < 2 || x%2 == 0)return 0;

  i = 3;
  while( i <= sqrt(x)){
    if(x%i ==0)flg = 1;
      i = i + 2;
  }
  if(flg == 1)return 0;
  else return 1;
}


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

int main(){
  int a,b,c,n;
  cin >> a >> b >> c >> n;
  int ans=0;
  for(int i=0;i<=3000;i++){
    for(int j=0;j<=3000;j++){
      if(n-a*i-b*j>=0&&(n-a*i-b*j)%c==0){
        ans++;
      }
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.InputMismatchException;
import java.io.IOException;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 *
 * @author Dhanin Gupta
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        ALucky7 solver = new ALucky7();
        solver.solve(1, in, out);
        out.close();
    }

    static class ALucky7 {
        public void solve(int testNumber, InputReader in, PrintWriter w) {

            char[] a = in.next().toCharArray();

            if (a[0] == '7' || a[1] == '7' || a[2] == '7')
                w.println("Yes");
            else
                w.println("No");
        }

    }

    static class InputReader {
        private InputStream stream;
        private byte[] buf = new byte[1024];
        private int curChar;
        private int numChars;
        private InputReader.SpaceCharFilter filter;

        public InputReader(InputStream stream) {
            this.stream = stream;
        }

        public int read() {
            if (numChars == -1)
                throw new InputMismatchException();

            if (curChar >= numChars) {
                curChar = 0;
                try {
                    numChars = stream.read(buf);
                } catch (IOException e) {
                    throw new InputMismatchException();
                }

                if (numChars <= 0)
                    return -1;
            }
            return buf[curChar++];
        }

        public String readString() {
            int c = read();
            while (isSpaceChar(c))
                c = read();
            StringBuilder res = new StringBuilder();
            do {
                res.appendCodePoint(c);
                c = read();
            }
            while (!isSpaceChar(c));

            return res.toString();
        }

        public boolean isSpaceChar(int c) {
            if (filter != null)
                return filter.isSpaceChar(c);
            return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1;
        }

        public String next() {
            return readString();
        }

        public interface SpaceCharFilter {
            public boolean isSpaceChar(int ch);

        }

    }
}



Measured memory_bytes: 32360