akhauriyash/Code-Regression huggingface dataset:
using System;
using System.Text;
using System.Linq;
using System.Collections;
using System.Collections.Generic;
using static System.Console;
using static System.Math;

namespace AtCoder
{
    public class Program
    {
        public static void Main(string[] args)
        {
            new Program().Solve(new ConsoleInput(Console.In, ' '));
        }

        public void Solve(ConsoleInput cin)
        {
            var N = cin.ReadInt;
            var H = cin.ReadIntArray(N);

            var beforeH = H[0];
            var cnt = 0;
            var ans = 0;
            for(var i=1; i<N; i++)
            {
                if(H[i] <= beforeH)
                {
                    cnt++;
                }
                else
                {
                    ans = Math.Max(cnt, ans);
                    cnt = 0;
                }
                beforeH = H[i];
            }
            ans = Math.Max(cnt, ans);
            cnt = 0;
            WriteLine(ans);

        }
    }

    public class ConsoleInput
    {
        private readonly System.IO.TextReader _stream;
        private char _separator = ' ';
        private Queue<string> inputStream;
        public ConsoleInput(System.IO.TextReader stream, char separator = ' ')
        {
            this._separator = separator;
            this._stream = stream;
            inputStream = new Queue<string>();
        }
        public string Read
        {
            get
            {
                if (inputStream.Count != 0) return inputStream.Dequeue();
                string[] tmp = _stream.ReadLine().Split(_separator);
                for (int i = 0; i < tmp.Length; ++i)
                    inputStream.Enqueue(tmp[i]);
                return inputStream.Dequeue();
            }
        }
        public string ReadLine { get { return _stream.ReadLine(); } }
        public int ReadInt { get { return int.Parse(Read); } }
        public long ReadLong { get { return long.Parse(Read); } }
        public double ReadDouble { get { return double.Parse(Read); } }
        public string[] ReadStrArray(long N) { var ret = new string[N]; for (long i = 0; i < N; ++i) ret[i] = Read; return ret; }
        public int[] ReadIntArray(long N) { var ret = new int[N]; for (long i = 0; i < N; ++i) ret[i] = ReadInt; return ret; }
        public long[] ReadLongArray(long N) { var ret = new long[N]; for (long i = 0; i < N; ++i) ret[i] = ReadLong; return ret; }
    }
}

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

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	ll n;
	cin>>n;
	vector<ll> a(n);
	REP(i,n) cin>>a[i];
	vector<ll>  buf(n);
	REP(i,n) buf[i]=a[i];
	REP(i,n) buf[i]-=(i+1);
	sort(ALL(buf));
	ll b=buf[n/2];
	ll ans=0;
	REP(i,n) ans+=abs(a[i]-(b+(i+1)));
	cout<<ans<<endl;
}


Measured memory_bytes: 3456
#include<iostream>
#include<vector>
#include<queue>
#include<stack>
#include<map>
#include<string>
#include<algorithm>
#include<utility>
#include<math.h>

using namespace std;
typedef pair<int, int> P;
typedef long long int ll;

const int INF = 1<<30;

char field[410][410];
int h, w;
int dx[]={0, 0, 1, -1}, dy[]={1, -1, 0, 0};
P voyage(int i, int j){
  int sharp=0, dot=0;
  char c=(field[i][j]=='#'?'.':'#');
  if(field[i][j]=='#')sharp++;
  else dot++;
  field[i][j]='x';
  for(int k=0;k<4;k++){
    int x=i+dx[k], y=j+dy[k];
    if(0<=x&&x<h&&0<=y&&y<w&&field[x][y]==c){
      P p = voyage(x, y);
      sharp+=p.first;dot+=p.second;
    }
  }
  return P(sharp, dot);
}

int main(){
  cin>>h>>w;
  for(int i=0;i<h;i++){
    for(int j=0;j<w;j++){
      cin>>field[i][j];
    }
  }
  ll ans=0;
  for(int i=0;i<h;i++){
    for(int j=0;j<w;j++){
      if(field[i][j]=='#'){
        P p = voyage(i, j);
        ans+=ll(p.first)*ll(p.second);
      }
    }
  }
  cout<<ans<<endl;
}


Measured memory_bytes: 10368
import java.util.Scanner;
import java.util.List;
import java.util.ArrayList;
import java.util.Objects;

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

    Scanner sc = new Scanner(System.in);

    int X = sc.nextInt();
    int A = sc.nextInt();

    System.out.println(X < A ? 0 : 10);

  }
}


Measured memory_bytes: 21972
#include <iostream>
#include <cstdio>
#include <cmath>
#include <algorithm>
#include <string>
#include <map>
#include <numeric>
#include <bitset>
#include <vector>
#include <queue>

using namespace std;

typedef long long ll;
#define FOR(i,a,b)   for(ll i = (a); i < (b); i++ )
#define REP(i, n)    FOR(i,0,n)
typedef pair< ll, ll >   cp2;
typedef pair< ll, cp2 >   cp3;
#define fi first
#define se second
#define sec  se.fi
#define thr  se.se
const ll mod = 1000000007;
//              123456789

 
///////////////////////////////////////////////
//
//
///////////////////////////////////////////////

////////////////////////////////////////////////
////////////////////////////////////////////////

int N;
int X;
int a;
int sml = mod;
int sum = 0;

int main(){
	
	cin>>N>>X;
	REP( i, N ){
		cin>>a;
		sum += a;
		sml = min( sml, a );
	}
	
	cout<<N+((X-sum)/sml)<<endl;
}



Measured memory_bytes: 256
from collections import Counter

n=int(input())
a=list(map(int,input().split()))

l1=[i+a[i] for i in range(n)]
l2=[i-a[i] for i in range(n)]

c2=Counter(l2)

ans=0
for i in l1:
  ans+=c2[i]

print(ans)

Measured memory_bytes: 50704
def lma():return list(map(int, input().split()))#x or y
a = int(input())
k=[]
s=[]
c=0
s= [lma()]
x2= lma()
x3 = lma()
s.append(x2)
s.append(x3)
res =0
r =0
for j in range(3):
    for i in range(a):
        k.append([j,s[j][i]])
k.sort(key=lambda x: x[1], reverse=True)
for i in range(a*3):
    if k[i][0] == 2:
       c+=1
    elif k[i][0] == 1:
       r+=c 
    else:
       #res+=sum(co[:i])
        res+=r
print(res)

Measured memory_bytes: 51164
/*
Minhazul Hayat Khan
minhaz1217.github.io
Website: www.minhazul.com
EWU, Bangladesh
Problem Name:
Problem Link:
Date : 12 / May / 2019
Comment:
*/
#include<bits/stdc++.h>
//#include<iostream>
using namespace std;
#define DEBUG 1
#define check(a) DEBUG==1?(cout << a << endl):null;
#define cc(a) DEBUG==1?(cout << a << endl):cout<<"";
#define msg(a,b) DEBUG==1?(cout << a << " : " << b << endl):cout<<"";
#define msg2(a,b,c) DEBUG==1?(cout << a << " : " << b << " : " << c << endl):cout<<"";
#define msg3(a,b,c,d) DEBUG==1?(cout << a << " : " << b << " : " << c << " : " << d << endl):cout<<"";
#define msg4(a,b,c,d,e) DEBUG==1?(cout << a << " : " << b << " : " << c << " : " << d << " : " << e << endl):cout<<"";
#define _INIT ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);

vector<pair< long long int, long long int> > res;
vector<long long int> vec;
void sliding_window(int m){
    int val;
    deque<pair<long long int, long long int> > dqMin, dqMax;
    for(int i=0;i<vec.size();i++){
        val = vec[i];
        while(!dqMin.empty() && dqMin.front().first >= val){
            dqMin.pop_front();
        }
        dqMin.push_front(make_pair(val,i));
        while(!dqMin.empty() && dqMin.back().second <= i-m){
            dqMin.pop_back();
        }


        while(!dqMax.empty() && dqMax.front().first <= val){
            dqMax.pop_front();
        }
        dqMax.push_front(make_pair(val,i));
        while(!dqMax.empty() && dqMax.back().second <= i-m){
            dqMax.pop_back();
        }

        if(i>=m-1){
            res.push_back(make_pair(dqMin.back().first, dqMax.back().first) );
        }
    }
}


int main(){

    long long int n,k,a,ans,mn = INT_MAX,u,v;
    cin >> n >> k;
    for(int i=0;i<n;i++){
        cin >> a;
        vec.push_back(a);
    }
    sliding_window(k);
    for(int i=0;i<res.size();i++){
        u = res[i].first;
        v = res[i].second;

        if( (u <= 0 && v<= 0) || (u>=0 && v>=0)){
            ans = max(abs(u), abs(v));
        }else{
            ans = min( abs(u), abs(v) )*2 + max( abs(u), abs(v) );
        }
        mn = min(ans,mn);
        //msg2(u,v,mn)
    }
    cout << mn << endl;
    return 0;
}


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

using namespace std;

#define REP(i,a,b) for(int i = a; i <= b; ++i)
#define PER(i,a,b) for(int i = a; i >= b; --i)
#define MP make_pair
#define PB push_back
#define fi first
#define se second
typedef long long LL;
typedef long double LD;

const int maxn = 5000;
const int P = 1e9+7;

void Add(int &a, int b) { a+=b; if(a>=P) a-=P; }
void Sub(int &a, int b) { a-=b; if(a<0) a+=P; }
LL PowMod(LL a, LL b) { LL r=1; while(b) { if(b&1) r=r*a%P; a=a*a%P, b>>=1; } return r; }

int n, A, B;
int f[maxn+5][maxn+5][2], ss[maxn+5];
int two[maxn+5];

int main() {
    two[0] = 1;
    REP(i,1,maxn) two[i] = two[i-1]*2 % P; 

    scanf("%d%d%d", &n, &A, &B);
    if(A>B) swap(A,B);

    f[0][1][0] = f[0][1][1] = 1;
    ss[0] = 1;
    int ans = 0;
    for(int i = 1; i <= n; ++i) {
        ss[i] = ss[i-1];
        for(int t = 1; t <= i; ++t) {
            int tmp = f[i-1][t][0];
            if(i-t+1 >= B) {
                if(i < n) tmp = LL(tmp) * two[n-i-1] % P;
                Add(ans, tmp);
            }
            else {
                f[i][t][1] = tmp;
                Add(ss[i], f[i][t][1]);
            }
            Add(f[i][t][1], f[i-1][t][1]);
        }

        Add(f[i][i+1][0], ss[i-1]);
        if(i-A >= 0) Sub(f[i][i+1][0], ss[i-A]);

        for(int t = 1; t <= i; ++t) {
            int tmp = 0;
            if(i-A >= 0) tmp = f[i-A][t][1];
            if(i-t+1 >= B) {
                if(i < n) tmp = LL(tmp) * two[n-i-1] % P;
                Add(ans, tmp);
            }
            else {
                f[i][t][0] = tmp;
            }
            Add(f[i][t][0], f[i-1][t][0]);
        }
    }
    printf("%d\n", ans);
    return 0;
}


Measured memory_bytes: 120524
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N=1e5+5;
int n,f[N],si[N];
struct node
{
    ll x;
    int id;
    bool operator<(const node&o)const
    {
        return x<o.x;
    }
}a[N];
unordered_map<ll,int>mp;
vector<pair<int,int> >v;
int tot,fa[N],head[N],nex[N<<1],to[N<<1];
void add(int u,int v){to[++tot]=v;nex[tot]=head[u];head[u]=tot;}
ll dis[N];
void dfs(int u,int p)
{
    fa[u]=p;
    for(int i=head[u];i;i=nex[i])
    {
        int v=to[i];if(v==p) continue;
        dfs(v,u);
        dis[u]+=dis[v]+si[v];
    }
}
bool dfs(int u)
{
    if(a[u].x!=dis[u]) return false;
    for(int i=head[u];i;i=nex[i])
    {
        int v=to[i];if(v==fa[u]) continue;
        dis[v]=dis[u]-si[v]+(n-si[v]);
        if(!dfs(v)) return false;
    }
    return true;
}
bool check()
{
    if(v.size()!=n-1) return false;
    for(int i=0;i<v.size();i++)
        add(v[i].first,v[i].second),add(v[i].second,v[i].first);
    dfs(1,0);
    return dfs(1);
}
int main()
{
    scanf("%d",&n);
    for(int i=1;i<=n;i++) scanf("%lld",&a[i].x),a[i].id=i;
    sort(a+1,a+1+n);
    for(int i=1;i<=n;i++) si[i]=1,f[i]=a[i].id,mp[a[i].x]=i;
    for(int i=n;i>1;i--)
    {
        ll t=a[i].x+si[i]-(n-si[i]);
        if(mp[t]&&mp[t]<i) v.push_back({i,mp[t]}),si[mp[t]]+=si[i];
    }
    if(si[1]!=n||!check()) {printf("-1\n");return 0;}
    else for(int i=0;i<v.size();i++)
        printf("%d %d\n",f[v[i].first],f[v[i].second]);
}


Measured memory_bytes: 14624
#include<stdio.h>
int main(void){
  int H,W;
  int a,b,k=1;
  while(k != 0){
    scanf("%d %d",&H,&W);
    if(H==0 && W==0){
      break;
    }
    for(b=1;b <= H;b++){
      for(a=1;a <= W;a++){
        printf("#");
      }
      printf("\n");
    }
    printf("\n");
  }
  return 0;
}

Measured memory_bytes: 572
#include <bits/stdc++.h>
#define N 3003
using namespace std;

int n;
double f[N][N], p[N];

int main() {
#ifdef whyqx
    freopen("work.in", "r", stdin);
    freopen("work.out", "w", stdout);
#endif
    cin >> n;
    for (int i = 1; i <= n; ++i)
        scanf("%lf", p + i);
    f[0][0] = 1;
    for (int i = 1; i <= n; ++i)
        for (int j = 0; j <= i; ++j) {
            f[i][j] = f[i - 1][j] * (1 - p[i]);
            if (j) f[i][j] += f[i - 1][j - 1] * p[i];    
        }
    double ans = 0.000;
    for (int j = n / 2 + 1; j <= n; ++j)
        ans += f[n][j];
    printf("%.10lf\n", ans);
    return 0;
}


Measured memory_bytes: 68992
//AtCoder AGC031 A - Colorful Subsequence
#include <bits/stdc++.h>
using namespace std;
using ll=int64_t;
constexpr ll MOD=1e9+7;
#define FOR(i,a,b) for(int64_t i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
int main() {
    ll N; cin>>N;
    string S; cin>>S;
    unordered_map<char,ll> chnum;
    REP(i,N){
        ++chnum[S[i]];
    }
    ll ans=1;
    for(const auto& cn:chnum){
        ans *= (cn.second+1);
        ans %= MOD;
    }
    ans -= 1;
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
#define syosu(x) fixed<<setprecision(x)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef pair<double,double> pdd;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<string> vs;
typedef vector<P> vp;
typedef vector<vp> vvp;
typedef vector<pll> vpll;
typedef pair<int,P> pip;
typedef vector<pip> vip;
const int inf=1<<30;
const ll INF=1ll<<60;
const double pi=acos(-1);
const double eps=1e-9;
const ll mod=1e9+7;
const int dx[4]={0,1,0,-1},dy[4]={1,0,-1,0};

ll f(ll x){
	ll t=0;
	while(x) t+=x%10,x/=10;
	return t;
}

int k;

int main(){
	cin>>k;
	vl a;
	ll t=1;
	for(int i=0;i<15;i++){
		for(int j=2;j<=150;j++) a.push_back(t*j-1);
		t*=10;
	}
	sort(a.begin(),a.end());
	a.erase(unique(a.begin(),a.end()),a.end());
	ll S=a.size();
	for(int i=0;k;i++){
		bool B=0;
		for(int j=i+1;j<S;j++) if(a[i]*f(a[j])>a[j]*f(a[i])) B=1;
		if(!B){
			cout<<a[i]<<endl;
			k--;
		}
	}
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <cstdlib>
#include <vector>
#include <sstream>
#include <set>
#include <tuple>
#include <algorithm>
#include <memory>
#include <numeric>

typedef long long ll;
typedef unsigned long long ull;

using namespace std;

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

	ll N;
	string A, B, C;
	cin >> N;
	cin >> A;
	cin >> B;
	cin >> C;

	ll cnt = 0;
	for (ll i = 0; i < N; ++i)
	{
		if (A[i] == B[i] && B[i] == C[i] && C[i] == A[i])
		{
			continue;
		}

		if (A[i] == B[i] || B[i] == C[i] || C[i] == A[i])
		{
			cnt++;
			continue;
		}

		cnt += 2;

	}

	cout << cnt << endl;
}

Measured memory_bytes: 256
N = int(input())
D, X = map(int, input().split())
A_list = [int(input()) for _ in range(N)]

ans = X
for i in range(N):
    num = 1 + D // A_list[i]
    if D % A_list[i] == 0:
        num -= 1

    ans += num

print(ans)


Measured memory_bytes: 2940
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
const int INF = 1e9+5;

int main(){
	int n,W;
	scanf("%d%d",&n,&W);
	vector<int> weight(n), value(n);
	for(int i = 0; i < n; i++)
		scanf("%d%d", &weight[i], &value[i]);

	int sum_value = 0;
	for(int i = 0; i < n; i++)
		sum_value += value[i];

	vector<ll> dp(sum_value+1, INF);///Min weight at this value
	
	dp[0] = 0;
	for(int item = 0; item < n; item++){

		for(int val = sum_value - value[item]; val >= 0; val--){
			dp[val + value[item]] = min(dp[val+value[item]], dp[val] + weight[item]);
		}
	}

	ll ans = 0;
	for(int i = 1; i <= sum_value; i++)
		if(dp[i] <= W)
			ans = max(ans, (ll)i);

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

Measured memory_bytes: 1024
fn input() -> String{
    let mut buf = String::new(); //A
    std::io::stdin().read_line(&mut buf).unwrap(); //B
    buf.trim().to_string() //C
}

fn three(line: &str) {
    let number: f64 = line.parse().unwrap();
    println!("{}", number.powf(3.0));
}

fn main() {
    let line = &input();
    three(line);
}


Measured memory_bytes: 5164
#include<iostream>
#include<cmath>
#include<numeric>
#include<functional>
#include<string>
#include<algorithm>
#include<vector>
#include<map>
#include<iomanip>
#include<queue>
#define rep(i,n) for(int i=0;i<n;i++)
#define rep1(i,n) for(int i=1;i<n;i++)
#define ll long long
#define INF 2147483647
using namespace std;
using Graph=vector<vector<int>>;

int main(){
  ll n,k; cin>>n>>k; ll p[n],c[n];
  rep(i,n){
    cin>>p[i]; p[i]--;
  }
  rep(i,n){
    cin>>c[i];
  }
  ll period[n]; vector<ll> v[n];
  ll sum[n]={},ruis[n][n];
  rep(i,n){
    ll tmp=0,q=i,s=0;
    while(1){
      q=p[q];
      v[i].push_back(q);
      tmp++;
      s+=c[q];
      ruis[i][tmp-1]=s;
      if(q==i){
        period[i]=tmp;
        break;
      }
    }
    sum[i]=s;
  }
  ll ma=-INF,anst;
  rep(i,n){
    ll r=(k-1)%period[i]+1,q=(k-r)/period[i],maxi1=0,maxi2=ruis[i][0];
    for(int j=0;j<r;j++){
      maxi1=max(maxi1,ruis[i][j]);
    }
    for(int j=1;j<min(k,period[i]);j++){
      maxi2=max(maxi2,ruis[i][j]);
    }
    if(q!=0){
      sum[i]>0?anst=q*sum[i]+max(maxi1,(ll)0):anst=maxi2;
    }else{
      anst=maxi2;
    }
    ma=max(ma,anst);
    // cout<<maxi1<<" "<<maxi2<<" "<<anst<<" "<<ma<<endl;
  }
  cout<<ma;
}

Measured memory_bytes: 414220
# Aizu Problem 0101: Aizu PR
#
import sys, math, os

# read input:
PYDEV = os.environ.get('PYDEV')
if PYDEV=="True":
    sys.stdin = open("sample-input.txt", "rt")


N = int(input())
for _ in range(N):
    print(input().replace("Hoshino", "Hoshina"))

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

using namespace std;

int main() {
	int N[3][3];
	int a[3],b[3],c[3],d[3];
	for(int i=0;i<3;i++){
		for(int j=0;j<3;j++){
			cin>>N[i][j];
		}
	}
	for(int i=0;i<3;i++){
		a[i]=N[i][0]-N[i][1];
	}
	for(int i=0;i<3;i++){
		b[i]=N[i][1]-N[i][2];
	}
	for(int i=0;i<3;i++){
		c[i]=N[0][i]-N[1][i];
	}
	for(int i=0;i<3;i++){
		d[i]=N[2][i]-N[1][i];
	}
	if(((a[2]==a[1])&&(a[1]==a[0]))&&((b[2]==b[1])&&(b[1]==b[0]))&&((c[2]==c[1])&&(c[1]==c[0]))&&((d[2]==d[1])&&(d[1]==d[0])))
	{cout<<"Yes"<<endl;}
	else {cout<<"No"<<endl;}
	// cout<<a[0]<<endl;
	// cout<<a[1]<<endl;
	// cout<<a[2]<<endl;
	// cout<<(a[0]==a[1])<<endl;
	// cout<<(a[2]==a[1])<<endl;
	// cout<<(a[2]==a[1]==a[0])<<endl;
	// cout<<((a[2]==a[1])&&(a[1]==a[0]))<<endl;

	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <stdio.h>

#define rep(i,min,sup) for(int i=min;i<sup;i++)
#define per(i,min,sup) for(int i=(sup-1);i>=min;i--)
#define swap(a,b) {a+=b;b=a-b;a-=b;}
#define ll long long

using namespace std;

main(){
  ll N,K;
  scanf("%lld %lld",&N,&K);
  ll ans=0;
  ll MOD=1000000007;
  rep(L,K,N+2){
    ans+=L*(N-L+1)+1;
    ans%=MOD;
  }
  printf("%lld",ans);
}

Measured memory_bytes: 3828
#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<map>
#include<iostream>
using namespace std;
map<int,long long>mp;
char s[200003];
int main(){
    cin>>s;
    long long len=strlen(s);
    for(int i=0;i<len;i++){
    	mp[s[i]-'a']++;
	}
    long long ans=1;
    ans+=len*(len-1)/2;
    for(int i=0;i<26;i++){
    	if(mp[i]){
        	ans-=mp[i]*(mp[i]-1)/2;
		}
	}
    cout<<ans<<endl;
    return 0;
}
/*

in:
abracadabra

out:
44

*/

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

int main()
{
    int n,m,s,d;
    scanf("%d %d",&n,&m);
    if(m%n==0){
        s=m+n;
        printf("%d",s);
    }
    else{
        d=m-n;
        printf("%d",d);
    }
    return 0;
}



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

int main() {
  char s[200001];
  cin >> s;
  int len = strlen(s);
  int mn_a = len + 1, mx_z = -1;
  for (int i = 0; i < len; i++) {
    if (s[i] == 'A') {
      if (i < mn_a)
        mn_a = i;
    }
    if (s[i] == 'Z') {
      if (i > mx_z)
        mx_z = i;
    }
  }
  cout << mx_z - mn_a + 1;
  return 0;
}


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

using namespace std;

int main()
{
  int N, K;
  cin >> N >> K;
  vector<int> hist(N + 1, 0);
  for (int i = 0; i < N; i++) {
    int A;
    cin >> A;
    hist[A]++;
  }

  sort(hist.begin(), hist.end());
  int idx = 0;
  while (hist[idx] == 0) idx++;
  int ans = 0;
  for (int i = idx; N - i + 1 > K; i++) {
    ans += hist[i];
  }
  cout << ans << endl;

  return 0;
}


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

double solve(int N, int T, const vector<int>& board) {
    vector<double> dp1(N + 1), dp2(N + 1), dp3(N + 1); dp1[0] = 1.0;
    rep(i, T) {
        rep(j, N) rep(k, 6) {
            int nj = j + k + 1;
            if (nj > N) nj = N - (nj - N);
            switch (board[nj]) {
                case 0: dp2[nj] += dp1[j] / 6.0; break;
                case 1: dp3[nj] += dp1[j] / 6.0; break;
                case 2: dp2[0] += dp1[j] / 6.0; break;
            }
        }
        dp2[N] += dp1[N];
        dp1.swap(dp2);
        dp2.swap(dp3);
        dp3.assign(N + 1, 0.0);
    }
    return dp1.back();
}

int main() {
    cout << fixed;
    for (int N, T, L, B; cin >> N >> T >> L >> B, N | T | L | B;) {
        vector<int> board(N + 1);
        for (int l; L--; cin >> l, board[l] = 1);
        for (int b; B--; cin >> b, board[b] = 2);
        cout << solve(N, T, board) << endl;
    }
}

Measured memory_bytes: 3256
#include<stdio.h>
int main(void)
{
	int a,b,x[101][101],flg,r,i,j;
	char X[101][101];
	scanf("%d%d",&a,&b);
	for(i=0;i<a;i++){
		scanf("%s",X[i]);
	}
	for(i=0;i<a;i++){
		flg=0;
		r=0;
		for(j=0;j<b;j++){
			x[i][j]=0;
			if(flg==0){
				if(X[i][j]=='c'){
					x[i][j]=0;
					flg=1;
				}
				else{
					x[i][j]=-1;
				}
			}
			else{
				if(X[i][j]=='c'){
					r=0;
					x[i][j]=0;
				}
				else{
					r++;
					x[i][j]=r;
				}
			}
		}
	}
	for(i=0;i<a;i++){
		for(j=0;j<b-1;j++){
			printf("%d ",x[i][j]);
		}
		printf("%d\n",x[i][b-1]);
	}
	return 0;
}

Measured memory_bytes: 1080
n = int(input())
w = list(map(int, input().split()))

diff = []

for t in range(1, n+1):
  upper = 0
  lower = 0
  
  for i in range(n):
    if i+1 > t:
      upper += w[i]
    else:
      lower += w[i]
    
  diff.append(abs(upper-lower))
  
print(min(diff))

Measured memory_bytes: 38768
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
ll mod = 1000000007;
const int INF = 1001001001;

template<class Type>
Type modpow(Type a, Type n, Type mod)
{
	Type res = 1;
	while (0 < n) {
		if (n & 1) {
			res = res * a % mod;
		}
		a = a * a % mod;
		n >>= 1;
	}
	return res;
}

template<class Type>
Type gcd(Type x, Type y)
{
	Type r;
	if (x < y) swap(x, y);

	while (0 < y) {
		r = x % y;
		x = y;
		y = r;
	}
	return x;
}

template<class Type>
Type lcm(Type x, Type y)
{
	return x * y / gcd(x, y);
}

template<class Type>
bool is_prime(Type x)
{
	if (x == 2) return true;
	if (x < 2 || x % 2 == 0) return false;

	for (Type i = 3; i <= sqrt(x); i += 2) {
		if (x % i == 0) return false;
	}
	return true;
}

template<class Type>
vector<bool> eratos(Type n)
{
	vector<bool> isPrime(n + 1, true);
	isPrime[0] = isPrime[1] = false;
	for (Type i = 2; i <= n; i++) {
		if (isPrime[i]) {
			Type j = i + i;
			while (j <= n) {
				isPrime[j] = false;
				j = j + i;
			}
		}
	}
	return isPrime;
}

bool binary_search_judge(vector<int> a, int index, int key)
{
	if (key <= a[index]) return true;
	else return false;
}

int binary_search(vector<int> a, int key)
{
	int ng = -1;
	int ok = a.size();
	while (1 < abs(ng - ok)) {
		int mid = (ng + ok) / 2;
		if (binary_search_judge(a, mid, key)) ok = mid;
		else ng = mid;
	}
	return a[ok] == key;
}

void turn_over(int i, int j, vector<vector<int>>& table)
{
	for (int k = i - 1; k <= i + 1; k++) {
		for (int l = j - 1; l <= j + 1; l++) {
			if (table[k][l] == 0) table[k][l] = 1;
			else table[k][l] = 0;
		}
	}
}

int main()
{
	ll n, m;
	cin >> n >> m;

	if (n == 1 && m == 1) cout << 1 << endl;
	else if (n == 1 && 1 < m) cout << m - 2 << endl;
	else if (m == 1 && 1 < n) cout << n - 2 << endl;
	else cout << (n - 2) * (m - 2) << endl;
}

Measured memory_bytes: 256
#pragma region
#pragma GCC target("avx2")
#pragma GCC optimize("03")
#pragma GCC optimize("unroll-loops")
#include <bits/stdc++.h>
using namespace std; typedef long double ld; typedef long long ll;
typedef unsigned long long ull;
#define endl "\n"
#define MP make_pair
#define FOR(i,a,b) for(int i=(a);i<=(b);i++)
#define FORR(x,arr) for(auto& x:arr)
#define PII pair<int, int>
#define PLL pair<ll, ll>
#define VPII vector<PII>
#define VPLL vector<PLL>
#define FI first 
#define SE second
#define ALL(x) (x).begin(), (x).end()
constexpr int INF=1<<30; constexpr ll LINF=1LL<<60; constexpr ll mod=1e9+7; constexpr int NIL = -1;
template<class T>inline bool chmax(T &a, const T &b) { if (a<b) { a = b; return 1; } return 0; }
template<class T>inline bool chmin(T &a, const T &b) { if (b<a) { a = b; return 1; } return 0; }
#pragma endregion
//-------------------
const ll mx = 200;

ll pow5(ll x) {
    return x*x*x*x*x;
}
int main(){
    cin.tie(0); ios::sync_with_stdio(false); //cout << fixed << setprecision(15);
    ll x; cin >> x;
    for(int i=-mx; i<=mx; i++) {
        for(int j=-mx; j<=mx; j++) {
            if(pow5((ll)i)-pow5((ll)j) == x) {
                cout << i << " " << j; 
                return 0;
            }
        }
    }
    return 0;
}


Measured memory_bytes: 3652
#define _CRT_SECURE_NO_WARNINGS
#include<bits/stdc++.h>
#define fi first
#define se second
#define pb push_back
#define E "\n"

using namespace std;
const long long MOD = (long long)1e9 + 7;

long long n, m, p[100009], cnt, pe;
string s[100009];
int ac[100009];
bool ok[100009];

int main()
{
    ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    cin >> n >> m;
    for (int i = 0; i < m; i++) {
        cin >> p[i] >> s[i];
        if (ok[p[i]]) continue;
        if (s[i] == "WA") {
            ac[p[i]]++;
        }
        else {
            cnt++;
            pe += ac[p[i]];
            ok[p[i]] = true;
        }
    }
    cout << cnt << " " << pe << E;
    //system("pause");
    return 0;
}

Measured memory_bytes: 7040
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int x = sc.nextInt();
		int a = sc.nextInt();
		int b = sc.nextInt();
		sc.close();
		
		int l1 = Math.abs(x - a);
		int l2 = Math.abs(x - b);
		
		if(l1 > l2)
			System.out.println("B");
		else
			System.out.println("A");
	}
}


Measured memory_bytes: 21972
#include<stdio.h>
#include<algorithm>
using namespace std;
double dp[1<<14];
int g[20][20];
int main(){
	int a,b,c;scanf("%d%d%d",&a,&b,&c);
	for(int i=0;i<b;i++){
		int p,q;scanf("%d%d",&p,&q);p--;q--;
		g[p][q]=g[q][p]=1;
	}
	for(int i=0;i<(1<<a);i++){
		dp[i]=1.0;
		if(i==0)continue;
		int at=0;
		for(int j=0;j<a;j++)if(i&(1<<j)){at=j;continue;}
		for(int j=i;j>=1;j=((j-1)&i)){
			if(j==i||!(j&(1<<at)))continue;
			double ks=dp[j];
			for(int k=0;k<a;k++){
				if(!(j&(1<<k)))continue;
				for(int l=0;l<a;l++){
					if(!(i&(1<<l))||(j&(1<<l)))continue;
					if(g[k][l])ks*=(double)c/100;
				}
			}
			dp[i]-=ks;
		}
	}
	printf("%.12f",dp[(1<<a)-1]);
	for(int i=0;i<1000;i++)printf("%d",rand()%1000000000);
	printf("\n");
}

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

int main(){
    int n, a, b;
    cin >> n >> a >> b;
    a--, b--;
    vector<int> v[n];
    for(int i = 0; i < n-1; i++){
        int x, y;
        cin >> x >> y;
        x--, y--;
        v[x].push_back(y);
        v[y].push_back(x);
    }
    function<void(vector<int>&,int,int,int)> f = [&](vector<int> &d, int x, int par, int dep){
        d[x] = dep;
        for(int y : v[x]){
            if(y != par)    f(d, y, x, dep+1);
        }
    };
    vector<int> tak(n), aoki(n);
    f(tak, a, -1, 0);
    f(aoki, b, -1, 0);
    int ret = 0;
    for(int i = 0; i < n; i++){
        if(tak[i] < aoki[i])    ret = max(ret, aoki[i]-1);
    }
    cout << ret << endl;
    return 0;
}

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

int main(){
    string s;
    getline(cin, s);

    for(int i=0; i<(int)s.length(); i++){
        if('A' <= s[i] && s[i] <= 'Z'){
            s[i] = 'a' +s[i]-'A';
        }else if('a' <= s[i] && s[i] <= 'z'){
            s[i] = 'A' +s[i]-'a';
        }
    }
    cout << s << endl;
    return 0;
}

Measured memory_bytes: 3204
#include <iostream>
#include <string>
#include <algorithm>
#include <functional>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <cstdio>
#include <cmath>
#include <tuple>
#include <iomanip>
#include <numeric>
#include <unordered_map>
#include <sstream>   
#include<limits.h>
using namespace std;
#define i64  long long
#define lint long long

#define I32_MAX 2147483647
#define I64_MAX 9223372036854775807
#define MOD_Q 1e9 + 7;

void solve()
{
  int N;
  cin>>N;
  vector<int> vec(N + 1,0);
  for (int i = 1; i <= N; i++)
  {
    cin>>vec[i];
  }
  
  vector<int> DP (N + 1,I32_MAX);

  DP[1] = 0;
  DP[2] = abs(vec[2]-vec[1]);

  for (int i = 3; i <= N; i++)
  {
    DP[i] = min(abs(vec[i] - vec[i-2]) + DP[i-2],abs(vec[i] - vec[i-1]) + DP[i-1]);
  }

  // for (int i = 0; i < N+1; i++)
  // {
  //   cout<<DP[i]<<endl;
  // }
  
  
  cout<<DP[N]<<endl;

  return;
}

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

  solve();

  return 0;
}


Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define mod 1000000007

int main(){
	

	int t = 1;
	//cin >> t;
	while(t--){
		int n, k;
		cin >> n >> k ;
		std::vector<int> v(n);
		for(int i = 0; i < n; ++i){
			cin >> v[i];
		}

		for(int i = k; i < n; ++i){
			if(v[i] > v[i - k]){
				cout << "Yes\n";
			}
			else{
				cout << "No\n";
			}
		}

	}
	return 0;
}

Measured memory_bytes: 3980
/*
क्षमाशील हो रिपु-समक्ष
तुम हुये विनत जितना ही
दुष्ट कौरवों ने तुमको
कायर समझा उतना ही।
*/
#include<bits/stdc++.h>
using namespace std;
 
#define int                 long long int
#define ull                 unsigned int
#define ld                  long double
#define pb                  push_back
#define ff                  first
#define ss                  second
#define S(arr)              sort(arr.begin(),arr.end());
#define all(p)              p.begin(), p.end()
#define RS(arr)             sort(arr.rbegin(),arr.rend());
#define R(arr)              reverse(arr.begin(),arr.end());
#define pii                 pair <int, int>
#define vpi                 vector <pii>
#define vi                  vector <int>
#define vld                 vector <ld>
#define vvi                 vector <vector <int>>
#define vvpi                vector <vector <pii>>
#define vs                  vector <string>
#define si                  set <int>
#define spi                 set <pii>
#define setbits(x)          __builtin_popcountll(x)
#define zrobits(x)          __builtin_ctzll(x)
#define mii                 map <int, int>
#define mci                 map<char, int>
#define mpi                 map <pii, int>
#define T                   int tcf;cin>>tcf;while(tcf--)
#define que_max(t)          priority_queue <t>
#define que_min(t)          priority_queue <t, vector<t>, greater<t>>
#define endl                "\n"
#define dba(a, l, r)        for(auto x:a)cout<<x<<" ";cout<<endl;
#define db1(x)              cout << #x " = " << x << endl;
#define db2(x,y)            cout << #x " = " << x << " " << #y " = " << y << endl;
#define db3(x,y,z)          cout << #x " = " << x << " " << #y " = " << y << " " << #z " = " << z << endl;
#define db4(x,y,z,w)        cout << #x " = " << x << " " << #y " = " << y << " " << #z " = " << z << " " << #w " = " << w << endl;
#define db5(x,y,z,w,v)      cout << #x " = " << x << " " << #y " = " << y << " " << #z " = " << z << " " << #w " = " << w << " " << #v " = " << v << endl;
#define db6(x,y,z,w,v,a)    db3(a, y, x)db3(w, v, a)
#define p2d(v)              for(auto a:v){for(auto b:a)cout<<b<<" ";cout<<endl;}
#define p1d(v)              for(auto a:v)cout<<a<<" ";cout<<endl;
#define ppi(v)              for(auto a:v)cout<<a.ff<<" "<<a.ss<<endl;

// #include <ext/pb_ds/assoc_container.hpp>
// using namespace __gnu_pbds;  
// typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> pbds;
//  // *( hsh.find_by_order(k) ) kth smallest, from 0
//  // hsh.order_of_key(k) num of ele str less than k
//  // change less to less_equal for multiset pbds
 
void read(int n=10){
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    cout<<setprecision(n)<<fixed;
    #ifndef ONLINE_JUDGE
         freopen("input.txt",  "r",  stdin);
         freopen("output.txt", "w", stdout);
    #endif
}
 
int M = 1e9 + 7;
int M1 = 998244353;
#define qqq 4000005
#define pi 3.14159265358979323851



int32_t main(){
    // read();
    int a;
    cin>>a;
    cout<<a+(a*a)+(a*a*a);
}  

Measured memory_bytes: 3616
#include <bits/stdc++.h>
#include <atcoder/dsu>

using namespace std;
#ifdef __DEBUG__
    void debug_out() { cerr << endl; } 
    template <typename Head, typename... Tail>
    void debug_out(Head H, Tail... T) {cerr << " " << H; debug_out(T...);}
    #define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#else
    #define debug(...) 
#endif

using ll = long long int;
using pii = pair<int, int>;

inline void fast_io() { ios_base::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr); };
template<typename T> inline ostream& operator<<(ostream& os, const vector<T>& v) { for (auto el : v) cout << el << " "; return os; }

void chmin(int& a, int b){if(a>b) a=b;}

int N;
vector<int> Idx;
vector<pii> P;
inline void input(){
    fast_io();
    cin >> N;
    P.resize(N);
    Idx.resize(N);
    for (int i = 0; i < N; i++)
    {
        int x,y; cin >> x >> y;
        x--, y--;
        P[i] = make_pair(x, y);
        Idx[x] = i;
    }
}

int solve(){
    vector<int> Ans(N,0);
    auto cmp_x = [](pii a, pii b){return a.first < b.first;};
    sort(P.begin(),P.end(), cmp_x);
    vector<int> Y, IdxY(N,0);
    for (int i = 0; i < N; i++) Y.push_back(P[i].second);
    for (int i = 0; i < N; i++) IdxY[Y[i]] = i;
    debug(Y);
    atcoder::dsu uf(N);
    vector<bool> used(N,false);
    // int ymin = Y[0];
    // int yidx = 0;
    set<int> minset;
    minset.insert(Y[0]);
    for (int i = 1; i < N; i++)
    {
        bool merged = false;
        int ymin = Y[i];
        auto lb = minset.lower_bound(Y[i]);
        for(auto itr=minset.begin();itr!=lb;){
            int y = *itr;
            int idx = IdxY[y];
            if(y < Y[i]) {
                uf.merge(i, idx);
                merged = true;
                itr = minset.erase(itr);
                chmin(ymin, y);
            }
            else{
                itr++;
            }
        }

        minset.insert(ymin);
    }
    
    for (int i = 0; i < N; i++) Ans[Idx[i]] = uf.size(i);
    for(auto a:Ans) cout << a << "\n";    
    return 0;
}

int main()
{
    input();
    solve();
    return 0;
}


Measured memory_bytes: 12796
#include<iostream>
#include<vector>

using namespace std;
#define T_MAX 1000000000



typedef vector<int> vec;
typedef vector<vec> mat;


int n, m, a, b, c, t, num;

mat mul(mat &A, mat&B, int m) {
	mat C(A.size(), vec(B[0].size()));
	for (int i = 0; i < A.size(); i++) {
		for (int k = 0; k < B.size(); k++) {
			for (int j = 0; j < B[0].size(); j++) {
				C[i][j] = (C[i][j] + A[i][k] * B[k][j]) % m;
			}
		}
	}
	return C;
}
mat pow(mat A, int n, int m) {
	mat B(A.size(), vec(A.size()));
	for (int i = 0; i < A.size(); i++) {
		B[i][i] = 1;
	}
	while (n > 0) {
		if (n & 1)B = mul(B, A, m);
		A = mul(A, A, m);
		n >>= 1;
	}
	return B;
}


int main(void) {
	while (1) {
		cin >> n >> m >> a >> b >> c >> t;
		if (n == 0)break;
		mat A(n, vec(n)), A_T(n, vec(n));
		vec Nin(n), Nout(n);
		int i;
		for (i = 0; i < n; i++) {
			cin >> num;
			Nin[i] = num;
		}
		for (i = 0; i < n; i++) {
			if (i != 0)A[i][i - 1] = a;
			A[i][i] = b;
			if (i != n - 1)A[i][i + 1] = c;
		}
		A_T = pow(A, t, m);

		for (i = 0; i < n; i++) {
			for (int k = 0; k < n; k++) {
				Nout[i] = (Nout[i] + A_T[i][k] * Nin[k]) % m;
			}
			cout << Nout[i];
			if (i != n - 1)cout << " ";
		}
		cout << endl;
	}
	return 0;
}

Measured memory_bytes: 1296
using System;
using System.Collections.Generic;
using System.Linq;
using static System.Console;
using static System.Math;

class MainClass
{
    static void Main()
    {
        var r = ReadLine().Split();
        int a = int.Parse(r[0]);
        int b = int.Parse(r[2]);
        if (r[1] == "+")
        {
            WriteLine(a+b);
        }
        else
        {
            WriteLine(a-b);
        }
    }
}


Measured memory_bytes: 27336
n = input()
a = list(map(int, input().split()))
even = True
count = 0
while even:
    for ai in range(len(a)):
        if a[ai] % 2 != 0:
            even = False
            break

    if even:
        a = list(map(lambda num: num / 2, a))
        count += 1
    else:
        break
print(count)

Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std;
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
template<class T> using oset=tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
#define pb push_back
#define N 200001
#define ll long long
#define int ll 
#define pi pair<int , int>
#define pip pair<pair ,int>
#define mp make_pair 
#define f first
#define s second
#define mod 998244353
ll Mod(ll x, ll y, int p) 
{ll res = 1; x = x % p;
while (y > 0) 
{if(y & 1) res = (res*x) % p; 
y = y>>1;x = (x*x) % p; 
}return res; 
}
int* getlps(string pattern){
 int len = pattern.length();
 int * lps = new int[len];
 lps[0] = 0;
 int i = 1 , j = 0;
 while(i < len){
  if(pattern[i] == pattern[j]){
	  lps[i] = j+1;
   i++;
   j++;
  }
  else{
		if(j != 0){
		 j = lps[j-1];
		}
		else{
		 lps[i] = 0;
		 i++;
		}
  }
 }
 return lps;
}
class Triplet{
 public:
 int x ;
 int y ;
 int gcd;
};
Triplet extendedEuclid(int a , int b){
 if(b == 0){Triplet ans; ans.gcd = a;ans.x = 1;ans.y = 0;return ans;}
 Triplet smallAns = extendedEuclid(b , a%b);
 Triplet ans;
 ans.gcd = smallAns.gcd;
 ans.x = smallAns.y;
 ans.y = smallAns.x - (a/b)*smallAns.y;
 return ans;
}
int mmInverse(int a , int m){
 Triplet ans = extendedEuclid(a , m);
 return ans.x;
}
int32_t main(){
ios_base::sync_with_stdio(false);
cin.tie(NULL);
string str;
cin>>str;
if(str == "AAA" || str == "BBB"){
 cout<<"No"<<endl;
}
else
cout<<"Yes"<<endl;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
#define dgt 50
using namespace std;
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n;
  long long k;
  cin >> n >> k;
  vector<long long> a(n);
  vector<int> mul(dgt + 1, 0);
  for (int i = 0; i < n; i++) {
    long long tmp;
    cin >> tmp;
    a[i] = tmp;
  }
  for (int p = 0; p <= dgt; p++) {
    for (int i = 0; i < n; i++) {
      mul[p] += a[i] & 1LL;
      a[i] /= 2LL;
    }
  }
  long long ans = 0;
  for(int crr = dgt; crr >= 0; crr--) {
    long long times = 1LL << crr;
    if (!(k & times)) {
      ans += times * mul[crr];
    } else {
      if (mul[crr] < n - n / 2) {
        ans += times * (n - mul[crr]);
        k -= times;
      } else {
        ans += times * mul[crr];
        k = times - 1;
      }
    }
  }
  cout << ans << '\n';
  return 0;
}

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

using namespace std;
using ll = long long;

void FastIO ()
{
  cin.tie(0);
  cout.tie(0);
  ios_base::sync_with_stdio(false);
}

int main ()
{
  FastIO();
  
  ll x;
  cin >> x;
  
  ll ans = x/500 * 1000;
  x %= 500;
  
  cout << ans + x/5 * 5;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <algorithm>
#include <string>
#include <cmath>
#include <cstdio>
#include <iomanip>
#include <fstream>
#include <cassert>
#include <cstring>
#include <unordered_set>
#include <unordered_map>
#include <numeric>
#include <ctime>
#include <bitset>
#include <complex>
#include <chrono>
#include <random>
#include <functional>

using namespace std;

#define int long long

const int N = 5004;
const int INF = 1e18 + 239;

int dp[2][N][N];
int cdp[2][N][N];

int a[N];
int sz[N];
vector<int> g[N];

//dp[0] - pos
//dp[1] - neg

void dfs(int cur, int P) {
	sz[cur] = 1;
	vector<int> sons;
	for (auto t : g[cur]) {
		if (t != P) {
			dfs(t, cur);
			sz[cur] += sz[t];
			sons.push_back(t);
		}
	}
	for (int i = 0; i <= (int)sons.size(); i++) {
		for (int j = 0; j < sz[cur]; j++) {
			cdp[0][i][j] = INF;
			cdp[1][i][j] = INF;
		}
	}
	if (a[cur] > 0) {
		cdp[0][0][0] = a[cur];
		cdp[1][0][0] = a[cur];
	} else {
		cdp[1][0][0] = a[cur];
	}
	int psz = 1;
	for (int i = 0; i < (int)sons.size(); i++) {
		int son = sons[i];
		for (int p = 0; p < psz; p++) {
			//0
			{
				for (int n = 0; n < sz[son]; n++) {
					if (dp[0][son][n] < INF) {
						cdp[0][i + 1][p + n] = min(cdp[0][i + 1][p + n], cdp[0][i][p] + dp[0][son][n]);
					}
					if (dp[1][son][n] < 0 || dp[0][son][n] < INF) {
						cdp[0][i + 1][p + n + 1] = min(cdp[0][i + 1][p + n + 1], cdp[0][i][p]);
					}
				}
			}
			//1
			{
				for (int n = 0; n < sz[son]; n++) {
					cdp[1][i + 1][p + n] = min(cdp[1][i + 1][p + n], cdp[1][i][p] + dp[1][son][n]);
					if (dp[0][son][n] < INF) {
						cdp[1][i + 1][p + n] = min(cdp[1][i + 1][p + n], cdp[1][i][p] + dp[0][son][n]);
					}
					if (dp[1][son][n] < 0 || dp[0][son][n] < INF) {
						cdp[1][i + 1][p + n + 1] = min(cdp[1][i + 1][p + n + 1], cdp[1][i][p]);
					}
				}
			}
		}
		psz += sz[son];
	}
	for (int i = 0; i < sz[cur]; i++) {
		dp[0][cur][i] = cdp[0][sons.size()][i];
		dp[1][cur][i] = cdp[1][sons.size()][i];
	}
}

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

	int n;
	cin >> n;
	for (int i = 0; i < n; i++) {
		cin >> a[i];
	}
	for (int i = 0; i + 1 < n; i++) {
		int u, v;
		cin >> u >> v;
		u--;
		v--;
		g[u].push_back(v);
		g[v].push_back(u);
	}
	dfs(0, -1);
	int ans = n;
	for (int i = 0; i < n; i++) {
		if (dp[0][0][i] != INF) {
			ans = min(ans, i);
		}
	}
	for (int i = 0; i < n; i++) {
		if (dp[1][0][i] < 0) {
			ans = min(ans, i);
		}
	}
	cout << ans << '\n';
}


Measured memory_bytes: 434616
from collections import deque

N, M = map(int, input().split())
H = list(map(int, input().split()))
X = [list(map(int, input().split())) for _ in range(M)]

graph = [[] for _ in range(N + 1)]
for a, b in X:
    graph[a].append(b)
    graph[b].append(a)


ans = 0
for i in range(N):
    ans += all(H[i] > H[j - 1] for j in graph[i + 1])

print(ans)


Measured memory_bytes: 112472
#include <bits/stdc++.h>
        using namespace std;
   #define int long long
   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; }
    const int MAX =200002;
const int MOD =1000000007;

     signed main(){
        int n;
        cin>>n;
        cout<<n/3<<endl;
        



   }
     


 


 






    





      

        


Measured memory_bytes: 3600
#include <iostream>
#include <cstring>

using namespace std;


int main()
{
    int flag=1;
    string a;
    cin>>a;
    for(int i=0;i<a.size()/2;i++)
        if(a[i]!=a[a.size()-1-i])flag=0;
    if(flag)cout<<"Yes";
    else cout<<"No";
}


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

int main(){
    int n;
    long long m;
    cin>>n>>m;
    int a,b;
    vector<int> card;
    long long num[100005]={};
    for(int i=0; i<n; i++){
        cin>>a>>b;
        vector<int>::iterator citer = find( card.begin(),card.end() , a );
        if( citer==card.end() ){
            card.push_back(a);
        }
        num[a]+=b;
    }
    sort(card.begin(), card.end());
    long long key=m;
    for(int i=0; i<card.size();i++){
         key-=num[card[i]];
        if(key<=0){
            cout<<card[i]<<endl;
            break;
        }

    }
    return 0;
}

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

int main(){
    string S,T;
    cin >> S;
    cin >> T;
    int count = 0;
    for (int i = 0; i<S.size(); i++){
        if (S.at(i)!=T.at(i)){
            count ++;
        }
    }
    cout << count << endl;
    return 0;
}

Measured memory_bytes: 3848
#include <bits/stdc++.h>
using namespace std;
#define LL long long
#define M 100005
LL A[M];
struct Node{
	LL k,b;
}B[M];
int main(){//3 673
	int n;
	cin>>n;
	for(int i=1;i<=n;i++)
		scanf("%lld",&A[i]),A[i]<<=1;
	LL res=0;
	for(int i=1;i<=n;i++)res+=((i&1)==(n&1)?1:-1)*A[i];
	LL last=res>>1;
	cout<<last<<' ';
	for(int i=2;i<=n;i++){
		LL now=A[i-1]-last;
		printf("%lld ",now);
		last=now;
	}
	return 0;
}

Measured memory_bytes: 2048
#!/usr/bin/env python3
from collections import defaultdict, Counter
from itertools import product, groupby, count, permutations, combinations
from math import pi, sqrt
from collections import deque
from bisect import bisect, bisect_left, bisect_right
from string import ascii_lowercase
from functools import lru_cache
import sys
sys.setrecursionlimit(10000)
INF = float("inf")
YES, Yes, yes, NO, No, no = "YES", "Yes", "yes", "NO", "No", "no"
dy4, dx4 = [0, 1, 0, -1], [1, 0, -1, 0]
dy8, dx8 = [0, -1, 0, 1, 1, -1, -1, 1], [1, 0, -1, 0, 1, 1, -1, -1]


def inside(y, x, H, W):
    return 0 <= y < H and 0 <= x < W


def ceil(a, b):
    return (a + b - 1) // b


def sum_of_arithmetic_progression(s, d, n):
    return n * (2 * s + (n - 1) * d) // 2


def gcd(a, b):
    if b == 0:
        return a
    return gcd(b, a % b)


def lcm(a, b):
    g = gcd(a, b)
    return a / g * b


def solve():
    A, B, C = map(int, input().split())
    if A == B or A == C or B == C:
        if A != B or A != C or B != C:
            print("Yes")
            return
    print("No")


def main():
    solve()


if __name__ == '__main__':
    main()


Measured memory_bytes: 9920
#include<bits/stdc++.h>
#define For(i,x,y) for (register int i=(x);i<=(y);i++)
#define FOR(i,x,y) for (register int i=(x);i<(y);i++)
#define Dow(i,x,y) for (register int i=(x);i>=(y);i--)
#define Debug(v) for (auto i:v) printf("%lld ",i);puts("")
#define mp make_pair
#define fi first
#define se second
#define pb push_back
#define ep emplace_back
#define siz(x) ((int)(x).size())
#define all(x) (x).begin(),(x).end()
#define fil(a,b) memset((a),(b),sizeof(a))
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pa;
typedef pair<ll,ll> PA;
typedef vector<int> poly;
inline ll read(){
    ll x=0,f=1;char c=getchar();
    while ((c<'0'||c>'9')&&(c!='-')) c=getchar();
    if (c=='-') f=-1,c=getchar();
    while (c>='0'&&c<='9') x=x*10+c-'0',c=getchar();
    return x*f;
}

const int N = 210;
int n;
ll a[N];
char s[N];

ll b[N];
inline void init(){
	For(i,0,63) b[i]=0;
}
inline bool insert(ll x){
	Dow(i,63,0) if (x&(1ll<<i)){
		if (!b[i]) return b[i]=x,1;
			else x^=b[i];
	}
	return 0;
}

inline void solve(){
	n=read();
	For(i,1,n) a[i]=read();
	scanf("%s",s+1);
	init();
	Dow(i,n,1) if (s[i]=='0'){
		insert(a[i]);
	} else if (insert(a[i])) return puts("1"),void(0);
	puts("0");
}

int main(){
	int T=read();
	while (T--) solve();
}

Measured memory_bytes: 3704
#include<cstdio>
#include<ctype.h>
#include<iostream>

using namespace std;

int main(){
    int temp;
    int ans=0;
    char a[1000];
    for(int i=0;i<1000;i++){
        scanf("%c",&a[i]);
        if(a[i]=='\n'){
            temp=i-1;
            break;
        }
    }
    for(int i=temp;i>=0;i--){
        printf("%c",a[i]);
    }
    printf("\n");
    return 0;
}

Measured memory_bytes: 1100