akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
#define rep(i,n)for(int i=0;i<n;++i)
#include<string>
#include<vector>
using namespace std;
typedef long long ll;
typedef pair<int, int>P;
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; }
//max=({});
//条件式が真ならwhileの中身を回し続ける
//printf("%d\n", ans);

//pairの入力
//vector<pair<ll, ll>>work(n);
//rep(i, n) {
//	ll a, b;
//	cin >> a >> b;
//	work[i] = make_pair(a, b);
//for(auto p:mp)(mapの探索)
//printf("%.10f\n",なんちゃら)

int g[15][15];
const int INF = 1001001001;
const int dx[4] = { -1,0,1,0 };
const int dy[4] = { 0,-1,0,1 };

//最大公約数
ll gcd(ll x, ll y) {
	return y ? gcd(y, x % y) : x;
}

ll lcm(ll x, ll y) {
	if (x == 0 || y == 0)return 0;
	return (x / gcd(x, y) * y);
}

//素因数分解
vector<pair<ll, int>>factorize(ll n) {
	vector<pair<ll, int>>res;
	for (ll i = 2;i * i <= n;++i) {
		if (n % i)continue;
		res.emplace_back(i, 0);
		while (n % i == 0) {
			n /= i;
			res.back().second++;
		}
	}
	if (n != 1)res.emplace_back(n, 1);
	return res;
}

int bingo[3][3];
bool flag[3][3];
int cnt[2][105];
int h, w;
int choco[1010][1010];
int s[11][11];

int main() {
	int n, k;
	cin >> n >> k;
	int target = 1;
	rep(i, n) {
		if (target >= k)target += k;
		else target *= 2;
	}
	cout << target << endl;
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using P = pair<ll, ll>;
const int INF = 1e9 + 10;
const int MAX_N = 300;
#define print(x) cout << (x) << endl;
#define rep(i,m,n) for(ll i = (m); i < (n); i++)

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n, m, l;
    cin >> n >> m >> l;
    int d[MAX_N][MAX_N];
    for (int i = 0; i < n; i++) {
        for (int j = 0; j < n; j++) {
            if (i == j) {
                d[i][i] = 0;
            }
            else {
                d[i][j] = INF;
            }
        }
    }
    for (int i = 0; i < m; i++) {
        int from, to, cost;
        cin >> from >> to >> cost;
        from--;
        to--;
        d[from][to] = cost;
        d[to][from] = cost;
    }
    for (int i = 0; i < n; i++) {
        for (int j = 0; j < n; j++) {
            for (int k = 0; k < n; k++) {
                d[j][k] = min(d[j][k], d[j][i] + d[i][k]);
            }
        }
    }
    int dbool[MAX_N][MAX_N];
    for (int i = 0; i < n; i++) dbool[i][i] = 0;
    for (int i = 0; i < n; i++) {
        for (int j = 0; j < n; j++) {
            if (d[i][j] <= l) {
                dbool[i][j] = 1;
            }
            else {
                dbool[i][j] = INF;
            }
        }
    }
    for (int i = 0; i < n; i++) {
        for (int j = 0; j < n; j++) {
            for (int k = 0; k < n; k++) {
                dbool[j][k] = min(dbool[j][k], dbool[j][i] + dbool[i][k]);
            }
        }
    }
    int q;
    cin >> q;
    vector<int> ans(q);
    for (int i = 0; i < q; i++) {
        int s, t;
        cin >> s >> t;
        s--;
        t--;
        if (dbool[s][t] < INF) {
            ans.at(i) = dbool[s][t] - 1;
        }
        else {
            ans.at(i) = -1;
        }
    }
    for (int i = 0; i < q; i++) {
        cout << ans.at(i) << endl;
    }
}

Measured memory_bytes: 1664
#include <iostream>
#include <vector>
#include <algorithm> // sort
#include <map>       // pair
#include <string>
#include<stdio.h>
using namespace std;

int main(int argc, const char *argv[])
{
    int N,M;
    cin>>N>>M;
    vector<pair<long long ,long long> > pairs(N);

    for (int i = 0; i < N; i++)
    {
       cin>>pairs[i].first >> pairs[i].second;
    }

    // firstが小さい順、secondが小さい順にソート
    sort(pairs.begin(), pairs.end());

    // for (int i = 0; i < N; i++)
    // {
    //     printf("(%d,%d) ", pairs[i].first, pairs[i].second);
    // }

    long long money = 0;;

    for(int i = 0; i < N ; i ++)
    {
        if(M - pairs[i].second > 0)
        {
            money +=pairs[i].first * pairs[i].second;
            M = M - pairs[i].second;
        }
        else
        {
            money += pairs[i].first * M;
            cout << money;
            return 0;
        }
        
    }
  

    return 0;
}

Measured memory_bytes: 1792
#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 fi first
#define se second
#define mp make_pair
#define pb push_back
 
typedef long long ll;
typedef pair<int,int> ii;
typedef vector<int> vi;
typedef unsigned long long ull;
typedef long double ld; 
typedef tree<ii, null_type, less<ii>, rb_tree_tag, tree_order_statistics_node_update> pbds;

int main()
{
	ios_base::sync_with_stdio(0); cin.tie(0);
	int n; cin>>n;
	string s; cin>>s;
	if(n>=3200) cout<<s<<'\n';
	else cout<<"red"<<'\n';
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define mod 1000000007
#define mod998 998244353
#define sp ' '
#define intmax 2147483647
#define llmax 9223372036854775807
#define mkp make_pair
typedef long long ll;
using namespace std;

int N;
double x[100000], y[100000];
char d[100000];

double f(double t) {
	double XMIN = 10000000000;
	double XMAX = -10000000000;
	double YMIN = 10000000000;
	double YMAX = -10000000000;
	for (int i = 0; i < N; ++i) {
		if (d[i] == 'U') {
			XMAX = max(XMAX, x[i]);
			XMIN = min(XMIN, x[i]);
			YMIN = min(YMIN, y[i] + t);
			YMAX = max(YMAX, y[i] + t);
		}
		if (d[i] == 'D') {
			XMAX = max(XMAX, x[i]);
			XMIN = min(XMIN, x[i]);
			YMIN = min(YMIN, y[i] - t);
			YMAX = max(YMAX, y[i] - t);
		}
		if (d[i] == 'R') {
			XMAX = max(XMAX, x[i] + t);
			XMIN = min(XMIN, x[i] + t);
			YMIN = min(YMIN, y[i]);
			YMAX = max(YMAX, y[i]);
		}
		if(d[i]=='L'){
			XMAX = max(XMAX, x[i] - t);
			XMIN = min(XMIN, x[i] - t);
			YMIN = min(YMIN, y[i]);
			YMAX = max(YMAX, y[i]);
		}
	}
	return (XMAX - XMIN)*(YMAX - YMIN);
}

int main() {
	cin >> N;
	for (int i = 0; i < N; ++i) {
		cin >> x[i] >> y[i] >> d[i];
	}
	double LL, L, R, RR;
	LL = 0;
	RR = 10000000000;
	for (int i = 0; i < 1000; ++i) {
		L = (LL * 2 + RR) / 3;
		R = (LL + RR * 2) / 3;
		if (f(L) < f(R)) {
			RR = R;
		}
		else {
			LL = L;
		}
	}
	printf("%.11f\n", f(LL));
}

Measured memory_bytes: 1920
#include<stdio.h>
int main()
{
	int N;
	int X;
	scanf("%d",&N);
	X= N/2;
	if(N%2==0)
	{
		printf("%d",X);
	}
	else if(N%2!=0)
	{
		printf("%d",++X);
	}
	

	
	return 0;
}

Measured memory_bytes: 1696
#include <bits/stdc++.h>
#include <unordered_map>
#include <unordered_set>
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
 
/*** Template Begins ***/
 
typedef unsigned long long    ll;
typedef pair<ll,ll>  pll;
typedef pair<ll, pair<int, int> > plll;
typedef vector<long long>  vll;
typedef vector<pll>  vp;
typedef long double ld;
#define pb           push_back
#define INF          INT_MAX/10
#define F            first
#define S            second
#define mp           make_pair
// #define ios          ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define hell         1000000007
// #define h 998244353
#define all(a)       (a).begin(),(a).end()
ll power(ll x, ll y, ll p)
{
  ll res = 1;
  x = x % p;
  while (y > 0)
  { 
    if (y & 1) 
      res = (res*x) % p;
    y = y>>1;
    x = (x*x) % p;
  } 
  return res; 
} 
const int MAXN = 2e5+5;

// Debug //
#define trace(x)                 cerr << #x << ": " << x << endl;
#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, n,i;b, c, d, e, f) cerr << #a << ": " << a << " | " << #b << ": " << b << " | " << #c << ": " << c << " | " << #d << ": " << d << " | " << #e << ": " << e << " | " << #f << ": " << f << endl;
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;
template <typename T>
using ordered_set = tree<T, null_type, less_equal<T>, rb_tree_tag, tree_order_statistics_node_update>;

// Constants //
 
/*** Template Ends ***/


void solve()
{
  ll k,n;
  cin>>n>>k;
  ll sum=0,num,i;
  std::vector<ll> v(n);
  for(i=0;i<n;i++)
  {
    // cin>>num;
    // sum+=num;
    cin>>v[i];
  }
  if(k>=n)
    cout<<0;
  else
  {
    sort(all(v));
    for(i=0;i<n-k;i++)
      sum+=v[i];
    cout<<sum;
  }
}
int main()
{ 
  // ios;
  // fxreopen("inputt.txt", "w", stdout);
  ll t;
  // cin >> t;
  t=1;
  while(t--)
    solve();
  return 0;
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
// Welcome to my source code!

int main() {
    ll n, time;
    cin >> n >> time;
    ll t, cur = 0, ans = 0;
    for (int i = 0; i < n; i++) {
        cin >> t;
        if (t < cur) ans += time - (cur - t);
        else ans += time;
        cur = t + time;
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <string>
#include <vector>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <iomanip>
#include <functional> // std::function<void(int)>
using namespace std;
#define int long long
#define All(v) (v).begin(),(v).end()
int dy[4] = {-1,0,1,0};
int dx[4] = {0,1,0,-1};
int Dy[8] = {-1,-1,0,1,1,1,0,-1};
int Dx[8] = {0,1,1,1,0,-1,-1,-1};
const int mod = 1000000007;
const int inf = mod*mod;
const int d5 = 100100;
signed main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n,m;
    unordered_map<int,int> d,t;
    cin>>n;
    for(int i=0;i<n;i++){
        int a;
        cin>>a;
        d[a]++;
    }
    cin>>m;
    for(int i=0;i<m;i++){
        int a;
        cin>>a;
        t[a]++;
    }
    bool can=true;
    for(auto it:t){
        if(d[it.first]<it.second)can=false;
    }
    if(can)cout<<"YES"<<endl;
    else cout<<"NO"<<endl;
}

Measured memory_bytes: 16712
#include <bits/stdc++.h>
using namespace std;
int main() {
    #ifdef DEBUG
    std::ifstream in("/home/share/inputf.in");
    std::cin.rdbuf(in.rdbuf());
    #endif
    int N, L;
    cin >> N >> L;
    vector<string> S(N);
    for(int i = 0; i < N; i++) {
        cin >> S[i];
    }
    sort(S.begin(), S.end());
    for(int i = 0; i < N; i++) {
        cout << S[i];
    }
    cout << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <vector>
#include <algorithm>
#include <cstring>
#include <map>
#include <queue>
#include <cmath>
#include <complex> // complex<double> a(1.2 , 2.3);// real(): 1.2, imag()2.3
using namespace std;

#define MOD 1000000007
#define ll long long
#define ld long double
#define FOR(i,a,b) for(ll i=(ll)a;i<(ll)b;i++)
#define rep(i,n) FOR(i,0,n)
#define pb push_back
#define mp make_pair
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define rmsame(a) sort(all(a)),a.erase(unique(all(a)), a.end())
#define rmvector(a,b) rep(i,a.size())rep(j,b.size())if(a[i]==b[j]){a.erase(a.begin()+i);i--;break;}
template<typename X> bool exist(vector<X> vec, X item){return find(all(vec), item)!=vec.end();}

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

  ll N ; cin >> N;
  vector<string> a;
  rep(i,N){
    string inp; cin >> inp;
    a.pb(inp);
  }

  rmsame(a);

  if(a.size()==4) cout << "Four"<< endl;
  else cout << "Three" << endl;
  //cout << fixed << setprecision(16) << ans << endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int n, m, p = 1000000007;
long long a, b, x;
int main() {
	scanf("%d%d", &n, &m);
	for (int i = 0; i < n; i++) {
		scanf("%lld", &x);
		a += x * (2 * i + 1 - n);
	}
	for (int i = 0; i < m; i++) {
		scanf("%lld", &x);
		b += x * (2 * i + 1 - m);
	}
	a %= p;
	b %= p;
	printf("%lld\n", a * b % p);
	return 0;
}

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

int d[100003];
bool che[100003];
vector<pair<int, int> > g[100003];
int ans=1e9;
void dij(int k)
{
	d[0]=0;
	priority_queue<pair<int, int> > pq;
	for (int i=1; i<k; i++) d[i]=1e9;
	pq.push(make_pair(-d[0], 0));
	while(!pq.empty())
	{
		pair<int , int> p = pq.top(), v; pq.pop();
		if (-p.first != d[p.second]) continue;
		for (int i=0; i< g[p.second].size(); i++)
		{
			v= g[p.second][i];
			if (v.first==0) ans= min(ans, d[p.second]+ v.second);
			if (d[v.first] > d[p.second]+ v.second)
			{
				d[v.first] = d[p.second]+ v.second;
				pq.push(make_pair(-d[v.first], v.first));
			}
		}
	}
}

int main()
{
	int k ; cin>>k;
	for (int i=0; i<k; i++)
	{
		int x= 10*i % k;
		int y= (i+1) % k;
		if (i) g[i].push_back(make_pair(x, 0));
		g[i].push_back(make_pair(y, 1));
	}
	dij(k); cout << ans << endl;
}

Measured memory_bytes: 6780
using System;
    class Program
    {
        static void Main()
        {
            string[] input = Console.ReadLine().Split();
            int[] inputarray = new int[5];
            for (int i = 0; i <= 4; i++)
            {
                inputarray[i] = int.Parse(input[i]);
            }
            Array.Sort<int>(inputarray);
            Array.Reverse(inputarray);
            for (int i = 0; i < 4; i++)
            {
                Console.Write(inputarray[i] + " ");
            }
            Console.WriteLine(inputarray[4]);
            Console.ReadLine();
        }
    }

Measured memory_bytes: 9320
#include <stdio.h>

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

	if(a >= b){
		tmp = a;
		a = b;
		b = tmp;
	}

	if(a >= c){
		tmp = a;
		a = c;
		c = tmp;
	}

	if(b >= c){
		tmp = b;
		b = c;
		c = tmp;
	}

	printf("%d %d %d\n", a, b, c);
	return 0;
}

Measured memory_bytes: 596
#include <stdio.h>

char str[10001];
int N, K;

void receive_input() {
	fgets(str, sizeof(str), stdin);
	sscanf(str, "%d %d", &N, &K);
}

void initialize() {
	// nop
}

int main(void) {
	receive_input();
	initialize();

	printf("%s\n", (N >= 2*K-1) ? "YES" : "NO");

	return 0;
}


Measured memory_bytes: 128
#include<iostream>
using namespace std;
int main()
{
    long long int arr[2];
    int maxx,minn,r;

    for(int i=0;i<=2;i++)
    {
        cin>>arr[i];
    }
    maxx=arr[0];
    minn=arr[0];

    if((arr[0]>=1 && arr[0]<=100)&&(arr[1]>=1 && arr[1]<=100)&&(arr[2]>=1 && arr[2]<=100))
    {
        for(int i=1;i<=2;i++)
        {
            if(maxx>arr[i])
            {
                maxx=arr[i];
            }
            if(minn<arr[i])
            {
                minn=arr[i];
            }
        }
       r=maxx-minn;
       if(r<0)
       {
           r=(-1)*r;
           cout<<r;
       }
       else
        cout<<r;
    }
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define M 1000000007
#define pb emplace_back
#define F first
#define S second
#define rep(i, st, ed) for(ll i=st; i<ed; ++i)
#define repn(i, st, ed) for(ll i=st; i<=ed; ++i)
#define repb(i, ed, st) for(ll i=ed; i>=st; --i)
#define all(v) v.begin(),v.end()
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );
#define PI acosl(-1.0)
#define mp(a, b) make_pair(a, b)
#define eps 1e-9
#define FAST ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
typedef long long ll;
template<class T> void chmax(T &a,T b) { if (a<b) a=b;}
template<class T> void chmin(T &a,T b) { if (a>b) a=b;}
const int N = 1e5 + 10;
const ll INF = 1LL << 60;
ll iv[N];
ll powM(ll a, ll b){ll res = 1;for(;b;a=a*a%M,b/=2) if(b&1) res=res*a%M;return res;}
ll nckbig(int n, int k){ll ans = 1;for(int i=1; i<=k; ++i){ans = ans*(n-i+1)%M*iv[i]%M;}return ans;}
void caliv(){iv[1] = 1;for(int i=2; i<N; i++){iv[i] = M-M/i*iv[M%i]%M;}}
ll f1[N], f2[N];
void calf(){f1[0] = f2[0] = 1;for(int i=2; i <N; ++i){f1[i] = f1[i-1]*i%M;f2[i] = f2[i-i]*iv[i]%M;}}
ll nck(int n, int k){return f1[n]*f2[n-k]%M*f2[k]%M;}
ll npk(int n, int k){return f1[n]*f2[n-k]%M;}
void Rnck(int big){if(big){caliv();}else{calf();}}

ll getans(ll n, ll b)
{
	ll sum = 0;
	while(n)
	{
		sum += n%b;
		n /= b;
	}
	return sum;
}

void solve()
{
	ll n, s;
	cin>>n>>s;
	ll ans = -1;
	if(n == s){
		cout<<(n+1)<<endl;
		return;
	}
	if(n < s)
	{
		cout<<-1<<endl;
		return;
	}
	for(ll i=1; i*i <= (n-s); i++)
	{
		if((n-s)%i != 0) continue;
		ll b = i+1;
		if(getans(n, b) == s)
		{
			ans = b;
			break;
		}
		ll rem = (n-s) / i;
		b = rem + 1;
		if(getans(n, b) == s)
		{
			if(ans == -1) ans = b;
			else ans = min(ans, b);
		}
	}
	cout<<ans<<endl;
}


int main()
{
    FAST
    ll Tests = 1;
    //cin>>Tests;
    while(Tests--)
    {
        solve();
    }
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <cmath>
#include <queue>
#include <map>
#include <set>
#include <stack>
#include<algorithm>
#include<sstream>
#include<iomanip>
#include<deque>
#include<list>


using namespace std;

typedef long long ll;

typedef pair<int, int> pii;

const ll MOD_CONST = 1000000007;
const ll BIG_NUM = 1000000000000000000;
const int BIG_INT = 1000000000;

int main() {
	string s;
	cin >> s;
	int a = -1, b = -1;

	for (int i = 1; i <= 2;i++) {
		for (int j = 0; i + j < s.length();j++) {
			if (s[j] == s[i + j]) {
				a = j + 1;
				b = i + j + 1;
				
			}
		}
	}

	cout << a << " " << b << endl;
}

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

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int K = sc.nextInt();

		// A:値を保存する主配列
		// B:累積和を表現する副配列
		int[] A = new int[N + 1];
		int[] B = new int[N + 1];

		// Aの要素に入力を代入
		for (int i = 0; i < N; i++) {
			int a = sc.nextInt();
			A[i] = a;
		}
		
		// K回の試行を行う主反復
		for (int i = 0; i < Math.min(K, 42); i++) {
			/* 解法
			 * 長さNの配列について累積和を計算。それぞれの加算範囲はAのn番目の要素ajについてn-aj~n+ajの範囲
			 * 配列外参照に注意
			 */
			// Bを初期化
			Arrays.fill(B, 0);
			for (int j = 0; j < N; j++) {
				// j番目の要素について、それぞれの始点、終点を記録。配列範囲より大きければ0もしくはNを指定
				// j - ajを始点とすると
				int start = Math.max(0, j - A[j]);
				// j + aj - 1が終点となる(終わりをふくむため)
				int end = Math.min(N, j + A[j] + 1);
				//始点を+1、終点を-1
				B[start]++;
				B[end]--;
			}
			for (int j = 1; j < N; j++) {
				// Bを順に加算していく
				B[j] += B[j - 1];
			}
			// Bの値をAとする
			A = B.clone();
		}

		// 出力
		for (int i = 0; i < N; i++) {
			System.out.print(A[i] + (i < N - 1 ? " " : "\n"));
		}
	}
}

Measured memory_bytes: 64260
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
using namespace std;

typedef struct node{
	int data;
	struct node *pre, *next;
}Node;

Node *head;

void init()
{
	head = (Node*)malloc(sizeof(Node));
	head->next = head;
	head->pre = head;
}

void insert(int key)
{
	Node *x = (Node*)malloc(sizeof(Node));
	x->data = key;
	Node *p = head->next;
	x->next = p;
	p->pre = x;
	head->next = x;
	x->pre = head;
}

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

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

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

void deleteLast()
{
	deleteNode(head->pre);
}

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

void printLast(){
	Node* cur = head->next;
	int isf = 0;
	while (1) {
		if (cur == head) {
			break;
		}
		if (isf++ > 0) {
			printf(" ");
		}
		printf("%d", cur->data);
		cur = cur->next;
	}
	printf("\n");
}


int main(int argc, char *argv[]) {
	int key, n, i;
	int size = 0;
	char com[20];
	int np = 0, nd = 0;
	scanf("%d", &n);
	init();
	for (i = 0; i < n; i++) {
		scanf("%s %d", com, &key);
		if (com[0] == 'i') {
			insert(key);
			np++;
			size++;
		}else if (com[0] == 'd') {
			if (strlen(com) > 6) {
				if (com[6] == 'F') {
					deleteFirst();
				}
				else if (com[6] == 'L') {
					deleteLast();
				}
			}else {
				deleteKey(key);
				nd++;

			}
			size--;
		}
	}
	printLast();
	return 0;	
}


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

#define pb push_back
#define mp make_pair
#define fs first
#define se second
#define pi 2*acos(0)
#define PI 3.14159265358979323846264338

typedef long long ll;
typedef unsigned long long ull;
typedef pair < int , int > pii;
typedef pair < ll , ll > pll;

const int N = 1000010;
const int MX = 123456;
const int mod = (int)1e9 + 7;
const int base = 1023456789;
const ull BS1 = 10000019ULL;
const int INF = (1 << 29);

template < class T > inline void fastScan(T &x){
    register char c = getchar();
    int neg = 0; x = 0;
    for(   ; (c < 48 || c > 57) && (c != '-'); c = getchar());
    if(c == '-') { neg = 1; c = getchar(); }
    for(   ; c > 47 && c < 58; c = getchar()){
        x = (x << 1) + (x << 3) + c - 48;
    }
    if(neg) x = -x;
}

int fx[]={1,-1,0,0};
int fy[]={0,0,-1,1};

int main(){
    int a, b;
    fastScan(a); fastScan(b);
    cout << 2 * b - a << '\n';
}


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


int main(void){
    // Your code here!
    int D;
    int c[26];
    int s[365][26];
    int t;
    int neglect[26]={};
    long S = 0;
    
    scanf("%d",&D);
    for(int i = 0; i < 26; i++)
        scanf("%d",&c[i]);
        
    for(int i = 0; i < D; i++)
        for(int j = 0; j < 26; j++)
            scanf("%d",&s[i][j]);
            
    for(int i = 0; i < D; i++)
    {
        scanf("%d",&t);
        
        for(int j = 0; j < 26; j++)
        {
            neglect[j] = (t-1-j != 0)*(neglect[j]+1);
            S -= c[j]*neglect[j];
        }
        
        S += s[i][t-1];
        printf("%ld\n",S);
    }
        
}


Measured memory_bytes: 3784
#include<iostream>
using namespace std;
int main(){
int a[1001][3],x[1001]={0},b;
cin>>b;
for(int i=0;i<b;i++){
  for(int j=0;j<3;j++)
  {
    cin>>a[i][j];
  }
}
for(int n=0;n<b;n++){
  if(a[n][0]>a[n][1]){
    int okiba=a[n][0];
    a[n][0]=a[n][1];
    a[n][1]=okiba;
  }
 if(a[n][1]>a[n][2]){
    int okiba=a[n][1];
    a[n][1]=a[n][2];
    a[n][2]=okiba;
  }
   if(a[n][0]>a[n][1]){
    int okiba=a[n][0];
    a[n][0]=a[n][1];
    a[n][1]=okiba;
  }

}



int  sum=0;
for(int i=0;i<b-1;i++){
  for(int j=i+1;j<b;j++){
  if(a[i][0]==a[j][0]&&x[j]!=1){
    if(a[i][1]==a[j][1]){
   if(a[i][2]==a[j][2]){
    sum++;
    x[j]=1;
  } 
  }
  }
  
  }
}

cout<<sum<<'\n';

return 0;
}

Measured memory_bytes: 3112
import Control.Monad
import Data.List
import Data.Bits
import Debug.Trace
import Data.Maybe
import qualified Data.ByteString.Char8 as C

main :: IO ()
main = do
  s <- getLine
  putStrLn $ solve s

solve :: String -> String
solve n = if (read n :: Integer) `mod` sn == 0 then "Yes" else "No"
  where
    sn :: Integer
    sn = foldl' (\a x -> a + read [x]) 0 n

-- 以下ライブラリ

readInts :: IO [Int]
readInts = map (fst . fromJust . C.readInt) . C.words <$> C.getLine

readNInts :: Int -> IO [[Int]]
readNInts = flip replicateM readInts

readIntegers :: IO [Integer]
readIntegers = map (fst . fromJust . C.readInteger) . C.words <$> C.getLine

readNIntegers :: Int -> IO [[Integer]]
readNIntegers = flip replicateM readIntegers

getNLns :: Int -> IO [String]
getNLns = flip replicateM getLine

toTup2 :: [[a]] -> [(a, a)]
toTup2 = map (\ys -> case ys of y : z : zs -> (y, z))

encIdx2 :: Int -> (Int, Int) -> Int
encIdx2 mx (y, x) = y * mx + x

decIdx2 :: Int -> Int -> (Int, Int)
decIdx2 mx idx = (idx `div` mx, idx `mod` mx)

encIdx3 :: (Int, Int) -> (Int, Int, Int) -> Int
encIdx3 (my, mx) (z, y, x) = z * my * mx + y * mx + x

decIdx3 :: (Int, Int) -> Int -> (Int, Int, Int)
decIdx3 (my, mx) idx = (z, y, x)
  where
    basez = my * mx
    z = idx `div` basez
    y = (idx `mod` basez) `div` mx
    x = idx `mod` mx

while :: Monad m => m Bool -> m () -> m ()
while cond body = do
  b <- cond
  when b $ do
    body
    while cond body


Measured memory_bytes: 508
#include<iostream>
#include<vector>
#include<cmath>
#include<algorithm>
#include<utility>
#include<string>
#include<utility>
using namespace std;

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

    if(a[0] != a[1] && a[1] != a[2] && a[2] != a[3]){
        cout << "Good" <<endl;
    }else{
        cout << "Bad" << endl;
    }
    
}

Measured memory_bytes: 256
N, K = map(int, input().split())
p = list(map(int, input().split()))
e = [(n+1)/2 for n in p]
now = sum(e[0:K])
ans = now
if N == 1:
  print(e[0])
  exit()

for i in range(1, N-K+1):
  now -= e[i-1]
  now += e[i+K-1]
  ans = max(ans, now)
print(ans)

Measured memory_bytes: 77448
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define se second
#define fi first
#define mp make_pair
#define pb push_back
#define all(_v) _v.begin(), _v.end()
const int mod = (int)1e9 + 7;
const int INF = (int)1e9;
const ll LINF = (ll)1e18;
const int N = (int)1e5 + 100;
const int MAXA = (int)3e6;
int main(){
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
    //ifstream cin("input.txt");
    //ofstream cout("output.txt");
    long double x,p;
    cin >> x >> p;
    p /= 100;
    cout << fixed << setprecision(7);
    if(!(int(x) & 1))cout << x / (2 * p); else cout << (x + 1) / (2 * p);
    return 0;
}


Measured memory_bytes: 3800
#include<iostream>
using namespace std;
#define ll long long
ll n,x,ans;
ll calc(ll n,ll x)
{
	if(!x)return -n;
	ll d=n%x;
	return calc(x,d)+(n/x)*2*x;
}
int main()
{
	cin>>n>>x;ans=n;
	ans+=calc(n-x,x);
	cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 256
import sys

N = int(input())

one = (0, 0)
two = (0, 0)
for i, A in enumerate(map(int, sys.stdin.readlines())):
    if A > one[0]:
        two = one
        one = (A, i)
    elif A > two[0]:
        two = (A, i)

for i in range(N):
    if i == one[1]:
        print(two[0])
    else:
        print(one[0])


Measured memory_bytes: 71644
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (n); i++)
#define repi(i, s, n) for (int i = (s); i < (n); i++)
#ifdef LOCAL
#define INPUT_FILE                              \
  ifstream in("atcoder-problems/abc129_b.txt"); \
  cin.rdbuf(in.rdbuf());
#define print_vec(v)                        \
  rep(l, v.size()) { cout << v[l] << " "; } \
  cout << endl;
#else
#define INPUT_FILE
#define print_vec(v)
#endif
#define CIN_OPTIMIZE \
  cin.tie(0);        \
  ios::sync_with_stdio(false);
typedef pair<int, int> P;
typedef long long ll;
typedef pair<ll, ll> pl;
const int INF = 100100100;
const ll LINF = 1e18 + 100;
const int MOD = 1e9 + 7;

int main() {
  INPUT_FILE CIN_OPTIMIZE;

  int N;
  cin >> N;

  vector<int> c(N);
  int total = 0;
  rep(i, N) {
    int w;
    cin >> w;
    if (i == 0) c[i] = w;
    else
      c[i] = c[i - 1] + w;
    total += w;
  }

  int ans = INF;
  rep(i, N) {
    ans = min(ans, abs(c[i] - (total - c[i])));
  }

  cout << ans << endl;
}

Measured memory_bytes: 3608
//Code By CXY07
#include<bits/stdc++.h>
using namespace std;

#define ONLINE_JUDGE
//#define int long long
const int MAXN = 110;
const int INF = 2e9;
const int mod = 1e9 + 7;

int n,x,ans;
bool p[MAXN];

template<typename T> inline void read(T &a) {
	a = 0; char c = getchar(); int f = 1;
	while(c < '0' || c > '9') {if(c == '-') f = -1; c = getchar();}
	while(c >= '0' && c <= '9') {a = a * 10 + (c ^ 48); c = getchar();}
	a *= f;
}

signed main () {
#ifndef ONLINE_JUDGE
	freopen(".in","r",stdin);
	freopen(".out","w",stdout);
#endif
	read(x); read(n);
	ans = -INF;
	for(register int i = 1,x;i <= n; ++i) {
		read(x);
		p[x] = true;
	}
	ans = INF;
	for(register int i = -200;i <= 200; ++i)
		if((i < 0 || !p[i]) && abs(x - i) < abs(x - ans)) ans = i;
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 3640
#include <cstdio>
#include <cstdlib>
#include <cstring>

#define siz 10000000

char buf[siz], *bit = buf;

inline int nextInt(void) {
	register int ret = 0;
	register int neg = false;

	for (; *bit < '0'; ++bit)
		if (*bit == '-')neg ^= true;

	for (; *bit >= '0'; ++bit)
		ret = ret * 10 + *bit - '0';

	return neg ? -ret : ret;
}

#define inf 2147483647

int n, m;

int tag[400005];

int find(int t, int l, int r, int p) {
	if (~tag[t])
		return tag[t];
	int mid = (l + r) >> 1;
	if (p <= mid)
		return find(t << 1, l, mid, p);
	else
		return find(t << 1 | 1, mid + 1, r, p);
}

void update(int t, int l, int r, int x, int y, int k) {
	if (l == x && r == y)
		tag[t] = k;
	else {
		int mid = (l + r) >> 1;
		if (~tag[t])
			tag[t << 1] = tag[t << 1 | 1] = tag[t], tag[t] = -1;
		if (y <= mid)
			update(t << 1, l, mid, x, y, k);
		else if (x > mid)
			update(t << 1 | 1, mid + 1, r, x, y, k);
		else {
			update(t << 1, l, mid, x, mid, k);
			update(t << 1 | 1, mid + 1, r, mid + 1, y, k);
		}
	}
}

signed main(void) {
	fread(buf, 1, siz, stdin);

	n = nextInt();
	m = nextInt();

	for (int i = 0; i < (n << 2); ++i)
		tag[i] = inf;

	for (int i = 1; i <= m; ++i) {
		int c = nextInt();
		if (c)	// find(x)
			printf("%d\n", find(1, 1, n, nextInt() + 1));
		else {
			int x = nextInt();
			int y = nextInt();
			int k = nextInt();
			update(1, 1, n, x + 1, y + 1, k);
		}
	}

	//system("pause");
}

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

int main()
{
    int H, W, K;
    cin >> H >> W >> K;
    int cij;
    vector<string> C(H);
    for(int i=0;i<H;i++){
        cin >> C[i];
    }
    int res = 0;
    for(int bH=0; bH<(1<<H); bH++){
        for(int bW=0; bW<(1<<W); bW++){
            int count = 0;
            for(int i=0;i<H;i++){
                for(int j=0;j<W;j++){
                    if(C[i][j]=='.') continue;
                    if(bH & (1<<i)) continue;
                    if(bW & (1<<j)) continue;
                    count++;
                }
            }
            if(count == K) res++;
        }
    }
    cout << res << endl;

    return 0;
}

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

using namespace std;
using ll =long long;
using db = double;
using vll = vector<long long>;

template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
#define che(a,string) cout<<"//"<<string <<"=="<<(a)<<"//" <<endl;
#define SORT(a) sort((a).begin(),(a).end())
#define rSORT(a) reverse((a).begin(),(a).end())
#define For(i, a, b)    for(int i = (a) ; i < (b) ; ++i)
#define rep(i, n)       For(i, 0, n)
#define leftunique(a) {SORT(a);(a).erase(unique((a).begin(),(a).end()),(a).end());}
//leftuniqueは配列から同じ要素のものを取り除く 例 4 6 2 1 3 4 1 2 なら 1 2 3 4 6 になる
#define debug(x)  cout << #x << " = " << (x) << endl;
bool IsInt(double a){int b = a/1;if(a==b){return true;}else {return false;}}
bool coY() {cout <<"Yes"<<endl;}
bool coN(){cout <<"No"<<endl;}
const int mod = 1e9 + 7;
const ll INF = 1LL << 60;
// a^n mod を計算する
long long modpow(long long a, long long n, long long mod) {
    long long res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}
//グラフ用
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};	
//ここから書き始める

ll combination(ll n, ll i){
	ll count = 0;
	ll multi = 1;
	ll div =1;
	int limit = i;
	while(count < limit){
		multi *= n;
		n--;
		multi/= count+1;
		count ++ ;
	}
	return multi / div;
}

int main()
{
	cout <<setprecision(10);
	int n ; cin >> n;
	map<ll,ll> A;
	rep(i,n){
		int a ; cin >> a;
		A[a] ++;
	}
	ll ans = 0;
	for(auto x : A){
		if(x.second %2 == 1){
			ans ++ ;
		}
	}
	cout << ans << endl;
}


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

using ll = long long;

ll ct2(ll n)
{
    ll r = 0;
    while(n>0 && n%2==0)
    {
        n/=2;
        ++r;
    }
    return r;
}

ll pw(int x, int n)
{
    ll r = 1;
    rep(i,n) r *=x;
    return r;
}

ll num(int n)
{
    ll ct = 0;
    rep(i,n+1)
    {
        ct += ct2(i);
    }
    return ct;
}

ll C(int n, int m)
{
    ll p = num(n);
    ll q = num(m) + num(n-m);
    // printf("C %d %d %lld\n", n,m,p-q);
    return p-q;
}

void test()
{
    for(int i=3; i<=100000; i+=2)
    {
        printf(" i %d\n", i);
        for(int j=2; j<=i; j+=2)
        {
            if(C(i,j)>0)
            {
                assert(j==pw(2,ct2(i+1)));
                break;
            }
        }
    }
    printf(" END\n");
}

int main()
{
    // test();

    ll n;
    cin >>n;

    cout << pw(2,ct2(n+1)) << endl;
    return 0;
}

Measured memory_bytes: 3080
#include <bits/stdc++.h>
using namespace std;
#define deb(x)  cout << #x << ' ' << x << endl;
#define mod 1000000007
#define all(n)      (n).begin(), (n).end()
#define ll long long
#define ull unsigned long long 

vector<int> adj[100001];
vector<bool> vis;

void dfs(int i=1,int pr=0){
    vis[i]=1;
    for(int ch : adj[i]){
        if(ch==pr)continue;
        if(!vis[ch]){
            dfs(ch,i);
        }

    }
}
void solve() {
    int n,m;
    cin >> n >> m;
    vis.clear();
    for(int i = 1; i <= n ; i++){
        adj[i].clear();
    }
    for(int i = 1; i <= n; i++){
        vis.push_back(0);
    }
    for(int i = 1;i <= m;i++){
        int u,v; cin >> u >> v; 
        adj[u].push_back(v);
        adj[v].push_back(u);
    }
    int ans = 0;
    for(int i = 1; i <= n ; i++){
        if(!vis[i]){
            dfs(i);
            ans++;
        }
    }
    ans--;
    cout << ans << endl;
    
    
}
int main(){
    ios::sync_with_stdio(0);
    cin.tie(0);
    //Starts here , 
    // Chaaliya Be! Tamam Dekhun!	
                
    int T = 1; 
    // cin >> T;	
    while(T--){
        solve();
    }
    return 0;
            
}

Measured memory_bytes: 9872
N, M = map(int, input().split())
jobs = sorted([list(map(int, input().split())) for i in range(N)], reverse=True)

from heapq import *
q = []
heapify(q)
ans = 0
for i in range(1, M+1):
    while jobs and jobs[-1][0] <= i:
        heappush(q, -1*jobs.pop()[1])
    if q:
        ans += -1 * heappop(q)
print(ans)

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

int main() {
  string S;
  cin >> S;
  bool check = true;
  for (int i = 0; i < S.size(); i++){
    if (i % 2 == 0){
      if (S[i] == 'L'){
        check = false;
        break;
      }
    }
    else {
      if (S[i] == 'R'){
        check = false;
        break;
      }
    }
  }
  if (check)
  cout << "Yes" << endl;
  else
  cout << "No" << endl;
}


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

typedef vector<int> vi;
typedef pair<int,int> pii;
#define pb push_back

const int MN = 5e4+5, MM = 1e5+5;
int T, N, M, i, x, y, st, ds[MN], use[MN], ans[MM];
pii ed[MM]; vector<int> adj[MN];
bitset<MN> ok[MN], hm;
int fnd(int x){return ds[x]=x==ds[x]?x:fnd(ds[x]);}

int main(){
    scanf("%d%d%d",&N,&M,&T);
    if(T==1){
        for(i=1;i<=M;i++) scanf("%d%d",&ed[i].first,&ed[i].second);
        for(i=1;i<=N;i++) ok[i][i]=1;
        for(i=M;i>=1;i--){
            ok[ed[i].first]|=ok[ed[i].second];
            ok[ed[i].second]|=ok[ed[i].first];
        }
        for(i=2;i<=N;i++)
            ok[1]&=ok[i];
        st = -1;
        for(i=1;i<=N;i++){
            if(ok[1][i]){
                st = i;
                break;
            }
        }
        if(st==-1) printf("-1\n");
        else{
            hm[st] = 1;
            vector<char> ans;
            for(i=M;i>=1;i--){
                if(hm[ed[i].first]) ans.pb('^');
                else ans.pb('v');
                hm[ed[i].first]=(hm[ed[i].first]||hm[ed[i].second]);
                hm[ed[i].second]=(hm[ed[i].second]||hm[ed[i].first]);
            }
            reverse(ans.begin(),ans.end());
            for(auto ch : ans) printf("%c",ch);
            printf("\n");
        }
    }
    else{
        for(i=1;i<=N;i++) ds[i]=i;
        pii ok(-1,-1);
        for(i=1;i<=M;i++){
            scanf("%d%d",&ed[i].first,&ed[i].second);
            if(!use[ed[i].first]&&!use[ed[i].second]){
                ds[fnd(ed[i].first)]=fnd(ed[i].second);
                use[ed[i].first]=use[ed[i].second]=1;
            }
            adj[ed[i].first].pb(i);
            adj[ed[i].second].pb(i);
        }
        for(i=2;i<=N;i++){
            if(fnd(i)!=fnd(1)){
                ok={1,i};
                break;
            }
        }
        if(ok.first==-1) printf("-1\n");
        else{
            tie(x,y)=ok;
            int px=0, py=0;
            while(1){
                if(px>=adj[x].size()||py>=adj[y].size()) break;
                if(adj[x][px]>adj[y][py]) swap(x,y), swap(px,py);
                if(px+1<adj[x].size()&&adj[x][px+1]==adj[y][py]){
                    int t = adj[x][px];
                    if(x==ed[t].first) ans[t]=1, x=ed[t].second;
                    else x=ed[t].first;
                    px=upper_bound(adj[x].begin(),adj[x].end(),t)-adj[x].begin();
                }
                else{
                    int t = adj[x][px];
                    if(x==ed[t].second) ans[t]=1;
                    px++;
                }
            }
            for(i=1;i<=M;i++){
                printf("%c",ans[i]?'v':'^');
            }
            printf("\n");
        }
    }
    return 0;
}


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

#define FOR(a, b, c) for(int a = b; a <= c; ++a)
#define fi first
#define se second
#define pb push_back
#define int long long

typedef pair<int, int> ii;
typedef pair<int, ii> iii;

const int N = 1e5 + 10;
const int oo = 1e18;

int a[] = {1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};

signed main()  {
    //freopen("test.inp", "r", stdin);
    //freopen("test.out", "w", stdout);
    ios_base::sync_with_stdio(false); cout.tie(0);

    int a, b, c; cin >> a >> b >> c;
    if(c > a + b && 4 * a * b < (c - a - b) * (c - a - b)) cout << "Yes";
    else cout << "No";
}


Measured memory_bytes: 256
a,b,c,d,e,f=map(int,input().split())
inf=float("inf")
a*=100
b*=100
lst=[[inf,0] for _ in range(f//100)]
for i in range(f//b+1):
    for j in range(f//a+1):
        if i==0 and j==0:
            continue
        if (i*b+j*a)<=f:
            lst[(i*b+j*a)//100-1][0]=(i*b+j*a)
sugarlst=[]
C=max(c,d)
D=min(c,d)

for i in range(1500//C+1):
    for j in range((1500-i*C)//D+1):
        sugarlst.append(C*i+D*j)
sugarlst=set(sugarlst)
sugarlst=sorted(sugarlst)

for i in range(f//100):
    if lst[i][0]==inf:
        continue
    for j in sugarlst:
        weight=lst[i][0]+j
        if weight>f or (lst[i][0]//100)*e<j :
            break
        lst[i][1]=j

noudomax=0
for i in lst:
    noudo=i[1]/(i[0]+i[1])
    if noudo>=noudomax:
        ans=i
        noudomax=noudo
if noudomax==0:
    print(a,0)
else:
    print(ans[0]+ans[1],ans[1])

Measured memory_bytes: 108648
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
using namespace std;
#include<iomanip>
#define PI 3.14159265359
int main()
{
  setprecision(10);
  int num = 1;
  int data[1000];
  double ave,deviation;

  while(1)
  {
    ave = 0;
    deviation = 0;
    cin >> num;
    if(num == 0)break;
    for(int i = 0 ; i < num ; i ++)
    {
      cin >> data[i];
      ave += data[i];
    }
    ave = (ave/num);
    for(int i = 0 ; i < num; i++)
    {
      deviation += pow(ave - data[i],2);
    }

    if(deviation != 0.0)deviation = (deviation/num);
    cout << fixed<<sqrt(deviation)<< endl;
  }
  return 0;
}



Measured memory_bytes: 3224
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i=0;i<n;++i)
#define rep1(i,n) for(int i=1;i<=n;++i)
#define co(x) cout << (x) << "\n"
#define cosp(x) cout<< (x) << " "
int main(){
    int n,k;cin>>n>>k;
    double p[n],sum[n];
    double tmp, stack = 0.0;
    rep(i,n){cin>>tmp;stack+=(1+tmp)/2.0;p[i]=stack;}
    double ans = p[k-1];
    for(int i=k;i<n;i++){
        ans = max(ans, p[i]-p[i-k]);
    }
    printf("%.12f\n", ans);
}


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

using namespace std;

#define rep(i, n) for (int i = 0; i < (int)n; ++i)
#define FOR(i, a, b) for (int i = a; i < (int)b; ++i)
#define rrep(i, n) for (int i = ((int)n - 1); i >= 0; --i)

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

const ll INF = 1e18;
const int Inf = 1e9;
const double EPS = 1e-9;
const ll MOD = 1e9 + 7;

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(0);
	int x;
	cin >> x;
	cout << !x << endl;
    
    return 0;
}


Measured memory_bytes: 3616
#include <stdio.h>

using namespace std;

int main(){
    int C[10001];
    for(int i = 0; i < 10001; i++) C[i] = 0;
    int n;
    scanf("%d",&n);
    int* A = new int[n];
    int* B = new int[n];
    for(int i = 0; i < n; i++){
        scanf("%d",&A[i]);
        C[A[i]]++;
    }

    for(int i = 0,j=0; i < 10001; i++){
        if(C[i] != 0){
            for(int k = 0; k < C[i]; k++){
                B[j++] = i;
            }
        }
    }

    for(int i = 0; i < n-1; i++) printf("%d ",B[i]);
    printf("%d\n",B[n-1]);
    delete[] A;
    delete[] B;
    return 0;
}


Measured memory_bytes: 17916
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define pb push_back
#define all(a) a.begin(),a.end()
#define fi first
#define se second
#define deb(x) cout << #x << "=" << x << endl
#define clr(x) memset(x, 0, sizeof(x))
#define rep(i,k,n) for(int i=k;k<n?i<n:i>n;k<n?i+=1:i-=1)
int M=1e9+7,N=205001;

int mm(int x,int y){x%=M,y%=M;return (x*y)%M;}//Modular Multiply
int po(int x,int y){ if(!y)return 1;int a=po(x,y/2)%M;if(y%2)return mm(a,mm(a,x));return mm(a,a);}//(x**y)%M



void solve() {
	int n;
	cin>>n;
	int dp[2010]={1};
	int s[2010]={1};
	for(int i=1;i<=n;i++){
		rep(j,3,n+1){
			if(i-j>=3 or i==j) dp[i]+=dp[i-j];
			dp[i]%=M;
		}
	}
	cout<<dp[n];
}


signed main(){
ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
	int t=1;
	//cin>>t;
	while(t--) solve();
	return 0;
}





Measured memory_bytes: 3644
import sys
input = sys.stdin.readline
def main():
    N, M = map(int, input().split())
    S = [[]]*M
    for i in range(M):
        S[i] = list(map(int, input().split()))
    P = list(map(int, input().split()))
    LUMP, COMB = 0, 0
    for bit in range(1<<N):
        LUMP = 0
        for j in range(M):
            on = 0
            for k in range(1, S[j][0]+1):
                if bit>>(S[j][k]-1) & 1:
                    on += 1
            if on%2 == P[j]:
                LUMP += 1        
        if LUMP == M:
            COMB  += 1
    print(COMB)

if __name__ == '__main__':
    main()

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int sz = 2e5+5;

ll sa[sz], sb[sz], sc[sz];

int main()
{
    ll x, y, a, b, c;
    cin >> x >> y >> a >> b >> c;
    for(ll i=0; i<a; i++) scanf("%lld", &sa[i]);
    for(ll i=0; i<b; i++) scanf("%lld", &sb[i]);
    for(ll i=0; i<c; i++) scanf("%lld", &sc[i]);
    sort(sa, sa+a, greater <ll>());
    sort(sb, sb+b, greater <ll>());
    sort(sc, sc+c, greater <ll>());

    ll ans = 0;
    vector <ll> now;
    for(ll i=0; i<x; i++) now.push_back(sa[i]);
    for(ll i=0; i<y; i++) now.push_back(sb[i]);
    sort(now.begin(), now.end());

    for(ll i=0; i<min(x+y, c); i++) {
        if(now[i] < sc[i]) swap(now[i], sc[i]);
    }

    for(ll v : now) ans += v;
    cout << ans << endl;
}


Measured memory_bytes: 5748
def main():
    h1, h2 = map(int, input().split())
    k1, k2 = map(int, input().split())
    a, b, c, d = map(int, input().split())

    hiroshi = h1 * a + int(h1 / 10) * c + h2 * b + int(h2 / 20) *d
    kenjiro = k1 * a + int(k1 / 10) * c + k2 * b + int(k2 / 20) *d

    if hiroshi > kenjiro:
        print('hiroshi')
    elif kenjiro > hiroshi:
        print('kenjiro')
    else:
        print('even')

if __name__ == '__main__':
    main()

Measured memory_bytes: 7820
package main

import "fmt"

func main() {
	var n int
	fmt.Scan(&n)
	a := make([]int, n)
	result := "APPROVED"
	for i:=0; i<n; i++{
		fmt.Scan(&a[i])
		if a[i] % 2 == 0 && a[i] % 3 != 0 && a[i] % 5 != 0{
			result = "DENIED"
		}
	}


	fmt.Println(result)
}

Measured memory_bytes: 1776
n = gets.to_i
abc = (1..n).map{|x| gets.split.map(&:to_i) }

result = abc.inject([0,0,0]) {|m,x|
  [
    [m[1],m[2]].max + x[0],
    [m[0],m[2]].max + x[1],
    [m[0],m[1]].max + x[2]
  ]
}.max

puts result


Measured memory_bytes: 9596
import java.io.BufferedReader;
import java.io.InputStreamReader;

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

    public void solve(String[] args) {
        MyScanner scanner = new MyScanner();
        int a = scanner.nextInt();
        int b = scanner.nextInt();
        int c = scanner.nextInt();
        int max = Math.max(a, Math.max(b,c));
        int min = Math.min(a, Math.min(b, c));

        System.out.println(max-min);

    }

    private class MyScanner {
        String[] s;
        int i;
        BufferedReader br;
        String reg = " ";
        MyScanner () {
            s = new String[0];
            i = 0;
            br = new BufferedReader(new InputStreamReader(System.in));
        }
        public String next() {
            try {
                if (i < s.length) return s[i++];
                String line = br.readLine();
                while (line.equals("")) {line = br.readLine();}
                s = line.split(reg, 0);
                i = 0;return s[i++];
            } catch (Exception e) {e.printStackTrace();}
            return null;
        }
        public int nextInt() {
            try {return Integer.parseInt(next());} catch (Exception e) {e.printStackTrace();}
            return -1;
        }
        public double nextDouble() {
            try {return Double.parseDouble(next());} catch (Exception e) {e.printStackTrace();}
            return -1;
        }
        public long nextLong()  {
            try {return Long.parseLong(next());} catch (Exception e) {e.printStackTrace();}
            return -1;
        }
    }
}

Measured memory_bytes: 21204
#include <cstdio>
using namespace std;
int main() {
	int n;
	while(scanf("%d",&n),n) {
		int p,d1,d2;
		int max_d=0,max_p=0;
		for(int i=0;i<n;i++) {
			scanf("%d %d %d",&p,&d1,&d2);
			if(max_d<(d1+d2)) {
				max_d=(d1+d2);
				max_p=p;
			}
		}
		printf("%d %d\n",max_p,max_d);
	}
}

Measured memory_bytes: 1024