akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <cmath>
using namespace std;
#define fo(i,l,r) for (int i = l; i < r; i++)
typedef long long ll;

int main() {
    int n, k; cin >> n >> k;
    int a[n];
    fo(i,0,n) cin >> a[i];
    cout << ((int)ceil((n-k) * 1.0 / (k-1)) + 1) << endl;
    return 0;
}


Measured memory_bytes: 640
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include<bits/stdc++.h>
#define endl "\n"
using namespace __gnu_pbds;
using namespace std;
typedef tree<int, null_type, less<int>, rb_tree_tag, 
             tree_order_statistics_node_update> 
    PBDS;
typedef long long int ll;
const int N=1e5;
void solve(){
	int n,k;
	cin>>n>>k;
	int arr[n];
	int dp[n];
	int x=1e6;
	memset(dp,x,sizeof(dp));
	for(int i=0;i<n;i++)cin>>arr[i];
	dp[0]=0;
//dp[1]=abs(arr[1]-arr[0]);
		for(int i=1;i<n;i++){
			for(int j=1;j<=k;j++){
				if(i-j>=0)
			dp[i]=min(dp[i],dp[i-j]+abs(arr[i]-arr[i-j]));
		else break;
		}
		}
		cout<<dp[n-1]<<endl;
}
int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
#ifndef ONLINE_JUDGE
	freopen("input.txt","r",stdin);
	freopen("output (2).txt","w",stdout);
#endif
	int t;
	t=1;
	while(t--){
	solve();
	}
	return 0;
}


Measured memory_bytes: 4416
using System;
using System.Linq;

namespace atcoder.abc172.c
{
    class Program
    {
        static void Main(string[] args)
        {
            int[] paramArray = getIntParams();
            int N = paramArray[0];
            int M = paramArray[1];
            int K = paramArray[2];

            long[] A = getLongParams();
            long[] B = getLongParams();

            long[] sumA = new long[N + 1];
            long[] sumB = new long[M + 1];

            for (int c = 0; c < N; c++)
            {
                sumA[c + 1] = sumA[c] + A[c];
            }
            for (int c = 0; c < M; c++)
            {
                sumB[c + 1] = sumB[c] + B[c];
            }

            long ret = 0;
            int j = M;
            for (int i = 0; i <= N; i++)
            {
                long remain = K - sumA[i];
                if (remain < 0)
                {
                    break;
                }

                while (sumB[j] > remain)
                {
                    j--;
                }
                ret = Math.Max(ret, i + j);
            }
            Console.WriteLine(ret);
        }

        //↓↓↓ shared function ↓↓↓
        static int getIntParam()
        {
            return int.Parse(Console.ReadLine());
        }
        static int[] getIntParams()
        {
            return Console.ReadLine().Split(' ').Select(i => int.Parse(i)).ToArray();
        }
        static long getLongParam()
        {
            return long.Parse(Console.ReadLine());
        }
        static long[] getLongParams()
        {
            return Console.ReadLine().Split(' ').Select(i => long.Parse(i)).ToArray();
        }
        static string getStringParam()
        {
            return Console.ReadLine();
        }
        static string[] getStringParams()
        {
            return Console.ReadLine().Split(' ');
        }
    }
}


Measured memory_bytes: 72992
using System;
using System.Collections;
using System.Collections.Generic;
using System.Collections.Specialized;
using System.Linq;
using System.Numerics;

namespace AtCoderWorkspace
{
    public class Solver
    {
        public void Solve()
        {
            var cin = new Scanner();
            var s = cin.next();
            var list = new Stack<char>();
            foreach (var ss in s)
            {
                if ('B' != ss)
                {
                    list.Push(ss);
                }
                else
                {
                    if(list.Count!=0)
                    list.Pop();
                }
            }
            var ans = "";
            var ii = list.Count();
            for (int i = 0; i < ii; i++)
            {
                ans = "" + list.Pop() + ans;
            }
            Console.WriteLine(ans);
        }
    }    

    class Scanner
    {
        string[] s;
        int i;

        char[] cs = new char[] { ' ' };

        public Scanner()
        {
            s = new string[0];
            i = 0;
        }

        public string next()
        {
            if (i < s.Length) return s[i++];
            string st = Console.ReadLine();
            while (st == "") st = Console.ReadLine();
            s = st.Split(cs, StringSplitOptions.RemoveEmptyEntries);
            if (s.Length == 0) return next();
            i = 0;
            return s[i++];
        }

        public int nextInt()
        {
            return int.Parse(next());
        }
        public int[] ArrayInt(int N, int add = 0)
        {
            int[] Array = new int[N];
            for (int i = 0; i < N; i++)
            {
                Array[i] = nextInt() + add;
            }
            return Array;
        }

        public int[] DPArrayInt(int N, int ex)
        {
            int[] Array = new int[N + ex];
            for (int i = 0; i < N; i++)
            {
                Array[i] = nextInt();
            }
            return Array;
        }

        public long nextLong()
        {
            return long.Parse(next());
        }

        public long[] ArrayLong(int N, long add = 0)
        {
            long[] Array = new long[N];
            for (int i = 0; i < N; i++)
            {
                Array[i] = nextLong() + add;
            }
            return Array;
        }

        public long[] DPArrayLong(int N, int ex)
        {
            long[] Array = new long[N + ex];
            for (int i = 0; i < N; i++)
            {
                Array[i] = nextLong();
            }
            return Array;
        }

        public double nextDouble()
        {
            return double.Parse(next());
        }


        public double[] ArrayDouble(int N, double add = 0)
        {
            double[] Array = new double[N];
            for (int i = 0; i < N; i++)
            {
                Array[i] = nextDouble() + add;
            }
            return Array;
        }
    }

    class Program
    {
        static void Main(string[] s) => new Solver().Solve();
    }
}

Measured memory_bytes: 11348
/*      Welcome to my Code      */
 
#include <bits/stdc++.h>
#define ll                      long long int
#define i(a,n)                  int a=n;
#define l(a,n)                  ll a=n;
#define d(a,n)                  double a=n;
#define s(a)                    string a;
#define c(a)                    ll a; cin>>a;a
#define cd(a)                   double a; cin>>a;
#define cs(a)                   string a; cin>>a;
#define ci(a)                   cin>>a;
#define co(a)                   cout<<a;
#define cos(a)                  cout<<a<<" "
#define con(a)                  cout<<a<<endl
#define yes                     cout<<"YES"<<endl
#define no                      cout<<"NO"<<endl
#define nl                      cout<<endl
#define ca(arr,n)               for(ll i=0;i<n;i++) cin>>arr[i]
#define caa(arr,n)              c(n); ll arr[n]; for(ll i=0;i<n;i++) cin>>arr[i];
#define f0(i,a,n)               for(ll i=a;i>=n;i--)
#define f(i,n)                  for(ll i=0;i<n;i++)
#define f1(i,a,n)               for(ll i=a;i<n;i++)
#define lcm(a,b)                (a*b)/__gcd(a,b)
#define T                       ll t=1; cin>>t; while(t--)
#define fast                    ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL)
#define ret(x)                  return cout<<x,0;
 
using namespace std;
 
int main()
{
    fast;
    c(x);c(k);c(d);
    x=abs(x);
    if(x/d>=k) con(x-(k*d));
    else
    {
        k=k-x/d;
        if(k%2) con(abs(x%d-d));
        else con(x%d);
    }
    return 0;
}
 
/*It's not who I am underneath, but what I do that defines me
 
MMMMMMMMMMMMMMMMMMMMM.                             MMMMMMMMMMMMMMMMMMMMM
 `MMMMMMMMMMMMMMMMMMMM           M\  /M           MMMMMMMMMMMMMMMMMMMM'
   `MMMMMMMMMMMMMMMMMMM          MMMMMM          MMMMMMMMMMMMMMMMMMM'
     MMMMMMMMMMMMMMMMMMM-_______MMMMMMMM_______-MMMMMMMMMMMMMMMMMMM
      MMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMM
      MMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMM
      MMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMM
     .MMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMM.
    MMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMM
                   `MMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMM'
                          `MMMMMMMMMMMMMMMMMM'
                              `MMMMMMMMMM'
                                 MMMMMM
                                  MMMM
                                   MM
*/

Measured memory_bytes: 3604
#include <cstdio>
#include <cstdlib>
#include <iostream>
#include <fstream>
#include <sstream>
#include <set>
#include <map>
#include <vector>
#include <list>
#include <algorithm>
#include <cstring>
#include <cmath>
#include <string>
#include <stack>
#include <queue>
#include <bitset>     //UWAGA - w czasie kompilacji musi byc znany rozmiar wektora - nie mozna go zmienic
#include <cassert>
#include <iomanip>        //do setprecision
#include <ctime>
#include <complex>
using namespace std;

#define FOR(i,b,e) for(int i=(b);i<(e);++i)
#define FORQ(i,b,e) for(int i=(b);i<=(e);++i)
#define FORD(i,b,e) for(int i=(b)-1;i>=(e);--i)
#define REP(x, n) for(int x = 0; x < (n); ++x)

#define ST first
#define ND second
#define PB push_back
#define PF push_front
#define MP make_pair
#define LL long long
#define ULL unsigned LL
#define LD long double
#define pii pair<int,int>
#define pll pair<LL,LL>
#define vi vector<int>
#define vl vector<LL>
#define vii vector<vi>
#define vll vector<vl>

const double pi = 3.14159265358979323846264;
const int mod=1000000007;

int main(){
	char c;
    cin>>c;
    cout<<(char)(c+1)<<endl;
}


Measured memory_bytes: 256
import collections
N = int(input())
A = list(map(int,input().split()))
S = set()
D = set()
for a in A:
    if a in S:
        D.add(a)
    else:
        S.add(a)
M = max(S)
A = [0]*(M+1)
for s in S:
    if s in D:
        A[s] += 1
    for i in range(2*s,M+1,s):
        A[i]+=1
count = 0
for s in S:
    if A[s]==0:
        count += 1
print(count)


Measured memory_bytes: 121532
import java.io.BufferedInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.util.Arrays;

public class Main {
	private static final int MOD = 1000000007;

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

		while (true) {
			Arrays.sort(A);
			debug(A);

			int a = 0;
			int i;
			for (i = 0; i < A.length; i++) {
				if (A[i] != 0) {
					a = A[i];
					break;
				}
			}

			if (i == A.length - 1) {
				break;
			}

			for (i++; i < A.length; i++) {
				A[i] = A[i] % a;
			}
		}

		System.out.println(A[N - 1]);
	}

	private static boolean isDebug = System.getProperty("sun.desktop") != null;

	private static void debug(Object... o) {
		if (isDebug) {
			System.err.println(Arrays.deepToString(o));
		}
	}

	public static class Scanner {
		private BufferedInputStream inputStream;

		public Scanner(InputStream in) {
			inputStream = new BufferedInputStream(in);
		}

		public int nextInt() throws IOException {
			int num = 0;

			int read = skip();
			do {
				num = num * 10 + (read - 0x30);
			} while ((read = inputStream.read()) > 0x20);

			return num;
		}

		public void fill(int[] a) throws IOException {
			for (int i = 0; i < a.length; i++) {
				a[i] = nextInt();
			}
		}

		public void fill(int[] a, int[] b) throws IOException {
			if (a.length != b.length) {
				throw new IllegalArgumentException();
			}

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

		public long nextLong() throws IOException {
			long num = 0;

			int read = skip();
			do {
				num = num * 10 + (read - 0x30);
			} while ((read = inputStream.read()) > 0x20);

			return num;
		}

		public void fill(long[] a) throws IOException {
			for (int i = 0; i < a.length; i++) {
				a[i] = nextLong();
			}
		}

		public void fill(long[] a, long[] b) throws IOException {
			if (a.length != b.length) {
				throw new IllegalArgumentException();
			}

			for (int i = 0; i < a.length; i++) {
				a[i] = nextLong();
				b[i] = nextLong();
			}
		}

		public long[] nextLong(int n) throws IOException {
			long[] array = new long[n];
			for (int i = 0; i < n; i++) {
				array[i] = nextLong();
			}

			return array;
		}

		public String next() throws IOException {
			StringBuilder builder = new StringBuilder();

			int read = skip();
			do {
				builder.append((char) read);
			} while ((read = inputStream.read()) > 0x20);

			return builder.toString();
		}

		private int skip() throws IOException {
			int read;
			while ((read = inputStream.read()) <= 0x20)
				;

			return read;
		}
	}
}

Measured memory_bytes: 24632
import java.util.Arrays;
import java.util.Scanner;
public class Main {
@SuppressWarnings("resource")
public static void main(String[] args) {
	Scanner sc =new Scanner(System.in);
	int N=sc.nextInt();
	int[] L=new int[N];
	int[] L2=new int[N];
	for(int i=0;i<N;i++) {
		L[i]=sc.nextInt();
	}
	Arrays.sort(L);
	for(int i=0;i<N;i++) {
		L2[i]=L[N-1-i];
	}
	int ans=0;
	for(int i=0;i<N-2;i++) {
		for(int j=i+1;j<N-1;j++) {
			for(int z=j+1;z<N;z++) {
				if(L2[i]<L2[j]+L2[z]) {
					ans++;
				}
			}
		}
	}
	System.out.println(ans);
}
}

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

#define MAX 101
int G[MAX][MAX];
int V;

int main()
{
    std::scanf("%d", &V);
    int source, E, tmp;

    for (int i = 1; i <= V; i++) {
        for (int j = 1; j <=V; j++) G[i][j] = 0;
    }


    for (int i = 0; i < V; i++) {
        std::scanf("%d %d", &source, &E);
        if (E > 0) {
            for (int j = 0; j < E; j++) {
                std::scanf("%d", &tmp);
                G[source][tmp] = 1;
            }
        }
    }

    for (int i = 1; i <= V; i++) {
        for (int j = 1; j <= V; j++) {
            if (j > 1) std::printf(" ");
            std::printf("%d", G[i][j]);
        }
        std::printf("\n");
    }

    return 0;
}



Measured memory_bytes: 3224
import java.util.*;
  
public class Main {
    Scanner sc = new Scanner(System.in);
  
    public static void main(String[] args) {
        new Main(); 
    }
  
    public Main() {
        new A().doIt();
    }
    class A{
    	int map[][];
    	int W = 0;int B = 0;int X = 0;int Y = 0;
    	int mx[] = {0,1,0,-1};
    	int my[] = {1,0,-1,0};
    	boolean w,b;
    	
    	int dfs(int y,int x,int cnt){
    		if(cnt == 0){
    			map[y][x] = -1;
    			cnt++;
    		}
    		for(int i = 0;i < 4;i++){
    			if(x + mx[i] < X && x + mx[i] >= 0 &&
    					y + my[i] < Y && y + my[i] >= 0){
    				if(map[y + my[i]][x + mx[i]] == 0){
    					map[y + my[i]][x + mx[i]] = -1;
    					cnt = dfs(y + my[i],x + mx[i],cnt+1);
    				}else if(map[y + my[i]][x + mx[i]] == 1){
    					w = true;
    				}else if(map[y + my[i]][x + mx[i]] == 2){
    					b = true;
    				}
    			}
    		}
    		if(w && b)cnt = 0;
    		return cnt;
    	}
    	
    	void check(){
    		for(int i = 0;i < Y;i++){
    			for(int j = 0;j < X;j++){
    				System.out.printf("%3d",map[i][j]);
    			}
    			System.out.println();
    		}
    		System.out.println();
    	}
    	
        void doIt(){
        	while(true){
        		B = 0;W = 0;
        		X = sc.nextInt();
        		Y = sc.nextInt();
        		if(X + Y == 0)break;
        		map = new int [Y][X];
        		for(int i = 0;i < Y;i++){
        			String str = sc.next();
        			char ctr[] = str.toCharArray();
        			for(int j = 0;j < X;j++){
        				if(ctr[j] == 'W')map[i][j] = 1;
        				else if(ctr[j] == 'B')map[i][j] = 2;
        				else map[i][j] = 0;
        			}
        		}
        		for(int i = 0;i < Y;i++){
        			for(int j = 0;j < X;j++){
        				if(map[i][j] == 0){
        					w = false;b = false;
        					int cnt = dfs(i,j,0);
//        					System.out.println(w+" "+b+" "+cnt);
//        					check();
        					if(w && !b)W += cnt;
        					else if(!w && b)B += cnt;
        				}
        			}
        		}
        		System.out.println(B+" "+W);
        	}
        }
    }
}

Measured memory_bytes: 36504
// #define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(v) v.begin(), v.end()
#define Graph vector<vector<int>>
typedef long long ll;
typedef pair<int, int> P;
const int INF = 1000000007;

// #include <boost/multiprecision/cpp_dec_float.hpp>
// #include <boost/multiprecision/cpp_int.hpp>
// namespace mp = boost::multiprecision;
// using Bint = mp::cpp_int;
// using Real = mp::number<mp::cpp_dec_float<1024>>;

int main(){
    string S, S_top;
    int Q;
    cin >> S >> Q;
    int rev = 0;
    rep(i, Q){
        int T;
        cin >> T;
        if(T == 1){
            rev++;
            continue;
        } else {
            int F;
            char C;
            cin >> F >> C;
            if( (rev + F) % 2 == 1 ) S_top += C;
            else S += C;
        }
    }

    if(rev % 2 == 0){
        reverse(all(S_top));
        S_top += S;
        cout << S_top << endl;
    }
    else if(rev % 2 == 1){
        reverse(all(S));
        S += S_top;
        cout << S << endl;
    } 

}

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

#define fastIO ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
typedef long long ll ;
typedef long double ld ;

const ll MOD = 998244353, INF = 1E18 + 5 ;
const double PI = 2 * acos(0.0) ;
const long double EPS = 1.0E-14 ;

ll n, W ;
ll arrW[105], arrC[105], dp[105][100005] ;

ll check(ll nVal, ll weight)
{
    if (dp[nVal][weight] != -1) return dp[nVal][weight] ;
    if (nVal == 0 or weight == 0) {
        return 0 ;
    }
    if (arrW[nVal] > weight) {
        dp[nVal][weight] = check(nVal - 1, weight) ;
    }
    else {
        dp[nVal][weight] = max( (check(nVal - 1, weight - arrW[nVal]) + arrC[nVal]), check(nVal - 1, weight) ) ;
    }
    return dp[nVal][weight] ;
}

int main()
{
    ll ans = 0 ;
    cin >> n >> W ;
    for (int i = 1; i <= n; i++) {
        scanf("%lld %lld", &arrW[i], &arrC[i]) ;
    }
    for (int i = 1; i <= n; i++) {
        for (int j = 1; j <= W; j++) {
            dp[i][j] = -1 ;
        }
    }
    ans = check(n, W) ;
    cout << ans ;

    return 0 ;
}


Measured memory_bytes: 79360
//ABC074B
#include <bits/stdc++.h>
#include <iostream>
#include <iomanip>
#include <numeric>
#include <math.h>
#include <stdio.h>
#include <climits>
#include <cfloat>
#include <string>
#include <numeric>
using namespace std;

int main() {
	int n, k;
	cin >> n >> k;
	int ans = 0;
	for(int i=0;i<n;i++){
		int x;
		cin >> x;
		ans += 2*min(x,k-x);
	}
	cout << ans << endl;
	return 0;
}

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

using namespace std;

mt19937 rnd(chrono::high_resolution_clock::now().time_since_epoch().count());

int main() {
    ios::sync_with_stdio(0);
    cin.tie(0);
    int a, b;
    cin >> a >> b;
    int ans = a * b;
    if (a <= 0) ans = a + b;
    if (b < 0) ans = a - b;
    if (b == 0 && a < 0) ans = a * b;
    if (a < 0 && b < 0) ans = a * b;
    if (a == 0 || b == 0) ans = a + b;
    if (a == 0 && b < 0) ans = a - b;
    if (a < 0 && b == 0) ans = a * b;
    if (a > 0 && b > 0) ans = a * b;
    if (a > 0 && b == 1) ans = a + b;
    if (a == 1 && b > 0) ans = a + b;
    cout << ans << '\n';
    return 0;
}


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

typedef pair<int, int> pii;
typedef vector<int> vi;
typedef queue<int> qi;
typedef stack<int> si;
typedef deque<int> dqi;

#define rep(i, n) for (int i = 0; i < n; i++)
#define FOR(i, a, b) for (int i = a; i < b; i++)
#define pf push_front
#define pb push_back
#define FST first
#define SEC second
#define sz(obj) ((int)(obj).size())

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

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

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

  string str;

  while (cin >> str){
    rep(i, sz(str)){
      if (str[i] == '@'){
        int j = 0;
        while (j != str[i + 1] - '0'){
          cout << str[i + 2];
          j++;
        }
        i += 2;
      }
      else cout << str[i];
    }
    cout << endl;
  }
}

Measured memory_bytes: 1180
#include <algorithm>
#include <climits>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <functional>
#include <iostream>
#include <map>
#include <ostream>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
#define INF 1000000000
#define rep(i,a,b) for (int i=(a);i<(b);i++)
#define rev(i,a,b) for (int i=(a)-1;i>=b;i--)
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef queue<int> qi;
typedef vector<int> vi;
typedef vector<string> vs;
int dx[4] = { 0, 1, 0, -1 };
int dy[4] = { 1, 0, -1, 0 };

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

  int p[] = {6000, 4000, 3000, 2000};

  rep(i,0,4) {
    int t, n;
    cin >> t >> n;
    cout << p[t-1]*n << endl;
  }

	return 0;
}

Measured memory_bytes: 1192
#include<algorithm>
#include<bitset>
#include<climits>
#include<cmath>
#include<cstdlib>
#include<iomanip>
#include<iostream>
#include<map>
#include<numeric>
#include<queue>
#include<set>
#include<stack>
#include<string>
#include<time.h>
#include<tuple>
#include<utility>
#include<vector>

using namespace std;
long gcd(long x, long y) { if (x > y) { return gcd(y, x); } long r; while (y != 0) { r = x % y; x = y; y = r; } return x; }
long lcm(long x, long y) { return (x / gcd(x, y) * y); }

int main(void) {

	long res = 0;
	long N; cin >> N;

	vector<vector<long>> graph(N);

	for (int i = 0; i < N; i++) {
		for (int j = 0; j < N; j++) {
			char c; cin >> c;
			if (c == '1') graph[i].push_back(j);
		}
	}

	for (int i = 0; i < N; i++) {
		vector<long> depth(N, -1);//visitedも兼ねる
		queue<pair<long, long>> Q;//現在位置と深さ
		Q.push(make_pair(i, 1));

		while (!Q.empty()) {
			long now = Q.front().first;
			long dep = Q.front().second;
			Q.pop();
			depth[now] = dep;
			for (auto e : graph[now]) {
				if (depth[e] != -1) {
					if ((dep % 2) == (depth[e] % 2)) { cout << -1 << endl; return 0; }//このとき例外
					else {
						if (e == i) res = max(res, dep / 2 + 1);
						else res = max(res, max(dep, depth[e]));
					}
				}
				else{ Q.push(make_pair(e, dep + 1));
				depth[e] = dep + 1;}
			}

		}
	}

	cout << res << endl;
}

Measured memory_bytes: 640
n=int(input())
a=[]
b=[]
for i in range(n):
    a.append(list(map(int,input().split())))
for i in range(n):
    for j in range(n):
        b.append(((a[i][0]-a[j][0])**2+(a[i][1]-a[j][1])**2)**0.5)
print((sum(b)/(len(b)-n))*(n-1))

Measured memory_bytes: 38256
const main = (input) => {
  input = input.trim().split('\n')
  const [n, m, k] = input[0].split(' ').map(BigInt)
  const a = input[1].split(' ').map(BigInt)
  const b = input[2].split(' ').map(BigInt)

  const a_read = [], b_read = []
  let a_sum = 0n, b_sum = 0n

  for (let i=0; i<b.length; i++) {
    if (b_sum + b[i] <= k) {
      b_read.push(b[i])
      b_sum += b[i]
    }
    else break
  }

  let ans = b_read.length

  for (let i=0; i<a.length; i++) {
    a_read.push(a[i])
    a_sum += a[i]

    while (a_sum + b_sum > k && b_read.length) b_sum -= b_read.pop()

    if (a_sum + b_sum > k) break

    ans = Math.max(ans, a_read.length + b_read.length)
  }

  return console.log(ans)
}

process.env.MYTEST ? test() : main(require('fs').readFileSync('/dev/stdin', 'utf8'))

Measured memory_bytes: 100292
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define FASTIO
#define endl "\n"  // Since endl forces a buffer flush which slows down large I/O operations.
#define ff first
#define ss second
#define pb push_back
#define input(c, n) for (int i = 0; i < n; ++i) cin >> c[i];
#define exit_message(s) return 0 * printf(s)
#define show_all(c) for (auto i: c) cout << i << " "; cout << "\n";
#define display(c, a, n) cout << "Displaying array \"" << #c << "\" : \n"; for (int (i) = (a); (i) < (n); ++(i)) cout << (c)[(i)] << " "; cout << "\n";
#define forl(i, a, n) for (int i = (a); (i) < (n); ++(i))
#define dugbe(k) cout << "-\t> " << #k << " = " << k << "\n";

// What follows is a magical ordered set data structure.
// Supports the following functions:
// find_by_order(int k) - returns k'th smallest element (0-indexed)
// order_of_key(int k) - returns number of elements strictly smaller than k.
using namespace __gnu_pbds;
#define ordered_set tree <ll, null_type, greater_equal <ll>, rb_tree_tag, tree_order_statistics_node_update>

/* TIPS FOR DEBUGGING
 * Check if values are not overflowing (use long long where required)
 * Check if ranges are inclusive or not.
 * Check properly if greedy will work or not before using it.
 * Check EDGE CASES!! Seriously, even in 2B, saving 8 points by being
 * 2 minutes faster will bite you in the ass if you don't make sure
 * it works on edge cases.
 * Keep adding to this list.
*/

using namespace std;
typedef long long ll;
typedef pair<int, int> pr;
typedef pair<ll, ll> prll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<pr> vpr;
ifstream in("input.txt");
const ll mod = 1e9 + 7;
const long double eps = 1e-7;

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

long long true_rand(long long n)
{
	// Returns a random number between 0 and n - 1 inclusive using mt19937.
    uniform_int_distribution<long long> uid(0, n - 1);
    return uid(rng);
}

ll mod_pow(ll a, ll b)
{
	if (b == 0)
		return 1LL;

	ll res = mod_pow(a, b >> 1);
	res = (res * res) % mod;
	if (b & 1LL)
		res = (res * a) % mod;
	
	return res;
}

const int N = 3e5 + 5;

int32_t main()
{
	#ifdef FASTIO
		ios_base::sync_with_stdio(false);
		cin.tie(NULL);
	#endif
	// freopen("input.txt", "r", stdin);
	// freopen("output.txt", "w", stdout);

	int n;
	cin >> n;
	vi vec(n, 0);
	forl(i, 0, n)
	{
		cin >> vec[i];
	}
	sort(vec.begin(), vec.end());
	double x = vec[0];
	forl(i, 1, n)
	{
		double y = vec[i];
		x = (x + y) / 2.0;
	}
	cout << fixed << setprecision(10);
	cout << x << "\n";

	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
#define all(a) a.begin(),a.end()
#define P pair<int,int>
#define F first
#define S second
#define mod 1000000007
#define INF 9000000000000000000
signed main(void){
    int n;cin>>n;
    vector<int>V(n);rep(i,n)cin>>V[i];
    int count=0;
    rep(i,n-2){
        if(V[i]<V[i+1]&&V[i+1]<V[i+2])count++;
        if(V[i]>V[i+1]&&V[i+1]>V[i+2])count++;
    }
    cout<<count;
}

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

void solve() {
  int n;
  cin >> n;
  cout << (n+999) / 1000 * 1000 - n << endl;
}

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0), cout.tie(0);
  solve();
}

Measured memory_bytes: 3652
import heapq

N=int(input())
array=[int(x) for x in input().split()]
leftsidesum=[]
firstN=[]
for i in range(N):
	heapq.heappush(firstN,array[i])
summ=sum(firstN)
leftsidesum.append(summ)

for i in range(N,2*N):
	summ+=array[i]
	heapq.heappush(firstN,array[i])
	summ-=heapq.heappop(firstN)
	leftsidesum.append(summ)
	
rightsidesum=[]
secondN=[]
for i in range(3*N-1,2*N-1,-1):
	heapq.heappush(secondN,-array[i])
summm=sum(secondN)
rightsidesum.append(-summm)

for i in range(2*N-1,N-1,-1):
	summm-=array[i]
	heapq.heappush(secondN,-array[i])
	summm-=heapq.heappop(secondN)
	rightsidesum.append(-summm)

	
rightsidesum=rightsidesum[::-1]
tobeprinted=[]
for i in range(N+1):
	tobeprinted.append(leftsidesum[i]-rightsidesum[i])
print(max(tobeprinted))

Measured memory_bytes: 119876
import java.util.Scanner;

class Main{
	
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		
		int ans = 0;
		int max = 0;
		for (int i = 0; i < N; i++) {
			int pi = sc.nextInt();
			max = Math.max(pi, max);
			ans += pi;
		}
		
		System.out.println(ans - max + (max / 2));
	}
	
}

Measured memory_bytes: 21716
#include<cstdio>
#include<map>
#include<set>
using namespace std;

const int MAX_N = 1e5;
int n;
map<int, int> p;

int main() {
    scanf("%d", &n);
    for (int i = 1; i <= n; i++) {
        int x;
        scanf("%d", &x);
        p[x] = i;
    }
    
    long ans = 0;
    set<int> ind;
    for (map<int, int>::reverse_iterator i = p.rbegin(), e = p.rend(); i != e; i++) {
        if (ind.empty()) {
            ind.emplace(i->second);
            continue;
        }
        set<int>::iterator it = ind.lower_bound(i->second);
        int w, x, y, z;
        y = (it == ind.end()) ? n + 1 : *it;
        z = (it == --ind.end() || y == n + 1) ? n + 1 : *next(it);
        x = (it == ind.begin()) ? 0 : *prev(it);
        w = (it == ++ind.begin() || x == 0) ? 0 : *prev(it, 2);
        ans += static_cast<long>(i->first) * (y - i->second) * (x - w);
        ans += static_cast<long>(i->first) * (z - y) * (i->second - x);
        ind.emplace(i->second);
    }

    printf("%ld\n", ans);
    return 0;
}


Measured memory_bytes: 9600
#include <bits/stdc++.h>
#define ll long long int
#define pb push_back
#define s second
#define f first
#define MOD 1000000007
// #define 
using namespace std;

const ll INF=1e18L + 5;
int main()
{

    ll a,b,i,j,n,w,val=0;
    vector <pair<ll,ll>> v;
    cin>>n>>w;
    for(i=0;i<n;i++)
    {
        cin>>a>>b;
        val+=b;
        v.pb({a,b});
    }
    vector <ll> arr(val+5,INF);
    arr[0]=0;
    for (i = 0; i < n; i++)
    {
        for(j=val-v[i].s;j>=0;j--)
        {
            arr[j+v[i].s]=min(arr[j+v[i].s],arr[j]+v[i].f);
        }
    }
    // for(i=0;i<=val;i++)
    //     cout<<arr[i]<<" ";
    ll ans=0;
    for(i=0;i<=val;i++)
    {
        if(arr[i]<=w)
            ans=max(ans,i);
    }
    cout<<ans;
    return 0;
}

Measured memory_bytes: 1024
import math
import copy
from operator import mul
from functools import reduce
from collections import defaultdict
from collections import Counter
from collections import deque
# 直積 A={a, b, c}, B={d, e}:のとき，A×B={(a,d),(a,e),(b,d),(b,e),(c,d),(c,e)}: product(A, B)
from itertools import product
# 階乗 P!: permutations(seq), 順列 {}_len(seq) P_n: permutations(seq, n)
from itertools import permutations
# 組み合わせ {}_len(seq) C_n: combinations(seq, n)
from itertools import combinations
# 一次元累積和
from itertools import accumulate
from bisect import bisect_left, bisect_right

import re
# import numpy as np
# from scipy.misc import comb

def inside(y, x, H, W):
    return 0 <= y < H and 0 <= x < W

# 四方向: 右, 下, 左, 上
dy = [0, -1, 0, 1]
dx = [1, 0, -1, 0]
 
def i_inpl(): return int(input())
def l_inpl(): return list(map(int, input().split()))
def line_inpl(x): return [i_inpl() for _ in range(x)]

INF = int(1e18)
MOD = int(1e9)+7 # 10^9 + 7

# W行H列, x[W][H]
def create_grid(W, H, value = 0):
    return [[ value for _ in range(H)] for _ in range(W)]

########

# A, B = l_inpl()

# if (A+B)%2 == 0:
#     print((A+B)//2)
# else:
#     print("IMPOSSIBLE")

N = i_inpl()
p = l_inpl()

l = list(range(1, N+1))

cnt = 0
for pi, li in zip(p, l):
    if pi != li:
        cnt += 1

if cnt == 2 or cnt == 0:
    print("YES")
else:
    print("NO")

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

using namespace std;

const int mod = 998244353;

#define rep(i, a, b) for (int i = (a); i < (b); i++)
#define mp make_pair
#define fi first
#define se second

const int maxn = 3e5 + 5;

long long fact[maxn], inv[maxn];
long long n, a, b, k;

long long gcd(long long a, long long b) {
  long long r;
  while (b) {
    r = a % b;
    a = b;
    b = r;
  }
  return a;
}

pair<long long, long long> euclid(long long a, long long b) {
  if (!b) return mp(1, 0);
  pair<long long, long long> r = euclid(b, a % b);
  return mp(r.second, r.first - a / b * r.second);
}

long long power_mod(long long a, long long b) {
  long long res = 1;
  while (b) {
    if (b % 2) res = res * a % mod;
    a = a * a % mod;
    b /= 2;
  }
  return res;
}

long long C(int n, int k) {
  if (k > n) return 0ll;
  return fact[n] * inv[n - k] % mod * inv[k] % mod;
}

int main() {
  fact[0] = inv[0] = 1;
  rep(i, 1, maxn) {
    fact[i] = fact[i - 1] * i % mod;
    inv[i] = power_mod(fact[i], mod - 2);
  }

  cin >> n >> a >> b >> k;

  long long g = gcd(a, b);
  if (k % g != 0) {
    cout << 0;
    return 0;
  }

  a /= g;
  b /= g;
  k /= g;

  pair<long long, long long> v = euclid(a, b);

  v.fi *= k;
  v.se *= k;

  if (v.fi > 0) {
    long long rem = v.fi / b;
    v.fi = v.fi - rem * b;
    v.se = v.se + rem * a;
  } else {
    long long rem = (abs(v.fi) + b - 1) / b;
    v.fi = v.fi + rem * b;
    v.se = v.se - rem * a;
  }

  long long ans = 0;
  rep(i, -1000000, 1000001) {
    long long x = v.fi - i * b;
    long long y = v.se + i * a;
    if (x < 0 || y < 0 || x > n || y > n) continue;
    (ans += C(n, x) * C(n, y) % mod) %= mod;
  }

  cout << ans;

  return 0;
}


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

string SortString(string s) {

	string s_sort;
	vector<char> tmp(s.size());

	for (int i = 0; i < s.size(); i++) { tmp[i] = s[i]; }

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

	for (int i = 0; i < s.size(); i++) { s_sort += tmp[i]; }

	return s_sort;
}

int main()
{
	int size = 10;
	int n;  cin >> n;

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

	for (int i = 0; i < n; i++) { 
		
		s[i] = SortString(s[i]);

	}

	sort(s.begin(), s.end());
		
	long long ans = 0;
	for (int i = 0; i < n - 1; ) {
	
		long long tmp_ans = 0;
		long long tmp_cnt;
		for (int j = 1; i + j < n; j++) {

			if (s[i] == s[i + j]) {

				if (j == 1) {
					tmp_ans = 1;
					tmp_cnt = 2;
				}
				else {
					tmp_ans += tmp_cnt;
					tmp_cnt++;
				}
			}
			else {
				ans += tmp_ans;
				i += j;
				break;
			}
			
			if (i + j == n - 1) {
				ans += tmp_ans;
				i += j;
			}
		}	

	}

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 7296
#include<iostream>
#include<stdio.h>
#include<cmath>
using namespace std;
int main(){
    double a, b, C, S, L, h;
    
    cin >> a >> b >> C;
    
    double rad;
    double PI = acos(-1);
    rad = C * PI / 180;
    
    S = a * b * sin(rad) / 2;
    
    L = a + b + sqrt(a * a + b * b - 2 * a * b * cos(rad));
    
    h = b * sin(rad);
    
    printf("%.5lf\n", S);
    printf("%.5lf\n", L);
    printf("%.5lf\n", h);
}


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

int main(){
    int x;
    cin >> x;
    int n = x/100;
    int m = x%100;
    if(m<=5*n){
        cout << 1 << endl;
    }else{
        cout << 0 << endl;
    }
    return 0;
}

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

int main(){
    /*int A,B,C;

    cin >> A >> B >> C;

    if(A==B || A==C || B==C){
        if(A==B && A==C && B==C) cout << "No";
        else cout << "Yes";
    }
    else cout << "No";*/

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

    for(int i=0; i < n; i++){
        if(a[i]%2 == 0){
            if((a[i]%3 != 0) && (a[i]%5 != 0)){
                cout << "DENIED" << endl;
                return 0;
            }
        }
    }
    cout << "APPROVED" << endl;

}

Measured memory_bytes: 256
// D - Road to Millionaire
#include <bits/stdc++.h>
using namespace std;
using ll = int64_t;
#define rp(i,s,e) for(int i=(int)(s);i<(int)(e);++i)

int main(){
	int N; cin>>N;
	vector<int> A(N+1);
	rp(i, 0, N) cin>>A[i];
	ll yen = 1000, kabu_yen, kabu_n = kabu_yen = 0;
	rp(i, 1, N+1){
		if(A[i-1] < A[i]){ // buy
			ll m = yen / A[i-1];
			ll cost = (ll)m * A[i-1];
			yen -= cost;
			kabu_yen += cost;
			kabu_n += m;
		}
		else if(A[i-1] > A[i]){ // sell
			yen += kabu_n * A[i-1];
			kabu_yen = kabu_n = 0;
		}
	}
	cout<< yen <<endl;
}


Measured memory_bytes: 3636
#include <iostream>
#include <array>
#include <algorithm>
#include <vector>
#include <bitset>
#include <set>
#include <unordered_set>
#include <cmath>
#include <complex>
#include <deque>
#include <iterator>
#include <numeric>
#include <map>
#include <unordered_map>
#include <queue>
#include <stack>
#include <string>
#include <tuple>
#include <utility>
#include <limits>
#include <iomanip>
#include <functional>
#include <cassert>
using namespace std;

using ll=long long;
template<class T> using V = vector<T>;
template<class T, class U> using P = pair<T, U>;
using vll = V<ll>;
using vvll = V<vll>;
#define rep(i, k, n) for (ll i=k; i<(ll)n; ++i)
#define REP(i, n) rep(i, 0, n)
#define ALL(v) v.begin(),v.end()
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; }
#define DEBUG_VLL(vec) REP(sz, vec.size()) std::cerr<<vec[sz]<<(sz==vec.size()-1?'\n':' ');

const long long MOD = 1000000007;
const long long HIGHINF = (long long)1e18;
const int INF = (int)1e9;

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll n; cin >> n;
    ll cc = 26;
    int i = 1;
    while (true) {
        if (cc >= n) break;
        n -= cc;
        cc *= 26;
        i++;
    }
    n--;
    
    string ans(i, 'a');
    for (int j = i - 1; j >= 0; j--) {
        ans[j] += n % 26;
        n /= 26;
        // if (n > 0) n--;
    }
    cout << ans << '\n';

    return 0;
}


Measured memory_bytes: 3648
#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<b;i++)
#define rrep(i,a,b) for(int i=a;i>=b;i--)
#define fore(i,a) for(auto &i:a)
#define all(x) (x).begin(),(x).end()
//#pragma GCC optimize ("-O3")
using namespace std; void _main(); int main() { cin.tie(0); ios::sync_with_stdio(false); _main(); }
typedef long long ll; const int inf = INT_MAX / 2; const ll infl = 1LL << 60;
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; }
//------------------------------------------------------------------------------
//------------------------------------------------------------------------------
void _main()
{
    int N;
    ll X;
    cin >> N >> X;

    --X;

    vector<ll> layerNum(N + 1);
    vector<ll> pattiNum(N + 1);
    layerNum[0] = 1;
    pattiNum[0] = 1;

    rep(i, 0, N)
    {
        layerNum[i + 1] = layerNum[i] * 2 + 3;
        pattiNum[i + 1] = pattiNum[i] * 2 + 1;
    }

    // B BPPPB P BPPPB B
    // 0 12345 6 78901 2

    ll ans = 0;
    rrep(level, N, 0)
    {
        if (X == 0)
        {
            if (level == 0)
            {
                ++ans;
            }
            break;
        }
        else if (X == (layerNum[level] - 1) / 2)
        {
            ans += pattiNum[level - 1] + 1;
            break;
        }
        else if (X == layerNum[level] - 1)
        {
            ans += pattiNum[level];
            break;
        }
        else if (X < (layerNum[level] - 1) / 2)
        {
            --X;
        }
        else
        {
            X -= layerNum[level - 1] + 2;
            ans += pattiNum[level - 1] + 1;
        }
    }

    cout << ans << endl;
}


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

N, M = map(int, input().split())
cnt = 0
a = list(map(int, input().split())) + [0]
for i in range(N):
    if a[i] + a[i+1] > M:
        o = a[i] + a[i+1] - M
        cnt += o
        if o > a[i+1]:
            o -= a[i+1]
            a[i+1] = 0
            # a[i] -= o
        else:
            a[i+1] -= o
print(cnt)

Measured memory_bytes: 14132
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.HashMap;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.StringTokenizer;
import java.util.Map;
import java.util.Map.Entry;
import java.io.BufferedReader;
import java.io.InputStream;

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

	static class TaskE {
		public void solve(int testNumber, FastScanner in, PrintWriter out) {
			int n = in.nextInt();
			int[] a = new int[n];
			for (int i = 0; i < n; i++) {
				a[i] = in.nextInt();
			}
			Map<Integer, Integer> m = compress(a);
			int[] prev = new int[n];
			Arrays.fill(prev, -1);
			int last = 0;
			for (int i = 1; i < n; i++) {
				if (a[i] > a[last]) {
					prev[i] = last;
					last = i;
				}
			}
			Map<Integer, Integer> invM = new HashMap<>();
			for (Map.Entry<Integer, Integer> e : m.entrySet()) {
				invM.put(e.getValue(), e.getKey());
			}
			long[] am = new long[m.size()];
			int amPtr = am.length - 1;
			long[] ans = new long[n];
			for (int i = n - 1; i >= 0; i--) {
				++am[m.get(a[i])];
				if (i > 0 && prev[i] < 0) {
					continue;
				}
				int x = 0;
				if (i > 0) {
					x = a[prev[i]];
				}
				int xPtr = m.get(x);
				while (amPtr > xPtr) {
					int p = amPtr - 1;
					if (p < 0) {
						throw new AssertionError();
					}
					long dist = invM.get(amPtr) - invM.get(p);
					ans[i] += dist * am[amPtr];
					am[p] += am[amPtr];
					am[amPtr] = 0;
					amPtr = p;
				}
			}
			for (int i = 0; i < n; i++) {
				out.println(ans[i]);
			}
		}

		private Map<Integer, Integer> compress(int[] a) {
			int[] b = a.clone();
			Arrays.sort(b);
			Map<Integer, Integer> m = new HashMap<>();
			m.put(0, 0);
			for (int x : b) {
				if (!m.containsKey(x)) {
					int sz = m.size();
					m.put(x, sz);
				}
			}
			return m;
		}

	}

	static class FastScanner {
		private BufferedReader in;
		private StringTokenizer st;

		public FastScanner(InputStream stream) {
			in = new BufferedReader(new InputStreamReader(stream));
		}

		public String next() {
			while (st == null || !st.hasMoreTokens()) {
				try {
					String rl = in.readLine();
					if (rl == null) {
						return null;
					}
					st = new StringTokenizer(rl);
				} catch (IOException e) {
					throw new RuntimeException(e);
				}
			}
			return st.nextToken();
		}

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

	}
}



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

#define int long long
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define rep(i, n) for (int i = 0; i < n; ++i)
#define REP(i, n) for (int i = 0; i < n; ++i)
#define range(i,a,b) ((a)<=(i) && (i)<(b))
#define debug(x) cout << #x << " = " << (x) << endl;
#define fs first
#define sc second
#define pb push_back
#define eb emplace_back
#define SP << " " <<

typedef long long ll;
typedef pair<ll, ll> P;
typedef tuple<ll, ll, ll> T;
typedef vector<ll> vec;
typedef vector<P> pvec;
typedef vector<vector<ll>> vvec;
typedef vector<vector<P>> pvvec;
typedef priority_queue<ll> PQI;
typedef priority_queue<P> PQP;
typedef priority_queue<ll,vector<ll>,greater<ll>> PQIG;
typedef priority_queue<P,vector<P>,greater<P>> PQPG;

const vector<int> dx = {0, -1, 0, 1, 1, 1, -1, -1};
const vector<int> dy = {1, 0, -1, 0, 1, -1, 1, -1};
constexpr int MOD = (1000000007);
// const int MOD = (998244353);
// const int INF = (1 << 30); // 1073741824
const int INF = (1LL << 60); // 1152921504606846976
const double EPS = (1 >> 30);

template<class T> inline bool chmin(T& a, T b) {if (a > b) {a = b; return 1;} return 0;}
template<class T> inline bool chmax(T& a, T b) {if (a < b) {a = b; return 1;} return 0;}
template<class T> inline T ceil(T a, T b) {return T((a + b - 1)/b);}
template< typename T1, typename T2 > istream &operator>>(istream &is, pair< T1, T2 > &p) { is >> p.first >> p.second; return is; }

int nmax=200000; // 2*(10^5)
vvec g(nmax);



signed main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout << fixed << setprecision(15);
    //---------------------------------------------
    
    int n,k;
    cin>>n>>k;
    vector<int> a(n);
    rep(i,n) cin >> a[i],a[i]--;
    vec s(n+1);
    rep(i,n){
        s[i+1]=(s[i]+a[i])%k;
    }
    map<int,int> mp;
    int ans=0;
    rep(i,n+1){
        ans+=mp[s[i]];
        mp[s[i]]++;
        if(i-k+1>=0){
            mp[s[i-k+1]]--;
        }
    }
    cout<<ans<<endl;
    
}

Measured memory_bytes: 20608
#include<cstdio>
#include<algorithm>
#include<vector>
#include<queue>
#include<cstring>
using namespace std;
typedef long long ll;
int main(){
    int n;
    ll ans=0,a[100001],b[100000],x;
    scanf("%d",&n);
    for(int i=0;i<=n;i++){
        scanf("%lld",&a[i]);
    }
    for(int i=0;i<n;i++){
        scanf("%lld",&b[i]);
        x=min(a[i],b[i]);
        ans+=x;
        a[i]-=x;
        b[i]-=x;
        x=min(a[i+1],b[i]);
        ans+=x;
        a[i+1]-=x;
        b[i]-=x;
    }
    printf("%lld\n",ans);
}

Measured memory_bytes: 1664
n = int(input())
li = list(map(int,input().split()))

flag = 'n' #'u',d'
counter = 1
for i,l in enumerate(li):
    if i == len(li)-1:
        break
    if flag == 'n':
        if l > li[i+1]:
            flag = 'd'
        elif l < li[i+1]:
            flag = 'u'
    elif flag == 'u':
        if l > li[i+1]:
            counter += 1
            flag = 'n'
            new_flag = True
    elif flag == 'd':
        if l < li[i+1]:
            counter += 1
            flag = 'n'
            new_flag = True
    #print(i,l,li[i+1],flag)
print(counter)

Measured memory_bytes: 62704
#include<stdio.h>

 


int main(void){
    int n;
    scanf("%d",&n);
    for(int i=0;i<n/2;i++){
        for(int j=0;j<n/2;j++){
            if(n==4*i+7*j){
                printf("Yes");
                return 0;
            }
        }
    }

    printf("No");
    return 0;

}

Measured memory_bytes: 128
#include <stdio.h>

int main() {
	int n, k, cnt;

	scanf("%d%d", &n, &k);
	cnt = 0;
	while (n--) {
		int h;

		scanf("%d", &h);
		if (h >= k)
			cnt++;
	}
	printf("%d\n", cnt);
	return 0;
}

Measured memory_bytes: 128
#include<iostream>
#include<cassert>
#include<stdio.h>
#include<string>
#include<vector>
#include<map>
#include<tuple>
#include<algorithm>
#include<cmath>
#include<limits>
#include<set>
#include<deque>
#include<queue>
using namespace std;
#define int long  long int
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }
int lcm(int a, int b) { return a / gcd(a, b) * b; }
typedef pair<int, int>P;
const int MOD = 1e9 + 7;
const int INF = 1e10;
const long double PI = (acos(-1));


signed main() {
	int N;
	string S;
	cin >> N >> S;
	int r = 0, g = 0, b = 0;
	for (auto i : S) {
		if (i == 'R')r++;
		else if (i == 'G')g++;
		else b++;
	}
	int num = 0;
	for (int haba = 1; haba <= N / 2; haba++) {
		int one = 0, two = one + haba, three = two + haba;
		while (1) {
			if (three >= N)break;
			if (S[one] != S[two] && S[one] != S[three] && S[two] != S[three])num++;
			one++; two++; three++;
		}
	}
	int ans = r * g * b;
	ans -= num;
	cout << ans;
}

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

int main(){
  long int n;
  string s;
  
  cin >> s;
  n = s.size();
  
  int cntB = 0;
  int cntW = 0;
  long int ans = 0;
  for(long int i=0; i<n; i++){
    if(s[i] == 'B') cntB++;
    if(s[i] == 'W') ans += cntB; 
  }
  
  cout << ans << endl;
  
  return 0;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
#pragma GCC optimize("Ofast")
#define rep(i,n) for(int i=0; i<n; i++)
typedef long long ll;
typedef pair<int,int> P;
const ll MOD = (int)1e9+7;
const ll INF = MOD*MOD;
const ll powll = 1LL<<1;

int main(void){
  int x,y,z; cin >> x >> y >> z;
  swap(x,y);
  swap(x,z);
  cout << x << " " << y << " " << z << "\n";
}

Measured memory_bytes: 256