akhauriyash/Code-Regression huggingface dataset:
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.HashMap;
import java.util.Map;

public class Main {
	public static void main(String[] args) throws IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

		long n = Long.parseLong(br.readLine());

		Map<Long, Integer> map = primeFactorization(n);

		long ans = 0;
		for (long key : map.keySet()) {
			int i = 1;
			while (true) {
				if (map.get(key) >= i) {
					ans++;
					map.put(key, map.get(key) - i);
					i++;
				} else {
					break;
				}
			}
		}
		System.out.println(ans);

	}

	static Map<Long, Integer> primeFactorization(long n) {
		Map<Long, Integer> map = new HashMap<>();
		for (long p = 2; p * p <= n; p++) {
			if (n % p != 0)
				continue;
			int cnt = 0;
			while (n % p == 0) {
				cnt++;
				n = n / p;
			}
			map.put(p, cnt);
		}
		if (n > 1)
			map.put(n, 1);

		return map;
	}
}


Measured memory_bytes: 32524
#include<cmath>
#include<iostream>
#include<iomanip>
#define EPS (1e-10)
#define equals(a,b) (fabs((a)-(b)) < EPS)
using namespace std;

class Point {
public:
    double x, y;

    Point(double x=0, double y=0): x(x), y(y) {}

    Point operator + (Point p) { return Point(x+p.x, y+p.y); }
    Point operator - (Point p) { return Point(x - p.x, y - p.y); }
    Point operator * (double a) { return Point(x*a, y*a); }
    Point operator / (double a) { return Point(x/ a, y/ a); }

    double abs() { return sqrt(norm()); }
    double norm() { return x*x, y*y; }
    bool operator < (const Point &p) const {
	return x != p.x ? x<p.x : y < p.y;
    }
    
    bool operator == (const Point &p) const {
	return fabs(x-p.x) < EPS && fabs(y-p.y) < EPS;
    }
};

typedef Point Vector;

double dot(Vector a, Vector b) {
    return a.x*b.x + a.y*b.y;
}

double norm(Vector a) {
    return a.x*a.x + a.y*a.y;
}


Point project(Point p0, Point p1, Point p2) {
    Point base = p1-p0;
    double r = dot(p2-p0, base) /norm(base);
    return p0 + base*r;
}


Point reflect(Point p0, Point p1, Point p2){
    return p2 + (project(p0,p1,p2)-p2)*2.0;
}

int main() {
    int n,i;
    
    Point p0, p1, p2,p3;
    cin >> p0.x >> p0.y >> p1.x >> p1.y;
    cin >> n;
    for(i=0;i<n;i++){
	cin >>  p2.x >> p2.y;
	p3 = reflect(p0,p1, p2);
	cout << fixed << showpoint;
	cout << setprecision(8);
	cout << p3.x <<" " << p3.y << endl;
    }
    return 0;

}

Measured memory_bytes: 1296
#include <bits/stdc++.h>
using namespace std;
 
int main () {
  int n;
  cin >> n;
  n = n % 10;
  if (n == 2 || n == 4 || n == 5 || n == 7 || n == 9)
    cout << "hon";
  else if (n == 0 || n == 1 || n == 6 || n == 8)
    cout << "pon";
  else
    cout << "bon";
  return 0;
}

Measured memory_bytes: 3504
str = input()
for q in range(int(input())):
    com, *num = input().strip().split()
    a, b = int(num[0]), int(num[1])
    if com == 'print':
        print(str[a:b+1])
    elif com == 'replace':
        str = str[:a] + num[2] + str[b+1:]
    else: # com == 'reverse'
        str = str[:a] + str[a:b+1][::-1] + str[b+1:]

Measured memory_bytes: 7688
#include<bits/stdc++.h>
#include<iostream>
#include<cmath>
#include<vector>
#include<string>
#include<queue>
#include<set>
#include<map>
#include<algorithm>
#include<functional>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef pair<ll, ll> pll;
typedef pair<ull, ull> pullull;
typedef pair<ll, int> plli;
typedef pair<int, pii> pipii;
typedef vector<vector<int> > mati;
typedef vector<vector<double> > matd;

#define rep(i,x,y) for(int i=(x); i<(y); ++i)

template <typename T>
void vec_print(vector<T> VEC){
  rep(i, 0, VEC.size()){
    cout << VEC[i] << " ";
  }
  cout << "\n";
};

template <typename T>
void mat_print(vector<vector<T> > MAT){
  rep(i, 0, MAT.size()){
    rep(j, 0, MAT[i].size()){
      cout << MAT[i][j] << " ";
    }
    cout << "\n";
  }
};

template <typename CLASS1, typename CLASS2>
class HOGE{
  public:
    CLASS1 key;
    CLASS2 value;
    HOGE(ll key, ll value){
      this->key = index;
      this->value = value;
    };
    ~HOGE(void){
      return;
    };

    void print(void){
      cout << "key : " << key << ", value : " << value << "\n";
      return;
    };
    
    bool operator==(const HOGE &obj){
      return (this->value == obj.value);
    };
    bool operator<(const HOGE &obj){
      return (this->value < obj.value);
    };
    bool operator>(const HOGE &obj){
      return (this->value > obj.value);
    };
};

constexpr int INF = (1<<30);
constexpr ll INFLL = 1LL<<62;
constexpr long double EPS = 1e-12;

ll min_search(int pos, const int last, const int K, const vector<ll>& h, vector<ll>& dp){
  if(pos==last) return 0;
  if(dp[pos]>=0) return dp[pos];
  ll min_value = min_search(pos+K, last, K, h, dp) + abs(h[pos]-h[pos+K]);
  for(int i=K-1; i>=1; --i){
    ll tmp1 = min_search(pos+i, last, K, h, dp) + abs(h[pos]-h[pos+i]);
    min_value = min(min_value, tmp1);
  }
  dp[pos] = min_value;
  return dp[pos];
}

int main(){
  cin.tie(0); // cut the cin and cout (default, std::flush is performed after std::cin)
  ios::sync_with_stdio(false); // cut the iostream and stdio (DON'T endl; BUT "\n";)

  ll N, K;
  cin >> N >> K;
  vector<ll> h(N);
  rep(i, 0, N){
    cin >> h[i];
  }

  vector<ll> dp(N, -1);

  for(int j=max(0, (int)(N-K-1)); j<N; ++j){
    dp[j] = abs(h[N-1] - h[j]);
  }

  ll ans = min_search(0, N-1, K, h, dp);

  cout << ans << "\n";

  return 0;
}

Measured memory_bytes: 11136
N = int(input())
H = list(map(int,input().split()))

if N == 1:
    print("Yes")
    exit()

for i in range(N-1):
    if H[i+1] > H[i]:
        H[i+1] -= 1
    if H[i+1] < H[i]:
        print("No")
        exit()

print("Yes")

Measured memory_bytes: 15020
#define _USE_MATH_DEFINES
#include<iostream>
#include<fstream>
#include<string>
#include<vector>
#include<utility>
#include<algorithm>
#include<climits>
#include<set>
#include<map>
#include<cmath>
#include<iomanip>
#include<iterator>
#include<queue>
#include<stack>
#include<cctype>
#include<deque>
#include<time.h>
#include<bitset>
#include<random>
#include<unordered_set>
#include<unordered_map>
#include<sstream>
#include<random>
#include<numeric>
//by Skeef79

typedef long long ll;
typedef long double ld;

typedef unsigned long long ull;

#pragma warning(disable : 4996)
#pragma comment(linker, "/STACK:16777216")
#define pb push_back
#define en '\n'
#define for0(i,n) for(int i = 0;i<n;i++)
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define vec vector
#define pii pair<int,int>
#define pll pair<ll,ll>
#define SZ(a) int(a.size())

using namespace std;

const int INF = 2000000000;
const ll LINF = 2000000000000000000;

template<typename T> void print(vector<T>& a)
{
	for (int i = 0; i < a.size(); i++)
		cout << a[i] << ' ';
	cout << en;
}

template<typename T> void print(deque<T>& a)
{
	for (int i = 0; i < a.size(); i++)
		cout << a[i] << ' ';
	cout << en;
}

template<typename T> void print(vector<vector<T>>& a)
{
	for (int i = 0; i < a.size(); i++)
	{
		for (int j = 0; j < a[i].size(); j++)
			cout << a[i][j] << ' ';
		cout << en;
	}
}

template <typename T> void input(vector<T>& a)
{
	for (int i = 0; i < a.size(); i++)
		cin >> a[i];
}

template<typename T> void input(deque<T>& a)
{
	for (int i = 0; i < a.size(); i++)
		cin >> a[i];
}

template<typename T> void input(vector<vector<T>>& a)
{
	for (int i = 0; i < a.size(); i++)
		for (int j = 0; j < a[i].size(); j++)
			cin >> a[i][j];

}

const ll mod = 1e9 + 7;

void solve()
{
	ll n;
	cin >> n;
	vector<ll>dp(n + 1);
	for (int i = 3; i <= n; i++)
		dp[i] = 1;

	for (int i = 4; i <= n; i++)
	{
		for (int j = i - 3; j >= 0; j--)
			dp[i] = (dp[i] % mod + dp[j] % mod) % mod;
	}
	//print(dp);
	cout << dp[n];
}

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

#ifdef _DEBUG
	freopen("input.txt", "r", stdin);
#endif

	//freopen("input.in", "r", stdin);
	//freopen("output.out", "w", stdout);

	int tst = 1;
	//cin >> tst;

	while (tst--)
		solve();
}


Measured memory_bytes: 3664
#include <bits/stdc++.h>
#define endl '\n'
#define pb push_back
#define mp make_pair
#define MOD 1000000007
#define cont continue
#define rep(i, n) for(int i = 0 ; i < (n) ; i++)
#define all(x) (x).begin(), (x).end()
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
const int INF = 987654321;

map<ll, ll> m;

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

  int X, N;
  cin >> X >> N;

  for(int i = 0 ; i < N ; i++) {
    int x;
    cin >> x;
    m[x]++;
  }

  int left = X;
  int right = X;
  while(1) {
    if(m.find(left) == m.end()) {
      cout << left << endl;
      return 0;
    }
    else if(m.find(right) == m.end()) {
      cout << right << endl;
      return 0;
    }
    else {
      left--;
      right++;
    }
  }
}

Measured memory_bytes: 3660
/**/
#include <bits/stdc++.h>
using namespace std;
/***********************************************/
/* Dear online judge:
 * I've read the problem, and tried to solve it.
 * Even if you don't accept my solution, you should respect my effort.
 * I hope my code compile and get accepted.
 *      ____________
 *     /         __ \
 *    /   __    |  | \
 *   /   |__|   |  |  \
 *  (           |__|   )
 *   \                /
 *    \      ___     /
 *     \____________/
 */
const long long mod = 1000000007;
int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(nullptr);

	long long A,B,C;
	cin>>A>>B>>C;
	if(A%2 == 0 || B%2 == 0 || C%2 == 0){
		cout<<"0\n";
	}else{
		cout<<min(A*B,min(B*C,A*C))<<'\n';
	}
	return 0;
}
/**/


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

typedef long long llint;

int n, k;
int pn = 0, mn = 0;
llint xp[114514];
llint xm[114514];

llint ans = 3000000000;

int main() {
    cin >> n >> k;
    for (int i = 0; i < n; i++) {
        int x;
        cin >> x;
        if (x < 0) {
            xm[mn] = x;
            mn++;
        } else {
            xp[pn] = x;
            pn++;
        }
    }

    for (int i = 1; i <= k; i++) {
        if (i > pn) {
            break;
        } else {
            if (i == k) {
                ans = min(ans, xp[i - 1]);
            } else {
                if (mn - (k - i) < 0) {
                    continue;
                }
                ans = min(ans, xp[i - 1] * 2 - xm[mn - (k - i)]);
            }
        }
    }

    for (int i = 1; i <= k; i++) {
        if (i > mn) {
            break;
        } else {
            if (i == k) {
                ans = min(ans, -xm[mn - i]);
            } else {
                if (k - i - 1 >= pn) {
                    continue;
                }
                ans = min(ans, -xm[mn - i] * 2 + xp[k - i - 1]);
            }
        }
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 1024
import java.io.*;
 
class Main {
  public static void main(String[] args)throws IOException{
    BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
    String str = br.readLine();
     
    String[] strAry = str.split(" ");
     
    int W = Integer.parseInt(strAry[0]);
    int H = Integer.parseInt(strAry[1]);
    int x = Integer.parseInt(strAry[2]);
    int y = Integer.parseInt(strAry[3]);
    int r = Integer.parseInt(strAry[4]);

    if(x-r >= 0 && x+r <= W && y-r >= 0 && y+r <= H){
    	System.out.println("Yes");
    }else{
    	System.out.println("No");
    }
  }
}

Measured memory_bytes: 24420
using System;
namespace 風のクロノアをすこれ{
    class OneShotをすこれ{
        static void Main(){
            int[,] c = new int[3,3];
            for(int i=0;i<3;i++){
                string[] cs = Console.ReadLine().Split();
                for(int j=0;j<3;j++){
                    c[i,j] = int.Parse(cs[j]);
                }
            }

            int[] a = {0,0,0};
            int[] b = {0,0,0};
            b[0] = c[0,0];
            a[1] = c[1,0] - b[0];
            a[2] = c[2,0] - b[0];
            b[1] = c[0,1] - a[0];
            b[2] = c[0,2] - a[0];

            for(int i=0;i<3;i++){
                for(int j=0;j<3;j++){
                    if(c[i,j]!=a[i]+b[j]){
                        Console.WriteLine("No");
                        return;
                    }
                }
            }
            Console.WriteLine("Yes");
        }
    }
}

Measured memory_bytes: 13140
#include <bits/stdc++.h>
#define fi(i, a, b) for(int i = a; i <= b; i++)
#define fid(i, a, b) for(int i = a; i >= b; i--)
#define TTT "BAI1"
#define maxn
using namespace std;
int m, d, res = 0;
int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(NULL);
    cout.tie(NULL);
    cin >> m >> d;
    fi(i, 1, m)
    fi(j, 1, d)
    {
        int x = j / 10;
        int y = j % 10;
        if(x * y == i && x >= 2 && y >= 2) res++;
    }
    cout << res;
}


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

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

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n;
  cin>>n;
  double t,a;
  double ma=100000000;
  double H[n+1],T[n+1];
  int k;
  cin>>t>>a;
  for(int i=0; i<n; i++){
    cin>>H[i];
    T[i]=t-0.006*H[i];
    if(ma>=abs(a-T[i])){
      ma=abs(a-T[i]);
      k=i;
    }
  }
  cout<<k+1<<endl;
}
 


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef unsigned long long ull;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<double, double> pdd;
const ll mod = 1e9 + 7;
//const ll mod = 998244353;
#define REP(i,n) for(int i=0;i<(int)n;++i)
//debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return 1; } return 0; }
template<class S, class T> ostream& operator << (ostream& os, const pair<S, T> v){
os << "(" << v.first << ", " << v.second << ")"; return os;
}
template<class T> ostream& operator << (ostream& os, const vector<T> v){
for(int i = 0; i < (int)v.size(); i++){if(i > 0){os << " ";} os << v[i];} return os;
}
template<class T> ostream& operator << (ostream& os, const vector<vector<T>> v){
for(int i = 0; i < (int)v.size(); i++){if(i > 0){os << endl;} os << v[i];} return os;
}
string num2bit(ll num, ll len){
    string bit = "";
    REP(i, len){
    bit += char('0'+(num>>i & 1));
    }
    return bit;
}

template <std::uint_fast64_t Modulus> class modint {
  // long long から modint を作るときは必ず正の数にしてからコンストラクタに入れること！ 
  // そうしないとバグります
  using u64 = std::uint_fast64_t;

public:
  u64 a;

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

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


    ll N, K;
    cin >> N >> K;
    mint res = 0;

    for(int P=K;P<=N+1;P++){
        mint tmp1 = mint(P)*(P-1)/2;
        mint tmp2 = mint(N)*(N+1)/2;
        mint tmp3 = mint(N-P)*(N-P+1)/2;
        mint tmp4 = tmp2 - tmp3;
        //dump(tmp1.value())
        //dump(tmp4.value())

        res += (tmp2-tmp3) - tmp1 + 1;
    }
    cout << res.value() << endl;

    return 0;
}

Measured memory_bytes: 3656
#include <bits/stdc++.h>
#include <vector>
#include <algorithm>
#include <cmath>

using namespace std;

int a, b, dep=0, mrk;
int up;
vector< vector<int> > board;
vector<int> h;
vector<int> w;

void pas(int x, int y){
	if(0<x){
		if(board[x][y]+1<board[x-1][y]){
			h.emplace_back(x-1);
			w.emplace_back(y);
			up++;
		}
		board[x-1][y]=min(board[x-1][y], board[x][y]+1);
	}

	if(x+1<a){
		if(board[x][y]+1<board[x+1][y]){
			h.emplace_back(x+1);
			w.emplace_back(y);
			up++;
		}
		board[x+1][y]=min(board[x+1][y], board[x][y]+1);
	}

	if(0<y){
		if(board[x][y]+1<board[x][y-1]){
			h.emplace_back(x);
			w.emplace_back(y-1);
			up++;
		}
		board[x][y-1]=min(board[x][y-1], board[x][y]+1);
	}

	if(y+1<b){
		if(board[x][y]+1<board[x][y+1]){
			h.emplace_back(x);
			w.emplace_back(y+1);
			up++;
		}
		board[x][y+1]=min(board[x][y+1], board[x][y]+1);
	}
}

	/*board[h-1][w]=min(board[h-2][w], board[h][w], board[h-1][w-1], board[h-1][w+1]);
	board[h+1][w]=min(board[h][w], board[h+2][w], board[h+1][w-1], board[h+1][w+1]);
	board[h][w-1]=min(board[h-1][w-1], board[h+1][w-1], board[h][w-2], board[h][w]);
	board[h][w+1]=min(board[h-1][w+1], board[h+1][w+1], board[h][w], board[h][w+2]);*/

int main(){

	char s;

	cin>> a >> b;
	board.resize(a);
	for(int i=0;i<a;i++) board[i].resize(b);

	for(int i=0;i<a;i++){
		for(int j=0;j<b;j++){
			cin>> s;
			if(s=='#'){
				board[i][j]=0;
				h.emplace_back(i);
				w.emplace_back(j);
			}else{
				board[i][j]=5000;
			}
		}
	}

	while(1){
		mrk=h.size();
		up=0;
		for(int i=0;i<mrk;i++) pas(h[i], w[i]);
		h.erase(h.begin(), h.begin() + mrk-1);
		w.erase(w.begin(), w.begin() + mrk-1);

	/*for(int i=0;i<a;i++){
		for(int j=0;j<b;j++){
			cout<< board[i][j] << " ";
		}
		cout<< endl;
	}
	cout<< endl;*/

		if(up==0) break;
		dep++;
	}

	cout<< dep << endl;

}

Measured memory_bytes: 13712
#include <iostream>
#include <vector>
#include <string>
#include <cstring>
#include <queue>
#include <set>
#include <stack>
#include <map>
#include <unordered_map>
#include <cmath>
#include <utility> // pair make_pair
#include <algorithm>
#include <functional>
#include <iomanip>
#include <numeric>
#include <climits> // LLONG_MAX, LLONG_MIN, INT_MIN, INT_MAX
#include <assert.h>

#define m0(x) memset(x,0,sizeof(x))
#define m1(x) memset(x,63,sizeof(x))
#define fill(x,y) memset(x,y,sizeof(x))
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define ll long long
//#define int ll
#define INF INT_MAX/10
#define MOD 1000000007

using namespace std;
using Pi = pair<int, int>;
using Graph = vector<vector<int> >;
using WeightGraph = vector<vector<Pi> >;

int Input[100100];

int dp[5005][5005];

int main() {
  int N; cin >> N;
  string S; cin >> S;
  
  for (int i = N-1; i >= 0; i--) {
    for (int j = N-1; j >= 0; j--) {
      if (S[i] == S[j]) {
        dp[i][j] += dp[i+1][j+1] + 1;
      } 
    }
  }

  int ans = 0;
  rep(i, N) rep(j, N) {
    if (i >= j) continue; // i < j;
    int now = min(dp[i][j], j-i);
    ans = max(ans, now);
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 98048
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
int main() {
  ll a;
  cin>>a;
  vector<ll>vec(a);
  for(ll i=0;i<a;i++){
    cin>>vec.at(i);
  }
  sort(vec.begin(),vec.end());
  cout<<vec.at(a-1)-vec.at(0)<<endl;
  return 0;
}


Measured memory_bytes: 3608
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
int main(){
    int n,m;
    while(cin>>n>>m){
        if(n+m==0)break;
        vector<int> sum(n,0);
        for(int i=0;i<m;i++){
            for(int j=0;j<n;j++){
                int score;cin>>score;
                sum[j]+=score;
            }
        }
        cout<<(*max_element(sum.begin(),sum.end()))<<endl;
    }
}


Measured memory_bytes: 3008
import java.io.PrintWriter;
import java.util.Scanner;

public class Main {
    void solve(Scanner sc, PrintWriter pw) {
        int a = sc.nextInt();
        pw.println(a >= 30 ? "Yes" : "No");
    }
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        PrintWriter pw = new PrintWriter(System.out);
        new Main().solve(sc, pw);
        pw.flush();
        pw.close();
        sc.close();
    }
}


Measured memory_bytes: 35712
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int k;
  	cin>>k;
	string s;
  	cin>>s;
	if(s.size() > k){
      	for(int i=0;i<k;i++)
         	cout<<s[i];
      	cout<<"...";
    }
	else{
		cout<<s;
	}
	return 0;
}


Measured memory_bytes: 3616
#include "bits/stdc++.h"
using namespace std;
#define Would
#define you
#define all(n)  n.begin(),n.end()
#define rall(n) n.rbegin(),n.rend()
typedef long long ll;
const ll INF = 1e18;
const ll MOD = 1e9 + 7;
const double EPS = 1e-10;
const double pi = acos(-1);//3.1415926535897932384626433832795028...
const ll SIZE = 1 << 17;
int dx[] = { 1,0,-1,0 }, dy[] = { 0,1,0,-1 }, alp[30];
ll fac[200005], finv[200005], inv[200005];
vector<ll>dij;
struct edge { ll to, cost; };
vector<vector<edge> >G;

ll mod_pow(ll a, ll b) {
	ll res = 1, mul = a;
	for (int i = 0; i < 31; ++i) {
		if (b >> i & 1) {
			res *= mul;
			res %= MOD;
		}
		mul = (mul * mul) % MOD;
	}
	return res;
}

void addedge(int from, int to, int cost) {
	G[from].push_back({ to,cost });
	G[to].push_back({ from,cost });
}

template<typename T>
vector<T> make_v(size_t a) { return vector<T>(a); }

template<typename T, typename... Ts>
auto make_v(size_t a, Ts... ts) {
	return vector<decltype(make_v<T>(ts...))>(a, make_v<T>(ts...));
}

template<typename T, typename V>
typename enable_if<is_class<T>::value == 0>::type
fill_v(T & t, const V & v) { t = v; }

template<typename T, typename V>
typename enable_if<is_class<T>::value != 0>::type
fill_v(T & t, const V & v) {
	for (auto& e : t) fill_v(e, v);
}

template<typename T>
void outp(vector<T>v) {
	for (int i = 0; i < v.size(); ++i) {
		cout << v[i];
		if (i != v.size() - 1) { cout << " "; }
	}
}

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

struct UnionFind {
private:
	const int n;
	int _size;
	vector<int>uf;
public:
	UnionFind(int _n) :n(_n), _size(_n), uf(_n, -1) {}
	int find(int x) { return (uf[x] < 0) ? x : uf[x] = find(uf[x]); }
	bool same(int x, int y) { return find(x) == find(y); }
	int size(int x) { return -uf[find(x)]; }
	int size() { return _size; }
	void unite(int x, int y) {
		x = find(x);
		y = find(y);
		if (x == y) { return; }
		--_size;
		if (uf[y] < uf[x]) { swap(x, y); }
		uf[x] += uf[y];
		uf[y] = x;
	}
};

int main() {
	int a, b;
	cin >> a >> b;
	UnionFind uf(a);

	for (int i = 0; i < b; ++i) {
		int n, m, mm;
		cin >> n >> m >> mm;
		if (n == 0) { uf.unite(m, mm); }
		else { cout << uf.same(m, mm) << endl; }
	}
}


Measured memory_bytes: 3124
from string import ascii_lowercase


def solve(s):
    if len(s) < 26:
        for c in ascii_lowercase:
            if c not in s:
                return s + c

    while s:
        pi = ascii_lowercase.index(s[-1])
        s = s[:-1]
        for c in ascii_lowercase[pi + 1:]:
            if c not in s:
                return s + c
    return -1


s = input()
print(solve(s))


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

typedef long long ll;
const ll InF = 1e15;

int main() {
    int n;
    cin>>n;
    int ans = n;
    for (int i = 0; i <= n; i++) {
        int tmp = 0;
        int t = i;
        while(t > 0) tmp += t % 6, t /= 6;
        t = n - i;
        while (t > 0) {
            tmp += t % 9;
            t /= 9;
        }
        ans = min(ans,tmp);
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		Sort st = new Sort();
		int n = sc.nextInt();
		int[][] array = new int[n][3];
		for (int i = 0; i < array.length; i++) {
			String str = sc.next();
			try {
				array[i][0] = Integer.parseInt(str.substring(1, str.length()));
				array[i][2] = (int) str.charAt(0);
				array[i][1] = i;
			} catch (Exception e) {
				break;
			}
		}
		int[][] array2 = new int[array.length][array[0].length];
		for (int i = 0; i < array2.length; i++) {
			for (int j = 0; j < array2[0].length; j++) {
				array2[i][j] = array[i][j];
 			}
		}
		st.bubble(array);
		st.select(array2);
	}

}

class Sort {
	Scanner sc;

	public void bubble(int[][] array) {
		int count = 0;
		boolean flag = true;
		while (flag) {
			flag = false;
			for (int i = 1; i < array.length; i++) {
				if (array[i][0] < array[i - 1][0]) {
					swap(array, i, i - 1);
					count++;
					flag = true;
				}
			}
		}
		for (int i = 0; i < array.length - 1; i++) {
			System.out.print(((char) array[i][2]) + "" + array[i][0] + " ");
		}
		System.out.println((char)array[array.length - 1][2] + "" + array[array.length - 1][0]);
		if (judge(array)) {
			System.out.println("Stable");
		} else {
			System.out.println("Not stable");
		}
	}

	public void select(int[][] array) {
		int minJ = 0;
		for (byte i = 0; i < array.length; i++) {
			minJ = i;
			for (byte j = i; j < array.length; j++) {
				if (array[j][0] < array[minJ][0]) {
					minJ = j;
				}
			}
			if (i != minJ) {
				swap(array, minJ, i);
			}
		}
		for (int i = 0; i < array.length - 1; i++) {
			System.out.print(((char) array[i][2]) + "" + array[i][0] + " ");
		}
		System.out.println((char)array[array.length - 1][2] + "" + array[array.length - 1][0]);
		if (judge(array)) {
			System.out.println("Stable");
		} else {
			System.out.println("Not stable");
		}
	}

	public boolean judge(int[][] array) {
		for (int i = 1; i < array.length; i++) {
			if (array[i][0] == array[i - 1][0] && array[i][1] < array[i - 1][1]) {
				return false;
			}
		}
		return true;
	}

	public void swap(int[][] array, int x, int y) {
		for (int i = 0; i < array[0].length; i++) {
			int tmp = array[x][i];
			array[x][i] = array[y][i];
			array[y][i] = tmp;
		}
	}
}



Measured memory_bytes: 26276
#include<bits/stdc++.h>
using namespace std;
#define REP(i,n) for(int i=0;i<(n);i++)
typedef long long LL;
typedef pair<int , int > P;
const LL maxn=200005;
const LL INF=1e13+5;
LL arr[maxn];

int main()
{
    int N;
    cin >> N;
    for(int i=0;i<N;i++)
        cin >> arr[i];
    LL sum=0;
    LL max1=arr[0];
    for(int i=0;i<N;i++)
    {
        if(max1<arr[i])
            max1=arr[i];
        if(max1>arr[i])
            sum+=max1-arr[i];
    }
    cout << sum;
}


Measured memory_bytes: 5148
#include<bits/stdc++.h>
using namespace std;
#define int long long int
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define r0 return 0;
#define f(k,i,n,j) for(ll k=i;k<=n;k=k+j)
#define cin(a) cin>>a;
#define loop while(t--)
#define vi vector<int>
#define vii vector<long long int>
#define SORT(v) sort(v.begin(),v.end());
#define mod (1e9+7)
#define crap ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define endl "\n"
signed main()
{
    crap;
    int n,max=0;
    cin>>n;
    string s[n+1];
    string ans[n+1];
    map<string,int> m;
    for(int i=0;i<n;i++)
    {
        cin>>s[i];
        m[s[i]]++;
        if(m[s[i]]>max){
        max=m[s[i]];
        }
    }
    sort(s,s+n);
    for(int i=0;i<n;i++)
    {
        if(m[s[i]]==max){
        cout<<s[i]<<endl;
        m[s[i]]=0;
        //s[i]="";
        }
    }
    return 0;
}

Measured memory_bytes: 27044
#include<iostream>
#include<cmath>
#include<cstdio>

using namespace std;

int main(){
	double sumX = 0;
	double sumY = 0;
	double d,rad = 3.1415/2;
	double theta;
	while(1){

		cin >> d ;
		getchar();
		cin >> theta;
		if(d == 0 and theta == 0) break;
		sumX += d * cos(rad);
		sumY += d * sin(rad);
		rad -= (3.1415*theta)/180.0;
	}

	cout << (int)sumX << endl;
	cout << (int)sumY << endl;
	return 0;
}

Measured memory_bytes: 1224
#include<bits/stdc++.h>
using namespace std;
string s;
int to[200001];
int ans[200001];
int main(){
    cin>>s;
    for(int i=0;i<s.size();i++){
        int c=i,d=i;
        while(s[c]==s[i]) c++;
        to[i]=(s[i]=='L')?i-1:c;
        c--;
        while(d<=c) to[d]=to[i],d++;
        i=c;
    }
    for(int i=0;i<s.size();i++)
        ans[(abs(to[i]-i)%2?to[i]+1-(s[i]=='R')*2:to[i])]++;
    for(int i=0;i<s.size();i++)
        cout<<ans[i]<<" ";
    cout<<endl;
	return 0;
}

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

int main(){
  long long int a;
  double b;
  int new_b;
  long long int sol;
  
  cin >> a>>b;
//  cout << b<<endl;
  
  new_b = (int)(b*100+0.5);
//  cout << new_b<<endl;
  
  sol = a*new_b;
  sol = sol/100;
  
  cout << sol << endl;
  return 0;
  
}



Measured memory_bytes: 3720
#include <bits/stdc++.h>
using namespace std;
int main()
{
  int n, m;
  cin >> n >> m; 
 map<int, int> mm;
  for(int i=0; i<n; i++){
    int a, b;
    cin >> a >> b;
     mm[a] += b;
  }  
  map<int, int>::iterator it;
  long long price = 0;
  for( it=mm.begin(); it!=mm.end(); it++){
    long long num =it->second ;
    if(num<=m){
      price += (long long)it->first* num;
      m-= num;
    }
    else{
      price += (long long)it->first* m;
      break;
    }
  }
  cout << price << endl; 
    
  return 0;
}


Measured memory_bytes: 4992
#include<stdio.h>
#include<math.h>
#include<algorithm>
#include<queue>
#include<deque>
#include<stack>
#include<string>
#include<string.h>
#include<vector>
#include<set>
#include<map>
#include<bitset>
#include<stdlib.h>
#include<cassert>
#include<time.h>
#include<bitset>
using namespace std;
const long long mod=1000000007;
const long long inf=mod*mod;
const long long d2=(mod+1)/2;
const double EPS=1e-6;
const double PI=acos(-1.0);
int ABS(int a){return max(a,-a);}
long long ABS(long long a){return max(a,-a);}
char in[60][60];
int dx[]={1,0,-1,0};
int dy[]={0,1,0,-1};
int bfs[60][60];
int main(){
	int a,b;scanf("%d%d",&a,&b);
	for(int i=0;i<a;i++)scanf("%s",in[i]);
	for(int i=0;i<a;i++)for(int j=0;j<b;j++)bfs[i][j]=mod;
	bfs[0][0]=0;
	int cnt=0;
	for(int i=0;i<a;i++)for(int j=0;j<b;j++)if(in[i][j]=='.')cnt++;
queue<pair<int,int> >Q;
	Q.push(make_pair(0,0));
	while(Q.size()){
		int row=Q.front().first;
		int col=Q.front().second;Q.pop();
		for(int i=0;i<4;i++){
			int tr=row+dx[i];
			int tc=col+dy[i];
			if(tr<0||tr>=a||tc<0||tc>=b)continue;
			if(in[tr][tc]=='#')continue;
			if(bfs[tr][tc]==mod){
				bfs[tr][tc]=bfs[row][col]+1;
				Q.push(make_pair(tr,tc));
			}
		}
	}
	if(bfs[a-1][b-1]==mod)printf("-1\n");
	else printf("%d\n",cnt-1-bfs[a-1][b-1]);
}

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

//{ START
using namespace std;
#define int int64_t
#define rep(i, a, n) for (int i = (a); i < (n); ++i)
#define reps(i, a, n) for (int i = (a); i > (n); --i)
#define arep(i, x) for (auto &&i : (x))
#define irep(i, x) for (auto i = (x).begin(); i != (x).end(); ++i)
//降順はgreater<T>()
#define all(x) (x).begin(), (x).end()
#define rv(s) reverse((s).begin(), (s).end())
// gcd lcmはそのままok
#define gcd(a, b) __gcd(a, b)
#define bits(n) (1LL << (n))
#define pcnt(x) __builtin_popcountll(x)
//配列内等要素削除
#define unique(x) (x).erase(unique((x).begin(), (x).end()), (x).end())
#define Fixed(n) fixed << setprecision(n)
//総和
#define sowa(n) ((n) * ((n) + 1)) / 2
#define pb(x, a) (x).push_back(a)
#define fb(x, a) (x).push_front(a)
#define eb(x, a) (x).emplace_back(a)
#define cauto const auto &
using P = pair<int, int>;
using Graph = vector<vector<P>>;
template <class T>  //昇順
using min_heap = priority_queue<T, vector<T>, greater<T>>;
template <class T>  //降順
using max_heap = priority_queue<T>;
template <class A, class B>
using umap = unordered_map<A, B>;
template <class A>
using uset = unordered_set<A>;
template <typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val) {  //多次元初期化
  std::fill((T *)array, (T *)(array + N), val);
}
template <class T>
bool chmax(T &a, const T &b) {  //最大値更新 返り値はbool
  if (a < b) {
    a = b;
    return 1;
  }
  return 0;
}
template <class T>
bool chmin(T &a, const T &b) {  //最小値更新 返り値はbool
  if (b < a) {
    a = b;
    return 1;
  }
  return 0;
}
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};
constexpr int INF = 0x3f3f3f3f;
constexpr int LINF = 0x3f3f3f3f3f3f3f3fLL;
constexpr int mod1 = 1e9 + 7;
constexpr int mod2 = 998244353;
//} END

signed main() {
  cin.tie(nullptr);
  ios_base::sync_with_stdio(false);

  int n, ans = 0;
  cin >> n;
  map<int, int> x;

  rep(i, 0, n) {
    int a;
    cin >> a;
    ans += a;
    x[a - 1]++;
  }
  // cout << ans << ' ';

  int q;
  cin >> q;
  rep(i, 0, q) {
    int a, b;
    cin >> a >> b;
    if (x.find(a - 1) != x.end()) {
      int tmp = x[a - 1];
      x[a - 1] = 0;
      x[b - 1] += tmp;
      ans += (b * tmp) - (a * tmp);
    }
    // arep(i, x) cout << i.first << ' ' << i.second << '\n';
    cout << ans << '\n';
  }

  return 0;
}

Measured memory_bytes: 8604
#include "bits/stdc++.h"
using namespace std;
 
////////////// Prewritten code follows. Look down for solution. ////////////////

#define fs first
#define sc second
#define pb push_back
#define mp(a, b) make_pair(a, b)
#define len(x) ((int)(x).size())
#define all(x) (x).begin(), (x).end()
#define fastio ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);

typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef long long ll;
typedef pair<ll, ll> pll;

template<typename T>
const T INF = (is_same<T, int>::value ? 1e9 : 1e18);
template<typename T>
inline T mod(T n, T mod){ T res = n%mod; if(res < 0) res += mod; return res; }
 
////////////////////////// Solution starts below. //////////////////////////////

int vx[] = {0, 0, -1, 1};
int vy[] = {1, -1, 0, 0};

int dist[25][25];
bool vis[25][25];
char grid[25][25];
int n, m;

int bfs(int sti, int stj){
    for(int i = 0; i < n; i++){
      for(int j = 0; j < m; j++){
        dist[i][j] = 0;
        vis[i][j] = false;
      }
    }
    queue<pii> q;
    q.emplace(sti, stj);
    vis[sti][stj] = true;
    dist[sti][stj] = 0;
    while(!q.empty()){
      int x = q.front().fs;
      int y = q.front().sc;
      q.pop();
      for(int i = 0; i < 4; i++){
        int nx = x+vx[i];
        int ny = y+vy[i];
        if(nx >= 0 and nx < n and ny >= 0 and ny < m){
          if(!vis[nx][ny] and grid[nx][ny] != '#'){
            q.emplace(nx, ny);
            dist[nx][ny] = dist[x][y]+1;
            vis[nx][ny] = true;
          }
        }
      }
    }
    int ans = 0;
    for(int i = 0; i < n; i++){
      for(int j = 0; j < m; j++){
        ans = max(ans, dist[i][j]);
      }
    }
    return ans;
  }

int main(){
  fastio;
  cin >> n >> m;
  for(int i = 0; i < n; i++){
    for(int j = 0; j < m; j++){
      cin >> grid[i][j];
    }
  }
  int ans = 0;
  for(int i = 0; i < n; i++){
    for(int j = 0; j < m; j++){
      if(grid[i][j] == '.') ans = max(ans, bfs(i, j));
    }
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
float x[100],y[100],t,u,a,b,s;n,i,j,k,c,z;main(m){for(;m=scanf("%d",&n),z=i=n;printf("%d\n",m))for(;!z?j=--i:scanf("%f,%f",x+z,y+--z);)for(;!z&&j--;)for(u=acos(hypot(a=x[j]-x[i],b=y[j]-y[i])/2),s=1,t=atan2(b,a);c=0,u<9&&s+3;s-=2)for(a=x[i]+cos(b=t+s*u),b=y[i]+sin(b),k=n;k--;)hypot(a-x[k],b-y[k])<1.1&&++c>m?m=c:0;}

Measured memory_bytes: 0
X , Y = map(int,input().split())

if X == 1 and Y == 1:
    print("1000000")

elif X == 1 and Y == 2:
    print("500000")

elif X == 1 and Y == 3:
    print("400000")

elif X == 2 and Y == 3:
    print("300000")

elif X == 2 and Y == 2:
    print("400000")
   
elif X == 3 and Y == 3:
    print("200000")

elif X == 3 and Y == 2:
    print("300000")
    
elif X == 2 and Y == 1:
    print("500000")

elif X == 3 and Y == 1:
    print("400000")

elif X == 1 and Y >= 4:
    print("300000")

elif X == 2 and Y >= 4:
    print("200000")  

elif X == 3 and Y >= 4:
    print("100000")

elif X >= 4 and Y == 1:
    print("300000")

elif X >= 4 and Y == 2:
    print("200000")

elif X >= 4 and Y == 3:
    print("100000")

else:
    print("0")


Measured memory_bytes: 38256
#include<stdio.h>
#include<string.h>
#pragma GCC optimize("O3")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
static inline void PUT(char c)
{
  static char buf[1<<15],*ptr=buf;
  if(ptr==buf+strlen(buf)||c==0){fwrite(buf,1,ptr-buf,stdout),ptr=buf;}*ptr++=c;
}
static inline int IN(void)
{
  int x=0,f=0,c=getchar();while(c<48||c>57){f^=c==45,c=getchar();}
  while(c>47&&c<58){x=x*10+c-48,c=getchar();}return f?-x:x;
}
static inline void OUT(long a)
{
  if(a<0)PUT('-'),a=-a;
  int d[40],i=0;do{d[i++]=a%10;}while(a/=10);
  while(i--){PUT(d[i]+48);}PUT('\n');
}
int main()
{
  int N=IN(),Q=IN(),H=N,W=N,col[N+1],row[N+1];long b=1l*(N-2)*(N-2);
  for(int i=1;i<=N;++i)row[i]=col[i]=N;
  while(Q--)
  {
    int i,type=IN(),x=IN();
    if(type==1){if(x<W){i=x;while(i<W){col[i++]=H;}W=x;}b-=col[x]-2;}
    else{if(x<H){i=x;while(i<H){row[i++]=W;}H=x;}b-=row[x]-2;}
  }
  return OUT(b),0;
}

Measured memory_bytes: 3032
package main

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

func main() {

	// map left values
	// sort

	m := make(map[int]int)

	scanner := bufio.NewScanner(os.Stdin)
	scanner.Scan()
	nk := strings.Split(scanner.Text(), " ")
	k, _ := strconv.Atoi(nk[1])
	for scanner.Scan() {
		ab := strings.Split(scanner.Text(), " ")
		a, _ := strconv.Atoi(ab[0])
		b, _ := strconv.Atoi(ab[1])
		m[a] += b
	}
	keys := make([]int, 0)
	for k := range m {
		keys = append(keys, k)
	}
	sort.Ints(keys)
	x := 0
	for k > 0 {
		k -= m[keys[x]]
		x++
	}
	fmt.Println(keys[x-1])
}

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

void solve() {
  int a, b;
  cin >> a >> b;

  if (a + b == 15) {
    cout << "+" << endl;
  } else if (a * b == 15) {
    cout << "*" << endl;
  } else {
    cout << "x" << endl;
  }
}

int main() {
  solve();
}

Measured memory_bytes: 256
// A - 台形 / Trapezoids https://atcoder.jp/contests/abc045/tasks/abc045_a

  import io.Source

  object Main extends App {
    val xs = Source.stdin.getLines()
    val a = xs.next().toInt
    val b = xs.next().toInt
    val h = xs.next().toInt

    println(solve(a, b, h))

    def solve(a: Int, b: Int, h: Int): String = {
      ((a + b) * h / 2).toString
    }
  }


Measured memory_bytes: 25412
#include <iostream>

using namespace std;

int ceil(int numerator, int denominator)
{
    int quotient = numerator/denominator;
    int remainder = numerator%denominator;

    return (quotient + (remainder != 0));
}

int main()
{
    int n, k;
    cin >> n >> k;
    cout << (k <= ceil(n,2) ? "YES\n" : "NO\n");
    return 0;
}


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

#define pb push_back
#define vi vector < int >
#define ii pair < int, int >
#define vii vector < pair < int, int > >
#define vvi vector < vector < int > >
#define ll long long
#define X first
#define Y second
#define mp make_pair
#define FOR( i, lo, hi ) for( int i = (lo);i < (hi);i++ )
#define DFOR( i, hi, lo ) for( int i = (hi);i >= (lo);i-- )
#define pqueue priority_queue

using namespace std;

const int MAXN = 1e5 + 10;

int n;
string s;
int ans[ MAXN ];

int main()
{
	cin >> s;
	n = s.size();
	vi cycles;
	int lo = 0, hi = 0;
	FOR( i, 1, n )
	{
		if ( s[ i ] == s[ i - 1 ] )
			hi++;
		else
		{
			int uk = hi - lo + 1;
			if ( s[ i - 1 ] == 'R' )
			{
				int even = 0, odd = 0;
				if ( uk % 2 == 0 )
				{
					even = uk / 2;odd = uk - even;
				}
				else
				{
					even = uk / 2 + ( uk % 2 );odd = uk - even;
				}
				ans[ hi ] += even;
				ans[ hi + 1 ] += odd;
				//cout << uk << "\n";
			}
			else
			{
				int even = 0, odd = 0;
				if ( uk % 2 == 0 )
				{
					even = uk / 2;odd = uk - even;
				}
				else
				{
					even = uk / 2 + ( uk % 2 );odd = uk - even;
				}
				ans[ lo ] += even;
				ans[ lo - 1 ] += odd;
				//cout << uk << "\n";
			}
			lo = i;hi = i;
		}
	}
	
	int uk = hi - lo + 1;
	if ( s[ n - 1 ] == 'R' )
	{
		int even = 0, odd = 0;
		if ( uk % 2 == 0 )
		{
			even = uk / 2;odd = uk - even;
		}
		else
		{
			even = uk / 2 + ( uk % 2 );odd = uk - even;
		}
		ans[ hi ] += even;
		ans[ hi + 1 ] += odd;
		//cout << uk << "\n";
	}
	else
	{
		int even = 0, odd = 0;
		if ( uk % 2 == 0 )
		{
			even = uk / 2;odd = uk - even;
		}
		else
		{
			even = uk / 2 + ( uk % 2 );odd = uk - even;
		}
		ans[ lo ] += even;
		ans[ lo - 1 ] += odd;
		//cout << uk << "\n";
	}

	FOR( i, 0, n )
	{
		cout << ans[ i ] << " ";
	}
	cout << "\n";
	return 0;
}


Measured memory_bytes: 1024
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <cctype>
#include <climits>
#include <string>
#include <bitset>
using namespace std;
typedef long double ld;
typedef long long int ll;
typedef unsigned long long int ull;
typedef vector<int> vi;
typedef vector<char> vc;
typedef vector<string> vs;
typedef vector<ll> vll;
typedef vector<pair<int,int> > vpii;
typedef vector<vector<int> > vvi;
typedef vector<vector<char> > vvc;
typedef vector<vector<string> > vvs;
typedef vector<vector<ll> > vvll;
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define fin(ans) cout<<(ans)<<endl
#define STI(s) atoi(s.c_str())
#define mp(p,q) make_pair(p,q)
#define pb(n) push_back(n)
#define Sort(a) sort(a.begin(),a.end())
#define Rort(a) sort(a.rbegin(),a.rend())
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;}
const int P = 1000000007;
const int INF = INT_MAX;
const long long LLINF = 1LL<<60;
//g++ -std=c++1z main.cpp
//.\a.exe

int main(void){ios::sync_with_stdio(false);cin.tie(0);
////////////////////////////////////////////////////////
int n,ans=0;
cin >> n;
int a[n];
for(int i=1;i<n+1;i++){
	cin >> a[i];
}
int i=1;
while(i!=2){
   i = a[i];
   ans++;
   if(ans==n){
	   ans = -1;
	   break;
   }
}

cout << ans << endl;





////////////////////////////////////////////////////////
return 0;}

Measured memory_bytes: 640
import sys
from math import *
from fractions import gcd
readints=lambda:map(int, input().strip('\n').split())



m,k = readints()

if k>=2**m:
    print(-1)
    sys.exit(0)


if m==1:
    if k==0:
        print('0 0 1 1')
    else:
        print(-1)
    sys.exit(0)


ans = []
for i in range(2**m):
    if i!=k:
        ans.append(i)

ans.append(k)
i=2**m-1
while i>=0:
    if i!=k:
        ans.append(i)
    i-=1
ans.append(k)


print(' '.join([str(i) for i in ans]))


Measured memory_bytes: 33952
#include<bits/stdc++.h>
using namespace std;
#define N 100005
int n,m,d[N],M,c[N];
vector <int> G[N],T[N],v;
queue <int> Q;
int main()
{
    cin>>n>>m;
    for(int i=1;i<=m;i++)
    {
        int x,y;
        cin>>x>>y;
        G[x].push_back(y);
        T[y].push_back(x);
        d[y]++;
    }
    for(int i=1;i<=n;i++)
        if(d[i]==0)
            Q.push(i);
    while(!Q.empty())
    {
        int p=Q.front();
        Q.pop();
        for(int i=0;i<G[p].size();i++)
        {
            d[G[p][i]]--;
            if(d[G[p][i]]==0)
                Q.push(G[p][i]);
        }
        v.push_back(p);
        for(int i=0;i<T[p].size();i++)
        {
            int q=T[p][i];
            if(c[q]+1>c[p]) c[p]=c[q]+1;
            if(c[p]>M) M=c[p];
        }
    }
    cout<<M;
}


Measured memory_bytes: 12544
use proconio::{fastout, input};
#[allow(unused_mut)]
#[fastout]
fn main() {
    input! {
        x: usize,
        y: usize
    }
    for t in 0..=x {
        let tn = t * 4;
        let cn = (x - t) * 2;
        if tn + cn == y {
            println!("Yes");
            return;
        }
    }
    println!("No");
}


Measured memory_bytes: 2176
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int mod = 1000000007;

ll quickpow(ll a,ll b){
    ll ans=1;
    while(b){
        if(b&1){
            ans=(ans*a)%mod;
        }
        b/=2;
        a=a*a%mod;
    }
    return ans%mod;
}

int main() {
    ll n,a,b;
    cin >> n >> a >> b;
    a = min(a,n-a);
    b = min(b,n-b);
    ll sum = quickpow(2,n) - 1;
    ll x = 1,y = 1;
    for(int i = n; i > n - a; i--)
		x = (x*i) % mod;
	for(int i = 1; i <= a; i++)
		y = (y*i) % mod;
    sum = (sum+mod-quickpow(y,mod-2)*x%mod)%mod;
    x = 1,y = 1;
    for(int i = n; i > n - b; i--)
		x = (x*i) % mod;
	for(int i = 1; i <= b; i++)
		y = (y*i) % mod;
    sum = (sum+mod-quickpow(y,mod-2)*x%mod)%mod;
    cout << sum << endl;
}

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

typedef long long ll;

int main()
{
    int n;
    while(cin >> n && n) {
        int a = 0, b = 0, c, d;
        for(int i = 0; i < n; i++) {
            cin >> c >> d;
            if(c > d) {
                a += (c + d);
            } else if(c == d) {
                a += c;
                b += d;
            } else {
                b += (c + d);
            }
        }
        cout << a << " " << b << endl;
    }
}

Measured memory_bytes: 0
#coding: UTF-8
if __FILE__ == $0
  while line = gets
    initial_debt = 100000
    weeks = line.split(" ")[0].to_i

    total_debt = initial_debt;
    weeks.times{|week|
      total_debt += ((total_debt * 0.05) / 1000).ceil * 1000
    }
    puts total_debt
  end
end

Measured memory_bytes: 2284
require 'set'; require 'prime'; require 'pp'
INF=Float::INFINITY; MOD=10**9+7
n = gets.chomp.to_i
sx = Array.new(n)
sy = Array.new(n)
n.times do |i|
  x, y = gets.chomp.split.map(&:to_i)
  sx[i] = x - y
  sy[i] = x + y
end

puts [sx.max - sx.min, sy.max - sy.min].max


Measured memory_bytes: 17696
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
#include<cmath>
#include<limits>
#define ll long long
#define ALL(x) (x).begin(),(x).end()
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define int_INF 2147483647
#define pint_INF 2000000000
#define ll_INF 	9223372036854775807
#define MOD 1000000007
#define vi vector<int>
#define vvi vector<vector<int>>
#define vvc vector<vector<char>>
#define vll vector<long long>
#define pii pair<int,int>
#define vpii vector<pair<int,int>>
#define sysp system("PAUSE")
#define pno cout << "no" << endl
#define pyes cout << "yes" << endl
#define pYes cout << "Yes" << endl
#define pNo cout << "No" << endl
using namespace std;

int main() {
	vector<ll> scoreboard(100000+1,0);
	ll current = 0;

	int N; cin >> N;
	for (int i = 0; i < N; i++) {
		int a; cin >> a;
		scoreboard[a]++;
		current += a;
	}

	int Q; cin >> Q;
	for (int times = 0; times < Q; times++) {
		ll b, c; cin >> b >> c;
		ll diff = (c - b) * scoreboard[b];
		scoreboard[c] += scoreboard[b];
		scoreboard[b] = 0;
		current += diff;
		cout << current << endl;
	}
}

Measured memory_bytes: 3804