akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

int main(int argc, char const *argv[])
{
    int N;
    cin >> N;
    vector<int> d;
    int tmp;
    for (int i = 0; i < N; i++)
    {
        cin >> tmp;
        d.emplace_back(tmp);
    }

    sort(d.begin(), d.end());
    cout << (d[N / 2] - d[N / 2 - 1]) << endl;
    return 0;
}

Measured memory_bytes: 892
#include <stdio.h>
#include <string>
#include <cstring>
#include <stdlib.h>
#include <math.h>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <list>
#include <iterator>
#include <assert.h>
#pragma warning(disable:4996) 
 
typedef long long ll;
#define MIN(a, b) ((a)>(b)? (b): (a))
#define MAX(a, b) ((a)<(b)? (b): (a))
#define LINF 9223300000000000000
#define INF 2140000000
const long long MOD = 1000000007;
using namespace std;


int main(int argc, char* argv[])
{
    int n;
    scanf("%d", &n);

    vector<int> a(n);
    int cnt=0;
    int i;
    int max=0;
    for(i=0; i<n; i++) {
        scanf("%d", &a[i]);
        if(i>0) {
            if(a[i]<=a[i-1]) {
                cnt++;
                max=MAX(max,cnt);
            }
            else {
                cnt=0;
            }
        }
    }
    printf("%d\n", max);



    return 0;
}


Measured memory_bytes: 640
import math
import heapq

n, m = map(int, input().split())
A = list(map(int, input().split()))
A = list(map(lambda x:x*(-1), A))
heapq.heapify(A)
for i in range(m):
    min = (-1)*((-1)*(heapq.heappop(A))//2)
    heapq.heappush(A, min)


print(int(sum(A))*(-1))


Measured memory_bytes: 14380
N=int(input())
d=input().split()
d=[int(i) for i in d]
d_max=max(d)

#import numpy
#m=int(numpy.median(d)-2)

y=sorted(d)
z=len(d)
w=int(z/2)

m=y[w-1]
n=y[w]
#print(y)
print(n-m)

# ans=0
# flag=0
# for K in range(m,d_max):
#     arc=0
#     abc=0
#     if flag==1:
#         break
#     for i in range(len(d)):
#         if(K > d[i]):
#             abc+=1
#         if(K <= d[i]):
#             arc+=1
#         if(abc > len(d)/2):
#             flag=1
#             break
#         print(arc,abc,ans,j,d[i])
#     if abc==arc:
#         ans+=1
# print(ans)

Measured memory_bytes: 14396
#include <stdio.h>
#include <string.h>

int main(void){
	char a[11];
	char b[11];
	char c[21];
	int x=0;
	scanf("%s",a);
	int n;
	scanf("%d",&n);
	int i;
	for (i=0;i<n;i++){
		scanf("%s",b);
		strcpy(c,b);
		strcat(c,b);
		if (strstr(c,a)!=NULL)
		{
			x++;
		}
	}
	printf("%d\n",x);
	return 0;
}

Measured memory_bytes: 624
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<bool> vb;
typedef vector<string> vs;
typedef vector<ll> vl;
typedef vector<vector<int, int> > vvi;
#define pb push_back
#define mp make_pair
#define f first
#define s second
#define in insert
#define FOR(i,a,b) for (int i = a; i < b; i++)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define speed ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
const int INF = 1e9 + 5;
int main(){
    int n;
    cin >> n;
    vi b;
    vi a;
    int x;
    for(int i = 0; i < n-1; i++){
        cin >> x;
        b.pb(x);
    }
    a.pb(b[0]);
    for(int i = 1; i < n-1; i++){
        a.pb(min(b[i-1], b[i]));
    }
    a.pb(b[b.size()-1]);
    int sum = 0;
    for(int i = 0; i < n; i++){
        sum+=a[i];
    }
    cout << sum;


}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef unsigned long long ull;
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;



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

    string s;
    cin >> s;
    int odd = 0;
    int L = 0, R = (int)s.size() - 1;
    while (L <= R) {
        if (s[L] == s[R]) {
            ++L;
            --R;
            continue;
        }
        if (s[L] == 'x') {
            ++L;
            ++odd;
            continue;
        }
        if (s[R] == 'x') {
            --R;
            ++odd;
            continue;
        }
        odd = -1;
        break;
    }
    cout << odd << endl;

    return 0;
}


Measured memory_bytes: 512
#include<bits/stdc++.h>
using namespace std;
#define MEM(a, b) memset(a, (b), sizeof(a))
#define FOR(i, j, k, in) for (int i=j ; i<k ; i+=in)
#define RFOR(i, j, k, in) for (int i=j ; i>=k ; i-=in)
#define REP(i, j) FOR(i, 0, j, 1)
#define RREP(i, j) RFOR(i, j, 0, 1)
#define MP make_pair
#define PB push_back
#define INF (int)1e9
#define EPS 1e-9	
#define MOD 1000000007
typedef pair<int, int> PII;
typedef vector<long long int> VI;
typedef vector<string> VS;
typedef vector<PII> VII;
typedef vector<VI> VVI;
typedef map<int,int> MPII;
typedef set<int> SETI;
typedef multiset<int> MSETI;
typedef long int int32;
typedef unsigned long int uint32;
typedef long long int int64;
typedef unsigned long long int  uint64;

void solve() {
	int n;
	cin >> n;
	int w;
	cin >> w;

	VVI weight(n,VI(2));
	VVI dp(n+1,VI(w+1,0));
	for(int i = 0; i < n; i++) {
		for(int j = 0; j < 2; j++) {
			cin >> weight[i][j];
		}
	}
	for(int i = 0; i <= n; i++) {
		for(int j = 0; j <= w; j++) {
			if(i == 0 || j == 0) continue;
			 int64 ans = 0;
			if(j-weight[i-1][0] >= 0) {
				ans = max(ans,dp[i-1][j-weight[i-1][0]]+weight[i-1][1]);
			}
			dp[i][j] = max(ans,dp[i-1][j]);
		}
	}
	cout << dp[n][w];
}

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

	return 0;
}

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

#define watch(x) cout << (#x) << " is " << (x) << endl
#define fr(i,n) for(int i=0; i<n; i++)
#define rep(i, st, en) for(int i=st; i<=en; i++)
#define repn(i, st, en) for(int i=st; i>=en; i--)
#define sq(a) (a*a)
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
ll mod = 1e9+7;

const int inf = INT_MAX;
int n, m, x;
vector<int> c;
vector<vector<int>> a;
int ans = inf;

void rec(int i, int mask, vector<int>& v, int cost){
    int mn = *min_element(v.begin(), v.end());
    if(mn >= x){
        ans = min(ans, cost);
        return;
    }
    if(i == n) return;

    rec(i+1, mask, v, cost);

    fr(j, m) v[j] += a[i][j];
    rec(i+1, mask^(1<<i), v, cost + c[i]);
    fr(j, m) v[j] -= a[i][j];
}

void solve(){
    cin>>n>>m>>x;
    int z;
    a.resize(n);
    c.resize(n);
    fr(i, n){
        cin>>c[i];
        fr(j, m){
            cin>>z;
            a[i].push_back(z);
        }
    }

    vector<int> v(m, 0);
    rec(0, 0, v, 0);

    if(ans == inf){
        cout<<-1;
    } else cout<<ans;
}

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

    ll t = 1;
    //  cin>>t;
    while(t--){
        solve();
    }

    return 0;
}



Measured memory_bytes: 3608
#!/usr/bin/ruby
Z=10**9+7
def d(x,y) x.zip(y).reduce(0){|s,(a,b)|s+a*b} end
def mul(x,y)
	y=y.transpose
	[[d(x[0],y[0])%Z,d(x[0],y[1])%Z],[d(x[1],y[0])%Z,d(x[1],y[1])%Z]]
end
def pow(x,y)
	z=1
	while y>0
		z=z*x%Z if y%2>0
		x=x*x%Z
		y/=2
	end
	z
end
h,w,k=gets.split.map(&:to_i)
k-=1
m=$<.map{|e|e.chomp.chars};mt=m.transpose
c=m.count{|s|s[0]=='#'&&s[-1]=='#'}
d=mt.count{|s|s[0]=='#'&&s[-1]=='#'}
if c>0&&d>0
	p 1
	exit
end
if d>0
	c,d=d,c
	m,mt=mt,m
	h,w=w,h
end
a=b=0
m.each{|s|w.times{|i|
	a+=1 if s[i]=='#'
	b+=1 if i<w-1&&s[i]=='#'&&s[i+1]=='#'
}}
if c==0&&d==0
	p pow(a,k)
	exit
end

e=[[1,0],[0,1]]
m=[[a,-b],[0,c]]
while k>0
	e=mul(e,m) if k%2>0
	m=mul(m,m)
	k/=2
end
p (e[0][0]+e[0][1])%Z

Measured memory_bytes: 89212
n, m = map(int, input().split())
A = set()
B = set()
for i in range(m):
    a, b = map(int, input().split())
    if a == 1:
        B.add(b)
    if b == n:
        A.add(a)
        
if len(A&B) != 0:
    print('POSSIBLE')
else:
    print('IMPOSSIBLE')

Measured memory_bytes: 19024
#include <bits/stdc++.h>
using namespace std;
int N, M; 
char S[110][110]; 
vector<int> E[10500]; 
int match[10500];
bool used[10500];
int ans; 
bool dfs(int v){
	used[v] = true; 
	for(int u : E[v]){
		int w = match[u]; 
		if(w < 0 || !used[w] && dfs(w)){
			match[u] = v; match[v] = u; 
			return true; 
		}
	}
	return false; 
}
int f(int i, int j){
	return i * (M+1) + j; 
}
int main(){
	cin >> N >> M; 
	for(int i = 1; i <= N; i++){
		for(int j = 1; j <= M; j++){
			cin >> S[i][j]; 
		}
	}
	for(int i = 1; i <= N; i++){
		for(int j = 1; j <= M; j++){
			if(S[i][j] == '#') continue; 
			if(S[i+1][j] == '.'){
				E[f(i, j)].emplace_back(f(i+1, j)); 
				E[f(i+1, j)].emplace_back(f(i, j)); 
			}
			if(S[i][j+1] == '.'){
				E[f(i, j)].emplace_back(f(i, j+1)); 
				E[f(i, j+1)].emplace_back(f(i, j)); 
			}
		}
	}
	for(int i = 0; i < (N+2)*(M+2); i++) match[i] = -1; 
	for(int i = 0; i < (N+2)*(M+2); i++){
		if(match[i] < 0){
			fill(used, used + (N+2)*(M+2), false); 
			if(dfs(i)) ans ++; 
		}
	}
	cout << ans << "\n"; 
	for(int i = 1; i <= N; i++){
		for(int j = 1; j <= M; j++){
			if(S[i][j] == '#') cout << '#'; 
			else if(match[f(i, j)] < 0) cout << '.'; 
			else if(match[f(i, j)] == f(i-1, j)) cout << '^'; 
			else if(match[f(i, j)] == f(i+1, j)) cout << 'v'; 
			else if(match[f(i, j)] == f(i, j-1)) cout << '<'; 
			else if(match[f(i, j)] == f(i, j+1)) cout << '>'; 
		}
		cout << "\n"; 
	}
}

Measured memory_bytes: 4440
from math import ceil,floor
x = int(input())

lower_sum = ceil(x/105)
upper_sum = floor(x/100)
num_list = list(range(lower_sum, upper_sum+1))

for i in num_list:
    for a in range(i+1):
        for b in range(i+1-a):
            for c in range(i+1-a-b):
                for d in range(i+1-a-b-c):
                    for e in range(i+1-a-b-c-d):
                        for f in range(i+1-a-b-c-d-e):
                            if 100*a + 101*b + 102*c + 103*d + 104*e + 105*f == x:
                                print("1")
                                exit()

print("0")

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

int main(){
  double x1, y1, x2, y2;
  cin >> x1 >> y1 >> x2 >> y2;

  double res = 0;
  res = sqrt(pow(x2-x1, 2) + pow(y2-y1,2));

  printf("%.8lf\n", res);
}



Measured memory_bytes: 3208
#include<bits/stdc++.h>
using namespace std;
#define ALL(x) x.begin(),x.end()
#define rep(i,n) for(int i=0;i<n;i++)
#define debug(v) cout<<#v<<":";for(auto x:v){cout<<x<<' ';}cout<<endl;
#define INF 1000000000
#define mod 1000000007
using ll=long long;
const ll LINF = 1001002003004005006ll;
int dx[]={1,0,-1,0};
int dy[]={0,1,0,-1};
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
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; }

vector<ll> l,r;



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

    ll n,k,lw,hi;cin>>n>>k>>lw>>hi;
    rep(i,n){
        ll t;cin>>t;
        if(i%2==0)  l.push_back(t);
        else        r.push_back(t);
    }

    //r
    vector<vector<ll>> v(n+1);
    for(int bit=0;bit<(1<<r.size());bit++){
        int mai=__builtin_popcount(bit);
        ll en=0;
        rep(i,r.size()){
            if((bit>>i)&1) en+=r[i];
        }
        v[mai].push_back(en);
    }

    rep(i,n) sort(ALL(v[i]));


    ll ans=0;
    //l
    for(int bit=0;bit<(1<<l.size());bit++){
        int mai=__builtin_popcount(bit);
        int need=k-mai;
        if(need<0) continue;
        ll en=0;
        rep(i,l.size()){
            if((bit>>i)&1) en+=l[i];
        }
        ans+=lower_bound(ALL(v[need]),hi-en+1)-lower_bound(ALL(v[need]),lw-en);
    }
    cout<<ans<<endl;
    return 0;
}



Measured memory_bytes: 12348
#include <bits/stdc++.h>
#include <math.h>
#include <cmath>

using namespace std;
using ll =long long;
using vi = vector<int>; 
using vvi = vector<vi>; 
using vl = vector<ll>; 
using vvl = vector<vl>; 
using vs = vector<string>;
using vvs = vector<vs>; 
using vc = vector<char>;
using vvc = vector<vc>; 
using vb = vector<bool>;
using vvb = vector<vb>; 

#define rep(i,n); for( int i =0; i < n ; i ++)
#define all(a) a.begin(),a.end()
#define pb(a) push_back(a)
#define pd(a) printf("%.10f\n",a)
#define mem(a) memset(a,0,sizeof(a))
#define f(i,a,b) for(int i=a;i<b;i++)
#define pri(a)  printf("%.14lf\n",a);
#define MOD 1000000007
typedef pair<int, int> P;
bool is_int_lround(double x){
  return std::lround(x)==x;
}
ll keta(ll x){
  ll n=0;
  while(x>0){
    x /=10 ;
    n ++;
  }
  return n;
}

ll conbi(int n,int m){
  
  cin>>n>>m;
  vector<ll> a(100);
  a[0] =1;
  for(int i=0;i<14;i++){
    a[i+1]=a[i]*(i+1);
  }
  return a[n] /(a[m] *a[n-m]);
}

long long modpow(long long a, long long n, long long mod) {
    long long res = 1;//繰り返し二乗法
    while (n > 0) {
        if (n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}
ll kaijo(ll x){
  ll z=1;
  while(x>0){
    z *=x;
    z %=MOD;
    x--;
  }
  return z;
}
ll yakusu_num(ll n){
  vl yakusu(n+1,1);
  for(ll i=2;i*i<=n;i++){ 
    while(n%i==0){
      n /=i;
      yakusu[i]++;
    }
  }
  if(n!=1)yakusu[n]++;
  ll num=1;
  for(ll i=0;i <=n;i++){
    num*=yakusu[i];
  }
  return num;
}


//cout<<""<<endl;
int main(){
  ll A,B,C,X,Y;cin>>A>>B>>C>>X>>Y;
  ll ans=1000000000;
  rep(a,max(X,Y)+1){
    ans= min(ans,2*a*C+A*max(X-a,0LL)+B*max(Y-a,0LL));
  }
  cout<<ans<<endl;
}


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

#define M_PI       3.14159265358979323846   // pi

using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> VI;
typedef pair<ll, ll> P;
typedef tuple<ll, ll, ll> t3;
typedef tuple<ll, ll, char, ll> t4;

#define rep(a,n) for(ll a = 0;a < n;a++)
#define repi(a,b,n) for(ll a = b;a < n;a++)

const ll mod = 1000000007;

static const ll INF = 1e15;

typedef ll Weight;
struct Edge {
	int from, to;
	Weight weight;
	Edge(int src, int dst) :
		from(src), to(dst), weight(0) { }

	Edge(int src, int dst, Weight weight) :
		from(src), to(dst), weight(weight) { }
};
bool operator < (const Edge& e, const Edge& f) {
	return e.weight != f.weight ? e.weight > f.weight :
	e.from != f.from ? e.from < f.from : e.to < f.to;
}

struct UndirectionalCompare {
	bool operator() (const Edge& e, const Edge& f) const {
		if (min(e.from, e.to) != min(f.from, f.to))
			return min(e.from, e.to) < min(f.from, f.to);
		return max(e.from, e.to) < max(f.from, f.to);
	}
};

typedef vector<Edge> Edges;
typedef vector<Edges> Graph;

typedef vector<Weight> Array;
typedef vector<Array> Matrix;
typedef set<Edge, UndirectionalCompare> Edgeset;

struct topoloricalSort_runnner {
	bool visit(const Graph& g, int v, vector<int>& order, vector<int>& color) {
		color[v] = 1;
		for (auto e : g[v]) {
			if (color[e.to] == 2) continue;
			if (color[e.to] == 1) return false;
			if (!visit(g, e.to, order, color)) return false;
		}
		order.push_back(v); color[v] = 2;
		return true;
	}
	
	bool topologicalSort(const Graph& g, vector<int>& order) {
		int n = g.size();
		vector<int> color(n);
		rep(u, n) if (!color[u] && !visit(g, u, order, color))
			return false;
		reverse(order.begin(), order.end());
		return true;
	}
};

int main(void)
{
	int v, e;
	cin >> v >> e;

	Graph g(v);
	rep(i, e) {
		int s, t;
		cin >> s >> t;
		g[s].push_back({s,t,0});
	}
	topoloricalSort_runnner runner;
	vector<int> order;
	if (runner.topologicalSort(g, order)) {
		for (auto o : order) {
			cout << o << endl;
		}
	}
	return 0;
}



Measured memory_bytes: 4428
#include <iostream>
#include <vector>
#include <algorithm>
#include <iterator>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <string>
#include <cmath>
using namespace std;
#define MOD 1000000007
#define INF 1<<30
#define LINF (ll)1<<62
#define MAX 510000
#define rep(i,n) for(ll i=0; i<(n); i++)
#define REP(i,a,b) for(ll i=(a); i<(b); i++)
#define all(x) (x).begin(),(x).end()
#define uni(q) unique(all(q)),q.end()
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef pair<ll, ll> P;
typedef vector<pair<ll, ll>> vpl;

vl bit(40,0),fun(40),sum(41,0);
ll n,k;

int main(){
    string a,b; cin >> a >> b;
    ll A = a.size();
    ll B = b.size();
    if(A > B){
        puts("GREATER");
        return 0;
    }
    else if(A < B){
        puts("LESS");
        return 0;
    }
    else{
        rep(i,A){
            if(a[i] > b[i]){
                puts("GREATER");
                return 0;
            }else if(a[i] < b[i]){
                puts("LESS");
                return 0;
            }
        }
    }
    puts("EQUAL");
}


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

using namespace std;

#define INF 100000000
#define YJ 1145141919
#define INF_INT_MAX 2147483647
#define INF_LL 9223372036854775
#define INF_LL_MAX 9223372036854775807
#define EPS 1e-10
#define MOD 1000000007
#define MOD9 998244353
#define Pi acos(-1)
#define LL long long
#define ULL unsigned long long
#define LD long double

#define int long long

using II = pair<int, int>;

int gcd(int a, int b) { return b != 0 ? gcd(b, a % b) : a; }
int lcm(int a, int b) { return a * b / gcd(a, b); }
int extgcd(int a, int b, int &x, int &y) { int g = a; x = 1; y = 0; if (b != 0) g = extgcd(b, a % b, y, x), y -= (a / b) * x; return g; }

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(a)  begin((a)), end((a))
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())

signed main()
{
  int K, X;
  cin >> K >> X;
  cout << (500*K >= X ? "Yes" : "No") << endl;
  return 0;
}


Measured memory_bytes: 384
#include<cstdio>
using namespace std;
int main()
{
	int w,h,n,i,a,b,y[1000],x[1000],sum;
	scanf("%d %d %d",&w,&h,&n);
	for(i=0;i<n;i++){
		scanf("%d %d",&x[i],&y[i]);
	}
	sum=0;
	for(i=0;i<n-1;i++){
		a=x[i+1]-x[i];
		b=y[i+1]-y[i];
		// printf("%d %d\n",a,b);
		if(a>=0&&b>=0||a<0&&b<0){
			if(a<0)	a*=-1;
			if(b<0)	b*=-1;
			if(a>b)	sum+=a;
			else	sum+=b;
		}
		else{
			if(a<0)	a*=-1;
			if(b<0)	b*=-1;
			sum+=a+b;
		}
	}
	printf("%d\n",sum);
	return 0;
}


Measured memory_bytes: 2744
#include <bits/stdc++.h>
using namespace std;
int l[110], n;
int main(){
	scanf("%d",&n);
  	for (int i=1;i<=n;i++) scanf("%d",&l[i]);
  	int ans = 0;
  	for (int i=1;i<=n;i++)
      for (int j=i+1;j<=n;j++)
        for(int k=j+1;k<=n;k++){
        	if (l[i] == l[j] || l[i] == l[k] || l[j] == l[k]) continue;
          	if (l[i] + l[j] <= l[k]) continue;
          	if (l[i] + l[k] <= l[j]) continue;
          	if (l[j] + l[k] <= l[i]) continue;
          	ans++;
        }
  	printf("%d\n",ans);
  	return 0;
}

Measured memory_bytes: 3832
#include<iostream>
        #include<string>
        using namespace std;
        int main(){
        std::string a;
        int s,s2;
        char st,en;
        cin>>a;
        a.c_str();
        s=a.size();
        s2=s-2;
        st=a[0];
        en=a[s-1];
        cout<<st<<s2<<en<<endl;
        return 0;
        }

Measured memory_bytes: 256
N,K,Q = map(int,input().split())

Answer_list = list()
point_list = [0] *N
for i in range(0,Q):
    Answer_list.append(int(input()))

for j in Answer_list:
    point_list[j-1] += 1

for l in point_list:
    if Q - l >= K:
        print("No")
    else:
        print("Yes")


Measured memory_bytes: 8632
#include <iostream>
#include <sstream>
#include <vector>
#include <string>
#include <cmath>
#include <algorithm>
#include <map>
#include <iomanip>
#include <stdio.h>

using namespace std;

//typedefリスト
typedef vector<long long int> vint;
typedef vector<vector<long long int>> vvint;
typedef vector<string> vstr;
typedef long long int llint;

llint gcd(llint x, llint y) {
	while (y != 0) {
		if (x > y) {
			llint r = x % y;
			x = y;
			y = r;
		}
		else {
			llint r = y % x;
			y = r;
		}
	}
	return x;
}

int main(void) {
	int X,days;
	cin >> X;
	
		days =abs( X - 9);
		int ans = days % 7;
	if (X >= 9) {
		switch (ans)
		{
		case 0:cout << "sat" << endl;
			break;
		case 1:cout << "sun" << endl;
			break;
		case 2:cout << "mon" << endl;
			break;
		case 3:cout << "tue" << endl;
			break;
		case 4:cout << "wed" << endl;
			break;
		case 5:cout << "thu" << endl;
			break;
		case 6:cout << "fri" << endl;
			break;
		}
	}
	else {
		switch (ans)
		{
		case 0:cout << "sat" << endl;
			break;
		case 6:cout << "sun" << endl;
			break;
		case 5:cout << "mon" << endl;
			break;
		case 4:cout << "tue" << endl;
			break;
		case 3:cout << "wed" << endl;
			break;
		case 2:cout << "thu" << endl;
			break;
		case 1:cout << "fri" << endl;
			break;
		}
	}
}



Measured memory_bytes: 3136
#include<stdio.h>
#include<math.h>
#include<iostream>
#include<string.h>
using namespace std;
int main()
{
	char name1[110], name2[110], name3[110];
	int lname1, lname2, lname3 ;
	int i;
	scanf("%s %s %s", &name1, &name2, &name3);
	lname1 = strlen(name1);
	lname2 = strlen(name2);
	lname3 = strlen(name3);
	printf("A%cC\n", name2[0]); 
	return 0;

}

Measured memory_bytes: 256
# 幅優先探索（行きがけ）
import collections
import sys
import copy
import re


def I(): return int(sys.stdin.readline().rstrip())
def LI(): return list(map(int, sys.stdin.readline().rstrip().split()))
def S(): return sys.stdin.readline().rstrip()
def LS(): return list(sys.stdin.readline().rstrip().split())


def main():
    N, K = LI()
    pArray = LI()
    pArray.sort()

    count = 0
    for i in range(K):
        count += pArray[i]

    print(count)


if __name__ == '__main__':
    main()


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

#define rep(i, a, b) for(int i = (a); i < (b); ++i)
#define all(x) begin(x), end(x)
typedef long long ll;
typedef pair<int, int> pii;
const int inf=1010001000;
const ll  INF=1001000100010001000;
const int mod=(int)1e9+7;

int main(){
    int h,m,h2,m2,k;
    cin>>h>>m>>h2>>m2>>k;
    cout<<(60*h2+m2)-(60*h+m)-k<<endl;
return 0;
}

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

using namespace __gnu_pbds;
using namespace std;


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


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


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


int32_t main()
{
    fast;
    int n,k;cin>>n>>k;
    int *arr=new int[n];
    for(int i=0;i<n;i++)
        cin>>arr[i];
    int ans=0;
    for(int i=0;i<n;i++)
    {
        int overall_chhote=0,agge_chhote=0;
        for(int j=0;j<n;j++)
        {
            if(arr[j]<arr[i])
            {
                overall_chhote++;
                if(j>i)
                    agge_chhote++;
            }
        }
        ans+=agge_chhote*k,ans%=mod;
        int val=k*(k-1)/2;
        val%=mod;
        val*=overall_chhote,val%=mod;
        ans+=val;
        ans%=mod;
    }
    cout<<ans;
}

Measured memory_bytes: 256
(let* ((n (read))
       (arr (make-array n :initial-element 0 :element-type 'fixnum))
       (ll-arr nil)
       (x 0)
       (y 0))
  (loop :for a :from 0 :upto (1- n) :do(setf (aref arr a) (read)))
  (setf ll-arr (copy-seq arr))
  (sort arr #'<)
  (setf x (aref arr (ceiling (1- n) 2)))
  (setf y (aref arr (floor (1- n) 2)))
  (map nil (lambda (n) (format t "~A~%" (if (<= x n) y x))) ll-arr))

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

int main() {
    int N; cin >> N;
    vector<int> P(N); for (int i = 0; i < N; i++) cin >> P[i];
    int mi = P[0];
    int ans = 1;
    for (int i = 1; i < N; i++) {
        if (mi >= P[i]) {
            ans++;
            mi = P[i];
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 1024
import sys
mod = pow(10, 9) + 7
sys.setrecursionlimit(pow(10, 8))

def power(x, y):
    if   y == 0: return 1
    elif y == 1     : return x % mod
    elif y % 2 == 0 : return power(x, y//2)**2 % mod
    else: return power(x, (y-1)//2)**2 * x % mod
    
def mul(a, b):
    return ((a % mod) * (b % mod)) % mod

def div(a, b):
    return mul(a, power(b, mod-2))
def div2(a, b):
    return mul(a, modinv(b))

def modinv(a):
    b, u, v = mod, 1, 0
    while b:
        t = a//b
        a, u = a-t*b, u-t*v
        a, b, u, v = b, a, v, u
    u %= mod
    return u

def cmb(n, r, mod):
    if ( r<0 or r>n ):
        return 0
    r = min(r, n-r)
    return g1[n] * g2[r] * g2[n-r] % mod

NNN = (10)
inverse = [0, 1]

for i in range( 2, NNN + 1 ):
    inverse.append( ( -inverse[mod % i] * (mod//i) ) % mod )

N, = map(int, input().split())
xs = list(map(int, input().split()))
xs.sort()
r = 0
for i, x in enumerate(xs[::-1]):
    r = (r + mul(((i+1)+1),x))%mod
f = power(2,N)
r = mul(mul(mul(r, f),f), inverse[4])
print(r)


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

using namespace std;
int n, mn = 3e5, pref[300001][2];
string s;
int main(){
    cin >> n >> s;
    for(int i = 0; i < s.size(); i++){
        if(s[i] == 'E'){
            pref[i][0]++;
        }
        else{
            pref[i][1]++;
        }
        pref[i][0] += pref[i - 1][0];
        pref[i][1] += pref[i - 1][1];
     }
     for(int i = 0; i < s.size(); i++){
        mn = min(mn, pref[i - 1][1] + pref[s.size() - 1][0] - pref[i][0]);
     }
     cout << mn;
}


Measured memory_bytes: 2948
#include <bits/stdc++.h>
#include <string>
#include <vector>
#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(){
    ll n;
    cin >> n; 
    vector<ll> a(n);
    rep(i,n) cin >> a[i];
    sort(a.rbegin(),a.rend());//降順にソート
     ll ans = 0;
     int t = n-1;
    rep(i,n){
        int lim = 2;
        if (i==0) lim = 1;
        rep(j,lim){
            if (t > 0) {
                ans += a[i];
                t--;
            }
        }
    }
     cout << ans <<endl;
}

Measured memory_bytes: 4792
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vl = vector<ll>;
using vvl = vector<vl>;
using vi = vector<int>;
using vvi = vector<vi>;
#define ote(x) cout<<(x)<<endl
#define all(x) (x).begin(),(x).end()
#define rp(i,s,e) for(int i=(s);i<(e);++i)

int main(){
	string s; cin>>s;
	ote(s[0]+to_string(s.size()-2)+s[s.size()-1]);
}


Measured memory_bytes: 256
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Scanner;
import java.util.regex.Pattern;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        Scanner in = new Scanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        sumitrust2019B solver = new sumitrust2019B();
        solver.solve(1, in, out);
        out.close();
    }

    static class sumitrust2019B {
        public void solve(int testNumber, Scanner in, PrintWriter out) {
            // 整数の入力
            int n = Integer.parseInt(in.next());
            String ans = ":(";
            String[] x = new String[2];
            String[] x2 = new String[2];

            x = String.valueOf(n / 1.08).split(Pattern.quote("."), 0);
            x2 = String.valueOf((Integer.valueOf(x[0]) * 1.08)).split(Pattern.quote("."), 0);

            if (String.valueOf(n).equals(x2[0])) {
                ans = x[0];
            } else {
                x2 = String.valueOf(((Integer.valueOf(x[0]) + 1) * 1.08)).split(Pattern.quote("."), 0);
                if (String.valueOf(n).equals(x2[0])) ans = String.valueOf(Integer.valueOf(x[0]) + 1);

            }

            // 出力
            out.println(ans);

        }

    }
}



Measured memory_bytes: 22740
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
int main(){
  int n;
  cin >> n;
  vector<ll> a(n);
  vector<ll> ans(n+1);
  for(int i = 0; i < n-1; i++){
      cin >> a.at(i);
      ans[a[i]]++;
  }
  for(int i = 1; i < n+1; i++){
      // cout << ans[i]<< endl;
    printf("%lld\n", ans[i]);
  }
}


Measured memory_bytes: 6352
#include <bits/stdc++.h>
#define rep(i, l, r) for(register int i = l; i < r; i++)
#define hrp(i, l, r) for(register int i = l; i <= r; i++)
#define rev(i, r, l) for(register int i = r; i >= l; i--)
#define pb push_back
#define int ll
#ifndef JOEON
#define D(...)
#define R(x, l)
#endif
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
template<typename tn> inline tn next(void);
template<typename tn> inline ostream& operator << (ostream& os, const vector<tn>& v);
signed main(void)
{
	#ifdef JOEON
//		freopen("C:\Users\Joeon\Desktop\IN.txt", "r", stdin);
//		freopen("C:\Users\Joeon\Desktop\OUT.txt", "w", stdout);
	#endif
	ios::sync_with_stdio(false);
	cin.tie(0);
	int a, b, c, d;
	cin>>a>>b>>c>>d;
	if ((abs(a-b) <= d && abs(b-c) <= d) || abs(a-c) <= d) cout<<"Yes"<<endl;
	else cout<<"No"<<endl;
	return 0;
}
template<typename tn> inline tn next(void)
{
	tn k;
	cin>>k;
	return k;
}
template<typename tn> inline ostream& operator << (ostream& os, const vector<tn>& v)
{
	rep(i, 0, v.size()) os<<v[i]<<' ';
	return os;
}

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

#define TRACE(x) x
#define WATCH(x) TRACE(cout << #x" = " << x << endl)
#define WATCHR(a, b) TRACE(for (auto it=a; it!=b;) cout << *(it++) << " "; cout << endl)
#define WATCHC(V) TRACE({cout << #V" = "; WATCHR(V.begin(), V.end());})

#define all(x) (x).begin(), (x).end()

using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using vb = vector<bool>;
using vs = vector<string>;

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

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

    int N;
    cin >> N;

    vvi adj(N, vi(N, true));

    for (int i = 0; i < N; i++) {
        adj[i][i] = false;
    }

    if (N&1) {
        for (int i = 0; i + 1 < N; i++) {
            adj[i][N-2-i] = false;
        }
    } else {
        for (int i = 0; i < N; i++) {
            adj[i][N-1-i] = false;
        }
    }

    int sum = -1;
    for (int i = 0; i < N; i++) {
        int res = 0;
        for (int j = 0; j < N; j++)
            if (adj[i][j])
                res += j + 1;

        if (sum != -1) assert(sum == res);
        sum = res;
    }

    vector<pair<int, int>> edges;
    for (int i = 0; i < N; i++)
        for (int j = i + 1; j < N; j++)
            if (adj[i][j])
                edges.emplace_back(i+1, j+1);

    cout << edges.size() << "\n";
    for (auto p : edges)
        cout << p.first << " " << p.second << "\n";

    return 0;
}



Measured memory_bytes: 384
/* AtCoder Regular Contest 080. Task C - 4-adjacent, by Abreto<m@abreto.net>. */
#include <stdio.h>

int main(void)
{
    int N = 0, ai = 0;
    int Np = 0, N2 = 0, N4 = 0;
    scanf("%d", &N);
    while(N--)
    {
        scanf("%d", &ai);
        if(0 == ai%4) N4++;
        else if(0 == (ai&1)) N2++;
        else Np++;
    }
    if(0 == Np) puts("Yes");
    else if((Np - 1 + (N2>0)) <= N4) puts("Yes");
    else puts("No");
    return 0;
}


Measured memory_bytes: 128
K = int(input())
S = str(input()).lower()

if 0 < K < 101 and 0 < len(S) < 101:
    if len(S) <= K:
        print(S)
    else:
        print(S[:K] + "...") 
else:
    print("Try again with K and length of S between 1 and 100 ")

Measured memory_bytes: 9020
#include <iostream>
#include <vector>
#include <array>
#include <set>
#include <cmath>
#include <string>
#include <sstream>
#include <queue> 
#include <list>
#include <stack>
#include <unordered_map>
#include <algorithm> 
#include <numeric>  
#include <functional>
#include <cassert>
#include <bitset>
#include <cctype>  
#include <iomanip> 
#include <limits>  
#include <regex>
// std::numeric_limits<int>::max(), min()
// std::setprecision(X)
// std::islower(), std::isupper(), std::tolower, std::toupper
// std::accumulate(m.begin(), m.end(), 0LL);
// std::sort(begin(),end()) // 0, 1, 2, 3 ,4 (default, less);
// std::priority_queue<int, vector<int>, less<int>> que; // 4, 3, 2, 1 (defualt, less) : 
// if ( std::regex_match(S, std::regex("(dream|dreamer|erase|eraser)*")) ) std::cout << "YES" << std::endl;
 
#define rep(i, n) for(int i = 0; i < (int)(n);    i++)
#define sz(x) ((int)(x).size())
#define all(x) (x).begin(),(x).end()

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; }
typedef long long ll;

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


int main (void) {
  std::cin.tie(0);  std::ios::sync_with_stdio(false);
  int N; std::cin >> N;
  std::vector<int> p(N);  rep(i,N) std::cin >> p[i];

  int ans = 0;
  rep(i,N) {
    if ( i == N-1 ) {
      if ( p[i] == i+1 ) {
        std::swap(p[i],p[i-1]);
        ans++;
      }
    }
    else {
      if ( p[i] == i+1 ) {
        std::swap(p[i],p[i+1]);
        ans++;
      }
    }
  }
  std::cout << ans << std::endl;
  return 0;
}


Measured memory_bytes: 640
package main

import "fmt"

func main() {
	var s string
	fmt.Scan(&s)
	var hist [26]int
	for _, ch := range s {
		hist[ch-'a']++
		if hist[ch-'a'] > 1 {
			fmt.Println("no")
			return
		}
	}
	fmt.Println("yes")
}


Measured memory_bytes: 512
<?php
fscanf(STDIN, "%d", $n);
fscanf(STDIN, "%d", $k);
$ret = 1;
for($i = 0; $i < $n; $i++) {
    $ret = ($ret + $k > $ret * 2) ? $ret * 2 : $ret + $k;
}
echo $ret. "\n";

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

int main() {
  int N,A,a,b;
  a=0;
  cin >> N;

  cin >> A;
  if(A%2==0){
    while(true){
      A/=2;
      if(A%2==1){
        a++;
        break;
      }
      a++;
    }
  }


  for(int i=1;i<N;i++){
    cin >> A;
    if(A%2==0){
      b=0;
      while(true){
        A/=2;
        if(A%2==1){
          b++;
          break;
        }
        b++;
      }
      if(a>b){
        a=b;
      }
    }
  }

  cout << a << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<string>
#include<sstream>
using namespace std;
int main() {
  int n,k;
  stringstream ss;
  cin >> n >> k;
  int* h = new int[100000];
  for(int i=0;i<n;i++) cin >> h[i];
  sort(h,h+n);
  int md = 1000000001;
  for(int i=0;i<=n-k;i++){
    md = min(md,h[i+k-1]-h[i]);
  }
  cout << md << endl;
  return 0;
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
#define SORT(x) sort((x).begin(),(x).end())
#define ALL(x) (x).begin(),(x).end()
#define rep(i, n) for(int i = 0; i < n; i++)
#define reps(i, m, n) for(int i = m; i < n; i++)
#define repr(i, m, n) for(int i = m; i >= n; i--)
template<class T>bool maxi(T &a,const T &b){if(a<b){ a=b; return 1;} return 0;}
template<class T>bool mini(T &a,const T &b){if(b<a){ a=b; return 1;} return 0;}
#define y0 y3487465 //j0
#define y1 y1347829 //j1
#define INF2 4000000000000000037
#define INF 1000000007
#define PI (acos(-1))
#define MOD 1000000007
using namespace std;
typedef long long ll;

void Main(){

  int a,b,c,K;
  cin>>a>>b>>c>>K;

  if(a>=b and a>=c) rep(i,K) a*=2;
  else if(b>c) rep(i,K) b*=2;
  else rep(i,K) c*=2;

  cout<< a+b+c <<"\n";
}

//-----------------------------------
int main(){
  cin.tie(nullptr);
  ios_base::sync_with_stdio(false);
  cout << fixed << setprecision(15);
  Main();
}
//-----------------------------------


Measured memory_bytes: 256
using DataStructures

const MOD = 10^9+7
pow2(x) = big(2)^x%MOD

function solve()
    N = parse(Int,readline())
    cnt = counter(Rational{Int})
    zero = 0
    for i in 1:N
        a, b = parse.(Int,split(readline()))
        if (a==0 && b==0)
            zero+=1
        else
            inc!(cnt,a//b)
        end
    end

    ans = 1
    for (r,c) in cnt
        inv = r==0//1 ? 1//0 : -1/r
        ans *= pow2(c) + pow2(cnt[inv]) - 1
        reset!(cnt, inv)
        ans %= MOD
    end
    ans = mod(ans+(zero-1)+MOD, MOD)
    println(ans)
end
solve()

Measured memory_bytes: 363144
const int LG = 21;
const int FN = 400005;
const long long MOD = 1e9 + 7;
const long long INF = 1e9;
const long long INFLL = 1e18;

#include <bits/stdc++.h>

using namespace std;

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

#define forn(i, n) for (int (i) = 0; (i) != (n); (i)++)
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()
#define popcount(x) __builtin_popcount(x)
#define popcountll(x) __builtin_popcountll(x)
#define fi first
#define se second
#define re return
#define pb push_back
#define uniq(x) sort(all(x)); (x).resize(unique(all(x)) - (x).begin())

#ifdef LOCAL
#define dbg(x) cerr << __LINE__ << " " << #x << " " << x << endl
#define ln cerr << __LINE__ << endl
#else
#define dbg(x) void(0)
#define ln void(0)
#endif // LOCAL

int cx[4] = {-1, 0, 1, 0};
int cy[4] = {0, -1, 0, 1};
string Ans[2] = {"No", "Yes"};
string ANS[2] = {"NO", "YES"};

ll inq(ll x, ll y)
{
    if (!y) re 1 % MOD;
    ll l = inq(x, y / 2);
    if (y % 2) re l * l % MOD * x % MOD;
    re l * l % MOD;
}

ll rev(ll x)
{
    return inq(x, MOD - 2);
}

bool __precomputed_combinatorics = 0;
vector<ll> __fact, __ufact, __rev;

void __precompute_combinatorics()
{
    __precomputed_combinatorics = 1;
    __fact.resize(FN);
    __ufact.resize(FN);
    __rev.resize(FN);
    __rev[1] = 1;
    for (int i = 2; i < FN; i++) __rev[i] = MOD - __rev[MOD % i] * (MOD / i) % MOD;
    __fact[0] = 1, __ufact[0] = 1;
    for (int i = 1; i < FN; i++) __fact[i] = __fact[i - 1] * i % MOD, __ufact[i] = __ufact[i - 1] * __rev[i] % MOD;
}

ll fact(int x)
{
    if (!__precomputed_combinatorics) __precompute_combinatorics();
    return __fact[x];
}

ll cnk(int n, int k)
{
    if (k < 0 || k > n) return 0;
    if (!__precomputed_combinatorics) __precompute_combinatorics();
    return __fact[n] * __ufact[n - k] % MOD * __ufact[k] % MOD;
}

int Root(int x, vector<int> &root)
{
    if (x == root[x]) return x;
    return root[x] = Root(root[x], root);
}

void Merge(int v, int u, vector<int> &root, vector<int> &sz)
{
    v = Root(v, root), u = Root(u, root);
    if (v == u) return;
    if (sz[v] < sz[u])
    {
        sz[u] += sz[v];
        root[v] = u;
    }
    else
    {
        sz[v] += sz[u];
        root[u] = v;
    }
}

int ok(int x, int n)
{
    return 0 <= x && x < n;
}

void bfs(int v, vi &dist, vector<vi> &graph)
{
    fill(all(dist), -1);
    dist[v] = 0;
    vi q = {v};
    for (int i = 0; i < q.size(); i++)
    {
        for (auto u : graph[q[i]])
        {
            if (dist[u] == -1)
            {
                dist[u] = dist[q[i]] + 1;
                q.push_back(u);
            }
        }
    }
}


signed main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    string s;
    cin >> s;
    forn(i, s.size() - 8) cout << s[i];
}

/* Note:
Check constants at the beginning of the code.
    N is set to 4e5 but be careful in problems with large constant factor.
    Setting N in every problem is more effective.
Check corner cases.
    N = 1
No def int long long for now.
Add something here.
*/


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <queue>
#include <stack>
#include <string>
#include <functional>
#include <algorithm>
using namespace std;

typedef long long ll;

int main()
{
    int N;
    while(cin >> N && N) {
        int sum, res;
        res = 0;
        for(int i = 1; i <= N; i++) {
            sum = i;
            for(int j = i + 1; j <= N; j++) {
                sum += j;
                if(sum == N)
                    res++;
                if(sum > N)
                    break;
            }
        }
        cout << res << endl;
    }
}

Measured memory_bytes: 0
#include <vector>
#include <iostream>
#include <map>
#include <algorithm>
#include <random>
#include <complex>
#include <unordered_map>
#include <cmath>
#include <cstring>
#include <cassert>
#include <cstdio>
#include <bitset>

using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;

const int MN = 501*1000*1000;

ll gcd(ll a, ll b) {
    if (!a) return b;
    return gcd(b%a, a);
}
ll ext_gcd(ll a, ll b, ll &x, ll &y) {
    ll d = a;
    if (b) {
        d = ext_gcd(b, a%b, y, x);
        y -= a / b*x;
    } else {
        x = 1;
        y = 0;
    }
    return d;
}

int w, d, n, m, t, u, h;
int x, tu, th;
void init() {
    m = t-m%t;
    u = gcd(t, w+d), h = gcd(t, m);
    tu = t/u; th = t/h;
    ll xx, y;
    ext_gcd(m, t, xx, y);
    x = ((xx % th) + th) % th;
}
int solve() {
    init();

    int res = 0;
    int l = 0;

    int s = 0;
    int th = t/h;
    for (int i = 0; i < t; i += h) {
        if (s<n) {
            res += max(0, (i-l-w) / u);
            l = i/u*u;
        }
        s += x;
        if (s >= th) s -= th;
    }
    res += max(0, (t-l-w)/u);
    return res;
}

int main() {
    cin >> w >> d >> n >> m >> t; w++; d--;
    printf("%.20f\n", 1.0 * solve() / tu);
    return 0;
}

Measured memory_bytes: 1176
/* cerberus97 - Hanit Banga */

#include <iostream>
#include <iomanip>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <vector>
#include <algorithm>

using namespace std;

#define pb push_back
#define fast_cin() ios_base::sync_with_stdio(false); cin.tie(NULL)

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

const int N = 1e5 + 10;

int main() {
	fast_cin();
	int m; cin >> m;
	ll sum = 0, len = 0;
	for (int i = 0; i < m; ++i) {
		ll d, c;
		cin >> d >> c;
		sum += d * c;
		len += c;
	}
	cout << (sum + 8) / 9 + len - 2 << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
ll mod = 1e9+7;


int main(){
    int n; cin >> n;
    vector<int> p(n);
    vector<int> np(n);
    for(int i=0;i<n;i++){
        cin >> p[i];
        np[i] = p[i]; 
    }
    sort(np.begin(),np.end());
    int cnt = 0;
    for(int i=0;i<n;i++){
        if(np[i]!=p[i]){
            cnt++;
        }
    }
    if(cnt>2){
        cout << "NO" << endl;
    }else{
        cout << "YES" << endl;
    }
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
using namespace std;
#define MAX_N 100100
#define MAX_LOG_N 20
int N,root;
vector<int> g[MAX_N];
int depth[MAX_N];
int par[MAX_N][MAX_LOG_N];
void dfs(int v,int p,int d){
  par[v][0]=p;
  depth[v]=d;
  for(int i=0;i<g[v].size();i++){
    if(g[v][i]==p)continue;
    dfs(g[v][i],v,d+1);
  }
}
void fill_table(){
  for(int i=0;i<19;i++){
    for(int j=0;j<N;j++){
      if(par[j][i]==-1)par[j][i+1]=-1;
      else par[j][i+1]=par[par[j][i]][i];
    }
  }

}
int lca(int u,int v){
  if(depth[u]>depth[v])swap(u,v);
  for(int i=19;i>=0;i--){
    if(((depth[v]-depth[u])>>i)&1)v=par[v][i];
  }
  if(u==v)return u;
  for(int i=19;i>=0;i--){
    if(par[u][i]!=par[v][i]){
      u=par[u][i];
      v=par[v][i];
    }
  }
 
  return par[u][0];
}
int main(){
  cin >> N;
  for(int i=0;i<N;i++){
    int k;
    cin >> k;
    for(int j=0;j<k;j++){
      int x;
      cin >> x ;
      g[i].push_back(x);
    }
  }
  root=0;
  dfs(root,-1,0);
 
  fill_table();
 
  int Q;
  cin >> Q;
  for(int i=0;i<Q;i++){
    int u,v;
    cin >> u >> v;
    cout << lca(u,v) << endl;
  }
  return 0;
}

Measured memory_bytes: 21416
#include <bits/stdc++.h>
using namespace std;
 
int main(){
    int N, K;
    cin >> N >> K;
 
    vector<int> snuke(N, 1);
    for(int i=0; i<K; i++){
        int D;
        cin >> D;
        for(int j=0; j<D; j++){
            int A;
            cin >> A;
            A-= 1;
            snuke[A] = 0;
        }
    }
 
    int tot = 0;
    for(int i=0; i<N; i++){
        tot += snuke[i];
    }
    cout << tot << endl;
    return 0;
}

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

public class AtCoderD
{
    static void Main()
    {
        long mod = 1000000007;
        int n;
        int a;
        int b;
        {
            var line = Console.ReadLine();
            var words = line.Split(' ');
            n = int.Parse(words[0]);
            a = int.Parse(words[1]);
            b = int.Parse(words[2]);
        }

        long total = 1;
        for (int i = 0; i < n; i++)
        {
            if (n - i > 30)
            {
                total *= (1024 * 1024 * 1024);
                i += 29;
            }
            else
            {
                total *= 2;
            }
            total = total % mod;
        }

        long ca = Combination(n, a);
        long cb = Combination(n, b);
        long answer = total - ca - cb - 1;

        answer += mod * 2;
        answer = answer % mod;

        Console.WriteLine(answer);
    }

    // Comnibation（mod版）
    private static long Combination(int n, int k)
    {
        long answer = 1;
        for (int i = n; i > n - k; i--)
        {
            answer = mul(answer, i);
        }
        for (int i = 1; i <= k; i++)
        {
            answer = div(answer, i);
        }
        return answer;
    }

    // 掛け算（mod版）
    private static long mul(long a, long b)
    {
        long mod = 1000000007;
        return ((a % mod) * (b % mod)) % mod;
    }

    // 割り算（mod版）
    private static long div(long a, long b)
    {
        long mod = 1000000007;
        return mul(a, pow(b, mod - 2));
    }

    // べき乗（mod版）
    private static long pow(long a, long b)
    {
        long mod = 1000000007;
        if (b == 0)
        {
            return 1;
        }
        else if (b == 1)
        {
            return a % mod;
        }
        else if (b % 2 == 0)
        {
            long d = pow(a, b / 2);
            return d * d % mod;
        }
        else
        {
            return a * pow(a, b - 1) % mod;
        }
    }
}

Measured memory_bytes: 11220