akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;

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

  for (int i = 0; i < N; i++) {
    string S;
    cin >> S;
    
    if (S == "Y") {
      cout << "Four" << endl;
      break;
    }
    
    if (i == N-1) cout << "Three" << endl;
  }
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <numeric>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <array>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
using namespace std;
typedef long long unsigned int ll;

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))

int GCD(const int& a, const int& b){
   const int& _a = max(a,b);
   const int& _b = min(a,b);
   if(_a % _b == 0){
      return _b;
   }
   else{
      return GCD(_b, _a % _b);
   }
}

int LCM(const int& a, const int& b){
   const int& _a = max(a,b);
   const int& _b = min(a,b);
   return (_a*_b)/(GCD(_a, _b));
}

int main(){
   int N;
   cin >> N;
   vector<int> l(N), r(N);
   for(int i = 0; i < N; i++){
      cin >> l[i] >> r[i];
   }

   int ans = 0;
   for(int i = 0; i < N; i++){
      for(int j = l[i]; j <= r[i]; j++){
         ans++;
      }
   }

   cout << ans << endl;

   return 0;
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main(){
  int N,M,X,A[101],hoge;
  int Cost_toFront = 0,Cost_toBack = 0;
  cin >> N >> M >> X;
  for (int j = 0; j < N; j++)A[j] = 0;

  int i = 0;
  while(i < M){
    cin >> hoge;
    A[hoge] = 1;
    i++;
  }

  for (int i = 0; i < X; i++){
    if (A[X-i] == 1){
      Cost_toFront ++;
    }
  }
  for (int i = 0; i < N-X; i++){
    if (A[X+i] == 1){
      Cost_toBack ++;
    }
  }
  if (Cost_toBack >= Cost_toFront){
    cout << Cost_toFront <<endl;
  }else{
    cout << Cost_toBack <<endl;
  }
}


Measured memory_bytes: 256
#include<stdio.h>
int main()
{
    int a,b,c,x,y,i,ans[3];
    scanf("%d %d %d %d %d",&a,&b,&c,&x,&y);
    //A+B
    ans[0]=x*a+y*b;
    //C
    if(x>y)
    {
        ans[1]=x*c*2;
        ans[2]=(x-y)*a+y*c*2;
    }
    else
    {
        ans[1]=y*c*2;
        ans[2]=(y-x)*b+x*c*2;
    }
    int min=ans[0];
    for(i=1;i<3;i++)
    {
        if(min>ans[i])
            min=ans[i];
    }
    printf("%d\n",min);
    return 0;
}


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

int main() {
  int a, b, c, d, x;
  cin >> d;
  a = d / 100;
  b = (d  - a * 100) / 10;
  c = d - a * 100 - b * 10;
  x = a + b + c;
  cout << x << endl;
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
#define FAST_IO                     \
  ios_base::sync_with_stdio(false); \
  cin.tie(0);                       \
  cout.tie(0);
typedef long long ll;
/**
 * Uncomment the #define below if problem contains multiple test cases
 */
// #define MULTIPLE_TESTS 1
template <typename T>
inline void readArray(vector<T>& arr, int n) {
  arr.resize(n);
  for (auto& element : arr) {
    cin >> element;
  }
}
void solve() {
  int n;
  cin >> n;
  map<ll, ll> cnt;
  ll x;
  ll sum = 0;
  for (int i = 0; i < n; ++i) {
    cin >> x;
    ++cnt[x];
    sum += x;
  }
  int q;
  cin >> q;
  ll b, c;
  for (int i = 0; i < q; ++i) {
    cin >> b >> c;
    sum -= b * cnt[b];
    sum -= c * cnt[c];
    cnt[c] += cnt[b];
    cnt[b] = 0;
    sum += c * cnt[c];
    cout << sum << endl;
  }
}

int main() {
  FAST_IO;
  int t = 1;
#ifdef MULTIPLE_TESTS
  cin >> t;
#endif

  while (t--) {
    solve();
  }

  return 0;
}

Measured memory_bytes: 9520
#include<bits/stdc++.h>
using namespace std;
using ll=long long;
using ld=long double;
using P=pair<ll,ll>;
#define MOD 1000000007ll
#define INF 1000000000ll
#define EPS 1e-7
#define FOR(i,n,m) for(ll i=n;i<(ll)m;i++)
#define REP(i,n) FOR(i,0,n)
#define DUMP(a) REP(d,a.size()){cout<<a[d];if(d!=a.size()-1)cout<<" ";else cout<<endl;}
#define ALL(v) v.begin(),v.end()
#define UNIQUE(v) sort(v.begin(),v.end());v.erase(unique(v.begin(),v.end()),v.end());
#define pb push_back

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	ll n,p,q;
	cin>>n>>p>>q;
	vector<ll> c(n);
	REP(i,n) cin>>c[i];
	ll sum=0;
	REP(i,n) sum+=c[i];
	ll ans=sum;
	vector<ll> diff(n);
	REP(i,n) diff[i]=p*(q-i)-c[i];
	sort(ALL(diff));
	ll buf=0;
	FOR(i,1,n+1) {
		buf+=diff[n-i]+2*p*(i-1);
		ans=max(ans,sum+buf);
	}
	cout<<ans<<endl;
	return 0;
}



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

int main() {
  int N, M;
  cin >> N >> M;
  vector<int> ss(M);
  vector<int> cs(M);
  rep(i, M) {
    cin >> ss[i] >> cs[i];
  }
  int ans = -1;
  rep(i, 1000) {
    string str = to_string(i);
    if (str.size() != N) continue;
    bool isAnswer = true;
    rep(j, M) {
      int s = ss[j];
      int c = cs[j];
      if (str[s-1] != '0' + c) {
        isAnswer = false;
        break;
      }
    }
    if (isAnswer) {
      ans = i;
      break;
    }
  }
  cout << ans << endl;
  return 0;
}


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

bool can_pile(vector<int> v,int n,int k,int p){
  int l=0;
  for(int i=0;i<n;i++){
    if(l+v[i]>p){
      l=v[i];k-=1;
    }else if(l+v[i]<p){
      l+=v[i];
    }else{
      l=0;k-=1;
    }
  }
  if(l!=0){k-=1;}
  return k>=0;
}



//合計以下でmax以上
int main(){
  int N,K;cin >> N >> K;
  vector<int> V(N);for(int i=0;i<N;i++) cin >> V[i];
  //vectorはmax_element
  int k1=*max_element(V.begin(),V.end());
  int k2=0;for(int i=0;i<N;i++) k2+=V[i];
  while(k2-k1>1){
    int l=(int)((k1+k2)/2);
    if(can_pile(V,N,K,l)){
      k2=l;
    }else{
      k1=l;
    }
  }
  if(can_pile(V,N,K,k1)){
    cout << k1 << endl;
    //cout << 0 << endl;
  }else{
    cout << k2 << endl;
  }


}



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

using namespace std;

#define rep(i,n) for(int i=0;i<(n);i++)
#define repa(i,a,n) for(int i=(a);i<(n);i++)
#define rrep(i,n) for(int i=n;i>=0;i--)
#define rrepa(i,a,n) for(int i=n;i>=(a);i--)
#define all(a) (a).begin(),(a).end()
#define MOD 1000000007
#define cmax(a,b) a=max(a,b)
#define cmin(a,b) a=min(a,b)
#define vc vector

typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef pair<int,int> pi;

int main(){

    ll a,b,n;
    cin>>a>>b>>n;


    ll ans1=((a*n)/b),m1=n/b;
    ans1-=a*m1;

    if(n>=b)n-=1+(n%b);

    ll ans2=((a*n)/b),m2=n/b;
    ans2-=a*m2;

    cout<<max(ans1,ans2)<<"\n";
    
    return 0;
}

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

struct ModInt {
    using M = ModInt;
    long long v;
    ModInt(long long _v = 0) : v(_v % MOD + MOD) { norm(); }
    M &norm() {
        v = (v < MOD) ? v : v - MOD;
        return *this;
    }
    M operator+(const M &x) const { return M(v + x.v); }
    M operator-(const M &x) const { return M(v + MOD - x.v); }
    M operator*(const M &x) const { return M(v * x.v % MOD); }
    M operator/(const M &x) const { return M(v * x.inv().v); }
    M &operator+=(const M &x) { return *this = *this + x; }
    M &operator-=(const M &x) { return *this = *this - x; }
    M &operator*=(const M &x) { return *this = *this * x; }
    M &operator/=(const M &x) { return *this = *this / x; }
    friend istream &operator>>(istream &input, M &x) {
        return input >> x.v, x.norm(), input;
    }
    friend ostream &operator<<(ostream &output, const M &x) {
        return output << x.v;
    }
    M pow(long long n) const {
        M x(v), res(1);
        while (n) {
            if (n & 1)
                res *= x;
            x *= x;
            n >>= 1;
        }
        return res;
    }
    M inv() const { return this->pow(MOD - 2); }

    static long long MOD;
    static vector<M> fact, finv;
    static void build(int n) {
        fact.assign(n + 1, 1);
        finv.assign(n + 1, 1);
        for (int i = 1; i < n + 1; i++)
            fact[i] = fact[i - 1] * M(i);
        for (int i = 0; i < n + 1; i++)
            finv[i] = fact[i].inv();
    }
    static M comb(int n, int k) {
        if (n < k || k < 0)
            return M(0);
        return fact[n] * finv[n - k] * finv[k];
    }
    static M extgcd(int a, int b, int *x, int *y) {
        M d(a);
        if (b) {
            d = extgcd(b, a % b, y, x);
            *y -= (a / b) * *x;
        } else {
            *x = 1, *y = 0;
        }
        return d;
    }
};
vector<ModInt> ModInt::fact = vector<ModInt>();
vector<ModInt> ModInt::finv = vector<ModInt>();
long long ModInt::MOD = 1e9 + 7;

const int maxn = 100001;
ModInt dp[maxn][2];

int n;
vector<vector<int>> graph;
vector<bool> visited;

/* 
木DP。
*/
void dfs(int i) {
    visited[i] = true;
    dp[i][0] = 1; dp[i][1] = 1;
    for(int j : graph[i]) {
        if (visited[j]) continue;
        dfs(j);
        dp[i][0] *= dp[j][0] + dp[j][1];
        dp[i][1] *= dp[j][0];
    }
    return;
}

int main() {
    cin >> n;
    graph.resize(n);
    visited.resize(n);
    rep(i, n-1) {
        int x, y;
        cin >> x >> y;
        x--; y--;
        graph[x].push_back(y);
        graph[y].push_back(x);
    }
    dfs(0);
    cout << dp[0][0] + dp[0][1] << endl;
    return 0;
}

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

int main() {
	int i;
	int x;
	int y;

	i = 0;

	while (i < 3000) {
		i = i + 1;
		cin >> x >> y;
		if (x == 0 && y==0) {
			break;
		}
		int max;
		int min;

		if (x > y) {
			max = x;
			min = y;
		}
		else {
			max = y;
			min = x;
		}

		cout << min << " " << max << endl;
	}

	return 0;
}


Measured memory_bytes: 2980
#include <bits/stdc++.h>
using namespace std;
#define REP(i,n) for(int i=0;i<(n);i++)
#define N 100000
typedef long long ll;
#define ALL(v) (v).begin(),(v).end()
#define SZ(x) int(x.size())
#define OUT(a) cout<<(a)<<endl
typedef pair<int,int> P; 
#define INF 100000000
const int MAX = 1000000;
const int MOD = 1000000007;
int main(){
   int a,b;
   cin>>a>>b;
   OUT(6-a-b);
    return 0;
}

Measured memory_bytes: 256
import math
def main():
    a, b, h, m = map(float, input().split())
    rshort = 30*h + m*1/2
    rlong = 6*m
    ang = abs(rlong-rshort)
    ans = a**2 + b**2 -2*a*b*math.cos(math.radians(ang))
    return print(math.sqrt(ans))

if __name__ == '__main__':
    main()


Measured memory_bytes: 9440
fun main(args: Array<String>) {
    val N = readInt()
    val list = (0 until N).map{readIntList()}.toList()
    var ans = 0.0
    var num = 0

    fun f(xy:List<Int>, sum:Double, mada:List<Int>){
        if (mada.size == 0){
            ans += sum
            num++
            return
        }
        for (n in mada){
            val dist = Math.sqrt((xy[0]-list[n][0]).pow(2) + (xy[1]-list[n][1]).pow(2))
            f(list[n], sum+dist, mada.minus(n))
        }
    }
    val mada = (0 until N).toList()
    for (n in mada)
        f(list[n], 0.0, mada.minus(n))

    println(ans/num)
}

fun readString() = readLine()!!
fun readInt() = readLine()!!.toInt()
fun readLong() = readLine()!!.toLong()
fun readIntList() = readLine()!!.split(" ").map(String::toInt)
fun readLongList() = readLine()!!.split(" ").map(String::toLong)

fun Int.pow(n:Int) = Math.pow(this.toDouble(), n.toDouble())

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

constexpr int64_t INF = 1'010'000'000'000'000'017LL;
constexpr int64_t MOD = 1'000'000'007LL;
constexpr double EPS = 1e-12;
constexpr double PI = 3.14159265358979323846;

#define FOR(i, start, end) for(int64_t i=start; i<end; i++)
#define REP(i, n) FOR(i, 0, n)

// 最大公約数gcd
uint64_t gcd(uint64_t m, uint64_t n) {
  uint64_t temp;
  while (m % n != 0){
    temp = n;
    n = m % n;
    m = temp;
  }
  return n;
}

// 最小公倍数lcm=m*n/gcd
uint64_t lcm(uint64_t m, uint64_t n) {
  return (m*n)/gcd(m,n);
}

// nCm
void comb(vector<vector <uint64_t> > &v){
  for(uint64_t i = 0;i <v.size(); i++){
    v[i][0]=1;
    v[i][i]=1;
  }
  for(uint64_t k = 1;k <v.size();k++){
    for(uint64_t j = 1;j<k;j++){
      v[k][j]=(v[k-1][j-1]+v[k-1][j]);
    }
  }
}

signed main() {
  int64_t n, m;
  cin >> n >> m;

  vector<int64_t> H(n,0);
  map<int64_t, set<int64_t>> road;
  REP(i, n){
    cin >> H[i];
    road[i] = {};
  }

  int64_t a, b;
  REP(i, m){
    cin >> a >> b;
    road[a-1].insert(b-1);
    road[b-1].insert(a-1);
  }
  
  int64_t count = 0;
  REP(i, n){
    bool isGood = true;
    for(auto neighbor: road[i]){
      if(H[neighbor]>= H[i]) isGood = false;
    }
    if(isGood)count++;
  }

  cout << count;
  return 0;
}

Measured memory_bytes: 22744
#include <bits/stdc++.h>
#define MAX 100001

using namespace std;

int A[MAX];
int WA[MAX];
int n, maior;

int mdc(int x, int y){
	if(x == -1){
		return y;
	}
	if(y == -1){
		return x;
	}
	return __gcd(x,y);
}

void conquer(int i1, int j1, int i2, int j2){
	int left = mdc(A[i1],WA[i1]);
	int right = mdc(A[i2],WA[i2]);
	for(int i = i1; i <= j1; i++){
		WA[i] = mdc(WA[i],right); 
	}
	for(int i = i2; i <= j2; i++){
		WA[i] = mdc(WA[i],left); 
	}
}

void divide(int l, int r){
	if(l != r){
		int m = (l + r)/2;
		divide(l  ,m);
		divide(m+1,r);
		conquer(l,m,m+1,r);
	}
}

int main(){
	
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
	
	cin >> n;
	for(int i = 0; i < n; i++){
		cin >> A[i];
		WA[i] = -1;
	}
	
	divide(0,n-1);
	
	maior = 1;
	for(int i = 0; i < n; i++){
		maior = max(maior,WA[i]);
	}
	
	cout << maior << "\n";
	
    return 0;
}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
#define N 6
#define NA 100
#define Q 24
using namespace std;

void change(char);
void turn(void);
int dice[2][N];

int main(){
  
  char arrow[]="NWNWNW";
  // string str;
  int i,j,k,status=0,count=0;

  for(j=0;j<2;j++)for(i=0;i<N;i++)cin>>dice[j][i];
  
  for(j=0;j<N;j++){
    change(arrow[j]);
    for(k=0;k<4;k++){
      turn();
      count=0;
      for(i=0;i<N;i++)if(dice[0][i]==dice[1][i])count++;
      
      
      if(count==6){
	status=1;
	break;
      }
    }
    if(status==1)break;
  }

  if(status==1)cout<<"Yes"<<endl;
  else cout<<"No"<<endl;
    
}

void change(char c){
  if(c=='N'){
    swap(dice[1][0],dice[1][4]);
    swap(dice[1][0],dice[1][1]);
    swap(dice[1][1],dice[1][5]);
  }else if(c=='S'){
    swap(dice[1][0],dice[1][1]);
    swap(dice[1][0],dice[1][4]);
    swap(dice[1][5],dice[1][4]);
  }else if(c=='W'){
    swap(dice[1][2],dice[1][0]);
    swap(dice[1][2],dice[1][5]);
    swap(dice[1][5],dice[1][3]);
  }else if(c=='E'){
    swap(dice[1][0],dice[1][3]);
    swap(dice[1][3],dice[1][5]);
    swap(dice[1][5],dice[1][2]);
  }
}

void turn(void){
  swap(dice[1][1],dice[1][2]);
  swap(dice[1][2],dice[1][4]);
  swap(dice[1][4],dice[1][3]);
}



Measured memory_bytes: 3116
import sys
sys.setrecursionlimit(10000000)

N = int(input())
childs = [[] for _ in range(N)]
for i in range(1, N):
    childs[int(input())-1].append(i)

def solve(node):
    if not childs[node]:
        return 0

    elif len(childs[node]) == 1:
        return 1 + solve(childs[node][0])

    else:
        depths = sorted(map(solve, childs[node][:]), reverse = True)
        return max(i + depth + 1 for i, depth in enumerate(depths))

print(solve(0))

Measured memory_bytes: 105476
#include <iostream>
using namespace std;
 
int main() {
    string S;
    cin >> S;
    bool p = S[0] == 'R';
    bool q = S[1] == 'R';
    bool r = S[2] == 'R';
    if (p and q and r) {
        cout << 3 << endl;
    } else if ((p and q) or (q and r)) {
        cout << 2 << endl;
    } else if (p or q or r) {
        cout << 1 << endl;
    } else {
        cout << 0 << endl;
    }
 
    return 0;
}

Measured memory_bytes: 3180
#include <iostream>
#include <vector>
#include <queue>

using namespace std;

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n, m;
    vector<priority_queue<int>> problems;
    while(cin >> n >> m && n && m){
        problems.clear();
        problems.resize(m);
        for(int i = 0; i < n; i++){
            int d, v;
            cin >> d >> v;
            problems[d - 1].push(v);
        }
        int ans = 0;
        for(auto&& i : problems){
            ans += i.top();
        }
        cout << ans << "\n";
    }
}


Measured memory_bytes: 3080
MAX_N = 10**5+100
INF = float('inf')

N, K = map(int, input().split())
h = list(map(int, input().split()))

# dp table
# dp[i] := 足場iに行くのにかかる最小のコスト
dp = [INF]*MAX_N
dp[0] = 0

for i in range(1,N):
    for j in range(1,K+1):
        if i-j>=0:
            dp[i] = min(dp[i],dp[i-j]+abs(h[i]-h[i-j]))
print(dp[N-1])

Measured memory_bytes: 55392
#include <bits/stdc++.h>
// iostream is too mainstream
#include <cstdio>
// bitch please
#include <iostream>
#include <algorithm>
#include <cstdlib>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <list>
#include <cmath>
#include <iomanip>
#include <time.h>
#define dibs reserve
#define OVER9000 1234567890123456789LL
#define ALL_THE(CAKE,LIE) for(auto LIE =CAKE.begin(); LIE != CAKE.end(); LIE++)
#define tisic 47
#define soclose 1e-8
#define chocolate win
// so much chocolate
#define patkan 9
#define ff first
#define ss second
#define abs(x) ((x < 0)?-(x):x)
#define uint unsigned int
#define dbl long double
#define pi 3.14159265358979323846
using namespace std;
// mylittledoge

typedef long long cat;

#ifdef DONLINE_JUDGE
	// palindromic tree is better than splay tree!
	#define lld I64d
#endif

int main() {
	cin.sync_with_stdio(0);
	cin.tie(0);
	cout << fixed << setprecision(10);
	int N,A,B;
	string S;
	cin >> N >> A >> B >> S;
	int passJ =0, passO =0;
	for(int i =0; i < N; i++) {
		if(S[i] == 'c') {
			cout << "No\n";
			continue;
		}
		if(S[i] == 'a') {
			if(passJ+passO < A+B) {
				passJ++;
				cout << "Yes\n";
			}
			else cout << "No\n";
		}
		if(S[i] == 'b') {
			if(passJ+passO < A+B && passO < B) {
				passO++;
				cout << "Yes\n";
			}
			else cout << "No\n";
		}
	}
	return 0;}

// look at my code
// my code is amazing


Measured memory_bytes: 848
n, k = map(int, input().split())
h = list(map(int, input().split()))
c = [float("INF")] * n
c[0] = 0
for i in range(1, n):
    for j in range(1, min(n, k + 1)):
        c[i] = min(c[i], c[i - j] + abs(h[i] - h[i - j]))

print(c[n - 1])


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

class Main
{
	public static void main (String[] args) throws Exception
	{
		// your code goes here
		BufferedReader bu=new BufferedReader(new InputStreamReader(System.in));
		int n=Integer.parseInt(bu.readLine());
		int i;long sum=0;
		for(i=1;i<=n;i++)
		if(i%3==0 || i%5==0) continue;
		else sum=sum+i;
		System.out.print(sum);
	}
}

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

int main(){

    string s;
    ll k;
    cin >> k >> s;

    if(s.length() <= k){
        cout << s << endl;
    }else{
        cout << s.substr(0,k) << "..." << endl; 
    }


    return 0;
}


Measured memory_bytes: 3628
#include <bits/stdc++.h>
#include <unistd.h>
#include <sys/time.h>
#include <stdlib.h>

using namespace std;

typedef long long ll;
typedef pair<ll, ll> P;
typedef pair<P, ll> T;
typedef pair<long double , ll> Ps;
typedef pair<ll, bool> Pb;

const ll INF = 1e18;
const ll fact_table = 3200008;
long double Pi = 3.1415926535897932384626;

priority_queue <ll> pql;
priority_queue <P> pqp;
priority_queue <P> bag;
//big priority queue
priority_queue <ll, vector<ll>, greater<ll> > pqls;
priority_queue <P, vector<P>, greater<P> > pqps;
//small priority queue
//top pop

ll dx[8] = {1, 0, -1, 0, 1, 1, -1, -1};
ll dy[8] = {0, 1, 0, -1, 1, -1, -1, 1};
//↓,→,↑,←


#define endl "\n"
#ifdef ENJAPMA
#undef endl
#endif

#define p(x) cout<<x<<endl;
#define el cout<<endl;
#define pe(x) cout<<x<<" ";
#define ps(x) cout<<fixed<<setprecision(25)<<x<<endl;
#define pu(x) cout<<(x);
#define pb push_back
#define lb lower_bound
#define ub upper_bound
#define CLEAR(a) a = decltype(a)();
#define pc(x) cout << x << ",";
#define rep(i, n) for (ll i = 0; i < (n); i ++)

// const ll mod = 998244353ll;
const ll mod = 1000000007ll;

ll mypow(ll a, ll b, ll mod) {ll x = 1; while (b) {while (!(b & 1)) {(a *= a) %= mod; b >>= 1;}(x *= a) %= mod; b--;} return x;}
void YES(bool cond) { if (cond) { p("YES");} else { p("NO");} return;}
void Yes(bool cond) { if (cond) { p("Yes");} else { p("No");} return;}
void line() { p("--------------------"); return;}

/*
ll fact[fact_table + 5], rfact[fact_table + 5];

void c3_init() {
    fact[0] = rfact[0] = 1;
    for (ll i = 1; i <= fact_table; i++) {
        fact[i] = (fact[i - 1] * i) % mod;
    }
    rfact[fact_table] = mypow(fact[fact_table], mod - 2, mod);
    for (ll i = fact_table; i >= 1; i--) {
        rfact[i - 1] = rfact[i] * i;
        rfact[i - 1] %= mod;
    }
    return;
}
ll c3(ll n, ll r) {
    return (((fact[n] * rfact[r]) % mod ) * rfact[n - r]) % mod;
}
*/
struct Timer {
    int64_t start;
    const int64_t CYCLES_PER_SEC = 2800000000;
    Timer() { reset(); }
    void reset() { start = getCycle(); }
    inline double get() { return (double)(getCycle() - start) / CYCLES_PER_SEC; }
    inline int64_t getCycle() {
        uint32_t low, high;
        __asm__ volatile ("rdtsc" : "=a" (low), "=d" (high));
        return ((int64_t)low) | ((int64_t)high << 32);
    }
};

bool multicase = false;

ll n, m, k, w, a, b, c, d, e, h, q, ans, sum, l;

typedef vector<ll> vec;
typedef vector<vector<ll>> mat;

void solve() {
    cin >> n;
    Yes(n >= 30);
    return;
}

int main() {
    // init();
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    ll q, testcase = 1;
    if (multicase) {
        cin >> q;
    } else {
        q = 1;
    }
    while (q--) {
        // pu("Case ");pu("#");pu(testcase);pu(": ");
        solve();
        testcase++;
    }
    // solve();
    return 0;
}



Measured memory_bytes: 3632
import java.util.Scanner;
public class Main {
	public static void main(String[] args){
		Scanner scan=new Scanner(System.in);
		String x;
		int ans;
		while(true){
			x=scan.next();
			ans=0;
			if(x.equals("0")) break;
			for(int i=0;i<x.length();i++){
				ans=ans+x.charAt(i)-'0';
			}
			System.out.println(ans);
		}
		scan.close();
	}
}

Measured memory_bytes: 17200
#include<bits/stdc++.h>
#define fo(i,a,b) for((i)=(a);i<=(b);i++)
#define rfo(i,a,b) for((i)=(a);i>=(b);i--)
#define inrange(x,y,z) (((x)>=(y))&&((x)<=(z)))
#define ALL(vec) ((vec).begin(),(vec).end())
#define SOR(vec) sort(ALL(vec))
#define UNI(vec) (vec).erase(unique(ALL(vec)),(vec).end())
using namespace std;
int n;
int main(){
	#ifdef FILIN
		#ifndef LOCAL
			freopen(FILIN,"r",stdin);
			freopen(FILOUT,"w",stdout);
		#endif
	#endif
	ios::sync_with_stdio(0);
	cin.tie(NULL);
	cout.tie(NULL);
	cin>>n;
	long long res=0LL;
	for(int i=1;i<=n;i++){
		if((i%3!=0)&&(i%5!=0))
			res+=(long long)(i);
	}
	cout<<res<<endl;
	return 0;
}


Measured memory_bytes: 3652
#!/usr/bin/env python
"""AtCoder Beginner Contest 085: C - Otoshidama
https://atcoder.jp/contests/abc086/tasks/abc085_c
"""

__author__ = 'bugttle <bugttle@gmail.com>'


def calc(N, Y):
    for x in range(N + 1):
        for y in range(0, N+1-x):
            z = N - x - y
            if 10000*x + 5000*y + 1000*z == Y:
                return [str(x), str(y), str(z)]
    return ['-1', '-1', '-1']


def main():
    N, Y = map(int, input().split())

    answer = calc(N, Y)
    print(' '.join(answer))


if __name__ == '__main__':
    main()


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

#define sws ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define INFINITO 1000000000
#define ll long long
#define vi vector<int>
#define pb push_back
#define pii pair<int, int>
#define mp make_pair
#define ff first
#define ss second
#define vvi vector<vi>
#define all(x) x.begin(), x.end()
#define fo(i, n) for( int i = 0; i < n; i++ )


int main() {

    string s;
    cin >> s;

    bool eh = true;
    if ( s[0] != 'A' ) eh = false;
    int contc = 0;
    for ( size_t i = 1; i < s.size(); i++ ) {
        if ( s[i] == 'C' ) contc++;
        else if ( s[i] >= 'A' and s[i] <= 'Z' ) eh = false;
    }
    if ( s[1] == 'C' or contc != 1 or s.back() == 'C' ) eh = false;

    cout << (eh ? "AC\n" : "WA\n");

    return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <cctype>
#include <algorithm>
using namespace std;
int N,K,cnt,F[1005][1005],l[1005];
int main(){
	scanf("%d",&N);
	while (K*(K-1)/2<N) ++K;
	if (K*(K-1)/2!=N){
		puts("No");
		return 0;
	}
	printf("Yes\n%d\n",K);
	for (int i=1;i<K;++i)
		for (int j=K;j>i;--j) F[i][++l[i]]=++cnt,F[j][++l[j]]=cnt;
	for (int i=1;i<=K;++i){
		printf("%d ",l[i]);
		for (int j=1;j<l[i];++j) printf("%d ",F[i][j]);
		printf("%d\n",F[i][l[i]]);
	}
	return 0;
}

Measured memory_bytes: 3072
#include <bits/stdc++.h>
int main(void)
{
  long long p8, p4, p2, p1, n, ans = 0;
  std::cin >> p8 >> p4 >> p2 >> p1 >> n;
  p4 = std::min(p4, p8 * 2);
  p2 = std::min(p2, p4 * 2);
  p1 = std::min(p1, p2 * 2);
  ans += (n / 2) * p1;
  n -= (n / 2) * 2;
  ans += n * p2;
  std::cout << ans << std::endl;
  return 0;
}

Measured memory_bytes: 256
// Author := Abhishek Giri

#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define mp make_pair
#define mod 1000000007
#define V(type) vector<(type)>
#define all(c) ((c).begin(),(c).end())
#define in(var) cin>>(var)
#define out(var) cout<<(var)
#define on(var) cout<<var<<"\n"
#define f(i,n) for(ll i = 0 ; i < n ;i++)
#define mfor(i,init,n,b) for(ll i = (init) ; i < (n) ; i+= (b))
#define cfor(i,c) for(auto i = (c).begin() ; i!= (c).end(); i++)
#define el "\n"

/*##################################################################################*/


int prime[1000000] ;
vector < int > pr;
void calculateprime()
{
    prime[0] = prime[1] = 1 ;
    for(int i = 2 ; i <= 1000000 ; i++)
    {
        if(prime[i] == 0)
        {
            pr.pb(i);
            for(ll j = i*2 ; j <= 1000000 ; j += i )
            {
                prime[j] = 1 ;
            }
        }
    }
}


void fast(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
}

bool isprime(ll n)
{
    for(ll i = 2 ; (ll) i*i <= n ; i++)
    {
        if(n % i == 0){
            return false;
        }
    }
    return true;
}

ll fib(int n)
{
  ll a = 0, b = 1, c, i;
  if( n == 0)
    return a;
  for (i = 2; i <= n; i++)
  {
    c = (a + b);
    a = b;
    b = c;
  }
  return b;
}


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

ll extendedgcd(ll a, ll b, ll& x, ll& y) {
    if (b == 0) {
        x = 1;
        y = 0;
        return a;
    }
    ll x1, y1;
    ll d = extendedgcd(b, a % b, x1, y1);
    x = y1;
    y = x1 - y1 * (a / b);
    return d;
}

ll findgrouplcm(vector<int> &arr, int n)
{
    ll ans = arr[0];

    for (ll i = 1; i < n; i++)
        ans = (arr[i] * (ans/(gcd(arr[i], ans))));

    return ans;
}


ll powerwithmod(ll x, unsigned ll y, ll p)
{
    ll res = 1;

    x = x % p;

    if (x == 0) return 0;

    while (y > 0)
    {
        if (y & 1)
            res = (res*x) % p;

        y = y>>1; // y = y/2
        x = (x*x) % p;
    }
    return res;
}


bool comp(const pair<int,int> &a , const pair<int,int> &b){
    return a.first < b.first;
    if(a.first == b.first)  return a.second < b.second;
}


void solve(){
    ll w,h,x,y;
    in(w)>>h>>x>>y;
    cout<<fixed<<setprecision(12)<<((long double)w*h/2)<<" ";
    if( w% 2 == 0 and h%2 == 0 and x == w/2 and y == h /2)    cout<<"1";
    else cout<<"0";
}


int main() {
    fast();
    ll t = 1;
    //cin>>t;
    while(t--)
    {
        solve();
    }

    return 0;
}


Measured memory_bytes: 3780
n = int(input())

s_L = []
for i in range(n):
    s_L.append(int(input()))

ans = sum(s_L)
if ans % 10 != 0:
    print(ans)
    exit()

s_L = sorted(s_L)

for i in range(n):
    if s_L[i]%10 != 0:
        print(ans-s_L[i])
        exit()

print(0)

Measured memory_bytes: 38256
#include <bits/stdc++.h>
#define last last2

using namespace std;

int q1[200005],q2[200005];
int num[200005];

int main() {
  int n,k;
  scanf("%d%d",&n,&k);
  for(int i=1;i<=n;i++) scanf("%d",&num[i]);
  bool v=0;
  int ans=0,last=1;
  int l1=1,l2=1,r1=0,r2=0;
  for(int i=1;i<k;i++) {
  	  while (l1<=r1&&i-q1[l1]>k) l1++;
  	  while (l2<=r2&&i-q2[l2]>k) l2++;
  	  while (l1<=r1&&num[i]<num[q1[r1]]) r1--;
  	  q1[++r1]=i;
  	  while (l2<=r2&&num[i]>num[q2[r2]]) r2--;
  	  q2[++r2]=i;
	  if (num[i]<num[i-1]) last=i;
    }
  for(int i=k;i<=n;i++) {
  	while (l1<=r1&&i-q1[l1]>k) l1++;
  	while (l2<=r2&&i-q2[l2]>k) l2++;
  	while (l1<=r1&&num[i]<num[q1[r1]]) r1--;
  	q1[++r1]=i;
  	while (l2<=r2&&num[i]>num[q2[r2]]) r2--;
  	q2[++r2]=i;
  	if (num[i]<num[i-1]) last=i;
  	if (q1[l1]!=i-k||q2[l2]!=i) {
  		if (last<=i-k+1) {
  			if (!v) v=1,ans++;
		  }
  		else ans++;
	  }
  }
  printf("%d\n",ans);
  return 0;
}

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

long long int a,b,n,m,s,ans=1;;
long long int sum[100010];


int main()
{
    cin>>n;
       for(int i=1; i<=n; i++)
    {
        scanf("%d",&m);
        sum[m]++;
    }
    for(int i=0; i<n; i++)
    {

        if(sum[i]>=3)
        {
            cout<<"0";
            return 0;
        }
    }
    if((n%2==1&&sum[0]!=1)||(!(n%2)&&sum[0]))
    {
        cout<<"0";
        return 0;
    }

    a=2;
    b=n/2;
    while(b)
    {
        if(b&1)
        {
            ans=(ans*a)%1000000007;
        }
        b=b/2;
        a=(a*a)%1000000007;
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 1024
#include <stdio.h>
int main(void){
  int A1,A2,A3,A;

  scanf("%d %d %d",&A1,&A2,&A3);
  A=A1+A2+A3;
  if(A>=22)
    printf("bust\n");
  else 
    printf("win\n");

  return 0;
}

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

int main() {
    int N, W;
    cin >> N >> W;
    vector<int> w(N), v(N);
    for (int i = 0; i < N; ++i) cin >> w[i] >> v[i];

    vector<vector<long long>> dp(N+1, vector<long long>(W+1, 0));
    for (int i = 1; i <= N; ++i) {
        for (int j = 0; j <= W; ++j) {
            dp[i][j] = max(dp[i][j], dp[i-1][j]);
            if (j-w[i-1] >= 0) {
                dp[i][j] = max(dp[i][j], dp[i-1][j-w[i-1]] + v[i-1]);
            }
        }
    }
    cout << dp[N][W] << endl;
}

Measured memory_bytes: 82996
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii = pair<int, int>;

int N, M;
int A[100010];

int main() {
  cin.tie(0);
  ios_base::sync_with_stdio(false);
  cout << fixed << setprecision(10);
  
  cin >> N >> M;
  for (int i = 0; i < N; i++) {
    cin >> A[i];
  }
  map<int, int> mp;
  mp[0]++;
  int sum = 0;
  ll ans = 0;
  for (int i = 0; i < N; i++) {
    sum += A[i];
    sum %= M;
    if (mp[sum]) ans += mp[sum];
    mp[sum]++;
  }
  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 3584
#include <iostream>
#include <stdio.h>
#include <algorithm>
#include <vector>
#include <queue>
#include <numeric>
#include <string>
#include <string.h>
#include <map>
#include <set>
#include <functional>
#include <complex>
#include <stack>
#include <tuple>
#include <array>
using namespace std;
#define rep(i,n) for (int i=0; i < (n); i++)


typedef long long int ll;
typedef double D;      // ??§?¨?????????????double???long double?????????
typedef complex<D> P;  // Point
typedef pair<P, P> L;  // Line
typedef vector<P> VP;


const int INF = (1<<30) - 1;
const D EPS = 1e-9;

#define X real()
#define Y imag()
#define LE(n,m) ((n) < (m) + EPS)
#define GE(n,m) ((n) + EPS > (m))
#define EQ(n,m) (abs((n)-(m)) < EPS)

int N, M, K;

int dfs(int cur, int s){
    if(cur == 0){
        return s-K > 0 ? s-K: 1;
    }
    
    int ans = 0;
    for(int i=1; i<=M; i++){
        ans += dfs(cur-1, s+i);
    }
    return ans;
}

void solve(){
    double d = dfs(N, 0);
    for(int i=0; i<N; i++)
        d /= M;
    cout << d << endl;
}

//g++ -std=c++0x -msse4.2 -O3
//#include <bits/stdc++.h>
int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.precision(16);
    cout.setf(ios::fixed);
    
    
    while(cin>>N>>M>>K, N|M|K)
        solve();
    
    return 0;
}

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

using namespace std;

/* g++ -g -fsanitize=address -lasan -std=c++11 -Dfoo_ */

/* freopen("input.txt", "rt", stdin); */
/* freopen("output.txt", "wt", stdout); */

#define ALL(c)          (c).begin(), (c).end()
#define ALLR(c)         (c).rbegin(), (c).rend()
#define FOR(i,a,b)      for (int i=(a); i < (b); ++i)
#define FORR(i,a,b)     for (int i=(a); i > (b); --i)
#define FOR_ALL(i,c)    for (__typeof((c).begin()) i=(c).begin();   \
                             i != (c).end(); ++i)
#define FOR_ALLR(i,c)   for (__typeof((c).rbegin()) i=(c).rbegin(); \
                             i != (c).rend(); ++i)
#define SZ(array)       (sizeof(array)/sizeof(array[0]))
#define lc(x)           (x<<1)     /* 2*x */
#define rc(x)           (x<<1 | 1) /* 2*x+1 */
#define lowbit(x)       (x & (-x)) /* 0b10100 -> 0b100 */

typedef long long       LL;
typedef map<int,int>    MII;
typedef pair<int,int>   PII;
typedef set<int>        SI;
typedef vector<bool>    VB;
typedef vector<double>  VD;
typedef vector<int>     VI;
typedef vector<string>  VS;

/* check if a key is in container C */
template <class C>
inline bool in_(const typename C::key_type& k, const C& A)
{ return A.find(k) != A.end(); }
inline bool in_(const string& s, const string& S)
{ return S.find(s) != string::npos; }

bool cmp(const PII& a, const PII& b)
{
    if (a.first == b.first)
        return a.second > b.second;
    return a.first < b.first;
}

int main()
{
#ifdef foo_
    freopen("foo", "rt", stdin);
#endif
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n,m;
    while (cin >> n >> m) {
        vector<PII> J(n);
        FOR(i,0,n) {
            int a,b; cin >> a >> b; J[i] = PII(m-a,b);
        }
        sort(ALL(J),cmp);
        multiset<int> S;
        int now = 0;
        FOR(i,0,n) {
            const int start = J[i].first;
            const int value = J[i].second;
            if (start < 0)
                continue;
            if (start < now) {
                if (S.size() && *S.begin() < value) {
                    S.erase(S.begin());
                    S.insert(value);
                }
            }
            else {
                S.insert(value);
                now++;
            }
        }
        int ans = 0;
        FOR_ALL(x,S)
            ans += *x;
        cout << ans << endl;
    }
    return 0;
}


Measured memory_bytes: 5760
<?php
fscanf(STDIN,"%d",$n);
$l_li = explode(" ",trim(fgets(STDIN)));

sort($l_li);

$c = 0;
$end = count($l_li)-1;
for($i=0;$i<$n-2;$i++){
  for($j=$i+1;$j<$n;$j++){
    $ab = $l_li[$i]+$l_li[$j];
    $start = $j;
    $end = count($l_li);
    
    while($start+1 < $end){
      $center = intdiv($start+$end,2);
      if($l_li[$center]<$ab){
        $start = $center;
      }else{
        $end = $center;
      }
    }
    
    $c += ($start - $j);
  }
}

echo $c;


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

int main() {
	int A[2], K;
	cin >> A[0] >> A[1] >> K;
	for (int i = 0;i < K;++ i) {
		A[!(i & 1)] += A[i & 1] >> 1;
		A[i & 1] >>= 1;
	}
	cout << A[0] << " " << A[1];
	return 0;
}
/*
31536000のコメント解説欄
ここテンプレで用意してるから、A問題とかだとこの先空欄の危険あり
また、コンテスト後に https://31536000.hatenablog.com/ で解説していると思うので、良かったら読んでねー

実際にシミュレーションするだけ。O(K)
*/

Measured memory_bytes: 256
import java.util.Scanner;

public class Main{
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        while(true) {
        
            
            int a = sc.nextInt();
            String op = sc.next();
            int b = sc.nextInt();
            if (op.equals("+")) {
                System.out.println(a+b);          
            } else if (op.equals("-")) {
                System.out.println(a-b);
            } else if(op.equals("*")){
                System.out.println(a*b);
            } else if(op.equals("/")){
                System.out.println(a/b);
            } else if(op.equals("?")){
                break;
            }
                
        }
    
        sc.close();
    }
} 


Measured memory_bytes: 26312
#include"bits/stdc++.h"

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define REP(i, n) for (int i = 1; i <= (int)(n); i++)
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()
using namespace std;
using ll = long long;
using pi = pair<int, int>;
const ll INF = 1LL << 60;
const ll mod = 1e9 + 7;

ll powmod(ll x,ll n) {
	ll res = x;
	rep(i, n - 1)res = ((res * x) % mod);
	return res;
}

int main() {
	ll n;
	cin >> n;
	ll ans = powmod(10, n) + powmod(8, n) - (powmod(9, n) * 2LL);
	ans %= mod;
	ans = (ans + mod) % mod;
	cout << ans << endl;
	return 0;
}



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

const string YES = "Yes";
const string NO = "No";

void solve(std::string S, std::string T)
{
    bool result = equal(S.begin(), S.end(), T.begin()) && S.size() + 1 == T.size();
    cout << (result ? YES : NO) << endl;
}

// Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
int main()
{
    std::string S;
    std::cin >> S;
    std::string T;
    std::cin >> T;
    solve(S, T);
    return 0;
}


Measured memory_bytes: 3636
import sys
sys.setrecursionlimit(10**6)
from math import floor,ceil,sqrt,factorial,log
from heapq import heappop, heappush, heappushpop
from collections import Counter,defaultdict,deque
from itertools import accumulate,permutations,combinations,product,combinations_with_replacement
from bisect import bisect_left,bisect_right
from copy import deepcopy
from operator import itemgetter
from fractions import gcd
mod = 10 ** 9 + 7
inf = float('inf')
ninf = -float('inf')
 
#整数input
def ii(): return int(sys.stdin.readline().rstrip()) #int(input())
def mii(): return map(int,sys.stdin.readline().rstrip().split())
def limii(): return list(mii()) #list(map(int,input().split()))
def lin(n:int): return [ii() for _ in range(n)]
def llint(n: int): return [limii() for _ in range(n)]
#文字列input
def ss(): return sys.stdin.readline().rstrip() #input()
def mss(): return sys.stdin.readline().rstrip().split()
def limss(): return list(mss()) #list(input().split())
def lst(n:int): return [ss() for _ in range(n)]
def llstr(n: int): return [limss() for _ in range(n)]

#本当に貪欲法か？ DP法では？？
#本当に貪欲法か？ DP法では？？
#本当に貪欲法か？ DP法では？？

n,q=mii()
mat = [[] for _ in range(n)]

for i in range(n-1):
    a,b=mii()
    mat[a-1].append(b-1)
    mat[b-1].append(a-1)
cnt=[0]*n

for i in range(q):
    p,x=mii()
    cnt[p-1]+=x

ans=[0]*n

def dfs(point,now,parent):
    point+=cnt[now]
    ans[now]=point
    for visit in mat[now]:
        if visit==parent:continue
        dfs(ans[now],visit,now)
dfs(0,0,0)
for i in ans:
    print(i)

Measured memory_bytes: 235856
#include "bits/stdc++.h"
#define PRECISION(x) cout << fixed << setprecision(x)
#define FAST_IO ios::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define SZ(X) ((int)(X).size())
#define ALL(X) (X).begin(), (X).end()
#define ALLR(X) (X).rbegin(), (X).rend()
#define MP make_pair
#define PB push_back
#define EB emplace_back
#define F first
#define S second

using namespace std;

template<class T> void max_self(T & a, const T & b) { if(a < b) a = b; }
template<class T> void min_self(T & a, const T & b) { if(a > b) a = b; }
typedef long long LL;
const int INF = 1e9 + 7;
const double PI = acos(-1.0);
const double EPS = (1e-9);


int main(){
  FAST_IO  

  int cnt = 0;
  string from, till, util;
  cin >> from >> till;
  util = from;

  for(int f = 0; f <= 9; ++f){
    for(int s = 0; s <= 9; ++s){
      for(int m = 0; m <= 9; ++m){
        util[0] = util[4] = f + '0';
        util[1] = util[3] = s + '0';
        util[2] = m + '0';
        if(util >= from && util <= till) cnt++;
      }
    }
  }

  cout << cnt << "\n";
  return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

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

//    	File file = new File("test.txt");
//    	Scanner sc = new Scanner(file);
    	Scanner sc = new Scanner(System.in);
    	int start = sc.nextInt();
    	int end = sc.nextInt();
    	sc.close();
    	int ans = 0;
    	for(int i = start; i <= end; i++){
    		String str = String.valueOf(i);
    		String str2 = str.substring(4, 5) + str.substring(3, 4);
    		if(str.substring(0, 2).equals(str2)) ans++;
		}
    	System.out.println(ans);
    }

}


Measured memory_bytes: 40148
#include<iostream>
#include<string>
#include<algorithm>
#include<cmath>
using namespace std;
int main() {
	int a; double b, c;
	int ans = 0; double r = 1000000;
	cin >> a >> b >> c;
	for (int i = 1; i <= a; i++){
		double p; cin >> p;
		p = b - p * 0.006;
		double d = abs(c - p);
		if (r > d) {
			ans = i;
			r = d;
		}
	}
	cout << ans << endl;
}

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

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

#define SORT(c) sort((c).begin(),(c).end())
#define BACKSORT(c) sort((c).begin(),(c).end(),std::greater<LL>())
#define FOR(i,a,b) for(LL i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define SP << " " <<

LL mod = 1000000007;

int main()
{
  cin.tie(0);
  ios::sync_with_stdio(false);
  LL N;
  cin>>N;
  cout << (N - 2) * 180 << endl;
}


Measured memory_bytes: 256
#include<iostream>
#include<math.h>
#include<algorithm>
#include<stdint.h>
#include<vector>
#include<deque>
#include<stack>
#include<functional>
#include<string>
#include<cstring>
#include<array>
#include<iomanip>
#include<list>
#include<set>
#include<map>
#include<unordered_map>
#include<unordered_set>
#include<bitset>
#include <queue>
#include<boost/multiprecision/cpp_int.hpp>



using namespace std;
using namespace boost::multiprecision;

using ll = long long;
using ull = unsigned long long;
using uint = unsigned int;
using ldb = long double;

#define REP(i,a,b) for(ll i = a; i < b; ++i)
#define PRI(s) cout << s << endl
#define PRIF(v, n) printf("%."#n"f\n", v)
#define PRIY PRI("Yes")
#define PRIN PRI("No")
template<typename A, typename B>
void mins(A& a, const B& b) { a = min(a, (A)b); };
template<typename A, typename B>
void maxs(A& a, const B& b) { a = max(a, (A)b); };




int main() {
	ll N, K; cin >> N >> K;
	vector<ll> H(1 + N); REP(i, 1, 1 + N) cin >> H[i];
	vector<vector<unordered_map<ll,ll>>> dp(1 + N);
	REP(i, 0, N + 1) dp[i].resize(1 + K);
	dp[0][0][0] = 0;
	REP(i, 0, N) {
		REP(j, 0, 1 + K) {
			for (const auto& p : dp[i][j]) {
				if (dp[i + 1][j].count(H[i + 1]) == 0) dp[i + 1][j][H[i + 1]] = dp[i][j][p.first] + max(0LL, H[i + 1] - p.first);
				else mins(dp[i + 1][j][H[i + 1]], dp[i][j][p.first] + max(0LL, H[i + 1] - p.first));
				if (j < K) {
					if (dp[i + 1][j + 1].count(p.first) == 0) dp[i + 1][j + 1][p.first] = dp[i][j][p.first];
					else mins(dp[i + 1][j + 1][p.first], dp[i][j][p.first]);
				}
			}
		}
	}
	ll ans = 1e18;
	REP(i, 0, 1 + K) for (const auto& p : dp[N][i]) mins(ans, p.second);
	PRI(ans);
	return 0;
}


Measured memory_bytes: 203388
import java.io.IOException;
import java.util.Scanner;

public class Main {


	public static void main(String[] args)throws IOException {
		int a,b;
		Scanner sc = new Scanner(System.in);
		a=Integer.parseInt(sc.next());
		b=Integer.parseInt(sc.next());

		if(a==b){
			System.out.println("a == b");

		}else if(a>b){
			System.out.println("a > b");
		}else{
			System.out.println("a < b");
		}
		sc.close();

	}





}

Measured memory_bytes: 25920
import itertools
import math

n = int(input())
p = list(map(str,input().split()))
q = list(map(str,input().split()))
lst = []
for i in range(n):
    lst.append(str(i+1))
lst_perm = list(itertools.permutations(lst))
a=0
b=0
for i in range(math.factorial(n)):
    if ("".join(p))==("".join(q)):
        if ("".join(p))==("".join(lst_perm[i])):
            a=i
            b=i
    else:
        if ("".join(p))==("".join(lst_perm[i])):
            a = i
        elif ("".join(q))==("".join(lst_perm[i])):
            b = i
print(abs(a-b))

Measured memory_bytes: 7972
import math

H, N = map(int,input().split()) # 複数の数字を変数に格納
List = [list(map(int,input().split())) for i in range(N)] # [[1,2],[3,4],[5,6]]

#for i in range(N):
#    List[i].append(List[i][0] / List[i][1])
    
#List.sort(key=lambda x: x[2], reverse=True)

table = [[0] * H for i in range(N)]

for i in range(H):
    table[0][i] = List[0][1] * (math.ceil((i+1) / List[0][0]))
    
for j in range(1,N):
    attack = List[j][0]
    MP = List[j][1]
    for i in range(H):
        if (i+1) < attack:
            table[j][i] = min(table[j-1][i], MP)
        else:
            table[j][i] = min(table[j-1][i], table[j][i-attack]+MP)
            
print(table[N-1][H-1])

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

using ll = long long int;

const int MAX = (int)(1e5 + 5);
const ll INF = (ll)(1e10 + 5);

const int MAX_H = (int)(8e1 + 5);
const int MAX_W = (int)(8e1 + 5);
const int MAX_DIFF = (int)(8e1 + 5);
const int BASE = MAX_H * MAX_W * MAX_DIFF;
const int SIZE = 2 * BASE;

int h, w;
int a[MAX_H][MAX_W];
int b[MAX_H][MAX_W];

bitset<SIZE> dp[MAX_H][MAX_W];

int main(void) {
  // Here your code !
  scanf("%d %d", &h, &w);

  for (int i = 0; i < h; ++i) {
    for (int j = 0; j < w; ++j) {
      scanf("%d", &(a[i][j]));
    }
  }

  for (int i = 0; i < h; ++i) {
    for (int j = 0; j < w; ++j) {
      scanf("%d", &(b[i][j]));
    }
  }

  int init = abs(a[0][0] - b[0][0]);

  dp[0][0].set(BASE + init);
  dp[0][0].set(BASE - init);

  for (int i = 0; i < h; ++i) {
    for (int j = 0; j < w; ++j) {
      int diff = abs(a[i][j] - b[i][j]);

      if (i - 1 >= 0) {
        dp[i][j] |= (dp[i - 1][j] << diff);
        dp[i][j] |= (dp[i - 1][j] >> diff);
      }

      if (j - 1 >= 0) {
        dp[i][j] |= (dp[i][j - 1] << diff);
        dp[i][j] |= (dp[i][j - 1] >> diff);
      }
    }
  }

  int ans = SIZE;

  for (int i = 0; i < SIZE; ++i) {
    if (dp[h - 1][w - 1][i]) {
      ans = min(ans, abs(i - BASE));
    }
  }

  printf("%d\n", ans);

  return 0;
}


Measured memory_bytes: 1020416
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time,copy,functools
from collections import deque

sys.setrecursionlimit(10**7)
inf = 10**20
mod = 10**9 + 7

DR = [1, -1, 0, 0]
DC = [0, 0, 1, -1]

def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def S(): return input()


def find_x_miman(pos, i, neg, x):
    if len(neg) == 0:
        return 0
    if neg[0] * pos[i] >= x:
        return 0
    ok = 0
    ng = len(neg)
    while ok + 1 < ng:
        m = (ng + ok) // 2
        if neg[m] * pos[i] < x:
            ok = m
        else:
            ng = m
    return ok + 1

def find_x_miman_from_right(arr, i, x):
    if not (i + 1  < len(arr)):
        return 0
    if arr[i] * arr[i+1] >= x:
        return 0

    ok = i + 1
    ng = len(arr)
    while ok + 1 < ng:
        m = (ng + ok) // 2
        if arr[m] * arr[i] < x:
            ok = m
        else:
            ng = m
    return ok - i

def main():
    N, K = LI()
    A = LI()
    A = sorted(A)
    pos = [a for a in A if a > 0]
    neg = [a for a in A if a < 0]
    rev_neg = [abs(a) for a in neg][::-1]
    n_zero = N - len(neg) - len(pos)
    l = -10**18 - 1 # K未満
    r = 10**18 + 1

    def count_miman(x):
        # return count of mul less than x
        cnt = 0
        if x < 0:
            for i in range(len(pos)):
                cnt += find_x_miman(pos, i, neg, x)
        else: # x > 0
            if x > 0:
                cnt += n_zero * (len(neg) + len(pos)) + (n_zero * (n_zero - 1)) // 2
            for i in range(len(pos)):
                cnt += find_x_miman_from_right(pos, i, x)
            for i in range(len(rev_neg)):
                cnt += find_x_miman_from_right(rev_neg, i, x)
            cnt += len(pos) * len(neg)
        return cnt

    # x未満がK個未満あるような最大のx
    while l + 1 < r:
        m = (l + r) // 2
        mimcount = count_miman(m)
        if mimcount < K:
            l = m
        else:
            r = m
    print(l)

main()



Measured memory_bytes: 123944