akhauriyash/Code-Regression huggingface dataset:
using System;
using System.Collections;
using System.Collections.Generic;
using System.Collections.Specialized;
using System.Linq;
using System.Numerics;

namespace AtCoderWorkspace
{
    public class Solver
    {
        public void Solve()
        {
            var cin = new Scanner();
            var h = cin.nextInt();
            var w = cin.nextInt();
            var list = new List<string>();
            for (int i = 0; i < h; i++)
            {
                var s = cin.next();
                list.Add(s);
                list.Add(s);
            }
            foreach (var item in list)
            {
                Console.WriteLine(item);
            }
        }
    }

    class Scanner
    {
        string[] s;
        int i;

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

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

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

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

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

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

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

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

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


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

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


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

int main() {
  // int A, H;
  // cin >> H >> A;
  // int ans = H / A;
  // if (H % A != 0) {
  //   cout << ans + 1 << endl;
  // } else {
  //   cout << ans << endl;
  // }

  // int H, N;
  // cin >> H >> N;
  // vector<int> A(N, 0);
  // for (int i; i < N; i++) {
  //   int val;
  //   cin >> val;
  //   A.at(i) = val;
  //   H = H - val;
  // }
  // if (H <= 0) {
  //   cout << "Yes" << endl;
  // } else {
  //   cout << "No" << endl;
  // }
  // int N, K;
  // cin >> N >> K;
  // vector<long long> H(N, 0);
  // long long ans = 0;
  // for (int i; i < N; i++) {
  //   int val;
  //   cin >> val;
  //   H.at(i) = val;
  // }
  // sort(H.begin(), H.end(), std::greater<int>());
  // if (N <= K) {
  //   cout << 0 << endl;
  // } else{
  //   for (int i; i < K; i++){
  //     H.at(i) = 0;
  //   }
  //   ans = accumulate(H.begin(), H.end(), 0LL);
  //   cout << ans << endl;
  // }
  long long H;
  cin >> H;
  long long ans = 0;
  long long pow_int = 0;
  while (H != 0) {
    H = H / 2;
    pow_int += 1;
  }
  pow_int -= 1;
  for (int i = 0; i <= pow_int; i++)
  {
    ans += pow(2, i);
  }
  // if (H % 2 == 0) {
  //   ans += H;
  //   while (H != 0) {
  //     ans += H / 2;
  //     H = H /2;
  //   }
  // } else {
  //   H = H - 1;
  //   ans += H;
  //   while (H != 0) {
  //     ans += H / 2;
  //     H = H / 2;
  //   }
  // }
  cout << ans << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
 
using namespace std;
 
int main(void)
{
	int n;
	string s, t1, t2;

	cin >> n;
	cin >> s;

	if (n%2) {
		cout << "No";
		return 0;
	}
	
	t1 = s.substr(0, (n/2));
	t2 = s.substr((n/2));

	if (t1==t2) {
		cout << "Yes";
	} else {
		cout << "No";
	}

	return 0;
}

Measured memory_bytes: 256
import sys

sys.setrecursionlimit(500005)
stdin = sys.stdin

ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))
ns = lambda: stdin.readline().strip()

R, C, K = na()
g = [[0] * C for _ in range(R)]
for i in range(K):
    r, c, v = na()
    g[r-1][c-1] = v

I = -9999999999999999999
dp = [I] * C
dp[0] = 0
for i in range(R):
    ndp = [I] * C
    row = g[i]
    ldp = [I] * 4
    for j in range(C):
        ldp[0] = max(ldp[0], dp[j])
        for k in range(2,-1,-1):
            ldp[k+1] = max(ldp[k+1], ldp[k] + row[j])
        ndp[j] = max(ldp)
    dp = ndp

print(dp[C-1])


Measured memory_bytes: 156052
#include <stdio.h>
#include <map>
#include <algorithm>
#include <vector>
#include <queue>

#define INF 1 << 29
#define REP(i,n) for(int i=0; i<(int)(n); i++)
#define FOR(i,k,n) for(int i=(k);i<(int)(n);i++)

using namespace std;

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

int abs(int x){
  return x > 0 ? x : -x;
}

int length(char c[]){
  int cnt=0;
  for(cnt=0;c[cnt]!='\0';cnt++){
  }
  return cnt;
}

int main(){
  int a,b,c,d;
  scanf("%d %d %d %d",&a,&b,&c,&d);
  if(a+b>c+d){
    printf("Left");
  }else if(a+b<c+d){
    printf("Right");
  }else{
    printf("Balanced");
  }
  return 0;
}


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

#define PI 3.1415926535897932
#define MOD 1000000007
#define INF 1e9

#define REP(i, n) for(int i = 0; i < (n); i++)
#define REP1(i, n) for(int i = 1; i <= (n); i++)
#define FOR(i, start, end) for(int i = (start); i < (end); i++)
#define ALL(v) (v).begin(), (v).end()

using namespace std;

typedef long long ll;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<vi> vvi;
typedef vector<string> vs;
typedef vector<bool> vb;


void solve()
{
    string S; cin >> S;
    if(S <= "2019/04/30") cout << "Heisei" << endl;
    else cout << "TBD" << endl;
}

int main()
{
    cin.tie(nullptr);
    ios_base::sync_with_stdio(false);
    cout << fixed << setprecision(20);

    solve();

    return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

  public static int area(int length, int width) {
    int area = length * width;
    return area;
  }

  public static int perimeter(int length, int width) {
    int perimeter = (length * 2) + (width * 2);
    return perimeter;
  }

	public static void main(String[] args) {
		Scanner s = new Scanner(System.in);
		int l = s.nextInt();
    int w = s.nextInt();
		System.out.println(area(l, w) + " " + perimeter(l, w));
	}
}



Measured memory_bytes: 26136
import sys
from itertools import combinations

n, x, y = map(int, sys.stdin.readline().split())
    
def main():
    res = [0] * (n + 1)
    for i, j in combinations(range(1, n+1), 2):
        d = min(j - i, abs(i - x) + 1 + abs(j - y))
        res[d] += 1
        
    for i in range(1, n):
        print(res[i])

if __name__ == "__main__":
    main()

Measured memory_bytes: 3444
<?php

define('DEBUG', true);
// define('DEBUG', false);

fscanf(STDIN, "%d %d %d %d", $A, $B, $C, $K);
// $sum = $A + $B + $C;

// for ($i = 0; $i < $K; $i++) {
// 	$sum *= 2;
// 	if (pow(10, 18) < $sum) {
// 		echo "Unfair";
// 		exit;
// 	}
// }

if ($K % 2 == 0) {
	echo $A - $B;
} else {
	echo $B - $A;
}


Measured memory_bytes: 4728
#include <bits/stdc++.h>
#include <variant>
#include <boost/range/algorithm.hpp>
#include <boost/range/numeric.hpp>
#include <boost/range/irange.hpp>
#include <boost/range/adaptor/indexed.hpp>
#define FOR(i,k,n)  for(int i = (k);i < (n);++i)
#define REP(i,n)    FOR(i,0,n)
#define ALL(x) begin(x),end(x)

using namespace std;
using namespace boost::adaptors;
using namespace std::string_literals;
using ll = int64_t;
using vecint = vector<int>;
using vecll = vector<ll>;
using boost::irange;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  int x;
  cin>>x;
  int y = 1999 - x;
  cout<<(y/200+1)<<endl;
  return 0;
}


Measured memory_bytes: 3644
import sys
import math  # noqa
import bisect  # noqa
import queue  # noqa


def input():
    return sys.stdin.readline().rstrip()


def main():
    S = input()
    K = int(input())

    N = len(S)
    substring = set()
    for i in range(N):
        for j in range(1, 6):
            substring.add(S[i:i + j])

    substring = list(substring)
    substring.sort()
    print(substring[K - 1])


if __name__ == '__main__':
    main()


Measured memory_bytes: 40172
import java.util.Scanner;
public class Main
{
	public static void main(String[] args)
	{
		Scanner sc = new Scanner(System.in);
		int num = sc.nextInt();
		int constraint = sc.nextInt();

		int[] friends = new int[num];
		int counter = 0;
		for(int i = 0;i<friends.length; i++)
		{
			friends[i] = sc.nextInt();
			if(friends[i] >= constraint)
				counter++;

		}
		System.out.println(counter);
	}
}

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

using namespace std;
int n;
int h[100005];
int dp[100005];

int main() {
    //freopen("input.in", "r", stdin);
    //freopen("output.txt", "w", stdout);
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    memset(dp,-1,sizeof dp);
    cin>>n;
    for(int i=0;i<n;i++){
        cin>>h[i];
    }
    reverse(h,h+n);
    dp[0]=0;
    for(int i=1;i<n;i++){
        if(i-2>=0){
            dp[i]=min(dp[i-1]+abs(h[i-1]-h[i]),dp[i-2]+abs(h[i-2]-h[i]));
        }
        else{
            dp[i]=dp[i-1]+abs(h[i-1]-h[i]);
        }
    }
    cout<<dp[n-1]<<endl;
    return 0;
}

Measured memory_bytes: 1024
import std.algorithm, std.container, std.conv, std.math, std.range, std.typecons, std.stdio, std.string;

auto rdsp(){return readln.splitter;}
void pick(R,T)(ref R r,ref T t){t=r.front.to!T;r.popFront;}
void readV(T...)(ref T t){auto r=rdsp;foreach(ref v;t)pick(r,v);}

void main()
{
  int n; readV(n);
  writeln(n*800-(n/15)*200);
}


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

using namespace std;

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

    double base, height, waterVolume;
    cin >> base >> height >> waterVolume;
    double waterHeight = waterVolume / base / base;
    if (waterHeight * 2.0 > height) {
        height = (height - waterHeight) * 2.0;
        if (abs(height) <= 1e-10) {
            cout << "0\n";
            return 0;
        }
        waterHeight = height / 2.0;
    }
    double waterArea = waterHeight * base;
    double ret = atan(2.0 * waterArea / height / height);
    ret = 90.0 - (ret / M_PI * 180.0);
    cout << setprecision(20) << ret << '\n';

    return 0;
}

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

using namespace std;

#define REP(i,a,b) for(int i=a;i<(int)b;i++)
#define rep(i,n) REP(i,0,n)
#define all(c) (c).begin(), (c).end()
#define zero(a) memset(a, 0, sizeof a)
#define minus(a) memset(a, -1, sizeof a)
#define watch(a) { cout << #a << " = " << a << endl; }
template<class T1, class T2> inline bool minimize(T1 &a, T2 b) { return b < a && (a = b, 1); }
template<class T1, class T2> inline bool maximize(T1 &a, T2 b) { return a < b && (a = b, 1); }
template<class T> void operator>> (istream& ist, vector<T>& vs) { for(auto& e: vs) cin >> e; }

typedef unsigned long long ll;
int const inf = 1<<29;

ll lcm(ll a, ll b) {
  return a / __gcd(a, b) * b;
}

int main() {

  int N; cin >> N;
  ll ans = 1;
  rep(i, N) {
    ll T; cin >> T;
    ans = lcm(ans, T);
  }

  std::cout << ans << "\n";
  
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cmath>
#include <algorithm>
#include <vector>
using namespace std;
int main() {
    int H, N; cin >> H >> N;
    unsigned long long int sum = 0;
    for (int i = 0; i < N; ++i) {
        int a = 0; cin >> a;
        sum += a;
    }
    if (sum >= H) printf("%s\n", "Yes");
    else printf("%s\n", "No");
}


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

    int len = s.length();
    string ans;
    cout << s[0];
    cout << len - 2;
    cout << s[len-1];
 
    return 0;
}

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

typedef long long ll;
typedef pair<int, int> P;
typedef tuple<int, int, int> T;

int MOD=1e9+7;
ll INF=1e18;

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

ll f(ll x, ll y){
    ll a=min(x, y), b=max(x, y);
    if(a==0) return -b;
    return f(a, b%a)+2LL*a*(b/a);
}

int main(){
    ll n, x; cin>>n>>x;
    cout << n+f(x, n-x) << endl;
}

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

using ll = long long;
using namespace std;

/* initialize */
auto p = [](int i) -> int {return i/2;};
auto l = [](int i) -> int{return 2 *i;};
auto r = [](int i) -> int{return 2*i+1;};
int H,temp;
int A[2000001];

void increasekey(int i, int key) {
    if ( key < A[i]) return;
    A[i] = key;
    while (i > 1 && A[p(i)] < A[i]){
        temp = A[p(i)]; A[p(i)] = A[i]; A[i] = temp;
        i = p(i);
    }
}

void maxheapify(int i){
    int largest,temp;
    int le=l(i), ri=r(i);
    if (le <= H && A[le] > A[i]) largest = le;
    else largest = i;
    if (ri <= H && A[ri] > A[largest]) largest = ri;
    if (largest!=i){
        temp = A[i];
        A[i] = A[largest];
        A[largest] = temp;
        maxheapify(largest);
    }
}

void ins(int key){
    H++;
    A[H] = -(1<<30);
    increasekey(H, key);
}

int ext() {
    int maxv;
    if (H < 1) return -(1<<30);
    maxv = A[1];
    A[1] = A[H--];
    maxheapify(1);
    return maxv;
}

/* main */
int main() {
    int key;
    char c[10];

    while(true){
        scanf("%s", c);
        if (c[0] == 'e' and c[1] == 'n') break;
        else if (c[0] == 'i') {scanf("%d", &key); ins(key);}
        else printf("%d\n", ext());
    }
    return 0;
}


Measured memory_bytes: 7108
# include <iostream>
# include <algorithm>
#include <array>
# include <cassert>
#include <cctype>
#include <climits>
#include <numeric>
# include <vector>
# include <string>
# include <set>
# include <map>
# include <cmath>
# include <iomanip>
# include <functional>
# include <tuple>
# include <utility>
# include <stack>
# include <queue>
# include <list>
# include <bitset>
# include <complex>
# include <chrono>
# include <random>
# include <limits.h>
# include <unordered_map>
# include <unordered_set>
# include <deque>
# include <cstdio>
# include <cstring>
using namespace std;
using LL = long long;
using ULL = unsigned long long;
constexpr long long MOD = 1000000000 + 7;
constexpr long long INF = 1e17 - 10;
const double PI = acos(-1);
typedef pair<LL, LL> Pll;
typedef pair<LL, pair<LL, LL>> Ppll;
typedef pair<LL, pair<LL, bitset<100001>>> Pbll;
typedef pair<LL, pair<LL, vector<LL>>> Pvll;
typedef pair<LL, LL> Vec2;
struct Tll { LL first, second, third; };
typedef pair<LL, Tll> Ptll;
#define rep(i,rept) for(LL i=0;i<rept;i++)
#define Mfor(i,mf) for(LL i=mf-1;i>=0;i--)
int dx[4] = { 0, 1, 0, -1 }, dy[4] = { 1, 0, -1, 0 };
struct Edge { LL to, cost; };
LL h, w, n, m, s = INF, k, sum,p=INF, ans = 0, t[1000000],o[1000000], a[1000000];
string YES = "YES", Yes = "Yes", NO = "NO", No = "No";
bool flag;
int main() {
	cin >> n >> m;
	t[0] = 0;
	rep(i, n) {
		w = 0;
		cin >> a[i];
		if (a[i] < 0)
			t[i + 1] = -a[i];
		else o[i + 1] = a[i];
		t[i + 1] += t[i];
		o[i + 1] += o[i];
		if (a[i] > 0)sum += a[i];
		if (i + 1 >= m) {
			s = min(s, t[i + 1] - t[i + 1 - m]);
			p = min(p, o[i + 1] - o[i + 1 - m]);
		}
		if (a[i] > 0) { h++, k = 0; }
		else if (a[i] < 0) { k++, h = 0; }
		else { k++, h++; }
		if (k == m || h == m)flag = 1;
	}
	cout << (flag == 1 ? sum : max(sum - p, sum - s)) << endl;
	return 0;
}

Measured memory_bytes: 9216
module Main where

import Control.Applicative

getInt :: IO Int
getInt = head <$> getInts

getInts :: IO [Int]
getInts = map read . words <$> getLine

main :: IO ()
main = do
  { [a, b] <- getInts
  ; if a < b then putStrLn "a < b"
    else if a == b then putStrLn "a == b"
         else putStrLn "a > b"
  }




Measured memory_bytes: 3596
H,W=[int(a) for a in input().split(" ")]
tab=[[int(a) for a in input().split(" ")] for i in range(H)]
ans = []
moving=False
i,j=0,0
dx=1
while i<H and j<W:
    moving = not moving if tab[i][j]%2 == 1 else moving
    ni,nj=i,j
    if (dx>0 and j==W-1) or (dx<0 and j==0):
        ni=i+1
        dx*=-1
    else:
        nj=j+dx
    if moving and ni<H and nj<W:
        ans.append([i+1,j+1,ni+1,nj+1])
    i,j=ni,nj
print(len(ans))
for row in ans:
    print(" ".join([str(x) for x in row]))

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

int main(){
    string s; cin>>s;
    s+="@";
    int max=0,cnt=0;
    for(int i=0;i<s.size()-1;i++){
        if(s[i]=='A'||s[i]=='C'||s[i]=='G'||s[i]=='T'){
            cnt++;
            if(!(s[i+1]=='A'||s[i+1]=='C'||s[i+1]=='G'||s[i+1]=='T')){
                if(cnt>max)max=cnt;
                cnt=0;
            }
        }
    }
    cout<<max<<endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <fstream>
#include <vector>
#include <string>
#include <map>
#include <queue>
#include <cstdlib>
#include <algorithm>
#include <iterator>
using namespace std;

/*
const int MAX_E=2*(100-1);
const int MAX_V=100;
const long long int INF=100000000;
struct edge { int from,to,cost;};
edge es[MAX_E];
//int d[MAX_V];
int V,E;
void shortest_path(int s,int e,vector<int>& d);
int main(){
	int n,k;
	while(cin >> n >> k&&n!=0&&k!=0){
		int V=n;
		int E=2*(n-1);
		vector<int> land(V);
		int l=0;
		for(int i=0; i<E; ++i){
			es[i].cost=-1;
			es[i].from=-1;
			es[i].to=-1;
		}
		for(int i=0; i<k; ++k){
			int m;
			cin >> m;
			if(m==0){
				int a,b;
				cin >> a >> b;
				shortest_path(a,b,land);
				cout << land[b] << "\n";
			} else if(m==1){
				int c,d,e;
				cin >> c >> d >> e;
				es[l].from=c;
				es[l].to=d;
				es[l].cost=e;
				es[l+1].from=d;
				es[l+1].to=c;
				es[l+1].cost=e;
				l+=2;
			}
		}
	}
	return 0;
}

void shortest_path(int s,int e,vector<int>& d){
	cout << "ok1\n";
	for(int i=0; i<V; ++i) {
		cout << "ok\n";
		d[i]=INF;
	}
	d[s]=0;
	while(true){
		cout << "ok2\n";
		bool update=false;
		for(int i=0; i<E; ++i){
			edge e=es[i];
			if(d[e.from]!=INF&&d[e.to]>d[e.from]+e.cost){
				d[e.to]=d[e.from]+e.cost;
				update=true;
			}
		}
		if(!update) break;
	}
}
*/
/*
const int INF=100000000;
int main(){
	int n;
	while(cin >> n&&n!=0){
		vector<int> color;
		for(int i=0; i<n; ++i){
			int t;
			cin >> t;
			color.push_back(t);
		}
		int maxDel=INF;
		for(int i=0; i<n; ++i){
			for(int j=1; j<=3; ++j){
				if(color[i]==j) continue;
				int up=i-1;
				int down=i+1;
				int sum=0;
				int c=1;
				int col=j;
				while(1){
					int nCal=-1;
					while(1){
						if(up<0) break;
						if(color[up]!=col){
							nCal=color[up];
							break;
						}
						up--;
						c++;
					}
					while(1){
						if(down>=n) break;
						if(color[down]!=col){
							if(nCal==-1) nCal=color[down];
							break;
						}
						++down;
						++c;
					}
					if(c>=4){
						sum+=c;
					} else{
						break;
					}
					c=0;
					if(nCal==-1){
						break;
					}else{
						col=nCal;
					}
				}
				maxDel=min(maxDel,n-sum);
			}
		}
		cout << maxDel << "\n";
	}
	return 0;
}
*/

int main(){
	int n;
	cin >> n;
	vector< vector<int> > a(n,vector<int>(3));
	vector<int> sum(n);
	for(int i=0; i<n; ++i){
		for(int j=0; j<3; ++j){
			cin >> a[i][j];
		}
	}
	for(int j=0; j<3; ++j){
		for(int i=0; i<n; ++i){
			bool f=true;
			for(int k=0; k<n; ++k){
				if(a[i][j]==a[k][j]&&i!=k){
					f=false;
					break;
				}
			}
			if(f)sum[i]+=a[i][j];
		}
	}
	for(int i=0; i<n; ++i){
		cout << sum[i] << "\n";
	}
	return 0;
}

Measured memory_bytes: 1224
/*
 * @Author: Patchouli_ 
 * @Date: 2020-02-09 20:57:40 
 * @Last Modified by:   Patchouli_ 
 * @Last Modified time: 2020-02-09 21:00:40 
 */
#include <bits/stdc++.h>
#define MAXN 200010
#define int long long
using namespace std;
inline int read(){
    int ret=0,pos=1;char c=getchar();
    while(!isdigit(c) && c!='-' )c=getchar();
    if(c=='-')	pos=-1,c=getchar();
    while(isdigit(c))ret=(ret<<3)+(ret<<1)+c-48,c=getchar();
    return pos*ret;
}
int n,k;
int s[MAXN];
int m;
signed main(){
	n=read(),k=read();
	for(int i=1;i<=n;++i)	s[i]=s[i-1]+read()+1;
	for(int i=k;i<=n;++i)	m=max(m,s[i]-s[i-k]);
	printf("%lf",m*0.5);
}

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

using namespace std;

typedef long long ll;

int main() {
    int a, b, c, d, e, f, g, h, i;
    cin >> a >> b >> c >> d >> e >> f >> g >> h >> i;
    if (a + e == b + d && b + f == c + e && d + h == e + g && e + i == f + h){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }
}

Measured memory_bytes: 256
N = int(input())
s = list(input())
t = list(input())

ans = N

for i in range(N):
    check = 0
    for j in range(N-i):
        if s[j+i] == t[j]:
            pass
        else:
            check = 1
    if check == 0:
        ans = i
        break

print(N + ans)

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

using namespace std;

#define INF 100000000
#define YJ 1145141919
#define INF_INT_MAX 2147483647
#define INF_LL_MAX 9223372036854775807
#define EPS 1e-10
#define MOD 1000000007
#define Pi acos(-1)
#define LL long long
#define ULL unsigned long long
#define LD long double

#define int long long

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(a)  begin((a)), end((a))
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())

const int MAX_N = 100005;
int N;
int A[MAX_N], B[MAX_N];
int S[MAX_N];

vector<int> vEdge[MAX_N];
vector<int> Edge[MAX_N];

int cnt[MAX_N];

using II = pair<int, int>;

II G = II(-1,-1);
unordered_map<int, unordered_map<int, int>> edgeCost;

int countCnt(int pos, int pre = -1) {
    int ret = 1;
    for(int next : vEdge[pos]) {
        if(next == pre) {
            continue;
        }
        Edge[pos].push_back(next);
        ret += countCnt(next, pos);
    }
    return cnt[pos] = ret;
}

int calcCost(int pos = 0) {
    // cerr << "pos: " << pos << endl;
    for(int next : Edge[pos]) {
        int nextCnt = cnt[next];
        int posCnt = N - nextCnt;
        if(posCnt == nextCnt) {
            // cerr << pos+1 << " " << next+1 << endl;
            G = II(pos, next);
        } else {
            // cerr << pos+1 << " " << next+1 << " " << S[pos] << " " << S[next] << " " << posCnt << " " << nextCnt << " " << abs(S[pos] - S[next]) / abs(posCnt - nextCnt) << endl;
            edgeCost[pos][next] = abs(S[pos] - S[next]) / abs(posCnt - nextCnt);
        }
        calcCost(next);
    }
}

int preCountCnt(int pos, int pre = -1) {
    int ret = 1;
    for(int next : vEdge[pos]) {
        if(next == pre) {
            continue;
        }
        ret += preCountCnt(next, pos);
    }
    return cnt[pos] = ret;
}

int calcCost(int pos, int pre) {
    int ret = 0;
    for(int next : vEdge[pos]) {
        if(next == pre) {
            continue;
        }
        // cerr << pos << " " << next << " " << cnt[next] << " " << max(edgeCost[pos][next], edgeCost[next][pos]) << endl;
        ret += cnt[next] * max(edgeCost[pos][next], edgeCost[next][pos]);
        ret += calcCost(next, pos);
    }

    return ret;
}

signed main()
{
    cin >> N;
    REP(i,N-1) {
        cin >> A[i] >> B[i];
        A[i]--; B[i]--;
        vEdge[A[i]].push_back(B[i]);
        vEdge[B[i]].push_back(A[i]);
    }

    REP(i,N) {
        cin >> S[i];
    }

    countCnt(0);

    calcCost(0);

    if(G.first != -1) {
        preCountCnt(G.first, G.second);
        preCountCnt(G.second, G.first);
        int cost = calcCost(G.first, G.second) + calcCost(G.second, G.first);
        // cerr << G.first << " " << G.second << endl;
        // cerr << "cost: " << cost << " " << S[G.first] << " " << abs(S[G.first] - cost) / (N/2) << endl;
        edgeCost[G.first][G.second] = (S[G.first] - cost) / (N/2);
    }

    REP(i,N-1) {
        cout << max(edgeCost[A[i]][B[i]], edgeCost[B[i]][A[i]]) << endl;
    }

    return 0;
}

Measured memory_bytes: 42404
#include <bits/stdc++.h>
using namespace std;
using Graph = vector<vector<int>>;
using ll = long long;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define all(v) v.begin(), v.end()
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; }
const long long INF = 1LL << 60;

int main(){
  ll n, k;
  cin >> n >> k;
  string s;
  cin >> s;
  char a = (ll)s[k - 1] +32;
  s[k - 1] = a;
  cout << s << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <queue>
#include <stack>
#include <cstdlib>
#include <map>
#include <iomanip>
#include <set>
#include <stdio.h>
#include <ctype.h>
#include <random>
#include <string.h>
#include <cmath>
#include <unordered_map>
#include <cstdio>
using namespace std;
#define all(vec) vec.begin(),vec.end()
typedef long long ll;

ll gcd(ll x, ll y) {
	if (y == 0)return x;
	return gcd(y, x%y);
}
ll lcm(ll x, ll y) {
	return x / gcd(x, y)*y;
}
ll kai(ll x, ll y, ll m) {
	ll res = 1;
	for (ll i = x - y + 1; i <= x; i++) {
		res *= i; res %= m;
	}
	return res;
}
ll mod_pow(ll x, ll y, ll m) {
	ll res = 1;
	while (y > 0) {
		if (y & 1) {
			res = res * x % m;
		}
		x = x * x % m;
		y >>= 1;
	}
	return res;
}

ll comb(ll x, ll y, ll m) {
	if (y > x)return 0;
	return kai(x, y, m) * mod_pow(kai(y, y, m), m - 2, m) % m;
}

int x;

signed main() {
	cin >> x;
	if (x < 600)cout << 8 << endl;
	else if (x < 800)cout << 7 << endl;
	else if (x < 1000)cout << 6 << endl;
	else if (x < 1200)cout << 5 << endl;
	else if (x < 1400)cout << 4 << endl;
	else if (x < 1600)cout << 3 << endl;
	else if (x < 1800)cout << 2 << endl;
	else cout << 1 << endl;
}

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

namespace ABC065A___Expired
{
    class Program
    {
        static void Main(string[] args)
        {
            string[] input = Console.ReadLine().Split(' ');

            int dayOfLimitDangerous = int.Parse(input[0]);
            int dayOfBeforeLimit = int.Parse(input[1]);
            int eatDay = int.Parse(input[2]);

            string result = "";
            if (eatDay <= dayOfBeforeLimit)
            {
                result = "delicious";
            }

            if (dayOfBeforeLimit < eatDay &&
                eatDay <= dayOfBeforeLimit + dayOfLimitDangerous)
            {
                result = "safe";
            }

            if (dayOfBeforeLimit + dayOfLimitDangerous < eatDay)
            {
                result = "dangerous";
            }

            Console.WriteLine(result);
        }
    }
}


Measured memory_bytes: 11092
fn main() {
    let (n, x, y): (i32, i32, i32) = input();
    let ans = solve(n, x, y);
    for a in ans.iter() { println!("{}", a); }
}

fn input() -> (i32, i32, i32) {
    let mut buf = String::from("");
    buf.pop();
    std::io::stdin().read_line(&mut buf).unwrap();
    let mut iter = buf.split_whitespace();
    let n: i32 = iter.next().unwrap().parse().unwrap();
    let x: i32 = iter.next().unwrap().parse().unwrap();
    let y: i32 = iter.next().unwrap().parse().unwrap();
    (n, x, y)
}

fn solve(n: i32, x: i32, y: i32) -> Vec<usize> {
    let mut ans: Vec<usize> = vec![0usize; (n-1) as usize];
    for i in 1..n {
        for j in (i+1)..(n+1) {
            // min{|j − i|, |X − i| + 1 + |j − Y |, |Y − i| + 1 + |j − X|}
            let dis = std::cmp::min(j - i, (i - x).abs() + 1 + (j - y).abs()) as usize;
            ans[dis-1] += 1 as usize;
        }
    }
    ans
}

Measured memory_bytes: 4352
import java.io.*;
import java.util.*;

public class Main {
    public static void main(String[] args) {
        MyScanner sc = new MyScanner();

        int n = sc.nextInt();
        char[] s = sc.next().toCharArray();

        long sum = 0;
        int[] cnt = new int[3];
        for (int i = 0; i < n; i++) {
            cnt[checkRGB(s[i])]++;
        }

        int[] cnt2 = new int[3];
        for (int i = 0; i < n-3; i++) {
            cnt2[checkRGB(s[i])]++;

            int[] cnt3 = new int[3];
            for (int j = i+1; j < n-1; j++) {
                cnt3[checkRGB(s[j])]++;
                if (s[i] == s[j])
                    continue;

                int tmp = 3 - checkRGB(s[i]) - checkRGB(s[j]);
                sum += cnt[tmp] - cnt2[tmp] - cnt3[tmp];

                if (j + (j-i) < n && checkRGB(s[j + (j-i)]) == tmp)
                    sum--;
            }
        }

        System.out.println(sum);
    }

    static int checkRGB(char c) {
        if (c == 'R')
            return 0;
        else if (c == 'G')
            return 1;
        else
            return 2;
    }

    static class MyScanner {
        BufferedReader reader = new BufferedReader(new InputStreamReader(System.in), 1 << 15);
        StringTokenizer tokenizer;

        String next() {
            try {
                while (tokenizer == null || !tokenizer.hasMoreTokens()) {
                    tokenizer = new StringTokenizer(reader.readLine());
                }
            } catch (IOException ignored) {
            }
            return tokenizer.nextToken();
        }

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

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

Measured memory_bytes: 33508
#include <iostream>
#include <string>
#include <vector>

using namespace std;

template <class T>
vector<T> Vec(size_t l, T v) { return vector<T>(l, v); }

template <class T, class... Ts>
auto Vec(size_t l, Ts... ts) {
    return vector<decltype(Vec<T>(ts...))>(l, Vec<T>(ts...));
}

auto A = Vec<int>(0, 0);
auto pre = Vec<int>(0, 0, 0);
auto dp = Vec<int>(0, 0, 0, 0);

int rec(int L, int R, int K) {
    if (L > R) return 0;
    if (dp[L][R][K] >= 0) return dp[L][R][K];

    // 1. A[L]を使わない場合
    dp[L][R][K] = rec(L + 1, R, K);

    // 2. A[L]を使う場合
    //    Rの直前にあるA[L]を使う
    int gain = (pre[R][A[L]] == L ? 1 : 2);
    dp[L][R][K] = max(dp[L][R][K], rec(L + 1, pre[R][A[L]] - 1, K) + gain);

    // 3. A[L]を変更する場合
    //    A[L]をA[R]に変えるのが最善
    if (K > 0) {
        int gain = (L == R ? 1 : 2);
        dp[L][R][K] = max(dp[L][R][K], rec(L + 1, R - 1, K - 1) + gain);
    }

    return dp[L][R][K];
}

int main() {
    string S;
    int K;
    cin >> S >> K;
    int N = S.length();

    A = Vec<int>(N + 1, 0);
    for (int i = 1; i <= N; ++i) {
        A[i] = S[i - 1] - 'a';
    }

    pre = Vec<int>(N + 1, 26, -1);
    // pre[i][c] = j <= iかつA[j] = cなる最大のj

    for (int i = 1; i <= N; ++i) {
        for (int c = 0; c < 26; ++c) {
            if (A[i] == c) {
                pre[i][c] = i;
            } else {
                pre[i][c] = pre[i - 1][c];
            }
        }
    }
    dp = Vec<int>(N + 1, N + 1, K + 1, -1);

    cout << rec(1, N, K) << endl;
    return 0;
}


Measured memory_bytes: 110336
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <algorithm>
#include <deque>
#include <cctype>
#include <cstdio>
#include <math.h>
using namespace std;
int main(){
    long long n;
    cin >> n;
    long long sum = n*3;
    vector<long long> a(sum);
    for(int i=0;i<sum;i++){
        cin >> a[i];
    }
    long long ans=0;
    sort(a.begin(),a.end());
    reverse(a.begin(),a.end());
    for(int i=1;i<n*2;i=i+2){
        ans+=a[i];
    }
    cout << ans << endl;
}

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

namespace ARC100_A
{
    internal class Program
    {
        public static void Main(string[] args)
        {
            int n = int.Parse(Console.ReadLine());
            long[] a = Array.ConvertAll(Console.ReadLine().Split(' '), long.Parse);

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

            Array.Sort(temp);
            temp = temp.Select(c => c - temp[0]).ToArray();

            long cur = temp[0];
            long[] asc = new long[n+1];
            asc[0] = 0;
            for (int i = 1; i < n; i++)
            {
                if (temp[i] != cur)
                {
                    cur = temp[i];
                    asc[i] = Math.Abs(cur - temp[i - 1]) * (i) + asc[i - 1];
                    continue;
                }

                asc[i] = asc[i - 1];
            }

            asc[n] = asc[n - 1];

            cur = temp[n - 1];
            long[] desc = new long[n+1];
            for (int i = n - 1; i > 0; i--)
            {
                if (temp[i] != cur)
                {
                    cur = temp[i];
                    desc[i] = Math.Abs(cur - temp[i + 1]) * (n - i - 1) + desc[i + 1];
                    continue;
                }

                desc[i] = desc[i + 1];
            }
            desc[0] = desc[1];

            long min = Int64.MaxValue;
            for (int i = 0; i <= n; i++)
            {
                min = Math.Min(min, asc[i] + desc[i]);
            }
            
            Console.WriteLine(min);
        }
    }
}

Measured memory_bytes: 40500
#include <bits/stdc++.h>
#define ALL(a) (a).begin(),(a).end()
#define RALL(a) (a).rbegin(),(a).rend()
#define pb push_back
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define ll long long
using namespace std;
int main(){
  int n;
  cin >> n;
  int m = 0, cnt = 0;
  REP(i,n){
    int a;
    cin >> a;
    if(a >= m){
      cnt++; 
    }
    m = max(m, a);
  }
  cout << cnt << endl;
  return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<sstream>
#include<algorithm>
#include<vector>
#include<iomanip>
#include<cmath>
#include<complex>
#include<queue>
#include<deque>
#include<stack>
#include<map>
#include<set>
#include<bitset>
#include<functional>
#include<numeric>
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; }
using namespace std;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
using ll = long long;
const int inf=1e9+7;
const ll longinf=1LL<<60 ;
const ll mod=1e9+7 ;
int dx[4] = {1,0,-1,0}, dy[4] = {0,1,0,-1};

int main()
{

    int m ;
    cin >> m;
    cout << 48-m << endl;
    return 0;
}

Measured memory_bytes: 256
N,D=map(int,input().split())
X=[list(map(int,input().split())) for i in range(N)]
ans=0
for i in range(N-1):
    for j in range(i+1,N):
        dis=0
        for k in range(D):
            dis+=(X[i][k]-X[j][k])**2
        dis**=0.5
        if dis==dis//1 :ans+=1
print(ans)

Measured memory_bytes: 3188
#include <cstdio>
#include <climits>
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <list>
#include <set>
#include <bitset>
#include <iterator>
#define rep(i, n) for(long long i = 0; i < (long long)(n); i++)
#define mod 1000000007
using namespace std;
typedef long long int LL;

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

    vector<LL> a(N);
    rep(i, N) {
        cin >> a[i];
    }

    rep(i, N) {
        a[i] -= (i + 1);
    }

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

    LL b = a[N / 2];

    LL ans = 0;
    rep(i, N) {
        ans += abs(a[i] - b);
    }

    cout << ans << endl;
    return 0;
}


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

int main() {
  long long a, b, c, d;
  cin >> a >> b >> c >> d;
  a = (a == 0 && a != b)? a+1 : a;
  b = (b == 0 && a != b)? b-1 : b;
  c = (c == 0 && d != c)? c+1 : c;
  d = (d == 0 && d != c)? d-1 : d;
  cout << max({a*c, a*d, b*c, b*d}) << endl;
  //printf("%d %d %d %d", a*c, a*d, b*c, b*d);
}


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

class Graph01
{
    int V;
    using Pint = pair<int, int>;
    vector<vector<Pint> > E;

public:
    Graph01(int N) : V(N)
    {
        E.resize(V);
    }
    void add_edge(int from, int to, int cost)
    {
        E[from].push_back(make_pair(to, cost));
    }
    int bfs01(int s, int t)
    {
        deque<Pint> deq;
        vector<int> checked(V, 0);

        deq.push_front(Pint(s, 0));

        while(!deq.empty())
        {
            Pint now = deq.front();
            deq.pop_front();
            if (now.first == t) return now.second;
            if (checked[now.first]) continue;
            checked[now.first] = 1;
            for (auto e: E[now.first])
            {
                if (e.second) deq.push_back(Pint(e.first, now.second+1));
                else deq.push_front(Pint(e.first, now.second));
            }
        }
        // 到達不可能
        return -1;
    }
};


int N, M;

int main()
{
    cin >> N >> M;
    Graph01 graph(2*M+2 + N);
    vector<map<int, int> > ekinum(1000001);

    int eki_now = 2;
    for (int i=0; i<M; i++)
    {
        int p, q, c;
        cin >> p >> q >> c;
        p--; q--;
        int ekip, ekiq;
        if (!ekinum[c].count(p))
        {
            ekinum[c][p] = eki_now;
            eki_now++;
        }
        ekip = ekinum[c][p];
        if (!ekinum[c].count(q))
        {
            ekinum[c][q] = eki_now;
            eki_now++;
        }
        ekiq = ekinum[c][q];

        graph.add_edge(ekip, ekiq, 0);
        graph.add_edge(ekiq, ekip, 0);

        if (p == 0) graph.add_edge(0, ekip, 1);
        if (p == N-1) graph.add_edge(ekip, 1, 0);
        if (q == 0) graph.add_edge(0, ekiq, 1);
        if (q == N-1) graph.add_edge(ekiq, 1, 0);
    }

    vector<vector<int> > lst(N);
    for (auto v : ekinum)
    {
        for (auto val : v)
        {
            lst[val.first].push_back(val.second);
        }
    }
    for (auto vec : lst)
    {
        for (auto v : vec)
        {
            graph.add_edge(v, eki_now, 1);
            graph.add_edge(eki_now, v, 0);
        }
        eki_now++;
    }
    cout << graph.bfs01(0, 1) << endl;
}


Measured memory_bytes: 104704
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
typedef long long ll;
int main() {
    // ifstream in("data1.txt");
    // cin.rdbuf(in.rdbuf());
    ll N, M;
    cin >> N >> M;
    vector<pair<ll, ll>> mp(N);
    ll ans = 0;
    rep(i, N) {
        ll x,y;
        cin >> x >> y;
        mp.at(i) = make_pair(x, y);
    }
    sort(mp.begin(), mp.end());
    for(auto x : mp) {
        if(M <= x.second){
            ans += x.first * M;
            break;
        } else {
            ans += x.first * x.second;
            M -= x.second;
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 1792
#!/usr/bin/env python3
K = int(input())
l = [1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51]
print(l[K-1])


Measured memory_bytes: 2940
#include<stdio.h>

int main(void){
    
    char array[3];
    for(int i = 0; i < 3; i++){
        scanf("%c",&array[i]);
    }
    
    if(array[0]==array[1] && array[1]==array[2]){
        printf("No\n");
    }else{
        printf("Yes\n");
    }
    
    return 0;
}

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

using namespace std;
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl "\n"
#define int long long
const int N = 1e5+7;

int32_t main() {
    IOS;
	int n;
	cin >> n;
	n = n * 2;
	vector<int> a(n);
	for (auto &i : a) cin >> i;
	sort(a.begin(), a.end());
	int ans = 0;
	for (int i = 0; i < n; i+=2)
		ans += min(a[i], a[i+1]);
	cout << ans << endl;
    return 0;
}


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

using namespace std;

typedef long long ll;
typedef pair<int, int> P;
typedef vector<int> vi;
typedef vector<ll> vll;
// #define int long long
#define pb push_back
#define mp make_pair
#define eps 1e-9
#define INF 2000000000               // 2e9
#define LLINF 2000000000000000000ll  // 2e18 (llmax:9e18)
#define fi first
#define sec second
#define all(x) (x).begin(), (x).end()
#define sq(x) ((x) * (x))
#define dmp(x) cerr << #x << ": " << x << endl;

template <class T>
void chmin(T &a, const T &b) {
  if (a > b) a = b;
}
template <class T>
void chmax(T &a, const T &b) {
  if (a < b) a = b;
}

template <class T>
using MaxHeap = priority_queue<T>;
template <class T>
using MinHeap = priority_queue<T, vector<T>, greater<T>>;
template <class T>
vector<T> vect(int len, T elem) {
  return vector<T>(len, elem);
}

template <class T, class U>
ostream &operator<<(ostream &os, const pair<T, U> &p) {
  os << p.fi << ',' << p.sec;
  return os;
}
template <class T, class U>
istream &operator>>(istream &is, pair<T, U> &p) {
  is >> p.fi >> p.sec;
  return is;
}
template <class T>
ostream &operator<<(ostream &os, const vector<T> &vec) {
  for (int i = 0; i < vec.size(); i++) {
    os << vec[i];
    if (i + 1 < vec.size()) os << ' ';
  }
  return os;
}
template <class T>
istream &operator>>(istream &is, vector<T> &vec) {
  for (int i = 0; i < vec.size(); i++) is >> vec[i];
  return is;
}
void fastio() {
  cin.tie(0);
  ios::sync_with_stdio(0);
  cout << fixed << setprecision(20);
}

#define endl "\n"

void solve() {
  int N, T;
  cin >> N >> T;
  vector<int> t(N);
  cin >> t;
  int ans = T;
  for (int i = 1; i < N; i++) { ans += min(t[i] - t[i - 1], T); }
  cout << ans << endl;
  return;
}

signed main() {
  fastio();
  solve();
  // int t; cin >> t; while(t--)solve();
  return 0;
}


Measured memory_bytes: 1024
import sys
sys.setrecursionlimit(10 ** 6)
int1 = lambda x: int(x) - 1


def II(): return int(input())


def MI(): return map(int, input().split())


def MI1(): return map(int1, input().split())


def LI(): return list(map(int, input().split()))


def LLI(rows_number): return [LI() for _ in range(rows_number)]


def Fibo(n, memo={}):
    if n == 1:
        return 0
    elif n == 2:
        return 1
    elif n in memo:
        return memo[n]
    else:
        memo[n] = Fibo(n - 1, memo) + Fibo(n - 2, memo)
        return memo[n]


def solve():
    M = list(MI())
    if len(M) == 2:
        n, m = M
    else:
        n = M[0]
        m = 0

    s = 0
    mod = 1000000007
    ans = 1
    for _ in range(m):
        t = II() - 1
        d = t - s
        if d < 0:
            keiro = 0
        else:
            keiro = Fibo(d + 2)
        # print(s, t, d, keiro)
        ans = ans * keiro % mod
        s = t + 2
    d = n - s
    if d < 0:
        keiro = 0
    else:
        keiro = Fibo(d + 2)

    ans = ans * keiro % mod
    print(ans % mod)


if __name__ == '__main__':
    solve()


Measured memory_bytes: 568680
#include <stdio.h>
#define _USE_MATH_DEFINES
#include <math.h>
#include <stdlib.h>
#include <sys/stat.h>
#include <string.h>


int L_in;
int R_in;
int d_in;


int main(int argc, char* argv[]){
    int i,j;
    int temp,count;
    count=0;
    scanf("%d %d %d",&L_in,&R_in,&d_in);
    for(i=L_in;i<=R_in;i++){
        if(i % d_in == 0){
            count++;
        }
    }
    printf("%d",count);
    return 0;
}

Measured memory_bytes: 1676
#include <algorithm>
#include <bitset>
#include <cstdio>
#include <cstdlib>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>
#define REP(i, b, n) for (Int i = b; i < Int(n); i++)
#define rep(i, n) REP(i, 0, n)
using namespace std;
using Int = long long;
Int inf = 1000000000000000001LL;
using vi = vector<Int>;
using vvi = vector<vi>;

Int GCD(Int a, Int b){
    if(b==0) return a;
    if(a < b) return GCD(b, a);
    unsigned r;
    while ((r=a%b)) {
        a = b;
        b = r;
    }
    return b;
}

int even_n(Int n) {
    return n/2;
}

int odd_n(Int n){
    return 3*n+1;
}

int main() {
    string S;

    cin >> S;
    Int ans =0;

    vi a;
    unordered_map<Int,Int> mp;
    mp[stoi(S)] = 1;
    a.push_back(0);
    a.push_back(stoi(S));
    REP(i,2,1000001){
        if(a[i-1]%2 == 0){
            a.push_back(even_n(a[i-1]));
        }else{
            a.push_back(odd_n(a[i-1]));
        }

        if(mp[a[i]] != 0){
            ans = i;
            break;
        }else{
            mp[a[i]] = i;
        }
    }


    cout << ans;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>

#define N 500

using namespace std;

int main()
{
  int h, w;
  char a[N][N];
  int hist[N][N];
  int tmp;

  while(cin>>h>>w && h+w){
    for(int i = 0; i < h; ++i)
      for(int j = 0; j < w; ++j)
     cin >> a[i][j];

    for(int i = 0; i < h; ++i){
      tmp = 0;
      for(int j = w-1; j >= 0; --j){
     if(a[i][j] == '*'){
       tmp = 0;
       hist[i][j] = 0;
     } else {
       hist[i][j] = ++tmp;
     }
      }
    }

    int s = 0, s_max = 0;
    for(int i = 0; i < h; ++i){
      for(int j = 0; j < w; ++j){
     if(a[i][j] == '*') continue;
     s = tmp = hist[i][j];

     for(int k = i+1; k < h; ++k){
       if(a[k][j] == '*') break;
       tmp = min(hist[k][j], tmp);
       s = max(s, (k-i+1)*min(tmp, hist[k][j]));
     }

     s_max = max(s, s_max);
      }
    }

    cout << s_max << endl;
  }

  return 0;
}

Measured memory_bytes: 2380
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#define _CRT_SECURE_NO_WARNINGS
#include <vector>
#include <iostream>
#include <string.h>
#include <set>
#include <bitset>
#include <cmath>
#include <iomanip>
#include <string>
using namespace std;

typedef double LD;
typedef long long LL;
typedef pair<int, int> PII;
#define MP make_pair
#define PB push_back
#define FOR(i,a,b) for(int i = (a); i < (b); ++i)
#define RFOR(i,b,a) for(int i = (b) - 1; i >= (a); --i)
#define REP(i, t) FOR(i,0,t)
#define ALL(a) a.begin(), a.end()
#define SZ(a) (int)((a).size())

const LL MOD = 1000000007;
const int INF = 1e9;
const LL LINF = 1LL * INF * INF;
const int MAXN = 2007;
const LD EPS = 1e-7;

bitset <MAXN * MAXN> B;

int main()
{
	ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
	//freopen("In.txt", "r", stdin);
	int n, s = 0;
	cin >> n;
	B[0] = 1;
	REP(i, n)
	{
		int a;
		cin >> a;
		s += a;
		B |= B << a;
	}
	FOR(i, (s + 1) >> 1, MAXN * MAXN)
		if (B[i])
		{
			cout << i;
			return 0;
		}
	//cout << endl; system("pause");
	return 0;
}

Measured memory_bytes: 1792
N,K = map(int,input().split())
A = list(map(int,input().split()))
wa = [0] * (N+1)
for i in range(N):
    wa[i+1] = wa[i] + (A[i]+1)/2
Max = 0
for i in range(N-K+1):
    Max = max(Max,wa[K+i]-wa[i])
print(Max)


Measured memory_bytes: 32160