akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;

#define ll long long
#define F(i,m,n) for(ll i=m;i<n;i++)
#define Fr(j,n,m) for(ll j=n;j>=m;j--)
#define vll vector<ll>
#define pll pair<ll,ll>
#define ff first
#define ss second
#define vpll vector< pll >
#define tlll tuple < ll ,ll,ll >
/*-------------------------------------*---------------------------------------*/

#define godspeed ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define deb(x) cout << #x << "=" << x << endl
#define cout_array(a) cout<<#a<<"=";for(auto x: a){ cout<<x<<" ";}cout<<endl

ll gcd(ll a,ll b){
    return (b?gcd(b,a%b):a);
}
const ll MAX_PRIME = 1e9+7;
const ll INF = 1e18;


/*I NEED YOU TO WORK FOR TWO HOURS ON THIS NO MATTER WHAT....THE RESULT DOESN'T MATTER.....ITS ALL ABOUT YOUR EFFORTS.
---------------------------------------------------------------------------------------------------------------------*/

ll fast_pow(ll x,ll y,ll z){
    if(y==0)return 1%z;
    else if(y==1)return x%z;
    if(y%2==0){
        ll res = fast_pow(x,y/2,z);
        return (res*res)%z;
    }
    else{
        ll res = fast_pow(x,y/2,z);
        ll temp = (res*res)%z;
        return ((x%z)*temp)%z;
    }
}

int main() {
    godspeed
    string string1;
    cin>>string1;
    ll ans = 0;
    for(auto x: string1){
        ans += (x-'0');
        ans%=9;
    }
    if(ans==0)cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
    return 0;
}

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

int main() {
	int n;
	cin >> n;
	int mx = 0, x;
	long long ans = 0;
	for (int i = 0; i < n; i++) {
		cin >> x; mx = max(mx, x);
		ans += mx - x;
	}
	cout << ans << endl;
}


Measured memory_bytes: 3632
#include <cstdio>
#include <cmath>

#include <iostream>

#include <string>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <stack>
#include <deque>

#include <algorithm>

using namespace std;

int main(){
	string s;
	int res = 0;
	cin >> s;
	for (int i = 1; i < s.size(); i++) {
		if (s[i] == s[i-1]) {
			s[i] = 1 - (s[i-1] - '0') + '0';
			res++;
		}
	}
	cout << res << endl;
}

Measured memory_bytes: 512
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <numeric>
#include <string>
#include <cstdio>
#include <cstring>
#include <queue>
#include <stack>
#include <set>
#include <cmath>
#include <bitset>

typedef long long ll;
using namespace std;

#define FALSE printf("false\n");
#define TRUE printf("true\n");
#define all(x) (x).begin(),(x).end()
#define print(x) cout<<(x)<<endl
#define rep(i,n) for(int i = 0;i < ((int)(n));++i)
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define SUM(vec) accumulate(all(vec),0LL)
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );
#define test(a) cout<<"line:"<<__LINE__<<"["<<(#a)<<": "<<(a)<<"]"<<endl

const int INF = 1e9+7;
const ll INFL = 9*1e18;

ll inline digit(ll num){int tmp = 0;while(num){tmp++;num/=10;}return tmp;}
template<typename T>inline T digitSum(T num){T sum = 0;while(num){sum+=num%10;num/=10;}return sum;} // 各桁の和
template<typename T>inline T gcd(T a,T b){if(b == 0)return a;return gcd(b,a%b);}
template<typename T>inline T lcm(T a, T b){T g = gcd(a,b);return a/g*b;}
template<typename T>inline T power(T a,T b){T tmp=1;rep(i,b){tmp*=a;}return tmp;}


bool isOk(ll key,ll value){
  return key >= value;
}

ll binary_search(vector<ll> a,ll key){
  ll ok = a.size()-1;
  ll ng = 0;

  while(abs(ok - ng) > 1){
    ll mid = (ok + ng) / 2;
    if(isOk(key,a[mid]))ok = mid;
    else ng = mid;
  }
  return ok;
}

bool isPrime(ll n) {
	for (int i = 2; n >= i * i; ++i) {
		if(!(n % i))return false;
	}
  return true;
}

int main() {
  cin.tie(0); ios::sync_with_stdio(0);
  int a,b,c;cin>>a>>b>>c;
  int ans = a+b+c;
  int tmp = max(a,max(b,c));
  ans += tmp * 9;
  print(ans);
  return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<math.h>
#include<vector>
#include<algorithm>
#include<iomanip>
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)
#define EACH(x,a) for(auto& (x):(a))
#define ALL(obj) (obj).begin(),(obj).end()
#define Yes(n) cout<<((n)?"Yes":"No")<<endl;
#define CO(x) cout<<(x)<<endl;
#define COSP(x) cout<<(x)<<" ";
#define DICIMAL(x) fixed<<setprecision(x)
using namespace std;
using ll=long long;
using vi=vector<int>;
using pii=pair<int,int>;
const int INF=1e9;
const ll LINF=1e18;
int gcd(int a,int b){return b?gcd(b,a%b):a;}

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

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

  vector<pair<int, double>> divs;
  int i=0;
  divs.push_back(make_pair(-1,1000000));
  while(true){
    divs.push_back(make_pair(i,K/pow(2,i)));
    if(K/pow(2,i)<1) break;
    ++i;
  }
  reverse(ALL(divs));

  vi nums(i+1,0);
  int index = 0;
  FOR(num,1,N+1){
    while(num>=divs[index+1].second) ++index;
    ++nums[index];
  }

  double ans=0;
  REP(j,i+1){
    ans += nums[j] * pow(0.5, divs[j].first);
  }
  ans /= (double)N;

  cout<< DICIMAL(12) << ans << endl;
  return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
#define LEN 100005

typedef struct pp{
  char name[100];
  int time;
}P;

P Q[LEN+1];
int head, tail, n;

void enqueue(P x){
  Q[tail]=x;
  tail=(tail+1)%LEN;
  }

P dequeue(){
    P d;
    d=Q[head];
    head=(head+1)%LEN;
    return d;
}

void initialize(){
  head=tail=0;
}



int main(){
  int elaps = 0, c;
  int i, q;
  P deq;
  //プロセスの数と実行時間を入力
  scanf("%d %d", &n, &q);
    head=1;
    tail=n+1;
  //各プロセスとそれぞれの実行時間
  for ( i = 1; i <= n; i++){
    scanf("%s", Q[i].name);
    scanf("%d", &Q[i].time);
  }

  while(head!=tail){
  deq=dequeue();
  if(q<deq.time){
      c=q;
  }else{
      c=deq.time;
  }
  deq.time-=c;
  elaps+=c;
  if(deq.time>0){
      enqueue(deq);
  }else{
      printf("%s %d\n",deq.name,elaps);
  }
  }

  
  return 0;
}



Measured memory_bytes: 11868
import java.io.BufferedWriter;
import java.io.FileWriter;
import java.io.InputStream;
import java.io.PrintWriter;
import java.lang.reflect.Array;
import java.math.BigDecimal;
import java.math.MathContext;
import java.util.ArrayDeque;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.Comparator;
import java.util.Deque;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.Map.Entry;
import java.util.Objects;
import java.util.PriorityQueue;
import java.util.Queue;
import java.util.Random;
import java.util.Scanner;
import java.util.Set;
import java.util.Stack;
import java.util.TreeMap;
import java.util.TreeSet;

import static java.util.Comparator.*;

public class Main {
    public static void main(String[] args) {
        PrintWriter out = new PrintWriter(System.out);
        Solver solver = new Solver(System.in, out);
        solver.solve();
        out.close();
    }
}
class Solver {
	Scanner sc;
	PrintWriter out;
    public Solver(InputStream in, PrintWriter out) {
    	sc = new Scanner(in);
    	this.out = out;
    }
    // ======================================================================
    public void solve() {
    	int N = ni();
    	List<PPL> list = new ArrayList<>();
    	long x, l;
    	for (int i = 0; i < N; i++) {
			x = ni();
			l = ni();
			list.add(new PPL(x - l, x + l));
		}
    	list.sort(comparing(PPL::getR));
    	int ans = 0;
    	long end = -1000000010;
    	for(PPL pp : list) {
    		if(pp.getL() >= end) {
    			ans++;
    			end = pp.getR();
    		}
    	}
    	out.println(ans);
    }
    class PPL {
    	long L, R;
    	public PPL(long l, long r) {
    		L = l;  R = r;
    	}
		public long getL() {
			return L;
		}
		public void setX(long l) {
			L = l;
		}
		public long getR() {
			return R;
		}
		public void setR(long r) {
			R = r;
		}
    }
    // ------------------------------------------
    // 入力
    // ------------------------------------------
    public int ni() {
    	return sc.nextInt();
    }
    public long nl() {
    	return sc.nextLong();
    }
    public String ns() {
    	return sc.next();
    }
    public char[] nc() {
    	return sc.next().toCharArray();
    }
    public int[] ndi(int N) {
    	int[] ans = new int[N];
    	for (int i = 0; i < N; i++) {
			ans[i] = ni();
		}
    	return ans;
    }
    public long[] ndl(int N) {
    	long[] ans = new long[N];
    	for (int i = 0; i < N; i++) {
			ans[i] = nl();
		}
    	return ans;
    }
    public String[] nds(int N) {
    	String[] ans = new String[N];
    	for (int i = 0; i < N; i++) {
			ans[i] = ns();
		}
    	return ans;
    }
    public char[][] ndc(int N) {
    	char[][] ans = new char[N][];
    	for (int i = 0; i < N; i++) {
			ans[i] = nc();
		}
    	return ans;
    }
    public int[][] nddi(int N, int S) {
    	int[][] ans = new int[N][S];
    	for (int i = 0; i < N; i++) {
			for (int j = 0; j < S; j++) {
				ans[i][j] = ni();
			}
		}
    	return ans;
    }
}


Measured memory_bytes: 93960
using System;

namespace ABC147A
{
    class Program
    {
        static void Main(string[] args)
        {
            string[] word = Console.ReadLine().Split(' ');
            int a = int.Parse(word[0]);
            int h = int.Parse(word[1]);
            int n = int.Parse(word[2]);

            int s = a + h + n;

            if (s >= 22)
                Console.WriteLine("bust");
            else if (s <=21)
                Console.WriteLine("win");
            

        }
    }
}


Measured memory_bytes: 27436
#include<bits/stdc++.h>
#define IOS ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
using namespace std;
	const int maxn=500000;
	

	int main(){
		IOS
		string s;
		int n,k;
		cin>>n>>k;
		cin>>s;
		s[k-1]=s[k-1]-'A'+'a';
		cout<<s<<endl;
		
		
		
	} 

Measured memory_bytes: 256
from collections import Counter
def main():
    n = int(input())
    S = [input() for _ in range(n)]
    c = Counter(S).most_common()
    V = c[0][1]
    ans = [k for k, v in c if v == V]
    [print(a) for a in sorted(ans)]

if __name__ == '__main__':
    main()


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

typedef long long lnt;
char a[310][310];
bool ok[310][310];
int n;
void ch(int x,int y){
    bool flag=true;
    for(int k=0;k<n;k++){
        if(a[x][(y+k)%n]!=a[(x+k)%n][y]){
            flag=false;
            break;
        }
    }
    if(flag) ok[x][y]=true;
}
int main(){
    scanf("%d",&n);
    for(int k=0;k<n;k++){
        scanf("%s",a[k]);
    }
    for(int k=0;k<n;k++){
        for(int i=0;i<n;i++){
            ch(k,i);
        }
    }
    int ans=0;
    for(int k=0;k<n;k++){
        bool flag=true;
        for(int i=0;i<n;i++){
            if(!ok[i][(k+i)%n]){
                flag=false;
                break;
            }
        }
        if(flag) ans++;
    }
    printf("%d",ans*n);
}
        

Measured memory_bytes: 384
import java.util.*; 
import java.io.*;
 
public class Main {
	 static long lowerBound(int[] array, int key) {
		int start = -1;
		int end = array.length;
 
		while (end  > 1 + start) {
			int mid = (start + end) / 2;
			if (array[mid] < key) {
				start = mid;
			} else {
				end = mid;
			}
		}
 
		return start+1;
 
	}
	 static long upperBound(int[] array, int key) {
		int start = -1;
		int end = array.length;
 
		while (end > 1 + start) {
			int mid = (end + start) / 2;
			if (array[mid] > key) {
				end = mid;
			} else {
				start = mid;
			}
		}
 
		return end;
	}
	public static void main(String[] args) {
		InputReader in = new InputReader(System.in);
	    int n = in.readInt();
	    int a[] = new int[n]; 
	    int b[] = new int[n]; 
	    int c[] = new int[n]; 
	    
	    for(int i = 0; i<n; i++) a[i] = in.readInt();
	    for(int i = 0; i<n; i++) b[i] = in.readInt();
	    for(int i = 0; i<n; i++) c[i] = in.readInt();
	    
	    Arrays.sort(a);
	    Arrays.sort(c); 
	    long ans = 0; 
	    for(int i = 0; i<n; i++) {
	    	ans += (lowerBound(a,b[i])) * (n - upperBound(c,b[i])); 
	    }
	    System.out.println(ans); 
	}
}

class InputReader {

	private InputStream stream;
	private byte[] buf = new byte[1024];
	private int curChar;
	private int numChars;
	private SpaceCharFilter filter;

	public InputReader(InputStream stream) {
		this.stream = stream;
	}

	public int read() {
		if (numChars == -1)
			throw new InputMismatchException();
		if (curChar >= numChars) {
			curChar = 0;
			try {
				numChars = stream.read(buf);
			} catch (IOException e) {
				throw new InputMismatchException();
			}
			if (numChars <= 0)
				return -1;
		}
		return buf[curChar++];
	}

	public int readInt() {
		int c = read();
		while (isSpaceChar(c))
			c = read();
		int sgn = 1;
		if (c == '-') {
			sgn = -1;
			c = read();
		}
		int res = 0;
		do {
			if (c < '0' || c > '9')
				throw new InputMismatchException();
			res *= 10;
			res += c - '0';
			c = read();
		} while (!isSpaceChar(c));
		return res * sgn;
	}

	public String readString() {
		int c = read();
		while (isSpaceChar(c))
			c = read();
		StringBuilder res = new StringBuilder();
		do {
			res.appendCodePoint(c);
			c = read();
		} while (!isSpaceChar(c));
		return res.toString();
	}

	public long readLong() {
		int c = read();
		while (isSpaceChar(c)) {
			c = read();
		}
		int sgn = 1;
		if (c == '-') {
			sgn = -1;
			c = read();
		}
		long res = 0;
		do {
			if (c < '0' || c > '9') {
				throw new InputMismatchException();
			}
			res *= 10;
			res += c - '0';
			c = read();
		} while (!isSpaceChar(c));
		return res * sgn;
	}
	
	public boolean isSpaceChar(int c) {
		if (filter != null)
			return filter.isSpaceChar(c);
		return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1;
	}

	public String next() {
		return readString();
	}

	public interface SpaceCharFilter {
		public boolean isSpaceChar(int ch);
	}
}


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

using namespace std;

typedef long long llint;
const long long MOD = 1e9 + 7;

template <typename T>
T modpow(T m, T n, const T &p) {
  if (n == 0) return 1;
  T ret = modpow(m * m % p, n / 2, p);
  if (n % 2) ret *= m;
  return ret % p;
}

/* nを素因数分解する */
map<long long, long long> primefactor(long long n) {
  map<long long, long long> ret;
  for (long long i = 2; i * i <= n; i++) {
    while (n % i == 0) {
      ret[i]++;
      n /= i;
    }
  }
  if (n != 1) ret[n] = 1;
  return ret;
}

int main() {
  int N;
  cin >> N;
  vector<map<llint, llint>> primes;
  vector<llint> A(N);
  for (int i = 0; i < N; i++) {
    cin >> A[i];
    auto v = primefactor(A[i]);
    primes.emplace_back(v);
  }

  map<llint, llint> L;
  for (int i = 0; i < N; i++) {
    for (auto &v : primes[i]) {
      llint p = v.first;
      llint q = v.second;
      L[p] = max(L[p], q);
    }
  }

  llint lcm = 1;
  for (auto &v : L) {
    lcm *= modpow(v.first, v.second, MOD);
    lcm %= MOD;
  }

  llint ans = 0;
  for (int i = 0; i < N; i++) {
    ans += (lcm * modpow(A[i], MOD - 2, MOD)) % MOD, ans %= MOD;
  }

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 3896
import java.io.IOException;
import java.util.ArrayList;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) throws IOException {
//		BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
//		String W	 = in.readLine();
//		int num = Integer.parseInt(W.split(" ")[0]);

		Scanner sc = new Scanner(System.in);
		int A = sc.nextInt();
		int B = sc.nextInt();
		int C = sc.nextInt();
		int K = sc.nextInt();

		if(K <= A) {
			System.out.println(K);
		}else if(K<=A+B){
			System.out.println(A);
		}else {
			System.out.println(A-(K-A-B));
		}

	}

	//	//二分探索
	//k <= num となる最小の配列要素kのインデックスを返す
	static private int binarySearch(long num, long[] orderedArray){
		int lowerBorder = -1;
		int upperBorder = orderedArray.length;
		int mid;

		while(upperBorder - lowerBorder >1) {
			mid = (upperBorder + lowerBorder)/2;
			if(orderedArray[mid]<=num) {
				lowerBorder = mid;
			}else {
				upperBorder = mid;
			}
		}
		return lowerBorder;
	}

	//二分探索
	//k <= num となる最小のList要素kのインデックスを返す
	static private int binarySearch(long num, ArrayList<Long> orderedList){
		int lowerBorder = -1;
		int upperBorder = orderedList.size();
		int mid;

		while(upperBorder - lowerBorder >1) {
			mid = (upperBorder + lowerBorder)/2;
			if(orderedList.get(mid)<=num) {
				lowerBorder = mid;
			}else {
				upperBorder = mid;
			}
		}
		return lowerBorder;
	}

	//aとbの最小公倍数を求める
	public static int gcd(int a, int b) {
        return b == 0 ? a: gcd(b, a % b);
	}
	public static long gcd(long a, long b) {
        return b == 0 ? a: gcd(b, a % b);
	}



}


Measured memory_bytes: 35712
#include        <map>
#include      <cmath>
#include      <queue>
#include     <string>
#include     <cstdio>
#include     <vector>
#include    <cstring>
#include   <iostream>
#include  <algorithm>
using namespace std;
#define ll long long
const ll inf = 0x3f3f3f3f3f3f3f3f;
const int maxn = 100+5;
const ll mod = 1e9+7;

int main(){
    ll n , m, ans = 0;
    scanf("%lld%lld",&n,&m);
    if(m==0){
        printf("%lld\n",n*n);
        return 0;
    }
    for(ll b = m+1;b<=n;++b){
        ans += n/b*(b-m);
        ans += max(0ll,n%b-m+1);
    }
    printf("%lld\n",ans);
    return 0;
}


Measured memory_bytes: 256
input_date_list = ['SUN', 'MON', 'TUE', 'WED', 'THU', 'FRI', 'SAT']
S = input()
today_date_list = ['日', '月', '火', '水', '木', '金', '土']
s1 = input_date_list.index(S)
today_date = (today_date_list[s1])
s2 = 7 - s1
print(s2)

#print("今日は{0}曜日です。".format(today_date)+"次の日曜日は{0}日後です".format(s2))


Measured memory_bytes: 8956
/* Sometimes you win , sometimes you learn . */
/* Sometimes you win , sometimes you learn . */
#include <bits/stdc++.h>
#define lp(i , N) for(ll i = 0; i < ll (N) ; i++)
#define FAST ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0);
#define debug(x) cout<<" [ " << #x << " is: " << x << " ] "<<endl;
using namespace std;
typedef long long ll;
typedef long double ld;
const long double EPS = 1e-6;
const long double pi = acos(-1);
ll lcm(ll a , ll b){
    return a * b / __gcd(a , b);
}
int main(){
    FAST
    string s;
    cin >> s;
    if(s[2] == s[3] && s[4] == s[5]) cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0;
}
/*
[#]=============================================================[#]
         ___    ____              ____          ___ _
        |_ _|  / ___|__ _ _ __   |  _ \  ___   |_ _| |_
         | |  | |   / _` | '_ \  | | | |/ _ \   | || __|
         | |  | |__| (_| | | | | | |_| | (_) |  | || |_
        |___|  \____\__,_|_| |_| |____/ \___/  |___|\__|
                     it's just about time

[#]=============================================================[#]
*/



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(int)(n);++i)
#define repone(i,n) for(int i=1;i<(int)(n);++i)
#define repo(i,o,n) for(int i=o;i<(int)(n);++i)
#define Rep(j,n) for(int j=0;j<(int)(n);++j)
#define Repo(j,o,n) for(int j=o;j<(int)(n);++j)
#define Repone(j,n) for(int j=1;j<(int)(n);++j)
#define all(v) (v).begin(),(v).end()
#define rall(v) (v).rbegin(),(v).rend()
#define int long long
#define pb(a) push_back(a)
#define eraser(v,i) (v).erase(v.begin()+(i))
#define pbpair(a,b) push_back(make_pair(a,b))
#define MOD 1000000007
#define INF 9223372036854775807
#define pairint pair<int,int>
int num[12] = {31,28,31,30,31,30,31,31,30,31,30,31};
bool uru(int checkyear){if(checkyear%4==0){if(checkyear%100!=0||checkyear%400==0)return true;}return false;}
int gcd( int x, int y ){return y ? gcd(y, x%y) : x;}
signed main()
{
int x=0,y=0,z=0,w=0,n=0,m=0;
std::cin >> x;
for(int i=1;i<=x;i++){
  if(i/10==0)y++;
  else if(i/100==0)continue;
  else if(i/1000==0)y++;
  else if(i/10000==0)continue;
  else if(i/100000==0)y++;
}
std::cout << y << '\n';
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
using lint = long long int;

int main() {
    cout << setprecision(10);
    double a, b, x;
    cin >> a >> b >> x;
    double c1 = atan( 2*(a*a*b - x) / (a*a*a) ) / M_PI * 180;
    double c2 = atan( (a*b*b) / (2*x) ) / M_PI * 180;
    if(a*a*b/2 < x) cout << c1 << endl;
    else  cout << c2 << endl;
}

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


int main(){
    ll n,k,a[200005],b[200005],sum=0;
    double ans;
    cin>>n>>k;
    b[0]=0;
    rep(i,n){
        cin>>a[i];
        b[i+1]=b[i]+a[i];
    }
    rep(i,n-k+1){
        if(sum<b[i+k]-b[i]){
            sum=b[i+k]-b[i];
        }
    }
    sum+=k;
    ans=sum/2.0;
    cout << fixed << setprecision(15) << ans << endl;
}

Measured memory_bytes: 6900
n = int(input())
A = [(a, i) for i, a in enumerate(map(int, input().split()))]
A.sort(reverse=True)
dp = [[0]*(n+1) for _ in range(n+1)]
ans = 0
for L in range(n+1):
    for R in range(n+1):
        if n <= L+R-1:
            continue
        a, i = A[L+R-1]
        if 0 <= R-1:
            dp[L][R] = max(dp[L][R], dp[L][R-1]+abs((n-R)-i)*a)
        if 0 <= L-1:
            dp[L][R] = max(dp[L][R], dp[L-1][R]+abs(i-(L-1))*a)
        ans = max(ans, dp[L][R])
print(ans)


Measured memory_bytes: 106144
#include <bits/stdc++.h>
#define int long long
using namespace std;
const int N = 15;
const int INF = 1e9 + 7;

int n, m, x;
vector<vector<int>> a(N, vector<int>(N));
vector<int> c(N);

int32_t main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cin >> n >> m >> x;
	for (int i = 0; i < n; i++)
	{
		cin >> c[i];
		for (int j = 0; j < m; j++)
			cin >> a[i][j];
	}
	int ans = INF;
	for (int mask = 0; mask < (1 << n); mask++)
	{
		vector<int> temp(m);
		int cost = 0;
		for (int i = 0; i < n; i++)
		{
			if ((mask >> i) & 1)
			{
				cost += c[i];
				for (int j = 0; j < m; j++)
					temp[j] += a[i][j];
			}
		}
		bool ok = true;
		for (int j = 0; j < m; j++)
			if (temp[j] < x)
				ok = false;
		if (ok)
			ans = min(ans, cost);
	}
	if (ans != INF)
		cout << ans;
	else
		cout << -1;
	return 0;
}
//11-09-2020 17:10:06

Measured memory_bytes: 3580
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define repo(i,n) for(int i = 1; i < (int)(n); i++)
#define pb push_back
#define mp make_pair
#define np next_permutation
#define umap unordered_map
#define fi first
#define se second
#define all(x) (x).begin(),(x).end()
#define mod 1000000007
#define pi acos(-1.0)
ll gcd(ll x, ll y) { return y ? gcd(y, x % y) : x; }
ll lcm(ll x, ll y) { return x / gcd(x, y) * y; }
ll jou(ll N, ll P){if(P==0) return 1;
    if(P%2==0){ll t = jou(N, P/2);return t*t % mod;
    }return (N * jou(N, P-1)) % mod;}  //jou(n,mod-2)で逆元
//intの最大値2147483647 ≒ 2×10^9
//long longの最大値9223372036854775807 ≒ 9×10^18
//'0'+=16;        で大文字に
//'大文字'+=32;    で小文字に
//  cout << fixed << setprecision (20);   小数点以下2０桁まで
//実行時間制約2秒では２×10^8回くらいまで計算できる


int main() {
  ll n;
  cin>>n;
  
  deque<ll> que;

  que.pb(3);
  que.pb(5);
  que.pb(7);
  
  ll ans=0;
  
  // BFS 開始 (キューが空になるまで探索を行う)
  while (!que.empty()) {
    ll v = que.front(); // キューから先頭頂点を取り出す
    que.pop_front();

    if(v>n) {
      cout << ans << endl;
      return 0; 
    }
    
    string s=to_string(v);
    int m=s.size();
    bool san=false;
    bool go=false;
    bool nana=false;
    rep(i,m){
      if(s[i]=='3') san=true;
      if(s[i]=='5') go=true;
      if(s[i]=='7') nana=true;      
    }
    if(san && go && nana) ans++;
    
    // 新たな白色頂点 nv について距離情報を更新してキューに追加する
    que.pb(v*10+3);
    que.pb(v*10+5);
    que.pb(v*10+7);
  }

}


Measured memory_bytes: 4172
from sys import exit

N, M, C = map(int, input().split())

B = list(map(int, input().split()))

A = [[""] * M] * N

for i in range(N):
    A[i] = list(input().split())

result = 0

for i in range(N):
    score = C
    for j in range(M):
        score += int(A[i][j]) * B[j]
    if score > 0:
        result += 1

print(result)


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

#define ll long long int
#define li int64_t

int main()
{
	int x,y;
	cin>>x>>y;
	if((y-2*x)%2 == 0 && (4*x-y)%2 == 0 && y-2*x >= 0 && 4*x -y >=0)cout<<"Yes";
	else
	{
		cout<<"No";
	}
}

Measured memory_bytes: 3604
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		
		while(true){
			int a = sc.nextInt();
			int b = sc.nextInt();
			if(a == 0 && b == 0) break;
			
			int ways = 0;
			
			for(int i = 1; i <= a; i++){
				for(int j = 1; j <= a; j++){
					for(int k = 1; k <= a; k++){
						if(i != j && j != k && i != k){
							if((i + j + k) == b){
								ways++;
							}
						}
					}
				}
			}

			System.out.println(ways/6);
		}
		
		sc.close();
	}

}

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

#define rep(i, a, b) for (int i = a; i < (int)(b); ++i)
#define rrep(i, a, b) for (int i = b - 1; i >= (int)(a); --i)

using namespace std;

using ll = long long;
using vi = vector<int>;
using vll = vector<ll>;


int main() {
    int n, q, ans = 0;
    cin >> n;

    vi S(n);
    rep(i, 0, n) { cin >> S[i]; }

    cin >> q;
    rep(i, 0, q) {
        int query;
        cin >> query;
        if (*lower_bound(S.begin(), S.end(), query) == query) { ++ans; }
    }
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 3144
N = int(input())
def make_divisors(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)
    return divisors
divisors = make_divisors(N)
ans_list = []
for i in divisors:
    if i-1 == 0:
        pass
    elif N//(i-1) == N%(i-1):
        ans_list.append(i-1)
print(sum(ans_list))

Measured memory_bytes: 3296
//--- pA ---//
import java.util.*;
import java.lang.*;
import java.io.*;
public class Main {
	public static void main (String[] args) throws java.lang.Exception {
		new Solution();
	}
}
class Solution {
	Reader reader;
	public Solution () {
		reader = new Reader();
		while (reader.hasNext()) {
			run_case();
		}
	}

	private void run_case() {
		String str = reader.ns();
		if (str.charAt(2) == str.charAt(3) && str.charAt(4) == str.charAt(5)) {
			System.out.println("Yes");
		} else {
			System.out.println("No");
		}

		return;
	}
}


class Reader {
	BufferedReader br;
	StringTokenizer st;
	public Reader(){
		try {
			br = new BufferedReader(new InputStreamReader(System.in));
			st = new StringTokenizer(br.readLine());
		} catch (Exception e) {
			e.printStackTrace();
		}
	}
	public String next() {
		if (st.hasMoreTokens()) return st.nextToken();
		try {
			st = new StringTokenizer(br.readLine());
		} catch (Exception e) {
			e.printStackTrace();
		}
		return st.nextToken();
	}
	public boolean hasNext() {
		try {
			if (!st.hasMoreTokens() && !br.ready()) return false;
			else return true;
		} catch (Exception e) {
			e.printStackTrace();
		}
		return false;
	}
	public int ni() {return Integer.parseInt(this.next());}
	public String ns() {return this.next();}
}


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

int main(){
	int a,b,count=0;
	cin>>a>>b;
	for(int i=a;i<=b;i++){
		int x=i;
		vector<int> elem(5);
		for(int j=0;j<5;j++){
			elem.at(j)=x%10;
			x/=10;
		}
		if(elem.at(0)==elem.at(4) && elem.at(1)==elem.at(3)){
			count++;
		}
	}
	cout<<count<<endl;
	return 0;
}

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

//#include "atcoder/all"
//using namespace atcoder;

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

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	int n;
	cin >> n;
	vector<int> a(n), l(n), r(n);
	rep(i,n) cin >> a[i];
	l[0] = a[0];
	r[n-1] = a[n-1];
	rep(i,n-1) l[i+1] = gcd(l[i], a[i+1]);
	for(int i = n-2; i >= 0; --i) r[i] = gcd(r[i+1], a[i]);
	int ans = 1;
	rep(i,n){
		if(i == 0) chmax(ans, r[1]);
		else if(i == n-1) chmax(ans, l[n-2]);
		else chmax(ans, (int)(gcd(l[i-1], r[i+1])));
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 4512
#include<cstdio>
#include<cstring>
#include<iostream>
using namespace std;
typedef long long LL;
int main(){
	LL n,T;
	cin>>n>>T;
	LL t,temp;
	cin>>t;
	temp=t;
	LL sum=n*T;
	for(int i=1;i<n;i++){
		cin>>t;
		t=t-temp;
		temp=temp+t;
		if(t<T) sum-=T-t;
	}
	printf("%lld\n",sum);
return 0;
}


Measured memory_bytes: 384
#include<stdio.h>
int main()
{
	int a,b,d,c,i;
	scanf("%d%d",&a,&b);
	for(i=a;i>=1;i=i/b)
	{
		d=a%b;
		a=a/b;
		c++;
	}
	printf("%d",c);
}

Measured memory_bytes: 128
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <algorithm>
#include <string>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <stack>
#include <queue>
#define llong long long
#define INF (__INT32_MAX__ / 2)

using namespace std;
typedef pair<int, int> ipair;

char table_s2t[26];
char table_t2s[26];

int main(int argc, char **argv) {
    for(int i = 0; i < 26; ++i) {
        table_s2t[i] = -1;
        table_t2s[i] = -1;
    }
    
	string S, T;
	cin >> S >> T;

    bool res = true;

    for(int i = 0; i < S.size(); ++i) {
        if(table_s2t[S[i] - 'a'] == -1)
            table_s2t[S[i] - 'a'] = T[i];
        else
            res &= (table_s2t[S[i] - 'a'] == T[i]);

        if(table_t2s[T[i] - 'a'] == -1)
            table_t2s[T[i] - 'a'] = S[i];
        else
            res &= (table_t2s[T[i] - 'a'] == S[i]);
    }
    
    cout << (res ? "Yes" : "No") << endl;
}

Measured memory_bytes: 900
s = int(input())
def colazt(n):
    if n % 2 == 0:
        return int(n/2)
    else:
        return int(3*n + 1)

suuretu = set()
ans = 1
while True:
    if s in suuretu:
        break
    
    suuretu.add(s)
    s = colazt(s)
    ans = ans + 1

print(ans)



Measured memory_bytes: 2940
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
#define pb push_back
const int mod=1e9+7;
#define fast ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
int main(){
    fast;
    int n,m,x;
    cin>>n>>m>>x;
    int a[n][m+1];
    for(int i=0;i<n;i++){
        for(int j=0;j<m+1;j++){
            cin>>a[i][j];
        }
    }
    int mn=10000001;
    for(int i=1;i<(1<<n);i++){
        int val[m],tot=0;
        for(int k=0;k<m;k++) val[k]=0;
        for(int j=0;j<n;j++){
            if((i&(1<<j))!=0){
                tot+=a[j][0];
                for(int k=0;k<m;k++){
                    val[k]+=a[j][k+1];
                }
            }
        }
        bool flag=0;
        for(int k=0;k<m;k++){
            if(val[k]<x){
                flag=1;
                break;
            }
        }
        if(!flag){
            mn=min(mn,tot);
        }
    }
    if(mn==10000001) cout<<"-1";
    else cout<<mn;
}

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

using namespace std;

#define ll long long

int main(){
	int n;
	cin >> n;
	ll l[n];
	for(int i=0;i<n;i++){
		cin >> l[i];
	}
	sort(l, l+n);
	int cnt = 0;
	for(int i=0;i<n-2;i++){
		for(int j=i+1;j<n-1;j++){
			if(l[j] != l[i]){
				int max = l[j] + l[i];
				for(int k=j+1;l[k] < max && k < n; k++){
					if(l[k] != l[j]){
						cnt++;
					}
				}
			}
		}
	}
	cout << cnt << endl;
}


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

using namespace std;



int main() {
    using ll = long long;
    using Vec = vector<ll>;
    using Mat = vector<Vec>;

    const ll mod = 1000000007;

    ll n, k;
    cin >> n >> k;

    Mat a(n, Vec(n));

    for (int i = 0; i < n; i++) {
        for (int j = 0; j < n; j++) {
            cin >> a[j][i];
        }
    }

    auto matmul = [&](Mat& a, const Mat& b) {
        Mat c(n, Vec(n));

        for (int i = 0; i < n; i++) {
            for (int k = 0; k < n; k++) {
                for (int j = 0; j < n; j++) {
                    (c[i][j] += a[i][k] * b[k][j]) %= mod;
                }
            }
        }

        a = c;
    };

    Mat x(n, Vec(n));
    Mat base = a;

    for (int i = 0; i < n; i++) {
        x[i][i] = 1;
    }

    while(k > 0) {
        if(k & 1) {
            matmul(x, base);
        }

        matmul(base, base);
        k >>= 1;
    }

    ll ans = 0;

    for (int i = 0; i < n; i++) {
        for (int j = 0; j < n; j++) {
            (ans += x[i][j]) %= mod;
        }
    }

    cout << ans << endl;
}


Measured memory_bytes: 384
if __name__ == '__main__':
    N, K = map(int, input().split())
    height = sorted([int(input()) for n in range(N)])
    s =  [ height[idx + K - 1] - h for idx, h in enumerate(height)
            if idx + K - 1 < len(height)
        ]
    print(min(s))

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

ll q,S1=0,S2=0,S=0,n=0;
priority_queue<ll> q1,q2;

int main(){
	ios::sync_with_stdio(0);
	cin.tie(0);
	cin>>q;
	for(int i=0;i<q;i++){
		ll t;
		cin>>t;
		if(t==1){
			ll x,y;
			cin>>x>>y;
			S+=y;n++;
			if(n==1||x<=q1.top()) q1.push(x),S1+=x;
			else q2.push(-x),S2+=x;
			while(q1.size()<(n+1)/2){
				ll t=-q2.top();q2.pop();
				q1.push(t);
				S1+=t,S2-=t;
			}
			while(q1.size()>(n+1)/2){
				ll t=q1.top();q1.pop();
				q2.push(-t);
				S1-=t,S2+=t;
			}
		}
		else{
			ll t=q1.top(),s1=q1.size(),s2=q2.size();
			cout<<t<<' '<<S2-S1+t*(s1-s2)+S<<endl;
		}
	}
}

Measured memory_bytes: 3828
import itertools

K, S = map(int, input().split())

if not ((2 <= K and K <= 2500) or (0 <= S and S <= 3*K)):
    exit()

count = 0
for X in range(0, K + 1):
    for Y in range(0, K + 1):
        if 0 <= (S - X - Y) and (S - X - Y) <= K:
            count += 1

print(count)


Measured memory_bytes: 3060
# -*- coding: utf-8 -*-
import sys
from math import sqrt
sys.setrecursionlimit(10**9)
INF=10**18
MOD=10**9+7
def input(): return sys.stdin.readline().rstrip()

def main():
    N=int(input())
    print(int(sqrt(N))**2)

if __name__ == '__main__':
    main()


Measured memory_bytes: 38384
#include <bits/stdc++.h>
using namespace std;
const int N=5e5;

#define C getchar()-48
int read()
{
  int s=0,t=1,k=C;
  for (;k<0||9<k;k=C) if (k==-3) t=-1;
  for (;0<=k&&k<=9;k=C) s=(s<<1)+(s<<3)+k;
  return s*t;
}

  int n;
  int a[N];
void in()
{
  cin>>n;
  n+=n;
  for (int i=0;++i<=n;)
    a[i]=read();
}

  int A;
void wor()
{
  sort(a+1,a+n+1);
  while (n>1)
    A+=a[n-1],n-=2;
}

void out()
{
  cout<<A;
}

int main()
{
  in();
  wor();
  out();
  exit(0);
} 

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

#define pb push_back
#define ff first
#define ss second

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

int ans = 1e9;
string s;

int main() {
	ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0);
	cin >> s;
	for (int k = 0; k < 26; k++) {
		int res = 0;
		for (int i = 0; i < s.size(); i++) {
			int ind = s.size();
			for (int j = i; j < s.size(); j++)
				if (s[j] - 'a' == k) {
					ind = j;
					break;
				}
			res = max(res, ind - i);
		}
		ans = min(ans, res);
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 256
#include <stdio.h>

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

int main(void) {
  int i, j, a[10000], m[10000], n, l1, l2;
  char buf[2];
  scanf("%d", &l1);
  for (n = 0; n < l1 && (j = scanf("%d%1[\n]", a+n, buf)) == 1; n++) ;
  if (j == 2)
  n++;
  scanf("%d", &l2);
  for (n = 0; n < l2 && (j = scanf("%d%1[\n]", m+n, buf)) == 1; n++) ;
  if (j == 2)
  n++;

  for (i = 0; i < l2; i++) {
    if (solve(0, a, m[i], l1) == 1) {
      printf("yes\n");
    } else {
      printf("no\n");
    }
  }
  return 0;
}



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

// types
typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef pair<ld,ld> pdd;
typedef vector<ll> vll;

// macros
#define ALL(a) a.begin(),a.end()
#define SZ(a) ((int)a.size())
#define FI first
#define SE second
#define REP(i,n) for(int i=0;i<((int)n);i++)
#define REP1(i,n) for(int i=1;i<((int)n);i++)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define PB push_back
#define EB emplace_back
#define MP(a,b) make_pair(a,b)
#define SORT_UNIQUE(c) (sort(c.begin(),c.end()), c.resize(distance(c.begin(),unique(c.begin(),c.end()))))
#define GET_POS(c,x) (lower_bound(c.begin(),c.end(),x)-c.begin())
#define Decimal fixed<<setprecision(20)
#define INF 1000000000
#define LLINF 1000000000000000000LL

// constants
const int inf = 1e9;
const ll linf = 1LL << 50;
const double eps = 1e-10;
const int MOD = 1e9 + 7;
const int dx[4] = {-1, 0, 1, 0};
const int dy[4] = {0, -1, 0, 1};


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

  ll n,k;
  cin >> n >> k;

  vector<pll> v;
  REP1(i, n)
    v.push_back(pll(0, i));

  REP1(i, n){
    for(ll j = i+1; j<n; j++){
      v.push_back(pll(i, j));
    }
  }

  if(k > n*(n-1)/2-(n-1)){
    cout << -1 << endl;
    return 0;
  }
  ll m = v.size()-k;
  cout << m << endl;
  REP(i, m)
    cout << v[i].FI+1 << " " << v[i].SE+1 << endl;

}


Measured memory_bytes: 512
#include <iostream>
#include <cmath>
#include <vector>
#include <string>
#include <queue>
#include <map>
#include <algorithm>
#include <numeric>

typedef long long ll;
const ll INF = 1e18;



int main(int argc, char* argv[])
{
  ll a, b, x;
  std::cin >> a >> b >> x;

  ll c = a % x == 0 ? 1 : 0;

  ll ans = b / x - a / x + c;
  std::cout << ans << std::endl;

  return 0;
}


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

#define rep(i, n) for (int i = 0; i < int(n); i++)
#define rrep(i, n) for (int i = int(n) - 1; i >= 0; i--)
#define reps(i, n) for (int i = 1; i <= int(n); i++)
#define rreps(i, n) for (int i = int(n); i >= 1; i--)
#define repi(i, a, b) for (int i = int(a); i < int(b); i++)
#define each(x, y) for (auto &x : y)
#define all(a) (a).begin(), (a).end()
#define bit(b) (1ll << (b))
#define uniq(v) (v).erase(unique(all(v)), (v).end())
#define rsort(v) sort(all(v)); reverse(all(v))

using namespace std;

using i32 = int;
using i64 = long long;
using f80 = long double;
using vi32 = vector<i32>;
using vi64 = vector<i64>;
using vf80 = vector<f80>;
using vstr = vector<string>;

inline void yes() { cout << "YES" << '\n'; exit(0); }
inline void no() { cout << "NO" << '\n'; exit(0); }
inline i64 gcd(i64 a, i64 b) { if (min(a, b) == 0) return max(a, b); if (a % b == 0) return b; return gcd(b, a % b); }
inline i64 lcm(i64 a, i64 b) { return a / gcd(a, b) * b; }
void solve(); int main() { ios::sync_with_stdio(0); cin.tie(0); cout << fixed << setprecision(16); solve(); return 0; }
template<typename T> class pqasc : public priority_queue<T, vector<T>, greater<T>> {};
template<typename T> class pqdesc : public priority_queue<T, vector<T>, less<T>> {};
template<typename T> inline void amax(T &x, T y) { if (x < y) x = y; }
template<typename T> inline void amin(T &x, T y) { if (x > y) x = y; }
template<typename T> inline T power(T x, i64 n) { T r = 1; while (n > 0) { if (n & 1) r *= x; x *= x; n >>= 1; } return r; }
template<typename T> istream& operator>>(istream &is, vector<T> &v) { for (auto &x : v) is >> x; return is; }
template<typename T> ostream& operator<<(ostream &os, const vector<T> &v) { rep(i, v.size()) { if (i) os << ' '; os << v[i]; } return os; }

bool dp[100010];

void solve() {
  string s;
  cin >> s;
  int n = s.size();
  dp[0] = true;
  vstr lst = {"dream", "dreamer", "erase", "eraser"};
  rep(i, n) {
    if (!dp[i]) continue;
    each(str, lst) {
      int len = str.size();
      if (s.substr(i, len) == str) dp[i + len] = true;
    }
  }
  if (dp[n]) yes(); no();
}


Measured memory_bytes: 592
//#define __USE_MINGW_ANSI_STDIO 0
#include <iostream>
#include <bits/stdc++.h>
using namespace std;

#define debug(x) cout<<#x<<" :: "<<x<<endl;
#define debug2(x,y) cout<<#x<<" :: "<<x<<"\t"<<#y<<" :: "<<y<<endl;
#define debug3(x,y,z) cout<<#x<<" :: "<<x<<"\t"<<#y<<" :: "<<y<<"\t"<<#z<<" :: "<<z<<endl;

#define boost ios::sync_with_stdio(0); cin.tie(0)

#define fi first
#define se second
#define pb(x) push_back(x)
#define mp(x,y) make_pair(x,y)

typedef long long ll;
typedef double ld;
typedef pair<int, int> pii;

const int N = 1e5 + 5;
const ll INF = 1e18;

/***************************************************************************/

ll W[N], V[N];
ll dp[105][N];

int main() {

	boost;
	int n, w; cin>>n>>w;
	for(int i=1; i<N; i++) {
		dp[0][i] = INF;
	}
	for(int i=1; i<=n; i++) {
		cin>>W[i]>>V[i];
		for(int j=0; j<V[i]; j++) {
			dp[i][j] = min(dp[i-1][j], W[i]);
		}
		for(int j=V[i]; j<N; j++) {
			dp[i][j] = min(dp[i-1][j], W[i]+dp[i-1][j-V[i]]);
		}
	}
	for(int i=N-1; ; i--) {
		if(dp[n][i] <= w) {
			cout<<i<<"\n";
			break;
		}
	} 
	return 0;
}

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

#define REP(i, e) for(int (i) = 0; (i) < (e); ++(i))
#define FOR(i, b, e) for(int (i) = (b); (i) < (e); ++(i))
#define ALL(c) (c).begin(), (c).end()
#define ACC(c) (accumulate(ALL(c), 0LL))
#define PRINT(x) cout << (x) << "\n"

using namespace std;
using ll = long long;
using pint = pair<int, int>;
using pll = pair<ll, ll>;

inline int std_in(int& a) {return scanf("%d", &a);}
auto pint_compare = [](pint x, pint y) -> bool{return (x.first < y.first);};
const int MOD = 1000000007;


signed main(){
    int N, d[50];
    cin >> N;
    REP(i, N) cin >> d[i];
    int sum = 0;
    REP(i, N - 1){
        FOR(j, i + 1, N){
            sum += d[i] * d[j];
        }
    }
    PRINT(sum);
    return 0;
}

Measured memory_bytes: 256
#include <vector>
#include <algorithm>
#include <string>
#include <map>
#include <set>
#include <queue>
#include <cstring>
#include <deque>
#include <cstdio>
#include <cmath>

using namespace std;

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

typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int,int> pii;

int main()
{
	int nums[16384], ans[8192];
	int i, j, n, size, half;
	
	while(scanf("%d", &n), n){
		size = 0;
		half = (n-1) / 2;
		for(i=1; i<n; ++i)
			nums[size++] = (i*i) % n;

		sort(nums, nums + size);
		size = unique(nums, nums + size) - nums;

		memset(ans, 0, (half+1)*4);
		for(i=0; i<size; ++i){
			for(j=0; j<i; ++j){
				++ans[abs(nums[i]-nums[j])>half?n-abs(nums[i]-nums[j]):abs(nums[i]-nums[j])];
			}
		}
		for(i=1; i<=half; ++i)
			printf("%d\n", ans[i]*2);
	}

	return 0;
}

Measured memory_bytes: 836
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int t;
    cin>>t;
    if(t>=400 && t<600)
        cout<<8;
    else if(t>=600 && t<800)
        cout<<7;
    else if(t>=800 && t<1000)
        cout<<6;
    else if(t>=1000 && t<1200)
        cout<<5;
    else if(t>=1200 && t<1400)
        cout<<4;
    else if(t>=1400 && t<1600)
        cout<<3;
    else if(t>=1600 && t<1800)
        cout<<2;
    else if(t>=1800 && t<2000)
        cout<<1;
}

Measured memory_bytes: 3632
#include <bits/stdc++.h>
 
using namespace std;
 
#define mp make_pair
#define endl '\n'
using ll=long long;
 
const int INF=1e9+5;
const ll lim=(ll)3e16;
const int N=3e3+5;
const int mod=1e9+7;
const ll oo=1e18+5;


int main(){
	ios::sync_with_stdio(false); cin.tie(NULL); cout.tie(0);
	int n,d,a;
	cin>>n>>d>>a;
	vector<pair<int,int>> monsters;
	for(int i=0;i<n;++i){
		int x,h;
		cin>>x>>h;
		int hits=(h+a-1)/a;
		monsters.push_back(mp(x,hits));
	}
	sort(monsters.begin(),monsters.end());
	
	int base=1;
	while(base<n){
		base*=2;
	}
	cerr<<base<<endl;
	vector<ll> tree(2*base);
	// init
	for(int i=0;i<n;++i){
		tree[base+i]=monsters[i].second;
	}
	
	auto get_health=[&](int id){
		int tot=0;
		for(int j=base+id;j>=1;j>>=1){
			tot+=tree[j];
		}
		return tot;
	};
		
	auto add_interval = [&](int l,int r,int val){
		l+=base;
		r+=base;
		tree[l]+=val;
		if(l!=r){
			tree[r]+=val;
		}
		while(l+1<r){
			if(l%2==0){
				tree[l+1]+=val;
			}
			if(r%2==1){
				tree[r-1]+=val;
			}
			l/=2;
			r/=2;
		}
	};	
		
	ll ans=0;
	//~ cout<<"--------------------------------"<<endl;
	//~ for(int i=0;i<(int)tree.size();++i){
		//~ cout<<"num["<<i<<"] = "<<tree[i]<<endl;
	//~ }
	//~ cout<<"--------------------------------"<<endl;
	for(int i=0;i<n;++i){
		// find the last monster still hit by a bomb starting here
		int heal=get_health(i);
		if(heal<=0){
			continue;
		}
		int low=i,high=n-1;
		int last=-1;
		while(low<=high){
			int mid=(low+high)>>1;
			if(monsters[mid].first<=monsters[i].first+2ll*d){
				last=mid;
				low=mid+1;
			}
			else{
				high=mid-1;
			}
		}
		add_interval(i,last,-heal);
		//~ cout<<"--------------------------------"<<endl;
		//~ for(int i=0;i<(int)tree.size();++i){
			//~ cout<<"num["<<i<<"] = "<<tree[i]<<endl;
		//~ }
		//~ cout<<"--------------------------------"<<endl;
		ans+=heal;
	}
	cout<<ans<<endl;
	
	return 0;
}
         


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

using namespace std;
typedef long long ll;
const ll mod = 1e9 + 7;
ll N,M;
ll ans = 1;
int main() {
  cin >> N >> M;
  if(N < M) swap(N,M);

  if(N - M > 1) {
    cout <<"0"<<endl;
    return 0;
  }

  if(N - M == 1) {
    for(ll i = 2; i <= N; i++) {
      ans = ans * i % mod;
    }
    ans %= mod;
    for(ll i = 2; i <= M; i++) {
      ans = ans * i % mod;
    }
    cout << ans % mod << endl;
    return 0;
  }

  else {
    for(ll i = 2; i <= N; i++) {
      ans = ans * i % mod;
    }
    ans %= mod;
     for(ll i = 2; i <= N; i++) {
      ans = ans *  i % mod;
     }
    
      cout << ans * 2 % mod<< endl;
      return 0;
  }
}


Measured memory_bytes: 256
#include <cstdio>
#include <fstream>
#include <algorithm>
#include <vector>
#include <cstring>
using namespace std;

long long n;
long long a[52];
int main(){
    scanf("%d", &n);
    long long Sum = 0, ok = 0, Sol = 0;
    for(int i = 1; i <= n ; ++i)
        scanf("%lld", &a[i]);
    while(ok == 0){
        ok = 1; Sum = 0;
        for(int i = 1; i <= n ; ++i){
            if(a[i] >= n){
                Sum = Sum + a[i] / n;
                a[i] = a[i] % n - a[i] / n;
                ok = 0;
            }
        }
        for(int i = 1; i <= n ; ++i)
            a[i] = a[i] + Sum;
        Sol += Sum;
    }
    printf("%lld", Sol);
    return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
#define int long long
using namespace std;
typedef pair<int, int> P;
const int mod = 1000000007;
const int INF = 1e18;

signed main(){
    int n;
    cin >> n;
    vector<int> a(n);
    for(int i = 0; i < n; i++){
        cin >> a[i];
        a[i]--;
    }
    vector<int> d(n, 0); 
    for(int i = 0; i < n; i++){
        if(a[i] != 0){
            d[a[i]] = d[a[i] - 1] + 1;
        }else{
            d[a[i]] = 1;
        }
    }
    int ans = 0;
    for(int i = 0; i < n; i++) ans = max(ans, d[i]);
    cout << n - ans << endl;
}

Measured memory_bytes: 3456
def digitsum(n):#nは正の整数、各位の和、許容は１０＾１０００
    if n<10:
        return n
    else:
        m=n//10
        return n%10+digitsum(m)

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

s=0

for i in range(0,N+1):
    if B>=digitsum(i)>=A:
        s=s+i

print(s)


Measured memory_bytes: 2940
dic = {}
while True:
    try:
        key,num = input().split()
        dic.setdefault(key,[]).append(int(num))
    except:
        break

dic = sorted(dic.items())
for tup in dic:
    print(tup[0])
    tup[1].sort()
    for i in tup[1]:
        if i != tup[1][-1]:
            print(i,end=" ")
        else:
            print(i) 


Measured memory_bytes: 5612
import java.util.*;

public class Main {
	
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		
		int n = sc.nextInt();
		for(int z=0;z<n;z++){
			int maxx = 0;
			int maxy = 0;
			int prex = 0;
			int prey = 0;
			double d = 0;
			int x, y;
			while(true){
				x = sc.nextInt();
				y = sc.nextInt();
				if(x==0 && y==0) break;
				x += prex;
				y += prey;
				if(d<Math.sqrt(x*x+y*y) || (d==Math.sqrt(x*x+y*y) && x>maxx)){
					d = Math.sqrt(x*x+y*y);
					maxx = x;
					maxy = y;
				}
				prex = x;
				prey = y;
			}
			System.out.println(maxx + " " + maxy);
		}
	}	
}

Measured memory_bytes: 26016