akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;

#define fast_io ios_base::sync_with_stdio(false); cin.tie(nullptr)
#define rep(i, x, y) for(decltype(y) i = (x) - ((x) > (y)); i != (y) - ((x) > (y)); i += 1 - 2 * ((x) > (y)))
#define trav(i,a) for(auto& (i) : (a))
#define all(a) (a).begin(),(a).end()
#define sz(a) int((a).size())
#define clr(a,x) memset((a),(x),sizeof(a)) // array (0,-1)
#define dbg(x) cerr << "STDERR => " << __LINE__ << ": " << #x << " = " << (x) << "  :(\n";
#define pb push_back
#define mp make_pair
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
inline void cpuTime() { cerr << "cpu time : " << double(clock())/CLOCKS_PER_SEC << "\n"; return; }
using ll = long long;
using ull = unsigned long long;
using F = float;
using D = double;
using vi = vector<int>;
using pii = pair<int,int>;



void solve(){

    string T;
    cin >> T;

    rep(i,0,sz(T)){
        if(T[i]=='?') T[i]='D';
    }

    cout << T << "\n";
    return;
}

/*
 read the question carefully ( what're the exact constraints? )
 look out for SPECIAL CASES (n=1?) and OVERFLOW (ll vs int?) ARRAY OUT OF BOUNDS
 Check datatypes
*/
int main(){

    fast_io;
    int t=1;
    // cin >> t;

    while(t--){
        solve();
    }

    cpuTime();
return 0;
}


Measured memory_bytes: 3924
#include <iostream>
#include <algorithm>
#include <numeric>
#include <vector>
#include <cassert>
#include <string>
#include <memory.h>
#include <queue>
#include <cstdio>
#include <cstdlib>
#include <set>
#include <map>
#include <cctype>
#include <iomanip>
#include <sstream>
#include <cctype>
#include <fstream>
#include <cmath>
using namespace std;

#define REP2(i, m, n) for(int i = (int)(m); i < (int)(n); i++)
#define REP(i, n) REP2(i, 0, n)
#define ALL(c) (c).begin(), (c).end()
#define ITER(c) __typeof((c).begin())
#define PB(e) push_back(e)
#define FOREACH(i, c) for(ITER(c) i = (c).begin(); i != (c).end(); ++i)
#define MP(a, b) make_pair(a, b)
#define PARITY(n) ((n) & 1)

typedef long long ll;
typedef pair<ll, ll> P;
const int INF = 1000 * 1000 * 1000 + 7;
const double EPS = 1e-10;

const int sz = 210;
int height[sz][sz];
int number[sz][sz];

enum{
  TOP,
  BOTTOM,
  LEFT,
  RIGHT,
  FRONT,
  BACK
};

vector<int> init_dice(int top, int front){
  vector<int> dice(6);

  int L[6][6] = {
    {-1, 3, 1, 4, 2,-1},
    {2 ,-1, 5, 0,-1, 3},
    {4 , 0,-1,-1, 5, 1},
    {1 , 5,-1,-1, 0, 4},
    {3 ,-1, 0, 5,-1, 2},
    {-1, 2, 4, 1, 3,-1},
  };
  
  dice[TOP]    = top;
  dice[BOTTOM] = 5 - top;
  dice[LEFT]   = L[top][front];
  dice[RIGHT]  = 5 - dice[LEFT];
  dice[FRONT]  = front;
  dice[BACK]   = 5 - front;
  return dice;
}

void rotx(vector<int> &dice){
  int tmp      = dice[RIGHT];
  dice[RIGHT]  = dice[TOP];
  dice[TOP]    = dice[LEFT];
  dice[LEFT]   = dice[BOTTOM];
  dice[BOTTOM] = tmp;
}

void roty(vector<int> &dice){
  int tmp      = dice[FRONT];
  dice[FRONT]  = dice[TOP];
  dice[TOP]    = dice[BACK];
  dice[BACK]   = dice[BOTTOM];
  dice[BOTTOM] = tmp;
}

  

bool fall(int &x, int &y, vector<int> &dice){
  int dx[4] = {0, 1, 0, -1};
  int dy[4] = {1, 0, -1, 0};
  int face[4] = {FRONT, RIGHT, BACK, LEFT};

  int dir = -1;
  REP(i, 4){
    int x2 = x + dx[i];
    int y2 = y + dy[i];
    if(height[x][y] > height[x2][y2] && dice[face[i]] >= 3){
      if(dir == -1 || dice[face[dir]] < dice[face[i]]) dir = i;
    }
  }

  if(dir == -1) return false;
  
  x += dx[dir];
  y += dy[dir];
  if(dir == 0) roty(dice);
  if(dir == 1) rotx(dice);
  if(dir == 2) roty(dice), roty(dice), roty(dice);
  if(dir == 3) rotx(dice), rotx(dice), rotx(dice);
  return true;
}

int main(){
  int n, f, t;
  while(cin >> n && n){
    memset(height, 0, sizeof(height));
    memset(number, 0, sizeof(number));
      
    REP(i, n){
      cin >> t >> f;
      t--, f--;
      vector<int> dice = init_dice(t, f);
      int x = sz / 2;
      int y = sz / 2;
      while(fall(x, y, dice));
      height[x][y]++;
      number[x][y] = dice[TOP];
    }
    
    vector<int> res(6, 0);
    REP(i, sz)REP(j, sz) if(height[i][j] > 0) res[number[i][j]]++;
    REP(i, 6) cout << res[i] << (i == 5 ? '\n' : ' ');
    
  }
  return 0;
}

Measured memory_bytes: 1548
import java.util.Scanner;


public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		while(true) {
		int a = sc.nextInt();
		if(a==0) { break;}
		int b = sc.nextInt();
		int c = sc.nextInt();
		
		a-=b;
		for(int count=0;count<c;a+=b) {
			if(sosuu(a+b)) {
				count++;
			}
		}
			System.out.println(a);
			
		}
		sc.close();
	}
	
	public static boolean sosuu(int a) {
		//素数ならtrueを返す
		if(a==1)return false;
		for(int i=2;i<=Math.sqrt(a);i++) {
			if(a%i==0) {
				return false;
			}
		}
		return true;
	}

}



Measured memory_bytes: 29620
import java.util.Scanner;

public class Main {
  public static void main(String args[]) {
    Scanner input = new Scanner(System.in);
    Integer N = Integer.valueOf(input.nextLine());
    if (N % 1000 == 0) {
      System.out.println(0);
    }
    else {
      System.out.println(1000 - N % 1000);
    }
  }
}

Measured memory_bytes: 35332
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); i++)

using namespace std;
using ll = long long;

string S, T;

int main()
{
    cin >> S >> T;
    int cnt = 0;
    rep(i, S.length())
    {
        if (S[i] != T[i])
            cnt++;
    }

    cout << cnt << endl;
    return 0;
}

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

int main()
{
  int N, A, B;
  cin >> N >> A >> B;
  int ans = 0;
  int sum = 0;
  int a, b, c, d, e;
  for (int i = 1; i <= N; i++)
  {
    sum = 0;
    a = i % 10;
    b = i % 100;
    b = b / 10;
    c = i % 1000;
    c = c / 100;
    d = i % 10000;
    d = d / 1000;
    e = i / 10000;
    sum = a + b + c + d + e;

    if (A <= sum && B >= sum)
    {
      ans += i;
    }
  }
  cout << ans;
  return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	public static void main(String[] args){
		Scanner in= new Scanner(System.in);
		int a=0,b=0,temp1,temp2,j;
		while((j=in.nextInt())!=0){
			a=0;b=0;
			for(int i=0;i<j;i++){
				temp1=in.nextInt();
				temp2=in.nextInt();
				if(temp1>temp2){
					a+=temp1+temp2;
				}
				else if(temp1==temp2){
					a+=temp1;b+=temp2;
				}
				else{
					b+=temp1+temp2;
				}
			}
			System.out.printf("%d %d\n",a,b);
		}
	}
}

Measured memory_bytes: 12000
#include <stdio.h>

int main() {
    int v1, f1, v2, f2;
    scanf("%d%d%d%d", &v1, &f1, &v2, &f2);
    
    for (;;) {
        v2 -= f1;
        if (v2 <= 0) {
            printf("Yes");
            break;
        } else
            v1 -= f2;
            if (v1 <= 0) {
                printf("No");
                break;
            }
    }
    
    return 0;
}

Measured memory_bytes: 1736
#include <iostream>
#include <fstream>
#include <sstream>
#include <iomanip>
#include <vector>
#include <string>
#include <algorithm>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <unordered_set>
#include <unordered_map>
#include <bitset>
#include <limits>
#include <random>
#include <complex>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cassert>
using namespace std;

#define REP(i,n) for (int i = 0; i < n; i++)
template <class T> using reversed_priority_queue = priority_queue<T, vector<T>, greater<T> >;
typedef long long ll;

ll N,K;
ll a[1010];

int main ()
{
    cin >> N >> K;
    REP(i,N) cin >> a[i + 1];
    REP(i,1005) a[i + 1] = a[i + 1] + a[i];

    vector < ll > cnd;
    for (int i = 1; i <= (int)N; i++) {
        for (int j = i; j <= (int)N; j++) {
            ll t = a[j] - a[i - 1];
            cnd.push_back(t);
        }
    }    

    ll ans = 0;
    for (ll i = 60LL; i >= 0LL; i--) {
        vector < ll > nxt;
        REP(j,cnd.size()) {
            if (cnd[j] & (1LL << i)) {
                nxt.push_back(cnd[j]);
            }
        }
        if (nxt.size() >= K) {
            ans |= (1LL << i);
            cnd = nxt;
        }
    }

    cout << ans << endl;

    return 0;
}


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

#define REP(i, s) for (int i = 0; i < s; ++i)
#define ALL(v) (v).begin(), (v).end()
#define COUT(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << endl
#define EACH(i, s) for (__typeof__((s).begin()) i = (s).begin(); i != (s).end(); ++i)
#define DEBUG
#define int long long
#define INF 1e18
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;
}
template <class T1, class T2>
ostream &operator<<(ostream &s, pair<T1, T2> P)
{
    return s << '<' << P.first << ", " << P.second << '>';
}
template <class T>
ostream &operator<<(ostream &s, vector<T> P)
{
    for (int i = 0; i < P.size(); ++i)
    {
        if (i > 0)
        {
            s << " ";
        }
        s << P[i];
    }
    return s;
}
template <class T>
ostream &operator<<(ostream &s, vector<vector<T>> P)
{
    for (int i = 0; i < P.size(); ++i)
    {
        s << endl
          << P[i];
    }
    return s << endl;
}
template <class T>
ostream &operator<<(ostream &s, set<T> P)
{
    EACH(it, P) { s << "<" << *it << "> "; }
    return s << endl;
}
template <class T1, class T2>
ostream &operator<<(ostream &s, map<T1, T2> P)
{
    EACH(it, P) { s << "<" << it->first << "->" << it->second << "> "; }
    return s << endl;
}
template <class T>
void show(vector<T> v)
{
    for (int i = 0; i < v.size(); i++)
    {
        cerr << v[i] << " ";
    }
    cerr << "\n";
}
typedef long long ll;

signed main()
{
    int n;
    string s;
    cin >> n >> s;
    int cnt = 0;
    for (int i = 0; i < n - 2; i++)
    {
        if(s.substr(i,3)=="ABC")
            cnt++;
    }
    cout << cnt << endl;

    return 0;
}

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

using namespace std;

int main()
{
    string s;
    cin >> s;
    
    bool flag[4] = {false};
    for(int i = 0; i < s.size(); i++) {
        switch(s[i]) {
            case 'N': flag[0] = true; break;
            case 'W': flag[1] = true; break;
            case 'S': flag[2] = true; break;
            case 'E': flag[3] = true; break;
        }
    }
    
    if((flag[0] && flag[1] && flag[2] && flag[3]) || (flag[0] && !flag[1] && flag[2] && !flag[3]) || (!flag[0] && flag[1] && !flag[2] && flag[3])) {
        cout << "Yes" << endl;
    }
    else {
        cout << "No" << endl;
    }
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main(){
	int i,H,j,W;
	
	for(;;){
		cin>>H>>W;
		if(H==0 && W==0)break;
		for(i=1;i<=H;i++){
			for(j=1;j<=W;j++){
				if(i==H||i==1){
				cout<<"#";
				}else if(j==W||j==1){
					cout<<"#";
				}else{ 
					cout<<".";
			    }
			}
			cout<<endl;
		}
		cout<<endl;
	}
	return 0;
}

Measured memory_bytes: 3080
#include <stdio.h>
int main(void){
    long long int how_tawn,wark,worp;
    scanf("%lld %lld %lld",&how_tawn,&wark,&worp);
    long long int map[how_tawn];
    long long int loop1;
    for(loop1=0;loop1<how_tawn;loop1++){
        scanf("%lld",&map[loop1]);
    }
    long long int ans=0;
    for(loop1=0;loop1<how_tawn-1;loop1++){
        long long int distance=(map[loop1+1]-map[loop1]);
        if(wark*distance>worp){
            ans+=worp;
        }else{
            ans+=(wark*distance);
        }
    }
    printf("%lld\n",ans);
    return 0;
}

Measured memory_bytes: 1024
txt = input()
check_list = [0] * 26
base = ord('a')

for c in list(txt):
    check_list[ord(c) - base] = 1
    
ans = -1    
for i in range(26):
    if check_list[i] == 0:
        ans = base + i
        break
    
if ans == -1:
    print('None')
else:
    print(chr(ans))


Measured memory_bytes: 3956
#include<bits/stdc++.h>
#define INFTY 1<<20
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
typedef long long int ll;
const int MOD=1000000007;

int main(){

int n;cin>>n;
vector<int> b(n+1);
b[0]=INFTY;b[n]=0;
ll sum=0;
for (int i = 1; i < n; i++)
{
    cin>>b[i];
    sum += min(b[i],b[i-1]);
}
sum += b[n-1];
cout<<sum <<endl;

return 0;
}

Measured memory_bytes: 256
N,M,Q = map(int,input().split())
ABCD = [list(map(int,input().split())) for _ in [0]*Q]

A = [1]*N
ans = 0
while A[0] == 1:
    tmp = 0
    for a,b,c,d in ABCD:
        if A[b-1]-A[a-1]==c: tmp += d
    ans = max(ans,tmp)
    A[N-1] += 1
    for i in range(N-1,-1,-1):
        if A[i]>M:
            A[i-1] += 1
            for j in range(i,N):
                A[j] = A[i-1]
print(ans)

Measured memory_bytes: 68424
#include<cstdio>


typedef long long int lli;

int main(void) {
    int n,k;
    scanf("%d%d",&n,&k);

    lli res = 0;

    if(k==0) {
        res = n;
        res*= res;
        printf("%lld\n", res);
        return 0;
    }
    // 1 <= a = r + lb <= n
    // 1 <= lb <= n-r
    for(int b=k+1; b<=n; b++) {
        lli t = n/b * (b-k);
        res += t;
        lli l = n - n/b*b;
        if(l>=k) res += l-k+1;
        //printf("%d %d %d\n", b, t, l-k+1);
    }

    printf("%lld\n", res);
}

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

#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define llong long long
#define pb(a) push_back(a)
#define INF 1000000000000000000LL
#define MOD 1000000007
#define writeln(n) cout<<n<<endl
using namespace std;
typedef pair<int, int> P;
typedef pair<llong, llong> LP;
typedef pair<int, P> PP;
typedef pair<llong, LP> LPP;
//vector<tuple<long long, long long, long long>>vec;

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;
}

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


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

    int n;
    cin>>n;
    vector<int> s(n,0);
    int sum=0;


    REP(i,n)
    {
        cin>>s[i]; sum+=s[i];
    }

    int ans=0;
    sort(s.begin(),s.end());

    int v=0;
    bool f=false;
    REP(i,n)
    {
        if(s[i]%10!=0)
        {
           v=s[i];
           f= true;
           break;
        }
    }
    if(sum%10!=0) ans=sum;
    else if(f) ans=sum-v;

    cout<<ans<<endl;

}

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

using namespace std;

using int64 = long long;

template< typename T >
struct edge {
  int src, to;
  T cost;

  edge(int to, T cost) : src(-1), to(to), cost(cost) {}

  edge(int src, int to, T cost) : src(src), to(to), cost(cost) {}

  edge &operator=(const int &x) {
    to = x;
    return *this;
  }

  operator int() const { return to; }
};

template< typename T >
using Edges = vector< edge< T > >;
template< typename T >
using WeightedGraph = vector< Edges< T > >;
using UnWeightedGraph = vector< vector< int > >;
template< typename T >
using Matrix = vector< vector< T > >;

template< typename T >
vector< T > dijkstra(WeightedGraph< T > &g, int s) {
  const auto INF = numeric_limits< T >::max();
  vector< T > dist(g.size(), INF);

  using Pi = pair< T, int >;
  priority_queue< Pi, vector< Pi >, greater< Pi > > que;
  dist[s] = 0;
  que.emplace(dist[s], s);
  while(!que.empty()) {
    T cost;
    int idx;
    tie(cost, idx) = que.top();
    que.pop();
    if(dist[idx] < cost) continue;
    for(auto &e : g[idx]) {
      auto next_cost = cost + e.cost;
      if(dist[e.to] <= next_cost) continue;
      dist[e.to] = next_cost;
      que.emplace(dist[e.to], e.to);
    }
  }
  return dist;
}

int main() {
  int N, M, S, T;
  cin >> N >> M >> S >> T;
  --S, --T;
  WeightedGraph< int64 > g(N);
  for(int i = 0; i < M; i++) {
    int s[3], w;
    cin >> s[0] >> s[1] >> s[2] >> w;
    --s[0], --s[1], --s[2];
    for(int j = 0; j < 3; j++) {
      for(int k = 0; k < 3; k++) {
        g[s[j]].emplace_back(s[k], w);
      }
    }
  }
  auto ret = dijkstra(g, S)[T];
  if(ret >= numeric_limits< int64 >::max()) ret = -1;
  cout << ret << endl;
}


Measured memory_bytes: 32368
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner stdIn = new Scanner(System.in);
		int n = stdIn.nextInt();
		String[] a = new String[n];
		int[] s = new int[n];
		for(int i=0;i<n;i++){
			a[i] = stdIn.next();
			s[i] = stdIn.nextInt();
		}
		for(int i=0;i<n;i++){
			String min = a[i];
			int idx = i;
			for(int j=i+1;j<n;j++){
				if(min.length()>a[j].length()){
					idx = j;
					min = a[j];
				}
				else if(min.length()==a[j].length()&&min.compareTo(a[j])>0){
					idx = j;
					min = a[j];
				}
			}
			String temp1 = a[i];
			a[i] = a[idx];
			a[idx] = temp1;
			int temp2 = s[i];
			s[i] = s[idx];
			s[idx] = temp2;
		}
//		for(int i=0;i<n;i++){
//			System.out.println(a[i]+"\t"+s[i]);
//		}
		for(int i=0;i<n;){
			System.out.print(a[i]+" ");
			int sum = s[i];
			int j = i+1;
			while(true){
				if(j<n&&a[i].equals(a[j])){
					sum += s[j++];
				}
				else break;
			}
			System.out.println(sum);
			i = j;
		}
	}
}

Measured memory_bytes: 38332
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i=0; i<(n); ++i)
#define REP(i, d, n) for(int i=(d); i<(n); ++i)
#define all(v) v.begin(), v.end()
using ll = long long;
int main() {

  int h,w,k;
  cin>>h>>w>>k;
  vector<string>a(h);
  rep(i,h){cin>>a[i];}
  int ans=0;
  
  rep(ii,1<<h){
   rep(jj,1<<w){ 
       int cou=0;
       rep(i,h){ 
        rep(j,w){
          if(ii>>i&1)continue;
          if(jj>>j&1)continue;
          if(a[i][j]=='#')cou++;       
      }       
     }  
     if(cou==k)ans++;
   }
  }
  cout<<ans<<endl;
  
}

Measured memory_bytes: 3644
#include <iostream>
#include <string>

int main(){
  int n;
  std::cin >> n;
  std::string s, t;
  std::cin >> s >> t;
  for(int i=0; i<n; ++i)
    std::cout << s[i] << t[i];
  std::cout << std::endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
typedef long long ll;

const int limit = 50;

int n, m;
int a[limit];
int b[limit];
bool graph[limit][limit];
bool visited[limit];

void dfs(int v)
{
    visited[v] = true;
    for (int v2 = 0; v2 < n; ++v2)
    {
        if (graph[v][v2] == false)
        {
            continue;
        }
        if (visited[v2] == true)
        {
            continue;
        }
        dfs(v2);
    }
}

int main()
{
    cin>>n>>m;
    for(int i=0;i<m;i++){
        cin>>a[i]>>b[i];
        a[i]--;
        b[i]--;
        graph[a[i]][b[i]]=graph[b[i]][a[i]]=true;
    }
    int ans=0;
    for(int i=0;i<m;i++){
        graph[a[i]][b[i]]=graph[b[i]][a[i]]=false;
        for(int j=0;j<n;j++){
            visited[j]=false;
        }
        dfs(0);
        bool bridge=false;
        for(int j=0;j<n;j++){
            if(visited[j]==false){
                bridge=true;
            }
        }
        if(bridge){
            ans++;
        }
        graph[a[i]][b[i]]=graph[b[i]][a[i]]=true;
    }
    cout<<ans<<endl;
}

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

int main()
{
string  n;
 cin>>n;
  if(n[0]=='7'||n[1]=='7'||n[2]=='7'){
    //cout<<"Yes"<<endl;
  puts("Yes");
  }
  else{
    cout<<"No"<<endl;
  }

}


Measured memory_bytes: 3616
#include<iostream>
#include<vector>
#include<stdio.h>
#include<algorithm>
#include<sstream>
#include<iomanip>
using namespace std;
int main(){
long long int n,m,a,b,c,count=0,now=0,d,ac=0,e,idx,x,f,g;
  vector<long long int> y,yc,yd;
  vector<long long int>::iterator position;
  stringstream ss;
  cin>>n>>m;
  for(int i=0;i<m;i++){
  cin>>a>>b;
    a*=10000000000;
    c=a+b;
    y.push_back(c);
    yc.push_back(c);
    yd.push_back(c);
  }
  sort(yc.begin(),yc.end());
  sort(yd.begin(),yd.end());
  for(int i=0;i<m;i++){
    d=(long long int)yd.at(i)/10000000000;
    e=(long long int)yd.at(i)%10000000000;
    f=(long long int)d*1000000;
    g=(long long int)d*10000000000;
  if(d==now)count++;
    else {
      now=d;
      count=1;
    }
      yd.at(i)=yd.at(i)-e+count-g+f;
  }
  for(int i=0;i<m;i++){
    x=y.at(i);
  position=lower_bound(yc.begin(),yc.end(),x);
    idx=distance(yc.begin(),position);
  ss<<setw(12)<<setfill('0')<<yd.at(idx)<<"\n";
  }
  cout<<ss.str()<<endl;
return 0;
} 

Measured memory_bytes: 6500
#include <iostream>
#include <algorithm>
using namespace std;
int main() {
	ios::sync_with_stdio(0);
	int a[4];
	cin >> a[1] >> a[2] >> a[3];
	sort(a+1, a+1+3);
	cout << a[3]*10 + a[2] + a[1];
	return 0;
}

Measured memory_bytes: 256
/*~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=
    WRITER:kakitamasziru/OxOmisosiru
~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=*/
#define _GLIBCXX_DEBUG
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <iomanip>
#include <limits>//setprecision
//#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <math.h>//pow,,,
#include <cmath>//abs,,,
//#include <unordered_map> // unordered_map
//#include <unordered_set> // unordered_set
#include <bitset> // bitset
//#include <cctype> // isupper, islower, isdigit, toupper, tolower
//It is so troublesome that I include bits/stdc++.h !
using namespace std;

template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
const long long INF = 100100100100100;
const int MOD = 1000000007;
typedef pair<long long,long long> P;
//NのM乗を求める(繰り返し二乗法)
long long mod_pow(long long N, long long M) {
    if (M == 0) return 1;
    long long res = mod_pow((N * N) % MOD, M / 2);
    //最下位ビット(*N)が1の時は単独でNをかける
    if (M & 1) res = (res * N) % MOD;

    return res %= MOD;
}

long long dp[114514];
bool broken[114514];

int main() {
    int N,K;cin >> N >> K;
    for(int i = 0;i<114514;i++)broken[i] = false;

    for(int i = 0;i<K;i++){
        int a;cin >> a;
        broken[a] = true;
    }
    for(int i = 0;i<114514;i++) dp[i] = 0;
    dp[0] = 1;

    for(int i = 0;i<=N;i++){
        if(!broken[i+1]){
            dp[i+1] += dp[i];
            dp[i+1] %= MOD;
        }
        if(!broken[i+2]){
            dp[i+2] += dp[i];
            dp[i+2] %= MOD;
        }
    }
    
    cout << dp[N] << endl;
    

    // PLEASE GIVE ME THE "ACCEPTED" !
}

Measured memory_bytes: 1280
#include <iostream>
#include <cstring>
#include <map>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <set>
#include <vector>
#include <queue>
#include <list>
#include <numeric>
#include <stdio.h>
#include <string>
#include <cstdlib>
#include <math.h>
#include <stack>
#include <climits>
#include <bitset>
#include <utility>


using namespace std;
typedef long long ll;
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 ll INF = 1LL <<60;
const int INF = 10000;

//最小公倍数
ll gcd(ll x, ll y) {
  ll tmp = 0;
  if (x < y){
    tmp=x;
    x=y;
    y=tmp;
  }
  while (y > 0) {
    ll r = x % y;
    x = y;
    y = r;
  }
  return x;
}

//最大公倍数
ll lcm(ll x,ll y){
  return x/gcd(x,y)*y;
}

//階乗
ll kaijo(ll k){
    ll sum = 1;
    for (ll i = 1; i <= k; ++i)
    {
        sum *= i;
        sum%=1000000000+7;
    }
    return sum;
}

//for(int i = ; i < ; i++){}

ll lmax(ll s,ll t){
  if(s>t){
    return s;
  }
  else{
    return t;
  }
}

ll lmin(ll s,ll t){
  if(s<t){
    return s;
  }
  else{
    return t;
  }
}
// ここから開始


int main(){
  string s;
  cin>>s;
  int n = s.length();
  for(int i = 0; i < s.length()-2; i++){
    if(s[i]==s[i+1]){
      cout<<i+1<<" "<<i+2<<endl;
      return 0;
    }
    else if(s[i]==s[i+2]){
      cout<<i+1<<" "<<i+3<<endl;
      return 0;
    }
  }
  if(s[n-2]==s[n-1]){
    cout<<n-1<<" "<<n<<endl;
      return 0;
  }
  cout<<-1<<" "<<-1<<endl;
  return 0;
}


Measured memory_bytes: 512
import Data.Maybe
import Control.Monad
import qualified Data.ByteString.Char8 as C

readInt' = fst.fromJust.C.readInt
readLnInt = map readInt'.C.words<$>C.getLine
readCsInt n = concat<$>replicateM n readLnInt

x ? (a,b) = if x then a else b
aliq = ((0==).).rem
-- a `isFrom` (b `to` c)
a `isFrom` [b,c] = a >= b && a <= c
b `to` c = [b,c]

main = do
 inputs <- readLnInt
 putStr $ (solve inputs)?("Yes","No")

solve [animals,legs]
 | odd legs = False
 | legs `isFrom` ((2*animals) `to` (4*animals)) = True
 | otherwise = False


Measured memory_bytes: 3784
#include <string>
#include <vector>
#include <sstream>
#include <iostream>
#include <algorithm>
#include <map>
#include <list>
#include <set>
#include <numeric>
#include <queue>
#include <stack>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <cstring>
#include <climits>
#include <cfloat>
#include <ctime>
#include <complex>
#include <cassert>
#include <array>
#include <bitset> 
#include <unordered_map>
#include <random>

using namespace std;
typedef long long LL;
typedef pair<int,int> P;

const int L=10010;
int a[L];
bool s0[L][L];
bool s1[L][L];
int main() {
	int N,K;
	cin >> N >> K;
	for(int i=0;i<N;i++){
		cin >> a[i];
		a[i]=min(a[i],2*K);
	}
	s0[0][0]=true;
	for(int i=0;i<N;i++){
		for(int j=0;j<=2*K;j++){
			s0[i+1][j]|=s0[i][j];
			int v=min(2*K,j+a[i]);
			s0[i+1][v]|=s0[i][j];
		}
	}
	s1[N-1][0]=true;
	for(int i=N-1;i>0;i--){
		for(int j=0;j<=2*K;j++){
			s1[i-1][j]|=s1[i][j];
			int v=min(2*K,j+a[i]);
			s1[i-1][v]|=s1[i][j];
		}
	}
	int ret=0;
	for(int i=0;i<N;i++){
		if(a[i]>=K){
			continue;
		}
		int k=K+a[i]-1;
		bool ok=true;
		for(int j=0;j<K+a[i];j++){
			if(!s0[i][j]){
				continue;
			}
			while(k>=0&&(!s1[i][k]||K<=j+k)){
				k--;
			}
			//cerr << i << ", " << j << ", " << k << ", " << s1[i][3] << endl;
			if(k>=0&&K<=j+k+a[i]){
				//cerr << a[i] << ", " << j << ", " << k << endl;
				ok=false;
				break;
			}
		}
		if(ok){
			ret++;
		}
	}
	cout << ret << endl;
	return 0;
}



Measured memory_bytes: 100608
object Main {
  import scala.io.StdIn.readLine
  def main(args: Array[String]): Unit = {
    val x = readLine.trim().toLong
    var current = 100L

    var i = 0
    while(current < x) {
      current += (current * 0.01).toLong
      i += 1
    }
    println(i)
  }
}


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

#define se second
#define fi first
#define mk(a,b) make_pair(a,b)

typedef pair<int,int> pii;
typedef pair<int,pii> pipii;

int H,W;
char fid[100][100] = {0};
int D[100][100];
queue<pipii> Q;
int INF = 1001001001;
int dx[] = {0,1,0,-1},dy[] = {1,0,-1,0};
int cnt = 0;

int main()
{
    scanf("%d%d",&H,&W);
    for(int i = 1; i <= H; i++)for(int j = 1; j <= W; j++)scanf(" %c",&fid[i][j]);

    for(int i = 1; i <= H; i++)for(int j = 1; j <= W; j++)D[i][j] = INF;
    Q.push(mk(1,mk(1,1)));
    while(Q.size())
    {
        pipii now = Q.front();
        Q.pop();
        if(fid[now.se.fi][now.se.se] != '.')continue;
        if(D[now.se.fi][now.se.se] != INF)continue;
        D[now.se.fi][now.se.se] = now.fi;
        for(int i = 0; i < 4; i++)
        {
            Q.push(mk(now.fi + 1,mk(now.se.fi + dx[i],now.se.se + dy[i])));
        }
    }

    for(int i = 1; i <= H; i++)for(int j = 1; j <= W; j++)if(fid[i][j] == '.')cnt++;
    if(D[H][W] == INF)printf("-1\n");
    else printf("%d\n",cnt - D[H][W]);
    return 0;
}


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

  const ll MX = 1e18; //指数表現

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

  //計算判定
  ll ans = 1;//掛け算のため初期値を１にすると順番に掛けられる
  bool ng = false;
  rep(i,n) {
    ll a;
    cin >> a;
    if (a == 0) {
      cout << 0 << endl;//入力に0がある場合、即0を表示する
      return 0;
    }
    //オーバーフローの判定
    if (ng || MX/ans < a) {
      ng = true;
    }
    ans *= a;
  }

  //オーバーフローフラグ判定
  if (ng) cout << -1 << endl;
  else cout << ans << endl;
  return 0;
}


Measured memory_bytes: 3672
from collections import deque


class ModCalc:
    mod = 10**9 + 7

    def __init__(self, n):
        self.n = n
        self.inv = [1] * (self.n + 1)
        self.fac = [1] * (self.n + 1)
        self.finv = [1] * (self.n + 1)
        self.inv[0] = 0
        self.inv_table()

    def inv_table(self):
        for i in range(2, self.n+1):
            self.inv[i] = self.inv[self.mod % i] * (self.mod - self.mod // i) % self.mod
            self.fac[i] = self.fac[i-1] * i % self.mod
            self.finv[i] = self.finv[i-1] * self.inv[i] % self.mod

    def comb(self, n, r):
        if n < r:
            return 0
        if n < 0 or r < 0:
            return 0

        return self.fac[n] * self.finv[r] % self.mod * self.finv[n-r] % self.mod

    def perm(self, n, r):
        if n < r:
            return 0
        if n < 0 or r < 0:
            return 0

        return self.fac[n] * self.finv[n-r] % self.mod

    def fact(self, n):
        return self.fac[n]


n, k = map(int, input().split())
tree = [[] for _ in range(n+1)]

for _ in range(n-1):
    a, b = map(int, input().split())
    tree[a].append(b)
    tree[b].append(a)

ans = k
mod = 10**9 + 7
mc = ModCalc(100001)

q = deque([1])
dist = [-1] * (n+1)
dist[1] = 0
while q:
    now = q.popleft()
    cnt = 0
    for node in tree[now]:
        if dist[node] != -1:
            continue
        cnt += 1
        q.append(node)
        dist[node] = dist[now] + 1

    if dist[now] == 0:
        ans *= mc.comb(k-1, cnt) * mc.fact(cnt) % mod
        ans %= mod
    else:
        ans *= mc.comb(k-2, cnt) * mc.fact(cnt) % mod
        ans %= mod

print(ans)

Measured memory_bytes: 41520
/*input

*/
#include <bits/stdc++.h>
#define up(i,a,b) for(int (i) = (a);(i)<=(b);++(i))
#define down(i,b,a) for(int (i) = (b);i>=(a);--i)
#define debug(x) cerr << (x) << '\n';
#define bits(x,i) ((x >> i) & 1)
#define mid ((l+r)/2)
#define pr pair<int,int>
using namespace std;
const int N = 500005;
int bit[N],n,q, c[N];
int nxtColor[N], nxtPos[N], color[N];
struct query{
	int l,r, id;
	query(){l = r = id = 0;}
	query(int _l,int _r,int _id){l = _l; r = _r; id = _id;}
};
bool operator<(query a,query b){
	return a.l < b.l;
}
query question[N];
int ans[N];
void upd(int u,int val){
	while (u <= n) {
		bit[u] += val;
		u += (u &-u);
	}
}
int get(int u){
	int ans = 0;
	while (u){
		ans += bit[u];
		u -= (u &-u);
	}
	return ans;
}

int main(){
	ios_base::sync_with_stdio(0); cin.tie(0);
	cin >> n >> q;
	for(int i=1;i<=n;++i){
		cin >> c[i];
	}
	for(int i=1;i<=q;++i){
		cin >> question[i].l >> question[i].r;
		question[i].id = i;
	}
	for(int i=n;i>=1;--i){
		nxtPos[i] = nxtColor[c[i]];
		nxtColor[c[i]] = i;
	}
	for (int i=1;i<=n;++i) if (nxtColor[c[i]] == i) upd(i, 1);

	int curPos = 1;
	sort(question+1, question+1+q);
	for(int i=1;i<=q;++i){
		while (question[i].l != curPos){
			int nxt = nxtPos[curPos];
			upd(curPos, -1);
			if (nxt) upd(nxt, 1);
			curPos++;
		}
		ans[question[i].id] = get(question[i].r);
	}
	for(int i=1;i<=q;++i) cout << ans[i] << '\n';
}

Measured memory_bytes: 19432
#include<iostream>
using namespace std;
#define MAX (256)

int field[MAX][MAX];
int ans = 0;

void dfs(int i, int j){
	for(int k = -1; k <= 1; k++){
		for(int l = -1; l <= 1; l++){
			if(field[i+k][j+l] == 1){
				field[i+k][j+l] = 0;
				dfs(i+k, j+l);
			}
		}
	}
}

int main(){
	int k, l;

	while(1){
		ans = 0;
		cin >> l >> k;

		if((k|l) == 0) break;

		for(int i=0; i < MAX; i++){
			for(int j=0; j < MAX; j++) field[i][j]= 0;
		}

		for(int i=0; i < k; i++){
				for(int j=0; j < l; j++){
					cin >> field[i][j];
			}
		}

		for(int i=0; i < k; i++){
			for(int j=0; j < l; j++){
				if(field[i][j] == 1){
					field[i][j] = 0;
					dfs(i, j);
					ans++;
				}
			}
		}
		
		cout << ans << endl;
	}
}

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

int main(){
    int n;
    cin >> n;
    int h[n];
    for(int i=0;i<n;i++){
        cin >> h[i];
    }
    int cnt = 0;
    for(int i=0;i<n-1;i++){
        if(h[i]<=h[i+1]){
            if(h[i]<=h[i+1]-1){
                h[i+1]--;
            }
            cnt++;
        }
    }
    string ans = "Yes";
    if(cnt != n-1){
        ans = "No";
    }
    cout << ans << endl;

}


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

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

  int X = 1 + D * 2;
  int ans = 1;
  while (N > X) {
    X += 1 + D * 2;
    ans++;
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long LL;
typedef pair<LL,LL> P;
const LL mod=1000000007;
string u="abcdefghijklmnopqrstuvwxyz";

int main(){
    int N;
    cin >> N;
    string s[N];
    int check[N][26];
    memset(check,0,sizeof(check));
    for(int i=0;i<N;i++){
        cin >> s[i];
        sort(s[i].begin(),s[i].end());
        const char *cstr=s[i].c_str();
        for(int j=0;j<s[i].length();j++){
            check[i][(int)cstr[j]-(int)'a']++;
        }
    }
    for(int i=0;i<26;i++){
        int mini=100;
        for(int j=0;j<N;j++){
            mini=min(mini,check[j][i]);
        }
        for(int j=0;j<mini;j++) cout << u[i];
    }
    cout << "\n";
    return 0;
}

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

int main(){

	int n;
	string ans;
	ans = "No";

	cin >> n;

	for (int i = 0; i <= (n/7); i++) {
		if ((n- (7 * i)) % 4 == 0 || 7*i == n) {
			ans = "Yes";
			goto RESULT;
		}
	}
RESULT:

	cout << ans << endl;

	return 0;

}

Measured memory_bytes: 256
from collections import deque

H, W = map(int, input().split())
sy, sx = map(int, input().split())
gy, gx = map(int, input().split())
map_list = []
for i in range(H):
    str_input = input()
    map_list.append(list(str_input))

walk = [[1,0], [-1,0], [0,1], [0,-1]] #　下　上　右　左
warp = [[2,-2], [2,-1], [2,0], [2,1],[2,2], [1,-2], [1,-1], [1,1],[1,2], [0,-2], [0,2], [-1,-2],[-1,-1], [-1,1], [-1,2],[-2,-2], [-2,-1], [-2,0], [-2,1],[-2,2]]

dist = [[10**12 for _ in range(W)] for i in range(H)] #10^3より大きい値

d = deque()
d.append([sy-1, sx-1])
dist[sy-1][sx-1] = 0

#BFS実行部分
while d:
    y,x = d.popleft()
    for dy,dx in walk:
        new_x = x + dx
        new_y = y + dy
        if 0 <= new_y < H and 0 <= new_x < W and map_list[new_y][new_x] == '.' and dist[new_y][new_x] > dist[y][x]:
            dist[new_y][new_x] = dist[y][x]
            d.appendleft([new_y, new_x]) #コスト低い方を優先して取り出すために先頭に追加
    for dy, dx in warp:
        new_x = x + dx
        new_y = y + dy
        if 0 <= new_y < H and 0 <= new_x < W and map_list[new_y][new_x] == '.' and dist[new_y][new_x] > dist[y][x] + 1:
            dist[new_y][new_x] = dist[y][x] + 1
            d.append([new_y, new_x]) #コストが高いので優先順位低い　最高尾に追加

#print(dist)
ans = dist[gy-1][gx-1]
if ans == 10**12:
    ans = -1
print(ans)


Measured memory_bytes: 160292
#include <cstdio>
using namespace std;

int main (void)
{
	int a, b, key=0;
	char op;

	while (scanf("%d %c %d", &a, &op, &b) != EOF && key == 0){
		if (op == '?')
			break;
		else if (op == '+')
			printf("%d\n", a+b);
		else if (op == '-')
			printf("%d\n", a-b);
		else if (op == '*')
			printf("%d\n", a*b);
		else
			printf("%d\n", a/b);
	}

	return 0;
}

Measured memory_bytes: 1028
#include <iostream>
#include <vector>
#include <queue>
#include <unordered_set>

using namespace std;

int main(){
    int n, m; cin >> n >> m;
    vector<vector<int>> cs(n, vector<int>(n));
    vector<vector<bool>> rest(n, vector<bool>(n));
    for(int i=0; i<m; ++i){
        int a, b, c; cin >> a >> b >> c;
        --a; --b;
        cs[a][b]=cs[b][a]=c;
        rest[a][b]=rest[b][a]=true;
    }
    for(int i=0; i<n; ++i){
        vector<int> dists(n, 1000*1000*10);
        dists[i]=0;
        vector<int> prevs(n, -1);
        prevs[i]=i;
        using T=pair<int, int>; // (distance, id)
        priority_queue<T, vector<T>, greater<T>> q;
        q.push(make_pair(0, i));
        while(!q.empty()){
            auto p=q.top(); q.pop();
            int cur=p.second;
            for(int adj=0; adj<n; ++adj){
                if(!cs[cur][adj]) continue;
                int new_dist=dists[cur]+cs[cur][adj];
                if(dists[adj]>new_dist){
                    dists[adj]=new_dist;
                    prevs[adj]=cur;
                    q.push(make_pair(new_dist, adj));
                }
            }
        }
        for(int cur=0; cur<n; ++cur){
            int prev=prevs[cur];
            rest[cur][prev]=rest[prev][cur]=false;
        }
    }
    int ans=0;
    for(int i=0; i<n; ++i){
        for(int j=0; j<n; ++j){
            if(rest[i][j]) ++ans;
        }
    }
    cout << ans/2 << endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main()
{
  int N;
  cin>>N;
  int ps,ws,gs,ys;
  ps=0;ws=0;gs=0;ys=0;
  for(int i=0;i<N;i++)
  {
    string s;
    cin>>s;
    if(s=="P")
      ps++;
    else if(s=="W")
      ws++;
    else if(s=="G")
      gs++;
    else if(s=="Y")
      ys++;
  }
  if(ys==0)
    cout<<"Three"<<endl;
  else
    cout<<"Four"<<endl;
}
      

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <cstdlib>
#include <vector>
#include <algorithm>
#include <map>
using namespace std;
int main(){
    int N;cin >> N;
    std::vector<int> vec;
    for(int a = 0;a < N;a++){
        int b;cin >> b;
        vec.push_back(b);
        vec.push_back(b+1);
        vec.push_back(b-1);
    }
    map<int,int> mp;
    for(int a:vec){
        auto itr = mp.find(a);
        if(itr == mp.end()){
            mp[a] = 1;
        }else{
            mp[a]++;
        }
    }
    int ans = 0;
    for(auto a:mp){
        ans = max(ans,a.second);
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 5872
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cctype>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <time.h>
#include <tuple>
#include <utility>
#include <vector>
#define ll long long
#define itn int
#define endl '\n'
#define co(ans) cout<<ans<<endl
#define COYE cout<<"YES"<<endl
#define COYe cout<<"Yes"<<endl
#define COye cout<<"yes"<<endl
#define CONO cout<<"NO"<<endl
#define CONo cout<<"No"<<endl
#define COno cout<<"no"<<endl
#define FORE(i,a) for(auto &i:a)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define FFOR(i,a,b) for(int i=(a);i<=(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define RREP(i,n)  FFOR(i,1,n)
#define PB push_back
#define MP make_pair
#define ALL(V) (V).begin(),(V).end()
#define SORT(V) sort((V).begin(),(V).end())
#define REVERSE(V) reverse((V).begin(),(V).end())
#define EACH(V,i) for(typeof((V).begin()) i=(V).begin();i!=(V).end();++i)
#define equals(a,b) (fabs((a)-(b))<EPS)
#define INF ((1LL<<62)-(1LL<<31))
#define EPS 1e-10
#define PI 3.141592653589793238
#define MOD 1000000007
#define MAX 5100000
using namespace std;
using Edge=pair<ll,ll>;
using Graph=vector<vector<int>>;
inline int toInt(string s){int v;istringstream sin(s);sin>>v;return v;}
template<class T>inline string toString(T x){ostringstream sout;sout<<x;return sout.str();}
template<class T>bool chmax(T &a,const T &b){if(a<b){a=b;return 1;}return 0;}
template<class T>bool chmin(T &a,const T &b){if(b<a){a=b;return 1;}return 0;}
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;
const int dx[4]={0,1,0,-1},dy[4]={1,0,-1,0};
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b){return a/gcd(a,b)*b;}

int main(){
  ll N,K;
  cin>>N>>K;
  long double P[N],Q[N],SUM[N+1],ans=0.0;
  SUM[0]=0.0;
  REP(i,N){
    cin>>P[i];
    Q[i]=(P[i]+1)/2;
    SUM[i+1]=SUM[i]+Q[i];
  }
  
  for(int i=K; i<=N; ++i){
    chmax(ans,SUM[i]-SUM[i-K]);
  }
  
  cout<<setprecision(10)<<ans<<endl;
  return 0;
}

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

using namespace std;
using ll =long long;
using vi = vector<int>; 
using vvi = vector<vi>; 
using vl = vector<ll>; 
using vvl = vector<vl>; 
using vs = vector<string>;
using vvs = vector<vs>; 
using vc = vector<char>;
using vvc = vector<vc>; 
using vb = vector<bool>;
using vvb = vector<vb>; 

#define rep(i,n) ;for( int i =0; i < n ; i ++)
#define all(a) a.begin(),a.end()
#define pb(a) push_back(a)
#define pd(a) printf("%.10f\n",a)
#define mem(a) memset(a,0,sizeof(a))
#define f(i,a,b) for(int i=a;i<b;i++)
#define pri(a)  printf("%.14lf\n",a);
#define MOD 1000000007
bool is_int_lround(double x){
  return std::lround(x)==x;
}
ll keta(ll x){
  ll n=0;
  while(x>0){
    x /=10 ;
    n ++;
  }
  return n;
}

ll conbi(int n,int m){
  
  cin>>n>>m;
  vector<ll> a(100);
  a[0] =1;
  for(int i=0;i<14;i++){
    a[i+1]=a[i]*(i+1);
  }
  return a[n] /(a[m] *a[n-m]);
}

long long modpow(long long a, long long n, long long mod) {
    long long res = 1;//繰り返し二乗法
    while (n > 0) {
        if (n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}
ll kaijo(ll x){
  ll z=1;
  if(x==0){
    return 1;
  }
  while(x>0){
    z *=x;
    z %=MOD;
    x--;
  }
  return z;
}
ll yakusu_num(ll n){
  vl yakusu(n+1,1);
  for(ll i=2;i*i<=n;i++){ 
    while(n%i==0){
      n /=i;
      yakusu[i]++;
    }
  }
  if(n!=1)yakusu[n]++;
  ll num=1;
  for(ll i=0;i<=n;i++){
    num*=yakusu[i];
  }
  return num;
}

int H,W;
vs s(50);
vi dv ={-1,0,1,0};vi du={0,-1,0,1};
int cnt=1;
int dfs(int u,int v){
  s[u][v]='.';
  
  rep(i,4){
   
      int nu =u +du[i],nv=v+dv[i];
      if(nu<0||nu>=H||nv<0||nv>=W)continue;
      if(s[nu][nv]=='.')continue;
      cnt ++;
      dfs(nu,nv);
    
  }
  return cnt;

}
int keta_wa(int x){
  int tot=0;
  while(x>0){
    tot +=x%10;
    x/=10;
  }
  return tot;
}

//vc alp ={'a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z'};
//cout<<""<<endl;
int main(){
 int N;cin>>N;cout<<"ABC"<<N<<endl;
}





Measured memory_bytes: 256
//0-1knapsack
#include<iostream>
#include<algorithm>
using namespace std;
int dp[104][10004];
int w[105],v[10005];
const int INF=-1;
int main(){
	int N,W;//N個の品物、Wまで入る
	cin>>N>>W;
	for(int i=1;i<=N;i++)cin>>v[i]>>w[i];//vが価値、wが重さ
	for(int i=0;i<104;i++)for(int j=0;j<10004;j++)dp[i][j]=INF;
	dp[0][0]=0;
	for(int i=0;i<N;i++){
		//dp[i][j]!=INFなら、品物iを入れる状態と入れない状態に分岐
		for(int j=0;j<=W;j++){
			if(dp[i][j]!=INF){
			dp[i+1][j]=max(dp[i+1][j],dp[i][j]);
			if(j+w[i+1]<=W){
			dp[i+1][j+w[i+1]]=max(dp[i+1][j+w[i+1]],dp[i][j]+v[i+1]);
			}
			}
		}
	}

	/*for(int i=0;i<=N;i++){
		for(int j=0;j<=W;j++)cout<<dp[i][j]<<" ";
		cout<<endl;
	}*/
	int ans=0;
	for(int i=0;i<=W;i++)ans=max(ans,dp[N][i]);
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 5236
#include <iostream>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#include <vector>
#include <stdio.h>
#include <string>

int main(){
	int n; cin >> n;
  	int cnt = 0;
  	for(int i; i< 500001; i++){
    if(i*1.08 >= n && i*1.08 < n+1){
    cout << i << endl;
	cnt++;
    }
    }
    if(cnt == 0){
    cout << ":(" << endl; 
    }
    

  	
}

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

int main() {
  int n, k;
  cin >> n >> k;
  int snukes[n + 1];
  memset(snukes, 0, sizeof snukes);
  for (int i = 0; i < k; i++) {
    int d;
    cin >> d;
    for (int j = 0; j < d; j++) {
      int index;
      cin >> index;
      snukes[index]++;
    }
  }
  int r = 0;
  for (int i = 1; i <= n; i++) {
    if (!snukes[i])
      r++;
  }
  cout << r << endl;
  return 0;
}


Measured memory_bytes: 3624
#include <iostream>

using namespace std;

void swap_int_array(int array[], int a, int b);
bool check_ascending(int array[], int size);
bool one_swap_check(int array[], int size);

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


    int inputs[size];

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

    if(one_swap_check(inputs, size)) cout << "YES";
    else cout << "NO";

    return 0;
}

void swap_int_array(int array[], int a, int b){
    int tmp = array[a];
    array[a] = array[b];
    array[b] = tmp;
}

bool check_ascending(int array[], int size){
    int previous = array[0];
    for(int i = 1; i < size; i++){
        if(array[i] < previous) return false;
        previous = array[i];
    }
    return true;
}

bool one_swap_check(int array[], int size){
    int left = array[0];
    int swap_count = 0;
    int left_index = 0, right_index;
    for(int i = 1; i < size; i++){
        int right = array[i];
        if(left > right){
            swap_count++;
            if(left_index == 0) left_index = i;
            else right_index = i;
        }
        left = right;
    }

    if(swap_count == 0) return true;
    else if(swap_count > 2) return false;
    else if(swap_count == 1){
        swap_int_array(array, left_index - 1, left_index);
    }
    else if(swap_count == 2){
        swap_int_array(array, left_index - 1, right_index);
    }

    if(check_ascending(array, size)) return true;
    else return false;
}


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


#define rep(i,n) for(int i = 0 ; i< (n);i++)
using namespace std;


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


int main(){
	int n ; 
	cin >> n;
	vector<vector<int>> a(n,vector<int>(n-1));
	rep(i,n){//2行目 repeat 
	  rep(j,n-1){
		  cin >> a[i][j];
		  a[i][j]--;//ここまで二重配列の受け取り。
		}
		reverse(a[i].begin(),a[i].end());//配列をひっくり返す。理由 0番目の要素をとるより、末尾の要素をとるほうが早いから
	}
	vector<P> q;//qのサイズはまだ決めない　a:b のaとbを入れるpairの配列
	auto check = [&](int i ){//選手iが試合できるか
		if(a[i].size()==0) return;	
		int j = a[i].back();//jは対戦相手
		if(a[j].size() == 0 ) return;
		if(a[j].back() == i) {//対戦相手が自分であった場合。
			P p(i,j);//pairでp(i,j)っていうのを登録して、それをq（配列）の後ろに追加していく。その時に、(i,j)&(j,i)のだぶりが登録されてしまうので、次の行のifで、数字の大小によって操作するかしないかのif
			if(p.second <p.first) swap(p.first,p.second);
			q.push_back(p);
		  }
	  };
	rep(i,n){
		check(i);	
	  }
	  int day = 0;
	  while(q.size() > 0){//試合表、つまりqの配列が空になるまで繰り返す
		day ++;
		sort(q.begin(),q.end());//前のキューをプレブキューに移して、キューを殻にする swap二つの要素を入れ替える
		q.erase(unique(q.begin(),q.end()),q.end());//重複した要素を取り除く。
		vector<P> prevQ;//一回目ではprevQは空。
		swap(prevQ,q);
		for(P p : prevQ){
		  int i = p.first, j = p.second;
		  a[i].pop_back();
		  a[j].pop_back();
		  }
		 for(P p : prevQ){
		  int i = p.first, j = p.second;
			check(i);
			check(j);
		  }
		}
		rep(i,n){//試合が全部行われたかを判定しないといけない
			if (a[i].size()!=0){
				puts("-1");
			  return 0;
			  }
		}
		cout <<day<<endl;//yotube marukopi
		return 0;
}
	


Measured memory_bytes: 4224
#include <bits/stdc++.h>
using namespace std;
long long INF = 1000000000000000000;
int main(){
  int N;
  cin >> N;
  vector<long long> a(N);
  for (int i = 0; i < N; i++){
    cin >> a[i];
  }
  long long tv = -100;
  long long fv = INF;
  while (fv - tv > 1){
    long long mid = (tv + fv) / 2;
    vector<long long> b(N);
    for (int i = 0; i < N; i++){
      b[i] = a[i] + mid;
    }
    long long cnt = 0;
    for (int i = 0; i < N; i++){
      cnt += b[i] / (N + 1) - 1;
    }
    if (cnt >= mid){
      tv = mid;
    } else {
      fv = mid;
    }
  }
  long long ans = tv;
  long long curr = tv;
  while (1){
    vector<long long> b(N);
    for (int i = 0; i < N; i++){
      b[i] = a[i] + curr;
    }
    long long cnt = 0;
    for (int i = 0; i < N; i++){
      cnt += b[i] / (N + 1);
    }
    ans = curr - 1;
    if (cnt < curr && curr > 0 || curr == tv + 1000000){
      break;
    }
    curr++;
  }
  cout << ans << endl;
}

Measured memory_bytes: 3632