akhauriyash/Code-Regression huggingface dataset:
n = gets.to_i
s = gets.chomp
count = 0
for a in 0..9 do
  ai = s.index(a.to_s)
  if !ai.nil?
    for b in 0..9 do
      bi = s.index(b.to_s, ai + 1)
      if !bi.nil?
        for c in 0..9 do
          ci = s.index(c.to_s, bi + 1)
          if !ci.nil?
            count += 1
          end
        end
      end
    end
  end
end
puts count


Measured memory_bytes: 3836
#include <stdio.h>
#include <stdlib.h>
#include <iostream>

using namespace std;

int main(){

        int sum = 0;
        char num;

        while(true){
                scanf("%c",&num);
                if(num == '0') break;
                
                while(num != '\n'){
                        sum += atoi(&num);
                        scanf("%c",&num);
                }
                cout << sum << "\n";
                sum = 0;
        }
        return 0;
}

Measured memory_bytes: 1160
#include <bits/stdc++.h>
using namespace std;
#define int long long 
using ldb = long double;
using pa = pair < int, int >;
#define pb push_back
#define F  first
#define S  second
#define f(i,x,n) for(int i=x;i<n;i++) 
#define all(c) c.begin(),c.end()
#define fast() ios_base::sync_with_stdio(false);cin.tie(NULL)

const int MOD = 1e9 + 7, N = 5e5 + 10;
const int LINF = LLONG_MAX;
int a,b,c,d;
string s1,s2,s3,s;
int ans,sum;
int32_t main() {
    fast();
    cin >>a >> b ;
    if(a<10){
        cout<<b+(10-a)*100;
    }
    else{
        cout<<b;
    }

    return 0;
}


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

using namespace std;


void solve() {
    int n; cin >> n;
    int mx = 0, sum = 0;
    for (int _ = 0; _ < n; _++) {
        int x; cin >> x;
        sum += x;
        mx = max(mx, x);
    }
    bool T = 2*mx < sum;
    cout << (T?"Yes":"No");
}

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    solve();
    cout << endl;
}


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

using namespace std;
using ll = long long;
using ld = long double;

namespace NyaGadget
{	// DFSライブラリ

	struct DFSedge
	{
		ll v;	// 頂点
		DFSedge(ll vindex) { v = vindex; }
	};

	template <class TE = DFSedge> struct DFS
	{
		using Graph = vector<vector<TE>>;
		Graph graph;

		DFS(ll size) { graph.resize(size); }
		// 頂点xと接続されている頂点を全て取得したいときに使う演算子
		vector<TE>& operator [](int x) { return graph[x]; }

		/**
		@brief 辺を追加する関数
		@note
		 頂点v1とv2を結ぶ辺を追加する。
		**/
		void CreateEdge(ll v1, ll v2)
		{	// 後戻りも出来るようにv1→v2とv2→v1の両方の辺を追加する
			graph[v1].push_back(DFSedge(v2));
			graph[v2].push_back(DFSedge(v1));
		}
	};

}

#define all(collection) (collection).begin(), (collection).end()  // begin to end
#define ceil(a, b) ceil((ld) a / (ld) b);                         // div ceiling
#define each(e, collection) for(auto& e: collection)              // for each
#define rep(i, begin, end) for (ll i = begin; i < end; i++)       // repeat
#define repr(i, begin, end) for (ll i = begin; end < i; i--)      // repeat reverse
#define size(collection) ((ll) (collection).size())               // collection size

using namespace NyaGadget;

/**
@brief 深さ優先探索
@param r 根
@param v 頂点
@param dfs 処理するDFSグラフ
@param memo 前処理したメモ(加算するべきカウンタの値)
@param ans 出力する答えを格納する配列
@note
 DFSで全てのノードを処理する。
**/
void Solve(ll r, ll v, DFS<>& dfs, vector<ll>& memo, vector<ll>& ans)
{
	if (r != -1)
		ans[v] = ans[r] + memo[v];

	each(e, dfs[v])
	{	// 後戻りしないようにする
		if (e.v == r)
			continue;

		Solve(v, e.v, dfs, memo, ans);
	}
}

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

	ll u, v;
	DFS<> dfs(n);
	rep(i, 0, n - 1)
	{
		cin >> u >> v;
		--u; --v;
		dfs.CreateEdge(u, v);
	}

	vector<ll> p(q), x(q);
	rep(i, 0, q)
	{
		cin >> p[i] >> x[i];
		p[i]--;
	}

	// 頂点xで加算するべきカウンタの値をメモしておく。
	vector<ll> memo(n);
	rep(i, 0, q)
		memo[p[i]] += x[i];

	vector<ll> ans(n);
	ans[0] = memo[0];
	Solve(-1, 0, dfs, memo, ans);

	each (e, ans)
		cout << e << " ";

	return 0;
}


Measured memory_bytes: 35200
import java.util.*;
import java.io.*;

class Main{
        static final String[] operator = {"+", "-", "*"};
        static Stack<Integer> stack = new Stack<Integer>();
        static BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

        static void doPlus(){
                int a=stack.pop();
                a += stack.pop();
                stack.push(a);
        }
        static void doMinus(){
                int a = 0 - stack.pop();
                a += stack.pop();
                stack.push(a);
        }
        static void doMul(){
                int a=stack.pop();
                a *= stack.pop();
                stack.push(a);
        }
        static void doPop(String i){
                stack.push(new Integer(i));
        }
        public static void main(String[] args) throws IOException{
                String[] elements = br.readLine().split(" ");
                for(String e : elements){
                        switch (e){
                                case "+":
                                        doPlus();
                                        break;
                                case "-":
                                        doMinus();
                                        break;
                                case "*":
                                        doMul();
                                        break;
                                default:
                                        doPop(e);
                        }
                }
                while(!stack.empty()){
                        System.out.print(stack.pop());
                        if(!stack.empty())
                                System.out.print(" ");
                }
                System.out.println();
        }
}

Measured memory_bytes: 24080
/**
 * Created by yusaku on 2017/02/27.
 */

fun main(args: Array<String>) {
    val line = readLine()
    if (line != null) {
        val NM = line.split(" ").map(String::toLong)
        val s = NM[0]
        val c = NM[1]

        if (s * 2 <= c) {
            print(s + (c - 2 * s) / 4)
        } else {
            print(c / 2)
        }
    }
}


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

int main(){
    int n; cin>>n;
    vector<int> weight(n);
    int sum = 0;
    for(int i=0; i<n; i++){
        cin>>weight[i];
        sum += weight[i];
    }
    int ans = sum;
    for(int i=0; i<n; i++){
        int tmp=0;
        for(int j=0; j<=i; j++){
            tmp+=weight[j];
        }
        ans = min(ans,abs(sum-2*tmp));
    }
    cout<< ans <<endl;
}

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

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

	if (n == 0){
		cout << "0" << endl;
		return 0;
	}
	if (n == 1){
		cout << "1" << endl;
		return 0;
	}
	if (n == 2){
		cout << "3" << endl;
		return 0;
	}
	long long int sum = 3;
	for(int i = 3; i <= n; i++){
		if(i%3 != 0 && i%5 != 0){
			sum = sum + i;
		}
	}
	cout << sum << endl;
	return 0;
}


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

using namespace std;

const int MAXN = 20100;

int p[MAXN], q[MAXN], a[MAXN], b[MAXN];

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	
	int n, i;
	
	cin>>n;
	
	for (i = 0; i < n; ++i)
	{
		cin>>p[i];
		--p[i];
		q[p[i]] = i;
	}
	
	for (i = 0; i < n; ++i)
		a[i] = 1 + i * n;
	
	int x = 1 + p[0] * n + 1 + (n - p[0] - 1) * n;
	
	for (i = 0; i < n; ++i)
		b[p[i]] = x + i - a[p[i]];
	
	for (i = 0; i < n; ++i)
		cout<<a[i]<<' ';
	cout<<'\n';
	for (i = 0; i < n; ++i)
		cout<<b[i]<<' ';
	cout<<'\n';
}


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

int main() {
    int ans  = 0;
    string s;
    cin >> s ;
    int n = s.size();

    for (int i = 0; i < n/2; i ++){
        if(s.at(i) != s.at(n - 1 - i)) {
            ans++;
        }
    }

    cout <<ans << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
int main() {
  string s;
  cin >> s;
  rep(i,s.size()-1)
    if(s[i]==s[i+1]){
      cout << "Bad";
      return 0;
    }
  cout << "Good";
}

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

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

using namespace std;

int main(){
	int a,b,c,k; scanf("%d%d%d%d",&a,&b,&c,&k);
	while(a>=b && k>0) b*=2, k--;
	while(b>=c && k>0) c*=2, k--;
	puts(a<b&&b<c?"Yes":"No");
	return 0;
}


Measured memory_bytes: 3760
S = list(input())
s1, s2 = int("".join(S[:2])), int("".join(S[2:]))

if 1 <= s1 <= 12 and 1 <= s2 <= 12:
    print("AMBIGUOUS")
elif 1 <= s1 <= 12 and (s2 == 0 or s2 >= 13):
    print("MMYY")
elif (s1 == 0 or s1 >= 13) and 1 <= s2 <= 12:
    print("YYMM")
else:
    print("NA")


Measured memory_bytes: 3060
#include<iostream>
using namespace std;
int main()
{
	int a, b;
	cin >> a >> b;
	if (((a == 1) || (a== 2)) && ((b == 1) || (b == 2)))
		cout << 3;
	else if (((a == 1) || (a == 3)) && ((b == 1) || (b == 3)))
		cout << 2;
	else
		cout << 1;
	return 0;
}

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

typedef long long ll;
typedef long double ld;
typedef double db;
typedef string str;
typedef pair<int, int> pi;
typedef pair<ll, ll> pll;
typedef pair<ld, ld> pd;

typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<bool> vb;
typedef vector<ll> vll;
typedef vector<ld> vld;
typedef vector<str> vs;
typedef vector<char> vc;
typedef vector<vc> vvc;
typedef vector<pi> vpi;
typedef vector<pll> vpll;

#define forr(i, a, b, s) for (int i = (a); (s) > 0 ? i < (b) : i > (b); i += (s))
#define f0(i, n) forr(i, 0, (n), 1)
#define f1(i, n) forr(i, 1, ((n) + 1), 1)
#define fo(i, b, e) forr(i, (b), (e), 1)
#define trav(a, x) for (auto &a : x)

#define mp make_pair
#define pb push_back
#define eb emplace_back
#define ff first
#define ss second

#define sz(x) (int)x.size()
#define all(x) begin(x), end(x)
#define rall(x) rbegin(x), rend(x)
#define rsz resize
#define ins insert

#define sll unordered_set<ll>
#define sii unordered_set<int>
#define mll unordered_map<ll, ll>
#define mii unordered_map<int, int>
#define pqb priority_queue<ll>
#define pqs priority_queue<ll, vll, greater<ll>>

#define zerobits(x) __builtin_ctzll(x)
#define setbits(x) __builtin_popcountll(x)
#define ps(x, y) fixed << setprecision(y) << x
#define mem(arr, x) memset(arr, x, sizeof(arr))
#define endl '\n'

const ll INF = 9e18;
ll mod = 1000000007;

template <typename T>
ostream &operator<<(ostream &stream, vector<T> &v)
{
    for (T &x : v)
        stream << x << " ";
    return stream;
}

template <typename T>
istream &operator>>(istream &stream, vector<T> &v)
{
    for (T &x : v)
        stream >> x;
    return stream;
}

template <typename T>
void sort(vector<T> &v)
{
    std::sort(v.begin(), v.end());
    return;
}

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

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

// =============== !!! ~ ~ ~ code starts here ~ ~ ~ !!! ===============

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
#ifdef RAGHAV
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
    freopen("error.txt", "w", stderr);
#endif
    clock_t t1, t2;
    t1 = clock();
    int tc = 1;
    // cin >> tc;
    while (tc--)
    {
        ll n, w;
        cin >> n >> w;
        vll weight(n), val(n);
        f0(i, n) cin >> weight[i] >> val[i];

        vector<vll> dp(n + 1, vll(w + 1));
        f0(i, n + 1) dp[i][0] = 0;
        f0(i, w + 1) dp[0][i] = 0;

        fo(i, 1, n + 1)
        {
            fo(j, 1, w + 1)
            {
                dp[i][j] = dp[i - 1][j];
                if (weight[i - 1] <= j)
                {
                    dp[i][j] = max(dp[i][j], dp[i - 1][j - weight[i - 1]] + val[i - 1]);
                }
            }
        }
        cout << dp[n][w] << endl;
    }
#ifdef RAGHAV
    t2 = clock();
    cout << "\n\ntime taken: " << (t2 - t1) / (long double)CLOCKS_PER_SEC;
#endif
    return 0;
}


Measured memory_bytes: 83136
N=int(input())
X=list(map(int,input().split()))
Y=[X[i] for i in range(N)]
Y.sort()
for i in range(N):
    if X[i]<Y[N//2]:
        B=Y[N//2]
    else:
        B=Y[(N//2)-1]
    print(B)

Measured memory_bytes: 26772
#include <stdio.h>

#include <iostream>
#include <string>
#include <vector>
using namespace std;

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

    vector<long long int> p(N);
    for (long long int i = 0; i < N; i++) {
        long long int tmp;
        cin >> tmp;
        p[i] = tmp;
    }

    double res_max = 0.0;
    double res = 0.0;
    for (long long int j = 0; j < N - K + 1; j++) {
        if (j == 0) {
            for (long long int i = 0; i < K; i++) {
                res += (p[i] + 1) * 0.5;
            }
        } else {
            res -= (p[j - 1] + 1) * 0.5;
            res += (p[j + K - 1] + 1) * 0.5;
        }
        if (res > res_max) {
            res_max = res;
        }
    }

    cout << fixed << res_max << endl;

    return 0;
}


Measured memory_bytes: 1792
#include <iostream>
#include <cmath>
#include <string>
#include <utility>
#include <queue>
using namespace std;
typedef long long int ll;

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

int main() {
  int H, N, A[10010], B[10010];
  ll dp[10010];
  ll dm[10010];
  dp[0] = 0;
  dm[0] = 0;
  cin >> H >> N;
  for (int i = 0; i < N; i++) cin >> A[i] >> B[i];
  for (int i = 1; i <= H; i++) {
    ll minv = 1e10;
    for (int j = 0; j < i; j++) {
      if (dm[j] >= i && minv > dp[j]) {
        minv = dp[j];
        dm[i] = dm[j];
      }
    }
    for (int j = 0; j < N; j++) {
      if (i - A[j] < 0) {
        minv = min(minv, B[j]);
        if (minv > B[j]) {
          dm[i] = A[j];
        }
      } else {
        minv = min(minv, dp[i-A[j]] + B[j]);
        if (minv > dp[i-A[j]] + B[j]) {
          dm[i] = dm[i-A[j]] + A[j];
        }
      }
    }
    dp[i] = minv;
  }
  cout << dp[H] << endl;
  return 0;
}


Measured memory_bytes: 888
#include <stdio.h>
#include<iostream>
#include<string>
#include <string.h>
#include <cmath>
#include <algorithm>
#include <vector>
#include <queue>
#include <climits>
#include <map>
using namespace std;
long long v[3005][3005];
long long dp[3005][3005][4];
int main() {
    int n, m, k;
    int x, y, t;
    cin >> n >> m >> k;
    for (int i = 1; i <= k; i++) {
        scanf("%d%d%d", &x, &y, &t);
        v[x][y] = t;
    }
    for (int i = 1; i <= n; i++)
        for (int j = 1; j <= m; j++) {
            for (int l = 0; l <= 3; l++) dp[i][j][0] = max(dp[i][j][0], dp[i - 1][j][l]);
            dp[i][j][0] = max(dp[i][j][0], dp[i][j - 1][0]);
            if (v[i][j]) {
                for (int l = 0; l <= 3; l++) dp[i][j][1] = max(dp[i][j][1], dp[i - 1][j][l] + v[i][j]);
            }
            for (int l = 1; l <= 3; l++) {
                if (v[i][j]) dp[i][j][l] = max(dp[i][j][l], max(dp[i][j - 1][l - 1] + v[i][j], dp[i][j - 1][l]));
                else dp[i][j][l] = dp[i][j - 1][l];
            }
        }
    long long ans = 0;
    for (int i = 0; i < 4; i++) ans = max(ans, dp[n][m][i]);
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 355844
X=int(input())

if X<=599:
  print(8)
elif X<=799:
  print(7)
elif X<=999:
  print(6)
elif X<=1199:
  print(5)
elif X<=1399:
  print(4)
elif X<=1599:
  print(3)
elif X<=1799:
  print(2)
else:
  print(1)

Measured memory_bytes: 9172
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<map>
using namespace std;
int main() {
  int N,K;
  cin >> N >> K;
  int cnt = 0;
  vector<int> h(N);
  for (int i=0; i<N; i++) {
    cin >> h[i];
    if(h[i]>=K){
      cnt++;
    }
  }
  cout << cnt << endl;
}


Measured memory_bytes: 640
#include <stdio.h>
int main(void){
    // Your code here!
    int S,h,m,s;
    scanf("%d",&S);
    h=S/3600;
    m=(S%3600)/60;
    s=(S%3600)%60;
    printf("%d:%d:%d\n",h,m,s);
    
}


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

int main(){
	int N;
	cin >> N;
	vector<int> d(N);
	for(int i = 0; i < N; i++){
		cin >> d.at(i);
	}
	
	sort(d.begin(), d.end());
	
	int ans = d.at(N / 2) - d.at((N / 2) - 1);
	
	cout << ans << endl;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
#define REP(i,N) for(i=0;i<N;i++)
typedef long long ll;

int main(void){
  int i,index=0,count=0,N,K;
  string S;
  cin >> N >> K;
  cin >> S;
  vector<int> comp;
  vector<int> len(1,0);
  char pre=' ';
  REP(i,N){
    if((i!=0 && pre!=S[i])){
      if(S[i]=='1')comp.push_back(-count);
      else comp.push_back(count);
      count=0;
    }
    pre = S[i];
    count++;
  }
  if(S[N-1]=='1')comp.push_back(count);
  else comp.push_back(-count);

  count = 0;
  REP(i,comp.size()){
    if(comp[i]<0){
      if(K<=count){
        len.push_back(len[index]+comp[i-2*K]-comp[i-2*K-1]);
        index++;
      }
      len[index]-=comp[i];
      count++;
    }else{
      len[index]+=comp[i];
    }
  }
  int max=0;
  REP(i,len.size()){
    if(max<len[i])max=len[i];
  }
  cout << max << endl;
  return 0;
}


Measured memory_bytes: 1272
// ConsoleApplication9.cpp : アプリケーションのエントリ ポイントを定義します。
//


#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<math.h>
#include<iomanip>
#include<set>
#include<numeric>
#include<cstring>
#include<cstdio>
#include<functional>

#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 FORR(i, m, n) for(int i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define REVERSE(v,n) reverse(v,v+n);
#define VREVERSE(v) reverse(v.begin(), v.end());
#define ll long long
#define pb(a) push_back(a)
#define INF 9999999999
#define m0(x) memset(x,0,sizeof(x))
#define fill(x,y) memset(x,y,sizeof(x))
#define p(x) cout<<x<<endl;
#define pe(x) cout<<x<<" ";
#define lb(v,n) lower_bound(v.begin(), v.end(), n);
#define ub(v,n) upper_bound(v.begin(), v.end(), n);
#define int long long


using namespace std;


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




ll gcd(ll x, ll y) {
	ll m = max(x, y), n = min(x, y);
	if (m%n == 0)return n;
	else return gcd(m%n, n);
}
ll lcm(ll x, ll y) {
	return x / gcd(x, y)*y;
}

ll myPow(ll x, ll n, ll m) {
	if (n == 0)
		return 1;
	if (n % 2 == 0)
		return myPow(x * x % m, n / 2, m);
	else
		return x * myPow(x, n - 1, m) % m;
}

ll pow2(ll a, ll n) {//aのn乗を計算します。
	ll x = 1;
	while (n > 0) {//全てのbitが捨てられるまで。
		if (n & 1) {//1番右のbitが1のとき。
			x = x * a;
		}
		a = a * a;
		n >>= 1;//bit全体を右に1つシフトして一番右を捨てる。
	}
	return x;
}

long long nCr(int n, int r) {
	if (r > n / 2) r = n - r; // because C(n, r) == C(n, n - r)
	long long ans = 1;
	int i;

	for (i = 1; i <= r; i++) {
		ans *= n - r + i;
		ans /= i;
	}

	return ans;
}

const int MAX = 510000;
const int MOD = 1000000007;

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

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

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

bool arr[100000100];
vector<ll>sosuu;
void Eratosthenes() {
	ll N = 10000010;
	int c = 0;
	for (int i = 0; i < N; i++) {
		arr[i] = 1;
	}
	for (ll i = 2; i < sqrt(N); i++) {
		if (arr[i]) {
			for (ll j = 0; i * (j + 2) < N; j++) {
				arr[i *(j + 2)] = 0;
			}
		}
	}

	for (int  i = 2; i < N; i++) {
		if (arr[i]) {
			sosuu.pb(i);
			//cout << sosuu[c] << " ";
			c++;
		}
	}
	//cout << endl;
	//cout << c << endl;
}

ll stoL(string s) {
	ll n = s.length();
	ll ans = 0;
	for (int i = 0; i < n; i++) {
		ans += pow2(10, n - i-1)*(ll)(s[i]-'0');
	}
	return ans;
}


signed main() {
	string X; cin >> X;
	int N = X.length();
	ll ans = 0;
	ll found = 0;
	REP(i, N) {
		if (X[i] == 'S')found++;
		if (X[i] == 'T') {
			if (found > 0) {
				ans++;
				found--;
			}
		
		}
	}
	p(N-ans*2);
}



Measured memory_bytes: 640
n, x, y = map(int, input().split())
x, y = x-1, y-1

a = [0] * n
for i in range(n):
    for j in range(i+1, n):
        k = min(j - i, abs(i-x) + abs(j-y) + 1)
        a[k] += 1

for i in a[1:]:
    print(i)

Measured memory_bytes: 46044
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N,ans,j;
  cin >> N;
  ans = 0;
  j=N+1;
  vector<int> P(N);
  for (int i = 0;i<N;i++) {
    cin >> P.at(i);
    if (j>=P.at(i)) ans++;
    if (P.at(i)<j) j=P.at(i);
  };
  cout << ans;
}

Measured memory_bytes: 1024
import Data.Map as Map

main = do
    n  <- read <$> getLine
    vs <- ((fmap read . words) <$> getLine) :: IO [Int]

    let lMap = Prelude.foldl createMap empty (oddLs vs)
    let rMap = Prelude.foldl createMap empty (evenLs vs)

    let lMax = Map.foldr max 0 lMap
    let rMax = Map.foldr max 0 rMap

    let (lfMapT,lfMapF) = partition (==lMax) lMap
    let (rfMapT,rfMapF) = partition (==rMax) rMap

    if size lfMapT == 1 && size rfMapT == 1 && keys lfMapT == keys rfMapT then do
        let lMax' = Map.foldr max 0 lfMapF
        let rMax' = Map.foldr max 0 rfMapF
        print $ min (n - lMax' - rMax) (n - lMax - rMax')
    else print (n - lMax - rMax)

createMap :: Map Int Int -> Int -> Map Int Int
createMap old n
    | member n old = insert n (old!n + 1) old
    | otherwise    = insert n 1 old

oddLs :: [a] -> [a]
oddLs []       = []
oddLs (x:[])   = [x]
oddLs (x:_:xs) = x:oddLs xs

evenLs :: [a] -> [a]
evenLs []      = []
evenLs (x:[])  = []
evenLs (_:y:ys)= y:evenLs ys

Measured memory_bytes: 82812
from collections import deque

def main():
    tosearch = deque()

    H, W = map(int, input().split())

    grid = [[-1 for _ in range(W + 2)]]
    for i in range(H):
        grid.append([-1] + [0 if char == "#" else -2 for char in input()] + [-1])
    grid.append([-1 for _ in range(W + 2)])

    for i, line in enumerate(grid):
        for j, char in enumerate(line):
            if char == 0:
                tosearch.append((i, j))

    movement = [(-1, 0), (1, 0), (0, -1), (0, 1)]

    while tosearch:
        y, x = tosearch.popleft()

        for move in movement:
            ny, nx = y + move[0], x + move[1]

            if grid[ny][nx] == -2:
                grid[ny][nx] = grid[y][x] + 1
                tosearch.append((ny, nx))

    ans = 0
    for line in grid:
        ans = max(ans, max(line))

    print(ans)


if __name__ == '__main__':
    main()


Measured memory_bytes: 84828
N, K, Q = map(int, input().split())

seikai = [0] * N

for i in range(Q):
  Ai = int(input())
  seikai[Ai-1] += 1

for n in range(N):
  if K + seikai[n] - Q > 0:
    print('Yes')
  else:
    print('No')

 


Measured memory_bytes: 4680
#include <algorithm>
#include <iostream>
#include <cassert>
#include <vector>

using namespace std;

#define rep(i, a, b) for (auto i = (a); i < (b); ++i)
#define per(i, a, b) for (auto i = (b) - 1; i >= (a); --i)
#define trav(x, v) for (auto &x : v)

#define sz(x) int((x).size())
#define eb(x...) emplace_back(x)
#define all(x) begin(x), end(x)
#define ff first
#define ss second

using ll = int64_t;

template<class T> bool ckmin(T& a, const T& b) { return a > b ? a = b, 1 : 0; }
template<class T> bool ckmax(T& a, const T& b) { return a < b ? a = b, 1 : 0; }

using vi = vector<int>;

constexpr int N = 1 << 17;
int M;
int f[N], h[N];
vi g[N];

void down(int u, int p) {
	f[u] = 1;
	if (p != u) g[u].erase(find(all(g[u]), p));
	trav(v, g[u]) {
		down(v, u);
		f[u] = 1ll * f[u] * (1 + f[v]) % M;
	}
}

void up(int u) {
	int c = sz(g[u]);
	vi s(c, 1); int x = 1;
	per(i, 1, c) s[i - 1] = 1ll * s[i] * (1 + f[g[u][i]]) % M;
	rep(i, 0, c) {
		int v = g[u][i];
		h[v] = 1ll * x * s[i] % M * (1 + h[u]) % M;
		x = 1ll * x * (1 + f[v]) % M;
		up(v);
	}
}

signed main() {
	ios::sync_with_stdio(false);
	cin.tie(nullptr);

	int n; cin >> n >> M;
	rep(i, 1, n) {
		int u, v; cin >> u >> v; --u; --v;
		g[u].eb(v); g[v].eb(u);
	}
	down(0, 0);
	up(0);
	rep(u, 0, n) cout << 1ll * f[u] * (1 + h[u]) % M << '\n';
}

Measured memory_bytes: 15232
#pragma comment(linker, "/stack:200000000")
    #pragma GCC optimize("Ofast")
    #pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
    #include<bits/stdc++.h>
    #define int long long
    using namespace std;

    signed main()
    {
        ios_base::sync_with_stdio(false);
        cin.tie(NULL);  
    //  #ifndef ONLINE_JUDGE
    //     freopen ("INPUT.txt" , "r" , stdin);
    //     freopen ("OUTPUT.txt" , "w" , stdout);
    //  #endif
        

    // -------------------------------------Code starts here--------------------------------------------------------------------- 

        int n;
        cin>>n;
        for(int i=1;i<=50000;i++)
        {
            int z=i*1.08;
            if(z==n)
            {
                cout<<i;
                return 0;
            }
        }
        cout<<":(";

    // -------------------------------------Code ends here------------------------------------------------------
        clock_t clk;
        clk = clock();
    
        clk = clock() - clk;
        cerr << fixed << setprecision(6) << "Time: " << ((double)clk)/CLOCKS_PER_SEC << "\n";
        return 0;
    }

Measured memory_bytes: 256
from fractions import gcd
A, B, C, D = map(int, input().split())

ca = (A-1)//C 
cb = B//C

da = (A-1)//D
db = B//D

lcm = C * D //gcd(C,D)
cda = (A-1)//lcm
cdb = B//lcm

print(B-A+1-((cb-ca)+(db-da)-(cdb-cda)))


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

int main() {
	int s;
	cin >> s;
	vector<int>a;
	a.push_back(s);
	int i = 1;
	bool flag = 1;
	while (flag) {
		if (a[i - 1] % 2)a.push_back(3 * a[i-1] + 1);
		else a.push_back(a[i - 1] / 2);
		for (int j = 0; j < i; j++)if (a[i] == a[j])flag = 0;
		i++;
	}
	cout << i << endl;
}


Measured memory_bytes: 256
parseInt(x)=parse(Int,x)
parseMap(x::Array{SubString{String},1})=map(parseInt,x)

function main()
	n = readline() |> parseInt
	a = readline() |> split |> parseMap
	b = zeros(Int,n)
	b[1] = a[1]
	for i in 2:n
		if i%2==0
			b[i] = b[i-1]-a[i]
		else
			b[i] = b[i-1]+a[i]
		end
	end
	print(b[n]," ")
	for i in 2:n-1
		if i%2 == 0
			print(-(b[n]-2*b[i-1]), " ")
		else
			print(b[n]-2*b[i-1], " ")
		end
	end
	println(b[n]-2*b[n-1])
end

main()

Measured memory_bytes: 166168
#include<iostream>
#include<string>
#include<vector>
#include<queue>
using namespace std;
// This is Dummy Program SOrry
// Problem https://atcoder.jp/contests/agc033/tasks/agc033_a
// Reference http://drken1215.hatenablog.com/entry/2019/05/05/223200
// 上記レファレンス通りで動作確認

int H,W;
vector<string> fi;

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

int main(void){
    cin >> H >> W;
    fi.resize(H);
  //  cout << H << "," << W << endl;
    for(int j=0;j<H;j++){
        cin >> fi[j];
    }
/**    for(int j=0;j<H;j++){
        cout << fi.at(j) << endl;
    } **/
    vector<vector<int>> dist(H,vector<int> (W,-1));
    using pint = pair<int,int>;
    queue<pint> que;
    for(int j=0;j<H;j++){
        for(int k=0;k<W;k++){
            if(fi.at(j).at(k) == '#'){
                dist.at(j).at(k) = 0;
                que.push(pint(j,k));
            }
        }
    }
 //   cout << "Init # count" << que.size() << endl;
    // 深さ優先探索
    while(!que.empty()){
        auto nowCursol = que.front();
//        cout << "Cursol is " << nowCursol.first << "," << nowCursol.second << endl;
        que.pop();
        for(int dir=0;dir<4;dir++){
            int curX = nowCursol.first+dx[dir];
            int curY = nowCursol.second+dy[dir];
            if(curX < 0 || curY < 0 || (H-1) < curX || (W-1) < curY){ // 範囲外に出ている
                continue;  // 処理しないので次の動きで回るfor文へ
            }
            if(dist.at(curX).at(curY) == -1){
                dist.at(curX).at(curY) = dist.at(nowCursol.first).at(nowCursol.second) +1;
            que.push(pint(curX,curY));
            }

        }
    } 
    int answer = -1;
    for(int j=0;j<H;j++){
        for(int k=0;k<W;k++){
            if(answer < dist.at(j).at(k)){
                answer = dist.at(j).at(k);
            }
        }
    }
    cout << answer << endl;
}

Measured memory_bytes: 13456
#include <stdio.h>

int main(void)
{
	int W, H, x, y, r;
	
	scanf("%d %d %d %d %d", &W, &H, &x, &y, &r);
	
	if (x + r <= W && x - r >= 0 && y + r <= H && y -r >= 0){
		puts("Yes");
	}
	else {
		puts("No");
	}
	
	return (0);
}

Measured memory_bytes: 584
#include <iostream>
#include <vector>
#include <limits.h>
#include <algorithm>
#include <string>
#include <math.h>
#include <limits.h>
#include <queue>
#include <map>
#include <set>
#include <iomanip>
#include <bitset>
#include <cassert>
#include <random>
#include <functional>
#include <stack>
#include <iomanip>
#include <cassert>
//#include <boost/multiprecision/cpp_int.hpp>
#include <complex>
#include <cstdio>
#include <list>
#include <bitset>

//< in.txt > out.txt
using namespace std;
//std::ios::sync_with_stdio(false);
//std::cin.tie(0);
const long long MOD = 998244353;
const long long INF = 1e18;
typedef long long LL;
typedef long double LD;
//typedef boost::multiprecision::cpp_int bigint;
typedef pair<LL, LL> PLL;
typedef pair<LD, LL> pdl;
typedef pair<LD, LD> pdd;
typedef vector<LL> VLL;
typedef vector<VLL> VVLL;
typedef unsigned long long ULL;

int main() {
	std::ios::sync_with_stdio(false);
	std::cin.tie(0);
	LL X, Y;
	cin >> X >> Y;
	for (LL n = 0; n <= 200; n++) {
		if ((X - n) < 0)continue;
		if (2 * n + (X - n) * 4 == Y) {
			cout << "Yes\n";
			return 0;
		}
	}
	cout << "No\n";
	return 0;
}

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

int main()
{
    long  n, i, a[100001], b[100001],c[100001];
    //freopen("vocation.inp","r",stdin);
    cin>>n;
    long A[n],B[n],C[n];

    for (i=1;i<=n;i++)
        cin >> a[i]>>b[i]>>c[i];
    A[1]=a[1];
    B[1]=b[1];
    C[1]=c[1];
    for (i=2;i<=n;i++)
    {
        A[i]=max(B[i-1],C[i-1])+a[i];
        B[i]=max(C[i-1],A[i-1])+b[i];
        C[i]=max(A[i-1],B[i-1])+c[i];
    }
    cout<<max(max(A[n],B[n]),C[n]);
    return 0;
}


Measured memory_bytes: 4992
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#include <climits>
#include <cstring>
#include <cassert>


using namespace std;
#define SZ(x) (int)(x.size())
#define REP(i, n) for(int i=0;i<n;++i)
#define FOR(i, a, b) for(int i=a;i<b;++i)
#define RREP(i, n) for(int i=n-1;i>=0;--i)
#define RFOR(i, a, b) for(int i=b-1;i>=a;--i)

#define all(x) begin(x),end(x)
#define dump(x) cerr<<#x<<" = "<<(x)<<endl
#define debug(x) cerr<<#x<<" = "<<(x)<<" (L"<<__LINE__<<")"<< endl;

using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using P = pair<int, int>;
const double eps = 1e-8;
const ll MOD = 1000000007;
const int INF = INT_MAX / 2;
const ll LINF = LLONG_MAX / 2;

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

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


template<typename T1, typename T2>
ostream &operator<<(ostream &os, const pair<T1, T2> p) {
    os << p.first << ":" << p.second;
    return os;
}

template<class T>
ostream &operator<<(ostream &os, const vector<T> &v) {
    os << "[";
    REP(i, SZ(v)) {
        if (i) os << ", ";
        os << v[i];
    }
    return os << "]";
}

template<class T1, class T2>
ostream &operator<<(ostream &os, const map<T1, T2> &mp) {
    os << "[";
    for (auto it = mp.begin(); it != mp.end(); ++it) {
        if (it != mp.begin()) {
            os << ", ";
        }
        os << *it;
    }
    return os << "]";
}

// edit

void solve() {
    int a;
    cin >> a;
    a = a + a * a + a * a * a;
    cout << a << endl;



}


int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(10);
//    std::ifstream in("input.txt");
//    std::cin.rdbuf(in.rdbuf());

    solve();


    return 0;
}


Measured memory_bytes: 3188
#include <bits/stdc++.h> 
using namespace std; 
#define INF 0x3f3f3f3f 
int n, val[100005], dp[100005], k;
int main() { 
    cin >> n >> k;
    for(int i=1; i<=n; i++){ 
        cin >> val[i]; 
    }
    memset(dp, INF, sizeof(dp));
    dp[1]=0; 
    dp[2]=abs(val[2]-val[1]); 
    for(int i=3; i<=n; i++){
        for(int j=1; j<=k; j++){
            if(j<=i){
                dp[i]=min(dp[i], dp[i-j]+abs(val[i]-val[i-j]));
            }
        }
    }
    cout << dp[n] << endl; 
    return 0; 
}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
const int N=2*1e5+5;
int frv[N];
int v[N];
int main()
{
  int n;
  cin>>n;
  long long ans=0;
  for(int i=1;i<=n;i++){
    cin>>v[i];
    ans+=frv[v[i]];
    frv[v[i]]++;
  }
  for(int i=1;i<=n;i++){
    long long auxans=ans-(frv[v[i]]-1);
    cout<<auxans<<"\n";
  }
  return 0;
}


Measured memory_bytes: 3712
//INCLUDE
//------------------------------------------
#include <bits/stdc++.h>
//DEFINE
//------------------------------------------
#define ll long long
#define ld long double
#define ALLv(a)  (a).begin(),(a).end()
#define ALL(a,n)  (a),(a)+n
#define vi vector<long long>
#define vd vector<long double>
#define vs vector<string>
#define dcml(n) fixed<<setprecision(n)
//CONST
//------------------------------------------
const ll INF=1010000000000000017LL;
const ll MOD=1000000007LL;
const ld EPS=1e-12;
const ld PI=3.14159265358979323846;
//REPEAT
//------------------------------------------
#define   FOR(i,m,n) for(ll (i)=(m);   (i)<(n);  (i)++)
#define  FORS(i,m,n) for(ll (i)=(m);   (i)<=(n); (i)++)
#define  RFOR(i,m,n) for(ll (i)=(n)-1; (i)>=(n); (i)--)
#define RFORS(i,m,n) for(ll (i)=(n);   (i)>(n);  (i)--)
#define   REP(i,n)   for(ll (i)=0;     (i)<(n);  (i)++)
#define  REPS(i,x)   for(ll (i)=1;     (i)<=(x); (i)++)
#define  RREP(i,x)   for(ll (i)=(x)-1; (i)>=0;   (i)--)
#define RREPS(i,x)   for(ll (i)=(x);   (i)> 0;   (i)--)
#define  WREP(i,in,j,jn) REP(i,in)REP(j,jn)
#define WREPS(i,in,j,jn) REPS(i,in)REPS(j,jn)
//-----------------------------------------
//namespace
using namespace std;
//ライブラリはここに
//↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓

//-----------------------------------------
int main(void){
    ll N,K;cin>>N>>K;
    vector<ll> A(N);
    REP(i,N){cin>>A[i];A[i]--;}
    
    ll fi,li;//first, last

    vi v;//軌跡
    ll done[N+1];REP(i,N+1)done[i]=-1;//いつ行ったか
    ll tmp=0;//初期値=0
    v.push_back(0);
    REPS(i,N+1){
        tmp=A[tmp];v.push_back(tmp);
        if(done[tmp]==-1){
            done[tmp]=i;
        }else{
            li=i;fi=done[tmp];
            //cout<<"fi:"<<fi<<"li:"<<li<<"\n";
            break;
        }
    }

    if(K<N+1){//K<N+1の場合に限り
        REP(i,N){
            if(i==K){
                cout<<v[i]+1<<"\n";
                exit(0);
            }
        }
    }

    //cout<<v[fi]<<" "<<v[li]<<"\n";
    v.erase(v.begin(),v.begin()+fi);
    //cout<<v[0]<<" "<<v[v.size()-1]<<"\n";

    ll idx=K-fi;
    ll round=li-fi;
    //cout<<idx<<" "<<round<<"\n";
    cout<<v[idx%round]+1<<"\n";

}

Measured memory_bytes: 8432
// https://atcoder.jp/contests/agc022/tasks/agc022_e
//
#![allow(unused_imports)]
use std::io::*;
use std::fmt::*;
use std::str::*;
use std::cmp::*;
use std::collections::*;

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

macro_rules! input_inner {
    ($iter:expr) => {};
    ($iter:expr, ) => {};

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

macro_rules! read_value {
    ($iter:expr, ( $($t:tt),* )) => {
        ( $(read_value!($iter, $t)),* )
    };

    ($iter:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()
    };

    ($iter:expr, chars) => {
        read_value!($iter, String).chars().collect::<Vec<char>>()
    };

    ($iter:expr, usize1) => {
        read_value!($iter, usize) - 1
    };

    ($iter:expr, $t:ty) => {
        $iter.next().unwrap().parse::<$t>().expect("Parse error")
    };
}

#[allow(unused_macros)]
macro_rules! debug {
    ($($a:expr),*) => {
        println!(concat!($(stringify!($a), " = {:?}, "),*), $($a),*);
    }
}

const MOD: u64 = 1e9 as u64 + 7;

fn main() {
    input! {
        s: chars
    };
    let n = s.len();

    let mut dp = vec![vec![0; 8]; n+1];

    dp[0][0] = 1;
    for i in 0..n {
        for j in 0..8 {
            let base = dp[i][j];
            let last = j & 1;
            let has_one = j & 2;
            let has_two = j & 4;

            for w in 0..2 {
                if s[i] == '1' && w == 0 {
                    continue;
                }
                if s[i] == '0' && w == 1 {
                    continue;
                }


                let mut tj = has_one | has_two | w;
                if i == 0 && w == 1 {
                    tj |= 2;
                }
                if i >= 1 && w == 1 && last == 1 {
                    if (i-1)%2 == 1 {
                        tj |= 2;
                    } else if (tj & 2) == 2 {
                        tj |= 4;
                    }
                }
                if i == n-1 && w == 1 && (tj & 2) == 2 {
                    tj |= 4;
                }
                dp[i+1][tj] += base;
                dp[i+1][tj] %= MOD;
            }
        }
    }

    println!("{}", (dp[n][6] +dp[n][7]) % MOD);
}


Measured memory_bytes: 33020
N, K, *A = map(int, open(0).read().split())

ans = 10 ** 9 * 20
for bit in range(2 ** N):
    if bin(bit).count("1") < K or not (bit >> 0 & 1):
        continue

    res = 0
    tmp = A[0]
    for i in range(1, N):
        if bit >> i & 1:
            res += max(0, tmp - A[i] + 1)
            tmp = max(A[i], tmp + 1)
        else:
            tmp = max(A[i], tmp)
    ans = min(ans, res)

print(ans)


Measured memory_bytes: 42604
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <algorithm>
#include <deque>
#include <cctype>
#include <cstdio>
#include <math.h>
#include <set>
using namespace std;
int main(){
    string s;
    cin >> s;
    string ans;
    if(s[0]==s[s.length()-1]){
        if(s.length()%2==0){
            ans = "First";
        }else{
            ans = "Second";
        }
    }else{
        if(s.length()%2==0){
            ans = "Second";
        }else{
            ans = "First";
        }
    }
    cout << ans << endl;
}

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

int main(){
    int N,K;
    cin>>N>>K;
    vector<ll>X(N);
    rep(i,N){
        cin>>X.at(i);
    }
    ll ans=20000000000;
    for(int i=0;i<=N-K;i++){
        ll a=min(abs(X[i])+abs(X[i+K-1]-X[i]),abs(X[i+K-1])+abs(X[i+K-1]-X[i]));
        ans=min(a,ans);
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define fi first
#define se second
#define pb push_back
#define eb emplace_back
#define sz(x) (int)(x).size()
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()
using namespace std;
using ll = long long;
using P = pair<int, int>;
using vi = vector<int>;
using vc = vector<char>;
using vb = vector<bool>;
using vs = vector<string>;
using vll = vector<long long>;
using vp = vector<pair<int, int>>;
using vvi = vector<vector<int>>;
using vvc = vector<vector<char>>;
using vvll = vector<vector<long long>>;
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 (b<a) {a=b; return 1;} return 0;}

const int mod = 1000000007;
struct mint {
    long long x;
    mint(long long x=0) : x((x % mod + mod) % mod) {}
    mint operator-() const { return mint(-x);}
    mint& operator+=(const mint a) {
        if ((x += a.x) >= mod) x -= mod;
        return *this;
    }
    mint& operator-=(const mint a) {
        if ((x += mod - a.x) >= mod) x -= mod;
        return *this;
    }
    mint& operator*=(const mint a) { (x *= a.x) %= mod; return *this;}
    mint operator+(const mint a) const { return mint(*this) += a;}
    mint operator-(const mint a) const { return mint(*this) -= a;}
    mint operator*(const mint a) const { return mint(*this) *= a;}
    mint pow(long long t) const {
        if (!t) return 1;
        mint a = pow(t>>1);
        a *= a;
        if (t&1) a *= *this;
        return a;
    }
    mint inv() const { return pow(mod-2);}
    mint& operator/=(const mint a) { return *this *= a.inv();}
    mint operator/(const mint a) const { return mint(*this) /= a;}
};
istream& operator>>(istream& is, const mint& a) { return is >> a.x;}
ostream& operator<<(ostream& os, const mint& a) { return os << a.x;}

vector<vector<int>> to;
mint ans = 1;
int n, k;

void dfs(int v, int x=k, int p=-1) {
    ans *= x;
    int nxt = (p == -1 ? k : k-1);
    for (auto u : to[v]) {
        if (u == p) continue;
        dfs(u, --nxt, v);
    }
}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    
    cin >> n >> k;
    to.resize(n);
    rep(i, n-1) {
        int a, b;
        cin >> a >> b;
        a--; b--;
        to[a].pb(b);
        to[b].pb(a);
    }
    dfs(0);
    cout << ans << endl;
}

Measured memory_bytes: 9216
#include <bits/stdc++.h>
using namespace std;
#define rep(i, srt, end) for (long long i = (srt); i < (long long)(end); i++)
#define VL vector<ll>
#define INF 100000000
typedef long long ll;
 
int main(){
    ll N,A,B;
    cin>>N>>A>>B;
    if((N*A)<=B)cout<<(N*A);
    else cout<<B;
    return 0;
}

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

int main(int argc, const char * argv[]) {
    double a,b,c;
    int hisi=0,cho=0;
    
    while(scanf("%lf,%lf,%lf",&a,&b,&c)!=EOF){
        if(fabs(a-b)<0.00001){
            if(fabs(a*a+b*b-c*c)>0.00001)
                hisi++;
        }
        
        else if(fabs(a*a+b*b-c*c)<0.00001)
            cho++;
        
        
        
    }
    printf("%d\n",cho);
    printf("%d\n",hisi);
    
    
    return 0;
}

Measured memory_bytes: 624
#ABC 085 C Otoshidama
N, Y = (int(i) for i in input().split())

def find():
  rhs = Y - 1000 * N

  for x in range(N+1):
    for y in range(N+1-x):
      if 9000 * x + 4000 * y == rhs:
        return x, y, N-x-y
      
  return -1, -1, -1

print(("{} {} {}").format(*find()))

Measured memory_bytes: 3060
#include <iostream>
#include <algorithm>

#define NUM 1000*1000

using namespace std;

int pnum[500], dp1[NUM], dp2[NUM];

int main(){
	for(int i=0; pnum[i-1]<NUM; i++){
		pnum[i] = (i*(i+1)*(i+2))/6;
	}
	for(int i=1; i<NUM; i++){
		dp1[i]=dp2[i]=NUM+1;
	}
	for(int i=0; i<NUM; i++){
		for(int j=0; j<500; j++){
			if(i+pnum[j]>NUM) break;
			dp1[i+pnum[j]] = min(dp1[i+pnum[j]], dp1[i]+1);
			if(pnum[j]%2) dp2[i+pnum[j]] = min(dp2[i+pnum[j]], dp2[i]+1);
		}
	}
	while(1){
		int n;  cin >>n;
		if(!n) break;
		cout << dp1[n] << " " << dp2[n] << endl;
	}
}


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

using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
typedef long long ll;
using Graph = vector<vector<int>>;
typedef long long ll;
typedef pair<int, int> P;

const int MOD = 1000000007;
const int INF_32 = 1LL << 30;
const int64_t INF_64 = 1LL << 60;

const int MAX_N = 110000;

int main()
{
    int N;
    ll K;
    cin >> N >> K;
    vector<pair<ll, ll>> v(N);
    for (int i = 0; i < N; i++)
        cin >> v[i].first >> v[i].second;

    // sort
    sort(v.begin(), v.end());

    ll res = 0;
    ll sum = 0;
    for (int i = 0; i < N; i++) {
        sum += v[i].second;
        if (sum >= K) {
            res = v[i].first;
            break;
        }
    }
    cout << res << endl;
    return 0;
}

Measured memory_bytes: 4812
#include <stdio.h>
int main(void)
{
int a, b;
scanf("%d", &a);
scanf("%d", &b);

if(a < b){
printf("a < b\n");
}
else if(a > b){
printf("a > b\n");
}
else{
printf("a == b\n");
}


return 0;
}

Measured memory_bytes: 580
function main(input) {
  var x = input[0]-0;
  var oni = [100,101,102,103,104,105];
  var dp = {};
  dp[0] = 0;
  oni.forEach(v=>dp[v]=1);
  for(var i=100;i<=x;i++){
    oni.forEach(v=>{
      if(i>v && dp[i-v]){
        dp[i] = (dp[i]||0)+1;
      }
    });
  }
  console.log(dp[x]?1:0);
}

main(require('fs').readFileSync('/dev/stdin', 'utf8').split("\n"))


Measured memory_bytes: 15052
#include <bits/stdc++.h>
using namespace std;
int main() {
    int n;
    int cnt = 0;
    bool flg = false;
    cin >> n;
    int nums[n];
    for (int i = 0; i < n; i++) {
        cin >> nums[i];
        if (nums[i] % 2 != 0) {
            cout << 0 << endl;
            return 0;
        }
    }
    while (!flg) {
        for (int i = 0; i < n; i++) {
            if (nums[i] % 2 == 1) {
                flg = true;
                break;
            } else {
                nums[i] /= 2;
            }
        }
        if (!flg) cnt += 1;
    }
    cout << cnt << endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <stdlib.h>
#include <time.h> 
 
using namespace std;
long long mod = 1e9 + 7;
long long INF = 1e7;
double EPS = 1e-12;
typedef long long int lld;
long double tick(){static clock_t oldt; clock_t newt=clock();
    long double diff=1.0L*(newt-oldt)/CLOCKS_PER_SEC; oldt = newt; return diff; }
#define rep(i,a,n) for(long long int i = (a); i <= (n); ++i)
#define repI(i,a,n) for(int i = (a); i <= (n); ++i)
#define repD(i,a,n) for(long long int i = (a); i >= (n); --i)
#define repDI(i,a,n) for(int i = (a); i >= (n); --i)
inline lld sc() { lld a; scanf("%lld", &a); return a; }
inline int scd() { int a; scanf("%d", &a); return a; }
inline double scf() { double a; scanf("%lf",&a); return a; }
#define prL(a) printf("%lld\n",a)
#define prS(a) printf("%lld ",a)
#define prdL(a) printf("%d\n",a)
#define prdS(a) printf("%d ",a)
#define all(c) (c).begin(), (c).end()
#define sz(a) ((int)a.size())
#define Error(x...) { cout << "(" << #x << ")" << " = ( "; printIt(x); }
template <typename T1> void printIt(T1 t1) { cout << t1 << " )" << endl; }
template <typename T1, typename... T2>
void printIt(T1 t1, T2... t2) { cout << t1 << " , "; printIt(t2...); }
#define errorpair(a) cout<<#a<<" = ( "<<((a).first)<<" , "<<((a).second)<<" )\n";
#define mset(a, v) memset(a, v, sizeof(a))
#define popcount __builtin_popcountll

typedef pair<lld,lld> PA;

lld powP(lld x, lld y) {
    lld ans = 1, po = x % mod;
    while(y > 0) {
        if(y & 1) ans = ans * po % mod;
        y >>= 1; po = po * po % mod;
    }
    return ans;
}
 
bool bitSet(lld n, lld bit){
    if((n & (1LL << bit)) != 0) return true;
    else return false;
}
 
lld findGcd(lld a, lld b){
    while(a != 0) { lld temp = b % a; b = a; a = temp; }
    return b;
}

#define lim 300010
#define lim2 200010
#define qqqqqq 210
// Ab :)
// inline lld sqr(lld x) { return x * x; }
// unordered_map<lld,lld>::iterator it;
// std::ios::sync_with_stdio(false);
// priority_queue<PA> Q;
// lld dp[1<<18];

// vector<lld> G[lim];
// string S[lim];
// lld A[lim];
lld Cost[20], A[20][20];
lld Know[20];

int main(){
    lld n = sc(), m = sc(), x = sc();
    rep(i,0,n-1) {
        Cost[i] = sc();
        rep(j,1,m) A[i][j] = sc();
    }
    lld ans = INT_MAX;
    lld total = (1LL << n) - 1;
    rep(mask,1,total) {
        rep(j,1,m) Know[j] = 0;
        lld cost = 0;
        rep(bit,0,n-1) {
            if(bitSet(mask, bit)) {
                cost += Cost[bit];
                rep(j,1,m) Know[j] += A[bit][j];
            }
        }
        bool poss = true;
        rep(j,1,m) {
            if(Know[j] < x) poss = false;
        }
        if(poss) ans = min(ans, cost);
    }
    if(ans == INT_MAX) ans = -1;
    prL(ans);
    return 0;
}


Measured memory_bytes: 3828