akhauriyash/Code-Regression huggingface dataset:
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Runtime.CompilerServices;
using System.Text;
using static System.Console;
using static System.Math;

namespace Atcoder
{
    class Program
    {
        static StreamWriter sw = new StreamWriter(OpenStandardOutput()) { AutoFlush = false };
        static void Main(string[] args)
        {
            try
            {
                SetOut(sw);
                Solve.Answer();
                Out.Flush();
            }
            catch (Exception ex)
            {
                WriteLine(ex.ToString());
            }
        }
    }

    public class Solve
    {
        static List<string> lis = new List<string>();
        static long N;

        public static void Answer()
        {
            N = IO.RInt;

            DFS("");

            long ans = 0;
            foreach (var num in lis)
            {
                if (num.Where(c => c == '3').Count() == 0 ||
                    num.Where(c => c == '5').Count() == 0 ||
                    num.Where(c => c == '7').Count() == 0)
                    continue;

                var n = long.Parse(num);
                if (n <= N) ans++;
            }
            WriteLine(ans);
        }

        public static void DFS(string s)
        {
            if (s.Length > N.ToString().Length) return;

            lis.Add(s + "3");
            DFS(new string(s + "3"));

            lis.Add(s + "5");
            DFS(new string(s + "5"));

            lis.Add(s + "7");
            DFS(new string(s + "7"));
        }
    }

    public class IO
    {
        #region Input
        public static int RInt => int.Parse(ReadLine());
        public static long RLong => long.Parse(ReadLine());
        public static double RDouble => double.Parse(ReadLine());

        public static string[] RSString => ReadLine().Split();
        public static int[] RSInt => ReadLine().Split().Select(s => int.Parse(s)).ToArray();
        public static long[] RSLong => ReadLine().Split().Select(s => long.Parse(s)).ToArray();
        public static double[] RSDouble => ReadLine().Split().Select(s => double.Parse(s)).ToArray();
        #endregion

        #region Output
        public static void OutJoinSpace<T>(IEnumerable<T> list) => WriteLine(string.Join(" ", list));
        public static void WriteLineYes_or_No(bool flag) => WriteLine(flag ? "Yes" : "No");
        public static void WriteLineYES_or_NO(bool flag) => WriteLine(flag ? "YES" : "NO");
        #endregion
    }

    public class Mod
    {
        #region
        private readonly static long M = 1000000007;

        public static long Add(long a, long b) => (a * b) % M;
        public static long Sub(long a, long b) => (a - b) % M >= 0 ? (a - b) % M : (a - b) % M + M;
        public static long Multi(long a, long b) => (a * b) % M;
        #endregion
    }
}

Measured memory_bytes: 28168
#include <iostream>
#include <fstream>
#include <typeinfo>
#include <vector>
#include <stack>
#include <cmath>
#include <set>
#include <map>
#include <string>
#include <algorithm>
#include <cstdio>
#include <queue>
#include <iomanip>
#include <cctype>
#define syosu(x) fixed<<setprecision(x)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef pair<double,double> pdd;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<char> vc;
typedef vector<vc> vvc;
typedef vector<string> vs;
typedef vector<bool> vb;
typedef vector<vb> vvb;
typedef vector<P> vp;
typedef vector<vp> vvp;
typedef vector<pll> vpll;
typedef pair<int,P> pip;
typedef vector<pip> vip;
const int inf=1<<30;
const ll INF=1ll<<52;
const double pi=acos(-1);
const double eps=1e-8;
const ll mod=1e9+7;
const vi emp;
const int dx[4]={0,1,0,-1},dy[4]={1,0,-1,-0};
const int DX[8]={-1,-1,-1,0,0,1,1,1},DY[8]={1,0,-1,1,-1,1,0,-1};

ll n,m;

int main(){
	cin>>n>>m;
	ll ans=min(n,m/2);
	m-=2*ans;
	ans+=m/4;
	cout<<ans<<endl;
}

Measured memory_bytes: 256
#input of int(split by space)
def get_i()
  return gets.chomp.split(" ").map(&:to_i)
end
#input of float(split by space)
def get_f()
  return gets.chomp.split(" ").map(&:to_f)
end
#input of string(split by space)
def get()
  return gets.chomp.split(" ")
end
#input of string(split per one character)
def get_nsp()
  return gets.chomp.split("")
end
#yes or no decision
def yn_judge(bool,y="Yes",n="No")
  return bool ? y : n 
end
#create of array
def array(size1,init=nil,size2=-1)
  if size2==-1
      return Array.new(size1){init}
  else
      return Array.new(size2){Array.new(size1){init}}
  end
end

def max(a,b)
    return a>b ? a : b
end

def min(a,b)
    return a>b ? b : a
end

INF=Float::INFINITY
L,R,d=get_i
ans=0
L.upto(R) do|i|
    ans+=1 if (i%d).zero?
end
puts ans

Measured memory_bytes: 14368
#include<bits/stdc++.h>
using namespace std;
int main()
{
	long long flag,i,a,ans,j,k,b,c;
	ans=0;
	flag=0;
	a=0;
	string s;
	cin>>s;
	for (i=0;i<s.length();i++)
	{
		if (s[i]=='>')
		{
			a++;
		}
		else
		{
			break;
		}
	}
	ans=ans+(a*(a+1)/2);
	j=i;
	a=0;
	for (i=s.length()-1;i>=0;i--)
	{
		if (s[i]=='<')
		{
			a++;
		}
		else
		{
			break;
		}
	}
	k=i;
	ans=ans+(a*(a+1)/2);
	a=0;
	b=0;
	//cout<<ans<<endl;
	for (i=j;i<=k;i++)
	{
		if (s[i]=='<' && flag==0)
		{
			a++;
		}
		else if (s[i]=='>')
		{
			b++;
			flag=1;
		}
		else if(s[i]=='<' && flag==1)
		{
			flag=0;
			ans=ans+(max(a,b)*(max(a,b)+1)/2);
			ans=ans+(min(a,b)*(min(a,b)-1)/2);
			//cout<<ans<<endl;
			a=1;
			b=0;
		}
	}
	ans=ans+(max(a,b)*(max(a,b)+1)/2);
	ans=ans+(min(a,b)*(min(a,b)-1)/2);
	cout<<ans<<endl;	
}

Measured memory_bytes: 900
#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.at(i);
  }
  sort(a.begin(), a.end());
  reverse(a.begin(), a.end());
  int sum = 0;
  for (int i = 0; i < N; i++) {
    sum += a.at(i);
  }
  int Alice = 0;
  for (int i = 0; i < N; i += 2) {
    Alice += a.at(i);
  }
  cout << Alice - (sum - Alice) << endl;
}

Measured memory_bytes: 256
//pragma
//#pragma GCC optimize("Ofast")
//#pragma GCC optimize("unroll-loops")

#include <bits/stdc++.h>

#define YOU using
#define DONT namespace
#define SAY std

YOU DONT SAY;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef pair<ll,int> pli;
typedef pair<int,ll> pil;
typedef vector<int> vi;
typedef vector<pii> vii;
typedef vector<pll> vll;

#define REPP(i,a,b,d) for(int i=a;i<=b;i+=d)
#define REP(i,a,b) REPP(i,a,b,1)
#define REVV(i,a,b,d) for(int i=a;i>=b;i-=d)
#define REV(i,a,b) REVV(i,a,b,1)

#define FOR(i,a) for(int i=0; i<a; i++)
#define FORD(i,a) for(int i=(int)a-1; i>=0; i--)

#define pb push_back
#define F first
#define S second

const int OO = 1e9;
const ll INF = 1e18;

const int irand(int lo,int hi){
	return ((double)rand()/(RAND_MAX + 1.0)) * (hi-lo+1) + lo;
}

const ll lrand(ll lo,ll hi){
	return ((double)rand()/(RAND_MAX + 1.0)) * (hi-lo+1) + lo;
}

#define getc getchar
template<typename T>
T getnum(){
	int sign = 1;
	T ret = 0;
	char c;

	do{
		c = getc();
	}while(c == ' ' || c == '\n');
	if(c == '-')sign = -1;
	else ret = c-'0';
	while(1){
		c = getc();
		if(c < '0' || c > '9')break;
		ret = 10*ret + c-'0';
	}
	return sign * ret;
}

inline void ini(int& x){
	x = getnum<int>();
}

inline void scani(int& x){
	scanf("%d",&x);
}

//end of macro

const int N = 2e5 + 5;

int n,t;
vii vec;
vi zeromul;

bool cmp(pii i, pii j){
	return (ll)i.S * j.F + j.F + j.S < (ll)i.F * j.S + i.F + i.S;
}

ll memo[N][35];
ll dp(int now, int take){
	if(take > now+1)return t+1;
	if(now < 0)return 0;
	
	ll& ret = memo[now][take];
	if(ret != -1)return ret;
	
	// leave
	ret = dp(now-1, take);
	
	// take
	if(take > 0)ret = min(ret, (dp(now-1, take-1) + 1) * vec[now].F + vec[now].S);
	
	// limit the time
	ret = min(ret, (ll)t + 1);
	
	return ret;
}

int main(){
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    #define endl '\n'
    cout.setf(ios::fixed);
    cout.setf(ios::showpoint);
    cout.precision(10);
    
    cin>>n>>t;
    REP(i,1,n){
    	int a,b;
    	cin>>a>>b;
    	if(a > 0)vec.pb({a+1, b});
    	else zeromul.pb(b);
	}
	sort(vec.begin(), vec.end(), cmp);
	
	sort(zeromul.begin(), zeromul.end());
	
	memset(memo, -1, sizeof memo);
	int ans = 0;
	ll czero = 0;
	int czcnt = 0;
	REV(i,min(n, 30),0){
		ll v1 = dp((int)vec.size()-1, i);
//		printf("take %d, = %lld\n",i,v1);
		if(v1 <= t){
			while(czcnt < zeromul.size() && v1 + czero + 1 + zeromul[czcnt] <= t){
				czero += 1 + zeromul[czcnt++];
			}
//			printf("czcnt %d\n",czcnt);
			ans = max(ans, i + czcnt);
		}
	}
	
	cout << ans << endl;
    
    return 0;
}

Measured memory_bytes: 66032
#include <bits/stdc++.h> 
#define MOD 1000000007
using namespace std;
 
typedef long long int ll;
typedef unsigned long long int ull;

int main() {
      #ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin) ;
    freopen("output.txt", "w", stdout) ;
    #endif
    ios_base::sync_with_stdio(false);
    cin.tie(NULL) ; cout.tie(NULL) ;
    int t;
    cin >> t;
    int a,b;
    cin >> a >> b;
    int flag =0;
    for(int i = a; i<=b;i++){
        if(i%t==0){
            flag = 1;
            break;
        }
    }
    if(flag == 1){
        cout << "OK";
    }
    else {
        cout << "NG";
    }
    cout << endl;
}

Measured memory_bytes: 3648
# Algorithms and Data Structures 1
# Greatest Common Divisor
# Name: Ryuya Asada
# ID: s1260064


def gcd(a: int, b: int) -> int:
    if b == 0:
        return a
    
    return gcd(b, a%b)


def main():
    a, b = (int(e) for e in input().split(" "))
    print(gcd(a, b))


if __name__ == "__main__":
    main()



Measured memory_bytes: 5604
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const ll INF = 1LL << 60;

int main() {
    int n;
    cin >> n;
    vector<char> s(n), t(n), u(2 * n);
    for (int i = 0; i < n; i++) {
        cin >> s.at(i);
    }
    for (int i = 0; i < n; i++) {
        cin >> t.at(i);
    }

    for (int i = 0; i < n; i++) {
        u.at(2 * i) = s.at(i);

        u.at(2 * i + 1) = t.at(i);
    }
    for (int i = 0; i < n * 2; i++) {
        cout << u.at(i);
    }
    cout << endl;
    return 0;
}

Measured memory_bytes: 3628
#include <bits/stdc++.h>
using namespace std;
typedef long long int lli;
typedef unsigned long long int uli;
typedef long double Lf;
typedef pair<int,int> pii;
typedef vector<int> vi;
#define fastIO  std::ios::sync_with_stdio(false);cin.tie(NULL)
#define mod 1000000007
#define N 30005
#define NN 2005
#define SZ(x) ((lli) (x).size())
#define loop(i,s,n) for(int i=(s);i<(n);i++)
#define loopr(i,n,s) for(int i=(n)-1;i>=(s);i--)
#define pb push_back
#define o2(a,b) cout<<(a)<<" "<<(b)<<endl
#define o3(a,b,c) cout<<(a)<<" "<<(b)<<" "<<(c)<<endl
#define o4(a,b,c,d) cout<<(a)<<" "<<(b)<<" "<<(c)<<" "<<(d)<<endl
#define cl cout<<endl
#define r0 return 0
#define e0 exit(0)
#define x first
#define y second
#define endl "\n"


int main(){
    
	lli n;
	cin>>n;
	lli ans=n%10;
	if(ans==2 || ans==4 || ans==5 || ans==7 || ans==9)cout<<"hon"<<endl;
	if(ans==0 || ans==1 || ans==6 || ans==8)cout<<"pon"<<endl;
	if(ans==3)cout<<"bon"<<endl;
    return 0;
}

Measured memory_bytes: 3636
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int, int> pii;

ll n;
ll tsum = 0, total = 0;
ll MOD = 1e9 + 7;

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cin >> n;
	vector<ll> nums(n);
	for (int i = 0; i < n; i++)
	{
		cin >> nums[i];
		tsum = (tsum + nums[i]) % MOD;
	}
	for (int i = 0; i < n; i++)
	{
		tsum -= nums[i];
		if (tsum < 0)
			tsum += MOD;
		total = (total + tsum * nums[i]) % MOD;
	}
	cout << total;
}

Measured memory_bytes: 4764
N = int(input())
A = list(map(int, input().split()))
A.insert(0, 0)
A.append(0)
distance = []

for i in range(N+1):
    distance.append(abs(A[i+1]-A[i]))


dist_sum = sum(distance)

for i in range(1, N+1):
    result = dist_sum + abs(A[i-1] - A[i+1]) - ( abs(A[i-1] - A[i]) + abs(A[i] - A[i+1]) )
    print(result)

Measured memory_bytes: 14048
import java.util.*;
 
public class Main {
	public static void main(String[] args) {
    	Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int k = sc.nextInt();
        int p[] = new int[n];
        for(int i = 0; i < n; i++){
        	p[i] = sc.nextInt();
        }
        Arrays.sort(p);
        int sum = 0;
        for(int i = 0; i < k; i++){
        	sum += p[i];
        }
        System.out.println(sum);
    }
}

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

using namespace std;

double s(double x)
{
    return (x * x);
}

int main()
{
    int n, m;
    
    scanf("%d %d", &n, &m);
    
    double a[20], b[20], c[20];
    double ans = 0;
    
    for (int i = 0; i < n; i++){
        scanf("%lf %lf %lf", a + i, b + i, c + i);
    }
    
    for (int i = 0; i < 1 << n; i++){
        if (__builtin_popcount(i) != m) continue;
        
        double ta[20], tb[20], tc[20];
        int ctr = 0;
        for (int j = 0; j < n; j++){
            if (i >> j & 1){
                ta[ctr] = a[j];
                tb[ctr] = b[j];
                tc[ctr] = c[j]; ctr++;
            }
        }
        
        double tmp = 0;
        for (int j = 0; j < m; j++){
            for (int k = j + 1; k < m; k++){
                tmp += s(ta[j] - ta[k]) + s(tb[j] - tb[k]) + s(tc[j] - tc[k]);
            }
        }
        ans = max(ans, tmp);
    }
    
    printf("%.10f\n", ans);
    
    return (0);
}

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

const int INF = 1e9;
const int MOD = 1e9+7;
const ll LINF = 1e18;

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) for(int i=0;i<(n);++i)
#define REPR(i,n) for(int i=n;i>=0;i--)
#define ALL(v) (v.begin(),v.end())
#define COUT(x) cout<<(x)<<endl


int main(){
    ll n;
    cin >> n;
    ll num1 = 50;
    ll count = 0;
    if(n%2==0){
        count += n/10;
        while(num1<=n){
            count += n/num1;
            num1*=5;
        }
    }
    COUT(count);
    return 0;
}


Measured memory_bytes: 256
n = int(input())
k = int(input())

l = [int(i) for i in input().split()]
s = 0

for i in range(n):
  if k - l[i] >= l[i]:
    s += l[i]  * 2
 
  elif k - l[i] < l[i]:
    s += 2 * (k - l[i])
    
print(s)

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

#define ll long long int

int felicidad[100005][3];
ll memo[100005][3];
int N;

ll maxFeliz(int dia, int act){
	if(!dia) return felicidad[0][act];
	if(memo[dia][act]) return memo[dia][act];
	return memo[dia][act] = felicidad[dia][act]+
					max(maxFeliz(dia-1, (act+1)%3),
						maxFeliz(dia-1, (act+2)%3));
}

int feli[3];
ll mem [2][3];

ll calcFelicidad(){
	cin>>feli[0]>>feli[1]>>feli[2];
	mem[0][0] = feli[0];
	mem[0][1] = feli[1];
	mem[0][2] = feli[2];
	for(int i = 1; i<N; i++){
		cin>>feli[0]>>feli[1]>>feli[2];
		for(int k = 0; k<3;k++)
			mem[i&1][k] = feli[k]+max(mem[(i-1)&1][(k+1)%3],
								mem[(i-1)&1][(k+2)%3]);
	}
	return max(mem[(N-1)&1][0],
			   max(mem[(N-1)&1][1],mem[(N-1)&1][2]));
}


int main() {
	cin>>N;
	/*for(int i = 0; i<N; i++)
		cin>>felicidad[i][0]>>felicidad[i][1]>>felicidad[i][2];
	cout<<max(maxFeliz(N-1,0), max(maxFeliz(N-1,1), maxFeliz(N-1,2)))<<"\n";*/
	cout<<calcFelicidad()<<"\n";
	return 0;
}

Measured memory_bytes: 3612
#include <bits/stdc++.h>
#include <algorithm>
#define rep(i, n) for (int i=0; i<n; ++i)
#define all(obj) (obj).begin(),(obj).end()
using namespace std;
typedef long long ll;
long long GCD(long long x, long long y) { return y ? GCD(y, x%y) : x; }

int main(){
    while(1){
        string x;
        cin >> x;
        if(x=="0") return 0;
        int len = x.length();
        ll ans = 0;
        for(int i=0; i<len; ++i){
            ans += (int)x[i]-'0';
        }
        cout << ans << endl;
    }
}



Measured memory_bytes: 3156
#include<iostream>
#include<stdio.h>
#include<math.h>
#include<algorithm>
#include<vector>
#include<cstdlib>
#include<map>
#include<queue>
#include<stack>
#include<deque>
#include<fstream>
#include<string>
#include<sstream>
#include<iomanip>
#include<numeric>
#include<cctype>
#include<random>

using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
typedef long long int I;

int keta(int a){
    int count=0;
    while(a!=0){
        a/=10;
        count++;
    }
    return count;
}


int main(){
    long long int n,m;
    cin>>n>>m;
    if(n>m){
        rep(i,n){cout<<m;}
    }
    else{
        rep(i,m){cout<<n;}
    }
    cout<<endl;
    

    return 0;
} //カモンAC

Measured memory_bytes: 256
#include <bits/stdc++.h>
#pragma GCC optimize("unroll-loops,no-stack-protector")
#pragma GCC target("sse,sse2,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#define watch(x) cout << (#x) << " is " << (x) << endl
#define debug cout << "hi" << endl

using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;

ll gcd(ll a, ll b) {return (!b ? a : gcd(b, a % b));}
bool cmp(int a,int b){return a>b;}

const ll mod = 1e9 + 7;
const int INF32 = 1<<30;
const ll INF64 = 1LL<<60;
const ld pi = 3.141592653589793;
const int N = 1e6 + 10;

long long modpow(long long n, long long k, long long mod)
{
if (k == 0) return 1;
long long r = modpow(n * n % mod, k >> 1, mod);
if (k & 1) r = r * n % mod;
return r;
}

void solve(){
    ll l,r;
    cin >> l >> r;
    if(r-l<4){
        ll ans = l;
        for(ll i = l+1;i<=r;i++) ans = ans^i;
        cout << ans;
        return;
    }
    if((l^(l+1))!=1&&(r^(r-1))==1){
        if((r-l)%4) cout << (l^1);
        else cout << (l^0);
    }
    else if((l^(l+1))==1&&(r^(r-1))!=1){
        if((r-l)%4) cout << (r^1);
        else cout << (r^0);
    }
    else if((l^(l+1))!=1&&(r^(r-1))!=1){
        ll ans = (l^r);
        if((r-l-1)%4) cout << (ans^1);
        else cout << (ans^0);
    }
    else{
        if((r-l+1)%4) cout << 1;
        else cout << 0;
    }
}

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


Measured memory_bytes: 3640
#include <bits/stdc++.h>
#define fi first
#define se second
#define mp make_pair

using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
const double eps = 1e-8;
const int NINF = 0xc0c0c0c0;
const int INF = 0x3f3f3f3f;
const ll mod  = 1e9;
const ll N = 2e5 + 5;

int n;
double a[N],pre[N];

int main(){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cin>>n;
    map<pii,int> M;
    for(int i=0;i<n;i++){
        double x;cin>>x;
        ll y=llround(x*1e9);
        int c2=0,c5=0;
        while(y%2==0) y/=2,c2++;
        while(y%5==0) y/=5,c5++;
        M[{c2,c5}]++;
    }
    ll ans=0;
   	for(auto p1:M)
        for(auto p2:M)
            if(p1.fi.fi+p2.fi.fi>=18 && p1.fi.se+p2.fi.se>=18)
                if(p1<p2) ans+=1ll*p1.se*p2.se;
                else if(p1==p2) ans+=1ll*p1.se*(p1.se-1)/2;
    cout<<ans;
    return 0;
}

Measured memory_bytes: 3792
/*
** author:mahmoud magdy
*/
#include <bits/stdc++.h>
using namespace std;

#define ll long long
#define endl "\n"

inline int D()
{
    int m ;
    cin>>m;
    return m ;
}
inline ll lD()
{
    ll m ;
    cin>>m;
    return m ;
}
inline double dD()
{
    double m;
    cin>>m;
    return m;
}
void fast()
{
    ios_base :: sync_with_stdio( 0 ) ;
    cin.tie( 0 ) ;
    cout.tie( 0 ) ;
}
const int N=1e2+5;

int main()
{
 int a[4]={D(),D(),D()};
  int c1=0,c2=0;
 for(int i=0;i<3;++i){
    if(a[i]==7)c1++;
    else if(a[i]==5)c2++;
 }
 if(c2==2&&c1==1)cout<<"YES"<<endl;
 else cout<<"NO"<<endl;
}


Measured memory_bytes: 764
#include<iostream>
using namespace std;
int main () {
    
    int n;
    cin >> n;
    
    for (int j = 1; j <= n; j++ ) {
        
        if (j % 3 == 0) {
            
            cout << ' ' << j;
            
        } else if (j % 10 == 3) {
            
            cout << ' ' << j;
            
        } else if (j / 10 == 3 || (j / 10) % 10 == 3 || j / 100 == 3 || (j / 100) % 10 == 3 || (j / 100) % 100 == 3 || j / 1000 == 3) {
            
            cout << ' ' << j;
            
        }
        
    }
    cout << endl;
    
    return 0;
    
}


Measured memory_bytes: 3084
import java.util.Scanner;

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

	public static void solve(Scanner s) {
		int a = s.nextInt();
		int b = s.nextInt();
		int c = s.nextInt();

		int count5 = 0;
		int count7 = 0;

		if (a == 5) {
			count5++;
		} else if (a == 7) {
			count7++;
		}

		if (b == 5) {
			count5++;
		} else if (b == 7) {
			count7++;
		}

		if (c == 5) {
			count5++;
		} else if (c == 7) {
			count7++;
		}

		if (count5 == 2 && count7 == 1) {
			System.out.println("YES");
		} else {
			System.out.println("NO");
		}
	}
}

Measured memory_bytes: 9428
import java.util.Stack

fun main(args: Array<String>) {
  val n = readLine()!!.toInt()
  val a = readLine()!!.split(" ").map { it.toInt() }.toIntArray()
  val t = Array<MutableList<Int>>(n+1) { mutableListOf<Int>() }
  repeat(n-1) {
    val (u, v) = readLine()!!.split(" ").map { it.toInt() }
    t[u].add(v)
    t[v].add(u)
  }
  val stack = Stack<Int>()
  stack.push(1)
  var size = 0
  val pop = BooleanArray(n+1)
  val las = IntArray(n+1)
  val pos = IntArray(n+1)
  val par = IntArray(n+1)
  val lis = IntArray(n+1)
  val ans = IntArray(n+1)
  while (stack.isNotEmpty()) {
    val u = stack.pop()
    if (u > 0) {
      pos[u] = lis.lowerBound(a[u-1], 0, size)
      if (pos[u] == size) {
        pop[u] = true
        size++
      }
      las[u] = lis[pos[u]]
      lis[pos[u]] = a[u-1]
      stack.push(-u)
      ans[u] = size
      for (v in t[u]) {
        if (v == par[u]) continue
        par[v] = u
        stack.push(v)
      }
    } else {
      val v = -u
      if (pop[v]) size-- else lis[pos[v]] = las[v]
    }
  }
  ans.drop(1).forEach { println(it) }
}
fun IntArray.lowerBound(element: Int, fromIndex: Int, toIndex: Int): Int {
  val index = this.binarySearch(element, fromIndex, toIndex)
  return if (index < 0) -index-1 else index
}

Measured memory_bytes: 105268
#include<iostream>
#include<algorithm>
#include<cmath>
#include<map>
#include<stdio.h>
#include<vector>
using namespace std;
#define int long long
#define rep(s,i,n) for(int i=s;i<n;i++)
#define c(n) cout<<n<<endl;
#define ic(n) int n;cin>>n;
#define sc(s) string s;cin>>s;
#define mod 1000000007
#define inf 1000000000000000007
#define f first
#define s second
#define mini(c,a,b) *min_element(c+a,c+b)
#define maxi(c,a,b) *max_element(c+a,c+b)
//printf("%.12Lf\n",c);
int keta(int x){
	rep(0,i,30){
		if(x<10){
			return i+1;
		}
		x=x/10;
	}
}
int gcd(int x,int y){
	int aa=x,bb=y;
	rep(0,i,1000){
		aa=aa%bb;
		if(aa==0){
			return bb;
		}	
		bb=bb%aa;
		if(bb==0){
			return aa;
		}
	}
}	
int lcm(int x,int y){
	int aa=x,bb=y;
	rep(0,i,1000){
		aa=aa%bb;
		if(aa==0){
			return x/bb*y;
		}	
		bb=bb%aa;
		if(bb==0){
			return x/aa*y;
		}
	}
}
bool p(int x){
	if(x==1)return false;
	rep(2,i,sqrt(x)+1){
		if(x%i==0&&x!=i){
			return false;
		}
	}	
	return true;
}
int n2[41];		
int nis[41]; 
int nia[41];
int mody[41];
int nn;
int com(int n,int y){
	int ni=1;
	for(int i=0;i<41;i++){
		n2[i]=ni;
		ni*=2;
	}
	int bunsi=1,bunbo=1;
	rep(0,i,y)bunsi=(bunsi*(n-i))%mod;
	rep(0,i,y)bunbo=(bunbo*(i+1))%mod;
	mody[0]=bunbo;
	rep(1,i,41){
		bunbo=(bunbo*bunbo)%mod;
		mody[i]=bunbo;
	}
	rep(0,i,41)nis[i]=0;
	nn=mod-2;
	for(int i=40;i>=0;i-=1){
		if(nn>n2[i]){
			nis[i]++;
			nn-=n2[i];
		}
	}
	nis[0]++;
	rep(0,i,41){
		if(nis[i]==1){
			bunsi=(bunsi*mody[i])%mod;
		}
	}
	return bunsi;
}
int a[114],b[114];
int dp[114][114514];
signed main(){
	ic(n) ic(w)
	rep(0,i,n)cin>>a[i]>>b[i];
	rep(0,i,w+1)dp[0][i]=0;
	rep(0,i,n){
		rep(0,j,w+1){
			if(j>=a[i])dp[i+1][j]=max(dp[i][j-a[i]]+b[i],dp[i][j]);
			else dp[i+1][j]=dp[i][j];
		}
	}     	
	c(dp[n][w])
}	


Measured memory_bytes: 92160
#!/usr/bin/env python
# -*- coding: utf-8 -*-

def solve():
    n = int(input())
    li = [1]
    li.extend([6 ** i for i in range(1, 15) if 6 ** i <= n])
    li.extend([9 ** i for i in range(1, 15) if 9 ** i <= n])
    li.sort(reverse=True)

    cnt = 0
    s = set([n])
    bf = False
    while not bf:
        ts = set(s)
        for e in li:
            for c in s:
                if c - e == 0:
                    bf = True
                    break
                if c - e > 0:
                    ts.add(c - e)
            if bf:
                break
        if not bf:
            s = ts
        cnt += 1
    print(cnt)


if __name__=="__main__":
    solve()


Measured memory_bytes: 65636
#![allow(unused, non_snake_case, dead_code, non_upper_case_globals)]
use {
    proconio::{marker::*, *},
    std::{cmp::*, collections::*, mem::*},
};

#[fastout]
fn main() {
    input! {//
        n:usize,
       mut d:[i64;n],
    }
    d.sort();
    println!("{}", d[n / 2] - d[n / 2 - 1]);
}
pub trait BinarySearch<T> {
    fn lower_bound_by<F: Fn(&T) -> bool>(&self, f: F) -> usize;
    fn lower_bound(&self, x: &T) -> usize;
    fn upper_bound(&self, x: &T) -> usize;
}
impl<T: Ord> BinarySearch<T> for [T] {
    fn lower_bound_by<F: Fn(&T) -> bool>(&self, f: F) -> usize {
        let mut ng = -1;
        let mut ok = self.len() as i64;
        while (ok as i32 - ng as i32).abs() > 1 {
            let mid = (ok + ng) / 2;
            if f(&self[mid as usize]) {
                ok = mid;
            } else {
                ng = mid;
            }
        }
        ok as usize
    }
    fn lower_bound(&self, x: &T) -> usize {
        self.lower_bound_by(|y| y >= x)
    }
    fn upper_bound(&self, x: &T) -> usize {
        self.lower_bound_by(|y| y > x)
    }
}


Measured memory_bytes: 3836
#include <bits/stdc++.h>
using namespace std;
#define rep(i,a,b) for(int i=a;i<b;i++)
typedef long long ll;

// V??????, NV???????´???°, def????????????, comp???????????¢??°
template<class V, int NV> class SegTree {
public:
	vector<V> val;
	static V const def = 0;
	V comp(V l, V r) { return (l + r); };

	SegTree() { val = vector<V>(NV * 2, def); };
	V getval(int x, int y, int l = 0, int r = NV, int k = 1) {	// [x,y)
		if (r <= x || y <= l) return def;
		if (x <= l && r <= y) return val[k];
		return comp(getval(x, y, l, (l + r) / 2, k * 2), getval(x, y, (l + r) / 2, r, k * 2 + 1));
	}
	void update(int entry, V v) {
		entry += NV;
		val[entry] = v;
		while (entry>1) entry >>= 1, val[entry] = comp(val[entry * 2], val[entry * 2 + 1]);
	}
};

int main()
{
	int n, q; cin >> n >> q;
	SegTree<ll, 1<<20> st;
	rep(i, 0, q)
	{
		int c, x;
		ll y;
		cin >> c >> x >> y;

		if (c == 0)
		{
			st.update(x, y + st.getval(x, x+1));
		}
		else
		{
			cout << st.getval(x, y+1) << endl;
		}
	}
}

Measured memory_bytes: 19204
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
#define REP(i, start, end) for (ll i = start, i##Len = (end); i < i##Len; ++i)
#define REPR(i, start, end) for (ll i = start, i##Len = (end); i > i##Len; --i)
using ll = long long;
using namespace std;

int main()
{
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    int H, W, K;
    cin >> H >> W >> K;
    vector<vector<int>> board(H, vector<int>(W, 0));
    string s;
    int total = 0;

    REP(y, 0, H)
    {
        cin >> s;
        REP(x, 0, W)
        {
            board[y][x] = (s[x] == '#' ? 1 : 0);
            total += board[y][x];
        }
    }

    vector<int> cnt_h(H), cnt_v(W);
    REP(y, 0, H)
    REP(x, 0, W)
    {
        cnt_h[y] += board[y][x];
        cnt_v[x] += board[y][x];
    }

    int ans = 0;
    REP(y_bit, 0, 1 << H)
    REP(x_bit, 0, 1 << W)
    {
        int st = total;
        REP(y, 0, H)
        if ((1 << y) & y_bit) st -= cnt_h[y];
        REP(x, 0, W)
        if ((1 << x) & x_bit) st -= cnt_v[x];
        REP(y, 0, H)
        REP(x, 0, W) if ((1 << y) & y_bit && (1 << x) & x_bit) st += board[y][x];
        if (st == K)
            ++ans;
    }

    cout << ans << endl;
}


Measured memory_bytes: 3616
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cstring>

using namespace std;
typedef pair<string, int> psi;

// dp[step][potion(bit)] = max-remains-hp
int dp[1001][1 << 12];

int main(){
	while(true){
		int hp_init, hp_max;
		cin >> hp_init >> hp_max;
		if(hp_init == 0 && hp_max == 0){ break; }
		int R, C;
		cin >> R >> C;
		vector<string> field(R);
		for(int i = 0; i < R; ++i){ cin >> field[i]; }
		int T;
		cin >> T;
		vector<int> traps(26);
		for(int i = 0; i < T; ++i){
			string t;
			int d;
			cin >> t >> d;
			traps[t[0] - 'A'] = d;
		}
		int S;
		cin >> S;
		vector<psi> commands(S);
		for(int i = 0; i < S; ++i){ cin >> commands[i].first >> commands[i].second; }
		int P;
		cin >> P;
		vector<int> potions(P);
		for(int i = 0; i < P; ++i){ cin >> potions[i]; }
		vector<int> route;
		int x = 0, y = 0;
		for(int i = 0; i < S; ++i){
			int n = commands[i].second;
			int dx = 0, dy = 0;
			switch(commands[i].first[0]){
				case 'L': dx = -1; break;
				case 'R': dx =  1; break;
				case 'U': dy = -1; break;
				case 'D': dy =  1; break;
			}
			while(n--){
				x += dx; y += dy;
				route.push_back(traps[field[y][x] - 'A']);
			}
		}
		memset(dp, 0, sizeof(dp));
		dp[0][0] = hp_init;
		for(int i = 0; i < route.size(); ++i){
			int d = route[i];
//			cout << d << " |\t";
			for(int j = 0; j < (1 << P); ++j){
//				cout << dp[i][j] << "\t";
				if(dp[i][j] <= 0){ continue; }
				if(dp[i][j] - d > 0){
					dp[i + 1][j] = max(dp[i + 1][j], dp[i][j] - d);
				}
				for(int k = 0; k < P; ++k){
					if(j & (1 << k)){ continue; }
					int hp = min(dp[i][j] + potions[k], hp_max);
					dp[i][j | (1 << k)] = max(dp[i][j | (1 << k)], hp);
				}
			}
//			cout << endl;
		}
		bool found = false;
		for(int i = 0; i < (1 << P); ++i){
			if(dp[route.size()][i] > 0){
				found = true;
				break;
			}
		}
		cout << (found ? "YES" : "NO") << endl;
	}
	return 0;
}

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

int main() {
  ll N,d;
  const ll mod = 998244353;
  cin >> N;
  map<ll,ll> dmap;
  cin >> d;
  if (d != 0) {
    cout << 0 << endl;
    return 0;
  }
  else {
    ll ans = 1, dmax = 1;
    for (ll i = 1; i < N; ++i) {
      cin >> d;
      dmap[d] += 1;
      if (dmax < d) dmax=d;
    }
    if (dmap[0] > 0) { 
      cout << 0 << endl;
      return 0;
    }
    else {
      for (ll j = 1; j <= dmax-1; ++j) {
        const ll p = dmap[j];
        ll x = 1;
        for (ll k = 0; k < dmap[j+1]; ++k) x = (x*p)%mod;
        ans = (ans*x)%mod;
      }
      cout << ans << endl;
    }
  }
  return 0;
}


Measured memory_bytes: 6528
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  string S, T, U;
  int A, B;
  cin >> S >> T;
  cin >> A >> B;
  cin >> U;
  if (U == S)
    cout << A-1 << " " << B << endl;
  else
    cout << A << " " << B-1 << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
using namespace std;
int main()
{
    long n,s=0,min=0,max=0,a;
    cin>>n;
    for(int i=0;i<n;i++)
    {cin>>a;
    if(i==0) {
        min=a;max=a;
    }
s+=a;
if(min>a) min=a;
if(max<a) max=a;

    }
    cout<<min<<" "<<max<<" "<<s<<endl;
    
}


Measured memory_bytes: 3092
X,Y,_,_,_ = map(int, input().strip().split())
R = list(map(int, input().strip().split()))
G = list(map(int, input().strip().split()))
A = list(map(int, input().strip().split()))

apples = [(k, 'r') for k in R] + [(k, 'g') for k in G] + [(k, 'a') for k in A]
apples = sorted(apples, reverse=True)

ans = 0
flag = True
status = {k:0 for k in ['r','g','a']}

for score,color in apples:
  if color == 'r' and status['r'] < X:
    ans += score
    status['r'] += 1
  elif color == 'g' and status['g'] < Y:
    ans += score
    status['g'] += 1
  elif color == 'a':
    ans += score
    status['a'] += 1

  if status['r'] + status['g'] + status['a'] == X+Y: break

print(ans)


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

#define rep(i, n) REP(i, 0, n)
#define ALL(v) v.begin(), v.end()
#define MSG(a) cout << #a << " " << a << endl;
#define REP(i, x, n) for (int i = x; i < n; i++)
#define OP(m) cout << m << endl;

int main()
{
    int n;
    cin >> n;
    vector<int> a(n);
    rep(i, n) cin >> a[i];

    for (int i = a.size() - 1; i >= 0; i--)
    {
        cout << a[i];
        if (i != 0)
        {
            cout << " ";
        }
    }
    cout << endl;

    return 0;
}


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

int n,m,q,a[50],b[50],c[50],d[50],ans;
int p[10];

void dfs(int len,int pre){
    if(len==n){
        int sum=0;
        for(int i=0;i<q;i++) if(p[b[i]-1]-p[a[i]-1]==c[i]) sum+=d[i];
        ans=max(ans,sum);
        return;
    }
    for(int i=pre;i<=m;i++){
        p[len]=i;
        dfs(len+1,i);
    }
}

main()
{
    cin>>n>>m>>q;
    for(int i=0;i<q;i++) cin>>a[i]>>b[i]>>c[i]>>d[i];
    dfs(0,1);
    cout<<ans;
    return 0;
}


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

int main() {
    string s,t;
    cin  >> s >> t;
    int n = s.size();
    sort(s.begin(),s.end());
    sort(t.begin(),t.end());
    vector<tuple<char,int,int>> sv;
    vector<tuple<char,int,int>> tv;
    int count = 1;
    for(int i=0; i<n-1; i++){
        if(s.at(i) == s.at(i+1)){
            count++;
        }
        else{
            sv.push_back(make_tuple(s.at(i),count,-1));
            count = 1;
        }
    }
    sv.push_back(make_tuple(s.at(n-1),count,-1));
    count = 1;
    for(int i=0; i<n-1; i++){
        if(t.at(i) == t.at(i+1)){
            count++;
        }
        else{
            tv.push_back(make_tuple(t.at(i),count,-1));
            count = 1;
        }
    }
    tv.push_back(make_tuple(t.at(n-1),count,-1));
    vector<int> js;
    vector<int> jt;
    for(int i=0; i<sv.size(); i++){
        for(int j=0; j<tv.size(); j++){
            if(get<0>(sv.at(i)) == get<0>(tv.at(j)) && get<1>(sv.at(i)) == get<1>(tv.at(j))){
                get<2>(sv.at(i)) = 1;
                get<2>(tv.at(j)) = 1;
            }
        }
    }
    for(int i=0; i<sv.size(); i++){
        if(get<2>(sv.at(i)) == -1){
            js.push_back(get<1>(sv.at(i)));
        }
    }
    for(int i=0; i<tv.size(); i++){
        if(get<2>(tv.at(i)) == -1){
            jt.push_back(get<1>(tv.at(i)));
        }
    }
    sort(js.begin(),js.end());
    sort(jt.begin(),jt.end());
    if(js == jt) {
        cout << "Yes" << endl;
    }
    else{
        cout << "No" << endl;
    }
}

Measured memory_bytes: 776
#include <bits/stdc++.h>
using namespace std;
#define REP(i,n) for (int i = 0; i < n; i++)
typedef long long ll;
// Welcome to my source code!

int main() {
    int key;
    string com;
    priority_queue<int> PQ;

    while (1) {
        cin >> com;
        if (com == "insert") {
            cin >> key;
            PQ.push(key);
        } else if (com == "extract") {
            cout << PQ.top() << endl;
            PQ.pop();
        } else {
            break;
        }
    }
}


Measured memory_bytes: 7080
package main

import (
	"bufio"
	"fmt"
	"os"
	"sort"
	"strconv"
)

func out(x ...interface{}) {
	fmt.Println(x...)
}

var sc = bufio.NewScanner(os.Stdin)

func getInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}

func getString() string {
	sc.Scan()
	return sc.Text()
}

func min(a, b int) int {
	if a > b {
		return b
	}
	return a
}

func main() {
	sc.Split(bufio.ScanWords)
	sc.Buffer([]byte{}, 1000000)

	s := getString()
	K := getInt()
	sub := make([]string, 0)
	for i := 0; i < len(s); i++ {
		n := min(i+5, len(s))
		for j := i + 1; j <= n; j++ {
			sub = append(sub, s[i:j])
		}
	}

	sort.Strings(sub)
	prev := ""
	cnt := 0
	for _, v := range sub {
		if v == prev {
			continue
		}
		prev = v
		cnt++
		if cnt == K {
			break
		}
	}
	out(prev)
}


Measured memory_bytes: 2816
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<int,int>;
constexpr ll INF = 9e18;
constexpr int inf = 1e9;
constexpr double INFD = 1e100;
constexpr ll mod = 1000000007;
const double PI = 3.1415926535897932384626433832795028841971;
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
// ---------------------------------------------------------------------------

int main(){
  int N;
  cin >> N;
  vector<string> S(N);
  for(int i=0; i<N; i++){
    cin >> S[i];
  }
  int ans = 0;
  int A=0,B=0,AB=0;

  for(int i=0; i<N; i++){
    for(int j=0; j<S[i].size()-1; j++){
      if(S[i].substr(j,2) == "AB") ans++;
    }
    if(S[i][0] == 'B' && S[i][S[i].size()-1] == 'A'){
      AB++;
    }else if(S[i][0] == 'B'){
      B++;
    }else if(S[i][S[i].size()-1] == 'A'){
      A++;
    } 
  }
  if(AB){
    ans += AB-1;
    if(A){
      ans++;
      A--;
    }
    if(B){
      ans++;
      B--;
    }
  }
  ans += min(A,B);
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 768
#include<iostream>
#include<string>
using namespace std;
 int ora(char x){
	if(x=='y'||x=='u'||x=='i'||x=='o'||x=='p'||x=='h'||x=='j'||x=='k'||x=='l'||x=='n'||x=='m'){return 1;}
	return 0;
}
int main(){
	string s;
	while(true){
	cin>>s;
	if(s=="#")break;
	int cnt=0;
	bool flag;
	if(ora(s[0]))flag=true;
	else flag=false;
	for(int i=0;i<s.size();i++){
		if(flag!=ora(s[i]))cnt++;
		flag=ora(s[i]);
	}
	cout<<cnt<<endl;
	}
	return 0;
}

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

int main(){
    int n;
    int pos=1;
    int count=0;
    cin >> n;

    vector<int> vec(n);
    for (int i = 0; i < n; i++) {
        cin >> vec.at(i);
    }

    vector<int> flag(n);
    flag.at(0) =1;
    for(int i=0;i<n;i++){
        pos = vec.at(pos-1);
        if(flag.at(pos-1)==1){
            cout << -1 << endl;
            return 0;
        }
        flag.at(pos-1) =1;
        count += 1;
        if(pos==2){
            cout << count << endl;
            return 0;
        }
    }

    return 0;
}

Measured memory_bytes: 1024
N,M,*L = map(int, open(0).read().split())
dic = [[] for i in range(N+1)]
rdic = [[] for i in range(N+1)]
for a,b,c in zip(*[iter(L)]*3):
  dic[a].append(b)
  rdic[b].append(a)

ok1 = [False]*(N+1)
ok1[1] = True
q = [1]
while q:
  p = q.pop()
  for v in dic[p]:
    if not ok1[v]:
      ok1[v] = True
      q.append(v)
ok2 = [False]*(N+1)
ok2[N] = True
q = [N]
while q:
  p = q.pop()
  for v in rdic[p]:
    if not ok2[v]:
      ok2[v] = True
      q.append(v)
ok = [a&b for a,b in zip(ok1,ok2)]
cnt = 0
dist = [-10**20]*(N+1)
dist[1] = 0
while True:
  flag = True
  for a,b,c in zip(*[iter(L)]*3):
    if ok[a]&ok[b] and ok[a]!=-10**20 and dist[b]<dist[a]+c:
      flag = False
      dist[b] = dist[a]+c
  if flag:
    print(dist[N])
    break
  cnt += 1
  if cnt>N:
    print('inf')
    break

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

#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define FOR(i,n,m) for(int i=(int)(n); i<=(int)(m); i++)
#define RFOR(i,n,m) for(int i=(int)(n); i>=(int)(m); i--)
#define ITR(x,c) for(__typeof(c.begin()) x=c.begin();x!=c.end();x++)
#define RITR(x,c) for(__typeof(c.rbegin()) x=c.rbegin();x!=c.rend();x++)
#define setp(n) fixed << setprecision(n)

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 ll long long
#define vll vector<ll>
#define vi vector<int>
#define pll pair<ll,ll>
#define pi pair<int,int>

#define all(a) (a.begin()),(a.end())
#define rall(a) (a.rbegin()),(a.rend())
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define ins insert

using namespace std;

/* Some Libraries */

//-------------------------------------------------

int main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll a,b,c; cin>>a>>b>>c;
    ll B = c-a-b;
    if (B<0){
        cout<<"No\n";
        return 0;
    }
    if (a*b*4<B*B){
        cout<<"Yes\n";
    }else{
        cout<<"No\n";
    }
    return 0;
}


Measured memory_bytes: 256
import sys
input = lambda: sys.stdin.readline().rstrip()
input_nums = lambda: list(map(int, input().split()))

def main():
    X, Y, A, B, C = input_nums()
    P = input_nums()
    Q = input_nums()
    R = input_nums()
    P.sort(reverse=True)
    Q.sort(reverse=True)
    R.sort()

    P = sorted(P[:X])
    Q = sorted(Q[:Y])
    res = []
    res = P + Q + R
    res.sort(reverse=True)
    print(sum(res[:X+Y]))
if __name__ == '__main__':
    main()

Measured memory_bytes: 101672
#include <iostream>
#include <string>
#include <cstring>
#include <cstdio>
using namespace std;
string s; 
int main()
{
	cin>>s;
	if(s[0]=='R'&&s[1]=='R'&&s[2]=='R')cout<<3;
	else if(s[0]=='S'&&s[1]=='S'&&s[2]=='S')cout<<0;
	else if(s[0]=='S'&&s[1]=='R'&&s[2]=='S')cout<<1;
	else if(s[1]=='S')cout<<1;
	else cout<<2;
	cout<<endl;
	return 0;
}

Measured memory_bytes: 3628
(ns Atcoder.ABC088-B)
(require '[clojure.string :as str])
(def N (read-string (read-line)))                                         ; N
(def A (map read-string (str/split (read-line) #" ")))      ; A
(def A (sort > A))

(def alice (reduce + (map (fn [x] (nth A x)) (filter even? (range 0 N)))))
(def bob (reduce + (map (fn [x] (nth A x)) (filter odd? (range 0 N)))))

(println (- alice bob))

Measured memory_bytes: 66192
#include <iostream>
#include <deque>

using namespace std;

const int N = 1e5 + 10;

int nxt[N], dp[N];
string str;
int n, m;

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

  deque<int> deq;

  deq.push_back(n);
  dp[n] = 0;

  for (int i = n-1; i >= 0; --i) {
    if (str[i] == '1') continue;
    while (!deq.empty() && deq.back() > i+m) deq.pop_back();
    if (deq.empty()) {
      cout << (-1) << endl;
      return 0;
    }
    dp[i] = dp[deq.back()] + 1;
    nxt[i] = deq.back();
    while (!deq.empty() && dp[i] <= dp[deq.front()]) deq.pop_front();
    deq.push_front(i);
  }

  for (int u = 0; u != n; u = nxt[u]) {
    int gap = nxt[u] - u;
    cout << gap << " ";
  }
  cout << endl;

  return 0;
}


Measured memory_bytes: 1408
#include <iostream>
#include <string>
#include <algorithm>
#include <cstdio>
#include <vector>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <numeric>
#include <cmath>
#include <cassert>

using namespace std;

typedef long long int ll;
typedef pair<int,int> P;

#define rep(i,n) for(int i=0;i<(n);++i)
#define all(x) x.begin(),x.end()

const ll mod = 1e9+7;
const ll INF = 1e9;

ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};

vector<vector<int>> g;

int main()
{
	int n;
	cin>>n;
	g.resize(n);
	rep(i,n-1){
		int a,b;
		cin>>a>>b;
		a--;b--;
		g[a].push_back(b);
		g[b].push_back(a);
	}
	vector<int> c(n);
	rep(i,n)cin>>c[i];
	sort(all(c));
	reverse(all(c));

	vector<int> num(n,-1);

	num[0] = c[0];

	for (int k = 1; k < n; k++){
		bool flag = false;
		rep(i,n){
			if(num[i]<0) continue;
			rep(j,g[i].size()){
				if(num[g[i][j]]<0){
					num[g[i][j]] = c[k];
					flag = true;
					break;
				}
			}
			if(flag) break;
		}
	}


	cout<<accumulate(c.begin(),c.end(),0)-c[0]<<endl;
	rep(i,n)cout<<num[i]<<" ";
	cout<<endl;


	return 0;
}

Measured memory_bytes: 1024
#include<iostream>
#define rep(i, n) for(int i = 0; i < n; i++)
using namespace std;

int main(void){
    int n, d;
    cin >> n >> d;
    int J = 2 * d + 1;   //区間の幅
    int ans = 0;
    if(n % J == 0){
        ans = n / J;
    }else{
        ans = n / J + 1;
    }
    
    cout << ans << endl;
    return 0;
}

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

int main() {
  char c;
  cin >> c;
  if(c=='a'||c=='i'||c=='u'||c=='e'||c=='o'){
    cout << "vowel" << endl;
  }else{
    cout << "consonant" << endl;
  }
}


Measured memory_bytes: 256
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>
#include <cstring>
#include <limits>
#include <iomanip>

using namespace std;

int main(){
  int N,K;
  cin >> N >> K;
  int a[N];
  for(int i = 0 ; i < N; i++) cin >> a[i];
  int grundy[K+1];
  for(int i = 0; i <= K; i++){
     bool used[101];
     memset(used,false,sizeof(used));
     for(int j = 0 ; j < N; j++){
        if(a[j] > i) break;
        used[grundy[i-a[j]]]=true;
     }
     for(int j = 0 ; j < 101; j++){
        if(used[j] == false){
           grundy[i] = j;
           break;
        }
     }
  }
  if(grundy[K]==0){
     cout <<"Second"<<endl;
  }
  else{
     cout << "First"<<endl;
  }
  return 0;
}


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

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

int main(){
  int N;
  cin>>N;
  vector<int> A(N);
  int ce=0,co=0;
  rep(i,N){
    cin>>A[i];
    if(A[i]%2==0)ce++;
    else co++;
  }
  if(ce==N||co==N)cout<<0<<endl;
  else if(co%2==0)cout<<N-2<<endl;
  else cout<<N-1<<endl;

  return 0;
}



Measured memory_bytes: 3624
#include <bits/stdc++.h>
using namespace std;
#define IOS ios::sync_with_stdio(false); cin.tie(0);
#define FOR(i,s,n) for(int i = s; i < (n); i++)
#define REP(i,n) FOR(i,0,n)
#define ALL(n) (n).begin(), (n).end()
#define RALL(n) (n).rbegin(), (n).rend()
#define ATYN(n) cout << ( (n) ? "Yes":"No") << endl;
#define CFYN(n) cout << ( (n) ? "YES":"NO") << endl;
#define OUT(n) cout << (n) << endl;
using ll = long long;
using ull = unsigned long long;
using pii = pair<int,int>;

vector<vector<pii>> g;
vector<bool> visit;
vector<int> d;

bool dfs(const int &cnt,const int &par) {
    visit[cnt] = true;
    for(auto p:g[cnt]) {
        if (visit[p.first]) {
            if (d[cnt] != d[p.first] + p.second) return false;
        } else {
            d[p.first] = d[cnt] - p.second;
        }
    }
    for(auto p:g[cnt]) {
        if (visit[p.first]) continue;
        if (!dfs(p.first,cnt)) return false;
    }

    return true;
}

int main(void)
{
    IOS
    int n, m;
    cin >> n >> m;
    g.resize(n);
    visit.resize(n);
    d.resize(n);
    REP(i,m) {
        int l, r, d;
        cin >> l >> r >> d;
        l--;r--;
        g[l].push_back({r,d});
        g[r].push_back({l,-d});
    }

    bool ans = true;
    REP(i,n) {
        if (visit[i]) continue;
        if (!dfs(i,-1)) {
            ans = false;
            break;
        }
    }
    
    // REP(i,n) cout << i+1 << " " << d[i] << endl;

    ATYN(ans)

    return 0;
}

Measured memory_bytes: 12928