akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <utility>
#include <functional>
#include <climits>
#include <cstring>

using namespace std;

#define int long long

#define rep(i, n) for (int i=0;i<(int)n;++i)
#define rep1(i, n) for (int i=1;i<=(int)n;++i)
#define unless(a) if(!(a))
#define all(a) begin(a),end(a)
#define fst first
#define scd second
#define PB emplace_back
#define PPB pop_back

using ll=long long;
using vi=vector<int>;
using pii=pair<int, int>;

bool chmin(int&a,int b){return a>b?(a=b,true):false;}
bool chmax(int&a,int b){return a<b?(a=b,true):false;}
int read(){int a;scanf("%lld",&a);return a;}

const int INF = 1e9 + 10;
const int mod = 1e9 + 7;

ll inv[200010];
ll fac[200010], fac_inv[200010];

ll C(int n, int k) {
	return ((fac[n] * fac_inv[k] % mod) * fac_inv[n - k]) % mod;
}

void comb_init()
{
	int N = 200005;
	inv[1] = 1;

	for (int i = 2; i <= N; ++i) {
		inv[i] = mod - (mod / i) * inv[mod % i] % mod;
	}

	fac[0] = fac_inv[0] = 1;

	for (int i = 1; i <= N; ++i) {
		fac[i] = (fac[i - 1] * i) % mod;
		fac_inv[i] = (fac_inv[i - 1] * inv[i]) % mod;
	}
}

int N;
int a[100010];
bool used[100010];

signed main()
{
	cin >> N;

	if (N == 1) {
		cout << 1 << endl;
		cout << 1 << endl;
		return 0;
	}

	int l, r;

	rep(i, N + 1) {
		cin >> a[i];
		if (used[a[i]]) {
			r = i + 1;
			rep(j, i) {
				if (a[j] == a[i]) {
					l = j + 1;
					break;
				}
			}
		}
		used[a[i]] = true;
	}

	comb_init();

	int s = r - l - 1;

	rep1(k, N + 1) {
		int ans = 0;

		ans += C(N + 1 - 2, k);
		ans %= mod;
		if (k - 2 >= 0) {
			ans += C(N + 1 - 2, k - 2);
			ans %= mod;
		}
		if (N + 1 - 2 >= k - 1) ans += C(N + 1 - 2, k - 1) * 2 % mod;
		if (N + 1 - s - 2 >= k - 1) ans += (mod - C(N + 1 - s - 2, k - 1)) * 2 % mod;
		ans %= mod;
		if (N + 1 - s - 2 >= k - 1) ans += C(N + 1 - s - 2, k - 1);
		ans %= mod;

		printf("%lld\n", ans);
	}
}



Measured memory_bytes: 7040
import java.util.*;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int T = sc.nextInt();
		int cost[] = new int[N];
        int time[] = new int[N];
        int i;
        int result = 0;
        for(i = 0;i < N; i++){
          cost[i] = sc.nextInt();
          time[i] = sc.nextInt();
          if(time[i] <= T){
            if(result > cost[i] || result == 0){
                result = cost[i];
            }
          }
        }
      	if(result == 0){
           System.out.println("TLE");   
        }else{
     	   System.out.println(result);   
        }
    }
}

Measured memory_bytes: 36080
#include<bits/stdc++.h>
#define FOR0(i,n) for(ll i=0;i<n;i++)
#define FOR1(i,n) for(ll i=1;i<=n;i++)
#define FORl(i,l,n) for(ll i=l;i<n;i++)
using namespace std;
#define pi pair<ll,ll>
#define pb push_back
#define ll long long
#define ld long double
#define ff first
#define ss second
#define mp make_pair
#define mst0(x) memset(x,0,sizeof(x));
#define vi vector<int>
#define sync ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl '\n'
#define sp <<" "<<
#define intmax 1e18



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

	int a[n];
	FOR0(i, n) cin >> a[i];

	bool chk = 1;
	FOR0(i, n){
		if (a[i]%2==0){
			if (a[i]%3==0 || a[i]%5==0){
				continue;
			}
			else {
				chk = 0;
			}
		}
	}
	if(chk){
		cout << "APPROVED" << endl;
	}
	else{
		cout << "DENIED\n";
	}

}

Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
using namespace std;
signed main() {
  ios::sync_with_stdio(false); cin.tie(0);
  int n;
  cin >> n;
  if (n == 3) {
    cout << "2 5 63" << endl;
    return 0;
  }
  vector<int> ans;
  int sum = 0;
  for (int i = 1; i <= 30000; i++) {
    if (i % 2 == 0 || i % 3 == 0) {
      ans.push_back(i);
      sum += i;
    }
    if ((int) ans.size() == n) break;
  }
  int need = (6 - sum % 6) % 6;
  for (int i = n - 1; i >= 0 ; i--) {
    if (ans[i] + need <= 30000 && ((ans[i] + need) % 2 == 0 || (ans[i] + need) % 3 == 0)) {
      ans[i] += need;
      break;
    }
  }
  for (int i = 0; i < n; i++) {
    if (i > 0) cout << " ";
    cout << ans[i];
  }
  cout << endl;
  return 0;
}

Measured memory_bytes: 640
N, M = map(int, input().split())
d = (N-1)//2
ans = [(1, 1+d)]

while True:
    a, b = ans[-1][0]+1, ans[-1][1]-1
    
    if a<b:
        ans.append((a, b))
    else:
        break

ans.append((2+d, 1+2*d))

while True:
    a, b = ans[-1][0]+1, ans[-1][1]-1
    
    if a<b:
        ans.append((a, b))
    else:
        break

for a, b in ans[:M]:
    print(a, b)

Measured memory_bytes: 74944
#include<bits/stdc++.h>
#define For(i,l,r) for(int i=l;i<=r;i++)
#define ll long long
using namespace std;
const int M=1e5+5;
int n,a[M],b[M],x[M],y[M],vis[M],cnt,ans;
map<int,int>d;
vector<int>Q[M];
inline int read(){
	int f=1,sum=0;
	char ch=getchar();
	while(!isdigit(ch)){if(ch=='-')f=-1;ch=getchar();}
	while(isdigit(ch)){sum=(sum<<1)+(sum<<3)+(ch^48);ch=getchar();}
	return f*sum; 
}
inline void dfs(int x){
	vis[x]=1;
	For(i,0,Q[x].size()-1){
		if(!vis[Q[x][i]]){
			dfs(Q[x][i]);
		}
	}
}
int main(){
	n=read();
	For(i,1,n){
		a[i]=read();a[n+1]^=a[i];
	    if(!d[a[i]]) d[a[i]]=++cnt;
	}
	if(!d[a[n+1]]) d[a[n+1]]=++cnt;
	For(i,1,n){
		b[i]=read();b[n+1]^=b[i];
		if(!d[b[i]]) d[b[i]]=++cnt;
	}
	if(!d[b[n+1]]) d[b[n+1]]=++cnt;
	memcpy(x,a,sizeof(x));memcpy(y,b,sizeof(y));
	sort(x+1,x+n+2);sort(y+1,y+n+2);
	For(i,1,n) if(x[i]!=y[i]){printf("-1");return 0;}
	For(i,1,n+1) a[i]=d[a[i]],b[i]=d[b[i]];
	For(i,1,n) if(a[i]!=b[i]) ans++,Q[a[i]].push_back(b[i]);
	if(a[n+1]!=b[n+1]) Q[a[n+1]].push_back(b[n+1]); 
	For(i,1,cnt-1) if(Q[i].size()&&!vis[i]) dfs(i),ans++;
	if(!vis[cnt]) ans++;
	printf("%d",ans-1);
	return 0;
}

Measured memory_bytes: 14208
#include<stdio.h>
int main()
{
    int n, d, x, a, i, ans = 0;
    scanf("%d%d%d", &n, &d, &x);
    for (i = 0; i < n; i++)
    {
        scanf("%d", &a);
        ans += d / a + 1;
        if (d%a == 0)
            ans--;
    }
    ans += x;
    printf("%d", ans);
    return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define MOD 1000000007
#define print(A,n) for(ll i=0;i<n;++i)cout<<A[i]<<' ';cout<<endl;
#define take(A,n) for(ll i=0;i<n;++i)cin>>A[i];
ll mulmod(ll a,ll b,ll c) 
{ 
    if (b==0) 
        return 0; 
    ll s = mulmod(a, b/2, c); 
    if (b%2==1) 
        return (a%c+2*(s%c)) % c; 
 
    else
        return (2*(s%c)) % c; 
} 

  
void fastio(){ios_base::sync_with_stdio(false);cin.tie(NULL);}
int main()
{ll int tc;
//t=1;
tc=1;

while(tc--)
{string s,t,u;ll int a,b;
cin>>s>>t;
cin>>a>>b;
cin>>u;
if(s==u)a--;
else
b--;
cout<<a<<" "<<b<<endl;
   
}
 
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#define loop(i,a,b) for(int i=a;i<b;i++)
#define rep(i,a) loop(i,0,a)
using namespace std;

bool prime[1000001];

int main(){
	int n,x;
	rep(i,1000002)prime[i]=true;
	prime[0]=prime[1]=false;
	loop(i,2,1010)for(int j=i*2;j<1000001;j+=i)prime[j]=false;
	while(cin>>n>>x,n||x){
		int dish[n];
		rep(i,n)cin>>dish[i];
		bool cost[x+10];
		rep(i,x+10)cost[i]=false;
		rep(i,n)if(dish[i]<x+1)cost[dish[i]]=true;
		cost[0]=true;
		rep(i,x+1){
			if(!cost[i])continue;
			rep(j,n){
				if(i+dish[j]>x)continue;
				cost[i+dish[j]]=true;
			}
		}
		bool check=true;
		for(int i=x;i>=0;i--){
			if(prime[i] && cost[i]){
				check=false;
				cout<<i<<endl;
				break;
			}
		}
		if(check)cout<<"NA"<<endl;
	}
	return 0;
}

Measured memory_bytes: 3108
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author tatsumack
 */

#include <iostream>
#include <fstream>

#include <bits/stdc++.h>

#define int long long
#define REP(i, n) for (int i = 0, i##_len = (n); i < i##_len; ++i)
#define FOR(i, a, b) for (int i = (a), i##_len = (b); i <= i##_len; ++i)
#define REV(i, a, b) for (int i = (a); i >= (b); --i)
#define CLR(a, b) memset((a), (b), sizeof(a))
#define DUMP(x) cout << #x << " = " << (x) << endl;
#define INF 1001001001001001001ll
#define fcout cout << fixed << setprecision(12)

using namespace std;

typedef pair<int, int> P;


class EAlmostEverywhereZero {
public:
    int dp[101][5][2];

    void solve(std::istream& cin, std::ostream& cout) {
        string S;
        int K;
        cin >> S >> K;

        CLR(dp, 0);
        dp[0][0][0] = 1;
        REP(i, S.size()) {
            char c = S[i];
            int n = (c - '0');
            REP(j, K + 1) {
                // ぴったり
                if (n == 0) {
                    dp[i + 1][j][0] += dp[i][j][0];
                } else {
                    dp[i + 1][j][1] += dp[i][j][0];
                    dp[i + 1][j + 1][1] += dp[i][j][0] * (n - 1);
                    dp[i + 1][j + 1][0] += dp[i][j][0];
                }

                // 未満
                dp[i + 1][j][1] += dp[i][j][1];
                dp[i + 1][j + 1][1] += dp[i][j][1] * 9;
            }
        }
        cout << dp[S.size()][K][0] + dp[S.size()][K][1] << endl;
    }
};


signed main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);
    std::istream& in(std::cin);
    std::ostream& out(std::cout);

    EAlmostEverywhereZero solver;
    solver.solve(in, out);
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#pragma gcc optimize("ofast")
using namespace std;

#define ll long long //data types used often, but you don't want to type them time by time
#define ull unsigned long long
#define ui unsigned int
#define mod 1000000007
#define us unsigned short
#define IOS ios_base::sync_with_stdio(0); //to synchronize the input of cin and scanf
#define INF LONG_MAX
#define PI 3.1415926535897932384626
#define mp make_pair
#define fi first
#define se second
#define pb push_back
#define rep(x,j,n)for(int x=j;x<n;x++)
typedef vector<pair<ll,ll>> vpi;
typedef vector<ll> vi;
typedef vector<vi> vvi;

ll modexp(ll a,ll b,ll m)
{
    ll r=1;
    a=a%m;
    while(b>0)
    {
        if(b&1)
            r=(r*a)%m;
        b>>1;
        a=(a*a)%m;
    }
    return r%m;
}

int main(){
    string s; cin>>s;
    ll n =s.size();
    ll flag =1;
    rep(i,0,n)
    {
        if((i+1)%2)
        {
            if(s[i]=='L')flag=0;
        }
        else
        {
            if(s[i]=='R')flag=0;
        }
    }
    if(flag==0)cout<<"No\n";
    else cout<<"Yes\n";
    return 0;
    
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define MAX 505
#define INF (1<<30)
typedef pair<int,int> P;
int dy[]={-1,0,1,0};
int dx[]={0,1,0,-1};
int W,H,N,sy,sx,ty,tx;
int t[MAX][MAX][2];
int d[MAX][MAX];

int change(char ch){
  if(ch=='U')return 0;
  if(ch=='R')return 1;
  return (ch=='D'?2:3);
}

int solve(){
  int h=MAX;
  d[sy][sx]=0;
  priority_queue< P,vector<P>,greater<P> > Q;
  Q.push(P(0,sy*h+sx));
  while(!Q.empty()){
    P p=Q.top();Q.pop();
    int y=p.second/h,x=p.second%h;
    int cost=p.first,ncost;
    if(y==ty&&x==tx)return cost;
    if(cost>d[y][x])continue;
    for(int i=0;i<4;i++){
      int ny=y+dy[i],nx=x+dx[i];
      if(ny<0||nx<0)continue;
      if(ny>H||nx>W)continue;
      ncost=cost;
      if(i==0)ncost+=t[ny][x][1];
      else if(i==1)ncost+=t[y][x][0];
      else if(i==2)ncost+=t[y][x][1];
      else ncost+=t[y][nx][0];
      if(ncost>=d[ny][nx])continue;
      d[ny][nx]=ncost;
      Q.push(P(ncost,ny*h+nx));
    }
  }
  return INF;
}

void calc(){
  string str;
  int y,x,T;
  cin>>x>>y>>T>>str;

  while(T--){
    for(int i=0;i<(int)str.size();i++){
      int dir=change(str[i]);
      int ny=y+dy[dir],nx=x+dx[dir];
      if(ny<0||nx<0)continue;
      if(ny>=H||nx>=W)continue;
      if(dir==0)t[y][x][0]++;
      else if(dir==1)t[ny][nx][1]++;
      else if(dir==2)t[ny][nx][0]++;
      else t[y][x][1]++;
      y=ny,x=nx;
    }
  }
}

void init(){
  for(int i=0;i<MAX;i++){
    for(int j=0;j<MAX;j++){
      t[i][j][0]=0,
      t[i][j][1]=0,
      d[i][j]=INF;
    }
  }
}

int main(){
  cin>>W>>H>>N;
  init();
  cin>>sx>>sy>>tx>>ty;
  for(int i=0;i<N;i++)calc();
  cout<<solve()<<endl;
  return 0;
}

Measured memory_bytes: 6116
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>

using namespace std;

// typedef
typedef long long ll;

// container util
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(auto i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())

// repetition
#define FOR(i,m,n) for(ll i = ((ll) m); i < ((ll) n); ++i)
#define REP(i,n) FOR(i,0,n)

struct Phrase {
    int s;
    int l;
    int p;
};

int main() {
    int n; cin >> n;
    Phrase* ph = new Phrase[n];
    REP(i, n) cin >> ph[i].s >> ph[i].l >> ph[i].p;
    const int MAX = 393;
    int s[MAX+1];
    REP(m, MAX+1) s[m] = 0;
    REP(k, n) {
        FOR(m, ph[k].s, MAX+1) {
            int val = s[m];
            FOR(t, ph[k].s, min((ll)ph[k].l, m)+1) {
                val = max(val, s[m-t]+ph[k].p);
            }
            s[m] = val;
        }
    }
    int m; cin >> m;
    int *w = new int[m];
    bool error = false;
    REP(i, m) {
        cin >> w[i];
        error |= s[w[i]] == 0;
    }
    if (error) {
        cout << -1 << endl;
    } else {
        REP(i, m) cout << s[w[i]] << endl;
    }
    return 0;
}
/*
VOCAL ANDROID
http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=2502

dp[k][m] = k番目までのフレーズのみを使った時に長さmのメロディが得られる最大のスコア
dp[k][m] = max_{s..l}{0..} {dp[k-1][m - nt]+ns}
         = max_{s..l} max(dp[k-1][m], max_{1..} {dp[k-1][m - nt]+ns})
         = max_{s..l} max(dp[k-1][m], max_{0..} {dp[k-1][m - t - nt]+ns} + s)
         = max_{s..l} max((dp[k-1][m], dp[k][m-t]+s)
*/


Measured memory_bytes: 3108
n, w = map(int, input().split())
s = [list(map(int, input().split())) for _ in range(n)]
ss = s[0][0]
s.sort(key = lambda x : x[1], reverse = True)
t = [[] for _ in range(4)]
for u in s:
    t[u[0] - ss].append(u[1])
l1, l2, l3, l4 = len(t[0]) + 1, len(t[1]) + 1, len(t[2]) + 1, len(t[3]) + 1
a, b, = [0] * l1, [0] * l2
c, d, = [0] * l3, [0] * l4
for i in range(1, l1):
    a[i] = t[0][i - 1] + a[i - 1]
for i in range(1, l2):
    b[i] = t[1][i - 1] + b[i - 1]
for i in range(1, l3):
    c[i] = t[2][i - 1] + c[i - 1]
for i in range(1, l4):
    d[i] = t[3][i - 1] + d[i - 1]
ans = 0
for i in range(l1):
    for j in range(l2):
        for k in range(l3):
            for l in range(l4):
                if ss * (i + j + k + l) + (j + 2 * k + 3 * l) <= w:
                    ans = max(ans, a[i] + b[j] + c[k] + d[l])
print(ans)

Measured memory_bytes: 3188
#pragma region include
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <string>
#include <queue>
#include <stack>
#include <cmath>
#include <set>
#include <cstdio>
#define ALL(obj) (obj).begin(),(obj).end()
#define RALL(obj) (obj).rbegin(),(obj).rend()
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define MOD 1000000007
#define INF 1000000000
#define LLINF 4000000000000000000
using namespace std;
typedef long long ll;
typedef pair<int, int> PII;
typedef vector<int> VI;
typedef vector<VI> VVI;
#pragma endregion

//#define __DEBUG__
#ifdef  __DEBUG__
#define dump(x) cerr << #x << " = " << (x) << " [" << __LINE__ << ":" << __FUNCTION__ << "] " << endl;
// vector出力
template<typename T>
ostream& operator << (ostream& os, vector<T>& v) {
    os << "{";
    REP(i, (int)v.size()) { os << v[i] << (i < v.size() - 1 ? ", " : ""); }
    os << "}";
    return os;
}
// pair出力
template<typename T, typename U>
ostream& operator << (ostream& os, pair<T, U>& p) {
    return os << "(" << p.first << ", " << p.second << ")";
}
// map出力
template<typename T, typename U>
ostream& operator << (ostream& os, map<T, U>& map_var) {
    os << "{";
    for (auto itr = map_var.begin(); itr != map_var.end(); itr++) {
        os << "(" << itr->first << ", " << itr->second << ")";
        itr++;
        if (itr != map_var.end()) os << ", ";
        itr--;
    }
    os << "}";
    return os;
}
// set 出力
template<typename T>
ostream& operator << (ostream& os, set<T>& set_var) {
    os << "{";
    for (auto itr = set_var.begin(); itr != set_var.end(); itr++) {
        os << *itr;
        ++itr;
        if (itr != set_var.end()) os << ", ";
        itr--;
    }
    os << "}";
    return os;
}
#endif

int main() {
    cin.tie(0); ios::sync_with_stdio(false);
    int A, P; cin >> A >> P;
    int ans = 0,cnt = 0;
    cnt += A * 3;
    cnt += P;
    ans = cnt / 2;
    cout << ans << endl;
    getchar(); getchar();
}

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

bool Function(int ,int ,int ,int[] ,int );

int main(void)
{
    int n,q;
    cin>>n;
    int num[n];
    for(int i=0;i<n;i++)
    {
        cin>>num[i];
    }
    cin>>q;
    int m[q];
    for(int i=0;i<q;i++)
    {
        cin>>m[i];
    }
    for(int i=0;i<q;i++)
    {
        if(Function(m[i],0,0,num,n))cout<<"yes"<<endl;
        else cout<<"no"<<endl;
    }
    return 0;
}

bool Function(int m,int k,int i,int num[],int n)
{
    if(m==k)return true;
    else if(i==n)return false;
    else
    {
        if(Function(m,k+num[i],i+1,num,n))
        {
            return true;
        }
        if(Function(m,k,i+1,num,n))
        {
            return true;
        }
        return false;
    }
}



Measured memory_bytes: 3092
#include<iostream>
#include<string>
#include<algorithm>
#include<math.h>
#include<queue>
#include<set>
#include<map>
#include<random>
#include<functional>
#include<utility>

typedef long long ll;

#define rep(i,n) for(int i=0; i<n; i++)
#define pb push_back
#define P pair<int, int>
#define PLI pair<ll, int>
#define PLL pair<ll, ll>
#define VI vector<int>
#define VII vector<VI>

using namespace std;


string JOI = "JOI";
int M, N;
string frag[1005], mon[2];
int old[1005][1005] = {};
int main() {
	cin >> M >> N;
	rep(i, M) cin >> frag[i];
	rep(i, 2) cin >> mon[i];
	int cnt = 0;
	rep(i, M-1) rep(j, N-1) {
		if (!(frag[i][j] == mon[0][0] && frag[i][j + 1] == mon[0][1] && frag[i + 1][j] == mon[1][0] && frag[i + 1][j + 1] == mon[1][1]))
			continue;
		cnt++;
		rep(k, 2)rep(l, 2) old[i + k][j + l]++;
	}
	int ans = cnt;
	rep(i, M)rep(j, N) {
		rep(o, 3) {
			if (frag[i][j] == JOI[o]) continue;
			char bf = frag[i][j];
			frag[i][j] = JOI[o];
			int tmp = cnt - old[i][j];
			rep(k, 2) rep(l, 2) {
				int x = i - k, y = j - l;
				if (x < 0 || y < 0 || M - 1 <= x || N - 1 <= y) continue;
				if (frag[x][y] == mon[0][0] && frag[x][y + 1] == mon[0][1] && frag[x + 1][y] == mon[1][0] && frag[x + 1][y + 1] == mon[1][1])
					tmp++;
			}
			ans = max(ans, tmp);
			frag[i][j] = bf;
		}
	}
	cout << ans << endl;

	return 0;
}



Measured memory_bytes: 8016
n = int(input())
listA=[]
index=0
while index < n:
    listA.append(int(input()))
    index+=1
listA.sort()


if len(listA)%2==0:
    sum = listA[len(listA)//2]-listA[len(listA)//2-1]
    index=0
    while index < len(listA):
        if index == len(listA)//2-1 or index == len(listA)//2:
            pass
        else:
            if index < len(listA)//2:
                sum-=2*listA[index]
            else:
                sum+=2*listA[index]
        index+=1
    print(sum)
else:
    sum=-1*(listA[len(listA)//2]+listA[len(listA)//2-1])
    index = 0
    while index < len(listA):
        if index == len(listA)//2-1 or index == len(listA)//2:
            pass
        else:
            if index < len(listA)//2:
                sum -= 2*listA[index]
            else:
                sum += 2*listA[index]
        index += 1
    sumB = listA[len(listA)//2]+listA[len(listA)//2+1]
    index2 = 0
    while index2 < len(listA):
        if index2 == len(listA)//2 or index2 == len(listA)//2+1:
            pass
        else:
            if index2 < len(listA)//2:
                sumB -= 2*listA[index2]
            else:
                sumB += 2*listA[index2]
        index2 += 1

    print(max(sum, sumB))

Measured memory_bytes: 7536
#include<stdio.h>
#define Max 44
int F[Max];

void fivonacci(int n){
	int i;
	F[0] = 1;
	F[1] = 1;
	for(i = 2; i <= n; i++){
		F[i] = F[i - 2] + F[i - 1]; 
	}
	printf("%d\n", F[n]);
}

	int main(){
		int n;
		
		scanf("%d", &n);
		fivonacci(n);
		return 0;
	}

Measured memory_bytes: 596
# ABC112B - Time Limit Exceeded
n, t = list(map(int, input().rstrip().split()))
data = [list(map(int, input().rstrip().split())) for _ in range(n)]
match = []

for i in range(n):
    if data[i][1] <= t:
        match.append(data[i][0])

if match == []:
    print("TLE")
else:
    print(min(match))

Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  
  int n=0;
  int le;
  int max =0;
  int sum =0;
  
  cin >> n;
  for(int i = 0;i<n;++i){
    cin >> le;
    sum += le;
      if(le > max){
        max = le;
      }
  }
  if(max<sum-max){
    cout << "Yes" << endl;
  }
  else cout <<"No"<<endl;
  
}  


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

int main() {
  int A, B;
  int sum = 0;
  cin >> A >> B;
  for (int i=A; i<=B; i++){
    if(i/10000 == i%10 && i/1000 % 10 == i/10 % 10){
      sum += 1;
    }
  }
  cout << sum << endl;
  
}

Measured memory_bytes: 256
use std::str::FromStr;
use std::fmt::Debug;
use std::cmp;
use std::collections::HashMap;


#[allow(dead_code)]
fn read_as_vec<T>() -> Vec<T>
where T: FromStr, <T as FromStr>::Err : Debug{
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).unwrap();
    s.trim().split_whitespace().map(|c| T::from_str(c).unwrap()).collect()

}

fn main(){
    let n: usize = read_as_vec()[0];
    let mut hash = HashMap::new();
    let a: Vec<u64> = read_as_vec();
    let mut counter = 0;

    for elem in a{
        *hash.entry(elem).or_insert(0) += 1;
    }

    for (key, val) in hash.into_iter(){
        if val < key{
            counter += val;
        }else{
            counter += val - key;
        }
    }

    println!("{}", counter);
}


Measured memory_bytes: 12540
#light "off"
open System;;
open System.IO;;

let reader = new StreamReader(new BufferedStream(Console.OpenStandardInput ()))
let writer = new StreamWriter(new BufferedStream(Console.OpenStandardOutput ()))

let skipSpaces () = while reader.Peek () <= int ' ' do reader.Read () |> ignore done;;
let read f = skipSpaces (); [|while reader.Peek () > int ' ' do yield char (reader.Read ()) done |] |> System.String |> f;;
let readint () = skipSpaces (); let s = if reader.Peek() = int '-' then (ignore (reader.Read()); -1) else 1 in let mutable ans = 0 in while reader.Peek () > int ' ' do ans <- ans * 10 + (reader.Read () - int '0'); done; s * ans;;
let write (s : string) = writer.Write s;;
let writeln (s : string) = writer.WriteLine s;;

let S = read string;;
let N = S.Length;;

let mutable i = 0;;
let ans = Array.create N 0;;

while i < N do
  let j = i in
  while i < N && S.[i] = 'R' do i <- i + 1 done;
  let k = i in
  while i < N && S.[i] = 'L' do i <- i + 1 done;
  let a = k - j in
  let b = i - k in
  ans.[k-1] <- ((a + 1) / 2 + b / 2);
  ans.[k] <- (a / 2 + (b + 1) / 2);
done;;

ans |> Array.map string |> String.concat " " |> writeln;;

reader.Close();;
writer.Close();;

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

#define rep(i,n) for (int i = 0; i < (n); ++i)
typedef long long ll;
const int MOD = 1e9+7;

int main() {
    ll N,r=0;
    cin >> N;
    vector<ll> A(N);
    rep(i,N)
        cin >> A.at(i);
    
    rep(i,60) {
        ll c0=0,c1=0;
        rep(j,N) {
            if((A.at(j)>>i) & 1)
                c1++;
            else
                c0++;
        }
        r += (((1ll<<i)%MOD) * ((c0*c1)%MOD)) % MOD;
    }

    cout << r%MOD << endl;
}

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

int main() {
	int n;
	cin >> n;
	map<string, vector<pair<int, int>>> t;
	rep(i, n) {
		string s;
		int p;
		cin >> s >> p;
		t[s].push_back(make_pair(p, i+1));
	} 
	for(auto a: t) {
		auto now = a.second;
		sort(all(now));
		reverse(all(now));
		for(auto p: now) {
			cout << p.second << endl;
		}
	}
	
	return 0;
}

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

#define FOR(i,a,b) for (int i = (a); i < (b); ++i)
#define F0R(i,a) FOR(i,0,a)
#define ROF(i,a,b) for (int i = (b)-1; i >= (a); --i)
#define R0F(i,a) ROF(i,0,a)

using ll = long long;
using ld = long double;
ll INF = LLONG_MAX;

using vi = vector<int>;
using vll = vector<ll>;
using pii = pair<int, int>;

namespace output {
	void pr(int x) { cout << x; }
	void pr(long x) { cout << x; }
	void pr(ll x) { cout << x; }
	void pr(unsigned x) { cout << x; }
	void pr(unsigned long x) { cout << x; }
	void pr(unsigned long long x) { cout << x; }
	void pr(float x) { cout << x; }
	void pr(double x) { cout << x; }
	void pr(ld x) { cout << x; }
	void pr(char x) { cout << x; }
	void pr(const char* x) { cout << x; }
	void pr(const string& x) { cout << x; }
	void pr(bool x) { pr(x ? "true" : "false"); }
	template<class T> void pr(const complex<T>& x) { cout << x; }
	
	template<class T1, class T2> void pr(const pair<T1,T2>& x);
	template<class T> void pr(const T& x);
	
	template<class T, class... Ts> void pr(const T& t, const Ts&... ts) { 
		pr(t); pr(ts...); 
	}
	template<class T1, class T2> void pr(const pair<T1,T2>& x) { 
		pr("{",x.f,", ",x.s,"}"); 
	}
	template<class T> void pr(const T& x) { 
		pr("{"); // const iterator needed for vector<bool>
		bool fst = 1; for (const auto& a: x) pr(!fst?", ":"",a), fst = 0; 
		pr("}");
	}
	
	void print() { pr("\n"); } // print w/ spaces
	template<class T, class... Ts> void print(const T& t, const Ts&... ts) { 
		pr(t); if (sizeof...(ts)) pr(" "); print(ts...); 
	}
}

using namespace output;

int main() {
    ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
	int x; cin >> x;
	print(1-x);
}

Measured memory_bytes: 3652
/**
 *		author:  zvm
 *		created: 25.09.2020 18:15:23
**/

#include <bits/stdc++.h>

using namespace std ;

int main() 
{
	ios_base::sync_with_stdio(false);
	cin.tie(nullptr);
	cout.tie(nullptr);	

	int n, a, b ;
	cin >> n >> a >> b ;
	cout << min( n*a, b ) << endl ;
}


Measured memory_bytes: 3616
# -*- coding: utf-8 -*-

#############
# Libraries #
#############

import sys
input = sys.stdin.readline

import math
#from math import gcd
import bisect
from collections import defaultdict
from collections import deque
from functools import lru_cache


#############
# Constants #
#############

MOD = 10**9+7
INF = float('inf')

#############
# Functions #
#############

######INPUT######
def inputI(): return int(input().strip())
def inputS(): return input().strip()
def inputIL(): return list(map(int,input().split()))
def inputSL(): return list(map(str,input().split()))
def inputILs(n): return list(int(input()) for _ in range(n))
def inputSLs(n): return list(input().strip() for _ in range(n))
def inputILL(n): return [list(map(int, input().split())) for _ in range(n)]
def inputSLL(n): return [list(map(str, input().split())) for _ in range(n)]

######OUTPUT######
def Yes(): print("Yes"); return
def No(): print("No"); return

#####Inverse#####
def inv(n): return pow(n, MOD-2, MOD)

######Combination######
kaijo_memo = []
def kaijo(n):
  if(len(kaijo_memo) > n):
    return kaijo_memo[n]
  if(len(kaijo_memo) == 0):
    kaijo_memo.append(1)
  while(len(kaijo_memo) <= n):
    kaijo_memo.append(kaijo_memo[-1] * len(kaijo_memo) % MOD)
  return kaijo_memo[n]

gyaku_kaijo_memo = []
def gyaku_kaijo(n):
  if(len(gyaku_kaijo_memo) > n):
    return gyaku_kaijo_memo[n]
  if(len(gyaku_kaijo_memo) == 0):
    gyaku_kaijo_memo.append(1)
  while(len(gyaku_kaijo_memo) <= n):
    gyaku_kaijo_memo.append(gyaku_kaijo_memo[-1] * pow(len(gyaku_kaijo_memo),MOD-2,MOD) % MOD)
  return gyaku_kaijo_memo[n]

def nCr(n,r):
  if(n == r):
    return 1
  if(n < r or r < 0):
    return 0
  ret = 1
  ret = ret * kaijo(n) % MOD
  ret = ret * gyaku_kaijo(r) % MOD
  ret = ret * gyaku_kaijo(n-r) % MOD
  return ret

######Factorization######
def factorization(n):
  arr = []
  temp = n
  for i in range(2, int(-(-n**0.5//1))+1):
    if temp%i==0:
      cnt=0
      while temp%i==0: 
        cnt+=1 
        temp //= i
      arr.append([i, cnt])
  if temp!=1:
    arr.append([temp, 1])
  if arr==[]:
    arr.append([n, 1])
  return arr

#####MakeDivisors######
def make_divisors(n):
  divisors = []
  for i in range(1, int(n**0.5)+1):
    if n % i == 0:
      divisors.append(i)
      if i != n // i: 
        divisors.append(n//i)
  return divisors

#####LCM#####
def lcm(a, b):
    return a * b // gcd (a, b)

#####BitCount#####
def count_bit(n):
  count = 0
  while n:
    n &= n -1
    count += 1
  return count

#####ChangeBase#####
def Base_10_to_n(X, n):
  if X//n:
    return Base_10_to_n(X//n, n)+[X%n]
  return [X%n]

def Base_n_to_10(X, n):
  return sum(int(str(X)[-i])*n**i for i in range(len(str(X))))

#####IntLog#####
def int_log(n, a):
  count = 0
  while n>=a:
    n //= a
    count += 1
  return count

#############
# Main Code #
#############

N = inputI()
print( min(int_log((x&(-x)),2) for x in inputIL() ))


Measured memory_bytes: 38512
#include <iostream> // cin, cout, cerr, clog
#include <algorithm> // minmax, sort, swap
#include <numeric> // iota, accumulate, inner_product
#include <cstdio> // printf, scanf
#include <climits> // INT_MIN, LLONG_MIN
#include <cmath> // long, trig, pow
#include <string> // string, stoi, to_string
#include <vector> // vector
#include <queue> // queue, priority_queue
#include <stack> // stack
#include <map> // key-value pairs sorted by keys
#include <set> // set
#include <unordered_map> // hashed by keys
#include <unordered_set> // hashed by keys
#include <iomanip> // cout<<setprecision(n)

#define rep(i,n) for(int i = 0; i < n; i++)
#define ENDL "\n"
#define print(i) std::cout << (i) << "\n"

#define int long long // at least int64 > 9*10^18
#define all(v) v.begin(), v.end()
#define INF 1010101010

signed main() {
  int n;
  std::cin >> n;
  std::vector<int> height(n);
  std::vector<int> dp(n+2,INF);
  rep(i,n) std::cin >> height[i];
  dp[0] = 0;
  rep(i,n) {
    dp[i+1] = std::min(dp[i+1],dp[i] + std::abs(height[i]-height[i+1]));
    dp[i+2] = std::min(dp[i+2],dp[i] + std::abs(height[i]-height[i+2]));
  }
  print(dp[n-1]);
  return 0;
}

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

#define DEBUG(x) cerr << #x << ": " << x << endl;
#define ll long long

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

    if (a.size() > b.size()) {
        puts("GREATER");
        return 0;
    } else if (a.size() < b.size()) {
        puts("LESS");
        return 0;
    } else if (a > b) {
        puts("GREATER");
        return 0;
    } else if (a < b) {
        puts("LESS");
        return 0;
    }

    puts("EQUAL");

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;++i)
#define rrep(i,n) for(int i=n-1;i>0;--i)
#define yesno(flg) if(flg){cout<<"Yes"<<endl;}else{cout<<"No"<<endl;}
#define Vi vector<int>
#define Vd vector<double>
#define Vl vector<long long>
#define pb(a) push_back(a)
using namespace std;

typedef long long ll;
typedef pair<int,int> Pi;
typedef pair<int,Pi> Pii;
typedef pair<ll,int> Pl;
typedef pair<int,Pl> Pil;
const int inf=1000000000;
const ll inf2=1000000000000000;
const int np=1000000007;
struct edge{
	int myc,to,c,cost;
};
struct pos{
	int to,cost,color;
};
int dy[]={0, 0, 1, -1};
int dx[]={1, -1, 0, 0};

int bit[200001]={};
int n,c;
int sum(int i){
	int s=0;
	while(i>0){
		s += bit[i];
		i -= i & -i;
	}
	return s;
}

void add(int i, int x){
	while(i <=n+c){
		bit[i] += x;
		i += i & -i;
	}
}

int main() {
	cin>>n>>c;
	Vl P(n+1,0);
	vector<Pl> rank(n+c,Pl(inf2,inf));
	rep(i,n)rank[i]=Pl(0,n-i-1);

	vector<Pil> cmd(c);
	int nrank=n;
	rep(i,c){
		int a1,a2;
		ll a3=0;
		cin>>a1;
		if(a1==1)cin>>a2;
		if(a1==0){
			cin>>a2>>a3;
			P[a2]+=a3;
			rank[nrank]=Pl(P[a2],n-a2);
			nrank++;
		}
		cmd[i]=Pil(a1,Pl(a3,a2));
	}
	sort(rank.begin(),rank.end());
	//making BIT
	rep(i,n)add(i+1,1);

//	rep(i,12){
//			cout<<rank[i].first<<" "<<rank[i].second<<endl;
//		}

	Vl P2(n+1,0);
	rep(i,c){
		if(cmd[i].first==0){
			//change BIT
			int t=cmd[i].second.second;
			ll p=cmd[i].second.first;
			auto it=lower_bound(rank.begin(),rank.end(),Pl(P2[t],n-t));
//						cout<<it-rank.begin()+1<<endl;

			add(it-rank.begin()+1,-1);
			P2[t]+=p;
			it=lower_bound(rank.begin(),rank.end(),Pl(P2[t],n-t));
			add(it-rank.begin()+1,1);
		}else{
			int num=n-cmd[i].second.second+1;
			int high=n+c;
			int low=0;
			while(high-low>1){
				int mid=(high+low)/2;
				int r=sum(mid);
				if(r<num){
					low=mid;
				}else{
					high=mid;
				}
			}
//			cout<<high<<endl;
			cout<<n-rank[high-1].second<<" "<<rank[high-1].first<<endl;
		}
	}
	return 0;
}



Measured memory_bytes: 10744
def main():
    N, M = (int(i) for i in input().split())

    def gcd(x, y):
        if y == 0:
            return x
        while y != 0:
            x, y = y, x % y
        return x

    def trial_division(n):
        divs = []
        for i in range(1, int(n**0.5)+1):
            if n % i == 0:
                divs.append(i)
                if i != n//i:
                    divs.append(n//i)
        return divs

    if M % N == 0:
        return print(M//N)

    divs = [i for i in trial_division(M) if i >= N]
    print(M//min(divs))


if __name__ == '__main__':
    main()


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

int main() {

    int h, w, c;
    cin >> w >> h >> c;

    int v = min(w, h);
    while(true) {
        if(w % v == 0 && h % v == 0) {
            break;
        }
        v--;
    }

    cout << w * h / (v * v) * c << endl;
}

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

using namespace std;

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

#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep2(i,n) for(int i=1;i<=(int)(n);i++)
#define rep3(i,n) for(int i=0;i<=(int)(n);i++)
#define REP(i,m,n) for(int i=m;i<(int)(n);i++)
#define repll(i,n) for(ll i=0;i<(ll)(n);i++)
#define repll2(i,n) for(ll i=1;i<=(ll)(n);i++)
#define REPLL(i,m,n) for(ll i=m;i<(ll)(n);i++)
#define INF (int)1e9  //
#define LINF (ll)4e18  //
#define MOD (int)(1e9)+7
#define MP make_pair
#define YES(n) cout << ((n) ? "YES" : "NO"  ) << endl
#define Yes(n) cout << ((n) ? "Yes" : "No"  ) << endl
#define PI 3.1415926535898

//------------------------------------------------------

int main() {
    int h, w;
    cin >> h >> w;

    rep(i, h) {

        rep(j, w) {
            string s;
            cin >> s;
            if (s == "snuke") {
                cout << (char) (j + 'A') << i + 1 << endl;
                return 0;
            }
        }

    }

    return 0;
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main() {
    int n;
    cin >> n;
    string s;
    cin >> s;
    int i = 0;
    int j = n - 1;
    int cnt = 0;
    while (i < n && j >= 0 && i < j) {
    	while (i < n && s[i] == 'R') {
    		++i;
    	}
    	while (j >= 0 && s[j] == 'W') {
    		--j;
    	}
    	if (i < n && j >= 0 && i < j) {
    		swap(s[i], s[j]);
    		cnt++;
    	}
    }
    cout << cnt << endl;
}

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

int abs(int N)
{
       return (N>0)? N: (-1)*N;
}

main()
{
      int x, a, b, d_a, d_b;
      cin >> x >>a >>b;

      d_a = abs(x-a) ;
      d_b = abs(x-b) ;

      (d_a <= d_b) ? cout << "A" : cout << "B" ;
}  

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

int main()
{
double l ;
cin >> l ;
l/=3;
ans=l*l*l;
cout<<fixed<<setprecision(12)<<ans<<endl;
return 0;
}

Measured memory_bytes: 256
n, k = gets.chomp.split(" ").map(&:to_i)
h = gets.chomp.split(" ").map(&:to_i)
INF = 10 ** 12
dp = Array.new(n) { INF }
dp[0] = 0
1.upto(n - 1) do |i|
  min = INF
  [i - k, 0].max.upto(i - 1) do |j|
    cost = dp[j] + (h[i] - h[j]).abs
    min = cost if cost < min
  end
  dp[i] = min
end
puts dp[n - 1]

Measured memory_bytes: 12036
W, H, N = map(int, input().split())
box = [[0]*W] * H

for i in range(N):
    x, y, a = map(int, input().split())
    if a == 1:
        for j in range(H):
            box[j] = [1] * x + box[j][x:]
    elif a == 2:
        for j in range(H):
            box[j] = box[j][:x] + [1] * (W-x)
    elif a == 3:
        for j in range(y):
            box[j] = [1] * W
    else:
        for j in range(y, H):
            box[j] = [1] * W

Sum = 0
for i in box:
    Sum += sum(i)

print(W*H - Sum)


Measured memory_bytes: 3064
#ifndef _GLIBCXX_NO_ASSERT
#include <cassert>
#endif
#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>

#if __cplusplus >= 201103L
#include <ccomplex>
#include <cfenv>
#include <cinttypes>
#include <cstdbool>
#include <cstdint>
#include <ctgmath>
#include <cwchar>
#include <cwctype>
#endif

// C++
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>

#if __cplusplus >= 201103L
#include <array>
#include <atomic>
#include <chrono>
#include <condition_variable>
#include <forward_list>
#include <future>
#include <initializer_list>
#include <mutex>
#include <random>
#include <ratio>
#include <regex>
#include <scoped_allocator>
#include <system_error>
#include <thread>
#include <tuple>
#include <typeindex>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>
#endif
using namespace std;

typedef long long ll;
//typedef pair<int,int> Pint;
typedef pair<ll, ll> P;
//typedef pair<int, pair<int, int>> P;
//typedef tuple<int,int,int> T;
typedef vector<ll> vec;
typedef vector<vec> mat;
#define rep(i, n) for(ll i = 0; i < n; i++)
#define revrep(i, n) for(ll i = n-1; i >= 0; i--)
ll max(ll a, ll b){return (a > b) ? a : b;}
ll min(ll a, ll b){return (a < b) ? a : b;}
ll Mypow(ll x, ll k){
  ll res = 1;
  while(k > 0){
    if(k % 2) res *= x;
    x *= x;
    k /= 2;
  }
  return res;
}

ll gcd(ll a, ll b){//計算量はO(log(max(a,b))
    if(b == 0) return a;
    return gcd(b, a % b);
}

ll INFL = 1LL << 60;//10^18 = 2^60
int INF = 1 << 30;//10^9
ll MOD  = 1000000007;
//vector<int> dy = {0,0,1,-1};
//vector<int> dx = {1,-1,0,0};

ll kai(ll x){
  if(x == 1) return 1;
  return x * kai(x-1) % MOD;
}

int main(){
  ll N; cin >> N;
  ll ans = 0;
  ans += N / 11 * 2;
  N %= 11;
  if(N > 6) ans += 2;
  else if(N > 0) ans++;
  cout << ans << endl;
}


Measured memory_bytes: 256
n = int(input())
a = [int(item) for item in input().split()]
a_s = sorted(a)

low_med = a_s[n//2 - 1]
high_med = a_s[n//2]

for item in a:
  if low_med == high_med:
    print(low_med)
  elif item <= low_med:
    print(high_med)
  elif item >= high_med:
    print(low_med)

Measured memory_bytes: 26016
#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<queue>
#include<stack>
#include<set>
#include<map>
#include<vector>
#include<cmath>
using namespace std;
const int maxn=2e5+5;
typedef long long ll;
vector<ll>vec1,vec2,vec3;
ll n,k;
bool check(ll x){
	ll x1=vec1.size();
	ll x2=vec2.size();
	ll x3=vec3.size();
	ll pos=0;
     if(x==0){
		 pos+=(x1*x3);
		 pos+=(x2*x1+x3*x2);
		 pos+=(x2*(x2-1))/2;
		 return pos>=k;
	 }
	 else if(x>0){
		 pos+=(x1*x3);//负数的数量
		 pos+=(x2*x1+x3*x2);//0的数量
		 pos+=(x2*(x2-1))/2;//0的数量
		 for(int i=0;i<x1;i++){
			 ll tmp;
			 if(x%vec1[i]){
                 tmp=x/vec1[i];
			 }
			 else{
			     tmp=x/vec1[i];
			 }
             if(lower_bound(vec1.begin()+i+1,vec1.end(),tmp)==vec1.end()){
                 pos+=0;
			 }
			 else{
				 pos+=vec1.end()-lower_bound(vec1.begin()+i+1,vec1.end(),tmp);
			 }
		//	 pos+=x1-i-(lower_bound(vec1.begin()+i+1,vec1.end(),tmp)-(vec1.begin()+i));
		 }
		  for(int i=0;i<x3;i++){
			 ll tmp;
			 if(x%vec3[i]){
                 tmp=x/vec3[i];
			 }
			 else{
			     tmp=x/vec3[i];
			 }
			 if(upper_bound(vec3.begin()+i+1,vec3.end(),tmp)==vec3.end()){
                 pos+=vec3.end()-(vec3.begin()+i+1);
             }
             else{
                 pos+=upper_bound(vec3.begin()+i+1,vec3.end(),tmp)-1-vec3.begin()-i;
             }
			
		 }
		// cout<<"x:"<<x<<" "<<"pos:"<<pos<<endl;
		 return pos>=k;
	 }
	 else{
		 for(int i=x1-1;i>=0;i--){
			  ll tmp;
			 if(x%vec1[i]){
                 tmp=x/vec1[i]+1;
			 }
			 else{
			     tmp=x/vec1[i];
			 }
			if(lower_bound(vec3.begin(),vec3.end(),tmp)==vec3.end()){
                 pos+=0;
			 }
			 else{
				 pos+=vec3.end()-lower_bound(vec3.begin(),vec3.end(),tmp);
			 }
		 }
		// cout<<x<<" "<<pos<<endl;
		 return pos>=k;
	 }
}
int main(){
	
	cin>>n>>k;
	ll x;
	for(int i=1;i<=n;i++){
        scanf("%lld",&x);
		if(x<0){
          vec1.push_back(x);
		}
		else if(x==0){
          vec2.push_back(x);
		} 
		else{
			vec3.push_back(x);
		}
	}
	sort(vec1.begin(),vec1.end());
	sort(vec2.begin(),vec2.end());
	sort(vec3.begin(),vec3.end());
	ll l=-1e18,r=1e18;
	ll mid;
	while(l<=r){
		mid=(l+r)>>1;
		if(check(mid))r=mid-1;
		else{
            l=mid+1;
		}
		
	}
//	cout<<r+1<<endl;
	if(check(r+1)){
		cout<<r+1<<endl;
	}
	else{
		cout<<r<<endl;
	}
	// mid=(l+r)>>1;
	// cout<<mid<<endl;
	// if(check(mid)){
	// 	cout<<mid<<endl;
	// }
	// else if(check(mid+1)){
	// 	cout<<mid+1<<endl;
	// }
	// else{
	// 	cout<<mid-1<<endl;
	// }
 	// if(check(mid+1)){
	// 	cout<<mid+1<<endl;
	// }
	// else if(check(mid)){
	// 	cout<<mid<<endl;
	// }
	// else
	//     cout<<mid-1<<endl;

	return 0;
}

Measured memory_bytes: 2548
#include <stdio.h>

int main(void){
	int num[5] , i , j , buf;
	scanf("%d %d %d %d %d" , &num[0] , &num[1] , &num[2] , &num[3] , &num[4]);
	for(i=0;i<5;i++){
		for(j=0;j<5;j++){
			if(num[j] < num[j+1]){
				buf = num[j];
				num[j] = num[j+1];
				num[j+1] = buf;
			}
		}
	}
	printf("%d %d %d %d %d\n" , num[0] , num[1] , num[2] , num[3] , num[4]);
	return 0;
}

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

using namespace std;

int main()
{
    int n, k, x, y;
    cin >> n >> k >> x >> y;

    if(n<k) cout << x*n << endl;
    else cout << x*k + (n-k)*y << endl;

    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
const int N=2e5+5;
int n,m,a[N],st[N],b[N],hs[N],tot,head[N],nex[N<<1],to[N<<1],wi[N<<1];
void add(int u,int v,int w){to[++tot]=v;nex[tot]=head[u];head[u]=tot;wi[tot]=w;}
bool vis[N],use[N];
int lowb(int x)
{
    return lower_bound(hs+1,hs+1+n,x)-hs;
}
int uppb(int x)
{
    return upper_bound(hs+1,hs+1+n,x)-hs;
}
bool dfs(int u)
{
    vis[u]=true;
    int x=st[u];
    for(int i=head[u];i;i=nex[i])
    {
        int v=to[i];
        if(!vis[v]&&dfs(v))
        {
            x^=1;use[wi[i]]=true;
        }
    }
    return x;
}
int main()
{
    scanf("%d%d",&n,&m);
    for(int i=1;i<=n;i++)
        scanf("%d%d",&a[i],&b[i]),hs[i]=a[i];
    sort(hs+1,hs+1+n);
    for(int i=1;i<=n;i++)
        a[i]=lowb(a[i]),st[a[i]]=b[i];
    for(int i=n+1;i>=1;i--)
        st[i]^=st[i-1];
    //for(int i=1;i<=n+1;i++)
    //    if(st[i]==st[i-1])
    //        b[i]=b[i-1];
    //else b[i]=b[i-1]^1;
    //for(int i=1;i<=n+1;i++)
    //    printf(i==n+1?"%d\n":"%d ",b[i]);
    for(int i=1;i<=m;i++)
    {
        int l,r;scanf("%d%d",&l,&r);
        l=lowb(l);
        r=uppb(r)-1;
        if(l<=r)
            add(l,r+1,i),add(r+1,l,i);
    }
    for(int i=1;i<=n+1;i++)
        if(!vis[i]&&dfs(i))
    {
        printf("-1\n");return 0;
    }
    int ans=0;
    for(int i=1;i<=m;i++)
        if(use[i]) ans++;
    printf("%d\n",ans);
    for(int i=1;i<=m;i++)
    if(use[i])
        printf("%d ",i);
}


Measured memory_bytes: 11008
n,m=map(int,input().split())
a=[input() for i in range(n)]
b=[input() for i in range(m)]

for i in range(n-m+1):
    for j in range(n-m+1):
        flag=True
        for k in range(m):
            for l in range(m):
                if a[i+k][j+l]!=b[k][l]:
                    flag=False
                    break
            if not flag:
                break
        if flag:
            print('Yes')
            break
    if flag:
        break

if not flag:
    print('No')


Measured memory_bytes: 3064
package main

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

func parseFloat64(s string) (n float64) {
	n, _ = strconv.ParseFloat(s, 64)
	return n
}

func sum(ary []float64) (t float64) {
	for _, v := range ary {
		t += v
	}
	return
}
func main() {
	var n int
	var x float64
	fmt.Scan(&n)
	s := bufio.NewScanner(os.Stdin)
	s.Split(bufio.ScanWords)

	w := make([]float64, n)
	for i := range w {
		s.Scan()
		w[i] = parseFloat64(s.Text())
	}
	total := sum(w)
	mid := total / 2

	for i := 0; i < n; i++ {
		x += w[i]
		if x > mid {
			if x-mid < mid-(x-w[i]) {
				fmt.Println(x - (total - x))
				break
			} else {
				fmt.Println(total - 2*(x-w[i]))
				break
			}
		}
	}
}


Measured memory_bytes: 640
<?php
	fscanf(STDIN, "%d", $n);
	if($n < 2){
      echo 1;
    }elseif($n % 2 === 0){
      echo 0.5;
    }elseif($n % 2 !== 0){
      echo floor(($n/2)+1)/$n;
    }
?>

Measured memory_bytes: 4604
#include<bits/stdc++.h>
using namespace std;
#define int long long
signed main(){
  int T,n;
  int s[100010],t[100010];
  cin>>T>>n;
  for(int i=0;i<n;i++){
    cin>>s[i]>>t[i];
  }
  int l=0,r=0;
  int sum=0;
  int ans=0;
  for(;l<n;l++){
    if(t[l]-s[l]>=T){
      ans=T;
      break;
    }
    for(;r<n;r++){
      if(t[r]>s[l]+T)break;
      sum+=t[r]-s[r];
    }
    if(t[r]>s[l]+T)ans=max(ans,sum+max(0LL,s[l]+T-s[r]));
    ans=max(ans,sum);
    sum-=t[l]-s[l];
  }
  cout<<ans<<endl;
  return 0;
}



Measured memory_bytes: 4660
#include <iostream>

using namespace std;

int main(int argc, char const *argv[])
{
    double w, h, x, y;
    cin >> w >> h >> x >> y;
    double res = 0;
    int tf = 0;
    res = w*h/2;
    if (x==w/2&&y==h/2) tf = 1;

    printf("%lf %d", res, tf);
    return 0;
}

Measured memory_bytes: 256
N = int(input())
ans = True
t1,x1,y1 = 0,0,0
for i in range(N):
    t2,x2,y2 = map(int, input().split())
    if t2-t1 >= abs(x2-x1)+abs(y2-y1) and ((t2-t1)-(abs(x2-x1)+abs(y2-y1)))%2 == 0:
        None
    else:
        ans = False
        break
    t1,x1,y1 = t2,x2,y2
    #print(i)
print("Yes" if ans==True else "No")

Measured memory_bytes: 3064