akhauriyash/Code-Regression huggingface dataset:
#include<cstdio>
#include<cstring>
#include<queue>
using namespace std;
#define M 2300000
#define N 120300
#define INF 0x3f3f3f3f
struct node{
	int to,next,v;
}q[M];
int head[N],ss,dis[N],k,que[N<<4];bool vis[N],inq[N];
void addedge(int x,int y,int V)
{//printf("%d--(%d)->%d\n",x,V,y);
	q[++ss]=(node){y,head[x],V};head[x]=ss;
}
struct data{
	int v,idx;
	bool operator < (const data &B) const {return v>B.v;}
};
priority_queue <data> H;
void dij()
{
	memset(dis,0x3f,sizeof(dis));
	dis[k]=0;H.push((data){dis[k],k});
	while(!H.empty())
	{
		int u=H.top().idx;H.pop();
		if (vis[u]) continue;
		vis[u]=true;
		for (int j=head[u];j;j=q[j].next)
			if (dis[q[j].to]>dis[u]+q[j].v)
			{
				int t=q[j].to;
				dis[t]=dis[u]+q[j].v;
				H.push((data){dis[t],t});
			}
	}
}
void spfa()
{
	memset(dis,0x3f,sizeof(dis));
	int f=1,e=0;
	que[++e]=k;dis[k]=0;
	while(f<=e)
	{
		int u=que[f++];inq[u]=false;
		for (int j=head[u];j;j=q[j].next)
			if (dis[q[j].to]>dis[u]+q[j].v)
			{
				int t=q[j].to;
				dis[t]=dis[u]+q[j].v;
				if (!inq[t]) que[++e]=t,inq[t]=true;
			}
	}
}
int main()
{
	scanf("%d",&k);
	for (int i=1;i<k;++i)
		for (int j=0;j<=9;++j) addedge(i,(i*10+j)%k,j);
	for (int i=1;i<=9;++i) addedge(k,i%k,i);
	dij();
	printf("%d\n",dis[0]);
//	spfa();
//	printf("%d\n",dis[0]);
	return 0;
}

Measured memory_bytes: 16884
#include <string>
#include <vector>
#include <iostream>
#include <algorithm>
using namespace std;
const int inf = 1012345678;
int main() {
	int N, K;
	cin >> N >> K;
	vector<int> X(N);
	for (int i = 0; i < N; ++i) {
		cin >> X[i];
	}
	int ans = inf;
	for (int i = 0; i <= N - K; ++i) {
		int pl = X[i], pr = X[i + K - 1];
		int dl = 0, dr = 0;
		if (pl < 0) dl = max(dl, -pl);
		else dr = max(dr, pl);
		if (pr < 0) dl = max(dl, -pr);
		else dr = max(dr, pr);
		ans = min(ans, dl * 2 + dr);
		ans = min(ans, dl + dr * 2);
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 640
#include <stdio.h>

int main()
{
	int n;
	scanf("%d", &n);
	int p[n];
	int i, max, flag, sum, count=0;
	for (i = 0; i < n; i++) {
		scanf("%d", &p[i]);
	}
	max = p[0];
	flag = 0;
	for (i = 1; i < n; i++) {
		if (max < p[i]) {
			max = p[i];
			flag = i;
		}
	}
	sum = 0;
	for (i = 0; i < n; i++) {
		if (count != 1 && i == flag) {
			sum += (p[i] / 2);
			count = 1;
		} else {
			sum += p[i];
		}
	}
	printf("%d\n", sum);
	return 0;
}


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

#if defined(DEBUG)

#include <unistd.h>
#include <sys/fcntl.h>
#define DLOG(...)        cerr << dbgFormat(__VA_ARGS__) << endl
#define DCALL(func, ...) func(__VA_ARGS__)

template <class... Args>
string dbgFormat(const char* fmt, Args... args) {
  size_t len = snprintf(nullptr, 0, fmt, args...);
  char buf[len + 1];
  snprintf(buf, len + 1, fmt, args...);
  return string(buf);
}

#else  // defined(DEBUG)

#define DLOG(...)
#define DCALL(func, ...)

#endif // defined(DEBUG)
// ----------------------------------------------------------------------

// ----------------------------------------------------------------------
int main(int argc, char *argv[]) {
#if defined(DEBUG)
  // GDB on Cygwin ignores redirection at run command.
  if (argc == 2) dup2(open(argv[1], 0), 0);
#else
  // For performance.  We should not use C-style stdio functions
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);
#endif
  cout << setprecision(20);

  string S;
  cin >> S;
  string ans;
  if (S == "Sunny") {
    ans = "Cloudy";
  }else if (S == "Cloudy") {
    ans = "Rainy";
  }else if (S == "Rainy") {
    ans = "Sunny";
  }
  cout << ans << endl;

  return 0;
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int x,n,l,r,op,coun;
char s[600010],ch[200010],ch1;
void add(int x,int y,char z)
{
	if(x^y)
	{
		s[--l]=z;
	}else{
		s[++r]=z;
	}
}
int main()
{
	scanf("%s",ch);
	for(int i=0;i<strlen(ch);i++)
	{
		s[i+200010]=ch[i];
	}
	l=200010;
	r=strlen(ch)+200009;
    scanf("%d",&n);
    while(n--)
    {
    	scanf("%d",&op);
    	if(op==1)
    	{
    		coun=(coun+1)%2;
		}else{
			scanf("%d",&x);
			cin>>ch1;
			add(coun,x%2,ch1);
		}
	}
	if(coun)
	{
		for(int i=r;i>=l;i--)
		{
			cout<<s[i];
		}
	}else{
		for(int i=l;i<=r;i++)
		{
			cout<<s[i];
		}
	}
	return 0;
}

Measured memory_bytes: 896
#include<iostream>
#include<stack>
#include<utility>
#define INF 10000000
using namespace std;
int fw[30][30],fh[30][30];
bool used[30][30];
int w,h;
int d[30][30];
int cnt;
void dfs(){
  stack<pair<pair<int,int>,int> > sta;
  sta.push(make_pair(make_pair(0,0),1));
  while(!sta.empty()){
    pair<pair<int,int> ,int> q=sta.top(); sta.pop();
    int x=q.first.first,y=q.first.second;
    int cnt=q.second;
    if(d[x][y]<=cnt) continue;
    d[x][y]=cnt;
    cnt++;
    if(x!=0&&fh[x-1][y]==0) sta.push(make_pair(make_pair(x-1,y),cnt));
    if(y!=0&&fw[x][y-1]==0) sta.push(make_pair(make_pair(x,y-1),cnt));
    if(x!=h-1&&fh[x][y]==0) sta.push(make_pair(make_pair(x+1,y),cnt));
    if(y!=w-1&&fw[x][y]==0) sta.push(make_pair(make_pair(x,y+1),cnt));
  }
}
int main(){
  cin >> w >> h;
  while(w!=0){
    cnt=0;
    for(int i=0;i<2*h-1;i++){
      if(i%2==0){
        for(int j=0;j<w-1;j++){
          cin >> fw[i/2][j];
        }
      }else{
        for(int j=0;j<w;j++){
          cin >> fh[i/2][j];
        }
      }
    }
    for(int i=0;i<30;i++){
      for(int j=0;j<30;j++){
        used[i][j]=false;
        d[i][j]=INF;
      }
    }
    dfs();
    if(d[h-1][w-1]==INF) d[h-1][w-1]=0;
    cout << d[h-1][w-1]<<endl;
    cin >> w >> h;
  }
}



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

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


Measured memory_bytes: 3020
def main():
    n = int(input())
    xl = [list(map(int, input().split())) for _ in [0]*n]
    xy = [(x-l, x+l) for x, l in xl]
    xy.sort(key=lambda x: x[1])
    cnt = 0
    now = -10**10
    for x, y in xy:
        if x >= now:
            cnt += 1
            now = y
    print(cnt)


main()


Measured memory_bytes: 42596
import collections
N=int(input())
def prime_factorize(n):
    a = []
    while n % 2 == 0:
        a.append(2)
        n //= 2
    f = 3
    while f * f <= n:
        if n % f == 0:
            a.append(f)
            n //= f
        else:
            f += 2
    if n != 1:
        a.append(n)
    return a

def count_n(x):
    n=1
    while True:
        m=(1+n)*n/2
        if m>x:
            n-=1
            break
        n+=1
    return n


c = collections.Counter(prime_factorize(N))
d = c.values()
co=0
for i in d:
    co+=count_n(i)

if N==1:
    print(0)
else:
    print(co)   

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

#define endl '\n'

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    int x; cin >> x;
    int resp = (x/500)*1000;
    x %= 500;
    resp += (x/5)*5;
    cout << resp << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <vector>
#include <string>
#include <numeric>
#include <algorithm>
#include <cmath>
#include <functional>
#include <map>
#include <set>
#include <stack>
#include <deque>

#define INF 1000000000;
#define MOD 1000000007;
#define LIMIT 1000000000000000000;
typedef long long ll;
typedef unsigned long long ull;
using namespace std;
typedef pair<int, int> P;

template<typename T>
T gcd(T a, T b) {
    return b ? gcd(b, a % b) : a;
}

template<typename T>
T lcm(T a, T b) {
    return (a * b) / gcd(a, b);
}

int main()
{
    string s; cin >> s;
    string t = s;
    reverse(t.begin(), t.end());
    string ans = s == t ? "Yes" : "No";
    cout << ans << endl;
}

Measured memory_bytes: 256
n,m=map(int,input().split())
a=[]
for _ in range(m):
  b=list(map(int,input().split()))
  a.append(b)
  
a.sort()

left=a[0][0]
right=a[0][1]

ans=1

for i in range(1,m):
  x=a[i][0]
  y=a[i][1]
  
  if left<=x<right:
    left=x
    right=min(right,y)
    
  else:
    ans+=1
    left=x
    right=y
    
print(ans)
    
    

Measured memory_bytes: 27600
#include<stdio.h>


int main(void) {
    int ret;
    int n;
    double t,a;
    ret = scanf("%d",&n);
    ret = scanf("%lf%lf",&t,&a);

    double min = 1e30;
    int ans = -1;
    for (int i = 0; i < n; i++) {
        int h;
        ret = scanf("%d", &h);
        double tp = a - (t - 0.006 * h);
        if (tp < 0 ) tp = -tp;
        if (min > tp) {
            min = tp;
            ans = i+1;
        }
    }

    printf("%d\n",ans);

    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
long long arr[1000000];
int main()
{
    ios_base::sync_with_stdio(false); 
    cin.tie(NULL);  
	long long x;
	cin>>x;
	if (x>=30)
	{
		cout<<"Yes"<<endl;
	 } 
	 else
	 {
	 	cout<<"No"<<endl;
	 }
}

Measured memory_bytes: 3632
import java.util.*;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        int b = sc.nextInt();
        int c = sc.nextInt();
        System.out.println(c - (a - b) < 0 ? 0 : c - (a - b));
        sc.close();

    }

}


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

int main() {
    int N;
    int S1, S2;
    int head = 1, end = 1;

    cin >> N;

    vector<int> weight(N);
    for (int i = 0; i < N; i++) {
        int a;
        cin >> a;
        weight[i] = a;
    }

    S1 = weight[0];
    S2 = weight[N-1];

    while (head != N-end) {
        if(S1<=S2){
            S1 += weight[head];
            head++;
        } else {
            S2 += weight[N-1-end];
            end++;
        }
    }

    cout << abs(S1-S2) << endl;

    return 0;
}

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

int main()
{
  int d, n, i;
  cin >> d >> n;
  int ans = 1;
  for (i = 0; i < d; i++)
    ans *= 100;
  if (n != 100)
    cout << n * ans << endl;
  else
    cout << 101*ans << endl;
}


Measured memory_bytes: 256
parseInt(x) = parse(Int, x)

function main()
    N = parseInt(readline())
    A =parseInt.(split(readline()))
    for i in 1:N
        if A[i] % 2 == 0 && A[i] % 3 != 0 && A[i] % 5 != 0
            println("DENIED")
            return
        end
    end
    println("APPROVED")
end

main()

Measured memory_bytes: 114884
#include<iostream>
#include<algorithm>
#include<deque>
#include<string>
#include<map>
#include<set>
#include <unordered_set>
#include<vector>
#include<cmath>

using namespace std;

int sss(long long int x){
	long long int a = 2, sum = 0;
	long long int mx = 0;
	while (x >= a * a) {
		if (x%a == 0) {
			x /= a;
			sum++;
			mx = (mx, sum);
		}
		else { a++; sum = 0; }
	}
	return mx;
}

int main(void) {
	long long int n, p; cin >> n >> p;
	long long int i;
	long long int ans = 0;
	long long int mx = 0;

	if (n == 1) { cout << p << endl; return 0; }
	if (p == 1) { cout << "1" << endl; return 0; }

	for (i = 1; pow(i, n) <= p; i++) {
		long long x = p / pow(i, n);
		if (x == p / pow(i, n)) {
			if (sss(x) < n) {
				ans = i;
			}
		}
	}

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

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

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

using namespace std;

int main() {
  while(1){
    int n,m;
    cin>>n>>m;
    if(!n)break;
    vector<int> codes(m);
    REP(i,m)cin>>codes[i];
    vector<int> data(n);
    REP(i,n)cin>>data[i];
    vector<int64_t> dp(256,INT64_C(1000000000000000));
    dp[128] = 0;
    REP(i,n){
      vector<int64_t> tmp(256,INT64_C(1000000000000000));
      REP(j,256){
        REP(k,m){
          int newv = min(255, max(0, j+codes[k]));
          int diff = data[i] - newv;
          int sqd = diff*diff;
          tmp[newv] = min(tmp[newv], dp[j] + sqd);
        }
      }
      dp.swap(tmp);
    }
    cout << *min_element(begin(dp),end(dp)) << endl;
  }
  return 0;
}

Measured memory_bytes: 1276
#include <stdio.h>
#include <iostream>

#include <bits/stdc++.h>


using namespace std;

#define INPUT_INT(valName) int valName; cin >> valName;
#define INPUT_STR(valName) string valName; cin >> valName;
#define INPUT_LINE(valName) string valName; getline(cin,s);
#define INPUT_VECTOR_INT(valName, N) vector<int> valName(N); for(int i=0; i < N; ++i) { cin >> valName[i]; }
#define INPUT_VECTOR_DOUBLE(valName, N) vector<double> valName(N); for(int i=0; i < N; ++i) { cin >> valName[i]; }

#define OUTPUT(A) cout << (A) << endl;
#define OUTPUT2(A, B) cout << (A) << " " << (B) << endl;
#define OUTPUT3(A, B, C) cout << (A) << " " << (B) << " " << (C) << endl;

#define REP(valName, N) for(int valName = 0; valName < N; ++valName)

vector<string> split(const string &str, char delimiter) {
	vector<string> ret;
	string tmp = "";
	for (auto c : str) {
		if (c != delimiter) {
			tmp.push_back(c);
		} else {
			ret.push_back(tmp);
			tmp = "";
		}
	}
	ret.push_back(tmp);
	return ret;
}

template <typename T> void sortAsc(vector<T>& v) { sort(v.begin(), v.end(), less<T>()); }
template <typename T> void sortDesc(vector<T>& v) { sort(v.begin(), v.end(), greater<T>()); }



int main() {

	INPUT_INT(N);
	INPUT_VECTOR_DOUBLE(v, N);

	sortAsc(v);
	while (v.size() > 1) {
		v[0] = (v[0] + v[1]) / 2.0;
		v.erase(v.begin()+1);
	}

	OUTPUT(v[0]);

	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

/* {1,2,3} -> ... -> {3,2,1} */
int next_permutation(int arr[],int n) {
	int target;
	int i;
	int temp;
	for (i = n - 2; i >= 0; i--) {
		if (arr[i] < arr[i + 1]) break;
	}
	if (i < 0) return 0;
	target = i;

	for (i = 0; target + i + 1 < n - i - 1; i++) {
		temp = arr[target + 1 + i];
		arr[target + 1 + i] = arr[n - 1 - i];
		arr[n - i - 1] = temp;
	}

	for (i = target + 1; i < n; i++) {
		if (arr[i] > arr[target]) break;
	}
	temp = arr[i];
	arr[i] = arr[target];
	arr[target] = temp;
	return 1;
}

int main(void) {
	int HorieYui[9];
	int MorikuboSyotaro[9] = {1, 2, 3, 4, 5, 6, 7, 8, 9};
	int i;
	int answer = 0;
	for (i = 0; i < 9; i++) {
		if (scanf("%d" ,&HorieYui[i]) != 1) return 1;
	}
	do {
		int ok = 1;
		for (i = 0; i < 9; i++) {
			if (HorieYui[i] != -1 && HorieYui[i] != MorikuboSyotaro[i]) {
				ok = 0;
				break;
			}
		}
		if (ok) {
			if (MorikuboSyotaro[0] +
			(MorikuboSyotaro[1] * 10 + MorikuboSyotaro[2]) +
			(MorikuboSyotaro[3] * 100 + MorikuboSyotaro[4] * 10 + MorikuboSyotaro[5]) ==
			(MorikuboSyotaro[6] * 100 + MorikuboSyotaro[7] * 10 + MorikuboSyotaro[8])) {
				answer++;
			}
		}
	} while (next_permutation(MorikuboSyotaro, 9));
	printf("%d\n", answer);
	return 0;
}

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


int solve(int *a, int n){

	int dp[n];
	dp[0] = a[0];
	dp[1] = abs(a[0]-a[1]);
	dp[2] = min(abs(a[0]-a[2]), abs(a[0]-a[1]) + abs(a[2]-a[1]));
	for (int i = 3; i < n; ++i){
		dp[i] = min(dp[i-2]+abs(a[i]-a[i-2]), dp[i-1]+abs(a[i]-a[i-1]));
	}

	return dp[n-1];

}

int main(){

	int n;
	cin>>n;
	int h[n];
	for (int i = 0; i < n; ++i)
	{
		/* code */cin>>h[i];
	}
	cout<<solve(h,n);
	
	return 0;
}

Measured memory_bytes: 1024
#include<iostream>
#include<vector>
using namespace std;
#define FOR(i,a) for(int i=0;i<(int)(a);i++)
#define pb push_back
#define clr clear()
#define sz size()
typedef unsigned int ui;

class edge{
public:
  int b,e;
  int cost;

  void set(int s,int g,int c){
    b = s;
    e = g;
    cost = c;
  }
};

class graph{
public:
  vector<int> n;
  vector<edge> e;

  void set(void){
    n.clr;
    e.clr;
  }

  int Nexist(int a){
    FOR(i,n.sz){
      if(a == n[i])return i;
    }
    return -1;
  }

  int Eexist(int a,int b){
    for(ui i=0;i<e.sz;i++){
      if(e[i].b == a && e[i].e == b)return i;
      if(e[i].b == b && e[i].e == a)return i;
    }
    return -1;
  }

  void Nadd(int a){
    if(!n.sz)n.pb(a);
    else if(Nexist(a)<0){
      ui i = 0;
      while(n[i] < a && i<n.sz)i++;
      n.insert(n.begin()+i,a);
    }
  }

  void Eadd(edge a){
    if(!e.sz)e.pb(a);
    else{
      ui i = 0;
      while(e[i].cost < a.cost && i<e.sz)i++;
      e.insert(e.begin()+i,a);
    }
    Nadd(a.b);
    Nadd(a.e);
  }

  graph prim(void){
    graph res;

    res.set();

    if(!e.sz)return res;
    else{
      res.Eadd(e[0]);

      while(res.n.sz < n.sz){
	FOR(i,e.sz){
	  if(res.Nexist(e[i].b)>=0 && res.Nexist(e[i].e)<0){
	    res.Eadd(e[i]);
	    i = 0;
	  }else if(res.Nexist(e[i].b)<0 && res.Nexist(e[i].e)>=0 ){
	    res.Eadd(e[i]);
	    i = 0;
	  }
	}
      }
      return res;
    }
  }

  vector<int> warshall_floyd(void){
    vector<int> at;
    int tmp;
    for(ui i=0;i<n.sz;i++){
      for(ui j=0;j<n.sz;j++){
	if(i==j)at.pb(0);
	else{
	  tmp = Eexist(i,j);
	  if(tmp>=0)at.pb(e[tmp].cost);
	  else at.pb(-1);
	}
      }
    }

    for(ui k=0;k<n.sz;k++){
      for(ui i=0;i<n.sz;i++){
	for(ui j=0;j<n.sz;j++){
	  if(at[i*n.sz+k] >= 0 && at[k*n.sz+j] >= 0){
	    if(at[i*n.sz+k] + at[k*n.sz+j] < at[i*n.sz+j] || at[i*n.sz+j]<0){
	      at[i*n.sz+j] = at[i*n.sz+k] + at[k*n.sz+j];
	      at[j*n.sz+i] = at[i*n.sz+k] + at[k*n.sz+j];
	    }
	  }
	}
      }
    }
    return at;
  }
};

int main(){
  int n;
  int a,b,c;
  vector<int> at;
  graph wf;
  edge tmp;
  int cost,max,minn;
  int min;

  while(1){
    cin >> n;
    if(!n)break;

    max = 0;
    wf.set();
    at.clear();
    for(int k=0;k<n;k++){
      cin >> a >> b >> c;
      if(max < a)max = a;
      if(max < b)max = b;
      tmp.set(a,b,c);
      wf.Eadd(tmp);
    }

    at = wf.warshall_floyd();

    max++;

    min = 2000000000;
    for(int i=0;i<max;i++){
      cost = 0;
      for(int j=0;j<max;j++)cost += at[i*max+j];
      if(min > cost){
	min = cost;
	minn = i;
      }
    }
    cout << minn << " " << min << endl;
  }
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
const ll MOD=1000000007;
const double PI=3.14159265358979;
const ll INF= pow(10,18);
typedef pair<ll,ll> P;
typedef vector<ll> vl;
typedef vector<vl> vvl;
#define FOR(i,a,b) for(ll i=a;i<b;i++)
#define rep(i,n) FOR(i,0,n)
string abc="abcdefghijklmnopqrstuvwxyz";
string ABC="ABCDEFGHIJKLMNOPQRSTUVWXYZ";

int main() {
  ll n,m,v,p;
  cin >> n >> m >> v >> p;
  vl a(n);
  rep(i,n){
    cin >> a[i];
  }
  sort(a.begin(),a.end());
  auto check = [&](ll M) -> bool {
    bool ok=false;
    bool sub=true;
    ll s=0;
    //a[M]で条件満たすの?
    FOR(i,M+1,n-p+1){
      if(a[M]+m-a[i]>=0){
        s +=(a[M]+m-a[i]);
      }
      else
        sub=false;
    }
    if((M+1)*m+s>=m*(v-p+1)){
      ok=true;
    }
    return ok && sub;
  };
  
  ll ok = n - 1, ng = -1;
  while(abs(ok - ng) > 1){
    ll cen = (ok + ng) / 2;
    (check(cen) ? ok : ng) = cen;
  }
  
  cout << n - ok << endl;
}


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

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(a) (a).begin(), (a).end()
#define INF (int)1e8
#define EPS 1e-9

using vi = vector<int>;
using vvi = vector<vi>;
using vs = vector<string>;

int main() {
  int A, B;
  cin >> A >> B;

  int res = 0;
  for (int i = A; i <= B; i++) {
    string s = to_string(i);
    string r = s;
    reverse(all(r));
    if (s == r) res++;
  }

  cout << res << endl;
}

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

public class Main {
    public static void main(String args[]) {
        FastReader sc = new FastReader();
        String a = sc.next();
        String b = sc.next();
        if (a.equals("H") && b.equals("H") || a.equals("D") && b.equals("D"))
            System.out.println("H");
        else
            System.out.println("D");
    }

    static class FastReader
    {
        BufferedReader br;
        StringTokenizer st;

        public FastReader()
        {
            br = new BufferedReader(new
                    InputStreamReader(System.in));
        }

        String next()
        {
            while (st == null || !st.hasMoreElements())
            {
                try
                {
                    st = new StringTokenizer(br.readLine());
                }
                catch (IOException e)
                {
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }

        int nextInt()
        {
            return Integer.parseInt(next());
        }

        long nextLong()
        {
            return Long.parseLong(next());
        }

        double nextDouble()
        {
            return Double.parseDouble(next());
        }

        String nextLine()
        {
            String str = "";
            try
            {
                str = br.readLine();
            }
            catch (IOException e)
            {
                e.printStackTrace();
            }
            return str;
        }
    }
}


Measured memory_bytes: 21332
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int MOD=1e9+7;
const int INF=1e9;

int main(){
    int c[10]={0,2,5,5,4,5,6,3,7,6};
    int n,m;
    cin>>n>>m;
    char a[9];
    for(int i=0;i<m;i++){
        cin>>a[i];
    }
    string dp[n+10];
    dp[0]="";
    for(int i=1;i<n+10;i++){
        dp[i]="m";
    }
    for(int i=0;i<n;i++){
        for(int j=0;j<m;j++){
            if(dp[i]=="m")continue;
            int next=i+c[a[j]-'0'];
            if(dp[next]=="m"){
                dp[next]=dp[i]+a[j];
            }else if(dp[next].size()<dp[i].size()+1){
                dp[next]=dp[i]+a[j];
            }else if(dp[next].size()==dp[i].size()+1&&dp[next]<dp[i]+a[j]){
                dp[next]=dp[i]+a[j];
            }
        }
    }
    cout<<dp[n]<<endl;
}


Measured memory_bytes: 45056
n=int(input())

x=[0]*n
y=[0]*n

for i in range(n):
    x[i],y[i]=map(int,input().split())

dist=0
for i in range(n):
    for j in range(n):
        dist+=((x[i]-x[j])**2+(y[i]-y[j])**2)**0.5
        
print(dist/n)


Measured memory_bytes: 38512
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <cstring>
#include <math.h>
#include <bitset>
#include <queue>
#include <set>
#include <iomanip>
#include <math.h>
#include <assert.h>
// #include<bits/stdc++.h>
using namespace std;
typedef long long ll;
constexpr long long int INFLL = 1001001001001001LL;
constexpr long long int infll = 1001001001001001LL;
constexpr int INF = 1000000007;
constexpr int inf = 1000000007;
const int mod = 1000000007;

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

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

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

inline double nCr(const int n, int r)
{
    if (n == 0)
    {
        return 0;
    }
    if (r == 0)
    {
        return 1;
    }
    if (r == 1)
    {
        return n;
    }
    if (n == r)
    {
        return 1;
    }

    if (r > n / 2)
    {
        r = n / 2;
    }

    double result = 1;
    for (double i = 1; i <= r; i++)
    {
        result *= (n - i + 1) / i;
    }

    return (result);
}

template <typename T>
T seinomi(T a)
{
    if (a > 0)
    {
        return a;
    }
    else
    {
        return 0;
    }
}

template <typename T>
map<T, T> soinsuubunkai(T n) //連想配列[素因数f.first][個数f.second]
{
    map<T, T> ret;
    for (T i = 2; i * i <= n; i++)
    {
        while (n % i == 0)
        {
            ret[i]++;
            n /= i;
        }
    }
    if (n != 1)
        ret[n] = 1;
    return ret;
}

template <typename T>
T ketasuu(T num)
{
    return std::to_string(num).length();
}

int kaizyou(int k)
{
    int sum = 1;
    for (int i = 1; i <= k; ++i)
    {
        sum *= i;
    }
    return sum;
}

template <class ForwardIt, class T>
void iota(ForwardIt first, ForwardIt last, T value)
{
    while (first != last)
    {
        *first++ = value;
        ++value;
    }
}

//nの階乗を計算
int factorial(int n)
{
    int answer = 1;
    while (n > 1)
    {
        answer *= n;
        n--;
    }
    return answer;
}
int comb(int n, int r)
{
    return factorial(n) / (factorial(r) * factorial(n - r));
}

long long modpow(long long a, long long n, long long mod)
{
    long long res = 1;
    while (n > 0)
    {
        if (n & 1)
            res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}


template <typename T>
T amarinasi(T a,T b){
    if(a%b==0)
{
    return a/b;
}
else if(a%b>0)
{
    return a/b+1;
}
else
{
    return a/b-1;
}
}

//小数点以下10桁テンプレート（main関数内の最初に貼付け）
//std::cout << std::fixed << std::setprecision(10);

//----------------------------------------------------------------

int main(){
string s;
cin>>s;
ll ans=infll;
for(int i=0;i<s.size()-2;i++){
    string t=s.substr(i,3);
    ll a=stoll(t);
    chmin(ans,abs(a-753));
}
cout<<ans<<endl;
}












Measured memory_bytes: 256
#include<bits/stdc++.h>
#define For(i,j,k) for(int i=j;i<=k;++i)
#define Forr(i,j,k) for(int i=j;i>=k;--i)
#define ll long long 
using namespace std;
const int N = 60, INF = 0x3f3f3f3f, Mod = 1e9 + 7;
template<class T>void read(T &x){
	x=0;char c=getchar();
	while(!isdigit(c))c=getchar();
	while( isdigit(c))x=x*10+c-48,c=getchar();
}
inline void file(){
	freopen("test.in","r",stdin);
	freopen("test.out","w",stdout);
}
int n, f[N][N], C[N][N];
inline void add(int &a, int b){a = (a + b) % Mod;}
void init(){
	read(n);
	C[0][0] = 1;
	For(i, 1, n){
		C[i][0] = 1;
		For(j, 1, i)
			C[i][j] = (C[i - 1][j]  + C[i - 1][j - 1]) % Mod;
	}
}
void solve(){
	f[1][0] = f[1][1] = 1;
	For(i, 1, n - 1)
		For(j, 0, i)if(f[i][j])
			For(x, 0, n - i)
				For(y, 0, n - i - x)if((x + y) && (x + y >= j) && (x + y - j) % 2 == 0)
					add(f[i + x + y][abs(j + (x + y - j) / 2 - x)], 1ll * f[i][j] * C[i + x + y][x + y] % Mod * C[x + y][x] % Mod);
	printf("%d\n", f[n][0]);
}
int main(){
	//file();
	init();
	solve();
	return 0;
}


Measured memory_bytes: 256
#include <cstdio>
#include <algorithm>

using namespace std;
typedef long long ll;

int main() {
    int N;
    int P;
    int A[50];
    int num_odd = 0, num_even = 0;
    scanf("%d %d", &N, &P);
    for (int i = 0; i < N; i ++) {
        scanf("%d", &A[i]);
    }
    for (int i = 0; i < N; i ++) {
        if (A[i] % 2 == 0) {
            num_even ++;
        } else {
            num_odd ++;
        }
    }
    ll ret;
    if (num_odd > 0) {
        ret = 1ll << (N - 1);
    } else if (P == 0) {
        ret = 1ll << num_even;
    } else {
        ret = 0;
    }
    printf("%lld\n", ret);
}

Measured memory_bytes: 128
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>

#define REP(i, m, n) for(int i=int(m);i<int(n);i++)
#define EACH(i, c) for (auto &(i): c)
#define all(c) begin(c),end(c)
#define EXIST(s, e) ((s).find(e)!=(s).end())
#define SORT(c) sort(begin(c),end(c))
#define pb emplace_back
#define MP make_pair
#define SZ(a) int((a).size())

//#define LOCAL 1
#ifdef LOCAL
#define DEBUG(s) cout << (s) << endl
#define dump(x)  cerr << #x << " = " << (x) << endl
#define BR cout << endl;
#else
#define DEBUG(s) do{}while(0)
#define dump(x) do{}while(0)
#define BR
#endif


//改造
typedef long long int ll;
using namespace std;


//ここから編集する
int A, B, C, D, E, F;

int main() {
    REP(i,0,3){
        string str;
        cin >> str;
        char out = str[0];
        if(out >= 'a' && out <= 'z'){
            out = out - 'a' + 'A';
        }
        cout << out;
    }
    cout << endl;

    return 0;
}


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

long long MOD = 1e9 + 7;
// const int MAX = 10000000;


// 繰り返し二乗法  a^n (mod p) を計算
// https://math.nakaken88.com/textbook/cp-binary-exponentiation-and-recursive-function/
long long modPow(long long a, long long n, long long p) {
    if(n == 1) return a % p;
    if(n % 2 == 1) return (a * modPow(a, n - 1, p)) % p;
    long long t = modPow(a, n / 2, p) % p;
    return (t * t) % p;
}

// フェルマーの小定理より. mod p では
// Y^{-1} と Y^{p - 2} は等価
long long modInv(long long a, long long p) {
    return modPow(a, p - 2, p);
}

long long modCom(long long n, long long r, long long p) {
    long long ue = 1, shita = 1;
    for(int i = 0; i < r; i++) {
        ue = ue * (n - i) % p;
        shita = shita * (r - i) % p;
    }
    return ue * modInv(shita, p) % p;
}

/*
int fraction(int n) {
    int ans = 1;
    for(int i = 2; i <= n; i++) {
        ans *= i % MOD;
    }
    return ans % MOD;
}
*/


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

// https://qiita.com/drken/items/3b4fdf0a78e7a138cd9a
// a^n mod を計算する
/*
long long modpow(long long a, long long n, long long mod) {
    long long res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}
*/

// a^{-1} mod を計算する
/* 
long long modinv(long long a, long long mod) {
    return modpow(a, mod - 2, mod);
}
*/

/*
int combination(int n, int r) {
    return (fraction(n) % MOD) * modinv(fraction(r), MOD) * modinv(fraction(n - r), MOD);
}
*/



int main() {


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

    int ans = (modPow(2, n, MOD) - modCom(n, a, MOD) - modCom(n, b, MOD) - 1) % MOD;
    if(ans < 0) ans += MOD;
    cout << setprecision(15) << ans << endl;

    return 0;
}

Measured memory_bytes: 256
import java.io.BufferedReader
import java.io.InputStreamReader
import java.io.PrintWriter
import kotlin.math.min

val br = BufferedReader(InputStreamReader(System.`in`))
val out = PrintWriter(System.out)

fun main() {
    br.use { out.use {
        solve()
        out.flush()
    } }
}

fun solve() {
    val n = readInteger()
    val aList = readLongList()
    val bList = readLongList()

    val aSum = aList.sum()
    val bSum = bList.sum()
    if (aSum < bSum) {
        out.println(-1)
        return
    }

    val diffList = LongArray(n)
    for (i in 0 until n) {
        diffList[i] = aList[i] - bList[i]
    }
    diffList.sortDescending()

    // 4 -1 -1
    var minus = diffList.filter { it < 0 }.sum()
    val minusCount = diffList.count { it < 0 }
    var ans = 0
    while (minus < 0) {
        minus += diffList[ans]
        ans++
    }
    out.println(minusCount + ans)
}

fun readInteger() = Integer.parseInt(br.readLine())
fun readLong() = java.lang.Long.parseLong(br.readLine())
fun readStringList() = br.readLine()!!.split(' ')
fun readIntegerList() = readStringList().map(Integer::parseInt)
fun readLongList() = readStringList().map(java.lang.Long::parseLong)
fun readDoubleList() = readStringList().map(java.lang.Double::parseDouble)


Measured memory_bytes: 60472
#include <cstdio>
#include <cstring>
#include <cmath>
#include <algorithm>
#include <vector>
#include <iostream>
#include <set>
#include <map>
using namespace std;
typedef long long ll;

ll N, M;

int main(int argc, char const *argv[]) {
	cin >> N >> M;
	ll res = 0;
	if (N * 2 <= M) {
		res += N + (M - 2 * N) / 4;
	}
	else {
		res += min(M / 2, N);
	}
	cout << res << endl;
	return 0;
}

Measured memory_bytes: 256
from collections import defaultdict
import math


def main():
    n = int(input())
    ans = float("inf")
    for i in range(1, int(math.sqrt(n)) + 2):
        if n % i == 0:
            ans = min(ans, max(len(str(i)), len(str(n // i))))
    print(ans)


if __name__ == '__main__':
    main()


Measured memory_bytes: 3316
a = []
b = []
count1=0
count2=0
count3=0
count4=0
for i in range(3):
    tempa,tempb = map(int, input().split())
    if tempa == 1:
        count1 += 1
    if tempb == 1:
        count1 += 1
    if tempa == 2:
        count2 += 1
    if tempb == 2:
        count2 += 1
    if tempa == 3:
        count3 += 1
    if tempb == 3:
        count3 += 1
    if tempa == 4:
        count4 += 1
    if tempb == 4:
        count4 += 1
if (count1>2) or(count2>2) or(count3>2) or (count4>2):
    print("NO")
else:
    print("YES")

Measured memory_bytes: 3064
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

var sc = bufio.NewScanner(os.Stdin)

func next() string {
	sc.Scan()
	return sc.Text()
}

func nextInt() int {
	sc.Scan()
	i, _ := strconv.Atoi(sc.Text())
	return i
}

func nextFloat64() float64 {
	f, _ := strconv.ParseFloat(next(), 64)
	return f
}

func nextInts(n int) []int {
	slice := make([]int, n)
	for i := 0; i < n; i++ {
		slice[i] = nextInt()
	}
	return slice
}

func main() {
	sc.Split(bufio.ScanWords)
	a, b := nextInt(), nextInt()
	if (a+b)%2 == 1 {
		fmt.Println("IMPOSSIBLE")
	} else {
		fmt.Println((a + b) / 2)
	}
}


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

int main()
{
    int N;
    cin >> N;
    vector<long> A(N);
    long mod = 1e+9 + 7;

    for (int i = 0; i < N; i++)
    {
        cin >> A.at(i);
    }
    long ans = 0;
    long mult = A.at(N - 1);
    for (int i = N - 2; i >= 0; i--)
    {
        ans = (ans % mod) + ((A.at(i) * mult) % mod);
        mult += A.at(i);
        mult %= mod;
    }
    cout << ans % mod << endl;
    return 0;
}


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

#define rep(l, r) for (int i = (l); i < (r); i++)

typedef long long ll;
 
using namespace std;

int main() {
    int a, b, h;
    cin >> a >> b >> h;

    cout << ((a + b) * h / 2) << endl;

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
struct Edge {
    int to;     // 辺の行き先
    int weight; // 辺の重み
    Edge(int t, int w) : to(t), weight(w) { }
};
using Graph = vector<vector<int> >;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define reprep(i,j,h,w) rep(i,h)rep(j,w)
#define rrep(i,m, n) for(int i = m; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
#define aall(x,n) (x).begin(),(x).begin()+(n)
#define VEC(type,name,n) std::vector<type> name(n);rep(i,n)std::cin >> name[i];
#define pb push_back
#define pf push_front
#define lb lower_bound
#define ub upper_bound
#define fi first
#define se second
#define mk make_pair
#define sum accumulate
#define keta fixed<<setprecision
#define vvector(name,typ,m,n,a)vector<vector<typ> > name(m,vector<typ> (n,a))
#define vvvector(name,t,l,m,n,a) vector<vector<vector<t> > > name(l, vector<vector<t> >(m, vector<t>(n,a)));
#define vvvvector(name,t,k,l,m,n,a) vector<vector<vector<vector<t> > > > name(k,vector<vector<vector<t> > >(l, vector<vector<t> >(m, vector<t>(n,a)) ));
typedef long long ll;
const int INF = 2000000000;
const long INF64 = 1000000000000000ll;
const ll MOD = 1000000007LL;
typedef unsigned int uint;
#include <bits/stdc++.h>
using namespace std;
int main(){
    string s;
    std::cin >> s;
    int n;
    std::cin >> n;
    rep(i,n){
        string ss;
        int a,b;
        string t;
        std::cin >> ss;
        std::cin >> a>>b;
        if(ss=="replace")std::cin >> t;
        if(ss=="replace"){
            //td::cout << t << std::endl;
            rep(i,b-a+1)s[i+a]=t[i];
            //s.substr(a,b-a+1)=t;
            
        }
        if(ss=="reverse"){
            reverse(s.begin()+a,s.begin()+b+1);
        }
        if(ss=="print"){
            std::cout << s.substr(a,b-a+1) << std::endl;
        }
    }
}


Measured memory_bytes: 3184
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <string>
#include <cstring>
#include <utility>
#include <set>
#include <stack>
#include <climits>
#include <cmath>
#include <iomanip>

#define rep(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define rep1(i,n) for(int i=1, i##_len=(n); i<=i##_len; ++i)
#define reps(i,s,n) for(int i=s, i##_len=(n); i<i##_len; ++i)
#define all(x) (x).begin(),(x).end()
#define MEMSET(v, h) memset((v), h, sizeof(v))
typedef long long ll;
const char sp = ' ';


using namespace std;

int main(void){
    double L;
    cin>>L;
    cout<<setprecision(10)<<(L/3)*(L/3)*(L/3)<<endl;
    return 0;
}


Measured memory_bytes: 256
// SPDX-License-Identifier: X11

// Copyright 2020 Elias Yuan <a@jthv.ai>, MIT/X11 License
//   https://jthv.ai/LICENSE/X11.txt

// ANU-CPC Complexity Workshop - Two Integers

#include <stdio.h>

#define BOUND 1000000000000000000

int main(void)
{
  unsigned long x,y;
  scanf("%lu %lu",&x,&y);

  if (x < y){
    printf("%lu\n",x);
    return 0;
  }

  if (x % y == 0) {
    printf("-1\n");
    return 0;
  }

  unsigned long long z = x;

  while (z < BOUND) {
    if (z % y != 0) break;
    z += x;
  }

  printf("%llu\n",z);

  return 0;
}


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

#define ll long long
#define vi vector<int>
#define vvi vector<vi>
#define pii pair<int,int>
#define vll vector<ll>
#define vvll vector<vll>
template<typename T, typename U> 
static inline void amin(T &x, U y){
    if(x>y)
        x = y;
}
template<typename T, typename U> 
static inline void amax(T &x, U y){
    if(x<y)
        x = y;
}
#define rep(i,n) for(int i = 0; i < n; ++i)
#define irep(i,k,n) for(int i = k; i <= n; ++i)
#define irepr(i,k,n) for(int i = k; i >= n; --i)

const ll mod = 1e9+7;

int main(){
    ll n, a, b;
    cin>> n>> a>> b;
    if((b-a)%2 == 0){
        cout << (b-a)/2 << "\n";
    }else{
        if(a-1 < n-b){
            cout << a+(b-a)/2 << "\n";
        }else{
            cout << n-b+1+(b-a)/2 << "\n";
        }
    }
    return 0;
}

Measured memory_bytes: 256
import java.util.Arrays;
import java.util.Scanner;

class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);

		int p = sc.nextInt();
		int q = sc.nextInt();
		int r = sc.nextInt();

		int[] ft = {p + q, q + r, r + p};
		Arrays.sort(ft);

		System.out.println(ft[0]);

		sc.close();
	}

}


Measured memory_bytes: 23636
#include<bits/stdc++.h>
#define rep(i,n) for(ll i=0;i<(n);i++)
#define ll long long
using namespace std;
int main(){
    ll n;
    cin >> n;
    ll ans=0;
    for(int i=1;i < n+1;i++){
        if(i%3 != 0 && i%5 != 0){
            ans += i;
        }
    }
    cout << ans << endl;
}

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

int main()
{
    int x;
    cin >> x;
    int sum = 0;
    
    for(int i = 0;; i++)
    {
        sum += i;
        if(sum >= x)
        {
            cout << i << endl;
            break;
        }
    }
    
    return 0;
}

Measured memory_bytes: 256
// 1_abc142_a
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>// C++
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>

using namespace std;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define rep1(i, n) for(int i = 1; i <= (int)(n); i++)
#define SZ(x) ((int)(x).size())
#define INF (1e16)
#define MOD (1000000007)
typedef long long ll;

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n;
    cin >> n;
    double ans = 0;
    rep1(i, n){
        if(i % 2 == 1) ans++;
    }
    ans = ans / n;
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
import java.io.*;
import java.util.*;
class Program{
    int solve(int i, int size){
        int temp = i;
        for(int j=1;j<size;j++){
            temp=temp*10+i;
        }
        return temp;
    }
}
class Main{
    public static void main(String[] args) {
        Program obj = new Program();
        Scanner in = new Scanner(System.in);
        int n = in.nextInt(), m = in.nextInt(), x = in.nextInt(), y = in.nextInt();
        int X[] = new int[n]; int Y[] = new int[m];
        for(int i=0;i<n;i++) X[i] = in.nextInt();
        for(int i=0;i<m;i++) Y[i] = in.nextInt();
        Arrays.sort(X); Arrays.sort(Y);
        //System.out.println(Arrays.toString(X)+" "+Arrays.toString(Y));
        if(y>x){
            if (Y[0]>X[n-1]) {
                    if(Y[0]>x && y>X[n-1]) System.out.println("No War");
                    else System.out.println("War");
                }
                else System.out.println("War");
            }
        else System.out.println("War");
    }
}

Measured memory_bytes: 21844
c = { 'I' => 1, 'V' => 5, 'X' => 10, 'L' => 50, 'C' => 100, 'D' => 500, 'M' => 1000 }

while str = gets
  arr = str.chomp.chars
  break if arr.size == 0

  sum = 0
  0.upto(arr.size-1) do |i|
    a, b = arr[i], arr[i+1]

    if i == arr.size - 1
      sum += c[a]
    elsif c[a] < c[b]
      sum -= c[a]
    else
      sum += c[a]
    end
  end
  puts sum
end

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

int main(){
    
    // 1. 入力情報.
    int a[4];
    scanf("%d %d %d %d", &a[0], &a[1], &a[2], &a[3]);
    
    // 2. sort.
    sort(a, a + 4);
    
    // 3. 出力.
    if(a[0] == 1 && a[1] == 4 && a[2] == 7 && a[3] == 9) puts("YES");
    else                                                 puts("NO");
    return 0;
    
}

Measured memory_bytes: 256
#include <cstdio>

int main()
{
    int h, w;
    scanf("%d %d", &h, &w);
    char b[52][52] = {};
    char temp[64];
    for(int i = 1; i <= h; ++i)
    {
        scanf("%s", temp);
        for(int j = 1; j <= w; ++j)
        {
            if(temp[j-1] == '#')
            {
                b[i][j] = 1;
            }
        }
    }
    for(int i = 1; i <= h; ++i)
    {
        for(int j = 1; j <= w; ++j)
        {
            if(b[i][j])
            {
                if(!(b[i-1][j] || b[i+1][j] || b[i][j-1] || b[i][j+1]))
                {
                    printf("No\n");
                    return 0;
                }
            }
        }
    }
    printf("Yes\n");
    return 0;
}


Measured memory_bytes: 128
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>

#define REP(i, a, b) for (int i = int(a); i < int(b); i++)
#ifdef _DEBUG_
#define dump(val) cerr << __LINE__ << ":\t" << #val << " = " << (val) << endl
#else
#define dump(val)
#endif

using namespace std;

typedef long long int ll;

template<typename T>
vector<T> make_v(size_t a, T b) {
    return vector<T>(a, b);
}
template<typename... Ts>
auto make_v(size_t a, Ts... ts) {
    return vector<decltype(make_v(ts...))>(a, make_v(ts...));
}

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    int N, K;
    cin >> N >> K;
    cout << N - K + 1 << endl;
    return 0;
}


Measured memory_bytes: 256
N, M = map(int, input().split())
array = [list(map(int, input().split())) for _ in range(M)]
p = list(map(int, input().split()))
ans = 0

for i in range(2 ** N):
    flg = True
    for j, row in enumerate(array):
        count = 0
        for k in row[1:]:
            if i & (1 << (k - 1)):
                count += 1
        if not p[j] % 2 == count % 2:
            flg = False
            break
    if flg:
        ans += 1
print(ans)


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

using namespace std;

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

int main()
{
    long long int n, a[100010];
    long long int ans;

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

    ans = a[0];

    for (int i = 1; i < n; i++) {
        ans = ans/gcd(ans,a[i])*a[i];
    }

    cout << ans << endl;
}


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

using namespace std;
using llong = long long;
using ldbl = long double;
using P = pair<llong, llong>;

#define BE(x) x.begin(), x.end()

const llong inf = llong(1e18)+7;
const llong mod = 1e9+7;

int main(){
	int a, b, x;
	cin >> a >> b >> x;
	x = (x+499)/500;

	cout << min({(x/2+(x&1))*a, x*b, x/2*a + (x&1)*b}) << endl;

	return 0;
}


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

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
#ifdef LOCAL
	std::ifstream in("in");
	std::cin.rdbuf(in.rdbuf());
#endif

	string s;
	cin >> s;
	int pos = 0;
	int ans = 0;
	for(int i = 0; i < s.size(); i++){
		int npos = s[i] - 'A';
		do{
			pos = (pos + 1) % 26;
			if(pos == 0) ans++;
		} while(pos != npos);
	}
	cout << ans << endl;
}

Measured memory_bytes: 3176
import sys
sys.setrecursionlimit(10**6)

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

lis = [[] for _ in range(N+1)]
for i in range(M):
    A,B = map(int,input().split())
    lis[A].append(B)
    lis[B].append(A)
    
cnt = 0
seen = [False]*(N+1)
def dfs(v,graph):
    global cnt
    seen[v] = True
    for next_v in graph[v]:
        if seen[next_v] == True:
             continue
        if seen[next_v] == []:
             continue
        cnt += 1
        dfs(next_v,graph)
    return cnt

ma = 0
for j in range(N):
    cnt = 0
    if seen[j] == True:
        continue
    ma = max(ma,dfs(j,lis))
print(ma+1)

Measured memory_bytes: 210608
#include <iostream>
#include <vector>
#include <cmath>

using namespace std;

int main() {
    int n, k;  cin >> n >> k;
    vector<long long> h(n), dp(n, 1e10);
    for (int i = 0; i < n; i++)
        cin >> h[i];

    dp[0] = 0;
    for (int i = 0; i < n; i++) {
        for (int j = 1; j <= k; j++) {
            if (i+j < n)
                dp[i+j] = min(dp[i+j], dp[i]+abs(h[i]-h[i+j]));
        }
    }

    cout << dp[n-1] << endl;
    return 0;
}

Measured memory_bytes: 4780