akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<string>
#include<cstdio>
#include<cmath>
#include<algorithm>
using namespace std;
double check(double xa,double ya,double xb,double yb,double xc,double yc);
int main(void){
    double qxa,qya,qxb,qyb,qxc,qyc,qxp,qyp;
    while(cin>>qxa){
 
        cin>>qya>>qxb>>qyb>>qxc>>qyc>>qxp>>qyp;
        double abc,abp,bcp,cap;
        abc=check(qxa,qya,qxb,qyb,qxc,qyc);
        abp=check(qxa,qya,qxb,qyb,qxp,qyp);
        bcp=check(qxb,qyb,qxc,qyc,qxp,qyp);
        cap=check(qxc,qyc,qxa,qya,qxp,qyp);
 
        double var=abc-(abp+bcp+cap);
        if(var<=0.01&&var>=-0.01)var=0.0;
        if(var==0.0)cout<<"YES"<<endl;
        else cout<<"NO"<<endl;
 
 
    }
    return 0;
}
 
 
double check(double xa,double ya,double xb,double yb,double xc,double yc){
 
    double ab,bc,ca;
    double S,s;
    ab=sqrt((xa-xb)*(xa-xb)+(ya-yb)*(ya-yb));
    bc=sqrt((xb-xc)*(xb-xc)+(yb-yc)*(yb-yc));
    ca=sqrt((xc-xa)*(xc-xa)+(yc-ya)*(yc-ya));
    s=0.5*(ab+bc+ca);
    S=sqrt(s*(s-ab)*(s-bc)*(s-ca));
    //cout<<S<<endl;
    return S;
 
 
}

Measured memory_bytes: 1216
#include <iostream>
#include <vector>
#include <string>
#include <numeric>

using namespace std;

#define ll long long int

#define SAY_YES cout << "YES" << endl
#define SAY_NO cout << "NO" << endl
#define say(s) cout << s << endl
#define rep(i, n) for(int i=0; i<(int)(n); i++)

#define vec vector

int main() {
  int n;
  cin >> n;
  int m1=0, m2=0, i1=0;
  rep(i, n) {
    int a;
    cin >> a;
    if (a > m1) {
      m2 = m1;
      m1 = a;
      i1 = i;
    } else {
      m2 = max(m2, a);
    }
  }

  rep(i, n) {
    if (i == i1) {
      say(m2);
    }else {
      say(m1);
    }
  }

  return 0;
}


Measured memory_bytes: 1664
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define FAST_IO ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
int main(){
    //freopen("input.txt","r",stdin);
    //freopen("output.txt","w",stdout);

    string str;
    while(cin>>str){
        cout<<str.substr(0,str.length()-8)<<endl;
    }
    return 0;
}


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

typedef long long ll;
typedef double d;

#define gcd(a,b) __gcd(a,b)
#define lcm(a,b) (abs(a*b)/gcd(a,b))
#define sqr(a) (a*a)

#define tt int t; cin>>t; while(t--)
#define lo(i, a, b) for(int i=a; i<b; i++)
#define rlo(i, a) for(int i=a; i>0; i--)
#define be(a) a.begin(),a.end()
#define sz(x) x.size()
#define nl cout<<"\n";
#define sp cout<<" ";

#define op() ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define file() freopen("input.txt","r",stdin);freopen("output.txt","w",stdout);

int main()
{
    op();int s,w;
    cin>>s>>w;
    if(s>w)
        cout<<"safe";
    else
        cout<<"unsafe";
    nl;
    return 0;
}



Measured memory_bytes: 3652
#include <bits/stdc++.h>
#include <math.h>
#include <cmath>

using namespace std;
using ll =long long;
using vi = vector<int>; 
using vvi = vector<vi>; 
using vl = vector<ll>; 
using vvl = vector<vl>; 

#define rep(i,n) ;for( int i =0; i < n ; i ++)
#define all(a) a.begin(),a.end()
#define f(i,a,b) for(int i=a;i<b;i++)
bool is_int_lround(double x){
  return std::lround(x)==x;
}
int ketasuu(int x){
  int n=0;
  while(x>0){
    x /=10 ;
    n ++;
  }
  return n;
}
ll gcd_ll(ll x, ll y){
  long long a= max(x,y), b=min(x,y), c=a%b;
  while( c!=0){
    a =b;
    b =c;
    c = a%b;
  }
  return b;
}

int abs(int x, int y){
  if(x>=y){
    return x-y;
  }
  else if(y>x){
    return y-x;
  }
}
int fiv(int n){
  if(n==0){
    return 0;
  }
  else if(n==1){
    return 1;
  }
  return fiv(n-1)+fiv(n-2);
}
ll conbi(int n,int m){
  
  cin>>n>>m;
  vector<ll> a(100);
  a[0] =1;
  for(int i=0;i<14;i++){
    a[i+1]=a[i]*(i+1);
  }
  return a[n] /(a[m] *a[n-m]);
}
int main(){
  int n,k;
  cin>>n>>k;
  vi p(n);
  rep(i,n) cin>>p[i];
  vector<double> e(n);
  rep(i,n) e[i] = ((double)p[i]+1)/2; 
  vector<double> wa(n) ;
  wa[0]= e[0];
  rep(i,n-1) wa[i+1] = e[i+1] + wa[i];
  double ans = wa[k-1];
  rep(i,n-k) ans =max(ans , wa[i+k]-wa[i]);
  printf("%.12lf\n", ans);
}





Measured memory_bytes: 4096
#include<cstdio>
#include<cmath>
#include<algorithm>
#include<iostream>
#include<string>
#include<vector>
#include<map>
#include<cstdlib>
#include<iomanip>
#include<queue>
#include<set>
#include <valarray>

using namespace std;


const double EPS = 1e-8;

typedef valarray<double> P;

void assign(P &p, double x, double y, double z)
{
    p.resize(3); // 5 -> 3
 
    p[0] = x;
    p[1] = y;
    p[2] = z;
}

double dot(const P &a, const P &b)
{
    return (a * b).sum();
}

P cross(const P &a, const P &b)
{
    return a.cshift(-1) * b.cshift(1) - a.cshift(1) * b.cshift(-1);
}

bool Solution()
{
    double x, y, z;
 
    P pt[5];
    
    for(int i = 0; i < 5; ++i)
    {
        cin>>x>>y>>z;
        
        assign(pt[i], x, y, z);
    }
    
    P n = cross(pt[3] - pt[2], pt[4] - pt[2]);
    
    double r = dot(pt[2] - pt[0], n);
    double s = dot(pt[1] - pt[0], n);
    
    if(abs(s) < EPS)
    {
        return true;
    }
    
    double t = r / s;
    
    if(t < -EPS || t > 1.0 + EPS)
    {
        return true;
    }
    
    P c = pt[0] * (1.0 - t) + pt[1] * t;
    P d = cross(pt[3] - pt[2], c - pt[2]);
    
    if(dot(d, cross(pt[4] - pt[3], c - pt[3])) < -EPS)
    {
        return true;
    }
    
    if(dot(d, cross(pt[2] - pt[4], c - pt[4])) < -EPS)
    {
        return true;
    }
    
    return false;
}

int main()
{
    cout<<(Solution() ? "HIT\n" : "MISS\n"); // don't forget the "(" ")"
    return 0;
}

Measured memory_bytes: 1208
#include <iostream>
#include <iomanip>
using namespace std;
int main(void){
    int n;
    int a[150]={};
    cin>>n;
    for(int z=1;z<=n;z++){
        cin>>a[z];
    }
    for(int z=n;z>=2;z--){
        cout<<a[z]<<" ";
    }
    cout<<a[1]<<endl;
}


Measured memory_bytes: 3080
import heapq
n, k = map(int,input().split())
hq = []
for i in range(n):
  heapq.heappush(hq, tuple(map(int, input().split())))
length = 0
while(length < k):
  a, b = heapq.heappop(hq)
  length += b
print(a)

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

int n,m;
int dp[100005];
vector<int> e[100005];

int dfs(int at) {
	if (dp[at] != -1) return dp[at];
	dp[at] = 0;
	for (int i=0; i<e[at].size(); i++) {
		dp[at] = max(dp[at],dfs(e[at][i])+1);
	}
	return dp[at];
}

int main() {
	scanf("%d%d",&n,&m);
	for (int i=0; i<m; i++) {
		int a,b;
		scanf("%d%d",&a,&b);
		e[a].push_back(b);
	}
	int ret = 0;
	memset(dp,-1,sizeof(dp));
	for (int i=1; i<=n; i++) {
		ret = max(ret,dfs(i));
	}
	printf("%d\n",ret);
	return 0;
}


Measured memory_bytes: 8192
// template
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef pair<long long, long long> LP;
#define INF 999999999
#define MOD 1000000007
#define REP(i, n) for(ll i = 0, i##_len = (n); i < i##_len; ++i)
#define REP_AB(i, a, b) for (ll i = ll(a); i <= ll(b); ++i)
#define ALL(v) v.begin(), v.end()
#define SORT(v) sort(ALL(v))
#define UNIQUE(v) sort(ALL(v));v.erase(unique(ALL(v)), v.end());
#define SIZE(x) ((ll)(x).size())
#define REVERSE(v) reverse(ALL(v))
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b){return (a / gcd(a, b)) * b;}
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};
#define out cout
#define in cin
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 end

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

    ll n;
    in >> n;
    vector<ll> a(n+1);
    vector<ll> ans(n+1, 0);
    REP(i, n){
        in >> a[i + 1];
    }
    REP(i, n){
        ll num = n-i;
        ll sum_ = 0;
        REP(i, int(n / num) - 1){
            sum_ = (sum_ + ans[num * (i + 2)]) % 2;
        }
        sum_ = (sum_ + a[num]) % 2;
        ans[num] = sum_;
    }
    ll count = 0;
    REP(i, n){
        if(ans[i+1] == 1){
            count += 1;
        }
    }
    out << count << endl;
    ll count_out = 0;
    REP(i, n){
        if(ans[i+1] == 1){
            out << i+1;
            if(count_out < count) out << " ";
        }
    }
    out << endl;
}


Measured memory_bytes: 3968
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<iomanip>
using namespace std;

int main(){
    int n,m;
    cin>>n>>m;
    bool c[n+1]={false};
    int k,tmp,s[n+1]={0};
    if(n>1)s[1]=1;else s[1]=0;
    bool flag=true;
    for(int i=0;i<m;i++){
        cin>>k>>tmp;
        if(k==1){
            if(n>1&&tmp==0){
                flag=false;
            }else{
                if(!c[k]){
                    s[1]=tmp;
                    c[1]=true;
                }else{
                    if(s[1]!=tmp)flag=false;
                }
            }
        }else{
            if(!c[k]){
                s[k]=tmp;
                c[k]=true;
            }else{
                if(s[k]!=tmp)flag=false;
            }
        }
    }
    if(flag){
        for(int i=1;i<=n;i++)cout<<s[i];
        cout<<endl;
    }else{
        cout<<-1<<endl;
    }
    return 0;
}

Measured memory_bytes: 3584
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace SoundHound2
{
    public class Program
    {
        public static void Main(string[] args)
        {
            var line = Console.ReadLine().Trim();
            var n = int.Parse(Console.ReadLine());
            var output = "";

            for (var i = 0; i < line.Length; i++)
            {
                if (i % n == 0)
                {
                    output += line[i];
                }
            }

            Console.WriteLine(output);
        }
    }
}


Measured memory_bytes: 11092
#include <bits/stdc++.h>
#define ll long long
#define ull unsigned long long

using namespace std;

int main() {
    //freopen("a.in", "r", stdin);
    //freopen("a.out", "w", stdout);

    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);

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

    vector<vector<ll>> fromleft(n);
    vector<vector<ll>> fromright(n);
    for(int step = 1; step < n; step ++) {
        for(int i = 0; i < n; i += step) {
            if(fromleft[step].size() == 0)
                fromleft[step].push_back(0);
            else
                fromleft[step].push_back(fromleft[step].back());
            fromleft[step].back() += v[i];
        }

        for(int i = n - 1; i >= 0; i -= step) {
            if(fromright[step].size() == 0)
                fromright[step].push_back(0);
            else
                fromright[step].push_back(fromright[step].back());
            fromright[step].back() += v[i];
        }
    }

    ll ans = 0; /// cazul cand sar direct din 0 in n - 1
    for(int dif = 1; dif <= n - 3; dif ++) {
        for(int multiple = dif; multiple <= n - 3; multiple += dif) {
            int a = n - 1 - multiple;
            int b = a - dif;

            if(a > b && b > 0 & a > 0 && (n - 1 < 2 * a || a % (a - b))) {
                ll l = fromleft[dif][multiple / dif];
                ll r = fromright[dif][multiple / dif];
                ans = max(ans, r + l);

                //cout << a << " " << b << " " << multiple / dif << endl;
            }
        }
    }
    cout << ans;


    return 0;
}


Measured memory_bytes: 33268
import math
from sys import stdin

a, b, c = map(int, stdin.readline().rstrip().split())
if (c - a - b) > 0:
    if (c - a - b) ** 2 > 4 * a * b:
        print('Yes')
    else:
        print('No')
else:
    if math.sqrt(a) + math.sqrt(b) < math.sqrt(c):
        print('Yes')
    else:
        print('No')

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

int main (){
    ll a[10],k;
    cin>>a[0]>>a[1]>>a[2]>>k;
    sort(a,a+3);
    for(int i=1;i<=k;i++){
        a[2]=a[2]*2;
    }
    ll ans=0;
    for(int i=0;i<=2;i++) ans+=a[i];
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 256
#include <cstdio>
#include <cstring>
#include <cmath>
#include <iostream>                                                                                           
#include <algorithm>
#include <iomanip>
#include <sstream>
#define abs(a,b) a<b?b-a:a-b
using namespace std;
int a,b,c,d,e,f,l,r,m,n,x0,z0,i;
int t[2005][2005],p[2005][2005];
int x[10000000],y[10000000],st[10000000];
string s1,s2;
int k[4][2]={1,0,0,1,-1,0,0,-1};
int main()
{ int x2,y2,z2;
 cin>>s1>>s2;
 if(s1[0]==s2[2]&&s1[1]==s2[1]&&s1[2]==s2[0])
  cout<<"YES";
 else cout<<"NO";

 return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <iostream>
#include <set>
#include <bitset>
#include <map>
#include <stack>
#include <algorithm>
#include <math.h>
#include <queue>
#include <vector>
#include <string.h>
#define mem(x,b) memset(x,b,sizeof(x))
#define mp(a,b) make_pair(a,b)
#define debug(a) cout<<a<<endl
#define maxn 200005
using namespace std;
typedef long long ll;
typedef double db;
const int mod=1e9+7;
ll a[maxn];
ll b[maxn];
int main()
{
    ll n,m,k;
    scanf("%lld%lld%lld",&n,&m,&k);
    ll tpa=0,tpb=0;
    for(int i=1;i<=n;i++){
    
    	scanf("%lld",&a[i]);

    	a[i]+=a[i-1];
    }
    for(int i=1;i<=m;i++){
    
    	scanf("%lld",&b[i]);
    	
    	b[i]+=b[i-1];
    }
    int res=0;
   	for(int i=0;i<=n;i++){
   		if(a[i]>k){
   			break;
   		}
   		int l=1,r=m,mid,ans=-1;
   		while(l<=r){
   			mid=(l+r)>>1;
   			if(b[mid]+a[i]<=k){
   				ans=mid;
   				l=mid+1;
   			}else{
   				r=mid-1;
   			}
   		}
   		if(ans!=-1){
   			res=max(res,ans+i);
   		}
   	}
   	for(int i=0;i<=m;i++){
   		if(b[i]>k){
   			break;
   		}
   		int l=1,r=n,mid,ans=-1;
   		while(l<=r){
   			mid=(l+r)>>1;
   			if(a[mid]+b[i]<=k){
   				ans=mid;
   				l=mid+1;
   			}else{
   				r=mid-1;
   			}
   		}
   		if(ans!=-1){
   			res=max(res,ans+i);
   		}
   	}
    printf("%d\n",res);
    return 0;
}


Measured memory_bytes: 6360
n = input()
score = []
s_not10 = []

for i in range(int(n)):
    s = input()
    score.append(int(s))

score.sort()
for j in range(len(score)):
    if score[j]%10 != 0:
        s_not10.append(j)

s_all = int(sum(score))

if s_all%10 != 0:
    best = s_all
elif len(s_not10) == 0:
    best = 0
else:
    best = score[s_not10[-1]]
    if s_all-s_not10[0] > best:
        best = s_all-score[s_not10[0]]

print(best)


Measured memory_bytes: 3064
import java.util.Scanner;

public class Main {
    
    public static void main(String[] args) {
    
        var sc = new Scanner(System.in);
        
        long a = Long.parseLong(sc.next());
        long b = Long.parseLong(sc.next());
        long c = Long.parseLong(sc.next());
        long d = Long.parseLong(sc.next());
        
        long ans = Long.MIN_VALUE;
        ans = Math.max(a*c, ans);
        ans = Math.max(b*d, ans);
        if(b < 0){
            ans = Math.max(b*c, ans);
        }
        if(d < 0){
            ans = Math.max(a*d, ans);
        }
        System.out.println(ans);
    }
}

Measured memory_bytes: 35564
//Created by Kira

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

#define IOS cin.sync_with_stdio(0);cin.tie(0); cout.tie(0);
#define all(x) x.begin(), x.end()
#define sz(x) (int)x.size()
#define pii pair<int,int> 
#define pb push_back
#define vi vector<int> 
using ll = long long;

const int mod = 1e9 + 7;

ll pwr(ll a, ll b);
    



int main(){
   IOS
   
  string s, t; cin>>s>>t;

  int cnt = 0;
  for(int i = 0; i < sz(s); i++){
      if(s[i] != t[i])cnt++;
  }
  cout<<cnt<<"\n";


}

ll pwr(ll a, ll b){
   a %= mod;	//Remove mod if not required
   ll res = 1;
   while(b > 0){
    if(b&1) res = res * a % mod;
        a = a * a % mod;
    b >>= 1;
    }

    return res;
}



Measured memory_bytes: 3788
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>
#include <cstring>
#include <sstream>
#include <cassert>
#include <list>
using namespace std;
static const double EPS = 1e-10;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> PI;
#define rep(i,n) for(int i=0;i<(int)n;++i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)
#define ALL(c) (c).begin(), (c).end()
#define mp(a,b) make_pair(a,b)
#define pb(a) push_back(a)
#define SZ(a) (int(a.size()))
#define F first
#define S second
const double pi=acos(-1);
int dx[]={0,1,0,-1},dy[]={1,0,-1,0};


vector<PI> V[30];
bool vis[1<<8][30];
int ti[30];

main(){
  int n,m,p,a,b;
  while(scanf("%d%d%d%d%d",&n,&m,&p,&a,&b),n){
    --a,--b;
    rep(i,n)scanf("%d",ti+i);
    rep(i,m)V[i].clear();

    rep(i,p){
      int x,y,z;
      scanf("%d%d%d",&x,&y,&z);
      --x,--y;
      V[x].pb(mp(y,z));
      V[y].pb(mp(x,z));
    }

    priority_queue<pair<double,PI> > Q;
    Q.push(mp(0,mp(a,0)));
    memset(vis,0,sizeof(vis));
    double ans=-1;

    while(!Q.empty()){
      int v=Q.top().S.F,cst=Q.top().S.S;
      double cc=-Q.top().F;
      Q.pop();
      if(vis[cst][v])continue;
      vis[cst][v]=true;
      if(v==b){
        ans=cc;
        break;
      }

      rep(i,n){
        if(cst>>i&1)continue;
        rep(j,SZ(V[v])){
          int nv=V[v][j].first;
          int tc=V[v][j].second;
          int nst=cst|(1<<i);
          if(vis[nst][nv])continue;
          double nc=cc+1.0*tc/ti[i];
          Q.push(mp(-nc,mp(nv,nst)));
        }
      }
    }
    if(ans<0)puts("Impossible");
    else printf("%f\n",ans);
  }
}

Measured memory_bytes: 8276
#include <iostream>

using namespace std;

typedef long long ll;

ll a, b, c, d;

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

void solve() {
  a--;
  ll lcm = c * d / gcd(c, d);
  cout << (b - a - (b / c + b / d - b / lcm - a / c - a / d + a / lcm)) << endl;
}

int main() {
  cin >> a >> b >> c >> d;
  solve();
}


Measured memory_bytes: 256
N = gets.to_i
H = gets.split.map(&:to_i)
result = true

H[0] -= 1
(1...N).each do |i|
  if H[i-1] > H[i]
    result = false
    break
  elsif H[i-1] < H[i]
    H[i] -= 1
  end
end

puts result ? 'Yes' : 'No'

Measured memory_bytes: 8580
#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 gcd( int a, int b ){


    if( a < b ) swap(a,b);
    if( b==0 ) return a;

    int r;

    r = a % b;
    while( r ){
        a = b;
        b = r;
        r = a%b;
    }

    return b;

}

int main() {

    int a,b,c;
    Scd3(a,b,c);

    printf ("%d\n", c/a*b );




    return 0;
}



Measured memory_bytes: 256
#include<stdio.h>

int selectionSort(int A[], int N){
	int i, j, t, sw = 0, minj;
	for(i = 0; i < N - 1; i++){
		minj = i;
		for(j = i; j < N; j++){
			if(A[j ]< A[minj]) minj = j;
		}
		t = A[i]; A[i] = A[minj]; A[minj] = t;
		if(i != minj) sw++;
	}
	return sw;
}

int main(){
	int A[100], N, i, sw;
	
	scanf("%d" ,&N);
	for(i = 0; i < N; i++) scanf("%d",&A[i]);
	
	sw = selectionSort(A, N);
	
	for(i = 0; i < N; i++){
		if(i > 0) printf(" ");
		printf("%d", A[i]);
	}
	printf("\n");
	printf("%d\n", sw);
	
	return 0;
}




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

#define debug(n) cerr << #n << ':' << n << endl;

using namespace std;

using  ll = long long;

template<class T,class U>
using umap = unordered_map<T,U>;

template<class T>
using uset = unordered_set<T>;

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

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


int main(){
  ll n;cin >> n;
  cout << ((n-1)*n)/2 << endl;
  return 0;
}



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

int main() {
  int h, w;
  while(cin >> w >> h, w || h) {
    complex<double> pos(1, 1);
    complex<double> unit(0, 1);
    string command;
    while(cin >> command, command != "STOP") {
      if(command == "FORWARD") {
        int len;
        cin >> len;
        pos += unit * (double)len;
      } else if(command == "BACKWARD") {
        int len;
        cin >> len;
        pos += unit * (double)-len;
      } else if(command == "RIGHT") {
        unit *= complex<double>(0, -1);
      } else if(command == "LEFT") {
        unit *= complex<double>(0, 1);
      }
      if(pos.real() < 1) pos.real(1);
      if(pos.real() > w) pos.real(w);
      if(pos.imag() < 1) pos.imag(1);
      if(pos.imag() > h) pos.imag(h);
    }
    cout << pos.real() << ' ' << pos.imag() << endl;
  }
  return 0;
}

Measured memory_bytes: 1284
#define _USE_MATH_DEFINES
#include "bits/stdc++.h"
using namespace std;
#define FOR(i,j,k) for(int (i)=(j);(i)<(int)(k);++(i))
#define rep(i,j) FOR(i,0,j)
#define each(x,y) for(auto &(x):(y))
#define mp make_pair
#define MT make_tuple
#define all(x) (x).begin(),(x).end()
#define debug(x) cout<<#x<<": "<<(x)<<endl
#define smax(x,y) (x)=max((x),(y))
#define smin(x,y) (x)=min((x),(y))
#define MEM(x,y) memset((x),(y),sizeof (x))
#define sz(x) (int)(x).size()
#define RT return
using ll = long long;
using pii = pair<int, int>;
using vi = vector<int>;
using vll = vector<ll>;

void solve() {
    int N;
    cin >> N;
    vll s(N);
    rep(i, N)cin >> s[i];

    ll ans = LLONG_MIN;
    set<int> T;
    for (int i = 1; i <= N - 1; ++i) { // A-B
        T.clear();
        ll sum = 0;
        for (int j = 0; i*j < N - 1; ++j) { // j turns
            int A = N - 1 - i * j;
            int B = A - i;
            if (B <= 0)break;
            if (T.count(i*j))break;
            T.insert(i*j);
            sum += s[i*j];
            if (T.count(N - 1 - i * j))break;
            T.insert(N - 1 - i * j);
            sum += s[N - 1 - i * j];
            smax(ans, sum);
        }
    }
    cout << ans << endl;
}

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	cout << fixed << setprecision(15);
	solve();
	return 0;
}

Measured memory_bytes: 5760
/*
"Won't stop until I'm phenomenal."
- Phenomenal, Eminem
 */
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
#define ff first
#define Shazam ios_base::sync_with_stdio(false);   cin.tie(NULL); cout.tie(NULL);
#define ss second
#define all(c) c.begin(),c.end()
#define endl "\n"
#define test() int t; cin>>t; while(t--)
#define fl(i,a,b) for(int i = a ; i <b ;i++)
#define get(a) fl(i,0,a.size())  cin>>a[i];
#define pra(a) fl(i,0,a.size()) cout<<a[i]<<" ";	cout<<endl;
#define pr(a,n) fl(i,0,n) cout<<a[i]<<" ";	cout<<endl;
const ll INF = 2e18;
const int inf = 2e9;
const int mod1 = 1e9 + 7;



int main(){
    Shazam;
    int n; cin>>n;
    ll g = 0;
    map<int,int> f;
    for(int i = 0 ; i < n; i++){
        ll k; cin>>k;
        g = __gcd(g,k);
        for(int i = 2; i*i <= k; i++){
            if(k%i==0){
                f[i]++;
                while(k%i==0){
                    k/=i;
                }
            }
        }
        if(k>=2)
            f[k]++;
    }
    if(g!=1){
        cout<<"not coprime"<<endl;
    }
    else{
        bool single = true;
        for(auto pp : f){
            if(pp.ss>1)
                single = false;
        }
        if(!single){
            cout<<"setwise coprime"<<endl;
        }
        else{
            cout<<"pairwise coprime"<<endl;
        }
    }
    return 0;
}

Measured memory_bytes: 7300
/*
これを入れて実行
g++ code.cpp
./a.out
 */
 
#include <iostream>
#include <vector>
#include <string>
#include <queue>
#include <deque>
#include <algorithm>
#include <utility>
#include <set>
#include <map>
#include <cmath>
#include <math.h>
#include <tuple>
#include <iomanip>
 
using namespace std;
typedef long long ll;
typedef long double ld;
 
int dy4[4] = {-1, 0, +1, 0};
int dx4[4] = {0, +1, 0, -1};
int dy8[8] = {-1, -1, 0, 1, 1, 1, 0, -1};
int dx8[8] = {0, 1, 1, 1, 0, -1, -1, -1};
 
const long long INF = 1LL << 60;
const ll MOD = 1e9 + 7;
 
bool greaterSecond(const pair<int, int>& f, const pair<int, int>& s){
    return f.second > s.second;
}
 
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;
}
 
ll nCr(ll n, ll r){
    if(r == 0 || r == n){
        return 1;
    } else if(r == 1){
        return n;
    }
    return (nCr(n - 1, r) + nCr(n - 1, r - 1));
}
 
ll nPr(ll n, ll r){
    r = n - r;
    ll ret = 1;
    for (ll i = n; i >= r + 1; i--) ret *= i;
    return ret;
}
 
//-----------------------ここから-----------

int main(void){
    int n;
    cin >> n;

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

    int ans = 0;

    for(int i = 0; i < n; i++){
        for(int j = i + 1; j < n; j++){
            ans += d[i] * d[j];
        }
    }

    cout << ans << endl;
}

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

using namespace std;

int solve(int p, int t);

int n, q;
vector<int> A;
vector<int> M;

int main(){
    cin>>n;
    for (int i=0 ;i<n; i++) {
        int input;
        cin>>input;
        A.push_back(input);
    }
    cin>>q;
    for (int i=0; i<q; i++) {
        int input;
        cin>>input;
        M.push_back(input);
    }
    //cout<<"input end"<<endl;
    for (int i=0; i<q; i++) {
        if ( solve(0,M[i])== 1 ) {
            cout<<"yes"<<endl;
        }else{
            cout<<"no"<<endl;
        }
    }
}

int solve(int p, int t){
    if ( p >= n) {
        return 0;
    }
    else if ( solve(p+1, t-A[p]) == 1 || solve(p+1, t) == 1){
        return 1;
    }
    else if ( t-A[p] == 0 ){
        return 1;
    }else{
        return 0;
    }
}

Measured memory_bytes: 1208
#include <iostream>
#include <string>
#include <algorithm>
#include <math.h>
#include <iomanip>

#define fori(x) for(int i=0;i<x;++i)

// cout << fixed << setprecision(10) << num << endl;

using namespace std;

int main(){
  int h,a;
  cin>>h>>a;
  
  int i=0;
  for(;0<h;++i){
    h-=a;
  }
  cout<<i;
  return 0;
}

Measured memory_bytes: 256
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		Scanner scanner = new Scanner(System.in);

//		ArrayList<Integer> p=new ArrayList<Integer>();
		int N = scanner.nextInt();
		int p[] = new int[N];
		int counter=0;

		for(int i=0;i<N;i++) {
			p[i]=scanner.nextInt();
		}

		if(p[0]-p[1]!=-1) counter++;
//		System.out.println(counter);

		for(int i=1;i<N-2;i++) {
			if(p[i]-p[i+1]!=-1) {
				counter++;
				i++;
			}
		}

		if(p[N-2]-p[N-1]!=-1) counter++;
//		System.out.println(counter);

//		System.out.println(counter);
		if(counter==0||counter==2) System.out.println("YES");
		else System.out.println("NO");

		scanner.close();


	}

}


Measured memory_bytes: 22996
import java.util.Scanner;

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

        //Nはお札の枚数
        int N = stdIn.nextInt();
       
        int Y = stdIn.nextInt();

        for (int i=0; i<=N; i++) {
            for (int j=0; j<=N-i; j++) {
                int k = N - i - j;
                int totil = i * 10000 + j * 5000 + k * 1000;
                if (totil == Y) {
                    System.out.println(i + " " + j + " " + k);
                    return;
                }
            }
        }

        System.out.println("-1 -1 -1");
    }
}

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

int main()
{
  int N;
  cin >> N;
  set<char> st;
  while (N--)
  {
    char c;
    cin >> c;
    st.insert(c);
  }
  if (st.size() == 4)
    cout << "Four" << endl;
  else
    cout << "Three" << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n;
  cin>>n;
  vector<int> a(n);
  map<int,int> b;
  for(int i=0;i<n;i++){
    cin>>a.at(i);
    b[a.at(i)]++;
  }
  int64_t p=0;
  for(auto i:b){
    int64_t v=i.second;
    p+=v*(v-1)/2;
  }
  for(int i=0;i<n;i++)
    cout<<p-(b.at(a.at(i))-1)<<endl;
}

Measured memory_bytes: 8320
def eratosthenes(n):
    prime = [2]
    if n == 2:
        return prime
    limit = int(n ** 0.5)
    data = [i + 1 for i in range(2, n, 2)]
    while True:
        p = data[0]
        if limit <= p:
            return prime + data
        prime.append(p)
        data = [e for e in data if e % p != 0]


def solve():
    Q = int(input())
    primes = set(eratosthenes(10 ** 5))
    like_2017 = [0] * (10 ** 5 // 2)
    for i in range(3, 10 ** 5, 2):
        if i in primes and (i + 1) // 2 in primes:
            like_2017[i // 2] = like_2017[i // 2 - 1] + 1
        else:
            like_2017[i // 2] = like_2017[i // 2 - 1]
    for _ in range(Q):
        l, r = map(int, input().split())
        ans = like_2017[r // 2] - like_2017[max(0, l // 2 - 1)]
        print(ans)


if __name__ == '__main__':
    solve()


Measured memory_bytes: 53724
#include <iostream>

using namespace std;

int main()
{
	int n, c = 0;
	cin >> n;
	int* p = new int[n];
	for (int i = 0; i < n; i++)
	{
		cin >> p[i];
	}
	for (int i = 1; i < n-1; i++)
	{
		if ((p[i] > p[i-1] && p[i] < p[i + 1]) || (p[i] < p[i - 1] && p[i] > p[i + 1]))
		{
			c++;
		}
	}
	cout << c << endl;
}


Measured memory_bytes: 256
h,w = map(int, raw_input().split())
c = '.'*(w+2)
mass = []
mass.append(c)
for _ in xrange(h):
    s = '.' + raw_input() + '.'
    mass.append(s)
mass.append(c)

ans = [['.' for _ in xrange(w)] for _ in xrange(h)]
for i in xrange(h):
    for j in xrange(w):
        if mass[i+1][j+1] == '#':
            ans[i][j] = '#'
        else:
            count = 0
            for a in [-1, 0, 1]:
                for b in [-1, 0, 1]:
                    if mass[i+1+a][j+1+b] == '#': count += 1
            ans[i][j] = str(count)

for x in ans:
    print "".join(x)

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

using ll = long long;

template<typename T>
T gcd(T a, T b)
{
	if (a < b)	return gcd(b, a);
	T r;
	while ((r = a % b))
	{
		a = b;
		b = r;
	}
	return b;
}

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

template<typename T>
T ext_gcd(T a, T b, T& x, T& y)
{
	x = 1;
	y = 0;
	T x0 = 0, y0 = 1;
	while (b != 0)
	{
		T q = a / b;
		a -= q * b;
		swap(a, b);
		x -= q * x0;
		swap(x, x0);
		y -= q * y0;
		swap(y, y0);
	}
	return a;
}

template<typename T>
T inv_mod(T a, T mod)
{
	T t1, t2;
	ext_gcd(a, mod, t1, t2);
	t1 %= mod;
	if (t1 < 0)		t1 += mod;
	return t1;
}

template<typename T>
T combination_large(T n, T k, T mod)
{
	if (n < k || n < 0 || k < 0)	return 0;
	vector<T> inv(n + 1, 1), fact(n + 1, 1), fact_inv(n + 1, 1);
	for (T i = 2; i <= n; ++i)
	{
		inv[i] = mod - inv[mod % i] * (mod / i) % mod;
		fact[i] = (fact[i - 1] * i) % mod;
		fact_inv[i] = fact_inv[i - 1] * inv[i] % mod;
	}
	return fact[n] * (fact_inv[k] * fact_inv[n - k] % mod) % mod;
}

template<typename T>
T combination(T n, T k, T mod = 1)
{
	vector<vector<T>> table(n + 1, vector<T>(k + 1, 1));
	for (T i = 1; i <= n; ++i)
	{
		table[i][0] = 1;
		for (T j = 1; j <= n; ++j)
		{
			table[i][j] = (table[i - 1][j - 1] + table[i - 1][j]) % mod;
		}
	}
}


int main(int, char**)
{
	long long A;
	scanf("%lld",&A);
	long long B;
	scanf("%lld",&B);
	long long C;
	scanf("%lld",&C);
	long long K;
	scanf("%lld",&K);

	if (A >= K)
	{
		cout << K << endl;
	}
	else if (A + B >= K)
	{
		cout << A << endl;
	}
	else
	{
		cout << A - (K - A - B) << endl;
	}

	return 0;
}


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

int main()
{
	int n;
	cin >> n;
	auto a = vector<int>(n);
	for(auto&& aa : a) cin >> aa;
	sort(a.begin(), a.end());
	long long int s = 0, t = 0;
	int p = n - 1;
	while(p > 0 && s * t == 0){
		if(a[p] == a[p - 1]){
			if(s == 0) s = a[p];
			else t = a[p];
			--p;
		}
		--p;
	}
	cout << s * t << endl;
	return 0;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int MAXN = 300500;

ll arr[MAXN];
ll ans_left[MAXN], ans_right[MAXN];
int n;


int main()
{
  cin >> n;
  for (int i = 0; i < 3 * n; i++)
  {
    cin >> arr[i];
  }

  multiset <ll> pl;
  ll sum = 0;

  for (int i = 0; i < n; i++)
  {
    pl.insert(arr[i]);
    sum += arr[i];
  }

  for (int i = n; i < 3 * n; i++)
  {
    ans_left[i - 1] = sum;
    pl.insert(arr[i]);
    sum += arr[i];
    sum -= *pl.begin();
    pl.erase(pl.begin());
  }

  pl.clear();
  sum = 0;

  for (int i = 3 * n - 1; i >= 2 * n; i--)
  {
    pl.insert(arr[i]);
    sum += arr[i];
  }

  for (int i = 2 * n - 1; i >= 0; i--)
  {
    ans_right[i + 1] = sum;
    pl.insert(arr[i]);
    sum += arr[i];
    sum -= *pl.rbegin();
    pl.erase(pl.find(*pl.rbegin()));
  }

  ll ans = -1e18;

  for (int i = n - 1; i < 2 * n; i++)
    ans = max(ans, ans_left[i] - ans_right[i + 1]);

  cout << ans << '\n';

  return 0;
}


Measured memory_bytes: 11520
// practice with Dukkha
#include <algorithm>
#include <iostream>

using namespace std;

const int N = 50;

long long vv[N];

long long ch(int n, int k) {
	return k == 0 ? 1 : ch(n - 1, k - 1) * n / k;
}

int main() {
	int n, a, b; cin >> n >> a >> b;
	for (int i = 0; i < n; i++)
		cin >> vv[i];
	sort(vv, vv + n, greater<>());
	long long sum = 0; int cnt = 0;
	long long sum_ = 0; int cnt_ = 1; long long ways = 0;
	for (int i = 0, j; i < n; i = j) {
		j = i + 1;
		while (j < n && vv[j] == vv[i])
			j++;
		int k = j - i;
		for (j = i; j < n && vv[j] == vv[i]; j++) {
			sum += vv[j];
			cnt++;
			if (a <= j + 1 && j + 1 <= b) {
				if (sum_ * cnt < sum * cnt_) {
					sum_ = sum;
					cnt_ = cnt;
					ways = ch(k, j - i + 1);
				} else if (sum_ * cnt == sum * cnt_)
					ways += ch(k, j - i + 1);
			}
		}
	}
	printf("%f\n%lld\n", (double) sum_ / cnt_, ways);
	return 0;
}


Measured memory_bytes: 3736
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cmath>
#include<string>
#include<vector>
#include<list>
#include<set>
#include<map>
#include<queue>
#include<stack>
#include<cctype>
#include<climits>
#include<bitset>
#include<bits/stdc++.h>
#define ld long double
#define ll long long int
#define ull unsigned long long intS
#define rep(i,n) for(int i=0;i<n;i++)
#define fin(ans) cout<<(ans)<<endl
#define INF INT_MAX
#define vi vector<int>
#define vc vector<char>
#define vs vector<string>
#define vpii vector<pair<int,int> >
#define vvi vector<vector<int> >
#define vvc vector<vector<char> >
#define vvs vector<vector<string> >
#define P 1000000007
using namespace std;
template<class T> inline bool chmax(T& a,T b){if(a<b){a=b;return 1;}return 0;}
template<class T> inline bool chmin(T& a,T b){if(a>b){a=b;return 1;}return 0;}
const long long LLINF=1LL<<60;
//set<int>::iterator it;


int main(void){ios::sync_with_stdio(false);cin.tie(0);
//////////////////////////////////////////////////////
    
    int k;
    
    cin >> k;
    
    if ( k%2 == 0 ){
    
    cout << k/2*k/2 << endl;
    
    }else{
    
    cout << (k/2+1)*(k-1)/2 << endl;
    
    }
    
    
    
    
    
//////////////////////////////////////////////////////
return 0;}

Measured memory_bytes: 892
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

fn main() {
    input!{
        a: i64,
        b: i64,
        h: i64,
    }
    println!("{}", (a + b) * h / 2);
}


Measured memory_bytes: 4352
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
#define INF 1000000000000000000
vector<ll> dijkstra(ll s,vector<vector<pair<ll, ll>>> adj)
{
    ll n=adj.size();
    vector<ll> dist(n+1,INF);
    vector<ll> prev(n+1,-1);
    dist[s]=0;
    priority_queue<pair<ll,ll>, vector<pair<ll,ll>>, greater<pair<ll,ll>>> pq;
    pq.push({0, s});
    while(!pq.empty())
    {
        ll v = pq.top().second;
        ll dist_v=pq.top().first;
        pq.pop();
        if(dist_v!= dist[v])
        continue;
        for (auto edge : adj[v]) 
        {
            ll to = edge.first;
            ll len = edge.second;
            if (dist[v] + len < dist[to]) 
            {
                dist[to] = dist[v] + len;
                prev[to] = v;
                pq.push({dist[to], to});
            }
        }
    }
    // vector<ll> ans;
    // ll pos;
    // ll mini=LLONG_MAX;
    // for(ll i=0;i<dist.size();i++)
    // {
    //     if(i==s)
    //     continue;
    //     else
    //     if(dist[i]<mini)
    //     {
    //         mini=dist[i];
    //         pos=i;
    //     }
    // }
    // cout<<pos<<" "<<endl; //minimum distance node from s
    // for(ll i=pos;i!=-1;i=prev[i])
    // {
    //     ans.push_back(i);
    // }
    // reverse(ans.begin(),ans.end());
    // for(auto i:ans)
    // {
    //     cout<<i<<' '; //path to the minimum distance node
    // }
    // cout<<endl;
    return dist;
}
int main() 
{
	ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
	ll n,m,i,x,y;
    cin>>n>>x>>y;
    vector<vector<pair<ll,ll>>> adj(n+5);
    for(i=1;i<n;i++)
    {
        adj[i].push_back({i+1,1});
        adj[i+1].push_back({i,1});
    }
    adj[x].push_back({y,1});
    adj[y].push_back({x,1});
    ll b[n+10]={0};
    for(i=1;i<=n;i++)
    {
        vector<ll> distance=dijkstra(i,adj);
        for(ll j=i+1;j<=n;j++)
        {
            if(distance[j]<=n)
            b[distance[j]]++;
        }
        //cout<<endl;
    }
    for(i=1;i<n;i++)
    cout<<b[i]<<endl;
	return 0;
}

Measured memory_bytes: 640
//Author ::  ABHINAV3010 ::

#include<bits/stdc++.h>
using namespace std;
#define fi first
#define se second
#define pb push_back
#define fast ios_base::sync_with_stdio(false)
typedef long long ll;
typedef pair<ll,ll> p;
ll mod=1000000007;
ll gcd(ll a,ll b)
{
    return (b==0)?a:gcd(b,a%b);
}
int main()
{
fast;
ll n;
cin>>n;
vector<ll>v;
vector<ll>ans(n+1,0);
for(ll i=0;i<n;i++)
{
    ll a;
    cin>>a;
    ans[a]=i+1;
}
for(ll i=1;i<=n;i++)
{
    cout<<ans[i]<<" ";
}
return 0;
}


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

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

        String S = sc.next();
        String s = S.toLowerCase();

        int count = 0;
        while(true) {
            String T = sc.next();
            if (T.equals("END_OF_TEXT")) {
                break;
            }
            String t = T.toLowerCase();
            if (t.equals(s)) {
                count++;
            }
        }
        out.printf("%d\n", count);
        out.flush();
    }
}


Measured memory_bytes: 26536
//
// Created by yamunaku on 2019/09/20.
//

#include <bits/stdc++.h>

using namespace std;

#define rep(i, n) for(int i = 0; i < (n); i++)
#define repl(i, l, r) for(int i = (l); i < (r); i++)
#define per(i, n) for(int i = ((n)-1); i >= 0; i--)
#define perl(i, l, r) for(int i = ((r)-1); i >= (l); i--)
#define all(x) (x).begin(),(x).end()
#define MOD9 998244353
#define MOD1 1000000007
#define IINF 1000000000
#define LINF 1000000000000000000
#define SP <<" "<<
#define CYES cout<<"Yes"<<endl
#define CNO cout<<"No"<<endl
#define CFS cin.tie(0);ios::sync_with_stdio(false)
#define CST(x) cout<<fixed<<setprecision(x)

typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<vector<int>> mti;
typedef vector<ll> vl;
typedef vector<vector<ll>> mtl;

int main(){
    ll m;
    string s;
    cin >> m >> s;
    int n=s.size();
    vl kei(10,0);
    rep(i,n){
        rep(j,10){
            kei[j]=(kei[j]*10)%MOD1;
        }
        kei[s[i]-'0']++;
    }
    vi p(10);
    iota(all(p),0);
    do{
        ll sum=0;
        rep(i,10){
            sum=(sum+kei[i]*p[i])%MOD1;
        }
        if(sum==m){
            if(m==0||p[s[0]-'0']!=0){
            rep(i,n){
                cout << p[s[i]-'0'];
            }
            cout << endl;
            return 0;
            }
        }
    }while(next_permutation(all(p)));
    cout << -1 << endl;
    return 0;
}





Measured memory_bytes: 3340
#include<bits/stdc++.h>
using namespace std;
#define int long long int
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define r0 return 0;
#define f(k,i,n,j) for(ll k=i;k<=n;k=k+j)
#define cin(a) cin>>a;
#define loop while(t--)
#define vi vector<int>
#define vii vector<long long int>
#define SORT(v) sort(v.begin(),v.end());
#define mod (1e9+7)
#define crap ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define endl "\n"
void findNumberOfDigits(int n, int base) 
{ 
    // Calculating log using base 
    // changing property and then 
    // taking it floor and then  
    // adding 1. 
    int dig = (int)(floor( log(n) /  
                         log(base)) + 1);  
      
    // printing output 
    cout<<dig<<endl;
    
} 
  
signed main()
{
    crap;
    int n,k;
    cin>>n>>k;
    findNumberOfDigits(n,k);
}

Measured memory_bytes: 256
let rec f _ = 
    let (x, y) = Scanf.sscanf(read_line()) "%d %d" (fun x y -> (x, y)) in
    if x = 0 && y = 0 then () 
    else
        let (a, b) = if x < y then (x, y) else (y, x) in
        (Printf.printf "%d %d\n" a b;
        f ());;
        
f ();;


Measured memory_bytes: 4496
#include<bits/stdc++.h>
using namespace std;
struct eat
{
    string n;
    int s=0,id=0;
}a[105];
bool cmp(struct eat a,struct eat b)
{
   if(a.n!=b.n)
    return a.n<b.n;
   else return a.s>b.s;


}
int main()
{
    int t=0;
    cin>>t;
    for(int i=0;i<t;i++)
    {
        cin>>a[i].n;
        cin>>a[i].s;
        a[i].id=i+1;
    }
    sort(a,a+t,cmp);
    for(int i=0;i<t;i++)
    {
        cout<<a[i].id<<endl;
    }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(k,i,n) for(ll i=k;i<n;++i)
ll dx[4]={1,-1,0,0},dy[4]={0,0,1,-1};
int main(void){
    ll h,w;
    cin>>h>>w;
    string s[h];
    rep(0,i,h)cin>>s[i];
    ll ans=0;
    vector<vector<bool>>d(h,vector<bool>(w,false));
    rep(0,i,h){
        rep(0,j,w){
            if(d[i][j]==false){
                ll cw=0,cb=0;
                queue<pair<ll,ll>>q;
                d[i][j]=true;
                q.push({i,j});
                while(!q.empty()){
                    ll x=q.front().first,y=q.front().second;q.pop();
                    if(s[x][y]=='#')++cb;
                    else ++cw;
                    rep(0,k,4){
                        ll nx=x+dx[k],ny=y+dy[k];
                        if(!(nx>=0&&nx<h&&ny>=0&&ny<w))continue;
                        if(s[x][y]!=s[nx][ny]&&(!d[nx][ny])){
                            d[nx][ny]=true;
                            q.push({nx,ny});
                        }
                    }
                }
                //cout<<cb<<" "<<cw<<endl;
                ans+=cw*cb;
            }
        }
    }
    cout<<ans;
}

Measured memory_bytes: 3840
process.stdin.resume();
process.stdin.setEncoding('utf8');

var g_input = '';
process.stdin.on('data', function(chunk) {
    g_input += chunk;
});

process.stdin.on('end', function() {
    Main(g_input.split(/\r?\n/));
});

function Main(input) {

    var hw = input[0].split(' ');
    var h = parseInt(hw[0], 10);
    var w = parseInt(hw[1], 10);

    var i = 0;
    var grid = [];
    for (i = 0; i < h; i++) {
        var line = input[1 + i].split('');
        grid[i] = line;
    }

    var ans = true;
    var j = 0;
    for (i = 0; i < h; i++) {
        for (j = 0; j < w; j++) {
            if (grid[i][j] === '#') {
                if ((i === 0 || grid[i - 1][j] === '.') &&
                    (i === h - 1 || grid[i + 1][j] === '.') &&
                    (j === 0 || grid[i][j - 1] === '.') &&
                    (j === w - 1 || grid[i][j + 1] === '.')) {

                    ans = false;
                    break;
                }
            }
        }

        if (!ans) {
            break;
        }
    }

    if (ans) {
        console.log('Yes');
    }
    else {
        console.log('No');
    }

    return 0;
}


Measured memory_bytes: 21192
#include "bits/stdc++.h"
using namespace std;

int main() {
	unsigned int H, W;
	cin >> H >> W;

	char c;
	string* s = new string[H + 2];
	string* t = new string[H + 2];

	for (int i = 0; i <= H + 1; ++i) {
		s[i] = string(W + 2, '.');
		t[i] = string(W + 2, '#');
	}
	for (int i = 0; i < H; ++i) {
		for (int j = 0; j < W; ++j) {
			cin >> c;
			s[i + 1][j + 1] = c;
		}
	}
	for (int i = 1; i <= H; ++i) {
		for (int j = 1; j <= W; ++j) {
			if (s[i][j] == '.') {
				int bom = 0;
				if (s[i - 1][j - 1] == '#') { ++bom; };
				if (s[i - 1][j] == '#') { ++bom; };
				if (s[i - 1][j + 1] == '#') { ++bom; };
				if (s[i][j - 1] == '#') { ++bom; };
				if (s[i][j + 1] == '#') { ++bom; };
				if (s[i + 1][j - 1] == '#') { ++bom; };
				if (s[i + 1][j] == '#') { ++bom; };
				if (s[i + 1][j + 1] == '#') { ++bom; };
				t[i][j] = to_string(bom)[0];
			}
		}
	}
	for (int i = 0; i < H; ++i) {
		for (int j = 0; j < W; ++j) {
			cout << t[i + 1][j + 1];
		}
		cout << endl;
	}
}


Measured memory_bytes: 384
#include <stdio.h>
#include <string.h>

int main(void){
  int l, r, d;
  scanf("%d %d %d", &l, &r, &d);
  int i;
  int ans=0;
  for(i=l; i<r+1; i++){
    if(i%d==0){
      ans++;
    }
  }
  
  printf("%d\n", ans);
  return 0;
}

Measured memory_bytes: 1728
n = int(input())
a = list(map(int,input().split()))
b = list(map(int,input().split()))
c = list(map(int,input().split()))

ans = sum(b)

for i in range(n-1):
    if a[i]+1 == a[i+1]:
        ans += c[a[i]-1]

print(ans)

Measured memory_bytes: 3064
n, m = gets.split.map(&:to_i)
graph = Array.new(n + 1) { [] }

m.times do
  a, b = gets.split.map(&:to_i)
  graph[a] << b
  graph[b] << a
end

dist = []
dist[1] = 0
queue = [1]
ret = []

while queue.any?
  v = queue.shift

  graph[v].each do |i|
    next if dist[i]

    dist[i] = dist[v] + 1
    queue << i
    ret[i] = v
  end
end

puts :Yes
puts ret.compact

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

int main() {
	int n, k;
	cin >> n >> k;
	long long ans = 0, d = 0;
	for (int i = 1;i <= n;i++) {
		if (k % 2 == 0) {
			if (i % k == 0)ans++;
			else if (i % (k / 2) == 0)d++;
		}
		else {
			if (i%k == 0)ans++;
		}
	}
	cout << ans * ans * ans + d * d*d << endl;
}

Measured memory_bytes: 256