akhauriyash/Code-Regression huggingface dataset:
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		long n = sc.nextLong();
		long ans = 0;
		for(long i = 0; i < n; i++) {
			long a = sc.nextLong();
			while(a % 2 == 0) {
				ans++;
				a /= 2;
			}
		}
		System.out.println(ans);

	}

}


Measured memory_bytes: 33828
include Math
N = gets.to_i

class Point
  attr_accessor :x, :y
  def initialize(x, y)
    @x = x
    @y = y
  end
end

a = Point.new(0, 0)
b = Point.new(100, 0)

def koch(n, a, b)
  # 線分の右端の座標を返す
  return b if n == 0

  # 現在の線分に対して3頂点を計算する
  s = trisection_left(a, b)
  t = trisection_right(a, b)
  u = trisection_top(s, t)

  # 3頂点で分かれた4本の線分の左から順に再帰呼び出しを実行
  koch(n-1, a, s)
  # もし、nが0に到達したら、右端の座標が返されるので、それを表示する
  puts "%.8f %.8f" %[s.x, s.y]
  koch(n-1, s, u)
  puts "%.8f %.8f" %[u.x, u.y]
  koch(n-1, u, t)
  puts "%.8f %.8f" %[t.x, t.y]
  koch(n-1, t, b)
  #結果、(0,0),(100,0)を除く、頂点の座標が左から順に出力される
end

def trisection_left(a, b)
  new_x = (2 * a.x + b.x ) / 3.to_f
  new_y = (2 * a.y + b.y ) / 3.to_f
  Point.new(new_x, new_y)
end

def trisection_right(a, b)
  new_x = (a.x + 2 * b.x) / 3.to_f
  new_y = (a.y + 2 * b.y) / 3.to_f
  Point.new(new_x, new_y)
end

def trisection_top(s, t)
  new_x = (t.x - s.x) * cos(PI/3) - (t.y - s.y) * sin(PI/3) + s.x
  new_y = (t.x - s.x) * sin(PI/3) + (t.y - s.y) * cos(PI/3) + s.y
  Point.new(new_x, new_y)
end

puts "%.8f %.8f" %[a.x, a.y]
koch(N, a, b)
puts "%.8f %.8f" %[b.x, b.y]



Measured memory_bytes: 6940
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define all(x) (x).begin(),(x).end()
using namespace std;
using ll = long long;
template <class T> void chmin(T &a, const T &b) noexcept { if (b < a) a = b; }
template <class T> void chmax(T &a, const T &b) noexcept { if (a < b) a = b; }
void debug_out() { cout << "\n"; }
template <class T, class... Args>
void debug_out(const T &x, const Args &... args) { cout << x << " "; debug_out(args...);}
#ifdef _DEBUG
  #define debug(...) debug_out(__VA_ARGS__)
#else
  #define debug(...) 
#endif

int main() {
  std::cin.tie(nullptr);
  std::ios_base::sync_with_stdio(false);
  std::cout << std::fixed << std::setprecision(15);
  int n;
  cin >> n;
  vector<pair<pair<string, int>,int> > a(n);
  rep(i,n) {
    cin >> a[i].first.first >> a[i].first.second;
    a[i].first.second *= -1;
    a[i].second = i+1;
  }
  sort(all(a));
  rep(i,n) {
    cout << a[i].second << endl;
  }
  return 0;
}


Measured memory_bytes: 256
A = [i for i in range(2, 14)] + [1]
a, b = map(int, input().split())
c = -1
d = -1
for i in range(len(A)):
    if c == -1 and A[i] == a:
        c = i
    if d == -1 and A[i] == b:
        d = i

if c > d:
    print("Alice")
elif c < d:
    print("Bob")
else:
    print("Draw")

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

int main(){
  int n; cin >> n;
  set<int> st;
  bool ok = true;
  int t = 0;
  for(int i = 0; i <= n ; i++){
    t = t * 10 + 7;
    t %= n;
    if(t == 0){
      cout << i + 1 << endl;
      break;
    }
    if(st.count(t)){
      ok = false;
      break;
    }
    st.insert(t);
  }
  if(!ok) cout << -1 << endl;  
}

Measured memory_bytes: 50360
# include <bits/stdc++.h>
using namespace std;
const int N = 2e5 + 10, mod = 1e9 + 7;
int main(){
    ios::sync_with_stdio(0);
    cin.tie(0); cout.tie(0);
    string s;
    cin >> s;
    int x = (s[2] - '0') * 10 + s[3] - '0';
    int y = (s[0] - '0') * 10 + s[1] - '0';
    bool invx = false, invy = false;
    if(!x || x > 12)invx = true;
    if(!y || y > 12)invy = true;
    if(invx && invy){
        cout << "NA\n";
    }else{
        if(!invx && !invy){
            cout << "AMBIGUOUS\n";
        }else{
            if(invx){
                cout << "MMYY\n";
            }else{
                cout << "YYMM\n";
            }
        }
    }
}


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

#define pb push_back
#define all(a) (a).begin(), (a).end()

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

int main() {
    ios::sync_with_stdio(false);cin.tie(nullptr);
    vector<vector<int>> a(3, vector<int>(3));
    for (int i = 0; i < 3; ++i) {
        for (int j = 0; j < 3; ++j) {
            cin >> a[i][j];
        }
    }

    int n; cin >> n;
    set<int> b;
    while (n--) {
        int x; cin >> x;
        b.insert(x);
    }
    bool flag = false;
    flag |= (b.count(a[0][0]) && b.count(a[0][1]) && b.count(a[0][2]));
    flag |= (b.count(a[1][0]) && b.count(a[1][1]) && b.count(a[1][2]));
    flag |= (b.count(a[2][0]) && b.count(a[2][1]) && b.count(a[2][2]));
    flag |= (b.count(a[0][0]) && b.count(a[1][0]) && b.count(a[2][0]));
    flag |= (b.count(a[0][1]) && b.count(a[1][1]) && b.count(a[2][1]));
    flag |= (b.count(a[0][2]) && b.count(a[1][2]) && b.count(a[2][2]));
    flag |= (b.count(a[0][0]) && b.count(a[1][1]) && b.count(a[2][2]));
    flag |= (b.count(a[0][2]) && b.count(a[1][1]) && b.count(a[2][0]));

    cout << (flag ? "Yes" : "No") << '\n';
 
}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<stack>
#include<queue>
#include<algorithm>
#include<string>
#include<set>
#include<map>
#include<vector>
#include<math.h>
#include<tuple>
#include<string.h>
#include <numeric> 
#include<unordered_map>
using namespace std; 
#define sim template < class c
#define ris return * this
#define dor > debug & operator <<
#define eni(x) sim > typename \
  enable_if<sizeof dud<c>(0) x 1, debug&>::type operator<<(c i) {
sim > struct rge { c b, e; };
sim > rge<c> range(c i, c j) { return rge<c>{i, j}; }
sim > auto dud(c* x) -> decltype(cerr << *x, 0);
sim > char dud(...);
struct debug {
#ifdef LOCAL
~debug() { cerr << endl; }
eni(!=) cerr << boolalpha << i; ris; }
eni(==) ris << range(begin(i), end(i)); }
sim, class b dor(pair < b, c > d) {
  ris << "(" << d.first << ", " << d.second << ")";
}
sim dor(rge<c> d) {
  *this << "[";
  for (auto it = d.b; it != d.e; ++it)
    *this << ", " + 2 * (it == d.b) << *it;
  ris << "]";
}
#else
sim dor(const c&) { ris; }
#endif
};
#define pp(...) "\033[94m [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "]\033[0m"
#define pp1(...) "\033[1;47;35m" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "]\033[0m"
#define dg(x) debug() << pp1(x)
#define dg1(x) debug() << pp(x)
#define dg2(x,y) debug() << pp(x) pp(y)
#define dg3(x,y,z) debug() << pp(x) pp(y) pp(z)
#define dg4(w,x,y,z) debug() << pp(w) pp(x) pp(y) pp(z)
#define int long long
#define all(x) x.begin() , x.end()
#define clr(x) memset(x , 0 , sizeof x);
#define sz(x) (int)x.size()
template<typename T> void db(T x ){ debug() <<">>> " <<  x; }
template<typename T> void db(T x , T y){ debug() <<">>> " <<  x <<" , "<< y; }
template<typename T> void db(T x , T y , T z){ debug() <<">>> "<< x <<" , "<< y <<" , "<< z; }
template<typename T> void db(T x , T y , T z , T a){ debug() <<">>> "<< x <<" , " << y <<" , "<< z <<" , "<< a; }
const int xx = 2e5;
const int Mod = 1e9 + 7;
const int inf = 1e18;
const int Maxn = 20010;
auto in = [](auto &&... args) { (cin >> ... >> args); };


int Pow(int x , int y , int mod){
  int res = 1;
  while(y>0){
      if(y&1)
          res = (res*x) % mod;
      y=y>>1;
      x = (x*x) % mod;
  }
  return res % mod;
}
long long modinv(long long a, long long m) {
    long long b = m, u = 1, v = 0;
    while (b) {
        long long t = a / b;
        a -= t * b; swap(a, b);
        u -= t * v; swap(u, v);
    }
    u %= m;
    if (u < 0) u += m;
    return u;
}

int C(int n, int k , int mod) {
    int res = 1;
    for (int i = 1; i <= k; ++i) {

      res = (res * (n - k + i) % mod) * (modinv(i, mod));
      res = res % mod;
    }
    return res % mod;
}

signed main(){
  ios::sync_with_stdio(false);cin.tie(0);
  int N, a, b;
  cin >> N >> a >> b;
  int sum = Pow(2, N , Mod) - 1;
  sum = (sum + Mod) % Mod;
  sum -= C(N, a, Mod);
  sum = (sum + Mod) % Mod;
  sum -= (C(N, b, Mod));
  sum = (sum + Mod) % Mod;
  cout << sum << '\n';
}

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

#define rep(i,n) for(int i=0; i<n; i++)
#define all(x) (x).begin(),(x).end()
#define INF (1e9)

int H,W;
char a[10][10],b[10][10];
string s;

int main(){
  cin >> H >> W;

  rep(i,H){
    rep(j,W){
      cin >> a[i][j];
    }
  }

  rep(i,H-1){
    s += "d";
  }
  rep(i,W-1){
    s += "r";
  }

  do{
    //初期化
    rep(i,H){
      rep(j,W){
        if((i==0&&j==0)){
          b[i][j] = '#';
        }else{
          b[i][j] = '.';
        }
      }
    }

    int px=0,py=0;
    //sに従って順路を作る
    rep(i,H+W-2){
      if(s[i] == 'd'){
        py++;
      }else{
        px++;
      }
      b[py][px]='#';
    }

    //一致しているかどうか判定
    bool pos=true;
    rep(i,H){
      rep(j,W){
        if(a[i][j] != b[i][j]){
          pos = false;
          i=j=INF;
        }
      }
    }

    if(pos){
      cout << "Possible" << endl;
      return 0;
    }
    
    /*rep(i,H){
      rep(j,W){
        cout << b[i][j];
      }
      cout << endl;
    }*/
    //cout << s << endl;
  }while(next_permutation(all(s)));
  cout << "Impossible" << endl;
}

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

using namespace std;

int n, m;
int a[21][(1 << 20) + 1], f[21][(1 << 20) + 1];

int main() {
	ios::sync_with_stdio(false);
	
	cin >> n >> m;
	for (int i = 0; i <= n; ++i) {
		string s;
		cin >> s;
		for (int j = 0; j < (1 << i); ++j) {
			a[i][j] = s[j] - '0';
		}
	}
	
	for (int i = 1; i <= n; ++i) {
		for (int j = 0; j < (1 << i); ++j) {
			int b = j >> (i - 1) & 1, r = 0;
			while (r < i && (j >> (i - r - 1) & 1) == b) {
				++r;
			}
			f[i][j] = r == i ? -1 : r;
		}
	}
	
	int len = 0, ans = 0;
	for (int i = 0; i <= n; ++i) {
		for (int j = 1; j <= n - i; ++j) {
			for (int k = 0; k < (1 << (i + j)); ++k) {
				a[i][k >> j] += a[i + j][k];
				int tmp = f[j][k & ((1 << j) - 1)];
				if (!~tmp) continue;
				a[i + j - tmp][((k >> j) << (j - tmp)) | (k & ((1 << (j - tmp)) - 1))] += a[i + j][k];
			}
		}
		for (int j = (1 << i) - 1; j >= 0; --j) {
			if (a[i][j] >= m) {
				len = i;
				ans = j;
			}
		}
	}
	
	for (int i = len - 1; i >= 0; --i) {
		printf("%d", ans >> i & 1);
	}
}

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


int main(void) {
  cin.tie(0);
  ios::sync_with_stdio(false);
  
  int n,x,y;
  cin >> n >> x >> y;
  x--; y--;
  vector<int> cnt(n);
  for(int i =0; i < n; ++i) {
    for(int j = i+1; j < n; ++j) {
      int dist = min(j-i, abs(j-x)+1+abs(i-y));
      dist = min(dist, abs(j-y)+1+abs(i-x));
      cnt[dist]++;
    }
  }

  for(int i = 1; i < n; ++i) {
    cout << cnt[i] << endl;
  }

  return 0;
}


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

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

	int A[100][100] = { 0 };
	int b[100] = { 0 };
	int c[100] = { 0 };

	for (int i = 0; i < n; i++) {
		for (int j = 0; j < m; j++) {
			std::cin >> A[i][j];
		}
	}

	for (int i = 0; i < m; i++) {
		std::cin >> b[i];
	}

	for (int i = 0; i < n; i++) {
		for (int j = 0; j < m; j++) {
			c[i] += A[i][j] * b[j];
		}
		std::cout << c[i] << std::endl;
	}
}

Measured memory_bytes: 1208
base_num = input()
a = int(base_num)
end_num = 0

input_list = []
while True:
    base_suit = input()
    input_list.append(base_suit)

    end_num += 1
    if a == end_num:
        break

count = [[[0 for i in range(10)] for j in range(3)] for k in range(4)]

for i in input_list:
    t = i.split(' ')
    b = int(t[0]) - 1
    f = int(t[1]) - 1
    r = int(t[2]) - 1
    v = int(t[3])

    count[b][f][r] = count[b][f][r] + v

for i, b in enumerate(count):
    for f in b:
        for r in f:
            print(" {}".format(r),end='')
        print()
    if i + 1 != len(count):
        print('####################',end='\n')




Measured memory_bytes: 5632
#include"bits/stdc++.h"
#include<unordered_set>
#include<unordered_map>
#include<random>
using namespace std;
typedef long long ll;
const ll MOD = (ll)(1e9+7);
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(), (x).end()
#define rep(i, n) for(int (i)=0; (i)<(n); (i)++)
int dx[4]={ 1,0,-1,0 };
int dy[4]={ 0,1,0,-1 };

template<typename T>
struct UnionFind{
private:
    vector<int> par;
    vector<int> siz;
    vector<T> dif;
public:
    void init(int N){
        par.resize(N);
        siz.resize(N);
        dif.resize(N);
        for(int i=0; i<N; i++){
            par[i] = i;
            siz[i] = 1;
            dif[i] = 0;
        }
    }
    void unite(int a, int b, T d){
        int rootA = root(a);
        int rootB = root(b);
        if(rootA == rootB) return;
        d += weight(a);
        d -= weight(b);
        if(siz[rootA] < siz[rootB]){
            swap(rootA, rootB);
            d *= -1;
        }
        par[rootB] = rootA;
        dif[rootB] = d;
        siz[rootA] += siz[rootB];
    }
    int root(int a){
        if(par[a] == a) return a;
        int r = root(par[a]);
        dif[a] += dif[par[a]];
        return par[a] = r;
    }
    bool same(int a, int b){
        return root(a) == root(b);
    }
    int size(int a){
        return siz[root(a)];
    }
    T weight(int a){
        root(a);
        return dif[a];
    }
    T diff(int a, int b){
        return weight(b) - weight(a);
    }
};

int N, Q;
UnionFind<int> uf;

signed main(){
	cin >> N >> Q;
    uf.init(N);
	rep(i, Q){
		int a, b, d;
        cin >> a >> b >> d;
        a--; b--;
        if(uf.same(a, b)){
            if(uf.diff(a, b) != d){
                cout << "No" << endl;
                return 0;
            }
        }
        uf.unite(a, b, d);
	}
    cout << "Yes" << endl;
}

Measured memory_bytes: 1536
#include "bits/stdc++.h"
using namespace std;
long long a[1001];
int main()
{
	int n, k;
	long long mx = 0;
	scanf("%d%d", &n, &k);
	for(int i = 1; i <= n; ++i)
	{
		scanf("%lld", &a[i]);
		a[i] += a[i - 1];
	}
	vector<long long> b(0);
	for(int i = 0; i <= n; ++i)
	{
		for(int j = i + 1; j <= n; ++j)
		{
			b.push_back(a[j] - a[i]);
		}
	}
	for(int i = 40, count = 0; i >= 0; --i, count = 0)
	{ 
		mx |= (1ll << i);
		for(long long j : b)
		{
			count += (j & mx) == mx;
		}
		if(count < k)
		{
			mx &= ~(1ll << i);
		}
	}
	printf("%lld\n", mx);
}

Measured memory_bytes: 6128
#include <bits/stdc++.h>
using namespace std;
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define sz(x) (int)(x).size()
#define F first
#define S second
#define forn(i, n) for (int i = 0; i < (int)n; i++)
#define pb push_back
#define fastIO ios::sync_with_stdio(0), cin.tie(0);
#define endl '\n'
typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;
typedef pair<int, int> pii;
int n, m;
bool ok(int i, int j) {
    return i >= 0 && i < n && j >= 0 && j < m;
}
int main() {
#ifdef LOCAL
    // freopen("in.txt", "r", stdin);
    // freopen("out.txt", "w", stdout);
#else
    fastIO;
#endif

    int n, k;
    cin >> n >> k;
    int x = ceil(log2(k));
    int ans = 0;
    ans = 1 * (1 << min(x, n));
    n -= min(x, n);
    ans += k * n;
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
n,k=map(int,input().split())
a=list(map(int,input().split()))
l=max(len(bin(k)),len(bin(max(a))))-2
ans=0
for i in range(l,-1,-1):
  b=2**i
  m=sum([1 for j in a if j&b])
  if m<n-m and b<=k:
    m=n-m
    k-=b
  ans+=b*m
print(ans)

Measured memory_bytes: 14708
N=int(input())
A=list(map(int, input().split()))
B=list(map(int, input().split()))
C=list(map(int, input().split()))

total=0
pre = -10
for i in range(len(A)):
    total += B[A[i]-1]
    if pre+1 == A[i]:
        total += C[A[i]-2]
    pre=A[i]

        
print(total)

Measured memory_bytes: 3064
from itertools import permutations

def f(a,g):
    return ((a+(g-1))//g)*g

A=int(input())
B=int(input())
C=int(input())
D=int(input())
E=int(input())

P=[A,B,C,D,E]
Q=permutations(P)

M=10**100
for (v,w,x,y,z) in Q:
    M=min(M,f(v,10)+f(w,10)+f(x,10)+f(y,10)+z)
print(M)


Measured memory_bytes: 62304
from collections import defaultdict
def d():
    tree_map = defaultdict(list)
    value_map = defaultdict(int)
    N, Q = map(int,input().split())
    
    for _ in range(1, N):
        a, b = map(int,input().split())
        tree_map[a].append(b)
        tree_map[b].append(a)

    res = [0] * N

    for _ in range(1, Q+1):
        p, x = map(int,input().split())
        res[p-1] += x
    
    stack = []
    stack.append((1, -1, 0))

    while stack:
        i, p, s = stack.pop()

        res[i-1] += s
        s = res[i-1]
        
        for j in tree_map[i]:
            if j == p:
                continue
            else:
                stack.append((j, i, s))

    print(*res)


if __name__ == "__main__":
    d()

Measured memory_bytes: 129112
#include<bits/stdc++.h>
using namespace std;
int main()
{ int n;
cin>>n;
int a[n],b[n],c[n];
for(int i=0;i<n;i++)
cin>>a[i]>>b[i]>>c[i];

int dpa[n]={0},dpb[n]={0},dpc[n]={0};
dpa[0]=a[0];
dpb[0]=b[0];
dpc[0]=c[0];
for(int i=1;i<n;i++)
{ dpa[i]=a[i]+max(dpc[i-1],dpb[i-1]);
  dpb[i]=b[i]+max(dpa[i-1],dpc[i-1]);
  dpc[i]=c[i]+max(dpa[i-1],dpb[i-1]);
}
cout<<max(dpa[n-1],max(dpb[n-1],dpc[n-1]))<<endl;
}


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

#define int long long

#define rep(i,n) for(int i=0;i<(n);i++)
#define pb push_back
#define all(v) (v).begin(),(v).end()
#define fi first
#define se second
typedef vector<int>vint;
typedef pair<int,int>pint;
typedef vector<pint>vpint;

template<typename A,typename B>inline void chmin(A &a,B b){if(a>b)a=b;}
template<typename A,typename B>inline void chmax(A &a,B b){if(a<b)a=b;}

int N;
string S;

string dp[333][333];

void latte(string &a,const string &b){
    if(a.size()>b.size()||(a.size()==b.size()&&a>b))a=b;
}

signed main(){
    fill_n(*dp,333*333,string(333,')'));
    dp[0][0]="";
    cin>>N>>S;

    S+=")";
    N++;
    for(int i=0;i<N;i++){
        for(int j=0;j<N;j++){
            latte(dp[i][j+1],dp[i][j]+"(");
        }
        for(int j=N;j>0;j--){
            latte(dp[i][j-1],dp[i][j]+")");
        }

        for(int j=0;j<=N;j++){
            if(S[i]=='('){
                latte(dp[i+1][j+1],dp[i][j]+"(");
            }
            else{
                if(j)latte(dp[i+1][j-1],dp[i][j]+")");
            }
        }
    }

    cout<<dp[N-1][0]<<endl;
    return 0;
}


Measured memory_bytes: 3840
import bisect
import sys

N,H=map(int,input().split())
AB=[list(map(int,input().split())) for i in range(N)]

AB.sort()
MAX=AB[N-1][0]

AB.sort(key=lambda x:x[1])

if AB[N-1][1]<=MAX:
    print(-(-H//MAX))
    sys.exit()


for i in range(N):
    if AB[i][1]>MAX:
        break

THRSUM=[AB[N-1][1]]
for j in range(N-2,i-1,-1):
    THRSUM.append(AB[j][1]+THRSUM[-1])

if H>=THRSUM[-1]:
    ANS=0
    H-=THRSUM[-1]
    ANS+=len(THRSUM)

    print(ANS+(-(-H//MAX)))

else:
    #print(bisect.bisect_right(THRSUM,H)+1)
    for i in range(len(THRSUM)):
        #print(i)
        if H<=THRSUM[i]:
            
            print(i+1)
            break

Measured memory_bytes: 31956
s = input()

if len(s)%2 == 0:
    mid = len(s)//2
    s_first = s[:mid]
    s_last = s[mid:]
else:
    mid = len(s)//2
    s_first = s[:mid]
    s_last = s[(mid+1):]
    
ans = 0
for i,j in zip(s_first, s_last[::-1]):
    if i!= j:
        ans += 1
        
print(ans)

Measured memory_bytes: 3064
#define _CRT_SECURE_NO_WARNINGS
#include<string>
#include<iostream>
namespace Program
{
    using namespace std;
    class Solver
    {
    private:
        static const char S = 'S';
        static const char T = 'T';

        string X;

    public:
        Solver()
        {
            cin.tie(0);
            ios::sync_with_stdio(false);

            cin >> X;
        };

        void Solve()
        {
            int stack = 0;
            int count = 0;

            for (char x : X)
            {
                switch (x)
                {
                case S:
                    stack++;
                    break;
                case T:
                    if (stack > 0)
                    {
                        stack--;
                        count += 2;
                    }
                    break;
                }
            }

            cout << X.size() - count << "\n";
        };
    };
}

int main()
{
    // メンバ関数ポインタ取得
    void (Program::Solver::*pSolve)() = &Program::Solver::Solve;

    // コンストラクタ呼び出し
    Program::Solver obj;

    // .*演算子でアクセス
    (obj.*pSolve)();
    return 0;
}


Measured memory_bytes: 720
# AOJ 0089 The Shortest Path on A Rhombic Path
# Python3 2018.6.21 bal4u

s = [[0 for i in range(100)] for j in range(100)]
w = k = 0
while 1:
	try: a = list(map(int, input().split(',')))
	except: break
	n = len(a)
	if n > w:
		w = n
		s[k+1][0] = s[k][0] + a[0]
		for i in range(1, n): s[k+1][i] = max(s[k][i-1], s[k][i]) + a[i]
		s[k+1][n-1] = s[k][n-2] + a[n-1]
	else:
		for i in range(n): s[k+1][i] = max(s[k][i], s[k][i+1]) + a[i]
	k += 1
print(s[k][0])


Measured memory_bytes: 5724
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define REP(i,s,n) for(int i=s; i<(n); ++i)
#define ALL(n) begin(n),end(n)
using ll = long long;
const ll INF = numeric_limits<long long>::max();

int main(){
    string N;
    cin >> N;
    REP(i, 0, 3){
        if (N[i] == '7') {
            cout << "Yes" << endl;
            return 0;
        }
    }
    cout << "No" << endl;

    return 0;
}


Measured memory_bytes: 3628
#include <stdio.h>
#include <string.h>
int main(void)
{
    char s[100005];
    scanf("%s", s);
    int n=0;
    while(strncmp(&s[n], "\0", 1)!=0) n++;

    int anszero=0,ansone=0,i;
    for(i=0; i<n; i++)
    {
        if(i%2==0)
        {
            if(strncmp(&s[i], "0", 1)==0)
            {
                ansone++;
            }
            else
            {
                anszero++;
            }
        }
        else
        {
            if(strncmp(&s[i], "0", 1)==0)
            {
                anszero++;
            }
            else
            {
                ansone++;
            }
        }
    }
    int ans;
    if(anszero>=ansone) ans=ansone;
    else ans=anszero;
    
    printf("%d", ans);
    return 0;
}

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

using namespace std;

#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define INF 2000000000000000000LL
#define EPS 1e-9
#define debug(a) cerr<<#a<<"="<<(a)<<"\n"
#define FastSlowInput ios_base::sync_with_stdio(false); cin.tie(NULL);

typedef long long ll;
typedef unsigned long long ull;
typedef complex<double> cd;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

const ll mod = 998244353 ;
const double PI = acos(-1);

int n,i,j,k,t;
int a[500];
ll psum[500];
ll dp[402][402];

ostream& operator<<(std::ostream& stream, const pair<ll, pii>& ot){
    stream << ot.fi <<" "<<ot.se.fi<<" "<<ot.se.se;
    return stream;
}

ll solve(int l, int r){
    ll &ans = dp[l][r];
    if(ans == -1){
        if(l == r)
            ans = 0;
        else{
            ans = psum[r] - psum[l-1];
            ll mini = solve(l+1, r);
            for(int i=l+1;i<r;++i)
                mini = min(mini, solve(l, i) + solve(i+1, r));
            ans += mini;
        }
    }
    return ans;
}

int main(){
    memset(dp, -1, sizeof dp);
    scanf("%d", &n);
    psum[0] = 0;
    for(i=1;i<=n;++i){
        scanf("%d", a+i);
        psum[i] = a[i] + psum[i-1];
    }
    ll ans = solve(1, n);
    printf("%lld\n", ans);
    return 0;
}

Measured memory_bytes: 1536
#include<iostream>

constexpr auto m_gcd(size_t m, size_t n){
    if(m == 0){
        return n;
    }else if(n == 0){
        return m;
    }else{
        return m_gcd(n, m % n);
    }
}

constexpr auto m_lcm(size_t m, size_t n){
    if(n != 0 && m != 0){
        return m * n / m_gcd(m, n);
    }else{
        return 0lu;
    }
}

int main(){

    size_t a, b;
    std::cin >> a >> b;

    std::cout << m_lcm(a, b) << std::endl;

    return 0;
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
#define fast ios_base::sync_with_stdio(0);cin.tie(0)
#define debug freopen("input", "r", stdin);freopen("output", "w", stdout)
#define endl '\n'
#define all(var) var.begin(), var.end()
typedef unsigned long long ll;
ll const MOD = 1e9+7;
using namespace std;

int main(){
    int n, k;
    cin >> n >> k;
    string s;
    while(n != 0){
        string temp = to_string(n%k);
        s.append(temp);
        n /= k;
    }
    cout << s.size() << endl;
}




Measured memory_bytes: 256
#include <bits/stdc++.h>
#define int long long
#define ALL(v) (v).begin(),(v).end()
#define Vi vector<int>
#define pb push_back
#define rep(i,a,b) for(int i=a;i<b;i++)
#define repeq(i,a,b) for(int i=a;i<=b;i++)
#define repr(i,a,b) for(int i=a;i>b;i--)
#define repreq(i,a,b) for(int i=a;i>=b;i--)
#define leng(n) (int)(log10(n)+1)
#define INF 9000000000000000000
#define MOD 1000000007
#define PAI 3.14159265358979
// ver1.6
using namespace std;

int gcd(int a,int b){return b?gcd(b,a%b):a;}  //  最大公約数gcd
int lcm(int a,int b){return a/gcd(a,b)*b;}  //  最小公倍数lcm

signed main() {
  cout << fixed << setprecision(14);
  string s;
  cin >> s;
  int l = s.size(),memo = s.size();
  rep(i,0,l){
    if(s[i]=='C'){
      memo = i;
      break;
    }
  }
  rep(i,memo,l){
    if(s[i]=='F'){
      cout << "Yes" << endl;
      return 0;
    }
  }
  cout << "No" << endl;
}

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


int main(){

    char v[3][106];

    for (int i = 0; i < 3; i++) {
        scanf("%s", v[i]);
    }

    int v1 = strlen(v[0]);
    int v2 = strlen(v[1]);
    int v3 = strlen(v[2]);

    if ((v[0][v1-1] == v[1][0]) && (v[1][v2-1] == v[2][0])){
        printf("YES\n");
    } else
        printf("NO\n");


return 0;
}


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

typedef long long ll;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef pair<ll,ll> pll;
typedef vector<bool> vb;
const ll oo = 0x3f3f3f3f3f3f3f3f;
const double eps = 1e-9;
#define sz(c) ll((c).size())
#define all(c) begin(c), end(c)
#define FOR(i,a,b) for (ll i = (a); i < (b); i++)
#define FORD(i,a,b) for (ll i = (b)-1; i >= (a); i--)
#define mp make_pair
#define mt make_tuple
#define pb push_back
#define eb emplace_back
#define xx first
#define yy second
#define has(c,i) ((c).find(i) != end(c))
#define DBGDO(X) ({ if(1) cerr << "DBGDO: " << (#X) << " = " << (X) << endl; })

int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	
	string s; cin >> s;
	list<char> a(all(s));
	auto it = begin(a);
	ll res = sz(s);
	while (it != end(a)) {
		auto nit = it;
		nit++;
		if (nit == end(a)) break;
		if (*it == 'S' && *nit == 'T') {
			res -= 2;
			auto pit = it;
			if (it == begin(a)) pit++, pit++;
			else pit--;
			a.erase(it), a.erase(nit);
			it = pit;
		} else it++;
	}
	cout << res << endl;
}


Measured memory_bytes: 6676
N,K =map(int, input().split())
V=list(map(int, input().split()))
res=0
for l in range(K+1):
    for r in range(K+1-l):
        if l+r>N: continue
        t=V[:l]+V[N-r:]
        t.sort()
        S=sum(t)
        for c in range(min(K-l-r,l+r)):
            if t[c]<0:
                S-=t[c]
        res=max(res,S)
print(res)

Measured memory_bytes: 73312
#include<stdio.h>

int main(void) {

  char A[60][60];
  char B[60][60];
  int N,M;
  int i,j;

  scanf("%d %d",&N,&M);
  for(i=0;i<N;i++){
    scanf("%s",A[i]);
  }
  for(i=0;i<M;i++){
    scanf("%s",B[i]);
  }

  int count;
  int max;
  int num;
  int x,y;
  int flag;
  int yes = 0;
  max = M * M;
  num = N - M + 1;
  for(i=0;i<num;i++){
    for(j=0;j<num;j++){
      count = 0;
      flag = 1;
      for(x=0;x<M;x++){
	for(y=0;y<M;y++){
	  if(A[i+x][j+y] == B[x][y]){
	    count++;
	  } else { 
	    flag =0;
	  }
	  if(flag==0){
	    break;
	  }
	}
	if(flag==0){
	  break;
	}
      }
      if(count==max){
	yes = 1;
      }
      if(yes){
	break;
      }
    }
    if(yes){
      break;
    }
  }

  if(yes){
    printf("Yes\n");
  } else {
    printf("No\n");
  }

  return 0;
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
const int N=3005,inf=0x3f3f3f3f;
const ld PI=3.1415926535897932384626;
int read(){
	int f=1,g=0;
	char ch=getchar();
	for (;!isdigit(ch);ch=getchar()) if (ch=='-') f=-1;
	for (;isdigit(ch);ch=getchar()) g=g*10+ch-'0';
	return f*g;
}
int n,L,a[N];
ld b[N],ansx,ansy;
int main(){
//	freopen("balance.in","r",stdin);
//	freopen("balance.out","w",stdout);
	n=read();L=read();
	for (int i=1;i<=n;i++) a[i]=read();
	for (int i=1;i<=n;i++)
	for (int j=1;j<=n;j++)
	if (i!=j){
		int d=(i<j) ? (a[i]+a[j]) : (a[i]+a[j]-L),cnt=(i<j) ? (i-1+n-j) : (i-j-1);
		ansx+=cnt*cosl(PI*d/L);
		ansy+=cnt*sinl(PI*d/L);
	}
	ll s=(ll)n*(n-1)*(n-2)/6;
	ansx/=s;ansy/=s;
	printf("%.12Lf %.12Lf\n",ansx,ansy);
	return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<iostream>
#include<string.h>
#include<algorithm>
#include<queue>
#include<stack>
#include<math.h>
#include<map>
typedef long long int ll;
using namespace std;
#define maxn 0x3f3f3f3f
int d[10000];
int main()
{
	ios::sync_with_stdio(false);
	int n,i,ss;
	cin>>n;
	for(i=0;i<n;i++)
	cin>>d[i];
	int s=0;ss=0;
	int k=n,kk=-1;
	while(1)
	{
	  if(s<=ss)
	  {
	     kk++;
		 s+=d[kk];	
	  }	
	  else
	  {
	  	k--;
	  	ss+=d[k];
	  }
	  if(kk+1==k)
	  break;
    }
    printf("%d\n",abs(ss-s));
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int run();
int main() {
// #ifdef home
//     freopen("i", "r", stdin);
//     freopen("d", "w", stderr);
// #endif
//     cout.precision(15);
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);
    run();
    return 0;
}


int run() {
    int n,a,b,c1=0,c2=0,c3=0;
    cin>>n>>a>>b;
    int A[101];
    for(int i=1;i<=n;i++){
        int x;
        cin>>x;
        A[i]=x;
        if(x<=a)
            c1++;
        if(x>=a+1 && x<=b) c2++;
        if(x>=b+1) c3++;
    }
    cout<<min(min(c1,c2),c3);
}



Measured memory_bytes: 256
// #include "pch.h"
#include <iostream>
#include <algorithm>
#include <map>
#include <set>
#include <queue>
#include <bitset>
#include <limits.h>
#include <string>
#include <stack>
#include <deque>
#include <cmath>
#include <bitset>
#include <complex>
#include <functional>
#include <time.h>
#include <cassert>
#include <fstream>
#include <stdio.h>
#include<unordered_map>

typedef long long ll;
typedef std::pair<int, int> Pii;
typedef std::pair<long long, long long> Pll;
typedef std::pair<double, double> Pdd;

#define rip(i, n, s) for (int i = (s);i < (int)( n ); i++)
#define mapa make_pair
#define all(a) a.begin(), a.end()
#define MM << " " <<

template<typename T>
using MaxHeap = std::priority_queue<T>;
template<typename T>
using MinHeap = std::priority_queue<T, std::vector<T>, std::greater<T>>;

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;
}

template<typename T>
std::vector<T> vec(int len, T elem) { return std::vector<T>(len, elem); }
template<typename T>
void vdeb(std::vector<T> &da) {
	for (int i = 0;i < da.size();i++) {
		if (i == da.size() - 1) std::cout << da[i];
		else std::cout << da[i] << ' ';
	}
	std::cout << std::endl;
}
template<typename T>
void vdeb(std::vector<std::vector<T>> &da) {
	for (int i = 0;i < da.size();i++) vdeb(da[i]);
	std::cout << std::endl;
}

using namespace std;

int main(){
	vector<int> co(200000);
	int n; cin >> n;
	rip(i,n,0){
		int a; cin >> a;
		co[a] ++;
		co[a+1] ++;
		if(a > 0) co[a-1] ++; 
	}
	int ans = 0, id = -1;
	rip(i,200000,0) chmax(ans, co[i]);
	cout << ans << endl;
}

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

using namespace std;
using ll=long long;
#define rep(i, n) for(int i = 0; i < n; i++)
#define rep2(i, a, n) for(int i = (n); i < (a); i++)

int main(){
  cin.tie(nullptr);ios_base::sync_with_stdio(false);
  cout << fixed << setprecision(15);
  int a,b;cin>>a>>b;
  if(abs(a+b)%2==0 ) cout<<abs(a+b)/2<<endl;
  else cout<<"IMPOSSIBLE"<<endl;
}


Measured memory_bytes: 256
//#pragma GCC optimize("O3")
#include<bits/stdc++.h>
#define ll long long int
#define ld long double
#define pb push_back
#define mp make_pair
#define mod 1000000007
#define fio ios_base::sync_with_stdio(false);cin.tie(NULL);
#define all(x) x.begin(),x.end()
#define F first
#define S second
#define fo(i,n) for(int i=0;i<(n);i++)
#define inp(a) int a;cin>>a;
#define inpa(a,n)vector<int> a(n);fo(i,n)cin>>a[i];
#define printclock cerr<<"Time : "<<1000*(ld)clock()/(ld)CLOCKS_PER_SEC<<"ms\n";
using namespace std;
#define int ll
// #define MAX 20
#define INF (int)1e18

template<class T> ostream& operator<<(ostream& cout,vector<T> V)
{cout<<"[ ";for(auto v:V)cout<<v<<' ';return cout<<']';}
template<class L,class R> ostream& operator<<(ostream& cout,pair<L, R> P)
{return cout<<'('<<P.F<<','<< P.S<<')';}


signed main()
{
	fio
	inp(n)
	int ans=0;
	for(int i=1;i<=n;i++)
	{
		if(i%3 && i%5)
			ans+=i;
	}
	cout<<ans<<endl;
	printclock;
}

Measured memory_bytes: 3804
import std.stdio;	
import std.array;	
import std.conv;	
import std.math;
import std.string;

void main()
{
	int[] addinput = new int[200];
	int anslength;
	string s;
	int i = -1;
	while( (s=readln()).length > 1 )
	{
		i ++;
		anslength = i;
		string[] input = split(s);
		int a = to!int(input[0]); 
		int b = to!int(input[1]); 
		addinput[i] = cast(int)log10(a + b) + 1;
	}
	for(int j = 0; j <= anslength; j++)
	{
		writeln(addinput[j]);
	}
}

Measured memory_bytes: 1056
#include <bits/stdc++.h>
using namespace std;
#define repd(i,a,b) for (int i=(a);i<(b);i++)
#define rep(i,n) repd(i,0,n)
#define all(x) (x).begin(),(x).end()
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; }
typedef long long ll;
const long long INF = 1LL << 60;
typedef pair<int, int> P;
int main()
{
    int N, x = 0, ans = 0;
    string S;
    cin >> N >> S;

    rep(i, N) {
        if (S[i] == 'I') x++;
        else x--;
        chmax(ans, x);
    }

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

Measured memory_bytes: 256
#include<stdio.h>

int A[50],n;

int solve(int i,int m){
  int res;

  if (m==0)return 1;
  if (i>=n)return 0;
  res = solve(i+1,m) || solve(i+1,m-A[i]);
  return res;

}
int main(){
  int i,j;
  int q,m;

  scanf("%d",&n);
  if(n<0 || n>20)return 0;

  for(i=0 ; i<n ; i++){
    scanf("%d",&A[i]);
    if(A[i] < 1 || A[i] > 200)return 0;
  }

  scanf("%d",&q);
  if(q < 0 || q > 200)return 0;

  for(i = 0 ; i < q ; i++){
    scanf("%d",&m);
    if(solve(0,m) == 1)printf("yes\n");
    else printf("no\n");
  }
  return 0;
}



Measured memory_bytes: 2100
#include <bits/stdc++.h>
using namespace std;
 
#define MOD 1000000007
#define INF  2000000000
#define int ll
#define ll long long
#define ld long double
#define vi vector<int>
#define pa pair<int, int>
#define pb push_back
#define mp make_pair
 
#define INIT ios::sync_with_stdio(false);cin.tie(0);
#define VAR(type, ...)type __VA_ARGS__;MACRO_VAR_Scan(__VA_ARGS__);
template<typename T> void MACRO_VAR_Scan(T& t) { cin >> t; }
template<typename First, typename...Rest>void MACRO_VAR_Scan(First& first, Rest&...rest) { cin >> first; MACRO_VAR_Scan(rest...); }
#define VEC(type, c, n) vector<type> c(n);for(auto& i:c)cin>>i;
#define MAT(type, c, m, n) vector<vector<type>> c(m, vector<type>(n));for(auto& r:c)for(auto& i:r)cin>>i;
 
#define BR cout << "\n";
#define SP cout << " ";
#define ENDL cout<<endl;
#define OUT(d) cout<<(d);
#define OUTL(d) cout<<(d)<<endl;
#define YES OUTL("YES")
#define Yes OUTL("Yes")
#define NO OUTL("NO")
#define No OUTL("No")
#define RET return 0;
#define SUM(a, n) accumulate(a, a+n, 0)
#define VSUM(v) accumulate(ALL(v), 0);
 
#define REP(i, n) for(int i=0;i<(n);i++)
#define RREP(i, n) for(int i=n-1;i>=0;--i)
#define FOR(i, m, n) for(int i = m;i < n; i++)
#define RFOR(i, a, b) for(int i=(a)-1;i>=(b);--i)
#define AREP(a, n) for(auto (a):(n))
#define ALL(a) (a).begin(),(a).end()
#define IN(n, a, b) ((a)<=(n)&&(n)<(b))

signed main(){ INIT;
    VAR(int, n);
    vi c(n), s(n), f(n);
    REP(i, n-1){
        cin >> c[i] >> s[i] >> f[i];
    }
    REP(i, n-1){
        int time = 0;
        FOR(j, i, n-1){
            int t = 0;
            while(time > s[j] + f[j] * t){
                t++;
            }
            time = s[j] + f[j] * t + c[j];
        }
        OUTL(time);
    }
    OUTL(0);
RET;}

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

#define CPP_STR(x) CPP_STR_I(x)
#define CPP_CAT(x,y) CPP_CAT_I(x,y)
#define CPP_STR_I(args...) #args
#define CPP_CAT_I(x,y) x ## y

using i8  = int8_t;
using u8  = uint8_t;
using i16 = int16_t;
using u16 = uint16_t;
using i32 = int32_t;
using u32 = uint32_t;
using i64 = int64_t;
using u64 = uint64_t;

using f32 = float;
using f64 = double;

#define FOR(i, start, end) for(i64 i = (start), CPP_CAT(i,xxxx_end)=(end); i < CPP_CAT(i,xxxx_end); ++i)
#define REP(i, n) FOR(i, 0, n)
#define REPS(i, n) for(i64 i = 1; i <= n; ++i)
#define RREP(i, n) for(i64 i = n - 1; i >= 0 ; --i)
#define RREPS(i, n) for(i64 i = n; i >= 1; --i)

#define ALL(f,c,...) (([&](decltype((c)) cccc) { return (f)(std::begin(cccc), std::end(cccc), ## __VA_ARGS__); })(c))

#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );

#define pb push_back
#define mp make_pair
#define F first
#define S second

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

template<typename C>
i64 SIZE(const C& c) { return static_cast<i64>(c.size()); }

template<typename T, size_t N>
i64 SIZE(const T (&)[N]) { return static_cast<i64>(N); }


struct ProconInit {
    static constexpr int IOS_PREC = 15;
    static constexpr bool AUTOFLUSH = false;

    ProconInit() {
        cin.tie(nullptr);
        ios::sync_with_stdio(false);
        cout << fixed << setprecision(IOS_PREC);
        if(AUTOFLUSH)
            cout << unitbuf;
    }
} PROCON_INIT;


int main() {
    i64 A, B, C, X, Y;
    cin >> A >> B >> C >> X >> Y;

    i64 cost = 0;
    i64 ab = min(A + B, 2 * C);
    cost += min(X, Y) * ab;
    if (X >= Y) {
        cost += (X - Y) * min(A, 2 * C);
    } else {
        cost += (Y - X) * min(B, 2 * C);
    }
    cout << cost << endl;

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
int main() {
  int h, a, count=0;
  scanf("%d %d", &h, &a);
  while (h > 0) {
    h-=a;
    count++;
  }
  printf("%d\n", count);
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
using namespace __gnu_pbds;   
#define ll long long
#define ull unsigned long long
// #define ordered_set tree<pair<ll, ll>, null_type, less<pair<ll, ll>>, rb_tree_tag, tree_order_statistics_node_update> 
ll mod=1e9+7;
#define PI 3.1415926535897932385
#define inf 9e18
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);
string char_to_str(char c){string tem(1,c);return tem;}
typedef pair<long long, long long> ii;
#define S second
#define F first
ll max(ll a,ll b){if(a>b){return a;}return b;}
ll min(ll a,ll b){if(a<b){return a;}return b;}
#define MAXN 200005
// Comment this out for interactice problem
// #define endl '\n'
// string to integer stoi() Remember: it takes string not character
// string to long long stoll()
// string.substr(position,length);
// integer to string to_string();
 
// To compile--> g++ -std=c++0x -o output one.cpp
// To run--> ./output

int main() 
{ 
    fastio;
    // freopen("input.txt","r",stdin);
    // freopen("output.txt","w",stdout);

    ll a,v;
    ll b,w;
    ll t;
    cin>>a>>v>>b>>w>>t;
    
    if(v<=w){
        cout<<"NO";
    }
    else{
        ll dis = abs(a-b);
        ll vel = abs(v-w);
        ll cov = vel*t;
        if(cov>=dis){
            cout<<"YES";
        }
        else{
            cout<<"NO";
        }
    }

    return 0;
}

Measured memory_bytes: 3612
#include <algorithm>
#include <cassert>
#include <cctype>
#include <chrono>
#define _USE_MATH_DEFINES
#include <cmath>
#include <cstdio>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iostream>
#include <map>
#include <queue>
#include <random>
#include <set>
#include <sstream>
#include <string>
#include <tuple>
#include <vector>
using namespace std;

#define FOR(i,m,n) for(int i=(m);i<(n);++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) (v).begin(),(v).end()

const int INF = 0x3f3f3f3f, MOD = 1000000007;
const long long LINF = 0x3f3f3f3f3f3f3f3fLL;
/*-----------------------------------------*/
using CostType = long long;
struct Edge {
  int src, dst;
  CostType cost;
  Edge(int src_, int dst_, CostType cost_ = 0) : src(src_), dst(dst_), cost(cost_) {}
  inline bool operator<(const Edge &rhs) const {
    return cost != rhs.cost ? cost < rhs.cost : dst != rhs.dst ? dst < rhs.dst : src < rhs.src;
  }
  inline bool operator<=(const Edge &rhs) const { return cost <= rhs.cost; }
  inline bool operator>(const Edge &rhs) const {
    return cost != rhs.cost ? cost > rhs.cost : dst != rhs.dst ? dst > rhs.dst : src > rhs.src;
  }
  inline bool operator>=(const Edge &rhs) const { return cost >= rhs.cost; }
};

vector<int> color;
bool dfs(const vector<vector<Edge> > &graph, int ver, int now) {
  color[ver] = now;
  for (Edge e : graph[ver]) {
    int nx = e.dst;
    if (color[nx] == now || (color[nx] == 0 && !dfs(graph, nx, -now))) return false;
  }
  return true;
}
bool is_bipartite(const vector<vector<Edge> > &graph) {
  int sz = graph.size();
  color.assign(sz, 0);
  REP(i, sz) if (color[i] == 0) {
    if (!dfs(graph, i, 1)) return false;
  }
  return true;
}

int main() {
  cin.tie(0); ios::sync_with_stdio(false);
  // freopen("input.txt", "r", stdin);

  long long n; int m; cin >> n >> m;
  vector<vector<Edge> > graph(n);
  REP(i, m) {
    int a, b; cin >> a >> b; --a; --b;
    graph[a].emplace_back(Edge(a, b));
    graph[b].emplace_back(Edge(b, a));
  }
  if (is_bipartite(graph)) {
    long long black = 0, white = 0;
    REP(i, n) {
      if (color[i] == 1) ++black;
      else ++white;
    }
    cout << black * white - m << '\n';
  } else {
    cout << n * (n - 1) / 2 - m << '\n';
  }
  return 0;
}


Measured memory_bytes: 8448
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define pb push_back
#define fi first
#define se second
typedef pair<ll, ll> P;
using VP = vector<P>;
using VVP = vector<VP>;
using VI = vector<ll>;
using VVI = vector<VI>;
using VVVI = vector<VVI>;
const int inf = 1e9 + 7;
const ll INF = 1LL << 61;
const ll mod = 1e9 + 7;

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

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

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int i, j;
    int a;
    cin >> a;
    cout << a + a * a + a * a * a << endl;
}

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

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
	int n;
	cin >> n;
	map<string, int> mp;
	while (n--) {
		string s;
		cin >> s;
		sort(s.begin(), s.end());
		mp[s]++;
	}	
	ll ans = 0;
	for (auto it = mp.begin(); it != mp.end(); it++) {
		ll n = it -> second;
		ans += n * (n - 1) / 2;
	}
	cout << ans << "\n";
	return 0;
}


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

int main(){
  int a, b;
  cin >> a >> b;
  int ans=0;
  for(int i=0;i<2;i++){
    if(a>b){
      ans += a;
      a--;
    }
    else{
      ans += b;
      b--;
    }
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <fstream>
#include <string> 
#include <cmath>  
#include <cstdlib>
#include <ctime>
#include <vector>
#include <algorithm>
#include <numeric>
#include <map>
#include <set>
#include <functional>

#define FOR(i, m, n) for(int i = (m);i < (n);i++)
#define REP(i,n) for(int i = 0; i < int(n); i++)
#define VI vector<int>
#define VVI vector<vector<int>>
#define VVVI vector<vector<vector<int>>>

using namespace std;
using ll = long long;

int main() {
	int N, K;
	cin >> N >> K;
	VI A(N),B(N,0);
	REP(i, N) {
		int a;
		cin >> a;
		A[a - 1] = 1;
		B[a - 1]++;
	}
	if (accumulate(A.begin(), A.end(), 0) <= K) {
		cout << 0 << endl;
		return 0;
	}
	sort(B.begin(), B.end(), greater<int>());
	cout << accumulate(B.begin() + K, B.end(), 0) << endl;
	


	
	return 0;
}

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

using namespace std; 
  
const int N = 5e5 + 10; 
  
struct Q { 
  int l, r, idx; 
}; 

Q queries[N]; 
int ans[N], vis[N], a[N], bit[N]; 

bool cmp(Q x, Q y) { 
  return x.r < y.r; 
} 
  
void update(int i, int val, int n) { 
  while (i <= n) {
    bit[i] += val;
    i += i & -i;
  }
} 
  
int query(int i, int n) { 
  int sum = 0; 
  while (i) { 
    sum += bit[i]; 
    i -= i & -i;
  }
  return sum; 
} 

int main() 
{ 
  int n, q;
  cin >> n >> q;
  for (int i = 0; i < n; ++i) {
    cin >> a[i];
    vis[i + 1] = -1;
  }
  for (int i = 0; i < q; ++i) {
    int x, y;
    cin >> x >> y;
    queries[i].l = x - 1;
    queries[i].r = y - 1;
    queries[i].idx = i;
  }
  sort(queries, queries + q, cmp);   
  int c = 0; 
  for (int i = 0; i < n; i++) { 
    if (vis[a[i]] != -1) {
      update(vis[a[i]] + 1, -1, n); 
    }
    vis[a[i]] = i; 
    update(i + 1, 1, n); 
    while (c < q && queries[c].r == i) { 
      ans[queries[c].idx] = query(queries[c].r + 1, n);
      ans[queries[c].idx] -= query(queries[c].l, n); 
      ++c; 
    }
  } 
  for (int i = 0; i < q; i++) {
    cout << ans[i] << '\n'; 
  } 
  return 0; 
} 

Measured memory_bytes: 17412
n,m=map(int,input().split())
a_all=[]
for i in range(n):
            a=list(input())
            a_all.append(a)

for i in range(n+2):
            if i==0 or i==n+1:
                        c=['#']*(m+2)
                        d="".join(c)
                        print(d)        
            else:
                        #print('i',i)
                        e=['#']+a_all[i-1]+['#']
                        f="".join(e)
                        print(f)
                                    
            


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

using namespace std;

#define ALL(x) (x).begin(), (x).end()
#define AND(x,y,z) 
#define DUMP(xs) for (auto x:xs) cout<<x<<' ';cout<<endl
#define DUMPP(xs) for (auto x:xs) cout<<'('<<x.first<<','<<x.second<<')';cout<<endl
#define FOR(i,a,b) for (ll i=(ll)(a);i<(ll)(b);++i)
#define OUT(x) cout<<x<<endl
#define REP(i,n) FOR(i,0,n)
#define YES(cond) cond ? OUT("YES") : OUT("NO")
#define Yes(cond) cond ? OUT("Yes") : OUT("No")

template<class T> T gcd(const T x,const T y){if(!y){return x;}return gcd(y,x%y);}
template<class T> T lcm(const T x,const T y){return x/gcd(x,y)*y;};
template<class T> T modpow(const T x,const T n,const T mod) {
  T res=1;while(n>0){if(n%2)res=res*x%mod;x=x*x%mod;n/=2;};return res;
}
template<class T> bool alltrue(const T &a){return all_of(ALL(a),[](bool x){return x;});}
template<class T> bool anytrue(const T &a){return any_of(ALL(a),[](bool x){return x;});}
template<class T> bool contain(const T &a,const T &b){for(auto x:b){if (a.find(x)==a.end()){return false;}}return true;}
template<class T> bool mmax(T &m,const T q){ if (m < q) {m = q; return true;} else return false; }
template<class T> bool mmin(T &m,const T q){ if (m > q) {m = q; return true;} else return false; }
template<class T> int siz(const T &a) {return (int)a.size();}
template<class T> set<T> devisers(T n) {
  set<T> res;for(T i=1;i<(T)sqrt(n)+1;i++){if(n%i==0){res.insert(i);res.insert(n/i);}}return res;
}
template<class T> void concat(T &a, const T &b){a.insert(a.end(),b.begin(),b.end());}
template<class T> void getand(const T &a,const T &b,T &c) {
  set_intersection(a.begin(),a.end(),b.begin(),b.end(),inserter(c,c.end()));
}
template<class T> void getor(const T &a,const T &b,T &c) {
  set_union(a.begin(),a.end(),b.begin(),b.end(),inserter(c,c.end()));
}

typedef long long ll;
typedef pair<ll, ll> P;

const ll MOD=1e9+7;
const int MAX=1e5+100;

int main() {
  // 末尾につく0の数
  // 計算はN*(N-2)*(N-4)....*1となる
  // Nが奇数の場合は、2の倍数が登場しないため0
  // f(n)で登場する数の、5の素因数の合計
  ll N;cin>>N;

  if (N%2==1) {
    OUT(0);
    return 0;
  }

  ll ans = 0;
  ll cur = 10;
  while (cur<=N) {
    ans += N/cur;
    cur *= 5;
  }
  OUT(ans);

  return 0;
}

Measured memory_bytes: 256