akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <queue>
#include <map>
#include <algorithm>
#include <cassert>
#define rep(i,n) for(int i = 0; i < n; ++i )
using namespace std;
using ll = long long;
using P = pair<int,int>;

// auto mod int
// https://youtu.be/L8grWxBlIZ4?t=9858
// https://youtu.be/ERZuLAxZffQ?t=4807 : optimize
// https://youtu.be/8uowVvQ_-Mo?t=1329 : division
const int mod = 1000000007;
struct mint {
  ll x; // typedef long long ll;
  mint(ll x=0):x((x%mod+mod)%mod){}
  mint operator-() const { return mint(-x);}
  mint& operator+=(const mint a) {
    if ((x += a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator-=(const mint a) {
    if ((x += mod-a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator*=(const mint a) {
    (x *= a.x) %= mod;
    return *this;
  }
  mint operator+(const mint a) const {
    mint res(*this);
    return res+=a;
  }
  mint operator-(const mint a) const {
    mint res(*this);
    return res-=a;
  }
  mint operator*(const mint a) const {
    mint res(*this);
    return res*=a;
  }
  mint pow(ll t) const {
    if (!t) return 1;
    mint a = pow(t>>1);
    a *= a;
    if (t&1) a *= *this;
    return a;
  }

  // for prime mod
  mint inv() const {
    return pow(mod-2);
  }
  mint& operator/=(const mint a) {
    return (*this) *= a.inv();
  }
  mint operator/(const mint a) const {
    mint res(*this);
    return res/=a;
  }
};
// combination mod prime
// https://www.youtube.com/watch?v=8uowVvQ_-Mo&feature=youtu.be&t=1619
struct combination {
  vector<mint> fact, ifact;
  combination(int n):fact(n+1),ifact(n+1) {
    assert(n < mod);
    fact[0] = 1;
    for (int i = 1; i <= n; ++i) fact[i] = fact[i-1]*i;
    ifact[n] = fact[n].inv();
    for (int i = n; i >= 1; --i) ifact[i-1] = ifact[i]*i;
  }
  mint operator()(int n, int k) {
    if (k < 0 || k > n) return 0;
    return fact[n]*ifact[k]*ifact[n-k];
  }
};

combination comb(2*1e6+10);
mint sumF( int r, int c ){
    return comb(r+c+2,r+1);
}
int main() {
    int r1,c1,r2,c2;
    cin >> r1 >> c1 >> r2 >> c2;
    --r1;
    --c1;

    mint ans = sumF( r2, c2 );
    ans -= sumF( r1, c2 );
    ans -= sumF( r2, c1 );
    ans += sumF( r1, c1 );
    cout << ans.x << endl;
}


Measured memory_bytes: 31488
#include<bits/stdc++.h>
#define FOR(i,a,b)for(int i=(a),_b=(b);i<=_b;i++)
#define FORN(i,b,a)for(int i=(b);_a=(a);i>=_a;i--)
#define REP(i,n)for(int i=0,_n=n;i<n;i++)
#define ll long long
#define pii pair<int,int>
#define re return
#define vi vector<int>
#define pb push_back
#define si set<int>
#define in insert
#define fl float
#define db double
#define ld long double
#define X first
#define Y second
#define st string
#define ull unsigned long long
using namespace std;
inline void read(int &x)
{
	short negative=1;
    x=0;
    char c=getchar();
    while(c<'0' || c>'9')
    {
		if(c=='-')
			negative=-1;
		c=getchar();
	}
    while(c>='0' && c<='9')
        x=(x<<3)+(x<<1)+(c^48),c=getchar();
    x*=negative;
}
int main()
{
	int n;
	int a[100100];
	int num[100100];
	memset(num,0,sizeof(num)); 
	cin>>n;
	REP(i,n)
		cin>>a[i];
	REP(i,n)
	{
		num[a[i]]++;
		num[a[i]-1]++;
		num[a[i]+1]++;
	}
	sort(num,num+100100);
	reverse(num,num+100100);
	cout<<num[0]<<endl;
	return 0;
}



Measured memory_bytes: 1152
#include <iostream>
#include <cstdio>
#include <vector>
#include <cmath>
#include <map>
#include <set>
#include <algorithm>
#include <string>
#include <queue>
#define PIE 3.14159265358979
#define rep(i,n) for(int i = 0;i < (n);i++)
using namespace std;
typedef long long ll;

double dp[3005][3005];
int N;
double p[3005];


double dfs(int i,int j){ //i枚目まで投げた時、j枚おもての確率
    if(dp[i][j]>=0){
        return dp[i][j];
    }
    double ret=0.0;
    if(i>0){
        ret += dfs(i-1,j)*(1.0-p[i-1]);
        if(j>0)ret += dfs(i-1,j-1)*p[i-1];
    }
    dp[i][j]=ret;
    return ret;
}

int main() {
    cin>>N;
    rep(i,N){
        cin>>p[i];
    }
    rep(i,3005){
        rep(j,3005){
            dp[i][j]=-1;
        }
    }
    
    dp[0][0]=1.0;
    double ans = 0.0;
    for(int i = (N+1)/2;i <= N;i++){
        ans += dfs(N,i);
    }
    printf("%.10lf\n",ans);
    return 0;
}



Measured memory_bytes: 71040
#include<cstdio>

int n, A[20];


int solve(int i, int m){
	if(m == 0) return 1;
	if(i >= n) return 0;
	int res = solve(i + 1, m) || solve(i + 1, m - A[i]);
	return res;
}

int main(void){
	int q, M, i;

	scanf("%d", &n);
	for(i = 0; i < n; i++) scanf("%d", &A[i]);
	scanf("%d", &q);
	for(i = 0; i < q; i++){
		scanf("%d", &M);
		if(solve(0, M)) printf("yes\n");
		else printf("no\n");
	}

	return 0;
}

Measured memory_bytes: 2684
module mod_priority_queue
  implicit none
  type t_priority_queue
    private
    integer :: num = 0
    integer, pointer :: heap(:) => null()
  contains
    procedure :: offer => offer
    procedure :: clear => clear
    procedure :: poll => poll
    procedure :: peek => peek
    procedure :: size => size_of
  end type
contains
  integer function compare(a,b)
    integer, intent(in) :: a, b
    compare = b-a
  end
  subroutine offer(this,item)
    class(t_priority_queue), intent(inout) :: this
    integer, intent(in) :: item
    integer :: n, i, t
    integer, allocatable :: tmp(:)
    if (.not.associated(this%heap)) allocate(this%heap(1))
    if (this%num == size(this%heap)) then
      allocate(tmp(this%num))
      tmp = this%heap
      deallocate(this%heap)
      allocate(this%heap(2*this%num))
      this%heap(1:this%num) = tmp
      deallocate(tmp)
    end if
    this%num = this%num+1
    this%heap(this%num) = item
    n = this%num
    do while (n > 1)
      i = n/2
      if (compare(this%heap(n),this%heap(i)) < 0) then
        t = this%heap(n)
        this%heap(n) = this%heap(i)
        this%heap(i) = t
      end if
      n = i
    end do
  end
  subroutine clear(this)
    class(t_priority_queue), intent(inout) :: this
    if (associated(this%heap)) deallocate(this%heap)
    this%num = 0
  end
  function poll(this) result(item)
    class(t_priority_queue), intent(inout) :: this
    integer :: item, n, i, j, tmp
    n = this%num
    item = this%heap(1)
    this%heap(1) = this%heap(n)
    this%num = this%num-1
    i = 1
    do while (2*i < n)
      j = 2*i
      if (j+1 < n .and. compare(this%heap(j+1),this%heap(j)) < 0) j = j+1
      if (compare(this%heap(j),this%heap(i)) < 0) then
        tmp = this%heap(j)
        this%heap(j) = this%heap(i)
        this%heap(i) = tmp
      end if
      i = j
    end do
  end
  function peek(this) result(item)
    class(t_priority_queue), intent(in) :: this
    integer :: item
    item = this%heap(1)
  end
  integer function size_of(this)
    class(t_priority_queue), intent(in) :: this
    size_of = this%num
  end
end module mod_priority_queue
program powerful_discount_tickets
  use mod_priority_queue
  implicit none
  integer :: n, m, a(100000) = 0, i
  type(t_priority_queue) :: pq
  integer(8) :: ans = 0_8
  read(*,*) n, m
  read(*,*) a(1:n)
  do i = 1, n
    call pq%offer(a(i))
  end do
  do i = 1, m
    call pq%offer(pq%poll()/2)
  end do
  do i = 1, n
    ans = ans+int(pq%poll(),8)
  end do
  write(*,'(i0)') ans
end program powerful_discount_tickets

Measured memory_bytes: 1760
#include <iostream>
using namespace std;
int main() {
    int age;
    int price;
    cin>>age>>price;
    if(age >= 13)
    {
        cout<<price<<endl;
    }
    else if (age >= 6 && age <= 12)
    {
        cout<<price/2;
    }
    else{
        cout<<0<<endl;
    }
}

Measured memory_bytes: 256
#include<iostream>

int main (){
    std::cin.tie(0); 
	std::ios::sync_with_stdio(false);
    int X;std::cin >> X;
    int ans=8;

    if (1800 <= X) {
        ans=1;
    } else if (1600 <= X) {
        ans=2;
    } else if (1400 <= X) {
        ans=3;
    } else if (1200 <= X) {
        ans=4;
    } else if (1000 <= X) {
        ans=5;
    } else if (800 <= X) {
        ans=6;
    } else if (600 <= X) {
        ans=7;
    } 
    std::cout << ans;
    return 0 ;

}


Measured memory_bytes: 3684
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<math.h>
#include<map>
#include<iomanip>

using namespace std;

#define rep(i,n,m) for(int i=n;i<(int)(m);i++)

int main() {

	int a, b, c;

	cin >> a >> b >> c;

	if (b - a == c - b)cout << "YES" << endl;
	else cout << "NO" << endl;


	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n - 1; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i <= n; i++)
#define FORR(i, m, n) for(int i = m; i >= n; i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define VSORTR(v) sort(v.rbegin(), v.rend());
#define ALL(v) (v).begin(),(v).end()
 
using ll = long long;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
using P = pair<ll, ll>;

const ll MOD = 1e9 + 7;
// return a^b O(log b)
template<typename T>
T mypow(T a, T b){
    if (b == 0)
        return 1;
    T tmp = mypow(a, b / 2);
    if (b % 2)
        return (((tmp * tmp) % MOD) * a) % MOD;
    else
        return (tmp * tmp) % MOD;
}

bool init = false;
const ll M = 2e5 + 10;
vector<ll> frc(M + 1, 1), inv(M + 1, 1);
// return nCk 前処理 O(N) + query あたり O(1)
long long comb(int n, int k){
    long long res = 1;
    if(!init){
        init = true;
        REP(i, M){
            frc[i + 1] = (frc[i] * (i + 1)) % MOD;
            inv[i + 1] = mypow(frc[i + 1], MOD - 2);
        }
    }
    if (k < 0 || n < k) return 0;
    res = (((frc[n] * inv[k]) % MOD) * inv[n - k]) % MOD;
    return res;
}

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

    ll n, k;
    cin >> n >> k;
    vll a(n);
    REP(i, n) cin >> a[i];
    VSORT(a);

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

    // combsum[i + 1] := (k - 2)C(k - 2) + ,..., + iC(k - 2)
    vll combsum(n + 1);
    REP(i, n) {
        combsum[i + 1] = combsum[i] + comb(i, k - 2);
        combsum[i + 1] %= MOD;
    }
    ll left = 0, right = 0;
    REP(i, n) {
        left += combsum[n - 1 - i] * a[i];
        left %= MOD;
    }
    VSORTR(a);
    REP(i, n) {
        right += combsum[n - 1 - i] * a[i];
        right %= MOD;
    }
    ll res = (MOD * MOD + right - left) % MOD;
    cout << res << endl;
    return 0;
}

Measured memory_bytes: 4992
import sys

sl = sys.stdin.readlines()
s = ''
for i in sl:
    s += i.rstrip().lower()

a = 'abcdefghijklmnopqrstuvwxyz'
d = {}
for c in a:
    d[c] = 0

for c in s:
    if c in a:
        d[c] += 1

for k, v in d.items():
    print(f'{k} : {v}')


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

int main() {

    long long int HP;
    long long int sum = 0;
    long long int MonsterCount = 1;

    cin >> HP;

    while(HP != 0) {

        bool isOdd = HP % 2;
        HP /= 2;

        sum += MonsterCount;
        MonsterCount *= 2;


    }

    cout << sum << endl;

    return 0;


}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main() {
  int a,b;
  cin >> a >> b;
  if((a+b) % 3 == 0 || a%3 == 0 || b%3 == 0) {
    cout << "Possible" << endl;
  }else{
    cout << "Impossible" << endl;
  }
  return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <string.h>
#include <algorithm>
#include <iostream>
#include <math.h>
#include <assert.h>
#include <vector>
#include <deque>

using namespace std;
typedef long long ll;
typedef unsigned int uint;
typedef unsigned long long ull;
static const double EPS = 1e-9;
static const double PI = acos(-1.0);

#define REP(i, n) for (int i = 0; i < (int)(n); i++)
#define FOR(i, s, n) for (int i = (s); i < (int)(n); i++)
#define FOREQ(i, s, n) for (int i = (s); i <= (int)(n); i++)
#define FORIT(it, c) for (__typeof((c).begin())it = (c).begin(); it != (c).end(); it++)
#define MEMSET(v, h) memset((v), h, sizeof(v))

deque<int> deq[2];
deque<int> minDeq[2][2];
int q;

void Erase(int lr) {
  assert(!minDeq[0][lr].empty());
  assert(!minDeq[1][lr].empty());
  if (minDeq[0][lr].front() == deq[lr][0]) {
    minDeq[0][lr].pop_front();
  }
  if (minDeq[1][lr].front() == -deq[lr][0]) {
    minDeq[1][lr].pop_front();
  }
  deq[lr].pop_front();
}

void Insert(int lr, int tb, int v) {
  if (tb == 1) {
    assert(lr == 1);
    while (!minDeq[0][lr].empty() && v < minDeq[0][lr].back()) {
      minDeq[0][lr].pop_back();
    }
    while (!minDeq[1][lr].empty() && -v < minDeq[1][lr].back()) {
      minDeq[1][lr].pop_back();
    }
    minDeq[0][lr].push_back(v);
    minDeq[1][lr].push_back(-v);
    deq[lr].push_back(v);
  } else {
    if (minDeq[0][lr].empty() || v < minDeq[0][lr].front()) {
      minDeq[0][lr].push_front(v);
    }
    if (minDeq[1][lr].empty() || -v < minDeq[1][lr].front()) {
      minDeq[1][lr].push_front(-v);
    }
    deq[lr].push_front(v);
  }
}

int main() {
  while (scanf("%d", &q), q) {
    REP(i, 2) {
      deq[i].clear();
      REP(j, 2){
        minDeq[i][j].clear();
      }
    }
    REP(iter, q) {
      int type;
      int v = 0xdeadbeaf;
      scanf("%d", &type);
      if (type == 0 || type == 4 || type == 5 || type == 8 || type == 9) {
        scanf("%d", &v);
        if (type != 0) { v--; }
      }
      switch (type) {
case 0:
        Insert(1, 1, v);
        break;
case 1:
        printf("%d\n", deq[0][0]);
        Erase(0);
        break;
case 2:
        printf("%d\n", minDeq[0][0][0]);
        break;
case 3:
        printf("%d\n", minDeq[0][1][0]);
        break;
case 4:
        printf("%d\n", minDeq[0][0][v]);
        break;
case 5:
        printf("%d\n", minDeq[0][1][v]);
        break;
case 6:
        printf("%d\n", -minDeq[1][0][0]);
        break;
case 7:
        printf("%d\n", -minDeq[1][1][0]);
        break;
case 8:
        printf("%d\n", -minDeq[1][0][v]);
        break;
case 9:
        printf("%d\n", -minDeq[1][1][v]);
        break;
default:
        assert(false);
        break;
      }
      if (deq[0].size() < deq[1].size()) {
        Insert(0, 0, deq[1][0]);
        Erase(1);
      }
    }
    puts("end");
  }
}

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

int main() {
  long N, M, Ans=0;
  cin >> N >> M;
  if(N==1 && M!=1) cout << M-2 << endl;
  else if(N!=1 && M==1) cout << N-2 << endl;
  else if(N==1 && M==1) cout << 1 << endl;
  else cout << (N-2)*(M-2) << endl;
}

Measured memory_bytes: 256
n = int(input())
a = list(map(int, input().split()))
out = []

def solve_plus(out):
    for i in range(n-1):
        out.append([i+1, i+2])
    return out

def solve_minus(out):
    for i in range(n-1):
        out.append([n-i, n-i-1])
    return out

max_a = 0
max_i = 0
min_a = 10**7
min_i = 0
for i in range(n):
    if a[i] > max_a:
        max_a = a[i]
        max_i = i+1
    if a[i] < min_a:
        min_a = a[i]
        min_i = i+1

if min_a >= 0:
    out = solve_plus(out)
elif max_a < 0:
    out = solve_minus(out)
else:
    if abs(max_a) > abs(min_a):
        for i in range(n):
            if a[i] < 0:
                out.append([max_i, i+1])
        out = solve_plus(out)
    else:
        for i in range(n):
            if a[i] > 0:
                out.append([min_i, i+1])
        out = solve_minus(out)
print(len(out))
for x, y in out:
    print(x, y)


Measured memory_bytes: 38256
#include<iostream>
#include<stdio.h>
#include<stdlib.h>
using namespace std;

int main()
{
    int m,f,r;

    while( cin>>m>>f>>r)
    {
        if(m==-1&& f== -1 && r== -1)
            return 0;
        else if(m==-1 || f==-1)
            cout<< "F"<<endl;
        else if((m+f)>=80)
            cout<< "A"<<endl;
        else if((m+f)>=65 && (m+f)<80)
            cout<< "B"<<endl;
        else if((m+f)>=50 && (m+f)<65)
            cout<< "C"<<endl;
        else if((m+f)>=30 && (m+f)<50 && r <50)
            cout<< "D"<<endl;
        else if((m+f)>=30 && (m+f)<50 && r>=50)
            cout<< "C"<<endl;
        else if((m+f)<30)
            cout<< "F"<<endl;
    }
    return 0;
}



Measured memory_bytes: 3100
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <cstdlib>
#include <vector>
#include <map>
#include <queue> 
#include <stack>
#include <set>
#include <list>

using namespace std;
typedef long long ll;
#define rep(i, s, e) for (int(i) = (s); (i) <= (e); ++(i))
#define all(x) x.begin(),x.end()


int main()
{
	ll n; cin >> n;
	cout << n * (n + 1) / 2 - n << endl;
}


Measured memory_bytes: 256
k,a,b = map(int, input().split())
res = 1
if b <= a + 1:
  print(res + k)
else:
  if k < a - 1 + 2:
    print(res + k)
  else:
    res += b - 1
    k -= a + 1
    print(res + k//2 * (b - a) + k % 2)

Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i,N) for(ll i=0;i<N;++i)
const ll INF = 1LL<<60;

int main(){
    ll a,b;
    cin >> a >> b;
    ll c = abs(a-b);
    if(c % 2 == 0){
        cout << min(a,b)+c/2 << endl;
    }else cout << "IMPOSSIBLE" << endl;
}

Measured memory_bytes: 256
import sys
import bisect
readline = sys.stdin.readline

def main():
	n = int(input())
	s = tuple(input())

	ans = 0
	r = []
	g = []
	b = []
	for i in range(3):
		if s[i] == 'R':
			r.append(i)
		elif s[i] == 'G':
			g.append(i)
		else:
			b.append(i)

	for i in range(3,n):
		if s[i] == 'R':
			r.append(i)
		elif s[i] == 'G':
			g.append(i)
		else:
			b.append(i)

		for j in range(i-2):
			if (j-i) % 2 == 0:
				if s[i] == s[j]:
					continue
				elif 'R' not in [s[i],s[j]]:
					ans += bisect.bisect_left(r,i) - bisect.bisect_left(r,j)
					index = bisect.bisect_left(r,j + (i-j)//2 )
					if index < len(r):
						if r[index] == j + (i-j)//2:
							ans -= 1
				elif 'G' not in [s[i],s[j]]:
					ans += bisect.bisect_left(g,i) - bisect.bisect_left(g,j)
					index = bisect.bisect_left(g,j + (i-j)//2 )
					if index < len(g):
						if g[index] == j + (i-j)//2:
							ans -= 1
				elif 'B' not in [s[i],s[j]]:
					ans += bisect.bisect_left(b,i) - bisect.bisect_left(b,j)
					index = bisect.bisect_left(b,j + (i-j)//2 )
					if index < len(b):
						if b[index] == j + (i-j)//2:
							ans -= 1
			else:
				if s[i] == s[j]:
					continue
				elif 'R' not in [s[i],s[j]]:
					ans += bisect.bisect_left(r,i) - bisect.bisect_left(r,j)

				elif 'G' not in [s[i],s[j]]:
					ans += bisect.bisect_left(g,i) - bisect.bisect_left(g,j)

				elif 'B' not in [s[i],s[j]]:
					ans += bisect.bisect_left(b,i) - bisect.bisect_left(b,j)


	print(ans)

if __name__ == '__main__':
	main()


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

using ll = long long;
#define REP(i, n) for (int i = 0; i < n; ++i)
using namespace std;

struct Edge {
	int from, to;
};
using Graph = vector<vector<Edge>>;

int scc(Graph &g, vector<int> &cmp) {
	int n = g.size();
	vector<int> used(n);
	vector<int> ord(n, -1);
	int k = 0;
	function<void(int)> dfs = [&](int v) {
		if (used[v]) return;
		used[v] = true;
		for (auto &e : g[v]) {
			dfs(e.to);
		}
		ord[k++] = v;
	};
	for (int i = 0; i < n; ++i) {
		if (!used[i]) dfs(i);
	}
	vector<vector<int>> rg(n);
	for (int i = 0; i < n; ++i) {
		for (auto &e : g[i])
			rg[e.to].push_back(i);
	}
	k = 0;
	cmp.assign(n, -1);
	function<void(int)> rdfs = [&](int v) {
		if (cmp[v] != -1) return;
		cmp[v] = k;
		for (auto &to : rg[v])
			rdfs(to);
	};
	for (int i = n - 1; i >= 0; --i) {
		if (cmp[ord[i]] == -1) rdfs(ord[i]), k++;
	}
	return k;
}

int main() {
	int n, x, a, o;
	cin >> n >> x >> a >> o;
	if (x == 0) {
		cout << "No" << endl;
		return 0;
	}
	int m = 1 << (n + 1);
	Graph g(m);
	REP(i, m) {
		if (i == o || i == a) {
			g[i].push_back({i, i ^ x});
			continue;
		}

		for (int j = i + 1; j < m; ++j) {
			if (j == o || j == a) continue;
			if ((i & j) == a || (i | j) == o || (i ^ j) == x) {
				g[i].push_back({i, j ^ x});
				g[j].push_back({j, i ^ x});
			}
		}
	}
	vector<int> cmp(n);
	int k = scc(g, cmp);

	vector<int> used(k, -1);
	used[cmp[a]] = 0;
	used[cmp[o]] = 0;
	vector<int> ans;
	REP(i, m) {
		if (i > (i ^ x)) continue;
		if (cmp[i] == cmp[i ^ x]) {
			cout << "No" << endl;
			return 0;
		}
		int a = cmp[i], b = cmp[i ^ x];
		if (used[cmp[i]] == 1 || used[cmp[i ^ x]] == 0) {
			ans.push_back(i);
			used[a] = 1;
			used[b] = 0;
		} else if (used[cmp[i]] == 0 || used[cmp[i ^ x]] == 1) {
			ans.push_back(i ^ x);
			used[a] = 0;
			used[b] = 1;
		} else if (cmp[i] > cmp[i ^ x]) {
			ans.push_back(i);
			used[a] = 1;
			used[b] = 0;
		} else {
			ans.push_back(i ^ x);
			used[a] = 0;
			used[b] = 1;
		}
	}
	cout << "Yes" << endl;
	assert(ans.size() == m / 2);
	REP(i, ans.size()) {
		if (i) cout << " ";
		cout << ans[i];
	}
	cout << endl;
}


Measured memory_bytes: 185656
import java.util.Scanner;

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

	public void run() {
		Scanner sc = new Scanner(System.in);
		long n=sc.nextLong();
		int ans=dfs("",n);
		System.out.println(ans);
		sc.close();
	}

	private int dfs(String num, long max) {
		long n=0;
		if(! num.equals("")) {
			n=Long.parseLong(num);
		}
		if(n>max) {
			return 0;
		}
		int cnt = 0;
		if(num.contains("7") && num.contains("5") && num.contains("3")) {
			cnt=1;
		}
		cnt += dfs(num+"7", max);
		cnt += dfs(num+"5", max);
		cnt += dfs(num+"3", max);
		return cnt;
	}
}


Measured memory_bytes: 36308
# coding: utf-8
import sys

sr = lambda: sys.stdin.readline().rstrip()
ir = lambda: int(sr())
lr = lambda: list(map(int, sr().split()))

N, M, X, Y = lr()
x = lr(); x.append(X)
x.sort()
y = lr(); y.append(Y)
y.sort()
bl = y[0] > x[-1]
print('No War' if bl else 'War')


Measured memory_bytes: 3060
import java.util.*;
public class Main{
    public static void main(String[]$){
		Scanner s=new Scanner(System.in);
		int n=s.nextInt(),z=s.nextInt(),w=s.nextInt(),a[]=new int[n--];
		Arrays.setAll(a,i->s.nextInt());
		System.out.println(n==0?Math.abs(a[0]-w):Math.max(Math.abs(a[n]-w),Math.abs(a[n-1]-a[n])));
	}
}

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

using namespace std;

int main()
{
    int H, W, i;

    while (i < 100000)
    {
        cin >> H >> W;
        if (H == 0 && W == 0)
        {
            break;
        }
        for (int i = 0; i < H; i++)
        {
            for (int i = 0; i < W; i++)
            {
                cout << "#";
            }
            cout << endl;
        }
        cout << endl;
        i++;
    }
}


Measured memory_bytes: 3100
#include <iostream>
#include <string>
using namespace std;
int main(int argc, char const *argv[]) {
  string s,tmp;
  cin>>s;
  if(tmp.size()==0){
    tmp.push_back(s[0]);
  }
  for(int i=1;i<s.size();i++){
    auto itr=tmp.find(s[i]);
    if(itr!=-1){
      cout<<"no"<<endl;
      break;
    }else{
      tmp.push_back(s[i]);
    }
    if(i==s.size()-1){
      cout<<"yes"<<endl;
      break;
    }
  }
  return 0;
}


Measured memory_bytes: 256
#define _GLIBCXX_DEBUG
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define ALL(v) v.begin(), v.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; }

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

#define mod 1000000007

int main() {
  int n,k;
  cin>>n>>k;
  
  long long dp[2010][2010];
  
  for(int i=1;i<=n;i++){
    dp[i][0]=1;
    dp[i][i]=1;
  }
  
  for(int i=2;i<=n;i++){
    for(int j=1;j<i;j++){
      dp[i][j]=(dp[i-1][j-1]+dp[i-1][j])%mod;
    }
  }
  
  if(k==1) cout << n <<endl;
  else{
    for(int i=1;i<=k;i++){
      if(i<=(n+1)/2){
        cout << (dp[n-k+1][i]*dp[k-1][i-1])%mod <<endl;
      }
      else cout << 0 <<endl;
    }
  }

  return 0;
}

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

#define inf 0x3f3f3f3f
#define pi acos(-1)
#define fi first
#define se second
#define pb push_back
#define all(a) a.begin(),a.end()
template<class T> bool mmin(T &a,T b){return (a>b ?(a=b,true):false);};
template<class T> bool mmax(T &a,T b){return (a<b ?(a=b,true):false);};

int32_t main(){
	ios::sync_with_stdio(0);
	cin.tie(0);
	
	string str;
	cin >> str;
	int ans=0,cont=0;
	for(auto c:str){
		if(c=='A' or c=='C' or c=='G' or c=='T')
			cont++;
		else{
			mmax(ans,cont);
			cont=0;
		}
	}
	mmax(ans,cont);
	cout << ans << '\n';
#ifdef LOCAL_DEFINE
	cerr << "\nTime: " << 1.0 * clock() / CLOCKS_PER_SEC << " s.\n";
#endif
	return 0;
}


Measured memory_bytes: 256
"use strict"
// inputに入力データ全体が入る
function Main(input) {
    // 1行目がinput[0], 2行目がinput[1], …に入る
    input = input.split("\n");
    var tmp = input[1].split(" ");
    //文字列から10進数に変換するときはparseIntを使います
    var a = parseInt(input[0], 10);
    var b = parseInt(tmp[0], 10);
    var c = parseInt(tmp[1], 10);
    var s = input[2];
    for (var i = 0; i < input.length; i++){
        input[i] = input[i].match(/[0-9]*/g);
        input[i] = input[i].filter(v => v);
    }
    //中身
    var n = input[0] * input[0];
    console.log(n-input[1]);
}
//*この行以降は編集しないでください（標準入出力から一度に読み込み、Mainを呼び出します）
Main(require("fs").readFileSync("/dev/stdin", "utf8"));

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

using namespace std;

int main(){
    int n;
    cin >> n;
    vector<int64_t> A(n);
    copy_n(istream_iterator<int64_t>(cin), n, A.begin());

    vector<map<int, int64_t>> DP(n + 2);
    DP[0][0] = 0;
    const constexpr int64_t INF = 1e17;
    vector<int> B(n);
    for (int i = 0; i < n; i++){
        B[i] = n / 2 - (n - i + 1) / 2;
    }

    for (int i = 0; i < n; i++){
        for (const auto &[k, v]: DP[i]){
            if (k < B[i])
                continue;
            if (DP[i + 1].count(k) == 0)
                DP[i + 1][k] = -INF;
            DP[i + 1][k] = max(DP[i + 1][k], DP[i][k]);
            if (DP[i + 2].count(k + 1) == 0)
                DP[i + 2][k + 1] = -INF;
            DP[i + 2][k + 1] = max(DP[i + 2][k + 1], DP[i][k] + A[i]);
        }
    }

    int64_t ans = -INF;
    for (int i = 0; i <= n + 1; i++){
        if (DP[i].count(n / 2) != 0)
            ans = max(ans, DP[i][n / 2]);
    }
    cout << ans << endl;
}

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

#define MAX(x,y) (x>y?x:y)
#define MIN(x,y) (x<y?x:y)
#define ABS(x) (x>0?x:-(x))

#define INF 1000000000

void swap(int* a, int* b)
{
	int tmp;
	tmp = *a;
	*a = *b;
	*b = tmp;
}

int gcd(int a, int b)
{
	if (a < b)
		swap(&a, &b);

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

int lcm(int a, int b)
{
	return a*b/gcd(a, b);
}

void bubble_sort(int* p, int n)
{
	for (int i = 0; i < n; i++)
	{
		for (int j = 0; j < n - i - 1; j++)
		{
			if (p[j] > p[j + 1])
				swap(&p[j], &p[j + 1]);
		}
	}
}

int array_max(int* p, int n)
{
	int max = 0;
	for (int i = 0; i < n; i++)
	{
		if (p[i] > max)
			max = p[i];
	}
	return max;
}

int binary_search(int* p, int key, int n)
{
	int low = 0, high = n - 1;
	int middle;

	while (low <= high)
	{
		middle = (low + high) / 2;

		//printf("low %d  middle %d  high %d\n", low, middle, high);

		//for (int i = 0; i < n; i++)
		//{
		//	if (i == middle)
		//		printf(" ^ ");
		//	else if (i == low)
		//		printf(" [ ");
		//	else if (i == high)
		//		printf(" ] ");
		//	else if (i == middle)
		//		printf(" ^ ");
		//	else
		//		printf("   ");
		//}
		//printf("\n");

		if (key == p[middle])
			return key;
		else if (key < p[middle])
			high = middle - 1;
		else if (key > p[middle])
			low = middle + 1;
	}

	//printf("low %d  middle %d  high %d\n", low, middle, high);
	return -1;
}

int main()
{
	int N, K, R, S, P;
	char T[100000];
	char T2[100000];
	long long int score = 0;

	scanf("%d%d%d%d%d", &N, &K, &R, &S, &P);

	scanf("%s", T);

	for (int i = 0; i < N; i++)
	{
		if (i - K >= 0)
		{
			if (T[i] == 'r' && T2[i - K] != 'p')
			{
				T2[i] = 'p';
				score += P;
			}
			else if (T[i] == 's' && T2[i - K] != 'r')
			{
				T2[i] = 'r';
				score += R;
			}
			else if (T[i] == 'p' && T2[i - K] != 's')
			{
				T2[i] = 's';
				score += S;
			}
			else T2[i] = ' ';
		}
		else
		{
			if (T[i] == 'r')
			{
				T2[i] = 'p';
				score += P;
			}
			else if (T[i] == 's')
			{
				T2[i] = 'r';
				score += R;
			}
			else if (T[i] == 'p')
			{
				T2[i] = 's';
				score += S;
			}
			else T2[i] = ' ';
		}
	}

	printf("%lld\n", score);

	return 0;
}

Measured memory_bytes: 384
c = 0
list1=input().split()
N = int(list1[0])
M = int(list1[1])
X = int(list1[2]) 
list2 = list(map(int, input().split()))
for i in range(M):
    if list2[i] < X:
        c+=1
if c<=M-c:
    print(c)
else:
    print(M-c)

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

int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    int N;
    cin >> N;
    vector<int> A(N), B(N), C(N);
    for(int i=0; i<N; i++) cin >> A[i];
    for(int i=0; i<N; i++) cin >> B[i];
    for(int i=0; i<N; i++) cin >> C[i];

    sort(A.begin(), A.end());
    sort(B.begin(), B.end());
    sort(C.begin(), C.end());
    ll ans = 0;
    for(int i=0; i<N; i++)
    {
        int numa = lower_bound(A.begin(), A.end(), B[i]) - A.begin();
        int numc = C.end() - upper_bound(C.begin(), C.end(), B[i]);
        ans += 1LL * numa * numc;
    }
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 4444
c=[p]*gets.to_i
l=$<.map{|t|n,*a=t.split.map &:to_i;d=[];a.map{|i|i<0||(d<<i;c[i]=[i,n]+(a-[i]))};[n,d]}.sort
f=->n,d{c[n][3,0]=[l[n][1].size,d,h=(l[n][1].map{|i|f[i,d+1]}.max||-1)+1,d<1?:root:h<1?:leaf:"internal node"];h}
c[n=c.index(p)]=[n,-1,-1]
f[n,0]
puts c.map{|i|%w(node\ %d:\ parent sibling degree depth height %s)*" = %d, "%i}

Measured memory_bytes: 6124
#include <stdio.h>

int num[110];
int bubblesort(int num[],int n){

  int i,j,tmp,count=0;
  for(i=0;i<n;i++){
    for(j=n-1;j>i;j--){
      if(num[j]<num[j-1]){
        count++;
        tmp=num[j-1];
        num[j-1]=num[j];
        num[j]=tmp;
      }
    }
  }
  return count;
}

int main(){

  int i,n,ans;

  scanf("%d",&n);

  for(i=0;i<n;i++){
    scanf("%d",&num[i]);
  }
  ans=bubblesort(num,n);
  for(i=0;i<n-1;i++) printf("%d ",num[i]);
  printf("%d\n%d\n",num[n-1],ans);
  return 0;
}


Measured memory_bytes: 600
N, M, L = map(int, raw_input().split())
nm = [map(int, raw_input().split()) for n in range(N)]
ml = [map(int, raw_input().split()) for m in range(M)]

ml_t = []
for l in range(L):
    tmp = []
    for m in range(M):
        tmp.append(ml[m][l])
    ml_t.append(tmp)

for n in range(N):
    tmp1 = nm[n]
    col = [0]*L
    for l in range(L):
        tmp2 = ml_t[l]
        for m in range(M):
            col[l] += tmp1[m] * tmp2[m]
    print ' '.join(map(str, col))

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

int main(){
    int K, a, b;
    cin >> K;
    if(K % 2 == 0){
        a = K/2;
        b = K/2;
    }else{
        a = K/2;
        b = K/2 + 1;
    }
    cout <<  a * b << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <cstdlib>
#include <algorithm>
#include <numeric>
#include <iostream>
#include <string>
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 a,b,c;
  cin  >> a >> b >> c;
  cout << min(a+b, min(b+c, c+a)) << endl;
  return 0;
} 

Measured memory_bytes: 3584
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cassert>
#include <functional>
#include <algorithm>
#include <string>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <stack>
using namespace std;
using llong = long long;

llong d, g;
llong p[16];
llong c[16];

int main() {
    cin >> d >> g;
    for (int i = 0; i < d; i++) {
        cin >> p[i] >> c[i];
    }

    llong ans = 1000000;
    for (llong st = 0; st < (1ll << d); st++) {
        llong s = 0;
        llong x = 0;

        
        llong tmp = st;
        llong j = 1;
        while (tmp) {
            if (tmp & 1) {
                s += 100 * j * p[j - 1] + c[j - 1];
                x += p[j - 1];
            }
            tmp >>= 1;
            j++;
        }

        if (s >= g) {
            ans = min(ans, x);
            continue;
        }

        tmp = st;
        j = d;
        while (j > 0 && tmp & (1 << (j - 1))) j--;

        if (j <= 0) continue;
        if (((g - s) + (100 * j - 1)) / (100 * j) < p[j - 1]) {
            x += ((g - s) + (100 * j - 1)) / (100 * j);
            ans = min(ans, x);
        }
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
using ll=long long;
int main(){
  ll N,B,R;
  cin>>N>>B>>R;
  ll sum=0;
  sum=(N/(B+R))*B;
  //cout<<sum<<endl;
  ll amari=(N%(B+R));
  if(amari>=B){
    sum+=B;
  }else{
    sum+=amari;
  }
  cout<<sum<<endl;
}

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

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

#define pb push_back
#define eb emplace_back
#define mp make_pair
#define fi first
#define se second
#define rep(i,n) rep2(i,0,n)
#define rep2(i,m,n) for(int i=m;i<(n);i++)
#define ALL(c) (c).begin(),(c).end()

string s;
ll ret;
ll num[26];

int main() {
	cin >> s;
	rep(i, s.size()) ++num[s[i]-'a'];
	rep(i, 26) ret += num[i] * (s.size() - num[i]);
	cout << ret / 2 + 1 << endl;
	return 0;
}

Measured memory_bytes: 640
# -*- coding: utf-8 -*-
# 整数の入力
num = int(input())

c = [0,0,0,0]

for i in range(num):
    s = input()
    if s == "AC":
        c[0]+= 1
    if s == "WA":
        c[1]+= 1
    if s == "TLE":
        c[2]+=1
    if s == "RE":
        c[3]+=1



# 出力
print("AC x {}".format(c[0]))
print("WA x {}".format(c[1]))
print("TLE x {}".format(c[2]))
print("RE x {}".format(c[3]))


Measured memory_bytes: 9172
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define ALL(a) (a).begin(),(a).end()
using namespace std;
using ll = long long;
using P = pair<int,int>;

int h,w;
vector<string> field(1000);
vector<vector<int>> d(1000,vector<int> (1000));

int INF = 1e9;
vector<int> dx = {1,0,-1,0}, dy = {0,1,0,-1};

void bfs(){
    queue<P> que;
    rep(i,h)rep(j,w) d[i][j] = INF;
    rep(i,h)rep(j,w) if(field[i][j] == '#') {
        d[i][j] = 0;
        que.push(P(i,j));
    }
    while(que.size()){
        P p = que.front(); que.pop();
        int x = p.first, y = p.second;
        rep(i,4){
            int nx = x + dx[i], ny = y + dy[i];
            if(0 <= nx && nx < h && 0 <= ny && ny < w && d[nx][ny] == INF){
                que.push(P(nx,ny));
                d[nx][ny] = d[x][y] + 1;
            }
        }
    }
    return;
}

int main(){
    cin >> h >> w;
    rep(i,h) cin >> field[i];
    bfs();
    int ans = 0;
    rep(i,h)rep(j,w) ans = max(ans,d[i][j]);
    cout << ans << endl;
}

Measured memory_bytes: 13456
#include <bits/stdc++.h>
using namespace std;
#define long long long
#define read cin >>
#define echo cout <<
#define fin << '\n'

struct Data {
    int to, id;
};

vector<Data> g[100100];

int colour[100100];

void dfs ( int pos, int colourPrev) {
    int colourNext = 1;
    for ( int i = 0; i < (int)g[pos].size(); i++ ) {
        Data next = g[pos][i];
        if ( !colour[next.id] ) {
            if ( colourNext == colourPrev ) colourNext++;
            colour[next.id] = colourNext;
            dfs ( next.to, colourNext );
            colourNext++;
        }
    }
}

signed main ( ) {

    int n;
    read n;
    for ( int i = 0; i < n-1; i++ ) {
        int a, b;
        read a >> b;
        a--;
        b--;
        g[a].push_back({b,i});
        g[b].push_back({a,i});
    }

    int k = 0;
    for ( int i = 0; i < n; i++ ) {
        k = max ( (int)g[i].size(), k );
    }

    echo k fin;
    dfs(0, 0);

    for ( int i = 0; i < n-1; i++ ) {
        echo colour[i] fin;
    }

    return 0;
}

Measured memory_bytes: 9344
#include <bits/stdc++.h>
#include <chrono>
using namespace std;
using ll = long long;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repl(i, n) for (ll i = 0; i < (ll)(n); i++)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
#define rep2l(i, s, n) for (ll i = (ll)(s); i < (ll)n; i++)

int main() {
    int N;
    cin >> N;
    vector<ll> A(N);
    vector<ll> ruiseki(N);
    priority_queue<ll, vector<ll>, greater<ll>> ans;
    rep(i, N) {
        cin >> A[i];
    }
    rep(i, N) {
        if (i == 0) {
            ruiseki[i] = A[i];
        }
        else {
            ruiseki[i] = ruiseki[i-1] + A[i];
        }
    }
    rep(i, N-1) {
        ll x = ruiseki[i];
        ll y = ruiseki[N-1] - ruiseki[i];
        ans.push(abs(x-y));
    }
    cout << ans.top() << endl;
}

Measured memory_bytes: 5492
#include<iostream>
#include<vector>
#include<queue>
#include<utility>
using namespace std;

#define rep(i,n) for(int i=0;i<(n);++i)

constexpr int dx[]={1,0,-1,0};
constexpr int dy[]={0,1,0,-1};
constexpr int ddx[] = {1,1,-1,-1,2,2,2,2,2,-2,-2,-2,-2,-2,1,0,-1,1,0,-1};
constexpr int ddy[] = {1,-1,1,-1,0,1,2,-1,-2,2,1,0,-1,-2,2,2,2,-2,-2,-2};
constexpr int INF = 1<<28;

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  int H,W,C_h,C_w,D_h,D_w;

  cin>>H>>W>>C_h>>C_w>>D_h>>D_w;
  C_h--,C_w--,D_h--,D_w--;
  vector<string> S(H);
  rep(i,H)cin>>S[i];

  vector dist(H,vector(W,INF));
  dist[C_h][C_w] = 0;
  deque<pair<int,int>> deq;
  deq.emplace_front(C_h,C_w);
  while(!deq.empty()){
    auto [y,x] = deq.front();
    deq.pop_front();
    rep(i,4){
      int ny = y+dy[i];
      int nx = x+dx[i];
      if(ny>=0&&nx>=0&&ny<H&&nx<W&&S[ny][nx]=='.'){
        if(dist[ny][nx]>dist[y][x]){
          dist[ny][nx] = dist[y][x];
          deq.emplace_front(ny,nx);
        }
      }
    }
    rep(j,20){
      int ny = y+ddy[j];
      int nx = x+ddx[j];
      if(ny>=0&&nx>=0&&ny<H&&nx<W&&S[ny][nx]=='.'){
        if(dist[ny][nx]>dist[y][x]+1){
          dist[ny][nx] = dist[y][x]+1;
          deq.emplace_back(ny,nx);
        }
      }
    }
  }
  int ans = dist[D_h][D_w];
  cout<<(ans==INF?-1:ans)<<endl;
}


Measured memory_bytes: 8776
s = str(input())
t = str(input())

coincidence = 0
for i in range(len(s) - len(t) + 1):
    count = 0
    for j in range(len(t)):
        if s[i+j] == t[j]:
            count += 1
    coincidence = max(coincidence, count)

print(len(t) - coincidence)

Measured memory_bytes: 9124
#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG
#define rep(i, from, to) for (int i = from; i < (to); ++i)
#define mp(x,y) make_pair(x,y)
#define all(x) (x).begin(),(x).end()
#define pb push_back
using ll = long long;
using vin=vector<int>;
using vll=vector<ll>;
using vst=vector<string>;
using P = pair<int, int>;
const int inf=1e9+7;
const ll INF=1e18;
template <typename T> void chmin(T &a, T b) { a = min(a, b); }
template <typename T> void chmax(T &a, T b) { a = max(a, b); }
template<class T> inline void Yes(T condition){ if(condition) cout << "Yes" << endl; else cout << "No" << endl; }
template<class T> inline void YES(T condition){ if(condition) cout << "YES" << endl; else cout << "NO" << endl; }
const int dx[4] = { 1, 0, -1, 0 };
const int dy[4] = { 0, 1, 0, -1 };


int main(){cout<<fixed<<setprecision(10);
		   string s;
           cin>>s;
           int n=s.size();
           rep(i,0,n-8){
             cout<<s[i];
           }
           cout<<endl;
}

Measured memory_bytes: 3584
#include<stdio.h>

#define N 100

void Insort(void);

int n = 0,arr[N];
int i = 0;
int v = 0;
int j = 0;
int k = 0;
int main()
{

//input data

  scanf("%d",&n);
  for(i = 0; i < n; i++)
    {
      scanf("%d",&arr[i]);
    }

  //assignment Insort

    printf("%d",arr[0]);
      for(k = 1; k < n ; k++)
	{
	  printf(" %d",arr[k]);
	}
      printf("\n");
  Insort();

  return 0;
}

void Insort(void)
{
  for(i = 1; i <= n - 1; i++)
    {
      v = arr[i]; 
      j = i - 1;

      for(; j >= 0 && arr[j] > v ;)
	{
	  arr[j+1] = arr[j];
	  j--;
	  //printf("j=%d\n",j);
	}
      arr[j+1]=v;
      /*
       if(j == -1 || arr[j] <= v)
	    {
	      arr[j+1] = v;
	      break;
	      }*/

      printf("%d",arr[0]);
      for(k = 1; k < n ; k++)
	{
	  printf(" %d",arr[k]);
	}
      printf("\n");
    }
     
}




Measured memory_bytes: 2036
#include<bits/stdc++.h>
#include<iostream>
#include<algorithm>
#include<numeric>
#include<string>
#include<vector>
using namespace std;
int main(){
    string s;
    cin>>s;
    int ans=1000;
    int n=s.length();
    for(int i=0;i<=n-3;i++){
        int num=stoi(s.substr(i,3));
        ans=min(ans,abs(num-753));
    }
    cout<<ans<<endl;
    return 0;
}

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

int main(){
    //入力変数宣言
    ll n,m; ll l; 
    cin >> n >> m >> l;
    vector<vector<ll>> d(n,vector<ll>(n,INF)); //d[i][j]:iとjの最短距離
    ll a,b; ll c;
    
    //入力
    rep(i,m){
        cin >> a >> b >> c;
        --a; --b;
        d[a][b] = c;
        d[b][a] = c;
    }

    rep(i,n) d[i][i] = 0LL;

    //warshal-floyd
    //最短距離を求める
    rep(k,n) rep(i,n) rep(j,n) d[i][j] = min(d[i][j], d[i][k] + d[k][j]);
    
    //最小補給回数を求める
    vector<vector<ll>> charge(n,vector<ll>(n,INF)); //charge[i][j]:iからjに行く時の最小補給回数(+1)
    rep(i,n) rep(j,n) if(d[i][j] <= l && i != j) charge[i][j] = 1LL; //最小距離がl以下なら辺を張る
    rep(i,n) charge[i][i] = 0LL;
    //warshal-floyd
    rep(k,n) rep(i,n) rep(j,n) charge[i][j] = min(charge[i][j], charge[i][k] + charge[k][j]);

    //クエリ処理
    ll q; cin >> q;
    ll s,t;
    rep(i,q){
        cin >> s >> t;
        --s; --t;
        if(charge[s][t] < INF) cout << charge[s][t]-1 << "\n";
        else cout << -1 << "\n";
    }
}

Measured memory_bytes: 1920
g=gets.split
x=[0,2,5,3]
y=[0,4,5,1]
gets
while gets
a,b=$_.split.map{|s|g.index s}
n=[*g]
m=->r,d{r.map{|i|n[i]}.rotate(d).map.with_index{|v,i|n[r[i]]=v}}
m[rand(2)>0?x:y,rand(2)>0?1:-1]until[g[a],g[b]]==n[0..1]
puts n[2]
end

Measured memory_bytes: 6136
#include <cstdio>
#include <vector>
using namespace std;
int N, t; vector<int> v;
int rec(int x, int cnt) {
  if(x%2 == 1) return cnt;
  return rec(x/2, cnt+1);
}
int main() {
  int N; scanf("%d", &N);
  for(int i = 0; i < N; i++) {
    scanf("%d", &t);
    if(t%2 == 0) v.push_back(t);
  }
  int sum;
  for(int x : v) sum += rec(x, 0);
  printf("%d\n", sum);
}

Measured memory_bytes: 384
//hi
#include<bits/stdc++.h>
using namespace std;
#define PB push_back
#define MP make_pair
#define F first
#define S second
typedef long long int LL;
vector<int> v[100005];
int tot;
int n,k;
int dfs(int now,int fa){
	int i;
	int maxch=0;
	for(i=0;i<v[now].size();i++){
		int to=v[now][i];
		maxch=max(maxch,dfs(to,now));
	}
	if(fa==1) return 0;
	if(maxch==k-1 && fa!=1){
		tot++;
		return 0;
	}
	return maxch+1;
}
int main(void){
    scanf("%d%d",&n,&k);
    int i;
    int o;
    scanf("%d",&o);
    for(i=2;i<=n;i++){
		int d;
		scanf("%d",&d);
		v[d].PB(i);
	}
	tot=0;
	dfs(1,1);
	if(o!=1) tot++;
	printf("%d\n",tot);
    return 0;
}


Measured memory_bytes: 11904
a = map(int, raw_input().split())

if a[0] > a[1]:
	tmp=a[0]
	a[0]=a[1]
	a[1]=tmp
	
if a[1] > a[2]:
	tmp=a[1]
	a[1]=a[2]
	a[2]=tmp

if a[0] > a[1]:
	tmp=a[0]
	a[0]=a[1]
	a[1]=tmp
	
print a[0],a[1],a[2]

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

using ll = long long int;

const int MAX = (int)(1e5 + 5);
const ll INF = (ll)(1e10 + 5);

ll n, k;

ll ans;

int main(void) {
  // Here your code !
  scanf("%lld %lld", &n, &k);

  ans = 0LL;

  // for (int j = 0LL; j <= n; ++j) {
  //   printf("%lld ", j);
  // }
  // printf("\n");

  // for (ll i = 1LL; i <= n; ++i) {
  //   for (int j = 0LL; j <= n; ++j) {
  //     printf("%lld ", j % i);
  //   }
  //   printf("[%lld\n", i);
  // }

  for (ll i = 1LL; i <= n; ++i) {
    ll block = (n + 1LL) / i;
    ll remain = (n + 1LL) % i;

    ll commit_block = max(i - k, 0LL);
    ll commit_remain = max(remain - k, 0LL);

    // printf("i: %lld, commit_block: %lld, block: %lld, commit_reamin: %lld\n", i, commit_block, block, commit_remain);

    ans += commit_block * block + commit_remain - ((k == 0LL) ? 1LL : 0LL);
  }

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

  return 0;
}


Measured memory_bytes: 256
class Array
	def bsearch_first_index(l = 0, r = size - 1, &pred)
		return nil if l > r
		c = (l + r) / 2 
		if pred[self[c]]
			bsearch_first_index(l, c-1, &pred) || c
		else
			bsearch_first_index(c+1, r, &pred)
		end
	end

	def bsearch_first_item(l = 0, r = size - 1, &pred)
		i = bsearch_first_index(l, r, &pred)
		i ? self[i] : nil
	end

	def bsearch_last_index(l = 0, r = size - 1, &pred)
		return nil if l > r
		c = (l + r) / 2 
		if pred[self[c]]
			bsearch_last_index(c+1, r, &pred) || c
		else
			bsearch_last_index(l, c-1, &pred)
		end
	end

	def bsearch_last_item(l = 0, r = size - 1, &pred)
		i = bsearch_last_index(l, r, &pred)
		i ? self[i] : nil
	end
end

a = (1..1111).to_a.repeated_combination(2).map{|x, y|
	x**3 + y**3
}.sort

loop {
	z = gets.to_i
	break if z == 0
	z3 = z**3
	p z3 - a.bsearch_last_item{|x| x <= z3}
}

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

using namespace std;

typedef long long ll;
const ll MOD=1e9+7;
const int INF = numeric_limits<int>::max() / 2;

char c[26]={'a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z'};

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

  int n;cin>>n;
  std::vector<string> s(n);
  for(int i=0;i<n;i++) cin>>s[i];
  int memo[30];
  for(int i=0;i<30;i++) memo[i]=INF;
  for(int i=0;i<n;i++){
      int tmp[30]={};
      for(int j=0;j<(int )s[i].length();j++){
          int t=s[i][j]-'a';
          //cout<<t<<endl;
          tmp[t]++;
      }
      for(int j=0;j<26;j++){
          //cout<<tmp[i]<<endl;
          memo[j]=min(memo[j],tmp[j]);
      }
  }
  
  for(int i=0;i<26;i++)if(memo[i]!=INF)for(int j=0;j<memo[i];j++){
      cout<<c[i];
  }
  cout<<endl;

}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const int inf = 1e9; //1(1倍)e(指数)9(10^9)
ll calc(int n)
{
	int res = 0;
	while (n > 0)
	{
		res += n % 10;
		n /= 10;
	}
	return res;
}

int main()
{
	int n;
	scanf("%d", &n);
	ll res = inf;
	for (ll i = 1; i < n; ++i) //n = i + jとして全探索
	{
		ll j = n - i;
		ll tmp = calc(i) + calc(j);
		res = min(res, tmp);
	}
	cout << res << endl;
	return 0;
}

Measured memory_bytes: 3632
"use strict";
function Main(input) {
    let lines = input.split("\n");
    let nm = lines.shift().split(/\s/).map((v) => v - 0);
    let N = nm[0], M = nm[1];
    const MAX_N = 1e5 + 1;
    let V = new Array(MAX_N).fill(0).map(() => []);
    for (let m = 0; m < M; m++) {
        let py = lines.shift().split(/\s/).map((v) => v - 0);
        V[py[0]].push([py[1], m]);
    }
    const d6 = (n) => ('000000' + n.toString()).slice(-6);
    const d12 = (p, y) => d6(p) + d6(y);
    let ans = new Array(M);
    for (let m = 0; m < MAX_N; m++) {
        V[m].sort((a, b) => a[0] - b[0]);
        let v = V[m];
        for (let n = 0; n < v.length; n++) {
            ans[v[n][1]] = d12(m, n + 1);
        }
    }
    for (let m = 0; m < M; m++) {
        console.log(ans[m]);
    }
}
if (typeof window == "undefined") Main(require("fs").readFileSync("/dev/stdin", "utf8"));


Measured memory_bytes: 79956
import sys
readline = sys.stdin.readline
write = sys.stdout.write
flush = sys.stdout.flush

def query(n):
    write("? %d\n" % n)
    flush()
    return readline().strip() == 'Y'
def answer(n):
    write("! %d\n" % n)
    flush()

"""
N = 123
q = 0
def dummy(n, N):
    return ((n <= N and str(n) <= str(N)) or (n > N and str(n) > str(N)))
def query(n):
    global q
    q += 1
    assert q <= 64
    print q, n, N, dummy(n, N)
    return dummy(n, N)
def answer(n):
    print "check", n, N
    assert n == N
"""

dig = None
for i in xrange(10):
    if not query(10**i):
        dig = i
        break
else:
    # 10**k
    for i in xrange(10):
        if query(10**i+1):
            ans = 10**i
            break
    answer(ans)
    exit(0)

def check(ans, i):
    if i == dig-1:
        return not query(int("".join(map(str, ans)))*10)
    return query(int("".join(map(str, ans))))

ans = []
for i in xrange(dig):
    ans.append(0)
    left = (i<1)-1; right = 10
    while left+1 < right:
        mid = (left + right) / 2
        ans[i] = mid
        if check(ans, i):
            left = mid
        else:
            right = mid
    if i == dig-1:
        ans[i] = left+1
    else:
        ans[i] = left

num = int("".join(map(str, ans)))
answer(num)


Measured memory_bytes: 3152