akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;

using i64 = int64_t;

bool is_valid(int n){
    string s = to_string(n);
    for(int i=1;i<s.size();++i){
        if(s[i] != s[i-1]+1)return false;
    }
    return true;
}

int main(){
    int n;
    cin >> n;
    vector<int> v;
    for(int i=0;i<n;++i){
        int a;
        cin >> a;
        v.push_back(a);
    }

    int ans = -1;
    for(int i=0;i<n;++i){
        for(int j=i+1;j<n;++j){
            bool ok = is_valid(v[i]*v[j]);
            if(ok && v[i]*v[j] > ans)ans = v[i]*v[j];
        }
    }

    cout << ans << endl;

    return 0;
}



Measured memory_bytes: 3288
#include<iostream>
#include<string>
#include<queue>
#include<algorithm>
using namespace std;

int main(){
    int n, q, t;
    string name;

    cin>>n>>q;
    queue<pair<string, int> > Q;
    for(int i=0; i<n;i++){
        cin>>name>>t;
        Q.push(make_pair(name, t));
    }
    int totalTime=0;
    while(!Q.empty()){
        int oneExeTime;
        pair<string, int> qOne;
        qOne = Q.front(); Q.pop();
        oneExeTime = min(qOne.second,q );
        totalTime += oneExeTime;
        qOne.second -= oneExeTime; 

        if(qOne.second == 0){
            cout << qOne.first << " " << totalTime<< endl;
        }else{
            Q.push(qOne);
            
        }
    }
    return 0;
}


Measured memory_bytes: 6376
#include<bits/stdc++.h>
#define N 105
using namespace std;
inline int read(){
	int ans=0;
	char ch=getchar();
	while(!isdigit(ch))ch=getchar();
	while(isdigit(ch))ans=(ans<<3)+(ans<<1)+(ch^48),ch=getchar();
	return ans;
}
int n,x,a[N];
int main(){
	n=read(),x=read();
	for(int i=1;i<=n;++i)a[i]=read();
	sort(a+1,a+n+1);
	int cnt=0;
	for(int i=1;i<n;++i){
		if(x>=a[i])++cnt,x-=a[i];
		else break;
	}
	if(x==a[n])++cnt;
	cout<<cnt;
	return 0;
}

Measured memory_bytes: 256
S=input()
if S=="SUN":
	print(7)
elif S=="MON":
	print(6)
elif S=="TUE":
	print(5)
elif S=="WED":
	print(4)
elif S=="THU":
    print(3)
elif S=="FRI":
    print(2)
else:
    print(1)

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

int main()
{
	int n, k;
	cin >> n >> k;
	string s;
	cin >> s;
	
	s[k-1] = s[k-1] + ('a' - 'A');
	
	cout << s << endl;
	
	return 0;
}


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

#define ll long long
#define MOD 1000000007
#define maxlen 100005

#define fastio ios_base::sync_with_stdio(false);
#define fastcin cin.tie(NULL);

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

    cout << (n-h+1)*(n-w+1) << "\n";

}


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++)

int main(){
    int x,a,b;
    cin>>x>>a>>b;
    x-=a;
    while (true)
    {
        if (x<b)
        {
            /* code */
            break;
        }
        
        x-=b;
    }
    cout<<x<<endl;
    
}

Measured memory_bytes: 256
#include <iostream>
#include <queue>
#include <vector>

std::vector<std::vector<int>> make_tree(const int n) {
  std::vector<std::vector<int>> tree(n);
  for (int i = 0; i < n - 1; ++i) {
    int a, b;
    std::cin >> a >> b;
    tree[a - 1].push_back(b - 1);
    tree[b - 1].push_back(a - 1);
  }
  return tree;
}

std::vector<int> make_counter(const int n, const int q) {
  std::vector<int> counter(n, 0);
  for (int i = 0; i < q; ++i) {
    int p, x;
    std::cin >> p >> x;
    counter[p - 1] += x;
  }
  return counter;
}

int main() {
  int n, q;
  std::cin >> n >> q;

  const auto tree = make_tree(n);
  auto counter = make_counter(n, q);

  std::queue<int> roots;
  roots.push(0);

  // 探索済みかどうかを記録する配列
  std::vector<bool> is_searched(n, false);

  while (!roots.empty()) {
    const auto root = roots.front();
    roots.pop();

    is_searched[root] = true;
    const auto c = counter[root];
    const auto& nodes = tree[root];

    for (auto&& node : nodes) {
      if (!is_searched[node]) {
        counter[node] += c;
        roots.push(node);
      }
    }
  }

  for (auto&& c : counter) std::cout << c << ' ';
  std::cout << std::flush;
}

Measured memory_bytes: 15604
using System;
using System.Diagnostics;
using System.Collections.Generic;

class Myon

{
    public Myon() { }
    public static int Main()
    {
        cin = new Scanner();
        new Myon().calc();
        return 0;
    }
    static Scanner cin;

    void calc()
    {
        int X = cin.nextInt();
        int ans = (X / 500) * 1000 + (X % 500 / 5) * 5;
        Console.WriteLine(ans);
    }

}


class Scanner
{
    string[] s;
    int i;

    char[] cs = new char[] { ' ' };

    public Scanner()
    {
        s = new string[0];
        i = 0;
    }

    public string next()
    {
        if (i < s.Length) return s[i++];
        string st = Console.ReadLine();
        while (st == "") st = Console.ReadLine();
        s = st.Split(cs, StringSplitOptions.RemoveEmptyEntries);
        if (s.Length == 0) return next();
        i = 0;
        return s[i++];
    }

    public int nextInt()
    {
        return int.Parse(next());
    }
    public int[] ArrayInt(int N, int add = 0)
    {
        int[] Array = new int[N];
        for (int i = 0; i < N; i++)
        {
            Array[i] = nextInt() + add;
        }
        return Array;
    }

    public long nextLong()
    {
        return long.Parse(next());
    }

    public long[] ArrayLong(int N, long add = 0)
    {
        long[] Array = new long[N];
        for (int i = 0; i < N; i++)
        {
            Array[i] = nextLong() + add;
        }
        return Array;
    }

    public double nextDouble()
    {
        return double.Parse(next());
    }


    public double[] ArrayDouble(int N, double add = 0)
    {
        double[] Array = new double[N];
        for (int i = 0; i < N; i++)
        {
            Array[i] = nextDouble() + add;
        }
        return Array;
    }
}




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

void max_replace(int &a, int b) {
    if (a < b) {
        a = b;
    }
}

int N;
vector<vector<int>> gragh(N);
vector<int> dp(N, -1);

int DP(int a) {
    if (dp.at(a) != -1) {
        return dp.at(a);
    }

    int res = 0;
    for (auto v : gragh.at(a)) {
        max_replace(res, DP(v) + 1);
    }
    dp.at(a) = res;
    return res;
}

int main() {
    int M;
    cin >> N >> M;
    gragh.resize(N);
    for (int i = 0; i < M; i++) {
        int x, y;
        cin >> x >> y;
        gragh.at(x - 1).push_back(y - 1);
    }

    dp.resize(N, -1);
    int ans = 0;
    for (int i = 0; i < N; i++) {
        max_replace(ans, DP(i));
    }

    cout << ans << endl;
}

Measured memory_bytes: 8192
import java.util.Scanner;

public class Main {

    static final int FIZZ_VAL = 3;
    static final int BUZZ_VAL = 5;

    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
        final int iInputVal = Integer.parseInt(sc.next());
        long lResult = 0;
        for (int iColumn = 1; iColumn <= iInputVal; iColumn++) {
            if (0 == isFizz(iColumn)) {
                continue;
            } else if (0 == isBuzz(iColumn)) {
                continue;
            } else if (0 == isFizz(iColumn) && 0 == isBuzz(iColumn)) {
                continue;
            }
            lResult += iColumn;
        }

        System.out.print(lResult);
    }

    private static int isFizz(final int iVal) {
        return iVal % FIZZ_VAL;
    }

    private static int isBuzz(final int iVal) {
        return iVal % BUZZ_VAL;
    }

}


Measured memory_bytes: 35648
#include <bits/stdc++.h>
 
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(), (x).end()
 
using namespace std;
 
typedef long long ll;
typedef vector<int> vi;
typedef pair<int,int> P;
 
constexpr int INF = 1e9;
constexpr int MOD = 1e9+7;

int main() {
    int n;
    string c;
    cin >> n >> c;
    int l = 0,r = n-1,cnt = 0;
    while(l < r){
        while(l < n && c[l]!='W') l++;
        while(r >= 0 && c[r]!='R') r--;
        if(l>=r) break;
        cnt++;
        l++,r--;
    }
    cout << cnt << endl;

	return 0;
}

Measured memory_bytes: 3724
n, t = map(int, input().split())
ct = [list(map(int, input().split())) for _ in range(n)]

ct.sort(key=lambda x: x[1])
ct.sort(key=lambda x: x[0])
for i in range(n):
    if ct[i][1] <= t:
        print(ct[i][0])
        exit()
print('TLE')


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

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

    int count=0;
    
    for(int i=0;i<n.size();i++){
        count+=n[i]-'0';
    }

    if(count%9==0) cout<<"Yes"<<endl;
    else if(count%9!=0) cout<<"No"<<endl;
}

Measured memory_bytes: 3716
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
#define brep(i,n) for(int i=n-1;i>=0;i--)
#define rep1(i,n) for(int i=1;i<n;i++)
#define cY cout<<"Yes"<<endl
#define cN cout<<"No"<<endl
 
int main(void){
    int n,m,l;
    cin >> n >> m >> l;
    int ans;
    if(n >= m&&n >= l)ans = 10*n+m+l;
    else if(m >= n&&m >= l)ans = 10*m+n+l;
    else ans = 10*l+n+m;
    cout << ans << endl;
    return 0;
}

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

#define x first
#define y second

using namespace std;

typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int,int> ii;
typedef pair<ll,ll> pll;

const int mod=1000000000+7;

int addm(int& a,int b) {return (a+=b)<mod?a:a-=mod;}

template<class T,class U> bool smin(T& a,U b) {return a>b?(a=b,1):0;}
template<class T,class U> bool smax(T& a,U b) {return a<b?(a=b,1):0;}

int N,a[100000];

bool can(int i) {
	ll sz=0;
	for (int j=0;j<=i;j++) sz+=a[j];
	for (int j=i+1;j<N;j++) if (a[j]<=2*sz) sz+=a[j];
	else return 0;
	return 1;
}

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

	cin >> N;
	for (int i=0;i<N;i++) cin >> a[i];
	sort(a,a+N);

	int l=0,u=N-1;
	while (l!=u) {
		int mid=(l+u)/2;
		if (can(mid)) u=mid;
		else l=mid+1;
	}

	cout << N-l << endl;
}

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

using namespace std;

#define rep(i, x)   for (__typeof(x) i = 0; i < x; i++)
#define mp             make_pair
#define pb             push_back
#define fi             first
#define se             second
#define sz(x)          (int)((x).size())
#define all(x)         (x).begin(), (x).end()
#define sci(x)         int x;       scanf("%d", &x);
#define scii(x, y)     int x, y;    scanf("%d %d", &x, &y);
#define sciii(x, y, z) int x, y, z; scanf("%d %d %d", &x, &y, &z);
#define TC(x)          sci(x); while(x --)
#define eprintf(...)   fprintf(stderr, __VA_ARGS__)
#define debug(x)       { cerr << #x << " = " << x << endl; }
#define repi(i, x)  for (__typeof(x) i = x-1; i >= 0; i --)
#define fore(itr, x)   for (__typeof(x.begin()) itr = x.begin(); itr != x.end(); itr ++)
#define forei(itr, x)  for (__typeof(x.end()) itr = x.end() - 1; itr != x.begin() - 1; itr --)
typedef long long      ll;
typedef pair<int, int> ii;
typedef pair<ii, int>  iii;
typedef vector<int>    vi;
typedef vector<ii>     vii;
typedef vector<iii>    viii;
typedef vector<vector<int> > vvi;
typedef pair<ll, ll>   pairl;
typedef vector<ll>     vl;
typedef vector<ll>     vll;
typedef vector<vector<ll> > vvl;
const   int            infi = numeric_limits<int>::max();
const   ll             infl = numeric_limits<ll>::max();
const   double         eps = 0;
const   int            ms  = 0;



int main()
{
    ios::sync_with_stdio(false);//endl->"\n"
    cin.tie(0);
    int N;
    string S;
    cin >> N >> S;
    string A = S.substr(0, N/2);
    if(S == A+A){
        cout << "Yes" << endl;
    }
    else {
        cout << "No" << endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
int top, S[1000];

void push(int x){
	S[++top] = x;
}
int pop(){
	top--;
	return S[top+1];
}

int main(){
	int a,b;
	top = 0;
	char str[100];
	while( scanf("%s",str) != EOF) {
		if(str[0] == '+'){
			a = pop();
			b = pop();
			push(a+b);
		}else if(str[0] == '-'){
			b = pop();
			a = pop();
			push(a-b);
		}else if(str[0] == '*'){
			a = pop();
			b = pop();
			push(a*b);
		}else{
			push(atoi(str));
		}
	}
	printf("%d\n",pop());
	return 0;
}

Measured memory_bytes: 2732
using System;
using System.Linq;

class D
{
	static void Main()
	{
		var k = Console.ReadLine().Split().Select(int.Parse).ToArray()[3];
		var v = new int[3].Select(_ => Console.ReadLine().Split().Select(long.Parse).OrderBy(x => -x).ToArray()).ToArray();

		Func<long[], long[], long[]> comb = (p, q) => p.SelectMany((x, i) => q.TakeWhile((y, j) => (i + 1) * (j + 1) <= k).Select(y => x + y)).OrderBy(x => -x).Take(k).ToArray();
		Console.WriteLine(string.Join("\n", comb(comb(v[0], v[1]), v[2])));
	}
}


Measured memory_bytes: 17888
#include <stdio.h>

int main()
{
    int n,a;
    scanf("%d",&n);

    int i = 0;
    do
    {
        do
        {
            a = i * (i + 1) / 2;
            i ++;
        } while (a < n);
        printf("%d\n",i -1);
        n -= (i - 1);
        i = 0;
    } while (n != 0);
}

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

const int INF = 1e9;
const int MOD = 1e9 + 7;

using namespace std;

typedef long long ll;

#define REP(i, n) for (int i = 0; i < int(n); i++)
#define REPD(i, n) for (int i = n - 1; i >= 0; i--)
#define FOR(i, a, b) for (int i = a; i < int(b); i++)
#define FORD(i, a, b) for (int i = b - 1; i >= int(a); i--)
#define WRAP(y, x, h, w) (0 <= y && y < h && 0 <= x && x < w)

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

int dx[4] = { 1, 0, -1, 0 };
int dy[4] = { 0, 1, 0, -1 };


int main()
{
    int n;
    cin >> n;
    int ans=0;
    FOR(i,1,n){
       ans+=(n-1)/i;
    }

    cout<<ans<<endl;
    
}

Measured memory_bytes: 3632
#include<cstdio>
#define IN 50
using namespace std;

int n,u,f,y,x;
int h[100][100],d[100][100],res[7];
int dice[6],tmp[6];
int dy[] = {0,1,-1,0}, dx[] = {-1,0,0,1}; //w,s,n,e
 
int rot[4][6] = { {4,0,2,3,5,1},
		  {3,1,0,5,4,2},
		  {2,1,5,0,4,3},
		  {1,5,2,3,0,4} };

int die[6][6] = { {0,2,4,1,3,0},
		 {3,0,0,5,0,2},
		 {1,5,0,0,0,4},
		 {4,0,0,0,5,1},
		 {2,0,5,0,0,3},
		 {0,3,1,4,2,0} };

int main(){
  while(scanf("%d",&n),n){
    for(int i=0;i<100;i++)
      for(int j=0;j<100;j++)h[i][j] = d[i][j] = -1;

    while(n--){
      scanf("%d %d",&u,&f);
      u--; f--;
      dice[0] = u; dice[5] = 5-u;
      dice[1] = f; dice[4] = 5-f;
      dice[2] = die[u][f]; dice[3] = 5 - die[u][f];
      
      f = true;
      y = x = IN;
      while(f){
	f = false;
	for(int i=5;i>=3;i--){
	  for(int j=0;j<4;j++){
	    if(dice[j+1] == i){
	      if(h[y][x] > h[y+dy[j]][x+dx[j]]){
		y = y+dy[j]; x = x+dx[j];
		for(int k=0;k<6;k++)tmp[k] = dice[rot[j][k]];
		for(int k=0;k<6;k++)dice[k] = tmp[k];
		f = true;
		break;
	      }
	    }
	  }
	  if(f)break;
	}
      } 
      h[y][x]++; d[y][x] = dice[0];
    }
    
    for(int i=0;i<7;i++)res[i] = 0;
    for(int i=0;i<100;i++)
      for(int j=0;j<100;j++)res[d[i][j]+1]++;
    for(int i=1;i<6;i++)printf("%d ",res[i]);
    printf("%d\n",res[6]);
  }
}

Measured memory_bytes: 0
#include<bits/stdc++.h>
using namespace std;
#define re register
struct eg{int to;eg*nx;}e[4100],*la[2100],*cnt=e;
char ss[2010];
int f[2010],nm[2010],mi[2010];
void addE(re int a,re int b)
{
	*++cnt=(eg){b,la[a]};la[a]=cnt;
	*++cnt=(eg){a,la[b]};la[b]=cnt;
}
void dfs(re int a,re int fa)
{
	nm[a]=ss[a]-'0';f[a]=0;
	re int mx=0,mxq=0;
	for(re eg*i=la[a];i;i=i->nx)if(i->to!=fa)
	{
		dfs(i->to,a);
		f[a]+=f[i->to]+nm[i->to];nm[a]+=nm[i->to];
		if(mx<mi[i->to]+nm[i->to])mx=mi[i->to]+nm[i->to],mxq=f[i->to]+nm[i->to];
	}
	if(mx+mxq<=f[a])mi[a]=f[a]&1;
	else mi[a]=mxq+mx-f[a];
}
int main()
{
	re int n,x,y;
	re int ans=1<<30;
	scanf("%d",&n);
	scanf("%s",ss+1);
	for(re int i=1;i<n;i++)
	{
		scanf("%d%d",&x,&y);
		addE(x,y);
	}
	for(re int i=1;i<=n;i++)
	{
		dfs(i,0);//printf("**%d %d %d\n",i,f[i],mi[i]);
		if(mi[i]==0)ans=min(ans,f[i]/2);
	}
	if(ans!=(1<<30))printf("%d\n",ans);
	else puts("-1");
}

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


int main(){
  int a,b,c,cnt=0;
  cin >> a >> b >> c;
  
  while(c > 0 && b >= a){
    cnt++;
    c--;
    b -= a;
  }
  cout << cnt << endl;
    
  }


Measured memory_bytes: 256
N,X,Y = map(int,input().split())
X-=1;Y-=1
ans = [0 for _ in range(N-1)]
for i in range(N):
  for j in range(i+1,N):
    direct = j-i
    shortcut = abs(X-i)+1+abs(Y-j)
    shortest = min(direct,shortcut)
    ans[shortest-1] += 1
print(*ans,sep="\n")

Measured memory_bytes: 9272
n,k=map(int,input().split())
X=[0]*10**5
for _ in range(n):
    a,b=map(int,input().split())
    X[a-1]+=b
cnt=0
for i in range(10**5):
    cnt+=X[i]
    if cnt>=k:
        print(i+1)
        break

Measured memory_bytes: 5748
#include <iostream>
#include <string>
#include <algorithm>
#include <functional>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <tuple>
#include <cstdio>
#include <cmath>
#define rep(i, n) for(i = 0; i < n; i++)
#define int long long
using namespace std;

signed main() {
	int a, b;
	cin >> a >> b;
	cout << a * b << endl;
	return 0;
}

Measured memory_bytes: 3624
#!/usr/bin/env python3

N, K = map(int, input().split())
N_list = [0]*N
A = []
cnt = 0

for _ in range(K):
    d = int(input())
    A = list(map(int, input().split()))
    for i in A:
        N_list[i-1] += 1

print(N_list.count(0))

Measured memory_bytes: 9180
#include <bits/stdc++.h>
#define debug(x) cerr << "\n" \
                      << #x << " = " << x << ".\n"
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
#define print(xx) cout << (xx) << endl
using namespace std;
#define int long long
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vint;
const int INF = ((1LL << 30) + (1LL << 29));
const ll MOD = 1000000007;

/* 

*/

//================== INPUT ========================
int N;
vector<int> A;
//=================================================
void input()
{
    cin >> N;
    A = vector<int>(N);
    rep(i, N)
    {
        cin >> A[i];
    }
}

//=================================================
void solve()
{
    vector<int> d;
    rep(i, N)
    {
        auto it = lower_bound(d.rbegin(), d.rend(), A[i]) ;// index
        if (it == d.rbegin())
        {
            d.push_back(A[i]);
        }
        else
        {
            --it;
            *it = A[i];
        }
    }
    cout << d.size() << endl;
}

//=================================================
signed main()
{
    input();
    solve();
    return 0;
}

Measured memory_bytes: 2168
#include"bits/stdc++.h"
#include<iostream>
using namespace std;
typedef long long ll;
typedef vector<int> vi;

int main(void) {
	int n;
	ll m = 0;

	cin >> n;

	for (int i = 1; i <= n; i++) {
		m += (n/i)*0.5*(2*i+(n/i-1)*i);
		//cout << m << endl;
	}

	cout << m << endl;

	return 0;
}

Measured memory_bytes: 3620
/*
    AUTHOR:hruday pabbisetty
    NIT ROURKElA(My_College_Sucks)
*/
#include <bits/stdc++.h>
using namespace std;
#define opt ios_base::sync_with_stdio(0)
#define lli long long int
#define ulli unsigned long long int
#define I int
#define S string
#define D double
#define rep(i,a,b) for(i=a;i<b;i++)
#define repr(i,a,b) for(i=a;i>b;i--)
#define in(n) scanf("%lld",&n)
#define in2(a,b) scanf("%lld %lld",&a,&b)
#define in3(a,b,c) scanf("%lld %lld %lld",&a,&b,&c)
#define out(n) printf("%lld",n)
#define inu(a) scanf("%lld",&a)
#define outu(a) printf("%llu",a)
#define ins(s) scanf("%s",&s)
#define outs(s) printf("%s",s)
#define nl printf("\n")
#define mod 1000000007
#define inf 100000000000000
typedef long long       ll;
typedef pair<lli,lli>  plli;
typedef vector<lli>     vlli;
typedef vector<ulli>    vulli;
typedef vector<ll>      vll;
typedef vector<string>  vs;
typedef vector<plli>     vplli;
#define MM(a,x)  memset(a,x,sizeof(a));
#define ALL(x)   (x).begin(), (x).end()
#define P(x)       cerr<<"{"#x<<" = "<<(x)<<"}"<<endl;
#define P2(x,y)       cerr<<"{"#x" = "<<(x)<<", "#y" = "<<(y)<<"}"<<endl;
#define P3(x,y,z)  cerr<<"{"#x" = "<<(x)<<", "#y" = "<<(y)<<", "#z" = "<<(z)<<"}"<<endl;
#define P4(x,y,z,w)cerr<<"{"#x" = "<<(x)<<", "#y" = "<<(y)<<", "#z" = "<<(z)<<", "#w" = "<<(w)<<"}"<<endl;
#define PP(x,i)     cerr<<"{"#x"["<<i<<"] = "<<x[i]<<"}"<<endl;
#define TM(a,b)     cerr<<"{"#a" -> "#b": "<<1000*(b-a)/CLOCKS_PER_SEC<<"ms}\n";
#define UN(v)    sort(ALL(v)), v.resize(unique(ALL(v))-v.begin())
#define mp make_pair
#define pb push_back
#define f first
#define s second
#define sz() size()
#define nl cout<<"\n"
#define MX1 100005
#define MX2 1000005

#define bs binary_search
#define lb lower_bound
#define ub upper_bound

lli power(lli a,lli b)
    {
    lli value;
    if(b==0)
        {
        return 1;
    }
    else if(b%2==0)
        {
        value=power(a,b/2)%mod;
        return(value*value)%mod;
    }
    else
        {
        value=power(a,b/2)%mod;
        return ((a*value)%mod*(value))%mod;
    }
}
int main()
{
      /*  #ifndef ONLINE_JUDGE
        freopen("input.txt","r",stdin);
        freopen("output.txt","w",stdout);
        #endif*/
    opt;
    lli n;
    cin>>n;
    lli fre[8],cnt=0;
    MM(fre,0);
    while(n--)
    {
        lli a;
        cin>>a;
        if(a<=399)
        {
            fre[0]++;
        }
        else if(a<=799)
        {
            fre[1]++;
        }
        else if(a<=1199)
        {
            fre[2]++;
        }
        else if(a<=1599)
        {
            fre[3]++;
        }
        else if(a<=1999)
        {
            fre[4]++;
        }
        else if(a<=2399)
        {
            fre[5]++;
        }
        else if(a<=2799)
        {
            fre[6]++;
        }
        else if(a<=3199)
        {
            fre[7]++;
        }
        else
        {
            cnt++;
        }
    }
        lli mini=0,maxi=-inf,i;
        rep(i,0,8)
        {
            if(fre[i])
            {
                mini++;
            }
        }
        maxi=cnt+mini;
        if(!mini)
        {
            mini=1;
        }

        cout<<mini<<" "<<maxi;

}


Measured memory_bytes: 256
//t秒間で初速V0, 最高速度Vm, 最終速度V1で走るときの最大の速度を求める
#include<bits/stdc++.h>
using namespace std;
using ll = long long;

double area(double v0, double v1, double vm, double t){
    double tp = (t + v1 - v0)/2.0;
    double vp = (t + v1 + v0)/2.0;
    if(vp > vm) {
        return vm * t - (vm - v0)*(vm - v0)/2.0 - (vm - v1)*(vm - v1)/2.0;
    }
    else {
        return vp*t - tp*tp/2.0 - (t - tp)*(t - tp)/2.0;
    }
}

int main()
{
    int N;
    cin >> N;
    int t[N+1], v[N+1];
    for(int i = 1; i <= N; ++i) cin >> t[i];
    for(int i = 1; i <= N; ++i) cin >> v[i];
    t[0] = 0; v[0] = 0;

    int kv[N+1]; // kv[i] -- 区間iが終わるときの終速度
    kv[0] = 0, kv[N] = 0;
    for(int i = 1; i < N; ++i) {
        kv[i] = min(kv[i-1] + t[i], min(v[i], v[i+1]));
    }
    for(int i = N-1; i > 0; --i) {
        kv[i] = min(kv[i+1] + t[i+1], kv[i]);
    }

    /*
    for(int i = 0; i <= N; ++i) cout << kv[i] << " ";
    cout << endl;
    */
    double res = 0;
    for(int i = 1; i <= N; ++i) {
        res += area(kv[i-1], kv[i], v[i], t[i]);
    }
    cout << fixed << setprecision(10) << res << endl;
    return 0;
}

Measured memory_bytes: 256
using System;
using System.IO;
using System.Linq;
using System.Numerics;
using System.Collections.Generic;
using System.Text;
using System.Text.RegularExpressions;
using static System.Math;
using Debug = System.Diagnostics.Debug;


static class P
{
    static void Main()
    {
        int n = int.Parse(Console.ReadLine());
        var d = Console.ReadLine().Split().Select(int.Parse).OrderBy(x => x).ToArray();
        var under = d.Take(n / 2).Last();
        var upper = d.Skip(n / 2).First();
        Console.WriteLine(upper - under);
    }
}


Measured memory_bytes: 22240
#include <stdio.h>

char win_choice(char op)
{
  char win;
  switch(op) {
  case 'r':
    win = 'p'; break;
  case 's':
    win = 'r'; break;
  case 'p':
    win = 's'; break;
  }
  return win;
}

int get_point(char me, int r, int s, int p)
{
  switch(me) {
  case 'r':
    return r;
  case 's':
    return s;
  case 'p':
    return p;
  }
  return 0;
}

int main(void)
{
  int n, k;
  int r, s, p;
  char info[100000];
  char choice[10000] = {0};
  char me, op;
  int points = 0;

  
  scanf("%d %d", &n, &k);
  scanf("%d %d %d", &r, &s, &p);
  scanf("%s", info);

  for(int i = 0; i < n; i++) {
    choice[i] = win_choice(info[i]);
    if(i >= k && choice[i] == choice[i - k]) {
      choice[i] = 'n';
    }
    points += get_point(choice[i], r, s, p);
  }
  printf("%d\n", points);
  
  return 0;
}


Measured memory_bytes: 256
n=int(input())
ki=[[] for _ in range(n)]
for i in range(n-1):
  a,b=map(int,input().split())
  ki[a-1].append(b-1)
  ki[b-1].append(a-1)
fe=[0]*n
sn=[0]*n
from collections import deque
d=deque()
d.append(0)
visited=[False]*n
visited[0]=True
while d:
  g=d.popleft()
  for i in ki[g]:
    if visited[i]:
      continue
    d.append(i)
    visited[i]=True
    fe[i]=fe[g]+1
d=deque()
d.append(n-1)
visited=[False]*n
visited[n-1]=True
while d:
  g=d.popleft()
  for i in ki[g]:
    if visited[i]:
      continue
    d.append(i)
    visited[i]=True
    sn[i]=sn[g]+1
x=0
for i in range(n):
  if fe[i]>sn[i]:
    x+=1
  else:
    x-=1
print('Fennec' if x<0 else 'Snuke')

Measured memory_bytes: 30112
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        
        Scanner sc = new Scanner(System.in);
        int n;
        String s,ans="No";
        StringBuilder sbs = new StringBuilder();
        StringBuilder sbh1 = new StringBuilder();
        StringBuilder sbh2 = new StringBuilder();
        
        s = sc.nextLine();
        n = s.length();
        String firstHalf = s.substring(0, (n-1) / 2);
        String secondHalf = s.substring((n+3) / 2 - 1, n);
        
        sbs.append(s);
        sbh1.append(firstHalf);
        sbh2.append(secondHalf);
        
        if(s.equals(sbs.reverse().toString())){
            if(firstHalf.equals(sbh1.reverse().toString())){
                if(secondHalf.equals(sbh2.reverse().toString())){
                    ans = "Yes";
                }
            }
        }
        
        System.out.println(ans);
    }
}


Measured memory_bytes: 23764
#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, x;
  cin >> n >> x;
  int m[n];
  for(int i = 0; i < n; i++) {
    cin >> m[i];
    x -= m[i];
  }
  sort(m, m + n);
  n += x / m[0];
  cout << n << endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int n, a, c[100009];
int main()
{

  	cin >> n;
	
  	for (int i = 0; i < n; i++) cin >> a, c[a]++;
	
  	int ret = 0;
	
  	for (int i = 0; i <= 100000; i++) ret = max(ret, c[i] + c[i + 1] + c[i + 2]);
	
  	cout << ret << endl;
	
  	return 0;
}

Measured memory_bytes: 640
N,P=map(int,input().split())
D=dict()
k=2
Q=P
while(True):
    if k*k>P:
        break
    if Q%k==0:
        if k in D:
            D[k]+=1
        else:
            D[k]=1
        Q=Q//k
    else:
        k+=1
D[Q]=1
ans=1
for p in D:
    ans=ans*(p**(D[p]//N))
print(ans)


Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> l_l;
typedef pair<int , int> i_i;
typedef vector<ll> vel;
typedef vector<int> vei;
typedef vector<char> vec;
typedef vector<bool> veb;
typedef vector<string> ves;
typedef vector<vector<ll>> ve_vel;
typedef vector<vector<int>> ve_vei;
typedef vector<vector<char>> ve_vec;
typedef vector<vector<bool>> ve_veb;
typedef vector<vector<string>> ve_ves;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep1(i,n) for(int i=1;i<(int)(n);i++)
#define rep2(i,n) for(int i=2;i<(int)(n);i++)
#define repk(i,k,n) for(int i=k;i<(int)(n);i++)
#define fs first
#define sc second
#define pub push_back
#define puf push_front
#define pob pop_back
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define maxel(a) *max_element(all(a))
#define minel(a) *min_element(all(a))
#define acc accumulate
#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
#define mod (1000000007)
#define show(x) cout << #x << " = " << x << endl
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return 1; } return 0; }

#define MAX_N 200050
ll par[MAX_N+1]; //親
ll ran[MAX_N+1]; //木の深さ

//n要素で初期化
void init(int n) {
    rep(i,n) {
		par[i] = i;
		ran[i] = 0;
	}
}

//木の根を求める
int find(int x) {
	if(par[x] == x) return x;
	else return par[x] = find(par[x]);
}

//x,yの属する集合の併合
void unite(int x, int y) {
	x = find(x); y = find(y);
	if(x == y) return ;

	if(ran[x] < ran[y]) par[x] = y;
	else {
		par[y] = x;
		if(ran[x] == ran[y]) ran[x]++;
	}
}

//x,yが同じ集合の属するか
bool same(int x, int y) {
	return find(x) == find(y);
}



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

  int N, M; cin >> N >> M;

  init(200020);

  rep(i,N) {
    int K; cin >> K;
    rep(j,K) {
      int L; cin >> L; L += 100005;
      unite(i, L);
    }
  }
  rep(i,N-1) {
    if(!same(i, i + 1)) {cout << "NO" << endl; return 0;}
  }
  cout << "YES" << endl;
  return 0;
}



Measured memory_bytes: 3328
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int mod = 1000000007;
#define pi 3.14159265358979

int main()
{
	string s;
	cin >> s;
	if(s=="AAA" || s=="BBB" ) {
		cout <<"No"<<endl;
	} else{
		cout << "Yes" << endl; 
	}
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
long long gcd(long long a,long long b){
  return b?gcd(b,a%b):a;
}

int main(){
  int n;
  while(1){
    cin >> n;
    if(n==0) break;
    long long d[10],v[10];
    for(int i=0;i<n;i++){
      cin >> d[i] >> v[i];
   }
    long long d_all=d[0],v_all=v[0];
    for(int i=1;i<n;i++){
      d_all = ( d[i]*v_all / gcd(d_all*v[i], d[i]*v_all) ) * d_all;
    }
    for(int i=0;i<n;i++){
      cout << d_all * v[i] / v_all / d[i] << "\n";
   }
  }
}

Measured memory_bytes: 1164
def merge (A, left, mid, right):
    banpei = 10**9
    L = A[left:mid]  + [banpei]
    R = A[mid:right] + [banpei]
    i, j = 0, 0
    for k in range(left, right):
        if L[i] <= R[j]:
            A[k] = L[i]
            i += 1
        else:
            A[k] = R[j]
            j += 1
    global count
    count += right - left
 
def mergeSort(A, left, right):
    if left+1 < right:
        mid = (left + right) // 2
        mergeSort(A, left, mid)
        mergeSort(A, mid, right)
        merge(A, left, mid, right)

n = int(input())
A = list(map(int, input().split()))
count = 0
mergeSort(A, 0, len(A))
print(*A)
print(count)

Measured memory_bytes: 63796
//#pragma GCC optimize("Ofast,unroll-loops")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,tune=native")
#include<bits/stdc++.h>

using namespace std;

#define all(x) (x).begin(),(x).end()
#define I(x, a) for(auto x : (a))
#define ins insert
#define F(i, l, r) for(auto i = (l); i < (r); i++)
#define DF(i, l, r) for(auto i = (l); i >= (r); i--)
#define E(i, l, r) for(auto i = (l); i <= (r); i++)
#define pb push_back
#define X first
#define Y second
#define mp make_pair
#define ret return
#define brk break
#define cont continue
#define move fjgjgjgjghd

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

const int mod = (int)1e9 + 7;

int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	int n;
	cin >> n;
	string s;
	cin >> s;
	int cnt[30];
	fill(cnt, cnt + 30, 0);
	F(i, 0, n)cnt[s[i] - 'a']++;
	ll dp = 1;
	F(i, 0, 30){
		dp = dp * (cnt[i] + 1);
		dp %= mod;
	}
	--dp;
	dp += dp < 0 ? mod : 0;
	cout << dp << endl;
	return 0;
}


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

int main()
{
    int a, b, c, d;

    cin >> a >> b >> c >> d;

    if ( abs(a - c) <= d || (abs(a - b) <= d && abs(b - c) <= d)) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
   
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
const int N = 2e5 + 10, mod = 998244353;
vector < string > rec(int n){
	vector < string > ans;
	if(n == 1){
		ans.push_back("a");
		return ans;
	}
	vector < string > prev = rec(n - 1);
	bool f[n + 1];
	for(int i = 0; i < prev.size(); i++){
		memset(f, 0, sizeof f);
		for(int j = 0; j < prev[i].size(); j++){
			f[prev[i][j] - 'a'] = 1;
		}
		int last = 0;
		for(int j = 0; j < n; j++){
			if(f[j]){
				ans.push_back(prev[i] + char(j + 'a'));
				last = j;
			}
		}
		ans.push_back(prev[i] + char(last + 1 + 'a'));
	}
	return ans;
}
int main(){
	ios::sync_with_stdio(0);
	cin.tie(0); cout.tie(0);
	int n, m;
	cin >> n; 
	vector < string > ans = rec(n);
	sort(ans.begin(), ans.end());
	for(int i = 0; i < ans.size(); i++){
		cout << ans[i] << endl;
	}
	
}

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

//#define int long long
#define ll long long
#define all(v) (v).begin(), (v).end()
#define rep(i,n) for(int i=0;i<n;++i)
#define rep1(i,n) for(int i=1;i<n;++i)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define EPS (1e-7)
#define gearup ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
typedef pair<ll, ll> P;
typedef vector<ll> vl;
typedef vector<vector<ll> > vvl;
typedef vector<vector<vector<ll> > > vvvl;
ll MOD = 1000000007;
const long long L_INF = 1LL << 60;
const int INF = 2147483647; // 2^31-1
const double PI = acos(-1);
//cout<<fixed<<setprecision(10);

template<class T> inline bool chmin(T& a, T b) {if (a > b) {a = b;return true;}return false;}
template<class T> inline bool chmax(T& a, T b) {if (a < b) {a = b;return true;}return false;}
template<class T> void debug(T v){rep(i,v.size()) cout<<v[i]<<" ";cout<<endl;}
const ll dx[8] = {1, 1, 0, -1, -1, -1, 0, 1};
const ll dy[8] = {0, 1, 1, 1, 0, -1, -1, -1};

int is_sum(int sum){
    int res = 0;
    while(sum > 0){
        res += sum%10;
        sum/=10;
    }
    return res;
}
signed main()
{   
    gearup;
    int n,a,b;cin>>n>>a>>b;
    ll res = 0;
    rep1(i,n+1){
        int m = is_sum(i);
        if(m>=a && m<=b)res+=i;
    }
    cout << res << endl;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);


        int r = sc.nextInt() * 100;
        int g = sc.nextInt() * 10;
        int b = sc.nextInt();

        if ((r + g + b) % 4 == 0) {
            System.out.println("YES");
        } else {
            System.out.println("NO");
        }

    }
}

Measured memory_bytes: 35532
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt(); //N枚の AtCoder せんべい
        int K = sc.nextInt(); //K人の AtCoder 参加者
        if (N % K == 0)
            System.out.println(0);
        else
            System.out.println(1);
        sc.close();
    }
    
}


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

int main() {
    int n;
    cin >> n;
    for(int i = 0; i < n; i++) {
        int a;
        cin >> a;
        if(a % 2 == 0 && a % 3 && a % 5) {
            cout << "DENIED" << endl;
            return 0;
        }
    }
    cout << "APPROVED" << endl;
    return 0;
}


Measured memory_bytes: 256
#include<iostream>

using namespace std;

int main(void){

  long long n,a,b;
  cin >> n >> a >> b;

  if(b-a < 0){
    cout << 0 << endl;
    return 0;
  }

  if(b-a == 0 && n == 1){
    cout << 1 << endl;
    return 0;
  }

  if(b-a > 0 && n == 1){
    cout << 0 << endl;
    return 0;
  }

  cout << (b-a)*(n-2) + 1 << endl;
  
  return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;
public class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int[] ten;
        int n = sc.nextInt();

        ten = new int[n];
        for(int i=0;i<n;i++){
            ten[i] = sc.nextInt();
        }
        for(int i=n-1;i>=0;i--){
            System.out.print(ten[i]);
            if(i != 0){
                System.out.print(" ");
            }
        }
        System.out.print("\n");
    }
}


Measured memory_bytes: 26296
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace abc085b {
    class Program {
        static void Main(string[] args) {
            var N = int.Parse(Console.ReadLine());
            var mochi = new List<int>();
            for(var i = 0; i != N; ++i) mochi.Add(int.Parse(Console.ReadLine()));
            Console.WriteLine(mochi.Distinct().Count());
        }
    }
}


Measured memory_bytes: 13268
#include <iostream>
#include <string>
#include<math.h>
using namespace std;

int N;
int a[10000];
int flag;
int counter=0;
int num;
int k=0;

void solove()
{
    while(flag!=2)
    {
        flag=0;
        for(int i=k;i<N;i++)
        {
            if(a[i]%2==0)
            {
                a[i]=a[i]/2;
                k = i;
                flag=1;
                break;
            }
        }
        for(int j=0;j<N;j++)
        {
            if(j!=k)
            {
                a[j]=a[j]*3;
            }
        }
        if(flag==0)
        {
            flag=2;
        }
        counter++;
    }
}

int main()
{
    cin >> N;
    for(int i=0;i<N;i++)
    {
        cin >> a[i];
    }
    solove();
    cout << counter-1 << endl;
    
}

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

const int INF = 1001001001;

int main() {
  int n, m, a, b;
  cin >> n >> m;
  vector<vector<int>> to(n);
  rep(i, m) {
    cin >> a >> b;
    a--, b--;
    to[a].push_back(b);
    to[b].push_back(a);
  }

  queue<int> q;
  vector<int> dist(n, INF);
  vector<int> pre(n, -1);
  dist[0] = 0;
  q.push(0);
  while (!q.empty()) {
    int v = q.front();
    q.pop();
    for (int u : to[v]) {
      if (dist[u] != INF) continue;
      dist[u] = dist[v] + 1;
      pre[u] = v;
      q.push(u);
    }
  }

  cout << "Yes" << endl;
  rep(i, n) {
    if (i == 0) continue;
    cout << pre[i] + 1 << endl;
  }
  return 0;
}


Measured memory_bytes: 10552
#
# 　　  ⋀_⋀　 
#　　  (･ω･)  
# .／ Ｕ ∽ Ｕ＼
#  │＊　合　＊│
#  │＊　格　＊│ 
#  │＊　祈　＊│ 
#  │＊　願　＊│ 
#  │＊　　　＊│ 
#      ￣
#
import sys
sys.setrecursionlimit(10**6)
input=sys.stdin.readline
from math import floor,ceil,sqrt,factorial,log #log2ないｙｐ
from heapq import heappop, heappush, heappushpop
from collections import Counter,defaultdict
from itertools import accumulate,permutations,combinations,product,combinations_with_replacement
from bisect import bisect_left,bisect_right
from copy import deepcopy
inf=float('inf')
mod = 10**9+7
def INT_(n): return int(n)-1
def MI(): return map(int,input().split())
def MF(): return map(float, input().split())
def MI_(): return map(INT_,input().split())
def LI(): return list(MI())
def LI_(): return [int(x) - 1 for x in input().split()]
def LF(): return list(MF())
def LIN(n:int): return [I() for _ in range(n)]
def LLIN(n: int): return [LI() for _ in range(n)]
def LLIN_(n: int): return [LI_() for _ in range(n)]
def LLI(): return [list(map(int, l.split() )) for l in input()]
def I(): return int(input())
def F(): return float(input())
def ST(): return input().replace('\n', '')
def main():
    N = I()
    ans = ((N-1)*N//2) 
    print(ans)
if __name__ == '__main__':
    main()

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

int main(){
	string s;
	cin>>s;
	int A=0,Z=s.size()-1;
	while(s[A]!='A')A++;
	while(s[Z]!='Z')Z--;
	cout<<Z-A+1<<endl;
}











/*

#include<iostream>
#include<vector>
#include<string>
#include<algorithm>	
#include<map>
#include<set>
#include<utility>
#include<cmath>
#include<cstring>
#include<queue>
#include<stack>
#include<cstdio>
#include<sstream>
#include<iomanip>
#include<assert.h>
#define loop(i,a,b) for(int i=a;i<b;i++) 
#define rep(i,a) loop(i,0,a)
#define pb push_back
#define mt make_tuple
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)
using namespace std;
//kaewasuretyuui
typedef long long ll;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<pii> vp;
typedef vector<vp> vvp;
typedef vector<string> vs;
typedef vector<double> vd;
typedef tuple<int,int,int> tp;
typedef vector<tp> vt;
typedef vector<vd> vvd;
typedef pair<int,pii> pip;
typedef vector<pip>vip;
const double PI=acos(-1);
const double EPS=1e-7;
const int inf=1e8;
const ll INF=2e18;
int dx[]={0,1,0,-1};
int dy[]={1,0,-1,0};
int main(){
}





*/





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

using namespace std;
const int N=3055;
double a[N];
double dp[N][N];
int n;

double bt(int i , int j)
{
    if(i==n)
    {
        if(j>n-j)
            return 1;
        return 0;
    }
    if(dp[i][j]!=-1)
        return dp[i][j];
    double ret=a[i]*bt(i+1,j+1);
    ret+=(1-a[i])*bt(i+1,j);
    dp[i][j]=ret;
    return ret;
}

int main()
{
    for(int i=0;i<N;i++)
        for(int j=0;j<N;j++)
            dp[i][j]=-1;
    cin>>n;
    for(int i=0;i<n;i++)
    {
        cin>>a[i];
    }
    cout<<fixed<<setprecision(9)<<bt(0,0)<<endl;;
    return 0;
}


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


int main (void){
    ll n, a, b, c, d, e;
    cin >> n >>a>>b>>c>>d>>e;
    ll m = min({a, b, c, d, e});

    ll sum = (n+m-1)/m;
    

    sum += 4;

    cout << sum << endl;
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<queue>
#include<string>
#include<cmath>
#include<cstdio>
#include<cctype>
#include<cstring>
#include<iomanip>
#include<cstdlib>
#include<ctime>
#include<set>
#include<map>
#include<utility>
#include<vector>
#include<stack>
#include<sstream>
#include<algorithm>
using namespace std;
/****************************/
#define ll long long
#define vi vector<int>
#define pii pair<int,int>
#define vpii vector<pair<int,int> >
#define qi queue<int>
#define mii map<int,int>
#define msi map<string,int>
#define vs vector<string>
#define vc vector<char>
/****************************/
#define rep(i,n) for(ll i=0;i<(n);i++)
#define rep2(i,n) for(ll i=(n)-1;i>=0;i--)
#define rep3(i,a,n) for(ll i=(a);i<(n);i++)
#define rep4(i,a,n) for(ll i=(n)-1;i>=a;i--)
#define mp make_pair
#define pb push_back
#define st first
#define nd second
#define pi 3.1415926535897932384626433832795
#define zero(n) memset(n,0,sizeof(n));
#define SZ(n) n.size()
#define mod 1000000007
#define INF 1000000000000000000
/****************************/
int a[2010];
int n;
ll ans=0;
int main()
{
	cin>>n;
	rep(i,n)
	{
		cin>>a[i];
	}
	sort(a,a+n);
	ans=0;
	rep(i,n)
	{
		rep3(j,i+1,n)
		{
			int l=j+1;
			int r=n-1;
			while(l<=r)
			{
				int mid=l+r>>1;
				if(a[i]+a[j]>a[mid])
				{
					l=mid+1;
				}
				else
				{
					r=mid-1;
				}
			}
			ans+=l-j-1;
		 }
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i,n) for (int i=0; i<(n); ++i)
#define repi(i,a,b) for(int i=int(a);i<int(b);++i)
using namespace std;
typedef long long ll;
#include<bits/stdc++.h>
using namespace std;
int main(){
  string s;
  cin >> s;
  string s2 = s.substr(5,2);
  if(atoi(s2.c_str()) <= 4){
    cout << "Heisei" << endl;
  }else{
    cout << "TBD" << endl;
  }
  return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;
public class Main{
    public static void main(String[] args){
        Scanner scanner = new Scanner(System.in);
        int a_integer_value = scanner.nextInt();
        int b_integer_value = scanner.nextInt();
        if (a_integer_value<b_integer_value){
            System.out.println("a < b");
        }else if(a_integer_value>b_integer_value){
            System.out.println("a > b");
        }else{
            System.out.println("a == b");
        }
    }
}


Measured memory_bytes: 26244
//#include <bits/stdc++.h>
#include <iostream>
#include <vector>
#include <algorithm>
#include <climits>
#include <iomanip>

using namespace std;

#define FAST       			ios_base :: sync_with_stdio(false); cin.tie(NULL); 
#define endl "\n"

typedef long long int  ll;

int maxSum = INT_MIN;
void max1(int i , int n , int cost[] , int gem[] , int prevCost , int prevGem)
{
	if(i == n)
	{
		maxSum = max(maxSum , prevGem-prevCost);
		return;
	}

	max1(i+1 , n , cost , gem , cost[i]+prevCost , gem[i]+prevGem);
	max1(i+1 , n , cost , gem , prevCost , prevGem);
}

int main()
{
	FAST;
	int n;
	cin >> n;
	int gem[21];
	int cost[21];

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

	max1(0 , n , cost , gem , 0 , 0);

	cout << maxSum;
	return 0;
}

Measured memory_bytes: 256
# coding: utf-8
# Your code here!

n = int(input())
p = list(map(int, input().split()))
count = 0
for i in range(1, n-1):
    if((p[i]<p[i-1])&(p[i]>p[i+1])):
        count +=1
    elif((p[i]>p[i-1])&(p[i]<p[i+1])):
        count +=1
print(count)

Measured memory_bytes: 3060
#include <cstdio>
#include <vector>
#include <algorithm>
#include <utility>
#include <queue>
using namespace std;

typedef pair<int,int> pii;

int solve(int n, int m, int L, int k){
	int mask = (1 << L) - 1;
	vector<vector<pii> > G(n + 1);
	vector<int> bf(n + 1);
	int start, goal, u, v, c, b;
	for(int i = 0; i < m; ++i){
		scanf("%d%d%d", &u, &v, &c);
		G[u].push_back(pii(c, v));
		G[v].push_back(pii(c, u));
	}

	scanf("%d%d", &start, &goal);
	G[0].push_back(pii(0, start));
	goal = goal << L | mask;

	for(int i = 0; i < L; ++i){
		scanf("%d", &b);
		bf[b] |= 1 << i;
	}

	priority_queue<pii> pq;
	pq.push(pii(0, 0));
	vector<int> use((n + 1) << L);
	while(!pq.empty()){
		int d = pq.top().first;
		int st = pq.top().second;
		pq.pop();
		if(++use[st] > k){ continue; }
		if(use[goal] == k){
			return -d;
		}
		
		int p = st >> L;
		int b = st & mask;
		
		for(size_t i = 0; i < G[p].size(); ++i){
			int np = G[p][i].second;
			int nd = d - G[p][i].first;
			int nb = b | bf[np];
			int nst = np << L | nb;
			if(use[nst] < k){
				pq.push(pii(nd, nst));
			}
		}
	}

	return -1;
}

int main(){
	int n, m, L, k;
	while(scanf("%d%d%d%d", &n, &m, &L, &k), n){
		int ans = solve(n, m, L, k);
		printf(ans < 0 ? "NA\n" : "%d\n", ans);
	}
}

Measured memory_bytes: 27780
#include <stdio.h>
#include<ctype.h>
#include<string.h>
int main(void)
{
	int i,n;
	char str[1200];
	gets(str);
	n=strlen(str);
	for(i=0;i<n;i++){
		if(isalpha(str[i])){
		     if(isupper(str[i]))
		     printf("%c",tolower(str[i]));
		     else 
		     printf("%c",toupper(str[i]));
		}
		else{
			printf("%c",str[i]);
		}
		
	}
	printf("\n");
	return 0;
}

Measured memory_bytes: 524
#include <iostream>
using namespace std;
int main(){
  int NUM = 1000000;
  bool prime[NUM];
  prime[0] = false;prime[1] = false;
  for(int i=2;i<NUM;i++)prime[i] = true;
  for(int i=2;i*i<NUM;i++)
    for(int k=2;i*k<NUM;k++)
      prime[i*k]=false;
  int n,c,i;
while(cin>>n){
for(c=0,i=0;i<=n;i++)if(prime[i])c++;
cout<<c<<endl;}}

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

	using namespace std;

	#define ll long long

	int n, w;
	ll dp[100001][101];
	int v[100001][101];
	int v1[1000];
	int w1[1000];
	ll s1(int wr, int i){
		if(wr<0){
			return INT_MIN;
		}
		if(i==-1){
			return 0;
		}
		if(v[wr][i]){
			return dp[wr][i];
		}
		v[wr][i]=1;

		dp[wr][i] = max(s1(wr-w1[i], i-1)+v1[i], s1(wr, i-1));
		return dp[wr][i];
	}

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

		cin>>n>>w;
		for(int i=0; i<n; i++){
			cin>>w1[i]>>v1[i];
		}

		cout<<s1(w, n-1);
	}

Measured memory_bytes: 118400