akhauriyash/Code-Regression huggingface dataset:
#include <stdio.h>
#include <stdlib.h>

int main(void) {

  long n;
  scanf("%ld", &n);
  long a[n];
  for (long i = 0; i < n; i++) {
    scanf("%ld", &a[i]);
  }
  long **bit;
  bit = (long **)malloc(sizeof (long*) * n);
  for (long i = 0; i < n; i++) {
  	bit[i] = (long *)malloc(sizeof (long) * 20);
  }
  for (long i = 0; i < n; i++) {
    bit[i][0] = a[i];
    for (long j = 1; j < 20; j++) {
      bit[i][j] = bit[i][j-1]/2;
      bit[i][j-1] %= 2;
    }
  }
  int check[20];
  long count = 0;
  long cur_end = -1;
  int flag;
  for (long start = 0; start < n; start++) {
    if (cur_end < start) {
      for (long i = 0; i < 20; i++) {
        check[i] = 0;
      }
    }
    for (long end = cur_end+1; end < n; end++) {
      flag = 1;
      for (long i = 0; i < 20; i++) {
        if (bit[end][i] == 1 && check[i] == 1) {
          flag = 0;
          break;
        }
      }
      if (flag == 1) {
        cur_end = end;
        for (int i = 0; i < 20; i++) {
          check[i] += bit[end][i];
        }
      } else {
        break;
      }
    }
    count += cur_end-start+1;
    for (int i = 0; i < 20; i++) {
      check[i] -= bit[start][i];
    }
  }
  printf("%ld\n", count);

  return 0;
}

Measured memory_bytes: 39224
require 'pp'

def gets; ARGF.gets; end

class Solver

  def main
    n = gets.chomp.to_i
    bs = gets.split.map(&:to_i)

    bs.sort!

    ans = bs.inject(-1) do |ave, i|
      if ave == -1
        i
      else
        (ave + i) / 2.0
      end
    end

    puts ans
  end
end

if __FILE__ == $0
  Solver.new.main
end


Measured memory_bytes: 2172
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author Kishan Sairam Adapa
 */

#include <algorithm>
#include <array>
#include <bitset>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <limits>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>

#define ll long long int
#define MOD ((int)(1e9) + 7)

using namespace std;

class CLowElements {
public:
    void solve(istream& cin, ostream& cout) {
        int n; cin >> n;
        int curr_min = INT_MAX; int cnt = 0;
        for(int i=0; i<n; i++) {
            int tp; cin >> tp;
            if(tp <= curr_min) {
                curr_min = tp;
                cnt++;
            }
        }
        cout << cnt << '\n';
    }
};


int main() {
    std::ios_base::sync_with_stdio(false);
    std::cin.tie(NULL);
    CLowElements solver;
    std::istream& in(std::cin);
    std::ostream& out(std::cout);
    solver.solve(in, out);
    return 0;
}


Measured memory_bytes: 384
def printfull(x):
	l = ''
	for _ in range(x):
		l += '#'
	return l

def printmid(x):
	l = ''
	for i in range(x):
		if i == 0 or i == x-1:
			l+= '#'
		else:
			l+= '.'
	return l
		
while True:
	try:
		line = input()
		if line != '0 0':
			dim = line.split(' ')
			dim = list(map(int, dim))
			
			for i in range(dim[0]):
				if i ==0 or i == dim[0]-1:
					print(printfull(dim[1]))
				else:
					print(printmid(dim[1]))
			print('')
			
		else:
			break
		
	except EOFError:
		break




Measured memory_bytes: 5624
#include <bits/stdc++.h>
#define rep(i,n)for(long long i=0;i<(n);i++)
using namespace std;
using P=pair<long long,long long>;
typedef unsigned long long ull;
typedef long long ll;
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; }
 
const ll MOD=1e9+7;
const ll INF=1e18;
const double pi=acos(-1);
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};


int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);  
  
  int n;
  cin >> n;
  vector<int>vec(n+1);
  rep(i,n) cin >> vec[i+1];
  int M=0;
  bool ok=false;
  int res=1;
  rep(i,n){
    if(vec[i+1]==1)ok=true;
    if(vec[i]==1 && vec[i+1]==1)res++;
    else{
      M=max(M,res);
      res=1;
    }
  }
  M=max(M,res);
  if(ok)cout << M+1 << endl;
  else cout << 1 << endl;
}



Measured memory_bytes: 3184
#include <stdio.h>
int main(){
  int cnt=0;
  char s[4]={0}, t[4]={0};
  scanf("%s %s", s, t);
  if( s[0]==t[0] ){ cnt++; }
  if( s[1]==t[1] ){ cnt++; }
  if( s[2]==t[2] ){ cnt++; }
  printf("%d\n", cnt);
  return 0;
}

Measured memory_bytes: 1688
package main

import (
	"fmt"
)

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

	var a uint64
	var max, d uint64
	max = 0
	d = 0
	for i := 0; i < n; i++ {
		fmt.Scan(&a)
		if i == 0 {
			max = a
		}
		if max < a {
			max = a
		} else {
			d += max - a
		}

	}
	fmt.Println(d)
}


Measured memory_bytes: 6416
#include <bits/stdc++.h>
using namespace std;
#define fo(x, n) for(int i = x; i <= n; i++)
#define all(x) x.begin(), x.end()
typedef long long ll;
typedef pair<int, int> pii;
typedef vector <int> vi;
const int MOD = 1e9 + 7;
bool bad[10];
bool ok(int x){
    while(x > 0){
        if(bad[x % 10]) return false;
        x /= 10;
    }
    return true;
}
void solve(){
    int n, k;
    cin >> n >> k;
    fo(1, k){
        int d;
        cin >> d;
        bad[d] = 1;
    }
    for(int i = n; i <= 10 * n; i++){
        if(ok(i)){
            cout << i;
            break;
        }
    }
}
int main(){
    ios::sync_with_stdio(false); cin.tie(0);
	int T = 1;
    //cin >> T;
    fo(1, T){
        solve();
    }
}



Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <string>
#include <sstream>
#include <algorithm>
#include <vector>
#include <utility>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <functional>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <cassert>
 
using namespace std;
 
#define REP(i,s,e) for(int i=(s); i<(int)(e); i++)
#define rep(i,n) REP(i, 0, n)
#define pb push_back
#define mp make_pair
#define all(r) (r).begin(),(r).end()
#define rall(r) (r).rbegin(),(r).rend()
#define fi first
#define se second
 
typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vii;
typedef vector<ll> vl;
typedef vector<vl> vll;
typedef pair<int, int> pii;
typedef pair<double, int> pdi;
typedef pair<ll, ll> pll;
 

 
const int INF = 1000000;
const double EPS = 1e-8;
const int mod = 1e9 + 7;
const double INF_D = 1e18;

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


int dp[110][110];
bool ng[2][110][110];
bool used[110][110];


int main(){
	int n, p, t;
	int gx, gy;
	pii p1, p2;


	int x, y, nx, ny;
	cin>>n;
	while(n--){
		
		rep(i, 110) rep(j, 110){
			rep(k, 2) ng[k][i][j]=false;
			dp[i][j]=0;
			used[i][j] = false;
		}
		cin>>gx>>gy>>p;
		
		//cout<<" "<<n<<" "<<p<<endl;

		rep(i, p){
			cin>>p1.fi>>p1.se>>p2.fi>>p2.se;
			if(p1 > p2) swap(p1, p2);
			if(p1.fi != p2.fi){
				ng[0][p1.fi][p1.se] = true;
			}
			else{
				ng[1][p1.fi][p1.se] = true;
			}
		}

		queue<int> q;
		dp[0][0]=1;
		q.push(0);
		used[0][0]=true;
		while(!q.empty()){
			t = q.front(); q.pop();
			x = t /100; y = t%100;
			//assert(x < 100 && y < 100);
			if(x > 15 || y > 15) continue;
			if(x == gx && y == gy) break;
			rep(i, 2){
				if(ng[i][x][y]) continue;
				nx = x + dx[i];
				ny = y + dy[i];
				dp[nx][ny] += dp[x][y];
				if(used[nx][ny]) continue;
				q.push(nx*100+ny);
				used[nx][ny]=true;
			}
		}
		if(dp[gx][gy] == 0){
			cout<<"Miserable Hokusai!"<<endl;
			continue;
		}
		cout<<dp[gx][gy]<<endl;
		//cout<<dp[0][0]<<" "<<dp[0][1]<<" "<<dp[1][1]<<endl;
	}
}

Measured memory_bytes: 1288
n = int(input())
arms = []  # [s, t]のリスト
for _ in range(n):
    x, l = map(int, input().split())
    arms.append([x-l, x+l])
ans = 0
pre_t = -1 * float('inf')
arms.sort(key=lambda arm: arm[1])
for i in range(n):
    s, t = arms[i]
    if s >= pre_t:
        ans += 1
        pre_t = t
print(ans)

Measured memory_bytes: 25504
// D.

#include <iostream>
#include <sstream>
#include <algorithm>
#include <cstdio>
#include <cstring>
#include <vector>

using namespace std;

int main(int argc, char *argv[])
{
	int n, k;
	cin >> n >> k;
  static int f[4000][4000];
  for (int i = 0; i < n; ++i) {
    int x, y;
    cin >> x >> y;
    char c;
    cin >> c;
    if (c == 'B') {
      x += k;
    }
    for (int p = 0; p < 4; ++p) {
      for (int q = 0; q < 2; ++q) {
        f[(y + p * k) % (4 * k)][(x + ((p % 2) + q * 2) * k) % (4 * k)] += 1;
      }
    }
  }

  static int sum[4000][4000];
  for (int i = 0; i < 4 * k; ++i) {
    int t = 0;
    for (int j = 0; j < 4 * k; ++j) {
      t += f[i][j];
      sum[i][j] = t + (i == 0 ? 0 : (sum[i-1][j]));
    }
  }
  int ans = 0;
  for (int i = 0; i <= 3 * k; ++i) {
    for (int j = 0; j <= 3 * k; ++j) {
      int t = sum[i + k - 1][j + k - 1];
      if (i) {
        t -= sum[i - 1][j + k - 1];
      }
      if (j) {
        t -= sum[i + k - 1][j - 1];
      }
      if (i && j) {
        t += sum[i - 1][j - 1];
      }
      ans = max(ans, t);
    }
  }
  cout << ans << endl;
  return 0;
}


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

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

    ll ans = 1;
    rep(i, n) {
        if (i == 0)
            ans *= k;
        else
            ans *= (k - 1);
    }

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

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
using namespace std;
#define ll long long
#define INF (ll)(1e19)
#define MAX_V 60
#define x 1
#define y 0

pair<int,int> zx[MAX_V], zy[MAX_V];

ll N, K;



ll solve(){
	ll ans = INF;
	sort(zx,zx+N);
	sort(zy,zy+N);
	
	// for(int i = 0; i < N; i++)
		// cout<<zx[i].first<<" "<<zy[i].second<<endl;
	
	
	for(int i = 0; i < N; i++){
		for(int j = 0; j < N; j++){
			if(zy[N-i-1].first  < zy[j].first) break;
			for(int k = 0; k < N; k++){
				for(int l = 0; l < N; l++){
					ll up = zy[N-i-1].first,lo = zy[j].first,ri = zx[N-k-1].first,le = zx[l].first;
					if(ri < le) continue;
					ll sq = (up-lo)*(ri-le), count = 0;
					// cout<<sq<<" "<<(up-lo)<<" "<<(ri-le)<<endl;
					if(ans <= sq) continue;
					for(int m = 0; m < N; m++){
						if(zx[m].first >= le && zx[m].first <= ri && zx[m].second <= up && zx[m].second >= lo){
							count++;
						}
						if(count >= K)break;
					}
					//cout<<"count = "<<count<<endl;
					if(count >= K) ans = min(ans, sq);
					// if(ans < 0) ans = INF;
					// cout<<ans<<endl;
				}
			}
		}
	}
	return ans;
}


int main(){
	int X, Y;
	
	cin>>N>>K;
	
	for(int i = 0; i < N; i++){
		cin>>X>>Y;
		zx[i] = make_pair(X,Y);
		zy[i] = make_pair(Y,X);
	}
	

	cout<<solve()<<endl;
	
	return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>
#include <cstring>
#include <iomanip>

using namespace std;

int main(){
   string S;
   cin >> S;
   int size =  S.size();
   bool ok = true;
   for(int i = 0; i < size/2; i++){
      if(S[i]!=S[size-1-i]) ok = false;
      if(S[i]!=S[size/2-1-i]) ok = false;
      if(S[size-1-i]!=S[size/2+1+i]) ok = false;
   }
   if(ok){
      cout << "Yes" << endl;
   }
   else{
      cout << "No" << endl;
      }
   return 0;
}


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

void solve() {
    int n, x, t; cin >> n >> x >> t;
    int k = n/x;
    if((n%x) != 0) {
        k ++;
    }
    cout << k * t << endl;
}


int32_t main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    int t = 1;
    // cin >> t;
    while(t --) {
        solve();
    }
    return 0;
}

Measured memory_bytes: 3600
a=list(map(str,input()))
n=len(a)
b=[[] for i in range(2**(n-1))]
for i in range(2**(n-1)):
    for j in range(n-1):
        if ((i >> j) & 1) ==1:
            b[i].append("+")
        else:
            b[i].append("-")

for j in range(2**(n-1)):
    result = [None]*(n+n-1)
    result[::2]=a
    result[1::2]=b[j]
    ans=eval(''.join(result))
    if ans==7:
        aa=[''.join(result),"=",str(ans)]
        print(''.join(aa))
        exit()


Measured memory_bytes: 3064
import sys
import bisect
input = sys.stdin.readline

def main():
    N = int(input())
    l = sorted(list(map(int, input().split())))
    memo = [-1] * (l[-2] + l[-1] + 1)
    ans = 0
    for i in range(N):
        for j in range(i+1, N):
            a = l[i]
            b = l[j]
            if memo[a + b] == -1:
                right = bisect.bisect_left(l, a + b)
                memo[a + b] = right
            else:
                right = memo[a + b]
            ans += max(0, right - j - 1)
    print(ans)


if __name__ == "__main__":
    main()

Measured memory_bytes: 3188
from itertools import chain
a, b, k = map(int, input().split(" "))
r1 = range(a, min(b + 1, a + k))
r2 = range(max(a, b - k + 1), b + 1)
ans = sorted(set((chain(r1, r2))))
print('\n'.join(str(x) for x in ans))


Measured memory_bytes: 3064
#include <cstdio>
#include <algorithm>

using namespace std;

int main()
{
	int cup[]={1,0,0};
	for(char a,b;scanf("%c,%c ",&a,&b)==2;)
		swap(cup[a-'A'],cup[b-'A']);
	
	for(int i=0;i<3;i++)
		if(cup[i]){
			printf("%c\n",'A'+i);
			break;
		}
	
	return 0;
}

Measured memory_bytes: 0
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#define INPUT(X) cin >> X
#define OUTPUT(X) cout << X << endl

using namespace std;




int main(void) {

	string S;
	int N, D;
	int X[10][10];
	int dist2=0;
	int count=0;
	INPUT(N);
	INPUT(D);
	for( int i=0; i<N; i++){
		for( int d=0; d<D; d++){
			INPUT(X[i][d]);
		}
	}
	
	for( int i=0; i<N; i++){
	for( int j=i+1; j<N; j++){
		if( j == N ) break;
		dist2 = 0;
		for( int d=0; d<D; d++) dist2 += (X[i][d]-X[j][d])*(X[i][d]-X[j][d]);		
		for( int k = 0 ; k <= 40*40 ; k++ ){
			if( k*k == dist2 ){
				count++;
				break;		
			}		
		}		
		
	}
	}
	

	
	OUTPUT(count);

}

Measured memory_bytes: 256
#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);
  }
  int S, e;
  S = 0;
  e = 0;
  for (int i = 0; i < N; i++) {
    e += d.at(i) * d.at(i);
    for (int j = 0; j < N; j++) {
      S += d.at(i) * d.at(j);
    }
  }
  cout << (S - e) / 2 << endl;
}


Measured memory_bytes: 256
/*
  C - Boxes and Candies
  <http://abc048.contest.atcoder.jp/tasks/arc064_a>
  [Tips]
  ・callocはヒープ領域からメモリの割り当てを行うため遅い<https://oshiete.goo.ne.jp/qa/1726895.html>
*/

#include <stdio.h>

typedef long int int32_t;
typedef long long int int64_t;

int main(int argc, char const *argv[]) {

  int32_t N, x, a, a_next;
  int32_t i;
  int32_t cnt;

  scanf("%ld %ld", &N, &x);

  cnt = 0;
  a = 0;
  for( i=0; i<N; i++ ){
    scanf("%ld", &a_next);
    if( (a+a_next) > x ){
      cnt += (a+a_next) - x;
      a_next = x-a;
    }
    a = a_next;
  }

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


Measured memory_bytes: 128
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> // Common file
#include <ext/pb_ds/tree_policy.hpp> // Including tree_order_statistics_node_update
#define ll long long
#define PI 3.141592653589
#define IO ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define EPS 1e-7
#define f first
#define s second
using namespace std;
using namespace __gnu_pbds;
typedef tree<int, null_type, less<int>, rb_tree_tag,
             tree_order_statistics_node_update>
    ordered_set;
const ll MOD = 1e9+7;
const int RANDOM = chrono::high_resolution_clock::now().time_since_epoch().count();
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
int random_int(int l,int r){return uniform_int_distribution<int>(l,r)(rng);}
ll fast_power(ll x, ll p){
    ll res = 1;
    while(p > 0){
        if(p & 1){
            res = (res * x);
        }
        p = p >> 1;
        x = (x*x);
    }
    return res;
}
int a[17][17];
ll  maskanswer[(1 << 17)];
vector<vector<int>> maskChildren;
int n;
ll dp[(1 << 17)];
bool done[(1 << 17)];
void bruteChild(int mask, int pos, int original) {
    if (pos == n)
        return;
    if (mask != original)
        maskChildren[original].push_back(mask);
    if ((1 << pos) & mask) {
        bruteChild(mask & (~(1 << pos)), pos + 1, original);

    }
    bruteChild(mask, pos + 1, original);
}

void bruteMask(int mask) {

    if (maskChildren[mask].size() != 0) return;
    bruteChild(mask, 0, mask);
    ll ans = 0;
    for (int i = 0; i < n; i++) {
        if (!(mask & (1 << i))) continue;
        for (int j = i + 1; j < n; j++) {
            if (!(mask & (1 << j))) continue;
            ans += a[i][j];
        }
    }
    maskanswer[mask] = ans;
    int first = 1;
    for (int i = 0; i < n; i++) {
        if (mask & (1 << i)) {
            int child = mask & (~(1 << i));
            bruteMask(child);
        }
    }
}

ll solve(int mask) {
    if (!mask) return 0;
    if (done[mask]) return dp[mask];
    done[mask] = 1;
    ll ans = max(maskanswer[mask], (ll)0);
    for (int child: maskChildren[mask]) {
        ans = max(ans, solve(child ^ mask) + maskanswer[child]);
    }
    return dp[mask] = ans;
}


int main() {
    IO;
    cin >> n;
    maskChildren.resize(1 << n);
    for (int i = 0; i < n; i++)
        for (int j = 0; j < n; j++)
            cin >> a[i][j];
    bruteMask((1 << n) - 1);
    cout << solve((1 << n) - 1);
    return 0;
}


Measured memory_bytes: 444424
#include "bits/stdc++.h"
#include <sys/timeb.h>
#include <fstream>

using namespace std;

#define repl(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define rep(i,n) repl(i,0,n)
#define replrev(i,a,b) for(int i=(int)(b)-1;i>=(int)(a);i--)
#define reprev(i,n) replrev(i,0,n)
#define repi(itr,ds) for(auto itr = ds.begin(); itr != ds.end(); ++itr)
#define all(a) a.begin(),a.end()
#define mp make_pair
#define INF 2000000000
#define INFL 1000000000000000000LL
#define EPS 1e-9
#define MOD 1000000007
#define PI 3.1415926536
#define RMAX 4294967295

typedef long long ll;
typedef pair<int, int> P;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<bool> vb;
typedef vector<char> vc;
typedef vector<string> vs;
typedef vector<double> vd;
typedef vector<P> vP;
typedef vector<vector<int> > vvi;
typedef vector<vector<bool> > vvb;
typedef vector<vector<ll> > vvll;
typedef vector<vector<char> > vvc;
typedef vector<vector<double> > vvd;
typedef vector<vector<P> > vvP;
typedef priority_queue<int, vector<int>, greater<int> > pqli;
typedef priority_queue<ll, vector<ll>, greater<ll> > pqlll;
typedef priority_queue<P, vector<P>, greater<P> > pqlP;
typedef pair<int, pair<int, int> > Edge;
typedef vector<Edge> vE;
typedef priority_queue<Edge, vector<Edge>, greater<Edge> > pqlE;

int main() {
	ll H, W;
	cin >> H >> W;
	if (H % 3 == 0 || W % 3 == 0) {
		cout << 0 << endl;
	}
	else {
		ll ans = INFL, a, b, c;
		repl(i, 1, H) {
			a = i * W, b, c;
			b = (H - i)*((W + 1) / 2);
			c = (H - i)*(W / 2);
			ans = min(ans, abs(max(a, max(b, c)) - min(a, min(b, c))));
		}
		repl(i, 1, W) {
			a = i*H, b, c;
			b = (W - i)*((H + 1) / 2);
			c = (W - i)*(H / 2);
			ans = min(ans, abs(max(a, max(b, c)) - min(a, min(b, c))));
		}
		if (W >= 3) {
			a = H*(W / 3);
			b = H*((W + 2) / 3);
			ans = min(ans, abs(a - b));
		}
		if (H >= 3) {
			a = W*(H / 3);
			b = W*((H + 2) / 3);
			ans = min(ans, abs(a - b));
		}

		cout << ans << endl;
	}

	return 0;
}

Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS
#include <cstdio>
#include <vector>
using namespace std;

int main()
{
    int N;
    if (scanf("%d", &N) < 1) return 0;

    vector<int> A;
    vector<int> B;
    A.resize(N);
    B.resize(N);

    for (int i = 0; i < N; i++)
    {
        if (scanf("%d%d", &A[i], &B[i]) < 2) return 0;
    }

    long long int push = 0LL;
    for (int i = N - 1; 0 <= i; i--)
    {
        long long int a = (A[i] + push) % B[i];
        if (a > 0LL)
        {
            push += B[i] - a;
        }
    }

    printf("%lld\n", push);
    return 0;
}


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

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

int main(){
    int N;
    cin >> N;
    vector<ll> A(N);
    for (int i = 0; i < N; i++) cin >> A.at(i);

    ll ans = 0;
    for (int i = 1; i < N; i++) {
        if (A.at(i - 1) > A.at(i)) {
            ans += (A.at(i - 1) - A.at(i));
            A.at(i) += (A.at(i - 1) - A.at(i));
        }
    }
    cout << ans << endl;
    return 0;
}

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

using namespace std;

int main() {
    string s;
    cin >> s;
    bool j = true;

    for(int i = 0; i < 3 ; i++) {
        if(s[i] == s[i+1]){
            j = false;
            break;
        }
    }
    if(j){
        cout << "Good" << endl;
    }
    else{
        cout << "Bad" << endl;
    }

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using ll = long long;
using ld = long double;
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
#define rep3(i, n) for (int i = 1; i < (int)(n+1); i++)
#define rep4(i, s, n) for (int i = (s); i < (int)(n+1); i++)
#define repr(i,n) for (int i = (n-1); i>=0;i--)
#define repr2(i,s,n) for (int i = (n-1); i>=(int)(s);i--)
#define repr3(i,n) for(int i = (n);i>0;i--)
#define stlen(s) ll s.size()-1
#define all(v) v.begin(), v.end()
#define cout(n) cout<<std::fixed<<std::setprecision(n)
using Graph = vector<vector<int>>;
using Grid = vector<vector<int>>;
const ll INF = 10011032323450010;
const ld PI = 3.14159265358979323846;



int main() {
    string A,B,C;
    cin>>A>>B>>C;
    if((A[A.size()-1]==B[0])&&(B[B.size()-1]==C[0])){
        cout<<"YES"<<endl;
    }
    else{
        cout<<"NO"<<endl;
    }

return 0;
}

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

public class Main{

	public static void main(String[] args) throws NumberFormatException, IOException {
		// TODO Auto-generated method stub
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		int n = Integer.parseInt(br.readLine());
		String[] s = br.readLine().split(" ");
		int array[] =  new int[s.length];
		for(int i = 0 ; i< n ; i++) {
			array[i] = Integer.parseInt(s[i]);
		}
		int min = Integer.MAX_VALUE;
		int count = 0;
		for(int i = 0 ; i< n ; i++) {
			if(array[i] < min) {
				count++;
				min = array[i];
			}
		}
		System.out.println(count);
		
	}

}


Measured memory_bytes: 49748
#include<bits/stdc++.h>
using namespace std;
int main(){
    int MaxLength=0;
    string Str;
    cin >> Str;
    int i=0;
    int N=0;
    while(i<Str.length()){
        if(
            Str.at(i)=='A' or
            Str.at(i)=='T' or
            Str.at(i)=='G' or
            Str.at(i)=='C'
        ){
            N++;
        }else{
            N=0;
        }
        if(MaxLength<N) MaxLength = N;
        i++;
    }
    //printf("%d",MaxLength);
    cout << MaxLength;
    return 0;
}

Measured memory_bytes: 256
until (n = gets.chomp.to_i) == 0 ? true:false

  sum_a,sum_b = 0,0 
  n.times do
    nums = gets.split(" ").map{|x| x.to_i}
    if nums[0] == nums[1]
      sum_a += nums[0]
      sum_b += nums[1]
    elsif nums[0] > nums[1]
      sum_a += nums[0] + nums[1]
    else
      sum_b += nums[0] + nums[1]
    end
    nums.clear  
  end
  printf("%d %d\n",sum_a,sum_b)
end

Measured memory_bytes: 6120
#include <stdio.h>
#include <math.h>
#include <string.h>
#include <stdbool.h>  //for bool
#include <stdlib.h> // abs,labs,llabs
#include <limits.h>
#include <ctype.h>

typedef long long int ll;
typedef unsigned long long int ull;
typedef long double ld; //%Lf

int main(void) {
  int k, x, i;
  scanf("%d %d", &k, &x);
  k = k - 1;
  for (i = (x - k); i <= (x + k); i++) {
    printf("%d ", i);
  }
  return 0;
}


Measured memory_bytes: 128
module Main where

import           Control.Monad
import           Data.List

main :: IO ()
main = do
    [h, _] <- map read . words <$> getLine
    ass <- replicateM h getLine
    putStr $ solve ass

solve :: [String] -> String
solve = unlines . transpose . filter (any (== '#')) . transpose . filter (any (== '#'))

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

int main(){
  string s;
  cin >> s;
  
  int ans = 1;
  for (int i=0 ; i<s.size() ; i++){
    if (i%2 == 0){
      if (s.at(i) == 'L'){
        ans = 0;
        break;
      }
    }
    else{
      if (s.at(i) == 'R'){
        ans = 0;
        break;
      }
    }
  }
  
  if (ans == 1)
    cout << "Yes" << endl;
  else
    cout << "No" << endl;
}

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


int main(){
  
//  bool torf=false;
  int N,count=0;
  cin >> N;
  
  vector<int> a(N);
  vector<int> c(N,0);
  
  
  rep(i,N){
    cin >> a.at(i);
    if(a.at(i)>N)
      count++;
    else
      c.at(a.at(i)-1)++;
  }
  
  //cout << count << endl;
  
  rep(i,N){
    if(c.at(i)!=0 && c.at(i)>i+1)
      count+=(c.at(i)-(i+1));
    else if(c.at(i)!=0 && c.at(i)<i+1)
      count+=c.at(i);
  }
  
  cout << count << endl;
  
 }



Measured memory_bytes: 1024
#include <stdio.h>

int main () {
	char N[5];
	scanf ("%s", N);
	if (N[1]==N[2]) {
		if (N[0]==N[1] || N[2]==N[3])
			printf ("Yes\n");
		else
			printf ("No\n");
	} else
		printf ("No\n");
	return 0;
}



Measured memory_bytes: 128
#include<stdio.h>
main(){
  int n,b,f,r,v,i,j,k;
  int count[4][3][10]={};
  scanf("%d",&n);
  for(i=0;i<n;i++){
    scanf("%d%d%d%d",&b,&f,&r,&v);
    count[b-1][f-1][r-1]+=v;
  }
  for(i=0;i<4;i++){
    for(j=0;j<3;j++){
      for(k=0;k<10;k++){
        printf(" %d",count[i][j][k]);
      }
      printf("\n");
    }
    if(!(i==3)){
      for(k=0;k<20;k++){
        printf("#");
      }
      printf("\n");
    }
  }
  return 0;
}

Measured memory_bytes: 600
#include<bits/stdc++.h>
using namespace std;
map<int,int> m;
void fac(int n){
  int r=n;
  for(int i=2;i*i<=n;i++){
    int exp=0;
    while(r%i==0){
      exp++;
      r/=i;
      }
      m[i]+=exp;
  }
  if(r!=1){m[r]++;}
}
int main(){
  int n;cin>>n;
  long long ans=1;
  for(int i=2;i<=n;i++){
    fac(i);
  }
  for(auto it=m.begin();it!=m.end();it++){
    ans*=(*it).second+1;
    ans=ans%1000000007;
  }
  cout<<ans;
}

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

int main(int argc, char *argv[]) {
  ios::sync_with_stdio(false);
	cin.tie(nullptr);
	cout.tie(nullptr);

  string s,t;cin>>s>>t;
  int res=0;
  for(int i=0;i<3;i++){
    if(s[i]==t[i])res++;
  }
  cout<<res<<endl;

  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define FIN ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);

typedef long long ll;
typedef vector<ll> vll;

int main() {FIN
	
	ll n, k, i, j;
	cin >> n >> k;
	vll tp(n), pt(n, -1);
	for (i = 0; i < n; i++)
		cin >> tp[i];
	
	i = 0; j = 0;
	while (pt[i] == -1) {
		pt[i] = j++;
		i = (tp[i] - 1);
		k--;
		if (k == 0)
			break;
	}
	k = k % (j - pt[i]);
	while (k > 0) {
		i = (tp[i] - 1);
		k--;
	}
	
	cout << i + 1 << "\n";
		
	return 0;
}


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

int main() {
    string S;  cin >> S;
    int now = 0;
    for (int i = 0; i < S.size(); ++i) {
        if (S[i] == '+') ++now;
        else --now;
    }
    cout << now << endl;
}


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

int a[1000000],n;

int binarysearch(int key){
	int left=0,right=n,mid;
	while(left<right){
		mid=(left+right)/2;
		if(key==a[mid])return 1;
		if(key>a[mid]) left=mid+1;
		else if(key<a[mid]) right=mid;
	} 
	return 0;
}

int main(){
	int i,q,k,sum=0;
	
	cin>>n;
	for(i=0;i<n;i++){
		cin>>a[i];
	}
	
	cin>>q;
	for(i=0;i<q;i++){
		cin>>k;
		if(binarysearch(k)) sum++;
	}
	cout<<sum<<endl;
	
	return 0;
}



Measured memory_bytes: 3456
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define rep(i, n) for (ll i = 0; i < n; i++)
#define FOR(i, a, b) for (ll i = a; i < b; i++)
#define is(a, b) a == b
#define len(v) ll(v.size())

class UnionFind {
public:
	vector<int> par;//親の番号
    vector<int> rank;//木の深さ
 
	UnionFind(int n){//全ての要素に対して自身が根となるように初期化, 木の深さは0になる
		rep(i,n){
            par.push_back(i);
            rank.push_back(0);
        }
	}
 
	int find(int x) {//木の根を求める
		if(par[x]==x){
            return x;
        }else{
            return par[x]=find(par[x]);
        }
	}
 
	void unite(int x,int y){//xとyの属する集合を併合
        x=find(x);
        y=find(y);
        if(x==y) return;
        if(rank[x]<rank[y]){//木の深さが小さい方を大きい方へ繋げる
            par[x]=y;
        }else{
            par[y]=x;
            if(rank[x]==rank[y]) rank[x]++;
        }
    }

    bool same(int x,int y){//xとyが同じ集合に属するか否か
        return find(x)==find(y);
    }
};
//x以下の要素への最小index, ソートしてから使ってね
template <class T> 
int former(const vector<T> &v, T x){
  return upper_bound(v.begin(), v.end(), x) - v.begin() - 1;
}
//x以上の要素への最小index
template <class T> 
int latter(const vector<T> &v, T x){
  return lower_bound(v.begin(), v.end(), x) - v.begin();
}
//vector書き出し
template <class T>
void cout_vec(const vector<T> &vec1){
  rep(i,len(vec1)){
    cout<<vec1[i]<<' ';
  }
  cout<<'\n';
}
//nCk
template <class T>
T comb(T n,T k){
    T ans=1;
    FOR(i,n-k+1,n+1){
        ans*=i;
    }
    FOR(i,1,k+1){
        ans/=i;
    }
    return ans;
}
//a,bの最大公約数
template <class T>
T gcd(T a,T b) {
	if (b == 0) return a;
	else return gcd(b, a % b);
}
//素因数分解
template <class T>
map<T,T> prime_factor(T x){
    map<T,T> ans;
    for(T i=2;i*i<=x;i++){
        while(x%i==0){
            x/=i;
            ans[i]++;
        }
    }
    if (x!=1){
        ans[x]=1;
    }
    return ans;
}
//約数列挙
template <class T>
vector<T> divisor(T x){
    vector<T> res;
    for(T i=1;i*i<=x;i++){
        if(x%i==0){
            res.push_back(i);
            if(i!=x/i){
                res.push_back(x/i);
            }
        }
    }
    return res;
}
//素数判定
template <class T>
bool is_prime(T x){
    for(T i=2;i*i<=x;i++){
        if(x%i==0){
            return false;
        }
    }
    return x!=1;
}

const ll inf=1e9+7;

ll mult(ll n,ll m){//n^m%infを求める
    if(m==1){
        return n%inf;
    }else if(m%2==0){//オーバーフロー防止のためにn^(m/2)*n^(m/2)を考える
        ll t=mult(n,m/2);
        return (t*t)%inf;
    }else{//奇数の時はn^(m-1)*nを考える
        ll t=mult(n,m-1);
        return (t*n)%inf;
    }
}

typedef pair<ll,ll> P;

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int a,b,c,x;
    cin>>a>>b>>c>>x;
    int ans=0;
    rep(i,a+1){
        rep(j,b+1){
            rep(k,c+1){
                if(500*i+100*j+50*k==x){
                    ans++;
                }
            }
        }
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 256
n = int(input())
a = []
ans = 0
for i in range(n):
    a.append(sorted(input()))
a.sort()
flg = 0
for i in range(1,n):
    if a[flg] != a[i]:
        z = i - 1 - flg
        ans += (1 + z) * z // 2
        flg = i
z = n - 1 - flg
ans += (1 + z) * z // 2
print(ans)

Measured memory_bytes: 30780
#include<bits/stdc++.h>
using namespace std;
#define rep(i,a,n) for(int i=a;i<n;i++)
#define pb push_back
typedef vector<int> VI;
typedef vector<bool> VB;

int main() {
	int n,m,a,b,u;
	cin>>n>>m;

	VI adj[n+1];
	VI p(n+1,-1), d(n+1,0);
	VB vis(n+1,false);

	while(m--) {
		cin>>a>>b;
		adj[a].pb(b);
		adj[b].pb(a);
	}

	queue<int> q;
	int tot=0;
	vis[1]=true;
	q.push(1);
	while(!q.empty()) {
		u = q.front();
		q.pop();
		tot++;
		for(auto v:adj[u]) {
			if(!vis[v]) {
				p[v]=u;
				d[v]=1+d[u];
				vis[v]=true;
				q.push(v);
			}
		}
	}

	if(tot<n)
		cout<<"No\n";
	else {
		cout<<"Yes\n";
		rep(i,2,n+1) cout<<p[i]<<"\n";
	}
	return 0;
}



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

using namespace std;

#define pb push_back
#define mp make_pair
#define forn(i, n) for (int i = 0; i < (int)(n); ++i)
typedef long long LL;
typedef pair<LL, LL> PII;

int n, from, to;
LL a[50];
PII d[51][51];

void add(PII &a, PII b) {
    if (b.first > a.first) {
        a = b;
    } else if (b.first == a.first) {
        a.second += b.second;
    }
}

int main() {
    cin >> n >> from >> to;
    forn(i, n) cin >> a[i];
    forn(i, 51) forn(j, 51) {
        d[i][j] = mp(-1, 0);
    }
    d[0][0] = mp(0, 1);
    forn(i, n) forn(j, n) if (d[i][j].first != -1) {
        add(d[i + 1][j], d[i][j]);
        add(d[i + 1][j + 1], mp(d[i][j].first + a[i], d[i][j].second));
    }
    LL num = 0, denom = 1;
    LL cnt = 0;
    for (int i = from; i <= to; ++i) {
        LL nnum = d[n][i].first;
        LL ndenom = i;
        LL ncnt = d[n][i].second;
        if (nnum * denom > num * ndenom) {
            num = nnum;
            denom = ndenom;
            cnt = ncnt;
        } else if (nnum * denom == num * ndenom) {
            cnt += ncnt;
        }
    }
    printf("%.15f\n", (double)num / denom);
    cout << cnt << endl;
    return 0;
}


Measured memory_bytes: 256
import sys, re, os
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians, acos, atan, asin
from itertools import permutations, combinations, product, accumulate
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from fractions import gcd
def input(): return sys.stdin.readline().strip()
def STR(): return input()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def S_MAP(): return map(str, input().split())
def LIST(): return list(map(int, input().split()))
def S_LIST(): return list(map(str, input().split()))
def lcm(a, b): return a * b // gcd(a, b)
sys.setrecursionlimit(10 ** 9)
inf = sys.maxsize
mod = 10 ** 9 + 7
dx = [0, 0, 1, -1, 1, -1, -1, 1]
dy = [1, -1, 0, 0, 1, -1, 1, -1]

n, a, b, c, d = MAP()
s = STR()

dp1 = [inf for _ in range(n + 1)]
dp1[a] = 0
dp1[a - 1] = 0
for i in range(a + 1,c + 1):
    if s[i - 1] == '.':
        dp1[i] = min(dp1[i - 1], dp1[i - 2]) + 1
dp2 = [inf for _ in range(n + 1)]
dp2[b] = 0
dp2[b - 1] = 0
for i in range(b + 1, d + 1):
    if s[i - 1] == '.':
        dp2[i] = min(dp2[i - 1], dp2[i - 2]) + 1

if a < b and c < d or a > b and c > d:
    if dp1[c] < inf and dp2[d] < inf:
        print('Yes')
    else:
        print('No')
else:
    if a > b and c < d:
        a, b = b, a
        c, d = d, c
    flag = False
    for i in range(b, d + 1): #抜かす場所
        if s[i - 2:i + 1] == '...': #抜かせる
            flag = True
            break
    if dp1[c] < inf and dp2[d] < inf and flag:
        print('Yes')
    else:
        print('No')


Measured memory_bytes: 86948
#include <cassert>
#include <cctype>
#include <cstdio>
#include <cstdlib>
#include <ctime>
#include <algorithm>
#include <vector>
#include <string>
#define REP(i, n) for(int i = 0; i < (int)(n); ++i)

using namespace std;

int main(void) {
  int n, k;
  scanf("%d%d", &n, &k);
  double res = 0;
  for(int d = 1; d <= n; ++d) {
    double p = 1.0 / n;
    int cur = d;
    while(cur < k) {
      cur *= 2;
      p /= 2;
    }
    res += p;
  }
  printf("%.10f\n", res);
  return 0;
}


Measured memory_bytes: 760
//A,Elebereth Gilthoniel mantae!
//For Temeria!
#include<iostream>
#include<algorithm>
#include<cmath>
#include<string>
#include<vector>
#include<set>
#include<cstdio>
#include<map>
#include<stack>
#include<queue>
#include<cstring> 
using namespace std;
int a[100008],pre[100008],suf[100008];
int main()
{
 	//freopen("","r",stdin);
	//freopen("","w",stdout);
	 int n;
	 cin>>n;
	 for(int i=1;i<=n;i++) 
	 {
	 	cin>>a[i];pre[i]=pre[i-1]+abs(a[i]-a[i-1]);
	 }
	 for(int i=n;i>=1;i--)
	 {
	 	suf[i]=suf[i+1]+abs(a[i]-a[i+1]);
	 }
	 for(int i=1;i<=n;i++)
	 {
	 	cout<<pre[i-1]+suf[i+1]+abs(a[i-1]-a[i+1])<<endl;
	 }
	return 0;
}

Measured memory_bytes: 2432
#include<stdio.h>

int main(void){
    int i,ex1,ex2,ex3,ex4;
    int dice[7];
    char command[200];

    for(i = 1;i <= 6;i++){
        scanf("%d",&dice[i]);
    }

    scanf("%s",command);

    i = 0;
    while(command[i] != '\0'){
        if(command[i] == 'S'){
            ex1 = dice[1];
            ex2 = dice[2];
            ex3 = dice[5];
            ex4 = dice[6];
            dice[1] = ex3;
            dice[2] = ex1;
            dice[5] = ex4;
            dice[6] = ex2;
        }else if(command[i] == 'N'){
            ex1 = dice[1];
            ex2 = dice[2];
            ex3 = dice[5];
            ex4 = dice[6];
            dice[1] = ex2;
            dice[2] = ex4;
            dice[5] = ex1;
            dice[6] = ex3;
        }else if(command[i] == 'E'){
            ex1 = dice[1];
            ex2 = dice[3];
            ex3 = dice[4];
            ex4 = dice[6];
            dice[1] = ex3;
            dice[3] = ex1;
            dice[4] = ex4;
            dice[6] = ex2;
        }else if(command[i] == 'W'){
            ex1 = dice[1];
            ex2 = dice[3];
            ex3 = dice[4];
            ex4 = dice[6];
            dice[1] = ex2;
            dice[3] = ex4;
            dice[4] = ex1;
            dice[6] = ex3;
        }
        i++;
    }
    printf("%d\n",dice[1]);
    return 0;
}

Measured memory_bytes: 596
import static java.lang.Math.*;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.util.InputMismatchException;
import java.util.StringTokenizer;

public class Main {

	public static void main(String[] args) throws IOException {
		InputStream inputStream = System.in;
		OutputStream outputStream = System.out;
		InputReader in = new InputReader(inputStream);
		PrintWriter out = new PrintWriter(outputStream);
		TaskX solver = new TaskX();
		solver.solve(1, in, out);
		out.close();
	}

	static int INF = 1 << 30;
	static long LINF = 1L << 50;
	static int MOD = 1000000007;
	static int[] mh4 = { 0, -1, 1, 0 };
	static int[] mw4 = { -1, 0, 0, 1 };
	static int[] mh8 = { -1, -1, -1, 0, 0, 1, 1, 1 };
	static int[] mw8 = { -1, 0, 1, -1, 1, -1, 0, 1 };

	static class TaskX {

		long[] a;
		public void solve(int testNumber, InputReader in, PrintWriter out) {

			int n = in.nextInt();
			a = new long[n];
			for (int i = 0; i < n; i++) {
				a[i] = in.nextLong() - (i+1);
			}

			long left = -(long)pow(10, 12);
			long right = (long)pow(10, 12);

			for (int i = 0; i < 1000; i++) {
				long c1 = (left * 2L + right) / 3;
				long c2 = (left + right * 2L) / 3;

				if (func(c1) < func(c2)) {
					right = c2;
				} else {
					left = c1;
				}
			}

			long ans = LINF;

			for (long b = left; b <= right; b++) {
				ans = min(ans, func(b));
			}

			out.println(ans);

		}

		long func(long b) {
			long ret = 0;
			for (long l : a) {
				ret += Math.abs(l - b);
			}
			return ret;
		}
	}

	static class InputReader {
		BufferedReader in;
		StringTokenizer tok;

		public String nextString() {
			while (!tok.hasMoreTokens()) {
				try {
					tok = new StringTokenizer(in.readLine(), " ");
				} catch (IOException e) {
					throw new InputMismatchException();
				}
			}
			return tok.nextToken();
		}

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

		public long nextLong() {
			return Long.parseLong(nextString());
		}

		public double nextDouble() {
			return Double.parseDouble(nextString());
		}

		public int[] nextIntArray(int n) {
			int[] res = new int[n];
			for (int i = 0; i < n; i++) {
				res[i] = nextInt();
			}
			return res;
		}

		public long[] nextLongArray(int n) {
			long[] res = new long[n];
			for (int i = 0; i < n; i++) {
				res[i] = nextLong();
			}
			return res;
		}

		public InputReader(InputStream inputStream) {
			in = new BufferedReader(new InputStreamReader(inputStream));
			tok = new StringTokenizer("");
		}
	}

}


Measured memory_bytes: 46924
n,k = map(int,input().split())
arr = list(map(int,input().split()))

exarr = [(i+1)/2 for i in arr]
tmpsum = sum(exarr[:k])
sol = tmpsum

for i in range(n-k):
    tmpsum = tmpsum - exarr[i] + exarr[i+k]
    sol = max(sol,tmpsum)
    
print(sol)

Measured memory_bytes: 25060
n,k=map(int,input().split())
mod=10**9+7
def f(n):
  mod=10**9+7
  return (n*(n+1)//2)%mod
ans=0
for i in range(k,n+2):
  a=f(n)-f(n-i)-f(i-1)+1
  ans+=(a%mod)
print(ans%mod)

Measured memory_bytes: 9204
import java.util.Scanner;
public class Main {
	public static void main(String[] args) {
		Scanner in = new Scanner(System.in);
		String s = in.nextLine();
		String fes = "CODEFESTIVAL2016";
		
		int num = 0;
		for(int i =0;i<fes.length();i++){
			if(s.charAt(i)!=fes.charAt(i)){
				num++;
			}
		}
		System.out.println(num);
	}
}


Measured memory_bytes: 8916
#include "bits/stdc++.h"
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds; 
using namespace std;
#define int long long int
#define IOS ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define vi vector <int>
#define ff first
#define ss second
#define vp vector <pair<int,int>>
#define vpp vector <pair<int,pair<int,int>>>
#define seti set<int>
#define setbit(x) __builtin_popcountll(x)
#define sov(v) accumulate(all(v),0)
#define fs(it,a) for(auto it=a.begin();it!=a.end();it++)
#define pb push_back
#define pob pop_back
#define mp make_pair
#define pqmax priority_queue <int,vector <int>> 
#define pqmin priority_queue <int,vector <int>,greater<int>> 
#define dq deque <int>
#define umi unordered_map<int,int>
#define ums unordered_map<string,int>
#define sp(x,y) fixed << setprecision(y) << x
#define all(x) x.begin(),x.end()
#define f(x,y,z) for(int x=y;x<z;x++)
#define si size()
#define countdigit(x) floor( log10(x) +1)
#define M 1000000007  
//Use (k%M+m)%m always where k is any no
#define PI 3.1415926535
typedef tree<int, null_type, less<int>, rb_tree_tag, 
tree_order_statistics_node_update> pdbs; 
// null for set,mapped_type for map; 
//less for assending greater for descending
//ceil(a/b)=(a+b-1)/b
#define ee "\n"
#define re return 
 
 
 
//Author Rahul Sannigrahi
 
vector<int> take(int n)
{
    int i,j;
    vi v;
    f(i,0,n)
    {
        cin>>j;
        v.pb(j);
    }
    return v;
}
 

void show(vector<int>v)
{
    int i;
    for(i=0;i<v.si;i++)
    {
     cout<<v[i]<<" ";   
    }
    cout<<ee;
}
 
int decode()
{
   int a,b,c,d;
   string s="ACL";
   cin>>a;
   f(b,0,a)
   cout<<s;
   cout<<ee;
    re 0;
}
 
int32_t main()
{
    IOS
    // #ifndef ONLINE_JUDGE
    // freopen("input.txt","r",stdin);
    //  freopen("output.txt","w",stdout);
    // #endif 
    
    int t=1;
   // cin>>t;
    while(t--)
    decode();
    return 0;
}

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

short int n, m, res=0, a[5001], b[5001], best[5001][5001];

int main()
{
    cin>>m>>n;
    for(int i=1;i<=m;i++)
        cin>>a[i];
    for(int j=1;j<=n;j++)
        cin>>b[j];
    for(int i=1;i<=m;i++)
        for(int j=1;j<=n;j++)
        {
            if(a[i]==b[j]) best[i][j]=best[i-1][j-1]+1;
            else best[i][j]=best[i-1][j];
            res = max(res, best[i][j]);
        }
    cout<<res<<'\n';
    return 0;
}

Measured memory_bytes: 50020
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<(n); i++)
#define FOR(i,x,n) for(int i=x; i<(n); i++)
#define ALL(n) begin(n),end(n)
#define MOD (1000000007)
#define INF (1e9)
#define INFL (1e18)

typedef long long ll;
typedef unsigned int ui;
typedef unsigned long long ull;
template<class T>using arr=vector<vector<T>>;
template<class T>void pr(T x){cout << x << endl;}
template<class T>void prvec(vector<T>& a){rep(i, a.size()-1){cout << a[i] << " ";} pr(a[a.size()-1]);}
template<class T>void prarr(arr<T>& a){rep(i, a.size()) if(a[i].empty()) pr(""); else prvec(a[i]);}
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

vector<bool> row(8, false), col(8, false), diag(15, false), eiag(15, false);
vector<string> field(8);
vector<int> q;

void dfs(vector<string> f, vector<bool> r, vector<bool> c, vector<bool> d, vector<bool> e, int k){
    if(k==8){
        field = f;
        return;
    }

    rep(i, 8) rep(j, 8){
        if(r[i] || c[j] || d[i-j+7] || e[i+j]) continue;
        f[i][j] = 'Q';
        vector<bool> rn=r, cn=c, dn=d, en=e;
        rn[i] = true;
        cn[j] = true;
        dn[i-j+7] = true;
        en[i+j] = true;
        dfs(f, rn, cn, dn, en, k+1);
        f[i][j] = '.';
    }
}

int main()
{
    int n; cin >> n;
    int a, b;
    rep(i, 8){
        field[i] = "........";
    }
    rep(i, n){
        cin >> a >> b;
        row[a] = true;
        col[b] = true;
        diag[a-b+7] = true;
        eiag[a+b] = true;
        field[a][b] = 'Q';
        q.push_back(a*8 + b);
    }

    dfs(field, row, col, diag, eiag, n);
    rep(i, 8){
        cout << field[i] << endl;
    }

    return 0;}


Measured memory_bytes: 3216
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Comparator;
import java.util.List;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner in = new Scanner(System.in);
		int n = in.nextInt();
		int k = in.nextInt();
		int[] a = new int[n];
		for(int i=0;i<n;i++) {
			a[i] = in.nextInt();
		}
		Arrays.sort(a);
		List<Integer> list = new ArrayList<>();
		int num = a[0];
		int count = 1;
		for(int i=1;i<n;i++) {
			if(a[i]==num) count++;
			else {
				list.add(count);
				num = a[i];
				count = 1;
			}
		}
		list.add(count);
		list.sort(Comparator.naturalOrder());
		int variation = list.size();
		if(variation<=k) System.out.println(0);
		else {
			int sum = 0;
			for(int i=0;i<variation-k;i++) {
				sum += list.get(i);
			}
			System.out.println(sum);
		}
		in.close();
	}

}


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

int main()
{
  long n, a[5];
  cin >> n >> a[0] >> a[1] >> a[2] >> a[3] >> a[4];
  long min, count;
  min = a[0];
  count;
  for (int i = 1; i < 5; ++i) {
    if (a[i] < min) {
      min = a[i];
    }
  }
  count = (n-1) / min;
  cout << 5 + count << endl;
  return 0;
}

Measured memory_bytes: 256
A = input()
B = input()
C = input()

A = list(A)
B = list(B)
C = list(C)

bool = True
turn = 'a'

while bool:
    if turn == 'a':
        if len(A) == 0:
            print('A')
            bool = False
        else:            
            turn = A[0]
            A.pop(0)
    elif turn == 'b':
        if len(B) == 0:
            print('B')
            bool = False
        else:            
            turn = B[0]
            B.pop(0)
    else:
        if len(C) == 0:
            print('C')
            bool = False
        else:            
            turn = C[0]
            C.pop(0)



Measured memory_bytes: 3064
#include <stdio.h>
#define INF 999999999
 
int l[250002] = {};
int r[250002] = {};
int c ;
 
 int s[500000];


void merge(int,int,int);
void mergesort(int,int);
 
     
int main(){
   
  int n,i,left,right;
  
  c = 0;
   
  scanf("%d",&n);
  for(i = 0;i < n;i++) scanf("%d",&s[i]);
 
  left = 0;right = n;
  mergesort(left,right);
 
  for(i = 0;i < n;i++){
    if(i != n - 1) printf("%d ",s[i]);
    else printf("%d\n",s[i]);
  }
  printf("%d\n",c);
  return 0;
}



void merge(int left,int mid,int right){
 
  int i,j,k;
  int n1 = mid - left;
  int n2 = right - mid;
 
  for(i = 0;i < n1;i++) l[i] = s[left + i];
  for(i = 0;i < n2;i++) r[i] = s[mid + i];
 
  l[n1] = INF;
  r[n2] = INF;
 
  i = j = 0;
   
  for(k = left;k < right;k++){
    c++;
    if(l[i] <= r[j]){
      s[k] = l[i];
      i++;
    }
    else{
      s[k] = r[j];
      j++;
    }
  }
}


void mergesort(int left,int right){
  int mid;
  if(left + 1 < right){
    mid = (left + right) / 2;
    mergesort(left,mid);
    mergesort(mid,right);
    merge(left,mid,right);
  }
}

Measured memory_bytes: 6640
import java.util.*;

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

      int s=sc.nextInt();
      int x,y,z,w;

        z=s%10;

        y=(s-z)%100/10;

        x=(s-10*y-z)%1000/100;

        w=(s-100*x-10*y-z)%10000/1000;

///////////////////////////////////////////////////////////
        if(w==x || x==y || y==z || (w==x&&x==y) || (x==y&&y==z) || (w==x&&x==y&&y==z)){
          System.out.println("Bad");
        }
        else{
          System.out.println("Good");
        }
///////////////////////////////////////////////////////////



    }
}


Measured memory_bytes: 21844