akhauriyash/Code-Regression huggingface dataset:
import java.util.*;

class Main {
        public static void main(String args[]) {
                try (Scanner sc = new Scanner(System.in)) {
                        int N = sc.nextInt();
                        int sum = 0;
                        int[] A = new int[N];
                        for (int i = 0; i < N; i++) {
                                A[i] = sc.nextInt();
                                sum += A[i];
                        }
                        int M = sc.nextInt();
                        int max = 0;
                        for (int i = 0; i < M; i++) {
                                int P = sc.nextInt() - 1, X = sc.nextInt();
                                System.out.println(sum - A[P] + X);
                        }
                }
        }
}

Measured memory_bytes: 10700
import java.util.Scanner;

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

    void solve(Scanner sc) {
        int a = sc.nextInt();
        int b = sc.nextInt();
        int c = sc.nextInt();

        if (a + b + 1 < c) {
            System.out.println(b + b + a + 1);
        } else {
            System.out.println(b + c);
        }
    }
}

Measured memory_bytes: 21972
"use strict";
var GET=(function(){function f(s){return new g(s);}function g(s){this._s=s.trim().split("\n");this._y=0;}g.prototype.a=function(f){var s=this._s, y=this._y, r;if(typeof s[y]==="string")s[y]=s[y].split(" ").reverse();r=s[y].pop();if(!s[y].length)this._y++;return f?r:+r;};g.prototype.l=function(f){var s=this._s[this._y++].split(" ");return f?s:s.map(a=>+a);};g.prototype.m=function(n,f){var r=this._s.slice(this._y,this._y+=n).map(a=>a.split(" "));return f?r:r.map(a=>a.map(a=>+a));};g.prototype.r=function(n,f){var r=this._s.slice(this._y,this._y+=n);return f?r:r.map(a=>+a);};return f;})();
var o=GET(require("fs").readFileSync("/dev/stdin","utf8"));
function xArray(v){var a=arguments,l=a.length,r="Array(a["+--l+"]).fill(0).map(x=>{return "+v+";})";while(--l)r="Array(a["+l+"]).fill(0).map(x=>"+r+")";return eval(r);}

console.log(main());
function main(){
  var n = o.a();
  var m = o.a();
  var map = xArray(0,n+1);
  var ok = 0, ng = 0;
  for(var i = 0; i < m; i++){
    var p = o.a(), s = o.a(1);
    if(map[p] === -1)continue;
    if(s === "AC"){
      ng += map[p];
      ok++;
      map[p] = -1;
    }else{
      map[p]++;
    }
  }
  return ok+" "+ng;
}

Measured memory_bytes: 33360
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <string>
using namespace std;

struct Node{
	int key;
	Node *prev,*next;
};

Node *nil;
void init(){
	nil=(Node *)malloc(sizeof(Node));
	nil->next=nil;
	nil->prev=nil;
}

void insert(int key){
	Node *x=(Node *)malloc(sizeof(Node));
	x->key=key;
	x->next=nil->next;
	nil->next->prev=x;
	nil->next=x;
	x->prev=nil;
}

Node* listSearch(int key){
	Node *cur=nil->next;
	while(cur!=nil && cur->key!=key){
		cur=cur->next;
	}
	return cur;
}

void deleteNode(Node *t){
	if(t==nil)return;
	t->prev->next=t->next;
	t->next->prev=t->prev;
	free(t);
}

void deleteFirst(){
	deleteNode(nil->next);
}

void deleteLast(){
	deleteNode(nil->prev);
}

void deleteKey(int key){
	deleteNode(listSearch(key));
}

int n;
int main(void){
	init();
	char com[21];
	scanf("%d",&n);
	for(int i=0;i<n;i++){
		int key;
		scanf("%s",com);
		if(com[0]=='i'){
			scanf("%d",&key);
			insert(key);
		}
		else if(com[0]=='d'){
			if(strlen(com)>6){
				if(com[6]=='F')deleteFirst();
				if(com[6]=='L')deleteLast();
			}else{
				scanf("%d",&key);
				deleteKey(key);
			}
		}
	}
	Node *now=nil->next;
	while(now!=nil){
		printf("%d%c",now->key,now->next==nil?'\n':' ');
		now=now->next;
	}
	return 0;
}

Measured memory_bytes: 32216
// https://atcoder.jp/contests/abc084/tasks/abc084_a

#include <algorithm>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <set>
#include <string>
#include <tuple>
#include <vector>
using namespace std;

typedef long long ll;
typedef pair<int, int> PII;
typedef pair<ll, ll> PLL;
#define INF (1e9)
#define MOD (1000000007)
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) for (int i = 0; i < (n); ++i)
#define REPR(i, n) for (int i = n; i >= 0; i--)
#define FOREACH(x, a) for (auto &(x) : (a))
#define ALL(obj) (obj).begin(), (obj).end()
#define ALLR(obj) (obj).rbegin(), (obj).rend()
#define LEN(x) (sizeof(x) / sizeof(*(x)))
ll gcd(long a, long b) { return b ? gcd(b, a % b) : a; }
ll lcm(long a, long b) { return a * b / gcd(a, b); }

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int m;
    cin >> m;
    cout << (24 - m) + 24 << endl;

    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<algorithm>
#include<string.h>
using namespace std;
#define NIL -2000000001
#define MAX 2000000000000

int main() {
  int n, k;
  scanf("%d %d", &n, &k);
  if (n%k == 0) {
    printf("0\n");
  } else {
    printf("1\n");
  }
  return 0;
}


Measured memory_bytes: 128
#include <iostream>
#include <stdio.h>
int main(void){
  long long int N,T;
  long long int t[200000];
  long long int sum=0;
  std::cin >> N >> T;
  for(int i=0;i<N;i++){
    std::cin >> t[i];
  }
  sum = N*T;
  for(int i=0;i<N-1;i++){
    if(t[i+1]-t[i] < T){
      sum -= T-(t[i+1]-t[i]);
    }
  }
  printf("%lld",sum);
  return 0;
}

Measured memory_bytes: 1792
#include<bits/stdc++.h>
#include<iomanip>
using namespace std;
typedef long long ll;
typedef long  l;
typedef pair<int,int> P;
#define rep(i,n) for(int i=0;i<n;i++)
#define fs first
#define sc second
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define ALL(A) A.begin(),A.end()
const double PI=3.141592653589;
const int INF=1000000007;
const ll LMAX=1000000000000001;
ll gcd(ll a,ll b){if(a<b)swap(a,b);while((a%b)!=0){a=b;b=a%b;}return b;}
int dx[]={-1,0,1,0};
int dy[]={0,1,0,-1};


int main(){
  int n,m; cin>>n>>m;
  vector<string> a(n);
  vector<string> b(m);
  rep(i,n) cin>>a[i];
  rep(i,m) cin>>b[i];

  int x=0;
  int y=0;
  while(x+m<=n){
    bool c=1;
    for(int i=x;i<x+m;i++){
      for(int j=y;j<y+m;j++){
        // cout<<"a "<<a[i][j]<<" b "<<b[i-x][j-y]<<endl;
        if(a[i][j]!=b[i-x][j-y])
        c=0;
      }
    }
    if(c){
      puts("Yes");
      return 0;
    }
    y++;
    if(y+m>=n){
      y=0;x++;
    }
  }
  puts("No");

  return 0;
}


Measured memory_bytes: 256
#include <cstdio>
#include <cstring>
#include <cmath>
#include <vector>
#include <iostream>
#include <algorithm>

using namespace std;

int N, M, t;
vector<int> a, b;

int main() {
    cin >> N;
    for (int i = 0;i < N;i ++) {
        cin >> t;
        a.push_back(t);
    }
    cin >> M;
    for (int i = 0;i < M;i ++){
        cin >> t;
        b.push_back(t);
    }
    sort(a.begin(), a.end());
    sort(b.begin(), b.end());

    bool flag = true;
    int i = 0;
    for (int j = 0;j < M;j ++) {
        while (i < N && a[i] < b[j]) i ++;
        if (i >= N) {
            flag = false;
            break;
        } else {
            if (a[i] == b[j]) {
                i ++;
            } else {
                flag = false;
                break;
            }
        }
    }
    if (flag) cout << "YES" << endl;
    else cout << "NO" << endl;
    return 0;
}

Measured memory_bytes: 2548
#include<bits/stdc++.h>
using namespace std;
int N,a;
int main(){
  cin >> N;
  for(int i=0;i<N;i++){
    cin >> a;
    if(a%2==1){
      cout << "first" << endl;
      return 0;
    }
  }
  cout << "second" << endl;
  return 0;
}

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

using namespace std;

#define intt long long
#define FAST ios_base::sync_with_stdio(0); cin.tie(0);

const int MOD = 1000000007;

int n, k;

int main() {

	FAST;

	cin >> n >> k;
	vector <int> a(n);
	for (int i = 0; i < n; i ++) {
		cin >> a[i];
	}
	sort(a.begin(), a.end());
	// Case I
	if (k % 2 && a[n - 1] == 0) {
		cout << 0 << '\n';
		return 0;
	}
	// Case II
	int ans = 1;
	if (k % 2 && a[n - 1] < 0) {
		for (int i = n - 1; i >= n - k; i --) {
			ans = 1LL * ans * a[i] % MOD;
			if (ans < 0) ans += MOD;
		}
		cout << ans << '\n';
		return 0;
	}
	int i = 0, j = n - 1;
	// Case III
	if (k % 2 && a[n - 1] > 0) {
		ans = a[n - 1];
		k --;
		j --;
	}
	// Case IV
	// we will take the numbers in pairs
	// and k / 2 pairs will be choosen
	k /= 2;
	while (k -- ) {
		intt left = 1LL * a[i] * a[i + 1];
		intt right = 1LL * a[j] * a[j - 1];
		if (left > right) {
			ans = 1LL * ans * (left % MOD) % MOD;
			if (ans < 0) ans += MOD;
			i += 2;
		}
		else {
			ans = 1LL * ans * (right % MOD) % MOD;
			if (ans < 0) ans += MOD;
			j -= 2;
		}
	}
	cout << ans << '\n';
	return 0;
}

Measured memory_bytes: 3972
use std::io::*;
use std::str::FromStr;

fn main() {
    let n: usize = read();
    let k: usize = read();
    let h: Vec<i64> = (0..n).map(|_| read()).collect();
    let inf: i64 = 1_i64 << 40;

    let mut dp: Vec<i64> = vec![inf; n];
    dp[0] = 0;
    for i in 0..n {
        for j in 1..k+1 {
            if i + j >= n {
                break;
            }
            dp[i + j] = std::cmp::min(dp[i + j], dp[i] + (h[i + j] - h[i]).abs());
        }
    }
    println!("{}", dp[n-1]);
}

fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.unwrap() as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().unwrap()
}


Measured memory_bytes: 6396
#include<iostream>
#include<algorithm>
#include<iomanip>
#include<deque>
#include<ios>
#include<string>
#include<map>
#include<set>
#include <unordered_set>
#include<vector>
#include<cmath>

using namespace std;

int main(void) {
	int n; cin >> n;
	int x;
	deque<int> d;
	int i;
	for (i = 0; i < n; i++) {
		if (i % 2 == 1) { cin >> x; d.push_front(x); }
		else if (i % 2 == 0) { cin >> x; d.push_back(x); }
	}

	if (n % 2 == 0) {
		while (!d.empty()) {
			cout << d.front() << " ";
			d.pop_front();
		}
	}
	else if (n % 2 == 1) {
		while (!d.empty()) {
			cout << d.back() << " ";
			d.pop_back();
		}
	}
	return 0;
}

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

using namespace std;

int main(int argc, char *argv[]) {
	int N;
	vector<long> a, b;

	cin >> N;

	for (int i = 0; i < N; i++) {
		int ai;
		cin >> ai;
		a.push_back(ai);
	}

	for (int i = 0; i < N; i++) {
		int bi;
		cin >> bi;
		b.push_back(bi);
	}

	int ans = 0;
	for (int k = 30; k >= 0; k--) {
		long T = 1 << k;
		long cnt = 0;

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

		for (int i = 0; i < N; i++) {
			long p = a[i];
			int x = lower_bound(b.begin(), b.end(), 2 * T - p) - lower_bound(b.begin(), b.end(), T - p);
			int y = lower_bound(b.begin(), b.end(), 4 * T - p) - lower_bound(b.begin(), b.end(), 3 * T - p);
			cnt += x + y;
		}

		if (cnt & 1) ans |= T;

		for (int i = 0; i < N; i++) {
			a[i] = a[i] % T;
			b[i] = b[i] % T;
		}
	}

	cout << ans << endl;

	return 0;
}

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

using namespace std;

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


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

int main(){
  int n,b;
  int a[250]={};
  cin>>n;
  for(int i=0;i<26;i++){
    for(int j=0;j<16;j++){
      b=4*i+7*j;
      a[b]=1;
    }
  }
  if(a[n]==1) cout<<"Yes"<<endl;
  else cout<<"No"<<endl;
  
  return 0;
}


Measured memory_bytes: 256
#pragma GCC optimize(3,"Ofast","inline")
#include<bits/stdc++.h>
#define IOS ios::sync_with_stdio(false),cin.tie(0),cout.tie(0)
#define ms(a,b) memset(a,b,sizeof(a))
#define msn(a,n,b) for(int i=0;i<=n;i++)a[i]=b
#define lson l,mid,rt<<1
#define rson mid+1,r,rt<<1|1
#define fi first
#define se second
using namespace std;
mt19937 rng_32(chrono::steady_clock::now().time_since_epoch().count());
typedef long long ll;
typedef long double ld;
typedef pair<int,int> P;
typedef double db;
const int mod=998244353;
const int seed=233;
const double PI=acos(-1.0);
const double eps=1e-7;
const int inf=0x3f3f3f3f;
const int max_n=200005;
ll ceil(ll x,ll y){if(x==0)return 0;if(y<0)x=-x,y=-y;bool sign=x>0;x=abs(x);return sign?(x+y-1)/y:-x/y;}
ll floor(ll x,ll y){if(x==0)return 0;if(y<0)x=-x,y=-y;bool sign=x>0;x=abs(x);return sign?x/y:-(x+y-1)/y;}
char str[max_n];
void rs(string& s){scanf(" %s",str);s=str;}
namespace {
    inline int Add(int x,int y){return (x+=y)>=mod?x-mod:x;}
    inline int Sub(int x,int y){return (x-=y)<0?x+mod:x;}
    inline int Mul(int x,int y) {return 1ll*x*y%mod;}
    inline int Pow(int x,int y=mod-2){int res=1;while(y){if(y&1)res=1ll*res*x%mod;x=1ll*x*x%mod;y>>=1;}return res;}
}
/**********************head************************/
ll f[max_n*2];
ll inv[max_n*2];
ll invn[max_n*2];
ll C(int n,int m)
{
    if(n<m||m<0)return 0;
    return f[n]*inv[n-m]%mod*inv[m]%mod;
}
ll S(int n,int m)
{
    // x_1 + x_2 + ... + x_n = m, x_i >= 0
    if(n==0&&m==0)return 1;
    return C(m+n-1,n-1);
}
ll solve(int n,int s,int m)//xi<m,xi>=0
{
    ll res=S(n,s);
    for(int i=1;i<=n;i++)
    {
        if(i&1)res=Sub(res,Mul(C(n,i),S(n,s-m*i)));
        else res=Add(res,Mul(C(n,i),S(n,s-m*i)));
    }
    return res;
}
void init(int n)
{
    f[0]=1;
    for(int i=1;i<=n;i++)f[i]=f[i-1]*i%mod;
    inv[n]=Pow(f[n]);
    for(int i=n-1;i>=0;i--)inv[i]=inv[i+1]*(i+1)%mod;
    invn[1]=1;
    for(int i=2;i<=n;i++)invn[i]=invn[mod%i]*(mod-mod/i)%mod;
}
int n,m,k;
int main(){
    scanf("%d%d%d",&n,&m,&k);
    init(n);
    int ans=0;
    for(int i=0;i<=k;i++)ans=Add(ans,Mul(C(n-1,i),Pow(m-1,n-1-i)));
    ans=Mul(ans,m);
    printf("%d\n",ans);
    return 0;
}

Measured memory_bytes: 8356
from collections import deque
B,A = list(map(int,input().split()))
Abinstr = bin(A)
Bbinstr = bin(B)
stk = deque()
if ((int((A+1)/2)-int(B/2))%2==1):
    stk.append("1")
else:
    stk.append("0")
for i in range(1,len(Abinstr)-2):
    k = 2**i-1 #桁のずらし
    jA = (A-k)%2**(i+1)
    if B>k:
        jB = (B-1-k)%2**(i+1)
    else :
        jB=0
    if 2**i > jA and jA%2==1:
        jA = 3
    else:
        jA = 2
    
    if 2**i > jB and jB%2==1:
        jB = 1
    else:
        jB = 2
    if (jA-jB)%2==0:
        stk.appendleft("0")
    else:
        stk.appendleft("1")
print(int("".join(stk),2))

Measured memory_bytes: 3316
// 2015/06/02 Tazoe

#include <iostream>
#include <string>
#include <sstream>
using namespace std;

class Stack{
private:
	int sp;			// スタックポインタ
	int S[100];		// スタックの配列
public:
	Stack()			{  sp = 0;  }
	bool isFull() const	{  return (sp==100);  }
	bool isEmpty() const	{  return (sp==0);  }
	void push(int d);
	int top();
	void pop();
};

void Stack::push(int d)
{
	if(isFull())
		return;		// 満杯

	S[sp++] = d;		// スタックにデータを追加する
}

int Stack::top()
{
	if(isEmpty())
		return -1;	// 異常終了（空）

	return S[sp-1];		// 頂上のデータ
}

void Stack::pop()
{
	if(isEmpty())
		return;		// 空

	sp--;			// スタックからデータを取り出す
}


int main()
{
	Stack s;

	string exp;
	getline(cin, exp);	// 1行読み込み

	istringstream is(exp);	// 入力ストリーム

	while(!is.eof()){
		string opr;
		is >> opr;

		int tmp1, tmp2;

		switch(opr[0]){
		case '+':
			tmp1 = s.top();  s.pop();
			tmp2 = s.top();  s.pop();
			s.push(tmp2+tmp1);
			break;
		case '-':
			tmp1 = s.top();  s.pop();
			tmp2 = s.top();  s.pop();
			s.push(tmp2-tmp1);
			break;
		case '*':
			tmp1 = s.top();  s.pop();
			tmp2 = s.top();  s.pop();
			s.push(tmp2*tmp1);
			break;
		default:
			istringstream is2(opr);
			is2 >> tmp1;
			s.push(tmp1);
			break;
		}
	}

	cout << s.top() << endl;

	return 0;
}

Measured memory_bytes: 1228
h,w=map(int,input().split())
a=[list(input()) for i in range(h)]
c=[]
ng_h,ng_w=[],[]
for i in range(h):
  ok=True
  for j in range(w):
    if a[i][j]!=".":
      ok=False
      break
  if ok:
    ng_h.append(i)

for i in range(w):
  ok=True
  for j in range(h):
    if a[j][i]!=".":
      ok=False
      break
  if ok:
    ng_w.append(i)

for i in range(h):
  t=""
  for j in range(w):
    if i in ng_h:continue
    if j in ng_w:continue
    t+=a[i][j]
  if t!="":
    c.append(t)
print(*c,sep='\n')


Measured memory_bytes: 3188
#include <bits/stdc++.h>
#include <iomanip>
#include <math.h>
#define rep(i,x) for(ll i = 0;i<x;i++)
#define all(a) (a).begin(),(a).end()
using ll = long long;
using ld = long double;
using namespace std;
using dou = double;
const ll INF = 1001001001;
const ll mod = 1000000007;
typedef pair<ll,ll> P;
using graph = vector<vector<ll>>;
ll gcd(ll a,ll b){
    if(a < b)swap(a,b);
    if(a % b == 0)return b;
    else return gcd(b,a%b);
}
bool isp(ll n){
    bool res = true;
    if(n == 1)return false;
    else{
        for(ll i = 2;i * i <= n;i++){
            if(n % i == 0){
                res = false;
                break;
            }
        }
        return res;
    }
}
//printf("%.10f\n", N);
/*
ll memo[100000];
ll fibo(ll n){
    if(memo[n] != 0)return memo[n];
    if(n <= 1)return n;
    else return memo[n] = fibo(n - 1)+ fibo(n - 2);
}*/

int main(){
    ll N,K;
    cin >> N >> K;
    vector<ll> num(N);
    ll n;
    rep(i,N){
        cin >> n;
        num[i] = abs(n - K);
    }
    ll ans = num[0];
    rep(i,N){
        ans = gcd(ans,num[i]);
    }
    cout << ans << endl;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
typedef long long ll;
int main() {
  int n, m;
  cin >> n >> m;
  if (n==m) cout << "Yes" << endl;
  else cout << "No" << endl;
}


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

//定義場所//
int i, j, k, l, m, n;
int W, N, K;
////////////

int main()
{
	cin >> N >> K;
	string S;
	cin >> S;
	if (S.at(K - 1) == 'A') {
		S.at(K - 1) = 'a';
	}
	else if (S.at(K - 1) == 'B') {
		S.at(K - 1) = 'b';
	}
	else {
		S.at(K - 1) = 'c';
	}
	cout << S;
}

Measured memory_bytes: 256
#include "stdio.h"

#define ALP_SIZE 26

int main()
{
	int A[ALP_SIZE];
	int i;
	char ch;

	for (i = 0; i < ALP_SIZE; i++) A[i] = 0;

	while ((ch = getchar()) != EOF)
	{
		if (ch >= 0x41 && ch <= 0x5A || ch >= 0x61 && ch <= 0x7A) A[(ch & 0x1F) - 1]++;
	}

	for (i = 0; i < ALP_SIZE; i++) printf("%c : %d\n",0x61 + i, A[i]); 

	return 0;
}

Measured memory_bytes: 2708
#include<iostream>
#include <string>
#include<cmath>
#include<math.h>
#include<vector>

using namespace std;

int main(void)
{
	int a, b, c;

	cin >> a >> b >> c;

	if (a == 5)
	{
		if (((b == 7) && (c == 5)) || ((b == 5) && (c == 7)))
		{
			cout << "YES" << endl;
		}
		else
		{
			cout << "NO" << endl;
		}
	}

	if (a == 7)
	{
		if ((b == 5) && (c == 5))
		{
			cout << "YES" << endl;
		}
		else
		{
			cout << "NO" << endl;
		}
	}






	return 0;
}

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

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

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

	int n;
	cin >> n;

	vector<int> s(n), l(n), p(n);
	for(int i = 0; i < n; ++i)
		cin >> s[i] >> l[i] >> p[i];

	vector<int> dp(394, -1);
	dp[0] = 0;
	for(int i = 0; i < 394; ++i) {
		if(dp[i] == -1)
			continue;

		for(int j = 0; j < n; ++j)
			for(int k = s[j]; k <= l[j] && i + k < 394; ++k)
				chmax(dp[i + k], dp[i] + p[j]);
	}

	int m;
	cin >> m;

	vector<int> ans(m);
	for(int i = 0; i < m; ++i) {
		int w;
		cin >> w;

		if(dp[w] == -1) {
			cout << -1 << endl;
			return EXIT_SUCCESS;
		}

		ans[i] = dp[w];
	}

	for(int i = 0; i < m; ++i)
		cout << ans[i] << endl;

	return EXIT_SUCCESS;
}

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

int main() {
	int A,B,C;
	cin >> A >> B >> C;
	if(B/A>C){
		cout << C << endl;
	} else {
		cout << B/A << endl;
	}
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define mp make_pair
#define F first
#define S second
using namespace std;

typedef pair<int, int> ii;
typedef vector<ii> vii;
typedef long long ll;
typedef vector<int> vi;

int main(){
//	freopen(".in", "r", stdin);
	ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);

	int a, b;

	cin >> a >> b;

	if(a == b) cout << "a == b\n";
	if(a < b) cout << "a < b\n";
	if(a > b) cout << "a > b\n";

	return 0;
}


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

namespace ABC084A
{
    class Program
    {
        static void Main(string[] args)
        {
            int M;

            M = int.Parse(Console.ReadLine());

            Console.WriteLine(48 - M);

            Console.ReadKey();
        }
    }
}


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

int main(){
  string s;
  cin >> s;
  if(s == "SUN") cout << 7;
  if(s == "MON") cout << 6;
  if(s == "TUE") cout << 5;
  if(s == "WED") cout << 4;
  if(s == "THU") cout << 3;
  if(s == "FRI") cout << 2;
  if(s == "SAT") cout << 1;
}


Measured memory_bytes: 256
#include <iostream> 
#include <sstream> 
#include <iomanip> 
#include <algorithm> 
#include <cmath> 
#include <string> 
#include <vector> 
#include <list> 
#include <queue> 
#include <stack> 
#include <set> 
#include <map> 
#include <bitset> 
#include <numeric> 
#include <climits> 
#include <cfloat> 
using namespace std; 

map<string, int> atom;

int solve(string s, int& i)
{
    int n = s.size();

    int ret = 0;
    while(i < n && s[i] != ')'){
        int w;
        if(s[i] == '(')
            w = solve(s, ++i);
        else{
            string t;
            t = s[i];
            ++ i;
            if(i < n && 'a' <= s[i] && s[i] <= 'z'){
                t += s[i];
                ++ i;
            }
            if(atom.find(t) == atom.end())
                w = -1;
            else
                w = atom[t];
        }
        if(w == -1)
            return -1;

        int num = 0;
        while(i < n && '0' <= s[i] && s[i] <= '9'){
            num *= 10;
            num += s[i] - '0';
            ++ i;
        }
        if(num == 0)
            num = 1;
        ret += w * num;
    }

    ++ i;
    return ret;
}

int main()
{
    for(;;){
        string s;
        cin >> s;
        if(s == "END_OF_FIRST_PART")
            break;
        int w;
        cin >> w;
        atom.insert(make_pair(s, w));
    }

    for(;;){
        string s;
        cin >> s;
        if(s == "0")
            return 0;

        int i = 0;
        int ret = solve(s, i);
        if(ret == -1)
            cout << "UNKNOWN" << endl;
        else
            cout << ret << endl;
    }
}

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

int main(){
    int A,B,m; cin >> A >> B >> m;
    int a[A], b[B];
    int ami = INT_MAX, bmi = INT_MAX;
    for(int i = 0; i < A; i++) {cin >> a[i]; ami = min(ami, a[i]); }
    for(int i = 0; i < B; i++) {cin >> b[i]; bmi = min(bmi, b[i]); }
    int mi = ami+bmi;
    for(int i = 0; i < m; i++){
        int x,y,c; cin >> x >> y >> c;
        mi = min(mi, a[x-1]+b[y-1]-c);
    }
    cout << mi << endl;
    return 0;
}

Measured memory_bytes: 1024
N = int(input())
A = [0] + list(map(int, input().split())) + [0]
AA = list(zip(A[:-1], A[1:]))
cost = [abs(aa[0] - aa[1]) for aa in AA]
# print('cost', cost)
ttl = sum(cost)
# print('ttl', ttl)

for i in range(1, N + 1):
    ans = ttl
    if A[i - 1] < A[i] and A[i] < A[i + 1]:
        pass
    elif A[i - 1] > A[i] and A[i] > A[i + 1]:
        pass
    else:
        d1, d2 = abs(A[i - 1] - A[i]), abs(A[i] - A[i + 1])
        d = min(d1, d2)
        red = d * 2
        ans -= red
    print(ans)


Measured memory_bytes: 22320
import java.util.Scanner;

public class Main {

	public static void main (String[] args) {

		Scanner sc = new Scanner(System.in);
		
		for (int i = 1; i <= 10000; i++) {
			int n = sc.nextInt();
			if (n == 0) break;
			System.out.println("Case " + i + ": " + n);
		}
		
		sc.close();
	}

}

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

int main() {
	int a;
	int b;
	int c;
	cin>>a>>b>>c;
	if (a<b && b<c) {
		cout << "Yes" << endl;
	}
	else {
		cout << "No" << endl;
	}
	return 0;
}



Measured memory_bytes: 3100
process.stdin.resume();
process.stdin.setEncoding('utf8');
 
var lines = [];
var reader = require('readline').createInterface({
    input: process.stdin,
    output: process.stdout
});
reader.on('line', (line) => {
    // ここで入力を処理する
    lines.push(line);
});
reader.on('close', () => {
  var a = lines[0].split("");
  var cnt = 0;
 // console.log(a)
  for(var i in a){
    if(a[i] == 1){
      //console.log(a[i])
    ++cnt}
  }
  console.log(cnt)

//console.log(1*lines[0]+1*lines[1].split(' ')[0]+1*lines[1].split(' ')[1]+" "+lines[2])
});

Measured memory_bytes: 7628
#include <stdio.h>
int main()
{
	int h, w, i, j;
	while(1)
	{
		scanf("%d %d", &h, &w);
		if (h == 0 && w == 0) { break; }
		for (i = 0; i < h; i++) {
			for (j = 0; j < w; j++) {
				if (i == 0 || i == h - 1 || j == 0 || j == w - 1)
				{
					printf("#");
				}
				else
				{
					printf(".");
				}
			}
			printf("\n");
		}
		printf("\n");
	}
	return 0;
}

Measured memory_bytes: 572
#include <bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<=b;++i)
#define ck(a,x) (!!((a)&(1<<(x))))
typedef long long ll;
const int N = 2e5 + 100;
const int inf = 0x3f3f3f3f;
using namespace std;
int n, f[N][2], b[N];
ll a[N];
int main() {
    scanf("%d", &n);
    rep(i, 1, n) scanf("%lld", &a[i]), b[i] = inf;
    rep(j, 0, 20) {
        rep(i, 1, n)
            if(ck(a[i],j)) f[i][0] = 0;
            else f[i][0] = f[i-1][0] + 1;
        rep(i, 1, n) {
            if(ck(a[i],j)) f[i][1] = f[i-1][0] + 1;
            else f[i][1] = f[i-1][1] + 1;
            b[i] = min(b[i], f[i][1]);
        }
    }
    ll ans = 0;
    rep(i, 1, n) ans += 1LL*b[i];
    printf("%lld\n", ans);
    return 0;
}


Measured memory_bytes: 4096
#!/usr/bin/env python3
#AGC34-A
import sys
import math
import bisect
from heapq import heappush, heappop
from collections import defaultdict
from itertools import accumulate
from collections import Counter
from collections import deque
from operator import itemgetter
mod = 10**9 + 7

n,a,b,c,d = map(int,input().split())
s = list(input())

for i in range(a,c-1):
    if s[i] == '#' and s[i+1] == '#':
        print('No')
        quit()
for i in range(b,d-1):
    if s[i] == '#' and s[i+1] == '#':
        print('No')
        quit()
if c > d:
    for i in range(b-1,d):
        if s[i] == '.' and s[i+1] == '.' and s[i-1] == '.':
            print('Yes')
            quit()
    print('No')
else:
    print('Yes')


Measured memory_bytes: 61412
import Control.Monad
import Data.Array
import qualified Data.ByteString.Char8 as BS
import Data.Maybe

readInt = fromIntegral . fst . fromJust . BS.readInteger

readIntList = map readInt . BS.words

getInt = readInt <$> BS.getLine

getIntList = readIntList <$> BS.getLine

getIntNList n = map readIntList <$> replicateM (fromIntegral n) BS.getLine

checkI css tup 0 _ = True
checkI css tup n v
  | n == 3 = checkI css tup (n -1) diff
  | v == diff = checkI css tup (n -1) v
  | otherwise = False
  where
    diff = css ! (fst tup, n) - css ! (snd tup, n)

checkJ css tup 0 _ = True
checkJ css tup n v
  | n == 3 = checkJ css tup (n -1) diff
  | v == diff = checkJ css tup (n -1) v
  | otherwise = False
  where
    diff = css ! (n, fst tup) - css ! (n, snd tup)

main = do
  let num = 3
  css <- getIntNList num
  let css' = listArray ((1, 1), (num, num)) (concat css)
  if checkI css' (3, 2) 3 0 && checkI css' (2, 1) 3 0 && checkJ css' (3, 2) 3 0 && checkJ css' (2, 1) 3 0
    then putStrLn "Yes"
    else putStrLn "No"


Measured memory_bytes: 3804
#include<iostream>
#include <bits/stdc++.h>
using namespace std;
int main()
{
	int a,b,sum=0;
	cin >> a >> b;
  	int c[a];
  	for(int i=0;i<a;i++) {cin >> c[i];
  	sum += c[i];}
  	sort(c,c+a);
  	if((float)c[a-b] < (float)sum/(4*b)) cout << "No";
  	else cout << "Yes";
}

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

int main() {
  int x1, y1, x2, y2;
  cin >> x1 >> y1 >> x2 >> y2;
  int a = x2 - x1;
  int b = y2 - y1;
  int x3 = x2 - b;
  int y3 = y2 + a;
  int x4 = x1 - b;
  int y4 = y1 + a;
  cout << x3 << " " << y3 << " " << x4 << " "<< y4 << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(a,n) for (ll a = 0; a < (n); ++a)
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
typedef vector<vector<ll> > Graph;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
const ll INF = 1e9;

// auto mod int
// https://youtu.be/L8grWxBlIZ4?t=9858
// https://youtu.be/ERZuLAxZffQ?t=4807 : optimize
// https://youtu.be/8uowVvQ_-Mo?t=1329 : division
const int mod = 1000000007;
//const int mod = 998244353;
struct mint {
  ll x; // typedef long long ll;
  mint(ll x=0):x((x%mod+mod)%mod){}
  mint operator-() const { return mint(-x);}
  mint& operator+=(const mint a) {
    if ((x += a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator-=(const mint a) {
    if ((x += mod-a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator*=(const mint a) { (x *= a.x) %= mod; return *this;}
  mint operator+(const mint a) const { return mint(*this) += a;}
  mint operator-(const mint a) const { return mint(*this) -= a;}
  mint operator*(const mint a) const { return mint(*this) *= a;}
  mint pow(ll t) const {
    if (!t) return 1;
    mint a = pow(t>>1);
    a *= a;
    if (t&1) a *= *this;
    return a;
  }

  // for prime mod
  mint inv() const { return pow(mod-2);}
  mint& operator/=(const mint a) { return *this *= a.inv();}
  mint operator/(const mint a) const { return mint(*this) /= a;}
};
istream& operator>>(istream& is, const mint& a) { return is >> a.x;}
ostream& operator<<(ostream& os, const mint& a) { return os << a.x;}




// combination mod prime
// mintが必要
// https://www.youtube.com/watch?v=8uowVvQ_-Mo&feature=youtu.be&t=1619
struct combination {
  vector<mint> fact, ifact;
  combination(int n):fact(n+1),ifact(n+1) {
    assert(n < mod);
    fact[0] = 1;
    for (int i = 1; i <= n; ++i) fact[i] = fact[i-1]*i;
    ifact[n] = fact[n].inv();
    for (int i = n; i >= 1; --i) ifact[i-1] = ifact[i]*i;
  }
  mint operator()(int n, int k) {
    if (k < 0 || k > n) return 0;
    return fact[n]*ifact[k]*ifact[n-k];
  }
};

ll comb(int x){
    ll res = x*(x-1)/2;
    return res;
}
int main(){
    int n,m;
    cin >> n >> m;
    ll ans = 0;
    ans += comb(n);
    ans += comb(m);
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
  int n;
  cin>>n;
  double sum=0;
  for(int i=0;i<n;i++)
  {   double k;
       cin>>k;
       sum+=double(1/k);
    }
    cout<<fixed<<setprecision(14)<<double(1/sum)<<endl;

}


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

signed main(){
    ios::sync_with_stdio(0);cin.tie(0);
    
    int n;
    cin>>n;

    int c=1,ans=0;
    for(int i=0;i<n;i++){
        int x;
        cin>>x;
        if(x==c){
            c++;
        }
        else{
            ans++;
        }
    }

    if(ans==n){
        ans=-1;
    }
    cout<<ans;

    return 0;
}

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

int main(){
  int N;
  cin>>N;
  int j=0,k=0,l=0;
  for(int i=0;i<N;i++){
    int a;
    cin>>a;
    if(a==j)
      k++;
    else{
      l+=k/2;
      j=a;
      k=1;
    }
  }
  cout<<l+k/2<<endl;
}

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

int main(){

  int num, v, n, m, len, cnt;
  vector<long long> vc[2];

  while(cin >> n){
    if(n == 0) break;
    vc[0].clear();
    vc[1].clear();
    len = 0;

    for(int i=0; i<n; i++){
      cin >> num >> v >> m;
      for(int j=0; j<=len; j++){
        if(j == len){
          vc[0].push_back(num);
          vc[1].push_back((long long)v * m);
          len++;
          break;
        }
        if(vc[0][j] == num){
          if(vc[1][j] < 1000000){
            vc[1][j] += (long long)v * m;
          }
          break;
        }
      }
    }
    
    cnt = 0;
    for(int i=0; i<len; i++){
      if(vc[1][i] >= 1000000){
        cout << vc[0][i] << endl;
        cnt++;
      }
    }
    if(cnt == 0) cout << "NA" << endl;

  }

  return 0;

}

Measured memory_bytes: 1232
a = 0
c = True
for i in range(int(input())):
    b = input()
    if b == "A":
        a += 1
    else:
        a -= 1
    if a == -1:
        print("NO")
        c = False
        break
if c == True:
    if a == 0:
        print("YES")
    else:
        print("NO")


Measured memory_bytes: 5592
from copy import copy

C,R,K=map(int,input().split())
dp=[[0]*(R+1) for i1 in range(4)]
M=[[0]*R for i in range(C)]
for i in range(K):
    r,c,v=map(int,input().split())
    M[r-1][c-1]=v
for i,l in enumerate(M):
    for num in range(1,4):
        for j in range(R):
            if num==1:
                dp[num][j]= max(dp[num][j-1],dp[num-1][j-1]+M[i][j])
            else:
                dp[num][j]= max(dp[num][j-1],dp[num-1][j],dp[num-1][j-1]+M[i][j])
    dp[0]=dp[-1][1:-1]+[0,dp[-1][0]]

print(dp[-1][-2])

Measured memory_bytes: 147200
def selectionSort(A, N):
	count = 0
	for i in range(N):
		minj = i
		for j in range(i, N):
			if A[j] < A[minj]:
				minj = j
		if i != minj:
			A[i], A[minj] = A[minj], A[i]
			count += 1
	print(*A)
	print(count)


if __name__ == "__main__":
	n = int(input())
	a = list(map(int, input().split()))
	selectionSort(a, n)


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

void shuffle( string& s )
{
    char temp = s[0];

    for( int i = 0; i < s.size() - 1; i++ )
    {
        s[i] = s[i+1];
    }
    s[s.size()-1] = temp;
}

int main() 
{
    string str;                 //入力文字
    int m;                      //シャッフル回数
    int h;                      //下からh何枚

    while( cin >> str )
    {
        if( str == "-" )
            break;
        
        cin >> m;

        for ( int i = 0; i < m; i++)
        {
            cin >> h;
            for( int i = 0; i < h; i++ )
            {
                shuffle(str);
            }
        }
        cout << str << endl;
    }
    return 0;
}


Measured memory_bytes: 3196
#define _USE_MATH_DEFINES
#include <math.h>
#include <iostream>
#include <iomanip>
#include <cstdlib>
#include <algorithm>
#include <numeric>
#include <stdio.h>
#include <vector>
#include <map>

using namespace std;
typedef long long ll;

#define rep(i, n) for(ll i = 0; i < (ll)(n); i++)

int main() {

    ll N;
    cin >> N;
    ll a1 = 0;
    ll a2 = 0;
    ll a4 = 0;
    rep(i,N){
        ll a;
        cin >> a;
        if(a%4==0) a4++;
        else if(a%2==0) a2++;
        else a1++;
    }
    string out = "No";
    if(a1==0) out = "Yes";
    else if(a2==0&&a1-a4<2) out = "Yes";
    else if(a1<=a4) out = "Yes";
    cout << out << endl;
    return 0;
}


Measured memory_bytes: 256
#include "bits/stdc++.h"
#define MOD 1000000007
#define INF 11234567890
#define in std::cin
#define out std::cout
#define rep(i,N) for(LL i=0;i<N;++i)
typedef long long int LL;

LL N, K;
std::pair<LL, LL>ab[112345];

int main()
{
	in >> N >> K;
	rep(i, N) { in >> ab[i].first >> ab[i].second; }

	std::sort(ab, ab + N);
	rep(i, N)
	{
		K -= ab[i].second;
		if (K <= 0)
		{
			out << ab[i].first << std::endl;
			break;
		}
	}
	return 0;
}

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

using i8  = int8_t;   /* -128 ~ 127 */
using u8  = uint8_t;  /* 0 ~ 255 */
using i16 = int16_t;  /* -32,768 ~ 32,767 */
using u16 = uint16_t; /* 0 ~ 65,535 */
using i32 = int32_t;  /* -2,147,483,648 ~ 2,147,483,647 */
using u32 = uint32_t; /* 0 ~ 4,294,967,295 */
using i64 = int64_t;  /* -9,223,372,036,854,775,808 ~ 9,223,372,036,854,775,807 */
using u64 = uint64_t; /* 0 ~ 18,446,744,073,709,551,615 */
using f32 = float;    /* (-3.4 * 10^38) ~ (3.4 * 10^38) */
using f64 = double;   /* (-1.7 * 10^308) ~ (1.7 * 10^308) */
using f80 = __float80;
template <class T> using Vec = vector<T>;
constexpr i64 INF = 1010000000000000017;
constexpr i64 MOD = 1e9 + 7;
constexpr f64 EPS = 1e-12;
constexpr f64 PI = 3.14159265358979323846;
#define ALL(v) v.begin(), v.end()
#define GCD(a, b) __gcd(a, b) /* 最大公約数 */
#define LCM(a, b) a / __gcd(a, b) * b /* 最小公倍数 */

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout << fixed << setprecision(15);
    Main();
    return 0;
}

class PrimeList {
  private:
    u64 max;
    Vec<u64> vals;
    Vec<bool> is_prime;
  public:
    PrimeList(u64 val): max(val), is_prime(val + 1, true) {
        is_prime[0] = false; is_prime[1] = false;
        for(int i = 4; i <= max; i += 2) is_prime[i] = false;
        for(int i = 3; i * i <= max; i += 2) {
            if(!is_prime[i]) continue;
            for(int j = 3; i * j <= max; j += 2)
                if(is_prime[i * j]) is_prime[i * j] = false;
        }
        for (int i = 0; i <= max; i++) if (is_prime[i]) vals.push_back(i);
    }
    bool exists(u64 x) const { return is_prime[x]; }
    u64 size() const noexcept { return (u64)vals.size(); }
    u64 range_max() const noexcept { return max; }
    u64 operator[](u64 index) const { return vals[index]; }
    decltype(vals)::const_iterator begin() const noexcept { return vals.cbegin(); }
    decltype(vals)::const_iterator end() const noexcept { return vals.cend(); }
};

Vec<pair<u64, u32>> prime_factorization(u64 num) {
    u64 n = sqrt(num);
    PrimeList p(n);
    Vec<pair<u64, u32>> res;
    for (auto it = p.begin(); it != p.end(); it++) {
        u32 sum = 0;
        u64 i = *it;
        while (num % i == 0) {
            sum++;
            num /= i;
        }
        if (sum > 0) res.push_back(make_pair(i, sum));
    }
    if (num > n) res.push_back(make_pair(num, 1));
    return res;
}

void Main() {
    i64 A, B;
    cin >> A >> B;
    Vec<pair<u64, u32>> pa = prime_factorization(A);
    Vec<pair<u64, u32>> pb = prime_factorization(B);
    Vec<i64> da;
    Vec<i64> db;
    for (i64 i = 0; i < pa.size(); i++) da.push_back(pa[i].first);
    for (i64 i = 0; i < pb.size(); i++) db.push_back(pb[i].first);
    Vec<i64> cd;
    set_intersection(ALL(da), ALL(db), inserter(cd, cd.end()));
    i64 sum = 1;
    sum += cd.size();
    cout << sum << endl;
}


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

using namespace std;

int main()
{
    string word;
    int n,counter=0;
    cin>>n>>word;
    for (int i=0;i<n ;++i )
        {
            if(i==0)
                counter++;
            else{
                if(word[i]==word[i-1])
                    continue;
                else
                    counter++;
            }
        }
    cout<<counter<<endl;

     return 0;
}


Measured memory_bytes: 512
s = input().split()

len_max = 0
freq_max = 0
w_len = ""
w_freq = ""
dict_freq = {}

for i,w in enumerate(s):
    if w in dict_freq:
        dict_freq[w] += 1
    else:
        dict_freq[w] = 1
    if len(w) > len_max:
        w_len = w
        len_max = len(w)
    if dict_freq[w] > freq_max:
        w_freq = w
        freq_max = dict_freq[w]
print(w_freq, w_len)



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

int main(){
  int n,k;
  cin >> n >> k;
  vector<double> p(n);
  double a=0;//すべてのサイコロの期待値の合計
  for(int i=0;i<n;i++){
    cin >> p.at(i);
    p.at(i)++;
    p.at(i)/=2;//i個目のサイコロの期待値
    a+=p.at(i);
  }
  
  vector<double> aa(n);
  aa.at(0)=a-p.at(0);
  for(int i=1;i<n;i++)
    aa.at(i)=aa.at(i-1)-p.at(i);
  reverse(aa.begin(),aa.end());
  aa.push_back(a);
  reverse(aa.begin(),aa.end());
  
  double kk=0;
  
  for(int i=0;i<n-k+1;i++){
    kk=max(kk,aa.at(i)-aa.at(i+k));
  }
  printf("%.12f\n",kk);
}

Measured memory_bytes: 6528
import java.util.ArrayList;
import java.util.Collections;
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
       int n=sc.nextInt();
       ArrayList<Integer> array =new ArrayList<>();
       for(int i=0;i<n;i++) {
    	   array.add(sc.nextInt());
       }
       Collections.sort(array);
       double temp=0;
       for(int i=0;i<n;i++) {
    	 if(i==0) {
    	 temp=(double)(array.get(i)+array.get(i+1))/2;
           i++;

    	 }else {
    		temp=(double)(temp+array.get(i))/2;
                    
    	 }
       }
       System.out.println(temp);
    }
}


Measured memory_bytes: 23124
import java.util.Scanner;

public class Main{
	public static void main(String[] args){
		Scanner sc=new Scanner(System.in);
		while(sc.hasNext()){
			long a=sc.nextInt();
			long b=sc.nextInt();
			if(a==0 || b==0 || a*b<0) System.out.println("Zero");
			else if(a>0 && b>0) System.out.println("Positive");
			else System.out.println((-b+a+1)%2==0 ? "Positive" : "Negative");
		}
	}
}

Measured memory_bytes: 9428
package main

import (
  "fmt"
  "sort"
)

func main() {
  var p, q, r int
  fmt.Scan(&p, &q, &r)
  num_list := []int{p,q,r}
  sort.Ints(num_list)
  ans := num_list[0] + num_list[1]
  fmt.Println(ans)
}

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

int main() {
  int n;
  cin >> n;
  int a[n+1];
  pair<int,int> tmp;
  pair<int,int> st;
  //tmp = make_pair(a,b);
  
  for(int i = 1;i<n+1;i++){
    cin >> a[i];
  }
  ll bl = 1000;
  ll num;
  ll sn =0;
  for(int i = 1 ;i <n+1;i++){
     if(i == n){
      bl += a[i]*sn;
      sn = 0;
    }else{
      if(a[i] > a[i+1]){
        bl += a[i]*sn;
        sn = 0;
      }
    }
    
    num = 0;
    if(bl > 0 && i != n){
      if(a[i+1] > a[i]){
        num = bl/a[i];
        bl %= a[i];
        //tmp = make_pair(num,a[i]);
      }
    }
    //cout << i << " " << num << " " << a[i] << " " << bl << endl;

    //cout << i << " " << num << " " << a[i] << endl;
    sn += num;  
    //d.push_back(tmp);
  }
  cout << bl;
}

Measured memory_bytes: 3612
#include <cstdio>
#include <algorithm>
#include <vector>
#include <map>
#define repi(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,a) repi(i,0,a)
#define all(a) (a).begin(), (a).end()

using ll = long long;
using P = std::pair<ll, ll>;

ll N;
ll x[60], y[60];
std::vector<P> ps;
std::map<P,ll> cnt;
bool used[60];

int main()
{
  scanf( "%lld", &N );
  rep( i, N )
    scanf( "%lld%lld", x+i, y+i ), ps.push_back( P( x[i], y[i] ) );

  std::sort( all(ps) );

  rep( i, N ) rep( j, i )
  {
    P diff = P( ps[i].first-ps[j].first, ps[i].second-ps[j].second );

    ++cnt[diff]; 
  }

  ll tmp = 0;

  for( auto it = cnt.begin(); it != cnt.end(); ++it )
    tmp = std::max( tmp, it->second );

  printf( "%lld\n", N-tmp );

  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define fastIO ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define int long long int
#define fi first
#define se second
#define pub push_back
#define pi pair<int,int>
#define all(v) (v).begin(), (v).end()
#define rep(i, l, r) for(int i=(int)(l);i<(int)(r);i++)
#define repd(i, l, r) for (int i=(int)(l);i>=(int)(r);i--)
#define clrg(i, l, r) for(int i=(int)(l);i<(int)(r);i++)vis[i]=0,v[i].clear();
int power(int x, unsigned int y){int res = 1;while (y > 0){ if (y & 1){res = res*x;} y = y>>1;x = x*x;}return res;}
int powermod(int x, unsigned int y, int p){int res = 1;x = x % p;while (y > 0){if (y & 1){res = (res*x) % p;}y = y>>1; x = (x*x) % p;}return res;}
#define print2d(mat,n,m){for(int i=0;i<(int)(n);i++){for(int j=0;j<(m);j++){cout<<mat[i][j]<<" ";}cout<< endl;}}
#define clr(a,x) memset(a,x,sizeof(a))
#define rr(v) for(auto &val:v)
#define print(v) for (const auto itr : v){cout<<itr<<' ';}cout<<"\n";
#define ln length()
#define sz size()
#define mod 1000000007
#define elif else if
int dp[100][100005],n,k;
vector<int> v,w;
int solve(int i,int k){
  if(i==n or k==0)return 0;
  if(dp[i][k]!=-1)return dp[i][k];
  int ans=0;
  if(k>=w[i])ans=max(ans,v[i]+solve(i+1,k-w[i]));
  ans=max(ans,solve(i+1,k));
  dp[i][k]=ans;
  return ans;
}
int32_t main(){
  clr(dp,-1);
  cin>>n>>k;
  rep(i,0,n){
    int t ; cin>>t;
    w.pub(t);
    cin>>t;
    v.pub(t);
  }
  cout<<solve(0,k)<<"\n";
   return 0;
}
/*
Edge cases? n=1? a[i]<=0?
long vs int? 1LL? 64bits?
Re-read problem. Is it as easy as it seems?
KEEP CORRECTING AND SUBMITTING!
*/


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

int main() {
    long long n;
    cin >> n;
    long long x, y;
    for (long long i=1; i<=sqrt(n); i++) {
        if (n%i == 0) {
            x = i; y = n/i;
        }
    }
    x--; y--;
    cout << x + y << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <string>
using namespace std;
using ll = long long;

int main(){
    ll a,n,m,c,d=0;
    cin>>n;
    if (n%2==0) {
        cout<<(n*(n-1))/2-n/2<<endl;
        for (ll i=1; i<n; i++) {
            for (ll j=i+1; j<=n; j++) {
                if (i+j-1!=n) {
                    cout<<i<<" "<<j<<endl;
                }
            }
        }
    }
    if (n%2==1) {
        cout<<(n*(n-1))/2-n/2<<endl;
        for (ll i=1; i<n; i++) {
            for (ll j=i+1; j<=n; j++) {
                if (i+j!=n) {
                    cout<<i<<" "<<j<<endl;
                }
            }
        }
    }
}




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

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int a,b;
    string s,t,u;
    cin>>s>>t>>a>>b>>u;
    if(u==s)cout<<a-1<<' '<<b<<endl;
    else{
      cout<<a<<' '<<b-1<<endl;
    }
    return 0;
}


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

//????????¢??????????????\??£?????????????????????

int main(int argc, char *argv[]){
        int W, H, x, y, r;
        bool isOut;
        cin >> W >> H >> x >> y >> r;
        if (x - r < 0 || x + r > W 
         || y - r < 0 || y + r > H){
                cout << "No\n"; 
        } else {
                cout << "Yes\n";
        }
}

Measured memory_bytes: 3072
#include <bits/stdc++.h>
#define int long long
#define double long double
#define INF 1e18
#define MOD 1000000007
using namespace std;
signed main() {
  int N, Q;
  while (cin >> N >> Q, N+Q) {
    vector<int> dates(200, 0);
    for (int i = 0; i < N; i++) {
      int M; cin >> M;
      for (int j = 0; j < M; j++) {
        int d; cin >> d;
        dates[d]++;
      }
    }
    
    int ans = 0;
    int cnt = 0;
    for (int i = 0; i < dates.size(); i++) {
      if (dates[i] == N) {
        ans = i;
        break;
      } else {
        if (dates[i] > cnt && dates[i] >= Q) {
          ans = i;
          cnt = dates[i];
        }
      }
    }
    cout << ans << endl;
  }
}



Measured memory_bytes: 3076
#include<algorithm>
#include<iostream>
#include<string>

bool ispalindrome( const std::string &s )
{
	return std::equal( s.begin(), s.end(), s.rbegin() );
}

int main()
{
	std::string s;
	int ans = 0;

	while( std::getline( std::cin, s ) )
	{
		if( ispalindrome( s ) )
			ans++;
	}

	std::cout << ans << std::endl;

	return 0;
}

Measured memory_bytes: 1176
#include<bits/stdc++.h>
using namespace std;
#define ll long long
int main()
{
    ll i,n,k;
    cin>>n>>k;
    set<ll> a;
    for(i=0;i<n;i++)
    {
        ll x;
        cin>>x;
        a.insert(x);
    }
    bool dp[k+1];
    dp[0]=false;
    for(i=1;i<=k;i++)
    {
        bool ans=false;
        for(auto j:a)
        {
            if(j>i)break;
            if(dp[i-j]==false)
            {
                ans=true;break;
            }
        }
        dp[i]=ans;
    }
    //for(i=0;i<=k;i++)cout<<i<<" "<<dp[i]<<"\n";
    if(dp[k])cout<<"First\n";
    else cout<<"Second\n";
}


Measured memory_bytes: 384
#include<bits/stdc++.h>
#define ll long long int
#define FOR(i,a,b) for(ll i=(ll)(a);i<(ll)(b);i++)
#define REP(i,n) FOR(i,0,n)
#define REP1(i,n) FOR(i,1,n)
using namespace std;
  
int main () {
  int n, q, count;
  cin >> n;
  int s[n];
  REP(i, n) {
    cin >> s[i];
  }
  cin >> q;
  int t[q];
   REP(i, q) {
    cin >> t[i];
  }

  count = 0;
  REP(i, q) {
    REP(j, n) {
      if (s[j] == t[i]) {
        count++;
        break;
      } else if (t[i] < s[j]) {
        break;
      }
    }
  }

  cout << count << endl;
  return 0;
}

Measured memory_bytes: 3644