akhauriyash/Code-Regression huggingface dataset:
s = input()

not_ACGT_list = [-1]
max_len = 0

for i in range(len(s)):
    if s[i] != "A" and s[i] != "C" and s[i] != "G" and s[i] != "T":
        not_ACGT_list.append(i)
not_ACGT_list.append(len(s))
#print(not_ACGT_list)
        
for i in range(len(not_ACGT_list)-1):
    max_len = max(max_len,not_ACGT_list[i+1]-not_ACGT_list[i]-1)

print(max_len)

Measured memory_bytes: 8976
n=int(input())
lst=list(input().split())
lst1=[""]*n
lst2=[""]*n
for i in range(n):
    lst1[i]=lst[i]
    lst2[i]=lst[i]

for i in range(n-1):
    for j in range(i+1,n)[::-1]:
        if int(lst1[j][1])<int(lst1[j-1][1]):
            lst1[j],lst1[j-1]=lst1[j-1],lst1[j]
print(*lst1)
print("Stable")

for i in range(n-1):
    minlst=min([int(lst2[_][1]) for _ in range(i,n)])
    if minlst==int(lst2[i][1]):continue
    for j in range(i+1,n):
        if minlst==int(lst2[j][1]):
            lst2[i],lst2[j]=lst2[j],lst2[i]
            break
print(*lst2)
print("Stable" if lst1==lst2 else "Not stable")


Measured memory_bytes: 5620
#include <bits/stdc++.h>
using namespace std;
typedef pair<int,int> P;
#define FOR(I,A,B) for(int I=int(A);I<int(B);++I)
#define FORR(I,A,B) for(int I=int(B-1);I>=int(A);--I)

int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	
	int n;
	cin >> n;
	vector<int> v(n);
	FOR(i,0,n)cin >> v[i];
	cout << v[n-1];
	FORR(i,0,n-1)cout<<' '<<v[i];
	cout << endl;
}



Measured memory_bytes: 3132
#include <iostream>
#include <cstring>
#include <algorithm>
#include <vector>
#include <string>
#include <math.h>
#include <iomanip>
#include <limits>
#include <list>
#include <queue>
#include <tuple>
#include <map>
#include <stack>
#include <set>
using namespace std;
#define MOD (long long int)(1e9+7)
#define ll long long int
#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define reps(i,n) for(int i=1; i<=(int)(n); i++)
#define REP(i,n) for(int i=n-1; i>=0; i--)
#define REPS(i,n) for(int i=n; i>0; i--)
#define INF (int)(1123456789)
#define LINF (long long int)(112345678901234567)
#define chmax(a, b) a = (((a)<(b)) ? (b) : (a))
#define chmin(a, b) a = (((a)>(b)) ? (b) : (a))
#define all(v) v.begin(), v.end()

const int N = (int)3e5;

ll mpow(ll a, ll b){
	if(b==0) return 1;
	else if(b%2==0){ll memo = mpow(a,b/2); return memo*memo%MOD;}
	else return mpow(a,b-1) * a % MOD;
}
ll gcd(ll a, ll b){
	if(b==0) return a;
	else return gcd(b, a%b);
}
vector<ll> kaijo_memo;
ll kaijo(ll n){
	if(kaijo_memo.size() > n) return kaijo_memo[n];
	if(kaijo_memo.size() == 0) kaijo_memo.push_back(1);
	while(kaijo_memo.size() <= n) kaijo_memo.push_back(kaijo_memo[kaijo_memo.size()-1] * kaijo_memo.size() % MOD);
	return kaijo_memo[n];
}
ll nCr(ll n, ll r){
	if(n < r || r < 0) return 0;
	ll ret = 1;
	ret *= kaijo(n); ret %= MOD;
	ret *= mpow(kaijo(r), MOD-2); ret %= MOD;
	ret *= mpow(kaijo(n-r), MOD-2); ret %= MOD;
	return ret;
}

int main(void){
	int n;cin>>n;
	vector<vector<ll>> X;
	rep(i,n){
		ll x,y;cin>>x>>y;
		X.push_back(vector<ll>());
		rep(a,101){
			rep(b,101){
		X[i].push_back(a*x+b*y);
		X[i].push_back(b*x-a*y);
			}
		}

	}
	vector<vector<pair<ll,ll>>> ans;
	rep(i,101*101*2*2){
		ans.push_back(vector<pair<ll,ll>>());
		rep(j,2){
			ans[i].push_back({0,0});
		}
	}

	rep(i,n){
		rep(a,101){
		rep(b,101){
			rep(hoge,2){
				int j = (a*101+b)*2+hoge;
			if(X[i][j] > 0){
				rep(k,2){
					ans[2*j][k].first += X[i][j/2*2];
					ans[2*j][k].second += X[i][j/2*2+1];				
				}

			}else if(X[i][j] < 0){
				rep(k,2){
					ans[2*j+1][k].first += X[i][j/2*2];
					ans[2*j+1][k].second += X[i][j/2*2+1];				
				}

			}else{
				int k;
				if(X[i][j/2*2 + (j+1)%2] > 0){
					k = 0;
				}else{
					k = 1;
				}
				rep(h, 2){
					ans[2*j+h][k].first += X[i][j/2*2];
					ans[2*j+h][k].second += X[i][j/2*2+1];
				}
			}
		}
		}
		//cerr<<i<<" "<<ans[5][1].first<<" "<<ans[5][1].second<<endl;
	}

	}
	ll answer = 0;
	rep(j,101*101*2*2){
		int a = j/(101*2*2);
		int b = j/(2*2)%101;
		rep(k,2){
			//cerr<<j<<" "<<k<<" "<<ans[j][k].first<<" "<<ans[j][k].second<<endl;
			ll sum = pow(ans[j][k].first,2) + pow(ans[j][k].second,2);
			sum /= (pow(a,2) + pow(b,2));
			chmax(answer, sum);
		}
	}
	cout<<setprecision(11)<<sqrt(answer)<<endl;
	return 0;
}


Measured memory_bytes: 19380
#include<bits/stdc++.h>
using namespace std;
using Graph=vector<vector<int>>;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
typedef long long ll;
template<class T> inline bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template<class T> inline bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}

ll MOD=1000000007;

int main(){
    ll N,K;cin>>N>>K;
    vector<ll>A(N);
    rep(i,N){
        cin>>A[i];
    }
    //整数列1回分の転倒数
    int count=0;
    rep(i,N-1){
        for(int j=i+1;j<N;j++){
            if(A[i]>A[j]){
                count++;
            }
        }
    }
    //整数列2回以上の場合に現れる転倒数
    int count2=0;
    for(int i=1;i<N;i++){
        for(int j=0;j<i;j++){
            if(A[i]>A[j]){
                count2++;
            }
        }
    }
    ll ans=0;
    ans=ans+(((K)*(K+1)/2)%MOD*count)%MOD;
    ans=ans+(((K)*(K-1)/2)%MOD*count2)%MOD;
    ans=ans%MOD;
    cout<<ans<<endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <limits.h>
#include <queue>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
#define REP(i, n) for(int i=0; i<n; i++)

int S[110];
int main(){
    int N;
    cin >> N;
    int sum = 0;
    bool all = true;
    REP(i,N){
        int s;
        cin >> s;
        S[i] = s;
        sum += s;
        if(s % 10 != 0) all = false;
    }
    sort(S, S+N);

    int ans;
    if(all) ans = 0;
    else if(sum % 10 != 0){
        ans = sum;
    }
    else{
        int m;
        int i = 0;
        while(1){
            if(S[i] % 10 != 0){
                m = S[i];
                break;
            }
            i++;
        }
        ans = sum - m;
    }
    cout << ans << endl;
    return 0;
}


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

using namespace std;
using ll=long long ;

template <typename T=int>
struct Fenwick {
    int n;
    vector<T> v;
    
    Fenwick(int size = 100005) : n(size), v(n+1, 0) {}
    inline void add(int p, T val) {
        for (; p <= n; p += (p&-p)) { v[p] += val; }
    }
    inline T query(int p) {
        T tmp = 0;
        for (; p > 0; p -= (p&-p)) { tmp += v[p]; }
        return tmp;
    }
    inline T query(int l, int r) {
        return query(r) - query(l-1);
    }
};

template <typename T=int>
struct Compress {
    map<T, int> id;
    vector<T> num;

    Compress(vector<T> v) {
        sort(v.begin(), v.end());
        v.erase(unique(v.begin(), v.end()), v.end());
        num = v;
        for (int i = 0; i < (int)num.size(); i++) {
            id[num[i]] = i;
        }
    }

    inline int get_id(T x) {
        assert(id.count(x));
        return id[x];
    }
    inline T get_num(int i) {
        assert(0 <= i && i < num.size());
        return num[i];
    }
};

void solve() {
    int n, K;
    cin >> n >> K;
    vector<int> a(n);
    for (auto& x: a) {
        cin >> x;
    }
    vector<ll> f(n+1);
    f[0] = 0;
    for (int i = 1; i <= n; i++) {
        f[i] = f[i-1] + a[i-1] - K;
    }
    Compress<ll> c(f);
    Fenwick<int> st(n+3);
    ll res = 0;
    for (int i = 0; i <= n; i++) {
        int j = c.get_id(f[i]) + 1;
        res += st.query(j);
        st.add(j, 1);
    }
    cout << res;
}

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    solve();
    cout << endl;
}


Measured memory_bytes: 18176
#include<bits/stdc++.h>
#define ll long long int 
#define pb push_back
#define mp make_pair
#define ff first
#define se second
using namespace std;
int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	ll n,i,sum=0;
	cin>>n;
	ll a[n];
	for(i=0;i<n;i++){
	    cin>>a[i];
	    sum+=a[i];
	}
	sort(a,a+n);
	sum=sum-a[n-1]/2;
	cout<<sum;
}

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

int main(void) {
    int N,K;cin>>N>>K;
    vector<int> L;
    for (int i = 0;i < N; i++) {
        int l;cin>>l;
        L.push_back(l);
    }
    sort(L.begin(), L.end());
    
    int result = 0;
    for (int i = N - 1; i >= N - K; i--) {
        result += L[i];

    }
    cout << result << endl;
    return 0;
}

Measured memory_bytes: 888
#include <iostream>

 

using namespace std;

 

int main()
{
    int a, b, c;
    cin >> a >> b >> c;
    if (a <= b && b <= c)
        cout << a << " " << b << " " << c << endl;
    else if (a <= c && c <= b)
        cout << a << " " << c << " " << b << endl;
    else if (b <= a && a <= c)
        cout << b << " " << a << " " << c << endl;
    else if (c <= a && a <= b)
        cout << c << " " << a << " " << b << endl;
    else if (c <= b && b <= a)
        cout << c << " " << b << " " << a << endl;
    else  
        cout << b << " " << c << " "<< a << endl;   
}


Measured memory_bytes: 3084
# frozen_string_literal: true

N = gets.chomp.to_i
L = gets.chomp.split.map(&:to_i)

count = 0

L.combination(3) do |i, j, k|
  next if i == j || j == k || i == k

  triangle = [i, j, k].sort
  longest = triangle.pop
  next if longest >= triangle.sum

  count += 1
end

puts count


Measured memory_bytes: 14332
#include <bits/stdc++.h>
#define rep(i, z, n) for(int64_t i = z; i < n; i++)
#define all(v) v.begin(), v.end()
typedef long long ll;
#define PI 3.14159265358979
//const int64_t INF = 1LL << 60;
//const int INF = 1 << 29;
//const int64_t MOD = 1000000007;
//const int64_t INF = 998244353;
using namespace std;
typedef pair<int64_t, int64_t> P;

int main(){
    int H, A;
    cin >> H >> A;
    cout << ceil((double)H / A) << endl;
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
#include<iostream>
#include<cstdlib>
using namespace std;
#define REP(i,b,n) for(int i=b;i<n;i++)
#define rep(i,n)   REP(i,0,n)
#define fir first
#define sec second

const int M = 21;
const int inf = 1500000*2;
const int N = 101;
int dp[N][M];
int cost[N][N];
void pre(int n,int *in){
  rep(i,n){
    cost[i][i]=in[i];
    REP(j,i+1,n)cost[i][j]=cost[i][j-1]+in[j];
  }
}

int solve(int n,int m){
  rep(i,n+1)rep(j,m+1)dp[i][j]=inf;
  //dp[0][0]=0;
  REP(i,1,n+1){
    REP(j,1,m+1){
      rep(k,i){
	if (k==0)dp[i][j]=min(dp[i][j],cost[k][i-1]              );
	else     dp[i][j]=min(dp[i][j],max(dp[k][j-1],cost[k][i-1]));
      }
    }
  }
  return dp[n][m];
}

main(){
  int n,m;
  int in[N];
  while(cin>>m>>n && n){
    rep(i,n)cin>>in[i];
    pre(n,in);
    cout << solve(n,m) << endl;
  }
}

Measured memory_bytes: 0
#include<bits/stdc++.h>
typedef long long ll;

using namespace std;

#define REP(i,a,b) for (int i = a; i <= b; i++)
#define ALL(a)              a.begin(), a.end()
#define ALLN(a, n)          (a, a+n)
#define MAX                 10000007
#define MIN                 -10000007



              
int main()
{
  ios::sync_with_stdio(0);
    cin.tie(0);
  #ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
    freopen("error.txt", "w", stderr);
    #endif
      
    int t;
    t=1;
     //  cin>>t;
    while(t--){
          	ll a;
          	cin>>a;
          	cout<<a+a*a+a*a*a;
       


             }
             cerr<<"Time taken : "<<(float)clock()/CLOCKS_PER_SEC<<" secs"<<endl;
    return 0;
}


Measured memory_bytes: 3800
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<cmath>

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

using namespace std;
int main() {
	int a;
	cin >> a;

	cout << a / 3 << endl;

	return 0;
}

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

int main() {
	vector<int>a(6);
	for (int b = 0; b < 6; b++) {
		int c;
		cin >> c;
		a[b] = c;
	}
	int s;
	cin >> s;
	for (int k = 0; k < s; k++) {
		int l,r;
		cin >> l >> r;
		for (int d = 0; d < 4; d++) {
			vector<int>f(6);
			for (int g = 0; g < 6; g++) {
				f[g] = a[g];
			}
			a[0] = f[1]; a[1] = f[5]; a[4] = f[0]; a[5] = f[4];
			for (int e = 0; e < 4; e++) {
				if (a[0] == l&&a[1] == r) { cout << a[2] << endl; goto h; }
				if (a[1] == l&&a[0] == r) { cout << a[3] << endl; goto h; }
				vector<int>f(6);
				for (int g = 0; g < 6; g++) {
					f[g] = a[g];
				}
				a[0] = f[3]; a[2] = f[0]; a[3] = f[5]; a[5] = f[2];
			}
		}
	h:;
	}
}

Measured memory_bytes: 3104
// #include "pch.h"
#include <iostream>
#include <algorithm>
#include <map>
#include <set>
#include <queue>
#include <bitset>
#include <climits>
#include <string>
#include <cmath>
#include <bitset>
#include <complex>
#include <functional>
#include <ctime>
#include <cassert>
#include <fstream>
#include<unordered_map>
#include <stack>
#include <random>

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

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

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

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

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

using namespace std;

const ll MOD = 10e8 + 7;

ll modpow(ll a, ll b){
    ll ret = 1;
    while(b){
        if(b&1) ret = ret * a % MOD;
        a = a * a % MOD;
        b >>= 1LL;
    }
    return ret;
}

int eular_phi(int x){
    int lim = sqrt(x) + 1;
    int ret = x;
    rip(i, lim, 2){
        if(x%i == 0){
            ret/= i;
            ret *= i-1;
            while(x%i == 0) x /= i;
        }
    }
    if(x > 1){
        ret /= x;
        ret *= x-1;
    }
    return ret;
}

int main(){
    ll n,k; cin >> n >> k;
    ll ans = 0;
    rip(i,k+1,1){
        ans +=modpow(k/i, n) * eular_phi(i) % MOD;
        // cout << modpow(k/i, n) << endl;
    }
    cout << ans % MOD << endl;
}

Measured memory_bytes: 3584
#include <bits/stdc++.h>
using namespace std;
#define int long double
vector<vector<int>>dp(3001,vector<int>(3001,-1));
vector<int>A(3001);
int n;
int solve(int i,int left)
{
    if (i==n)return 1;
    if (dp[i][left]!=-1)return dp[i][left];
    if (left==n-i)return dp[i][left] = A[i]*solve(i+1,left-1);
    if (left==0)return 1;
    return dp[i][left] = A[i]*solve(i+1,left-1) + (1-A[i])*solve(i+1,left);
}
int32_t main()
{
    cin>>n;
    for (int i = 0;i<n;i++)cin>>A[i];
    cout<<setprecision(10)<<solve(0,ceil((double)n/(double)2))<<endl;
    return 0;
}

Measured memory_bytes: 145012
#include <bits/stdc++.h>
using namespace std;
 
typedef long long LL;
typedef pair<int,int> pii;
typedef pair<LL,LL> pll;
typedef pair<string,string> pss;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<pii> vii;
typedef vector<LL> vl;
typedef vector<vl> vvl;
 
double EPS = 1e-9;
int INF = 1000000005;
long long INFF = 1000000000000000005LL;
double PI = acos(-1);
int dirx[8] = {-1,0,0,1,-1,-1,1,1};
int diry[8] = {0,1,-1,0,-1,1,-1,1};
 
#ifdef TESTING
  #define DEBUG fprintf(stderr,"====TESTING====\n")
  #define VALUE(x) cerr << "The value of " << #x << " is " << x << endl
  #define debug(...) fprintf(stderr, __VA_ARGS__)
#else
  #define DEBUG 
  #define VALUE(x)
  #define debug(...)
#endif
 
#define FOR(a,b,c) for (int (a)=(b);(a)<(c);++(a))
#define FORN(a,b,c) for (int (a)=(b);(a)<=(c);++(a))
#define FORD(a,b,c) for (int (a)=(b);(a)>=(c);--(a))
#define FORSQ(a,b,c) for (int (a)=(b);(a)*(a)<=(c);++(a))
#define FORC(a,b,c) for (char (a)=(b);(a)<=(c);++(a))
#define FOREACH(a,b) for (auto &(a) : (b))
#define REP(i,n) FOR(i,0,n)
#define REPN(i,n) FORN(i,1,n)
#define MAX(a,b) a = max(a,b)
#define MIN(a,b) a = min(a,b)
#define SQR(x) ((LL)(x) * (x))
#define RESET(a,b) memset(a,b,sizeof(a))
#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define ALL(v) v.begin(),v.end()
#define ALLA(arr,sz) arr,arr+sz
#define SIZE(v) (int)v.size()
#define SORT(v) sort(ALL(v))
#define REVERSE(v) reverse(ALL(v))
#define SORTA(arr,sz) sort(ALLA(arr,sz))
#define REVERSEA(arr,sz) reverse(ALLA(arr,sz))
#define PERMUTE next_permutation
#define TC(t) while(t--)
 
inline string IntToString(LL a){
  char x[100];
  sprintf(x,"%lld",a); string s = x;
  return s;
}
 
inline LL StringToInt(string a){
  char x[100]; LL res;
  strcpy(x,a.c_str()); sscanf(x,"%lld",&res);
  return res;
}
 
inline string GetString(void){
  char x[1000005];
  scanf("%s",x); string s = x;
  return s;
}
 
inline string uppercase(string s){
  int n = SIZE(s); 
  REP(i,n) if (s[i] >= 'a' && s[i] <= 'z') s[i] = s[i] - 'a' + 'A';
  return s;
}
 
inline string lowercase(string s){
  int n = SIZE(s); 
  REP(i,n) if (s[i] >= 'A' && s[i] <= 'Z') s[i] = s[i] - 'A' + 'a';
  return s;
}
 
inline void OPEN (string s) {
  #ifndef TESTING
  freopen ((s + ".in").c_str (), "r", stdin);
  freopen ((s + ".out").c_str (), "w", stdout);
  #endif
}


int N;
int A[100000];
int ans = 0;
int mini;

void solve() {
  for (int i = 0; i < N; i++) {
    mini = i;
    for (int j = i; j < N; j++) {
      if (A[j] < A[mini]) {
        mini = j;
      }
    }
    if (A[i] > A[mini]) {
      swap(A[i], A[mini]);
      ans++; 
    }
       
  }
}

void show() {
  for (int i = 0; i < N; i++){
    if (i != 0) {
      cout << " ";
    }
    cout << A[i];
  }
  cout << endl;
  cout << ans << endl;
}

int main() {
  cin >> N ;
  REP(i, N) {
    cin >> A[i];
  }

  solve();

  show();

  return 0;
}

Measured memory_bytes: 3092
#include<stdio.h>
#include<string.h>

int main()
{
	char s[10];
	scanf("%s", s);
	for(int i = 0; i < strlen(s); i++)
		if(s[i] == 'A' && s[i + 1] == 'C')
			{
				printf("Yes");
				return 0;
			} 
	printf("No");
			
	return 0;
}

Measured memory_bytes: 128
#pragma GCC optimize ("O3")

#include <bits/stdc++.h>
#define FOR(i, m, n) for (int i = (m); i < (n); ++i)
#define REP(i, n) FOR(i, 0, n)
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define bcnt __builtin_popcountll
#define dump(x)  cerr << #x << " = " << (x) << endl
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl

using namespace std;

typedef long long ll;
typedef pair<ll,ll> Pll;
typedef pair<int,int> Pin;

ll INF = 1e16;
int inf = 1e9;
ll MOD = 1e9+7;

template<typename T>
ostream& operator << (ostream& os, const vector<T>& vec) {
    os << "[ ";
    REP(i, vec.size()) {
        os << vec[i] << " ";
    }
    os << "]";

    return os;
}

ll pow_mod(ll a, ll p) {
    ll res = 1;
    while(p) {
        if (p & 1) res = (res * a) % MOD;
        a = (a * a) % MOD;
        p >>= 1;
    }

    return res;
}


ll mod_inv(ll a, ll m) {
    ll b = m, u = 0, v = 1;
    while(a) {
        ll t = b / a;
        swap(b -= t * a, a);
        swap(u -= t * v, v);
    }

    return (u % m + m) % m;
}

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

struct C {
        int x;
        int y;
        C(int _x, int _y) : x(_x), y(_y) {}
};


int s[50][50];
bool m[50][50];
int H, W;

void dfs(int i, int j, int c) {
    if (c >= s[i][j]) return;
    s[i][j] = c;

    int l = max(j-1, 0);
    int r = min(j+1, W-1);
    int t = max(i-1, 0);
    int b = min(i+1, H-1);

    if (m[i][r]) dfs(i, r, c+1);
    if (m[b][j]) dfs(b, j, c+1);
    if (m[i][l]) dfs(i, l, c+1);
    if (m[t][j]) dfs(t, j, c+1);
}



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

    cin >> H >> W;

    int w = 0;
    REP(i, H) {
        REP(j, W) {
            char f;
            cin >> f;
            if (f == '.') {
                m[i][j] = true;
                ++w;
            }
            else m[i][j] = false;
        }
    }

    REP(i, H) REP(j, W) s[i][j] = inf;
    dfs(0, 0, 1);

    cout << fixed << setprecision(20);
    if (s[H-1][W-1] == inf) cout << -1 << endl;
    else cout << w - s[H-1][W-1] << endl;

}


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

int main(){
    int N;
    cin >> N;
    vector<pair<int,int>> A(N);
    for(int i=0;i<N;++i){
        cin >> A[i].first;
        A[i].second = i;
    }
    sort(A.begin(),A.end());
    for(int i=0;i<N;++i){
        cout << A[i].second+1 << endl;
    }
}


Measured memory_bytes: 1664
N=int(input())
L = list(map(int,input().split()))

ans=0

for i in range(N):
    for j in range(N):
        for k in range(N):
            if L[i]!=L[j] and L[k]!=L[j] and L[i]!=L[k] :
                if (L[i]+L[j]>L[k]) and (L[k]>abs(L[i] - L[j])):
                    ans += 1
print(ans//6)

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

int main(){
	int a,b;
	cin>>a>>b;
	//cout<< a<<endl;
	int q[b],sum=0;
	for(int i =0;i<b;i++){
	cin>>q[i];
	sum+=q[i];
	}
	if(sum>a)cout<<"-1"<<endl;
	else cout<<a-sum<<endl;
	
		
}

Measured memory_bytes: 3712
from decimal import Decimal
n = int(input())
v = list(map(int,input().split()))
sumv = sum(v)
for i in range(n-1):
    v.sort()
    sumv -= Decimal((v[0]+v[1])/2)
    v[1] = Decimal((v[0]+v[1])/2)
    v[0] = 1000000
print(sumv)

Measured memory_bytes: 5332
#include <iostream>
#include <string.h>
#include <stdio.h>
#include <map>
#include <vector>
#include <math.h>
#include <algorithm>
#include <queue>
using namespace std;

#define rep(i,a) for(int i=0; i<a; i++)
#define rrep(i,a) for(int i=a; i>=0; i--)
#define loop3(i,j,k,a) for(int i=0; i<a; i++)for(int j=0; j<a; j++)if(i!=j)for(int k=0; k<a; k++)if(i!=k&&j!=k)
#define loop4(i,j,k,l,a) for(int i=0; i<a; i++)for(int j=0; j<a; j++)if(i!=j)for(int k=0; k<a; k++)if(i!=k&&j!=k)for(int l=0; l<a; l++)if(i!=l&&j!=l&&k!=l)
#define rep1(i,a) for(int i=1; i<=a; i++)

#define scnd1(a) scanf("%d", &a)
#define scnd2(a,b) scanf("%d%d", &a,&b)
#define scnd3(a,b,c) scanf("%d%d%d", &a,&b,&c)
#define scnd4(a,b,c,d) scanf("%d%d%d%d", &a,&b,&c,&d)

#define cin1(a) cin >> a;
#define cin2(a,b) cin >> a >> b;
#define cin3(a,b,c) cin >> a >> b >> c;
#define cin4(a,b,c,d) cin >> a >> b >> c >> d;
#define cout1(a) cout << a << endl;
#define cout2(a,b) cout << a << " " << b << endl;
#define cout3(a,b,c) cout << a << " " << b << " " << c << endl;
#define cout4(a,b,c,d) cout << a << " " << b << " " << c << " " << d << endl;
#define prtd1(a) printf("%d\n", a)
#define prtd2(a,b) printf("%d %d\n", a,b)
#define prtd3(a,b,c) printf("%d %d %d\n", a,b,c)
#define prtd4(a,b,c,d) printf("%d %d %d %d\n", a,b,c,d)

#define mem(a,n) memset( a, n, sizeof(a))
#define INF 1000000000
typedef long long ll;

priority_queue<int> A, B;

int main() {
    int N, H;
    cin >> N >> H;
    
    int a, b;
    rep(i,N) {
        cin >> a >> b;
        A.push(a);
        B.push(b);
    }
    
    B.push(0);
    int cnt = 0;
    while( A.top() < B.top() ) {
        H -= B.top(); B.pop(); cnt++;
        if(H<=0) break;
    }
    cnt += max( 0, (int)ceil(1.0*H/A.top()));
    cout << cnt << endl;
}


Measured memory_bytes: 1276
n, m = map(int, input().split())
a = [input() for _ in range(n)]
b = [input() for _ in range(m)]

from itertools import product
for i,j in product(range(n-m+1), repeat=2):
    t = []
    for k in range(m):
        t.append(a[i+k][j:j+m])

    if t == b:
        print("Yes")
        break

else:
    print("No")

Measured memory_bytes: 39792
#include <bits/stdc++.h>
using namespace std;
string s, t;
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0), cout.tie(0);
    cin >> s >> t;
    int wynik = 0, mini = 1000*1000+10;
    for(int i = 0; i < s.size() - t.size() + 1; i++)
    {
        wynik = 0;
        for(int j = i; j < i + t.size(); j++)
            wynik += (s[j] != t[j - i]);
        mini = min(mini, wynik);
    }
    cout << mini << "\n";
}


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

int main() {
    int N, M, X, c_m;
    cin >> N >> M >> X;
    int C[N], A[N][M];
    bitset<12> b;
    for (int i = 0; i < N; i++) {
        cin >> C[i];
        for (int j = 0; j < M; j++) {
            cin >> A[i][j];
        }
    }

    int start = 10000000;
    int best = start;
    bool good;
    for (int i = 0; i < 1 << N; i++) {
        good = true;
        c_m = 0;
        int c_x[M] = {0};
        b = i;
        for (int j = 0; j < N; j++) {
            if (b.test(j)) {
                c_m += C[j];
                for (int k = 0; k < M; k++) {
                    c_x[k] += A[j][k];
                }
            }
        }
        for (int j = 0; j < M; j++) {
            if (c_x[j] < X) {
                good = false;
                break;
            }
        }
        if (good == true) {
            best = min(best, c_m);
        }
    }
    if (best < start) {
        cout << best << endl;
    } else {
        cout << -1 << endl;
    }
    return 0;
}


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

using namespace std;
using LL = long long;

constexpr int N = 1e5 + 5;

int main() {
    ios::sync_with_stdio(false); cin.tie(nullptr);
    
    int n, m, k;
    cin >> n >> m >> k;

    vector< string> in(n);
    for (int i = 0; i < n; i++) cin >> in[i];

    int res = 0;
    for (int i = 0; i < (1 << n); i++) {
        for (int j = 0; j < (1 << m); j++) {

            int cnt = 0;
            for (int x = 0; x < n; x++) {
                for (int y = 0; y < m; y++) {
                    if ((i >> x & 1) && (j >> y & 1)) {
                        if (in[x][y] == '#') cnt++;
                    }
                }
            }

            res += cnt == k;
        }
    }

    cout << res << endl;
}

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

int main(){
  vector<string> q(3);
  for (int i = 0; i < 3; i++){
    cin >> q.at(i);
    transform(q.at(i).begin(), q.at(i).end(), q.at(i).begin(),::toupper);
  }
  cout << q.at(0).at(0) << q.at(1).at(0) << q.at(2).at(0) << endl;
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long
#define f first
#define s second
#define pb push_back
#define mp make_pair
using namespace std;
ll n,a,b,c,d,ans;
int main(){
    cin >> a >> b >> c >> n;
    
    for(int i=0; i<=n; i++){
        for(int j=0; j<=n; j++){
            if(n - i * a - j * b >= 0 && (n - i * a - j * b)%c == 0)ans++;
        }
    }
    cout << ans;
    
    
    
    
    return 0;
}


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

int main(){

    int N,K,Q;
    cin >> N >> K >> Q;

    vector<int> ans(N,K-Q);

    for (size_t i = 0; i < Q; i++)
    {
        int a;
        cin >> a;
        ans[a-1]++;
        
    }

    for (size_t i = 0; i < N; i++)
    {
        if(ans[i]>0)cout << "Yes" <<endl;
        else cout << "No" <<endl;
    }

    return 0;
}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
using Int = long long;
template<typename T1,typename T2> inline void chmin(T1 &a,T2 b){if(a>b) a=b;}
template<typename T1,typename T2> inline void chmax(T1 &a,T2 b){if(a<b) a=b;}

//INSERT ABOVE HERE
signed main(){
  int n;
  cin>>n;
  int ans=1;
  while(ans<=n) ans<<=1;
  cout<<ans/2<<endl;
  return 0;
}



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

int main(){
	long int A, B, C;
	cin >> A >> B >> C;
	long int count = 0;
	long int first = min(B, C);
	count = 2 * first;
	C -= first;
	B -= first;
	long int second = min(A,C);
	count += second;
	C -= second;
	if(C > 0) count++;
	if(B > 0) count += B;
	cout << count << endl;
}

Measured memory_bytes: 256
#include <algorithm>
#include <bits/stdc++.h>
#include<iostream>
#include<string>
using namespace std;
#define rep(i, n) for (int i = 0; i <(int)(n); i++)
#define all(x) (x).begin(), (x).end()
#define ll long long
const int INF=1000100010;
int main(){
  int n,m;cin>>n>>m;
  int h[n];
  int ans=0;
  set<int> trash;
  rep(i,n)cin>>h[i];
  rep(i,m){
    int a,b;
    cin>>a>>b;
    a--;b--;
    if(h[a]>=h[b])trash.insert(b);
    if(h[a]<=h[b])trash.insert(a);
  }
 ans=n-trash.size();
 cout<<ans<<endl;
 return 0;
}

Measured memory_bytes: 6648
program main;
var
    n, i : integer;
    s : string;
    a : array[1..4] of integer;
begin
    readln(n);

    for i := 1 to 4 do
        a[i] := 0;

    for i := 1 to n do begin
        readln(s);
        if (s = 'AC') then
            a[1] := a[1] + 1
        else if (s = 'WA') then
            a[2] := a[2] + 1
        else if (s = 'TLE') then
            a[3] := a[3] + 1
        else if (s = 'RE') then
            a[4] := a[4] + 1;
    end;

    writeln('AC x ', a[1]);
    writeln('WA x ', a[2]);
    writeln('TLE x ', a[3]);
    writeln('RE x ', a[4]);
end.

Measured memory_bytes: 1372
alph = ['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z']

n = int(input())

str = ''
count = 0
while True:
  n -= 26 ** count
  if n < 26 ** (count + 1):
    while count != 0:
      mod = 26 ** count
      num_1 = n // mod
      n %= mod
      str = str + alph[num_1]
      count -= 1
    break
  count += 1
str = str + alph[n]
print(str)

Measured memory_bytes: 9148
from collections import deque

def bfs(sy,sx):
  q = deque([[sy,sx]])
  d[sy][sx] = 0
  while q:
    y,x = q.popleft()
    for i,j in [(-1,0),(1,0),(0,-1),(0,1)]:
      dy,dx = y+i,x+j
      if dy < 0 or h <= dy: continue
      elif dx < 0 or w <= dx: continue
      elif s[dy][dx] == "#": continue
      elif d[dy][dx] != -1: continue
      d[dy][dx] = d[y][x]+1
      q.append([dy,dx])

h,w = map(int, input().split())
s = [input() for _ in range(h)]

if s[0][0] == "#" or s[h-1][w-1] == "#":
  print(-1)
  exit()

d = [[-1]*w for _ in range(h)]
bfs(0,0)
if d[h-1][w-1] == -1: print(-1)
else:
  t = 0
  for i in range(h): t += s[i].count("#")
  print(h*w-t-(d[h-1][w-1]+1))

Measured memory_bytes: 9416
#define _USE_MATH_DEFINES
#include <cassert>
#include <cstdio>
#include <cstring>
#include <iostream>
#include <string>
#include <sstream>
#include <vector>
#include <queue>
#include <stack>
#include <list>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <algorithm>
#include <complex>
#include <cmath>
#include <numeric>
#include <bitset>

using namespace std;

#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
  cerr << name << ": " << arg1 << endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
  const char* comma = strchr(names + 1, ',');
  cerr.write(names, comma - names) << ": " << arg1 << " |";
  __f(comma + 1, args...);
}

typedef long long int64;
typedef pair<int, int> ii;
const int INF = 1 << 30;
const int MOD = 1e9 + 7;

const int C = 500 * 500;
const int N = 600;
int a[N][N];
int main() {
  int H, W, h, w;
  scanf("%d%d%d%d", &H, &W, &h, &w);
  if (H % h == 0 && W % w == 0) {
    puts("No");
    return 0;
  }
  puts("Yes");
  a[0][0] = C;
  a[h - 1][w - 1] = -C - 1;
  for (int i = 0; i < H; ++i) {
    for (int j = 0; j < W; ++j) {
      printf("%d%c", a[i % h][j % w], " \n"[j + 1 == W]);
    }
  }

  return 0;
}


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

int main(){
    string s;

    cin >> s;

    while(true){
        for(int i=0; i<s.size()-1; ++i){
            if(s[i] != s[i+1]){
                break;
            }
            if(i == s.size()-2){
                cout << s << endl;
                return 0;
            }
        }

        int a = atoi(s.c_str());
        s = to_string(++a);
    }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long int lli;
const lli MAX = 1e5+9;
vector < lli> G[MAX];
vector <lli> in_degree(MAX);
vector <bool> visited(MAX);
vector <lli> dist(MAX);
void dfs(int a){

    visited[a] = true;
//    cout << a << "we ";
    for(int i =0;i<G[a].size();i++){
            dist[G[a][i]] = max(dist[G[a][i]],dist[a]+1);
            in_degree[G[a][i]]--;
        if(in_degree[G[a][i]] == 0){

            dfs(G[a][i]);
        }


  //  cout << endl;
  }
}
int main(){
    
    lli n,m;
    cin >> n >> m;
    while(m--){
        lli x, y;
        cin >> x >> y;
        G[x].push_back(y);
        in_degree[y]++;
    }

    //cout << endl;
    for(int i =1;i<=n;i++){

        if(!visited[i] &&in_degree[i]==0)dfs(i);
      //  for(int i =1;i<=n;i++)cout << in_degree[i] <<  " ";
        //cout << endl;
    }
    lli ans = 0;
    //cout << endl;
    for(int i =1;i<=n;i++){

            ans = max(ans,dist[i]);}
    //cout << endl;
    cout << ans << endl;
}


Measured memory_bytes: 12032
#include<map>
#include<set>
#include<cmath>
#include<queue>
#include<cstdio>
#include<string>
#include<vector>
#include<cstring>
#include<fstream>
#include<iomanip>
#include<iostream>
#include<algorithm>
// #include<bits/stdc++.h>
#define INF 0x7f7f7f7f //2139062143
#define INF1 0x3f3f3f3f //1061109567
#define INF2 2147483647
#define llINF 9223372036854775807
#define pi 3.141592653589793//23846264338327950254
#define ft first
#define sd second
#define pb push_back
#define ll long long
#define vec vector<ll>
#define mat vector<vector<ll>>
//cout<<fixed<<setprecision(6)<<
//freopen(".in","r",stdin);
//freopen(".out","w",stdout);
//ifstream f1("/Users/wangzichao/Documents/wzc.in");
//ofstream f2("/Users/wangzichao/Documents/wzc.out");
//ios::sync_with_stdio(false);
//cin.tie(0);cout.tie(0);
using namespace std;
#define local
#ifdef local
#endif
const ll maxn=6e5+7;
const double eps=1e-10;
const ll mod=1e9+7;
#define STDIN freopen("in.txt","r",stdin); freopen("out.txt","w",stdout);//************************************
#define Quick ios::sync_with_stdio(false);cin.tie(NULL);

int main()
{
   // STDIN
    Quick
    string s;
    cin >> s;
    string ans = "No";
    for (int i = 0; i < 3; i++)
    {
        if (s[i] == '7')
            {
                ans = "Yes";break;
            }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3644
#include <stdio.h>
#include <algorithm>

using namespace std;

const int MAX_N = 1e5 + 100;

int N, Nr[MAX_N], C, K;
int main() {
	scanf("%d%d%d", &N, &C, &K);
	for(int i=0; i<N; i++) scanf("%d", &Nr[i]);
	sort(Nr, Nr+N);
	int ix = 0, ans = 0;
	while(ix < N) {
		ans++;
		int left = Nr[ix];
		int jx = ix;
		while(jx < ix+C && jx < N && Nr[jx] - left <= K) jx++;
		ix = jx;
	}
	printf("%d\n", ans);
	return 0;
}

Measured memory_bytes: 512
# -*- coding: utf-8 -*-
import re
import sys

N,M = list(map(int, input().rstrip().split()))
A_list = [input().strip() for _ in range(N)]
B_list = [input().strip() for _ in range(M)]
#-----

candidate=[]   # [[ x,[y] ]] start position of row(int x) and column(list [int y]) 
for ia in range(N):
    find_string = [m.start() for m in re.finditer( B_list[0] , A_list[ia])]
    
    if find_string != [] and N-ia >= M:
        candidate.append( [ia,find_string] )

if candidate == []:
    print("No")
    sys.exit()

for start_r,start_c_list in candidate:
    for start_c in start_c_list:
    
        for ib in range(M):
            if B_list[ib] ==  A_list[start_r + ib][start_c:(start_c + M)]:
                if ib == (M-1):
                    print("Yes")
                    sys.exit()
                else:
                    continue
            else:
                break

else:
    print("No")


Measured memory_bytes: 3188
n, m = map(int, input().split())
l = list(map(int, input().split()))

import fractions
from functools import reduce

def lcm_base(x, y):
  return (x * y) // fractions.gcd(x, y)

def lcm_list(numbers):
  return reduce(lcm_base, numbers, 1)

#print(lcm_list(l))

x = lcm_list(l)

for i in range(n):
  if (x//l[i])%2 == 0:
    print(0)
    exit()

ans = (m*2)//lcm_list(l)
if ans%2 == 1:
  print((ans+1)//2)
else:
  print(ans//2)

Measured memory_bytes: 14356
package main

import (
	"bufio"
	"fmt"
	"math"
	"os"
	"sort"
	"strconv"
	"strings"
	"unsafe"
)

var (
	sc scanner
)

func main() {
	k := sc.nextInt()
	a := []int{1, 2, 3, 4, 5, 6, 7, 8, 9}
	idx := 0
	for len(a) <= k {
		now := a[idx]
		if (now)%10 != 0 {
			a = append(a, 10*now+now%10-1)
		}
		a = append(a, 10*now+now%10)
		if now%10 != 9 {
			a = append(a, 10*now+now%10+1)
		}
		idx++
	}
	fmt.Println(a[k-1])
}

func check(x int) bool {
	if x == 0 {
		return false
	}

	if x/10 == 0 {
		return true
	}

	s := strconv.Itoa(x)
	for i := 0; i < len(s)-1; i++ {
		if abs(int(s[i])-int(s[i+1])) > 1 {
			return false
		}
	}
	return true
}

/* template functions */

func init() {
	sc = scanner{
		buf: make([]string, 0, 10000),
		cur: 0,
		r:   bufio.NewReader(os.Stdin),
	}
}

type scanner struct {
	buf []string
	cur int
	r   *bufio.Reader
}

func (s *scanner) readln() {
	rbuf := make([]byte, 0, 100)
	for {
		line, prefix, err := s.r.ReadLine()
		if err != nil {
			panic(err)
		}
		rbuf = append(rbuf, line...)
		if prefix == false {
			break
		}
	}
	s.cur = 0
	s.buf = strings.Split(*(*string)(unsafe.Pointer(&rbuf)), " ")
}

func (s *scanner) isFull() bool {
	if s.cur == len(s.buf) {
		return true
	}
	return false
}

func (s *scanner) resetCur() {
	s.cur = 0
}

func (s *scanner) next() string {
	if s.cur == 0 {
		s.readln()
	}
	res := s.buf[s.cur]
	s.cur++
	if s.isFull() {
		s.resetCur()
	}
	return res
}

func (s *scanner) nexts() []string {
	s.readln()
	s.resetCur()
	return s.buf
}

func (s *scanner) nextByte() byte {
	if s.cur == 0 {
		s.readln()
	}
	res := s.buf[s.cur][0]
	s.cur++
	if s.isFull() {
		s.resetCur()
	}
	return res
}

func (s *scanner) nextInt() int {
	if s.cur == 0 {
		s.readln()
	}
	res, _ := strconv.Atoi(s.buf[s.cur])
	s.cur++
	if s.isFull() {
		s.resetCur()
	}
	return res
}

func (s *scanner) nextInts() []int {
	s.readln()
	res := make([]int, len(s.buf))
	for i, _ := range s.buf {
		res[i], _ = strconv.Atoi(s.buf[i])
	}
	s.resetCur()
	return res
}

func (s *scanner) nextFloat() float64 {
	if s.cur == 0 {
		s.readln()
	}
	res, _ := strconv.ParseFloat(s.buf[s.cur], 64)
	s.cur++
	if s.isFull() {
		s.resetCur()
	}
	return res
}

func (s *scanner) nextFloats() []float64 {
	s.readln()
	res := make([]float64, len(s.buf))
	for i, _ := range s.buf {
		res[i], _ = strconv.ParseFloat(s.buf[i], 64)
	}
	s.resetCur()
	return res
}

func max(x, y int) int {
	return int(math.Max(float64(x), float64(y)))
}

func min(x, y int) int {
	return int(math.Min(float64(x), float64(y)))
}

func abs(x int) int {
	return int(math.Abs(float64(x)))
}

// Searchable
// idx := lower_bound([]int{-199, -1, 0, 2, 4, 67, 100, 8435}, 60)
// => idx = 5
//
// No present
// idx := lower_bound([]int{-199, -1, 0, 2, 4, 67, 100, 8435}, 10000)
// => idx = 8

func lower_bound(a []int, x int) int {
	return sort.SearchInts(a, x)
}

func dump(value ...interface{}) {
	for _, v := range value {
		fmt.Fprintf(os.Stderr, "%#v\n", v)
	}
}

func yes() {
	fmt.Println("Yes")
}

func no() {
	fmt.Println("No")
}


Measured memory_bytes: 4480
#include <bits/stdc++.h>
#define rep(i,n) for(ll i=0;i<(n);++i)
#define all(a) (a).begin(),(a).end()
using namespace std;
using Graph = vector<vector<int>>;
typedef pair<int,int> P;
typedef long long ll;

int main(){
    ll a , v, b, w, t; cin >> a >> v >> b >> w >> t;
    ll d = abs(a-b);

    if(d <= (v-w)*t){
        cout << "YES" << endl;
    }
    else{
        cout << "NO" << endl;
    }

}

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

int main()
{
  int input1,que1,rem1,que2,ans=0;
  cin>>input1;
  que1=input1/500;
  rem1=input1%500;
  que2=rem1/5;
  ans=(que1*1000)+(que2*5);
  cout<<ans<<endl;  
 return 0; 
}

Measured memory_bytes: 256
'use strict'

function main(input) {
  const nums = input.split(' ').map(n => parseInt(n, 10))
  
  const N = nums[0]
  const A = nums[1]
  const B = nums[2]
  
  
  let sum = 0

  for (let i = 1; i <= N; i ++) {
    let n = String(i).split('').map(n => parseInt(n, 10)).reduce((acc, arg) => {
      return acc + arg
    }, 0)

    if (n >= A && n <= B) {
      sum += i
    }
  }
  
  console.log(sum)
  
}

main(require('fs').readFileSync('/dev/stdin', 'utf8'))


Measured memory_bytes: 11228
N = input()

tmp = len(N)

if tmp == 1:
    print(int(N))
else:
    ans = 0
    for i in range(tmp):
        if i&1 == 1:
            ans += 10**(i) - 10**(i-1)
        elif i == tmp-1:
            ans += int(N) - int("9"*i)

    # if N[0] == "1" and N[1:]
    print(ans)


Measured memory_bytes: 2940
from collections import deque

def dfs(edge, s):
    used = {s}
    que = deque([s])
    while que:
        v = que.pop()
        for u in edge[v]:
            if u in used:
                continue
            used.add(u)
            que.append(u)
    return used

def bellmanFord(edges):
    coins = [float('inf')] * N
    coins[0] = 0
    for _ in range(N):
        f = True
        for u, v, c in edges:
            if coins[u] + c < coins[v]:
                coins[v] = coins[u] + c
                f = False
        if f:
            return max(0, -coins[-1])
    return -1

N, M, P = map(int, input().split())
A = [[] for _ in range(N)]
A_rev = [[] for _ in range(N)]
E = [tuple()] * M
for i in range(M):
    a, b, c = map(int, input().split())
    a -= 1
    b -= 1
    c = P - c
    A[a].append(b)
    A_rev[b].append(a)
    E[i] = (a, b, c)
U = dfs(A, 0) & dfs(A_rev, N-1)
F = [(a, b, c) for (a, b, c) in E if a in U and b in U]
print(bellmanFord(F))

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

template<class T1, class T2> ostream& operator << (ostream &s, pair<T1,T2> P)
{ return s << '<' << P.first << ", " << P.second << '>'; }

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

// res[i][c] := i 文字目以降で最初に文字 c が登場する index (存在しないときは n)
vector<vector<int> > calcNext(const string &S) {
    int n = (int)S.size();
    vector<vector<int> > res(n+1, vector<int>(26, n));
    for (int i = n-1; i >= 0; --i) {
        for (int j = 0; j < 26; ++j) res[i][j] = res[i+1][j];
        res[i][S[i]-'a'] = i;
    }
    return res;
}

int main() {
    string S; cin >> S;
    int n = (int)S.size();
    
    // 前処理配列
    auto next = calcNext(S);

    // DP
    vector<int> dp(n+1, 1<<29); // DP テーブル
    vector<pair<char, int> > recon(n+1, {'?', n}); // 復元用テーブル
    dp[n] = 1;
    for (int i = n - 1; i >= 0; --i) {
        for (int j = 0; j < 26; ++j) {
            if (next[i][j] == n) {
                if (dp[i] > 1)
                    dp[i] = 1, recon[i] = {'a'+j, n};
            }
            else if (chmin(dp[i], dp[next[i][j] + 1] + 1))
                recon[i] = {'a'+j, next[i][j] + 1};
        }
        //cout << i << ": " << S[i] << "; " << dp[i] << ", " << recon[i] << endl;
    }
    
    // 復元
    string res = "";
    int index = 0;
    while (index < n) {
        auto p = recon[index];
        res += p.first;
        index = p.second;
    }
    cout << res << endl;
}

Measured memory_bytes: 29444
#include<stdio.h>

#define MAX 10000
#define NIL -1

struct Node {
  int p,l,r;
};

struct Node T[MAX];

int n;
int D[MAX],H[MAX];

int main() {
  int i,v,l,r;

  scanf("%d",&n);
  for(i = 0 ; i < n ; i++) {
    T[i].p = NIL;
  }

  for(i = 0 ; i < n ; i++) {
    scanf("%d%d%d",&v,&l,&r);
    T[v].l = l;
    T[v].r = r;
    if ( l != NIL )
      T[l].p = v;
    if ( r != NIL )
      T[r].p = v;
  }

  for (i = 0 ; i < n ; i++){
    D[i] = getDepth(i);
    H[i] = 0;
  }
    
  for (i = 0 ; i < n ; i++){
    if (T[i].l == NIL && T[i].r == NIL) { 
      H[i] = 0;
      int p = T[i].p;
      int c = 1;
      while(1){
	if (p == NIL)
	  break;
	if (H[p] < c)
	  H[p] = c;
	c++;
	p = T[p].p;
      }
    }
  }
  for (i = 0 ; i < n ; i++)
    print(i);
  return 0;
}

int getDepth(int x) {
  int d = 0;

  while(1) {
    x = T[x].p;
    if(x == NIL)
      break;
    d++;
  }
  return d;
}

int getSibling(int x) {
  if(T[x].p == NIL)
    return NIL;
  if(T[T[x].p].l != x && T[T[x].p].l != NIL)
    return T[T[x].p].l;
  if(T[T[x].p].r != x && T[T[x].p].r != NIL)
    return T[T[x].p].r;
  return NIL;
}

int print(int x){
  int degree = 0;

  printf("node %d: ", x);
  printf("parent = %d, ", T[x].p);
  printf("sibling = %d, ", getSibling(x));

  if ( T[x].l != NIL )
    degree++;
  if ( T[x].r != NIL )
    degree++;
  printf("degree = %d, ", degree);
  printf("depth = %d, ", D[x]);
  printf("height = %d, ", H[x]);

  if ( T[x].p == NIL ){
    printf("root\n");
  }
  else if ( T[x].l == NIL && T[x].r == NIL ){
    printf("leaf\n");
  }
  else {
    printf("internal node\n");
  }
}
  



Measured memory_bytes: 2104
#include <iostream>
#include <string>
#include <algorithm>

using namespace std;

int main() {
    int n;
    int tmp = 1;
    int ans = 0;

    cin >> n;

    if(n == 1){
        cout << 1;
    }else{
        while(tmp <= n){
            tmp *= 2;
        }
        cout << tmp/2;
    }
    return 0;
}

Measured memory_bytes: 3632
from sys import exit

def gcd(x,y):
    if x == 0: return y
    else: return gcd(y%x,x)


N = int(input())
A = list(map(int,input().split()))

is_prime = [True]*(10**6+10)
is_prime[0] = False
is_prime[1] = False

for i in range(2,10**6+10):
    if not is_prime[i]:
        continue
    else:
        for j in range(i*i,10**6+10,i):
            is_prime[j] = False

g = 0
for i in A:
    g = gcd(g,i)

if g != 1:
    print("not coprime")
    exit(0)

prime = [p for p in A if is_prime[p]]
used = [False]*(10**6+10)
notprime = [np for np in A if not is_prime[np]]
small_prime = [p for p in range(10**3+10) if is_prime[p]]


for p in prime:
    used[p] = True

for np in notprime:
    for p in small_prime:
        if np == 1: break
        if np % p != 0: continue
        if used[p]:
            print("setwise coprime")
            exit(0)
        used[p] = True
        while np % p == 0:
            np //= p
    if np > 1:
        if used[np]:
            print("setwise coprime")
            exit(0)
        used[np] = True

print("pairwise coprime") 

Measured memory_bytes: 225744
#include <bits/stdc++.h>
using namespace std;
#define pi 3.14159265359
#define int long long
#define pii pair<int,int>
const int mod = 1e9+7;
 
int dx[]={1,-1,0,0,1,-1,1,-1};
int dy[]={0,0,1,-1,1,-1,-1,1};




int32_t main()
{

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

   int n;
   cin>>n;

   set<string>st;

   for(int i=0;i<n;i++)
   {
	   string s;
	   cin>>s;
	   st.insert(s);

   }


cout<<st.size()<<"\n";


}


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

using namespace std;

int main()
{
    string A;
    cin >> A;

    int N = A.size();

    vector<vector<long long>> cnt(N, vector<long long>(26, 0));    
    for (int i = 0; i < N; i++) {
        cnt[i][A[i] - 'a']++;
    }

    for (int i = N - 1; i > 0; i--) {
        for (int j = 0; j < 26; j++) {
            cnt[i - 1][j] += cnt[i][j];
        }
    }

    long long ans = 1;
    for (int i = 0; i < N; i++) {
        ans += (N - i) - cnt[i][A[i] - 'a'];
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 48900
import math

a, b = map(int, input().split(" "))

for i in range(1, 10000):
    if math.floor(i * 0.08) == a and math.floor(i * 0.1) == b:
        if math.floor(i * 0.08) != 0:
            print(i)
            exit()

print(-1)

Measured memory_bytes: 3060
#include<iostream>
#include<bits/stdc++.h>
using namespace std;
int solve(int A[], int n,int k){
    vector<int> ans(n+1, INT_MAX);
    ans[1]=0;
    ans[2]=abs(A[2]-A[1]);
    
    for(int i=3;i<=n;i++)
    for(int j=1;j<=min(i-1,k);j++)
    ans[i]=min(ans[i-j]+abs(A[i]-A[i-j]), ans[i]);
    
    return ans[n];
}
int main(){
    int n,k;
    cin>>n>>k;
    int A[n+1];
    for(int i=1;i<=n;i++)
    cin>>A[i];
    
    cout<<solve(A,n,k);
}

Measured memory_bytes: 1024
#include <stdio.h>

int n,A[50];


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

int main (){
	int q,M,i;
	
	scanf("%d",&n);
	for(i=0 ; i<n ; i++ )scanf("%d",&A[i]);
	scanf("%d",&q);
	for(i=0 ; i<q ; i++){
		scanf("%d",&M);
		if(solve(0,M)) printf("yes\n");
	else printf("no\n");
}

return 0;
}


Measured memory_bytes: 2124