akhauriyash/Code-Regression huggingface dataset:
using System;

namespace AtCoderProblems
{
    class MainClass
    {
        public static void Main(string[] args)
        {
            int x;
            x = int.Parse(Console.ReadLine());　//標準入力
            if(x == 0)
            {
                Console.WriteLine(1);
            }
            else
            {
                Console.WriteLine(0);
            }
        }
    }
}


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

int main() {
    string S;
    cin >> S;
    if(S[3]==S[2] && S[4]==S[5]){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }
    return 0;
}

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

int main()
{
	char temp;
	int r,c;
	cin>>r>>c;
	long long int grid[r][c]={},dp[r][c]={};
	dp[0][0]=1;
	
	for(int i=0;i<r;i++)
	{
		for(int j=0;j<c;j++)
		{
			cin>>temp;
			grid[i][j]=((temp=='.')?1:0);
			if(!i&&j)dp[0][j]=grid[0][j]&dp[0][j-1];
			else if(i&&!j)dp[i][0]=grid[i][0]&dp[i-1][0];	
		}
	}
	
	for(int i=1;i<r;i++)
	{
		for(int j=1;j<c;j++)
		{
			dp[i][j]=((grid[i][j])?dp[i-1][j]+dp[i][j-1]:0)%1000000007;
		}
	}
	
	/*for(int i=0;i<r;i++)
	{
		for(int j=0;j<c;j++)
			cout<<dp[i][j]<<" ";
		cout<<endl;
	}*/
	cout<<dp[r-1][c-1]<<"\n";
	return 0;
}


Measured memory_bytes: 19256
/*
 ID: swagchicken1
 PROG:
 LANG: C++11
 */

#include <iostream>
#include <tuple>
#include <cmath>
#include <string>
#include <cstring>
#include <vector>
#include <deque>
#include <queue>
#include <stack>
#include <map>
#include <unordered_map>
#include <set>
#include <algorithm>
#include <vector>
#include <fstream>
#include <iomanip>
#include <ctime>
#include <cctype>
using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef vector< vector <int> > vvi;
typedef pair<int, int> pii;
typedef pair < pair < int, int >, int > piii;
typedef pair < pair <int, int > , pair <int, int> > piiii;

#define FOR(i,a,b) for(int i = a; i < b; i ++)
#define RFOR(i,a,b) for(int i = a-1; i >= b; i --)

//#define endl '\n';

#define mp make_pair
#define pb push_back
#define f first
#define s second

const int MOD = 1000000007;
double PI = 4*atan(1);


int main() {
    ios_base::sync_with_stdio(0);cin.tie(0);
    //     ofstream fout("trapped.out");
    //      ifstream fin("trapped.in");
    int N,M; cin >> N >> M;
    pair <ll ,ll> A[100005] = {};

    
    FOR(i,0,N) {
        cin >> A[i].f >> A[i].s;
    }
    sort(A,A+N);
    ll numdrinks = M;
    ll cost = 0;
    FOR(i,0,N) {
        if(A[i].s >= numdrinks) {
            
            cost += A[i].f*numdrinks;
            numdrinks = 0;
        }
        else {
            cost += A[i].f*A[i].s;
            numdrinks -= A[i].s;
        }
    }
    cout << cost << endl;
    
    //  fin.close();
    //    fout.close();
}


Measured memory_bytes: 1792
import java.util.*;

public class Main {

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

		int k = sc.nextInt();
		String s = sc.next();
		
		if (s.length() > k) {
			s = s.substring(0, k) + "...";
		}
		
		System.out.println(s);
		
	}

}


Measured memory_bytes: 38580
#include <iostream>
#include <cstdio>
#include <cmath>
#include <algorithm>
using namespace std;

int main()
{
	while (true) {
		int r, n;
		cin >> r >> n;

		if (r == 0 && n == 0) {
			break;
		}

		bool grid[21][41];
		for (int i = 0; i < 21; i++) {
			for (int j = 0; j < 41; j++) {
				grid[i][j] = false;
			}
		}

		for (int i = 0; i < n; i++) {
			int lx, rx, y;
			cin >> lx >> rx >> y;

			for (int j = 0; j < y; j++) {
				for (int k = lx + 20; k < rx + 20; k++) {
					grid[j][k] = true;
				}
			}
		}

		double ans = 10000000;

		for (int y = 0; y < 21; y++) {
			for (int x = -r + 20; x < r + 20; x++) {
				if (grid[y][x] == false) {
					double temp;
					if (x < 20) {
						temp = (double)r - sqrt((double)r * r - abs(x - 19)*abs(x - 19)) + y;
					}
					else {
						temp = (double)r - sqrt((double)r * r - abs(x - 20)*abs(x - 20)) + y;
					}
					ans = min(ans, temp);
				}
			}
		}

		printf("%.4f\n", ans);
	}

	return 0;
}

Measured memory_bytes: 3128
#include <iostream>
#include <stdio.h>
using namespace std;
int main() {
  double x[4],y[4];
  double x1,y1,x2,y2,x3,y3;
  int i;
  while(scanf("%lf,%lf,%lf,%lf,%lf,%lf,%lf,%lf",&x[0],&y[0],&x[1],&y[1],&x[2],&y[2],&x[3],&y[3])!=EOF) {
	  for (i=0;i<4;i++) {
		  x1=x[(i+2) % 4]-x[i]; y1=y[(i+2) % 4]-y[i];
		  x2=x[(i+2) % 4]-x[(i+3) % 4]; y2=y[(i+2) % 4]-y[(i+3) % 4];
          x3=x[(i+2) % 4]-x[(i+1) % 4]; y3=y[(i+2) % 4]-y[(i+1) % 4];
		  if ((x1*x2+y1*y2+x1*x3+y1*y3)<=0) { i=10; break; }
	  }
	  if (i<10) cout << "YES" << endl; else cout << "NO" << endl;
  }
  return 0;
  }

Measured memory_bytes: 1224
#include<bits/stdc++.h>
using namespace std;
int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	int n; cin >> n;
	vector<long long> a(3*n);
	for(int i = 0; i < 3*n; i++)
		cin >> a[i];
	sort(a.begin(), a.end());
	long long ans = 0;
	for(int i = 0; i < n; i++){
		ans += a[3*n-2*(i+1)];
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 2560
#define _CRT_SECURE_NO_DEPRECATE
#pragma GCC optimize("O3")
#pragma GCC target("sse4")
#include<bits/stdc++.h>
//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
//using namespace __gnu_pbds;
#define int long long int
#define SYNC std::ios_base::sync_with_stdio(0);cin.tie(NULL);cout.tie(NULL);
#define FRE freopen("input.txt","r",stdin);freopen("output.txt","w",stdout);
typedef long double ld;
typedef pair<int,int> ii;
typedef pair<int,ii> iii;
typedef vector<int> vi;
typedef vector<ii>   vii;
//typedef tree<int, null_type, less<int>, rb_tree_tag, 
//             tree_order_statistics_node_update> 
//    ost;
#define rep(i,l,r)   for (int i = (l); i < (r); i++)
#define here cout << " Hey!!\n";
#define  pb push_back
#define  F  first
#define  S  second
#define all(v) (v).begin(),(v).end()
#define sz(a) (int)((a).size())
#define sq(x) ((x)*(x))
template <typename T>
void etch(T V) {
	for (auto x : V)	cout << x << ' ' ;
	cout << '\n';
}
vector<string> vec_splitter(string s) {
	s += ',';
	vector<string> res;
	while(!s.empty()) {
		res.push_back(s.substr(0, s.find(',')));
		s = s.substr(s.find(',') + 1);
	}
	return res;
}
void debug_out(
vector<string> __attribute__ ((unused)) args,
__attribute__ ((unused)) int idx, 
__attribute__ ((unused)) int LINE_NUM) { cerr << endl; } 
template <typename Head, typename... Tail>
void debug_out(vector<string> args, int idx, int LINE_NUM, Head H, Tail... T) {
	if(idx > 0) cerr << ", "; else cerr << "Line(" << LINE_NUM << ") ";
	stringstream ss; ss << H;
	cerr << args[idx] << " = " << ss.str();
	debug_out(args, idx + 1, LINE_NUM, T...);
}
#ifndef ONLINE_JUDGE
#define debug(...) debug_out(vec_splitter(#__VA_ARGS__), 0, __LINE__, __VA_ARGS__)
#else
#define debug(...) 42
#endif
const int MOD = 1e9+7;
const int MOD1 = 998244353;
const int N = 2e5+5;
const int INF = 1000111000111000111LL;
const ld EPS = 1e-12;
const ld PI = 3.141592653589793116;

struct pt {
	int ki;
	int profit;
};
bool comp(pt &a, pt &b) {
	return a.ki < b.ki;
}

int solve() 
{
	int n;	cin >> n;	
	int ans = 0;
	vector<pt> vf, vb;
	for (int i = 0; i < n; i++) {
		int k, l, r;
		cin >> k >> l >> r;
		if (l >= r) {
			pt tmp;
			tmp.profit = l - r;
			tmp.ki = k;
			vf.pb(tmp);
		} else {
			pt tmp;
			tmp.profit = r - l;
			tmp.ki = n - k;
			vb.pb(tmp);
		}
		ans += min(l, r);
	}
	sort(all(vb), comp);
	sort(all(vf), comp);
	multiset<int> st;
	for (auto it : vf) {
		if (sz(st) < it.ki) {
			st.insert(it.profit);
			continue;
		}
		if (*st.begin() >= it.profit) {
			continue;
		}
		auto nt = st.begin();
		st.erase(nt);
		st.insert(it.profit);
	}
	for (auto it : st) ans += it;
	st.clear();
	for (auto it : vb) {
		if (sz(st) < it.ki) {
			st.insert(it.profit);
			continue;
		}
		if (st.empty()) {
			continue;
		}
		if (*st.begin() >= it.profit) {
			continue;
		}
		auto nt = st.begin();
		st.erase(nt);
		st.insert(it.profit);
	}
	for (auto it : st) ans += it;
	cout << ans << '\n';
	return 0;
}

int32_t main()
{
	SYNC
	int T; cin >> T;
	while(T--) {
		solve();
	}
	return 0;
}


Measured memory_bytes: 11172
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
const int mod = 1e9+7;

int main(){
    int n;
    cin >> n;
    int math[2][n];
    for(int i = 0; i < 2; i++){
        for(int j = 0; j < n; j++){
            cin >> math[i][j];
        }
    }    
    int ans = 0;
    for(int i = 0; i < n; i++){
        int can = 0;
        for(int j = 0; j <= i; j++){
            can += math[0][j];
        }
        for(int j = i; j < n; j++){
            can += math[1][j];
        }
        if(ans < can) ans = can;
    }
    cout << ans << endl;
}

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

int main() {
	string str;
	getline(cin,str);
	for(unsigned int i=0;i<str.size();++i) {
		if(str[i]>='a' && str[i]<='z') {
			str[i]+='A'-'a';
		} else if(str[i]>='A' && str[i]<='Z') {
			str[i]+='a'-'A';
		}
	}
	cout << str << endl;
	return 0;
}

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

using namespace std;

#define rep(i,n) for(int i=0;i<(n);i++)
#define repa(i,a,n) for(int i=(a);i<(n);i++)
#define rrep(i,n) for(int i=n;i>=0;i--)
#define rrepa(i,a,n) for(int i=n;i>=(a);i--)
#define all(a) (a).begin(),(a).end()
#define MOD 1000000007
#define cmax(a,b) a=max(a,b)
#define cmin(a,b) a=min(a,b)
#define vc vector

typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef pair<int,int> pi;

int main(){

    int n;
    cin>>n;
    vi a(n);
    rep(i,n-1){
        int tmp;
        cin>>tmp;
        a[tmp-1]++;
    }

    rep(i,n){
        cout<<a[i]<<"\n";
    }

    return 0;
}

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

using ll = long long;

constexpr ll MOD = 1e9+7;
constexpr ll INF = 1ll<<60;

#define FOR(i,a,b) for (ll i=(a);i<(ll)(b);++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) (v).begin(),(v).end()

ll N;
vector<ll> res[3];

int main(int argc, char **argv)
{
	cin >> N;
	ll tmp{1};
	ll k;
	for (ll i = 2;;++i)
	{
		if (tmp >= N)
		{
			k = i;
			break;
		}
		tmp += i;
		
	}

	if (tmp != N)
	{
		std::cout << "No" << std::endl;
		return 0;
	}

	std::cout << "Yes" << std::endl;
	std::cout << k << std::endl;
	vector<vector<ll>> res(k, vector<ll>());
	ll tm{1};
	REP(i, k)
	{
		for (ll j = i+1; j < k; ++j)
		{
			res[i].push_back(tm);
			res[j].push_back(tm);
			++tm;
		}
	}

	REP(i, k)
	{
		std::cout << res[i].size() << " ";
		for (auto &e : res[i])
			std::cout << e << " ";
		std::cout << std::endl;
	}
}


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

int main()
{
  int a,b,sum=0;
  cin >> a >> b;
  for (int i = 0; i < 2; ++i)
  {
    if (a < b)
    {
      sum += b--;
    }
    else
    {
      sum += a--;
    }
  }
  cout << sum << endl;

  return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
int main(){
  int n,x,y,h,w,s,s1,s2,a,i;
  int m[]={600,800,1000,1200,1400,1600,0};
  while(1){
    scanf("%d",&n);
    if(n==0)break;
    a=0;
    for(i=0;i<n;i++){
      scanf("%d %d %d %d",&x,&y,&h,&w);
      if     (x+y+h>160)s1=6;
      else if(x+y+h>140)s1=5;
      else if(x+y+h>120)s1=4;
      else if(x+y+h>100)s1=3;
      else if(x+y+h> 80)s1=2;
      else if(x+y+h> 60)s1=1;
      else              s1=0;
      if     (w>25)s2=6;
      else if(w>20)s2=5;
      else if(w>15)s2=4;
      else if(w>10)s2=3;
      else if(w>5 )s2=2;
      else if(w>2 )s2=1;
      else         s2=0;
      if(s1>s2)s=s1;
      else     s=s2;
      a+=m[s];
    }
    printf("%d\n",a);
  }
  return 0;
}

Measured memory_bytes: 600
#include <bits/stdc++.h>
using namespace std;
/**** Type Define ****/
 
typedef long long ll;

int main(){
    string S;
    cin>>S;

    int ans=0;
    for (size_t i = 0; i < 6; i++)
    {
      if(S[i]=='1'){ans++;} 
    }
    
 cout<<ans<<endl;
 return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<iostream>
#include<string>
#include<math.h>
#include<cmath>
#include<algorithm>
#include<map>
#include<queue>
#include<stack>
#include<vector>
#include<time.h>
#include<ctime>
#include<functional>
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
ll inf = (1 << 29);
template<typename T>
T GCD(T a, T b) {
	while (max(a, b) % min(a, b)) {
		if (a > b)a = a % b;
		else b = b % a;
	}
	return min(a, b);
}
template<typename T>
T LCM(T a, T b) {
	return a / GCD(a, b)*b;
}
bool prime(ll a) {
	for (int i = 2; i <= sqrt(a); i++) {
		if (!(a%i))return false;
	}
	return true;
}
int main() {
	string s;
	ll k;
	cin >> s >> k;
	int one = 0;
	for (int i = 0; i < s.size(); i++) {
		if (s[i] == '1')one++;
		else break;
	}
	if (one >= k)cout << 1 << endl;
	else if(one)cout << s[one] << endl;
	else cout << s[0] << endl;
	return 0;
}


Measured memory_bytes: 256
#pragma GCC optimize("Ofast") 
#include<bits/stdc++.h>
//#include<bits/extc++.h>
using namespace std;
//using namespace __gnu_pbds;
//typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update> set_t;
#define mp(a,b) make_pair((a),(b))
#define pii pair<int,int>
#define pll pair<LL,LL>
#define pdd pair<double,double>
#define pb push_back
#define x first
#define y second
#define sqr(x) ((x)*(x))
#define EPS 1e-6
#define MEM(x) memset(x,0,sizeof(x))
#define MEMS(x) memset(x,-1,sizeof(x))
#define pi acos(-1)
#define index Index
#define Line pll
typedef long long LL;
double dp[305][305][305];
int n;
double DP(int a,int b,int c){
    if(dp[a][b][c]>=0){
        return dp[a][b][c];
    }
    dp[a][b][c]=0;
    if(a!=0)
    dp[a][b][c]+=(DP(a-1,b+1,c)+1)*a/n;
    if(b!=0)
    dp[a][b][c]+=(DP(a,b-1,c+1)+1)*b/n;
    if(c!=0)
    dp[a][b][c]+=(DP(a,b,c-1)+1)*c/n;
  //  printf("%d %d %d %lf\n",a,b,c,dp[a][b][c]);
    dp[a][b][c]=(dp[a][b][c]+(double)(n-a-b-c)/n)*n/(a+b+c);
   // printf("%d %d %d %lf\n",a,b,c,dp[a][b][c]);
    return dp[a][b][c];
}
int main(){
    scanf("%d",&n);
    int a[4]={0,0,0,0};
    for(int i=1;i<=n;i++){
        int x;
        scanf("%d",&x);
        a[x]++;
    }
    MEMS(dp);
    dp[0][0][0]=0;
    printf("%.12f\n",DP(a[3],a[2],a[1]));;
}


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

int main() {
  vector<int> v(3);
  for (int i = 0; i < 3; i++) {
    cin >> v[i];
  }
  sort(v.begin(), v.end());
  int d = v[2] - v[1] + v[2] - v[0];
  if (v[0] % 2 == v[1] % 2 && v[1] % 2 == v[2] % 2) {
    cout << d / 2 << endl;
  } else if (v[0] % 2 == v[1] % 2) {
    cout << d / 2 << endl;
  } else {
    cout << d / 2 + 2 << endl;
  }
}


Measured memory_bytes: 3176
#include <iostream>
#include <vector>
#include <algorithm>
#include <cstring>

using namespace std;

int n;
vector<int> a, ra;

long long INF = 1ll << 60;
long long dp[3001][3001];

long long dfs(int left, int right) {
	if (left + right == n) return 0;
	bool check = (left + right) % 2;
	if (dp[left][right] != -INF) return dp[left][right];
	if (check) {
		return dp[left][right] = min(dfs(left + 1, right) - a[left], dfs(left, right + 1) - ra[right]);
	}
	else {
		return dp[left][right] = max(dfs(left + 1, right) + a[left], dfs(left, right + 1) + ra[right]);
	}
}

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	cin >> n;
	a.resize(n);
	for (auto&& i : a) {
		cin >> i;
	}
	ra.resize(n);
	for (int i = 0; i < n; i++) {
		ra[i] = a[n - i - 1];
	}
	fill(dp[0], dp[3001], -INF);
	cout << dfs(0, 0) << "\n";
}

Measured memory_bytes: 70784
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower

using namespace std;



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

	cout << (n + 1) / 2 << endl;
}

Measured memory_bytes: 3588
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
#define Rep(i,a,b) for(int i=a;i<b;i++)
#define REP(i,a,b) for(int i=a;i<=b;i++)
#define rev(i,n) for(int i=n-1;i>=0;i--)
#define vi vector<int>
#define vvi vector<vi>
#define pb push_back
#define pi pair<int,int>
#define vp vector<pair<int,int>>
#define mp make_pair
#define all(v) (v).begin(),(v).end()
#define fi first
#define se second
#define MEMSET(a) memset(a,0,sizeof(a))
#define inf (1ll<<60)
#define Yes(f) cout<<(f?"Yes":"No")<<endl
#define yes(f) cout<<(f?"yes":"no")<<endl
#define YES(f) cout<<(f?"YES":"NO")<<endl
#define SORT(v) sort(all(v))
#define RSORT(v) sort(all(v), greater<int>())
#define VI(a,n) vi a(n); rep(i,n)cin>>a[i]
#define sq(n) (n)*(n)

using namespace std;

const int mod=1e9+7;

void run();

void init() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout<<fixed<<setprecision(12);
}

signed main(){
    init();
    run();
    return 0;
}

vi g[100010];
int h[100010];

void run(){
    int n,m;
    cin>>n>>m;
    m+=n-1;
    rep(i,m){
        int a,b;
        cin>>a>>b;
        a--,b--;
        g[a].pb(b);
        h[b]++;
    }
    stack<int> st;
    rep(i,n){
        if(h[i]==0){
            st.push(i);
            break;
        }
    }
    vi ans(n+1,-1);
    while(!st.empty()){
        int u=st.top();
        st.pop();
        for(int v:g[u]){
            h[v]--;
            if(h[v]==0){
                st.push(v);
                ans[v]=u;
            }
        }
    }
    rep(i,n){
        cout<<ans[i]+1<<endl;
    }
}

Measured memory_bytes: 7936
N,K = map(int, input().split())
H = list(map(int, input().split()))
steps = [0]*N
steps[1] = abs(H[0]-H[1])
for i in range(2,N):
    steps[i] = min([steps[j] + abs(H[j]-H[i]) for j in range(max(0,i-K),i)])
print(steps[-1])

Measured memory_bytes: 20388
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <iomanip>
using namespace std;
typedef long long unsigned int ll;

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)   FOR(i,0,n)

#define DEBUG

#ifdef DEBUG
#define var_dump(...) fprintf(stdout, __VA_ARGS__)
#define dump(a) cout << a << "\n";
#else
#define var_dump(...) 42
#define dump(a) 42
#endif

// https://beta.atcoder.jp/contests/abc070/tasks/abc070_b

int main() {
    int A, B, C, D;
    cin >> A >> B >> C >> D;

    int cnt = 0;
    REP(i, 101) {
        if (i > A && i <= B) {
            if (i > C && i <= D) {
                cnt++;
            }
        }
    }

    cout << cnt << "\n";

    return 0;
}


Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main(void){
    
    long long N, i, j, subnum = 0;
    
    cin >> N;
    
    for(i=0; subnum<N; i++){
        subnum += i;
    }
    
    int n = subnum-N;
    
    i -= 1;
    
    for(j=1; j<=i; j++){
        if(j == n){ continue; }
        cout << j << endl;
    }
    
    return 0;
}


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

using namespace std;

#define int long long
#define INF 1e9
#define LINF 1e18

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

typedef pair<P, P> PP;

const int MOD = 1e9 + 7;
const int dy[] = { 0, 0, 1, -1 };
const int dx[] = { 1, -1, 0, 0 };

template <class T> void chmin(T& a, const T& b) { a = min(a, b); }
template <class T> void chmax(T& a, const T& b) { a = max(a, b); }

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

    int H, R;
    cin >> H >> R;
    if(H < 0 && -1 * H > R) cout << -1;
    else if(H < 0 && -1 * H == R) cout << 0;
    else cout << 1;
    cout << "\n";
	return 0;
}



Measured memory_bytes: 3212
package main

import (
	"fmt"
)

func main() {
	var S string
	var weather = [4]string{"Sunny", "Cloudy", "Rainy", "Sunny"}

	fmt.Scanln(&S)

	for i := 0; i < len(weather)-1; i++ {
		if S == weather[i] {
			fmt.Println(weather[i+1])
		}
	}
}


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

using namespace std;
int main() {
    int N;
    vector<vector<int>> data(3, vector<int>(3));
    for (int i = 0; i < 3; i++){
        for(int j = 0; j < 3; j++){
            cin >> data.at(i).at(j);
        }
    }
    //ビンゴの穴開ける数字を取得
    cin >> N;
    vector<int> nums(N);
    for (int i = 0; i < N; i++){
        cin >> nums.at(i);
    }

    for(int i = 0; i < N; i++){
        for(int j = 0; j < 3; j++){
            for (int k = 0; k < 3; k++){
                //番号一致したら-1にする(穴が空いた)
                if(data.at(j).at(k) == nums.at(i)) {
                    // cout << "yes" << endl;
                    data.at(j).at(k) = -1;
                }
            }
        }
    }
    int flag = 0;
    //たて方向にビンゴ
    for(int i = 0; i < 3; i++){
        int bingo = 0;
        for(int j = 0; j < 3; j++){
            bingo += data.at(i).at(j);
        }
        if(bingo == -3) {
            flag = 1;
            break;
        }
    }
    //横方向にビンゴ
    for(int i = 0; i < 3; i++){
        int bingo  = 0;
        for(int j = 0; j < 3; j++){
            bingo += data.at(j).at(i);
        }
        if(bingo == -3) {
            flag = 1;
            break;
        }
    }
    //斜め方向にビンゴ
    int bingo = data.at(0).at(0) + data.at(1).at(1) + data.at(2).at(2);
    if (bingo == -3 ){
        flag = 1;
    } 
    int bingo2 = data.at(2).at(0) + data.at(1).at(1) + data.at(0).at(2);
    if (bingo2 == -3 ){
        flag = 1;
    } 

    // for(int i = 0; i < 3; i++){
    //     for(int j = 0; j < 3; j++){
    //         cout << data[i][j] << " ";
    //     }
    //     cout << endl;
    // }
    if(flag == 1){
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
    return 0;
}

Measured memory_bytes: 256
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
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;}
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define all(vec) vec.begin(),vec.end()
typedef long long ll;
typedef pair<ll,ll> l_l;
typedef pair<int,int> i_i;
const ll mod=1e9+7;
const int inf=1<<30;

struct unionfind{
  vector<int> par;
  vector<int> rank;
  unionfind(int n=1){
    init(n);
  }
  void init(int n=1){
      par.resize(n); rank.resize(n);
      for(int i=0;i<n;++i) par[i]=i,rank[i]=0;
  }
  int root(int x){
    if(par[x]==x){
      return x;
    }
    else{
      int r=root(par[x]);
      return par[x]=r;
    }
  }
  bool issame(int x,int y){
    return root(x)==root(y);
  }
  bool merge(int x,int y){
    x=root(x); y=root(y);
    if(x==y) return false;
    if(rank[x]<rank[y]) swap(x,y);
    if(rank[x]==rank[y]) ++rank[x];
    par[y]=x;
    return true;
  }
};

int main(){
  int N,M;
  cin >> N >> M;
  unionfind uf(N);
  vector<int> p(N);
  rep(i,N) cin >> p[i];
  rep(i,N) p[i]--;
  rep(i,M){
    int x,y;
    cin >> x >> y;
    x--; y--;
    uf.merge(x,y);
  }
  int ans=0;
  rep(i,N){
    if(uf.root(i)==uf.root(p[i])) ans++;
  }
  cout << ans << endl;
  
}

Measured memory_bytes: 1408
import sys
input = sys.stdin.readline

def main():
    n = int(input())
    a = list(map(int, input().split()))
    s = [0]*(n+1)

    for i in range(n):
        s[i+1] += s[i] + a[i]
    
    ans = int(1e15)
    for i in range(n):
        sub = []
        for l, r, ll, rr in zip([0, i], [i, n], [0, i], [i, n]):
            while r-l > 1:
                k = (r+l) // 2
                if s[k] - s[ll] < s[rr] - s[k]:
                    l = k
                else:
                    r = k

            if abs(s[ll] + s[rr] - s[l]*2) > abs(s[ll] + s[rr] - s[r]*2):
                k = r
            else:
                k = l
            sub.append(s[k] - s[ll])
            sub.append(s[rr] - s[k])
        judge = max(sub) - min(sub)
        ans = min(ans, judge)
    
    print(ans)


    
if __name__ == "__main__":
    main()



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

int main(){
    int N;
    
    cin >> N;
    vector<int> L(N);

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

    sort(L.begin(), L.end());
    int lmax = L[N-1];
    int lsum = 0;

    for(int i=0; i<N-1; i++){
       lsum += L[i]; 
    } 
    if(lmax < lsum){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }
    return 0;
}


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


int main(){
  int a, b;
  cin >> a >> b;
  
  if (a <= b*2) cout << 0 << endl;
  if (a > 2*b) cout << a- 2*b << endl;
  

  }

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define int long long
using namespace std;
#define deb(x) cout<<#x<<" = "<<x<<"\n";
 
signed main()
{
	
	int n; cin>>n;
	
	for(int i=1; i<=9; i++)
	{
		for(int j=1; j<=9; j++)
		{
			if(i*j == n)
			{
				cout<<"Yes\n"; return 0;
			}
		}
	}
	cout<<"No\n"; return 0;
	
}

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

public class Main {

    void run() {
        Scanner sc = new Scanner(System.in);
        long n = sc.nextLong();
        long ans = 0;
        if (n == 1) {
            System.out.println(0);
            return;
        }
        for (long i = 1; i * i <= n; i++) {
            if ((n - i) % i == 0) {
                long x = ((n - i) / i);
                if (n / x == n % x) ans += x;
            }
        }

        System.out.println(ans);
    }

    void debug(Object...os) {
        System.err.println(Arrays.deepToString(os));
    }

    public static void main(String[] args) {
        new Main().run();
    }
}


Measured memory_bytes: 22612
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define fi first
#define se second
#define pb push_back
#define eb emplace_back
#define sz(x) (int)(x).size()
using namespace std;
using ll = long long;
using P = pair<int, int>;
using vi = vector<int>;
using vc = vector<char>;
using vb = vector<bool>;
using vs = vector<string>;
using vll = vector<long long>;
using vp = vector<pair<int, int>>;
using vvi = vector<vector<int>>;
using vvc = vector<vector<char>>;
using vvll = vector<vector<long long>>;
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 (b<a) {a=b; return 1;} return 0;}

ll get(vll& b) {
    ll sm = 0;
    rep(i, sz(b) - 1) {
        sm += abs(b[i+1] - b[i]);
    }
    return sm;
}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    
    int n;
    cin >> n;
    vll a(n);
    rep(i, n) cin >> a[i];
    sort(a.begin(), a.end());
    ll ans = -1;
    vll b(n);
    if (n % 2 == 0) {
        //　大小......大小
        rep(i, n/2) b[2*i + 1] = a[i];
        rep(i, n/2) b[2*i] = a[i+n/2];
        ans = get(b);
    } else {
        // 大小......小大
        rep(i, n/2) b[2*i + 1] = a[i];
        b[n-1] = a[n/2];
        rep(i, n/2) b[2*i] = a[n/2+1+i];
        chmax(ans, get(b));
        // 小大......大小
        rep(i, n/2) b[2*(i+1)] = a[i];
        b[0] = a[n/2];
        rep(i, n/2) b[2*i + 1] = a[n/2+1+i];
        chmax(ans, get(b));
    }
    cout << ans << endl;
}

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

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP0(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define REP1(i,n) for(int i=1, i##_len=(n); i<=i##_len; ++i)
#define RREP0(i,n) for(int i=n-1; i>=0; --i)
#define RREP1(i,n) for(int i=n; i>=1; --i)
#define SORT(c) sort((c).begin(),(c).end())
#define REVERSE(c) reverse((c).begin(),(c).end())
#define FILL(c, v) fill((c).begin(),(c).end(), v)
#define SZ(a) int((a).size())
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define CLR(a) memset((a), 0 ,sizeof(a))

inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}

typedef long long LL;

const int INTINF = 2147483647;
const LL LLINF = 9223372036854775807;
int gcd(int a,int b){return b?gcd(b,a%b):a;}

void solve() {
  int N, tmp; cin >> N;
  vector<int> d; d.reserve(N+1);
  REP0(i, N) { cin >> tmp; d.push_back(tmp); }
  SORT(d);
  cout << d[N/2] - d[N/2-1] << endl;
}

int main(int argc, char const *argv[])
{
  cin.tie(0);
  ios::sync_with_stdio(false);
  solve();
  return 0;
}

Measured memory_bytes: 640
s=list(input())
n=len(s)
ans=0
for i in range(1,n):
  if s[i] == s[i-1]:
    if s[i] == "0":
      s[i] = "1"
    elif s[i] == "1":
      s[i] = "0"
    ans+=1
print(ans)

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

int main(){
  int h,n;
  cin >> h >> n;
  vector<int> a(n);
  rep(i,n){cin >> a[i];}
  
  int attack = 0;
  rep(i,n){attack += a[i];}
  
  if(h<=attack){
    cout << "Yes" << endl;
  }else{
    cout << "No" << endl;
  }
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
#define rep(i,N) for(int i=0,i##_max=(N);i<i##_max;++i)
#define repp(i,l,r) for(int i=(l),i##_max=(r);i<i##_max;++i)
#define per(i,N) for(int i=(N)-1;i>=0;--i)
#define perr(i,l,r) for(int i=r-1,i##_min(l);i>=i##_min;--i)
#define all(arr) (arr).begin(), (arr).end()
#define SP << " " <<
#define SPF << " "
#define SPEEDUP cin.tie(0);ios::sync_with_stdio(false);
#define MAX_I INT_MAX //1e9
#define MIN_I INT_MIN //-1e9
#define MAX_UI UINT_MAX //1e9
#define MAX_LL LLONG_MAX //1e18
#define MIN_LL LLONG_MIN //-1e18
#define MAX_ULL ULLONG_MAX //1e19
  typedef long long ll;
  typedef pair<int,int> PII;
  typedef pair<char,char> PCC;
  typedef pair<ll,ll> PLL;
  typedef pair<char,int> PCI;
  typedef pair<int,char> PIC;
  typedef pair<ll,int> PLI;
  typedef pair<int,ll> PIL; 
  typedef pair<ll,char> PLC; 
  typedef pair<char,ll> PCL; 

inline void YesNo(bool b){ cout << (b?"Yes" : "No") << endl;}
inline void YESNO(bool b){ cout << (b?"YES" : "NO") << endl;}
inline void Yay(bool b){ cout << (b?"Yay!" : ":(") << endl;}

int main(void){
  SPEEDUP
  cout << setprecision(15);
  int N;cin >> N;
  int M = 26;
  vector<int> count(M,50);
  rep(i,N){
    string s;cin >> s;
    sort(all(s));
    rep(i,M){
      char x = 'a'+i;
      int num = upper_bound(all(s),x) - lower_bound(all(s),x);
      count[i] = min(count[i],num);
    }
  }
  rep(i,M){
    rep(j,count[i]) cout << (char)('a'+i);
  }
  cout << endl;
  return 0;
}


Measured memory_bytes: 256
import java.io.BufferedOutputStream;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.StringTokenizer;

class Main {
    private void solve() {
        int n = in.nextInt();
        int[] array = new int[n];
        for (int i = 0; i < n; ++i) {
            array[i] = in.nextInt();
        }
        long minCost = Long.MAX_VALUE;
        for (int j = -200; j < 200; ++j) {
            long curCost = 0;
            for (int i = 0; i < n; ++i) {
                curCost += (array[i] - j) * (array[i] - j);
            }
            if (minCost > curCost)
                minCost = curCost;
        }
        out.println(minCost);
    }

    private class FastScanner {
        BufferedReader br;
        StringTokenizer st;

        FastScanner() {
            br = new BufferedReader(new InputStreamReader(System.in));
            st = new StringTokenizer("");
        }

        String next() {
            while (!st.hasMoreTokens()) {
                try {
                    st = new StringTokenizer(br.readLine());
                }
                catch (IOException e) {
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }

        int nextInt() {
            return Integer.parseInt(next());
        }

        long nextLong() {
            return Long.parseLong(next());
        }
        double nextDouble() {
            return Double.parseDouble(next());
        }

        String nextLine() {
            String str = "";
            try {
                str = br.readLine();
            } catch (IOException e) {
                e.printStackTrace();
            }
            return str;
        }
    }

    private FastScanner in;
    private PrintWriter out;


    private void run() {
        try {
            in = new FastScanner();
            out = new PrintWriter(new BufferedOutputStream(System.out));
            solve();
        } catch (Exception e) {
            throw e;
        } finally {
            out.close();
        }
    }


    public static void main(String[] arg) {
        new Main().run();
    }
}




Measured memory_bytes: 8148
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace __gnu_pbds;
using namespace std;


#define fast ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define PSET(x,y) fixed<<setprecision(y)<<x
#define pb push_back
#define pii pair<int,int>
#define pf push_front
#define mp make_pair
#define vi vector<int>
#define vip vector<pair<int,int> >
#define ff first
#define ss second
#define int long long
#define mod 1000000007
#define BIG 998244353
#define s(t) scanf("%lld",&t)
#define p(t) printf("%lld\n",t)
#define mii map<int,int>
#define MSET(table,i) memset(table, i, sizeof(table))
#define endl '\n'
#define tc int t;cin>>t;while(t--)
#define pi  3.1415926358
#define bits(x) __builtin_popcount(x)
#define minimum(a,n) min_element(a,a+n)-a
#define maximum(a,n) max_element(a,a+n)-a
#define pqbig priority_queue<pii>
#define pqsmall priority_queue<int,vector<int>,greater<int> >
#define all(v) v.begin(),v.end()
#define sitr set<int>:: iterator
#define spitr set<pii>:: iterator
#define mitr map<int,int>:: iterator

int toint(const string &s) {stringstream ss; ss << s; int x; ss >> x; return x;}
string tostring ( int number ) {stringstream ss; ss << number; return ss.str();}


typedef tree<int, null_type, less<int>, rb_tree_tag,
        tree_order_statistics_node_update>
        new_data_set;


#define trace1(x)                cerr<<#x<<": "<<x<<endl
#define trace2(x, y)             cerr<<#x<<": "<<x<<" | "<<#y<<": "<<y<<endl
#define trace3(x, y, z)          cerr<<#x<<":" <<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<endl
#define trace4(a, b, c, d)       cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<endl
#define trace5(a, b, c, d, e)    cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<endl
#define trace6(a, b, c, d, e, f) cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<" | "<<#f<<": "<<f<<endl

const int N=2e5+5;
int dp[N][10],arr[N];
int n;

int solve(int id,int left,int kitne)
{
	//trace3(id,left,kitne);
	if(kitne==0)
		return 0;

	if(dp[id][left]!=-1)
		return dp[id][left];

	int ans=-1e18;

	if(left)
		ans=max(ans,solve(id+1,left-1,kitne));

	int cur=arr[id];
	for(int i=id+2;i<=id+2+left;i++)
		ans=max(ans,cur+solve(i,left-(i-(id+2)),kitne-1));
	return dp[id][left]=ans;
}

int32_t main() 
{
    fast;
    cin>>n;
    for(int i=1;i<=n;i++)
    	cin>>arr[i];
    MSET(dp,-1);

    if(n%2==0)
   		cout<<solve(1,1,n/2);
    else
    	cout<<solve(1,2,n/2);
}

Measured memory_bytes: 28648
#include<bits/stdc++.h>
using namespace std;
#define ll long long 
ll mod =1000000007;
/*"itob" int to "N"base */           template<typename TypeInt> string itob(const TypeInt v, int base){static const char table[] = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ";string ret;static numeric_limits<TypeInt> t;TypeInt n = v;if (t.is_signed) {if (v < 0) n *= -1;}while (n >= base) {ret += table[n%base];n /= base;}ret += table[n];if (t.is_signed) {if (v < 0 && base == 10) ret += '-';}reverse(ret.begin(), ret.end());return ret;}
/*"chmin" a = MAX*/                  template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
/*"chmax" a = MIN*/                  template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
/*"ctoi"  char to int*/              int ctoi(char c) {return c-'0';}
/*"gcd"   MAX*/                      int gcd(ll a,ll b){return b?gcd(b,a%b):a;}
/*"lcm"   MIN*/                      int lcm(ll a,ll b){return a*b/gcd(a,b);}
/*"primecheck"If prime,return true.*/bool primecheck(ll n){if(n < 2) return false;else{for(int i = 2; i * i <= n; i++){if(n % i == 0) return false;}return true;}}
string  reverserange(string s,ll a,ll b){reverse(s.begin()+a-1,s.begin()+b); return s;}
int main(){
int n,k;
cin >> n >> k;
ll a[n];
for(int i=0;i<n;i++){
   cin >> a[i];
}
sort(a,a+n);
ll ans = 10e17;
for(int i=0;i<n;i++){
   if(i+k-1==n)break;
   ans = min(ans,a[i+k-1]-a[i]);
}
cout << ans << endl;
}





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

int main() {
	
	int e = 0, t = 0, d = 0, all = 0;
	
	while (1) {
		int i, j, k;
		cin >> i >> j >> k;
		if (i < j && k < j) {
			int temp = i;
			i = j;
			j = temp;
		}
		else if (i <k && j < k) {
			int temp = i;
			i = k;
			k = temp;
		}
		
		if (j + k <= i) break;
		int ii = i * i, jj = j * j, kk = k*k;
		if (ii == jj + kk) t++;
		else if (ii < jj + kk) e++;
		else d++;
		all++;
	}
	
	cout << all << " " << t << " " << e << " " << d << "\n";
	
	return 0;
}


Measured memory_bytes: 3096
#include <iostream>

using namespace std;

int main()
{
    int n;
    cin >> n;
    int cnt = 0;
    if(n <= 9){
        cnt += n;
    }else if(n <= 99){
        cnt += 9;
    }else if(n <= 999 ){
        cnt += 9;
        cnt += (n-99);
    }else if(n <= 9999 ){
        cnt += 9;
        cnt += 900;
    }else if(n <= 99999 ){
        cnt += 9;
        cnt += 900;
        cnt += (n-9999);
    }else if(n == 100000){
        cnt += 9;
        cnt += 900;
        cnt += 90000;
    }
    cout << cnt << endl; 
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <ios> 
#include <vector>
#include <string>
#include <algorithm>
#include <functional>
#include <queue>
#include <stack>
#include <set>
#include <cmath>
#include <bitset>
#include <map>
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define rep1(i,n) for(int i=1;i<=(int)(n);i++)
#define sz(c) ((int)(c).size())

using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
const int MAX=1e5+5;



int main(){
	int N,Q;
	cin>>N>>Q;
	string S;
	cin>>S;
//	[0,i]にあるACをp[i]で
//  [0,i]を取っ払ったときに減るACをq[i]で
	int p[MAX],q[MAX];
	p[0]=0;
	rep1(i,N-1){
		p[i]=p[i-1];
		if(S[i-1]=='A'&&S[i]=='C')p[i]++;
	}
	q[0]=0;
	if(S[0]=='A'&&S[1]=='C')q[0]++;
	rep1(i,N-2){
		q[i]=q[i-1];
		if(S[i]=='A'&&S[i+1]=='C')q[i]++;
	}
	q[N-1]=q[N-2];
	
//  	rep(i,N)cout<<p[i]<<" ";
//  	cout<<endl;
//  	rep(i,N)cout<<q[i]<<" ";
//  	cout<<endl;
	rep(i,Q){
		int l,r;
		cin>>l>>r;
      	l--;r--;
		if(l>=1)cout<<p[r]-q[l-1]<<endl;
      	else cout<<p[r]<<endl;
	}
}

Measured memory_bytes: 1792
#include <iostream>
#include <iomanip>
#include <vector>
#include <algorithm>
using namespace std;

int main() {
    int n, k;
    cin >> n >> k;
    vector<int> p(n);
    for (int i = 0; i < n; i++) {
        cin >> p[i];
    }
    // Find a window of size k with the largest sum
    int sum = 0;
    for (int i = 0; i < k; i++) {
        sum += p[i];
    }
    int maxSum = sum;
    for (int i = k; i < n; i++) {
        sum -= p[i - k];
        sum += p[i];
        maxSum = max(maxSum, sum);
    }
    double ans = (maxSum + k) / 2.0;
    cout << setprecision(12) << fixed << ans << "\n";
}

Measured memory_bytes: 1024
import std.stdio, std.algorithm, std.conv, std.array, std.string, std.math, std.typecons, std.numeric;

void main()
{
    auto N = readln.chomp.to!int;
    auto S = readln.chomp;
    auto es = new int[](N);
    auto ws = new int[](N);
    foreach (i; 0..N) {
        if (i > 0) ws[i] += ws[i-1];
        if (S[i] == 'W') ws[i] += 1;
    }
    foreach_reverse (i; 0..N) {
        if (i < N-1) es[i] += es[i+1];
        if (S[i] == 'E') es[i] += 1;
    }

    int r = N;
    foreach (i; 0..N) {
        int rr;
        if (i > 0) rr += ws[i-1];
        if (i < N-1) rr += es[i+1];
        r = min(r, rr);
    }
    writeln(r);
}

Measured memory_bytes: 4476
#include <stdio.h>

int main()
{
    int N, T, c, t, cost = 10000;
    scanf("%d%d", &N, &T);

    for (int i = 0; i < N; i++)
    {
        scanf("%d%d", &c, &t);
        if (t <= T && c < cost) cost = c;
    }
    if (cost < 10000) printf("%d", cost);
    else puts("TLE");
}


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

int gcd(int x, int y){
  if(y == 0){
    return x;
  }
  return gcd(y, x%y);
}

int main(){
	int a, b, k;
  int g;
  int result;
  int cnt = 0;

  cin >> a >> b >> k;

  g = gcd(a, b);

  int i = g;
  int flag = 0;
  while(1){
    if(g % i == 0){
      cnt++;
      if(cnt == k){
        flag = 1;
        break;
      }
    }
    if(flag == 1){
      break;
    }
    i--;
  }

  cout << i << endl;

}


Measured memory_bytes: 256
// #define _CRT_SECURE_NO_WARNINGS
// #define _USE_MATH_DEFINES	// M_PI=3.1415...
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <stack>
#include <cmath>
#include <cstdlib>
#include <functional>
#include <locale>
#include <cctype>
#include <sstream>
#include <iomanip>	// 20桁出力 cout << setprecision(20) << double;
#include <queue>
#include <bitset>	// bitset<8> bs1(131uL); // 10000011 bs1[0]は1 01stringからビット集合生成可
using namespace std;

typedef long long LL;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<LL> VL;
typedef map<int, int> MAPII;
typedef multimap<int, char, greater<int> > MuMAPIC;
typedef vector<pair<int, int> > VPII;
typedef multimap<int, string, greater<int> > MuMIS;
typedef pair<int, int> P;
typedef pair<int, pair<P, P> > PP;

#define INF 999999999999999997;
#define MP make_pair
#define FAST_IO  cin.tie(0); ios::sync_with_stdio(false);
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define FORL(i,a,b) for(LL i=(a);i<(b);i++)
#define FOR_REV(i,a,b) for(int i=(a);i>=(b);i--)
//for gcc (未test)
// #define FOREACH_IT(it,c) for(typeof(c)::iterator it=(c).begin(); it!=(c).end(); ++it)
//for Visual Studio
#define foreach_it(type,it,c) for(type::iterator it=c.begin(),c_end=c.end();it!=c_end;++it)
#define FOR_ITR(d) for(auto itr=d.begin(),d_end=d.end();itr!=d_end;++itr)	// C++11
// for Debug.
#define DUMP_VVI(b) FOR(i,0,b.size()){FOR(j,0,b[i].size())printf("%d ",b[i][j]);puts("");}
#define D_OUT(str,value) if(dbgF){cout<<str<<" : "<<value<<endl;}
// 入力をpush_back(d)やarray[d]に使う時に1行で書ける
// int INPUT_INT() {int d;cin>>d;return d;}
template<class T>T IN() { T d; cin >> d; return d; }
// 最大公約数（Greatest Common Divisor）
LL gcd(LL a, LL b) { return (b > 0) ? gcd(b, a%b) : a; }
// 最小公倍数（Least Common Multiple）
LL lcm(LL a, LL b) { return a / gcd(a, b) * b; }
// Y年はうるう年か否か
bool uruu(LL Y) { return (((Y % 4 == 0 && Y % 100 != 0) || Y % 400 == 0) ? true : false); }

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

// vector注意
// vec[i][j]の形に入力を入れるとき、vecは初期化してある必要がある.

// ------------------- include, typedef, define END. -------------------

int main() {
	FAST_IO;
	// for D_OUT(str, value)  ... cout<< str <<" : "<< value <<endl;
	bool dbgF = true;

	//コードはここから書く.
	LL N, K;
	LL ans = 0;
	cin >> N >> K;
	FOR(i, 0, N) {
		LL x = IN<LL>();
		ans += min(x - 0, K - x) * 2;
	}
	cout << ans << endl;

	return 0;
}


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

char vow[] = {'a', 'e', 'i', 'o', 'u'};

int main(){
  char c; cin >> c;
  bool ans = false;
  for(int i = 0; i < 5; i++){
    if(c == vow[i]) ans = true;
  }
  cout << (ans?"vowel":"consonant") << endl;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
#define FI first.first
#define SE first.second
#define TH second
#define fi first
#define se second
#define th second

using namespace std;

void debug_out() { cerr << endl; }
 
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
  cerr << " " << to_string(H);
  debug_out(T...);
}
 
#ifdef DEBUG
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#else
#define debug(...) 42
#endif

class DebugStream {}LOG;
template <typename T>DebugStream &operator<<(DebugStream &s, const T&) { return s; }
#ifdef DEBUG
#define LOG clog
#endif

typedef long long ll;
typedef pair<ll, ll> ii;
typedef long double ld;
mt19937 rnd(chrono::steady_clock::now().time_since_epoch().count());

const int maxN = 1e5 + 9, maxV = 1e6 + 9, MOD = 1e9 + 7, SQ = 335, lg = 20, bs = 29;

ll fastPow(ll a, ll b, ll p) {
	ll ret = 1;
 	while(b) {
		if(b & 1) ret = ret * a % p;
		b >>= 1, a = a * a % p;
	}
	return ret;
}

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	#ifdef DEBUG
	freopen("input.txt", "r", stdin);
	#endif

	int n, p;
	string str;
	cin >> n >> p >> str;
	if(p == 2 || p == 5) {
		ll ans = 0;
		for(int i = 0; i < n; i++)
			if((str[i] - '0') % p == 0) ans += i + 1;
		cout << ans << '\n'; exit(0);
	}

	int inv = fastPow(10, p - 2, p), pot = 1, zer = 0;
	vector<int> cnd(p);
	ll ans = 0;
	for(auto el: str) {
		el -= '0';
		cnd[zer]++;
		int tomv = pot * int(el) % p;
		zer = (p + zer - tomv) % p;
		ans += cnd[zer];
		pot = pot * inv % p;
	}
	cout << ans << '\n';
}



Measured memory_bytes: 720