akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define rep(i,n) for(ll i=0;i<(n);++i)
#define all(a) (a).begin(),(a).end()
#define dunk(a) cout << (a) << endl
#define rall(a) (a).rbegin(),(a).rend()
const int INF = 2e9;
using namespace std;
using Graph = vector<vector<int>>;
typedef pair<int,int> P;
typedef long long ll;

int main(){
    string s; cin >> s;
    vector<int> j(26,0);

    rep(i,s.size()){
        j[s[i] - 'a']++;
    }

    bool jud = true;

    rep(i,26) if(j[i] >= 2) jud = false;

    if(jud) cout << "yes" << endl;
    else cout << "no" << endl;
}

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

const ll maxs = 1e6+5;
const ll lmaxs = 20;
ll mod = 1e9+7;
ll oo = 1e9;

#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define I insert


int main(){
    // #ifndef ONLINE_JUDGE
    // freopen("input00.txt","r",stdin);
    // #endif
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);cout.tie(nullptr);
    ll T = 1;
    //cin>>T;
    while(T--){
        ll a,b,c;
        cin>>a>>b>>c;
        ll val = c - a - b;
        bool flg=true;
        if(val <= 0)
            flg = false;
        if( 4*a*b >= val*val )
                flg = false;
        if( flg )
            cout << "Yes\n";
        else
            cout << "No\n";
    }   
    return 0;
}

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

#define MAX 100000

vector<int> G[MAX];
int N;
bool visited[MAX];
int prenum[MAX], parent[MAX], lowest[MAX], timer;

void dfs(int current, int prev) {
	prenum[current] = lowest[current] = ++timer;
	
	visited[current] = true;
	
	int next;
	for(int i = 0; i < G[current].size(); i++) {
		next = G[current][i];
		if(!visited[next]) {
			parent[next] = current;
			
			dfs(next, current);
			
			lowest[current] = min(lowest[current], lowest[next]);
		} else if(next != prev) {
			lowest[current] = min(lowest[current],prenum[next]);
		}
	}
}

void art_points() {
	for(int i = 0; i < N; i++) visited[i] = false;
	timer = 1;
	
	dfs(0, -1);
	
	int np = 0;
	set<int> ap;
	
	for(int i = 1; i < N; i++) {
		int p = parent[i];
		if(p == 0) np++;
		else if(prenum[p] <= lowest[i]) ap.insert(p);
	}
	if(np > 1) ap.insert(0);
    for(set<int>::iterator it = ap.begin(); it != ap.end(); it++)
	    cout << *it << endl; 
}

main() {
	int m, s, t;
	cin >> N >> m;
	
	for(int i = 0; i < m; i++) {
		cin >> s >> t;
		G[s].push_back(t);
		G[t].push_back(s); 
	}
	
	art_points();
	
	return 0;
	
}

Measured memory_bytes: 6892
from operator import itemgetter


def main():
    N = int(input())
    ab = [[int(j) for j in input().split()] for i in range(N)]
    cd = [[int(j) for j in input().split()] for i in range(N)]
    # y 降順
    ab.sort(key=itemgetter(1), reverse=True)
    # x 昇順
    cd.sort(key=itemgetter(0))
    # ペアになった赤
    done = [False] * N
    for bx, by in cd:
        for k, ((rx, ry), d) in enumerate(zip(ab, done)):
            if not d and rx < bx and ry < by:
                done[k] = True
                break
    print(sum(done))
    return


main()


Measured memory_bytes: 3444
#include <limits.h>
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <algorithm>
#include <cfloat>
#include <complex>
#include <functional>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <vector>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;

vector<vector<ll> > table;
vector<P> roads;
vector<P> qs;

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

  map<string, ll> m;
  for (int i = 0; i < N; i++) {
    string tmp;
    cin >> tmp;
    m[tmp]++;
  }

  string ans = "Three";
  if (m.size() == 4) ans = "Four";
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <cstdlib>
#include <cstdio>
#include <cmath>
#include <algorithm>
#include <map>
#include <stack>
#include <queue>
#include <set>
#include <cstring>

using namespace std;
// ascending order
#define vsort(v) sort(v.begin(), v.end())
// descending order
#define vsort_r(v) sort(v.begin(), v.end(), greater<int>())
#define vunique(v) unique(v.begin(), v.end())
#define mp make_pair
#define ts(x) to_string(x)
#define rep(i, a, b) for(int i = (int)a; i < (int)b; i++)
#define repm(i, a, b) for(int i = (int)a; i > (int)b; i--)
#define bit(a) bitset<8>(a)
#define des_priority_queue priority_queue<int, vector<int>, greater<int> >
typedef long long ll;
typedef pair<int, int> P;
const ll INF = 1e18;

#define MAX_N 100010

int par[MAX_N]; // 親
int depth[MAX_N]; // 木の深さ

// n要素で初期化
void init(int n) {
	rep(i, 0, n) {
		par[i] = i;
		depth[i] = 0;
	}
}

// 木の根を求める
int find(int x) {
	if(par[x] == x) return x;
	else return par[x] = find(par[x]);
}

// xとyの属する集合を併合
void unite(int x, int y) {
	x = find(x);
	y = find(y);
	if(x == y) return;

	if(depth[x] < depth[y]) {
		par[x] = y;
	} else {
		par[y] = x;
		if(depth[x] == depth[y]) depth[x]++;
	}
}

// xとyが同じ集合に属するか否か
bool same(int x, int y) {
	return find(x) == find(y);
}


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

	int n, m;
	cin >> n >> m;
	int p[n];
	rep(i, 0, n) {
		cin >> p[i];
		p[i]--;
	}
	
	init(n);

	rep(i, 0, m) {
		int x, y;
		cin >> x >> y;
		x--; y--;
		unite(x, y);
	}

	int cnt = 0;
	rep(i, 0, n) {
		if(same(p[i], i)) cnt++;
	}

	cout << cnt << endl;


}


Measured memory_bytes: 1408
import sys


def solve():
    input = sys.stdin.readline
    mod = 10 ** 9 + 7
    n, k = list(map(int, input().rstrip('\n').split()))
    h = list(map(int, input().rstrip('\n').split()))
    h.sort()
    t = 0
    for i in range(n - k):
        t += h[i]
    print(t)


if __name__ == '__main__':
    solve()


Measured memory_bytes: 80232
/*
これを入れて実行
g++ code.cpp
./a.out
 */

#include <iostream>
#include <vector>
#include <string>
#include <queue>
#include <algorithm>
#include <utility>
#include <set>
#include <map>
#include <cmath>
#include <tuple>
#include <iomanip>

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

int dy4[4] = {-1, 0, +1, 0};
int dx4[4] = {0, +1, 0, -1};
int dy8[8] = {-1, -1, 0, 1, 1, 1, 0, -1};
int dx8[8] = {0, 1, 1, 1, 0, -1, -1, -1};

const long long INF = 1LL << 60;
const ll MOD = 1e9 + 7;

bool greaterSecond(const pair<int, int>& f, const pair<int, int>& s){
    return f.second > s.second;
}

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

ll nCm(ll n, ll m){
    if(m == 0 || m == n){
        return 1;
    } else if(m == 1){
        return n;
    }
    return (nCm(n - 1, m) + nCm(n - 1, m - 1));
}

//-----------------------ここから-----------

int main(void){
    int n;
    cin >> n;
    string s = to_string(n);

    if(s[0] == '9' || s[1] == '9'){
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
}

Measured memory_bytes: 256
N = int(input())
S = list(input())

r_num = S.count("R")
g_num = S.count("G")
b_num = S.count("B")

count = 0
for i in range(N - 2):
    for j in range(i + 1, N - 1):
        k = j * 2 - i
        if k >= N:
            continue
        si, sj, sk = S[i], S[j], S[k]
        if si != sj and sj != sk and sk != si:
            count += 1

print(r_num * g_num * b_num - count)

Measured memory_bytes: 68392
#pragma target("avx")
#pragma optimize("O3")
#include<bits/stdc++.h>
using ll = int_fast64_t;
using P = std::pair<ll,ll>;
using PP = std::pair<ll,P>;
using V = std::vector<ll>;
template<typename T> using pq = std::priority_queue<T>;
template<typename T> using rpq = std::priority_queue<T, std::vector<T>, std::greater<T>>;

#define REP(i,b,e) for(ll i=b; i<e; i++)
#define ALL(vec) vec.begin(),vec.end()
#define PRINT(vec) printf("[ ");for(auto &i:vec)printf("%ld ",i);puts("]");
#define SCAN(vec) for(auto &i:vec)scanf("%ld",&i)
#define fi first
#define se second

const int MOD = 1e9+7;
const ll INF = 1e18;
int dx[] = {0, 1, 0, -1, 1, 1, -1, -1}, dy[] = {1, 0, -1, 0, 1, -1, -1, 1};

int main(){
	int n;
	scanf("%d", &n);
	int a[n];
	REP(i, 0, n) scanf("%d", &a[i]);

	int ans = 1e9;
	REP(x, -100, 101){
		int tmp = 0;
		REP(i, 0, n) tmp += (x-a[i])*(x-a[i]);
		if(ans>tmp) ans = tmp;
	}
	printf("%d\n", ans);
	return 0;
}



Measured memory_bytes: 384
import sys
input = lambda : sys.stdin.readline().rstrip()
sys.setrecursionlimit(max(1000, 10**9))
write = lambda x: sys.stdout.write(x+"\n")


h,w = map(int, input().split())
ch,cw = map(int, input().split())
dh,dw = map(int, input().split())
ch -= 1
cw -= 1
dh -= 1
dw -= 1
rows,cols = h,w

OK = "."
NG = "#"

from collections import defaultdict

ns = defaultdict(set)
ss = [None] * rows
for i in range(rows):
    s = input()
    ss[i] = s
n = rows * cols
start = (ch,cw)
goal = (dh,dw)
seen = [None]*n
seen[start[0]*w+start[1]] = 0
from heapq import heappop as hpp, heappush as hp
q = [(0, start)] # ワープ回数, 現在位置, 最後の道の位置
# dx = [0,1,0,-1]
# dy = [1,0,-1,0]
dx = []
dy = []
vvs = []
for i in range(-2,3):
    for j in range(-2,3):
        if not (i==j==0):
            dx.append(i)
            dy.append(j)
            if abs(i)+abs(j)>1:
                vvs.append(1)
            else:
                vvs.append(0)
while q:
    pnum,(ux,uy) = hpp(q)
    if (ux,uy)==goal:
        break
#     print(ux,uy, num, prv)
#     for xx,yy,vv in zip(dx,dy,vvs):
    for xx in range(-2,3):
        for yy in range(-2,3):
            if (xx==yy==0):
                continue
            if abs(xx)+abs(yy)>1:
                vv = 1
            else:
                vv = 0
            x = ux+xx
            y = uy+yy
            num = pnum+vv
            if x<0 or y<0 or x>=h or y>=w or ss[x][y]=="#":
                continue            
            if seen[x*w+y] is None or seen[x*w+y]>num:
                seen[x*w+y] = num
                hp(q, (num, (x,y)))
val = seen[goal[0]*w+goal[1]]
if val is None:
    print(-1)
else:
    print(val)

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

using namespace std;
//#define rep(i, n) for (ll i = 0; i < (n); ++i)
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define sz(x) ll(x.size())
typedef long long ll;
//typedef pair<int, int> P;
//typedef pair<ll, ll> P;
//const double INF = 1e10;
//const ll INF = 10e15;
const ll MINF = -10e10;
const int INF = INT_MAX;
#define cmin(x, y) x = min(x, y)
#define cmax(x, y) x = max(x, y)


//ifstream myfile("C:\\Users\\riku\\Downloads\\0_00.txt");
//ofstream outfile("log.txt");
//outfile << setw(6) << setfill('0') << prefecture << setw(6) << setfill('0') << rank << endl;
// std::cout << std::bitset<8>(9);

//typedef priority_queue<P, vector<P>, greater<P>> PQ_ASK;
const int mod = 1000000007;

struct N {
    int index, number;
    char operation;
};


int main() {
    char _a, _b, _c, _d;
    cin >> _a >> _b >> _c >> _d;
    int a = _a - '0';
    vector<int> nums = {
            _b - '0',
            _c - '0',
            _d - '0',
    };

    for (int i = 0; i < (1 << 3); i++) {
        int now = a;
        for (int j = 0; j < 3; j++) {
            int k = (i >> j) & 1;
            int l = ((k + 1) & 0b10) - 1;
            int m = nums[j] * l;
            now += m;
        }
        if (now == 7) {
            cout << a;
            for (int j = 0; j < 3; j++) {
                int k = (i >> j) & 1;
                int l = ((k + 1) & 0b10) - 1;
                int m = nums[j] * l;
                printf("%+d", m);
            }

            cout << "=7" << endl;
            return 0;
        }
    }

}

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

void print() { std::cout << std::endl; }
template <class Head, class... Tail> void print(Head &&head, Tail &&... tail) {
    std::cout << head;
    if(sizeof...(tail) != 0)
        std::cout << " ";
    print(std::forward<Tail>(tail)...);
}
template <class T> void print(std::vector<T> &vec) {
    for(auto &a : vec) {
        std::cout << a;
        if(&a != &vec.back())
            std::cout << " ";
    }
    std::cout << std::endl;
}
template <class T> void print(std::vector<std::vector<T>> &df) {
    for(auto &vec : df) {
        print(vec);
    }
}

int main() {
    int N, K;
    cin >> N >> K;
    vector<int> h(N);
    for(int i = 0; i < N; i++) {
        cin >> h[i];
    }

    int n = 0;
    for(const auto height : h) { //全要素参照
        if(height >= K) {
            n++;
        }
    }
    print(n);
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(ll i = 0, i##_len = (n); i < i##_len; i++)
#define reps(i, s, n) for(ll i = (s), i##_len = (n); i < i##_len; i++)
#define rrep(i, n) for(ll i = (n) - 1; i >= 0; i--)
#define rreps(i, e, n) for(ll i = (n) - 1; i >= (e); i--)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define sz(x) ((ll)(x).size())
#define len(x) ((ll)(x).length())
#define endl "\n"
template<class T> void chmax(T &a, const T b){ a = max(a, b); }
template<class T> void chmin(T &a, const T b){ a = min(a, b); }

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    // ifstream in("input.txt");
    // cin.rdbuf(in.rdbuf());
    const ll inf = LONG_LONG_MIN / 2 + 1;
    ll n, ga, sa, ba, gb, sb, bb;
    cin >> n >> ga >> sa >> ba >> gb >> sb >> bb;
    vector<ll> dp(n + 1, inf);
    dp[0] = 0;
    rep(i, n + 1) {
        dp[i] = i;
        if (i >= ga) chmax(dp[i], dp[i - ga] + gb);
        if (i >= sa) chmax(dp[i], dp[i - sa] + sb);
        if (i >= ba) chmax(dp[i], dp[i - ba] + bb);
    }
    ll nn = *max_element(all(dp));
    vector<ll> dp2(nn + 1, inf);
    dp2[0] = 0;
    rep(i, nn + 1) {
        dp2[i] = i;
        if (i >= gb) chmax(dp2[i], dp2[i - gb] + ga);
        if (i >= sb) chmax(dp2[i], dp2[i - sb] + sa);
        if (i >= bb) chmax(dp2[i], dp2[i - bb] + ba);
    }
    ll ans = *max_element(all(dp2));
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 198488
import java.util.Scanner;

public class Main {
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);

        int a = sc.nextInt();
        int b = sc.nextInt();

        System.out.println(Math.max(Math.max(a + b, a - b), a * b));

        sc.close();
    }
}

Measured memory_bytes: 21972
#include <iostream>
#include <vector>
#include <map>
#include <algorithm>
using namespace std;

int main() {
    int N;
    cin >> N;
    vector<int> A(N);

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

    vector<bool> sea(N+2);
    sea[0] = true;
    sea[N+1] = true;
    vector<pair<int, int>> AandNum;

    /*初期状態での陸地と海を調べる*/
    for(int i = 0; i < N; i++) {
        if(A[i] == 0) {
            sea[i+1] = true;
        }
        else {
            /*陸地の場合は高さと配列のインデックスを記録*/
            AandNum.push_back(make_pair(A[i], i+1)); 
            sea[i+1] = false;
        }
    }
    
    /*陸地の高さの順にソート*/
    sort(AandNum.begin(), AandNum.end());

    int temp = 0;
    int ans = 0;
    /*島の数の初期状態をカウント*/
    for(int i = 0; i < N+1; i++) {
        if(sea[i] && !sea[i+1]) {
            temp += 1;
        }
    }
    ans = temp;
    /*陸地が一つ沈んだ場合の島の増減*/
    for(int i = 0; i < AandNum.size(); i++) {
        int j = AandNum[i].second;
        sea[j] = true;
        /*両方が陸地なら島が1つ増える*/
        if(!sea[j-1] && !sea[j+1]) {
            temp += 1;
        }
        /*両方が海なら島が1つ減る*/
        else if(sea[j-1] && sea[j+1]) {
            temp -= 1;
        }
        if(i+1 == AandNum.size() || AandNum[i].first < AandNum[i+1].first) {
            ans = max(ans, temp);
        }
    }
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 4272
n,m,x=map(int,input().split())
a=list(map(int,input().split()))
counta=0
countb=0
for i in range(x):
    if a.count(i)==1:
        counta+=1
for i in range(x,n+1):
    if a.count(i)==1:
        countb+=1
print(min(counta,countb))


Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
typedef pair<int,int> P;
typedef long long ll;
typedef long double ld;
const int inf=1e9+7;
const ll longinf=1LL<<60;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
#define F first
#define S second

const int mx=1010;
const ll mod=1e9+7;


int main(){
  int n,ans=0,l=0; cin >> n;
  ll a[n],b[n];
  cin >> a[0]; 
  b[0] = a[0];
  
  for(int i=1; i<n; i++){ 
    cin >> a[i]; 
    b[i] = (a[i]+b[i-1]); 
  }
  
  ll h= b[n-1];
  for(int i=0; i<n; i++){ 
    h = min(h,abs(b[i]-(b[n-1]-b[i])));
  }

  
  
  cout << h << endl;
  return 0;
}

Measured memory_bytes: 3328
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define MAX 300000
double dp[30][MAX];
signed main(){
  int n;
  cin>>n;
  double a[n];
  for(int i=0;i<n;i++) cin>>a[i];
  double INF=1e10;
  for(int i=0;i<MAX;i++) dp[0][i]=0;
  for(int i=0;i<n;i++){
    for(int j=0;j<MAX;j++) dp[i+1][j]=INF;
    for(int j=1;j<MAX;j++){
      if(dp[i][j]==INF) continue;
      //if(j<30) cout<<i<<" "<<j<<":"<<dp[i][j]<<endl;
      for(int k=j;k<MAX;k+=j){
	dp[i+1][k]=min(dp[i+1][k],max(dp[i][j],abs(a[i]-k)/a[i]));
      }
    }
  }
  /*
  for(int j=1;j<MAX;j++)
    if(j<30) cout<<n<<" "<<j<<":"<<dp[n][j]<<endl;
  */
  double ans=INF;
  for(int j=0;j<MAX;j++) ans=min(ans,dp[n][j]);
  printf("%.12f\n",ans);
  return 0;
}

Measured memory_bytes: 52424
#include <bits/stdc++.h>
#define syosu(x) fixed<<setprecision(x)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef pair<double,double> pdd;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<string> vs;
typedef vector<P> vp;
typedef vector<vp> vvp;
typedef vector<pll> vpll;
typedef pair<int,P> pip;
typedef vector<pip> vip;
const int inf=1<<30;
const ll INF=1ll<<60;
const double pi=acos(-1);
const double eps=1e-9;
const ll mod=1e9+7;
const int dx[4]={0,1,0,-1},dy[4]={1,0,-1,0};

const ll p=998244353,r=3;

ll Pow(ll n,ll m){
	ll res=1;
	while(m>0){
		if(m&1) (res*=n)%=p;
		(n*=n)%=p;
		m>>=1;
	}
	return res;
}

ll Inv(ll x){return Pow(x,p-2);}

void ntt(vl& a,bool B){
	int n=a.size(),h=0;
	while(1<<h<n) h++;
	for(int i=0;i<n;i++){
		int j=0;
		for(int k=0;k<h;k++) if(i&1<<k) j+=1<<(h-k-1);
		if(i<j) swap(a[i],a[j]);
	}
	for(int i=1;i<n;i*=2){
		ll w=Pow(r,(p-1)/(i*2));
		if(B) w=Inv(w);
		for(int j=0;j<n;j+=i*2){
			ll wn=1;
			for(int k=0;k<i;k++){
				ll s=a[j+k],t=a[i+j+k]*wn%p;
				a[j+k]=(s+t)%p;
				a[i+j+k]=(s-t+p)%p;
				(wn*=w)%=p;
			}
		}
	}
	if(B){
		ll v=Inv(n);
		for(int i=0;i<n;i++) (a[i]*=v)%=p;
	}
}

vl Conv(vl a,vl b){
	int s=a.size()+b.size()-1,t=1;
	while(t<s) t*=2;
	a.resize(t);
	b.resize(t);
	ntt(a,0);ntt(b,0);
	for(int i=0;i<t;i++) (a[i]*=b[i])%=p;
	ntt(a,1);
	a.resize(s);
	return a;
}

const int M=2005;
ll n,k,C[M][M],two[M];

int main(){
	ios::sync_with_stdio(0);
	cin.tie(0);
	cin>>k>>n;
	C[0][0]=two[0]=1;
	for(int i=0;i<M-1;i++) for(int j=0;j<=i;j++){
		(C[i+1][j]+=C[i][j])%=p;
		(C[i+1][j+1]+=C[i][j])%=p;
	}
	for(int i=1;i<M;i++) two[i]=two[i-1]*2%p;
	vl ans;
	for(int i=2;i<k+2;i++){
		ll A=0,B=0;
		for(int j=1;j<=k;j++){
			if(0<i-j&&i-j<=k) A++;
			else if(2*j!=i) B++;
		}
		A/=2;
		vl a(A+1),b(B+1);
		for(int j=0;j<=A;j++) a[j]=C[A][j]*two[j]%p;
		for(int j=0;j<=B;j++) b[j]=C[B][j];
		vl c=Conv(a,b);
		ll res=0;
		for(int j=1;j<=min(A+B,n);j++){
			(res+=c[j]*C[n-1][n-j])%=p;
			if(i%2==0&&j<n) (res+=c[j]*C[n-2][n-j-1])%=p;
		}
		ans.push_back(res);
	}
	for(int i=0;i<k-1;i++) cout<<ans[i]<<endl;
	for(int i=k-1;i>=0;i--) cout<<ans[i]<<endl;
}

Measured memory_bytes: 30336
#include<bits/stdc++.h>
using namespace std;
#define MAX (1 << 28)

int main(){
  int n, k, val, ans = 0, crr = 0;
  cin >> n >> k;
  vector<int> v(n+1, MAX);
  for ( int i = 0; i < n; i++){
    cin >> val;
    if ( v[val] == MAX){
      v[val] = 1;
    } else {
      v[val] ++;
    }
  }
  sort(v.begin(), v.end() );
  for ( int i = 0; i <= n; i++){
    if ( v[i] == MAX){ break; }
    crr++;
  }
  if ( k > crr){
    ans = 0;
  } else {
    for ( int i = 0; i < crr - k; i++){
      ans += v[i];
    }
  }

  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 1024
#include <iostream>
#include <cstdio>
#include <cmath>
#include <algorithm>
#include <string>
#include <map>
#include <bitset>
#include <vector>
#include <queue>

using namespace std;

typedef long long ll;
#define FOR(i,a,b)   for(ll i = (a); i < (b); i++ )
#define REP(i, n)    FOR(i,0,n)
typedef pair< ll, ll >   cp2;
typedef pair< string, cp2 >   cp3;
#define fi first
#define se second
#define sec  se.fi
#define thr  se.se
const ll mod = 1000000007;
//              123456789


///////////////////////////////////////////////
//
//
///////////////////////////////////////////////

////////////////////////////////////////////////
////////////////////////////////////////////////

int N;
int B;
cp2 A[112345];


int main(){
    
    cin>>N;
    
    REP( i, N ){
        cin>>B;
        A[i] = cp2( B, i+1 );
    }
    sort(A, A+N);
    
    REP( i, N ){
        if( i ) cout<<" ";
        cout<<A[i].se;
    }
    
    puts("");
    
    return 0;
}



Measured memory_bytes: 2432
import java.util.*;

public class Main {

	public static void main(String[] args) {
		Scanner in=new Scanner(System.in);
		int n=in.nextInt(),cnt=0,max=0;
		for(int i=0;i<n;i++){
			if(in.nextInt()==1)cnt++;
			else {
				max=Math.max(max, cnt);
				cnt=0;
			}
		}
		max=Math.max(max, cnt);
		System.out.println(max+1);
	}

}


Measured memory_bytes: 26316
#include <cstdio>

using namespace std;
typedef long long llong;

#define MAX

int main()
{
  llong N, A, B;
  llong C, mod, div;
  scanf("%lld", &N);
  scanf("%lld%lld", &A, &B);

  C = A + B;

  div = N / C;
  mod = N % C;
  if (mod - A >= 0)
  {
    printf("%lld", (div + 1) * A);
  }
  else
  {
    printf("%lld", div * A + mod);
  }

  return 0;
}

Measured memory_bytes: 1732
#!/usr/bin/env python
# -*- coding: utf-8 -*-
import itertools

COSTS = (99, 2, 5, 5, 4, 5, 6, 3, 7, 6)


def gen(base_digit, base_cost, base_length, digits, remain):
  number = [base_digit] * base_length
  remain -= base_cost * base_length

  if remain == 0:
    print(''.join(str(d) for d in number), flush=True)
    return True

  digits = [(d, c - base_cost) for d, c in digits if d != base_digit and c - base_cost <= remain]

  if len(digits) == 0:
    return False

  max_repeat = min(remain // min(digits, key=lambda x: x[1])[1], len(number))
  numbers = []

  for repeat in range(1, max_repeat + 1):
    for idxs in itertools.product(range(len(digits)), repeat=repeat):
      if sum(digits[i][1] for i in idxs) != remain:
        continue

      replaces = [digits[i][0] for i in idxs]
      uppers = [d for d in replaces if d > base_digit]
      lowers = [d for d in replaces if d < base_digit]

      num = number[:]

      if len(uppers) > 0:
        num = uppers + num[len(uppers):]

      if len(lowers) > 0:
        num = num[:-len(lowers)] + lowers

      numbers.append(num)

  if len(numbers) == 0:
    return False

  number = max(numbers)

  print(''.join(str(d) for d in number), flush=True)

  return True


def main():
  remain, _ = list(map(int, input().split()))

  digits = {}

  for d in map(int, input().split()):
    if COSTS[d] not in digits or digits[COSTS[d]] < d:
      digits[COSTS[d]] = d

  digits = [(d, c) for c, d in digits.items()]
  base_digit, base_cost = min(digits, key=lambda x: x[1])

  for length in range(remain // base_cost, -1, -1):
    if gen(base_digit, base_cost, length, digits, remain):
      break


if __name__ == '__main__':
  main()



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

#define F first
#define S second
#define MP make_pair
#define pb push_back
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define LCM(a, b) (a) / __gcd((a), (b)) * (b)
#define CEIL(a, b) (a)/(b)+(((a)%(b))?1:0)
#define ln '\n'

using namespace std;
using LL = long long;
using ldouble = long double;
using P = pair<int, int>;
using LP = pair<LL, LL>;

static const int INF = INT_MAX;
static const LL LINF = LLONG_MAX;
static const int MIN = INT_MIN;
static const LL LMIN = LLONG_MIN;
static const int MOD = 1e9 + 7;
static const int SIZE = 200005;

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

vector<LL> Div(LL n) {
    vector<LL> ret;
    for(LL i = 1; i * i <= n; ++i) {
        if(n % i == 0) {
            ret.pb(i);
            if(i * i != n) ret.pb(n / i);
        }
    }
    sort(all(ret));
    return ret;
}

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

    int N;
    cin >> N;
    vector<int> v(N);
    for(int i = 0; i < N; ++i) {
        cin >> v[i];

    }

    // + - + - ...
    LL res = 0;
    LL sum = 0;
    for(int i = 0; i < N; ++i) {
        if(i % 2 == 0) {
            if(sum + v[i] <= 0) {
                res += abs((1 - sum) - v[i]);
                sum = 1;

            } else {
                sum += v[i];

            }
        } else {
            if(sum + v[i] >= 0) {
                res += abs((-1 -sum) - v[i]);
                sum = -1;

            } else {
                sum += v[i];

            }
        }
    }

    sum = 0;
    LL tmp = 0;
    for(int i = 0; i < N; ++i) {
        if(i % 2 == 0) {
            if(sum + v[i] >= 0) {
                tmp += abs((-1 -sum) - v[i]);
                sum = -1;

            } else {
                sum += v[i];

            }
        } else {
            if(sum + v[i] <= 0) {
                tmp += abs((1 - sum) - v[i]);
                sum = 1;

            } else {
                sum += v[i];

            }
        }
    }
    cout << min(res, tmp) << endl;

    return 0;
}


Measured memory_bytes: 768
class Tree
  def initialize(n, colors, edges)
    @n = n
    @colors = colors
    @adj = @n.times.map{Array.new}
    edges.each do |a, b|
      @adj[a].push b
      @adj[b].push a
    end

    # 各色でのノードを取り除いて木を森にしたときに、
    # すでに訪問した木に含まれるパスの合計を累積して保持する
    @path_count_in_trees = Hash.new(0)
  end

  def get_answer
    total_path_count = all_path_count(@n)
    size, disconnected_node_sizes = get_subtree_info(0, -1)
    (1..@n).map do |color|
      tree_size = size - disconnected_node_sizes[color]
      @path_count_in_trees[color] += all_path_count(tree_size)
      total_path_count - @path_count_in_trees[color]
    end
  end

  private

  # node以下の部分木について、
  # - サイズ
  # - 各色を取り除いて非連結になるノードの数
  # を返す
  # （サイズ-各色を取り除いて非連結になるノードの数）が、
  # node以下の部分木でnodeから連結してる木のサイズ
  def get_subtree_info(node, parent)
    size = 1
    disconnected_node_sizes = Hash.new(0)

    node_color = @colors[node]
    @adj[node].each do |child|
      if child != parent
        sub_size, sub_disconnected_node_sizes = get_subtree_info(child, node)
        size += sub_size

        # node_colorについて、nodeで木が切断されるので、木のサイズが確定する
        # なので、確定した木に含まれるパスの数を足し込む
        tree_size = sub_size - sub_disconnected_node_sizes[node_color]
        @path_count_in_trees[node_color] += all_path_count(tree_size)

        # 非連結なノード数を足し込む
        # このとき、効率をよくするためにサイズの大きなオブジェクトを再利用する
        if disconnected_node_sizes.size < sub_disconnected_node_sizes.size
          disconnected_node_sizes, sub_disconnected_node_sizes \
            = [sub_disconnected_node_sizes, disconnected_node_sizes]
        end
        sub_disconnected_node_sizes.each do |color, sub_disconnected_node_size|
          disconnected_node_sizes[color] += sub_disconnected_node_size
        end
      end
    end

    # node_colorについて、nodeで木が切断されるので、
    # node以下は親から見て非連結になる
    # なので、非連結なノード数をnode以下の部分木のサイズにする
    disconnected_node_sizes[node_color] = size

    [size, disconnected_node_sizes]
  end

  # サイズnの木にあるパスの総数
  def all_path_count(n)
    n * (n + 1) / 2
  end
end

n = gets.to_i
colors = gets.split.map(&:to_i)
edges = (n-1).times.map{ gets.split.map{|e| e.to_i - 1} }

tree = Tree.new(n, colors, edges)
tree.get_answer.each do |i|
  puts i
end


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

int main() {
	int n, x, a = 0;
	cin >> n;
	for (int i = 0; i < n; i++) {
		char p;
		cin >> p >> x;
		if (p == '(') a += x;
		else {
			a -= x;
			if (a < 0) break;
		}
	}
	if (a) cout << "NO";
	else cout << "YES";
	cout << endl;
}


Measured memory_bytes: 3116
#include<iostream>
#include<cstdio>
#include<queue>
#include<cstring>
using namespace std;
const int maxn = 100010;
int n, m, tot, head[maxn], ans[maxn];
struct node {
    int num, val;
    node(){}
    node(int a, int b) {
        num = a, val = b;
    }
    bool operator < (const node & a) const {
        return val > a.val;
    }
};
struct line {
    int to, nxt;
} edge[maxn * 2];

void add(int u, int v) {
    edge[++tot].to = v, edge[tot].nxt = head[u], head[u] = tot;
}

int main()
{
    scanf("%d", &n);
    for(int u, v, i = 1; i < n; i++) {
        scanf("%d %d", &u, &v);
        add(u, v), add(v, u);
    }
    memset(ans, -1, sizeof(ans));
    scanf("%d", &m);
    priority_queue <node> pq;
    for(int u, p, i = 1; i <= m; i++) {
        scanf("%d %d", &u, &p);
        ans[u] = p;
        pq.push(node(u, p));
    }
    while(!pq.empty()) {
        node u = pq.top();
        pq.pop();
        for(int i = head[u.num]; i; i = edge[i].nxt) {
            int v = edge[i].to;
            if(ans[v] == -1) {
                ans[v] = u.val + 1;
                pq.push(node(v, ans[v]));
            }
        }
    }
    for(int i = 1; i <= n; i++)
        for(int j = head[i]; j; j = edge[j].nxt)
            if(abs(ans[i] - ans[edge[j].to]) != 1) {
                puts("No");
                return 0;
            }
    puts("Yes");
    for(int i = 1; i <= n; i++) printf("%d\n", ans[i]);
    return 0;
}

Measured memory_bytes: 4212
import std.stdio, std.algorithm, std.conv, std.array, std.string;

int[(10^^5)*2+1] PS;

void main()
{
    auto N = readln.chomp.to!int;
    foreach (_; 0..N) {
        auto p = readln.chomp.to!int;
        PS[p] = PS[p-1] + 1;
    }

    int max = 0;
    foreach (p; PS[0..N+1]) if (p > max) max = p;
    writeln(N - max);
}

Measured memory_bytes: 2044
#include<iostream>
#include<stdio.h>
#include<algorithm>
#include<vector>
#include<string.h>
#include<math.h>
#include<map>
#include<iomanip>

#define MOD 1e9+7;
#define INF 1e17+9;
#define PI acos(-1);

using namespace std;

int main(){
	long long x;
	cin >> x;
	for(int i=0;i<=x;i++){
		if(i*100<=x && x<=i*105){
			cout << "1" << endl;
			return 0;
		}
	}
	cout << "0" << endl;
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <math.h>
#include <vector>

using namespace std;

int main() {

	int N, i;
	unsigned long long total = 0;

	cin >> N;

	for (i = 0; i <= N; i++) {
		if (i % 3 != 0 && i % 5 != 0) {
			total += i;
		}
	}

	cout << total;

	return 0;
}

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

using ll = long long int;
using P = std::pair<int, int>;

#define rep(i, n) for (int i = 1; i <= (n); ++i)
#define rag(con) std::begin(con), std::end(con)

constexpr int MAX = 1010;

std::vector<int> to[MAX];

int main()
{
    int n, m;
    std::cin >> n >> m;

    rep(i, m)
    {
        int a, b;
        std::cin >> a >> b;
        to[a].push_back(b);
    }

    std::vector<int> ans(n + 1);
    constexpr int INF = 1e9;

    rep(i, n)
    {
        std::queue<int> que;

        std::vector<int> dis(n + 1, INF);
        std::vector<int> par(n + 1);

        que.push(i);
        dis[i] = 0;

        while (!que.empty())
        {

            int x = que.front();
            que.pop();

            for (auto u : to[x])
            {
                if (dis[u] > dis[x] + 1)
                {
                    dis[u] = dis[x] + 1;
                    par[u] = x;
                    que.push(u);
                }
                else if (dis[u] == 0)
                    par[u] = x;
            }
        }
        if (!par[i])
            continue;
        int v = par[i];
        std::vector<int> vec;
        while (v != i)
        {
            vec.push_back(v);
            v = par[v];
        }
        vec.push_back(i);
        if (ans.size() > vec.size())
            ans = vec;
    }

    if (ans.size() == n + 1)
        std::cout << -1 << std::endl;
    else
    {
        std::cout << ans.size() << std::endl;
        for (auto x : ans)
            std::cout << x << std::endl;
    }

    return 0;
}

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

int main() {
    int n;
    cin >> n;
    int hmax=0;
    int c=0;
    rp(i,n){
        int h;
        cin >> h;
        if(h>=hmax){
            hmax=h;
            c++;
        }
    }
    cout << c << endl;
    return 0;
}

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

#define F first
#define S second
#define MP make_pair
#define pb push_back
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define LCM(a, b) (a) / __gcd((a), (b)) * (b)
#define CEIL(a, b) (a)/(b)+(((a)%(b))?1:0)
#define ln '\n'

using namespace std;
using LL = long long;
using ldouble = long double;
using P = pair<int, int>;
using LP = pair<LL, LL>;

static const int INF = INT_MAX;
static const LL LINF = LLONG_MAX;
static const int MIN = INT_MIN;
static const LL LMIN = LLONG_MIN;
static const int MOD = 1e9 + 7;
static const int SIZE = 200005;

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

vector<LL> Div(LL n) {
    vector<LL> ret;
    for(LL i = 1; i * i <= n; ++i) {
        if(n % i == 0) {
            ret.pb(i);
            if(i * i != n) ret.pb(n / i);
        }
    }
    sort(all(ret));
    return ret;
}

LL fac[SIZE], finv[SIZE], inv[SIZE];
void combInit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for(int i = 2; i < SIZE; ++i) {
        fac[i] = (fac[i - 1] * i) % MOD;
        inv[i] = MOD - inv[MOD % i] * (MOD / i) % MOD;
        finv[i] = (finv[i - 1] * inv[i]) % MOD;

    }
}

LL comb(int n, int k) {
    if(n < k) return 0;
    if(n < 0 || k < 0) return 0;
    return (fac[n] * (finv[k] * finv[n - k] % MOD)) % MOD;

}

LL Bin(LL n, LL k) {
    if(k < 0 || n < k) {
        return 0;

    }
    LL ret = 1;
    for(LL i = 1; i <= k; ++i) {
        ret *= n--;
        ret /= i;

    }
    return ret;
}

bool dfs(int now);

vector<int> tree[SIZE];
int k;
LL res;
bool visit[SIZE];

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

    combInit();
    int n;
    cin >> n >> k;
    for(int i = 0; i < n - 1; ++i) {
        int a, b;
        cin >> a >> b;
        tree[a].pb(b);
        tree[b].pb(a);

    }
    res = k;
    dfs(1);
    cout << res << endl;
    return 0;
}

bool dfs(int now) {
    if(visit[now]) return false;
    visit[now] = true;

    int p = k - 1;
    if(now != 1) p--;
    for(int i = 0, t = 0; i < tree[now].size(); ++i) {
        bool f = dfs(tree[now][i]);
        if(f) {
            res = res * max(0, p) % MOD;
            --p;

        }
    }

    return true;

}


Measured memory_bytes: 17536
#include <bits/stdc++.h>
//登録しよう！→ https://www.youtube.com/channel/UCRXsI3FL_kvaVL9zoolBfbQ
using namespace std;
using ll = long long;
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}//a,bの最大公約数(gcd)を求める
ll lcm(ll a,ll b){return abs(a*b)/gcd(a,b);}//a,bの最小公倍数(lcm)を求める
vector<ll> enum_div(ll n){vector<ll> ret;for(int i=1 ; i*i<=n ; i++){if(n%i == 0){ret.push_back(i);if(i!=1 && i*i!=n)ret.push_back(n/i);}}ret.push_back(n);return ret;}
//↑nの約数を求める
vector<bool> IsPrime; void sieve(size_t max){if(max+1 > IsPrime.size())IsPrime.resize(max+1,true);IsPrime[0] = false;IsPrime[1] = false;for(size_t i=2; i*i<=max; ++i)if(IsPrime[i])for(size_t j=2; i*j<=max; ++j)IsPrime[i*j] = false;}
//↑エラトステネスの篩で素数を求める
#define roundup(divisor,dividend) (divisor + (dividend - 1)) / dividend //切り上げ割り算
#define all(x) (x).begin(),(x).end() //xの初めから終わりまでのポインタ
#define size_t ll //size_tは自動でllに変換される
#define pb(x) push_back(x)
#define gre greater //sortを降順にする
#define pri_queue priority_queue //優先度付きキュー
#define syo(x) fixed << setprecision(x) //iostreamで小数をx桁表示

void solve(long long N, std::vector<long long> v){
  sort(all(v));
  double ans = (double)(v[0] + v[1])/2.0;
  for (int i = 2; i < N; i++) {
    ans = (double)(ans + v[i])/2.0; 
  }  
  cout << syo(5) << ans << endl;
}

// Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
int main(){
    long long N;
    scanf("%lld",&N);
    std::vector<long long> v(N);
    for(int i = 0 ; i < N ; i++){
        scanf("%lld",&v[i]);
    }
    solve(N, std::move(v));
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0; i < (n); i++)
using ll = long long;
using P = pair<int,int>;
using PP = pair<int,pair<int,int>>;
using T = tuple<string,int,int>;
const ll INF = 1LL<<60;
const int ny[4] = {-1,1,0,0}, nx[4] = {0,0,-1,1};
int sy,sx,gy,gx;

int main(){
  int n; cin >> n;
  vector<int> a(3);
  while(1){
    int now = n;
    rep(i,3){
      a[i] = now % 10;
      now /= 10;
    }
    if(a[0] == a[1] && a[1] == a[2]){
      cout << n << endl;
      return 0;
    }
    n++;
  }
  return 0;
}


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

using namespace std;

int main()
{
    int a , b , C=0;
    cin>>a>>b;
    int sum=1 ;
    while( sum < b )
    {
        sum+=a-1;
        C++;
    }
    cout<<C<<endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <map>
#include <set>
#include <math.h>
#include <limits>

template <typename T>
void vc(T t) {
    std::cout << t << " ";
}

template<typename T, typename... Args>
void vc(T t, Args... args) {
// recursive variadic function
    std::cout << t << " ";
    vc(args...) ;
}

const int N = 100000;
long long dp[100001];
long long dpf(const std::vector<int>& vw, const std::vector<long long>& vv, int w, int r, int n) {
  int sum_v = 0;
  for (int i = 1; i <= n; ++i) {
    sum_v += vv[i];
  }

  std::vector<long long> dp(sum_v + 1, 0x3ffffffffffff);
  dp[0] = 0;
  for (int i = 1; i <= n; ++i) {
    for (int vi = sum_v; vi >= vv[i]; --vi) {
      dp[vi] = std::min(dp[vi], dp[vi - vv[i]] + vw[i]);
    }
    // vc("+ ", i, dp[sum_v], "\n");
  }
  auto ans = 0;
  for (int i = sum_v; i >= 0; --i) {
    if (dp[i] <= w) {
      ans = i;
      break;
    }
  }
  return ans;
}

void once() {
  int n, w;
  std::cin >> n >> w;
  std::vector<int> vw(n + 1);
  std::vector<long long> vv(n + 1);
  for (int i = 1; i <= n; ++i) {
    std::cin >> vw[i] >> vv[i];
  }
  // vc("return , r, w, dp[r][w], \n");
  std::cout << dpf(vw, vv, w, 1, n) << std::endl;
}

int
main() {
  int n = 1;
  std::ios::sync_with_stdio(false);
  // std::cin >> n;
  while (n--) {
    once();
  }
}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
#define int long long
#define endl "\n"
using namespace std ;
const int N =1e5 + 5 ;
int dp[105][N] ;
int pref[105][N] ; 
int mod = 1e9 +7 ;

signed main()
{
	ios_base::sync_with_stdio(false) ; 
	cin.tie(NULL) ;
	int n , x ;	 
	cin >> n >> x ;	
	vector<int> a(n);	
	for(int i =0 ; i < n ;++i)
		cin >> a[i] ; 
	for(int i = 0 ; i <=x ;++ i)
		pref[0][i] =1  ; 
	dp[0][0] =1 ; 
 	for(int i = 1 ; i <=n ; ++i)
	{
		for(int j =0 ; j <=x ; ++j)
		{
			int x = pref[i-1][j] ;
			int y = ((j-a[i-1]-1 >=0)?(pref[i-1][j-a[i-1]-1]):0)  ;
			dp[i][j] = (x-y + mod)%mod ; 
			if(j > 0 )
				pref[i][j] = (dp[i][j]+ pref[i][j-1])%mod ; 
			else if(j ==0 )
				pref[i][j] =1 ; 
		}
	}
//	for(int i = 0 ; i <=n ; ++i)
//	{
//		for(int j = 0 ; j <= x ; ++j)
//		{cout << dp[i][j] << " "  ; }
//		cout << endl ;
//	}
	cout << dp[n][x]%mod << endl ;

	                                                                                		
}



















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

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


typedef long long ll;

int main() {
    ll n,k;
    cin>>n>>k;
    vector<ll> a(n);
    rep(i,n){
        cin>>a[i];
        a[i]--;
        a[i]%=k;
    }
    rept(i,1,n){
        a[i]+=a[i-1];
        a[i]%=k;
    }
    
    ll ans=0;
    map<ll,vector<ll>> mp;
    rep(i,n){
        ll s=a[i];
        ans+=mp[s].end()-upper_bound(mp[s].begin(),mp[s].end(),i-k);
        mp[s].push_back(i);

    }
    rep(i,mp[0].size()){
        if(mp[0][i]<k-1) ans++;
    }

    
    cout<<ans;

    return 0;
}

Measured memory_bytes: 23680
import java.util.Scanner;
//import java.lang.Math;
import java.util.Random;

public class Main{
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		Random rnd = new Random();

		int n = sc.nextInt();
		int i = 1;

		while(true){
			int x = i;
			if(x%3==0 || x%10==3 || (x/10)%10==3 || (x/100)%10==3|| (x/1000)%10==3){
            	System.out.print(" "+x);
        	}
        i++;
        if(i>n){
            break;
        }


		}

		System.out.println();	
	}
}

Measured memory_bytes: 28728
//For higher stack size use g++ -O2 -std=c++11 -Wall -Wl,--stack=268435456 a.cpp -o a.exe in cmd
    #include <bits/stdc++.h>
    #include <cstdio>
    #include <cstring>
    #include <cmath>
    #include <cstring>
    #include <chrono>
    #include <complex>
    #define ll long long
    #define ld long double
    #define vi vector<int>
    #define vll vector<ll>
    #define vvi vector < vi >
    #define pii pair<int,int>
    #define pll pair<long long, long long>
    #define mod 1000000007
    #define inf 1000000000000000001;
    #define all(c) c.begin(),c.end()
    #define mp(x,y) make_pair(x,y)
    #define mem(a,val) memset(a,val,sizeof(a))
    #define eb emplace_back
    #define pb push_back
    #define f first
    #define s second
    
    using namespace std;
    int main()
    {
        std::ios::sync_with_stdio(false);
        int T;
        T=1;
        // cin.ignore(); must be there when using getline(cin, s)
        while(T--)
        {
            int n,i,j;
            cin>>n;
            set<int> st;
            for(i=1;i<=n;++i)
            {
                cin>>j;
                st.insert(j);
            }
            if(st.size()==n)
                cout<<"YES"<<endl;
            else
                cout<<"NO"<<endl;
        }
        return 0;
    }


Measured memory_bytes: 9600
#include<iostream>
#include<vector>
#include<string>
#include<map>
#include<numeric>
typedef long long ll;
using namespace std;

int main() {
	ll A, B;
	cin >> A >> B;

	ll x = A * B;
	ll tmp;
	/* 自然数 a > b を確認・入替 */
	if (A < B) {
		tmp = A;
		A = B;
		B = tmp;
	}

	/* ユークリッドの互除法 */
	ll r;
	r = A % B;
	while (r != 0) {
		A = B;
		B = r;
		r = A % B;
	}

	/* 最小公倍数を出力 */
	
	cout << x / B << endl;
	return 0;


}

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

using namespace std;
#ifdef _DEBUG
#define _GLIBCXX_DEBUG
#include "dump.hpp"
#else
#define dump(...)
#endif

#define int long long
#define ll long long
#define ll1 1ll
#define ONE 1ll
#define DBG 1
#define rep(i, a, b) for (int i = (a); i < (b); i++)
#define rrep(i, a, b) for (int i = (b)-1; i >= (a); i--)
#define loop(n) rep(loop, (0), (n))
#define all(c) begin(c), (c)
const int INF =
sizeof(int) == sizeof(long long) ? 0x3f3f3f3f3f3f3f3fLL : 0x3f3f3f3f;
const int MOD = (int)(1e9) + 7;
const double PI = acos(-1);
const double EPS = 1e-9;
#define fi first
#define se second
#define pb push_back
#define eb emplace_back
using pii = pair<int, int>;
// template<class T> ostream &operator<<(ostream &os,T &t){dump(t);return os;}
template <typename T, typename S>
istream &operator>>(istream &is, pair<T, S> &p) {
	is >> p.first >> p.second;
	return is;
}
template <typename T, typename S>
ostream &operator<<(ostream &os, pair<T, S> &p) {
	os << p.first << " " << p.second;
	return os;
}

template <typename T> void printvv(const vector<vector<T>> &v) {
	cerr << endl;
	rep(i, 0, v.size()) rep(j, 0, v[i].size()) {
		if (typeid(v[i][j]).name() == typeid(INF).name() and v[i][j] == INF) {
			cerr << "INF";
		}
		else
			cerr << v[i][j];
		cerr << (j == v[i].size() - 1 ? '\n' : ' ');
	}
	cerr << endl;
}
/*
typedef __int128_t Int;
std::ostream &operator<<(std::ostream &dest, __int128_t value) {
std::ostream::sentry s(dest);
  if (s) {
	__uint128_t tmp = value < 0 ? -value : value;
	char buffer[128];
	char *d = std::(buffer);
	do {
	  --d;
	  *d = "0123456789"[tmp % 10];
	  tmp /= 10;
	} while (tmp != 0);
	if (value < 0) {
	  --d;
	  *d = '-';
	}
	int len = std::(buffer) - d;
	if (dest.rdbuf()->sputn(d, len) != len) {
	  dest.setstate(std::ios_base::badbit);
	}
  }
  return dest;
}

__int128 parse(string &s) {
  __int128 ret = 0;
  for (int i = 0; i < s.length(); i++)
	if ('0' <= s[i] && s[i] <= '9')
	  ret = 10 * ret + s[i] - '0';
  return ret;
}
*/

#ifndef _DEBUG
#define printvv(...)
#endif
void YES(bool f) { cout << (f ? "YES" : "NO") << endl; }
void Yes(bool f) { cout << (f ? "Yes" : "No") << endl; }
template <class T> bool chmax(T &a, const T &b) {
	if (a < b) {
		a = b;
		return true;
	}
	return false;
}
template <class T> bool chmin(T &a, const T &b) {
	if (a > b) {
		a = b;
		return true;
	}
	return false;
}

signed main(signed argc, char *argv[]) {
	cin.tie(0);
	ios::sync_with_stdio(false);
	cout << fixed << setprecision(12);

	int N; cin >> N;
	int A; cin >> A;
	int B; cin >> B;
	int x = 0, y = 0, z = 0;
	vector<int>P(N); rep(i, 0, N) {
		cin >> P[i];
		if (P[i] <= A)x++;
		else if (P[i] <= B)y++;
		else z++;
	}
	cout << min({ x,y,z }) << endl;


	return 0;
}


Measured memory_bytes: 256
import Control.Monad
import Control.Applicative
import Data.List
import qualified Data.Map as Map
import Data.Array
import qualified Data.ByteString.Char8 as BC
import Data.Maybe
import qualified Data.Set as Set
import qualified Data.Sequence as Sq
import Data.Sequence (ViewL(..),ViewR(..),(><),(<|),(|>),Seq)

bsreadInt :: BC.ByteString -> Int
bsreadInt = fst . fromJust . BC.readInt

setadj :: Int -> [[Int]] -> [[Int]]
setadj n sn = setadj_ startset sn
              where startset = replicate n []

setadj_ :: [[Int]] -> [[Int]] -> [[Int]]
setadj_ an [] = an
setadj_ an (s:sn) = setadj_ bn sn
                    where sa = head s
                          sb = last s
                          bn = (take sa an) ++ [sb : (an!!sa)] ++ drop (sa+1) an

--無向隣接リスト作成
nsetadj :: Int -> [[Int]] -> [[Int]]
nsetadj n sn = setadj_ startset snx
              where startset = replicate (n+1) []
                    snx = sn ++ (map reverse sn)
                    
main = do
    [n,m] <- map bsreadInt . BC.words <$> BC.getLine --n頂点，m本の辺
    ab <- map ((map bsreadInt . BC.words)) <$> replicateM m BC.getLine -- a-->b :path のリスト
    let q = Sq.singleton [1]
    let chk = Set.singleton 1
    print $ length $ filter (==False) [connectchk q n (listArray (1,n) (drop 1 (nsetadj n (ab \\ [ab!!(k-1)] )))) chk | k <- [1..m]]
    --print $ length $ filter (==False) [connectchk q n (Set.union (Set.fromList (ab \\ [ab!!(k-1)] ) ) (Set.fromList (map reverse (ab \\ [ab!!(k-1)] )) )) chk | k <- [1..m]]

connectchk :: Sq.Seq [Int] -> Int -> (Array Int [Int]) -> Set.Set Int -> Bool
connectchk q n adjs chk = foldr (&&) True [ (bsearch q n g adjs chk) /= [] | g <- [2..n] ]
         
adjset :: Int -> Int  -> (Array Int [Int]) -> Set.Set Int -> [Int]
adjset x n adjs chk  = (adjs!x) \\ Set.toList chk

bsearch :: Sq.Seq [Int] -> Int -> Int -> (Array Int [Int]) -> Set.Set Int -> [Int]
bsearch q n g adjs chk = if Sq.length q == 0
                         then []
                         else if head (sqleft q) == g
                              then reverse $ sqleft q
                              else bsearch q2 n g adjs chk2
                                where qa = sqleft q
                                      q2 = (Sq.drop 1 q) >< (Sq.fromList add)
                                      add = [x : qa | x <- adjset (head qa) n adjs chk]
                                      chk2 = Set.union chk (Set.fromList (adjset (head qa) n adjs chk))
                                      
sqleft :: Seq a -> a
sqleft q = sqleft_(Sq.viewl q)
sqleft_ :: ViewL a -> a
sqleft_ (x :< xs) = x
sqright :: Seq a -> a
sqright q = sqright_(Sq.viewr q)
sqright_ :: ViewR a -> a
sqright_ (xs :> x) = x

    


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

using namespace std;
#define all(a)a.begin(),a.end()
using ll=long long;
const int INF = 1<<30;
const ll INFll =1LL<<62;
const int mod= int(1e9)+7;
using P = pair<ll,ll>;
using ld=long double;

int main(){
    ll n;cin >>n;
    string s;cin >>s;
    for (int i = 0; i < s.size(); ++i) {
        ll num=s[i]-'A';
        num+=n;
        num%=26;
        cout <<(char)('A'+num);
    }
    cout <<endl;
    return 0;
}

Measured memory_bytes: 256