akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <string> 
#include <vector> 
#include <algorithm> 
#include <utility> 
#include <tuple> 
#include <cstdint> 
#include <cstdio> 
#include <map> 
#include <queue> 
#include <set> 
#include <stack> 
#include <deque> 
#include <unordered_map> 
#include <unordered_set> 
#include <bitset> 
#include <cctype> 
#include<math.h>
using namespace std;

#define int long long
#define endl "\n"
#define fir first
#define sec second
#define fro front
#define m_p make_pair
#define mod 1000000007
#define all(v)  v.begin(),v.end()
#define rep(i,n)  for(int i=0; i<(int) (n); i++)
#define all(v)  v.begin(),v.end()
#define vecin(v) for(int i=0; i<(int)v.size(); i++)cin>>v[i];
using namespace std;

const int MAX = 510000;
const int MOD = 1000000007;
long long fac[MAX], finv[MAX], inv[MAX];
int jousu(int x00, int y00) {
	int z00 = 1;
	for (int i = 0; i < y00; i++) {
		z00 *= x00;
	}
	return z00;
}
int keta(int x00) {
	int z00 = x00;
	int w00 = 0;
	while (z00 != 0) {
		z00 /= 10;
		w00++;
	}
	return w00;
}

int modinv(int a, int m) {
	int b = m, u = 1, v = 0;
	while (b) {
		int t = a / b;
		a -= t * b; swap(a, b);
		u -= t * v; swap(u, v);
	}
	u %= m;
	if (u < 0) u += m;
	return u;
}
int modpow(int a, int n) {
	int res = 1;
	while (n > 0) {
		if (n & 1) res* a % mod;
		a = a * a % mod;
		n >>= 1;
	}
	return res;
}
int gcd(int xx, int yy) {
	int p = xx;
	int q = yy;
	if (q > p)swap(p, q);
	while (p % q != 0) {
		p %= q;
		swap(p, q);
	}
	return q;
}
int lcm(int xx, int yy) {
	return xx * yy / gcd(xx, yy);
}
bool prime(int xx) {
	int a = xx;
	for (int i = 2; i * i <= xx; i++) {
		if (xx % i == 0) {
			return 0;
		}
	}
	return 1;
}
int com(int xx, int yy) {
	int zz = 1;
	for (int i = xx; i > xx - yy; i--) {
		zz *= i;
		zz %= mod;
	}
	for (int i = 1; i <= yy; i++) {
		zz *= modinv(i, mod);
		zz %= mod;
	}
	return zz;
}



signed main() {
	int x, a;
	cin >> x >> a;
	if (x < a) {
		cout << 0 << endl;
	}
	else {
		cout << 10 << endl;
	}
}



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

int n, l, m, ans;

int main() {
    scanf("%d %d", &n, &l);
    m = 100;

    for ( int i = 1; i <= n; i++ ) {
        if ( abs(l+i-1) < abs(m) ) {
            m = l + i - 1;
        }

        ans += l + i - 1;
    }

    ans -= m;
    printf("%d\n", ans);
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <queue>
using namespace std;
using Graph = vector<vector<int> >;
 
int main(){
  int N; cin >> N;
  int a[] = {1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
  
  cout << a[N-1] <<endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <math.h> 
#include <string> 
#include <algorithm>
#include <numeric>
#include <cmath>
using namespace std;

int main() {

	long res = 0;

	long A, B; cin >> A >> B;

	res = (B % A == 0) ? A + B: B - A;

	cout << res << endl;
}

Measured memory_bytes: 256
import java.util.Arrays;
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        char[] S = sc.next().toCharArray();
        String SS = String.valueOf(S);
        String res = "-1";
        if(S.length < 26) {
            for(int c = 'a'; c < 'z'; c++) {
                boolean flag = true;
                for(char ch : S) if(c == ch) {
                    flag = false;
                    break;
                }
                if(flag) {
                    res = String.valueOf(S) + (char)c;
                    break;
                }
            }
        } else if(nextPermutation(S)) {
            for(int i = 0; i < S.length; i++) {
                char[] ST = SS.substring(i, S.length).toCharArray();
                if(!nextPermutation(ST)) {
                    res = String.valueOf(S).substring(0, i);
                    break;
                }
            }
        }
        System.out.println(res);
    }
    public static boolean nextPermutation(char[] array) {
        int num = array.length;
        for(int i = num - 2; i >= 0; i--) {
            if(array[i] < array[i + 1]) {
                int j = num;
                do {
                    j--;
                } while(array[i] > array[j]);
                swap(array, i , j);
                Arrays.sort(array, i + 1, num);

                return true;
            }
        }
        return false;
    }
    public static void swap(char[] array, int a, int b) {
        char tmp = array[a];
        array[a] = array[b];
        array[b] = tmp;
    }
    public static void reverse(char[] array) {
        int num = array.length;
        for(int i = 0; i < num / 2; i++) {
            swap(array, i, num - i - 1);
        }
    }
}


Measured memory_bytes: 22356
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.StringTokenizer;
import java.io.IOException;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        TaskB solver = new TaskB();
        solver.solve(1, in, out);
        out.close();
    }

    static class TaskB {
        public void solve(int testNumber, InputReader in, PrintWriter out) {
            String s = in.next();
            s = s.replace("BC", "D");
            long res = 0;
            for (int i = 0; i < s.length(); ) {
                if (s.charAt(i) == 'A') {
                    int j = i;
                    while (j < s.length() && (s.charAt(j) == 'A' || s.charAt(j) == 'D')) ++j;
                    res += countInversions(s, i, j);
                    i = j;
                } else {
                    ++i;
                }
            }
            out.println(res);
        }

        private long countInversions(String s, int start, int end) {
            long res = 0;
            long na = 0;
            for (int i = start; i < end; ++i) {
                if (s.charAt(i) == 'A') ++na;
                else res += na;
            }
            return res;
        }

    }

    static class InputReader {
        public BufferedReader reader;
        public StringTokenizer tokenizer;

        public InputReader(InputStream stream) {
            reader = new BufferedReader(new InputStreamReader(stream), 32768);
            tokenizer = null;
        }

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

    }
}



Measured memory_bytes: 30020
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
#define dump(x) cout << x << endl
typedef int64_t Int;

using namespace std;
using Graph = vector<vector<Int>>;

const double pi = M_PI;
const Int MOD = 1000000007;

int main() {
    int n;
    cin >> n;
    vector<string> s1, ans;
    map<string, int> s2;
    for (int i = 0; i < n; i++) {
        string a;
        cin >> a;
        s1.push_back(a);
        s2.insert({a, 0});
    }
    for (auto e : s1) {
        s2[e]++;
    }
    int m = 0;
    for (auto itr = s2.begin(); itr != s2.end(); itr++) {
        m = max(m, itr->second);
    }
    for (auto itr = s2.begin(); itr != s2.end(); itr++) {
        if (itr->second == m) {
            ans.push_back(itr->first);
        }
    }
    sort(ans.begin(), ans.end());
    for (auto e : ans) {
        cout << e << endl;
    }

    return 0;
}


Measured memory_bytes: 28528
#include <iostream>
#include <string>
#include <vector>
#include <deque>
#include <queue>
#include <algorithm>
#include <set>
#include <map>
#include <bitset>
#include <cmath>
#include <functional>
#define vv(a, b, c, d) vector<vector<d> >(a, vector<d>(b, c))
#define vvi vector<vector<int> >
#define vvl vector<vector<ll> >
#define vll vector<ll>
#define rep(c, a, b) for(ll c=a;c<b;c++)
#define re(c, b) for(ll c=0;c<b;c++)
#define all(obj) (obj).begin(), (obj).end()
typedef long long int ll;
typedef long double ld;
using namespace std;

int main(int argc, char const *argv[]) {
  ll a, b, c;std::cin >> a >> b >> c;
  multiset<ll>t;
  t.insert(a), t.insert(b), t.insert(c);
  std::cout << (t.count(5)==2&&t.count(7)==1?"YES":"NO") << '\n';
  return 0;
}


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

ans = 0
for i in range(N):
    if A[i] == B[i] and B[i] == C[i]:
        ans += 0
    elif A[i] == B[i] or B[i] == C[i] or C[i] == A[i]:
        ans += 1
    else:
        ans += 2
print(ans)

Measured memory_bytes: 3064
//Daniel Grzegorzewski
#include <bits/stdc++.h>

#define MP make_pair
#define PB push_back
#define ST first
#define ND second

using namespace std;

typedef pair<int, int> PII;
typedef vector<int> VI;
typedef vector<PII> VII;
typedef long long LL;

void init_ios() {
     ios_base::sync_with_stdio(0);
     cin.tie(0);
}

int n;

int sum(int x) {
  int res = 0;
  while(x) {
    res += x%10;
    x /= 10;
  }
  return res;
}

int main() {
  init_ios();
  cin >> n;
  int res = 1e9;
  for (int i = 1; i < n; ++i) {
    int tmp = sum(i)+sum(n-i);
    if (tmp < res)
      res = tmp;
  }
  cout<<res<<"\n";
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<string>
#include<vector>
#include<queue>
#include<map>
#include<cmath>
using namespace std;
#define REP(i, limit) for(int i=0; i< limit; ++i)
#define FOR(i, j, limit) for(int i=j; i< limit; ++i)
#define DUMP(a) REP(d,a.size()){cout<<a[d];if(d!=a.size()-1)cout<<" ";else cout<<endl;}
#define ECHO(x) cout<<x<<endl;
#define LL long long
int INF = 2147483647;
LL LINF = 9223372036854775807;
LL MOD = 1000000007;
typedef pair<int, int>P;
typedef pair<LL, LL>PL;
typedef vector<int> vi;
typedef vector<LL> vl;

struct st{
  LL a;
  LL b;
  LL c;

  bool operator<(const st &r) const{
    return c<r.c;
  }
};


int main(){
  int n;
  cin>>n;
  st s[n];
  REP(i, n){
    cin>>s[i].a>>s[i].b;
    s[i].c = s[i].a + s[i].b;
  }

  if(n==1){
    cout<<s[0].a<<endl;
    return 0;
  }
  sort(s, s+n);
  LL ans=0;
  int j=0;
  for(int i=n-1; i>-1; --i) {
    if(j%2) ans-=s[i].b;
    else ans += s[i].a;
    ++j;
  }

  cout<<ans<<endl;

  return 0;
}


Measured memory_bytes: 2560
#include "bits/stdc++.h"
using namespace std;
#define ll long long int
#define rep(i,n) for( int i = 0; i < n; i++ )
#define rrep(i,n) for( int i = n; i >= 0; i-- )
#define REP(i,s,t) for( int i = s; i <= t; i++ )
#define RREP(i,s,t) for( int i = s; i >= t; i-- )
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define INF 2000000000
#define mod 1000000007
#define INF2 1000000000000000000


int main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    string S; cin >> S;
    bool c[26] = {};
    rep(i, S.length()) {
        c[S[i] - 'a'] = true;
    }
    rep(i, 26) {
        if (!c[i]) {
            cout << (char)(i + 'a') << endl;
            return 0;
        }
    }
    cout << "None" << endl;

    return 0;
}


Measured memory_bytes: 512
import sys
from collections import Counter
def input():
    return sys.stdin.readline()[:-1]


def main():

    MOD = 10**9 + 7
    N, K = map(int, input().split())
    A = list(map(int, input().split()))

    fall_count_in = 0
    fall_count_out = 0
    for i,ai in enumerate(A):
        for j,aj in enumerate(A):
            if i == j:
                continue
            if ai > aj:
                fall_count_out += 1
                if i < j:
                    fall_count_in += 1

    ans = fall_count_out * K * (K-1) // 2 + fall_count_in * K
    print(ans % MOD)

if __name__ == "__main__":
    main()


Measured memory_bytes: 3444
import std.stdio, std.string, std.conv, std.range;
import std.algorithm, std.array, std.typecons, std.container;
import std.math, std.numeric, std.random, core.bitop;

enum inf = 1_001_001_001;
enum infl = 1_001_001_001_001_001_001L;


void main() {
    string s;
    scan(s);
    yes(s.canFind('7'));
}



void scan(T...)(ref T args) {
    auto line = readln.split;
    foreach (ref arg; args) {
        arg = line.front.to!(typeof(arg));
        line.popFront;
    }
    assert(line.empty);
}

void fillAll(R, T)(ref R arr, T value) {
    static if (is(typeof(arr[] = value))) {
        arr[] = value;
    }
    else {
        foreach (ref e; arr) {
            fillAll(e, value);
        }
    }
}

bool chmin(T, U...)(ref T x, U args) {
    bool isChanged;
    foreach (arg; args) if (x > arg) {
        x = arg;
        isChanged = true;
    }
    return isChanged;
}

bool chmax(T, U...)(ref T x, U args) {
    bool isChanged;
    foreach (arg; args) if (x < arg) {
        x = arg;
        isChanged = true;
    }
    return isChanged;
}

void yes(bool ok, string y = "Yes", string n = "No") {
    return writeln(ok ? y : n);
}


Measured memory_bytes: 2684
import java.util.*;
import java.io.*;
public class Main
{
    static ArrayList<Integer> edge[];
    public static void dfs(int src,boolean vis[],TreeSet<Integer> ts)
    {
        vis[src]=true;
        ts.add(src);
        for(int i=0;i<edge[src].size();i++)
        {
            int temp=edge[src].get(i);
            if(!vis[temp])
            dfs(temp,vis,ts);
        }
    }
    public static void main(String args[])throws Exception
    {
        BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
        PrintWriter pw=new PrintWriter(System.out);
        String str[]=br.readLine().split(" ");
        int n=Integer.parseInt(str[0]);
        int m=Integer.parseInt(str[1]);
        edge=new ArrayList[n+1];
        for(int i=1;i<=n;i++)
        edge[i]=new ArrayList<>();
        for(int i=0;i<m;i++)
        {
            str=br.readLine().split(" ");
            int u=Integer.parseInt(str[0]);
            int v=Integer.parseInt(str[1]);
            edge[u].add(v);
            edge[v].add(u);
        }
        TreeSet<Integer> ts=new TreeSet<>();
        dfs(1,new boolean[n+1],ts);
        if(ts.size()!=n)
        pw.println("No");
        else
        {
            pw.println("Yes");
            int depth[]=new int[n+1];
            Queue<Integer> queue=new LinkedList<>();
            queue.add(1);
            boolean vis[]=new boolean[n+1];
            vis[1]=true;
            while(!queue.isEmpty())
            {
                int node=queue.poll();
                for(int i=0;i<edge[node].size();i++)
                {
                    
                    if(!vis[edge[node].get(i)])
                    {
                        vis[edge[node].get(i)]=true;
                        queue.add(edge[node].get(i));
                        depth[edge[node].get(i)]=node;
                    }
                }
            }
            for(int i=2;i<=n;i++)
            pw.println(depth[i]);
        }
        pw.flush();
        pw.close();
    }
}

Measured memory_bytes: 83448
N = int(input())

from collections import defaultdict

counter = defaultdict(int)

for x in map(str, range(1, N+1)):
    head = x[0]
    tail = x[-1]
    counter[(head, tail)] += 1

ans = 0
items = list(counter.items())
for (head, tail), cnt in items:
    ans += cnt * counter[(tail, head)]

print(ans)

Measured memory_bytes: 3316
H,W = map(int,input().split())
A = []
for i in range(H):
  temp = list(map(int,input().split()))
  A.append(temp)
#print(A)
ans = 0
L = []
for i in range(H):
  for j in range(W):
    if A[i][j]%2 == 1:#奇数なら動かす
      if j <= W-2 and A[i][j+1]%2 == 1: #右が奇数
        ans +=1
        A[i][j] -=1
        A[i][j+1] +=1
        L.append([i,j,i,j+1])
      elif i <= H-2 and A[i+1][j]%2 == 1: #下が奇数
        ans +=1
        A[i][j]-=1
        A[i+1][j] += 1
        L.append([i,j,i+1,j])
      else: #どちらも偶数
        if j <=W-2: #横に動かす
          ans +=1
          A[i][j] -=1
          A[i][j+1] +=1
          L.append([i,j,i,j+1])
        elif i <= H-2: #下に動かす
          ans +=1
          A[i][j]-=1
          A[i+1][j] += 1
          L.append([i,j,i+1,j])
print(ans)
for t in L:
  temp = []
  for x in t:
    temp.append(x+1)
  print(*temp)

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

int main()
{
    ll n,i,j;
    cin>>n;
    ll a[n][3];
    for(i=0;i<n;i++)
    {
        for(j=0;j<3;j++)
        cin>>a[i][j];
    }
    ll t[n+1][3];
    //memset(t,0,sizeof(t));
    t[0][0]=a[0][0];
    t[0][1]=a[0][1];
    t[0][2]=a[0][2];
    for(i=1;i<n;i++)
    {
        t[i][0]=a[i][0]+max(t[i-1][1],t[i-1][2]);
        t[i][1]=a[i][1]+max(t[i-1][0],t[i-1][2]);
        t[i][2]=a[i][2]+max(t[i-1][0],t[i-1][1]);
   // cout<<max(t[n-1][0],max(t[n-1][1],t[n-1][2]))<<endl;
    }
    cout<<max(t[n-1][0],max(t[n-1][1],t[n-1][2]))<<endl;
}

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

#define CPP_STR(x) CPP_STR_I(x)
#define CPP_CAT(x,y) CPP_CAT_I(x,y)
#define CPP_STR_I(args...) #args
#define CPP_CAT_I(x,y) x ## y

using i8  = int8_t;
using u8  = uint8_t;
using i16 = int16_t;
using u16 = uint16_t;
using i32 = int32_t;
using u32 = uint32_t;
using i64 = int64_t;
using u64 = uint64_t;

using f32 = float;
using f64 = double;

#define FOR(i, start, end) for(i64 i = (start), CPP_CAT(i,xxxx_end)=(end); i < CPP_CAT(i,xxxx_end); ++i)
#define REP(i, n) FOR(i, 0, n)
#define REPS(i, n) for(i64 i = 1; i <= n; ++i)
#define RREP(i, n) for(i64 i = n - 1; i >= 0 ; --i)
#define RREPS(i, n) for(i64 i = n; i >= 1; --i)

#define ALL(f,c,...) (([&](decltype((c)) cccc) { return (f)(std::begin(cccc), std::end(cccc), ## __VA_ARGS__); })(c))

#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );

#define pb push_back
#define mp make_pair

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

template<typename C>
i64 SIZE(const C& c) { return static_cast<i64>(c.size()); }

template<typename T, size_t N>
i64 SIZE(const T (&)[N]) { return static_cast<i64>(N); }


struct ProconInit {
    static constexpr int IOS_PREC = 15;
    static constexpr bool AUTOFLUSH = false;

    ProconInit() {
        cin.tie(nullptr);
        ios::sync_with_stdio(false);
        cout << fixed << setprecision(IOS_PREC);
        if(AUTOFLUSH)
            cout << unitbuf;
    }
} PROCON_INIT;


int main() {
    i64 N; cin >> N;
    vector<i64> C(N + 1, 0);
    REP(i, N) {
        i64 a; cin >> a;
        C[i + 1] = C[i] + a;
    }

    i64 mind = 1152921504606846976;
    REPS(i, N - 1) {
        i64 x = C[i];
        i64 y = C[N] - x;
        chmin(mind, abs(x - y));
    }
    cout << mind << endl;

    return 0;
}


Measured memory_bytes: 4776
#include "bits/stdc++.h"
using namespace std;
#define ll long long int
#define rep(i,n) for( int i = 0; i < n; i++ )
#define rrep(i,n) for( int i = n; i >= 0; i-- )
#define REP(i,s,t) for( int i = s; i <= t; i++ )
#define RREP(i,s,t) for( int i = s; i >= t; i-- )
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define INF 2000000000
#define mod 1000000007
#define INF2 1000000000000000000


int main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int H, W; cin >> H >> W;
    string S[110];
    rep(i, H) cin >> S[i];
    int cnt[26] = {};
    rep(i, H) rep(j, W) cnt[S[i][j] - 'a']++;
    sort(cnt, cnt + 26);
    int k = 0;
    int used1 = 0, used2 = 0, used4 = 0;
    rep(i, (H + 1) / 2) rep(j, (W + 1) / 2) {
        if (i < H / 2 && j < W / 2) used4++;
        else if (i == H / 2 && j < W / 2) used2++;
        else if (i < H / 2 && j == W / 2) used2++;
        else used1++;
    }
    int cnt1 = 0, cnt2 = 0, cnt4 = 0;
    rep(i, 26) {
        if (cnt[i] % 4 == 1) {cnt1++; cnt[i]--;}
        if (cnt[i] % 4 == 2) {cnt2++; cnt[i] -= 2;}
        cnt4 += cnt[i] / 4; 
    }
    int less = min(used1, cnt1);
    used1 -= less;
    cnt1 -= less;
    used2 += used1 / 2;
    used1 -= (used1 / 2) * 2;
    less = min(used2, cnt2);
    used2 -= less;
    cnt2 -= less;
    used4 += used2 / 2;
    used2 -= (used2 / 2) * 2;
    less = min(used4, cnt4);
    used4 -= less;
    cnt4 -= less;
    if(used1 > 0 || used2 > 0 || used4 > 0) {
        cout << "No" << endl;
    }else {
        cout << "Yes" << endl;
    }
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
 
const int N = 4010;
 
std::vector <int> vec;
 
int a, b, n;
int ans[N];
char s[N];
 
int main(){
	scanf("%d%d", &a, &b);
	n = a + b;
	if (a <= b){
		return printf("Impossible\n"), 0;
	}
	for (int i = 0; i < n; ++ i){
		if (!vec.size()){
			vec.push_back(i);
			continue;
		}
		printf("? %d %d\n", i, vec.back());
		fflush(stdout);
		int x;
		scanf("%s", s);
		if (s[0] == 'Y'){
			vec.push_back(i);
		}
		else{
			vec.pop_back();
		}
	}
	int honest = vec.front();
	for (int i = 0; i < n; ++ i){
		printf("? %d %d\n", honest, i);
		fflush(stdout);
		scanf("%s", s);
		ans[i] = s[0] == 'Y';
	}
	printf("!");
	for (int i = 0; i < n; ++ i){
		printf("%d", ans[i]);
	}
	return printf("\n"), 0;
}

Measured memory_bytes: 848
import sys

sys.setrecursionlimit(10 ** 8)
ini = lambda: int(sys.stdin.readline())
inm = lambda: map(int, sys.stdin.readline().split())
inl = lambda: list(inm())
ins = lambda: sys.stdin.readline().rstrip()
debug = lambda *a, **kw: print("\033[33m", *a, "\033[0m", **dict(file=sys.stderr, **kw))

N, K = inm()
P = inl()


def solve():
    ex = 0.0
    for i in range(K):
        ex += (P[i] + 1) / 2
    mex = ex
    for i in range(K, N):
        j = i - K
        ex += (P[i] + 1) / 2
        ex -= (P[j] + 1) / 2
        if mex < ex:
            mex = ex
    return mex


print(solve())


Measured memory_bytes: 31616
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Text.RegularExpressions;

namespace AOJ
{
	class Program
	{
		static void Main(string[] args)
		{
			var t1 = new int[1001];
			var t2 = new int[1001];
			var s = "";
			while ((s = Console.ReadLine()) != "")
			{
				var d = int.Parse(s.Split(',')[0]);
				t1[d]++;
			}
			while ((s = Console.ReadLine()) != null)
			{
				var d = int.Parse(s.Split(',')[0]);
				t2[d]++;
			}
			for(int i=0;i<1001;i++)
			{
				if(t1[i]>0 && t2[i]>0)
				{
					Console.WriteLine("{0} {1}", i, t1[i] + t2[i]);
				}
			}
		}
	}
}

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

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int s = sc.nextInt();
        int w = sc.nextInt();
        if( s <= w) {
            System.out.println("unsafe");
        } else {
            System.out.println("safe");
        }
    }
}

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

#define M_PI       3.14159265358979323846   // pi

using namespace std;
typedef long long ll;
typedef vector<int> VI;
typedef pair<ll, ll> P;

#define rep(a,n) for(int a = 0;a < n;a++)
#define repi(a,b,n) for(int a = b;a < n;a++)

const ll mod = 1000000007;

int main(void)
{
	ll n;
	cin >> n;
	vector<ll> a(n + 1, 0);
	vector<ll> b(n, 0);
	rep(i, n + 1) cin >> a[i];
	rep(i, n ) cin >> b[i];
	ll sum = 0;
	rep(i, n) {
		auto ai = min(a[i], b[i]);
		a[i] -= ai;
		b[i] -= ai;
		sum += ai;
		auto ai1 = min(a[i+1], b[i]);
		a[i+1] -= ai1;
		b[i] -= ai1;
		sum += ai1;
	}
	cout << sum << endl;
	return 0;
}


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

int main() {
    int a,b,c,d;
    cin>>a>>b>>c>>d;
    if(a+b==c+d) cout<<"Balanced"<<endl;
    else if(a+b>c+d) cout<<"Left"<<endl;
    else cout<<"Right"<<endl;
}

Measured memory_bytes: 256
// In The Name Of The Queen
#include<bits/stdc++.h>
using namespace std;
const int N = 100005;
int n, L, T, Cnt, X[N], W[N], A[N];
int main()
{
    scanf("%d%d%d", &n, &L, &T);
    for (int i = 0; i < n; i ++)
    {
        scanf("%d%d", &X[i], &W[i]);
        if (W[i] == 1)
            A[i] = (X[i] + T) % L, Cnt = (Cnt + max((T - (L - X[i]) + L) / L, 0)) % n;
        else
            A[i] = (X[i] - T % L + L) % L, Cnt = (Cnt - max((T - X[i] - 1 + L) / L, 0) + n) % n;
    }
    sort(A, A + n);
    for (int i = 0; i < n; i ++)
        A[i + n] = A[i];
    for (int i = Cnt; i < n + Cnt; i ++)
        printf("%d\n", A[i]);
    return 0;
}

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

#define F first
#define S second

using namespace std;

typedef long long LL;
typedef pair<int, int> PII;

const int N = 15, M = 10, mod = 1e9 + 7;

int n, x, y;

bool check(int x, int y)
{
	if (!x || !y) return false;
	if ((x + y) % 3) return false;
	n = (x + y) / 3;
	if (min(x, y) < n) return false;
	else return true;
}

int qp(int a, int b)
{
	int res = 1;
	while (b)
	{
		if (b & 1) res = (LL)res * a % mod;
		a = (LL)a * a % mod;
		b >>= 1;
	}
	return res;
}

int C(int a, int b)
{
	int res = 1;
	for (int i = a; i > a - b; i -- ) res = (LL)res * i % mod;
	for (int i = 1; i <= b; i ++ ) res = (LL)res * qp(i, mod - 2) % mod;
	return res;
}

int main()
{
	cin >> x >> y;
	if (!check(x, y))
	{
		puts("0");
		return 0;
	}
	
	x -= n, y -= n;
	cout << C(n, x) << endl;
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define fr(i,n) for(int i=0;i<(n);++i)
#define foor(i,a,b) for(int i=(a);i<=(b);++i)
#define rf(i,n) for(int i=(n);i--;)
#define roof(i,b,a) for(int i=(b);i>=(a);--i)
#define all(x) x.begin(),x.end()
#define Sort(x) sort(all(x))
#define Reverse(x) reverse(all(x))
#define PQ priority_queue
#define print(x) cout<<(x)<<endl
using namespace std;            typedef vector<int>  vi;
typedef long long ll;           typedef vector< ll>  vl;
typedef unsigned long long ull; typedef vector<ull>  vu;
typedef double dbl;             typedef vector<dbl>  vd;
typedef string str;             typedef vector<str>  vs;
typedef pair<int,int>pii;       typedef vector<pii>vpii; typedef map<int,int>mii;
typedef pair< ll, ll>pll;       typedef vector<pll>vpll; typedef map< ll, ll>mll;
typedef pair<dbl,dbl>pdd;       typedef vector<pdd>vpdd; typedef map<dbl,dbl>mdd;
typedef pair<str,str>pss;       typedef vector<pss>vpss; typedef map<str,str>mss;
typedef pair< ll,int>pli;       typedef vector<pli>vpli; typedef map< ll,int>mli;
typedef pair<dbl,int>pdi;       typedef vector<pdi>vpdi; typedef map<dbl,int>mdi;
template<typename T>vector<T>&operator<<(vector<T>&v,const T t){v.push_back(t);return v;}
template<typename T>multiset<T>&operator<<(multiset<T>&m,const T t){m.insert(t);return m;}
template<typename T>set<T>&operator<<(set<T>&s,const T t){s.insert(t);return s;}
template<typename T,typename U>PQ<T,vector<T>,U>&operator<<(PQ<T,vector<T>,U>&q,const T t){q.push(t);return q;}
template<typename T,typename U>istream&operator>>(istream&s,pair<T,U>&p){return s>>p.first>>p.second;}
template<typename T>istream&operator>>(istream&s,vector<T>&v){fr(i,v.size()){s>>v[i];}return s;}
template<typename T,typename U>ostream&operator<<(ostream&s,const pair<T,U>p){return s<<p.first<<" "<<p.second;}
template<typename T>ostream&operator<<(ostream&s,const vector<T>v){for(auto a:v){s<<a<<endl;}return s;}
const int MD=1e9+7;
vpli dijkstra(const int N,const vpli E[],const int s,const ll inf){vpli d;fr(i,N)d<<pli{inf,i};d[s].first=0;PQ<pli,vpli,greater<pli>>pq;pq<<(d[s]=pli{0,s});while(pq.size()){pli a=pq.top();pq.pop();int v=a.second;if(d[v].first>=a.first){for(pli e:E[v]){if(d[v].first+e.first<d[e.second].first){d[e.second]=pli{d[v].first+e.first,v};pq<<pli{d[v].first+e.first,e.second};}}}}return d;}
ll gcd(const ll a,const ll b){return a?gcd(b%a,a):b;}
ll pow(const ll a,const ll n,const int m){ll t;return n?(n&1?a>=0?a%m:~-m+~a%m:1)*(t=pow(a,n>>1,m),t*t%m)%m:1;}
ll C2(const int n){return(ll)n*~-n/2;}
ll sum(const vl a){ll s=0;for(ll e:a){s+=e;}return s;}
template<typename T>T max(const vector<T>a){T m=a[0];for(T e:a){m=max(m,e);}return m;}
template<typename T>T min(const vector<T>a){T m=a[0];for(T e:a){m=min(m,e);}return m;}
// (int) * (int) => (int)
// (int) / (int) => (int)

main(){cin.tie(0);ios::sync_with_stdio(false);
	ll N;
	cin>>N;
	str S;
	cin>>S;
	map<pss,ll>m1,m2;
	fr(i,1<<N){
		pss s,t;
		fr(j,N){
			(i>>j&1?s.first:s.second)+=S[j];
			(i>>j&1?t.first:t.second)+=S[2*N-1-j];
		}
		++m1[s];
		++m2[t];
	}
	ll z=0;
	for(auto s:m1){
		z+=s.second*m2[s.first];
	}
	print(z);
}


Measured memory_bytes: 108288
/* Traveling Salesman Problem - ?????????????????????????????? ?????¢???*/

#include<iostream>
#include<algorithm>
#include<vector>

using namespace std;

typedef pair<int,int> pii;
typedef long long ll;
typedef ll int__;
#define rep(i,j) for(int__ (i)=0;(i)<(j);(i)++)
#define repeat(i,j,k) for(int__ i=(j);i<(k);(i)++)
#define all(v) v.begin(),v.end()

#define V_MAX 15
const int INF=1<<30;

int DP[1<<V_MAX][V_MAX]; //[S][now] : now ?????? U\S ????¨???????0????????????????????????
int G[V_MAX][V_MAX];
int V,E;
int rec(int S,int now){
  if( DP[S][now] >= 0 ) return DP[S][now];
  if( S == (1<<V)-1 && now==0 ) return DP[S][now]=0;
  int ret=INF;
  rep(v,V){
    if(( S & (1<<v)) || G[now][v] == INF)continue;
    ret = min( ret , rec(S | 1<<v,v)+G[now][v] );
  }
  return DP[S][now]=ret;
}

int main()
{
  cin>>V>>E;
  rep(i,V)rep(j,V)G[i][j]=INF;
  rep(i,1<<V)rep(j,V)DP[i][j]=-1;
  rep(i,E){
    int s,t,d;
    cin>>s>>t>>d;
    G[s][t]=d;
  }
  int ans=rec(0,0);
  cout<< (ans>=INF ? -1 : ans) <<endl;
  
  return 0;
}

Measured memory_bytes: 3080
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < n; i++)
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
 
const double EPS = 1e-10;
const ll INF = 100000000;
const ll MOD = 1000000007;

int n;
int b[101];
int ans[101];

int main() {
    cin >> n;
    rep(i,n) cin >> b[i];
    for (int i = n-1; i >= 0; i--) {
        bool ok = false;
        for (int j = i; j >= 0; j--) {
            if (b[j] == j+1) {
                ans[i] = b[j];
                ok = true;
                for (int k = j; k <= i; k++) {
                    b[k] = b[k+1];
                }
                break;
            }
        }
        if (!ok) {
            cout << -1 << endl;
            return 0;
        }
    }
    rep(i,n) cout << ans[i] << endl;
}



Measured memory_bytes: 256
=begin
－－－－－－－－－－－－－－
  N = 入力値
  cnt = 桁数
  ans = 答え
－－－－－－－－－－－－－－
  digitsメソッドを作成(num)
    1: cnt += 1
    2: num /10
    3. num < 0 になったら cnt を返す
  メソッド－－－－－－－－－－

  1: 1 ~ N まで繰り返す(i)
  2: digits(i) % 2 が 0 以外なら ans += 1
  3: ans を出力
=end

def digits(num)
  cnt = 0;
  while num > 0
    cnt += 1;
    num /= 10;
  end
  return cnt;
end

n = gets.to_i;
ans = 0;
for i in 1..n do
  ans += 1 unless digits(i) % 2 == 0
end

puts ans

Measured memory_bytes: 1788
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

macro_rules! input_inner {
    ($iter:expr) => {};
    ($iter:expr, ) => {};

    ($iter:expr, $var:ident : $t:tt $($r:tt)*) => {
        let mut $var = read_value!($iter, $t);
        input_inner!{$iter $($r)*}
    };
}

macro_rules! read_value {
    ($iter:expr, ( $($t:tt),* )) => {
        ( $(read_value!($iter, $t)),* )
    };

    ($iter:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()
    };

    ($iter:expr, chars) => {
        read_value!($iter, String).chars().collect::<Vec<char>>()
    };

    ($iter:expr, usize1) => {
        read_value!($iter, usize) - 1
    };

    ($iter:expr, $t:ty) => {
        $iter.next().unwrap().parse::<$t>().expect("Parse error")
    };
}

use std::collections::HashSet;

fn main() {
    input! {
        n: usize,
        m: usize,
        edges: [(usize, usize); m],
    }

    edges.sort_by(|a, b| a.1.cmp(&b.1));

    let mut previous = 0;
    let mut cnt = 0;
    for (i, j) in edges {
        if i <= previous && previous < j {
            continue;
        }
        previous = j - 1;
        cnt += 1;
    }
    println!("{}", cnt)
}


Measured memory_bytes: 8444
#include<bits/stdc++.h>
#include<cstring>
using namespace std;
#define endl '\n'
#define pb push_back
#define all(x) x.begin(), x.end()
#define rep(i, n) for (int i = 0; i < n; ++i)
#define reps(i, m, n) for (int i = m; i <= n; ++i)
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
const int INF = 0x3f3f3f3f;
const ll LINF = 0x3f3f3f3f3f3f3f3fLL;

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

  string s; cin >> s;

  string ans = "";

  for (int i = 0; i < s.length(); ++i) {
    if( s[i] == 'B' && ans.length() != 0 ) ans.pop_back();
    else if( s[i] == '0' || s[i] == '1' ) ans.pb(s[i]);
  }

  cout << ans << endl;

  return 0;
}

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

const int maxn=2e6+7;
int w[maxn],e[maxn];
int main (){
    int n;cin>>n;
    string str;cin>>str;
    memset(e,0,sizeof(e));memset(w,0,sizeof(w));
    if(str[0]=='W') w[0]=1;
    for(int i=1;i<n;i++){
        if(str[i]=='W') w[i]=w[i-1]+1;
        else w[i]=w[i-1];
    }

    if(str[n-1]=='E') e[n-1]=1;
    for(int i=n-2;i>=0;i--){
        if(str[i]=='E') e[i]=e[i+1]+1;
        else e[i]=e[i+1];
    }
    int ans=100000000;
    ans=min(e[1],ans);
    //cout<<ans<<endl;
    for(int i=1;i<n;i++) ans=min(e[i+1]+w[i-1],ans);//cout<<i<<" "<<ans<<endl;
    cout<<ans<<endl;
	return 0;
}



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

using namespace std;
using ll = long long;

const int MOD = 1e9 + 7;
#define REP(i, n)  for(int i = 0; i < n; ++i)
#define FOR(i, t, n)  for(ll i = t; i <= (ll)n; ++i)
struct edge {
    int from, to;
    ll cost;
};


class Eratosthenes {
public:
    vector<bool> prime;

    Eratosthenes(int size) {
        prime.resize(size + 1, 1);
        prime[0] = 0;
        prime[1] = 0;
        FOR(i, 2, size) {
            if (prime[i]) {
                for (int j = 2 * i; j <= size; j += i) {
                    prime[j] = 0;
                }
            }
        }
    }

};


class Combination {
    vector<ll> fac; //n!(mod M)
    vector<ll> ifac; //k!^{M-2} (mod M)
public:
    Combination(ll size) {
        fac.resize(size);
        ifac.resize(size);
        fac[0] = 1;
        ifac[0] = 1;
        for (ll i = 0; i < size; i++) {
            fac[i + 1] = fac[i] * (i + 1) % MOD;
            ifac[i + 1] = ifac[i] * mpow(i + 1, MOD - 2) % MOD;
        }
    }

    ll mpow(ll x, ll n) {
        ll ans = 1;
        while (n != 0) {
            if (n & 1) ans = ans * x % MOD;
            x = x * x % MOD;
            n = n >> 1;
        }
        return ans;
    }

    ll comb(ll a, ll b) {
        if (a == 0 && b == 0)return 1;
        if (a < b || a < 0)return 0;
        ll tmp = ifac[a - b] * ifac[b] % MOD;
        return tmp * fac[a] % MOD;
    }
};


ll GCD(ll a, ll b) {
    if (b == 0)return a;
    return GCD(b, a % b);
}

ll LCM(ll a, ll b) {
    ll gcd = GCD(a, b);
    return a / gcd * b;
}

int N;
int e[101010], o[101010];
bool b[2][101010];

int main() {
    cin >> N;
    vector<int> A(N);
    REP(i, N)cin >> A[i];
    REP(i, N) {
        if (i % 2 == 0)e[A[i]]++;
        else o[A[i]]++;
    }
    pair<int, int> x1 = {-1, 0}, x2 = {-1, 0}, y1 = {-1, 0}, y2 = {-1, 0};
    REP(i, N) {
        if (i % 2 == 0 && x1.second < e[A[i]]) x1 = {A[i], e[A[i]]};
        if (i % 2 == 1 && y1.second < o[A[i]])y1 = {A[i], o[A[i]]};
    }
    if (x1.first == y1.first) {
        REP(i, N) {
            if (i % 2 == 0 && A[i] != x1.first && x2.second < e[A[i]])x2 = {A[i], e[A[i]]};
            if (i % 2 == 1 && A[i] != y1.first && y2.second < o[A[i]])y2 = {A[i], o[A[i]]};
        }
        cout << min(N - x1.second - y2.second, N - x2.second - y1.second) << endl;
    } else cout << N - x1.second - y1.second << endl;
    return 0;
}


Measured memory_bytes: 1408
//#include <tourist>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <iostream>
#include <string>
#include <iomanip>
#include <limits>
#include <vector>
#include <map>
#include <set>
#include <stack>
#include <list>
#include <queue>
#include <tuple>
#include <deque>
#include <algorithm>
#include <numeric>
#include <iomanip>
#include <utility>
#include <complex>
#include <functional>
using namespace std;
const int MOD = 1000000007;
typedef long long ll;
typedef pair<ll, ll> p;
const int INF = (1 << 28);
const int dx[4] = {0, 1, 0, -1}, dy[4] = {-1, 0, 1, 0};
const int Dx[8] = {0, 1, 1, 1, 0, -1, -1, -1}, Dy[8] = {-1, -1, 0, 1, 1, 1, 0, -1};
#define yes cout << "Yes" << endl
#define YES cout << "YES" << endl
#define no cout << "No" << endl
#define NO cout << "NO" << endl
#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 INF 2e9
#define ALL(v) v.begin(), v.end()
//setprecision(15)有効数字15桁
//-std=c++14
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a, ll b)
{
    return a * b / gcd(a, b);
}
struct edge {
    int to, cost;
};
int n;
int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    cin >> n;
    int a[21][21];
    for (int i = 0; i < n; i++)
    {
        for(int j=0;j<n;j++){
            cin>>a[i][j];
        }
    }
    vector<vector<ll> > dp(n+1,vector<ll>(1<<n,0));
    dp[0][0]=1;
    for(int i=0;i<n;i++){
        for(int j=0;j<(1<<n);j++){
            if(i==__builtin_popcount(j)){//立ってるbitを数える
                for(int k=0;k<n;k++){
                    if(j&1<<k)continue;//すでに選ばれている
                    if(a[i][k]){
                        dp[i+1][j|(1<<k)]+=dp[i][j];
                        dp[i+1][j|(1<<k)]%=MOD;
                    }
                }
            }
        }
    }
    cout << dp[n][(1<<n)-1] << "\n";
}



Measured memory_bytes: 377216
#include<iostream>
using namespace std;
int main(){
	int a[4];
	a[1]=0;
	a[2]=0;
	a[3]=0;
	int x,y;
	cin>>x>>y;
	a[x]=1;
	a[y]=1;
	for(int i=1;i<4;i++)
		if(a[i]==0)
			cout<<i;
} 

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cstring>
#include<vector>
using namespace std;
int n,k,a[200005];
int main() {
	cin>>k>>n;
	for(int i=1;i<=n;i++)cin>>a[i];
	a[n+1]=a[1]+k;
	int maxx=0;
	for(int i=2;i<=n+1;i++)maxx=max(maxx,a[i]-a[i-1]);
	cout<<k-maxx;
}

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

using namespace std;

inline void quit(){ exit(0); }

typedef long long ll;

ll mpow(ll _x, ll _y, ll _mod){
    if(_y==0) return 1;
    if(_y==1) return _x%_mod;
    if(_y&1) return (mpow(_x, _y-1, _mod)*_x)%_mod;
    ll _tmp = mpow(_x, _y>>1, _mod);
    return (_tmp*_tmp)%_mod;
}

int n;
int arr[100002];
priority_queue<pair<int, int> > pq;

int main(){
    scanf("%d", &n);
    for(int i=1; i<=n; i++){
        int x;
        scanf("%d", &x);
        pq.push(make_pair(n-x, i));
    }
    while(!pq.empty()){
        printf("%d ", pq.top().second);
        pq.pop();
    }
}


Measured memory_bytes: 1780
#include <cmath>
#include <cassert>
#include <iostream>
#include <iomanip>
#include <map>
#include <set>
#include <vector>
#include <algorithm>
#include <queue>

using namespace std;

#define forsn(i,s,n) for (int i = (s);i < (int)(n);i++)
#define forn(i,n) forsn(i,0,n)
#define dforsn(i,s,n) for (int i = (n-1);i >= (int)(s);i--)
#define dforn(i,n) dforsn(i,0,n)
#define all(v) (v).begin(), (v).end()
#define F first
#define S second

int a[64];

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

	int n; cin >> n;
	
	int border = 0;
	forn(i,n) {
		cin >> a[i];
		if (abs(a[i]) > abs(a[border])) border = i;
	}
	
	cout << 2 * n - 1 << '\n';
	forn(i,n) cout << border + 1 << ' ' << i + 1 << '\n';
	if (a[border] > 0) {
		forn(i,n - 1) {
			cout << i + 1 << ' ' << i + 2 << '\n';
		}
	} else {
		dforn(i,n - 1) {
			cout << i + 2 << ' ' << i + 1 << '\n';
		}
	}
}


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

int main(){
    int a[105], n;
    scanf("%d", &n);
    for(int i = 0; i < n; i ++){
        scanf("%d", &a[i]);
    }
    int time = 0;
    for(int i = 0; i < n; i ++){
        int minj = i, minnum = a[i];
        for(int j = i + 1; j < n; j++){
            if(a[j] < minnum){
                minj = j;
                minnum = a[j];
            }
        }
        if(minj != i){
            time ++;
            swap(a[i], a[minj]);
        }
    }
    for(int i = 0; i < n - 1; i ++){
        printf("%d ", a[i]);
    }
    printf("%d\n", a[n - 1]);
    printf("%d\n", time);
    return 0;
}



Measured memory_bytes: 2696
import java.io.PrintWriter;
import java.util.Scanner;

public class Main {
    private static final int MAX = 500+24;

    public static void main(String[] args){
        Scanner in = new Scanner(System.in);
        PrintWriter out = new PrintWriter(System.out);
        while(in.hasNext()) {
            String str=in.nextLine();
            String answer=str.substring(0,3)+"8"+str.substring(4);
            out.println(answer);
            out.flush();
        }
        in.close();
        out.close();
    }

}


Measured memory_bytes: 21844
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int a,b,c,d;
	cin>>a>>b>>c>>d;
	if(a+b==c+d)
	cout<<"Balanced";
	else if(a+b>c+d)
	cout<<"Left";
	else
	cout<<"Right";
}



Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <cstdio>
#include <vector>
#include <stdio.h>
#include <algorithm>
#include <functional>


using namespace std;

int main(){
    int n;
    scanf("%d",&n);
    long long ans=0;
    for(int i=1;i<=n;i++){
    if(i%3!=0 && i%5!=0)ans+=i;
    }
    //printf("%lld\n",ans);
    cout<<ans;
}






Measured memory_bytes: 3736
#include <bits/stdc++.h>
using namespace std;
const int MOD = 1000000007;
int b;
string t;
long long bio[3005][3005];
long long modz (long long x, long long y)
{
	if(x + y >= MOD)
	{
		return x+y-MOD;
	}
	return x+y;
}
long long modm(long long x, long long y)
{
	return ((x%MOD)-(y%MOD)+MOD)%MOD;
}
int main()
{
    cin >> b >> t;
    for(int i = 0; i < b-1; i++)
    {
    	bio[0][i] = 1;
	}
    for(int i = 1; i < b; i++)
    {
    	if(t[i-1] == '<')
    	{
	    	for(int j = 1; j <= i; j++)
	    	{
	    		bio[i][j] = modz(bio[i][j-1], bio[i-1][j-1]);
			}
	    }
	    else
	    {
	    	for(int j = 0; j <= i; j++)
	    	{
	    		if(j == 0)
	    		{
	    			bio[i][j] = bio[i-1][i-1];
				}
				else
				{
					bio[i][j] = modm(modz(bio[i][j-1], bio[i-1][i-1]), bio[i-1][j-1]);
				}
			}
		}
	}
    cout << bio[b-1][b-1] << endl;
}



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

#define sz(a) int((a).size())
#define all(c) c.begin(), c.end()
#define ll long long
#define pb push_back
#define zoom                          \
    ios_base::sync_with_stdio(false); \
    cin.tie(NULL);                    \
    cout.tie(NULL);
#define pl pair<ll, ll>
#define MOD 1000000007
#define endl "\n"
#define ff first
#define ss second
#define trace1(x) cerr << #x << ": " << x << endl
#define trace2(x, y) cerr << #x << ": " << x << " | " << #y << ": " << y << endl
#define trace3(x, y, z) cerr << #x << ":" << x << " | " << #y << ": " << y << " | " << #z << ": " << z << endl
#define trace4(a, b, c, d) cerr << #a << ": " << a << " | " << #b << ": " << b << " | " << #c << ": " << c << " | " << #d << ": " << d << endl
#define trace5(a, b, c, d, e) cerr << #a << ": " << a << " | " << #b << ": " << b << " | " << #c << ": " << c << " | " << #d << ": " << d << " | " << #e << ": " << e << endl
#define trace6(a, b, c, d, e, f) cerr << #a << ": " << a << " | " << #b << ": " << b << " | " << #c << ": " << c << " | " << #d << ": " << d << " | " << #e << ": " << e << " | " << #f << ": " << f << endl
#define trace(v)                                   \
    for (auto it = v.begin(); it != v.end(); it++) \
        cerr << *it << " ";                        \
    cerr << endl;
#define tr(container, it) \
    for (typeof(container.begin()) it = container.begin(); it != container.end(); it++)

#define forn(i, n) for (int i = 0; i < (int)(n); ++i)
#define for1(i, n) for (int i = 1; i <= (int)(n); ++i)
#define ford(i, n) for (int i = (int)(n)-1; i >= 0; --i)
#define fore(i, a, b) for (int i = (int)(a); i <= (int)(b); ++i)

typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<pii> vpi;
typedef vector<pll> vpl;
typedef vector<vi> vvi;

void solve()
{
    int n,k;
    cin >> n >> k;
    vll v(n);
    forn(i, n)
    {
        cin >> v[i];
    }

    int temp = 0;
    for (int i = k; i < n; i++)
    {
        if(v[i]>v[temp]){
            cout<<"Yes"<<endl;
        }else{
            cout<<"No"<<endl;
        }
        temp++;
    }
}

int main()
{
    zoom;
    ll t = 1;
    //cin >> t;

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

Measured memory_bytes: 4772
#include <stdio.h>

int main(int argc, const char * argv[]) {
    // insert code here...
    int a, b, d, r;
    double f;
    scanf("%d %d", &a, &b);
    d = a/b;
    r = a%b;
    f = (double)a/b;
    printf("%d %d %f", d, r, f);
    return 0;
}

Measured memory_bytes: 636
#include <cstdio>
#include <algorithm>
using namespace std;
int main() {
    int N, L[2000] {}, ans = 0;
    scanf("%d%*c", &N);
    for (int i = 0; i < N; ++i) scanf("%d%*c", &L[i]);
    sort(L, L + N);
    for (int i = 0; i < N; ++i) {
        for (int j = i + 1; j < N; ++j) {
            for (int k = j + 1; k < N; ++k) {
                if ((L[i] > L[j] ? L[i] - L[j] : L[j] - L[i]) < L[k] && L[k] < L[i] + L[j]) {
                    ++ans;
                }
            }
        }
    }
    printf("%d\n", ans);
}


Measured memory_bytes: 384
s = str(input())
if s[0] == s[1]:
  if s[2] == s[3] and s[0] != s[2]:
    print("Yes")
  else:
    print("No")
elif s[0] == s[2]:
  if s[1] == s[3] and s[0] != s[1]:
    print("Yes")
  else:
    print("No")
elif s[0] == s[3]:
  if s[1] == s[2] and s[0] != s[1]:
    print("Yes")
  else:
    print("No")
else:
  print("No")

Measured memory_bytes: 3064
#include <cstdio>

int BubbleSort(int a[], int n) {
    int swp = 0;
    for (int i=0; i<n; i++) {
        for (int j=n-1; j > i; j--) {
            if (a[j] < a[j-1]) {
                int tmp = a[j];
                    a[j] = a[j-1];
                    a[j-1] = tmp;
                    swp++;
            }
        }
    }
    return swp;
}

int main () {
    int n;
    int A[100];
    scanf("%d", &n);
    for (int i=0; i<n;i++) scanf("%d", &A[i]);
    int swp = BubbleSort(A, n);
    for (int i=0; i<n; i++) {
        if (i < n-1) {
            printf("%d ", A[i]);
        } else {
            printf("%d\n", A[i]);
        }
    }
    printf("%d\n", swp);
    return 0;
}

Measured memory_bytes: 1028