akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
int a[1000000];
int main ()
{
    ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    int n;
    cin>>n;
    int num=0;
    int ret=0;
    a[0]=1e9;
    for (int i=1;i<=n;i++)
    {
        cin>>a[i];
        ret=max(ret,num);
        if (a[i]<=a[i-1])num++;
        else num=1;
        ret=max(ret,num);
    }
    cout<<ret-1<<endl;
}


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


int main(){
    long int N;
    //int N;
    int alpha;
    alpha = 26;
    cin >> N;

    char moji;
    vector<char> moji_list;
    vector<int> Y;
    int i;

    for(moji='a'; moji<='z'; ++moji){
        moji_list.push_back(moji);
    }

    /*
    for(i=0;i<=26;i++){
        cout << moji_list[i] << endl;
    }
    */

    long int syo;
    //int syo;
    if(N <= alpha){
        cout << moji_list[N-1] << endl;
        return 0;
    }
    while(N > alpha){
        syo = (long int)((N-1) / alpha);
        //syo = (N / alpha);
        if(N % alpha == 0){
            Y.push_back((int)(alpha));
        }
        else{
            Y.push_back((int)(N % alpha));
        }
        N = syo;
        //cout << N << endl;
    }

    Y.push_back((int)(N));

    for(i=Y.size()-1; i>=0; i--){
        //cout << Y[i] << endl;
        cout << moji_list[Y[i]-1];
        //cout << i << endl;
    }
    cout << endl;


    return 0;

}

Measured memory_bytes: 3168
/*
我的心脏怦怦跳，监管者就在附近
name:
Algorithm:
writer:Lxs(cdx)
place:
nothing is impossible
*/
//#pragma GCC optimize(3,"Ofast","inline")
//#include<bits/stdc++.h>
#include<string>
#include<iostream>
#include<cmath>
#include<set>
#include<stack>
#include<queue>
#include<unistd.h>
#include<stdio.h>
#include<cstring>
#define random(a,b) (rand()%(b-a+1)+a)
using namespace std;
bool prime(int x){
	 int i;
	 if(x<2) return 0;
	 for(i=2;i*i<=x;i++){
		if(x%i==0){return 0;}
	 }
	 return 1;
}
int main()
{
	int a;
	cin>>a;
	cout<<a*2*3.1415926<<endl;
	return 0;
}


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

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

    long long x, y;
    cin >> x >> y;

    int ans = 1;
    while(true){
        if(x * 2 <= y) ans++;
        else break;
        x *= 2;
    }

    cout << ans << endl;

    return 0;
}

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

using namespace std;

int main() {
  int n;
  scanf("%d", &n);
  if (n == 0) {
    puts("0");
    return 0;
  }
  const int base = -2;
  string s;
  while (n != 0) {
    int r = n % base;
    n /= base;
    if (r < 0) r += 2, n++;
    s += static_cast<char>('0' + r);
  }
  reverse(s.begin(), s.end());
  printf("%s\n", s.c_str());
  return 0;
}

Measured memory_bytes: 256
import math
import queue
import bisect
import heapq
import time
import itertools

mod = int(1e9+7)

def swap(a,b):
    return (b,a)

def gcd(a,b): #最大公約数
    if (a<b):
        a,b = swap(a,b)
    if (b==0):
        return a
    else:
        return gcd(b,a%b)

def lcm(a,b): #最小公倍数
    return a/gcd(a,b)*b

def divisors(a): # 約数列挙
    divisors = []
    for i in range(1,int(a**0.5)+1):
        if a%i==0:
            divisors.append(i)
            if i!=a//i:
                divisors.append(a//i)
    return divisors

def is_prime(a): #素数判定
    if a<2:
        return False
    elif a==2:
        return True
    elif a%2==0:
        return False
    sqrt_num = int(a**0.5)
    for i in range(3,sqrt_num+1,2):
        if a%i==0:
            return False
    return True

def prime_num(a): #素数列挙
    pn = [2]
    for i in range(3,int(a**0.5),2):
        prime = True
        for j in pn:
            if i%j==0:
                prime = False
                break
        if prime:
            pn.append(i)
    return pn

def prime_fact(a): #素因数分解
    sqrt = math.sqrt(a)
    res = []
    i = 2
    if is_prime(a):
        res.append(a)
    else:
        while a!=1:
            while a%i==0:
                res.append(i)
                a //= i
            i += 1
    return res

def main():
    s = input()
    ans = 0
    for i in range(3):
        if s[i]=='1':
            ans += 1
    print(ans)
    return

if __name__=='__main__':
    main()


Measured memory_bytes: 38892
#include<bits/stdc++.h>
using namespace std;
int main(){
    int n, k;
    cin >> n >> k;
    int A[n], dp[n];
    for(int i = 0;i < n;++i){
        cin >> A[i];
        dp[i] = INT_MAX;
    }
    dp[0] = 0;
    for(int i = 1; i < n;++i){
        for(int j = max(0, i - k); j < i;++j)
            dp[i] = min(dp[i], dp[j] + abs(A[i] - A[j]));
    }
    cout << dp[n - 1] << endl;
    return 0;
}

Measured memory_bytes: 1152
#include <algorithm>
#include <bitset>
#include <cstdio>
#include <cstdlib>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>
#define REP(i, b, n) for (Int i = b; i < Int(n); i++)
#define rep(i, n) REP(i, 0, n)
using namespace std;
using Int = long long;
Int inf = 1000000000000000001LL;
using vi = vector<Int>;
using vvi = vector<vi>;
using pii = pair<Int,Int>;
using mapis = unordered_map<Int,string>;
using mapii = unordered_map<Int,Int>;

Int GCD(Int a, Int b){
    if(b==0) return a;
    if(a < b) return GCD(b, a);
    unsigned r;
    while ((r=a%b)) {
        a = b;
        b = r;
    }
    return b;
}

Int LCM(Int a, Int b){
    return a*b/GCD(a,b);
}


int main() {
    Int a;
    string s;

    cin >> a >> s;

    if(a>=3200){
        cout << s << endl;
    }else{
        cout << "red" << endl;
    }




    return 0;
}

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

using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vint;
typedef vector<double> vdbl;
typedef vector<ll> vll;
typedef vector<string> vstr;
typedef vector<vector<int> > vvint;
typedef vector<pair<int, int> > vpii;
typedef vector<pair<ll, ll> > vpll;
typedef priority_queue<int, vector<int>, greater<int> > spqint; //小さい順に取り出し
typedef priority_queue<ll, vector<ll>, greater<ll> > spqll;     //小さい順に取り出し
typedef priority_queue<int, vector<int>, less<int> > bpqint;    //大きい順に取り出し
typedef priority_queue<ll, vector<ll>, less<ll> > bpqll;        //大きい順に取り出し

#define REP(i, n) for (int(i) = 0; (i) < (int)(n); i++)
#define FOR(i, a, b) for (int(i) = a; (i) < (int)b; i++)
#define IREP(i, v) for (auto i = v.begin(); i != v.end(); i++)
#define MOD 1000000007
#define NIL -1
#define FI first
#define SE second
#define MP make_pair
#define PB push_back
#define PF push_front
#define TS to_string
#define BS binary_search
#define LB lower_bound
#define UB upper_bound
#define NP next_permutation
#define ALL(v) (v).begin(), (v).end()
#define SZ(x) (ll) x.size()
#define SP(x) setprecision((ll)x)

const int INF = 1e9;
const ll LINF = 1e18;
const double EPS = 1e-9;
const double PI = M_PI;
const int dx[8] = {1, 0, -1, 0, 1, -1, 1, -1};
const int dy[8] = {0, 1, 0, -1, -1, 1, 1, -1};
ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; } //最大公約数
ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }     //最小公倍数

void yes()
{
    cout << "Yes" << endl;
}
void no()
{
    cout << "No" << endl;
}
//-----------------------------------------

//-----------------------------------------
int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    string s;
    cin >> s;
    int ans = 0;
    REP(i, 4)
    {
        if (s[i] == '+')
        {
            ans++;
        }
        else
        {
            ans--;
        }
    }
    cout << ans << endl;

    return 0;
}


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

#define M 1046527
#define NIL (-1)
#define L 14

class HashDictionary
{
private:
	char **hash;
public:
	HashDictionary() {
		//using STL vector should be better
		//vector< vector<int> > arr;
		//arr.resize(M);
		//arr[i].resize(L);
		hash = new char*[M];

		for (int i = 0; i < M; i++) {
			hash[i] = new char[L];
			hash[i][0] = '\0';
		}
	}

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

	long long GetKeyFromStr(char *str) {
		long long keySum = 0, p = 1, i;
		for (i = 0; i < strlen(str); i++) {
			keySum += p * (CharToInt(str[i]));
			p *= 5;
		}

		return keySum;
	}

	long long H1(long long key) { return key % M; }
	long long H2(long long key) { return 1 + (key % (M - 1)); }

	int FindFromHash(char *searchingStr) {
		long long key, i, h;
		key = GetKeyFromStr(searchingStr);
		for (i = 0; i < M ; i++) {
			h = ( H1(key) + i * H2(key) ) % M;
			if (strcmp(hash[h], searchingStr) == 0) return 1;
			else if (strlen(hash[h]) == 0) return 0;
		}
		return 0;
	}

	int Insert(char *insertStr) {
		long long key, i, h;
		key = GetKeyFromStr(insertStr);
		for (i = 0; i < M; i++) {
			h = (H1(key) + i * H2(key)) % M;
			if (strcmp(hash[h], insertStr) == 0) return 1;
			else if (strlen(hash[h]) == 0) {
				strcpy( hash[h], insertStr);
				return 0;
			}
		}
		return 0;
	}



	~HashDictionary() {
		for (int i = 0; i < M; i++) {
			delete[] hash[i];
			hash[i] = 0;
		}
		delete[] hash;
		hash = 0;
	}
};

int main() {
	int cmdNumber;
	char cmd[9], str[L];
	HashDictionary dictionary = HashDictionary();

	scanf("%d", &cmdNumber);

	for (int i = 0; i < cmdNumber; i++) {
		scanf("%s %s", cmd, str);

		if (cmd[0] == 'i') {
			dictionary.Insert(str);
		}
		else {
			if (dictionary.FindFromHash(str)) {
				printf("yes\n");
			}
			else {
				printf("no\n");
			}
		}
	}
	

	return 0;
}


Measured memory_bytes: 43108
#include<iostream>
#include<cstdint>
using namespace std; // 575

int main() {
	int64_t N;
	cin >> N;
	int64_t ans = 0;
	for (int64_t i = 1;i * (i + 2) <= N;++ i) if ((N - i) % i == 0) ans += (N - i) / i;
	cout << ans;
	return 0;
}
/*
31536000のコメント解説欄
ここテンプレで用意してるから、A問題とかだとこの先空欄の危険あり
また、コンテスト後に https://31536000.hatenablog.com/ で解説していると思うので、良かったら読んでねー

仮に商と余りを決め打つと答えが出しやすそう
商=余り=1なら、N=m+1かつm≧2だし
商=余り=2なら、N=2m+2かつm≧3だし
以下、同様に行うと√N通りだけ考えれば良いことが分かる

余りをiとする
すると、N-iについてiの倍数なら、(N-i)/iがmであるから調べるだけ
ループ条件は(N-i)/i≧i+1、よりN≧i(i+2)
*/

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

const int mod = 1e9+7;

int main(){
	ios::sync_with_stdio(0);
	cin.tie(0);
	int n,m;
	cin >> n >> m;
	vector<string> v(n);
	for (int i=0; i<n; ++i) cin >> v[i];
	vector<vector<int>> dp(n,vector<int>(m));
	dp[0][0] = 1;
	for (int i=0; i<n; ++i){
		for (int j=0; j<m; ++j){
			if (v[i][j] == '.'){
				if (i-1 >= 0) dp[i][j] += dp[i-1][j];
				dp[i][j] %= mod;
				if (j-1 >= 0) dp[i][j] += dp[i][j-1];
				dp[i][j] %= mod;
			}
		}
	}
	cout << dp[n-1][m-1];
	return 0;
}


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

int main() {
	int m,d;
	cin>>m>>d;
	if(d<22 || m<4){
		cout<<"0"<<endl;
		return 0;
	}
	int count=0;
	for(int i=22;i<=d;i++){
		if(i%10>=2 && i/10>=2){
			if(1<=(i%10)*(i/10) && (i%10)*(i/10)<=m){
				count++;
			}
		}
	}
	cout<<count<<endl;
	return 0;
}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Collections;
using System.Linq;
namespace Atcoder_0404
{
    class Program
    {
        static void Main(string[] args)
        {
            var ND = GetInput_long();
            var magdist = ND[1] * ND[1];
            int result = 0;
            for(int i = 0; i < ND[0]; i++)
            {
                var input = GetInput_long();
                var check = input[0] * input[0] + input[1] * input[1];
                if (check <= magdist) result++;
            }
            Console.WriteLine(result);
        }

        #region input


        static string[] GetInput_string()
        {
            var input = Console.ReadLine().Split(' ');
            return input;
        }

        static int[] GetInput_int()
        {
            var input = GetInput_string();
            var result = new int[input.Length];
            for (int i = 0; i < result.Length; i++)
            {
                result[i] = int.Parse(input[i]);
            }
            return result;
        }
        static long[] GetInput_long()
        {
            var input = GetInput_string();
            var result = new long[input.Length];
            for (int i = 0; i < result.Length; i++)
            {
                result[i] = long.Parse(input[i]);
            }
            return result;
        }
        #endregion
        #region sonota
        static void Swap_array<T>(T[] target, int a, int b)
        {
            T temp = target[a];
            target[a] = target[b];
            target[b] = temp;
        }
        static void Swap_list<T>(List<T> target, int a, int b)
        {
            T temp = target[a];
            target[a] = target[b];
            target[b] = temp;
        }
        /// <summary>
        /// 最大公約数
        /// </summary>
        public static int GCD(int a, int b)
        {

            /* 自然数 a > b を確認・入替 */
            if (a < b)
            {
                int tmp = a;
                a = b;
                b = tmp;
            }

            /* ユークリッドの互除法 */
            int r = a % b;
            while (r != 0)
            {
                a = b;
                b = r;
                r = a % b;
            }
            return b;
        }

        /// <summary>
        /// 最小公倍数
        /// </summary>
        public static int LCM(int a, int b)
        {
            int x = a * b;
            b = GCD(a, b);
            return x / b;

        }
        #endregion
        
    }
}

Measured memory_bytes: 40640
#include <bits/stdc++.h>
using namespace std;
int main()
{
   int n,s;
   cin>>n;
    int a[n];
    for(int i=0;i<n;i++)
        cin>>a[i];
    sort(a,a+n);
    cout<<a[n-1]-a[0];
   return 0;
   }

Measured memory_bytes: 3496
#include<iostream>
using namespace std;
 
int main()
{
  char b;
  cin>>b;
  switch(b)
  {
    case 'A':
      	cout<<'T'<<endl;
        break;
       case 'T':
      	cout<<'A'<<endl;
        break;
       case 'G':
      	cout<<'C'<<endl;
        break;
       case 'C':
      	cout<<'G'<<endl;
        break;
  }
}

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

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)   FOR(i,0,n)
#define LL long long


int main(){
  LL n;
  cin>>n;
  FOR(h,1,3501){
    FOR(w,1,3501){
      if(((4*h-n)*w-n*h)!=0&&(n*h*w)/((4*h-n)*w-n*h)>0&&(n*h*w)%((4*h-n)*w-n*h)==0){
	cout<<h<<" "<<w<<" "<<(n*h*w)/((4*h-n)*w-n*h)<<endl;
	return 0;
      }
    }
  }
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
int main()
{
	int n,sum=0;
	scanf("%d",&n);
	long long a[n],b[n],c[n];
	for(int i=0;i<n;i++)
	{
		scanf("%lld",&a[i]);
		b[i]=a[i]-1;
	}
	c[0]=b[0];
	int flag=1;
	for(int i=0;i<n-1;i++)
	{
		if(c[i]>b[i+1]&&c[i]<=a[i+1])c[i+1]=a[i+1];
		if(c[i]<=b[i+1])c[i+1]=b[i+1];
		if(c[i]>a[i+1])
		{
			flag=0;
			break;
		}
	}
	if(flag==1)printf("Yes\n");
	if(flag==0) printf("No\n");
}

Measured memory_bytes: 2560
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <fstream>
#include <queue>

#pragma warning( disable: 4996 )

using namespace std;

typedef long long ll;

#define INF 1000000000
#define EPS 1e-10

#define MAX_W 21
#define MAX_H 21

int h, w;

char maze[MAX_H][MAX_W];

vector<int> ans_list;

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

int solve(int x, int y, int sum){

	int ans = INF;

	if (sum > 10)
		return INF;

	for (int i = 0; i < 4; i++){
		int xx = x + dx[i];
		int yy = y + dy[i];
		if (xx < 0 || xx >= w || yy < 0 || yy >= h || maze[yy][xx] == '1')
			continue;
		for (int num = 1; ; num++){
			int nx = x + dx[i] * num;
			int ny = y + dy[i] * num;
			if (ny < 0 || ny >= h || nx < 0 || nx >= w){
				break;
			}
			else if (maze[ny][nx] == '1'){
				maze[ny][nx] = '0';
				int tmp = solve(x + dx[i]*(num-1), y + dy[i]*(num-1), sum+1);
				if (tmp <= 10)
					ans = min(ans, tmp);
				maze[ny][nx] = '1';
				break;
			}
			else if (maze[ny][nx] == '3'){
				return sum + 1;
			}
		}

	}

	return ans;

}

int main(){

	while (true){
		cin >> w >> h;
		if (w == 0 && h == 0)
			break;
		int sx, sy;
		for (int i = 0; i < h; i++){
			for (int j = 0; j < w; j++){
				cin >> maze[i][j];
				if (maze[i][j] == '2'){
					sy = i;
					sx = j;
				}
			}
		}

		int ans = solve(sx, sy, 0);
		if (ans <= 10)
			ans_list.push_back(ans);
		else
			ans_list.push_back(-1);

	}

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

	return 0;

}

Measured memory_bytes: 1220
s = input()
buf = 0
str_len = len(s)
total = 0

while buf < str_len:
    l_count = 0
    r_count = 0

    while buf < str_len and s[buf] == "<":
        l_count += 1
        buf += 1

    while buf < str_len and s[buf] == ">":
        r_count += 1
        buf += 1

    n = max(l_count, r_count)
    total += n * ( n + 1 ) // 2
    m = min(l_count, r_count) - 1
    total += m * ( m + 1 ) // 2

print(total)

Measured memory_bytes: 4212
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <queue>
#include <set>
#include <map>
#include <functional>
#include <numeric>
#include <limits>
#include <cmath>
#include <iomanip>
#include <sstream>
 
#define ALL(a)  (a).begin(),(a).end()
 
using namespace std;
typedef long long int ll;
typedef pair <int,int> P;

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

    double t, x;
    cin >> t >> x;

    cout << setprecision(10) << t / x << endl;
    

    

}

Measured memory_bytes: 256
# include <iostream>
# include <algorithm>
# include <string>
# include <math.h>
using namespace std;

int main() {
	string a, b;
	double n;
	
	cin >> a >> b;
	n = sqrt(stoi(a + b));

	if (ceil(n) == floor(n)) {
		cout << "Yes" << endl;
	}
	else {
		cout << "No" << endl;
	}

	return 0;
}

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

using namespace std;

struct twoEdgeComponents {
	int n;
	vector<vector<int>> g;
	vector<int> cmp;
	vector<vector<int>> each_bcc;
	vector<pair<int,int>> bridge;
	vector<int> order;
	vector<bool> inS;
	stack<int> roots, S;

	twoEdgeComponents() {}
	twoEdgeComponents(vector<vector<int>> g_) : n(g_.size()), g(g_) {}

	void add_edge(int p, int q) {
		g[p].push_back(q);
		g[q].push_back(p);
	}

	void dfs(int cur, int prev, int &k) {
		order[cur] = ++k;
		S.push(cur); inS[cur] = true;
		roots.push(cur);

		for(auto to: g[cur]) {
			if(order[to]==0) dfs(to, cur, k);
			else if(to!=prev && inS[to]) {
				while(order[roots.top()] > order[to]) roots.pop();
			}
		}

		if(cur == roots.top()) {
			if(prev!=-1) bridge.push_back({prev, cur});
			vector<int> bcc;
			while(1) {
				int node = S.top(); S.pop(); inS[node] = false;
				bcc.push_back(node);
				if(node==cur) break;
			}
			each_bcc.push_back(bcc);
			roots.pop();
		}
	}

	void bcc() {
		order.assign(n, 0);
		inS.assign(n, false);
		cmp.assign(n, -1);
		int k = 0;
		for(int i=0; i<n; ++i) {
			if(order[i] == 0) {
				dfs(i, -1, k);
			}
		}
		for(int i=0; i<(int)each_bcc.size(); ++i) {
			for(auto j: each_bcc[i]) {
				cmp[j] = i;
			}
		}
	}

	vector<vector<int>> getbcc() {
		vector<vector<int>> h(each_bcc.size(), vector<int>());
		for(auto i: bridge) {
			int a = cmp[i.first], b = cmp[i.second];
			h[a].push_back(b);
			h[b].push_back(a);
		}
		return h;
	}
};

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

	twoEdgeComponents graph(g);
	graph.bcc();
	// for(auto i: graph.bridge) cout << i.first << "," << i.second << endl;
	// cout << "-----" << endl;
	// for(auto i: graph.each_bcc) {
	// 	for(auto j: i) {
	// 		cout << j << " ";
	// 	}
	// 	cout << endl;
	// }
	// cout << "-----" << endl;
	vector<vector<int>> tree = graph.getbcc();
	// for(auto i: tree) {
	// 	for(auto j: i) {
	// 		cout << j << " ";
	// 	}
	// 	cout << endl;
	// }

	vector<int> W(graph.each_bcc.size());
	for(int i=0; i<(int)graph.each_bcc.size(); ++i) {
		for(int j=0; j<(int)graph.each_bcc[i].size(); ++j) {
			W[i] += w[graph.each_bcc[i][j]];
		}
	}

	vector<bool> v(n, false);
	function<bool(int,int)> dfs = [&](int x, int p) {
		bool ret = false;
		if(graph.each_bcc[x].size() >= 2) ret = true;
		for(auto i: tree[x]) {
			if(i == p) continue;
			ret |= dfs(i, x);
		}
		// cout << x << " " << ret << endl;
		return v[x] = ret;
	};

	dfs(graph.cmp[0], -1);

	int ans = 0;
	for(int i=0; i<(int)graph.each_bcc.size(); ++i) {
		if(v[i]) ans += W[i];
	}
	// cout << ans << endl;

	int tmp = 0;
	vector<int> v2(n, 0);
	function<void(int,int,int)> dfs2 = [&](int x, int p, int cost) {
		if(!v[x]) cost += W[x];
		tmp = max(tmp, cost);
		for(auto i: tree[x]) {
			if(i == p) continue;
			dfs2(i, x, cost);
		}
	};

	dfs2(graph.cmp[0], -1, 0);
	ans += tmp;
	cout << ans << endl;

	return 0;
}



Measured memory_bytes: 40108
/*
 * 2660.cc: Sigma
 */

#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<iostream>
#include<string>
#include<vector>
#include<map>
#include<set>
#include<stack>
#include<list>
#include<queue>
#include<deque>
#include<algorithm>
#include<numeric>
#include<utility>
#include<complex>
#include<functional>
 
using namespace std;

/* constant */

const int MAX_N = 300;

const int INF = 1 << 30;

/* typedef */

/* global variables */

int dpa[MAX_N][MAX_N], dps[MAX_N][MAX_N];

/* subroutines */

int calc_sec(int x, int y) {
  int sum = 0, ci = 0;
  while (x > 0 || y > 0 || ci > 0) {
    int xi = x % 10, yi = y % 10;
    sum += xi * yi + ci;
    ci = (xi + yi + ci) / 10;
    x /= 10;
    y /= 10;
  }
  return sum;
}

/* main */

int main() {
  int n;
  cin >> n;
  for (int i = 0; i < n; i++) cin >> dpa[i][i];

  for (int l = 1; l < n; l++) {
    for (int i = 0, j = l; j < n; i++, j++) {
      int mindps = INF, mindpa;
      for (int k = i; k < j; k++) {
	int ndps =
	  calc_sec(dpa[i][k], dpa[k + 1][j]) + dps[i][k] + dps[k + 1][j];
	if (mindps > ndps) {
	  mindps = ndps;
	  mindpa = dpa[i][k] + dpa[k + 1][j];
	}
      }
      dps[i][j] = mindps;
      dpa[i][j] = mindpa;
    }
  }

  printf("%d\n", dps[0][n - 1]);
  return 0;
}

Measured memory_bytes: 1852
#!/usr/bin/perl
my ($k,$x) = map { $_ - 0 } split(/\s+/,<STDIN>);

my $sep = '';
for(my $i = $x + 1 - $k ; $i <=  $x - 1 + $k ; $i ++){
  print "$sep$i";
  $sep = ' ';
}
print "\n";


Measured memory_bytes: 512
import java.io.*;
import java.util.*;

public class Main {

    public static void main(String[] args) {
        FastScanner sc = new FastScanner();
        PrintWriter out = new PrintWriter(System.out);

        AtCoder problem = new AtCoder(sc);
        problem.solve(out);

        out.flush();
    }

}

class AtCoder {

    /* 変数宣言 */
    final int N, K;
    final List<Integer> p;

    AtCoder(FastScanner sc) {
        N = sc.nextInt();
        K = sc.nextInt();

        p = new ArrayList<>();
        for (int i = 0; i < N; i++) {
            p.add(sc.nextInt());
        }
    }

    void solve(PrintWriter out) {
        Collections.sort(p);
        int sum = 0;
        for (int i = 0; i < K; i++) {
            sum += p.get(i);
        }

        out.println(sum);
    }
}
    // https://qiita.com/p_shiki37/items/a0f6aac33bf60f5f65e4
class FastScanner {
 
    private final InputStream in = System.in;
    private final byte[] buffer = new byte[1024];
    private int ptr = 0;
    private int buflen = 0;
 
    private boolean hasNextByte() {
        if (ptr < buflen) {
            return true;
        } else {
            ptr = 0;
            try {
                buflen = in.read(buffer);
            } catch (IOException e) {
                e.printStackTrace();
            }
            if (buflen <= 0) {
                return false;
            }
        }
        return true;
    }
 
    private int readByte() {
        if (hasNextByte()) {
            return buffer[ptr++];
        } else {
            return -1;
        }
    }
 
    private static boolean isPrintableChar(int c) {
        return 33 <= c && c <= 126;
    }
 
    public boolean hasNext() {
        while (hasNextByte() && !isPrintableChar(buffer[ptr])) {
            ptr++;
        }
        return hasNextByte();
    }
 
    public String next() {
        if (!hasNext()) {
            throw new NoSuchElementException();
        }
        StringBuilder sb = new StringBuilder();
        int b = readByte();
        while (isPrintableChar(b)) {
            sb.appendCodePoint(b);
            b = readByte();
        }
        return sb.toString();
    }
 
    public long nextLong() {
        if (!hasNext()) {
            throw new NoSuchElementException();
        }
        long n = 0;
        boolean minus = false;
        int b = readByte();
        if (b == '-') {
            minus = true;
            b = readByte();
        }
        if (b < '0' || '9' < b) {
            throw new NumberFormatException();
        }
        while (true) {
            if ('0' <= b && b <= '9') {
                n *= 10;
                n += b - '0';
            } else if (b == -1 || !isPrintableChar(b)) {
                return minus ? -n : n;
            } else {
                throw new NumberFormatException();
            }
            b = readByte();
        }
    }
 
    public int nextInt() {
        long nl = nextLong();
        if (nl < Integer.MIN_VALUE || nl > Integer.MAX_VALUE) {
            throw new NumberFormatException();
        }
        return (int) nl;
    }
 
    public double nextDouble() {
        return Double.parseDouble(next());
    }
}

Measured memory_bytes: 32252
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 n = Integer.parseInt(br.readLine());
	
	String[] tmpArray;
	Card[] cards = new Card[n];
	for(int i = 0; i < n ; i++){
	    //空白をとる
	    tmpArray = br.readLine().split(" ");
	    //0番目にマーク1番目に番号
	    cards[i] = new Card(i, tmpArray[0], Integer.parseInt(tmpArray[1]));
	}
	
	quickSort(cards, 0, cards.length - 1);
	
	if(isStable(cards)){
	    System.out.println("Stable");
	}
	else{
	    System.out.println("Not stable");
	}
	StringBuffer sb = new StringBuffer();
	for(int i = 0; i < n; i++){
	    sb.append(cards[i].toString()+"\n");
	}
	System.out.print(sb);
    }
    
    static boolean isStable(Card[] cards){
	int currentNum = 0;
	for(int i = 1; i < cards.length; i++){
	    if(cards[i].number == currentNum && cards[i].id < cards[i - 1].id){
		return false;
	    }
	    
	    else if(cards[i].number != currentNum){
		currentNum = cards[i].number;
	    }
	}
	return true;
    }
    
    static void quickSort(Card[] cards, int p, int r){
	if(p < r){
	    int q = partition(cards, p, r);
	    quickSort(cards, p, q - 1);
 	    quickSort(cards, q + 1, r);
	}
    }
    
    // static int partition(int[] array, int p, int r){
    // 	int x = array[r];
    // 	int i = p - 1;
    // 	for(int j = p ; j <= r - 1 ;j++){
    // 	    if(array[j] <= x){
    // 		i++;
    // 		int tmp = array[i];
    // 		array[i] = array[j];
    // 		array[j] = tmp;
		
    // 	    }
    // 	}
    // 	int tmp = array[i + 1];
    // 	array[i + 1] = array[r];
    // 	array[r] = tmp;
    // 	return i + 1;
    // }
    
    static int partition(Card[] array, int p, int r){
	int x = array[r].number;
	int i = p - 1;
	for(int j = p ; j <= r -1 ;j++){
	    if(array[j].number <= x){
		i++;
		Card tmp = array[i];
		array[i] = array[j];
		array[j] = tmp;
		
	    }
	}
	Card tmp = array[i + 1];
	array[i + 1] = array[r];
	array[r] = tmp;
	return i + 1;
    }
}

class Card {
    int id;
    String mark;
    int number;
    
    public Card (int id, String mark, int number){
	this.id = id;
	this.mark = mark;
	this.number = number;
    }
    
    public String toString(){
	return mark + " "  + number;
    }
}


Measured memory_bytes: 70388
#include <vector>
#include <list>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <cstring>

using namespace std;

#define MAX 100000
#define INF 2140000000
#define MOD 1000000007

int main() {
	string s;
	int q, rev = 0;
	vector<vector<char> > add(2);

	cin >> s;
	cin >> q;

	for (int i = 0; i < q; ++i) {
		int t, f;
		char ch;
		cin >> t;

		if (t == 1) {
			if (rev) {
				rev = 0;
			}
			else {
				rev = 1;
			}
		}
		else {
			cin >> f >> ch;

			if (f == 1) {
				if (rev) {
					add[1].push_back(ch);
				}
				else {
					add[0].push_back(ch);
				}
			}
			else {
				if (rev) {
					add[0].push_back(ch);
				}
				else {
					add[1].push_back(ch);
				}
			}
		}
	}

	string final;

	for (int i = 0; i < (int) add[0].size(); ++i) {
		final += add[0][(int) add[0].size() - 1 - i];
	}

	final += s;

	for (int i = 0; i < (int) add[1].size(); ++i) {
		final += add[1][i];
	}

	if (rev) {
		reverse(final.begin(), final.end());
		cout << final << endl;
	}
	else {
		cout << final << endl;
	}

	return 0;
}

Measured memory_bytes: 1368
import sys
H,W = map(int,input().split())
lists= [[j for j in input()] for i in range(H)]
for l in lists:
    l.append(".")
    l.insert(0,".")
lists.insert(0,["."]*len(lists[0]))
lists.insert(len(lists),["."]*len(lists[0]))
check = True
for h in range(len(lists)):
    for w in range(len(lists[0])):
        if lists[h][w]=="#":
            if lists[h+1][w]!="#" and lists[h-1][w]!="#" and lists[h][w+1]!="#" and lists[h][w-1]!="#":
                print("No")
                sys.exit()
print("Yes")

Measured memory_bytes: 3064
object Main {

  def main(args: Array[String]): Unit = {
    scala.io.StdIn.readLine()
    val str = scala.io.StdIn.readLine()
    val k = scala.io.StdIn.readLine().toInt
    val target = str(k-1)
    val res = str.map {
      case c @ `target` => c
      case _ => '*'
    }
    println(res)
  }

}

Measured memory_bytes: 25424
#include<bits/stdc++.h>
#define int long long
#define REP(i,s,t) for(int i=s;i<=t;i++)
using namespace std;
const int maxn=2e5+5;
int a[maxn];
signed main(){
	int n,ans=0; cin>>n;
	REP(i,1,n) cin>>a[i];
	int pt=1,num=a[1];
	REP(i,1,n){
		num^=a[i-1];
		while(pt<n&&!(a[pt+1]&num)) num|=a[++pt];
		ans+=pt-i+1;
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
#define MAX (ll)(1e6 + 7)
#define INF (ll)(1e17 + 7)
#define MOD (ll)(1e9 + 7)
#define PI (double)(3.14159265)
#define IO ios_base :: sync_with_stdio (false);
#define LOG 22

using namespace std;
using ll = long long;

int main () {
	IO;
	ll x, y, a, b, c;
	cin >> x >> y >> a >> b >> c;
	multiset<ll> sa, sb, sc, s1, s2;
	ll su = 0;
	for (ll i = 0; i < a; i++) {
		ll v;
		cin >> v;
		sa.insert (v);
		s1.insert (v);
	}
	for (ll i = 0; i < b; i++) {
		ll v;
		cin >> v;
		sb.insert (v);
	}
	for (ll i = 0; i < c; i++) {
		ll v;
		cin >> v;
		sc.insert (v);
		s1.insert (v);
	}
	ll ma = 0, ss = 0;
	for (ll i = 0; i < b - y; i++) {
		sb.erase (sb.begin ());
	}
	for (ll x : sb) {
		ss += x;
	}
	for (ll i = 0; i < x; i++) {
		ss += *s1.rbegin ();
		s2.insert (*s1.rbegin ());
		s1.erase (--s1.end ());
	}
	ma = ss;
	for (ll i = 0; i < min (y, c); i++) {
		ss -= *sb.begin ();
		sb.erase (sb.begin ());
		ll v = *sc.rbegin ();
		ss += v;
		sc.erase (--sc.end ());
		if (s1.count (v)) {
			s1.erase (s1.find (v));
		}
		else {
			ss -= v;
			s2.erase (s2.find (v));
			ss += *s1.rbegin ();
			s2.insert (*s1.rbegin ());
			s1.erase (--s1.end ());
		}
		ma = max (ss, ma);
	}
	cout << ma << "\n";
}
	
	
	


Measured memory_bytes: 23680
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

class Program
{
    static void Main(string[] args)
    {
        var line = Console.ReadLine();
        int n = int.Parse(line);
        int sum = 0;
        for (int i = 0; i < line.Length; i++)
        {
            sum += (n % (int)Math.Pow(10, i + 1)) / (int)Math.Pow(10, i);
        }
        if (n % sum == 0)
        {
            Console.WriteLine("Yes");
        }
        else
        {
            Console.WriteLine("No");
        }
    }
}

Measured memory_bytes: 13140
//* AuThOr GaRyMr *//
#include<bits/stdc++.h>
#define rb(a,b,c) for(int a=b;a<=c;++a)
#define rl(a,b,c) for(int a=b;a>=c;--a)
#define niv vector<int>
#define LL long long
#define IT iterator
#define PB(a) push_back(a)
#define II(a,b) make_pair(a,b)
#define FIR first
#define SEC second
#define FREO freopen("check.out","w",stdout)
#define rep(a,b) for(int a=0;a<b;++a)
#define KEEP while(1)
#define SRAND mt19937 rng(chrono::steady_clock::now().time_since_epoch().count())
#define random(a) rng()%a
using namespace std;
const int INF=0x3f3f3f3f;
typedef pair<int,int> mp;
typedef pair<mp,mp> superpair;
double a[55];int n;
int main(){
	cin>>n;
	rb(i,1,n) cin>>a[i];
	sort(a+1,a+1+n);
	rb(i,1,n-1){
		a[2]=a[1]+a[2];
		a[2]/=2.0;
		rb(j,1,n-1) a[j]=a[j+1];
		sort(a+1,a+1+(n-i));
	}
	printf("%.10f\n",a[1]);
	return 0;
}

Measured memory_bytes: 256
from sys import stdin
nii=lambda:map(int,stdin.readline().split())
lnii=lambda:list(map(int,stdin.readline().split()))

n,m=nii()

ms=1900*m+100*(n-m)

ans=0
for i in range(1,10**6):
  p1=0.5**m
  p2=(1-0.5**m)**(i-1)
  p=p1*p2
  t_ms=ms*i
  ans+=p*t_ms

ans=int(ans)
q=ans%10
if q!=0:
  ans+=10-q

print(ans)

Measured memory_bytes: 74272
# pypy
import sys
read = sys.stdin.read
readline = sys.stdin.readline
readlines = sys.stdin.readlines

R, C, K = map(int, readline().split())
rcv = list(map(int, read().split()))
rc2v = {}
for rr, cc, vv in zip(rcv[::3], rcv[1::3], rcv[2::3]):
    rc2v[(rr-1, cc-1)] = vv

dp = [[[0]*4 for c in range(C)] for r in range(2)]
dp[0][0][1] = rc2v[(0, 0)] if (0, 0) in rc2v else 0

for c in range(1, C):
  for k in range(1, 4):
    v = rc2v[(0, c)] if (0, c) in rc2v else 0
    dp[0][c][k] = max(dp[0][c-1][k], dp[0][c-1][k-1]+v)

for r in range(1, R):
  rr = r % 2
  dp[rr][0][0] = max(dp[rr-1][0])
  v = rc2v[(r, 0)] if (r, 0) in rc2v else 0
  dp[rr][0][1] = dp[rr][0][0] + v
  for c in range(1, C):
    v = rc2v[(r, c)] if (r, c) in rc2v else 0
    temp_max = max(dp[rr-1][c])
    dp[rr][c][1] = max(dp[rr][c-1][1], max(dp[rr][c-1][0], temp_max)+v)
    for k in range(2, 4):
      dp[rr][c][k] = max(dp[rr][c-1][k], dp[rr][c-1][k-1]+v)
    
if R % 2:
  print(max(dp[0][-1]))
else:
  print(max(dp[-1][-1]))

Measured memory_bytes: 151664
package main

import (
	"fmt"
	"sort"
)

func main() {
	var n int
	fmt.Scan(&n)
	a := make([]int, n)
	for i := range a {
		fmt.Scan(&a[i])
	}
	b := make([]int, n)
	for i := range b {
		fmt.Scan(&b[i])
	}

	sumA := 0
	for _, ai := range a {
		sumA += ai
	}
	sumB := 0
	for _, bi := range b {
		sumB += bi
	}
	if sumA < sumB {
		fmt.Println(-1)
		return
	}

	allOver := true
	for i := 0; i < n; i++ {
		if a[i] < b[i] {
			allOver = false
		}
	}
	if allOver {
		fmt.Println(0)
		return
	}

	var over []int
	less := 0
	count := 0
	for i := 0; i < n; i++ {
		if a[i] < b[i] {
			less += b[i] - a[i]
			count++
		}
		if a[i] > b[i] {
			over = append(over, a[i]-b[i])
		}
	}
	sort.Sort(sort.Reverse(sort.IntSlice(over)))

	for _, oi := range over {
		less -= oi
		count++
		if less <= 0 {
			break
		}
	}

	fmt.Println(count)
}


Measured memory_bytes: 6656
c = [[], [], []]
c[0] = list(map(int, input().split()))
c[1] = list(map(int, input().split()))
c[2] = list(map(int, input().split()))

a1 = sum(c[0])
a2 = sum(c[1])
a3 = sum(c[2])
b1 = sum([c[0][0], c[1][0], c[2][0]])
b2 = sum([c[0][1], c[1][1], c[2][1]])
b3 = sum([c[0][2], c[1][2], c[2][2]])

if (a1 - a2) % 3 == 0 and (a2 - a3) % 3 ==0 and (a3 - a1) % 3 ==0 and (b1-b2)%3 ==0 and (b2-b3)%3==0 and (b3-b1)%3==0:
    print('Yes')
else:
    print('No')

Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  for(int i=0;i<(n);++i)
#define REPr(i,n) for(int i=(n)-1;i>=0; --i)
#define FORq(i, m, n) for(int i = (m);i <= (n);++i)
#define rFORq(i, m , n) for(int i = (n);i >=(m);--i)
#define SCD(n) scanf("%d",&n)
#define SCD2(m,n) scanf("%d%d",&m,&n)
#define SCD3(m,n,k) scanf("%d%d%d",&m,&n,&k)
#define SCLLD(n) scanf("%lld",&n)
#define SCLLD2(m,n) scanf("%lld%lld",&m,&n)
#define SCLLD3(m,n,k) scanf("%lld%lld%lld",&m,&n,&k)
#define PB push_back
#define MP make_pair
#define ARSCD(A,N) REP(i,N){SCD(A[i]);}
#define ARSCD1(A,N) FORq(i,1,N){SCD(A[i]);}
#define VSCD(v,N) REP(i,N){int x; SCD(x); v.PB(x);}
#define VSCLLD(v,N) REP(i,N){long long x; SCLLD(x); v.PB(x);}
#define PRINTD(n) printf("%d\n",n)
#define PRINTLLD(n) printf("%lld\n",n)
#define DEBUG printf("%s\n","debug")
#define fst first
#define snd second
#define SIN(x,S) (S.count(x) != 0)
using namespace std;
typedef pair<int,int> PII;
typedef vector<int> VI;
typedef vector < VI > VVI;
typedef vector<long long> VL;
typedef long long ll;
typedef long long integer;
////////////////////////////////////////////////////////////////////
ll X[52];
ll P[52];

ll F(long long x, long long L){
    if ((L==0) and (x==1)) return 1;
    if (x == 1) return 0;
    else if ((1 < x) and (x <= 1+X[L-1])) return F(x-1,L-1);
    else if (x == 2 + X[L-1]) return P[L-1] + 1;
    else if ((2 + X[L-1] < x) and (x <= 2 + 2*X[L-1])) return 1 + P[L-1] + F(x-2-X[L-1],L-1);
    else if (x== 3 + 2*X[L-1]) return 2 * P[L-1]+ 1;
    return 0;
}

int main(){
    ll N; SCLLD(N);
    ll x; SCLLD(x);

    X[0] = 1;
    P[0] = 1;
    FORq(i,1,50){
        P[i] = 2 * P[i-1] + 1;
        X[i] = 2 * X[i-1] + 3;
    }

    PRINTLLD(F(x,N));
}

Measured memory_bytes: 256
def main():
    n = int(input())
    arr = [0] * n

    for i in range(1, int(n**0.5+1)):
        for j in range(i**2, n + 1, i):
            arr[j-1] += 2

    for i in range(1, int(n**0.5+1)):
        arr[i ** 2 - 1] -= 1

    res = 0
    for i, a in enumerate(arr):
       res += (i+1) * a
    print(res)


if __name__ == '__main__':
    main()



Measured memory_bytes: 144776
#include<bits/stdc++.h>
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL);
#define f(i,a,n) for(i=a;i<n;i++)
#define rf(i,a,n) for(i=a;i>=n;i--)
#define ll long long
#define pii pair<int,int>
#define pll pair<long long,long long>
#define vi vector<int>
#define vll vector<long long>
#define umii unordered_map<int,int>
#define umci unordered_map<char,int>
#define pb push_back
#define pf push_front
#define pob pop_back
#define pof pop_front
#define F first
#define S second
#define all(v) begin(v),end(v)
#define mkp make_pair
#define M 1000000007
#define TakeInput freopen("input.txt","r",stdin);freopen("output.txt","w",stdout);freopen("error.txt","w",stderr);


using namespace std;
int main()
{
	#ifndef ONLINE_JUDGE
	//TakeInput
	#endif
	fast;
	int i,j,n;
	cin >> n;
	int a[n];
	int min=INT_MAX, cnt=0;
	f(i,0,n)
	{
		cin >> a[i];
		if (a[i] < min)
		{
			min = a[i];
			cnt++;
		}
	}
	cout << cnt;
	return 0;
}


Measured memory_bytes: 1024
// luogu-judger-enable-o2
#include<bits/stdc++.h>
#define FOR(i,a,b) for (register ll i=(a);i<=(b);i++)
#define For(i,a,b) for (register ll i=(a);i>=(b);i--)
#define mem(i,j) memset(i,j,sizeof(i))
using namespace std;
typedef long long ll;
const ll N=2e5+5;
ll n,E,T,x[N],f[N],Ans,k=1e18;
ll l=1,r=1,q[N];
ll read()
{
	ll x=0,f=1;
	char c=getchar();
	while (c<'0'||c>'9') {if (c=='-') f=-1;c=getchar();}
	while (c>='0'&&c<='9') {x=(x<<1)+(x<<3)+c-'0';c=getchar();}
	return f*x;
}
int main()
{
	mem(f,0x3f);
	n=read(),E=read(),T=read();
	FOR(i,1,n) x[i]=read();
	f[0]=0;
	FOR(i,1,n)
	{
		while (l<=r&&2*(x[i]-x[q[l]+1])>T)
		{
			k=min(k,f[q[l]]-2*x[q[l]+1]);
			l++;
		}
		f[i]=min(f[i],f[q[l]]+T);
		f[i]=min(f[i],k+2*x[i]);
		q[++r]=i;
	}
	Ans=f[n]+E;
	printf("%lld\n",Ans);
	return 0;
}

Measured memory_bytes: 3712
def factorization(n):
    arr = []
    temp = n
    for i in range(2, int(-(-n**0.5//1))+1):
        if temp%i==0:
            cnt=0
            while temp%i==0:
                cnt+=1
                temp //= i
            arr.append([i, cnt])

    if temp!=1:
        arr.append([temp, 1])

    if arr==[]:
        arr.append([n, 1])

    return arr

n, p = map(int, input().split())
factors = factorization(p)
ans = 1
for factor, num in factors:
    ans *= factor**(num//n)
print(ans)

Measured memory_bytes: 3188
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> l_l;
typedef pair<int, int> i_i;
template<class T>
inline bool chmax(T &a, T b) {
    if(a < b) {
        a = b;
        return true;
    }
    return false;
}

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

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
//const ll mod = 1000000007;

int main() {
    //cout.precision(10);
    cin.tie(0);
    ios::sync_with_stdio(false);
    int a, b, c;
    cin >> a >> b >> c;
    cout << min(a*b,c) << endl;
    return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
#include<stdlib.h>
#define min(x,y) (x)<(y)?x:y;
#define N 100000000
typedef struct{
    int w;
    int h;
    int leg;
}Data;
Data queue[N];
int num,head;
void enqueue(int leg,int h,int w){
    if(num<N){
        queue[(head+num)%N].w=w;
        queue[(head+num)%N].h=h;
        queue[(head+num)%N].leg=leg;
        num++;
    }else{
        printf("エラー\n");
        exit(1);
    }
}
Data dequeue(const int cost[2][62][32]){
    int index=head; Data x=queue[head];
    int min=cost[x.leg][x.h][x.w];
    for(int i=head+1;i<head+num;i++){
        if(min>cost[queue[i%N].leg][queue[i%N].h][queue[i%N].w]){
            min=cost[queue[i%N].leg][queue[i%N].h][queue[i%N].w];
            index=i%N;
        }
    }
    Data tmp=queue[head]; queue[head]=queue[index]; queue[index]=tmp;
    Data d={-1,-1,-1};
    if(num>0){
        d=queue[head];
        head=(head+1)%N;
        num--;
    }
    return d;
}
char map[62][32];
int mv[2][9][2]={{{1,2},{1,1},{1,0},{1,-1},{1,-2},{2,1},{2,0},{2,-1},{3,0}},
    {{-3,0},{-2,1},{-2,0},{-2,-1},{-1,2},{-1,1},{-1,0},{-1,-1},{-1,-2}}};
int main(void){
    while(1){
        int w,h;
        char s[10];
        scanf("%d%d",&w,&h);
        if(w+h==0) break;
        getchar();
        for(int i=0;i<h;i++){
            for(int j=0;j<w;j++){
                scanf("%s",s);
                map[i][j]=s[0];
            }
        }
        /*for(int i=0;i<h;i++){
            for(int j=0;j<w;j++){
                printf("%c ",map[i][j]);
            }puts("");
        }*/
        int ans=100000000;
        int cost[2][62][32]={0};
        for(int j=0;j<w;j++)
            if(map[h-1][j]=='S') enqueue(0,h-1,j),enqueue(1,h-1,j);
        while(1){
            int nh,nw;
            Data tmp=dequeue(cost);
            if(tmp.leg==-1) break;
            for(int i=0;i<9;i++){
                int leg=tmp.leg;
                nh=tmp.h+mv[leg][i][1];
                nw=tmp.w+mv[leg][i][0];
                if(nh<0||nh>=h||nw<0||nw>=w) continue;
                if(map[nh][nw]=='S'||map[nh][nw]=='X') continue;
                if(map[nh][nw]=='T'){
                    if(cost[!leg][nh][nw]==0||
                       cost[!leg][nh][nw]>cost[leg][tmp.h][tmp.w]){
                        cost[!leg][nh][nw]=cost[leg][tmp.h][tmp.w];
                    }
                }
                else if(cost[!leg][nh][nw]==0||
                   cost[!leg][nh][nw]>
                   cost[leg][tmp.h][tmp.w]+(map[nh][nw]-'0')){
                    cost[!leg][nh][nw]=cost[leg][tmp.h][tmp.w]+(map[nh][nw]-'0');
                    enqueue(!leg,nh,nw);
                }
            }
        }
        int min=10000000;
        for(int j=0;j<w;j++){
            if(map[0][j]=='T'){
                if(cost[0][0][j]!=0&&min>cost[0][0][j])
                    min=cost[0][0][j];
                if(cost[1][0][j]!=0&&min>cost[1][0][j])
                    min=cost[1][0][j];
            }
        }
        if(min==10000000) printf("-1\n");
        else printf("%d\n",min);
    }
}



Measured memory_bytes: 3144
def nibun(D, x):
    return bisect.bisect_left(D, x)  # 場所返す

import bisect
import sys
def I(): return int(sys.stdin.readline())
def LI(): return list(map(int,sys.stdin.readline().split()))
mod = 10**9 + 7
inf = float('inf')
ans = int(0)
A,B,Q =LI()
s = [0]*A
t = [0]*B
x = [0]*Q
for i in range(A):
    s[i] = I()
for i in range(B):
    t[i] = I()
for i in range(Q):
    x[i] = I()

ansy = int(0)
for i in range(Q):
    Scandi = [inf] * 2
    Tcandi = [inf] * 2
    xc = x[i]
    k = nibun(s,xc)
    if k>0:
        Scandi[0] = xc - s[k-1]
    if k<A:
        Scandi[1] = s[k] - xc

    k = nibun(t,x[i])
    if k>0:
        Tcandi[0] = xc - t[k-1]
    if k<B:
        Tcandi[1] = t[k] - xc

    anscandi = []
    for i in range(2):
        anst = Scandi[i]*2 + Tcandi[i-1]
        anscandi.append(anst)
        anst = Scandi[i] + Tcandi[i-1]*2
        anscandi.append(anst)
    anst = max(Scandi[0],Tcandi[0])
    anscandi.append(anst)
    anst = max(Scandi[1],Tcandi[1])
    anscandi.append(anst)


    ans = min(anscandi)
    print(ans)
#    print(anscandi)

Measured memory_bytes: 105564
#include <iostream>
#include <vector>

using namespace std;

int gcd(int a, int b) {
    int c;
    for(;1;) {
        if (a<b) {
            c=b;b=a;a=c;
        }
        if (b==0) {
            break;
        }
        c=a%b; a=b; b=c;
    }
    return a;
}

int gcd_vector(vector<int>& x) {
    int c = x[0];
    for(const auto& v: x) {
        c = gcd(c, v);
    }
    return c;
}


int main(int argc, char const *argv[])
{
    int n, x_, d=1;
    cin >> n >> x_;
    vector<int> x(n, 0);
    for(int i=0;i<n;++i) {
        cin >> x[i];
        x[i] -= x_;
        if (x[i]<0) x[i] *= -1;
    }

    cout << gcd_vector(x) << endl;
    return 0;
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
vector<int> input(int N) {
  vector<int> vec(N);
  for (int i = 0; i < N; i++) {
    cin >> vec.at(i);
  }
  return vec;
}

int main() {
  string s;
  cin >> s;
  if(s=="ABC"){
    cout << "ARC" << endl;
  }else{
    cout << "ABC" << endl;
  }
}

Measured memory_bytes: 3596
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <queue>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <fstream>
#include <cassert>
using namespace std;

#define sz(a) int((a).size())
#define rep(i, s, n)  for(int i = s; i <= (n); ++i)
#define rev(i, n, s)  for(int i = (n); i >= s; --i)
#define fore(x, a) for(auto &&x : a)
typedef long long ll;
const int mod = 1000000007;
const int N = 3005;

int dp[N][N][2];
int n;

int go(int m, int r, bool y) {
  if(m == 0) {
    return y;
  }
  int &res = dp[m][r][y];
  if(res == -1) {
    res = 0;
    if(r) {
      res += go(m - 1, r - 1, y || (r == 1));
      if(res >= mod) {
        res -= mod;
      }
      res += go(m - 1, r, y || (r == 1));
      if(res >= mod) {
        res -= mod;
      }
    }
    if(n - r) {
      res += go(m - 1, r, y || (r == 0));
      if(res >= mod) {
        res -= mod;
      }
      res += go(m - 1, r + 1, y || (r == 0));
      if(res >= mod) {
        res -= mod;
      }
    }
  }
  return res;
}

int main() {
#ifdef loc
  if(!freopen((string(FOLDER) + "inp.txt").c_str(), "r", stdin)) {
    assert(0);
  }
  freopen((string(FOLDER) + "out.txt").c_str(), "w", stdout);
#endif
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  int m;
  cin >> n >> m;
  memset(dp, -1, sizeof(dp));
  int res = 0;
  rep(i, 0, n) {
    res += go(m, i, 0);
    if(res >= mod) {
      res -= mod;
    }
  }
  cout << res << endl;
  return 0;
}

Measured memory_bytes: 71040
package main

import (
	"fmt"
)

func main() {
	array := scanNums(3)
	a := array[0]
	b := array[1]
	k := array[2]

	var a2 int64
	var b2 int64
	if a < k {
		a2 = 0
		if a+b < k {
			b2 = 0
		} else {
			b2 = a + b - k
		}
	} else {
		a2 = a - k
		b2 = b
	}

	fmt.Println(a2, b2)
}

func scanNums(len int64) (nums []int64) {
	var num int64
	var i int64
	for i = 0; i < len; i++ {
		fmt.Scan(&num)
		nums = append(nums, num)
	}
	return
}


Measured memory_bytes: 512