akhauriyash/Code-Regression huggingface dataset:
class BIT:
  def __init__(s, n):
    s._n = n
    s.data = [0] * n
  def set(s, L):
    for i in range(len(L)):
      s.add(i, L[i])
  def add(s, p, x):
    p += 1
    while p <= s._n:
      s.data[p - 1] += x
      p += p & -p
  def sum(s, l, r):
    return s.zum(r) - s.zum(l)
  def zum(s, r):
    ans = 0
    while r > 0:
      ans += s.data[r - 1]
      r -= r & -r
    return ans

N, Q = list(map(int, input().split()))
a = list(map(int, input().split()))
Query = [list(map(int, input().split())) for _ in range(Q)]
  
bit = BIT(N)
bit.set(a)
 
for q in Query:
  if q[0] == 0:
    _, p, x = q
    bit.add(p, x)
  else:
    _, l, r = q
    print(bit.zum(r) - bit.zum(l))


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

using namespace std;

long long n, m, l;
string s1, s2;
map<int, char> x;

int gcd(int a, int b){
    while(b){
        a %= b;
        swap(a, b);
    }
    return a;
}

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

int main() {

    cin >> n >> m >> s1 >> s2;

        l = lcm(n, m);

    for(int i = 0; i < s1.size(); ++i){
        x[i * l / n + 1] = s1[i];
    }

    for(int i = 0; i < s2.size(); ++i){
        if(x[i * l / m + 1] != 0 && x[i * l / m + 1] != s2[i]) {cout << -1; return 0;}
    }

    cout << l;

    return 0;

}


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

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

typedef long long ll;

const int INF=1e9+7;

int main(){
	int odd=0,even=0;
	int n;
	cin>>n;
	rep(i,n){
		int a;
		cin>>a;
		if(a%2==0)even++;
		else odd++;
	}
	if(odd%2==1)cout<<"NO"<<endl;
	else cout<<"YES"<<endl;
}


Measured memory_bytes: 256
#unionfind木_集合の管理_同じ集合の数を数える場合：
#parには集合の数と親の名前を同時にメモ化する（根なら-size, 子なら親）
def find(k):#要素k
    if par[k] < 0:#初期はparがすべて負の値
        return k
    else:
        par[k] = find(par[k])
        return par[k]

def unite(i, j):
    i = find(i)
    j = find(j)
    if i==j:#すでに同じ集合
        return False
    else:
        #sizeが大きい方がi
        if i > j:#sizeはマイナス管理なので、i>jの時jの方がサイズが大きい
            i, j = j, i
        par[i] += par[j] #親は負の値で大きくなる
        par[j] = i
        return True

def size(x):
    return -par[find(x)]

n, m = map(int, input().split())

par = [-1]*n#初めは自分自身が親

for i in range(m):
    a, b = map(lambda x:int(x)-1, input().split())
    unite(a, b)

ans = 0
for i in range(n):
    if -par[i]>0:
        ans += 1
print(ans-1)



Measured memory_bytes: 74560
#include <stdio.h>
#include <stdlib.h>

int c(const void* t, const void* u) {
	int v = *(const int*)t;
	int w = *(const int*)u;
	if (v > w) return 1;
	if (v < w) return -1;
	return 0;
}

int n;
int a[1000];

int main(void) {
	int i;
	int r;
	while (scanf("%d", &n) == 1 && n > 0) {
		for (i = 0; i < n; i++) {
			if (scanf("%d", &a[i]) != 1) return 1;
		}
		qsort(a, n, sizeof(*a), c);
		r = a[1] - a[0];
		for (i = 2; i < n; i++) {
			if (a[i] - a[i - 1] < r) r = a[i] - a[i - 1];
		}
		printf("%d\n", r);
	}
	return 0;
}

Measured memory_bytes: 648
a,b,c,x = Array.new(4){|i| gets.chomp.to_i}

count = 0
for i in 0..a
    for j in 0..b do
        for k in 0..c do
            d = 500 * i + 100 * j + 50 * k
            count += 1 if d == x
        end
    end
end

puts count

Measured memory_bytes: 1788
#include <iostream>
#include <string>
#include <cmath>
#include <algorithm>
 
using namespace std;
 
int main(){
    int n;
    cin >> n;
    string s;
    cin >> s;
    long r_num = 0;
    long g_num = 0;
    long b_num = 0;
    for (int i=0; i<n; i++){
        if (s[i]=='R'){
            r_num += 1;
        }
        else if (s[i]=='G'){
            g_num += 1;
        }
        else if (s[i]=='B'){
            b_num += 1;
        }
    }
    long sum = 0;
    for (int i=0; i<b_num; i++){
        sum += r_num * g_num;
    }
    for (int i=0; i<n-2; i++){
        for(int j=i+1; j<n-1; j++){
            if (n > 2*j-i){
                if (s[i]!=s[j] && s[j]!=s[2*j-i] && s[i]!=s[2*j-i]){
                    sum -= 1;
                }
            }
        }
    }
    if (n<=3){
        sum = 0;
    }
    cout << sum << endl;
}

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

using ll = long long;
using Pi = pair<int, int>;
using Pl = pair<ll, ll>;
using vint = vector<int>;
using vvint = vector<vint>;
using vvvint = vector<vvint>;
using vdouble = vector<double>;
using vvdouble = vector<vdouble>;
using vvvdouble = vector<vvdouble>;
using vll = vector<ll>;
using vvll = vector<vll>;
using vvvll = vector<vvll>;
using uint = unsigned int;
using ull = unsigned long long;

template<typename T> using uset = unordered_set<T>;
template<typename T1, typename T2> using umap = unordered_map<T1, T2>;

constexpr int INF = (1 << 30) - 1;
constexpr ll LLINF = 1LL << 60;
constexpr int dy[] = {1, 0, -1, 0, 1, -1, -1, 1};
constexpr int dx[] = {0, 1, 0, -1, 1, 1, -1, -1};
constexpr char el = '\n';
constexpr int mod = 1000000007;
constexpr int mod2 = 998244353;
template<typename T> T gcd(T a, T b) { return (b ? gcd(b, a % b) : a); }
template<typename T> T lcm(T a, T b) { return (a / gcd(a, b) * b); }
template<typename T1, typename T2>
inline bool chmin(T1 &a, T2 b) { return (a > b && (a = b, true)); }
template<typename T1, typename T2>
inline bool chmax(T1 &a, T2 b) { return (a < b && (a = b, true)); }

template<typename T>
vector<T> makeVector(size_t a, T b) { return (vector<T>(a, b)); }
template<typename... Ts>
auto makeVector(size_t a, Ts... ts) { 
	return (vector<decltype(makeVector(ts...))>(a, makeVector(ts...)));
}

template<typename T>
bool isin(T y, T x, T h, T w) { return (0 <= y && 0 <= x && y < h && x < w); }
template<typename T>
bool isin1(T y, T x, T h, T w) { return (0 < y && 0 < x && y <= h && x <= w); }

template<typename T>
ostream& operator <<(ostream &os, vector<T> &v) {
	if (v.size()) {
		os << v[0];
		for (int i = 1; i < v.size(); i++) os << " " << v[i];
	}
	return (os);
}

template<typename T>
istream& operator >>(istream &is, vector<T> &v) {
	for (auto &u : v) is >> u;
	return (is);
}

template<typename T1, typename T2>
istream& operator >>(istream &is, pair<T1, T2> &p) {
	return (is >> p.first >> p.second);
}


void Main() {
	int H, W, K; cin >> H >> W >> K;
	vector<string> S(H); cin >> S;
	int ans = 0;
	for (int br = 0; br < (1<<H); br++) {
		for (int bc = 0; bc < (1<<W); bc++) {
			int cnt = 0;
			for (int i = 0; i < H; i++) {
				for (int j = 0; j < W; j++) {
					if (S[i][j] == '#' && !((br>>i)&1) && !((bc>>j)&1)) {
						cnt++;
					}
				}
			}
			if (cnt == K) {
				ans++;
			}
		}
	}
	cout << ans << endl;
}

int main() {
	cin.tie(0);
	ios::sync_with_stdio(0);
	cout << fixed << setprecision(20);
	Main();
	return (0);
}


Measured memory_bytes: 3640
#include <bits/stdc++.h>
using namespace std;
#define mp       make_pair
#define pb       push_back
#define all(x)   (x).begin(),(x).end()
#define YES() printf("YES\n")
#define NO() printf("NO\n")
#define Yes() printf("Yes\n")
#define No() printf("No\n")
#define in(x,y,h,w) x >= 0 && x < h && y >= 0 && y < w

#define int long long
//typedef    long long          ll;
typedef    vector<bool>       vb;
typedef    vector<int>        vi;
typedef    vector<vb>         vvb;
typedef    vector<vi>         vvi;
typedef    pair<int,int>      P;

template <typename T> T &chmin(T &a, const T &b) { return a = min(a, b); }
template <typename T> T &chmax(T &a, const T &b) { return a = max(a, b); }
 
const int INF=1e+18;
const double EPS=1e-9;
const int MOD=1000000007;

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

signed main(){
	int n,mi = INF;
	string s;
	cin >> s;
	n = s.length();
	for(int t = 0;t < 2;t++){
		int ans = 0;
		for(int i = 0;i < n;i++){
			if((i + t) % 2 != s[i] - '0') ans++;
		}
		mi = min(mi,ans);
	}
	cout << mi << endl;
}


Measured memory_bytes: 512
#include <iostream>
#include <vector>
#include <algorithm>
#include <utility>
#include <string>
#include <queue>
#include <stack>
#include <unordered_set>
#include <unordered_map>

using namespace std;

typedef long long int ll;
typedef pair<int, int> Pii;

const ll mod = 1000000007;


template <class T>
struct segtree {
  int n;
  vector<T> data;

  segtree(const int s) {
    init(s);
  }

  segtree(const int s, const T u) {
    init(s);
    for (int i = 0; i < s; i++) {
      data[i+n-1] = u;
    }
    for (int i = n-2; i >= 0; i--) {
      data[i] = min(data[i*2+1], data[i*2+2]);
    }
  }

  segtree(const vector<T> &v) {
    int s = v.size();
    init(s);
    for (int i = 0; i < s; i++) {
      data[i+n-1] = v[i];
    }
    for (int i = n-2; i >= 0; i--) {
      data[i] = 0;
    }
  }

  void init(const int s) {
    n = 1;
    while (n < s) n <<= 1;
    data = vector<T>(2*n-1);
  }

  void update(int x, T v) {
    int p = x + n - 1;

    // update bottom
    data[p] = v;

    // update rest
    while (p > 0) {
      p = (p - 1) >> 1;
      data[p] = min(data[p*2+1], data[p*2+2]);
    }
  }

  T query(int l, int r, int p = 0, int a = 0, int b = -1) {
    if (b < 0) b = n; // init
    if (r <= a || b <= l) return 0x7fffffff; // out of range

    if (l <= a && b <= r) return data[p];// fully covered

    int vl = query(l, r, p*2+1, a, (a + b) / 2); // left
    int vr = query(l, r, p*2+2, (a + b) / 2, b); // right
    return min(vl, vr);
  }
};

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

  int n;
  cin >> n;
  string s;
  cin >> s;
  int q;
  cin >> q;
  vector<vector<int> > query(q, vector<int>(3));
  for (auto &x: query) {
    cin >> x[0] >> x[1];
    if (x[0] == 1) {
      char c;
      cin >> c;
      x[2] = c;
    }
    else cin >> x[2];
  }

  vector<segtree<int> > st(26, segtree<int>(n));
  for (int i = 0; i < n; i++) {
    st[s[i]-'a'].update(i, -1);
  }

  vector<int> ans;
  for (int i = 0; i < q; i++) {
    if (query[i][0] == 1) {
      st[s[query[i][1]-1]-'a'].update(query[i][1]-1, 0);
      s[query[i][1]-1] = (char) query[i][2];
      st[s[query[i][1]-1]-'a'].update(query[i][1]-1, -1);
    }
    else {
      int count = 0;
      for (int j = 0; j < 26; j++) count += -(st[j].query(query[i][1]-1, query[i][2]));
      ans.push_back(count);
    }
  }

  for (auto &x: ans) cout << x << endl;

  return 0;
}


Measured memory_bytes: 112540
#pragma warning(disable:4996)
#include <bits/stdc++.h>

using namespace std;

#define REP(i,n) for (int i = 0; i<n; i++)
#define ALL(a) begin(a), end(a)
#define TPL template
#define TNM typename

using ll = long long;
using ull = unsigned long long;
TPL<TNM T> using vec = vector<T>;
TPL<TNM T> using vec2 = vec<vec<T>>;
TPL<TNM T> using vec3 = vec<vec2<T>>;
TPL<TNM T> using vec4 = vec<vec3<T>>;
TPL<TNM T> using vec5 = vec<vec4<T>>;

TPL<TNM K, TNM V> using umap = unordered_map<K, V>;
TPL<TNM K, TNM V> using uset = unordered_set<K, V>;

TPL<class T> inline void OUT(const T &x) { cout << x << "\n"; }
struct pre_ { pre_() { cin.tie(nullptr); ios::sync_with_stdio(false); cout << fixed << setprecision(6); } } pre__;

TPL<TNM V, TNM H> void resize(vector<V>& v, const H h) { v.resize(h); }
TPL<TNM V, TNM H, TNM ... T> inline void resize(vector<V>& v, const H& h, const T ... t) { v.resize(h); for (auto& _v : v) resize(_v, t ...); }
TPL<TNM V, TNM T> void fill(V& x, const T& val) { x = val; }
TPL<TNM V, TNM T> inline void fill(vector<V>& vec, const T& val) { for (auto& v : vec) fill(v, val); }
TPL<TNM T> inline void UNIQUE(vector<T>& vec) { sort(ALL(vec)); vec.erase(unique(ALL(vec)), vec.end()); }

using Int = long long;
map<Int, int> prime_factor(Int n) {
	map<Int, int> ret;
	for (ll i = 2; i * i <= n; i++) {
		while (n % i == 0) {
			ret[i]++;
			n /= i;
		}
	}
	if (n != 1) ret[n] = 1;
	return ret;

}

Int modpow(Int a_, Int n_, Int mod_) {
	Int r = 1;
	while (n_) r = r * ((n_ % 2) ? a_ : 1) % mod_, a_ = a_ * a_%mod_, n_ >>= 1;
	return r;
}

Int getC(Int n_, Int r_, Int mod_) {
	if (n_ < 0 || r_<0 || r_>n_) return 0;
	Int nume = 1, denom = 1;
	r_ = min(r_, n_ - r_);
	for (int i = 1; i <= r_; ++i) {
		nume = nume * n_%mod_;
		denom = denom * i%mod_;
		--n_;
	}
	return nume * modpow(denom, mod_ - 2, mod_) % mod_;
}

Int getH(Int n_, Int r_, Int mod_) { return (n_ == 0 && r_ == 0) ? 1 : getC(n_ + r_ - 1, r_, mod_); }

int main(void) {
	ll N, M;
	cin >> N >> M;
	map<Int, int> pf = prime_factor(M);

	const ll K = 1'000'000'007;
	ll ans = 1;
	for (auto& i : pf) {
		ans *= getH(N, i.second, K);
		ans %= K;
	}

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#include<stack>
#include<string>
#include<map>
#include<set>
#include<tuple>
#include<cmath>
#include<iomanip>


#define MOD 1000000007
#define INF 1001001001
#define MIN -1001001001
#define rep(i,k,N) for(int i=k;i<N;i++)
#define MP make_pair
#define MT make_tuple //tie,make_tuple は別物
#define PB push_back
#define PF push_front
#define all(x) (x).begin(),(x).end()


using namespace std;
typedef long long ll;
typedef vector<ll> v;
typedef vector<vector<ll>> vv;

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

int main(){
    ll a,b;
    cin>>a>>b;
    ll ans = 1;
    rep(i,0,a)ans *=100;
    ans *= b;
    if(b == 100){
        ans/=100;
        ans *=101;
    }
    cout<<ans;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <sstream>
#include <string>
#include <algorithm>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <cassert>

using namespace std;

#define FOR(i,k,n) for(int i=(k); i<(int)n; ++i)
#define REP(i,n) FOR(i,0,n)
#define FORIT(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)

template<class T> void debug(T begin, T end){ for(T i = begin; i != end; ++i) cout<<*i<<" "; cout<<endl; }

typedef long long ll;
const int INF = 100000000;
const double EPS = 1e-8;
const int MOD = 1000000007;

#include <complex>
#define CURR(P, i) (P[i])
#define NEXT(P, i) (P[(i + 1) % P.size()])

typedef complex<double> Point;
typedef vector<Point> Polygon;
struct Line : public vector<Point> {
  Line() {;}
  Line(Point a, Point b) { push_back(a); push_back(b); }
};
struct Circle {
  Point p;
  double r;
  Circle() {;}
  Circle(Point p, double r) : p(p), r(r) {;}
};

namespace std{
  bool operator < (const Point& a, const Point& b){
    return a.real() != b.real() ? a.real() < b.real() : a.imag() < b.imag();
  }
}

inline double cross(const Point& a, const Point& b){
  return imag(conj(a) * b);
}

inline double dot(const Point& a, const Point& b){
  return real(conj(a) * b);
}

int ccw(Point a, Point b, Point c){
  b -= a; c -= a;
  double len = abs(b) * abs(c);
  if(cross(b, c) > +EPS * len) return +1; // counter-clockwise
  if(cross(b, c) < -EPS * len) return -1; // clockwise
  if(dot(b, c) < 0) return +2; // c--a--b
  if(norm(b) < norm(c)) return -2; // a--b--c
  return 0; // a--c--b 
}

double polygonArea(const Polygon& P) {
  double A = 0;
  for (int i = 0; i < P.size(); ++i) 
    A += cross(CURR(P, i), NEXT(P, i));
  return abs(A) / 2.0;
}


int main(){
  int n;
  int cnt = 1;
  while(cin>>n && n){
    printf("%d ", cnt++);
    Polygon p(n);
    REP(i, n){
      int x, y; cin>>x>>y;
      p[i] = Point(x, y);
    }
    printf("%.1f\n", polygonArea(p));
  }
  return 0;
}

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

using namespace std;

#define rep(i,m,n) for(int (i)=(int)(m);i<(int)(n);i++)
#define rep2(i,m,n) for(int (i)=(int)(n)-1;i>=(int)(m);i--)
#define REP(i,n) rep(i,0,n)
#define REP2(i,n) rep2(i,0,n)
#define FOR(i,c) for(decltype((c).begin())i=(c).begin();i!=(c).end();++i)
#define ll long long
#define ull unsigned long long
#define all(hoge) (hoge).begin(),(hoge).end()
#define en '\n'
template <class T> using vec = vector<T>;
template <class T> using vvec = vector<vec<T>>;
typedef pair<ll, ll> P;
constexpr long long INF = 1LL << 60;
constexpr int INF_INT = 1 << 25;
constexpr long long MOD = (ll) 1e9 + 7;
typedef vector<ll> Array;
typedef vector<Array> Matrix;
constexpr int loose = 0;
constexpr int tight = 1;


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

struct Edge {
	ll to, cap, rev;
	Edge(ll _to, ll _cap, ll _rev) {
	to = _to; cap = _cap; rev = _rev;
	}
};
typedef vector<Edge> Edges;
typedef vector<Edges> Graph;

void add_edge(Graph& G, ll from, ll to, ll cap, bool revFlag, ll revCap) {
	G[from].push_back(Edge(to, cap, (ll)G[to].size()));
	if (revFlag)G[to].push_back(Edge(from, revCap, (ll)G[from].size() - 1));
}


class RmqTree {
private:
 ll _find(ll a, ll b, ll k, ll l, ll r) {
  if (r <= a || b <= l)return 0;
  if (a <= l && r <= b)return dat[k];
  else {
   ll s1 = _find(a, b, 2 * k + 1, l, (l + r) / 2);
   ll s2 = _find(a, b, 2 * k + 2, (l + r) / 2, r);
   return max(s1, s2);
  }
 }
public:
 ll n, height;
 vector<ll> dat;

 RmqTree(ll _n) {
  n = 1;
  height = 1;
  while (n < _n) {
   n *= 2;
   height++;
  }
  dat = vector<ll>(2 * n - 1, 0);
 }

 //場所iにxを代入する
 void update(ll i, ll x) {
  i += n - 1;
  dat[i] = x;
  while (i > 0) {
   i = (i - 1) / 2;
   dat[i] = max(dat[i * 2 + 1], dat[i * 2 + 2]);
  }
 }

 //区間[a,b)の最小値
 ll find(ll a, ll b) {
  return _find(a, b, 0, 0, n);
 }
};



void solve(){
	ll n;
	cin>>n;
	Array h(n),a(n);
	REP(i,n) cin>>h[i];
	REP(i,n) cin>>a[i];

	RmqTree seg(201010);

	ll ans=0;
	REP(i,n){
		ll x = seg.find(0,h[i]) + a[i];
		chmax(ans,x);
		seg.update(h[i],x);
	}
	cout << ans << en;
}

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

    solve();
    return 0;
}

Measured memory_bytes: 7552
#include <iostream>
#include<set>
#define INF 1e8
using namespace std;
int main(void){
    // Your code here!
int n;cin>>n;

int ar[n];
int sum=0;

for(int i=0;i<n;i++){
    cin>>ar[i];
    sum+=ar[i];
}
int mid= sum/n;
int ans1=0, ans2=0;

for(int i=0;i<n;i++){
    ans1+=(abs(mid-ar[i])*abs(mid-ar[i]));
}

mid++;

for(int i=0;i<n;i++){
    ans2+=(abs(mid-ar[i])*abs(mid-ar[i]));
}
cout<<min(ans1, ans2);

}


Measured memory_bytes: 3636
d,s=[],[];5.times{d<< gets.chomp.to_i}
d.permutation(5).to_a.each{|arr|
  arrd=arr
  4.times{|a|arrd[a]+=10-(arrd[a].to_s[-1].to_i%10) if arrd[a].to_s[-1]!="0"}
  s<< arrd.inject(:+)
  }
p s.min

Measured memory_bytes: 1788
#include<bits/stdc++.h>
using namespace std;
const int inf=0x3f3f3f3f;
int n,m,p;

struct Node
{
    int x,y;
};
const int maxn=3000+10;
vector<Node>s[maxn];
vector<int>w[maxn];

int ans=0;
int vis[maxn];
int dis[maxn];
int cnt[maxn];
int f=0;
int reachable[maxn];
void dfs(int x)
{
    reachable[x]=1;
    for(int i=0; i<w[x].size(); i++)
    {
        if(reachable[w[x][i]])
            continue;
        dfs(w[x][i]);
    }
}
bool SPFA()
{
    for(int i=1; i<=n; i++)
        dis[i]=-inf;
    vis[1]=1;
    dis[1]=0;
    queue<int>que;
    que.push(1);
    cnt[1]=1;
    while(!que.empty())
    {
        int top=que.front();
        que.pop();
        vis[top]=0;
        if(!reachable[top]||dis[top]==-inf)
            continue;
        for(int i=0; i<s[top].size(); i++)
        {
            Node no=s[top][i];
            int v=no.x;
            if(!reachable[v])
                continue;
            if(dis[v]<dis[top]+no.y)
            {
                dis[v]=dis[top]+no.y;
            }
            if(vis[v]==0)
            {
                vis[v]=1;
                que.push(v);
                if(++cnt[v]>n)
                    return false;
            }
        }
    }
    return true;
}
bool bellman_ford(){
	for(int i=2;i<=n;i++){
		dis[i] = -inf;
	}
	for(int k=0;k<=n;k++){
		bool updated = false;
		for(int i=1;i<=n;i++){
			int l = s[i].size();
			if(!reachable[i]||dis[i]==-inf) continue;
			for(int j=0;j<l;j++){
				int v = s[i][j].x;
				if(!reachable[v]) continue;
				int c = s[i][j].y;
				if(dis[v]<dis[i]+c){
					updated = true;
					dis[v] = dis[i]+c;
				}
			}
		}
		if(!updated) return true;
	}
	return false;
}

int main()
{

    std::ios::sync_with_stdio(false);

    cin>>n>>m>>p;
    for(int i=0; i<m; i++)
    {
        int x,y,z;
        cin>>x>>y>>z;
        w[y].push_back(x);
        s[x].push_back({y,z-p});
    }
    dfs(n);
    //bool flag=SPFA();
    bool flag=bellman_ford();
    if(flag)
        cout<<max(0,dis[n])<<'\n';
    else
        puts("-1");

    return 0;
}


Measured memory_bytes: 640
using System;
using System.Collections;
using System.Collections.Generic;
using System.Text;

class Program
{
    static void Main(string[] args)
    {
        var p = new Program();
        var N = p.ConvertIntArray(p.ReadInput());
        var result = N[0] + N[1];
        var result2 = N[0] - N[1];
        var result3 = N[0] * N[1];
        int[] array = new int[3];
        array[0] = result;
        array[1] = result2;
        array[2] = result3;
        Array.Sort(array);
        Console.WriteLine(array[2]);
    }

    public string[] ReadInput()
    {
        return Console.ReadLine().Split(' ');
    }

    public int[] ConvertIntArray(string[] x)
    {
        var convertedArray = new int[x.Length];
        for (var i = 0; i < x.Length; i++)
        {
            convertedArray[i] = int.Parse(x[i]);
        }

        return convertedArray;
    }
}



Measured memory_bytes: 11092
object Main extends App {
  val Array(a, b, c, x) = Iterator.continually(io.StdIn.readLine.toInt)
    .take(4).toArray

  val ans = {
    var cnt = 0
    val A = math.min(a, x/500:Int)
    val B = math.min(b, x/100:Int)
      for {
        i <- 0 to A
        c0 = 500*i
        j <- 0 to B
        c1 = 100*j
        if c0 + c1 <= x
        k <- 0 to c
        if c0 + c1 + 50*k == x
      } cnt += 1
    cnt
  }

  println(ans)
}

Measured memory_bytes: 27324
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N, A, t;
  cin >> N >> A;
  
  t = N % 500;
  if (t<=A) {
  	cout << "Yes" << endl;
  }
  else {
    cout << "No" << endl;
  }
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <string.h>
#include <math.h>
#include <algorithm>
#include <stdlib.h>
#include <vector>
#include <map>
typedef long long ll;
using namespace std;

int main() {
	int s,w;
	cin >> s >> w;
	if (s>w) cout << "safe";
	else cout << "unsafe";
	return 0;
}

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

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(), (x).end()
#define fin(x) cout << x << endl;

using namespace std;
using ll = long long;

int main(void) {
  int N, M;
  cin >> N >> M;
  vector<vector<int>> s(M);
  rep(i, M) {
    int k;
    cin >> k;
    rep(j, k) {
      int a;
      cin >> a;
      a--;
      s[i].push_back(a);
    }
  }
  vector<int> p(M);
  rep(i, M) {
    cin >> p[i];
  }
  ll ans = 0;

  // スイッチのオンオフ全部
  for (int bit = 0; bit < (1<<N); bit++) {
    bool f = true;
    rep(i, M) { // 電球について
      int con = 0;
      for (auto v : s[i]) { // スイッチがオンになっているか
        if (bit & (1<<v)) {
          con++;
        }
      }
      if (con % 2 != p[i]) { // 電球が点灯するか
        f = false;
      }
    }
    if (f) {
      ans++;
    }
  }
  cout << ans << endl;
  return 0;
}

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

int main(){
   int n; cin>>n;
   vector<int> h(n);
   rep(i,n) cin>>h[i];
   int ans=0;
   int maxr=0;
   for(int i=0;i<n-1;i++){
      if(h[i+1]<=h[i]) ans++;
      else ans=0;
      maxr=max(ans,maxr);
   }
   cout<<maxr<<endl;
   return 0;
}


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

int main() {
    int ac = 0;
    int wa = 0;
    int tle = 0;
    int re = 0;
    int n;
    cin >> n; 
    string s;
    for (int i = 0; i < n; i++) {
        cin >> s;
        if (s == "AC") ac++;
        if (s == "WA") wa++;
        if (s == "TLE") tle++;
        if (s == "RE") re++;
    }
    cout << "AC" << " " << "x" << " " << ac << endl;
    cout << "WA" << " " << "x" << " " << wa << endl;
    cout << "TLE" << " " << "x" << " " << tle << endl;
    cout << "RE" << " " << "x" << " " << re << endl;
return 0;
}

Measured memory_bytes: 3628
#include <bits/stdc++.h>
using namespace std;
 
int main () {
  int N;
  cin >> N;
  long int power = 1;
  long int a = 1000000007;

  for(int i = 1; i <= N; i++){
    power = power * i % a;
  }
  cout << power << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int live[200000];
int pre[200000];
int nxt[200000];
int main(){
	int n,m,q;
	cin>>n>>m>>q;
	for(int i=0;i<n;i++){
		pre[i]=i-1;
		nxt[i]=i+1;
		live[i]=1;
	}
	nxt[n-1]=0;
	pre[0]=n-1;
	int pos=0;
	while(m--){
		int t;cin>>t;
		if(t%2)while(t--)pos=pre[pos];
		else while(t--)pos=nxt[pos];
		live[pos]=0;
		nxt[pre[pos]]=nxt[pos];
		pre[nxt[pos]]=pre[pos];
		pos=nxt[pos];
	}
	while(q--){
		int t;cin>>t;
		cout<<live[t]<<endl;
	}
	return 0;
}


Measured memory_bytes: 3504
#include <cmath>
#include <iostream>
using namespace std;
int main() {
  double a, b = 0.0, c = INFINITY;
  while (cin >> a) {
    if (a > b) b = a;
    if (a < c) c = a;
  }
  cout << (b - c) << endl;
  return 0;
}

Measured memory_bytes: 1280
#include <cstdio>
#include<iostream>
#include<map>
#include<algorithm>
#include<vector>
#include <cmath>
#include <iomanip>
#include <regex>
#include <queue>
#include <set>
#include <cassert>
using namespace std;
using ll = long long;
using plong = pair<ll,ll>;

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
const long MAX = 100000;
const long 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 (long 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 COM(long n, long k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

int main(){
    ll N,M;
    cin>>N>>M;
    COMinit();
    cout<<COM(N,2)+COM(M,2)<<endl;


    
}


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

ll n, k;
const ll MAX_N = 2e5;
const ll INF = 1e10;

vector<ll> Rank;
vector<ll> tmp;
vector<ll> sa;
vector<ll> lcp;

bool comp_sa(ll i, ll j) {
	if (Rank[i] != Rank[j])return Rank[i] < Rank[j];
	else {
		ll ri = i + k <= n ? Rank[i + k] : -1;
		ll rj = i + k <= n ? Rank[j + k] : -1;
		return ri < rj;
	}
}

void construct_sa(string s) {
	n = s.length();
	Rank.resize(n + 1);
	tmp.resize(n + 1);
	sa.resize(n + 1);

	for (ll i = 0; i <= n; ++i) {
		sa[i] = i;
		Rank[i] = i < n ? s[i] : -1;
	}

	for (k = 1; k <= n; k *= 2) {
		sort(sa.begin(), sa.end(), comp_sa);
		tmp[sa[0]] = 0;
		for (ll i = 1; i <= n; ++i) {
			tmp[sa[i]] = tmp[sa[i - 1]] + (comp_sa(sa[i - 1], sa[i]) ? 1 : 0);
		}
		Rank = tmp;
	}
}

void construct_lcp(string s) {
	n = s.length();
	lcp.resize(n + 1);
	for (ll i = 0; i <= n; ++i)Rank[sa[i]] = i;

	ll h = 0;
	lcp[0] = 0;
	for (ll i = 0; i < n; ++i) {
		ll j = sa[Rank[i] - 1];
		if (h > 0)--h;
		for (; j + h < n && i + h < n; ++h) {
			if (s[j + h] != s[i + h])break;
		}
		lcp[Rank[i] - 1] = h;
	}
}

class SegmentTree {
private:
	ll n;
	vector<ll> node;

public:
	// 元配列 v をセグメント木で表現する
	SegmentTree(vector<ll> v) {
		// 最下段のノード数は元配列のサイズ以上になる最小の 2 冪 -> これを n とおく
		// セグメント木全体で必要なノード数は 2n-1 個である
		ll sz = v.size();
		n = 1; while (n < sz) n *= 2;
		node.resize(2 * n - 1, INF);

		// 最下段に値を入れたあとに、下の段から順番に値を入れる
		// 値を入れるには、自分の子の 2 値を参照すれば良い
		for (ll i = 0; i < sz; i++) node[i + n - 1] = v[i];
		for (ll i = n - 2; i >= 0; i--) node[i] = min(node[2 * i + 1], node[2 * i + 2]);
	}

	void update(ll x, ll val) {
		// 最下段のノードにアクセスする
		x += (n - 1);

		// 最下段のノードを更新したら、あとは親に上って更新していく
		node[x] = val;
		while (x > 0) {
			x = (x - 1) / 2;
			node[x] = min(node[2 * x + 1], node[2 * x + 2]);
		}
	}

	ll getmin(ll a, ll b, ll k = 0, ll l = 0, ll r = -1) {
		// 最初に呼び出されたときの対象区間は [0, n)
		if (r < 0) r = n;

		// 要求区間と対象区間が交わらない -> 適当に返す
		if (r <= a || b <= l) return INF;

		// 要求区間が対象区間を完全に被覆 -> 対象区間を答えの計算に使う
		if (a <= l && r <= b) return node[k];

		// 要求区間が対象区間の一部を被覆 -> 子について探索を行う
		// 左側の子を vl ・ 右側の子を vr としている
		// 新しい対象区間は、現在の対象区間を半分に割ったもの
		ll vl = getmin(a, b, 2 * k + 1, l, (l + r) / 2);
		ll vr = getmin(a, b, 2 * k + 2, (l + r) / 2, r);
		return min(vl, vr);
	}
};

int main() {
	string s;
	cin >> s;
	ll n = s.size();
	map<char, ll> m;
	for (char c : s)++m[c];
	ll ans = n * (n - 1) / 2;
	for (auto p : m) {
		ans -= p.second * (p.second - 1) / 2;
	}
	cout << ans + 1 << endl;
}


Measured memory_bytes: 640
#include <iostream>
#include <sstream>
#include <string>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <cstdlib>
#include <cstdio>
#include <cmath>
#include <bitset>
#include <complex>
using namespace std;
 
const double EPS = 1e-9;
const double PI = 3.14159265359;
 
typedef complex<double> P;

typedef long long int li;

int main(){
	int n;
	string hos = "Hoshino";

	cin >> n;
	cin.ignore();
	while(n--){
		string s;
		getline(cin, s);

		int k = s.size()+1-hos.size();
		for(int i = 0; i < k; i++){
			if(s.substr(i, hos.size()) == hos){
				s[i+hos.size()-1] = 'a';
			}
		}

		cout << s << endl;
	}

    return 0;
}

Measured memory_bytes: 1220
# include <iostream>
# include <algorithm>
# include <vector>
# include <string>
# include <set>
# include <map>
# include <cmath>
# include <iomanip>
# include <functional>
# include <utility>
# include <stack>
# include <queue>
# include <list>
using namespace std;
using LL = long long;
constexpr int MOD = 1000000000 + 7;
constexpr int INF = 2000000000;

int C[1000];

int main() {
	string s;
	cin >> s;
	LL ans = 0;
	for (int i = 0; i < s.size(); i++) {
		C[s[i]]++;
	}
	for (int i = 'a'; i <= 'z'; i++) {
		//if (C[i] >= 2)ans -= LL(C[i] * (C[i] - 1) / 2);
		ans += (s.size() - C[i])*C[i];
	}
	cout << ans / 2 + 1 << endl;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
#define fi first
#define se second
#define all(a) a.begin(), a.end()
#define pb push_back
#define mp make_pair
typedef long long ll;
typedef pair<ll,ll> P;
#define rep(i,a,b) for(ll i=a ; i<b ; i++)
const int max_n = 1e5;
const ll mod = 1e9+7;
const ll INF = 1LL<<60;
typedef long double ld;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
int dx[4] = {0,0,1,-1};
int dy[4] = {1,-1,0,0};
ll gcd(ll a, ll b) { return a ? gcd(b%a, a) : b; }
int main(){
  int n,m;  cin >>n>>m;
  vector<int> a(n);
  double sum=0;
  rep(i,0,n){
    cin >> a[i];
    sum += a[i];
  }
  sort(all(a));
  reverse(all(a));
  bool ok=true;
  rep(i,0,m){
    if(a[i]<(sum/(4*m))) ok=false;
  }
  if(ok){
    cout <<"Yes"<< endl;
  }else{
    cout <<"No" << endl;
  }
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <cmath>
#include <vector>
#include <queue>
#include <limits>
#include <algorithm>
#include <string>
#include <set>
using namespace std;

int main()
{
	string A, B, C;
	cin >> A >> B >> C;

	cout << (A[A.size() - 1] == B[0] && B[B.size() - 1] == C[0] ? "YES" : "NO") << endl;

	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair <int,int> PAIR;
const int N = 1e4+5;
const int M = 1e4;
const int INF = 0x3f3f3f3f;

struct node{
	int A,B,C,D;
} p[55];
int n,m,q,ans,a[15];

inline int cal(){
	int res = 0;
	for(int i = 1;i <= q;++i){
		if(a[p[i].B] - a[p[i].A] == p[i].C)
			res += p[i].D;
	}
	return res;
}

inline void dfs(int now,int st){
	if(now > n){
		ans = max(ans,cal());
		return ;
	}
	
	for(int i = st;i <= m;++i){
		a[now] = i;
		dfs(now+1,i);
	}
	return ;
}

int main() {
	scanf("%d%d%d",&n,&m,&q);
	for(int i = 1;i <= q;++i)
		scanf("%d%d%d%d",&p[i].A,&p[i].B,&p[i].C,&p[i].D);
	
	ans = 0;
	dfs(1,1);
	printf("%d\n",ans);
    return 0;
}

Measured memory_bytes: 3760
def main():
    n = input()
    if len(n) == 1:
        print(n)
        return
    if set(n[1:]) == {'9'}:
        print(int(n[0]) + 9 * (len(n) - 1))
        return

    for i, c in enumerate(n):
        if c != '9':
            print(9 * (len(n) - 1) + int(n[0]) - 1)
            return
    else:
        print(9 * len(n))


if __name__ == '__main__':
    main()


Measured memory_bytes: 3060
H,W = map(int,input().split())
A = [input() for _ in range(H)]
ans = [[10000]*(W+2) for _ in range(H+2)]
for i in range(H):
    for j in range(W):
        if A[i][j] == "#":
            ans[i+1][j+1] = 0

for i in range(H):
    for j in range(W):
        ans[i+1][j+1] = min(ans[i+1][j+1],ans[i+1][j]+1)
for i in range(H):
    for j in range(W-1,-1,-1):
        ans[i+1][j+1] = min(ans[i+1][j+1],ans[i+1][j+2]+1)
for j in range(W):
    for i in range(H):
        ans[i+1][j+1] = min(ans[i+1][j+1],ans[i][j+1]+1)
for j in range(W):
    for i in range(H-1,-1,-1):
        ans[i+1][j+1] = min(ans[i+1][j+1],ans[i+2][j+1]+1)

num = 0
for i in range(H):
    for j in range(W):
        num = max(num,ans[i+1][j+1])

print(num)

Measured memory_bytes: 59244
//	-*- mode: C++ -*-
//	Spreadsheet
//
//		Your task is to perform a simple table calculation.
//
//		Write a program which reads the number of rows r, columns c and a table of r × c elements, and prints a new table, which includes the total sum for each row and column.
//
//	Input
//		In the first line, two integers r and c are given. Next, the table is given by r lines, each of which consists of c integers separated by space characters.
//
//	Output
//		Print the new table of (r+1) × (c+1) elements. Put a single space character between adjacent elements. For each row, print the sum of it's elements in the last column. For each column, print the sum of it's elements in the last row. Print the total sum of the elements at the bottom right corner of the table.
//
//	Constraints
//		1 ≤ r, c ≤ 100
//		0 ≤ an element of the table ≤ 100
//	Sample Input
//		4 5
//		1 1 3 4 5
//		2 2 2 4 5
//		3 3 0 1 1
//		2 3 4 4 6
//	Sample Output
//		1 1 3 4 5 14
//		2 2 2 4 5 15
//		3 3 0 1 1 8
//		2 3 4 4 6 19
//		8 9 9 13 17 56

#include <iostream>
#include <vector>

int	main(int	argc,
		 char*	argv[])
{
	unsigned int	r	{0};
	unsigned int	c	{0};

	std::cin >> r >> c;
	std::vector<std::vector<unsigned int>>	sheet	{0}; 

	sheet.resize(r + 1);

	for(unsigned int i = 0; i < r + 1; i++){
		sheet[i].resize(c + 1, 0);
	}

	for(unsigned int i = 0; i < r; i++){
		sheet[i].resize(c + 1, 0);
		unsigned int sum	{0};
		for(unsigned int j = 0; j < c; j++){
			unsigned int	x	{0};

			std::cin >> x;
			sheet[i][j]	= x;
			sum	+= x;
			sheet[r][j]	+= x;
		}
		sheet[i][c]	= sum;
		sheet[r][c]	+= sum;
	}

	for(auto row : sheet){
		unsigned int	count	{0};
		for(auto column : row){
			count++;
			std::cout << column;
			if(count <= c){
				std::cout << ' ';
			}
			else{
				std::cout << '\n';
			}
		}
	}

    return 0;
}



Measured memory_bytes: 3132
#include <bits/stdc++.h>
#define fo(i, a, b) for (int i = a; i < b; i++)
#define re(i, n) fo(i, 0, n)
using namespace std;
typedef long long ll;
int main()
{
  string s, t;
  cin >> s >> t;

  sort(s.begin(), s.end());
  sort(t.begin(), t.end(), greater<int>());

  if (s < t) cout << "Yes" << endl;
  else cout << "No" << endl;

  return 0;
}


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

using ll = long long;

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  
  int n;
  cin >> n;
  
  while (n--) {
    string s;
    cin >> s;
    
    vector<vector<ll>> x(5005);
    int it = 0;
    ll keep = 0;
    for (int i = 0; i < s.size(); i++) {
      if (s.at(i) == '[') it++;
      else if (s.at(i) == ']') {
        if (keep > 0) {
          x[it].emplace_back(keep / 2 + 1);
          keep = 0;
        }
        else {
          sort(x[it + 1].begin(), x[it + 1].end());
          ll keep2 = 0;
          for (int j = 0; j < x[it + 1].size() / 2 + 1; j++) {
            keep2 += x[it + 1].at(j);
          }
          x[it].emplace_back(keep2);
          x[it + 1].clear();
        }
        it--;
      }
      else {
        keep *= 10;
        keep += (ll) s.at(i) - '0';
      }
    }
    
    cout << x[1].at(0) << '\n';
  }
}


Measured memory_bytes: 3356
from collections import deque
s = deque(input())
qn = int(input())
q = []
rev = False

for i in range(qn):
    qi = input().split()
    if qi[0] == "1":
        rev = not rev
    else:
        if rev:
            if qi[1] == "1":
                qi[1] = "2"
            else:
                qi[1] = "1"
        q.append((2, int(qi[1]), qi[2]))
for i in range(len(q)):
    if q[i][0] == 2:
        if q[i][1] == 1:
            s.appendleft(q[i][2])
        else:
            s.append(q[i][2])
if rev:
    s = list(s)[::-1]
print("".join(s))

Measured memory_bytes: 24472
#include <algorithm>
#include <cassert>
#include <cmath>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
using namespace std;
typedef long long ll;
// const int INF = (1 << 30) - 1;
// const ll LL_INF = (1LL << 62) - 1;
// const ll MOD = 1e9 + 7;
// const double PI = M_PI;

ll N, A, B;
// vector<int> A;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cin >> N >> A >> B;
  // A.resize(N);
  // for (int i = 0; i < N; i++) {
  //   int tmp;
  //   cin >> tmp;
  //   A[i] = tmp;
  // }

  ll ans = 0;
  if ((B - A) % 2 == 0) {
    ans = (B - A) / 2;
  } else {
    ans = min(B - 1, N - A);
    ans = min(ans, A + (B - A - 1) / 2);
    ans = min(ans, N - B + 1 + (N - (A + N - B + 1)) / 2);
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 632
#include <stdio.h>

int ans;
int s,n;

void init(int b[]){
	int i;
	ans=0;
	for(i=0; i<10; i++)b[i]=0;
}

void culc(int sum,int num,int b[]){
	int b2[10],i;
	for(i=0; i<10; i++)b2[i]=b[i];
	if(n==num&&sum==s){
		//printf("n:%d s:%d\n",n,s);
		// printf("  b:");
		// for(i=0; i<10; i++){
		// 	if(b[i])printf("%d ",i);
		// }
		// printf("\n");
		ans++;
		return;
	}
	if(n<num)return;
	if(s<sum)return;
	for(i=0; i<10; i++){
		if(!b2[i]){
			b2[i]=1;
			//sum+=i;
			culc(sum+i,num+1,b2);
			b2[i]=0;
		}
	}
}

int main(){
	int b[10],i;
	while(1){
		scanf("%d %d",&n,&s);
		if(n==0&&s==0)break;
		init(b);
		culc(0,0,b);
		for(i=n; i>0; i--)ans/=i;
		printf("%d\n",ans);
	}

	return 0;
}

Measured memory_bytes: 600
s = input()
x = s.split()
A = int(x[0])
B = int(x[1])
if A == 1:
    if B == 1:
        print('Draw')
    else:
        print("Alice")
elif B == 1:
    print('Bob')
elif A > B:
    print('Alice')
elif B > A:
    print('Bob')
elif A == B:
    print('Draw') 

Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std;
char s[105];
int ans;
int main(){
	cin>>s;
	int len=strlen(s);
	len--;
	for(int i=0;i<=len;i++){
		if(ans==0){
			if(s[i]=='C')ans++;
		}else{
			if(ans==1&&s[i]=='F'){
				ans++;
				break;
			}
		}
	}
	if(ans==2)printf("Yes\n");
	else printf("No\n");
	return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner std = new Scanner(System.in);
        int n = std.nextInt();
        String s = std.next();
        int k = std.nextInt();

        char target = s.charAt(k - 1);
        StringBuilder sb = new StringBuilder();
        for (int i = 0; i < n; i++) {
            if (target != s.charAt(i)) {
                sb.append('*');
            } else {
                sb.append(s.charAt(i));
            }
        }

        System.out.println(sb.toString());
    }
}


Measured memory_bytes: 21844
# ABC100-B
D, N = map(int, input().split())
if N != 100:
    if D == 0:
        print(N)
    elif D == 1:
        print(N * 100)
    elif D == 2:
        print(N * 10000)
else:
    if D == 0:
        print(N + 1)
    elif D== 1:
        print(N * 100 + 100)
    else:
        print(N * 10000 + 10000)

Measured memory_bytes: 3060
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
// 293206GT
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <set>
#include <map>
#include <queue>
#include <unordered_map>
#include <unordered_set>
#include <unordered_set>
#include <stack>
#include <string>
#include<algorithm>
#include <random>
#include <bitset>
#include <chrono>

typedef long long ll;
//#define int ll
using namespace std;
#define put(a) cout << (a) << '\n'
#define sqr(x) ((x) * (x))
typedef pair<int, int> pii;
typedef long double ld;
typedef pair<ld, ld> pld;
typedef unsigned long long ull;

typedef vector<int> vi;
typedef vector<pii> vpii;
#define rep(x, y, a) for (int x = (y); x < (int)(a); ++x)
#define all(a) a.begin(), a.end()
#define chkmax(a, b) a = max(a, (b))
#define chkmin(a, b) a = min(a, (b))
#define prev asasdasd
#define next aasdasda
#define left asdasdasdasd
#define right asnabsdkasdl
#define rank asdasdknlasd
#define move asdasdas
#define fname "parray"
#define fin fname".in"
#define fout fname".out"
#define files freopen(fin, "r", stdin);freopen(fout, "w", stdout);
namespace IO {

    template<class A, class B>
    ostream &operator<<(ostream &out, vector<pair<A, B>> a);

    template<class A>
    ostream &operator<<(ostream &out, vector<A> a);

    template<class A, class B>
    ostream &operator<<(ostream &out, pair<A, B> a) {
        out << a.first << " " << a.second;
        return out;
    }

    template<class A, class B>
    ostream &operator<<(ostream &out, vector<pair<A, B>> a) {
        for (pair<A, B> x: a)
            out << x.first << " " << x.second << '\n';
        return out;
    }

    template<class A>
    ostream &operator<<(ostream &out, vector<A> a) {
        for (A x: a) out << x << ' ';
        return out;
    }

    template<class A, class B>
    istream &operator>>(istream &in, pair<A, B> &a) {
        in >> a.first >> a.second;
        return in;
    }

    template<class A>
    istream &operator>>(istream &in, vector<A> &a) {
        for (A &x: a) in >> x;
        return in;
    }
}
using namespace IO;


mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

void solve() {
    int x;
    cin >> x;
    put(x>=30?"Yes":"No");
}

signed main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    cout.precision(30);
//    freopen("input.txt", "r", stdin);
//    files
    int q = 1;
//    cin >> q;
    while (q--) solve();
}



Measured memory_bytes: 3136
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {

		Scanner scanner = new Scanner(System.in);
		int second = scanner.nextInt();
		int h;
		int m;
		int s;

		h = second / 3600;
		second = second - h * 3600;
		m = second / 60;
		second = second - m * 60;
		s = second;

		System.out.println(h + ":" + m + ":" + s);

	}
}

Measured memory_bytes: 17176
#include <bits/stdc++.h>
using namespace std;
#define NewNode (ListNode *)malloc(sizeof(ListNode))
#define Mem(a,b) memset(a,b,sizeof(a))
const int N = 1e5 + 5;
const int INF = 0x3f3f3f3f;
const double EPS = 1e-10;
const unsigned long long mod = 998244353;
const double II = 3.1415926535;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef pair<ll,ll> piil;
map<int,int> mp;
int main()
{
    std::ios::sync_with_stdio(false);
    cin.tie(0),cout.tie(0);
    ll ans = 0,n;
    cin >> n;
    for(int i = 1;i <= n;i++)
    {
        ll a;
        cin >> a;
        ans += mp[a-i];
        mp[-1*a-i]++;
    }
    cout << ans << endl;
}


Measured memory_bytes: 20660
import java.util.Scanner;

public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int a = sc.nextInt();
    String b = sc.next();
    char[] c = b.toCharArray();
    if(a % 2 == 1){
      System.out.println("No");
      System.exit(0);
    }
    for(int i = 0;i < a / 2;i++){
      if(c[i] != c[(a / 2) + i]){
        System.out.println("No");
        System.exit(0);
      }
    }
    System.out.println("Yes");
  }
}

Measured memory_bytes: 21844
#include <iostream>
#include <map>
#include <algorithm>

using namespace std;

bool is_valid(int count[]) {
    bool is_ok;
    for (int i = 0; i < 9; ++i) {
        if (count[i] > 0) {
            if (count[i] >= 3) {
                count[i] -= 3;
                is_ok = is_valid(count);
                count[i] += 3;
                if (is_ok) {
                    return true;
                }
            }
            if (count[i] * count[i + 1] * count[i + 2] > 0) {
                for (int j = 0; j < 3; ++j) {
                    --count[i + j];
                }
                is_ok = is_valid(count);
                for (int j = 0; j < 3; ++j) {
                    ++count[i + j];
                }
                if (is_ok) {
                    return true;
                }
            }
            return false;
        }
    }
    return true;
}

bool is_winner(int n[], char c[]) {
    const char colors[] = "RGB";
    int count[9];
    for (int i = 0; colors[i]; ++i) {
        for (int j = 0; j < 9; ++j) {
            count[j] = 0;
        }
        for (int j = 0; j < 9; ++j) {
            if (c[j] == colors[i]) {
                ++count[n[j] - 1];
            }
        }
        if (!is_valid(count)) {
            return false;
        }
    }
    return true;
}

int main() {
    int t;
    int n[9];
    char c[9];
    cin >> t;
    for (int i = 0; i < t; ++i) {
        for (int i = 0; i < 9; ++i) {
            cin >> n[i];
        }
        for (int i = 0; i < 9; ++i) {
            cin >> c[i];
        }
        if (is_winner(n, c)) {
            cout << 1 << endl;
        } else {
            cout << 0 << endl;
        }
    }
    return 0;
}

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

// #define int long long
#define rep(i, n) for (long long i = (long long)(0); i < (long long)(n); ++i)
#define reps(i, n) for (long long i = (long long)(1); i <= (long long)(n); ++i)
#define rrep(i, n) for (long long i = ((long long)(n)-1); i >= 0; i--)
#define rreps(i, n) for (long long i = ((long long)(n)); i > 0; i--)
#define irep(i, m, n) for (long long i = (long long)(m); i < (long long)(n); ++i)
#define ireps(i, m, n) for (long long i = (long long)(m); i <= (long long)(n); ++i)
#define SORT(v, n) sort(v, v + n);
#define REVERSE(v, n) reverse(v, v+n);
#define vsort(v) sort(v.begin(), v.end());
#define all(v) v.begin(), v.end()
#define mp(n, m) make_pair(n, m);
#define cout(d) cout<<d<<endl;
#define coutd(d) cout<<std::setprecision(10)<<d<<endl;
#define cinline(n) getline(cin,n);
#define replace_all(s, b, a) replace(s.begin(),s.end(), b, a);
#define PI (acos(-1))
#define FILL(v, n, x) fill(v, v + n, x);
#define sz(x) long long(x.size())

using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using vs = vector<string>;
using vpll = vector<pair<ll, ll>>;
using vtp = vector<tuple<ll,ll,ll>>;
using vb = vector<bool>;

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

const ll INF = 1e9;
const ll MOD = 1e9+7;
const ll LINF = 1e18;



signed main()
{
  cin.tie( 0 ); ios::sync_with_stdio( false );
  string s; cin>>s;
  ll n=s.size();
  
  bool ok=true;
  rep(i,n-1){
    if(s[i]!=s[i+1]) ok=false;
  }
  if(ok){
    cout<<0<<endl;
    return 0;
  }
  
  ll ans=100;
  rep(i,26){
    char c='a'+i;
    string tmp=s;
    ll cnt=0;
    bool flg=true;
    while(flg){
      flg=false;
      string itmp="";
      rep(j,tmp.size()-1){
        if(tmp[j]==c||tmp[j+1]==c){
          itmp+=c;
        }
        else{
          itmp+=tmp[j];
          flg=true;
        }
      }
      tmp=itmp;
      // cout<<tmp<<endl;
      cnt++;
    }
    chmin(ans,cnt);
  }
  
  cout<<ans<<endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <string>
#include <math.h>
#include <queue>
using namespace std;
typedef long long int ll;

int main(){
	int t[3][6];
	for(int i=0;i<3;i++){
		for(int j=0;j<6;j++){
			cin >> t[i][j];
		}
	}
	int m[3];
	for(int i=0;i<3;i++){
		m[i]=(t[i][3]*3600+t[i][4]*60+t[i][5])-(t[i][0]*3600+t[i][1]*60+t[i][2]);
	}
	for(int i=0;i<3;i++){
		cout << m[i]/3600 << " " << m[i]%3600/60 << " " << m[i]%60 << endl;
	}
	return 0;
}


Measured memory_bytes: 3076