akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<set>
#include<stack>
#include<cmath>
#include<sstream>
#include<string>
using namespace std;
typedef long long ll;
ll mod = 1e9+7;
#define rep(i,n) for(int i = 0; i < (n); ++i)

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

    int max_num = 0;
    int next_max_num = n;
    int sel_num = 1;

    while ( 1 ) {
        ll sum = 0;
        rep(i, next_max_num ) {
            sum += (ll)(i + 1);
        }

        if ( sum < n ) {
            break;
        }

        max_num = next_max_num;
        next_max_num /= 2;
    }

//    cout << max_num << endl;

    vector<int> tmp_ans;
    vector<int> ans;
    while ( 1 ) {
        tmp_ans.clear();
        ll sum = 0;
        ll tmp_num = max_num;
        bool ok = true;
        while ( 1 ) {
            if ( tmp_num == 0 ) {
                ok = false;
                break;
            }
            if ( sum + tmp_num >= n ) {
                tmp_ans.push_back( n - sum );
                break;
            }
            else {
                sum += tmp_num;
                tmp_ans.push_back(tmp_num);
            }
            --tmp_num;
        }
        if ( !ok ) {
            break;
        }
        ans.clear();
        for ( auto ans_i : tmp_ans ) {
            ans.push_back(ans_i);
        }
        --max_num;
    }

    for ( auto tmp_ans : ans ) {
        cout << tmp_ans << endl;
    }

    return 0;
}

Measured memory_bytes: 384
#include <iostream>
#include <cstdio>
#include <string>
#include <cstdlib>
#include <vector>
#include <algorithm>
#include <functional>
#include <iomanip>
#include <stdlib.h>
#include <cmath>
#include <map>
#define INF 100000000
using namespace std;
map<int, int> mp;
int main()
{
	cin.tie(0);
	ios::sync_with_stdio(false);
	int a, b, c, x, y;
	cin >> a >> b >> c >> x >> y;
	int min1 = a * x + b * y;
	for (int i = 1; i <= 100000; i++) {
		int tmp = i * 2 * c + max(0, x - i) * a + max(0, y - i) * b;
		if (min1 > tmp) min1 = tmp;
	}
	cout << min1 << endl;
	return 0;
}

Measured memory_bytes: 892
import sys
N, = map(int, raw_input().split())
s = raw_input()
k = set([s])
l = s[-1]
for i in range(N-1):
  s = raw_input()
  if s[0]!=l or s in k:
    print "No"
    sys.exit(0)
  k.add(s)
  l = s[-1]
print "Yes"

Measured memory_bytes: 2692
#include<iostream>
#include<string>
#include<vector>
#include<stdio.h>
#include<algorithm>
#include<math.h>
#include<numeric>
#include<iomanip>
#include<deque>
#include<tuple>
#include<queue>
#include<map>
#include <cstdint>
#include<unordered_map>
#include <boost/multiprecision/cpp_int.hpp>


#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define vi vector<int>
#define all(x) (x).begin(),(x).end()
#define Endl endl
#define F first
#define S second

namespace mp = boost::multiprecision;

using cpp_int = mp::cpp_int;
using ll = long long;
using namespace std;


int main() {
	int A, B, C, D, E, F;
	cin >> A >> B >> C >> D >> E >> F;
	double solubility = 100.00000 * E / (E + 100.00000);
	double concentration = 0.00000;
	double water = 0.00000;
	double sugar = 0.00000;
	rep(i, 101) {
		rep(j, 101) {
			rep(k, 101) {
				rep(m, 101) {
				
					double tmpwater = 100.00000 * A*i + 100.00000 * B*j;
					double tmpsugar = C * k + D * m;
					double maxsugar = tmpwater * E / 100.00000;
					if (tmpsugar + tmpwater <= F
						&&tmpsugar+tmpwater!=0
						&&tmpsugar<=maxsugar) {
						double tmp =
							100.00000 * tmpsugar / (tmpsugar+tmpwater);
						if (tmp <= solubility&&
							concentration<tmp) {
							concentration = tmp;
							water = tmpwater;
							sugar = tmpsugar;
						}
						if (concentration==
							solubility) {
							break;
						}
					}
				}
			}
		}
	}
	if (water == 0) {
		water = 100*A;
	}
	cout << water+sugar << " " << sugar;
}


Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <algorithm>
#include <cstdio>
#include <utility>
#include <string>
#include <cmath>
#include <cstdlib>
#include <cstring>
#include <deque>
#include <numeric>

using namespace std;

typedef uint64_t u64;
typedef int64_t s64;
typedef uint32_t u32;
typedef int32_t s32;
typedef vector<s32> vs32;
typedef vector<u32> vu32;
typedef vector<s64> vs64;
typedef vector<u64> vu64;

const double PI=3.14159265358979323846;

#define MAX(x, y) ((x) < (y) ? (y) : (x))
#define MIN(x, y) ((x) > (y) ? (y) : (x))

#define rep(i, N) for(int i = 0; i < N; ++i)

#define CEIL(x, y) (((x) + (y) - 1) / (y))
#define MOD 1000000007ULL

#define IN(l, r, x) ((l) <= (x) && (x) < (r))

int prime_factorization(int x)
{
    map<int, int> frac;
    for (int i = 2; i * i < x; ++i)
    {
        while (x % i == 0)
        {
            ++frac[i];
            x /= i;
        }
    }
    if (x > 1) ++frac[x];

    int ret = 1;
    for (auto item : frac)
    {
        ret *= item.second + 1;
    }
    return ret;
}

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

    int n;
    cin >> n;

    int ans = 0;
    rep (i, n + 1)
    {
        if (i % 2 == 1 && prime_factorization(i) == 8) ++ans;
    }

    cout << ans << "\n";
    return 0;
}



Measured memory_bytes: 3656
#include <algorithm>
#include <bitset>
#include <tuple>
#include <cstdint>
#include <cstdio>
#include <cctype>
#include <assert.h>
#include <stdlib.h>
#include <stdio.h>
#include <cassert>
#include <cfloat>
#include <climits>
#include <cmath>
#include <complex>
#include <ctime>
#include <deque>
#include <fstream>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <list>
#include <limits>
#include <map>
#include <memory>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>
using namespace std;
using ll=long long;
using ld=long double;
//#define int long long
//#define _CRT_SECURE_NO_WARNINGS
#define rep(i, n) for (int i = 0; i < n; i++)
#define _GLIBCXX_DEBUG
const int MOD = 1e9 + 7;
const int INF = 1e18 + 9;
constexpr long double pi = 3.141592653589793238462643383279;
int fact(int i) {
    if (i == 0) return 1;
    return (fact(i - 1)) * i;
}
int gcd(int a, int b) {
    if (b == 0) return a;
    return gcd(b, a % b);
}
int lcm(int a, int b) {
    return a * b / gcd(a, b);
}
int keta(int n) {
    if (n == 0) return 1;
    int count = 0;
    while (n != 0) {
        n /= 10;
        count++;
    }
    return count;
}
int ketasum(int n) {
    int sum = 0;
    while (n != 0) {
        sum += n % 10;
        n /= 10;
    }
    return sum;
}
template<class T> inline bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template<class T> inline bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
char x, y;
int main(void) {
    cin >> x >> y;
    if (x < y) cout << "<" << endl;
    else if (x > y) cout << ">" << endl;
    else cout << "=" << endl;
    return 0;
}

Measured memory_bytes: 3556
# D - Maze Master

from collections import deque

H, W = map(int, input().split())
S = [list(input()) for _ in range(H)]

# ある地点を渡すと、その地点から到達可能かつ距離未計算の地点のリストを返す
def not_investigated_positions(current_position):
    output = []
    for udrl in [[0, 1], [0, -1], [1, 0], [-1, 0]]:
        y = current_position[0]+udrl[0]
        x = current_position[1]+udrl[1]
        if 0 <= y <= H-1 and 0 <= x <= W-1:
            if S[y][x] == "." and distance[y][x] == -1:
                output.append([y, x])
    return output

ans = 0

for sy in range(H):
    for sx in range(W):
        if S[sy][sx] == "#":
            continue
        distance = [[-1]*W for _ in range(H)]
        current_position = [sy, sx]
        distance[sy][sx] = 0
        next_positions = deque()
        next_positions.append(current_position)

        while next_positions:
            current_position = next_positions.popleft()
            for q in not_investigated_positions(current_position):
                distance[q[0]][q[1]] = distance[current_position[0]][current_position[1]] + 1
                next_positions.append(q)

        ans = max(ans, max(map(max,distance)))

print(ans)

Measured memory_bytes: 3316
#include <iostream>
#include <random>
#include <chrono>
#include <algorithm>
#define rep(i, begin, end) for (__typeof(end) i = (begin) - ((begin) > (end)); i != (end) - ((begin) > (end)); i += 1 - 2 * ((begin) > (end)))
using namespace std;
typedef long long ll;
const ll MOD = (ll)1e9 + 7;
const int N = 3e3+5, inf = 1e9+5;
ll add(ll x, ll y) { x += y; if (x >= MOD) return x - MOD; return x; }
ll sub(ll x, ll y) { x -= y; if (x < 0) return x + MOD; return x; }
ll mult(ll x, ll y) { return (x * y) % MOD; }
mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count());

ll dp[N][N];

int main() {
    ios_base::sync_with_stdio(0); cin.tie(0);
    string s, t; cin >> s >> t;
    for (int i = 0; i < s.size(); ++i) {
        for (int j = 0; j < t.size(); ++j) {
            if (s[i] == t[j]) dp[i+1][j+1] = dp[i][j]+1;
            else dp[i+1][j+1] = max(dp[i][j+1], dp[i+1][j]);
        }
    }

    vector<char> ans;
    for (int i = s.size()-1, j = t.size()-1; i >= 0 && j >= 0;) {
        if (s[i] == t[j]) {
            ans.push_back(s[i]);
            i--, j--;
        } else {
            if (dp[i+1][j+1] == dp[i+1][j]) j--;
            else i--;
        }
    }

    for (int i = ans.size()-1; i >= 0; i--)
        cout << ans[i];
    cout << endl;
    return 0;
}

Measured memory_bytes: 70784
#include<iostream>
#include<algorithm>
using namespace std;
int main(){
    int n;
    char s[110];
    cin>>n;
    cin>>s;
    bool x[27]={};
    bool y[27]={};
    int max=0;
    // cout<<s<<endl;
    for(int i=0;i<n;i++){
        for(int k=0;k<=i;k++){
            x[s[k]-'a']=true;
        }
        for(int k=n-1;k>i;k--){
            y[s[k]-'a']=true;
        }
        int ret=0;
        for(int c=0;c<27;c++){
            if(x[c]&&y[c]){
                ret++;
            }
                x[c]=false;
                y[c]=false;
        }
        if(ret>max)max=ret;
        // cout<<i<<" "<<ret<<endl;
    }
    cout<<max<<endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int (i)=0;(i)<(n);i++)
#define INF 1001001001
#define LLINF 1001001001001001001
#define MOD 1000000007
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 (b<a) { a=b; return 1; } return 0; }
#define ALL(v) v.begin(), v.end()
typedef long long ll;



int main(){
    char s;cin>>s;
    cout << char(s+1)<<endl;
}





Measured memory_bytes: 256
import java.util.*;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int k = sc.nextInt();
        int[] h = new int[n];
        for (int i = 0; i < n; i++) {
            h[i] = sc.nextInt();
        }
        long a = 0L;
        Arrays.sort(h);
        for (int i = 0; i < n; i++) {
            if(i < k) continue;
            a += h[n-1-i];
        }
        System.out.println(a);
        sc.close();

    }

}


Measured memory_bytes: 66616
from collections import Counter

def C(n):
    if n < 2: return 0
    return n * (n-1) // 2    
    
n = int(input())
a = list(map(int, input().split()))
c = Counter(a)

count = 0

for i, j in c.items():
    count += C(j)

for i in a:
    m = c[i]
    print(count - m + 1)

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

using namespace std;


int main(){

  int N;
  cin >> N;
  std::vector<int> vH(N);

  int h;
  for(int i = 0; i< N; ++i){
    cin >> h;
    vH.at(i) = h;
  }

  int ans = 0;
  int hMax = 0;
  for(int i = 0; i < N; ++i){
    if(vH.at(i) >= hMax){
      ans += 1;
      hMax = vH.at(i);
    }
  }

  std::cout << ans << std::endl;

  return 0;

}


Measured memory_bytes: 256
/*ex3_2
ryo_1129*/
#include <stdio.h>

int main(void){
	int N; //変数宣言
	scanf("%d",&N); //入力
	//１の位が３の時、bonを出力
	if(N%10 ==3){
		printf("bon\n");
	//１の位が0,1,6,8の時、ponを出力
	}else if(N%10 == 0 || N%10 == 1|| N%10 == 6 || N%10 == 8){
		printf("pon\n");
	//それ以外、honを出力
	}else{
		printf("hon\n");
	}
	
}

Measured memory_bytes: 1644
# frozen_string_literal: true

n, k = gets.split.map(&:to_i)
a = gets.split.map(&:to_i)
h = Hash.new
a.each_with_index do |e, i|
  h[i + 1] = e
end
c = [1]
i = 1
hh = Hash.new { false }
ind = 0
hh[1] = true
loop do
  i = h[i]
  if hh[i]
    ind = c.index(i)
    break
  end

  c.push i
  hh[i] = true
end
if k <= c.size - 1
  puts c[k]
else
  puts c[ind..-1][(k - ind) % (c.size - ind)]
end


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

using namespace std;

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

int main() {
  int n;
  cin >> n;
  vector<int> a(n);
  for (int i = 0; i < n; i++) {
    cin >> a[i];
  }
  function<bool()> solve = [&]() {
    int even_n = 0, odd_n = 0, odd_e = -1;
    for (int i = 0; i < n; i++) {
      if (a[i] & 1) {
        odd_n++;
        odd_e = a[i];
      } else {
        even_n++;
      }
    }
    cerr << "odd_n = " << odd_n << " even_n = " << even_n << endl;
    if (odd_n > 1) {
      if (even_n & 1) {
        return true;
      } else {
        return false;
      }
    } else if (odd_n == 1) {
      if (even_n & 1) {
        return true;
      } else {
        if (odd_e > 1) {
          int odd_id = -1;
          for (int i = 0; i < n; i++) {
            if (a[i] & 1) {
              assert(odd_id == -1);
              odd_id = i;
            }
          }
          a[odd_id]--;
          int g = 0;
          for (int i = 0; i < n; i++) {
            g = gcd(g, a[i]);
          }
          for (int i = 0; i < n; i++) {
            a[i] /= g;
          }
          bool ret = !solve();
          for (int i = 0; i < n; i++) {
            a[i] *= g;
            if (odd_id == i) {
              a[i]++;
            }
          }
          return ret;
        } else {
          return false;
        }
      } 
    } else {
      if (even_n & 1) {
        for (int i = 0; i < n; i++) {
          if (a[i] == 2) {
            return true;
          }
        }
        for (int i = 0; i < n; i++) {
          a[i]--;
          int g = 0;
          for (int j = 0; j < n; j++) {
            g = gcd(g, a[j]);
          }
          for (int j = 0; j < n; j++) {
            a[j] /= g;
          }  
          if (!solve()) {
            return true;
          }
          for (int j = 0; j < n; j++) {
            a[j] *= g;
          }
          a[i]++;
        }
        return false;
      } else {
        return false;
      }
    }
  };
  bool ans = solve();
  cout << (ans ? "First" : "Second") << '\n';
  return 0;
}

Measured memory_bytes: 640
#include <iostream>
using namespace std;
typedef long long ll;
static const ll Z = 1 << 21;
#define rep(i,s,n)for(ll i = s;i<n;i++)

char s[Z];
int main() {
	cin >> s;
	int i = 0;
	while (*(s + i) != '\0') i++;
	cout << *s << i - 2 << *(s + i - 1) << endl;
	return 0;
}

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

int main()
{
	double avg=0;
	int n, result, sum = 0;
	cin >> n;
	int* p = new int[n];
	for (int i = 0; i < n; i++)
	{
		cin >> p[i];
		avg += p[i];
	}
	avg /= n;
	if (2 * avg >= 2 * (int)avg + 1) result = avg + 1;
	else result = avg;

	for (int i = 0; i < n; i++)
	{
		sum += pow(p[i] - result, 2);
	}
	cout << sum << endl;

	delete[] p;
	return 0;

}

Measured memory_bytes: 256
#include <algorithm>
#include <cstdio>
#include <cstdlib>
#include <cstdint>
#include <cmath>
#include <iostream>
#include <map>
#include <set>
#include <queue>
#include <vector>

using namespace std;

constexpr static int MAXN = 50;
constexpr static int MAXA = (1 << 18);

int n, k, S, T;
int a[MAXN], b[MAXN];
int64_t choose[MAXN + 1][MAXN + 1];
int64_t nsubsets[MAXN + 1];

int64_t calc() {
    if ((S | T) != T)
        return 0;

    int m = 0;
    for (int i = 0; i < n; i++)
        if ((a[i] & S) == S && (a[i] | T) == T)
            b[m++] = a[i];

    // for each mask subset, count subsets that have same bits, use PIE
    int64_t total = 0;
    for (int mask = 0; mask < MAXA; mask++) {
        if ((mask | (S ^ T)) != (S ^ T))
            continue;
        map <int, int> cnt;
        for (int i = 0; i < m; i++)
            cnt[b[i] & mask]++;

        int64_t nsame = 0;
        for (auto kv : cnt) {
            // cout << kv.second << " ";
            nsame += nsubsets[kv.second];
        }
        // cout << endl;

        int bits = __builtin_popcount(mask);
        if (bits % 2 == 0)
            total += nsame;
        else
            total -= nsame;
    }
    return total;
}

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

    cin >> n >> k >> S >> T;
    for (int i = 0; i < n; i++)
        cin >> a[i];

    choose[0][0] = 1;
    for (int i = 1; i <= n; i++) {
        choose[i][0] = choose[i][i] = 1;
        for (int j = 1; j < i; j++)
            choose[i][j] = choose[i - 1][j] + choose[i - 1][j - 1];
    }
    for (int i = 1; i <= n; i++) {
        nsubsets[i] = 0;
        for (int j = 1; j <= k && j <= i; j++)
            nsubsets[i] += choose[i][j];
    }

    cout << calc() << endl;
}


Measured memory_bytes: 3212
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<ll> vll;
typedef pair<ll, ll> pll;
typedef vector<pll> vpll;
typedef string str;
static const long long INF = INT64_MAX;
static const long long MOD = (ll)1e9+7;

#define endl "\n"
#define fast_io ios_base::sync_with_stdio(false);cin.tie(NULL)
#define REP(i, n) for(ll i=0;i<n;i++)
#define SZ(v) (ll)((v).size())
#define WHOLE(v) (v).begin(), (v).end()
#define ASC(v) sort((v).begin(), (v).end())
#define DESC(v) sort((v).rbegin(), (v).rend())
#define INV(v) reverse((v).begin(), (v).end())
#define FOLDL(src, dst, lambda) partial_sum((src).begin(), (src).end(), (dst).begin(), lambda)
#define FOLDR(src, dst, lambda) INV(src);partial_sum((src).begin(), (src).end(), (dst).begin(), lambda);INV(dst)
#define CUMSUML(src, dst) FOLDL(src, dst, [](auto a, auto b) {return a+b;})
#define CUMSUMR(src, dst) FOLDR(src, dst, [](auto a, auto b) {return a+b;})
#define ACCUM(v, d0, lambda) accumulate((v).begin(), (v).end(), d0, lambda)
#define SUM(v, d0) ACCUM(v, d0, [](auto a, auto b) {return a+b;})
#define ERASE(v, i) v.erase(v.begin() + i)
#define UNIQ(v) ASC(v);v.erase(unique(v.begin(), v.end()), v.end())

template <typename T>void debug(T t) {cerr << t << endl;}
template <typename T, typename ...Args>void debug(T t, Args ...args) {cerr << t << " ";debug(args...);}
template <typename T>void out(T t) {cout << t << endl;}
template <typename T, typename ...Args>void out(T t, Args ...args) {cout << t << " ";out(args...);}

void solve() {
    str s, t;
    cin >> s;
    t.resize(s.size());
    REP(i, s.size()) {
        t[i] = (i % 2 == 0 ? 'g' : 'p');
    }
    ll ans = 0;
    REP(i, s.size()) {
        if(s[i] == 'p' && t[i] == 'g') ans--;
        if(s[i] == 'g' && t[i] == 'p') ans++;
    }
    out(ans);
}

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


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

#define BUF_SIZE 10

// size: specify sizeof(str)
int get_str(char *str, int size) {
    if(!fgets(str, size, stdin)) return -1;
    return 0;
}

int get_int(void) {
  int num;
#ifdef BUF_SIZE
  char line[BUF_SIZE];
  if(!fgets(line, BUF_SIZE, stdin)) return 0;
  sscanf(line, "%d", &num);
#else
#error
#endif
  return num;
}

int get_int2(int *a1, int *a2) {
#ifdef BUF_SIZE
  char line[BUF_SIZE];
  if(!fgets(line, BUF_SIZE, stdin)) return -1;
  sscanf(line, "%d %d", a1, a2);
#else
#error
#endif
  return 0;
}

// TODO: how many data sets?
#define ANS_MAX 1000000

int main(void) {
    int n, x;
    int ans[ANS_MAX];
    int idx = 0;
    int i, j, k;
    while(1) {
        get_int2(&n, &x);
        if(n+x == 0) break;

        int cnt = 0;
        for(i = 1; i <= n; i++) {
            for(j = i+1; j <= n; j++) {
                for(k = j+1; k <= n; k++) {
                    if(i+j+k == x) cnt++;
                }
            }
        }
        ans[idx++] = cnt;
    }
    for(i = 0; i < idx; i++) {
        printf("%d\n", ans[i]);
    }
    return 0;
}



Measured memory_bytes: 2056
A = list(map(int,input().split()))
cnt = 0
cost = 0
sum_A = sum(A)
min = 9999
for i in range(len(A)):
    cost = 0
    for j in range(len(A)):
            if i != j:
                cost = abs(A[j] - A[i] ) + abs(A[j] - (sum_A - A[i] - A[j]))
                if min > cost:
                    min = cost
cost = 0
print(min)

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

#define ll long long

int main() {
    std::ios::sync_with_stdio(false);
    using namespace std;
    int n, k;
    cin >> n >> k;
    vector<int> A(n), B(n + 1, 1e9 + 10);
    for(int i = 0; i < n; i++) cin >> A[i];
    B[0] = 0;
    for(int i = 1; i < n; i++) {
        for(int j = max(0, i - k); j < i; j++)
            B[i] = min(B[i], B[j] + abs(A[i] - A[j]));
    }
    cout << B[n - 1] << "\n";
    
    return 0;
}


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

int main() {
  int n;
  cin >> n;
  string ans = "Three";
  
  for (int i = 0; i < n; i++) {
    string si;
    cin >> si;
    
    if (si == "Y") {
      ans = "Four";
      break;
    }
  }
  
  cout << ans << endl;
}


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



int main() {
   ios_base::sync_with_stdio(false);

   long long int i,j,k,a,b,c,d,n,m;
   cin>>n;
   long long int mx=0;
   c=0;
   vector <long long int> v1;
   for(i=0;i<n;i++)
   {
       cin>>a;
       v1.push_back(a);
       if(i>0)
       {
           if(v1[i]<=v1[i-1])
            c++;
           else
           {
               mx=max(mx,c);
               c=0;
           }
       }
   }
   mx=max(mx,c);
   cout<<mx<<"\n";
  return 0;
}


Measured memory_bytes: 1400
n = int(input())
a = [int(input()) for _ in range(n)]

idx = 0
cnt = 0
while True:
    cnt += 1
    idx = a[idx] - 1
    if idx+1 == 2:
        break
    
    if cnt > len(a):
        cnt = -1
        break

print(cnt)

Measured memory_bytes: 7084
import fractions
A,B,C,D = map(int,input().split())

def lcm(x, y):
    return (x * y) // fractions.gcd(x, y)

LCM = lcm(C,D)
BC = B // C
BD = B // D
BCD = B // LCM
AC = (A-1) // C
AD = (A-1) // D
ACD = (A-1) // LCM
x = B - BC - BD + BCD
y = (A-1) - AC - AD + ACD
print(x - y)

Measured memory_bytes: 5076
(* O(|s|) *)
let get_left_info s =
  let n = String.length s in
  let left = Array.make (n + 1) 0 in
  for i = 0 to n - 2 do
    left.(i + 1) <- left.(i) + if s.[i] = 'A' && s.[i + 1] = 'C' then 1 else 0
  done;
  left

(* O(max {n, q}) *)
let _ = Scanf.scanf " %d %d %s" @@ fun n q s ->
  let left = get_left_info s in
  for i = 1 to q do
    Scanf.scanf " %d %d" @@ fun l r ->
      Printf.printf "%d\n" @@ left.(r - 1) - left.(l - 1) (* r - 1 = r - 1 - (|"AC"| - 2) *)
  done

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

long A[100000];

int main()
{
    long N;
    cin >> N;

    priority_queue<long> A_;
    for(int n = 0; n < N; n++) {
        long m;
        cin >> m;
        A_.push(m);
    }
    long i = N - 1;
    while (!A_.empty()) {
        A[i] = A_.top();
        A_.pop();
        i--;
    }

    /*
    for(int i = 0; i < N; i++) {
        cout << A[i] << " ";
    }*/
    
    long l = 0;
    long r = N - 1;
    long sum = 0;

    long c = A[N / 2]; // N が偶数の場合はスタートは真ん中のどっちでも良い（右が選ばれる）
    long d = 0; // 0 が左、1 が右

    if(N >= 3 && N % 2 != 0) {
        //cout << A[N / 2] << endl;
        //cout << A[N / 2 - 1];
        //cout << A[N / 2 + 1];
        if(abs(A[N / 2] - A[N / 2 - 1]) < abs(A[N / 2 + 1] - A[N / 2])) {
            d = 1;
            //cout << "d = 1" << endl;
        }
        // なお、N が偶数の場合は遠い方に左に飛ぶので d = 0 でよい
    }
    while(l != r) {
        if(d == 0) {
            //cout << d << ": l = " << l << ", " << abs(c - A[l]) << endl;
            sum += abs(c - A[l]);
            c = A[l];
            l++;
        } else {
            //cout << d << ": r = " << r << ", " << abs(c - A[r]) << endl;
            sum += abs(c - A[r]);
            c = A[r];
            r--;
        }
        //cout << sum << endl;
        d = 1 - d;
    }
    cout << sum;

    return 0;
}


Measured memory_bytes: 2036
#include<deque>
#include<queue>
#include<vector>
#include<algorithm>
#include<iostream>
#include<set>
#include<cmath>
#include<tuple>
#include<string>
#include<chrono>
#include<functional>
#include<iterator>
#include<random>
#include<unordered_set>
#include<array>
#include<map>
#include<iomanip>
#include<assert.h>
#include<bitset>
#include<stack>
#include<memory>
using namespace std;
using namespace std::chrono;
typedef long long int llint;
typedef double lldo;
#define mp make_pair
#define mt make_tuple
#define pub push_back
#define puf push_front
#define pob pop_back
#define pof pop_front
#define fir first
#define sec second
#define res resize
#define ins insert
#define era erase
/*cout<<fixed<<setprecision(20);cin.tie(0);ios::sync_with_stdio(false);*/
const llint mod=1000000007;
const llint big=2.19e15+1;
const long double pai=3.141592653589793238462643383279502884197;
const long double eps=1e-15;
template <class T,class U>bool mineq(T& a,U b){if(a>b){a=b;return true;}return false;}
template <class T,class U>bool maxeq(T& a,U b){if(a<b){a=b;return true;}return false;}
llint gcd(llint a,llint b){if(a%b==0){return b;}else return gcd(b,a%b);}
llint lcm(llint a,llint b){if(a==0){return b;}return a/gcd(a,b)*b;}
template<class T> void SO(T& ve){sort(ve.begin(),ve.end());}
template<class T> void REV(T& ve){reverse(ve.begin(),ve.end());}
template<class T>llint LBI(vector<T>&ar,T in){return lower_bound(ar.begin(),ar.end(),in)-ar.begin();}
template<class T>llint UBI(vector<T>&ar,T in){return upper_bound(ar.begin(),ar.end(),in)-ar.begin();}
int main(void){
	//n<100 で 200点あげていいと思う
	int n,i;cin>>n;
	vector<int>a(n);
	for(i=0;i<n;i++){cin>>a[i];}
	SO(a);
	if(a[n-1]==0){cout<<"Yes"<<endl;return 0;}
	if(n%3!=0){cout<<"No"<<endl;return 0;}
	int m=n/3;
	if(a[0]!=a[m-1]||a[m]!=a[m+m-1]||a[m+m]!=a[m+m+m-1]||((a[0]^a[m])!=a[m+m])){cout<<"No"<<endl;}
	else{cout<<"Yes"<<endl;}
	return 0;
}

Measured memory_bytes: 640
#include <iostream>
#include <algorithm>
#include <vector>
#include <cmath>
#include <utility>
typedef long long ll;
using namespace std;
const int mod=1e9+7;

ll solve(){
    ll sm=0,ans=0;
    ll n,t=0;
    cin>>n;
    int a[n];
    for(int &i:a) cin>>i,sm=(sm+i)%mod;
    for(int i=0;i<n;i++){
        t=(t+a[i])%mod;
        ans=(ans + ((sm-t+mod)%mod)*a[i]%mod )%mod;
    }
    return ans;
}

int main()
{
#ifndef ONLINE_JUDGE
    freopen("input.txt","r",stdin);
    freopen("output.txt","w",stdout);
#endif
    int t=1;
    //cin>>t;
    while(t--) cout<<solve()<<'\n';
    //while(t--) solve(),cout<<'\n';
    return 0;
}


Measured memory_bytes: 4380
#include <bits/stdc++.h>
#define maxn 100086

using namespace std;

int n;

int main(){
	scanf("%d", &n);
	int x = 0;
	for(int i = 1;i <= n * 7;i++){
		x = (1ll * x * 10 + 7) % n;
		if(x == 0) return printf("%d", i), 0;
	} 
	puts("-1");
}

Measured memory_bytes: 3816
#include<iostream>
using namespace std;
int main(){
  int N;
  cin >> N;
  int W[N];
  for (int i = 0; i < N; i++)
    cin >> W[i];
  int ans = 100000;
  int S1 = 0;
  int S2 = 0;
  for (int i = 0; i < N; i++){
    S1 = 0;
    S2 = 0;
    for (int j = 0; j < N; j++){
      if (j <= i)
        S1 += W[j];
      else
        S2 += W[j];
    }
    if (abs(S1-S2) < ans)
      ans = abs(S1-S2);
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
import std.algorithm, std.container, std.conv, std.math, std.range, std.typecons, std.stdio, std.string;

auto rdsp(){return readln.splitter;}
void pick(R,T)(ref R r,ref T t){t=r.front.to!T;r.popFront;}
void readV(T...)(ref T t){auto r=rdsp;foreach(ref v;t)pick(r,v);}

void main()
{
  int q; readV(q);

  foreach (_; 0..q) {
    long a, b; readV(a, b);

    if (a > b) swap(a, b);

    if (a == b) {
      writeln(a*2-2);
    } else {
      auto c = nsqrt(a*b-1);
      if (c*(c+1) >= a*b)
        writeln(c*2-2);
      else
        writeln(c*2-1);
    }
  }
}

pure T nsqrt(T)(T n)
{
  import std.algorithm, std.conv, std.range, core.bitop;
  if (n <= 1) return n;
  T m = T(1) << (n.bsr/2+1);
  return iota(1, m).map!"a * a".assumeSorted!"a <= b".lowerBound(n).length.to!T;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n - 1; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i <= n; i++)
#define FORR(i, m, n) for(int i = m; i >= n; i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define VSORTR(v) sort(v.rbegin(), v.rend());
#define ALL(v) (v).begin(),(v).end()
 
using ll = long long;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
using P = pair<ll, ll>;

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

    ll x, y, a, b, c;
    cin >> x >> y >> a >> b >> c;
    vll p(a), q(b), r(c), mem;
    REP(i, a) cin >> p[i];
    REP(i, b) cin >> q[i];
    REP(i, c) cin >> r[i];

    VSORTR(p);
    VSORTR(q);
    VSORTR(r);

    REP(i, x) mem.push_back(p[i]);
    REP(i, y) mem.push_back(q[i]);
    REP(i, c) mem.push_back(r[i]);

    VSORTR(mem);

    ll res = 0;
    REP(i, x + y) res += mem[i];

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

Measured memory_bytes: 8816
#include<stdio.h>

void trace(int A[], int N) {
    int i;
    for (i = 0; i < N; i++) {
        if (i > 0) printf(" ");
        printf("%d", A[i]);
    }
    printf("\n");
}

void insertionSort(int A[], int N) {
    int j, i, v;
    for (i = 1; i < N; i++) {
        v = A[i];
        j = i - 1;
        while (j >=0 && A[j] > v) {
            A[j+1] = A[j];
            j--;
        }
    A[j+1] = v;
    trace(A, N);
    }
}


int main() {
    int N, i, j;
    int A[100];

    scanf("%d", &N);
    for (i = 0; i < N; i++) scanf("%d", &A[i]);

    trace(A, N);
    insertionSort(A, N);

    return 0;
}

Measured memory_bytes: 2740
#include <iostream>
#include <string>
#include <sstream>
#include <utility>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <queue>
#include <cmath>
#include <functional>
#include <chrono>
#include <cstring>
#include <bits/stdc++.h>


using namespace std;
typedef long long lint;
typedef vector<int> vi;
typedef pair<int,int> pii;

typedef vector<lint> vl;
typedef pair<lint,lint> pll;

#define mpr make_pair


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

    int n; cin>>n;
    map<string, int> cnt;
    string s;
    for (int i=0; i<n; ++i){
        cin>>s;
        cnt[s]++;
    }

    cout<<"AC x "<<cnt["AC"]<<endl;
    cout<<"WA x "<<cnt["WA"]<<endl;
    cout<<"TLE x "<<cnt["TLE"]<<endl;
    cout<<"RE x "<<cnt["RE"]<<endl;
}


Measured memory_bytes: 3680
#include<bits/stdc++.h>
            using namespace std;
            #define rep(i,b) for(i=0;i<b;++i)
            #define repp(i,a,b) for(i=a;i<b;++i)
            #define endl "\n"
            //#define LLONG_MAX 99999999999999
            typedef long long int lli;
            int main(){
                lli t,n,i,j,k,m;
                cin>>n;
                vector<int> v(n);
                vector<int> ans(n);
                for(i=0;i<n;i++)cin>>v[i];
                ans[0]=0;
                ans[1]=abs(v[0]-v[1]);
                for(i=2;i<n;i++)ans[i]=min(ans[i-1]+abs(v[i]-v[i-1]),ans[i-2]+abs(v[i]-v[i-2]));
                cout<<ans[n-1]<<endl;
                return 0;



            }

Measured memory_bytes: 1024
#include <stdio.h>


int main(){

    int n;
    int u;
    int m;
    scanf("%d%d%d", &n,&u,&m);
   
    if(n+u==m||n+m==u||u+m==n) {
        printf("Yes");
    }
    else {
        printf("No");
    }
    
    return 0;
}





Measured memory_bytes: 128
#include<bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < n ; i++)
#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define whole(f, x, ...) ([&](decltype((x)) whole) { return (f)(begin(whole), end(whole), ## __VA_ARGS__); })(x) // decltypeで型取得、引数があればva_argsのところに入れる
using namespace std;
typedef long long ll; // long longをllでかけるようにした
const int INF = 1e9;

int main(void){
    int n, m; cin >> n >> m;
    if(n == m) cout << "Yes" << endl;
    else cout << "No" << endl;
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main()
{
    int a,b,c;
    cin>>a>>b>>c;
    if(a<b)
        {
            if(a<c)
                cout<<"Yes\n";
            else
                cout<<"No\n";
        }
    else
        cout<<"No\n";
    return 0;
}


Measured memory_bytes: 3104
#include <bits/stdc++.h>
typedef long long int ll;
typedef long double ld;
using namespace std;
const long long int INF = 1e6;
const long long int inf = 1e9+7;
typedef pair<ll,ll> pairs;
vector<pairs> p;


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

ll keta(ll N){
    int tmp{};
    while( N > 0 ){
        tmp += ( N % 10 );
        N /= 10;
    }
    N = tmp;
    return N;
}

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

int main(){
    ll r;
    cin>>r;
    cout<<2*r*3.141592<<endl;
}

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


#define MOD 1000000007

using namespace std;

long long int modpow(long long int a, long long int n) {
	if (n == 0)return 1;
	if (n == 1)return (a % MOD);

	long long int hanbun = n / 2;
	long long int amari = n % 2;

	long long int ans = (a * a) % MOD;
	ans = modpow(ans, hanbun);

	if (amari == 1)ans *= a;

	ans %= MOD;

	return ans;

}

long long int gcd(long long int a, long long int b) {
	if (a < b) {
		long long int tmp = a;
		a = b;
		b = tmp;
	}

	long long int amari = a % b;

	if (amari == 0)return b;

	return gcd(b, amari);
}

long long int lcm(long long int a, long long int b) {
	long long int ans = (a * b) % MOD;
	long long int wari = modpow(gcd(a, b), MOD - 2);
	ans = (ans * wari) % MOD;
	return ans;
}

long long int factElement[10000] = { 0 };

long long int factrial(int n) {

	if (factElement[n] != 0)return factElement[n];

	if (n == 0) {
		factElement[0] = 1;
		return factElement[n];
	}

	long long int ans = n * factrial(n - 1);
	factElement[n] = ans;
	return factElement[n];

}


int main()
{

	long long int a, b, c;
	cin >> a >> b >> c;

	if (c - a - b < 0) {
		cout << "No" << endl;
		return 0;
	}

	if (4 * a * b < (c - a - b) * (c - a - b)) {
		cout << "Yes" << endl;


	}
	else {
		cout << "No" << endl;
	}


	




	return 0;

}



Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashSet;
import java.util.List;
import java.util.Set;

class Main {
    public static void main(final String[] args) throws Exception {

        try (BufferedReader br = new BufferedReader(new InputStreamReader(System.in));) {
            String input = br.readLine();

            String ans = input.substring(0, 1) + input.substring(1, input.length() - 1).length()
                    + input.substring(input.length() - 1);

                    System.out.println(ans);
        } catch (IOException | NumberFormatException e) {
            e.printStackTrace();
            System.exit(0);
        } catch (final Exception e) {
            e.printStackTrace();
            System.exit(0);
        }
    }
}

Measured memory_bytes: 23124
#include<iostream>
#include<vector>
#include<algorithm>
#define all(a) (a).begin(),(a).end()
using namespace std;

int n,m,h[2000],w[2000];

int main(){
  while(cin >> n >> m,n){
    vector<int> sumh,sumw;
    for(int i=0;i<n;i++)cin >> h[i];
    for(int i=0;i<n;i++){
      int sum = 0;
      for(int j=i;j<n;j++){
	sum += h[j];
	sumh.push_back(sum);
      }
    }

    for(int i=0;i<m;i++)cin >> w[i];
    for(int i=0;i<m;i++){
      int sum = 0;
      for(int j=i;j<m;j++){
	sum += w[j];
	sumw.push_back(sum);
      }
    }

    sort(all(sumh)); sort(all(sumw));

    int ans = 0;
    for(int i=0;i<sumh.size();i++){
      ans += upper_bound(all(sumw),sumh[i]) - lower_bound(all(sumw),sumh[i]);
    }
    cout << ans << endl;
  }
}


	

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

using namespace std;

using int64 = long long;
const int mod = 1000003;

const int64 infll = (1LL << 62) - 1;
const int inf = (1 << 30) - 1;

struct IoSetup {
  IoSetup() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(10);
    cerr << fixed << setprecision(10);
  }
} iosetup;

template <typename T1, typename T2>
ostream &operator<<(ostream &os, const pair<T1, T2> &p) {
  os << p.first << " " << p.second;
  return os;
}

template <typename T1, typename T2>
istream &operator>>(istream &is, pair<T1, T2> &p) {
  is >> p.first >> p.second;
  return is;
}

template <typename T>
ostream &operator<<(ostream &os, const vector<T> &v) {
  for (int i = 0; i < (int)v.size(); i++) {
    os << v[i] << (i + 1 != v.size() ? " " : "");
  }
  return os;
}

template <typename T>
istream &operator>>(istream &is, vector<T> &v) {
  for (T &in : v) is >> in;
  return is;
}

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

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

template <typename T = int64>
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 F>
struct FixPoint : F {
  FixPoint(F &&f) : F(forward<F>(f)) {}

  template <typename... Args>
  decltype(auto) operator()(Args &&... args) const {
    return F::operator()(*this, forward<Args>(args)...);
  }
};

template <typename F>
inline decltype(auto) MFP(F &&f) {
  return FixPoint<F>{forward<F>(f)};
}

int main() {
  int N;
  cin >> N;
  vector<int> X(N);
  cin >> X;

  int mn = inf;
  for (int i = 1; i <= 100; i++) {
    int tmp = 0;
    for (int j = 0; j < N; j++) {
      tmp += (X[j] - i) * (X[j] - i);
    }
    mn = min(mn, tmp);
  }
  cout << mn << endl;
}


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

int counter_function(int x){
	if(x==0){ return 0; }
	return counter_function(x>>1)+(x & 1);
}

int main() {
	int N, M, k, on_switch_cnt, on_light_cnt, all_light;
	vector<vector<int>> s;
	vector<int> p;
	cin >> N >> M;

	s.resize(M);
	p.resize(M);
	for(int i=0; i<M; i++){
		cin>>k;
		s[i].resize(k);
		for(int j=0; j<k; j++){
			cin>>s[i][j];
		}
	}
	for(int i=0; i<M; i++){
		cin>>p[i];
	}
	
	all_light=0;//全ての電球が点灯しているときの数
	for(int bits=0; bits<(1<<N); bits++){//2^Nパターンを2bit全探索
		on_light_cnt=0;//点灯している電球の数
		for(int i=0; i<M; i++){
			on_switch_cnt=0;
			for(int j=0; j<s[i].size(); j++){
				if((bits>>(s[i][j]-1))&1){
					on_switch_cnt++;
				}
			}
			if(on_switch_cnt%2==p[i]){
				on_light_cnt++;
			}
		}
		if(on_light_cnt==M){
			all_light++;
		}
	}

	cout<<all_light<<endl;
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
 
typedef    long long          ll;
typedef    vector<long long>    vi; 
typedef    vector<vi>         vvi; 
typedef    pair<long,long>      ii; 
#define    sz(a)              long((a).size()) 
#define    pb                 push_back 
#define    mp                   make_pair
#define    all(c)             (c).begin(),(c).end() 
#define    tr(c,i)            for(typeof((c).begin() i = (c).begin(); i != (c).end(); i++) 
#define    present(c,x)       ((c).find(x) != (c).end()) 
#define    cpresent(c,x)      (find(all(c),x) != (c).end())  
#define    input(v,n)           for(ll i = 0 ; i<n ; i++) cin>>v[i]
#define    output(v,n)          for(ll i = 0 ; i<n ; i++) cout<<v[i]<<" "
#define    ff           first
#define    ss           second




void __print(int x) {cerr << x;}
void __print(long x) {cerr << x;}
void __print(long long x) {cerr << x;}
void __print(unsigned x) {cerr << x;}
void __print(unsigned long x) {cerr << x;}
void __print(unsigned long long x) {cerr << x;}
void __print(float x) {cerr << x;}
void __print(double x) {cerr << x;}
void __print(long double x) {cerr << x;}
void __print(char x) {cerr << '\'' << x << '\'';}
void __print(const char *x) {cerr << '\"' << x << '\"';}
void __print(const string &x) {cerr << '\"' << x << '\"';}
void __print(bool x) {cerr << (x ? "true" : "false");}
 
template<typename T, typename V>
void __print(const pair<T, V> &x) {cerr << '{'; __print(x.first); cerr << ','; __print(x.second); cerr << '}';}
template<typename T>
void __print(const T &x) {int f = 0; cerr << '{'; for (auto &i: x) cerr << (f++ ? "," : ""), __print(i); cerr << "}";}
void _print() {cerr << "]\n";}
template <typename T, typename... V>
void _print(T t, V... v) {__print(t); if (sizeof...(v)) cerr << ", "; _print(v...);}
#ifndef ONLINE_JUDGE
#define debug(x...) cerr << "[" << #x << "] = ["; _print(x)
#else
#define debug(x...)
#endif


vi g[200010];
ll vis[200010];
ll ans = 0;



ll dfs(ll s)
{
  //debug(s);
  vis[s]=1;
  ll val = 1;
  for(ll i = 0; i<g[s].size();i++)
  {
    if(vis[g[s][i]] == 0)
    {
      val +=dfs(g[s][i]);
    }
  }
  //debug(s,val);
  return val;
}

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

    ll n,m,i;
    cin>>n>>m;
    for(i=0;i<m;i++)
    {
      ll x,y;
      cin>>x>>y;
      g[x].pb(y);
      g[y].pb(x);
    }
    ll ans = 0;


    for(i=1;i<=n;i++)
    {
      if(vis[i] == 0)
      {
        ll p = dfs(i);
   
        ans = max(ans,p);
      }
    }

    cout<<ans<<"\n";


  return 0;
}

Measured memory_bytes: 25488
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int n, count=0, b;
  cin >> n;

  vector<int> a(n+1);
  for(int i=1;i<n+1;i++)
  	cin >> a.at(i);

  b = a.at(1);
  count++;
  for(int i=0;i<n;i++){
  	if(b==2){
  		cout << count << endl;
  		return 0;
  	}else{
  		b = a.at(b);
  		count++;
  	}
  }
  cout << -1 << endl;
}

Measured memory_bytes: 640
using System;
using System.Collections;
using System.Collections.Generic;
using System.Text;
using static MyIO;


public class C
{
	public static void Main()	
	{
		int N = GetInt();
		long T = GetLong();
		long[] t = new long[N];
		for(int i = 0; i < N; i++)
			t[i] = GetLong();

		long ans = T;
		for(int i = 1; i < N; i++)
			ans += Math.Min(T, t[i] - t[i-1]);

		Console.WriteLine(ans);
	}
}


public static class MyIO
{
	private static string[] args = null;
	private static int num = -1;
	private static int used = -1;

	private static string getArg()
	{
		if(used == num)
		{
			args = Console.ReadLine().Split(' ');
			num = args.Length;
			used = 0;
		}
		return args[used++];
	}

	public static int GetInt(){ return int.Parse(getArg()); }
	public static long GetLong(){ return long.Parse(getArg()); }
	public static double GetDouble(){ return double.Parse(getArg()); }
	public static string GetString(){ return getArg(); }
}


Measured memory_bytes: 32796
from bisect import bisect

a,b,q=map(int,input().split())
s=[-10**18]+[int(input()) for i in range(a)]+[10**18]
t=[-10**18]+[int(input()) for i in range(b)]+[10**18]

for i in range(q):
  x=int(input())
  s_inx=bisect(s,x)
  t_inx=bisect(t,x)

  s_l=s[s_inx-1]
  s_r=s[s_inx]

  t_l=t[t_inx-1]
  t_r=t[t_inx]

  ans=10**18
  for i in [s_l,s_r]:
    for j in [t_l,t_r]:
      ans=min(ans,abs(i-x)+abs(j-i))

  for i in [t_l,t_r]:
    for j in [s_l,s_r]:
      ans=min(ans,abs(i-x)+abs(j-i))

  print(ans)

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

string str[4] = {"maerd", "remaerd", "esare", "resare"};

int main(){
	string s;
	cin >> s;
	reverse(s.begin(), s.end());
	for(int i=0; i< s.size();){
		for(int j=0; j<4; j++){
			if(s.substr(i,str[j].size()) == str[j]){
				i += str[j].size();
				break;
			}
			if(j == 3){
				cout << "NO" << endl;
				return 0;
			}
		}
	}
	cout << "YES" << endl;
	return 0;
}

Measured memory_bytes: 512
#include <iostream>
#include <iomanip>
#include <cstdio>
using namespace std;

int main()
{
	const double pai = 3.141592653589;
	double r;
	cin >> r;
	printf("%.5lf %.5lf\n",pai * r * r,2 * pai * r);
	return 0;
}

Measured memory_bytes: 3192
//include
//------------------------------------------
#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 <ctime>

using namespace std;

#define SORT(c) sort((c).begin(),(c).end())
#define ANS(ans) cout<<(ans)<<endl;
typedef vector<int> VI;


//repetition
//------------------------------------------
#define FOR(i,a,b) for(int i=(a);i<=(b);++i)
#define REP(i,n)  for (int i = 0; i < (n); ++i)



int main() {
	int h, w;
	cin >> h >> w;

	char field[53][53];

	REP(i, w + 2) {
		field[0][i] = '.';
		field[h + 1][i] = '.';
	}
	REP(i, h + 2) {
		field[i][0] = '.';
		field[i][w + 1] = '.';
	}

	FOR(i, 1, h) {
		FOR(j, 1, w) {
			cin >> field[i][j];
		}
	}


	REP(i, h + 2) {
		REP(j, w + 2) {
			if (field[i][j] == '#') {
				if (field[i - 1][j] != '#' && field[i + 1][j] != '#' && field[i][j + 1] != '#' &&field[i][j - 1] != '#') {
					cout << "No" << endl;
					return 0;
				}
			}
		}
	}

	cout << "Yes" << endl;


	return 0;
}



Measured memory_bytes: 256
#include <stdio.h>

int main () {
    int i,j,m = 0;
    int N,M,K;
    scanf("%d %d %d",&N,&M,&K);
    for (i=0;i<=N;i++){
        for (j=0;j<=M;j++){
            if (j*(N - i)+i*(M - j) == K){m=1;}
        }
    }
    if (m==1){printf("Yes\n");}
    else{printf("No\n");}
    return 0;
}

Measured memory_bytes: 128
def caddi2018b_c():
    from collections import Counter
    def prime_decomposition(num):
        i = 2
        table = []
        while i * i <= num:
            while num % i == 0:
                num /= i
                table.append(i)
            i += 1
        if num > 1:
            table.append(int(num))
        return table

    n, p = map(int, input().split())
    ans = 1
    factors = Counter(prime_decomposition(p))
    for val in factors:
        ans *= val ** (factors[val] // n)
    print(ans)


caddi2018b_c()

Measured memory_bytes: 3316
using System;
using System.Text;
using System.Collections.Generic;
using System.Collections;
using static System.Math;
using System.Linq;
using static System.Array;

namespace ConsoleApp2
{
    class Program
    {

        static void Main(string[] args)
        {
            //var N = long.Parse(Console.ReadLine());
            var NA = Console.ReadLine().Split(' ').Select(x => long.Parse(x)).ToArray();
            var N = NA[0];
            var A = NA[1];

            var X = Console.ReadLine().Split(' ').Select(x => long.Parse(x)).ToArray();
            var dp = new long[N+1,N+1, (N * A)+1];

            for (int j = 0; j <= N; j++)
            {
                dp[0, j, 0] = 1;
            }

            for (int i = 1; i <= N; i++)
            {
                for (int j = 1; j <= N; j++)
                {
                    for (int k = 0; k <= N*A; k++)
                    {
                        if(k - X[j - 1] >= 0)
                        {
                            dp[i,j,k] = dp[i, j - 1, k] + dp[i - 1,j - 1,k - X[j - 1]];
                        }
                        else
                        {
                            dp[i, j, k] = dp[i, j-1, k];
                        }
                        
                    }
                }
            }

            long ans = 0;
            for (int i = 1; i <= N; i++)
            {
                ans += dp[i, N, A * i];
            }


            Console.WriteLine(ans);
            

            
            
        }


    }


}


Measured memory_bytes: 77344