akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
#include<string.h>
#include<vector>
#include<set>
#include<map>
#include<stack>
#include<queue>
#define endl  "\n"
#define ll long long
#define int long long
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL);cin.exceptions(cin.failbit);cout.tie(NULL);
using namespace std;
bool isPrime(int n)
{
    if (n <= 1)
        return false;
    if (n <= 3)
        return true;
    if (n % 2 == 0 || n % 3 == 0)
        return false;
    for (int i = 5; i * i <= n; i += 6)
    {
        if ((n % i == 0) || (n % (i + 2) == 0))
            return false;
    }
    return true;
}
int mod=1e9+7;
ll powermod(ll x, ll y)
{
    ll res = 1;
    x = x % mod;
    while (y > 0)
    {
        if (y & 1)
            res = (res * x) % mod;
        y = y >> 1;
        x = (x * x) % mod;
    }
    return res;
}

ll mulmod(ll a, ll b)
{
    ll res = 0;
    a %= mod;
    while (b)
    {
        if (b & 1)
            res = (res + a) % mod;
        a = (2 * a) % mod;
        b >>= 1;
    }
    return res;
}
ll nCr(ll n, ll r)
{
    if (r == 0)
        return 1;

       ll x= mulmod(n ,nCr(n - 1, r - 1));
    return (x) / r;
}
int32_t main()
{
	int n;
	cin >> n;
	string raj="";
	while(n>0)
	{
		int temp=n%26;
		if(temp==0)
		raj="z"+raj;
		else
		raj=(char)('a'+temp-1)+raj;
		n--;
		n=n/26;
	}
	cout << raj;
}



Measured memory_bytes: 3624
#include <iostream>
using namespace std;
int main(){
    while(1){
    int x,y,s,t,count;
    count = 0;
    cin >> x>>y;
    if(x != 0){
    for(int i =1;i<x+1;i++){
        s = y-i;
        for(int j=i+1;j<x+1;j++){
            t = s-j;
            if( x+1>t&&t>j){
                count++;
            }
        }
    }
    cout << count <<endl;
    }
    else{
        break;
    }
    }
}


Measured memory_bytes: 3072
#include <iostream>
#include <vector>

using namespace std;

int main() {
	int x, i;
	vector<int> vec;
	while (1) {
		cin >> x;
		if (x == 0) {
			break;
		}
		vec.push_back(x);
	}
	for (i = 0; i < vec.size(); i++) {
		cout << "Case " << i + 1 << ": " << vec[i] << endl;
	}
	return 0;
}


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

const int INF = 1 << 29;
using ll = long long int;
#define all(x) (x).begin(),(x).end()
#define rep(i,N) for(ll i = 0; i < (ll)N; ++i)
#define repi(i,a,b) for(ll i = ll(a); i < ll(b); ++i)


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

	int res = 0;
	int j;
	for(int i = 0; i < s.size(); ++i) {
		for (j = i; j < s.size(); ++j) {
			if (s[j] != 'A' && s[j] != 'C' && s[j] != 'G' && s[j] != 'T') break;
		}
		res = max(res, j - i);
	}
	

	cout << res << endl;
}

Measured memory_bytes: 3196
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <iostream>
#include <algorithm>
#include <functional>
#include <vector>
#include <map>
#include <set>
#include <deque>
#include <string>

using namespace std;

typedef long long llint;

void print() { cout << "\n"; }

template <typename...T, typename X>
void print(X& x, T... args) { cout << x << " "; print(args...); }

void input() { /* pass */ }

template <typename...T, typename X>
void input(X& x, T&... args) { cin >> x; input(args...); }

const int N = 3333;
const int MOD = 998244353;

llint dp[N][N];

int main()
{
    int n, s;
    input(n, s);

    vector<int> ns(n + 1, 0);
    for (int i = 1; i <= n; i++) {
        scanf("%d", &ns[i]);
    }

    memset(dp, 0, sizeof(int));
    dp[0][0] = 1;

    llint tot = 0;

    for (int i = 1; i <= n; i++) {
        int cur = ns[i];
        for (int j = 0; j <= s; j++) {
            dp[i][j] = dp[i - 1][j];
            if (j - cur > 0) {
                dp[i][j] += dp[i - 1][j - cur];
            } else if (j - cur == 0) {
                dp[i][j] += i;
            }
            dp[i][j] %= MOD;
            // print(i, j, dp[i][j]);
        }
        // print();
        tot += dp[i][s];
        tot %= MOD;
    }

    print(tot);

    return 0;
}



Measured memory_bytes: 80128
#include <iostream>
#include <algorithm>
#include <math.h>
#include <stdio.h>
#include <string>
#include <set>

using namespace std;

int main()
{
    set<int> myset;
    int N;
    scanf("%d", &N);
    for (int i=0; i < N; i++)
    {
        int a;
        scanf("%d", &a);
        myset.insert(a);
    }
    printf("%d", myset.size());
    return 0;
}


Measured memory_bytes: 256
/*
[dp] A - Frog 1
*/

#include <algorithm>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
using namespace std;
typedef long long int ll;
typedef pair<int, int> pii;
typedef pair<ll, int> pli;

const int MAX_N = 1e5;

int N;
int h[MAX_N];
int dp[MAX_N];

ll solve() {
    dp[0] = 0;
    dp[1] = abs(h[1] - h[0]);
    for (int i = 2; i < N; i++) {
        dp[i] = min(dp[i - 1] + abs(h[i] - h[i - 1]),
                    dp[i - 2] + abs(h[i] - h[i - 2]));
    }

    return dp[N - 1];
}

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

    cout << solve() << endl;

    return 0;
}


Measured memory_bytes: 1024
#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#include <vector>

#define ll long long
#define ull unsigned long long

using namespace std;

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

	ll oneIndex;	//1の場所
	vector<ll> A(N, 0);
	for (int i = 0; i < N; ++i){
		cin >> A[i];
		if (A[i] == 1){
			oneIndex = i;
		}
	}

	const ll INF = 1001001001001;

	ll trialNum = K;
	ll trial = 0;
	ll transMin = INF;
	while (trial < K) {
		//ボックスの左端と右端のindexを計算
		ll leftIndex = oneIndex - K + trial + 1;
		ll rightIndex = oneIndex + trial;

		//ボックスがはみ出していたら次のtrialへ
		if ( (leftIndex < 0) || (rightIndex > N-1) ){
			trial++;
			continue;
		}

		//左側の操作
		ll lcnt = 0;
		while(leftIndex > 0){
			leftIndex = leftIndex - K + 1;
			lcnt++;
		}

		//右側の操作
		ll rcnt = 0;
		while(rightIndex < N-1){
			rightIndex = rightIndex + K - 1;
			rcnt++;
		}

		//最小値の更新
		if ((lcnt + rcnt) < transMin){
			transMin = lcnt + rcnt;
		}

		trial++;
	}

	cout << transMin + 1 << endl;

	return 0;
}


Measured memory_bytes: 1024
package main

import (
	"bufio"
	"fmt"
	"os"
)

var sc = bufio.NewScanner(os.Stdin)

func main() {
	sc.Scan()
	input := sc.Text()

	result := 0
	tmp := 0

	for _, r := range input {
		switch string(r) {
		case "A", "C", "G", "T":
			tmp++
		default:
			if tmp > result {
				result = tmp
			}
			tmp = 0
		}
	}
	if tmp > result {
		result = tmp
	}

	fmt.Print(result)
}

Measured memory_bytes: 640
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author NikuKyabe
 */

#include "bits/stdc++.h"
using namespace std;
#define int long long
#define FOR(i,a,b) for(int i=(int)(a);i<(int)(b);++i)
#define REP(i,n)  FOR(i,0,(n))


class BMinorChange {
public:
	void solve(std::istream& in, std::ostream& out) {
    string s,t;
    in >> s >> t;
    int ans = 0;
    REP(i, s.length()){
      if(s[i] != t[i]){
        ans++;
      }
    }
    out << ans << endl;
	}
};


signed main() {
  ios::sync_with_stdio(false);
  cout.tie(0);
  cout << fixed;
	BMinorChange solver;
	std::istream& in(std::cin);
	std::ostream& out(std::cout);
	solver.solve(in, out);
	return 0;
}


Measured memory_bytes: 3860
//#include <bits/stdc++.h>
#include <string>
#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <deque>
#include <utility>

using namespace std;
using ll=long long;

void solve(){
  int h,w;
  cin >> h >> w;
  vector<string> gred(h);
  for(int i=0;i<h;i++)
    cin >> gred[i];
  for(int i=0;i<h;i++){
    for(int j=0;j<w;j++){
      if(gred[i][j]=='#'){cout << '#';continue;}
      int ct=0;
      for(int k=max(0,i-1);k<=min(h-1,i+1);k++)
        for(int l=max(0,j-1);l<=min(w-1,j+1);l++)
          ct+=gred[k][l]=='#';
      cout << ct;
    }
    cout << endl;
  }
}

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


Measured memory_bytes: 256
#pragma GCC optimize("O3,unroll-loops")
#pragma GCC target("sse,sse2")
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;

template<class T>
using ordered_set = tree <T, null_type ,  less<T> ,  rb_tree_tag ,  tree_order_statistics_node_update>;

template<class T>
using ordered_multiset = tree <T, null_type ,  less_equal<T> ,  rb_tree_tag ,  tree_order_statistics_node_update>;

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

using vi = vector<int>;
using ii = pair<int, int>;
using vii = vector<ii>;
using vvi = vector<vi>;
using vvii = vector<vii>;

#define all(x) x.begin(), x.end()
#define all_r(x) x.rbegin(), x.rend()
#define pb push_back
#define FOR(i, n) for(int i = 0; i < (n); ++i)
#define REP(i, n) for(int i = n; i >= 0; --i)
#define f first
#define s second

int main() {
	ios_base :: sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	int a;
	cin >> a;
	cout << a * (a * (a + 1) + 1)  << '\n';
 	return 0;
}

Measured memory_bytes: 3616
def rain_volume(A, N):
    X = [0]*N
    X[0] = sum(A)
    for i, a in enumerate(A):
        if i%2 != 0:
            X[0] -= 2*a
    for i in range(1, N):
        if i != 0:
            X[i] = 2*A[i-1] - X[i-1]
    return X

if __name__ == '__main__':
    N = int(input())
    A = list(map(int, input().split(' ')))

    print(' '.join(map(str, rain_volume(A, N))))

Measured memory_bytes: 18076
import sys


class Bigint:

    mod = 10**9 + 7

    def __init__(self, n):
        self.n = n % self.mod

    def __str__(self):
        return str(self.n)

    def __add__(self, other):
        ot = type(other)
        if ot == Bigint:
            return Bigint(self.n+other.n)
        elif ot == int:
            return Bigint(self.n+other)
        else:
            raise ValueError("Invalid type")

    def __iadd__(self, other):
        return self.__add__(other)

    def __sub__(self, other):
        ot = type(other)
        if ot == Bigint:
            o = other.n
        elif ot == int:
            o = other
        else:
            raise ValueError("Invalid type")
        #
        return Bigint(self.n - o)

    def __isub__(self, other):
        return self.__sub__(other)

    def __mul__(self, other):
        ot = type(other)
        if ot == Bigint:
            return Bigint(self.n*other.n)
        elif ot == int:
            return Bigint(self.n*other)
        else:
            raise ValueError("Invalid type")

    def __imul__(self, other):
        return self.__mul__(other)

    def __pow__(self, other):
        assert type(other) == int, "power should be integer"
        #
        if other < 0:
            return self ** (other % (self.mod-1))
        ret = Bigint(1)
        now = Bigint(self.n)
        while other > 0:
            if other % 2 == 0:
                pass
            else:
                ret *= now
            other //= 2
            now *= now
        return ret

    def __truediv__(self, other):
        ot = type(other)
        if ot == Bigint:
            o = other
        elif ot == int:
            o = Bigint(other)
        else:
            raise ValueError("Invalid type")

        self *= (o ** (o.mod-2))
        return self

    def __itruediv__(self, other):
        return self.__truediv__(other)


def _s(): return sys.stdin.readline().strip()


def _i(): return int(sys.stdin.readline().strip())


def main():
    k = _i()
    s = _s()
    n = len(s)

    fact = [Bigint(1)] * (n+k)
    for i in range(1, n+k):
        fact[i] = fact[i-1] * i

    ifact = [None] * (n+k)
    ifact[n+k-1] = fact[n+k-1] ** (-1)
    for i in range(n+k-2, -1, -1):
        ifact[i] = ifact[i+1] * (i+1)

    p = [Bigint(1)] * (k+1)
    q = [Bigint(1)] * (k+1)
    for i in range(1, k+1):
        p[i] = p[i-1] * 25
        q[i] = q[i-1] * 26

    nf = ifact[n-1]
    ret = Bigint(0)
    for i in range(k+1):
        k_ = k - i
        n_ = n - 1 + k_
        nck = fact[n_] * ifact[k_] * nf
        ret += (nck * p[k_] * q[i])

    return ret


if __name__ == "__main__":
    print(main())


Measured memory_bytes: 562388
#include <iostream>
using namespace std;
  
int main(){
    int x,y;
    cin >> x >> y;
    int a[x][y], b[y];
    for(int i = 0; i < x; i++){
        for(int j = 0; j < y; j++){
            cin >> a[i][j];
        }
    }
    for(int i = 0; i < y; i++)
        cin >> b[i];
    int ans = 0;
    for(int i = 0; i < x; i++){
        for(int j = 0; j < y; j++){
            ans = ans+a[i][j]*b[j];
        }
        cout << ans << endl;
        ans = 0;
    }
    return 0;
}


Measured memory_bytes: 3104
#include<bits/stdc++.h>
#define MAX 1e9
using namespace std;

typedef long long ll;

int
main(void){

  int n; cin >> n;
  string s, t; cin >> s >> t;

  for(int i = 0; i < n; i++){
    cout << s[i] << t[i];
  }

  cout << endl;

  return 0;
}

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

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

Measured memory_bytes: 3100
import Control.Applicative
import Data.List

main :: IO ()
main = do
    s <- getLine
    putStrLn $ show (solve (sort s))
    
solve :: String -> Int 
solve s | "++++" == s = 4
        | "+++-" == s = 2
        | "++--" == s = 0
        | "+---" == s = -2
        | "----" == s = -4

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

#define REP(i,n) for(ll i=0; i<(ll)(n); i++)
#define FOR(i,n,m) for (ll i=n; i<(ll)(m); i++)
#define pb push_back
#define INF 1000000007LL
#define all(a) (a).begin(),(a).end()
#define chmin(a,b) a=min(a,b)
#define chmax(a,b) a=max(a,b)

typedef long long ll;
typedef pair<int,int> p;

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


#include <cstdio>
#include <vector>
#include <algorithm>

using namespace std;

vector<int> G[1000000];
vector<pair<int, int> > bridge;
vector<int> articulation;
int ord[1000000], low[1000000];
bool vis[1000000];

void dfs(int v, int p, int &k)
{
    vis[v] = true;
    
    ord[v] = k++;
    low[v] = ord[v];
    
    bool isArticulation = false;
    int ct = 0;
    
    for (int i = 0; i < G[v].size(); i++){
        if (!vis[G[v][i]]){
            ct++;
            dfs(G[v][i], v, k);
            low[v] = min(low[v], low[G[v][i]]);
            if (~p && ord[v] <= low[G[v][i]]) isArticulation = true;
            if (ord[v] < low[G[v][i]]) bridge.push_back(make_pair(min(v, G[v][i]), max(v, G[v][i])));
        }
        else if (G[v][i] != p){
            low[v] = min(low[v], ord[G[v][i]]);
        }
    }
    
    if (p == -1 && ct > 1) isArticulation = true;
    if (isArticulation) articulation.push_back(v);
}

int main(){
    ios::sync_with_stdio(false);
    int n, m;
    cin >> n >> m;
    REP(i,m) {
        int x, y;
        cin >> x >> y;
        G[--x].push_back(--y);
        G[y].push_back(x);
    }
    
    int k = 0;
    for (int i = 0; i < n; i++){
        if (!vis[i]) dfs(i, -1, k);
    }
    
    sort(bridge.begin(), bridge.end());
    sort(articulation.begin(), articulation.end());
    
    cout << bridge.size() << endl;
    
    return 0;
}

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

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

    long long ans = N - 1;
    for (long long i = 1; i * i <= N; i++)
    {
        if (N % i == 0)
        {
            ans = min(ans, (i - 1) + (N / i - 1));
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <math.h>

int main(){
	char str[2];
	while(1){
		fgets(str,2,stdin);
		if(str[0]==10){
			break;
		}
		
		if(str[0]>=97 & str[0]<=122){
			str[0]=str[0]-32;
		}
		printf("%c",str[0]);
	}
	printf("\n");
	return 0;
}

Measured memory_bytes: 0
{-# LANGUAGE FlexibleInstances    #-}
{-# LANGUAGE TypeSynonymInstances #-}

import           Control.Applicative
import           Control.DeepSeq
import           Control.Monad
import           Control.Monad.ST
import qualified Data.Array                    as A
import qualified Data.Array.IArray             as IA
import qualified Data.Array.IO                 as AI
import qualified Data.Array.MArray             as MA
import qualified Data.Array.ST                 as STA
import qualified Data.Array.Unboxed            as AU
import           Data.Bits
import qualified Data.ByteString.Char8         as BS
import           Data.Char
import qualified Data.Graph                    as G
import           Data.Int
import qualified Data.IntMap                   as IM
import qualified Data.IntSet                   as IS
import           Data.List
import qualified Data.Map.Strict               as M
import           Data.Maybe
import           Data.Ord
import qualified Data.Sequence                 as SQ
import qualified Data.Set                      as S
import           Data.Time
import qualified Data.Tree                     as T
import qualified Data.Vector                   as V
import qualified Data.Vector.Mutable           as VM
import qualified Data.Vector.Unboxed           as VU
import qualified Data.Vector.Unboxed.Mutable   as VUM

readInt :: IO [Int]
readInt = map (fst . fromJust . BS.readInt) . BS.words <$> BS.getLine

readInts :: Int -> IO [[Int]]
readInts n = replicateM n readInt

readInteger :: IO [Integer]
readInteger = map (fst . fromJust . BS.readInteger) . BS.words <$> BS.getLine

readIntegers :: Int -> IO [[Integer]]
readIntegers n = replicateM n readInteger

readString :: IO [String]
readString = map BS.unpack . BS.words <$> BS.getLine

readStrings :: Int -> IO [[String]]
readStrings n = replicateM n <$> readString

toPair :: [a] -> (a, a)
toPair [x, y] = (x, y)

count :: Eq a => a -> [a] -> Int
count a as = length $ filter (== a) as

put :: Show a => a -> IO ()
put = putStr . show

putList :: Show a => [a] -> IO ()
putList [n     ] = put n
putList (n : ns) = do
  put n
  putStr " "
  putList ns

putStrList :: [String] -> IO ()
putStrList [n     ] = putStr n
putStrList (n : ns) = do
  putStr n
  putStr " "
  putStrList ns

yesNoUpper b | b         = putStrLn "YES"
             | otherwise = putStrLn "NO"

yesNo b | b         = putStrLn "Yes"
        | otherwise = putStrLn "No"

main = do
  [n]<-readInt
  print $ sum [1..n]

Measured memory_bytes: 380
import java.util.Scanner;


public class Main{
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int i = 1;
		while(i == i){
			int X = sc.nextInt();
			if(X == 0)
				break;
			System.out.println("Case " + i +": "+ X);
			i++;
		}
		sc.close();
	}
}

Measured memory_bytes: 32948
#include <iostream>
#include <math.h>
#include <algorithm>
#include <string>
using namespace std;
int main(){
  int A,B,C,K;
  cin>>A>>B>>C>>K;
  int judge=0;
  while(judge<K){
    if(B<=A) B*=2;
    else if(C<=B) C*=2;
    judge++;
  }
  if(C>B&&B>A) cout<<"Yes"<<endl;
  else cout<<"No"<<endl;
  
  return 0;
}

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

int INF = 900000000;
using pii = std::pair<int, int>;
std::vector<std::vector<pii>> g;
std::vector<bool> visited; 
std::vector<int> c; 
std::priority_queue<pii, std::vector<pii>, std::greater<pii>> q;

int n, p, x, y;
int discard;


int main() {
    std::cin >> n;
    visited.assign(n, false);
    g.assign(n, std::vector<pii>(0));
    c.assign(n, INF);
    for (int i = 0; i < n; i++) {
        std::cin >> discard >> p;
        for (int k = 0; k < p; k++) {
            std::cin >> x >> y;
            g[i].push_back(std::make_pair(y, x));
        }
    }
    q.push(std::make_pair(0, 0));
    c[0] = 0;
    while (!q.empty()) {
        auto e = q.top();
        q.pop();
        for (int j = 0; j < g[e.second].size(); j++) {
            if (c[g[e.second][j].second] < g[e.second][j].first) {
                continue;
            }
            if (c[e.second]+g[e.second][j].first < c[g[e.second][j].second]) {
                c[g[e.second][j].second] = c[e.second]+g[e.second][j].first;
                q.push(g[e.second][j]);
            }
        }
    }
    for (int i = 0; i < n; i++) {
        std::cout << i << " " << c[i] << std::endl;
    }
}



Measured memory_bytes: 3152
N = int(input())
h = list(map(int, input().split()))

minimumCostToReach = [0 for i in range(N)]

minimumCostToReach[0] = 0
for i in range(1, N):
  previous1 = minimumCostToReach[i - 1] + abs(h[i] - h[i - 1])
  previous2 = minimumCostToReach[i - 2] + abs(h[i] - h[i - 2]) if i >= 2 else 1000000000

  minimumCostToReach[i] = min(previous1, previous2)

print(minimumCostToReach[N - 1])


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

using namespace std;

int main(){

	long long int N,M;
	cin >> N >> M;

	long long int H[N+1];
	long long int R[N+1];
	for(int i=1;i<=N;i++){
		cin >> H[i];
		R[i]=H[i];
	}
	long long int A[M+1],B[M+1];
	for(int i=1;i<=M;i++){
		cin >> A[i] >> B[i];
	}
	for(int i=1;i<=M;i++){

	if(H[A[i]]>H[B[i]]){
		R[B[i]]=H[A[i]];
	}

	else if(H[A[i]]<H[B[i]]){
		R[A[i]]=H[B[i]];
	}
	else{
		R[A[i]]=0;
		R[B[i]]=0;
	}
	}

	long long int counter;
	counter=0;
	for(int i=1;i<=N;i++){
		if(R[i]==H[i]){
			counter+=1;
		}
	}
	cout << counter;
	return 0;
	}



Measured memory_bytes: 6728
#include <bits/stdc++.h>
using namespace std;
#define rep(i,a,n) for (int i=a;i<n;i++)
#define per(i,a,n) for (int i=n-1;i>=a;i--)
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define fi first
#define se second
#define SZ(x) ((int)(x).size())
typedef vector<int> VI;
typedef long long ll;
typedef pair<int,int> PII;
typedef double db;
mt19937 mrand(random_device{}()); 
const ll mod=1000000007;
int rnd(int x) { return mrand() % x;}
ll powmod(ll a,ll b) {ll res=1;a%=mod; assert(b>=0); for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}
ll gcd(ll a,ll b) { return b?gcd(b,a%b):a;}
int main() {
	ll a,b,c;
	cin>>a>>b>>c;
		cout<<(ll)((a/(b+c))*b)+min((a%(b+c)),b);
}


Measured memory_bytes: 256
#include <iostream>
#include <complex>
#include <vector>
#include <string>
#include <algorithm>
#include <cstdio>
#include <numeric>
#include <cstring>
#include <ctime>
#include <cstdlib>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <list>
#include <cmath>
#include <bitset>
#include <cassert>
#include <queue>
#include <stack>
#include <deque>
#include <random>
#include <iomanip>
#define rep(i,n) for(int i=0;i<n;i++)
using namespace std;
typedef long long int ll;
typedef long double ld;
typedef pair<ll,ll> P;
typedef pair<P,P> PP;
const ll MOD=998244353;
const ll MAX_N=500010;
const ll INF=4999999996000000001;



int main(){
    int n;
    cin>>n;
    int M=0;
    map<string, int> num;
    for(int i=0;i<n;i++){
        string s;
        cin>>s;
        num[s]++;
        if(M<num[s]){
            M=num[s];
        }
    }
    for(auto mp:num){
        if(mp.second==M){
            cout<<mp.first<<endl;
        }
    }
}

Measured memory_bytes: 18728
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
using namespace __gnu_pbds; 
#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>
using namespace std;
#define ll long long int
#define ld long double
#define ff first
#define ss second  
#define endl '\n'
#define pb push_back
#define t_case ll tt; cin>>tt; while (tt--)
#define all(v) v.begin(),v.end()
#define ub(a,x) upper_bound(all(a),x)-a.begin()
#define lb(a,x) lower_bound(all(a),x)-a.begin()
#define fr(a,b,c) for (ll a=b;a<c;a++)
#define take(xx,n) for (int i=0;i<n;i++) cin>>xx[i];
#define take1(xx,n) for (int i=1;i<=n;i++) cin>>xx[i];
#define fastio ios_base::sync_with_stdio(false); cin.tie(NULL);
const auto inf=LLONG_MAX; 
vector<int> adj[200002];
int vis[200003];
ll dfs(int vx ,int pr){
	int cnt=0; vis[vx]=1;
	for(auto i: adj[vx]){
		if (!vis[i]) cnt+=dfs(i,vx);
	}
	return cnt+1;
} 
int main() 
{
	fastio
	//t_case
	{
		ll sum=0,ans=0,n,m=0,mx=-inf,mn=inf,p,f ;cin>> n >> m;
		map<pair<int,int>,int> mp;
		fr(i,0,m) {
			int x,y; cin>>x>>y;
			if (x>y) swap(x,y); 
			mp[{x,y}]++;
			if (mp[{x,y}]==1){
				adj[x].pb(y),
				adj[y].pb(x);
			}
		}
		fr(i,1,n+1) {
			if (!vis[i]){
			 	ans=max(ans,dfs(i,0));
			}
		}
		cout<<ans;
		cout<<endl;
	}
	return 0;
}

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

int main(){
  int N; 
  cin >> N;
  
  vector<int> d(N);
  
  for(int i=0; i<N; i++){
    cin >> d.at(i);
  }
  
  sort(d.begin(), d.end());

  cout << d.at(N/2)-d.at(N/2-1) << endl;
}

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

int main(){
  int n;
  cin>>n;
  
  vector<int> arr;
  arr.push_back(0);
  int x;
  
  for(int i =0;i<n;i++){
    cin>>x;
    arr.push_back(x);
  }
  arr.push_back(0);
  
  int sum = 0;
  for(int i =1;i<=n;i++){
    sum = sum + abs(arr[i]- arr[i-1]);
  }
  
  for(int i =1;i<=n;i++)
  {
    cout<< sum - abs(arr[i] - arr[i-1]) - abs(arr[i] - arr[i+1]) + abs(arr[i-1] - arr[i+1]) + abs(arr[n])<<"\n";
  }
  return 0;
}

Measured memory_bytes: 1784
#include <iostream>
#include <set>
#include <utility>
#include <stdlib.h>
#define llint long long

using namespace std;
typedef pair<llint, llint> P;

llint N;
llint L[100005], R[100005];
set<P> lset, rset;

llint solve()
{
	llint ret = 0, pos = 0;
	for(int i = 0; i < N; i++){
		set<P>::iterator it;
		if(i % 2 == 0) it = lset.end(), it--;
		else it = rset.begin();
		llint id = it->second;
		//cout << L[id] << " " << R[id] << " " << pos << endl;
		if(pos < L[id]){
			ret += L[id] - pos;
			pos = L[id];
		}
		else if(pos > R[id]){
			ret += pos - R[id];
			pos = R[id];
		}
		lset.erase(make_pair(L[id], id));
		rset.erase(make_pair(R[id], id));
		//cout << pos << endl;
	}
	ret += abs(pos);
	return ret;
}

int main(void)
{
	cin >> N;
	for(int i = 0; i < N; i++) cin >> L[i] >> R[i];
	
	llint ans = 0;
	for(int i = 0; i < N; i++){
		lset.insert(make_pair(L[i], i));
		rset.insert(make_pair(R[i], i));
	}
	ans = solve();
	
	//cout << ans << endl;
	
	for(int i = 0; i < N; i++){
		llint tmp = L[i];
		L[i] = R[i];
		R[i] = tmp;
	}
	for(int i = 0; i < N; i++){
		L[i] *= -1, R[i] *= -1;
	}
	
	lset.clear();
	rset.clear();
	for(int i = 0; i < N; i++){
		lset.insert(make_pair(L[i], i));
		rset.insert(make_pair(R[i], i));
	}
	ans = max(ans, solve());
	
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 16384
#include<iostream>
using namespace std;
 
bool is_palindrome(string s){
    string t(s.rbegin(),s.rend());
    return s == t;
}
 
int main(){
    string s;
    cin>>s;
    int n=s.size();
    if(is_palindrome(s) && is_palindrome(s.substr(0,(n-1)/2)) && is_palindrome(s.substr((n+1)/2))){
        cout<<"Yes"<<endl;
    }
    else cout<<"No"<<endl;
}

Measured memory_bytes: 384
#include <iostream>
#include <utility>
#include <algorithm>
using namespace std;
int main(){
	pair<int,int> p[200010];
	int i,n,a,b;
	cin >> n;
	for(i=0;i<n;i++){
		cin >> a;
		p[i] = make_pair(a,0);
	}
	for(i=0;i<n;i++){
		cin >> b;
		p[i+n] = make_pair(b,1);
	}
	
	sort(p,p+2*n);
	long long ans = 1;
	int s=0,t=0;
	for(i=0;i<2*n;i++){
		if(p[i].second==0){
			if(t==0){
				s++;
			}else{
				ans *= t;
				ans = ans%1000000007;
				t--;
			}
		}else{
			if(s==0){
				t++;
			}else{
				ans *= s;
				ans = ans%1000000007;
				s--;
			}
		}
	}
	cout << ans << endl;
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(x) x.begin(),x.end()
const int INF = 100100100;
typedef long long ll;
 
int main() {
   int n,k,h;
   cin >> n >> k;
   int ans=0;
   rep(i,n){
      cin >> h;
      if(h>=k)
      ans++;
   }
   cout << ans << endl;
}

Measured memory_bytes: 256
#include <algorithm>
#include <cassert>
#include <climits>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <list>
#include <map>
#include <memory>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
//#include <regex>

/* g++ -g -std=c++0x */
/* g++ -g -std=c++11 */

using namespace std;

// freopen("input.txt", "rt", stdin);
// freopen("output.txt", "wt", stdout);

#define ALL(c)          (c).begin(), (c).end()
#define ALLR(c)         (c).rbegin(), (c).rend()
#define FOR(i,a,b)      for (int i=(a); i < (b); ++i)
#define FORR(i,a,b)     for (int i=(a); i > (b); --i)
#define FOR_ALL(i,c)    for (__typeof((c).begin()) i=(c).begin();   \
                             i != (c).end(); ++i)
#define FOR_ALLR(i,c)   for (__typeof((c).rbegin()) i=(c).rbegin(); \
                             i != (c).rend(); ++i)
#define SZ(array)       (sizeof(array)/sizeof(array[0]))
#define lc(x)           (x<<1)     /* 2*x */
#define rc(x)           (x<<1 | 1) /* 2*x+1 */
#define lowbit(x)       (x & (-x)) /* 0b10100 -> 0b100 */

typedef long long       LL;
typedef map<int,int>    MII;
typedef pair<int,int>   PII;
typedef set<int>        SI;
typedef vector<bool>    VB;
typedef vector<double>  VD;
typedef vector<int>     VI;
typedef vector<string>  VS;

/* check if a key is in container C */
template <class C>
inline bool in_(const typename C::key_type& k, const C& A)
{ return A.find(k) != A.end(); }
inline bool in_(const string& s, const string& S)
{ return S.find(s) != string::npos; }

string o, e;

int main()
{
/* #ifndef ONLINE_JUDGE */
/*     freopen("foo", "rt", stdin); */
/* #endif */
    std::ios::sync_with_stdio(false);

    while (cin >> o >> e) {
        int n = max(o.size(), e.size());
        FOR(i,0,n) {
            cout << o[i];
            if (i < min (o.size(), e.size()))
                cout << e[i];
        }
        cout << endl;
    }
}


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

ll nCr(ll n, ll r){
    ll a = 1;
    ll b = 1;
    rep(i, r){
        a *= n-i;
        b *= i+1;
    }
    return a/b;
}

int main()
{
    ll N, P;
    cin >> N >> P;
    vector<ll> A(N);
    ll even = 0;
    ll odd = 0;
    rep(i, N){
        cin >> A[i];
        if (A[i] % 2 == 0){
            even++;
        }else{
            odd++;
        }
    }

    if(even == N){
        if (P == 0){
            ll ans = 1;
            rep(i, N){
                ans *= 2;
            }
            cout << ans << endl;
        }else{
            puts("0");
        }
        return 0;
    }

    ll ans = 1;
    rep(i, N-1){
        ans *= 2;
    }
    cout << ans << endl;


    return 0;
}


Measured memory_bytes: 3608
import sys
N = int(input())
data = []
for _ in range(N):
    data.append(list(map(int,input().split())))
CX = -1
CY = -1
H = -1
for cx in range(101):
    for cy in range(101):
        estimated_h = -1
        for d in data:
            x,y,h = d
            if h <= 0:
                continue

            if estimated_h < 0 :
                estimated_h = abs(x-cx) + abs(y-cy) + h
            if estimated_h != abs(x-cx) + abs(y-cy) + h:
                break
        else:
            CX = cx
            CY = cy
            H = estimated_h
            for d in data:
                x, y, h = d
                if max(H - abs(x-cx) - abs(y-cy), 0) != h:
                    H = -1
                    CX = -1
                    CY = -1
                    break
            else:
                print(cx,cy,estimated_h)
                sys.exit(0)

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

int main() {

  int n;
  cin >> n;

  vector<int> w(n);
  for (int i = 0; i < n; i++) { cin >> w.at(i); }

  int min = 9999999999;

  for (int t = 0; t < n; t++) {

    int s1 = 0;
    int s2 = 0;
    for (int i1 = 0; i1 <= t; i1++) { s1 += w.at(i1);}
    for (int i2 = t+1; i2 < n; i2++) { s2 += w.at(i2);}
	
    int diff = s1-s2;
    if (diff < 0) { diff = diff*(-1); }
    if (diff < min) { min = diff; }

  }

  cout << min << endl;
}


Measured memory_bytes: 256
# include <iostream>
# include <cmath>
# include <algorithm>
# include <stdio.h>
# include <cstdint>
# include <cstring>
# include <string>
# include <cstdlib>
# include <vector>
# include <bitset>
# include <map>
# include <queue>
# include <ctime>
# include <stack>
# include <set>
# include <list>
# include <random>
# include <deque>
# include <functional>
# include <iomanip>
# include <sstream>
# include <fstream>
# include <complex>
# include <numeric>
# include <immintrin.h>
# include <cassert>
# include <array>
# include <tuple>
# include <unordered_set>
# include <unordered_map>
using namespace std;

long long n, ans;
long long a[100005];
long long g[100005], g2[100005];

inline long long gcd(long long x, long long y) {
    while (x > 0 && y > 0) {
        if (x > y) x %= y;
        else y %= x;
    }
    return x + y;
}



int main(int argc, const char * argv[]) {
#ifdef __APPLE__
    freopen("/Users/danya.smelskiy/Documents/Danya/Resources/input.txt","r",stdin);
#endif
    ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
    cin >> n;
    for (int i = 1; i <= n; ++i) {
        cin >> a[i];
        g[i] = gcd(g[i - 1], a[i]);
    }
    for (int i = n; i > 0; --i) {
        g2[i] = gcd(g2[i + 1], a[i]);
        ans = max(ans, gcd(g[i - 1], g2[i + 1]));
    }
    cout << ans << '\n';
}



Measured memory_bytes: 2560
#include <bits/stdc++.h>
using namespace std;
  
#define IOS ios_base::sync_with_stdio(false);cin.tie(NULL); 
  
#define ff first
#define ss second
#define pb push_back
#define pf push_front
#define mp make_pair
#define pu push
#define pp pop_back
#define in insert
#define ld long double


#define TRACE
#ifdef TRACE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
  cerr << name << " : " << arg1 << std::endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
  const char* comma = strchr(names + 1, ',');cerr.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
}
#else
#define trace(...) 1
#endif
template<class T> ostream& operator<<(ostream &os, vector<T> V) {os << "[ "; for(auto v : V) os << v << " "; return os << "]";}
template<class L, class R> ostream& operator<<(ostream &os, pair<L,R> P) {return os << "(" << P.first << "," << P.second << ")";}
  
typedef long long int ll;
  
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vi> vvi;
typedef vector<vl> vvl;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<pii> vpii;
typedef vector<pll> vpll;
const ll mod =998244353;
const ll maxn=1000001;
const ll LOGMAXN=30;
ll power(ll x, ll n) {
      ll res = 1;
      for (; n > 0; n >>= 1) {
        if (n & 1) res = (res * x) % mod;
        x = (x * x) % mod;
      }
      return res;
}

int main()
{
   
  IOS
  ll n;
  cin>>n;
  for(ll i=1;i<=50000;i++)
  {
    if(((i*108)/100)==n)
    {
      cout<<i;
      return 0;
    }
  }
  cout<<":(";
  

}
    

  
  
	

 

Measured memory_bytes: 256
/*
 * 2016-ho-t1.cpp
 *
 *  Created on: 2017/02/09
 *      Author: joi
 */

#include<cstdio>
int main(void){
	long long dp[1001];
	long long dpb[1001];
	long long dpmin[1001];
	long long dpmax[1000];
long long n;
long long m;
long long min;
	long long a[20000];
	long long k=0;
	long long x=0;
	long long y=0;
	scanf("%lld %lld %lld",&n,&m,&k);
	for(int i=0;i<n;i++){
		scanf("%lld",&a[i]);
	}
for(int i=0;i<m;i++){
	dp[i]=0;
	dpb[i]=0;
	dpmax[i]=0;
	dpmin[i]=0;
}
for(int i=0;i<n;i++){
	x=a[i];
if(i<m-1)y=i;
else y=m-1;
	for(int j=y;j>0;j--){
		dpb[j]=dp[j];
	if(dpmax[j-1]<x){
		dp[j]=((x-dpmin[j-1])*(j+1))-((dpmax[j-1]-dpmin[j-1])*(j))+dp[j-1];
		dpmax[j]=x;
		dpmin[j]=dpmin[j-1];
	}
	else if(dpmin[j-1]>x){
		dp[j]=((dpmax[j-1]-x)*(j+1))-((dpmax[j-1]-dpmin[j-1])*(j))+dp[j-1];
		dpmax[j]=dpmax[j-1];
		dpmin[j]=x;
	}
	else{
		dp[j]=dpmax[j-1]-dpmin[j-1]+dp[j-1];
		dpmax[j]=dpmax[j-1];
		dpmin[j]=dpmin[j-1];
}
	}
	if(i==0){
		dp[i]=k;
		dpmax[i]=x;
		dpmin[i]=x;
	}
	else{
	dpb[0]=dp[0];
	min=100000000000000000;
	for(int j=0;j<m&&j<i;j++){
		if(min>dpb[j]){
min=dpb[j];
		}
	}
		dp[0]=min+k;
		dpmax[0]=x;
		dpmin[0]=x;
	}
}
min=100000000000000000;
for(int i=0;i<m&&i<n;i++){
	if(min>dp[i])min=dp[i];
}
printf("%lld\n",min);
	return 0;
}

Measured memory_bytes: 2940
#走らせながら入力例を参考に足りないアルゴリズムを修正していく感じ

n,m,X,Y = map(int,input().split())
x=list(map(int,input().split()))
x.append(X)
y=list(map(int,input().split()))
y.append(Y)
if X < Y:
    if max(x) < min(y):
        print('No War')
    else:
        print('War')
else:
    print('War')


Measured memory_bytes: 2940
// This file is a "Hello, world!" in C++ language by GCC for wandbox.
#include <iostream>
#include <cstdlib>

using namespace std;

int main() {
    int input;
    int answer;
    cin >> input;
    answer=input*input*input;
    cout << answer<<endl;
   
}

// GCC reference:
//   https://gcc.gnu.org/

// C++ language references:
//   https://msdn.microsoft.com/library/3bstk3k5.aspx
//   http://www.cplusplus.com/
//   https://isocpp.org/
//   http://www.open-std.org/jtc1/sc22/wg21/

// Boost libraries references:
//   http://www.boost.org/doc/



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

int main(){
    int N, L;
    cin >> N >> L;
    string S[100];
    for (int i = 0; i < N; ++i) cin >> S[i];

    sort(S, S + N);

    for (int i = 0; i < N; ++i){
        cout << S[i];
    }

}

Measured memory_bytes: 256
package main

import (
	"bufio"
	"fmt"
	"io"
	"log"
	"os"
	"strconv"
)

func main() {
	s := readBytes()
	q := readInt()

	b := make([]byte, len(s)+2*q+10)
	start := q + 5
	end := start + len(s) - 1
	for i := range s {
		b[start+i] = s[i]
	}

	flipCnt := 0
	for i := 0; i < q; i++ {
		if readInt() == 1 {
			flipCnt++
			continue
		}

		f, c := readInt(), readBytes()[0]
		if (f == 1 && flipCnt%2 == 0) || (f == 2 && flipCnt%2 == 1) {
			start--
			b[start] = c
		} else {
			end++
			b[end] = c
		}
	}

	if flipCnt%2 == 1 {
		j := end
		for i := start; i <= (start+end)/2; i++ {
			b[i], b[j] = b[j], b[i]
			j--
		}
	}
	fmt.Println(string(b[start : end+1]))
}

var (
	readString func() string
	readBytes  func() []byte
)

func init() {
	log.SetFlags(log.Lshortfile)
	readString, readBytes = newReadString(os.Stdin)
}

func newReadString(ior io.Reader) (func() string, func() []byte) {
	r := bufio.NewScanner(ior)
	r.Buffer(make([]byte, 1024), int(1e+11))
	r.Split(bufio.ScanWords)

	f1 := func() string {
		if !r.Scan() {
			panic("Scan failed")
		}
		return r.Text()
	}
	f2 := func() []byte {
		if !r.Scan() {
			panic("Scan failed")
		}
		return r.Bytes()
	}
	return f1, f2
}

func readInt64() int64 {
	i, err := strconv.ParseInt(readString(), 10, 64)
	if err != nil {
		panic(err.Error())
	}
	return i
}

func readInt() int {
	return int(readInt64())
}

func readFloat64() float64 {
	f, err := strconv.ParseFloat(readString(), 64)
	if err != nil {
		panic(err.Error())
	}
	return f
}

func min(a, b int) int {
	if a < b {
		return a
	}
	return b
}

func max(a, b int) int {
	if a > b {
		return a
	}
	return b
}

func abs(a int) int {
	if a < 0 {
		return -a
	}
	return a
}

func sum(a []int) int {
	var ret int
	for i := range a {
		ret += a[i]
	}
	return ret
}

func sumFloat64(a []float64) float64 {
	var ret float64
	for i := range a {
		ret += a[i]
	}
	return ret
}

func gcd(m, n int) int {
	for m%n != 0 {
		m, n = n, m%n
	}
	return n
}

func lcm(m, n int) int {
	return m / gcd(m, n) * n
}


Measured memory_bytes: 2560
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ABC_Training
{

    public class Program
    {
        static void Main(string[] args)
        {
            var n = int.Parse(Console.ReadLine());
            var a = Console.ReadLine().Split(' ').Select(int.Parse).ToArray();
            int[] b = new int[n];
            for(int i = 0; i < n; i++)
            {
                b[a[i] - 1] = i + 1;
            }
            Console.WriteLine(string.Join(" ", b));
        }
    }
}


Measured memory_bytes: 29788
#include<bits/stdc++.h>
using namespace std;
#define MOD 1000000007
#define BIG 1000000010
#define repi(i,x,n) for(int i=x;i<n;i++)
#define rep(i,n) repi(i,0,n)
#define repn(i,n) for(int i=n;i>=0;i--)
typedef long long int ll;

int s[50];
int now=0;
int ans=0;
int n,k;
deque<int> v;
int a;

void solve(int b){
  deque<int> d;
  d=v;
  rep(i,b){
    s[i]=d[i];
  }
  sort(s,s+b);
  
  rep(i,b){
    if(s[i]<0 && (i+1)<=k-b) s[i]=0;
    now+=s[i];
  }
  ans=max(ans,now);
  now=0;
  rep(j,b){
    int c=d.back();
    d.pop_back();
    d.push_front(c);
   
    rep(i,b){
      s[i]=d[i];
    }
    sort(s,s+b);
    rep(i,b){
      if(s[i]<0 && (i+1)<=k-b) s[i]=0;
      now+=s[i];
    }
    ans=max(ans,now);
    now=0;
  }
  
}

int main(){
 
  cin>>n>>k;

 
 
  rep(i,n){
    cin>>a;
    v.push_back(a);
  }
  repi(i,1,min(k+1,n+1)){
    solve(i);
  }
  
  cout<<ans<<endl;

  return 0;
}







Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
using P = pair<int,int>;
/* ちゃんと考えてわかって実装 */

int main(void){
    int k, n;
    cin >> k >> n;
    vector<int> a(n);
    for(int i=0; i<n; i++){
        cin >> a[i];
    }
    int max_dist = 0;
    for(int i=1; i<n; i++){
        max_dist = max(max_dist, a[i] - a[i-1]);
    }
    max_dist = max(max_dist, k-a[n-1]+a[0]);

    cout << k - max_dist << endl;
    return 0;
}

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

using namespace std;

typedef long long ll;
typedef long double Double;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)

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

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

void solve(long long n, std::vector<std::string> S) {
    int cnt[128] = {};
    for(int i = 0 ; i < 128 ; i++) cnt[i] = 11451419;
    for (auto s : S) {
        int sub[128] = {};
        for (auto c : s) {
            sub[c]++;
        }
        for (int i = 0; i < 128; i++) {
            cnt[i] = min(cnt[i], sub[i]);
        }
    }
    for (int i = 0; i < 128; i++) {
        for (int j = 0; j < cnt[i]; j++) {
            cout << (char) i;
        }
    }
    cout << endl;
}

int main() {
    long long n;
    scanf("%lld", &n);
    std::vector<std::string> S(n);
    for (int i = 0; i < n; i++) {
        std::cin >> S[i];
    }
    solve(n, std::move(S));
    return 0;
}


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

using namespace std;

int main() {
    ios::sync_with_stdio(0);
    cin.tie(0);
    int n;
    cin >> n;
    string s;
    cin >> s;
    string t = "RGB";
    int K = (int) t.size();
    vector<int> xs(K * n);
    for (int i = 0; i < K * n; ++i) {
        for (int j = 0; j < K; ++j) {
            if (s[i] == t[j]) {
                xs[i] = j;
            }
        }
    }
    vector<vector<int>> colors(K);
    for (int i = 0; i < K * n; ++i) {
        colors[xs[i]].push_back(i);
    }
    vector<int> ms(n), Ms(n);
    vector<int> order(K * n, 0);
    for (int i = 0; i < n; ++i) {
        vector<int> run(K);
        for (int j = 0; j < K; ++j) {
            run[j] = colors[j][i];
        }
        sort(run.begin(), run.end());
        for (int j = 0; j < K; ++j) {
            order[run[j]] = j;
        }
    }
    long long prime = 998244353;
    vector<int> counters(K + 1, 0);
    counters[0] = n;
    long long answer = 1;
    for (int i = 0; i < K * n; ++i) {
        answer = (answer * (counters[order[i]] - counters[order[i]+1]++)) % prime;
    }
    cout << answer << endl;
    return 0;
}


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

vector<int> link;
vector<int> size;
stack<pair<int, int>> edges;
vector<ll> ans;

int find(int x)
{
	while (x != link[x]) x = link[x];
	return x;
}

ll unite(int a, int b)
{
	a = find(a);
	b = find(b);
	if (a != b)
	{
		ll pairs = size[a] * size[b];
		if (size[a] < size[b]) swap(a, b);
		size[a] += size[b];
		link[b] = a;
		return pairs;
	}
	return 0;
}

ll calc_pairs()
{
	vector<int> groups;
	for (int i = 0; i < link.size(); ++i)
		if (i == link[i]) groups.push_back(size[i]);
		
	ll total = 0;
	for (int i = 0; i < groups.size() - 1; ++i)
	{
		ll sum = accumulate(groups.begin()+i+1, groups.end(), 0);
		total += groups[i] * sum;
	}
	return total;
}

int main()
{
	ll N, M;
	cin >> N >> M;
	
	link.resize(N);
	for (int i = 0; i < N; ++i)
		link[i] = i;
	size.assign(N, 1);
	
	for (int i = 0; i < M; ++i)
	{
		int a, b;
		cin >> a >> b; a--; b--;
		edges.push({a, b});
	}
	
	ll total = N*(N-1)/2;
	ans.push_back(total);
	while (edges.size() != 1)
	{
		int a, b;
		tie(a, b) = edges.top();
		edges.pop();
		total -= unite(a, b);
		ans.insert(ans.begin(), total);
	}
	
	for (ll i : ans)
		cout << i << '\n';
}


Measured memory_bytes: 3760
from itertools import combinations

N = int(input())
xys = [
    [tuple(map(int, input().split())) for _ in range(int(input()))] for A in range(N)
]

# 大きい順に
for ans in range(N, -1, -1):
    # 組み合わせ
    for c in combinations(range(1, 1 + N), ans):
        honest = [False] * N
        for ci in c:
            honest[ci - 1] = True

        for i, xy in zip(range(1, 1 + N), xys):
            for x, y in xy:
                if y:
                    if honest[i - 1] and not honest[x - 1]:
                        break
                else:
                    if honest[i - 1] and honest[x - 1]:
                        break
            else:
                continue
            break
        else:
            break
        continue
    else:
        continue
    break

print(ans)



Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
#define ff first
#define ss second
#define pb push_back
#define mp make_pair
typedef long long LL;
typedef unsigned long long uLL;
typedef pair<int,int> pii;

const int inf=0x3f3f3f3f;

const int maxn=2111;

bitset<2111> val[4111],up[2111];

int fa[2111][2111],lca[2111][2111],id[2111][2111],n,m,tot;
namespace tree
{
	vector<int> g[2111];
	void addedge(int u,int v)
	{
		g[u].pb(v);
		g[v].pb(u);
	}
	void dfs(int x,int f,int nf,int idv)
	{
		if(idv)
		{
			val[idv].set(x);
			fa[nf][x]=f;
		}
		for(int i=0;i<(int)g[x].size();i++)if(g[x][i]!=f)
		{
			if(!idv)
			{
				id[x][g[x][i]]=++tot;
				dfs(g[x][i],x,nf,tot);
			}
			else dfs(g[x][i],x,nf,idv);
		}
	}
	
	vector<int> vs[2111];
	void rdfs(int x,int f)
	{
		if(f)up[x]=up[f];
		up[x].set(x);
		for(int i=0;i<(int)g[x].size();i++)if(g[x][i]!=f)
		{
			rdfs(g[x][i],x);
			for(auto v:vs[g[x][i]])vs[x].pb(v);
		}
		vs[x].pb(x);
		for(auto v:vs[x])lca[x][v]=lca[v][x]=x;
		for(auto v1:g[x])for(auto v2:g[x])if(v1!=f&&v2!=f&&v1<v2)
		{
			for(auto t1:vs[v1])for(auto t2:vs[v2])
				lca[t1][t2]=lca[t2][t1]=x;
		}
	}
	
	void prework()
	{
		tot=0;
		for(int i=1;i<=n;i++)dfs(i,0,i,0);
		rdfs(1,0);
	}
}

bitset<2111> es[2111];
int eu[2111],ev[2111],q[2111*2111],fr,rr,ans;

void addedge(int u,int v)
{
	if(es[u].test(v))return;
//	printf("addedge %d %d\n",u,v);
	ans++;
	es[u].set(v);es[v].set(u);
	q[rr++]=u;q[rr++]=v;
}

void debug(bitset<2111>cur,string comment="")
{
	if(comment!="")comment=comment+" ";
	cout<<comment;
	for(int i=cur._Find_first();i<=n;i=cur._Find_next(i))printf("%d ",i);puts("");
}

void check_edge(int u,int v)
{
//	printf("check_edge %d %d\n",u,v);
	
	bitset<2111>cur=val[id[fa[u][v]][v]]|val[id[fa[v][u]][u]]|(up[u]^up[v]),tmp;
	cur.set(lca[u][v]);
//	debug(cur,"cur");
	
	tmp=cur&es[u]&(~es[v]);
	for(int i=tmp._Find_first();i<=n;i=tmp._Find_next(i))if(i!=u&&i!=v)
		addedge(v,i);
	cur=cur&es[v]&(~es[u]);
	for(int i=cur._Find_first();i<=n;i=cur._Find_next(i))if(i!=u&&i!=v)
		addedge(u,i);
}

int main()
{
	scanf("%d%d",&n,&m);
	for(int i=1,u,v;i<n;i++)
	{
		scanf("%d%d",&u,&v);
		tree::addedge(u,v);
	}
	tree::prework();
	for(int i=1,u,v;i<=m;i++)
	{
		scanf("%d%d",&u,&v);
		addedge(u,v);
	}
	for(;fr<rr;fr+=2)
	{
		int u=q[fr],v=q[fr+1];
		check_edge(u,v);
	}
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 83072