akhauriyash/Code-Regression huggingface dataset:
/*
?????????: Graph I - Breadth First Search
URL: http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=ALDS1_11_C
?????°
19:08 ??°?????????????????????????????£??¨??????????????????????????§???????????????????????£?????????
19:08 ???????????\????????\????????°??????????????????????¢????
19:09 ????????°???????????????????§£
19:13 ??¨???????????????????????£???
19:19 BFS????¨???¶???????¶??????????????????§??¨?????????????????????????????????
19:28 ???????????????????§?????????????????????£????????§????????????????????????????????????????????§????????????????????£????????????
19:29 ?????????????????????????????????????????? 1 ????????????????????????????????????????????????????????¢??¨??????-1 ?????????????????????????????????
*/
#include <iostream>
#include <vector>
#include <set>
#include <queue>
#define INF 114514
using namespace std;

int main()
{
	int n; cin>>n;
	vector< set<int> > graphdat(n+1);  
	for(int i=0;i<n;i++){
		int u; int k; cin >> u >> k;
		set<int> v;
		for(int j=0;j<k;j++){
			int tmp;
			cin >> tmp;
			v.insert(tmp);
		}
		graphdat[u] = v;
	}

	vector<int> distance(n+1);
	distance[1] = 0;
	for(int i=2;i<=n;i++){
		distance[i] = INF;
	}

	queue<int> Q;
	Q.push(1);

	while(!Q.empty()) {
		int cur = Q.front();
		Q.pop(); // pop?????????????????????????????¨?¬???\??§??????
		for(int dest=1; dest<=n; dest++) {
			if(graphdat[cur].find(dest) != graphdat[cur].end()) { // ??????????????????
				if(distance[dest] > distance[cur] + 1) { // ??´??°??§????????????
					distance[dest] = distance[cur] + 1;
					Q.push(dest);
				}
			}
		}
	}

	for(int i=1;i<=n;i++){
		cout << i << " " << (distance[i] == INF ? -1 : distance[i])<< endl;
	}

}

Measured memory_bytes: 3112
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int m = sc.nextInt();
		for(int i=0; i<m; i++) {
			n -= sc.nextInt();
			if(n<0) {
				System.out.println("-1");
				return;
			}
		}
		System.out.println(n);

	}

}


Measured memory_bytes: 46364
import java.util.Scanner;
public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int a = sc.nextInt();
    int b = sc.nextInt();
    if(a>9 || b>9) System.out.println(-1);
    else System.out.println(a*b);
  }

}

Measured memory_bytes: 25172
import java.util.Scanner;

class Main {

	public static void main(String[] args) {
		int place[]=new int[5];
		Scanner sc = new Scanner(System.in);
		int min;
		
		for(int i=0; i<5; i++){
			place[i]=sc.nextInt();
		}
		
		int minp=place[0];
		
		for(int i=1; i<3; i++){
			if(minp>place[i]) minp=place[i];
		}
		
		
		if(place[3]<place[4]){
			min=place[3];
		}
		else{ 
			min=place[4];
		}
		
		System.out.println(min+minp-50);

	}

}

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

int dp[100005];

int main(){
    int n,k,s;
    cin>>n>>k;

    int arr[n];

    for(int i=0;i<n;i++)
        cin>>arr[i];


    dp[0]=0;
    if(n==1)
        cout<<0<<endl;

    else{

        dp[1]=abs(arr[1]-arr[0]);

        for(int i=2;i<n;i++){
           s=INT_MAX;
           if(k>i)
           {
               for(int j=i-1;j>=0;j--){
                  dp[i]=min(s,dp[j]+abs(arr[i]-arr[j]));

                  if(dp[j]+abs(arr[i]-arr[j])<s)
                     s=dp[j]+abs(arr[i]-arr[j]);
               }
           }

           else{

                 for(int j=i-1;j>=i-k;j--){

                  dp[i]=min(s,(dp[j]+abs(arr[i]-arr[j])));

                  if(dp[j]+abs(arr[i]-arr[j])<s)
                     s=dp[j]+abs(arr[i]-arr[j]);


               }

           }


        }


    }

    cout<<dp[n-1]<<endl;
    return 0;



}


Measured memory_bytes: 1024
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <cstdlib>
#include <vector>
#include <map>
#include <queue> 
#include <stack>
#include <set>

using namespace std;
typedef long long ll;
#define rep(i, s, e) for (int(i) = (s); (i) <= (e); ++(i))
#define all(x) x.begin(),x.end()


int main()
{
	ll l, r; cin >> l >> r;
	ll ans = 2019;
	if (r - l + 1 >= 2019)
	{
		cout << 0 << endl;
	}
	else if (l == 0)
	{
		cout << 0 << endl;
	}
	else
	{
		rep(i, l, r - 1)rep(j, i + 1, r)
		{
			ll x = i;
			ll y = j;
			ans = min(ans, x*y % 2019);
		}
		cout << ans << endl;
	}
}

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

#define ll          long long
#define pb          push_back
#define pii         pair<int,int>
#define pll         pair<long,long>
#define vi          vector<int>
#define vll         vector<ll>
#define vii         vector<pii>
#define Mi          map<int,int>
#define mii         map<pii,int>
#define all(a)      (a).begin(),(a).end()
#define rall(a)      (a).rbegin(),(a).rend()
#define x           first
#define y           second
#define sz(x)       (int)x.size()
#define endl        '\n'
#define mod        1000000007
#define rep(i,a,b)  for(int i=a;i<b;i++)
#define rem(i,a,b)  for(int i=a;i>b;i--)
#define mp(a,b)     make_pair(a,b)
#define vvi(a,b,name)    vector<vector<int>> name(a,vector<int>(b,-1))




void solve(){
    int n,k;cin>>n>>k;
    vi l;
    rep(i,0,n){
        int temp;
        cin>>temp;
        l.pb(temp);
    }
    sort(rall(l));
    int ans=0;
    rep(i,0,k)ans+=l[i];
    cout<<ans;

}

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    long t=1;
    //cin>>t;

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


Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
int main(){
  int N;
  cin >> N;
  int count=1;
  if(N<105){
    cout << 0 << endl;
    return 0;
  }
  else if(N==105){
    cout << 1 << endl;
    return 0;
  }
  else{
    for(int i=106;i<=N;i++){
      int cnt=0;
      for(int j=1;j<=i;j++){
        if(i%2==1&&i%j==0){
          cnt++;
            if(cnt==8){
               count++;
          }
        }
      }
    }
    cout << count << endl;
    return 0;
  }
}
      


Measured memory_bytes: 256
#include <bits/stdc++.h>
typedef long long ll;
#define rep(i, n) for (ll i = 0; i < (ll)n; ++i)
const int MOD = 1000000007;
using namespace std;
void solve(void)
{
    int a1, a2, a3;
    cin >> a1 >> a2 >> a3;
    int x = max(a1, max(a2, a3));
    int y = min(a1, min(a2, a3));
    cout << abs(x - y) << endl;
}
int main(void)
{
    solve();
}

Measured memory_bytes: 3580
#include <iostream>
#include <algorithm>

using namespace std;

int main() {
    u_long N, *d, answer;

    // input
    cin >> N;
    d = new u_long[N];
    for (int i = 0; i < N; i++) {
        cin >> d[i];
    }

    // process
    sort(d, d + N);

    answer = d[(N / 2)] - d[(N / 2) - 1];

    // output
    cout << answer << endl;
    return 0;
}


Measured memory_bytes: 1024
import sys
from bisect import bisect_right,bisect_left
read=sys.stdin.read
readline=sys.stdin.readline

def main():
    n=int(readline())
    a,b,c=(list(map(int,lst.split())) for lst in read().splitlines())
    a.sort()
    b.sort()
    c=[-x for x in c]
    c.sort()
    print(sum(bisect_left(a,x)*bisect_left(c,-x) for x in b))

if __name__=='__main__':
    main()
      
      


Measured memory_bytes: 31560
#include<bits/stdc++.h>
using namespace std;
#define rep(i,N) for(int (i)=0;(i) < (N); (i)++)
using i64 = int64_t;
using P = pair<i64,i64>;


int main(){
    int N,M;
    cin >> N >> M;
    priority_queue<vector<P>,vector<P>,greater<P>> que;
    map<int,int> mp;
    rep(i,N){
        int a;
        cin >> a;
        mp[a]++;
    }

    for(auto& p : mp) {
        que.push({p.first,p.second});
    }

    rep(i,M){
        int b,c;
        cin >> b >> c;

        int cnt = 0;

        while(b){
            P p = que.top();
            if(p.first >= c) break;

            que.pop();
            if(p.second > b){
                p.second -= b;
                cnt += b;
                b = 0;
                que.push({p.first,p.second});
            } else {
                b -= p.second;
                cnt += p.second;
            }
        }
        que.push({c,cnt});
    }

    int64_t ans = 0;
    while(!que.empty()){
        P p = que.top();
        ans += p.first*p.second;
        que.pop();
    }

    cout << ans << endl;
}


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

def readInts():
  return [int(s) for s in input().split(" ")]

def main():
  N = readInts()[0]
  V = readInts()
  V.sort()

  ans = V[0]
  for i in range(0, N):
    ans = (ans + V[i]) / 2
  print(ans)

if __name__ == "__main__":
  main()


Measured memory_bytes: 3060
using System;
using System.Linq;
using System.Collections.Generic;
using static System.Console;
using System.Text;
using System.IO;

namespace AOJ
{
    class Program
    {
        static public long[] Sarray() { return ReadLine().Split().Select(long.Parse).ToArray(); }
        static public List<long> Slist() { return ReadLine().Split().Select(long.Parse).ToList(); }

        class node
        {
            public List<long> ko = new List<long>();
            public long oya = -1;
        }
        static void Main(string[] args)
        {
            var N = Sarray()[0];
            var preorder = Sarray();
            var inorder = Sarray();
            var nodes = new node[N];
            var ans = new List<long>();

            Action<long, long, long, long> recon = null;
            recon = (prel, prer, inl, inr) =>
              {
                  //WriteLine($"({prel},{prer}),({inl},{inr})");
                  if (prer <= prel)
                      return;
                  if (inr <= inl)
                      return;
                  /*for (var i = prel; i < prer; ++i)
                  {
                      Write($"{preorder[i]},");
                  }
                  WriteLine();
                  for (var i = inl; i< inr; ++i)
                  {
                      Write($"{inorder[i]},");
                  }
                  WriteLine("\n");*/
                  //preでルート(preroot)を見つける
                  var preroot = prel;
                  //inでprerootに対応するもの(inroot)を見つける
                  var inroot = -1L;
                  for (var i = inl; i < inr; ++i)
                      if (preorder[preroot] == inorder[i])
                          inroot = i;
                  //preでinroot+1に対応するもの(preright)を見つける
                  var preright = preroot + (inroot - inl) + 1;
                  //(preroot,preright)がleft、残りがright
                  recon(preroot + 1, preright, inl, inroot);
                  //inの[,inroot)と(preroot,preright)で同じことを繰り返す
                  recon(preright, prer, inroot + 1, inr);
                  //WriteLine(preorder[preroot]);
                  ans.Add(preorder[preroot]);
              };
            recon(0, N, 0, N);
            WriteLine(string.Join(" ", ans));
        }
    }
}


Measured memory_bytes: 20472
/*******Bismillahir-Rahmanir-Rahim**********/
/*
Name         : Abu Rifat Muhammed Al Hasib
Institution  : University of Barisal, Bangladesh
Github       : abu-rifat
Codeforces   : AbuRifatMuhammed
AtCoder      : aburifat
codechef     : aburifat
SPOJ         : abu_rifat
UvaOJ        : aburifat
DevSkill     : abu_rifat
lightoj      : Abu Rifat Muhammed Al Hasib
facebook     : https://www.facebook.com/a.r.m.al.hasib/
linkedin     : https://www.linkedin.com/in/abu-rifat-534258142/
Email        : rifat.cse4.bu@gmail.com, armalhasib@gmail.com
*/

/*
Contest         : Beginner Contest 158
Online Judge    : AtCoder
Solving Method  :
*/

#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define MX 250009
#define pb push_back


int main()
{
    //freopen("input.txt","r",stdin);
    //freopen("output.txt","w",stdout);
    ll t;
    t=1;
    //cin>>t;
    for(ll T=1;T<=t;T++)
    {
        string s;
        cin>>s;
        map<char,ll>m;
        for(ll i=0; i<s.size();i++){
            m[s[i]]++;
        }
        if(m['A']==0|m['B']==0){
            cout<<"No"<<endl;
        }else{
            cout<<"Yes"<<endl;
        }
    }
    return 0;
}

/***********Alhamdulillah***********/



Measured memory_bytes: 256
#include <bits/stdc++.h>
#define int long long
#define rng(i, l, r) for (size_t i = (l); i < (r); ++i)
#define rep(i, n) rng(i, 0, n)
#define gnr(i, l, r) for (size_t i = (r)-1; i >= (l); i--)
#define per(i, b) gnr(i, 0, b)
#define ALL(obj) (obj).begin(), (obj).end()    //1,2,3,...
#define rALL(obj) (obj).rbegin(), (obj).rend() //...,3,2,1

using namespace std;

const int INF = 1e18;

int mp[10][10];
int minMP[10][10];
void warshallFloyd()
{
    rep(i, 10) rep(j, 10) minMP[i][j] = INF;
    for (int k = 0; k < 10; k++)
    {
        for (int i = 0; i < 10; i++)
        {
            for (int j = 0; j < 10; j++)
            {
                mp[i][j] = min(mp[i][j], mp[i][k] + mp[k][j]);
            }
        }
    }
}

void solve()
{

    // remove the bottom 3 lines when you submit this code.
    std::ifstream in("./sample.txt");
    std::cin.rdbuf(in.rdbuf());

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

    int H, W;
    cin >> H >> W;
    rep(i, 10) rep(j, 10) cin >> mp[i][j];

    int wall[210][210];
    rep(h, H) rep(w, W) cin >> wall[h][w];

    warshallFloyd();

    int ans = 0;
    rep(h, H)
    {
        rep(w, W)
        {
            if (wall[h][w] == -1)
                continue;
            ans += mp[wall[h][w]][1];
        }
    }

    cout << ans << endl;
}

signed main()
{
    solve();
    return 0;
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()
#define rep(i,n) for (int i=0;i<(int)(n);i++)
#define codefor int test;scanf("%d",&test);while(test--)
#define yn(ans) if(ans)printf("Yes\n");else printf("No\n")
#define YN(ans) if(ans)printf("YES\n");else printf("NO\n")
#define umap unordered_map
#define uset unordered_set
using namespace std;
using ll = long long;
const int MOD=1000000007;
//入力系
void scan(int& a){scanf("%d",&a);}
void scan(long long& a){scanf("%lld",&a);}
template<class T> void scan(T& a){cin>>a;}
template<class T> void scan(vector<T>& vec){for(auto&& it:vec)scan(it);}
void in(){}
template <class Head, class... Tail> void in(Head& head, Tail&... tail){scan(head);in(tail...);}
//出力系
void print(const int& a){printf("%d",a);}
void print(const long long& a){printf("%lld",a);}
void print(const double& a){printf("%.15lf",a);}
template<class T> void print(const T& a){cout<<a;}
template<class T> void print(const vector<T>& vec){if(vec.empty())return;print(vec[0]);for(auto it=vec.begin();++it!= vec.end();){putchar(' ');print(*it);}}
void out(){putchar('\n');}
template<class T> void out(const T& t){print(t);putchar('\n');}
template <class Head, class... Tail> void out(const Head& head,const Tail&... tail){print(head);putchar(' ');out(tail...);}
//デバッグ系
template<class T> void dprint(const T& a){cerr<<a;}
template<class T> void dprint(const vector<T>& vec){if(vec.empty())return;cerr<<vec[0];for(auto it=vec.begin();++it!= vec.end();){cerr<<" "<<*it;}}
void debug(){cerr<<endl;}
template<class T> void debug(const T& t){dprint(t);cerr<<endl;}
template <class Head, class... Tail> void debug(const Head& head, const Tail&... tail){dprint(head);cerr<<" ";debug(tail...);}

int main(){
    int n,k,r,s,p;
    string t;
    in(n,k,r,s,p,t);
    vector<bool> win(n,false);
    ll ans=0;
    for(int i=0;i<n;i++){
        //debug(t[i]);
        if(t[i]=='r'){
            if(i-k>=0&&t[i-k]=='r'&&win[i-k])continue;
            ans+=(ll)p;
            win[i]=true;
        }
        if(t[i]=='s'){
            if(i-k>=0&&t[i-k]=='s'&&win[i-k])continue;
            ans+=(ll)r;
            win[i]=true;
        }
        if(t[i]=='p'){
            if(i-k>=0&&t[i-k]=='p'&&win[i-k])continue;
            ans+=(ll)s;
            win[i]=true;
        }
    }
    out(ans);
}


Measured memory_bytes: 3940
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<int, int>;
ll INF = 1e10;
int main()
{
    ll n, c, k;
    cin >> n >> c >> k;
    vector<int> t(n);
    for(int i = 0; i < n; i++) cin >> t[i];
    sort(t.begin(), t.end());
    priority_queue<ll, vector<ll>, greater<ll>> que;
    que.push(t[0]);
    ll ans = 0;
    for(int i = 1; i < n; i++)
    {
        ll now = t[i];
        que.push(now);
        while(que.size() && que.top() + k <= now)
        {
            ll bus = que.top() + k;
            ll loop = min(ll(que.size()), c);
            while(loop-- && que.top() <= bus) que.pop();
            ans++;
        }
    }
    if(que.size()) ans += (que.size()-1)/c + 1;
    cout << ans << endl;
}



Measured memory_bytes: 640
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <utility>
#include <tuple>
#include <cstdint>
#include <cstdio>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <deque>
#include <unordered_map>
#include <unordered_set>
#include <bitset>
#include <cctype>
#include <functional>
#include <ctime>
#include <cmath>
#include <limits>
#include <numeric>
#include <type_traits>
#include <iomanip>
#include <float.h>
#include <math.h>
using namespace std;
using ll = long long;


unsigned euclidean_gcd(unsigned a, unsigned b) {
    if (a < b) return euclidean_gcd(b, a);
    unsigned r;
    while ((r = a % b)) {
        a = b;
        b = r;
    }
    return b;
}

class UnionFind {
public:
    vector <ll> par;
    vector <ll> siz;
    UnionFind(ll sz_) : par(sz_), siz(sz_, 1LL) {
        for (ll i = 0; i < sz_; ++i) par[i] = i;
    }
    void init(ll sz_) {
        par.resize(sz_);
        siz.assign(sz_, 1LL);
        for (ll i = 0; i < sz_; ++i) par[i] = i;
    }
    ll root(ll x) {
        while (par[x] != x) {
            x = par[x] = par[par[x]];
        }
        return x;
    }
    bool merge(ll x, ll y) {
        x = root(x);
        y = root(y);
        if (x == y) return false;
        if (siz[x] < siz[y]) swap(x, y);
        siz[x] += siz[y];
        par[y] = x;
        return true;
    }

    bool issame(ll x, ll y) {
        return root(x) == root(y);
    }

    ll size(ll x) {
        return siz[root(x)];
    }
};

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

long long modinv(long long a, long long mod) {
    return modpow(a, mod - 2, mod);
}

int main() {
    ll n, p;
    string s;
    cin >> n >> p >> s;
    ll ans = 0;
    if (p == 2 || p==5) {
        for (int i = 0; i < n; i++) {
            if ((s[i] - '0') % p == 0)ans += i + 1;
        }
        cout << ans << endl;
    }
    else {
        ll now = 0;
        vector<ll> z(p);
        z[0]++;
        for (int i = n-1; i > -1; i--) {
            now = ((s[i] - '0')*modpow(10,n-1-i,p) + now);
            now %= p;
            z[now]++;
        }
        for (int i = 0; i < p; i++) {
            ans += z[i] * (z[i] - 1) / 2;
        }
        cout << ans << endl;
    }
}

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

using namespace std;

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

	int count = 0;
	for (int i = 1; i < S.size(); i++){
		if(S[i-1] != S[i]){
			count++;
		}
	}

	cout << count << endl;
	return 0;
}


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

#define MP make_pair
#define PB push_back
#define ALL(x)      (x).begin(),(x).end()
#define REP(i,n)    for(int i=0;i<(n);i++)
#define REP1(i,n)   for(int i=1;i<(n);i++)
#define REP2(i,d,n) for(int i=(d);i<(n);i++)
#define RREP(i,n)   for(int i=(n);i>=0;i--)
#define CLR(a)      memset((a),0,sizeof(a))
#define MCLR(a)     memset((a),-1,sizeof(a))
#define RANGE(x,y,maxX,maxY) (0 <= (x) && 0 <= (y) && (x) < (maxX) && (y) < (maxY))

typedef long long LL;
typedef unsigned long long ULL;
typedef vector<int> VI;
typedef vector<VI > VVI;
typedef vector<string> VS;
typedef vector<LL> VLL;
typedef pair<int,int> PII;

const int INF = 0x3f3f3f3f;
const LL INFL = 0x3f3f3f3f3f3f3f3fLL;
const double EPS = 1e-9;

const int DX[]={1,0,-1,0},DY[]={0,-1,0,1};


void solve(long long N, std::string S){
    LL ans = 1;
    REP(i, N-1) {
        if(S[i] != S[i+1]) ans++;
    }

    cout << ans << endl;
}

int main(){
    long long N;
    scanf("%lld",&N);
    std::string S;
    std::cin >> S;
    solve(N, S);
    return 0;
}


Measured memory_bytes: 512
#include<bits/stdc++.h>
#define boost ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define ll long long int
#define mem(a,b) memset(a,b,sizeof(a))
#define endl "\n"
#define mod 1000000007
#define PI 3.1415926535897932384626
#define pq priority_queue
#define pb push_back
#define mp make_pair
using namespace std;
/*
int gcd(int x,int y)
{
    if(x%y==0)
    return y;
    return gcd(y,x%y);
}

int no1(int x)
{
    int count=0;
    while(x)
    {
        if(x%2)
        count++;
        x=x>>1;
    }
    return count;
}
ll power(int  b,int p)
{
    if(p==0)
    return 1;
    ll temp=power(b,p/2);
    temp=temp*temp;
    if(p%2==1)

    temp=temp*b;
    return temp;
}
bool cmp(const pair<int, pair<int,int> > & p1,const pair<int, pair<int,int> > & p2)
{
    if(p1.first>p2.first)
        return true;
    if(p1.first==p2.first&&p1.second.first<p2.second.first)
        return true;
    return false;
}
*/
int jump(int i,int h[],int dp[],int n)
{
    if(i==n-1)
        return 0;
    if(i==n-2)
        return abs(h[n-1]-h[n-2]);
    if(dp[i]!=-1)
        return dp[i];
    dp[i]=min(abs(h[i]-h[i+1])+jump(i+1,h,dp,n),abs(h[i+2]-h[i])+jump(i+2,h,dp,n));
    return dp[i];
}
int main()
{
    int n;
    int h[100005];
    cin>>n;
    for(int i=0;i<n;i++)
        cin>>h[i];
    int dp[100005];
    for(int i=0;i<100005;i++)
        dp[i]=-1;
    cout<<jump(0,h,dp,n);
    return 0;

}


Measured memory_bytes: 4992
s = input()
n = len(s) // 2 + 1
l1 = "01" * n
l2 = "10" * n
a1 = 0
a2 = 0
for i in range(len(s)):
    if l1[i] != s[i]:
        a1 += 1
    if l2[i] != s[i]:
        a2 += 1
    
print(min(a1, a2))

Measured memory_bytes: 3316
#[allow(unused_macros)]
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

fn main() {
    input!{
        n: i32,
    }
    for i in 0..10 {
        for j in 0..10 {
            if i * j == n {
                println!("Yes");
                return;
            }
        }
    }
    println!("No");
}


Measured memory_bytes: 4476
# coding: utf-8
# Your code here!
n = int(input())

S=[input() for i in range(n)]
ac=0
tle=0
wa=0
re=0
for i in range(n):
    if(S[i] == 'AC'):
        ac = ac+1
    if(S[i]=='TLE'):
        tle=tle+1
    if(S[i]=='WA'):
        wa=wa+1
    if(S[i]=='RE'):
        re=re+1



print("AC x",ac)
print("WA x",wa)
print("TLE x",tle)
print("RE x",re)


Measured memory_bytes: 16324
#include <stdio.h>

int main(void) {
int cnt, a,b,tmp;
//cnt=0;
scanf("%d %d\n",&a,&b);
while((a!=0)||(b!=0)){
//cnt++;
if(a<b){
printf("%d %d\n", a,b);
}else{
printf("%d %d\n", b,a);
}
scanf("%d %d\n",&a,&b);
}
return 0;
}

Measured memory_bytes: 604
#include <algorithm>
#include <iomanip>
#include <iostream>
#include <string>
#include <vector>

std::string solve(int n, const std::vector<int>& vec)
{
  for (auto v : vec) {
    if (v % 2 == 0) {
      if (v % 3 != 0 && v % 5 != 0) return "DENIED";
    }
  }
  return "APPROVED";
}

int main()
{
  int n;
  std::cin >> n;
  std::vector<int> vec(n);
  for (auto& v : vec) {
    std::cin >> v;
  }

  std::cout << std::setprecision(20) << solve(n, vec) << std::endl;
}


Measured memory_bytes: 256
# -*- coding: utf-8 -*-
#ABC144D
import sys
import math
import collections
#sys.setrecursionlimit(100000)


#n=int(input())

tmp = input().split()
a,b,x = list(map(lambda a: int(a), tmp))

#print(2*x/a/b)
#print(math.degrees(math.atan(1/1.732)))

if(a**2*b>2*x):
	print(90-math.degrees(math.atan(2*x/a/b/b)))
else:
	print(math.degrees(math.atan((a**2*b-x)*2/(a**3))))
	



Measured memory_bytes: 3440
s = input()

firstTile = s[0]
lastTile = s[-1]

def isOneColor():
    t = None
    for c in s:
        if t is None:
            t = c
        else:
            if c is not t:
                return False
    return True

def reverse(tile):
    if tile is "0":
        return "1"
    else:
        return "0"

def shouldZeroStart():
    z = 0
    o = 0
    currentTile = "0"
    for tile in s:
        if tile is not currentTile:
            z = z + 1
        currentTile = reverse(currentTile)
    currentTile = "1"
    for tile in s:
        if tile is not currentTile:
            o = o + 1
        currentTile = reverse(currentTile)
    if z < o:
        return True
    else:
        return False

result = 0
currentTile = "1"
if isOneColor():
    if firstTile is "0":
        currentTile = "0"
else:
    if shouldZeroStart():
        currentTile = "0"
for i in range(len(s)):
    if s[i] is not currentTile:
        result = result + 1
    currentTile = reverse(currentTile)



print(result)


Measured memory_bytes: 3316
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define FOR(i, a, b) for(int i=(a);i<(b);++i)
#define rep(i, n) FOR(i, 0, n)
#define rrep(i, n) for (int i = ((int)(n)-1); i >= 0; --i)
#define whole(x) (x).begin(),(x).end()
#define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end())
using P = pair<int, int>;
#define debug(var) cerr << "[" << #var << "] " << var << endl
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
const ll mod = 1000000007;
const int dx[] = {-1,0,1,0};
const int dy[] = {0,-1,0,1};


int main(){
    int n;
    cin >> n;
    vector<ll> a(n);
    rep(i, n) cin >> a[i];
    sort(whole(a));
    reverse(whole(a));
    ll ans = 0;
    rep(i, n) {
        if (i==0) continue;
        ans += a[i/2];
    }
    
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 4844
package main

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

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

func main() {
	N := readI()
	K := readI()
	p := readIs(N)
	sort.Ints(p)
	var ans int
	for i := 0; i < K; i++ {
		ans += p[i]
	}
	fmt.Println(ans)
}

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

var sc = bufio.NewScanner(os.Stdin)

func init() {
	if flag.Parse(); flag.Arg(0) == "debug" {
		debug()
	}
	const maxBuf = 200100
	var buf []byte = make([]byte, maxBuf)
	sc.Split(bufio.ScanWords)
	sc.Buffer(buf, maxBuf)
}

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

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

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

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

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

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

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

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

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

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

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

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


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

ll a[100001];


int main(){
    int n;
    int q;
    ll b,c;
    ll sum=0;
    cin>>n;
    int temp;
    for(int i=0;i<n;++i){
        cin>>temp;
        sum=sum+temp;
        a[temp]++;
    }
    cin>>q;
    while(q--){
        cin>>b>>c;
        ll count=a[b];
        sum = sum-(count*b);
        a[b]=0;
        a[c]=a[c]+count;
        sum = sum+(count*c);
        cout<<sum<<endl;
    }
    
    
    return 0;
}

Measured memory_bytes: 4388
#include<bits/stdc++.h>
#define int long long
using namespace std;

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

    int ans = 0;
    for(int i=1 ; i<n ; i++){
       if(a[i]<a[i-1]){
          int x = abs(a[i]-a[i-1]);
          ans += x;
          a[i] = max(a[i],a[i-1]);
       }
    }
       cout<<ans;
}

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

using namespace std;
using ll = long long;
// #define int ll
using PII = pair<ll, ll>;

#define FOR(i, a, n) for (ll i = (ll)a; i < (ll)n; ++i)
#define REP(i, n) FOR(i, 0, n)
#define ALL(x) x.begin(), x.end()

template<typename T> T &chmin(T &a, const T &b) { return a = min(a, b); }
template<typename T> T &chmax(T &a, const T &b) { return a = max(a, b); }
template<typename T> bool IN(T a, T b, T x) { return a<=x&&x<b; }
template<typename T> T ceil(T a, T b) { return a/b + !!(a%b); }

template<typename T> vector<T> make_v(size_t a) { return vector<T>(a); }
template<typename T,typename... Ts>
auto make_v(size_t a,Ts... ts) {
  return vector<decltype(make_v<T>(ts...))>(a,make_v<T>(ts...));
}
template<typename T,typename V> typename enable_if<is_class<T>::value==0>::type
fill_v(T &t, const V &v) { t=v; }
template<typename T,typename V> typename enable_if<is_class<T>::value!=0>::type
fill_v(T &t, const V &v ) { for(auto &e:t) fill_v(e,v); }

template<class S,class T>
ostream &operator <<(ostream& out,const pair<S,T>& a){
  out<<'('<<a.first<<','<<a.second<<')'; return out;
}
template<typename T>
istream& operator >> (istream& is, vector<T>& vec){
  for(T& x: vec) {is >> x;} return is;
}
template<class T>
ostream &operator <<(ostream& out,const vector<T>& a){
  out<<'['; for(T i: a) {out<<i<<',';} out<<']'; return out;
}

int dx[] = {0, 1, 0, -1}, dy[] = {1, 0, -1, 0}; // DRUL
const int INF = 1<<30;
const ll LLINF = 1LL<<60;
const ll MOD = 1000000007;

struct UnionFind {
  vector<int> par, s;
  UnionFind(int n=2e5) { init(n); }
  void init(int n) { 
    s.assign(n, 1); par.resize(n); 
    iota(par.begin(), par.end(), 0);
  }
  int find(int x) {
    if(par[x] == x) return x;
    return par[x] = find(par[x]);
  }
  void unite(int x, int y) {
    x = find(x);
    y = find(y);
    if(x == y) return;
    if(s[x] < s[y]) par[x] = y, s[y] = s[x] + s[y];
    else par[y] = x, s[x] = s[x] + s[y];
  }
  bool same(int x, int y) { return find(x) == find(y); }
  int size(int x) { return s[find(x)]; }
};

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

  ll n, d;
  cin >> n >> d;
  vector<ll> a(n);
  REP(i, n) cin >> a[i];

  vector<vector<PII>> g(2*n);
  // i <-> i+n
  REP(i, n) {
    g[i].push_back({i+n, a[i]});
    g[i+n].push_back({i, a[i]});
  }
  // i <-> i+1
  REP(i, n-1) {
    g[n+i].push_back({n+i+1, d});
    g[n+i+1].push_back({n+i, d});
  }
  // グラフに色を塗って全域木の候補の辺を特定
  ll ret = 0;
  vector<ll> dist(2*n, INF), col(2*n, -1);
  struct node {
    ll dist, vertex, col;
    node() {}
    node(ll a, ll b, ll c) : dist(a), vertex(b), col(c) {}
    bool operator<(node nd) const { return dist > nd.dist; }
  };
  priority_queue<node> que;
  REP(i, n) que.push(node(0, i, i));
  while(que.size()) {
    node p = que.top(); que.pop();
    if(dist[p.vertex] == INF) {
      dist[p.vertex] = p.dist;
      col[p.vertex] = p.col;
      for(auto to: g[p.vertex]) {
        que.push(node(p.dist+to.second, to.first, p.col));
      }
    } else {
      if(p.col != col[p.vertex]) {
        ret += dist[p.vertex] + p.dist;
      }
    }
  }
  cout << ret/2 << endl;

  return 0;
}

Measured memory_bytes: 59756
def slove():
    import sys
    import collections
    input = sys.stdin.readline
    s = collections.Counter(list(str(input().rstrip('\n'))))
    for k, v in s.items():
        if v != 1:
            print("no")
            exit()
    print("yes")


if __name__ == '__main__':
    slove()


Measured memory_bytes: 38384
#include "iostream"
#include "climits"
#include "list"
#include "queue"
#include "stack"
#include "set"
#include "functional"
#include "algorithm"
#include "string"
#include "map"
#include "unordered_map"
#include "unordered_set"
#include "iomanip"
#include "cmath"
#include "random"
#include "bitset"
#include "cstdio"
#include "numeric"
#include "cassert"
#include "ctime"

using namespace std;

//constexpr long long int MOD = 1000000007;
//constexpr int MOD = 1000000007;
//constexpr int MOD = 998244353;
constexpr long long int MOD = 998244353;
constexpr long double EPS = 1e-8;

long long int N, M, K, L, R, H, W;
//int N, M, K, L, R, H, W;

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

	cin >> N >> M;
	/*
	vector<vector<vector<int>>>dp(N * 3 + 1, vector<vector<int>>(N * 2 + 1, vector<int>(N + 1)));
	dp[0][0][N] = 1;
	for (int i = 0; i < N * 3; i++) {
		for (int j = 0; j <= N * 2; j++) {
			for (int l = 0; l <= N; l++) {
				for (int k = -2; k <= 1; k++) {
					if (j + k<0 || j + k>N * 2)continue;
					if (k < 0 && l == 0)continue;
					int by = 1;
					if (k == -1) {
						by = j;
					}
					if (k == -2) {
						by = j * (j - 1);
					}
					if(k < 0) {
						dp[i + 1][j + k][l - 1] += 1LL*dp[i][j][l] * by%M;
						dp[i + 1][j + k][l - 1] %= M;
					}
					else {
						dp[i + 1][j + k][l] += dp[i][j][l];
						dp[i + 1][j + k][l] %= M;
					}
				}
			}
		}
	}

	cout << accumulate(dp.back().front().begin(),dp.back().front().end(),0LL)%M << endl;
	*/

	vector<vector<long long int>>dp(3 * N + 1, vector<long long int>(N + 1));
	dp[3 * N][N] = 1;
	for (int i = 3 * N; i > 0; i--) {
		for (int j = 0; j <= N; j++) {
			dp[i - 1][j] += dp[i][j];
			dp[i - 1][j] %= M;
			if (i > 1 && j) {
				dp[i - 2][j - 1] += dp[i][j] * (i - 1);
				dp[i - 2][j - 1] %= M;
			}
			if (i > 2 && j) {
				dp[i - 3][j - 1] += dp[i][j] * (i - 1) % M*(i - 2);
				dp[i - 3][j - 1] %= M;
			}
		}
	}
	cout << accumulate(dp.front().begin(), dp.front().end(), 0LL) % M << endl;
}

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

#define ll long long
#define vi vector<int>
#define pb push_back
//#define unordered_map<int,int> um

int  main(){


     int f=0;
    string str;
    cin>>str;
    
    string temp2="";
    string temp3="";
    string s1="";
    string temp1=str;
    reverse(str.begin(),str.end());
    
    if(temp1==str){
    	int n=str.size();
    	int l=(n-1)/2;
    	for(int i=0;i<l;i++)
    	   s1+=temp1[i];
    	
    	string temp2=s1;
    	reverse(s1.begin(),s1.end());
    	 //cout<<s1<<" "<<temp2<<endl;
    	string s2="";
    	if(s1==temp2){
    		int m=(n+3)/2;
    		for(int j=m-1;j<n;j++){
    		     s2+=temp1[j];	
    		}
    		// cout<<s2;
    		temp3=s2;
    		reverse(s2.begin(),s2.end());
    		if(temp3==s2)
    		 f=1;
    		
    	}
    }
    	
    	if(f==1)cout<<"Yes"<<endl;
    	else
    	 cout<<"No"<<endl;
    
    return 0;	
}

Measured memory_bytes: 256
N = int(input())
b = list(map(int,input().split()))
a = []

flag = True
for i in range(N):
    if i+1 < b[i]:
        flag = False
if not flag:
    print(-1)
else:
    while True:
        if len(b) ==  0:
            break
        m = 0
        for j in range(len(b)):
            if b[j] == j+1:
                m = max(m,j)
        a.append(m+1)
        b.pop(m)

    for i in reversed(range(N)):
        print(a[i])


Measured memory_bytes: 38896
#include <stdio.h>
int a[6], q, s, t, u, v;
const int r[6][6] = {
	{ 7, 2, 4, 1, 3, 7 },
	{ 3, 7, 0, 5, 7, 2 },
	{ 1, 5, 7, 7, 0, 4 },
	{ 4, 0, 7, 7, 5, 1 },
	{ 2, 7, 5, 0, 7, 3 },
	{ 7, 3, 1, 4, 2, 7 }
};
int main() {
	for(int i = 0; i < 6; i++) scanf("%d", &a[i]);
	scanf("%d", &q);
	for(int i = 0; i < q; i++) {
		scanf("%d%d", &s, &t);
		for(int j = 0; j < 6; j++) {
			if(a[j] == s) u = j;
			if(a[j] == t) v = j;
		}
		printf("%d\n", a[r[u][v]]);
	}
	return 0;
}

Measured memory_bytes: 2700
#include <bits/stdc++.h>
using namespace std;
int main(){
  int N;
  cin >> N;
  vector<int> m(N+1);
  vector<int> h(N);
  long long r=0;
  for(int i=0;i<N+1;i++){
  cin >> m.at(i);
  }
  for(int n=0;n<N;n++){
  cin >> h.at(n);
  }
  for(int i=0;i<N;i++){
    if(m.at(i)-h.at(i) >= 0){
      r+= h.at(i);
    }
    else if(m.at(i)+m.at(i+1)-h.at(i)>=0){
      m.at(i+1) = m.at(i)+m.at(i+1)-h.at(i);
      r+=h.at(i);
    }
    else if(m.at(i)+m.at(i+1)-h.at(i)<=0){
      r+= m.at(i)+m.at(i+1);
        m.at(i+1)=0;
     }
    
  }
  cout << r <<endl;
}

Measured memory_bytes: 1024
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<iostream>
using namespace std;
typedef long long ll;
ll n,x;
ll gcd(ll a,ll b)
{
	if(a%b==0)
		return b;
	return gcd(b,a%b);
}
int main()
{
	scanf("%lld %lld",&n,&x);
	printf("%lld\n",(n-gcd(n,x))*3);
	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
  int arr[3];
  cin>>arr[0]>>arr[1]>>arr[2];
  sort(arr,arr+3);
    if(arr[0]==5 && arr[1]==5 & arr[2]==7)
    {
      cout<<"YES"<<endl;
    }
  else
  {
    cout<<"NO"<<endl;
  }
  return 0;
}

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

using namespace std;

const int INF = 1 << 30;

void chmax(int &a, int b)
{
  a = max(a, b);
}

struct edge
{
  int to, cost;
};

int N, M, K;
vector< edge > g[2000];
bool v[2000];
int dp[2000][2002][2][2];
int sz[2000];
int temp;

int rec(int idx, int pre = -1)
{
  if(v[idx]++) return (pre);
  ++temp;
  if(pre < 0) dp[idx][0][0][0] = 0, dp[idx][1][1][1] = 0;
  for(auto &e : g[idx]) {
    if(pre == e.to) continue;
    for(int i = 0; i <= N; i++) {
      for(int j = 0; j < 2; j++) {
        chmax(dp[e.to][i][0][j], dp[idx][i][0][j]);
        chmax(dp[e.to][i][0][j], dp[idx][i][1][j]);
        chmax(dp[e.to][i + 1][1][j], dp[idx][i][0][j]);
        if(e.cost != 0 && dp[idx][i][1][j] > -INF) chmax(dp[e.to][i + 1][1][j], dp[idx][i][1][j] + e.cost);
      }
    }
    return (rec(e.to, idx));
  }
  return (idx);
}

int rec2(int idx)
{
  int par = rec(idx);
  int edge_cost = -INF;
  for(auto &e : g[idx]) if(e.to == par) edge_cost = e.cost;
  assert(edge_cost != -INF);
  fill_n(**dp[idx], 2002 * 2 * 2, -INF);
  for(int i = 0; i <= N; i++) {
    chmax(dp[idx][i][0][0], dp[par][i][0][0]);
    chmax(dp[idx][i][0][0], dp[par][i][1][0]);
    chmax(dp[idx][i][1][1], dp[par][i][0][1]);
    if(edge_cost != 0 && dp[par][i][1][1] > -INF) chmax(dp[idx][i][1][1], dp[par][i][1][1] + edge_cost);
  }
  return (idx);
}

int main()
{
  fill_n(***dp, 2000 * 2002 * 2 * 2, -INF);

  cin >> N >> M >> K;
  for(int i = 0; i < M; i++) {
    int a, b, c;
    cin >> a >> b >> c;
    --a, --b;
    g[a].emplace_back((edge) {b, c});
    g[b].emplace_back((edge) {a, c});
  }
  vector< int > end;
  for(int i = 0; i < N; i++) {
    if(v[i]) continue;
    if(g[i].size() <= 1) {
      temp = 0;
      end.push_back(rec(i));
      sz[end.back()] = temp;
    }
  }
  for(int i = 0; i < N; i++) {
    if(v[i]) continue;
    temp = 0;
    end.push_back(rec2(i));
    sz[end.back()] = temp;
  }

  vector< int > dp2(N + 1, -INF);
  dp2[0] = 0;
  int sum = 0;
  for(int i : end) {
    for(int x = sum; x >= 0; x--) {
      if(dp2[x] == -INF) continue;
      for(int j = sz[i]; j >= 1; j--) {
        for(int k = 0; k < 2; k++) {
          for(int l = 0; l < 2; l++) {
            if(dp[i][j][k][l] == -INF) continue;
            if(x + j > K) continue;
            chmax(dp2[x + j], dp2[x] + dp[i][j][k][l]);
          }
        }
      }
    }
    sum += sz[i];
  }
  if(dp2[K] == -INF) {
    cout << "Impossible" << endl;
  } else {
    cout << dp2[K] << endl;
  }
}

Measured memory_bytes: 65844
#include<iostream>
using namespace std;
int main(){
	int n;
	int c=0,m=0;
	string s;
	cin>>n>>s;
	if(1<=n<=100)
	{
		
	for(int i=0;i<n;i++){
	
	if(s[i]=='I'){
		c++;
	}
	else if	(s[i]=='D'){
		c--;}
		if(m<c){
		
		m=c;
	}
		
}
		
	}
	cout<<m;
}

Measured memory_bytes: 256
#include <iostream>
#include <fstream>
#include <cstdio>
#include <string>
#include <stack>
#include <queue>
#include <deque>
#include <cassert>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <numeric>
#include <sstream>
#include <iomanip>
#include <algorithm>
#include <vector>
#include <list>
#include <forward_list>
#include <array>
#include <cstring>
#include <cmath>
#include <tuple>
#include <complex>
#include <bitset>
#include <climits>
using namespace std;
using LL = long long;
using ULL = unsigned long long;
using LD = long double;
using pii = pair<int, int>;
using pll = pair<LL, LL>;
using pld = pair<LD, LD>;


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

    int A, B, C, D;
    cin >> A >> B >> C >> D;
    
    cout << (C - A / D * B <= B - B * (A % D == 0) ? "Yes" : "No");
}


Measured memory_bytes: 3628
#include <bits/stdc++.h>
using namespace std;
const int N=210000;
#define ll long long
char s[N];
ll L,R;
int nex[N];
ll len[210];
struct node
{
	ll a[26];
	void init(int x)
	{
		for(int i=1;i<=x;i++)
			a[s[i]-'a']++;
	}
	friend node operator + (const node &r1,const node &r2)
	{
		node ret;
		for(int i=0;i<26;i++)
			ret.a[i]=r1.a[i]+r2.a[i];
		return ret;
	}
	friend node operator - (const node &r1,const node &r2)
	{
		node ret;
		for(int i=0;i<26;i++)
			ret.a[i]=r1.a[i]-r2.a[i];
		return ret;
	}
	void print()
	{
		for(int i=0;i<26;i++)
			printf("%lld ",a[i]);
		puts("");
	}
}v[210];
node calc(ll x)
{
	int p;
	for(p=1;;p++)
		if(len[p]>=x)break;
	node ret,t;
	memset(&ret,0,sizeof(ret));
	memset(&t,0,sizeof(t));
	for(;p>=1;p--)
		if(len[p]<=x)
		{
			ret=ret+v[p];
			x-=len[p];
		}
	t.init(x);
	ret=ret+t;
	return ret;
}
int main()
{
	//freopen("tt.in","r",stdin);
	scanf("%s%lld%lld",s+1,&L,&R);
	len[2]=strlen(s+1)/2;
	nex[1]=0;
	for(int i=2,j=0;i<=len[2];i++)
	{
		while(j&&s[j+1]!=s[i])
			j=nex[j];
		if(s[j+1]==s[i])j++;
		nex[i]=j;
	}
	len[1]=len[2]-nex[len[2]];
	v[1].init(len[1]);
	v[2].init(len[2]);
	for(int i=3;;i++)
	{
		len[i]=len[i-1]+len[i-2];
		v[i]=v[i-1]+v[i-2];
		if(len[i]>=R)break;
	}
	(calc(R)-calc(L-1)).print();
	return 0;
}


Measured memory_bytes: 896
listN = list(map(int, list(str(input()))))

index=0
while index < len(listN):
    if index ==0 and listN[index]!=9:
        index+=1
    else:
        if listN[index]!=9:
            listN[index-1]-=1
            index2 = index
            while index2 < len(listN):
                listN[index2]=9
                index2+=1
            index3=0
            count=0
            while index3 < len(listN):
                count+=listN[index3]
                index3+=1
            print(count)
            break
        else:
            index+=1
if index == len(listN):
    count=0
    index4=0
    while index4 < len(listN):
        count+=listN[index4]
        index4+=1
    print(count)

Measured memory_bytes: 3064
INT = lambda: int(input())
INTM = lambda: map(int,input().split())
STRM = lambda: map(str,input().split())
STR = lambda: str(input())
LIST = lambda: list(map(int,input().split()))
LISTS = lambda: list(map(str,input().split()))
def do():
    n=INT()
    ct=0
    ct+=(n//500)*1000
    n=n-(n//500)*500
    ct+=n//5*5
    print(ct)
if __name__ == '__main__':
    do()

Measured memory_bytes: 3064
package main
import(
  "fmt"
  "bufio"
  "os"
  "strconv"
)
var sc=bufio.NewScanner(os.Stdin)
func nextInt() int{
  sc.Scan()
  i, e :=strconv.Atoi(sc.Text())
  if e!=nil{
    panic(e)
  }
  return i
}
func main(){
  var i int
  ans:=0
  sc.Split(bufio.ScanWords)
  n:=nextInt()
  j:=nextInt()
  a:=make([]int, n)
  for i=0;i<n;i++{
    a[i]=nextInt()
  }
  for i=0;i<n;i++{
    if a[i]>=j{
      ans++
    }
  }
  fmt.Println(ans)
}


Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
#define pp pair<int,int>
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define ll long long
#define ld long double
#define all(a) (a).begin(),(a).end()
#define mk make_pair
ll MOD=1000000007;
ll mod=998244353;
int inf=1000001000;
ll INF=1e18+5;

int main() {
    ll n,a,b;
    ll c=1;
    cin >> n >> a >> b;
    if ((b-a)%2==0) cout << (b-a)/2 << endl;
    else{
        cout << min(a+(b-a)/2,n-b+1+(b-a)/2) << endl;
    }
}


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

int main() {
	vector<int>k = { 1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51 };
	int n;
	cin >> n;
	cout << k.at(n - 1) << endl;
}

Measured memory_bytes: 256
#include <algorithm>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <string>
#include <utility>
#include <vector>

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

using namespace std;
typedef long long int ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef pair<int, int> PI;
const ll mod = 1e9 + 7;

void fail(void) {
  cout << "no\n";
  exit(0);
}

int main(void) {
  ios::sync_with_stdio(false);
  cin.tie(0);
  string t, p;
  cin >> t >> p;
  t += '$';
  p += '$';
  int pos = 0;
  REP(i, 0, p.size()) {
    char prev = i >= 1 ? p[i - 1] : '\0';
    while (pos < (int) t.size()) {
      if (t[pos] == p[i]) {
	break;
      }
      if (t[pos] == prev) {
	fail();
      }
      pos++;
    }
    if (pos == (int) t.size()) {
      fail();
    }
    pos++;
  }
  cout << "yes\n";
}

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


int main(){
    char c;
    cin >> c;
    
    switch(c){
        case 'A': 
            cout << 'T';
            break;
        case 'T': 
            cout << 'A';
            break;
        case 'C':
            cout << 'G';
            break;
        case 'G':
            cout << 'C';
            break;
    }
    cout << endl;
}


Measured memory_bytes: 256
<?php
// B
fscanf(STDIN, '%d', $x);
$ans = 1;
for ($i = 2; $i <= $x; $i++) {
    $t = 2;
    while ($i ** $t <= $x) {
        $ans = max($ans, $i ** $t);
        $t++;
    }
}
echo $ans;

Measured memory_bytes: 4984
#include<bits/stdc++.h>
using namespace std;
typedef pair<int,int> P;
int N;
P p[50];
 
int H[55][333][2];
 
int calc(int i,int f,int t,int c,int *F){
  int tot = t + p[i].first;
  if( c == 0 ) return tot;
  for(int j=i+1;j<N;j++){
    if( c - F[j] - 1 < 0 ) continue;
    if( H[j][c-F[j]-1][f] > tot )
      tot = H[j][c-F[j]-1][f];    
  }
  for(int j=i+1;j<N;j++){
    if( c-F[j]-1<0 ) continue;
    if( H[j][c-F[j]-1][f] == tot ) F[j]++;
  }
  return tot;
}
 
int main(){
  while( cin >> N && N ){
    for(int i=0;i<N;i++){
      cin >> p[i].first >> p[i].second;
    }
    memset(H,0,sizeof(H));
    int res = 0;
    sort(p,p+N);
    for(int i=N-1;i>-1;i--){
      int t = 0, F[55] = {};
      for(int c=0; c < p[i].second; c++ ){
    t = calc(i,0,t,c,F);
    H[i][c][0] = t;
    t = calc(i,1,t,c,F);
    H[i][c][1] = t;
    res = max( res, t );
      }
    }
    cout << res << endl;
  }
}

Measured memory_bytes: 1316