akhauriyash/Code-Regression huggingface dataset:
#include <stdio.h>

typedef struct{
    int id,parent,depth;
    int l,r;
    int sib,height;
}Node;

Node node[200000];

int dfs(int,int);

int main(){
    int i,j,k;
    int N;
    int id,l,r;
    int deg,root;

    scanf("%d",&N);
    for(i=0;i<N;i++) node[i].parent = node[i].l = node[i].r = node[i].sib = -1;

    for(i=0;i<N;i++){
        scanf("%d%d%d",&id,&l,&r);
        node[id].id = id;
        node[id].l = l;
        node[id].r = r;
        if(l!=-1){
            node[l].parent = id;
            node[l].sib = r;
        }
        if(r!=-1){
            node[r].parent=id;
            node[r].sib=l;
        }
    }

    for(i=0;i<N;i++) if(node[i].parent == -1) root=i;
    dfs(root,0);

    for(i=0;i<N;i++){
        deg = (node[i].l!=-1) + (node[i].r!=-1);
        printf("node %d: parent = %d, sibling = %d, degree = %d, depth = %d, height = %d, ",node[i].id,node[i].parent,node[i].sib,deg,node[i].depth,node[i].height);
        if(node[i].parent==-1) printf("root\n");
        else if(node[i].l == -1 && node[i].r == -1) printf("leaf\n");
        else printf("internal node\n");
    }
    return 0;
}

int dfs(int pos,int dep){
     node[pos].depth = dep;
     int a=0,b=0;
     if(node[pos].l!=-1) a=dfs(node[pos].l,dep+1);
     if(node[pos].r!=-1) b=dfs(node[pos].r,dep+1);
     node[pos].height = a<b? b:a;
     return node[pos].height+1;
 }


Measured memory_bytes: 2148
#include<iostream>
using namespace std;
int P[10010];
void init(int N)
{
  for (int i=0; i<=N; ++i) P[i] = i;
}

int root(int a)
{
  if (P[a] == a) return a;
  return (P[a] = root(P[a]));
}

bool is_same_set(int a, int b)
{
  return root(a) == root(b);
}

void unite(int a, int b)
{
  P[root(a)] = root(b);
}

int main()
{
  int n,q;
  cin>>n>>q;
  init(n);
  for(int i=0;i<q;i++)
    {
      int f,x,y;
      cin>>f>>x>>y;
      if(f==0)
	unite(x,y);
      if(f==1)
	 cout<< is_same_set(x,y)<<endl;;
    }
}

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

int t[105][10];
int score[105][11];

int main(){
    int n;
    cin >> n;
    rep(i,n)rep(j,10) cin >> t[i][j];
    rep(i,n)rep(j,11) cin >> score[i][j];

    int ans = -1e9;
    rep(sche,1<<10){
        if(sche==0) continue;
        int sum = 0;
        rep(i,n){
            int cnt = 0;
            rep(j,10) {
                //cout << (sche>>j&1) << endl;
                if(sche>>j&1 == t[i][j]) cnt++;
            }
            sum += score[i][cnt];
            //cout << cnt << endl;
        }
        ans = max(ans,sum);
    }

    cout << ans << endl;
}

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

#define fi first
#define se second
#define ll long long
#define pb push_back
#define mp make_pair
#define mt make_tuple

using namespace std;

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);

    int a, b, c;
    cin >> a >> b >> c;
    if(a == b && a != c) cout << "Yes";
    else if(a == c && a != b) cout << "Yes";
    else if(c == b && a != c) cout << "Yes";
    else cout << "No";

    return 0;
}


Measured memory_bytes: 256
n = int(input())
a = [int(input()) for _ in range(n)]

from collections import Counter

a_c = Counter(a)

first = max(a_c)
a_c[first] -= 1
second = max(+a_c)

for ai in a:
    if ai != first:
        print(first)
    else:
        print(second)


Measured memory_bytes: 29592
N = int(input())
A = list(map(int, input().split()))
from collections import Counter
C = Counter(A)
e = []
for k,v in C.items():
    if v >= 2: e.append(k)
    if v >= 4: e.append(k)
e.sort(reverse=True)
if len(e) >= 2:
    print(e[0]*e[1])
else:
    print(0)

Measured memory_bytes: 18316
x=int(input())

def hans(n):
    a=0
    for i in range(2,n):
        if n%i==0:
            a=a+1
    
    if a==0:
        return 1
    else:
        return 0

def maxs(n):
    for i in range(n,):
        if hans(n)==1:
            return n
        else:
            n=n+1
            continue

print(maxs(x))

Measured memory_bytes: 3060
import sys

def yn(b):
    print("Yes" if b==1 else "No")
    return

def resolve():
    readline=sys.stdin.readline
    n=int(readline().strip())
    ss=readline().strip()
    x=0
    maxx=x
    for s in ss:
      diff=1 if s=="I" else -1
      x+=diff
      maxx=max(maxx,x)
    print(maxx)

    return


resolve()

Measured memory_bytes: 3060
#include<iostream>
#include<algorithm>
#include<vector>
#include<string>
#include<cmath>
#include<queue>
#include<stack>
#include<map>
#include<numeric>

using namespace std;

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

template<typename A, typename B> bool chmin(A &a, const B &b){ return b < a && (a = b, true); }
template<typename A, typename B> bool chmax(A &a, const B &b){ return a < b && (a = b, true); }

int main () {
  int n;
  cin >> n;
  vector<tuple<string,int,int>> a(n);
  for (int i = 0; i < n; i++){
    cin >> get<0>(a[i]) >> get<1>(a[i]);
    get<2>(a[i]) = i+1;
    get<1>(a[i]) *= -1;
  } 
  sort(a.begin(), a.end());
  for (int i = 0; i < n; i++){
    cout << get<2>(a[i]) << '\n';
  }
  return 0;
}

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

int main() {
	int H,W;
	string t="";
	cin >> H >> W;
	vector<string> a(H);
	set<int> w,h;
	vector<bool> b(W,1);

	rep(i,H) {
		cin >> a.at(i);
		rep(j,W)
			if(a.at(i).at(j) == '#')
				b.at(j) = 0;
	}

	rep(i,W) {
		t += '.';
		if(b.at(i))
			w.insert(i);
	}
	rep(i,H)
		if(a.at(i) == t)
			h.insert(i);
	
	rep(i,H)
		if(!h.count(i)) {
			rep(j,W)
				if(!w.count(j))
					cout << a.at(i).at(j);
			cout << endl;
		}
}

Measured memory_bytes: 256
package main

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

type Scanner struct {
	sc *bufio.Scanner
}

func NewScanner() *Scanner {
	sc := bufio.NewScanner(os.Stdin)
	sc.Split(bufio.ScanWords)
	sc.Buffer(make([]byte, 1024), int(1e+9))
	return &Scanner{sc}
}

func (s *Scanner) nextStr() string {
	s.sc.Scan()
	return s.sc.Text()
}

func (s *Scanner) nextInt() int {
	i, e := strconv.Atoi(s.nextStr())
	if e != nil {
		panic(e)
	}
	return i
}

func (s *Scanner) nextRuneSlice() []rune {
	return []rune(s.nextStr())
}

func (s *Scanner) nextIntSlice(n int) []int {
	res := make([]int, n)
	for i := 0; i < n; i++ {
		res[i] = s.nextInt()
	}
	return res
}

func max(nums ...int) int {
	m := nums[0]
	for _, i := range nums {
		if m < i {
			m = i
		}
	}
	return m
}

func min(nums ...int) int {
	m := nums[0]
	for _, i := range nums {
		if m > i {
			m = i
		}
	}
	return m
}

func abs(x int) int {
	if x > 0 {
		return x
	}
	return -x
}

func pow(x, y int) int {
	res := 1
	for i := 0; i < y; i++ {
		res *= x
	}
	return res
}

func main() {
	sc := NewScanner()
	N, W := sc.nextInt(), sc.nextInt()
	weight := make([]int, N)
	value := make([]int, N)
	for i := 0; i < N; i++ {
		weight[i] = sc.nextInt()
		value[i] = sc.nextInt()
	}
	dp := make([][]int, N+1)
	for i, _ := range dp {
		dp[i] = make([]int, W+1)
	}
	for i := 0; i < N; i++ {
		for w := 0; w <= W; w++ {
			if w >= weight[i] {
				dp[i+1][w] = max(dp[i][w-weight[i]]+value[i], dp[i][w])
			} else {
				dp[i+1][w] = dp[i][w]
			}
		}
	}
	fmt.Println(dp[N][W])
}


Measured memory_bytes: 81792
//============================================================================
// Name        : t
// Date        : Wed Mar  6 11:22:36 CST 2019
// Author      : landcold7
// Description : Actions speak louder more than words
//============================================================================
#include "bits/stdc++.h"
using namespace std;

#define pb push_back
#define sz(x) ((int)(x).size())
#define all(x) (x).begin(), (x).end()
#define mst(x, y) memset(x, y, sizeof(x))
#define pvar(x) cout << #x << ": "
#define fora(e, c) for (auto &e : c)
#define fori(i, a, b) for (int i = a; i < b; ++i)
#define ford(i, a, b) for (int i = a; i > b; --i)
#define output(v) cout << (v) << '\n'
#define jam(x, n) cout << "Case #" << x << ": " << n << "\n"
#define prt(x, a, n) { cout << x[a]; if (a < n - 1) cout << " "; }
#define par(x, s, n, v) if(v) pvar(x); fori(y, s, n) prt(x, y, n) cout << "\n"

#ifndef __has_trace
#define trace(...)
#endif
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vi> vvi;
typedef vector<string> vs;
typedef pair<int, int> pii;
typedef vector<pii> vpii;

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

void add(int &a, int b) {
    a += b;
    if (a >= mod) {
        a -= mod;
    }
}
void solve() {
    int n; string s;
    cin >> n >> s;

    // dp[i][j] denotes the number of permutations of 1, 2, ... i
    // such that the last element is j and all the first i - 1
    // inequalities are fulfilled.
    vvi dp(n + 1, vi(n + 1));
    dp[1][1] = 1;
    fori (len, 2, n + 1) {
        vl pref(n + 1);
        fori (i, 1, len) {
            pref[i] = pref[i - 1] + dp[len - 1][i];
        }
        fori (j, 1, n + 1) {
            int lo, hi;
            if (s[len - 2] == '>') {
                lo = j, hi = len - 1;
            } else {
                lo = 1, hi = j - 1;
            }
            add(dp[len][j], (pref[hi] - pref[lo - 1] + mod) % mod);
            // fori (k, lo, hi + 1) {
            //     add(dp[len][j], dp[len - 1][k]);
            // }
        }
    }

    int ret = 0;
    fori (i, 1, n + 1) {
        add(ret, dp[n][i]);
    }
    output(ret);
}

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



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

typedef long long LL;
const int M=2e5+5;

int k;
int add(int x,int y)
{
	x+=y;
	if(x>=k) x-=k;
	return x;
}
int sub(int x,int y)
{
	x-=y;
	if(x<0) x+=k;
	return x;
}
int a[M],sum[M];

unordered_map<int,int> ma;

// a        1 4 2  3  5
// sum    0 1 5 7 10 15
// mod    0 1 1 3  2  3
// id     0 1 2 3  4  5
// mod-id 0 0 3 0  2  2

int main()
{
	int n; 
	scanf("%d%d",&n,&k);
	for(int i=1;i<=n;i++)
		scanf("%d",&a[i]);
	if(k==1)
	{
		printf("0\n");
		return 0;
	}
	LL ans=0;
	ma[0]++;
	for(int i=1;i<=n;i++)
	{
		sum[i]=add(sum[i-1],a[i]%k);
		ans+=ma[sub(sum[i],i%k)];
		ma[sub(sum[i],i%k)]++;
		// length of window < k
		if(i>=k-1)
			ma[sub(sum[i-k+1],(i-k+1)%k)]--;
	}
	printf("%lld\n",ans);
	return 0;
}

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

#define dump(x) cout << (x) << '\n'
#define Int int64_t
#define fi first
#define se second
#define all(x) (x).begin(), (x).end()
 
Int INF = 1e18;
int inf = 1e9;
Int mod = 1e9+7;

// mod付きコンビネーション
const int MAX = 5100000;
const int MOD = 1000000007;

Int fac[MAX], finv[MAX], inv[MAX];

// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

// 二項係数計算
Int COM(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

int main() {
    Int a, b, c, d;
    cin >> a >> b >> c >> d;
    COMinit();
    Int res = 0;
    for (Int i = a + 1; i <= c + 1; i++) {
        Int add = fac[i + d] * finv[i] % mod * finv[d] % mod;
        Int sub = fac[i + b - 1] * finv[i] % mod * finv[b - 1] % mod;
        res = (res + add - sub + mod) % mod;
    }
    dump(res);
    return 0;
}

Measured memory_bytes: 119808
#include <iostream>
#include <cmath>
#include <cstdio>
const double eps = 0.00001;
using namespace std;

int main(void) {
    int q;
    while (1) {
        cin >> q;
        if (q == -1) break;

        double bx = q/2.0;
        do {
            double ax = bx - (bx*bx*bx - q)/(3*bx*bx);
            bx = ax;
        } while (abs(bx*bx*bx-q) >= eps*q);
        printf("%.7f\n", bx);
    }

    return 0;
}

Measured memory_bytes: 1192
#include <bits/stdc++.h>
#define MOD 1000000007
#define INF 0x3f3f3f3f
#define EPS 1e-10
#define setNil(x) memset((x),0,sizeof(x))
#define setINF(x) memset((x),63,sizeof(x))
#define setNegINF(x) memset((x),192,sizeof(x)) //NegINF=-INF-1
#define setNeg1(x) memset((x),255,sizeof(x))
using namespace std;
int n;
long long fac[1000005],inv[1000005],ans;
inline long long fpow(long long x,int y){
	if(y==1)return x;
	long long t=fpow(x,y>>1);
	(t*=t)%=MOD;
	if(y&1)(t*=x)%=MOD;
	return t;
}
int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	cin>>n;
	for(int i=fac[0]=inv[0]=1;i<=n;i++){
		fac[i]=fac[i-1]*i%MOD;
		inv[i]=fpow(fac[i],MOD-2);
	}
	for(int i=(n+1)>>1;i<n;i++){
		(ans+=fac[i]*fac[i-1]%MOD*inv[2*i-n]%MOD)%=MOD;
	}
	cout<<(fac[n]-ans+MOD)%MOD<<endl;
	return 0;
}

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

using namespace std;

int main(){
    int n,k;
    cin>>n>>k;
    int a[n];
    long long sum=0ll;
    for(int i=0;i<n;i++){
        cin>>a[i];
        sum+=a[i]+0ll;
    }
    long long left=0ll,right=1e9+5ll;
    while(left<right){
        long long mid=(0ll+left+right)/2ll;
        bool ok=false;
        if(1ll*mid*(0ll+n+k)>=sum){
            int gr=0;
            for(int i=0;i<n;i++){
                gr+=(1ll*a[i]-1ll)/mid;
            }
            if(gr<=k){
                ok=true;
            }
        }
        if(ok){
            right=mid;
        }
        else{
            left=mid+1;
        }
        // cout<<left<<" "<<right<<endl;
    }
    cout<<left<<'\n';
    return 0;
}

Measured memory_bytes: 4384
#include <bits/stdc++.h>
using namespace std;
#define REP(i,N) for(i=0;i<N;i++)
#define MAX_I INT_MAX //1e9
#define MIN_I INT_MIN //-1e9
#define MAX_UI UINT_MAX //1e9
#define MAX_LL LLONG_MAX //1e18
#define MIN_LL LLONG_MIN //-1e18
#define MAX_ULL ULLONG_MAX //1e19
#define INF 1e9
  typedef long long ll;
  typedef pair<int,int> PII;
  typedef pair<char,char> PCC;
  typedef pair<ll,ll> PLL;
  typedef pair<char,int> PCI;
  typedef pair<int,char> PIC;
  typedef pair<ll,int> PLI;
  typedef pair<int,ll> PIL;
  typedef pair<ll,char> PLC;
  typedef pair<char,ll> PCL;

int main(void){
  int N,ColorType;cin >> N >> ColorType;
  int i,j,k;
  int ChengeCost[ColorType][ColorType];
  int InitGridColor[N][N];

  //変更のためのコスト
  REP(i,ColorType) REP(j,ColorType) cin >> ChengeCost[i][j];

  //(i+j)%3が同じやつのColorTypeの個数
  int nums[3][ColorType];
  //初期化
  REP(i,3) REP(j,ColorType) nums[i][j] = 0;

  //入力
  REP(i,N)REP(j,N){
     int x;
     cin >> x;x--;
     nums[(i+j)%3][x]++;
  }

  priority_queue<PII, vector<PII>, greater<PII> > que[3];
  REP(k,3){
    //iのものをjに変更する
    REP(j,ColorType){
      int sum = 0;
      REP(i,ColorType){
        if(i==j) continue;
        sum += ChengeCost[i][j]*nums[k][i];
      }
      que[k].push(PII(sum,j));
    }
  }

  //
  PII Cand[3][3];

  REP(k,3){
    REP(j,3){
      if(que[k].empty()) Cand[k][j] = PII(INF,ColorType);
      else Cand[k][j] = que[k].top();que[k].pop();
    }
  }

  int min = MAX_I;
  REP(i,3){
    REP(j,3){
      REP(k,3){
        if(Cand[0][i].second == Cand[1][j].second)continue;
        if(Cand[1][j].second == Cand[2][k].second)continue;
        if(Cand[2][k].second == Cand[0][i].second)continue;
        int sum = Cand[0][i].first + Cand[1][j].first + Cand[2][k].first;
        if(sum<min) min = sum;
      }
    }
  }
  cout << min << endl;
  return 0;
}


Measured memory_bytes: 256
import bisect
N,M,K = map(int,input().split())
a = list(map(int,input().split()))
b = list(map(int,input().split()))
A = [0]*(N+1)
B = [0]*(M+1)
for i in range(N):
    A[i+1] = A[i] + a[i] 
for i in range(M):
    B[i+1] = B[i] + b[i] 

possible = [0]
for i in range(N+1):
    ans = i
    nokori = K - A[i]
    if nokori < 0:
        break
    else:
        j = bisect.bisect_right(B,nokori)
        ans += j-1
        possible.append(ans)

print(max(possible))

Measured memory_bytes: 110972
# A = [list(map(int, input().split())) for _ in range(3)]
# k = int(input())
# B = [int(input()) for _ in range(n)]
# X = list(map(int, input().split()))
a, b, c = map(int, input().split())
if c-a-b < 0:
    print("No")
else:
    if 4*a*b < (c-a-b)**2:
        print("Yes")
    else:
        print("No")


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

using namespace std;

int main()
{
    string s, t;
    cin>>s>>t;
    int ans=INT_MAX;
    int n = s.size();
    int m=t.size();
    for(int i=0;i<=(n-m);++i){
        int c=0;
        for(int j=0;j<m;++j){
            if(s[i+j]!=t[j]){
                c++;
            }
        }
        ans = min(c, ans);
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 3568
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define ll long long
#define ld long double
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; }
using P=pair<long long,long long>;
#define rep(i,n) for(long long i=0; i<(long long)n; i++)
#define req(i,n) for(long long i=n-1; i>=0; i--)
#define range(i,a,b) for(long long i=a; i<b; i++)
#define all(x) (x).begin(), (x).end()
#define sz(x) ((long long)(x).size())
#define COUT(x) cout << x << endl
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define onBoard(y,x) (y>=0 && y<h && x>=0 && x<w)
#define vint vector<int>
#define pri_que priority_queue
#define vvint vector<vector<int>>
#define vstr vector<string>
#define vp vector<pair<int,int>>
#define vb vector<bool>
#define vvb vector<vector<bool>>
#define show(x) cout<<#x<<"="<<x<<endl;
#define SUM(x) accumulate(x.begin(),x.end(),0)
#define MAX(x) *max_element(x.begin(),x.end())
#define MIN(x) *min_element(x.begin(),x.end())
#define couty cout<<"Yes"<<endl
#define coutn cout<<"No"<<endl
#define coutY cout<<"YES"<<endl
#define coutN cout<<"NO"<<endl
#define yn(x) cout<<(x?"Yes":"No")<<endl
#define YN(x) cout<<(x?"YES":"NO")<<endl
long long gcd(long long a,long long b){return b?gcd(b,a%b):a;}
long long lcm(long long a, long long b){return a/gcd(a,b)*b;}
const long long dx[8]={1,0,-1,0,1,-1,-1,1};
const long long dy[8]={0,1,0,-1,1,1,-1,-1};
const long long INF = 1e12;
const long long MOD = 1e9+7;

signed main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cout<<fixed<<setprecision(15);

    int n; cin>>n;
    string s; cin >> s;
    vint sw(n+1,0);
    vint se(n+1,0);
    int w=0,e=0;
    rep(i,n){
        if(s[i]=='W'){
            w++;
            sw[i+1]=sw[i]+1;
            se[i+1]=se[i];
        }else{
            e++;
            sw[i+1]=sw[i];
            se[i+1]=se[i]+1;
        }
    }
    int res=INF;
    range(i,1,n+1){
        chmin(res,sw[i-1]+se[n]-se[i]);
    }
    cout<<res<<endl;
    // rep(i,n+1) cout<<sw[i]<<' '; cout<<endl;
    // rep(i,n+1) cout<<se[i]<<' '; cout<<endl;
}

Measured memory_bytes: 8200
#include <iostream>
#include <string>
#include <algorithm>
#include <functional>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <cstdio>
#include <cmath>
#include <tuple>
#include <iomanip>
#include <numeric>
#include <unordered_map>
#include <sstream>   
#include<limits.h>
#include<float.h>
#include<list>
#include <array>
#include <complex>
using namespace std;
#define i64  long long
#define int  long long
 
#define I32_MAX 2147483647
#define I64_MAX 9223372036854775807LL
#define I64_MAX2 1223372036854775807LL
#define INF I64_MAX2
#define MOD 1000000007
#define MEM_SIZE 10000
#define DEBUG_OUT true

// int DP[MEM_SIZE][MEM_SIZE] = {0};
// int GMEM[MEM_SIZE][MEM_SIZE] = {0};
template<typename T> void DEBUG(T e){if(DEBUG_OUT == false)return;std::cout << e << std::endl;}
template<class T> void DEBUG(string str, T e){if(DEBUG_OUT == false)return;std::cout <<str << ">>" << e << std::endl;}
template<typename T> void DEBUG(const std::vector<T>& v){if(DEBUG_OUT == false)return;for(const auto& e : v){ std::cout << e << " "; } std::cout << std::endl;}
template<typename T> void DEBUG(const std::vector<std::vector<T> >& vv){if(DEBUG_OUT == 1)return;for(const auto& v : vv){ DEBUG(v); } }
template <class T> void corner(bool flg, T hoge) {if (flg) {cout << hoge << endl; exit(0);}}
template< typename T1, typename T2 > inline bool chmax(T1 &a, T2 b) { return a < b && (a = b, true); }
template< typename T1, typename T2 > inline bool chmin(T1 &a, T2 b) { return a > b && (a = b, true); }
template<typename T> void SORT_(std::vector<T>& v,bool GREATER = 0){if(GREATER == 0)sort(v.begin(),v.end());else{sort(v.begin(),v.end(),std::greater<T>());}}


//CODE
void solve(void)
{
  int N;
  cin>>N;
  vector<int> vec(N);
  int MAX = -1*INF;
  int MIN = INF;
  int MAX_index,MIN_index;
  for (int i = 0; i < N; i++)
  {
    cin>>vec[i];
    if(chmax(MAX,vec[i]))MAX_index = i;
    if(chmin(MIN,vec[i]))MIN_index = i;
  }

  vector<vector<int> > ANS;
  int MODE;
  if(abs(MAX) > abs(MIN)) MODE = 0;
  else MODE = 1;
  for (int i = 0; i < N; i++)
  {
    vector<int> tmp(2);
    if(MODE == 0)
    {
      if(vec[i] < 0)
      {
        vec[i] += MAX;
      tmp[0] = MAX_index;
      tmp[1] = i;
      ANS.push_back(tmp);
      }
    }
    else
    {
      if(vec[i] > 0)
      {
        vec[i] += MIN;
      tmp[0] = MIN_index;
      tmp[1] = i;
      ANS.push_back(tmp);
      }
    }
  }

  for (int i = 0; i < N-1; i++)
  {
    vector<int> tmp(2);
    if(MODE == 0)
    {
      tmp[0] = i;
      tmp[1] = i+1;
      ANS.push_back(tmp);
    }
    else
    {
      tmp[0] = N-1-i;
      tmp[1] = N-2-i;
      ANS.push_back(tmp);
    }
  }
  // DEBUG("MAX",MAX);
  // DEBUG("MIN",MIN);
  // DEBUG(vec);
  cout<<ANS.size()<<endl;
  for (int i = 0; i < ANS.size(); i++)
  {
    cout<<ANS[i][0]+1<<" "<<ANS[i][1]+1<<endl;
  }
  
  

  

  

  
  
  return;
}


int32_t main(int32_t argc, const char *argv[])
{
  std::ios::sync_with_stdio(false);
  std::cin.tie(0);

  std::cout << std::fixed;
  std::cout << std::setprecision(9);
  solve();

 
  return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <vector>
#include <algorithm>
#include <cstring>
#include <cstdlib>

using namespace std;

int main() {
  int n;
  scanf("%d\n", &n);
  vector<int> a;
  for(int i=0; i<n; ++i) {
    int x;
    scanf("%d", &x);
    a.push_back(x);
  }
  sort(begin(a), end(a));
  int m = a[n-1];
  int r = a[0];
  int d = r <= m/2 ? r : m-r;
  for(int i=1; i<n-1; ++i) {
    int x = a[i];
    int dd = x <= m/2 ? x : m-x;
    if(d<dd) {
      d=dd;
      r=x;
    }
  }
  printf("%d %d\n", m, r);
}


Measured memory_bytes: 892
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
 
#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
#define MAXN 200001
 
ll gcd(ll a, ll b) {
    if(a < b) swap(a, b);
    if (b==0) return a;
    return gcd(b, a%b);
}
 
int main() {
    int n, a[MAXN], m, b[MAXN], mid;
 
    cin >> n;
 
    for (int i=0; i<n; i++) {
        cin >> a[i+1];
    }
 
    for (int i=n; i>=1; --i) {
        int sum = 0;
        for (int j=2*i; j<=n; j+=i) {
            sum ^= b[j];
        }
        b[i] = sum^a[i];
    }
 
    vector<int> ans;
    for (int i=1; i<=n; i++) {
        if (b[i]) ans.push_back(i);
    }
    cout << ans.size() << endl;
    for(int i=0; i<ans.size(); ++i) {
        cout << ans[i];
        if (i+1 != ans.size()) cout << " ";
    }
 
    cout << endl;
}

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

const int MAXN = 1e5+5;
int n, m, fa[MAXN];

struct EDGE
{
	int u, v;
}e[MAXN];

long long ans[MAXN], sz[MAXN];

int find(int x)
{
	if(x == fa[x])
		return x;
	return fa[x] = find(fa[x]);
}

int main()
{
	cin >> n >> m;
	
	for(int i = 1; i <= m; ++i)
		cin >> e[i].u >> e[i].v;
	for(int i = 1; i <= n; ++i)
		fa[i] = i, sz[i] = 1;
	
	ans[m] = (long long)n * (n - 1) / 2;
	
	for(int i = m; i >= 1; --i)
	{
		int u = find(e[i].u), v = find(e[i].v);
		
		if(u == v)
			ans[i - 1] = ans[i];
		else
		{
			ans[i - 1] = ans[i] - sz[v] * sz[u];
			sz[v] += sz[u];
			fa[u] = v;
		}
	}
	
	for(int i = 1; i <= m; ++i)
		cout << ans[i] << endl;
	
	return 0;
}

Measured memory_bytes: 4096
#include <bits/stdc++.h>
using namespace std;
using lint = long long;
template<class T = int> using V = vector<T>;
template<class T = int> using VV = V< V<T> >;

int main() {
  cin.tie(nullptr); ios::sync_with_stdio(false);
  int a, b; cin >> a >> b;
  if (a < 10 and b < 10) {
    cout << a * b << '\n';
  } else {
    cout << -1 << '\n';
  }
}

Measured memory_bytes: 256
#include <iostream>
#include <cmath>
#include <string>
#include <algorithm>
#include <set>
#include <vector>
#include <map>
#include <list>
#include <stack>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <queue>
#define pye cout << "yes" << endl
#define pno cout << "no" << endl
#define pYe cout << "Yes" << endl
#define pNo cout << "No" << endl
#define pYE cout << "YES" << endl
#define pNO cout << "NO" << endl
#define prin(num) cout << num << endl
#define max(a, b) ((a)>(b) ? (a):(b))
#define min(a, b) ((a)<(b) ? (a):(b))
#define mp make_pair
#define INF 100000000000
#define MOD 1000000007LL
#define MAX 100005
#define NIL -1
#define WHITE 0
#define BLACK 1
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
typedef map<ll, ll> Map;
class Edge {
public:
    ll t;
    ll w;
    Edge() {}
    Edge(ll t, ll w): t(t), w(w) {}
};


int main(void) {
    ll N;
    ll a[100000];
    ll s[100000];
    ll i;
    cin >> N;
    for(i=0; i<N; i++) {
        cin >> a[i];
    }
    sort(a, a+N);
    
    for(i=0; i<N; i++) {
        if(i==0) s[i]=a[i];
        else s[i]=s[i-1]+a[i];
    }
    
    for(i=N-2; i>=0; i--) {
        if(s[i]*2<a[i+1]) {
            prin(N-i-1);
            return 0;
        }
    }
    
    prin(N);
    
}


Measured memory_bytes: 1792
import java.util.Scanner;
public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int n=sc.nextInt(),a=sc.nextInt(),b=sc.nextInt(),sum=0,sumb=0;
    String s=sc.next();
    for(int i=0;i<s.length();i++) {
    	if(s.substring(i, i+1).equals("a")&&sum<a+b) {
    		System.out.println("Yes");
    		sum++;
    	}else if(s.substring(i, i+1).equals("b")&&sum<a+b&&sumb+1<=b) {
    		System.out.println("Yes");
    		sum++;
    		sumb++;
    	}else {
    		System.out.println("No");
    	}
    }
  }
}


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

using namespace std;
typedef long long ll;

#define INF (long long)(10e9+7)
#define REP(i,n) for(ll i = 0; i < n; i++)
#define REP1(i,n) for(ll i = 1; i <= n; i++)

int main(void)
{
    int a, b;
    cin >> a >> b;
    if(a == 1) a = 14;
    if(b == 1) b = 14;
    if(a > b) {
        cout << "Alice" << endl;
    } else if(a < b) {
        cout << "Bob" << endl;
    } else {
        cout << "Draw" << endl;
    }
}


Measured memory_bytes: 256
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

macro_rules! input_inner {
    ($iter:expr) => {};
    ($iter:expr, ) => {};
    ($iter:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($iter, $t);
        input_inner!{$iter $($r)*}
    };
}

macro_rules! read_value {
    ($iter:expr, ( $($t:tt),* )) => {
        ( $(read_value!($iter, $t)),* )
    };
    ($iter:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()
    };
    ($iter:expr, chars) => {
        read_value!($iter, String).chars().collect::<Vec<char>>()
    };
    ($iter:expr, usize1) => {
        read_value!($iter, usize) - 1
    };
    ($iter:expr, $t:ty) => {
        $iter.next().unwrap().parse::<$t>().expect("Parse error")
    };
}

//

fn run() {
    input! {
        n: usize,
        p: [(f64, f64); n],
    }
    let mut ans = 0f64;
    for (i, a) in p.iter().enumerate() {
        for b in p[..i].iter() {
            let dx = a.0 - b.0;
            let dy = a.1 - b.1;
            ans += (dx * dx + dy * dy).sqrt();
        }
    }
    ans = ans * 2f64 / n as f64;
    println!("{:.9}", ans);
}

fn main() {
    run();
}


Measured memory_bytes: 4352
#include <iostream>
#include <stdio.h>

using namespace std;

int n;

int main(){
    cin >> n;
    for(int i=1;i <= n;i++){
        if(!(i%3)){
            cout << " " << i;
            continue;
        }
        for(int j=i;j!=0;j/=10){
            if(j%10 == 3){
                cout << " " << i;
                break;
            }
        }

    }
    cout << endl;
    
    return 0;
}


Measured memory_bytes: 3100
#include<bits/stdc++.h>
using namespace std;
#define FOR(i,l,r) for(long long i=(l);i<(r);++i)
#define REP(i,n) FOR(i,0,n)
#define REPS(i,n) FOR(i,1,n+1)
#define int long long
#define mp make_pair
#define pb push_back
#define eb emplace_back
const int MOD=1e9+7;
const int INF=1e18;
const int MAX=200001;
int fac[MAX],finv[MAX],inv[MAX];
 
void COMinit(){
    fac[0]=fac[1]=1;
    finv[0]=finv[1]=1;
    inv[1]=1;
    for(int i=2;i<MAX;i++){
        fac[i]=fac[i-1]*i%MOD;
        inv[i]=MOD-inv[MOD%i]*(MOD/i)%MOD;
        finv[i]=finv[i-1]*inv[i]%MOD;
    }
}
 
int COM(int n,int k){
    if(n<k)return 0;
    if(n<0||k<0)return 0;
    return fac[n]*(finv[k]*finv[n-k]%MOD)%MOD;
}

signed main(){
    COMinit();
  	int N,K;cin>>N>>K;
    vector<int>A(N);
    REP(i,N)cin>>A[i];
    sort(A.rbegin(),A.rend());
    int ans=0;
    for(int i=0;i<=N-K;i++){
        ans+=A[i]*COM(N-i-1,K-1);
        ans%=MOD;
    }
    sort(A.begin(),A.end());
    for(int i=0;i<=N-K;i++){
        ans-=A[i]*COM(N-i-1,K-1);
        ans%=MOD;
    }
    while(ans<0)ans+=MOD;
    cout<<ans<<endl;
}

Measured memory_bytes: 5760
#include<iostream>
#include<algorithm>
#define N 105
using namespace std;

int n;
int M[N][N];
int main()
{
	cin >> n;
	int u, v;
	for (int i = 0; i < n; i++)
	{
		int s;
		cin >> u >> s;
		for (int j = 0; j < s; j++)
		{
			cin >> v;
			M[u][v] = 1;
		}
	}
	for (int i = 1; i <= n; i++)
	{
		for (int j = 1; j <= n; j++)
		{
			if (j > 1)
				cout << ' ';
			cout << M[i][j];
		}
		cout << endl;
	}
	return 0;
}


Measured memory_bytes: 3112
function Main(input) {
 var a=0;
 var str=input.split("\n");
 var str2=str[1].split(" ");
 for(i=0;i<str[0];i++){
  if(str2[i]%2==1)a++;
 }   
 if(a%2==0)console.log("YES");
 else console.log("NO");

}
 
Main(require("fs").readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 27944
#include <iostream>
#include <cstdio>
using namespace std;
long long n, di, ans;
int main()
{
    cin >> n;
    for(long long i = 10; ; i *= 10){
        if(n % i == n){
            di = i / 10;
            break;
        }
    }
    if(di == 1){
        for(long long i = 1; i <= n; i++){
            ans++;
        }
        cout << ans;
    }else if(di == 10){
        cout << 9;
    }else if(di == 100){
        for(long long i = 100; i <= n; i++){
            ans++;
        }
        cout << 9 + ans;
    }else if(di == 1000){
        cout << 909;
    }else if(di == 10000){
        for(int i = 10000; i <= n; i++){
            ans++;
        }
        cout << 909 + ans;
    }else if(di == 100000){
        cout << 90909;
    }
    return 0;
}


Measured memory_bytes: 256
import java.io.*;
import java.util.*;
class Main{
	static final long MOD = 1_000_000_007; // 10^9+7
    static final int MAX = 2_147_483_646; // intMax 
    static final int INF = 1_000_000_000; // 10^9  
    public static void main(String[] args) throws Exception {
		hayami saori = new hayami();
		int n = saori.saori_hayami();
		int m = saori.saori_hayami();
		int[] l = new int[m];
		int[] r = new int[m];
		for(int i = 0;i < m;i++){
			l[i] = saori.saori_hayami();
			r[i] = saori.saori_hayami();
		}
		int ans = 0;
		Arrays.sort(l);
		Arrays.sort(r);
		ans = r[0] - l[l.length-1];
		if(ans < 0){
			ans = 0;
		} else {
			ans += 1;
		}
		System.out.println(ans);
		
		saori.close();
    }
}

class hayami implements Closeable {
	private final InputStream in = System.in;
	private final byte[] hayami = new byte[1024];
	private int Hayami = 0;
	private int saori = 0;
	private boolean HayamiSaori() {
		if (Hayami < saori) {
			return true;
		}else{
			Hayami = 0;
			try {
				saori = in.read(hayami);
			} catch (IOException e) {
				e.printStackTrace();
			}
			if (saori <= 0) {
				return false;
			}
		}
		return true;
	}
	private int SaoriHayami() { 
		if (HayamiSaori()) {
            return hayami[Hayami++];
         }else{
             return -1;
         }
	}
	private static boolean hayami_saori(int hayami) { 
		return 33 <= hayami && hayami <= 126;
	}
	public boolean hayamisaori() { 
		while(HayamiSaori() && !hayami_saori(hayami[Hayami])) Hayami++; return HayamiSaori();
	}
	public String nextHayami() {
		if (!hayamisaori()) throw new NoSuchElementException();
		StringBuilder hayamin = new StringBuilder();
		int saori = SaoriHayami();
		while(hayami_saori(saori)) {
			hayamin.appendCodePoint(saori);
			saori = SaoriHayami();
		}
		return hayamin.toString();
	}
	public long saorihayami() {//nextLong
		if (!hayamisaori()) throw new NoSuchElementException();
		long hayami = 0;
		boolean misao = false;
		int saori = SaoriHayami();
		if (saori == '-') {
			misao = true;
			saori = SaoriHayami();
		}
		if (saori < '0' || '9' < saori) {
			throw new NumberFormatException();
		}
		while(true){
			if ('0' <= saori && saori <= '9') {
				hayami *= 10;
				hayami += saori - '0';
			}else if(saori == -1 || !hayami_saori(saori)){
				return misao ? -hayami : hayami;
			}else{
				throw new NumberFormatException();
			}
			saori = SaoriHayami();
		}
	}
	public int saori_hayami() {//nextInt
		long hayami = saorihayami();
		if (hayami < Integer.MIN_VALUE || hayami > Integer.MAX_VALUE) throw new NumberFormatException();
		return (int) hayami;
	}
	public double Hayamin() { //nextDouble
		return Double.parseDouble(nextHayami());
	}
	public void close() {
		try {
			in.close();
		} catch (IOException e) {
		}
    }
    
}

Measured memory_bytes: 23384
#include<iostream>
using namespace std;
typedef long long ll;
int main()
{
	ll sum,n;
	while(cin>>n)
	{
		sum=0;
		for(int i=1;i<n;i++)
		{
			sum+=i;
		}
		cout<<sum<<endl;
	}
	return 0;	
} 

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <math.h>
#define ALL(a)    a.begin(), a.end() 
#define rep(i, K, N)  for(int i = K; i < N; i++)
#define ll long long int
using namespace std;
int main() {
string S;cin >> S;

ll N, count = 0;cin >> N;

deque<char> D(S.size());

rep(i, 0, S.size())D[i] = S[i];

rep(i, 0, N){
  
    ll T;cin >> T;

    if(T == 1)count++;

    if(T == 2){

    ll F;cin >> F;
    char C;cin >> C;

        if(F == 1){

            if(count%2 == 0)D.push_front(C);

            else D.push_back(C);

        }

        if(F == 2){

            if(count%2 == 0)D.push_back(C);

            else D.push_front(C);

        }

    }
 
}

if(count%2 == 1)reverse(ALL(D));

rep(i, 0, D.size())cout << D[i];
}

Measured memory_bytes: 3984
import java.util.*;
class Main{
	public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
      int[] a = {1,1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
      int b = sc.nextInt();
      int c = a[b];
      System.out.println(c);
    }
}

Measured memory_bytes: 22608
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.StringTokenizer;
import java.io.IOException;
import java.util.InputMismatchException;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        TaskC solver = new TaskC();
        solver.solve(1, in, out);
        out.close();
    }

    static class TaskC {
        public void solve(int testNumber, InputReader in, PrintWriter out) {
            int n = in.nextInt();
            int[] a = in.nextIntArray(n);

            if (a[0] != 0) {
                out.println(-1);
                return;
            }

            long ans = 0;
            for (int i = 1; i < n; i++) {
                if (a[i] > a[i - 1] + 1) {
                    out.println(-1);
                    return;
                }

                if (a[i] == a[i - 1] + 1) {
                    ans++;
                } else {
                    ans += a[i];
                }
            }

            out.println(ans);
        }

    }

    static class InputReader {
        BufferedReader in;
        StringTokenizer tok;

        public String nextString() {
            while (!tok.hasMoreTokens()) {
                try {
                    tok = new StringTokenizer(in.readLine(), " ");
                } catch (IOException e) {
                    throw new InputMismatchException();
                }
            }
            return tok.nextToken();
        }

        public int nextInt() {
            return Integer.parseInt(nextString());
        }

        public int[] nextIntArray(int n) {
            int[] res = new int[n];
            for (int i = 0; i < n; i++) {
                res[i] = nextInt();
            }
            return res;
        }

        public InputReader(InputStream inputStream) {
            in = new BufferedReader(new InputStreamReader(inputStream));
            tok = new StringTokenizer("");
        }

    }
}



Measured memory_bytes: 46128
while 1:
    ans = 0
    n = int(input())
    if n == 0:
        break
    flag = True
    while n != 6174:
        ans += 1
        num = [n-n//10*10, n//10-n//100*10, n//100-n//1000*10, n//1000]
        a = sorted(num)
        b = sorted(num, reverse = True)
        if a == b:
            print("NA")
            flag = False
            break
        n = 0
        for i in range(4):
            n += (a[i]-b[i])*10**i
    if flag:
        print(ans)


Measured memory_bytes: 5616
#include<iostream>
#include<algorithm>
#include<cstring>
#include<cstdio>
#include<cmath>
#include<cstdio>
using namespace std;
string st;
int main()
{
	cin>>st;
	for(int i=0;i<st.size()-8;i++)cout<<st[i];
	cout<<endl;
	return 0;
}

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

using namespace std;

int N, K;
int x[100000];
int a = 3 * (int)1e8;

int main(){
	cin >> N >> K;
	for(int i = 0; i < N; ++i) cin >> x[i];
	for(int i = 0; i < N - K + 1; ++i) a = min(a, min(abs(x[i]) + abs(x[i + K - 1] - x[i]), abs(x[i + K - 1]) + abs(x[i + K - 1] - x[i])));
	cout << a << endl;
}

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


int main()
{
	int n,f;
	cin >> n;
	vector<int> a(n/2);
	vector<int> b(n/2);
	for (int i = 0; i < n/2; i++) {
		cin >> a[i] >> b[i];
	}
	sort(a.begin(), a.end());
	sort(b.begin(), b.end());
	int am = 1;
	int bm = 1;
	int amax = 0;
	int bmax = 0;
	int as = 0;
	int bs=0;

	int ac = a[0];
	int amaxn = a[0];
	int bc = b[0];
	int bmaxn = b[0];
	for (int i = 1; i < n/2; i++) {
		if (ac == a[i])am++;
		else {
			if (am > amax) {
				as = amax;
				amax = am;
				amaxn = a[i - 1];
			}
			else if (am > as)as = am;

			ac = a[i];
			am = 1;
		}
		if (bc == b[i])bm++;
		else {
			if (bm > bmax) {
				bs = bmax;
				bmax = bm;
				bmaxn = b[i - 1];
			}
			else if (bm > bs)bs = bm;

			bc = b[i];
			bm = 1;
		}
		
	}
	if (amax == 0)amax = am;
	if (bmax == 0)bmax = bm;

	if (amaxn != bmaxn)f = n - amax - bmax;
	else if (as + bmax > bs + amax)f = n - bmax - as;
	else f = n - amax - bs;
	cout << f << endl;
	return 0;

}

Measured memory_bytes: 640
#include<iostream>
using namespace std;
int main()
{
  int N,M,n,data,sum=0;
  cin>>N>>M;
  int count[30]={0};
  for(int i=0;i<N;i++){
    cin>>n;
    for(int k=0;k<n;k++){
      cin>>data;
      data--;
      count[data]++;
    }
  }
  for(int i=0;i<M;i++){
    if(count[i]==N) sum++;
  }
  cout<<sum<<endl;
}


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


#define FOR(i, start, end) for(uint64_t i=start; i<end; i++)
#define REP(i, n) FOR(i, 0, n)

// 最大公約数gcd
// 最小公倍数lcm=m*n/gcd
uint64_t gcd(uint64_t m, uint64_t n) {
  uint64_t temp;
  while (m % n != 0){
    temp = n;
    n = m % n;
    m = temp;
  }
  return n;
}

uint64_t lcm(uint64_t m, uint64_t n) {
  return (m*n)/gcd(m,n);
}

void comb(vector<vector <uint64_t> > &v){
  for(uint64_t i = 0;i <v.size(); i++){
    v[i][0]=1;
    v[i][i]=1;
  }
  for(uint64_t k = 1;k <v.size();k++){
    for(uint64_t j = 1;j<k;j++){
      v[k][j]=(v[k-1][j-1]+v[k-1][j]);
    }
  }
}

// 掛け算オーバーフロー判定
bool is_product_overflow(uint64_t a, uint64_t b) {

	uint64_t prod = a * b;
	
	return (prod / b != a);
}

//素因数分解
void primeFactorization(uint64_t a, list<uint64_t> &factors){ //素因数分解を出力するプログラム
  long i,sq;
  if(a%2==0){ //偶数の場合
    factors.push_back(2);
    primeFactorization(a/2,factors); //2で割った値で再帰
    return;
  }
  sq = sqrt(a);
  for(i=3;i<=sq;i+=2){ //3以上√a以下の奇数の場合
	if(a%i==0){
	  factors.push_back(i);
      primeFactorization(a/i,factors); //割れた値で再帰
      return;
	}
  }
  //偶数でも3以上√a以下の奇数の場合でも割り切れない場合
  if(a!=1){ //aが1でないなら、a自身は素数
    factors.push_back(a);
  }
}

// 円周率
// M_PI

// #include <iomanip> // setprecisionを使用するのに必要
// cout << std::fixed << std::setprecision(15) << y << endl;

// 昇順
// priority_queue<int, vector<int>, greater<int> > queue;

void call(int n){
    for(int i = 1; i<=n; i++){
        int x = i;
        if( x%3 == 0 ){
            cout << " " << i;
        }
        else{
            while(x){
                if (x % 10 == 3){
                    cout << " " << i;
                    break;
                }
                x /= 10;
            }
        }
    }
    cout << endl;
    
}

signed main() {
  int64_t n;
  cin >> n;
  call(n);
  return 0;
}


Measured memory_bytes: 3096
#include <iostream>
#include <string>

using namespace std;

int main() {
    int a, b; cin >> a >> b;
    string str; cin >> str;

    bool flag = true;
    int len = a + b;

    for (int i = 0; i < len; ++i) {
        if (i == a) {
            flag = str[a] == '-';
        } else {
            flag = 48 <= str[i] && str[i] <= 57;
        }
        if (!flag) break;
    }

    cout << (flag ? "Yes" : "No") << endl;

    return 0;
}

Measured memory_bytes: 256
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.Scanner;

//Carrot Tour
public class Main{

	double norm(double[] a){
		return Math.hypot(a[0], a[1]);
	}
	double dot(double[] a, double[] b){
		return a[0]*b[0]+a[1]*b[1];
	}
	double cross(double[] a, double[] b){
		return a[0]*b[1]-a[1]*b[0];
	}
	double angleCos(double[] a, double[] b){
		double na = norm(a), nb = norm(b);
		return Math.acos(dot(a, b)/na/nb);
	}
	double[] sub(double[] a, double[] b){
		return new double[]{a[0]-b[0], a[1]-b[1]};
	}
	double EPS = 1e-10;
	int INF = 1<<29;
	
	@SuppressWarnings("unchecked")
	void run(){
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		double R = sc.nextDouble(), thita = sc.nextDouble()*Math.PI/180;
		double[][] p = new double[n][2];
		for(int i=0;i<n;i++)for(int j=0;j<2;j++)p[i][j]=sc.nextDouble();
		double[][] d = new double[n][n];
		for(int i=0;i<n;i++)for(int j=0;j<n;j++)d[i][j]=Math.hypot(p[i][0]-p[j][0], p[i][1]-p[j][1]);
		List<Integer>[][] l = new List[n][n];
		for(int i=0;i<n;i++)for(int j=0;j<n;j++){
			l[i][j] = new ArrayList<Integer>();
			if(i==j)continue;
			for(int k=0;k<n;k++){
				if(k==i)continue;
				double t = angleCos(sub(p[k], p[i]), sub(p[i], p[j]));
				if(t<thita+EPS)l[i][j].add(k);
			}
		}
		double[][] dp = new double[n][n];
		for(double[]a:dp)Arrays.fill(a, INF);
		int res = 0;
		boolean f = false;
		for(int k=1;k<n;k++)if(d[0][k]<R+EPS){
			f = true; dp[k][0] = d[0][k];
		}
		while(f){
			res++;
			f = false;
			double[][] next = new double[n][n];
			for(double[]a:next)Arrays.fill(a, INF);
			for(int i=0;i<n;i++)for(int j=0;j<n;j++){
				if(i==j||dp[i][j]==INF)continue;
				for(int k:l[i][j]){
					if(dp[i][j]+d[i][k]<R+EPS){
						next[k][i] = Math.min(next[k][i], dp[i][j]+d[i][k]); f = true;
					}
				}
			}
			dp = next;
		}
		System.out.println(res);
	}
	
	public static void main(String[] args) {
		new Main().run();
	}
}

Measured memory_bytes: 0
import math

N, D = map(int, input().rstrip().split())
X = []
for i in range(N):
    X.append(list(map(int, input().rstrip().split())))

count_int = 0
for i in range(N):
    for j in range(i + 1, N):
        distance = 0
        for k in range(D):
            distance += (X[i][k] - X[j][k]) ** 2
        distance = math.sqrt(distance)
        if distance.is_integer():
            count_int += 1

print(count_int)


Measured memory_bytes: 3064
#include <iostream>
//#include <iomanip>
//#include <algorithm>
//#include <numeric>
//#include <queue>
//#include <stack>
//#include <math.h>
#include <vector>
//#include <string>
//typedef long long LL;
using namespace std;

int main(){
    vector<int> a(5);
    int k;
    for(int i=0; i<5; i++){
        cin >> a[i];
    }
    cin >> k;
    if(a[4]-a[0]<=k){
        cout << "Yay!";
    }else{
        cout << ":(";
    }
    cout << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
const int N = 2e5 + 10;
const int INF = 0x3f3f3f3f;
int n, k, a[N];
int ans = INF;
int main() {
	scanf("%d%d", &k, &n);
	for (int i = 0; i < n; i++)scanf("%d", &a[i]);
	if (n == 2) { cout << min(k - (a[1] - a[0]), a[1] - a[0]) << endl; return 0; }
	sort(a, a + n);
	for (int i = 0; i < n - 1; i++) {
		ans = min(ans, k - a[i + 1] + a[i]);
	}
	ans = min(ans, k - (a[0] + k - a[n - 1]));
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 1152
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>

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

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

    string ans;
    while(N >=1){
        long long a = N%26;
        N /=26;
        //cout << a << endl;

        if(a >0){
            ans += apla[a-1];
        }else{
            ans += 'z';
            N -= 1;
        }
    }
    reverse(ans.begin(), ans.end());

    cout << ans << endl;
}

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

int main(){
    int n,m;
    int N[1000],M[1000];
    while(1){
        cin >> n >> m;
        if(n==0 && m==0) break;
        for(int i=1; i<=n; i++){
            cin >> N[i];
        }
        for(int i=1; i<=m; i++){
            cin >> M[i];
        }
        int s=1;
        int t=0;
        while(1){
            for(int i=1; i<=m; i++){
                s += M[i];
                s += N[s];
                t = i;
                if(s>=n) break;
            }
            if(s>=n) break;
        }
        cout << t << endl;
    }
}

Measured memory_bytes: 3012
def palindrome?(s)
  s.reverse == s
end

s = gets.chomp!
len = s.size

ans = 'Yes'
ans = 'No' unless palindrome?(s)

s2 = s.slice(0, (len -1) / 2)
ans = 'No' unless palindrome?(s2)
s3 = s.slice((len+3)/2 - 1, len)
ans = 'No' unless palindrome?(s3)

puts ans


Measured memory_bytes: 3836
using System;
using System.Linq;
using System.Collections.Generic;

namespace ConsoleApp1 {
    public class Class {
        static void Main(string[] args) {
            var N = long.Parse(Console.ReadLine());
            var C = new List<long>();
            while (N != 1) {
                while (N % 2 == 0) {
                    C.Add(2);
                    N /= 2;
                }
                for (var i = 3; i <=Math.Sqrt(N); i += 2) {
                    while (N % i == 0) {
                        C.Add(i);
                        N /= i;
                    }
                }
                if(N != 1) {
                    C.Add(N);
                    N /= N;
                }
            }
            var tmp = C.GroupBy(_ => _).Where(x => x.Count() > 0).Select(x => x.Count()).ToList();
            var ans = 0;
            for (var t = 0; t < tmp.Count(); t++) {
                for (var i = 1; i <= tmp[t]; i++) {
                    if (tmp[t] - i >= 0) {
                        ans++;
                        tmp[t] -= i;
                    }
                }
            }
            Console.Write(ans);
        }
    }
}

Measured memory_bytes: 28528