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

using namespace std;

#define LOG(...) fprintf(stderr, __VA_ARGS__)
//#define LOG(...)
#define FOR(i, a, b) for (int i = (int)(a); i < (int)(b); ++i)
#define RFOR(i, a, b) for (int i = (int)(b - 1); i >= (int)(a); --i)
#define REP(i, n) for (int i = 0; i < (int)(n); ++i)
#define RREP(i, n) for (int i = (int)(n - 1); i >= 0; --i)
#define ALL(a) (a).begin(), (a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define EXIST(s, e) ((s).find(e) != (s).end())
#define SORT(c) sort(ALL(c))
#define RSORT(c) sort(RALL(c))
#define SZ(a) ((int)(a).size())
#define BIT(x, i) (((x) >> (i)) & 1)
#define SQ(x) ((x) * (x))

typedef long long ll;
typedef unsigned long long ull;
typedef vector<bool> vb;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<vb> vvb;
typedef vector<vi> vvi;
typedef vector<vll> vvll;
typedef vector<char> vc;
typedef vector<vc> vvc;
typedef vector<string> vs;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

#define INF 1e8

struct Edge {
    int v, cost;
};

struct P {
    int v, cost;
    int life;

    bool operator >(const P& p) const {
        if (cost != p.cost) return cost > p.cost;
        return life > p.life;
    }
};

int main() {
    int town_n, life, freeze_n, road_n, start, goal;
    while (cin >> town_n >> life >> freeze_n >> road_n >> start >> goal, town_n) {
        vector<vector<Edge>> E(town_n);
        vb freeze(town_n);
        REP(i, freeze_n) {
            int a;
            cin >> a;
            freeze[a] = true;
        }
        REP(i, road_n) {
            int a, b, c;
            cin >> a >> b >> c;
            E[a].push_back({b, c});
            E[b].push_back({a, c});
        }

        vvi G(town_n, vi(life+1, INF));
        G[start][life] = 0;

        priority_queue<P, vector<P>, greater<P>> que;
        que.push({start, 0, life});
        while (!que.empty()) {
            P p = que.top(); que.pop();
            if (p.v == goal) {
                cout << p.cost << endl;
                goto END;
            }

            if (G[p.v][p.life] < p.cost) continue;

            for (Edge to : E[p.v]) {
                if (p.life >= to.cost) {
                    int l = p.life - to.cost;
                    REP(i, life+1) {
                        if (freeze[to.v] || i == 0) {
                            if (l+i <= life){
                                int cost = p.cost + to.cost + i;
                                if (G[to.v][l+i] > cost) {
                                    G[to.v][l+i] = cost;
                                    que.push({to.v, cost, l+i});
                                }
                            }
                        }
                    }
                }
            }
        }
        cout << "Help!" << endl;
END: {}
    }
}

Measured memory_bytes: 3244
/+ dub.sdl:
    name "A"
    dependency "dcomp" version=">=0.0.2"
+/

import std.algorithm, std.range, std.stdio, std.math, std.conv, core.bitop;

// import dcomp.scanner;
// import dcomp.algorithm;

int n;
struct Edge {
    int to;
    long dist;
}
Edge[][] g;
long md;

T[N] toS(T, int N)(T[N] data){ return data; }

long[2][] dfs(int p) {
    if (g[p].empty) {
        return [[0L, 0L]];
    }
    Edge le = g[p][0], re = g[p][1];
    auto lt = dfs(le.to);
    auto rt = dfs(re.to);
    if (lt.length > rt.length) {
        swap(le, re);
        swap(lt, rt);
    }
    long ld = le.dist, rd = re.dist;
//    long[2][] ans;
    auto buf = Appender!(long[2][])();
    foreach (co; lt) {
        //co[1] + ld + rd + rco[0] <= md
        int idx = binSearch!((i){return co[1]+ld+rd+rt[i][0] > md;})(-1L, rt.length).to!int-1;
        if (idx == -1) continue;
        buf.put([co[0]+ld, rt[idx][1]+rd].toS);
        buf.put([rt[idx][1]+rd, co[0]+ld].toS);
    }
    auto ans = buf.data;
    sort(ans);
    if (ans.empty) return ans;
    long ma = 10L^^15;
    int co = 0;
    foreach (e; ans) {
        if (ma <= e[1]) continue;
        ma = min(ma, e[1]);
        ans[co] = e;
        co++;
    }
    return ans[0..co];
}

//md以下にできるか？
bool solve(long _md) {
    md = _md;
    return !dfs(0).empty;
}

int main() {
    auto sc = new Scanner();
    int n;
    sc.read(n);
    g = new Edge[][](n);
    foreach (i; 1..n) {
        int a; long b;
        sc.read(a, b); a--;
        g[a] ~= Edge(i, b);
    }

    writeln(binSearch!solve(-1L, 10L^^12));
    return 0;
}
/* IMPORT /Users/yosupo/Program/dcomp/source/dcomp/scanner.d */
// module dcomp.scanner;

class Scanner {
    import std.stdio : File, readln, stdin;
    import std.conv : to;
    import std.range : front, popFront, array, ElementType;
    import std.array : split;
    import std.traits : isSomeString, isDynamicArray;
    import std.algorithm : map;
    File f;
    this(File f = stdin) {
        this.f = f;
    }
    string[] buf;
    bool succ() {
        while (!buf.length) {
            if (f.eof) return false;
            buf = readln.split;
        }
        return true;
    }
    int read(Args...)(auto ref Args args) {
        foreach (i, ref v; args) {
            if (!succ()) return i;
            alias VT = typeof(v);
            static if (!isSomeString!VT && isDynamicArray!VT) {
                v = buf.map!(to!(ElementType!VT)).array;
                buf.length = 0;
            } else {
                v = buf.front.to!VT;
                buf.popFront();
            }
        }
        return args.length;
    }
}
/* IMPORT /Users/yosupo/Program/dcomp/source/dcomp/algorithm.d */
// module dcomp.algorithm;

//[0,0,0,...,1,1,1]で、初めて1となる場所を探す。pred(l) == 0, pred(r) == 1と仮定
T binSearch(alias pred, T)(T l, T r) {
    while (r-l > 1) {
        T md = (l+r)/2;
        if (!pred(md)) l = md;
        else r = md;
    }
    return r;
}


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

#define for_(i,a,b) for(int i=a;i<b;++i)

int main() {
	string s; cin >> s;
	int s_size = s.size();
	for_(i,0,s_size) {
		char si = s[i];
		for_(j,0,3) {
			--si;
			if (si < 'A') si = 'Z';
		}
		s[i] = si;
	}
	cout << s << endl;
	return 0;
}

Measured memory_bytes: 1180
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {

	public static void main(String[] args) throws NumberFormatException, IOException {

		BufferedReader br =
		        new BufferedReader(new InputStreamReader(System.in));

		  int x  = Integer.parseInt(br.readLine());

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

	}

}

Measured memory_bytes: 24220
#include <bits/stdc++.h>
 
#define forn(i, n) for (llong i = 0ll; i < (llong) n; ++i)
#define fornn(i, l, r) for (llong i = (llong) l; i < (llong) r; ++i)
#define size(x) ((int) (x.size()))
 
using namespace std;
 
typedef long long llong;
const llong inf = (llong) 1e+9 + 7ll;
const llong linf = (llong) 1e+18 + 7ll;
const long double eps = (long double) 1e-9;
const long double pi = acosl((long double) -1.0);
const int alph = 26;

mt19937 mrand(random_device{} ()); 

template<typename T, typename U> inline llong umin(const T& a, const U& b) { return a < b ? a : b; }
template<typename T, typename U> inline llong umax(const T& a, const U& b) { return a > b ? a : b; }
 
static char buff[(int) 2e6 + 17]; // reads std::string
const int maxn = (int) 2e5 + 17;

int n, m;
int a[maxn];
llong P[maxn], D[maxn];

bool read()
{
	if (scanf("%d %d", &n, &m) != 2)
		return false;

	forn (i, n)
		scanf("%d", a + i), --a[i];

	return true;
}

void solve()
{
	forn (i, n - 1)
	{
		int s = a[i], t = a[i + 1];

		if (s < t)
		{
			P[0] += t - s;
			D[s + 2] += -1;
			D[t + 1] += 1;
			P[t + 1] += t - s - 1;
		}
		else
		{
			P[0] += t + 2;
			D[0] += -1;
			P[t + 1] += m + t - s - 1;
			D[t + 1] += 1;
			D[s + 2] += -1;
		}
	}

	llong curp = 0, curd = 0, ans = linf;

	for (int i = 0; i < m; ++i)
	{
		curd += D[i];
		curp += P[i] + curd;
		ans = min(ans, curp);
	}

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

int main()
{
#if SEREZHKA
	freopen("file.in", "r", stdin);
#endif

	while (read())
		solve();

	return 0;
}


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

int main()
{
  map<string, int> m;
  int N;
  cin >> N;
  vector<string> S(N);
  int max = 0;
  for (auto & s : S)
  {
    cin >> s;
    ++m[s];
    if (max < m[s])
      ++max;
  }
  vector<string> Smax;
  for (const auto & s : S)
    if (max == m[s])
      Smax.push_back(s);
  sort(Smax.begin(), Smax.end());
  Smax.erase(unique(Smax.begin(), Smax.end()), Smax.end());
  for (const auto & s : Smax)
    cout << s << endl;
  return 0;
}


Measured memory_bytes: 28404
#include <algorithm>
#include <iostream>
#include <queue>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>

using namespace std;

int N, K;
int p[1001];

int main() {
  cin >> N >> K;
  for (int i = 0; i < N; i++) {
    cin >> p[i];
  }
  sort(p, p + N);

  int sum = 0;
  for (int i = 0; i < K; i++) {
    sum += p[i];
  }
  cout << sum << endl;

  return 0;
}

Measured memory_bytes: 3640
import math
import fractions
import heapq
import sys
import re
from collections import Counter
import datetime
from decimal import Decimal, ROUND_HALF_UP, ROUND_HALF_EVEN

#N,K=map(int, input().split())  #複数数値入力　「A B」みたいなスペース空いた入力のとき
#x=list(map(int, input().split()))  #リスト入力 「a1 a2 a3 ...」みたいな配列のような入力のとき

N=int(input())
print((2*N)//fractions.gcd(2,N))

Measured memory_bytes: 68844
n = int(input())
t = [0 for _ in range(n+1)]
x = [0 for _ in range(n+1)]
y = [0 for _ in range(n+1)]
for i in range(n):
    t[i+1], x[i+1], y[i+1] = [int(z) for z in input().split()]
    if t[i+1] - t[i] < abs(x[i + 1] - x[i]) + abs(y[i + 1] - y[i]) or (t[i+1] % 2 != (abs(x[i+1]) + abs(y[i+1])) % 2):
        print('No')
        exit()
print('Yes')


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

const int N = 1e7 + 5;
int dp[N][2];
string s;

int solve(int idx,int b)
{
    if(idx == s.size())
    {
        return b;
    }
    int & ret = dp[idx][b];
    if(~ret) return ret;
    ret = 1e9;
    for(int i = 0 ; i<=9; ++i)
    {
        int x = i;
        x -= b;
        if(x<0)
        {
            ret = min(ret, solve(idx+1, 1) + i + x+10 - (s[idx] - '0'));
        }
        else
        {
            if(x < s[idx]-'0')
            {
                ret = min(ret, solve(idx+1, 1) + i + x+10 - (s[idx] - '0'));
            }
            else
            {
                ret = min(ret, solve(idx+1, 0) + i + x - (s[idx] - '0'));
            }
        }
    }
    return ret;

}

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

    cin>>s;

    memset(dp, -1 , sizeof dp);
    reverse(s.begin(), s.end());
    cout<<solve(0,0)<<endl;


    return 0;
}


Measured memory_bytes: 157596
#include<iostream>
#include<string>
#define rep(i,n) for(int i = 0; i < (n); i++)
using ll = long long;
using namespace std;

int main()
{
    string s;
    cin >> s;
    int i = 0;
    rep(j,3){
        if(s[j] == 'R') i++;
    }
    if(s[1] == 'S' && i == 2){
        cout << 1 << endl;
        return 0;
    }else{
        cout << i << endl;
        return 0;
    }
}

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


class data
{
    public int input;
    public int position;

};
namespace ConsoleApplication3
{
    class Program
    {

        static void Main(string[] args)
        {
            string temp;
            string[] data;
            int[] result;
            int number;
            int swap,count=0;

            temp = Console.ReadLine();
            number = int.Parse(temp);
            result = new int[number];

            data = new string[number];
            temp = Console.ReadLine();
            data = temp.Split(' ');
            for (int i = 0; i < number; i++)
                result[i] = int.Parse(data[i]);
           
            for (int i = 0; i < number; i++)
            {
                for (int j = number - 1; j >= i + 1; j--)
                {
                    if (result[j] < result[j - 1])
                    {
                        swap = result[j];
                        result[j] = result[j-1];
                        result[j - 1] = swap;
                        count++;
                    }

                }

            }


            Console.WriteLine(string.Join(" ", result));
            Console.WriteLine("{0}",count);
        }
    }
}



Measured memory_bytes: 18056
#include <stdio.h>
#include <vector>
 
using namespace std;
 
struct Node{
    Node(){
        brother = parent = -1;
        height = depth = num_of_children = 0;
    }
    int parent,brother,depth,num_of_children,height;
    vector<int> children;
};
 
void calcDepth(Node nodes[],int root_id){
    for(int i = 0;i < nodes[root_id].num_of_children;i++){
        nodes[nodes[root_id].children[i]].depth = nodes[root_id].depth+1;
        calcDepth(nodes,nodes[root_id].children[i]);
    }
}
 
void calcHeight(Node nodes[],int height,int parent){
    nodes[parent].height = max(nodes[parent].height,height+1);
    if(nodes[parent].parent != -1) calcHeight(nodes,height+1,nodes[parent].parent);
}
 
int main(){
    int n,id,left_id,right_id,root_id;
    scanf("%d",&n);
    Node nodes[n];
 
    for(int i = 0; i < n; i++){
        scanf("%d %d %d",&id,&left_id,&right_id);
        if(left_id != -1){
            nodes[id].children.push_back(left_id);
            nodes[id].num_of_children++;
            nodes[left_id].parent = id;
        }
        if(right_id != -1){
            nodes[id].children.push_back(right_id);
            nodes[id].num_of_children++;
            nodes[right_id].parent = id;
        }
        if(left_id != -1 && right_id != -1){
            nodes[left_id].brother = right_id;
            nodes[right_id].brother = left_id;
        }
    }
 
    for(root_id = 0; root_id < n; root_id++){
        if(nodes[root_id].parent == -1) break;
    }
 
    if(n > 1){
        calcDepth(nodes,root_id);
 
        for(int i = 0; i < n; i++){
            if(nodes[i].num_of_children == 0) calcHeight(nodes,0,nodes[i].parent);
        }
    }
 
    for(int i = 0; i < n; i++){
        printf("node %d: parent = %d, sibling = %d, degree = %d, depth = %d, height = %d,"
                ,i,nodes[i].parent,nodes[i].brother,nodes[i].num_of_children,nodes[i].depth,nodes[i].height);
        if(nodes[i].parent == -1){
            printf(" root\n");
        }else if(nodes[i].num_of_children == 0){
            printf(" leaf\n");
        }else{
            printf(" internal node\n");
        }
 
    }



}


Measured memory_bytes: 2804
#include <algorithm>
#include <bitset>
#include <tuple>
#include <cstdint>
#include <cstdio>
#include <cctype>
#include <assert.h>
#include <stdlib.h>
#include <stdio.h>
#include <cassert>
#include <cfloat>
#include <climits>
#include <cmath>
#include <complex>
#include <ctime>
#include <deque>
#include <fstream>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <list>
#include <limits>
#include <map>
#include <memory>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>
#include <math.h>

// ===============================================================

using namespace std;
using ll = long long;
using vl = vector<long long>;
using vll = vector<vector<long long>>;
using vs = vector<string>;
using vc = vector<char>;
using vcc = vector<vector<char>>;
using vm = vector<short>;
using vmm = vector<vector<short>>;
using pii = pair<int, int>;
using psi = pair<string, int>;
using ld = long double;
using ull = unsigned long long;

// ===============================================================

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

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

ll box(double a) //doubleの切り捨て
{
	ll b = a;
	return b;
}

ll fff(double a) //doubleの四捨五入
{
	ll b = a + 0.5;
	return b;
}

ll sum(ll n) { //整数sまでの合計
	if (n == 0) {
		return 0;
	}

	int s = sum(n - 1);
	return s + n;
}

bool prime(ll num)//素数判定、primeならtrue,違うならfalse
{
	if (num < 2) return false;
	else if (num == 2) return true;
	else if (num % 2 == 0) return false;
	double sqrtNum = sqrt(num);
	for (int i = 3; i <= sqrtNum; i += 2)
	{
		if (num % i == 0)
		{
			return false;
		}
	}

	// 素数である
	return true;
}

// ===============================================================

int main() {
	string s, t, u;
	ll a, b;
	cin >> s >> t >> a >> b >> u;
	if (u == s) {
		cout << a - 1 << " " << b << endl;
	}
	else {
		cout << a << " " << b - 1 << endl;
	}
}

Measured memory_bytes: 3604
n,*t=`dd`.split;
#a=j=m=0;t.map!{|e|e.to_i*2}.pop(n.to_i).map{|v|$*[j]=a=[a,v].min;j+=t.shift.times{$*<<a=[a+1,v].min}};j.times{|i|$.+=m=[m+1,$*[-i-2]].min}
a,*z=j=0;t.map!{|e|e.to_i*2}.pop(n.to_i).map{|v|z[0]=a=[a,v].min;j+=t.shift.times{z=a=[a+1,v].min,*z}};m=-1;z.map{|a|$.+=m=[m+1,a].min}
p$./4.0

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

#define I inline
#define fi first
#define se second
#define LL long long
#define mp make_pair
#define reg register int
#define pii pair<int,int>
#define fo(i, a, b) for(reg i = a; i <= b; i++)
#define fd(i, a, b) for(reg i = a; i >= b; i--)
#define cr const reg&
using namespace std;
const int N = 2001, mod = 1e9 + 7;

I int _max(cr x, cr y) {return x > y ? x : y;}
I int _min(cr x, cr y) {return x < y ? x : y;}
I int read() {
	reg x = 0, f = 1; char ch = getchar();
	while(ch < '0' || ch > '9') {if(ch == '-') f = -1; ch = getchar();}
	while(ch >= '0' && ch <= '9') x = (x << 3) + (x << 1) + (ch ^ 48), ch = getchar();
	return x * f;
}
I void ptt(LL x) {if(x >= 10) ptt(x / 10); putchar(x % 10 + '0');}
I void put(LL x) {x < 0 ? putchar('-'), ptt(-x) : ptt(x);}
I void pr1(LL x) {put(x), putchar(' ');}
I void pr2(LL x) {put(x), puts("");}

I int pow_mod(reg a, reg k) {reg ans = 1; for(; k; k >>= 1, a = (LL)a * a % mod) if(k & 1) ans = (LL)ans * a % mod; return ans;}

int jc[N], inv[N], s[N][N], f[N][N];

I int C(cr n, cr m) {return (LL)jc[n] * inv[m] % mod * inv[n - m] % mod;}
I int add(cr x, cr y) {return x + y >= mod ? x + y - mod : x + y;}

int main() {
	reg A = read(), B = read();
	reg ans = 0;
	jc[0] = 1; fo(i, 1, B) jc[i] = (LL)jc[i - 1] * i % mod;
	inv[B] = pow_mod(jc[B], mod - 2); fd(i, B, 1) inv[i - 1] = (LL)inv[i] * i % mod;
	fo(i, 0, B - 1) {
		s[i][0] = 1; fo(j, 1, i) s[i][j] = add(s[i][j - 1], C(i, j));
	} fo(j, 0, A) f[0][j] = 1;
	fo(i, 1, B) {
		f[i][0] = s[i - 1][0];
		fo(j, 1, A) f[i][j] = add(f[i][j - 1], s[i - 1][_min(i - 1, j)]);
	} fo(i, 0, A) {
		fo(j, 0, _min(B - 1, A - i)) {
			reg R = A - i - j, E = j;
			ans = (ans + (LL)C(B - 1, j) * f[E][R]) % mod;
		}
	} pr2(ans);
	return 0;
}



Measured memory_bytes: 31488
#include <stdio.h>

int selectionSort(int A[],int N){
	int count = 0;
	int min;
	int change;
	for(int i = 0;i <N-1;i++){
		min = i;
		for(int j = i;j < N;j++){
			if(A[j] < A[min]){
			min = j;
			}
		}
			change = A[i];
			A[i] = A[min];
			A[min] = change;
			if(i != min)count++;
			
		
	}
	return count;
}
int main(void){
	int n;
	scanf("%d",&n);
	int a[n];
	int c;
	c = 0;
	for(int i=0;i<n;i++){
	scanf("%d",&a[i]);
	}
	c = selectionSort(a , n);
	
	
	for(int i = 0;i<n;i++){
		printf("%d",a[i]);
		
		if(i != n-1)printf(" ");
	}
	printf("\n");
	printf("%d\n",c);
	return 0;
}



Measured memory_bytes: 2092
#include <bits/stdc++.h>
using namespace std;
using lint = long long int;

signed main(){
	lint N, M; cin >> N >> M;
	vector<vector<lint> > data(M + 1);
	for(lint i = 0; i < N; i++){
		lint a, b; cin >> a >> b;
		if(a > M) continue;
 		data[a].push_back(b);
	}
	lint ans = 0;
	priority_queue<lint> que;
	for(lint i = 1; i <= M; i++){
		for(lint j = 0; j < data[i].size(); j++) que.push(data[i][j]);
		if(que.size()) ans += que.top(), que.pop();
	}
	cout << ans << endl;
}

Measured memory_bytes: 5632
#include <bits/stdc++.h>
using namespace std;
int main(){
  int n;
  cin >> n;
  unordered_map<string, int> m;
  for(int i=0; i<n; i++){
    string j;
    cin >> j;
    m[j]++;
  }
  vector<string> v{"AC", "WA", "TLE", "RE"};
  for(auto label: v) {
    cout << label << " x " << m[label] << endl;
  }
}

Measured memory_bytes: 3620
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.Map;
import java.util.HashMap;
import java.util.List;
import java.util.ArrayList;
import java.util.Collections;

public class Main {
    public static void main(String[] args) throws Exception {
        // Your code here!
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        String[] nk = br.readLine().split(" ");
        int n = Integer.parseInt(nk[0]);
        int k = Integer.parseInt(nk[1]);
        HashMap<Integer, Integer> nums = new HashMap<Integer, Integer>();
        
        
        String[] line = br.readLine().split(" ");
        for (int i = 0; i < n; i++) {
            int key = Integer.parseInt(line[i]);
            if (nums.get(key) == null) nums.put(key, 1);
            else nums.put(key, nums.get(key) + 1);
        }
        
        
        List<Integer> list = new ArrayList<>(nums.values());
        Collections.sort(list);
        
        int res = 0;
        for (int i = 0; i < list.size() - k; i++) {
            res += list.get(i);
        }
        
        System.out.println(res);
    }
}


Measured memory_bytes: 61452
//#define _GLIBCXX_DEBUG

#include<bits/stdc++.h>
using namespace std;

#define endl '\n'
#define lfs cout<<fixed<<setprecision(10)
#define ALL(a)  (a).begin(),(a).end()
#define ALLR(a)  (a).rbegin(),(a).rend()
#define spa << " " <<
#define fi first
#define se second
#define MP make_pair
#define MT make_tuple
#define PB push_back
#define EB emplace_back
#define rep(i,n,m) for(ll i = (n); i < (ll)(m); i++)
#define rrep(i,n,m) for(ll i = (ll)(m) - 1; i >= (ll)(n); i--)
using ll = long long;
using ld = long double;
const ll MOD1 = 1e9+7;
const ll MOD9 = 998244353;
const ll INF = 1e18;
using P = pair<ll, ll>;
template<typename T1, typename T2>
bool chmin(T1 &a,T2 b){if(a>b){a=b;return true;}else return false;}
template<typename T1, typename T2>
bool chmax(T1 &a,T2 b){if(a<b){a=b;return true;}else return false;}
ll median(ll a,ll b, ll c){return a+b+c-max({a,b,c})-min({a,b,c});}
void ans1(bool x){if(x) cout<<"Yes"<<endl;else cout<<"No"<<endl;}
void ans2(bool x){if(x) cout<<"YES"<<endl;else cout<<"NO"<<endl;}
void ans3(bool x){if(x) cout<<"Yay!"<<endl;else cout<<":("<<endl;}
template<typename T1,typename T2>
void ans(bool x,T1 y,T2 z){if(x)cout<<y<<endl;else cout<<z<<endl;}  
template<typename T>
void debug(vector<vector<T>>&v,ll h,ll w){for(ll i=0;i<h;i++)
{cout<<v[i][0];for(ll j=1;j<w;j++)cout spa v[i][j];cout<<endl;}};
void debug(vector<string>&v,ll h,ll w){for(ll i=0;i<h;i++)
{for(ll j=0;j<w;j++)cout<<v[i][j];cout<<endl;}};
template<typename T>
void debug(vector<T>&v,ll n){if(n!=0)cout<<v[0];
for(ll i=1;i<n;i++)cout spa v[i];cout<<endl;};
template<typename T>
vector<vector<T>>vec(ll x, ll y, T w){
  vector<vector<T>>v(x,vector<T>(y,w));return v;}
ll gcd(ll x,ll y){ll r;while(y!=0&&(r=x%y)!=0){x=y;y=r;}return y==0?x:y;}
vector<ll>dx={1,-1,0,0,1,1,-1,-1};
vector<ll>dy={0,0,1,-1,1,-1,1,-1};
template<typename T>
vector<T> make_v(size_t a,T b){return vector<T>(a,b);}
template<typename... Ts>
auto make_v(size_t a,Ts... ts){
  return vector<decltype(make_v(ts...))>(a,make_v(ts...));
}
template<typename T1, typename T2>
ostream &operator<<(ostream &os, const pair<T1, T2>&p){
  return os << p.first << " " << p.second;
}
//mt19937 mt(chrono::steady_clock::now().time_since_epoch().count());
struct nazo_basis{
  vector<ll>basis;
  nazo_basis() = default;
  ll rank(){return basis.size();};
  bool insert(ll k){
    for(auto b:basis)chmin(k, k^b);
    if(k){
      basis.push_back(k);
      return true;
    }
    else return false;
  }
  bool include(ll k){
    for(auto b:basis)chmin(k, k^b);
    return !k;
  }
  ll subset_max(){
    ll k=0;
    for(auto b:basis)chmax(k, k^b);
    return k;
  }
  void print(){
    for(auto b:basis)cout<<b<<" ";
    cout<<endl;
  }
};
int main(){
  cin.tie(nullptr);
  ios_base::sync_with_stdio(false);
  ll res=0,buf=0;
  bool judge = true;
  ll t;cin>>t;
  while(t--){
    ll n;cin>>n;
    vector<ll>a(n);
    rep(i,0,n)cin>>a[i];
    string s;cin>>s;
    nazo_basis b;
    judge=true;
    rrep(i,0,n){
      if(s[i]=='0')b.insert(a[i]);
      else if(!b.include(a[i]))judge=false;
    }
    cout<<!judge<<endl;
  }
  return 0;
}

Measured memory_bytes: 3548
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rep1(i, n) for(int i = 1; i <= (n); i++)
#define co(x) cout << (x) << "\n"
#define cosp(x) cout << (x) << " "
#define ce(x) cerr << (x) << "\n"
#define cesp(x) cerr << (x) << " "
#define pb push_back
#define mp make_pair
#define Would
#define you
#define please


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

	
	int A, B;
	cin >> A >> B;

	co((A + B) % 24);

	Would you please return 0;
}

Measured memory_bytes: 256
origin_n=int(input())
n=origin_n
dpair=[]
for i in range(2,int(n**(1/2))+1):
	k=0
	while True:
		if n//i == n/i:
			k+=1
			n/=i
		else:
			break
	if k!=0:
		dpair.append([i,k])

if n!=1:
	dpair.append([int(n),1])
print(f"{origin_n}:",end="")

for i in dpair:
	for k in range(i[1]):
		print(f" {i[0]}",end="")
print()


Measured memory_bytes: 5644
#include<iostream>
#include<string>
#include<cstdio>
#include<algorithm>
#include<cstdlib>
#include<cmath>
#include<vector>
#include<utility>
#include<queue>
#include<stack>
#include<set>
#include<map>
#include<bitset>
#include<iomanip>
#include<list>
#include<deque>
using namespace std;
//#define MODE 1
#ifdef MODE
#define DEB(X) cout<< #X <<": "<<X<<" ";
#define DEB2(X) cout<<X<<" ";
#define END cout<<endl;
#else
#define DEB(X) {}
#define DEB2(X) {}
#define END {}
#endif
typedef long long ll;
#define int ll
#define uset unordered_set
#define umap unordered_map
//typedef std::pair<int,int> P;
struct edge{int to,cost;};
const int INF=100000000000000000;
const int INF2=9223372036854775807;
const int MOD=1000000007;
#define REP(i,n) for(int i=0;i<(int)(n);i++)
#define min(X,Y) (((int)(X)<(int)(Y))?(X):(Y))
#define max(X,Y) (((int)(X)>(int)(Y))?(X):(Y))
#define NP(X,Y) next_permutation(X,Y)
#define setdouble(X,Y) cout<<fixed<<setprecision(X)<<Y
int ceil2(int a,int b){if(a%b==0){return a/b;}else{return a/b+1;}}
int pow2(int a,int b){int r=1;for(int i=1;i<=b;i++){r*=a;}return r;}
int Log2(int a){int t=0;while(1){if(a==0||a==1){break;}a/=2;t++;}return t;}

string S;

signed main(){
	cin>>S;
	int sum=0;
	REP(i,S.size()){
		sum+=S[i]-'0';
	}
	if(sum%9==0){
		cout<<"Yes"<<endl;
	}
	else{
		cout<<"No"<<endl;
	}
	return 0;
}


Measured memory_bytes: 3752
#pragma GCC optimize("O3")

#define _GLIBCXX_DEBUG
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <cassert>
#include <list>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <stack>
using namespace std;

/*----------macros----------*/

//output================
#define endl '\n'
#define fcout cout << fixed << setprecision(15)

//typedef===============
typedef long long       ll;
typedef long double     ld;
typedef pair<int, int>  Pii;
typedef pair<ll, ll>    Pll;

//const number==========
constexpr ll INF9   = (ll)1e9 + 1;
constexpr ll INF18  = (ll)1e18 + 1;
constexpr ll MOD    = 1000000007;
constexpr ld PI     = 3.141592653589793L;

//member================
#define pb push_back
#define eb emplace_back
#define pf push_front
#define mp make_pair
#define fi first
#define se second

//others================
#define all(x)          (x).begin(), (x).end()
#define rall(x)         (x).rbegin(), (x).rend()
#define rep(i, n)       for(int i = 0; (i) < (n); ++(i))
#define reps(i, n)       for(int i = 1; (i) <= (n); ++(i))
#define rrep(i, n)      for(int i = n - 1; (i) >= 0 ; --(i))
#define CtoI(c)         int((c)) - int('0')
#define ItoC(c)         char((c) + '0')

//functions=============
template<typename T1, typename T2>
inline bool chmax(T1 &a, T2 b) { return a < b && (a = b, true); }

template<typename T1, typename T2>
inline bool chmin(T1 &a, T2 b) { return a > b && (a = b, true); }

//vector<int> dx = {1, 0, -1, 0}, dy = {0, 1, 0, -1};
//vector<int> dx2 = { 1,1,0,-1,-1,-1,0,1 }, dy2 = { 0,1,1,1,0,-1,-1,-1 };

/*--------additional--------*/

ll gcd(ll a, ll b){
    if(a%b == 0){
        return b;
    }else{
        return gcd(b, a%b);
    }
}

ll lcm(ll a, ll b)
{
    return a * b / gcd(a, b);
}

/*----------main------------*/

int main() {
/*----------fastio----------*/
    std::cin.tie(nullptr);
    std::cout.tie(nullptr);
    std::ios::sync_with_stdio(false);
/*----------solve-----------*/

    ll a, b; cin >> a >> b;

    cout << lcm(a, b) << endl;

return 0;
}

Measured memory_bytes: 3648
#include <bits/stdc++.h>
using namespace std;
typedef long long lint;
typedef vector<lint> vlint;

#define inf 1e+9
#define endl "\n"
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep1(i, n) for (int i = 1; i < (int)(n); i++)
#define all(x) (x).begin(), (x).end()

#define pb push_back
#define eb emplace_back
#define Size(c) (int)(c).size()

#define lb(c, x) distance((c).begin(), lower_bound(all(c), (x)))
#define ub(c, x) distance((c).begin(), upper_bound(all(c), (x)))

template <class T> using pq = priority_queue<T>;
template <class T> using pqg = priority_queue<T, vector<T>, greater<T>>;

template <class T, class S> inline bool chmax(T &a, S b) {
    if(a < b) {a = b;return 1;} return 0;
}
template <class T, class S> inline bool chmin(T &a, S b) {
    if(a > b) {a = b;return 1;} return 0;
}
template <class T>
void line(vector<T> &x){for (auto&& xi : x) cin >> xi;}

inline void IN(void){ return;}

template <typename First, typename... Rest>
void IN(First& first, Rest&... rest){ cin >> first; IN(rest...); return;}

#define INT(...) int __VA_ARGS__; IN (__VA_ARGS__)
#define LINT(...) lint __VA_ARGS__; IN (__VA_ARGS__)
#define STR(...) string __VA_ARGS__; IN(__VA_ARGS__)

template <class T> void UNIQUE(vector<T> &x) {
    sort(all(x)); x.erase(unique(all(x)), x.end());
}
template <class T> void print_vec(T first, T end){
    for (auto i = first; i < end - 1; i++) cout << *i << " ";
    cout << *(end-1) << endl;
}
template <class T> void print(T a){ cout << a << endl;};
vector<string> Yes = {"No", "Yes"};
vector<string> YES = {"NO", "YES"};

int main(){
    INT(l, r, d);
    int ans = 0;
    for (int i = l; i <= r; ++i){
        if (i % d == 0) ans ++;
    }
    print(ans);
}
    



Measured memory_bytes: 3552
N,K=map(int,input().split())
treat=set()
for i in range(1,K+1):
    d=int(input())
    A=list(map(int,input().split()))
    for i in A:
        treat.add(i)
result=0
for i in range(1,N+1):
    if not (i in treat) :
         result+=1
print(result)


Measured memory_bytes: 9184
//AUTHOR: RAVAN_2070
//PUNE INSTITUTE OF COMPUTER TECHNOLOGY
/*
    I LOVE CLARICE STARLING

     ♥LOVE♥        ♥LOVE♥
  ♥LOVE♥♥LOVE♥  ♥LOVE♥♥LOVE♥
♥LOVE♥♥LOVE♥♥LOVE♥♥LOVE♥♥LOVE♥
   ♥LOVE♥♥LOVE♥♥LOVE♥♥LOVE♥
      ♥LOVE♥♥LOVE♥♥LOVE♥
         ♥LOVE♥♥LOVE♥
            ♥LOVE♥
               ♥


    EXPLAINATION BELOW->
    1  5  1  100
    1  1   4  7   . . . .
     
    if take position 1 neglet position 2 then 3 we have W=1 i=4
    even same situation(state) appears when you neglect postion 1,and take position 2
    which indicates Overlapping subproblems,and also  Optimal substructure
    
     If you try out different subsequences under given conditions you can observe,
     Overlapping Subproblems as well as Optimal substructure so Definitely Dynamic Programming
    
    DP State consist of  Weight,position which indicates if I start from this position and have capacity W what is the optimal Answer..
*/

/*
 *   ITERATIVE SOLUTION
 */
//
#include<bits/stdc++.h>
using namespace std;
typedef unsigned long long int ull;
typedef long long int ll;
typedef long double ld;
typedef vector<ll> vi;
typedef vector<pair<ll,ll>> vii;
typedef pair<ll,ll> pii;
typedef map<ll,ll> mii;
#define MOD7 1000000007
#define MOD9 1000000009
#define pi 3.1415926535
#define Test_cases ll TC;cin>>TC;while(TC--)
#define fastio ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(), x.rend()
#define sp(x) fixed<<setprecision(x)
#define sz(x) (ll)(x.size())
#define fo(i,a,b) for(i=a;i<b;i++)
#define foe(i,a,b) for(i=a;i<=b;i++)
ll dp[105][100005];
ll knapsack[100001][2];
void solve()
{
    int N,W,i,j;cin>>N>>W;
    fo(i,0,N)cin>>knapsack[i][0]>>knapsack[i][1];
    
    for(i=N-1;i>=0;i--)
    {
        for(j=0;j<=W;j++)
        {
            if(j==0)dp[i][j]=0;
            
            if(knapsack[i][0]<=j)
            dp[i][j]=max(dp[i+1][j],knapsack[i][1]+dp[i+1][j-knapsack[i][0]]);
            else
            dp[i][j]=dp[i+1][j];
        }
    }
    cout<<dp[0][W]<<"\n";
}
int main()
{
   fastio
   solve();
  return 0;
}
//map<ll,ll,greater<int>> to sort in descending order ,in iterator declaration no greater<int>
//if you want to apply lowerbound on set use s.lower_bound(key),not the one used for vector
/* TIPS FOR DEBUGGING
 * Check if values are not overflowing (use long long where required)
 * Check if ranges are inclusive or not.
 * Check properly if greedy will work or not before using it.
 * Check EDGE CASES!! Seriously, even in 2B, saving 8 points by being
 * 2 minutes faster will bite you in the ass if you don't make sure
 * it works on edge cases.
 * Keep adding to this list.
*/


Measured memory_bytes: 78592
#include <iostream>
#include <algorithm>
#include <cmath>
using namespace std;

long long int f(int x){
	if(x==0){
		return 1;
	}else{
		return x*f(x-1);
	}
}

int main(){
	int a;
	long long int r;
	while(cin >> a){
		r=f(a);
		cout << r << endl;
	}
	return 0;
}

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

using namespace std;



int main()
{
    int x,y,z;
    cin>>x>>y>>z;
    if((y-x+1)<=z)
    {
        for(int i=x;i<=y;i++)
        cout<<i<<endl;
    }
    else
    {
        vector<int>v;
        for(int i=0;i<z;i++)
        v.push_back(x+i);
        for(int i=0;i<z;i++)
        v.push_back(y-i);
        sort(v.begin(),v.end());
        for(int i=0;i<v.size();i++)
        {
            if(v[i+1]!=v[i])
            cout<<v[i]<<endl;
        }
    }
    system("pause");
    return 0;
}



Measured memory_bytes: 504
#include <iostream>
#include <vector>
#include <algorithm>
 
using namespace std;
 
int main() {
  int a,b,k;
  cin >> a >> b >> k;
  
  int ma, mb;
  
  if (a > b){
    ma = a;
    mb = b;
  } else {
    ma = b;
    mb = a;
  }
  
  vector<int> v;
  long long c[ma];
  long long count=0;
  for (int i=1;i<=ma;i++){
    if((ma%i==0) && (mb%i==0)){
      v.push_back(i);
      //count = count + 1;
    }
  }
  cout << v[v.size()-k] << endl;
  return 0;
}

Measured memory_bytes: 256
x, y, z=map(int, input().split())
if x < y < z:
  print(x, y, z)
elif x < z < y:
  print(x, z, y)
elif y < x < z:
  print(y, x, z)
elif y < z < x:
  print(y, z, x)
elif z < x < y:
  print(z, x, y)
elif z < y < x:
  print(z, y, x)
elif x == z and z < y:
  print(x, z, y)
elif x == y and y < z:
  print(x, y, z)
elif y == z and z < x:
  print(y, z, x)
else:
  print(x, y, z)


Measured memory_bytes: 5596
#include <stdio.h>
int main() {
	int a;
	int b;
	int c;

	scanf("%d", &a);
	scanf("%d", &b);
	scanf("%d", &c);

	if (a < b && b<c) {
		printf("Yes\n");
	}
	else {
		printf("No\n");
	}

	return 0;
}


Measured memory_bytes: 2096
import sys
def input(): return sys.stdin.readline().rstrip()
def main():
    n=int(input())
    A=[int(input())for _ in range(n)]
    A.sort()
    ans1=0
    if n%2==0:
        ans1=(2*sum(A[n//2:])-A[n//2])-(2*sum(A[:n//2])-A[n//2-1])
    else:
        ans1=(2*sum(A[n//2:])-A[n//2]-A[n//2+1])-2*sum(A[:n//2])
    ans2=0
    if n%2==0:
        ans2=(2*sum(A[n//2:])-A[n//2])-(2*sum(A[:n//2])-A[n//2-1])
    else:
        ans2=2*sum(A[n//2+1:])-(2*sum(A[:n//2+1])-A[n//2-1]-A[n//2])      
    print(max(ans1,ans2))

if __name__=='__main__':
    main()

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

ans = Array.new(h) { Array.new(w) }
for i in 0..h-1
    for j in 0..w-1
        ans[i][j] = (i < b ? 1 : 0) ^ (j < a ? 1 : 0)
    end
end
puts ans.map(&:join).join("\n")

Measured memory_bytes: 16892
N=int(input())
a=list(map(int,input().split()))
zako=set()
aka=list()
for i in a:
    if 1<= i <=399:
        zako.add('g')
    elif 400<=i<=799:
        zako.add('Br')
    elif 800<=i<=1199:
        zako.add('gre')
    elif 1200<=i<=1599:
        zako.add('mizu')
    elif 1600<=i<=1999:
        zako.add('blu')
    elif 2000<=i<=2399:
        zako.add('ye')
    elif 2400<=i<=2799:
        zako.add('ora')
    elif 2800<=i<=3199:
        zako.add('red')
    else:
        aka.append(1)
if len(zako)==0:
    print(1,len(aka))
else:
    print((len(zako)),(len(zako)+len(aka)))
    


Measured memory_bytes: 9224
#include <iostream>
#include <vector>
#include <queue>
#include <limits>
using namespace std;
using llong = long long;

//===
template<class T>
struct Edge {
    int src, to;
    T cost;

    Edge (int to, T cost):
        src(-1), to(to), cost(cost) {};
    Edge (int src, int to, T cost):
        src(src), to(to), cost(cost) {};

    operator int() const {
        return to;
    };
};

template <class T>
using WeightedGraph = vector<vector<Edge<T>>>;
using UnWeightedGraph = vector<vector<int> >;
//===

//===
// require graph/basic.cpp
// #inlcude <limits>
// time: O(|E||V|)

// when g has negative cycle, it returns empty vector<>
template<class T, class Compare = less<T> >
vector<T> bellman_ford(WeightedGraph<T> &g, int from,
                       const Compare &cmp = Compare() ) {

    const int V = g.size();
    const T INF = numeric_limits<T>::max();
    vector<T> min_cost(g.size(), INF);

    min_cost[from] = 0;
    for (int k = 0; k < V; k++) {
        for (int i = 0; i < V; i++) {
            for (auto &e:g[i]) {
                if (min_cost[i] == INF) break;
                if (cmp(min_cost[i] + e.cost, min_cost[e.to])) {
                    
                    min_cost[e.to] = min_cost[i] + e.cost;
                    if (k == V - 1) return vector<T>();
                }
            }
        }
    }

    return min_cost;
};

// when from->to path has negative cycle, it returns empty vector<T>
template<class T, class Compare = less<T> >
vector<T> bellman_ford(WeightedGraph<T> &g, int from, int to,
                       const Compare &cmp = Compare() ) {
    
    const int V = g.size();
    const T INF = numeric_limits<T>::max();
    vector<T> min_cost(g.size(), INF);

    min_cost[from] = 0;
    for (int k = 0; k < V; k++) {
        for (int i = 0; i < V; i++) {
            for (auto &e:g[i]) {
                if (min_cost[i] == INF) break;
                if (cmp(min_cost[i] + e.cost, min_cost[e.to])) {
                    
                    min_cost[e.to] = min_cost[i] + e.cost;
                    if (k == V - 1 && e.to == to) return vector<T>();
                }
            }
        }
    }

    return min_cost;
};
//===

int AOJ_GRL_1_B() {
    llong V, E, R;
    llong s, t, d;
    bool is_negative;

    cin >> V >> E >> R;
    WeightedGraph<llong> G(V);
    for (int i = 0; i < E; i++) {
        cin >> s >> t >> d;
        G[s].emplace_back(t, d);
    }

    auto dist = bellman_ford(G, R);

    if (dist.empty()) cout << "NEGATIVE CYCLE" << endl;
    for (auto &e:dist) {
        if (e == numeric_limits<llong>::max()) cout << "INF" << endl;
        else cout << e << endl;
    }

    return 0;
}

int main() {
    return AOJ_GRL_1_B();
}



Measured memory_bytes: 3188
#include <iostream>
#include <string>
using namespace std;
int main() {
  ios::sync_with_stdio(false);
  string s;
  string t;
  cin >> s;
  cin >> t;
  int ret = 0;
  for (int i=0; i<3; i++) {
    if (s[i] == t[i]) ret++;
  }
  cout << ret << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <numeric>

using namespace std;

int main(int argc, const char *argv[]) {
  int N, T, c, t;
  cin >> N >> T;
  vector<int> cost;

  for (int i = 0; i < N; i++) {
    cin >> c >> t;
    if(t <= T){
      cost.push_back(c);
    }
  }
  if(cost.size() == 0){
    cout << "TLE" << endl;
    return 0;
  }
  sort(cost.begin(), cost.end());
  cout << cost[0] << endl;

  return 0;
}


Measured memory_bytes: 256
n=int(input())
l=list(map(int,input().split()))
ones,twos,threes=0,0,0
for i in l:
    if i==1:
        ones+=1
    elif i==2:
        twos+=1
    else:
        threes+=1
max_ones=ones+twos+threes
max_twos=twos+threes
max_threes=threes
dp=[[[0.0]*(n+1)for i in range(n+1)]for j in range(n+1)]
for k in range(max_threes+1):
    for j in range(max_twos+1-k):
        for i in range(max_ones+1-j-k):
            if (i+j+k)==0:
                continue
            else:
                dp[i][j][k]=n/(i+j+k)
                if i>0:
                    dp[i][j][k]+=(dp[i-1][j][k]*i)/(i+j+k)
                if j>0:
                    dp[i][j][k]+=(dp[i+1][j-1][k]*j)/(i+j+k)
                if k>0:
                    dp[i][j][k]+=(dp[i][j+1][k-1]*k)/(i+j+k)
print(dp[i][j][k])




            

Measured memory_bytes: 295488
import java.util.*;

public class Main{
  public static void main(String[]args){
    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();
    
    boolean[] b = new boolean[1000001];
    b[n] = true;
    int i = 2;
    while(true){
      if(n%2 == 0){
        n /= 2;
      }else{
        n = n*3+1;
      }
      if(b[n]){
        break;
      }else{
        b[n] = true;
      }
      i++;
    }
    System.out.println(i);
  }
}

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

int main() {
  double a, b, x;
  cin >> a >> b >> x;
  
  double arg = 0;
  double c = M_PI;
  if (2*x > a*a*b) {
    double y = (-x/a)/a;
    y += b;
    y *= 2/a;
    arg = (180/c)*atan(y);
  }
  else {
    double y = (2/b)*(x/a);
    arg = (180/c)*atan(b/y);
  }
  cout << fixed << setprecision(8);
  cout << arg << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <sstream>
#include <algorithm>
#include <cstdio>
#include <cmath>
#include <set>
#include <map>
#include <queue>
#include <string>
#include <cstring>
#include <bitset>
#include <functional>
#include <random>
#define REP(i,a,n) for(int i=a;i<=n;++i)
#define PER(i,a,n) for(int i=n;i>=a;--i)
#define hr putchar(10)
#define pb push_back
#define lc (o<<1)
#define rc (lc|1)
#define mid ((l+r)>>1)
#define ls lc,l,mid
#define rs rc,mid+1,r
#define x first
#define y second
#define io std::ios::sync_with_stdio(false)
#define endl '\n'
#define DB(a) ({REP(__i,1,n) cout<<a[__i]<<' ';hr;})
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
const int P = 1e9+7, INF = 0x3f3f3f3f;
ll gcd(ll a,ll b) {return b?gcd(b,a%b):a;}
ll qpow(ll a,ll n) {ll r=1%P;for (a%=P;n;a=a*a%P,n>>=1)if(n&1)r=r*a%P;return r;}
ll inv(ll x){return x<=1?1:inv(P%x)*(P-P/x)%P;}
inline int rd() {int x=0;char p=getchar();while(p<'0'||p>'9')p=getchar();while(p>='0'&&p<='9')x=x*10+p-'0',p=getchar();return x;}
//head



const int N = 1e6+50;
int n,m,a[N],b[N];
int sum[N];

ll solve(int *a, int n) {
	REP(i,1,n) sum[i]=(sum[i-1]+a[i])%P;
	ll ans = 0;
	REP(i,1,n) ans=(ans+(ll)(n-i)*a[i]-(sum[n]-sum[i]))%P;
	if (ans<0) ans += P;
	return ans;
}
int main() {
	scanf("%d%d",&n,&m);
	REP(i,1,n) scanf("%d",a+i);
	REP(i,1,m) scanf("%d",b+i);
	printf("%lld\n",solve(a,n)*solve(b,m)%P);
}








Measured memory_bytes: 8960
import java.io.*;
import java.util.*;
import java.lang.*;

class Main{
  public static void main(String[] args) throws IOException{
    Scanner scan=new Scanner(System.in);
    int n=Integer.parseInt(scan.next());
    int[] array=new int[n];
    for(int i=0;i<array.length;i++){
      array[i]=Integer.parseInt(scan.next());
    }


    for(int i=array.length-1;i>=0;i--){
      System.out.print(array[i]);
      if(i>0){
        System.out.print(" ");
      }else{
        System.out.println();
      }
    }
  }
  static void show(int[] a){
    for(int k=0;k<a.length;k++){
      System.out.println(a[k]);
    }
  }
}


Measured memory_bytes: 26284
from collections import deque
N, M = map(int, input().split())
P = list(map(int, input().split()))
K = [[] for _ in range(N)]
for i in range(M):
    x, y = map(int, input().split())
    x, y = x-1, y-1
    K[x].append(y)
    K[y].append(x)
used = [0]*N
OK = []
for i in range(N):
    P[i] -= 1
    if i == P[i]:
        OK.append(i)
ans = 0
for i in range(N):
    if used[i] == 0:
        used[i] = 1
        S = deque([i])
        Enable = [i]
        Origin = [P[i]]
        while S:
            t = S.popleft()
            for j in K[t]:
                if used[j] == 0:
                    used[j] = 1
                    Enable.append(j)
                    Origin.append(P[j])
                    S.append(j)
        T_1 = list(set(OK + Enable))
        T_2 = list(set(OK + Origin))
        ans = max(ans, len(T_1) + len(T_2) - len(set(T_1 + T_2)))

print(ans)

Measured memory_bytes: 145872
#include <iostream>
#include <cstdio>
#include <algorithm>
const int MAX_N = 20, INF = 500000;
int dis[MAX_N+1][MAX_N+1];

//V ¸_ from n_ to I_
int wfloyd(int V, int from, int to){
	for(int k=0;k<=V;k++){
		for(int i=0;i<=V;i++){
			for(int j=0;j<=V;j++)dis[i][j] = std::min(dis[i][j], dis[i][k] + dis[k][j]);
		}
	}
	return dis[from][to];
}

int main(){
	//Initialization
	for(int i=0;i<MAX_N+1;i++){
		for(int j=0;j<MAX_N+1;j++){
			dis[i][j] = INF;
		}
	}

	//Input
	int n, m;//XÌC¹Ì
	std::cin >> n >> m;
	for(int i=0;i<m;i++){
		int a, b, c, d;
		scanf("%d,%d,%d,%d",&a,&b,&c,&d);
		dis[a][b] = c;
		dis[b][a] = d;
	}

	int x1, x2, y1, y2;
	scanf("%d,%d,%d,%d",&x1,&x2,&y1,&y2);

	//Processing
	int lowest = wfloyd(n,x1,x2) + wfloyd(n,x2,x1),
		res = y1 - y2 - lowest;

	std::cout << res << std::endl;
	return 0;
}

Measured memory_bytes: 0
#include<stdio.h>

int main()
{
	int N,a[11111],i,j,ans=0;
	scanf("%d",&N);
	for(i=0; i<N; i++){
		scanf("%d",&a[i]);
	}
	for(i=0; i<N; i++){
		for(j=0; a[i]%2==0; j++){
			a[i]=a[i]/2;
		}
		ans+=j;
	}
	
	printf("%d\n",ans);
	
	return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner scanner = new Scanner(System.in);
		int numPpl = Integer.parseInt(scanner.nextLine());
		int M = 1;
		int A = 2;
		int R = 4;
		int C = 8;
		int H = 16;
		int[] numMARCH = new int[17];
		int[] comb3Chars = {
				M + A + R,
				M + A + C,
				M + A + H,
				M + R + C,
				M + R + H,
				M + C + H,
				A + R + C,
				A + R + H,
				A + C + H,
				R + C + H,
				};

		for (int pIdx = 0; pIdx < numPpl; pIdx++) {
			char firstChar = scanner.nextLine().charAt(0);
			if(firstChar == 'M') numMARCH[M]++;
			if(firstChar == 'A') numMARCH[A]++;
			if(firstChar == 'R') numMARCH[R]++;
			if(firstChar == 'C') numMARCH[C]++;
			if(firstChar == 'H') numMARCH[H]++;
		}

		long result = 0;
		for (int comb3Char: comb3Chars) {
			long tmpResult = 1;
			if ((comb3Char & M) > 0) tmpResult = numMARCH[M] == 0L ? 0L : tmpResult * numMARCH[M];
			if ((comb3Char & A) > 0) tmpResult = numMARCH[A] == 0L ? 0L : tmpResult * numMARCH[A];
			if ((comb3Char & R) > 0) tmpResult = numMARCH[R] == 0L ? 0L : tmpResult * numMARCH[R];
			if ((comb3Char & C) > 0) tmpResult = numMARCH[C] == 0L ? 0L : tmpResult * numMARCH[C];
			if ((comb3Char & H) > 0) tmpResult = numMARCH[H] == 0L ? 0L : tmpResult * numMARCH[H];
			result += tmpResult;
		}
		System.out.println(result);
	}
}


Measured memory_bytes: 91960
import java.util.*;

public class Main{
	public static void main(String args[]){
		Scanner sc = new Scanner(System.in);
		List<String> list = new LinkedList<>();
		String hw;
		String end = "0 0";

		while(true){
			hw = sc.nextLine();
			if(hw.equals(end)){
				break;
			}
			list.add(hw);
		}
		for(String data: list){
			int h = Integer.parseInt(data.split(" ")[0]);
			int w = Integer.parseInt(data.split(" ")[1]);
			for(int i = 0;i < h; i++){
				for(int j = 0;j < w; j++){
					if(((j + i) % 2 == 0)){
						System.out.print("#");
					}else{
						System.out.print(".");
					}
				}
				System.out.println();
			}
			System.out.println();
		}
	}
}




Measured memory_bytes: 34820