akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;

int main() {
  vector<vector<int>> a(5, vector<int>(2));
  for (int i = 0; i < 5; i++) {
    cin >> a.at(i).at(1);
    a.at(i).at(0) = a.at(i).at(1) % 10;
    if (a.at(i).at(0) == 0) a.at(i).at(0) = 10;
  }
  sort(a.begin(), a.end());
  int sum = 0;
  sum = a.at(0).at(1);
  for (int i = 1; i < 5; i++) {
    if (a.at(i).at(1) % 10 != 0) a.at(i).at(1) = 10 * (a.at(i).at(1) / 10 + 1);
    sum += a.at(i).at(1);
  }
  cout << sum << endl;
}

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

using namespace std;

int a[111][111];
int b[1111];

int main() {
	int n, m;
	cin >> n >> m;
	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) {
		cin >> b[i];
	}
	for (int i = 0; i < n; ++i) {
		int c = 0;
		for (int j = 0; j < m; ++j) {
			c += a[i][j]*b[j];
		}
		cout << c << '\n';
	}
}


Measured memory_bytes: 3104
#include<bits/stdc++.h>
using namespace std;
int main() {
    int W,H,N;
    cin>>W>>H>>N;
    int x[N],y[N],a[N];
    char p[W][H];
    for(int i=0;i<N;i++){
        cin>>x[i]>>y[i]>>a[i];
    }
    for(int k=0;k<W;k++){
        for(int t=0;t<H;t++){
            p[k][t]='w';
        }
    }
    for(int i=0;i<N;i++){
        if(a[i]==1){
            for(int k=0;k<x[i];k++){
                for(int t=0;t<H;t++){
                    p[k][t]='b';
                }
            }
        }else if(a[i]==2){
            for(int k=x[i];k<W;k++){
                for(int t=0;t<H;t++){
                    p[k][t]='b';
                }
            }
        }else if(a[i]==3){
            for(int k=0;k<W;k++){
                for(int t=0;t<y[i];t++){
                    p[k][t]='b';
                }
            }
        }else{
            for(int k=0;k<W;k++){
                for(int t=y[i];t<H;t++){
                    p[k][t]='b';
                }
            }
        }
    }
    int count=0;
    for(int k=0;k<W;k++){
        for(int t=0;t<H;t++){
            if(p[k][t]=='w'){
                count++;
            }
        }
    }
    cout<<count<<endl;
    return 0;
}


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

int main()
{
	ll n;
	cin >> n;
	ll ans = 0;
	for (int i = 1; i <= n; i++) {
		if (i % 3 == 0 && i % 5 == 0) continue;
		else if (i % 3 == 0) continue;
		else if (i % 5 == 0) continue;
		else ans += i;
	}
	cout << ans << endl;
}

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

using namespace std;
typedef long long LL;


int main() {
  int N;
  cin >> N;
  int minim = N;
  int cnt = 0;
  for(int i=0; i<N; i++) {
    int k;
    cin >> k;
    if(minim >= k)cnt++;
    minim = min(minim, k);

  }
  cout << cnt << endl;

  return 0;
}

Measured memory_bytes: 256
#include<queue>
#include<iostream>
#include<cstdio>
#include<cmath>
#include<cstring>
#include<cstdlib>
#include<set>
#include<utility>
#include<algorithm>

using namespace std;

#define REP(i,n) for(int i = 0;i < n;i++)
#define MK make_pair
	
int dp[51][51][51][51];
char mapl[60][60],mapr[60][60];
int dxl[] = {1,0,-1,0},dyl[] = {0,1,0,-1};
int dxr[] = {-1,0,1,0},dyr[] = {0,1,0,-1};

struct s
{
	int lx,ly,rx,ry;
	s(int a,int b ,int c,int d):ly(a),lx(b),ry(c),rx(d){};
};


int main()
{
	int w,h;
	while(cin >> w >> h,w|h)
	{
		REP(i,h)
		{
			scanf("%s %s",mapl[i],mapr[i]);
		}
		
		int ly,lx,ry,rx;
		REP(i,h)REP(j,w)
		{
			if(mapl[i][j] == 'L'){ly = i,lx = j; mapl[i][j] = '.';}
			if(mapr[i][j] == 'R'){ry = i,rx = j; mapr[i][j] = '.';}
		}
		memset(dp,0,sizeof(dp));
		
		queue
 q;
		
		q.push(s(ly,lx,ry,rx));
		dp[ly][lx][ry][rx] = 1;
		
		while(!q.empty())
		{
			s now = q.front();q.pop();
			REP(i,4)
			{
				int cly,clx,cry,crx;
				cly = now.ly + dyl[i];
				clx = now.lx + dxl[i];
				cry = now.ry + dyr[i];
				crx = now.rx + dxr[i];
				if(cly < 0 || cly >= h || clx < 0 || clx >= w || mapl[cly][clx] == '#')
				{
					cly = now.ly;clx = now.lx;
				}
				if(cry < 0 || cry >= h || crx < 0 || crx >= w || mapr[cry][crx] == '#')
				{
					cry = now.ry;crx = now.rx;
				}
				
				if(mapl[cly][clx] == '%' && mapr[cry][crx] == '%')
				{
					cout << "Yes" << endl; goto NEXT;
				}
				
				if(dp[cly][clx][cry][crx] == 1)continue;
				if(mapl[cly][clx] == '%' || mapr[cry][crx] == '%')continue;
				
				q.push(s(cly,clx,cry,crx));
				dp[cly][clx][cry][crx] = 1;
			}
			
		}
		
		cout << "No" << endl;
		
		NEXT:;
	}
	
	return 0;
	
}

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

int main() {
	
	long long int n,sum=0; cin>>n;
	int a[n+1],b[n];
	for(int i=0;i<n+1;i++) cin>>a[i];
	for(int i=0;i<n;i++) {
		cin>>b[i];
	}
	for(int i=0;i<n;i++) {
		if(a[i]>=b[i]) { sum+=b[i]; }
		else {
			b[i]-=a[i];
			sum+=a[i];
			if(a[i+1]>=b[i])  { 
				a[i+1]-=b[i]; sum+=b[i];
			}
			else {
				sum+=a[i+1]; a[i+1]=0;
			}	
		}
	}
	cout<<sum<<endl;
}

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

using namespace std;

int main() {
	string a, b;
	cin >> a;
	cin >> b;
	sort(a.begin(), a.end());
	sort(b.begin(), b.end());
	reverse(b.begin(), b.end());

	if (a < b) cout << "Yes" << "\n";
	else cout << "No" << "\n";
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
using namespace std;
int main(){
	int n,a[5];
	string b;
	cin>>n;
	int out;
	for(int i=0;i<n;i++){
		out=0;
		for(int i=0;i<5;i++)
		a[i]=0;
		while(true){
			cin>>b;
			a[0]=1;
			if(b=="HIT"){
				a[4]+=a[3];
				a[3]=a[2];
				a[2]=a[1];
				a[1]=1;
		    }
			if(b=="HOMERUN"){
				a[4]+=a[3]+a[2]+a[1]+1;
				a[3]=0;
				a[2]=0;
				a[1]=0;
			}
			if(b=="OUT"){
				out++;
				if(out==3)
					break;
			}
		}
		cout<<a[4]<<endl;
	}
	return 0;
}

Measured memory_bytes: 1208
$<.readlines.map {|l| l.chomp.split}.each do |data|
  result = 0
  stack = []
  while (x = data.shift)
    if %w(+ - * /).include?(x)
      a, b = stack.pop, stack.pop
      stack << eval("#{b}.to_f #{x} #{a}")
    else
      stack << x
    end
  end
  printf "%.6f\n", stack.first
end


Measured memory_bytes: 9004
#include <bits/stdc++.h>
using namespace std;
template <typename T> void read(T &t) {
	t=0; char ch=getchar(); int f=1;
	while (ch<'0'||ch>'9') { if (ch=='-') f=-1; ch=getchar(); }
	do { (t*=10)+=ch-'0'; ch=getchar(); } while ('0'<=ch&&ch<='9'); t*=f;
}
typedef long long ll;
const int mod=(1e9)+7;
const int maxn=610;
int n,a[maxn],cnt,d[maxn],tot;
bool mk[maxn],mk2[maxn],ex[maxn];
int jc[maxn],ans;
int dp[maxn][maxn][maxn];
void update(int &x,int y) {
	x+=y; if (x>=mod) x-=mod;
}
int main() {
	//freopen("1.txt","r",stdin);
	read(n); n*=2;
	jc[0]=1;
	for (int i=1;i<=n;i++) read(a[i]),jc[i]=(ll)jc[i-1]*i%mod;
	for (int i=1;i<=n;i+=2) {
		if (a[i]==-1&&a[i+1]==-1) cnt++;
		else if (a[i]!=-1&&a[i+1]!=-1) ex[a[i]]=ex[a[i+1]]=1;
		else if (a[i]!=-1) mk2[a[i]]=1; else mk2[a[i+1]]=1;
	}
	for (int i=1;i<=n;i++)
		if (!ex[i]) d[++tot]=i;
	for (int i=1,x;i<=n;i++) {
		if (!mk2[i]) continue;
		x=lower_bound(d+1,d+tot+1,i)-d;
		mk[x]=1;
	}
	/*printf("%d\n",cnt);
	for (int i=1;i<=n;i++) if (mk[i]) printf("%d ",i);
	printf("\n%d\n",tot);*/
	dp[tot+1][0][0]=1;
	for (int i=tot+1;i>=1;i--)
	for (int j=0;j<=tot;j++)
	for (int k=0;j+k<=tot;k++) {
		if (!dp[i][j][k]) continue;
	//	printf("%d %d %d %d\n",i,j,k,dp[i][j][k]);
		if (mk[i-1]) {
			update(dp[i-1][j+1][k],dp[i][j][k]);
			if (k) update(dp[i-1][j][k-1],dp[i][j][k]);
		} else {
			update(dp[i-1][j][k+1],dp[i][j][k]);
			if (j) update(dp[i-1][j-1][k],(ll)dp[i][j][k]*j%mod);
			if (k) update(dp[i-1][j][k-1],dp[i][j][k]);
		}
	}
	ans=(ll)jc[cnt]*dp[1][0][0]%mod;
	printf("%lld\n",ans);
	return 0;
}
/*
  0. Enough array size? Enough array size? Enough array size? Interger overflow?
  
  1. Think TWICE, Code ONCE!
  Are there any counterexamples to your algo?
    
  2. Be careful about the BOUNDARIES!
  N=1? P=1? Something about 0?
    
  3. Do not make STUPID MISTAKES!
  Time complexity? Memory usage? Precision error?
*/

Measured memory_bytes: 873984
#include <bits/stdc++.h>
#define X first
#define Y second
using namespace std;

typedef long long ll;
typedef pair<int, int> pii;

const ll Q = (ll)(1e9) + 7;
const int MAXR = 63245;
const int MAXK = 101;

ll len[MAXR];
ll ans[MAXK][MAXR];

int main() {
	ios_base::sync_with_stdio(0);

	int N, K;
	cin >> N >> K;

	int R = floor(sqrt(N));

	for(int r = 1; r <= R; r++) {
		len[r] = 1;
		len[2*R+1-r] = N/r - (r < R ? N/(r+1) : R);
		ans[0][r] = 1;
		ans[0][R+r] = 1;
	}

	for(int k = 1; k <= K; k++) {
		for(int r = 1; r <= 2*R; r++) {
			ll add = ans[k-1][2*R+1-r] * len[r];
			ans[k][r] += (ans[k][r-1] + add) % Q;
		}
	}

	cout << ans[K][2*R] << '\n';
	return 0;
}

Measured memory_bytes: 50688
#include <iostream>
#include <fstream>
#include <vector>
#include <set>
#include <algorithm>
using namespace std;
const int nmax=200005;
const long long mod=1000*1000*1000+7;
vector < pair<int,int> > l[nmax];
set< pair<int,int> > s;
set< pair<int,int> >::iterator it,it1;
vector<int> ad[nmax];
long long part,ans;
long long fact[nmax],inv[nmax];
int viz[nmax],c[nmax],col[nmax],ap[nmax];
int nr,n,X,Y,i,w,j;
long long expo(long long A,int B)
{
    long long p2=A,ret=1;
    for(int p=0;p<=30;p++)
    {
        if(((1<<p)&B))
          ret=(1LL*ret*p2)%mod;
        p2=(1LL*p2*p2)%mod;
    }
    return ret;
}
void prc()
{
    fact[0]=1;
    for(long long i=1;i<=n;i++)
      fact[i]=(1LL*fact[i-1]*i)%mod;
    inv[n]=expo(fact[n],mod-2);
    for(long long i=n-1;i>=0;i--)
        inv[i]=(1LL*inv[i+1]*(i+1))%mod;

}
void add(int x,int y)
{
   ad[x].push_back(y);
   ad[y].push_back(x);
}
void dfs(int x)
{
    viz[x]=1;c[++nr]=col[x];
    part=(1LL*part*fact[ap[col[x]]])%mod;
    ap[col[x]]++;
    part=(1LL*part*inv[ap[col[x]]])%mod;
    for(int i=0;i<ad[x].size();i++)
        if(!viz[ad[x][i]])
           dfs(ad[x][i]);
}
int main()
{
   // freopen("data.in","r",stdin);
    ios_base::sync_with_stdio(false);
    cin>>n>>X>>Y;
    prc();
    for(i=1;i<=n;i++)
    {
        cin>>col[i]>>w;
        l[col[i]].push_back({w,i});
    }
    for(i=1;i<=n;i++)
    {
        sort(l[i].begin(),l[i].end());
        for(j=0;j<l[i].size();j++)
        {
            if(l[i][j].first+l[i][0].first<=X)
            {
                add(l[i][j].second,l[i][0].second);
            }
            for(it=s.begin();it!=s.end()&&l[i][j].first+(*it).first<=Y;)
            {
                it1=it;it1++;
                add((*it).second,l[i][j].second);
                if(it!=s.begin())
                    s.erase(it);
                it=it1;
            }
        }
        for(j=0;j<l[i].size();j++)
            s.insert(l[i][j]);
    }
    ans=1;
    for(int i=1;i<=n;i++)
        if(!viz[i])
    {
        part=1;nr=0;
        dfs(i);
        for(int j=1;j<=nr;j++)
            ap[c[j]]=0;
        part=(1LL*part*fact[nr])%mod;
        ans=(1LL*ans*part)%mod;
    }
    cout<<ans;
    return 0;
}

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

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int n=0,w=0;
    cin>>n>>w;
    long long int t[n+1][w+1]={0};
    int weight_array[n]={0};
    int value_array[n]={0};
    for(int i=0;i<n;i++){
        cin>>weight_array[i]>>value_array[i];
    }
    
    for(int i=0;i<n+1;i++)
        {for(int j=0;j<w+1;j++)
            {if(i==0||j==0)
                t[i][j]=0;
                
            }}

for(int i=1;i<n+1;i++){
    for(int j=1;j<w+1;j++){
        if(weight_array[i-1]<=j)
            t[i][j]=max(value_array[i-1]+t[i-1][j-weight_array[i-1]],t[i-1][j]);
        else
            t[i][j]=t[i-1][j];
    }
}
    
cout<<t[n][w];

    return 0;
}


Measured memory_bytes: 79232
#include <bits/stdc++.h>
#define REP(i, s, n) for (int i = s; i < (int)(n); i++)
#define ALL(a) a.begin(), a.end()
#define MOD 1000000007
using namespace std;
using ll = long long;
class UnionFindTree {
   public:
    vector<int> parent;
    vector<int> siz;

    UnionFindTree(int n) {
        siz.resize(n, 1);
        parent.resize(n);
        for (int i = 0; i < n; i++) {
            parent[i] = i;
        }
    }

    int root(int x) {
        if (parent[x] == x) return x;
        return parent[x] = root(parent[x]);
    }

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

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

    int size(int x) {
        return siz[root(x)];
    }
};
int main() {
    int N, M; cin >> N >> M;
    UnionFindTree uft(N);
    REP(i, 0, M) {
        int a, b; cin >> a >> b;
        uft.unite(--a, --b);
    }

    set<int> s;
    REP(i, 0, N) s.insert(uft.root(i));
    cout << (int)s.size() - 1 << endl;
    return 0;
}

Measured memory_bytes: 7916
s=input()

def evenjudge(obj):
    if obj %2!=0:
        return 1
    else:
        return 2
def oddjudge(obj):
    if obj %2!=0:
        return 2
    else:
        return 1

lo=[i for i in range(0,110,2)]
le=[i for i in range(1,110,2)]

oeflag=evenjudge(len(s))
eoflag=oddjudge(len(s))
for j in lo:
    if s[j] == "L":
        print("No")
        exit(0)
    if j == len(s)-oeflag:
        break


for k in le:
    if len(s)==1:
        break
    if s[k] == "R":
        print("No")
        exit(0)
    if k == len(s)-eoflag:
        break


print("Yes")

Measured memory_bytes: 3064
#include<iostream>
#include<cstdio>
#include<algorithm>
using namespace std;
const int N=205;
int n,a[N],ans;
int main()
{
	scanf("%d",&n);
	for(int i=1;i<=2*n;i++)
		scanf("%d",&a[i]);
	sort(a+1,a+1+2*n);
	for(int i=1;i<=2*n;i+=2)
		ans+=a[i];
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 256
#include <iostream>

const int MOD = 1000000007;

using namespace std;
typedef long long ll;

ll dp[401][401];

int main(){
    int N, C;
    int A[400], B[400];
    cin >> N >> C;
    for(int i = 0; i < N; i++){
        cin >> A[i+1];
    }
    for(int i = 0; i < N; i++){
        cin >> B[i+1];
    }
    dp[0][0] = 1;
    for(int i = 1; i <= N; i++){
        for(int xi = A[i]; xi <= B[i]; xi++){
            ll tmp = dp[i-1][0];
            dp[i][0] += tmp;
            dp[i][0] %= MOD;
            for(int j = 1; j <= C; j++){
                tmp *= xi;
                tmp += dp[i-1][j];
                tmp %= MOD;
                dp[i][j] += tmp;
                dp[i][j] %= MOD;
            }
        }
    }
    cout << dp[N][C] << endl;
}

Measured memory_bytes: 1536
//Õâ¸öcÐ´³öÀ´µÄ³ÌÐòÎªÉ¶Ö»ÄÜ¹ýÒ»°ëÄØ
#include<iostream>
#include<cstdio>
using namespace std;
long long gcd(long long m,long long n){
	return m==0?n:gcd(n%m,m);
}
int gcd(int a,int b){
	return a==0?b:gcd(b%a,a);
}
long long lcm(long long a,long long b){
	return a/gcd(a,b)*b;            //Á½ÊýÏà³Ë³ýÒÔ×î´ó¹«±¶Êý 
}
int main()
{
	int a,b;
	while(~scanf("%d%d",&a,&b)){
		printf("%d ",gcd(a,b));
		printf("%lld\n",lcm(a,b));     //long longµÄÊä³ö¸ñÊ½·û£¬very important 
	}
	
	return 0;
 } 


Measured memory_bytes: 3128
#include <iostream>
#include <string>
#include <sstream>
#include <iomanip> 
#include <math.h>
#include <stdio.h>
#include <string.h>
#include <queue>
#include <stack>
#include <vector>
#include <map>
#include <set>
#include <functional>
#include <algorithm>
#include <unordered_map>
#include <unordered_set>
#include <bitset>

using namespace std;

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

	string s;
	cin >> s;

	bool ans = false;
	if ((s[0] != s[1]) || (s[1] != s[2]) || (s[0] != s[2])) ans = true;
	if (ans) cout << "Yes\n";
	else cout << "No\n";

	return 0;
}


Measured memory_bytes: 256
import std.stdio : readf, readln, writeln;
import std.string;
import std.array;
import std.conv;

void main() {
  int[] v;
  v = readln.split.to!(int[]);
  int H = v[0];
  int W = v[1];
  string[] s;
  for (int i=0; i<H; i++)
    s ~= readln.chomp;
  int[][] dw;
  int[][] dh;
  for (int i = 0; i < H; i++) {
    int[] cw;
    int count = 0;
    for (int j = 0; j < W; j++) {
      if (s[i][j] == '#') {
          cw ~= 0;
      }
      else if (j == 0 || s[i][j - 1] == '#') {
        count = 0;
        for (int k = j; k < W; k++) {
          if (s[i][k] == '.') {
            count++;
          }
          else {
            break;
          }
        }
        cw ~= count;
      }
      else {
        cw ~= count;
      }
    }
    dw ~= cw;
  }
  for (int j = 0; j < W; j++) {
    int[] ch;
    int count = 0;
    for (int i = 0; i < H; i++) {
      if (s[i][j] == '#') {
        ch ~= 0;
      }
      else if (i == 0 || s[i - 1][j] == '#') {
        count = 0;
        for (int k = i; k < H; k++) {
          if (s[k][j] == '.') {
            count++;
          }
          else {
            break;
          }
        }
        ch ~= count;
      }
      else {
        ch ~= count;
      }
    }
    dh ~= ch;
  }
  int max = 0;
  for (int i = 0; i < H; i++) {
    for (int j = 0; j < W; j++) {
      int sum = dw[i][j] + dh[j][i];
      if (max < sum) {
        max = sum;
      }
    }
  }
  writeln(max - 1);
}


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

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



Measured memory_bytes: 3092
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <vector>
#include <sstream>
#include <cmath>
#include <queue>

using namespace std;

int main(){
	
	int w;
	
	while(true){
		cin >> w;
		if(w < 0){
			break;
		}
		
		int cost = 0;
		
		if(w <= 10){
			cost = 1150;
		}else if(w <= 20){
			cost = 1150 + 125 * (w - 10);
		}else if(w <= 30){
			cost = 1150 + 125 * 10 + 140 * (w - 20);
		}else{
			cost = 1150 + 125 * 10 + 140 * 10 + 160 * (w - 30);
		}
		
		cout << 4280 - cost << endl;
		
	}
	
	return 0;
}

Measured memory_bytes: 3076
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#define ll long long
#define rep(i,l,r)for(ll i=(l);i<(r);i++)
#define repp(i,l,r,k)for(ll i=(l);i<(r);i+=(k))
#define INF ((1LL<<62)-(1LL<<31))
#define max(p,q)((p)>(q)?(p):(q))
#define min(p,q)((p)<(q)?(p):(q))
#define bit(n,m)(((n)>>(m))&1)
int upll(const void*a, const void*b){return*(ll*)a<*(ll*)b?-1:*(ll*)a>*(ll*)b?1:0;}
int downll(const void*a, const void*b){return*(ll*)a<*(ll*)b?1:*(ll*)a>*(ll*)b?-1:0;}
void sortup(ll*a,int n){qsort(a,n,sizeof(ll),upll);}
void sortdown(ll*a,int n){qsort(a,n,sizeof(ll),downll);}
ll pom(ll a,ll n,int m){ll x=1;for(a%=m;n;n/=2)n&1?x=x*a%m:0,a=a*a%m;return x;}
//#define MOD 998244353
#define MOD 1000000007
#define invp(a,p)pom(a,p-2,p)

int a[]={
	1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51
};

int main(){
	ll n;
	scanf("%lld",&n);
	printf("%lld",a[n-1]);
}

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

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

  int n;
  cin >> n;
  vector<int> p(n);
  rep(i, n) {
    cin >> p[i];
    --p[i];
  }

  vector<int> index(n);
  rep(i, n) { index[p[i]] = i; }

  set<int> s;
  ll ans = 0;
  for (int x = n - 1; x >= 0; --x) {
    int i = index[x];
    ll c = 0;
    {
      s.insert(index[x]);
      vector<int> l(2, -1);
      vector<int> r(2, n);
      {
        auto it = s.find(i);
        rep(j, 2) {
          if (it == s.begin()) break;
          --it;
          l[j] = *it;
        }
      }
      {
        auto it = s.find(i);
        rep(j, 2) {
          it++;
          if (it == s.end()) break;
          r[j] = *it;
        }
      }
      vector<int> ls(2);
      ls[0] = i - l[0];
      ls[1] = l[0] - l[1];
      vector<int> rs(2);
      rs[0] = r[0] - i;
      rs[1] = r[1] - r[0];
      c = (ll)ls[0] * rs[1] + (ll)ls[1] * rs[0];
    }
    ans += c * (x+1);
  }
  cout << ans << endl;
  return 0;
}


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

int main(){
    ll N, x; cin >> N >> x;
    vector<int> A(N+1);
    A[0] = 0;
    for(int i = 1; i <= N; i++) cin >> A[i];
    ll res = 0;
    for(int i = 1; i <= N; i++){
        if(A[i-1] + A[i] > x){
            res += A[i-1] + A[i] - x;
            A[i] -= A[i-1] + A[i] - x;
        }
    }
    cout << res <<endl;
}

Measured memory_bytes: 640
#include <stdio.h>
int main(void){
    int second=0;
    int minute=0;
    int hour=0;

    scanf("%d\n",&second);
    
    while(second>=3600)
    {
        second=second-3600;
        hour++;
    }
    while(second>=60)
    {
        second=second-60;
        minute++;
    }
    
    printf("%d:%d:%d\n",hour,minute,second);
    
    return(0);
}



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

namespace arc084_a
{
    class Program
    {
        static void Main(string[] args)
        {
            int n = int.Parse(Console.ReadLine());
            int[] a = Console.ReadLine().Split().Select(int.Parse).ToArray(); Array.Sort(a);
            int[] b = Console.ReadLine().Split().Select(int.Parse).ToArray(); Array.Sort(b);
            int[] c = Console.ReadLine().Split().Select(int.Parse).ToArray(); Array.Sort(c);
            long[] acount = new long[n];
            int x;
            for (x = 0; x < n && a[x] < b[0]; x++) ;
            acount[0] = x;
            for (int i = 1; i < n; i++)
            {
                long j;
                for (j = acount[i - 1]; j < n && a[j] < b[i]; j++) ;
                acount[i] = j;
            }
            long[] ccount = new long[n];
            for (x = 0; x < n && b[0] < c[n - x - 1]; x++) ;
            ccount[0] = x;
            for (int i = 1; i < n; i++)
            {
                long j;
                for (j = ccount[i - 1]; j > 0 && b[i] >= c[n - j]; j--) ;
                ccount[i] = j;
            }
            long ret = 0;
            for (int i = 0; i < n; i++)
            {
                ret += acount[i] * ccount[i];
            }
            Console.WriteLine(ret);
        }
    }
}

Measured memory_bytes: 46192
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll N = 3e5 + 5;
const ll MOD = 1e9 + 7;
#define all(x) x.begin(),x.end()
#define pii pair<ll,ll>
#define pis pair<ll,string>
#define F first
#define S second
#define LCM(a,b) ((a*b)/__gcd(a,b))
#define inf 1e15
#define test ll cse;cin>>cse;for(ll _i=1;_i<=cse;_i++)
#define PI 3.14159265
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
const double EPS = 1E-9;
typedef vector< vector<double> > matrix;
typedef vector< vector<ll> > array_2D;
typedef pair<ll, pair<ll, ll> > ppi;
typedef vector<ll> vi;


ll ar[N];

int main() {


    ll n, k; cin >> n >> k;
    for(int i = 1; i <= n; i++) cin >> ar[i];


    ll ans[N];
    vector< ll > visited(N, -1);

    ll town = 1;
    ll itr = 0;

    while(visited[town] == -1) {

        visited[town] = itr;
        ans[itr++] = town;

        town = ar[town];
    }

    // cout << itr << "\n";
    // for(int i = 0; i < itr; i++) cout << ans[i] << " "; cout << "\n";

    ll offset = visited[town];

    if(k >= itr)
        cout << ans[ (k - offset) % (itr - offset) + offset] << "\n";
    else
        cout << ans[ k ] << "\n";

    return 0;
}

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

using namespace std;

int main(){
int H,W; cin >> H >> W;
  vector<string> S(H);
  for(int i = 0; i < H; i++){
    cin >> S[i];}
  
  vector<vector<int>> L(H,vector<int>(W,0));
  vector<vector<int>> R(H,vector<int>(W,0));
  vector<vector<int>> U(H,vector<int>(W,0));
  vector<vector<int>> D(H,vector<int>(W,0));
  
  for(int i = 0; i < H; i++){
    int cnt = 0;
    for(int j = 0; j < W; j++){
     if(S[i][j] == '#'){ cnt = 0;}
     else{ cnt++;}    
      L[i][j] = cnt;}
       } //(i,j)自身も数えていることに注意
  
  for(int i = 0; i < H; i++){
    int cnt = 0;
    for(int j = W - 1; j >= 0; j--){
      if(S[i][j] == '#'){ cnt = 0;}
      else{ cnt++;} 
      R[i][j] = cnt;}
  }
  
  for(int j = 0; j < W; j++){
    int cnt  = 0;
    for(int i = 0; i < H; i++){
      if(S[i][j] == '#'){ cnt = 0;}
      else{cnt++;}
      U[i][j] = cnt;}
  }
  
  for(int j = 0; j < W; j++){
    int cnt = 0;
    for(int i = H - 1; i >= 0; i--){
      if( S[i][j] == '#'){ cnt = 0;}
      else{ cnt++;}
      D[i][j] = cnt;}
  }
  
  int max_cnt  = 0;
  
  for(int i = 0; i < H; i++){
    for(int j = 0; j < W; j++){
      if(S[i][j] == '#'){ continue;}
      
     int M = L[i][j] + R[i][j] + U[i][j] + D[i][j] - 3;
      
      max_cnt = max( max_cnt, M);}}
    
    cout << max_cnt << endl;
    
    return 0;}
        
 
  
  
  


Measured memory_bytes: 67200
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.List;
import java.util.Scanner;
import java.util.stream.Collectors;

public class Main {
	public static void main(String[] args) {
		Scanner scanner = new Scanner(System.in);
		int N = scanner.nextInt();
		int K = scanner.nextInt();

		ArrayList<Integer> unused_numbers = new ArrayList<Integer>();
		for (int i = 0 ; i < K ; i++) {
			unused_numbers.add(scanner.nextInt());
		}

		ArrayList<Integer> usable_numbers = new ArrayList<Integer>();
		for (int i = 0 ; i < 10 ; i++) {
			if (!unused_numbers.contains(i)) {
				usable_numbers.add(i);
			}
		}

		// 使用可能な数字の中で、Nを超える最大の整数値を探す
		System.out.println(get_payment(usable_numbers, N));

		scanner.close();
	}

	private static int get_payment(ArrayList<Integer> usable_numbers, int N) {
		int tmp = N;
		List<Integer> n = Arrays.asList(String.valueOf(N).split("")).stream().map(value -> Integer.parseInt(value)).collect(Collectors.toList());
		Collections.reverse(n);


		for (int i = 0 ; i < n.size() ; i++) {
			if(!usable_numbers.contains(n.get(i))) {
				int next_min = get_next_min_number(usable_numbers, n.get(i));

				// 桁繰り上がりによって、支払い額を調整
				if(n.get(i) > next_min ) {
					tmp = (int)((tmp + Math.pow(10, i + 1)) - (n.get(i) - next_min)*(Math.pow(10, i)));
				} else {
					tmp = (int)(tmp + (next_min - n.get(i))*(Math.pow(10, i)));
				}

				// 上位桁が上がったため、下位桁を最小値に変更
				for (int j = 0 ; j < i ; j++) {
					tmp = (int) (tmp - (n.get(j) - usable_numbers.get(0))*Math.pow(10, j));
				}

				n = Arrays.asList(String.valueOf(tmp).split("")).stream().map(value -> Integer.parseInt(value)).collect(Collectors.toList());
				Collections.reverse(n);
			}
		}

		Collections.reverse(n);
		return Integer.parseInt(String.join("", n.stream().map(value -> String.valueOf(value)).collect(Collectors.toList())));
	}

	private static int get_next_min_number(ArrayList<Integer> usable_numbers, int number) {
		while(true) {
			number = (number + 1) % 10;
			if(usable_numbers.contains(number)) {
				return number;
			}
		}
	}
}


Measured memory_bytes: 27092
import java.util.*;

class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int[] H = new int[N];
		for (int i=0;i<N;i++) {
			H[i]=sc.nextInt();
		}

		int cnt=0;
		int h=0;
		for (int i=0;i<N;i++) {
			if (h<=H[i]) {
				h=H[i];
				cnt++;
			}
		}
		System.out.println(cnt);
	}
}

Measured memory_bytes: 21844
import java.util.List;

import java.util.ArrayList;
import java.util.Scanner;


/**
 * Created by liguoxiang on 2017/02/11.
 */
public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        // 整数の入力
        int a = sc.nextInt();
        // スペース区切りの整数の入力
        int b = sc.nextInt();
        sc.nextLine();
        List<String> strA=new ArrayList<>();
        List<String> strB=new ArrayList<>();

        for(int i=0;i<a;i++){
            strA.add(sc.nextLine());
        }


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

            strB.add(sc.nextLine().trim());
        }



        for(int i=0;i<a-b+1;i++){

            String aStr=strA.get(i);

            int index=0;
            if(aStr.contains(strB.get(0))){
                index=aStr.indexOf(strB.get(0));

                boolean isExist=true;
                for(int j=1;j<b;j++){
                    if(index==strA.get(i+j).indexOf(strB.get(j),index)){
                        continue;
                    }else{
                        isExist=false;
                        break;
                    }
                }


                if(isExist){
                    System.out.println("Yes");
                    return;
                }


            }

        }
        System.out.println("No");
    }
}

Measured memory_bytes: 22612
#include<iostream>
#include<cstdio>
#include<cstring>
#include<cmath>
#include<algorithm>
using namespace std;
typedef long long LL;
const int MAXN=1e5+5;
int tot,head[MAXN];
bool mark[MAXN];
int ans1,ans2;
int n;
int num;
int slit;
int father;

struct Edge
{
    int from,to;
    int next;
}e[MAXN*2];

void add(int u,int v)
{
    e[tot].from=u;
    e[tot].to=v;
    e[tot].next=head[u];
    head[u]=tot++;
}

bool dfs(int rt,int fa)
{
    for(int i=head[rt];i!=-1;i=e[i].next)
    {
        int to=e[i].to;
        if(to==fa) continue;
        if(to==n) return true;
        if(dfs(to,rt))
        {
            mark[to]=true;
            return true;
        }
    }
    return false;
}

int dfs2(int rt,int fa)
{
    for(int i=head[rt];i!=-1;i=e[i].next)
    {
        int to=e[i].to;
        if(to==fa) continue;
        if(!mark[to]) continue;
        else
        {
            num++;
            if(num==slit)
            {
                father=rt;
                return to;
            }
            else
                return dfs2(to,rt);
        }
    }
}

void dfs3(int rt,int fa)
{
    for(int i=head[rt];i!=-1;i=e[i].next)
    {
        int to=e[i].to;
        if(to==fa) continue;
        ans1++;
        dfs3(to,rt);
    }
}

void dfs4(int rt,int fa)
{
    for(int i=head[rt];i!=-1;i=e[i].next)
    {
        int to=e[i].to;
        if(to==fa) continue;
        ans2++;
        dfs4(to,rt);
    }
}

int main()
{
    //ios::sync_with_stdio(false);
    while(cin>>n)
    {
        memset(head,-1,sizeof(head));
        memset(mark,false,sizeof(mark));
        tot=0;
        int u,v;
        for(int i=1;i<=n-1;i++)
        {
            cin>>u>>v;
            add(u,v);add(v,u);
        }
        dfs(1,0);
        mark[1]=true;mark[n]=true;
        int cnt=0;
        for(int i=1;i<=n;i++)
        {
            if(mark[i])
            {
                cnt++;
                //cout<<i<<" ";
            }

        }
        //cout<<endl;
        if(cnt&1)
            slit=cnt/2+1;
        else slit=cnt/2;
        //cout<<"slit: "<<slit<<endl;
        num=1;
        int id=dfs2(1,0);
        //cout<<id<<endl;
        int child;
        for(int i=head[id];i!=-1;i=e[i].next)
        {
            int to=e[i].to;
            if(mark[to]&&to!=father)
                child=to;
        }
        //cout<<father<<" "<<id<<" "<<child<<endl;
        ans1=0;ans2=0;
        dfs3(id,child);
        dfs4(child,id);
        //cout<<ans1<<" "<<ans2<<endl;
        if(ans1>ans2)
            cout<<"Fennec"<<endl;
        else
            cout<<"Snuke"<<endl;
    }

    return 0;
}
/*
11
1 2
1 6
1 8
3 6
4 6
5 8
5 7
4 9
4 10
10 11
*/


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

int main()
{
	int A,B,C,D;
	cin>>A>>B>>C>>D;
	if (A*B>C*D)
	{
		cout<<A*B;
	}
	else if(C*D>A*B)
	{
		cout<<C*D;
	}
	else
	{
		cout<<A*B||C*D;
	}
	return 0;
}

Measured memory_bytes: 3144
#include<bits/stdc++.h>
#include<boost/variant.hpp>
using namespace std;
typedef long long ll;
typedef vector<boost::variant<bool, ll, int, string, double, char*, const char*>> any;
template<typename T> inline void pr(const vector<T> &xs){
	for(int i=0; i<xs.size()-1; i++) cout<<xs[i]<<" ";
	(xs.empty()?cout:(cout<<xs[xs.size()-1]))<<endl;
}
#ifdef DEBUG
#define debug(...) pr(any{__VA_ARGS__})
#define debugv(x) pr((x))
#else
#define debug(...)
#define debugv(x)
#endif

int main(){
	int N;
	ll K;
	cin >> N >> K;
	vector<ll> A(N);
	for(int i=0; i<N; i++) cin >> A[i];

	vector<ll> sum(N+1);
	for(int i=0; i<N; i++) sum[i+1] = (sum[i]+A[i])%K;
	vector<ll> x(N+1);
	for(int i=0; i<=N; i++) x[i] = (sum[i]-i%K+K)%K;
	debugv(x);

	map<ll, int> cnt;
	for(int i=0; i<min(K, (ll)N+1); i++) cnt[x[i]]++;

	ll ans = 0;
	for(int i=0; i<N; i++){
		cnt[x[i]]--;
		debug(i, cnt[x[i]]);
		ans += cnt[x[i]];
		if(i+K<=N) cnt[x[i+K]]++;
	}
	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 17408
import math
 
N = int(input())
A = [int(a) for a in input().split(" ")]
ave = sum(A) / N
can1 = math.floor(ave)
can2 = math.ceil(ave)
 
cost1 = sum([(a - can1) ** 2 for a in A])
cost2 = sum([(a - can2) ** 2 for a in A])
print(min([cost1, cost2]))

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

int main(int argc, char *argv[]) {
  ios::sync_with_stdio(false);
	cin.tie(nullptr);
	cout.tie(nullptr);

  string s;cin>>s;
  for(int i=0;i<3;i++){
    if(s[i]=='1'){
      cout<<9;
    }else{
      cout<<1;
    }
  }
  cout<<endl;

  return 0;
}


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

#define F first
#define S second
#define pb push_back
#define eb emplace_back
#define PI 3.14159265359
#define sz(c) (int)c.size()
#define len(c) (int)c.length()
#define hcf(a, b) __gcd(a, b)
#define all(c) c.begin(), c.end()
#define vint vector<int>
#define vll vector<ll>
#define vpint vector<pair<int, int>>
#define vpll vector<pair<ll, ll>>
#define fr(it, a, b) \
    for (int it = (a); it < (b); it++)
#define tr(con, it) \
    for (auto it = con.begin(); it != con.end(); it++)
#define present(con, ele) (con.find(ele) != con.end())
#define cpresent(con, ele) (find(all(con), ele) != con.end())
#define maximum(a, b, c) (a > b ? (a > c ? a : c) : (b > c ? b : c))
#define minimum(a, b, c) (a < b ? (a < c ? a : c) : (b < c ? b : c))
typedef long long ll;
typedef long double lf;
typedef unsigned long long lu;
const ll mod = 1e9 + 7;
int32_t main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    lf a, b;
    cin >> a >> b;
    ll ans = a * b;
    cout << ans << endl;
    return 0;
}

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

int hy[] = {0, 1, 0, -1};
int wx[] = {1, 0, -1, 0};

int H, W;

bool closed(int x, int y){
  bool flag = true;
  if(x<0 || W<=x)
    flag = false;
  if(y<0 || H<=y)
    flag = false;
  return flag;
}


int main(){
  cin >> H >> W;
  char s[H][W];
  rep(i, H)
    rep(j, W)
    cin >> s[i][j];
  //入力終了

  bool flag;
  rep(i, H){
    rep(j, W){
      //.は飛ばす
      if(s[i][j] == '.')
	continue;
      flag = false;
      //4方向の判定
      rep(k, 4){
	//近傍の点がマス目におさまっているか
	if(closed(j+wx[k], i+hy[k]) ){
	  if(s[i+hy[k] ][j+wx[k] ] == '#'){
	    flag = true;
	  }
	}
      } // k
  
      //孤立した#があれば終了
      if(!flag){
	cout << "No" << endl;
	return 0;
      }
    } //j
  } // i

  //上のループを抜ければOK
  cout << "Yes" << endl;

  return 0;
}


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

int n,l,a,cnt;

int main()
{
	scanf("%d %d",&n,&l);
	for(int i=1;i<=n;++i) {
		scanf("%d",&a);
		if(a>=l) cnt++;
	}
	printf("%d",cnt);
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define FOR(i, a, n) for (ll i = (ll)a; i < (ll)n; i++)
#define RFOR(i, a, n) for (ll i = (ll)n - 1; i >= (ll)a; i--)
#define rep(i, n) FOR(i, 0, n)
#define rrep(i, n) RFOR(i, 0, n)
#define ALL(v) v.begin(), v.end()
#define bra(first, second) '(' << first << ',' << second << ')'
//constexpr ll MOD = 1000000007;
constexpr ll MOD = 998244353;
ll INF = 1001001001001001001;
long double EPS = 1e-9;
long double PI = 3.141592653589793238;
template <typename T>
void remove(std::vector<T> &vector, unsigned int index)
{
   vector.erase(vector.begin() + index);
}

using Graph = vector<vector<pair<ll,ll>>>;

// MOD確認

ll N,X,M;
ll m[200010];
ll ind[200010];

int main(){
   cin >> N >> X >> M;
   m[0] = X;
   ll flag = 0;
   rep(i,2*M){
      m[i+1] = (m[i] * m[i]) % M;
      if(flag == 0 && m[i+1] == 0) flag = i + 1;
   }
   ll num = 0,sum = 0;
   ll l = 0,r = 0;
   rep(i,2*M) ind[i] = -1;
   rep(i,2*M){
      if(ind[m[i]] != -1){
         r = i;
         l = ind[m[i]];
         num = r - l;
         break;
      }
      ind[m[i]] = i;
   }
   FOR(i,l,r) sum += m[i];
   //cout << l << ' ' << r << endl;
   //cout << m[l] << ' ' << m[r] << endl;
   ll ans = 0;
   if(flag){
      rep(i,min(N,flag)){
         ans += m[i];
      }
      cout << ans << endl;
      return 0;
   }
   rep(i,min(l,N)) ans += m[i];
   rep(i,(N - l) % num) ans += m[i+l];

   ans += sum * ((N - l) / num);
   cout << ans << endl;
}

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

int main(void)
{
    int x,y,count = 0;
    cin >> x >> y;
    switch(x)
    {
        case 2:
        cout << "No" << endl;
        return 0;
        case 4:
        case 6:
        case 9:
        case 11:
        count++;
        break;
        default:
        count--;
    }
        switch(y)
    {
        case 2:
        cout << "No" << endl;
        return 0;
        case 4:
        case 6:
        case 9:
        case 11:
        count++;
        break;
        default:
        count--;
    }
    if(count == 2 || count == -2){cout << "Yes" <<endl;}
    else{cout << "No" << endl;}
    return 0;
}

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

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

using namespace std;

int main() {

	string s;
	int a = 0, b = 0, c = 0;
	cin >> s;
	REP(i, 3) {
		if (s[i] == 'a')
			a++;
		else if (s[i] == 'b')
			b++;
		else if (s[i] == 'c')
			c++;
	}

	if (a == 1 && b == 1 && c == 1)
		cout << "Yes" << endl;
	else
		cout << "No" << endl;

	return 0;
}


Measured memory_bytes: 256
#include<stdio.h>

int main(){
	
	int A,B,C;
	
	scanf("%d %d %d",&A,&B,&C);
	
	if(   ((A==B)&&(A!=C)) ||  ((B==C)&&(B!=A))  || ((C==A)&&(C!=B))  ){
		
		printf("Yes");
		
	}
	
	else{
		
		printf("No");
		
	}
	
return 0;

}

Measured memory_bytes: 128
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner scan=new Scanner(System.in);
		int x=scan.nextInt();
			int hanako=0,tarou=0;
			for(int i=0;i<x;i++) {
				String str1=scan.next();
				String str2=scan.next();
				if(str1.compareTo(str2)>0) {
					tarou +=3;
				}else if(str1.compareTo(str2)<0) {
					hanako +=3;
				}else {
					hanako +=1;
					tarou +=1;
				}
			}
			System.out.println(tarou+" "+hanako);
			scan.close();
		}
}


Measured memory_bytes: 29816
#include <iostream>
#include <cmath>
#include <vector>
using namespace std;
#define rep(i, n) for (int i = 0; i < (n); ++i)
using Graph = vector<vector<int>>;
using ll = long long;
using p = pair<int, int>;

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

    rep(i, n)
    {
        int x, y;
        cin >> x >> y;
        double di = sqrt(pow(x, 2) + pow(y, 2));
        if (di <= d)
        {
            ans++;
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 3672
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <string>
#include <stack>
#include <queue>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <cmath>

using namespace std;
#define PI 3.1415926535897932384626433832795
#define MOD (1000000007)
#define rep(i, n) for (int i = 0; i < (n); i++)
#define repc(i, s, n) for (int i = (s); i <= (n); i++)
#define rrep(i, n) for (int i = (n) - 1; i >= 0; i--)
#define rrepc(i, s, n) for (int i = (s); i >= (n); i--)
typedef long long ll;
typedef unsigned long long ull;

int digitSum(int num)
{
	int ret = 0;

	while (num > 0) {
		ret += num % 10;
		num /= 10;
	}

	return ret;
}

int main()
{
	int N, ans = 100000000;

	cin >> N;

	for (int A = 1; N - A >= 1; A++) {
		int B = N - A;
		int sum = 0;

		sum += digitSum(A);
		sum += digitSum(B);

		ans = min(ans, sum);
	}

	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 256
// Shift-JIS（シフトジス）

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

int gcd(int a, int b)
{
    if (a < b)
    {
        a ^= b;
        b ^= a;
        a ^= b;
    }

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

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

int main()
{
    int N, K;
    cin >> N >> K;
    int A;
    for (int i = 0; i < N; i++) cin >> A;
    cout << ((N - 1) + (K - 1 - 1)) / (K - 1) << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(n);i++)
typedef long long ll;
template<typename T>
void print(T x) {
    cout << x << endl;
}
bool cmp(const int &a, const int &b) {
    int x = a%10, y = b%10;
    if(x==0) return x < y;
    if(y==0) return y < x;
    return x > y;
}
int main(void) {
    vector<int> x(5);
    rep(i, 5) cin >> x[i];
    sort(x.begin(), x.end(), cmp);
    int sum = 0;
    rep(i, 4) {
        sum += (x[i]+9)/10 * 10;
    }sum += x[4];
    cout << sum;
}


Measured memory_bytes: 256
N, x = map(int, input().split())
a = list(map(int, input().split()))
a.sort()
cnt = 0
j = 0
for i in range(N):
  if (cnt + a[i]) > x:
    break
  cnt += a[i]
  j += 1
if j == len(a):
  if x != cnt:
    j -= 1
print(j)

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

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

#define pb push_back
#define rep(i, n) for(int i = 0; i < (n); i++)
#define FOR(i, a, n) for(int i = a; i < (n); i++)
#define mod (ll)(1e9+7)
#define int ll

__attribute__((constructor))
void initial() {
  cin.tie(0);
  ios::sync_with_stdio(false);
}

struct unionFind {
  vector<int> par;
  vector<int> sizes;

  unionFind (int n) : par(n), sizes(n, 1) {
    rep(i, n) par[i] = i;
  }
  int find(int x) {
    if (x == par[x]) return x;
    return par[x] = find(par[x]);
  }

  void unite(int x, int y) {
    x = find(x);
    y = find(y);
    if (x == y) return;

    if(sizes[x] < sizes[y]) swap(x, y);

    par[y] = x;
    sizes[x] += sizes[y];
  }

  bool same(int x, int y) {
    return find(x) == find(y);
  }
  int size(int x) {
    return sizes[find(x)];
  }
};


signed main() {
	ll n, k, l;
  cin >> n >> k >> l;

  unionFind uf_1(n + 1);
  unionFind uf_2(n + 1);

  rep(i, k) {
    ll p, q;
    cin >> p >> q;
    uf_1.unite(p, q);
  }

  rep(i, l) {
    ll r, s;
    cin >> r >> s;
    uf_2.unite(r, s);
  }

  map<pair<ll, ll>, ll>mp;

  for(int i = 1; i <= n; i++) {
    mp[make_pair(uf_1.find(i), uf_2.find(i))]++;
  }

  for(int i = 1; i <= n; i++) {
    cout << mp[make_pair(uf_1.find(i), uf_2.find(i))];
    cout << ((i != n) ? " " : "\n");
  }

	return 0;
}

Measured memory_bytes: 18176
n = int(input())
a = list(map(int, input().split()))

a.sort()
mx = a[-1]

dp = [True for _ in range(mx)]

cnt = 0
for i, ai in enumerate(a):
    if dp[ai-1]:
        if i >= len(a)-1 or ai != a[i+1]:
            cnt += 1
        for j in range(ai - 1, mx, ai):
            dp[j] = False

print(cnt)

Measured memory_bytes: 32244
using System;
using System.Collections.Generic;
using System.Linq;

namespace AizuOnlineJudge
{
    class Program
    {
        static void Main(string[] args)
        {
            Console.ReadLine();
            var arr = Console.ReadLine().Split(' ').Select(int.Parse).ToArray();

            InsertionSort(ref arr);
        }

        private static void InsertionSort(ref int[] arr)
        {
            Console.WriteLine(string.Join(" ", arr));
             for(var i = 1; i < arr.Length; ++i)
            {
                var tmp = arr[i];
                var k = i - 1;
                while(k >= 0 && arr[k] > tmp)
                {
                    arr[k + 1] = arr[k];
                    arr[k] = tmp;
                    --k;
                }
                Console.WriteLine(string.Join(" ", arr));
            }
        }
    }
}


Measured memory_bytes: 16328
import java.math.*

val INF = 1000000000

data class Edge(val src: Int, val dst: Int, val cost: Int)

class Node(val id: Int) {
    val edges = mutableListOf<Edge>()
    val nextNodes = mutableListOf<Node>()
    var distance = INF
    var parent: Node? = null
    fun addEdge(edge: Edge, dst: Node) {
        edges.add(edge)
        nextNodes.add(dst)
    }
}

fun main(args: Array<String>) {
    val (N, M, P) = readInputLine().split(" ").map{it.toInt()}

    val nodes = Array(N, {Node(it)})
    val edges = Array(M, {
        val (A, B, C) = readInputLine().split(" ").map{it.toInt()}
        Edge(A - 1, B - 1, (C - P) * -1)
    })

    for (e in edges) {
        nodes[e.src].addEdge(e, nodes[e.dst])
    }

    // ベルマン-フォード法による頂点Nのコスト導出
    // 始点ノードのコストを0にする
    nodes[0].distance = 0
    
    // 辺の緩和
    for (i in 1..N - 1) {
        for (e in edges) {
            val u = nodes[e.src]
            val v = nodes[e.dst]
            val w = e.cost
            if (u.distance == INF) {
                // 親の距離が無限大の場合計算するだけ無駄
                continue
            }
            if (v.distance > u.distance + w) {
                v.distance = u.distance + w
                v.parent = u
            }
        }
    }
    
    // 負の閉路チェック
    // 最後に閉路判定が出たノードから終点ノードへの到達可能判定をするため、
    // 閉路判定が出たノード一覧を取っておく
    val cycleNodes = mutableSetOf<Node>()
    for (e in edges) {
        val u = nodes[e.src]
        val v = nodes[e.dst]
        val w = e.cost
        
        if (u.distance == INF) {
            // 距離がINF -> 始点から到達不能のため考慮不要
            continue
        }
        
        if (u.distance + w < v.distance) {
            cycleNodes.add(u)
        }
    }
    while (true) {
        val tmp = cycleNodes.toSet()
        for (n in tmp) {
            cycleNodes.addAll(n.nextNodes)
        }
        if (cycleNodes.size == tmp.size) {
            break
        }
    }
    
    for (n in cycleNodes) {
        if (n.id == N - 1) {
            println(-1)
            return
        }
    }
    
    println(Math.max(nodes[N - 1].distance * -1, 0))
}

fun readInputLine(): String {
    return readLine()!!
}


Measured memory_bytes: 75712
day = [0, 31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30]
for i in range(2,12):
    day[i] += day[i-1]
week = ['Wednesday', 'Thursday', 'Friday', 'Saturday', 'Sunday', 'Monday', 'Tuesday']
while True:
    M, D = map(int, input().split())
    if M==0:
        break
    days = day[M-1] + D
    print(week[days%7])


Measured memory_bytes: 5600
from heapq import*
import sys
r=sys.stdin.readline
def g(n,E,S,G):
 F=[1e7]*-~n;F[S]=0;H=[(0,S)]
 while H:
  c,u=heappop(H)
  if u==G:return c
  for f,v in E[u]:
   t=c+f
   if t<F[v]:F[v]=t;heappush(H,(t,v))
 return-1
def s(n,k):
 E=[[]for _ in[0]*-~n]
 for _ in[0]*k:
  f=r();p=map(int,f[2:].split())
  if'0'==f[0]:print(g(n,E,*p))
  else:c,d,e=p;E[c]+=[(e,d)];E[d]+=[(e,c)]
[s(*map(int,e.split()))for e in iter(r,'0 0\n')]


Measured memory_bytes: 6308
N,M,C = gets.split(" ").map(&:to_i)
B = gets.split(" ").map(&:to_i)

count = 0
N.times do |n|
  A = gets.chomp.split.map(&:to_i)
  score = 0
  M.times do |m|
    score += A[m] * B[m]
  end
  if score + C > 0
    count += 1
  end
end

puts count



Measured memory_bytes: 1788
#include <algorithm>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <functional>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <vector>
using namespace std;

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

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

// Self settings
// clang-format off
#define MAX_N 100000
#define REP(i, N) for (int i = 0; i < (int)(N); ++i)
#define SLN(i,N) (i == N-1 ? "\n" : " ")
ll fact(ll n) { ll res = 1; for(ll i=2;i<=n;++i) res = res * i; return res;}
ll nCr(ll n, ll r) {return (fact(n)/fact(n-r)*fact(r)) ;}
ll gcd(ll a,ll b){if(b==0)return a;return gcd(b,a%b);}
ll lcm(ll a,ll b){return a/gcd(a,b)*b;}
const ll MOD = 1e9+7;
const ll INF = 1LL << 60;
const int inf = 1 << 30;
// clang-format on

int N, M;
int a[MAX_N], b[MAX_N], c[MAX_N], d[MAX_N];

int manhatand(int x1, int y1, int x2, int y2) {
  return (abs(x1 - x2) + abs(y1 - y2));
}

int main(void) {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cin >> N >> M;

  REP(i, N) cin >> a[i] >> b[i];
  REP(i, M) cin >> c[i] >> d[i];

  vector<int> ans(N);

  for (int i = 0; i < N; i++) {
    int mini = 0, minv = inf;
    for (int j = 0; j < M; j++) {
      int dist = manhatand(a[i], b[i], c[j], d[j]);
      if (dist < minv) {
        minv = dist;
        mini = j + 1;
      }
    }
    ans[i] = mini;
  }

  REP(i, N) cout << ans[i] << endl;

  return 0;
}


Measured memory_bytes: 256