akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<ll,ll> P;
typedef pair<int,int> Pi;
#define rep(i, n) for (ll i = 0; i < n; i++)
#define FOR(i, a, b) for (ll i = a; i < b; i++)
#define fi first
#define se second
#define PI (acos(-1))

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;
}
template<typename T> ostream& operator<<(ostream& s,const complex<T>& d) {return s<<"("<<d.real()<<", "<<d.imag()<< ")";}
template<typename T1, typename T2> ostream& operator<<(ostream& s,const pair<T1,T2>& d) {return s<<"("<<d.first<<", "<<d.second<<")";}
template<typename T> ostream& operator<<(ostream& s, const vector<T>& d){
	int len=d.size();
	rep(i,len){
		s<<d[i];if(i<len-1) s<<" ";
	}
	return s;
}
template<typename T> ostream& operator<<(ostream& s,const vector<vector<T>>& d){
	int len=d.size();
	rep(i,len){
		s<<d[i]<<endl;
	}
	return s;
}
template<typename T> ostream& operator<<(ostream& s,const set<T>& v){
	s<<"{ ";
	for(auto itr=v.begin();itr!=v.end();++itr) {
		if (itr!=v.begin()) {s<< ", ";}
		s<<(*itr);
	}
	s<<" }";
	return s;
}
template<typename T1, typename T2> ostream& operator<<(ostream& s,const map<T1,T2>& m){
	s<<"{"<<endl;
	for(auto itr=m.begin();itr!=m.end();++itr){
		s<<" "<<(*itr).first<<" : "<<(*itr).second<<endl;
	}
	s<<"}"<<endl;
	return s;
}

const ll mod=1e9+7;
const ll inf=1e15;

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	int n,m;
	string s;
	cin>>n>>m>>s;
	int cnt=0;
	reverse(begin(s),end(s));
	vector<int> ind;
	rep(i,s.size()){
		if(s[i]=='1'){
			cnt++;
			if(cnt>=m){
				cout<<-1<<endl;
				return 0;
			}
			if(i<s.size()-1 && s[i+1]=='0'){
				cnt=0;
				//ind.push_back(i);
			}
		}else{
			ind.push_back(i);
		}
	}
	ind.push_back(1e9);
	//cout<<ind<<endl;
	vector<int> ans;
	int now=0;
	int cnt1=0;
	while(now!=n){
		//cout<<now<<' ';
		int ne=lower_bound(begin(ind),end(ind),now+m)-begin(ind);
		if(ind[ne]>now+m) ne--;
		ans.push_back(ind[ne]-now);
		now=ind[ne];
		//cout<<ind[ne]<<endl;
		//cnt1++;
		//if(cnt1>=10) break;
	}
	reverse(begin(ans),end(ans));
	cout<<ans<<endl;
}

Measured memory_bytes: 1480
require 'prime'

n, m = gets.strip.split.map(&:to_i)
MOD = 10**9+7

def power(n, k)
  return 1 if k==0
  return power(n, k/2)**2 % MOD if k.even?
  n*power(n, k/2)**2 % MOD
end

fmax = Math.sqrt(m).ceil+n
@factor = [1,1]
(2..fmax).each do |i|
  @factor[i] = i*@factor[i-1] % MOD
end

@ifactor = [1,1]
@ifactor[fmax-2] = power(@factor[fmax-2], MOD-2) % MOD
(fmax-3).downto(2).each do |i|
  @ifactor[i] = @ifactor[i+1]*(i+1) % MOD
end

def comb(n, k)
  @factor[n]*(@ifactor[n-k]*@ifactor[k]%MOD)%MOD
end

divisions = m.prime_division

ans=1
divisions.each do |pr, div|
  ans = ans * comb(div+n-1, n-1) % MOD
end

#p @factor
#p @ifactor

p ans

Measured memory_bytes: 4168
#include <stdio.h>
#include <string.h>
int main(void) {
	char s[100];
	char p[100];
	char t[200];
	
	scanf("%s",s);
	scanf("%s",p);
	strcpy(t,s);
	strcat(t,s);
	if(strstr(t,p))
		printf("Yes\n");
	else 
		printf("No\n");
	
	
	return 0;;

}

Measured memory_bytes: 1824
# 貪欲法 + 山登り法 + 3点スワップ操作
import time
s__ = time.time()
limit = 1.9
#limit = 10

from numba import njit
import numpy as np

d = int(input())
cs = list(map(int, input().split()))
cs = np.array(cs, dtype=np.int64)
sm = [list(map(int, input().split())) for _ in range(d)]
sm = np.array(sm, dtype=np.int64)

@njit('i8(i8[:], i8)', cache=True)
def total_satisfaction(ts, d):
    ls = np.zeros(26, dtype=np.int64)
    s = 0
    for i in range(d):
        t = ts[i]
        t -= 1
        s += sm[i][t]
        ls[t] = i + 1

        dv = cs * ((i+1) - ls)
        s -= dv.sum()
    return s

@njit('i8[:]()', cache=True)
def greedy():
    ts = np.array([0] * d, dtype=np.int64)
    for i in range(d):
        mx = -1e10
        mxt = None
        for t in range(1, 26+1):
            ts[i] = t
            s = total_satisfaction(ts, i + 1)
            if s > mx:
                mx = s
                mxt = t
        ts[i] = mxt
    return ts

@njit('i8(i8, i8[:])', cache=True)
def loop(mxsc, ts):
    it = 50
    rds = np.random.randint(0, 6, (it,))
    rdd = np.random.randint(1, d, (it,))
    rdq = np.random.randint(1, 26, (it,))
    rdx = np.random.randint(1, 12, (it,))
    rdy = np.random.randint(1, 12, (it,))
    c1 = 0
    c2 = 3
    for i in range(it):
        bk1 = 0
        bk2 = 0
        bk3 = 0
        if rds[0] <= c1:
            # trailing
            di = rdd[i]
            qi = rdq[i]

            bk1 = ts[di]
            ts[di] = qi
        elif rds[0] <= c2:
            # swap
            di = rdd[i]
            xi = rdx[i]
            if di + xi >= d:
                xi = di - xi
            else:
                xi = di + xi
            
            bk1 = ts[di]
            bk2 = ts[xi]
            ts[di] = bk2
            ts[xi] = bk1
        else:
            # triswap
            di = rdd[i]
            xi = rdx[i]
            if di + xi >= d:
                xi = di - xi
            else:
                xi = di + xi
            yi = rdy[i]
            if xi + yi >= d:
                yi = xi - yi
            else:
                yi = xi + yi
            
            bk1 = ts[di]
            bk2 = ts[xi]
            bk3 = ts[yi]
            ts[di] = bk2
            ts[xi] = bk3
            ts[yi] = bk1

        sc = total_satisfaction(ts, d)

        if sc > mxsc:
            #print(mxsc, '->', sc)
            mxsc = sc
        else:
            # 最大値を更新しなかったら戻す
            if rds[0] <= c1:
                ts[di] = bk1
            elif rds[0] <= c2:
                ts[di] = bk1
                ts[xi] = bk2
            else:
                ts[di] = bk1
                ts[xi] = bk2
                ts[yi] = bk3

    return mxsc

ts = greedy()
mxsc = total_satisfaction(ts, d)
mxbk = mxsc

s_ = time.time()
mxsc = loop(mxsc, ts)
e_ = time.time()

consume = s_ - s__
elapsed = e_ - s_
#print('consume:', consume)
#print('elapsed:', elapsed)

if consume < limit:
    lp = int((limit - consume) / elapsed)
    #print('loop', lp)
    for _ in range(lp):
        mxsc = loop(mxsc, ts)

for t in ts:    print(t)
#print(mxbk, mxsc)
#print(time.time() - s__)


Measured memory_bytes: 124176
import javax.xml.crypto.Data;
import java.util.*;
import java.io.*;

public class Main {
    public static int n;
    public static int N = 100;
    public static int[][] M = new int[N][N];
    public static int INF = 10000007;
    public static int NIL = -1;
    public static int WHITE = 0;
    public static int GRAY = 1;
    public static int BLACK = 2;

    public static void main(String[] args) throws IOException {

        //??\???
        /*
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        String[] str = br.readLine().split(" ");
        */
        Scanner sc = new Scanner(System.in);
        n = sc.nextInt();
        for(int i = 0; i < n; i++) {
            for(int j = 0; j < n; j++) {
                int d = sc.nextInt();
                if(d == -1) M[i][j] = INF;
                else M[i][j] = d;
            }
        }

        //??????
        System.out.println(prim());
    }

    public static int prim() {
        int[] color = new int[n];
        int[] d = new int[n];
        int[] p = new int[n];
        for(int i = 0; i < n; i++) {
            color[i] = WHITE;
            d[i] = INF;
        }
        d[0] = 0;
        p[0] = NIL;

        while(true) {
            int mincost = INF;
            int u = 0;
            for(int i = 0; i < n; i++) {
                if(color[i] != BLACK && d[i] < mincost) {
                    mincost = d[i];
                    u = i;
                }
            }
            if(mincost == INF) break;
            color[u] = BLACK;
            for(int i = 0; i < n; i++) {
                if(color[i] != BLACK && M[u][i] < d[i]) {
                    d[i] = M[u][i];
                    color[i] = GRAY;
                    p[i] = u;
                }
            }
        }
        int ans = 0;
        for(int i = 0; i < n; i++) {
            if(p[i] != NIL) ans += M[i][p[i]];
        }
        return ans;
    }



}

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

#define pb push_back
#define eb emplace_back
#define mk make_pair
#define fi first
#define se second
#define mset(a, b) memset(a, b, sizeof(a))
#define DBG(x) cout << "[" << #x << "]: " << x << endl
using ll = long long;
using pii = pair<int, int>;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
#ifdef _WIN32
#define getchar_unlocked _getchar_nolock
#endif

template<class Ty> Ty randint(Ty a, Ty b) { return uniform_int_distribution<Ty>(a, b)(rng); }
template<class num> inline void rd(num& x) {
	char c, neg = 0; while(isspace(c = getchar_unlocked()));
	if(!isdigit(c)) neg = (c == '-'), x = 0;
	else x = c - '0';
	while(isdigit(c = getchar_unlocked())) x = (x << 3) + (x << 1) + c - '0';
	x = neg ? -x : x; }
template <class... Args> inline void rd(Args&... args) { (rd(args), ...); }

const int MAXN = 2e5 + 5, INF = 0x3f3f3f3f;

const int MOD = 1e9 + 7;

int a[MAXN];
int sum[MAXN];

int main() {
	int n; rd(n);
	for (int i = 1; i <= n; i++) rd(a[i]);

	for (int i = 1; i <= n; i++) {
		sum[i] = (a[i] + sum[i-1]) % MOD;
	}

	int ans = 0;
	for (int i = 1; i <= n; i++) {
		ans += 1ll * a[i] * (sum[n] - sum[i] + MOD) % MOD;
		ans %= MOD;
		ans += MOD;
		ans %= MOD;
	}

	printf("%d\n", ans);
}

Measured memory_bytes: 5320
from collections import deque
 
 
class Dinic:
    def __init__(self, n: int):
        """頂点数をnとする"""
        self.INF = float("inf")
        self.n = n
        self.graph = [[] for _ in range(n)]
 
    def add_edge(self, _from: int, to: int, capacity: int):
        """残余グラフを構築
        1. _fromからtoへ向かう容量capacityの辺をグラフに追加する
        2. toから_fromへ向かう容量0の辺をグラフに追加する
        """
        forward = [to, capacity, None]
        forward[2] = backward = [_from, 0, forward]
        self.graph[_from].append(forward)
        self.graph[to].append(backward)
 
    def bfs(self, s: int, t: int):
        """capacityが正の辺のみを通ってsからtに移動可能かどうかBFSで探索
        level: sからの最短路の長さ
        """
        self.level = [-1] * self.n
        q = deque([s])
        self.level[s] = 0
        while q:
            _from = q.popleft()
            for to, capacity, _ in self.graph[_from]:
                if capacity > 0 and self.level[to] < 0:
                    self.level[to] = self.level[_from] + 1
                    q.append(to)
 
    def dfs(self, _from: int, t: int, f: int) -> int:
        """流量が増加するパスをDFSで探索
        BFSによって作られた最短路に従ってfを更新する
        """
        if _from == t:
            return f
        for edge in self.itr[_from]:
            to, capacity, reverse_edge = edge
            if capacity > 0 and self.level[_from] < self.level[to]:
                d = self.dfs(to, t, min(f, capacity))
                if d > 0:
                    edge[1] -= d
                    reverse_edge[1] += d
                    return d
        return 0
 
    def max_flow(self, s: int, t: int):
        """s-tパス上の最大流を求める
        計算量: O(|E||V|^2)
        """
        flow = 0
        while True:
            self.bfs(s, t)
            if self.level[t] < 0:
                break
            self.itr = list(map(iter, self.graph))
            f = self.dfs(s, t, self.INF)
            while f > 0:
                flow += f
                f = self.dfs(s, t, self.INF)
        return flow

n = int(input())
a = list(map(int, input().split()))

dinic = Dinic(n + 2)
s = 0
t = n + 1
_sum = 0
for i in range(0, n):
    if a[i] > 0:
        dinic.add_edge(s, i+1, 0)
        dinic.add_edge(i+1, t, a[i])
        _sum += a[i]
    elif a[i] < 0:
        dinic.add_edge(s, i+1, -a[i])
        dinic.add_edge(i+1, t, 0)
    else:
        dinic.add_edge(s, i+1, 0)
        dinic.add_edge(i+1, t, 0)

for i in range(n):
    num = i+1
    next_num = 2 * num
    while next_num <= n:
        dinic.add_edge(num, next_num, 10**18)
        next_num += num

print(_sum - dinic.max_flow(s, t))

Measured memory_bytes: 41052
import java.util.Scanner;

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

        if (s.equals("SUN")) {
            System.out.println(7);
        } else if (s.equals("MON")) {
            System.out.println(6);
        } else if (s.equals("TUE")) {
            System.out.println(5);
        } else if (s.equals("WED")) {
            System.out.println(4);
        } else if (s.equals("THU")) {
            System.out.println(3);
        } else if (s.equals("FRI")) {
            System.out.println(2);
        } else if (s.equals("SAT")) {
            System.out.println(1);
        }
    }
}

Measured memory_bytes: 21716
#include <bits/stdc++.h>
using namespace std;
#define rep(i,ini,n) for(int i=ini;i<n;i++)
#define _rep(i,ini,n) for(int i=ini;i>=n;i--)
#define ToEnd(a) a.begin(),a.end()
uint64_t MOD=1000000007;

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

    int num0=0,num1=0;
    for(auto s:S){
        if(s=='0') num0++;
        if(s=='1') num1++;
    }

    cout<<min(num0,num1)*2<<endl;
}

Measured memory_bytes: 512
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time,copy,functools

sys.setrecursionlimit(10**7)
inf = 10**20
eps = 1.0 / 10**10
mod = 10**9+7
dd = [(-1,0),(0,1),(1,0),(0,-1)]
ddn = [(-1,0),(-1,1),(0,1),(1,1),(1,0),(1,-1),(0,-1),(-1,-1)]

def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def S(): return input()
def pf(s): return print(s, flush=True)


class UnionFind:
    def __init__(self, size):
        self.table = [-1 for _ in range(size)]

    def find(self, x):
        if self.table[x] < 0:
            return x
        else:
            self.table[x] = self.find(self.table[x])
            return self.table[x]

    def union(self, x, y):
        s1 = self.find(x)
        s2 = self.find(y)
        if s1 != s2:
            if self.table[s1] <= self.table[s2]:
                self.table[s1] += self.table[s2]
                self.table[s2] = s1
            else:
                self.table[s2] += self.table[s1]
                self.table[s1] = s2
            return True
        return False

    def subsetall(self):
        a = []
        for i in range(len(self.table)):
            if self.table[i] < 0:
                a.append((i, -self.table[i]))
        return a

    def tall(self):
        d = collections.defaultdict(list)
        for i in range(len(self.table)):
            d[self.find(i)].append(i)
        return d

def main():
    M = 2**17
    n,m = LI()
    a = [LI() for _ in range(m)]
    e = collections.defaultdict(list)
    for p,q,c in a:
        pc = p+c*M
        qc = q+c*M
        pm = p-M
        qm = q-M
        e[pc].append(qc)
        e[qc].append(pc)
        e[pm].append(pc)
        e[qm].append(qc)
        e[pc].append(pm)
        e[qc].append(qm)

    def search():
        d = collections.defaultdict(lambda: inf)
        s = 1-M
        d[s] = 0
        q = []
        heapq.heappush(q, (0, s))
        v = set()
        while len(q):
            k, u = heapq.heappop(q)
            if u in v:
                continue
            v.add(u)
            if u < 0:
                for uv in e[u]:
                    if uv in v:
                        continue
                    vd = k + 1
                    if d[uv] > vd:
                        d[uv] = vd
                        heapq.heappush(q, (vd, uv))

            else:
                if u % M == n:
                    return k

                for uv in e[u]:
                    if uv in v:
                        continue
                    if d[uv] > k:
                        d[uv] = k
                        heapq.heappush(q, (k, uv))

        return -1

    return search()



print(main())


Measured memory_bytes: 215640
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {

	public static void main(String[] args) throws NumberFormatException, IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		int n = Integer.parseInt(br.readLine());
		int ac = 0,wa= 0,tle= 0,re=0;
		
		while(n-- > 0)
		{
			
		
		char ch = br.readLine().charAt(0);
		//System.out.println(ch);
		switch(ch)
		{
			case 'A':
			{
				ac++;
				break;
			}
				
			case 'W':
			{
				wa++;
				break;
			}
				
			case 'T':
			{
				tle++;
				break;
			}
			
			case 'R':
			{
				re++;
				break;
			}
		
		}
		}
		System.out.println("AC x "+ac);
		System.out.println("WA x "+wa);
		System.out.println("TLE x "+tle);
		System.out.println("RE x "+re);
	}

}


Measured memory_bytes: 43164
#import sys
#input = sys.stdin.readline
def main():
    S = input()
    N = len(S)
    for i in range(0, N, 2):
        if S[i] == "L":
            print("No")
            return
    for i in range(1,N,2):
        if S[i] == "R":
            print("No")
            return
    print("Yes")
if __name__ == '__main__':
    main()


Measured memory_bytes: 2940
#!/usr/bin/env python3
# from typing import *



# def solve(N: int, D: int, X: List[int], Y: List[int]) -> int:
def solve(N, D, X, Y):
    count = 0
    for x,y in zip(X,Y):
        dist = (x**2 + y**2)**0.5
        if dist <= D:
            count += 1

    return count

# generated by online-judge-template-generator v4.4.0 (https://github.com/kmyk/online-judge-template-generator)
def main():
    N, D = map(int, input().split())
    X = [None for _ in range(N)]
    Y = [None for _ in range(N)]
    for i in range(N):
        X[i], Y[i] = map(int, input().split())
    a = solve(N, D, X, Y)
    print(a)

if __name__ == '__main__':
    main()


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

using namespace std;

void solve() {
    int a, b; cin >> a >> b;
    string s, t;
    for (int i = 0; i < b; i++) s.push_back(a + '0');
    for (int i = 0; i < a; i++) t.push_back(b + '0');
    if (s < t) cout << s; else cout << t;
}

int main() {
    ios::sync_with_stdio(NULL), cin.tie(0), cout.tie(0);
    cout.setf(ios::fixed), cout.precision(20);
    solve();
}


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

using namespace std;
using ll = long long;
using ld = long double;
using pii = pair<int, int>;
using pll = pair<ll, ll>;

#define FOR(k,m,n) for(ll (k)=(m);(k)<(n);(k)++)
#define REP(i,n) FOR((i),0,(n))
#define WAITING(str) int str;std::cin>>str;
#define DEBUGING(str) cout<< #str << " " str<<endl

constexpr int INF = (1 << 30);
constexpr ll INFL = (1ll << 60);
constexpr ll MOD = 1000000007;// 10^9+7



int main()
{
	ll N, res = 99;
	cin >> N;
	FOR(i, 1, sqrt(N) + 1) if (N%i == 0) {
		res = min(res, (ll)to_string(N / i).size());
	}
	cout << res << endl;
	return 0;
}


Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Scanner;

public class Main {

		public static void main(String args[]) throws IOException{
			Scanner scan = new Scanner(System.in);

			double cx1, cy1, r1;
			double cx2, cy2, r2;
			
			//if(args.length != 0){
				cx1 = scan.nextDouble();
				cy1 = scan.nextDouble();
				r1 = scan.nextDouble();
				cx2 = scan.nextDouble();
				cy2 = scan.nextDouble();
				r2 = scan.nextDouble();
				
				double l = (Math.pow(cx1 - cx2, 2) + Math.pow(cy1 - cy2, 2));
				double rlen = r1+r2;
				double revlen = r1 - r2;
				if(l > rlen*rlen) 
					System.out.println("4");
				else if(l == rlen*rlen) 
					System.out.println("3");
				else if(l < rlen*rlen) {
					if(l > revlen*revlen)
						System.out.println("2");
					else if(l == revlen*revlen)
						System.out.println("1");
					else if(l < revlen*revlen)
						System.out.println("0");
				}
			//}
				scan.close();
			//else System.out.println("Input doesn't be exist");
		}	
	}




Measured memory_bytes: 28032
#include <iostream>
#include <algorithm>
#include <cstdio>
#include <cstring>
#include <set>
using namespace std;
int main()
{
    set<int> x;
    int n;
    cin>>n;
    for(int i=0;i<n;i++)
    {
    	int d;
    	cin>>d;
    	x.insert(d);
    }
    cout<<x.size()<<endl;
    return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
    static Scanner sc = new Scanner(System.in);

    public static void main(String[] args) {
        long n = sc.nextInt();
        long k = sc.nextInt();
        long mod = (long) Math.pow(10, 9) + 7;
        long count = 0;
        for (long i = k; i <= n + 1; i++) {
            long min = sum(0, i - 1);
            long max = sum(n - i + 1, n);
            count += (max - min + 1);
            count %= mod;
        }
        System.out.println(count);

    }

    private static long sum(long left, long right) {
        return (left + right) * (right - left + 1) / 2;
    }
}


Measured memory_bytes: 35752
#include <bits/stdc++.h>
#define LLI long long int
#define FOR(v, a, b) for(LLI v = (a); v < (b); ++v)
#define FORE(v, a, b) for(LLI v = (a); v <= (b); ++v)
#define REP(v, n) FOR(v, 0, n)
#define REPE(v, n) FORE(v, 0, n)
#define REV(v, a, b) for(LLI v = (a); v >= (b); --v)
#define ALL(x) (x).begin(), (x).end()
#define RALL(x) (x).rbegin(), (x).rend()
#define ITR(it, c) for(auto it = (c).begin(); it != (c).end(); ++it)
#define RITR(it, c) for(auto it = (c).rbegin(); it != (c).rend(); ++it)
#define EXIST(c,x) ((c).find(x) != (c).end())
#define fst first
#define snd second
#define popcount __builtin_popcount
#define UNIQ(v) (v).erase(unique(ALL(v)), (v).end())
#define bit(i) (1LL<<(i))

#ifdef DEBUG
#include <misc/C++/Debug.cpp>
#else
#define dump(...) ((void)0)
#endif

#define gcd __gcd

using namespace std;
template <class T> constexpr T lcm(T m, T n){return m/gcd(m,n)*n;}

template <typename I> void join(ostream &ost, I s, I t, string d=" "){for(auto i=s; i!=t; ++i){if(i!=s)ost<<d; ost<<*i;}ost<<endl;}
template <typename T> istream& operator>>(istream &is, vector<T> &v){for(auto &a : v) is >> a; return is;}

template <typename T, typename U> bool chmin(T &a, const U &b){return (a>b ? a=b, true : false);}
template <typename T, typename U> bool chmax(T &a, const U &b){return (a<b ? a=b, true : false);}
template <typename T, size_t N, typename U> void fill_array(T (&a)[N], const U &v){fill((U*)a, (U*)(a+N), v);}

struct Init{
  Init(){
    cin.tie(0);
    ios::sync_with_stdio(false);
  }
}init;



int main(){

  int n;
  while(cin >> n){
    vector<int> h(n); cin >> h;
    reverse(ALL(h));

    vector<int> dp(n);

    FOR(i,1,n){
      if(h[i-1] > h[i]) dp[i] = 0;
      else dp[i] = dp[i-1] + 1;
    }

    int ans = *max_element(ALL(dp));

    cout << ans << endl;
  }


  return 0;
}



Measured memory_bytes: 1024
#include <iostream>
#include <math.h>
#include <limits>
#include <iomanip>
#include <algorithm>
#include <vector>
#include <stdio.h>
#include <map>
using namespace std;
#define rep(i, n) for (int i =0; i < (int)(n); i++)
typedef pair<int, string> P;

template<int MOD> struct Fp {
    long long val;
    constexpr Fp(long long v = 0) noexcept : val(v% MOD) {
        if (val < 0) val += MOD;
    }
    constexpr int getmod() { return MOD; }
    constexpr Fp operator - () const noexcept {
        return val ? MOD - val : 0;
    }
    constexpr Fp operator + (const Fp& r) const noexcept { return Fp(*this) += r; }
    constexpr Fp operator - (const Fp& r) const noexcept { return Fp(*this) -= r; }
    constexpr Fp operator * (const Fp& r) const noexcept { return Fp(*this) *= r; }
    constexpr Fp operator / (const Fp& r) const noexcept { return Fp(*this) /= r; }
    constexpr Fp& operator += (const Fp& r) noexcept {
        val += r.val;
        if (val >= MOD) val -= MOD;
        return *this;
    }
    constexpr Fp& operator -= (const Fp& r) noexcept {
        val -= r.val;
        if (val < 0) val += MOD;
        return *this;
    }
    constexpr Fp& operator *= (const Fp& r) noexcept {
        val = val * r.val % MOD;
        return *this;
    }
    constexpr Fp& operator /= (const Fp& r) noexcept {
        long long a = r.val, b = MOD, u = 1, v = 0;
        while (b) {
            long long t = a / b;
            a -= t * b; swap(a, b);
            u -= t * v; swap(u, v);
        }
        val = val * u % MOD;
        if (val < 0) val += MOD;
        return *this;
    }
    constexpr bool operator == (const Fp& r) const noexcept {
        return this->val == r.val;
    }
    constexpr bool operator != (const Fp& r) const noexcept {
        return this->val != r.val;
    }
    friend constexpr ostream& operator << (ostream& os, const Fp<MOD>& x) noexcept {
        return os << x.val;
    }
    friend constexpr Fp<MOD> modpow(const Fp<MOD>& a, long long n) noexcept {
        if (n == 0) return 1;
        auto t = modpow(a, n / 2);
        t = t * t;
        if (n & 1) t = t * a;
        return t;
    }
};

const int MOD= 1000000007;
using mint = Fp<MOD>;

long long sum(long long l, long long r) {
    return (l + r) * (r - l + 1) / 2;

}



int main() {
    int n,k;
    cin >> n>>k;
    mint ans = 0;
    for (int i = k; i <= n + 1; i++) {
        long long l = sum(0, i - 1), r = sum(n - i + 1, n);
        ans += r - l + 1;
    }
    cout << ans << endl;
}


Measured memory_bytes: 3588
# -*- coding: utf-8 -*-
"""
Created on Fri Jun 15 11:27:37 2018

@author: Yuya
"""

N = int(input())
A = list(map(int,input().split()))

A.sort()
A.reverse()

Alice = 0
Bob = 0

for i in range(N):
    if i%2 > 0:
        Bob += A[i]
    else:
        Alice += A[i]

print(Alice-Bob)

Measured memory_bytes: 3060
'use strict';

process.stdin.resume();
process.stdin.setEncoding('utf-8');

let inputString = '';
let currentLine = 0;

process.stdin.on('data', inputStdin => {
    inputString += inputStdin;
});

process.stdin.on('end', _ => {
    inputString = inputString.trim().split('\n').map(string => {
        return string.trim();
    });

    main();
});

function readline() {
    return inputString[currentLine++];
}

function getArray(str) {
    return str.split(' ').map(x => Number(x));
}

function getInt(str) {
    return Number(str);
}

function getStrArray(str) {
    return str.split(' ').map(x => x);
}
// ---------------------------------------



function main() {
    const len = getInt(readline());
    const a = getArray(readline());
    const dp = new Array(len);
    dp.fill(-1);
    dp[0] = 0;
    dp[1] = Math.abs(a[1] - a[0]);
    for (let i = 2; i < len; i++) {
        dp[i] = Math.min(
            dp[i - 1] + Math.abs(a[i] - a[i - 1]),
            dp[i - 2] + Math.abs(a[i] - a[i - 2]),
        );  
    }
    console.log(dp[len-1]);
}

Measured memory_bytes: 40416
#include <bits/stdc++.h>
using namespace std;
#define REP(i, s, n) for (int i = s; i < n; ++i)
#define rep(i, n) REP(i, 0, n)
#define SORT(c) sort((c).begin(), (c).end())
#define SORT_INV(c) sort((c).begin(), (c).end(), greater<int>())
#define IINF INT_MAX
#define LLINF LLONG_MAX
#define DEBUG true
#define LL long long
// sort(a.begin(), a.end(), std::greater<int>());

int main()
{
    int n;
    cin >> n;
    vector<LL int> hoge;
    hoge.push_back(2);
    hoge.push_back(1);
    REP(i, 2, 100)
    {
        LL int namu = hoge[i - 1] + hoge[i - 2];
        hoge.push_back(namu);
    }
    cout<<hoge[n]<<endl;
}

Measured memory_bytes: 384
#include <iostream>
#include <algorithm>
#include <cmath>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <queue>
#include <string>
#include <queue>
#include <numeric>
#include <ctype.h>
#include <limits>
#include <iomanip>

#define rep(i,n) for (int i = 0; i < n; i++)
#define all(x) (x).begin(),(x).end()
using namespace std;

typedef long long ll;

int main() {
	int N, A, B, C, D;
	string S;
	cin >> N >> A >> B >> C >> D >> S;
	bool ok = true;
	int i;

	if (C < D) {
		for (i = A; i < D; i++) {
			if (S[i] == '#' && S[i + 1] == '#') {
				ok = false;
				break;
			}
		}
	}
	else {
		ok = false;

		for (i = A; i < C; i++) {
			if (S[i] == '#' && S[i + 1] == '#') {
				break;
			}
			if (i >= B - 2 && i < D - 1) {
				if (S[i] == '.' && S[i + 1] == '.' && S[i + 2] == '.') {
					ok = true;
				}
			}
		}

	}
	if (ok) {
		cout << "Yes" << endl;
	}
	else {
		cout << "No" << endl;
	}
	return 0;
}

Measured memory_bytes: 640
#include <stdio.h>
#include <algorithm>

#define LIM_S 200002
#define LIM_N 200001

char str[LIM_S];
unsigned long long N;
unsigned long long a[5];

void receive_input() {
	fgets(str, sizeof(str), stdin);
	sscanf(str, "%llu", &N);

	for (size_t i = 0; i < 5; i++) {
		fgets(str, sizeof(str), stdin);
		sscanf(str, "%llu", &a[i]);
	}
}

void initialize() {
}

unsigned long long solve() {
	unsigned long long ans = 0;
	unsigned long long neck = a[0];
	int neck_num = 0;

	for (size_t i = 0; i < 5; i++) {
		if (a[i] < neck) {
			neck = a[i];
			neck_num = i;
		}
	}

	ans = 5;
	if (N / neck > 0) {
		ans += N / neck - 1;
		if (N % neck > 0) {
			ans += 1;
		}
	}

	return ans;
}

int main(void) {
	receive_input();
	initialize();

	printf("%llu\n", solve());

	return 0;
}


Measured memory_bytes: 128
#include <stdio.h>
#include <stdlib.h>

typedef struct {
  int a;
  int b;
} abstruct;


int compare_ab(const void *a, const void *b)
{
    return (*(abstruct*)a).b - (*(abstruct*)b).b;
}

int main()
{
  int i,n; 
  abstruct ab[200000];
  scanf("%d",&n);
  for(int i=0;i<n;i++){
    scanf("%d%d",&ab[i].a, &ab[i].b);
  }
  qsort(ab, n, sizeof(abstruct), compare_ab);
  int elapsed=0;
  for(int i=0;i<n;i++){
    elapsed+=ab[i].a;
    if(elapsed>ab[i].b){
      printf("No\n");
      return 0;
    }
  }
  printf("Yes\n");
  return 0;
}

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

int main(){
  cin.tie(nullptr);
  ios_base::sync_with_stdio(false);
  int a;
  string s;
  cin >> a >> s;
  if(a >= 3200){
    cout << s << endl;
  }
  else{
    cout << "red" << endl;
  }
  return 0;
}

Measured memory_bytes: 256
// id: ALDS1_4_A
#include <stdio.h>

#define MAX_N 10000
#define MAX_Q 500

int find(int a[], int n, int key);

int main(void)
{
	int s[MAX_N + 1];
	int t[MAX_Q];
	int n, q;
	int cnt = 0;
	
	scanf("%d", &n);
	for ( int i = 0; i < n; ++i )
		scanf("%d", &s[i]);
	scanf("%d", &q);
	for ( int i = 0; i < q; ++i )
		scanf("%d", &t[i]);

	for ( int i = 0; i < q; ++i ) {
		if ( find(s, n, t[i]) != -1 )
			++cnt;
	}

	printf("%d\n", cnt);

	return 0;
}

int find(int a[], int n, int key)
{
	a[n] = key;
	int i;

	for ( i = 0; a[i] != key; ++i )
		;

	return i == n ? -1 : i;
}


Measured memory_bytes: 2772
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef pair<ll,ll> pll;
typedef double db;
#define INF 1e8
#define EPS 1e-9
#define ALL(x) x.begin() , x.end()
#define ALLR(x) x.rbegin() , x.rend()
#define UNIQUE(c) (c).resize(unique(ALL(c)) - (c).begin())
#define PI acos(-1.0) 

int main()
{
  int n;
  string s;
  cin>>n>>s;
  vl c,d;
  bool o=0;
  for(int i=0;i<n;i++)
  {
    c.push_back((s[i]-'0')-1);
    if(c[i]==1)o=1;

  }

  for(int i=0;i<n;i++)
  {
    if(c[i]==2)
    {
      if(!o)c[i]=1;
      else c[i]=0;
    }
  }
  while(c.size()!=1)
  {
    int maxlog = 31 - __builtin_clz(c.size());
    ll des = 1<<maxlog;
    if(des==c.size())des=des>>1;
    for(int i=0;i<c.size()-des;i++)
    {
      d.push_back(c[i]^c[i+des]);
    }
    c.clear();
    c.assign(ALL(d));
    d.clear();
  }
  if(c[0]==1)
  {
    if(o)cout<<c[0];
    else cout<<2<<endl;
  }
  else
  cout<<c[0]<<"\n";
}

Measured memory_bytes: 17140
#include <iostream>
#include <iomanip>
using namespace std;
int main()
{
	double a, b, c, d, e, f, x, y;
	while (cin >> a >> b >> c >> d >> e >> f)
	{
		if (cin.eof()) break;
		y = (c*d - a*f) / (b*d - a*e);
		x = -b/a * y + c/a;
		cout << setprecision(3) << setiosflags(ios::fixed) << x << " " << y << endl;
	}
	return 0;
}

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

using namespace std;

int main () {

  int A, B;
  bool ans;
  cin >> A >> B;

  if (A % 2 == 0 || B % 2 == 0) {
    ans = false;
  } else {
    ans = true;
  }

  if (ans) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }

  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i,n) for(int i = 0; i < (n); i++)
#define all(v) v.begin(), v.end()
#define MOD 1000000007
const int INF = 1LL<<30;

int dp[1010][10010];

int main(){
    int h,n;
    cin>>h>>n;
    vector<int> a(n),b(n);
    rep(i,n) cin>>a[i]>>b[i];

    rep(i,n+1) rep(j,h+1) dp[i][j]=INF;
    dp[0][0]=0;

    rep(i,n){
        rep(j,h+1){
            dp[i+1][j]=min(dp[i+1][j],dp[i][j]);
            dp[i+1][min(j+a[i],h)]=min(dp[i+1][min(j+a[i],h)],dp[i+1][j]+b[i]);
        }
    }

    cout<<dp[n][h]<<endl;
}

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

#define ll long long
#define INF 99999999
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()

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

    rep(i,2*K-1)
    {
        cout << X + i - K + 1;
        if(i != 2*K-2) cout << " ";
    }
    cout << endl;
}


Measured memory_bytes: 256
void main()
{
    long a = readln.chomp.to!long - 1;
    long b = readln.chomp.to!long - 1;

    bool[3] ok;
    ok[] = true;
    ok[a] = ok[b] = false;

    foreach (i, x; ok)
    {
        if (x) writeln(i + 1);
    } 
}

import std.stdio;
import std.string;
import std.array;
import std.conv;
import std.algorithm;
import std.range;
import std.math;
import std.numeric;
import std.container;
import std.typecons;
import std.ascii;
import std.uni;

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

int main() {
  int N,M;
  cin>>N;
  vector<string> s(N);
  for(int i=0;i<N;i++)
  {
     cin>>s.at(i); 
  }
    

  cin>>M;
  
  
  vector<string> t(M);
  for(int i=0;i<M;i++)
   {
    cin>>t.at(i);
   }

int cnt = 0;
  for(int i=0;i<N;i++){
    int cntt= 0;
    for(int j=0;j<N;j++){
      if(s.at(i)==s.at(j))
        cntt++;
    }
    
    
    
    for(int j=0;j<M;j++){
      if(s.at(i)==t.at(j))
        cntt--;
    }
    if(cntt>cnt)
      cnt=cntt;
  }
  cout<<cnt<<endl;
}


Measured memory_bytes: 256
#include<stdio.h>
#include<vector>
#include<algorithm>
#include<map>
using namespace std;
typedef long long ll;
typedef pair<ll, ll>pii;
vector<ll>pr;
map<ll, ll>sq;
bool ispr[1000001];
void init()
{
	fill(ispr, ispr + 1000001, true);
	for (int i = 2; i <= 1000000; i++)
	{
		if (ispr[i])
		{
			for (int j = i + i; j <= 1000000; j += i)ispr[j] = false;
			pr.push_back(i);
		}
	}
	for (ll i = 2; i <= 1000000; i++)
	{
		if (ispr[i])sq[i*i] = i;
	}
}
ll getpair(ll n)
{
	ll p = 1;
	for (int i = 0;; i++)
	{
		if (pr[i] * pr[i] * pr[i] > n)break;
		if (n%pr[i] == 0)
		{
			int t = 0;
			for (;;)
			{
				if (n%pr[i] != 0)break;
				t++;
				n /= pr[i];
			}
			if (t % 3 == 1)p *= pr[i] * pr[i];
			if (t % 3 == 2)p *= pr[i];
		}
	}
	if (sq.count(n) != 0)
	{
		p *= sq[n];
		n = 1;
	}
	if (double(p)*double(n)*double(n) > (1e11))return -1;
	return p * n * n;
}
int main()
{
	int num;
	scanf("%d", &num);
	map<ll, ll>ma;
	init();
	int ans = 0;
	for (int i = 0; i < num; i++)
	{
		ll z;
		scanf("%lld", &z);
		ll t = getpair(z);
		if (t == -1)ans += 2;
		else ma[getpair(z)]++;
		//printf("%lld %lld\n", z, getpair(z));
	}
	map<ll, ll>::iterator it = ma.begin();
	for (;;)
	{
		if (it == ma.end())break;
		pii z = *it;
		it++;
		if (z.first == 1)
		{
			ans += 2;
			continue;
		}
		ll t = getpair(z.first);
		if (ma.count(t) == 0)ans += z.second * 2;
		else ans += max(z.second, ma[t]);
	}
	printf("%d\n", ans / 2);
}

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

#define INF 1001001001
#define LINF 1001001001001001001
#define MOD 1000000007
#define MOD2 998244353

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

#define rep(i,n) for(int i=0,_i=(n);i<_i;++i)
#define rep1(i,a,b) for(int a_=(a),b_=(b),i=a_;i<b_;++i)
#define repr(i,n) for(int _i=(n),i=_i;i>0;--i)

#define db(x) cerr<<#x<<" = "<<x<<" ";
#define db2(x,y) cerr<<"("<<#x<<", "<<#y<<") = ("<<x<<", "<<y<<") ";
#define ln cout<<endl;

#define all(a)  (a).begin(),(a).end()
#define dig(n)  to_string(n).length()
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define se second
#define fi first

typedef long long ll;
typedef pair<int,int> pii;
typedef pair<pii,pii> ppii;

ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b){return (a*b)/gcd(a,b);}
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};



int main(){

    bool flag=false;
    ll ans=0,sum=0;

    int n,m;
    cin >>n;
    vector<int> a(n);

    rep(i,n){
        cin>>a[i];
        sum += a[i];
    }

    ll snk=a[0];
    ll dif = abs(snk - (sum-snk));
    rep1(i,1,n-1){
        snk += a[i];

        chmin(dif,abs(snk - (sum-snk)) );
    }

    //cout <<fixed<<setprecision(16)<< << endl;
    cout<< dif <<endl;
    //if(flag)cout << "Yes" <<endl;
    //else cout << "No" <<endl;
    
    return 0;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int (i) = 0; (i) < (n); ++(i))
#define rrep(i,n) for(int (i) = (n) - 1; (i) >= 0; --(i)) //Reversi rep
#define nfor(i,a,b) for(int (i) = (a); (i) < (b); ++(i)) //Natural for
#define rfor(i,a,b) for(int (i) = (b) - 1; (i) >= (a); --(i)) //Reversi for
#define ll long long
#define mod (1000000007)
#define YES cout << "YES" << endl;
#define Yes cout << "Yes" << endl;
#define yes cout << "yes" << endl;
#define NO cout << "NO" << endl;
#define No cout << "No" << endl;
#define no cout << "no" << endl;

int asc(const void *a, const void *b) {
    return *(int *)a - *(int *)b;
}

int desc(const void *a, const void *b) {
    return *(int *)b - *(int *)a;
}

int main()
{
    int h,w,cnt = 0,b = 0,c = 0;
    cin >> h >> w;
    string a[h];
    rep(i, h)cin >> a[i];
    rep(i, h)rep(j, w)if(a[i][j] == '#')++cnt;
    if (cnt != h + w - 1) {
        cout << "Impossible" << endl;
        //cout << 1 << endl;
    }else{
        if (a[b][c] != '#') {
            cout << "Impossible" << endl;
            cout << 2 << endl;
        }else{
            rep(i, h + w - 2){
                if ((a[b + 1][c] != '#' && a[b][c + 1] != '#') || (a[b + 1][c] == '#' && a[b][c + 1] == '#')) {
                    cout << "Impossible" << endl;
                    return 0;
                }else if (a[b + 1][c] == '#' && a[b][c + 1] != '#'){
                    ++b;
                }else if (a[b + 1][c] != '#' && a[b][c + 1] == '#'){
                    ++c;
                }
            }
            cout << "Possible" << endl;
        }
    }
    return 0;
}


Measured memory_bytes: 256
def main():
    input()  # n
    stones = input()
    white_counter = []
    white_stones = 0
    red_stones = 0
    for color in stones:
        if color == 'W':
            white_stones += 1
        else:
            red_stones += 1
        white_counter.append(white_stones)

    if red_stones == 0:
        print(0)
    else:
        print(white_counter[red_stones - 1])


if __name__ == '__main__':
    main()


Measured memory_bytes: 17196
#include<iostream>
#include<vector>
using namespace std;
int main()
{
    int n, k, q;
    cin >> n >> k >> q;
    string ans;
    vector<int> score(n);
    vector<int> a(q);
    for(int i = 0; i < q; i++){
        cin >> a[i];
        score[a[i]-1]++;
    }
    for(int i = 0; i < n; i++){
        if(score[i]+k-q > 0) ans = "Yes";
        else ans = "No";
        cout << ans << endl;
    }
    return 0;
}

Measured memory_bytes: 1408
#include <bits/stdc++.h>
#define ll long long
using namespace std;
#define maxn 0x3f3f3f3f
#define INF 0x3f3f3f3f3f3f3f3f
const int mm=2e5+100;
ll d[mm];
ll vis[mm];
int main()
{
	ll n,m,i,j,x,k;
    string s;
    cin>>n;
    cin>>s;
    if(s.size()<=n)
    {
    	cout<<s<<endl;
	}
	else
	{
    for(i=0;i<n;i++)
    cout<<s[i];
    cout<<"..."<<endl; 
}}

Measured memory_bytes: 3628
#include <algorithm>
#include <iostream>
#include <math.h>
#include <stdio.h>
#include <string>
#include <sstream>
#include <vector>
#include <set>
using namespace std;

bool canMake(int target,int *materials,int m,int index){
	if(index > m || target < 0) return false;
	if(target == 0) return true;
	return canMake(target,materials,m,index+1) || canMake(target - materials[index],materials,m,index + 1);
}

int main()
{
	int n,m;
	cin >> n;
	int *A = new int[n];
	for(int i = 0; i < n; i++){
		cin>>A[i];
	}
	cin >> m;
	int *B = new int [m];
	for(int i = 0; i < m; i++){
		cin>>B[i];
	}
	for(int i = 0; i < m; i++){
		if(canMake(B[i],A,n,0) == true){
			cout<<"yes"<<endl;
		}else{
			cout<<"no"<<endl;
		}
	}
	return 0;
}





Measured memory_bytes: 3088
#include <iostream>
#include <cstdio>
#include <sstream>
#include <cstring>
#include <algorithm>
#include <vector>
#include <queue>
#include <cctype>
#include <stack>
#include <bitset>
#include <unordered_set>
#include <unordered_map>
#include <map>
#include <set>
#include <cmath>
//#include <bits/stdc++.h>

using namespace std;
typedef long long lolo;
typedef pair<int,int> pii;
typedef pair<double,double> pdd;
typedef unsigned long long ulolo;

const int maxn = (int)3e5 + 5;
const int INF = 0x3f3f3f3f;
const lolo inf = 0x3f3f3f3f3f3f3f3f;
const double eps = 1e-6;
const int MOD = 1000000007;

template<class T>
inline void read(T &x) {
    x = 0; T flag = 1;char c;
    do { c = (char) getchar(); if (c == '-') break; } while (c < '0' || c > '9');
    if (c == '-') { c = '0', flag = -1;}
    do { x = x * 10 + c - '0';c = (char) getchar();} while (c >= '0' && c <= '9');
    x *= flag;
}
template<class T>
inline void out(T x) {
    if (x > 9) out(x / 10);
    x = x % 10;
    putchar('0' + x);
}

int bitsum[62][maxn];
lolo a[maxn];
int main() {
//    freopen("../in.txt", "r", stdin);
    int n;
    read(n);
    for (int i = 1; i <= n; ++i) {
        read(a[i]);
        for (int j = 0; j < 60; ++j) {
            bitsum[j][i] = bitsum[j][i-1];
            if((a[i]>>j)&1) {
                ++bitsum[j][i];
            }
        }
    }
    lolo ans = 0;
    for (int i = 1; i <= n; ++i) {
        for (int j = 0; j < 60; ++j) {
            if ((a[i]>>j)&1) {
                ans = (ans + (1LL<<j)%MOD*(n-i-bitsum[j][n]+bitsum[j][i]))%MOD;
            } else {
                ans = (ans + (1LL<<j)%MOD*(bitsum[j][n]-bitsum[j][i]))%MOD;
            }
        }
    }
    printf("%lld\n", ans);
    return 0;
}


Measured memory_bytes: 73984
package main

import (
	"fmt"
)

func main() {
	var n int
	fmt.Scan(&n)

	for i := 0; i <=25; i++ {
		for j := 0; j < 15; j++ {
			sum := 4 * i + 7 * j
			if sum == n {
				fmt.Println("Yes")
				return
			}
		}
	}
	fmt.Println("No")
}

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

using namespace std;

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

static const double EPS = 1e-8;
static const double PI = 4.0 * atan(1.0);
static const ll INF = 1023456789;

#define REP(i,n)	for(int i=0;i<n;++i)
#define REPR(i,n)	for(int i=n-1;i>=0;--i)
#define FOR(i,s,n)	for(int i=s;i<n;++i)
#define FORR(i,s,n)	for(int i=n-1;i>=s;--i)
#define ALL(c)		(c).begin(),(c).end()
#define CLEAR(v)	memset(v,0,sizeof(v))
#define MP(a,b)		make_pair((a),(b))
#define ABS(a)		((a)>0?(a):-(a))
#define F			first
#define S			second

int main(int argc, char **argv) {
	ll n, a;
	cin >> n;
	ll res = 0;
	REP(i, n) {
		cin >> a;
		res += a-1;
	}
	cout << res << endl;
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <array>
#include <set>
#include <cmath>
#include <string>
#include <sstream>
#include <queue> 
#include <list>
#include <stack>
#include <unordered_map>
#include <algorithm> 
#include <numeric>  
#include <functional>
#include <cassert>
#include <bitset>
#include <cctype>  
#include <iomanip> 
#include <limits>  
#include <regex>
// std::numeric_limits<int>::max(), min()
// std::setprecision(X)
// std::islower(), std::isupper(), std::tolower, std::toupper
// std::accumulate(m.begin(), m.end(), 0LL);
// std::sort(begin(),end()) // 0, 1, 2, 3 ,4 (default, less);
// std::priority_queue<int, vector<int>, less<int>> que; // 4, 3, 2, 1 (defualt, less) : 
// if ( std::regex_match(S, std::regex("(dream|dreamer|erase|eraser)*")) ) std::cout << "YES" << std::endl;
 
#define rep(i, n) for(int i = 0; i < (int)(n);    i++)
#define sz(x) ((int)(x).size())
#define all(x) (x).begin(),(x).end()

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; }
typedef long long ll;

ll gcd ( ll a, ll b ) { if ( b == 0 ) return a; else return gcd ( b, a%b ); }
ll lcm ( ll a, ll b ) { return a * b / gcd(a, b); }


int main (void) {
  std::cin.tie(0);  std::ios::sync_with_stdio(false);
  std::string S; std::cin >> S;

  int a = 0, z = 0;
  for(int i=0; i<sz(S); i++)    if ( S[i] == 'A' ) { a = i; break; }
  for(int i=sz(S)-1; i>=0; i--) if ( S[i] == 'Z' ) { z = i; break; }
  std::cout << z-a+1 << std::endl;
  return 0;
}


Measured memory_bytes: 720
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		String[]S = new String[n];
		for(int i = 0; i < n; i++) {
			S[i] = sc.next();
		}
		sc.close();
		int[][]k = new int[n][26];
		for(int i = 0; i < n; i++) {
			String s = S[i];
			int l = s.length();
			for(int j = 0; j < l; j++) {
				int t = (int)s.charAt(j) - 'a';
				k[i][t]++;
			}
		}
		StringBuilder sb = new StringBuilder();
		for(int i = 0; i < 26; i++) {
			int t = k[0][i];
			for(int j = 1; j < n; j++) {
				t = Math.min(t, k[j][i]);
			}
			for(int j = 0; j < t; j++) {
				char c = (char)(i + 'a');
				sb.append(c);
			}
		}
		System.out.println(sb.toString());
	}
}

Measured memory_bytes: 23892
//بِسْمِ ٱللَّٰهِ ٱلرَّحْمَٰنِ ٱلرَّحِيمِ
#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef double db;

#define endl "\n"

const int MOD = 1000000007;


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

    int a;
	cin >> a ;
	if ( a % 2 == 0){
		cout << a / 2  << endl;
	}
	else 
		cout << (a /2) + 1 << endl;
    return 0;
}


Measured memory_bytes: 3640
#include <iostream>

using namespace std;

int main(){
	int a,b,i,j,n,m,*p,*pl;

	while(1){
		cin >> n;

		if(n != 0){
			cin >> m;
			p = new int[m];
			pl = new int[m];
			
			for(i = 0; i < m; i++){
				p[i] = 0;
				pl[i] = i+1;
			}

			for(i = 0; i < n; i++){
				for(j = 0; j < m; j++){
					cin >> a;
					if(a){
						p[j]++;
					}
				}
			}

			i = 0;
			while(i < m-1){
				if(p[i] < p[i+1]){
					b = p[i+1];
					p[i+1] = p[i];
					p[i] = b;

					b = pl[i+1];
					pl[i+1] = pl[i];
					pl[i] = b;
					
					i = 0;
					continue;
				}
				
				i++;
			}

			for(i = 0; i < m; i++){
				cout << pl[i];
				if(i == m-1){
					cout << endl;
				}else{
					cout << " ";
				}
			}
		}else{
			break;
		}
	}
 
	return 0;
}

Measured memory_bytes: 908