akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <cmath>
#include <vector>
using namespace std;

int main(){
    vector<int> sq;
    for( int i = 0; pow(i+1.0,2) < 33000; i++ ){
        sq.push_back( pow(i+1.0,2) );
    }
    int n, c = 0;
    while( cin >> n, c++ < 255 ){
        int sum, count = 0;
        for( int i = 0; i < sq.size(); i++ ){
            //sum = 0;
            if( sq[i] > n ){
                break;
            }else if( sq[i] == n ){
                //cout << sq[i] << endl;
                count++;
            }else{
                //sum += sq[i];
                for( int j = i; j < sq.size(); j++ ){
                    if( sq[i] + sq[j] > n ){
                        break;
                    }else if( sq[i] + sq[j] == n ){
                        //cout << sq[i] << ' ' << sq[j] << endl;
                        count++;
                    }else{
                        //sum += sq[j];
                        for( int k = j; k < sq.size(); k++ ){
                            if( sq[i] + sq[j] + sq[k] > n ){
                                break;
                            }else if( sq[i] + sq[j] + sq[k] == n ){
                                //cout << sq[i] << ' ' << sq[j] << ' ' << sq[k] << endl;
                                count++;
                            }else{
                                //sum += sq[k];
                                for( int l = k; l < sq.size(); l++ ){
                                    if( sq[i] + sq[j] + sq[k] + sq[l] > n ){
                                        break;
                                    }else if( sq[i] + sq[j] + sq[k] + sq[l] == n ){
                                        //cout << sq[i] << ' ' << sq[j] << ' ' << sq[k] << ' ' << sq[l] << endl;
                                        count++;
                                    }
                                }
                            }
                        }
                    }
                }
            }
        }
        cout << count << endl;
    }
}

Measured memory_bytes: 1216
#include <bits/stdc++.h>
using ll = long long;
#define FOR(i, k, n) for(ll i = (k); i < (n); i++)
#define FORe(i, k, n) for(ll i = (k); i <= (n); i++)
#define FORr(i, k, n) for(ll i = (k)-1; i > (n); i--)
#define FORre(i, k, n) for(ll i = (k)-1; i >= (n); i--)
#define REP(i, n) FOR(i, 0, n)
#define REPr(i, n) FORre(i, n, 0)
#define ALL(x) (x).begin(), (x).end()
#define ALLr(x) (x).rbegin(), (x).rend()
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
using namespace std;

const int INF = 1001001001;

const int mod = 1000000007;

struct mint{
  ll x;
  mint(ll x = 0):x((x % mod + mod) % mod){};
  mint pow(ll y) const {
    mint res(1);
    mint a(x);
    while(y>0){
      if(y&1) res *= a;
      a *= a;
      y >>= 1;
    }
    return res;
  }
  mint inv() const{ return pow(mod-2); }
  mint& operator+= (const mint a) noexcept {
    if((x += a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator-= (const mint a) noexcept {
    if((x += mod - a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator*= (const mint a) noexcept {
    (x *= a.x) %= mod;
    return *this;
  }
  mint& operator/= (const mint a) noexcept {
    return (*this) *= a.inv();
  }
  mint operator+ (const mint a) const noexcept {
    mint res(*this);
    return res += a;
  }
  mint operator- (const mint a) const noexcept {
    mint res(*this);
    return res -= a;
  }
  mint operator* (const mint a) const noexcept {
    mint res(*this);
    return res *= a;
  }
  mint operator/ (const mint a) const noexcept{
    mint res(*this);
    return res /= a;
  }
};

ostream& operator<<(ostream& stream, const mint& n){
  stream << n.x;
  return stream;
};

struct comb{
  vector<mint> fact, ifact;
  comb(int n): fact(n+1), ifact(n+1){
    fact[0] = 1;
    for(int i = 1; i <= n; i++) fact[i] = fact[i-1] * i;
    ifact[n] = fact[n].inv();
    for(int i = n; i >= 1; i--) ifact[i-1] = ifact[i] * i;
  }
  mint operator()(int n, int k) const noexcept{
    if(k < 0 || n < k) return 0;
    return fact[n] * ifact[k] * ifact[n-k];
  }
};

int main(void){
  ll n;
  cin >> n;
  vector<ll> a(n);
  REP(i, n) cin >> a[i];

  vector<mint> b(n+1, 0);
  REP(i, n) b[i+1] = b[i]+a[i];

  mint ans = 0;
  REP(i, n) ans += (b[n]-b[i+1])*a[i];
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 6348
#include <bits/stdc++.h>
using namespace std;
#define repr(i,a,b) for(int i=a;i<b;i++)
#define rep(i,n) for(int i=0;i<n;i++)
#define reprrev(i,a,b) for(int i=b-1;i>=a;i--) // [a, b)
#define reprev(i,n) reprrev(i,0,n)
typedef long long ll;
typedef unsigned long long ull;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

/* attention
    long longのシフト演算には気をつけよう
    タイポした時のデバッグが死ぬほどきつくなるので変数名は最低3字くらい使った方がいいかも
    sizeは(int)とキャストしよう
    ごちゃごちゃ場合分けを考える前に全探索は考えましたか？
    詰まった時に、別の分野の問題として考え直す（これdpでは？、グラフとしてみればいいのでは？）
    多くの問題はパターンマッチだが、パターンに落とし込むまでが難しく、そのための訓練としてわからない問題をあれこれ色々な角度から考察してみるのではないか
    cin.tie(0);
    ios::sync_with_stdio(false);<- これら、printfとかと併用しない方が良さそう

*/

const ll mod = 1e9+7;

void chmod(ll &M){
    if(M >= mod) M %= mod;
    else if(M < 0){
        M += (abs(M)/mod + 1)*mod;
        M %= mod;
    }
}

ll modpow(ll x, ll n){
    if(n==0) return 1;
    ll res=modpow(x, n/2);

    if(n%2==0) return res*res%mod;
    else return res*res%mod*x%mod;
}

int getl(int i, int N) { return i==0? N-1:i-1; };
int getr(int i, int N) { return i==N-1? 0:i+1; };

/* <--------------------------------------------> */


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

    string s; cin >> s;
    bool flg=true;

    int l, r;
    rep(i, s.size()-1) if(s[i]==s[i+1]) { flg=false; l=i+1, r=i+2; }
    rep(i, s.size()-2) if(s[i]==s[i+2]) { flg=false; l=i+1, r=i+3; }

    if(!flg){
        cout << l << ' ' << r << endl;
    }
    else{
        {{{{{{{{{{{{{{}}}}}}}}}}}}}};;;;;;;
        cout << -1 << ' ' << -1 << endl;;;;;;;;;;;
    }

    return 0;
}


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

/***********************************************/
/* Dear online judge:
 * I've read the problem, and tried to solve it.
 * Even if you don't accept my solution, you should respect my effort.
 * I hope my code compiles and gets accepted.
 *  ___  __     _______    _______      
 * |\  \|\  \  |\  ___ \  |\  ___ \     
 * \ \  \/  /|_\ \   __/| \ \   __/|    
 *  \ \   ___  \\ \  \_|/__\ \  \_|/__  
 *   \ \  \\ \  \\ \  \_|\ \\ \  \_|\ \ 
 *    \ \__\\ \__\\ \_______\\ \_______\
 *     \|__| \|__| \|_______| \|_______|
 */
const long long mod = 1000000007;

const int mxN = 100010;
vector<int> g[mxN];
int C[mxN];
long long cnt[2];

bool dfs(int v,int c) {
	if(C[v] != -1 && c != C[v]) return false;
	if(C[v] != -1) return true;
	cnt[c]++;
	C[v] = c;
	for(auto u : g[v]) {
		if(!dfs(u,!c)) return false;
	}
	return true;
}


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

	int N,M,u,v;
	cin>>N>>M;
	for(int i = 0;i < M;i++) {
		cin>>u>>v;
		u--,v--;
		g[u].push_back(v);
		g[v].push_back(u);
	}
	
	memset(C,-1,sizeof C);
	if(!dfs(0,0)) {
		long long res = (N * 1ll * (N-1ll) / 2ll) - M;
		cout<<res<<'\n';
	} else {
		long long res = cnt[0] * cnt[1] - M;
		cout<<res<<'\n';
	}
	
	return 0;
}


Measured memory_bytes: 6400
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <queue>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>

using namespace std;

inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}

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

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

#define MP make_pair
#define EACH(i,c) for(auto i: c)
#define SORT(c) sort((c).begin(),(c).end())

#define ALL(a)  (a).begin(),(a).end()

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

	LL ret = 0;
	FOR(a, 1, K + 1){
		FOR(b, 1, K + 1){
			FOR(c, 1, K + 1){
				ret += __gcd(a, __gcd(b, c));
			}
		}
	}

	cout << ret << endl;

	return 0;
}


Measured memory_bytes: 3648
import java.util.Scanner;

class Main {
public static void main (String[] args){
Scanner sc = new Scanner(System.in);
int i = 1;
while(i <= 10000){
int x = sc.nextInt();
if ( x == 0 ) {
break;
}else{
System.out.println("Case " + i + ":" + " " + x);
i++;
}
}
}
}


Measured memory_bytes: 41496
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		//String s = sc.next();
		//String t = sc.next();
		//String g = sc.next();
		long n = sc.nextLong();
		//long m = sc.nextLong();
		//long k = sc.nextLong();
		//long l = sc.nextLong();
		long count=0;

		/*for(int i=0;i<=3;i++) {
			if(s.substring(i,i+1).equals("+")) {
				count++;
			}else {
				count--;
			}
		}*/
		if(n%2==0) {
			System.out.println(n);
		}else{
			System.out.println(n*2);
		}
		//System.out.println((int)Math.ceil((n+m)/2.0));
		//System.out.println(count);
	}
}




Measured memory_bytes: 23892
import sys
input = sys.stdin.readline

def F(N,A,B):
    # n 個のどんぐりを持っている
    # a個がbの価値に変換できる
    AB = [(x,y) for x,y in zip(A,B) if x < y]
    dp = [0] * (N+1)
    for n in range(N+1):
        x = n
        for a,b in AB:
            if n >= a:
                y = dp[n-a] + b
                if x < y:
                    x = y
        dp[n] = x
    return dp[N]

N = int(input())
A = [int(x) for x in input().split()]
B = [int(x) for x in input().split()]

answer = F(F(N,A,B),B,A)
print(answer)

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

int main() {
  string s;
  cin >> s;
  if (s.at(0) == s.at(1) || s.at(1) == s. at(2) || s.at(2) == s.at(0)) {
    cout << "No" << endl;
  }
  else {
    cout << "Yes" << endl;
  }
  return 0;
}

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

using namespace std;

typedef long long int ll;
typedef pair<int,int> P;

#define rep(i,n) for(int i=0;i<(n);++i)
#define repi(i,a,b) for(int i=int(a);i<(b);i++)
#define all(x) x.begin(),x.end()

const ll mod = 1e9+7;
const ll INF = 1e9;

ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};

int main()
{
	int n;
	while(cin>>n,n!=0){
		vector<int> a(n);
		rep(i,n)cin>>a[i];
		cout<<(accumulate(all(a),0)-*max_element(all(a))-*min_element(all(a)))/(n-2)<<endl;
	}
	return 0;
}


Measured memory_bytes: 3076
n = int(input())
h = list(map(int, input().split()))
max_num = 0
num = 0
for i in range(n-1):
    if h[i] >= h[i+1]:
        num += 1
    else:
        if max_num < num:
            max_num = num
        num = 0
if max_num < num:
    max_num = num
print(max_num)

Measured memory_bytes: 15020
import java.util.*;
import java.io.*;
public class Main{
	
	static final int NONUM=-1;
	public static void main(String[] args)throws IOException{
		final Scanner sc=new Scanner(System.in);
		int a=sc.nextInt();
		NODE[] n = new NODE[a];
	
		for(int i=0;i<n.length;i++){
			int id=sc.nextInt();
			n[id]=new NODE();
			n[id].id = id;
			n[id].l = sc.nextInt();
			n[id].r = sc.nextInt();
			n[id].p = -1;
			n[id].s = -1;
			n[id].d = 0;
			n[id].t = "leaf";
			if(n[id].l != -1){
				n[id].d++;
				n[id].t = "internal node";
			}
			if(n[id].r != -1){
				n[id].d++;
				n[id].t = "internal node";
			}
		}
	     for(int i=0; i<a; i++){
	    	 if(n[i].l != -1){
	                n[n[i].l].p = n[i].id;
	            }
	            if(n[i].r != -1){
	                n[n[i].r].p = n[i].id;
	            }
	            if(n[i].l != -1 && n[i].r != -1){
	                n[n[i].l].s = n[i].r;
	                n[n[i].r].s = n[i].l;
	            }
	     }
		
	        for(int i=0; i<a; i++){
	            if(n[i].p == -1){
	                n[i].t = "root";
	                if(n[i].l != -1){
	                    getdepth(n, n[i].l, 1);
	                }
	                if(n[i].r != -1){
	                    getdepth(n, n[i].r, 1);
	                }
	            }
	            if(n[i].d == 0){
	                if(n[i].p != -1){
	                    getheight(n, n[i].p, 1);
	                }
	            }
	        }
		
		for(int i=0;i<a;i++){
			System.out.println("node "+n[i].id+": parent = "+n[i].p+", sibling = "+n[i].s+", degree = "+n[i].d+", depth = "+n[i].dep+", height = "+n[i].h+ ", "+n[i].t);
		}
	}
	
	static void getdepth(NODE[] n,int i,int d){
	     n[i].dep = d;
	        d++;
	        if(n[i].l != -1){
	            getdepth(n, n[i].l, d);
	        }
	        if(n[i].r != -1){
	            getdepth(n, n[i].r, d);
	        }
	        
	}	
	
	static void getheight(NODE[] n,int i, int h){
        if(h < n[i].h) h = n[i].h;
        else           n[i].h = h;
        h++;
        if(n[i].p != -1){
            getheight(n, n[i].p, h);
        }
	}
}
	
class NODE{
	int id;
	int r;
	int l;
	int p;
	int d;
	int dep;
	int h;
	int s;
	String t; 
}

Measured memory_bytes: 26124
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <vector>
#include <cmath>
#include <queue>
#include <algorithm>
using namespace std;
#define EPS (1E-10)
const int maxn=100000+10;
int n;
struct Point
{
    int x,y;
    Point() {}
    Point(int _x,int _y):x(_x),y(_y) {}
    Point operator -(Point p)
    {
        return Point(x-p.x,y-p.y);
    }
    bool operator <(Point p)
    {
        return x==p.x?y<p.y:x<p.x;
    }
    int cross(Point p)
    {
        return x*p.y-y*p.x;
    }
    int dot(Point p)
    {
        return x*p.x+y*p.y;
    }
    int norm()
    {
        return x*x+y*y;
    }

};
vector<Point> ps;
bool cmp(Point A,Point B)
{
    if(A.y!=B.y) return A.y<B.y;
    return A.x<B.x;
}
int ccw(Point p,Point p1,Point p2)
{
    #define CLOCKWISE -1
    #define COUNT_CLOCKWISE 1
    #define ON_SEGMENT 0
    #define ONLINE_BACK 2
    #define ONLINE_FRONT -2
    Point a=p1-p;
    Point b=p2-p;
    if(a.cross(b)<-EPS) return CLOCKWISE;
    if(fabs(a.cross(b)<EPS)) return CLOCKWISE;
    if(a.cross(b)>EPS) return COUNT_CLOCKWISE;
    if(a.dot(b)<-EPS) return ONLINE_BACK;
    if(a.norm()<b.norm()) return ONLINE_FRONT;
    return ON_SEGMENT;
}
vector<Point> convex_hull(vector<Point> ps) {
    vector<Point> u, l;

    if(ps.size()<3) return ps;
 sort(ps.begin(),ps.end());
    u.push_back(ps[0]);
    u.push_back(ps[1]);
    l.push_back(ps[ps.size()-1]);
    l.push_back(ps[ps.size()-2]);
    for(int i=2;i<ps.size();i++)
    {
        for(int n=u.size();n>=2&&ccw(u[n-2],u[n-1],ps[i])!=CLOCKWISE;n--) u.pop_back();
        u.push_back(ps[i]);
    }
     for(int i=ps.size()-3;i>=0;i--)
    {
        for(int n=l.size();n>=2&&ccw(l[n-2],l[n-1],ps[i])!=CLOCKWISE;n--) l.pop_back();
        l.push_back(ps[i]);
    }
    reverse(l.begin(),l.end());
    for(int i=u.size()-2;i>=1;i--) l.push_back(u[i]);
    return l;
}
int main()
{
//    freopen("in.txt","r",stdin);
    scanf("%d",&n);
    Point p;
    for(int i=0; i<n; i++)
    {
        scanf("%d%d",&p.x,&p.y);
        ps.push_back(p);
    }

    vector<Point> qs=convex_hull(ps);
//    sort(qs.begin(),qs.end(),cmp);
    printf("%d\n",qs.size());
    int index=0;
    int min_y=10000,min_x=10000;
    for(int i=0;i<qs.size();i++)
    {
        Point p=qs[i];
        if(p.y<min_y)
        {
            min_y=p.y;
            min_x=p.x;
            index=i;
        }
        else if(p.y==min_y&&p.x<min_x)
         {
             min_y=p.y;
             min_x=p.x;
             index=i;
         }

    }
    for(int i=0;i<qs.size();i++)
    {
        Point p=qs[(i+index)%qs.size()];
        printf("%d %d\n",p.x,p.y);
    }


    return 0;

}

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

int N, T;
int t[200001];
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);

    cin >> N >> T;

    int ans = 0;
    for(int i = 0; i < N; ++i){
        cin >> t[i];
        if(i != 0){
            if(t[i] - t[i - 1] > T){
                ans += T;
            }
            else {
                ans += t[i] - t[i - 1];
            }
        }
    }
    ans += T;
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 1024
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author aajisaka
 */

#include<bits/stdc++.h>

using namespace std;

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

#define SPEED ios_base::sync_with_stdio(false);cin.tie(nullptr)
#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define all(v) v.begin(), v.end()
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

using ll = long long;
using P = pair<ll, ll>;

constexpr long double PI = 3.14159265358979323846264338327950288L;
mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count());

class CDistinctOrNot {
public:
    void solve(istream& cin, ostream& cout) {
      SPEED;
      int n; cin >> n;
      set<int> st;
      rep(i, n) {
        int a; cin >> a;
        st.insert(a);
      }
      if (st.size() == n) {
        cout << "YES" << endl;
      } else {
        cout << "NO" << endl;
      }
    }
};

signed main() {
  CDistinctOrNot solver;
  std::istream& in(std::cin);
  std::ostream& out(std::cout);
  solver.solve(in, out);
  return 0;
}

Measured memory_bytes: 9600
#pragma gcc optimize("Ofast")
#include <bits/stdc++.h>
using namespace std;

#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) FOR(i, 0, n)
#define ALL(V) (V).begin(),(V).end()
#define SORT(V) sort(ALL(V)) //小さい方からソート
#define REV(V) reverse(ALL(V)) //リバース
#define RSORT(V) SORT(V);REV(V) //大きい方からソート
#define NPN(V) next_permutation(ALL(V)) //順列
#define pb(n) push_back(n)
#define endl '\n'
#define Endl '\n'
#define DUMP(x)  cout << #x << " = " << (x) << endl
#define YES(n) cout << ((n) ? "YES" : "NO"  ) << endl
#define Yes(n) cout << ((n) ? "Yes" : "No"  ) << endl
#define yes(n) cout << ((n) ? "yes" : "no"  ) << endl
#define Yay(n) cout << ((n) ? "Yay!": ":(") << endl
#define RAPID cin.tie(0);ios::sync_with_stdio(false)
#define VSUM(V) accumulate(ALL(V), 0)
#define MID(a,b,c) (a) < (b) && (b) < (c)
#define MIDe(a,b,c) (a) <= (b) && (b) <= (c)
#define IN(n) cin >> n
#define IN2(a,b) cin >> a >> b
#define IN3(a,b,c) cin >> a >> b >> c 
#define IN4(a,b,c,d) cin >> a >> b >> c >> d
#define VIN(V) for(int i = 0; i < (V).size(); i++) {cin >> (V).at(i);}
#define OUT(n) cout << n << endl
#define VOUT(V) REP(i, (V).size()) {cout << (V)[i] << endl;}
#define VOUT2(V) REP(i, (V).size()) {cout << (V)[i] << " ";} cout<<endl;
#define FIX cout << fixed << setprecision(15)

// 型マクロ定義
#define int long long
#define P pair<ll,ll>
#define Vi vector<ll>
#define VVi vector<vector<ll>>
#define Vd vector<double>
#define Vb vector<bool>
#define Vs vector<string>
#define Vc vector<char>
#define M map<ll,ll>
#define S set<ll>
#define PQ priority_queue<ll>
#define PQG priority_queue<ll,V,greater<ll>
//

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

using ll = long long;
using Graph = vector<vector<int>>;

const int MOD = 1000000007;
const int INF = 1061109567;
const double EPS = 1e-10;
const double PI  = acos(-1.0);
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};

int gcd(int a,int b){return b != 0 ? gcd(b, a % b) : a;} //最大公約数
int lcm(int a, int b){return a * b / gcd(a, b);}
string toStrUp(string str){char diff = 'A'-'a';REP(i,str.size()) str[i] += diff;return str;}
string gCh(string str, int key){return str.substr(key,1);}

signed main() {
  RAPID;
  // デフォルト変数定義
  int n=0,m=0,a=0,b=0,c=0,d=0,x=0,y=0,z=0;
  string s="",t="";
  //

  // ここから
  IN(s);
  bool ok = true;
  for(int i = s.size()-1; i >= 0; --i){
    if(i >= 6 && s.substr(i-6,7)=="dreamer") {
      i -= 6;
    } else if(i >= 4 && s.substr(i-4,5)=="dream") {
      i -= 4;
    } else if(i >= 5 && s.substr(i-5,6)=="eraser") {
      i -= 5;
    } else if(i >= 4 && s.substr(i-4,5)=="erase") {
      i -= 4;
    } else {
      ok = false;
      break;
    }
  }
  YES(ok);
}

Measured memory_bytes: 512
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <cmath>
#include <map>
#include <queue>
#include <iomanip>
#include <set>
#include <tuple>
#define mkp make_pair
#define mkt make_tuple
#define rep(i,n) for(int i = 0; i < (n); ++i)
using namespace std;
typedef long long ll;
const ll MOD=1e9+7;
template<class T> void chmin(T &a,const T &b){if(a>b) a=b;}
template<class T> void chmax(T &a,const T &b){if(a<b) a=b;}

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

  int N;
  cin>>N;
  vector<int> X(N);
  rep(i,N) cin>>X[i];

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

  int ans=MOD;
  for(int x=1;x<=100;x++){
    int res=0;
    rep(i,N) res+=(x-X[i])*(x-X[i]);
    chmin(ans,res);
  }

  cout<<ans<<endl;

  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
using namespace std;
int N;
long A[100001][2];
int main(){
  cin >> N; 
  A[0][1] = -1;
  for(int i = 0; i < N; ++i) {
    int a;
    cin >> a;
    if(a == 0) {
      A[i + 1][0] = A[i][0];
      A[i + 1][1] = -1;
    }else if(a % 2 == 0) {
      A[i + 1][0] = A[i][0] + a / 2;
      A[i + 1][1] = max(A[i][0] + a / 2 - 1, A[i][1] + a / 2);
    }else{
      A[i + 1][0] = max(A[i][0] + a / 2, A[i][1] + a / 2 + 1);
      A[i + 1][1] = A[i][0] + a / 2;
    }
  }
  cout << A[N][0] << endl;
}


Measured memory_bytes: 1792
#include<cstdio>
#include<cstdlib>
#include<algorithm>
#include<iostream>
#include<queue>
#include<vector>
#include <bitset>
#include<math.h>
using namespace std;
#define INF 110000000000
#define MOD 1000000007
typedef long long ll;
typedef pair<int,int> P;

int main(){
  int N,T,c=10000,t,ans=10000;
  cin>>N>>T;

  for(int i=0;i<N;i++){
    cin>>c>>t;
    if(T>=t) ans=min(ans,c);
  }
  if(ans!=10000) cout<<ans<<endl;
  else cout<<"TLE"<<endl;
  
}


Measured memory_bytes: 256
#include<stdio.h>
#include<stdlib.h>
const int MAXSIZE = 100000 + 2;
const int INF = 2000000000;
struct Card {
	char type;
	int data;
}a[MAXSIZE],b[MAXSIZE];
struct Card L[MAXSIZE / 2 + 2], R[MAXSIZE / 2 + 2];
void Merge(struct Card A[], int left, int mid, int right) {
	int n1 = mid - left;
	int n2 = right - mid;
	for (int i = 0; i < n1; i++) L[i] = A[left + i];
	for (int i = 0; i < n2; i++)R[i] = A[mid + i];
	L[n1].data = R[n2].data = INF;
	int i = 0, j = 0;
	for (int k = left; k < right; k++) {
		if (L[i].data <= R[j].data) {
			A[k] = L[i++];
		}
		else {
			A[k] = R[j++];
		}
	}
}
void Merge_sort(struct Card A[], int left, int right) {
	if (left + 1 < right) {
		int mid = (left + right) / 2;
		Merge_sort(A, left, mid);
		Merge_sort(A, mid , right);
		Merge(A, left, mid, right);
	}
}
int Partition(struct Card A[], int p, int r) {
	int x = A[r].data;
	int i = p - 1;
	struct Card temp;
	for (int j = p; j < r; j++) {
		if (A[j].data <= x) {
			i++;
			temp = A[j];
			A[j] = A[i];
			A[i] = temp;
		}
	}
	temp = A[r];
	A[r] = A[i + 1];
	A[i + 1] = temp;
	return i + 1;
}
void Quick_sort(struct Card A[], int p, int r) {
	if (p < r) {
		int q = Partition(A, p, r);
		Quick_sort(A, p, q - 1);
		Quick_sort(A, q + 1, r);
	}
}
int main() {
	int n;
	scanf("%d", &n);
	for (int i = 0; i < n; i++) {
		char c[10]; int num;
		scanf("%s %d", c, &num);
		a[i].type = b[i].type = c[0];
		a[i].data = b[i].data = num;
	}
	Merge_sort(a, 0, n);
	Quick_sort(b, 0, n - 1);

	int stable = 1;
	for (int i = 0; i < n; i++) {
		if (a[i].type != b[i].type) {
			stable = 0; break;
		}
	}
	if (stable) {
		printf("Stable\n");
	}
	else {
		printf("Not stable\n");
	}
	for (int i = 0; i < n; i++) {
		printf("%c %d\n", b[i].type, b[i].data);
	}
	
	return 0;
}

Measured memory_bytes: 4948
import sys
def MI(): return map(int,sys.stdin.readline().rstrip().split())
def LI(): return list(map(int,sys.stdin.readline().rstrip().split()))  #空白あり


N,K = MI()
A = [0] + LI()

visited = [0]*(N+1)  # visited[i] = 町iに何回のテレポートで到着するか
times = [0]*(N+1)  # times[i] = i回目のテレポートでどの町に到着するか
i = 1
a = 0
visited[1] = 0
times[0] = 1
while True:
    i = A[i]
    a += 1
    times[a] = i
    if visited[i] != 0:
        b,c = visited[i],a  # 循環開始、終了
        break
    else:
        visited[i] = a

print(times[K] if K <= a else times[a+(K-a)%(b-a)])


Measured memory_bytes: 101476
import bisect

D = int(input())
c = [0] + list(map(int, input().split()))
s = [0] + [[0] + list(map(int, input().split())) for _ in range(D)]
held = [[0] for _ in range(27)]

SL, sch = 0, [0]
for d in range(1, D+1):
    t = int(input())
    sch.append(t)
    held[t].append(d)
    SL += s[d][t]
    for i in range(1, 27):
        SL -= c[i] * (d - held[i][-1])
for i in range(1, 27):
    held[i].append(D+1)

M = int(input())
for i in range(M):
    d, q = map(int, input().split())

    SL += s[d][q] - s[d][sch[d]]

    ind = bisect.bisect_left(held[sch[d]], d)
    k = d - held[sch[d]][ind-1]
    l = held[sch[d]][ind+1] - d
    SL -= c[sch[d]] * k * l
    del held[sch[d]][ind]

    ind = bisect.bisect_left(held[q], d)
    held[q].insert(ind, d)
    k = d - held[q][ind-1]
    l = held[q][ind+1] - d
    SL += c[q] * k * l

    sch[d] = q
    print(SL)

Measured memory_bytes: 9232
#include <bits/stdc++.h>
using namespace std;
template <class T> void corner(bool flg, T hoge) {if (flg) {cout << hoge << endl; exit(0);}}

int main() {
    cin.tie(0);ios::sync_with_stdio(false);
    long long N,K; cin >> N >> K;
    vector<int> A(N);
    for(int i = 0; i < N; ++i) cin >> A[i];
    vector<vector<int>> B(200001);
    for(int i = 0; i < N; ++i) B[A[i]].push_back(i);
    vector<int> C(N);
    for(int i = 0; i < 200001; ++i) {
        if(B[i].empty()) continue;
        for(int j = 0; j + 1 < B[i].size(); ++j){
            C[B[i][j]] = B[i][j+1];
        }
        C[B[i].back()] = B[i].front();
    }
    vector<vector<int>> D(2,vector<int>(N));
    D[0][0] = 1;
    for(int i = 0, from = 0, to; i < N; ++i,from = to) {
        to = C[from];
        D[1][to] = D[0][from] + (from >= to);
        from = to, to = (from + 1) % N;
        if(to == 0) break;
        D[0][to] = D[1][from] + (from >= to);
    }
    long long M = D[1][N-1];
    K %= M;
    corner(!K,"");
    int s;
    for(int i = 0; i < N; ++i) if(K==D[0][i]) s = i;
    vector<int> ans,E(200001,0);
    for(int i = s; i < N; ++i) {
        if(E[A[i]]) {
            while(ans.back()!=A[i]){
                E[ans.back()] = 0;
                ans.pop_back();
            }
            ans.pop_back();
        }
        else{
            ans.push_back(A[i]);
        }
        E[A[i]] ^= 1;
    }
    corner(ans.empty(),"");
    for(int e:ans) cout << e << " ";
    cout << endl;

    
    return 0;
}


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

typedef long long int ll;
typedef pair<ll, ll> p_ll;
typedef vector<pair<ll, ll>> vec_p; //vector<pair<ll, ll>> pairs(n) ,pairs.at(i) = make_pair(i*i, i)

#define ture ture
#define flase false
#define falg flag

#define REP(i, x) for (ll i = 0; i < (ll)(x); i++)
#define REPS(i, x) for (ll i = 1; i <= (ll)(x); i++)
#define RREP(i, x) for (ll i = ((ll)(x)-1); i >= 0; i--)
#define RREPS(i, x) for (ll i = ((ll)(x)); i > 0; i--)
#define all(x) (x).begin(), (x).end()

const ll MOD = pow(10, 9) + 7;
const ll LLINF = pow(2, 61) - 1;//llの最大9*10^18
const int INF = pow(2, 30) - 1;

ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }

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

    double W,H,x,y;
    string S;
    cin >> W>>H>>x>>y;
    

    if(x==W/2.0&&y==H/2.0){
        cout << setprecision(12) << W * H / 2.0;
        cout << " " << 1 << endl;
    }
    else{
        cout << setprecision(12) << W * H / 2.0;
        cout << " " << 0 << endl;
    }
}


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

using namespace std;

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

typedef long double D;

struct edge { int to; D cap, cost; int rev; };
//int const INF = 1<<29;
double const Inf = 1e40;
int const Max = 300;
D h[Max], dist[Max];
int prevv[Max], preve[Max];

int V;

vector<edge> G[Max];

inline void add_edge(int f, int t, D cap, D cost) {
  G[f].push_back((edge){t, cap, cost, (int)G[t].size()});
  G[t].push_back((edge){f, 0, -cost, (int)G[f].size()-1});
}

double const INF = 1e40;
long double const EPS = 1e-5;

typedef pair<D, int> P;

D min_cost_flow(int S, int T, D f) {
  D ret = 0;
  fill(h, h+V, 0);
  while(f > 0) {
    priority_queue<P, vector<P>, greater<P> > pq;
    fill(dist, dist+V, INF);
    dist[S] = 0;
    pq.push(P(0, S));
    while(!pq.empty()) {
      D cost = pq.top().first;
      int curr = pq.top().second; pq.pop();
      if(dist[curr] < cost) { continue; }
      rep(i, G[curr].size()) {
	edge& e = G[curr][i];
	if(e.cap > EPS && dist[e.to] > dist[curr] + e.cost + h[curr] - h[e.to] + EPS) {
	  dist[e.to] = dist[curr] + e.cost + h[curr] - h[e.to];
	  prevv[e.to] = curr;
	  preve[e.to] = i;
	  pq.push(P(dist[e.to], e.to));
	}
      }
    }
    
    if(dist[T] == INF) { return -1; }
    
    rep(i, V) h[i] += dist[i];
    
    D d = f;
    for(int v = T; v!=S; v=prevv[v]) {
      d = min(d, G[prevv[v]][preve[v]].cap);
    }
    
    f -= d;
    ret += d*h[T];
    
    for(int v=T; v!=S; v=prevv[v]) {
      edge& e = G[prevv[v]][preve[v]];
      e.cap -= d;
      G[v][e.rev].cap += d;
    }
  }
  
  return ret;
}

template<class T>
vector<T> gauss_jordan(vector<vector<T> > const& A, vector<T> const& b) {
  int N = A.size();
  vector<vector<T> > B(A);
  rep(i, B.size()) B[i].resize(N+1);
  rep(i, N) B[i][N] = b[i];
  rep(i, N) {
    int pivot = i;
    REP(j, i, N) {
      if(abs(B[pivot][i]) < abs(B[j][i])) {
	pivot = j;
      }
    }
    swap(B[i], B[pivot]);
    
    if(abs(B[i][i]) < EPS) { return vector<T>(); }
    
    REP(j, i+1, N+1) { B[i][j] /= B[i][i]; }
    rep(j, N) if(i != j) {
      REP(k, i+1, N+2) B[j][k] -= B[j][i] * B[i][k];
    }
  }
  vector<T> x(N);
  rep(i, N) x[i] = B[i][N];
  return x;
}

typedef vector<D> Vec;
typedef vector<Vec> Mat;

int main() {
  
  int Tc; cin >> Tc;
  while(Tc--) {
    int N, s, t; D F; cin >> N >> s >> t >> F;
    V = N;
    rep(i, N) G[i].clear();
    
    Mat A(N, Vec(N)); Vec b(N);
    rep(i, N) {
      rep(j, N) {
	cin >> A[i][j];
      }
      cin >> b[i];
    }
    
    Vec X(gauss_jordan(A, b));
    
    rep(i, N) {
      int M; cin >> M;
      vector<int> ds(M);
      rep(j, M) { cin >> ds[j]; }
      rep(j, M) {
	D f; cin >> f;
	//	cerr << i << " -> " << ds[j] << endl;
	add_edge(i, ds[j], f, abs(X[i]-X[ds[j]]));
      }
    }
    
    D r = min_cost_flow(s, t, F);
    if(r < EPS) {
      cout << "impossible\n";
    }
    else {
      printf("%.10Lf\n", r);
    }
  }
  
  return 0;
}

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

#include <algorithm>

using namespace std;

#define sqr(x) ((x) * (x))
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()

typedef long long ll;

const int MOD = 1000000007;
const int INF = 1000000007;
const ll INFLL = 1000000000000000007LL;

void solve() {
  string S;
  cin >> S;
  if (S[2] == S[3] && S[4] == S[5]) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }
}

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  // cout << fixed << setprecision(12);

  solve();

  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i, n) for(int (i) = 0; (i) < (n); (i)++)
#define print(x) cout << (x) << endl;
#define printa(x, n) for(ll i = 0; i < n; i++) {cout << (x[i]) << " ";} cout << endl;
using namespace std;
using ll = long long;

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

    int n = 0, w = 0, s = 0, e = 0;
    rep (i, S.size()) {
        if (S[i] == 'N') n++;
        if (S[i] == 'W') w++;
        if (S[i] == 'S') s++;
        if (S[i] == 'E') e++;
    }

    if (!n && s || n && !s || !w && e || w && !e) {
        cout << "No" << endl;
    }
    else cout << "Yes" << endl;
    
    return 0;
}

Measured memory_bytes: 256
n = int(input())
dat = []
for _ in range(n):
    x, l =map(int, input().split())
    dat.append([x-l, x+l])
dat.sort(key=lambda x: x[1])
#print(dat)
prevr = -99999999999999999
res = 0
for i in range(n):
    if dat[i][0] >= prevr:
        prevr = dat[i][1]
        res += 1
print(res)



Measured memory_bytes: 63192
use std::collections::HashMap;
use proconio::input;

const DIVISOR: i64 = 1000000007;

fn main() {
    input! {
        s: u32
    }

    if s < 3 {
        println!("{}", 0);
        return;
    }

    let mut memo: HashMap<u32, i64> = HashMap::new();

    println!("{}", resolve(s, &mut memo));    
}

fn resolve(s: u32, memo: &mut HashMap<u32, i64>) -> i64 {
    if s == 0 {
        return 1;
    } else if s < 3 {
        return 0;
    }
    return match memo.get(&s) {
        Some(&x) => x,
        None => {
            let res = (3..=s).map(|x| {
                resolve(s - x, memo)
            }).sum::<i64>() % DIVISOR;
            memo.insert(s, res);
            res
        },
    }
}

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

using namespace std;
const int MOD = 1e6 * 2 + 7;


int main() {
    int n;
    cin >> n;
    int d = n%10;
    if (d == 2 || d == 4 || d == 5 || d == 7 || d == 9) {
        cout << "hon" << "\n";
    }
    else if (d == 0 || d == 1 || d == 6 || d == 8) {
        cout << "pon" << "\n";
    }
    else if (d == 3) {
        cout << "bon" << "\n";
    }
    

    return 0;
}


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

int main() {
    int N;
    cin >> N;
    vector<int> v(100002, 0);
    int a, b;
    for (int i=0; i<N; ++i) {
        cin >> a >> b;
        v[a] ++;
        v[b+1] --;
    }
    int mx = 0;
    for (int i=1; i<=N+1; ++i) {
        v[i] += v[i-1];
        if (v[i]+1 >= i) {
            mx = max(mx, i-1);
        }
    }
    cout << mx << endl;
    return 0;
}


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

int main() {
  int n, flag = 0;
  int count = 0;
  int a[N];
  cin >> n;
  for(int i = 0; i < n; i++){
    cin >> a[i];
  }
  while(flag == 0){
	for(int i = 0; i < n; i++){
	  if(a[i]%2 == 0){
		a[i] /= 2;
      }else{
		flag = 1;
        break;
      }
    }
    if(flag == 1){
	  break;
    }
    count++;
  }
  cout << count << endl;
}



Measured memory_bytes: 256
import sys
from collections import defaultdict

sys.setrecursionlimit(10 ** 6)
INF = float("inf")
MOD = 10 ** 9 + 7


def input():
    return sys.stdin.readline().strip()


def main():
    N = int(input())
    if N == 1:
        print(1)
        return

    X = []
    Y = []
    for _ in range(N):
        x, y = map(int, input().split())
        X.append(x)
        Y.append(y)

    cnt = defaultdict(int)
    for i in range(N):
        for j in range(N):
            if i == j:
                continue

            dx = X[j] - X[i]
            dy = Y[j] - Y[i]
            cnt[(dx, dy)] += 1

    cnt = sorted(cnt.items(), key=lambda x: x[1], reverse=True)
    ans = N - cnt[0][1]
    print(ans)


if __name__ == "__main__":
    main()


Measured memory_bytes: 3948
N, A, B, C = map(int, input().split())
l = [int(input()) for i in range(N)]
inf = 10 ** 9

def dfs(cur, a, b, c):
    if cur == N:
        return abs(a-A)+abs(b-B)+abs(c-C) - 30 if min(a, b, c) >0 else inf
    ret0 = dfs(cur+1, a,b,c)
    ret1 = dfs(cur+1, a+l[cur], b, c) + 10
    ret2 = dfs(cur+1, a, b+l[cur], c) +10
    ret3 = dfs(cur+1, a,b,c+l[cur]) +10
    return min(ret0, ret1, ret2, ret3)

print(dfs(0, 0, 0, 0))

Measured memory_bytes: 3064
import math


def solve(r):
    return math.pi * r * 2


def main():
    r = int(input())
    res = solve(r)
    print(res)


def test():
    assert abs(solve(1) - 6.28318530717958623200) < 0.01
    assert abs(solve(73) - 458.67252742410977361942) < 0.01


if __name__ == "__main__":
    test()
    main()


Measured memory_bytes: 9180
using System;
using System.Linq;

namespace _038_PokerHand
{
	class Program
	{
		static void Main ( string[] args )
		{
			string inputStr;

			while ((inputStr = Console.ReadLine ()) != null)
			{
				int[] cards = inputStr.Split (',').Select (int.Parse).ToArray ();

				string result = Poker.Judge (cards);

				Console.WriteLine (result);
			}
		}
	}

	static class Poker
	{
		private static int[] cardArray { set; get; }

		public static string Judge ( int[] cards )
		{
			cardArray = new int[13];
			foreach (var item in cards)
			{
				cardArray[item - 1]++;
			}

			if (IsFourCard ())
			{
				return "four card";
			}
			else if (IsFullHouse ())
			{
				return "full house";
			}
			else if (IsStraight (cards))
			{
				return "straight";
			}
			else if (IsThreeCard ())
			{
				return "three card";
			}
			else if (IsTwoPair ())
			{
				return "two pair";
			}
			else if (IsOnePair ())
			{
				return "one pair";
			}
			else
			{
				return "null";
			}
		}

		private static bool IsFourCard ()
		{
			if (cardArray.Any (item => item == 4))
				return true;
			else
				return false;
		}
		private static bool IsFullHouse ()
		{
			if (cardArray.Any (item => item == 2) && cardArray.Any (item => item == 3))
				return true;
			else
				return false;
		}
		private static bool IsStraight ( int[] cards )
		{
			int aceIndex = Array.IndexOf (cards, 1);

			if (aceIndex != -1)
			{
				bool isFindKing = cards.Any (item => item == 13);

				if (isFindKing)
				{
					cards[aceIndex] += 13;
				}
			}

			Array.Sort (cards);

			if (cards[0] + 1 == cards[1] &&
				cards[1] + 1 == cards[2] &&
				cards[2] + 1 == cards[3] &&
				cards[3] + 1 == cards[4])
			{
				return true;
			}

			return false;
		}
		private static bool IsThreeCard ()
		{
			if (cardArray.Any (item => item == 3))
				return true;
			else
				return false;
		}
		private static bool IsTwoPair ()
		{
			if (cardArray.Count (item => item == 2) == 2)
				return true;
			else
				return false;
		}
		private static bool IsOnePair ()
		{
			if (cardArray.Any (item => item == 2))
				return true;
			else
				return false;
		}
	}
}

Measured memory_bytes: 9876
#include "bits/stdc++.h"
		using namespace std;
		#define sim template < class c
		#define ris return * this
		#define dor > debug & operator <<
		#define eni(x) sim > typename \
		  enable_if<sizeof dud<c>(0) x 1, debug&>::type operator<<(c i) {
		sim > struct rge { c b, e; };
		sim > rge<c> range(c i, c j) { return rge<c>{i, j}; }
		sim > auto dud(c* x) -> decltype(cerr << *x, 0);
		sim > char dud(...);
		struct debug {
		#ifdef LOCAL
		~debug() { cerr << endl; }
		eni(!=) cerr << boolalpha << i; ris; }
		eni(==) ris << range(begin(i), end(i)); }
		sim, class b dor(pair < b, c > d) {
		  ris << "(" << d.first << ", " << d.second << ")";
		}
		sim dor(rge<c> d) {
		  *this << "[";
		  for (auto it = d.b; it != d.e; ++it)
			*this << ", " + 2 * (it == d.b) << *it;
		  ris << "]";
		}
		#else
		sim dor(const c&) { ris; }
		#endif
		};
		#define imie(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "
		#define cool ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
			#define int  long long int
			#define pb push_back
			#define fe first
			#define lb lower_bound 
			#define ub upper_bound
			#define pii pair<pair<int,int>,pair<int,int> >
			#define se second
			#define endl "\n"
			#define pi pair<int, int>
			#define mi          map<int,int>
			#define mii         map<pi,int>
			#define vi vector<int> 
			#define vvi vector<vi>
			#define bs   binary_search
			#define rep(i,a,b) for(int i=a;i<b;i++)
			#define rep1(i,a,b) for(int i=a;i<=b;i++)	
			#define all(c) (c).begin(),(c).end()
			#define sz(x)       (int)x.size() 
			#define PI 3.14159265358979323846
			
			 const int N =1e5;
			
			 int mod= 1e9+7;
			 int dx[4]={0,0,+1,-1};
			 int dy[4]={+1,-1,0,0};  
			 
			 
			int po(int a, int b) {
				a %= mod;
				int res = 1;
				while (b > 0) {
					if (b & 1)
						res = (res * a) % mod;
					a =(a*a) % mod;
					b >>= 1;
				}
				 return res;	
			   }
	  
			
			 void solve(){
				     int x;
				     cin>>x;
				     int sm=0;
				     sm+=(x/500)*1000;
				     x%=500;
				     sm+=(x/5)*5;
				     cout<<sm<<endl;			     
				 
			 }
			
			  int32_t main() {
				cool;
				int t=1;
				//cin>>t;
				while(t--)
				   solve();
				   
				   
				   return 0;	   
			   }


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <queue>
#include <map>
#include <set>
#include <cmath>
#include <cstdio>
#include <cstring>
using namespace std;
typedef long long int ll;
#define rep(i, a, n) for (ll i = a; i < (ll)(n); i++)
long long GCD(long long a, long long b) { return b ? GCD(b, a%b) : a; }
long long LCM(long long a, long long b)  {return a/GCD(a,b)*b;}
int n,m;
int dp[100001];
int yes[100001];
int maxdp=0;
vector <int> xy[100001];
int dpsearch(int i)
{
    if(yes[i]!=0)
        return dp[i];
    if(xy[i].size()==0)
    {
        dp[i]=0;
        yes[i]=1;
    }
    else
    {
        for(auto j=xy[i].begin();j!=xy[i].end();j++)
        {
            dp[i]=max(dp[i],dpsearch(*j)+1);
        }
        yes[i]=1;
    }
    maxdp=max(maxdp,dp[i]);
    return dp[i];
}

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    cin>>n>>m;
    memset(dp,0,sizeof(dp));
    memset(yes,0,sizeof(yes));
    for(int i=0;i<m;i++)
    {
        int x,y;
        cin>>x>>y;
        xy[y].push_back(x);
    }
    for(int i=1;i<=n;i++)
    {
        if(yes[i]!=0)
            continue;
        dp[i]=dpsearch(i);
    }
    
    cout<<maxdp<<endl;
    return 0;
}
 



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

using namespace std;
typedef long long ll;
typedef pair<ll, ll> p_ll;

template<class T>
void debug(T itr1, T itr2) { auto now = itr1; while(now<itr2) { cout << *now << " "; now++; } cout << endl; }
#define repr(i,from,to) for (int i=(int)from; i<(int)to; i++)
#define rep(i,N) repr(i,0,N)
#define per(i,N) for (int i=(int)N-1; i>=0; i--)

const ll MOD = pow(10,9)+7;
const ll LLINF = pow(2,61)-1;
const int INF = pow(2,30)-1;


int main() {
  string S; cin >> S;
  int l = S.length();
  string result = S.substr(0,l-8);
  cout << result << endl;
  return 0;
}

Measured memory_bytes: 256
import java.io.IOException;
import java.io.BufferedReader;
import java.io.InputStreamReader;

class Main {
    public static void main(String[] args) throws IOException {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

        String line;
        while ((line = br.readLine()) != null) {
            double sum = 0;
            double[] arr = new double[10];
            arr[0] = Double.parseDouble(line);
            sum += arr[0];
            for (int i = 1; i < 10; i++) {
                if (i % 2 == 0) {
                    arr[i] = arr[i - 1] / 3;
                } else {
                    arr[i] = arr[i - 1] * 2;
                }
                sum += arr[i];
            }
            System.out.printf("%.8f%n", sum);
        }
    }
}


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

using VI = vector<int>;
using VVI = vector<VI>;
using PII = pair<int, int>;
using LL = long long;
using VL = vector<LL>;
using VVL = vector<VL>;
using PLL = pair<LL, LL>;
using VS = vector<string>;

#define ALL(a)  begin((a)),end((a))
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define SZ(a) int((a).size())
#define SORT(c) sort(ALL((c)))
#define RSORT(c) sort(RALL((c)))
#define UNIQ(c) (c).erase(unique(ALL((c))), end((c)))

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

#define FF first
#define SS second
template<class S, class T>
istream& operator>>(istream& is, pair<S,T>& p){
  return is >> p.FF >> p.SS;
}
template<class S, class T>
ostream& operator<<(ostream& os, const pair<S,T>& p){
  return os << p.FF << " " << p.SS;
}
template<class T>
void maxi(T& x, T y){
  if(x < y) x = y;
}
template<class T>
void mini(T& x, T y){
  if(x > y) x = y;
}


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

int main(){
  LL N, M;
  cin >> N >> M;
  vector<vector<PLL>> G(N);
  REP(i,M){
	LL a, b, c;
	cin >> a >> b >> c;
	--a;
	--b;
	G[a].EB(b, c);
  }

  VL dist(N, -INF);
  dist[0] = 0;
  REP(i,N+1){
	REP(j,N){
	  for(PLL& e: G[j]){
		maxi(dist[e.FF], dist[j] + e.SS);
	  }
	}
  }

  VL dist2 = dist;
  REP(i,N*2+1){
	REP(j,N){
	  for(PLL& e: G[j]){
		maxi(dist2[e.FF], dist2[j] + e.SS);
	  }
	}
  }
  if(dist[N-1] < dist2[N-1])
	cout << "inf" << endl;
  else
	cout << dist[N-1] << endl;
  
  return 0;
}


Measured memory_bytes: 384
#include<iostream>
#include<vector>
#include<cstring>
using namespace std;
int main(){
    int n,ans=0,ans2=0,ba=0,first=0,last=0;
    cin>>n;
    char s[n][11];
    bool lastA[n]={},firstB[n]={};
    for(int i=0;i<n;i++){
        cin>>s[i];
        if(s[i][0]=='B')firstB[i]=true;


        if(strlen(s[i])==2)if(s[i][1]=='A')lastA[i]=true;
        if(strlen(s[i])==2)continue;

        for(int j=0;s[i][j+2]!='\0';j++){
            //cout<<s[i][j]<<"test"<<endl;
         
            if(s[i][j]=='A'&&s[i][j+1]=='B')ans++;
            if(s[i][j+3]=='\0'&&s[i][j+2]=='A')lastA[i]=true;
        }
    }

    for(int i=0;i<n;i++){if(firstB[i]&&lastA[i])ba++;if(firstB[i])first++;if(lastA[i])last++;}
    //cout<<ba<<first<<last<<endl;
    if(ba){
        ans2+=ba-1;
        if(first-ba)ans2++;
        if(last-ba)ans2++;
        ans2+=max(min(first-ba,last-ba)-1,0);
    }
    else ans2+=min(first,last);
    //cout<<ans<<endl;
    //cout<<ans2<<endl;
    cout<<ans+ans2<<endl;
    return 0;
}

Measured memory_bytes: 384
#include <stdio.h>
int main(void){
    long long num[100005]={0},a,b,m;
    int n,i;
    scanf("%d%lld",&n,&m);
    for(i=0;i<n;i++){
        scanf("%lld%lld",&a,&b);
        num[a-1]+=b;
    }
    i=0;
    while(1){
        m-=num[i];
        if(m<=0){
            printf("%d",i+1);
            break;
        }
        i++;
    }
    return 0;
}


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

int n, k;

double kitaichi(vector<int> p, int start, int k){
  double ans;
  for (int i = 0; i < k; i++){
    double sum = 0;
    for (int j = 1; j <= p[start+i]; j++){
      sum += j;
    }
    ans += sum/p[start+i];
  } 
  return ans;
}
 
int main() {
  cin >> n >> k;
  vector<int> p(n);
  for (int i = 0; i < n; i++){
    cin >> p.at(i);
  }
  int sum = 0;
  int start;
  int s = 0;
  for (int i = 0; i  < 1; i++){
    for (int j = 0; j < k; j++){ 
      s += p.at(i+j);
    }
    sum = s;
    start = i;
  }
  for (int i = 1; i + k <= n; i++){
    s += p.at(i+k-1);
    s -= p.at(i-1);
    if (sum < s){
      sum = s;
      start = i;
    }
  }
  cout << fixed << setprecision(15) << kitaichi(p, start, k) << endl;
}

Measured memory_bytes: 4804
#include <bits/stdc++.h>
#define sz(c)      int(c.size())
#define rep(i,a,b) for (int i=a; i<(b); ++i)
#define per(i,a,b) for (int i=(b)-1; i>=(a); --i)
using namespace std;
using ll = long long;

vector<int> solve(int n,int a,int b) {
	if (__builtin_popcount(a^b)%2==0) return {};
	
	if (a==b) return {a};

	if (n==1) return {a,b};

	int bit=1<<(n-1);
	if ((a&bit)==(b&bit)) {
		auto r1=solve(n-1,a,b);
		auto r2=solve(n-1,a^bit,r1[1]^bit);
		r1.insert(r1.begin()+1,r2.begin(),r2.end());
		return r1;
	} else {
		auto r1=solve(n-1,a,b^1^bit);
		auto r2=solve(n-1,b^1,b);
		r1.insert(r1.end(),r2.begin(),r2.end());
		return r1;
	}
}

int main() {
	cin.tie(0);
	ios_base::sync_with_stdio(0);
	cout<<fixed<<setprecision(10);

	int N,A,B;
	cin>>N>>A>>B;
	
	auto res=solve(N,A,B);
	if (res.empty()) {
		cout<<"NO\n";
	} else {
		cout<<"YES\n";
		for (int x:res) cout<<x<<" ";
		cout<<"\n";
	}
}


Measured memory_bytes: 1648