akhauriyash/Code-Regression huggingface dataset:
# AOJ 0103: Baseball Simulation
# Python3 2018.6.17 bal4u

for i in range(int(input())):
	p1 = p2 = p3 = out = cnt = 0;
	while True:
		s = input()
		if s == 'HIT':
			if p3 > 0: cnt += 1
			p3, p2, p1 = p2, p1, 1
		elif s == 'HOMERUN':
			cnt += p1 + p2 + p3 + 1
			p1 = p2 = p3 = 0
		else:
			out += 1
			if out == 3: break
	print(cnt)


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

Measured memory_bytes: 3624
#include <cstdio>
#include <climits>
using namespace std;

int main()
{
	int array[200][200];
	int n;
	
	scanf("%d", &n);
	for (int i = 0; i < n; i++){
		for (int j = 0; j < n; j++){
			scanf("%d", &array[i][j]);
			
			if (i > 0) array[i][j] += array[i - 1][j];
			if (j > 0) array[i][j] += array[i][j - 1];
			if (i > 0 && j > 0) array[i][j] -= array[i - 1][j - 1];
		}
	}

	
	long Max = LONG_MIN;
	for (int si = 0; si < n; si++){
		for (int sj = 0; sj < n; sj++){
			for (int ei = si; ei < n; ei++){
				for (int ej = sj; ej < n; ej++){
					int sum = array[ei][ej];
//					sum = array[ei][ej] -= array[si - 1][ej] 
//					-= array[ei][sj - 1] += array[si - 1][sj - 1];
					
					if (si > 0) sum -= array[si - 1][ej];
					if (sj > 0) sum -= array[ei][sj - 1];
					if (si > 0 && sj > 0) sum += array[si - 1][sj - 1];
					
					if (Max < sum){
						Max = sum;
					}
				}
			}
		}
	}
	
	printf("%d\n", Max);
	
	return 0;
}

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

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

using namespace std;

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; }
const long long INF = 1LL<<60;


const int MAX_H=10000;
const int MAX_N=1000;

int H,N;
string str;



int main()
{

    cin>>str;
    if (str[0]==str[1] and str[0]==str[2])
    {
        cout << "No"<<endl;
    }
    else
    {
        cout<<"Yes"<<endl;
    }
    return 0;
}




Measured memory_bytes: 256
#include<stdio.h>
//#include<stdlib.h>
#define INF (1<<30)

int A[500000];
int count = 0;
int R[500000],L[500000];


void merge(int A[],int left,int mid,int right){
  
  int n1,n2;
  int i,j,k;

  n1 = mid - left;
  n2 = right - mid; //divided by mid

  for( i = 0 ; i < n1 ; i++)
    L[i] = A[left + i];
  for( i = 0 ; i < n2 ; i++)
    R[i] = A[mid + i];

  L[n1] = INF;
  R[n2] = INF;

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


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


int main(){
  int length,i;
  scanf("%d",&length);
  for(i = 0; i < length ; i++){
    scanf("%d",&A[i]);
  }
  mergeSort(A,0,length);
  for(i = 0 ; i < length-1 ; i++)
    printf("%d ",A[i]);
  printf("%d\n%d\n",A[i],count);

  return 0;
  
}

Measured memory_bytes: 5484
#include <cstdio>
#include <algorithm>
#include <vector>
#include <deque>
#include <cstdint>

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

  std::vector<intmax_t> A(N);
  for (int i=0; i<N; ++i)
    scanf("%jd", &A[i]);

  if (N == 1) {
    printf("%jd\n", A[0]);
    return 0;
  } else if (N == 2) {
    printf("%jd\n", std::max(A[0], A[1]));
    return 0;
  }

  std::vector<std::vector<intmax_t>> dp(N, std::vector<intmax_t>(N));
  for (int i=0; i<N; ++i) {
    dp[i][i] = A[i];
  }

  // XXX half-open interval is better than this... 
  for (int i=1; i<N; ++i) {
    for (int j=0; j<N; ++j) {
      // dp[j][(i+j)%N]; haba: i, hidari: j
      // l_next, [l_cur, ..., r_cur], r_next
      int l_cur=j, r_cur=(l_cur+i+N-1)%N;
      int l_next=(l_cur-1+N)%N, r_next=(r_cur+1)%N;
      if (l_cur == r_next) {
        continue;
      }
      if (i % 2 == 0) {
        // JOI
        dp[l_cur][r_next] = std::max(dp[l_cur][r_next], dp[l_cur][r_cur]+A[r_next]);
        dp[l_next][r_cur] = std::max(dp[l_next][r_cur], dp[l_cur][r_cur]+A[l_next]);
      } else {
        // IOI
        if (A[l_next] > A[r_next]) {
          // ... eats A[l_next]
          dp[l_next][r_cur] = std::max(dp[l_next][r_cur], dp[l_cur][r_cur]);
        } else {
          dp[l_cur][r_next] = std::max(dp[l_cur][r_next], dp[l_cur][r_cur]);
        }
      }
    }
  }

#if 0
  for (int i=0; i<N; ++i) {
    for (int j=0; j<N; ++j) {
      printf("%jd%c", dp[j][(j+i)%N], j+1<N? ' ':'\n');
    }
  }
#endif

  intmax_t res=0;
  for (int i=0; i<N; ++i)
    res = std::max(res, *std::max_element(dp[i].begin(), dp[i].end()));

  printf("%jd\n", res);
  return 0;
}

Measured memory_bytes: 33812
#include <iostream>
#include <stdlib.h>
#include <vector> //vector
#include <algorithm> //sort()
#include <numeric>

#define rep(i, n) for(int i=0; i<(int)(n);i++)
#define all(x) (x).begin(), (x).end()
#define debug(a) cout << "debug (" #a "):" << endl << (a) << endl;

typedef uint64_t ulint;
typedef int64_t lint;

using namespace std;

template<class T> inline bool chmin(T& a, T b);
template<class T> inline bool chmax(T& a, T b);
template<typename T> ostream& operator<<(ostream& s, const vector<T>& v);

template<class T> lint sum(vector<T> a);
template<class T> double ave(vector<T> a);

//uint64_t a, b, c, d;
//uint64_t i, j;
lint n, x,l;

int main(){
//////////////////////////////////////////////////////

    cin >> n >> x;


    lint d=0;
    lint sum = 1;
    rep(i,n)
    {
        cin >> l;
        d+=l;
        if(d<=x)
        {
            sum++;
        }
        else
        {
            break;
        }
        
        
    }



    //昇順ソート
    //sort(all(a));


    //デバッグ出力
    //debug(a);
    //debug(b);
    //debug(c);


    cout << sum << endl;

    

   

    // sort(input.begin() , input.end());

    // uint64_t max = numeric_limits<uint64_t>::max();


    //////////////////////////////////////////////////////
    // DP

//     // 無限大の値
//     const uint64_t INF = (uint64_t)1 << 60;
//     //const int64_t NINF = -1 * ((int64_t)1 << 60 );
 
//     // DP テーブル
//     uint64_t dp[100010];

//     //DPテーブル初期化（最小化用）
//     for (int i = 0; i < 100010; ++i)
//     {
//         //dp[i] = INF;
//         dp[i] = 0;
//     } 

//     // 初期条件
//     dp[0] = 0;

//     // ループ
//     for (int i = 1; i <= n; ++i) {
//         //chmin( dp[i], dp[i - 1] + abs( input[i] - input[i - 1] ));
//         //if (i < 2)continue;
//         //chmin( dp[i], dp[i - 2] + abs( input[i] - input[i - 2] ));



//         // chmax ( dp [i] , dp[i - 1]);
//         // chmax ( dp [i] , dp[i - 1] + input[i]);
//         // cout << "dp[" << i <<"] = " << dp[i] << endl;

//     }



// //////////////////////////////////////////////////////

//     cout << dp[n] << endl;

//////////////////////////////////////////////////////
// Ctrl + Opt + N to make
    return 0;
}


//最小化用関数
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;
}


// vectorprint用
template<typename T> ostream& operator<<(ostream& s, const vector<T>& v) {
	int len = v.size();
	for (int i = 0; i < len; ++i) {
		s << v[i]; if (i < len - 1) s << "\t";
	}
	return s;
}

// //合計
// template<class T> lint sum(vector<T> a)
// {
//     return std::accumulate(a.begin(), a.end(), 0);
// }


// //平均
// template<class T> double ave(vector<T> a)
// {
//     return std::accumulate(a.begin(), a.end(), 0.0) / a.size();
// }


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
using namespace std;

class Edge
{
public:
	int from, to, cost;
	Edge(){}
};

const int INF = 999999999;
int cost[1000];
Edge e[2000];
int V, E, r;
bool isUpdated;

bool bellmanford()
{
	fill(cost, cost + V, INF);
	cost[r] = 0;

	for (int i = 0; i < V; i++)
	{
		isUpdated = false;
		for (int j = 0; j < E; j++)
		{
			if (cost[e[j].from] == INF) continue;
			if (cost[e[j].to] <= cost[e[j].from] + e[j].cost) continue;
			isUpdated = true;
			cost[e[j].to] = cost[e[j].from] + e[j].cost;
		}
		if (!isUpdated) return true;
	}
	return false;
}

int main()
{
	cin >> V >> E >> r;
	for (int i = 0; i < E; i++)
	{
		cin >> e[i].from >> e[i].to >> e[i].cost;
	}

	if (bellmanford())
	{
		for (int i = 0; i < V; i++)
		{
			if (cost[i] == INF)
			{
				cout << "INF" << endl;
				continue;
			}
			cout << cost[i] << endl;
		}
	}
	else
	{
		cout << "NEGATIVE CYCLE" << endl;
	}

	return 0;
}

Measured memory_bytes: 3128
#include<bits/stdc++.h>
using namespace std;
int main()
{
  	int n;
  	cin>>n;
  	int ar[n];
  	for(int i=0;i<n;i++)
    {
      	cin>>ar[i];
    }
  	int c=0;
  	for(int i=1;i<n-1;i++)
    {
      	if((ar[i]>ar[i-1] && ar[i]<ar[i+1]) || (ar[i]<ar[i-1] && ar[i]>ar[i+1]))
        {
          	c++;
        }
    }
  	cout<<c<<"\n";
  	return 0;
}

Measured memory_bytes: 256
#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;
struct pt
{
	int id;
	char ch;
}a[100005],c[1005];
int n,at,f[1005],t,ct;
char s[63]="0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz";
char str[1005];
bool operator<(const pt x,const pt y)
{
	if(x.ch==y.ch)
	{
		return x.id<y.id;
	}
	t=0;
	for(int i=1;i<=x.id;i++)
		str[t++]=x.ch;
	for(int j=y.id;j<=f[y.ch];j++)
		str[t++]=y.ch;
	str[t]=0;
	printf("? %s\n",str);
	fflush(stdout);
	int nw;
	scanf("%d",&nw);
	if(nw!=n-t) return 0;
	return 1;
}
void merge(int l,int r)
{
	if(l>=r) return;
	int mid=(l+r)/2;
	merge(l,mid);
	merge(mid+1,r);
	int itl=l,itr=mid+1,mxl=mid,mxr=r;
	ct=l-1;
	while(itl<=mxl&&itr<=mxr)
	{
		if(a[itl]<a[itr])
		{
			c[++ct]=a[itl];
			itl++;
		}
		else
		{
			c[++ct]=a[itr];
			itr++; 
		}
	}
	while(itl<=mxl)
	{
		c[++ct]=a[itl];
		itl++;
	}
	while(itr<=mxr)
	{
		c[++ct]=a[itr];
		itr++; 
	}
	for(int i=l;i<=r;i++)
		a[i]=c[i];
}
int main()
{
	for(int i=0;i<62;i++)
	{
		/*int mn=1e9;
		for(int j=1;;j++)
		{
			printf("? ");
			for(int k=1;k<=j;k++)
				printf("%c",s[i]);
			printf("\n");
			fflush(stdout);
			int nw;
			scanf("%d",&nw);
			if(mn<=nw)
			{
				for(int k=1;k<j;k++)
				{
					a[++at].ch=s[i];
					a[at].id=k;
				}
				f[s[i]]=j-1;
				break;
			}
			mn=nw;
		}*/
		printf("? ");
		for(int j=1;j<=128;j++)
			printf("%c",s[i]);
		printf("\n");
		fflush(stdout);
		int nw;
		scanf("%d",&nw);
		nw=128-nw;
		for(int k=1;k<=nw;k++)
		{
			a[++at].ch=s[i];
			a[at].id=k;
		}
		f[s[i]]=nw;
	}
	n=at;
	merge(1,n);
	printf("! ");
	for(int i=1;i<=n;i++)
		printf("%c",a[i].ch);
	return 0;
}

Measured memory_bytes: 3800
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define FAST_IO ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
struct points{
    int x,y;
};
int main(){
    //freopen("input.txt","r",stdin);
    //freopen("output.txt","w",stdout);
    double h,w,n;
    while(cin>>h>>w>>n){
        cout<<ceil(n/max(h,w))<<endl;
    }
    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>

int main() {
	int n, m;
	int l[100000], r[100000];
	scanf("%d%d", &n, &m);
	for (int i = 1; i <= m; i++)
		scanf("%d%d", &l[i], &r[i]);
	int maxl = 0, minr = 100000;
	for (int i = 1; i <= m; i++)
		if (maxl < l[i])
			maxl = l[i];
	for (int i = 1; i <= m; i++)
		if (minr > r[i])
			minr = r[i];
	if (minr - maxl < 0)
		printf("0");
	else if (minr - maxl + 1 > n)
		printf("%d", n);
	else
		printf("%d", minr - maxl + 1);
	return 0;
}

Measured memory_bytes: 896
namespace ABC124_A
{
    using System;
    using System.Collections.Generic;
    using System.Linq;
    using static System.Console;

    public class Program
    {
        public static void Main(string[] args)
        {
            var input = ReadInputsAsInt().ToList();
            WriteLine(Solve(input[0], input[1]));
        }

        public static int Solve(int a, int b)
        {
            if (a == b) return 2 * a;

            var max = Math.Max(a, b);
            return max + (max - 1);
        }

        public static IEnumerable<int> ReadInputsAsInt() => ReadLine().Split(' ').Select(x => int.Parse(x));
    }
}

Measured memory_bytes: 11220
#include <iostream>
#include <map>
#include <vector>
#include <algorithm>

using namespace std;

map<int, int> m1;
map<int, int> m2;

bool comp1(int a, int b) {
  return m1[a] > m1[b];
}


bool comp2(int a, int b) {
  return m2[a] > m2[b];
}

int main(int argc, char* argv[]) {
  int n;
  cin >> n;

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

  vector<int> a;
  for (int i = 0; i < n; i += 2) {
    if (m1.find(v[i]) == m1.end()) {
      m1[v[i]] = 0;
      a.push_back(v[i]);
    }
    ++m1[v[i]];
  }

  vector<int> b;
  for (int i = 1; i < n; i += 2) {
    if (m2.find(v[i]) == m2.end()) {
      m2[v[i]] = 0;
      b.push_back(v[i]);
    }
    ++m2[v[i]];
  }

  sort(a.begin(), a.end(), comp1);
  sort(b.begin(), b.end(), comp2);

  long long ret = 0;
  if (a[0] == b[0]) {
    if (a.size() == 1 && b.size() == 1) {
      ret = n / 2;
    } else if (a.size() == 1 && b.size() > 1) {
      ret = n - m1[a[0]] - m2[b[1]];
    } else if (b.size() == 1 && a.size() > 1) {
      ret = n - m1[a[1]] - m2[b[0]];
    } else {
      ret = n - max(m1[a[0]] + m2[b[1]], m1[a[1]] + m2[b[0]]);
    }
  } else {
    ret = n - m1[a[0]] - m2[b[0]];
  }

  cout << ret << endl;

  return 0;
}

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

#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define rep1(i, n) for (ll i = 1; i < (ll)(n); i++)
#define INF 10000000000
#define MOD 1000000007
using ll = unsigned long long;
using Graph = vector<vector<int>>;

int main(){
    ll N; cin>>N;
    string res = "";
    while(N){
        --N;
        res += (char)('a' + (N%26));
        N /= 26;
    }
    reverse(res.begin(),res.end());
    cout << res <<endl;
}

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

typedef long long ll;
#define rep(i,x) for(int i=0;i<x;i++)
#define put(ans)    cout << ans << endl;

double kaijyo(int n){
    int k(1);
    for(int i=n;i>0;i--){
        k *= i;
    }

    return k;
}

double distance(int x[],int y[],int i,int j){
    int dx = (x[i] - x[j]) * (x[i] - x[j]);
    int dy = (y[i] - y[j]) * (y[i] - y[j]);
    return sqrt(dx+dy);
}

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

    int ans(0);
    while (n>0){
        n /= k;
        ans++;
    }
    
    cout << ans << endl;

    return 0;
}

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

using namespace std;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  cout << fixed << setprecision(15);

  vector<vector<int>> a(3, vector<int>(3));
  vector<vector<bool>> chc(3, vector<bool>(3, false));
  for (int i = 0; i < 3; ++i) {
    for (int j = 0; j < 3; ++j) {
      cin >> a[i][j];
    }
  }
  int n;
  cin >> n;
  vector<int> b(n);
  for (int i = 0; i < n; ++i) {
    cin >> b[i];
  }
  for (int i = 0; i < 3; ++i) {
    for (int j = 0; j < 3; ++j) {
      for (int k = 0; k < n; ++k) {
        if (a[i][j] == b[k]) {
          chc[i][j] = true;
          break;
        }
      }
    }
  }
  string ans = "No";
  for (int i = 0; i < 3; ++i) {
    if ((chc[i][0] && chc[i][1] && chc[i][2]) ||
        (chc[0][i] && chc[1][i] && chc[2][i])) {
      ans = "Yes";
    }
  }
  if ((chc[0][0] && chc[1][1] && chc[2][2]) ||
      (chc[0][2] && chc[1][1] && chc[2][0])) {
    ans = "Yes";
  }
  cout << ans << '\n';

  return 0;
}


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

int main() {
  int X, Y; cin >> X >> Y;
  if (Y % 2 != 0) cout << "No" << endl;
  else if (Y < 2 * X || Y > 4 * X) cout << "No" << endl;
  else cout << "Yes" << endl;
}

Measured memory_bytes: 3568
#include <iostream>
#include <complex>
#include <cstdio>
#include <cmath>
#define x real()
#define y imag()
using namespace std;
typedef complex <double> point;

double dot(point a,point b){
  return a.x*b.x+a.y*b.y;
}

double cross(point a,point b){
  return a.x*b.y-a.y*b.x;
}

int ccw(point a,point b,point c){
  point d = b-a;
  point e = c-a;
  if(cross(d,e)>0) return 1;//"COUNTER_CLOCKWISE"
  if(cross(d,e)<0) return -1;//"CLOCKWISE"
  if(dot(d,e)<0) return 1;//"ONLINE_BACK"
  if(abs(d) < abs(e)) return -1;//"ONLINE_FRONT"
  return 0;//"ON_SEGMENT"
}

point projection(point a,point b,point c){
  point d = b - a;
  return a+d*(dot(c-a,d)/(abs(d)*abs(d)));
}

point reflection(point a,point b,point c){
  return 2.0*projection(a,b,c)-c;
}

bool intersection(point a,point b,point c,point d){
  //if(ccw(a,b,c)==ccw(a,b,d)) return false;
  return (ccw(a,b,c)*ccw(a,b,d)<=0&&ccw(c,d,a)*ccw(c,d,b)<=0);
  /*if(ccw(a,b,c) == ccw(a,b,d)) return false;
  b-=a;
  c-=a;
  d-=a;
  c *= conj(b)/abs(b);
  d *= conj(b)/abs(b);
  point e = d+((c-d)*d.y)/(d.y-c.y);
  if(e.x > abs(b) || e.x < 0) return false;
  return true;*/
}

int main(){
  point a,b,c,d;
  int q;
  cin >> q;
  for(int i=0;i<q;i++) {
    cin >>a.x>>a.y>>b.x>>b.y>>c.x>>c.y>>d.x>>d.y;
    cout << intersection(a,b,c,d)<<endl;
  }
  return 0;
}

Measured memory_bytes: 1244
#include <iostream>
#include <vector>
using namespace std;
int main(){
    int n,d,x;
    cin>>n>>d>>x;
    vector<int> a(n,0);
    for(int i=0;i<n;i++){
        cin>>a[i];
    }

    for(int i=0;i<n;i++){
        int days=1;
        while(days<=d){
            x++;
            days+=a[i];
        }
    }
    
    cout<<x<<endl;
    return 0;
}

Measured memory_bytes: 256
#pragma GCC optimize ("O3")
#pragma GCC optimize ("unroll-loops")
#pragma GCC optimize("-Ofast")
#include <bits/stdc++.h>
using namespace std;

typedef int in;
#define int long long
#define f first
#define s second
#define pb push_back
#define pp push
#define RETURN exit(0)
#define pow(x,y) (int)(pow(x,y))
#define ceil(x) (int)(ceil(x))
#ifndef ONLINE_JUDGE
#define debug(x) cout<<x<<endl;
#else
#define debug(x) 42
#endif
const int MAX=1e4;
const int MOD=1e9+7;
const int MAAX=1e15;
const long double EPS=1e-6;
const int N=1e5+10;
int power(int x,int y)
{
    if (y == 0)
        return 1;
    int a=power(x,y/2);
    if (y % 2 == 0)
        return a * a % MOD;
    else
        return x * a * a % MOD;
}
long double sq(int x){
    long double s=0,e=x,mid;
    while(e-s>=EPS){
        mid=(s+e)/2;
        if(mid*mid<=x){
            s=mid;
        }
        else{
            e=mid-EPS;
        }
    }
    return s;
}
bool check(int x){

}
int binary(int x,int y){
    int s=x,e=y,mid;
    while(s<e){
        mid=ceil((s+e)/2.0);
        if(check(mid))
            s=mid;
        else
            e=mid-1;
    }
    return s;
}
vector<int> primes;
bool visted[N+5];
void sieve(){
    visted[0]=visted[1]=1;
    for(int i=2;i*i<=N;i++){
        if(visted[i]==0){
            primes.pb(i);
            for(int j=i*i;j<=N;j+=i){
                visted[i]=1;
            }
        }
    }
    for(int i=sqrt(N)+1;i<=N;i++){
        if(visted[i]==0)
            primes.pb(i);
    }
    return;
}

int fun(int arr[],int s,int e){
    if(e-s==1){
        return 0;
    }
    int sz1=(s+e)/2;
    int sz2=e-(sz1+s);
    int ans=fun(arr,s,sz1)+fun(arr,sz1,e);
    int x=s;
    for(int i=sz1;i<e;i++){
        if(arr[i]>arr[x]){
            ans+=sz1-(x);
        }
        else{
            i--;
            x++;
        }
    }
    return ans;
}

in main()
{
    //freopen("in.in","r",stdin);
    //freopen("out.out","w",stdout);
    int tc=1;
    //sieve();
    //scanf("%lld",&tc);
    while(tc--)
    {
        int n;
        cin>>n;
        cout<<(n/500*1000)+(n%500/5*5)<<endl;
    }
    RETURN;
}


Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;

int main() {
	int n; cin >> n;
	vector<int>A(n), b(n); for (auto&& x : A)cin >> x;
	for (int i = 0; i < n; i++) {
		b[i] = A[i] - i + 1;
	}
	sort(b.begin(), b.end());
	int bNum = b.size() % 2 == 0 ? (b[b.size() / 2] + b[b.size() / 2 - 1]) / 2 : b[b.size() / 2];
	long long ans = 0; for (auto&& x : b)ans += abs(x - bNum);
	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 1792
import java.io.*;
import java.lang.Integer;
public class Main {
	public static void main(String[] args) {
		try (BufferedReader br = new BufferedReader(new InputStreamReader(System.in))) {
			String in  = br.readLine() ;
			String[] numStr = in.split(" ");
			int[] num = new int[4];
			num[0] = Integer.parseInt(numStr[0]);
			num[1] = Integer.parseInt(numStr[1]);
			num[2] = Integer.parseInt(numStr[2]);
			for( int i = 0 ; i < 3 ; i++) {
				for( int j = 0 ; j < 2 ; j++) {
					if ( num[j] > num[j+1]) {
						int w = num[j];
						num[j] = num[j+1];
						num[j+1] = w;
					}
				}
			}
			System.out.println( "" + num[0] + " " + num[1] + " " + num[2]);
		} catch ( IOException e ) {
			System.out.println("??¨??????????????????????????????");
		}
	}
}

Measured memory_bytes: 24368
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <numeric>

using namespace std;
typedef long long ll;
int H,W,K;

int main(){
  cin >> H >> W >> K;
  vector<vector<int> > c(H,vector<int>(W));
  int all =0;
  for(int i=0;i<H;i++){
    for(int j=0;j<W;j++){
      char a;
      cin >> a;
      if(a=='#') {
	all++;
	c[i][j]=1;
      }
      else c[i][j]=0;
    }
  }
  int ans =0;
  for(int bith = 0;bith<(1<<H);++bith){
    for(int bitw = 0;bitw<(1<<W);++bitw){
      int black=0;
      for(int i=0;i<H;i++){
	for(int j=0;j<W;j++){
	  if((bith & (1<<i)) && (bitw & (1<<j))){
	    black+=c[i][j];
	  }
	}
      }
      if(black==K) ans++;
    }
  }
  cout << ans << endl;
}


Measured memory_bytes: 3200
#include <stdio.h>
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
using namespace std;
#define mp make_pair
#define pb push_back
#define rep(i,n) for(int i=0;i<n;i++)
#define repn(i,n) for(int i=1;i<=n;i++)
typedef long long ll;

ll dp[300][20005];
int n,m,c[305],x[20005];

int main(){
    while(1){
        cin>>n>>m;
        if(n==0 && m==0) return 0;
        for(int i=1;i<=m;i++) cin>>c[i];
        for(int i=1;i<=n;i++) cin>>x[i];
        rep(i,300) rep(j,20005){
            dp[i][j] = 1e18;
        }
        dp[128][0] = 0;
        for(int j=0;j<n;j++){
            for(int i=0;i<300;i++){
                if(dp[i][j] > 1e17) continue;
                repn(k,m){
                    int nxt = i+c[k];
                    nxt = max(nxt,0);
                    nxt = min(nxt,255);
                    dp[nxt][j+1] = min(dp[nxt][j+1],dp[i][j]+1LL*(nxt-x[j+1])*(nxt-x[j+1]));
                }
            }
        }
        ll ans = 1e18;
        rep(i,300) ans = min(ans,dp[i][n]);
        cout << ans << endl;
    }
}



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

int main(){
  int n; cin >> n;
  int l[n];
  int sum=0;
  int max=0;
  for(int i = 0; i < n; i++) cin >> l[i];
  
  for(int j = 0; j < n; j++)
  {
    sum += l[j];
    if(l[j] > max) max = l[j];
  }
  
  if(max < (sum - max)) cout << "Yes" << endl;
  else 					cout << "No" << endl;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<stdlib.h>
#include<math.h>
#include<string.h>
#include <time.h>

// typedef struct{
//         long aa;
//         long bb;
//     }s;
//     int cmp( const void *p, const void *q ) {
//         return ((s*)p)->bb - ((s*)q)->bb;
//     }

int main(void){
    long n,a,i,b;
    scanf("%ld",&n);
    a=sqrt(n);
    for(i=a;i>0;i--){
        if(n%i==0) break;
    }
    b=i-1+n/i-1;
   



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


Measured memory_bytes: 384
# -*- coding: utf-8 -*-
import numpy as np
from collections import deque
import collections

mod = 10 ** 9 + 7
N = int(input())


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


ans = N-1
for i in range(1, int(np.sqrt(N) + 1)):
    if (N % i == 0):
        j = N//i
    ans = min(ans, i+j-2)
print(ans)


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

int main() {
  int N, S, H, J, I;
  cin >> N;
  S = N / 1000;
  N = N % 1000;
  H = N / 100;
  N = N % 100;
  J = N / 10;
  I = N % 10; 
  if (S == H && H == J) {
    cout << "Yes" << endl;
  }
  else if (H == J && J == I){
    cout << "Yes" << endl;
  }
  else {
    cout << "No" << endl;
  }
}

Measured memory_bytes: 3596
#include <stdio.h>

int main(void){
    int c[100]={0};
    int v[100]={0};
    int a[100]={0};
    int N,T,ans=1000;
    int i,j=0;

    scanf("%d %d",&N,&T);
    for(i=0;i<N;i++) scanf("%d %d",&c[i],&v[i]);

    for(i=0;i<N;i++)
        if(v[i]<=T){
            a[j]=c[i];
            j++;
        }
    
    if(a[0]){
        for(i=0;i<j;i++)
            if(a[i]<ans) ans=a[i];
        printf("%d",ans);
    }
    else printf("TLE\n");

    return 0;
}

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

using namespace std;

int main() {
    int n, count, count_tmp = 0, ans;
    cin >> n;
    for(int i = 1; i <= n; ++i) {
        int copy = i;
        count = 0;
        while(copy % 2 == 0) {
            copy /= 2;
            count++;
        }
        if(count >= count_tmp) {
            count_tmp = count;
            ans = i;
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>

using namespace std;

int main(int argc, char const *argv[])
{
	string order;
	string mess;

	int n;
	int sz;

	cin>>n;

	for(int i1=0;i1<n;i1++){
		cin>>order;
		cin>>mess;

		reverse(order.begin(), order.end());
		sz=mess.size();

		for(int i2=0;i2<order.size();i2++){
			if(order[i2]=='J'){
				mess=mess[sz-1]+mess.substr(0,sz-1);
			}
			else if(order[i2]=='C'){
				mess=mess.substr(1,sz-1)+mess[0];
			}
			else if(order[i2]=='E'){
				string l,r;
				l=mess.substr(0,sz/2);
				
				if(sz%2==0){	
					r=mess.substr(sz/2,sz/2);
					mess=r+l;
				}
				else {
					r=mess.substr(sz/2+1,sz/2);
					mess=r+mess[sz/2]+l;
				}
			}
			else if(order[i2]=='A'){
				reverse(mess.begin(), mess.end());
			}
			else if(order[i2]=='P'){
				for(int i3=0;i3<sz;i3++){
					if(mess[i3]>='1' && mess[i3]<='9') mess[i3]--;
					else if(mess[i3]=='0') mess[i3]='9';
				}
			}
			else {// M
				for(int i3=0;i3<sz;i3++){
					if(mess[i3]>='0' && mess[i3]<='8') mess[i3]++;
					else if(mess[i3]=='9') mess[i3]='0';
				}
			}
		}

		cout<<mess<<endl;

	}

	return 0;
}

Measured memory_bytes: 1208
#include<math.h>
#include<cmath>
#include<bitset>
#include<stdio.h>
#include<string>
#include<map>
#include<algorithm>
#include<vector>
#include<iostream>
#include<utility>
using namespace std;
int main(){
  char s;
  int sum1[20],b=0,ans=(1<<29),sum=0,y[20][1010],x=0,m=0,h,k,w,a[20][1010],i,j,l;
  scanf("%d %d %d\n",&h,&w,&k);
  for(i=0;i<h;i++){
    for(j=0;j<w;j++){
      scanf("%c",&s);
      a[i][j]=s-'0';
    }
    scanf("\n");
  }
  for(int tmp=0;tmp<(1<<(h-1));tmp++){
    for(i=0;i<h;i++){
      sum1[i]=0;
    }
    for(i=0;i<h;i++){
      for(j=0;j<w;j++){
        y[i][j]=0;
      }
    }
    bitset<20> s(tmp);
    s[h-1]=1;
    for(i=0;i<h;i++){
      if(s[i]==1){
        sum++;
        for(l=0;l<w;l++){
          for(j=x;j<=i;j++){
            y[m][l]+=a[j][l];
          }
        }
        x=i+1,m++;
      }
    }
    sum--;
    for(i=0;i<w;i++){
      for(j=0;j<m;j++){
        sum1[j]+=y[j][i];
        if(sum1[j]>k){
          sum++;
          b=1;
          break;
        }
      }
      if(b==1){
        b=0;
        for(j=0;j<m;j++){
          sum1[j]=y[j][i];
        }
      }
    }
    for(i=0;i<w;i++){
      for(j=0;j<m;j++){
        if(y[j][i]>k){
          b=1;
        }
      }
    }
    if(b==1){
      sum=0,m=0,x=0;
      continue;
    }
    if(ans>sum){
      ans=sum;
    }
    sum=0,m=0,x=0;
  }
  printf("%d\n",ans);
  return 0;
}

Measured memory_bytes: 384
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <map>
#include <unordered_map>
#include <set>
#include <climits>
using namespace std;

void judge(vector<long long> &a, vector<pair<int, int>> &ans){
    for(auto x : ans){
        int i = x.first;
        int j = x.second;
        a[j] += a[i];
    }
    int N = a.size();
    for(int i=0; i<N; i++) cerr << a[i] << " ";
    cerr << endl;

    bool flag = true;
    for(int i=0; i<N-1; i++){
        if(a[i] > a[i+1]) flag = false;
    }
    if(flag) cerr << "YES" << endl;
    else cerr << "NO" << endl;
}

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N;
    cin >> N;
    vector<long long> a(N);
    for(int i=0; i<N; i++) cin >> a[i];

    long long mn = 2000000;
    long long mx = -2000000;
    for(int i=0; i<N; i++){
        mn = min(mn, a[i]);
        mx = max(mx, a[i]);
    }
    bool mns;
    if(abs(mn) > abs(mx)) mns = true;
    else if(abs(mn) < abs(mx)) mns = false;

    int m = 0;
    vector<pair<int, int>> ans;
    if(!mns){
        int jmx = 0;
        for(int i=0; i<N; i++){
            if(a[i]==mx) jmx = i;
        }
        for(int i=0; i<N; i++){
            if(i != jmx){
                m++;
                ans.push_back(make_pair(jmx, i));
            }
        }
        for(int i=0; i<N-1; i++){
            m++;
            ans.push_back(make_pair(i, i+1));
        }
    }else{
        int jmn = 0;
        for(int i=0; i<N; i++){
            if(a[i]==mn) jmn = i;
        }
        for(int i=0; i<N; i++){
            if(i != jmn){
                m++;
                ans.push_back(make_pair(jmn, i));
            }
        }
        for(int i=N-1; i>0; i--){
            m++;
            ans.push_back(make_pair(i, i-1));
        }
    }


    cout << m << endl;
    for(auto x : ans)
        cout << x.first+1 << " " << x.second+1 << endl;

    judge(a, ans);
    return 0;
}


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

#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;
#define int 	     	  long long   // [9,223,372,036,854,775,807 to -9.....808] 19 digits
#define pb                push_back
#define all(x)            (x).begin(),(x).end()
#define mp                make_pair
#define vi                vector<int>
#define vpi               vector<pair<int,int>>
#define mii               map<int,int>
#define x                 first
#define y                 second
#define mem(a,x)          memset(a,x,sizeof(a))
#define rep(i,a,b)        for(int i=a;i<b;i++)
#define sz(x)             (int)((x).size())
 
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_set; // find_by_order()  // order_of_key
 
//const int32_t hellhsh = 444440583533; const double pi=2*acos(0.0);
const int32_t mod = 1e9+7;
const int32_t maxn=2e5+5;
int inf=1e18;
 
int dx[5]={-2,-1,0,+1,+2},dy[5]={-2,-1,0,+1,+2};
int n,m,r1,c1,r2,c2,dp[1005][1005];
string s[1005];
 
 
void solve(){
    cin>>n>>m>>r1>>c1>>r2>>c2;
    rep(i,0,n) cin>>s[i];
    rep(i,0,n) rep(j,0,m) dp[i][j]=LLONG_MAX;
    r1--;r2--;c1--;c2--;
    dp[r2][c2]=0;
 
 
    priority_queue<pair<int,pair<int,int>>> q;
 
    q.push(mp(0,mp(r2,c2)));
 
    while(sz(q)){
        auto d=-q.top().x;
        auto pos=q.top().y;
        q.pop();
 
        rep(i,0,5){
            rep(j,0,5){
                if(!dx[i] and !dy[j]) continue;
 
                int x=dx[i]+pos.x;
                int y=dy[j]+pos.y;
                if(x<0 or y<0 or x>=n or y>=m or s[x][y]=='#') continue;
                
 
                if((abs(dx[i])==1 and !dy[j]) or (abs(dy[j])==1 and !dx[i])){
                    if(dp[x][y]>d){
                        dp[x][y]=d;
                        q.push(mp(-d,mp(x,y)));
                    }
                }
                else{
                    if(dp[x][y]>d+1){
                        dp[x][y]=d+1;
                        q.push(mp(-d-1,mp(x,y)));
                    }
                }
            }
        }
    }
 
    if(dp[r1][c1]==LLONG_MAX) cout<<-1;
    else cout<<dp[r1][c1];
}
 
signed main(){
    ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
    int tc=1,k=1;
    //cin>>tc;
    while(tc--){
        //cout<<"Case #"<<k++<<": ";
        solve();
    }
    return 0;
}


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

int main(void){
   int N;
   cin>>N;
   vector<long long> A(N);
   for(int i=0;i<N;i++){
      cin>>A[i];
   }
   map<long long,int> result;
   for(int i=0;i<N;i++){
      result[A[i]]++;
   }
   
   vector<long long> ans;
   long long temp=0;
   for(auto x:result){
      if(x.second>=2) {
         ans.push_back(x.first);
         if(x.second>=4){
            temp=x.first;
         }
      }
   }
   sort(ans.begin(),ans.end());
   if(ans.size()<2&&temp==0){
      cout<<0<<endl;
   }else if(ans.size()<2&&temp!=0){
      cout<<temp*temp<<endl;
   }else{
      cout<<max(ans[ans.size()-1]*ans[ans.size()-2],temp*temp)<<endl;
   }
   return 0;
}

Measured memory_bytes: 7296
#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<b;i++)
#define rrep(i,a,b) for(int i=a;i>=b;i--)
#define fore(i,a) for(auto &i:a)
#define all(x) (x).begin(),(x).end()
//#pragma GCC optimize ("-O3")
using namespace std; void _main(); int main() { cin.tie(0); ios::sync_with_stdio(false); _main(); }
typedef long long ll; const int inf = INT_MAX / 2; const ll infl = 1LL << 60;
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; }
//---------------------------------------------------------------------------------------------------
int gcd(int a, int b) { return a ? gcd(b % a, a) : b; }
/*---------------------------------------------------------------------------------------------------
　　　　　　　　　　　 ∧＿∧
　　　　　 ∧＿∧ 　（´<_｀ ）　 Welcome to My Coding Space!
　　　　 （ ´_ゝ`）　/　 ⌒i     @hamayanhamayan0
　　　　／　　　＼　 　  |　|
　　　 /　　 /￣￣￣￣/　　|
　 ＿_(__ﾆつ/　    ＿/ .| .|＿＿＿＿
　 　　　＼/＿＿＿＿/　（u　⊃
---------------------------------------------------------------------------------------------------*/














int K;
//---------------------------------------------------------------------------------------------------
void _main() {
	cin >> K;

	ll ans = 0;
	rep(a, 1, K + 1) rep(b, 1, K + 1) rep(c, 1, K + 1) ans += gcd(a, gcd(b, c));
	cout << ans << endl;
}







Measured memory_bytes: 3640
#include<iostream>
#include<string>
#include<cstdio>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<ciso646>
#include<random>
#include<map>
#include<set>
#include<complex>
#include<bitset>
#include<stack>
#include<unordered_map>
#include<utility>
#include<cassert>
using namespace std;

typedef long long ll;
const ll mod = 1000000007;
const ll INF = mod * mod;
typedef pair<int, int> P;
typedef pair<ll, ll> LP;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<string> svec;

int main() {
	int n, m;
	cin >> n >> m;
	vll dp(n + 10, 0);
	vll ban(n + 10, 0);
	for (int i = 0; i < m; i++) {
		int a;
		cin >> a;
		ban[a] = 1;
	}
	dp[0] = 1;
	if (ban[1] != 1)dp[1] = 1;
	for (int i = 2; i < n + 1; i++) {
		if (ban[i] == 1)continue;
		dp[i] = dp[i - 1] + dp[i - 2];
		dp[i] %= mod;
	}
	cout << dp[n] << endl;
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll, ll> pll;
#define PI 3.14159265358979
#define rep(i, n) for(int i = 0; i < (n); ++i)
#define repp(i, s, e) for(int i = (s); i <= (e); ++i)
#define sz(x) ((int)x.size())
#define all(x) x.begin(), x.end()
#define FAST_IO() ios::sync_with_stdio(0); cin.tie(0)
template<typename T>
ostream& operator<<(ostream &os, const vector<T> &v) { for (auto x : v) os << x << " "; return os << "\n"; }
template<class U, class V>
ostream& operator<<(ostream &os, const pair<U, V> &p) { return os << "(" << p.first << "," << p.second << ")";}

int main() {
    int A, B; cin >> A >> B;
    cout << (B + A - 3) / (A - 1) << "\n";
}

Measured memory_bytes: 256
/* Focus your enery towards light */

#include<bits/stdc++.h>
using namespace std;

#define ll long long
#define ld long double
#define pb push_back
#define mp make_pair
#define forn(i,n) for(int i=0;i<n;i++)
#define fore(i,a,b) for(int i=a;i<=b;i++)
#define ford(i,n) for(int i=n-1;i>=0;i--)
#define fi first
#define se second
#define endl "\n"
#define all(a) a.begin(),a.end()
#define sync ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define PI 3.14159265
#define inf 1e18

/******************************************************************************************************/
void file() {
#ifndef ONLINE_JUDGE
    // for getting input from input.txt
    freopen("input.txt", "r", stdin);
    // for writing output to output.txt
    freopen("output.txt", "w", stdout);
#endif
}
/******************************************************************************************************/

// const ll nax = 2e5 + 1;
// const ll mod = 1e9 + 7;



int main() {

    sync


    int testCases = 1;
    // cin >> testCases;

    while (testCases--) {
        ll a;
        cin >> a;
        cout << a + a * a + a * a * a << endl;
    }
    return 0;
}


Measured memory_bytes: 3636
#include<bits/stdc++.h>
using namespace std;
int main(){
	string s;cin>>s;int c=150,f=-1;
  	for(int i=0;i<s.length();i++){
    	if(s[i]=='C'){c=i;break;}
    }
  	for(int i=s.length()-1;i>=0;i--){
    	if(s[i]=='F'){f=i;break;}
    }
  	//cout<<f<<" "<<c;
  	if(f>c) cout<<"Yes";
  	else cout<<"No";
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int a, b, rim;

  cin >> a >> b;

  rim = a * b % 2;

  if(rim == 0){
    cout << "Even" << endl;
  }  
  else if(rim == 1){
    cout << "Odd" << endl;
  }

}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define fast ios::sync_with_stdio(0);cin.tie(0);
#define all(v)    ((v.begin()),(v.end()))
#define sz(v)     ((int)(v.size()))
#define forv(i, v) for(int i = 0; i < sz(v); ++i)
#define forn(i,n)   for(int i = 0; i < (int)(n); i++)
using namespace std;

typedef long long       ll;
typedef long double     ld;
typedef vector<int>     vi;
typedef vector<double>  vd;
typedef vector< vi >    vii;
typedef vector< vd >    vdd;
typedef vector<string>  vs;


int main()
{
	int n, k;
	scanf("%d%d", &n, &k);
	vector<int>a(n + 2);
	for (int i = 0; i < n; i++) scanf("%d", &a[i]);

	vector<bool> dp(k + 3);
	for (int i = 0; i <= k; i++) {
		for (int j = 0; j  < n; j++) {
			if (i >= a[j] && !dp[i - a[j]]) {
				dp[i] = true;
			}
		}
	}
	puts(dp[k] ? "First" : "Second");


	return 0;
}


Measured memory_bytes: 384
using System;
using System.Collections.Generic;
using System.Linq;
using static System.Console;
using static System.Convert;
using static System.Math;

class Program
{
    static void Main(string[] args)
    {
        var num = ToInt32(ReadLine());
        var ar = Array.ConvertAll(ReadLine().Split(' '), int.Parse);
        var res = new int[num];
        CountingSort(ar, res, ar.Max());
        WriteLine(string.Join(" ", res));
    }
    private static void CountingSort(int[] ar,int[] res,int max)
    {
        var cout = new int[max + 1];
        for (var i = 0; i < ar.Length; i++)
            cout[ar[i]]++;
        for (var i = 1; i <= max; i++)
            cout[i] += cout[i - 1];

        for(var i=0;i<ar.Length;i++)
        {
            res[cout[ar[i]]-1] = ar[i];
            cout[ar[i]]--;
        }
    }
    private const string ALFA = "abcdefghijklmnopqrstuvwxyz";
    private const int MOD = 1000000007;
}


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

int main()
{
    string str1, str2;
    cin >> str1 >> str2;

    if (str1.length() > str2.length()) {
        cout << "GREATER" << endl;
        return 0;
    } else if (str1.length() < str2.length()) {
        cout << "LESS" << endl;
        return 0;
    } else {
        for (int i = 0; i < str1.length(); i++) {
            if (str1[i] > str2[i]) {
                cout << "GREATER" << endl;
                return 0;
            } else if (str1[i] < str2[i]) {
                cout << "LESS" << endl;
                return 0;
            }
        }
    }
    cout << "EQUAL" << endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
struct Fast {
    Fast() {
        cin.tie(0);
        ios::sync_with_stdio(false);
        cout << fixed << setprecision(20);
    }
} fast;

long long mod = 1000000007;

long long modpow(long long m, long long n) {
    if (n == 0) return 1;
    if (n % 2 == 0) {
        long long t = modpow(m, n / 2);
        return (t * t) % mod;
    } else {
        return (modpow(m, n - 1) * m) % mod;
    }
}

void yes() {
    cout << "Yes" << endl;
    exit(0);
}
void no() {
    cout << "No" << endl;
    exit(0);
}
#define REP(i, n) for (long long i = 0; i < (n); i++)
template <typename A, size_t N, typename T> void Fill(A (&array)[N], const T& val) {
    std::fill((T*)array, (T*)(array + N), val);
}
struct LCA {
    vector<vector<int>> par;
    vector<int> d;
    int n;
    LCA(vector<vector<int>> graph, int root) {
        n = graph.size();
        par.resize(n, vector<int>(30));
        d.resize(n, 0);
        function<void(int, int, int)> dfs = [&](int c, int p, int depth) {
            d[c] = depth;
            par[c][0] = p;
            for (auto ch : graph[c]) {
                if (ch != p) dfs(ch, c, depth + 1);
            }
        };
        dfs(0, 0, 0);
        for (int j = 1; j < 30; j++) {
            REP(i, n) { par[i][j] = par[par[i][j - 1]][j - 1]; }
        }
    }
    int getdistance(int u, int v) { return (d[u] + d[v]) - 2 * (d[query(u, v)]); }
    int query(int u, int v) {
        if (d[u] > d[v]) {
            swap(u, v);
        }
        for (int i = 29; 0 <= i; i--) {
            if (d[u] <= d[par[v][i]]) {
                v = par[v][i];
            }
        }
        /* LCA */
        for (int i = 29; 0 <= i; i--) {
            if (par[v][i] != par[u][i]) {
                v = par[v][i];
                u = par[u][i];
            }
        }
        if (u == v) {
            return u;
        } else {
            return par[v][0];
        }
    }
};

struct UnionFind {
    vector<int> parent, size;
    UnionFind(int n) {
        parent.resize(n, -1);
        size.resize(n, 1);
    }
    void unite(int x, int y) {
        if (same(x, y)) {
            return;
        }
        x = root(x);
        y = root(y);
        if (size[x] <= size[y]) {
            swap(x, y);
        }
        parent[y] = x;
        size[x] += size[y];
    }
    bool same(int x, int y) { return (root(x) == root(y)); }
    int root(int x) {
        while (parent[x] != -1) {
            x = parent[x];
        }
        return x;
    }
    int getsize(int x) { return size[root(x)]; }
};
void aoj(vector<int> bs) {
    REP(i, bs.size() - 1) { cout << bs[i] << " "; }
    cout << bs[bs.size() - 1] << endl;
}

signed main() {
    int a, b;
    cin >> a >> b;
    if (a * 2 > b){
        cout << "No" << endl;
        return 0;
    }
    if (b % 2 == 1) {
        cout << "No" << endl;
        return 0;
    }
    if (b <= 4 * a) {
        cout << "Yes" << endl;
        return 0;
    } else {
        cout << "No" << endl;
    }
}


Measured memory_bytes: 3648
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i,n) for(int i=0;i<n;i++)
int main(void){
    // Your code here!
    vector<string> YN{"NO","YES"};
    vector<string> yn{"No","Yes"};
    int a,b,c;
    cin>>a;
    cout<<yn[a/100==a%10]<<endl;
}


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

int main(){
        int a, b;
        char op;
        while(true){
                cin >> a >> op >> b;
                if(op == '+')
                        cout << a + b << endl;
                else if(op == '-')
                        cout << a - b << endl;
                else if(op == '*')
                        cout << a * b << endl;
                else if(op == '/')
                        cout << a / b << endl;
                else if(op == '?')
                        break;
        }
        return 0;
}


Measured memory_bytes: 3096
#include<iostream>
#include<math.h>
#include<algorithm>
#define ll long long int
#define FOR(i,a,b) for(ll i=(ll)(a);i<(ll)(b);i++)
#define REP(i,n) FOR(i,0,n)
#define REP1(i,n) FOR(i,1,n)

using namespace std;

int main(){
	int c = 0;
	string s;
	cin >> s;
	if(s[0] != 'A') {
		cout << "WA" << endl;
		return 0;
	}
	if(s[1] >= 'A' && s[1] <= 'Z'){
		cout << "WA" << endl;
		return 0;
	}
	if(s[s.size()-1] >= 'A' && s[s.size()-1] <= 'Z'){
		cout << "WA" << endl;
		return 0;
	}
	for(int i = 2; i < s.size()-1; i++){
		if(s[i] == 'C') c++;
		else if(s[i] >= 'A' && s[i] <= 'Z'){
			cout << "WA" << endl;
			return 0;
		}
		if(c == 2){
			cout << "WA" << endl;
			return 0;
		}
	}
	if(c == 0){
		cout << "WA" << endl;
		return 0;
	}

	else cout << "AC" << endl;
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<string> vs;
typedef vector<bool> vb;
typedef vector<vb> vvb;
#define rep(i,n) for(int i=0;i<(n);i++)
#define rep1(i,n) for(int i=1;i<=(n);i++)
#define all(x) (x).begin(),(x).end()

constexpr auto INF = INT_MAX/2;
constexpr auto MOD = 1000000007;


int main() {

	int n, m;
	cin >> n >> m;
	vector<P> c(m);
	rep(i, m) {
		int a, b;
		cin >> a >> b;
		c[i] = make_pair(a, b);
	}

	sort(all(c));

	vi bre = {};

	rep(i, m) {
		if (bre.size() == 0)bre.push_back(c[m - 1 - i].first + 1);

		int k = bre[bre.size() - 1];
		int s, t;
		if (k <= c[m - 1 - i].first)s = bre.size();
		else s = *lower_bound(all(bre), c[m - 1 - i].first);
		if (k <= c[m - 1 - i].second)t = bre.size();
		else t = *lower_bound(all(bre), c[m - 1 - i].second);

		if (s == t)bre.push_back(c[m - 1 - i].first + 1);
	}

	cout << bre.size() << endl;

}

Measured memory_bytes: 1024
#include<stdio.h>
int main(void)
{
	char c[3][4];
	for (int i = 0; i < 3; i++) {
		for (int j = 0; j < 4; j++) {
			scanf("%c", &c[i][j]);
		}
	}
	printf("%c%c%c", c[0][0], c[1][1], c[2][2]);
	return 0;
}

Measured memory_bytes: 128
t=list(input())
if len(t)==1:
    if t[0]=="?":
        print("D")
    else:
        print(*t)
    exit()
if t[0]=="?":
    if t[1]=="?":
        t[0]="P"
        t[1]="D"
    elif t[1]=="D":
        t[0]="P"
    else:
        t[0]="D"
for i in range(1,len(t)-1):
    if t[i]=="?":
        if t[i-1]=="P":
            t[i]="D"
        elif t[i-1]=="D":
            if t[i+1]=="P":
                t[i]="D"
            else:
                t[i]="P"
if t[-1]=="?":
    t[-1]="D"
print(*t,sep="")

Measured memory_bytes: 91796
n,k = map(int,input().split())
x = list(map(int,input().split()))
INF = float("inf")
cost = INF
for i in range(len(x)-k+1):
  l = x[i]
  r = x[i+k-1]
  tmp = min(abs(l)+abs(l-r),abs(r)+abs(r-l))
  cost = min(cost,tmp)
print(cost)


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

using namespace std;

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

  for (int i = 0; i < 5; ++i) {
    int x;
    cin >> x;
    if (x == 0) {
      cout << i + 1;
      return 0;
    }
  }

  return 0;
}


Measured memory_bytes: 3640
#include <iostream>
#include <vector>
#include <algorithm>
#include <limits>

using namespace std;

#define int long long

signed main(void) {
	int N, K; cin >> N >> K;
	vector<int> A(N); for (auto &a : A) cin >> a;
	int allSum = 0;
	for (auto &a : A) allSum += max(a, 0LL);
	int res = 0;

	if (K == 1) {
		cout << allSum << endl;
		return 0;
	}

	{
		int sum = 0;
		for (int i = 0; i < K; ++i) {
			if(A[i] < 0)
				sum += A[i];
		}
		res = max(res, allSum + sum);

		int mi = -1e9 - 1;
		for (int i = K; i < N; ++i) {
			if(A[i-K] < 0)
				sum -= A[i - K];
			if(A[i] < 0)
				sum += A[i];
			res = max(res, allSum + sum);
		}
	}

	{
		int sum = 0;
		for (int i = 0; i < K; ++i) {
			if(A[i] > 0)
				sum += A[i];
		}
		res = max(res, allSum - sum);

		int mi = -1e9 - 1;
		for (int i = K; i < N; ++i) {
			if(A[i-K] > 0)
				sum -= A[i - K];
			if(A[i] > 0)
				sum += A[i];
			res = max(res, allSum - sum);
		}
	}

	cout << res << endl;
}


Measured memory_bytes: 1152