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

struct UnionFind
{
    vector<int> parent;
    UnionFind(int n) : parent(n) {
        for(int i = 0; i < n; i++) parent[i] = i;
    }

    int root(int x){
        return x == parent[x] ? x : (parent[x] = root(parent[x])); // 経路圧縮
    }

    void unite(int x, int y){
        int rx = root(x), ry = root(y);
        if(rx != ry) parent[rx] = parent[ry];
        return;
    }

    bool isSame(int x, int y){
        return root(x) == root(y);
    }
};


int main()
{
    int n, m, xi, yi, ans = 0;
    cin >> n >> m;
    vector<int> p(n);
    for(int i = 0; i < n; i++){
        cin >> p[i];
        p[i]--;
    }

    UnionFind u(n);
    for(int i = 0; i < m; i++){
        cin >> xi >> yi;
        u.unite(xi - 1, yi - 1);
    }
    for(int i = 0; i < n; i++){
        if(u.isSame(i, p[i])) ans++;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 1152
#include <stdio.h>

int main()
{
    int n,a,i,j,c4 = 0,c2 = 0;
    scanf("%d",&n);
    for (i = 0; i < n; i++)
    {
        scanf("%d",&a);
        if(a % 4 == 0)
        {
            c4++;
        }
        else if (a % 2 == 0)
        {
            c2++;
        }
    }

    if(c2 == 0)
    {
        printf(c4 * 2 + 1 >= n ? "Yes" : "No");
    }
    else
    {
        printf(c4 * 2 + c2 >= n ? "Yes" : "No");
    }
    printf("\n");
}

Measured memory_bytes: 128
#include <vector>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <algorithm>
#include <utility>
#include <functional>
#include <sstream>
#include <iostream>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <climits>
#include <fstream>
#include <iomanip>
using namespace std;
inline int toInt(string s) { int v; istringstream sin(s); sin >> v; return v; }
template<class T> inline string toStr(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;
#define ALL(a) (a).begin(),(a).end()
#define RALL(a) (a).rbegin(),(a).rend()
#define FOR(i,a,b) for(int i=(a);i<=(b);++i)
#define REP(i,n) FOR(i,0,(n)-1)
const double EPS = 1e-10;
const double PI = acos(-1.0);
const int INF = INT_MAX / 2;
const int MOD = 1000000007;
typedef vector<ll> vl;
typedef vector<vl> vvl;

int main() {
	ll N, M;
	cin >> N >> M;
	if (N > M) {
		swap(N, M);
	}

	ll ans = 0;
	if (N == 1) {
		if (M == 1) {
			ans = 1;
		}
		else {
			ans = max(ans, M - 2);
		}
	}
	else if (N == 2) {

	}
	else {
		ans = (N-2)*(M-2);
	}

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

Measured memory_bytes: 256
/***************************************** START OF TEMPLATE *********************************************/

#include<bits/stdc++.h>

using namespace std;

#define  SPEED          ios:: sync_with_stdio(0);cin.tie(0);cout.tie(0);cout<<fixed;cout<<setprecision(10);
#define  randomINIT     mt19937 rnd(chrono::steady_clock::now().time_since_epoch().count());
#define  foo(i,a,n)     for(ll i = (a); i <= n; i++)
#define  frr(i,a,n)     for(ll i = (a); i >= n; i--)
#define  fo(i,n)        for(ll i = 0; i < n; i++)
#define  all(x)         (x).begin(),(x).end()
#define  mset(x,val)    memset(x,val,sizeof(x))
#define  newl           cout<<"\n"
#define  f              first
#define  s              second
#define  pb             push_back
#define  INPa(a,n)      foo(i,1,n) cin>>a[i];
#define  deb2d(a,n,m)   foo(i,1,n){foo(j,1,m){cout<<a[i][j]<<" ";}newl;}
#define  deb1d(a,n)     foo(i,1,n)cout<<a[i]<<" ";newl;
#define  debv(a)        for(auto it: a)cout<<it<<" ";newl;
#define  deb1(a)        cout<<a<<" ";newl;
#define  deb2(a,b)      cout<<a<<" "<<b<<" ";newl;
#define  deb3(a,b,c)    cout<<a<<" "<<b<<" "<<c<<" ";newl;
#define  deb4(a,b,c,d)  cout<<a<<" "<<b<<" "<<c<<" "<<d;newl;
#define  ll             long long
#define  ld             long double
#define  pll            pair<ll,ll>
#define  vll            vector<ll>
#define  vpll           vector<pll>

const ll   MOD   =  1e+9 + 7;
const ll   INF   =  LLONG_MAX;
const int  INFi  =  INT_MAX;
const ll   N     =  2e+5 + 8;

vll adj[N]; ll vis[N];
ll dx4[] = {0, 1, 0, -1}, dy4[] = {1, 0, -1, 0};

ll test_cases = 1; randomINIT;

/*********************************************************************************************************/
/***************************************** VARIABLE DECLARATIONS *****************************************/
string s, t;
ll a, b, c, k;

/***************************************** FUNCTION IMPLEMENTATIONS **************************************/



/***************************************** START OF MAIN FUNCTION ****************************************/
void MAIN(ll tc) {
    ll res = 0;
    cin >> a >> b >> c >> k;
    if (k >= a)res += a;
    else {
        cout << k;
        return;
    }
    k -= a;
    if (k >= b) {}
    else {
        cout << res;
        return;
    }
    k -= b;
    res -= k;
    cout << res;
}

int main() {
    SPEED;

    //cin>>test_cases;
    foo(i, 1, test_cases) {
        MAIN(i);
    }
}

Measured memory_bytes: 8332
#include <bits/stdc++.h>
#define l_ength size
const int inf = (1<<30);
const int mod = 1000000007;
using ll = long long;
using namespace std;

int main(){
	ll n, m; cin >> n >> m;
	ll ans = 0;
	if( n*2 > m ){
		ans += m/2;
		m = 0;
	} else {
		ans += n;
		m -= n*2;
	}
	ans += m/4;
	cout << ans << endl;
}


Measured memory_bytes: 256
import java.io.InputStream;
import java.io.PrintStream;
import java.math.BigDecimal;
import java.util.Scanner;

public class Main {

  public static void main(String[] args) {
    resolve(System.in, System.out);
  }

  static void resolve(InputStream is, PrintStream pw) {
    Scanner sc = new Scanner(is);
    long a = Long.parseLong(sc.next());
    BigDecimal d = new BigDecimal(sc.next());
    BigDecimal ans = d.multiply(BigDecimal.valueOf(a));
    pw.println(ans.longValue());
  }
}


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

using namespace std;

#define PI 3.1415926535897932

//typedef long long ll;


int lcm(int a,int b) { return a*b/__gcd(a,b); }
//ll lcm(ll a,ll b) { return a*b/__gcd(a,b); }

/**
 * vector<int>ar(3);
 * for(auto&e:ar){
 *     scanf("%d",&e);
 * }
 * sort(ar.begin(),ar.end())
 * int sum=accumulate(ar.begin(),ar.end(),0);
 **/


int main(){
    int mod=1000000007;
    int a,b,chk;
    scanf("%d %d",&a,&b);
    chk=b-a-1;
    chk=(chk+1)*(chk/2)+(chk%2? chk/2+1:0);
    printf("%d\n",chk-a);

    return 0;
}

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

#if MYDEBUG
#include "lib/cp_debug.hpp"
#else
#define DBG(...) ;
#endif
#if __cplusplus <= 201402L
template <typename T>
T gcd(T a, T b) { return ((a % b == 0) ? b : gcd(b, a % b)); }
template <typename T>
T lcm(T a, T b) { return a / gcd(a, b) * b; }
#endif
using LL = long long;
constexpr LL LINF = 334ll << 53;
constexpr int INF = 15 << 26;
constexpr LL MOD = 1E9 + 7;

namespace Problem {
using namespace std;

class Solver {
 public:
  void solve() {
    string s;
    cin >> s;
    int n, m;
    n = toint(s[0], s[1]);
    m = toint(s[2], s[3]);
    int c = (1 <= n && n <= 12) * 2 + (1 <= m && m <= 12);
    string ans[] = {"NA", "YYMM", "MMYY", "AMBIGUOUS"};
    cout << ans[c] << endl;
  }

  int toint(char a, char b) {
    return (a - '0') * 10 + (b - '0');
  }
};

}  // namespace Problem

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

  Problem::Solver sol;
  sol.solve();
  return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<iomanip>
//#include<cstdio>
#include<vector>
#include<map>
#include<queue>
#include<algorithm>
#include<cmath>
#include<cassert>
using namespace std;
typedef long long ll;

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

	cout << setprecision(10);
	if(d == 0){
		cout << (double)(m-1)/n << endl;
	}
	else{
		cout << (double)(m-1)*2*(n-d)/(n*n) << endl;
	}

	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <cmath>
#include <algorithm>
#include <climits>
#include <set>
#include <map>
#include <queue>
#include <deque>
#include <stack>
#include <string>

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

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

    int p,q,r;
    cin>>p>>q>>r;
    cout<<min(p+q,min(r+q,p+r));

    return 0;
}


Measured memory_bytes: 256
#include<iostream>
using namespace std;
int n;
int a;
int gg;
int main(){
	cin>>n;
	for (int i=0;i<n;i++){
		cin>>a;
		if(a%2!=0) gg++;
	} 
	if(gg!=0){
		cout<<"first"<<endl;
	}
	else{
		cout<<"second"<<endl;
	}
	return 0;
}

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

int main(){
    long int a,b,v,w,t;

    cin >> a >> v >> b >> w >> t;

    if(a >= 0 && b >= 0){
    long int s = b - a;
    long int x = v - w;

    if(x * t >= s){
        cout << "YES"<< endl;
    }else{
        cout << "NO" << endl;
    }
    }else if(a >= 0 && b < 0){
    long int s = a - b;
    long int x = v - w;

    if(x * t >= s){
        cout << "YES"<< endl;
    }else{
        cout << "NO" << endl;
    }
    }else if(a < 0 && b >= 0){
    long int s = b - a;
    long int x = v - w;

    if(x * t >= s){
        cout << "YES"<< endl;
    }else{
        cout << "NO" << endl;
    }
    }else{
    long int s = abs(b - a);
    long int x = v - w;

    if(x * t >= s){
        cout << "YES"<< endl;
    }else{
        cout << "NO" << endl;
    }
    }
    }

Measured memory_bytes: 3636
import sys, math
import heapq
class Heapq:
    def __init__(self, arr, desc=False):
        if desc:
            arr = [-a for a in arr]
        self.sign = -1 if desc else 1
        self.hq = arr
        heapq.heapify(self.hq)

    def pop(self):
        return heapq.heappop(self.hq) * self.sign

    def push(self, a):
        heapq.heappush(self.hq, a * self.sign)

    def top(self):
        return self.hq[0] * self.sign

def main():
    def input():
        return sys.stdin.readline()[:-1]
    N, M = map(int,input().split())
    A = sorted(list(map(int,input().split())))[::-1]
    Q = Heapq(A, True)
    for k in range(M):
        now = Q.pop()
        Q.push(now//2)
    ans = 0
    for k in range(N):
        ans += Q.pop()
    print(ans)
if __name__ == '__main__':
    main()


Measured memory_bytes: 66728
#include<bits/stdc++.h>
#define ll long long
#define rep(i,n) for(int i=0;i<n;i++)
using namespace std;
const int N=12;
int n,m;
int k,ans;
char c[N][1005];
int check(int mask)
{
	int res=0,cnt[12],add=0;
	for(int i=0;i<12;i++)cnt[i]=0;
	for(int j=1;j<=m;j++)
	{
		int ji=0;
		add=0;
		bool flag=false;
		for(int i=1;i<=n;i++)
		{
			add+=c[i][j]-'0';
			if(mask&(1<<(i-1)))
			{
				if(cnt[ji]+add>k)flag=true;
				if(add>k)return 1e9;
				if(flag)break;
				cnt[ji++]+=add;
				add=0;
			}
		}
		if(cnt[ji]+add>k)flag=true;
		else cnt[ji]+=add;
		if(add>k)return 1e9;
		add=0;
		ji=0;
		if(flag)
		for(int i=1;i<=n;i++)
		{
			add+=c[i][j]-'0';
			if(mask&(1<<(i-1)))
				cnt[ji++]=add,add=0;
		}
		if(flag)cnt[ji]=add;
		res+=flag;
	}
	return res;
}
int main()
{
	cin>>n>>m>>k;
	for(int i=1;i<=n;i++)
		for(int j=1;j<=m;j++)
			cin>>c[i][j];
	ans=1e9;
	for(int i=0;i<(1<<n);i++)
		ans=min(ans,check(i)+__builtin_popcount(i));
	cout<<ans<<"\n";
	return 0;
}

Measured memory_bytes: 256
X, Y, Z, K = map(int, input().split())
A = list(map(int, input().split()))
B = list(map(int, input().split()))
C = list(map(int, input().split()))

D = []
for a in A:
    for b in B:
        D.append(a + b)
D.sort(reverse=True)
if len(D) > K:
    D = D[:K]
E = []
for d in D:
    for c in C:
        E.append(c + d)

E.sort(reverse=True)
for i, e in enumerate(E):
    if i >= K:
        break
    print(e)

Measured memory_bytes: 151768
#include <cstdio>
int main()
{
 long M,m,sum,d;
 int n,i;
 sum=0;
 scanf("%d",&n);
 M= -1000000;
 m=1000000;
 for(i=0;i<n;i++){
  scanf("%ld",&d);
  M=(M<d)?d:M;
  m=(m<d)?m:d;
  sum += d;
 }
 printf("%ld %ld %ld\n",m,M,sum);
 return 0;
};

Measured memory_bytes: 1028
#include<bits/stdc++.h>
using namespace std;
int a[200005];
int b[200005];
int main()
{
    int n;
    cin>>n;
    for(int i=1;i<=n;i++)
    {
        scanf("%d",&a[i]);
        b[i]=a[i];
    }
    sort(b+1,b+1+n);
    for(int i=1;i<=n;i++)
    {
        if(a[i]==b[n])
        {
            cout<<b[n-1]<<endl;
        }
        else
        {
            cout<<b[n]<<endl;
        }
    }
}


Measured memory_bytes: 3200
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,k,n) for(int i = (k); i < (n); i++)
#define REP(i,n) FOR(i,0,n)
#define ALL(a) begin(a),end(a)
#define MS(m,v) memset(m,v,sizeof(m))
#define D10 fixed<<setprecision(10)
typedef vector<int> vi;
typedef vector<string> vs;
typedef pair<int, int> pii;
typedef long long ll;
const int INF = 114514810;
const int MOD = 1000000007;
const double EPS = 1e-10;
typedef double weight;
struct edge
{
	int from, to; weight cost;
	bool operator < (const edge& e) const { return cost < e.cost; }
	bool operator >(const edge& e) const { return cost > e.cost; }
};
typedef vector<vector<edge>> Graph;
int dx[] = { -1, 0, 0, 1 }; int dy[] = { 0, -1, 1, 0 };
template<class T> T &chmin(T &a, const T &b) { return a = min(a, b); }
template<class T> T &chmax(T &a, const T &b) { return a = max(a, b); }
bool valid(int x, int y, int h, int w) { return (x >= 0 && y >= 0 && x < h&&y < w); }
int place(int x, int y, int w) { return w*x + y; }
///*************************************************************************************///
///*************************************************************************************///
///*************************************************************************************///
typedef complex<double> Point;
struct union_find
{
	vector<int> par;
	union_find(int n) :par(n, -1) {}
	int find(int x) { return par[x] < 0 ? x : par[x] = find(par[x]); }
	void unite(int x, int y)
	{
		x = find(x); y = find(y);
		if (x == y) return;
		if (par[y] < par[x]) swap(x, y);
		if (par[x] == par[y]) par[x]--;
		par[y] = x;
		if (find(x) != find(y)) par[find(y)] = x;
	}
	int count()
	{
		int cnt = 0;
		REP(i, par.size()) if (par[i] < 0) cnt++;
		return cnt;
	}

	bool same(int x, int y)
	{
		return find(x) == find(y);
	}
};


int main()
{
	int n, m;
	cin >> n >> m;
	vector<Point> ps(n);
	REP(i, n)
	{
		double x, y;
		cin >> x >> y;
		ps[i] = Point(x, y);
	}
	vector<edge> es;
	double ans = 0;
	REP(i, m)
	{
		int a, b;
		cin >> a >> b;
		a--; b--;
		double d = abs(ps[a] - ps[b]);
		ans += d;
		es.push_back(edge{ a, b, d });
	}
	sort(es.rbegin(), es.rend());
	union_find uf(n);
	REP(i, es.size())
	{
		if (uf.same(es[i].from, es[i].to)) continue;
		ans -= es[i].cost;
		uf.unite(es[i].from, es[i].to);
	}
	cout << D10 << ans << endl;
	return 0;
}

Measured memory_bytes: 2020
#include <algorithm>
#include <cmath>
#include <functional>
#include <iomanip>
#include <iostream>
#include <numeric>
#include <queue>
#include <stack>
#include <string>
#include <vector>

#define repd(i, a, b) for (ll i = (a); i < (b); i++)
#define rep(i, n) repd(i, 0, n)
typedef long long ll;

using namespace std;

ll inputValue() {
    ll a;
    cin >> a;
    return a;
};

void inputArray(ll *p, ll a){rep(i, a){cin >> p[i];
}
}
;

void inputVector(vector<ll> *p, ll a) {
    rep(i, a) {
        ll input;
        cin >> input;
        p->push_back(input);
    }
}

template <typename T> void output(T a, ll precision) {
    if (precision > 0) {
        cout << setprecision(precision) << a << "\n";
    } else {
        cout << a << "\n";
    }
}

ll dfs(ll num, ll n) {
    if (num > n) {
        return 0;
    }
    ll res = 0;
    string str = to_string(num);
    ll num7 = 0, num5 = 0, num3 = 0;
    rep(i, str.size()) {
        if (str[i] == '7') {
            num7++;
        } else if (str[i] == '5') {
            num5++;
        } else if (str[i] == '3') {
            num3++;
        }
    }
    if (num7 > 0 && num5 > 0 && num3 > 0) {
        res++;
    }
    res += dfs(num * 10 + 7, n);
    res += dfs(num * 10 + 5, n);
    res += dfs(num * 10 + 3, n);
    return res;
}

int main() {
    ll n;
    cin >> n;
    cout << dfs(0, n) << endl;
}



Measured memory_bytes: 256
def main():
    n,k= map(int,input().split())
    h = [int(i) for i in input().split()]
    inf = 10**7
    dp = [inf]*100005
    dp[0] = 0
    for i in range(1,n):
        dp[i] = min(dp[i-j] + abs(h[i-j] - h[i]) for j in range(1,min(k,i)+1))
    print(dp[n-1])
main()

Measured memory_bytes: 20324
using System;
using System.Collections.Generic;

namespace AtCoder {
    class Program {

        static void Main(string[] args) {

            var temp = Console.ReadLine().Split(' ');
            var N = int.Parse(temp[0]);
            var T = int.Parse(temp[1]);

            var dic = new Dictionary<int, int>();

            for(int i = 0; i < N; i++) {

                var temp2 = Console.ReadLine().Split(' ');
                dic[int.Parse(temp2[0])] = int.Parse(temp2[1]);
            }

            var result = 1001;

            foreach(var pair in dic) {

                if(pair.Value > T) {
                    continue;
                }
                if(result > pair.Key) {

                    result = pair.Key;
                }
            }
            Console.WriteLine(result == 1001 ? "TLE" : result.ToString());
        }
    }
}


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

int main() {
  bool flag = true;
  char c, c2 = 'a';
  for (int i=0; i<4; i++) { 
    cin >> c;
    if (c == c2) flag = false;
    c2 = c;
  }
  if (flag) cout << "Good" << endl;
  else cout << "Bad" << endl;
}


Measured memory_bytes: 256
#include<iostream>
#include<string.h>
#include<algorithm>
using namespace std;
int main(){
    string a,b;
    cin>>a>>b;
    string str;
    if(a.size() != b.size()){
    str = (a.size() > b.size())?"GREATER":"LESS";   
    }else{
    str = (a>b)?"GREATER":((a<b)?"LESS":"EQUAL");
    }
    cout<<str<<endl;
}

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

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

#define int long long int 
#define mp make_pair
#define pb push_back
#define f first
#define s second



int32_t main()
{
     IOS; 
     
     
     int a,b;
     cin>>a>>b;
     
     for(int i=1;i<=3;i++)
     {
          if((i*a*b)%2==1)
          {
               cout<<"Yes";
               return 0;
          }
     }
     cout<<"No";    return 0;
     
}

Measured memory_bytes: 256
#!/usr/bin/env python
# coding: utf-8

def ri():
    return int(input())

def rl():
    return list(input().split())

def rli():
    return list(map(int, input().split()))

def main():
    a, v = rli()
    b, w = rli()
    t = ri()
    if t*(v-w) >= abs(a-b):
        print("YES")
    else:
        print("NO")



if __name__ == '__main__':
    main()


Measured memory_bytes: 9180
#include <bits/stdc++.h>
using namespace std;
#define F first
#define S second
#define pi M_PI
#define R cin>>
#define Z class
#define ll long long
#define ln cout<<'\n'
#define in(a) insert(a)
#define pb(a) push_back(a)
#define pd(a) printf("%.10Lf\n",a)
#define mem(a) memset(a,0,sizeof(a))
#define all(c) (c).begin(),(c).end()
#define iter(c) __typeof((c).begin())
#define rrep(i,n) for(int i=(int)(n)-1;i>=0;i--)
#define REP(i,m,n) for(int i=(int)(m);i<(int)(n);i++)
#define rep(i,n) REP(i,0,n)
#define tr(it,c) for(iter(c) it=(c).begin();it!=(c).end();it++)
template<Z A>void pr(A a){cout<<a;ln;}
template<Z A,Z B>void pr(A a,B b){cout<<a<<' ';pr(b);}
template<Z A,Z B,Z C>void pr(A a,B b,C c){cout<<a<<' ';pr(b,c);}
template<Z A,Z B,Z C,Z D>void pr(A a,B b,C c,D d){cout<<a<<' ';pr(b,c,d);}
template<Z A>void PR(A a,ll n){rep(i,n){if(i)cout<<' ';cout<<a[i];}ln;}
ll check(ll n,ll m,ll x,ll y){return x>=0&&x<n&&y>=0&&y<m;}
const ll MAX=1000000007,MAXL=1LL<<61,dx[4]={-1,0,1,0},dy[4]={0,1,0,-1};
typedef pair<int,int> P;

void Main() {
  ll n,l,r;
  cin >> n >> l >> r;
  ll a[n];
  rep(i,n) R a[i];
  ll dp[n+1][n+1],dp2[n+1][n+1];
  rep(i,n+1)rep(j,n+1)dp[i][j]=-MAXL;
  mem(dp2);
  dp[0][0]=0;
  dp2[0][0]=1;
  rep(i,n) {
    rrep(j,n+1) {
      if(j<n) {
        if(dp[i+1][j+1]<dp[i][j]+a[i]) {
          dp[i+1][j+1]=dp[i][j]+a[i];
          dp2[i+1][j+1]=dp2[i][j];
        } else if(dp[i+1][j+1]==dp[i][j]+a[i]) dp2[i+1][j+1]+=dp2[i][j];
      }
      if(dp[i+1][j]<dp[i][j]) {
        dp[i+1][j]=dp[i][j];
        dp2[i+1][j]=dp2[i][j];
      } else if(dp[i+1][j]==dp[i][j]) dp2[i+1][j]+=dp2[i][j];
    }
  }
  long double M=-1;
  ll x=0;
  REP(i,l,r+1) M=max(M,(long double)dp[n][i]/i);
  REP(i,l,r+1) {
    if(M==(long double)dp[n][i]/i) x+=dp2[n][i];
  }
  pd(M);
  pr(x);
}

int main(){Main();return 0;}


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

#define FOR(i, a, b) for (int i = (a); i < int(b); ++i)
#define RFOR(i, a, b) for (int i = (a); i >= int(b); --i)
#define REP(i, n) FOR(i, 0, n)
#define RREP(i, n) RFOR(i, n, 0)
#define ALL(c) begin(c), end(c)
#define MSG(a) cout << a << endl;

template <typename T>
using vec = std::vector<T>;
using vi = vec<int>;
using vvi = vec<vi>;
using pii = std::pair<int, int>;
using ll = long long;
using ld = long double;

int gcd(int a, int 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;
  cin >> N;

  int ans = 0;

  FOR(i, 1, N + 1) {
    if (i % 2 == 0) continue;

    int count = 1;
    FOR(j, 3, i + 1) {
      if (j % 2 == 0) continue;
      if (i % j == 0) count++;
    }
    if (count == 8) ans++;
  }

  MSG(ans);
  return 0;
}


Measured memory_bytes: 256
import java.util.*;
import java.io.*;

public class Main {
    public static void main(String[] args) {
        FastScanner scanner = new FastScanner();
        PrintWriter out = new PrintWriter(System.out);
        int n = scanner.nextInt();
        int[][] arr = new int[n][n-1];
        for(int i = 0; i < n; i++) for(int j = 0; j <n-1; j++) arr[i][j] = scanner.nextInt()-1;
        int ans = 0;
        boolean changed = true;
        int[] ptr = new int[n];
        boolean[] did = new boolean[n];
        ArrayDeque<Integer> queue = new ArrayDeque<>();
        for(int i = 0; i <n; i++)  queue.offer(i);
        while(changed) {
            changed = false;
            Arrays.fill(did, false);
            ArrayDeque<Integer> nq = new ArrayDeque<>();
            while(!queue.isEmpty()) {
                int i = queue.poll();
                if (did[i] || ptr[i] == n-1) continue;
                int opp = arr[i][ptr[i]];
                if (ptr[opp] == n-1 || did[opp]) continue;
                if (arr[opp][ptr[opp]] == i) {
                    did[i] = true;
                    did[opp] = true;
                    ptr[opp]++;
                    ptr[i]++;
                    changed = true;
                    nq.offer(i); nq.offer(opp);
                }
            }
            if (changed) {
                ans++;
                queue = nq;
            }
        }
        boolean good = true;
        for(int i = 0; i < n; i++) {
            if (ptr[i] != n-1) good = false;
        }
        if (good) out.println(ans);
        else out.println(-1);
        out.flush();
    }
    
    public static class FastScanner {
        BufferedReader br;
        StringTokenizer st;
        
        public FastScanner(Reader in) {
            br = new BufferedReader(in);
        }
        
        public FastScanner() {
            this(new InputStreamReader(System.in));
        }
        
        String next() {
            while (st == null || !st.hasMoreElements()) {
                try {
                    st = new StringTokenizer(br.readLine());
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }
        
        int nextInt() {
            return Integer.parseInt(next());
        }
        
        long nextLong() {
            return Long.parseLong(next());
        }
        
        double nextDouble() {
            return Double.parseDouble(next());
        }
        
        String readNextLine() {
            String str = "";
            try {
                str = br.readLine();
            } catch (IOException e) {
                e.printStackTrace();
            }
            return str;
        }
    }
}


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

int main()
{
    int n, r, rel;
    cin >> n >> r;
    if(n<10){
        r += 100 * (10-n);
    }
    cout << r << endl;
    return 0;
}

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

public class Main {
	public static void main(String[] args) throws IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String str = null;
		while ((str = br.readLine()) != null) {
			String[] array = str.split(" ");
			for(int i = 0; i<array.length; i++){
				if(i == array.length-1){
					System.out.println("YES");
					break;
				}
				if(array[i].charAt(array[i].length()-1) != array[i+1].charAt(0)){
					System.out.println("NO");
					break;
				}
			}
		}
	}
}


Measured memory_bytes: 22868
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n,m,x,sum=0;
    cin>>n>>m;
    for(int i=1;i<=m;i++)
    {
        cin>>x;
        sum+=x;
    }
    if(sum<=n)
        cout<<n-sum<<endl;
    else
        cout<<"-1\n";
}


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

using namespace std;

typedef vector<int> VI;
typedef pair<int,int> PII;
typedef long long ll;

#define dump(x)  cerr << #x << " = " << (x) << endl
#define rep(i,n) for(int i=0;i<(n);i++)
#define ALL(a)  (a).begin(),(a).end()
#define PB push_back
#define sz size()

const double EPS = 1e-10;



double len(double xa,double ya,double xb,double yb){
    return sqrt( (xa-xb)*(xa-xb) + (ya-yb)*(ya-yb) );
}

double solve(double xa,double ya,double xb,double yb,double xc,double yc){
    double a,b,c;
    a=len(xa,ya,xb,yb);
    b=len(xa,ya,xc,yc);
    c=len(xb,yb,xc,yc);
    
    double z=(a+b+c)/2.0;
    
    double ret=z*(z-a)*(z-b)*(z-c);

    return sqrt(ret);
}


int main(){
    double x[30],y[30];
    double ans=0;
    double centerx=0,centery=0;
    int count=0;

    for(int i=0;;i++){
        char ch;

        if( !( cin>>x[i] && cin>>ch && cin>>y[i]) )break;
        
        count++;
        centerx+=x[i];
        centery+=y[i];
    }
    
    centerx/=count;
    centery/=count;

    rep(i,count){
        ans+=solve(centerx,centery,x[i],y[i],x[(i+1)%count],y[(i+1)%count]);
    }
    
    cout<<ans<<endl;
    
    return 0;
}

Measured memory_bytes: 1284
#include<iostream>
using namespace std;
#define INFTY 100000000000
int c;

int merge(int A[],int left,int mid,int right){
  int n1=mid-left;
  int n2=right-mid;
  int L[n1],R[n2];

  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]=R[n2]=INFTY;

  int i=0,j=0;
  for(int k=left;k<right;k++){
    if(L[i]<=R[j]){
      A[k]=L[i];
      i++;
      c++;
    }else{
      A[k]=R[j];
      j++;
      c++;
    }
  }

}

int mergesort(int A[],int left,int right){
  if(left+1<right){
    int mid=(left+right)/2;
    mergesort(A,left,mid);
    mergesort(A,mid,right);
    merge(A,left,mid,right);
  }
}

int main(){
  int n;
  cin>>n;
  int S[n];

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

  mergesort(S,0,n);
for(int i=0;i<n-1;i++){
  cout<<S[i]<<" ";
  }
 cout<<S[n-1]<<endl;
 cout<<c<<endl;

 return 0;
}



Measured memory_bytes: 6880
#include <iostream>


using namespace std;

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



Measured memory_bytes: 3088
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		String s = sc.next();
		char[] c = s.toCharArray();
		int count = 1;

		for(int i = 0;i < n-1;i++){
			if(c[i] == c[i+1]){

			}else{
				count++;
			}
		}

		System.out.println(count);
	}

}

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

int main() {
    int n, m;
    cin >> n >> m;
    vector<pair<ll, ll>> student(n);
    vector<pair<ll, ll>> point(m);
    rep(i, 0, n){
        cin >> student[i].first >> student[i].second;
    }
    rep(i, 0, m){
        cin >> point[i].first >> point[i].second;
    }
    rep(i, 0, n){
        ll root = 1000000000;
        int ans = 0;
        rep(j, 0, m){
            ll temproot = abs(point[j].first - student[i].first)+
            abs(point[j].second - student[i].second);
            if(temproot < root) ans = j + 1; 
            root = min (root, temproot);
        }
        cout << ans << endl;
    }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

#define pi acos(-1.0)
#define eps 1e-9
#define ll long long
#define ull unsigned long long
#define sf scanf
#define pf printf
#define nl printf("\n")
#define	inf (ll)1e15
#define mod 1000000007
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend() 
#define sz(x) (int)(x).size()
#define test_case int ___t;scanf("%d", &___t);for(int cs=1;cs<=___t;cs++)

using namespace __gnu_pbds;
using namespace std;

inline string str_inp(int n){char ch[n+5];sf(" %s",ch);return string(ch);}
inline string line_inp(int n)
{char ch[n+5];fgets(ch,n+5,stdin);string s=string(ch);s.pop_back();return s;}

//typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> new_data_set;


const int S=100100;
int main()
{
    //#ifndef ONLINE_JUDGE
    //freopen("input.txt","r",stdin);
    //#endif

    string s[15];
    s[0]="pon";
    s[1]="pon";
    s[2]="hon";
    s[3]="bon";
    s[4]="hon";
    s[5]="hon";
    s[6]="pon";
    s[7]="hon";
    s[8]="pon";
    s[9]="hon";
	int n;
	while(~sf("%d",&n))
	{
		int pos=n%10;
		pf("%s\n",s[pos].c_str());
	}
    return 0;
}
 






































Measured memory_bytes: 3688
/*input
3 1
ABC

*/

#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> PII;
typedef pair<ll , ll> PLL;
typedef long double ld;

#define pb push_back
#define all(c) c.begin(),c.end()
#define allr(c) c.rbegin(),c.rend()
int mod = 998244353;
#define PI 3.14159265
#define endl '\n'
#define debug(x) cout << #x << " = " << x << endl;
#define TRACE

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


template < typename T > T GCD(T a, T b)            { ll t; while(a) { t = a; a = b % a; b = t; } return b; }
template < typename T > string toString(T a)       { return to_string(a); }
template < typename T > void toInt(string s, T &x) { stringstream str(s); str >> x;}
inline int add(int x, int y){ x += y; if(x >= mod) x -= mod; return x;}
inline int sub(int x, int y){ x -= y; if(x < 0) x += mod; return x;}
inline int mul(int x, int y){ return (x * 1ll * y) % mod;}
inline int powr(int a, ll b){
    int x = 1 % mod;
    while(b){
        if(b & 1) x = mul(x, a);
        a = mul(a, a);
        b >>= 1;
    }
    return x;
}
inline int inv(int a){ return powr(a, mod - 2);}

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

  int n, k;
  cin >> n >> k;
  string str;
  cin >> str;
  char &c = str[k - 1];
  c = tolower(c);
  cout << str << endl;

  return 0;
}

Measured memory_bytes: 892
#include <iostream>
#include <stdio.h>
#include <vector>
#include <algorithm>
#define rep(i,n) for(int i = 0; i < (n); ++i)
using namespace std;


int main(){
    int x,y,a,b,c;
    cin >> x >> y >> a >> b >> c;
    vector<int> qa(a),qb(b),qc(c);

    rep(i,a){
        cin >> qa[i];
    }
    rep(i,b){
        cin >> qb[i];
    }
    rep(i,c){
        cin >> qc[i];
    }
    std::sort(qa.begin(),qa.end(),std::greater<int>());

    std::sort(qb.begin(),qb.end(),std::greater<int>());

    std::sort(qc.begin(),qc.end(),std::greater<int>());

    int xtmp=x,ytmp=y,ztmp=0;
    rep(i,c){
        if(xtmp==0&&ytmp==0) break;

        if(xtmp==0){
            if(qc[i]>qb[ytmp-1]){
                ytmp--;
                ztmp++;
                continue;
            }
            else break;
        }

        if(ytmp==0){
            if(qc[i]>qa[xtmp-1]){
                xtmp--;
                ztmp++;
                continue;
            }
            else break;
        }

        if(qa[xtmp-1]<qb[ytmp-1]){
            if(qc[i]>qa[xtmp-1]){
                xtmp--;
                ztmp++;
                continue;
            }
            else break;
        }
        if(qa[xtmp-1]>=qb[ytmp-1]){
            if(qc[i]>qb[ytmp-1]){
                ytmp--;
                ztmp++;
                continue;
            }
            else break;
        }
    }
    long long sum=0;
    rep(i,xtmp){
        sum+=qa[i];
    }
    rep(i,ytmp){
        sum+=qb[i];
    }
    rep(i,ztmp){
        sum+=qc[i];
    }
    cout << sum << endl;
    return 0;
}

Measured memory_bytes: 1408
from heapq import heappop,heappush,heapify

class Graph():
    def __init__(self,n,edge,directed=False):
        self.n = n
        self.graph = [[] for _ in range(n)]
        for e in edge:
            self.graph[e[0]].append((e[1],e[2]))
            if not directed:
                self.graph[e[1]].append((e[0],e[2]))
    def dijkstra(self,s,INF=10**18):
        dist = [INF for _ in range(self.n)]
        dist[s] = 0
        heap = [(0,s)]
        while heap:
            cost,node = heappop(heap)
            if dist[node] < cost:
                continue
            for adj,adjcost in self.graph[node]:
                if dist[node]+adjcost < dist[adj]:
                    dist[adj] = dist[node]+adjcost
                    heappush(heap,(dist[adj],adj))
        return dist

INF = 10**18

import sys
input = sys.stdin.readline

V,E,r = map(int,input().split())
edge = [tuple(map(int,input().split())) for _ in range(E)]

g = Graph(V,edge,True)
D = g.dijkstra(r,INF)

for i in range(V):
    if D[i] == INF: D[i] = 'INF'

print('\n'.join(map(str,D)))


Measured memory_bytes: 149032
#include<cstdio>

using namespace std;

int a, b;

int main()
{
    int num = 0;
    while (1)
    {
        scanf("%d %d\n", &a, &b);
        if (a == 0 && b == 0) break;
        if( num )
        {
            printf("\n");
        }
        num++;
        bool Na = 1;
        for (int i = a; i <= b; i++)
        {
            bool out = 1;
            if( i % 4 == 0 )
            {
                if( i % 100 == 0 )
                {
                    if( i % 400 == 0 )
                    {
                        out = 1;
                    }
                    else
                    {
                        out = 0;
                    }
                }
                else
                {
                    out = 1;
                }
            }
            else
            {
                out = 0;
            }
            if( out )
            {
                Na = 0;
                printf( "%d\n", i );
            }
        }
        if (Na)
        {
            printf("NA\n");
        }
    }
    return 0;
}



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

int main() {
	string S;
	cin >> S;
	int N;
	N = S.length();//文字の長さ

	int Ans = 10000;
	for (int i = 0; i < N - 2; i++) {
		string sub = S.substr(i, 3);
		int NS = stoi(sub);
		NS = abs(NS - 753);
		if (Ans > NS) {
			Ans = NS;
		}
	}

	cout << Ans << endl;
}

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

using namespace std;

struct node{
	int pos, mid, val;
}a[200003];

int n, ans[200003];

bool cmp(node a, node b) {
	return a.val < b.val;
}

inline void read(int& x) {
	x = 0; char c = getchar();
	while(!isdigit(c)) c = getchar();
	while(isdigit(c)) x = x * 10 + c - '0', c = getchar();
}

int main() {
	read(n);
	for(int i = 1; i <= n; ++i) a[i].pos = i, read(a[i].val);
	sort(a + 1, a + n + 1, cmp);
	int where = n >> 1;
	for(int i = 1; i <= n; ++i) {
		if(i <= where) a[i].mid = a[where + 1].val;
		else a[i].mid = a[where].val;  
	}
	for(int i = 1; i <= n; ++i)
		ans[a[i].pos] = a[i].mid;
	for(int i = 1; i <= n; ++i) printf("%d ", ans[i]);
	return 0;
}

Measured memory_bytes: 5248
var s:string;
f:boolean;
i:longint;
begin
 readln(s);
 if (pos('C',s)=0) or (pos('F',s)=0) then writeln('No')
 else
 begin
  f:=true;
  while pos('F',s)<pos('C',s) do
  begin
   if pos('F',s)=0 then begin f:=false; break; end;
   delete(s,pos('F',s),1);
  end;
  if f then writeln('Yes') else writeln('No');
 end;
end.

Measured memory_bytes: 128
import java.io.*;
public class Main {
	public static void main(String[] args) throws IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		int w = Integer.parseInt(br.readLine());
		int n = Integer.parseInt(br.readLine());
		String[] c = new String[2];
		int f=0;
		int s=0;
		int temp = 0;
		int[] amida = new int[w];
		for(int i = 0 ; i < w ; i ++)
			amida[i]=i+1;
		for(int i = 0 ; i < n ; i ++){
			c=br.readLine().split(",");
			f=Integer.parseInt(c[0]);
			s=Integer.parseInt(c[1]);
			temp=amida[f-1];
			amida[f-1]=amida[s-1];
			amida[s-1]=temp;
		}
		for(int i = 0;i<w;i++){
			System.out.println(amida[i]);
		}
	}
}

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

ll x[100010];

int main() {
  ll N, K;
  cin >> N >> K;
  for (int i = 0; i < N; i++) {
    int a, b;
    cin >> a >> b;
    x[a] += b;
  }

  for (int i = 0; i < 100010; i++) {
    if (K - x[i] <= 0) {
      cout << i << endl;
      return 0;
    }
    K -= x[i];
  }
}

Measured memory_bytes: 1024
/*
  	^_HAR HAR MAHADEV_^
    |Om namah shivaya|
*/

// AUTHOR : Harshil Mehta

#include <bits/stdc++.h>
//For ordered_set
/*
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
*/
//#include<boost/multiprecision/cpp_int.hpp>
#define mod 1000000007
#define init(arr,val) memset(arr,val,sizeof(arr))
#define f(i,a,b) for(int i=a;i<b;i++)
#define fr(i,a,b) for(int i=a;i>=b;i--)
#define ull unsigned long long int
#define ll long long int
#define pb push_back
#define pf push_front
#define F first
#define S second
#define fast ios_base::sync_with_stdio(false);cin.tie();cout.tie();
#define FILE_READ_IN freopen("input.txt","r",stdin);
#define FILE_READ_OUT freopen("output.txt","w",stdout);
#define all(a) a.begin(),a.end()
#define br "\n"
//using namespace boost::multiprecision;
using namespace std;
// For ordered_set
/*
using namespace __gnu_pbds;
#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>
*/
ll findS(ll s) {
	return (sqrtl(8*s + 1) - 1)/2;
}
ll phi(ll n)
{
    ll result = n;
    for (ll p = 2; p * p <= n; ++p){
        if (n % p == 0) {
            while (n % p == 0)
                n /= p;
            result -= result / p;
        }
    }
    if (n > 1)
        result -= result / n;
    return result;
}
bool isPrime(ll a) {
	if(a==1)return false;
	if(a==2 || a==3)return true;
	if(a%2==0 ||a%3==0)return false;
	for(ll i=5; i<=sqrt(a); i+=6)
		if(a%i==0 || a%(i+2)==0)
			return false;
	return true;
}
ll power(ll x,ll y) {
	if (y == 0)
		return 1;
	ll p = power(x, y/2) % mod;
	p = (p * p) % mod;

	return (y%2 == 0)? p : (x * p) % mod;
}
ll nCr(ll n,ll k) {
	ll C[k+1];
	C[0] = 1;
	f(i,0,k+1)C[i]=0;
	for (ll i = 1; i <= n; i++) {
		for (ll j = min(i, k); j > 0; j--)
			C[j] = (C[j] + C[j-1])%mod;
	}
	return C[k];
}
ll LOGN(ll n , ll r) {
	return (n > r-1) ? (1 + LOGN(n / r , r)) : 0 ;
}
void dfs(vector<ll> v[], bool visited[], ll current_node) {
	visited[current_node]=true;
	for(ll nxt_node : v[current_node]) {
		if(visited[nxt_node]==false) {
			dfs(v , visited, nxt_node);
		}
	}
	return;
}
void solve(){
	int n , q;
	cin >> n >> q;
	string s ;
	cin >> s ;
	int pos[n+1] = {0} ;
	int cnt = 0 ;
	f(i,0,n){
		if(i > 0){
			if(s[i] == 'C' && s[i-1] == 'A') {
				pos[i] = ++ cnt ;
			}
			else{
				pos[i] = pos[i-1] ;
			}
		}
	}
	while(q--){
		int  l , r ;
		cin >> l >> r ;
		-- l , --r ;
		cout << pos[r] - pos[l] << br ;
	}
}
int main(){
	fast ;
   int t = 1;
   //cin >> t;
   while(t--){
       solve();
   }
   return 0;
}



Measured memory_bytes: 1488
require 'prime'
cache = Array.new(50001,0)
ps = Prime.each(50000).to_a
while ps!=[]
	p = ps[0]
	ps.each do |x|
		if p+x < cache.length
			cache[p+x]+=1 
		else
			break
		end
	end
	ps.shift
end

while (n = gets.to_i) != 0
	p cache[n]
end

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

int palindrome(string str){

  string tmp = str;
  reverse(tmp.begin(),tmp.end());

  if(str==tmp){
    return 0;
  }else{
    return 1;
  }

}

int main() {

  string S;
  cin >> S;
  
  int N = S.size();
  int firstCheck = palindrome(S);

  if(firstCheck!=0){
    cout << "No" << endl;
    return 0;
  }

  string mae = S.substr(0,N/2);

  int secondCheck = palindrome(mae);

  if(secondCheck!=0){
    cout << "No" << endl;
    return 0;
  }

  string ushiro = S.substr(N/2+1);
  reverse(ushiro.begin(),ushiro.end());

  int thirdCheck = palindrome(ushiro);

  if(thirdCheck==0){
    cout << "Yes" << endl;
  }else{
    cout << "No" << endl;
  }

  return 0;


}


Measured memory_bytes: 256
/*
ID: anonymo14
TASK: wormhole
LANG: C++                 
*/
#include<bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<pair<int,int>> vpii;

#define F first
#define S second
#define PU push
#define PUF push_front
#define PUB push_back
#define PO pop
#define POF pop_front
#define POB pop_back

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

#define MOD 1000000007

void solve(int test_case) {//227
	string s,t;
	cin>>s>>t;
	REP(i,0,(int)s.length()-1) {
		bool e = 1;
		REP(j,0,(int)t.length()-1) {
			if(s[(i+j)%(int)s.length()]!=t[j]){e=0;break;}
		}
		if(e) {
			cout<<"Yes";
			return;
		}
	}
	cout<<"No";
}

int main() {
	
	////// FILE BASED IO////
	//freopen("wormhole.in", "r", stdin);
	//freopen("wormhole.out", "w", stdout);
	///////////////
	
	ios::sync_with_stdio(0);
	cin.tie(0);
	int t=1;
	//cin>>t;
	REP(i,1,t) {
		solve(i);
	}
	return 0;
}	


Measured memory_bytes: 3628
#include <cstdio>
#include <vector>
#include <algorithm>
using namespace std;

int main()
{
  vector<int> l(10);
  int v1, v2;
  while (scanf("%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d",
	       &l[0], &l[1], &l[2], &l[3], &l[4], &l[5], &l[6], &l[7], &l[8], &l[9], &v1, &v2) != EOF) {
    vector<double> ll(10);
    ll[0] = l[0];
    for (int i = 1; i < 10; ++i)
      ll[i] = ll[i-1] + l[i];

    double t = ll.back() / static_cast<double>(v1+v2);
    double d = t * v1;
    for (int i = 0; i < ll.size(); ++i) {
      if (d <= ll[i]) {
	printf("%d\n", i+1);
	break;
      }
    }
  }
  return 0;
}

Measured memory_bytes: 0
#include "bits/stdc++.h"
#include <iostream>
#include <string.h>
#include <stdio.h>
#include <map>
#include <vector>
#include <math.h>
#include <algorithm>
#include <queue>
#include <set>
#include <tuple>
using namespace std;

#define FOR(i,init,a) for(int i=init; i<a; i++)
#define rep(i,a) FOR(i,0,a)
#define rrep(i,a) for(int i=a; i>=0; i--)
#define rep1(i,a) for(int i=1; i<=a; i++)
#define cout1(a) cout << a << endl;
#define cout2(a,b) cout << a << " " << b << endl;
#define cout3(a,b,c) cout << a << " " << b << " " << c << endl;
#define cout4(a,b,c,d) cout << a << " " << b << " " << c << " " << d << endl;
#define mem(a,n) memset( a, n, sizeof(a))
#define all(a) a.begin(),a.end()
#define chmin(a,b) a=min(a,b);
#define chmax(a,b) a=max(a,b);

typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef vector<int> V;
typedef vector<V> VV;
typedef vector<VV> VVV;
const int INF = 1e9;
const int MOD = 1e9+7;
const ll LLINF = 1e18;
static const double pi = 3.141592653589793;

ll fact[200000], invFact[200000]; 

long long power(long long x, long long c) {
    if(c==0) return 1;
    if(c==1) return x;
    if (c%2==1) return (power( (x*x)%MOD, c/2)*x)%MOD;
    else return power( (x*x)%MOD, c/2)%MOD;
}

void make_combT(ll n){
    fact[0]=1;
    rep1(i,n) fact[i]= fact[i-1]*i%MOD;
    
    invFact[n] = power(fact[n],MOD-2);
    rrep(i,n-1) invFact[i] = invFact[i+1] * (i+1) %MOD;
}

ll comb(ll n, ll m){
    if(n<m||n<0||m<0) return 0;
    return (fact[n] * invFact[m] %MOD) * invFact[n-m] %MOD;
}

ll hcomb(ll n, ll m){
    if(n==0&&m==0) return 1;
    return comb(n+m-1,m);
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    int N;
    cin>>N;
    
    make_combT(10000);
    map<int,int> dic;
    rep1(i,N){
        int tmp=i;
        for(int n=2;n<=tmp;n++){
            while(tmp%n==0){
                dic[n]++;
                tmp/=n;
            }
        }
    }
    
    ll res=1;
    for(auto d:dic){
        int x=d.second;
        res=(res*(x+1))%MOD;
    }
    cout1(res)
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<ll,ll>;
//マクロ
//forループ関係
//引数は、(ループ内変数,動く範囲)か(ループ内変数,始めの数,終わりの数)、のどちらか
//Dがついてないものはループ変数は1ずつインクリメントされ、Dがついてるものはループ変数は1ずつデクリメントされる
#define FOR(i,a,b) for(ll i=a;i<=(ll)(b);i++)
//xにはvectorなどのコンテナ
#define ALL(x) (x).begin(),(x).end() //sortなどの引数を省略したい
#define SIZE(x) ((ll)(x).size()) //sizeをsize_tからllに直しておく
#define MAX(x) *max_element(ALL(x)) //最大値を求める
#define MIN(x) *min_element(ALL(x)) //最小値を求める
//定数
#define INF 1000000000000 //10^12:極めて大きい値,∞
#define inf 2,147,483,647 //int値の最大値
#define MOD 1000000007 //10^9+7:合同式の法
#define MAXR 100000 //10^5:配列の最大のrange(素数列挙などで使用)
//略記
#define PB push_back //vectorヘの挿入
#define MP make_pair //pairのコンストラクタ
#define F first //pairの一つ目の要素
#define S second //pairの二つ目の要素
#define cint(n) int n;cin>>n;
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;
}
int gcd(int a, int b) {
    if (b==0) return a;
    else return gcd(b, a%b);
}
int lcm(int a, int b) {
    return a * b / gcd(a, b);
}
int main() {
    string s,t;cin>>s>>t;
    int si=SIZE(s);
    int ans=0;
    rep(i,si){
        if(s[i]!=t[i])ans++;
    }
    cout<<ans<<endl;
    return 0;
}


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

using namespace std;

using ll = long long;
using ull = unsigned long long;

int main() {
    int N;
    std::cin >> N;

    std::vector<ull> a(N);
    std::for_each(a.begin(), a.end(), [](auto &x) { std::cin >> x; });

    const auto ans = std::accumulate(a.cbegin(), a.cend(), 0ll, [&](const auto &acc, const auto &x) {
        return acc + x - 1;
    });

    std::cout << ans << std::endl;

    return 0;
}


Measured memory_bytes: 256