akhauriyash/Code-Regression huggingface dataset:
import java.util.*;

//update 2020/1/1 23:01

public class Main{

  static Scanner sc = new Scanner(System.in);
  static StringBuilder sb = new StringBuilder();

  public static void main(String[] args) {

    int k = nextInt();
    int n = nextInt();
    int[] a = new int[n];

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

    Arrays.sort(a);

    int max = 0;

    for(int i=1;i<n;i++){
      max = Math.max(max,a[i]-a[i-1]);
    }

    max = Math.max(max,a[0]+k-a[n-1]);

    System.out.println(k-max);

  }

  static int lcm(int a,int b){
    return a*b*gcd(a,b);
  }

  static int gcd(int a,int b){
    if(a%b!=0){
      return gcd(b,a%b);
    }
    else{
      return b;
    }
  }

  /*
    static String toSmall(String s){
      char c = s.charAt(0);
      //if(Character.isUpperCase(c)){
      if(c<=90){
        c += 32;
      }
      return String.valueOf(c);
    }
    static String toBig(String s){
      char c = s.charAt(0);
      //if(Character.isLowerCase(c)){
      if(c>=97){
        c -= 32;
      }
      return String.valueOf(c);
    }
  */

  static String toSmall(String s){
    return s.toLowerCase();
  }

  static String toBig(String s){
    return s.toUpperCase();
  }

  static String next(){
    return sc.next();
  }

  static int nextInt(){
    return Integer.parseInt(sc.next());
  }

  static long nextLong(){
    return Long.parseLong(sc.next());
  }

  static double nextDouble(){
    return Double.parseDouble(sc.next());
  }

  static String[] splitString(String s){
    return s.split("");
  }

  static char[] splitChar(String s){
    return s.toCharArray();
  }

  static int charToInt(char a){
    return a - 48;
  }

////////////////////////////////////////////
  public static int max(int[] a){
    int lng = a.length;
    int max = a[0];
    for(int i=1;i<lng;i++){
      max = Math.max(max,a[i]);
    }
    return max;
  }
  public static long max(long[] a){
    int lng = a.length;
    long max = a[0];
    for(int i=1;i<lng;i++){
      max = Math.max(max,a[i]);
    }
    return max;
  }
////////////////////////////////////////////

////////////////////////////////////////////
  public static int min(int[] a){
    int lng = a.length;
    int min = a[0];
    for(int i=1;i<lng;i++){
      min = Math.min(min,a[i]);
    }
    return min;
  }
  public static long min(long[] a){
    int lng = a.length;
    long min = a[0];
    for(int i=1;i<lng;i++){
      min = Math.min(min,a[i]);
    }
    return min;
  }
////////////////////////////////////////////

}


Measured memory_bytes: 57828
import java.util.*;

public class Main {

    private static int r;
    private static int D;
    private static int x2000;

    private static void read() {
        Scanner sc = new Scanner(System.in);
        r = sc.nextInt();
        D = sc.nextInt();
        x2000 = sc.nextInt();
    }

    public static void main(String[] args) {
        read();
        int x = x2000;
        for (int i = 0; i < 10; i += 1) {
            x = r * x - D;
            System.out.println(x);
        }
    }
}


Measured memory_bytes: 23124
io = STDIN
$n,$c=io.gets.split.map(&:to_i)
$x,$v=[0],[0]
$n.times do
  x,v = io.gets.split.map(&:to_i)
  $x<<x
  $v<<v
end
$left_max={}
$right_max={}
def init
  max,sum_v,max_i=0,0,0
  (1..$n).each do |i|
    sum_v+=$v[i]
    if max < sum_v-$x[i]
      max = sum_v-$x[i]
      max_i = i
    end
    $left_max[i]=[max_i,max]
  end
  sum_v=0
  max,sum_v,max_i=0,0,0
  $n.downto(1) do |i|
    sum_v+=$v[i]
    if max < sum_v-($c-$x[i])
      max = sum_v-($c-$x[i])
      max_i = i
    end
    $right_max[i]=[max_i,max]
  end
end
init
$left_max[0]=[0,$left_max.values.max_by{|i,max|max}.last]
$right_max[0]=[0,$right_max.values.max_by{|i,max|max}.last]

ans=[$left_max[0].last,$right_max[0].last,0].max
(2..$n).each do |b|
  i,left_val=$left_max[b-1]
  ans=[ans,
    left_val +
    $right_max[b].last -
    [$x[i],$c-$x[b]].min
  ].max
end
puts ans

Measured memory_bytes: 30516
#include <stdio.h>
#include <string.h>

#define MAX 100001

void Calc(char s[MAX], char ans[MAX/2 + 1]);

int main(){
	char s[MAX];
	char ans[MAX/2 + 1] = "";

	if(scanf("%s", s) != 1){
		scanf("%*s");
		return -1;
	}

	Calc(s, ans);

	printf("%s\n", ans);

	return 0;
}

void Calc(char s[MAX/2 + 1], char ans[MAX/2 + 1]){
	int count, gusu = 0;

	for(count = 0; count < strlen(s); count++)
		if(count % 2 == 0){
			ans[gusu] = s[count];
			gusu++;
		} else if(s[count] == '\0'){
			ans[gusu] = '\0';
			gusu++;
		}

	return;
}

Measured memory_bytes: 384
macro_rules ! input { ( source = $ s : expr , $ ( $ r : tt ) * ) => { let mut iter = $ s . split_whitespace ( ) ; input_inner ! { iter , $ ( $ r ) * } } ; ( iter = $ iter : ident , $ ( $ r : tt ) * ) => { let s = { use std :: io :: Read ; let mut s = String :: new ( ) ; std :: io :: stdin ( ) . read_to_string ( & mut s ) . unwrap ( ) ; s } ; let mut $ iter = s . split_whitespace ( ) ; input_inner ! { $ iter , $ ( $ r ) * } } ; ( $ ( $ r : tt ) * ) => { let s = { use std :: io :: Read ; let mut s = String :: new ( ) ; std :: io :: stdin ( ) . read_to_string ( & mut s ) . unwrap ( ) ; s } ; let mut iter = s . split_whitespace ( ) ; input_inner ! { iter , $ ( $ r ) * } } ; }
macro_rules ! input_inner { ( $ iter : expr ) => { } ; ( $ iter : expr , ) => { } ; ( $ iter : expr , mut $ var : ident : $ t : tt $ ( $ r : tt ) * ) => { let mut $ var = read_value ! ( $ iter , $ t ) ; input_inner ! { $ iter $ ( $ r ) * } } ; ( $ iter : expr , mut $ var : ident $ ( $ r : tt ) * ) => { input_inner ! { $ iter , mut $ var : usize $ ( $ r ) * } } ; ( $ iter : expr , $ var : ident : $ t : tt $ ( $ r : tt ) * ) => { let $ var = read_value ! ( $ iter , $ t ) ; input_inner ! { $ iter $ ( $ r ) * } } ; ( $ iter : expr , $ var : ident $ ( $ r : tt ) * ) => { input_inner ! { $ iter , $ var : usize $ ( $ r ) * } } ; }
macro_rules ! read_value { ( $ iter : expr , ( $ ( $ t : tt ) ,* ) ) => { ( $ ( read_value ! ( $ iter , $ t ) ) ,* ) } ; ( $ iter : expr , [ $ t : tt ; $ len : expr ] ) => { ( 0 ..$ len ) . map ( | _ | read_value ! ( $ iter , $ t ) ) . collect ::< Vec < _ >> ( ) } ; ( $ iter : expr , { chars : $ base : expr } ) => { read_value ! ( $ iter , String ) . chars ( ) . map ( | c | ( c as u8 - $ base as u8 ) as usize ) . collect ::< Vec < usize >> ( ) } ; ( $ iter : expr , { char : $ base : expr } ) => { read_value ! ( $ iter , { chars : $ base } ) [ 0 ] } ; ( $ iter : expr , chars ) => { read_value ! ( $ iter , String ) . chars ( ) . collect ::< Vec < char >> ( ) } ; ( $ iter : expr , char ) => { read_value ! ( $ iter , chars ) [ 0 ] } ; ( $ iter : expr , usize1 ) => { read_value ! ( $ iter , usize ) - 1 } ; ( $ iter : expr , $ t : ty ) => { $ iter . next ( ) . unwrap ( ) . parse ::<$ t > ( ) . unwrap ( ) } ; }
use std::cmp::min;
fn main() {
    input! { n, s: chars };
    let mut ans = 0usize;
    let t1 = &s[..n];
    let t2 = &s[n..];
    for i in 0..1 << n {
        let mut dp = vec![vec![0; n + 1]; n + 1];
        let mut a = vec![];
        let mut b = vec![];
        for j in 0..n {
            if i & 1 << j != 0 {
                a.push(t1[j]);
            } else {
                b.push(t1[j]);
            }
        }
        a.reverse();
        b.reverse();
        let (na, nb) = (a.len(), b.len());
        dp[0][na] = 1;
        for j in 0..n {
            for k in na..min(na + j, n) + 1 {
                if k - na < nb && t2[j] == b[k - na] {
                    dp[j + 1][k + 1] += dp[j][k];
                }
                if j - (k - na) < na && t2[j] == a[j - (k - na)] {
                    dp[j + 1][k] += dp[j][k];
                }
            }
        }
        ans += dp[n][n];
    }
    println!("{}", ans);
}


Measured memory_bytes: 4352
n = gets.chomp.to_i
arr = gets.chomp.split(' ').map(&:to_i)

count = 0
sorted_arr = arr.sort

arr.each_with_index do |i, idx|
  unless arr[idx] == sorted_arr[idx]
    count += 1
  end
end

if count == 2 || count == 0
  print 'YES'
else
  print 'NO'
end


Measured memory_bytes: 1788
import java.util.Scanner;
 
public class Main {
	public static void main(String[] args) {
		try (Scanner sc = new Scanner(System.in)) {
			long h = sc.nextInt();
			long w = sc.nextInt();
			if ((h == 1 || w == 1)) {
				System.out.println(1);
				return;
			}
			if (h % 2 == 0) {
				System.out.println((h / 2 * w));
				return;
			}
			if (w % 2 == 0) {
				System.out.println((w / 2 * h));
				return;
			}
			System.out.println((h / 2 * w) + (w / 2 + 1));
		}
	}
}

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

int main() {
int N;
  cin>>N;
  
  set<int>st;
  for(int i=0; i<N; i++){
    int A;
    cin>>A;
   if(st.count(A)==0){st.insert(A);}  // st.countはAの個数を表示
   else{st.erase(A);}  // Aの個数が0ならstに追加、1個なら削除して0に戻す。
  }  // setは重複するデータは2個目以降は自動で削除される。よってその要素がある場合は1を、ない場合はは0を返す
    // st内には1（要素あり）のみinsertする。stのsizeが答えになる。
  cout<<st.size();  // 
}


Measured memory_bytes: 4864
#include <bits/stdc++.h>
using namespace std;
#define N 509
#define INF 10000000000009
#define MOD 1000000007
typedef long long int ll;
#define sd(x) scanf("%d",&x)
#define sd2(x,y) scanf("%d%d",&x,&y)
#define sd3(x,y,z) scanf("%d%d%d",&x,&y,&z)
#define pf(x) printf("%lld\n",x);
#define pf2(x,y) printf("%d %d\n",x,y);
#define pf3(x,y,z) printf("%d %d %d\n",x,y,z);
#define fi first
#define se second
#define pb(x) push_back(x)
#define mp(x,y) make_pair(x,y)
#define _ ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define tr(x) cout<<x<< endl;
#define tr2(x,y) cout<<x<<" "<<y<<" " << endl;
#define tr3(x,y,z) cout<<x<<" "<<y<<" "<<z<<endl;
#define tr4(x,y,z,a) cout<<x<<" "<<y<<" "<<z<<  " " << a << " " << endl;
ll a[N];
int pi[N][N]; // storing best k -> dp[i][j] = dp[i][k] + dp[k][j]
ll dp[N][N];

ll calculate(int n){
    int i,j,len;
    for (int len = 1; len < n; len++) {                   //s - length(size) of substring
        for (int l = 1; l+len <= n; l++) {              //l - left point

          int r = l + len;                            //r - right point

          if (len < 2) {
            dp[l][r] = a[r] - a[l-1];                          //DP base - nothing to break
            pi[l][r] = l;                          //pi is equal to left border
            continue;
          }

          int mleft = pi[l][r-1];                  //Knuth's trick: getting bounds on m
          int mright = pi[l+1][r];
          dp[l][r] = INF;

          for (int m = mleft; m<=mright; m++) {     //iterating for m in the bounds only
                ll temp = dp[l][m] + dp[m+1][r] + (a[r]-a[l-1]);
                if (dp[l][r] > temp) {                 //relax current solution
                  dp[l][r] = temp;
                  pi[l][r] = m;
                }
          }


        }
    }

    return dp[1][n];
}
int main(){
    int i,j,t,x,y,k,m,n,z;
    sd(n);
    for(i=1; i<=n; i++){
        cin >> a[i];
        a[i] += a[i-1];
    }
    ll ans = calculate(n);
    tr(ans);
    return 0;
}

// https://atcoder.jp/contests/dp/tasks/dp_n


Measured memory_bytes: 2688
n=int(input())
c=sorted(list(map(int,input().split())))[::-1]
if c[-1]==0:
	print(0)
else:
	tot=1
	flag=0
	for i in range(len(c)):
		tot*=c[i]
		if tot>1000000000000000000:
			print(-1)
			flag=1
			break
	if flag==0:
		print(tot)
				


Measured memory_bytes: 84548
k,n = map(int,input().split())
a = list(map(int,input().split()))
b = [0] * n
for i in range(n-1):
     b[i] = a[i+1] - a[i]
b[n-1] = k - a[n-1] + a[0]
print(k-max(b))

Measured memory_bytes: 26444
#include <iostream>
#include <string>
#include <vector>
#include <math.h>
#include <stdio.h>
#include <algorithm>
#include <cmath>
#include <cstdlib>
#include <stack>
#include <istream>
#include <map>
#include <set>
#include <queue>
#define rep0(i,n) for (int i = 0; i <= (n); ++i)
#define rep1(i,n) for (int i = 1; i <= (n); ++i)
#define REP(a,b) for (int i = a; i <= (b); ++i) 
#define mREP(a,b) for (int i = a; i == (b); --i) 
typedef long long ll;
using namespace std;
int main() {
cin.tie(0);
ios::sync_with_stdio(false);
/*
	　　　  　 ,ﾍ／L──- 、
	　　　   　Lﾆ)r_」=＝= ｲ
	　　 　,ﾍ、i ﾉノλﾉﾊﾉﾍ
	　　   ,'　｀(ﾊﾘ ﾟ ヮﾟﾉi)　',
	　　 .i　　 >〈(つ,i!と)　　i
	　　  vﾍγk´_/___i,ゝﾍノ
	　　　　　 ｀ﾞr_,ｨ_ｧﾞ´
*/
string s;
cin >> s;
int temp = 0;
if (s.length() != 1) {
	if (s[0] == '1') {
		rep0(ii, s.length() - 1) {
			temp += s[ii] - '0';
		}
		cout << max(temp, (9 * (int)(s.length() - 1))) << endl;
	}
	else {
		rep1(jj, s.length() - 1) {
			if (s[jj] != '9') {
				s[jj - 1] -= 1;
				REP(jj, s.length() - 1) {
					s[i] = '9';
				}
			}
		}
		rep0(ii, s.length() - 1) {
			temp += s[ii] - '0';
		}
		cout << temp << endl;
	}
}
else {
	cout << s << endl;
}
return 0;
}


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


ll choose2(ll n)
{
    return n*(n-1)/2;
}


int main()
{
   int n; cin>>n;
   vector<int>a(n);
   rep(i,n)cin>>a[i];
   rep(i,n)a[i]--;
   vector<int>cnt(n);
   rep(i,n)cnt[a[i]]++;
  
   ll tot=0;
   rep(i,n)
   {
     tot +=choose2(cnt[i]);
   }
  
   rep(i,n)
   {
       ll ans = tot;
       ans -=choose2(cnt[a[i]]);
       ans +=choose2(cnt[a[i]]-1);
   
       cout<<ans<<endl;
   
   }
  
    return 0;
  
}


Measured memory_bytes: 4096
const input = require("fs").readFileSync("/dev/stdin", "utf8")

const lines = input.split('\n')
let S = lines[0].trim()
let T = lines[1].trim()

let diff = Infinity

const f = (a, b) => {
    let count = 0
    for (let i = 0; i < a.length; i++) {
        if (a[i] !== b[i]) count++
    }
    return count
}

for (let i = 0; i < S.length - T.length + 1; i++) {
    diff = Math.min(diff, f(S.substr(i, T.length), T))
}

console.log(diff)


Measured memory_bytes: 32496
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <vector>
#include <numeric>
#include <algorithm>

using namespace std;

#define rep(i, N) for(LL i=0; i < N; ++i)
typedef long long int LL;

int main(void){
  LL H, W, N, sr, sc;
  string S, T;

  cin >> H >> W >> N >> sr >> sc >> S >> T;
  int L=0, R=0, U=0, D=0;

  for (int i=0; i<N; i++) {
    if (S[i] == 'L') L++;
    else if (S[i] == 'R') R++;
    else if (S[i] == 'U') U++;
    else if (S[i] == 'D') D++;
    if (L >= sc || R > W-sc || U >= sr || D > H - sr) {
      cout << "NO\n";
      return 0;
    }

    if (T[i] == 'L' && sc + R > 1) R --;
    else if (T[i] == 'R' && sc - L < W) L--;
    else if (T[i] == 'U' && sr + D > 1) D--;
    else if (T[i] == 'D' && sr - U < H) U--;
  }

  cout << "YES\n";

  return 0;
}

Measured memory_bytes: 776
a, b = map(int, input().split())
if(1 < a and 1 < b):
    print((a-2)*(b-2))
elif(a == 1 and 1 < b):
    print(b-2)
elif(1 < a and b == 1):
    print(a-2)
else:
    print(1)

Measured memory_bytes: 3060
#include <iostream>
#include<algorithm>
using namespace std;
#define ll long long int
int main()
{
    ll n,i;
    cin>>n;
    ll a[n];
    for(i=0;i<n;i++){
        cin>>a[i];
    }
    ll allXor = 0;
    for(i=0;i<n;i++){
        allXor = a[i]^allXor;
    }
    for(i=0;i<n;i++){
        ll ans = allXor^a[i];
        cout<<ans<<" ";
    }
}


Measured memory_bytes: 5176
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define int long long
int n, p;
const int maxN = (int)1e4 + 100;
ll a[maxN];
ll gcd(ll a, ll b) {
    a = abs(a);
    b = abs(b);
    while (a > 0 && b > 0) {
        if (a < b) swap(a, b);
        a %= b;
    }
    return (a + b);
}
bool used[maxN];
bool pr(ll x) {
    if (x == 1) return false;
    for (int i = 2; 1LL * i * i <= x; i++) {
        if (x % i == 0) return false;
    }
    return true;
}
bool solve(int p) {
    vector < ll > res(p, 0);
    for (int i = 0; i <= n; i++) {
        res[i % (p - 1)] += a[i];
    }
    if (a[0] % p != 0) return false;
    for (int i = 0; i < p; i++) {
        if (res[i] % p != 0) return false;
    }
    return true;
}
signed main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    //freopen("input.txt", "r", stdin);
    cin >> n;
    ll d = 0;
    for (int i = n; i >= 0; i--) {
        cin >> a[i];
        d = gcd(d, a[i]);
    }
    set < ll > cur;
    for (int i = 2; i < maxN; i++) {
        if (!used[i]) {
            used[i] = true;
            for (int j = 2 * i; j < maxN; j += i) used[j] = true;
            if (solve(i)) cur.insert(i);
        }
    }
    for (ll j = 1; 1LL * j * j <= d; j++) {
        if (d % j == 0) {
            if (pr(j)) cur.insert(j);
            if (pr(d / j)) cur.insert(d / j);
        }
    }
    for (auto it : cur) cout << it << '\n';
    return 0;
}

Measured memory_bytes: 384
#include<stdio.h>
#include<iostream>
using namespace std;
int main(){
	long long n,a[10000],i,j,b;
	long long gokei=0,saisho=0,saidai=0;
	cin>>n;
	for(i=0;i<n;i++){
		cin>>a[i];
		gokei+=a[i];
	}
	for(i=0;i<n;i++){
		for(j=i;j<n;j++){
			if(a[i]>a[j]){
				b=a[i];
				a[i]=a[j];
				a[j]=b;
			}
		}
	}
	saisho=a[0];
	saidai=a[n-1];
	cout<<saisho<<" "<<saidai<<" "<<gokei<<endl;
return 0;
}

Measured memory_bytes: 3160
#include <iostream>
#include <cstdio>
#include <cstring>
using namespace std;

void solve(int c,int n,int limit) {
	int i, j, t;
	int w[1000] = {}, v[1000] = {};
	static int dp[1001][1001];

	memset(dp, 0, sizeof(dp));

	for (i = 0;i < n;i++) {
		scanf("%d,%d", &v[i], &w[i]);
		//cin >> v[i] >> w[i];
	}

	for (i = 1;i <= n;i++) {
		for (j = 0;j <= limit;j++) {
			t = j - w[i-1];
			if (t >= 0&&dp[i-1][j]<dp[i-1][t]+v[i-1]) {
				dp[i][j] = dp[i - 1][t] + v[i - 1];
			}
			else {
				dp[i][j] = dp[i - 1][j];
			}
		}
	}

	for (i = 0;i <= limit;i++) {
		if (dp[n][i] == dp[n][limit]) {
			break;
		}
	}

	printf("Case %d:\n%d\n%d\n",c, dp[n][i], i);

	return;
}

int main(void) {
	int c, n, limit;

	c = 1;
	while (true) {
		cin >> limit;
		if (limit == 0) {
			break;
		}
		cin >> n;
		solve(c, n, limit);
		c++;
	}
	
	return 0;
}


Measured memory_bytes: 7108
#include <stdio.h>
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <functional>
#include <algorithm>
#include <cmath>
#include <iomanip>

using namespace std;

#define in(x) cin >> x
#define out(x) cout << x << endl

#define PI acos(-1)
#define pp push_back

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

#define vec2(type) vector<vector<type>>
#define vec3(type) vector<vector<vector<type>>>

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

#define Tcmp(X, Y) (abs(aryvec[i]->x) == X && abs(aryvec[i]->y) == Y)

template<typename T> void input(T *data, int n){
	For(i, n){
		cin >> data[i];
	}
}

template<typename T> void sort(vector<T> &ary){
	sort(ary.begin(), ary.end());
}

template<typename T> void rsort(vector<T> &ary){
	sort(ary.rbegin(), ary.rend());
}

void rstring(string &str){
	string temp = str;

	For(i, (int)str.size()){
		str[i] = temp[(str.size() - 1) - i];
	}
}

struct Vec{
	int x, y;
	Vec():
	x(0), y(0){}
};

int main(){

	int n, k;
	string s;

	int count = 0;
	int pcount = 0;
	int maxp = 0;
	vector<int> group;

	in(n), in(k);
	in(s);

	char now = s[0];

	For(i, n){

		if(s[i] == now){
			count++;
		}
		else{
			if(now == '1'){
				group.push_back(count);
				now = '0';
			}
			else{
				group.push_back(count * -1);
				now = '1';
			}
			count = 1;
		}
	}

		if(now == '1'){
			group.push_back(count);
		}
		else{
			group.push_back(count * -1);
		}
	count = 0;

	// for(int i = 0; i < (int)group.size(); i++){
	// 	cout << group[i] << " ";
	// }
	// cout << endl;

	For(i, (int)group.size()){
		// if(group[i] == -1){
		// 	pcount -= group[i];

		// 	if(count - 1 >= k){

		// 	}
		// }
		if(group[i] > 0){
			pcount += group[i];
			if(pcount > maxp){
				maxp = pcount;
			}
		}
		else if(group[i] < 0){
			pcount -= group[i];
			if(count >= k){
				pcount += group[i - k * 2];
				if(i - k * 2 - 1 >= 0){
					pcount -= group[i - k * 2 - 1];
				}
			}
			else{
				count++;
			}
			if(pcount > maxp){
				maxp = pcount;
			}
		}


	}

	out(maxp);

	return 0;

}

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

#define rep(i, n) for(int i = 0; i<(n); i++)
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
using namespace std;
typedef long long ll;

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


    vector<vector<ll>> mp(10, vector<ll>(10, 0));
    ll m = 1;
    for (ll i = 1; i <= N; i++) {
        if (pow(10LL, m) == i) m++;

        ll n1 = i % 10;
        ll n2 = i % 10;
        if (i >= 10) n2 = i / pow(10LL, (m - 1));
        mp[n2][n1]++;
    }

    ll ans = 0;
    for (int i = 1; i <= 9; i++) {
        for(int j=1; j<= 9; j++) {
            ans += mp[j][i] * mp[i][j];
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define F first
#define S second
#define all(x) (x).begin(),(x).end()
using namespace std;
typedef long long ll;
using vi = vector<int>;
using vvi = vector<vi>;
using pii = pair<int,int>;
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 (b<a) { a=b; return 1; } return 0; }
ll gcd(ll a, ll b) { return b?gcd(b, a%b):a;}
ll lcm(ll a, ll b) { return a*b/gcd(a,b);}
ll MOD=1000000007;

int main(){
  int n;cin>>n;
  double ans=0;
  rep(i,n){
    double t;
    cin>>t;
    ans+=1.0/t;
  }
  cout<<fixed<<setprecision(10)<<1.0/ans<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define FOR(i, a, n) for(ll i = (ll)a; i < (ll)n; i++)
#define FORR(i, n) for(ll i = (ll)n - 1LL; i >= 0LL; i--)
#define rep(i, n) FOR(i, 0, n)
#define ALL(x) begin(x), end(x)
using namespace std;
using ll = long long;
constexpr ll Mod = 998244353;
constexpr ll mod = 1e9 + 7;
constexpr ll inf = 1LL << 60;
const double PI = acos(-1);
template <typename T1, typename T2> inline bool chmax(T1 &a, T2 b) {
    return a < b && (a = b, true);
}
template <typename T1, typename T2> inline bool chmin(T1 &a, T2 b) {
    return a > b && (a = b, true);
}
/*-------------------------------------------*/

int n;
ll d;
int cnt;

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

    cin >> n >> d;
    rep(i, n) {
        ll a, b;
        cin >> a >> b;
        if(a * a + b * b <= d * d) cnt++;
    }
    cout << cnt;

    return 0;
}

Measured memory_bytes: 3652
n=int(input())
arr=[]
for i in range(n):
    a,b,c=map(int,input().split())
    arr.append([a,b,c])
dp0=[0]*n
dp1=[0]*n
dp2=[0]*n
dp0[0]=arr[0][0]
dp1[0]=arr[0][1]
dp2[0]=arr[0][2]
for i in range(1,n):
    dp0[i]=arr[i][0]+max(dp1[i-1],dp2[i-1])
    dp1[i]=arr[i][1]+max(dp0[i-1],dp2[i-1])
    dp2[i]=arr[i][2]+max(dp0[i-1],dp1[i-1])
print(max(dp0[n-1],dp1[n-1],dp2[n-1]))


Measured memory_bytes: 34676
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
ll ar[500009],br[500009];
int main()
{
    ll a,b,c,i,j,k=1;
    string s,d;
    char q,w;
    cin>>a;
    while(a!=1)
    {
        k++;
        a=a/2;
    }
    j=1ll<<k;
    cout<<j-1<<endl;

}



Measured memory_bytes: 256
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
// #pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx")
#include <cstdio>
#include <cstdint>
using namespace std;

uint_fast16_t d;
uint_fast32_t M = 0;
uint_fast64_t c, sd = 0, sc = 0;
char ct;

int main() {
    while((ct=getchar_unlocked())>47) M = M * 10 + ct - 48;
    while(M--) {
        c = 0;
        d = getchar_unlocked();
        getchar_unlocked();
        while((ct=getchar_unlocked())>47) c = c * 10 + ct - 48;
        sc += c;
        sd += c * (d - 48);
    }
    printf("%lld\n", --sc + --sd / 9);
	return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
#define rep(i,n) for (int i = (0); i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define rng(x) (x).begin(),(x).end()
#define rrng(x) (x).rbegin(),(x).rend()
#define limit(x,l,r) max(l,min(x,r))
#define lims(x,l,r) (x = max(l,min(x,r)))
#define isin(x,l,r) ((l) <= (x) && (x) < (r))
#define show(x) cout << #x << " = " << (x) << endl
#define show2(x,y) cout << #x << " = " << (x) << ", " << #y << " = " << (y) << endl
#define show3(x,y,z) cout << #x << " = " << (x) << ", " << #y << " = " << (y) <<  ", " << #z << " = " << (z) << endl
#define showv(v) rep(i,v.size()) printf("%d%c", v[i], i==v.size()-1?'\n':' ')
#define showv2(v) rep(j,v.size()) showv(v[j])
#define showt(t,n) rep(i,n) printf("%d%c", t[i], i==n-1?'\n':' ')
#define showt2(t,r,c) rep(j,r) showt(t[j],c)
#define showvp(p) rep(i,p.size()) printf("%d %d\n", p[i].first, p[i].second);
#define printv(v) rep(i,v.size()) printf("%d\n", v[i])
#define printt(t,n) rep(i,n) printf("%d\n", t[i])
#define incl(v,x) find(rng(v),x)!=v.end()
#define incls(s,c) s.find(c)!=string::npos
#define fi first
#define se second
#define pb push_back
#define eb emplace_back
#define sz(x) (int)(x).size()
#define pcnt __builtin_popcountll
#define bit(n,k) ((n>>k)&1) // nのk bit目
#define bn(x) ((1<<x)-1)
#define dup(x,y) (((x)+(y)-1)/(y))
#define newline puts("")
#define uni(x) x.erase(unique(rng(x)),x.end())
#define SP << " " <<
#define v(T) vector<T>
#define vv(T) v(v(T))
using namespace std;
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vl = vector<ll>;
using vs = vector<string>;
using P = pair<int, int>;
using T = tuple<int, int, int>;
using vp = vector<P>;
using vt = vector<T>;
const int mod = 1000000007;
const double EPS = 1e-9;
//const long double EPS = 1e-14;
const int INF = (1<<30)-1;
const ll LINF = (1LL<<62)-1;
#define dame { puts("No"); return 0;}
#define yn {puts("Yes");}else{puts("No");}
inline int in() { int x; scanf("%d",&x); return x;}
//template<class T = int> inline T in() { T x; cin >> x; return (x);}
template<typename T>inline ll suma(const v(T)& a) { ll res(0); for (auto&& x : a) res += x; return res;}
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
char itoa(int n) { return n + '0';}
ll gcd(ll a, ll b) { return b ? gcd(b,a%b) : a;}
ll lcm(ll a, ll b) { return a/gcd(a,b)*b;}

int main () {
  string s;
  vi cnt(26);
  while (getline(cin, s)) {
    rep(i,s.size()) {
      if ('A'<=s[i] && s[i]<='Z') s[i] += 'a'-'A';
      if ('a'<=s[i] && s[i]<='z') cnt[s[i]-'a']++;
    }
  }
  rep(i,26) {
    printf("%c : %d\n", i+'a', cnt[i]);
  }
  return 0;
}


Measured memory_bytes: 3328
from heapq import heappush, heappop


def solve(string):
    n, m, *a = map(int, string.split())
    h = []
    for _a in a:
        heappush(h, -_a)
    for _ in range(m):
        heappush(h, -(-heappop(h) // 2))
    return str(-sum(h))


if __name__ == '__main__':
    print(solve('\n'.join([input(), input()])))


Measured memory_bytes: 15176
#include <algorithm>
#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...)); }
/* clang-format on */

int main() {
  int N, x;
  while (cin >> N >> x) {
    vector<int> a(N);
    for (int i = 0; i < N; i++) cin >> a[i];
    sort(a.begin(), a.end());
    int res = 0;
    for (int y : a) {
      if (y > x) break;
      x -= y;
      ++res;
    }
    if (x > 0 && res >= N) {
      --res;
    }
    cout << res << endl;
  }
  return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
main(){
int a,b,c,d;
scanf("%d %d %d",&a,&b,&c);
if (a > b) {d=a;a=b;b=d;}
if (a > c) {d=a;a=c;c=d;}
if (b > c) {d=b;b=c;c=d;}
printf("%d %d %d\n",a,b,c);
}


Measured memory_bytes: 2092
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();
        int c = sc.nextInt();
        if (a < b) {
            if (b < c) {
                System.out.printf("%d %d %d\n", a, b, c);
            } else if (c < a) {
                System.out.printf("%d %d %d\n", c, a, b);
            } else {
                System.out.printf("%d %d %d\n", a, c, b);
            }
        } else {
            if (a < c) {
                System.out.printf("%d %d %d\n", b, a, c);
            } else if (b < c) {
                System.out.printf("%d %d %d\n", b, c, a);
            } else {
                System.out.printf("%d %d %d\n", c, b, a);
            }
        }
    }
}


Measured memory_bytes: 26504
class Soba
   def initialize(size,cost,discount,rate)
      @size=size
      @cost=cost
      @discount=discount
      @rate=rate*0.01
   end
   def buy(vol)
      return nil unless vol % @size == 0
      count=vol/@size
      buf=@cost*(count-(count % @discount))*(1-@rate)
      buf+=(count % @discount) * @cost
      return buf.to_i
   end
   def getsize
      @size
   end
end

arr=Array.new
arr << Soba.new(200,380,5,20)
arr << Soba.new(300,550,4,15)
arr << Soba.new(500,850,3,12)
until (n=gets.to_i) == 0 do
   table=Array.new
   ans=Array.new
   0.step(n,arr[0].getsize){|i|
      0.step(n,arr[1].getsize){|j|
         0.step(n,arr[2].getsize){|k|
         table << [i,j,k] if i + j + k == n
         }
      }
   }
   table.each{|e|
      ans << arr[0].buy(e[0])+arr[1].buy(e[1])+arr[2].buy(e[2])
   }
   puts ans.min
end

Measured memory_bytes: 6124
#include<bits/stdc++.h>
using namespace std;
#define fs first
#define sc second
#define mp make_pair
#define pb push_back
#define eb emplace_back
#define ALL(A) A.begin(),A.end()
#define RALL(A) A.rbegin(),A.rend()
typedef long long LL;
typedef pair<LL,LL> P;
const LL mod=1e9+7;
const LL LINF=1LL<<62;

int main(){
    int H,W;
    cin >> H >> W;
    char s[H][W];
    for(int i=0;i<H;i++){
        for(int j=0;j<W;j++){
            cin >> s[i][j];
        }
    }
    char c[H][W],t[H][W];
    for(int i=0;i<H;i++){
        for(int j=0;j<W;j++){
            if(i%2){
                if(s[i][j]=='#'||j==0) t[i][j]='#';
                else t[i][j]='.';
            }
            else{
                if(j==W-1&&s[i][j]!='#') t[i][j]='.';
                else t[i][j]='#';
            }
        }
    }
    for(int i=0;i<H;i++){
        for(int j=0;j<W;j++){
            if(i%2==0){
                if((s[i][j]=='#'||j==W-1)&&W!=0) c[i][j]='#';
                else c[i][j]='.';
            }
            else{
                if(j==0&&s[i][j]!='#') c[i][j]='.';
                else c[i][j]='#';
            }
        }
    }
    for(int i=0;i<H;i++){
        for(int j=0;j<W;j++){
            cout << t[i][j];
        }
        cout << "\n";
    }
    cout << "\n";
    for(int i=0;i<H;i++){
        for(int j=0;j<W;j++){
            cout << c[i][j];
        }
        cout << "\n";
    }
    return 0;
}

Measured memory_bytes: 1408
#include "bits/stdc++.h"

#define REP(i,n) for(ll i=0;i<ll(n);++i)
#define RREP(i,n) for(ll i=ll(n)-1;i>=0;--i)
#define FOR(i,m,n) for(ll i=m;i<ll(n);++i)
#define RFOR(i,m,n) for(ll i=ll(n)-1;i>=ll(m);--i)
#define ALL(v) (v).begin(),(v).end()
#define UNIQUE(v) v.erase(unique(ALL(v)),v.end());
#define INF 1000000001ll
#define MOD 1000000007ll
#define EPS 1e-9

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


using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vi> vvi;
typedef vector<vl> vvl;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;



int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	int n;
	while (cin >> n, n) {
		vl v(n);
		ll sum = 0;
		REP(i, n) {
			cin >> v[i];
			sum += v[i];
		}
		int cnt = 0;
		REP(i, n) {
			if (v[i] * n <= sum)cnt++;
		}
		cout << cnt << endl;
	}

}


Measured memory_bytes: 3264
/*
 _____ _             _              _           _ 
|_   _| |__   ___   / \   _ __  ___| |__  _   _| |
  | | | '_ \ / _ \ / _ \ | '_ \/ __| '_ \| | | | |
  | | | | | |  __// ___ \| | | \__ \ | | | |_| | |
  |_| |_| |_|\___/_/   \_\_| |_|___/_| |_|\__,_|_|                                                

*/
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp>
#define ll          long long
#define pb          push_back
#define ppb         pop_back
#define	endl		'\n'
#define mii         map<ll,ll>
#define msi         map<string,ll>
#define mis         map<ll, string>
#define rep(i,a,b)    for(ll i=a;i<b;i++)
#define repr(i,a,b) for(ll i=b-1;i>=a;i--)
#define trav(a, x) 	for(auto& a : x)
#define pii         pair<ll,ll>
#define vi          vector<ll>
#define vii         vector<pair<ll, ll>>
#define vs          vector<string>
#define all(a)      (a).begin(),(a).end()
#define F           first
#define S           second
#define sz(x)       (ll)x.size()
#define hell        1000000007
#define lbnd        lower_bound
#define ubnd        upper_bound
#define max(a,b)	(a>b?a:b)
#define min(a,b)	(a<b?a:b)

/*	For Debugging	*/
#define DEBUG 		cerr<<"\n>>>I'm Here<<<\n"<<endl;
#define display(x) trav(a,x) cout<<a<<" ";cout<<endl;
#define what_is(x)  cerr << #x << " is " << x << endl;

std::mt19937_64 rng(std::chrono::steady_clock::now().time_since_epoch().count());
#define ordered_set tree<ll, null_type,less<ll>, rb_tree_tag,tree_order_statistics_node_update> 
#define TIME        cerr << "\nTime elapsed: " << setprecision(5) <<1000.0 * clock() / CLOCKS_PER_SEC << "ms\n";
#define DECIMAL(n)  cout << fixed ; cout << setprecision(n);
#define FAST ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
using namespace __gnu_pbds;
using namespace std;
#define PI 3.141592653589793
#define N  100005
ll t[N];
ll expo(ll base, ll exponent, ll mod) {								//return base^exponent modulo modulus
    ll ans = 1;
    while(exponent !=0 ) {
        if((exponent&1) == 1) {
            ans = ans*base ;
            ans = ans%mod;
        }
        base = base*base;
        base %= mod;
        exponent>>= 1;
    }
    return ans%mod;
}
void solve()
{
	ll n,k;
	cin>>k>>n;
	t[1]=1;
	ll sum=0;
	rep(j,2,n+1)
	{
		sum=0;
		for (int i = 1, la; i <= j; i = la + 1) {
			la = j / (j / i);
			//n / x yields the same value for i <= x <= la.
			sum=(sum+t[j/i]*(la-i+1))%hell;
		}
		t[j]=(expo(j,k,hell)-sum+hell)%hell;
	}
	// rep(i,1,n+1)
	// {
	// 	cout<<t[i]<<" ";
	// }
	// cout<<endl;
	ll ans=0;
	rep(i,1,n+1)
	{
		ans=(ans+i*t[n/i])%hell;
	}
	cout<<ans<<endl;
	return;
}
int main()
{
	FAST
	int TESTS=1;
//	cin>>TESTS;
	while(TESTS--)
	{
		solve();
	}
	TIME
	return 0;
}

Measured memory_bytes: 4572
w=input()
w_list=list(w)
w_unique=list(set(w_list))
c=0
for x in w_unique:
    if w_list.count(x)%2==0:
        c=c
    else:
        c+=1
        
if c==0:
    print('Yes')
    
else:
    print("No")
    

        
        

Measured memory_bytes: 2940
import bisect

N = int(input())
L = list(map(int,input().split()))
L.sort()

cnt = 0
for first in range(N):
    for second in range(first+1,N):
        bnd = bisect.bisect_left(L,L[first]+L[second]) - 1
        dif = bnd - second
        if dif > 0:
            cnt += dif

print(cnt)


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

#define int long long
#define pb push_back
#define vi vector<int>
#define pi pair<int,int>
#define vii vector<pi>
#define ps(x,y) fixed<<setprecision(y)<<x
#define w(t) int t;cin>>t;while(t--)solve()
#define debug(...) fprintf(stderr, __VA_ARGS__), fflush(stderr)
#define f(n) for (int i=0;i<n;++i)
#define init(arr,m,n,value) std::fill(*arr,*arr+m*n,value)
#define low(s) transform(s.begin(),s.end(),s.begin(),::tolower)
#define up(s) transform(s.begin(),s.end(),s.begin(),::toupper)
//debug("Total Time: %.3f\n", (double)(clock() - z) / CLOCKS_PER_SEC);

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

int binpow(int a, int b) {
    int res = 1;
    while (b > 0) {
        if (b & 1)res = res * a;
        a = a * a;
        b >>= 1;
    }
    return res;
}

void solve(){
	
}

int32_t main(){
	ios::sync_with_stdio(0);
	cin.tie(0);
	//clock_t z = clock();
	int n;
	cin>>n;
	int ans=0;
	for (int i=1;i<n;++i)ans+=(n-1)/i;
	cout<<ans;

}


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

int gcd(int a, int b)
{
	int x = 0;

	if (b == 0) return a;
	else x = gcd(b, a % b);

	return x;
}

int main(void)
{
	int K;
	cin >> K;

	int64_t sum = 0;

	for (int i = 1; i < K + 1; i++) {
		for (int j = 1; j < K + 1; j++) {
			for (int k = 1; k < K + 1; k++) {
				sum += gcd(gcd(i, j), k);
			}
		}
	}

	cout << sum << endl;

	return 0;
}


Measured memory_bytes: 3624
package main

import (
	"bufio"
	"fmt"
	"math"
	"os"
	"strconv"
)

var sc = bufio.NewScanner(os.Stdin)

func swap(a int64, b int64) (int64, int64) {
	return b, a
}

func gcd(a int64, b int64) int64 {
	if b > a {
		a, b = swap(a, b)
	}
	if b == 0 {
		return a
	} else {
		return gcd(a%b, b)
	}
}

func nextInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}

func min(nums ...int64) int64 {
	if len(nums) == 0 {
		panic("funciton min() requires at least one argument.")
	}
	res := nums[0]
	for i := 0; i < len(nums); i++ {
		res = int64(math.Min(float64(res), float64(nums[i])))
	}
	return res
}

func max(nums ...int64) int64 {
	if len(nums) == 0 {
		panic("funciton max() requires at least one argument.")
	}
	res := nums[0]
	for i := 0; i < len(nums); i++ {
		res = int64(math.Max(float64(res), float64(nums[i])))
	}
	return res
}

func nextLong() int64 {
	sc.Scan()
	i, e := strconv.ParseInt(sc.Text(), 10, 64)
	if e != nil {
		panic(e)
	}
	return i
}

func nextString() string {
	sc.Scan()
	s := sc.Text()
	return s
}

func main() {
	sc.Split(bufio.ScanWords)
	N := nextLong()
	A := nextLong()
	minnum := A
	B := nextLong()
	minnum = min(minnum, B)
	C := nextLong()
	minnum = min(minnum, C)
	D := nextLong()
	minnum = min(minnum, D)
	E := nextLong()
	minnum = min(minnum, E)
	ans := int64(math.Ceil(float64(N)/float64(minnum)) + 4)
	fmt.Printf("%d\n", ans)
}


Measured memory_bytes: 640
class CircleInaRectangle:
    def __init__(self, W, H, x, y, r):
        if 0 <= x - r and 0 <= y - r and x + r <= W and y + r <= H:
            print "Yes"
        else:
            print "No"

if __name__ == "__main__":
    W, H, x, y, r = map(int, raw_input().split())
    CircleInaRectangle(W, H, x, y, r)

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

using namespace std;

int main(){
	int x,y;
	while(true){
		cin >> x >> y;
		if(x==0&&y==0){
			break;
		}
		if(x<y)
			cout << x << " " << y << endl;
		else
			cout << y << " " << x << endl;
	}
}


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

void solver() {
  long long  n;
  cin >> n;

  long long minA = 1000000;
  long long ans = 0;
  for (long long i = 0; i < n; i++) {
    long long a;
    cin >> a;

    if (minA > a) ans++;
    minA = min(minA, a);
  }

  cout << ans << "\n";
}

int main() {
  solver();
}


Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main() {
    int x,y,i,z;
    cin >> x >> y;
    
    for(i=1;i<=10000;i++){
        if(x==0 && y==0){
            break;
        }
        if(x>y){
        cout << y <<" "<< x<<endl;
        cin >> x >> y;
       
        }
        else{
          cout << x <<" "<< y<<endl;
          cin >> x >> y;
        }
    }
    
}


Measured memory_bytes: 3008
#include "stdio.h"

int main(void) {
  int A;
  int B;
  int C;
  int X;
  int sum;
  int cnt;
  int i, j, h;
  int sum500 ,sum100, sum50;
  
  scanf("%d", &A);
  scanf("%d", &B);
  scanf("%d", &C);
  scanf("%d", &X);
  
  sum = 0;
  cnt = 0;
  for (i = 0; i <= A; i++){
    sum500 = 500 * i;
    sum = sum500;
    if(sum == X){
      cnt = cnt + 1;
      continue;
    }
    else if(sum > X)
    {
      continue;
    }
    
    for(j=0; j<=B; j++){
      sum100 = (100 * j);
      
      sum = sum500 + sum100;
      if(sum == X)
      {
        cnt = cnt + 1;
        continue;
      }
      else if(sum > X)
      {
        sum = sum500;
        continue;
      }
      
      for(h=0; h<=C; h++){
        sum50 = (50 * h);
        sum = sum500 + sum100 + sum50;
        
        if(sum == X)
        {
          cnt = cnt + 1;
          continue;
        }
        else if(sum > X)
        {
          sum = sum500 + sum100;
          continue;
        }
      }  
    }
  }
  printf("%d\n", cnt);
  
  return 0;
}

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

int main()
{
    long double a, b, n;
    cin >> a >> b >> n;

    if (n >= b)
    {
        cout << floorl(a * (b - 1) / b) - a * floorl((b - 1) / b) << endl;
    }
    else
    {

        cout << floorl(a * n / b) - a * floorl(n / b) << endl;
    }

    return 0;
}

Measured memory_bytes: 3796
using System;
using System.Linq;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics.CodeAnalysis;

namespace ConsoleApp1
{
    class Program
    {
        static void Main(string[] args)
        {

            string[] data = Console.ReadLine().Split(' ');
            int N = int.Parse(data[0]);
            int K = int.Parse(data[1]);
            int[] Arr = Console.ReadLine().Split(' ').Select(int.Parse).ToArray();

            for (int i = 0; i < N - K; i++) 
            {
                if (Arr[i] >= Arr[i + K])
                {
                    Console.WriteLine("No");
                }
                else 
                {
                    Console.WriteLine("Yes");
                }
            }

        }
    }
}


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

int main()
{
    int a, b, c;
    scanf("%d %d %d", &a, &b, &c);

   if(c == a + b || b == a + c || a == b + c)
    printf("Yes\n");
   else
    printf("No\n");
    return 0;
}


Measured memory_bytes: 3592
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
//#define mod 1000000007
#define F first
#define S second
#define endl "\n"
#define nl cout<<endl
#define pb push_back
#define f(i,a,b) for(ll i=a;i<b;i++)
#define Knucklehead ios_base::sync_with_stdio(false);cin.tie(NULL);
#define txti freopen("input.txt", "r", stdin);
#define txto freopen("output.txt", "w", stdout);


bool compare(char &s1,char &s2) 
{ 
    return s1 > s2; 
} 

bool sortmahstyle(const pair<ll,ll> &a,  const pair<ll,ll> &b) 
{ 

    if(a.second > b.second )
        return true;
    if( a.second==b.second && a.first > b.second )
       return true;

    return false;

}
ll const mod = 1e9+7;
ll const inf = 1e5+1;


void solve()
{
    ll l,r,d; cin >> l >> r >> d;

    ll ans = 0;
    for(ll i =l; i<=r; i++)
        if(i%d==0)
            ans++;

    cout << ans << endl;
}
int main() {
Knucklehead 
/*
#ifndef ONLINE_JUDGE
freopen("input.txt", "r", stdin);
freopen("output.txt", "w", stdout);
#endif
/**/

        ll t=1;
        //ll t;cin>>t;
        while(t-->0){
            solve();

        }




    return 0;
}

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

#define __STDC_FORMAT_MACROS
#define p64 PRId64

#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) FOR (i, 0, n)
#define ALL(f, x, ...)                                                         \
    ([&] (decltype ((x)) ALL) {                                                \
        return (f) (begin (ALL), end (ALL), ##__VA_ARGS__);                    \
    }) (x)

using namespace std;
using ll = int64_t;

template<class T> void gc (T& x) {
    char c;
    int s = 0;
    x = 0;
    c = getchar_unlocked();
    if (c == '-')
        s = 1;
    else if ('0' <= c && c <= '9')
        x = c - '0';
    while (true) {
        c = getchar_unlocked();
        if (c < '0' || '9' < c)
            break;
        x = x * 10 + (c - '0');
    }
    if (s)
        x = -x;
}

int main() {
    int N, K;
    cin >> N >> K;
    vector<int> A (N, 1);
    FOR (i, 0, K) {
        int d;
        cin >> d;
        vector<int> arr (d);
        FOR (j, 0, d) {
            cin >> arr[j];
            A[--arr[j]] = 0;
        }
    }
    int ans = 0;
    FOR (i, 0, N) {
        ans += A[i];
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 3640
import java.util.Scanner;

public class Main {
  private static void solve(int n, int[] a, int[] b) {
    int[] sumA = new int[n + 1];
    int[] sumB = new int[n + 1];
    for (int i = 0; i < n; i++) {
      sumA[i + 1] = sumA[i] + a[i];
      sumB[i + 1] = sumB[i] + b[i];
    }
    int max = 0;
    for (int i = 1; i <= n; i++) {
      int sum = sumA[i] + sumB[n] - sumB[i - 1];
      max = Math.max(max, sum);
    }
    System.out.println(max);
  }
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int n = Integer.parseInt(sc.nextLine());
    String[] as = sc.nextLine().split(" ");
    String[] bs = sc.nextLine().split(" ");
    sc.close();
    int[] a = new int[n];
    int[] b = new int[n];
    for (int i = 0; i < n; i ++) a[i] = Integer.parseInt(as[i]);
    for (int i = 0; i < n; i ++) b[i] = Integer.parseInt(bs[i]);
    solve(n, a, b);
  }
}

Measured memory_bytes: 23764
def factorize(n):
    a=[]
    while n%2==0:
        a.append(2)
        n//=2
    f=3
    while f*f<=n:
        if n%f==0:
            a.append(f)
            n//=f
        else:
            f+=2
    if n!=1:
        a.append(n)
    return a
n = int(input())
li = list(map(int,input().split()))
lia = []
for i in range(n):
    fac = factorize(li[i])
    count = fac.count(2)
    lia.append(count)
print(min(lia))

Measured memory_bytes: 8976
import math
import itertools
import statistics
#import collections
#x = int(input())
#k, n = (map(int, input().split()))
#A= (map(int, input().split()))

#x個の赤りんごp　y緑りんごq c個無色r
#n =  list(map(int, input().split()))
s = input()
max_ = 0
count = 0

for i in range(len(s)):
    if s[i] in ("A", "T", "C", "G"):
        count +=1
    else:
        count = 0

    if max_ <= count:
        max_ = count
    
    

print(max_)



Measured memory_bytes: 5268
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <vector>
#include <numeric>
#include <set>
#include <cstdlib>
#include <queue>

using namespace std;

typedef long long llint;
typedef long double ld;

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

llint w,v;
llint n;
llint weight[105],value[105];
llint dp[105][100005];
void solve(){
  cin >> n >> w;
  for(int i=0;i<n;i++)cin >> weight[i] >> value[i];

  for(int i=0;i<n;i++){
    for(int sum_w=0;sum_w<=w;sum_w++){
      if (sum_w - weight[i] >= 0){
        chmax(dp[i+1][sum_w], dp[i][sum_w - weight[i]] + value[i]);
      }
      chmax(dp[i+1][sum_w],dp[i][sum_w]);
    }
  }
  cout << dp[n][w] << endl;
}

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


Measured memory_bytes: 79360
H, W = map(int, input().split())

dist_list = [list(map(int, input().split())) for _ in range(10)]

for k in range(10):
    for i in range(10):
        for j in range(10):
            dist_list[i][j] = min(dist_list[i][j], dist_list[i][k] + dist_list[k][j])


A = [list(map(int, input().split())) for _ in range(H)]
ans = 0
for i in range(H):
    for j in range(W):
        if A[i][j] != -1:
            ans += dist_list[A[i][j]][1]
print(ans)

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

typedef long long ll;
#define rep(i, n) for (int(i) = 0; (i) < (n); (i)++)
#define debug(x) cerr << #x << ": " << x << '\n'

int main()
{
    string S;
    int win = 0;
    cin >> S;

    for (int i = 0; i < S.length(); ++i)
    {
        if (S[i] == 'o')
        {
            ++win;
        }
    }

    if (15 - S.length() + win > 7)
    {
        cout << "YES" << endl;
    }
    else
    {
        cout << "NO" << endl;
    }
}


Measured memory_bytes: 256