akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define ld long double
#define ll long long
#define P pair<int,int>
#define fi first
#define se second
#define rep(i,n) for(int i=0;i<n;i++)
#define all(v) v.begin(),v.end()
#define pb push_back
#define eb emplace_back
template<class T>void chmax(T &a,T b){if(a<b)a=b;}
template<class T>void chmin(T &a,T b){if(a>b)a=b;}
constexpr int INF=1000000000000000000;
constexpr int mod=1000000007;
constexpr double eps=1e-8;
const double pi=acos(-1);
int dx[]={0,1,0,-1},dy[]={1,0,-1,0};
int Random(int mi,int ma){
    random_device rnd;
    mt19937 mt(rnd());//32bit
    //[mi,ma]
    uniform_int_distribution<int>engine(mi,ma);
    return engine(mt);
}
int gcd(int a,int b){
    if(b==0)return a;
    return gcd(b,a%b);
}
int lcm(int a,int b){
    return a/gcd(a,b)*b;
}
bool prime(int a){
    if(a==1)return false;
    for(int i=2;i*i<=a;i++){
        if(a%i==0)return false;
    }
    return true;
}
int modpow(int a,int b){
    if(b==0)return 1;
    if(b%2)return modpow(a,b-1)*a%mod;
    int memo=modpow(a,b/2);
    return memo*memo%mod;
}
vector<int>kaijo,invkaijo;
void init_fact(int n){
    kaijo.resize(n+1);
    invkaijo.resize(n+1);
    kaijo[0]=1;
    for(int i=1;i<=n;i++){
        kaijo[i]=kaijo[i-1]*i;
        kaijo[i]%=mod;
    }
    rep(i,n+1)invkaijo[i]=modpow(kaijo[i],mod-2);
}
int comb(int a,int b){
    if(a<b)return 0;
    if(a<0||b<0)return 0;
    return kaijo[a]*invkaijo[a-b]%mod*invkaijo[b]%mod;
}
int inv(int x){
    x=modpow(x,mod-2);
    return x;
}
struct block{
    int w,s,v;
    bool operator<(block b){
        return w+s<b.w+b.s;
    }
};
int dp[1010][30010];
signed main(){
    cin.tie(0);ios::sync_with_stdio(false);
    int n;
    block b[1010];
    cin>>n;
    rep(i,n){
        int w,s,v;
        cin>>w>>s>>v;
        b[i]={w,s,v};
    }
    sort(b,b+n);
    dp[0][0]=0;
    rep(i,n){
        rep(j,20001){
            chmax(dp[i+1][j],dp[i][j]);
            chmax(dp[i+1][j+1],dp[i+1][j]);
            if(j<=b[i].s)chmax(dp[i+1][j+b[i].w],dp[i][j]+b[i].v);
        }
    }
    cout<<*max_element(dp[n],dp[n]+20001)<<endl;
    return 0;
}

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

template <typename T>
struct Edge
{
    int to;
    T cost;
};

template <typename T>
struct WeightedGraph
{
    int n;
    vector<vector<Edge<T>>> g;
    
    WeightedGraph(int n) : n(n){
        g.resize(n);
    }
    
    void init(int n_){
        n = n_;
        g.resize(n_);
    }
    
    void add_edge(int from, int to, T cost){
        g[from].push_back((Edge<T>){to, cost});
    }
};

struct Graph
{
    int n;
    vector<vector<int>> g;
    
    Graph(int n) : n(n){
        g.resize(n);
    }
    
    void init(int n_){
        n = n_;
        g.resize(n_);
    }
    
    void add_edge(int from, int to){
        g[from].push_back(to);
    }
};

template <typename T>
vector<T> Dijkstra(WeightedGraph<T> &g, int s){
    int n = g.n;
    vector<T> d(n);
    fill(d.begin(), d.end(), -1);
    queue<int> que;
    d[s] = 0;
    que.push(s);
    while(que.size()){
        int now = que.front();
        que.pop();
        for(Edge<T> e : g.g[now]){
            if(d[e.to] == -1){
                d[e.to] = d[now] + e.cost;
                que.push(e.to);
            }
        }
    }
    return d;
}

int main()
{
    int n, u, v;
    cin >> n >> u >> v;
    u--; v--;
    WeightedGraph<int> g(n);
    for(int i = 0; i < n - 1; i++){
        int a, b;
        cin >> a >> b;
        a--; b--;
        g.add_edge(a, b, 1);
        g.add_edge(b, a, 1);
    }
    vector<int> d = Dijkstra(g, u);
    vector<int> e = Dijkstra(g, v);
    int ans = 0;
    for(int i = 0; i < n; i++) if(d[i] < e[i]) ans = max(ans, e[i] - 1);
    cout << ans << endl;
}

Measured memory_bytes: 7168
#include <bits/stdc++.h>
#define rep(i,n) for (int i=1; i<=(n); i++)
using namespace std;
typedef long long ll;

int main(){
    int N,M; cin >> N >> M;
    vector <pair<int,int>> A(51);//生徒位置
    rep(i,N){
        int a,b; cin >> a >> b;
        A[i]=make_pair(a,b);
    }
    vector <pair<int,int>> B(51);//チェックポイント位置
    rep(j,M){
        int c,d; cin >> c >> d;
        B[j]=make_pair(c,d);
    }
    
    rep(i,N){
        int ans=1e9;
        int ans_num=1e9;
        rep(j,M){
            if(ans>abs(A[i].first-B[j].first)+abs(A[i].second-B[j].second)){
                ans=abs(A[i].first-B[j].first)+abs(A[i].second-B[j].second);
                ans_num=j;
                ans_num=min(ans_num,j);
            }
        }
        cout << ans_num << endl;
    }
}

Measured memory_bytes: 256
import sys
input = sys.stdin.readline

# 再帰上限を引き上げる
sys.setrecursionlimit(10**6)

# G:graph, cr:current node, seen:is seen?, dist:out;each distance
def dfs(G,cr,seen,dist):
	seen[cr] = 1
	for i in G[cr]: #G[cr]から行ける各頂点へ
		if seen[i] == 0: #まだ通っていなかったら
			dist[i] = dist[cr]+1
			dfs(G,i,seen,dist)


n,u,v = (int(x) for x in input().split())

u,v = u-1,v-1

a = [[] for i in range(n)]

for i in range(n-1):
	# 配列indexは0開始だからinputは-1
	l,m = (int(x)-1 for x in input().split())
	a[l].append(m)
	a[m].append(l)

# v視点のdistを調べる
dist_u = [0]*n
dist_v = [0]*n

dfs(a,u,[0]*n,dist_u)
# u視点のdistを調べる
dfs(a,v,[0]*n,dist_v)

for i in range(n):
	if dist_u[i] >= dist_v[i]: # vが追いつける距離なら
		dist_v[i] = -1

print(max(dist_v) - 1)

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

using ll = long long;
using Pi = pair<int, int>;
using Pl = pair<ll, ll>;
using vint = vector<int>;
using vvint = vector<vint>;
using vvvint = vector<vvint>;
using vdouble = vector<double>;
using vvdouble = vector<vdouble>;
using vvvdouble = vector<vvdouble>;
using vll = vector<ll>;
using vvll = vector<vll>;
using vvvll = vector<vvll>;
using uint = unsigned int;
using ull = unsigned long long;

template<typename T> using uset = unordered_set<T>;
template<typename T1, typename T2> using umap = unordered_map<T1, T2>;

constexpr int INF = (1 << 30) - 1;
constexpr ll LLINF = 1LL << 60;
constexpr int dy[] = {1, 0, -1, 0, 1, -1, -1, 1};
constexpr int dx[] = {0, 1, 0, -1, 1, 1, -1, -1};
constexpr char el = '\n';
constexpr int mod = 1000000007;
constexpr int mod2 = 998244353;
template<typename T> T gcd(T a, T b) { return (b ? gcd(b, a % b) : a); }
template<typename T> T lcm(T a, T b) { return (a / gcd(a, b) * b); }
template<typename T1, typename T2>
inline bool chmin(T1 &a, T2 b) { return (a > b && (a = b, true)); }
template<typename T1, typename T2>
inline bool chmax(T1 &a, T2 b) { return (a < b && (a = b, true)); }
template<typename T>
bool isin(T y, T x, T h, T w) { return (0 <= y && 0 <= x && y < h && x < w); }
template<typename T>
bool isin1(T y, T x, T h, T w) { return (0 < y && 0 < x && y <= h && x <= w); }

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

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

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


void Main() {
	ll N; cin >> N;
	ll cnt = 0;
	for (ll i = 2; i*i <= N; i++) {
		ll cn = 0;
		ll border = 1;
		while (N % i == 0) {
			N /= i;
			cn++;
			if (cn == border) {
				cnt++;
				cn = 0;
				border++;
			}
		}
	}
	if (N > 1) cnt++;
	cout << cnt << endl;
}

int main() {
	cin.tie(0);
	ios::sync_with_stdio(0);
	cout << fixed << setprecision(20);
	Main();
	return (0);
}


Measured memory_bytes: 3644
#import<bits/stdc++.h>
using namespace std;long L,R,D,M=998244353,l,r,d,z,A['   '];map<int,int>m;main(){cin>>l>>r;for(m[l]=1;l--;A[l]=++z%=M)z*=10;for(;cin>>L>>R>>D;cout<<z<<" "){z+=D*(A[--L]-A[R]+M);auto t=m.lower_bound(l=L);for(d=t->second;z=(z-t->second*(A[l]-A[r=min(R,l=t->first)])%M+M)%M,r<R;t=m.erase(t));m[L]=d;m[R]=D;}}

Measured memory_bytes: 14476
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <stack>
#include <queue>
#include <map>
using namespace std;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef long long ll;
typedef vector<ll> vll;
typedef vector<vector<ll>> vvll;

int main()
{
    ll n;
    cin >> n;
    map<string, ll> mp;
    for (int i = 0; i < n; i++)
    {
        string s;
        cin >> s;

        vector<char> sorted(s.length());
        for (size_t j = 0; j < s.length(); j++)
        {
            sorted[j] = s[j];
        }
        sort(sorted.begin(), sorted.end());

        string key = "";
        for (size_t j = 0; j < s.length(); j++)
        {
            key = key + sorted[j];
        }

        if (mp.find(key) != mp.end())
        {
            mp[key]++;
        }
        else
        {
            mp[key] = 1;
        }
    }

    ll ans = 0;
    for (auto v : mp)
    {
        ll cnt = v.second;
        ans += (cnt * (cnt - 1) / 2);
    }
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 11136
#include <bits/stdc++.h>
#define ALL(a)  (a).begin(),(a).end()
#define sz(x) int(x.size())
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
typedef pair<long long, long long> Pll;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<long long> vll;
typedef vector<vector<long long>> vvll;
template <typename T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template <typename T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
const long long INF = 1LL << 60;
const int INT_INF = 1 << 30;
const double PI = acos(-1.0);
#define MOD 1000000007LL
#define endl "\n"

int main(){
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  ll H, W;
  cin >> H >> W;
  vector<string> S(H);
  for(int i = 0; i < H; i++){
    cin >> S.at(i);
  }
  Pll p(0, 0);
  vector<vector<bool>> flag(H, vector<bool>(W, false));
  vi dy = {1, -1, 0, 0};
  vi dx = {0, 0, 1, -1};
  function<void(int, int)> dfs = [&](int y, int x){
    flag.at(y).at(x) = true;
    char c = S.at(y).at(x);
    if(c == '#') p.first++;
    else p.second++;
    for(int i = 0; i < 4; i++){
      int yy = y + dy.at(i);
      int xx = x + dx.at(i);
      if(yy < 0 || yy >= H || xx < 0 || xx >= W) continue;  
      if(flag.at(yy).at(xx)) continue;
      if(S.at(yy).at(xx) == c) continue;
      dfs(yy, xx);
    }
  };
  ll ans = 0LL;
  for(int i = 0; i < H; i++){
    for(int j = 0; j < W; j++){
      if(flag.at(i).at(j)) continue;
      p = Pll(0, 0);
      dfs(i, j);
      ans += p.first * p.second;
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 17952
package main

import "fmt"

func main() {
	var n int
	fmt.Scan(&n)

	count := 0
	for i := 0; i < n; i++ {
		var d1, d2 int
		fmt.Scan(&d1, &d2)
		if d1 == d2 {
			count += 1
		} else {
			count = 0
		}
		if count == 3 {
			fmt.Println("Yes")
			return
		}
	}

	fmt.Println("No")
}


Measured memory_bytes: 1772
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <set>
#include <queue>
#include <stack>
#include <tuple>
#include <cmath>
#include <iomanip>
#include <map>
#include <cstring> //memset(dp,0,sizeof(dp))
#include <functional>
#include <cctype>
#include <locale>
#define ll long long
#define rep(i,n) for(int i=0;i<(n);i++)
#define rrep(i,n) for(int i=n-1;i>=0;i--)
#define fi first
#define se second
#define pb push_back
#define ALL(a) (a).begin(),(a).end()
using namespace std;
template<typename T1,typename T2> inline void chmin(T1 &a,T2 b){if(a>b) a=b;}
template<typename T1,typename T2> inline void chmax(T1 &a,T2 b){if(a<b) a=b;}
typedef pair<int,int> P;
typedef pair<long long,long long> Pll;
#define fout(num) cout << fixed << setprecision(20) << (num) << endl
//s[i]=tolower(s[i]); islower(s[i]); cout << tolower(s[i])はバグ


signed main(){
    ios::sync_with_stdio(false);
    std::cin.tie(nullptr);
    ll n; cin >> n;
    ll a[3],b[3];
    rep(i,3) cin >> a[i];
    rep(i,3) cin >> b[i];
    
    vector<vector<ll>> dp(4,vector<ll>(n+1LL));
    
    rep(i,n+1) dp[0][i]=0;
    
    rep(i,3){
        rep(j,n+1){
            if((j-a[i])>=0) dp[i+1][j]=max(dp[i][j],dp[i+1][j-a[i]]+b[i]-a[i]);
            else dp[i+1][j]=dp[i][j];
        }
    }
    
    ll res=0;
    for(ll i=0;i<=n;i++) chmax(res,n+dp[3][i]);

    
    vector<vector<ll>> dp2(4,vector<ll>(res+1LL));

    rep(i,res+1) dp2[0][i]=0;
    rep(i,3){
        rep(j,res+1){
            if((j-b[i])>=0) dp2[i+1][j]=max(dp2[i][j],dp2[i+1][j-b[i]]+a[i]-b[i]);
            else dp2[i+1][j]=dp2[i][j];
        }
    }
    ll ans=0;
    for(ll i=0;i<=res;i++) chmax(ans,res+dp2[3][i]);
    
    cout << ans << endl;
}


Measured memory_bytes: 979992
#include <iostream>
#include <cstdio>
#include <utility>
using namespace std;

#define abs(N) (((N)>0)?(N):(-1)*(N))


int main() {
	int N,M;
	cin >> N >> M;
	for (int i = N; i <= M/2; ++i) {
		if(M%i==0){
			cout << M/i << endl;
			return 0;
		}
	}
	cout << 1 << endl;
	return 0;
}


Measured memory_bytes: 256
n = int(input())
p = tuple(map(int, input().split()))
q = tuple(map(int, input().split()))

import itertools
r = list(itertools.permutations(range(1, n+1)))

p_place = r.index(p)
q_place = r.index(q)
answer = abs(p_place-q_place)
print(answer)

Measured memory_bytes: 8052
S = input()
K = int(input())

def count(s):
    """何文字変更が必要か
    """
    a = []
    b = ''
    c = 1
    for si in s:
        if b == si:
            c += 1
        else:
            a.append(c)
            c = 1
        b = si
    a.append(c)

    r = 0
    for ai in a:
        r += ai // 2
    # print(s, a, r)
    return r

if K == 1:
    ans = count(S)
elif len(S) == 1:
    ans = K // 2
elif len(set(S)) == 1:
    c = count(S*2)
    if K % 2 == 0:
        ans = c * (K//2)
    else:
        diff = count(S*3) - count(S*2)
        ans = c * (K//2) + diff
else:
    a1 = count(S*2)
    a2 = count(S*3)
    ans = a1 + (a2-a1) * (K-2)

print(ans)

# for i in range(1, 10):
#     print(i, S*i, count(S*i))


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

int main() {
  int n;
  cin>>n;
  int p[n+1];
  for (int i=1; i<=n; i++) cin>>p[i];
  int cnt = 0;
  for (int i=1; i<=n; i++) {
    if (p[i] != i) {
      ++cnt;
    }
  }
  if (cnt <= 2) {
    cout<<"YES"<<endl;
  } else {
    cout<<"NO"<<endl;
  }
}

Measured memory_bytes: 256
//http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=2007

#include<iostream>
#include<map>
#include<vector>
#include<algorithm>
#include<cmath>
#include<climits>
#include<ctime>
#include<cstring>
#include<numeric>

#define ALL(v) (v).begin(),(v).end()
#define REP(i,p,n) for(int i=p;i<(int)(n);++i)
#define rep(i,n) REP(i,0,n)
#define dump(a) (cerr << #a << "=" << (a) << endl)
#define DUMP(list) cout << "{ "; for(auto nth : list){ cout << nth << " "; } cout << "}" << endl;

using namespace std;

int main()
{
	int money=0;
	bool is_first=true;

	while(cin >> money && money)
	{
		int yen[4] = {10, 50, 100, 500};
		vector<int> num(4,0);
		vector<int> ans(4,0);
		int sum=0;

		rep(i,num.size()){
			cin >> num[i];
			sum += yen[i] * num[i];
		}

		if(!is_first){ 
			cout << endl; 
		}else{
			is_first=false;
		}

		sum -= money;
		for(int i=3; i>=0; --i)
		{
			ans[i] = sum / yen[i];
			sum %= yen[i];
			if(num[i] >= ans[i]){
				ans[i] = num[i] - ans[i];
			}else{
				ans[i] = 0;
			}
		}

		rep(i,ans.size()){
			if(ans[i]){ cout << yen[i] << " " << ans[i] << endl; }
		}

	}
	return 0;
}

Measured memory_bytes: 1192
#include <bits/stdc++.h>
using namespace std;
int main(){
long long n,a,b;
scanf ("%lld", &n);
scanf ("%lld", &a);
scanf ("%lld", &b);
long long min,max;
min=(n-1)*a+b;
max=(n-1)*b+a;
long long ans;
ans=max-min+1;
 if (ans<0) ans=0;
printf ("%lld",ans);
return 0;
}


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

#define N 36

typedef struct{
  char str[3];
  int value;
} Tramp;

void bubbleSort(Tramp *,int);
void selectionSort(Tramp *,int);
  
int main(void){
  int num,cnt;
  int i;
  Tramp A[N],C1[N],C2[N];

  scanf(" %d",&num);
  
  for(i = 0; i < num; i++){
    scanf(" %s",A[i].str);
  }

  for(i = 0; i < num; i++){
    strcpy(C1[i].str,A[i].str);
    C1[i].value = atoi((A[i].str)+1);
  }

  for(i = 0; i < num; i++){
    strcpy(C2[i].str,A[i].str);
    C2[i].value = atoi((A[i].str)+1);
  }

  bubbleSort(C1,num);
  selectionSort(C2,num);

  for(i = 0; i < num-1; i++){
    printf("%s ",C1[i].str);
  }
  printf("%s\n",C1[num-1].str);
  printf("Stable\n");

  for(i = 0; i < num-1; i++){
    printf("%s ",C2[i].str);
  }
  printf("%s\n",C2[num-1].str);
  
  for(i = 0; i < num; i++){
    if(strcmp(C1[i].str,C2[i].str) != 0){
      printf("Not stable\n");
      break;
    }
  }
  if(i == num){
    printf("Stable\n");
  }
  
  
  return 0;
}

void bubbleSort(Tramp *A, int num){
  int i,j;
  int tmp;
  char str_tmp[3];

  for(i = 0; i < num; i++){
    for(j = num -1; j > i; j--){
      if(A[j].value < A[j-1].value){
	tmp = A[j-1].value;
	A[j-1].value = A[j].value;
	A[j].value = tmp;
	strcpy(str_tmp,A[j-1].str);
	strcpy(A[j-1].str,A[j].str);
	strcpy(A[j].str,str_tmp);
      }
    }
  }

}
  
void selectionSort(Tramp *A, int num){
  int i,j;
  int min,tmp;
  char str_tmp1[3],str_tmp2[3];

  for(i = 0; i < num; i++){
    min = i;
    for(j = i; j < num; j++){
      if(A[j].value < A[min].value){
	min = j;
      }
    }
    tmp = A[i].value;
    A[i].value = A[min].value;
    A[min].value = tmp;
    strcpy(str_tmp1,A[i].str);
    strcpy(str_tmp2,A[min].str);
    strcpy(A[i].str,str_tmp2);
    strcpy(A[min].str,str_tmp1);
  }

}



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

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


int main(void){
    string str;
    while(cin>>str){
        if(str=="#") break;
        int now=str.length()-1;
        int countn=0, countw=0;
        int a=0, b=1, suma=0, sumb=1;
        while(now>=0){
            if(str[now]=='h'){
                if(countn!=0||countw!=0){
                    b*=2;
                    suma=suma*2-a;
                    sumb=b;
                }
                countn++;
                now-=5;
            }
            else if(str[now]=='t'){
                if(countn==0&&countw==0){
                    a=suma=90;
                }
                else{
                    if(countw==0) a=90;
                    b*=2;
                    suma=suma*2+a;
                    sumb=b;
                }
                countw++;
                now-=4;
            }
        }
        int r=gcd(suma, sumb);
        if(sumb/r==1) cout << suma/r << "\n";
        else cout << suma/r << "/" << sumb/r << "\n";
        
    }
    
}



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

#define F first
#define S second
#define MP make_pair
#define pb push_back
#define all(a) a.begin(), a.end()
#define lcm( a, b ) (a)/__gcd((a),(b))*(b)
#define endl '\n'

using namespace std;

typedef long long LL;
typedef pair< int, int > P;
typedef pair< LL, LL > LP;

static const int INF = INT_MAX;
static const LL LINF = LLONG_MAX;
static const int MIN = INT_MIN;
static const LL LMIN = LLONG_MIN;
static const int MOD = 1000000007;
static const int SIZE = 200005;

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

LL fac[SIZE], finv[SIZE], inv[SIZE];
void combInit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for( int i = 2; i < SIZE; ++i ) {
        fac[i] = (fac[i - 1] * i) % MOD;
        inv[i] = MOD - inv[MOD % i] * (MOD / i) % MOD;
        finv[i] = (finv[i - 1] * inv[i]) % MOD;

    }
}

LL comb(int n, int k) {
    if( n < k ) return 0;
    if( n < 0 || k < 0 ) return 0;
    return (fac[n] * (finv[k] * finv[n - k] % MOD)) % MOD;

}

vector< int > Div( int n ) {
    vector< int > ret;
    for( int i = 1; i * i <= n; ++i ) {
        if( n % i == 0 ) {
            ret.pb( i );

            if( i * i != n ) ret.pb( n / i );
        }
    }
    sort( all( ret ) );
    return ret;
}

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

    int n, m;
    cin >> n >> m;
    bool ac[SIZE] = {};
    int wa[SIZE] = {};
    int acnt = 0,  wcnt = 0;
    for( int i = 0; i < m; ++i ) {
        int a;
        string b;
        cin >> a >> b;
        if( b == "AC" && !ac[a] ) {
            ac[a] = true;
            ++acnt;

        }
        if( b == "WA" && !ac[a] ) {
            ++wcnt;
            wa[a]++;


        }
    }

    for( int i = 1; i <= n; ++i ) {
        if( !ac[i] ) wcnt -= wa[i];

    }
    cout << acnt << " " << wcnt << endl;
    return 0;
}



Measured memory_bytes: 1280
N = int(input())

def nega_binary(num):
    if num == 0:
        return 0
    res = []
    while num != 0:
        remainder = abs(num) % 2
        res.append(str(remainder))
        if num < 0 and remainder:
            num -= 1
        num = int(num / -2)
    return ''.join(reversed(res))

print(nega_binary(N))

Measured memory_bytes: 3060
import sys

sys.setrecursionlimit(10 ** 7)
rl = sys.stdin.readline


def solve():
    s = rl().rstrip()
    K = int(rl())
    
    ans = []
    for si in s:
        if si == 'a':
            ans.append('a')
            continue
        cnt = ord('z') - ord(si) + 1
        if cnt <= K:
            ans.append('a')
            K -= cnt
        else:
            ans.append(si)
    
    ans[-1] = chr(ord('a') + (ord(ans[-1]) - ord('a') + K % 26) % 26)
    print(''.join(ans))


if __name__ == '__main__':
    solve()


Measured memory_bytes: 46704
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset

#include <math.h>
#include <stdlib.h>


#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
typedef long long ll;

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; }

//INT_MAX	2,147,483,647 = 2*1.0e9

int main(){
  int N, i;
  cin >> N >> i;

  cout << N - i + 1 << endl;

  return 0;
}


Measured memory_bytes: 256
#include <iostream>

using namespace std;

int fib(int n);
int fib_rec(int n, int dp[]);

int main()
{
	int n;
	cin >> n;
	cout << fib(n) << endl;
}


int fib(int n)
{
	//亦可采用静态数组 
	int * dp = new int[n+1]();
	
	int result = fib_rec(n, dp);	
	
	delete [] dp;
	
	return result;	
	
}


int fib_rec(int n, int dp[])
{

	if (n == 1 || n == 0)
		return dp[n] = 1;
	if (dp[n] != 0)
		return dp[n];
	return dp[n] = fib_rec(n-1, dp) + fib_rec(n-2, dp);
}


Measured memory_bytes: 3096
/*

結果:
*/
#define _USE_MATH_DEFINES
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#include <limits.h>  
#include <stdbool.h>   
#define inf (INT_MAX-1)
#define INF 9223372036854775807
#define PI 3.14159265358979323846;
#define EPS 1e-10
#define sq(n) ((n)*(n))
#define rep(i,n) for(i=0;i<n;i++)
#define rev(i,n) for(i=n-1;i>=0;i--)
/*
#define sort(a,n) qsort(a,n,sizeof(TYPE),cmp)
#define sort_r(a,n) qsort(a,n,sizeof(TYPE),cmp_r)
*/
#define chsort(s,n) qsort(s,n,sizeof(char),cmp)
#define chsort_r(s,n) qsort(s,n,sizeof(char),char_cmp_r)
#define TYPE long long
#define ll long long
#define MEMSET(a) memset(a,0,sizeof(a))
#define MEMSET_U(a) memset(a,-1,sizeof(a))
#define bool    _Bool
const int mod = (int)1e09 + 7;

//#define DEBUG1
//#define DEBUG2
//#define DEBUGF
#define DUMMY

int in(void) { int i; scanf("%d", &i); return i; }
long long llin(void) { long long i; scanf("%lld", &i); return i; }
double din(void) { double i; scanf("%lf", &i); return i; }
void chin(char s[]) { scanf("%s", s); }

void print(int a) { printf("%d\n", a); }
void llprint(long long a) { printf("%lld\n", a); }
void dprint(double a) { printf("%.10f\n", a); }
void print2(int a, int b) { printf("%d %d\n", a, b); }
int Max(int a, int b) { if (a > b) { return a; }return b; }
int Min(int a, int b) { if (a < b) { return a; }return b; }
long long llmax(long long a, long long b) { return a > b ? a : b; }
long long llmin(long long a, long long b) { return a < b ? a : b; }
double dmax(double a, double b) { return a > b ? a : b; }
double dmin(double a, double b) { return a < b ? a : b; }
//long long llmax(long long a, long long b) { return a > b ? a : b; }
//long long llmin(long long a, long long b) { return a < b ? a : b; }
//double dmax(double a, double b) { return a > b ? a : b; }
int cmp(const void *a, const void *b) { return *(TYPE *)a - *(TYPE *)b; }
int cmp_r(const void *a, const void *b) { return *(TYPE *)b - *(TYPE *)a; }
int char_cmp(const void *a, const void *b) { return strcmp((char *)a, (char *)b); }
int char_cmp_r(const void *a, const void *b) { return strcmp((char *)b, (char *)a); }
void swap(int *a, int *b) { int t = *a; *a = *b; *b = t; }



int main() {
	int N, M;
	char S[100][101], T[100][101];
	int cnt[100] = { 0 };
	int ans = 0;
	int max = 0;;
	scanf("%d", &N);
	for (int i = 0; i < N; i++) {
		scanf("%s", S[i]);
	}
	scanf("%d", &M);
	for (int j = 0; j < M; j++) {
		scanf("%s", T[j]);
	}

	for (int i = 0; i < N; i++) {
		for (int ii = 0; ii < N; ii++) {
			if (strcmp(S[i], S[ii]) == 0) {
				cnt[i]++;
			}
		}
	}
	for (int i = 0; i < N; i++) {
		for (int j = 0; j < M; j++) {
			if (strcmp(S[i], T[j]) == 0) {
				cnt[i]--;
			}
		}
	}

	for (int i = 0; i < N; i++) {
		ans = Max(ans, cnt[i]);
	}

	printf("%d\n", ans);


#ifdef DEBUGF
	getch();
#endif
	return 0;
	}

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

int main() {
  int h,w;
  cin >> h >> w;
  for ( int i=0; i<h; i++ ) {
    string s;
    cin >> s;
    cout << s << '\n';
    cout << s << '\n';
  }
  return 0;
}


Measured memory_bytes: 3620
N,M = map(int,input().split())
x = []
y = []
for i in range(M):
    x1,y1=[int(i) for i in input().split()]
    x.append(x1)
    y.append(y1)

for i in range(N):
    print(x.count(i+1) + y.count(i+1))

Measured memory_bytes: 3060
#include <iostream>
#include <queue>
#include <stdio.h>
using namespace std;
int n,k,ans,cnt[30],tmp[30],jum;
string x;
priority_queue < int > pq;
int main()
{
    scanf("%d %d",&n,&k);
    for(int i=0;i<n;i++)
    {
        cin>>x;
        cnt[x[0]-'A']++;
    }
    for(int i=0;i<26;i++)
    {
        if(cnt[i]) pq.push(cnt[i]);
    }
    while(pq.size()>=k)
    {
        jum = 0;
        for(int i=0;i<k;i++)
        {
            
            tmp[jum++] = pq.top()-1;
            pq.pop();
        }
        ans+=1;
        for(int i=0;i<jum;i++)
        {
            if(tmp[i]) pq.push(tmp[i]);
        }
    }
    printf("%d\n",ans);
    return 0;
}


Measured memory_bytes: 256
str = input()
num = len(str)
ans = True
for i in range(num):
    if (i+1) % 2 == 0:
        if str[i] == "R":
            ans = False
    else:
        if str[i] == "L":
            ans = False

if ans:
    print("Yes")
else:
    print("No")

Measured memory_bytes: 3060
#include <stdio.h>

int main() {
	int p, q, r, min = 1000;

	scanf("%d %d %d", &p, &q, &r);

	if (min > (p + q))
		min = p + q;
	if (min > (q + r))
		min = q + r;
	if (min > (r + p))
		min = r + p;

	printf("%d\n", min);

	return 0;
}

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

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

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

  int n;
  cin >> n;
  vector<vector<int>> p(n, vector<int>(n));
  rep(i, 0, n) cin >> p[i][0] >> p[i][1];
  double ans = 0;
  rep(i, 0, n) rep(j, i + 1, n) ans +=
      hypot(p[i][0] - p[j][0], p[i][1] - p[j][1]);
  cout << Fixed(10) << 2 * ans / n << '\n';
  return 0;
}

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

int main(){
    int n,m,k;
    cin >> n >> m >> k;
    vector<int> a(n);
    vector<int> b(m);
    rep(i,n) cin >> a[i];
    rep(i,m) cin >> b[i];

    ll t = 0;

    rep(i,m) t += b[i];
    int j = m;
    int ans = 0;
    rep(i,n+1){
        while(j > 0&&t > k){
            j--;
            t -= b[j];
        }
        if (t > k)break;
        ans = max(ans,i+j);
        if (i == n)break;
        t += a[i];
    }
    cout << ans <<endl;
}

Measured memory_bytes: 4772
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int X = sc.nextInt();

        int sum = X;
        int count = 1;
        while(sum % 360 != 0) {
            sum += X;
            count++;
        }
        System.out.println(count);
    }
}


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

using ll = long long;
using ld = long double;
using pii = pair<int, int>;

#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define all(x) (x).begin(),(x).end()
#define m0(x) memset(x,0,sizeof(x))

int dx4[4] = {1,0,-1,0}, dy4[4] = {0,1,0,-1};

int main()
{
    int n;
    ll ans=0;
    cin>>n;
    vector<ll> a(3*n);
    
    for(int i = 0; i < 3*n; i++)
    {
        cin>>a[i];
    }
    sort(all(a));
    reverse(all(a));
    
    for(int i = 0; i < n; i++)
    {
        ans+=a[i*2+1];
    }
    
    

    cout<<ans<<endl;

    return 0;
}

Measured memory_bytes: 2560
n = int(input())
a = list(input())
b = list(input())
c = list(input())
ans = 0
for i in range(n):
    if (a[i] == b[i]) and (b[i] == c[i]):
        ans += 0
    elif (a[i] != b[i]) and (a[i] != c[i]) and (b[i] != c[i]):
        ans += 2
    else:
        ans += 1
print(ans)

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

using namespace std;

#define llint long long int
#define REP(i,s,l) for(llint i=s;i<l;i++)
#define DEBUG 0
#define INF (1LL<<50)
#define MOD 1000000007

int main() {


    int  H,W,h,w;
    cin >> H >> W >> h >> w ;

    cout << (H-h)*(W-w) << endl;

    return 0;
}

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

using namespace std;

int main() {
    int n;
    cin >> n;
    vector<int> h(n);

    for (int i = 0; i < h.size(); ++i) cin >> h[i];

    int count = 0;
    int max = 0;
    for (int i = 0; i < h.size(); ++i) {
        if (h[i] >= max) {
            max = h[i];
            count++;
        }
    }
    cout << count << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define P pair<ll,ll>
#define FOR(I,A,B) for(ll I = (A); I < (B); ++I)
#define FORR(I,A,B) for(ll I = (B-1); I >= (A); --I)
#define SORT(x) (sort(x.begin(),x.end())) // 0 2 2 3 4 5 8 9
#define REV(x) (reverse(x.begin(),x.end())) //reverse
ll gcd(ll a,ll b){if(a<b)swap(a,b);if(a%b==0)return b;else return gcd(b,a%b);}
ll lcm(ll a,ll b){ll c=gcd(a,b);return ((a/c)*(b/c)*c);}//saisyo kobaisu
const ll INF=1e18+7;
const ll MOD=1e9+7;

ll calc(ll m,ll n,ll mod){
	if(n==0)return 1;
	ll ans = calc(m,n/2,mod);
	ans = ans*ans % mod;
	if(n&1)ans *= m;
	return ans%mod;
}
ll fai(ll n,ll mod){
	ll ans = 1;
	map<ll,ll> mp;
	ll k = n;
	FOR(i,2,sqrt(k)+1){
		while(n%i==0){
			n/=i;
			mp[i]++;
		}
	}
	if(n!=1)ans*=(n-1);
	ans %= mod;
	for(auto x:mp){
		ll p = x.first;
		ll m = x.second;
		ans *= calc(p,m,mod)-calc(p,m-1,mod);
		ans %= mod;
	}
	if(ans<0)ans += mod;
	return ans;
}




int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	ll n;
	cin >> n;
	cout << fai(n,MOD) << endl;
}


Measured memory_bytes: 3168
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <cmath>
#include <numeric>
#include <queue>
#include <sstream>

using namespace std;

typedef long long ll;

ll L[999999];
vector<ll> memo(999999,-1);
ll N;

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

ll dp(ll n){
    if(n==1) return abs(L[0]-L[1]);
    else if(n==0) return 0;
    
    if(memo[n]!=-1) return memo[n];
    return memo[n]=min(dp(n-1)+abs(L[n]-L[n-1]),dp(n-2)+abs(L[n]-L[n-2]));
}

int main(){
    cin>>N;
    rep(i,N) cin>>L[i];
    memo[0]=0;
    cout<<dp(N-1);
    return 0;
}

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

int main() {
	int w, h, n;
	cin >> w >> h >> n;
	vector<vector<bool>> grid(w, vector<bool>(h));
	for (int i = 0; i < n; i++) {
		int x, y, a;
		cin >> x >> y >> a;
		for (int i = 0; i < w; i++) {
			for (int j = 0; j < h; j++) {
				switch (a) {
				case 1:
					if (i < x)
						grid[i][j] = true;
					break;
				case 2:
					if (i >= x)
						grid[i][j] = true;
					break;
				case 3:
					if (j < y)
						grid[i][j] = true;
					break;
				case 4:
					if (j >= y)
						grid[i][j] = true;
					break;
				}
			}
		}
	}
	int ans = 0;
	for (int i = 0; i < w; i++)
		for (int j = 0; j < h; j++)
			if (grid[i][j] == false)
				ans++;
	cout << ans << endl;
}

Measured memory_bytes: 256
from collections import deque


class Bt(object):
    def __init__(self):
        self.used = [False] * 10  # 0-9????????°???????????¨?????????????????????????????°
        self.answers = []  # ?????¶???????????????????????????
        self.Q = deque()  # ????????§???????????¢??????????????°???????¨???¶??¨

    def solve(self, num, remain):
        # ????´¢??????????°??????§?????????????????????????????§????????????????????§????????°??????????????????????????????
        try:
            min_choice = max(self.Q) + 1
        except ValueError:
            min_choice = 0

        if min_choice <= remain < 10 and self.used[remain] == False and num == 1:
            self.Q.append(remain)
            # print('{0}'.format(self.Q))
            #ans = [*self.Q]
            ans = []
            for i in self.Q:
                ans.append(i)
            ans.sort()
            if not ans in self.answers:
                self.answers.append(ans)
            self.Q.pop()
            # self.answers.append(1)
            return
        elif num < 0:
            return

        for i in range(min_choice, 10):
            if self.used[i] == False and (remain - i) >= 0:
                self.used[i] = True
                self.Q.append(i)
                self.solve(num - 1, remain - i)
                self.used[i] = False
                self.Q.pop()


if __name__ == '__main__':
    while True:
        # ??????????????\???
        n, s = [int(x) for x in input().split(' ')]
        if n == 0 and s == 0:
            break

        if 0 <= s <= 45:
            # ????????????
            a = Bt()
            a.solve(n, s)

            # ???????????¨???
            print(len(a.answers))
        else:
            print(0)

Measured memory_bytes: 7888
#include <bits/stdc++.h>
using namespace std;
using uint = unsigned int;
using lint = long long int;
using ulint = unsigned long long int;
template<class T = int> using V = vector<T>;
template<class T = int> using VV = V< V<T> >;
template<class T, class U> void assign(V<T>& v, int n, const U& a) { v.assign(n, a); }
template<class T, class... Args> void assign(V<T>& v, int n, const Args&... args) { v.resize(n); for (auto&& e : v) assign(e, args...); }


template<class Int> Int rng(Int a, Int b) {
  static mt19937 mt(chrono::steady_clock().now().time_since_epoch().count());
  assert(a < b);
  return uniform_int_distribution<Int>(a, b - 1)(mt);
}

namespace RandomizedBinarySearchTree {
  struct Node;
  using Tree = Node*;
  struct Node {
    lint val, sum, laz;
    Tree cl, cr;
    int n;
    Node() {}
    Node(lint v);
  };
  Tree nil = new Node();
  Node::Node(lint v) :
    val(v), sum(v), laz(0), cl(nil), cr(nil), n(1) {}

  Tree update(Tree t) {
    t->sum = t->cl->sum + t->val + t->cr->sum;
    t->n = t->cl->n + 1 + t->cr->n;
    return t;
  }

  void push(Tree t) {
    t->cl->val += t->laz;
    t->cl->sum += t->laz * t->cl->n;
    t->cl->laz += t->laz;
    t->cr->val += t->laz;
    t->cr->sum += t->laz * t->cr->n;
    t->cr->laz += t->laz;
    t->laz = 0;
  }

  Tree merge(Tree tl, Tree tr) {
    if (tr == nil) return tl;
    if (tl == nil) return tr;
    if (rng(0, tl->n + tr->n) < tl->n) {
      push(tl);
      tl->cr = merge(tl->cr, tr);
      return update(tl);
    } else {
      push(tr);
      tr->cl = merge(tl, tr->cl);
      return update(tr);
    }
  }

  pair<Tree, Tree> split(Tree t, int i) {
    if (t == nil) return {nil, nil};
    push(t);
    if (i <= t->cl->n) {
      Tree resl;
      tie(resl, t->cl) = split(t->cl, i);
      return {resl, update(t)};
    } else {
      Tree resr;
      tie(t->cr, resr) = split(t->cr, i - t->cl->n - 1);
      return {update(t), resr};
    }
  }

  Tree insert(Tree t, int i, lint v) {
    Tree tl, tr;
    tie(tl, tr) = split(t, i);
    return merge(merge(tl, new Node(v)), tr);
  }

  Tree erase(Tree t, int i) {
    Tree tl, tr;
    tie(tl, tr) = split(t, i);
    tr = split(tr, 1).second;
    return merge(tl, tr);
  }
}

using namespace RandomizedBinarySearchTree;

int main() {
  cin.tie(nullptr); ios_base::sync_with_stdio(false);
  int n, q; cin >> n >> q;
  Tree t = nil;
  for (int i = 0; i < n; ++i) {
    t = insert(t, i, 0);
  }
  for (int _ = 0; _ < q; ++_) {
    int type; cin >> type;
    if (type == 0) {
      int l, r, x; cin >> l >> r >> x, --l;
      Tree tl, tm, tr;
      tie(tl, tr) = split(t, r);
      tie(tl, tm) = split(tl, l);
      tm->val += x;
      tm->sum += x * tm->n;
      tm->laz += x;
      t = merge(merge(tl, tm), tr);
    } else {
      int l, r; cin >> l >> r, --l;
      Tree tl, tm, tr;
      tie(tl, tr) = split(t, r);
      tie(tl, tm) = split(tl, l);
      cout << tm->sum << '\n';
      t = merge(merge(tl, tm), tr);
    }
  }
}


Measured memory_bytes: 9436
' Imports System.Collections.Generic
' Imports System.Text.RegularExpressions

Class Main
    Public Shared Function checkPal(ByVal s As String) As Boolean
        return s = StrReverse(s)
    End Function

    Public Shared Sub Main()
        Dim S As String = Console.ReadLine()
        Dim str As String = S.Substring(0, Math.floor(S.Length / 2))
        Console.WriteLine(If(checkPal(S) AndAlso checkPal(str),"Yes", "No"))
    End Sub
End Class


Measured memory_bytes: 19920
use proconio::input;

fn main() {
    input!(n: usize, a: [usize; n]);
    let mut mul = vec![0; 100_001];
    for x in a {
        mul[x] += 1;
    }
    println!(
        "{}",
        (1..100_000)
            .map(|i| { mul[i - 1] + mul[i] + mul[i + 1] })
            .max()
            .unwrap()
    );
}


Measured memory_bytes: 3720
#include<bits/stdc++.h>          
using namespace std;
 
#define rep(i,n) for(int i=0;i<(n);++i)
#define reps(i,n) for(int i=1;i<=(n);++i)
#define all(x) (x).begin(),(x).end()
//#define int long long
#define mk_p(a,b)	make_pair((a),(b))
using pii = pair<int,int>;
constexpr int INF  = 0x3f3f3f3f;
constexpr long long LINF = 0x3f3f3f3f3f3f3f3fLL;
constexpr long long MOD = 1000000007;

int gcd(int a,int b){return b ? gcd(b,a%b) : a;}
int lcm(int a,int b){return a/gcd(a,b)*b;}

signed main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	string a,b;
	cin >> a >> b;
	a = a + b;
	int n = stoi(a);
	double x = n;
	cout << ((sqrt(x) == int(sqrt(n))) ? "Yes\n" : "No\n"); 
	return 0;
}


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

int main(int argc, char *argv[]) {
  ios::sync_with_stdio(false);
	cin.tie(nullptr);
	cout.tie(nullptr);

  int a,b;cin>>a>>b;
  if(a <= b*2){
    cout<<0<<endl;
  }else{
    cout<<a-b*2<<endl;
  }

  return 0;
}


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

using namespace std;

#define endl            "\n"
#define sz(x)          (int) (x.size())
#define all(v)          v.begin(), v.end()
#define isOdd(n)       (n&1)
#define pow(n, m)      (ll)powl(n, m)
#define clr(x, val)     memset(x, val, sizeof(x))

typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef vector<int> vi;

const int N = 1e5 + 5;
unordered_map<int, int> mp;
ll pfx[N];
int main()
{
    ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);

    ll n, x, m, a1; cin >> n >> x >> m;

    ll t1 = 0, t2 = n, s = 0;
    a1 = x;
    pfx[1] = a1;
    mp[a1] = 1;
    for(int i = 2; i <= n; i++){
        ll r = (a1 * a1) % m;
        if(mp.count(r)){
            t1 = mp[r];
            t2 = i;
            break;
        }
        mp[r] = i;
        a1 = r;
        pfx[i] = r;
    }
    for(int i = 0; i < t1; i++) s += pfx[i], pfx[i] = 0;
    for(int i = 1; i <= t2; i++) pfx[i] += pfx[i - 1];

    if(t1 == 0) return cout << pfx[n], 0;

    ll p = t2 - t1;
    ll pt = (n + 1 - t1) / p;
    ll sum = pt * (pfx[t2 - 1] - pfx[t1 - 1]);
    if((n + 1 - t1) % p){
        ll sp = (n - t1) % p;
        sum += pfx[t1 + sp] - pfx[t1 - 1];
    }
    cout << sum + s;
    return 0;
}


Measured memory_bytes: 5512
def selectionSort(lst, n):
    cnt = 0
    for i in range(0, n):
        minj = i
        for j in range(i, n):
            if lst[j] < lst[minj]:
                minj = j

        if i != minj:
            tmp = lst[i]
            lst[i] = lst[minj]
            lst[minj] = tmp
            cnt += 1
    return (lst, cnt)


if __name__ == "__main__":
    n = int(input())
    lst = [int(n) for n in input().split()]
    result, cnt = selectionSort(lst, n)
    print(" ".join(str(n) for n in result))
    print(cnt)

Measured memory_bytes: 7804
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); i++)
#define repr(i, n) for (int i = (int)(n) - 1; i >= 0; i--)
#define range(a) a.begin(), a.end()
using namespace std;
using ll = long long;

int main() {
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  int X, A;
  cin >> X >> A;
  cout << (X < A ? 0 : 10) << endl;
}


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

double dist(pair<int, int>& p1, pair<int, int>& p2)
{
    double difx = p1.first - p2.first;
    double dify = p1.second - p2.second;
    return sqrt(difx*difx + dify*dify);
}

int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    int N;
    cin >> N;
    vector<pair<int, int>> P(N);
    for(int i=0; i<N; i++)
    {
        int a, b;
        cin >> a >> b;
        P[i] = make_pair(a, b);
    }

    sort(P.begin(), P.end());
    double all = 0;
    do
    {
        double sum = 0;
        for(int i=1; i<N; i++)
        {
            sum += dist(P[i], P[i-1]);
        }
        all += sum;
    } while (next_permutation(P.begin(), P.end()));
    for(int i=1; i<=N; i++)
    {
        all /= i;
    }
    cout << fixed << setprecision(8) << all << endl;
    

    return 0;
}


Measured memory_bytes: 3800
a,b = map(int, input().split())
import math

x = set(range(math.ceil(a/0.08), math.floor((a+0.99)/0.08)+1))
y = set(range(math.ceil(b/0.1), math.floor((b+0.99)/0.1)+1))
z = x.intersection(y)
print(min(z)) if z else print(-1)

Measured memory_bytes: 3060
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(std::io::BufReader::new(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)*}
    };
}

macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };

    ($next:expr, mut $var:ident : $t:tt $($r:tt)*) => {
        let mut $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

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, [ $t:tt ]) => {
        {
            let len = read_value!($next, usize);
            (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")
    };
}

#[allow(unused_imports)]
use std::cmp::{min, max};

fn main() {
    input!{
        n: usize,
        k: usize,
        v: [usize; n]
    }
    let mut s = 0;
    for i in 0..k {
        s += v[i];
    }
    let mut m = s;
    for i in k..n {
        s = s + v[i] - v[i - k];
        m = max(m, s);
    }
    println!("{}", (m + k) as f64 / 2.0);
}


Measured memory_bytes: 6396
from collections import defaultdict
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10**7)
n = int(input())
ab = []
edges = [[]for _ in range(n)]
for _ in range(n-1):
    a, b = list(map(lambda x: int(x)-1, input().split()))
    edges[a].append(b)
    edges[b].append(a)
    ab.append((a, b))

colors = defaultdict(int)


k = 1
init_v = 0
for v in range(n):
    if k < len(edges[v]):
        k = len(edges[v])
        init_v = v


def dfs(v, parent):
    palette = [i for i in range(len(edges[v])+1, 0, -1)
               if i != colors[(parent, v)]]
    for v2 in edges[v]:
        if v2 == parent:
            continue
        color = palette.pop()
        colors[(v2, v)] = color
        colors[(v, v2)] = color
        dfs(v2, v)


dfs(init_v, -1)

print(k)
for a, b in ab:
    print(colors[(a, b)])


Measured memory_bytes: 106796
#include<iostream>
using namespace std;
int DP[1010][1010];
string G[1010];
int main()
{
  int N,M;
  cin>>N>>M;
  for(int i=0;i<N;i++)
    cin>>G[i];
  DP[0][0]=1;
  for(int i=0;i<N;i++)
    for(int j=0;j<M;j++)
      if(G[i][j]=='.')
        DP[i+1][j]=(DP[i][j]+DP[i+1][j])%1000000007,
        DP[i][j+1]=(DP[i][j]+DP[i][j+1])%1000000007;
  cout<<DP[N-1][M-1]<<endl;
  return 0;
}

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

int main(){
     string S,T,U;
     int A,B;
     cin >>S>>T>>A>>B>>U;
     if (S==U){
          cout <<A-1<<" "<<B<<endl;
     }else{
          cout <<A<<" "<<B-1<<endl;
     }
}

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

template <class T>
void chmax(T &a, T b) {
  if (a < b) a = b;
}

int main() {
  int n, W;
  cin >> n >> W;
  vector<int> weight(n), value(n);
  rep(i, n) cin >> weight[i] >> value[i];

  vector<long long> dp(W + 1, 0);
  for (int i = 0; i < n; ++i) {
    for (int w = W; w >= 0; --w) {
      if (w - weight[i] >= 0) {
        chmax(dp[w], dp[w - weight[i]] + value[i]);
      }
    }
  }
  cout << dp[W] << endl;
}

Measured memory_bytes: 4044