akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <fstream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <string>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <deque>
#include <bitset>
#include <algorithm>
#include <complex>
#include <array>
using namespace std;
 
#define REP(i,n) for(int i=0; i<n; ++i)
#define FOR(i,a,b) for(int i=a; i<=b; ++i)
#define FORR(i,a,b) for (int i=a; i>=b; --i)
#define ALL(c) (c).begin(), (c).end()
 
typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<VI> VVI;
typedef vector<VL> VVL;
typedef pair<int,int> P;
typedef pair<ll,ll> PL;
typedef vector<double> VD;
typedef vector<VD> VVD;

template<typename T> void chmin(T &a, T b) { if (a > b) a = b; }
template<typename T> void chmax(T &a, T b) { if (a < b) a = b; }

int in() { int x; scanf("%d", &x); return x; }
ll lin() { ll x; scanf("%lld", &x); return x; }

string s;

P calc(int &i){
    vector<P> pa, po;
    while (i < s.length() && s[i] != ')'){
        P p;
        if (s[i] == '('){
            i++;
            p = calc(i);
        }else{
            p = make_pair(1, 1);
        }
        i++;
        pa.push_back(p);
        if (s[i] == ')') break;
        if (i < s.length() && s[i] == '|'){
            P tmp(1e9, 0);
            int s = 0;
            for (P p : pa){
                chmin(tmp.first, p.first + s);
                tmp.second += p.second;
                s += min(p.first, p.second);
            }
            po.push_back(tmp);
            pa.clear();
        }
        i++;
    }
    {
        P tmp(1e9, 0);
        int s = 0;
        for (P p : pa){
            chmin(tmp.first, p.first + s);
            tmp.second += p.second;
            s += min(p.first, p.second);
        }
        po.push_back(tmp);
        pa.clear();
    }
    P ret(0, 1e9);
    int s = 0;
    for (P p : po){
        ret.first += p.first;
        chmin(ret.second, p.second + s);
        s += min(p.first, p.second);
    }
    return ret;
}

int main() {
    cin >> s;
    int i = 0;
    P p = calc(i);
    cout << p.first << " " << p.second << endl;

    return 0;
}



Measured memory_bytes: 3308
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define dd double
#define endl "\n"
#define pb push_back
#define all(v) v.begin(),v.end()
#define mp make_pair
#define fi first
#define se second
#define vll vector<ll>
#define pll pair<ll,ll>
#define fo(i,n) for(int i=0;i<n;i++)
#define fo1(i,n) for(int i=1;i<=n;i++)
ll mod=1000000007;
ll n,k,t,m,q,flag=0;
ll power(ll a,ll b) {ll res=1;a%=mod; assert(b>=0); for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}
// #include <ext/pb_ds/assoc_container.hpp> 
// #include <ext/pb_ds/tree_policy.hpp> 
// using namespace __gnu_pbds; 
// #define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>
// ordered_set s ; s.order_of_key(a) -- no. of elements strictly less than a
// s.find_by_order(i) -- itertor to ith element (0 indexed)
ll min(ll a,ll b){if(a>b)return b;else return a;}
ll max(ll a,ll b){if(a>b)return a;else return b;}
ll gcd(ll a , ll b){ if(b > a) return gcd(b , a) ; if(b == 0) return a ; return gcd(b , a%b) ;}
int main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0); cout.tie(0);
    #ifdef NOOBxCODER
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
    #else 
    #define NOOBxCODER 0
    #endif
    //cin>>t;
    t=1;
    while(t--){
        cin>>n;
        ll a[n];
        fo(i,n)cin>>a[i];
        ll maxi=a[0];
        ll ans=0;
        fo(i,n){
            ans+=max( 0 ,maxi-a[i]);
            maxi=max(maxi,a[i]);
        }
        cout<<ans;




        
    }
    cerr << "Time : " << 1000 * ((double)clock()) / (double)CLOCKS_PER_SEC << "ms\n";
    return 0;
}


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

int main() {
    int n; cin >> n;
    vector<Int> a(n);
    Int sum = 0;
    rep(i, n){
        cin >> a[i];
        sum += a[i];
    }

    Int left_sum = 0;
    Int half = sum/2;
    Int i;
    for (i = 0; i < n; i++) {
        left_sum += a[i];
        if (half - left_sum == 0) {
            cout << 0 << endl;
            return 0;
        }
        else if (half - left_sum < 0) {
            break;
        }
    }

    Int minv = 0;
    if (i != 0) {
        minv = min(left_sum-(sum-left_sum),(sum-(left_sum-a[i])) - (left_sum-a[i]) );
    }
    else {
        minv = left_sum-(sum-left_sum);
    }
    cout << minv << endl;
}

Measured memory_bytes: 1792
stack = []
 
q = int(input())
for i in range(q):
    op = list(map(int, input().split(' ')))
    if op[0] == 0:
        stack.append(op[1])
    elif op[0] == 1:
        print(stack[op[1]])
    elif op[0] == 2:
        stack.pop()


Measured memory_bytes: 13360
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define ll long long
#define P pair<int,int>
#define fi first
#define se second
#define rep(i,n) for(int i=0;i<n;i++)
#define INF 1000000000000000000
#define MOD 1000000007
#define all(v) v.begin(),v.end()
#define pb push_back
int dx[]={0,1,0,-1},dy[]={1,0,-1,0};
int kaijo[2000010];
struct edge{int to,cost;};
int gcd(int a,int b){
	if(b==0)return a;
	return gcd(b,a%b);
}
int lcm(int a,int b){
	return a/gcd(a,b)*b;
}
bool prime(int a){
	if(a==1)return false;
	for(int i=2;i*i<=a;i++){
		if(a%i==0)return false;
	}
	return true;
}
bool kosa(double ax,double ay,double bx,double by,double cx,double cy,double dx,double dy){
	double ta=(cx-dx)*(ay-cy)+(cy-dy)*(cx-ax);
	double tb=(cx-dx)*(by-cy)+(cy-dy)*(cx-bx);
	double tc=(ax-bx)*(cy-ay)+(ay-by)*(ax-cx);
	double td=(ax-bx)*(dy-ay)+(ay-by)*(ax-dx);
	return tc*td<0&&ta*tb<0;
}
void init_fact(){
	kaijo[0]=1;
	for(int i=1;i<=2000000;i++){
		kaijo[i]=kaijo[i-1]*i;
		kaijo[i]%=MOD;
	}
}
int modpow(int a,int b){
	if(b==0)return 1;
	if(b%2)return modpow(a,b-1)*a%MOD;
	int memo=modpow(a,b/2);
	return memo*memo%MOD;
}

int comb(int a,int b){
	if(!kaijo[0])init_fact();
	return kaijo[a]*modpow(kaijo[a-b],MOD-2)%MOD*modpow(kaijo[b],MOD-2)%MOD;
}
int inv(int x){
	x=modpow(x,MOD-2);
	return x;
}

double dist(double ax,double ay,double bx,double by){
	return sqrt((bx-ax)*(bx-ax)+(ay-by)*(ay-by));
}
int n,a[200010],b[200010],ans,cnt[10];
string s;
signed main(){
	cin>>n;
	rep(i,n){
		cin>>a[i]>>b[i];
		cnt[a[i]]+=b[i];
	}
	ans+=cnt[0];
	for(int i=1;i<=9;i++){
		cnt[i]--;
	}
	if(cnt[1]>0)ans+=cnt[1]/9*10,cnt[1]%=9;
	if(cnt[2]>0)ans+=cnt[2]/9*11,cnt[2]%=9;
	if(cnt[3]>0)ans+=cnt[3]/3*4,cnt[3]%=3;
	if(cnt[4]>0)ans+=cnt[4]/9*13,cnt[4]%=9;
	if(cnt[5]>0)ans+=cnt[5]/9*14,cnt[5]%=9;
	if(cnt[6]>0)ans+=cnt[6]/3*5,cnt[6]%=3;
	if(cnt[7]>0)ans+=cnt[7]/9*16,cnt[7]%=9;
	if(cnt[8]>0)ans+=cnt[8]/9*17,cnt[8]%=9;
	if(cnt[9]>0)ans+=cnt[9]/1*2,cnt[9]=0;
	for(int i=1;i<=9;i++){
		cnt[i]++;
		for(int j=1;j<=cnt[i];j++)s+=to_string(i);
	}
	while(s.size()>1){
		if(s.size()==2)s=to_string((s[0]-'0')+(s[1]-'0'));
		else s=to_string((s[0]-'0')+(s[1]-'0'))+s.substr(2,s.size()-2);
		ans++;
	}
	cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 4352
#include <stdio.h>





int main(void){
    int N;
    scanf("%d",&N);
    if(N==3){printf("2 5 63");return 0;}
    if(N==4){printf("2 5 20 63");return 0;}
    int po=N%8;
    if(po==1)printf("30000 ");
    if(po==2)printf("30000 29994 ");
    if(po==3)printf("30000 29998 29996 ");
    if(po==4)printf("30000 29998 29996 29994 ");
    if(po==5)printf("30000 29991 29997 29998 29996 ");
    if(po==6)printf("30000 29994 29997 29991 29998 29996 ");
    if(po==7)printf("29990 29992 29996 29998 29991 29997 30000 ");
    N-=po;
    for(int i=1;;i++){
        if(i%2==0||i%3==0){printf("%d ",i);N--;}
        if(N<=0)break;
    }
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define rep(i, n) for (ll i = 0; i < n; i++)
#define FOR(i, a, b) for (ll i = a; i < b; i++)
#define len(v) ll(v.size())
#define fi first
#define se second

template <class T>
void cout_vec(const vector<T> &vec){
  for(auto itr:vec) cout<<itr<<' ';
  cout<<endl;
}

typedef pair<ll,ll> P;
const ll mod=1e9+7;
const ll inf=1e15;

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  int k;
  cin>>k;
  vector<ll> a(k);
  rep(i,k) cin>>a[i];
  reverse(begin(a),end(a));
  ll ans1=2,ans2=2;
  rep(i,k){
    if(ans2<a[i]){
      cout<<-1<<endl;
      return 0;
    }
    ans1=max(a[i],ans1);
    ans1=(ans1+a[i]-1)/a[i]*a[i];
    ans2=ans2/a[i]*a[i]+a[i]-1;
    if(ans1>ans2){
      cout<<-1<<endl;
      return 0;
    }
  }
  cout<<ans1<<' '<<ans2<<endl;
}

Measured memory_bytes: 1024
from operator import itemgetter
N, M = list(map(int, input().split()))
ab = [[0,0] for i in range(M)]
for i in range(M):
    ab[i] = list(map(int, input().split()))

ab = sorted(ab, key=itemgetter(0,1))

re = 1
x, y = ab[0]
for i in range(1, M):
    a, b = ab[i]
    if b <= x or y <= a: # 切ったとこの範囲外だったら
        re += 1
        x, y = a, b
    else:
        x = max(x, 1)
        y = min(y, b)
print(re)

Measured memory_bytes: 36264
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
 
const int maxV = 90010;
const int maxN = 1e5+10;
const int inf = 0x3f3f3f3f;
const ll MOD = 1e9+7;
const ll INF = 1000000000000000010LL;
#define X first
#define Y second

vector<pii> v[maxN]; 
pii a[maxN];
int n;
int k;
int b[maxN];
void dfs(int x,int p,int c)
{
	int tot = 0;
	for(int i=0;i<v[x].size();i++)
	{
		pii it = v[x][i];
		int y = it.X;
		int pos = it.Y;
		if(y == p)
		{
			continue;
		}
		tot++;
		if(tot == c)
		{
			tot++;
		}
		b[pos] = tot;
		dfs(y,x,tot);
	}
}
int main() {
	scanf("%d",&n);
	for(int i=1;i<n;i++)
	{
		int x,y;
		scanf("%d %d",&x,&y);
		a[i] = pii(x,y);
		v[x].push_back(pii(y,i));
		v[y].push_back(pii(x,i));
	}
	k = 0;
	for(int i=1;i<=n;i++)
	{
		k = max(k,(int)v[i].size());
	}
	dfs(1,0,0);
	printf("%d\n",k);
	for(int i=1;i<n;i++)
	{
		printf("%d\n",b[i]);
	}
	return 0;
}

Measured memory_bytes: 9728
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, a, b) for (int i = a; i < b; i++)
int D;
ll ans = 0;
vector<int> c(26);
int main()
{
    cin >> D;
    int s[366][28];
    int last[28];
    rep(i, 1, 27)
    {
        cin >> c[i];
    }
    rep(i, 1, D + 1)
    {
        rep(j, 1, 27)
        {
            cin >> s[i][j];
            last[j] = 0;
        }
    }
    vector<int> t(D);
    rep(i, 1, D + 1)
    {
        cin >> t[i];
    }
    rep(i, 1, D + 1)
    {
        rep(j, 1, 27)
        {
            if (t[i] != j)
            {
                ans -= c[j] * (i - last[j]);
                // cout << "ans=" << ans << endl;
            }
        }
        ans += s[i][t[i]];
        last[t[i]] = i;
        cout << ans << endl;
    }
    return 0;
}


Measured memory_bytes: 3604
import sys
input = sys.stdin.readline
S = input().strip()
T = input().strip()


N = len(S)
M = len(T)

ans = 10**10
for i in range(N-M+1):
    subS = S[i:i+M]
    temp = 0
    for s,t in zip(subS, T):
        if s != t:
            temp += 1
    ans = min(temp,ans)

print(ans)


Measured memory_bytes: 73436
def cin():  return list(map(int,input().split()))

def bellman_ford(s):
    d = [float('inf')] * N
    d[s] = 0
    for i in range(N):
        update = False
        for x, y, z in G:
            if d[y] > d[x] + z:
                d[y] = d[x] + z
                if i == N - 1 and y == N - 1:  return "inf"
    return -d[N - 1]

N, M = cin()
G = []
bfr = []
for i in range(M):
    s, t, w = cin()
    G.append((s - 1, t - 1, -w))
ans = bellman_ford(0)
print(ans)

Measured memory_bytes: 75504
#include <iostream>
#include <string>
#include <sstream>
#include <iomanip> 
#include <math.h>
#include <stdio.h>
#include <string.h>
#include <queue>
#include <stack>
#include <vector>
#include <map>
#include <set>
#include <functional>
#include <algorithm>
#include <unordered_map>
#include <unordered_set>
#include <bitset>

using namespace std;



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

	string s;
	cin >> s;
	int ct = 0;
	if (s[0] == '2') ct++;
	if (s[1] == '2') ct++;
	if (s[2] == '2') ct++;
	if (s[3] == '2') ct++;
	cout << ct << "\n";

	return 0;
}



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

#define infile "../test/sample-1.in"
#define int long long
// #define INF 2147483647
#define INF 1000000000000000000LL
#define MOD 1000000007LL
// {{{ define basic macro
// #define rep(i, x) for(int i = 0; i < (int)(x); i++)
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=(int)(a);i<(int)(b);++i)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define reps(i,x) for(int i = 1; i <= (int)(x); i++)
#define rrep(i,x) for(int i=((int)(x)-1);i>=0;i--)
#define rreps(i,x) for(int i=((int)(x));i>0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define RFOR(i, m, n) for(int i = m;i >= n;i--)
#define foreach(x,a) for(auto& (x) : (a) )
#define each(it,c) for(__typeof((c).begin()) it=(c).begin();it!=(c).end();it++)
#define all(x) (x).begin(),(x).end()
#define sum(v) accumulate(all(v), 0)
#define sz(x) ((int)(x).size())
template<class T> inline void chmax(T &a, const T &b) { if(a < b) a = b; }
template<class T> inline void chmin(T &a, const T &b) { if(a > b) a = b; }
// n次元配列の初期化。第２引数の型のサイズごとに初期化していく。
template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
    std::fill( (T*)array, (T*)(array+N), val );
}
#define fill(x,y) memset(x,y,sizeof(x))
#define pb(a) push_back(a)
#define uni(x) sort(all(x));x.erase(unique(all(x)),x.end())
#define ten(n) ((int)1e##n)

template <class T = int>
T in() {T x; cin>>x; return (x);}

struct Fast {
  Fast(){
    std::cin.tie(0);
    ios::sync_with_stdio(false);
  }
} fast;
// }}}
//{{{ dump macro
#ifdef PCM
  #include "dump.hpp"
#else
  #define dump(...) 42
  #define dump_1d(...) 42
  #define dump_2d(...) 42
#endif
//}}}
//{{{ others
typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<long long> vll;
typedef vector<vll> vvll;
typedef long double ld;
typedef pair<int,int> pii;
typedef vector<pii> vii;
typedef vector<vii> vvii;
typedef tuple<int,int,int> iii;
typedef set<int> si;
typedef complex<double> pnt;
typedef vector<pnt> vpnt;
typedef priority_queue<pii, vii, greater<pii> > spq;  //pop, topで最小値
int dx[]={1, -1, 0, 0, 0};
int dy[]={0, 0, 1, -1, 0};
//}}}


int solve(){
  int a,b,c;cin>>a>>b>>c;
  vi x;
  x.pb(a);
  x.pb(b);
  x.pb(c);
  sort(all(x));

  cout << abs(x[2]-x[1]) + abs(x[1]-x[0]) << endl;

  return 0;
}

signed main() { //{{{
#ifdef INPUT_FROM_FILE
  std::ifstream in(infile);
  std::cin.rdbuf(in.rdbuf());
#endif
  solve();
  return 0;
} //}}}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main{
	public static void main(String[] args){
		Scanner stdIn = new Scanner(System.in);
		String S = stdIn.nextLine();
		int count = 0;
		for(int i = 0; i < S.length(); i++){
			if(S.charAt(i) == '1'){
				count++;
			}
		}
		System.out.println(count);
	}

}

Measured memory_bytes: 23892
#include<ctime>
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cstdlib>
#include<cmath> 
#include<cstring> 
#include<cassert>
#include<string>
#include<sstream>
#include<fstream>
#include<deque>
#include<queue>
#include<vector>
#include<map>
#include<list>
#include<stack>
#include<set>
#include<bitset>
#include<iomanip>
#include<utility>
#include<functional>
#include<cctype>
#include<cerrno>
#include<cfloat>
#include<ciso646>
#include<climits>
#include<clocale>
#include<complex>
#include<csetjmp>
#include<csignal>
#include<cstdarg>
#include<cstddef>
#include<cwchar>
#include<cwctype>
#include<exception>
#include<locale>
#include<numeric>
#include<new>
#include<stdexcept>
#include<limits>
using namespace std;

#define ll long long
#define INF 1e9
#define rep(i,n) for(int (i)=0;(i)<n;i++)
#define REP(i,n) for(int (i)=1;(i)<=n;i++)
#define mk(a,b) make_pair(a,b)
#define fi first
#define se second
#define pii pair<int,int>
#define sz(s) s.size()
#define all(s) (s.begin(),s.end())

const int maxn=100005;
int n,mx;
int dep[maxn],sz[maxn];
vector<int>defeat[maxn];

bool cmp(int a,int b){
	return sz[a]>sz[b];
}

void dfs(int x,int p){
	vector<int>s;
	rep(i,defeat[x].size()){
		int y=defeat[x][i];
		if(y!=p)dfs(y,x),s.push_back(y);
	}
	sort(s.begin(),s.end(),cmp);
	rep(i,s.size())sz[x]=max(sz[x],sz[s[i]]+i+1);
}

int main(){
	ios::sync_with_stdio(false);
	cin>>n;
	for(int i=2;i<=n;i++){
		int x;
		cin>>x;
		defeat[x].push_back(i);
	}
	dfs(1,-1);
	REP(i,n)sort(defeat[i].begin(),defeat[i].end(),cmp);
	queue<int>q;
	dep[1]=0;
	q.push(1);
	while(!q.empty()){
		int x=q.front();q.pop();
		rep(i,defeat[x].size()){
			int y=defeat[x][i];
			if(!i)dep[y]=dep[x]+1;
			else dep[y]=dep[defeat[x][i-1]]+1; 
			q.push(y);
		}
	}
	REP(i,n)mx=max(mx,dep[i]);
	cout<<mx;
	return 0;
}
/*
8
1
1
2
4
3
6
7
*/

Measured memory_bytes: 17408
#include<iostream>
#include<cstdio>
#include<iomanip>
#include<algorithm>
#include<string>
#include<vector>
#include<queue>
#include<stack>
#include<cstdlib>
#define REP(i, N) for(int i = 0; i < N; ++i)
#define REEP(i, N) for(int i = N - 1; i >= 0; --i)
#define ALL(a) (a).begin(),(a).end()
#define FOR(i,m,n) for(int i = m; i < n; ++i)
#define RFOR(i,m,n) for(int i = n - 1; i >= m; --i)
#define CIN(a) cin >> a
#define CIN2(a, b) cin >> a >> b
#define CIN3(a, b, c) cin >> a >> b >> c
#define COUT(a) cout << a << endl
#define COUT2(a, b) cout << a << " " << b << endl
#define COUT3(a, b, c) cout << a << " " << b << " " << c << endl
#define pb push_back
#define PB push_back
#define VINT(v, n) vector<int> v(n); REP(i, n) { v[i] = 0 }
#define VINT2(v, n, m) vector<vector<int> > v(n, vector<int>(m)); REP(i, n) { REP(j, m) { v[i][j] = 0 } }
#define VCHAR(v, n) vector<char>v(n)
#define MAX(a, b) a > b ? a : b
#define MIN(a, b) a < b ? a : b
#define CEIL(c, a, b) if(a % b == 0) { c = a / b;} else { c = a / b + 1;}
#define sp(n) setprecision(n)
#define INF 100000000

using namespace std;
typedef pair<int, int> P;
int DX[4] = {1, 0, -1, 0};
int DY[4] = {0, 1, 0, -1};



int main() {
	int N;
	CIN(N);
	COUT((N * 800) - ((N / 15) * 200));
}



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

int main() {
    int N;
    cin >> N;
    vector<int> A(N + 1);
    for(int i = 0; i < N; i++) {
        cin >> A.at(i + 1);
    }

    vector<int> B(N + 1, 0);
    for(int n = N; n > 0; n--) {
        int cnt = 0;
        for(int n2 = n + n; n2 <= N; n2 += n) {
            if(B.at(n2) == 1) {
                cnt++;
            }
        }
        if(A.at(n) == 1) {
            if(cnt % 2 == 0) {
                B.at(n) = 1;
            } else {
                B.at(n) = 0;
            }
        } else {
            if(cnt % 2 == 0) {
                B.at(n) = 0;
            } else {
                B.at(n) = 1;
            }
        }
    }

    vector<int> ans;
    for(int i = 1; i <= N; i++) {
        if(B.at(i) == 1) {
            ans.push_back(i);
        }
    }

    cout << ans.size() << endl;
    for(int i = 0; i < ans.size(); i++) {
        if(i != 0) {
            cout << " ";
        }
        cout << ans.at(i);
    }
    cout << endl;

    return 0;
}

Measured memory_bytes: 3064
n, x, y = gets.chomp.split(" ").map(&:to_i)
ans = Array.new(n, 0)
graph = Array.new(n).map{Array.new}
graph[x-1] << y-1
graph[y-1] << x-1
(n-1).times do |i|
    graph[i] << i+1
    graph[i+1] << i
end

n.times do |i|
    dist = Array.new(n, -1)
    dist[i] = 0
    queue = [i]
    until queue.empty?
        v = queue.shift
        graph[v].each do |e|
            next if dist[e] != -1
            dist[e] = dist[v] + 1
            queue << e
        end
    end
    dist.each do |d|
        ans[d] += 1
    end
end

ans.each_with_index do |e, i|
    next if i == 0
    puts e / 2
end

Measured memory_bytes: 28540
#include <bits/stdc++.h>
using namespace std;
typedef pair<int,int> P;
typedef long long ll;
typedef long double ld;
const int inf=1e9+7;
const ll longinf=1LL<<60;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
#define F first
#define S second
 
#define bit(n,k) ((n>>k)&1) //*n no k bit me 1 or 0*/

const int mx=100010;
const ll mod=1e9+7;

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

int h,w;
vector<vector<char>> a(110, vector<char>(110,'#'));
vector<vector<int>> cnt(110, vector<int>(110,inf));

int dfs(int y, int x){
  if(cnt[y][x]!=inf) return cnt[y][x];
  bool t = (a[y][x]=='#');
  if(y==h-1 && x==w-1){
    return cnt[y][x] = 0;
  }

  int c = inf;
  rep(i,2){
    int ny = y+dy[i], nx = x+dx[i];
    if (ny < 0 || h <= ny || nx < 0 || w <= nx) continue;
    bool nt = (a[ny][nx]=='#');
    c = min(c, dfs(ny, nx)+(int)(!t&&nt));
  }
  if(y==0&&x==0&&t) c++;
  return cnt[y][x] = c;
}

int main(){  
  cin >> h >> w;
  rep(i,h)rep(j,w) cin >> a[i][j];

  int ans = dfs(0,0);
  cout << ans << endl;
  return 0;
}

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

using namespace std;

int main()
{
    int takahashi = 0;
    string S;
    cin >> S;
    for (int i = 0; i < S.length(); ++i)
    {
        if (S[i] == '+')
        {
            takahashi++;
        }
        else
        {
            takahashi--;
        }
    }
    
    cout << takahashi << endl;
    
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
typedef long long int ll;
typedef long double ld;
#define pb push_back
#define pii pair < int , int >
#define F first
#define S second
#define endl '\n'
#define int long long
#define sync ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#pragma GCC optimize("Ofast,no-stack-protector,unroll-loops,fast-math")
#define kill(x) return cout<<x<<'\n', 0;
using namespace std;
const int N=2e5+100;
vector <int> g[N];
ll dp[N];
ll p1=0;
ll z=0;
void dfs(ll v,ll p,ll k){
    multiset <int> s;
    for (auto u : g[v]){
        if (u==p) continue;
        dfs(u,v,k);
        s.insert(dp[u]+1);
        if (dp[u]+1>k){
            p1=1;
            return ;
        }
    }
    if (p1) return ;
   // if (v==1) cout << s.size() << " end " << endl;
   vector <int> y;
    while(s.size()>1){
        auto t=s.end();
        t--;
        ll val1=*t;
        s.erase(t);
        if (*s.begin()+val1>k){

                y.pb(val1);
                continue;
        }
        t=s.upper_bound(k-val1);
        t--;
        s.erase(t);
        z++;
    }
    if (s.size()){
        y.pb(*s.begin());
    }
    if (y.size()>2){
        p1=1;
        return ;
    }
    if (y.size()){
        sort(y.begin(),y.end());
        for (int i=1;i<y.size();i++) z++;
        dp[v]=y[0];
        if (v==1) z++;
    }
    if (dp[1]>k) p1=1;
}
int32_t main(){
    sync;
    ll n;
    cin >> n;
    for (int i=1;i<n;i++){
        ll u,v;
        cin >> u >> v;
        g[u].pb(v);
        g[v].pb(u);
    }
    ll l=0,r=n+10;
    dfs(1,1,r);
    ll o=z;
    while(r-l>1){
        memset(dp,0,sizeof dp);
        p1=0;
        ll mid=(r+l)/2;
        z=0;
        dfs(1,1,mid);
        if (!p1 && z==o) r=mid;
        else l=mid;
        //cout << z << " f " << mid << endl;
    }memset(dp,0,sizeof dp);
    z=0;
    p1=0;
    dfs(1,1,r);
    cout << z << " " << r << endl;
}


Measured memory_bytes: 28904
from math import *

marume = 10

def main():
    a,b,h,m = map(int,input().split())
    long_degree = (h % 12) * 30 + 0.5 * m #短針は1時間で30度進む 1分で0.5度進む
    short_degree = 6 * m #長針は1分で6度進む

    #短針と長針と書いたけど、問題では時針と分針になっている。これはトラップでは？
    #時針が分針より短いとは限らない

    degree = abs(long_degree - short_degree) #短針と長針の角度
    t = round(tan(radians(degree)),marume) #タンジェント
    s = round(sin(radians(degree)),marume) #サイン
    c = round(cos(radians(degree)),marume)
    hen1 = s * max(a,b)
    hen2 = c * max(a,b) - min(a,b)
    answer = sqrt(hen1 ** 2 + hen2 ** 2)
    print(answer)





if __name__ == '__main__':
    main()


Measured memory_bytes: 9532
#include <iostream>
#include <climits>
#include <vector>
#include <algorithm>

using namespace std;

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

    int n;
    cin >> n;
    vector<int> h(n);
    for (int i = 0; i < n; i++) cin >> h[i];
    int last = INT_MAX, ans = 0, c = 0;
    for (int i = 0; i < n; i++)
    {
        if (h[i] <= last) c++;
        else c = 1;

        ans = max(ans, c);
        last = h[i];
    }

    cout << ans - 1 << "\n";

    return 0;
}


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

typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef pair<ld,ld> pdd;
typedef vector<ll> vll;
typedef vector<ld> vld;
typedef vector<pll> vpl;
typedef vector<vll> vvll;

#define ALL(a) a.begin(),a.end()
#define SZ(a) ((int)a.size())
#define FI first
#define SE second
#define REP(i,n) for(int i=0;i<((int)n);i++)
#define REP1(i,n) for(int i=1;i<((int)n);i++)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define PB push_back
#define EB emplace_back
#define MP(a,b) make_pair(a,b)
#define SORT_UNIQUE(c) (sort(c.begin(),c.end()), c.resize(distance(c.begin(),unique(c.begin(),c.end()))))
#define GET_POS(c,x) (lower_bound(c.begin(),c.end(),x)-c.begin())
#define yes cout<<"Yes"<<endl
#define YES cout<<"YES"<<endl
#define no cout<<"No"<<endl
#define NO cout<<"NO"<<endl
#define Decimal fixed<<setprecision(20)
#define INF 1000000000
#define LLINF 1000000000000000000LL

const int inf = 1e9;
const ll linf = 1LL << 50;
const double eps = 1e-10;
const int MOD = 1e9 + 7;
const int dx[4] = {-1, 0, 1, 0};
const int dy[4] = {0, -1, 0, 1};

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

  ll a,b,c,d;
  cin>>a>>b>>c>>d;

  ll ans=max(a*c,b*d);
  ans=max(ans,a*d);
  ans=max(ans,b*c);
  cout<<ans<<endl;
}


Measured memory_bytes: 3644
/*raghav0307 - Raghav Gupta*/

#include <bits/stdc++.h>
using namespace std;

#define ff first
#define ss second
#define pb push_back
#define fast_io() ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);

typedef long long ll;

int maxDist = 0;
int nd;
vector<int> graph[200005];

void dfs(int cur, int dist, int par = -1){
	if(dist > maxDist){
		nd = cur;
		maxDist = dist;
	}
	for(auto x: graph[cur]){
		if( x == par)	continue;
		dfs(x, dist+1, cur);
	}
}

int main(){
	fast_io();
	int n;	cin >> n;
	for(int i = 0; i < n-1; i++){
		int a, b;
		cin >> a >> b;
		graph[a].pb(b);
		graph[b].pb(a);
	}
	dfs(1, 0);
	dfs(nd, 0);
	if((maxDist + 1) % 3 == 2){
		cout << "Second";
	}
	else cout << "First";
	return 0;
}

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

typedef pair<int,int> P;


int main() {
    long long N, X, D; cin >> N >> X >> D;

    map<long long,vector<pair<long long,long long>>> mp;
    if (D == 0) {
        if (X) cout << N + 1 << endl;
        else cout << 1 << endl;
        return 0;
    }

	// Flip signs WLOG.
    if (D < 0) {
        D *= -1;
		X *= -1;
    }

    for (long long k = 0; k <= N; ++k) {
        long long min_side = k * X / D + k * (k - 1) / 2;
		long long max_side = k * X / D + k * (2 * N - k - 1)/2;
        mp[abs(k * X) % D].push_back(make_pair(min_side, max_side));
    }

	long long ans = 0;
    for (auto& it : mp) {
        vector<pair<long long,long long>>& v = it.second;
        sort(v.begin(), v.end());
        long long l = -1e18;
        for (pair<long long,long long>& p : v) {
            ans += max(0LL, p.second - max(p.first, l) + 1);
            l = max(l, p.second + 1);
        }
    }

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


Measured memory_bytes: 22144
#include <iostream>
#include <string>
#include <cmath>

using namespace std;

bool
isPrime(uint64_t x) {
    for (auto i = 2; i <= sqrt(x); i++) {
        if (x%i==0) return false;
    }
    return true;
}

int
main() {
    uint64_t X, result;
    cin >> X;

    if (X == 2) {
        result = 2;
    } else {
        if (!(X&1)) X++;
        while (1) {
            if (isPrime(X)) {
                result = X;
                break;
            } else {
                X++;
            }
        }
    }
    
    cout << result << endl;
    
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double db;
typedef pair<int,int> pii;
typedef vector<int> vi;
#define de(x) cout << #x << "=" << x << endl
#define rep(i,a,b) for(int i=a;i<(b);++i)
#define all(x) (x).begin(),(x).end()
#define sz(x) (int)(x).size()
#define mp make_pair
#define pb push_back
#define fi first
#define se second
 ll ans=1e11+7;
const int maxn=200+7;
int  n,m,r;
ll sum;
ll road[maxn][maxn];
int t[10];
bool vis[10];
ll dfs(int st,int cnt)
{
  //de(st);
  //de(cnt);
   if(cnt==r)
  {
    //de(sum);
    if(sum<ans) ans=sum;
  }
  for(int i=1;i<=r;i++)
  {
    if(!vis[i])
    {
      vis[i]=true;
      sum+=road[st][t[i]];
      //de(road[st][t[i]]);
      dfs(t[i],cnt+1);
      sum-=road[st][t[i]];
      vis[i]=false;

    }
  }

}
int main()
{
  scanf("%d%d%d",&n,&m,&r);
  for(int i=1;i<=r;i++) scanf("%d",&t[i]);
  for(int i=1;i<=n;i++) for(int j=1;j<=n;j++) road[i][j]=1e9+7;
  for(int i=1;i<=m;i++)
  {
    int u,v,w;
    scanf("%d%d%d",&u,&v,&w);
    road[u][v]=road[v][u]=w;
  }
  for(int k=1;k<=n;k++) for(int u=1;u<=n;u++) for(int v=1;v<=n;v++)  road[u][v]=min(road[u][v],road[u][k]+road[k][v]);
  /*for(int i=1;i<=n;i++)
  {for(int j=1;j<=n;j++) cout<<road[i][j]<<" ";
  cout<<endl;}*/
  for(int i=1;i<=r;i++)
  {
    sum=0;
    memset(vis,0,sizeof(vis));
    vis[i]=true;
    dfs(t[i],1);
    vis[i]=false;

  }
  cout<<ans;
  return 0;
}


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

ll a[55], k;

int main() {
#ifdef LOCAL
    freopen("xxx.in", "r", stdin);
    freopen("xxx.out", "w", stdout);    
#endif
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cin >> k;
    int n = 50;
    for (int i = 0; i < n; ++i)
        a[i] = i + k / n;
    k %= n;
    for (int i = n - 1; i >= 0 && k > 0; --i, --k)
        a[i]++;
    cout << n << "\n";
    for (int i = 0; i < n; ++i)
        cout << a[i] << " "; 
    return 0;
}

Measured memory_bytes: 256
#include <vector>
#include <iostream>
#include <utility>
#include <algorithm>
#include <string>
#include <deque>
#include <queue>
#include <tuple>
#include <queue>
#include <functional>
#include <cmath>
#include <iomanip>
#include <map>
#include <set>
#include <numeric>
#include <unordered_map>
#include <unordered_set>
#include <complex>
#include <iterator>
#include <array>
#include <memory>
#include <stack>
#define vi vector<int>
#define vvi vector<vector<int> >
#define ll long long int
#define vl vector<ll>
#define vvl vector<vector<ll>>
#define vb vector<bool>
#define vc vector<char>
#define vs vector<string>
#define ld long double
#define INF 1e9
#define EPS 0.0000000001
#define rep(i,n) for(int i=0;i<n;i++)
#define loop(i,s,n) for(int i=s;i<n;i++)
#define all(in) in.begin(), in.end()
template<class T, class S> void cmin(T &a, const S &b) { if (a > b)a = b; }
template<class T, class S> void cmax(T &a, const S &b) { if (a < b)a = b; }
#define MAX 9999999
using namespace std;
typedef pair<int, int> pii;
typedef pair<double,double>pdd;
typedef pair<ll,ll>pll;
int main(){
    int n;
    while(cin>>n,n){
        
        vector<pair<pii, pii>>v;
        rep(_,n){
        int i,p,q,r; cin>>i>>p>>q>>r;
        v.push_back(pair<pii, pii>(pii(i,p),pii(q,r)));
        }
        vi ans;
        int rize,syaro,tiya,kokoa; cin>>rize>>syaro>>tiya>>kokoa;
        rep(i,n){
            if(v[i].first.second<=rize && v[i].second.first<=syaro&&v[i].second.second<=tiya &&
               v[i].first.second*4+v[i].second.first*9+v[i].second.second*4<=kokoa)
                ans.push_back(v[i].first.first);
        }
        if(ans.size()==0){cout<<"NA"<<endl; continue;}
        else rep(i,ans.size())cout<<ans[i]<<endl;
    }
}

Measured memory_bytes: 3136
#include<iostream>
#include<cstdio>
#include<string>
#include<stdlib.h>
using namespace std;
class STACK{
    public:
       int top=0;
       void push(int* N ,int n){
           top+=1;
           N[top]=n;
       }
       int pop(int* N){
           top-=1;
           return N[top+1];
       }
};

int main(){
    int N[1000],i,a,b,k;
    char ch[1000];
    i=0;
    STACK stack;
    while(cin>>ch){
        if(ch[0] == '+') {
            b=stack.pop(N);
            a=stack.pop(N);
            stack.push(N,a+b);
            
        }else if(ch[0] == '-'){
            b=stack.pop(N);
            a=stack.pop(N);
            stack.push(N,a-b);
        }else if(ch[0] == '*'){
            b=stack.pop(N);
            a=stack.pop(N);
            stack.push(N,a*b);
            
        }else{
            stack.push(N,atoi(ch));
        }
    }
    k=stack.pop(N);
    cout<<k<<endl;
    return 0;
}



Measured memory_bytes: 3052
import numpy as np
import math

buf=input().split(" ")

N=int(buf[0])
D=int(buf[1])

arr = np.empty((0,D), int)

for i in range(N):
  buf=input().split(" ")
  buf = [int(s) for s in buf]

  arr=np.append(arr, [buf], axis=0)
  

buf=0
c=0

for i in range(N):
  for j in range(N):
    if i<j:
      for k in range(D):
        buf=abs((arr[i,k]-arr[j,k])*(arr[i,k]-arr[j,k]))+buf
      buf=math.sqrt(buf)
      if buf.is_integer() == True:
        c=c+1
      buf=0
          
print(c)

Measured memory_bytes: 12424
#include<bits/stdc++.h>
using namespace std;
const int N=2e5+1;
int n,m,x,y,d[N],I,M;
vector<int>a[N];
void D(int k,int f)
{
	for(int i=0;i<a[k].size();i++)
		if(a[k][i]!=f)
			d[a[k][i]]=d[k]+1,D(a[k][i],k);
}
int main()
{
	cin>>n;
	m=n-1;
	while(m--&&cin>>x>>y)
		a[x].push_back(y),a[y].push_back(x);
	D(1,0);
	for(int i=1;i<=n;i++)
		if(d[i]>d[I])
			I=i;
	d[I]=0,D(I,0);
	for(int i=1;i<=n;i++)
		M=max(M,d[i]);
	if(M%3!=1)
		cout<<"First";
	else
		cout<<"Second";
	return 0;
}

Measured memory_bytes: 24448
#include <bits/stdc++.h>
    using namespace std;
    #define ll long long int
    #define pb push_back
    #define mk make_pair
    #define ft first
    #define sc second
    #define ppb pop_back
    #define sz size
    #define forn(i,a,n) for(i=a;i<n;i++)
    #define M 1000000007
    #define inf 2e18


    int main() {

    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
        
    int a,b;
    cin>>a>>b;
    string a1,b1;
    char a2 = '0'+a, b2= '0'+b;
    for(ll i=0;i<a;i++)b1+=b2;
    for(ll i=0;i<b;i++)a1+=a2;
    if(a1<b1)
        cout<<a1;
    else
        cout<<b1;

    return 0;
    }

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

typedef long long ll;

const ll BATS = (ll)1e15;

int is_possible(ll t, ll t1, ll t2, ll a1, ll a2, ll b1, ll b2) {
    ll diff = t1*a1 + t2*a2 - t1*b1 - t2*b2;

    if (t > (ll)1e18 / abs(diff)) return 0;

    diff *= (t - 1);

    int res = 0;
    if (1) {
        ll bef = diff;
        diff += t1 * a1;
        diff -= t1 * b1;
        res += ((diff >= 0) & (bef < 0)) | ((diff <= 0) & (bef > 0)) | (bef == 0);
    }
    if (2) {
        ll bef = diff;
        diff += t2 * a2;
        diff -= t2 * b2;
        res += ((diff >= 0) & (bef < 0)) | ((diff <= 0) & (bef > 0));
    }
    return res;
}

int main() {
    ll t1,t2; scanf("%lld %lld", &t1, &t2);
    ll a1,a2; scanf("%lld %lld", &a1, &a2);
    ll b1,b2; scanf("%lld %lld", &b1, &b2);

    if (t1*a1 + t2*a2 == t1*b1 + t2*b2) {
        printf("infinity\n");
        return 0;
    }

    ll res = 1;
    for (ll lo=1,hi=BATS; lo<=hi; ) {
        ll mid = (lo + hi) / (ll)2;
        int ret = is_possible(mid, t1,t2, a1,a2, b1,b2);

        if (ret == 0) {
            hi = mid - 1;
        } else if (ret == 1) {
            res = max(res, (ll)2 * mid - (ll)1);
            lo = mid + 1;
        } else if (ret == 2) {
            res = max(res, (ll)2 * mid);
            lo = mid + 1;
        }
    }

    printf("%lld\n", res - (ll)1);
    return 0;
}


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

int main(){
    int n;
    cin >> n;
    bool ans = true;
    set<int> A;
    for(int i = 0; i < n; i++){
        int a;
        cin >> a;
        if (A.find(a) != A.end())ans = false;
        A.insert(a);
    }
    if (ans) cout << "YES" << endl;
    else cout << "NO" << endl;
    return 0;
}

Measured memory_bytes: 9600
#include <iostream>
#include <map>

using namespace std;

int main(){
    int n;
    cin >> n;
    map<long long, int> v;
    long long x;
    for (int i = 0; i < n; i++){
        cin >> x;
        v[x]++;
    }
    auto it = --v.end();
    long long a = -1;
    while (it != v.begin()){
        //cout << (*it).first << ' ' << (*it).second << endl;
        if ((*it).second > 1){
            if ((*it).second >= 4){
                long long ans = (*it).first * (*it).first;
                long long ans2 = a * (*it).first;
                ans = max(ans, ans2);
                cout << ans << endl;
                return 0;
            }
            if (a != -1){
                long long ans = a * (*it).first;
                cout << ans << endl;
                return 0;
            } else {
                a = (*it).first;
            }
        }
        it--;
    }
    if ((*it).second > 1){
        if ((*it).second >= 4){
            long long ans = (*it).first * (*it).first;
            long long ans2 = a * (*it).first;
            ans = max(ans, ans2);
            cout << ans << endl;
            return 0;
        }
        if (a != -1){
            long long ans = a * (*it).first;
            cout << ans << endl;
            return 0;
        } else {
            a = (*it).first;
        }
    }
    cout << 0 << endl;
    return 0;
}

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

#define fast ios::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL)
#define int long long
#define endl '\n'

using namespace std;

const int N = 2e5 + 77 , M = 1e9+7;
int A[N] , C[N];
string s;

int32_t main(){
    fast;
    int n , k ; cin >> n >> k ;
    for(int i = 0 ; i < n ; ++i) cin >> A[i];
    int ans = 0;
    
    for(int i = 0 ; i < n ;++i){
        int a , b ;
        a = b = 0;
        for(int j= 0 ; j < i ; ++j) if(A[j]>A[i]) a++;
        b = a;
        for(int j = i+1 ; j < n ; ++j) if(A[j] > A[i]) b++;
        ans = (ans + (k*(k-1)/2)%M * b%M +a*k)%M;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3560
#include<bits/stdc++.h>
#define pb push_back
#define pob pop_back
#define pf push_front
#define pof pop_front
#define nd second
#define st first
using namespace std;
using ll=long long;
using pii=pair<int,int>;
using pll=pair<ll,ll>;
using vi=vector<int>;
using vl=vector<ll>;
using mii=map<int,int>;
using si=set<int,int>;
using vpi=vector<pii>;
using vpl=vector<pll>;

const int N=(int)1e5+5;

int n,m,a,b,c,q,dp[N][3],pom[3];
vi V;

int R(int l, int p){
	return rand()%(p-l+1)+l;
}

void wczytaj(){
	cin>>n;
	for (int i=1; i<=n; ++i){
		for (int j=0; j<3; ++j){
			cin>>a;
			for (int k=0; k<3; ++k){
				if (k!=j){
					dp[i][j]=max(dp[i][j],dp[i-1][k]+a);
				}
			}
//			cout<<dp[i][j]<<' ';
		}
//		cout<<'\n';
	}
	int wyn=0;
	for (int i=0; i<3; ++i)wyn=max(wyn,dp[n][i]);
	cout<<wyn<<'\n';
}

void solve(){

}

int main(){
	ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
	int ilosc_przypadkow_testowych=1;
//	cin>>ilosc_przypadkow_testowych
	for (int i=1; i<=ilosc_przypadkow_testowych; ++i){
		wczytaj();
		solve();
	}
}

Measured memory_bytes: 1408
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
template<typename T> bool chmax(T &a,T b){if(a<b){a=b;return true;}return false;}
template<typename T> bool chmin(T &a,T b){if(a>b){a=b;return true;}return false;}
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define all(vec) vec.begin(),vec.end()
typedef long long ll;
typedef pair<ll,ll> pll;
typedef pair<int,int> pii;
typedef tuple<ll,ll,ll> tlll;
typedef tuple<int,int,int> tiii;
const ll mod=1e9+7;
const int inf=1<<30;

int main(){
  int n; cin >> n;
  int m=n%10;
  if(m==2||m==4||m==5||m==7||m==9){
    cout << "hon" << endl;
  }
  else if(m==3){
    cout << "bon" << endl;
  }
  else{
    cout << "pon" << endl;
  }
  
}

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

int n, a;
bool f = 1;

int main()
{
	cin >> n;

	for (int i = 0; i < n; i++) {
		cin >> a;

		if (a % 2 == 0 && ((a % 3 != 0) && (a % 5 != 0)))
			f = 0;
	}

	if (f)
		cout << "APPROVED" << endl;
	else
		cout << "DENIED" << endl;

	return 0;
}

Measured memory_bytes: 256
N = int(input())
w = input()

l = w[-1]
a = []

a.append(w)

f_no = False

for n in range(N-1):
    w = input()
    if l != w[0]:
        f_no = True
    a.append(w)
    l = w[-1]

if f_no == False:
    if len(a) == len(list(set(a))):
        print('Yes')
    else:
        print('No')
else:
    print('No')


Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
const long long MX=1e18;
const long long MD=1e9+7;
const int N=1e5+5;
int dp[1010][1010],n,m;
char gr[1010][1010];
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    cin>>n>>m;
    for(int i=0;i<n;i++)
    {
        for(int j=0;j<m;j++)cin>>gr[i][j];
    }
    if(gr[0][0]=='.')dp[0][0]=1;
    for(int i=0;i<n;i++)
    {
        for(int j=0;j<m;j++)
        {
            if(i==0&&j==0)continue;
            if(gr[i][j]=='.')
            {
                if(i-1>=0)dp[i][j]+=dp[i-1][j];
                if(j-1>=0)dp[i][j]+=dp[i][j-1];
                dp[i][j]%=MD;
            }
        }
    }
    cout<<dp[n-1][m-1];
}


Measured memory_bytes: 5248
#include <bits/stdc++.h>
#define rep(i, n) for(int i=0; i<n; i++)
#define repr(i, n) for(int i=n; i>=0; i--)
#define reps(i, s, e) for(int i=s; i<e; i++)
#define inf 1e18
#define vsort(v) sort(v.begin(), v.end())
#define vsortr(v) sort(v.begin(), v.end(), greater<ll>())
#define sz(x) x.size()
#define ceil(a, b) (a+b-1)/b
#define ok cout << "ok" << endl;
using namespace std;
using ll = long long;
template<typename T> inline bool chmax(T &a, T b){ if(a<b){ a=b; return true; } return false; }
template<typename T> inline bool chmin(T &a, T b){ if(b<a){ a=b; return true; } return false; }
template<typename T> T gcd(T a, T b){ if(b==0) return a; return gcd(b, a%b); }
template<typename T> T lcm(T a, T b){ return a*b/gcd(a, b); }
template<typename T> T vdebug(vector<T> v){ for(auto vv : v){ cout << vv << " "; } cout << endl; }
template<typename T> T adebug(T arr[], int n){ rep(i, n){ cout << arr[i] << " "; } cout << endl; }
void ans(bool b){ if(b) cout << "Yes" << endl; else cout << "No" << endl; }
void ans2(bool b){ if(b) cout << "YES" << endl; else cout << "NO" << endl; }
int keta(ll num){ int k=0; while(num>0){ num/=10; k++; } return k; }
int dx[] = {1, -1, 0, 0, 1, -1, 1, -1};
int dy[] = {0, 0, 1, -1, 1, -1, -1, 1};


ll dp[100001];

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

    ll n, k, tmph;
    vector<ll> h;
    cin >> n >> k;
    rep(i, n){
        cin >> tmph;
        h.push_back(tmph);
    }

    rep(i, n){
        dp[i] = inf;
    }
    dp[0] = 0;

    rep(i, n){
        reps(j, 1, k+1){
            dp[i+j] = min(dp[i+j], dp[i] + abs(h[i+j]-h[i]));
        }
    }

    cout << dp[n-1] << endl;

    return 0;
}

Measured memory_bytes: 1908
#include <bits/stdc++.h>
using namespace std;
using LL = long long int;
#define incID(i, l, r) for(int i = (l)    ; i <  (r); ++i)
#define decID(i, l, r) for(int i = (r) - 1; i >= (l); --i)
#define incII(i, l, r) for(int i = (l)    ; i <= (r); ++i)
#define decII(i, l, r) for(int i = (r)    ; i >= (l); --i)
#define inc(i, n)  incID(i, 0, n)
#define dec(i, n)  decID(i, 0, n)
#define inc1(i, n) incII(i, 1, n)
#define dec1(i, n) decII(i, 1, n)
#define inID(v, l, r) ((l) <= (v) && (v) <  (r))
#define inII(v, l, r) ((l) <= (v) && (v) <= (r))
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define MT make_tuple
#define FI first
#define SE second
#define FR front()
#define BA back()
#define ALL(v) v.begin(), v.end()
#define RALL(v) v.rbegin(), v.rend()
auto setmin   = [](auto & a, auto b) { return (b <  a ? a = b, true : false); };
auto setmax   = [](auto & a, auto b) { return (b >  a ? a = b, true : false); };
auto setmineq = [](auto & a, auto b) { return (b <= a ? a = b, true : false); };
auto setmaxeq = [](auto & a, auto b) { return (b >= a ? a = b, true : false); };
#define SI(v) static_cast<int>(v.size())
#define RF(e, v) for(auto & e: v)
#define until(e) while(! (e))
#define if_not(e) if(! (e))
#define ef else if
#define UR assert(false)
#define IN(T, ...) T __VA_ARGS__; IN_(__VA_ARGS__);
void IN_() { };
template<typename T, typename ... U> void IN_(T &  a, U &  ... b) { cin >> a; IN_(b ...); };
template<typename T                > void OUT(T && a            ) { cout << a << endl; }
template<typename T, typename ... U> void OUT(T && a, U && ... b) { cout << a << " "; OUT(b ...); }

// ---- ----

vector<pair<LL, LL>> prime_factorization(LL x) {
	assert(x > 0);
	vector<pair<LL, LL>> f;
	for(LL i = 2; i <= x; i++) {
		if(i * i > x) { i = x; }
		if(x % i == 0) {
			f.EB(i, 0);
			while(x % i == 0) { f.back().SE++; x /= i; }
		}
	}
	return f;
}

int main() {
	IN(LL, n);
	auto pf = prime_factorization(n);
	LL ans = 0;
	RF(e, pf) {
		LL c = e.SE;
		inc1(i, n) { if(c >= i) { c -= i; ans++; } else { break; } }
	}
	OUT(ans);
}


Measured memory_bytes: 3636
n,a,b=map(int,input().split())

if n<=a:
    print(n)
    exit()

if n<=a+b:
    print(a)
    exit()

if a==0:
    print(0)
    exit()

if b==0:
    print(n)
    exit()

temp1=n//(a+b)

print(temp1*a+min(a,n%(a+b)))


Measured memory_bytes: 3060
/*
           Nothing is absolute.
     This is the only absolute truth.
*/

#include<bits/stdc++.h>

using namespace std;

using ull = unsigned long long;
using ll = long long;

#define READ freopen("in.txt", "r", stdin)
#define ROUT freopen("out.txt", "w", stdout)
#define pb push_back
#define endl '\n'

#define REP(i,a,b) for(int i=a; i<=b; i++)
#define arrL(i,a,b) for(int i=a; i<b; i++)

void fasterIO()
{
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
}

void fileIO()
{
    READ;
    ROUT;
}

void solve()
{
    int n, count=0;

    cin>>n;

    REP(i, 1, n){
        if((int)(log10(i)+1)%2!=0)
            count++;
    }

    cout<<count<<endl;
}

int main()

{
    ///fileIO();
    fasterIO();

    solve();

    return 0;
}


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

int main() {
  int n;
  cin>>n;
  bool ans=false;
  for(int i=1;i<=9;i++){
    for(int j=1;j<=9;j++){
      if(n==i*j)ans=true;
    }
  }
  if(ans)cout<<"Yes"<<endl;
  else cout<<"No"<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define endl "\n"
using namespace std;
#define ll long long
#define ld long double
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define repo(i,n) for(int i = 1; i < (int)(n); i++)
#define pb push_back
#define mp make_pair
#define np next_permutation
#define fi first
#define se second
#define all(x) (x).begin(),(x).end()
#define uniq(v) v.erase(unique(v.begin(),v.end()),v.end())
#define lb(v,x) (lower_bound(v.begin(),v.end(),x)-v.begin())
#define ub(v,x) (upper_bound(v.begin(),v.end(),x)-v.begin())
using Pair = pair<ll,pair<int,int>>;
#define pq priority_queue<Pair, vector<Pair>, greater<Pair>> 
const ll mod=1000000007;
//const ll mod=998244353;
const ld pi=acos(-1.0);
const ll INF = 1LL<<61;
template<class T>bool chmax(T &a, const T &b) { 
  if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) {
  if (b<a) { a=b; return 1; } return 0; }
ll gcd(ll x, ll y) { return y ? gcd(y, x % y) : x; }
ll lcm(ll x, ll y) { return x / gcd(x, y) * y; }
//intの最大値2147483647 ≒ 2×10^9
//long longの最大値9223372036854775807 ≒ 9×10^18
//'大文字'+=32;    で小文字に
//  cout << fixed << setprecision (20);   小数点以下2０桁まで
//実行時間制約2秒では２×10^8回くらいまで計算できる




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

  int h,w;
  cin>>h>>w;

  vector<vector<int>> p(h,vector<int>(w));
  rep(i,h){
    rep(j,w){
      cin>>p[i][j];
    }
  }

  rep(i,h){
    rep(j,w){
      int x;
      cin>>x;
      p[i][j]-=x;
      p[i][j]=abs(p[i][j]);
    }
  }

  bool ok[h][w][13000];
  memset(ok,false,sizeof(ok));

  ok[0][0][p[0][0]]=true;

  rep(i,h){
    rep(j,w){
      if(i+1<h) {
        int t=p[i+1][j];
        rep(k,13000){
          if(ok[i][j][k]) {
            ok[i+1][j][k+t]=true;
            ok[i+1][j][abs(k-t)]=true;
          }
        }
      }
      if(j+1<w) {
        int t=p[i][j+1];
        rep(k,13000){
          if(ok[i][j][k]) {
            ok[i][j+1][k+t]=true;
            ok[i][j+1][abs(k-t)]=true;
          }
        }
      }
    }
  }

  rep(i,13000){
    if(ok[h-1][w-1][i]) {
      cout << i << endl;
      return 0;
    }
  }

}

Measured memory_bytes: 84916