akhauriyash/Code-Regression huggingface dataset:
import java.util.Scanner;
public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		for (int i = 0 ; i < n ; i++){
			double a,b,c,s,t,r;
			double a1,b1,c1,a2,b2,c2,x,y;
			double x1 = sc.nextDouble();
			double y1 = sc.nextDouble();
			double x2 = sc.nextDouble();
			double y2 = sc.nextDouble();
			double x3 = sc.nextDouble();
			double y3 = sc.nextDouble();
			a = Math.sqrt(Math.pow(x2-x1,2)+Math.pow(y2-y1, 2));
			b = Math.sqrt(Math.pow(x3-x2,2)+Math.pow(y3-y2, 2));
			c = Math.sqrt(Math.pow(x3-x1,2)+Math.pow(y3-y1, 2));
			s = (a+b+c)/2;
			t = Math.sqrt(s*(s-a)*(s-b)*(s-c));
			r = (a*b*c)/(4*t);
			a1 = (x2-x1)*2;
			b1 = (y2-y1)*2;
			c1 = Math.pow(x1,2) - Math.pow(x2,2) + Math.pow(y1,2) - Math.pow(y2,2);
			a2 = (x3-x1) * 2;
			b2 = (y3-y1) * 2;
			c2 =Math.pow(x1,2) - Math.pow(x3,2) + Math.pow(y1,2) - Math.pow(y3,2);
			x = ((b1*c2) - (b2*c1))/((a1*b2) - (a2*b1));
			y = ((c1*a2) - (c2*a1))/((a1*b2) - (a2*b1));
			x = x * 1000;
			x = Math.round(x);
			x = x/1000;
			y = y * 1000;
			y = Math.round(y);
			y = y/1000;
			r = r * 1000;
			r = Math.round(r);
			r = r/1000;
			System.out.printf("%.3f %.3f %.3f\n",x ,y, r );

		}
		
		
		
		
		
		sc.close();
	}

}

Measured memory_bytes: 20828
#include<stdio.h>

int main(){
	int a,b,c;

	scanf("%d %d %d",&a,&b,&c);

	if(c>=a && c>=b){
		printf("%d\n",c*10+a+b);
	}else if(b>=a && b>=c){
		printf("%d\n",b*10+a+c);
	}else{
		printf("%d\n",a*10+b+c);
	}

	return 0;
}

Measured memory_bytes: 128
from collections import deque

def resolve():
    H, W = map(int, input().split())
    grid = [["#"]*(W+2) for _ in range(H+2)]
    cnt = 0
    for i in range(1,H+1):
        g = list(input())
        cnt += g.count(".")
        grid[i][1:-1] = g

    q = deque()
    q.append((1, 1))
    dxy = [(-1, 0), (0, 1), (1, 0), (0, -1)]
    visited = [[0] * (W + 2) for _ in range(H + 2)]
    visited[1][1] = 1

    while q:
        x, y = q.popleft()
        for dx, dy in dxy:
            nx = dx + x
            ny = dy + y
            if grid[ny][nx] == "." and visited[ny][nx] == 0:
                visited[ny][nx] += 1 + visited[y][x]
                q.append((nx, ny))
    if visited[H][W] > 0:
        ans = cnt - visited[H][W]
    else:
        ans = -1

    return print(ans)

if __name__ == "__main__":
    resolve()

Measured memory_bytes: 3316
#include <iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<map>
#include<set>
#include<stack>
#include<queue>
#include<math.h>
using namespace std;
typedef long long ll;
#define int long long
#define double long double
typedef vector<int> VI;
typedef pair<int, int> pii;
typedef vector<pii> VP;
typedef vector<string> VS;
typedef priority_queue<int> PQ;
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; }
#define fore(i,a) for(auto &i:a)
#define REP(i,n) for(int i=0;i<n;i++)
#define eREP(i,n) for(int i=0;i<=n;i++)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define eFOR(i,a,b) for(int i=(a);i<=(b);++i)
#define SORT(c) sort((c).begin(),(c).end())
#define rSORT(c) sort((c).rbegin(),(c).rend())
#define LB(x,a) lower_bound((x).begin(),(x).end(),(a))
#define UB(x,a) upper_bound((x).begin(),(x).end(),(a))
#define INF 1000000000
#define LLINF 9223372036854775807
#define mod 1000000007
#define eps 1e-12 
//priority_queue<int,vector<int>, greater<int> > q2;

int V[3010][3010];
int dp[3010][3010][4];

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

	int R, C, K; cin >> R >> C >> K;
	REP(i, 3005)REP(j, 3005)V[i][j] = -1;
	REP(i, K) {
		int r, c, v; cin >> r >> c >> v;
		r--;
		c--;
		V[r][c] = v;
	}

	REP(i, 3005)REP(j, 3005)REP(k, 4)dp[i][j][k] = 0;
	REP(i, R) {
		REP(j, C) {
			eREP(k, 3) {

				if (k != 3 && V[i][j] != -1) {
					if (k == 0)chmax(dp[i][j][k + 1], dp[i][j][k] + V[i][j]);

					if (j != 0 && j >= k)chmax(dp[i][j][k + 1], dp[i][j - 1][k] + V[i][j]);
					
				}
				if (i != R - 1)chmax(dp[i + 1][j][0], dp[i][j][k]);
				
				if (j != C - 1)chmax(dp[i][j + 1][k], dp[i][j][k]);
			}
		}
	}
	int ans = -INF;
	REP(k, 4)chmax(ans, dp[R - 1][C - 1][k]);
	cout << ans << endl;
	return 0;
}



Measured memory_bytes: 356984
#include<stdio.h>
int main(){

  int a,b,c;
  char op;

  while(1){
    scanf("%d %c %d", &a, &op, &b);
    
    if ( op == '?') break;
    if ( op == '+') c = a + b;
    if ( op == '-') c = a - b;
    if ( op == '*') c = a * b;
    if ( op == '/') c = a / b;

    printf("%d\n", c);
    }

  return 0;
  
}

Measured memory_bytes: 600
use std::io::*;


fn solve(n: usize, ws: Vec<String>) -> usize{
    let array = [5, 7, 5, 7, 7];
    for index in 0..n {
        let mut count = 0;
        let mut pos = 0;
        for i in index..n {
            count+=ws[i].len();
            if count > array[pos] {
                break;
            }
            if count == array[pos] {
                count-=array[pos];
                pos = pos + 1;
                if pos == array.len() {
                    return index;
                }
            }
        }
    }
    0
}

fn main() {
    let mut buf = String::new();
    std::io::stdin().read_to_string(&mut buf).unwrap();
    let mut iter = buf.split_whitespace();

    loop {
        let n: usize = iter.next().unwrap().parse().unwrap();
        if n == 0 { break; }
        let ws: Vec<String> = (0..n)
            .map(|_| {iter.next().unwrap().parse().unwrap()})
            .collect();

        println!("{}", solve(n, ws)+1);
    }
}



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

bool check(int a, int b, int c){
    return (a < b+c && b < c+a && c < a+b);
}

int main() {
    int n, cnt = 0;
    cin >> n;
    vector<int> ls(n);
    rep(i,n) cin >> ls[i];
    sort(ls.begin(), ls.end());
    rep(i,n-2){
        for(int j = i+1; j < n-1; ++j){
            for(int k = j+1; k < n; ++k){
                if(check(ls[i], ls[j], ls[k])) cnt++;
            }
        }
    }
    cout << cnt << endl;
}


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

int n,m,k;

void work()
{
	scanf("%d %d %d",&n,&m,&k);
	for (int i=0; i<=n; i++)
		for (int j=0; j<=m; j++)
			if (i*m+j*n-2*i*j==k)
				puts("Yes"),exit(0);
	puts("No");
}

int main()
{
	work();
	return 0;
}


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

#if ((_WIN32 || __WIN32__) && __cplusplus < 201103L)
#define lld I64d
#else
#define lld lld
#endif

//{{{
using namespace std;
typedef long long LL;
typedef vector<int> VI;
#define pb push_back
#define all(x) (x).begin(), (x).end()
#define clr(a, b) memset(a, b, sizeof(a))
// clang-format off
#define debug(args...) {vector<string> _v = split(#args, ','); err(_v.begin(), args); cerr<<endl;}
vector<string> split(const string& s, char c) {vector<string> v; stringstream ss(s); string x; while
(getline(ss, x, c)) v.push_back(x); return v;} void err(vector<string>::iterator) {}
template<typename T, typename... Args> void err(vector<string>::iterator it, T a, Args... args)
{cerr << it -> substr((*it)[0] == ' ', it -> length()) << " = " << a << ", "; err(++it, args...);}
// clang-format on
//}}}

const int N = 1e5 + 10;
int T;
int n;

struct I
{
    LL w, s, v;
} item[1010];

bool cmp(const I& a, const I& b) { return a.s + a.w < b.s + b.w; }

LL dp[20010];

int main()
{
#ifdef LOCAL
    freopen("in", "r", stdin);
// freopen("out", "w", stdout);
#endif

    while (cin >> n)
    {
        for (int i = 1; i <= n; i++)
        {
            cin >> item[i].w >> item[i].s >> item[i].v;
        }
        sort(item + 1, item + 1 + n, cmp);

        clr(dp, -1);
        dp[0] = 0;

        for (int i = 0; i < n; i++)
        {
            LL w = item[i + 1].w;
            LL s = item[i + 1].s;
            LL v = item[i + 1].v;

            for (int j = 20000; j >= 0; j--)
            {
                if (dp[j] == -1) continue;
                if (j + w > 20000) continue;

                if (s >= j)
                {
                    dp[j + w] = max(dp[j + w], dp[j] + v);
                }
            }
        }
        LL ans = 0;
        for (int i = 0; i <= 20000; i++)
        {
            ans = max(ans, dp[i]);
        }
        cout << ans << endl;
    }

    return 0;
}


Measured memory_bytes: 3792
# -*- coding: utf-8 -*-
# Luis Yoichi Morales January 2019

from sys import stdin
import sys

def manhattan_dist(a, c):
    return  abs(a[0]-c[0]) + abs(a[1]-c[1])



N,M = map( int, raw_input().split() )
#print N, M


a=[]
c=[]
for i in range (N):
    a.append( map(int, stdin.readline().split()) )

for i in range (M):
    c.append( map(int, stdin.readline().split()) )

prev_dist=sys.maxint
index=[]
for i in range (N):
    for j in range (M):
        if prev_dist > manhattan_dist( a[i], c[j] ):
            index = (manhattan_dist( a[i], c[j] ), j+1 )
            prev_dist = manhattan_dist( a[i], c[j] )
    print index[1] 
    prev_dist=sys.maxint


Measured memory_bytes: 2696
#include <stdio.h>
int main()
{

   long long int N,K,X,Y,s;
    scanf("%lld %lld %lld %lld",&N,&K,&X,&Y);
    if (K<=N){
    s=K*X+(N-K)*Y;
    }
    else if (K>N){
        s=N*X;
    }
   printf("%lld\n",s);


return 0;
}


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

const long long mod = 1e9 + 7;

using ll = long long;
using pii  = pair<int, int>;
using pll = pair<ll, ll>;
#define ull unsigned long long
#define ld long double
#define vi vector<int>
#define vll vector<ll>
#define vc vector<char>
#define vs vector<string>
#define vpii vector<pii>
#define vpll vector<pll>

#define rep(i, n) for (int i = 0, i##_len = (n); i < i##_len; i++)
#define rep1(i, n) for (int i = 1, i##_len = (n); i <= i##_len; i++)
#define repr(i, n) for (int i = ((int)(n)-1); i >= 0; i--)
#define rep1r(i, n) for (int i = ((int)(n)); i >= 1; i--)

#define sz(x) ((int)(x).size())
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()

#define SORT(v, n) sort(v, v + n);
#define VSORT(v) sort(v.begin(), v.end());
#define RSORT(x) sort(rall(x));
#define pb push_back
#define mp make_pair

#define INF (1e9)
#define PI (acos(-1))
#define EPS (1e-10)

ull gcd(ull a, ull b) { return b ? gcd(b, a % b) : a; }
ull lcm(ull a, ull b) { return a / gcd(a, b) * b; }

int main(){
    int n, k;
    cin >> n >> k;
    vi a(n);
    rep(i, n) cin >> a[i];
    int mx = 0;
    rep(i, n) mx = max(mx, a[i]);
    double l = 0.0, r = mx;
    while (fabs(r-l) >= 1e-6) {
        double c = (l+r)/2.0;
        ll sum = 0;
        rep(i, n) sum += (ll)(a[i] / c);
        if (sum > k) l = c;
        else r = c;
    }
    cout << (ll)ceil(l) << endl;
    return 0;
}


Measured memory_bytes: 4052
import java.util.Scanner;

/**
 *
 * @author k16075kk
 */
public class Main {

    /**
     * @param args the command line arguments
     */
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int[] x = new int[n];
        int[] y = new int[n];
        for (int i = 0; i < n; i++) {
            x[i] = sc.nextInt();
        }
        for (int i = 0; i < n; i++) {
            y[i] = sc.nextInt();
        }
        for (int p = 1; p <= 3; p++) {
            double dis = 0.0;
            for (int i = 0; i < n; i++) {
                dis += Math.pow(Math.abs(x[i] - y[i]), p);
            }
            System.out.println(Math.pow(dis, 1.0 / p));
        }
        int max = 0;
        for (int i = 0; i < n; i++) {
            max = Math.max(max, Math.abs(x[i] - y[i]));
        }
        System.out.println(max);

    }

}



Measured memory_bytes: 26600
#include <iostream>
#include <string>
int main(void){
  std::string S;
  std::cin >> S;
  if ((int)S.find("a")>=0&&(int)S.find("b")>=0&&(int)S.find("c")>=0){
    std::cout << "Yes\n";
  }else{
    std::cout <<"No\n";
  }
}
  

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

int main(){
  int n,cnt=0;
  cin>>n;
  for(int i=0;i<n;i++){
    int a;
    cin>>a;
    while(a%2==0){
      cnt++;
      a/=2;
  }
  }
  cout<<cnt<<endl;
}

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

using namespace  std;

#define ll long long

#define DEBUG(x) cerr << '>' << #x << ':' << x << endl;


int main(){
   
  ll n,k,r,cnt=0;
  cin>>n>>k;
  for (int i = 0; i < n; ++i)
  {
    cin>>r;
    if(r>=k){
        cnt++;
    }
  }
  cout<<cnt;
 //cerr<<"\nTime Elapsed: " << 1.0*clock() / CLOCKS_PER_SEC << " sec\n";
    return 0;
} 

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
#define MD 1000000007
#define INF 1ll<<60
typedef pair<ll, ll> P;
template <typename T>
std::string tostr(const T &t){std::ostringstream os;os << t;return os.str();}
int dx[4]={1, 0, -1, 0}, dy[4]={0, 1, 0, -1};

int main(){
    int a,b;
    cin>>a>>b;
    int tap=0,aki=1;
    while(aki<b){
        aki--;
        tap++;
        aki+=a;
    }
    cout<<tap<<endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
//template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
//template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

/* attention
    long longのシフト演算には気をつけよう
    タイポした時のデバッグが死ぬほどきつくなるので変数名は最低3字くらい使った方がいいかも
*/

int main(){
    ll N; cin >> N;
    vector<ll> a(N), b(N);
    for(int i=0; i<N; i++) cin >> a[i];
    for(int i=0; i<N; i++) cin >> b[i];

    ll cnt = 0;
    for(int i=0; i<N; i++){
        if(a[i] < b[i]) cnt += (b[i]-a[i])/2;
        if(a[i] > b[i]) cnt -= a[i]-b[i];
    }

    if(cnt >= 0) cout << "Yes" << endl;
    else cout << "No" << endl;
}

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

int main() {
  long long n;
  long long ans=0;

  cin >> n;

  for(int i=1;i<=n;i++) {
    for(int j=i; j<=n; j+=i ) {
      ans += j;
      // cout << ans <<endl;
    }
  }

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 3620
#include<stdio.h>
int main(void){
	int a,b,c,d,i,j;
	while(scanf("%d%d",&a,&b) != EOF){
		c=a+b;
		for(i=0,d=1,j=10;j>9;i++,d*=10){
			j=c/d;
		}
		printf("%d\n",i);
	}
	return 0;
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
#define fi first
#define se second
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define rng(a) a.begin(),a.end()
#define sz(x) (int)(x).size()
#define uni(x) x.erase(unique(rng(x)),x.end())
#define show(x) cout<<#x<<" = "<<x<<endl;
#define PQ(T) priority_queue<T,v(T),greater<T> >
#define newline puts("")
#define v(T) vector<T>
#define vv(T) v(v(T))
#define chmin(x,y) x=min(x,y)
#define chmax(x,y) x=max(x,y)
#define EPS (1e-10)
#define equals(a, b) (fabs((a)-(b)) < EPS)
using namespace std;
typedef long long int ll;
typedef pair<int,int> P;
typedef set<int> S;
typedef queue<int> Q;
typedef queue<P> QP;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
typedef vector<double> vd;
typedef pair<double,double> PD;
typedef pair<int,P> ed;
const ll LINF = 1001002003004005006ll;
const int INF = 1001001001;
const int MOD = 1000000007;

vl ans;
void solve(ll k,ll N) {
  if(k<=1) return;
  ll a = N/k;
  ll r = N;
  while(r%k==0) r /= k;
  r--;
  if(r%k==0) {
    ans.push_back(k);
  }
}
int main() {
  ll N;
  cin >> N;
  for(ll k=1;k*k<=N-1;k++) {
    if((N-1)%k!=0) continue;
    ans.push_back(k);
    ans.push_back((N-1)/k);
  }
  for(ll k=1;k*k<=N;k++) {
    if(N%k!=0) continue;
    solve(k,N);
    solve(N/k,N);
  }
  sort(rng(ans));
  uni(ans);
  if(ans[0]==1) {
    cout << sz(ans)-1 << endl;
  } else {
    cout << sz(ans) << endl;
  }
  return 0;
}

Measured memory_bytes: 256
//abc073_c.cpp
//Sat May 26 14:04:31 2018

#include <iostream>
#include <string>
#include <queue>
#include <unordered_map>
#include <vector>
#include <algorithm>
using namespace std;

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

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

	sort (a,a+n);

	int count = 0;
	int ansnum = 0;
	int num = 0;
	int currnum = 0;

	while (currnum < n){
		num = a[currnum];
		count = 0;
		while (currnum<n && a[currnum]==num){
			currnum++;
			count++;
		}
		ansnum = ansnum + count%2;
	}

	cout << ansnum << endl;
}

Measured memory_bytes: 640
fun main(args: Array<String>) {
    readLine()
    val l = readLine()!!.split(" ").map { it.toInt() }.sorted()
    var a = 999999999
    for (i in l.first() .. l.last()){
        val tmp = l.map{ Math.abs(it - i) * Math.abs(it - i) }.sum()
        a = Math.min(a, tmp )
    }
    println(a)
}


Measured memory_bytes: 37868
N,M,X = map(int,input().split())
arr = []
for i in range(N):
    arr.append(list(map(int,input().split())))
cost = 10**9 + 7
for k in range(2**N):
    c = 0
    t = [0]*M
    for i in range(N):
        if (k >> i)%2 :
            c += arr[i][0]
            for j in range(M):
                t[j] += arr[i][j+1]
    if sum(x>=X for x in t) == M:
        cost = min(cost,c)
print(cost if cost < 10**9 + 7 else -1)

Measured memory_bytes: 9112
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n)  for(long long i=0;i<(long long)(n);i++)
#define REP(i,k,n) for(long long i=k;i<(long long)(n);i++)
#define all(a) a.begin(),a.end()
#define eb emplace_back
#define pb push_back
#define lb(v,k) (lower_bound(all(v),k)-v.begin())
#define ub(v,k) (upper_bound(all(v),k)-v.begin())
typedef long long ll;
typedef pair<ll,ll> P;
#define se second
#define fi first
struct PP{ll fi;ll se;ll th;};
typedef multiset<ll> S;
typedef priority_queue<ll> PQ;
typedef priority_queue<P,vector<P>,greater<P>> SPQ;
using vi=vector<ll>;
using vvi=vector<vector<ll>>;
const ll inf=1001001001001001;
const int INF=1001001001;
const int mod=1000000007;
bool chmin(auto &a,auto b){if(a>b){a=b;return true;}return false;}
bool chmax(auto &a,auto b){if(a<b){a=b;return true;}return false;}
void outvi(vi v){rep(i,v.size()){if(i)cout<<' ';cout<<v[i];}cout<<endl;}
void outvvi(vvi v){rep(i,v.size()){rep(j,v[i].size()){if(j)cout<<' ';cout<<v[i][j];}cout<<endl;}}
int main(){
    double a;cin>>a;
    ll k=(a+0.999)/1.08;
  if(a<=k*1.08&&k*1.08<a+1)cout<<k<<endl;
  else cout<<":("<<endl;
}

Measured memory_bytes: 256
n = 1
x = 1
loop do
cnt = 0
n, x = gets.split.map(&:to_i)
(1..n).each do |i|
  (i + 1..n).each do |j|
    (j + 1..n).each do |k|
      if i + j + k == x
        cnt += 1
      end
    end
  end
end
break if n == 0 && x == 0
p cnt
end


Measured memory_bytes: 6864
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
#define for1(i,n) for (ll i=0;i<(n);i++)
#define for2(i,m,n) for (ll i=(m);i<(n);i++)
#define for3(i,m,n,d) for (ll i=(m);i<(n);i+=(d))
#define DEBUG 0

ll solve()
{
    ll A,B,C,D;
    cin >> A >> B >> C >> D;
    A = max(A,C);
    B = min(B,D);
    if (A > B) {
        return 0;
    } else {
        return B - A;
    }
}

int main()
{
    do {
        cout << solve() << endl;
    } while (DEBUG);
}


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

void print( int* a );
void AND( int* a, int* b );
void OR( int* a, int* b );
void XOR( int* a, int* b );

int main()
{
    long long x, y;                    //整数の範囲を間違えない
    int bitx[32], bity[32];

    for( int i = 0; i < 32; i++ )
    {
        bitx[i] = 0;
        bity[i] = 0;
    }
    cin >> x >> y;

    int j = 0;
    while( x > 1 )
    {
        bitx[j] = x % 2;
        j++;
        x = x / 2;
    }
    int k = 0;
    while( y > 1 )
    {
        bity[k] = y % 2;
        k++;
        y = y / 2;
    }
    bitx[j] = x;                     //最後のbitを入れる(1)
    bity[k] = y;

    AND( bitx, bity );
    OR( bitx, bity );
    XOR( bitx, bity );

    return 0;
}

void print( int* a )
{
    for( int i = 0; i < 32; i++ )
        cout << a[31-i];
    cout << endl;
}

void AND( int* a, int* b )
{
    int x[32];
    for( int i = 0; i < 32; i++ )
    {
        if( a[i] == 1 && b[i] == 1 )
            x[i] = 1;
        else
            x[i] = 0;
    }
    print( x );
}

void OR( int* a, int* b )
{
    int x[32];
    for( int i = 0; i < 32; i++ )
    {
        if( a[i] == 0 && b[i] == 0 )
            x[i] = 0;
        else
            x[i] = 1;
    }
    print( x );
}

void XOR( int* a, int* b )
{
    int x[32];
    for( int i = 0; i < 32; i++ )
    {
        if( a[i] == b[i] )
            x[i] = 0;
        else
            x[i] = 1;
    }
    print( x );
}


Measured memory_bytes: 3112
#include<algorithm>//sort,二分探索,など
#include<bitset>//固定長bit集合
#include<cmath>//pow,logなど
#include<complex>//複素数
#include<deque>//両端アクセスのキュー
#include<functional>//sortのgreater
#include<iomanip>//setprecision(浮動小数点の出力の誤差)
#include<iostream>//入出力
#include<map>//map(辞書)
#include<numeric>//iota(整数列の生成),gcdとlcm(c++17)
#include<queue>//キュー
#include<set>//集合
#include<stack>//スタック
#include<string>//文字列
#include<unordered_map>//イテレータあるけど順序保持しないmap
#include<unordered_set>//イテレータあるけど順序保持しないset
#include<utility>//pair
#include<vector>//可変長配列
using namespace std;

typedef long long ll;

//マクロ
#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=(ll)(n)-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=(a);i<=(b);i++)
#define FORD(i,a,b) for(ll i=(a);i>=(b);i--)
#define ALL(x) (x).begin(),(x).end() //sortなどの引数を省略したい
#define SIZE(x) ((ll)(x).size()) //sizeをsize_tからllに直しておく
#define MAX(x) *max_element(ALL(x))
#define INF 1000000000000 //10^12
#define MOD 10000007 //10^9+7
#define MAXR 100000 //10^5:最大のrange(素数列挙などで使用)

int memo[201][201];

int gcd(int a, int b)
{
   if(memo[a][b] != -1) {
       return memo[a][b];
   }
   if (a%b == 0)
   {
       memo[a][b] = b;
       memo[b][a] = b;
       return(b);
   }
   else
   {
       return(gcd(b, a%b));
   }
}

int main(void){
    int K;
    cin >> K;
    
    REP(i, 201) {
        REP(j, 201) {
            memo[i][j] = -1;
        }
    }
    
    ll sum = 0;
    REP(i, K) {
        REP(j, K) {
            REP(k, K) {
               sum += gcd(gcd(i+1, j+1), k+1);
               //cout << i << j << k << endl;
               //cout << sum << endl;
            }
        }
    }
    cout << sum << endl;
    return 0;
}


Measured memory_bytes: 3788
import sys
input = sys.stdin.readline

n, k = [int(x) for x in input().split()]
a = [int(x) for x in input().split()]

visited = set()
visited.add(0)
now = 0
route = [0]

for i in range(1, n + 5):
    now = a[now] - 1
    if now in visited:
        break
    route.append(now)
    visited.add(now)

start = route.index(now)
loop = i - start

if k <= start:
    print(route[k] + 1)
else:
    k -= start
    k %= loop
    route = route[start:]
    print(route[k] + 1)




Measured memory_bytes: 132004
#[allow(unused_imports)]
use std::cmp::*;
#[allow(unused_imports)]
use std::collections::*;
#[allow(unused_imports)]
use std::io::{Write, BufWriter};

// https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8
#[allow(unused_macros)]
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)*}
    };
}

#[allow(unused_macros)]
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)*}
    };
}

#[allow(unused_macros)]
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! (
        n: usize,
        m: usize,
        t: [usize; n],
    );
    let mut ans = (m * n) as i64;
    for i in 0..n-1 {
        let tmp = max(0i64, (m + t[i]) as i64 - t[i+1] as i64);
        ans -= tmp;
    }
    println!("{}", ans);
}

Measured memory_bytes: 6396
import heapq
import sys
n, m, s, t = [int(i) for i in input().split()]
s -= 1
t -= 1
snuuk_dict = dict()
yen_dict = dict()
snuuk_que = []
yen_que = []
for i in range(m):
    u, v, a, b = [int(i) for i in sys.stdin.readline().split()]
    u -= 1
    v -= 1
    if snuuk_dict.get(u) is None:
        snuuk_dict[u] = []
        yen_dict[u] = []
    if snuuk_dict.get(v) is None:
        snuuk_dict[v] = []
        yen_dict[v] = []
    snuuk_dict[u].append([b, u, v])
    snuuk_dict[v].append([b, v, u])
    yen_dict[u].append([a, u, v])
    yen_dict[v].append([a, v, u])

for i in snuuk_dict[t]:
    heapq.heappush(snuuk_que, i)
for i in yen_dict[s]:
    heapq.heappush(yen_que, i)
snuuk_ls = [-1 for i in range(n)]
yen_ls = [-1 for i in range(n)]
yen_ls[s] = 0
snuuk_ls[t] = 0
while len(yen_que) > 0:
    a, u, v = heapq.heappop(yen_que)
    if yen_ls[v] != -1:
        continue
    yen_ls[v] = a
    for i in yen_dict[v]:
        if yen_ls[i[2]] == -1:
            heapq.heappush(yen_que, [i[0] + yen_ls[v], i[1], i[2]])
while len(snuuk_que) > 0:
    b, v, u = heapq.heappop(snuuk_que)
    if snuuk_ls[u] != -1:
        continue
    snuuk_ls[u] = b
    for i in snuuk_dict[u]:
        if snuuk_ls[i[2]] == -1:
            heapq.heappush(snuuk_que,  [i[0] + snuuk_ls[u], i[1], i[2]])
sum_ls = [10** 15 - (i + j) for i, j in zip(snuuk_ls, yen_ls)]
_max = 0
for i in range(n):
    _max = sum_ls[-1-i] if sum_ls[-1-i] > _max else _max
    sum_ls[-i-1] = _max
for i in range(n):
    print(sum_ls[i])

Measured memory_bytes: 103112
//============================================================================
// Name        : DPTest.cpp
// Author      :
// Version     :
// Copyright   : Your copyright notice
// Description : Hello World in C++, Ansi-style
//============================================================================

#include <iostream>
using namespace std;
int N,M,K;
int A[20001]={};
const long long INF=100000000000000;
long long dp[20001]={};
int maxdp[20001][1001]={};
int mindp[20001][1001]={};

int maxD(int n2,int n3){
	int ans2=A[n2+n3];
	if(maxdp[n2][n3]>0)return maxdp[n2][n3];
	if(n3>1)ans2=max(maxD(n2,n3-1),A[n2+n3]);
	maxdp[n2][n3]=ans2;
	return ans2;
}
int minD(int n2,int n3){
	int ans2=A[n2+n3];
	if(mindp[n2][n3]>0)return mindp[n2][n3];
	if(n3>1)ans2=min(minD(n2,n3-1),A[n2+n3]);
	mindp[n2][n3]=ans2;
	return ans2;
}

long long calc(int n1){
	long long ans=INF;
	if(dp[n1]>-1)return dp[n1];
	for(int i=1;i<M+1&&i<n1+1;i++){
		ans=min(ans,calc(n1-i)+(long long)K+(long long)i*(long long)(maxD(n1-i,i)-minD(n1-i,i)));
	}
	dp[n1]=ans;
	return ans;
}
int main() {
	cin>>N>>M>>K;
	for(int i=1;i<N+1;i++)cin>>A[i];
	fill(dp,dp+20001,-1);
	dp[0]=0;
	cout<<calc(N)<<endl;
	return 0;
}



Measured memory_bytes: 161004
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define TEST int t = 1; while(t--) solve()

void solve(){
    long double a,b;
    cin>>a>>b;
    a=a*b;
    int t=(int)a;
    cout<<t<<"\n";

}

signed main(){
    ios_base::sync_with_stdio(false); 
    cin.tie(NULL); TEST; return 0;
}


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

int main() {
    int N, M;
    vector<pair<int, int>> v;
    cin >> N >> M;
    for (int i = 0; i < M; ++i){
        int a, b;
        cin >> a >> b;
        v.push_back(make_pair(b, a));
    }
    sort(v.begin(), v.end());

    int ans = 0;
    int cut = 0;
    for (int i = 0; i < M; ++i){
        auto p = v[i];
        int a = p.second;
        int b = p.first; 
        if (cut < a){
            ans++;
            cut = b-1;
        }
    }
    cout << ans << endl;


    return 0;
}


Measured memory_bytes: 1400
#include <stdio.h>

int main()
{
	int max[3] = {0, }, height[10], i;
	
	for (i = 0; i <= 9; i++) {
		scanf("%d", height + i);
	}
	
	for (i = 0; i <= 9; i++) {
		if (height[i] > max[0]) {
			max[2] = max[1];
			max[1] = max[0];
			max[0] = height[i];
		} else if (height[i] > max[1]) {
			max[2] = max[1];
			max[1] = height[i];
		} else if (height[i] > max[2]) {
			max[2] = height[i];
		}
	}
	
	for (i = 0; i <= 2; i++) {
		printf("%d\n", max[i]);
	}
	
	return 0;
}

Measured memory_bytes: 0
/*5
	WEEWW*/
	#include<cstdio>
    #include<cstring>
    #include<algorithm>
    #include<climits>
    using namespace std;
    #define MAXN 300000
    int lens,wn,en;
    int a[MAXN+5];
    char s[MAXN+5];
    int main()
    {
    	int maxn=INT_MAX;
    	scanf("%d",&lens);
    	scanf("%s",s);
    	for(int i=0;i<lens;i++)
    	{
    		if(s[i]=='W') wn++;
    		if(s[i]=='E') en++;
    		a[i]=wn;
    	}
    	int t;
    	for(int i=0;i<lens;i++)
    	{
    		t=0;
    		if(s[i]=='W')t=1;	
    		maxn=min(maxn,a[i]-t+en-(i+1-a[i]));
    		//printf("i:%d a[i]:%d en:%d %d %d\n",i,a[i],en,a[i]-t+en-(i+1-a[i]),maxn);
    	}
    	printf("%d",maxn);
    }

Measured memory_bytes: 1664
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<algorithm>
using namespace std;
char s[101010];
int la[101];
int main()
{
	int l;
	for(int i=0;i<26;i++)
		la[i]=-100;
	scanf("%s",s+1);
	l=strlen(s+1);
	for(int i=1;i<=l;i++)
	{
		if(i-la[s[i]-'a']<=2)
		{
			printf("%d %d",la[s[i]-'a'],i);
			return 0;
		}
		la[s[i]-'a']=i;
	}
	printf("-1 -1");
	return 0;
}

Measured memory_bytes: 384
#include<stdio.h>
#include<math.h>
#define N 100
typedef long long Int;
typedef struct Point{ Int x,y; } point;
Int inner(point a,point b){ return a.x*b.x+a.y*b.y; }
Int det(point a,point b){ return a.x*b.y-a.y*b.x; }
double norm(point a){ return sqrt(inner(a,a)); }
point add(point a,point b){ return (point){ a.x+b.x, a.y+b.y }; }
point sub(point a,point b){ return (point){ a.x-b.x, a.y-b.y }; }
double max(double a,double b){ return (a<b)?b:a; }
int main(void){
    Int i,j,k,n,m,Det;
    double maxi;
    point vec[N],polygon[2*N],tmp[2*N];
    scanf("%lld",&n);
    for(i=0;i<n;i++) scanf("%lld %lld",&vec[i].x,&vec[i].y);
    for(i=0;i<n;i++) if(norm(vec[i])) break;
    maxi = 0;
    if(i<n){
        m = 2;
        polygon[0] = (point){0,0};
        polygon[1] = vec[i];
        for(i++;i<n;i++) if(norm(vec[i])) {
            for(j=0;j<m;j++) if(det(sub(polygon[(j+1)%m],polygon[j]),vec[i])>=0) break;
            while(1){
                Det = det(sub(polygon[(j+1)%m],polygon[j]),vec[i]);
                if( Det<=0 && ( Det<0 || inner(sub(polygon[(j+1)%m],polygon[j]),vec[i])>0 ) ) break;
                j = (j+1)%m;
            }
            if(Det==0) for(k=1;k<=m/2;k++) polygon[(j+k)%m] = add(polygon[(j+k)%m],vec[i]);
            else {
                tmp[0] = polygon[j];
                for(k=0;k<=m/2;k++) tmp[k+1] = add(polygon[(j+k)%m],vec[i]);
                for(k=0;k<m/2;k++) tmp[m/2+2+k] = polygon[(j+k+m/2)%m];
                for(k=0;k<m+2;k++) polygon[k] = tmp[k];
                m+=2;
            }
        }
        for(i=0;i<m;i++) maxi = max(maxi,norm(polygon[i]));
    }
    printf("%.15lf\n",maxi);
    return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  cin >> n;
  vector<int> H(n);
  for(int i=0;i<n;i++){
    cin >>H.at(i);
  }
  vector<int> dp(n);
  dp.at(1) = abs(H.at(1)-H.at(0));
  for(int i=2;i<n;i++){
    int can_1 = dp.at(i-1)+abs(H.at(i)-H.at(i-1));
    int can_2 = dp.at(i-2)+abs(H.at(i)-H.at(i-2));
    dp.at(i) = min(can_1,can_2);
  }
  cout << dp.at(n-1) << endl;
}
    
    
    

Measured memory_bytes: 1024
#include <iostream>
#include <string>
#include <cstdio>
#include <algorithm>
#include <cstdlib>
#include <cmath>
#include <vector>
#include <utility>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <bitset>
using namespace std;
#define INF 1000000007
#define LINF 8000000000000000007
#define MOD 1000000007
#define int long long
#define rep(i, n) for (int i = 0; i < (n); i++)
#define repb(i, n) for (int i = n - 1; i >= 0; i--)
#define MODE 1
#ifdef MODE
#define DEB(X) cout << #X << ": " << X << " ";
#define ARDEB(i, X) cout << #X << "[" << i << "]: " << X[i] << " ";
#define END cout << endl;
#else
#define DEB(X) \
    {          \
    }
#define ARDEB(i, X) \
    {               \
    }
#define END \
    {       \
    }
#endif
typedef pair<int, int> P;
struct edge{int to,cost;};

typedef long long ll;

using namespace std;


int ans=1,ans2;
int n,m;
signed main(){

	string s,t;
	cin>>n>>s>>t;
	rep(i,n){
		int f=true,co=0;
		for(int j=i;j<n;j++){
			if(s[j]!=t[j-i])f=false;
			co++;
		}
		if(f){
			cout<<n*2-co<<endl;
			return 0;
		}
	}

	cout<<n*2<<endl;
	
}

Measured memory_bytes: 256
import scala.collection.mutable.TreeSet
import scala.io.Source
object Main {
  val lines = Source.stdin.getLines.toStream.map(_.toInt)
  val n = lines.head
  val inArr = lines.tail.toArray

  def main(args: Array[String]) = {
    val st = TreeSet[(Int, Int)]()
    var color = 1

    for (i <- 0 until n) {
      val it = st.iteratorFrom((-(inArr(i)-1), 0))
      if (it.hasNext) {
        val (locMax, num) = it.next
        st -= ((locMax, num))
        st += ((-inArr(i), num))
      } else {
        st += ((-inArr(i), color))
        color = color+1
      }
    }
    println(st.size)
  }
}


Measured memory_bytes: 128608
import sys

def primes(n):
    ps = []
    table = [True] * n
    table[0] = False
    for i in range(n):
        if table[i]:
            for j in range(2 * (i + 1) - 1, n, i + 1):
                table[j] = False
    for i in range(n):
        if table[i]:
            ps.append(i + 1)
    return ps

for line in sys.stdin:
    n = int(line)
    print(len(primes(n)))

Measured memory_bytes: 19000
# この問題の解説ブログはこちら https://ysk-pro.hatenablog.com/entry/abc168-e-bullet

MOD = 1000000007
N = gets.chomp.to_i

group = Hash.new(0)
worst_iwashi_count = 0 # 最悪のイワシを管理する変数

N.times do |i|
  a, b = gets.chomp.split.map(&:to_i)

  if a == 0 && b == 0 # 最悪のイワシのケース
    worst_iwashi_count += 1
    next
  end

  if a == 0 # A = 0 のイワシのケース
    group[[0, -1]] += 1
    next
  end

  if b == 0 # A = 0 のイワシのケース
    group[[1, 0]] += 1
    next
  end

  # 最大公約数でそれぞれを割る
  gcd = a.gcd(b)
  a /= gcd
  b /= gcd

  # 正負を揃える
  if a < 0
    a *= -1
    b *= -1
  end

  group[[a, b]] += 1
end

ans = 1

group.each do |(a, b), count|
  # ペアとなるグループに含まれるイワシの数を数える
  # ペアとして計算されたグループは、重複して計算されることを防ぐために削除する
  if b < 0
    pair_count = group[[-b, a]]
    group.delete([-b, a])
  else
    pair_count = group[[b, -a]]
    group.delete([b, -a])
  end

  ans *= (2 ** count - 1) + (2 ** pair_count - 1) + 1
  ans %= MOD
end

p (ans + worst_iwashi_count - 1) % MOD


Measured memory_bytes: 35320
import java.util.*;

public class Main {

	public static void addorder(String ans[], String t) {
		String tar = t.substring(0);
		int a = ans.length;
		for (int i = 0; i < a; ++i) {
			if (ans[i] == null) {
				ans[i] = tar.substring(0);
				break;
			}else {
				String tmp = ans[i];
				if (tmp.equals(tar))
					break;
				else if (tmp.compareTo(tar) > 0) {
					ans[i] = tar.substring(0);
					tar = tmp.substring(0);
				}
			}
		}
	}

	public static String solve(String s, int k) {
		String ans = "";
		int n = s.length();
		char tmp[] = s.toCharArray();
		Arrays.sort(tmp);
		char min = tmp[0];

		List<Character> tmp2 = new ArrayList<Character>();
		tmp2.add(min);
		for (int i = 0; i < n; ++i) {
			if (tmp[i] != min) {
				tmp2.add(tmp[i]);
				min = tmp[i];
			}
		}

		String a[] = new String[k];
		for (int i = 0; i < tmp2.size(); ++i) {
			min = tmp2.get(i);
			List<Integer> list = new ArrayList<Integer>();
			for (int j = 0; j < n; ++j) {
				if (s.charAt(j) == min)
					list.add(j);
			}
			for (int j = 0; j < list.size(); ++j) {
				int m = list.get(j);
				for (int l = 1; l <= k; ++l) {
					if (l + m > n)
						break;
					String t = s.substring(m, m + l);
					addorder(a, t);
				}
			}
			if (a[k - 1] != null) {
				ans = a[k - 1].substring(0);
				break;
			}
		}
		return ans;
	}

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String s = sc.next();
		int k = sc.nextInt();
		sc.close();
		String ans = solve(s, k);
		System.out.println(ans);
	}

}


Measured memory_bytes: 25216
#include <iostream>
#include <algorithm>
#include <string>
#include <math.h>
#include <cstdint>
#include <vector>
 
using namespace std;
typedef long long ll;


ll ans,mx,mn,sum;
int main(){
	int x,t;
	cin>>x>>t;
	if(x-t>=0)cout<<x-t;
	else cout<<0;
}


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

using namespace std;
using ll = long long;

int n;
vector<vector<pair<int,int>>> hen;
vector<int> col;

void dfs(int v, int par) {
    for(auto i : hen[v]) {
        if(i.first == par)continue;
        col[i.first] = (i.second % 2 ? !col[v] : col[v]);
        dfs(i.first, v);
    }
}

int main()
{
    cin >> n;
    hen.resize(n), col.resize(n);
    for(int i = 0; i < n - 1; i++) {
        int a, b, c; cin >> a >> b >> c; a--, b--;
        hen[a].emplace_back(b, c);
        hen[b].emplace_back(a, c);
    }

    dfs(0, -1);
    for(auto i : col)cout << i << endl;
}

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

int main(){
    int n; vi v;
    int cnt = 0;
    scanf("%d", &n); v.resize(n);
    for(int i=0;i<n;i++){
        scanf("%d", &v[i]);
        cnt += (v[i]-1 != i);
    }
    printf(cnt<=2? "YES\n" : "NO\n");
}

Measured memory_bytes: 256
S = input()

flg = 0
for i in range(len(S)):
    if i%2==0:
        if S[i]!='R' and S[i]!='U' and S[i]!='D':
            flg=1
    else:
        if S[i]!='L' and S[i]!='U' and S[i]!='D':
            flg=1

if flg==1:
    print('No')
else:
    print('Yes')

Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
void dfs(vector<int> &d, vector<string> &M, vector<vector<int>> &c, int v = 0){
  for (int i = 0; i < d[v]; i++){
    cout << '.';
  }
  cout << M[v];
  cout << endl;
  for (int w : c[v]){
    d[w] = d[v] + 1;
    dfs(d, M, c, w);
  }
}
int main(){
  int n;
  cin >> n;
  vector<int> k(n);
  vector<string> M(n);
  for (int i = 0; i < n; i++){
    cin >> k[i] >> M[i];
    k[i]--;
  }
  vector<vector<int>> c(n);
  for (int i = 1; i < n; i++){
    c[k[i]].push_back(i);
  }
  vector<int> d(n);
  d[0] = 0;
  dfs(d, M, c);
}


Measured memory_bytes: 3476
#define _USE_MATH_DEFINES 
#include <iomanip> 
#include <cmath>  
#include<iostream>
#include <fstream>
#include<vector>
#include<algorithm>
#include<bitset>
#include<map>
#include<queue>
#include<stack>
using namespace std;
typedef long long ll;
#define repi(i,a,b) for(ll i = (ll)(a) ; i < (ll)(b) ; i++)
#define repd(i,a,b) for(ll i = (ll)(a) ; i > (ll)(b) ; i--)
#define rd(x) cin >> x
#define wr(x)  cout << x
#define wrln(x) cout << x << endl

int N, t, ansMin, ansMax;
int colors[10];

int main() {
	cin >> N;
	repi(i, 0, N) {
		rd(t);
		repi(j, 1, 9) {
			if (t < 400 * j) {
				colors[j - 1]++;
				break;
			}
			if (j == 8) colors[8]++;
		}
	}
	repi(i, 0, 8) {
		if (colors[i] > 0) ansMin++;
	}
	ansMax = ansMin + colors[8];
	if (ansMin == 0 && colors[8] > 0) ansMin = 1;

	cout << ansMin << " " << ansMax << endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long int
#define ld long double
#define ull unsigned long long int
#define forn(i,n)for(ll i=0;i<(n);i++)
#define forn_rev(i,n)for(ll i=(n)-1;i>=0;i--)
#define for1n(i,n) for(ll i=1;i<=(n);i++)
#define ARRAY_SIZE(a) sizeof(a)/sizeof(*a)
#define MOD 1000000007
#define MAXN 1000005

using namespace std;


int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(NULL); cout.tie(NULL);
    ll T=1;
    //cin>>T;
    while(T--)
    {


       ll N;
       cin>>N;
       map<string,bool> mp;
       forn(i,N){
        string s;
        cin>>s;
        mp[s]=1;;
       }
       cout<<mp.size()<<endl;







    }



    return 0;
}

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

#define int long long
#define vi vector <int>
#define endl "\n"
#define vvi vector <vector<int> >
#define vii vector <pair<int,int> >
#define rep(i,a,b) for (int i=a;i<b;i++)
#define repD(i,a,b) for (int i=a;i>=b;i--)
#define speed ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define init(i,k) memset(i,k,sizeof i)
#define pb push_back
#define pii pair <int,int>
#define ff first
#define ss second
#define all(a) a.begin(),a.end()
const int N=3e3+5 , MOD=1e9+7;

// vector<vector<string> > dp(N, vector<string>(N,""));
// string dp[2][N]={""};

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


void solve()
{
    string f,s;
    cin >> f >> s;
    f = '*'+f;
    s = '*'+s;
    int n1 = f.size(), n2 = s.size(), t=1;
    
    vector<vector<string> > dp(2, vector<string>(n2,""));
    rep(i,1,n1)
    {
    	rep(j,1,n2)
    	{
    		if(f[i]==s[j])
    		{
    			dp[t][j] = dp[t^1][j-1] + s[j];
    		}
    		else
    		{
    			int x=dp[t][j-1].size(), y=dp[t^1][j].size(), z=dp[t^1][j-1].size();
    			if(x>=y && x>=z)
    				dp[t][j] = dp[t][j-1];
    			else if(y>=z && y>=x)
    				dp[t][j] = dp[t^1][j];
    			else
    				dp[t][j] = dp[t^1][j-1];
    		}
    	}
    	t ^= 1;
    }

    cout << dp[t^1][n2-1] << endl;
}

signed main()
{
    speed;
    
 //    int t; cin >> t;
 //    rep(tt,1,t+1)
 //    {
	// cout <<"Case #"<<tt<<": ";
	solve();
 //    }
    return 0;
}

Measured memory_bytes: 18712
# ???????¨????????????£????????????
def area(x1, y1, x2, y2, x3, y3)
  a = Math.sqrt((x1 - x2)**2 + (y1 - y2)**2)
  b = Math.sqrt((x2 - x3)**2 + (y2 - y3)**2)
  c = Math.sqrt((x3 - x1)**2 + (y3 - y1)**2)
  s = (a + b + c)/2.0
  Math.sqrt(s*(s - a)*(s - b)*(s - c))
end

while gets do
  x1, y1, x2, y2, x3, y3, xp, yp = $_.chomp.split(' ').map(&:to_f)
  s_all = area(x1, y1, x2, y2, x3, y3)
  s_1 = area(x1, y1, x2, y2, xp, yp)
  s_2 = area(x2, y2, x3, y3, xp, yp)
  s_3 = area(x1, y1, x3, y3, xp, yp)
  puts (s_all - s_1 - s_2 - s_3).abs <= 0.00001 ? 'YES' : 'NO'
end

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

using namespace std;

#define long long long
#define INF ((long) 2e18)
#define MOD ((long) (1e9 + 7))
#define umap unordered_map

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

    long t = 1;
    //cin >> t;

    while (t--) {
        long n;
        string s;
        cin >> n >> s;

        long count = 0;
        for (long i = 0; i < n - 2; i++) {
            count += s.substr(i, 3) == "ABC";
        }
        printf("%lld\n", count);
    }
}


Measured memory_bytes: 3736
S = input()

if S == "zyxwvutsrqponmlkjihgfedcba":
    print(-1)
else:

    code = list(map(lambda x : ord(x) - ord('a'), list(S)))

    done = False
    for i in range(26):
        if not i in code:
            code.append(i)
            done = True
            break


    while len(code) > 0 and not done:
        last = code[-1]
        code = code[:-1]
        if last == 25:
            continue
        else:
            for i in range(last+1, 26):
                if i not in code:
                    code.append(i)
                    done = True
                    break


    decode = list(map(lambda x : chr(x + ord('a')), code))
    print(''.join(decode))

Measured memory_bytes: 3064
//Mahir Ratanpara (DA-IICT)
#include<bits/stdc++.h>
using namespace std;
#define Ff(i,a,n) for(i=a;i<n;i++)
#define Fr(i,a,n) for(i=a;i>n;i--)
#define ll long long
#define FAST ios_base::sync_with_stdio(false),cin.tie(0),cout.tie(0);
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define all(x) x.begin(), x.end()
#define clr(x) memset(x, 0, sizeof(x))
#define sortall(x) sort(all(x))
#define tr(it, a) for(auto it = a.begin(); it != a.end(); it++)
typedef pair<ll, ll>	pa;
typedef vector<ll>		vc;
typedef vector<pa>		vp;
typedef vector<vc>		vvc;
int mpow(int base, int exp); 
void ipgraph(int m);
void dfs(int u, int par);
const int mod = 1000000007;
const int N = 3e5, M = N;
//=======================

vc g[N];
ll a[N];

int main() {
    FAST;
    ll t, i, j, k, p, q, r, x, y, u, v, n, m;
    string s1,s2;
    cin>>s1>>s2;

    Ff(i,0,s1.size())
    {
      if(s1[i]!=s2[i])
      {
        cout<<"No";
        return 0;
      }
    }
    cout<<"Yes";
    return 0;
}

int mpow(int base, int exp) {
  base %= mod;
  int result = 1;
  while (exp > 0) {
    if (exp & 1) result = ((ll)result * base) % mod;
    base = ((ll)base * base) % mod;
    exp >>= 1;
  }
  return result;
}

void ipgraph(int n, int m){
	int i, u, v;
	while(m--){
		cin>>u>>v;
		g[u-1].pb(v-1);
		g[v-1].pb(u-1);
	}
}

void dfs(int u, int par){
	for(int v:g[u]){
		if (v == par) continue;
		dfs(v, u);
	}
}

Measured memory_bytes: 10684
#include <bits/stdc++.h>
 using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
 int main(){
   int n;
   cin>>n;
   vector<char> s(n);
   vector<char> t(n);
   rep(i,n)cin>>s.at(i);
   rep(i,n)cin>>t.at(i);
   rep(i,n){
    cout<<s.at(i)<<t.at(i);
   }
   cout<<endl;
     

}


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

class Main{
	public static void main(String[] args) throws IOException{
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		int n = Integer.parseInt(br.readLine());
		String[] str = br.readLine().split(" ");
		Set<Integer> S = new TreeSet<Integer>();
		for(int i = 0; i < n; i++){
			S.add(Integer.parseInt(str[i]));
		}
		int m = Integer.parseInt(br.readLine());
		str = br.readLine().split(" ");
		for(int i = 0; i < m; i++){
			S.remove(Integer.parseInt(str[i]));
		}
		for(Integer num : S) System.out.println(num);
	}
}



Measured memory_bytes: 107700
//compiledef
#include <bits/stdc++.h>
#define rep(i, n) for(i=0;i<(n);i++)
#define per(i, n) for(i=(n-1);i>=0;i--)
#define repx(i, n, x) for(i=(x);i<(n);i++)
#define xper(i, n, x) for(i=(n-1);i>(x);i--)
#define pb push_back

//c++def
using namespace std;
typedef long long int ll;
const ll MOD = 1e9+7;
const ll MOD2 = 998244353;
int cnt;
int gc;
int m;
vector<int> A;
vector<int> G;
void issort(int n, int g){
	int i, j;
	int tmp;
	repx(i, n, g){
		tmp = A[i];
		j = i - g;
		while(j >= 0 &&A[j] > tmp){
			A[j+g] =A[j];
			j -= g;
			cnt++;
		}
		A[j+g] =tmp;
#ifdef DBG
		int k;
		rep(k, n)printf("%d ", A[k]);
		printf("\n");
#endif

	}
}

void shsort(int n){
	static int mq = 1;
	m=n;
	if(n==1){
		G.pb(1);
		issort(n, 1);
		gc++;
	}else
		while(m != 1){
			if(mq%2==1||m == 2){
				m /= 2;
			}else if(mq%2 == 0 || m == 3){
				m /= 3;
			}
				G.pb(m);
				issort(n, m);
				gc++;
		}
}

int main(){
	int i;
	int tmp;
	int n;
	scanf("%d", &n);
	rep(i, n){
		scanf("%d", &tmp);
		A.pb(tmp);
	}
	shsort(n);
	printf("%d\n", gc);
	rep(i, gc){	
		printf("%d", G[i]);
		if(i!=n-1) printf(" ");
	}
	printf("\n");
	printf("%d\n", cnt);
	rep(i, n){
		printf("%d\n", A[i]);
	}
}



Measured memory_bytes: 7060