akhauriyash/Code-Regression huggingface dataset:
#pragma GCC optimize("O3")
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <string>
#include <cstring>
#include <deque>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <cfloat>
#include <climits>
#include <ctime>
#include <cassert>
#include <numeric>
#include <fstream>
#include <functional>
#include <bitset>
using namespace std;

using ll = long long;
using P = pair<int, int>;
using T = tuple<int, int, int>;

template <class T> inline T chmax(T &a, const T b) {return a = (a < b) ? b : a;}
template <class T> inline T chmin(T &a, const T b) {return a = (a > b) ? b : a;}

constexpr int MOD = 998244353;
constexpr int inf = 1e9;
constexpr long long INF = 1e18;

#define all(a) (a).begin(), (a).end()

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

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

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

    vector<vector<ll>> dp(n+1, vector<ll>(s+1, 0));
    for(int i=0; i<n; i++) dp[i][0] = 1;

    for(int i=0; i<n; i++){
        for(int j=0; j<=s; j++){
            dp[i+1][j] += dp[i][j];
            dp[i+1][j] %= MOD;

            if(j - a[i] >= 0){
                dp[i+1][j] += dp[i][j-a[i]];
                dp[i+1][j] %= MOD;
            }
        }
    }

    ll ans = 0;
    for(int i=0; i<n; i++){
        ans += dp[i+1][s];
        ans %= MOD;
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 70912
#include<stdio.h>
#define N 25
typedef struct{
  int p;
  int l;
  int r;
}Node;
 
void preorder(int);
void inorder(int);
void postorder(int);
 
Node T[N];
int main(){
  int n, i, j;
  int id, left, right;
  scanf("%d\n",&n);
  for(i = 0 ; i < n ; i++){
    T[i].p = -1;
    T[i].l = -1;
    T[i].r = -1;
  }
  for(i = 0 ; i < n ; i++){
    scanf("%d%d%d", &id, &left, &right);
    T[id].l = left;
    T[left].p = id;
    T[id].r = right;
    T[right].p = id;
  }
  printf("Preorder\n");
  for(i = 0 ; i < n ; i++){
    if(T[i].p == -1){
      preorder(i);
    }
  }
  printf("\n");
  printf("Inorder\n");
  for(i = 0 ; i < n ; i++){
    if(T[i].p == -1){
      inorder(i);
    }
  }
  printf("\n");
  printf("Postorder\n");
  for(i = 0 ; i < n ; i++){
    if(T[i].p == -1){
      postorder(i);
    }
  }
  printf("\n");
  return 0;
}
 
void preorder(int u)
{
  if(u == -1) return;
  printf(" %d", u);
  preorder(T[u].l);
  preorder(T[u].r);
}
void inorder(int u)
{
  if(u == -1) return;
  inorder(T[u].l);
  printf(" %d", u);
  inorder(T[u].r);
}
 
void postorder(int u)
{
  if(u == -1) return;
  postorder(T[u].l);
  postorder(T[u].r);
  printf(" %d", u);
}

Measured memory_bytes: 616
N,M = list(map(int,input().split()))

flag = True

D = [list(map(int,input().split())) for i in range(M)]

if N==1:
    b = 0
else:
    b = 10**(N-1)

B = 10**N
flag = False
for i in range(b,B):
    S = str(i)
    fl = True
    for j in range(M):
        s,c = D[j]
        if S[s-1]!=str(c):
            fl = False
            break
    if fl:
        flag=True
        break

if flag:
    print(i)
else:
    print(-1)

Measured memory_bytes: 38468
#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <cmath>
#include <vector>
#include <queue>
#include <utility>

using namespace std;
typedef long long ll;
const int LEN = 100000;

struct fastio{
  int it,len;
  char s[LEN + 5];
  fastio(){
    it = len = 0;
  }
  char get(){
    if(it < len) return s[it++];
    it = 0, len = fread(s,1,LEN,stdin);
    return len ? s[it++] : EOF;
  }
  bool notend(){
    char c;
    for(c = get();c == ' ' || c == '\n';c = get());
    if(it) it--;
    return c != EOF;
  }
  void put(char c){
    if(it == LEN) fwrite(s,1,LEN,stdout), it = 0;
    s[it++] = c;
  }
  void flush(){
    fwrite(s,1,it,stdout);
  }
}buff,bufo;
inline int getint(){
  char c; int res = 0, sig = 1;
  for(c = buff.get();c < '0' || c > '9';c = buff.get()) if(c == '-') sig = -1;
  for(;c >= '0' && c <= '9';c = buff.get()) res = res * 10 + (c - '0');
  return sig * res;
}
inline ll getll(){
  char c; ll res = 0, sig = 1;
  for(c = buff.get();c < '0' || c > '9';c = buff.get()) if(c == '-') sig = -1;
  for(;c >= '0' && c <= '9';c = buff.get()) res = res * 10 + (c - '0');
  return sig * res;
}
inline void putint(int x,char suf){
  if(!x) bufo.put('0');
  else{
    if(x < 0) bufo.put('-'), x = -x;
    int k = 0; char s[15];
    while(x){
      s[++k] = x % 10 + '0';
      x /= 10;
    }
    for(;k;k--) bufo.put(s[k]);
  }
  bufo.put(suf);
}
inline void putll(ll x,char suf){
  if(!x) bufo.put('0');
  else{
    if(x < 0) bufo.put('-'), x = -x;
    int k = 0; char s[25];
    while(x){
      s[++k] = x % 10 + '0';
      x /= 10;
    }
    for(;k;k--) bufo.put(s[k]);
  }
  bufo.put(suf);
}
inline char get_char(){
  char c;
  for(c = buff.get();c == ' ' || c == '\n';c = buff.get());
  return c;
}
#define maxn 200005
int n,k,h[maxn];
int main(){
  n = getint(), k = getint();
  k = min(k,n);
  for(int i = 1;i <= n;i++) h[i] = getint();
  sort(h + 1,h + n + 1);
  ll ans = 0;
  for(int i = 1;i <= n - k;i++) ans += h[i];
  putll(ans,'\n');
  bufo.flush();
  return 0;
}


Measured memory_bytes: 1152
class Prime():
    def __init__(self, n):
        self.p = []
        self.d = [0] * n

        for i in range(2, n):
            if self.d[i] == 0:
                self.p.append(i)
                for j in range(i, n, i):
                    if self.d[j] == 0:
                        self.d[j] = i

        self.ind = [-1] * n
        for i in range(len(self.p)):
            self.ind[self.p[i]] = i

    def prime_factorization_index(self, x):
        l = []
        while x != 1:
            if l == [] or l[-1] != self.ind[self.d[x]]:
                l.append(self.ind[self.d[x]])
            x //= self.d[x]
        return l

    def num_prime(self):
        return len(self.p)

from math import gcd
 
n = int(input())
a = list(map(int, input().split()))
 
g = a[0]
for i in range(1, n):
    g = gcd(g, a[i])
    if g == 1:
        break
else:
    print('not coprime')
    exit()

p = Prime(10**6 + 1)

tf = [False] * p.num_prime()

for i in range(1, n):
    l = p.prime_factorization_index(a[i])
    for i in l:
        if tf[i]:
            print('setwise coprime')
            exit()
        else:
            tf[i] = True

print('pairwise coprime')

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

int main() {
  int N,A,min,j;
  cin >> N;
  
  for(int i=0;i<N;i++){
    cin >> A;
    for(j=0;;){
      if(A%2==0){
        A=A/2;
        j++;
      }
      else
        break;
    }
    if(i==0)
      min=j;
    if(min>j)
      min=j;
  }
  cout << min;
}

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

int main() {
  string s;
  cin >>s;
  
  int count=0,maximum=0;
  
  for(int i=0; i<s.size(); i++){
    if(s[i]=='A'||s[i]=='T'||s[i]=='G'||s[i]=='C'){
      count++;
      maximum=max(maximum,count);
    }
    else{
      count=0;
    }
  }
  cout <<maximum <<endl; 
}

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

#define   mp make_pair
#define   pb push_back
#define   ff first 
#define   ss second
#define   IOS ios::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define   endl "\n" 
#define   pll pair<ll, ll>
#define   all(x) x.begin(), x.end()
#define   vll vector<ll> 

const ll inf = (ll)(1e17 + 17);
const ll mod = (ll)(1e9 + 7);
ll dp[1001][10001];
vll a, b;
ll h, n;
ll recurse(ll idx, ll tot) {
	if(tot >= h) return 0;
	if(idx >= n) {
	if(tot >= h) return 0;
	return inf;
  }
	ll &ans = dp[idx][tot];
	if(ans != -1) return ans;
	ans = inf;
	ans = recurse(idx + 1, tot);
	ans = min(ans, b[idx] + recurse(idx , tot + a[idx]));
	return ans;
}
int main(){
 IOS
#ifdef SHAN
    freopen("input.txt" , "r" , stdin);  
#endif
  cin >> h >> n;
  memset(dp, -1, sizeof dp);
  a.resize(n), b.resize(n);
  for(ll i = 0; i < n; i++) cin >> a[i] >> b[i];
  cout << recurse(0, 0);
  return 0;
} //good night.

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

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	int a[32]={1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
	int b;
	cin >>b;
	cout << a[b-1];
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
	std::ios::sync_with_stdio(false);
	string s,t,ans="";
  int i,j,n,m;
  cin>>n;
  cin>>s>>t;
  for(i=0;i<n;i++){
    cout<<s[i];
    cout<<t[i];
  }
	return 0;
}

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

struct UnionFind {
  vector<int> par;
  vector<int> siz;

  UnionFind(int N) : par(N), siz(N, 1) {
    for ( int i = 0; i < N; i++ ) { par[i] = i; }
  }

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

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

  int size(int x) {
    return siz[root(x)];
  }

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

int main() {
  long long n, m;
  cin >> n >> m;
  int a[m], b[m];
  for ( int i = 0; i < m; i++ ) {
    cin >> a[i] >> b[i];
    a[i]--;
    b[i]--;
  }

  UnionFind tree(n);
  long long ans[m+1];
  ans[m] = n * (n-1) / 2;
  for ( int i = m-1; i >= 0; i-- ) {
    if ( tree.same(a[i], b[i]) ) {
      ans[i] = ans[i+1];
    } else {
      ans[i] = ans[i+1] - (tree.size(a[i])*tree.size(b[i]));
      tree.unite(a[i], b[i]);
    }
  }

  for ( int i = 1; i <= m; i++ ) {
    cout << ans[i] << endl;
  }
  return 0;
}


Measured memory_bytes: 5632
from collections import defaultdict, deque
import sys
input = sys.stdin.readline
N, M = map(int, input().split())
edges = [set(range(N)) for i in range(N)]
for i in range(N):
    edges[i].remove(i)
for _ in range(M):
    a, b = map(int, input().split())
    edges[a-1].remove(b-1)
    edges[b-1].remove(a-1)
size = defaultdict(lambda: [0, 0])
color = [-1]*N
def set_color(root):
    
    que = deque([root])
    color[root] = 0
    size[root][0]+=1
    while que:
        v = que.pop()
        for nv in edges[v]:
            if color[nv]<0:
                c = 1- color[v]
                color[nv] = c
                size[root][c]+=1
                que.append(nv)
            elif color[nv] == color[v]:
                print(-1)
                sys.exit()
for i in range(N):
    if color[i]<0:
        set_color(i)
S = set([0])
for a, b in size.values():
    S = set(s+b for s in S)|set(s+a for s in S)
ans = min(x*(x-1)//2+(N-x)*(N-x-1)//2 for x in S)            
print(ans)                

Measured memory_bytes: 35952
#include <bits/stdc++.h>
using namespace std;
using lint = long long;
using P = pair<int, int>;
using vec = vector<int>;
using mat = vector<vector<int>>;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(v) v.begin(), v.end()
#define endl "\n"

constexpr int MOD = 1000000007;
const int INF = 1 << 30;

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

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

int main() {
  int N, L, maxv = 0, sum = 0;
  cin >> N;
  for(int i = 0; i < N; i++){
    cin >> L;
    maxv = max(L, maxv);
    sum += L;
  }
  if(sum - maxv > maxv){ cout << "Yes" << endl;}
  else{ cout << "No" << endl;}
}

Measured memory_bytes: 256
#include <stdio.h>
#include <string.h>
#include <math.h>
#include <stdlib.h>

int main(void) {
	char tmp[1000];
	//????????¢???????¨?
	int height[300];
	int width[300];
	int cnt=0;
	//????????¢???????¨??????\???????¶???????
	while (1) {
		fgets(tmp, sizeof(tmp), stdin);
		height[cnt] = atoi(strtok(tmp," "));
		width[cnt] = atoi(strtok(NULL, " "));
		//????????¨???0????????°?????????
		if (height[cnt]==0&&height[cnt]==0)break;
		cnt++;	
	}
	//??¨??????????§???¢???????????????
	int i, j,k;
	for (i = 0; i < cnt; i++) {
		for (j = 0; j < height[i]; j++) {
			for (k = 0; k < width[i]; k++) {
			    if(j==0||j+1==height[i]||k==0||k+1==width[i])printf("#");
			    else printf(".");
			}
			printf("\n");
		}
		printf("\n");

	}
	return 0;
}

Measured memory_bytes: 524
#include <cstdio>
#include <iostream>
#include <set>
#include <map>
#include <vector>
#include <algorithm>
#include <utility>
#include <string>
#include <cmath>
#include <iomanip>
#include <deque>
#include <queue>
#include <unordered_map>
#include <stack>
#include <bitset>
#include <cstdlib>
#include <sstream>
typedef long long ll;
#define rep(i,n) for(int i=0;i<n;i++)

using namespace std;
ll pow(ll N, ll P){
    if(P==0) return 1;
    if(P%2==0){
        ll t = pow(N, P/2);
        return t*t;
    }
    return N * pow(N, P-1);
}
ll modpow(ll N, ll P,ll k){
    if(P==0) return 1;
    if(P%2==0){
        ll t = modpow(N, P/2,k)%k;
        return t*t%k;
    }
    return N * modpow(N, P-1,k)%k;
}
ll modkai(ll n,ll m,ll k){//n*(n-1)*(n-2)*...(m+1)%k
    if(n == m)return 1;
    return modkai(n-1,m,k)*n%k;
}
ll mod_cnb(ll n,ll m,ll k){//nCm%k,kは十分大きい素数
  int m_=modkai(m,0,k);
  return modkai(n,n-m,k)*modpow(m_,k-2,k)%k;
}
ll gcd(ll n,ll m){
    ll n_ = max(n,m);
    ll m_ = min(n,m);
    if(n_%m_ == 0)return m_;
    return gcd(m_,n_%m_);
}
ll lcm(ll n,ll m){
    return n*m/gcd(n,m);
}

int main() {
  int a[3];cin>>a[0]>>a[1]>>a[2];
  sort(a,a+3);
  cout<<a[2]*10+a[0]+a[1]<<endl;
}

Measured memory_bytes: 256
#include <string>
#include <iostream>
#include <stack>
#include <queue> // priority_queue も入ってる
#include <set>   // 要素数は size() で取得 multisetもある
#include <map>
#include <array> // sizeはコンパイル時定数で固定
#include <vector>
#include <numeric>   // accumulate, gcd
#include <algorithm> // count_ifに必要
#include <iomanip>   // cout << setprecision(15) << x で小数の出力精度を指定
#include <tuple>
#include <utility> //pair
#include <cmath>
#include <random>

using namespace std;
// 問題が起こるまでintは使用禁止2020-04-13
using ll = long long;

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

template <class InputIterator, class T>
bool contains_itr(InputIterator iterator, const T &value)
{
    if (find(iterator.begin(), iterator.end(), value) == iterator.end())
        return false;
    else
        return true;
}

template <class T>
bool contains_set(set<T> st, const T &value)
{
    if (st.find(value) == st.end())
    {
        return false;
    }
    else
    {
        return true;
    }
}

template <class InputIterator>
auto sum(InputIterator iterator)
{
    return accumulate(iterator.begin(), iterator.end(), 0);
}

// endは排他的(exclusive)なので注意
vector<ll> range(ll begin, ll end)
{
    vector<ll> result;
    for (ll i = begin; i < end; ++i)
    {
        result.push_back(i);
    }
    return result;
}

random_device seed_gen;
mt19937 engine(seed_gen());
// 0, 1, 2 のどれかが得られる一様分布
// uniform_int_distribution<> dist(0, 2);
// cout << dist(engine) << endl;
// みたいに、先に確率分布を宣言して、そこにengineを与えて使う。

// =========ここまでテンプレ============

int main()
{
    ll n;
    cin >> n;
    vector<ll> xy(n);
    vector<ll> yx(n);
    rep(i, n)
    {
        ll x, y;
        cin >> x >> y;
        xy[i] = x + y;
        yx[i] = x - y;
    }
    sort(xy.begin(), xy.end());
    sort(yx.begin(), yx.end());
    cout << max(*(xy.rbegin()) - *(xy.begin()), *(yx.rbegin()) - *(yx.begin())) << endl;
    return 0;
}

Measured memory_bytes: 5952
#include<iostream>
#include<vector>
#include<algorithm>

using namespace std;

int main(){
	int n, m, ans = 0;
	cin >> n >> m;
	vector<vector<int>> a(n, vector<int>(m + 1));
	vector<int> pos(n), stop(m + 1);
	ans = n;
	for(int i = 0; i < n; i++){
		for(int j = 0; j < m; j++){
			cin >> a[i][j];
		}
	}
	for(int i = 0; i < m; i++){
		vector<int> cnt(m + 1, 0);
		for(int j = 0; j < n; j++){
			 cnt[a[j][pos[j]]]++;
		}
		int t = 0, u = 0;
		for(int j = 1; j <= m; j++){
			if(t < cnt[j]){
				t = cnt[j];
				u = j;
			}
		}
		stop[u] = 1;
		ans = min(ans, t);
		for(int j = 0; j < n; j++){
			while(stop[a[j][pos[j]]] == 1) pos[j]++;
		}
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 640
import sys
from collections import deque
readline = sys.stdin.readline

N, M = map(int, readline().split())
Edge = [[] for _ in range(N)]

for _ in range(M):
    a, b = map(int, readline().split())
    a -= 1
    b -= 1
    Edge[a].append(b)
    Edge[b].append(a)

Q = int(readline())
VDC = [map(int, readline().split()) for _ in range(Q)]
VDC.reverse()

table = [-1]*N
Col = [[0]*11 for _ in range(N)]
for v, d, c in VDC:
    v -= 1
    if table[v] >= d:
        continue
    Q = deque([(v, d)])
    while Q:
        vn, dn = Q.pop()
        Col[vn][dn] = c
        table[vn] = dn
        for vf in Edge[vn]:
            if table[vf] < dn-1:
                Q.appendleft((vf, dn-1))
Ans = [0]*N
for i in range(N):
    for j in range(11):
        if Col[i][j]:
            Ans[i] = Col[i][j]
            break
print('\n'.join(map(str, Ans)))


Measured memory_bytes: 127024
#include <iostream>
#include <string>
#include <math.h>
#include <stdio.h>
#include <algorithm>
#include <iomanip>
#include <sstream>

using namespace std;

int N;

int main(){
    
    cin >> N;
    
    long long L[N+1], ans;
    
    if(N == 1) ans = 1;
    else{
        L[0] = 2, L[1] = 1;
        
        for(int i = 2; i < N+1; i++) L[i] = L[i-1] + L[i-2];
        
        ans = L[N];
    }
    cout << ans << endl;
    
    return 0;
}

    

Measured memory_bytes: 256
import heapq

N, M = list(map(int,input().split()))
A = []
for i in range(N):
    in1, in2 = list(map(int,input().split()))
    A.append([in1, in2])

A = sorted(A)
ans = 0
day = 1
cnt = 0
x = []

for i in range(M):
    while(cnt < N):
        if A[cnt][0] == day:
            heapq.heappush(x, -A[cnt][1])
            cnt += 1
        else:
            break
    if x:  ans -= heapq.heappop(x)
    day += 1

print(ans)

Measured memory_bytes: 93876
import Control.Monad
import Data.List

del :: [String] -> [String]
del = filter (\a -> not . all (== '.') $ a)

main :: IO ()
main = do
    [h, w] <- fmap (map read . words) getLine :: IO [Int]
    a <- replicateM h getLine
    putStr . unlines . transpose . del . transpose . del $ a

Measured memory_bytes: 1916
#include<iostream>
#include<algorithm>
using namespace std;
int N,A[3<<17];
main()
{
  cin>>N;
  for(int i=0;i<3*N;i++)cin>>A[i];
  sort(A,A+3*N);
  long ans=0;
  for(int i=0;i<N;i++)ans+=A[N+i*2];
  cout<<ans<<endl;
}

Measured memory_bytes: 1408
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		String[] W = new String[N + 1];
		W[0] = null;
		int count_a = 0;
		int count_b = 0;
		
		for(int i = 1; i < (N + 1); i++) {
			W[i]  = sc.next();
			if((i >= 2) && (W[i].charAt(0) == W[i - 1].charAt(W[i - 1].length() - 1))) {
				count_a++;
			}
		}
		
		for(int i = 2; i < (N + 1); i++) {
			for(int j = 1; j < i; j++) {
				if(W[i].equals(W[j])) {
					count_b++;
				}
			}
		}
		
		
		if((count_a == (N - 1)) && count_b == 0) {
			System.out.println("Yes");
		} else {
			System.out.println("No");
		}		
	}
}


Measured memory_bytes: 23508
//### In The Name Of GOD ###

//%% Remember; (((He))) is The (((Accepter))) %%

// GOD IS GREATER ...

#include <bits/stdc++.h>

using namespace std;

typedef long long ll ;
typedef long double ld ;

#define int ll
#define pb push_back
#define bp pop_back
#define pf push_front
#define fp pop_front
#define X first
#define Y second
#define IO ios_base::sync_with_stdio(false);
#define sz(a) (int)(a.size())
#define sg(a, b) (a + b - 1) / b

const int MOD = 1000 * 1000 * 1000 + 7;
const int INF = 8 * 1000 * 1000 + 200;
const int MAXN =  100 * 1000 + 1;
const int MLOG = 18;
const int NMAX = 20;

signed main(){
	IO;
	int n, a;
	cin >> n;
	map<int, int> mp;
	for(int i = 0; i < n; i++) cin >> a, mp[a]++;
	if((n - sz(mp)) % 2){
		cout << sz(mp) - 1;
	}else{
		cout << sz(mp);
	}
}

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

int main(){
    int n,k;
    cin >> n >> k;
    int lmx = (n-1) * (n-2) / 2;
    if(k > lmx) {
        cout << "-1" << endl;
        return 0;
    }
    vector<pair<int,int>> vp;
    // star
    rep(i,n-1){
        vp.push_back({1,i+2});
    }
    int adl = lmx-k;
    int cur = 0;
    for(int i=2;i<=n-1 && cur<adl;i++){
        for(int j=i+1;j<=n && cur<adl;j++){
            vp.push_back({i,j});
            cur++;
        }
    }
    cout << vp.size() << endl;
    rep(i,vp.size()){
        cout << vp.at(i).first << " " << vp.at(i).second << endl;
    }
    return 0;
}

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

int main() {
    int n;
    cin >> n;
    int border = 1;
    for(int i = 0; i < 10; i++){
        if(n >= border){
            border = border * 2;
        } else if(n < border){
            break;
        }
    }
    cout << border / 2 << endl;    
}

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

const double PI = 3.14159265358979323846;
using namespace std;
typedef long long ll;
const double EPS = 1e-9;
#define rep(i, n) for (int i = 0; i < (n); ++i)
//typedef pair<ll, ll> P;
typedef pair<ll, ll> P;
const ll INF = 10e17;
#define cmin(x, y) x = min(x, y)
#define cmax(x, y) x = max(x, y)
#define ret() return 0;

std::istream &operator>>(std::istream &in, set<int> &o) {
    ll a;
    in >> a;
    o.insert(a);
    return in;
}

std::istream &operator>>(std::istream &in, queue<int> &o) {
    ll a;
    in >> a;
    o.push(a);
    return in;
}

bool contain(set<int> &s, int a) { return s.find(a) != s.end(); }

//ifstream myfile("C:\\Users\\riku\\Downloads\\0_00.txt");
//ofstream outfile("log.txt");
//outfile << setw(6) << setfill('0') << prefecture << setw(6) << setfill('0') << rank << endl;
// std::cout << std::bitset<8>(9);
const int mod = 1000000007;
//const ll mod = 1e10;
typedef priority_queue<string, vector<string>, greater<string> > PQ_ASK;

int check(int n, vector<int> &times) {
    int ans = 24;
    for (int i = 0; i < n; i++) {
        for (int j = i + 1; j < n; j++) {
            int k = abs(times[i] - times[j]);
            assert(k <= 24);
            int now = min(k, 24 - k);
            cmin(ans, now);
        }
    }
    return ans;
}

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

    vector<int> times(n);
    rep(i, n) cin >> times[i];


    n++;
    times.push_back(0);
    vector<int> counter(13);

    for (int i : times) counter[i]++;

    {
        int max = *max_element(counter.begin(), counter.end());
        if (max >= 3) {
            cout << 0 << endl;
            ret();
        }
    }

    int ans = 0;
    for (int i = 0; i < (1 << 13); i++) {
        vector<int> tmp;
        for (int j = 0; j < 13; j++) {
            if (counter[j] == 0) continue;
            else if (counter[j] == 1) {
                int g = (i >> j) & 1;
                if (g) {
                    tmp.push_back(j);
                } else {
                    tmp.push_back(24 - j);
                }
            } else if (counter[j] == 2) {
                tmp.push_back(j);
                tmp.push_back(24 - j);
            }
        }
        int now = check(n, tmp);
        cmax(ans, now);
    }
    cout << ans << endl;
}



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

using namespace std;

#define rep(i, n) for (ll i = 0; i < (n); ++i)
#define fin(ans) cout << (ans) << endl;
#define blank(ans) cout << (ans) << " ";
#define mp(p, q) make_pair(p, q)
#define pb(n) push_back(n)
#define all(a) a.begin(), a.end()

typedef long long ll;
typedef long long lli;
typedef unsigned long long ull;
typedef long double ld;
typedef string str;

typedef vector<char> vc;
typedef vector<bool> vb;
typedef vector<ld> vd;
typedef vector<str> vs;
typedef vector<ll> vll;
typedef vector<pair<ll, ll>> vpll;
typedef vector<pair<ll, str>> vpls;
typedef vector<tuple<str, ll, ll>> vtsl;
typedef vector<vector<ll>> vvll;
typedef vector<vector<char>> vvc;
typedef vector<vector<str>> vvs;

const ld PI = acos(-1.0);
const ll MAX = 9000000000000000000;
const ll MIN = -9000000000000000000;
const ld DMAX = 4500;
const ld DMIN = -4500;
const ll MOD = 1000000007;

//実行部
void Main()
{
  ll a, b, c; cin >> a >> b >> c;
  if(a == b) fin(c)
  else if(a == c) fin(b)
  else fin(a)
}

//前処理
int main()
{
  //ios::sync_with_stdio(false);
  //cin.tie(0);
  cout << fixed << setprecision(20); //高精度少数表示
  Main();
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <map>
#include <vector>
#include <queue>
#include <algorithm>

using namespace std;

//typedef pair<int,int> P;


int main(){
	int N,C;
	int D[30][30];
	int c[500][500];

	scanf("%d %d", &N, &C);
	for(int i=0;i<C;i++){
		for(int j=0;j<C;j++){
			scanf("%d", &D[i][j]);
		}
	}
	for(int i=0;i<N;i++){
		for(int j=0;j<N;j++){
			scanf("%d", &c[i][j]);
		}
	}

	long long ans = 1000*500*500;
	int num[30][3];
	for(int i=0;i<30;i++){
		for(int j=0;j<3;j++){
			num[i][j] = 0;
		}
	}
	for(int i=0;i<N;i++){
		for(int j=0;j<N;j++){
			num[c[i][j]-1][(i+j)%3]++;
		}
	}
	for(int i=0;i<C;i++){
		for(int j=0;j<C;j++){
			for(int k=0;k<C;k++){
				if(i==j || j==k || k==i) continue;
				long long tmp = 0;
				for(int l=0;l<30;l++) tmp += D[l][i]*num[l][0];
				for(int l=0;l<30;l++) tmp += D[l][j]*num[l][1];
				for(int l=0;l<30;l++) tmp += D[l][k]*num[l][2];
				if(tmp<ans) ans = tmp;
				//printf("%lld ",tmp);
			}
		}
	}

	printf("%lld\n", ans);

	return 0;
}


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

using namespace std;

using ll = long long;
using vi = vector<int>;

const ll linf = 1LL << 62;
const int inf = 999999;
const int dx[4] = {1,0,-1,0};
const int dy[4] = {0,1,0,-1};
const ll atcoder = int(1e9 + 7);

#define Endl endl
#define pr(x) cout << x << endl
#define chmax(x,y) x = max(x,y)
#define chmin(x,y) x = min(x,y)
#define all(x) x.begin(),x.end()
#define atcoder(int)1e9+7
#define rep(i,n) for(int i = 0;i<n;i++)
#define pb(x) push_back(x)
#define mp(a,b) make_pair(a,b)


ll gcd(ll a, ll b) {//最大公約数
	if (a%b == 0)return b;
	else gcd(b, a%b);
}

ll lcm(ll a, ll b) {//最小公倍数
	return (a / gcd(a, b))*b;
}

int  main() {
	
	int x, y;
	cin >> x >> y;
	int ans = 0;

	if (abs(x) < abs(y)) {
		if (x < 0)ans++;
		ans += abs(y) - abs(x);
		if (y < 0)ans++;
	}
	else {
		if (x > 0)ans++;
		ans += abs(x) - abs(y);
		if (y > 0)ans++;
	}
	
	pr(ans);
	return 0;

}

Measured memory_bytes: 256
from collections import deque


def main():
    H, W = map(int, input().split())
    maze = []
    wn = 0
    for _ in range(H):
        maze.append(input())
        wn += maze[-1].count(".")
    pc = -1
    que = deque([(0, 0, 1)])
    visited = {(0, 0)}
    while que:
        y, x, d = que.popleft()
        if y == H-1 and x == W-1:
            pc = d
        for dy, dx in moves:
            ny, nx = y+dy, x+dx
            if 0 <= ny < H and 0 <= nx < W and maze[ny][nx] == "." and (ny, nx) not in visited:
                que.append((ny, nx, d+1))
                visited.add((ny, nx))
    if pc == -1:
        print(-1)
    else:
        print(wn-pc)


if __name__ == "__main__":
    moves = [(1, 0), (-1, 0), (0, 1), (0, -1)]
    main()


Measured memory_bytes: 3572
// ABC122_C
#include <iostream>
#include <string>
#include <vector>
#include <iterator>  // std::prev(iter, n) n 個分デクリメントしたイテレータ
#include <tuple>
#include <map>
#include <unordered_map>
#include <set>
#include <unordered_set>
#include <stack>
#include <queue>
#include <algorithm>
#include <functional>  // std::greater<T>()
#include <utility>  // std::swap()
#include <numeric>  // accumulate(ALL(vec), 0)  0 は初期値
#include <bitset>  // static_cast<std::bitset<8>>
#include <sstream>  // std::stringstream
#include <cmath>
#include <climits>  // INT_MIN
#include <cctype>  // std::isdigit()
#include <iomanip>  // std::setprecision()
using namespace std;
using ll = long long;

#define REP(i, n) for (ll i=0; i < n; i++)  // 0 ~ n-1
#define MIN(vec) min_element(vec.begin(), vec.end())  // イテレータのため、値を取り出すときは * を先頭につける
#define MAX(vec) max_element(vec.begin(), vec.end())
#define IDX(vec, element_iter) distance((vec).begin(), element_iter)
#define SUM(vec) accumulate(vec.begin(), vec.end(), 0LL)  // 0 は初期値
#define pll pair<ll, ll>
#define F first
#define S second
const ll INF = 1LL<<60;  // 10^18（const int inf   = 1<<29;）

int main() {
    // input(sunippets: inpv, inpn, inps)
    ll N, Q, l, r;
    cin >> N >> Q;
    string S;
    cin >> S;
    
    // calculation
    // if (N == 2) {
        
    // } else {
        vector<ll> num(N, 0);
        REP(i, N-1) {
            if (S[i] == 'A' && S[i+1] == 'C') {
                num[i] = 1;
                num[i+1] = 1;
            }
        }
        vector<ll> partial = num; // copy vec
        partial_sum(num.begin(), num.end(), partial.begin());
        partial.insert(partial.begin(), 0);
        
        ll tmp;
        REP(i, Q) {
            cin >> l >> r;
            tmp = partial[r] - partial[l-1];
            if (tmp >= 2) {
                if (S[l-1] == 'C' && num[l-1] == 1) --tmp;
                if (S[r-1] == 'A' && num[r-1] == 1) --tmp;
            }
            tmp /= 2;
            
            cout << tmp << "\n";
        }
    // }
    
    return 0;
}

Measured memory_bytes: 2816
#import <stdio.h>

typedef unsigned long long UINT;

int main(){
    UINT a,b;
    scanf("%llu %llu", &a,&b);
    UINT s = a%2;
    UINT e = b%2;
    UINT r;
    if(s==0 && e==1){
        r = (b+1-a)/2 % 2;
    }
    if(s==0 && e==0){
        r = ((b-a)/2 % 2) ^ b;
    }
    if(s==1 && e==1){
        r = ((b-a)/2 % 2) ^ a;
    }
    if(s==1 && e==0){
        r = ((b-1-a)/2 % 2) ^ a ^ b;
    }
    printf("%llu\n", r);
    return 0;
}



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

typedef long long int ll;
typedef long long unsigned int ull;
typedef long double ld;
typedef vector<int> vr;
typedef pair<int, int> pr;
#define pb push_back
#define ff first
#define ss second
#define INF 1999999999
#define MODA 1000000007
#define PI 3.1415926535897932384626433
#define endl "\n"
//cout << fixed << setprecision(2);

int main()
{
    // freopen("input.txt", "r", stdin);
    // freopen("output.txt", "w", stdout);
    ios::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    string s;
    cin >> s;
    int len = s.size();
    int cnt = 0;
    if(len % 2 != 0){
        cout << "No" << endl;
        exit(0);
    }
    for(int i = 0; i < len; i+=2){
        if(s[i] != 'h' || s[i+1] != 'i'){
            //cout << s[i] << " " << s[i+1] << endl;
            cout << "No" << endl;
            exit(0);
        }
    }
    cout << "Yes" << endl;
    return 0;
}



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

int main(){
    ll n,k,ans=mod;
    cin>>n>>k;
    ll x[100009];
    rep(i,n) cin>>x[i];
    rep(i,n-k+1){
        ll da=x[i+k-1]-x[i]+min(abs(x[i+k-1]),abs(x[i]));
        ans=min(ans,da);
    }
    cout<<ans<<endl;
}


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

ll n, ans, divisor;

int main() {
  cin >> n;
  if (n%2 == 1) {
    ans = 0;
  } else {
    ans = 0;
    divisor = 2;
    rep (i, 25) {
      divisor *= 5;
      ans += n / divisor;
    }
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 3580
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define mod 1000000007
const int N=200005;

ll modulo(ll num,ll MOD=mod){ return ((num%MOD)+MOD)%MOD;} // for negative integer
ll power(ll b,ll e,ll MOD=mod){ll ans=1; while(e){if(e%2) ans=(ans*b)%MOD; b=(b*b)%MOD; e/=2;} return ans;}
 

int main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    /*#ifndef ONLINE_JUDGE
    // for getting input from input.txt
    freopen("input.txt", "r", stdin);
    // for writing output to output.txt
    freopen("output.txt", "w", stdout);
    #endif*/
    cout<<fixed<<setprecision(15);
    
    ll n;
    cin>>n;
    string s;
    cin>>s;
    ll cnt=0;
    for(int i=0;i<n;i++) {
        while(s[i]==s[i+1]) {
            i++;
        }
        cnt++;
    }
    cout<<cnt;

    return 0;
}

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

#define N 8
#define FREE -1
#define NOT_FREE 1

int row[N],col[N],dpos[2*N-1],dneg[2*N-1];

bool X[N][N];

//????§????
void initialize()
{
	for(int i=0;i<N;i++){row[i]=FREE,col[i]=FREE;}
	for(int i=0;i<2*N-1;i++){dpos[i]=FREE;dneg[i]=FREE;}
}

//?????°
void printBoard()
{
	//?¢?????????????????????????????????????
	for(int i=0;i<N;i++)
		for(int j=0;j<N;j++)
			if(X[i][j]&&row[i]!=j)return;
			
	for(int i=0;i<N;i++)
	{
		for(int j=0;j<N;j++)
		{
			cout<<((row[i]==j)?"Q":".");
		}
		cout<<endl;
	}
}

void recursive(int i)
{
	//??????????????????
	if(i==N)
	{
		printBoard();
		return;
	}
	
	for(int j=0;j<N;j++)
	{
		//??????(i,j)?????°??¶?????????????????????????????\??\??????
		if(NOT_FREE==col[j]||
		   NOT_FREE==dpos[i+j]||
		   NOT_FREE==dneg[i-j+N-1])continue;
		
		//??¨(i,j)????????????
		row[i]=j;
		col[j]=dpos[i+j]=dneg[i-j+N-1]=NOT_FREE;
		
		//?°?????????????
		recursive(i+1);
		
		//??????????????¨(i,j)?????????
		row[i]=col[j]=dpos[i+j]=dneg[i-j+N-1]=FREE;
	}
}

int main()
{
	initialize();
	
	for(int i=0;i<N;i++)
		for(int j=0;j<N;j++)
			X[i][j]=false;
			
	int k;cin>>k;
	for(int i=0;i<k;i++)
	{
		int r,c;cin>>r>>c;
		X[r][c]=true;
	}
	
	recursive(0);
}

Measured memory_bytes: 3104
#include<iostream>
#include<string.h>
#include<iomanip>
#include<vector>
#include<algorithm>
#include<tgmath.h>
#include<cstdio>
using namespace std;
#define SWAP(a,b) { \
                    a^=b;\
                    b^=a;\
                    a^=b;\
}
void shift(char a[],int n)
{
    if(n==1)
        return;
    char c;
    c=a[n-1];
    for(int i=n-1;i>0;i--)
    {

        a[i]=a[i-1];
    }
    a[0]=c;
    return;
}
int main()
{

    int i,j,k,m,n,val,t=0,test;
    char a[1000],b[1000];
    cin>>a>>b;
    n=strlen(a);
    for(i=0;i<n;i++){
        if(strcmp(a,b)==0) {
            printf("Yes\n");
            return 0;
        }
        shift(a,n);
    }
    printf("No\n");
    //free();   //if pointer array
    return 0;
}


Measured memory_bytes: 256
import java.util.*;
public class Main
{
	public static void main(String args[])
	{
		Scanner input = new Scanner(System.in);
		int a, b, c;
		while(true)
		{
			a = input.nextInt();
			b = input.nextInt();
			c = input.nextInt();
			if(a == -1  && b == -1 && c == -1)
				break;
			else {
				if(a == -1 || b == -1)
					System.out.println("F");
				else if(a+b < 30)
					System.out.println("F");
				else if(a+b < 50){
					if(c == -1){
						System.out.println("D");
					}
					else {
						if(c >= 50)
							System.out.println("C");
						else
							System.out.println("D");
					}
				}
				else if(a+b < 65)
					System.out.println("C");
				else if(a+b < 80)
					System.out.println("B");
			
				else if(a+b >= 80)
					System.out.println("A");
			}
		}
	}
}

Measured memory_bytes: 26580
using System;
using System.Collections;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Numerics;
using System.Text;
using System.Threading.Tasks;
using static System.Console;
using static System.Math;
class Z { static void Main() => new K(); }
class K
{
	int F => int.Parse(Str);
	long FL => long.Parse(Str);
	int[] G => Strs.Select(int.Parse).ToArray();
	long[] GL => Strs.Select(long.Parse).ToArray();
	string Str => ReadLine();
	string[] Strs => Str.Split(new char[] { ' ', '\t' }, StringSplitOptions.RemoveEmptyEntries);
	const int MOD = 1000000007;
	public K()
	{
		SetOut(new StreamWriter(OpenStandardOutput()) { AutoFlush = false });
		Solve();
		Out.Flush();
	}
	void Solve()
	{
		var I = G;
		WriteLine(I[0] + I[1] / 2);
	}
}


Measured memory_bytes: 11220
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> P;
typedef pair<ll,ll> l_l;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
#define fi first
#define se second
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
const int INF=1001001000;
const int mINF=-1001001000;
const ll LINF=1010010010010010000;
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;
}
//グリッド：（典型）dp,dfs,bfs,最短経路,その他
int main(){
    int k,n;cin >> k >> n;
    vl a(n);
    rep(i,n) cin >> a[i];
    sort(a.begin(),a.end());
    vl d(n);
    rep(i,n){
        if(i>=1&&i<n-1) d[i]=min(k-a[i]+a[i-1],a[i]+k-a[i+1]);
        if(i==0) d[i]=min(a[n-1]-a[i],a[i]+k-a[i+1]);
        if(i==n-1) d[i]=min(a[n-1]-a[0],k-a[n-1]+a[n-2]);
    }
    sort(d.begin(),d.end());
    cout << d[0] << endl;
    return 0;
}

Measured memory_bytes: 3328
#include<iostream>//第1题
#include<string>
#include<algorithm>
using namespace std;int main()
{
 int n = 0, A[100] = {0},a=0,b=0;
 cin >> n;
 for (int i = 0; i < n; i++)
 {
  cin >> A[i];
 }
 for (int i = 0; i < n; i++)
 {
  a = max(A[i], a);
 }
 for (int i = 0; i < n; i++)
 {
  b = A[i] + b;
 }
 b = b - a;
 if (b > a)
 {
  cout << "Yes";
 }
 else
 {
  cout << "No";
 }
 return 0;
}

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

int main() {
  string s,t;
  cin>>s>>t;
  for (int i=0;i<s.length();i++){
    if (s[i]!=t[i]){
      cout<<"No"<<endl;
      goto loop;
    }
  }
  cout<<"Yes"<<endl;
  loop:
  return 0;
}

Measured memory_bytes: 3096
# python3
# -*- coding: utf-8 -*-
import sys
import math
import bisect
from fractions import gcd
from itertools import count, permutations
from functools import lru_cache
from collections import deque, defaultdict
from pprint import pprint

INF = float('inf')

ii = lambda: int(input())
mis = lambda: map(int, input().split())
lmis = lambda: list(mis())
lmtx = lambda h: [list(map(int, lmis())) for _ in range(h)]
sys.setrecursionlimit(1000000000)


def lcm(a, b):
    return (a * b) // gcd(a, b)


# main
n, x, y = mis()

ans = [0] * n

for i in range(1, n):
    for j in range(i+1, n+1):
        ans[min(abs(j-i),
                abs(x-i)+1+abs(j-y),
                abs(y-i)+1+abs(j-x))] += 1

for i, a in zip(range(len(ans)), ans):
    if i == 0:
        continue
    print(a)


Measured memory_bytes: 5560
//submitted by Himj
#include<bits/stdc++.h>
#define ll long long
#define mod 1000000007
#define pb push_back
#define fi first
#define se second
#define fr(i,s,e) for(i=s;i<e;i++)
#define ms(arr,val) memset(arr,val,sizeof(arr))
using namespace std;

const int mxn=2e5+1;

ll dp[2][mxn];
ll arr[101];
ll n;
ll solve(int turn,int left,int temp)
{
  //cout<<temp<<" "<<turn<<" "<<left<<"\n";
  if(left<=0)
    return turn==1;
  
  int i;
  int ans=0;
  if(turn)
    ans=1;
  if(dp[turn][left]!=-1)
    return dp[turn][left];
  fr(i,0,n)
  {
    if(arr[i]<=left)
    {
      
      if(turn)
        ans&=solve(turn^1,left-arr[i],temp+1);
      else
        ans|=solve(turn^1,left-arr[i],temp+1);
    }
  }
  return dp[turn][left]=ans;
}
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);

  int t=1;
  //cin>>t;
    while(t--){
      cin>>n;
      int k,i;
      cin>>k;
      fr(i,0,n)
      cin>>arr[i];
      ms(dp,-1);
      bool ans=solve(0,k,0);
      if(ans)
        cout<<"First";
      else cout<<"Second";
      
       
    }
  return 0;
  }



Measured memory_bytes: 11136
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int A = sc.nextInt();
        int B = sc.nextInt();
        int H = sc.nextInt();
        int M = sc.nextInt();

        int m = H*60+M;

        double distance = Math.sqrt((A*Math.cos(m*Math.PI/30)-B*Math.cos(m*Math.PI/360))*(A*Math.cos(m*Math.PI/30)-B*Math.cos(m*Math.PI/360))
                +(A*Math.sin(m*Math.PI/30)-B*Math.sin(m*Math.PI/360))*(A*Math.sin(m*Math.PI/30)-B*Math.sin(m*Math.PI/360)));

        System.out.println(distance);
    }
}


Measured memory_bytes: 35956
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<utility>
#include<map>
#include<queue>
#include<set>
#include<bitset>
#include<stdio.h>
#include<deque>
using namespace std;
#define rep(i, n) for(int i = 0; i < n; i++)
typedef long long ll;

int main()
{
    int n;
    cin >> n;
    vector<int> v(n);
    rep(i, n)cin>> v[i];
    deque<int> dq;
    rep(i, n){
        if(n %2 == 0){
            if((i+1)%2 == 0){
                dq.push_front(v[i]);
            }
            else{
                dq.push_back(v[i]);
            }
        }
        else{
            if((i+1)%2 == 0){
                dq.push_back(v[i]);
            }
            else{
                dq.push_front(v[i]);
            }
        }
    }
    rep(i, n){
        cout << dq[i] << " ";
    }
    cout << endl;
    return 0;
}

Measured memory_bytes: 3840
#include <stdio.h>

int main(){

  int a[100010]={0};
  int n,i,num,ans=0;

  scanf("%d",&n);

  for(i = 0; i < n; i++){
    scanf("%d",&num);
    a[num] = 1;
  }
  for(i = 0; i < 100010; i++){
    ans += a[i];
  }
  if(ans%2 ==0) ans -= 1;

  printf("%d\n",ans);
  return 0;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
#define ll long long 
int gcd(int a, int b) 
{ 
    if (b == 0) 
        return a; 
    return gcd(b, a % b); 
} 
  
// Returns LCM of array elements 
ll findlcm(ll arr[],ll n) 
{ 
    // Initialize result 
    ll ans = arr[0]; 
  
    // ans contains LCM of arr[0], ..arr[i] 
    // after i'th iteration, 
    for (int i = 1; i < n; i++) 
        ans = (((arr[i] * ans)) / 
                (gcd(arr[i], ans))); 
  
    return ans; 
} 
int main() {
     ios::sync_with_stdio(false);
  cin.tie(0);

   ll k,a,b;
   cin>>k>>a>>b;
   ll fl=0;
   for(int i=a;i<=b;i++){
   if(i%k==0){
   cout<<"OK"<<endl;
   fl=1;
   break;}
}
if(fl==0)
cout<<"NG"<<endl;

  
	// your code goes here
	return 0;
}


Measured memory_bytes: 3640
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <math.h> // sqrt
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <iomanip> // setprecision
using namespace std;
using ll = long long;
using ld = long double;
using vi = vector<int>;
using vb = vector<bool>;
using vll = vector<long long>;
using pii = pair<int, int>;
using psi = pair<string, int>;

int main() {
    int N;
    cin >> N;
    vi b(N - 1);
    for (int i = 0; i < N - 1; i++) {
        cin >> b.at(i);
    }
    int ans = b.at(0);
    for (int i = 0; i < N - 2; i++) {
        ans += min(b.at(i), b.at(i + 1));
    }
    ans += b.at(N - 2);
    cout << ans << endl;
}

Measured memory_bytes: 3640
// 木の直径
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<stack>
#include<algorithm>
#include<iostream>
#include<cmath>
#include<vector>
#include<queue>

using namespace std;

#define MAX 100000
#define INFTY ( 1 << 30 )

class Edge
{
    public:
        int t, w;
        Edge(){}
        // t : 辺の end 側の頂点,  w : 辺の重み
        Edge(int t, int w): t(t), w(w){}
};

vector<Edge> G[MAX];
int n;

// 任意のスタート点から、各頂点までの距離を保持する配列
int d[MAX];

// 任意の頂点からの距離を求める関数
// s : スタートする頂点
void bfs(int s)
{
    for(int i = 0; i < n; i++)
    {
        // 距離情報の初期化
        d[i] = INFTY;
    }

    queue<int> Q;
    // スタート点の情報を設定する
    Q.push(s);
    d[s] = 0;

    int u;

    while( !Q.empty() )
    {
        u = Q.front();
        Q.pop();

        for(unsigned int i = 0; i < G[u].size(); i++)
        {
            Edge e = G[u][i];

            // 未訪問の頂点について, 始点からの距離を求める
            if( d[e.t] == INFTY )
            {
                d[e.t] = d[u] + e.w;
                Q.push(e.t);
            }
        }
    }
}

// 木の直径を求める関数
void solve()
{
    // -------------------------------------
    // 適当な始点 s から最も遠い節点 tgt を求める
    // -------------------------------------
    bfs(0);

    int maxv = 0;
    int tgt = 0;

    for(int i = 0; i < n; i++)
    {
        if( d[i] == INFTY )
        {
            continue;
        }

        if( maxv < d[i] )
        {
            maxv = d[i];
            tgt = i;
        }
    }

    // -------------------------------------
    // tgt から最も遠い節点の距離 maxv を求める
    // -------------------------------------
    bfs(tgt);

    maxv = 0;

    for(int i = 0; i < n; i++)
    {
        if( d[i] == INFTY )
        {
            continue;
        }

        maxv = max(maxv, d[i]);
    }

    cout << maxv << endl;
}

int main(void)
{
    int s, t, w;

    cin >> n;

    for(int i = 0; i < n - 1; i++)
    {
        cin >> s >> t >> w;

        // 双方向に設定する
        G[s].push_back(Edge(t, w));
        G[t].push_back(Edge(s, w));
    }

    solve();

    return 0;
}



Measured memory_bytes: 9816
n = int(input())
d = dict()
m = 0
for i in range(n):
    s = input()
    d[s] = d.get(s, 0) + 1
    m = max(m, d[s])
res = list()
for k, v in d.items():
    if v == m:
        res.append(k)
res.sort()
for r in res:
    print(r)
    

Measured memory_bytes: 32144
#include <bits/stdc++.h>
using namespace std;
#define REP(i,n) for(int i=0;i<(int)(n);i++)
#define FOR(i,a,b) for(int i=(int)(a);i<(int)(b);i++)

#define CHMIN(a,b) (a)=min((a),(b))
#define CHMAX(a,b) (a)=max((a),(b))

typedef long long ll;

int N,A,B;
int a[830], b[830];
int c[830];

bool g[830][830];

int main(){
  scanf("%d%d%d",&N,&A,&B);
  REP(i,N)scanf("%d%d",a+i,b+i);
  REP(i,N)c[i] = a[i]-b[i];
  int ans = 0;
  vector<int> pos, neg;
  REP(i,N){
    if(abs(c[i])<=A || (B<=abs(c[i]) && abs(c[i])<=2*A)){
      ans++;
    }else{
      (c[i]<0 ? neg : pos).push_back(c[i]);
    }
  }
  int n = pos.size(), m = neg.size();
  REP(i,n)REP(j,m){
    int x = pos[i] + neg[j];
    if(abs(x)<=A || (B<=abs(x) && abs(x)<=2*A)){
      g[i][n+j] = true;
    }else{
      g[i][n+j] = false;
    }
  }
  int s = n+m;
  int t = n+m+1;
  REP(i,n)g[s][i] = true;
  REP(j,m)g[n+j][t] = true;
  while(true){
    vector<int> bef(n+m+2, -1);
    vector<bool> used(n+m+2, false);
    stack<int> S;
    S.push(s);
    used[s] = true;
    while(!S.empty()){
      int p = S.top(); S.pop();
      REP(to,n+m+2)if(!used[to]){
        if(!g[p][to])continue;
        used[to] = true;
        bef[to] = p;
        S.push(to);
      }
    }
    if(!used[t])break;
    int cur = t;
    while(cur != s){
      int b = bef[cur];
      g[b][cur] = false;
      g[cur][b] = true;
      cur = b;
    }
    ans++;
  }
  printf("%d\n",ans);
  return 0;
}


Measured memory_bytes: 3848
import math
D, G = map(int,input().split())
p = [0] * D
c = [0] * D
for i in range(D):
    p[i], c[i] = map(int, input().split())
ans = 10**10
for i in range(2**D):
    rest = G
    problems = 0
    for j in range(D):
        if i & 2**(D-j-1):
            problems += p[j]
            rest -= p[j] * (j+1) * 100 + c[j]
    for j in reversed(range(D)):
        if rest <= 0:
            break
        if i & 2**(D-j-1):
            continue
        add_problems = min(p[j] - 1, math.ceil(rest//((j+1)*100)))
        problems += add_problems
        rest  -= add_problems * (j+1) * 100
    if rest <= 0:
        ans = min(ans, problems)
print(ans)

Measured memory_bytes: 3064