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

template<typename T1, typename T2> void cmax(T1 &a, T2 b) { if (a < b) a = b; }
template<typename T1, typename T2> void cmin(T1 &a, T2 b) { if (a > b) a = b; }

template<typename T> class Dijkstra {
  struct edge {
    int to; T cost;
  };
  vector<vector<edge>> G;
  vector<T> D;
public:
  Dijkstra(int n) : G(n), D(n, numeric_limits<T>::max()) {}
  void add(int from, int to, T cost) {
    G.at(from).push_back((edge) {to, cost});
  }
  vector<T> build(int start) {
    using pit = pair<int, T>;
    priority_queue<pit, vector<pit>, greater<pit>> Q;
    D.at(start) = 0;
    Q.push(pit(start, 0));
    while (Q.size()) {
      auto [now, dist] = Q.top();
      Q.pop();
      if (dist > D.at(now)) continue;
      for (auto [next, cost] : G.at(now)) {
        if (dist + cost < D.at(next)) {
          D.at(next) = dist + cost;
          Q.push(pit(next, D.at(next)));
        }
      }
    }
    return D;
  }
  void reset() {
    fill(D.begin(), D.end(), numeric_limits<T>::max());
  }
};

signed main() {
  cin.tie(nullptr);
  ios_base::sync_with_stdio(false);

  int H, W;
  cin >> H >> W;
  pair<int, int> c, d;
  int a, b;
  cin >> a >> b, a--, b--;
  c = {a, b};
  cin >> a >> b, a--, b--;
  d = {a, b};
  vector<vector<char>> S(H, vector<char>(W));
  for (int i = 0; i < H; i++) {
    for (int j = 0; j < W; j++) {
      cin >> S.at(i).at(j);
    }
  }

  vector<int> mh {-1, 0, 1, 0};
  vector<int> mw {0, 1, 0, -1};
  Dijkstra<int> D(H * W);

  auto id = [&](pair<int, int> p) {
    return W * p.first + p.second;
  };

  for (int h = 0; h < H; h++) {
    for (int w = 0; w < W; w++) {
      for (int i = 0; i < 4; i++) {
        int nh = h + mh.at(i);
        int nw = w + mw.at(i);
        if (nh < 0 || nh >= H || nw < 0 || nw >= W) continue;
        if (S.at(nh).at(nw) == '#') continue;
        D.add(id({h, w}), id({nh, nw}), 0);
      }
      for (int nh = h - 2; nh <= h + 2; nh++) {
        for (int nw = w - 2; nw <= w + 2; nw++) {
          if (nh < 0 || nh >= H || nw < 0 || nw >= W) continue;
          if (S.at(nh).at(nw) == '#') continue;
          D.add(id({h, w}), id({nh, nw}), 1);
        }
      }
    }
  }

  int ans = D.build(id(c)).at(id(d));
  if (ans == INT_MAX) ans = -1;
  cout << ans << "\n";
}

Measured memory_bytes: 206416
#include<bits/stdc++.h>
using namespace std;
#define endl '\n'
#define lli long long int
#define REP1(i, n) for(lli i = 0; i < n; i++)
#define REP2(i, n) for(lli i = 1; i <= n; i++)
#define pb push_back
#define ff first
#define ss second
#define pr pair<lli, lli>
#define mp make_pair
#define vi vector<lli>
#define mii map<lli, lli>
#define mod 1000000007
     
void solution()
{
	lli n, x, t;
	cin >> n >> x >> t;
	if(n >= x)
	{
		if(n % x == 0)
			cout << (n / x) * t;
		else
			cout << ((n / x) + 1) * t;
	}
	else
		cout << t;
}

int main()
{
    #ifndef ONLINE_JUDGE
    // for getting input from input.txt
    freopen("Input.txt", "r", stdin);
    // for writing output to output.txt 
    freopen("Output.txt", "w", stdout);
    #endif
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int t;
   // cin >> t;	
    //while(t--)
        solution();
    return 0;
}
    

Measured memory_bytes: 3568
#include <iostream>
#include <algorithm>
#include <cstring>
#include <cmath>
#include <vector>
#include <set>
#include <queue>
#include <map>
#include <string>

#define rep(i, a, b) for ( int i = (a); i < (b); i++ )
#define per(i, a, b) for ( int i = (b)-1; i >= (a); i--)
#define pb push_back
#define mp make_pair
#define bg begin()
#define en end()


using namespace std;

typedef long long ll;

static const long long MOD = 1000000007;
static const int INF = 1000000000;

int ans, N, K;
int D[10];

int main(void) {
    scanf("%d %d", &N, &K);
    rep(i, 0, K) scanf("%d", &D[i]);

    rep(i, N, 1000000) {
        string x = to_string(i);
        bool ok = true;
        for (int j = 0; j < x.size(); j++) {
            for (int k = 0; k < K; k++) {
                if (x[j]-'0' == D[k]) {
                    ok = false;
                }
            }
        }
        if (ok) {
            printf("%d\n", i);
            return 0;
        }    
    }
	return 0;
}


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

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

    int P[N];
    for(int i=0; i<N; ++i) cin >> P[i];

    // ある時点の最小値
    int m = P[0];

    // 求める答え
    int ans = 0;

    for(int i=0; i<N; ++i){
        if(P[i] <= m) ++ans;
        m = min(m, P[i]);
    }
    cout << ans << endl;
}

Measured memory_bytes: 1024
N = int(input())
A = list(map(int, input().split()))

A_min = min(A)
while(True):
    amin = max(A)
    for i in range(N):
        if A_min == A[i]:
            continue
        A[i] %= A_min
        if A[i] > 0 and A[i] <= amin:
            amin = A[i]
    A_min = amin
    if max(A) == A_min:
        break

print(max(A))


Measured memory_bytes: 14252
import java.util.*;

class Main{
    static int[] motoX;//³ÉÈéÜêüÌxÀW
    static int[] motoY;//³ÉÈéÜêüÌyÀW
    static int[] count;//½ÔÚÌ`Æêvµ½©
    static int kaitensu;//ñ]
    static int n;//ÜêüÌ{

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

	int honsu = sc.nextInt();//ÜêüÌ{
	while(honsu!=0){
	    count = new int[honsu+1];	
	    n = 0;	    
	    //³ÆÈéÜêü
	    int moto = sc.nextInt();
	    motoX = new int[moto];
	    motoY = new int[moto];
	    for(int i=0; i<moto; i++){
		motoX[i] = sc.nextInt();
		motoY[i] = sc.nextInt();
	    }
	    
	    //är·éÜêüÌ¾¯JèÔ·
	    while(honsu!=0){
		n++;
		kaitensu = 0;
		//är·éÜêü
		int m = sc.nextInt();
		int[] x = new int[m];
		int[] y = new int[m];
		for(int i=0; i<m; i++){
		    x[i] = sc.nextInt();
		    y[i] = sc.nextInt();
		}
		solve(x,y);
		
		honsu--;
	    }
	    //êvµ½ÜêüÌÔðoÍ
	    for(int i=0; i<count.length; i++){
		if(count[i]==1)System.out.println(i);
	    }
	    System.out.println("+++++");
	    honsu = sc.nextInt();
	}
    }

    public static void solve(int[] x, int[] y){
	if(x.length!=motoX.length)return;//¸_ÌªáÁ½çreturn
	for(int j=0; j<2; j++){
	    int moveX = motoX[0]-x[0];//³ÌÜêüÆär·éÜêüÆÌÀW·
	    int moveY = motoY[0]-y[0];
	    if(hantei(x,y,moveX,moveY))count[n] = 1;//êv·é©»è
	    x = reverse(x);//tÉ·é
	    y = reverse(y);
	}

	if(kaitensu==3){return;}//êüµ½
	kaiten();//³ÌÜêüðñ]
	solve(x,y);
    }
    
    //³Ì`Æär·é`ªêvµÄ¢é©Ç¤©»è·é
    public static Boolean hantei(int[] x, int[] y, int moveX, int moveY){
	for(int i=0; i<x.length; i++){
	    if(x[i]+moveX != motoX[i])return false;
	    if(y[i]+moveY != motoY[i])return false;
	}
	return true;
    }
   
    //³Ì`ð90xñ]·é
    public static void kaiten(){
	kaitensu++;
	for(int i=0; i<motoX.length; i++){
	    int temp = motoX[i];
	    motoX[i] = motoY[i];
	    motoY[i] = temp - temp - temp;
	}
    }

    //zñÌgðtÉ·é
    public static int[] reverse(int[] line){
	int[] reverse = new int[line.length];
	for(int i=0; i<line.length; i++){
	    reverse[i] = line[line.length-i-1];
	}
	return reverse;
    }
}

Measured memory_bytes: 12000
d = int(input())
c = list(map(int,input().split()))
cmax = max(c)
for al in range(26):
  if c[al] == cmax:
    maxc = al
cmax2 = 0
maxc2 = -1
for al in range(26):
  if al == maxc:
    continue
  if c[al] > cmax2:
    cmax2 = c[al]
    maxc2 = al
m = [maxc,maxc2]
up = []
for _ in range(d):
  up.append(list(map(int,input().split())))
ans = [[-1] for _ in range(26)]
for i in range(d):
  ans[m[i%2]].append(i)
task = [m[i%2] for i in range(d)]
#print(m)
#print(ans)
#print(task)
#print(task)
#ans[0].append(0)
#ans[16].append(1)
#ans[12].append(2)
#ans[13].append(3)
#ans[12].append(4)

for al in range(26):
  ans[al].append(d)
#print(ans)
import bisect
from random import random
from random import randrange
import math
scr = 0
for al in range(26):
  now = ans[al]
  l = len(now)
  for j in range(1,l):
    scr -= c[al] * (now[j]-now[j-1]-1) * (now[j]-now[j-1]) // 2
    #print(c[al] * (now[j]-now[j-1]-1) * (now[j]-now[j-1]) // 2)
  for j in range(1,l-1):
    scr += up[now[j]][al]
    #print(up[now[j]][al])
  #print('$')
#print(scr)
est = 20000
for kk in range(222):
  for _ in range(10000):
    day = randrange(d)
    pre = task[day]
    pst = randrange(26)
    if pre == pst:
      continue
    bpre = bisect.bisect_left(ans[pre],day)
    bpst = bisect.bisect_left(ans[pst],day)
    bpre1 = ans[pre][bpre-1]
    bpre2 = ans[pre][bpre+1]
    bpst1 = ans[pst][bpst-1]
    bpst2 = ans[pst][bpst]
    #print(day,ans[pre][bpre],ans[pst][bpst])
    #print(day)
    #print(bpre1,day,bpre2,'#',pre)
    #print(bpst1,day,bpst2,'#',pst)
    tmp = 0
    tmp -= c[pre] * (day-bpre1) * (bpre2-day)
    #print(c[pre] * (day-bpre1) * (bpre2-day))
    tmp += c[pst] * (day-bpst1) * (bpst2-day)
    #print(c[pst] * (day-bpst1) * (bpst2-day))
    tmp -= up[day][pre]
    #print(up[day][pre])
    tmp += up[day][pst]
    #print(up[day][pst])
    #print(tmp)
    r = random()
    if est > 0:
      exp = math.exp(tmp/est)
    else:
      exp = bool(tmp>0)
    if exp > r:
      #print(ans[pre])
      #print(ans[pst])
      ans[pre].remove(day)
      bisect.insort(ans[pst],day)
      #print(ans[pre])
      #print(ans[pst])
      task[day] = pst
      scr += tmp
      #print(scr)
    #print('%')
  est -= 100
  if 200 <= kk < 210:
    est = 100 - (kk-200) * 10
#for x in ans:
  #print(x)
for x in task:
  print(x+1)
#print(scr)

Measured memory_bytes: 92712
#include <iostream>
#include <string>
using namespace std;
int main (){
    string wordT, wordH;
    int  scoreT = 0, scoreH = 0, n;
    cin >> n;
    for (int i = 0; i < n; i++ ){
        cin >> wordT >> wordH;
        if (wordT > wordH){
            scoreT += 3;
        } else if (wordT == wordH){
            scoreT += 1;
            scoreH += 1;
        } else {
            scoreH += 3;
        }
    }
    cout << scoreT  << " " << scoreH << endl;
}


Measured memory_bytes: 3192
#include <iostream>
#include <algorithm>
#include <vector>
#include <numeric>

using namespace std;

int n, m;
vector<int> s[10];
int p[10];
int on[10] = {0};

int dfs(int i) {
    //cerr << i << ' ' << n << '\n';
    if (i == n) {
        bool yes = true;
        for (int j = 0; j < m; j++) {
            int sum=0;
            for (auto sjk : s[j]) sum += on[sjk];
            //cerr << sum << '\n';
            if (sum % 2 != p[j]) {
                yes = false;
                break;
            }
        }
        return (int)yes;
    } else {
        int a, b;
        on[i] = 0;
        a = dfs(i + 1);
        on[i] = 1;
        b = dfs(i + 1);
        return a + b;
    }
}

int main() {
    cin >> n >> m;
    for (int i = 0; i < m; i++) {
        int k; cin >> k;
        for (int j = 0; j < k; j++) {
            int sij; cin >> sij;
            s[i].push_back(sij - 1);
        }
    }
    for (int i = 0; i < m; i++) cin >> p[i];
    cout << dfs(0) << '\n';
    return 0;
}


Measured memory_bytes: 384
#include <stdio.h>

int main(void)
{
    int k, a, b;
    scanf("%d", &k);
    scanf("%d %d", &a, &b);
    if(!(a % k) || (a / k)*k + k <= b) printf("OK\n");
    else printf("NG\n");
    return 0;
}

Measured memory_bytes: 1644
def main():
    n,m=map(int,input().split())
    CARD=[0]*(n+1)
    for i in range(m):
        L,R=map(int,input().split())
        CARD[L-1]+=1
        CARD[R]-=1
    ans=0
    for i in range(n):
        if CARD[i]==m:ans+=1
        CARD[i+1]=CARD[i+1]+CARD[i]

    print(ans)

if __name__=='__main__':
    main()

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

using namespace std;
int n;
vector<vector<int>> S;

int main() {
    cin >> n;
    int k = 2;
    int nc = 1;
    S.push_back(vector<int>({1}));
    S.push_back(vector<int>({1}));
    bool ok = true;
    while (nc < n) {
        S.push_back(vector<int>());
        for (int i = 0; i < k; ++i) {
            S[i].push_back(nc + i + 1);
            S[k].push_back(nc + i + 1);
        }
        nc+=k;
        k++;
        //cout << nc << endl;
        if (nc == n) {
            break;
        }
        if (nc > n) {
            ok = false;
            break;
        }
    }
    if (ok) {
        cout << "Yes" << endl;
        cout << S.size() << endl;
        for (vector<int> si : S) {
            cout << si.size();
            for (int sij : si) {
                cout << " " << sij;
            }
            cout << endl;
        }
    } else {
        cout << "No" << endl;
    }
}

Measured memory_bytes: 2304
#include <bits/stdc++.h>
using namespace std;
#ifdef _DEBUG
  #include "_DEBUG.hpp"
#endif
#define int long long
const int INF = 1LL << 60;
const int MOD = 1e9 + 7;

signed main(){

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

  return 0;
}

Measured memory_bytes: 3620
#include<bits/stdc++.h>
using namespace std;
#define fast ios_base::sync_with_stdio(0);cin.tie(NULL)
#define ll long long
#define fm_t  ll t;cin>>t;while(t--)
#define fr(i,a,b) for( ll i=a;i<b;i++)
#define fr1(i,n,a) for( ll i=n-1;i>=a;i--)
#define sz(x) (ll)(x).size()
#define all(v)  (v).begin(), (v).end()
#define Sort(x) sort(x.begin(),x.end())
#define ms(a) memset(a,0,sizeof(a))
#define endl '\n'
#define pb push_back
#define ff first
#define ss second
const ll mod = 998244353;
#define Mod 1000000007

#define inf 1e18
#define ld long double
#define pll pair<ll, ll> 
#define vi vector<int>
#define vl vector<ll> 
#define vvl vector< vector<ll> > 
#define vvi vector< vector<int> >
#define vlp vector< pair<ll, ll> >
#define vllp vector<pair<ll, ll>, ll >
#define pi pair<ll, ll>
#define ppi pair<pair<ll, ll>, ll>
#define ump unordered_map<ll,ll>
#define pri priority_queue< pair<ll,ll> , vector< pair<ll,ll> >, greater< pair<ll,ll> > >
void ingraph(vl graph[], ll m){ll x, y;fr(i,0,m){cin>>x>>y;x--, y--;graph[x].pb(y);graph[y].pb(x);}}

#define max3(a, b, c)   max(max(a, b), c)
#define min3(a, b, c)   min(min(a, b), c)

//setprecision(10)
//greater<int>()
ll gcd(ll a, ll b){if(b==0)return a;return gcd(b, a%b);}
ll lcm(ll a, ll b){return a*b/gcd(a, b);}


ll modmulti(ll a, ll b){
   return ((a%mod)*1ll*(b%mod))%mod;
}
ll modadd(ll a, ll b){
   ll asdfgh =  ((a%mod)+(b%mod)+mod+mod)%mod;
   asdfgh = (asdfgh+mod)%mod;
   return asdfgh;
}
ll modpower(ll a, ll n){
   if(n==0) return 1;
   if(n==1) return a%mod;
   ll b = modpower(a,n/2);
   b = modmulti(b,b);
   if(n%2==0) return b;
   return modmulti(a,b);
}
ll modinv(ll a){
    return modpower(a,mod-2);
}
ll dp[100005]; 
ll visited[100005];  

void dfs(ll u,vl adj[])
{
  visited[u]=1;
  ll mx=0;
  for(auto it:adj[u])
  {
    if(visited[it]==0)
      dfs(it,adj);
    dp[u]=max(dp[u],dp[it]+1);
  }

}
     
int main()
{
      
  fast;
  ll n,m;
  cin>>n>>m;
  vl adj[n];
  fr(i,0,m)
  {
    ll a,b;
    cin>>a>>b;
    a--;
    b--;
    adj[a].pb(b);
  }

  fr(i,0,n)
  dfs(i,adj);

  ll ans=0;
  fr(i,0,n)
  ans=max(ans,dp[i]);
  cout<<ans<<endl;
  

    
//cerr << "Time elapsed: " << clock() / (double)CLOCKS_PER_SEC << endl;
return 0;
}

Measured memory_bytes: 14072
#include <stdio.h>
#define _USE_MATH_DEFINES
#include <math.h>
#include <vector>
#include <algorithm>
#include <iostream>

using namespace std;

int main(){
    char str[1];
    scanf("%s", str);
    if(str[0] > 96){
        std::cout << "a" << std::endl;
    } 
    if(str[0] < 91){
        std::cout << "A" << std::endl;
    }
    
    return 0;
}


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

using ll =  long long;
using pint =  pair<int,int>;

#define INF 99999999
#define rep(i,n) for(int (i)=0,temp=(int)(n);(i)<temp;++(i)) 
#define repi(i,start,end) for(int (i)=(start),temp=(int)(end);i<(end);++(i))
#define rfor(v,x) for(const auto& (x) : (v)) //xは値を表す
#define all(x) (x).begin(),(x).end()
#define SORT(v, n) sort((v), (v)+(n))
#define vsort(v) sort((v).begin(), (v).end())
#define vfsort(v,lambda) sort(all((v)),(lambda))
#define vint vector<int>
#define vvint vector<vector<int>> //vvint v(n,vint(n))のように宣言できる
#define vin(v) rep(i,(v).size()) {cin >> (v)[i];}
//最終奥義
//#define int long long
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; }
int gcd(int a,int b){return b?gcd(b,a%b):a;}
int ctoi(char c) {return c-'0';}
//lambda式 -> [&](int x, int y){return x<y;}
//vector内の重複を削除-> v.erase(unique(all(v)),v.end());

signed main(void){
  int n;cin>>n;
  vint d(n);vin(d);
  int ans=0;
  rep(i,n-1){
    repi(j,i+1,n){
      ans+=d[i]*d[j];
    }
  }
  cout << ans << endl;


}


Measured memory_bytes: 256
#include <stdio.h>
int bubbleSort(int*,int);
int main(){
  int A[100],i,j,N,s;
  scanf("%d",&N);
  for(i=0;i<N;i++)
    scanf("%d",&A[i]);
  s=bubbleSort(A,N);

  for(i=0;i<N;i++){
    printf("%d",A[i]);
    if(i==N-1)break;
    printf(" ");
  }
  printf("\n");
  
  printf("%d\n",s);
  return 0;
}

int bubbleSort(int A[],int N){
  int s = 0,flag=1,i,j,tmp;
  while(flag==1){
    flag=0;
    for(j=N-1;j>=1;j--){
      if(A[j]<A[j-1]){
	tmp=A[j];
	A[j]=A[j-1];
	A[j-1]=tmp;
	flag=1;
	s++;
      }
    }
  }
  return s;
}



Measured memory_bytes: 2752
import math

N, D = map(int, input().split())
table = [[int(i) for i in input().split()] for _ in range(N)]

temp = []

for i in range(N):
    for j in range(i + 1, N):
        sum = 0
        for k in range(D):
            # print(table[i][k], table[j][k])
            sum += abs(table[i][k] - table[j][k]) ** 2
        else:
            temp.append(sum)

ans = 0

for i in temp:
    if math.sqrt(i).is_integer():
        ans += 1

print(ans)


Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> pll;
typedef tuple<ll, ll, ll> tll;

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll N, K;
    cin >> N >> K;
    vector<ll> nums(N);
    ll minIndex = -1;
    ll minValue = 1e12;
    for (ll i = 0; i < N; i++)
    {
        cin >> nums.at(i);
        if (nums.at(i) < minValue)
        {
            minIndex = i;
            minValue = nums.at(i);
        }
    }
    ll answer = 1e12;
    for (int i = minIndex; i < minIndex + K; i++)
    {
        //iを右端として一回実行後、左右の余りを埋めつくすのに必要な回数を計算
        ll leftRemainNum = max((ll)0, i + 1 - K);
        ll leftConvertNum = (leftRemainNum + K - 2) / (K - 1);
        ll rightRemainNum = max((ll)0, N - i - 1);
        ll rightConvertNum = (rightRemainNum + K - 2) / (K - 1);
        answer = min(answer, 1 + leftConvertNum + rightConvertNum);
    }
    cout << answer << endl;
    return 0;
}


Measured memory_bytes: 1024
#include <algorithm>
#include <cstdio>
#include <climits>

const int N = 5000;

int dp[2][N + 1];
std::pair<int, int> a[N];

bool cmp(const std::pair<int, int>& a, const std::pair<int, int>& b)
{
    return a.first + a.second < b.first + b.second;
}

void update(int& x, int a)
{
    x = std::min(x, a);
}

int main()
{
    int n;
    while (scanf("%d", &n) == 1) {
        for (int i = 0; i < n; ++ i) {
            scanf("%d%d", &a[i].first, &a[i].second);
        }
        std::sort(a, a + n, cmp);
        dp[0][0] = 0;
        for (int i = 0; i < n; ++ i) {
            for (int j = 0; j <= i + 1; ++ j) {
                dp[i + 1 & 1][j] = INT_MAX;
            }
            for (int j = 0; j <= i; ++ j) {
                update(dp[i + 1 & 1][j], dp[i & 1][j]);
                if (dp[i & 1][j] <= a[i].first) {
                    update(dp[i + 1 & 1][j + 1], dp[i & 1][j] + a[i].second);
                }
            }
        }
        int ans = n;
        while (dp[n & 1][ans] == INT_MAX) {
            ans --;
        }
        printf("%d\n", ans);
    }
}


Measured memory_bytes: 384
#include<iostream>
#include<vector>
#include<cstdio>
#include<string>
#include<algorithm>
#include <sstream>
#include<map>
#include<cmath>
#include<queue>

using namespace std;

int main() {

	double A, B;
	cin >> A >> B;

	int result = abs(A - B);

	if (result % 2 == 0)
	{
		result /= 2;

		if (A > B)
		{
			result = A - result;
		}
		else
		{
			result = B - result;
		}
		cout << result << endl;
	}
	else
	{
		cout << "IMPOSSIBLE" << endl;
	}

	
	return 0;
}

Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#include<iostream>
#include<string>
#include<queue>
#include<cmath>
#include<map>
#include<set>
#include<list>
#include<iomanip>
#include<vector>
#include<random>
#include<functional>
#include<algorithm>
#include<stack>
#include<cstdio>
#include<bitset>
#include<unordered_map>
#include<climits>
#include<fstream>
using namespace std;
///////////////////library zone!!!!!!!!!!!!!!!!!!!!!!!!!!!!
typedef long long ll;
typedef long double ld;
#define all(a) (a).begin(),(a).end()
#define EPS (1e-5)
#define bit(n,k) ((n>>k)&1)
const ll Mod = 1000000007;
const ll mod = 998244353;
struct H {
	ll x, y;
	bool operator<(const H& b) const {
		if (x != b.x) return x < b.x;
		return y < b.y;
	}
	bool operator>(const H & b) const {
		if (x != b.x) return x > b.x;
		return y > b.y;
	}
	bool operator==(const H & b) const { return x == b.x && y == b.y; }
	bool operator!=(const H & b) const { return (*this) != b; }
};
struct P {
	ll pos, cost;
	bool operator<(const P& b) const { return cost < b.cost; }
	bool operator>(const P& b) const { return cost > b.cost; }
};
struct B {
	ll to, cost;
};
struct E {
	ll from, to, cost;
	bool operator<(const E& b) const { return cost < b.cost; }
	bool operator>(const E& b) const { return cost > b.cost; }
};
template<typename T, typename U>
void chmin(T & a, U b) {
	if (a > b) a = b;
}
template<typename T, typename U>
void chmax(T & a, U b) {
	if (a < b) a = b;
}
template<typename T>
T max_0(T a) {
	if (a < 0) return 0;
	return a;
}
template<typename T>
T min_0(T a) {
	if (a > 0) return 0;
	return a;
}
ll read() {
	ll u;
	ll k = scanf("%lld", &u);
	return u;
}
ll gcd(ll i, ll j) {
	if (i > j) swap(i, j);
	if (i == 0) return j;
	return gcd(j % i, i);
}
ll mod_pow(ll x, ll n, ll p) {
	ll res = 1;
	while (n > 0) {
		if (n & 1) res = res * x % p;
		x = x * x % p;
		n >>= 1;
	}
	return res;
}//x^n%p
const ll Inf = 3023372036854775807;
const int inf = 1500000000;
#define int long long
//----------------------------------------------------
int w, h, x, y;
signed main() {
	cin >> w >> h >> x >> y;
	cout << (w * h) / 2. << " ";
	if (x == w / 2. && y == h / 2.) {
		cout << 1 << endl;
	}
	else {
		cout << 0 << endl;
	}
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define maxn 500005
using namespace std;
const int mod = 998244353;
int n,m,ans,fac[maxn],inv[maxn];
int Pow(int a,int b){int s=1;for(;b;b>>=1,a=1ll*a*a%mod) b&1&&(s=1ll*s*a%mod);return s;}
int C(int n,int m){return 1ll*fac[n]*inv[m]%mod*inv[n-m]%mod;}
int main()
{
	scanf("%d%d",&n,&m); if(n>m) swap(n,m);
	for(int i=fac[0]=inv[0]=1;i<=m;i++) fac[i]=1ll*fac[i-1]*i%mod;
	inv[m]=Pow(fac[m],mod-2);
	for(int i=m-1;i>=1;i--) inv[i]=1ll*inv[i+1]*(i+1)%mod;
	for(int i=0;i<=n;i++) ans=(ans+(i&1?-1:1)*1ll*C(n,i)*C(m,i)%mod*fac[i]%mod*Pow(m+1,n-i)%mod*Pow(n+1,m-i))%mod;
	printf("%d\n",(ans+mod)%mod);
}

Measured memory_bytes: 7700
#include <bits/stdc++.h>
using namespace std;
int main(void){
    long long a,b; cin>>a>>b;
    if(a==b) {cout<<b<<endl; return 0;}
    long long t = 0;
    queue<long long> q;
    if(a%2==1) {q.push(a); a++;}
    if(b%2==0) {q.push(b); b--;}
    int x=(b-a+1)/2;
    if(x%2==0) t=0;
    else t=1;
    while(q.size()!=0){
        long long tmp=q.front(); q.pop();
        t=t^tmp;
    }
    cout<<t<<endl;
}

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

#define _overload(_1,_2,_3,name,...) name
#define _rep(i,n) _range(i,0,n)
#define _range(i,a,b) for(int i=int(a);i<int(b);++i)
#define rep(...) _overload(__VA_ARGS__,_range,_rep,)(__VA_ARGS__)

#define _rrep(i,n) _rrange(i,n,0)
#define _rrange(i,a,b) for(int i=int(a)-1;i>=int(b);--i)
#define rrep(...) _overload(__VA_ARGS__,_rrange,_rrep,)(__VA_ARGS__)

#define _all(arg) begin(arg),end(arg)
#define uniq(arg) sort(_all(arg)),(arg).erase(unique(_all(arg)),end(arg))
#define getidx(ary,key) lower_bound(_all(ary),key)-begin(ary)
#define clr(a,b) memset((a),(b),sizeof(a))
#define bit(n) (1LL<<(n))
#define popcount(n) (__builtin_popcountll(n))

using namespace std;

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

typedef long long ll;
typedef long double R;
const R EPS=1e-9L; // [-1000,1000]->EPS=1e-8 [-10000,10000]->EPS=1e-7
inline int sgn(const R& r){return(r > EPS)-(r < -EPS);}
inline R sq(R x){return sqrt(max(x,0.0L));}

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

// Problem Specific Parameter:

int main() {
  int n; cin >> n;
  int c[500], s[500], f[500];
  for(int i = 0; i < n-1; ++i) cin >> c[i] >> s[i] >> f[i];
  for(int i = 0; i < n; ++i) {
    int t = 0;
    for(int j = i; j < n-1; ++j) {
      if(t<s[j]) t = s[j];
      else if(t % f[j] == 0);
      else t = t + f[j] - t%f[j];
      t += c[j];
    }
    cout << t << endl;
  }

  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#define TREE_SIZE 30
#define NIL -1
using namespace std;

struct Node 
{
    int parent_node = NIL;
    int left_child = NIL;
    int right_child = NIL;
};

Node Tree[TREE_SIZE];
int Depth[TREE_SIZE];
int Height[TREE_SIZE];

// set depth of all nodes by recursion
void Set_depth_of_node(int node_id, int depth)
{
    Depth[node_id] = depth;
    // if there is a child
    if (Tree[node_id].left_child != NIL) Set_depth_of_node(Tree[node_id].left_child, depth+1);
    if (Tree[node_id].right_child != NIL) Set_depth_of_node(Tree[node_id].right_child, depth+1);
}

// set height of all nodes by recursion
int Set_height_of_node(int node_id) 
{
    int l_height = 0, r_height = 0;
    // if there is a child
    if (Tree[node_id].left_child != NIL) l_height = Set_height_of_node(Tree[node_id].left_child) + 1;
    if (Tree[node_id].right_child != NIL) r_height = Set_height_of_node(Tree[node_id].right_child) + 1;

    return Height[node_id] = (l_height < r_height ? r_height : l_height);
}

int main() 
{
    int node_num, node_id, l_child, r_child;
    scanf("%d", &node_num);
    for (int i = 0; i < node_num; ++i) 
    {
        scanf("%d %d %d", &node_id, &l_child, &r_child);
        Tree[node_id].left_child = l_child;  // set left child
        Tree[node_id].right_child = r_child; // set right child 
        
        // set parent if the node has children
        if (l_child != -1) Tree[l_child].parent_node = node_id;
        if (r_child != -1) Tree[r_child].parent_node = node_id;
    }

    // search root of Tree
    int root = 0;
    while (Tree[root].parent_node != NIL) 
    {
        root++;
    }

    // set depth of all nodes
    Set_depth_of_node(root, 0);

    // set height of all nodes
    Set_height_of_node(root);

    // print out below
    for (int i = 0; i < node_num; ++i) 
    {
        printf("node %d: parent = %d, ", i, Tree[i].parent_node);

        // print out siblings
        if (Tree[i].parent_node == NIL) printf("sibling = -1, "); // if this is root
        else 
        {
            if (i == Tree[Tree[i].parent_node].left_child) // if this is left child, print right child
            {
                printf("sibling = %d, ", Tree[Tree[i].parent_node].right_child);
            }
            else // if this is right child, print left child
            {
                printf("sibling = %d, ", Tree[Tree[i].parent_node].left_child);
            }
        }

        // print out degree (number of children)
        int degree = 0;
        if (Tree[i].left_child != NIL) degree++;
        if (Tree[i].right_child != NIL) degree++;
        printf("degree = %d, ", degree);

        // print out depth
        printf("depth = %d, ", Depth[i]);

        // print out height
        printf("height = %d, ", Height[i]);

        // print out position
        if (i == root) printf("root\n");
        else if (degree == 0) printf("leaf\n");
        else printf("internal node\n");
    }
}


Measured memory_bytes: 3224
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define F first
#define S second
#define pii pair<int, int>
#define pll pair<ll, ll>
int main()
{
    ll x, y, ans = 0;
    cin >> x >> y;
    if (x == 1)
        ans += 300000;
    else if (x == 2)
        ans += 200000;
    else if (x == 3)
        ans += 100000;
    if (y == 1)
        ans += 300000;
    else if (y == 2)
        ans += 200000;
    else if (y == 3)
        ans += 100000;
    if (x == 1 && y == 1)
        ans += 400000;
    cout << ans << endl;
    return 0;
}

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

//#define int long long
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()
#define rep(i,n) for(int i=0;i<n;++i)
#define rep1(i,n) for(int i=1;i<n;++i)
#define exrep(i, a, b) for(ll i = a; i < b; i++)
#define out(x) cout << x << endl
#define EPS (1e-7)
#define gearup ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
typedef long double ld;
typedef long long int ll;
typedef unsigned long long int ull;
typedef vector<int> vi;
typedef vector<char> vc;
typedef vector<bool> vb;
typedef vector<double> vd;
typedef vector<string> vs;
typedef vector<pair<int,int> > vpii;
typedef vector<vector<int> > vvi;
typedef vector<vector<char> > vvc;
typedef vector<vector<bool> > vvb;
typedef vector<vector<double> > vvd;
typedef vector<vector<string> > vvs;
typedef vector<ll> vl;
typedef vector<vector<ll> > vvl;
typedef vector<vector<vector<ll> > > vvvl;
ll MOD = 1000000007;
const long long L_INF = 1LL << 60;
const int INF = 2147483647; // 2^31-1
const double PI = acos(-1);
//cout<<fixed<<setprecision(10);

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;}
template<class T> void debug(T v){rep(i,v.size()) cout<<v[i]<<" ";cout<<endl;}
const ll dx[8] = {1, 1, 0, -1, -1, -1, 0, 1};
const ll dy[8] = {0, 1, 1, 1, 0, -1, -1, -1};

map<ll,ll> factorize(ll n){
    map<ll,ll> ret;
    ll x = n;
    for(ll i = 2; i*i<=n;i++){
        while(x % i == 0){
            ret[i]++;
            x /= i;
        }
    }
    if(x != 1)ret[x]++;
    return ret;
}

// a^b mod を計算する
ll mod_pow(ll a, ll b, ll p) {
    if (b == 0) return 1;
    if (b & 1) return (a * mod_pow(a, b - 1, p)) % p;
    ll t = mod_pow(a, b / 2, p);
    return (t * t) % p;
}

ll mod_inv(ll a, ll p) { return mod_pow(a, p - 2, p); }

signed main()
{   
    gearup;
    ll n; cin >> n;
    vl a(n);
    rep(i,n)cin>>a[i];
    map<ll,ll> lcm;
    rep(i,n){
        map<ll,ll> res = factorize(a[i]);
        for(auto re:res){
            if(lcm[re.first] < re.second) lcm[re.first] = re.second;
        }
    }
    ll lcm_mod = 1;
    for(auto lc:lcm){
        lcm_mod = lcm_mod * mod_pow(lc.first,lc.second,MOD) % MOD;
    }

    vl l(n+1,1),r(n+1,1);
    for (int i = 0; i < n; i++)l[i + 1] = l[i] * a[i] % MOD;
    for (int i = n; i > 0; i--)r[i - 1] = r[i] * a[i - 1] % MOD;

    ll nume = 0; //分子
    for (int i = 0; i < n; i++) nume = (nume + l[i] * r[i + 1] % MOD) % MOD;

    ll deno = 1; //分母
    for (int i = 0; i < n; i++) deno = deno * a[i] % MOD;

    out(lcm_mod * nume % MOD * mod_inv(deno,MOD) % MOD);
}


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

int main() {
  int a, b, c;
  std::cin >> a >> b >> c;
  if (a == b) std::cout << c << std::endl;
  else if (a == c) std::cout << b << std::endl;
  else std::cout << a << std::endl;
  return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
#define A 200000
int main(void){
	int n,i,j,k;
	int R[A];
	scanf("%d",&n);
	for(i=0;i<n;i++){
		scanf("%d",&R[i]);
	}
	for(i=0;i<n-1;i++){
		if(i==0 || j>R[i]){
			j=R[i];
		}
		if(i==0 || k<R[i+1]-j){
			k=R[i+1]-j;
		}
	}
	printf("%d\n",k);
	return 0;
}


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

using namespace std;

using ll = long long;
using ld = long double;

const int INF = 1e9 + 10;
const ll MOD = 1e9 + 7;
const int N = 1e6 + 1;

void solve() {
	string s;
	cin >> s;
	cout << s.substr(0, 3) << endl;
}

int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	solve();
}


Measured memory_bytes: 3644
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<queue>
#include<deque>
#include<cmath>
#include<map>
#include<unordered_map>
#include<set>
#include<cstring>
#include<iomanip> //cout << fixed << setprecision(15) << x << endl;

using namespace std;
typedef long long ll;
const ll INF = 1e9 + 6;
const ll MOD = 1e9 + 7;
const ll LLINF = 1LL<<60;
#define P pair<int, int>
#define rng(i,a,b) for(int i=int(a);i<int(b);i++)
#define rep(i,b) rng(i,0,b)

#define pb push_back
#define mp make_pair
#define all(x) (x).begin(),(x).end()
/* -- template -- */

int main() {
    string N; cin >> N;
    int ans = 0;
    bool flg1 = true;
    rep(i, N.size() - 1) {
        ans += 9;
        if(N[i + 1] != '9') flg1 = false;
    }
    bool flg = true;
    rep(i, N.size()) if(N[i] != '9') flg = false;
    ans += ((flg) ? 9 : (N[0] - '0') - ((!flg1) ? 1 : 0));
    if(N.size() == 1) ans = N[0] - '0';
    cout << ans << endl;
}


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

#define int            long long int
#define float          long double
#define setbits(x)     __builtin_popcountll(x)
#define zrobits(x)     __builtin_ctzll(x)
#define mod            1000000007
#define inf            1e18
#define set_pre(x,y)   fixed<<setprecision(y)<<x
#define w(t)           int t; cin>>t; while(t--)

using namespace std;
int32_t main()
{
    string s;
    string t;
    cin>>s>>t;
    int dp[s.length()+1][t.length()+1];
    for(int i=0;i<=s.length();i++)
        dp[i][0]=0;
    for(int j=0;j<=t.length();j++)
        dp[0][j]=0;
    string ans;
    for(int i=1;i<=s.length();i++)
    {
        for(int j=1;j<=t.length();j++)
        {
            if(s[i-1]==t[j-1])
            {
                dp[i][j]=dp[i-1][j-1]+1;
            }
            else
            dp[i][j]=max(dp[i-1][j],dp[i][j-1]);
        }
    }
    int x=s.length();
    int y=t.length();
    int len=dp[x][y];
    while(len>0)
    {
        if(s[x-1]==t[y-1])
        {
            ans+=s[x-1];
            x--;
            y--;
            len--;
        } else
        {
            if(dp[x][y]==dp[x-1][y])
                x--;
            if(dp[x][y]==dp[x][y-1])
                y--;
        }
    }
    reverse(ans.begin(),ans.end());
    cout<<ans<<endl;
}

Measured memory_bytes: 70656
#include <iostream>
#include <algorithm>
#include <numeric>
#include <vector>
#include <string>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <stack>
#include <iomanip>
#include <functional>
#include <bitset>
#include <limits>
#include <cstdio>
#include <cmath>
#include <cassert>
#include <random>

#ifdef DEBUG
#include "library/Utility/debug.cpp"
#else
#define debug(...)
#endif

#define rep(i,n) for(int i=0;i<(n);++i)
#define EL '\n'
#define print(i) std::cout << (i) << '\n'
#define all(v) (v).begin(), (v).end()
using lnt = long long;
struct FIO{FIO(){std::cin.tie(0);std::cout.tie(0);std::ios_base::sync_with_stdio(0);std::cout<<std::fixed<<std::setprecision(15);}}fIO;
/*-*/

template <typename T>
std::vector<int> sort_indexes(const std::vector<T> &v) {
	std::vector<int> idx(v.size());
	std::iota(idx.begin(), idx.end(), 0);
	std::sort(idx.begin(), idx.end(), [&v](int i1, int i2) {return v[i1] < v[i2];});
	return idx;
}


int main() {
	int d;
	std::cin >> d;
	int N=26;
	std::vector<lnt> c(N);
	std::vector<std::vector<lnt> > v(d,std::vector<lnt>(N));
	rep(i,N) std::cin >> c[i];
	rep(i,d) {
		rep(j,N) {
			std::cin >> v[i][j];
		}
	}
	std::vector<int> last(N,-1);
	rep(i,d) {
		std::vector<int> idx(N);
		std::iota(idx.begin(), idx.end(), 0);
		double X=1; double Y=3;
		auto f = [&](int ix) -> double {
			return c[ix]*(i-last[ix]+X)+Y*v[i][ix];
		};
		std::sort(idx.begin(), idx.end(), [&](int i1, int i2) {return f(i1) > f(i2) ;});
		last[idx[0]]=i;
		print(idx[0]+1);
	}
	/*
	lnt sum=0;
	std::vector<int> last(N,-1);
	rep(i,d) {
		int t;
		std::cin >> t;
		t--;
		sum+=v[i][t];
		last[t]=i;
		rep(j,N) sum-=(i-last[j])*c[j];
		print(sum);
	}
	*/
}


Measured memory_bytes: 3760
// C - Good Sequence
#include <bits/stdc++.h>
using namespace std;
#define rp(i,s,e) for(int i=(s);i<(e);++i)

int main(){
	int N; cin>>N;
	map<int,int> M;
	rp(i, 0, N){ int a; cin>>a; M[a]++; }
	int ans = 0;
	for(auto m:M){
		int a,c; tie(a,c) = m;
		if(c>a) ans += c - a;
		else if(c<a) ans += c;
	}
	cout<< ans <<endl;
}

Measured memory_bytes: 4736
/*
auth - @sportykush
*/

#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;
 
typedef long long int ll;
typedef long double ld;
typedef tree<ll,null_type,less<ll>,rb_tree_tag,tree_order_statistics_node_update> ordered_set; 
 
//#define mp make_pair
#define bug(v)                    cerr<<#v<<" = "<<(v)<<endl;
#define ERASE(x)                  x.erase(unique(x.begin(),x.end()),x.end())
#define pb                        emplace_back
#define vii                       vector<int>
#define vll                       vector<ll>
#define vpll                      vector< pair <ll,ll> >
#define pll                       pair <ll,ll>
#define pii                       pair <int,int>
#define pq                        priority_queue< int >
#define khtm                      "\n"
#define F                         first
#define S                         second
#define fr(i,a,n)                 for(i=a;i<n;i++)
#define mem(arr,l)                memset(arr,l,sizeof arr)
#define ALL(x)                    x.begin(), x.end()
#define frr(i,a,n)                for(i=n-1;i>=a;i--)
#define fast                      ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define testcase                  ll T; cin>>T; while(T--)


const double pi = 3.14159265359;
const int MAX = 1e6 +2;
const ll inf =  1e18;
const int N = 1010;
//const ll mod = 998244353 ;
const ll mod=1e9+7;
inline ll add(ll a,ll b){a+=b;if(a>=mod)a-=mod;return a;}
inline ll mul(ll a,ll b){return ((a%mod)*1ll*b)%mod;}
inline ll power(ll a,ll b){ll rt=1;while(b>0){if(b&1)rt=mul(rt,a);a=mul(a,a);b>>=1;}return rt;}


/*
important builtin functions
__gcd(value1, value2)
__builtin_ffs(x)
  Number of leading zeroes: __builtin_clz(x)
  Number of trailing zeroes : __builtin_ctz(x)
  Number of set bits: __builtin_popcount(x)
*/
 

ll i,j,k,l,m,r,n;
ll a[MAX],b[MAX];

ll dp[102][MAX/10];

// ll solve(ll items,ll tot)
// {
// 	if(tot)
// 		return 0;
// 	ll &ans = dp[items][tot];
// 	if(ans != -1)
// 		return ans;

// }


int main()
{
 

//cout << setprecision(15) << fixed;
fast

	cin >> n >> k;
	fr(i,1,1+n)
		cin >> a[i] >> b[i];
	fr(i,0,n)
		fr(j,0,k)
		{
			if(j + a[i+1] <= k)
				dp[i+1][j + a[i+1]] = max(dp[i+1][j + a[i+1]], dp[i][j] + b[i+1]);
			dp[i+1][j] = max(dp[i+1][j], dp[i][j]);
		}
		
	ll ans = 0;
	for(int j = 0; j <= k; ++j)
		ans = max(ans, dp[n][j]);
	cout << ans;




  return 0;
 
}


Measured memory_bytes: 81408
#include<bits/stdc++.h>
using namespace std;
#define rep(i,x,y) for(int i=x;i<y;i++)
#define range(a) (a).begin(),(a).end()
#define print(A,x,n) rep(i,0,n){cout<<(i ? " ":"")<<A[i]x;}cout<<endl;
#define pprint(A,y,m,n) rep(j,0,m){print(A[j],y,n);}
const long mod=998244353;
const int siz=1e5;
const long inf=1e9;
int main(){
	int K; cin>>K;
	cout<<(K/2) * ((K+1)/2)<<endl;
}

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

#define int long long
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; }
#define rep(i,n) for(int i=0; i<(int)n; i++)
#define ll long long
#define all(x) (x).begin(), (x).end()
#define SZ(x) ((int)(x).size())
#define COUT(x) cout << x << endl;
#define PB(x) push_back(x)
#define MP make_pair
#define vint vector<int>
int gcd(int a,int b){return b?gcd(b,a%b):a;}
const int dx[4]={1,0,-1,0};
const int dy[4]={0,1,0,-1};
const int INF = 1e9;
const int MOD = 1e9+7;
//cout << std::fixed << std::setprecision(15);

signed main(){
    cout << std::fixed << std::setprecision(15);
    int n,k; cin >>  n>> k;
    vector<double> p(n);
    rep(i,n) cin >> p[i];
    vector<double> e(n);
    rep(i,n) e[i]=(p[i]+1)/2;
    vector<double> s(n+1,0);
    rep(i,n){
        s[i+1]=s[i]+e[i];
    }
    double res=0;
    for(int i=0; i<=n-k; i++){
        chmax(res,s[i+k]-s[i]);
    }
    cout<<res<<endl;


}

Measured memory_bytes: 4992
/*
   AUTHOR :- Gaurang_Kothiya
   
   Quote:-" Great things never come from comfort zones."                                                                                                                
*/
 
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>  
#include <ext/pb_ds/tree_policy.hpp> 
#include <functional>
#include <bitset>
#include <cstdint>
#include <initializer_list>
 
using namespace std;
using namespace __gnu_pbds;  

typedef tree<int, null_type, less<int>, rb_tree_tag,tree_order_statistics_node_update> data_set; 
#define speed ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define ll long long  
#define ld long double
#define f(i,x,n) for(int i=x;i<=n;++i)
#define fe(x,v)   for(auto &x :v)
#define nf(i,x,n) for(int i=n;i>=x;--i)
#define all(a)   a.begin(),a.end()
#define rall(a)  a.rbegin(),a.rend()
#define b_s(a,b)   binary_search( all(a),b)
#define lb(v,n)  lower_bound(all(v) ,n )
#define ub(v,n)  upper_bound( all(v) , n)
#define gcd(a,b) __gcd(a,b)
#define pub push_back
#define pob pop_back
#define puf push_front
#define pof pop_front
#define RE rend()
#define RB rbegin()
#define B begin()
#define E end()
#define acc(v, x) accumulate(all(v), x)
#define p(a,b) pair<a,b>
#define F first
#define S second
#define sz size()
#define v(x) vector<x>
#define m(a,b) map<a,b>
#define u_m(a,b) unordered_map<a,b>
#define mm(a,b) multimap<a,b>
#define s(a) set<a>
#define us(a) unordered_set<a>
#define ms(a) multiset<a>
#define maxy __LONG_LONG_MAX__
#define miny INT_MIN
#define PI 3.14159265358979323846
#define MOD 998244353




void Solve()
{	
	ll a,b,c,d;
	cin>>a>>b>>c>>d;
	
	bool f=true;
	while(a>0 && c>0)
	{
		if(f)
		{
			c -=b;
			f=false;
			if(c<=0)break;
		}
		else
		{
			a-=d;
			f=true;
			if(a<=0)break;
		}
	}
	if(a<=0) cout<<"No";
	else cout<<"Yes";	
}

signed main() 
{
	speed		
	
	int q=1;
	//cin>>q;
	
	while(q--)
	Solve();
	
	//cout << "\n\n"<<"Time elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " seconds.\n";
	return 0;
}

 
 

Measured memory_bytes: 3640
import java.util.*;
import java.util.ArrayDeque;
import java.util.Deque;
public class Main {
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        while(true){
            String line = sc.nextLine();
            if(line.equals(".")) break;
            Boolean ans = true;
            Deque<Character> deque = new ArrayDeque<Character>();
            for(int i = 0; i<line.length(); i++){
                char c = line.charAt(i);
                if(c == '(' || c == '[') deque.push(c);
                else if(c==')'){
                    if(deque.isEmpty()){
                        ans = false;
                        break;
                    }
                    char bef = deque.pop();
                    if(bef != '('){
                        ans = false;
                        break;
                    }
                }else if(c==']'){
                    if(deque.isEmpty()){
                        ans = false;
                        break;
                    }
                    char bef = deque.pop();
                    if(bef != '['){
                        ans = false;
                        break;
                    }
                }else if(c=='.'){
                    if(!(deque.isEmpty())){
                        ans = false;
                        break;
                    }
                }else{
                    continue;
                }
            }
            if(ans) System.out.println("yes");
            else System.out.println("no");
        }
        sc.close();
    }
}


Measured memory_bytes: 45936
#include <stdio.h>
#define NIL -1

typedef struct {
  int par, left, right, dep;
}tree;

int depth(int,int);

tree t[100000];

int main()
{
  int i, j, n, id, noc, chi, left, root;

  scanf("%d",&n);
  for (i = 0; i < n; i++)
    t[i].par = t[i].left = t[i].right = NIL;
  for (i = 0; i < n; i++){
    scanf("%d%d",&id,&noc);
    for (j = 0; j < noc; j++){
      scanf("%d",&chi);
      if (j == 0)
	t[id].left = chi;
      else
	t[left].right = chi;
      left = chi;
      t[chi].par = id;
    }
  }
  for (i = 0; i < n; i++)
    if (t[i].par == NIL)
      root = i;
  depth(root,0);
  for (i = 0; i < n; i++){
    printf("node %d: parent = %d, depth = %d, ",i,t[i].par,t[i].dep);
    if (i == root)
      printf("root, ");
    else if (t[i].left == NIL)
      printf("leaf, ");
    else
      printf("internal node, ");
    printf("[");
    chi = t[i].left;
    while (chi != NIL){
      if (chi != t[i].left)
	printf(", ");
      printf("%d",chi);
      chi = t[chi].right;
    }
    printf("]\n");
  }
  return 0;
}

int depth(int id, int d)
{
  t[id].dep = d;
  if (t[id].right != NIL)
    depth(t[id].right,d);
  if (t[id].left != NIL)
    depth(t[id].left,d+1);
}



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

#define rep(i,x) for(int i=0;i<x;i++)
#define rep1(i,x) for(int i=1;i<=x;i++)
#define pb push_back
#define lb(vec,a) lower_bound(vec.begin(),vec.end(),a);
#define ub(vec,a) upper_bound(vec.begin(),vec.end(),a);
#define sor(vec) sort(vec.begin(),vec.end())

int main(){
	int n,q;
	vector<int> vec;
	
	cin>>n>>q;
	rep(i,n){
		int in;
		scanf("%d",&in);
		vec.pb(in);
	}
	sor(vec);
	
	rep(i,q){
		int p;
		scanf("%d",&p);
		
		if(p<=1000){
			int ans=0;
			rep(j,n){
				ans=max(ans,vec[j]%p);
			}
			printf("%d\n",ans);
		}
		else {
			int ans=0;
			vector<int>::iterator itr;
			int t=0;
			while(t<=300000){
				t+=p;
				itr=lb(vec,t);
				if(itr!=vec.begin()){
					itr--;
					ans=max(ans,*itr%p);
				}
			}
			printf("%d\n",ans);
		}
	}
}

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

using namespace std;

typedef long long ll;
typedef pair<int, int> pp;
double PI=acos(-1);
int const N = 5e5 + 10,M=5e6+10, oo = 1e9;
const int mod = oo+7;
const ll  OO = 3e18;

int n;
int main(){
    ios::sync_with_stdio(0);
    cin.tie(0);
    cin>>n;
    if(n%2)cout<<n*2<<endl;
    else cout<<n<<endl;
    return 0;
}


Measured memory_bytes: 256
import sys
IS = lambda: sys.stdin.readline().rstrip()
II = lambda: int(IS())
MII = lambda: list(map(int, IS().split()))

def main():
    a,b,c,d = MII()
    if abs(a-c)<=d: print('Yes')
    elif abs(a-b)<=d and abs(b-c)<=d: print('Yes')
    else: print('No')

if __name__ == '__main__':
    main()


Measured memory_bytes: 3060
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <cmath>
using namespace std;

int N, K, Q;
int A[100000];

void Input()
{
	cin >> N >> K >> Q;
	for (int i = 0; i < Q; i++) {
		int m;
		cin >> m;
		A[m - 1]++;
	}
}

int main()
{
	Input();

	int cnt = 0;
	for (int i = 0; i < N; i++) {
		cnt += A[i];
	}
	for (int i = 0; i < N; i++) {
		if (K - (cnt - A[i]) > 0) cout << "Yes" << endl;
		else cout << "No" << endl;
	}
	cout << endl;

	return 0;
}

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

int main() {
  int N,K,i;
  cin>>N>>K;
  vector<int> A(N);
  for (i=0;i<N;i++) cin>>A[i];
  for (i=K;i<N;i++) {
    cout<<((A[i]-1)/A[i-K]>0?"Yes":"No")<<endl;
  }
  return 0;
}

Measured memory_bytes: 3680
#include <iostream>
#include <map>

int main()
{
  int N;
  std::cin >> N;
  std::map<uint64_t, uint64_t> vals;
  uint64_t sum = 0;
  for(int i=0; i<N; i++) {
    uint64_t a;
    std::cin >> a;
    vals[a]++;
    sum += a;
  }
  int Q;
  std::cin >> Q;

  for(int i=0; i<Q; i++) {
    uint64_t b, c;
    std::cin >> b >> c;
    auto it = vals.find(b);

    if(it != vals.end()) {
      uint64_t cnt = it->second;
      vals.erase(it);
      vals[c] += cnt;
      sum -= b * cnt;
      sum += c * cnt;
    }

    std::cout << sum << std::endl;
  }

  return 0;
}


Measured memory_bytes: 7548