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

const int maxn=85;
int n;
char s[maxn][maxn];
long long F[maxn][maxn][maxn][maxn],G[maxn][maxn][maxn];
bool visF[maxn][maxn][maxn][maxn],visG[maxn][maxn][maxn];
long long solveF(int l,int r,int ll,int rr);
long long solveG(int l,int r,int m);

long long solveG(int l,int r,int m){
	if(l==m&&m==r)return 1;
	if(visG[l][r][m])return G[l][r][m];
	visG[l][r][m]=true;
	for(int ll=l;ll<m;ll++)for(int rr=r;rr>m;rr--)
		G[l][r][m]+=solveG(ll+1,rr-1,m)*solveF(l,ll,rr,r);
	return G[l][r][m];
}
long long solveF(int l,int r,int ll,int rr){
	if(visF[l][r][ll][rr])return F[l][r][ll][rr];
	visF[l][r][ll][rr]=true;
	for(int m=l;m<=r;m++)for(int mm=ll;mm<=rr;mm++)
		if(s[m][mm]=='1')F[l][r][ll][rr]+=solveG(l,r,m)*solveG(ll,rr,mm);
	return F[l][r][ll][rr]; 
}

int main(){
	scanf("%d",&n);
	n*=2;
	for(int i=0;i<n;i++){
		scanf("%s",s[i]);
		for(int j=0;j<n;j++)
			s[i+n][j]=s[i][j+n]=s[i+n][j+n]=s[i][j];
	}
	long long ans=0;
	for(int i=0;i<n;i++)for(int j=i+1;j<n;j++)if(s[i][j]=='1')
		ans+=solveG(i+1,i-1+n,j);
	printf("%lld\n",ans/(n/2));
	return 0;
}

Measured memory_bytes: 314496
#include <iostream>
#include <algorithm>
using namespace std;
class RMQ {
private:
	int size_, dat[262144];
	int query_(int a, int b, int k, int l, int r) {
		if(r <= a || b <= l) return 2147483647;
		if(a <= l && r <= b) return dat[k];
		int lc = query_(a, b, 2 * k, l, (l + r) / 2);
		int rc = query_(a, b, 2 * k + 1, (l + r) / 2, r);
		return min(lc, rc);
	}
public:
	RMQ(int s) {
		for(size_ = 1; size_ < s;) size_ *= 2;
		for(int i = 0; i < size_ * 2; i++) dat[i] = 2147483647;
	}
	void update(int pos, int x) {
		pos += size_; dat[pos] = x;
		while(pos > 1) {
			pos /= 2;
			dat[pos] = min(dat[2 * pos], dat[2 * pos + 1]);
		}
	}
	int query(int l, int r) {
		return query_(l, r, 1, 0, size_);
	}
};
int n, q, c, x, y;
int main() {
	scanf("%d%d", &n, &q);
	RMQ r(n);
	for(int i = 0; i < q; i++) {
		scanf("%d%d%d", &c, &x, &y);
		if(c == 0) r.update(x, y);
		else printf("%d\n", r.query(x, y + 1));
	}
}

Measured memory_bytes: 4232
#include <iostream>
#include <cmath>
#include <algorithm>
#include <vector>

using namespace std;

double EPS = 1e-10;

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

struct P {
	double x, y;
	P() {}
	P(double x, double y) : x(x), y(y) {
	}
	P operator + (P p) {
		return P(add(x, p.x), add(y, p.y));
	}
	P operator - (P p) {
		return P(add(x, -p.x), add(y, -p.y));
	}
	P operator * (double d) {
		return P(x * d, y * d);
	}
	double dot(P p) {
		return add(x * p.x, y * p.y);
	}
	double det(P p) {
		return add(x * p.y, -y * p.x);
	}
};

bool cmp_x(const P& p, const P& q) {
	if (p.x != q.x) {
		return p.x < q.x;
	}
	return p.y < q.y;
}

vector<P> convex_hull(P* ps, int n) {
	sort(ps, ps + n, cmp_x);
	int k = 0;
	vector<P> qs(n * 2);

	for (int i = 0; i < n; i++) {
		while (k > 1 && (qs[k-1] - qs[k-2]).det(ps[i] - qs[k-1]) <= 0) {
			k--;
		}
		qs[k++] = ps[i];
	}
	for (int i = n-2, t = k; i >= 0; i--) {
		while (k > t && (qs[k-1] - qs[k-2]).det(ps[i] - qs[k-1]) <= 0) {
			k--;
		}
		qs[k++] = ps[i];
	}
	qs.resize(k-1);
	return qs;
}

P ps[10];

int main() {
	int n;
	cin >> n;
	for (int i = 0; i < n; i++) {
		P pp, qq;
		P psp[3];
		cin >> psp[0].x >> psp[0].y >> psp[1].x >> psp[1].y >> psp[2].x >> psp[2].y >> pp.x >> pp.y >> qq.x >> qq.y;
		for (int j = 0; j < 3; j++) {
			ps[j] = psp[j];
		}
		ps[3] = pp;
		vector<P> qs = convex_hull(ps, 4);
		bool hantei;
		if (qs.size() == 4) {
			hantei = false;
		} else {
			hantei = true;
			for (int j = 0; j < 3; j++) {
				if (qs[j].x == pp.x && qs[j].y == pp.y) {
					hantei = false;
					break;
				}
			}
		}
		for (int j = 0; j < 3; j++) {
			ps[j] = psp[j];
		}
		ps[3] = qq;
		qs = convex_hull(ps, 4);
		bool hantei2;
		if (qs.size() == 4) {
			hantei2 = false;
		} else {
			hantei2 = true;
			for (int j = 0; j < 3; j++) {
				if (qs[j].x == qq.x && qs[j].y == qq.y) {
					hantei2 = false;
					break;
				}
			}
		}
		if (hantei == hantei2) {
			cout << "NG" << endl;
		} else {
			cout << "OK" << endl;
		}
	}
	return 0;
}

Measured memory_bytes: 1232
s = input()
a = s[0:1]
b = s[1:2]
c = s[2:3]
ans = 0
if a == 'R' and b == 'R' and c == 'R':
  ans = 3
elif (a=='R' and b=='R') or (b=='R' and c=='R'):
  ans = 2
elif a=='R' or b=='R' or c=='R':
  ans = 1
print(ans)

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

using Cell = pair<int, int>;

int main() {
  vector<Cell> cs(9);
  for(int i = 0; i < 9; ++i) {
    cin >> cs[i].first;
    cs[i].second = 0;
  }
  int N;
  cin >> N;
  int b;
  for(int i = 0; i < N; ++i) {
    cin >> b;
    for(auto& c : cs) {
      if(c.first == b) {
        c.second++;
      }
    }
  }
  vector<int> nns[] = {{0, 1, 2}, {3, 4, 5}, {6, 7, 8}, {0, 3, 6},
                       {1, 4, 7}, {2, 5, 8}, {0, 4, 8}, {2, 4, 6}};
  for(auto ns : nns) {
    bool bingo = true;
    for(auto n : ns) {
      if(cs[n].second == 0) {
        bingo = false;
      }
    }
    if(bingo) {
      cout << "Yes" << endl;
      return 0;
    }
  }
  cout << "No" << endl;
  return 0;
}


Measured memory_bytes: 256
X, Y, Z, K = map(int, input().split())
A = list(map(int, input().split()))
B = list(map(int, input().split()))
C = list(map(int, input().split()))

A.sort(reverse=True)
B.sort(reverse=True)
C.sort(reverse=True)

result = []
for i in range(X):
    for j in range(Y):
        for k in range(Z):
            if (i + 1) * (j + 1) * (k + 1) <= K:
                result.append(A[i] + B[j] + C[k])
            else:
                break
result.sort(reverse=True)
for rs in result[:K]:
    print(rs)

Measured memory_bytes: 8708
#include <iostream>
#include <math.h>
using namespace std;
int main(void){
    int A,B,C,ans;
    long long K;
    cin >> A >> B >> C >> K;
    
    if(K == 0){
        ans = A - B;
    }
    else if(K % 2 == 1){
        ans = -A + B;
    }
    else if(K % 2 == 0){
        ans = A - B;
    }
    
    if(ans >= pow(10,18)){
        cout << "Unfair" << endl;
        return 0;
    }else{
        cout << ans << endl;
}
}

Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.InputStreamReader;

public class Main {

	final static long MOD = 1000000007;
	public static void main(String[] args) throws Exception {
		// TODO 自動生成されたメソッド・スタブ

		BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
		String W = in.readLine();
		long N = Long.parseLong(W);

		System.out.println(N*N*N);


	}
}


Measured memory_bytes: 22996
#include <bits/stdc++.h>
#pragma GCC optimize("Ofast")
#define int long long
#define rep(val,cnt) for(int (val)=0;(val)<(cnt);++(val))
#define all(v) (v).begin(),(v).end()
using namespace std;

using pint = pair<int,int>;
using tint = tuple<int,int,int>;

void Main(void);
signed main(void){
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  Main();
}

template<typename T>
struct edge{T to,cost;};

template<typename T>
class Graph{
  public :
  vector<vector<edge<T>>> graph;

  void add(int from,T to,int cost){
    graph[from].emplace_back((edge<T>){to,cost});
  }
  T prim(void){
    using Pi = pair<T,int>;
    T total=0;
    vector<bool> used(graph.size(),false);
    priority_queue<Pi,vector<Pi>,greater<Pi>> que;
    que.emplace(0,0);
    while(!que.empty()){
      auto p=que.top(); que.pop();
      if(used[p.second]) continue;
      used[p.second]=true;
      total+=p.first;
      for(auto &e : graph[p.second]) que.emplace(e.cost,e.to);
    }
    return total;
  }
};

void Main(void){
  int N; cin>>N;
  vector<tint> PX,PY;
  rep(i,N){
    int x,y; cin>>x>>y;
    PX.emplace_back(x,y,i),PY.emplace_back(y,x,i);
  }
  sort(all(PX)),sort(all(PY));
  Graph<int> gr; gr.graph.resize(N);
  for(int i=1;i<N;++i){
    int x1,y1,p1,x2,y2,p2,dist;
    tie(x1,y1,p1)=PX[i-1],tie(x2,y2,p2)=PX[i];
    dist=min(abs(x1-x2),abs(y1-y2));
    gr.add(p1,p2,dist),gr.add(p2,p1,dist);
    tie(x1,y1,p1)=PY[i-1],tie(x2,y2,p2)=PY[i];
    dist=min(abs(x1-x2),abs(y1-y2));
    gr.add(p1,p2,dist),gr.add(p2,p1,dist);
  }
  cout<<gr.prim()<<endl;
}

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

using namespace std;

int partition(vector<int> &int_array,const int r){
    int x = int_array[r];
    vector<int>::iterator itr_i = int_array.begin();
    int counter = 0;
    for(vector<int>::iterator itr_j = int_array.begin();itr_j != int_array.end();itr_j++){
        if(*itr_j <= x){
            swap(*itr_j,*itr_i);
            itr_i++;
            counter++;
        } 
    }
    return counter;
}

int main(){
    int len_array;
    int temp,max_val = 0;
    scanf("%d",&len_array);
    
    vector<int> int_array(len_array,0);
    
    for(int i = 0;i < len_array;i++){
        scanf("%d",&temp);
        int_array[i] = temp;
    }
    int r = (int)int_array.size() -1;
    int x = int_array[r];
    int q = partition(int_array,r)-1;
    for(int i = 0;i < len_array;i++){
        if(i == q) printf("[%d]",int_array[i]);
        else printf("%d",int_array[i]);
        if(i < len_array-1) printf(" ");
        else printf("\n");
    }
    return 0;   
}



Measured memory_bytes: 3208
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define printVec(v) printf("{"); for (const auto& i : v) { std::cout << i << ", "; } printf("}\n");
#define degreeToRadian(deg) (((deg)/360)*2*M_PI)
#define radianTodegree(rad) (((rad)/2/M_PI)*360)
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; }
using namespace std;
using P = pair<int,int>;
using ll = long long;
const ll INF = 1LL<<60;
const int MOD = 1e9 + 7;
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};

//cin.tie(0);ios::sync_with_stdio(false);
//cout << fixed << setprecision(15) << y << endl;
int main() {
  int n; cin >> n;
  vector<int> b(n - 1);
  vector<int> a(n);
  rep (i, n - 1) cin >> b[i];

  int sum = 0;
  rep (i, n - 2) {
    sum += min(b[i], b[i + 1]);
  }
  sum += b[0] + b.back();

  cout << sum << endl;
  return 0;
}


Measured memory_bytes: 3584
#include <stdio.h>
#define N 100
#define WHITE 0
#define GRAY 1
#define BLACK 2

int n, M[N][N];
int color[N], d[N], f[N], tt;

void kaneko(int u) {
  int v;
  color[u] = GRAY;
  d[u] = ++tt;
  for (v = 0; v < n; v++) {
    if (M[u][v] == 0) {
      continue;
    }
    if (color[v] == WHITE) {
      kaneko(v);
    }
  }
  color[u] = BLACK;
  f[u] = ++tt;
}

void emiko() {
  int u;
  
  for (u = 0; u < n; u++) {
    color[u] = WHITE;
  }
  tt = 0;
  
  for (u = 0; u < n; u++) {
    if (color[u] == WHITE) {
      kaneko(u);
    }
  }
  for (u = 0; u < n; u++) {
    printf("%d %d %d\n", u + 1, d[u], f[u]);
  }
}

int main() {
  int u, v, k, i, j;
  
  scanf("%d", &n);
  for (i = 0; i < n; i++) {
    for (j = 0; j < n; j++) {
      M[i][j] = 0;
    }
  }
  
  for (i = 0; i < n; i++) {
    scanf("%d %d", &u, &k);
    u--;
    for (j = 0; j < k; j++) {
      scanf("%d", &v);
      v--;
      M[u][v] = 1;
    }
  }
  
  emiko();
  
  return 0;
}



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

int main(){
	int a,b,c,d,p;
	cin>>a;
	cin>>b;
	cin>>c;
	cin>>d;
	cin>>p;

	int x = p * a;
	int y = (p < c) ? b : (b + d * (p-c));

	cout<<min(x,y)<<endl;
}

Measured memory_bytes: 1160
#include<bits/stdc++.h>
#define _GLIBCXX_DEBUG
#define rep(i, n) for(int i = 0; i < (n); ++i)
using namespace std;
typedef long long ll;
template<class T> istream& operator >> (istream& s, vector<T>& v)
{ for (T& x: v) { s >> x; } return s;}

int main(){
    int a,b,k; cin >> a >> b >> k;
    for(int i = min(a,b); i >= 1; i--){
        if(a % i == 0 && b % i == 0) k--;
        if(k == 0){
            cout << i << endl;
            break;
        }
    }
    return 0;
}


Measured memory_bytes: 256
import math

a, b, h, m = map(float, input().split())
da = 0
db = 0

db = float(6) * m
da = float(30) * h + m / float(2)

sa = abs(da - db)
if sa >= float(180):
    sa = float(360) - sa

rad = math.cos(math.radians(sa))

ans = math.sqrt(a**2 +b**2 -2*a*b*rad)
print(ans)

Measured memory_bytes: 9420
n = int(input())
nums = list(map(int, input().split()))

count = 0
for i in range(n):
    minj = i
    for j in range(i+1, n):
        if nums[minj] > nums[j]:
            minj = j
    if minj != i:
        nums[minj], nums[i] = nums[i], nums[minj]
        count += 1
print(' '.join(map(str, nums)))
print(count)


Measured memory_bytes: 5600
n = int(input())
for i in range(n):
    order = str(input())
    mes = str(input())
    l = len(mes)

    for p in reversed(order):
        if p == "J":
            mes = mes[-1] + mes[:-1]

        elif p == "C":
            mes = mes[1:] + mes[0]

        elif p == "E":
            if l % 2 == 0:
                mes = mes[l // 2:] + mes[:l // 2]
            else:
                mes = mes[(l + 1) // 2:] + mes[(l - 1) // 2] + mes[:(l - 1) // 2]

        elif p == "A":
            mes = mes[::-1]

        elif  p == "P":
            mes_li = list(mes)
            for itr, c in enumerate(mes_li):
                if c.isdigit():
                    mes_li[itr] = str((int(c) + 9) % 10)
            mes = "".join(mes_li)

        elif p == "M":
            mes_li = list(mes)
            for itr, c in enumerate(mes_li):
                if c.isdigit():
                    mes_li[itr] = str((int(c) + 1) % 10)
            mes = "".join(mes_li)

    print(mes)


Measured memory_bytes: 5608
def main():
    n, k = map(int, input().split())
    a = list(map(int, input().split()))

    cum_all = [0 for _ in range(n+1)]
    cum_positive = [0 for _ in range(n+1)]
    for i in range(n):
        cum_all[i+1] = cum_all[i] + a[i]
        cum_positive[i+1] = cum_positive[i] + max(0, a[i])

    ans = 0
    for i in range(n-k+1):
        score1 = (cum_positive[i] - cum_positive[0]) + (cum_positive[n] - cum_positive[i+k])
        if score1 > ans:
            ans = score1
        score2 = (cum_positive[i] - cum_positive[0]) + (cum_all[i+k] - cum_all[i]) + (cum_positive[n] - cum_positive[i+k])
        if score2 > ans:
            ans = score2

    print(ans)

if __name__ == '__main__':
    main()


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

using namespace std;

using ll = long long;
using ld = long double;

const int INF = (1 << 30) - 1;
const ll INF64 = ((ll)1 << 62) - 1;
const double PI = 3.1415926535897932384626433832795;

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

ll solve(string s) {
	ll res = 0;

	int n = s.size();
	for (int i = 0; i < 1 << (n - 1); i++) {
		ll score = 0;
		ll v = s[0] - '0';
		for (int j = 0; j < n - 1; j++) {
			if ((1 & i >> j) == 1) {
				score += v;
				v = s[j + 1] - '0';
				continue;
			}
			v = 10 * v + s[j + 1] - '0';
		}
		score += v;
		res += score;
	}
	return res;
}

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

	string s;
	cin >> s;

	cout << solve(s) << endl;
	return 0;
}


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

using namespace std;
#define ll long long
#define ld long double
#define f first
#define s second

ll x , y , a , b , c;
deque<ll> q , q2 , q3;

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

    cin >> x >> y >> a >> b >> c;

    for(int i=1; i<=a; i++)
    {
        ll xx;
        cin >> xx;
        q.push_back(xx);
    }
    for(int i=1; i<=b; i++)
    {
        ll xx;
        cin >> xx;
        q2.push_back(xx);
    }
    for(int i=1; i<=c; i++)
    {
        ll xx;
        cin >> xx;
        q3.push_back(xx);
    }

    ll ans = 0 , mx=0 , cnt=0 , r=0 , g=0;
    sort(q.begin() , q.end());
    sort(q2.begin() , q2.end());
    sort(q3.begin() , q3.end());
    while(q.size() > x) q.pop_front();
    while(q2.size() > y) q2.pop_front();

    vector<ll> v;
    for(int i=0; i<q.size(); i++)
        ans += q[i] , v.push_back(q[i]);
    for(int i=0; i<q2.size(); i++)
        ans += q2[i] , v.push_back(q2[i]);

    mx = max(mx , ans);

    sort(v.begin() , v.end());
    reverse(v.begin() , v.end());

    while(q3.size())
    {
        if (!v.size()) break;

        ans -= v.back();
        v.pop_back();
        ans += q3.back();
        q3.pop_back();
        mx = max(mx , ans);
    }

    cout << mx << '\n';

    return 0;
}

Measured memory_bytes: 4920
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
#define rep(i,n) for( int i = 0; i < n; i++ )
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define INF 2000000000
#define mod 1000000007
#define INF2 1000000000000000000


int main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N;
    cin >> N;
    int A[4];
    rep(i, 4) {
        A[3-i] = N % 10;
        N /= 10;
    }
    rep(i, 8) {
        int tmp = i + 1;
        int ans = A[0];
        if (tmp % 2 == 0) ans += A[1];
        else ans -= A[1];
        tmp /= 2;
        if (tmp % 2 == 0) ans += A[2];
        else ans -= A[2];
        tmp /= 2;
        if (tmp % 2 == 0) ans += A[3];
        else ans -= A[3];

        if (ans == 7) {
                    tmp = i+1;
            cout << A[0];
            if (tmp % 2 == 0) cout << "+";
            else cout << "-";
            tmp /= 2;
            cout << A[1];
            if (tmp % 2 == 0) cout << "+";
            else cout << "-";
            tmp /= 2;
                        cout << A[2];
            if (tmp % 2 == 0) cout << "+";
            else cout << "-";
            cout << A[3] << "=7" << endl;
            return 0;
        }
    }

    return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include <cassert>
#include <iostream>
#include <vector>
#include <set>
#include <cstdio>
#include <complex>
#include <cstring>

using namespace std;

const int N = 100000 + 5;

int n;
vector<int> adj[N];
set<int> s[N];

set<int>& dfs(int u, int f)
{
    set<int> &have = s[u];
    int a = -1;

    for(auto v: adj[u]) {
        if (v == f) continue;
        set<int> &f = dfs(v, u);
        if (have.size() < f.size()) {
            have.swap(f);
        }
        for(auto e: f) {
            if (have.count(e)) {
                a = max(a, e);
            } else {
                have.insert(e);
            }
        }
    }

    int b = a + 1;
    for( ; have.count(b); b++);
    for( ; have.size() && *have.begin() <= b; have.erase(have.begin()));
    have.insert(b);
    return s[u];
}

void solve()
{
    cin >> n;
    for(int i = 0; i < n - 1; ++ i) {
        int u, v;
        cin >> u >> v;
        --u, --v;
        adj[u].push_back(v);
        adj[v].push_back(u);
    }
    set<int> ret = dfs(0, -1);
    int ans = *ret.rbegin();
    cout << ans << endl;
}

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


Measured memory_bytes: 19584
#include <iostream>

using namespace std;
typedef long long ll;

int main(void)
{
    int N, A[200005];

    cin >> N;
    for (int i = 0; i < N; i++) {
        cin >> A[i];
    }
    ll ans = 0;
    for (int i = 0; i < N; i++) {
        ll d = 0;
        if (i > 0) {
            if (A[i - 1] >= A[i]) {
                d = A[i - 1] - A[i];
                A[i] += d;
            }
        }
        ans += d;
    }
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 4336
package main

import (
	"bufio"
	"fmt"
	"io"
	"log"
	"os"
	"sort"
	"strconv"
)

var n = int(1e5)
var k int
var runs = make([]int, 0, 2*n)
var m = make(map[int]struct{}, 2*n)

func main() {
	k = readInt()

	for i := 1; i < 10; i++ {
		runs = append(runs, i)
	}

	for len(runs) < k {
		for i := range runs {
			pre := runs[i] % 10
			for j := max(0, pre-1); j <= min(9, pre+1); j++ {
				new := runs[i]*10 + j
				if _, ok := m[new]; ok {
					continue
				}
				runs = append(runs, new)
				m[new] = struct{}{}
			}
		}
	}

	sort.Ints(runs)

	// for i := range runs {
	// 	fmt.Println(runs[i])
	// }

	fmt.Println(runs[k-1])
}

// sort ------------------------------------------------------------

type xxx struct {
	x int
}

type sortArray []xxx

func (s sortArray) Len() int           { return len(s) }
func (s sortArray) Swap(i, j int)      { s[i], s[j] = s[j], s[i] }
func (s sortArray) Less(i, j int) bool { return s[i].x < s[j].x }

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

var (
	readString func() string
	readBytes  func() []byte
)

func init() {
	log.SetFlags(log.Lshortfile)
	readString, readBytes = newReadString(os.Stdin)
}

func newReadString(ior io.Reader) (func() string, func() []byte) {
	r := bufio.NewScanner(ior)
	r.Buffer(make([]byte, 1024), int(1e+11))
	r.Split(bufio.ScanWords)

	f1 := func() string {
		if !r.Scan() {
			panic("Scan failed")
		}
		return r.Text()
	}
	f2 := func() []byte {
		if !r.Scan() {
			panic("Scan failed")
		}
		return r.Bytes()
	}
	return f1, f2
}

func readInt() int {
	return int(readInt64())
}

func readInt64() int64 {
	i, err := strconv.ParseInt(readString(), 10, 64)
	if err != nil {
		panic(err.Error())
	}
	return i
}

func readFloat64() float64 {
	f, err := strconv.ParseFloat(readString(), 64)
	if err != nil {
		panic(err.Error())
	}
	return f
}

func min(a, b int) int {
	if a < b {
		return a
	}
	return b
}

func max(a, b int) int {
	if a > b {
		return a
	}
	return b
}

func abs(a int) int {
	if a < 0 {
		return -a
	}
	return a
}

func sum(a []int) int {
	var ret int
	for i := range a {
		ret += a[i]
	}
	return ret
}

func sumFloat64(a []float64) float64 {
	var ret float64
	for i := range a {
		ret += a[i]
	}
	return ret
}

func gcd(m, n int) int {
	for m%n != 0 {
		m, n = n, m%n
	}
	return n
}

func lcm(m, n int) int {
	return m / gcd(m, n) * n
}


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

using namespace std;

typedef long long ll;
typedef long double ld;
const ll INF = 1e10;
const ld eps = 1e-9, pi = acos(-1.0);
typedef pair<ll, ll> P;
typedef tuple<ll, ll, ll> T;

int main(){
  ll N, M;
  cin >> N >> M;
  vector<vector<ll> > edge(N, vector<ll>(0));
  for(int i=0;i<M;i++){
    ll a, b;
    cin >> a >> b;
    a--; b--;
    edge[a].push_back(b);
    edge[b].push_back(a);
  }
  ll Q;
  cin >> Q;
  vector<vector<T> > tmp(11);
  vector<T> state(N);
  for(int i=0;i<Q;i++){
    ll v, d, c;
    cin >> v >> d >> c;
    v--;
    //state[v] = T(i, d, c);
    tmp[d].push_back(T(i, v, c));
    //cout << d << endl;
  }
  //cout << tmp[0].size() << endl;
  /*for(int i=0;i<N;i++){
    ll v,d,c;
    tie(v, d, c) = state[i];
    cout << "v:" << v << " d:" << d << " c:" << c << endl;
  }
  cout << endl;*/
  for(int i=10;i>=1;i--){
    vector<T> nstate(N, T(-1, 0, 0));
    for(int j=0;j<tmp[i].size();j++){
      ll app, v, c;
      tie(app, v, c) = tmp[i][j];
      state[v] = max(state[v],  T(app, i, c));
    }
    for(int see=0;see<N;see++){
      T now = T(-1, 0, 0);
      for(auto &&next : edge[see]){
	if(get<1>(state[next]) == i)
	  now = max(now, state[next]);
      }
      ll v, d, c;
      tie(v, d, c) = now;
      d--;
      if(d == i-1)
	nstate[see] = max(state[see], T(v, d, c));
      else
	nstate[see] = state[see];
    }
    state = nstate;
    /*for(int i=0;i<N;i++){
      ll v,d,c;
      tie(v, d, c) = state[i];
      cout << "v:" << v << " d:" << d << " c:" << c << endl;
    }
    cout << endl;*/
  }
  for(int j=0;j<tmp[0].size();j++){
    ll app, v, c;
    //cout << j << endl;
    tie(app, v, c) = tmp[0][j];
    state[v] = max(state[v],  T(app, 0, c));
  }
  for(int i=0;i<N;i++)
    cout << get<2>(state[i]) << endl;
  return 0;
}


Measured memory_bytes: 15436
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> pll;
#define fi first
#define se second
const int maxn=105;
const int mod=1e9+7;
const int inf=0x3f3f3f3f;
int n,h[maxn];
inline ll fpow(ll a,ll b)
{
	ll ret=1;
	for(;b;b>>=1,a=a*a%mod)
		if(b&1) ret=ret*a%mod;
	return ret;
}
inline pll solve(int l,int r,int k)
{
	int mn=inf,cnt=0;
	for(int i=l;i<=r;i++)
		if(h[i]<mn) mn=h[i],cnt=1;
		else if(h[i]==mn) cnt++;
	if(cnt==r-l+1) return pll(fpow(2,r-l+1)-2,fpow(2,mn-k));
	int last=0; ll s0=1,s1=1; pll ret=pll(0,0);
	for(int i=l;i<=r+1;i++)
		if(!last && h[i]>mn) last=i;
		else if((i>r || h[i]==mn) && last)
		{
			pll tmp=solve(last,i-1,mn);
			(s0*=(tmp.fi+2*tmp.se))%=mod;
			(s1*=tmp.se)%=mod;
			last=0;
		}
	(s0-=s1)%=mod;
	ret.fi=(s0*fpow(2,cnt)+s1*(fpow(2,cnt)-2))%mod;
	ret.se=s1*fpow(2,mn-k)%mod;
	return ret;
}
int main()
{
	scanf("%d",&n);
	for(int i=1;i<=n;i++) scanf("%d",&h[i]);
	ll ans=1;
	for(int i=1;i<=n;i++)
		if(h[i]>h[i-1] && h[i]>h[i+1])
			(ans*=fpow(2,h[i]-max(h[i-1],h[i+1])))%=mod,h[i]=max(h[i-1],h[i+1]);
	pll ret=solve(1,n,0);
	printf("%lld\n",(ans*(ret.fi+ret.se)%mod+mod)%mod);	
	return 0;
}

Measured memory_bytes: 3840
L, R = map(int, input().split())

if (R - L) >= 2019:
    print(0)
else:
    ans = 2019
    for i in range(L, R):
        for j in range((i + 1), (R + 1)):
            ans = min(ans, ((i * j) % 2019))
    print(ans)

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

#define REP(i, n) for (int i = 0; i < (int)(n); i++)
#define REPl(i, n) for (ll i = 0; i < (ll)(n); i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define REPRl(i, n) for(ll i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < (int)n; i++)
#define FORl(i, m, n) for(ll i = m; i < (ll)n; i++)
#define ALL(v) v.begin(), v.end()
ll gcd(ll a,ll b) {
  return b? gcd(b,a%b): a;  
}
ll lcm(ll a,ll b) {
  return a*b/gcd(a,b);
}
int main() {
  vector<int> a(5);
  REP(i,5){
    cin>>a[i];
  }
  int min=10;
  int sum=0;
  REP(i,5){
    int lowest=a[i]%10;
    if(lowest!=0 && lowest<min){
      min=lowest;
    }
    int tmp=(lowest==0?a[i]:((a[i]/10+1)*10));
    sum+=tmp;
  }
  sum-=(10-min);
  cout << sum << endl;
}


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

using namespace std;
using ll = long long;

int main() {
  string s;
  cin >> s;
  int r;
    if(s == "SUN")
      r = 7;
      
    if(s == "MON")
      r = 6;
      
    if(s == "TUE")
      r = 5;
      
    if(s == "WED")
      r = 4;

    if(s == "THU")
      r = 3;

    if(s == "FRI")
      r = 2;

    if(s == "SAT")
      r = 1;


  cout << r;

}


Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<queue>
#include<algorithm>
#include<map>
#include<set>
#include<vector>
#include<math.h>
#include<time.h>

using namespace std;

#define INF 1000000007
#define LINF (1LL << 62)

typedef long long i64;
typedef pair<i64,i64> P;


i64 n, a[202020];

i64 mod_pow(i64 x, i64 y, i64 mod){
	i64 res = 1;
	while(y > 0){
		if(y & 1) res = res * x % mod;
		x = x*x %mod;
		y >>= 1;
	}
	return res;
}

const int MAX = 101010, MOD = INF;
long long fac[MAX], finv[MAX], inv[MAX];
// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}
// 二項係数計算
long long C(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

int main(){
	cin >> n;
	for(int i = 0; i < n; i++){
		cin >> a[i];
	}
	
	sort(a,a+n, greater<i64>());
	
	COMinit();
	
	i64 ans = 0;
	for(int i = 0; i < n; i++){
		ans += a[i] * (i+2);
		ans %= INF;
	}
	ans = ans * mod_pow(4,n-1,INF) % INF;
	cout << ans << endl;
	
	return 0;
}

Measured memory_bytes: 4224
N = int(input())
a = list(map(int,input().split(" ")))
b = list(map(int,input().split(" ")))

dif = sum(b) - sum(a)

if dif < 0:
	print("No")
	exit(0)

count = 0
for i in range(N):
	if (a[i] % 2) != (b[i] % 2):
		b[i] += 1
		count += 1
	
	if b[i] < a[i]:
		count += (a[i] - b[i])

if count > dif:
	print("No")
	exit(0)

if ((dif - count) % 2) == 0:
	print("Yes")
else:
	print("No")


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

int main()
{
	int N;
	scanf("%d", &N);
	int a[N];
	int r;
	
	for(r=0; r<N; r++){
		scanf("%d", &a[r]);
	}
	
	int c = 0;
	
	for(r=0; r<N; r++){
		if(a[r] == c+1){
			c++;
		}
	}
	
	if(c==0) printf("-1"); 
	else printf("%d",N-c);
	
	
	return 0;
}

Measured memory_bytes: 896
def is_ok(k):
    imos = [0] * (len(s) + 2)

    for i, x in enumerate(s, 1):
        imos[i] ^= imos[i - 1]
        if i <= len(s) - (k - 1):
            # 連続kの区間をi起点に取ることができる
            if x ^ imos[i - 1]:
                imos[i] ^= 1
                imos[i + k] ^= 1
        else:
            if x ^ imos[i - 1]:
                return i > k
    return True


def binary_search():
    ok = 1
    ng = len(s) + 1
    while abs(ng - ok) > 1:
        mid = (ng + ok) // 2
        if is_ok(mid):
            ok = mid
        else:
            ng = mid
    return ok


s = tuple(map(int, input()))
print(binary_search())

# Kで達成できるとき、K未満で達成できる
# TTTTFFF
#    ^
#    K
# 二分探索する


Measured memory_bytes: 4768
s=input()
l=len(s)
arr1=[0]
cnt=0
for i in range(l):
  if s[i]=='<':
    cnt+=1
  else:
    cnt=0
  arr1.append(cnt)
arr2=[0]
cnt=0
for i in range(l-1,-1,-1):
  if s[i]=='>':
    cnt+=1
  else:
    cnt=0
  arr2.append(cnt)
arr2=arr2[::-1]
ans=0
for i in range(l+1):
  ans+=max(arr1[i],arr2[i])
print(ans)

Measured memory_bytes: 31904
import java.util.*;

public class Main {

  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    String[] firstInput = sc.nextLine().split("[\\s]+");
    long N = Integer.parseInt(firstInput[0]);
    if(N % 2 == 0) {
      System.out.println(N);
    } else {
      System.out.println(N * 2);
    }
  }
}


Measured memory_bytes: 24276
// AOJ Volume2 0281 Formation

#include <stdio.h>

int main(void)
{
	int q;
	int c, a, n;
	int i;
	int team;
	int t;
	
	scanf("%d", &q);
	for (i = 0; i < q; i++){
		scanf("%d%d%d", &c, &a, &n);

		// CAN
		t = c;
		if (t > a){
			t = a;
		}
		if (t > n){
			t = n;
		}
		
		team = t;
		c -= t;
		a -= t;
		n -= t;
		
		// CCA
		if (c / 2 < a){
			t = c / 2;
		}
		else {
			t = a;
		}
		team += t;
		c -= (t * 2);
		a -= t;

		// CCC
		team += (c / 3);
		
		printf("%d\n", team);
	}
	
	return (0);
}

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

#define pb push_back
#define ppp pop_back
#define pii pair<int,int>
#define fi first
#define se second

const int N = 1e5 + 5;

int h[N], dp[N];

int main() {
    ios_base::sync_with_stdio(0); cin.tie(0);
#ifdef LOCAL
    freopen("input.txt", "r", stdin);
#endif
    int n;
    cin >> n;
    for (int i=1; i<=n; i++) cin >> h[i];
    dp[1] = 0;
    dp[2] = abs(h[2] - h[1]);
    for (int i=3; i<=n; i++) {
        dp[i] = min(dp[i-1] + abs(h[i] - h[i-1]), dp[i-2] + abs(h[i] - h[i-2]));
    }
    cout << dp[n] << "\n";
    return 0;
}


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

using namespace std;
using ll = long long;
using ull = unsigned long long;
using P = pair<int,int>;
#define rep(i,n) for(ll i = 0;i < (ll)n;i++)
#define ALL(x) (x).begin(),(x).end()
#define MOD 1000000007

struct subs{
  int a,b,c;
};

int main(){
  
  int n,Ma,Mb;
  cin >> n >> Ma >> Mb;
  vector<subs> v(n);
  rep(i,n)cin >> v[i].a >> v[i].b >> v[i].c;
  set<P> st;
  vector<pair<int,int>> w;
  int res = 1e9;
  for(int bit = 0;bit < (1 << (n/2));bit++){
    int a = 0,b = 0,c = 0;
    rep(i,n/2)if(bit >> i & 1)a += v[i].a,b += v[i].b,c += v[i].c;
    w.push_back(make_pair(a*Mb-b*Ma,c));
    if(a*Mb == b*Ma && a != 0)res = min(res,c);
  }
  for(int bit = 1;bit < (1 << (n-(n/2)));bit++){
    int a = 0,b = 0,c = 0;
    rep(i,(n-(n/2)))if(bit >> i & 1)a += v[i+n/2].a,b += v[i+n/2].b,c += v[i+n/2].c;
    st.insert(make_pair(-a*Mb+b*Ma,c));
  }
  for(auto au : w){
    auto iter = st.lower_bound(make_pair(au.first,0));
    if(iter != st.end() && (*iter).first == au.first)res = min(res,au.second+(*iter).second);
  }
  if(res != (int)1e9)cout << res << endl;
  else cout << -1 << endl;

  



  return 0;
}

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

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

typedef pair<int, int> pi;

int h, w, s, all, u[33][33], sum[33][33];
pi memo[33][33][33][33];

pi dp(int ax, int ay, int bx, int by)
{
    pi &best = memo[ay][ax][by][bx];
    if (best.first != -1) return best;
    int ss = sum[by][bx] - sum[ay][bx] - sum[by][ax] + sum[ay][ax];
    best = pi(1, ss);
    reps (x, ax + 1, bx) {
        pi p = dp(ax, ay, x, by);
        pi q = dp(x, ay, bx, by);
        int m = all - p.second;
        int n = all - q.second;
        if (m > s || n > s) continue;
        best = max(best, pi(p.first + q.first, min(p.second, q.second)));
    }
    reps (y, ay + 1, by) {
        pi p = dp(ax, ay, bx, y);
        pi q = dp(ax, y, bx, by);
        int m = all - p.second;
        int n = all - q.second;
        if (m > s || n > s) continue;
        best = max(best, pi(p.first + q.first, min(p.second, q.second)));
    }
    return best;
}

int main()
{
    while (cin >> h >> w >> s, h) {
        rep (i, h) rep (j, w) cin >> u[i][j];
        fill_n(*sum, 33*33, 0);
        fill_n(***memo, 33*33*33*33, pi(-1, -1));
        rep (i, h) rep (j, w)
            sum[i+1][j+1] = sum[i+1][j] + sum[i][j+1] - sum[i][j] + u[i][j];
        all = sum[h][w];
        pi ans = dp(0, 0, w, h);
        cout << ans.first << " " << s + ans.second - all << endl;
    }
}

Measured memory_bytes: 10444
import java.util.*;
public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int X[] = new int[3];
		for(int i=0;i<3;i++)X[i]=sc.nextInt();
		Arrays.sort(X);
		int ans = X[2]*10+X[1]+X[0];
		System.out.println(ans);
	}
}


Measured memory_bytes: 23892
#include <iostream>
#include <iomanip>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <algorithm>
#include <math.h>
#include <sstream>
#include <numeric>
#include <string>
#include <cassert>
#include <bitset>

using namespace std;
typedef long long ll;

int main() {
  int X, Y, A, B, C;
  cin >> X >> Y >> A >> B >> C;
  vector<pair<ll, int> > vp;
  for (int i = 0; i < A; ++i) {
    ll value;
    cin >> value;
    vp.push_back(make_pair(value, 1));
  }
  for (int i = 0; i < B; ++i) {
    ll value;
    cin >> value;
    vp.push_back(make_pair(value, 2));
  }
  for (int i = 0; i < C; ++i) {
    ll value;
    cin >> value;
    vp.push_back(make_pair(value, 0));
  }
  sort(vp.begin(), vp.end());
  reverse(vp.begin(), vp.end());

  ll tot_val = 0;
  int c1 = 0;
  int c2 = 0;
  int eaten = 0;
  for (int i = 0; i < A + B + C; ++i) {
    ll val = vp[i].first;
    int col = vp[i].second;
    if (col == 1) {
      if (c1 < X) {
	tot_val += val;
	++c1;
	++eaten;
      }
    } else if (col == 2) {
      if (c2 < Y) {
	tot_val += val;
	++c2;
	++eaten;
      }
    } else {
      tot_val += val;
      ++eaten;
    }
    if (eaten == X + Y) break;
  }
  cout << tot_val << endl;
  return 0;
}


Measured memory_bytes: 10348
#include<iostream>
#include<algorithm>
#include<string>
#include<vector>
#include<queue>
#include<map>
#include<math.h>
#include<numeric>
#include<utility>
#include<unordered_map> //hash map
#include<cstring>

#define rep(i,a,n) for(int (i)=(a);(i)<(n);(i)++)
#define rrep(i,a,n) for(int (i)=(a);(i)>=(n);(i)--)

#define INF 1000000000
#define MOD 1000000007

typedef  long long ll;

using namespace std;

template<class T> inline bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}

template<class T> inline bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}

double euclid_distance(double a,double b){
    return sqrt(a*a+b*b);
}

ll gcd(ll  a,ll b){
    ll r;
    if(a < b){
        ll tmp;
        tmp = a;
        a = b;
        b = tmp;
    }
    while(r = a % b){
        a = b;
        b = r;
    }
    return b;
}
/*
ll Integer_factorization(ll n){
    ll num = 0;
    ll ndash = n;
    if(n == 1) return 1;
    ll a = 2;
    while(ndash >= a*a){
        if(n % a  == 0){
            count++;
            n/=a;

        if(count % b == 0){
            ans *= a;
        }
        }else{a++;count = 0;}
    }

    return num;
}
*/

ll r_fuct[2000];
ll fuct[2000];

//MOD逆元
void conb(ll n,ll k){
    fuct[0] = 1;
    for(int i = 1;i < k+1;i++){
        fuct[i] *= fuct[i-1]%MOD;
        
        ll b = MOD, u = 1, v = 0;
        ll value = fuct[i];
        while (b) {
            ll t = value / b;
            value -= t * b;
            swap(value, b);
            u -= t * v;
            swap(u, v);
        }
        u %= MOD;
        if (u < 0) u += MOD;
        r_fuct[i] = u;
    }
}

ll factrial(ll n){
    if(n == 0) return 1;
    ll p = factrial(n-1)*n%MOD;
    return p;
}

//MOD逆元
ll farmat(ll n,ll p){    
    if(p == 0) return 1;
    else if(p == 1) return n%MOD;
    ll d = farmat(n,p/2);
    if(p%2 == 0){
        return (d*d)%MOD;
    }else{
        return ((n*d)%MOD*d)%MOD;
    }
}

ll conbination(ll n,ll k){
    ll a = factrial(n);
    ll b = factrial(k);
    ll c = factrial(n-k);
    return (a*farmat(b,MOD-2)%MOD*farmat(c,MOD-2))%MOD;
}

int memo[10000000];

int fib(int i){
    if(i <= 1) return i;
    if(memo[i] != 0) return memo[i];
    return memo[i] = fib(i-1)+fib(i-2);
}

ll dig(ll n){
    ll d = 0;
    while(n != 0){
        n/=10;
        d++;
    }
    return d;
}

void solve() {
    int s;
    cin >> s;
    int count = 0;
    vector<int> p;
    bool flag = true;
    while(flag){
        count++;
        p.push_back(s); 
        if(s%2 == 1) s = s*3+1;
        else s/=2;
        for(int i = 0;i < p.size();i++){
            for(int j = i+1;j < p.size();j++){
                if(p[i] == p[j]) flag = false;
            }
        }

    }
    cout << count << endl;

    
}




int main() {

	cin.tie(0);
	ios::sync_with_stdio(false);
	solve();
	return 0;
}



Measured memory_bytes: 256
# -*- coding: utf-8 -*-
import sys
N=int(sys.stdin.readline().strip())
A=map(int, sys.stdin.readline().split())
A_max=max(A)
A_max_idx=A.index(A_max)    #0-indexed
A_min=min(A)
A_min_idx=A.index(A_min)    #0-indexed

if 0<=A_min:    #Aの最小値が0以上である場合、累積和を構成すれば良い
    print N-1
    for i in range(1,N):
        print i,i+1
else:    #Aの最小値が0より小さい場合
    if 0<=A_max:
        if abs(A_min)<=abs(A_max):  #絶対を取った時にA_maxがA_min以上
            print 2*N-1
            for i in range(1,N+1):  #A_maxを配列Aの全ての値にそれぞれ足していく
                print A_max_idx+1,i
            for i in range(1,N):    #その後に累積和を取れば良い
                print i,i+1
        elif abs(A_min)>abs(A_max):  #絶対を取った時にA_minがA_max以上
            print 2*N-1
            for i in range(1,N+1):  #A_minを配列Aの全ての値にそれぞれ足していって、aを全て負の数にする
                print A_min_idx+1,i
            for i in range(N,1,-1): #後ろから累積和
                print i,i-1
    elif A_max<0:   #aの値が全部負なので、後ろから累積和を取ればよい
        print N-1
        for i in range(N,1,-1): #後ろから累積和
            print i,i-1

Measured memory_bytes: 28652
#include <bits/stdc++.h>
using namespace std;
#define IOS ios_base::sync_with_stdio(false);cin.tie(0)
#define endl "\n";
#define pb push_back
#define ff first   
#define ss second
#define all(a) a.begin(),a.end()
#define int long long
const int MOD=1e9+7;
const int N=3e5+10;
int32_t main()
{
	IOS;
	int n;
	cin>>n;
	cout<<n*(n-1)/2<<endl;
	
	
	

}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;

namespace ConsoleApp
{
    class Program
    {
        static void Main(string[] args)
        {
            var input1 = Console.ReadLine().Split().Select(int.Parse).ToList();
            var M = input1[1];

            var ansList = new List<Answer>();
            for (int i = 0; i < M; i++)
            {
                var input2 = Console.ReadLine().Split();
                ansList.Add(new Answer() { No = int.Parse(input2[0]), Result = input2[1] });
            }
            ansList.Reverse();

            var dict = new Dictionary<int, int>(); //acNo →waCount

            foreach (var ans in ansList)
            {
                if (ans.IsAc())
                {
                    if (dict.ContainsKey(ans.No))
                    {
                        dict[ans.No] = 0;
                    }
                    else
                    {
                        dict.Add(ans.No, 0);
                    }
                }
                else if (ans.IsWa())
                {
                    if (dict.ContainsKey(ans.No))
                    {
                        dict[ans.No] += 1;
                    }
                }
            }

            Console.WriteLine(string.Join(" ", dict.Keys.Count, dict.Values.Sum()));
        }
    }

    class Answer
    {
        public int No { get; set; }
        public string Result { get; set; }
        public bool IsAc() { return Result == "AC"; }
        public bool IsWa() { return Result == "WA"; }
    }
}


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

int main() {
  int N, M, X;
  cin >> N >> M >> X;
  
  int C[N];
  int A[N][M];
  for (int i = 0; i < N; i++) {
    cin >> C[i];
    for (int j = 0; j < M; j++) {
      cin >> A[i][j];
    }
  }
  

  int ans = -1;
  for (int i = 0; i < (1 << N); i++) {
    int a_sum[M];
    for (int i = 0; i < M; i++) {
      a_sum[i] = 0;
    }
    int sum = 0;
    for (int j = 0; j < N; j++) {
      if ((i>>j) & 1) {
        sum += C[j];
        for (int k = 0; k < M; k++) {
          a_sum[k] += A[j][k];
        }
      }
    }
    
    for (int k = 0; k < M; k++) {
      if (a_sum[k] < X) {
        goto theEnd;
      }
    }
    
    if (ans < 0 || sum < ans) {
      ans = sum;
    }
    
    theEnd:
      continue;
  }
  
  cout << ans << endl;
}

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

#include <iostream>
//#include <algorithm>
// #include <iomanip>
#define ll long long
#define map unordered_map
#define set unordered_set

using namespace std;

const ll MOD = 1000000007;
const ll INF = (1LL << 62);

int main() {
  // std::cout << std::fixed << std::setprecision(10);
  ll th, ta, ah, aa;
  scanf("%lld %lld %lld %lld", &th, &ta, &ah, &aa);

  for (;;) {
    ah -= ta;
    if (ah <= 0) {
      cout << "Yes" << endl;
      break;
    }
    th -= aa;
    if (th <= 0) {
      cout << "No" << endl;
      break;
    }
  }
}


Measured memory_bytes: 3764
#include <bits/stdc++.h>
#define sz(v)   ((int)(v).size())
#define  all(v)    ((v).begin()),((v).end())
#define  allr(v)    ((v).rbegin()),((v).rend())
#define   pb         push_back
#define   mp         make_pair
#define  clr(v,val)      memset(v,val,sizeof(v))
#define    lcm(a,b)                ((a*b)/(__gcd(a,b)))
typedef  long long     ll ;
typedef  unsigned long long     ull ;
const double eps= (1e-9);
using namespace std;
int getBit(ll num, int idx) {return ((num >> idx) & 1ll) == 1;}
ll setBit1(ll num, ll idx) {return num | (1ll<<idx);}
ll setBit0(ll num, int idx) {return num & ~(1ll<<idx);}
ll flipBit(ll num, int idx) {return num ^ (1ll<<idx);}
int dcmp(long double a,long double b){   return fabsl(a-b)<=eps ? 0: (a>b)? 1:-1  ;}
void GO(){ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);}
const int N=10000000+5;
ll d[N];
int main(){
    GO();
    int n;
    cin>>n;
    ll ans=0;
    for(int i=1;i<=n;i++){
        for(int j=i;j<=n;j+=i){
            d[j]++;
        }
    }
    for(int i=1;i<=n;i++){
        ans+= 1ll*i*d[i];
    }
    cout<<ans<<"\n";


}

























































































































Measured memory_bytes: 81708
import math

N = int(input())

#dp[i+1]:i円引き出すまでの回数

I = math.floor(math.log(N, 6))
J = math.floor(math.log(N+1, 9))

INF = float('inf')
dp = [INF for n in range(N+1)]
dp[0] = 0

for n in range(N):
    t_min = dp[n] + 1
    for i in range(1,I+1):
        if n+1 < 6**i:
            break
        t_min = min(t_min, dp[n-6**i+1]+1)
    for j in range(1,J+1):
        if n+1 < 9**j:
            break
        t_min = min(t_min, dp[n-9**j+1]+1)
    dp[n+1] = t_min

print(dp[N])

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

int main(){
    int W,H,x,y,r;
    cin >> W >> H >> x >> y >> r;
    if(x-r>=0 && y-r>=0 && x+r<=W && y+r<= H) cout << "Yes\n";
    else cout << "No\n";
}


Measured memory_bytes: 3100
import java.io.*;
import java.util.*;
import static java.lang.System.*;
import static java.lang.Math.*;

public class Main
{
	public static void main(String []args)throws IOException
	{
		BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
		String []s=br.readLine().split(" ");
		int A = Integer.parseInt(s[0]);
		int B = Integer.parseInt(s[1]);
		int C = Integer.parseInt(s[2]);
		
		if((A==B && C!=A) || (A==C && C!=B) || (B==C && C!=A))
			out.println("Yes");
		else
			out.println("No");
	
	}
}




Measured memory_bytes: 23120
private fun readLn() = readLine()!!
private fun readStrings() = readLn().split(" ")
private fun readInt() = readLn().toInt()
private fun readInts() = readStrings().map { it.toInt() }
private fun readLong() = readLn().toLong()
private fun readLongs() = readStrings().map { it.toLong() }
private fun readDouble() = readLn().toDouble()
private fun readDoubles() = readStrings().map { it.toDouble() }

fun main(args: Array<String>) {
        val n= readInt()
        if(n>=30)
            println("Yes")
        else
            println("No")
}

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






void solve()
{
	int n, K;
	cin >> n >> K;
		
	long long r, s, p;
	cin >> r >> s >> p;

	string t;
	cin >> t;

	long long ans = 0;

	for (int i = 0; i < K; i++)
	{
		long long a = 0, b = 0, c = 0;
		for (int k = i; k < n; k += K)
		{
			int ta = 0, tb = 0, tc = 0;

			ta = max(b, c);
			tb = max(a, c);
			tc = max(a, b);

			if (t[k] == 's')
			{
				ta += r;
			}

			if (t[k] == 'p')
			{
				tb += s;
			}

			if (t[k] == 'r')
			{
				tc += p;
			}

			a = ta, b = tb, c = tc;
		}

		long long temp = max(a, max(b, c));
		//cout << temp << "\n";
		ans += temp;
	}

	cout << ans;
}




int main()
{
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	//freopen("file.in", "r", stdin);//freopen("file.out", "w", stdout);

	int t = 1;
	//cin >> t;
	while (t--)
	{
		solve();
	}
	return 0;
}

Measured memory_bytes: 512
#include<iostream>
#include<vector>
#include<bitset>
#include<string>
#include<cmath>
#include<algorithm>
#include<stack>
#include<list>
#include<queue>
#include<map>
#include<numeric>
#include<set>
#include<iterator>
using namespace std;
#define rep(i,x) for(int i=0;i<x;i++)
#define re(i,x,y) for(int i=x;i<y;i++)
int INF=1e9;
const long long mod=1e9+7;
#define ll long long 
int main(){
    string s;
    cin>>s;
    if(s[0]==s[1]&&s[2]==s[3]){
        if(s[0]!=s[2]){
        cout<<"Yes"<<endl;
        }
        else{
            cout<<"No"<<endl;
        }
    }
    else if(s[0]==s[2]&&s[1]==s[3]){
        if(s[0]!=s[1]){
            cout<<"Yes"<<endl;
        }
        else{
            cout<<"No"<<endl;
        }
    }
    else if(s[0]==s[3]&&s[1]==s[2]){
        if(s[0]!=s[1]){
            cout<<"Yes"<<endl;
        }
        else{
            cout<<"No"<<endl;
        }
    }
    else{
        cout<<"No"<<endl;
    }
    return 0;
}

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

#define REP(i, n ,N) for(ll i = (n); i < (N); i++)
#define RREP(i, n ,N) for(ll i = (N-1); i >= (n); i--)
#define p(s) cout<<(s)<<endl
#define p2(a, b) cout<<(a)<<" "<<(b)<<endl
using namespace std;
typedef long long ll;
ll mod = 1e9+7;
ll inf = 1e18;

ll H, N;
ll A[100010];
ll sum;
int main(){
	cin >> H >> N;
	REP(i,0,N){
		cin >> A[i];
		sum += A[i];
	}
	if(H <= sum){
		p("Yes");
	}else{
		p("No");
	}
	return 0;
}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
 
using namespace std;
 
#define rep(i,n) for(int i=0 ; i<(n) ; i++)
#define repr(i,n) for(int i=(n) ; i>=0 ; i--)
#define ALL(x) (x).begin(),(x).end()
 
int GCD(int a,int b){ return b ? GCD(b,a%b) : a ;}
int LCM(int a,int b){ return a*b / GCD(a,b) ;}
 
typedef long long ll;
typedef unsigned long long ull;
 
const int INF = 1e9;

int ans = 0;
ll n;
void dfs(ll now,bool a,bool b,bool c){
      if(now > n)return;
      if(a && b && c)ans++;
      dfs(3+now*10,true,b,c);
      dfs(5+now*10,a,true,c);
      dfs(7+now*10,a,b,true);
}

int main(){
      cin >> n;
      dfs(0,false,false,false);
      cout << ans << endl;
      return 0;
}

Measured memory_bytes: 256