akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <algorithm>
#include <vector>
#include <cstdio>
#include <cmath>

using namespace std;

#define REP(i,n) for(int i = 0; i < (int)(n); i++)
typedef long long ll;
typedef pair<int, int> pint;

int main() {
  int N, K; cin>>N>>K;
  string S; cin>>S;
  vector<pint> rec;
  int cnt = 0;
  REP(i,N) {
    if(i == 0 || S[i-1]==S[i]) {
      cnt++;
    } else {
      rec.push_back(make_pair(S[i-1]-'0', cnt));
      cnt = 1;
    }
#ifdef DEBUG
    cout << i << " " << cnt << endl;
#endif
  }
  rec.push_back(make_pair(S[N-1]-'0', cnt));
#ifdef DEBUG
  REP(i,rec.size()) {
    cout << rec[i].first << ":" << rec[i].second << endl;
  }
#endif
  vector<int> d;
  if(rec[0].first == 0) d.push_back(0);
  REP(i,rec.size()) {
    d.push_back(rec[i].second);
  }
  if(rec.back().first == 0) d.push_back(0);
#ifdef DEBUG
  REP(i,d.size()) {
    cout << d[i] << " ";
  }
  cout << endl;
#endif
  vector<int> sum(d.size()+1,0);
  REP(i,d.size()) sum[i+1] = sum[i] + d[i];
#ifdef DEBUG
  REP(i,sum.size()) {
    cout << sum[i] << " ";
  }
  cout << endl;
#endif
  K = K * 2 + 1;
  int ans = 0;
#ifdef DEBUG
  cout << K << "/" << d.size() << endl;
#endif
  if(K >= (int)d.size()) {
    ans = sum.back();
  } else {
    for(int i = 0; i+K < sum.size(); i+=2) {
      ans = max(ans, sum[i+K] - sum[i]);
#ifdef DEBUG
      cout << i << "," << ans << endl;
#endif
    }
  }
  cout << ans << endl;
  return 0;
}



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

typedef long long ll;
#define ar array
#define vi vector<int>
#define vvi vector<vector<int>>
#define vll vector<long long>
#define fork(i, n) for (ll i = 0; i < (n); i++)
#define forn for (ll i = 0; i < (n); i++)
#define fori(i, k, n) for (ll i = k; i < (n); i++)
#define all(x) (x).begin(), (x).end()
#define en '\n'
#define FILL(x, v) memset(x, v, sizeof(x))
#define pb push_back
#define fast                     \
	ios::sync_with_stdio(false); \
	cin.tie(NULL);               \
	cout.tie(NULL);

template <typename A, typename B>
inline void chmin(A &a, B b)
{
	if (a > b)
		a = b;
}
template <typename A, typename B>
inline void chmax(A &a, B b)
{
	if (a < b)
		a = b;
}
template <typename T>
void print(vector<T> &a)
{
	for (int i = 0; i < a.size(); i++)
		cout << a[i] << ' ';
	cout << en;
}
template <typename T>
void print(deque<T> &a)
{
	for (int i = 0; i < a.size(); i++)
		cout << a[i] << ' ';
	cout << en;
}
template <typename T>
void print(vector<vector<T>> &a)
{
	for (int i = 0; i < a.size(); i++)
	{
		for (int j = 0; j < a[i].size(); j++)
			cout << a[i][j] << ' ';
		cout << en;
	}
}

int main()
{
	fast;
	ll n, ans = 0;
	cin >> n;
	vector<int> a(n);
	for (ll i = 1; i <= n; i++)
	{
		for (ll j = i; j <= n; j += i)
		{
			a[j]++;
		}
	}
	for (ll i = 1; i <= n; i++)
	{
		ans += i * a[i];
	}
	cout << ans << en;
}

Measured memory_bytes: 42224
#include <bits/stdc++.h>
#include <boost/functional/hash.hpp>

typedef std::pair<int,int> P;
typedef std::pair<int, P> pp;
struct edge{P to; int cost;};

int N, M;
std::unordered_map<P, std::vector<edge>, boost::hash<P>> G;
std::unordered_map<P, int, boost::hash<P>> d;

void dijkstra(int s) {
    std::priority_queue<pp, std::vector<pp>, std::greater<pp> > que;
    d[P(s, 0)] = 0;
    que.push(pp(0, P(s, 0)));

    while(!que.empty()) {
        pp p = que.top(); que.pop();
        P v = p.second;
        if(d[v] < p.first) continue;
        for(edge e : G[v]) {
            if(d.find(e.to) == end(d) || d[e.to] > d[v] + e.cost) {
                d[e.to] = d[v] + e.cost;
                que.push(pp(d[e.to], e.to));
            }
        }
    }
}

int main() {
    std::cin >> N >> M;
    for(int i=0; i<M; ++i) {
        int p, q, c;
        std::cin >> p >> q >> c;
        --p; --q;
        if(G.find(P(p, c)) == end(G)) {
            G[P(p, 0)].push_back({P(p, c), 1});
            G[P(p, c)].push_back({P(p, 0), 1});
        }
        if(G.find(P(q, c)) == end(G)) {
            G[P(q, 0)].push_back({P(q, c), 1});
            G[P(q, c)].push_back({P(q, 0), 1});
        }
        G[P(p, c)].push_back({P(q, c), 0});
        G[P(q, c)].push_back({P(p, c), 0});
    }

    dijkstra(0);
    if(d.find(P(N - 1, 0)) == end(d)) std::cout << -1 << std::endl;
    else std::cout << d[P(N - 1, 0)] / 2 << std::endl;
}

Measured memory_bytes: 84084
//Code by Mukul Totla
#include<bits/stdc++.h>
using namespace std;
#define ll long long

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

  ll n,i,d;
  cin>>n>>d;
  d=d*d;
  ll cnt=0;
  while(n--)
  {
    ll a,b;
    cin>>a>>b;
    ll dist=a*a + b*b;
    if(dist<=d)
      cnt++;

  }
  cout<<cnt;

  return 0;
}

Measured memory_bytes: 3656
#include "bits/stdc++.h"
using namespace std;
#define ff first
#define ss second
#define pb push_back
typedef long long ll;
#define db(x) cerr<<__LINE__<<": "<<#x<<" = "<<(x)<<'\n'
const int inf = 1e9+7;
const int N = 1e6+9;

int main() {
    ios_base::sync_with_stdio(0);
    int a,b,n;
    string s, t;
    cin>>s>>t;
    a = s.size(), b = t.size();
    int mn = inf;
    for(int i=0;i<=a-b;++i) {
        int cnt=0;
        for(int j=0;j<b;++j) {
            if(s[i+j]!=t[j]) ++cnt;
        }
        mn = min(mn, cnt);
    }
    cout<<mn<<endl;
    return 0;
}

Measured memory_bytes: 3668
#include <bits/stdc++.h>
#define ll long long
using namespace std;
ll N,W,w[109],v[109],dp[102][100009];

void init(){
    for(int i=0;i<=100;i++){
        dp[0][i]=0;
    }
}

int main(){
    init();
    cin>>N>>W;
    for(int i=0;i<N;i++){
        cin>>w[i]>>v[i];
    }
    for(int i=0;i<N;i++){
        for(int j=1;j<=W;j++){
            if(w[i]>j){
                if(i==0){
                    dp[i][j]=0;
                }
                else{
                    dp[i][j]=dp[i-1][j];
                }
            }
            else{
                if(i==0) dp[i][j]=v[i];
                else dp[i][j]=max(v[i]+dp[i-1][j-w[i]],dp[i-1][j]);
            }
        }
    }
    /*
    for(int i=0;i<N;i++){
        for(int j=0;j<=W;j++){
            cout<<dp[i][j]<<' ';
        }
        cout<<endl;
    }
    */
    cout<<dp[N-1][W];
    return 0;
}


Measured memory_bytes: 78336
#include <iostream>
#include <set>
#include <vector>
#include <algorithm>
#include <queue>
using namespace std;

typedef unsigned long long int ulint;
typedef long long int lint;

int main(){
  ulint N, M;
  cin >> N >> M;

  // vector<ulint> A;
  priority_queue<ulint> A;
  
  for (int i = 0; i < N; ++i) {
    ulint a;
    cin >> a;
    A.push(a);
  }

  for (int i = 0; i < M; ++i) {
    ulint val = A.top();
    A.pop();
    A.push(val / 2);
  }

  ulint sum = 0;
  for (int i = 0; i < N; ++i) {
    ulint a = A.top();
    A.pop();
    sum += a;
  }

  cout << sum << endl;
}


Measured memory_bytes: 1400
#define _USE_MATH_DEFINES
#define INF 0x3f3f3f3f
#include <cstdio>
#include <iostream>
#include <sstream>
#include <cmath>
#include <cstdlib>
#include <algorithm>
#include <queue>
#include <stack>
#include <limits>
#include <map>
#include <string>
#include <cstring>
#include <set>
#include <deque>
#include <bitset>
#include <list>
#include <cctype>
#include <utility>
 
using namespace std;
 
typedef long long ll;
typedef pair <int,int> P;
typedef pair <int,P > PP;
 
int tx[] = {0,1,0,-1};
int ty[] = {-1,0,1,0};
 
static const double EPS = 1e-8;
 
static const int MAX_N = 1000000;
bool isPrime[MAX_N];
 
int Matsuzaki(int N,int P){
    vector<int> prime;
    for(int i=N+1;i<=N+100000;i++){
        if(isPrime[i]){
            prime.push_back(i);
            if(prime.size() >= 100) break;
        }
    }
 
    vector<int> compo;
    for(int i=0;i<prime.size();i++){
        for(int j=i;j<prime.size();j++){
            compo.push_back(prime[i]+prime[j]);
        }
    }
 
    sort(compo.begin(),compo.end());
    //unique(compo.begin(),compo.end());
 
    return compo[P-1];
}
 
int main(){
    int N,P;
    memset(isPrime,-1,sizeof(isPrime));
 
    isPrime[0] = false;
    isPrime[1] = false;
 
    for(int i=2;i<MAX_N;i++){
        if(!isPrime[i]) continue;
 
        for(int j=i+i;j<MAX_N;j+=i){
            isPrime[j] = false;
        }
    }
 
    while(~scanf("%d %d",&N,&P)){
        if(N==-1) break;
        printf("%d\n",Matsuzaki(N,P));
    }
}

Measured memory_bytes: 2248
#include <iostream>
using namespace std;
int main(int argc, char const *argv[])
{
	int n;
	cin>>n;
	printf("AB");
	if(n < 1000)
	{
		printf("C");
	}
	else
	{
		printf("D");
	}
	printf("\n");
	return 0;
}

Measured memory_bytes: 256
//       In the name of         ****                      God                     ****

/*

Copyright (C)          JadedBeast

                                   Morocco

created : 7/3/2019

*/

#include <bits/stdc++.h>

using namespace std;

int dp(int i,int *values,int *result ,int n){
	if(i>=n)
		return 0 ;
	if(result[i]<INT_MAX)
		return result[i];
	if(i<n-2 )
		return result[i]=min(abs(values[i]-values[i+1])+dp(i+1,values,result,n),min(abs(values[i]-values[i+2])+dp(i+2,values,result,n),result[i]));
	if(i<n-1)
		return result[i]=min(abs(values[i]-values[i+1])+dp(i+1,values,result,n),result[i]);	
	return 0;
	}


int main() {
	int n;
	cin >> n;
	int values[n],result[n];
	fill(result,result+n,INT_MAX);
	for (int i = 0; i < n; i++)
	{
		cin >> values[i];
	}
	
	cout <<dp(0,values,result,n)<<endl;

   return 0;
}


Measured memory_bytes: 6528
import std.stdio, std.string, std.conv;
import std.algorithm, std.array;
auto solve(string s_) {
    immutable N = s_.to!int();
    auto a = new int[][N];
    foreach(i;1..N) a[readln.chomp.to!int()-1]~=i;
    int dfs(int i) {
        int m=0;
        foreach(int k,v;a[i].map!dfs().array().sort!"a>b"().array())
            m=max(m,k+v+1);
        return m;
    }
    return dfs(0);
}
void main(){ for(string s; (s=readln.chomp()).length;) writeln(solve(s)); }

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

using namespace std;
#define ll long long
const long double EPS = 1e-8;
const long double PI = acos(-1);
const int N = 1e5 + 9;
ll arr[N][4];
ll mem[N][4];
int n, k;

const ll inf = 1e14 + 7LL;

ll solve(int i = 0, int prev = 0) {
    if (i == n)return 0;
    ll &ret = mem[i][prev];
    if (~ret)return ret;
    ret =0;
    for (int j = 1; j <= 3; j++) {
        if (j != prev)
            ret = max(ret, solve(i + 1, j) + arr[i][j]);
    }
    return ret;
}

int main() {
    scanf("%d", &n);

    for (int i = 0; i < n; i++) {
        scanf("%lld%lld%lld", &arr[i][1], &arr[i][2], &arr[i][3]);
    }
    memset(mem, -1, sizeof mem);
    printf("%lld\n", solve());
}


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

#define max(a,b) ((a)>(b)?(a):(b))
#define min(a,b) ((a)<(b)?(a):(b))
#define abs(a) max((a),-(a))
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define repe(i,n) rep(i,(n)+1)
#define per(i,n) for(int i=(int)(n)-1;i>=0;i--)
#define pere(i,n) rep(i,(n)+1)
#define all(x) (x).begin(),(x).end()
#define SP <<" "<<
#define RET return 0
#define MOD 1000000007
#define INF 1000000000

typedef long long LL;
typedef long double LD;

int dist[60][30][60][30][2];

int main(){
  while(1){
    int w,h;
    cin >> w >> h;
    if(w==0) return 0;
    vector<vector<char>> f(h,vector<char>(w));
    for(int i=0;i<h;i++){
      for(int j=0;j<w;j++){
        cin >> f[i][j];
      }
    }
    for(int i=0;i<h;i++){
      for(int j=0;j<w;j++){
        for(int k=0;k<h;k++){
          for(int l=0;l<w;l++){
            dist[i][j][k][l][0]=dist[i][j][k][l][1]=INF;
          }
        }
      }
    }
    int hx[9]={1,1,2,1,2,3,1,2,1};
    int hy[9]={2,1,1,0,0,0,-1,-1,-2};
    priority_queue<pair<int,tuple<int,int,int,int,int>>> dijk;
    for(int i=0;i<w;i++){
      if(f[h-1][i]=='S'){
        dijk.push({0,make_tuple(h-1,i,h-1,i,0)});
        dijk.push({0,make_tuple(h-1,i,h-1,i,1)});
      }
    }
    pair<int,tuple<int,int,int,int,int>> now;
    int lx,ly,rx,ry,fl,di,nx,ny;
    int ans=INF;
    while(!dijk.empty()){
      now=dijk.top();
      dijk.pop();
      ly=get<0>(now.second);
      lx=get<1>(now.second);
      ry=get<2>(now.second);
      rx=get<3>(now.second);
      fl=get<4>(now.second);
      di=-now.first;
      if(dist[ly][lx][ry][rx][fl]==INF){
        dist[ly][lx][ry][rx][fl]=di;
        if(fl){
          for(int i=0;i<9;i++){
            nx=rx-hx[i];
            ny=ry+hy[i];
            if(0<=nx&&nx<w&&0<=ny&&ny<h){
              if(f[ny][nx]!='X'){
                if(dist[ny][nx][ry][rx][0]==INF){
                  if(f[ny][nx]=='T'){
                    ans=min(ans,di);
                  }else dijk.push({-di-(f[ny][nx]-'0'),make_tuple(ny,nx,ry,rx,0)});
                }
              }
            }
          }
        }else{
          for(int i=0;i<9;i++){
            nx=lx+hx[i];
            ny=ly+hy[i];
            if(0<=nx&&nx<w&&0<=ny&&ny<h){
              if(f[ny][nx]!='X'){
                if(dist[ly][lx][ny][nx][1]==INF){
                  if(f[ny][nx]=='T'){
                    ans=min(ans,di);
                  }else dijk.push({-di-(f[ny][nx]-'0'),make_tuple(ly,lx,ny,nx,1)});
                }
              }
            }
          }
        }
      }
    }
    if(ans==INF) cout << -1 << endl;
    else cout << ans << endl;
  }
  return 0;
}



Measured memory_bytes: 28916
#include<stdio.h>
#define SQ(x) ((x)*(x))
typedef long long ll;
struct Point{
	int x,y;
}pt0, pt1;
Point vector(Point p1,Point p2){
	Point res;
	res.x = p2.x-p1.x;
	res.y = p2.y-p1.y;
	return res;
}
int dot(Point p1, Point p2){ return p1.x*p2.x+p1.y*p2.y; }
int cross(Point p1, Point p2){ return p1.x*p2.y-p1.y*p2.x; }
ll lengthSQ(Point vec){ return SQ(ll(vec.x))+SQ(ll(vec.y)); }
void solve(Point pt2){
	const Point vec1 = vector(pt0, pt1);
	const ll vec1Len2 = lengthSQ(vec1);
	Point vec2 = vector(pt0, pt2);
	int cro = cross(vec1, vec2);
	if(cro>0) printf("COUNTER_CLOCKWISE\n");// a×b>0，则b在a的逆时针方向
	else if(cro<0) printf("CLOCKWISE\n");// a×b<0，则b在a的顺时针方向
	else if(dot(vec1, vec2)<0) printf("ONLINE_BACK\n");// a×b=0, a·b<0，则a、b方向相反
	else if(lengthSQ(vec2)>vec1Len2) printf("ONLINE_FRONT\n");
	else printf("ON_SEGMENT\n");
}
int main(){
	Point temp;
	int x, y, q;
	scanf("%d%d%d%d%d", &pt0.x, &pt0.y, &pt1.x, &pt1.y, &q);
	while(q--){
		scanf("%d%d", &temp.x, &temp.y);
		solve(temp);
	}
}


Measured memory_bytes: 2584
#include <iostream>
#include <math.h>
#include <queue>
#include <algorithm>
#include <map>
#include <set>
#include <cstdlib>
#include <unordered_map>
#include <numeric>
#include <functional>
#include <limits.h>
#include <utility>
#include <stack>

using namespace std;

#define fs first
#define sc second

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


int main(){
    int N;
    priority_queue<P> que;
    ll a[210000], b[210000];
    cin >> N;
    for(int i = 0; i < N; i++){
        cin >> a[i];
    }
    for(int i = 0; i < N; i++){
        cin >> b[i];
        que.push(P(b[i], i));
    }

    ll res = 0;
    while(!que.empty()){
        P x = que.top(); que.pop();
        int index = x.sc;
        if(a[index] == b[index]){
            continue;
        }
        ll nextB, trial;
        if(a[index] >= max(b[(index + N + 1) % N], b[(index + N - 1) % N])){
            trial = (b[index] - a[index]) / (b[(index + N + 1) % N] + b[(index + N - 1) % N]);
            nextB = b[index] - (b[(index + N + 1) % N] + b[(index + N - 1) % N]) * trial;
            if(nextB != a[index]){
                cout << -1 << endl;
                return 0;
            }
        }
        else{
            ll nextBMax = max(b[(index + N + 1) % N], b[(index + N - 1) % N]);
            trial = (b[index] - nextBMax) / (b[(index + N + 1) % N] + b[(index + N - 1) % N]) + 1;
            nextB = b[index] - (b[(index + N + 1) % N] + b[(index + N - 1) % N]) * trial;
        }

        if(nextB < a[index]){
            cout << -1 << endl;
            return 0;
        }
        else if(nextB > a[index]){
            que.push(P(nextB, index));
        }
        b[index] = nextB;
        res += trial;
    }

    cout << res << endl;


    return 0;
}

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

using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
#define rep1(i,n) for(int i=1;i<n;i++)
typedef long long ll;

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


Measured memory_bytes: 256
program main
implicit none
integer :: i, j, k, l, a(26)
character :: s*100

read(*,*) s
l = len(s)
a = 0
do i = 1, l
   do j = 1, 26
      k = ichar(s(i:i)) -96
      if( j == k ) then
         a(j) = a(j) + 1
      end if
   end do
end do
do j = 1, 26
   if( mod(a(j),2) /= 0 ) then
      write(*,*) 'No'
      stop
   end if
end do
write(*,*) 'Yes'

end program main


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

double calc(int A, int B, double h, double m){
    static const double pi = 3.141592653589793;
    double t, c;
    t = A*A + B*B - 2*A*B*cos(abs((h-m)/180)*pi);
    c = sqrt(t);
    return c;

}

int main(){
    int A, B, H, M;
    cin >> A >> B >> H >> M;
    double ans, h, m;
    h = 0.5 * (H*60+M);
    m = 6*M;
    ans = calc(A, B, h, m);
    cout << std::fixed << std::setprecision(15)<< ans << endl;

}

Measured memory_bytes: 4224
#include <iomanip>
#include <iostream>
#include <string>
using namespace std;
int main(void) {
  int n;
  cin >> n;
  int a = 0;
  int b = 0;
  for(int i = 0; i < n; i++) {
    string s, t;
    cin >> s >> t;
    if(s < t)
      b += 3;
    else if(s > t)
      a += 3;
    else {
      a++;
      b++;
    }
  }
  cout << a << " " << b << endl;

  return 0;
}



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

int main(){
  int n;
  cin >> n;
  vector<int> p(n);
  for(int i = 0;i<n;i++){
    cin >> p.at(i);
  }
  sort(p.begin(),p.end());
  cout << p.at(n/2) - p.at(n/2-1) << endl;
}

Measured memory_bytes: 640
extern crate proconio;
use proconio::fastout;
use proconio::marker::Usize1;

#[fastout]
fn main() {
    proconio::input! {
        n: usize,
        k: usize,
        a: [[Usize1]; k],
    }
    let mut ans = vec![true; n];
    for a in a {
        for a in a {
            ans[a] = false;
        }
    }
    println!("{}", ans.into_iter().filter(|&x| x).count());
}


Measured memory_bytes: 2148
#include<iostream>
using namespace std;
int main(){
	int cards[4][13];
	for (int i = 0; i < 4; i++){
		for (int j = 0; j < 13; j++){
			cards[i][j] = 0;
		}
	}
	int n;
	cin >> n;
	for (int h = 0; h < n; h++){
		int num;
		char mar;
		cin >> mar >> num;
		if (mar == 'S'){
			cards[0][num - 1] = 1;
		}
		if (mar == 'H'){
			cards[1][num - 1] = 1;
		}
		if (mar == 'C'){
			cards[2][num - 1] = 1;
		}
		if (mar == 'D'){
			cards[3][num - 1] = 1;
		}
	}
	for (int i = 0; i < 4; i++){
		for (int j=0; j < 13; j++){
			if (cards[i][j] == 0){
				if (i == 0){
					cout << 'S' << " " << j + 1 << endl;
				}
				if (i == 1){
					cout << 'H' << " " << j + 1 << endl;
				}
				if (i == 2){
					cout << 'C' << " " << j + 1 << endl;
				}
				if (i == 3){
					cout << 'D' << " " << j + 1 << endl;
				}
			}
		}
	}
	return 0;
}


Measured memory_bytes: 3036
#include<cstdio>
#include<cstdlib>
#include<cmath>
#include<cstring>
#include<iostream>
#include<algorithm>
#include<string>
#include<iomanip>
#include<map>
#include<set>
#include<vector>
#define FAST ios::sync_with_stdio(false);cin.tie(0);cout.tie(0)
typedef long long ll;
const int inf = 0x3f3f3f3f;
const int maxn = (int)1e6 + 5;
const int mod = (int)1e9 + 9;
using namespace std;
 
ll x[maxn];
int v[maxn];
ll c[maxn], cc[maxn];
ll cmx[maxn], ccmx[maxn];
 
int main()
{
	//input
	int n; ll C; scanf("%d %lld", &n, &C);
	for(int i = 1; i <= n; i++) scanf("%lld %d", &x[i], &v[i]);
	//solve
	for(int i = 1; i <= n; i++){
		c[i] = c[i-1] + v[i] - (x[i] - x[i-1]);
		cmx[i] = max(cmx[i-1], c[i]);
	}
	x[n+1] = C;
	for(int i = n; i >= 1; i--){
		cc[n-i+1] = cc[n-i] + v[i] - (x[i+1] - x[i]);
		ccmx[n-i+1] = max(ccmx[n-i], cc[n-i+1]); 
	}
	ll ans = 0;
	for(int i = 0; i <= n; i++){
		ans = max(ans, c[i] - x[i] + ccmx[n-i]);
		ans = max(ans, cc[i] - (C - x[n-i+1]) + cmx[n-i]);
	}
	//output
	printf("%lld\n", ans);
	return 0;
}


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


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

	vector<int>  fact(0); //factor container
	long long num = n; // 素因数分解する変数num 
    bool chk = true;

	for (int i = 2; i < sqrt(n); i++) {
        chk = true;
		    while (num%i == 0) { // 素数で割り切れなくなるまで割っていく
                if(chk) fact.push_back(0);
			     fact.back()++; //割った個数を配列に足す
			    num /= i;
              chk = false;
		    }
      
	}
  
  if(num > sqrt(n)) fact.push_back(1);


	for (int i = 0; i <  fact.size(); i++){
        int j = 1;	
		while(fact.at(i)>=0){
          	fact.at(i) -= j;
          if(fact.at(i) < 0) break;
            ans++;
            j++;
        }
	}

    cout << ans << endl;

}

Measured memory_bytes: 3700
#include<bits/stdc++.h>
#define M 1000000007
using namespace std;

typedef long long int ll;

int main()
{
    ll x;
    cin>>x;
    ll l,r;
    bool ans = true;
    for(int i=0;i<=3981&&ans;i++)
    {
        for(int j=0;j<=3981&&ans;j++)
        {
            ll a = i, b = j;
            ll pospos = pow(a,5) - pow(b,5);
            ll posneg = pow(a,5) - pow(-b,5);
            ll negneg = pow(-a,5) - pow(-b,5);
            ll negpos = pow(-a,5) - pow(-b,5);
            if(pospos == x)
            {
                l = a;
                r= b;
                ans = false;
            }
            else if( posneg == x)
            {
                l = a;
                r = -b;
                ans = false;
            }
            else if(negneg == x )
            {
                l = -a;
                r = -b;
                ans = false;
            }
            else if(negpos == x)
            {
                l = -a;
                r = b;
                ans = false;
            }

        }

    }
    cout<<l<<" "<<r<<endl;
}


Measured memory_bytes: 4188
#include <stdio.h>

int main(){

	double a,b,c,d,e,f;

	double x,y;
	while(scanf("%lf%lf%lf%lf%lf%lf",&a,&b,&c,&d,&e,&f) != EOF){
	fflush(stdin);
	

	y=(c*d-a*f)/(b*d-a*e);

	x=(c-b*y)/a;

	printf("%.3f %.3f\n",x,y);
	}
	return 0;
}
	

Measured memory_bytes: 0
{-# OPTIONS_GHC -O2 #-}
{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE ScopedTypeVariables #-}
{-# LANGUAGE LambdaCase #-}
{-# LANGUAGE BangPatterns #-}
{-# LANGUAGE TupleSections #-}
module Main where

import           Data.List
import           Control.Monad
import           Debug.Trace
import qualified Data.ByteString.Char8         as BC
import           Data.Maybe                     ( fromJust, fromMaybe )
import qualified Data.Set                      as S
import qualified Data.IntMap.Strict            as IM
import qualified Data.IntMap.Lazy            as IML
import qualified Data.Map.Strict               as M
import           Data.Char
import qualified Data.Array.IArray as A
import qualified Data.Array.Unboxed as UA
import Data.Bits
import Control.Monad.State.Strict
import qualified Data.Array.ST as STA
import qualified Data.Array.IO as IOA
import qualified Data.Array.MArray as MA
import Control.Monad.ST
import System.IO (stdin)
import Control.Arrow
import qualified Data.Vector as V
import qualified Data.Vector.Unboxed as UV
import qualified Data.Vector.Generic as GV
import qualified Data.Vector.Mutable as MV
import Data.Ix
import Data.Ord (Down(Down))
import qualified Data.Sequence as Seq
import Data.Foldable (toList)
-- import Control.Lens

debug = False

ts :: Show a => a -> a
ts a = if debug then traceShowId a else a


readTuple2 :: IO (Int, Int)
readTuple2 = do
    [a, b] <- readInts
    return (a, b)

readTuple3 :: IO (Int, Int, Int)
readTuple3 = do
    [a, b, c] <- readInts
    return (a, b, c)


readInt :: IO Int
readInt = fst . fromJust . BC.readInt <$> BC.getLine

readInts :: IO [Int]
readInts = map (fst . fromJust . BC.readInt) . BC.words <$> BC.getLine

split :: (a -> Bool) -> [a] -> [[a]]
split f [] = []
split f as =
    let (fo, la) = span f as
        las      = case la of
            [] -> []
            xs -> split f $ tail xs
    in  case fo of
            [] -> las
            xs -> xs : las

main :: IO ()
main = do
  n <- readInt
  as <- readInts
  let fromLeft = scanl1 (+) as
      total = sum as
      diffList = (\a -> abs $ a -  (total - a)) <$> fromLeft
      closest = minimum diffList
  print closest





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

int main(){
    int e;
    //x >= 0, y >= 0, z >= 0
    //x + y^2 + z^3 = e
    //find min(x + y + z)
    while(scanf("%d", &e) != EOF && e != 0){
        int min_v = 0x7fffffff;
        for(int z = 0; z * z * z <= e; z++){
            int y = sqrt(e - z * z * z), x = e - z * z * z - y * y;
            min_v = min(min_v, x + y + z);
        }
        printf("%d\n", min_v);
    }
    return 0;
}

Measured memory_bytes: 1188
import string
S  = input()
lower = string.ascii_lowercase
n = len(S)
interest_part = S[2:-1] 
interest_index_list = []

if S[0] != 'A':
    print('WA')
else:
    C_counter = 0
    for i in range(len(interest_part)):
        if interest_part[i] == 'C':
            C_counter += 1
            interest_index_list.append(i+2)
    if C_counter != 1:
        print('WA')
    else:
        sub_string = S[:interest_index_list[0]] + S[interest_index_list[0]+1:]
        sub_string = sub_string[1:]
        for i in sub_string:
            if i not in lower:
                print('WA')
                break
        else:
            print('AC')

Measured memory_bytes: 3896
def solve(K):
    checked = [False] * K
    def calc(x):
        while not checked[x]:
            checked[x] = True
            yield x
            x = (x * 10) % K
    i = 0
    xs = [0]
    while 1:
        i += 1
        ys = []
        for x in xs:
            for z in calc((x + 1) % K):
                if z == 0:
                    return i
                ys.append(z)
        xs = ys

K = int(input())
print(solve(K))

Measured memory_bytes: 7832
#include<cstdio>
#include<cctype>
#include<algorithm>
using namespace std;
typedef long long LL;
int main(){
  int m,d,cnt=0;
  scanf("%d%d",&m,&d);
  for(int i=1;i<=m;i++)
    for(int j=10;j<=d&&j<100;j++){
      int d1=j%10,d10=j/10;
      cnt+=d1>=2&&d10>=2&&d1*d10==i;
  }
  printf("%d\n",cnt);
  return 0;
}

Measured memory_bytes: 128
import java.util.*

fun main(args: Array<String>) {
    val sc = Scanner(System.`in`)
    val n = sc.nextInt()
    val x = (0 until n).map { sc.next().toInt() }
    println(problem156c(n, x))
}

fun problem156c(n: Int, x: List<Int>): Long {
    val sumList = LongArray(100000) { Long.MAX_VALUE }
    for (i in 0 until 100000) {
        var sum = 0L
        for (j in 0 until n) {
            sum += Math.pow((x[j] - (i+1)).toDouble(), 2.0).toLong()
        }
        sumList[i] = sum
        if (i != 0 && sumList[i] > sumList[i - 1]) break
    }
    return sumList.min()!!
}

Measured memory_bytes: 38124
N,K = map(int,input().split())
X = list(map(int,input().split()))

ans = 10**18
for l in range(N-K+1):
    r = l+K-1
    if X[l]*X[r] >= 0:
        tmp = max(abs(X[l]), abs(X[r]))
    else:
        tmp1 = abs(X[l])*2 + abs(X[r])
        tmp2 = abs(X[r])*2 + abs(X[l])
        tmp = min(tmp1, tmp2)
    ans = min(ans, tmp)
print(ans)

Measured memory_bytes: 14384
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define lld long double
#define vc vector
typedef pair<ll,ll>pairs;
int main() {
	// your code goes here
	std::ios::sync_with_stdio(false);
	ll t,n,i,j,k,l,c,f;
	vector<ll>a(5);
	i=0;
	while(i<5)
	{
	    cin>>a[i];
	    if(a[i]==0)
	        c=i+1;
	        i++;
	}
	cout<<c<<"\n";
	return 0;
}


Measured memory_bytes: 3612
<?php
list($s) = strs();
list($t) = strs();
$s = str_split($s);
$t = str_split($t);
natsort($s);
natsort($t);
$s = implode('', $s);
$t = strrev(implode('', $t));
echo strnatcmp($s, $t) < 0 ? 'Yes' : 'No';
function strs()
{
    return explode(' ', trim(fgets(STDIN)));
}


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

const ll MAX = 510000;
const ll MOD = 1000000007;

ll fac[MAX], finv[MAX], inv[MAX];

// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

// 二項係数計算
ll comb(ll n, ll k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

int main() {
    ll H, W, A, B;
    cin >> H >> W >> A >> B;
    ll count = 0;
    ll dp[W-B+1], C[W-B+1];
    ll sum = 0;

    COMinit();

    dp[0] = 0; C[0] = 0;

    for (int i = 1; i <= W-B; i++) {
        C[i] = comb(H-A+B-2+i, B-1+i); // comb内でmodを取っている
        if (C[i] < 0) C[i] += MOD;
    }

    for (int i = 1; i <= W-B; i++) {
        dp[i] = C[i] - C[i-1];
        if (dp[i] < 0) dp[i] += MOD;
    }

    for (int i = 1; i <= W-B; i++) {
        ll c = (dp[i] * comb(A+W-B-i, A)) % MOD;
        if (c < 0) c += MOD;
        count += c;
        count %= MOD;
    }

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

Measured memory_bytes: 13696
#include <iostream>
#include <vector>
#include <tuple>
#include <cmath>
#include <algorithm>
#include <iomanip>
#include <string>
#include <climits>
#include <map>
#include <set>
using namespace std;
#define Rep(i, n) for (int i = 0; i < (n); ++i)
#define InitRep(i, begin, n) for (int i = (begin); i < (n); ++i)
#define RepItr(it, begin, end) for (auto it = (begin); it != (end); ++it)
using int64 = long long;
using vint = vector<int>;
using vint64 = vector<int64>;
static double PI = ::acos(-1);


int main()
{
    int64 n, m;
    cin >> n >> m;
    vector<vint> to(n);
    Rep(i, m)
    {
        int s, t;
        cin >> s >> t;
        --s;
        --t;
        to[s].push_back(t);
    }

    vector<double> dp(n);
    for (int v = n - 2; v >= 0; --v)
    {
        double tmp = 0;
        for (int u : to[v])
        {
            tmp += dp[u];
        }
        tmp /= to[v].size();
        dp[v] = tmp + 1;
    }
    double ans =  dp[0];

    Rep(nv, n - 1)
    {
        if (to[nv].size() == 1) continue;
        int nu = to[nv][0];
        for (int u : to[nv])
        {
            if (dp[nu] < dp[u])
            {
                nu = u;
            }
        }

        double newAns = [&]()
        {
            vector<double> dp(n);
            for (int v = n - 2; v >= 0; --v)
            {
                double tmp = 0;
                for (int u : to[v])
                {
                    if (v == nv && u == nu) continue;
                    tmp += dp[u];
                }
                tmp /= (v == nv) ? to[v].size() - 1 : to[v].size();
                dp[v] = tmp + 1;
            }
            return dp[0];
        }();
        ans = min(ans, newAns);
    }
    cout << setprecision(10) << ans << endl;

    return 0;
}


Measured memory_bytes: 1408
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

int main(void) {
    int a,b;
    char s[11], t[11], u[11];
    scanf("%s %s", &s, &t);
    scanf("%d %d", &a, &b);
    scanf("%s", &u);

    if( strcmp(s,u) == 0 ) {
        a -= 1;
    } else {
        b -= 1;
    }

    printf("%d %d\n", a, b);
    return 0;
}

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

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

   int a,b;
   cin >> a >> b;

   if(a + b == 15) cout << '+' << endl;
   if(a * b == 15) cout << '*' << endl;
   if(a + b != 15 && a * b != 15) cout << 'x' << endl;

   return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <iomanip>
#include <random>
#include <cstdio>
#include <cmath>
#include <map>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (int) n; i++)

int main() {
    int h,a; cin >> h >> a;
    if ((double)h/a == (int)h/a) {
        cout << h/a << endl;
    } else {
        cout << h/a+1 << endl;
    }
    return 0;
}

Measured memory_bytes: 256
#最大公約数を求める
def gcd(a,b):
    if b == 0:
        return a
    else:
        return gcd(b,a % b)

#nの素因数分解を行い、リスト[[素因数,指数],....]を返す
# 2020 = 2^2 * 5^1 * 101^1
#[[2,2],[5,1],[101,1]
def prime_factorize(n):
    #返す配列
    res = []
    for i in range(2,n+1):
        #指数
        ex = 0
        # √Nまで行う
        if i * i > n:
            break
        if n % i != 0:
            continue
        #iで割り続ける
        while ( n % i == 0):
            ex += 1
            n /= i
        #その結果を追加
        res.append([i,ex])
    #最後に残った数について、1でなければ素数なのでリストに加える
    if n != 1:
        res.append([int(n),1])

    return res

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

#最大公約数を求める
G = gcd(A,B)

#素因数分解
pf = prime_factorize(G)

#素因数のの個数 + 1 が答え
print(len(pf) +1)


Measured memory_bytes: 38512
#include <algorithm>
#include <bitset>
#include <cctype>
#include <cmath>
#include <cstdlib>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <set>
#include <string>
#include <utility>
#include <vector>
#define IOS ios::sync_with_stdio(false); cin.tie(0);
#define FOR(i, s, n) for(int i = s; i < (n); ++i)
#define REP(i, n) FOR(i, 0, n)
typedef long long ll;
const int MOD = 1000000007;
using namespace std;


int main(){
    int n, cnt = 0; cin >> n;
    map<int, int> mp;
    REP(i, n){
        int a; cin >> a;
        ++mp[a];
    }
    for(auto x : mp){
        if(x.second % 2) ++cnt;
    }
    cout << cnt << "\n";
    return 0;
}


Measured memory_bytes: 4992
#include <bits/stdc++.h>
#define mp make_pair
#define pb push_back
#define IOS ios::sync_with_stdio(false); cin.tie(0);
#define sd(n) scanf("%d",&n)
#define sl(n) scanf("%lld",&n)
#define pd(n) printf("%d",n)
#define pl(n) printf("%lld",n)
#define endc printf("\n")

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

const int maxn = 1e5 + 7; 
const int lmx  = 19;
//const int md = 1e9 + 7;

int n;
int x[maxn];
int L;
int f[maxn][lmx];
int g[maxn][lmx];


int main() {
	sd(n);
	for (int i = 1; i <= n; i++) sd(x[i]);
	sd(L);
	for (int i = 1; i <= n; i++) {
		int l = i, r = n;
		while (l < r) {
			int mid = (l+r+1)>>1;
			if (x[mid] - x[i] <= L) l = mid;
			else r = mid-1;
		}
		f[i][0] = l; g[i][0] = i;
	}
	for (int j = 1; j < lmx; j++) {
		for (int i = 1; i <= n; i++) f[i][j] = f[f[i][j-1]][j-1];
	}

	for (int j = 1; j < lmx; j++) {
		for (int i = 1; i <= n; i++) g[i][j] = g[f[i][j-1]][j-1];
	}

	int q; sd(q);
	while (q--) {
		int a,b; sd(a); sd(b); if (a > b) swap(a,b);
		int ans = 0;
		for (int j = lmx-1; j >= 0; j--) {
			if (g[a][j] < b) { ans += 1<<j; a = f[a][j]; }
		}
		pd(ans); endc;
	}
}


Measured memory_bytes: 16000
#include <iostream>
#include <vector>
#include <cstdio>

#define M 100010

using namespace std;

int main(int argc, char const *argv[])
{
	int m,a,b;
	bool sosu[M];
	vector<int> v;
	int p,q;
	int max;

	sosu[0]=true;
	sosu[1]=true;
	for(int i1=2;i1<M;i1++){
		if(sosu[i1]!=true){
			//fprintf(stderr,"%d ",i1);
			v.push_back(i1);
			for(int i2=2;i2*i1<M;i2++){
				sosu[i1*i2]=true;
			}
		}
	}

	while(1){
		cin>>m>>a>>b;
		if(m+a+b==0) break;

		max=0;
		for(int i1=0;v[i1]*v[i1]<=m;i1++){
			for(int i2=i1;v[i2]*v[i1]<=m;i2++){
				if(m>=v[i1]*v[i2] && (double)a/(double)b<=(double)v[i1]/(double)v[i2] && (double)v[i1]/(double)v[i2]<=1){
					if(max<v[i1]*v[i2]) {
						max=v[i1]*v[i2];
						p=v[i1];
						q=v[i2];
					}
				}
			}
		}
		cout<<p<<" "<<q<<endl;
		
	}
	return 0;
}

Measured memory_bytes: 1420
# -*- coding: utf-8 -*-
"""
Created on Thu May 14 17:06:47 2020

@author: shinba
"""
import sys

n,m = map(int,input().split())
A = []
for i in range(n):
    a = input()
    A.append(a)
B = []
for j in range(m):
    b = input()
    B.append(b)

for i in range(n-m+1):
    for j in range(n-m+1):
        for k in range(m):
            if A[j+k][i:i+m] == B[k]:
                continue
            else:
                break
        else:
            print("Yes")
            sys.exit()
else:
    print("No")
        

Measured memory_bytes: 3064
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#define rep(i, n) for(int i = 0; i < (int)(n); ++i)
#define REP(i, n) for(int i = 1; i < (int)(n); ++i)
using namespace std;

int main() {
    int N;
    cin >> N;
    vector<int> A(N);
    rep(i, N) cin >> A[i];
    
    vector<int> B(N);
    rep(i, N) B[i] = A[i];
    sort(B.rbegin(), B.rend());
    rep(i, N) {
        if (A[i] == B[0]) cout << B[1] << endl;
        else cout << B[0] << endl;
    }
    return 0;
}


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

constexpr int INF = 2147483647;
constexpr long long int INF_LL = 9223372036854775807;
constexpr int MOD = 1000000007;
using namespace std;
typedef long long int ll;
typedef unsigned long long int ull;

// 3000 * 1000 * log(1000000)
int main() {
	ll X, Y, Z, K;
	cin >> X >> Y >> Z >> K;
	vector<ll> A(X), B(Y), C(Z);
	for (int i = 0; i < X; i++)cin >> A[i];
	for (int i = 0; i < Y; i++)cin >> B[i];
	for (int i = 0; i < Z; i++)cin >> C[i];

	sort(C.begin(), C.end(), greater<>());

	vector<ll> AB;
	AB.push_back(-INF_LL); //番兵
	AB.push_back(INF_LL);
	for (int i = 0; i < X; i++)for (int j = 0; j < Y; j++)AB.push_back(A[i] + B[j]);
	sort(AB.begin(), AB.end());
	
	ll ans = 0;
	ll prev_max = INF_LL/8;
	for (int i = 0; i < K; i++) {
		//AB[i] + C[j] < prev_max かつ最大になるi,jを見つけたい
		ll tmp = -INF;
		ll a = 0;
		for (int j = 0; j < Z; j++) {
			auto itr = lower_bound(AB.begin(), AB.end(), prev_max - C[j]);
			if (*itr == -INF_LL)continue;
			itr--;
			auto itr2 = lower_bound(AB.begin(), AB.end(), *itr);
			ll b = itr - itr2 + 1;

			if (C[j] + *itr > tmp) {
				tmp = C[j] + *itr;
				a = b;
			}
			else if (C[j] + *itr == tmp) {
				a += b;
			}

		}
		ans += tmp;
		prev_max = tmp;
		for (int j = 0; j < a; j++) {
			if (i + j >= K)break;
			cout << tmp << endl;
		}
		i += a - 1;
	}
}


Measured memory_bytes: 10480
#include <iostream>
#include <vector>
#include <list>
#include <algorithm>
#include <string>
#include <sstream>
#include <stack>
#include <iomanip>
#include <numeric>
#include <queue>
#include <climits>
#include <bitset>
#include <set>
#include <complex>
#include <cmath>
#include <cstring>
#include <map>
using namespace std;
using ll = long long;
using ppp = pair<pair<int, int>, pair<int, int>>;
#define MOD 1000000007
#define INF 1LL << 59
const int MAX = 510000;
const long long mod = 917120411LL;

long long fac[MAX], finv[MAX], inv[MAX];

// テーブルを作る前処理
void COMinit()
{
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++)
    {
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD % i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

// 二項係数計算
long long COM(int n, int k)
{
    if (n < k)
        return 0;
    if (n < 0 || k < 0)
        return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

int sieve[1000010];
void make_sieve()
{
    for (int i = 0; i < 1000010; ++i)
        sieve[i] = true;
    sieve[0] = sieve[1] = false;
    for (int i = 0; i * i < 1000010; ++i)
    {
        if (sieve[i])
        {
            for (int j = 2; j * i < 1000010; ++j)
            {
                sieve[i * j] = false;
            }
        }
    }
}

ll GCD(ll a, ll b)
{
    if (a < b)
        swap(a, b);
    if (b == 0)
        return a;
    else
        return GCD(b, a % b);
}
ll pow_mod(ll x, ll n)
{
    ll res = 1;
    while (n)
    {
        if (n & 1)
        {
            res = res * x;
        }
        x = x * x;
        n >>= 1;
    }
    return res;
}

int a[200010];
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);

    int N, x;
    cin >> N >> x;

    if (x == 1 || x == 2 * N - 1)
    {
        cout << "No" << endl;
    }
    else
    {
        cout << "Yes" << endl;
        int ans[200010] = {0};
        bool used[200010];
        for (int i = 0; i < 200010; ++i)
            used[i] = false;
        ans[N] = x;
        ans[N - 1] = 1;
        ans[N + 1] = 2 * N - 1;
        used[x] = true;
        used[1] = true;
        used[2 * N - 1] = true;

        int idx = 1;
        int cnt = 2 * N - 2;
        while (idx <= 2 * N - 1)
        {
            if (used[cnt])
            {
                cnt--;
                continue;
            }
            if (ans[idx])
            {
                idx++;
                continue;
            }
            else
            {
                ans[idx] = cnt;
                cnt--;
                idx++;
                continue;
            }
        }

        for (int i = 1; i <= 2 * N - 1; ++i)
        {
            cout << ans[i] << endl;
        }
    }
    return 0;
}


Measured memory_bytes: 2432
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int (i)=0;(i)<(n);i++)
#define INF 1001001001
#define LLINF 1001001001001001001
#define MOD 1000000007
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
#define ALL(v) v.begin(), v.end()
typedef long long ll;

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

    
    int ans = 1000;

    for(int i=0;i<s.length()-2;i++){
        int tem = 0;
        tem = s[i+2]-'0' + 10*(s[i+1]-'0') + 100*(s[i]-'0');
        ans = min(abs(tem-753),ans);
    }

    cout << ans << endl;


    return 0;

}


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


int main(){
  string s;
  int k;
  std::cin >> k>>s;
  if(s.size()<=k)std::cout << s << '\n';
  else std::cout << (s.substr(0,k)+"...") << '\n';

  return 0;
}


Measured memory_bytes: 3616
import java.util.*;
public class Main {

  public static void main(String[] args) { 
      Scanner sc = new Scanner(System.in);
      int n = sc.nextInt();
      long[] arr = new long[n];
      for(int i = 0; i < n; i++) {
        arr[i] = sc.nextInt();
      }
      Arrays.sort(arr);
      long[] prefixSum = new long[n];
      prefixSum[0] = arr[0];
      for(int i = 1; i < n; i++) {
        prefixSum[i] = prefixSum[i-1] + arr[i];
      }
      boolean[] can = new boolean[n];
      can[n-1] = true;
      for(int i = n - 2; i >= 0; i--) {
        long num = prefixSum[i] * 2;
        int idx = lowerUpper(i+1, arr, num);
        if(can[idx]) can[i] = true;
      }
      int cnt = 0;
      for(int i = 0; i < can.length; i++)
        if(can[i]) cnt++;
      System.out.println(cnt);
  }

  private static int lowerUpper(int left, long[] arr, long target) {
    int right = arr.length - 1;
    while(left <= right) {
      int mid = left + (right - left) / 2;
      if(arr[mid] <= target)
        left = mid + 1;
      else right = mid - 1;
    }
    return right;
  }
}

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

// #define int long long
#define rep(i, n) for (int i = (int)(0); i < (int)(n); ++i)
#define reps(i, n) for (int i = (int)(1); i <= (int)(n); ++i)
#define rrep(i, n) for (int i = ((int)(n)-1); i >= 0; i--)
#define rreps(i, n) for (int i = ((int)(n)); i > 0; i--)
#define irep(i, m, n) for (int i = (int)(m); i < (int)(n); ++i)
#define ireps(i, m, n) for (int i = (int)(m); i <= (int)(n); ++i)
#define SORT(v, n) sort(v, v + n);
#define REVERSE(v, n) reverse(v, v+n);
#define vsort(v) sort(v.begin(), v.end());
#define all(v) v.begin(), v.end()
#define mp(n, m) make_pair(n, m);
#define cout(d) cout<<d<<endl;
#define coutd(d) cout<<std::setprecision(10)<<d<<endl;
#define cinline(n) getline(cin,n);
#define replace_all(s, b, a) replace(s.begin(),s.end(), b, a);
#define PI (acos(-1))
#define FILL(v, n, x) fill(v, v + n, x);
#define sz(x) int(x.size())

using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using vs = vector<string>;
using vpll = vector<pair<ll, ll>>;

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; }

const ll INF = 1e15;
const int MOD = 1e9+7;
const ll LINF = 1e18;



signed main()
{
  cin.tie( 0 ); ios::sync_with_stdio( false );
  ll n,l; cin>>n>>l;
  vs s(n);
  rep(i,n) cin>>s[i];
  vsort(s);
  rep(i,n){
    cout<<s[i];
  }
  cout<<endl;
}

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


// 2011/10/24 
// 44 27.672

// 0554 TotalTime
public class Main {


	// C return falseÅ¨µÜ¢
	boolean main() throws IOException {

		int a = readIntArray()[0];
		int b = readIntArray()[0];
		int c = readIntArray()[0];
		int d = readIntArray()[0];
		//if (n == 0)
		//	return false;
		
		int sum = a + b + c + d;
		System.out.printf("%d\n%d\n", sum/60, sum%60);
		
		
		return false;
//		return true; // ³íI¹ Ö
	}
	

//	private final static boolean DEBUG = true;  // debug
	private final static boolean DEBUG = false; // release

	public static void main(String[] args) throws IOException {

		if (DEBUG) {
			log = System.out;
			
			String inputStr = "3:Cyan Yellow Red Magenta Green Blue:Cyan Yellow Red Magenta Green Blue:Red Yellow Magenta Blue Green Cyan:0:";

			inputStr = inputStr.replace(":", "\n");

			reader = new BufferedReader(new StringReader(inputStr)); 

		}
		else {
			log = new PrintStream(new OutputStream() { public void write(int b) {} } ); // «ÌÄ
			reader = new BufferedReader(new InputStreamReader(System.in)); // R\[©ç
		}
		
		int N = Integer.MAX_VALUE;
		//int N = readIntArray()[0];

		for(int i = 0; i < N; i++) {
			boolean b = new Main().main();
			if (!b)
				break;
		}		
		
		reader.close();
	}

	
	static PrintStream log;
	static BufferedReader reader;
	

	// WüÍæè1sªÌæØè¶æØèÅÌ®lðÇÞ
	// EOFÌêÍnullðÔ·
	private static int[] readIntArray() throws IOException {

		String s = null;
		for(;;) {
			s = reader.readLine();
//			log.printf("%s\n", s);
			if (s == null)
				return null;
			s = s.trim();
			if (s.length() != 0) // ¦¦¦@Ç¤àËRósðÇÞ±Æª éBÇÝòÎ·Æ¤Ü­¢­çµ¢BBBB
				break;
		}
		
		String[] sp = s.split("[ ,]"); // æØè¶ÍXy[X©J}
		int[] a = new int[sp.length];
		for(int i = 0; i < sp.length; i++) {
			a[i] = Integer.parseInt(sp[i]);
		}
		return a;
	}
		
}

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


class Program
{
    static void Main(string[] args)
    {
        int n = int.Parse(Console.ReadLine());
        int a = n / 100;
        int b = (n - a * 100) / 10;
        int c = (n - a * 100 - b * 10);
        int ans = 0;
        if (n > a * 100 + a * 10 + a)
        {
            ans = (a + 1) * 100 + (a + 1) * 10 + a+1;
        }
        else
        {
            ans = a * 100 + a * 10 + a;
        }

        if (n == a * 100 + a * 10 + a) ans = n;
        
        Console.WriteLine(ans);
        
    }


}

Measured memory_bytes: 11092
def factorization(n):
    arr = []
    temp = n
    for i in range(2, int(-(-n**0.5//1))+1):
        if temp%i==0:
            cnt=0
            while temp%i==0:
                cnt+=1
                temp //= i
            arr.append([i, cnt])

    if temp!=1:
        arr.append([temp, 1])

    if arr==[]:
        arr.append([n, 1])

    return arr

import math
def myFactorization(n):
    '''nを素因数分解する

    戻り値: factList = [[prime1, exp1], [prime2, exp2],...] 
           n=(prime1)**exp1 * (prime2)**exp2 * ...
    '''

    factList=[]
    temp=n
    cnt=0
    while(temp%2==0):
        temp=temp//2
        cnt+=1
    if(cnt>0):
        factList.append([2,cnt])

    m=int(math.sqrt(n))+1
    for i in range(3,m+1,2):
        cnt=0
        while(temp%i==0):
            temp=temp//i
            cnt+=1
        if(cnt>0):
            factList.append([i,cnt])
        if(temp==1):
            break
    if(temp>1):
        factList.append([temp,1])
    return factList            


def readinput():
    n=int(input())
    return n

def possibleCnt(n):
    cnt=0
    resu=n
    for i in range(1,n+1):
        if resu >= i:
            cnt+=1
            resu-=i
            #print(cnt,resu)
    return cnt       

def main(n):
    #ansList=factorization(n)
    ansList=myFactorization(n)
    #print(ansList)
    count=0
    for l in ansList:
        if(l[0]!=1):
            count+=possibleCnt(l[1])
    return count    


if __name__=='__main__':
    n=readinput()
    ans=main(n)
    print(ans)



Measured memory_bytes: 9324