akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <functional>

using namespace std;

typedef pair<int,int> PII;
typedef pair<int,PII> PIII;

int ufind(vector<int>& P, int u) {
  if (P[u] == 0) {
    return u;
  }
  return P[u] = ufind(P, P[u]);
}

void uf(vector<int>& P, int u, int v) {
  int _u = ufind(P, u);
  int _v = ufind(P, v);
  if (_u != _v) {
    P[_u] = _v;
  }
}

int main()
{
  int n;
  vector<PII> X, Y;

  cin >> n;
  for (int i = 1; i <= n; ++i) {
    int x,y;
    cin >> x >> y;
    X.push_back(make_pair(x,i));
    Y.push_back(make_pair(y,i));
  }

  sort(X.begin(), X.end());
  sort(Y.begin(), Y.end());

  vector<PIII> q;
  for (int i = 1; i < n; ++i) {
    int u = X[i-1].second, v = X[i].second;
    int xu = X[i-1].first, xv = X[i].first;
    q.push_back(make_pair(xv-xu, make_pair(u,v)));
  }
  for (int i = 1; i < n; ++i) {
    int u = Y[i-1].second, v = Y[i].second;
    int yu = Y[i-1].first, yv = Y[i].first;
    q.push_back(make_pair(yv-yu, make_pair(u,v)));
  }
  sort(q.begin(), q.end());

  long long res = 0;
  vector<int> P(n+1);
  for (PIII p : q) {
    int d = p.first;
    int u = p.second.first, v = p.second.second;

    if (ufind(P, u) != ufind(P, v)) {
      res += d;
      uf(P, u, v);
    }
  }
  cout << res << "\n";
}


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

const int INF = 1 << 30;

struct Vertex {
	int id;
	int w;
	vector<Vertex> vtxs;
};

int prim(int n, Vertex vtxs[]){
	
	int d[n];
	bool vst[n];
	for(int i=0;i<n;i++){
		d[i] = INF;
		vst[i] = false;
	}
	
	d[0]=0;
	while(true) {
		int minv = INF;
		int u = -1;
		for(int i=0;i<n;i++){
			if(vst[i]) continue;
			if(minv > d[i]){
				minv = d[i];
				u = i;
			}
		}
		if(u==-1) break;
		vst[u]=true;
		vector<Vertex> vec=vtxs[u].vtxs;
		for(int v=0;v<vec.size();v++){
			Vertex vtx=vec[v];
			int id=vtx.id;
			if(vst[id]) continue;
			d[id]=min(d[id],vtx.w);
		}
	}
	int cost=0;
	for(int i=0;i<n;i++){
		cost+=d[i];
	}
	return cost;
}

int main(){
	int n;
	cin >> n;
	Vertex vtxs[n];
	for(int i=0;i<n;i++){
		for(int j=0;j<n;j++){
			int w;
			cin >> w;
			if(w==-1) continue;
			Vertex v;
			v.id = j;
			v.w = w;
			vtxs[i].vtxs.push_back(v);
		}
	}
	int cost = prim(n,vtxs);
	cout << cost << endl;
	return 0;
}



Measured memory_bytes: 3372
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <sstream>
#include <stack>
#include <string>
#include <unordered_set>
#include <vector>

using namespace std;

#define ll long long
#define P pair<int, int>
#define FOR(i, N) for (int i = 0; i < (int)N; i++)
#define FORIN(i, a, b) for (int i = a; i < (int)b; i++)
#define ALL(x) (x).begin(), (x).end()
#define GI(name) \
  int(name);     \
  scanf("%d", &(name))
#define GI2(name1, name2) \
  int(name1), (name2);    \
  scanf("%d %d", &(name1), &(name2))
#define GI3(name1, name2, name3) \
  int(name1), (name2), (name3);  \
  scanf("%d %d %d", &(name1), &(name2), &(name3))
#define GVI(name, size)    \
  vector<int>(name)(size); \
  FOR(i, (size)) scanf("%d", &(name)[i])
#define GS(name) \
  string(name);  \
  cin >> (name);
#define MOD 1000000007
#define DEBUG(...) debug(__LINE__, ":" __VA_ARGS__)

string to_string(string s) {
  return s;
}

template <class T>
string to_string(vector<T> v) {
  string ret = "{";
  FOR(i, v.size() - 1) { ret += to_string(v[i]) + ","; }
  if (v.size() > 0) {
    ret += to_string(v.back());
  }
  ret += "}";
  return ret;
}

void debug() {
  cerr << endl;
}

template <class Head, class... Tail>
void debug(Head head, Tail... tail) {
  cerr << to_string(head) << " ";
  debug(tail...);
}

void print() {
  cout << endl;
}

template <class Head, class... Tail>
void print(Head head, Tail... tail) {
  cout << to_string(head);
  print(tail...);
}

int gcd(int a, int b) {
  int r = a % b;
  while (r != 0) {
    a = b;
    b = r;
    r = a % b;
  }
  return b;
}

int main() {
  GI3(A, B, C);
  print(C % gcd(A, B) == 0 ? "YES" : "NO");
  return 0;
}

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

int main() {
    string a,b,ans;
    cin>>a>>b;
    if (a.size()!=b.size()) {
        if (a.size()>b.size()) ans="GREATER";
        else if(a.size()<b.size()) ans="LESS";
        else ans="EQUAL";
    } else {
        if (a>b) ans="GREATER";
        else if(a<b) ans="LESS";
        else ans="EQUAL";
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 256
import java.util.Scanner;
class Main
 {
   public static void main(String[] args)
      {
   Scanner S = new Scanner(System.in);
      int x = S.nextInt();
      int y = S.nextInt();
      int z =S.nextInt();
      int m = 0;
      int n = 0;
      for(int i=x;i<=y ;i++)
      if (z%i==n){
      m= m + 1;
      }
      System.out.println(m);
      }
 }



Measured memory_bytes: 26268
def dfs(array, visited, next):
    if visited[next] is not True and len(array[next]) != 0:
        visited[next] = True
        for next_node in array[next]:
            visited = dfs(array, visited, next_node)
    else:
        return visited
    return visited


n, m = map(int, input().split())
edge_array = []
for i in range(m):
    edge_array.append([int(x) for x in input().split()])

cnt = 0
for _ in edge_array:
    remove_edge = edge_array[0]
    edge_array.remove(remove_edge)
    node_array = [[] for x in range(n + 1)]
    # 隣接リストの作成
    for edge in edge_array:
        node_array[edge[0]].append(edge[1])
        node_array[edge[1]].append(edge[0])
        visited = [False]*(n+1)
    res = dfs(node_array, visited, 1)
    if res.count(False) != 1:
        cnt += 1
    edge_array.append(remove_edge)

print(cnt)


Measured memory_bytes: 3064
A,B,C,D,E,F = map(int,input().split())

waters = set()
for a in range(0,F+1,100*A):
    for b in range(0,F+1,100*B):
        if a+b > F:
            break
        waters.add(a+b)
waters.remove(0)

sugars = set()
for c in range(0,F+1,C):
    for d in range(0,F+1,D):
        if c+d > F:
            break
        sugars.add(c+d)

best_r = -1
best_w = best_s = 0

for w in waters:
    for s in sugars:
        if w+s > F: continue
        if E*w < s*100: continue
        r = s / (w+s)
        if r > best_r:
            best_r = r
            best_s = s
            best_w = w
print(best_w+best_s, best_s)

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

#define rep(i, n) for (int i = 0; i < (n); i++)
#define repeat(i, a, b) for (int i = (a); i < (b); i++)
#define INF 2e8
#define all(a) a.begin(), a.end()

int main() {
  int n, t;
  cin >> n >> t;
  vector<vector<int>> d(n, vector<int>(2));
  rep(i, n) { cin >> d[i][0] >> d[i][1]; }

  // 所要時間T以下の要素のみフィルタリング
  vector<vector<int>> d_flt;
  copy_if(all(d), back_inserter(d_flt), [t](auto p) { return p[1] <= t; });
  if (d_flt.empty()) {
    cout << "TLE" << endl;
    return 0;
  }

  // 第0成分へ射影
  vector<int> d_flt0(d_flt.size());
  transform(all(d_flt), d_flt0.begin(), [](auto p) { return p[0]; });

  cout << *min_element(all(d_flt0)) << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp>
//#include <boost/lexical_cast.hpp>
#include <ext/pb_ds/detail/standard_policies.hpp>
using namespace std;
using namespace __gnu_pbds;
#define int long long
#define pb push_back
#define mp make_pair
#define endl '\n'
#define PI acos(-1)
#define bitcount(a) __builtin_popcountll(a)
#define P pair<int,int>
typedef tree<int,null_type,less_equal <int>,rb_tree_tag,tree_order_statistics_node_update>ordered_set;

long mod=1e9+7;
signed main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	int n;
	cin>>n;
	int a[n];
	for(int i=0;i<n;i++)
		cin>>a[i];
	int ans=0;
	int temp=1;
	for(int i=1;i<n;i++)
	{
		if(a[i]<=a[i-1])
		{
			++temp;
		}
		else
		{
			ans=max(ans,temp-1);
			temp=1;
		}
	}
	ans=max(ans,temp-1);
	cout<<ans;
	return 0;
}

Measured memory_bytes: 1024
#include <iostream>
#include <stdexcept>
#include <cassert>
#include <cmath>
#include <vector>
using namespace std;


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

  int prev = 0;
  int ans = abs(h[0] - h[1]);

  int tmp;
  for (int i = 2; i < N; i++) {
    tmp = ans;
    ans = min(
      ans + abs(h[i] - h[i-1]),
      prev + abs(h[i] - h[i-2])
    );
    prev = tmp;
  }
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 3784
import           Control.Applicative
import           Control.Monad
import           Data.List

type Width = Int
type Height = Int
type X = Int
type Y = Int
type R = Int

main :: IO ()
main = do
  w:h:x:y:r:_ <- (map read . words) <$> getLine
  putStrLn $ if isWithinArea w h x y r then "Yes" else "No"

isWithinArea :: Width -> Height -> X -> Y -> R -> Bool
isWithinArea w h x y r =
  case (x <= w - r, x >= r, y <= h - r, y >= r) of
    (True, True, True, True) -> True
    _                        -> False

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

enum state { New, Working, Done };

int main()
{
	int n;
	cin >> n;
	vector<vector<int>> am(n, vector<int>(n, -1));
	for (int i = 0; i < n; i++) {
		int u, k;
		cin >> u >> k;
		for (int j = 0; j < k; j++) {
			int v, c;
			cin >> v >> c;
			am[u][v] = c;
		}
	}

	vector<int> d(n, INT_MAX), p(n, INT_MAX);
	vector<state> status(n);
	d[0] = 0;
	p[0] = -1;
	status[0] = Working;
	while (true) {
		int minv = INT_MAX;
		int node = -1;
		for (int i = 0; i < n; i++) {
			if (status[i] != Done && d[i] < minv) {
				minv = d[i];
				node = i;
			}
		}
		if (minv == INT_MAX) break;
		status[node] = Done;
		for (int i = 0; i < n; i++) {
			if (am[node][i] != -1 && status[i] != Done && d[node] + am[node][i] < d[i]) {
				d[i] = d[node] + am[node][i];
				status[i] = Working;
			}
		}
	}

	for (int i = 0; i < n; i++) cout << i << " " << d[i] << endl;
}



Measured memory_bytes: 3120
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Scanner;

/*
 * SoundHound Inc. Programming Contest 2018 -Masters Tournament- B "Acrostic"
 *   https://soundhound2018-summer-qual.contest.atcoder.jp/tasks/soundhound2018_summer_qual_b/
 */
public class Main {

	public static void main(String[] args) {

		InputScanner in = new InputScanner(System.in);
		PrintWriter out = new PrintWriter(System.out);

		String[] S = in.nextStringArray("");
		int w = in.nextInt();

		for (int i = 0; i < S.length; i = i + w) {
			out.print(S[i]);
		}
		out.println();

		in.close();
		out.close();
	}

	/*
	 * extends java.util.Scanner
	 */
	static class InputScanner {

		Scanner scanner;

		public InputScanner(InputStream inputStream) {
			this.scanner = new Scanner(inputStream);
		}

		public int nextInt() {
			return scanner.nextInt();
		}

		public long nextLong() {
			return scanner.nextLong();
		}

		public double nextDouble() {
			return scanner.nextDouble();
		}
		public String next() {
			return scanner.next();
		}

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

		public int[][] nextIntArray(int h, int w) {
			int[][] ret = new int[h][w];
			for (int i = 0; i < h; i++) {
				for (int j = 0; j < w; j++) {
					ret[i][j] = scanner.nextInt();
				}
			}
			return ret;
		}

		public long[] nextLongArray(int n) {
			long[] ret = new long[n];
			for (int i = 0; i < n; i++) {
				ret[i] = scanner.nextLong();
			}
			return ret;
		}

		public long[][] nextlongArray(int h, int w) {
			long[][] ret = new long[h][w];
			for (int i = 0; i < h; i++) {
				for (int j = 0; j < w; j++) {
					ret[i][j] = scanner.nextLong();
				}
			}
			return ret;
		}

		public double[] nextDoubleArray(int n) {
			double[] ret = new double[n];
			for (int i = 0; i < n; i++) {
				ret[i] = scanner.nextDouble();
			}
			return ret;
		}

		public double[][] nextDoubleArray(int h, int w) {
			double[][] ret = new double[h][w];
			for (int i = 0; i < h; i++) {
				for (int j = 0; j < w; j++) {
					ret[i][j] = scanner.nextLong();
				}
			}
			return ret;
		}

		public String[] nextStringArray(int n) {
			String[] ret = new String[n];
			for (int i = 0; i < n; i++) {
				ret[i] = scanner.next();
			}
			return ret;
		}

		public String[] nextStringArray(String split) {
			String[] ret = scanner.next().split(split);
			return ret;
		}

		public String[][] nextStringArray(int h, int w) {
			String[][] ret = new String[h][w];
			for (int i = 0; i < h; i++) {
				for (int j = 0; j < w; j++) {
					ret[i][j] = scanner.next();
				}
			}
			return ret;
		}

		public String[][] nextStringArray(int h, String split) {
			String[][] ret = new String[h][];
			for (int i = 0; i < h; i++) {
				ret[i] = scanner.next().split(split);
			}
			return ret;
		}

		public void close() {
			scanner.close();
		}

	}

}


Measured memory_bytes: 22740
/*************************************************************************
Author: ziki
Created Time: 2012-10-5 14:09:43
File Name: aa.cpp
Description: 
************************************************************************/
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <queue>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <string.h>


using namespace std;

typedef long long int64;
typedef unsigned long long uint64;
#define two(X) (1<<(X))
#define twoL(X) (((int64)(1))<<(X))
#define contain(S,X) (((S)&two(X))!=0)
#define containL(S,X) (((S)&twoL(X))!=0)
const double pi=acos(-1.0);
const double eps=1e-11;
const int inf=0x7FFFFFFF;
template<class T> inline void checkmin(T &a,T b){if(b<a) a=b;}
template<class T> inline void checkmax(T &a,T b){if(b>a) a=b;}
template<class T> inline T sqr(T x){return x*x;}
typedef pair<int,int> ipair;
#define SIZE(A) ((int)A.size())
#define LENGTH(A) ((int)A.length())
#define MP(A,B) make_pair(A,B)
#define PB(X) push_back(X)
#define zero(a) memset(a, 0, sizeof(a))
#define out(x) (cout<<#x<<": "<<x<<endl)
template<class T>void show(T a, int n){for(int i=0; i<n; ++i) cout<<a[i]<<' '; cout<<endl;}
template<class T>void show(T a, int r, int l){for(int i=0; i<r; ++i)show(a[i],l);cout<<endl;}

struct S {
	int x,y, xx, yy;
	int idx;
	void in(int id) {
		scanf("%d%d%d%d",&x,&y,&xx,&yy);
		if(x>xx) swap(x,xx);
		if(y>yy) swap(y,yy);
		idx = id;
	}
	const bool operator<(const S & b) const {
		if(x!=b.x) return x<b.x;
		return y<b.y;
	}
}s[100];

vector<int> ans;
vector<S> ini;
bool vis[100];
int pos[100];

void dfs(vector<S> v) {
	//cout<<" In \n ";
	while(1) {
		if(v.size()==0)return;
		sort(v.begin(), v.end());
		vis[v[0].idx] = true;
		ans.PB(v[0].idx);
		pos[v[0].idx] = ans.size();
		//cout<<v[0].idx<<endl;
		vector<S> v2;
		int left = inf;
		for (int i=0; i<ini.size(); i++) {
	//		cout<<ini[i].yy<<' '<<ini[i].y<<' '<<ini[i].x<<endl;
			if( ini[i].yy > v[0].yy && ini[i].y < v[0].yy && ini[i].x >= v[0].xx ) checkmin(left, ini[i].x);
		}
		for (int i = 1; i<v.size(); i++) {
			if( v[i].yy <= v[0].yy && v[i].xx <= left) v2.PB(v[i]);
		}
	//	cout<<" Left "<<left<<endl;
		//for (int i=0; i<v2.size(); i++) cout<<v2[i].idx<<' '; cout<<endl;
		if(v2.size())
			dfs(v2);
		for (int i = v.size()-1; i>=0; i--) {
			if( vis[v[i].idx] ) 
				v.erase(v.begin()+i);
		}
	}
}
int main()
{
	int n, cas = 0;
	while(cin>>n && n) {
		for (int i=1; i<=n; i++) s[i-1].in(i);
		zero(vis);
		ans.clear();
		vector<S> v(s,s+n);
		ini = v;
		dfs(v);
		if(cas++)puts("");
		for (int i=1; i<=n; i++)
			cout<<pos[i]<<endl;
	}
	return 0;
}

Measured memory_bytes: 1276
n = int(input().strip())
a = list(map(int, input().strip().split()))
b=[0]*n
for i in range(0,n-1):
    b[i]=a[i+1]/a[i]
money=1000
for i in range(n):
    if b[i]>1:
        money=(money//a[i])*a[i+1]+(money%a[i])
print(money)

Measured memory_bytes: 9192
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <string>
#include <vector>
#include <algorithm>
#include <set>
#include <queue>
#include <deque>
using namespace std;

typedef long long ll;
typedef unsigned long long ull;

#define rep(i, up) for (ll i = 0; i < up; ++i)
#define repp(i, up) for (ll i = 0; i <= up; ++i)
#define rrep(i, lo, up) for (ll i = lo; i < up; ++i)
#define rrepp(i, lo, up) for (ll i = lo; i <= up; ++i)

#define rdi(i) ll i; scanf("%lld", &i)
#define rds(s) string s; cin >> s
#define rdc(c) char c; cin >> c

#define INF 10000000000
#define MOD 1000000007

ll gcd(ll a, ll b)
{
    if (a < b) {
        return gcd(b, a);
    }
    ll r;
    while (r = a % b) {
        a = b;
        b = r;
    }
    return b;
}

int main()
{
    string s;
    cin >> s;
    vector<ll> mods(s.size() + 1);
    ll l = s.size();
    mods[l] = 0;
    ll exp = 1;
    vector<ll> work(2019, 0);
    ++work[0];
    for (ll i = l - 1; i >= 0; --i) {
        mods[i] = (mods[i + 1] + exp * (s[i] - '0')) % 2019;
        exp = (exp * 10) % 2019;
        ++work[mods[i]];
    }
    ll result = 0;
    rep(i, 2019) {
        result += work[i] * (work[i] - 1) / 2;
    }
    cout << result << endl;
    return 0;
}

Measured memory_bytes: 4496
import java.util.*;
public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int C = sc.nextInt();
		int[][] tv = new int[C][200000];
		for(int i = 0; i < N; i++) {
			int s = sc.nextInt()-1;
			int t = sc.nextInt()-1;
			int c = sc.nextInt()-1;
			for(int j = s*2; j <= t*2; j++)
				tv[c][j] = 1;
		}
		for(int i = 0; i < C; i++)
			for(int j = 1; j < 200000; j++)
				if(tv[i][j] == 1 && tv[i][j-1] == 0)
					tv[i][j-1] = 1;
		int ans = 0;
		for(int j = 0; j < 200000; j++) {
			int temp = 0;
			for(int i = 0; i < C; i++)
				temp += tv[i][j];
			ans = Math.max(temp, ans);
		}
		System.out.println(ans);
	}

}

Measured memory_bytes: 122512
using System;
using System.Linq;

class aizu_judge
{
    static void Main()
    {
        int[] num = System.Console.ReadLine().Split().Select(int.Parse).ToArray();
        if(num[0] - num[4] >= num[2] 
            && num[2] - num[4] >= 0 
            && num[1] - num[4] >= num[3]
            && num[3] - num[4] >= 0)
        {
            Console.WriteLine("Yes");
        }
        else
        {
            Console.WriteLine("No");
        }

    }
}

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

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

  int c[n];
  int v = n + 1;
  for (int i=0; i<n; i++) {
    c[p[i]-1] = v;
    ++v;
  }
  int a[n], b[n];
  a[0] = 1;
  b[0] = c[0] - 1;
  for (int i=1; i<n; i++) {
    if (c[i] > c[i-1]) {
      b[i] = b[i-1] - 1;
      a[i] = c[i] - b[i];
    } else {
      a[i] = a[i-1] + 1;
      b[i] = c[i] - a[i];
    }
  }
  for (int i=0; i<n; i++) {
    cout<<a[i];
    if (i != n - 1) {
      cout<<" ";
    }
  }
  cout<<endl;
  int d = 0;
  if (b[n-1] <= 0) {
    d = -b[n-1] + 1;
  }
  for (int i=0; i<n; i++) {
    cout<<b[i] + d;
    if (i != n - 1) {
      cout<<" ";
    }
  }
  cout<<endl;
}

Measured memory_bytes: 896
function main()
  
  N = parse(Int,readline())
  S = split(chomp(readline()),"")
  
  if length(S) % 2 == 1
    println("No")
  elseif S[1:div(length(S),2)] == S[div(length(S),2)+1:end]
    println("Yes")
  else
    println("No")
  end
  
end

main()

Measured memory_bytes: 109720
#include <iostream>
#include <vector>
#include <stack>
#include <queue>

using namespace std;

bool ace11;
int total;

int hit(char card) {
    switch(card) {
    case 'T':
    case 'J':
    case 'Q':
    case 'K':
        return 10;
    case 'A':
        if (total <= 10) {
            ace11 = true;
            return 11;
        } else {
            return 1;
        }
    default:
        return (int)(card-'0');
    }
}

int main() {
    int n;
    cin >> n;
    for (int i = 0; i < n; i++) {
        queue<char> que;
        total = 0;
        ace11 = false;
        for (int j = 0; j < 10; j++) {
            char c;
            cin >> c;
            que.push(c);
        }
        for (int j = 0; j < 2; j++) {
            char card = que.front(); que.pop();
            total += hit(card);
        }
        if (total == 21) {
            cout << "blackjack" << endl;
            continue;
        }
        while(true){
            if (total > 17 || total == 17 && ace11 == false) {
                cout << total << endl;
                break;
            }
            char card = que.front(); que.pop();
            total += hit(card);
            if (total > 21) {
                if (ace11) {
                    total -= 10;
                    ace11 = false;
                } else {
                    cout << "bust" << endl;
                    break;
                }
            }
        }
    }
    return 0;
}

Measured memory_bytes: 1200
x, a, b = map(int, input().split())
if x < a and x < b:
    if a < b:
        print("A")
    else:
        print("B")
elif x > a and x > b:
    if a > b:
        print("A")
    else:
        print("B")
else:
    if abs(x - a) < abs(x - b):
        print("A")
    else:
        print("B")

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

int main () {
  int n;
  cin >> n;
  int a[n];
  for (int i = 0; i < n; i++) {
    cin >> a[i];
  }
  
  sort(a,a+n);
  int ans = 0;
  for (int i = 0; i < n-1; i++) {
    ans += a[i];
  }
  ans += a[n-1]/2;
  cout << ans << endl;
}

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

int main() {
	size_t c; cin >> c;
	deque<int> l(c);
	for (size_t i = 0; i < c; ++i)
		cin >> l.at(i);
	auto k = l;
	sort(k.begin(), k.end());
	for (int i = 0; i < c; ++i) {
		cout << ((l.at(i) == k.at(c-1)) ? k.at(c-2) : k.at(c-1)) << endl;
	}
}

Measured memory_bytes: 3200
import sys
def input(): return sys.stdin.readline().rstrip()

def main():
    N = int(input())

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

    ans = []
    while N != 0:
        r = N % 2
        if r < 0:
            r += 2
        ans.append(r)
        N -= r
        N //= -2
    print("".join(map(str, ans[::-1])))

if __name__ == '__main__':
    main()


Measured memory_bytes: 3060
#include <iostream>
#include <vector>
#include <array>
#include <list>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <string>
#include <sstream>
#include <algorithm>
#include <random>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <cmath>
#include <cassert>
#include <climits>
#include <bitset>
#include <functional>
#include <iomanip>
#include <random>

#define FOR_LT(i, beg, end) for (int i = (int)(beg); i < (int)(end); i++)
#define FOR_LE(i, beg, end) for (int i = (int)(beg); i <= (int)(end); i++)
#define FOR_DW(i, beg, end) for (int i = (int)(beg); (int)(end) <= i; i--)
#define REP(n)              for (int repeat_index = 0; repeat_index < (int)n; repeat_index++)


using namespace std;

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout << fixed << setprecision(20);

	int n; cin >> n;
	int64_t ans = 0;
	FOR_LE(i, 1, n) {
		if (i % 3 != 0 && i % 5 != 0) {
			ans += i;
		}
	}
	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 3640
#include <iostream>
#include <string>
#include <queue>
#include <stack>
#include <algorithm>
#include <list>
#include <vector>
#include <complex>
#include <utility>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <climits>
#include <bitset>
#include <ctime>
#include <map>
#include <unordered_map>
#include <set>
#include <unordered_set>
#include <cassert>
#include <cstddef>
#include <iomanip>
#include <numeric>
#include <tuple>
#include <sstream>
#include <fstream>

using namespace std;
#define REP(i, n) for (int (i) = 0; (i) < (n); (i)++)
#define FOR(i, a, b) for (int (i) = (a); (i) < (b); (i)++)
#define RREP(i, a) for(int (i) = (a) - 1; (i) >= 0; (i)--)
#define FORR(i, a, b) for(int (i) = (a) - 1; (i) >= (b); (i)--)
#define DEBUG(C) cerr << #C << " = " << C << endl;
using LL = long long;
using VI = vector<int>;
using VVI = vector<VI>;
using VL = vector<LL>;
using VVL = vector<VL>;
using VD = vector<double>;
using VVD = vector<VD>;
using PII = pair<int, int>;
using PDD = pair<double, double>;
using PLL = pair<LL, LL>;
using VPII = vector<PII>;
template<typename T> using VT = vector<T>;
#define ALL(a) begin((a)), end((a))
#define RALL(a) rbegin((a)), rend((a))
#define SORT(a) sort(ALL((a)))
#define RSORT(a) sort(RALL((a)))
#define REVERSE(a) reverse(ALL((a)))
#define MP make_pair
#define FORE(a, b) for (auto &&a : (b))
#define FIND(s, e) ((s).find(e) != (s).end())
#define EB emplace_back
template<typename T> inline bool chmax(T &a, T b){if (a < b){a = b;return true;}return false;}
template<typename T> inline bool chmin(T &a, T b){if (a > b){a = b;return true;}return false;}

const int INF = 1e9;
const int MOD = INF + 7;
const LL LLINF = 1e18;
const long double EPS = 1e-9;

const int MAX = 50;
int N, Ma, Mb;
int a[MAX], b[MAX], c[MAX];
int dp[1000][1000], _dp[1000][1000];

int main(void) {
    scanf("%d%d%d", &N, &Ma, &Mb);
    REP(i, N) {
        scanf("%d%d%d", a + i, b + i, c + i);
    }
    REP(j, 1000) REP(k, 1000) {
        dp[j][k] = INF;
        _dp[j][k] = INF;
    }
    dp[0][0] = 0;
    REP(i, N) {
        REP(j, 1000) REP(k, 1000) _dp[j][k] = INF;
        REP(j, 1000) REP(k, 1000) {
            chmin(_dp[j][k], dp[j][k]);
            if (a[i] + j < 1000 && b[i] + k < 1000) {
                chmin(_dp[a[i] + j][b[i] + k], dp[j][k] + c[i]);
            }
        }
        REP(j, 1000) REP(k, 1000) dp[j][k] = _dp[j][k];
    }
    int ma = Ma, mb = Mb;
    int ans = INF;
    while (ma < 1000 && mb < 1000) {
        chmin(ans, dp[ma][mb]);
        ma += Ma; mb += Mb;
    }
    if (ans == INF) ans = -1;
    cout << ans << endl;
}


Measured memory_bytes: 8064
#include <bits/stdc++.h>
#define int long long
#define lint long long
#define pii pair<int,int>
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(c) (c).begin(),(c).end()
#define ZERO(a) memset(a,0,sizeof(a))
#define MINUS(a) memset(a,0xff,sizeof(a))
#define MINF(a) memset(a,0x3f,sizeof(a))
#define POW(n) (1LL<<(n))
#define IN(i,a,b) (a <= i && i <= b)
using namespace std;
template <typename T> inline bool CHMIN(T& a,T b) { if(a>b) { a=b; return 1; } return 0; }
template <typename T> inline bool CHMAX(T& a,T b) { if(a<b) { a=b; return 1; } return 0; }
template <typename T> inline void SORT(T& a) { sort(ALL(a)); }
template <typename T> inline void REV(T& a) { reverse(ALL(a)); }
template <typename T> inline void UNI(T& a) { sort(ALL(a)); a.erase(unique(ALL(a)),a.end()); }
template <typename T> inline T LB(vector<T>& v, T a) { return *lower_bound(ALL(v),a); }
template <typename T> inline int LBP(vector<T>& v, T a) { return lower_bound(ALL(v),a) - v.begin(); }
template <typename T> inline T UB(vector<T>& v, T a) { return *upper_bound(ALL(v),a); }
template <typename T> inline int UBP(vector<T>& v, T a) { return upper_bound(ALL(v),a) - v.begin(); }
template <typename T1, typename T2> ostream& operator<< (ostream& os, const pair<T1,T2>& p) { os << p.first << " " << p.second; return os; }
template <typename T1, typename T2> istream& operator>> (istream& is, pair<T1,T2>& p) { is >> p.first >> p.second; return is; }
template <typename T> ostream& operator<< (ostream& os, const vector<T>& v) { REP(i,v.size()) { if (i) os << " "; os << v[i]; } return os; }
template <typename T> istream& operator>> (istream& is, vector<T>& v) { for(T& in : v) is >> in; return is; }
template <typename T = int> vector<T> make_v(size_t a) { return vector<T>(a); }
template <typename T, typename... Ts> auto make_v(size_t a, Ts... ts) { return vector<decltype(make_v<T>(ts...))>(a,make_v<T>(ts...)); }
template <typename T, typename V> typename enable_if<is_class<T>::value == 0>::type fill_v(T &t, const V &v) { t = v; }
template <typename T, typename V> typename enable_if<is_class<T>::value != 0>::type fill_v(T &t, const V &v) { for(auto &e : t) fill_v(e,v); }
const lint MOD = 1000000007;
const lint INF = 0x3f3f3f3f3f3f3f3f;
const double EPS = 1e-10;

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

    int M, D;
    cin >> M >> D;
    int ans = 0;
    for (int i = 1; i <= M; i++) {
        for (int j = 1; j <= D; j++) {
            int a = j / 10;
            int b = j % 10;
            if (a >= 2 && b >= 2 && a * b == i) {
                ans++;
            }
        }
    }
    cout << ans << endl;

    return 0;
}

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

#define rep(i, n) for (int i = 0; i < int(n); i++)
#define rrep(i, n) for (int i = int(n) - 1; i >= 0; i--)
#define reps(i, n) for (int i = 1; i <= int(n); i++)
#define rreps(i, n) for (int i = int(n); i >= 1; i--)
#define repi(i, a, b) for (int i = int(a); i < int(b); i++)
#define each(x, y) for (auto &x : y)
#define all(a) (a).begin(), (a).end()
#define bit(b) (1ll << (b))
#define uniq(v) (v).erase(unique(all(v)), (v).end())
#define rsort(v) sort(all(v)); reverse(all(v))

using namespace std;

using i32 = int;
using i64 = long long;
using f80 = long double;
using vi32 = vector<i32>;
using vi64 = vector<i64>;
using vf80 = vector<f80>;
using vstr = vector<string>;

inline void yes() { cout << "Yes" << '\n'; exit(0); }
inline void no() { cout << "No" << '\n'; exit(0); }
inline i64 gcd(i64 a, i64 b) { if (min(a, b) == 0) return max(a, b); if (a % b == 0) return b; return gcd(b, a % b); }
inline i64 lcm(i64 a, i64 b) { return a / gcd(a, b) * b; }
void solve(); int main() { ios::sync_with_stdio(0); cin.tie(0); cout << fixed << setprecision(16); solve(); return 0; }
template<typename T> class pqasc : public priority_queue<T, vector<T>, greater<T>> {};
template<typename T> class pqdesc : public priority_queue<T, vector<T>, less<T>> {};
template<typename T> inline void amax(T &x, T y) { if (x < y) x = y; }
template<typename T> inline void amin(T &x, T y) { if (x > y) x = y; }
template<typename T> inline T power(T x, i64 n) { T r = 1; while (n > 0) { if (n & 1) r *= x; x *= x; n >>= 1; } return r; }
template<typename T> istream& operator>>(istream &is, vector<T> &v) { for (auto &x : v) is >> x; return is; }
template<typename T> ostream& operator<<(ostream &os, const vector<T> &v) { rep(i, v.size()) { if (i) os << ' '; os << v[i]; } return os; }

void solve() {
  int N; cin >> N;
  vi32 a(N); cin >> a;
  int cnt1 = 0, cnt4 = 0;
  rep(i, N) {
    if (a[i] % 2 == 1) cnt1++;
    if (a[i] % 4 == 0) cnt4++;
  }
  if (cnt1 > cnt4 + 1) no();
  if (cnt1 == cnt4 + 1 && N > cnt1 + cnt4) no();
  yes();
}


Measured memory_bytes: 640
n=int(input())
if 400<=n<=599:
    print(8)
elif 600<=n<=799:
    print(7)
elif 800 <= n <= 999:
    print(6)
elif 1000<=n<=1199:
    print(5)
elif 1200<=n<=1399:
    print(4)
elif 1400<=n<=1599:
    print(3)
elif 1600<=n<=1799:
    print(2)
else:
    print(1)


Measured memory_bytes: 61632
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<climits>
#include<iostream>
#include<sstream>
#include<utility>
#include<map>
#include<vector>
#include<queue>
#include<algorithm>
#include<set>
#include<stack>
using namespace std;
typedef long long ll;
typedef pair<int,int>P;
const ll MOD=1000000007;

int main()
{
	ll N,M,a=1,b=1;
	cin>>N>>M;
	if(abs(N-M)>1)puts("0");
	else
	{
		for(int i=1;i<=N;i++)a=(a*i)%MOD;
		for(int i=1;i<=M;i++)b=(b*i)%MOD;
		cout<<a*b*(N==M?2:1)%MOD<<endl;
	}
}


Measured memory_bytes: 256
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cstring>
#include <string>
#include <iostream>
#include <algorithm>
#include <queue>
#include <map>

using namespace std;

typedef long long ll;
const int Maxn = 1e9 + 10;
const int N = 1e5 + 10;
const int INF=(0x7fffffff)/2;
int a[2][110], b[110];

int main(){
	int n;
	while(cin >> n){
		memset(b, 0, sizeof(b));
		for(int i = 0; i < 2; i++)
			for(int j = 0; j < n; j++)
				cin >> a[i][j];
		int sum = a[0][0];
		for(int k = 0; k < n; k++){
			for(int j = 0; j < n - k; j++){
				b[k] += a[0][j];
			}
	//		printf("%d  ", b[k]);
		}
	//	printf("\n");
		for(int k = 0; k < n; k++){
			for(int j = n - 1; j >= n - k - 1; j--){
				b[k] += a[1][j];
			}
	//		printf("%d  ", b[k]);
		}
	//	printf("\n");
		sort(b, b + n);
		printf("%d\n", b[n - 1]);
	}
}

Measured memory_bytes: 256
//c++ -std=gnu++14 a.cpp
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <iostream>
#include <istream>
#include <iterator>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
#include <tuple>
#include <iomanip>
#include <climits>
#include <fstream>
#include <random>
using namespace std;

typedef long long ll;
typedef unsigned long long ull;
//typedef pair<ll, ll> P;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define revrep(i, n) for(int i = (n)-1; i >= 0; i--)
#define pb push_back
#define f first
#define s second
#define chmin(x, y) x = min(x, y);
#define chmax(x, y) x = max(x, y);
#define len(x) ((int)(x).size())

//const ll INFL = LLONG_MAX;//10^18 = 2^60
const ll INFL = 1LL<<60;
//const int INF = INT_MAX;
const int INF = 1 << 30;//10^9
const ll MOD = 1000000007;
//const ll MOD = 998244353;
double EPS = 1e-10;

vector<ll> dy = {0, 1, 0, -1, 1, 1, -1, -1, 0};
vector<ll> dx = {1, 0, -1, 0, 1, -1, 1, -1, 0};

void pres(double A){printf("%.9lf\n", A);}
void BinarySay(ll x, ll y = 60){rep(i, y) cout << (x>>(y-1-i) & 1); cout << endl;}
ll cnt_bit(ll x){return __builtin_popcountll(x);}

ll pow_long(ll x, ll k){
  ll res = 1;
  while(k > 0){
    if(k % 2) res *= x;
    x *= x; k /= 2;
  }
  return res;
}

ll pow_mod(ll x, ll k){
  ll res = 1;
  while(k > 0){
    if(k % 2){
      res *= x; res %= MOD;
    }
    x *= x; x %= MOD;
    k /= 2;
  }
  return res;
}

ll inverse(ll x){return pow_mod(x, MOD - 2);};

ll gcd(ll a, ll b){
    if(b == 0) return a;
    return gcd(b, a % b);
}

ll lcm(ll x, ll y){
  ll res = x / gcd(x, y);
  res *= y;
  return res;
};


//コンビネーション
const int MAXcomb = 2000010;
ll fac[MAXcomb], finv[MAXcomb], inv[MAXcomb];
//facはn!,finvは1/n!
//invは逆元
void COMinit(){
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for(int i = 2; i < MAXcomb; 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;
    }
}
ll comb(int n, int k){
    if(n < k) return 0;
    if(n < 0 || k < 0) return 0;
    return fac[n] * finv[k] % MOD * finv[n-k] % MOD;
}


ll disit(ll s, ll base = 10){
  ll res = 0;
  while(s){
    res++;
    s /= base;
  }
  return res;
}


void solve(){
  ll A, B, C;
  cin >> A >> B >> C;
  ll K;
  cin >> K;
  ll need = 0;
  while(B <= A){
    B *= 2;
    need++;
  }
  while(C <= B){
    C *= 2;
    need++;
  }
  if(need <= K){
    cout << "Yes" << endl;
  }else{
    cout << "No" << endl;
  }

}

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


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

public class Main {
    static BufferedReader br = new BufferedReader(new InputStreamReader(System.in), 32768);
    static PrintWriter out = new PrintWriter(System.out);
    static StringTokenizer t;

    static String sn() {
        while (t == null || !t.hasMoreTokens()) {
            try {
                t = new StringTokenizer(br.readLine());
            } catch (IOException e) {
                throw new RuntimeException();
            }
        }
        return t.nextToken();
    }

    static int ni() {
        return Integer.parseInt(sn());
    }

    static long nlo() {
        return Long.parseLong(sn());
    }

    public static void main(String args[]) {
        int t = 1;//ni();
        while (t-- > 0) {
            solve();
        }
        out.close();
    }

    static long mod = 998244353;

    static long pro(long a, long b) {
        return (a % mod * b % mod) % mod;
    }

    static long add(long a, long b) {
        return (a + b) % mod;
    }

    static int maxn = 200005;

    static class pair implements Comparable<pair> {
        int id;
        String s;
        int sc;

        pair(int a, String b, int c) {
            id = a;
            s = b;
            sc = c;
        }

        public int compareTo(pair a) {
            if (!this.s.equals(a.s))
                return this.s.compareTo(a.s);
            return a.sc - this.sc;
        }
    }

    static void solve() {
        int n = ni();
        pair d[] = new pair[n];
        for (int i = 0; i < n; i++) {
            String s = sn();
            int p = ni();
            d[i] = new pair(i, s, p);
        }
        Arrays.sort(d);
        for (pair h : d)
            out.println(h.id+1);
    }
}

Measured memory_bytes: 21076
using System;
using System.Collections.Generic;
using System.Windows;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Atcoder
{
    public class Program
    {
        static void Main(string[] args)
        {
            var L = Console.ReadLine();

            var a = L.ToDecimal() / 3;

            var ans = a * a * a;

            Console.WriteLine(ans);
            Console.ReadLine();
        }
    }
}

public static class Extentions
{
    public static int ToInt(this object obj)
    {
        return int.Parse(obj.ToString());
    }

    public static decimal ToDecimal(this object obj)
    {
        return decimal.Parse(obj.ToString());
    }

    public static double ToDouble(this object obj)
    {
        return double.Parse(obj.ToString());
    }
}



Measured memory_bytes: 11220
#include<iostream>
#include<map>
#include<vector>
#include<list>
#include<algorithm>
#include<cmath>
#include<iomanip>
#include<numeric>
#include<climits>
#include<ctime>
#include<cstring>
#define REP(i,p,n) for(int i=p;i<(int)(n);i++)
#define rep(i,n) REP(i,0,n)
#define rep_split(tok,a_str,re) for(char *tok = strtok((char *)a_str.c_str(),re); tok != NULL; tok = strtok(NULL,re))
#define all(c) (c).begin(), (c).end()

using namespace std;
template<class T> inline void chmax(T& a, T b) { if(b > a) a = b; }
template<class T> inline void chmin(T& a, T b) { if(b < a) a = b; }

int stones[51];

int main() {
	int N,P;
	while(true) {
		cin >> N >> P;

		int wan = P;
		if (N == 0 && P == 0) { break; }
		rep(i,N) {
			stones[i] = 0;
		}

		int i = 0;
		while(true) {
			if (i >= N) { i = 0; }
			if (wan > 0) {
				wan--;
				stones[i]++;
			}
			else { //空なら
				wan = stones[i];
				stones[i] = 0;
			}
			//cout << i << ": " << stones[i] << " | ";
			if (stones[i] >= P) { 
				//cout << endl;
				cout << i << endl;
				break; 
			} 
			i++;
		}

	}

	return 0;
}

Measured memory_bytes: 1156
import math


def read_int():
    return int(input().strip())


def read_ints():
    return list(map(int, input().strip().split(' ')))


def solve():
    N, K = read_ints()
    A = read_ints()
    if K > max(A):
        return 'IMPOSSIBLE'
    gcd = A[0]
    for i in range(1, N):
        gcd = math.gcd(gcd, A[i])
    if K%gcd != 0:
        return 'IMPOSSIBLE'
    return 'POSSIBLE'


if __name__ == '__main__':
    print(solve())


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


using namespace std;

int main(){
  long long N, K;
  string S;
  cin >> N >> K;
  cin >> S;
  char lastchar;
  long long renzoku=0;
  vector<long long> v;
  vector<long long> sums;
  long long sum=0;
  long long ans=0;
  if(S[0] == '0'){
    lastchar='0';
    v.push_back(0);
  }
  else lastchar='1';

  for(long long i=0; S[i] != '\0'; i++){
    if(S[i] == lastchar){
      renzoku++;
    }
    else{
      v.push_back(renzoku);
      renzoku=1;
      lastchar=S[i];
    }
  }
  v.push_back(renzoku);
  if(v.size()%2==0) v.push_back(0);
  if((v.size())/2 <= K){
    cout << N << endl;
    return 0;
  }
  for(auto x: v){
    sum += x;
    sums.push_back(sum);
  }

  long long vsize=sums.size();
  for(long long i=0; i < vsize-2*K; i+=2){
    if(i==0){
      ans = max(ans, sums[i+2*K]);
      continue;
    }
    ans = max(ans, sums[i+2*K]-sums[i-1]);
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 2676
n = int(input())
mount = [0]*n
a = list(map(int, input().split()))
b = list(map(int, input().split()))
mount[0] = a[0]
mount[-1] = b[-1]
pat = 1
mod = 10**9+7
for i in range(1,n):
  if a[i] > a[i-1]:
    if mount[i] != 0 and mount[i] != a[i]:
      print(0)
      exit()
    else:
      mount[i] = a[i]
  if b[n-i-1] > b[n-i]:
    if mount[n-i-1] != 0 and mount[n-i-1] != b[n-i-1]:
      print(0)
      exit()
    else:
      mount[n-i-1] = b[n-i-1]
for i in range(n):
  if mount[i] == 0:
    dx = 1
    while mount[i+dx] == 0:
      dx += 1
    this = min(mount[i-1],mount[i+dx])
    pat = pat*(this**dx)%mod
    for j in range(dx):
      mount[i+j] = this
a2 = [0]*n
b2 = [0]*n
a2[0] = mount[0]
b2[-1] = mount[-1]
for i in range(1,n):
  a2[i] = max(mount[i],a2[i-1])
  b2[n-i-1] = max(mount[n-i-1],b2[n-i])
if a != a2 or b != b2:
  print(0)
else:
  print(pat)

Measured memory_bytes: 19520
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10**6)


def dfs(cur, par):
    for child in edge[cur]:
        if child == par:
            continue
        counter[child] += counter[cur]
        dfs(child, cur)


N, Q = map(int, input().split())
ab = [list(map(int, input().split())) for _ in range(N-1)]
px = [list(map(int, input().split())) for _ in range(Q)]
counter = [0] * N

edge = [[] for _ in range(N)]
for i in range(N-1):
    a = ab[i][0] - 1
    b = ab[i][1] - 1
    edge[a].append(b)
    edge[b].append(a)

for i in range(Q):
    p = px[i][0] - 1
    x = px[i][1]
    counter[p] += x


dfs(0, -1)
print(*counter)


Measured memory_bytes: 312768
#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#include <vector>
#include <queue>
#include <stack>
#include <cmath>
#include <map>
#include <cstdlib>
using namespace std;
using ll = long long int;
int INF = 1e9+7;

int main() {
    int N;
    string A,B,C;
    cin >> N;
    cin >> A >> B >> C;
    int total = 0;
    for (int i = 0; i < N ;i++) {
        if (A[i] == B[i] && B[i] == C[i] && C[i] == A[i]) continue;
        if (A[i] == B[i] || B[i] == C[i] || C[i] == A[i]) total += 1;
        else total += 2;
    }
    cout << total;
}


Measured memory_bytes: 256
#coding:utf-8
import sys,os
sys.setrecursionlimit(10**6)
write = sys.stdout.write
dbg = (lambda *something: print(*something)) if 'TERM_PROGRAM' in os.environ else lambda *x: 0
def main(given=sys.stdin.readline):
    input = lambda: given().rstrip()
    LMIIS = lambda: list(map(int,input().split()))
    II = lambda: int(input())
    XLMIIS = lambda x: [LMIIS() for _ in range(x)]
    YN = lambda c : print('Yes') if c else print('No')
    MOD = 10**9+7

    n,a,b = LMIIS()
    def cmb(n,r):
        if r == 0:
            return 0
        res = 1
        r = min(r,n-r)
        for i in range(n-r+1,n+1):
            res *= i
            res %= MOD
        for i in range(1,r+1):
            res *= pow(i,(MOD-2),MOD)
            res %= MOD
        return res
    print((pow(2,n,MOD)-cmb(n,a)-cmb(n,b)-1)%MOD)

    
if __name__ == '__main__':
    main()

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

int main()
{
  int n;
  cin >> n;
  for (int i = 1; i <= n; i++) {
    int ans = 0;
    for (int x = 1; x <= 100; x++) {
      if (x * x > i) break;
      for (int y = 1; y <= 100; y++) {
        if (y * y > i) break;
        for (int z = 1; z <= 100; z++) {
          if (z * z > i) break;
          int k = x*x + y*y + z*z + x*y + y*z + z*x;
          if (k > i) break;
          if (k == i) ans++;
        }
      }
    }
    cout << ans << endl;
  }
}


Measured memory_bytes: 3608
from collections import Counter

n = int(input())
d = list(map(int, input().split()))
mod = 998244353
if d[0] != 0 or 0 in d[1:]:
    print(0)
else:
    c = Counter(d)
    ans = 1
    for i in range(1, len(c)):
        ans *= c[i-1] ** c[i]
        ans %= mod
    print(ans % mod)


Measured memory_bytes: 19936
#include <bits/stdc++.h>
#define REP(i,n) for (int i=0;i<(n);i++)
#define ALL(a) (a).begin(),(a).end()
#define RFOR(i,a,b) for (int i=(b)-1;i>=(a);i--)
#define REP(i,n) for (int i=0;i<(n);i++)
#define RREP(i,n) for (int i=(n)-1;i>=0;i--)
#define ll long long
#define ull unsigned long long
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};

using namespace std;

int main(){

  int n,w;

  cin >> n >> w;
  vector<vector<int>> dp(n+1,vector<int>(w+1,0));
  vector<pair<int,int>> nap(n);
  REP(i,n)cin >> nap[i].first >> nap[i].second;
  
  for(int i=1;i<n+1;i++)
    REP(j,w+1){
      if(j-nap[i-1].second>=0){
	dp[i][j] = max(dp[i][j-nap[i-1].second]+nap[i-1].first,dp[i-1][j]);
      }else{
	dp[i][j] = dp[i-1][j];
      }
    }
  /*    REP(i,n+1){
    REP(j,w+1)
      cout << dp[i][j] << " ";
    cout << endl;
    }*/
  cout << dp[n][w] << endl;
		 
  return 0;
}

Measured memory_bytes: 6820
#include<iostream>
#include<string>
#include<cstdio>
#include<algorithm>
#include<cstdlib>
#include<cmath>
#include<vector>
#include<utility>
#include<queue>
#include<stack>
#include<set>
#include<map>
#include<unordered_set>
#include<unordered_map>
#include<bitset>
using namespace std;

signed main() {
	int year, month, day;
	char su1, su2;
	cin >> year >> su1 >> month >> su2 >> day;
	if (month <= 4) cout << "Heisei" << endl;
	else cout << "TBD" << endl;
}

Measured memory_bytes: 256
N=gets.to_i

h = {}
(N-1).times do
    a,b,c = gets.split.map(&:to_i)
    h[a] ||= []
    h[a] << [a,b,c]
    h[b] ||= []
    h[b] << [b,a,c]
end

Q,K = gets.split.map(&:to_i)

arr = Array.new(N+1,-1)
arr[K] = 0
q = h[K]

until q.empty?
    parent,child,d = q.shift
    next if arr[child] != -1

    arr[child] = arr[parent] + d

    q.concat h[child]
end

Q.times do
    x,y = gets.split.map(&:to_i)
    puts arr[x]+arr[y]
end

Measured memory_bytes: 40016
#include <iostream>
#include <string>
#include <vector>
#include <utility>
#include <functional>
#include <numeric>
#include <list>
#include <set>
#include <map>
#include <algorithm>
#include <cmath>
#include <limits>
#include <iomanip>
#include <bitset>
#include <queue>
#include <unordered_set>
#include <unordered_map>

using namespace std;
typedef long long ll;
typedef pair<int,int> pii;

#define rep(i, n) for(int i = 0;i < n;i++)
const int INF = 1LL << 30;
const int MOD = 1000000007;


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

    int k,x; cin >> k >> x;

    if(k*500 >= x) cout << "Yes" << endl;
    else cout << "No" << endl;

    
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#pragma GCC optimize("O3")
#define REP(i,n) for(int i=0;i<n;i++)
#define REPP(i,n) for(int i=1;i<=n;i++)
#define ALL(obj) (obj).begin(), (obj).end()
#define EPS (1e-9)
#define INF (1e17)
#define PI (acos(-1))
//const double PI = acos(-1);
//const double EPS = 1e-15;
//long long INF=(long long)1E17;
#define i_7 (long long)(1e9+7)
//#define i_7 998'244'353
long mod(long a){
    long long c=a%i_7;
    if(c>=0)return c;
    return c+i_7;
}
using namespace std;

bool prime_(int n){
  if(n==1){
    return false;
  }else if(n==2){
    return true;
  }else{
    for(int i=2;i<=sqrt(n);i++){
      if(n%i==0){
        return false;
      }
    }
    return true;
  }
}

long long gcd_(long long a, long long b){
  if(a<b){
    swap(a,b);
  }
  if(a%b==0){
    return b;
  }else{
    return gcd_(b,a%b);
  }
}
 
long long lcm_(long long x, long long y){
  return (x/gcd_(x,y))*y;
}

int main(){
  
  int a,b;
  cin>>a>>b;
  if(a>9 || b>9){
    cout<<-1<<endl;
    return 0;
  }
  cout<<a*b<<endl;
  return 0;
}


Measured memory_bytes: 256