akhauriyash/Code-Regression huggingface dataset:
import math
a, b, angle = map(float, input().split())

S = 1/2 * a * b * math.sin(math.radians(angle))

L = a + b + math.sqrt(a **2 + b ** 2 - 2 *a*b*math.cos(math.radians(angle)))

h = b * math.sin(math.radians(angle))

print(S)
print(L)
print(h)


Measured memory_bytes: 5692
#include<iostream>
#include<map>

using namespace std;

typedef long long ll;

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

map<ll, int> v;
void f(ll x) {
	ll waru = 2;
	while (waru * waru <= x) {
		while (x % waru == 0) {
			v[waru]++;
			x /= waru;
		}
		waru++;
	}
	if (x != 1)v[x]++;
}

int main(){
	ll A, B;
	cin >> A >> B;
	ll g = gcd(A, B);
	f(g);
	ll ans = 0;
	for (auto it = v.begin(); it != v.end(); it++) {
		ans++;
	}
	ans++;
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
d={}
A = input()
for i in range(len(A)):
    if d.get(A[i],None)==None:
        d[A[i]]=1
    else:
        d[A[i]]+=1

if(max(d.values())==2 & min(d.values())==2):
    print("Yes")
else:print("No")

Measured memory_bytes: 3060
import math
N, A, B = map(int, input().split())
h = [int(input()) for _ in range(N)]

def check(k):
  cnt = 0
  for i in range(N):
    cnt += max(0, math.ceil((h[i] - B*k) / (A - B)))
  if cnt <= k:
    return 1
  else:
    return 0

y, n = 10**10, 0
while y-n > 1:
  k = (y+n)//2
  if check(k):
    y = k
  else:
    n = k

print(y)


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

long long n, cnt;


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

    //no division
    //n % k = 1
    //n = 1 (mod k)
    //n - 1 = 0 (mod k)  we don't modify k
    //so we need to find factors of n - 1
    cnt = 0;
    for (long long i = 2; i * i <= n - 1; i++)
        if ((n - 1) % i == 0){
            cnt+= 2;
            if ((n - 1) / i == i)
                cnt--;
        }
    if (n - 1 > 1)
        cnt++;
    //div 
    //if (x / k) mod k = 1 -> no more div 
    for (long long i = 2; i * i <= n; i++)
        if (n % i == 0){
            long long tmp = n;
            while (tmp % i == 0 && tmp >= i){
                if (tmp % i == 0)
                    tmp /= i;
                else
                    tmp -= i;
            }
            // cout << i <<" " << tmp <<"\n";
            if (tmp % i == 1 || tmp == 1)
                cnt++;
        }
    cnt++;


    cout << cnt << "\n";
    return 0;
}
// (n, n - 1, 
// 2 [2]
// 3 [2, 3]
// 4 [2, 3, 4]
// 5 [2, 4, 5]
// 6 [2, 5, 6]
// 7 [2, 3, 6, 7]
// 8 [2, 7, 8]
// 9 [2, 3, 4, 8, 9]
// 10[2, 3, 9 10]




Measured memory_bytes: 256
#include <cmath>
#include <cstdlib>
#include <iostream>
#include <bitset>
#include <deque>
#include <list>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <vector>
#include <algorithm>
#include <iterator>
#include <string>
#include <chrono>
#include <random>
#include <tuple>
#include <utility>
#include <fstream>
#include <complex>

const long INF = (1l << 30);
const long LINF = (1l << 60);

long n, k, q;
long pnt[100005];

int main(){
    scanf("%ld%ld%ld", &n, &k, &q);
    for(int i = 0; i < q; i++){
        long a;
        scanf("%ld", &a);
        a--;
        pnt[a]++;
    }
    for(int i = 0; i < n; i++){
        pnt[i] += k-q;
        if(pnt[i] <= 0){
            printf("No\n");
        }else{
            printf("Yes\n");
        }
    }
}


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

using namespace std;

typedef long long ll;

int main() {
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    ll x;
    cin >> x;
    ll ans = 0;
    ans += (x / 11) * 2;
    x %= 11;
    if (x) {
        ++ans;
    }
    if (x > 6) {
        ++ans;
    }
    cout << ans;
    return 0;
}

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

#define pb push_back
#define mk make_pair
#define fi first
#define se second
#define eb emplace_back

typedef long long ll;
typedef pair<int,int> ii;
typedef vector< pair<int,int> > vii;
const ll INF = 0x3f3f3f3f3f3fef;

const int V = 1e5+2;
const int N = 102;

ll dp[V];
ll p[N];
ll v[N];
ll n,w;
 
int main() {
    ios_base::sync_with_stdio(false);
    for(int i = 0; i < V; i++) dp[i] = INF;

    cin >> n >> w;
    for(int i = 0; i < n; i++) cin >> p[i] >> v[i];
    
    dp[0] = 0;

    for(int i = 0; i < n; i++) 
        for(ll j = V-1; j-v[i] >= 0; j--)
            dp[j] = min(dp[j], dp[j-v[i]]+p[i]);

    for(int i = V-1; i >= 0; i--)
        if(dp[i] <= w) { cout << i << endl; return 0; }


    return 0;
}



Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define all(x) x.begin(),x.end()
using namespace std;
using ii = long long;
const int MAXN = 100100;
vector<int> v[MAXN];
int p[MAXN], d[MAXN];
int hae(int s)
{
    if (p[s]) return d[s];
    p[s] = 1;
    int r = 0;
    for (int u : v[s]) {
        r = max(r, hae(u) + 1);
    }
    return d[s] = r;
}
int main()
{
    int n, m;
    cin >> n >> m;
    for (int i = 0; i < m; ++i) {
        int a, b;
        cin >> a >> b;
        --a; --b;
        v[a].push_back(b);
    }
    int r = 0;
    for (int i = 0; i < n; ++i) {
        r = max(r, hae(i));
    }
    cout << r << "\n";
}


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

using namespace std;

typedef long long ll;

const int mxN = 2e5;
int n, m;
ll k, a[mxN+1], b[mxN+1];

void test_case() {
	cin >> n >> m >> k;
	for(int i = 0; i < n; ++i) {
		cin >> a[i+1];
		a[i+1] += a[i];
	}
	for(int i = 0; i < m; ++i) {
		cin >> b[i+1];
		b[i+1] += b[i];
	}
	int ans = 0;
	for(int i = 0, j = m; i <= n; ++i) {
		if(a[i] > k) break;
		while(a[i] + b[j] > k) {
			j--;
		}
		ans = max(ans, i + j);
	}
	cout << ans << "\n";
}

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


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

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

Measured memory_bytes: 256
#include <stdio.h>

int main(){
  int tmp, a, b, c;

  scanf("%d %d %d", &a, &b, &c);

  //???????????¨??????????????°??????????????????????????°??????
  if(a>b){
    tmp=b;
    b=a;
    a=tmp;
  }
  else{
  }
  //???????????¨???????????????????????????????????°??????
  if(b>c){
    tmp=c;
    c=b;
    b=tmp;
  }
  else{}

  //???????????¨???????????????????????????????????°??????
  if(a>b){
    tmp=b;
    b=a;
    a=tmp;
  }
  else{
  }

  printf("%d %d %d\n", a, b, c);

    return 0;
}

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

using namespace std;
#define  ll long long
#define ld long double
#define f first
#define s second
const int N = 2e5+5;

ll n , x , sz[N];
vector<ll> adj[N];

void dfs(int node)
{
    sz[node]++;
    for(auto ch : adj[node])
    {
        dfs(ch);
        sz[node] += sz[ch];
    }
}

int main()
{

    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);

    cin >> n;
    for(int i=2; i<=n; i++)
    {
        cin >> x;
        adj[x].push_back(i);
    }

    for(int i=1; i<=n; i++)
    {
        cout << adj[i].size() << '\n';
    }


    return 0;
}

Measured memory_bytes: 14524
#include <iostream>
#include <algorithm>
#include <vector>

using namespace std;


void eating_symbols_easy()
{
  string s;
  cin >> s;

  int cnt = 0;
  for (int i = 0; i < 4; ++i)
  {
    if (s[i] == '+') ++cnt;
    else --cnt;
  }
  cout << cnt << "\n";
}


void multiple_of_2_and_n()
{
  int n;
  cin >> n;

  if (n % 2 == 0) cout << n << "\n";
  else cout << 2 * n << "\n";
}


void task_scheduling_problem()
{
  vector<int> a(3);
  for (int i = 0; i < 3; ++i) cin >> a[i];

  sort(a.begin(), a.end());

  cout << a[2] - a[0] << "\n";
}


void rated_for_me()
{
  int r;
  cin >> r;

  if (r < 1200) cout << "ABC\n";
  else if (r < 2800) cout << "ARC\n";
  else cout << "AGC\n";
}


void atcoder_crackers()
{
  int n, k;
  cin >> n >> k;

  if (n % k == 0) cout << 0 << "\n";
  else cout << 1 << "\n";
}


void garden()
{
  int a, b;
  cin >> a >> b;

  cout << (a - 1) * (b - 1) << "\n";
}


void train()
{
  int n, i;
  cin >> n >> i;

  cout << n - i + 1 << "\n";
}


void Pair()
{
  int k;
  cin >> k;

  if (k % 2 == 0) cout << k / 2 * k / 2 << "\n";
  else cout << k / 2 * (k / 2 + 1) << "\n";
}


void ABC333()
{
  int a, b;
  cin >> a >> b;

  if ((a == 1 && (b == 1 || b == 3)) || (a == 3 && (b == 1 || b == 3))) cout << "Yes\n";
  else cout << "No\n";
}


void maximize_the_formula()
{
  int a, b, c;
  cin >> a >> b >> c;

  int v_max = max({ a,b,c });
  cout << a + b + c + 9 * v_max << "\n";
}


void digit_sums()
{
  int n;
  cin >> n;

  int s = 0, tmp = n;
  while (tmp > 0)
  {
    s += tmp % 10;
    tmp /= 10;
  }
  if (n % s == 0) cout << "Yes\n";
  else cout << "No\n";
}


void maximum_difference()
{
  int n;
  cin >> n;
  vector<int> a(n);
  for (int i = 0; i < n; ++i) cin >> a[i];

  sort(a.begin(), a.end());

  cout << a[n - 1] - a[0] << "\n";
}

void string_rotation() 
{
  string s, t;
  cin >> s >> t;

  for (int i = 0; i < s.size(); ++i)
  {
    if (s == t)
    {
      cout << "Yes\n";
      return;
    }
    char c = s.back();
    s.pop_back();
    s = c + s;
  }
  cout << "No\n";
}


int main()
{
  //eating_symbols_easy();
  //multiple_of_2_and_n();
  //task_scheduling_problem();
  //rated_for_me();
  //atcoder_crackers();
  //garden();
  //train();
  //Pair();
  //ABC333();
  //maximize_the_formula();

  //digit_sums();
  //maximum_difference();
  string_rotation();
}

Measured memory_bytes: 384
#include "bits/stdc++.h"
using namespace std;

int main(){
    long long int n,k;
    cin >> n >> k;
    if(k%2){
        cout << (n/k)*(n/k)*(n/k) << endl;
    } else {
        cout << (n/k)*(n/k)*(n/k)+(n/(k/2)-(n/k))*(n/(k/2)-(n/k))*(n/(k/2)-(n/k)) << endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define int long long
#define rep(a,b,c) for(int a=b;a<c;a++)
#define repm(a,b,c) for(int a=(b-1);a>=c;a--)
#define pb push_back
#define str string
#define INF 1<<64
#define sf(a) scanf("%d",&a)
using namespace std;
int replac(str s){double ans=0;rep(i,0,s.length()){ans+=(s[i]-'0')*pow(10,s.length()-i-1);}return (int)ans;}
typedef pair<int,int> pii;
vector<pii> vii;
signed main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n,l,p[100005];
    cin >> n >> l;
    int noko=0;
    for(int i=0;i<n;i++){
        cin >> p[i];
    }
    int num=0;
    for(int i=1;i<n;i++){
        if((p[i-1]+p[i])>=l){
            num=i;
            break;
        }
    }
    //cout << num << "a";
    //cout << lo << f;
    if(num){
        cout << "Possible" << endl;
        for(int i=1;i<num;i++){
            cout << i << endl;
        }
        for(int i=(n-1);i>=num;i--){
            cout << i << endl;
        }
    }else{
        cout << "Impossible" << endl;
    }
return 0;
}


Measured memory_bytes: 1664
import java.util.Scanner;

class Main {
    public static void main(String args[]) {
        Scanner sc = new Scanner(System.in);

        int debt = 100000;
        int weeks = sc.nextInt();
        for (int i = 0; i < weeks; i++) {
            debt = (int)(Math.ceil(debt*1.05 / 1000) * 1000);
        }

        System.out.println(debt);
    }
}

Measured memory_bytes: 26116
#include "bits/stdc++.h"
using namespace std;

typedef long long ll;

int main() {
	int N;
	string s, t;
	cin >> N >> s >> t;

	int ans=2*N;
	for (int i = 0; i < N; i++) {
		bool f=true;
		int k=0;
		for (int j = i; j < N; j++,k++) {
			if(s[j]!=t[k]) f=false;
		}
		if (f) {
			ans = N+i;
			break;
		}
	}

	cout << ans << endl;
}


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

int main()
{
    long long x,k,d;
    cin>>x>>k>>d;
    x=abs(x);
    if(x/d>=k) {
        cout<<x-d*k;
    }
    else {
        long long t=x/d;
        if((k-t)%2==0) cout<<x-t*d;
        else cout<<d-x+t*d;
    }
}

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

int main(){

  string s;
  cin >> s;
  int c[10];
  for(int i=0;i<10;i++){
    c[i]=0;
  }

  size_t len = s.length();
  for(int i=0;i<len;i++){
    if(s[i]!='A'&&s[i]!='T'&&s[i]!='G'&&s[i]!='C'){
      continue;
    }
    c[i]++;
    for(int j=i+1;j<len;j++){
       if(s[j]!='A'&&s[j]!='T'&&s[j]!='G'&&s[j]!='C'){
         break;
       }
       c[i]++;
    }
  }

  sort(c,c+10);
  cout << c[9] << endl;

}


Measured memory_bytes: 256
#include <utility>
#include <iostream>
#include <algorithm>
#include <queue>

using namespace std;

int D[110]; // ?????¢????¨???¶
int v, A[100][100], u, k, w;
queue<int> Q;



int main(){
	cin >> v;
	// ???????????§??????v
	for (int i = 0; i < v; ++i) {

		cin >> u >> k;
		// ??????????????????u???k?????\?????????????????°??????

		for (int j = 0; j < k; ++j) {

			cin >> w;
			A[u - 1][w - 1] = 1;

			// ??£??\???????????§?¨??????????????????????????????????

		}
	}
		Q.push(0);
		D[0] = 0;

		while (!Q.empty()) {
			int cur = Q.front();
			Q.pop();
			for (int i = 0; i < v; ++i) {
				if (A[cur][i] == 1 && D[i] == 0) {
					D[i] = D[cur] + 1;
					Q.push(i);
				}
			}
		}

		for (int l = 0; l < v; ++l) {
			//????????????????????????????????????
			if (D[l] == 0) { D[l] = -1; }
			if (l == 0) { D[l] = 0; }
			cout << l + 1 << " " << D[l] << endl;
		}

	}

Measured memory_bytes: 1240
h,n=map(int,input().split())
M=[list(map(int,input().split())) for _ in range(n)]
dp = [[-(-i//M[0][0])*M[0][1] for i in range(1,h+1)] for _ in range(n)]
for i in range(1,n):
  for j in range(h):
    if j<M[i][0]:
      dp[i][j]=min(dp[i-1][j],M[i][1])
    else:
      dp[i][j]=min(dp[i-1][j],dp[i][j-M[i][0]]+M[i][1])
print(dp[n-1][h-1])


Measured memory_bytes: 126652
#include <iostream>
#include <algorithm>
#include <cmath>
#include <limits>
#include <vector>
#include <cstdio>
#include <bits/stdc++.h>
#include <set>
#include <map>
#include <stdio.h>
using namespace std;
using ll =int long long;
map <int ,int> mpa,mpb;

int main (void){
  int H,W;
  cin >> H >>W;
  int s[H+2][W+2]={0};
  char a;
  int flag;
  for(int i=1;i<=H;i++){
      for(int j=1;j<=W;j++){
        cin >> a;
        if(int(a)==35){
          s[i][j]=1;
        }
      }
  }
  for(int i=1;i<=H;i++){
      for(int j=1;j<=W;j++){
        flag=0;
        if(s[i][j]==1){
          flag=s[i+1][j]+s[i][j+1]+s[i-1][j]+s[i][j-1];
          if(flag==0){
            cout <<"No";
            return 0;
          }
        }
      }
  }
  cout << "Yes";
}

Measured memory_bytes: 256
/*
    Author:zzugzx
    Lang:C++
    Blog:blog.csdn.net/qq_43756519
*/
#include<bits/stdc++.h>
using namespace std;
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define endl '\n'
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
const int mod=1e9+7;
//const int mod=998244353;
const double eps = 1e-10;
const double pi=acos(-1.0);
const int maxn=1e6+10;
const ll inf=0x3f3f3f3f;
const int dir[4][2]={{0,1},{1,0},{0,-1},{-1,0}};



int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);cout.tie(0);
    //freopen("in.txt","r",stdin);
    //freopen("out.txt","w",stdout);
    ll n;cin>>n;
    ll ans=0;
    for(ll i=2;i*i<=n;i++){
        if(n%i==0){
            int cnt=0,d=1;
            while(n%i==0)cnt++,n/=i;
            while(cnt>=d)cnt-=d,d++,ans++;
        }
    }
    if(n>1)ans++;
    cout<<ans;
    return 0;
}


Measured memory_bytes: 3652
#include <cstdio>
#include <map>
 
using std::map;
 
const int
	MAXN = 600000,
	MAXLGN = 16;
 
int N, Q;
map< int, int > pos;
int tree[MAXN];
int cant;
struct node {
	int val, L, R, size;
} buff[2 * MAXN * MAXLGN];
 
int build( int lo, int hi ) {
	if ( lo > hi ) return 0;
 
	int idx = ++cant;
	
	int mid = ( lo + hi ) / 2;
	buff[idx] = (node){ mid, build( lo, mid - 1 ), build( mid + 1, hi ), 0 };
	return idx;
}
 
int update( int x, int val, int amount ) {
 
	if ( x == 0 ) return 0;
 
	int idx = ++cant;
	
	int L = buff[x].L;
	int R = buff[x].R;
	if ( val < buff[x].val ) L = update( L, val, amount );
	if ( val > buff[x].val ) R = update( R, val, amount );
	
	buff[idx] = (node){ buff[x].val, L, R, buff[x].size + amount };
 
	return idx;
}
 
int query( int x, int val ) {
	if ( val < buff[x].val )
		return query( buff[x].L, val ) + buff[x].size -	buff[ buff[x].L ].size;
 
	if ( val > buff[x].val )
		return query( buff[x].R, val );
 
	return buff[x].size - buff[ buff[x].L ].size;
}
 
int main() {
 
	scanf( "%d %d", &N, &Q );
 
	tree[0] = build( 1, N );
	for ( int i = 1; i <= N; i++ ) {
		int x, posx;
		scanf( "%d", &x ); posx = pos[x];
		if ( posx != 0 )
			tree[i] = update( update( tree[i - 1], posx, -1 ), i, +1 );
		else
			tree[i] = update( tree[i - 1], i, +1 );
		pos[x] = i;
	}
 
	// scanf( "%d", &Q );
	while ( Q-- ) {
		int lo, hi;
		scanf( "%d %d", &lo, &hi );
		printf( "%d\n", query( tree[hi], lo ) );
	}
 
	return 0;
}

Measured memory_bytes: 293532
#include <bits/stdc++.h>
using namespace std;
long long int memo1[51] = {1};
long long int memo2[51] = {1};
long long int tall(int L){
    if(L == 0) return memo1[0];
    else{
        if(memo1[L] != 0) return memo1[L];
        return memo1[L] = 3 + 2*tall(L-1);
    }
}

long long int paty(int L){
    if(L == 0) return memo2[0];
    else{
        if(memo2[L] != 0) return memo2[L];
        return memo2[L] = 1 + 2*paty(L-1);
    }
}

long long int P(int L,long long int x){
    if(x == 1 && L == 0) return 1;
    else if(x == 1) return 0;
    else if(1 < x && x <= 1 + tall(L-1)) return P(L-1,x-1);
    else if(x == 2 + tall(L-1)) return paty(L-1) + 1;
    else if(2 + tall(L-1) < x && x <= 2 + 2*tall(L-1)) return 1 + paty(L-1) + P(L-1,x - 2 - tall(L-1));
    else if(2 + 2*tall(L-1) < x) return paty(L);
}

int main(){
    long long int N,x;
    cin >> N >> x;
    cout << P(N,x) << endl;
    return 0;
}

Measured memory_bytes: 256
//
//  main.cpp
//  B - String Palindrome
//
//  Created by Hashizo on 2020/03/22.
//  Copyright © 2020 Hashizo. All rights reserved.
//

#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <regex>
#include <cmath>

using namespace std;
 
#undef LONG_MAX
#undef LONG_MIN
 
#define LONG_MAX    9223372036854775807
#define LONG_MIN    (-LONG_MAX  -1)
 
#define ll long long
 
#define FOR(i, a, b) for (ll i = (a); i < (b); i++)
#define REP(i, n) FOR(i, 0, n)
 
#define SORT(c) sort((c).begin(), (c).end())
#define REVERSE(v) reverse((v).begin(), (v).end())


int main(int argc, const char * argv[]) {

	string s;
	cin >> s;

	ll n = s.size();
	ll half = (((n-1)/2));
	
	string s1,s2;
	s1 = s.substr(0, half);
	s2 = s.substr(half+1, n);
	REVERSE(s2);
	
	if (s1 != s2) {
		cout << "No" << endl;
		return 0;
	}

	string s3;
	string s4;
	n = s1.size();
	if (n % 2 == 0) {
		half = n / 2;
		s3 = s1.substr(0, half);
		s4 = s1.substr(half, n);
	}
	else {
		half = (((n-1)/2));
		s3 = s1.substr(0, half);
		s4 = s1.substr(half+1, n);
	}
	
	
	REVERSE(s4);

	if (s3 != s4) {
		cout << "No" << endl;
		return 0;
	}

	cout << "Yes" << endl;
	return 0;
}


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

#define ll long long int
#define str string
#define ALL(a)  (a).begin(),(a).end()
#define P pair<ll,ll>

using Graph = vector<vector<int>>;

const int dy[] = { 0, 0, 1, -1 }, dx[] = { 1, -1, 0, 0 };
ll INFL = 1ll << 60, INF = 1 << 30, mod = 1e9 + 7, Min = INFL, Max = -1;
ll a, b, c, n, sum, A[500010], B[500000], rui[500000], dp[5000];
str S, T, U; bool check = true;	vector<ll> v;



int main() {
	//Code Line
	cin >> a >> b;
	for (int i = 1; i <= 1000; i++) {
		c = i * 0.08;
		n = i * 0.1;
		if (c == a && n == b) { check = false; cout << i << endl; break; }
	}
	if (check)cout << -1 << endl;


	return 0;
}


Measured memory_bytes: 256
import sys, math
import io, os
#data = io.BytesIO(os.read(0,os.fstat(0).st_size)).readline
#from bisect import bisect_left as bl, bisect_right as br, insort
#from heapq import heapify, heappush, heappop
#from collections import defaultdict as dd, deque, Counter
#from itertools import permutations,combinations
def data(): return sys.stdin.readline().strip()
def mdata(): return list(map(int, data().split()))
def outl(var) : sys.stdout.write(' '.join(map(str, var))+'\n')
def out(var) : sys.stdout.write(str(var)+'\n')
#sys.setrecursionlimit(100000)
#INF = float('inf')
mod = 998244353
#from decimal import Decimal

a,v=mdata()
b,w=mdata()
t=int(data())
if a==b:
    out("YES")
elif a<b and a+v*t>=b+w*t:
    out("YES")
elif a>b and a-v*t<=b-w*t:
    out("YES")
else:
    out("NO")


Measured memory_bytes: 9196
#include<stdio.h>
#include<stdlib.h>
#define N 100000
  
int A[N];
int Partition(int A[],int p,int r);
int main(){
    
  int i,j,n,x;
    
  scanf("%d",&n);
  /*
    A = malloc(sizeof(int)*n+1);
    B = malloc(sizeof(int)*n+1);
  */
  for(i=0;i<n;i++){
    scanf("%d",&A[i]);
  }
    
  x=Partition(A,0,n-1);
  for(i=0;i<x;i++){
    printf("%d ",A[i]);   
  }
  printf("[%d] ",A[x]);
  for(i=x+1;i<n;i++){
    printf("%d",A[i]);
    if(i!=n-1)
      printf(" ");    
  }
  printf("\n");
  return 0;
}
  
int Partition(int A[],int p,int r){
  int x,i,j,n;
  x=A[r];
  i=p-1;
  for(j=p;j<=r-1;j++){
    if(x>=A[j]){
      i=i+1;
      n=A[j];
      A[j]=A[i];
      A[i]=n;
    }
  }
  n=A[r];
  A[r]=A[i+1];
  A[i+1]=n;
  return i+1;
}

Measured memory_bytes: 988
#include<iostream>
#include<algorithm>
#include<string>
#include<cmath>
#include<map>
#include<queue>
#include<set>
#include<vector>
#include<cstdio>

using namespace std;
/*
int find(int x, vector<int> &p) {
if (p[x] == x)return x;
return p[x] = find(p[x], p);
}

void uni(int x, int y, vector<int> &p) {
x = find(x, p);
y = find(y, p);
p[x] = y;
}

int same(int x, int y, vector<int> p) {
if (find(x, p) == find(y, p))return 1;
return 0;
}
*/

int main()
{
	int N, ans = 0;
	string S;

	cin >> S;

	for (auto s : S) {
		if (s == '-') {
			ans--;
		}
		else {
			ans++;
		}
	}

	cout << ans << endl;

	char qq;
	cin >> qq;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
void SUN(string s)
{
    if (s == "SUN")
        cout << 7 << endl;;
}
void MON(string s)
{
    if (s == "MON")
        cout << 6 << endl;;
}
void TUE(string s)
{
    if (s == "TUE")
        cout << 5 << endl;
}
void WED(string s)
{
    if (s == "WED")
        cout << 4 << endl;;
}
void THU(string s)
{
    if (s == "THU")
        cout << 3 << endl;
}
void FRI(string s)
{
    if (s == "FRI")
        cout << 2 << endl;
}
void SAT(string s)
{
    if (s == "SAT")
        cout << 1 << endl;
}
int main()
{
    string S;
    cin >> S;
    while (S != "SUN" && S != "SUN" && S != "MON" && S != "TUE" && S != "WED" && S != "THU" && S != "FRI" && S != "SAT")
    {
        cin >> S;
    }
    SUN(S); MON(S); TUE(S); WED(S); THU(S); FRI(S); SAT(S);
    return 0;
}


Measured memory_bytes: 256
// AOJ 0304 (http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=0304)
#include<cctype>
#include<iostream>
#include<string>
#include<vector>
#include<limits>
#define rep(i,a) for(int i=0;i<(a);++i)

const int MAX_N = 210, MAX_C = 210, INF = std::numeric_limits<int>::max()>>2;

struct edge
{
	int from, to, cost;

	edge( int from, int to, int cost )
	:	from(from), to(to), cost(cost)
	{}
};

struct Dat
{
	int a, b, d;
	bool pm;

	Dat( int a, int b, int d, bool pm )
	:	a(a), b(b), d(d), pm(pm)
	{}
};

int N, C;
std::string cst[MAX_C];
std::vector<edge> es;
std::vector<Dat> dats;
int d[MAX_N];

int read( int &p, const std::string &s )
{
	int ret = 0;

	while( p < s.size() && isdigit(s[p]) )
		ret *= 10, ret += s[p++]-'0';

	return ret;
}

int bellmanFord()
{
	std::fill( d, d+N, INF );
	d[0] = 0;
	
	rep( j, N )
	{
		rep( i, es.size() ) if( d[es[i].from] != INF && d[es[i].from]+es[i].cost < d[es[i].to] )
		{
			d[es[i].to] = d[es[i].from]+es[i].cost;

			if( j == N-1 )
				return -INF;
		}
	}

	int ret = -INF;
	rep( j, N )
		ret = std::max( ret, d[j] );

	return ret;
}

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

	std::cin >> N >> C;
	rep( i, C )
	{
		std::cin >> cst[i];

		int p = 0, t = 0, d = 0;
		bool pm;

		int a = read( p, cst[i] );
			
		if( cst[i][p] == '<' )
			t = 0, p += 2;
		else if( cst[i][p] == '>' )
			t = 1, p += 2;
		else if( cst[i][p] == '*' )
			t = 2, ++p;

		int b = read( p, cst[i] );
		pm = cst[i][p++]=='+';
		d = read( p, cst[i] );

		--a; --b;

		es.push_back( edge( a, 0, 0 ) );
		es.push_back( edge( b, 0, 0 ) );
	
		if( !t )
		{
			es.push_back( edge( b, a, 0 ) );
			es.push_back( pm?edge( b, a, -d ):edge( a, b, d ) );
		}
		else if( t == 1 )
		{
			es.push_back( edge( a, b, 0 ) );
			es.push_back( pm?edge( a, b, -d ):edge( b, a, d ) );
		}
		else if( t == 2 )
			dats.push_back( Dat( a, b, d, pm ) );
	}

	int ans = -INF;

	if( dats.empty() )
		ans = std::max( ans, bellmanFord() );

	rep( i, 1<<(dats.size()) )
	{
		rep( j, dats.size() )
		{
			if( i>>j&1 )
			{
				es.push_back( edge( dats[j].b, dats[j].a, 0 ) );
				es.push_back( dats[j].pm?edge( dats[j].b, dats[j].a, -dats[j].d ):edge( dats[j].a, dats[j].b, dats[j].d ) );
			}
			else
			{
				es.push_back( edge( dats[j].a, dats[j].b, 0 ) );
				es.push_back( dats[j].pm?edge( dats[j].a, dats[j].b, -dats[j].d ):edge( dats[j].b, dats[j].a, dats[j].d ) );
			}
		}

		 ans = std::max( ans, bellmanFord() );

		 rep( j, dats.size()*2 )
			es.pop_back();
	}

	if( ans == INF )
		std::cout << "inf" << std::endl;
	else
		std::cout << (ans>=0?ans:-1) << std::endl;

	return 0;
}

Measured memory_bytes: 1236
#include<iostream>
#include<vector>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i=0; i<(n); ++i)
template<class T> inline bool chmax(T & a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }


int main()
{
	int N, W; cin >> N >> W;
	vector<int> vs(N), ws(N);
	rep(i, N) cin >> vs[i] >> ws[i];
    vector<ll> dp(W+1, 0);  //	//重さwで最大の価値
	
	for (int i = 0; i < N; ++i) {
		for (int w = 0; w <= W; ++w) {
			if (w >= ws[i]) {
				chmax(dp[w], dp[w - ws[i]] + vs[i]);
			}
		}
	}
	cout << dp[W] << endl;
}



Measured memory_bytes: 3204
#include <stdio.h>

int main(void){
    int D,N=0;
    int Ringo=1;
    scanf("%d%d",&D,&N);

    for(int i=0;i<D;i++){
        Ringo*=100;
    }
    if(N!=100){
        Ringo*=N;
    } else {
        Ringo*=101;
    }
    printf("%d",Ringo);
    return 0;
}


Measured memory_bytes: 128
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#define int long long
using namespace std;
int n, k;
vector<int>v[123456]; bool p[123456];
int ans = 1, mod = 1000000007;
void f(int x, int d) {
	p[x] = 1; int j = 0;
	for (int i = 0; i < v[x].size(); i++) {
		if (!p[v[x][i]]) {
			if (d == 0)ans *= k - 1 - j;
			else ans *= k - 2 - j;
			ans %= mod;
			f(v[x][i], d + 1);
		}
		else j--;
		j++;
	}
	return;
}
signed main() {
	cin >> n >> k;
	for (int i = 1; i < n; i++) {
		int a, b; cin >> a >> b;
		v[a].push_back(b);
		v[b].push_back(a);
	}
	ans = k; p[1] = 1;
	f(1, 0);
	cout << ans << endl; cin >> n;
}

Measured memory_bytes: 11008
int zeller(int Y,int M,int D){if(++M<4)Y-=1,M+=14;int y=Y/100,z=y%100;return (21*y/4+5*z/4+26*M/10+D)%7;}
char *W[]={"Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"};
main(m,d){for(;scanf("%d%d",&m,&d),m;)puts(W[zeller(2004,m,d)]);exit(0);}

Measured memory_bytes: 0
#include<bits/stdc++.h>
#include<queue>
using namespace std;
void bfs(vector<pair<long, long> > adj[], bool visited[],int n){
	int color[n+1];
	for(long i=0;i<=n;i++){
		color[i]=-1;
	}
	color[0]=-1;
	color[1]=0;
	visited[1]=true;
	queue<long> q;
	q.push(1);
	while(!q.empty()){
		long temp=q.front();
		q.pop();
		vector<pair<long, long> >::iterator i;
		for(i=adj[temp].begin();i!=adj[temp].end();i++){
			if(!visited[i->first]){
				q.push(i->first);
				if(i->second % 2){
					if(color[temp]==1){
						color[i->first]=0;
					}
					else if(color[temp]==0){
						color[i->first]=1;
					}
			    }
			    else {
			    	if(color[temp]==1){
						color[i->first]=1;
					}
					else if(color[temp]==0){
						color[i->first]=0;
					}
				}
				visited[i->first]=true;
			}
		}
	}
	for(long int it=1;it<=n;it++){
		cout<<color[it]<<endl;
	}
}
int main(){
	long n;
	cin>>n;
	vector<pair<long, long> > adj[n+1];
	bool visited[n+1];
	for(long i=1;i<=n;i++){
		visited[i]=false;
	}
	long w,x,y;
	for(long i=1;i<n;i++){
		cin>>x>>y>>w;
		adj[x].push_back(make_pair(y,w));
		adj[y].push_back(make_pair(x,w));
	}
	bfs(adj,visited,n);
	return 0;
}

Measured memory_bytes: 8320
import math

n = int(input())
ans_min = 10 ** 13
for i in range(1, int(math.sqrt(n)) + 1):
    a, b = divmod(n, i)
    if b == 0:
        ans = a + i - 2
        if ans_min > ans > 0:
            ans_min = ans
print(ans_min)


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

typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;
typedef pair<LL, LL> PLL;

#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)

#define FF first
#define SS second
template<class S, class T>
istream& operator>>(istream& is, pair<S,T>& p){
  return is >> p.FF >> p.SS;
}

const double EPS = 1e-10;
const double PI  = acos(-1.0);
const LL MOD = 1e9+7;

string S;
int idx, N;

struct T{
  int rep;
  char c;
  vector<T> chd;
  T(){rep=0, c='0';}
};

/*
  <expr> ::= <term> | <term> <expr>
  <term> ::= c | <num> c | <num> ( <expr> )
 */

pair<int,T> expr(int p);
pair<int,T> term(int p=0){
  T t;
  if(isdigit(S[p])){
	t.rep = S[p] - '0';
	for(;isdigit(S[++p]);t.rep=t.rep*10+(S[p]-'0'));
	if(S[p] == '('){
	  auto res = expr(p+1);
	  p = res.FF;
	  t.chd.EB(res.SS);
	  assert(S[p] == ')');
	  return MP(p+1, t);
	}
	else{
	  t.c = S[p];
	  return MP(p+1, t);
	}
  }
  else{
	t.rep = 1;
	t.c = S[p++];
	return MP(p, t);
  }
}

pair<int,T> expr(int p=0){
  T t;
  t.rep = 1;
  while(p < N && S[p] != ')'){
	auto res = term(p);
	p = res.FF;
	t.chd.EB(res.SS);
  }

  return MP(p, t);
}

void debug(T& t, int lv = 1){
  REP(i,lv) cout << "*";
  cout << " " << t.rep << ": " << t.c << endl;
  for(auto& c: t.chd)
	debug(c, lv+1);
}


char dfs(T& t){
  REP(j,t.rep){
	if(!t.chd.empty())
	  for(auto& ch: t.chd){
		char c = dfs(ch);
		if(c != '0') return c;
	  }
	else{
	  if(idx == 0) return t.c;
	  --idx;
	}
  }
  return '0';
}

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

  while(cin>>S>>idx,S!="0"){
	N = SZ(S);
	auto rt = expr(0).SS;
	char c = dfs(rt);
	cout << (c? c: '0') << endl;
  }
  
  return 0;
}

Measured memory_bytes: 3160
// include
// ------------------------------------------------
#include <bits/stdc++.h>
#include <vector>
#include <algorithm>
#include <math.h>

using namespace std;

// func
// ------------------------------------------------
int CalcSumOfDigit(int n);      // 各桁の和を計算する。
string upper(string str);       // 英字を大文字に変換する。
string lower(string str);       // 英字を小文字に変換する。

// define
// ------------------------------------------------
#define all(a)        (a).begin(),(a).end()
#define rall(a)       (a).rbegin(),(a).rend()
#define pb            push_back
#define sz(a)         int((a).size())
#define rep(i,n)      for(int(i)=0;(i)<(n);(i)++)
#define repe(i,n)     for(int(i)=0;(i)<=(n);(i)++)
#define vsort(v)      sort((v).begin(),(v).end())
#define rvsort(v)     sort(rall((v)))
#define vi            vector<int>
#define GCD(a,b)      __gcd((a),(b))
#define LCM(a,b)      (a)/GCD((a),(b))*(b)
#define kiriage(a,b)  ((a)+(b)-1)/(b)

const int INF = 1e9;

// code
// ------------------------------------------------
int main() {

  int n; cin >> n;
  vi p(n);

 
  rep(i,n) cin >> p[i];

  int  cnt = 0;

  rep(i,n - 2)
  {
    if(p[i] < p[i+1] && p[i+1] < p[i+2])
      cnt++;
    else if(p[i+2] < p[i+1] && p[i+1] < p[i])
      cnt++;
  }

  cout << cnt;

  return 0;
}

// funcの実体
// ------------------------------------------------
int CalcSumOfDigit(int n)
{
  int s = 0;
  while(n)
  {
    s += n % 10;
    n = n / 10;
  }
  return s;
}

string upper(string str)
{
  for(auto itr = str.begin();itr != str.end() ; itr++)
  {
    if(97 <= *itr && *itr <= 122)
    {
      *itr = *itr - 32;
    }
  }
  return str;
}

string lower(string str)
{
  for(auto itr = str.begin();itr != str.end() ; itr++)
  {
    if(65 <= *itr && *itr <= 90)
    {
      *itr = *itr + 32;
    }
  }
  return str;
}


Measured memory_bytes: 256
n,m = map(int, input().split())
x = sorted(list(map(int ,input().split())))

if n >= m:
  print(0)
  exit()

nums = [0]*(m-1)
for i in range(m-1): nums[i] = x[i+1] - x[i]
nums.sort()
print(sum(nums[:m-1-(n-1)]))

Measured memory_bytes: 20316
using System.Linq;
using System.Collections.Generic;
using System;

public class hello
{
    public static void Main()
    {
        while (true)
        {
            string[] line = Console.ReadLine().Trim().Split(' ');
            var n = int.Parse(line[0]);
            var k = int.Parse(line[1]);
            if (n == 0 && k == 0) break;
            if (n == 1) { Console.WriteLine(0); goto end; }
            var a = GeneratePrime(n);
            var aL = a.Length;
            var dp = new int[n + 1, k + 2];
            dp[0, 0] = 1;
            for (int i = 0; i < aL; i++)
                for (int j = k; j >= 0; j--)
                    for (int L = 0; L <= n; L++)
                        if (dp[L, j] == 0 | L + a[i] > n) continue;
                        else dp[L + a[i], j + 1] += dp[L, j];
            Console.WriteLine(dp[n,k]);
            end:;
        }
    }
    public static int[] GeneratePrime(int m)
    {
        var ans = new List<int>();
        int prime;
        var sqrtMax = Math.Sqrt(m);
        var searchList = Enumerable.Range(2, m - 1).ToList();
        do
        {
            prime = searchList.First();
            ans.Add(prime);
            searchList.RemoveAll(n => n % prime == 0);
        }
        while (prime < sqrtMax);
        ans.AddRange(searchList);
        return ans.ToArray();
    }
}


Measured memory_bytes: 10988
#include<bits/stdc++.h>
using namespace std;
#define ALL(x) x.begin(),x.end()
#define rep(i,n) for(int i=0;i<n;i++)
#define debug(n,v) cout<<#v<<":";for(int i=0;i<n;i++)cout<<v[i]<<" ";cout<<endl; 
#define INF 1000000000
#define mod 1000000007
typedef long long ll;
const ll LINF = 1001002003004005006ll;
int dx[]={1,0,-1,0};
int dy[]={0,1,0,-1};
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
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; }

int main(){
    ll n;
    cin>>n;
    vector<ll> a(n);
    bool f=false;
    rep(i,n){
        cin>>a[i];
        if(a[i]%2) f=true;
    }
    cout<<(f?"first":"second")<<endl;
    return 0;
}


Measured memory_bytes: 1024
#include<bits/stdc++.h>
#define LL long long
#define N 100005
#define db(x) cout<<#x<<"="<<x<<endl;
using namespace std;
int n,a[N];
LL sum,x[N];
int main() {
	scanf("%d",&n);
	for(int i=1;i<=n;i++)scanf("%d",&a[i]),sum+=a[i];
	sum>>=1;
	for(int i=1;i<n;i+=2)sum-=a[i];
	x[n]=sum;
	x[1]=a[n]-x[n];
	for(int i=1;i<n;i++)x[i+1]=a[i]-x[i];
	for(int i=1;i<=n;i++)printf("%lld",x[i]<<1),putchar(i==n?'\n':' ');
	return 0;
}


Measured memory_bytes: 2432
#include <cstring>
#include <iostream>
#include <algorithm>
#include <string>
using namespace std;

const int INF = (int)1e9;

int dp[1001][1001];
string A, B;

int solve(int i, int j) {
  if(i == A.length() || j == B.length()) return max(A.length() - i, B.length() - j);
  int &res = dp[i][j];
  if(res != -1) return res;
  if(A[i] == B[j]) return res = solve(i + 1, j + 1);
  res = INF;
  res = min(res, 1 + solve(i + 1, j)); // jの位置にA[i]を挿入
  res = min(res, 1 + solve(i + 1, j + 1)); // B[j]をA[i]に置換
  res = min(res, 1 + solve(i, j + 1)); // jの位置の文字を削除
  return res;
}

int main() {
  cin >> A >> B;
  memset(dp, -1, sizeof(dp));
  cout << solve(0, 0) << endl;
}

Measured memory_bytes: 5196
#include<iostream>
#include<map>
#include<vector>
#include<cmath>
#include<string>
#include<algorithm> 
#include<regex>
using namespace std;

# define p(s) std::cout << s << endl;
# define printIf(j,s1,s2) cout << (j ? s1 : s2) << endl;
# define YES(j) cout << (j ? "YES" : "NO") << endl;
# define Yes(j) std::cout << (j ? "Yes" : "No") << endl;

int main()
{
    string s;
    cin>>s;
    cout<<(regex_match(s, regex("^A[a-z]+C[a-z]+$")) ? "AC" : "WA")<<endl;
}

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

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

    if(A>=13){
        cout<<B<<endl;
        return 0;
    }
    if(A>=6&&A<=12){
        cout<<B/2<<endl;
        return 0;
    }
    cout<<0<<endl;
}

Measured memory_bytes: 256
using System;
using System.Linq;//リストの使用
using System.Collections.Generic;
class Program
{
	static void Main()
	{
		long n = long.Parse(Console.ReadLine());//int.Parseは文字列を整数に変換。
    long[][] vertexesL = new long[n][];//座標と番号
    long[][] vertexesR = new long[n][];
    long[] looked = new long[n];//LかRのどちらかを確認したら1
    long checkingL = 0;
    long checkingR = 0;
    long answer = 0;
    long distanceMemo = 0;//距離の総和をメモ
    long nowPosition = 0;
    for(long i = 0; i < n; i++)
    {
      long[] nums = Array.ConvertAll(Console.ReadLine().Split(' '),long.Parse);
      vertexesL[i] = new long[2];
      vertexesL[i][0] = nums[0];
      vertexesL[i][1] = i;
      vertexesR[i] = new long[2];
      vertexesR[i][0] = nums[1];
      vertexesR[i][1] = i;
    }

    Array.Sort(vertexesL, (a, b) => b[0].CompareTo(a[0]));//ソート
    Array.Sort(vertexesR, (a, b) => a[0].CompareTo(b[0]));

    while(true)
    {
      while(true)//右へ
      {
        if(looked[vertexesL[checkingL][1]] == 0)
        {
          if(nowPosition < vertexesL[checkingL][0])//移動する場合
          {
            distanceMemo += Math.Abs(nowPosition - vertexesL[checkingL][0]);
            nowPosition = vertexesL[checkingL][0];
          }
          looked[vertexesL[checkingL][1]] = 1;
          break;
        }else checkingL++;
        if(checkingL >= n) break;
      }
      while(true)//左へ
      {
        if(looked[vertexesR[checkingR][1]] == 0)
        {
          if(nowPosition > vertexesR[checkingR][0])//移動する場合
          {
            distanceMemo += Math.Abs(nowPosition - vertexesR[checkingR][0]);
            nowPosition = vertexesR[checkingR][0];
          }
          looked[vertexesR[checkingR][1]] = 1;
          break;
        }else checkingR++;
        if(checkingR >= n) break;
      }
      if(checkingR >= n)//全て確認した
      {
        distanceMemo += Math.Abs(nowPosition);
        answer = Math.Max(answer, distanceMemo);
        break;
      }
    }

    nowPosition = 0;
    distanceMemo = 0;
    checkingL = 0;
    checkingR = 0;

    while(true)
    {
      while(true)//左へ
      {
        if(looked[vertexesR[checkingR][1]] == 1)
        {
          if(nowPosition > vertexesR[checkingR][0])//移動する場合
          {
            distanceMemo += Math.Abs(nowPosition - vertexesR[checkingR][0]);
            nowPosition = vertexesR[checkingR][0];
          }
          looked[vertexesR[checkingR][1]] = 2;
          break;
        }else checkingR++;
      if(checkingR >= n) break;
      }
    
      while(true)//右へ
      {
        if(looked[vertexesL[checkingL][1]] == 1)
        {
          if(nowPosition < vertexesL[checkingL][0])//移動する場合
          {
            distanceMemo += Math.Abs(nowPosition - vertexesL[checkingL][0]);
            nowPosition = vertexesL[checkingL][0];
          }
          looked[vertexesL[checkingL][1]] = 2;
          break;
        }else checkingL++;
        if(checkingL >= n) break;
      }
      if(checkingL >= n)//全て確認した
      {
        distanceMemo += Math.Abs(nowPosition);
        answer = Math.Max(answer, distanceMemo);
        break;
      }
    }
    
		Console.WriteLine(answer);
	}
}

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

typedef long long ll;
typedef long double ld;
typedef pair <ll, ll> pll;

#define pb push_back
#define mp make_pair
#define all(_c) _c.begin(), _c.end()

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

    int n, k; string s;
    cin >> n >> k >> s;

    vector <int> l, r;
    vector <pair <int, int> > z;

    for (int i = 0; i < n; ) {
        int j = i + 1;
        while (s[j] == s[j - 1] and j < n) j++;
        if (s[i] == '0')
            z.emplace_back(i, j - 1);
        else {
            l.push_back(i);
            r.push_back(j - 1);
        }
        i = j;
    }

    if (z.empty()) {
        cout << n << '\n';
        return 0;
    }


    int ans = 0;
    for (int i = 0, j = 0; j < z.size(); j++) {
        int en_val = n - 1;
        auto en_it = lower_bound(all(l), z[j].second + 1);
        if (en_it != l.end())
            en_val = min(en_val, r[en_it - l.begin()]);

        int st_val = 0;
        auto st_it = lower_bound(all(r), z[i].first - 1);
        if (st_it != r.end() and z[i].first)
            st_val = max(st_val, l[st_it - r.begin()]);

        ans = max(ans, en_val - st_val + 1);
        if (j - i + 1 == k)
            i++;
    }

    cout << ans << '\n';
    return 0;
}


Measured memory_bytes: 1400
/*
    Problem 26
    https://atcoder.jp/contests/abc138/tasks/abc138_d
*/
#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <map>
#include <numeric>
#include <string>
#include <cmath>
#include <iomanip>
#include <queue>
#include <list>
#include <set>
#include <stack>
#include <cctype>
#include <cmath>
#include <bitset>

using namespace std;
/* typedef */
typedef long long ll;
/* constant */
const int MAX = (2e+5) + 1;
/* global variables */
vector< vector<int> > G(MAX, vector<int>());
vector<int> visited(MAX), counter(MAX);
/* function */
void dfs() {
    stack<int> S;
    S.push(0);
    visited[0] = 1;
    while (!S.empty()) {
        int v = S.top();
        S.pop();
        for (int u : G[v]) {
            if (visited[u]) continue;
            visited[u] = 1;
            counter[u] += counter[v];
            S.push(u);
        }
    }
}
/* main */
int main(){
    int N, Q, a, b, p, x;
    cin >> N >> Q;
    for (int i = 0; i < N - 1; i++) {
        cin >> a >> b;
        a--; b--;
        G[a].push_back(b);
        G[b].push_back(a);
    }
    for (int i = 0; i < Q; i++) {
        cin >> p >> x;
        p--;
        counter[p] += x;
    }
    dfs();
    for (int i = 0; i < N; i++) {
        if (i) cout << ' ';
        cout << counter[i];
    }
    cout << '\n';
}

Measured memory_bytes: 16372
package main

import (
	"bufio"
	"fmt"
	"os"
	"sort"
	"strconv"
)

/*-----------Main-----------*/

func main() {
	x := readI()
	ans := 0
	switch {
	case x < 600:
		ans = 8
	case x < 800:
		ans = 7
	case x < 1000:
		ans = 6
	case x < 1200:
		ans = 5
	case x < 1400:
		ans = 4
	case x < 1600:
		ans = 3
	case x < 1800:
		ans = 2
	case x < 2000:
		ans = 1
	}
	fmt.Println(ans)
}

/*-----------Utilities-----------*/

var sc = bufio.NewScanner(os.Stdin)

func init() {
	if len(os.Args) >= 2 {
		if os.Args[1] == "debug" {
			debug()
		}
	}
	const maxBuf = 200100
	var buf []byte = make([]byte, maxBuf)
	sc.Split(bufio.ScanWords)
	sc.Buffer(buf, maxBuf)
}

func debug() {
	testFile, err := os.Open("./test/sample-1.in")
	if err != nil {
		fmt.Fprintln(os.Stderr, "Error : There is no testfile.")
		os.Exit(1)
	}
	sc = bufio.NewScanner(testFile)
}

func readS() string {
	sc.Scan()
	return sc.Text()
}

func readSs(a int) []string {
	b := make([]string, a)
	for i := 0; i < a; i++ {
		b[i] = readS()
	}
	return b
}

func readI() int {
	sc.Scan()
	r, _ := strconv.Atoi(sc.Text())
	return r
}

func readIs(a int) []int {
	b := make([]int, a)
	for i := 0; i < a; i++ {
		b[i] = readI()
	}
	return b
}

func readF() float64 {
	sc.Scan()
	r, _ := strconv.ParseFloat(sc.Text(), 64)
	return r
}

func readFs(a int) []float64 {
	b := make([]float64, a)
	for i := 0; i < a; i++ {
		b[i] = readF()
	}
	return b
}

func max(a []int) int {
	l := len(a)
	m := a[0]
	for i := 1; i < l; i++ {
		if a[i] > m {
			m = a[i]
		}
	}
	return m
}

func min(a []int) int {
	l := len(a)
	m := a[0]
	for i := 1; i < l; i++ {
		if a[i] < m {
			m = a[i]
		}
	}
	return m
}

func sortI(a []int) []int {
	sort.Ints(a)
	return a
}

func reverse(a []int) []int {
	l := len(a)
	r := make([]int, l)
	for i := 0; i < l; i++ {
		r[i] = a[l-i-1]
	}
	return r
}

func countI(a []int, b int) int {
	l := len(a)
	var c int
	for i := 0; i < l; i++ {
		if a[i] == b {
			c++
		}
	}
	return c
}


Measured memory_bytes: 1780
#include<cstring>
#include<cstdio>
#include<iostream>
#include<algorithm>
#include<vector>
#include<cmath>
#include<map>
#define l(x) (x<<1)
#define r(x) ((x<<1)+1)
#define IL inline
#define reg register
#define LL long long
#define INF 0x3f3f3f3f
using namespace std;

int n,i,x,y,Ans;

IL int Abs(int x){return (x<0)?-x:x;}
IL void Swap(int &a,int &b){a^=b^=a^=b;}
IL int Min(int a,int b){return (a<b)?a:b;}
IL int Max(int a,int b){return (a>b)?a:b;}

IL int read(){
	int p=0,f=1;	char	c=getchar();
	while (c<48||c>57)	{if (c=='-')	f=-1;	c=getchar();}
	while (c>=48&&c<=57)	p=(p<<1)+(p<<3)+c-48,c=getchar();
	return p*f;
}

IL LL Cal(int x){
	LL cnt=0,i=0,j=0,up=0,t=0,z=0;
	up=int(sqrt(x))+1;
	for (i=1;i<=up;i++){
		if (i*i>x)	goto END;
		for (j=1;j<=up;j++){
			t=i*i+j*j;
			if (t>x)	goto END;
			z=(i+j)*(i+j)-4*i*j+4*x-4*i*i-4*j*j;
			if (z<0)	continue;
			t=(LL)(sqrt(z));
			if (t*t!=z)	continue;
			t-=(i+j);
			if	(t<=0)	continue;
			if (t%2)	continue;
			cnt++;
			//cout<<i<<" "<<j<<t/2<<endl;
		}
		END:;
	}
	return cnt;
}

int main(){
	#ifdef __Marvolo
	freopen("zht.in","r",stdin);
	freopen("zht.out","w",stdout);
	#endif
	n=read();
	for (i=1;i<=n;i++){
		printf("%lld\n",Cal(i));
	}
	return 0;
}

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

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

using namespace std;

int main() {
	int k, s, ans = 0;
	cin >> k >> s;
	REP(i, k+1) {
		REP(j, k+1) {
			if (i + j <= s && i + j + k >= s) {
				ans++;
			}
		}
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
# -*- coding: utf-8 -*-

import sys

def input(): return sys.stdin.readline().strip()
def list2d(a, b, c): return [[c] * b for i in range(a)]
def list3d(a, b, c, d): return [[[d] * c for j in range(b)] for i in range(a)]
def list4d(a, b, c, d, e): return [[[[e] * d for j in range(c)] for j in range(b)] for i in range(a)]
def ceil(x, y=1): return int(-(-x // y))
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(N=None): return list(MAP()) if N is None else [INT() for i in range(N)]
def Yes(): print('Yes')
def No(): print('No')
def YES(): print('YES')
def NO(): print('NO')
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
MOD = 10 ** 9 + 7

class BIT2:
    """ 区間加算BIT(区間加算・区間合計取得) """

    def __init__(self, N):
        self.N = N
        self.data0 = [0] * N
        self.data1 = [0] * N

    def _add(self, data, k, x):
        while k < self.N:
            data[k] += x
            k += k & -k

    def _get(self, data, k):
        s = 0
        while k:
            s += data[k]
            k -= k & -k
        return s

    def add(self, l, r, x):
        """ 区間[l,r)に値xを追加 """

        self._add(self.data0, l, -x*(l-1))
        self._add(self.data0, r, x*(r-1))
        self._add(self.data1, l, x)
        self._add(self.data1, r, -x)

    def query(self, l, r):
        """ 区間[l,r)の和を取得 """

        return self._get(self.data1, r-1) * (r-1) + self._get(self.data0, r-1) \
             - self._get(self.data1, l-1) * (l-1) - self._get(self.data0, l-1)

N, Q = MAP()
bit = BIT2(N+1)

ans = []
for i in range(Q):
    cmd, *arg = MAP()
    if cmd == 0:
        s, t, x = arg
        bit.add(s, t+1, x)
    else:
        i, = arg
        ans.append(str(bit.query(i, i+1)))
print('\n'.join(ans))



Measured memory_bytes: 15660
#include <bits/stdc++.h>
#define REP(i, x, y) for (ll i = x; i <= y; i++)
#define BIT(t) (1ll << t)
#define PER(i, y, x) for (ll i = y; i >= x; i--)
#define vll vector<ll>
#define vvll vector<vector<ll>>
#define pll pair<ll, ll>
#define SIZE(v) ll(v.size())
#define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end());
using namespace std;
typedef long long ll;
//        ios::sync_with_stdio(false);
//        cin.tie(nullptr);

int main(){
  ll a,v,b,w,t;
  cin >> a >> v >> b >> w >> t;
  if(v <= w){
    cout << "NO" << endl;
    return 0;
  }
  if(abs(a-b) <= (v - w) * t){
    cout << "YES" << endl;
  }else{
    cout << "NO" << endl;
  }
}

Measured memory_bytes: 3624