akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <vector>
#include <set>
#include <queue>

struct Person {
    unsigned int index;
    unsigned int candidates;
    std::set<int> friends, blocked;
    bool operator<(const Person& other) const {
        return index < other.index;
    }
};

typedef std::vector<Person> Graph;
typedef std::vector<std::set<int>> Group;
const int N = (int) (1e5 + 10);

void bfs(const Graph& g, bool* visited, std::set<int>& group, int start) {
    std::queue<int> q;
    q.emplace(start);
    while (!q.empty()) {
        int cur = q.front();
        q.pop();
        if (visited[cur]) {
            continue;
        }
        visited[cur] = true;
        group.emplace(cur);
        for (int person : g[cur].friends) {
            if (!visited[person]) {
                q.emplace(person);
            }
        }
    }
}

int main() {
    std::ios_base::sync_with_stdio(false);
    std::cin.tie(nullptr);
    std::cout.tie(nullptr);

#if DEBUG_ON
    freopen("input", "r", stdin);
#endif

    int n, m, k;
    std::cin >> n >> m >> k;
    Graph g(n + 1);
    for (int i = 0; i < n; ++i) {
        g[i].index = i;
    }
    for (int i = 0; i < m; ++i) {
        int u, v;
        std::cin >> u >> v;
        g[u].friends.emplace(v);
        g[v].friends.emplace(u);
    }
    for (int i = 0; i < k; ++i) {
        int u, v;
        std::cin >> u >> v;
        g[u].blocked.emplace(v);
        g[v].blocked.emplace(u);
    }
    Group groups(n + 1);
    int groupIndex = 0;
    bool visited[N] = { false };
    for (int i = 1; i < n; ++i) {
        if (!visited[i]) {
            bfs(g, visited, groups[groupIndex++], i);
        }
    }
    for (int i = 0; i < groupIndex; ++i) {
        for (int member : groups[i]) {
            g[member].candidates = groups[i].size() - (1 + g[member].friends.size());
            for (int blocked : g[member].blocked) {
                if (groups[i].count(blocked) && !g[member].friends.count(blocked)) {
                    --g[member].candidates;
                }
            }
        }
    }
    for (int i = 1; i <= n; ++i) {
        std::cout << g[i].candidates << ' ';
    }
    std::cout << '\n';
    return 0;
}

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

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

int main() {
    int H, W;
    cin >> H >> W;
    vector <string> vec(H);
    for (int i = 0; i < H; ++i) {
        cin >> vec.at(i);
    }
    string txt;
    for (int k = 0; k < W + 2; ++k) {
        txt += "#";
    }
      for (int j = 0; j <= H; ++j) {
        if (j == 0) {
            cout << txt << endl;
        } else {
            cout << "#" << vec.at(j-1) << "#" << endl;
        }
    }
              cout << txt << endl;

}



Measured memory_bytes: 256
#include <cstdio>           // printf(), scanf()
#include <cstdlib>          // abs()

static const double EPS = 1e-10;

double
add(double a, double b)
{
//	if (abs(a + b) < EPS * (abs(a) + abs(b)))
//		return 0;

	return a + b;
}

class Point
{
public:
	double x, y;

	Point(double x = 0, double y = 0): x(x), y(y) {}
	Point operator + (Point p) { return Point(add(x, p.x), add(y, p.y)); }
	Point operator - (Point p) { return Point(add(x, -p.x), add(y, -p.y)); }
	Point operator * (double a) { return Point(a * x, a * y); }
	Point operator / (double a) { return Point(x / a, y / a); }
};

struct Segment
{
	Point p1, p2;
};

typedef Point Vector;
typedef Segment Line;

double
norm(Vector a)
{
	return add(a.x * a.x, a.y * a.y);
}

double
dot(Vector a, Vector b)
{
	return add(a.x * b.x, a.y * b.y);
}

Point
project(Segment s, Point p)
{
	Vector base = s.p2 - s.p1;
	double r = dot(p - s.p1, base) / norm(base);
	return s.p1 + base * r;
}

int
main(int argc, char** argv)
{
	Segment s;
	Point p, a;
	int q;
	int x, y;
	int x1, y1, x2, y2;
	int i;

	scanf("%d %d %d %d", &x1, &y1, &x2, &y2);
	s.p1.x = x1, s.p1.y = y1;
	s.p2.x = x2, s.p2.y = y2;

	scanf("%d", &q);
	for (i = 0; i < q; ++i)
	{
		scanf("%d %d", &x, &y);
		p.x = x, p.y = y;

		a = project(s, p);
		printf("%.10f %.10f\n", a.x, a.y);
	}

	return 0;
}

Measured memory_bytes: 1072
#define _CRT_SECURE_NO_WARNINGS
#include<stdio.h>
#include<vector>
#include<functional>
#include<algorithm>
#include<stdlib.h>
#include<string>
#include<string.h>
#define _USE_MATH_DEFINES
#include<math.h>
#include<deque>
#include<map>
#include<iostream>
using namespace std;
typedef long long ll;
#define rep(i,a,b) for(auto i=a;i<b;i++)
#define all(_x) _x.begin(), _x.end()
#define r_sort(_x) sort(_x.begin(), _x.end(), std::greater<int>())
#define vec_cnt(_a, _n) (upper_bound(all(_a), _n) - lower_bound(all(_a), _n))
int main() {
	int N, w = 0, h = 0;
	scanf("%d", &N);
	vector<int> A(N);
	rep(i, 0, N)scanf("%d", &A[i]);
	r_sort(A);
	rep(i, 0, N - 1) {
		if (A[i] == A[i + 1]) {
			if (w == 0) {
				w = A[i];
				i++;
			}
			else {
				h = A[i];
				break;
			}
		}
	}
	printf("%lld\n", (ll)w * h);
	return 0;
}


Measured memory_bytes: 640
// 参考:http://judge.u-aizu.ac.jp/onlinejudge/review.jsp?rid=1060290#1

#include <iostream>
#include <vector>
using namespace std;

const int MAX = 105;
const int INF = 10001;

void visit(int V, int G[MAX][MAX], int v, int s, int r,
    vector<int> &no, vector< vector<int> > &comp,
    vector<int> &prev, vector< vector<int> > &next,
    vector<int> &mcost, vector<int> &mark,
    int &cost, bool &found) {
  if (mark[v]) {
    vector<int> temp = no;
    found = true;
    do {
      cost += mcost[v];
      v = prev[v];
      if (v != s) {
        while (comp[v].size() > 0) {
          no[comp[v].back()] = s;
          comp[s].push_back(comp[v].back());
          comp[v].pop_back();
        }
      }
    } while (v != s);
    
    //REP(i, V){
    for(int i = 0;i < V;++i){
      if(i != r && no[i] == s)
        //REP(j, V){
        for(int j = 0;j < V;++j){
          if (no[j] != s && G[j][i] < INF) G[j][i] -= mcost[temp[i]];
        }
    }
  }
  mark[v] = true;
  //REP(i, next[v].size())
  for(int i = 0;i < next[v].size();++i)
    if(no[next[v][i]] != no[v] && prev[no[next[v][i]]] == v)
      if (!mark[no[next[v][i]]] || next[v][i] == s)
        visit(V, G, next[v][i], s, r, no, comp, prev, next, mcost, mark, cost, found);

}

int minimumSpanningArborescence(int V, int E, int G[MAX][MAX], int r) {
  vector<int> no(V);
  vector< vector<int> > comp(V);
  for(int i = 0;i < V;++i) comp[i].push_back(no[i] = i);

  for(int cost = 0; ;) {
    vector<int> prev(V, -1);
    vector<int> mcost(V, INF);

    for(int i = 0;i < V;++i){
      for(int j = 0;j < V;++j){
        if(j == r || G[i][j] == INF || no[i] == no[j] || G[i][j] > mcost[no[j]]) continue;
        mcost[no[j]] = G[i][j];
        prev[no[j]] = no[i];
      }
    }
    vector< vector<int> > next(V);
    //REP(i, V)
    for(int i = 0;i < V;++i)
      if(prev[i] >= 0)
        next[prev[i]].push_back(i);

    bool stop = true;
    vector<int> mark(V, false);

    for(int i = 0;i < V;++i)
      if(i != r && !mark[i] && !comp[i].empty()) {
        bool found = false;
        visit(V, G, i, i, r, no, comp, prev, next, mcost, mark, cost, found);
        if (found) stop = false;
      }
    if (stop) {
      for(int i = 0;i < V;++i) if (prev[i] >= 0) cost += mcost[i];
      return cost;
    }
  }
}

int main() {
  int vNum,eNum,s;
  cin >> vNum >> eNum >> s;
  int G[MAX][MAX];
  for(int i = 0;i < vNum;++i)
    for(int j = 0;j < vNum;++j)
        G[i][j] = (i == j ? 0 : INF);

  for(int i = 0;i < eNum;++i){
    int v,e,w;
    cin >> v >> e >> w;
    G[v][e] = w;
  }
  cout <<minimumSpanningArborescence(vNum,eNum, G, s) <<endl;
}


Measured memory_bytes: 3216
import scala.io.StdIn._

object Main extends App {
  val n = 5
  val a = (1 to 5).map(_ => readLine.toInt).toArray
  var min_v_index = 0
  var result = 0
  for (i <- (1 to 4)) {
    if (a(i) % 10 < a(min_v_index) % 10 && a(i) % 10 != 0) {
      min_v_index = i 
    }
  }
  a.zipWithIndex.foreach{ case (x, i) => {
    if (i != min_v_index) {
      if (a(i) % 10 == 0) {
        result += a(i)
      } else if (a(i) / 10 == 0) {
        result += 10
      } else {
        result += (a(i) / 10) * 10 + 10
      }
    }
  }}
  result += a(min_v_index)
  println(result)
}

Measured memory_bytes: 25536
import java.util.*;
import java.lang.Math;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    String w = sc.next();
    int istack;
    int alps[] = new int[26];
    boolean ans=true;
    
    Arrays.fill(alps,0);
    
    for(int i = 0;i < w.length();i++){
    	istack = (int)w.charAt(i) - 97;
      	alps[istack]++;
    }
    
    for(int i = 0;i < 26 && ans; i++){
    	if(alps[i] % 2 != 0) ans = false;
    }
    
    if(ans) System.out.println("Yes");
   	else System.out.println("No");
  }
}


Measured memory_bytes: 35536
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
#define cinf(n,x) for(int i=0;i<(n);i++)cin>>x[i];
#define ft first
#define sc second
#define pb push_back
#define lb lower_bound
#define ub upper_bound
#define all(v) (v).begin(),(v).end()
#define LB(a,x) lb(all(a),x)-a.begin()
#define UB(a,x) ub(all(a),x)-a.begin()
#define mod 1000000007
#define FS fixed<<setprecision(15)
using namespace std;
typedef long long ll;
const double pi=3.141592653589793;
template<class T> using V=vector<T>;
using Graph = vector<vector<int>>;
using P=pair<ll,ll>;
typedef unsigned long long ull;
typedef long double ldouble;
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }

const ll INF=1e18;

int main(){
    cin.tie(0);ios::sync_with_stdio(false);
    ll D;
    cin>>D;
    V<ll> c(26);
    V<ll> lst(26,1);
    cinf(26,c);
    V<P> p(26);
    V<ll> t(D);
    set<P> st;
    ll sum=0;
    rep(i,26){
        p[i]=make_pair(c[i],i);
    }
    sort(all(p));
    ll s[D][26];
    rep(i,D){
        rep(j,26)cin>>s[i][j];
    }
    cinf(D,t);
    V<ll> ans(D);
    ll now=0;
    rep(i,D){
        /*set<P> ss;
        ll cnt=-1;
        ll res=-INF;
        rep(j,26){
            ll cc=0;
            rep(k,26){
                if(j==k) continue;
                cc+=lst[k]*c[k];
            }
            if(s[i][j]-cc>res){
                res=s[i][j]-cc;
                cnt=j;
            }
        }*/
        ll cnt=0;
        rep(j,26){
            if(j!=t[i]-1){
                cnt+=c[j]*lst[j];
            }
        }
        now+=s[i][t[i]-1]-cnt;
        
        cout<<now<<endl;
        lst[t[i]-1]=1;
        rep(j,26){
            if(j!=t[i]-1) lst[j]++;
        }
    }
    //cout<<ans[i]<<endl;
    /*rep(i,D) cout<<ans[i]+1<<endl;*/
}
//ペナルティ出しても焦らない　ACできると信じろ！！！
//どうしてもわからないときはサンプルで実験　何か見えてくるかも
//頭で考えてダメなら紙におこせ！！
/*
V,P(大文字)使用不可
乗算などの際にオーバーフローに注意せよ！
(適切にmodをとれ　にぶたんで途中で切り上げろ)
制約をよく読め！
{
    ・全探索できるなら全探索しろ
    ・異常な制約ならそこに注目
}
stringの計算量(扱い)注意
コーナー注意！(特に数値が小さいものについては要検証)
N行出力のときは'¥n'
グリッド上では行先が範囲内におさまるかif文で確認(RE注意)
if文ではちゃんと比較演算子==を使え('='でもエラー出ない)
配列(vector)の大きさが0か1以上かで場合分けせよ(RE注意)
(vector<int> a(m)でm==0というものはできない)
modはなるべく最後に取れ！
doubleを扱うときには(abs)ではなく'fabs'!!!
*/

Measured memory_bytes: 3744
from sys import stdin
readline = stdin.readline

R, C, K = map(int, readline().split())

goods = [[0] * C for _ in range(R)]
for _ in range(K):
    r, c, v = map(int, readline().split())
    goods[r - 1][c - 1] = v

dp = [0] * (C + 1)
for i in range(R):
    cur = [0] * 4
    cur[0] = dp[0]
    for j in range(C):
        if goods[i][j] != 0:
            for k in range(2, -1, -1):
                cur[k + 1] = max(cur[k + 1], cur[k] + goods[i][j])
        dp[j] = max(cur)
        cur[0] = max(cur[0], dp[j + 1])

print(max(cur))


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

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

    int n,k;
    cin >> n >> k;
    map<int,bool> mp;
    for(int i = 0; i < k; i++){
        int d;
        cin >> d;
        mp[d] = true;
    }

    for(int i = n; i < 1e6+1; i++){
        string s = to_string(i);
        bool end = true;
        for(auto p:s){
            if(mp[p-'0']){
                end = false;
                break;
            } 
        }
        if(end){
            cout << i << endl;
            break;
        }
    }
    return 0;
}

Measured memory_bytes: 3708
import java.io.*
import java.util.*

fun solve(N: Int){
    var ret = Math.sqrt(N.toDouble()).toInt() - 1
    while(ret*ret <= N){
        ret++
    }
    println((ret - 1)*(ret-1))
    return
}


fun main(args: Array<String>) {
    fun StringArray(size: Int, init: (Int) -> String = { "\u0000" }): Array<String> {
        return Array<String>(size, init)
    }
    class Scanner(stream: InputStream) {
        private val reader = BufferedInputStream(stream).bufferedReader()
        private var st: StringTokenizer? = null
        fun next(): String {
            while (!(st?.hasMoreTokens() ?: false)) st = StringTokenizer(reader.readLine())
            return st!!.nextToken()
        }
    }
    val sc = Scanner(System.`in`)
    val N = sc.next().toInt()
    solve(N)
}



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

namespace ConsoleApp15
{
    class Class350
    {
        static void Main()
        {
            int N = int.Parse(Console.ReadLine());
            var A = new int[N];
            for(int i = 0; i < N; i++)
            {
                A[i] = int.Parse(Console.ReadLine());
            }
            int max = A.Max();
            if (A.Count(x => x == max) > 1)
            {
                for(int i = 0;i<N;i++)
                    Console.WriteLine(max);
                return;
            }
            for(int i = 0; i < N; i++)
            {
                if (A[i] == max)
                {
                    var B = new int[N];
                    Array.Copy(A, B, N);
                    B[i] = -1;
                    Console.WriteLine(B.Max());
                }
                else
                {
                    Console.WriteLine(max);
                }
            }
        }
    }
}


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

using namespace std;
typedef long long ll;
typedef pair<ll, ll> p_ll;

template<class T>
void debug(T itr1, T itr2) { auto now = itr1; while(now<itr2) { cout << *now << " "; now++; } cout << endl; }
#define repr(i,from,to) for (int i=(int)from; i<(int)to; i++)
#define all(vec) vec.begin(), vec.end()
#define rep(i,N) repr(i,0,N)
#define per(i,N) for (int i=(int)N-1; i>=0; i--)

const ll MOD = pow(10,9)+7;
const ll LLINF = pow(2,61)-1;
const int INF = pow(2,30)-1;

vector<ll> fac;
void c_fac(int x=pow(10,6)+10) { fac.resize(x,true); rep(i,x) fac[i] = i ? (fac[i-1]*i)%MOD : 1; }
ll inv(ll a, ll m=MOD) { ll b = m, x = 1, y = 0; while (b!=0) { int d = a/b; a -= b*d; swap(a,b); x -= y*d; swap(x,y); } return (x+m)%m; }
ll nck(ll n, ll k) { return fac[n]*inv(fac[k]*fac[n-k]%MOD)%MOD; }
ll gcd(ll a, ll b) { if (a<b) swap(a,b); return b==0 ? a : gcd(b, a%b); }
ll lcm(ll a, ll b) { return a/gcd(a,b)*b; }


int main() {
  int N; cin >> N;
  ll A[N]; rep(i,N) cin >> A[i];
  map<ll, ll, greater<ll>> count; rep(i,N) count[A[i]]++;
  ll result = 0;
  for (auto &x: count) {
    ll p2 = 1; while (p2<x.first) p2 *= 2;
    if (p2==x.first) {
      result += x.second/2;
      x.second %= 2;
    }
    else {
      if (count.count(p2-x.first)==0) continue;
      ll c = min(count[p2-x.first], x.second);
      result += c;
      x.second -= c;
      count[p2-x.first] -= c;
    }
  }
  // for (auto x: count) cout << x.first << " " << x.second << endl;
  cout << result << endl;
  return 0;
}


Measured memory_bytes: 14336
# 2019-11-13 08:30:54(JST)
import sys
# import collections
# import math
# from string import ascii_lowercase, ascii_uppercase, digits
# from bisect import bisect_left as bi_l, bisect_right as bi_r
# import itertools
# from functools import reduce
# import operator as op
# from scipy.misc import comb # float
# import numpy as np 

def main():
    r, d, x0 = [int(x) for x in sys.stdin.readline().split()]
    x = x0
    for _ in range(10):
        x = r * x - d
        print(x)

if __name__ == "__main__":
    main()


Measured memory_bytes: 2940
//
//AtCoder Beginner Contest XXX
//X - XXXX
//

#include <iostream>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <cmath>
#include <ctime>
#include <queue>
#include <map>
#include <set>
#include <tuple>
#include <functional>
#include <cassert>
#include <bitset>

using namespace std;

#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=a;i<=(ll)(b);i++)
#define FORD(i,a,b) for(ll i=a;i>=(ll)(b);i--)
#define ALL(x) (x).begin(),(x).end()
#define RALL(x) (x).rbegin(),(x).rend()
#define SIZE(x) (int)(x).size()
#define SIZEL(x) (ll)(x).size()
#define MSG(a) cout << #a << " " << a << endl;

using ll = long long;
using ld = long double;
using Graph = vector<vector<int>>;

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

ll gcd(ll x, ll y) { return (x % y)? gcd(y, x % y): y; }    //最大公約数
ll lcm(ll x, ll y) { return x / gcd(x, y) * y; }            //最小公倍数

int main()
{
    ll n;
    vector<ll> a(5);
    cin >> n >> a[0] >> a[1] >> a[2] >> a[3] >> a[4];
    int idx = min_element(ALL(a))-a.begin();
    ll ans = 5+(n/a[idx]);
    if  (a[idx]==1) ans--;
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 3580
#include<iostream>
#include<algorithm>
#include<string>
#include<vector>
#include<set>
#include<queue>
#define _USE_MATH_DEFINES
#include<math.h>
#include<cmath>
#include<ctime>
#include<map>
#define R(i, n) for(int i = 0;i < n; i++)
#define S(a) scanf("%d", &a)
#define S2(a, b) scanf("%d%d", &a, &b)
#define S3(a, b, c) scanf("%d%d%d", &a, &b, &c)
#define SL(a) scanf("%lld", &a)
#define SL2(a, b) scanf("%lld%lld", &a, &b)
#define SL3(a, b, c) scanf("%lld%lld%lld", &a, &b, &c)
#define SA(i, n, a) R(i, n) scanf("%d", a + i)
#define SAL(i, n, a) R(i, n) scanf("%lld", a + i)
#define SC(a) scanf("%c", &a);
#define P(a) printf("%d", a)
#define PL(a) printf("%lld", a)
using namespace std;
using ll = long long;
using PR = pair<int, int>;
const ll MOD = 1e+9 + 7;
const int INF = 1e+9;

string S, T;

int main() {
	cin >> S >> T;
	R(i, T.size() - 1) {
		if (S[i] != T[i]) {
			printf("No");
			return 0;
		}
	}
	printf("Yes");
}

Measured memory_bytes: 3764
#include <bits/stdc++.h>
using namespace std;
const int N = 2e5 + 25, M = 1e6 + 25, oo = 1e9+7, mxmsk = 1 << 16;
const long long OO = 1e18+25;
    
#define par pair<pair<int,int>, int>
#define f first
#define s second

int n,a,b;


int main() {
    scanf("%d%d%d",&n,&a,&b);
    printf("%d",min(a*n,b));
	return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;
 
public class Main {
 
    public static final int BIG_NUM  = 2000000000;
    public static final int MOD  = 1000000007;
 
    public static void main(String[] args) {
 
        Scanner scanner = new Scanner(System.in);
        int table[] = new int[128];
 
        for(int i = 0; i < table.length; i++){
            table[i] = 0;
        }
 
        StringBuilder sb = new StringBuilder();
 
        while(scanner.hasNext()){
            sb.append(scanner.nextLine());
        }
 
        String line = sb.toString();
 
        for(int i = 0; i < line.length(); i++){
            table[line.charAt(i)]++;
        }
 
        for(int i = 0; i < 26; i++){
            System.out.printf("%c : %d\n", 'a'+i,table['a'+i]+table['a'+i-32]);
        }
    }
}


Measured memory_bytes: 26240
#include<stdio.h>
#define N 251

int parent(int i){
  return i/2;

}
int left(int i){
  return 2*i;

}

int right(int i){
  return 2*i+1;

}

int main(){
  int heap[N];
  int i,n;
  scanf("%d",&n);
  for(i=1;i<=n;i++)scanf("%d",&heap[i]);
  for(i=1;i<=n;i++){

    if(i==1){
      printf("node %d: key = %d, ",i,heap[i]);
      if(left(i)<=n)printf("left key = %d, ",heap[left(i)]);
      if(right(i)<=n)printf("right key = %d, ",heap[right(i)]);
}
    else {
      printf("node %d: key = %d, parent key = %d, ",i,heap[i],heap[parent(i)]);
      if(left(i)<=n)printf("left key = %d, ",heap[left(i)]);
      if(right(i)<=n)printf("right key = %d, ",heap[right(i)]);

}
    printf("\n");





  }
  return 0;
}

Measured memory_bytes: 600
#include<bits/stdc++.h>
#define ll long long int 
#define mod 1000000007
#define se second
#define fi first
#define endl "\n"
#define pi 3.1415926535897932384626433832795028841971
#define MAX 9223372036854775807
using namespace std;
int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(0);cout.tie(0);
	cout<<fixed<<setprecision(15);
	double a,b,h,m;
	cin>>a>>b>>h>>m;
	double x,y,z;
	x=30.0*h+0.5*m;
	y=6.0*m;
	z=abs(x-y);
	if(z>180)
	z=360.0-z;
	double ans=a*a+b*b-(2*a*b*cos(z*pi/180.0));
	ans=sqrt(ans);
	cout<<ans;
	return 0;
}

Measured memory_bytes: 4240
#define __USE_MINGW_ANSI_STDIO 0
#include <iostream>
#include <string>
#include <vector>
#include <stdio.h>
#include <cstdlib>
#include <algorithm>
#include <cmath>
#include <set>
#include <numeric>
#include <bitset>
#include<map>

using namespace std;


int sumdigit(int x){
   int sum = 0;
    while(x != 0){
        sum += x % 10;
        x /= 10;
    }
    return sum;
}

int main(){
   string S,T;
   cin >> S >> T;
   vector<int> start(26,-1);
   vector<int> goal(26,-1);
   for(int i = 0; i < S.size();i++){
       int a = S[i] - 'a';
       int b = T[i] - 'a';
       if(start[a] != -1 || goal[b] != -1){
           if(start[a] != b || goal[b] != a){
               cout << "No" << endl;
               return 0;
           }
       }
       else{
       start[a] = b;
       goal[b] = a;
       }
   }
cout << "Yes" << endl;

}

Measured memory_bytes: 776
#include <stdio.h>
#include <bits/stdc++.h>
     
#define uint unsigned int
#define ll long long
#define ull unsigned long long
#define ld long double
#define rep(i, l, r) for (int i = l; i < r; i++)
#define repb(i, r, l) for (int i = r; i > l; i--)
#define sz(a) (int)a.size()
#define fi first
#define se second
#define mp(a, b) make_pair(a, b)
     
using namespace std;

const int N = 1000000;
const int inf = (int)1e9 + 1;
const ll big = (ll)1e18 + 1;
const int P = 239;
const int MOD = (int)1e9 + 9;
const int MOD1 = (int)1e9 + 9;
const double eps = 1e-9;
const double pi = atan2(0, -1);
const int ABC = 26;

int main()
{
    //freopen("a.in", "r", stdin);
    //freopen("a.out", "w", stdout);
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.precision(20);
    //ll TL = 0.95 * CLOCKS_PER_SEC;
    //clock_t time = clock();
    ll n, A, B, C, D;
    cin >> n >> A >> B >> C >> D;
    n--;
    rep(i, 0, n + 1)
    {
        ll l1 = A + i * C, r1 = A + i * D;
        ll l2 = B + (n - i) * C, r2 = B + (n - i) * D;
        if (min(r1, r2) >= max(l1, l2))
        {
            cout << "YES\n";
            return 0;
        }
    }
    cout << "NO\n";
    return 0;
}

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

int main()
{
	int h,wi;
	cin >> h >> wi;
	string grid[h];
	for (int q = 0; q < h; q++)
	{
		cin >> grid[q];
	}
	ll dp[h][wi];
	dp[0][0] = 1;
	for (int q = 0; q < h; q++)
	{
		for (int w = 0; w < wi; w++)
		{
			if (q == 0 && w == 0)
			{
				continue;
			}
			dp[q][w] = 0;
			if (grid[q][w] == '#')
			{
				continue;
			}
			if (q > 0)
			{
				dp[q][w] = (dp[q][w] + dp[q-1][w]) % md;
			}
			if (w > 0)
			{
				dp[q][w] = (dp[q][w] + dp[q][w-1]) % md;
			}
		}
	}
	cout << dp[h-1][wi-1] << "\n";
	return 0;
}


Measured memory_bytes: 9088
/*
lakshaygpt28
Lakshay Gupta
*/

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

using ll = long long;
using db = double;
using pii = pair < int, int >;
using pll = pair < ll, ll >;
using vll = vector < ll >;

template < typename T > using OrderedSet = tree < T, null_type, less < T >, rb_tree_tag, tree_order_statistics_node_update >;
template < typename T > using MinPriorityQueue = priority_queue < T, vector < T >, greater < T > >;


#ifndef ONLINE_JUDGE
#define debug(...) __f(#__VA_ARGS__, __VA_ARGS__)
template < typename Arg1 >
void __f(const char* name, Arg1&& arg1) {
    cerr << name << " : " << arg1 << std :: endl;
}
template < typename Arg1, typename... Args >
void __f(const char* names, Arg1&& arg1, Args&&... args) {
    const char* comma = strchr(names + 1, ',');
    cerr.write(names, comma - names) << " : " << arg1 << " | ";
    __f(comma + 1, args...);
}
#else
#define debug(...)
#endif

#define fast_io() ios_base :: sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define eb emplace_back
#define mp make_pair
#define pb push_back
#define mt make_tuple
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()

const db PI = acos(-1);
const ll LINF = LLONG_MAX;
const int INF = INT_MAX, MOD = 1e9 + 7, N = 2e5 + 10;

ll a[N], b[N];

int main() {
    fast_io();
    ll n;
    cin >> n;
    for (ll i = 1; i <= n; i++) {
        cin >> a[i];
    }
    ll ans = 0;
    for (ll i = n; i >= 1; i--) {
        ll sum = 0;
        for (ll j = 2 * i; j <= n; j += i) {
            sum += b[j];
        }
        b[i] = (sum % 2) ^ a[i];
        // debug(b[i]);
        if (b[i]) {
            ans++;
        }
    }
    cout << ans << "\n";
    for (ll i = 1; i <= n; i++) {
        if (b[i]) {
            cout << i << " ";
        }
    }
    cout << "\n";
    return 0;
}


Measured memory_bytes: 4096
process.stdin.resume();
process.stdin.setEncoding('utf8');
 
var input_string = "";
var reader = require('readline').createInterface({
  input: process.stdin,
  output: process.stdout
});
reader.on('line', (line) => {
  input_string = line;
});
reader.on('close', () => {
  const x = input_string;

  const h = parseInt(x / 3600);
  const m = parseInt((x % 3600)/60);
  const s = (x % 3600) % 60;

console.log(h+':'+m+':'+s);
});




Measured memory_bytes: 16252
#include <cstdint>

namespace n91 {

template <std::uint_fast64_t Modulus> class modint {
  using u64 = std::uint_fast64_t;

public:
  using value_type = u64;

  static constexpr u64 mod = Modulus;

private:
  static_assert(mod < static_cast<u64>(1) << 32,
                "Modulus must be less than 2**32");

  u64 v;

  constexpr modint &negate() noexcept {
    if (v != 0)
      v = mod - v;
    return *this;
  }

public:
  constexpr modint(const u64 x = 0) noexcept : v(x % mod) {}
  constexpr u64 &value() noexcept { return v; }
  constexpr const u64 &value() const noexcept { return v; }
  constexpr modint operator+() const noexcept { return modint(*this); }
  constexpr modint operator-() const noexcept { return modint(*this).negate(); }
  constexpr modint operator+(const modint rhs) const noexcept {
    return modint(*this) += rhs;
  }
  constexpr modint operator-(const modint rhs) const noexcept {
    return modint(*this) -= rhs;
  }
  constexpr modint operator*(const modint rhs) const noexcept {
    return modint(*this) *= rhs;
  }
  constexpr modint operator/(const modint rhs) const noexcept {
    return modint(*this) /= rhs;
  }
  constexpr modint &operator+=(const modint rhs) noexcept {
    v += rhs.v;
    if (v >= mod)
      v -= mod;
    return *this;
  }
  constexpr modint &operator-=(const modint rhs) noexcept {
    if (v < rhs.v)
      v += mod;
    v -= rhs.v;
    return *this;
  }
  constexpr modint &operator*=(const modint rhs) noexcept {
    v = v * rhs.v % mod;
    return *this;
  }
  constexpr modint &operator/=(modint rhs) noexcept {
    u64 exp = mod - 2;
    while (exp) {
      if (exp % 2 != 0)
        *this *= rhs;
      rhs *= rhs;
      exp /= 2;
    }
    return *this;
  }
  constexpr bool operator==(const modint rhs) const noexcept {
    return v == rhs.v;
  }
  constexpr bool operator!=(const modint rhs) const noexcept {
    return v != rhs.v;
  }
};
template <std::uint_fast64_t Modulus>
constexpr typename modint<Modulus>::u64 modint<Modulus>::mod;

} // namespace n91
#include <vector>

namespace n91 {

template <class T> class fact_binom {
  using size_t = std::size_t;

public:
  using value_type = T;

private:
  std::vector<T> fact, inv_fact;

public:
  fact_binom() = default;
  explicit fact_binom(const size_t n) : fact(n + 1), inv_fact(n + 1) {
    fact[0] = 1;
    for (size_t i = 0; i != n; ++i) {
      fact[i + 1] = fact[i] * (i + 1);
    }
    inv_fact[n] = static_cast<value_type>(1) / fact[n];
    for (size_t i = n; i != 0; --i) {
      inv_fact[i - 1] = inv_fact[i] * i;
    }
  }

  T operator()(const size_t n, const size_t r) const {
    return fact[n] * inv_fact[r] * inv_fact[n - r];
  }
};

} // namespace n91

#include <iostream>

int main() {
  using mint = n91::modint<1000000007>;
  int r1, c1, r2, c2;
  std::cin >> r1 >> c1 >> r2 >> c2;
  r1 -= 1;
  c1 -= 1;

  const n91::fact_binom<mint> binom(3000000);
  const auto f = [&](const int x, const int y) {
    return binom(x + y + 2, x + 1) - 1;
  };

  std::cout << (f(r2, c2) - f(r1, c2) - f(r2, c1) + f(r1, c1)).value()
            << std::endl;
}

Measured memory_bytes: 47104
#include <iostream>
#define INF 1e+18
#define int long long
using namespace std;
 
signed main(){
	int n,m;
	cin >> n >> m;
	if(n * 2 >= m) {
		cout << m / 2 << endl;
		return 0;
	}
	n *= 2;
	cout << (n + m) / 4 << endl;
	return 0;
}

Measured memory_bytes: 256
// #pragma GCC target ("avx2")
// #pragma GCC optimization ("O3")
// #pragma GCC optimization ("unroll-loops")
#include<bits/stdc++.h>
using namespace std;
#define FastRead ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define int long long int
#define ll int
#define bits_count __builtin_popcountll
#define endl '\n'
#define double long double
#define ld double
#define FOR(i,a,n) for (ll i=(a);i<=(n);++i)
#define RFOR(i,a,n) for (ll i=(n);i>=(a);--i)
#define FI(i,n) for (ll i=0; i<(n); ++i)
#define ZERO(a) memset((a),0,sizeof((a)))
#define MINUS(a) memset((a),-1,sizeof((a)))
#define f first
#define s second
#define pb push_back
#define mk make_pair
#define all(g) g.begin(),g.end()
#define sz(x) (ll)x.size()
int fastMax(int x, int y) { return (((y-x)>>(32-1))&(x^y))^y; }
int fastMin(int x, int y) { return (((y-x)>>(32-1))&(x^y))^x; }

// #include <ext/pb_ds/assoc_container.hpp> // Common file
// #include <ext/pb_ds/tree_policy.hpp>     // Including tree_order_statistics_node_updat
// using namespace __gnu_pbds;
// typedef tree<ll, null_type, less<ll>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;

int L; 

double cal(double l){
    double b = (L*1.0 - l*1.0)/2.0;
    double h = L*1.0 - b*1.0 - l*1.0;
    double lll = l*1.0;
    double vol = lll*b*h;

    return vol;    
}

void solve(){
    cin>>L;

    double ans = 0;

    double s = 0,e = L;
    FOR(i,1,100000){
        double mid1 = s + (e-s)/3.0;
        double mid2 = e - (e-s)/3.0;
    
        if(cal(mid1) >= cal(mid2)){
            ans = max(ans,cal(mid1));
            e = mid2-1;
        }else {
            ans = max(ans,cal(mid2));
            s = mid1+1;
        }
    }

    cout<<fixed<<setprecision(10)<<ans<<endl;
}

signed main(){

   FastRead;    


    int t = 1; 
    // cin>>t; 
    FOR(i,1,t){
        // cout<<"Case #"<<i<<": ";
        solve();
    }
}

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

int main()
{
	long long n, d;
	cin >> n >> d;
	vector<long long> x(n), y(n);
	int cnt = 0;
	rep(i, n)
	{
		cin >> x[i] >> y[i];
		if (x[i] * x[i] + y[i] * y[i] <= d * d)
			cnt++;
	}
	cout << cnt << endl;
	return 0;
}


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

using namespace std;

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

#define rep(i,n) for(int i=0;i<(n);++i)
#define repi(i,a,b) for(int i=int(a);i<(b);i++)
#define repr(i,b,a) for(int i=int(b);i>=(a);i--)
#define all(x) x.begin(),x.end()

const ll mod = 1e9+7;
const ll INF = 1e9;

ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};
bool valid(int lx,int ux,int ly,int uy,int x,int y){
	return lx<=x&&x<ux&&ly<=y&&y<uy; 
}
ll power(ll x,ll p){
	if(p==0)return 1;
	ll res=power(x*x%mod,p/2);
	if(p%2==1)res=res*x%mod;
	return res;
}

int main()
{
	ll a,b,k;
	cin>>a>>b>>k;

	if(a>=k)cout<<max(0LL,a-k)<<" "<<b<<endl;
	else if(a+b>=k)cout<<0<<" "<<max(0LL,b-(k-a))<<endl;
	else cout<<0<<" "<<0<<endl;
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
int main()
{
    ll n,x,s=0;
    vector<ll>v;
    cin>>n;
    for(ll i=0;i<n;i++)
    {
        cin>>x;
        v.push_back(x);
    }
    sort(v.begin(),v.end());
    for(ll i=0;i<n;i++)
    {
        if(i==n-1) v[i]/=2;
        s+=v[i];
    }
    cout<<s<<endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <fstream>
#include <typeinfo>
#include <vector>
#include <stack>
#include <cmath>
#include <set>
#include <map>
#include <string>
#include <algorithm>
#include <cstdio>
#include <queue>
#include <iomanip>
#include <cctype>
#include <random>
#define syosu(x) fixed<<setprecision(x)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef pair<double,double> pdd;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<char> vc;
typedef vector<vc> vvc;
typedef vector<string> vs;
typedef vector<bool> vb;
typedef vector<vb> vvb;
typedef vector<P> vp;
typedef vector<vp> vvp;
typedef vector<pll> vpll;
typedef pair<int,P> pip;
typedef vector<pip> vip;
const int inf=1<<30;
const ll INF=1ll<<57;
const double pi=acos(-1);
const double eps=1e-8;
const ll mod=1e9+7;
const int dx[4]={0,1,0,-1},dy[4]={1,0,-1,-0};
const int DX[8]={-1,-1,-1,0,1,1,1,0},DY[8]={1,0,-1,-1,-1,0,1,1};

int Figure(int x){
	return to_string(x).size();
}

int f(int x,int y){
	return max(Figure(x),Figure(y));
}

ll n;

int main(){
	cin>>n;
	int res=inf;
	for(ll i=1;i*i<=n;i++) if(n%i==0) res=min(res,f(i,n/i));
	cout<<res<<endl;
}

Measured memory_bytes: 256
n = input()
if len(n) == 1:
    print(n)
if len(n) == 2:
    print(9)
if len(n) == 3:
    print((int(n)-99)+9)
if len(n) == 4:
    print(909)
if len(n) == 5:
    print((int(n)-9999)+909)
if len(n) == 6:
    print(90909)

Measured memory_bytes: 3064
#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字くらい使った方がいいかも
*/

const int MAX = 1000005;
const int mod = 1000000007;

long long fac[MAX], finv[MAX], inv[MAX];
void COMinit(){
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for(int i = 2; i < MAX; i++){
        fac[i] = fac[i-1] * i % mod;
        inv[i] = mod - inv[mod%i] * (mod/i) % mod;
        finv[i] = finv[i-1] * inv[i] % mod;
    }
 
}
long long COM(int n, int k){
    if(n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n-k] % mod) % mod;
}

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

    COMinit();
    ll ans = COM((H-1)+(W-1), H-1);

    for(int i=1; i<=A; i++){
        ll tmp = COM(H-A+i-1 + B-1, B-1) * COM(A-i + W-B-1, A-i);
        tmp %= mod;
        ans -= tmp;
        if(ans < 0) ans += mod;
        ans %= mod;
    }

    cout << ans << endl;
}

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

int main()
{
    int A , B;
    cin>>A>> B;
    if(A<13 && A>=6){
         cout<<B/2<<endl;
    }
    if(A<6){
        cout<<0<<endl;

    }
    if(A>=13){
        cout<<B<<endl;        
    }
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define lf long double
#define vi vector<int>
#define vl vector<long long int>
#define pii pair <int,int>
#define pll pair <long long int, long long int>
#define vpii vector< pair<int,int> >
#define vpll vector < pair <long long int,long long int> >
#define MOD 1000000007
#define pb push_back
#define mk make_pair
#define f first
#define s second
#define in insert
#define all(x) x.begin(),x.end()
#define apo ios::sync_with_stdio(false);cin.tie(0)
ll add(ll x, ll y) {ll res = x + y; return (res >= MOD ? res - MOD : res);}
ll mul(ll x, ll y) {ll res = x * y; return (res >= MOD ? res % MOD : res);}
ll sub(ll x, ll y) {ll res = x - y; return (res < 0 ? res + MOD : res);}

ll power(ll x, ll y) {if (y < 0) return 1; ll res = 1; x %= MOD; while (y) {if (y & 1)res = mul(res, x); y >>= 1; x = mul(x, x);} return res;}
int main(){
	apo;
	ll t;
	cin>>t;
	if(t%10==2||t%10==4||t%10==5||t%10==7||t%10==9){
		cout<<"hon";
	}
	else if(t%10==0||t%10==1||t%10==6||t%10==8){
		cout<<"pon";
	}
	else{
		cout<<"bon";
	}
}

Measured memory_bytes: 3600
//g++ -std=c++14 test.cpp -o test.out
//問題URL:
//https://atcoder.jp/contests/agc047/tasks/agc047_a

//参考：
// https://maspypy.com/atcoder-%E5%8F%82%E5%8A%A0%E6%84%9F%E6%83%B3-2020-08-09agc047
// https://www.hamayanhamayan.com/entry/2020/08/10/054247
// Double型の変数で、例えば整数部4桁、少数部9桁の数を10倍してlongに変換する時、
// そのままx = y*10000000000などとやると誤差のせいでうまくいかない
// Double型変数を一度文字列に変換、それをlongに直してやる必要がある
 
#include <string.h>
#include <stdlib.h>
#include <math.h>
#include <cassert>
#include <algorithm>
#include <functional>
#include <iostream>
#include <iomanip>
#include <vector>
#include <queue>
#include <stack>
#include <map> 
#include <unordered_map> 
#include <utility>
#include <limits.h>
#include <bitset>
#include <set>
using namespace std;
 
#define LL long long int
const LL INF = (1LL<<60);
const int INF_INT = 2147483647-1e6-1;
const LL mod = 1000000007ll;
const int mod_int = 1000000007;

LL N;
LL A[200000];

LL ans = 0;

//xがdを何個約数に持つかを返す
LL divide(LL x,LL d){
	if(x==0) return 0;
	for(LL i=0;;i++){
		if(x%d!=0) return i;
		x/=d;
	}
}

void solve(){
	//2の約数をi個、5の約数をj個持つような数の個数をdivisor[i][j]とおく
	vector<vector<LL>> divisor(19,vector<LL>(19,0));
	for(int i=0;i<N;i++){
		LL d_2 = min(18LL,divide(A[i],2));
		LL d_5 = min(18LL,divide(A[i],5));
		divisor[d_2][d_5]++;
	}

	for(int i=0;i<N;i++){
		LL d_2 = min(18LL,divide(A[i],2));
		LL d_5 = min(18LL,divide(A[i],5));
		for(int i=18-d_2;i<=18;i++){
			for(int j=18-d_5;j<=18;j++){
				ans += divisor[i][j];
				if(i==d_2 && j==d_5) ans--;
			}
		}
	}

	ans/=2;
}
 
int main(){
   	cin >> N;
	for(int i=0;i<N;i++){
    	string s; cin >> s;

        LL x = 0;
        bool f = false;
        int rest = 9;
        for(int j=0;j<s.size();j++){
            if (s[j] != '.') {
                x = x * 10LL + ((LL)(s[j] - '0'));
                if (f) rest--;
            }
            else f = true;
        }
        for(int _=0;_<rest;_++) x *= 10LL;

    	A[i] = x;
    }
 
    solve();
 
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 4728
S=list(map(int,input().split()))
K=sorted(S)
ans=0
ans=K[-1]-K[-2]
rest=K[-1]-(ans+K[0])
if rest%2==0:
  ans+=rest//2
  print(ans)
else:
  ans+=(K[-1]+1-K[0]-ans)//2+1
  print(ans)

Measured memory_bytes: 61836
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <iomanip>
#include <stack>
#include <queue>

using namespace std;

int main() {
    int n;
    cin >> n;
    
    int ans = 0;
    for(int i = 1; i <= n; i++) {
        if(to_string(i).size() % 2 == 1){
            ans++;
        }
    }
    
    cout << ans << endl;
    
    return 0;
}



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

int main(){
    string s;cin>>s;
    string t="";
    string prev="";
    int ans=0;
    for(int i=0;i<(int)s.size();++i){
        t+=s[i];
        if(t!=prev){
            ans++;prev=t;t="";
        }
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 640
import java.util.HashSet;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
        Scanner sc = new Scanner (System.in);
        int n = sc.nextInt();
        HashSet<String> set = new HashSet<>();
        for(int i = 0 ; i < n ; i ++) {
        	set.add(sc.next());
        }
        System.out.println(set.size());
    }
}


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

using namespace std;

int main() {
  int n, a[112345], ans = 0, p = 1;
  cin >> n;
  for (int i = 0; i < n; i++) {
    cin >> a[i];
  }
  for (int i = 0; i < n; i++) {
    if (p == 2) {
      cout << ans << '\n';
      return 0;
    } 
    p = a[p - 1];
    ans++;
  }
  cout << -1 << '\n';
  return 0;
}


Measured memory_bytes: 640
s = input()
n = len(s)
c = 0
for i in range(n):
  if (i%2 == 0):
    if (s[i] == "L"):
      c = 1
  else:
    if (s[i] == "R"):
      c = 1
if (c == 0):
  print("Yes")
else:
  print("No")

Measured memory_bytes: 9060
line = require('fs').readFileSync('/dev/stdin', 'ascii').split('\n');
line = line.slice(1, parseInt(line[0]) + 1);
num_to_card = ['S', 'H', 'C', 'D'];
card_to_num = {'S': 0, 'H': 13, 'C': 13*2, 'D': 13*3};
map = []
for (i = 0; i < 52; i++) map.push(true);

line.forEach(function(line) {
	var ary = line.split(' ');
	map[card_to_num[ary[0]] + parseInt(ary[1]) - 1] = false;
});

for (i = 0; i < 4; i++)
	for (j = 0; j < 13; j++)
		if (map[i*13+j]) console.log(num_to_card[i], j + 1);

Measured memory_bytes: 15580
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for (ll i = 0; i < (ll)(n); ++i)
#define erep(i, n) for (ll i = 0; i <= (ll)(n); ++i)
#define FOR(i,a,b) for (ll i = (a); i < (ll)(b); ++i)
#define EFOR(i,a,b) for (ll i = (a); i <= (ll)(b); ++i)
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } }

#include <iostream>
#include <vector>
#include <queue>
using namespace std;
using Graph = vector<vector<int>>;
using P = pair<int, int>;

int h, w, t;
char s[15][15];
int sy, sx, gy, gx;


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

    bool alice_win = true;
    if(a < b) alice_win = false;
    if(a == 1 || b == 1) alice_win = !alice_win;

    if(alice_win) cout << "Alice" << endl;
    else cout << "Bob" << endl;

    return 0;
}


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

int main()
{
  int N, a;
  vector<int> vec;

  cin >> N;
  for(int i = 0; i < N; i++){
    cin >> a;
    vec.push_back(a);
  }

  float ave = accumulate(vec.begin(), vec.end(), 0.0) / vec.size();
  int iave;
  if((int(ave * 10.0) % 10) < 5){
    iave = int(ave);
  }else{
    iave = int(ave) + 1;
  }

  int cost = 0;

  for(auto p = vec.begin(); p != vec.end(); p++){
    cost += int(pow((*p - iave), 2));
  }
  cout << cost << endl;

  return 0;
}

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

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
#define MAXN 1000010
#define rep(i,n) for (int i = 0; i < (n); ++i)
const ll mod = 1e9+7;

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

bool pairCompare(const P& firstElof, const P& secondElof)
{
    return firstElof.second < secondElof.second;
}

int main() {
    string s;
    ll q;

    cin >> s;
    cin >> q;

    int t, f;
    char c;

    vector<char> sento;
    vector<char> matubi;

    int rev = 0;

    rep(i, q) {
        cin >> t;
        if (t == 1) {
            rev = 1 - rev;

        }else if (t == 2) {
            cin >> f >> c;

            if (rev == 0) {
                if (f == 1) {
                    sento.push_back(c);
                } else {
                    matubi.push_back(c);
                }
            } else {
                if (f == 1) {
                    matubi.push_back(c);
                } else {
                    sento.push_back(c);
                }
            }
        }
    }

    if (rev) {

        reverse(matubi.begin(), matubi.end());

        rep(k, matubi.size()) {
            cout << matubi[k];
        }

        reverse(s.begin(), s.end());
        rep(k, s.size()) {
            cout << s[k];
        }
        rep(k, sento.size()) {
            cout << sento[k];
        }



    } else {
        reverse(sento.begin(), sento.end());

        rep(k, sento.size()) {
            cout << sento[k];
        }

        rep(k, s.size()) {
            cout << s[k];
        }

        rep(k, matubi.size()) {
            cout << matubi[k];
        }
    }


    cout << endl;

}



Measured memory_bytes: 1024
#include<iostream>
#include<iomanip>
#include<math.h>
#include<algorithm>
#include<string>
#include<vector>
#include<queue>
#include<stack>
#include<set>
#include<map>
#include<unordered_map>
#define REP(i, N) for(ll i = 0; i < N; ++i)
#define FOR(i, a, b) for(ll i = a; i < b; ++i)
#define ALL(a) (a).begin(),(a).end()
#define pb push_back
#define INF (long long)1000000000
#define MOD 1000000007
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};

int main(void) {
	while(true) {
		int N;
		cin>>N;
		if(N == 0) break;
		int size = 0;
		ll res = 0;
		vector<string> s(N);
		map<char, ll> omomil;
		map<char, ll> omomir;
		int perm[10];
		vector<int> out;
		REP(i, 10) {
			perm[i] = (int)i;
		}
		REP(i, N) cin>>s[i];
		REP(i, N) {
			REP(j, s[i].size()) {
				if(omomil.count(s[i][s[i].size() - 1 - j]) == 0) {
					omomil[s[i][s[i].size() - 1 - j]] = 0;
					omomir[s[i][s[i].size() - 1 - j]] = 0;
					++size;
				}
				if(i != N - 1) omomil[s[i][s[i].size() - 1 - j]] += pow(10, j);
				else omomir[s[i][s[i].size() - 1 - j]] += pow(10, j);
			}
		}
		map<char, ll>::iterator ite3 = omomil.begin();
		int foo = 0;
		while(ite3 != omomil.end()) {
			REP(i, N) {
				if(s[i].size() > 1 && s[i][0] == (*ite3).first) {
					out.pb(foo);
					//cout<<(*ite3).first<<":"<<foo<<endl;
					break;
				}
			}
			++ite3;
			++foo;
		}

		ll sugoil[10];
		ll sugoir[10];
		ite3 = omomil.begin();
		REP(i, size) {
			sugoil[i] = (*ite3).second;
			++ite3;
		}
		ite3 = omomir.begin();
		REP(i, size) {
			sugoir[i] = (*ite3).second;
			++ite3;
		}
		do {
			ll l = 0;
			ll r = 0;
			bool cont = false;
			int roc = 0;
			REP(i, out.size()) {
				if(perm[out[i]] == 0) {
					cont = true;
					break;
				}
			}
			if(cont) continue;
			REP(i, size) {
				l += perm[i] * sugoil[i];
				++roc;
			}
			REP(i, size) {
				r += perm[i] * sugoir[i];
			}
			if(l == r) ++res;
		} while(next_permutation(perm, perm + 10));

		ll hoge = 1;
		REP(i, 10 - size) {
			hoge *= 10 - size - i;
		}
		cout<<res / hoge<<endl;
	}
}

Measured memory_bytes: 3344
a = int(input())
b = list(map(int,input().split()))
ans = 0
x = True
while x:
  for i in range(a):
    if b[i] %2 ==1:
      x=False
      break
    b[i] = b[i] /2
    ans +=1
ans = ans//a
  

print(ans)

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

using namespace std;

int main(void) {
  int a, b, n;
  cin >> a >> b >> n;

  bool ok = true;
  for (int i = 0; i < n; i++) {
    int s, f;
    cin >> s >> f;
    ok &= (b <= s || f <= a);
  }

  cout << !ok << endl;

  return 0;
}


Measured memory_bytes: 3104
#include <iostream>
using namespace std;
int main(){
    int n,q,d;
    cin >> n >> q;
    int a=q-1;
  string z;
  getline(cin,z);
    string s;
  getline(cin,s);
  int length=s.size();
  for(int i=0;i<length;i++){
    if(s[i]=='A' && a==i){
      s[i]='a';
  }
    else if(s[i]=='B' && a==i){
      s[i]='b';
  }
    else if(s[i]=='C' && a==i){
      s[i]='c';
  }
}
    for(d=0;d<length;d++){
        if(d<length){
            cout << s[d];
        }
	}
	if(d==length){
		cout << endl;
	}

}

Measured memory_bytes: 256