akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define FOR(i, begin, end) for(int i=(begin);i<(end);i++)
#define REP(i, n) FOR(i,0,n)
#define int long long
using namespace std;

typedef pair<int, int> Pii;

void readint(int N, vector<int> &a);
void readdouble(int N, vector<double> &a);
void readindex(int N, vector<int> &a);

#define MAX_V 1000
#define INF 1e10
struct edge { int to, cap, rev; };
vector<edge> G[MAX_V];
bool used[MAX_V];

void add_edge(int from, int to, int cap){
    G[from].push_back((edge){to, cap, G[to].size()});
    G[to].push_back((edge){from, 0, G[from].size() - 1});
}

int dfs(int v, int t, int f){
    if(v == t) return f;
    used[v] = true;
    REP(i, G[v].size()){
        edge &e = G[v][i];
        if(!used[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;
    while(true){
        memset(used, 0, sizeof(used));
        int f = dfs(s, t, INF);
        if(f == 0) return flow;
        flow += f;
    }
}


signed main(){

    int N;
    cin >> N;
    vector<int> a(N), b(N), c(N), d(N);
    REP(i, N){
        cin >> a[i] >> b[i];
    }
    REP(i, N){
        cin >> c[i] >> d[i];
    }

    int s = 0, t = 2 * N + 1;
    FOR(i, 1, N + 1){
        add_edge(s, i, 1);
    }
    FOR(i, N + 1, 2 * N + 1){
        add_edge(i, t, 1);
    }

    REP(i, N){
        REP(j, N){
            if(a[i] < c[j] && b[i] < d[j]) add_edge(i + 1, j + N + 1, 1);
        }
    }

    int ans = max_flow(s, t);

    cout << ans;
    
    return 0;
}








void readint(int N, vector<int> &a){
    string s;
    for(int i = 0; i < N - 1; i++){
        getline(cin, s, ' ');
        a[i] = atoi(s.c_str());
    }
    getline(cin, s, '\n');
    a[N - 1] = atoi(s.c_str());
}
void readdouble(int N, vector<double> &a){
    string s;
    for(int i = 0; i < N - 1; i++){
        getline(cin, s, ' ');
        a[i] = atof(s.c_str());
    }
    getline(cin, s, '\n');
    a[N - 1] = atof(s.c_str());
}
void readindex(int N, vector<int> &a){
    string s;
    for(int i = 0; i < N - 1; i++){
        getline(cin, s, ' ');
        a[i] = atoi(s.c_str()) - 1;
    }
    getline(cin, s, '\n');
    a[N - 1] = atoi(s.c_str()) - 1;
}

Measured memory_bytes: 512
import math
from collections import defaultdict
ml=lambda:map(int,input().split())
ll=lambda:list(map(int,input().split()))
ii=lambda:int(input())
ip=lambda:input()

"""========main code==============="""

t=ip()
if t[2]==t[3] and t[4]==t[5]:
    print("Yes")
else:
    print("No")


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

int main(){
  int n,k;
  cin>>n>>k;
  long double win = 0;
  for(int i = 1;i<=n;i++){
  	
  	if(i>=k){
  		win+=1.0/n*1.0;
  		continue;
  	}
  	
  	int face =i,heads=0;
    while(face<k){
    	face*=2;
      	heads++;
    }
    long long val = 1LL<<heads;
    win+=1.0/(1.0*val*n);
  }
  cout<<setprecision(12)<<win;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); i++)
#define irep(i, n) for (int i = (n); i >= 0; i++)
using namespace std;
using ll = long long;
using P = pair<int, int>;
const int INF = 1 << 30;
int n, k, x[100001]; 
int main() {
  cin >> n >> k;
  rep(i,n) cin >> x[i];
  int ans = INF;
  for (int i = 0; i + k <= n; i++)
  {
    int l = x[i], r = x[i+k-1];
    int now = min(abs(r)+abs(r-l), abs(l)+abs(r-l));
    ans = min(ans, now);
  }
  cout << ans << endl;
  
    return 0;
}

Measured memory_bytes: 3972
n=int(input())
a=list(map(int,input().split()))
money=1000
kabu=0
for i in range(n-1):
    if a[i]<a[i+1] and a[i]<=money:
        kabu+=money//a[i]
        money-=kabu*a[i]
    if a[i]>a[i+1] and kabu>0:
        money+=kabu*a[i]
        kabu=0
if kabu>0:
    money+=kabu*a[-1]
print(money)


Measured memory_bytes: 9132
// AOJ 3107 Spot The Difference
// 2019.9.23 bal4u

#include <stdio.h>

//// 入出力関係
#if 1
#define gc() getchar_unlocked()
#define pc(x) putchar_unlocked(x)
#else
#define gc() getchar()
#define pc(x) putchar(x)
#endif

int in() {  // 整数の入力
	int n = 0, c = gc();
	do n = 10*n + (c & 0xf), c = gc(); while (c >= '0');
	return n;
}

void ins(char *s) { // 文字列の入力　スペース以下の文字で入力終了
	do *s = gc();
	while (*s++ > ' ');
}

void out(int n) { // 非負整数の表示（出力）
	int i; char b[30];

	if (!n) pc('0');
	else {
		i = 0; while (n) b[i++] = n % 10 + '0', n /= 10;
		while (i--) pc(b[i]);
	}
	pc('\n');
}

int N, M;
char a[2005*2005];
char b[2005];

int main()
{
	int r, c, ans;
	char *p;

	N = in(), M = in();
	p = a, r = N; while (r--) ins(p), p += M;
	
	ans = 0, p = a, r = N; while (r--) {
		ins(b);
		c = M; while (c--) if (b[c] != p[c]) ans++;
		p += M;
	}
	out(ans);
	return 0;
}



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

int main(){
	int sum=0;
	int len;
	int x;
	
	while(1){
		string number;
		cin>>number;
		len=number.size();
		if(len==1 && (number[0]-48)==0)
			break;
		for(int i=0;i<len;i++){
			x=number[i]-48;
			sum+=x;
		}
		
	       cout<<sum<<endl;
	       sum=0;
	      }
}

Measured memory_bytes: 1188
s = gets.chomp
t = gets.chomp

ans = nil
(s.length - t.length + 1).times do |i|
    sr = s.dup
    result = true
    (t.length).times do |j|
        if s[i+j] == '?' || s[i+j] == t[j]
            sr[i+j] = t[j]
        else
            result = false
            break
        end
    end
    if result
        sr.gsub!('?', 'a')
        ans ||= sr
        ans = sr if ans > sr
    end
end

puts ans || 'UNRESTORABLE'

Measured memory_bytes: 2044
#include"bits/stdc++.h"
using namespace std;
#define LL long long
#define PB push_back
#define MP make_pair

//ベルマンフォード法
//更新はN-1回で済む(N回以上かかったら負の閉路あり)
//O(NM)

int N, M, P;
int A[5000], B[5000];
LL C[5000];
LL cost[2500];

int main(){
	cin >> N >> M;
	for(int i=0; i<M; i++){
		cin >> A[i] >> B[i] >> C[i];
		A[i]--; B[i]--;
		C[i] = - C[i];
	}
	for(int i=0; i<N; i++) cost[i] = LLONG_MAX/10000;
	cost[0] = 0;
	for(int i=0; i<N; i++){
		for(int j=0; j<M; j++){
			cost[B[j]] = min(cost[B[j]], cost[A[j]] + C[j]);
		}
	}
	for(int i=0; i<N*10; i++){
		for(int j=0; j<M; j++){
			if(B[j] == N-1 && cost[B[j]] > cost[A[j]] + C[j]){
				cout << "inf" << endl;
				return 0;
			}
			cost[B[j]] = min(cost[B[j]], cost[A[j]] + C[j]);
		}
	}
	cout << -cost[N-1] << endl;
}


Measured memory_bytes: 256
#include <stdio.h>

int main(void)
{
	int a;
	int b;
	int ans;
	int i;
	int k = 10;					
	int keta = 1;				
	
	while(scanf("%d %d",&a,&b) != EOF){
		ans = a + b;				
		
		while(1){
			if(i == 1) break;
				if((ans / k) < 1){		
					printf("%d\n",keta);
					i = 1;
				}
				keta++;
				k = k *10;
		}
		keta = 1;
		k = 10;
		i = 0;
	}
	
	return 0;
}

Measured memory_bytes: 1028
fun main(args: Array<String>) {
    val pw = java.io.PrintWriter(System.out)
    Problem.solve(java.util.Scanner(System.`in`), pw)
    pw.flush()
}

object Problem {
    lateinit var dfs: (v: Int, p: Int) -> Unit

    fun solve(sc: java.util.Scanner, pw: java.io.PrintWriter) {
        val N = sc.next().toInt()
        val tree = Array(N) { mutableListOf<Pair<Int, Int>>() }
        val ans = BooleanArray(N)
        repeat(N - 1) {
            val u = sc.next().toInt() - 1
            val v = sc.next().toInt() - 1
            val w = sc.next().toInt() % 2
            tree[u].add(Pair(v, w))
            tree[v].add(Pair(u, w))
        }

        dfs = { v, p ->
            tree[v].forEach {
                val next = it.first
                val w = it.second
                if (next != p) {
                    if (w == 1) {
                        ans[next] = !ans[v]
                    } else {
                        ans[next] = ans[v]
                    }
                    dfs(next, v)
                }
            }
        }
        dfs(0, -1)

        ans.forEach { pw.println(if (it) 1 else 0) }
    }
}


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

vector<int> g[100000];
int c[100000] = { 0 };

void paint(int v, int prevColor) {
	int curr = 1;

	for (int i = 0; i < g[v].size(); ++i) {
		if (curr == prevColor) {
			++curr;
		}

		c[g[v][i]] = curr;
		++curr;

		paint(g[v][i], curr - 1);
	}
}

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

	vector<int> l;
	for (int i = 0; i < n - 1; ++i) {
		int a, b;
		cin >> a >> b;

		g[a - 1].push_back(b - 1);
		l.push_back(b - 1);
	}

	paint(0, 0);

	int m = 0;
	for (int i = 1; i < n; ++i) {
		m = max(m, c[i]);
	}

	cout << m << endl;

	for (int li : l) {
		cout << c[li] << endl;
	}
	
	return 0;
}
	

Measured memory_bytes: 8572
#include<iostream>
#include<string>
#include<typeinfo>
#include<vector>
#include<algorithm>
#include<map>
#include<iomanip>
typedef long long int ll;
using namespace std;
int main()
{
	int H,W;
	cin >> H >> W;
	
	int board[H][W];
	for(int h=0; h<H; h++){
		for(int w=0; w<W; w++){
			board[h][w]=0;
		}
	}

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

	int tmph=0; 
	int tmpw=0;
	for(int i=0; i<N; i++){
		for(int j=0; j<a[i]; j++){
			board[tmph][tmpw]=i+1;
			if(tmph%2==0){
				if(tmpw==W-1){
					tmph++;
					tmpw=W-1;
				}else{
					tmpw++;
				}
			}else{
				if(tmpw==0){
					tmph++;
					tmpw=0;
				}else{
					tmpw--;
				}
			}
		}
	}

	for(int h=0; h<H; h++){
		for(int w=0; w<W; w++){
			cout << board[h][w] << " " ;
		}
		cout << endl;
	}
	return 0;
}

Measured memory_bytes: 384
n=int(input())
a=list(map(int,input().split()))
zero_in_a=(0 in a) #bool

if zero_in_a:
  tmp=[abs(i) for i in a]
  print(sum(tmp))
  exit()

minus_cnt=0
b=[]
for i in a:
  if i<0:
    minus_cnt+=1
    b.append(-i)
  else:
    b.append(i)

if minus_cnt%2==0:
  print(sum(b))
  exit()
  
c=min(b)
print(sum(b)-2*c)
    

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

vector<int> edges[100000];
vector<int> tree[100000];
int deg[100000];

bitset<100000> visited;
set<pair<int, int>> done;
vector<pair<int, int>> ans;

void dfs(int i){
    visited[i] = 1;
    for(int j : edges[i]){
        pair<int, int> p = {min(i, j), max(i, j)};
        if(done.count(p)) continue;
        done.insert(p);
        if(!visited[j]){
            tree[i].push_back(j);
            dfs(j);
        }else{
            deg[i]++;
            ans.emplace_back(i, j);
        }
    }
}

void dfs2(int i, int p){
    for(int j : tree[i]) dfs2(j, i);
    if(p == -1) return;
    if(deg[i]%2){
        ans.emplace_back(i, p);
    }else{
        ans.emplace_back(p, i);
        deg[p]++;
    }
}

int main(){
    int N, M;
    cin >> N >> M;
    for(int i=0; i<M; i++){
        int a, b;
        cin >> a >> b;
        edges[a-1].push_back(b-1);
        edges[b-1].push_back(a-1);
    }
    if(M%2){
        cout << -1 << endl;
        return 0;
    }
    dfs(0);
    dfs2(0, -1);
    for(auto& p : ans) cout << p.first+1 << " " << p.second+1 << endl;
}


Measured memory_bytes: 27764
main :: IO ()                                                                                                                                         
main = do                                                                                                                                             
  [a,b,k] <- map read . words <$> getLine                                                                                                             
  let g = gcd a b                                                                                                                                     
  print $ (!!(k-1)) . reverse . filter ((==0) . mod g) $ [1..g]

Measured memory_bytes: 508
#include<iostream> 
#include<cstdio> 
#include<cmath> 
using namespace std; 
int main(){
    double a,b,C;
    double x,y,y2,z,rad,PI;
    cin>>a>>b>>C;
    PI = acos(-1);
    rad=C * PI /180;
    x=a*b*sin(rad)/2;
    y=sqrt(a*a+b*b-cos(rad)*a*b*2);
    y2=a+b+y;
    z=2*x/a;
    printf("%f %f %f\n", x, y2, z);
    return 0;
}
    


Measured memory_bytes: 3572
#include <iostream>
#include <vector>
#include <stdio.h>
#include <atcoder/dsu>
#include <cstdio>

using namespace std;
using namespace atcoder;
int main()
{
    int N, M;
    cin >> N >> M;
    dsu d(N);
    for (int i = 0; i < M; i++)
    {
        int a = 0, b = 0;
        scanf("%d %d", &a, &b);
        d.merge(a - 1, b - 1);
    }
    vector<vector<int>> n = d.groups();
    int ans = n.size() - 1;
    cout << ans;
    return 0;
}

Measured memory_bytes: 9060
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using P = pair<ll, ll>;
using Pld = pair<ld, ld>;
using Vec = vector<ll>;
using VecP = vector<P>;
using VecB = vector<bool>;
using VecC = vector<char>;
using VecD = vector<ld>;
using VecS = vector<string>;
using Graph = vector<VecP>;
template <typename T>
using Vec1 = vector<T>;
template <typename T>
using Vec2 = vector<Vec1<T> >;
#define REP(i, m, n) for(ll i = (m); (i) < (n); ++(i))
#define REPN(i, m, n) for(ll i = (m); (i) <= (n); ++(i))
#define REPR(i, m, n) for(ll i = (m)-1; (i) >= (n); --(i))
#define REPNR(i, m, n) for(ll i = (m); (i) >= (n); --(i))
#define rep(i, n) REP(i, 0, n)
#define repn(i, n) REPN(i, 1, n)
#define repr(i, n) REPR(i, n, 0)
#define repnr(i, n) REPNR(i, n, 1)
#define all(s) (s).begin(), (s).end()
#define pb push_back
#define fs first
#define sc second
template <typename T>
bool chmax(T &a, const T b){if(a < b){a = b; return true;} return false;}
template <typename T>
bool chmin(T &a, const T b){if(a > b){a = b; return true;} return false;}
template <typename T>
ll pow2(const T n){return (1LL << n);}
template <typename T>
void cosp(const T n){cout << n << ' ';}
void co(void){cout << '\n';}
template <typename T>
void co(const T n){cout << n << '\n';}
template <typename T1, typename T2>
void co(pair<T1, T2> p){cout << p.fs << ' ' << p.sc << '\n';}
template <typename T>
void co(const Vec1<T> &v){for(T i : v) cosp(i); co();}
template <typename T>
void co(initializer_list<T> v){for(T i : v) cosp(i); co();}
template <typename T>
void ce(const T n){cerr << n << endl;}
void sonic(){ios::sync_with_stdio(false); cin.tie(0);}
void setp(const ll n){cout << fixed << setprecision(n);}
constexpr int INF = 1e9+1;
constexpr ll LINF = 1e18+1;
constexpr ll MOD = 1e9+7;
// constexpr ll MOD = 998244353;
constexpr ld EPS = 1e-11;
const ld PI = acos(-1);

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

VecS board;
Vec2<ll> dist;
ll h, w, k;
ll x1, y_1, x2, y2;

bool inBoard(ll x, ll y){
	return x >= 0 && x < h && y >= 0 && y < w && board[x][y] == '.';
}

ll solve(){
	queue<P> que;
	que.push({x1, y_1});
	while(!que.empty()){
		P p = que.front();
		que.pop();
		ll d = dist[p.fs][p.sc];
		rep(i, 4){
			ll x = p.fs, y = p.sc;
			rep(j, k){
				x += dx[i], y += dy[i];
				if(inBoard(x, y) && chmin(dist[x][y], d + 1)){
					que.push({x, y});
				}else if(inBoard(x, y) && dist[x][y] == d + 1)
					continue;
				else
					break;
			}
		}
	}
	return dist[x2][y2];
}

int main(void){
	cin >> h >> w >> k;
	board.resize(h);
	dist.resize(h);
	rep(i, h) dist[i].assign(w, LINF);
	cin >> x1 >> y_1 >> x2 >> y2;
	x1--, y_1--, x2--, y2--;
	dist[x1][y_1] = 0;

	rep(i, h) cin >> board[i];

	ll ans = solve();
	if (ans != LINF) co(ans);
	else
		co(-1);
	// rep(i, h) co(dist[i]);

	return 0;
}


Measured memory_bytes: 14340
#include <iostream>
#include <algorithm>
#include <string>
#include <cmath>
#include <vector>

using namespace std;
vector<int> v;
vector<int> v2;

int gcd(int a, int b)
{
	int c;

	if (a < b) {
		a += b; b = a - b; a -= b;
	}

	while (b != 0) {
		c = a % b;
		a = b;
		b = c;
	}

	return a;
}


int main() {
	
	int index = 0;

	int N,X;

	cin >> N >> X;



	for (int i = 0; i < N; i++)
	{
		int tmp;
		cin >> tmp;
		v.push_back(tmp);
	}
	
	sort(v.begin(), v.end());


	v2.push_back(abs(X - v[0]));

	for (int i = 0; i < N-1; i++)
	{
		v2.push_back(abs(v[i] - v[i+1]));
	}

	if (v2.size() == 1)
	{
		cout << v2[0] << endl;
		return 0;
	}

	int g = gcd(v2[0], v2[1]);


	for (int i = 2; i < v2.size(); i++)
	{
		g = gcd(g, v2[i]);
	}


	cout << g << endl;
	return 0;

}


Measured memory_bytes: 1400
n=int(input())
a=list(map(int,input().split()))
f=0
t=0
z=0
for i in range(n):
    if a[i]%4==0:
        f+=1
    elif a[i]%2==0:
        t+=1
    else:
        z+=1
flg=False
if t==0 and z-1<=f:
    flg=True
if z<=f and t>0:
    flg=True
if flg:
    print("Yes")
else:
    print("No")

Measured memory_bytes: 19992
#include "bits/stdc++.h"
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define all(s) s.begin(), s.end()
using namespace std;
typedef long long int ll;
typedef pair<int,int> P;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
typedef vector<string> vs;
const int MX = 100005, INF = 1001001001;
const ll LINF = 1e18;
const double eps = 1e-10;
const int DIV = 2e9+7;

int main() {
    int r;
    cin >> r;
    if (r < 1200) puts("ABC");
    else if (r < 2800) puts("ARC");
    else puts("AGC");
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main(){
    int q,w,e,i,a=0,s,z,y,x;
    cin>>q>>w>>e;
    for(i=1;i<=q;i++){
        s=1;
        y=i;
        while(y/10!=0){
            y/=10;
            s++;
        }
        z=0;
        x=i;
        for(y=0;y<s;y++){
            z+=x%10;
            x/=10;
        }
        if(z>=w&&z<=e)a+=i;
    }
    cout<<a<<endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <vector>
#include <valarray>
#include <map>
#include <set>
#include <list>
#include <queue>
#include <stack>
#include <bitset>
#include <utility>
#include <numeric>
#include <algorithm>
#include <functional>
#include <complex>
#include <string>
#include <sstream>

#include <cstdio>
#include <cstdlib>
#include <cctype>
#include <cstring>
#include <cmath>

using namespace std;

#define all(c) c.begin(),c.end()
#define repeat(i,n) for(int i=0;i<static_cast<int>(n);i++)
#define debug(x) #x << "=" << (x)
#define dump(x) cerr << debug(x) << " (L:" << __LINE__ << ")"<< endl

typedef long long ll;
typedef vector<int> vi;
typedef vector<vector<int> > vvi;
typedef vector<string> vs;

template<typename T>
ostream& operator<<(ostream& os, const vector<T>& vec){
    os << "[";
    for(int i = 0; i < vec.size(); i++){
        os << vec[i] << ",";
    }
    os << "]";
    return os;
}

template<typename T>
T input(){
    T t;
    cin >> t;
    return t;
}

template<typename T>
vector<T> input(const int N){
    vector<T> v(N);
    repeat(i,N) cin >> v[i];
    return v;
}

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

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

long long mul(const long long& a, const long long& b, const long long& mod) {
    return ((a % mod) * (b % mod)) % mod;
}

long long power(const long long& x, const long long& y, const long long& mod) {
    if (y == 0) {
        return 1;
    } else if (y == 1) {
        return x % mod;
    } else {
        long long value = power(x, y / 2, mod);
        if (y % 2 == 0) {
            return mul(value, value, mod);
        } else {
            return mul(value, value, mod) * x % mod;
        }
    }
}

long long div(const long long& a, const long long& b, const long long& mod) {
    return mul(a, power(b, mod - 2, mod), mod);
}

map<long long, long long> factorials;
long long factorial(const long long& n, const long long& mod) {
    if (n == 0 || n == 1) {
        return 1;
    }
    if (factorials[n] != 0) {
        return factorials[n];
    }
    factorials[n] = n * factorial(n - 1, mod) % mod;
    return factorials[n] % mod;
}

long long combination(const long long& n, const long long& x, const long long& mod) {
    long long numerator = 1;
    long long denominator = 1;
    repeat(i, x) {
        numerator *= (n - i) % mod;
        numerator %= mod;
        denominator *= (i + 1) % mod;
        denominator %= mod;
    }
    return div(numerator, denominator, mod);
}

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

    if (N.find('9') != string::npos) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define int long long
typedef pair<int,int> P;
int INF = 1e9+7;
int mod = 1e9+7;
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0 ,-1};
signed main() {
    string S;
    cin >> S;
    int a = 0;int b = 0;int c = 0;
    for(int i = 0; i < S.size(); i++) {
        if(S[i] == 'a')a++;
        if(S[i] == 'b')b++;
        if(S[i] == 'c')c++;
    }
    if(abs(a-b) <= 1 && abs(a-c) <= 1 && abs(b-c) <= 1) {
        cout << "YES" << endl;
    }
    else {
        cout << "NO" << endl;
    }
}


Measured memory_bytes: 3756
# include <bits/stdc++.h>
using namespace std;
const int N = 3e5 + 10;
int a[N] , f[N] , res; 
int main(){
	int n;
	cin >> n;
	for(int i = 1; i <= n; i ++) cin >> a[i];
	sort(a + 1 , a + n + 1);
	for(int l = 1; l <= n; l ++){
		int mx = l;
		for(int r = l + 1; r <= n; r ++){
			while(mx < n && a[mx + 1] < a[r] + a[l]) mx ++;
			res += mx - r;
		}
	}
	cout << res << "\n";
}

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

int main(){
  int n;
  cin >> n;
  
  string s;
  for(int i=0; i<n; i++){
    cin >> s[i];
  }
  int count =0;
  for(int i=0; i<=n-3; i++){
    if(s[i] == 'A' && s[i+1] == 'B' && s[i+2] == 'C'){
      count++;
    }
  }
  cout << count;

}


Measured memory_bytes: 256
import std.algorithm;
import std.array;
import std.ascii;
import std.container;
import std.conv;
import std.math;
import std.numeric;
import std.range;
import std.stdio;
import std.string;
import std.typecons;
void log(A...)(A arg) { stderr.writeln(arg); }
int size(T)(in T s) { return cast(int)s.length; }

void main() {
    int x = readln.chomp.to!int;
    writeln((x < 1200 ? "ABC" : "ARC"));
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define se second
#define fi first
#define ll long long
#define INF INT_MAX
#define mod 1000000007
#define chutiyaap ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
using namespace std;
ll pw(ll a, ll b) {
    if (b == 0) return 1;
    ll t = pw(a, b / 2);
    if (b % 2 == 0) return (t * t)%mod;
    else return ((t * t)%mod * a)%mod;
}
int main()
{
	int n;cin>>n;
	int a[n];for(int i=0;i<n;i++)cin>>a[i];
	sort(a,a+n);
	if(n<3)
	{
		cout<<0;
		return 0;
	}
    int count=0;
    int i=0;
    int j=i+1;
    while(i<n-2)
    {
        int k=j+1;
        while(k<n&&a[k]<a[i]+a[j])k++;
        count += k-j-1;
        j++;
        if(j>=n)
        {
            i++;
            j = i+1;
        }
    }
    cout<<count;
}


Measured memory_bytes: 3608
A, V = map(int, input().split())
B, W = map(int, input().split())
T = int(input())
if V == W:
  print("NO")
  exit()
if A > B:
  t1 = A
  A = B
  B = t1
if V < W:
#  print("A")
  print("NO")
  exit()
if (A + V*T) - (B + W*T) >= 0:
  print("YES")
  exit()
else:
  print("NO")
  exit()

Measured memory_bytes: 9168
#タスクを入力
task_list = list(map(int, input().split()))
task_list.sort()

#コストを計算
cost = 0
task_last = task_list[0]
for i in range(len(task_list)):
    cost += abs(task_list[i] - task_last)
    task_last = task_list[i]

#出力
print(cost)

Measured memory_bytes: 2940
#include <stdio.h>
#include <math.h>

int main(void)
{
    long n=0,count=0,min=0;
    scanf("%ld",&n);
    for(int i=1;i<=sqrt(n);i++){
        if(n%i==0){
            count=(i-1)+(n/i-1);
            if(min>count || min==0) min=count;
        }
    }
    printf("%ld",min);
    return 0;
}


Measured memory_bytes: 2132
a, b, k = map(int, input().split())
s = []
for i in range(k):
    if a + i <= b:
        s.append(a + i)
for i in range(k):
    if b - k + i + 1 >= a:
        s.append(b - k + i + 1)
s = list(set(s))
s.sort()
for i in s:
    print(i)

Measured memory_bytes: 3064
#include<stdio.h>
#include<stdlib.h>
#include<time.h>
#include<math.h>

#include<iostream>

using namespace std;

int main() {
  int a;
  cin >> a;

  int b;
  cin >> b;

  if (a+b==3) {
    cout << 3;
  }
  else if (a+b==5) {
    cout << 1;
  }
  else if (a+b==4) {
    cout << 2<<endl;
  }
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cmath>
#include <string>
#include <fstream>
#include <sstream>
#include <map>
#include <string.h>
#include <stdlib.h>
using namespace std;

const int INF = 1<<25;
typedef pair<int, char> P;

int main() {
	int n, q, year, month, day, d[100];
	string s1[100], s2[100];
	/*map<int, map<char, int> > t;
	map<int, map<char, int> > a;*/
	cin >> n;
	char c;
	for(int i = 0; i < n; ++i){
		cin >> s1[i];
		cin >> s2[i];
		scanf("%d%c%d%c%d", &year, &c, &month, &c, &day);
		/*	for(unsigned int j = 0; j < s1[i].size(); ++j)
			t[i][s1[i][j]] = 1;
		for(unsigned int j = 0; j < s2[i].size(); ++j)
			a[i][s2[i][j]] = 1;*/
		d[i] = year * 366 + month * 31 + day;
	}
	cin >> q;
	string st, sa, sf, sdt;
	for(int i = 0; i < q; ++i){
		if(i)
			cout << endl;
		cin >> st;
		cin >> sa;
		cin >> sf;
		cin >> sdt;
		for(int j = 0; j < n; ++j){
			if(st != "*"){
				if(s1[j].find(st, 0) == string::npos)
					continue;
			/*	
				bool ok = true;
				for(unsigned int k = 0; k < st.size(); ++k){
					if(t[j][st[k]] != 1){
						ok = false;
						break;
					}
				}
				if(!ok)
					continue;
			*/
			}
			if(sa != "*"){
				if(s2[j].find(sa, 0) == string::npos)
					continue;
			/*	
				bool ok = true;
				for(unsigned int k = 0; k < sa.size(); ++k){
					if(a[j][sa[k]] != 1){
						ok = true;
						break;
					}
				}
				if(!ok)
					continue;
			*/
			}
			int f = 0;
			if(sf == "*"){
				f = 1970 * 366 + 1 * 31 + 1;
			}
			else{
				int y = atoi(sf.substr(0, 4).c_str());
				int m = atoi(sf.substr(5, 2).c_str());
				int dd = atoi(sf.substr(8, 2).c_str());
				f = y * 366 + m * 31 + dd;
			}
			int dt = 0;
			if(sdt == "*"){
				dt = 2037 * 366 + 12 * 31 + 31;
			}
			else{
				int y = atoi(sdt.substr(0, 4).c_str());
				int m = atoi(sdt.substr(5, 2).c_str());
				int dd = atoi(sdt.substr(8, 2).c_str());
				dt = y * 366 + m * 31 + dd;
			}
			if(!(f <= d[j] && d[j] <= dt))
				continue;
			cout << s1[j] << endl;
		}
		
	}
	return 0;
}

Measured memory_bytes: 1280
package main

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

func main() {
	sc := bufio.NewScanner(os.Stdin)
	sc.Buffer([]byte{}, 100000000)
	sc.Scan()
	_ = sc.Text()
	sc.Scan()
	an := strings.Split(sc.Text(), " ")
	answer := make([]string, len(an))
	for i, a := range an {
		answer[mustAtoi(a)-1] = strconv.Itoa(i + 1)
	}
	fmt.Println(strings.Join(answer, " "))
}

func mustAtoi(s string) int {
	i, err := strconv.Atoi(s)
	if err != nil {
		panic(err)
	}
	return i
}


Measured memory_bytes: 7424
#include <stdio.h>

int main (){
	int q[101] = {}, c, a, n, x, i, j;
	scanf("%d", &x);
	for(i = 0; i < x; i++){
		scanf("%d %d %d", &c, &a, &n);
		while(c > 0 && a > 0 && n > 0){
			c--;
			a--;
			n--;
			q[i]++;
		}
		while(c >= 2 && a >= 1){
			c -= 2;
			a--;
			q[i]++;
		}
		while(c >= 3){
			c -= 3;
			q[i]++;
		}
	}
	for(i = 0; i < x; i++){
		printf("%d\n", q[i]);
	}
	return 0;
}

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

using namespace std;

int n;

void solve() {
  cin >> n;
  int unit = n % 10;

  if ((unit == 2) || (unit==4) || (unit==5) || (unit == 7) || (unit == 9)) {
    cout << "hon\n";
    return;
  } else if (unit == 3) {
    cout << "bon\n";
    return;
  }
  cout << "pon\n";
}

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


Measured memory_bytes: 3632
#include <bits/stdc++.h>
using namespace std;
//#include "testlib.h"
#define ff first
#define ss second
#define all(v) v.begin(),v.end()
#define int long long
#define ll long long
#define M 1000000007
#define MM 998244353
#define inputarr(a,n) for(int i=0;i<n;++i) cin>>a[i]
#define GCD(m,n) __gcd(m,n)
#define LCM(m,n) m*(n/GCD(m,n))
#define mii  map<ll ,ll >
#define sz(a) (int)a.size()
#define msi  map<string,ll >
#define rep(a,b)    for(ll i=a;i<b;i++)
#define rep0(n)    for(ll i=0;i<n;i++)
#define repi(i,a,b) for(ll i=a;i<b;i++)
#define pb push_back
#define vi vector<ll>
#define vs vector<string>
#define ppb pop_back
#define endl '\n'
#define asdf ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define r0 return 0;
#define FORD(i, a, b) for (int i = (int) (a); i >= (int) (b); --i)
#define inputoutput freopen("input.txt", "r", stdin);freopen("output.txt", "w", stdout);
#define Set(a, s) (a, s, sizeof (a))
#define FOR repi
#define pii pair<int,int>
#define REVERSE(v) reverse(all(v))
#define trav(a, x) for(auto& a : x)
#define display(x) trav(a,x) cout<<a<<" ";cout<<endl
#define debug cerr<<"bhau"<<endl
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
    std::cerr << name << " : " << arg1 << endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
    const char* comma = strchr(names + 1, ',');std::cerr.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
}
template<typename T, typename U> static inline void amin(T &x, U y) 
{ 
    if (y < x) 
        x = y; 
}
template<typename T, typename U> static inline void amax(T &x, U y) 
{ 
    if (x < y) 
        x = y; 
}
 
ll max(ll a, ll b) { return (a > b)? a : b;}
int min(int a, int b) { return (a < b)? a : b;} 
const int N=3e3+10;
int dp[N][N];

int solve(){
    dp[0][0]=1;
    int ans=0;
    int n;cin>>n;int s;cin>>s;
    int a[n];inputarr(a,n);
    for(int i=0,left=1,right=n;i<n;i++,left++,right--){
        // trace(i);
        if(a[i]==s){
            ans=(ans+left*right)%MM;
        }
        else if(a[i]<s){
            dp[i+1][a[i]]=left;
        }
        // trace(1);
        for(int sum=1;sum<s;sum++){
            // trace(sum,a[i]);
            if(sum+a[i]==s){
                ans+=(dp[i][sum]*right)%MM;
                ans%=MM;
            }
            else if(sum+a[i]<s){
                dp[i+1][sum+a[i]]+=dp[i][sum];
            }
        }
        for(int sum=0;sum<s;sum++) {dp[i+1][sum]=(dp[i+1][sum]+dp[i][sum])%MM;}
    }
    cout<<ans<<endl;
    // for(int i=1)



    return 0;
}
signed main(){
    asdf
    int t=1;
    // cin>>t;
    while(t--){
        solve();
    }
    return 0;
}


Measured memory_bytes: 70784
import sys
sys.setrecursionlimit(10**7)    

def vc(value,cost,pt):
    if value==1:
        if 0 in vcs.keys():
            vcs[0]=min(vcs[0],cost+d)     
        else:
            vcs[0]=cost+d     
        return value,cost+d
    elif value<=0:
        if 0 in vcs.keys():
            vcs[0]=min(vcs[0],cost)     
        else:
            vcs[0]=cost
        return cost
    
    if pt==1:
        v=value//2
        cost=cost+a+(value-v*2)*d
    elif pt==2:
        v=value//3
        cost=cost+b+(value-v*3)*d
    elif pt==3:
        v=value//5
        cost=cost+c+(value-v*5)*d
    elif pt==4:
        v=value//2+1
        cost=cost+a+(v*2-value)*d
    elif pt==5:
        v=value//3+1
        cost=cost+b+(v*3-value)*d
    elif pt==6:
        v=value//5+1
        cost=cost+c+(v*5-value)*d
    elif pt==7:
        v=0
        cost=cost+(value-v)*d
    return v,cost
    
def dfc(value,cost):
    if value==1:
        if 0 in vcs.keys():
            vcs[0]=min(vcs[0],cost+d)     
        else:
            vcs[0]=cost+d     
        return cost+d
    elif value<=0:
        if 0 in vcs.keys():
            vcs[0]=min(vcs[0],cost)     
        else:
            vcs[0]=cost
        return cost

    for i in range(7):
        value1,cost1=vc(value,cost,i+1)
#        print(i+1,":",value1,cost1)
        if value1 in vcs.keys():
            if vcs[value1]<=cost1:
                continue
            else:
                vcs[value1]=min(vcs[value1],cost1)     
                dfc(value1,cost1)
        else:
            vcs[value1]=cost1     
            dfc(value1,cost1)
        

t=int(input())
#t=1
for i in range(t):
    n,a,b,c,d=map(int,input().split())
#    n,a,b,c,d=11,1,2,4,8
#    n,a,b,c,d=11,1,2,2,8
#    n,a,b,c,d=32, 10, 8, 5, 4
#    n,a,b,c,d=29384293847243, 454353412, 332423423, 934923490, 1
#    n,a,b,c,d=900000000000000000, 332423423, 454353412, 934923490, 987654321
    
    vcs=dict()
    cost=dfc(n,0)
    print(vcs[0])

Measured memory_bytes: 117132
#include <stdio.h>
#include <iostream>
#include <string>
using namespace std;

int input(string, int);

int main() {
	string in;
	int a[10][10] = {};
	int x, y, s, n = 0, max;
	while (cin >> in) {
		x = input(in, 0);
		y = input(in, 1);
		s = input(in, 2);
		switch (s){
		case 3:
			if (x >= 2)
				a[x - 2][y]++;
			if (x <= 7)
				a[x + 2][y]++;
			if (y >= 2)
				a[x][y-2]++;
			if (y <= 7)
				a[x][y+2]++;
		case 2:
			if (x >= 1 && y >= 1)
				a[x - 1][y - 1]++;
			if (x >= 1 && y <= 8)
				a[x - 1][y + 1]++;
			if (x <= 8 && y >= 1)
				a[x + 1][y - 1]++;
			if (x <= 8 && y <= 8)
				a[x + 1][y + 1]++;
		}
		if (x >= 1)
			a[x - 1][y]++;
		if (x <= 8)
			a[x + 1][y]++;
		if (y >= 1)
			a[x][y - 1]++;
		if (x <= 8)
			a[x][y+1]++;
		a[x][y]++;
	}
	max = a[0][0];
	for (int i = 0; i < 100; i++) {
		if (a[i / 10][i % 10] == 0)
			n++;
		if (max < a[i / 10][i % 10])
			max = a[i / 10][i % 10];
	}
	cout << n << endl << max << endl;
	return 0;
}

/*
int main() {
	string in;
	int i;
	while (1) {
		cin >> in;
		cin >> i;
		cout<<input(in, i)<<endl;
	}
}
*/
int input(string in, int n) {
	int x = 0;
	for (int i = 0;; i++) {
		if (in[i] == ',' && n > 0) {
			n--;
			continue;
		}
		if (n > 0)
			continue;
		if (in[i] == ','|| in[i] == '\0')
			return x;
		x *= 10;
		x += in[i] - '0';
	}
}


Measured memory_bytes: 3124
N, Q = map(int, input().split())
S = input()
memo = [0]*(N+1)
for i in range(N-1):
    if S[i] == 'A' and S[i+1] == 'C':
        memo[i+1] = memo[i]+1
    else:
        memo[i+1] = memo[i]
ans = []
for _ in range(Q):
    l, r = map(int, input().split())
    ans.append(memo[r-1]-memo[l-1])

print('\n'.join(map(str, ans)))

Measured memory_bytes: 66136
A = [0] * 5
A[0] = int(input())
A[1] = int(input())
A[2] = int(input())
A[3] = int(input())
A[4] = int(input())
k = int(input())
exi = 0
for i in range(0,5):
    for j in range(i+1,5):
        if ((A[j]-A[i]) <= k):
            exi += 1
if (exi == 10):
    print("Yay!")
else:
    print(":(")

Measured memory_bytes: 3064
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cmath>
#include<string>
#include<cstring>

using namespace std;
int a,b,c;
int main()
{
	cin>>a>>b>>c;
	if(a>b)swap(a,b);
	if(a>c)swap(a,c);
	if(b>c)swap(b,c);
	if(b-a==c-b)cout<<"YES\n";
	else cout<<"NO\n";
	
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>

using namespace std;

int main()
{
    int a[3][3];
    for(int i=0;i<3;i++)
    {
        for(int j=0;j<3;j++)
        {
            scanf(" %c",&a[i][j]);
        }
    }

    int t=3;
    int i=0,j=0;
    while(t--)
    {
        //printf("i=%d,j=%d\n",i,j);
        printf("%c",a[i++][j++]);

    }
    printf("\n");
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<string.h>
 
typedef long long int ll;
#define all(x) (x).begin(), (x).end()
 
using namespace std;

int nxt() {
    int x;
    cin >> x;
    return x;
}

ll nxtl(){
    ll x;
    cin>>x;
    return x;
}
 
void SieveOfEratosthenes(int n,vector <int> &primes) 
{ 
    // Create a boolean array "prime[0..n]" and initialize 
    // all entries it as true. A value in prime[i] will 
    // finally be false if i is Not a prime, else true. 
    bool prime[n+1]; 
    memset(prime, true, sizeof(prime)); 
  
    for (int p=2; p*p<=n; p++) 
    { 
        // If prime[p] is not changed, then it is a prime 
        if (prime[p] == true) 
        { 
            // Update all multiples of p greater than or  
            // equal to the square of it 
            // numbers which are multiple of p and are 
            // less than p^2 are already been marked.  
            for (int i=p*p; i<=n; i += p) 
                prime[i] = false; 
        } 
    } 
  
    // Print all prime numbers 
    for (int p=2; p<=n; p++) 
       if (prime[p]) 
          primes.push_back(p);
} 
 
ll max(ll a,ll b)
{
    if(a>b)
        return a;
    return b;
}
 
ll power(ll x, ll y,ll mod) 
{ 
    ll temp; 
    if( y == 0) 
        return 1; 
    temp = power(x, y/2,mod); 
    if (y%2 == 0) 
        return (temp*temp)%mod; 
    else
        return (((x*temp)%mod)*temp)%mod; 
}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int n=nxt();
    ll ans=0;
    if(n==0)
    {
    	cout<<2<<endl;
    }
    else if(n==1)
    {
    	cout<<1<<endl;
    }
    else
    {
    	vector <ll> v(n+1);
    	v[0]=2;v[1]=1;
    	for(int i=2;i<=n;i++)
    		v[i]=v[i-1]+v[i-2];
    	cout<<v[n]<<endl;
    }
    
    return 0;   
}




 
 


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <math.h> 
#include <time.h>
using namespace std;
#define ll long long
#define rep(i,n) for(int i=0;i<n;i++)
const ll MOD=1000000007;
const long double PI=3.14159265358979;
const ll MAX=0;


bool IsPrime(ll num)
{
    if (num < 2) return false;
    else if (num == 2) return true;
    else if (num % 2 == 0) return false; // 偶数はあらかじめ除く

    double sqrtNum = sqrt(num);
    for (int i = 3; i <= sqrtNum; i += 2)
    {
        if (num % i == 0)
        {
            // 素数ではない
            return false;
        }
    }

    // 素数である
    return true;
}

vector<pair<long long,int>> PF(long long N){
  vector<pair<long long ,int>> ans(1,{0,0});
  long long n=N;
  for(int i=2;i<sqrt(n);i++){
    if(N%i==0){
      N/=i;
      if(ans.at(ans.size()-1).first==i){
        ans.at(ans.size()-1).second++;
      }
      else{
        ans.push_back({i,1});
      }
      i--;
    }
    if(N==1){
      break;
    }
  }
  if(N!=1){
    ans.push_back({N,1});
  }
  auto itr1=ans.begin();
  ans.erase(itr1);
  return ans;
}

int main() {
  int N,ans=1;
  cin>>N;
  ll a[N];
  vector<ll> b(0);
  rep(i,N){
    cin>>a[i];
  }
  ll g=a[0];
 // sort(a,a+N);
  rep(i,N){
    g=gcd(g,a[i]);
    if(g==1){
      break;
    }
  }
  if(g!=1){
    ans=0;
  }
  else {
    rep(i,N){
      if(IsPrime(a[i])){
        b.push_back(a[i]);
      }
      else{
    vector<pair<long long,int>> s=PF(a[i]);
    ll S=s.size();
    rep(j,S){
      b.push_back(s[j].first);
    }
      }
      if(clock()>1800000){
        ans=3;
        goto END;
      }
  }
  
  ll B=b.size();
  if(B>100000&&ans==1){
    ans=3;goto END;
  }
  sort(b.begin(),b.end());
  rep(i,B-1){
    if(b[i]==b[i+1]){
      ans*=2;
      break;
    }
  }
  }
  END:
  if(ans==0){
    cout<<"not coprime";
  }
  else if(ans==1){
   // goto J;
    cout<<"pairwise coprime";
   // J:
   // cout<<1;
  }
  else{
    cout<<"setwise coprime";
  }
  //out<<PF(1)[0].first;
}


Measured memory_bytes: 19416
#include <algorithm>
#include <cassert>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <vector>

#include <limits.h>

using namespace std;

typedef long long ll;

template<class T>
inline bool chmax(T &a, T b) {
    if(a < b) {
        a = b;
        return true;
    }
    return false;
}

template<class T>
inline bool chmin(T &a, T b) {
    if(a > b) {
        a = b;
        return true;
    }
    return false;
}

int main(void) {
    ll n;
    cin >> n;

    string ans = "";

    while (n != 0) {
        n--;
        int a = n % 26;
        ans.push_back('a' + a);
        n /= 26;
    }
    reverse(ans.begin(), ans.end());

    cout << ans << endl;

    return 0;
}


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

using namespace std;

int main()
{
  vector< int > E(4);
  for(int i = 0; i < 4; i++) {
    cin >> E[i];
  }
  sort(E.begin(), E.end());
  if(E[0] == E[1] && E[2] == E[3]) {
    cout << "yes" << endl;
  } else {
    cout << "no" << endl;
  }

}

Measured memory_bytes: 3140
#include <stdio.h>
      
int main(void){
  int i,temp,n;
      
  scanf("%d",&n);
  for(i=3;i<=n;i++){
    if(i%3==0)  printf(" %d",i);
    else if(i%10==3)  printf(" %d",i);
    else {
      temp=i;
      while(temp!=0){
        temp/=10;
        if(temp%10==3){
          printf(" %d",i);  break;
        }
      }
    }
  }
  printf("\n");
      
  return 0;
}

Measured memory_bytes: 600
import java.util.Scanner;
 
public class Main {
    public static void main(String[] args) {
        Scanner stdIn = new Scanner(System.in);
        
        while(stdIn.hasNext()){
            double a = stdIn.nextInt();
            double b = stdIn.nextInt();
            double c = stdIn.nextInt();
            double d = stdIn.nextInt();
            double e = stdIn.nextInt();
            double f = stdIn.nextInt();
            
            double x = (c * e - b * f) / (a * e - b * d);
            double y = (c * d - a * f) / (b * d - a * e);
			
            if(x == -0.0){
            	x = 0.0;
            }
            
            if(y == -0.0){
                y = 0.0;
            }
            
            System.out.printf("%.3f %.3f", x, y);
            System.out.println();
        }

        stdIn.close();
    }
}


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

#define max(a,b) ((a)>(b)?(a):(b))
#define min(a,b) ((a)<(b)?(a):(b))

typedef long long LL;

int main(){
  int n;
  cin >> n;
  int a,b;
  int ans=1000000;
  int wa;
  for(int i=1;i<=n-1;i++){
    a=i;
    b=n-i;
    wa=0;
    for(int j=1;j<7;j++){
      wa+=a%(int)pow(10,j)/(int)pow(10,j-1);
      wa+=b%(int)pow(10,j)/(int)pow(10,j-1);
    }
    ans=min(ans,wa);
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 384
from collections import Counter

n = int(input())
S = [input() for i in range(n)]

Min = min(S)
c = Counter(Min)
S.remove(Min)

ans = []
for i, j in c.items():
    flg = 0
    for k in range(j):
        if all((j-k) <= l.count(i) for l in S):
            for m in range(j-k):
                ans.append(i)
            break

ans.sort()
print(''.join(ans))

Measured memory_bytes: 3316
#include <algorithm>
#include <cstring>
#include <cstdio>
#define my_abs(x) ((x) < 0 ? -(x) : (x))
int lst[100005], to[200005], pre[200005], tot;
int fa[100005], col[100005], sum[100005], seq[100005], coef[100005];
inline void add_edge(int u, int v)
{
    to[tot] = v;
    pre[tot] = lst[u];
    lst[u] = tot++;
}
int getfa(int u)
{
    if (u == fa[u])
        return u;
    return fa[u] = getfa(fa[u]);
}
void dfs(int u, int c = 1, int f = -1)
{
    fa[u] = f;
    col[u] = sum[u] = c;
    for (int i = lst[u]; ~i; i = pre[i])
    {
        if (to[i] == f)
            continue;
        dfs(to[i], -c, u);
        sum[u] += sum[to[i]];
    }
}
int main()
try
{
    // freopen("AGC004-F.in", "r", stdin);
    memset(lst, -1, sizeof(lst));
    int n, m, x, y;
    scanf("%d%d", &n, &m);
    for (int i = 0; i < n; i++)
        fa[i] = i;
    for (int i = 0; i < m; i++)
    {
        int u, v;
        scanf("%d%d", &u, &v);
        if (getfa(--u) == getfa(--v))
        {
            x = u;
            y = v;
            continue;
        }
        fa[getfa(u)] = getfa(v);
        add_edge(u, v);
        add_edge(v, u);
    }
    dfs(0);
    long long ans = 0;
    if (m == n - 1)
    {
        if (sum[0])
            throw false;
    }
    else if (col[x] != col[y])
    {
        if (sum[0])
            throw false;
        for (int i = x; ~i; i = fa[i])
            coef[i]++;
        for (int i = y; ~i; i = fa[i])
            coef[i]--;
        int len = 0;
        for (int i = 0; i < n; i++)
        {
            if (coef[i])
                seq[len++] = -coef[i] * sum[i];
        }
        std::sort(seq, seq + len);
        int val = seq[len >> 1];
        ans += my_abs(val);
        for (int i = 0; i < n; i++)
            sum[i] += coef[i] * val;
    }
    else
    {
        if (sum[0] & 1)
            throw false;
        int val = sum[0] >> 1;
        ans += my_abs(val);
        for (int i = x; ~i; i = fa[i])
            sum[i] -= val;
        for (int i = y; ~i; i = fa[i])
            sum[i] -= val;
    }
    for (int i = 0; i < n; i++)
        ans += my_abs(sum[i]);
    printf("%lld\n", ans);
    return 0;
}
catch (bool)
{
    puts("-1");
    return 0;
}


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

#define fi first
#define se second
#define be begin
#define en end
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define ALL(a) (a).be() , (a).en()
#define REP(i,n) for(int (i)=0;(i)<(n);(i)++)        //repeat n times
#define REP2(i,s,n) for(int (i)=(s);(i)<(n);(i)++)   //repeat from s to n 
#define REPD(i,n) for(int (i)=(n);(i)>=0;(i)--)      //repeat from n to 0
#define REPD2(i,s,e) for(int (i)=(s);(i)>=(e);(i)--) //repeat from s to e
#define RANGE(i,v) for(auto &(i):v)                  //repeat range
#define ASIZE(a) (sizeof(a) / sizeof(a[0]))          //array size

using LL = long long;

template<typename T> using V = vector< T >;
using Vi = V<int>;
using Vll = V<LL>;
using Vs = V<string>;

Vs split_string(const string &s, char delim){
    Vs elements;
    string item;
    for(char ch : s){
        if(ch == delim){
            if(!item.empty()) elements.pb(item);
            item.clear();
        }else{
            item += ch;
        }
    }
    if(!item.empty()) elements.pb(item);
    return elements;
}

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

    auto splits = split_string(s,'/');
    if(stoi(splits[1])>4){
        cout<<"TBD"<<endl;
    }else{
        cout<<"Heisei"<<endl;
    }

    return 0;
}

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

using namespace std;

using ll = long long;
using vi = vector<int>;
using vll = vector<ll>;
using vvi = vector<vector<int>>;
using vvl = vector<vector<ll>>;

int main() {
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  ll n;
  cin >> n;
  if (n % 2) {
    cout << 0 << endl;
    return 0;
  }
  ll d5 = 0, d2 = 0;
  ll p5 = 1, p2 = 1;
  for (ll k = 0; k < 10000; k++) {
    p5 *= 5;
    d5 += n / p5 / 2;
    if (n / p5 == 0) break;
  }
  for (ll k = 0; k < 10000; k++) {
    p2 *= 2;
    d2 += n / p2;
    if (n / p2 == 0) break;
  }
  cout << min(d2, d5) << endl;

  return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include <cstdio>
#include <cstring>
#include <map>

const int N = 200000;

char s[N + 1];
std::map<int, int> mi;

int get(int msk)
{
    if (mi.count(msk)) {
        return mi[msk];
    }
    return N;
}

int add(int msk, int val)
{
    if (!mi.count(msk)) {
        mi[msk] = val;
    } else {
        mi[msk] = std::min(mi[msk], val);
    }
}

int main()
{
    scanf("%s", s);
    int n = strlen(s);
    int dp = 0;
    int msk = 0;
    for (int i = 0; i < n; ++ i) {
        add(msk, dp);
        msk ^= 1 << s[i] - 'a';
        dp = get(msk) + 1;
        for (int j = 0; j < 26; ++ j) {
            dp = std::min(dp, get(msk ^ (1 << j)) + 1);
        }
    }
    printf("%d\n", dp);
}


Measured memory_bytes: 9856
#include<bits/stdc++.h>
using namespace std;
#define debug(x) cout << '>' << #x << ':' << x << endl;
#define ll long long

int main() {
	ll n, m;
	scanf("%lld%lld", &n, &m);
	if (n == 1 && m == 1)
		return printf("1\n"), 0;
	if ((n == 1 && m > 1) || (m == 1 && n > 1))
		return printf("%lld\n", max(m, n) - 2), 0;
	printf("%lld\n", (n - 2) * (m - 2));
}


Measured memory_bytes: 3768
def main():
    n = int(input())
    v = list(map(int, input().split()))
    v_s = sorted(v)

    w = v_s[0]
    for i in range(1, n):
        w = (w + v_s[i])/2
    print(w)
    
if __name__ == '__main__':
    main()

Measured memory_bytes: 3064
import std.stdio, std.algorithm, std.string, std.conv, std.array, std.range, std.math;
int readint() { return readln.chomp.to!int; }
int[] readints() { return readln.split.to!(int[]); }


void main() {
    int n = readint();
    int[] b = readints();
    
    int[] a = b.dup;
    a.sort();
    int x = a[n/2], y = a[n/2 - 1];
    foreach (i; b) {
        writeln(i < x ? x : y);
    }
}

Measured memory_bytes: 12684