akhauriyash/Code-Regression huggingface dataset:
import std.stdio;
import std.conv;
import std.string;
import std.typecons;
import std.algorithm;
import std.array;
import std.range;
import std.math;
import std.regex : regex;
import std.container;
import std.bigint;


void main()
{
  int n, x;
  readf("%s %s\n", &n, &x);
  auto l = readln.chomp.split.to!(int[]);
  int d;
  auto cnt = 1;
  foreach (i; 0..n) {
    d += l[i];
    if (d <= x) {
      cnt++;
    } else {
      break;
    }
  }
  cnt.writeln;
}


Measured memory_bytes: 256
#![allow(unused_imports)]
use std::io::{stdin, stdout, Read, Write};

fn main() {
    let mut buf = [b'\n'; 11];
    let stdin = stdin();
    let mut handle = stdin.lock();
    handle.read(&mut buf).unwrap();
    buf[0] = b'2';
    buf[1] = b'0';
    buf[2] = b'1';
    buf[3] = b'8';
    stdout().write(&buf).unwrap();
}


Measured memory_bytes: 2120
A, B, K = map(int, input().split())
ans = []
for i in range(A,A+K):
    if i<=B and i not in ans:
        ans.append(i)
for i in range(B-K+1,B+1):
    if i>=A and i not in ans:
        ans.append(i)
print(*ans, sep='\n')

Measured memory_bytes: 3060
import sys
if __name__ == '__main__':
    N = int(input())
    s = input()
    t = input()
    S = []
    for i in range(N+1):
        tmp = s + t[i:]
        S.append(tmp)
    mini = 1000000
    for l in S:
        if l[-N:] == t:
            mini = min(mini,len(l))
    print(mini)

Measured memory_bytes: 3060
n,a,b = input().split()

n = int(n)
a = int(a)
b = int(b)

ans_max = min(a,b)

if (a + b) > n:
    ans_min = a + b - n 
else:
    ans_min = 0


print(ans_max, end=" ")
print(ans_min)


Measured memory_bytes: 2940
#include <stdio.h>

int main(void)
{
	int a;
	int b;
	int c;
	scanf( "%d %d %d", &a, &b, &c );

	 if(a < b && b < c){
        printf("Yes\n");
    }else{
        printf("No\n");
    }
	return 0;
}

Measured memory_bytes: 580
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		int A = 0;
		int B = 0;
		Scanner sc = new Scanner(System.in);
		A = Integer.parseInt(sc.next());
		B = Integer.parseInt(sc.next());
		if(A>=13){
			System.out.println(B);
		}
		else if(6<=A&&A<=12){
			System.out.println(B/2);
		}
		else
			System.out.println("0");
	}

}

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

int main() {
  string a,b;
  cin >> a >> b;
  for (int i=0 ; i< b.size() ; i++){
    cout << a.at(i) << b.at(i) ;
  }
  if ( a.size() > b.size()){
    cout << a.at(a.size()-1) ;
  }
  cout << endl;
}


Measured memory_bytes: 3608
import sys
sys.setrecursionlimit(10**6)
N, M = list(map(int, input().split()))
P = [set() for _ in range(N)]
for i in range(M):
    x, y = list(map(int, input().split()))
    x -= 1
    y -= 1
    P[x].add(y)

dp = [-1]*N


def lpth(n):
    if dp[n] > -1:
        return dp[n]
    l = P[n]
    # print(l)
    if l:
        s = [lpth(k) for k in l]
        # print(s)
        a = max(s)+1
    else:
        a = 0
    dp[n] = a
    return a


for i in range(N):
    dp[i] = lpth(i)
print(max(dp))
# print(dp)


Measured memory_bytes: 226516
#include<bits/stdc++.h>
using namespace std;
#define pi 3.14159265359
#define int long long
#define pii pair<int,int>
const int mod=1e9+7;

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






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


int n;
cin>>n;
int ans=(1000*(n/500));
n%=500;
ans+=5*(n/5);
n%=5;
cout<<ans<<"\n";


}




Measured memory_bytes: 256
#include <stdio.h>

int main()
{
	long long K, A, B;
	scanf("%lld %lld %lld", &K, &A, &B);
	
	if (A >= B - 2 || K <= A) printf("%lld\n", K + 1);
	else if ((K - A) % 2 == 0) printf("%lld\n", (B - A) * (K - A) / 2 + A + 1);
	else printf("%lld\n", (B - A) * (K - A + 1) / 2 + A);
	fflush(stdout);
	return 0;
}

Measured memory_bytes: 128
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#include <vector>
#include <stack>
#include <queue>
#include <map>
#include <algorithm>
using namespace std;

struct List{
	char s[20];
};
struct List now;
struct comp{
	bool operator() (const List& a, const List& b) const{
		if(strcmp(a.s,b.s)<0)	return true;
		return false;
	}
};
map <List,int,comp> MAP;
char inp[100005];
vector <int> v[1005];
int ans,vis[1005],no[1005];

void dfs(int x){
	vis[x] = 1;
	if(no[x]==0){
		ans++;
		return;
	}
	for(int i=0;i<v[x].size();i++)
		if(vis[v[x][i]]==0)
			dfs(v[x][i]);
}

int main()
{
	//freopen("in.txt","r",stdin);
	//freopen("out.txt","w",stdout);
	
	int N,n,i,j,c;
	while(~scanf(" %d",&N) && N){
		gets(inp);
		MAP.clear();
		c = 1;
		memset(no,0,sizeof(no));
		for(i=0;i<1005;i++)
			v[i].clear();
		for(n=0;n<N;n++){
			gets(inp);
			char *ptr = strtok(inp," :,.");
			sscanf(ptr," %s",now.s);
			if(MAP.find(now)==MAP.end()){
				MAP[now] = c++;
				i = c-1;
			}
			else
				i = MAP[now];
			no[i] = 1;
			while((ptr=strtok(NULL," ,.:"))!=NULL){
				sscanf(ptr," %s",now.s);
				if(MAP.find(now)==MAP.end()){
					MAP[now] = c++;
					j = c-1;
				}
				else
					j = MAP[now];
				v[i].push_back(j);
			}
		}
		ans = 0;
		memset(vis,0,sizeof(vis));
		dfs(1);
		printf("%d\n",ans);
	}
	
	return 0;
}

Measured memory_bytes: 1200
#include<iostream>
#include<cstdio>
#define _USE_MATH_DEFINES
#include<cmath>
using namespace std;
struct point{
  double x,y;
};
void koch(int n,point a,point b)
{
  if(n == 0) return ;
  point s,t,u;
  double th = M_PI *60.0/180.0;
  s.x = (2.0*a.x+1.0*b.x)/3.0;
  s.y = (2.0*a.y+1.0*b.y)/3.0;
  t.x = (1.0*a.x+2.0*b.x)/3.0;
  t.y = (1.0*a.y+2.0*b.y)/3.0;
  u.x = (t.x-s.x)*cos(th) - (t.y-s.y)*sin(th)+s.x;
  u.y = (t.x-s.x)*sin(th) + (t.y-s.y)*cos(th)+s.y;
  koch(n-1,a,s);
  printf("%.8f %.8f\n",s.x,s.y);
  koch(n-1,s,u);
  printf("%.8f %.8f\n",u.x,u.y);
  koch(n-1,u,t);
  printf("%.8f %.8f\n",t.x,t.y);
  koch(n-1,t,b);
}
int main ()
{
  point a,b;
  int n;
  scanf("%d",&n);
  a.x = 0;
  a.y = 0;
  b.x = 100;
  b.y = 0;
  printf("%.8f %.8f\n",a.x,a.y);
  koch(n,a,b);
  printf("%.8f %.8f\n",b.x,b.y);
  return 0 ;
}



Measured memory_bytes: 3112
#include <cstdio>
#include <algorithm>
#include <vector>
#include <utility>
#include <queue>
#include <functional>
#include <stack>
#include <set>
#include <map>
#include <iostream>
#include <string>
#include <cstring>
#include <ctype.h>
#include <assert.h>

#define fi first
#define se second
#define sz(x) ((int)x.size())

using namespace std;
typedef long long lli;
typedef pair<int,int> pii;
typedef pair<lli,int> pli;
typedef pair<lli,lli> pll;

int main() {
	int a,b,c,x,y;
	lli ans=1e18;

	scanf("%d%d%d%d%d",&a,&b,&c,&x,&y);
	for(int i=0;i<=max(x,y);i++) {
		ans = min(ans,2ll*i*c+1ll*max(0,(x-i))*a+1ll*max(0,(y-i))*b);
	}
	printf("%lld\n",ans);
	
}


Measured memory_bytes: 256
#include<bits/stdc++.h>                                                                                               
using namespace std;
 
#define rep(i,n) for(int i=0;i<(n);++i)
#define reps(i,n) for(int i=1;i<=(n);++i)
#define all(x) (x).begin(),(x).end()
#define int long long
#define mk_p(a,b)   make_pair((a),(b))
using pii = pair<int,int>;
constexpr int INF  = 0x3f3f3f3f;
constexpr long long LINF = 0x3f3f3f3f3f3f3f3fLL;

signed main(){
    int n;
    cin >> n;
    for(int i = n;i>0;--i){
        if((int)sqrt(i) == sqrt((double)i)){
            cout << i << '\n';
            return 0;
        }
    }   
    return 0;
}


Measured memory_bytes: 256
var log = console.log;
if (typeof process != "undefined") {
	var input = "";
	process.stdin.resume();
	process.stdin.setEncoding('utf8');
	process.stdin.on('data', function (chunk) {
		input += chunk;
	});
	process.stdin.on('end', function () {
		var lines = input.split("\n");
		main(lines);
	});
}

//-----

function main(lines) {
	//line???get
	var line = lines.shift();
	//input????????????
	var inputs = line.split(' ');
	/*
 	?????¬??¢?????´?????????
 	???????????????????????§??????????????§????????????
 	
 	??¨??¨?????????????????????2????????????????????§???????????????????????¶???????????£??????2?????????????????????????????¨???????????°??????????????????
 */
	var stack = [];
	inputs.forEach(function (e) {
		if (isnumber(e)) {
			//??°????????£???????????????????????????
			stack.push(Number(e));
		} else {
			//?????£??????2???????????????????¨????
			var a = Number(stack.pop());
			var b = Number(stack.pop());
			//?????????????????\????????£????????????????°????????????????????????????
			//eval!???????±???????!
			var res = eval("b" + e + "a");
			stack.push(res);
		}
	});
	console.log(stack.shift());
}

function isnumber(e) {
	//??°??????????????????????????????
	//js???????????????
	return Number(e).toString() != "NaN";
}

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

#define ll long long
#define vi vector<int>
#define vl vector<ll>
#define pii pair<int,int>
#define pll pair<ll,ll>
// pll pp; -> (pp.first,pp.second)
// vector<vl> pp(n,vl(2)); sort(pp.begin(),pp.end(),[](vl a,vl b){return a[0]<b[0];});

#define REP(i,n) for(ll (i)=0;(i)<(n);(i)++)
#define RREP(i,n) for(ll (i)=(n)-1;(i)>=0;(i)--)
#define FOR(i,a,b) for(ll (i)=(a);(i)<(b);(i)++)
#define FORR(i,a,b) for(ll (i)=(b)-1;(i)>=(a);(i)--)
#define DEBUG(x) cout << #x << ": " << x << endl
#define CHMAX(a,b) a=max((a),(b))
#define CHMIN(a,b) a=min((a),(b))
/*}}}*/
int main() {
  ll n;
  cin >> n;
  string s;
  cin >> s;
  ll ans = 1;
  REP(i,n-1){
    if(s[i]!=s[i+1]) ans ++;
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 512
/**
 * @author: Mackenzie
**/
#include <bits/stdc++.h>

using namespace std;

#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define sz(x) (int)(x).size()
#define F first
#define S second
#define forn(i, n) for (int i = 0; i < (int)n; i++)
#define pb push_back
#define fastIO ios::sync_with_stdio(0), cin.tie(0)
#define endl '\n'
typedef long long ll;

int main() {
#ifdef LOCAL
    // freopen("in.txt", "r", stdin);
    // freopen("out.txt", "w", stdout);
#else
    fastIO;
#endif
    ll n, x;
    cin >> n >> x;
    vector<ll> a(n);
    forn(i, n) cin >> a[i];
    ll ans = 0;
    for (int i = 1; i < n; i++) {
        ans += max(0ll, (a[i] + a[i - 1]) - x);
        a[i] = max(0ll, a[i] - max(0ll, (a[i] + a[i - 1]) - x));
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 1024
#include <iostream>
#include <cstdlib>

using namespace std;
#define N 500
#define C 100
#define CHANGE_RATE 0.7

int main()
{
    int d = 0;
    int c[26];
    int s[365][26];
    int t_c[C][365];
    int last[26] = {0};
    int score_c[C] = {0};
    int score = 0;
    int max_c = 0;

    cin >> d;

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

    for(int i = 0; i < d; i++)
    {
        for(int j = 0; j < 26; j++)
        {
            cin >> s[i][j];
        }
    }

    for(int i = 0; i < C; i++)
    {
        for(int j = 0; j < 365; j++)
        {
            t_c[i][j] = rand() % 26;
        }
    }

    for(int n = 0; n < N; n++)
    {
        score = 0;
        max_c = 0;
        for(int ca = 0; ca < C; ca++)
        {
            score_c[ca] = 0;
            for(int i = 0; i < 26; i++)
                last[i] = 0;

            for(int i = 0; i < d; i++)
            {
                for(int j = 0; j < 26; j++)
                {
                    if(t_c[ca][i] == j)
                    {
                        last[j] = 0;
                        score_c[ca] += s[i][j];
                    }
                    else
                    {
                        last[j]++;
                        score_c[ca] -= c[j] * last[j];
                    }
                }
            }
        }

        for(int ca = 0; ca < C; ca++)
        {
            if(score < score_c[ca])
            {
                score = score_c[ca];
                max_c = ca;
            }
        }

        for(int ca = 0; ca < C; ca++)
        {
            if(ca == max_c) continue;
            for(int i = 0; i < d; i++)
            {
                if((rand() / (double)RAND_MAX) < CHANGE_RATE)
                {
                    t_c[ca][i] = rand() % 26;
                }
                else
                {
                    t_c[ca][i] = t_c[max_c][i];
                }
            }
        }
    }

    for(int i = 0; i < d; i++)
    {
        cout << ((t_c[max_c][i] % 26) + 1) << endl;
    }

    return 0;
}

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

#define rep(i, a, n) for (int i = a; i < n; i++)
#define asc(v) sort(v.begin(), v.end())
#define desc(v) sort(v.begin(), v.end(), greater<int>())

using namespace std;

int main() {
  int N;
  cin >> N;
  vector<int> arr(N, 0);
  rep(i, 0, N) { cin >> arr[i]; }
  desc(arr);
  int ans = 0;
  rep(i, 0, N) {
    if (i % 2 == 0) {
      ans += arr[i];
    } else {
      ans -= arr[i];
    }
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

class Main {

	public static void main(String[] args){

		Scanner sc = new Scanner(System.in);
		int a = sc.nextInt();
		int b = sc.nextInt();
		int c = a*b;
		int d = 2*(a+b);
		System.out.println(c +" "+ d);

	}

}


Measured memory_bytes: 26160
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using p = pair<int, int>;
using V = vector<int>;
using VV = vector<vector<int>>;
using VL = vector<ll>;
using VVL = vector<vector<ll>>;
int Inf = (1<<30);
ll inf = (1LL<<60);
vector<pair<ll,ll>> divi;
void prime_fact(ll x) {
	for (ll i = 2; i * i <= x; i++) {
		if (x % i != 0) continue;
		int res = 0;
		while (x % i == 0) {
			x /= i;
			res++;
		}
		p tmp = make_pair(i, res);
		divi.push_back(tmp);
	}
	pair<ll,ll> tmp = make_pair(x, 1);
	divi.push_back(tmp);
	return;
}
int main() {
	ll n, p;
	cin >> n >> p;
	prime_fact(p);
	ll ans = 1;
	for (auto c : divi) {
		ll x = c.second / n;
		ans *= pow(c.first, x);
	}
	cout << ans;
}

Measured memory_bytes: 256
A,B,C = map(int,input().split())
S = A+B+C
if S == 17:
    S = S - max(A, B, C)
    if S == 10:
        S = S - min(A, B, C)
        if S == 5:
            print("YES")
        else:
            pass
    else:
        pass
else:
    print("NO")

Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
#define rep(i,N) for(int i=0;i<int(N);++i)
using i64 = int64_t;
using ll = long long;
int main() {
  int N;
  cin >> N;
  cout << int((N+1)/2) << endl;
  return 0;
}

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

void Main()
{
    string s;
    int q;
    cin >> s >> q;
    int r = 0;
    string sa, sb;
    for (int i = 0; i < q; i++)
    {
        int t, f;
        char c;
        cin >> t;
        if(t == 1) r++;
        else{
            cin >> f >> c;
            if(f == 1 && r % 2 == 0 || f == 2 && r % 2 == 1) sa += c;
            else sb += c;
        }
    }
    if(r % 2 == 1){
        swap(sa, sb);
        reverse(s.begin(), s.end());
    }
    reverse(sa.begin(), sa.end());

    cout << sa << s << sb << endl;
    
}

int main(int argc, char **argv)
{
    Main();
    return 0;
}


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

using namespace std;

#define forn(i,n) for (int i = 0; i < int(n); i++)
#define ford(i,n) for (int i = int(n) - 1; i >= 0; i--)
#define fore(i,l,r) for (int i = int(l); i <= int(r); i++)
#define all(a) a.begin(), a.end()
#define sz(a) int(a.size())
#define mp make_pair
#define pb push_back
#define ft first
#define sc second
#define x first
#define y second

template<typename X> inline X abs(const X& a) { return a < 0 ? -a : a; }
template<typename X> inline X sqr(const X& a) { return a * a; }

typedef long long li;
typedef long double ld;
typedef pair<int, int> pt;

const int INF = int(1e9);
const li INF64 = li(1e18);
const ld EPS = 1e-9;

li a[4];

inline bool read() {
	forn (i, 4)
		cin >> a[i];
	return true;
}
   
inline void solve() {
	forn (i, 3) {
		a[i + 1] = min(a[i + 1], a[i] * 2);
	}  
	int n;
	cin >> n;
	cout << n / 2 * a[3] + (n % 2) * a[2];
}

int main()
{
#ifdef _DEBUG
	assert(freopen("input.txt", "r", stdin));
	assert(freopen("output.txt", "w", stdout));
#endif

	cout << setprecision(25) << fixed;
	cerr << setprecision(10) << fixed;

	srand(int(time(NULL)));

	read();
	solve();

#ifdef _DEBUG
	cerr << "TIME: " << clock() << endl;
#endif

	return 0;
}

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

using namespace std;

const int n = 50;

long long k, q, a[55];

int main(){
//	freopen("input.inp", "r", stdin);
	scanf("%lld",&k);
	for(int i = 1; i <= n; ++i) a[i] = n - 1 + k / n;
	q = k % n;
	for(int i = 1; i <= q; ++i) a[i] += n - q;
	for(int i = q + 1; i <= n; ++i) a[i] -= q;
	printf("%d\n", n);
	for(int i = 1; i <= n; ++i) printf("%lld ", a[i]);
	return 0; 
}

Measured memory_bytes: 764
#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i=0; i<n; i++)
#define rep1(i, n) for(int i=1; i<=n; i++)
#define repr(i, n) for(int i=n-1; i>=0; i--)
#define repr1(i, n) for(int i=n; i>=1; i--)
#define all(v) v.begin(),v.end()
using ll = long long;
using pii = pair<int, int>;
using pil = pair<int, ll>;
using pli = pair<ll, int>;
using pll = pair<ll, ll>;
const int INF = 1e9;
const ll LLINF = 1e18;
const ll MOD = 1e9+7;
const double EPS = 1e-10;
const double PI = acos(-1);
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; }

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

    const int MAX = 1000010;

    vector<int> c(MAX, 0);
    rep(i, n) c[a[i]]++;

    bool pairwise = true;
    for (int i = 2; i < MAX; i++) {
        int cnt = 0;
        for (int j = i; j < MAX; j += i) {
            cnt += c[j];
        }
        if (cnt > 1) pairwise = false;
    }

    if (pairwise) {
        cout << "pairwise coprime" << endl;
        return 0;
    }

    int g = 0;
    rep(i, n) g = __gcd(g, a[i]);
    if (g == 1) {
        cout << "setwise coprime" << endl;
    } else {
        cout << "not coprime" << endl;
    }
}


Measured memory_bytes: 11180
#include <algorithm>
#include <map>
#include <iostream>
#include <string>
#include <set>
#include <queue>
#include <cmath>
#include <iterator>
#include <array>
typedef long long int ll;
using namespace std;
#define maxN 200005
#define mod 1000000007

int in1;
int n, m;

void solve()
{
    cin >> in1 >> n >> m;
    for (int i = n; i <= m; i++)
    {
        if (i % in1 == 0)
        {
            cout << "OK\n";
            return;
        }
    }
    cout << "NG\n";
}

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

Measured memory_bytes: 3652
# import numpy as np
# import math
# import copy
# from collections import deque
import sys
input = sys.stdin.readline
# sys.setrecursionlimit(10000)


def main():
    N = int(input())
    T = list(map(int,input().split()))
    M = int(input())
    PX = [list(map(int,input().split())) for i in range(M)]

    tot = sum(T)

    for i in range(M):
        diff = T[PX[i][0]-1] - PX[i][1]
        print(tot - diff)



main()


Measured memory_bytes: 3060
import numpy as np
import fractions

def prime_factorize(n):
    a = []
    while n % 2 == 0:
        a.append(2)
        n //= 2
    f = 3
    while f * f <= n:
        if n % f == 0:
            a.append(f)
            n //= f
        else:
            f += 2
    if n != 1:
        a.append(n)
    return a

a, b = [int(e) for e in input().strip().split()]
g = fractions.gcd(a, b)
f = prime_factorize(g)
print(len(set(f)) + 1)

Measured memory_bytes: 14308
package main

import (
	"bufio"
	"fmt"
	"io"
	"os"
	"strconv"
)

const (
	initialBufSize = 100000
	maxBufSize     = 1000000
)

var sc *bufio.Scanner

func initScanner(r io.Reader) *bufio.Scanner {
	buf := make([]byte, initialBufSize)

	sc := bufio.NewScanner(r)
	sc.Buffer(buf, maxBufSize)
	sc.Split(bufio.ScanWords) // bufio.ScanLines
	return sc
}

func main() {
	sc = initScanner(os.Stdin)
	fmt.Println(resolve(parseProblem()))
}

func parseProblem() int {
	return scanInt(sc)
}

func resolve(n int) int {
	return n * (n - 1) >> 1
}

// snip-scan-funcs
func scanInt(sc *bufio.Scanner) int {
	sc.Scan()
	i, _ := strconv.Atoi(sc.Text())
	return int(i)
}


Measured memory_bytes: 1780
fun main(args: Array<String>) {
    val (N, K) = readLine()!!.split(" ").map(String::toInt)
    val PN = readLine()!!.split(" ").map(String::toInt)

    var maxSum = 0
    var prevSum = 0
    var maxSumHead = 0
    for (i in 0..(N - K)) {
        if (i == 0) {
            maxSum = PN.slice(i until i + K).sum()
            prevSum = maxSum
        } else {
            val sum = prevSum - PN[i - 1] + PN[i + K - 1]
            prevSum = sum
            if (maxSum < sum) {
                maxSum = sum
                maxSumHead = i
            }
        }
    }
    PN.slice(maxSumHead until maxSumHead + K).map { it * (it + 1) / 2 / it.toDouble() }.sum().let(::println)
}



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

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

    ll a; cin >> a;
    ld b; cin >> b;

    ll ans = (a * b * 100) / 100;

    cout << ans << "\n";

    return 0;
}

Measured memory_bytes: 3744
#include<stdio.h>
int main(void){
  int i,N,A[21],B[21],C[20];
  int sum=0;
  scanf("%d",&N);
  for(i=0;i<N;i++){
    scanf("%d",&A[i]);
  }
  for(i=0;i<N;i++){
    scanf("%d",&B[i]);
  }
  for(i=0;i<N-1;i++){
    scanf("%d",&C[i]);
  }
  for(i=0;i<N;i++){
    if(A[i+1]==A[i]+1)
      sum=sum+B[A[i]-1]+C[A[i]-1];
    else
      sum=sum+B[A[i]-1];
  }
  printf("%d",sum);
  return 0;
}
  
  


Measured memory_bytes: 128
object Main {
  def main(args:Array[String]): Unit = {
    val sc = new java.util.Scanner(System.in)
    val W = sc.nextInt
    val H = sc.nextInt
    val x = sc.nextInt
    val y = sc.nextInt
    val r = sc.nextInt
    
    val minX = x-r
    val minY = y-r
    val maxX = x+r
    val maxY = y+r
    
    println(if(minX >= 0 && minY >= 0 && maxX <= W && maxY <= H)"Yes" else "No")
  }
}

Measured memory_bytes: 44996
#include<iostream>
#include<string>
#include<vector>
#include<queue>
#include<algorithm>
#include<map>
#include<set>
#include<cmath>
#include<iomanip>
#include<stack>
typedef long long ll;
#define rep(i,n) for(int i=0;i<(n);i++)
#define pb push_back
#define sz(a) (int)a.size()
using namespace std;

int main() {
    ll x, y;
    cin >> x >> y;
    ll n = y / x;
    int ans = 0;
  
  while(n>=2){
    ans++;
    n/=2;
  }
    cout << ans+1 << endl;
}


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

int main(){
    int ans=0,money=0;
    int a,b,c;
    cin >> a>>b>>c;

    while (money < c){
        ans++;
        if(ans%7==0){
            money += a+b;
        }else{
            money += a;
        }
    }
    //cout <<fixed<<setprecision(16)<< << endl;
    cout << ans << endl;

    //if(flag==1)cout << "Yes" <<endl;
    //else cout << "No" <<endl;
    
    return 0;
}



Measured memory_bytes: 3120
package main

import (
	"fmt"
	"math"
)

func main() {
	var a, b float64
	fmt.Scan(&a, &b)

	var x float64
	switch {
	case b < 10:
		x = a*10 + b
	case b < 100:
		x = a*100 + b
	default:
		x = a*1000 + b
	}

	if isInt(math.Sqrt(x)) {
		fmt.Println("Yes")
		return
	}
	fmt.Println("No")
}

func isInt(f float64) bool {
	var i = int(f)
	return f == float64(i)
}


Measured memory_bytes: 512
N=int(input())
ai=input().split(" ")
a=[]
for i in range(N):
  a+=[int(ai[i])]
#print(a)
want=1
bk=0
for i in range(N):
  if a[i]==want:
    want+=1
  else:
    bk+=1

if bk==N:
  print(-1)
else:
  print(bk)

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

namespace CSharpConsoleApp {

    class Program {

        static int Main() {
            var N = int.Parse(Console.ReadLine());
            var input = Console.ReadLine().Split(' ').ToList().Select(a => int.Parse(a));
            var fourMen = input.Where(a => a % 4 == 0).Count();
            var twoMen = input.Where(a => a % 4 != 0 && a % 2 == 0).Count();
            if (fourMen >= (int)(N / 2))
                Console.WriteLine("Yes");
            else if (twoMen + fourMen * 2 >= N)
                Console.WriteLine("Yes");
            else
                Console.WriteLine("No");

            //var HM = Console.ReadLine().Split(' ').ToList().Select(a => int.Parse(a)).ToArray();
            //var H = HM[0];
            //var M = HM[1];
            //var N = Console.ReadLine().Split(' ').Select(a => int.Parse(a));
            //var aArray = Console.ReadLine().Split(' ').ToList().Select(a => int.Parse(a));

            //var massL = new List<List<int>>();
            //massL.Select(list => list.Select(a => a = H * M + 1));
            //aArray.OrderBy(a => a);

            return 0;
        }
    }
}

Measured memory_bytes: 21088
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        int n = in.nextInt();
        int[] a = new int[n];
        int[] b = new int[n];
        int[] c = new int[n];
        for(int i=0; i<n; i++) {
            a[i] = in.nextInt();
            b[i] = in.nextInt();
            c[i] = in.nextInt();
        }
        int[][] dp = new int[n][3];
        dp[0][0] = a[0];
        dp[0][1] = b[0];
        dp[0][2] = c[0];
        for(int i=1; i<n; i++) {
            dp[i][0] = Math.max(dp[i-1][1], dp[i-1][2]) + a[i];
            dp[i][1] = Math.max(dp[i-1][2], dp[i-1][0]) + b[i];
            dp[i][2] = Math.max(dp[i-1][0], dp[i-1][1]) + c[i];
        }
        int max = Math.max(dp[n-1][0], dp[n-1][1]);
        max = Math.max(max, dp[n-1][2]);
        System.out.println(max);
    }
}


Measured memory_bytes: 93668
// Template
#include <iostream>
#include <string>
#include <vector>
#include <utility>
#include <functional>
#include <numeric>
#include <list>
#include <set>
#include <map>
#include <algorithm>
#include <cmath>

using namespace std;
typedef long long ll;

#define REP(i, n) for(int i = 0;i < n;i++)
#define INF 1 << 10


int n;
long long sum = 0;

int main(){
    cin >> n;
    std::vector<int> a(n+2);
    a[0] = 0; a[n+1] = 0;
    for(int i=1; i<n+1; ++i){
        cin >> a[i];
        sum += abs(a[i]-a[i-1]);
    }
    sum+=abs(a[n]);


    for(int i=1; i<n+1; ++i){
        cout << sum-(abs(a[i]-a[i-1])+abs(a[i]-a[i+1]))+abs(a[i-1]-a[i+1])<<endl;
    }




    return 0;

}


Measured memory_bytes: 1664
from collections import deque
#入力
s = input()
m = int(input())
q_list = [list(input().split()) 
          for nesya in range(m)]
d = deque(s)
n = 0
for q in q_list:
  if q[0] == '1':
    n += 1
  else:
    if (n%2 == 0 and q[1] == '1') or (n%2 == 1 and q[1] == '2'):
      d.appendleft(q[2])
    else:
      d.append(q[2])
ans = ''.join(d)
if n%2 == 0:
  print(ans)
else:
  print(ans[::-1])

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

P f(int x){
    int a =x%10;
    int b = 0;
    while(x) {
        b=x;
        x /= 10;
    }
    return P(a,b);
}

int main() {
    int N;
    cin >> N;
    map<P, int> freq;
    for(int i = 1;i <= N; i++){
        P p = f(i);
        freq[p]++;
    }
    ll ans = 0;
      for(int i = 1;i <= N; i++){
        P p = f(i);
        P q(p.second,p.first);
        ans += freq[q];
      }
      cout  << ans << endl;
    return 0;
}


Measured memory_bytes: 384
/*
 	author:: tamajit banerjee
*/

#include<iostream>
#include<vector>
#include<algorithm>
#include<bits/stdc++.h>
#include <iomanip>
using namespace std;
#define pb push_back
#define ll long long int
# define pll pair<ll,ll>
  
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int n;
    cin>>n;
    if(n>=30){
    	cout<<"Yes\n";
	}else{
		cout<<"No\n";
	}
	return 0;
}
    

Measured memory_bytes: 3688
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
const int INF = 1000000000;
int gcd(int p, int q){
  while(q != 0){
  int r = p % q;
  p = q;
  q = r;
  }
  return p;
}

int main() {
  int n;
  cin >> n;
  string s;
  cin >> s;
  int count = 0;
  rep(i,n-1){
    if(s[i]!=s[i+1]) ++count;
  }
  cout << count+1 << endl;
  return 0;
}

Measured memory_bytes: 512
import java.util.Scanner;

public class Main {
	public static void main(String[] args){
		//??????????????°
		String[][] data = new String[50][3];
		double[][] keisan = new double[50][4];

		Scanner sc = new Scanner(System.in);
		int i = 0;

		while(sc.hasNext()){

			String shin = sc.next();		//String????????°???1?????\??????

			data[i] = shin.split(",");		//????¬???????????????\??????
			i++;
		}

		//??????(double)
		for(int x = 0; x < i; x ++){
			for(int y = 1; y < 3; y ++){
				keisan[x][y] = Double.parseDouble(data[x][y]);
			}
		}

		//?¨????
		for(int z = 0; z < i; z++){
			keisan[z][2] = keisan[z][2] * keisan[z][2];
			keisan[z][3] = keisan[z][1] / keisan[z][2];
		}

		for(int a = 0; a<i; a++){
			if(keisan[a][3] >= 25){
				System.out.println(data[a][0]);
			}
		}
	}
}

Measured memory_bytes: 26112
import java.util.*;
public class Main {
	public static void main(String args[]) {
		Scanner sc = new Scanner(System.in);
		double W = sc.nextDouble();
		double H = sc.nextDouble();
		double x = sc.nextDouble();
		double y = sc.nextDouble();
		System.out.print(W * H / 2 + " ");
		if(x == W / 2 && y == H / 2) {
			System.out.println(1);
		} else {
			System.out.println(0);
		}
	}
}


Measured memory_bytes: 24660
#include<stdio.h>
#include<queue>
#include<algorithm>
using namespace std;
int bfs[2][50][50];
char str[50][51];
int dx[]={1,0,0,-1};
int dy[]={0,1,-1,0};
int main(){
	int a,b;
	while(scanf("%d%d",&a,&b),a){
		for(int i=0;i<b;i++)scanf("%s",str[i]);
		for(int i=0;i<50;i++)for(int j=0;j<50;j++)bfs[0][i][j]=bfs[1][i][j]=0;
		queue<pair<int,int> >Q;
		for(int i=0;i<b;i++){
			for(int j=0;j<a;j++){
				if(str[i][j]=='B'){
					bfs[0][i][j]=1;
					Q.push(make_pair(i,j));
				}
			}
		}
		while(Q.size()){
			int row=Q.front().first;
			int col=Q.front().second;
			Q.pop();
			for(int i=0;i<4;i++){
				if(0<=row+dx[i]&&row+dx[i]<b&&0<=col+dy[i]&&col+dy[i]<a&&str[row+dx[i]][col+dy[i]]=='.'&&!bfs[0][row+dx[i]][col+dy[i]]){
					bfs[0][row+dx[i]][col+dy[i]]=1;
					Q.push(make_pair(row+dx[i],col+dy[i]));
				}
			}
		}
		for(int i=0;i<b;i++){
			for(int j=0;j<a;j++){
				if(str[i][j]=='W'){
					bfs[1][i][j]=1;
					Q.push(make_pair(i,j));
				}
			}
		}
		while(Q.size()){
			int row=Q.front().first;
			int col=Q.front().second;
			Q.pop();
			for(int i=0;i<4;i++){
				if(0<=row+dx[i]&&row+dx[i]<b&&0<=col+dy[i]&&col+dy[i]<a&&str[row+dx[i]][col+dy[i]]=='.'&&!bfs[1][row+dx[i]][col+dy[i]]){
					bfs[1][row+dx[i]][col+dy[i]]=1;
					Q.push(make_pair(row+dx[i],col+dy[i]));
				}
			}
		}
		int B=0;
		int W=0;
		for(int i=0;i<b;i++)
			for(int j=0;j<a;j++){
				if(str[i][j]=='.'&&bfs[0][i][j]&&!bfs[1][i][j])B++;
				if(str[i][j]=='.'&&!bfs[0][i][j]&&bfs[1][i][j])W++;
			}
		printf("%d %d\n",B,W);
	}
}

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

typedef long long ll;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef pair<ll,ll> pll;
typedef vector<bool> vb;
const ll oo = 0x3f3f3f3f3f3f3f3f;
const double eps = 1e-9;
#define sz(c) ll((c).size())
#define all(c) begin(c), end(c)
#define FOR(i,a,b) for (ll i = (a); i < (b); i++)
#define FORD(i,a,b) for (ll i = (b)-1; i >= (a); i--)
#define mp make_pair
#define pb push_back
#define eb emplace_back
#define xx first
#define yy second
#define TR(X) ({ if(1) cerr << "TR: " << (#X) << " = " << (X) << endl; })

int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	
	ll n; cin >> n;
	vl x(n), y(n);
	FOR(i,0,n) cin >> x[i] >> y[i];

	vl p(n);
	iota(all(p),0);

	double res = 0;
	do {
		FOR(i,0,n-1) {
			ll a = p[i], b = p[i+1];
			res += hypot(x[a]-x[b], y[a]-y[b]);
		}
	} while (next_permutation(all(p)));

	FOR(i,1,n+1) res /= i;
	cout << fixed << setprecision(20) << res << endl;
	
}



Measured memory_bytes: 256
N, M = map(int, input().split())
K = []
A = []
for i in range(N):
    l = list(map(int, input().split()))
    K.append(l[0])
    A.append(l[1:])

ms = [0 for i in range(M)]
for a_s in A:
    for a in a_s:
        ms[a - 1] += 1
ans = 0
for m in ms:
    if m == N:
        ans += 1
print(ans)


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

using namespace std;
int N,M;
int ans = 0;
// if true, it's a pitfall
bool A[100000] = {false};
long long dp[100000] = {0};

int main(){
  cin >> N >> M;
  for(int i=0; i<M; i++){
    int a;
    cin >> a;
    a = a - 1;
    A[a] = true;
  }
  // cout << "A 0 is " << A[0] << endl;
  // cout << "A 1 is " << A[1] << endl;
  // cout << "A 2 is " << A[2] << endl;
  for(int i=0; i<N; i++){
    if(A[i]){
      dp[i] = 0;
    }else if(i == 0){
      dp[i] = 1;
    }else if(i == 1){
      dp[i] = dp[i-1] + 1;
    }else{
      dp[i] = (dp[i-1] + dp[i-2]) % 1000000007;
    }
  }
  cout << dp[N-1] << endl;
  return 0;
}


Measured memory_bytes: 1152
#include <iostream>
using namespace std;
int n, m, x, s[100];
int main() {
	while(cin >> n >> m, n + m) {
		for(int i = 0; i < m; i++) cin >> s[i];
		for(int i = 0; i < n; i++) {
			for(int j = 0; j < m; j++) cin >> x, s[j] -= x;
		}
		int f = 1;
		for(int i = 0; i < m; i++) {
			if(s[i] < 0) f = 0;
		}
		cout << (f ? "Yes" : "No") << endl;
	}
}

Measured memory_bytes: 3096
#include <iostream>
#define LIST_SIZE 100

using namespace std;

int main(){
    int n, u, k, v, adj[LIST_SIZE][LIST_SIZE] = {};

    cin >> n;
    for(int i = 0; i < n; i++){
        cin >> u >> k;
        while(k--){
            cin >> v;
            adj[u-1][v-1] = 1;
        }
    }

    for(int i = 0; i < n; i++){
        for(int j = 0; j < n; j++){
            if(j > 0){ cout << " "; }
            cout << adj[i][j];
        }
        cout << endl;
    }

    return 0;
}


Measured memory_bytes: 3156
<?php
fscanf(STDIN, "%d %d %d", $n, $m, $l);

$a = input_matrix($n, $m);
$b = input_matrix($m, $l);

$r = array();
for ($i = 0; $i < $n; $i++) {
    $r[] = array();
    for ($j = 0; $j < $l; $j++) {
        $r[$i][$j] = product($i, $j, $m, $a, $b);
    }
}

foreach ($r as $row) {
    echo join(' ', $row)."\n";
}

function product($i, $j, $m, $a, $b)
{
    $r = 0;
    for ($k = 0; $k < $m; $k++) {
        $r += $a[$i][$k] * $b[$k][$j];
    }

    return $r;
}

function input_matrix($r, $c)
{
    $format = join(' ', array_map(function () { return '%d'; }, range(1, $c)));

    $matrix = array();
    for ($i = 0; $i < $r; $i++) {
        $matrix[] = fscanf(STDIN, $format);
    }

    return $matrix;
}

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

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

#define fi first
#define se second
#define repl(i,a,b) for(ll i=(ll)(a);i<(ll)(b);i++)
#define rep(i,n) repl(i,0,n)
#define all(x) (x).begin(),(x).end()
#define dbg(x) cout<<#x"="<<x<<endl
#define mmax(x,y) (x>y?x:y)
#define mmin(x,y) (x<y?x:y)
#define maxch(x,y) x=max(x,y)
#define minch(x,y) x=min(x,y)
#define uni(x) x.erase(unique(all(x)),x.end())
#define exist(x,y) (find(all(x),y)!=x.end())
#define bcnt __builtin_popcountll

#define INF INT_MAX/3
#define mod 1000000007

vector<P> g[100010];
int sz[100010];
bool dame[100010];
vector<int> cent;

void compute_subtree_size(int v,int pre){
  sz[v]=1;
  for(P e : g[v]){
    int nv=e.fi;
    if(nv==pre||dame[nv])continue;
    compute_subtree_size(nv,v);
    sz[v]+=sz[nv];
  }
}

void search_centroid(int v,int pre,int tot){
  bool is_cent=true;
  for(P e : g[v]){
    int nv=e.fi;
    if(nv==pre||dame[nv])continue;
    search_centroid(nv,v,tot);
    if(sz[nv]>tot/2)is_cent=false;
  }
  if(tot-sz[v]>tot/2)is_cent=false;
  if(is_cent)cent.push_back(v);
}

vector<int> downs;
int ans=0;

void update(int v,int pre,int depth,int crtup,int upmx){
  for(P e : g[v]){
    int nv=e.fi;
    if(nv==pre){
      crtup+=e.se; break;
    }
  }
  if(crtup>=upmx){
    int lb=0,ub=downs.size();
    while(ub-lb>1){
      int mid=(ub+lb)/2;
      if(crtup+downs[mid]>=0)lb=mid;
      else ub=mid;
    }
    maxch(ans,depth+lb);
  }
  for(P e : g[v]){
    int nv=e.fi;
    if(dame[nv]||nv==pre)continue;
    update(nv,v,depth+1,crtup,max(crtup,upmx));
  }
}

int calcdown(int v,int pre,int depth,int crtdown,int downmn){
  maxch(downs[depth],downmn);
  for(P e : g[v]){
    int nv=e.fi;
    if(dame[nv]||nv==pre)continue;
    downs[depth]=max(downs[depth],calcdown(nv,v,depth+1,crtdown+e.se,min(crtdown+e.se,downmn)));
  }
  return downs[depth];
}

void solve_subprob(int v){ // main
  compute_subtree_size(v,-1);
  cent.clear();
  search_centroid(v,-1,sz[v]);
  int c=cent[0];
  int szv=sz[v];
  dame[c]=true;

  // devide
  for(P e : g[c]){
    int nv=e.fi;
    if(dame[nv])continue;
    solve_subprob(nv);
  }

  dame[c]=false;
  // conquer
  for(int i=0;i<2;reverse(all(g[c])),i++){
    downs.resize(szv);
    rep(j,szv)downs[j]=-INF;
    downs[0]=0;
    for(P e : g[c]){
      int nv=e.fi;
      if(dame[nv])continue;
      update(nv,c,1,0,0);
      downs[0]=max(downs[0],calcdown(nv,c,1,e.se,e.se));
    }
  }
  reverse(all(g[c]));
}

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  int N;
  cin>>N;
  vector<int> A(N);
  rep(i,N)cin>>A[i];
  rep(i,N-1){
    int a,b,c;
    cin>>a>>b>>c;
    a--;b--;
    g[a].push_back(P(b,A[a]-c));
    g[b].push_back(P(a,A[b]-c));
  }
  solve_subprob(0);
  cout<<ans+1<<endl;

  return 0;
}



Measured memory_bytes: 17748
import java.util.Scanner;

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

		String S = scan.next();

		if(S.equals("RRR")) {
			System.out.println(3);
		}else if(S.equals("RRS") || S.equals("SRR")) {
			System.out.println(2);
		}else if(S.equals("SSS")) {
			System.out.println(0);
		}else {
			System.out.println(1);
		}

	}
}

Measured memory_bytes: 26924
#include<cstdio>
#include<cmath>
#include<iostream>
#include<cstring>
#include<algorithm>
using namespace std;
int main()
{
	int n,i,a[200],t,b[200];
	memset(b,0,sizeof(b));
	scanf("%d",&n);
	for(i=1;i<=n;i++){
		t=0;
		a[i]=i;
		while (a[i]%2==0){
			a[i]/=2;
			t++;
		}
		b[i]=t;
	}
	int max=-1;
	for(i=1;i<=n;i++){
		if (max<b[i])
			max=b[i];
	}
	int ans=pow(2,max);
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
// Begin Header {{{
using namespace std;
using ll = long long;
using P = pair<ll, ll>;
using Graph = vector<vector<ll>>;
#define rep(i,n) for(ll i=0; i<n; i++)
#define loop(i, j, n) for(ll i=j; i<n; i++)
#define all(x) (x).begin(), (x).end()
constexpr int INF  = 0x3f3f3f40;
const long long mod=2e9+7;
const long double PI = acos(0);
// }}} End Header
int main() {
	ll n, d, ans=0;
	cin >> n >> d;
	rep(i,n){
		ll x, y;
		cin >> x >> y;
		if(x*x+y*y <= d*d) ans++;
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 3616
import itertools

isPrime = [True]*(10**5+1)
similar = [0]*(10**5+1)
isPrime[0] = False
isPrime[1] = False
def sieve(n):
    for i in range(2, n+1):
        if isPrime[i]:
            if isPrime[(i+1)//2]:
                similar[i] = 1
            for j in range(i*2, n+1, i):
                isPrime[j] = False

sieve(10**5)

acm = list(itertools.accumulate(similar))

Q = int(input())
for i in range(Q):
    l, r = map(int, input().split())
    ans = acm[r] - acm[l-1]
    print(ans)






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

int main() {
  int a,b;
  cin >> a >> b;

  if (a % 2==0 ||b % 2==0) {
    cout << "Even" << endl;
  }

  else{
    cout << "Odd" << endl;
  }
  
  
}


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

using namespace std;
typedef long long ll;
const int MAXN = 710;

int N, M;
int edge[MAXN][MAXN];

vector <int> neigh[MAXN];
int bp[MAXN];

bool bad;
int ntot, n1;

void gogo (int cloc, int cv)
{
    if (bp[cloc])
    {
        if (bp[cloc] != cv)
            bad = true;
        return;
    }
    bp[cloc] = cv;

    ntot++;
    if (cv == 1)
        n1++;

    for (int ne : neigh[cloc])
        gogo (ne, 3 - cv);
}

int cp[MAXN];
int np[MAXN];

int main()
{
    ios_base::sync_with_stdio(0);

    cin >> N >> M;
    for (int i = 0; i < N; i++)
        for (int j = 0; j < N; j++)
            edge[i][j] = 0;

    for (int i = 0; i < M; i++)
    {
        int x, y;
        cin >> x >> y;
        x--, y--;
        edge[x][y] = edge[y][x] = 1;
    }

    for (int i = 0; i < N; i++)
        for (int j = 0; j < N; j++)
        {
            if (i != j && !edge[i][j])
                neigh[i].push_back(j);
        }

    cp[0] = 1;
    for (int i = 1; i <= N; i++)
        cp[i] = 0;

    for (int i = 0; i < N; i++)
        bp[i] = 0;

    bad = false;
    for (int i = 0; i < N; i++)
    {
        if (!bp[i])
        {
            ntot = 0;
            n1 = 0;
            gogo (i, 1);

            for (int j = 0; j <= N; j++)
                np[j] = 0;

            for (int j = N; j >= 0; j--)
                if (cp[j])
                    np[j+n1] = np[j+ntot-n1] = 1;
            for (int j = 0; j <= N; j++)
                cp[j] = np[j];
        }
    }

    int ans = 1e9;
    for (int i = 0; i <= N; i++)
        if (cp[i])
            ans = min (ans, i * (i - 1) / 2 + ((N - i) * (N - i - 1)) / 2);

    if (bad)
        cout << "-1\n";
    else
        cout << ans << "\n";
}

Measured memory_bytes: 5120
#include <bits/stdc++.h>
using namespace std;
#define mp make_pair
#define pb push_back
#define x first
#define y second
typedef pair<int,int> pii;
typedef long long ll;
typedef unsigned long long ull;
template <typename T> void chkmax(T &x,T y){x<y?x=y:T();}
template <typename T> void chkmin(T &x,T y){x>y?x=y:T();}
template <typename T> void readint(T &x)
{
	x=0;int f=1;char c;
	for(c=getchar();!isdigit(c);c=getchar())if(c=='-')f=-1;
	for(;isdigit(c);c=getchar())x=x*10+c-'0';
	x*=f;
}
const int MOD=998244353;
inline int dmy(int x){return x>=MOD?x-MOD:x;}
inline void inc(int &x,int y){x=dmy(x+y);}
int qmi(int x,int y)
{
	int ans=1;
	for(;y;y>>=1,x=1ll*x*x%MOD)
		if(y&1)ans=1ll*ans*x%MOD;
	return ans;
}
const int MAXN=200005,MAXK=19;

int n,K,a[MAXN],l[MAXN][MAXK],r[MAXN][MAXK];
ll sl[MAXN][MAXK],sr[MAXN][MAXK];

int main()
{
	#ifdef LOCAL
	freopen("code.in","r",stdin);
//	freopen("code.out","w",stdout);
	#endif
	int Q,u,v;
	readint(n),readint(K);
	for(int i=1;i<=n;++i)readint(a[i]);
	a[0]=a[1]-K,a[n+1]=a[n]+K;
	for(int i=1;i<=n;++i)
		l[i][0]=upper_bound(a,a+n+2,a[i]-K)-a-1,
		sl[i][0]=(l[i][0]<=n?l[i][0]:0),
		r[i][0]=lower_bound(a,a+n+2,a[i]+K)-a,
		sr[i][0]=(r[i][0]<=n?r[i][0]:0);
	for(int j=0;j<MAXK;++j)r[n+1][j]=n+1;
	for(int j=1;j<MAXK;++j)
		for(int i=1;i<=n;++i)
			l[i][j]=l[l[i][j-1]][j-1],r[i][j]=r[r[i][j-1]][j-1],
			sl[i][j]=sl[i][j-1]+sl[l[i][j-1]][j-1],sr[i][j]=sr[i][j-1]+sr[r[i][j-1]][j-1];
	readint(Q);
	while(Q--)
	{
		readint(u),readint(v);
		ll su=u,sv=v;
		for(int i=u,j=MAXK-1;j>=0;--j)
			if(r[i][j]<=v)su+=sr[i][j],i=r[i][j];
		for(int i=v,j=MAXK-1;j>=0;--j)
			if(l[i][j]>=u)sv+=sl[i][j]+(1<<j),i=l[i][j];
		printf("%lld\n",sv-su+1);
	}
	return 0;
}

Measured memory_bytes: 93544
#include<bits/stdc++.h>
using namespace std;
int main()
{
    std::string s;
    cin >> s;
    int l=s.length();
    if(s[l-1]=='s')
    {
        s.append("es");
    }
    else
    {
        s.append("s");
    }
    cout << s << endl;

    return 0;
}


Measured memory_bytes: 3632
#include<bits/stdc++.h>
using namespace std;
/**
******************* Author:Bisnu sarkar ****************************
**/
#define ull            unsigned long long
#define ll             long long
#define pii            pair<int,int>
#define sit            set<int> :: iterator
#define vrit           vector<int> :: reverse iterator
#define ff             first
#define ss             second
#define endl           '\n';
#define sz(s)          (int)s.size()
#define all(s)         s.begin(),s.end()
#define IO             ios_base::sync_with_stdio(false),cin.tie(NULL);  
#define what_is(x)     cerr << #x << " is " << x << endl;
///*....Debugger....*///
#define error(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args); }
void err(istream_iterator<string> it) {cout << endl;}
template<typename T, typename... Args> void err(istream_iterator<string> it, T a, Args... args) {
  cerr << *it << " = " << a << ", ";
  err(++it, args...);
}
///*....Input....*///
template <typename T> inline void Int(T &n) {
  n = 0; int f = 1; register int ch = getchar();
  for (; !isdigit(ch); ch = getchar()) if (ch == '-') f = -1;
  for (; isdigit(ch); ch = getchar()) n = (n << 3) + (n << 1) + ch - '0';
  n = n * f;
}
 
template <typename T, typename TT> inline void Int(T &n, TT &m) { Int(n); Int(m); }
template <typename T, typename TT, typename TTT> inline void Int(T &n, TT &m, TTT &l) { Int(n, m); Int(l);}
double ind(){double x; scanf("%lf",&x);return x;}

///*....Bitmask....*///
int set_1(int n,int pos){return n = (n | (1<<pos));}
int reset_0(int n,int pos){return n= n & ~(1<<pos);}
bool check_bit(int n,int pos){return n = n & (1<<pos);}

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

///*....Constraints....*///
const int N = (int) 1e6 + 5;
const int M = (int) 1e9 + 7;
const double pi=2* acos(0.0);
const double eps=1e-9;


int main()
{
    int t=1,te=0;
    //Int(t);
    while(t--){
      int n;
      cin>>n;

      ll res=0;

      for(int i=1;i<=n;++i){
        if(i%3==0 or i%5==0)continue;
        res+= (ll)i;
      }     
      printf("%lld\n", res);

        //printf("Case %d: ",++te);
    }
    return 0;
}



Measured memory_bytes: 3764
#include<bits/stdc++.h>
#define pb push_back
#define x first
#define y second
using namespace std;
typedef long long ll;
typedef pair<double,double> PAIR;
const int N = 3e5+5;
const int INF = 0x3f3f3f3f;

ll a[4][N];
ll len[4];
ll sum[4][N];
ll ma[N];
ll mb[N];

bool cmp(ll a,ll b){
	return a>b;
}

int main() {
	int x,y;
	cin>>x>>y>>len[1]>>len[2]>>len[3];
	for(int l=1;l<=3;l++)
		for(int i=1;i<=len[l];i++)	
			cin>>a[l][i];
	for(int l=1;l<=3;l++)	sort(a[l]+1,a[l]+1+len[l],cmp);
	for(int i=1;i<=3;i++){
		for(int j=1;j<=len[i];j++){
			sum[i][j] = sum[i][j-1]+a[i][j];
		}
	}
	int cnt1 = 1;
	int cnta = 1;
	int cntc = 1;
	while(cnt1<=(x+len[3])&&cnta<=x&&cntc<=len[3]){
		if(a[1][cnta]>=a[3][cntc]){
			ma[cnt1] = ma[cnt1-1]+a[1][cnta];
			cnt1++;
			cnta++;
		}
		else {
			ma[cnt1] = ma[cnt1-1]+a[3][cntc];
			cnt1++;
			cntc++;
		}
	}
	while(cnta<=x){
		ma[cnt1] = ma[cnt1-1]+a[1][cnta];
		cnt1++;
		cnta++; 
	}
	while(cntc<=len[3]){
		ma[cnt1] = ma[cnt1-1]+a[3][cntc];
		cnt1++;
		cntc++; 
	}
	int cnt2 = 1;
	int cntb = 1;
	cntc = 1;
	while(cnt2<=(y+len[3])&&cntb<=y&&cntc<=len[3]){
		if(a[2][cntb]>=a[3][cntc]){
			mb[cnt2] = mb[cnt2-1]+a[2][cntb];
		//	cout<<mb[cnt2]<<"  "<<a[2][cntb]<<endl;
			cnt2++;
			cntb++;
		}
		else {
			mb[cnt2] = mb[cnt2-1]+a[3][cntc];
		//	cout<<mb[cnt2]<<"  "<<a[3][cntc]<<endl;
			cnt2++;
			cntc++;
		}
	}
	while(cntb<=y){
		mb[cnt2] = mb[cnt2-1]+a[2][cntb];
	//	cout<<a[2][cntb]<<endl;
		cnt2++;
		cntb++; 
	}
	while(cntc<=len[3]){
		mb[cnt2] = mb[cnt2-1]+a[3][cntc];
	//	cout<<a[3][cntc]<<endl;
		cnt2++;
		cntc++; 
	}
	int ba = max(1LL,x-len[3]);
	int bb = max(1LL,y-len[3]);
//	for(int i=ba;i<=(len[1]+len[3]);i++) cout<<ma[i]<<" ";
//	cout<<endl;
//	for(int i=1;i<=(len[2]+len[3]);i++) cout<<mb[i]<<" ";
//	cout<<endl;
	ll ans = 0;
	for(int i=ba;i<=x;i++){
		ans = max(ans,sum[1][i]+mb[x+y-i]);
	}
	for(int i=bb;i<=y;i++){
		ans = max(ans,sum[2][i]+ma[x+y-i]);
	}
	cout<<ans<<endl;
}

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

typedef long long LL;

double s(LL n)
{
	LL x = n;
	LL y = 0;
	while (x)
    {
		y += x % 10;
		x /= 10;
	}

	return (double)n / y;
}

int main()
{
	LL K;
	LL n = 1;
	LL x = 1;

	cin >> K;

	for (int i = 0; i < K; i++)
    {
		cout << n << endl;
		if (s(n + x) > s(n + x * 10))
        {
            x *= 10;
        }

		n += x;
	}

	return 0;
}


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

#define ll long long

int main() {
	int n;
	cin >> n;
	n %= 10;
	if (n == 2 || n == 4 || n == 5 || n == 7 || n == 9)cout << "hon";
	else if (n == 3)cout << "bon";
	else cout << "pon";
	return 0;
}

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

int main(){
  int H,N,S=0;
  cin >> H >>N;
  for (int i=0; i<N; i++){
    int a;
    cin >> a;
    S+=a;
  }
  if (H>S){
    cout << "No" << endl;
  }
  else{
    cout << "Yes" << endl;
  }
}

Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>

int main()
{
	int a, b, c, d;
	scanf("%d %d %d %d", &a, &b, &c, &d);
	if (abs(a - c) <= d || (abs(a - b) <= d && abs(b - c) <= d)) printf("Yes\n");
	else printf("No\n");
	fflush(stdout);
	return 0;
}

Measured memory_bytes: 1656