akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
using namespace std;

int main(){
    int a,b,c,d;
    cin >> a >> b >> c;
    if(b>c){
        d=c;
        c=b;
        b=d;
    }
    if(a>c){
        d=c;
        c=a;
        a=d;
    }
    if(a>b){
        d=b;
        b=a;
        a=d;
    }
    cout << a << " " <<  b << " " << c << endl;
}


Measured memory_bytes: 3084
#include <vector>
#include <math.h>
#include <iostream>
#include <string>
#include <algorithm>
#include <queue>
#include <iomanip>
#include <deque>
#include <cctype>
#include <unordered_map>

using namespace std;
using uint = unsigned int;
using ll = long long;
using ull = unsigned long long;
using pii = pair<int,int>;
using pll = pair<long, long>;
template <class T> using V = vector<T>;
template <class T> using VV = V<V<T>>;
#define rep(i, n) for(int i = 0; i<n; i++)
#define rep_s(i, start, n) for(int i= start;  i<n; i++)
#define rep_down(i, n) for(int i = n-1; i>=0; i--)
#define rep_down_s(i, n, start) for(int i = n-1; i>=start; i--)
#define ALL(a) (a).begin(), (a).end()
#define ALL_str(a) (a).cbegin(), (a).cend()

string alphabet_upper = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
string alphabet_lower  = "abcdefghijklmnopqrstuvwxyz";
string numbers = "0123456789";
/*
for (iterator = hash.begin(); iterator != hash.end(); iterator++)
{
// ここで、要素毎の操作を行います。
std::pair<std::string, CMyClass> element = *iterator;

}
*/
/*
using edge = struct {int to; ll cost;};
vector<edge> tree[limit];
ll depth[limit];

void dfs(int v, int p, ll d){
  depth[v] = d;
  //cout <<"v: " << v << endl;
  for (auto &e: tree[v]){
    //cout << "e.to: " << e.to << endl;
    if (e.to == p) continue;
    dfs(e.to, v, d+e.cost);
  }
}
*/
int keta_sum(int num){
  int dig, sum = 0;
  while(num){
    dig = num % 10;
    sum = sum + dig;
    num = num / 10;
  }
  return sum;
}

ll binary_search(ll left_key, ll border, ll low, ll high) {
     // 配列 a の左端と右端
    ll mid = (low+high)/2;
    while (high > low+1) {
       mid = (low+high)/2;
        if (left_key*mid>border) high = mid;
        else if (left_key*mid<border) low = mid;
        else {
          mid =mid-1;
          break;
        }
    }
    return mid;
}

bool IsPrime(ll a){
  ll b = sqrt(a);
  b++;
  while(b-->=2){
    if (a%b==0) return false;
  }
  return true;
}

ll gcd(ll a, ll b){
  ll tmp;
  if(a<b){
    tmp = a;
    a = b;
    b = tmp;
  }

  ll r = a % b;
  while(r!=0){
    a = b;
    b = r;
    r = a % b;
  }
  return b;
}

struct UnionFind {
    vector<int> par; // par[i]:iの親の番号　(例) par[3] = 2 : 3の親が2

    UnionFind(int N) : par(N) { //最初は全てが根であるとして初期化
        for(int i = 0; i < N; i++) par[i] = i;
    }

    int root(int x) { // データxが属する木の根を再帰で得る：root(x) = {xの木の根}
        if (par[x] == x) return x;
        return par[x] = root(par[x]);
    }

    void unite(int x, int y) { // xとyの木を併合
        int rx = root(x); //xの根をrx
        int ry = root(y); //yの根をry
        if (rx == ry) return; //xとyの根が同じ(=同じ木にある)時はそのまま
        par[rx] = ry; //xとyの根が同じでない(=同じ木にない)時：xの根rxをyの根ryにつける
    }

    bool same(int x, int y) { // 2つのデータx, yが属する木が同じならtrueを返す
        int rx = root(x);
        int ry = root(y);
        return rx == ry;
    }
};

int main(void){
  ll N, M, A, B, C, D, E, F, K,L, W, H, P, Q, R, X, Y;
  ll ans;
  string S, T;
  cin >> N;
  cout << 3*N*N << endl;
 
}


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

int main() {
	string S, T;
	cin >> S >> T;
	string S2 = S + S;
	long long ans = -1;
	for (int n = 0;n<T.size();++n) {
		string S3 = S2.substr((1 + ans)%S.size());
		int anstmp = S3.find(T[n]);
		if (string::npos == anstmp) {
			cout <<"-1" <<endl;
			return 0;
		}
		ans += (long long)anstmp + 1;
	}
	cout << ans + 1 <<endl;
	return 0;
} 

Measured memory_bytes: 4008
#include <iostream>
#include <algorithm>
#include <vector>
#include <cmath>
#include <cstdio>
#include <string>
#include <map>
#include <set>
#include <queue>
#include <stack>
using namespace std;
#define MOD 1000000007
#define rep(i,n) for(int i = 0; i < (n); ++i)
typedef long long ll;


int main(void) {
  int h, w, n;
  cin >> h >> w >> n;
  int ans = 0, now = 0;
  if(h >= w) {
    while(now < n){
      now += h;
      ++ans;
    } 
  } else {
    while(now < n) {
      now += w;
      ++ans;
    }
  }

  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
// #include <boost/multiprecision/cpp_int.hpp>
// using namespace boost::multiprecision;
#define fio ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define ll long long int
#define ull unsigned long long int  // ranges from (0 - twice of long long int)
#define rep(i,a,n) for (ll i=a;i<n;i++)
#define per(i,a,n) for (ll i=n-1;i>=a;i--)
#define pb push_back
#define mp make_pair
#define vll vector<ll>
#define mod 1000000007LL
#define llpair pair<ll,ll>
#define INF 1000000000000000000ll
#define np next_permutation
#define PI acos(-1)
#define deb(x) cout<<#x<<" "<<x<<endl;
//ALWAYS USE ll DATA TYPE FOR INTEGER(FASTER THAN INTEGER AS WELL AS SOMETIMES WITHOUT USE LONG UR ANSWER WILL NOT ACCEPTED) && DOUBLE FOR DECIMAL VALUE
template<typename T> // for removing front element from the vector
void pop_front(std::vector<T> &v)
{
    if (v.size() > 0) {
        v.erase(v.begin());
    }
}
template<typename R> // for removing back element from the vector or can directly
void pop_back(std::vector<R> &v) // use vec.pop_back() function...
{
    if (v.size() > 0) {
        v.erase(v.begin()+v.size()-1);
    }
}

bool isprime(ll n)  //IN  O(sqrt(n))
{
    if(n<=1) return false;
    for(ll i=2;i*i<=n;i++)
        if(n%i==0)
            return false;

    return true;
}

vector<ll> factors(ll n){    //IN  O(sqrt(n))

    vll v;
    for(ll i=2;i*i<=n;i++)
    {
        if(n%i==0)
        {
            v.pb(i);
            if((n/i)!=i)
            v.pb(n/i);
        }
    }
    return v;
}

ll power(ll a, ll n)  // using Binary Exponential in TC O(logn)
{                     // Self Written By </ME> :)
    ll res=1;
    while(1)
    {
        if(n%2){
            res=res*a; n--;
        }
        if(n==0) break;
        a=a*a; n/=2;
    }
    return res;
}

ll ts(ll arr[],int l,int r,int x) // ternary search to find x in sorted array arr
{
    
    while(l<=r)
    {
        ll mid1= l+(r-l)/3;
        ll mid2= r -(r-l)/3;
        if(arr[mid1]==x || arr[mid2]==x)
            return 1;
        if(x<arr[mid1])
            r=mid1-1;
        else if(x>arr[mid2])
            l=mid2+1;
        else
        {
            l=mid1+1;
            r=mid2-1;
        }
    }

    return -1;
}

int main() {
    auto start = chrono::high_resolution_clock::now();
    fio;
    ll t=1;
    //cin>>t;
    while(t--)
    {
        ll a,b,c; cin>>a>>b>>c;
        if(4*a*b< (c-a-b)*(c-a-b) && (c-a-b)>=0)
        cout<<"Yes"<<"\n";
        else
            cout<<"No"<<"\n";
    }
    
    auto finish = chrono::high_resolution_clock::now();
    cerr << "Time elapsed: " << (chrono::duration<long double>(finish-start)).count() << "s\n";
    return 0;
}





Measured memory_bytes: 256
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
    
        Scanner sc = new Scanner(System.in);
        
        int X = sc.nextInt();
        
        if( X == 3 || X == 5 || X == 7 ){
            System.out.println("YES");
        } else {
            System.out.println("NO");
        }
    }
}


Measured memory_bytes: 21844
N, Y = map(int,input().split())

# N = 1000
# Y = 1234000
search_flag = 0
count_10k = 0
count_5k = 0
count_1k = 0

for count_10k in range(N+1):
    for count_5k in range(N-count_10k+1):
        count_1k = N - count_10k - count_5k
        if count_10k * 10000 + count_5k * 5000 + count_1k * 1000 == Y:
            print(str(count_10k) + ' ' + str(count_5k) + ' ' + str(count_1k))
            search_flag = 1
            break
    else:
        continue
    break

if search_flag == 0:
    print('-1 -1 -1')

Measured memory_bytes: 3064
#include <iostream>
#include <stack>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <string>
#include <vector>
#include <queue>
#include <map>
#include <set>
#include <tuple>
#include <algorithm>
#include <functional>
#include <cstring>
#include <limits.h>
#include <bitset>
#include <complex>
#include <cassert>
#define FOR(i,k,n)  for (int i=(k); i<(int)(n); ++i)
#define REP(i,n)    FOR(i,0,n)
#define FORIT(i,c)	for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)
#define SZ(i) ((int)i.size())
#define GI(i) (scanf("%d",&i))
#define GLL(i) (scanf("%lld",&i))
#define GD(i)  (scanf("%lf",&i))
#define PB          push_back
#define MP          make_pair
#define MT          make_tuple
#define GET0(x)     (get<0>(x))
#define GET1(x)     (get<1>(x))
#define GET2(x)     (get<2>(x))
#define ALL(X)      (X).begin(),(X).end()
#define LLMAX       (1LL<<60)
#define LLMIN       -(1LL<<60)
#define IMAX        (1<<30)
#define IMIN        -(1<<30)
typedef long long LL;
using namespace std;

int main(void){
    LL N,K;
    GLL(N);GLL(K);
    LL p = N/K;
    LL q = N/K + (N%K >= K/2);
    if(K%2==0)
        printf("%lld\n", p*p*p + q*q*q);
    else
        printf("%lld\n", p*p*p);
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
typedef pair<int, int> pii;
#ifdef DEBUG
#define display(x) cerr << #x << " = " << x << endl;
#define displaya(a, st, n)\
	{cerr << #a << " = {";\
	for(int qwq = (st); qwq <= (n); ++qwq) {\
		if(qwq == (st)) cerr << a[qwq];\
		else cerr << ", " << a[qwq];\
	} cerr << "}" << endl;}
#define displayv(v) displaya(v, 0, (int)(v).size() - 1)
#define eprintf(...) fprintf(stderr, __VA_ARGS__)
#else
#define display(x) ;
#define displaya(a, st, n) ;
#define displayv(v) ;
#define eprintf(...) if(0) fprintf(stderr, "...")
#endif
template<typename T> bool chmin(T &a, const T &b) { return a > b ? a = b, true : false; }
template<typename T> bool chmax(T &a, const T &b) { return a < b ? a = b, true : false; }

const int maxN = 200000 + 233;
int n, a[maxN];
set<int> S[maxN];
LL K;
int vis[maxN];
vector<int> res;

int main() {
	ios::sync_with_stdio(false);
	cin >> n >> K;
	for(int i = 1; i <= n; ++i) cin >> a[i];
	for(int i = 1; i <= n; ++i) S[a[i]].insert(i);
	memset(vis, 0, sizeof(vis));
	int i = 1;
	LL rd = 1;
	while(rd <= K) {
		eprintf("i = %d, rd = %lld\n", i, rd);
		if(vis[i]) {
			rd += (K - rd) / (rd - vis[i]) * (rd - vis[i]);
			display(rd);
		}
		auto p = S[a[i]].upper_bound(i);
		if(p != S[a[i]].end()) {
			vis[i] = rd;
			i = *p;
//			vis[i] = rd;
		} else {
			p = S[a[i]].begin();
			vis[i] = rd;
			if(rd < K) {
				i = *p; ++rd;
//				vis[i] = rd;
			} else {
				res.push_back(a[i]);
			}
		}
		++i;
		if(i == n + 1) i = 1, ++rd;
	}
	for(int x : res) cout << x << ' ';
	cout << endl;
	return 0;
}


Measured memory_bytes: 22772
#include <iostream>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <algorithm>
#include <functional>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <bitset>
#include <fstream>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll,ll> P;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<char> vc;
typedef vector<string> vs;
typedef vector<P> vp;
#define rep(i,a,n) for(ll i = (a);i < (n);i++)
#define per(i,a,n) for(ll i = (a);i > (n);i--)
#define lep(i,a,n) for(ll i = (a);i <= (n);i++)
#define pel(i,a,n) for(ll i = (a);i >= (n);i--)
#define clr(a,b) memset((a),(b),sizeof(a))
#define pb push_back
#define all(c) (c).begin(),(c).end()
#define sz size()
#define endl "\n"
#define print(X) cout << (X) << "\n"
// // #define input(X) getline(cin,X)
static const ll  INF = 1e9+7;
static const ll INFL = 1e18+7;
ll n,m,l, p;
string s,t;
ll d[200010],e[200010],dp[1001][1001];
char field[202][202];

ll func(int p){
    d[1] = abs(e[1]-e[0]);

    lep(i,2,p){
        d[i] = min(d[i-1]+abs(e[i-1]-e[i]), d[i-2]+abs(e[i-2]-e[i]));
    }
    // rep(i,0,p+2)printf("%lld : %lld\n", i, d[i]);
    return d[p-1];
}

int main(){
    clr(d, 0);
    clr(e, 0);
    cin >> n;
    rep(i,0,n)cin >> e[i];
    print(func(n));
    return 0;
}


Measured memory_bytes: 5120
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for( int i = 0; i < n; i++ )
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define INF 2000000000
#define INF2 1000000000000000000
#define int long long int

struct edge { int to, cost; };
typedef pair<int, int> P;

int V;
vector<edge> G[100010];
int d[100010];

int bfs(int s){
    queue<P> que;
    fill(d, d + V + 1, INF2);
    d[s] = 0;
    que.push(P(0, s));

    while(!que.empty()){
        P p = que.front(); que.pop();
        int v = p.second;
        if( d[v] == INF2 ) continue;
        for (int i = 0; i < G[v].size(); i++) {
            edge e = G[v][i];
            dump(G[v][i].to);
            dump(G[v][i].cost);
            if (d[e.to] > d[v] + e.cost) {
                d[e.to] = d[v] + e.cost; 
                que.push(P(d[e.to], e.to));
            }
        }
    }
}

signed main(void)
{
    cin >> V;
    rep(i ,V-1){
        int s, t, c;
        cin >> s >> t >> c;
        G[s].push_back({t, c});
        G[t].push_back({s, c});
    }
    int Q,K;
    cin >> Q >> K;
    bfs(K);
    int x[Q], y[Q];
    rep(i, Q) cin >> x[i] >> y[i];
    rep(i ,Q) cout << d[x[i]] + d[y[i]] << endl;
    return 0;
}

Measured memory_bytes: 12400
#include<stdio.h>
#include<stdlib.h>
#include<math.h>
int main()
{
	int x,a,b;
	scanf("%d%d%d",&x,&a,&b);
	int A,B;
	A=abs(x-a);
	B=abs(x-b);
	//printf("%d %d\n",A,B);
	if(A<=B)
	{
		printf("A\n");
	}
	else
	{
		printf("B\n");
	}
	return 0;
}

Measured memory_bytes: 128
# include <bits/stdc++.h>
# define rep(i, n) for(int i=0, i##_len=(n); i<i##_len; ++i)
# define reps(i, n) for(int i=1, i##_len=(n); i<=i##_len; ++i)
# define rrep(i, n) for(int i=((int)(n)-1); i>=0; --i)
# define rreps(i, n) for(int i=((int)(n)); i>0; --i)
# define ALL(x) (x).begin(), (x).end()
# define SZ(x) ((int)(x).size())
# define pb push_back
# define optimize_cin() cin.tie(0); ios::sync_with_stdio(false)
using namespace std;
using lint = 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; }

int main()
{
    int N, M; cin >> N >> M;
    vector<int> X(M);
    rep (i, M) { cin >> X[i]; }

    if (N >= M)
    {
        cout << 0 << endl;
        return 0;
    }

    sort(ALL(X));
    vector<int> L;
    rep (i, M - 1)
    {
        L.push_back(abs(X[i] - X[i+1]));
    }
    sort(L.begin(), L.end());

    int s = 0;
    for (int i = 0; i < L.size() - N + 1; ++i)
    {
        s += L[i];
    }
    cout << s << endl;



    return 0;
}


Measured memory_bytes: 1276
def chk(x):
    cur = 0
    cnt = 0
    while cur<N:
        if S[cur]==str(x[cnt]):
            cnt += 1
            if cnt==3:
                break
        cur += 1
    if cnt==3:
        return 1
    else:
        return 0

N = int(input())
S = input().strip()
cnt = 0
for i in range(0,10):
    for j in range(0,10):
        for k in range(0,10):
            cnt += chk((i,j,k))
print(cnt)

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

using namespace std;

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

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

	double dp[n+1][n+1]; // [coins][heads]
	memset(dp, 0, sizeof(dp));
	dp[0][0] = 1;

	for(int i=1;i<=n;i++){
		for(int j=0;j<=i;j++){ // we need exactly j heads from i coins
			dp[i][j] = dp[i-1][j]*(1.0-a[i-1]); // j heads from i-1 coins * ith tail
			if(j){
				dp[i][j] += dp[i-1][j-1]*a[i-1]; // j-1 heads from i-1 coins * ith head
			}
		}
	}

	double res=0;

	for(int i=(n+1)/2;i<=n;i++){
		res += dp[n][i];
	}
	// cout << setprecision(10) << res;
	printf("%.10f", res);
	return 0;
}

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

const int MAXN = 1e5 + 5;
int dp[MAXN][3], happ[MAXN][3];

int main() {
    int n;
    cin >> n;
    for(int i = 1; i <= n; i++)
        cin >> happ[i][0] >> happ[i][1] >> happ[i][2];
    for(int i = 1; i <= n; i++) {
        for(int j = 0; j < 3; j++) {
            for(int k = 0; k < 3; k++) {
                if(k == j)
                    continue;
                dp[i][j] = max(dp[i][j], dp[i - 1][k] + happ[i][j]);
            }
        }
    }
    cout << max({dp[n][0], dp[n][1], dp[n][2]}) << endl;
}

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

int main() {
  
  int H, W; cin >> H >> W; char table[H + 2][W + 2];
  
  for (int i = 0; i < H + 2; i++) {
    for (int j = 0; j < W + 2; j++) {
      table[i][j] = '#';
    }
  }
  
  for (int i = 1; i < H + 1; i++) {
    for (int j = 1; j < W + 1; j++) {
      char a; cin >> a;
      table[i][j] = a;
    }
  }
  
  for (int i = 0; i < H + 2; i++) {
    for (int j = 0; j < W + 2; j++) {
      cout << table[i][j];
    }
    cout << endl;
  }
  
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using LL = long long;
using ULL = unsigned long long;
using VI = vector<int>;
using VL = vector<LL>;
using PII = pair<int, int>;
using PLL = pair<LL, LL>;

#define SZ(a) (int)a.size()
#define ALL(a) a.begin(), a.end()
#define MP make_pair
#define PB push_back
#define EB emplace_back
#define F first
#define S second
#define FOR(i, a, b) for (int i = (a); i<(b); ++i)
#define RFOR(i, b, a) for (int i = (b)-1; i>=(a); --i)
#define FILL(a, b) memset(a, b, sizeof(a))

void dout() { cerr << endl; }

template <typename Head, typename... Tail>
void dout(Head H, Tail... T) {
    cerr << H << ' ';
    dout(T...);
}

int main()
{
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    LL a, b, c, d;
    cin >> a >> b >> c >> d;
    LL ans = b * d;
    ans = max(ans, a * c);
    if (a <= 0 && 0 <= b ||
        c <= 0 && 0 <= c)
        ans = max(ans, 0LL);
    ans = max(ans, b * c);
    ans = max(ans, d * a);
    cout << ans;
    return 0;
}

Measured memory_bytes: 3648
import java.util.Collections;
import java.util.PriorityQueue;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int M = sc.nextInt();
		PriorityQueue<Long> A = new PriorityQueue<Long>(Collections.reverseOrder());

		for (int i = 0; i < N; i++) {
			A.add(sc.nextLong());
		}

		Long tmp = (long)0;
		for (int i = 0; i < M; i++) {
			tmp = A.poll();
			A.add(tmp / 2);
		}

		Long result = (long)0;
		for (int i = 0; i < N; i++) {
			result += A.poll();
		}
		System.out.println(result);

	}
}


Measured memory_bytes: 57728
#include <iostream>
#include <vector>
#include <algorithm>
#include <iomanip>

using namespace std;

#define rep(i, n) for (int i = 0; i < (int)n; i++)
#define vec vector
#define ll long long

ll dp[55][55];

ll combination(int p, int q)
{
	if (p < q) {
		return 0;
	}
	if (dp[p][q] > 0) return dp[p][q];
	if (!q) return 1;
	if (p == 1) return 1;
	dp[p][q] = combination(p - 1, q) + combination(p - 1, q - 1);
	return dp[p][q];
}

int main(void)
{
	int n, a, b;
	cin >> n >> a >> b;
	vec<double> v(n);
	rep(i, n) cin >> v[i];
	sort(v.begin(), v.end());
	reverse(v.begin(), v.end());

	double sum = 0;
	
	rep(i, a) sum += v[i];
	cout << setprecision(7) << sum / (double)a << endl;

	int c = 1;
	int keep = 0;
	while(keep + c < n) {
		if (v[keep + c] == v[keep]) {
			c++;
			continue;
		} else {
			if (keep + c > a) break;  
			keep += c;
			c = 1;
		}
	}
	
	rep(i, 55) rep(j, 55) dp[i][j] = - 1;

	if (keep == 0) {
		ll sum = 0;
		for (int i = a; i <= min(keep + c, b); i++) {
			sum += combination(c, i);
		}
		cout << sum << endl;
		return 0;
	}
	cout << combination(c, a - keep) << endl;
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <bits/stdc++.h>
#include <math.h>
using namespace std;
vector<int> v[100005];
long long cnt[2];
#define ll unsigned long long
void dfs(int node,int pnode,int color)
{
    cnt[color]++;
    for (int i=0;i<v[node].size();i++)
    {
        if (v[node][i]!=pnode)
        dfs(v[node][i],node,!color);
    }
}
int main()
{
   ll n,m;
   cin>>n>>m;
   ll a=floor(log(n)/log(m));
   cout<<a+1;
   return 0;
}

Measured memory_bytes: 2944
import std.stdio, std.string, std.conv;
import std.range, std.algorithm, std.array, std.typecons, std.container;
import std.math, std.numeric, core.bitop;

enum inf = 1.0 * 10L^^12;
int n;
real[][] cost;
real[] dist;
real[] x, y, r;

void main() {
    real xs, ys, xt, yt;
    scan(xs, ys, xt, yt);
    int n;

    scan(n);
    x = new real[](n + 2);
    y = new real[](n + 2);
    r = new real[](n + 2);

    x[0] = xs, y[0] = ys, r[0] = 0;
    x[n+1] = xt, y[n+1] = yt, r[n+1] = 0;

    foreach (i ; 1 .. n + 1) {
        scan(x[i], y[i], r[i]);
    }

    cost = new real[][](n + 2, n + 2);
    foreach (i ; 0 .. n + 2) {
        foreach (j ; i .. n + 2) {
            if (i == j) {
                cost[i][i] = 0;
            }
            else {
                cost[i][j] = cost[j][i] = max(0, hypot(x[i] - x[j], y[i] - y[j]) - r[i] - r[j]);
            }
        }
    }

    debug {
        writefln("%(%(%s %)\n%)", cost);
    }

    dist = new real[](n + 2);
    dist[] = inf;
    dist[0] = 0;
    bool[] fix = new bool[](n + 2);

    foreach (_ ; 0 .. n + 2) {
        int v = -1;
        real mx = inf;

        foreach (i ; 0 .. n + 2) {
            if (!fix[i] && mx > dist[i]) {
                v = i;
                mx = dist[i];
            }
        }

        debug {
            writeln("v:", v);
        }

        fix[v] = true;

        foreach (i ; 0 .. n + 2) {
            if (dist[i] > dist[v] + cost[v][i]) {
                dist[i] = dist[v] + cost[v][i];
            }
        }

        debug {
            writeln("dist:", dist);
        }
    }

    debug {
        writeln("dist:", dist);
    }

    writefln("%.12f", dist[n+1]);
}





void scan(T...)(ref T args) {
    import std.stdio : readln;
    import std.algorithm : splitter;
    import std.conv : to;
    import std.range.primitives;

    auto line = readln().splitter();
    foreach (ref arg; args) {
        arg = line.front.to!(typeof(arg));
        line.popFront();
    }
    assert(line.empty);
}



void fillAll(R, T)(ref R arr, T value) {
    static if (is(typeof(arr[] = value))) {
        arr[] = value;
    }
    else {
        foreach (ref e; arr) {
            fillAll(e, value);
        }
    }
}


Measured memory_bytes: 18428
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<cmath>
#include<stack>
#include<queue>
#include<deque>
#include<map>
#include<set>
using namespace std;
typedef long long ll;
typedef vector<int> VI;
#define FOR(i,j,n) for(int (i)=(j);(i)<(n);(i)++)
#define eFOR(i,j,n) for(int (i)=(j);(i)<=(n);(i)++)
#define SORT(i) sort((i).begin(),(i).end())
#define rSORT(i,a) sort((i).begin(),(i).end(),(a))
const int INF = 1000000000;
const ll LLINF = 1LL << 62;
const int mod = 1000000007;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; }return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; }return 0; }

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

    int n, m;
    cin >> n >> m;
    int u, v;
    vector<VI> edge(n * 3 + 1);
    FOR(i, 0, m){
        cin >> u >> v;
        edge[u].push_back(v + n);
        edge[u + n].push_back(v + n * 2);
        edge[u + n * 2].push_back(v);
    }
    int s, t;
    cin >> s >> t;

    vector<bool> ever(n * 3 + 1, false);
    queue<pair<int, int>> bfs;
    ever[s] = true;
    bfs.push({ s, 0 });
    while (!bfs.empty()){
        int now = bfs.front().first;
        int dis = bfs.front().second + 1;
        bfs.pop();
        for (int i : edge[now]){
            if (ever[i])continue;
            ever[i] = true;
            bfs.push({ i, dis });
            if (i == t){
                cout << dis / 3 << "\n";
                return 0;
            }
        }
    }
    cout << -1 << "\n";
}


Measured memory_bytes: 16768
#include<stdio.h>

int main(void){

   int x,y;
   while(1){
 
       scanf("%d %d",&x,&y);
       if(x==0&&y==0){
           break;
       }

       if(x<=y){
           printf("%d %d\n",x,y);
       }
       else{
           printf("%d %d\n",y,x);
           }
   }
   return 0;
}


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

int main(){
  long long md = 1e9+7, N;
  string S;
  cin >> N >> S;
  map<char, long long> mp;
  for (int i=0; i<N; i++){
    mp[S[i]]++;
  }
  long long ans = 1;
  for (auto k: mp){
    ans *= (k.second+1);
    ans %= md;
  }
  cout << ans-1 << endl;
}


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

int n,a[100010],sum1,sum2,cnt1,cnt2;

int main()
{
	cin>>n;
	for(int i=0;i<n;i++)
	{
		cin>>a[i];
		if(a[i]%4==0) sum1++;
		if(a[i]%4==1||a[i]%4==3) sum2++;
		if(a[i]%4==2) cnt1++;
		if(a[i]==2) cnt2++;
		
	}
	sum1+=cnt2/2;
	if(sum1+1>=sum2+min(1,cnt1)) cout<<"Yes"; else cout<<"No";
	
	return 0;
}

Measured memory_bytes: 640
#include<stdio.h>

int x;

int p[101];
int m[101][101];

void Matrix_Chain_Order(){
 
  int n,i,l,j,k,q;
  int A;
  n=x;
  
  for(i=1;i<=x;i++){
    m[i][i] = 0;  
  }
  for(l=2;l<=n;l++){
    for(i=1;i<=n-l+1;i++){    
      j = i+l-1;
      m[i][j]=10000000;  
      for(k=i;k<=j-1;k++){
	  q = m[i][k]+m[k+1][j]+p[i]*p[k+1]*p[j+1];
       
	  if(m[i][j]>q){
	  m[i][j] = q;
	    }
	
      }	
    }
  }
  printf("%d\n", m[1][x]);
}





main(){

  int i,a;
  int S;

  scanf("%d",&x);

  for(i=0;i<x;i++){
    scanf("%d %d",&p[i+1],&a);
   
    }
  p[i+1]=a;
 
  Matrix_Chain_Order();

  return 0;
}

Measured memory_bytes: 636
# -*- coding: utf-8 -*-
#ABC079C

n = int(input())

tmp=[]
tmp.append(n//1000)
n=n%1000
tmp.append(n//100)
n=n%100
tmp.append(n//10)
n=n%10
tmp.append(n)

for i in range(-1,2,2):
	for j in range(-1,2,2):
		for k in range(-1,2,2):
			sum= tmp[0]+i*tmp[1]+j*tmp[2]+k*tmp[3]
			if(sum == 7):
				break
#			print("{} {} {}:{}".format(i,j,k,sum))
		else:
			continue
		break
	else:
		continue
	break

res=""
res+=str(tmp[0])
if(i==-1):res+="-"
else:res+="+"
res+=str(tmp[1])
if(j==-1):res+="-"
else:res+="+"
res+=str(tmp[2])
if(k==-1):res+="-"
else:res+="+"
res+=str(tmp[3])
res+="=7"


print(res)

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

const int MOD = 1000000007;

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define copy(from, to) copy(from.begin(), from.end(), back_inserter(to))
#define sort(a) sort(a.begin(), a.end())
#define reverse(s) reverse(s.begin(), s.end())
#define p(s) cout << (s) << endl

typedef long long ll;
using namespace std;

template<class T>
void load(vector<T> &v, int n) {
  for (int i = 0; i < n; ++i) {
    T t;
    cin >> t;
    v.push_back(t);
  }
}

template<class T>
T max(vector<T> &v) {
  return *max_element(v.begin(), v.end());
}

template<class T>
T min(vector<T> &v) {
  return *min_element(v.begin(), v.end());
}

void py(bool isUpper = false) {
  if (isUpper) {
    p("YES");
  } else {
    p("Yes");
  }
}

void pn(bool isUpper = false) {
  if (isUpper) {
    p("NO");
  } else {
    p("No");
  }
}

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

  vector<pair<int, int>> p, c;
  for (int i = 0; i < n; ++i) {
    int a, b;
    cin >> a >> b;
    p.emplace_back(a, b);
  }
  for (int i = 0; i < m; ++i) {
    int a, b;
    cin >> a >> b;
    c.emplace_back(a, b);
  }

  for (auto person : p) {
    ll mi = 1e17;
    int num = 0;
    int index = 0;
    for (auto point : c) {
      num++;
      ll distance = abs(person.first - point.first) + abs(person.second - point.second);
      if (distance < mi) {
        mi = distance;
        index = num;
      }
    }
    p(index);
  }
}

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

typedef long long ll;
using namespace std;
ll a7=1000000007;
ll inf=100000000000000000;

ll min(ll a,ll b){
    if(a<b)return a;
    else return b;
}
ll max(ll a,ll b){
    if(a>b)return a;
    else return b;
}

bool b[1000010][1010]; //i日目にjさんがすでに試合の予定が入っている

int main(){
    ll n;cin>>n;
    ll a[n+1][n];
    vector<vector<ll>> hito(n*n);  //i日目に誰を確認すればいいか
    ll aa[n+1]; //iさんの何試合を次に見るか
    for(ll i=1;i<=n;i++){
        aa[i]=1;
        hito[1].push_back(i);
        for(ll j=1;j<=n-1;j++){
            cin>>a[i][j];
        }
    }
    bool bo=true;
    ll c=0;
    ll h;
    ll ha;
    bool boo;
    ll t;
    ll d=0;
    for(t=1;bo;t++){
        d++;
        boo=false;
        for(ll i=0;i<hito[t].size();i++){
            h=hito[t][i]; //今見る人
            if(aa[h]<n){
                ha=a[h][aa[h]];  //相手候補
                if(aa[ha]<n){
                    if(b[t][h]==false && b[t][ha]==false){
                        if(a[ha][aa[ha]]==h){
                            aa[h]++;
                            aa[ha]++;
                            c=c+2;
                            hito[t+1].push_back(h);
                            hito[t+1].push_back(ha);
                            b[t][h]=true;
                            b[t][ha]=true;
                            boo=true;
                        }
                    }
                }
            }
        }
        if(c==n*(n-1))bo=false;
        if(boo==false)bo=false;
    }
    if(boo==false){
        cout<<-1<<endl;
    }else{
        cout<<d<<endl;
    }
    return 0;
}


Measured memory_bytes: 540672
#include<iostream>
#include <bits/stdc++.h>
#include <cstdio>
#include<set>
using namespace std;
int main()
{
    // �����̓���
    int N;
    int sum = 0;
    
    cin >> N;
    vector<int> A(N);
    vector<int> B(N);
    for (int i = 0; i < N - 1; ++i) { 
       cin >> B[i]; 
    }
    A[0] = B[0];
    sum = A[0];
    
    
    
    for (int i = 1; i < N - 1; ++i) {
        A[i] = min(B[i], B[i - 1]);
        sum += A[i];
        //printf("%d,%d, %d\n", i, A[i], B[i]);
    }
    //printf("f %d\n", B[N - 1]);
    A[N - 1] = B[N - 2];
    sum += A[N - 1];
    
    cout << (sum) << endl;
    return 0;
}


Measured memory_bytes: 256
from itertools import product

N,a,b,c = map(int,input().split())
L = list(int(input()) for i in range(N))

ans = float("inf")

for prod in product(range(4), repeat=N) :
    A = []
    B = []
    C = []
    D = []
    for i in range(len(prod)) :
        if prod[i] == 1 :
            A.append(L[i])
        elif prod[i] == 2 :
            B.append(L[i])
        elif prod[i] == 3 :
            C.append(L[i])
        else :
            D.append(L[i])
    if len(A) * len(B) * len(C) == 0 :
        continue
    cost = 0
    for li in [A,B,C] :
        cost += (len(li)-1)*10
    cost += abs(a-sum(A)) + abs(b-sum(B)) + abs(c-sum(C))
    
    ans = min(ans, cost)
print(ans)


Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
#define SZ(v) ((int)(v).size())
#define rep(i,n) for(int i=0;i<(n);i++)
#define foreach(it,c) for(__typeof(c.begin()) it=c.begin();it!=c.end();it++)
#define all(v) (v).begin(),(v).end()
typedef long long ll;
typedef unsigned uint;
const int INF=0x3f3f3f3f;
int inline in(){int x=0,c;for(;(uint)((c=getchar())-'0')>=10;)
{if(c=='-')return -in();if(!~c)throw ~0;}do{x=(x<<3)+(x<<1)+(c-'0');}
while((uint)((c=getchar())-'0')<10);return x;}
vector<int> bfs(int n,vector<vector<int> >&G,int s){
	vector<int>d(n,INF);d[s]=0;
	queue<int>q;q.push(s);
	while(!q.empty()){
		int u=q.front();q.pop();
		rep(i,SZ(G[u])){
			int to=G[u][i];
			if(d[to]>d[u]+1){
				d[to]=d[u]+1;
				q.push(to);
			}
		}
	}
	return d;
}
int main(){
    cin.sync_with_stdio(false);cin.tie(0);
    int n;
	cin>>n;
	vector<vector<int> >G(n);
	rep(i,n-1){
		int a,b;
		cin>>a>>b;
		a--;b--;
		G[a].push_back(b);
		G[b].push_back(a);
	}
	vector<int>d1=bfs(n,G,0);
	vector<int>d2=bfs(n,G,n-1);
	int n1=0,n2=0;
	rep(i,n){
		if(d1[i]<=d2[i])n1++;
		else n2++;
	}
	string ans=n1>n2?"Fennec":"Snuke";
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 6528
import java.io.IOException;
import java.util.ArrayDeque;
import java.util.Deque;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) throws IOException {

		new Main().run();
	}

	private void run() throws IOException {
		Scanner scanner = new Scanner(System.in);
		while (true) {
			int n = scanner.nextInt();
			if (n == 0)
				break;
			Deque<Pair> deque = new ArrayDeque<Pair>();
			for (int i = 0; i < n; i++) {
				int a = scanner.nextInt();
				if (i % 2 == 1) {
					if (deque.peek().clr == a)
						deque.peek().num++;
					else {
						int num = deque.poll().num;
						if (deque.isEmpty())
							deque.push(new Pair(a, num + 1));
						else
							deque.peek().num += num + 1;
					}
				} else {
					if (deque.isEmpty() || deque.peek().clr != a)
						deque.push(new Pair(a, 1));
					else
						deque.peek().num++;
				}

			}
			int wcnt = 0;
			while (!deque.isEmpty()) {
				if (deque.peek().clr == 0)
					wcnt += deque.peek().num;
				deque.poll();
			}
			System.out.println(wcnt);
		}
	}

	class Pair {
		int clr, num;

		public Pair(int clr, int num) {
			super();
			this.clr = clr;
			this.num = num;
		}

		@Override
		public String toString() {
			return "Pair [clr=" + clr + ", num=" + num + "]";
		}

	}
}

Measured memory_bytes: 64024
#include <bits/stdc++.h>
using namespace std;
//#pragma comment(linker, ”/STACK:36777216“)

typedef long long ll;
#define mp make_pair
#define pb push_back
#define x first
#define y second
#define all(a) a.begin(), a.end()
#define db long double

int n;
vector<int> g[101];

pair<int, int> dfs(int v, int pred){
	pair<int, int> ans = mp(-1, v);
	for (int to : g[v]) if (to != pred){
		ans = max(ans, dfs(to, v));
	}
	ans.x++;
	return ans;
}

vector<int> st, path;
void go(int v, int pred, int need){
	st.pb(v);
	if (need == v){
		path = st;
		return;
	}
	for (int to : g[v]) if (to != pred) go(to, v, need);
	st.pop_back();
}

int ma[111];
int gg;

void calc(int v, int pred, int h){
	gg = max(gg, h);
	//cout << v + 1  << ' ' << h << ' ' << g[v].size() - 1 + (pred == -1) << endl;
	ma[h] = max(ma[h], (int)g[v].size() - 1 + (pred == -1));
 	for (int to : g[v]) if (to != pred) calc(to, v, h + 1);
}

int main(){
	//freopen("input.txt", "r", stdin);
	//freopen("output.txt", "w", stdout);
	ios_base::sync_with_stdio(0); cin.tie(0);
	cin >> n;
	for (int i = 1; i < n; i++){
		int a, b;
		cin >> a >> b;
		a--; b--;
		g[a].pb(b);
		g[b].pb(a);
	}

	//auto now1 = dfs(0, -1);
	//auto now2 = dfs(now1.y, -1);

	//int v1 = now1.y, v2 = now2.y;

	int cnt = 1e9;
	ll val = -1;

	for (int i = 0; i < n; i++){
		for (int s = 0; s < 111; s++) ma[s] = 0;
		gg = 0;
		calc(i, -1, 0);
		ll now = 1;
		for (int j = 0; j < gg; j++) now *= ma[j];
		gg++;
		if (gg < cnt){
			cnt = gg;
			val = now;
		} else if (gg == cnt){
			val = min(val, now);
		}
	}

	for (int v = 0; v < n; v++) for (int to : g[v]){
		for (int s = 0; s < 111; s++) ma[s] = 0;
		gg = 0;
		calc(v, to, 0);
		calc(to, v, 0);
		ll now = 2;
		for (int j = 0; j < gg; j++) now *= ma[j];
		gg++;
		if (gg < cnt){
			cnt = gg;
			val = now;
		} else if (gg == cnt){
			val = min(val, now);
		}
	}

	cout << cnt << ' ' << val;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	/*
	 * 移動できる最大値を求める。
	 */
	public static void main(String[] args) {

		/*
		 * Scannerで値取得。
		 */
		Scanner s = new Scanner(System.in);
		int number = s.nextInt();
		int[] heights = new int[number];
		for (int i = 0; i < number; i++) {
			heights[i] = s.nextInt();
		}
		s.close();

		/*
		 * 右隣の数が同じか以下が続く回数を数える。
		 * →iごとに行う。
		 * →最大値更新ごとに最大値を更新。
		 */
		int max = 0;
		int count = 0;
		//max:最大回数、count:iごとに数える変数。

		for (int i = 0; i < number; i++) {
			count = 0;
			int j = 0;
			for (j = 0; (i + j + 1) < number; j++) {
				//i+j+1がnumberを越えるとエラーになる。
				if (heights[i + j] >= heights[i + j + 1]) {
					count++;
				} else {
					break;
				}
				if (max < count) {
					max = count;
				}
			}
			i = i + j;
			//試行回数を減らすため、iを飛ばす。

		}

		System.out.println(max);

	}

}


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


int main() {
  int a;
  int s1;
  int s2;
  int s3;
  cin >> a;
  s1 = a / 100;
  s2 = a / 10;
  if (s2 > 9){
  s2 = s2 - 10;
  }
  s3 = a - 100 * s1 - 10 * s2;
  cout << s1 + s2 + s3 << endl;
}

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

const int N = 2000;
int L[N][N]={};
int R[N][N]={};
int U[N][N]={};
int D[N][N]={};
string s[N];

int main(){
  int H, W;
  cin >> H >> W;
  for(int i=0; i<H; i++){
    cin >> s[i];
  }
  for(int i=0; i<H; i++){
    for(int j=0; j<W; j++){
      if(s[i][j]=='#') L[i][j]=0;
      else if(j==0) L[i][j]=1;
      else L[i][j]=L[i][j-1]+1;
    }
  }
  for(int i=0; i<H; i++){
    for(int j=W-1; j>=0; j--){
      if(s[i][j]=='#') R[i][j]=0;
      else if(j==W-1) R[i][j]=1;
      else R[i][j]=R[i][j+1]+1;
    }
  }
  for(int j=0; j<W; j++){
    for(int i=0; i<H; i++){
      if(s[i][j]=='#') U[i][j]=0;
      else if(i==0) U[i][j]=1;
      else U[i][j]=U[i-1][j]+1;
    }
  }
  for(int j=0; j<W; j++){
    for(int i=H-1; i>=0; i--){
      if(s[i][j]=='#') D[i][j]=0;
      else if(i==H-1) D[i][j]=1;
      else D[i][j]=D[i+1][j]+1;
    }
  }
  int max = 0;
  for(int i=0; i<H; i++){
    for(int j=0; j<W; j++){
      int tmp = L[i][j]+R[i][j]+U[i][j]+D[i][j]-3;
      if(max<tmp) max=tmp;
    }
  }
  cout << max << endl;
  return 0;
}

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

#define int long long
#define fr(i,n) for(int i=0;i<n;i++)
#define frr(i,n) for(int i=n;i>=0;i--)
#define fra(i,a,n) for(int i=a;i<n;i++)
#define frra(i,a,n) for(int i=a;i>=n;i--)
#define all(v) (v).begin(),(v).end()
#define pb push_back
#define eb emplace_back
#define lb lower_bound
#define ub upper_bound
#define ff first
#define ss second
#define endl '\n'

typedef pair<int,int> ii;
typedef map<int,int> mii;
typedef set<int> si;
typedef unordered_map<int,int> uii;
typedef unordered_set<int> usi;
typedef vector<int> vi;
typedef vector<ii> vii;

const int mod = 1e9+7;
const int inf = 1e9;
const int MAXN = 2e5+5;
const double eps = 1e-6;

void solve(){
    //CODE BEGINS
    int n;
    cin>>n;
    vi a(n);
    uii up,um;
    fr(i,n)cin>>a[i],up[a[i]+i]++,um[i-a[i]]++;
    int cnt = 0;
    for(auto i:up){
		cnt+=i.ss*um[i.ff];
	}
	cout<<cnt<<endl;
}

signed main(){
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    int t = 1;
    //~ cin>>t;
    while(t--)solve();
    return 0;
}


Measured memory_bytes: 27852
#include <algorithm>
#include <climits>
#include <cmath>
#include <iostream>
#include <string>
#include <vector>
using namespace std;

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

  int target = 753;
  int ans = INT_MAX;
  for (int i = 2; i < S.size(); i++) {
    string sub = S.substr(i - 2, 3);
    int x = stoi(sub);
    ans = min(ans, abs(x - target));
  }

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

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

#define all(x) (x).begin(),(x).end()

#define MOD 1000000007

using namespace std;

int main(){
	int n,m;
	cin >> n >> m;
	vector<pair<int,string>> sub(m);
	for( int i=0; i<m; i++ )	cin >> sub[i].first >> sub[i].second;

	bool is_ac[n];
	int ac[n],pena[n];
	int ans[2];
	for( int i=0; i<n; i++ ){
		is_ac[i] = false;
		ac[i] = 0;
		pena[i] = 0;
	}
	ans[0] = 0;
	ans[1] = 0;

	for( int i=0; i<m; i++ ){
		if( is_ac[sub[i].first-1] == false ){
			if( sub[i].second == "AC" ){
				is_ac[sub[i].first-1] = true;
				ac[sub[i].first-1]++;
			}else{
				pena[sub[i].first-1]++;
			}
		}
	}

	for( int i=0; i<n; i++ ){
		if( is_ac[i] == true ){
			ans[0] += ac[i];
			ans[1] += pena[i];
		}
	}

	cout << ans[0] << " " << ans[1] << endl;

	return 0;
}


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

  cin >> n;
  vector<string> blue(n);
  for (int i = 0; i < n; i++) {
    cin >> blue.at(i);
  }
  
  cin >> m;
  vector<string> red(m);
  for (int i = 0; i < m; i++) {
    cin >> red.at(i);
  }
  
  int max_point=0;
  for (int i = 0; i < n; i++) {
    int point = 0;
    string word = blue.at(i);
    for (int j = 0; j < n; j++) {
      if (blue.at(j) == word) {
        point++;
      }
    }
    for (int k = 0; k < m; k++) {
      if (red.at(k) == word) {
        point--;
      }
    }
    
    if (point > max_point) {
      max_point = point;
    }
  }
  
  cout << max_point << endl;
}

Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.UncheckedIOException;
import java.util.Arrays;
import java.util.HashMap;
import java.util.StringTokenizer;

public class Main {
	public static void main(String[] args) {
		SC sc=new SC(System.in);
		int N=sc.nextInt();
		HashMap<Integer,Integer> unko=new HashMap<Integer,Integer>();
		int[] buri=new int[N];
		int[] cpy=new int[N];
		for(int i=0; i<N; i++) {
			buri[i]=sc.nextInt();
			cpy[i]=buri[i];
		}
		Arrays.sort(buri);
		for(int i=0; i<N; i++) {
			unko.put(buri[i],i);
		}
		int[] moto=new int[N];
		for(int i=0; i<N; i++) {
			moto[i]=unko.get(cpy[i]);
			//pl(moto[i]);
		}
		int kigu=0;
		for(int i=0;i<N; i++) {
			if(i%2!=moto[i]%2) {
				kigu++;
			}
		}
		pl(kigu/2);
	}
	static class SC {
		private BufferedReader reader = null;
		private StringTokenizer tokenizer = null;
		public SC(InputStream in) {
			reader = new BufferedReader(new InputStreamReader(in));
		}
		public String next() {
			if (tokenizer == null || !tokenizer.hasMoreTokens()) {
				try {
					tokenizer = new StringTokenizer(reader.readLine());
				} catch (IOException e) {
					throw new UncheckedIOException(e);
				}
			}
			return tokenizer.nextToken();
		}
		public int nextInt() {
			return Integer.parseInt(next());
		}
		public long nextLong() {
			return Long.parseLong(next());
		}
		public double nextDouble() {
			return Double.parseDouble(next());
		}
		public String nextLine() {
			try {
				return reader.readLine();
			} catch (IOException e) {
				throw new UncheckedIOException(e);
			}
		}
	}
	public static void pl(Object o) {
		System.out.println(o);
	}
	public static void pl() {
		System.out.println();
	}
	public static void p(Object o) {
		System.out.print(o);
	}
}


Measured memory_bytes: 46636
N,K = map(int,input().split())
if K%2==1:
    maxn = int(N/K)
    print(maxn**3)
else:
    maxn=int(N/K)
    if N%K >= int(K/2):
        print(maxn**3+(maxn+1)**3)
    else:
        print(2*maxn**3)

Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std;
using lli = long long;
#define rep(i,n) for(int i=0;i<n;i++)
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; }

lli n;

int main(void){
    cin >> n;
    queue<pair<lli, string>> q;
    q.push({1, "a"});
    while(!q.empty()){
        string t = q.front().second;
        lli k = q.front().first;
        q.pop();
        if(t.size() == n){
            cout << t << endl;
            continue;
        }
        rep(i, k){
            q.push({k, t+char('a'+i)});
        }
        q.push({k+1, t+char('a'+k)});
    }
    return 0;
}


Measured memory_bytes: 8244
#include <bits/stdc++.h>
#define REV(v) reverse(v.begin(), v.end());
#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, start, stop) for (int i = start; i < stop; i++)
#define FORR(i, start, stop) for (int i = start; i > stop; i--)
#define SORT(v, n) sort(v, v + n);
#define SORTR(v, n) sort(v, v + n,greater<int>());
#define VSORT(v) sort(v.begin(), v.end());
#define VSORTR(v) sort(v.begin(), v.end(),greater<int>());
#define REMOVE(v,n) remove(vector<long long> v,v+v.size(),long long n)
#define ERASE(v,n) v.erase(v.begin()+n);
#define ll long long
#define ull unsigned long long
#define pb(a) push_back(a)
#define INF 999999999
#define V(v,i,j) vector(v.begin() + i, v.begin() + j)
#define INSERT(va,vb) va.insert(va.end(), vb.begin(), vb.end())
using namespace std;
typedef vector<int> vint;
typedef pair<int, int> P;
typedef pair<ll, ll> LP;
typedef pair<int, P> PP;
typedef pair<ll, LP> LPP;
int dy[] = {0, 0, 1, -1};
int dx[] = {1, -1, 0, 0};
const int MOD = 1000000007;
void chmin(int &a, int b) { if (a > b) a = b; }

//vector< vector<int> > v (size1, vector<int>(size2) );

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll N;
    cin>>N;
    vector<ll> b(N);
    FOR(i,0,N) cin>>b[i];
    vector<ll> ans={};
    bool f=true;

    while(b.size()>0 && f){
        FOR(i,0,b.size()){
            f=false;
            if(b[b.size()-1-i]==b.size()-i){
                ans.pb(b.size()-i);
                ERASE(b,b.size()-1-i);
                f=true;
                //cout<<b.size()<<endl;
                break;
            }
            
        }
    }
    if(!(f)) cout<<-1<<endl;
    else{
      FOR(i,0,N){
        cout<<ans[N-1-i]<<endl;
      }
    }
  

}
//601

Measured memory_bytes: 256
#!/usr/bin/env python3
import sys, math, itertools, collections, bisect
input = lambda: sys.stdin.buffer.readline().rstrip().decode('utf-8')
inf = float('inf') ;mod = 10**9+7
mans = inf ;ans = 0 ;count = 0 ;pro = 1

n=int(input())
X=list(map(int,input().split()))
for p in range(1,100):
  tmp = 0
  for xi in X:
    tmp += (xi-p)**2
  mans = min(mans,tmp)
print(mans)

Measured memory_bytes: 38896
#include<iostream>
using namespace std;
int max(int a,int b,int c){
	if(a>=b&&a>=c) return a;
	else if(b>=a&&b>=c) return b;
	else return c;
}
int main(){
	int a,b;
	cin>>a>>b;
	cout<<max(a+b,a-b,a*b)<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(ll i = 0, i##_len = (n); i < i##_len; i++)
#define reps(i, s, n) for(ll i = (s), i##_len = (n); i < i##_len; i++)
#define rrep(i, n) for(ll i = (n) - 1; i >= 0; i--)
#define rreps(i, e, n) for(ll i = (n) - 1; i >= (e); i--)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define sz(x) ((ll)(x).size())
#define len(x) ((ll)(x).length())
#define endl "\n"

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    // ifstream in("input.txt");
    // cin.rdbuf(in.rdbuf());
    char c;
    cin >> c;
    if ((c >= 'A') && (c <= 'Z')) {
        cout << "A" << endl;
    }
    else {
        cout << "a" << endl;
    }
    return 0;
}


Measured memory_bytes: 3648
#include<stdio.h>
 
int main(void){
  int a=0,b=0,c=0,d=0;
scanf("%d",&a);
scanf("%d",&b);
scanf("%d",&c);
 
  d=b/a;
  if(d<=c){
  printf("%d",d);
  }
  else{
  printf("%d",c);
  }
}

Measured memory_bytes: 128
linea = input()
linea = list(linea)
lineb = input()
lineb = list(lineb)
linec = input()
linec = list(linec)
line = []

line.append(linea)
line.append(lineb)
line.append(linec)

c = 0
for i in range(300):
    if len(line[c]) != 0:
        if line[c][0] == 'a':
            del line[c][0]
            c = 0
        elif line[c][0] == 'b':
            del line[c][0]
            c = 1
        elif line[c][0] == 'c':
            del line[c][0]
            c = 2
    else:
        if c == 0:
            print('A', end='')
        elif c == 1:
            print('B', end='')
        elif c == 2:
            print('C', end='')
        exit()

Measured memory_bytes: 3064