akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;

vector<pair<int, int>> fri, blo;
vector<int> Group;
vector<vector<int>> G(100001);

void dfs(int now, int parent)
{
    Group[now] = parent;
    for (int &x : G[now])
    {
        if (Group[x] == -1)
        {
            dfs(x, parent);
        }
    }
}

int main()
{
    int n, m, k;
    cin >> n >> m >> k;
    blo.resize(k);
    fri.resize(m);
    Group.resize(n, -1);
    for (int i = 0; i < m; i++)
    {
        int a, b;
        cin >> a >> b;
        G[--a].push_back(--b);
        G[b].push_back(a);
        fri[i] = {a, b};
    }

    for (int i = 0; i < k; i++)
    {
        int a, b;
        cin >> a >> b;
        blo[i] = {--a, --b};
    }
    for (int i = 0; i < n; i++)
    {
        if (Group[i] == -1)
            dfs(i, i);
    }
    vector<int> cnt(n, 0);
    for (int &x : Group)
    {
        cnt[x]++;
    }
    vector<int> ret(n, 0);
    for (int i = 0; i < n; i++)
    {
        ret[i] = cnt[Group[i]] - 1;
    }
    for (auto &x : fri)
    {
        ret[x.first]--;
        ret[x.second]--;
    }
    for (auto &x : blo)
    {
        if (Group[x.first] == Group[x.second])
        {
            ret[x.first]--;
            ret[x.second]--;
        }
    }
    for (auto &x : ret)
    {
        cout << x << " ";
    }
    cout << endl;
    return 0;
}

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

using namespace std;

typedef pair <string, int> psi;

map <psi, int> id;

bool compare(psi x, psi y) {
  if(x.first == y.first) return x.second > y.second;
  return x.first < y.first;
}

int main() {
  int n; cin >> n;
  vector <psi> v;
  vector <psi> save;
  for(int i = 1; i <= n; i++) {
    string x; cin >> x;
    int p; cin >> p;
    save.push_back({x, p});
    v.push_back({x, p});
    id[{x, p}] = i;
  }
  sort(v.begin(), v.end(), compare);
  int l = 1;
  for(auto c : v) {
    cout << id[c] << '\n';
  }
}

Measured memory_bytes: 256
a, b, h, m = gets.split.map(&:to_i)

def angle(h, m)
  # 720 min => rotate
  h_angle = 360.0 *  (h * 60 + m) / 720.0

  m_angle = 360.0 * (m / 60.0)
  diff = (h_angle - m_angle).abs
  diff = 360 - diff if diff > 180
  return diff
end

def to_rad(angle)
  angle * Math::PI / 180
end

# puts angle(h, m)
# puts (angle(h, m) * Math::PI / 180);
rad = to_rad(angle(h, m))
# puts Math.cos(rad)
res = Math.sqrt(a**2 + b**2 - 2 * a * b * Math.cos(rad) ).abs

puts res


Measured memory_bytes: 14712
#include<bits/stdc++.h>
#define _GLIBCXX_DEBUG
#define rep(i,n) for (int i = 0; i < (int)(n); i++)
#define all(v) v.begin(),v.end()
#define INF INT_MAX;
typedef long long ll;
using namespace std;

int main(){
  int N; cin >>N;
  vector<int> vec(N);
  rep(i,N) cin >> vec.at(i);
  int Min=vec.at(0);
  int ans =1;
  for(int i=1;i<N;i++){
    if(vec.at(i)<Min){
      ans++;
      Min = vec.at(i);
    }
  }
  cout << ans  <<endl;

}

Measured memory_bytes: 1024
#include<stdio.h>
#define N 101

int main(){
  int G[N][N],A[N],key[N],p[N];
  int i,j,n,count=0,cost,u=0;

  scanf("%d",&n);

  for(i=0 ; i<n ; i++){
    for(j=0 ; j<n ; j++){
      scanf("%d",&G[i][j]);
    }
  }

  for(i=0 ; i<n ; i++){
    A[i] = 0;
    p[i] = -1;

    if(i==0)key[i] = 0;
    else key[i] = 2001;
    
  }


  while(cost != 2001){
    cost = 2001;
    for(i=0 ; i<n ; i++){
      if(A[i]!=2 && key[i]<cost){
	/*２は探索済み*/
	cost = key[i];
	u = i;
      }
    }

    A[u]=2;
    for(i=0 ; i<n ; i++){
      if(G[u][i] != -1 && A[i] != 2 && G[u][i]<key[i]){
	/*-1は辺が存在しない*/
	p[i] = u;
	key[i] = G[u][i];
	A[i] = 1;
      }
    }
  }

  for(i=0 ; i<n ; i++){
    if(p[i] != -1){
      count += G[i][p[i]];
    }
  }

    printf("%d\n",count);

    return 0;
  }

Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
#define fi first
#define endl "\n"
#define se second
#define ll long long
#define inf 0x3f3f3f3f
#define fast    ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
const int N = 3e5+5;
const ll mod =   1e9+7;
ll n;
ll arr[N];
int main()
{  fast
cin>>n;
for(int i=1;i<=n;i++){
	cin>>arr[i];

}
sort(arr+1,arr+n+1);
ll sum=arr[n];
ll y=n-1;ll x=1;
while(x+2<=n-1){
	sum+=2*arr[y--];x+=2;
}//cout<<sum<<endl;
sum+=(n-1-x)*arr[y];
cout<<sum;
}

Measured memory_bytes: 5200
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using ll = long long ;
int main(){
    int n;
    cin >> n;
    vector<int> joushi(n);
    rep(i,n-1){
        int a;
        cin >> a;
        a--;
        joushi[a]++;
    }
    rep(i,n) cout << joushi[i] << endl;
}

Measured memory_bytes: 4028
#include <iostream>
#include <string>
#include <algorithm> 
#include <cstdlib>
#include <map>
#include <queue>
#include <vector>
#include <cmath>
#include <limits>
#define ll long long
using namespace std;
int main(){
    string s;
    cin >> s;
    int a=0,b=0,c=0;
    for(int i=0;i<s.size();i++){
        if(s[i]=='a'){
            a++;
        }else if(s[i]=='b'){
            b++;
        } else{
            c++;
        }
    }
    int size = s.size();
    if(size%3!=0){
      size = size/3 + 1;
    }else{
      size = size/3;
    }
    if(a<=size&&b<=size&&c<=size){
      cout << "YES" << endl;
    }else{
      cout << "NO" << endl;
    }
}


Measured memory_bytes: 512
import bisect as bs

def fun(f,i,sw):
    ret=[]
    for s in sw:
        ii,ss=min(i,s),max(i,s)
        ret.append( f[:ii]+f[ss]+f[ii+1:ss]+f[ii]+f[ss+1:])
    return ret

def exist(a, x):
    'Locate the leftmost value exactly equal to x'
    i = bs.bisect_left(a, x)
    try:
        if i != len(a) and a[i] == x:
            return 1
    except:
        return 0

swaplist=[[1,4],[0,2,5],[1,3,6],[2,7],[0,5],[4,6,1],[5,7,2],[6,3]]
A={}
A[1234567]=0
ks=[1234567]
F=["01234567"]
n=0
while len(F)!=0:
    NF=[]
    n+=1
    for f in F:
        i=f.index('0')
        sw=swaplist[i]
        for g in fun(f,i,sw):
            ig=int(g)
            if not exist(ks,ig):
                A[ig]=n
                bs.insort(ks,ig)
                NF.append(g)
    F=NF[:]
while(1):
    try:
        print A[int("".join(raw_input().split()))]
    except:
        break

Measured memory_bytes: 6228
A,B,H,M = map(int,input().split())
minu = H * 60 + M

kaku1 = 360 *minu / (12*60)
kaku2 = 360 *minu / 60
kaku = abs(kaku1-kaku2)

import math

cos = math.cos(math.radians(kaku))
print((A**2+B**2 - 2*A*B*cos)**(1/2))


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

#define PI 4*atan(1)
#define INF 1e8

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

int main(){
  string s;
  cin >> s;
  bool A = false;
  int l = 0, r = 0;
  for(int i = 0; i < s.size(); i++){
    if(A == true && s[i] == 'Z'){
      r = i;
    }
    if(A == false && s[i] == 'A'){
      A = true;
      l = i;
    }
  }
  cout << r - l + 1 << endl;
}


Measured memory_bytes: 640
#include<cstdio>
#include<vector>
#include<algorithm>
#include<utility>
#include<numeric>
#include<iostream>
#include<array>
#include<string>
#include<sstream>
#include<stack>
#include<queue>
#include<list>
#include<functional>
#define _USE_MATH_DEFINES

#include<math.h>
#include<map>

#define INF 200000000

using namespace std;

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<ll, int> pli;

struct OwnVector2
{
	double x, y;
	OwnVector2(double x,double y):x(x),y(y){}
	OwnVector2() :OwnVector2(0, 0) {}
	OwnVector2 operator+(const OwnVector2& v)const
	{
		return OwnVector2(x + v.x, y + v.y);
	}
	OwnVector2 operator-(const OwnVector2& v)const
	{
		return OwnVector2(x - v.x, y - v.y);
	}
	OwnVector2 operator*(const double v)const
	{
		return OwnVector2(x*v, y*v);
	}
};

OwnVector2 CalcCrossPoint(OwnVector2 p1, OwnVector2 p2, OwnVector2 p3, OwnVector2 p4)
{
	OwnVector2 p12, p13, p14, p34, p31, p32;
	p12 = p2 - p1; p13 = p3 - p1; p14 = p4 - p1; p34 = p4 - p3; p31 = p1 - p3; p32 = p2 - p3;

	double ksi, delta;

	ksi = (p14.x*p34.y - p14.y*p34.x);
	delta = (p12.x*p34.y - p12.y*p34.x);

	return p1 + p12*(ksi / delta);
}

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

	int q;
	cin >> q;

	for (int i = 0; i < q; i++)
	{
		double x0, x1, x2, x3, y0, y1, y2, y3;
		cin >> x0 >> y0 >> x1 >> y1 >> x2 >> y2 >> x3 >> y3;

		OwnVector2 p0(x0, y0), p1(x1, y1), p2(x2, y2), p3(x3, y3);
		OwnVector2 crossPoint = CalcCrossPoint(p0, p1, p2, p3);

		printf("%.10lf %.10lf\n", crossPoint.x, crossPoint.y);
	}

	return 0;
}


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


int main(){
	
	int tc;
	char angka[1005];
	int count;
	
//	scanf("%d",&tc);
//	
//	for(int i=0;i<tc;i++){
		scanf("%s",angka);
		
		int len=strlen(angka);
		
		for(int b=0,j=len-1;b<len;b++,j--){
			if(angka[b]==angka[j]){
				count++;
			}
		}
		
		if(count==len){
			printf("Yes\n");
		}
		
		else{
			printf("No\n");
		}
		
		count=0;
	//}
	
	
	return 0;
}


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

int main(){
  while(1){
    int H, W;
    cin>>H>>W;
    if(H == 0 && W == 0) break;

      for(int i=0;i<H;i++){
            for(int j=0;j<W;j++){
                 if(i == 0|| i == H - 1 || j == 0 || j == W - 1) cout<<"#";
                          else cout<<".";
            }
                 cout<<endl;
      }
          cout<<endl;
   }

 return 0;
}


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

typedef long long ll;

const int Maxn = 1000005;

int n;
char S[Maxn];
int q;
int k;

int main()
{
    scanf("%d", &n);
    scanf("%s", S);
    scanf("%d", &q);
    while (q--) {
        scanf("%d", &k);
        ll res = 0, cur = 0;
        int D = 0, M = 0;
        int l = 0;
        for (int r = 0; r < n; r++) {
            if (r - l + 1 > k) {
                if (S[l] == 'D') { cur -= M; D--; }
                else if (S[l] == 'M') M--;
                l++;
            }
            if (S[r] == 'D') D++;
            else if (S[r] == 'M') { cur += D; M++; }
            else if (S[r] == 'C') res += cur;
        }
        printf("%lld\n", res);
    }
    return 0;
}


Measured memory_bytes: 1280
import sys
readline = sys.stdin.readline
write = sys.stdout.write

from heapq import heappush, heappop
class MinCostFlow:
    INF = 10**18

    def __init__(self, N):
        self.N = N
        self.G = [[] for i in range(N)]

    def add_edge(self, fr, to, cap, cost):
        forward = [to, cap, cost, None]
        backward = forward[3] = [fr, 0, -cost, forward]
        self.G[fr].append(forward)
        self.G[to].append(backward)

    def flow(self, s, t, f):
        N = self.N; G = self.G
        INF = MinCostFlow.INF

        res = 0
        H = [0]*N
        prv_v = [0]*N
        prv_e = [None]*N

        d0 = [INF]*N
        dist = [INF]*N

        while f:
            dist[:] = d0
            dist[s] = 0
            que = [(0, s)]

            while que:
                c, v = heappop(que)
                if dist[v] < c:
                    continue
                r0 = dist[v] + H[v]
                for e in G[v]:
                    w, cap, cost, _ = e
                    if cap > 0 and r0 + cost - H[w] < dist[w]:
                        dist[w] = r = r0 + cost - H[w]
                        prv_v[w] = v; prv_e[w] = e
                        heappush(que, (r, w))
            if dist[t] == INF:
                return None

            for i in range(N):
                H[i] += dist[i]

            d = f; v = t
            while v != s:
                d = min(d, prv_e[v][1])
                v = prv_v[v]
            f -= d
            res += d * H[t]
            v = t
            while v != s:
                e = prv_e[v]
                e[1] -= d
                e[3][1] += d
                v = prv_v[v]
        return res

def solve():
    N = int(readline())
    P = [list(map(int, readline().split())) for i in range(N)]
    s = set()
    for a, b in P:
        s.add(a); s.add(b)
    S = sorted(s)
    M = len(S)
    mp = {e: i for i, e in enumerate(S)}
    mcf = MinCostFlow(N+M+2)
    for i in range(M):
        mcf.add_edge(N+i, N+M+1, 1, 0)
    for i, (a, b) in enumerate(P):
        mcf.add_edge(N+M, i, 1, 0)
        mcf.add_edge(i, N+M+1, 1, 0)
        mcf.add_edge(i, N+mp[a], 1, -b)
        mcf.add_edge(i, N+mp[b], 1, -a)
    write("%d\n" % -mcf.flow(N+M, N+M+1, N))
solve()


Measured memory_bytes: 8424
#include<iostream>
using namespace std;
int main(){
	int n,a1=0,a2=0,a4=0;
	cin>>n;
	while(n--){
		int temp;
		cin>>temp;
		if(temp%4==0) a4++;
		else if(temp%2==0) a2++;
		else a1++;
	}
	if(a2==0){
		if(a4+1>=a1) cout<<"Yes";
		else cout<<"No";
	}else {
		if(a4>=a1) cout<<"Yes";
		else cout<<"No";
	}
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define rep(i, n) for (ll i = 0; i < n; ++i)
#define P pair<ll, ll>
#define Graph vector<vector<ll>>
#define fi first
#define se second
constexpr ll mod = 1000000007;
constexpr ll INF = (1ll << 60);
constexpr double pi = 3.14159265358979323846;
template <typename T>
inline bool chmax(T &a, T b) {
    if (a < b) {
        a = b;
        return 1;
    }
    return 0;
}
template <typename T>
inline bool chmin(T &a, T b) {
    if (a > b) {
        a = b;
        return 1;
    }
    return 0;
}

int main() {
    string a, b, c;
    cin >> a >> b >> c;
    if (a[a.size() - 1] == b[0] && b[b.size() - 1] == c[0]) {
        cout << "YES\n";
    } else {
        cout << "NO\n";
    }
    return 0;
}

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

int main(){
  int N,M;
  cin >> N >> M;
  vector<vector<bool>> match(N,vector<bool>(M,0));
  int k,m;
  for(int i = 0; i < N; ++i){
    cin >> k;
    for(int j = 0; j < k; ++j){
      cin >> m;
      match.at(i).at(m-1) = 1;
    }
  }
  bool like;
  int num;
  for(int i = 0; i < M; ++i){
    like = 1;
    for(int j = 0; j < N; ++j){
      like *= match.at(j).at(i);
    }
    num += like;
  }
  cout << num << endl;
}

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

/*ソートの時に使う*/
int sort(const void *a, const void *b){
    return *(int*)a-*(int*)b ;
}

/**/

int main(void){
    int n;
    scanf("%d",&n);
    int a[n];
    for (int i=0; i<n; i++){
        scanf("%d",&a[i]);
    }
    qsort (a,n,sizeof(int),sort); 
    printf ("%d",a[n-1]-a[0]);
	return 0 ;
}

Measured memory_bytes: 128
import java.io.InputStream;
import java.io.PrintStream;
import java.util.Scanner;

public class Main {

  public static void main(String[] args) {
    resolve(System.in, System.out);
  }

  static void resolve(InputStream is, PrintStream pw) {
    Scanner sc = new Scanner(is);
    String s = sc.next();
    String t = sc.next();
    int ans = t.length();
    for (int i = 0; i <= s.length() - t.length(); i++) {
      ans = Math.min(countDiff(s.substring(i, i + t.length()), t), ans);
    }
    pw.println(ans);
  }

  static int countDiff(String subS, String t) {
    int diff = 0;
    for (int i = 0; i < subS.length(); i++) {
      if (subS.charAt(i) != t.charAt(i)) {
        diff++;
      }
    }
    return diff;
  }
}


Measured memory_bytes: 35736
A[10];i;b=-1;main(a){for(;i<10;)scanf("%d",A+i++);for(;~scanf("%d",&a);b^=~i?1<<i:0)for(i=9;a&&~--i;)a*=A[i]!=a;puts(b&7&&b&56&&b&448&&b&73&&b&146&&b&292&&b&273&&b&84?"No":"Yes");}

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

int main(){
  int n,a,b;
  cin>> n;
  vector<pair<int,int>> w(n);
  for (int i=0; i<n; i++){
    cin>> a >> b;
    w.at(i)=make_pair(b,a);
  }
  
  sort(w.begin(),w.end());
  int now=0;
  string ans="Yes";
  for (auto i: w){
    now+=i.second;
    if (now>i.first){
      ans="No";
      break;
    }
  }
  cout<< ans <<endl;
}

Measured memory_bytes: 1920
R, G, B, N = map(int, input().split())
 
count = 0
tmp1 = N + R
for i in range(N // R + 1):
    tmp1 -= R
    tmp2 = tmp1 + G
    for j in range(N // G + 1):
        tmp2 -= G
        if tmp2 < 0:
            continue
        if tmp2 % B == 0:
            count += 1
 
print(count)

Measured memory_bytes: 40812
#include <iostream>
#include <cstring>
#include <stdlib.h>
#include <vector>
#include <algorithm>
#include <cmath>
#include <stack>
#include <queue>
#include <math.h>

using namespace std;

int main()
{
    int h,w;
    cin >> h >> w;
    int tile[h+2][w+2];
    memset(tile, 0, sizeof(tile));
    for(int i=1; i<=h; i++){
        for(int j=1; j<=w; j++){
            char tmp;
            cin >> tmp;
            if(tmp=='#'){
                tile[i][j]=1;
            }
        }
    }
    /*for(int i=0; i<=h+1; i++){
        for(int j=0; j<=w+1; j++){
            cout << tile[i][j];
        }
        cout << endl;
    }*/
    int a[3]={-1, 0, 1}, b[3]={-1, 0, 1};
    for(int i=1; i<=h; i++){
        for(int j=1; j<=w; j++){
            if(tile[i][j]==1){
                cout << '#';
            }else{
                int ans=0;
                for(int k=0; k<3; k++){
                    for(int l=0; l<3; l++){
                        ans+=tile[i+a[k]][j+b[l]];
                    }
                }
                cout << ans;
            }
        }
        cout << endl;
    }
    
    return 0;
}

Measured memory_bytes: 504
#include <iostream>
#include <string>
#include <algorithm>
#include <functional>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <cstdio>
#include <cmath>
#include <tuple>


// #define INT_MAX 2147483647
// #define LL_MAX 9223372036854775807

using namespace std;
#define i64  long long

void solve(void)
{
  int N,M;
  cin>>N>>M;
  vector<pair<int,int> > key;
  for (int i = 0; i < M; i++)
  {
    int a,b;
    cin>>a>>b;
    int s = 0;
    for (int j = 0; j < b; j++)
    {
      int c;
      cin>>c;
      c--; //１を０にする シフト演算の指数にするため
      s |= 1<<c;
    }

    key.emplace_back(s,a);
  }

  vector<int> DP (1<<N,INT32_MAX/2);

  DP[0] = 0;
  for (int s = 0; s < 1<<N; s++)
  {
    for (int i = 0; i < M; i++)
    {
      //S=0から出発する遷移において、鍵を１個ずつ試す。
      int t = s|key[i].first;
      //コストを計算する
      int cost = DP[s] + key[i].second;
      //遷移先の現在持ってるコストより、新しいコストが低くければ更新する
      DP[t] = min(DP[t],cost);
    }
  }

  if(DP.back() == INT32_MAX/2)
  cout<<-1;
  else
  cout<<DP.back();
  
  return;
  
}
int main(int argc, const char *argv[])
{

  solve();

  return 0;
}


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

int main() {
    string s; cin >> s;
    string t="";
    rep(i, s.size()){
        dump(t);
        if(s.at(i)==','){
            cout << t << " ";
            t = "";
            continue;
        }
        else{
            t.push_back(s.at(i));
        }
    }
    cout << t << endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <queue>
#include <vector>
#include <set>
#include <map>
#include <algorithm>
#include <utility>
#include <iomanip>

#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;
const int inf = 1e9;
const ll linf = 1LL << 50;

int n;
bool is_prime[1000000];
int prime[1000000];

int main(int argc, char const* argv[])
{
	fill(is_prime, is_prime+1000000, true);
	is_prime[0] = false;
	is_prime[1] = false;
	int res = 0;
	for(int i = 2; i < 1000000; i++){
			if(is_prime[i]){
					res++;
					for(int j = 2; j * i < 1000000; j++){
							is_prime[j * i] = false;
					}
			}
			prime[i] = res;
	}
	while(cin >> n){
			cout << prime[n] << endl;
	}
	return 0;
}



Measured memory_bytes: 7932
#define _USE_MATH_DEFINES
#include<iostream>
#include<iomanip>
#include<algorithm>
#include<cctype>
#include<cmath>
#include<cstdio>
#include<deque>
#include<list>
#include<set>
#include<stack>
#include<string>
#include<sstream>
#include<map>
#include<queue>
#include<vector>
using namespace std;

int main() {
	for (double V; cin >> V;) {
		for (int N = 1;; N++) {
			double y = 5 * N - 5;
			double t = sqrt(y / 4.9);
			double v = 9.8*t;
			if (v > V) {
				cout << N << endl;
				break;
			}
		}
	}
	return 0;
}

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

int main()
{
	set<double> height;
	set<double>::iterator it;
	double d;

	while (cin>>d)
		height.insert(d);

	d = *--height.end() - *height.begin();
	cout<<d<<endl;

	return 0;
}

Measured memory_bytes: 0
#include<bits/stdc++.h>
using namespace std;
long long gcd(long long a,long long b){
  if(a%b==0){
    return b;
  }
  else{
    return gcd(b,a%b);
  }
}
long long lcm(long long a,long long b){
    return a/gcd(a,b)*b;
}

 
int main(){
  long long a,b,c,d;
  cin>>a>>b>>c>>d;
  long long l=lcm(c,d);
  cout<<b-b/c-b/d+b/l-((a-1)-(a-1)/c-(a-1)/d+(a-1)/l)<<endl;
}
  

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define MOD 1000000007
//#define MOD 998244353
#define INF 1145141919810893364
//#define INF 810114514
//#define PI 3.141592653589
typedef pair<int,int> PP;
typedef long long ll;
#define int ll
#define setdouble setprecision
#define REP(i,n) for(int i=0;i<(n);++i)
#define OREP(i,n) for(int i=1;i<=(n);++i)
#define RREP(i,n) for(int i=(n)-1;i>=0;--i)
#define GOODBYE do { cout << "0" << endl; return 0; } while (false)
#define MM <<" "<<
#define Endl endl

int N,M;
int a,b;
vector<pair<int,int>> AB;
vector<int> A,B,L,R;
vector<int> C;//aの階差
vector<int> Ans;
vector<pair<int,int>> G[100010];
map<pair<int,int>,int> edge_index;
vector<bool> visited(100010,false);
vector<int> parent(100010);

void dfs(int p){
    visited[p]=true;
    REP(i,G[p].size()){
        int u=G[p][i].first;
        if(visited[u]){
            continue;
        }
        parent[u]=p;
        dfs(u);
        if(C[u]==1){
            int v = parent[u];
            if(v==-1)continue;
            Ans.push_back(edge_index[{u,v}]);
            C[u]^=1;
            C[v]^=1;
        }
        
    }
}

signed main(void){
    cin >> N >> M;
    REP(i,N){
        cin >> a >> b;
        AB.push_back({a,b});
    }
    REP(i,M){
        cin >> a;
        L.push_back(a);
        cin >> a;
        R.push_back(a);
    }
    sort(AB.begin(),AB.end());
    REP(i,N){
        A.push_back(AB[i].first);
        B.push_back(AB[i].second);
    }
    
    C.push_back(B[0]);
    REP(i,N-1){
        C.push_back(B[i]^B[i+1]);
    }
    C.push_back(B[N-1]);
    
    vector<pair<pair<int,int>,int>> edge;
    int l,r;
    REP(i,M){
        l = lower_bound(A.begin(),A.end(),L[i])-A.begin();
        r = upper_bound(A.begin(),A.end(),R[i])-A.begin();
        edge.push_back({{l,r},i});
    }
    //差分取って座圧した
    
    REP(i,edge.size()){
        int l=edge[i].first.first;
        int r=edge[i].first.second;
        int ind=edge[i].second;
        G[l].push_back({r,ind});
        G[r].push_back({l,ind});
        edge_index[{l,r}]=ind;
        edge_index[{r,l}]=ind;
    }
    
    REP(i,N){
        if(visited[i])continue;
        parent[i]=-1;
        dfs(i);
    }
    
    REP(i,N){
        if(C[i]!=0){
            cout << -1 << endl;
            return 0;
        }
    }
    
    sort(Ans.begin(),Ans.end());
    cout << Ans.size() << endl;
    REP(i,Ans.size()){
        cout << Ans[i]+1 << " ";
    }
    cout << endl;
    
    return 0;
}



Measured memory_bytes: 61804
#include<iostream>

int main()
{   
    int a,b,c;
    std::cin >> a >> b >> c;

    if ((a<b)&&(b<c)){
        std::cout << "Yes" << std::endl;      
    }else{
        std::cout << "No" << std::endl;      
    }
    return 0;
}


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

int main()
{
	int a[10], v1, v2;
	char c;

	while (cin >> a[0] >> c >> a[1] >> c >> a[2] >> c >> a[3] >> c 
				>> a[4] >> c >> a[5] >> c >> a[6] >> c >> a[7] >> c 
				>> a[8] >> c >> a[9] >> c >> v1 >> c >> v2) {
		
		int s = 0;

		for (int i = 0; i < 10; i++)
			s += a[i];

		double u = (double)(s * v1) / (double)(v1 + v2);

		int j = 0;

		while (u > 0) {
			u -= a[j];
			j++;
		}

		cout << j << endl;
	}

	return 0;
}


Measured memory_bytes: 3088
#include <stdio.h>
#include<stdlib.h>
int main(){
long int a;
int i;
long int k=0;
scanf("%ld",&a);
long int *b;
b=malloc(sizeof(long int)*a);
for(i=0;i<a;i++)
  scanf("%ld",&b[i]);
for(i=1;i<a;i++){
  if(b[i]-b[i-1]<0){
    k=k+b[i-1]-b[i];
    b[i]=b[i-1];
  }
}
printf("%ld",k);
return 0;
}


Measured memory_bytes: 3252
#include <bits/stdc++.h>
#define ll long long
 
using namespace std;
 
 
int main() {
    
     ll n;
     cin>>n;
     ll ar[n][3],ans[n][3];
     for(ll i=0;i<n;i++)
     {
         cin>>ar[i][0]>>ar[i][1]>>ar[i][2];
     }
    
      for(ll i=0;i<n;i++)
     {
         ans[i][0]=0;ans[i][1]=0;ans[i][2]=0;
     }
    /* for(ll i=0;i<n;i++)
     {
         if(ans[i][0]+ans[i][1]+ans[i][2])cout<<"OHNO!";
     }*/
     ans[0][0]=ar[0][0];
      ans[0][1]=ar[0][1];
       ans[0][2]=ar[0][2];
     
     for(ll i=1;i<n;i++)
     {
         
             ans[i][0]=ar[i][0]+max(ans[i-1][1],ans[i-1][2]);
             ans[i][1]=ar[i][1]+max(ans[i-1][0],ans[i-1][2]);
             ans[i][2]=ar[i][2]+max(ans[i-1][1],ans[i-1][0]);
             
          
     }
     ll anso=0;
     
     
         anso+=max(ans[n-1][0],max(ans[n-1][1],ans[n-1][2]));
     
     cout<<anso;
     
     
    
 
     
    
     
     
}

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

#if MYDEBUG
#include "lib/cp_debug.hpp"
#else
#define DBG(...) ;
#endif

using LL = long long;
constexpr LL LINF = 334ll << 53;
constexpr int INF = 15 << 26;
constexpr LL MOD = 1E9 + 7;

namespace Problem {
using namespace std;
using pii = pair<LL, LL>;
struct Edge {
  int from, to;
  LL cost;
  Edge(int from, int to, LL cost) : from(from), to(to), cost(cost){};
};
typedef vector<vector<Edge>> Graph;

LL dijkstra(const int start, const vector<vector<Edge>> &graph,
            vector<pii> &prev) {
  int visited = 0, N = graph.size();
  // vector<char> visited(N,false);
  // <<cost , place>, prev>
  priority_queue<pair<pii, int>, vector<pair<pii, int>>,
                 greater<pair<pii, int>>>
      Q;
  fill(prev.begin(), prev.end(), make_pair(-2, 0));
  Q.push(make_pair(make_pair(0, start), -1));
  while (!Q.empty()) {
    LL cost;
    int place, from;
    cost = Q.top().first.first;
    place = Q.top().first.second;
    from = Q.top().second;
    Q.pop();
    DBG(place, cost)
    if (prev[place].first != -2) continue;
    DBG(place, cost)
    prev[place] = {from, cost};
    visited++;
    if (visited == N) return 1;
    for (int j = 0; j < (int)graph[place].size(); j++) {
      DBG(graph[place][j].to)
      Q.push(make_pair(
          make_pair(graph[place][j].cost + cost, graph[place][j].to), place));
    }
  }
  return -1;
}

class Solver {
 public:
  int n, m, s, t;
  Graph yen, snuke;
  Solver(LL n) : n(n), yen(n), snuke(n){};

  void solve() {
    cin >> m >> s >> t;
    --s;
    --t;
    for (int i = 0; i < m; ++i) {
      int u, v, a, b;
      cin >> u >> v >> a >> b;
      --u;
      --v;
      yen[u].push_back({u, v, a});
      yen[v].push_back({v, u, a});
      snuke[u].push_back({u, v, b});
      snuke[v].push_back({v, u, b});
      DBG(u, v, a, b)
    }
    vector<pair<LL, LL>> resy(n), ress(n);
    dijkstra(s, yen, resy);
    dijkstra(t, snuke, ress);
    DBG(resy, ress)
    priority_queue<pair<LL, LL>> pq;
    for (int i = 0; i < n; ++i) {
      pq.emplace((LL)1e15 - resy[i].second - ress[i].second, i);
    }
    for (int i = 0; i < n; ++i) {
      while (pq.top().second < i) pq.pop();
      cout << pq.top().first << "\n";
    }
  }
};
}  // namespace Problem

int main() {
  std::cin.tie(0);
  std::ios_base::sync_with_stdio(false);
  long long n = 0;
  std::cin >> n;

  Problem::Solver sol(n);
  sol.solve();
  return 0;
}


Measured memory_bytes: 23232
#include<stdio.h>
int n,A[2000];
int solve(int x, int y){
  int res;
  if(A[x]==y) return 1;
  if(x>=n) return 0;
  res=solve(x+1,y) || solve(x+1,y-A[x]);
  return res;
}

int main(){
  int i,p,m;
  scanf("%d",&n);
  for(i=0;i<n;i++){
    scanf("%d",&A[i]);
  }
  scanf("%d",&p);
  for(i=0;i<p;i++){
    scanf("%d",&m);
    if (solve(0,m)==1) printf("yes\n");
    else printf("no\n");
  }
  return 0;
}



Measured memory_bytes: 2108
import collections

#文字列を一文字ずつ取得したいとき
def inputStrOnebyOne():
    s = list(input())
    return s

#整数を一つずつリストに入れる
def inputOnebyOne_Int():
    a = list(int(x) for x in input().split())
    return a

def main():
    x = int(input())
    a = int(input())
    b = int(input())
    x = x-a
    while b <= x:
        x-=b
    print(x)
    
if __name__=='__main__':
    main()

Measured memory_bytes: 3316
///////////////////////////////////////////////////////
//                                                   //
//                 Algorithm Lab : 05                //
//                                                   //
//                    Heap Sort                      //
//                                                   //
///////////////////////////////////////////////////////\

#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define _pb pop_back
#define VI vector<int>
#define MX 100005
//////////////////////////////////////////////////////

int tree[MX],sorted[MX],n,sz;
void get_random()
{
    for(int i=0; i<sz; i++)
    {
        tree[i]=rand()%MX;;
    }
}
//////////////////////////////////////////////////////

int left_child(int id)
{
    return 2*id+1;
}

//////////////////////////////////////////////////////

int right_child(int id)
{
    return 2*id+2;
}

//////////////////////////////////////////////////////

int parent(int id)
{
    return (id-1)/2;
}

//////////////////////////////////////////////////////

void max_heapify(int id)
{
    int lft=left_child(id);
    int rgt=right_child(id);
    int lrgst=id;
    if(lft<sz&&tree[lft]<=tree[lrgst])
    {
        lrgst=lft;
    }
    if(rgt<sz&&tree[rgt]<=tree[lrgst])
    {
        lrgst=rgt;
    }
    if(lrgst!=id)
    {
        swap(tree[lrgst],tree[id]);
        max_heapify(lrgst);
    }
}
//////////////////////////////////////////////////////

void build_maxheap()
{
    for(int i=(sz-1)/2;i>=0;i--)
    {
        max_heapify(i);
    }
}
//////////////////////////////////////////////////

void Heap_sort()
{
    while(sz>0)
    {
        sorted[n++]=(tree[0]);
        swap(tree[0],tree[--sz]);
        max_heapify(0);
    }
}
////////////////////////////////////////////
void print_vector()
{
    for(int i=0;i<n;i++)
    {
        cout<<sorted[i]<<" ";
    }
    cout<<endl;
}

//////////////////////////////////////////////////
//int main()
//{
//    int i,j,k;
//
//    cout<<"get the size of random numbers: "<<endl;
//    cin>>sz;
//
//    cout<<"generate "<<sz<<" random numbers"<<endl;
//    get_random();
//    build_maxheap();
//    Heap_sort();
//    //reverse(v1.begin(),v1.end());
//    print_vector();
//
//    return 0;
//}

int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    ////////////////////////////////////
    int a,b,x,y,z,i,j,k;
    memset(tree,0,sizeof(tree));
    memset(sorted,0,sizeof(sorted));
    cin>>a>>b>>x>>y;
    sz=a;
    for(int i=0;i<sz;i++)
    {
        cin>>tree[i];
    }
    n=0;
    tree[sz++]=x;
    build_maxheap();
    Heap_sort();
    x=sorted[n-1];
    memset(tree,0,sizeof(tree));
    memset(sorted,0,sizeof(sorted));
    sz=b;
    for(int i=0;i<sz;i++)
    {
        cin>>tree[i];
    }
    n=0;
    tree[sz++]=y;
    build_maxheap();
    Heap_sort();
    y=sorted[0];
    if(x<y)
    {
        cout<<"No War"<<endl;
    }
    else
    {
        cout<<"War"<<endl;
    }
    return 0;
}


Measured memory_bytes: 1024
#include<cstdio>
#include <iostream>
#include<algorithm>
#include<string>
#include<queue>
#include<vector>
#include<functional>
#include<cmath>
#include<map>
#include<stack>
#include<set>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
const ll MOD = 1000000007;
 
int main() {
 
	ll h, w;
	cin >> h >> w;
 
	ll s = h * w;
	ll ans = 10000000000;
	if (h % 3 == 0 || w % 3 == 0) 
		ans = 0;
	else {
		ll mi = min(h, w);
		ll ma = max(h, w);
 
		for (ll i = 1; i < ma; i++) {
			ll sa = i * mi;
			ll sb = (ma - i) * (mi / 2);
			ll sc = s - sa - sb;
			ll diff = max(abs(sa - sc), max(abs(sa - sb), abs(sb - sc)));
			ans = min(diff, ans);
		}
		for (ll i = 1; i < mi; i++) {
			ll sa = i * ma;
			ll sb = (mi - i) * (ma / 2);
			ll sc = s - sa - sb;
			ll diff = max(abs(sa - sc), max(abs(sa - sb), abs(sb - sc)));
			ans = min(diff, ans);
		}
		ans = min(ans, mi);
	}
	cout << ans << endl;
	return 0;
}

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

int palindromeCounter(int n) {
    int A[5];
    int i = 0;
    while (n > 0) {
        A[i] = n % 10;
        n /= 10;
        i++;
    }
    if (A[0] == A[4] && A[1] == A[3]) return 1;
    else return 0;
}

int main() {
    int A, B, res = 0;
    cin >> A >> B;
    for (int n = A; n <= B; n++) {
        res += palindromeCounter(n);
    }
    cout << res << endl;
    return 0;
}


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

int main() {
	int N, A, ans = 0;
	cin >> N;
	vector<int> a(1);
	for (int i = 1; i <= N; ++i) {
		cin >> A;
		if (0 == A) a.push_back(i);
	}
	a.push_back(1 + N);
	for (int i = 1; i < a.size(); ++i) ans = max(a[i] - a[i - 1], ans);
	cout << ans << endl;
}


Measured memory_bytes: 3136
#include <iostream>
#include <cmath>
#include <algorithm>
#include <vector>
#include <set>
#include <unordered_set>
#include <queue>
#include <deque>
#include <string>
#include <sstream>
#include <iomanip>
#include <map>
#include <unordered_map>
#include <stack>
#include <cstdio>
#include <climits>
#include <tuple>
#include <ctime>
#define FOR(i,a,n) for (int i = a; i < n; i++)
#define IFOR(i,n,a) for (int i = n; i >= a; i--)
#define mp make_pair
#define full(a) a.begin(), a.end()
#define SZ(x) ((int)(x).size())
#define TC(tc) while (tc--)
#define VI vector<int>
#define PII pair<int, int>
#define trav(a,x) for (auto& a : x)
typedef unsigned long long ull;
typedef long long ll;
typedef long double ld;
using namespace std;
const int mod = 1e9 + 7;

int main()
{
	ios::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
	int n; cin >> n;
	vector<VI> c(10, VI(10, 0));
	ull cnt = 0;
	FOR(i, 1, n + 1)
	{
		string a = to_string(i);
		c[a[0] - '0'][a[SZ(a) - 1] - '0']++;
	}
	FOR(i, 0, 10)
	{
		FOR(j, 0, 10)
		{
			cnt += (c[i][j] * c[j][i]);
		}
	}
	cout << cnt;
	return 0;
}



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

//const long double PIL = 3.141592653589793238462643383279502884L;
//const double PI = 3.14159265358979323846;

#define sz(a) int((a).size())
#define all(c) (c).begin(), (c).end()
#define what_is(x) cerr << #x << " is " << x << endl;
#define debug(v) for (auto el : v) { cerr << el << ' '; } cerr << endl;

using ll = long long;
using ii = pair<int,int>;
using vi = vector<int>;
using vll = vector<long long>;
using vii = vector<pair<int,int>>;

int main() {
	//~ ios::sync_with_stdio(0);
	//~ cin.tie(0);
	int n;
	cin >> n;
	vi a(n);
	for (int i = 0; i < n; i++) cin >> a[i];
	int x = *max_element(all(a));
	int y = accumulate(all(a), 0);
	string answer = 2*x >= y ? "No" : "Yes";
	cout << answer << endl;
}


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

#define rep(l, r) for (int i = (l); i < (r); i++)

typedef long long ll;
 
using namespace std;

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

    int a, b[n];
    bzero(b, sizeof(b));
    rep(0, n - 1) {
        cin >> a;
        b[a-1]++;
    }

    rep(0, n) cout << b[i] << endl;

    return 0;
}


Measured memory_bytes: 4416
#include <bits/stdc++.h>
#define rep(i,a,b) for(int i = a; i < b; ++i)
#define all(c) c.begin(), c.end()
#define gmax(x,y) x=max(x,y)
#define gmin(x,y) x=min(x,y)
#define gadd(x,y) x=add(x,y)
#define gmul(x,y) x=mul(x,y)
using namespace std;

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

int main(){
	cin.tie(0);
	cout.tie(0);
	ios_base::sync_with_stdio(0);
	ll n,k;
	cin >> n >> k;
	n%=k;
	set<ll> s;
	ll ans = n;
	while(s.find(n) == s.end()){
		s.insert(n);
		n = abs(n-k);
		gmin(ans,n);
	}
	cout << ans << '\n';
}


Measured memory_bytes: 256
n = gets.chomp.to_i
v = gets.chomp.split(" ").map(&:to_i)
count = 0
min = v[0].abs
n.times do |i|
    if v[i] < 0
      count+=1
    end
    if v[i].abs < min
        min = v[i].abs
    end
end
sum = 0
n.times do |i|
    sum += v[i].abs
end
if count%2 != 0 then sum -= min *2 end
puts sum

Measured memory_bytes: 9732
#include<bits/stdc++.h>
using namespace std;
#ifdef LOCAL_DEBUG
  #include "LOCAL_DEBUG.hpp"
#endif
#define int long long
const int MOD = 1e9 + 7;

struct Combination{
  vector<int> fact; //　fact[i] = iの階乗
  Combination(int n) : fact(n+1){
    fact[0] = fact[1] = 1;
    for(int i = 2; i <= n; i++){
      fact[i] = fact[i-1] * i % MOD;
    }
  }

  int nCr(int n, int r){ // nCr = n!/r!(n-r)!
    if(n < r) return 0;
    return fact[n] * inv(fact[r]*fact[n-r]%MOD) % MOD;
  }

  int inv(int n, int p = MOD-2){ // a/n ≡ a*n^(p-2) nとpは互いに素
    int r = 1;
    for(; p > 0; p >>= 1){
      if(p & 1LL) r = (r * n) % MOD;
      n = (n * n) % MOD;
    }
    return r; // r = n^p % MOD
  }
};

signed main(){

  int n; cin >> n;
  vector<vector<int>> G(n);
  for(int i = 0; i < n-1; i++){
    int a, b; cin >> a >> b;
    a--, b--;
    G[a].push_back(b);
    G[b].push_back(a);
  }

  Combination c(n+1);
  vector<int> num(n, 0), dp(n, 1);
  auto dfs1 = [&](auto&& dfs1, int u, int p)->void{
    for(int v : G[u]){
      if(v == p) continue;
      dfs1(dfs1, v, u);
      num[u] += num[v];
      dp[u] = dp[u] * dp[v]%MOD * c.nCr(num[u], num[v]) % MOD;
    }
    num[u]++;
  };
  dfs1(dfs1, 0, -1);

  vector<int> ans(n);
  auto dfs2 = [&](auto&& dfs2, int u, int p, int res)->void{
    ans[u] = dp[u] * res%MOD * c.nCr(n-1, n-num[u]) % MOD;
    for(int v : G[u]){
      if(v == p) continue;
      res = ans[u] * c.inv(dp[v])%MOD * c.inv(c.nCr(n-1, num[v])) % MOD;
      dfs2(dfs2, v, u, res);
    }
  };
  dfs2(dfs2, 0, -1, 1);

  for(int p : ans){
    cout << p << endl;
  }

  return 0;
}


Measured memory_bytes: 20976
#include <bits/stdc++.h>
using namespace std;
#define REP(i,a) for(int i = 0; i < (a); i++)
typedef long long ll;
typedef pair<int, int> P;
const int INF = 1e9;
const int MOD = 1e9 + 7;
#define MAX_N 100
#define MAX_W 10000

int dp[MAX_N + 1][MAX_W + 1];

int main(){
	int N,W;
	cin >> N >> W;
	int value[N],weight[N];
	REP(i,N) cin >> value[i] >> weight[i];
	for(int w = 0; w <= W; w++) dp[0][w] = 0;
	for(int i = 0; i < N; i++){
		for(int w = 0; w <= W; w++){
			if(w >= weight[i]) dp[i + 1][w] = max(dp[i][w - weight[i]] + value[i], dp[i][w]);
			else dp[i + 1][w] = dp[i][w];
		}
	}
	cout << dp[N][W] << endl;
}


Measured memory_bytes: 7032
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

func getScanner(fp *os.File) *bufio.Scanner {
	scanner := bufio.NewScanner(fp)
	scanner.Split(bufio.ScanWords)
	scanner.Buffer(make([]byte, 1000005), 1000005)
	return scanner
}

func getNextString(scanner *bufio.Scanner) string {
	scanner.Scan()
	return scanner.Text()
}

func getNextInt(scanner *bufio.Scanner) int {
	i, _ := strconv.Atoi(getNextString(scanner))
	return i
}

func getNextInt64(scanner *bufio.Scanner) int64 {
	i, _ := strconv.ParseInt(getNextString(scanner), 10, 64)
	return i
}

func getNextUint64(scanner *bufio.Scanner) uint64 {
	i, _ := strconv.ParseUint(getNextString(scanner), 10, 64)
	return i
}

func getNextFloat64(scanner *bufio.Scanner) float64 {
	i, _ := strconv.ParseFloat(getNextString(scanner), 64)
	return i
}

func main() {
	fp := os.Stdin
	wfp := os.Stdout
	cnt := 0

	if os.Getenv("MASPY") == "ますピ" {
		fp, _ = os.Open(os.Getenv("BEET_THE_HARMONY_OF_PERFECT"))
		cnt = 2
	}
	if os.Getenv("MASPYPY") == "ますピッピ" {
		wfp, _ = os.Create(os.Getenv("NGTKANA_IS_GENIUS10"))
	}

	scanner := getScanner(fp)
	writer := bufio.NewWriter(wfp)
	solve(scanner, writer)
	for i := 0; i < cnt; i++ {
		fmt.Fprintln(writer, "-----------------------------------")
		solve(scanner, writer)
	}
	writer.Flush()
}

func solve(scanner *bufio.Scanner, writer *bufio.Writer) {
	s := getNextString(scanner)
	ans := 0
	n := len(s)
	for i := 0; i < n; i++ {
		ans += int(s[i] - '0')
	}

	fmt.Fprintln(writer, ans)
}


Measured memory_bytes: 640
#define LOCAL
#include <bits/stdc++.h>
#define rep(i, n) for(int i=0; i<(n); ++i)
#define rrep(i, n) for(int i=(n-1); i>=0; --i)
#define rep2(i, s, n) for(int i=s; i<(n); ++i)
#define ALL(v) (v).begin(), (v).end()
#define memr(dp, val) memset(dp, val, sizeof(dp))
using namespace std;
typedef long long ll;
static const int INTINF = (INT_MAX >> 1); // 10^9 + 10^7
static const ll LLINF = (LLONG_MAX >> 1);
static const int MAX = 1e5+1;
static const ll MOD = 1e9+7;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
template<class T> inline bool int_ceil(T a, T b) { T res = a / b; if(a % b != 0) res++; return res; }
template<typename T>
using min_priority_queue = priority_queue<T, vector<T>, greater<T> >;
string to_string(string s) { return '"' + s + '"'; }
string to_string(bool b) { return b ? "true" : "false"; }
template <size_t N> string to_string(bitset<N> bs) {
  string res;
  for (size_t i = 0; i < N; ++i) res += '0' + bs[i];
  return res;
}
string to_string(vector<bool> v) {
  string res = "{";
  for (bool e : v) res += to_string(e) + ", ";
  return res += "}";
}
template <class T, class U> string to_string(pair<T, U> p);
template <class C> string to_string(C c) {
  string res = "{";
  for (auto e : c) res += to_string(e) + ", ";
  return res += "}";
}
template <class T, class U> string to_string(pair<T, U> p) {
  return "(" + to_string(p.first) + ", " + to_string(p.second) + ")";
}
void debug() { cerr << '\n'; }
template <class Head, class... Tail> void debug(Head head, Tail... tail) {
  cerr << '\t' << to_string(head), debug(tail...);
}
#ifdef LOCAL
#define print(...) cerr << "[" << #__VA_ARGS__ << "]:", debug(__VA_ARGS__)
#else
#define print(...)
#endif

int main(int argc, const char * argv[]) {
	std::cout << std::fixed << std::setprecision(15);

	int n; cin >> n;
	int mi=INTINF, ma=0;
	rep(i, n){
		int a; cin >> a;
		chmin(mi, a); chmax(ma, a);
	}

	cout << ma - mi << endl;

	return 0;
}


Measured memory_bytes: 3604
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<set>
#include<string>
#include<stack>
#include<cstdio>
#include<cmath>
using namespace std;

typedef long long ll;
typedef long double ld;
typedef pair<int,int> P;
typedef pair<int,P> P1;

#define fr first
#define sc second
#define mp make_pair
#define pb push_back
#define rep(i,x) for(int i=0;i<x;i++)
#define rep1(i,x) for(int i=1;i<=x;i++)
#define rrep(i,x) for(int i=x-1;i>=0;i--)
#define rrep1(i,x) for(int i=x;i>0;i--)
#define sor(v) sort(v.begin(),v.end())
#define rev(s) reverse(s.begin(),s.end())
#define lb(vec,a) lower_bound(vec.begin(),vec.end(),a)
#define ub(vec,a) upper_bound(vec.begin(),vec.end(),a)
#define uniq(vec) vec.erase(unique(vec.begin(),vec.end()),vec.end())
#define mp1(a,b,c) P1(a,P(b,c))

const int INF=1000000000;
const int dir_4[4][2]={{1,0},{0,1},{-1,0},{0,-1}};
const int dir_8[8][2]={{1,0},{1,1},{0,1},{-1,1},{-1,0},{-1,-1},{0,-1},{1,-1}};

int main(){
	long long N,K;
	long long a[1002];
	scanf("%lld%lld",&N,&K);
	for(int i = 1 ; i <= N ; i ++){
		scanf("%lld",&a[i]);
	}
	
	long long s[1002];
	s[0] = 0;
	for(int i = 1 ; i <= N ; i ++){
		s[i] = s[i-1] + a[i];
	}
	
	static long long b[1002][1002];
	for(int i = 1 ; i <= N ; i ++){
		for(int j = i ; j <= N ; j ++){
			b[i][j] = s[j]-s[i-1];
		}
	}
	
	long long ret = 0;
	for(int i = 40 ; i >= 0 ; i --){
		long long t = 1;
		t <<= i;
		long long ret_ = ret+t;
		int cnt = 0;
		for(int i = 1 ; i <= N ; i ++){
			for(int j = i ; j <= N ; j ++){
				if((ret_&b[i][j]) == ret_)cnt ++;
			}
		}
		if(cnt >= K)ret = ret_;
	}
	cout << ret << endl;
}


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

int n, k, q, a;
int p[100000];

int main()
{
	cin >> n >> k >> q;
	for (size_t i = 0; i < q; i++)
	{
		cin >> a;
		p[a - 1]++;
	}
	for (size_t i = 0; i < n; i++)
	{
		if (p[i] + k > q)
		{
			cout << "Yes" << endl;
		}
		else
		{
			cout << "No" << endl;
		}
	}
}

Measured memory_bytes: 1024
#include <cstdio>

int main()
{
    int matrix[4][4];

    for(int i = 1; i <= 3; i++)
        for(int j = 1; j <= 3; j++)
            scanf("%d", &matrix[i][j]);

    int A[4];
    int B[4];

    A[1] = 0;
    B[1] = matrix[1][1] - A[1];
    B[2] = matrix[1][2] - A[1];
    B[3] = matrix[1][3] - A[1];
    A[2] = matrix[2][1] - B[1];
    A[3] = matrix[3][1] - B[1];

    int is_possible = true;
    for(int i = 1; i <= 3; i++)
        for(int j = 1; j <= 3; j++)
            if(A[i] + B[j] != matrix[i][j])
                is_possible = false;

    printf(is_possible ? "Yes\n" : "No\n");
    return 0;
}

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

long long f(long long x)
{
    if (x == 1)
    {
        return 1;
    }
    return 1 + 2 * f(x / 2);
}

int main()
{
    long long H;
    cin >> H;
    cout << f(H) << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
 
  string s ;
  cin >> s;
  
 
      if(s.at(5)=='1'){
        cout << "TBD" << endl;
      }
      else{
        if(s.at(6)<'5'){
      cout << "Heisei" << endl;
        }
        else{
        cout << "TBD" << endl;
        }
      }
   
}


Measured memory_bytes: 256
xi = list(map(int, input().split()))

if xi[0]*xi[1] == 0 and xi[0]*xi[2] == 0:
	print(1)
elif xi[1]*xi[2] == 0 and xi[1]*xi[3] == 0:
	print(2)
elif xi[2]*xi[3] == 0 and xi[2]*xi[4] == 0:
	print(3)
elif xi[3]*xi[4] == 0 and xi[3]*xi[0] == 0:
	print(4)
else:
	print(5)

Measured memory_bytes: 9120
n = int(input())
s = list(input() for _ in range(n))
ans = 0
d = {}
for i in range(n):
    s[i] = "".join(sorted(s[i]))
    if s[i] not in d.keys():
        d[s[i]] = 0
    else:
        d[s[i]] += 1
        ans += d[s[i]]

print(ans)


Measured memory_bytes: 19488
import time
startTimeProblem=time.time()

import fileinput, sys, itertools, functools
from math import *
from bisect import *
from heapq import *
from collections import *

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

class InputHelper:
    def __init__(self):
        self.myinput = fileinput.input()

    def isLocal(self):
        return not fileinput.isstdin()

    def int(self):
        return int(self.myinput.readline().rstrip())

    def ints(self):
        return [int(_) for _ in self.myinput.readline().rstrip().split()]

    def str(self):
        return self.myinput.readline().rstrip()

    def strs(self):
        return [_ for _ in self.myinput.readline().rstrip().split()]

class OutputHelper:
    def int(self, a):
        print(a)    

    def ints(self, a):  
        print(" ".join([str(_) for _ in a]))
    
    def intsNL(self, a):
        for _ in a:
            print(_)
    
    def str(self, s):
        print(s)

    def strs(self, s):
        print(" ".join([_ for _ in s]))

    def strsNL(self, s):
        for st in s:
            print(st)

class ListNode:
    def __init__(self, val):
        self.val = val
        self.next = None
        self.prev = None

In = InputHelper()
Out = OutputHelper()

######################################

N = In.int()
A = In.ints()

A.sort(reverse=True)

l = 0
ans = 0
tick = True
for i in range(len(A)-1):
    ans+=A[l]
    
    if i==0:
        l+=1
    else:        
        if tick:
            tick=not tick
        else:
            l+=1
            tick=not tick

Out.int(ans)
            

######################################

if len(sys.argv)>2 and sys.argv[2]=="TIMEIT":
    fin = (time.time()-startTimeProblem)*1000
    print("{:.2f}".format(fin) + "ms")

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

#pragma GCC target("avx")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repi(i, s, n) for (int i = (s); i < (int)(n); i++)
#define all(x) (x).begin(), (x).end()
#define debug(x) cerr << #x << ": " << x << '\n'

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

const long long INF = 3e18 + 12;
const int inf = 1e9;

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

  int n, d, x;
  cin >> n >> d >> x;
  vector<int> v(n);
  rep(i, n) { cin >> v[i]; }

  int sum = 0;

  rep(i, n) {
    if (v[i] > d) {
      continue;
    } else {
      int j = 2;
      int dd = v[i];
      v[i] = v[i] + 1;
      while (v[i] <= d) {
        debug(v[i]);

        v[i] = (dd * j) + 1;
        sum++;
        j++;
      }
    }
  }

  cout << sum + n + x << endl;

  return 0;
}

Measured memory_bytes: 256