akhauriyash/Code-Regression huggingface dataset:
#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 FOR(i, m, n) for(int i = m; i < n; i++)
#define ALL(v) v.begin(), v.end()
#define MOD 1000000007
typedef long long ll;

using namespace std;

int main(void){
  while(true)
  {
    int x, y;
    cin >> x >> y;
    if (x == 0 && y == 0) break;
    if (x > y) {
      cout << y << " " << x << "\n";
    } else {
      cout << x << " " << y << "\n";
    }
  }
}


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

using namespace std;

using ll = long long;

const int MX = 100 * 1000 + 7;
vector<int> g[MX];

int ans = 0;

int dfs(int v, int k, int p = -1) {
    int mx = 0;
    for (int to : g[v]) {
        mx = max(mx, dfs(to, k, v) + 1);
    }
    bool fl = false;
    if (mx == k - 1 && v != 1 && p != 1) {
        ans++;
        fl = true;
    }
    if (fl) {
        return -1;
    }
    return mx;
}

int main() {
    ios_base::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr);
#ifdef BZ
    freopen("input.txt", "r", stdin);
#endif
    int n, k;
    cin >> n >> k;
    for (int i = 1; i <= n; i++) {
        int x;
        cin >> x;
        if (i == 1 && x != 1) {
            ans++;
        }
        if (i != 1) {
            g[x].push_back(i);
        }
    }
    dfs(1, k);
    cout << ans << "\n";
}




Measured memory_bytes: 12032
mnum = [0,2,5,5,4,5,6,3,7,6]



N,M = map(int, input().split())

A = list(map(int, input().split()))

dp=[-1 for _ in range(N + 100)]
dp[0] = 0

for i in range(N):
	for m in A:
		need = mnum[m]
		if(dp[i] >= 0):
			dp[i+need] = max(dp[i+need], dp[i] * 10 + m);

print(dp[N])

Measured memory_bytes: 51804
#define _USE_MATH_DEFINES
#include <math.h>
#include <algorithm>
#include <cctype>
#include <cmath>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <set>
#include <stack>
#include <string>
#include <vector>

using namespace std;
using LLONG = long long;
const LLONG MOD = 1000000007;

// Union-Find木（素集合森：Disjoint-Set Forest）
// グループ分けを木構造で管理するデータ構造
class UnionFindTree
{
private:
    // 各ノードの親ノード番号リスト
    vector<int> m_parents;

public:
    // コンストラクタ
    UnionFindTree(const int N) : m_parents(N)
    {
        // 最初は全ての親が自分自身＝根であるとして初期化
        for (int i = 0; i < N; ++i) m_parents[i] = i;
    }

    // データvが属する木の根を返す
    const int Root(const int v)
    {
        if (m_parents[v] == v) return v;
        return m_parents[v] = Root(m_parents[v]);
    }

    // データv1とv2の木を統合する
    void Unite(const int v1, const int v2)
    {
        int r1 = Root(v1), r2 = Root(v2);
        if (r1 == r2) return;
        m_parents[r1] = r2;
    }

    // ２つのデータが同じ木に属するかどうか判定
    const bool AreInSameTree(const int v1, const int v2)
    {
        return Root(v1) == Root(v2);
    }
};

int main()
{
    int N, M; cin >> N >> M;
    vector<pair<int, int>> edges;
    for (int i = 0; i < M; ++i)
    {
        int u, v; cin >> u >> v; --u; --v;
        edges.push_back({ u, v });
    }
    int ans = 0;
    for (int i = 0; i < M; ++i)
    {
        UnionFindTree uft(N);
        for (int j = 0; j < M; ++j)
        {
            if (i != j)
            {
                uft.Unite(edges[j].first, edges[j].second);
            }
        }
        if (!uft.AreInSameTree(edges[i].first, edges[i].second))
        {
            ++ans;
        }
    }
    cout << ans << endl;
}

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


void fst() {ios::sync_with_stdio(0);cin.tie(0);
    #ifndef ONLINE_JUDGE 
    freopen("input.txt", "r", stdin); 
    #endif
    }    
int nxt(){int x;cin>>x;return x;}
int nex_l(){long long x;cin>>x;return x;}
  
typedef long long ll; typedef vector<int> vi;typedef vector<bool> vb;typedef vector<vi> vvi; 
typedef vector<vb> vvb;typedef vector<ll> vl;typedef vector<vl> vvl;typedef pair<int,int> pii;
typedef vector<pair<int,int>> vpii;
  
#define fr first 
#define sc second 
#define pb push_back 
#define all(v) v.begin(), v.end()
#define binary(n) cout<<bitset<31>(n)<<"\n";
#define FOR(i,n) for(int i=0;i<n;i++)
#define rep(i,a,b) for(int i=a;i<b;i++)
#define input_arr(a,n) for(int i=0;i<n;i++)cin>>a[i];
#define print_arr(a,n) for(int i=0;i<n;i++)cout<<a[i]<<" ";
const int MOD=1e9+7;

int main(){
   // fst();
    int h=nxt(),w=nxt();
    vector<string> in(h);
    rep(i,0,h)cin>>in[i];
    vvi dp(h+1,vi(w+1,0));
    dp[1][1]=1;
    rep(i,1,h+1){
        rep(j,1,w+1){
            if(i>1)
            if(in[i-2][j-1]!='#' && in[i-1][j-1]!='#')dp[i][j]+=dp[i-1][j];
          
            if(j>1)
           if(in[i-1][j-2]!='#' && in[i-1][j-1]!='#')dp[i][j]+=dp[i][j-1];
            dp[i][j]=dp[i][j]%MOD;
        }
    }
    cout<<dp[h][w];

}

Measured memory_bytes: 5248
#include <iostream>
#include <vector>
#include <iomanip>
using namespace std;
#define int int64_t


signed main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    
    double L;
    cin >> L;
    
    L /= 3;
    
    L = L * L * L;
    
    
    cout << fixed;
    cout << setprecision(12);
    cout << L;
    return 0;
}


Measured memory_bytes: 256
n = int(input())
task_lis = sorted([[int(i) for i in input().split()] for _ in range(n)], key = lambda x:x[1])


sum_a = 0
ch_over = 1

for i in range(n):
    sum_a += task_lis[i][0]
    if task_lis[i][1] < sum_a:
        ch_over = 0
        break

if ch_over == 0:
    print("No")
else:
    print("Yes")


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

using namespace std;

#define rep(i,n) for(int i=0;i<n;++i)
#define Rep(i,n) for(int i=1;i<=n;++i)
#define rrep(i,n) for(int i=n-1;0<=i;--i)
#define rRep(i,n) for(int i=n;0<i;--i)
#define range(i,a,b) for(int i=(a);i<(b);++i)
#define scani(a) scanf("%d",&a)
#define scanr(a) scanf("%lf",&a)
#define scans(s) scanf("%s",s)
#define printi(a) printf("%d",a)
#define printr(a) printf("%lf",a)
#define prints(s) printf("%s",s)
#define is_odd(n) (n&1)
#define is_even(n) ((n+1)&1)
#define mp make_pair
#define pb push_back
#define fst first
#define snd second
#define all(x) x.begin(), x.end()
#define EPS 1e-8
#define INF 1e8
#define PI acos(-1.0)

typedef double Real;
typedef int Int;
typedef vector<Int> vi;
typedef vector<vector<Int> > vvi;
typedef pair<Int,Int> pii;

inline Real sr(Real a) {return sqrt(max(a, (Real)0));}
template <typename T> inline T sq(T a) {return a * a;}
const vi dy = {-1, 0, 1, 0}, dx = {0, -1, 0, 1};
vector<string> split(const string &s, char d) {vector<string> r;stringstream t(s);string x;while(getline(t,x,d))if(!x.empty())r.push_back(x);return r;}

void solve()
{
  for(;;)
  {
    Int n, r; scani(n); scani(r);
    if(n == 0 && r == 0) break;

    Int deck[n], buf[n];
    rep(i, n) deck[i] = n-i;

    rep(i, r)
    {
      Int p, c; scani(p); scani(c);

      copy(deck, deck+p+c-1, buf);
      copy(buf+p-1, buf+p+c-1, deck);
      copy(buf, buf+p-1, deck+c);
    }

    cout << *deck << endl;
  }
}

int main()
{
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(9);

  solve();

  return 0;
}

Measured memory_bytes: 1244
/*
power code taken from geeks for geeks
*/

#include <bits/stdc++.h>
#define MODD 1000000007LL
#define MAX_SIZE 100000000
#define MAX_N 100001
using namespace std;
typedef long long ll;

ll max(ll a,ll b){return a>b?a:b;}
ll min(ll a,ll b){return a<b?a:b;}
double max(double a,double b){return a>b?a:b;}
double min(double a,double b){return a<b?a:b;}

ll modd(ll a){if(a<0LL) return a*-1LL;return a;}
double modd(double a){if(a<0.0) return a*-1.0;return a;}

ll modulo(ll a){return a % MODD; }

ll power(ll k, ll p){
    if (p == 0)
        return 1LL;
 
    ll P = power(k, p/2LL);
    P = (P * P) % MODD;
 
    if (p % 2 == 1)
        P = (P * k) % MODD;
 
    return P;
}

bool _check(ll a[],ll b[], ll n){
    for(ll i=0;i<n;i++){
        if(a[i]!=b[i]){
            return false;
        }
    }
    return true;
}

int main(){


    // #ifndef ONLINE_JUDGE 

    // // For getting input from input.txt file 
    // freopen("input.txt", "r", stdin); 

    // // Printing the Output to output.txt file 
    // freopen("output.txt", "w", stdout); 
    // #endif 


    ios_base::sync_with_stdio(false);
    cin.tie(NULL);

    ll k,n;
    cin>>k>>n;
    ll arr[n];
    for(ll i=0;i<n;i++){
        cin>>arr[i];
    }
    ll ans=0;
    ll d;
    vector<ll> diff;
    diff.push_back(arr[0]);
    for(ll i=1;i<n;i++){
        d=arr[i]-arr[i-1];
        diff.push_back(d);
        ans+=d;
    }
    d=k-arr[n-1]+arr[0];
    ans+=d;
    diff.push_back(d);
    sort(diff.begin(), diff.end());
    ans-=diff[diff.size()-1];
    cout<<ans<<endl;
    
    return 0;
}


Measured memory_bytes: 3956
#include <iostream>
#include <vector>
#include <numeric>
using namespace std;

struct uf {
public:
  int cnt;
  vector<int> f;
  uf(int n) : f(n + 1), cnt(n) {
    iota(f.begin(), f.end(), 0);
  }

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

  void merge(int u, int v) {
    int pu = find(u);
    int pv = find(v);
    if (pu == pv) return;
    f[pv] = pu;
    --cnt;
  }
  
};

int main() {
  std::ios::sync_with_stdio(false);
  std::cin.tie(nullptr);
  int n, m;
  cin >> n >> m;
  uf s(n);
  int ans = n;
  while(m--) {
    int u, v;
    cin >> u >> v;
    s.merge(u, v);
  }
  cout << s.cnt - 1 << '\n';
  return 0;
}


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

using namespace std;
int main (){
    string s,t;
    cin>> s >> t ;
    int comp=0;
    int i;
    int len =s.size();
    bool flag=false;
    for (int j = 0; j < len; j++){
        i=j;
        while(comp<len){
            if(s[comp+i]!=t[comp]) break;
            comp++;
            if(comp+i==len)i-=len;
            if(comp==len) flag=true;
        }
        comp=0;
    }
    if(flag) cout << "Yes" << "\n";
    else cout << "No" << "\n";
}

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

const int mod=998244353;
#define ll long long
#define ld long double
#define pb push_back
#define Dracarys ios_base::sync_with_stdio(false);cin.tie(NULL);
#define all(x) x.begin(),x.end()

ll po(ll x,ll y,ll md=mod){
	ll res=1;
	x%=md;
	
	while(y){
		if (y&1){
			res=(res*x)%md;
		}
		y>>=1;
		x=(x*x)%md;
	}
	return res;
}

void solve(){
	string s;
	cin>>s;
	ll n=s.size();
	s='*'+s;
	ll arr[26][n+2],suff[26][n+2];
	memset(arr,0,sizeof(arr));
	
	for (ll i=1;i<=n;i++){
		arr[s[i]-'a'][i]++;
	}
	for (ll i=0;i<26;i++){
		for (ll j=1;j<=n;j++){
			arr[i][j]+=arr[i][j-1];
			suff[i][j]=1e16;
		}
		suff[i][0]=suff[i][n+1]=1e16;
	}
	
	for (ll i=0;i<26;i++){
		ll pass=1e16;
		for (ll j=n;j>=1;j--){
			suff[i][j]=min(suff[i][j],pass);
			pass=min(j-2*arr[i][j],pass);
		}
	}
	
	bool flag=false;
	pair<ll,ll> sol=make_pair(-69,-69);
	for (ll i=1;i<=n-1;i++){
		//cout<<(i-1)-2*arr[s[i]-'a'][i-1]<<" - "<<suff[s[i]-'a'][i]<<"\n";
		if ((i-1)-2*arr[s[i]-'a'][i-1]>suff[s[i]-'a'][i]){
			flag=true;
		}
		if (flag){
			
			ll cnt=1,sz=1;
			for (ll j=i+1;j<=n;j++){
				if (s[j]==s[i])
				cnt++;
				sz++;
				if (cnt>sz/2){
					sol={i,j};
					break;
				}
			}
			break;
		}
	}	
	
	if (flag){
		cout<<sol.first<<" "<<sol.second<<"\n";
	}
	else{
		cout<<"-1 -1\n";
	}
}

int main(){
	
	Dracarys

	ll t=1;
	//cin>>t;
	while(t--){
		solve();
	}
	return 0;
}



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

// definition {{{ 1

// scaning {{{ 2
#define Scd(x) scanf("%d", &x)
#define Scd2(x,y) scanf("%d%d", &x, &y)
#define Scd3(x,y,z) scanf("%d%d%d", &x, &y, &z)

#define Scll(x) scanf("%llu", &x)
#define Scll2(x,y) scanf("%llu%llu", &x, &y)
#define Scll3(x,y,z) scanf("%llu%llu%llu", &x, &y, &z)

#define Scc(c) scanf("%c", &c);
#define Scs(s) scanf("%s", s);
#define Scstr(s) scanf("%s", &s);
// }}} 2

// constants {{{ 2
#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
// }}} 2

// systems {{{ 2
#define Rep(x,y) for(int x = 0; x < y; x++)
#define Repe(x,y,z) for(int x = z; x < y; x++)
// }}} 2

// output {{{ 2
#define YesNo(a) (a)?printf("Yes\n"):printf("No\n");
// }}} 2

// }}} 1

int main() {

    int x,a,b;
    Scd3(x,a,b);

    if( a >= b )
        printf ("delicious\n");
    else if( b-a <= x )
        printf ("safe\n");
    else
        printf ("dangerous\n");

    return 0;
}



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

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    int x;
    cin>>x;
    if(x>=1800)
    cout<<1<<endl;
    else if(x>=1600)
    cout<<2<<endl;
    else if(x>=1400)
    cout<<3<<endl;
    else if(x>=1200)
    cout<<4<<endl;
    else if(x>=1000)
    cout<<5<<endl;
    else if(x>=800)
    cout<<6<<endl;
    else if(x>=600)
    cout<<7<<endl;
    else if(x>=400)
    cout<<8<<endl;
	return 0;
}



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

using namespace std;
using   ll=long long;

#define fast        	ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)

#define endl        	"\n"
#define pb          	push_back
#define mp          	make_pair
#define F           	first
#define S           	second
#define int             long long int
#define pll				pair<int , int>

#define ALL(v)      	v.begin(),v.end()
#define ALLR(v)     	v.rbegin(),v.rend()
#define pii         	3.14159265358979323
#define inf     		LLONG_MAX
#define ones(x)     	__builtin_popcount(x)
#define fill(a,b)   	memset(a,b,sizeof(a))
#define mod 			1000000007
#define hell            998244353 

ll mod_pow(ll a,ll b,ll m) 
{
    ll res = 1;
    while(b)	
    {
        if(b&1) 	
        {
        	res=(res*a) % m;
        }
        a=(a*a) % m;
        b>>=1;
    }
    return res;
}

ll mod_inverse(ll a) 
{
	return mod_pow(a , mod-2 , mod);
}

void solve() 
{
	string s;
	
	cin >> s;
	
	for(int i = 0; i < 3; ++i) {
		if(s[i] == s[i+1]) {
			cout << "Bad";
			return;
		}
	}
	
	cout << "Good";
}

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


Measured memory_bytes: 3580
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cstring>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <sstream>
#include <queue>
#include <functional>

using namespace std;

#define rep(i,n) for((i)=0;(i)<(int)(n);(i)++)
#define foreach(itr,c) for(__typeof((c).begin()) itr=(c).begin();itr!=(c).end();itr++)
inline int in(){ int x; scanf("%d",&x); return x;}

typedef pair<int,int> P;

int main(){
  int i,j,k;
  int s,d;

  while(scanf("%d %d",&s,&d)){
    if(s == 0 && d == 0) break;
    vector< vector<int> > a(s, vector<int>(d,0));
    vector< vector<int> > b(d, vector<int>(d,0));

    rep(i,s) rep(j,d) scanf("%d",&a[i][j]);
    rep(i,d-1) for(j = i+1; j < d; j++){
      int t; scanf("%d",&t);
      b[i][j] = b[j][i] = t;
    }
/*
    cout << "a " << endl;
    rep(i,s){ rep(j,d) cout << a[i][j] << ' '; cout << endl;}
    rep(i,d-1){ for(j = i+1; j < d; j++) cout << b[i][j] << ' '; cout << endl;}
*/
    int ans = 0;
    int rest = d;
    vector<int> end(d,0);
    priority_queue<P, vector<P>, greater<P> > q;
    rep(i,s) rep(j,d) if(a[i][j] != 0) q.push(P(a[i][j],j));
    while(!q.empty()){
      P p = q.top(); q.pop();

      if(end[p.second] == 1) continue;// cout << p.first << ' ' << p.second << endl;
      ans += p.first;
      end[p.second] = 1;
      rest--;
      if(rest == 0) break;
      rep(i,d) if(!end[i] && b[p.second][i] != 0) q.push(P(b[p.second][i], i));
    }

    cout << ans << endl;
  }

  return 0;
}

Measured memory_bytes: 0
#pragma GCC optimize ("O2")
#pragma GCC diagnostic ignored "-Wunused-variable"
#pragma GCC diagnostic ignored "-Wunused-result"
#pragma GCC diagnostic ignored "-Wunused-label"
#pragma GCC diagnostic ignored "-Wsign-compare"

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

#define rep(i, a, b) for (int i = (a); i < (b); ++i)
#define trav(a, A) for (auto & a : A)
#define all(a) (a).begin (), (a).end ()
#define f first
#define s second

typedef long long ll;

const ll MOD = 1e+9+7;
const ll INFLL = 0x3f3f3f3f3f3f3f3f;
const int INF = 0x3f3f3f3f;
const ll MAXN = 1e+6+7;

vector <vector <int>> fd, bk;
vector <int> viz, swp, qtd;

int dfs (int tgt, int flag)
{
	swp.push_back (tgt);
	viz[tgt] = flag;
	int ans = 1;
	trav (a, fd[tgt])
		if (!viz[a])
		 	ans += dfs (a, flag);
	return ans;
}



int main ()
{
	ios_base::sync_with_stdio (0);
	cin.tie (0);
	int tc = 1; //cin >> tc;
	while (tc--)
	{
		int i, j, n, m, k;
		cin >> n >> m >> k;
		fd.resize (n);
		bk.resize (n);
		viz.resize (n, 0);
		qtd.resize (n, 0);
		for (i = 0; i < m; ++i)
		{
			int a, b; cin >> a >> b; --a, --b;
			fd[a].push_back (b);
			fd[b].push_back (a);
		}
		for (i = 0; i < k; ++i)
		{
			int a, b; cin >> a >> b; --a, --b;
			bk[a].push_back (b);
			bk[b].push_back (a);
		}
		int cur = dfs (0, 1); --cur;
		trav (a, swp)
		{
			qtd[a] = cur;
			trav (b, fd[a])
				if (viz[a] == viz[b])
					--qtd[a];
			trav (b, bk[a])
				if (viz[a] == viz[b])
					--qtd[a];
		}
		for (i = 1; i < n; ++i)
		{
			if (viz[i]) continue;
			swp.clear ();
			cur = dfs (i, i + 1); --cur;
			trav (a, swp)
			{
				qtd[a] = cur;
				trav (b, fd[a])
					if (viz[a] == viz[b])
						--qtd[a];
				trav (b, bk[a])
					if (viz[a] == viz[b])
						--qtd[a];
			}
		}
		trav (a, qtd) cout << a << ' ';
		cout << '\n';
	}

	return 0;
}



Measured memory_bytes: 13948
#include <algorithm>
#include <iostream>
#include <map>
#include <numeric>
#include <set>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>
#include <queue>
#define MOD (1000000007l)
#define rep(i, n) for(long i = 0; i < n; i++)

using namespace std;

void solve() {
  long N;
  cin >> N;

  double ans = 0;
  
  rep (i, N) {
    double x;
    string u;
    cin >> x >> u;
    if (u == "JPY") ans += x;
    else ans += x * 380000.0;
  }

  cout << ans << endl;
}

int main(void) {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout.precision(12);
  solve();
  return 0;
}


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

int main(){

  int x[4][3][10];
  int n, X,Y,Z,m;

   for(int i =0; i< 4; ++i){
    for(int k =0; k < 3; ++k){
      for(int t=0; t<10;++t){
	x[i][k][t] = 0; 
      }
    }
  }
  


  cin >> n;

  for(int i = 0; i < n; ++i){
    cin >> Z >> Y >> X >> m;

    x[Z-1][Y-1][X-1] += m;
    
  }

  for(int i =0; i< 4; ++i){
    for(int k =0; k < 3; ++k){
      for(int t=0; t<10;++t){
	cout <<" " << x[i][k][t] ;
      }
      cout << endl;
    }
    if(i != 3) cout << "####################"<<endl; 
  }
  

    
  return 0;
}



Measured memory_bytes: 3068
#include <bits/stdc++.h>
#define repp(i,l,r)for(long long i=(l);i<(r);i++)
#define rep(i,n) for (long long i = 0; i < (n); ++i)
#define per(i,n) for (long long i = (n); i >= 0; --i)
const int INF = 2147483647;//int max
const long long int MOD = 1000000007;
using namespace std;
using ll = long long;
using P = pair<int,int>;
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }

int scoring(int score , int choose, int day, vector<int> &c,vector<vector<int>> &s,vector<int> last){
    --choose;
    score += s[day][choose];
    int hiku = 0;
    ++day;
    rep(i,26){
        hiku += c[i]*(day - last[i]);
    }
    score -= hiku;
    return score;
}

//ミョ(-ω- ?)
int main() {
    int d;
    cin >> d;
    const int n = 26;
    vector<int> c(n,0);
    rep(i,n)cin >> c[i];
    vector<vector<int>> s(365,vector<int>(n,0));
    rep(i,d)rep(j,n)cin >> s[i][j];
    vector<int> last(n,0);
    int score = 0;
    rep(i,d){
        int res = 0;
        int max_score = 0;
        rep(j,n){
            int ch = scoring(score,j,i,c,s,last);
            if(max_score < ch){
                res = j;
                max_score = ch;
            }
        }
        cout << res + 1 << endl;
        last[res] = i+1;
        score = max_score;
    }
    return 0;
}

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

using namespace std;

int main()
{
  int cup[3] = {1,0,0};
  string cupab("A,B");
  string cupba("B,A");
  string cupac("A,C");
  string cupca("C,A");
  string cupbc("B,C");
  string cupcb("C,B"); 
  string swapping;

  while (cin >> swapping){
    int temp;
    if(swapping == cupab || swapping == cupba){
      temp = cup[0];
      cup[0] = cup[1];
      cup[1] = temp;
    }
    else if(swapping == cupac || swapping == cupca){
      temp = cup[0];
      cup[0] = cup[2];
      cup[2] = temp;
    }
    else if(swapping == cupbc || swapping == cupcb){
      temp = cup[1];
      cup[1] = cup[2];
      cup[2] = temp;
    }
  }
  
  if(cup[0] == 1){
    cout<<"A"<<endl;
  }
  else if(cup[1] == 1){
    cout<<"B"<<endl;
  }
  else if(cup[2] == 1){
    cout<<"C"<<endl;
  }

  return 0;
}


Measured memory_bytes: 3044
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, ll> Pil;

int N;
const int MAX_N = 2.0e5 + 10;
ll A[MAX_N];

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

    ll cnt = 0;
    for (int i = 1; i < N; i++) {
        if (A[i-1] > A[i]) {
            cnt += A[i-1] - A[i];
            A[i] = A[i-1];
        }
    }

    cout << cnt << endl;

    return 0;
}


Measured memory_bytes: 5180
# ALDS1_7_A Rooted Trees
import sys


class Node:
    def __init__(self):
        self.child = []
        self.parent = -1
        self.type = 'root'


def calc_depth(node):
    global depth_num
    if node.parent != -1:
        depth_num += 1
        calc_depth(tree[node.parent])
    return depth_num


n = int(input())
tree = []
for i in range(n):
    node = Node()
    tree.append(node)

for i in range(n):
    A = list(map(int, sys.stdin.readline().strip().split()))
    if A[2:]:
        tree[A[0]].child = A[2:]
    else:
        tree[A[0]].type = 'leaf'

    for j in A[2:]:
        tree[j].parent = A[0]
        if tree[j].type != 'leaf':
            tree[j].type = 'internal node'

for i in range(n):
    depth_num = 0
    depth = calc_depth(tree[i])
    if n == 1:
        type = 'root'
    else:
        type = tree[i].type
    print('node {}: parent = {}, depth = {}, {}, {}'.format(i, tree[i].parent, depth, type, tree[i].child))





Measured memory_bytes: 39992
#include <iostream>
#include <vector>
#include <algorithm>
#include <numeric>
using namespace std;

#define REP(i, n) for(int i = 0; i < (int)(n); ++i)
#define FOR(i, m, n) for(int i = (int)(m); i < (int)(n); ++i)


int main()
{
    int N;
    vector<int> num(3);
    cin >> N >> num[0] >> num[1] >> num[2];
    vector<string> s(N);
    REP(i, N) cin >> s[i];


    vector<char> ans;
    REP(i, N){
        // 選ばれているものを数字に変換
        int c1 = s[i][0] - 'A';
        int c2 = s[i][1] - 'A';
        int c3 = 3-c1-c2;
        if(num[c1]+num[c2] == 0){
            cout << "No" << endl;
            return 0;
        }

        bool flag = true;
        for(auto c: s[i]){
            int idx = c-'A';
            string next;
            next += c; 
            next += c3+'A';
            sort(next.begin(), next.end());
            if((num[idx] == 0) or (i+1 < N and num[idx] == 1 and num[c3] == 0 and (s[i+1] == next))){
                ans.push_back(c);
                ++num[idx];
                --num[(idx == c1)? c2: c1];
                flag = false;
                break;
            }
        }
        if(flag){
            ans.push_back(s[i][0]);
            ++num[c1];
            --num[c2];
        }
        if(num[0] < 0 or num[1] < 0 or num[2] < 0){
            cout << "No" << endl;
            return 0;
        }
    }
    cout << "Yes" << endl;
    for(auto c: ans) cout << c << endl;

    return 0;
}

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

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

  ll n, m;
  priority_queue<ll> a;
  cin >> n >> m;
  ll entra;
  for (ll i = 0; i < n; i++) {
    cin >> entra;
    a.push(entra);
  }
  ll ans = 0;
  while(m) {
    ll topo = a.top();
    a.pop();
    topo >>= 1;
    a.push(topo);
    m--;
  }
  while(!a.empty()) {
    ans += a.top();
    a.pop();
  }
  cout << ans << '\n';
  return 0;
}


Measured memory_bytes: 1400
#pragma region Macros
#include <bits/stdc++.h>

#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) FOR(i, 0, n)
#define ALL(a) (a).begin(), (a).end()
#define SZ(x) ((int)(x).size())
#define IN(x, a, b) x >= a and x < b

using namespace std;
using ll = long long;

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;
}
template <typename T> constexpr T INF = numeric_limits<T>::max() / 2;
#pragma endregion

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int r;
  cin >> r;
  cout << pow(r, 2) << endl;

  return 0;
}

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

#define debug(x) cerr << #x << ": " << x << endl
#define debugArray(x,n) for(long long hoge = 0; (hoge) < (n); ++ (hoge)) cerr << #x << "[" << hoge << "]: " << x[hoge] << endl
using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef vector<ll> vll;
const ll INF = LLONG_MAX/2;
const ll MOD = 1e9+7;

signed main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  ll N;cin>>N;
  ll a[N];
  map<ll,ll> S;
  for(ll i=0;i<N;i++){
    cin>>a[i];
    S[a[i]]++;
  }
  if(S.size()>3){
    cout<<"No"<<endl;
    return 0;
  }
  if(N%3==0){
    bool isok=true;
    if(S.size()==3){
      ll sum=0;
      for(auto s:S){
        isok &= s.second==N/3;
        sum ^= s.first;
      }
      isok &= sum==0;
    }else if(S.size()==2){
      for(auto s:S){
        isok &= (s.second==N/3&&s.first==0)||(s.second==N*2/3);
      }
    }else{
      isok &= a[0]==0;
    }
    cout<<(isok? "Yes":"No")<<endl;
  }else{
    cout<<(S.size()==1&&a[0]==0? "Yes":"No")<<endl;
  }

  return 0;
}


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

typedef long long LL;
const int maxn = 1e5+3;
LL a[maxn*3], l[maxn], r[maxn];
priority_queue<LL, vector<LL>, greater<LL> >q;
priority_queue<LL>p;
int main()
{
    LL sum = 0, sum2=0, ans;
    int n, m;
    scanf("%d",&n);
    for(int i=1; i<=3*n; ++i)
    {
        scanf("%lld",&a[i]);
        if(i<=n) sum += a[i], q.push(a[i]);
        else if(i>2*n) sum2 += a[i], p.push(a[i]);
    }
    l[n] = sum;
    r[2*n+1] = sum2;
    for(int i=n+1; i<=2*n; ++i)
    {
        if(q.top() < a[i])
        {
            sum = sum - q.top() + a[i];
            q.pop();
            q.push(a[i]);
        }
        l[i] = sum;
    }
    r[2*n] = sum2;
    for(int i=2*n-1; i>=n; --i)
    {
        if(p.top() > a[i+1])
        {
            sum2 = sum2 - p.top() + a[i+1];
            p.pop();
            p.push(a[i+1]);
        }
        r[i] = sum2;
    }
    ans = l[n]-r[n];
    for(int i=n+1; i<=2*n; ++i)
        ans = max(ans, l[i]-r[i]);
    printf("%lld\n",ans);
    return 0;
}


Measured memory_bytes: 5108
N,A,B,C,D=map(int,input().split())
S=input()

# stoneCnt=S.count("#")

# if stoneCnt == 0:
# 	print("Yes")
# 	exit(0)


curStoneLen=0

# 先にBがいけるか考える
# いけなければOUT
for b in range(B-1,D):
	if S[b] == ".":
		curStoneLen = 0
	else:
		curStoneLen += 1

	if 2 == curStoneLen:
		print("No")
		exit(0)



curStoneLen=0

for a in range(A-1,C):
	if S[a] == ".":
		curStoneLen = 0
	else:
		curStoneLen += 1

	if 2 == curStoneLen:
		print("No")
		exit(0)

# print(maxAtoDSeqSpaceLen)

if D < C:
	# AはBをかわさないといけない
	maxAtoDSeqSpaceLen=0
	curSeqSpaceLen=0
	for BtoD in range(B-2,D+1):
		if S[BtoD] == ".":
			curSeqSpaceLen += 1
		else:
			curSeqSpaceLen = 0

		maxAtoDSeqSpaceLen=max(maxAtoDSeqSpaceLen,curSeqSpaceLen)

	if maxAtoDSeqSpaceLen < 3:
		# D+1までにかわすスペースが無い
		print("No")
		exit(0)	
else:
	# その他の場合は、Bを無視して良い
	pass


print("Yes")


Measured memory_bytes: 3572
#include<bits/stdc++.h>
#define ll long long int

using namespace std;

const ll mod=1000000007;
const ll inf=1e18;

int main(){

  ll n,k;
  cin >> n>>k;
  ll h[n];
  for(ll i=0;i<n;i++)cin >> h[i];

  sort(h,h+n);

  ll s=0;
  for(ll i=0;i<n-k;i++){
    s+=h[i];
  }

  cout << s << endl;

}

Measured memory_bytes: 5212
#include<stdio.h>
#define MAX 100000

int parent(int);
int left(int);
int right(int);

int main(){
  int H,i,A[MAX];

  scanf("%d",&H);
  
  for(i=1;i<=H;i++){
    scanf("%d",&A[i]);
  }
  for(i=1;i<=H;i++){
    printf("node %d: key = %d, ",i,A[i]);
    if(parent(i)>=1){
      printf("parent key = %d, ",A[parent(i)]);
    }
    if(left(i)<=H){
      printf("left key = %d, ",A[left(i)]);
    }
    if(right(i)<=H){
      printf("right key = %d, ",A[right(i)]);
    }
    printf("\n");
  }
  return 0;
}

int parent(int i){
  return i/2;
}

int left(int i){
  return 2*i;
}

int right(int i){
  return 2*i+1;
}



Measured memory_bytes: 2052
#!/usr/bin/env python
# -*- coding:utf-8 -*-
#from __future__ import print_function
import time
import sys
import io
import re
import math
from Queue import Queue
import collections
start = time.clock()
i = 0
(n,q)=map(int, raw_input().split())
datalist=[raw_input().split() for _ in range(n)]
datalist=collections.deque(datalist)
#print(datalist)
while len(datalist):
    data=datalist.popleft()
#    print data,datalist
    data[1]=int(data[1])
    if data[1]<=q:
        i+=data[1]
        print data[0],i
    else:
        i+=q
        data[1]-=q
        datalist.append(data)

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

a.sort(reverse = True)

width = 0
height = 0
cnt = 0
for i in range(n - 1):
    if a[i] == a[i + 1] and cnt == 0:
        width = a[i]
        cnt += 1
        del a[i + 1]
    elif a[i] == a[i + 1] and cnt == 1:
        height = a[i]
        break

print(width * height)

Measured memory_bytes: 14252
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using static System.Console;
using static System.Math;

namespace AtTest.ABC_147
{
    class D
    {
        static void Main(string[] args)
        {
            var sw = new System.IO.StreamWriter(OpenStandardOutput()) { AutoFlush = false };
            SetOut(sw);

            Method(args);

            Out.Flush();
        }

        static void Method(string[] args)
        {
            long n = ReadInt();
            long[] array = ReadLongs();
            long[] cnts = new long[61];
            for(int i = 0; i < n; i++)
            {
                long tmp = array[i];
                long div = 1;
                for (int j = 0; j < cnts.Length; j++)
                {
                    if ((tmp & div) > 0) cnts[j]++;
                    div *= 2;
                }
            }
            long res = 0;
            long digValue = 1;
            long mask = 1000000000 + 7;
            for(int i = 0; i < cnts.Length; i++)
            {
                long tmp = n - cnts[i];
                tmp *= digValue;
                tmp %= mask;
                tmp *= cnts[i];
                tmp %= mask;
                res += tmp;
                res %= mask;
                digValue *= 2;
                digValue %= mask;
            }
            WriteLine(res);
        }

        private static string Read() { return ReadLine(); }
        private static char[] ReadChars() { return Array.ConvertAll(Read().Split(), a => a[0]); }
        private static int ReadInt() { return int.Parse(Read()); }
        private static long ReadLong() { return long.Parse(Read()); }
        private static double ReadDouble() { return double.Parse(Read()); }
        private static int[] ReadInts() { return Array.ConvertAll(Read().Split(), int.Parse); }
        private static long[] ReadLongs() { return Array.ConvertAll(Read().Split(), long.Parse); }
        private static double[] ReadDoubles() { return Array.ConvertAll(Read().Split(), double.Parse); }
    }
}


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


using namespace std;
#define rep(i,n) for (int i = 0; i < (int)(n); ++i)
#define reps(i,n) for (int i = 1; i <= (int)(n); ++i)
#define repd(i,n) for (int i = (int)(n - 1); i >= 0; --i)
#define repds(i,n) for (int i = (int)(n); i > 0; --i)
#define loop(i,x,n) for (int i = (int)(x); i < (n); ++i)
#define loops(i,x,n) for (int i = (int)(x); i <= (n); ++i)
#define loopd(i,x,n) for (int i = (int)(x); i > (n); --i)
#define loopds(i,x,n) for (int i = (int)(x); i >= (n); --i)
#define itrep(i,s) for (auto i = begin(s); i != end(s); ++i)
#define itrepd(i,s) for (auto i = --end(s); i != begin(s); --i)
#define all(f,x,...) [&](decltype(x)& whole) { return (f)(begin(whole), end(whole), ##__VA_ARGS__); }(x)
#define rall(f,x,...) [&](decltype(x)& whole) { return (f)(rbegin(whole), rend(whole), ##__VA_ARGS__); }(x)
using ll = long long;
using ld = long double;
constexpr ll inf = static_cast<ll>(1e17);
constexpr int iinf = static_cast<int>(1e9);
constexpr double dinf = 1e10;
constexpr ld ldinf = 1e17;
ll mod = static_cast<ll>(1e9 + 7);
std::ostream& endn(std::ostream& os) { return os.put(os.widen('\n')); }
template<class T> constexpr int sz(const T& a) { return (int)a.size(); }
template<class T, class ... Args> constexpr void mins(T& a, Args... args) { a = min<T>({ a, args... }); }
template<class T, class... Args> constexpr void maxs(T& a, Args... args) { a = max<T>({ a,args... }); }

int n;
void solve() {
    cin >> n;

    map<int, int> kind;
    rep(i, n) {
        int a; cin >> a;
        ++kind[a];
    }

    int m;
    if (sz(kind) == 1 && ((m = kind.begin()->first) == n - 1 || n >= 2 * m)) { cout << "Yes" << endn; return; }
    if (sz(kind) != 2 || kind.begin()->first + 1 != (m = next(kind.begin())->first)) { cout << "No" << endn; return; }
    int k = kind.begin()->second, l = next(kind.begin())->second;
    if (m >= k + 1 && m <= k + l / 2) cout << "Yes" << endn;
    else cout << "No" << endn;

}

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    solve();
    cout << flush;
    return 0;
}



Measured memory_bytes: 4992
#include<stdio.h>
int main(){
  int max = 0;
  int now = 0;
  int N;
  char S[101];
  scanf("%d", N);
  scanf("%s", S);
  int i = 0;
  while(S[i]){
    if(S[i] == 'I'){
      now++;
    }else{
      now--;
    }
    if(now > max)
      max = now;
    i++;
  }
  printf("%d\n", max);
  return 0;
} 

Measured memory_bytes: 128
N = int(input())
TEN = 1
NINE = 1
EIGHT = 1
a = 10
b = 9
c = 8

mod = 10 ** 9 + 7

for i in range(64):
    if N % 2:
        TEN *= a
        TEN %= mod
        NINE *= b
        NINE %= mod
        EIGHT *= c
        EIGHT %= mod
    N //= 2
    a *= a
    a %= mod
    b *= b
    b %= mod
    c *= c
    c %= mod

print((TEN - 2 * NINE + EIGHT + mod * 2)%mod)

Measured memory_bytes: 61884
a, b = map(int, input().split())
if (0 < a):
  res = "Positive"

elif (a * b == 0) or (a * b < 0):
  res = "Zero"

else:
  if a == b:
    res = "Positive"
  elif (b-a) % 2 == 1:
    res = "Positive"
  else:
    res = "Negative"
print(res)

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

using namespace std;
#define ll long long
#define ld long double
#define f first
#define s second

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

    ld n;
    cin >> n;
    ld s = n/(ld)3;
    cout << fixed << setprecision(9) << s*s*s << '\n';

    return 0;
}


Measured memory_bytes: 256
class Frac(object):
    def __init__(self, a, b):
        self.a = a
        self.b = b

    def eq(self, f):
        return self.a * f.b == f.a * self.b

    def lt(self, f):
        return self.a * f.b > f.a * self.b

    def __repr__(self):
        return '%.6f' % (self.a / self.b)


def factorial(n):
    res = 1
    for i in range(n):
        res *= i+1
    return res


def nCr(n, r):
    return factorial(n) // factorial(r) // factorial(n - r)


N, A, B = map(int, input().split())
V = list(map(int, input().split()))
V.sort(reverse=True)

res = None
for i in range(A, B+1):
    now = Frac(sum(V[:i]), i)
    if res is None or now.lt(res[0]):
        res = [now]
    elif now.eq(res[0]):
        res.append(now)

cnt = 0
for now in res:
    p = V[:now.b]
    n = len(list(filter(lambda x: x == p[-1], V)))
    r = len(list(filter(lambda x: x == p[-1], p)))
    cnt += nCr(n, r)

print(res[0])
print(cnt)

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

using namespace std;

long long lcm(long long a , long long b) {
    return (a * 1ll * b) / __gcd(a , b);
}


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

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

    long long ans = b - a + 1;
    ans -= b / c - (a - 1) / c;
    ans -= b / d - (a - 1) / d;
    ans += b / lcm(c , d) - (a - 1) / lcm(c , d);
    cout << ans;
}


Measured memory_bytes: 3588
import sys
from collections import defaultdict
import bisect
def input(): return sys.stdin.readline().rstrip()


def main():
    s = list(input())
    t = list(input())
    dic = defaultdict(list)
    for index, string in enumerate(s):
        dic[string].append(index)
    cycle = 0
    ind = -1
    for string in t:
        if dic[string] == []:
            print(-1)
            exit()
        elif dic[string][-1] <= ind:
            cycle += 1
            ind = dic[string][0]
        else:  # [2,6,7,10] 6の次は？
            ind = dic[string][bisect.bisect_right(
                dic[string], ind)]  # n以下の個数を数える
    print(cycle*len(s)+ind+1)


if __name__ == '__main__':
    main()

Measured memory_bytes: 15164
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int>P;
const double eps = 1e-8;
const int NINF = 0xc0c0c0c0;
const int INF  = 0x3f3f3f3f;
const ll  mod  = 1e9 + 7;
const ll  maxn = 1e6 + 5;

int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	string s;cin>>s;
	if(s=="ABC") cout<<"ARC"<<'\n';
	else cout<<"ABC\n";
	return 0;
}

Measured memory_bytes: 3640
from itertools import combinations
n,x,y = map(int,input().split())
cnt = [0]*n
for i,j in combinations(range(1,n+1),r=2):
    k = min(j-i,abs(x-i)+1+abs(y-j),abs(x-j)+1+abs(y-i))
    cnt[k]+=1
for i in range(1,n):
    print(cnt[i])    

Measured memory_bytes: 3444
#include <bits/stdc++.h>
 
using namespace std;
 
#define rep(i, n) for(int i=0; i<(n); i++)
#define FOR(i, m, n) for(int i=(m);i<(n);i++)
#define sz(x) ((int)(x).size())
#define all(x) (x).begin(),(x).end()
#define SORT(x) sort((x).begin(),(x).end())
#define RSORT(x) sort((x).rbegin(),(x).rend())
#define REVE(x) reverse((x).begin(),(x).end())
#define mp make_pair
#define pb push_back
#define chmax(x,y) x = max(x,y)

 
typedef vector<int> VI;
typedef vector<string> VS;
typedef vector<vector<int> > VVI;
typedef pair<int, int> PII;
typedef long long LL;
typedef vector<bool> VB;
typedef vector<LL> VL;
typedef vector<vector<long long>> VVLL;
typedef vector<set<int>> VSI;
const int MOD = 1e9+7;
const int INF = 1e9;
const LL LINF = 1e18;
int gcd(int a, int b)
{
   if (a%b == 0)
   {
       return(b);
   }
   else
   {
       return(gcd(b, a%b));
   }
}

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

int main() {
    int n,k;
    cin >> n >> k;
    VI p(n);
    rep(i,n) cin >> p[i];
    SORT(p);

    int ans = 0;
    rep(i,k) ans += p[i];

    cout << ans << endl;

}


Measured memory_bytes: 3628
#include<stdio.h>

int main (void){

    int point = 0;
    int total = 0;
    int avel = 0;

    int i;

    for(i=0;i<5;i++){
        scanf("%d",&point);
        if(point < 40){
            total += 40;
        }else{
            total += point;
        }
    }
    avel = total / 5;

    printf("%d\n",avel);

    return 0;
}

Measured memory_bytes: 1028
import math
from itertools import permutations


def main():
    n = int(input())
    xy = [tuple(map(int, input().split())) for _ in range(n)]

    dist = []
    for i in range(n):
        d = []
        for j in range(n):
            if i == j:
                d.append(0.0)
                continue
            x1, y1 = xy[i]
            x2, y2 = xy[j]
            d.append(math.sqrt((x1 - x2) ** 2 + (y1 - y2) ** 2))
        dist.append(d)

    avg = 0
    perms = list(permutations(range(n)))
    for i in perms:
        d = 0
        for j in range(n)[:-1]:
            d += dist[i[j]][i[j + 1]]
        avg += d / len(perms)
    print(avg)


if __name__ == '__main__':
    main()


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

ll N;

void search(ll n, vi &candidate){
    //cout << n << endl;
    for(int i=3;i<=7;i+=2){
        ll ret=n*10+i;
        if(ret<=N){
            candidate.push_back(ret);
            search(ret,candidate);
        }
    }
    return;
}

int main(){
    cin >> N;
    vi candidate;
    search(0,candidate);
    //cout << "kani" << endl;
    int ans=0;
    for(int x:candidate){
        //cout << x << endl;
        bool flag3=false,flag5=false,flag7=false;
        while(x>0){
            if((x%10)%3==0) flag3=true;
            if((x%10)%5==0) flag5=true;
            if((x%10)%7==0) flag7=true;
            x/=10;
        }   
        if(flag3&flag5&flag7) ans++;
    }
    cout << ans << endl;
    
}

Measured memory_bytes: 3684
#include <iostream>
#include <algorithm>
#include <cstring>
#include <cmath>
#include <vector>
#include <set>
#include <queue>
#include <map>
#include <string>

#define rep(i, a, b) for ( int i = (a); i < (b); i++ )
#define per(i, a, b) for ( int i = (b)-1; i >= (a); i--)
#define pb push_back
#define mp make_pair
#define bg begin()
#define en end()


using namespace std;

typedef long long ll;

static const long long MOD = 1000000007;

/*
  ------  -----
--- -----
 ----

*/

int ans;
int N, M;
pair<int, int> pr[100005];
priority_queue<int, vector<int>, greater<int> > pq;

int main(void) {
    scanf("%d %d", &N, &M);
    rep(i, 0, M) {
        int a, b;
        scanf("%d %d", &a, &b);
        pr[i] = mp(a, b);
    }
    sort(pr, pr+M);
    for (int i=0; i<M; i++) {
        if (pq.empty()||pr[i].first<pq.top()) pq.push(pr[i].second);
        else {
            ans++;
            while (!pq.empty()) pq.pop();
            pq.push(pr[i].second);
        }
    }
    if (!pq.empty()) ans++;

  
    printf("%d\n", ans);

	return 0;
}


Measured memory_bytes: 1408
import java.util.*

fun main(args: Array<String>) {
    val sc = Scanner(System.`in`)
    val n = sc.nextInt()
    val a = (0 until n).map { sc.next().toInt() }
    println(problem155b(n, a))
}

fun problem155b(n: Int, a: List<Int>): String {
    return if (a.filter { it % 2 != 0 || it % 3 == 0 || it % 5 == 0 }.size == n) "APPROVED" else "DENIED"
}

Measured memory_bytes: 31776
#import sys
#input = sys.stdin.readline
from collections import deque
from bisect import bisect_right, bisect_left
def main():
    N = int( input())
    A = [ int( input()) for _ in range(N)]
    d = deque()
    for a in A:
        t = bisect_right(d, a)
        if t == 0:
            d.appendleft(a)
            continue
        if d[t-1] == a:
            t = bisect_left(d, a)
        if t == 0:
            d.appendleft(a)
        else:
            d[t-1] = a
    print(len(d))
if __name__ == '__main__':
    main()


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

#define ULL unsigned long long
#define LL long long

#define P pair<int, int>

#define pb push_back
//#define mp make_pair
#define pp pop_back

#define lson root << 1
#define rson root << 1 | 1

#define INF32 (int)1e9 + 7
#define INF64 (long long)1e18

#define sc(x) scanf("%d", &x)
#define pr(x) printf("%d\n", x)

#define mem(arry, in) memset(arry, in, sizeof(arry))

#define IOS ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);

#define BEGIN() int T; sc(T); while(T--)

#define rep(i, aa, bb) for (int i = aa; i < bb; ++i)
#define Rep(i, aa, bb) for (int i = aa; i <= bb; ++i)

#define Size(x) (int)(x).size()
#define Range(x) (x).begin(), (x).end()

#define PI acos(-1)

using namespace std;

/*
namespace fastIO {
    #define BUF_SIZE 100000
    bool IOerror = 0;
    inline char nc() {
        static char buf[BUF_SIZE], *p1 = buf + BUF_SIZE, *pend = buf + BUF_SIZE;
        if(p1 == pend) {
            p1 = buf;
            pend = buf + fread(buf, 1, BUF_SIZE, stdin);
            if(pend == p1) {
                IOerror = 1;
                return -1;
            }
        }
        return *p1++;
    }
    inline bool blank(char ch) {
        return ch == ' ' || ch == '\n' || ch == '\r' || ch == '\t';
    }
    inline void read(int &x) {
        char ch;
        while(blank(ch = nc()));
        if(IOerror) return;
        for(x = ch - '0'; (ch = nc()) >= '0' && ch <= '9'; x = x * 10 + ch - '0');
    }
    #undef BUF_SIZE
};
using namespace fastIO;
*/
/*
void print64mul(LL x, LL y) {
#if __SIZEOF_INT128__ == 16
  __int128 res = __int128(x) * y;
  char ch[64];
  int ptr = 0;
  if (res == 0) {
    puts("0");
    return;
  }
  while (res) {
    ch[ptr] = (res % 10) + '0';
    ptr++;
    res /= 10;
  }
  while (ptr)
    putchar(ch[--ptr]);
  putchar('\n');
#else
  constexpr LL limit = 1000000000;
  LL dig[4] = {0};
  dig[0] = x % limit;
  dig[1] = x / limit;
  dig[0] *= y;
  dig[1] *= y;
  dig[1] += dig[0] / limit;
  dig[0] %= limit;
  dig[2] += dig[1] / limit;
  dig[1] %= limit;
  int pos = 2;
  while (pos > 0) {
    if (dig[pos]) break;
    pos--;
  }
  printf("%d", dig[pos]);
  while (pos > 0) {
    pos--;
    printf("%09d", dig[pos]);
  }
  puts("");
#endif
}
*/

int n, T, A;

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

    int ans = 0;
    double res = INF32 * 1.0;
    Rep(i, 1, n) {
        double x;
        cin >> x;
        double tp = T - x * 0.006;
        if (fabs(tp - A) < res) {
            res = fabs(tp - A);
            ans = i;
        }
    }
    cout << ans << endl;


    return 0;
}






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

int main(void) {
    int n;
    long long ans = 0;
    vector<long long> a, b;
    cin >> n;
    for (int i = 0; i < n; i++) {
        int in;
        cin >> in;
        a.push_back(in);
        cin >> in;
        b.push_back(in);
    }
    for (int i = n - 1; i >= 0; i--) {
        ans += (b[i] - (a[i] + ans) % b[i]) % b[i];
    }
    cout << ans << endl;
}


Measured memory_bytes: 2036
#include <iostream>

using namespace std;

int main(void) {
  int n;
  int tmpn;
  int s = 0;

  cin >> n;

  tmpn = n;

  while(tmpn) {
    s += tmpn % 10;
    tmpn /= 10;
  }

  if (n % s == 0) cout << "Yes" << endl;
  else cout << "No" << endl;

  return 0;
}

Measured memory_bytes: 256
s = input()
ss = s.split("BC")
ans = 0
a = 0
for abaca in ss:
    if ("B" in abaca) or ("C" in abaca) :
        ababa = abaca.replace("C", "B")
        a_a_a = ababa.split("B")
        a = len(a_a_a[-1])
        ans += a
    else :
        a += len(abaca)
        ans += a
else :
    ans -= a
print(ans)

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

using namespace std;

#define FastIO ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);

#define nl "\n"
#define sp " "
#define int long long
#define PI 3.141592653589793
#define scanstr(s) cin>>ws; getline(cin,s);

void solve()
{
	int r,d,be;
	cin>>r>>d>>be;
	vector<int> ans;
	for(int i=0;i<10;i++)
	{
		int a=r*be-d;
		cout<<a<<nl;
		be=a;
	}
	return ;
}

int32_t main()
{
	FastIO;
	solve();
	return 0;
}


Measured memory_bytes: 3592