akhauriyash/Code-Regression huggingface dataset:
import std.stdio, std.algorithm, std.conv, std.array, std.string, std.math, std.typecons, std.numeric;

alias To = Tuple!(int, int);

void main()
{
    auto N = readln.chomp.to!int;
    bool[To][][] G;
    G.length = N;
    foreach (i; 0..N) {
        G[i].length = N;
        auto AS = readln.split.to!(int[]);
        foreach (j; 0..N-2) {
            auto a = i;
            auto b = AS[j]-1;
            if (a > b) swap(a, b);
            auto c = i;
            auto d = AS[j+1]-1;
            if (c > d) swap (c, d);
            G[a][b][To(c, d)] = true;
        }
    }

    auto memo = new int[][](N, N);
    auto max_d = new int[][](N, N);

    int x, max_w;
    foreach (i; 0..N) {
        foreach (j; i+1..N) {
            x += 2;
            int solve(int a, int b) {
                if (memo[a][b] < x) {
                    memo[a][b] = x;
                } else {
                    ++memo[a][b];
                }
                if (max_d[a][b]) return max_d[a][b];
                int e;
                foreach (to, _; G[a][b]) {
                    auto c = to[0];
                    auto d = to[1];
                    if (memo[c][d] == x+2) return -1;
                    auto r = solve(c, d);
                    if (r == -1) return -1;
                    e = max(e, r);
                }
                ++e;
                max_d[a][b] = e;
                max_w = max(e, max_w);
                return e;
            }
            if (max_d[i][j] == 0 && solve(i, j) == -1) {
                writeln("-1");
                return;
            }
        }
    }
    writeln(max_w);
}

Measured memory_bytes: 143356
#include <stdio.h>
long long n, a, c, u, v;
int main() {
	scanf("%lld", &n);
	for (long long i = 1; i <= n; i++) {
		a += i * (n + 1 - i);
	}
	for (long long i = 1; i < n; i++) {
		scanf("%lld %lld", &u, &v);
		if (u > v) {
			c = u;
			u = v;
			v = c;
		}
		a -= u * (n + 1 - v);
	}
	printf("%lld\n", a);
}

Measured memory_bytes: 1724
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define chmax(x, y) x = max(x, y)
using namespace std;
typedef long long ll;
typedef pair<int, int> P;

int main(){
  int n, k; cin >> n >> k;
  int mx = 0;
  for(int i = 3; i <= n; i++){
    mx += i - 2;
  }
  if(k > mx){
    cout << -1 << endl;
    return 0;
  }
  vector<P> ans;
  for(int i = 2; i <= n; i++){
    ans.push_back(make_pair(1, i));
  }
  int cnt = 0;
  bool brk = false;
  for(int i = 2; i <= n; i++){
    for(int j = i + 1; j <= n; j++){
      if(cnt == mx - k){
        brk = true;
        break;
      }
      ans.push_back(make_pair(i, j));
      cnt++;
    }
    if(brk) break;
  }

  cout << ans.size() << endl;
  rep(i, ans.size()){
    cout << ans[i].first << " " << ans[i].second << endl;
  }
  return 0;
}


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

int main() {
    int a, b, c;
    cin >> a >> b >> c;
    if (a + b == c || a + c == b || b + c == a)
        cout << "Yes" << "\n";
    else
        cout << "No" << "\n";
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<string>
#include<vector>
#include<algorithm>
#include<cstdlib>
using namespace std;
typedef long long int ll;

int main()
{
	int n;
	cin >> n;
	for(int i=0;i<n;i++){
		int a[80];
		string sa1,sa2,s1="",s2="";
		for(int i=0;i<80;i++)a[i]=0;
		cin >> sa1 >> sa2;
		if(sa1.length()>80||sa2.length()>80){
			printf("overflow\n");
			continue;
		}
		for(int j=0;j<80-sa1.length();j++){
			s1+='0';
		}
		s1+=sa1;
		for(int j=0;j<80-sa2.length();j++){
			s2+='0'; 
		}
		s2+=sa2;
		for(int i=0;i<80;i++){
			a[i]+=(s1[i]-'0')+(s2[i]-'0');
		}
		for(int i=79;i>=1;i--){
			a[i-1]+=a[i]/10;
			a[i]%=10;
		}
		if(a[0]>=10){
			printf("overflow\n");
			continue;
		}
		int x=0;
		while(a[x]==0)x++;
		for(int i=x;i<=79;i++){
			cout << a[i];
		}
		if(x==80)printf("0\n");
		else printf("\n");
	}
    return 0;
}

Measured memory_bytes: 1220
#include <iostream>

using namespace std;

int main()
{
  int a,b,c,d,p,x,y;
  cin>>a>>b>>c>>d>>p;
  x=a*p;
  if(p>c){
    y=b+d*p-d*c;
  }
  else{y=b;}
  if(x>y){
    cout<<y<<endl;
  }
  else{cout<<x<<endl;}
    return 0;
}



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

using namespace std;

/* g++ -g -fsanitize=address -lasan -std=c++11 -Dfoo_ */

/* freopen("input.txt", "rt", stdin); */
/* freopen("output.txt", "wt", stdout); */

#define ALL(c)          (c).begin(), (c).end()
#define ALLR(c)         (c).rbegin(), (c).rend()
#define FOR(i,a,b)      for (int i=(a); i < (b); ++i)
#define FORR(i,a,b)     for (int i=(a); i > (b); --i)
#define FOR_ALL(i,c)    for (__typeof((c).begin()) i=(c).begin();   \
                             i != (c).end(); ++i)
#define FOR_ALLR(i,c)   for (__typeof((c).rbegin()) i=(c).rbegin(); \
                             i != (c).rend(); ++i)
#define SZ(array)       (sizeof(array)/sizeof(array[0]))
#define lc(x)           (x<<1)     /* 2*x */
#define rc(x)           (x<<1 | 1) /* 2*x+1 */
#define lowbit(x)       (x & (-x)) /* 0b10100 -> 0b100 */

typedef long long       LL;
typedef map<int,int>    MII;
typedef pair<int,int>   PII;
typedef set<int>        SI;
typedef vector<bool>    VB;
typedef vector<double>  VD;
typedef vector<int>     VI;
typedef vector<string>  VS;

/* check if a key is in container C */
template <class C>
inline bool in_(const typename C::key_type& k, const C& A)
{ return A.find(k) != A.end(); }
inline bool in_(const string& s, const string& S)
{ return S.find(s) != string::npos; }

/*
 * Given a set of points on x,y plane. If there are 3 points form 3
 * corners of a rectangle, and the 4-th corner is missing a point, we
 * add a point at the 4-th corner position. The newly add point becomes
 * available for further operation, Ask how many points we can by doing
 * this repeatedly.
 */
/*
 *   |              There are 4 points initially. We can add 2 more
 * 3[x]-[ ]-[1]     points.
 *   |   |   |
 * 2[2]-[ ]-[x]     Create a bipartite G w/ x as left and y as right.
 *   |   |   |      1-1,1-3, 3-1,3-2
 * 1[x]-[ ]-[x]-
 *   1   2   3      Let x be the times we visit the left side, and y
 *                  be times we visit the right side. The total number
 * points can be created is x*y. The number of points we can add is
 * x-n where n is the number of initial points.
 *
 * R3-L1-R1-L3-R2 <=> (1,3)-(1,1)-(3,1)-(3,2)
 * left count x = 2; right count y = 3; n = 4; 2*3-4 = 2
 */

const int maxv = 1e5+5;
int vis[2*maxv], cnt[2]; VI G[2*maxv];

void dfs(const int u)
{
    vis[u]++; cnt[u/maxv]++;
    FOR_ALL(v,G[u]) if (!vis[*v])
        dfs(*v);
}

int main()
{
#ifdef foo_
    freopen("foo", "rt", stdin);
#endif
    ios::sync_with_stdio(false);
    int n;
    while (cin >> n) {
        FOR(i,0,SZ(G))
            G[i].clear();
        memset(vis,0,sizeof(vis));
        FOR(i,0,n) {
            int x,y; cin >> x >> y;
            y += maxv;
            G[x].push_back(y);
            G[y].push_back(x);
        }
        LL ans = 0;
        FOR(i,0,2*maxv) if (!vis[i]) {
            memset(cnt,0,sizeof(cnt));
            dfs(i);
            ans += 1LL*cnt[0]*cnt[1];
        }
        ans -= n;
        cout << ans << endl;
    }
    return 0;
}


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

#define int long long
map < int , int > sum;

signed main(){
	int N , val = 0 , ans = 0; cin >> N; sum[0] = 1;
	for(int i = 1 , x ; i <= N ; ++i){cin >> x; val += x; ans += sum[val]; ++sum[val];}
	cout << ans; return 0;
}


Measured memory_bytes: 12800
# include "bits/stdc++.h"
using namespace std;
using LL = long long;
using ULL = unsigned long long;
const double PI = acos(-1);
template<class T>constexpr T INF() { return ::std::numeric_limits<T>::max(); }
template<class T>constexpr T HINF() { return INF<T>() / 2; }
template <typename T_char>T_char TL(T_char cX) { return tolower(cX); };
template <typename T_char>T_char TU(T_char cX) { return toupper(cX); };
typedef pair<LL, LL> pii;
const int vy[] = { -1, -1, -1, 0, 1, 1, 1, 0 }, vx[] = { -1, 0, 1, 1, 1, 0, -1, -1 };
const int dx[4] = { 0,1,0,-1 }, dy[4] = { 1,0,-1,0 };
int popcnt(unsigned long long n) { int cnt = 0; for (int i = 0; i < 64; i++)if ((n >> i) & 1)cnt++; return cnt; }
int d_sum(LL n) { int ret = 0; while (n > 0) { ret += n % 10; n /= 10; }return ret; }
int d_cnt(LL n) { int ret = 0; while (n > 0) { ret++; n /= 10; }return ret; }
LL gcd(LL a, LL b) { if (b == 0)return a; return gcd(b, a%b); };
LL lcm(LL a, LL b) { LL g = gcd(a, b); return a / g*b; };
# define ALL(qpqpq)           (qpqpq).begin(),(qpqpq).end()
# define UNIQUE(wpwpw)        sort(ALL((wpwpw)));(wpwpw).erase(unique(ALL((wpwpw))),(wpwpw).end())
# define LOWER(epepe)         transform(ALL((epepe)),(epepe).begin(),TL<char>)
# define UPPER(rprpr)         transform(ALL((rprpr)),(rprpr).begin(),TU<char>)
# define FOR(i,tptpt,ypypy)   for(LL i=(tptpt);i<(ypypy);i++)
# define REP(i,upupu)         FOR(i,0,upupu)
# define INIT                 std::ios::sync_with_stdio(false);std::cin.tie(0)

int n, q;
string s;
int l, r;
int rui[101010];

int main(){
	cin >> n >> q;
	cin >> s;
	s = "*" + s;
	for(int i = 1;i <= n;i++){
		rui[i] += rui[i - 1];
		if(s[i - 1] == 'A' && s[i] == 'C'){
			rui[i]++;
		}
	}
	REP(i, q){
		cin >> l >> r;
		cout << rui[r] - rui[l] << endl;
	}
}

Measured memory_bytes: 1404
<?php
list($N,$K) = explode(" ",trim(fgets(STDIN)));

if($N < $K){
echo 0 .PHP_EOL;
}else{
$p = 0;
$i = 0;
while($i < $N){
$P = trim(fgets(STDIN));
if(isset($arr[$P[0]])){
++$arr[$P[0]];
}else{
$arr[$P[0]] = 1;
++$p;
}
++$i;
}

if($p < $K){
echo 0 .PHP_EOL;
}else{
$ans = 0;
while($p >= $K){
rsort($arr);
$i = 0;
while($i < $K){
--$arr[$i];
if($arr[$i] == 0){
--$p;
}
++$i;
}
++$ans;
}

echo $ans . PHP_EOL;
}
}
?>

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

int main() {
  int N,M,sum;
  sum = 0;
  cin >> N;
  M = N;
  while(N>=1){
    sum += N%10;
    N /= 10;
  }
  if(M%sum == 0) cout << "Yes" << endl;
  else cout << "No" << endl;
  
  return 0;
}



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

using namespace std;

int main() {
    string s;
    cin >> s;
    bool N, S, E, W;
    N = S = E = W = false;
    for (char c : s) {
        if (c == 'N') {
            N = true;
        }
        if (c == 'S') {
            S = true;
        }
        if (c == 'E') {
            E = true;
        }
        if (c == 'W') {
            W = true;
        }
    }
    if (W == E && S == N) {
        cout << "Yes";
    } else {
        cout << "No";
    }
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using VI = vector<int>;
using VL = vector<ll>;
using loop = int;
template<class T> using PQ = priority_queue<T, vector<T>, greater<T>>;
#define FOR(i,a,n) for(loop (i)=(a);(i)<(n);++(i))
#define eFOR(i,a,n) for(loop (i)=(a);(i)<=(n);++(i))
#define rFOR(i,a,n) for(loop (i)=(n)-1;(i)>=(a);--(i))
#define erFOR(i,a,n) for(loop (i)=(n);(i)>=(a);--(i))
#define each(i, a) for(auto &i : a)
#define SORT(i) sort((i).begin(),(i).end())
#define rSORT(i,a) sort((i).begin(),(i).end(),(a))
#define all(i) (i).begin(),(i).end()
#define out(y,x) ((y) < 0 || h <= (y) || (x) < 0 || w <= (x))
#define line cout << "------------------------\n" 
#define ENDL(i,n) ((i) == (n) - 1 ? "\n" : " ")
#define stop system("pause") //comment out this on AOJ.
constexpr ll INF = 1000000000;
constexpr ll LLINF = 1LL << 60;
constexpr ll mod = 1000000007;
constexpr ll MOD = 998244353;
constexpr ld eps = 1e-10;
constexpr ld pi = 3.1415926535897932;
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; }
inline void init() { cin.tie(nullptr); cout.tie(nullptr); ios::sync_with_stdio(false); cout << fixed << setprecision(15); }
template<class T>inline istream& operator>>(istream& is, vector<T>& v) { for (auto& elemnt : v)is >> elemnt; return is; }
template<class T, class U>inline istream& operator>>(istream& is, pair<T, U>& p) { is >> p.first >> p.second; return is; }
template<class T>inline vector<T> vec(size_t a) { return vector<T>(a); }
template<class T>inline vector<T> defvec(T def, size_t a) { return vector<T>(a, def); }
template<class T, class... Ts>inline auto vec(size_t a, Ts... ts) { return vector<decltype(vec<T>(ts...))>(a, vec<T>(ts...)); }
template<class T, class... Ts>inline auto defvec(T def, size_t a, Ts... ts) { return vector<decltype(defvec<T>(def, ts...))>(a, defvec<T>(def, ts...)); }

int main() {
    init();

    int n, k; cin >> n >> k;
    VL h(n); cin >> h;
    VL a = h;
    a.push_back(0);
    SORT(a);
    a.erase(unique(all(a)), a.end());
    int m = a.size();
    unordered_map<ll, int> ma;
    FOR(s, 0, m)ma[a[s]] = s;

    auto dp = defvec<ll>(LLINF, 2, k + 1, m);
    dp[0][0][0] = 0;
    FOR(i, 0, n) {
        eFOR(j, 0, k)FOR(s, 0, m)dp[(i + 1) & 1][j][s] = LLINF;
        eFOR(j, 0, k)FOR(s, 0, m) {
            chmin(dp[(i + 1) & 1][j][ma[h[i]]], dp[i & 1][j][s] + max(h[i] - a[s], 0LL));
            if (j == k)continue;
            chmin(dp[(i + 1) & 1][j + 1][s], dp[i & 1][j][s]);
        }
    }
        
    ll ans = LLINF;
    eFOR(j, 0, k)FOR(s, 0, m)chmin(ans, dp[n & 1][j][s]);
    cout << ans << "\n";
}

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

void fail(){
    cout << -1 << endl;
    exit(0);
}

int nth_bit(int64_t num, int n){
    return (num >> n) & 1;
}

int main(){
    int N;
    cin >> N;
    vector<int64_t> A(3);
    for(int i=0; i<N; i++){
        int64_t a;
        cin >> a;
        A[min(i, 2)] ^= a;
    }
    int64_t ans = 0;
    for(int k=40; k>=0; k--){
        int64_t d = 1LL<<k;
        if((nth_bit(A[0], k)^nth_bit(A[1], k)) != nth_bit(A[2], k)){
            int64_t v = min(A[0]%d+1, d - A[1]%d);
            if(A[0] < v) fail();
            A[0] -= v;
            A[1] += v;
            k = 41;
            ans += v;
        }
    }
    if(A[0] == 0) fail();
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 3624
#include <limits.h>
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <algorithm>
#include <cfloat>
#include <complex>
#include <functional>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <vector>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;

vector<vector<ll> > table;
vector<P> roads;
vector<P> qs;

int main() {
  ll A, B;
  cin >> A >> B;

  cout << max(max(A + B, A - B), A * B) << endl;

  return 0;
}

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

int main() {
int N;
  
  cin>>N;
  vector<string> S(N);

rep(i,N){cin>>S.at(i);}
  sort(S.begin(), S.end());
  

  
   map<string, int> score;
int count=1,flg=1;
  rep(i,N-1){if(S.at(i+1)==S.at(i)){count++;}else{score[S.at(i)]=count;flg=max(flg,count);count=1;}}
  score[S.at(N-1)]=count;flg=max(flg,count);
  

  for (auto p : score) {
  auto k = p.first;
  auto v = p.second;
    if(v==flg){cout << k << endl;}
  }
}  

Measured memory_bytes: 25168
N,M = gets.chomp.split.map(&:to_i)

graph = Hash.new{ |h,k| h[k] = []}

M.times do |i|
  a, b = gets.chomp.split.map(&:to_i)
  graph[a] << b
  graph[b] << a
end

visited = Hash.new(false)
visited[1] = true

queue = [1]

ans = Hash.new(0)

until queue.empty?
  point = queue.shift

  graph[point].each do |v|
    next if visited[v]
    ans[v] = point
    visited[v] = true
    queue << v
  end
end

1.upto(N) do |i|
  if visited[i] == false
    puts 'No'
    exit
  end
end



puts 'Yes'
2.upto(N) do |i|
  puts ans[i]
end




Measured memory_bytes: 43260
#include <bits/stdc++.h>
//#include <atcoder/all>
using namespace std;
//using namespace atcoder;
 
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using ll = long long;
using P = pair<int, int>;

#define INF 1001001001
#define MAX 1e18

int main() {
  int n;
  cin >> n;
  int cnt = 0;
  rep(i,n) {
    int a, b;
    cin >> a >> b;
    if (a==b) cnt++;
    else cnt = 0;
    if (cnt>=3) {
      cout << "Yes" << endl;
      return 0;
    }
  }
  cout << "No" << endl;
  return 0;
}


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

using namespace std;

int n,ans = 99999999;
int f[105],sum[105];

int main(){
	cin >> n;
	for(int i = 1; i <= n; ++i){
		int a;cin >> a;
		sum[i] = sum[i - 1] + a;
	}
	for(int i = 1; i <= n; ++i)
		ans = min(ans,abs(sum[i] - (sum[n] - sum[i])));
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main() {
    long long n, a, b, c, d, e;
    cin >> n >> a >> b >> c >> d >> e;
    long long m = min(min(min(a, b), c), min(d, e));
    cout << 5 + (n-1) / m << endl;

    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#include <limits.h>

int main() {
  int n;
  scanf("%d", &n);
  int a[n], count = 0, min = INT_MAX, k = 0;
  long int ans = 0;
  for (size_t i = 0; i < n; i++) {
    scanf("%d", a+i);
    if (a[i] < 0) {
      count++;
      a[i] = abs(a[i]);
    }
    if (a[i] < min) {
      k = i;
      min = a[i];
    }
  }
  if (count % 2 == 0) {
    for (size_t i = 0; i < n; i++) {
      ans += a[i];
    }
  } else {
    for (size_t i = 0; i < n; i++) {
      if (i != k) {
        ans += a[i];
      } else {
        ans -= a[i];
      }
    }
  }
  printf("%ld\n", ans);
  return 0;
}


Measured memory_bytes: 512
#include<bits/stdc++.h>
using namespace std;
int main(){
    int n;
    string s;
    int sum=0;
    int a=-1000;
    cin>>n>>s;
    if(sum>a){
        a=sum;
    }
    for(int i=0;i<n;i++){
        if(s[i]=='I'){
            sum++;
        }
        else{
            sum--;
        }
        if(sum>a){
            a=sum;
        }
    }
    cout<<a<<endl;
}


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

void fnInput(int& rnShtHand, int& rnLngHand, int& rnHour, int& rnMinute)
{
  cin >> rnShtHand >> rnLngHand >> rnHour >> rnMinute;
}

double fnClockHandsDist(int nShtHand, int nLngHand, int nHour, int nMinute)
{
  static const double PI = 3.141592653589793;

  double nShtAngl = (nHour + (nMinute / 60.0)) / 12.0 * 2 * PI;
  double nLngAngl = (nMinute / 60.0) * 2 * PI;
  double nDiffAngl = abs(nShtAngl - nLngAngl);
  if (nDiffAngl > PI)
    nDiffAngl = 2 * PI - nDiffAngl;

  double nHandsDist = nShtHand * nShtHand + nLngHand * nLngHand 
                      - 2 * nShtHand * nLngHand * cos(nDiffAngl);
  return sqrt(nHandsDist);
}
  
int main()
{
  int nShtHand, nLngHand, nHour, nMinute;

  fnInput(nShtHand, nLngHand, nHour, nMinute);
  cout << fixed << setprecision(10) << fnClockHandsDist(nShtHand, nLngHand, nHour, nMinute);
  cout << endl;

  return 0;
}

Measured memory_bytes: 4168
import numpy as np
n=int(input())
a=sorted(list(map(int,input().split())))

dp=np.array([0 for _ in range(max(a)+1)])
for i in range(n):
    ai=a[i]
    if(dp[ai]>=2):
        continue

    j=1
    while(ai*j<=a[-1]):
        dp[ai*j]+=1
        j+=1

print(sum(dp[ai]==1 for ai in a))


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

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


typedef long long ll;
typedef long double ld;
const int INF=1e9,MOD=1e9+7,ohara=1e6+10;
const ll LINF=1e18;
using namespace std;

#define rep(i,n) for(int (i)=0;(i)<(int)(n);(i)++)
#define rrep(i,a,b) for(int i=(a);i<(b);i++)
#define rrrep(i,a,b) for(int i=(a);i>=(b);i--)
#define all(v) (v).begin(), (v).end()
#define Size(n) (n).size()
#define Cout(x) cout<<(x)<<endl
#define doublecout(a) cout<<fixed<<setprecision(15)<<a<<endl;
#define Cerr(x) cerr<<(x)<<endl
#define fi first
#define se second
#define P pair<ll,ll> 
#define m_p make_pair
#define V vector<ll> 
#define U_MAP unordered_map<ll,ll>

ll n,cnt,ans,a,b,c,d,tmp,tmpp,m,h,w,x,y,sum,pos,k;
ld doua;
int dy[]={1,0,-1,0};
int dx[]={0,1,0,-1};
//int dy[]={-1,0,1,-1,1,-1,0,1};
//int dx[]={-1,-1,-1,0,0,1,1,1};
string alph("abcdefghijklmnopqrstuvwxyz"),s;
bool fl;
struct edge{int to,cost;};

//-------------------------↓↓↓↓↓↓------------------------

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

    using mint=modint<MOD>;
    
    cin>>s;

    vector<vector<mint>> dp(Size(s)+100,vector<mint>(5));//耳DP

    dp[0][0]=1;
    rrep(i,1,Size(s)+1){
        //選ばない
        rep(j,4){
            dp[i][j]+=(s[i-1]=='?' ? dp[i-1][j]*3 : dp[i-1][j]);
        }
        //選ぶ
        if(s[i-1]=='A'||s[i-1]=='?'){
            dp[i][1]+=dp[i-1][0];
        }
        if(s[i-1]=='B'||s[i-1]=='?'){
            dp[i][2]+=dp[i-1][1];
        }
        if(s[i-1]=='C'||s[i-1]=='?'){
            dp[i][3]+=dp[i-1][2];
        }
    }
    
    Cout(dp[Size(s)][3].value());
    return 0;
}


Measured memory_bytes: 7376
using System;
using System.Collections.Generic;
using System.Text;

namespace test
{
    class MainClass
    {
        public static void Main(string[] args)
        {
            List<int> resultList = new List<int>();
            string input;
            while ((input = Console.ReadLine()) != "0 0")
            {
                string[] inputArray = input.Split(' ');
                int n = int.Parse(inputArray[0]);
                int s = int.Parse(inputArray[1]);

                int count = Search(s, 0, 0, n, 0);

                resultList.Add(count);
            }

            foreach (int r in resultList)
            {
                Console.WriteLine(r);
            }


        }

        static int Search(int s, int a, int count, int n, int currentSum)
        {
            for (int i = a; i <= 9; i++)
            {
                if (n == 1)
                {
                    if (s == currentSum + i)
                    {
                        count++;
                        break;
                    }
                }
                else
                {
                    count = Search(s, i + 1, count, n - 1, currentSum + i);
                }
            }

            return count;
        }
    }

}

Measured memory_bytes: 8988
mod=10**9+7
n=int(input())
a=list(map(int,input().split()))
d=sum(a)-sum(range(n+1))
i1=a.index(d)
i2=i1+1+a[i1+1:].index(d)

g1=[1,1]
g2=[1,1]
inverse=[0,1]
for i in range(2,n+2):
    g1.append((g1[-1]*i)%mod)
    inverse.append((-inverse[mod % i]*(mod//i))%mod)
    g2.append((g2[-1]*inverse[-1])%mod)

h1=[1,1]
h2=[1,1]
iinverse=[0,1]
for i in range(2,n-i2+i1+1):
    h1.append((h1[-1]*i)%mod)
    iinverse.append((-iinverse[mod % i]*(mod//i))%mod)
    h2.append((h2[-1]*iinverse[-1])%mod)

for i in range(n+1):
    print((g1[n+1]*g2[i+1]*g2[n-i]%mod-(h1[n-i2+i1]*h2[i]*h2[n-i2+i1-i] if n-i2+i1>=i else 0)%mod)%mod)

Measured memory_bytes: 34660
#include<iostream>
#include<algorithm>
#include<vector>
#include<string>
#include<utility>
#include<map>
#include<set>
#include<queue>
#include<bitset>
#include<math.h>
using namespace std;
typedef long long ll;
typedef pair<int,ll> P;
#define N (1000000000+7)
#define INF (ll)1e16
typedef long long ll;



int main(void){
    ll n,p;
    cin>>n>>p;
    ll ans=1;
    vector<pair<ll,ll>>pri;
    for(ll i=2;i<=sqrtl(p)+1;i++){
        if(p%i==0){
            ll num=0;
            while(true){
                if(p%i==0){
                    p=p/i;
                    num++;
                }
                else break;
            }
            pair<ll,ll>x=make_pair(i,num);
            pri.push_back(x);
        }
        else continue;
    }
    if(p>1){
        pair<ll,ll>x=make_pair(p,1);
        pri.push_back(x);
    }
    for(auto itr=pri.begin();itr!=pri.end();++itr){
        if(itr->second>=n)ans=(ll)ans*pow(itr->first,itr->second/n);
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
///Welcome to Nasif's Code
#define bug printf("bug\n");
#define bug2(var) cout<<#var<<" "<<var<<endl;
#define co(q) cout<<q<<endl;
#define all(q) (q).begin(),(q).end()
typedef long long int ll;
typedef unsigned long long int ull;
const int MOD = (int)1e9+7;
const int MAX = 1e6;
#define pi acos(-1)
#define inf 1000000000000000LL
#define FastRead    ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
int main()
{
    FastRead
    //freopen("output.txt", "w", stdout);
    int a,b,c,d,cnt=0;
    cin>>a>>b>>c>>d;
    for(int i=a;i<=b;i++){
        if(i>=c && i<=d)
            cnt++;
    }
    cnt--;
    cnt=max(cnt,0);
    cout<<cnt<<endl;

    return 0;
}


Measured memory_bytes: 3652
char w[1025],s[1025];
main(f){
	for(;~scanf("%[^ ,.]%[ ,.]",w,s);){
		if(strlen(w)>=3&&strlen(w)<=6){
			if(!f)
				putchar(' ');
			printf("%s",w);
			f=0;
		}
	}
	exit(!puts(""));
}

Measured memory_bytes: 0
<?php
fscanf(STDIN, "%d", $n);
$tmp = trim(fgets(STDIN));
$input = explode(' ', $tmp);
$sum = 0;
for ($i = 0; $i < $n; $i++) {
    $tmp_i = $i;
    for ($j = $i; $j < $n; $j++){
        if ((int)$input[$j] <(int) $input[$tmp_i]) {
           $tmp_i = $j;
        }
    }
    if ($tmp_i !== $i) {
        $tmp_num = $input[$tmp_i];
        $input[$tmp_i] = $input[$i];
        $input[$i] = $tmp_num;
        $sum++;
    }
}
for ($i = 0; $i < $n; $i++) {
    if ($i === $n - 1) {
        echo "$input[$i]\n";
    } else {
        echo $input[$i] . ' ';
    }
}
echo "$sum\n";


Measured memory_bytes: 9264
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<vector>
#include<map>
#include<cmath>
#include<string>
#include<bitset>
using namespace std;

int main(){
    string str;
    int n,ans=0,M=0;
    cin >> n;
    cin >> str;
    for(int i=0;i<str.size();i++){
        if(str[i]=='D') ans--;
        else{
                ans++;
                if(M<ans){
                       M=ans;
                }
        }
        
    }    
    cout << M;
    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<string.h>
int main(void){
  char s[100 + 1];
  scanf("%s",s);
  int n=strlen(s);//文字列の長さを得るs
  for(int i= 0;i<n;i++) {
    if(i% 2 == 0) {
      if(s[i] =='L') {
        puts("No");
        return 0;
      }
    }else{
      if(s[i] =='R') {
        puts("No");
        return 0;
      }
    }
  }
  puts("Yes");
  return 0;
}

Measured memory_bytes: 128
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Scanner;
import java.util.Random;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 *
 * @author silviase
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        Scanner in = new Scanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        ALDS114BStringSearch solver = new ALDS114BStringSearch();
        solver.solve(1, in, out);
        out.close();
    }

    static class ALDS114BStringSearch {
        public void solve(int testNumber, Scanner in, PrintWriter out) {
            StringBuilder sb = new StringBuilder();
            String s = in.next();
            String t = in.next();
            sb.append(s);
            sb.append("*");
            sb.append(t);
            RollingHash hash = new RollingHash(new String(sb));

            for (int i = 0; i < s.length(); i++)
                if (hash.slice(i, t.length()) == hash.slice(s.length() + 1, t.length()))
                    out.println(i);
        }

    }

    static class RollingHash {
        private static final int MAX_LENGTH = 500000;
        private final static long MASK30 = (1L << 30) - 1;
        private final static long MASK31 = (1L << 31) - 1;
        private final static long MOD = (1L << 61) - 1;
        private final static long POSITIVER = MOD * 3;
        private static int Base;
        private static long[] pow = new long[MAX_LENGTH + 1];
        public long[] hash;

        static {
            Base = new Random().nextInt((int) 1e9) + 129;
            pow[0] = 1;
            for (int i = 1; i < pow.length; i++) {
                pow[i] = calc(mul(pow[i - 1], Base));
            }
        }

        public RollingHash(String s) {
            hash = new long[s.length() + 1];
            for (int i = 0; i < s.length(); i++) {
                hash[i + 1] = calc(mul(hash[i], Base) + s.charAt(i));
            }
        }

        public long slice(int begin, int length) {
            return calc(hash[begin + length] + POSITIVER - mul(hash[begin], pow[length]));
        }

        private static long mul(long l, long r) {
            long lu = l >> 31;
            long ld = l & MASK31;
            long rd = r & MASK31;
            long ru = r >> 31;
            long mid = ld * ru + lu * rd;
            return ((lu * ru) << 1) + ld * rd + ((mid & MASK30) << 31) + (mid >> 30);
        }

        private static long calc(long v) {
            v = (v & MOD) + (v >> 61);
            if (v >= MOD) v -= MOD;
            return v;
        }

    }
}




Measured memory_bytes: 87008
import sys
import math
sys.setrecursionlimit(10**7)

debug = True
debug = False

def dprint(*objects):
    if debug == True:
        print(*objects)

class Task:
    def __repr__(self):
        return str(self.__dict__)
    def time_toget_point(self, p):
        if p >= self.max_minus:
            return math.ceil(self.b + (p - self.max_minus)/self.u)
        else:
            return math.ceil(p/self.l)

def solve():
    n, x = map(int, input().split())
    t_list = []
    total_behind = 0 # これだけ点を取らなければならない

    for i in range(n):
        t = Task()
        t.b, t.l, t.u = map(int, input().split())

        t.max_minus = t.b * t.l # 重み最低で勉強しない場合のマイナス
        t.max_plus = (x-t.b) * t.u # 重み最高で満点まで勉強する時のプラス
        t.eff = t.max_plus + t.max_minus # 重み最高にした時の勉強効率
        t_list.append(t)

        total_behind += t.max_minus
    dprint(total_behind)

    # 重み最高での勉強効率の降順に並び変え
    import numpy as np
    t_list = sorted(t_list, key=lambda t: t.eff, reverse=True)
    cumsum = list(np.cumsum([t.eff for t in t_list]))
    dprint(t_list)
    dprint(cumsum)

    # 何要素目まで上から取ると必要点数を超えるか
    import bisect
    max_i = bisect.bisect_left(cumsum, total_behind)
    dprint("max_i:", max_i)

    # 部分点を取るtaskをi番目と決めたときの、必要勉強時間を求める。その最小値が答えになる
    min_time = -1
    for i, t in enumerate(t_list):
        if i <= max_i:
            # このケースでは上から max_i 要素目までのうち i 以外を取り、iから最適な値をとる
            rest_p = total_behind - (cumsum[max_i] - t.eff)

        else:
            # このケースでは単に上から max_i-1 要素目までとり、iから最適な個数とる
            # 必要時間がXを超える場合は解にならないが、気にしなくていい
            if max_i == 0:
                rest_p = total_behind
            else:
                rest_p = total_behind - cumsum[max_i-1]

        time = x * (max_i) + t.time_toget_point(rest_p)
        dprint(i, rest_p, time, min_time, t)
        if min_time == -1 or min_time > time:
            min_time = time
    print(min_time)

    # total_time = 0 # 総勉強時間
    # total_score = -1 * total_behind # マイナスからスタートし、0になったら勝ち
    # for i, t in enumerate(t_list):
    #     # ためしに全力してみる
    #     total_score_tmp = total_score
    #     total_score_tmp += t.eff
    #
    #     if total_score_tmp < 0:
    #         # まだ勉強が足りないので、このtaskをコミットして勉強を続ける
    #         total_score = total_score_tmp
    #         total_time += x
    #         dprint(i, total_score, total_time, "commited")
    #     else:
    #         # これを全力すると勉強しすぎの場合、いったん中止
    #         dprint(i, total_score, total_time, t.eff, "stop")
    #         break
    #
    # # 残り必要点数を稼ぐのにもっとも効率がいいものを探す
    # dprint("ajusting", total_time, total_score)
    #
    # min_rest_time = -1 # 残りを稼ぐ最小勉強時間
    # for t in t_list[i:]:
    #     rest_time = t.time_toget_point(-1*total_score)
    #     if min_rest_time == -1 or rest_time < min_rest_time:
    #         min_rest_time = rest_time
    #
    # print(int(total_time + min_rest_time))


solve()

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

using namespace std;

int main()
{
    int N, M;
    vector<int> vec1, vec2;
    
    cin >> N;
    vec1.reserve(N);
    for(int i = 0; i < N; ++i)
    {
        int tmp; cin >> tmp;
        vec1.push_back(tmp);
    }
    
    cin >> M;
    for(int i = 0; i < M; ++i)
    {
        int tmp; cin >> tmp;
        vec2.push_back(tmp);
    }
    
    int ans = 0;
    
    for(int i = 0; i < vec2.size(); ++i)
    {
        bool found = false;
        for(int j = 0; j < vec1.size(); ++j)
        {
            if(vec1[j] == vec2[i])
              found = true;
        }
        ans += found;
    }
    
    cout << ans << endl;
    
    return 0;
}


Measured memory_bytes: 3204
#include <iostream>
#include <math.h>
using namespace std;

int main()
{
    int a , b , c , d ;
    cin >> a >> b >> c >> d ;
    if((abs(b - a)<= d && abs(c - b)<= d)|| abs(a-c)<= d )
    {
        cout << "Yes" << endl;
    }else
    {
        cout << "No" << endl;
    }


    return 0;
}


Measured memory_bytes: 3600
// #include {{{
#include <iostream>
#include <cassert>
#include <cstring>
#include <cstdlib>
#include <cstdio>
#include <cctype>
#include <cmath>
#include <ctime>
#include <queue>
#include <set>
#include <map>
#include <stack>
#include <string>
#include <bitset>
#include <vector>
#include <complex>
#include <algorithm>
using namespace std;
// }}}
// #define {{{
typedef long long ll;
typedef double db;
typedef pair<int,int> pii;
typedef vector<int> vi;
#define de(x) cout << #x << "=" << x << endl
#define rep(i,a,b) for(int i=a;i<(b);++i)
#define per(i,a,b) for(int i=(b)-1;i>=(a);--i)
#define all(x) (x).begin(),(x).end()
#define sz(x) (int)(x).size()
#define mp make_pair
#define pb push_back
#define fi first
#define se second
// }}}

const int N = 5e5 + 10 , C = 26;
char s[N];
int Q , l , r , n , nxt[N][C+1] , jump[N][20];

int main(){
  scanf("%s",s);
  n = strlen(s);
  rep(i,0,C+1) nxt[n+1][i]=n+1;
  nxt[n][C]=n;
  rep(i,0,C) nxt[n][i]=n+1;
  per(i,0,n) {
    int ch=s[i]-'a';
    nxt[i][ch]=i+1;
    rep(j,ch+1,C+1) nxt[i][j]=nxt[nxt[i][j-1]][j-1];
    rep(j,0,ch) nxt[i][j]=nxt[nxt[i][C]][j];
    //rep(j,0,C+1) printf("%d%c",nxt[i][j]," \n"[j==C]);
  }
  rep(i,0,20) jump[n][i]=n,jump[n+1][i]=n+1;
  per(i,0,n) {
    jump[i][0]=nxt[i][C];
    rep(j,1,20) jump[i][j]=jump[jump[i][j-1]][j-1];
  }
  scanf("%d",&Q);
  rep(i,0,Q) {
    scanf("%d%d",&l,&r);
    --l;
    per(i,0,20) if(jump[l][i]<r)
      l=jump[l][i];
    l=jump[l][0];
    puts(l == r ? "Yes" : "No");
  }
  return 0;
}


Measured memory_bytes: 92928
/*
 *  AUTHOR : MANAV PATEl
*/
#include<bits/stdc++.h>
#include<functional>
//#include<boost/multiprecision/cpp_int.hpp>
//using namespace boost::multiprecision;
using namespace std;

namespace fastio {

	template <class T> istream &operator>>(istream &os, vector<T> & vec) {
		for (auto &u : vec)os >> u;
		return os;
	}
	template <class T> ostream &operator<<(ostream &os, const vector<T> & vec) {
		for (auto &u : vec)os << u << " ";
		return os;
	}
	template<class T1, class T2> inline istream& operator>>(istream& os, pair<T1, T2>& p) {
		return os >> p.first >> p.second;
	}
	template<class T1, class T2> ostream& operator<<(ostream& os, const pair<T1, T2>& p) {
		return os << p.first << " " << p.second;
	}
	template <class T> ostream &operator<<(ostream &os, set<T> & con) {
		for (auto &u : con) os << u << " ";
		return os;
	}
	void re() {}
	template <typename T, typename... args> void re(T& x, args&... tail) {
		cin >> x;
		re(tail...);
	}
	void pr() {}
	template <typename T> void pr(const T& x) {
		cout << x;
	}
	template <typename T, typename... args> void pr(const T& x, const args&... tail) {
		cout << x << " ";
		pr(tail...);
	}
	template <typename... args> void prln(const args&... tail) {
		pr(tail...);
		cout << "\n";
	}
}
using namespace fastio;

typedef long long int ll;
typedef long double ld;

const ll mod = 1e9+7;
const ll mod1 = 998244353;

#define fill(a)  memset(a, 0, sizeof(a))
#define fst first
#define snd second
#define mp make_pair
#define pb push_back

int main()
{
	cin.sync_with_stdio(false);
	cin.exceptions(cin.failbit);
	cin.tie(0);
	ll w, h, x, y;
	re(w,h,x,y);
	long double ans = (long double)(w) * (long double)(h) / 2.0;
    bool flag = false;
 
    if (w == 2 * x && h == 2 * y) {
        flag = true;
    }
 
    cout.precision(9);
    cout << ans << " " << flag;
}


Measured memory_bytes: 256
#import sys

#input = sys.stdin.readline

import bisect

def main():
#    h,w,a,b = map(int, input().split())
    n=int(input())
    l=list(map(int,input().split()))
    l=sorted(l)
 #   print(l)
    count=0
    for i in range(n-2):
        for j in range(i+1,n-1):
            a = bisect.bisect_left(l,l[i]+l[j])
#            print(a)
            count+=a-j-1

    print(count)






if __name__ == "__main__":
    main()

Measured memory_bytes: 3188
#include<bits/stdc++.h>
using namespace std;
int main()
{
  int n, k;
  long long int cnt = 0;
  cin>> n >> k;

  for(int i = k + 1; i <= n; i++) {

    cnt += (i - k) * (n / i);
    if(n % i >= k) cnt += (n % i) - k + 1;

    if(k == 0) cnt--;

  }

  cout<< cnt <<endl;

  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
struct edge{ll to, cost;};


int main(){
  ll n, i, a, b, c, q, k,x,y, f;
  scanf("%lld", &n);
  vector<edge> V[n];
  ll d[n] = {};
  for(i=0; i<n-1;i++){
    scanf("%lld%lld%lld", &a, &b, &c);a--;b--;
    V[a].push_back(edge{b, c});
    V[b].push_back(edge{a, c});
  }
  scanf("%lld%lld", &q, &k);
  k--;
  queue<ll> Q;
  Q.push(k);
  while(!Q.empty()){
    f = Q.front();
    Q.pop();
    for(i=0;i<V[f].size();i++){
      if(d[V[f][i].to] == 0){
        d[V[f][i].to] = d[f] + V[f][i].cost;
        Q.push(V[f][i].to);
      }
    }
  }
  for(i=0;i<q;i++){
    scanf("%lld%lld", &x, &y);
    x--;
    y--;
    printf("%lld\n", d[x]+d[y]);
  }
}


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



void solve()
{
	//cout<<"HI";
	int n,i,j,k,s;
	cin>>n;
	int arr[n+1][4];
	int dp[n+1][4]={0};
	for(i=1;i<=n;i++)
	{
		for(j=1;j<=3;j++)
		{
			cin>>arr[i][j];
		}
	}
	
	for(i=1;i<=n;i++)
	{
			dp[i][1]=max(arr[i][1]+dp[i-1][2],arr[i][1]+dp[i-1][3]);
			dp[i][2]=max(arr[i][2]+dp[i-1][1],arr[i][2]+dp[i-1][3]);
			dp[i][3]=max(arr[i][3]+dp[i-1][1],arr[i][3]+dp[i-1][2]);
		
	}
	s=max(dp[n][1],dp[n][2]);
	
	s=max(s,dp[n][3]);
	cout<<s<<endl;
}






int main()
{
	//cout<<"Main";
	solve();
	return 0;
}

Measured memory_bytes: 3328
#include <iostream>
#include <string>
#include <algorithm>
using namespace std;
int cal(string);
string ch(int);
int main(){
  int l,i,j,len,calc,max,min,h,flag;
  string s,s1,s2,st[21];
  while(1){
    flag=0;
    cin >> s >> l;
    st[0]=s;
    if(s=="0"&&l==0) break;
    for(h=1;h<=20;h++){
      len=s.size();
      if(len<l){
    for(i=len;i<l;i++){
      s=s+'0';
    }
      }
      s1=s;
      s2=s;
      for(i=0;i<l;i++){
    for(j=1;j<l;j++){
      if(s1[j]>s1[j-1]) swap(s1[j],s1[j-1]);
    }
      }
      max=cal(s1);
      for(i=0;i<l;i++){
    for(j=1;j<l;j++){
      if(s2[j]<s2[j-1]) swap(s2[j],s2[j-1]);
    }
      }
      min=cal(s2);
      calc=max-min;
      s=ch(calc);
      st[h]=s;
      if(st[h].size()==0) st[h]="0";
      for(i=0;i<h;i++){
    if(st[h]==st[i]){
      cout << i << ' ' << st[h] << ' ' << h-i << endl;
      flag=1;
      break;
    }
      }
      if(flag==1) break;
    }
  }
  return 0;
}
int cal(string change){
  int len,i,ret=0,x=1;
  len=change.size();
  for(i=len-1;i>=0;i--){
    ret+=x*(change[i]-'0');
    x*=10;
  }
  return ret;
}
string ch(int calc){
  string ret,retfi;
  char retf[7];
  int len,i;
  while(calc){
    ret+=calc%10+'0';
    calc/=10;
  }
  len=ret.size();
  for(i=0;i<len;i++){
    retf[i]=ret[len-i-1];
    retfi+=retf[i];
  }
  return retfi;
}

Measured memory_bytes: 1220
import math as mt
I=lambda:list(map(int,input().split()))
mod=10**9
n,=I()
l=I()
x=0
y=0
temp=l[0]
for i in range(1,n):
	temp=mt.gcd(temp,l[i])
N=10**6+3
ss=[0]*(N)
ss[0]=1
for i in range(2,N):
	if ss[i]==0:
		ss[i]=i
		for j in range(2*i,N,i):
			ss[j]=i
if temp!=1:
	print("not coprime")
else:
	pos=1
	visi=[0]*N
	for i in range(n):
		now=l[i]
		while now>1:
			te=ss[now]
			if visi[te]:
				pos=0
				break
			while now%te==0:
				now//=te
			visi[te]=1
		if not pos:
			break
	if pos:
		print("pairwise coprime")
	else:
		print("setwise coprime")


Measured memory_bytes: 204604
#[allow(unused_macros)]
macro_rules ! input { ( source = $ s : expr , $ ( $ r : tt ) * ) => { let mut iter = $ s . split_whitespace ( ) ; let mut next = || { iter . next ( ) . unwrap ( ) } ; input_inner ! { next , $ ( $ r ) * } } ; ( $ ( $ r : tt ) * ) => { let stdin = std :: io :: stdin ( ) ; let mut bytes = std :: io :: Read :: bytes ( stdin . lock ( ) ) ; let mut next = move || -> String { bytes . by_ref ( ) . map ( | r | r . unwrap ( ) as char ) . skip_while ( | c | c . is_whitespace ( ) ) . take_while ( | c |! c . is_whitespace ( ) ) . collect ( ) } ; input_inner ! { next , $ ( $ r ) * } } ; }
#[allow(unused_macros)]
macro_rules ! input_inner { ( $ next : expr ) => { } ; ( $ next : expr , ) => { } ; ( $ next : expr , mut $ var : ident : $ t : tt $ ( $ r : tt ) * ) => { let mut $ var = read_value ! ( $ next , $ t ) ; input_inner ! { $ next $ ( $ r ) * } } ; ( $ next : expr , $ var : ident : $ t : tt $ ( $ r : tt ) * ) => { let $ var = read_value ! ( $ next , $ t ) ; input_inner ! { $ next $ ( $ r ) * } } ; }
#[allow(unused_macros)]
macro_rules ! read_value { ( $ next : expr , ( $ ( $ t : tt ) ,* ) ) => { ( $ ( read_value ! ( $ next , $ t ) ) ,* ) } ; ( $ next : expr , [ $ t : tt ; $ len : expr ] ) => { ( 0 ..$ len ) . map ( | _ | read_value ! ( $ next , $ t ) ) . collect ::< Vec < _ >> ( ) } ; ( $ next : expr , chars ) => { read_value ! ( $ next , String ) . chars ( ) . collect ::< Vec < char >> ( ) } ; ( $ next : expr , usize1 ) => { read_value ! ( $ next , usize ) - 1 } ; ( $ next : expr , $ t : ty ) => { $ next ( ) . parse ::<$ t > ( ) . expect ( "Parse error" ) } ; }

fn main() {
    input! {
        a: chars, b: chars
    }

    let ret = match (a[0], b[0]) {
        ('H', 'H') => 'H',
        ('H', 'D') => 'D',
        ('D', 'H') => 'D',
        _ => 'H'
    };
    println!("{}", ret);
}

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


typedef long long ll;
    typedef pair <int, int> ii;
typedef pair <int, ii> iii;
typedef pair<ll, ll> pll;
typedef pair<double, int> pdi;
typedef pair<ll, int> pli;
typedef pair<int, ll> pil;

#define iINF (1<<30)
#define INF (1LL<<59)
#define forn(i) for(int i = 0;i < n; ++i)
#define form(i,n) for(int i = 0 ;i < n; ++i)
#define NIL -1

const ll mod = 998244353;
ll n;
ll m;
ll ans;
string str;
ll p0[100010], p1[100010];

int main(){
    int k;
    cin>>n>>k;
    cin>>str;
    int block_num=1;
    bool flg0=true;
    for(auto &c : str){
        if(flg0){
            if(c=='0'){
                p0[block_num-1]++;
            }else{
                flg0=false;
                p1[block_num-1]++;
            }
        }else{
            if(c=='0'){
                block_num++;
                flg0=true;
                p0[block_num-1]++;
            }else{
                p1[block_num-1]++;            }
        }
    }
    if(!flg0){
        block_num++;
        p0[block_num-1]=0;
    }
    int res=max(0, block_num-k);
    int left_[100010], right_[100010];
    left_[0]=0;
    right_[0]=0;
    left_[1]=p0[0];
    right_[1]=p0[block_num-1];
    for(int i=2;i<=block_num;i++){
        left_[i]=left_[i-1]+p0[i-1]+p1[i-2];
        right_[i]=right_[i-1]+p0[block_num-i]+p1[block_num-i];
    }
    int noko=n;
    for(int i=0; i<=res;i++){
        noko=min(noko,left_[i]+right_[res-i]);
    }
    cout<<n-noko<<endl;

    return 0;
}

Measured memory_bytes: 1664
use proconio::input;

fn gcd(a: i64, b: i64) -> i64 {
  return if b == 0 { a } else { gcd(b, a % b) };
}

fn main() {
  input! {
    k: i64,
  }

  let mut res: i64 = 0;

  for a in 1..k+1 {
    for b in 1..k+1 {
      for c in 1..k+1 {
        res += gcd(a, gcd(b, c));
      }
    }
  }

  println!("{}", res);
}

Measured memory_bytes: 2152
#include <bits/stdc++.h>
using namespace std;
#define mp make_pair
#define pb(x) push_back(x)
#define vi vector<int>
#define vs vector<string>
#define vll vector<long long>
#define vc vector<char>
#define vs vector<string>
#define pii pair<int, int>
#define pll pair<long long, long long>
#define pil pair<int, long long>
#define pli pair<long long, int>
#define pcc pair<char, char>
#define pdd pair<double, double>
#define mll map<long long, long long>
#define sz(v) ((int)(v).size())
#define all(v) (v).begin(), (v).end()
#define flsh fflush(stdout)
#define gcd __gcd
#define clr(x) memset(x, 0, sizeof(x))
#define mod 1000000007LL
#define INF 1000000000007
 

typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;


void solve()
{
    ll r;
    cin>>r;
    // cout<<r<<"\n";
    ld ans=2.0*3.14159*r;
    cout<<ans<<"\n"; 
}


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


if (fopen("input.txt","r" ))
  {
     freopen("input.txt", "r", stdin);
     freopen("output.txt", "w", stdout);
  }
cout<<setprecision(20);


ll t=1;


// cin>>t;


while(t--)
{
solve();
} 


return 0;
}

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

int main() {
    int N, M; cin >> N >> M;
    vector<int> A(M);
    for(int i = 0; i < M; ++i) {
        cin >> A[i];
    }
    vector<int> ans(N);
    for(int i = 0; i < M; ++i) {
        for(int j = 0; j < N; ++j) {
            int B; cin >> B;
            if(A[i] == B) {
                ans[j]++;
            } else {
                ans[A[i] - 1]++;
            }
        }
    }
    for(auto x : ans) {
        cout << x << endl;
    }
}



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

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

    if (2 * b == a + c) {
        cout << "YES" << endl;
    } else {
        cout << "NO" << endl;
    }


    return 0;
}


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


int comp(const void* a, const void* b) {
    return *(int*) a - *(int*)b;
}


int main() {
    int N, K;
    scanf("%d %d", &N, &K);
    int* h =(int*) malloc(N * sizeof(int));
    int i;
    for(i = 0; i < N; i++) {
        scanf("%d", &h[i]);
    }
    qsort(h, N, sizeof(int), comp);
    int start = 0, end = K - 1;
    int min = (int)1e9 + 1;

    while(end < N) {
        int diff = h[end] - h[start];
        if(diff < min) min = diff;
        start++;
        end++;
    }
    printf("%d\n", min);

    return 0;
}

Measured memory_bytes: 892
#include <cstdio>

int main() {
  char S[4];
  scanf("%s", S);

  if (S[0] != 'a' && S[1] != 'a' && S[2] != 'a') {
    puts("No");
  } else if (S[0] != 'b' && S[1] != 'b' && S[2] != 'b') {
    puts("No");
  } else if (S[0] != 'c' && S[1] != 'c' && S[2] != 'c') {
    puts("No");
  } else {
    puts("Yes");
  }
}

Measured memory_bytes: 128