akhauriyash/Code-Regression huggingface dataset:
#include <stdio.h>
#include <bits/stdc++.h>

using namespace std;

const int MAXN = 200005;

int n;
int a[MAXN];

long long ans;

int main()
{
	scanf("%d",&n);
	for (int i = 1;i <= n;i++)
		scanf("%d",&a[i]);
	if (a[1])
	{
		puts("-1");
		return 0;
	}
	for (int i = 2;i <= n;i++)
		if (a[i] > a[i - 1] + 1)
		{
			puts("-1");
			return 0;
		}
	for (int i = 2;i <= n;i++)
		if (a[i] != a[i - 1] + 1)
			ans += a[i];
		else
			ans++;
	printf("%lld\n",ans);
	return 0;
}

Measured memory_bytes: 1024
n = int(input())
x = list(map(int, input().split()))
y = list(map(int, input().split()))
p = 0
q = 0
p1 = 0
p2 = 0
p3 = 0
max = 0
import math
for i, j in zip(x, y):
    p1 += abs(i - j)
    p += abs((i - j) ** 2)
    p2 = math.sqrt(p)
    q += abs((i - j) ** 3)
    p3 = math.pow(q, 1.0/3.0)
    if abs(i - j) > max:
        max = abs(i - j)

print(p1)
print(p2)
print(p3)
print(max)

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

int main() {
    ll n;
    cin >> n;
    vector<pair<ll, ll>> v(n);
    for (ll i = 0;i < n;++i)cin >> v[i].first >> v[i].second;
    vector<ll> x;
    vector<ll> y;
    for (auto p : v) {
        x.push_back(p.first);
        y.push_back(p.second);
    }
    sort(x.begin(), x.end());
    sort(y.begin(), y.end());
    ll xmid = x[n / 2];
    ll ymid = y[n / 2];
    vector<ll> vv(4, LONG_LONG_MIN);
    vector<vector<ll>> w(4, vector<ll>(2, LONG_LONG_MIN));
    for (auto p : v) {
        ll xi = p.first - xmid;
        ll yi = p.second - ymid;
        ll val = abs(xi) + abs(yi);
        ll val1 = abs(xi) - abs(yi);
        ll val2 = -abs(xi) + abs(yi);
        if (xi >= 0) {
            if (yi >= 0) {
                vv[0] = max(vv[0], val);
                w[0][0] = max(w[0][0], val1);
                w[0][1] = max(w[0][1], val2);
            }
            if (yi <= 0) {
                vv[3] = max(vv[3], val);
                w[3][0] = max(w[3][0], val2);
                w[3][1] = max(w[3][1], val1);
            }
        }
        if (xi <= 0) {
            if (yi >= 0) {
                vv[1] = max(vv[1], val);
                w[1][0] = max(w[1][0], val2);
                w[1][1] = max(w[1][1], val1);
            }
            if (yi <= 0) {
                vv[2] = max(vv[2], val);
                w[2][0] = max(w[2][0], val1);
                w[2][1] = max(w[2][1], val2);
            }
        }
    }
    ll ans = 0;
    ans = max(ans, vv[0] + vv[2]);
    ans = max(ans, vv[1] + vv[3]);
    ans = max(ans, vv[1] + w[0][0]);
    ans = max(ans, vv[0] + w[1][1]);
    ans = max(ans, vv[2] + w[1][0]);
    ans = max(ans, vv[1] + w[2][1]);
    ans = max(ans, vv[2] + w[3][1]);
    ans = max(ans, vv[3] + w[2][0]);
    ans = max(ans, vv[3] + w[0][1]);
    ans = max(ans, vv[0] + w[3][0]);

    cout << ans << endl;
}

Measured memory_bytes: 9764
#include<bits/stdc++.h>
using namespace std;
#define fi first
#define se second
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define rng(a) a.begin(),a.end()
#define rrng(a) a.rbegin(),a.rend()
#define maxs(x,y) (x = max(x,y))
#define mins(x,y) (x = min(x,y))
#define limit(x,l,r) max(l,min(x,r))
#define lims(x,l,r) (x = max(l,min(x,r)))
#define isin(x,l,r) ((l) <= (x) && (x) < (r))
#define pb push_back
#define eb emplace_back
#define sz(x) (int)(x).size()
#define pcnt __builtin_popcountll
#define uni(x) x.erase(unique(rng(x)),x.end())
#define snuke srand((unsigned)clock()+(unsigned)time(NULL));
#define show(x) cout<<#x<<" = "<<x<<endl;
#define PQ(T) priority_queue<T,v(T),greater<T> >
#define bn(x) ((1<<x)-1)
#define dup(x,y) (((x)+(y)-1)/(y))
#define newline puts("")
#define v(T) vector<T>
#define vv(T) v(v(T))
typedef long long int ll;
typedef unsigned uint;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef tuple<int,int,int> T;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
typedef vector<T> vt;
inline int getInt() { int x; scanf("%d",&x); return x;}
template<typename T>inline istream& operator>>(istream&i,v(T)&v)
{rep(j,sz(v))i>>v[j];return i;}
template<typename T>string join(const v(T)&v)
{stringstream s;rep(i,sz(v))s<<' '<<v[i];return s.str().substr(1);}
template<typename T>inline ostream& operator<<(ostream&o,const v(T)&v)
{if(sz(v))o<<join(v);return o;}
template<typename T1,typename T2>inline istream& operator>>(istream&i,pair<T1,T2>&v)
{return i>>v.fi>>v.se;}
template<typename T1,typename T2>inline ostream& operator<<(ostream&o,const pair<T1,T2>&v)
{return o<<v.fi<<","<<v.se;}
template<typename T>inline ll suma(const v(T)& a) { ll res(0); for (auto&& x : a) res += x; return res;}
const double eps = 1e-10;
const ll LINF = 1001002003004005006ll;
const int INF = 1001001001;
const int MX = 200005;
#define dame { puts("-1"); return 0;}
#define yn {puts("Yes");}else{puts("No");}
//---------------------------------------------------------------
#define fastio std::ios::sync_with_stdio(false);
#define myio ifstream iofi; if(argc>1){iofi.open(argv[1]); std::cin.rdbuf(iofi.rdbuf());}
using u32 = int32_t ;
using u64 = int64_t ;
//--------------------------------------------------------------

int main(int argc,char** argv){ fastio; myio;
  int n;
  ll k;
  cin>>n>>k;
  priority_queue<P,vp,greater<P>> q;
  rep(i,n){
    P a;
    cin>>a;
    q.push(a);
  }
  int ans;
  ll sum=0;
  while(sum<k){
    ans = q.top().fi;
    sum+= q.top().se;
    q.pop();
  }
  // cout<<sum<<endl;
  cout<<ans<<endl;
}

Measured memory_bytes: 1400
#include<bits/stdc++.h>
#define ull unsigned long long
# define ll long long
# define mod 1000000007LL 
using namespace std;
int main()
{
     ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    string s,t;
    cin>>s>>t;
    ll ans=0;
    for(int i=0;i<s.length();i++)
    {
        if(s[i]==t[i])
        continue;
        else
        {
            ans++;
        }
        
    }
    cout<<ans;


    
    return 0;
}

Measured memory_bytes: 3800
class UnionFind():
    def __init__(self, n):
        self.n = n
        self.parents = [-1] * n

    def find(self, x):
        if self.parents[x] < 0:
            return x
        else:
            self.parents[x] = self.find(self.parents[x])
            return self.parents[x]

    def union(self, x, y):
        x = self.find(x)
        y = self.find(y)

        if x == y:
            return

        if self.parents[x] > self.parents[y]:
            x, y = y, x

        self.parents[x] += self.parents[y]
        self.parents[y] = x

    def size(self, x):
        return -self.parents[self.find(x)]

    def same(self, x, y):
        return self.find(x) == self.find(y)

    def members(self, x):
        root = self.find(x)
        return [i for i in range(self.n) if self.find(i) == root]

    def roots(self):
        return [i for i, x in enumerate(self.parents) if x < 0]

    def group_count(self):
        return len(self.roots())

    def all_group_members(self):
        return {r: self.members(r) for r in self.roots()}

    def __str__(self):
        return '\n'.join('{}: {}'.format(r, self.members(r)) for r in self.roots())

n,m = map(int, input().split())
uf = UnionFind(n)
for i in range(m):
    a,b = map(int, input().split())
    a -= 1
    b -= 1
    uf.union(a, b)
    
ans = [uf.size(i) for i in range(n)]
print(max(ans))

Measured memory_bytes: 22420
#include <bits/stdc++.h>
#define repr(i,from,to) for(int (i)=(from);(i)<(to);(i)++)
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
// const bool debug=true;
const bool debug=false;
#define DEBUG if(debug==true)
#define vprint(x) for(auto a:(x)) cout << x << endl;
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
const ll MOD = 1000000007;

int main(void) {
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll n,k;cin>>n>>k;
    ll h[n];rep(i,n){cin>>h[i];}
    ll dp[n];
    dp[0]=0;
    repr(i,1,n){
        dp[i]=(1LL<<60);
    }
    rep(i,n){
        for(ll j=1;j<=k&&i+j<n;j++){
            dp[i+j]=min(dp[i+j],dp[i]+abs(h[i]-h[i+j]));
        }
    }
    cout << dp[n-1] << endl;
    return 0;
}


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

const int mod=1e9+7;

void add(int &a,int b)
{
    a=(a+b)%mod;
}

signed main()
{
    int N,M; cin>>N>>M;
    vector<int> ng(N+1);
    for(int i=0;i<M;i++){
        int a; cin>>a;
        ng[a]=true;
    }

    vector<int> dp(N+1);
    dp[0]=1;
    for(int i=0;i<N;i++){
        if(ng[i]) continue;
        if(i+1<=N and !ng[i+1]){
            add(dp[i+1],dp[i]);
        }
        if(i+2<=N and !ng[i+2]){
            add(dp[i+2],dp[i]);
        }
    }
    cout<<dp[N]<<endl;
}


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

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
typedef long long ll;
using vi = vector<int>; // intの1次元の型に vi という別名をつける
using vvi = vector<vi>; // intの2次元の型に vvi という別名をつける
using vl = vector<ll>;  // long longの1次元の型に vl という別名をつける
using vvl = vector<vl>; // long longの2次元の型に vvl という別名をつける
int MOD = 1000000007; //10^9 + 7

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

// 無限大の値
const ll  LINF = 1LL << 60;
const int iINF = 1 << 29;

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

  int ans=0;

  for (int i = 1; i <= n; i++){
    if(i<=k) ans += x;
    else ans += y;
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 3616
#include <vector>
#include <iostream>
#include <utility>
#include <algorithm>
#include <string>
#include <deque>
#include <queue>
#include <tuple>
#include <queue>
#include <functional>
#include <cmath>
#include <iomanip>
#include <map>
#include <set>
#include <numeric>
#include <unordered_map>
#include <unordered_set>
#include <complex>
#include <iterator>
#include <array>
#include <memory>
#include <stack>
#define vi vector<int>
#define vvi vector<vector<int> >
#define ll long long int
#define vl vector<ll>
#define vvl vector<vector<ll>>
#define vb vector<bool>
#define vc vector<char>
#define vs vector<string>
#define ld long double
#define INF 1e9
#define EPS 0.0000000001
#define rep(i,n) for(int i=0;i<n;i++)
#define loop(i,s,n) for(int i=s;i<n;i++)
#define all(in) in.begin(), in.end()
template<class T, class S> void cmin(T &a, const S &b) { if (a > b)a = b; }
template<class T, class S> void cmax(T &a, const S &b) { if (a < b)a = b; }
#define MAX 9999999
using namespace std;
typedef pair<int, int> pii;
typedef pair<double,double>pdd;
typedef pair<ll,ll>pll;
int main(){
    string s; cin>>s;
    rep(i,s.size()-8)cout<<s[i];
    cout<<endl;
    return 0;
}


Measured memory_bytes: 256
#include <cstdio>
#include <cstdlib>
#include <iostream>
#include <fstream>
#include <sstream>
#include <set>
#include <map>
#include <vector>
#include <list>
#include <algorithm>
#include <cstring>
#include <cmath>
#include <string>
#include <stack>
#include <queue>
#include <bitset>     //UWAGA - w czasie kompilacji musi byc znany rozmiar wektora - nie mozna go zmienic
#include <cassert>
#include <iomanip>        //do setprecision
#include <ctime>
#include <complex>
using namespace std;

#define FOR(i,b,e) for(int i=(b);i<(e);++i)
#define FORQ(i,b,e) for(int i=(b);i<=(e);++i)
#define FORD(i,b,e) for(int i=(b)-1;i>=(e);--i)
#define REP(x, n) for(int x = 0; x < (n); ++x)

#define ST first
#define ND second
#define PB push_back
#define PF push_front
#define MP make_pair
#define LL long long
#define ULL unsigned LL
#define LD long double
#define pii pair<int,int>
#define pll pair<LL,LL>

const double pi = 3.14159265358979323846264;
const int mod=1000000007;

int main(){
	 //cin.tie(0);
	//ios::sync_with_stdio(false);
	//std::cout << std::fixed;
	//std::cout << std::setprecision(12);
	//std::cout << std::defaultfloat;
	int n,k;
	cin>>n>>k;
	vector<int> v(n);
	FOR(i,0,n)cin>>v[i];
	LL ans=0;
	FOR(l,0,n+1){
		FOR(r,0,n+1){
			if(l+r>k||l+r>n)continue;
			priority_queue<int> pq;
			LL sm=0;
			int rst=k-l-r;
			FOR(i,0,l){
				sm+=v[i];
				pq.push(-v[i]);
			}
			FOR(i,0,r){
				sm+=v[n-1-i];
				pq.push(-v[n-1-i]);
			}
			ans=max(ans,sm);
			FOR(i,0,rst){
				if(pq.empty())break;
				int t=pq.top();
				if(t<=0)break;
				pq.pop();
				sm+=t;
			}
			ans=max(ans,sm);
		}
	}
	cout<<ans<<endl;
	return 0;
}


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

struct node{
  unsigned int key;
  struct node *prev;
  struct node *next;
};
typedef struct node *NodePointer;

NodePointer nil;

NodePointer search(int);
void insert(int);
void deleteKey(int);
void deleteFirst(void);
void deleteLast(void);
void deleteNode(NodePointer);
void printlist(void);
void init(void);

int main(){
  int n = 0, i = 0;
  char command[15];
  int val = 0;
  NodePointer now;
  init();
  scanf("%d",&n);
  for(i = 0; i < n; i++){
    scanf("%s%d",command,&val);
    if(command[0] == 'i'){
      insert(val);
    }
    else if(command[0] == 'd'){
      if(strlen(command) > 6){
	if(command[6] == 'F')deleteFirst();
	else if(command[6] == 'L')deleteLast();
      }
      else deleteKey(val);
    }
  }

  printlist();
  
  return 0;
}

NodePointer search(int k){
  NodePointer x;
  x = nil->next;
  while(x != nil && x->key != k){
    x = x->next;
  }
  return x;
}
void insert(int k){
  NodePointer x;
  x = malloc(sizeof(struct node));
  x->key = k;  
  x->next = nil->next;
  x->next->prev = x;
  nil->next = x;
  x->prev = nil;
  
}

void deleteKey(int k){
  deleteNode(search(k));
  /* NodePointer x;
  x = search(k);
  x->prev->next = x->next;
  x->next->prev = x->prev;
  free(x);*/
}

void printlist(){
  NodePointer cur = nil->next;
  int isf = 0;
  while(1){
    if(cur == nil)break;
    if(isf++ > 0)printf(" ");
    printf("%d",cur->key);
    cur = cur->next;
  }
  printf("\n");
}

void init(void){
  nil = malloc(sizeof(struct node));
  nil->next = nil;
  nil->prev = nil;
}

void deleteNode(NodePointer x){
  if(x == nil)return;
  x->prev->next = x->next;
  x->next->prev = x->prev;
  free(x);
}

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

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



Measured memory_bytes: 33032
#include <bits/stdc++.h>
using namespace std;
int main(void){
    // Your code here!
  int W,H,x,y,r;
  cin>>W>>H>>x>>y>>r;
  if(x+r<=W&&y+r<=H&&x-r>=0&&y-r>=0){
      std::cout << "Yes" << std::endl;
  }
  else{
      cout<<"No"<<endl;
  }
}  




Measured memory_bytes: 3092
import { count } from 'console';

process.stdin.resume();
process.stdin.setEncoding('utf8');

// 標準入力取込
let gInput = '';
process.stdin.on('data', (chunk) => (gInput += chunk));
process.stdin.on('end', () => main(gInput.split(/\r?\n/)));

// 解答
function main(inputs: string[]): void {
  let [a, b, c, d] = inputs[0].split(' ').map(Number);
  let isTakahashiTurn = true;

  while (a > 0 && c > 0) {
    if (isTakahashiTurn) {
      c = attack(c, b);
    } else {
      a = attack(a, d);
    }
    isTakahashiTurn = !isTakahashiTurn;
  }

  if (a <= 0) {
    console.log('No');
  } else {
    console.log('Yes');
  }
}

function attack(hp: number, attack: number): number {
  return hp - attack;
}


Measured memory_bytes: 29948
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
typedef pair<P,ll> Pll;
typedef pair<P,P> PP;
#define rep(i,a,n) for(int i = a;i < n;i++)
#define repr(i,a,n) for(int i = n-1;i >= a;i--)
#define ALL(v) v.begin(), v.end()
#define LINF (ll)1e17
#define INF (int)1e9
#define MOD (ll)1e9+7
#define sMOD 1e5
#define fs first
#define sc second

ll gcd(ll a,ll b){
	if(!b) return a;
	return gcd(b,a%b);
}

void YNout(bool check){
	if(check)cout << "Yes" << endl;
	else cout << "No" << endl;
	
	return;
}

void Yayout(bool check){
	if(check) cout << "Yay!" << endl;
	else cout << ":(" << endl;
	
	return;
}
/*
template <typename T>
void vecout(vector<T>& vecout_vec){
	
	rep(i,0,vecout_vec.size()){
		cout << vecout_vec.at(i) << endl;
	}
	
	return ;
}

template <typename T>
void vecin(vector<T>& vecin_vec, ll n){
	
	ll temp ;
	
	rep(i,0,n){
		cin >> temp;
		vecin_vec.push_back(temp);
		
	}
}

template <typename T>
void in(T& literal_in, T& literal_in2, ...){
	cin >> literal_in;
	in(literal_in2, ...);
	
	return;
}

template <typename T>
void in(T& literal_in){
	
	cin >> literal_in;
	
	return;
}

template <typename T>
void out(T& literal_out, T& literal_out2, ...){
	cout << literal_out << endl;
	out(literal_out2, ...);
	
	return;
}

template <typename T>
void out(T& literal_out){
	
	cout << literal_out << endl;
	
	return;
}
*/
signed main(){
	ll n,m,memo = 0,cnt = 0;
	cin >> n >> m;
	ll up[n] = {0},down[n] = {0};
	
	rep(i,0,n){
		up[i] = 0;
		down[i] = 0;
	}
	
	
	
	ll l,r;
	
	rep(i,0,m){
		cin >> l >> r;
		up[l-1]++;
		down[r-1]++;
	}
	
	rep(i,0,n){
		cnt += up[i];
		if(i != 0) cnt -= down[i-1];
		if(cnt == m) memo++;
	}
	
	
	cout << memo << endl;
	return 0;
}


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

int main() {
	string s;
	cin >> s;
	for (int i = 0;i + 1 < s.size();i++) {
		if (s[i] == s[i + 1]) {
			cout << i + 1 << " " << i + 2 << endl;
			return 0;
		}
	}
	for (int i = 0;i + 2 < s.size();i++) {
		if (s[i] == s[i + 2]) {
			cout << i + 1 << " " << i + 3 << endl;
			return 0;
		}
	}
	cout << -1 << " " << -1 << endl;
}

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

int n, m;
int c[1000], d[1000];
long long dp[1001][1001];
const long long INF = 10000000000;

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

	for (int i = 0; i < n; i++)
		cin >> d[i];

	for (int i = 0; i < m; i++)
		cin >> c[i];

	for (int i = 1; i <= n; i++)
		dp[i][0] = INF;

	for (int j = 0; j <= m; j++)
		dp[0][j] = 0;

	for (int i = 0; i < n; i++) {
		for (int j = 0; j < m - n + i + 1; j++)
			dp[i + 1][j + 1] = min(dp[i + 1][j], dp[i][j] + d[i] * c[j]);
	}
	
	cout << dp[n][m] << endl;

	return 0;
}



Measured memory_bytes: 9108
#include <iostream>
#define REP(i, a, n) for(int i = (a); i < (n); i++)
using namespace std;
typedef long long ll;

int main(void) {
  int N;
  cin >> N;

  ll ans = 0;
  ll p = 1;
  while(p < N) {
    ans++;
    p *= 3;
  }
  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 3092
#include<cstdio>
long long D[110], Res;
int K, L;
int main() {
	int i, j;
	scanf("%d%d", &L, &K);
	D[1] = D[K] = 1;
	for (i = 1; i <= L; i++) {
		Res += D[i];
		D[i + 2] += D[i];
		D[i + K + 1] += D[i];
	}
	printf("%lld\n", Res);
}

Measured memory_bytes: 2756
#include <bits/stdc++.h>
#include <cmath>
#include <numeric>
using namespace std;
#define rep(i,a,b) for(int64_t i=(a); i<(b); ++i) // a ≦ i < b 
#define Rrep(i,a,b) for(int64_t i=(a);i>=(b);--i) // reverse repeat. a から b まで減少．
#define ALL(a) (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend() //逆イテレータ
#define RANGE(a,b,c) (a).begin()+b,(a).begin()+c // コンテナ a の 要素 b から c へのイテレータ
#define MOD 1000000007
#define INF 1000000000
typedef pair<int64_t, int64_t> PII;
typedef vector<int64_t> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef vector<PII> VP;

int LSD(const string s1, const string s2){
    VVI Ldist(s1.size()+1, VI(s2.size()+1));
    rep(i, 0, s1.size()+1) Ldist[i][0] = i;
    iota(ALL(Ldist[0]), 0);

    rep(i, 1, s1.size()+1){
        rep(j, 1, s2.size()+1){
            Ldist[i][j] = min({Ldist[i-1][j] + 1 , Ldist[i][j-1] + 1, 
                                Ldist[i-1][j-1] + (s1[i-1] == s2[j-1] ? 0 : 1)});
        }
    }
    return Ldist[s1.size()][s2.size()];
}

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

string s1, s2; cin >> s1 >> s2;

cout << LSD(s1, s2) << endl;
}

// 境界，出力文字列 チェック
// 可読性優先．高速化次点．
// まずは全探索，分割統治，次にDP
// 制限を見る
// 偶奇，逆から，ソート，出現回数，出現位置，DP， 余事象，包除
// データ構造． 問題の特徴量
// 存在判定：構成方法，入力の特徴
// gcd, lcm ,素因数分解．
// 例外を十分に含む一般化．想像力の限界
// 小さい系から例示
// 始めは過剰に例示・場合分けしてもいい．各場合を確実に対処．
// 自明な例から処理，除外．
// 小数のときは，精度の設定する．doubel 変数に数値を入力するときは 123. とする．
// テストケース作成は数表あり




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

typedef long long ll;

int main() {
    ll n;
    ll ans = 10000000000000000;
    ll sum = 0;
    cin >> n;
    vector<ll>a(n);
    for (int i = 0; i < n; i++) {
        cin >> a[i];
    }
    
    ll cnt = 0;
    for (int i = 0; i < n; i++) {
        sum += a[i];
        if (i % 2 == 0) {
            if (sum >= 0) {
                cnt += sum + 1;
                sum = -1;
            }
        } else {
            if (sum <= 0) {
                cnt += 1 - sum;
                sum = 1;
            }
        }
    }

    ans = min(ans, cnt);

    sum = 0;
    cnt = 0;
    for (int i = 0; i < n; i++) {
        sum += a[i];
        if (i % 2 == 0) {
            if (sum <= 0) {
                cnt += 1 - sum;
                sum = 1;
            }
        } else {
            if (sum >= 0) {
                cnt += sum + 1;
                sum = -1;
            }
        }
    }
    ans = min(ans, cnt);
    cout << ans << endl;
}


Measured memory_bytes: 1024
N = int(input())
A = list(map(int, input().split()))
A = [0] + A
balls = [0] * (N+1)

for i in range(N, 0, -1):
	tmpBalls = 0
	x = 1
	while i * x <= N:
		tmpBalls += balls[i*x]
		x += 1
	
	if A[i] == 1 and tmpBalls % 2 == 1:
		pass
		
	elif A[i] == 1 and tmpBalls % 2 == 0:
		balls[i] += 1
	
	elif A[i] == 0 and tmpBalls % 2 == 1:
		balls[i] += 1
	
	elif A[i] == 0 and tmpBalls % 2 == 0:
		pass
		

isOkay = True
for i in range(1, N+1):
	if balls[i] > 1:
		print(-1)
		exit()
	
print(balls.count(1))	
for i in range(1, N+1):
	if balls[i]:
		print(i)

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

/* #pragma */
//#pragma GCC optimize("Ofast")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")


/*alias*/
#define F first
#define S second

#define y0 y3487465
#define y1 y8687969
#define j0 j1347829
#define j1 j234892
#define next asdnext
#define prev asdprev
#define itn int

/*template*/
template<class T>inline bool amax(T &a, const T &b) { if (a < b) { a = b; return 1; } return 0; }
template<class T>inline bool amin(T &a, const T &b) { if (b < a) { a = b; return 1; } return 0; }

/* func */
int32_t GCD(int32_t a, int32_t b){return b ? GCD(b, a%b) : a;}
int64_t GCD(int64_t a, int64_t b){return b ? GCD(b, a%b) : a;}
int32_t LCM(int32_t a, int32_t b){return a * b / GCD(a, b);}
int64_t LCM(int64_t a, int64_t b){return a * b / GCD(a, b);}

/*struct*/
struct aaa {
	aaa() {
		cin.tie(nullptr); ios::sync_with_stdio(false); cout << fixed << setprecision(20);
	};
}aaaaaaa;

/* const */
constexpr int32_t INF = 1001001001;
constexpr int64_t LINF = 1001001001001001001ll;
constexpr int32_t MOD = 1e9 + 7; //10^9
constexpr int64_t EPS = 1e-9;
constexpr int32_t dx[] = { 1, 1, 0, -1, -1, -1, 0, 1 }, dy[] = { 0, 1, 1, 1, 0, -1, -1, -1 };
//constexpr int32_t dx[] = {1, 0, -1, 0}, dy[] = {0, 1, 0, -1};
//Counterclockwise from the 6o'clock direction
//Take the x-axis downward and the y-axis right


//g++ -std=c++14 -Wall --pedantic-errors -o template template.cpp
//g++ -std=c++14 -Wall --pedantic-errors template.cpp
//chcp 65001

/*global*/



#define int int64_t
signed main()
{
	int n;
	cin >> n;
	vector<int> a(n);
	for(int i = 0, i_len = (int)n; i < i_len; ++i) cin >> a[i];

	double mather{};
	for(int i = 0; i < n; ++i){
		mather += (double)1/a[i];
	}

	cout << (double)1/mather;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int a = sc.nextInt();
		int b = sc.nextInt();
		int c = Integer.valueOf(String.valueOf(a) + String.valueOf(b));

		boolean can = false;
		for (int i = 1; i <= 10000; i++) {
			if (c == Math.pow(i, 2)) can = true;
		}

		if (can) {
			System.out.println("Yes");
		} else {
			System.out.println("No");
		}


		sc.close();
	}

}


Measured memory_bytes: 23892
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time
import numpy as np
sys.setrecursionlimit(10**7)
inf = 10**20
mod = 10**9 + 7

stdin = sys.stdin

ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))
ns = lambda: stdin.readline().rstrip()  # ignore trailing spaces

start = time.time()

D = ni()
c = na()
s = [na() for _ in range(D)]
#out = [ni() for _ in range(D)]
sat = 0
last = [0] * 26
t = []
for d in range(D):
    li = []
    for k in range(26):
        last_t = last.copy()
        sat_t = sat
        j = k
        last_t[j] = d + 1
        for i in range(26):
            sat_t -= (d + 1 - last_t[i]) * c[i]
        sat_t += s[d][j]
        li.append(sat_t)
    sat = max(li)
    day = np.argmax(li)
    last[day] = d + 1
    #print(day+1, sat)
    t.append(day+1)

now = sat
while time.time() - start < 1.84:
    d = random.randint(1, D)
    q = random.randint(1, 26)
    if t[d - 1] == q:
        continue
    old = t[d-1]
    t[d-1] = q
    sat = 0
    last = [0] * 26
    for k in range(D):
        j = t[k] - 1
        last[j] = k + 1
        for i in range(26):
            sat -= (k + 1 - last[i]) * c[i]
        sat += s[k][j]
    if now > sat:
        t[d-1] = old
    else:
        now = sat
for i in range(D):
    print(t[i])


Measured memory_bytes: 27404
#include <stdio.h>

typedef struct{
    int k, l, r;
}node;

node nodes[500001];

void insert(int index, int z)
{
    int x = 0, y;

    nodes[index].k = z;
    nodes[index].l = -1;
    nodes[index].r = -1;

    if(index == 0)
        return ;

    while(x >= 0){
        y = x;
        if(z < nodes[x].k){
            x = nodes[x].l;
        }else{
            x = nodes[x].r;
        }
    }

    if(z < nodes[y].k)
        nodes[y].l = index;
    else
        nodes[y].r = index;
}

void pre(int id)
{
    if(id == -1)
        return ;
    printf(" %d", nodes[id].k);
    pre(nodes[id].l);
    pre(nodes[id].r);
}

void ino(int id)
{
    if(id == -1)
        return ;
    ino(nodes[id].l);
    printf(" %d", nodes[id].k);
    ino(nodes[id].r);
}

int main(void)
{
    int i, n;
    int index = 0, z;
    char buf[16];
    scanf("%d", &n);

    for(i = 0; i < n; i++){
        scanf("%s", buf);
        if(buf[0] == 'i'){
            scanf("%d", &z);
            insert(index++, z);
        }else{
            if(index > 0){
                ino(0);
                printf("\n");
                pre(0);
                printf("\n");
            }
        }
    }

    return 0;
}

Measured memory_bytes: 6460
N = list(str(input()))
if N[0] == '9':
    N[0] = '1'
else : 
    N[0] = '9'
if N[1]=='9':
    N[1] = '1'
else:
    N[1] = '9'
if N[2] == '9':
    N[2] = '1'
else:
    N[2] = '9'
print(N[0]+N[1]+N[2])

Measured memory_bytes: 3060
#include <iostream>
#include <algorithm>
#include <cstdio>
#include <vector>
#include <math.h>
#include <iomanip>
#include <bitset>
#include <string>
#include <cstring>
#include <stdlib.h>
#include <utility>
#include <set>
#include <map>
using namespace std;
typedef long long int ll;
typedef long double ld;
typedef pair<ll,ll> pairs;

#define MOD 998244353


ll gcd(ll a,ll b){
    if (a%b==0)return(b);
    else return(gcd(b,a%b));
}

bool primeNumber(ll n){
    if(n < 2) return false;
    else{
        for(ll i = 2; i * i <= n; i++){
            if(n % i == 0) return false;
        }
        return true;
    }
}




int main(){
    ll x,y,z;
    cin>>x>>y>>z;
    cout<<z<<" "<<x<<" "<<y<<endl;;
    return 0;
}


Measured memory_bytes: 256
import java.util.*;

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

Measured memory_bytes: 50732
#pragma GCC optimize(2)
#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<cmath>
#include<vector>
#include<stack>
#include<queue>
#include<map>
#include<set>
#define read(a) scanf("%d", &a)
#define readf(a) scanf("%lf", &a)
#define pb push_back
#define mk make_pair
#define _rand mt19937 RAND(time(0))
#define mem(a) memset(a, 0, sizeof(a))
#define Buff ios::sync_with_stdio(false)
typedef long long ll;
using namespace std;
const int INF = 1e9 + 7;
const int N = 3e5 + 7;
const int M = 1e6 + 7;

#define lson rt << 1
#define rson rt << 1 | 1
template<class T>
class SegTree
{
public:
    T maxv[N << 2];
    void init()
    {
        mem(maxv);
    }
    inline void pushup(int rt)
    {
        maxv[rt] = max(maxv[lson], maxv[rson]);
    }
    void update(int rt, int l, int r,int pos, T val)
    {
        if(l == r)
        {
            maxv[rt] = max(maxv[rt], val);
            return;
        }
        int mid = (l + r) >> 1;
        if(pos <= mid) update(lson, l, mid, pos, val);
        else          update(rson, mid + 1, r, pos, val);
        pushup(rt);
    }

    T query(int rt, int l, int r, int L, int R)
    {
        if(L <= l && r <= R) return maxv[rt];
        int mid = (l + r) >> 1;
        T ans = 0;
        if(L <= mid) ans = max(ans, query(lson, l, mid, L, R));
        if(R > mid)  ans = max(ans, query(rson, mid + 1, r, L, R));
        return ans;
    }
};
SegTree<int> tree;

int a[N];
signed main()
{
    int k;
    cin >> k;
    while(k--) cout << "ACL";
    return 0;
}
/**
**/



Measured memory_bytes: 3636
#include<stdio.h>
#include<stdlib.h>
#include<iostream>
#include<string>
#include<algorithm>
#include<vector> 
#include<limits>
#include<numeric>
#include<type_traits>
#include<math.h>
using namespace std;
typedef long long ll;

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define repi(i,a,b) for(int i = (int)(a); i < (int)(b); i++)
#define in(x) cin >> x
#define out(str) cout << str << endl

template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

int N,K,cnt,ans,tmp;
string S;

int main(){
    cin>>N>>K>>S;
    vector<int> z,o,vec;
    bool zeorone = (S[0]=='1');
    cnt=1;
    repi(i,1,N-1){
        if(S[i]=='0'){
            if(!zeorone)cnt++;
            else {
                o.push_back(cnt);
                cnt=1;
                zeorone = false;
            }
        }
        else{
            if(zeorone)cnt++;
            else {
                z.push_back(cnt);
                cnt=1;
                zeorone = true;
            }
        }
    }
    if(S[N-1]=='0'){
            if(!zeorone){
                cnt++;
                z.push_back(cnt);
            }
            else {
                z.push_back(cnt);
                o.push_back(1);
            }
    }
    else{
            if(zeorone){
                cnt++;
                o.push_back(cnt);
            }
            else {
                o.push_back(cnt);
                z.push_back(1);
            }
    }
    o.push_back(0);
    o.push_back(0);
    o.push_back(0);
    o.push_back(0);

    if(z.size()<=K)ans=N;
    else{  
        if(S[0]=='0'){
            rep(i,z.size()-K+1){
                rep(j,K){
                    tmp+=o[i+j]+z[i+j];
                }
                if(i)tmp+=o[i-1];
                vec.push_back(tmp);
                tmp=0;
            }
        }
        else{
            rep(i,z.size()-K+1){
                rep(j,K){
                    tmp+=o[i+j]+z[i+j];
                }
                tmp+=o[i+K];
                vec.push_back(tmp);
                tmp=0;
            }
        }
        rep(i,vec.size()){
            ans=max(ans,vec[i]);
        }
    }
    out(ans);

}


Measured memory_bytes: 1212
using System;
using System.Collections.Generic;
using System.Linq;


public class A{
	
	public static void Main(){
	
		string[] args = Console.ReadLine().Split(' ');
		long X = Int64.Parse(args[0]);
		long Y = Int64.Parse(args[1]);
		Console.WriteLine(X + Y/2);
		
	}
	
}

Measured memory_bytes: 13140
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<string>
#include<math.h>

using namespace std;

int main(void)
{
	int K, X;
	
	cin >> K >> X;

	long long int end = X - K + 1;
	long long int fin = X + K - 1;
	
	if (end < -1000000)
		end = -1000000;
	if (fin > 1000000)
		fin = 1000000;

	for (int i = end; i <= fin; i++)
		cout << i << " ";

	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define f first
#define s second
#define pb push_back
#define mp make_pair
using namespace std;
typedef long long int ll;
typedef pair<int,int> ii;
double sum;
double x;
int n;

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

	cin>>n;
	for(int i=0;i<n;++i)
	{
		cin>>x;
		sum+=1/x;
	}
	
	cout<<fixed<<setprecision(12);
	cout<<double(1/sum)<<"\n";
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define INF 5000000000000000000
#define ll long long
#define pll pair<ll, ll>
using namespace std;

//=============modinv============================
ll modinv(ll a, ll m) {
    ll b = m, u = 1, v = 0;
    while (b) {
        ll t = a / b;
        a -= t * b; swap(a, b);
        u -= t * v; swap(u, v);
    }
    u %= m;
    if (u < 0) u += m;
    return u;
}
//=================================================

//=============modcom============================
ll modcom(ll n, ll k, ll mod)
{
  k = min(k, n - k);
  ll up = 1;
  for (ll i = n - k + 1; i < n + 1; ++i)
  {
    up = (up * i) % mod;
  }
  ll down = 1;
  for (ll i = 2; i < k + 1; ++i)
  {
    down = (down * modinv(i, mod)) % mod;
  }
  return (up * down) % mod;
}
//=================================================

ll N, K;
ll const mod = 1000000007;

int main()
{
  cin >> N >> K;
  ll M = modcom(N + N - 1, N - 1, mod);
  if (K >= N - 1) {
    cout << M << endl;
    return 0;
  }
  ll ans = 1;
  ll choose = 1;
  ll pattern = 1;
  for (ll i = 0; i < K; ++i) {
    choose = ((choose * (N - i)) % mod) * modinv(i + 1, mod) % mod;
    pattern = ((pattern * (N - i - 1)) % mod) * modinv(i + 1, mod) % mod;
    ans = (ans + choose * pattern % mod) % mod;
  }
  cout << ans << "\n";
}


Measured memory_bytes: 384
N,M=map(int,input().split())
A=[[] for i in range(N)]
B=[0 for i in range(M)]

for i in range(N):
  A[i]=list(map(int,input().split()))
  
for i in range(M):
  B[i]=int(input())
  
for row in range(N):
  tmp=0
  for col in range(M):
    tmp += A[row][col]*B[col]
  print("{:d}".format(tmp))


Measured memory_bytes: 6036
#include <iostream>
#include <assert.h>
#include <stdlib.h>
#include <time.h>
#include <stdio.h>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <string>
#include <string.h>
#include <cmath>
#include <memory.h>
#include <algorithm>
#include <unordered_map>
#include <unordered_set>
#define ll long long
using namespace std;

void solve() {
    int n, m;
    cin >> n >> m;
    vector<int> a(n);
    int ans = 0, votes = 0;
    for (int i = 0; i < n; ++i) {
        cin >> a[i];
        votes += a[i];
    }
    for (int i = 0; i < n; ++i){
//        if (a[i] >= ((votes / 4) / m)) {
//            cout << i << endl;
//        }
        ans += (a[i] * 4 * m >= votes);
    }
    puts(ans >= m ? "Yes" : "No");
}

int main() {
    ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
//    freopen("input.txt", "r", stdin);
    int t = 1;
//    cin >> t;
    while(t--) {
        solve();
    }
    return 0;
}


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

int main() {
    ll N; cin >> N;
    vector<ll> A(N); for (int i = 0; i < N; ++i) cin >> A[i];
    ll m = 1000;
    for (int i = 0; i < N - 1; ++i) {
        if (A[i] < A[i + 1]) {
            m += (A[i + 1] - A[i]) * (m / A[i]);
        }
    }
    cout << m << endl;
    return 0;
}


Measured memory_bytes: 3620
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
using namespace std;
const int maxn = 100010;
const int inf = 0x0fffffff;
const long long mod = 1000000007;

int cs[maxn], ct[maxn];
int main()
{
	string S, T;
	int q, a, b, c, d;
	cin >> S >> T;
	for (int i = 0; i < S.length(); i ++)
		if (S[i] =='B')
			cs[i + 1] = cs[i] + 1;
		else
			cs[i + 1] = cs[i] + 2;

	for (int i = 0; i < T.length(); i ++)
		if (T[i] =='B')
			ct[i + 1] = ct[i] + 1;
		else
			ct[i + 1] =ct[i] +  2;
	cin >> q;
	while (q --)
	{
		cin >> a >>b >> c >> d;
		int t = abs((cs[b] - cs[a - 1]) - (ct[d] - ct[c - 1])) % 3;
		//cout << cs[a - 1] << " " << cs[b] << " " << ct[d] - ct[c - 1]) << endl;
		puts(t ? "NO" : "YES");
	}
	return 0;
}

Measured memory_bytes: 1664
parseInt(x)=parse(Int, x)
parseMap(x::Array{SubString{String},1})=map(parseInt, x)

function ftAdd(ft::Array{Int,1},k::Int,x::Int)
	t = k
	n = length(ft)
	while t<=n
		ft[t] += x
		t += t&(-t)
	end
	ft
end

function ftSum(ft::Array{Int,1},ll::Int,rr::Int)
	l = ll
	r = rr
	s = 0
	while r>0
		s += ft[r]
		r -= r&(-r)
	end
	while l>0
		s -= ft[l]
		l -= l&(-l)
	end
	s
end

function main()
	n,q = readline() |> split |> parseMap
	a = readline() |> split |> parseMap
	ft = zeros(Int,n)
	for i in 1:n
		ftAdd(ft,i,a[i])
	end
	for query in 1:q
		x,y,z = readline() |> split |> parseMap
		if x == 0
			ftAdd(ft,y+1,z)
		else
			println(ftSum(ft,y,z))
		end
	end
end

main()

Measured memory_bytes: 230532
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
''' 
------------------------
author : iiou16
------------------------
'''
import math


def main():
    N = int(input())

    _ans = math.floor(N / 1.08)
    if math.floor(_ans * 1.08) == N:
        print(int(_ans))
    elif math.floor((_ans + 1) * 1.08) == N:
        print(int(_ans + 1))
    else:
        print(":(")

if __name__ == '__main__':
    main()

Measured memory_bytes: 3060
#include<iostream>
#include<algorithm>
using namespace std;
int n,a[1<<17],s,x;
main()
{
	cin>>n;
	for(int i=0;i<=n;i++)
	{
		if(i<n)cin>>a[i+1];
		s+=abs(a[i+1]-a[i]);
	}
	for(int i=0;i<n;i++)
	{
		cout<<(s-abs(a[i+1]-a[i])-abs(a[i+2]-a[i+1])+abs(a[i+2]-a[i]))<<endl;
	}
}

Measured memory_bytes: 1792
#include "bits/stdc++.h"
#include <set>
using namespace std;
#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define RFOR(i, a, b) for (int i = (b)-1; i >= (a); i--)
#define rep(i, n) for (int i = 0; i < (n); i++)
#define rep1(i, n) for (int i = 1; i < (n); i++)
#define rrep(i, n) for (int i = (n)-1; i >= 0; i--)
#define all(i) (i).begin(), (i).end()
#define rall(i) (i).begin(), (i).end(), greater<int>()
#define int long long
#define elif else if
#define eb emplace_back
#define pb push_back
#define mp make_pair
#define fst first
#define sec second
#define mod 1000000007
#define INF 10e10
template <typename T>

void print(T x)
{
	std::cout << x << " ";
}
template <typename T>

void println(T x)
{
	std::cout << x << "\n";
}


signed main(void) {
	string s;
	cin >> s;
	if (s == "ARC")print("ABC");
	else print("ARC");
}

Measured memory_bytes: 3628
#include <iostream>
#define N 1000
using namespace std;

int main()
{
  int n,m,A[N][N],B[N],C[N],cnt=0;
  cin >> n >> m;
  for(int i=0;i<n;i++)
    {
      for(int j=0;j<m;j++)
        {
          cin >> A[i][j];
        }
    }
  for(int i=0;i<m;i++)
    {
      cin >> B[i];
    }
  for(int i=0;i<n;i++)
    {
      for(int j=0;j<m;j++)
        {
          int sum=A[i][j]*B[j];
          C[i]+=sum;
        }
    }
  for(int i=0;i<n;i++)
    {
      cout << C[i] <<endl;
    }
  return 0;
}

Measured memory_bytes: 3484
def main(argv)
  (h, w) = gets.chomp.split(' ').map(&:to_i)
  a = [nil] * h
  h.times{|y| a[y] = gets.chomp }

  counter = [0] * 26
  h.times{|y| w.times{|x| counter[a[y][x].ord - 'a'.ord] += 1 }}

  x = w / 2
  y = h / 2

  div4 = 0
  counter.size.times do |i|
    div4 += counter[i] / 4
    counter[i] = counter[i] % 4
  end

  if div4 < x * y then
    puts 'No'
    return
  end

  div2 = (div4 - (x * y)) * 2
  counter.size.times do |i|
    div2 += counter[i] / 2
    counter[i] = counter[i] % 2
  end

  flag = true
  if h % 2 == 0 then
    if w % 2 == 0 then
      flag = true
    else # w % 2 == 1
      flag = div2 == y
    end
  else # h % 2 == 1
    if w % 2 == 0 then
      flag = div2 == x
    else # w % 2 == 1
      flag = div2 == x + y
    end
  end
  puts (flag ? 'Yes' : 'No')
end

if self.to_s == 'main' then
  main(ARGV)
end

Measured memory_bytes: 1788
#include <cstdio>
#include <string>
#include <cmath>
#include <string>
#include <algorithm>
#include <iostream>
#include <map>
#include <vector>
#include <iomanip>
#include <tuple>
#include <queue>
using namespace std;
typedef long long ll;
#define rep(i, a, n) for (int i=a;i<n;++i)
#define repeq(i, a, n) for(int i=a;i<=n;++i)
#define per(i, a, n) for (int i=n-1; i>=a;--i)
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(), (x).end()

// C - Many Medians
int N;
vector<ll> x;
vector<ll> A;
vector<ll> ans;

int main(){
    cin >> N;
    rep(i, 0, N){
        ll tmp;
        cin >> tmp;
        x.push_back(tmp);
        A.push_back(tmp);
    }

    sort(all(A));
    rep(i, 0, N){
        if(x[i] >= A[(N/2)]){
            cout << A[N/2-1] << endl;
        }else{
            cout << A[N/2] << endl;
        }
    }

    return 0;
}




Measured memory_bytes: 5476
#include <iostream>
#include <string>
#include <algorithm>
#include <functional>
#include <vector>
#include <utility>
#include <cstring>
#include <iomanip>
#include <numeric>
#include <cmath>
#include <queue>
#include <map>
using namespace std;
typedef long long ll;
const int INF = 1<<30; 
const int MOD = 1e9 + 7;
const int dy[] = {1, 0, -1, 0};
const int dx[] = {0, 1, 0, -1};
int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n, q; cin >> n >> q;
    vector<ll> v(n);
    for(int i = 0; i < n; i++) cin >> v[i];
    for(int i = 0; i < q; i++)
    {
        ll x; cin >> x;
        int right = 0;
        ll sum = 0, res = 0;
        for(int left = 0; left < n; left++)
        {
            while(right < n && sum + v[right] <= x)
            {
                sum += v[right];
                right++;
            }
            res += right - left;
            if(left == right) right++;
            else sum -= v[left];
        }
        cout << res << endl;
    }
    return 0;
}


Measured memory_bytes: 3616
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
#define int long long
#define endl '\n'
#define pb push_back
#define fi first
#define se second
#define PI acos(-1)
#define all(c) (c).begin(),(c).end()
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef vector<int> vi;

template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

#define TRACE
#ifndef ONLINE_JUDGE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
	cerr << name << " : " << arg1 << endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
	const char* comma = strchr(names + 1, ',');cerr.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
}
#else
#define trace(...)
#endif

int modpow(int x, int n, int m) {
	x %= m;
	int res = 1;
	while(n > 0) {
		if(n & 1)
			res = res * x % m;
		x = x * x % m;
		n >>= 1;
	}
	return res;
}

const ll inf = 2e18;
const int mod = 1e9 + 7;
const int N = 1e5 + 10;

int dp[10010], a[1010], b[1010];

signed main() {
	ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
	srand(chrono::steady_clock::now().time_since_epoch().count());
	#ifndef ONLINE_JUDGE
		// freopen("input.txt", "r", stdin);
		// freopen("output.txt", "w", stdout);
	#endif

	int h, n;
	cin >> h >> n;
	for(int i = 0; i < 10010; i++) {
		dp[i] = inf;
	}
	for(int i = 1; i <= n; i++) {
		cin >> a[i] >> b[i];
	}
	dp[0] = 0;
	int ans = inf;
	for(int i = 0; i < h; i++) {
		for(int j = 1; j <= n; j++) {
			if(i + a[j] >= h) {
				ans = min(ans, dp[i] + b[j]);
			}
			else {
				dp[i + a[j]] = min(dp[i + a[j]], dp[i] + b[j]);
			}
		}
	}
	cout << ans;

	return 0;
}

Measured memory_bytes: 384
#include <iostream>
using namespace std;
class game{
public:
	int target;
	int n;
	int *p;
	game(){};
	void malloc(int n_){p = new int [n_];n = n_;}
	~game(){delete [] p;}
	void run(int *);
};

void game::run(int *point){
	int s = n;
	for(int i = 0;i < n;i++){
		if(i==target)continue;
		if(p[i] == target){
			point[i]++;
			s--;
		}
	}
	point[target] += s;
}

int main(){
	int n,m;
	cin>>n;
	cin>>m;
	game *g = new game[m];
	for(int i = 0;i < m;i++){
		g[i].malloc(n);
		cin>>g[i].target;
		g[i].target--;
	}
	int *point = new int [n];
	for(int i = 0;i < n;i++){
		point[i] = 0;
	}
	for(int i = 0;i < m;i++){
		for(int j = 0;j < n;j++){
			cin>>g[i].p[j];
			g[i].p[j]--;
		}
		g[i].run(point);
	}
	for(int i = 0;i < n;i++){
		cout<<point[i]<<endl;
	}
	delete [] g;
}

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

int N;
vector<string> V;

int main(void) {
	cin >> N;
	V.resize(N);
	for (int i = 0; i < N; ++i)
		cin >> V[i];

	sort(V.begin(), V.end());
	V.erase(unique(V.begin(), V.end()), V.end());

	cout << V.size() << '\n';
	return 0;
}


Measured memory_bytes: 9496
#include<iostream>
#include<algorithm>
#include<string>
#include<vector>
using namespace std;
int main() {
	int k, n;
	long int h[100000], m = 1000000000;
	cin >> n >> k;
	for (int i = 0; i < n; ++i)cin >> h[i];
	sort(h, h + n);
	for (int i = 0; i < n - k + 1; ++i) {
		m = min(m, h[i + k - 1] - h[i]);
	}
	cout << m << endl;
	return 0;
}

Measured memory_bytes: 1024
/* Many Formulas
   部分和の問題*/

#include <bits/stdc++.h>
using namespace std;

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

long long int S, n;

long long int dfs(long long int s, int digit, int depth){
    if(depth == n) return s;
    long long int a = s/pow(10,digit+1);
    long long int b = s - a*pow(10,digit+1);
    return dfs(s,digit+1,depth+1) + dfs(a,0,depth+1) + b*pow(2, n-depth-1);
}

void solve(){
    long long int ans = dfs(S, 0, 0);
    printf("%lld",ans);
}

int main(){
    scanf("%lld",&S);
    n = log10(S);
    solve();
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
const int MOD=2019;

int main(){
  string s;
  cin >> s;
  int n= s.size();
  map<int, int> mp;
  long long ans=0;
  int keta = 1;
  int tot =0;
  mp[0] =1;
  for(int i=0; i<n; ++i){
    int si= s[n-i-1] - '0';
    tot += si*keta%MOD;
    tot %=MOD;
    //cout << keta << " " << tot << endl;
    ans += mp[tot];
    ++mp[tot];
    keta *= 10;
    keta %= MOD;
  }
  cout << ans << endl;
}

Measured memory_bytes: 3680
// https://atcoder.jp/contests/abc079/tasks/abc079_a
#include <bits/stdc++.h>
using namespace std;

int main(void)
{
  int N;
  cin >> N;

  int S1 = N / 1000;
  int S2 = (N - S1 * 1000) / 100;
  int S3 = (N - S1 * 1000 - S2 * 100) / 10;
  int S4 = (N - S1 * 1000 - S2 * 100 - S3 * 10);

  if (S1 == S2 && S2 == S3 || S2 == S3 && S3 == S4)
    cout << "Yes" << endl;
  else
    cout << "No" << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
#include<iomanip>
#include<utility>
#include<iomanip>
#include<map>
#include<cmath>
#include<cstdio>
#define rep(i,n) for(int i=0; i<(n); ++i)
using namespace std;
using ll =long long;
using P = pair<int,int>;

int main(){
    int n;
    cin >> n;
    vector<int> P(n);
    rep(i,n) cin >> P[i];
    sort(P.begin(),P.end());
    int ans = P[n-1]/2;
    rep(i,n-1) ans+=P[i];
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main
{
  public static void main(String[] args)
    {
      Scanner sc = new Scanner(System.in);
      double r = sc.nextDouble();
      double pi = Math.PI;
      double area = r*r*pi;
      double length = 2*r*pi;
      System.out.printf("%f %f",area,length);
      sc.close();
    }
}


Measured memory_bytes: 28324