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

using namespace std;

#define X first
#define Y second

const int dx[]={0,0,-1,1};
const int dy[]={1,-1,0,0};

vector<pair<int,int> > way;
pair<int,int> fr[52][52],s[52*52],p1,p2,be,ed,cur;
int d[52][52],dir[52][52][5];
bool vis[52][52];
int w,h,n,ans,mindis;

int calc(pair<int,int>	src,pair<int,int> tar){
	int l=1,r=1,cx,cy,ex,ey;
	for	(int i=1;i<=w;++i)	for	(int j=1;j<=h;++j){
		vis[i][j]=0;d[i][j]=w*h+1;
	}
	s[1]=src;vis[src.X][src.Y]=1;d[src.X][src.Y]=0;
	while	(l<=r){
		if	(vis[tar.X][tar.Y])	break;
		cx=s[l].X;cy=s[l].Y;
		//printf("%d %d\n",cx,cy);
		for	(int k=0;k<4;++k)
			if	(dir[cx][cy][k]){
				ex=cx+dx[k];ey=cy+dy[k];
				if	(!vis[ex][ey]){
					vis[ex][ey]=1;
					fr[ex][ey]=make_pair(cx,cy);
					d[ex][ey]=d[cx][cy]+1;
					s[++r]=make_pair(ex,ey);
				}
			}
		l++;
	}
	if	(d[tar.X][tar.Y]>w*h)	return	-1;
	else	return	d[tar.X][tar.Y];
}

int main(){
	while	(~scanf("%d%d%d",&w,&h,&n)){
		for	(int i=1;i<=w;++i)	for	(int j=1;j<=h;++j)
			for	(int k=0;k<4;++k)
				if	(i+dx[k] && i+dx[k]<=w && j+dy[k] && j+dy[k]<=h)	dir[i][j][k]=1;
				else	dir[i][j][k]=0;
		for	(int i=1;i<=n;++i){
			scanf("%d%d%d%d",&p1.X,&p1.Y,&p2.X,&p2.Y);
			if	(p1>p2)	swap(p1,p2);
			if	(p1.X==p2.X){
				for	(int j=p1.Y+1;j<=p2.Y;++j){
					dir[p1.X][j][3]=dir[p1.X+1][j][2]=0;
					//printf("Cutting %d %d %d %d\n",p1.X,j,p1.X+1,j);
				}
			}
			else{
				for	(int j=p1.X+1;j<=p2.X;++j){
					dir[j][p1.Y][0]=dir[j][p1.Y+1][1]=0;
					//printf("Cutting %d %d %d %d\n",j,p1.Y,j,p1.Y+1);
				}
			}
		}
		scanf("%d%d%d%d",&be.X,&be.Y,&ed.X,&ed.Y);
		be.X++;be.Y++;ed.X++;ed.Y++;
		mindis=calc(be,ed);
		//printf("%d\n",mindis);
		cur=ed;way.clear();
		while	(cur!=be){
			way.push_back(cur);
			cur=fr[cur.X][cur.Y];
		}
		way.push_back(be);
		reverse(way.begin(),way.end());
		ans=0;
		for	(int i=0;i<way.size()-1;++i){
			p1=way[i];p2=way[i+1];
			if	(p1>p2)	swap(p1,p2);
			if	(p1.X==p2.X){
				dir[p1.X][p1.Y][0]=dir[p2.X][p2.Y][1]=0;
				ans=max(ans,calc(be,ed)-mindis);
				dir[p1.X][p1.Y][0]=dir[p2.X][p2.Y][1]=1;
			}
			else{
				dir[p1.X][p1.Y][3]=dir[p2.X][p2.Y][2]=0;
				ans=max(ans,calc(be,ed)-mindis);
				dir[p1.X][p1.Y][3]=dir[p2.X][p2.Y][2]=1;
			}
		}
		printf("%d\n",ans);
	}
}

Measured memory_bytes: 1352
#include <stdio.h>
#include <stdlib.h>

int get_int() {
    int n = 0;
    int sign = 1;
    int c = getchar_unlocked();
    if(c == 45) sign = -1, c = getchar_unlocked();
    else if(c < 48 || 57 < c) return c;
    while(47 < c && c < 58) {
        n = 10 * n + (c & 0xf);
        c = getchar_unlocked();
    }
    return n * sign;
}
int get_str(char *str) {
    int c;
    while((c = getchar_unlocked()) > 32) *str++ = (char)c;
    *str = 0;
    return c;
}
void put_int(int n) {
    if(!n) {
        putchar_unlocked('0');
        return;
    }
    if(n < 0) n *= -1, putchar_unlocked('-');
    char buf[11];
    int i = 0;
    while(n) buf[i++] = (char)(n % 10 + '0'), n /= 10;
    while(i--)putchar_unlocked(buf[i]);
}
void put_str(char *str) { while(*str) putchar_unlocked(*str++); }
typedef struct Node {
    int key;
    struct Node *left, *right;
} Node;
typedef struct BST {
    Node *root;
    size_t size;
} BST;
void bst_init(BST *BST) {
    BST->root = NULL;
    BST->size = 0;
}
void bst_insert(BST *BST, int key) {
    Node *new_node = malloc(sizeof(Node));
    new_node->key = key;
    new_node->left = NULL;
    new_node->right = NULL;
    Node *tmp;
    Node *root = BST->root;
    while(root != NULL) {
        tmp = root;
        if(key < root->key) root = root->left;
        else root = root->right;
    }
    if(BST->size == 0) BST->root = new_node;
    else if(key < tmp->key) tmp->left = new_node;
    else tmp->right = new_node;
    BST->size++;
}
int bst_find(Node *root, int key) {
    if(root == NULL) return 0;
    else if(root->key == key) return 1;
    else if(root->key > key) return bst_find(root->left, key);
    else return bst_find(root->right, key);
}
void bst_inorder(Node *root) {
    if(root == NULL) return;
    bst_inorder(root->left);
    putchar_unlocked(' ');
    put_int(root->key);
    bst_inorder(root->right);
}
void bst_preorder(Node *root) {
    if(root == NULL) return;
    putchar_unlocked(' ');
    put_int(root->key);
    bst_preorder(root->left);
    bst_preorder(root->right);
}
int main(int argc, char **argv) {
    BST BST;
    bst_init(&BST);
    int m = get_int();
    int key;
    char c[8];
    for(int i = 0; i < m; ++i) {
        get_str(c);
        switch(*c){
        case 'i':
            key = get_int();
            bst_insert(&BST, key);
            break;
        case 'f':
            key = get_int();
            put_str(bst_find(BST.root, key) ? "yes\n" : "no\n");
            break;
        default:
            bst_inorder(BST.root);
            putchar_unlocked('\n');
            bst_preorder(BST.root);
            putchar_unlocked('\n');
            break;
        }
    }
    return 0;
}



Measured memory_bytes: 14060
#include<stdio.h>
#include<math.h>
#include<algorithm>
#include<queue>
#include<deque>
#include<string>
#include<string.h>
#include<vector>
#include<set>
#include<map>
#include<bitset>
#include<stdlib.h>
#include<cassert>
using namespace std;
const long long mod=1000000007;
const long long inf=mod*mod;
const long long d2=500000004;
const double EPS=1e-6;
const double PI=acos(-1.0);
int ABS(int a){return max(a,-a);}
long long ABS(long long a){return max(a,-a);}
int p[310000];
int sum[310000];
vector<pair<int,int> >g[310000];
int dp[310000];
int segtree[524288];
int query(int a,int b,int c,int d,int e){
	if(d<a||b<c)return -1;
	if(c<=a&&b<=d)return segtree[e];
	int L=query(a,(a+b)/2,c,d,e*2);
	int R=query((a+b)/2+1,b,c,d,e*2+1);
	if(L==-1)return R;
	if(R==-1)return L;
	if(dp[L]+(R-L)-(sum[R]-sum[L])<dp[R])return L;
	else return R;
}
void update(int a){
	a+=262144;
	a/=2;
	while(a){
		int L=segtree[a*2];
		int R=segtree[a*2+1];
		if(dp[L]+(R-L)-(sum[R]-sum[L])<dp[R])segtree[a]=L;
		else segtree[a]=R;
		a/=2;
	}
}
int main(){
	int a;scanf("%d",&a);
	for(int i=0;i<a;i++)scanf("%d",p+i);
	for(int i=0;i<290000;i++)sum[i+1]=sum[i]+p[i];
	int b;scanf("%d",&b);
	for(int i=0;i<262144;i++)segtree[i+262144]=i;
	for(int i=0;i<=290000;i++)dp[i]=mod;
	dp[0]=0;
	for(int i=0;i<262144;i++)update(i);

	for(int i=0;i<b;i++){
		int l,r;scanf("%d%d",&l,&r);l--;
		g[l].push_back(make_pair(r,(r-l)-(sum[r]-sum[l])));
	}
	for(int i=0;i<a;i++){
	//	printf("%d: ",i);
	//	for(int j=i;j<=a;j++)printf("%d ",dp[j]);printf("\n");
		for(int j=0;j<g[i].size();j++){
			int at=query(0,262143,i,g[i][j].first,1);
		//	printf("%d %d: %d\n",i,g[i][j].first,at);
			dp[g[i][j].first]=dp[at]+(g[i][j].first-at)-(sum[g[i][j].first]-sum[at]);
			update(g[i][j].first);
		}
		dp[i+1]=min(dp[i+1],dp[i]+p[i]);
		update(i+1);
		dp[i]=mod;
		update(i);
	}
	printf("%d\n",dp[a]);
}

Measured memory_bytes: 18944
# -*- coding: utf-8 -*-

N = int(input())
W = [int(i) for i in input().split()]

min_difference = 1000000000000
for T in range(1, N):
    S1 = sum(W[:T])
    S2 = sum(W[T:N])
    difference = abs(S1 - S2)

    if difference < min_difference:
        min_difference = difference

print(min_difference)


Measured memory_bytes: 2940
#include "bits/stdc++.h"
#define MAXN 200009
#define INF 1000000007
#define mp(x,y) make_pair(x,y)
#define all(v) v.begin(),v.end()
#define pb(x) push_back(x)
#define wr cout<<"----------------"<<endl;
#define ppb() pop_back()
#define tr(ii,c) for(__typeof((c).begin()) ii=(c).begin();ii!=(c).end();ii++)
#define ff first
#define ss second
#define my_little_dodge 46
#define debug(x)  cerr<< #x <<" = "<< x<<endl;
using namespace std;

typedef long long ll;
typedef pair<int,int> PII;
template<class T>bool umin(T& a,T b){if(a>b){a=b;return 1;}return 0;}
template<class T>bool umax(T& a,T b){if(a<b){a=b;return 1;}return 0;}
int last[MAXN],dp[MAXN];
int main(){
    //~ freopen("file.in", "r", stdin);
    int n,ans=0;
    scanf("%d",&n);
    for(int i=1;i<=n;i++){
		int x;
		scanf("%d",&x);
		if(last[x-1])
			dp[i]=dp[last[x-1]]+1;
		else
			dp[i]=1;
		last[x]=i;	umax(ans,dp[i]);
	}printf("%d\n",n-ans);
	return 0;
}


Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
#define pb push_back
#define mp make_pair
#define rep(i,n) for(int i=0;i<(n);++i)

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	int n,a,b;cin >> n >> a >> b;
	ll ans=0;
	rep(i,n+1){
		int x=i,sum=0;
		while(x>0){
			sum+=x%10;
			x/=10;
		}
		if(sum>=a && sum<=b) ans+=i;
	}
	cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h> 
#define FOR(i,a,b) for(int i=(a);i<=(b);++i) 
#define RFOR(i,a,b) for(int i=(a);i>=(b);--i) 
#define REP(i,n) for(int i=0;i<(n);++i)
#define RREP(i,n) for(int i=(n);i>0;--i)
#define CI cin>> 
#define CO cout<<
#define EN <<endl 
#define all(x) (x).begin(),(x).end()
using namespace std;
template <typename T> istream& operator >> (istream& is, vector<T>& vec) { for (T& x : vec) is >> x; 	return is; }
using ll = long long;
using VI = vector<int>;


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

int main() {
	int n; CI n;
	VI a(n); CI a;
	VI memo1(n+1, 0), memo2(n+1, 0);
	memo1[0] = a[0];
	memo2[n - 1] = a[n - 1];

	for (int i = 0; i < n;i++) {
		memo1[i+1] = gcd(a[i], memo1[i]);
	}memo1[0] = 0;
	for (int i = n - 1; i >= 0; i--) {
		memo2[i] = gcd(a[i], memo2[i+1]);
	}memo2[n] = 0;

	int ans = 0;
	REP(i, n) {
		ans=max(ans,gcd(memo1[i], memo2[i+1]));
	}

	CO ans EN;
	return 0;
}

Measured memory_bytes: 1408
#include<stdio.h>
int main(){
    int a,b,c,i;
    int count;
    scanf("%d %d %d",&a,&b,&c);
    for(i=a,count=0;i<=b;i++){
            if(c%i==0) count ++;
    }
    printf("%d\n",count);
    return 0;
}

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

int main(){
	int M,D,ans=0;
	cin >> M >> D;
	for(int i=4;i<=min(M,81);i++){
		for(int d=22;d<=D;d++){
			if((d/10)*(d%10)==i && (d/10)>=2 && (d%10)>=2)ans++;
		}
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
# coding: utf-8
A,B,C,X,Y = map(int, input().split())
minprice = 10**10
for i in range(max(X,Y)+1):
    tmp = 0
    tmp += C * i*2
    tmp += A * max(0,X-i)
    tmp += B * max(0,Y-i)
    minprice = min(minprice, tmp)
print(minprice)

Measured memory_bytes: 9212
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
using namespace std;
using namespace __gnu_pbds;

typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;
#define endl '\n'

void solvetask(){
    int n,m,k; cin >> n >> m >> k;
    vector<long long> a(n+1), b(m+1);
    for (int i=1; i<=n; i++){
        cin >> a[i];
        a[i] += a[i-1];
    }
    for (int i=1; i<=m; i++){
        cin >> b[i];
        b[i] += b[i-1];
    }
    int ans = 0;
    for (int i=0; i<=n; i++){
        if (a[i] > k) break;
        int p = lower_bound(b.begin(), b.end(), k - a[i]) - b.begin();
        if (p == m + 1 || b[p] > k - a[i]) p--;
        ans = max(ans, i + p);
    }
    cout << ans << endl;
}

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    int t=1;// cin >> t;
    while(t--) solvetask();
}

Measured memory_bytes: 6368
#include <bits/stdc++.h>
#define MOD 100000007
#define PI 3.141592653589793238
#define pb push_back
#define ALL(V) (V).begin(), (V).end()
#define rep(i, a, b) for(int i = (a); i < (b); ++i)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long long int lint;
typedef vector<ll> VL;
typedef vector<VL> VVL;
typedef vector<int> VI;
typedef pair<int, int> PII;
typedef pair<ll, ll> PLL;
inline ll gcd(ll a, ll b) { return (a % b == 0 ? b : gcd(b, a % b)); }
inline ll lcm(ll a, ll b) { return a * b / gcd(a, b); }
inline ll char_to_ll(char c) { return (int)(c - '0'); }
inline ll string_to_ll(string s) { return atoi(s.c_str()); }
inline bool is_prime(ll x){ if(x <= 1) return false; for(ll i = 2; sqrt(i) <= x; i++) if(x % i == 0) return false; return true; }

int main(){
    ll K, ans = 0;
    cin >> K;

    rep(a, 1, K + 1)
        rep(b, 1, K + 1)
            rep(c, 1, K + 1)
                ans += gcd(gcd(a, b), c);

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 3652
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<utility>
#include<tuple>
#include<map>
#include<queue>
#include<set>
#include<stack>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>

using namespace std;

using ll = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;

#define BIL ((ll)1e9)
#define MOD ((ll)1e9+7)
#define INF (1LL<<60)           //1LL<<63でオーバーフロー
#define inf (1<<29)             //1<<29でオーバーフロー

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

    vector<ll> a(n+1,0),b(n,0);
    for(auto &x:a)cin >> x;
    for(auto &y:b)cin >> y;

    ll count=0;
    for(int i=0;i<n;i++){
        if(a[i]>=b[i]){
            count+=b[i];
        }else{
            if(a[i]+a[i+1]>=b[i]){
                count+=b[i];
                a[i+1]-=b[i]-a[i];
            }else{
                count+=a[i]+a[i+1];
                a[i+1]=0;
            }
        }
    }

    cout << count << endl;

    return 0;
}


Measured memory_bytes: 4844
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define REP(i, n) for (int i = 0; i < (int)(n); i++)
#define ALL(x) (x).begin(), (x).end()

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

    int A, B;
    cin >> A >> B;
    REP(i, 1010) {
        if (i * 8 / 100 == A && i * 10 / 100 == B) {
            cout << i << endl;
            return 0;
        }
    }
    cout << -1 << endl;
}

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

// definition {{{ 1

// scaning {{{ 2
#define Scd(x) scanf("%d", &x)
#define Scd2(x,y) scanf("%d%d", &x, &y)
#define Scd3(x,y,z) scanf("%d%d%d", &x, &y, &z)

#define Scll(x) scanf("%llu", &x)
#define Scll2(x,y) scanf("%llu%llu", &x, &y)
#define Scll3(x,y,z) scanf("%llu%llu%llu", &x, &y, &z)

#define Scc(c) scanf("%c", &c);
#define Scs(s) scanf("%s", s);
#define Scstr(s) scanf("%s", &s);
// }}} 2

// constants {{{ 2
#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
// }}} 2

// systems {{{ 2
#define Rep(x,y) for(int x = 0; x < y; x++)
#define Repe(x,y,z) for(int x = z; x < y; x++)
// }}} 2

// output {{{ 2
#define YesNo(a) (a)?printf("Yes\n"):printf("No\n");
// }}} 2

// }}} 1

int main() {

    int n,a;
    int x[52];

    Scd2(n,a);
    Rep(i,n){
        Scd(x[i]);
        x[i] -= a;
    }

    static ll dp[10000][52];

    dp[5000][0] = 1;
    Rep(i,n){
        Rep(j,10000){
            if( dp[j][i] )
                dp[j+x[i]][i+1]+=dp[j][i];
            dp[j][i+1]+=dp[j][i];
        }
    }




    printf("%llu\n",dp[5000][n]-1);


    return 0;
}



Measured memory_bytes: 4352
// checklist
// ll, int overflow, array bounds
// special cases (n=1?), n+1 (1-index)
// do smth instead of nothing & stay organized
// WRITE STUFF DOWN

#include <bits/stdc++.h>

using namespace std;

#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define all(x) (x).begin(), (x).end() 
#define MOD 1000000007

typedef long long ll;
typedef pair <int, int> ii;
typedef pair <ll, ll> pll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef long double ld;

ll INF=LLONG_MAX;

int main()
{
    ios_base::sync_with_stdio(0); cin.tie(0);
    //freopen("input.txt","r",stdin); freopen("output.txt","w",stdout);
	int n,k;
	cin >> n >> k;
	int dp[k+1],a[n];
	memset(dp,0,sizeof(dp));
	for(int i=0; i<n; i++){
		cin>>a[i];
		if(a[i]<=k)dp[a[i]]++;
	}
	for(int i=1; i<=k; i++){
		for(int j=0; j<n; j++){
			if(i-a[j]>=0&&dp[i-a[j]]==0)dp[i]=1;
		}
	}
	if(dp[k]==1)cout << "First" << endl;
	else cout << "Second" << endl;
}	


Measured memory_bytes: 768
#include <bits/stdc++.h>
#include <map> // pair
using namespace std;
int main(){
  int N;
  cin>>N;
  vector<int>A1(N);
  vector<int>A2(N);
  int ans = 0;
  for(int i=0;i<N;i++){
    cin>>A1.at(i);
  }
  for(int i=0;i<N;i++){
    cin>>A2.at(i);
  }
  if(N==1){
    ans = A1.at(0)+A2.at(0);
  }else{
    for(int i=1;i<N;i++){
      int root = 0;
      for(int j=0;j<i;j++){
        root+=A1.at(j);
        //cout<<A1.at(j)<<"+";
      }
      for(int j=i-1;j<N;j++){
        root+=A2.at(j);
      //  cout<<A2.at(j)<<endl;
      }
      if(ans<root)ans = root;
    }
  }

  cout<<ans<<endl;
}


Measured memory_bytes: 256
import sys, math, itertools, collections, bisect
input = lambda: sys.stdin.buffer.readline().rstrip().decode('utf-8')
inf = float('inf') ;mod = 10**9+7
mans = inf ;ans = 0 ;count = 0 ;pro = 1

n,d = map(int,input().split())
for i in range(n):
  x,y = map(int,input().split())
  if x**2 + y ** 2 <= d**2:
    count += 1
print(count)

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

#define loop(s, e, i) for (int i = s; i < e; ++i)
#define print(s) cout << s << endl;
using namespace std;
using ll = long long;

/*
浮動小数点の入力
cout << fixed << setprecision(9) << endl;
*/

ll gcd(ll a, ll b)
{
  if (a < b)
  {
    return gcd(b, a);
  }
  while (b != 0)
  {
    ll tmp = b;
    b = a % b;
    a = tmp;
  }
  return a;
}

struct Data
{
  int r, l, k;
};

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

  map<string, ll> M;

  loop(0, N, i)
  {
    string S;
    cin >> S;
    sort(S.begin(), S.end());
    if (M.find(S) != M.end())
    {
      M[S] = M[S] + 1;
    }
    else
    {
      M[S] = 1;
    }
  }
  ll sum = 0;
  for (auto &x : M)
  {
    if (x.second == 1) {
      continue;
    }
    sum += x.second*(x.second-1) / 2;
  }
  print(sum);
}

Measured memory_bytes: 11484
r, c = map(int, input().split(" "))

table = list()

for i in range(r):

    table.append(list())
    table[i] = list(map(int, input().split(" ")))

    table[i].append(0)
    for j in range(c):
        table[i][c] += table[i][j]

table.append(list())

for i in range(r):
    print(" ".join([str(x) for x in table[i]]))

    for j in range(c + 1):
        if i == 0:
            table[r].append(0)
        table[r][j] += table[i][j]

print(" ".join([str(x) for x in table[r]]))

Measured memory_bytes: 7796
<?php
//error_reporting(0);
//$N = trim(fgets(STDIN));
list($N,$M) = explode(" ",trim(fgets(STDIN)));
$A = explode(" ",trim(fgets(STDIN)));
$sum = array();
$sum[0]=0;
for($i=0;$i<$N;$i++) {
  $sum[$i+1]=($sum[$i]+$A[$i])%$M;
}
$res = 0;
foreach($sum as $k=>$v) {
  $res += $m[$sum[$k]];
  $m[$sum[$k]]++;
}
printf("%d\n",$res);

Measured memory_bytes: 44180
N = int(input())

A = [0]*(N+1)
for i in range(1, N+1):
    for j in range(i, N+1, i):
        A[j] += 1

count = 0
for i in range(1, N+1):
    if i%2 == 1 and A[i] == 8:
        count += 1
print(count)

Measured memory_bytes: 9180
H, W = map(int, input().split())
all_info = [list(input()) for i in range(H)]
for i, line in enumerate(all_info):
    all_info[i] = ['.'] + line + ['.']
all_info = [['.' for i in range(W+2)]] + all_info + [['.' for i in range(W+2)]]

for row_num, padded_row in enumerate(all_info[1: -1]):
    for collumn_num, s in enumerate(padded_row[1: -1]):
        if s == '#':
            continue
        else:
            all_info[row_num + 1][collumn_num + 1] = str((all_info[row_num][collumn_num: collumn_num +3]
                                                                           + all_info[row_num + 2][collumn_num: collumn_num + 3]
                                                                            + all_info[row_num + 1][collumn_num: collumn_num + 3]).count('#'))

for row in all_info[1: -1]:
    print(''.join(row[1: -1]))

Measured memory_bytes: 3188
#pragma region Macros
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define REPR(i, n) for(int i=(n); i>=0; --i)
#define FOR(i, n, m) for(int i=(m), i##_len=(n); i<i##_len; ++i)
#define EACH(i, v) for(const auto& i : v)
#define ALL(x) (x).begin(),(x).end()
#define ALLR(x) (x).rbegin(),(x).rend()
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; }
template<class Value>using vec = vector< Value >;
using ll = long long;
using P = pair< long long, long long >;
#define fi first
#define se second
#define el endl
#pragma endregion

const string YES = "Yes";
const string NO = "No";

void Main();
void solve(long long A, long long B, long long C, long long K);

int main(){
    std::cin.tie(nullptr);
    std::cout << std::fixed << std::setprecision(15);
    Main();
    return 0;
}

void Main(){
    long long A;
    scanf("%lld",&A);
    long long B;
    scanf("%lld",&B);
    long long C;
    scanf("%lld",&C);
    long long K;
    scanf("%lld",&K);
    solve(A, B, C, K);
}

void solve(long long A, long long B, long long C, long long K){
    for(; K >= 0; K--, B*=2){
        if(B > A){
            break;
        }
    }
    for(; K >= 0; K--, C*=2){
        if(C > B){
            cout << YES << el;
            return;
            break;
        }
    }
    cout << NO << el;

}



Measured memory_bytes: 3804
//#include "bits/stdc++.h"

#define _USE_MATH_DEFINES
#include<cstdio>
#include <cstring>
#include <cmath>
#include <cstdlib>
#include <deque>
#include <algorithm>
#include <functional>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>
#include <iterator>

using namespace std;

#define rep(i,a,b) for(int i=(a), i##_len=(b);i<i##_len;i++)
#define rrep(i,a,b) for(int i=(b)-1;i>=(a);i--)
#define all(c) begin(c),end(c)

#define int ll
#define SZ(x) ((int)(x).size())
#define pb push_back
#define mp make_pair

//typedef unsigned long long ull;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<ll, int> pli;
typedef pair<double, double> pdd;
typedef vector< vector<int> > mat;

template<class T> bool chmax(T &a, const T &b) { if (a < b) { a = b; return true; } return false; }
template<class T> bool chmin(T &a, const T &b) { if (b < a) { a = b; return true; } return false; }

const int INF = sizeof(int) == sizeof(long long) ? 0x3f3f3f3f3f3f3f3fLL : 0x3f3f3f3f;
const int MOD = (int)1e9 + 7;
const double EPS = 1e-9;

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

	int N, A, B;
	cin >> N >> A >> B;

	cout << min(A*N, B) << endl;

	return 0;
}

Measured memory_bytes: 256
class UnionFind:
    #def   -> foo=UnionFind(n,1)  <- 1-based index, default is 0
    #method -> foo.hoge(huga)
    __slots__ = ["_size", "_first_idx", "_parents"]
    def __init__(self, size: int, first_index: int = 0) -> None:
        self._size = size
        self._first_idx = first_index
        self._parents = [-1] * (size + first_index)
    def find(self, x: int) -> int:
        if self._parents[x] < 0:
            return x
        self._parents[x] = self.find(self._parents[x])
        return self._parents[x]
    def same(self, x: int, y: int) -> bool:
        return self.find(x) == self.find(y)
    def unite(self, x: int, y: int) -> bool:
        x, y = self.find(x), self.find(y)
        if x == y:
            return False
        if self._parents[x] > self._parents[y]:
            x, y = y, x
        self._parents[x] += self._parents[y]
        self._parents[y] = x
        return True
    def size(self, x: int) -> int:
        return -self._parents[self.find(x)]
    def group_count(self) ->int:
        return sum(1 for i in  self._parents if i<0)-self._first_idx
    def connected(self) ->bool:
        return self._parents[self.find(self._first_idx)]==-self._size
n,m=map(int,input().split())

uf=UnionFind(n,1)
for i in range(m):
    uf.unite(*map(int,input().split()))
print(-min(uf._parents))

Measured memory_bytes: 76564
#include<bits/stdc++.h>
using namespace std;
#define ll long long
 
int main() {
	ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
	ll n;
	cin>>n;
	if(n%1000==0) cout<<0;
	else
	cout<<1000-n%1000;
}

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

int main(){
	int n,m,l;
	cin >> n >> m >> l;
	
	long long int a[100][100], b[100][100];
	for(int i=0; i<n; i++){
		for(int j=0; j<m; j++){
			cin >> a[i][j];
		}
	}
	for(int i=0; i<m; i++){
		for(int j=0; j<l; j++){
			cin >> b[i][j];
		}
	}
	for(int i=0; i<n; i++){
		for(int j=0; j<l; j++){
			long long int e=0;
			for(int f=0; f<m; f++){
				e += a[i][f]*b[f][j];
			}
			if(j==0) cout << e;
			else cout <<" " << e;
	
		}
		cout<<endl;
	}
	return 0;
}


Measured memory_bytes: 3224
#include <iostream>
#include <algorithm>
#include <iomanip>
#include <math.h>
using namespace std;


int main()
{
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	int r;
	cin>>r;
	cout<<fixed<<setprecision(20)<<2*M_PI*r;
	
	return 0; 
}

Measured memory_bytes: 3800
#include<bits/stdc++.h>
#define ll long long
using namespace std;
int n,tot,sz[200010],a[200010],e[500010],rt[500010],hd[500010],nt[500010];
ll f[500010];
map<int,int>mp[200010];
void build(int x,int y){
	tot++;
	e[tot]=y;
	nt[tot]=hd[x];hd[x]=tot;
}
void hb(int &x,int y){
	int t,k;
	if(mp[x].size()<mp[y].size())swap(x,y);
	for(map<int,int>::iterator it=mp[y].begin();it!=mp[y].end();it++){
		t=it->first;k=it->second;
		mp[x][t]+=k;
	}
	mp[y].clear();
}
void dfs(int x,int fa){
	int i,w;
	sz[x]=1;rt[x]=x;
	for(i=hd[x];i;i=nt[i]){
		if(e[i]==fa)continue;
		dfs(e[i],x);
		sz[x]+=sz[e[i]];
		hb(rt[x],rt[e[i]]);
	}
	mp[rt[x]][a[x]]=sz[x];
	if(x==1){
		for(i=1;i<=n;i++){
			w=mp[rt[x]][i];
			f[i]+=1ll*(n-w)*(n-w+1)/2;
		}
	}
	 else{
	 	w=mp[rt[x]][a[fa]];
	 	f[a[fa]]+=1ll*(sz[x]-w)*(sz[x]-w+1)/2;
	 }
}
int main(){
	int i,x,y;
	/*scanf("%d",&n);
	for(i=1;i<=n;i++)*/
	//mp[1][1]=mp[1][2]=0;
	//printf("%d",mp[1].size());
	scanf("%d",&n);
	for(i=1;i<=n;i++)scanf("%d",&a[i]);
	for(i=1;i<n;i++){
		scanf("%d%d",&x,&y);
		build(x,y);build(y,x);
	}
	dfs(1,0);
	for(i=1;i<=n;i++)printf("%lld\n",1ll*n*(n+1)/2-f[i]);
}

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

int main() {
  int n, q;
  string s;
  cin >> n >> q >> s;
  vector <int> c(n, 0);
  for (int i = 0; i < n - 1; i++) {
	  if (s[i] == 'A' && s[i + 1] == 'C') {
		  c[i + 1] = 1;
		}
	  c[i + 1] += c[i];
	}
  for (int i = 0; i < q; i++) {
	  int l, r;
	  cin >> l >> r;
	  cout << c[r - 1] - c[l - 1] << endl;
	}
  return 0;
}


Measured memory_bytes: 1408
#include <bits/stdc++.h>
using namespace std;
using ll = int;
using PII = pair<ll, ll>;
#define FOR(i, a, n) for (ll i = (ll)a; i < (ll)n; ++i)
#define REP(i, n) FOR(i, 0, n)
#define ALL(x) x.begin(), x.end()
template<typename T> void chmin(T &a, const T &b) { a = min(a, b); }
template<typename T> void chmax(T &a, const T &b) { a = max(a, b); }
struct FastIO {FastIO() { cin.tie(0); ios::sync_with_stdio(0); }}fastiofastio;
#ifdef DEBUG_ 
#include "../program_contest_library/memo/dump.hpp"
#else
#define dump(...)
#endif
const ll INF = 1LL<<30;
ll dx[] = {1, 0}, dy[] = {0, 1};

string s[51];
ll h, w, dp[51][51][51][51];
vector<PII> g[26];
bool can[51][51][51][51];
ll dfs(ll sx, ll sy, ll gx, ll gy) {
    // dump(sx, sy, gx, gy);
    if(!can[sx][sy][gx][gy]) return -INF;
    if(gx==sx && gy==sy) return 0;
    if(dp[sx][sy][gx][gy] != -1) return dp[sx][sy][gx][gy];
    ll ret = 0;
    if('a' <= s[sy][sx] && s[sy][sx] <= 'z') {
        // s[sy][sx] に対応する位置
        for(auto to: g[s[sy][sx]-'a']) {
            if(to.first<sx || to.first>gx || to.second<sy || to.second>gy) continue;
            if(abs(to.first-sx) + abs(to.second-sy) == 1) {
                chmax(ret, 1 + dfs(to.first, to.second, gx, gy));
                continue;
            }
            ll vr = dfs(to.first, to.second, gx, gy);
            REP(i, 2) REP(j, 2) {
                ll nsx = sx + dx[i], nsy = sy + dy[i];
                ll ntx = to.first - dx[j], nty = to.second - dy[j];
                if(nsx > ntx || nsy > nty) continue;
                ll vl = dfs(nsx, nsy, ntx, nty);
                chmax(ret, vl + vr + 1);
                // dump(nsx, nsy, ntx, nty, gx, gy);
            }
        }
    }
    if(sx < gx) chmax(ret, dfs(sx+1, sy, gx, gy));
    if(sy < gy) chmax(ret, dfs(sx, sy+1, gx, gy));
    return dp[sx][sy][gx][gy] = ret;
}

void visit(ll sx, ll sy, ll x, ll y) {
    can[sx][sy][x][y] = true;
    if(x+1<w && s[y][x+1]!='#' && !can[sx][sy][x+1][y]) visit(sx, sy, x+1, y);
    if(y+1<h && s[y+1][x]!='#' && !can[sx][sy][x][y+1]) visit(sx, sy, x, y+1);
}

int main(void) {
    while(1) {
        cin >> h >> w;
        if(h==0) break;
        REP(i, h) cin >> s[i];
        // dump(h, w);
        // REP(i, h) dump(s[i]);

        memset(dp, -1, sizeof(dp));
        REP(i, 26) g[i].clear();
        REP(i, h) REP(j, w) {
            if('A' <= s[i][j] && s[i][j] <= 'Z') {
                g[s[i][j]-'A'].push_back({j, i});
            }
        }

        // REP(i, 26) dump(g[i]);

        memset(can, false, sizeof(can));
        REP(i, h) REP(j, w) {
            if(s[i][j]=='#') continue;
            visit(j, i, j, i);
        }
        if(!can[0][0][w-1][h-1]) {
            cout << -1 << endl;
            continue;
        }

        cout << dfs(0, 0, w-1, h-1) << "\n";
    }
    cout << flush;

    return 0;
}


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

int main(){
  int var[5];
  while(cin >> var[0] >> var[1] >> var[2] >> var[3] >> var[4]){
    for(int i=0; i<5; i++){
      if(var[i] == 0)
        cout << i+1 << endl;
    }
  }
}

Measured memory_bytes: 3588
import java.util.Scanner;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		
		while(sc.hasNext()){
			String[] s = sc.nextLine().split("[\\s]+");
			int n = Integer.parseInt(s[0])+Integer.parseInt(s[1]);
			String ans = ""+n;
			System.out.println(ans.length());
		}
	}
}

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

//using Graph = vector<vector<edge>>;
using dou =long double;
string yes="yes";
string Yes="Yes";
string YES="YES";
string no="no";
string No="No";
string NO="NO";

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
#define rep(i, n)         for(int i = 0; i < (int)(n); i++)
#define brep(n)           for(int bit=0;bit<(1<<n);bit++)
#define erep(i,container) for (auto i : container)
#define irep(i, n)        for(int i = n-1; i >= (int)0; i--)
#define rrep(i,m,n) for(ll i = m; i < (ll)(n); i++)
#define reprep(i,j,h,w) rep(i,h)rep(j,w)
#define all(x) (x).begin(),(x).end()
#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 query int qq;std::cin >> qq;rep(qqq,qq)
#define lb lower_bound
#define ub upper_bound
#define fi first
#define se second
#define itn int
#define mp make_pair
#define sum(a) accumulate(all(a),0ll)
#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)) ));
#define case std::cout <<"Case #" <<qqq+1<<": "
#define RES(a,i,j) a.resize(i);rep(ii,i)a[ii].resize(j); 
#define as assign
#define ffor for(;;)
#define ppri(a,b) std::cout << a<<" "<<b << std::endl
#define pppri(a,b,c) std::cout<<a<<" "<<b<<" "<<c<<std::endl
#define aall(x,n) (x).begin(),(x).begin()+(n)
#define ssum(a) accumulate(a,0ll) 
#define gre(n) greater<n>()

typedef long long ll;
//
typedef pair<int,int> P;
typedef pair<ll,ll> PL;
//typedef long long T;
const int INF = 1000000000;
const double dINF = 1000000000;
const ll INF64 = 922337203685477580ll;
const ll MOD = 998244353ll;
//const ll MOD = 67280421310721ll;
const dou pi=3.141592653589793;
//メモ
//二次元配列のresizeのしかた
//vv.resize(n);
//for(size_t i=0; i<n; i++){
// vv[i].resize(n);
//}

//メモ
//負の辺を持つ最短経路問題では到達不可経路でも初期化値より小さくなりうるので注意しよう
int main(){
    int n;
    std::cin >> n;
    VEC(int,a,n);
    std::multiset<int> s;
    s.insert(a[0]);
    rrep(i,1,n){
        if(s.lb(a[i])==s.begin()){
            s.insert(a[i]);
        }
        else{
            auto it=s.lb(a[i]);
            it--;
            s.erase(it);
            s.insert(a[i]);
        }
    }
    
    std::cout << s.size() << std::endl;
    
}

Measured memory_bytes: 5376
#include <stdio.h>

int main(void)
{
  int x1, y1, x2, y2, dx, dy;
  scanf("%d%d%d%d", &x1, &y1, &x2, &y2);
  dx = y1-y2;
  dy = x2-x1;
  printf("%d %d %d %d\n", dx+x2, dy+y2, dx+x1, dy+y1);
  return 0;
}

Measured memory_bytes: 128
//#include <bits/stdc++.h>
#include <iostream>
#include <fstream>
#include <vector>
#include <string>
#include <cmath>
#include <algorithm>
#include <map>
#include <iomanip>
#include <stdlib.h>
#include <stdio.h>
#include <queue>
#include <deque>
#include <set>
#include <stack>
#include <time.h>
 
using namespace std;
 
typedef long long ll;
typedef long double ld;
typedef pair<int, int> Pii;
typedef pair<int, ll> Pil;
typedef pair<ll, ll> Pll;
typedef pair<ll, int> Pli;

#define fi first
#define se second

const ll MOD = 1e9 + 7;
const ll MOD2 = 998244353;
const ll MOD3 = 1812447359;
const ll INF = 1ll << 62;
const double PI = 2 * asin(1);

void yes() {printf("yes\n");}
void no() {printf("no\n");}
void Yes() {printf("Yes\n");}
void No() {printf("No\n");}
void YES() {printf("YES\n");}
void NO() {printf("NO\n");}

int N, K, p, m;
ll Plus[int(2e5 + 5)], Minus[int(2e5 + 5)];
ll ans = 1;

int main(){
  scanf("%d%d", &N, &K);
  for (int i = 0; i < N; i++){
    ll A; scanf("%lld", &A);
    if (A >= 0) Plus[p] = A, p++;
    if (A < 0) Minus[m] = -1 * A, m++;
  }

  if (m == N && K % 2 != 0){
    sort(Minus, Minus + m);
    for (int i = 0; i < K; i++){
      ans *= Minus[i]; ans %= MOD;
    }
    ans *= -1;
    ans %= MOD; ans += MOD;
    cout << ans << endl;
    return 0;
  }

  if (p + m == N && N == K){
    for (int i = 0; i < p; i++){
      ans *= Plus[i]; ans %= MOD;
    }
    for (int i = 0; i < m; i++){
      ans *= -1 * Minus[i]; ans %= MOD; 
    }
    if (ans < 0) ans += MOD;
    cout << ans << endl;
    return 0;
  }

  sort(Plus, Plus + p, greater<ll>());
  sort(Minus, Minus + m, greater<ll>());


  int now = 0;
  for (int i = K - 1; i >= 1; i-=2){
    if (Minus[now] == 0 || Minus[now + 1] == 0) break;
    if (Minus[now] * Minus[now + 1] < Plus[i] * Plus[i-1]) break;

    Plus[i] = Minus[now];
    Plus[i-1] = Minus[now + 1];
    now += 2;
  }

  for (int i = 0; i < K; i++) ans *= Plus[i], ans %= MOD;
  cout << ans << endl;


  return 0;
}


Measured memory_bytes: 6752
#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 mp make_pair
#define pb(x) push_back(x)
#define vi vector<int>
#define vs vector<string>
#define vll vector<long long>
#define vc vector<char>
#define vs vector<string>
#define pii pair<int, int>
#define pll pair<long long, long long>
#define pil pair<int, long long>
#define pli pair<long long, int>
#define pcc pair<char, char>
#define pdd pair<double, double>
#define mll map<long long, long long>
#define sz(v) ((int)(v).size())
#define all(v) (v).begin(), (v).end()
#define flsh fflush(stdout)
#define gcd __gcd
#define clr(x) memset(x, 0, sizeof(x))
#define mod 1000000007LL
#define mod2 998244353LL
#define INF 1000000000007
 

typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;
typedef tree<ll,null_type,less<ll>,rb_tree_tag,tree_order_statistics_node_update> o_tree;


void solve()
{
    ll tt;
    cin>>tt;
    cout<<(tt>=30?"Yes":"No");
}


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


if (fopen("input.txt","r" ))
  {
     freopen("input.txt", "r", stdin);
     freopen("output.txt", "w", stdout);
  }
cout<<setprecision(20);


ll t=1;


// cin>>t;


while(t--)
{
solve();
} 


return 0;
}

Measured memory_bytes: 3656
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define double long double
#define rep(i,n) for(int i=0;i<n;i++)
#define mod 1000000007 // 10^9+7
#define INF 99999999999 //10^12-1
#define dev 998244353 //tenka1
#define P pair<int,int>
#define prique priority_queue
int n,a,b;
int p[110];
int cnt[3];
signed main(){
    cin>>n>>a>>b;
    rep(i,n){
        cin>>p[i];
        if(p[i]<=a)cnt[0]++;
        else if(p[i]<=b)cnt[1]++;
        else cnt[2]++;
    }
    sort(cnt,cnt+3);
    cout<<cnt[0]<<endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>

using namespace std;

int main() {
    int a,b,k;
    cin >> a >> b >> k;
    vector<int> ans;
    for (int i=1; i<10000; i++) {
        if (a%i == 0 && b%i == 0) ans.push_back(i);
    }

    cout << *(ans.end()-k) << endl;
}


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

int main() {
  int N, L;
  cin >> N >> L;

  string s[N];
  for (int i = 0; i < N; i++) cin >> s[i];

  sort(s, s + N);

  string min_string = "";
  for (int i = 0; i < N; i++) min_string += s[i];

  cout << min_string << endl;
}


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

#include<complex>

using ld=long double;
const ld EPS=1e-15;


ld solve(ld w,ld h,int n,vector<ld> x,vector<ld> y){
    vector<ld> event;
    event.push_back(h);
    for(int i=0;i<2*n;i++){
        for(int j=0;j<i;j++){
            if(abs(x[i]-x[j])<EPS) continue;
            ld b=(y[i]-y[j])/(x[i]-x[j])*(-x[i])+y[i];
            if(0<b && b<h){
                event.push_back(b);
            }
        }
    }
    for(int i=0;i<2*n;i++){
        if(abs(x[i]-w)>=EPS){
            ld b=(y[i]-h)/(x[i]-w)*(-x[i])+y[i];
            if(0<b && b<h){
                event.push_back(b);
            }
        }
        if(abs(x[i]-w)>=EPS){
            ld b=(y[i]-0)/(x[i]-w)*(-x[i])+y[i];
            if(0<b && b<h){
                event.push_back(b);
            }

        }
    }
    sort(event.begin(),event.end());
    
    
    
    auto f=[&](ld b){
        const ld INF=1e9;
        vector<ld> xy(2*n);
        for(int i=0;i<2*n;i++){
            if(x[i]==0){
                if(y[i]>b){
                    xy[i]=INF;
                }
                else if(y[i]<b){
                    xy[i]=-INF;
                }
                else{
                    return ld(0);
                }
            }
            else{
                xy[i]=(y[i]-b)/x[i];
            }
        }
        sort(xy.begin(),xy.end());
        ld lbr=max(ld(0),b+xy[n-1]*w);
        ld ubr=min(h,b+xy[n]*w);
        return max(ld(0),ubr-lbr);
    };

    ld v=f(0+EPS);
    ld b=0;
    ld res=0;
    for(int i=0;i<event.size();i++){
        ld nv=f(event[i]-EPS);
        res+=(event[i]-b)*(nv+v)/2;
        nv=f(event[i]+EPS);
        v=nv;
        b=event[i];
    }
    return res/h/h;
}
int main(){
    ld w,h;
    int n;
    cout<<fixed<<setprecision(11);
    while(cin>>w>>h>>n,n){
        vector<ld> x(2*n),y(2*n);
        for(int i=0;i<2*n;i++) cin>>x[i]>>y[i];
        cout<<solve(w,h,n,x,y)<<endl;
    }
    return 0;
}


Measured memory_bytes: 3520
import java.math.BigInteger;
import java.util.*;


public class Main {
	
	
	private void doit(){
		Scanner sc = new Scanner(System.in);
		while(sc.hasNext()){
			int n = sc.nextInt();
			int [] dp = new int[n+1];
			Arrays.fill(dp, 1 << 29);
			dp[0] = 0;
			for(int i = 0; i <= n; i++){
				if(i + 1 > n)continue;
				dp[i+1] = Math.min(dp[i+1], dp[i] + 1);
				
				int now = 6;
				while(i + now <= n){
					dp[i + now] = Math.min(dp[i + now], dp[i] + 1);
					now = now * 6;
				}
				
				now = 9;
				while(i + now <= n){
					dp[i + now] = Math.min(dp[i + now], dp[i] + 1);
					now = now * 9;
				}
			}
			System.out.println(dp[n]);
		}
	}
	
	private long calc(long n, long m, long l){
		long sum = 1;
		for(long i = n; i > m; i--){
			sum *= i;
		}
		for(long i = 2; i <= l; i++){
			sum /= i;
		}
		return sum;
	}

	private void debug(Object... o) {
		System.out.println("debug = " + Arrays.deepToString(o));
	}

	public static void main(String[] args) {
		new Main().doit();
	}

}


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

#define int long long
#define pb push_back
#define mp make_pair
#define f(i,a,n) for(int i=a ; i<n ; i++)
#define all(c) (c).begin(),(c).end()
#define F first
#define S second
#define fast ios:: sync_with_stdio(false),cin.tie(nullptr);
typedef long double ld;
typedef vector<int> vi;
typedef pair<int,int> pii;
typedef pair<pii,int> ppi;
typedef vector<pii> vpi;

const int inf = 1e9;
const int inf64 = 1e18;
const int MOD = inf + 7;
const ld PI = acos(-1.0);

int32_t main(){
	fast;
	int h,n;
	cin >> h >> n;
	int sum = 0;
	while(n--)
	{
		int a;
		cin >> a;
		sum += a;
	}
	
	cout << (sum >= h ? "Yes" : "No");
	
}



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

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


Measured memory_bytes: 256
import java.util.Scanner;

public class Main{
    public static void main(String[] args){
	Scanner sc = new Scanner(System.in);
	int D = sc.nextInt();
	int N = sc.nextInt();
        if(N<=99){
	    System.out.print(N * (int)Math.pow(100,D));
	}else if(N==100){
	    System.out.print(101 * (int)Math.pow(100,D));
	}
    }
}


Measured memory_bytes: 23764
#include <iostream>
#include <vector>

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

using namespace std;

int main () {
    int N;
  	cin >> N;
    vector <int> A(N);
  	vector <int> B(N);
    vector <int> C(N-1);
    
    rep(i, N) cin >> A[i];
    rep(i, N) cin >> B[i];
  	rep(i, N-1) cin >> C[i];
  	
  	int ans = 0;
  	rep(i, N) ans += B[i];
  	rep(i, N-1) {
      	if ((A[i] + 1) == A[i + 1]) {
      		ans += C[A[i]-1];
        }
    }

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

Measured memory_bytes: 256
import math
from functools import reduce


def gcd_list(l):
    return reduce(math.gcd, l)


def solve():
    N, X = map(int, input().split())
    x = map(int, input().split())
    xX = [abs(X - i) for i in x]
    print(gcd_list(xX))


if __name__ == '__main__':
    solve()


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

int main () {
    int n,k;
    cin >> n >> k;
    map<int,int> mp;
    for (int i=0;i<k;i++) {
        int d;
        cin >> d;
        for (int j=0;j<d;j++) {
            int a;
            cin >> a;
            mp[a] = j;
        }
    }
    cout << n-mp.size() << endl;
}

Measured memory_bytes: 3636
#include <stdio.h>
#define MAX 100000
int main(void)
{
    int n;
    int i;
    int p[MAX + 1];
    int tmp;
    int min = 0;

    scanf("%d", &n);
    for (i = 1; i <= n; i++) {
        scanf("%u", &p[i]);
    }
    for (i = 1; i < n; i++) {
        if (p[i] == i) {
            tmp = p[i];
            p[i] = p[i + 1];
            p[i + 1] = tmp;
            min++;
        }
    }
    if (p[n] == n) {
        min++;
    }
    printf("%u\n", min);
    return 0;
}

Measured memory_bytes: 512
import sys
read = sys.stdin.read
readlines = sys.stdin.readlines
def main():
    # 「素数の乗数」かつ「Nを割り切れる」数Zをなるべく多く選ぶ

    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

    n = int(input())
    if n == 1:
        print(0)
        sys.exit()
    pfactors = factorization(n)
    r = 0
    for pfe in pfactors:
        pfe1 = pfe[1]
        t1 = 1
        while pfe1:
            if pfe1 >= t1:
                r += 1
                pfe1 -= t1
                t1 += 1
            else:
                break
    print(r)

if __name__ == '__main__':
    main()

Measured memory_bytes: 9384
#include <iostream>
#include <cmath>
#include <cstdio>
using namespace std;

int main() {
    int n;
    cin >> n;
    while(n--) {
        double x1, x2, x3, y1, y2, y3;
        cin >> x1 >> y1 >> x2 >> y2 >> x3 >> y3;
        double a1, a2, b1, b2, c1, c2,x, y, r;
        a1 = 2*(x2-x1);
        b1 = 2*(y2-y1);
        c1 = x1*x1-x2*x2+y1*y1-y2*y2;
        a2 = 2*(x3-x1);
        b2 = 2*(y3-y1);
        c2 = x1*x1-x3*x3+y1*y1-y3*y3;
        
        x = (double)(b1*c2-b2*c1)/(double)(a1*b2-a2*b1);
        y = (double)(c1*a2-c2*a1)/(double)(a1*b2-a2*b1);
        r = (double)sqrt((x-x1)*(x-x1)+(y-y1)*(y-y1));
        
        printf("%.3f %.3f %.3f\n",x,y,r);
    }
    return 0;
}

Measured memory_bytes: 1244
n=int(input())
A=list(map(int,input().split()))
  
keta=[0]*60
for i in range(n):
  tar=A[i]
  ind=0
  while tar>0:
    if tar&1==1:
      keta[ind]+=1
    tar>>=1
    ind+=1

pair=[0]*60
for i in range(len(keta)):
  pair[i]=keta[i]*(len(A)-keta[i])
  
ans=0
mul=1
DIV=10**9+7
for i in range(len(pair)):
  ans+=pair[i]*mul
  ans%=DIV
  mul*=2
print(ans)


Measured memory_bytes: 125624
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.IOException;
import java.util.Set;
import java.util.HashSet;

public class Main {
  public static void main(String[] args) throws IOException {
    BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
    String[] str = in.readLine().split(" ");
    Set<String> st = new HashSet<String>();
    st.add(str[0]);
    st.add(str[1]);
    st.add(str[2]);
    System.out.println(st.size());
  }
}

Measured memory_bytes: 32720
#include <iostream>
#include <fstream>
#include <vector>
#include <cstring>
#include <algorithm> // sort
#include <map>
#include <math.h>
//#include <bitset/stdc++.h>

#define REP(i, n) for (long long i = 0; i < (n); i++) 
typedef long long ll;
static const ll MOD = 998244353;
static const ll INF = 1000000000000000000LL;
using namespace std;



int main()
{
    ll N,A,B,res;
    cin >> N >> A >> B;

    //卓の差が奇数の場合

    if((B-A) % 2 == 0)
    {
        res = (B-A) / 2;
    }
    else
    {
        res = min(N+1-B, A);
        res += (B-A) / 2;
    }

    cout << res << endl;
}

Measured memory_bytes: 256
import java.io.File;
import java.io.IOException;
import java.util.ArrayDeque;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Comparator;
import java.util.Deque;
import java.util.List;
import java.util.Scanner;

public class Main {
 
	public static void main(String[] args) throws IOException {
		//File file = new File("input.txt");
		//Scanner in = new Scanner(file);
		
		Scanner in = new Scanner(System.in);
		
		int AB = in.nextInt() + in.nextInt();
		System.out.println((AB < 10) ? AB : "error");
	}
}


Measured memory_bytes: 22996
#include<bits/stdc++.h>
#define x first
#define y second
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
const ll MAX_N=20;
const ll MAX_K=1<<20;
const ll MOD=1000000007;
pii dp[MAX_K][3];
int n,a[MAX_K],ans;
int main(ll argc, char** argv)
{
    scanf("%d",&n);
    for(int i=0;i<(1<<n);i++) scanf("%d",&a[i]),dp[i][0]=make_pair(-a[i],i),dp[i][1].second=-1,dp[i][2].second=-1;
    for(int i=0;i<(1<<n);i++){
        for(int j=0;j<n;j++) if(i&(1<<j)) {
            for(int k=0;k<2;k++) {
                int idx=dp[i^(1<<j)][k].second;
                if(idx!=dp[i][0].second&&idx!=dp[i][1].second){
                    dp[i][2]=make_pair(-a[idx],idx);
                    sort(dp[i],dp[i]+3);
                }
            }
        }
    }
    //for(int i=1;i<(1<<n);i++) printf("%d %d\n",-dp[i][0].first,-dp[i][1].first);
    for(int i=1;i<(1<<n);i++){
        ans=max(ans,-dp[i][0].first-dp[i][1].first);
        printf("%d\n",ans);
    }
    return 0;
}


Measured memory_bytes: 12288
n = list(map(int, list(input())))
ln = len(n)
ans = 0
for i in range(-1, -ln, -1):
    if n[i] == 10:
        n[i-1] += 1
        continue
    elif n[i] < 5:
        ans += n[i]
    elif n[i] > 5:
        ans += 10 - n[i]
        n[i-1] += 1
    else:
        if n[i-1] < 5:
            ans += 5
        else:
            ans += 5
            n[i-1] += 1
if n[0] == 10:
    ans += 1
elif n[0] <= 5:
    ans += n[0]
else:
    ans += 11 - n[0]

print(ans)

Measured memory_bytes: 141632