akhauriyash/Code-Regression huggingface dataset:
#include <cstdio>
#include <iostream>
#include <iomanip>
#include <string>
#include <queue>
#include <stack>
#include <vector>
#include <set>
#include <map>
#include <unordered_map>
#include <algorithm>
#include <utility>
#include <cmath>

#define ll long long int
#define pb push_back
#define mk make_pair
#define pq priority_queue

using namespace std;
typedef pair<int, int> P;
typedef pair<ll, int> Pl;
typedef pair<ll, ll> Pll;
const int inf = 1e9;
const ll linf = 1LL << 50;

template <typename T>
struct Graph_ {
  int n;
  vector<vector<pair<int, T> > > edge;
  vector<T> dis;
  Graph_(int ns) {
    n = ns;
    edge.resize(n);
    dis.resize(n);
  }
  void dijkstra(int s){
    dijkstra(s, 0);
  }
  T dijkstra(int s, int t){
    // initialize
    fill(dis.begin(), dis.end(), -1);
    vector<bool> used;
    used.resize(n);
    fill(used.begin(), used.end(), false);
    dis[s] = 0;
    // dijkstra
    priority_queue<pair<T, int>, vector<pair<T, int> >, greater<pair<T, int> > > q;
    q.push(make_pair(0, s));
    while(!q.empty()){
      pair<T, int> p = q.top(); q.pop();
      int at = p.second;
      T distance = p.first;
      if(used[at])continue;
      used[at] = true;
      for(auto itr = edge[at].begin(); itr != edge[at].end(); ++itr){
        int to = (*itr).first;
        T cost = (*itr).second;
        if(used[to])continue;
        if(dis[to] == -1 || dis[to] > distance + cost){
          q.push(make_pair(distance + cost, to));
          dis[to] = distance + cost;
        }
      }
    }
    return dis[t];
  }
  void adde(int at, int to, T cost){
    edge[at].push_back(make_pair(to, cost));
  }
  [[deprecated("This function takes O(edge[at].size()).")]]
  void remove(int at, int to){
    int index = -1;
    for(int i = 0; i < edge[at].size(); i++){
      if(edge[at][i].first == to){
        index = i;
        break;
      }
    }
    edge[at].erase(edge[at].begin() + index);
  }
};

typedef struct Graph_<int> GraphI;
typedef struct Graph_<ll> GraphL;

int main(int argc, char const* argv[])
{
  int n, m;
  cin >> n >> m;
  GraphI graph(n);
  vector<P> vec;
  for(int i = 0; i < m; i++){
    int a, b;
    cin >> a >> b;
    a--; b--;
    graph.adde(a, b, 1);
    graph.adde(b, a, 1);
    vec.pb(mk(a, b));
  }
  int res = 0;
  for(int i = 0; i < m; i++){
    int a = vec[i].first;
    int b = vec[i].second;
    graph.remove(a, b);
    graph.remove(b, a);
    if(graph.dijkstra(a, b) == -1)res++;
    graph.adde(a, b, 1);
    graph.adde(b, a, 1);
  }
  cout << res << endl;
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0; i<n; i++)
#define int long long
#define P pair<long long,long long>
#define all(a) a.begin(),a.end()
using namespace std;
signed main(){
    int n; string s,t;
    cin>>n>>s>>t;
    int ans=n*2;
    rep(i,n){
        if(s.substr(n-i-1,i+1)==t.substr(0,i+1)) ans=n*2-i-1;
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 256
#include <cstdio>
#include <functional>
#include <algorithm>
#define maxn 100005

using namespace std;

struct node{
	int cnt, link;
}_1[maxn], _2[maxn];
bool cmp(const node &a, const node &b){return a.cnt > b.cnt;}

int n;

int main(){
	scanf("%d", &n);
	
	for (int x, i = 1; i <= n; i++){
		scanf("%d", &x);
		if (i & 1) _1[x].cnt++, _1[x].link = x;
		else _2[x].cnt++, _2[x].link = x;
	}
	
	sort(_1 + 1, _1 + 100000 + 1, cmp);
	sort(_2 + 1, _2 + 100000 + 1, cmp);
	if (_1[1].link != _2[1].link) printf("%d\n", n - _1[1].cnt - _2[1].cnt); 
	else printf("%d\n", n - max(_1[1].cnt + _2[2].cnt, _1[2].cnt + _2[1].cnt));
	
	return 0;
}

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

int main(void) {
	int n;
  	int t[110];	
 	cin >> n;
  		for (int i=0; i<n; ++i) {
          cin >> t[i+1];
        }
  	int m;
  	int x[110];
  	int y[110];
  	cin >> m;
  		for (int j=0; j<m; ++j) {
			cin >> x[j+1];
          	cin >> y[j+1];
        }
  
  	int ans;
  
  	for (int i=0; i<m; ++i) {
      for (int j=0; j<n; ++j ) {
        ans += t[j+1];
      }
      ans += y[i+1];
      ans -= t[x[i+1]];
      cout << ans << endl;
      ans = 0;
    }
}

Measured memory_bytes: 256
N, K = [int(x) for x in input().split()]
X = [int(x) for x in input().split()]

def main():
    k = K
    l = len(X) 

    i = 0

    ans = float('inf')
    end = l - k
    while i <= end:
        first = X[i]
        last = X[i + k - 1]
        node_abs = [abs(first), abs(last)]
        if first * last >= 0:
            curr = max(node_abs)
        else:
            curr = max(node_abs) + (min(node_abs) * 2)
        ans = min(ans, curr)
        i += 1
    print(ans)

if __name__ == '__main__':
    main()


Measured memory_bytes: 14660
#include <iostream>
#include <cstdlib>
#include <cstdio>
#include <algorithm>
#include <cstring>
#include <vector>
#include <cmath>
#include <bitset>
#include <queue>

using namespace std;

void solve() {
    string s;
    cin >> s;
    for(int i = 0; i < s.size(); i++) {
        cout << "x";
    }
}

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

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

/*
提出前に確認!
- setとmultisetを間違えない
*/

int	main(void)
{
	int n;
	cin >> n;
	vector<char> c(n);
	for (int i = 0; i < n; i++) cin >> c[i];
	int red_cnt = 0;
	int ans = 0;
	for (int i = 0; i < n; i++) red_cnt += (c[i] == 'R');
	for (int i = 0; i < red_cnt; i++) ans += (c[i] != 'R');
	cout << ans << endl;
	return (0);
}


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

int descending_compare(const void *a, const void *b){
    if (*(int*)a > *(int*)b){
        return -1;
    }else if (*(int*)a == *(int*)b){
        return 0;
    }else{
        return 1;
    }
}

int ascending_compare(const void *a, const void *b){
    if (*(int*)a < *(int*)b){
        return -1;
    }else if (*(int*)a == *(int*)b){
        return 0;
    }else{
        return 1;
    }
}


int lower_bound(int *a, int n, int key){
    int left, mid, right;
    left = 0, right = n;
    mid = (left + right)/2;
    while ((left+1 != mid || mid+1 != right) && mid != left){
        if (key > a[mid]){
            left = mid;
        }else{
            right = mid+1;
        }
        mid = (left + right)/2;
    }
    if (a[left] >= key)return left;
    if (a[mid] >= key)return mid;
    if (a[right] >= key)return right;
    return n;
}

unsigned long  gcd(unsigned long x, unsigned long y)
{
        if (y == 0) {
                return x;
        } else {
                return gcd(y, x % y);
        }
}



long long calc(int x){
    long long rtn = 1;
    int i;
    for (i = x; i > 1; i--){
        rtn = (rtn*i);
    }
    return rtn;
}


int main(void){
    int n;
    int a;
    int i, j;
    int cnt = 0;
    int min = 0, max = 0;
    int color[9] = {0};
    int border[9] = {400, 800, 1200, 1600, 2000, 2400, 2800, 3200, 4801};

    scanf("%d", &n);
    for (i = 0; i < n; i++){
        scanf("%d", &a);
        for (j = 0; j < 9; j++){
            if (a < border[j]){
                color[j]++;
                break;
            }
        }
    }
    
    for (i = 0; i < 8; i++){
        if (color[i] > 0){
            min++;
        }
    }

    if (min == 0 && color[8] > 0){
        min = 1;
        max = color[8];
        printf("%d %d\n", min, max);
        return 0;
    }

    max = min + color[8];

    printf("%d %d\n", min, max);







    return 0;
}


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

int main() {
    int a;

    int city[4] = {};

    for (int i = 0; i < 3; i++) {
        cin >> a;
        city[a - 1]++;

        cin >> a;
        city[a - 1]++;
    }

    for (int i = 0; i < 4; i++) {
        if (city[i] > 2) {
            cout << "NO" << endl;
            return 0;
        }
    }

    cout << "YES" << endl;

    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<map>
#include<math.h>
#include<iomanip>
#include<set>
#include<limits.h>
#include<cmath>
#include<queue>
#include<stack>

#include<stdio.h>
#include<stdlib.h>

#define rep(i,n) for(ll i = 0; i < (ll)n; i++)
#define swap(a,b) a^=b;b^=a;a^=b;
#define chmax(a,b) {if(a < b) a = b;}
#define chmin(a,b) {if(a > b) a = b;}

using namespace std;
typedef long long ll;
const ll INF = 1LL << 60;

int main(void) {
	cin.tie(0);
	ios::sync_with_stdio(false);
	//Program Start	

	int K;
	string S;

	cin >> K >> S;

	if (K >= S.size()) {
		cout << S << endl;
	}
	else {
		auto it = S.begin();
		for (int i = 0; i < K; i++) {
			printf("%c", *it);
			it++;
		}
		printf("...");
	}

EndPoint:;

	//Program End
#ifndef DEBUG
	system("pause");
#endif // !DEBUG

	return 0;
}




Measured memory_bytes: 3232
#include <stdio.h>

int main(){

  int A[1000],N,i,j,k,v;
  scanf("%d",&N);

  for(i=0;i<N;i++){
    scanf("%d",&A[i]);
  }
  for(i=0;i<N;i++){
    printf("%d",A[i]);
    if(i == N-1) break;
    printf(" ");
  }

  printf("\n");
  
  for(i=1;i<N;i++){

    v = A[i];
    j = i - 1;

    while(j >= 0 && A[j] > v){

      A[j+1] = A[j];
      j--;
      A[j+1] = v;
    }
    
    for(k=0;k<N;k++){
      printf("%d",A[k]);
      if(k == N-1) break;
      printf(" ");
    }
    printf("\n");
    
  }

  return 0;
}
    
  



Measured memory_bytes: 2044
# -*- coding: utf-8 -*-
"""
Created on Sat Mar 28 21:18:11 2020

@author: liang
"""

K, N = map(int,input().split())
A = list(map(int,input().split()))

max_distance = 0
for i in range(N-1):
    temp = A[i+1] -A[i]
    if temp > max_distance:
        max_distance = temp

temp = A[0] + K - A[N-1]
if temp > max_distance:
    max_distance = temp

result = K - max_distance

print(result)

Measured memory_bytes: 26564
#include <iostream>
#include "stdio.h"
#include <stack>
#include <string>
#include <vector>
#include <algorithm>

using namespace std;

int main() {
	stack<int> leftDash;
	stack< pair<int, int> > dashArea;
	char inputDash;
	int sum = 0;

	for (int i = 0; inputDash = getchar() ; i++) {
		if (inputDash == '\n') break;
		if (inputDash == '\\') {
			leftDash.push(i);
		}
		else if (inputDash == '/' && leftDash.size() > 0) {
			int j = leftDash.top();
			leftDash.pop();
			sum += i - j;
			int a = i - j;

			while (dashArea.size() > 0 && dashArea.top().first > j) {
				a += dashArea.top().second;
				dashArea.pop();
			}

			dashArea.push(make_pair(j, a));
		}
	}

	vector<int> ans;
	while (dashArea.size() > 0) {
		ans.push_back(dashArea.top().second);
		dashArea.pop();

	}
	reverse(ans.begin(), ans.end());
	cout << sum << endl;
	cout << ans.size();

	for (int i = 0; i < ans.size(); i++) {
		cout << " ";
		cout << ans[i];
	}

	cout << endl;

	return 0;
}


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

int main() {
    int a,b,k;
    cin >> a >> b >> k;
    vector<int> x;
    if(b-a+1<=2*k){
        for(int i = a; i <= b; i++){
            x.push_back(i);
        }
        for(int i = 0; i < b - a + 1; i++){
            cout << x[i] << endl;;
        }
    }
    else {
    for(int i = 0; i < k; i++){
        x.push_back(a+i);
    }
    for(int i = 0; i < k; i++){
        x.push_back(b-i);
    }
        sort(x.begin(), x.end());
    for(int i = 0; i < 2 * k; i++){
        cout << x[i] << endl;;
    }
}

}


Measured memory_bytes: 256
# -*- coding: utf-8 -*-

import sys

def input(): return sys.stdin.readline().strip()
def list2d(a, b, c): return [[c] * b for i in range(a)]
def list3d(a, b, c, d): return [[[d] * c for j in range(b)] for i in range(a)]
def list4d(a, b, c, d, e): return [[[[e] * d for j in range(c)] for j in range(b)] for i in range(a)]
def ceil(x, y=1): return int(-(-x // y))
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(N=None): return list(MAP()) if N is None else [INT() for i in range(N)]
def Yes(): print('Yes')
def No(): print('No')
def YES(): print('YES')
def NO(): print('NO')
sys.setrecursionlimit(10 ** 9)
INF = 10 ** 18
MOD = 10 ** 9 + 7

N, K = MAP()
R, S, P = MAP()
T = list(input())

# mod KでK個のグループに分ける
T2 = [[] for i in range(K)]
for i, t in enumerate(T):
    T2[i%K].append(t)

ans = 0
for k in range(K):
    M = len(T2[k])
    # dp[i][j] := i回目まで見て、前回出した手がr,s,p(j=0,1,2)だった時の最大スコア
    dp = list2d(M+1, 3, 0)
    for i, t in enumerate(T2[k]):
        # 前回出した手j
        for j in range(3):
            # 今回出す手l
            for l in range(3):
                # 初回以外で、前回と同じ手なら遷移不可
                if i != 0 and j == l:
                    continue
                nxt = 0
                # 相手がrならp(2)の時に得点
                if t == 'r' and l == 2:
                    nxt = P
                # 相手がsならr(0)の時に得点
                elif t == 's' and l == 0:
                    nxt = R
                # 相手がpならs(1)の時に得点
                elif t == 'p' and l == 1:
                    nxt = S
                dp[i+1][l] = max(dp[i+1][l], dp[i][j] + nxt)
    # このグループでのスコアを合計に追加
    ans += max(dp[M])
print(ans)


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

const int N = 1005;
int Prime[N], cnt[N];

void sieve()
{
    memset(Prime, 1, sizeof Prime);
    Prime[1] = 0;
    for(int i = 2; i*i <= N; ++i)
        if(Prime[i])
        {
            for(int j = 2; i*j<=N;++j)
                Prime[i*j] = 0;
        }
}




int main()
{
//    cout << INT_MAX - (int)1e9+7;
    sieve();
    int n; cin >> n;
    for(int i = 1; i <= n; ++i)
    {
        ++cnt[i];
        if(Prime[i]){
            for(int j = i; j <= n; j*=i)
                cnt[i]+=n/j;
        }
    }
    long long ans = 1;
    long long P = 1e9+7;
    for(int i = 1; i <= n; ++i){
        ans *= (long long )cnt[i];
        ans = ans%((long long)(1e9+7));
//        if(ans >= P)
//            ans -= P;
    }
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define INF 2e9
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;
typedef vector<ll> vll;
typedef vector<vll> vvll;


int main()
{
    string date;
    cin >> date;
    date.replace(date.begin(), date.begin()+4, "2018");
    cout << date << endl;
    return 0;
}

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

using namespace std;

int main()
{
    int N, W;
    cin >> N >> W;
    long long w[N], v[N];
    for (int i = 0; i < N; i++)
    {
        cin >> w[i] >> v[i];
    }
    long long dp[N + 1][3 * W];
    for (int i = 0; i < N + 1; i++)
    {
        for (int j = 0; j < 3 * W; j++)
        {
            dp[i][j] = 0;
        }
    }
    for (int i = 1; i < N + 1; i++)
    {
        for (int j = 0; j <= W; j++)
        {
            if (j - w[i - 1] >= 0)
            {
                dp[i][j] = max({dp[i - 1][j - w[i - 1]] + v[i - 1], dp[i][j]});
            }
            dp[i][j] = max(dp[i - 1][j], dp[i][j]);
        }
    }
    long long ans = 0;
    for (int i = 0; i < W + 1; i++)
    {
        ans = max(ans, dp[N][i]);
    }
    cout << ans << endl;
}


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

#define FLASH ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define ll long long int
#define MAX 1e9
#define MIN -1e9
#define mod 1000000007
#define pb push_back
#define all(x) (x).begin(), (x).end()
#define debug(x) cerr<<#x<<'='<<(x)<<endl;
#define mxn 100005
using namespace std;

int main()
{
    FLASH
    ll n,k;
    cin >> n >> k;
    ll a[n];
    for(int i = 0; i < n; i++)
        cin >> a[i];
    sort(a,a+n);
    ll sum = 0;
    for(int i = 0; i < k; i++)
        sum += a[i];
    cout << sum;
    return 0;
}



Measured memory_bytes: 3680
#include <iostream>
#include <set>
#include <vector>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
void recurse(vector<int> cur , set< vector<int> > &to){
	if(to.find(cur) != to.end()) return;
	else to.insert(cur);
	rep(i,cur.size()){
		for(int k=1;k<=cur[i]/2;k++){
			vector<int> tmp = cur;
			tmp[i] = cur[i] - k;
			tmp.push_back(k);
			bool f = true;
			rep(j,tmp.size()-1) f &= tmp[j] >= tmp[j+1];
			if(f)recurse(tmp,to);
		}
	}
}

int main(){
	int n;
	while(cin >> n , n){
		set<vector<int> > ans;
		vector<int> start(1,n);
		recurse(start,ans);
		for(set<vector<int> >::reverse_iterator it = ans.rbegin(); it != ans.rend();++it){
			rep(i,(*it).size())
				cout << (*it)[i] << (i==(*it).size()-1?"\n":" ");
		}
	}
}

Measured memory_bytes: 1256
#include <iostream>
using namespace std;
int main(){
	int n; cin>>n;
	int r[] = {1,1,2};
	if( n<=2 ){
		cout<<r[n]<<endl;
		return 0;
	}
	while( n>0 ){
		int tmp = r[1] + r[2];
		r[0] = r[1]; r[1] = r[2]; r[2] = tmp;
		n = n-1;
	}
	cout<<r[0]<<endl;
	return 0;
}

Measured memory_bytes: 1164
#include <iostream>
#include <cstdio>
#include <vector>
#include <queue>
#include <string>
#include <cmath>
#include <algorithm>

using namespace std;

#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define BIT(X, i) ((X>>i)&1)
#define REP(i, a, b) for(int i = (a); i < (b); ++i)
#define rep(i, n) for(int i = 0; i < (n); ++i)
#define all(a) (a).begin(), (a).end()
#define r_all(a) (a).rbegin(), (a).rend()

typedef long long ll;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef vector<vvd> vvvd;
typedef pair<ll, ll> pii;
typedef vector<pii> vii;
typedef priority_queue<ll> pq;

const int MOD = 1e9+7;
const int INF = (1<<30);
const ll INFL = (1L<<62);

int main() {
  int n; cin >> n;
  vd a(n), c(4, 0);
  vvvd dp(n+1, vvd(n+1, vd(n+1, 0)));
  rep(i,n) {
    cin >> a[i];
    c[a[i]]++;
  }
  for (int i = 0; i <= n; i++) {
    for (int j = 0; i+j <= n; j++) {
      for (int k = 0; i+j+k <= n; k++) {
        double t1 = 0, t2 = 0, t3 = 0;
        int m = i + j + k; if (m == 0) continue;
        if (i) t1 = dp[i-1][j+1][k] * i / n;
        if (j) t2 = dp[i][j-1][k+1] * j / n;
        if (k) t3 = dp[i][j][k-1]   * k / n;
        dp[i][j][k] = (t1+t2+t3 + 1) * n / m;
      }
    }
  }
  printf("%.10f\n", dp[c[3]][c[2]][c[1]]);
  return 0;
}


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

using namespace std;
typedef long long ll;

#define REP(i, n) for (ll i = 0; i < (n); i++)
#define REPR(i, n) for (ll i = (n); i >= 0; i--)
#define FOR(i, m, n) for (ll i = (m); i < (n); i++)
#define FORR(i, m, n) for (ll i = (m); i >= (n); i--)
#define INF 1e9
#define pb push_back
#define ALL(x) (x).begin(), (x).end()
#define SZ(x) ((ll)(x).size())
#define SORT(x) sort((x).begin(), (x).end())
#define dump(x) cerr << #x << " = " << (x) << endl
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" \
                      << " " << __FILE__ << endl

int main(int argc, char const *argv[])
{
    int c[4] = {0};
    REP(i, 3)
    {
        ll a, b;
        cin >> a >> b;
        c[a - 1]++;
        c[b - 1]++;
    }
    REP(i, 4)
    {
        if (c[i] > 2)
        {
            puts("NO");
            return 0;
        }
    }
    puts("YES");
    return 0;
}


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

def main():
  n, m = map(int, input().split())
  tree = [[] for _ in range(n)]
  for i in range(m):
    l, r, d = map(int, input().split())
    tree[l-1].append((r-1, d))
    tree[r-1].append((l-1, -d))
  
  ans = [0]*n
  not_yet = deque([])
  already = [False]*n
  judge = True
  
  for i in range(n):
    if already[i]:
      continue
    already[i] = True
    for v in tree[i]:
      index, dist = v[0], v[1]
      ans[index] = dist
      already[index] = True
      not_yet.append(index)
    while not_yet:
      index = not_yet.popleft()
      for v in tree[index]:
        index2, dist = v[0], v[1]
        if already[index2]:
          if ans[index] + dist != ans[index2]:
            judge = False
        else:
          already[index2] = True
          ans[index2] = ans[index] + dist
          not_yet.append(index2)
          
  print("Yes" if judge else "No")
  
if __name__ == "__main__":
  main()

Measured memory_bytes: 71112
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define EPS (1e-7)
#define INF (1e9)
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) x.begin(),x.end()
const double PI = acos(-1);
const ll MOD = 1000000007;
// const ll MOD = 998244353;
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;
}
///////////////////////////////////////////////////////////////

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

public:
  u64 a;

  constexpr modint(const u64 x = 0) noexcept : a(x % Modulus) {}
  constexpr u64 &value() noexcept { return a; }
  constexpr const u64 &value() const noexcept { return a; }
  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 {
    a += rhs.a;
    if (a >= Modulus) {
      a -= Modulus;
    }
    return *this;
  }
  constexpr modint &operator-=(const modint rhs) noexcept {
    if (a < rhs.a) {
      a += Modulus;
    }
    a -= rhs.a;
    return *this;
  }
  constexpr modint &operator*=(const modint rhs) noexcept {
    a = a * rhs.a % Modulus;
    return *this;
  }
  constexpr modint &operator/=(modint rhs) noexcept {
    u64 exp = Modulus - 2;
    while (exp) {
      if (exp % 2) {
        *this *= rhs;
      }
      rhs *= rhs;
      exp /= 2;
    }
    return *this;
  }
};

using mint = modint<MOD>;

int main() {
    ios::sync_with_stdio(false); cin.tie(nullptr);
    int N; cin >> N;
    vector<int> A(N+1);
    rep(i,N+1) cin >> A[i];

    map<int, int> dic;
    int p,q;
    rep(i,N+1) {
        if (dic.count(A[i])) {
            p = dic[A[i]];
            q = i;
        } else dic.emplace(A[i],i);
    }
    int x = p;
    int y = q-p-1;
    int z = N-q;
    
    vector<mint> modfac(N+10,1);
    rep(i,N+5) modfac[i+1] = modfac[i]*(i+1);
    vector<mint> ans(N+2,1);
    for (int i = 1; i <= N; i++) {
        ans[i] = modfac[N]/(modfac[N-i]*modfac[i]);
        if (i >= 2)ans[i] += modfac[N-1]/(modfac[N-i+1]*modfac[i-2]);
        ans[i] += (modfac[N-1]/(modfac[N-i]*modfac[i-1]));
        if (x+z>=i-1) ans[i] -= (modfac[x+z]/(modfac[x+z-i+1]*modfac[i-1]));
    }

    rep(i,N+1) cout << ans[i+1].a << endl;
}

Measured memory_bytes: 7936
/* template.cpp [[[ */
#include <bits/stdc++.h>
using namespace std;
#define get_macro(a, b, c, d, name, ...) name
#define rep(...) get_macro(__VA_ARGS__, rep4, rep3, rep2, rep1)(__VA_ARGS__)
#define rrep(...) get_macro(__VA_ARGS__, rrep4, rrep3, rrep2, rrep1)(__VA_ARGS__)
#define rep1(n) rep2(i_, n)
#define rep2(i, n) rep3(i, 0, n)
#define rep3(i, a, b) rep4(i, a, b, 1)
#define rep4(i, a, b, s) for (ll i = (a); i < (ll)(b); i += (ll)s)
#define rrep1(n) rrep2(i_, n)
#define rrep2(i, n) rrep3(i, 0, n)
#define rrep3(i, a, b) rrep4(i, a, b, 1)
#define rrep4(i, a, b, s) for (ll i = (ll)(b) - 1; i >= (ll)(a); i -= (ll)s)
#define each(x, c) for (auto &&x : c)
#define fs first
#define sc second
#define all(c) begin(c), end(c)
using ui = unsigned;
using ll = long long;
using ul = unsigned long long;
using ld = long double;
const int inf = 1e9 + 10;
const ll inf_ll = 1e18 + 10;
const ll mod = 1e9 + 7;
const ll mod9 = 1e9 + 9;
const int dx[]{-1, 0, 1, 0, -1, 1, 1, -1};
const int dy[]{0, -1, 0, 1, -1, -1, 1, 1};
template<class T, class U> void chmin(T &x, const U &y){ x = min<T>(x, y); }
template<class T, class U> void chmax(T &x, const U &y){ x = max<T>(x, y); }
struct prepare_ { prepare_(){ cin.tie(nullptr); ios::sync_with_stdio(false); cout << fixed << setprecision(12); } } prepare__;
/* ]]] */

int h, w;
vector<string> a, b, c;

int main(){
  cin >> h >> w;
  a.resize(h);
  rep(i, h) cin >> a[i];
  b = c = a;
  rep(i, h) b[i][0] = c[i][w - 1] = '#';
  rep(i, h) rep(j, 1, w - 1) (i & 1 ? b : c)[i][j] = '#';
  rep(i, h) cout << b[i] << endl;
  cout << endl;
  rep(i, h) cout << c[i] << endl;
}


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

int main(){
	int sigma[200] = {0},cor = 0,x,dx;
	while(cin >> dx){
		for(x = 0;x < 600;x+=dx){
			sigma[cor] += dx*x*x;
		}
		cor++;
	}
	for(int i= 0;i < cor;i++){
		cout << sigma[i] << endl;
	}
	return 0;
}

Measured memory_bytes: 1160
#include <bits/stdc++.h>
#define y1 yy1
#define Maxn 200007
using namespace std;
int read()
{
	int x=0,f=1;char ch=getchar();
	while (ch<'0'||ch>'9'){if (ch=='-') f=-1;ch=getchar();}
	while (ch>='0'&&ch<='9'){x=x*10+ch-'0';ch=getchar();}
	return x*f;
}
int R,C,n,cnt=0;
int x1[Maxn],y1[Maxn],x2[Maxn],y2[Maxn];
pair<int,int> pos[Maxn*2+10];
int que[Maxn];
bool vis[Maxn];
bool check(int x,int y)
{
	if (x==0) return true;
	if (x==R) return true;
	if (y==0) return true;
	if (y==C) return true;
	return false;
}
int deal(int x,int y)
{
	if (y==0) return x;
	if (x==R) return R+y;
	if (y==C) return R+C+R-x;
	if (x==0) return R+R+C+C-y;
	return 0;
}
int main()
{
	R=read(),C=read(),n=read();
	for (int i=1;i<=n;i++)
		x1[i]=read(),y1[i]=read(),x2[i]=read(),y2[i]=read();
	for (int i=1;i<=n;i++)
		if (check(x1[i],y1[i])&&check(x2[i],y2[i]))
		{
			pos[++cnt].second=i;
			pos[cnt].first=deal(x1[i],y1[i]);
			pos[++cnt].second=i;
			pos[cnt].first=deal(x2[i],y2[i]);
		}
	sort(pos+1,pos+cnt+1);
	for (int i=cnt+1;i<=cnt*2;i++)
		pos[i]=pos[i-cnt];
	memset(que,0,sizeof(que));
	memset(vis,false,sizeof(vis));
	int sz=0;
	bool checkk=true;
	for (int i=1;i<=cnt*2;i++)
		if (!vis[pos[i].second])
		{
			que[++sz]=pos[i].second;
			vis[pos[i].second]=true;
		} else 
		{
			if (que[sz]!=pos[i].second) checkk=false;
			vis[pos[i].second]=false;
			--sz;
		}
	if (checkk) cout << "YES" << endl;
	else cout << "NO" << endl;
	return 0;
}


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

using namespace std;
#define int long long
signed main() {
    int a, b, c;
    cin >> a >> b >> c;
    int k;
    cin >> k;
    while(b <= a && k > 0)
        b = 2*b, k--;
    while(c <= b && k > 0)
        c = 2*c, k--;
    if(a < b && b < c)
        cout << "Yes\n";
    else
        cout << "No\n";
}

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

#define ll     long long
#define fr     first
#define sec    second
#define rep(i,n)  for(i=0;i<n;i++)
#define vi     vector <int>
#define vc     vector <char>
#define vl     vector <ll>
#define vb     vector <bool>
#define pb     push_back
#define M      1000000007
#define ios    ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define open   freopen("input.txt","r",stdin);
#define close  freopen("output.txt","w",stdout);
#define M_PI   3.14159265358979323846
#define pp     pair<int,int>
#define nn 100003
#define MM 1000000000
#define MN 1000000000000000000
int main()
{
    ios;
    string s;
    ll i,l,k;
    cin>>k>>s;
    l=s.length();
    if(l<=k)
        cout<<s;
    else
    {
        s=s.substr(0,k);
        s+="...";
        cout<<s;
    }
    return 0;
}


Measured memory_bytes: 3612
#include <cstdio>
 
#define MAX(a, b) ((a) > (b) ? (a) : (b))
 
int main(void) {
    int N;
    scanf("%d", &N);
    int s[N];
    for (int i = 0; i < N; ++i) {
        scanf("%d", &s[i]);
    }
 
    long long ans = 0;
    for (int c = 1; c < N; ++c) {
        long long f = 0;
        for (int l = 0, r = N - 1; l + c < N - 1; l += c, r -= c) {
            if ((N - 1) % c == 0 && l >= r) { break; }
            f += s[l] + s[r];
            ans = MAX(ans, f);
        }
    }
 
    printf("%lld\n", ans);
 
    return 0;
}

Measured memory_bytes: 640
// Best practice
 
#include<bits/stdc++.h>
 
#define int         long long
#define pb          push_back
#define pf          emplace_front
#define all(a)      (a).begin(),(a).end()
#define rall(a)     (a).rbegin(),(a).rend()
#define pii 		pair<int,int>
#define psi 		pair<string,int>
#define vi 			vector<int>
#define vpii  		vector<pii>
#define vvi 		vector<vi>
#define sz(x)	    (int)(x).size()
#define x           first
#define y           second
#define endl        '\n'
#define tezz        ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define MOD         1000000007
#define hell        998244353
#define prec(n) 	fixed<<setprecision(n)
#define ini(a, i) 	memset(a, i, sizeof(a))
#define output(x)   cout << (x ? "YES" : "NO")<<endl;
using namespace std;
 
#define debug(vec) cout<<(#vec)<<" : [ "; for (auto& i: vec) cout<<i<<" "; cout<< "]" << endl
#define debugp(vec) cout<<(#vec)<<" : [ "; for (auto& i: vec) cout<<"("<<i.x<<","<<i.y<<")"<<" "; cout<< "]" << endl
#define trace(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args);cout << endl; }
void err(istream_iterator<string> it) {}
template<typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args) {
    cout << "[" << *it << ": " << a << "]\t";
    err(++it, args...);
}
 
// const int dx[4] = { -1, 1, 0, 0};
// const int dy[4] = {0, 0, -1, 1};
// int dX[] = { -1, -1, -1, 0, 0, 1, 1, 1 };
// int dY[] = { -1, 0, 1, -1, 1, -1, 0, 1 };
 
 
// Code from Here -------------------------------------------------------------------------------

signed main() {
	tezz
 
	// #ifndef ONLINE_JUDGE
	// 	freopen("input.txt", "r", stdin);
	// 	freopen("output.txt", "w", stdout);
	// #endif

	int n,m;
	cin >> n;
	int a[n];
	int sum=0;
	for(int i=0; i<n; i++){
		cin >> a[i];
		sum+=a[i];
	}
	int dp[n+1][n+1];
	for(int i=n-1; i>=0; i--){
		for(int j=i; j<n; j++){
			if(i==j){
				dp[i][j]=a[i];
			}
			else{
				dp[i][j] = max(-dp[i+1][j]+a[i], -dp[i][j-1]+a[j]);
			}
		}
	}
	// trace(dp[0][n-1]);
	cout << dp[0][n-1] << endl;
 
	return 0;
}  

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

int main()
{
  int N; cin >> N;
  string S; cin >> S;
  
  for (int i = 0; i < S.length(); i++)
  {
    char c = S[i];
    int k = (c - 'A' + N) % 26;
    char cc = 'A' + k;
    cout << cc;
  }
  
  cout << endl;
  return 0;
}

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

void solve() {
  int x, n;
  cin >> x >> n;
  set<int> s;
  rep(i, n) {
    int x;
    cin >> x;
    s.insert(x);
  }
  for (int i = 0; i <= 100; ++i) {
    if (!s.count(x-i)) {
      cout << x-i << endl;
      return;
    }
    if (!s.count(x+i)) {
      cout << x+i << endl;
      return;
    }
  }
}
void solve(bool tests) {
  int t;
  cin >> t;
  while (t--) solve();
}

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0), cout.tie(0);
  solve();
}

Measured memory_bytes: 3660
/*
 * @Author: RBQRBQ
 * @Date: 2020-04-09 20:03:19
 * @LastEditors: RBQRBQ
 * @LastEditTime: 2020-04-09 20:51:12
 */
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<int> VI;
typedef pair<int,int> pii;
#define all(x) x.begin(),x.end()
namespace IO{
    template<typename T>inline void read(T &x){
        x=0;ll f=1;char ch=getchar();
        while(!isdigit(ch)){if(ch=='-')f=-f;ch=getchar();}
        while(isdigit(ch)){x=x*10+ch-48;ch=getchar();}
        x=x*f;
    }
}
using namespace IO;
int N;
const int maxn=205;
int mp[maxn][maxn];
char pp[maxn][maxn];
ll dis[maxn][maxn];
int color[maxn];
bool dfs(int u,int c)
{
    color[u]=c;
    for(int j=0;j<N;j++)
    if(mp[u][j]==1)
    {
        if(color[j]==c) return false;
        else if(!color[j]&&!dfs(j,c==1?2:1)) return false;
    }
    return true;
}
int main()
{
    read(N);
    for(int i=0;i<N;i++)
    scanf("%s",pp[i]);
    for(int i=0;i<N;i++)
    for(int j=0;j<N;j++)
    {
        char c;
        c=pp[i][j];
        if(c=='1')
        mp[i][j]=1;
        else mp[i][j]=0;
    }
    if(!dfs(0,1))
    {
        cout<<"-1";
        return 0;
    }
    for(int i=0;i<N;i++)
    for(int j=0;j<N;j++)
    {
        if(i==j) dis[i][j]=0;
        else
        {
            dis[i][j]=(mp[i][j]==0)?2000000:1;
        }
    }
    for(int k=0;k<N;k++)
    for(int i=0;i<N;i++)
    for(int j=0;j<N;j++)
    dis[i][j]=min(dis[i][k]+dis[k][j],dis[i][j]);
    ll ans=0;
    for(int i=0;i<N;i++)
    for(int j=0;j<N;j++)
    {
    if(dis[i][j]!=2000000){
    {
        ans=max(ans,dis[i][j]);
    }}}
    cout<<ans+1;
    
}

Measured memory_bytes: 768
#include<bits/stdc++.h>
using namespace std;
int L;
struct Front_star{int u,v,w;}e[90];
int tot=0;
void add(int u,int v,int w){tot++;e[tot].u=u;e[tot].v=v;e[tot].w=w;}
int main(){
	cin>>L;
	int cnt=0,tmp=L;
	while(tmp)cnt++,tmp/=2;
	for(int i=1;i<cnt;i++)add(i,i+1,0),add(i,i+1,(1<<(i-1)));
	cnt--;
	int ret=L-(1<<cnt);
	int Use=(1<<cnt);
	for(int i=0;i<20;i++){
		if((1<<i)&ret)add(i+1,cnt+1,Use),Use+=(1<<i);
	}
	cout<<cnt+1<<" "<<tot<<'\n';
	for(int i=1;i<=tot;++i){
		cout<<e[i].u<<" "<<e[i].v<<" "<<e[i].w<<'\n';
	}
} 

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

#define mp make_pair
#define all(x) (x).begin(), (x).end()
#define pb push_back
#define siz(x) (x).size()
using namespace std;
using ll = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;

int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }
int lcm(int a, int b) { return a / gcd(a, b) * b; }
int mpow(int a, int b) {
	if (b & 1)return a * mpow(a, b - 1);
	return mpow(a * a, b >> 1);
}
int mpow(int a, int b, int m) {
	if (b & 1)return a * mpow(a, b - 1, m) % m;
	return mpow(a * a % m, b >> 1, m) % m;
}

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	ll n, k; cin >> n >> k;
	ll s = 0;
	ll mini = 0, maxi = 0;
	const ll mod = 1e9 + 7;
	for (int i = 1; i < k; i++) {
		mini += i - 1;
		maxi += n - i + 1;
	}
	for (int i = k; i <= n + 1; i++) {
		mini += i - 1;
		maxi += n - i + 1;
		s = (s + maxi - mini + 1) % mod;
		
	}
	cout << s;
	return 0;
}

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

#define REP( i, n )     for( int (i) = 0; (i) < (n); (i)++ )
#define ALL( a )        (a).begin(), (a).end()

using namespace std;
using ll = long long;
using P = pair<int, int>;

template<class T>bool chmax( T& a, const T& b ) { if( a < b ) { a = b; return 1; } return 0; }
template<class T>bool chmin( T& a, const T& b ) { if( a > b ) { a = b; return 1; } return 0; }

const int INF = 1e9;
const ll LINF = 1e18;
const int MOD = 1e9 + 7;

int main(){
    string s; cin >> s;
    int ans = 0;
    for( int i = 0; i < s.size() / 2; i++ ){
        if( s[i] != s[s.size() - i - 1] ) ans++;
    }

    cout << ans << endl;
}

/*

*/

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define vi vector<ll>
#define vvi vector<vi>
#define mod 1000000007
 
#define p(x) cout<<x<<" ";
#define p2(x,y) cout<<x<<" "<<y<<" "
#define p3(x,y,z) cout<<x<<" "<<y<<" "<<z<<" "
#define F(i,a,b) for(ll i=a;i<=b;i++)
#define RF(i,a,b) for(ll i=a;i>=b;i--)
 
#define ff first
#define ss second
#define mp(x,y) make_pair(x,y)
#define pi pair<ll,ll>
#define ppi pair<ll,pi>
#define pb push_back
#define all(v) v.begin(), v.end() 

ll dp[100005];
ll solve(ll * v,ll n){
  if(n<=0)
    return 0;
  if(n==1)
    return 0;
  if(n==2)
    return abs(v[1]-v[0]);
  if(dp[n]!=-1)
    return dp[n];
  ll result=min(abs(v[n-1]-v[n-2])+solve(v,n-1),abs(v[n-1]-v[n-3])+solve(v,n-2));
  dp[n]=result;
return dp[n];
} 

int main()
{

ios_base::sync_with_stdio(false);
cin.tie(NULL);
cout.tie(NULL);
cout<<fixed<<setprecision(6);

// #ifndef ONLINE_JUDGE
// freopen("input.txt","r",stdin);
// freopen("output.txt","w",stdout);
// #endif
  
    ll t=1;
    //cin>>t;
    
    while(t--)
    {
      ll n;
      cin>>n;
    ll v[100005];
      memset(dp,-1,sizeof(dp));
      F(i,0,n-1) cin>>v[i];
      cout<<solve(v,n);

    }
        
}

Measured memory_bytes: 4992
import numpy as np

N, D = map(int, input().split())
X = []
for i in range(N):
    X.append(list(map(int, input().split())))

X = np.array(X)
ans = 0
for i in range(N-1):
    for j in range(i+1, N):
        dis = np.linalg.norm(X[i] - X[j])
        if int(dis)==dis:
            ans += 1
print(ans)

Measured memory_bytes: 12468
import java.util.Scanner;
import java.util.Arrays;

public class Main {
	public static void main(String[] args) {
		Scanner input = new Scanner(System.in);
		int n = input.nextInt();
		int[] a = new int[n];
		for (int i = 0; i < n; i++) {
			a[i] = input.nextInt();
		}
		Arrays.sort(a);
		boolean t = true;
		for (int i = 0; i < n - 1; i++) {
			if (a[i] == a[i + 1]) {
				System.out.print("NO");
				t = false;
				break;
			}
		}

		if (t) {
			System.out.print("YES");
		}

	}
}

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

#define M 1000000/* your task*/
#define L 14

char H[M][L]; /* Hash Table */

int getChar(char ch){
  if ( ch == 'A') return 1;
  else if ( ch == 'C') return 2;
  else if ( ch == 'G') return 3;
  else if ( ch == 'T') return 4;
}

/* convert a string into an integer value */
long long getKey(char str[]){
  long long sum = 0, p = 1, i;
  for ( i=0; i<strlen(str); i++ ){
    sum += p*(getChar(str[i]));
    p *= 5;
  }
  return sum;
}

int h1(int key){ return key % M; }
int h2(int key){ return 1+(key % (M-1)); }

int find(char str[]){
  long long key,i,h;
  int x,y;
 
  key=getKey(str);
  x=h1(key);
  y=h2(key);

  for(i=0; i<M; i++){
    h=(x + i * y) % M;
    if(strcmp(H[h],str)==0) return 1;
    else if(strlen(H[h])==0) return 0;
  }
  
  return 0;
}

int insert(char str[]){
  long long key,i,h;
  int x,y;
 
  key=getKey(str);
  x=h1(key);
  y=h2(key);

  for(i=0; i<M; i++){
    h=(x + y * i) % M;
    if(strcmp(H[h],str)==0)return 1;
    else if(strlen(H[h])==0){
      strcpy(H[h],str);
      return 0;
    }
  }
  
  return 0;
}

int main(){
    int i, n, h;
    char str[L], com[9];
    for ( i = 0; i < M; i++ ) H[i][0] = '\0';
    
    scanf("%d", &n);
    
    for ( i = 0; i < n; i++ ){
	scanf("%s %s", com, str);
	
	if ( com[0] == 'i' ){
	    insert(str);
	} else {
	    if (find(str)){
		printf("yes\n");
	    } else {
		printf("no\n");
	    }
	}
    }

    return 0;
}

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

#define rep(i,s,n) for(ll i = (s); i < (n); i++)
#define rep0(i,n) rep(i,0,n)
#define rep1(i,n) rep(i,1,n+1)

#define BR "\n"
#define SP " "

class UFD {
private:
  int par[10000];
public:
  void init(int N) {
    rep0(i, N) {par[i] = i;}
  }
  void unite(int x, int y) {
    par[root(y)] = root(x);
  }
  int root(int x) {
    if (x == par[x]) return x;
    return (par[x] = root(par[x]));
  }
  bool same(int x, int y) {
    return (root(x) == root(y));
  }
};

int main() {
  int N, Q;
  cin >> N >> Q;
  UFD ufd;
  ufd.init(N);

  rep0(i, Q) {
    int c, x, y;
    cin >> c >> x >> y;
    if (c == 0) ufd.unite(x, y);
    else if (ufd.same(x, y)) cout << "1\n";
    else cout << "0\n";
  }

  return 0;
}


Measured memory_bytes: 3120
#include<iostream>
#include<algorithm>
#include<functional>
#include<cmath>
#include<string>
#include<vector>
#include<stack>
#include<queue>
#include<map>
#include<set>
#include<deque>
using namespace std;
#define ll long long
const int mod = 1000000007;
const ll INF = 1000000000000000000;
double PI = 3.14159265358979323846;
int main()
{
	int A, B, H, M;
	cin >> A >> B >> H >> M;
	double degM = M * 6.0;
	double degH = H * 30.0 + M * 0.5;
	double deg = min(abs(degH - degM), 360 - abs(degH - degM));
	double ans = A * A + B * B - 2.0 * A * B * cos(deg * PI / 180);
	ans = pow(ans, 0.5);
	printf("%.10f\n",ans);
}

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

int main() {
  int N, K;
  cin >> N >> K;
  int S;
  
  for(int i = 0; i < N; i++){
    int x;
    cin >> x ;
    if (x < K - x) {
      S += 2 * x;
    }
    else {
      S += 2 * (K - x);
    }
  }
  cout << S << endl;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main{

	static final Scanner s=new Scanner(System.in);

	public static void main(String args[]){
		String a=s.next().toLowerCase(),b;
		int c=0;
		while(!(b=s.next()).equals("END_OF_TEXT"))
			if(a.equals(b.toLowerCase()))
				c++;
		System.out.println(c);
	}
}

Measured memory_bytes: 26120
#include <bits/stdc++.h>
typedef long long int LL;
typedef unsigned long long int ULL;
using namespace std;

// 插入此處
const int MAXN = 2e5 + 2;
vector<int> A(MAXN);

struct node {
    int val, cnt;
}typedef Node;

int main() {
    std::ios::sync_with_stdio(false);
    cin.tie(0);
    int N; cin >> N;
    for (int i = 0; i < N; ++i) {
        cin >> A[i];
    }
    vector<Node> v;
    for (int i = 0; i < N; ++i) {
        Node n;
        n.val = A[i];
        n.cnt = 1;
        if (A[i] == 0) {
            ++i;
            for (; i < N && A[i] == 0; ++i) {
                ++n.cnt;
            }
            --i;
        }
        v.push_back(n);
    }
    long long ans = 0;
    for (int i = 0; i < v.size(); ++i) {
        int t = 0;
        LL cur = 0;
        for (int j = i; j < i+42 && j < v.size(); ++j) {
            if ((t & v[j].val) > 0)  break;
            cur += v[j].cnt;
            t |= v[j].val;
        }
        if (v[i].val == 0) {
            ans += v[i].cnt;
            ans += (v[i].cnt) * (cur - v[i].cnt);
            ans += 1LL * (v[i].cnt) * (v[i].cnt - 1) / 2;
        } else {
            ans += cur;
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 6064
#include <cstdio>
#include <map>
#include <vector>
#include <cmath>
 #include <iostream>
using namespace std;
#define sz(x)          (int)((x).size(x))
#define ARRAY_LENGTH(array) (sizeof(array) / sizeof(array[0]))
#define all(x)         (x).begin(), (x).end()
#define sci(x)         int x;       scanf("%d", &x);
#define scii(x, y)     int x, y;    scanf("%d %d", &x, &y);
#define sciii(x, y, z) int x, y, z; scanf("%d %d %d", &x, &y, &z);
#define debug(x)       { cerr << #x << " = " << x << endl; }
#define REP(i, y)  for (__typeof(x) i = 0; i < y; i++)
#define REPI(i, y)  for (__typeof(x) i = y; i > 0; i--)
typedef long long      ll;
typedef pair<int, int> P;
typedef pair<P, int>   PP;
typedef vector<int>    VV;
typedef vector<P>      VVP;
typedef vector<PP>     VVPP;
const   int            INF = 2<<20;
const   double         EPS = 1E-8;
const   int            MAX_N = 100001;
 
int main() {
  sci(N);
  long long A[MAX_N];
  long long B[MAX_N];
  long long update=0;
  for (int i=0; i<N; i++) {
    sci(a); sci(b);
    A[i] = a;
    B[i] = b;
  }
  for (int i=N-1; i>=0; i--) {
      int k=1;
      //if(A[i]==0) {
      //  continue;
      //}
      //while(k*B[i] < (A[i]+update)) k++;
      //int k = (A[i]+update)/B[i];
      //k++;
      //update += k*B[i] - (A[i]+update);
    A[i] += update;
    update += (B[i] - A[i] % B[i]) % B[i];
  }
  cout<<update<<endl;
}

Measured memory_bytes: 1792
#include<bits/stdc++.h>
#pragma GCC optimize("Ofast")
using namespace std;
typedef long long ll;
typedef pair<ll, ll> PLL;
typedef vector<int> VI;
typedef vector<char> VC;
typedef vector<double> VD;
typedef vector<string> VS;
typedef vector<ll> VLL;
typedef vector<PLL> VP;
const static int INF = 1000000000;
const static int MOD = 1000000007;
const int dx[4]={1, 0, -1, 0};
const int dy[4]={0, 1, 0, -1};
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; }
#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 rept(i,m,n) for(ll i=m; i<n; i++)
#define stl_rep(itr, x) for (auto itr = x.begin(); itr != x.end(); ++itr)
#define all(x) (x).begin(), (x).end()
#define F first
#define S second
#define PF push_front
#define PB push_back
#define SORT(V) sort((V).begin(), (V).end())
#define RVERSE(V) reverse((V).begin(), (V).end())
#define paired make_pair
#define PRINT(V) for(auto v : (V)) cout << v << " "
//charを整数に
int ctoi(char c) { if (c >= '0' && c <= '9') { return c - '0'; } return 0; }
// 累積和 for (int i = 0; i < N; ++i) s[i+1] = s[i] + a[i]; 
void cum_sum(int N,vector<double> a, vector<double> &s){ for(int i=0; i<N; i++){ s[i+1]=s[i]+a[i];}}
//ユークリッドの控除法
ll gcd(ll a,ll b){
    if(b == 0) return a;
    return gcd(b,a%b);
}
//最小公倍数
ll lcm(ll a,ll b){
    ll g = gcd(a,b);
    return a / g * b; // Be careful not to overflow
}
//素数判定
bool is_prime(long long n) {
    if (n <= 1) return false;
    for (long long p = 2; p * p <= n; ++p) {
        if (n % p == 0) return false;
    }
    return true;
}
int getdigit(ll num){
    unsigned digit=0;
    while(num!=0){
        num /= 10;
        digit++;
    }
    return digit;
}
//空白文字も入力 getline(cin, S);
//桁数指定 setprecision

int main()
{
    ios::sync_with_stdio(0); 
    cin.tie(0); 
    cout.tie(0);
    int N;
    cin >> N;
    ll a[100010][3]={};
    ll dp[100010][3]={};

    rep(i,N){
        rep(j,3){
            cin >> a[i][j];
        }
    }

    rep(i,N){
        rep(j,3){
            rep(k,3){
                if(j==k) continue;
                chmax(dp[i+1][k],dp[i][j]+a[i][k]);
            }
        }
    }

    ll res=0;
    rep(i,3){
        chmax(res, dp[N][i]);
    }
    cout << res << endl;
}

Measured memory_bytes: 4992
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> pll;
typedef pair<pll,ll> plll;
typedef pair<pll,pll> ppll;
typedef long double ld;

#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define fst first
#define snd second
#define ins insert
#define pb push_back
template< typename T,typename V>ostream &operator<< (ostream &out,const pair<T,V> x){ out << "{" << x.fst << " : " << x.snd << "}"; return out;}template< typename T>ostream &operator<< (ostream &out,const set<T> x){ for(auto &it : x){ out << it << " "; } return out;}template< typename T>ostream &operator<< (ostream &out,const multiset<T> x){ for(auto &it : x){ out << it << " "; } return out;}template< typename T,typename V>ostream &operator<< (ostream &out,const map<T,V> x){ for(auto &it : x){ out << "[" << it.fst << "]" << " = " << it.snd << "\n"; } return out;}template< typename T>ostream &operator<< (ostream &out,const vector<T> x){ for(int i = 0;i < x.size() - 1; ++i){ out << x[i] << " "; } out << x.back(); return out;}template< typename T>ostream &operator<< (ostream &out,const vector<vector<T> > x){ for(int i = 0;i < x.size() - 1; ++i){ out << "[" << i << "]" << " = {" << x[i] << "}\n"; } out << "[" << x.size() - 1 << "]" << " = {" << x.back() << "}\n"; return out;}

const int N = 1e6 + 5;
const int MOD = 1e9 + 7;
const int INF = 1e9;
main(){
    ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    //freopen(".in", "r", stdin);
    //freopen(".out", "w", stdout);
    ll x,y;
    cin >> x >> y;
    ll ans = x / y;
    if(x % y)ans++;
    cout << ans;
    return 0;
}



Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <vector>
#include <map>
#include <algorithm>
#include <string>
#include <sstream>
 
#define INPUT_FROM_FILE (0) 
#if INPUT_FROM_FILE
#include <fstream>
#endif

int main(int argc, char **argv){
	std::string buf;
	int p;
	std::map<std::string, std::vector<int> > map;

#if INPUT_FROM_FILE
	std::ifstream ifs("test.txt");
	std::cin.rdbuf(ifs.rdbuf());
#endif

	while(std::cin >> buf >> p){
		map[buf].push_back(p);
	}

	for(std::map<std::string, std::vector<int> >::const_iterator it = map.begin(); it != map.end(); it++){
		std::vector<int> pages = it->second;
		std::sort(pages.begin(), pages.end());

		std::cout << it->first << std::endl;
		std::cout << pages[0];
		for(int i = 1; i < pages.size(); i++){
			std::cout << " " << pages[i];
		}
		std::cout << std::endl;
	}


#if INPUT_FROM_FILE
		//fclose(fp);
#endif
	return 0;
}



Measured memory_bytes: 3128