akhauriyash/Code-Regression huggingface dataset:
#include <stdio.h>
#include <vector>
#include <algorithm>
using namespace std;
long long rui[12];
long long x, y, z, n;
vector<long long>k[10];
long long d[300000];
int main() {
	rui[0] = 1;
	for (int i = 1; i < 12; i++)rui[i] = 10 * rui[i - 1];
	for (int i = 0; i < 10; i++) {
		k[0].push_back(i);
	}
	for (int i = 1; i < 10; i++) {
		for (int j = 0; j < k[i - 1].size(); j++) {
			x = k[i - 1][j];
			y = x / rui[i - 1];
			k[i].push_back(y * rui[i] + x);
			if (y > 0) {
				k[i].push_back((y - 1) * rui[i] + x);
			}
			if (y < 9) {
				k[i].push_back((y + 1) * rui[i] + x);
			}
		}
	}
	for (int i = 0; i < 10; i++) {
		for (int j = 0; j < k[i].size(); j++) {
			if (k[i][j] >= rui[i]) {
				d[z] = k[i][j];
				z++;
			}
		}
	}
	sort(d, d + z);
	scanf("%lld", &n);
	printf("%lld\n", d[n - 1]);
}

Measured memory_bytes: 4656
#include <bits/stdc++.h>
using namespace std;
using ll = long long int;
using str = string;
using P = pair<int, int>;
using Pll = pair<ll, ll>;
const double PI = 3.141592653589793238;
const ll mod = 1000000007;
#define rep(i, n) for (int i = 0; i < (int)n; i++)
#define REP(i, m, n) for (int i = m; i < (int)n; i++)
#define all(a) (a).begin(), (a).end()
#define allg(a) (a).begin(), (a).end(), greator<>()
#define d20 std::setprecision(20)
#define veci vector<int>
#define vecll vector<long long int>
#define vecb vector<bool>
#define vecd vector<double>
template <typename T>
T lcm(T a, T b)
{
	return a / __gcd(a, b) * b;
}
void comb(vector<vector<long long int>> &v)
{
	for (size_t i = 0; i < v.size(); i++)
	{
		v[i][0] = 1;
		v[i][i] = 1;
	}
	for (size_t k = 1; k < v.size(); k++)
	{
		for (size_t j = 1; j < k; j++)
		{
			v[k][j] = (v[k - 1][j - 1] + v[k - 1][j]);
		}
	}
}
ll repeat_squaring(ll n, ll p, ll m)
{
	if (p == 0)
		return 1;
	if (p % 2 == 0)
	{
		ll t = repeat_squaring(n, p / 2, m);
		return t * t % m;
	}
	return n * repeat_squaring(n, p - 1, m);
}

int main()
{
	int n;
	ll sum = 0;
	cin >> n;
	veci time(n);
	rep(i, n)
	{
		cin >> time[i];
		sum += time[i];
	}
	int m;
	cin >> m;
	vector<P> pairs(m);
	rep(i, m)
	{
		int num, post;
		cin >> num >> post;
		num--;
		pairs[i] = make_pair(num, post);
	}
	rep(i, m)
	{
		cout << sum - time[pairs[i].first] + pairs[i].second << endl;
	}
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#define r(i,n) for(int i=0; i<n; i++)
using namespace std;
int main(void){
  int n, m;
  int a, b;
  cin >> n >> m;
  vector<bool> a1(n,false);
  vector<bool> an(n,false);

  r(i,m){
    cin >> a >> b;
    if(a>b){
      swap(a,b);
    }
    if(a==1){
      a1[b]=true;
    }
    if(b==n){
      an[a]=true;
    }
  }

  r(i,n){
    if(a1[i] && an[i]){
      cout << "POSSIBLE" << endl;
      return 0;
    }
  }
  cout << "IMPOSSIBLE" << endl;
  return 0;
}


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

using namespace std;
typedef long long ll;
typedef long double ld;
#define pb push_back



int main(){
    string p;
    cin >> p;
    int n=0;
    int s=0;
    int e=0;
    int w=0;
    for(int i=0;i<p.size();i++){
        if(p[i]=='N'){
            n=1;
        }else if(p[i]=='W'){
            w=1;
        }else if(p[i]=='S'){
            s=1;
        }else{
            e=1;
        }
    }

    int x=n+w+s+e;

    if(x==4){
        cout << "Yes" << endl;
    }else if(x==3){
        cout << "No" << endl;
    }else if(x==1){
        cout << "No" << endl;
    }else{
        if(n==s&&w==e){
            cout << "Yes" << endl;
        }else{
            cout << "No" << endl;
        }
    }
    return 0;
}


Measured memory_bytes: 256
n = $stdin.readline.to_i

(1..n).each do |i|
  if i % 3 == 0
    print " "
    print i
    next
  end

  x = i
  while true
    if x % 10 == 3
      print " "
      print i
      break
    end

    x /= 10
    if x == 0
      break
    end
  end
end

puts



Measured memory_bytes: 6872
#include<iostream>
using namespace std;
int main(){
	int n,a[25],num=0,x=0;
	cin>>n;
	for(int i=1;i<=n;i++)
	{
		cin>>a[i];
		if(a[i]>=x)num++,x=a[i];	
	}
	cout<<num;
	return 0;
}

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

using namespace std;

#define _overload3(_1,_2,_3,_4,name,...) name
#define _rep(i,n) _repi(i,0,n)
#define _repi(i,a,b) for(int i=a, i##_len=(b); i<i##_len; ++i)
#define _repis(i,a,b,s) for(int i=a, i##_len(b); i<i##_len; i+=s)
#define REP(...) _overload3(__VA_ARGS__,_repis,_repi,_rep,)(__VA_ARGS__)

#define REPR(i, n) for(int i = n;i >= 0;--i)
#define REPARR(i, v) for(int i = 0;i < v.size();++i)

#define YES(n) cout<<((n)?"YES":"NO")<<endl
#define Yes(n) cout<<((n)?"Yes":"No")<<endl
#define yes(n) cout<<((n)?"yes":"no")<<endl
#define poss(n) cout<<((n)?"possible":"impossible")<<endl
#define Poss(n) cout<<((n)?"Possible":"Impossible")<<endl
#define POSS(n) cout<<((n)?"POSSIBLE":"IMPOSSIBLE")<<endl

int main(){
    string s;
    int stat=0;
    cin>>s;
    REPARR(i,s){
        if(s[i]=='C'&&stat==0){
            stat=1;
        }else if(s[i]=='F'&&stat==1){
            stat=2;
            break;
        }
    }
    Yes(stat==2);
    return 0;
}


Measured memory_bytes: 256
import sys
input = sys.stdin.readline
import numpy as np
from numba import njit


def read():
    N, K = map(int, input().strip().split())
    A = np.fromstring(input().strip(), dtype=np.int32, sep=" ")
    return N, K, A


@njit
def solve(N, K, A):
    d = np.empty(N+1, dtype=np.int32)

    for k in range(K):
        for i in range(N):
            d[i] = 0
        
        for i in range(N):
            l = max(0, i-A[i])
            r = min(N, i+1+A[i])
            d[l] += 1
            d[r] -= 1
        
        terminate = True
        v = 0
        for i in range(N):
            v += d[i]
            A[i] = v
            if terminate and A[i] < N:
                terminate = False
        if terminate:
            break
    return A


if __name__ == '__main__':
    inputs = read()
    outputs = solve(*inputs)
    print(*outputs)


Measured memory_bytes: 120808
import sys
import math
import re
import io

def query(n, m):
    ans = 0
    while n > 0:
        ans += n // m
        n //= m
    return ans

def solve(n):
    if n < 2:
        return 0
    if n % 2 == 0:
        return query(n // 2, 5)
    return 0

def main():
    n = int(input())
    ans = solve(n)
    print(ans)

if __name__ == "__main__":
    main()


Measured memory_bytes: 3188
C = Hash.new{|h, k| h[k] = 0}
gets.to_i.times{ C[gets.chomp] += 1}
gets.to_i.times{ C[gets.chomp] -= 1}

ans = C.max_by{|k, v| v}

puts ans[1] > 0 ? ans[1] : 0


Measured memory_bytes: 1788
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
constexpr ll MOD = 1000000007;
#define REP(i, n) for (ll i = 0; i < (n); i++)
#define REP2(i, x, n) for (ll i = x; i < (n); i++)
const long long INF = numeric_limits<long long>::max();
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;
}

string func(ll N, ll Y)
{

    for (ll i = 0; i <= N; ++i)
    {
        ll iAmount = 10000 * i;
        for (ll j = 0; j <= (N-i); ++j)
        {
            ll jAmount = 5000 * j;
            ll k = N - (i + j);
            if ( k < 0 )    continue;
            if (iAmount + jAmount + 1000 * k == Y)
            {

#ifdef SOURCE_TEST
                cout << N << " " << Y << endl;
                cout << i + j + k << endl;
                cout << i * 10000 + j * 5000 + k * 1000 << endl;
#endif
                return to_string(i) + " " + to_string(j) + " " + to_string(k);
            }
        }
    }

    return "-1 -1 -1";
}
int main()
{
    ll N, Y;
    cin >> N >> Y;

    cout << func(N, Y) << endl;

    return 0;
}

Measured memory_bytes: 3676
#include<bits/stdc++.h>
#define MAXN 100005
#define INF 1000000
using namespace std;
struct edge{int to,cap,rev;};
int n,a[MAXN],b[MAXN];
vector<edge> G[MAXN];
int level[MAXN];
int iter[MAXN];
void add_edge(int from,int to,int cap)
{
    G[from].push_back((edge){to,cap,(int)G[to].size()});
    G[to].push_back((edge){from,0,(int)G[from].size()-1});
}
void bfs(int s)
{
    memset(level,-1,sizeof(level));
    queue<int> que;
    level[s]=0;
    que.push(s);
    while(!que.empty())
    {
        int v=que.front(); que.pop();
        for(int i=0;i<(int)G[v].size();i++)
        {
            edge &e=G[v][i];
            if(e.cap>0&&level[e.to]<0)
            {
                level[e.to]=level[v]+1;
                que.push(e.to);
            }
        }
    }
}

int dfs(int v,int t,int f)
{
    if(v==t) return f;
    for(int &i=iter[v];i<(int)G[v].size();i++)
    {
        edge &e=G[v][i];
        if(level[v]<level[e.to]&&e.cap>0)
        {
            int d=dfs(e.to,t,min(f,e.cap));
            if(d>0)
            {
                e.cap-=d;
                G[e.to][e.rev].cap+=d;
                return d;
            }
        }
    }
    return 0;
}
int max_flow(int s,int t)
{
    int flow=0;
    for(;;)
    {
        bfs(s);
        if(level[t]<0) return flow;
        memset(iter,0,sizeof(iter));
        int f;
        while((f=dfs(s,t,INF))>0)
          flow+=f;
    }
}
int ida[MAXN],idb[MAXN],tot=0;
int main()
{
    scanf("%d",&n);
    for(int i=0;i<n;i++) scanf("%d",&a[i]);
    for(int i=0;i<n;i++) scanf("%d",&b[i]);
    memset(ida,-1,sizeof(ida));
    memset(idb,-1,sizeof(idb));
    for(int i=0;i<n;i++)
    {
        if(ida[i]==-1)
        {
            tot++;
            int now=i;
            while(ida[now]==-1)
            {
                ida[now]=tot;
                now=a[now];
            }
        }
    }
    for(int i=0;i<n;i++)
    {
        if(idb[i]==-1)
        {
            tot++;
            int now=i;
            while(idb[now]==-1)
            {
                idb[now]=tot;
                now=b[now];
            }
        }
    }
    int ans=n,s=tot+1,t=tot+2;
    for(int i=0;i<n;i++)
    {
        if(a[i]==i&&b[i]==i) ans--;
        else if(a[i]==i) add_edge(idb[i],t,1);
        else if(b[i]==i) add_edge(s,ida[i],1);
        else if(a[i]!=b[i]) add_edge(idb[i],ida[i],1);
        else
        {
            add_edge(idb[i],ida[i],1);
            add_edge(ida[i],idb[i],1);
        }
    }
    printf("%d\n",ans-max_flow(s,t));
    return 0;
}



Measured memory_bytes: 13440
#include <iostream>
#include <cmath>
using namespace std;
int main(){
  long long n, d;
  cin >> n >> d;
  int count=0;
  long long x[n],y[n];
  for(int i = 0; i < n; i++){
    cin >> x[i] >> y[i];
    if((max(x[i],y[i])-d)*(max(x[i],y[i])+d)<=-pow(min(x[i],y[i]),2))count++;
  }
  cout << count << endl;
  return 0;
}

Measured memory_bytes: 6768
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <map>
#include <set>
#include <vector>
#include <stack>
#include <queue>
#include <bitset>
#include <algorithm>
#include <numeric>
#include <functional>
using namespace std;

#define Rep(b, e, i) for(int i = b; i <= e; i++)
#define Repr(e, b, i) for(int i = e; i >= b; i--)
#define rep(n, i) Rep(0, n-1, i)
#define repr(n, i) Repr(n-1, 0, i)
#define all(v) (v).begin(), (v).end()
#define pb(v) push_back(v)
#define uniq(v) (v).erase(unique(all(v)),(v).end())
#define bitcnt(x) __builtin_popcount(x)
#define fst first
#define snd second
#define Pqaz(T) priority_queue<T,vector<T>,greater<T>>
#define Pqza(T) priority_queue<T>
#define ENJYU std::ios::sync_with_stdio(false);std::cin.tie(0);

typedef long long ll;
typedef pair<ll, ll> llP;
typedef pair<int, int> intP;

//vector の中身を出力
template <class T>ostream &operator<<(ostream &o,const vector<T>&v)
{o<<"{";for(int i=0;i<(int)v.size();i++)o<<(i>0?", ":"")<<v[i];o<<"}";return o;}

const int MAX = 200000;
const double PI = 3.14159265358979323846;
const double EPS = 1e-12;
const int INF = 1<<29;
const int MOD = 1000000007;

int dx4[4]={1,0,-1,0};
int dy4[4]={0,1,0,-1};
int dx8[8]={1,0,-1,1,-1,1,0,-1};
int dy8[8]={1,1,1,0,0,-1,-1,-1};

int dsum(int x) {
	int res = 0;
	while(x > 0) {
		res += x % 10;
		x /= 10;
	}
	return res;
}

void solve(void){
	int N;
	cin >> N;
	int ans = INF;
	Rep(1, N-1, i) {
		ans = min(ans, dsum(i)+dsum(N-i));
	}
	cout << ans << endl;
}

int main(void){
	solve();
	//cout << "yui(*-v・)yui" << endl;
	return 0;
}


Measured memory_bytes: 256
import sys

N = int(input())
A = list(map(int, input().split()))
B = list(map(int, input().split()))
C = list(map(int, input().split()))

Satis = 0

for i in range(N):

    Satis += B[A[i] - 1]

    if 0 < i:
        if A[i - 1] + 1 == A[i]:
            Satis += C[A[i - 1] - 1]

print(Satis)


Measured memory_bytes: 38384
#include <stdio.h>

int main()
{
    int n, max = -1000000, min = 1000000;
    long long sum = 0;
    
    scanf("%d", &n);
    
    int a;
    
    int i;
    
    for(i=0; i<n; i++){
        scanf("%d", &a);
        
        if(a<min){
            min = a;
        }
        if(max<a){
            max = a;
        }
        
        sum+=a;
    }
    
    printf("%d %d %lld\n", min, max, sum);
    
    return 0;
}

Measured memory_bytes: 600
#include <bits/stdc++.h>
#define all(x) (x).begin(), (x).end()
using namespace std;

int main()
{
    for (size_t i = 1;; i++) {
        int x;
        cin >> x;

        if (!x)
            break;

        printf("Case %zu: %d\n", i, x);
    }
}



Measured memory_bytes: 3048
#include <bits/stdc++.h>
#include <stdlib.h>
using namespace std;
typedef long long ll;

bool num[10];

bool check_keta(int x){
  while (x>0){
    if(!num[x%10]) return false;
    else x/=10;
  }
  return true;
}

int main() {
  int n,k;
  cin>>n>>k;
  for(int i=0;i<10;i++) num[i]=true;
  for(int i=0;i<k;i++){
    int d;
    cin>>d;
    num[d]=false;
  }
  for(int i=n;;i++){
    if(check_keta(i)){
      cout<<i<<endl;
      break;
    }
  }
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <cstring>
#include <string>
#include <cmath> 
#define ll long long

ll MOD=1e9+7;
ll a[100005];
using namespace std;

int main(){
	ll n;
	cin>>n;
	
	ll flag=1;//flag 
	ll ans=1;
	
	if(n%2==0){ // even number 
	
		for(ll i=0;i<n;i++){
			ll x;
			cin>>x;
			a[x]++;//a[7]++
			
		
			if(x>=n || x%2==0 || a[x]>2){ 
				flag=0;
				cout<<"0"<<endl;
				break;
			}
			
			//The correct situation 
			if(a[x]==1)
				ans=ans*2%MOD; // a * b %c == a%c * b%c 
		}
	} 
	
	else{ //odd 
	
		for(ll i=0;i<n;i++){
			ll x;
			cin>>x;
			a[x]++;
			
			
			if(x>=n || x%2==1 || a[0]>1 ||a[x]>2){
				flag=0;
				cout<<"0"<<endl;
				break;
			}
			
			//The correct situation
			if(x!=0 && a[x]==1)
				ans=ans*2%MOD;
		}
	}
	
	if(flag)
		cout<<ans<<endl;
	return 0;
}


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

using namespace std;
using int64 = long long;

constexpr int DEBUG = 0;

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

  int h, w, a, b;
  cin >> h >> w >> a >> b;
  for (int r = 0; r < h; r++) {
    for (int c = 0; c < w; c++) {
      if ((r < b && c < a) || (r >= b && c >= a)) {
        cout << "1";
      } else {
        cout << "0";
      }
    }
    cout << endl;
  }
}

Measured memory_bytes: 1280
N,M = map(int,input().split())
tmp = [0]*N

for _ in range(M):
  a,b = map(int,input().split())
  if a == 1:
    if tmp[b-1] == 1:
      print('POSSIBLE')
      exit()
    else:
      tmp[b-1] = 1
  elif b == N:
    if tmp[a-1] == 1:
      print('POSSIBLE')
      exit()
    else:
      tmp[a-1] = 1
print("IMPOSSIBLE")

Measured memory_bytes: 4596
#include<bits/stdc++.h>                
using namespace std;
#define ll long double

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

int main(){
	int n;     
	ll lcm1 = 1;
	cin >> n;
	vector<ll> v(n);
	for(int i = 0; i < n; i++){
		cin >> v[i];
		lcm1 = lcm(lcm1, v[i]);		
	}
	int diz = 0;
	for(int i = 0; i < n; i++){
		diz += lcm1 / v[i];
	}
	ll ans = lcm1 / diz;
	cout << fixed << ans << endl; 
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
long long n,s=0;
int main()
{
    cin>>n;
    int a[3*n+1];
    for(int i=1;i<=n*3;i++)
    cin>>a[i];
    sort(a+1,a+1+3*n);
    for(int i=n*3-1;i>=n+1;i-=2)
    s+=a[i];
    cout<<s;
}

Measured memory_bytes: 1408
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace ConsoleApplication3
{
    class Program
    {
        static void Main(string[] args)
        {
            while (true)
            {
                var HW = Console.ReadLine().Split().Select(int.Parse).ToArray();
                var H = HW[0];
                var W = HW[1];
                if (H == 0)
                    break;
                foreach(var i in Enumerable.Range(0,W-1))
                {
                    Console.Write("#");
                }
                Console.WriteLine("#");
                foreach (var i in Enumerable.Range(0, H-2))
                {
                    Console.Write("#");
                    foreach (var j in Enumerable.Range(0, W - 2))
                    {
                        Console.Write(".");
                    }
                    Console.WriteLine("#");
                }
                foreach (var i in Enumerable.Range(0, W - 1))
                {
                    Console.Write("#");
                }
                Console.WriteLine("#");
                Console.WriteLine();
            }
        }
    }
}

Measured memory_bytes: 9252
#include<iostream>
#include<algorithm>
#include<string>
#include<vector>
#include<queue>
#include<map>
#include<set>
#include<cmath>
using namespace std;
#define REP(i, limit) for(int i=0; i< limit; ++i)
#define FOR(i, j, limit) for(int i=j; i< limit; ++i)
#define DUMP(a) REP(d,a.size()){cout<<a[d];if(d!=a.size()-1)cout<<" ";else cout<<endl;}
#define ECHO(x) cout<<x<<endl;
#define MEMSET(a, n, x) REP(i, n) a[i]=x;
#define ARRIN(a, n) REP(i, n) cin>>a[i];
#define LL long long
int INF = 2147483647;
LL LINF = 9223372036854775807;
LL MOD = 1000000007;
typedef pair<int, int>P;
typedef pair<LL, LL>PL;
typedef vector<int> vi;
typedef vector<LL> vl;


int main(){
  int n, k;
  cin>>n>>k;
  string s;
  cin>>s;
  vector<pair<int, char>> ss;
  int l=-1;
  int zc=0;
  REP(i, n-1){
    if(s[i]!=s[i+1]){
      ss.push_back(make_pair(i-l, s[i]));
      l=i;
    }
  }
  ss.push_back(make_pair(n-1-l, s[n-1]));
  int j=0, x=0;
  int ans=0;
  int work=0;
  while(j<ss.size()){
    work+=ss[j].first;
    if(ss[j].second=='0') ++zc;
    if(zc>k){
      while(zc>k){
        work-=ss[x].first;
        if(ss[x].second=='0') --zc;
        ++x;
      }
    }
    ans=max(ans, work);
    ++j;
  }

  ECHO(ans);
  return 0;
}


Measured memory_bytes: 1528
#include <iostream>
using namespace std;
int main(void){
    int a=1;int x[10000];int n=0;
    while(1){
        cin >> a;
        if(a==0){break;}
        else{x[n]=a;n++;}
    }
    for(int i=0;i<n;i++){
        cout << "Case " << i+1 << ": " << x[i] << endl;
    }
}


Measured memory_bytes: 3060
#include <bits/stdc++.h>
#define REP(i,n) for(int i=0;i<(n);i++)
const int MOD=(int)1e9+7;
using namespace std;
int main(){
    string s,t,ans="No";
    cin>>s>>t;
    int a=stoi(s+t);
    REP(i,1001){
        if(i*i==a)ans="Yes";
    }
    cout<<ans<<endl;
}

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


using namespace std;

const int MX = 100500;

int sz[MX];
vector<pair<int,int>> e[MX];

void dfs(int u, int pr){
	sz[u] = 1;
	for(int i = 0; i < e[u].size(); i++){
		int v = e[u][i].first;
		if(v == pr) continue;
		dfs(v, u);
		sz[u] += sz[v];
	}
}

long long ans = 0;

void dfs2(int u, int pr){
	for(int i = 0; i < e[u].size(); i++){
		int v = e[u][i].first;
		if(v == pr) continue;
		long long t = e[u][i].second;
		t *= 2 * sz[v];
		ans += t;
		//cout << u << ' ' << t << endl;
		dfs2(v, u);
	}
}


int main() {
	ios_base::sync_with_stdio(false);
	int n;
	cin >> n;
	for(int i = 1; i < n; i++){
		int u, v, w;
		cin >> u >> v >> w;
		u--; v--;
		e[u].push_back({v, w});
		e[v].push_back({u, w});
	}
	int mid = (n + 1) / 2;
	dfs(0, 0);
	int u = 0;
	while(true){
		bool ok = false;
		for(int i = 0; i < e[u].size(); i++){
			int v = e[u][i].first;
			if(sz[u] < sz[v]) continue;
			if(sz[v] >= mid) {u = v; ok = true; break;}
		}
		if(!ok) break;
	}
	//cout << u << endl;
	dfs(u, u);
	dfs2(u, u);
	int r2 = 1e9;
	for(int i = 0; i < e[u].size(); i++)
		r2 = min(r2, e[u][i].second);
	for(int i = 0; i < e[u].size(); i++)
		if(sz[e[u][i].first] >= mid) r2 = e[u][i].second;
//	cout << ans << endl;
	cout << ans - r2 << endl;
	return 0;
}

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

char S[3];
int cur, ans;

int main() {
	scanf("%s", S);
	for (int i = 0; i < 3; i++) {
		if (S[i] == 'R') cur++;
		else cur = 0;
		ans = max(ans, cur);
	}
	printf("%d\n", ans);
	return 0;
}


Measured memory_bytes: 3756
#include <stdio.h>
#include <iostream>
#include <iomanip>
#include <vector>
#include <cstdlib>
#include <cmath>
#include <numeric>
#include <algorithm>
#include <sstream>
#include <string>
#include <map>
#include <set>
using namespace std;

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


int main() {
	int N;
	cin >> N;
	int64_t A[100];
	A[0] = 2;
	A[1] = 1;

	for (int i=2; i<100; i++) {
		A[i] = A[i-1] + A[i-2];
	}
	cout << A[N] << endl;
}

Measured memory_bytes: 256
mod = 10 ** 9 + 7

n, k = gets.split.map(&:to_i)

a = [1] * (k+1)
b = Array.new(k+1){|i| i }

ans = 0
(k/2).downto(1) do |i|
  cnt = ( k/i ).pow( n, mod )
  (i*2).step(k, i){|j| cnt = ( cnt - a[j] ) % mod }
  a[i] = cnt
  ans += i * cnt % mod
  ans %= mod if ans >= mod
end

puts (ans + (k-k/2) * ( k + k/2+1) / 2 ) % mod

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

int main(){
int N; cin >> N;
vector<int> A(N);
for (int i = 0; i < N; i++) {
    cin >> A[i];
}

int ans = 10000000;
for (int i = 0; i < N; i++) {
    int k = 0;
    while (A[i] % 2 == 0) {
        A[i] = A[i] / 2;
        k++; 
    }
    ans = min(k, ans);
}
cout << ans << endl;
}





Measured memory_bytes: 256
import java.util.Scanner;
public class Main {
    public static void main(String[] args){
	Scanner sc = new Scanner(System.in);	
	while (sc.hasNextLine()){
	String s=sc.nextLine();
    int []ara= new int[s.length()];
    char []roma=s.toCharArray();
    int ans=0,a=0;
    for(int i=0;i<s.length();i++){
		switch(roma[i]){
		case 'I':a=1; break;
		case 'V':a=5; break;
		case 'X':a=10; break;
		case 'L':a=50; break;
		case 'C':a=100; break;
		case 'D':a=500; break;
		case 'M':a=1000; break;
		}
		ara[i]=a;
	}
    if(s.length()<2){
    	ans=ara[0];
    }else
    for(int i=0;i<s.length();i++){
     if(i>0){
    	 if(ara[i-1]<ara[i])ans-=ara[i-1]*2;
     }
    	ans+=ara[i]; 
    }
	System.out.println(ans);
	}
    }
 }

Measured memory_bytes: 17196
#include <bits/stdc++.h>
using namespace std;
using vi = vector<int>;
using vb = vector<bool>;
using vc = vector<char>;
using vs = vector<string>;
using vvi = vector<vector<int>>;
using vvc = vector<vector<char>>;
using pii = pair<int, int>;
#define fix10 cout << fixed << setprecision(10);
#define rep(i,n) for(int i=0; i<(int)(n);i++)
#define MOD 1000000007

int main(){
  int d;
  cin >> d;
  if(d == 25) cout << "Christmas" << endl;
  else if(d == 24) cout << "Christmas Eve" << endl;
  else if(d == 23) cout << "Christmas Eve Eve" << endl;
  else cout << "Christmas Eve Eve Eve" << endl;
}


Measured memory_bytes: 384
#include<iostream>
using namespace std;
int nrec(int n){
    int a[44];
    a[0]=a[1]=1;
    for(int i=2;i<=n;i++){
        a[i]=a[i-1]+a[i-2];  
    }
    return a[n];
}

int main(){
    int n;
    cin>>n;
    cout<<nrec(n)<<endl;
    return 0;
}


Measured memory_bytes: 3088
from itertools import product

N = int(input())
MOD = 10**9 + 7
A = 'A'
T = 'T'
G = 'G'
C = 'C'
ATGC = [A, T, G, C]

dp = {i: {c1: {c2: {c3: 0 for c3 in ATGC} for c2 in ATGC} for c1 in ATGC} for i in range(N+1)}
dp[0][T][T][T] = 1

for i, c1, c2, c3 in product(range(N), ATGC, ATGC, ATGC):
    if dp[i][c1][c2][c3] == 0:
        continue
    for c in ATGC:
        if (c1, c2, c) == (A, G, C) or (c1, c3, c) == (A, G, C):
            continue
        elif (c2, c3, c) == (A, G, C) or (c2, c3, c) == (A, C, G) or (c2, c3, c) == (G, A, C):
            continue
        dp[i+1][c2][c3][c] += dp[i][c1][c2][c3]
        dp[i+1][c2][c3][c] %= MOD

ans = 0
for c1, c2, c3 in product(ATGC, ATGC, ATGC):
    ans += dp[N][c1][c2][c3]
    ans %= MOD
print(ans)

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

using namespace std;

int main() {
  long long N;
  int X, M;
  cin >> N >> X >> M;
  
  if (N <= M) {
    long long sum = 0;
    for (long long i = 0, A = X; i < N; i++) {
      sum += A;
      A = A * A % M;
    }
    cout << sum << endl;
    return 0;
  }
  
  vector<bool> used(M, false);
  int pre = 0, period = 0, last = -1;
  long long sum = 0;
  for (long long i = 0, A = X; i < N; i++) {
    if (used[A]) {
      pre = i;
      last = A;
      break;
    }
    sum += A;
    used[A] = true;
    A = A * A % M;
  }
  
  long long sum2 = 0;
  if (last != -1) {
    for (long long i = 1, A = last;; i++) {
      sum2 += A;
      A = A * A % M;
      if (A == last) {
        period = i;
        break;
      }
    }
  }
  
  if (period) sum += sum2 * ((N - pre) / period);
  
  for (long long i = 0, A = last; i < (period ? (N - pre) % period : 0); i++) {
    sum += A;
    A = A * A % M;
  }
  
  cout << sum << endl;
  
  return 0;
}

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

int main() {
	long num;
	cin >> num;
	long sum = 0;
	long tmp = num;
	while (tmp > 0) {
		sum += tmp % 10;
		tmp /= 10;
	}
	if (num % sum == 0)
		cout << "Yes\n";
	else
		cout << "No\n";
}


Measured memory_bytes: 256
# include <bits/stdc++.h>
using namespace std;
int main() {
  int N;
  cin >> N;
  vector<int> L(N, 0);
  
  
  for(int i = 0; i < N; i++){
    cin >> L[i];
  }
  
  int sum = 0;
  sort(L.begin(),L.end());
  for(int i = 0; i < N-1; i++){
    sum += L[i];
  }
  
 
  if(sum > L[L.size()-1]){
    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 < (int)(n); i++)

int main() {
 int N;
 int d = 100;
  cin >> N;
  rep(i, N) {
 int A;
 cin >> A;
int c=0;
 rep(i ,100){
if(A%2==1){
break;
}
else{
 A/=2;
 c++;
 }
 }
  d = min(d,c);
 }
cout  << d << endl;
}

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

#define step(i, s, n, d) for(int i=s; i<n; i+=d)
#define FOR(i,s,n) step(i,s,n,1)
#define rep(i,n) FOR(i,0,n)
#define gets(x) x; cin >> x;
#define puts(x) x; cout << x << endl;
#define list_input(x, n) x[n]; rep(i,n){ gets(x[i]);}
#define ll long long

int main(){
  int group[7] = {1, 3, 5, 7, 8, 10, 12};
  int a, b;
  cin >> a >> b;
  if (a == 2) {
    if (b == 2) {
      puts("Yes")
      exit(0);
    }else{
      puts("No")
      exit(0);
    }
  }
  if (find(begin(group), end(group), a) != end(group) && find(begin(group), end(group), b) != end(group) ) {
    puts("Yes")
    exit(0);
  }

  if (find(begin(group), end(group), a) == end(group) && find(begin(group), end(group), b) == end(group) ) {
    puts("Yes")
    exit(0);
  }
  puts("No")
}


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

using namespace std;
#define repr(i,a,b) for (int i=a; i<b; i++)
#define rep(i,n) for (int i=0; i<  n; i++)
 
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; }

const long long INF = 1LL << 60;

bool dp[100100];

int main () {
    int N, C, K;
    cin >> N >> C >> K;

    vector<int>t(N);
    rep(i,N)cin >> t[i];


    sort(t.begin(),t.end());

    int bus =0;
    for(int i=0; i <N ;){
        bus += 1;
        int start =i;
        while(i < N && t[i]-t[start] <= K && i-start < C ){
            i +=1;
        }
    }

    cout << bus  << endl;
    
}



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

A, B, C, D = map(int, input().split())

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

def lcm(x, y):
    return x * y // gcd(x, y)

# A-1 以下の割り切れるものの個数
a_c = (A-1) // C
a_d = (A-1) // D
a_cd = (A-1) // lcm(C, D)

# B以下の割り切れるものの個数
b_c = B // C
b_d = B // D
b_cd = B // lcm(C, D)

# A以上B以下の割り切れるものの個数
ab = (b_c + b_d - b_cd) - (a_c + a_d - a_cd)

# 割り切れないものの個数
ans = (B - A + 1) - ab

print(ans)



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

using namespace std;

#define INF 1001000100010001000
#define MOD 1000000007
#define EPS 1e-10
#define int long long
#define rep(i, N) for (int i = 0; i < N; i++)
#define Rep(i, N) for (int i = 1; i < N; i++)
#define For(i, a, b) for (int i = (a); i < (b); i++)
#define pb push_back
#define eb emplece_back
#define mp make_pair
#define i_i pair<int, int>
#define vi vector<int>
#define vvi vector<vi >
#define vb vector<bool>
#define vvb vector<vb >
#define vp vector< i_i >
#define Edge pair< i_i, int>
#define all(a) (a).begin(), (a).end()
#define Int(x) int x; scanf("%lld", &x);
#define int2(x, y) int x, y; scanf("%lld %lld", &x, &y);
#define fir first
#define sec second
#define ffir first.first
#define fsec first.second
#define sfir second.first
#define ssec second.second
 
//int dxy[5] = {0, 1, 0, -1, 0};
// assign

int lb(int life, int yui, int kyoko, int num)
{
    if (life <= num * kyoko)
        return 0;
    int l = 0, r = num;
    while (r - l > 1) {
        int mid = (l + r) / 2;
        if ( (num - mid) * kyoko + mid * yui >=
                life) {
            // true
            r = mid;
        } else {
            l = mid;
        }
    }
        int mid = (l + r) / 2;
        if ( (num - mid) * kyoko + mid * yui >=
                life) {
            return l;
        } else {
            return r;
        }
}


signed main()
{
    Int(n);
    int2(a, b);
    vi data(n);
    rep(i, n) {
        cin >> data[i];
    }

    int l = 1, r = 1010001000;
    while (r - l > 1) {
        int mid = (l + r) / 2;
        int atk = mid * b;

        /*
        cout << "(" << l << "," << r << ")" << " ";
        cout << mid << ":";
        */
        int cnt = 0;
        rep(i, n) {
            /*
            int tmp = data[i] - atk;
            if (tmp <= 0) continue;
            cnt += tmp / a + !!(tmp % a);
            cout << tmp / a + !!(tmp % a) << " ";
            */
            cnt += lb(data[i], a, b, mid);
        }
        //cout << endl;

        if (cnt <= mid) { // 成功
            r = mid;
        } else {
            l = mid;
        }
    }


        int atk = l * b;

        int cnt = 0;
        rep(i, n) {
            cnt += lb(data[i], a, b, l);
        }

        if (cnt <= l) {
            cout << l << endl;
        } else {
            cout << r << endl;
        }



    return 0;
}



Measured memory_bytes: 1024
#include<bits/stdc++.h>
#define rep(i,m) for(long long i=0; i<m; i++)
#define per(i,m) for(long long i=m-1; i>=0; i--)
#define FOR(i,n,m) for(long long i=n; i<m; i++)
#define ROF(i,n,m) for(long long i=n-1; i>=m; i--)
#define all(x) (x).begin(),(x).end()
#define EPS (1e-7)
#define INF (1e18)
#define PI (acos(-1))
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;
using namespace std;
typedef long long ll;
const ll MOD = 1000000007;
typedef pair<ll, ll> LP;

ll POW(ll x,ll n){
  if(n==0)return 1;
  if(n%2==0)return POW(x*x%MOD,n/2);
  return x*POW(x,n-1)%MOD;
}

ll gcd(ll u, ll v) {
  ll r;
  while (0 != v) {
    r = u % v; u = v; v = r;
  }
  return u;
}
 
ll KAI(ll m)
{
  if(m<0) return 0;
  if(m==0) return 1;
  return m*KAI(m-1)%MOD;
}
 
ll extGCD(ll a, ll b, ll &x, ll &y) {
    if (b == 0) {
        x = 1;
        y = 0;
        return a;
    }
    ll d = extGCD(b, a%b, y, x);
    y -= a / b * x;
    return d;
}
 
inline ll mod(ll a, ll m) {
    return (a % m + m) % m;
}
 
ll modinv(ll a) {
    ll x, y;
    extGCD(a, MOD, x, y);
    return mod(x, MOD);
}
 
ll COM(ll m,ll n)
{
  if(m<n) return 0;
  if(n<0) return 0;
  if(n==0) return 1;
  if(m==n) return 1;
  return KAI(m)%MOD*modinv(KAI(n)%MOD*KAI(m-n)%MOD)%MOD;
}

ll DEC(ll x,ll m,ll n)
{
  return x%POW(m,n+1)/POW(m,n);
}

ll keta(ll x,ll n)
{
  if(x==0)return 0;
  return keta(x/n,n)+1;
}

int main()
{
  ll l,c,k;
  k=0;
  cin >> l;
  c=POW(2,keta(l,2)-1);
  per(i,keta(l,2)-1){if(DEC(l,2,i)==1){
                                       k++;
                                      }
                    }
  cout << keta(l,2) << " " << (keta(l,2)-1)*2+k << endl;
  rep(i,keta(l,2)-1){
    cout << i+1 << " " << i+2 << " " << 0 << " " << endl;
  }
  rep(i,keta(l,2)-1){
    cout << i+1 << " " << i+2 << " " << POW(2,i) << " " << endl;
  }
  per(i,keta(l,2)-1){if(DEC(l,2,i)==1){cout << i+1 << " " << keta(l,2) << " " << c << " " << endl;
                                       c+=POW(2,i);
                                      }
                    }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define _USE_MATH_DEFINES
using namespace std;
// 型シノニム
typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> P;
// 定数
constexpr ll INF   = 1e16;
constexpr ll INM   = 114514;
constexpr ll MOD   = 1e9 + 7;
constexpr ld EPS   = 1e-12;
constexpr ll dx[4] = {1, 0, -1, 0};
constexpr ll dy[4] = {0, 1, 0, -1};
// 便利関数
void IOS() { ios::sync_with_stdio(false), cin.tie(0); }
template <typename T>
void dump(T x) { cout << x << endl; }
void dumpf(ld x, int t) { cout << setprecision(t) << fixed << x << endl; }
template <class T>
bool chmax(T &a, const T &b) {
	if (a < b) {
		a = b;
		return true;
	}
	return false;
}
template <class T>
bool chmin(T &a, const T &b) {
	if (b < a) {
		a = b;
		return true;
	}
	return false;
}
template <typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val) {
	fill((T *)array, (T *)(array + N), val);
}
inline ll mod(ll a, ll mod) {
	if (a > 0) return a % mod;
	if (a % mod == 0) return 0;
	ll x = -a / mod + 1;
	a += x * mod;
	return a % mod;
}
ll powm(ll a, ll b, ll m) {
	if (b == 0) {
		return 1;
	} else if (b % 2 == 0) {
		ll d = powm(a, b / 2, m);
		return (d * d) % m;
	} else {
		return (powm(a, b - 1, m) * a) % m;
	}
}

// 本体


int main() {
	IOS();
	ll n;
	cin >> n;
	vector<ll> p(n), q(n), a(n);
	for (int i = 0; i < n; i++) {
		cin >> p[i];
	}
	for (int i = 0; i < n;i++) {
		cin >> q[i];
		a[i] = i + 1;
	}
	ll cnt1 = 0, cnt2 = 0;
	ll cnt = 0;
	do {
		bool ok1 = true;
		for (int i = 0; i < n; i++) {
			if(p[i] != a[i]){
				ok1 = false;
				break;
			}
		}
		if (ok1) cnt1 = cnt;
		bool ok2 = true;
		for (int i = 0; i < n; i++) {
			if (q[i] != a[i]) {
				ok2 = false;
				break;
			}
		}
		if (ok2) cnt2 = cnt;
		cnt++;
	} while (next_permutation(a.begin(), a.end()));
	dump(abs(cnt1 - cnt2));
}


Measured memory_bytes: 3648
while True:
    n,x=map(int,input().split())
    cnt=0
    if n==0 and x==0:
        break
    for i in range(n):
        for j in range(n):
            if j<=i:
                continue
            for k in range(n):
                if k<=j:
                    continue
                if x==i+j+k+3:
                    cnt += 1
    print(str(cnt))


Measured memory_bytes: 5592
import java.util.Scanner;

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

    private static void solve(Scanner sc) {
        int a = Integer.parseInt(sc.next());
        int b = Integer.parseInt(sc.next());
        System.out.println(a * b);
    }
}


Measured memory_bytes: 35656
N = int(input())
s = []
for i in range(N):
  tmp = list(input())
  tmp = sorted(tmp)
  s.append(''.join(tmp))
s = sorted(s)

i, j = 0, 1
count = 0
total = 0
while j < N:
  while s[i] == s[j]:
    count += 1
    j += 1
    if j == N:
      break
  
  if count == 1:
    total += 1
  elif count > 1:
    tmp1, tmp2 = 1, 2
    for k in range(count+1, count+1-2, -1):
      tmp1 *= k
    total += int(tmp1/tmp2)
  i = j
  j += 1
  count = 0

print(total)


Measured memory_bytes: 17360
import bisect, copy, heapq, math, sys
from collections import *
from functools import lru_cache
from itertools import accumulate, combinations, permutations, product
def input():
    return sys.stdin.readline()[:-1]
def ruiseki(lst):
    return [0]+list(accumulate(lst))
def celi(a,b):
    return -(-a//b)
sys.setrecursionlimit(5000000)
mod=pow(10,9)+7
al=[chr(ord('a') + i) for i in range(26)]
direction=[[1,0],[0,1],[-1,0],[0,-1]]

n,q=map(int,input().split())
s=input()
td=[input().split() for i in range(q)]
# print(td)

ll,lr=0,n+1
while lr-ll>1:
    mid=(lr+ll)//2
    for i in range(q):
        if mid==0 or mid==n+1:
            break
        t,d=td[i]
        if s[mid-1]==t:
            if d=="L":
                mid-=1
            else:
                mid+=1
    if mid==0:
        ll=(lr+ll)//2
    else:
        lr=(lr+ll)//2
# print(ll)

ikeru,ikenai=n+1,0
while ikeru-ikenai>1:
    mid=celi(ikeru+ikenai,2)
    for i in range(q):
        if mid==0 or mid==n+1:
            break
        t,d=td[i]
        if s[mid-1]==t:
            if d=="L":
                mid-=1
            else:
                mid+=1
    if mid==n+1:
        ikeru=celi(ikeru+ikenai,2)
    else:
        ikenai=celi(ikeru+ikenai,2)

# print(ikeru)
print(max(0,n-(ll+n+1-ikeru)))

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

using namespace std;

#define rep(i,n) for(long i=1;i<=n;i++)

long n,m,q,p[501][501];

int main(){
  
  cin >> n >> m >> q;
  rep(i,m){
   long l,r;
    cin >> l >> r;
    p[l][r]++;
  }
  rep(i,n){
    rep(j,n) p[i][j]+=p[i][j-1];
  }
  rep(i,n){
    rep(j,n) p[i][j]+=p[i-1][j];
  }
  
 rep(i,q){
  long l,r;
   cin >> l >> r;
   cout <<p[r][r]+p[l-1][l-1]-p[r][l-1]-p[l-1][r] << endl;
 } 

}

Measured memory_bytes: 2944
const numberList = require('fs').readFileSync('/dev/stdin','utf8').trim().split(' ').map(e => parseInt(e))

const a = numberList[0]
const b = numberList[1]

const sum = a + b
const sub = a - b
const mul = a * b

var max = sum

max = max > sub ? max : sub
max = max > mul ? max : mul

console.log(max)


Measured memory_bytes: 7372
def solve():
    N = int(input())
    cnt = [0] * N
    for A in map(int, input().split()):
        if A < N and (N + A) % 2 == 1 and (A > 0 and cnt[A] < 2 or A == 0 and cnt[A] < 1):
            cnt[A] += 1
        else:
            return 0
    return pow(2, N // 2, 10**9 + 7)
print(solve())

Measured memory_bytes: 11188
n=input()
while n:
    R=[input() for i in range(n)]
    x=R
    s=max(x)
    while n-1:
        R=R[1:]
        x=[a+b for a,b in zip(x[:-1],R)]
        s=max(s,max(x))
        n-=1
    print s
    n=input()

Measured memory_bytes: 4460
#include <bits/stdc++.h>
using namespace std;
using Graph = vector<vector<int>>;

Graph G;
vector<bool> seen;
int cnt = 0;

void dfs(int v){
  seen[v] = true;
  for(int nv: G[v]){
    if(seen[nv]) continue;
    dfs(nv);
  }
}
    

int main(){
  int n, m; cin >> n >> m;
  G.resize(n);
  seen.resize(n);
  for(int i = 0; i < m; i++){
    int x, y, z; cin >> x >> y >> z;
    --x; --y;
    G[x].push_back(y);
    G[y].push_back(x);
  }
  for(int i = 0; i < n; i++){
    if(seen[i]) continue;
    cnt++;
    dfs(i);
  }
  cout << cnt << endl;
}

Measured memory_bytes: 11812
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define FAST() ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)

int main()
{
    FAST();
    int x;
    cin>>x;
    if(x>=30)cout<<"Yes"<<endl;
    else cout<<"No"<<endl;


    return 0;
}






Measured memory_bytes: 3632
n = int(input())
a = list(map(int,input().split()))

check = [False] * 8
r = 0
for i in range(n):
    if a[i] < 400:
        check[0] = True
    elif 400 <= a[i] < 800:
        check[1] = True
    elif 800 <= a[i] < 1200:
        check[2] = True
    elif 1200 <= a[i] < 1600:
        check[3] = True
    elif 1600 <= a[i] < 2000:
        check[4] = True
    elif 2000 <= a[i] < 2400:
        check[5] = True
    elif 2400 <= a[i] < 2800:
        check[6] = True
    elif 2800 <= a[i] < 3200:
        check[7] = True
    else:
        r += 1

color = 0
ans_max = r
for i in range(8):
    if check[i]:
        color += 1
        ans_max += 1

ans_min = max(color,1)
print(ans_min,ans_max)

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

string  henkan(int n){
 if(n==1) return "a";
  if(n==2) return "b";
  if(n==3) return "c";
  if(n==4) return "d";
 if(n==5) return "e";
 if(n==6) return "f";
 if(n==7) return "g";
 if(n==8) return "h";
 if(n==9) return "i";
 if(n==10) return "j";
 if(n==11) return "k";
 if(n==12) return "l";
 if(n==13) return "m";
 if(n==14) return "n";
 if(n==15) return "o";
 if(n==16) return "p";
 if(n==17) return "q";
 if(n==18) return "r";
 if(n==19) return "s";
 if(n==20) return "t";
 if(n==21) return "u";
 if(n==22) return "v";
 if(n==23) return "w";
 if(n==24) return "x";
 if(n==25) return "y";
 if(n==26) return "z";
}

int main(){
ll n;
cin >> n ;
vector<int> a;
while(n>0){
  int m = n%26;
  if(m==0)m=26;
  n = (n-m)/26;
  a.push_back(m);
}
string ans;
ll k = a.size();
for(int i = k-1; i>=0; i--) ans +=henkan(a[i]);

cout <<ans  <<endl;
 return 0;
}
 

Measured memory_bytes: 3636
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		int X = scan.nextInt();

		int happy = (X / 500) * 1000 + ((X - 500 * (X / 500)) / 5) * 5;
		System.out.println(happy);
		scan.close();
	}
}


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

using i64 = int64_t;

int main(){
    i64 n, k;
    cin >> n >> k;
    vector<i64> a, f;
    for(int i=0;i<n;++i){
        i64 tmp;
        cin >> tmp;
        a.push_back(tmp);
    }
    for(int i=0;i<n;++i){
        i64 tmp;
        cin >> tmp;
        f.push_back(tmp);
    }
    sort(a.rbegin(), a.rend());
    sort(f.begin(), f.end());

    i64 ok = 1e18, ng = -1;
    while(abs(ok-ng) > 1){
        i64 mid = (ok + ng) /  2;
        i64 cnt = k;
        for(int i=0;i<n;++i){
            if(a[i]*f[i] <= mid)continue;
            cnt -= a[i] - (mid / f[i]);
            assert(f[i]*(mid/f[i]) <= mid);
        }
        if(cnt >= 0)ok = mid;
        else ng = mid;
    }

    cout << ok << endl;

    return 0;
}


Measured memory_bytes: 4848
#include "bits/stdc++.h"

using namespace std;

using ll = long long;
using vi = vector<int>;
using vii = vector<vi>;
using pi = pair<int,int>;
using pl = pair<ll,ll>;

const ll linf = 1LL << 62;
const int inf = 999999;
const int dx[4] = {1,0,-1,0};
const int dy[4] = {0,1,0,-1};
const ll atcoder = int(1e9 + 7);

#define Endl endl
#define pr(x) cout << x << endl
#define chmax(x,y) x = max(x,y)
#define chmin(x,y) x = min(x,y)
#define all(x) x.begin(),x.end()
#define atcoder(int)1e9+7
#define rep(i,n) for(int i = 0;i<n;i++)
#define pb(x) push_back(x)
#define mp(a,b) make_pair(a,b)

ll gcd(ll a, ll b) {//最大公約数
	if (a%b == 0)return b;
	else gcd(b, a%b);
}

ll lcm(ll a, ll b) {//最小公倍数
	return (a / gcd(a, b))*b;
}

ll ketawa(ll a) {
	if (a < 10)return a;
	return ketawa(a / 10) + a % 10;
}

int main() {
	
	double r1, r2;
	cin >> r1 >> r2;

	cout << setprecision(10) << (r1*r2) / (r1 + r2) << endl;;

	return 0;
}

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

using namespace std;
typedef long long ll;
typedef long double ld;
#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define REPR(i,n) for(int i=n; i>-1; --i)
#define ALL(a) (a).begin(),(a).end()
#define FILL(a,n,x); REP(i,(n)){ (a)[i]=(x); }
#define CINA(a,n); REP(i,(n)){ cin >> (a)[i]; }
#define FILL2(a,n,m,x); REP(i,(n)){ REP(j,(m)){(a)[i][j]=(x);} }
#define CINA2(a,n,m); REP(i,(n)){ REP(j,(m)){cin >> (a)[i][j];} }
#define Liny "Yes\n"
#define Linn "No\n"
#define LINY "YES\n"
#define LINN "NO\n"

//cout << setfill('0') << right << setw(4) << 12; // "0012"
int keta(ll x){ if(x<10){return 1;} else{return keta(x/10) + 1;}}
int keta_wa(ll x){ if(x<10){return x;} else{return keta_wa(x/10) + x%10;} }
int ctoi(char c){ return ( (c>='0' && c<='9')? c - '0': 0 );}
int __stoi(string s){ return atoi(s.c_str()); }
ll sum(ll a[],ll N){ return accumulate(a,a+N,0LL);}
ll gcd(ll a,ll b){if(a<b)swap(a,b); return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b){if(a<b){swap(a,b);} return a/gcd(a,b)*b;}
template<class T> void chmax(T& a, T b){ if(a<b){a=b;} }
template<class T> void chmin(T& a, T b){ if(a>b){a=b;} }
template<class T> bool isIn(T a,vector<T> v){ for(T x:v){ if(a==x){return true;}} return false;}
string strReplace(string s,string target, string replacement){
    if (!target.empty()) {
      std::string::size_type pos = 0;
      while ((pos = s.find(target, pos)) != std::string::npos) {
        s.replace(pos, target.length(), replacement);
        pos += replacement.length();
      }
    }
    return s;
}
const ll MOD = 1e9+7;
#define pii pair<int,int>
#define pll pair<ll,ll>
#define MP make_pair

bool DEBUG = 0;

template<class T> void dprint(T s){
  if(DEBUG){ cout << s << "\n"; }
}

int main(int argc,char* argv[]){
  if(argc>1 && argv[1][0]=='D'){ DEBUG=1;}
  dprint("start");

  int X; cin>>X;
  int ans =  8 - (X-400)/200; 
  cout << ans << "\n";
}

Measured memory_bytes: 3624
import heapq as hq

k =int(input())
inf = float("inf")
dist = [inf for _ in range(k)]
dist[1]=1
start =1
q =[(1,1)]

while q:
    keta,nowmod = hq.heappop(q)
    if dist[(nowmod*10)%k]>keta:
        dist[(nowmod*10)%k]=keta
        hq.heappush(q,(keta,(nowmod*10)%k))
    if dist[(nowmod+1)%k]>keta+1:
        dist[(nowmod+1)%k]=keta+1
        hq.heappush(q,(keta+1,(nowmod+1)%k))

print(dist[0])




Measured memory_bytes: 8960
package main

import (
	"fmt"
)

func main() {
	var a, b, c int
	fmt.Scanf("%d %d %d", &a, &b, &c)

	if a+b+c != 17 {
		fmt.Println("NO")
		return
	}

	var f, s int
	for _, t := range []int{a, b, c} {
		if t == 5 {
			f++
		}
		if t == 7 {
			s++
		}
	}

	if f == 2 && s == 1 {
		fmt.Println("YES")
	} else {
		fmt.Println("NO")
	}
}

Measured memory_bytes: 512
import * as fs from 'fs';

const readString = (() => {
  const input = fs.readFileSync(0).toString();
  const words = input.split(/[ \n]/);
  let i = 0;
  return () => words[i++] || '';
})();
const readInt = () => parseInt(readString(), 10);
const readNumber = () => +readString();
const readBigInt = () => BigInt(readString());

const gcd = (a: bigint, b: bigint) => {
  const _gcd = (a: bigint, b: bigint): bigint => {
    const q = a % b;
    return q === 0n ? b : _gcd(b, q);
  };
  return a > b ? _gcd(a, b) : _gcd(b, a);
};

const MOD = 1000000007;
const MOD_BIGINT = BigInt(MOD);
class ModBigInt {
  constructor(public v: bigint) {}

  static of(n: number | bigint) {
    return new ModBigInt(ModBigInt.toBigInt(n));
  }

  static toBigInt(other: number | bigint | ModBigInt) {
    if (typeof other === 'bigint') return other;
    if (typeof other === 'number') return BigInt(other);
    return other.v;
  }

  clone = () => new ModBigInt(this.v);
  plus = (other: number | bigint | ModBigInt) => {
    this.v = (this.v + ModBigInt.toBigInt(other)) % MOD_BIGINT;
    return this;
  };
  minus = (other: number | bigint | ModBigInt) => {
    this.v = (this.v + MOD_BIGINT - ModBigInt.toBigInt(other)) % MOD_BIGINT;
    return this;
  };
  multiply = (other: number | bigint | ModBigInt) => {
    this.v = (this.v * ModBigInt.toBigInt(other)) % MOD_BIGINT;
    return this;
  };
  pow = (other: number) => {
    const v = mod(1);
    for (let i = 0; i < other; i++) v.multiply(this.v);
    return v;
  };
}

const mod = ModBigInt.of;

const abs = (a: bigint) => (a > 0n ? a : -a);

(function main() {
  const A = readBigInt();
  const B = BigInt(Math.round(readNumber() * 100));
  console.log(((A * B) / 100n).toString());
})();


Measured memory_bytes: 29640
#include <bits/stdc++.h>
typedef long long ll;
using namespace std;
#define repr(i,a,b) for(ll i=a;i<b;i++)
#define rep(i,n) for(int i=0;i<n;i++)
#define invrepr(i,a,b) for(int i=b-1;i>=a;i--)
#define invrep(i,n) invrepr(i,0,n)
#define repitr(itr,a) for(auto itr=a.begin();itr!=a.end();++itr)
const int MOD=1e9+7;


int main() {
    ios_base::sync_with_stdio(false);
    int n;
    cin >> n;
    ll a,b,c;
    repr(i,1,3501) {
        repr(j,i,3501) {
            if (4*i*j-n*(i+j)<=0) continue;
            if ((i*j*n)%(4*i*j-n*(i+j))==0) {
                a=i;
                b=j;
                c=(i*j*n)/(4*i*j-n*(i+j));
                if (c>0) break;
            } 
        }
    }
    cout << a << ' ' << b << ' ' << c << endl;
    
    return 0;
}

Measured memory_bytes: 256