akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#include <atcoder/all>
using namespace std;
using namespace atcoder;
#define rep2(i,m,n) for (int i = (m); i < (n); ++i)
#define rep(i,n) rep2(i,0,n)
#define debug(x) cout << x << endl;
typedef long long int ll;
typedef long double ld;
typedef pair<int, int> P;
template<typename T> struct V : vector<T> { using vector<T>::vector; };
V() -> V<int>;
V(size_t) -> V<int>;
template<typename T> V(size_t, T) -> V<T>;
template<typename T> vector<T> make_vec(size_t n, T a) { return vector<T>(n, a); }
template<typename... Ts> auto make_vec(size_t n, Ts... ts) { return vector<decltype(make_vec(ts...))>(n, make_vec(ts...)); }
template<typename T> ostream &operator<<(ostream &os, const vector<T> &v) { for (auto &e : v) os << e << ' '; return os; }
struct fast_ios { fast_ios(){ cin.tie(nullptr); ios::sync_with_stdio(false); cout << fixed << setprecision(20); }; } fast_ios_;
template<typename T> inline bool chmin(T &a, T b) { if (a > b) { a = b; return true; } return false; }
template<typename T> inline bool chmax(T &a, T b) { if (a < b) { a = b; return true; } return false; }
const int INF = 1<<30;
const ll LINF = 1LL<<61;
const ll MOD = 1000000007;
int MAX_K = 150;

int main()
{
    int n, m;
    cin >> n >> m;
    dsu d(n);
    rep(i,m)
    {
        int a, b;
        cin >> a >> b;
        --a; --b;
        d.merge(a, b);
    }
    set<int> s;
    rep(i,n)
    {
        s.insert(d.leader(i));
    }
    int ans = s.size();
    ans--;
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 7564
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) (v).begin(),(v).end()
#define fi first
#define se second
template<typename A, typename B> inline bool chmax(A &a, B b) { if (a<b) { a=b; return 1; } return 0; }
template<typename A, typename B> inline bool chmin(A &a, B b) { if (a>b) { a=b; return 1; } return 0; }
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
const ll INF = 1ll<<30;
const ll longINF = 1ll<<60;
const ll MOD = 1000000007;
const double EPS = 1e-9;
const bool debug = 0;
//---------------------------------//

// 繰り返し二乗法 x^n % mod を求める
ll mod_pow(ll x, ll n, ll mod) {
	if (n == 0) return 1;
	ll res = mod_pow(x * x % mod, n / 2, mod);
	if (n & 1) res = res * x % mod;
	
	return res;
}

 // 20^5以下階乗とその逆元(mod mod[素数])を求める
vector<ll> fact, inv;
void fact_inv(int n, ll mod) {
	fact.resize(n + 1);
	inv.resize(n + 1);
	
	fact[0] = 1;
	FOR(i, 1, n + 1) fact[i] = fact[i - 1] * i % mod;
	inv[n] = mod_pow(fact[n], mod - 2, mod);
	for (int i = n; i > 0; i--) inv[i - 1] = inv[i] * i % mod;
}

int N, K;
vector<int> g[112345];

ll dfs(int u, int par, int rank) {
	ll res = 1;
	if (rank == 0) res = K;
		
	int cnt = 0, pd = 1;
	for (int v : g[u]) {
		if (v == par) continue;
		cnt++;
		pd = pd * dfs(v, u, rank + 1) % MOD;
	}
	
	int p = 2;
	if (rank == 0) p = 1;
	if (K - p - cnt < 0) return 0;
	res = res * fact[K - p] % MOD * inv[K - p - cnt] % MOD;
	res = res * pd % MOD;
	return res;
}

int main() {
	fact_inv(112345, MOD);

	cin >> N >> K;	
	REP(i, N - 1) {
		int u, v;
		scanf("%d %d", &u, &v);
		u--; v--;
		g[u].push_back(v);
		g[v].push_back(u);
	}
	
	cout << dfs(0, -1, 0) << endl;
	
	return 0;
}

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


/*  
    
*/

void test_case(){
    //int n; cin >> n;
    
    ll n, x, m; cin >> n >> x >> m;
    ll res = x;
  
  
    n--;
    
    map< ll, ll > mp;
    
    ll cnt = 0;
    vector < ll > sum;
    while(n--){
        x = (x*x)%m;
        if(mp.count(x)){
            n++;
            int from = mp[x];
            ll curr = 0;
            for(int i = from; i < sum.size(); i++)
                curr+= sum[i];
            
            ll interval = sum.size() - from;
            res += (n/interval)*(curr);
            
            int left = (n % interval);
            for(int i = from; i < from + left; i++)
                res += sum[i];
            cout << res << endl;
            return;
        }
        mp[x] = cnt;
        sum.push_back(x);
        res += x;
        cnt++;
    }
    
    cout << res << endl;
    
}

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

    int t; t = 1;
    //cin >> t;
    while(t--)
        test_case();
    return 0;
}


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

int main(){
	int n, m, a;
	bool flag = false;
	string s, h;
	cin >> s >> h;
	n = s.size();
	m = h.size();
	for(int i = n - 1; i >= m - 1; i--){
		for(int j = 0; j < m; j++){
			string t = s.substr(i - j, 1);
			if(t == "?" || t == h.substr(m - j - 1, 1)){
				flag = true;
			}else{
				flag = false;
				break;
			}
		}
		if(flag){
			a = i;
			break;
		}
	}
	string p;
	if(flag){
		string::size_type pos(s.find("?"));
		while(pos != string::npos){
			s.replace(pos, 1, "a");
			pos = s.find("?", pos + 1);
		}
		if(a - m < 0){
			p = h + s.substr(m);
		}else if(a == n - 1){
			p = s.substr(0, a - m + 1) + h;
		}else{
			p = s.substr(0, a - m + 1) + h + s.substr(a + 1);
		}
	}else{
		p = "UNRESTORABLE";
	}
	cout << p << endl;
}

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

using ll = long long;
using ld = long double;
constexpr ll inf = static_cast<ll>(1e17);
constexpr ll mod = static_cast<ll>(1e9 + 7);

int n;
ll a[300005];
ll rlist[100005], blist[100005];
int main() {
	std::cin >> n;

	const int s = 3 * n;
	for (int i = 0; i < s; ++i)
		std::cin >> a[i];

	ll rsum = 0, bsum = 0;
	std::priority_queue<ll, std::vector<ll>, std::greater<ll>> red;
	std::priority_queue<ll> blue;
	for (int i = 0; i < n; ++i) {
		rsum += a[i];
		red.push(a[i]);

		bsum += a[s - i - 1];
		blue.push(a[s - i - 1]);
	}

	rlist[0] = rsum;
	blist[0] = bsum;
	for (int i = n, end = 2 * n; i < end; ++i) {
		auto idx = i - n + 1;

		rsum += a[i];
		red.push(a[i]);
		rsum -= red.top();
		red.pop();
		rlist[idx] = rsum;

		bsum += a[s - i - 1];
		blue.push(a[s - i - 1]);
		bsum -= blue.top();
		blue.pop();
		blist[idx] = bsum;
	}

	ll sum = -inf;
	for (int i = 0; i <= n; ++i)
		sum = std::max(sum, rlist[i] - blist[n - i]);

	std::cout << sum << std::endl;
	return 0;
}


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

#define FOR(i,l,r) for(int i = (int) (l);i < (int) (r);i++)
template<typename T> bool chmax(T& a,const T& b){ return a < b ? (a = b,true) : false; }
template<typename T> bool chmin(T& a,const T& b){ return b < a ? (a = b,true) : false; }
typedef long long ll;

int N;
ll K;
vector<ll> A;
ll acc [200001];
unordered_map<ll,ll> mp;
ll BIT [200001];

void update(int id)
{
	for(;id <= N;id += id & -id) BIT [id]++;
}

ll getSum(int id)
{
	ll res = 0;
	for(;id;id -= id & -id) res += BIT [id];
	return res;
}

int main()
{
	scanf("%d%lld",&N,&K);
	A.assign(N,0);
	FOR(i,0,N){
		scanf("%lld",&A [i]);
		A [i] -= K;
		acc [i + 1] = acc [i] + A [i];
	}
	vector<ll> B(acc,acc + N + 1);
	sort(B.begin(),B.end());
	B.erase(unique(B.begin(),B.end()),B.end());
	FOR(i,0,B.size()){
		mp [B [i]] = i + 1;
	}

	ll ans = 0;
	for(int i = N - 1;i >= 0;i--){
		update(mp [acc [i + 1]]);
		ans += (N - i) - getSum(mp [acc [i]] - 1);
	}
	printf("%lld\n",ans);

	return 0;
}


Measured memory_bytes: 14792
#include<iostream>
#include<cstdio>
#include<cstring>
#include<string>
#include<algorithm>
#include<bitset>
#include<vector>
#include<deque>
#include<queue>
#include<map>
#include<set>
#include<stack>
#include<cmath>
#include<iomanip>
#include <functional>
using namespace std;
typedef long long ll;
const int mod = 1000000007;
const int INF = 1 << 30;
const double EPS = 1e-10;
//cout << fixed << std::setprecision(9)
//memset(a, 0, sizeof(a));
//--------------------------

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

	cout << n * n - a << endl;

	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
typedef long long int ll;
typedef unsigned long long int ull;
#define BIG_NUM 2000000000
#define HUGE_NUM 1000000000000000000
#define MOD 1000000007
#define EPS 0.000000001
using namespace std;




int main(){

	ll N;
	scanf("%lld",&N);

	if(N%2 == 1){

		printf("0\n");

	}else{

		ll S = 10;
		ll ans = 0;

		while(S <= N){

			ans += N/S;

			S *= 5;
		}

		printf("%lld\n",ans);
	}

	return 0;
}


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

int main(void){
	int N,M;
	while(cin>>N>>M,N|M){
		vector<int> h(N),w(M);
		rep(i,N)cin>>h[i];
		rep(i,M)cin>>w[i];
		map<int,int> cntH,cntW;
		rep(i,N){
			int sum=0;
			rep(j,N)if(i<=j){
				sum+=h[j];
				cntH[sum]++;
			}
		}
		rep(i,M){
			int sum=0;
			rep(j,M)if(i<=j){
				sum+=w[j];
				cntW[sum]++;
			}
		}
		int res=0;
		for(auto itH:cntH){
			int H=itH.first;
			res += cntH[H]*cntW[H];
		}
		cout<<res<<endl;
	}
	return 0;
}

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

#define REP(i,n) for(ll i=0; i<(ll)(n); i++)
#define FOR(i,n,m) for (ll i=n; i<(ll)(m); i++)
#define pb push_back
#define INF 1000000007LL
#define all(a) (a).begin(),(a).end()

typedef long long ll;
typedef pair<int,int> p;

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

string s;
int N;
int main(){
    ios::sync_with_stdio(false);
    cin >> s;
    N = s.length();
    
    int right = 0;
    if (N==2) {
        if (s[0]==s[1]) {
            cout << "1 2" << endl;
            return 0;
        }
    }
    REP(i,N-2) {
        string tmp = s.substr(i,3);
        int cnt[26];
        fill(cnt, cnt+26, 0);
        REP(j,3) {
            char x = tmp[j];
            cnt[x-'a']++;
            if(cnt[x -'a']>=2) {
                cout << i+1 << " " << i+3 << endl;
                return 0;
            }
        }
    }
    
    cout << "-1 -1" << endl;
    return 0;
}

Measured memory_bytes: 512
void throwdice_N(int x[6]){
    int tmp;
    tmp = x[0];
    x[0] = x[1];
    x[1] = x[5];
    x[5] = x[4];
    x[4] = tmp;
}
void throwdice_E(int x[6]){
    int tmp;
    tmp = x[0];
    x[0] = x[3];
    x[3] = x[5];
    x[5] = x[2];
    x[2] = tmp;
}
void throwdice_S(int x[6]){
    int tmp;
    tmp = x[0];
    x[0] = x[4];
    x[4] = x[5];
    x[5] = x[1];
    x[1] = tmp;
}
void throwdice_W(int x[6]){
    int tmp;
    tmp = x[0];
    x[0] = x[2];
    x[2] = x[5];
    x[5] = x[3];
    x[3] = tmp;
}
 
#include <stdio.h>
int main(int argc, const char * argv[]) {
    int i, j, top, front, left, right, back, bottom, count=0, count1=0, count2=0, n=0;
    int top2, front2, left2, right2, back2, bottom2;
    int x[6], x2[6];
    int C=0;
     
    scanf("%d", &n);
     
    for(i=0; i<6; i++) {
        scanf("%d",&x[i]);
    }
    back = x[4];
    top = x[0];
    right = x[2];
    left = x[3];
    bottom = x[5];
    front =x[1];
     
    for(j=0; j<n-1; j++){
         
        for(i=0; i<6; i++) {
            scanf("%d",&x2[i]);
        }
        back2 = x2[4];
        top2 = x2[0];
        right2 = x2[2];
        left2 = x2[3];
        bottom2 = x2[5];
        front2 =x2[1];
         
        while (x2[1] != front) {
             
            if((x2[1] != back) &&
               (x2[1] != top) &&
               (x2[1] != right) &&
               (x2[1] != left) &&
               (x2[1] != bottom) &&
               (x2[1] != front) ){
                count++;
                break;
            }
             
            if (x2[2] == front || x2[3] == front) {
                throwdice_E(x2);
            }
            throwdice_N(x2);
        }
        while(x2[5] != bottom){
            if((x2[5] != back) &&
               (x2[5] != top) &&
               (x2[5] != right) &&
               (x2[5] != left) &&
               (x2[5] != bottom) &&
               (x2[5] != front) ){
                count1++;
                break;
            }
            if(0 < count) break;
            throwdice_E(x2);
            C++;
            if(C >= 4)break;
        }
        C=0;
        while (x2[0] != top) {
            if((x2[0] != back) &&
               (x2[0] != top) &&
               (x2[0] != right) &&
               (x2[0] != left) &&
               (x2[0] != bottom) &&
               (x2[0] != front) ){
                break;
            }
            if(0 < count) break;
            if(0 < count1) break;
            throwdice_E(x2);
            C++;
            if(C >= 4)break;
        }
         
        back2 = x2[4];
        top2 = x2[0];
        right2 = x2[2];
        left2 = x2[3];
        bottom2 = x2[5];
        front2 =x2[1];
         
        if(back == back2 &&
           top == top2 &&
           right == right2 &&
           left == left2 &&
           bottom == bottom2 &&
           front == front2){
            count2++;
        }
    }
    if(count2 == 0 ){
        printf("Yes\n");
    }else{
        printf("No\n");
    }
     
    return 0;
}


Measured memory_bytes: 2104
import queue
def dijkstra(n,EdgeMatrix,start):

    NodeList=queue.PriorityQueue() #探索対象の頂点
    Distance=[float('inf')]*n #頂点0からの最短経路
    used=[False]*n #頂点の使用情報

    Distance[start]=0 #0から0までの距離は0
    used[start]=True #0から探索を始める
    LastNode=start #最新の頂点
    NodeList.put([0,start])
    Flag=True #探索対象がなくなるとFalse
    
    while Flag:
        Flag=False
        for i in range(len(EdgeMatrix[LastNode])):
            #探索していない頂点へ距離の短い辺があればキューに追加
            Edge=EdgeMatrix[LastNode][i]
            if used[Edge[0]]==False and Distance[Edge[0]]>Distance[LastNode]+Edge[1]:
                    Distance[Edge[0]]=Distance[LastNode]+Edge[1]
                    NodeList.put([Distance[Edge[0]],Edge[0]])

        #最も近い探索していない頂点
        while not NodeList.empty():
            minNode=NodeList.get()
            if used[minNode[1]]==False:
                Flag=True
                break

        LastNode=minNode[1] #最新の頂点を更新
        used[minNode[1]]=True #頂点の使用情報を更新
    return Distance

#入力
n,m,s=map(int,input().split())

#辺の隣接リスト
EdgeMatrix=[[] for i in range(125000)]

for i in range(m):
    u,v,a,b=map(int,input().split())
    for j in range(a,2500):
        EdgeMatrix[(u-1)*2500+j].append([(v-1)*2500+j-a,b])
        EdgeMatrix[(v-1)*2500+j].append([(u-1)*2500+j-a,b])

for i in range(n):
    c,d=map(int,input().split())
    for j in range(2450):
        EdgeMatrix[i*2500+j].append([min(i*2500+j+c,(i+1)*2500-1),d])

#for i in range(2502):
#    print(EdgeMatrix[i])
    
#頂点0からの最短経路
Distance=dijkstra(125000,EdgeMatrix,min(s,2499))

for i in range(1,n):
    print(min(Distance[i*2500:(i+1)*2500-1]))


Measured memory_bytes: 170736
#include <bits/stdc++.h>
using namespace std;
int main(){
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    map<int, int> m;
    int n;
    cin>>n;
    int * arr = new int[n-1];
    for(int i = 0 ; i< n-1 ; i++){
        cin>>arr[i];
        m[arr[i]]++;
    }


    for(int i = 0 ; i < n ; i ++){
        cout<<m[i+1]<<endl;
    }



}

Measured memory_bytes: 13804
import java.util.*;
 
public class Main {
 
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int a=sc.nextInt();
        int b=sc.nextInt();
        if(a==b){
            System.out.println("Draw");
        }else if(a==1){
            System.out.println("Alice");
        }else if(b==1){
            System.out.println("Bob");
        }else if(a>b){
            System.out.println("Alice");
        }else{
            System.out.println("Bob");
        }
    }
}

Measured memory_bytes: 23764
/*
	Created by Faisal Ahmed
*/

#include <bits/stdc++.h>
 
using namespace std;
 
typedef long long int ll;
typedef long double ld;

int temp[200010];

int main()
{
	ios_base::sync_with_stdio(0);
	cin.tie(0);cout.tie(NULL);
	
	int a, b;
	
	cin >> a >> b;
	
	cout << 6 - a - b << endl;
	
	return 0;
} 

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

int main() {
	long long n, now, sum = 0;
	cin >> n;
	now = n;
	while(now > 0) {
		sum += now % 10;
		now /= 10;
	}
	if(n % sum) puts("No");
	else puts("Yes");
}

Measured memory_bytes: 256
N, P = map(int, input().split())

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

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

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

    return arr

a = factorization(P)
a.sort()

res = 1
for a1, a2 in a:
    if a2 >= N:
        res *= a1 ** (a2 // N)

print(res)


Measured memory_bytes: 3064
#include<stdio.h>
#include<string.h>
int main()
{
  char s[100];
  scanf("%s",s);
  int n[100];
  for(int i=0;i<26;i++)
    n[i]=0;
  for(int i=0;i<strlen(s);i++)
  {
    if(n[s[i]-'a']>0)
    {
      printf("no\n");
      return 0;
    }
    n[s[i]-'a']++;
  }
  printf("yes\n");
  return 0;
}

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

using namespace std;

#define rep(i, n) for (int i = 0; i < (int)n; ++i)
#define FOR(i, a, b) for (int i = a; i < (int)b; ++i)
#define rrep(i, n) for (int i = ((int)n - 1); i >= 0; --i)

using ll = long long;
using ld = long double;

const ll INF = 1e18;
const int Inf = 1e9;
const double EPS = 1e-9;
const ll MOD = 1e9 + 7;

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(0);
	ll d, t, s;
	cin >> d >> t >> s;
	cout << (d <= t * s ? "Yes" : "No") << endl;
    
    return 0;
}


Measured memory_bytes: 3640
n = int(input())
max_f = int(n / 4)
max_s = int(n / 7)
switch = 0
for i in range(max_s + 1):
    for j in range(max_f + 1):
        if (7 * i + 4 * j) == n:
            switch = 1
if switch == 1:
    print("Yes")
else:
    print("No")

Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std;
using Int = long long;
//INSERT ABOVE HERE
signed main(){
  string s;
  Int w;
  cin>>s>>w;
  string t;
  for(Int i=0;i<(Int)s.size();i+=w) t+=s[i];
  cout<<t<<endl;
  return 0;
}


Measured memory_bytes: 256
n=int(input())
a=list(map(int,input().split()))
a.sort()
ans=[0,0,0,0,0,0,0,0,0]
for i in range(n):
    if a[i]<400:
        ans[0]=1
    if 400<=a[i]<800:
        ans[1]=1
    if 800<=a[i]<1200:
        ans[2]=1
    if 1200<=a[i]<1600:
        ans[3]=1
    if 1600<=a[i]<2000:
        ans[4]=1
    if 2000<=a[i]<2400:
        ans[5]=1
    if 2400<=a[i]<2800:
        ans[6]=1
    if 2800<=a[i]<3200:
        ans[7]=1
    if 3200<=a[i]:
        ans[8]+=1
cnt=0
for i in range(8):
    if ans[i]!=0:
        cnt+=1
cnt2=cnt
if ans[8]!=0:
    cnt2=cnt+ans[8]
print(max(1,cnt),cnt2)


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

using namespace std;

typedef long long int ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<int,int> pt;
typedef pair<ll,ll> pll;

#define Max 1000001
#define intinf 2147483647
#define longlonginf 9223372036854775807
#define MOD 998244353
#define MOD2 1000000007
#define fastio ios_base::sync_with_stdio(false),cin.tie(NULL),cout.tie(NULL)
#define vint vector<int>
#define vll vector<long long>
#define endl '\n'
#define fi first
#define se second
#define pb push_back
#define F(i,n) for(int i = 0;i<n;i++)
#define Fr(i,l,r) for(int i = l;i <= r;i++)
#define rF(i,n) for(int i = n-1;i>=0;i--)
#define all(arr) arr.begin(),arr.end()


ll Lpow(ll a,ll b)
{
    ll ans = 1;
    while(b > 0)
    {
        if(b%2)
            ans = (ans*a);
        a = (a*a);
        b = b/2;
    }
    return ans;
}

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

ll dp[3005][3005];
ll arr[3005];

ll recur(int i,int j,int t)
{
    if(i == j)
    {
        if(t == 0)
            return arr[i];
        else
            return -1*arr[i];
    }
    if(t == 0)
    {
        if(dp[i][j] != 0)
            return dp[i][j];
        else
        {
            ll one = arr[i] + recur(i+1, j, (t+1)%2);
            ll two = arr[j] + recur(i, j-1, (t+1)%2);
            
            dp[i][j] = max(one,two);
            return dp[i][j];
        }
    }
    if(t == 1)
    {
        if(dp[i][j] != 0)
            return dp[i][j];
        else
        {
            ll one = recur(i + 1, j, (t + 1)%2) - arr[i];
            ll two = recur(i, j - 1, (t + 1)%2) - arr[j];
            
            dp[i][j] = min(one,two);
            return dp[i][j];
        }
    }
    
    return -1;
}

signed main()
{
    fastio;
//    cout.flush();
    
    int n;
    cin >> n;
    
    F(i,n)
    cin >> arr[i];
    
    ll ans = recur(0, n-1, 0);
    
    cout << ans << endl;
    
    return 0;
}


Measured memory_bytes: 70144
h,w = map(int, input().split())
ab = [list(map(int, input().split())) for _ in range(h)]

res = []
temp = 0

for i in range(h):
    for j in range(w-1):
        if ab[i][j] % 2 ==0:
            pass
        else:
            ab[i][j] -=1
            ab[i][j+1] += 1
            temp +=1
            res.append(str(i+1)+" "+str(j+1)+" "+str(i+1)+" "+str(j+2))

for k in range(h-1):
    if ab[k][w-1] % 2 ==0:
        pass
    else:
        ab[k][w-1] -=1
        ab[k+1][w-1] +=1
        temp +=1
        res.append(str(k+1)+" "+str(w)+" "+str(k+2)+" "+str(w))
                
print(temp)
for i in range(temp):
    print(res[i])

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

int main(){
  string s,t;
  cin>>s>>t;
  sort(s.begin(),s.end());
  sort(t.begin(),t.end());
  reverse(t.begin(),t.end());
  if(s<t)cout<<"Yes"<<endl;
  else cout<<"No"<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define all(x) begin(x), end(x)
#define dbg(x) cerr << #x << " = " << x << endl
#define _ << ' ' <<
using namespace std;
using ll = long long;
using vi = vector<int>;


int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n, y;
    cin >> n >> y;
    y /= 1000;
    for (int a = 0; a <= n; ++a)
        for (int b = 0; b <= n - a; ++b)
            if (a + 5 * b + (n - a - b) * 10 == y)
                return cout << n - a - b << ' ' << b << ' ' << a, 0;
    cout << "-1 -1 -1";
}


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

int main(){
    ll n;
    cin >> n;
    vector<int> j(4);
    vector<string> ju = {"AC","WA","TLE","RE"};
    rep(i,n){
        string s;
        cin >> s;
        if(s == "AC"){
            j.at(0)++;
        }else if(s == "WA"){
            j.at(1)++;
        }else if(s == "TLE"){
            j.at(2)++;
        }else{
            j.at(3)++;
        }
    }
    rep(i,4){
        cout << ju.at(i) << " " << "x" << " " << j.at(i) << endl;
    }
}

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

#define ll long long
#define vi vector<int>
#define vl vector<long long>
#define pb push_back
#define si set<int>
#define sl set<long long>
#define pq prioirty_queue
#define all(v) v.begin(),v.end()
#define left (2*idx)+1
#define right (2*idx)+2
#define FIO ios_base::sync_with_stdio(false);cin.tie(NULL);

const ll N = (ll)(1e5);
const ll MOD = (ll)(1e9 + 7);

int main()
{
    FIO;
    
    string s, t;
    cin >> s >> t;

    map<char, vector<long long>> m;
    long long ans = 0;
    long long prev = -1;

    for(int i=0; i<s.length(); i++)
    {
        m[s[i]].push_back(i+1);
    }

    for(auto ch : t)
    {
        if(m[ch].size() == 0)
        {
            cout << -1 << "\n";
            return 0;
        }
        vector<long long> :: iterator it = upper_bound(m[ch].begin(), m[ch].end(), prev);
        if(it == m[ch].end())
        {
            ans+=1;
            prev = *(m[ch].begin());
        }
        else
        {
            prev = *(it);
        }
    }

    cout << (ans * s.size()) + prev << "\n";
    return 0;
}


Measured memory_bytes: 1736
//https://codeforces.com/contest/1334/problem/A
//BROWNIE TK

#include <bits/stdc++.h>
using namespace std;

typedef long long int lli;
typedef unsigned long long int ulli;
typedef long double ldb;

#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;

#define pb push_back
#define popb pop_back()
#define pf push_front
#define popf pop_front()

#define si size()
#define be begin()
#define en end()
#define all(v) v.be, v.en

#define le length()
#define mp make_pair
#define mt make_tuple
#define acc(v) accumulate(all(v), 0)
#define F first
#define S second

#define pll pair<lli, lli>
#define pii pair<int, int>
#define pil pair<int, lli>

#define forz(i, n) for (int i = 0; i < n; i++)
#define fore(i, m, n) for (int i = m; i <= n; i++)
#define rforz(i, n) for (int i = n - 1; i >= 0; i--)
#define rfore(i, m, n) for (int i = n; i >= m; i--)

#define deci(n) fixed << setprecision(n)
#define high(n) __builtin_popcount(n)
#define highll(n) __builtin_popcountll(n)
#define parity(n) __builtin_parity(n)
#define ctz(n) __builtin_ctz(n)

#define bset(a, p) ((a) | (1ll << (p)))
#define bchk(a, p) ((a) & (1ll << (p)))
#define bxor(a, p) ((a) ^ (1ll << (p)));
#define brem(a, p) (bchk(a, p) ? (bxor(a, p)) : (a))
/*SOME BITMASK KNOWLEDGE
1)x & (x - 1):sets the last one bit of x to zero
power of two exactly when x & (x − 1) = 0.
2)x & -x:sets all the one bits to zero, except last one bit
3)x | (x - 1):inverts all the bits after the last one bit*/

#define lb lower_bound
#define ub upper_bound
#define er equal_range

#define findnot find_first_not_of

#define maxe *max_element
#define mine *min_element

#define mod2 1000000007
#define mod 998244353
#define gcd __gcd
#define kira ios::sync_with_stdio(0), cin.tie(0), cout.tie(0)

#define endl "\n"
#define p0(a) cout << a << " "
#define p1(a) cout << a << endl
#define p2(a, b) cout << a << " " << b << endl
#define p3(a, b, c) cout << a << " " << b << " " << c << endl
#define p4(a, b, c, d) cout << a << " " << b << " " << c << " " << d << endl

#define oset tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update>
#define osetlli tree<lli, null_type, less<lli>, rb_tree_tag, tree_order_statistics_node_update>
//member functions :
//1. order_of_key(k) : number of elements sbtriectly lesser than k
//2. find_by_order(k) : k-th element in the set
#define ofk order_of_key
#define fbo find_by_order

/*STD funcions*/
lli power(lli x, lli y, lli p)
{
    lli res = 1;
    x = x % p;
    while (y > 0)
    {
        if (y & 1)
            res = (res * x) % p;
        y = y >> 1;
        x = (x * x) % p;
    }
    return res;
}
lli modi(lli a, lli m) { return power(a, m - 2, m); }
/*CODE BEGINS*/

int main()
{
    kira;
    lli n;
    cin>>n;
    lli a[n],b[n],c[n-1];
    lli sum=0;
    forz(i,n)
    {
        cin>>a[i];
    }
    forz(i,n)
    {
        cin>>b[i];
        sum+=b[i];
    }
    forz(i,n-1)
    {
        cin>>c[i];
    }
    forz(i,n-1)
    {
        if(a[i+1]==a[i]+1)
        {
            sum+=c[a[i]-1];
        }
    }
    p1(sum);
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
using namespace std;         //  名前空間指定

int calc_cost(int x, int y){
  return (x-y)*(x-y);
}

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

  int min_a = a[0];
  int max_a = a[0];
  for (int i=1; i<N; ++i){
    if (min_a > a[i]){
      min_a = a[i];
    }
    if (max_a < a[i]){
      max_a = a[i];
    }
  }
  
  int min_cost = calc_cost(-100, 100)*100;
  for (int i=min_a; i<=max_a; ++i){
    int tmp_cost = 0;
    for (int j=0; j<N; j++){
      tmp_cost += calc_cost(a[j], i);
    }
    if (tmp_cost < min_cost){
      min_cost = tmp_cost;
    }
  }
  
  cout << min_cost << endl;
}


Measured memory_bytes: 256
Aa,Bb,Cc=input().split()
A=int(Aa)
B=int(Bb)
C=int(Cc)
count=0
kazu=min(A,B)
S=[]
for i in range(1,kazu+1):
    if A%i==0 and B%i==0:
        S.append(i)
S.reverse()
print(S[C-1])
    

Measured memory_bytes: 3060
s = gets.chomp
MASTER_LIKE = 753
min_diff = 999
(s.length-2).times do |i|
	try = s[i,3].to_i
	tmp_diff = (MASTER_LIKE - try).abs
	if (tmp_diff < min_diff)
		min_diff = tmp_diff
	end
end
puts min_diff

Measured memory_bytes: 1788
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using edge = struct{int to;ll cost;};
const int limit = 100000+10;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
vector<edge>tree[limit];
ll depth[limit];

void dfs(int v,int p,ll d){
  depth[v] = d;
  for(auto &e:tree[v]){
    if(e.to == p) continue;
    dfs(e.to,v,d+e.cost);
  }
}

int main() {
  int n;
  cin >> n;
  rep(i,n-1){
    int a,b,c;
    cin >> a >> b >> c;
    a--;b--;
    tree[a].push_back({b,c});
    tree[b].push_back({a,c});
  }
  int q,k;
  cin >> q >> k;
  k--;
  dfs(k,-1,0);
  rep(i,q){
    int x,y;
    cin >> x >> y;
    x--;y--;
    cout << depth[x]+depth[y] << endl;
  }
}


Measured memory_bytes: 14336
#include <iostream>
#include <cstdio>

using namespace std;

int main()
{
	int x, y;
	int remainder;
	int ans;
	cin >> x >> y;
	if (x<y) {
		int t = x;
		x = y;
		y = t;
	}
	remainder = x % y;
	if (x == y) cout << x << endl;
	else{
		for (int i = 1; i <= remainder; i++) {
			if (remainder%i == 0) {
				if (y%i == 0) ans = i;
			}
		}
		cout << ans << endl;
	}
}


Measured memory_bytes: 3100
#include <iostream>
#include <cstring>
using namespace std;
int main(){
string day;string s[7]={"SUN", "MON", "TUE", "WED", "THU", "FRI","SAT"};
int daycounter;
cin >> day;
for(int i=0;i<7;i++){
    if(day == s[i]){
        daycounter=7-i;
    }
}cout << daycounter;
return 0;}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
#define rep(i, n) for (int i = (int)(0); i < (int)(n); ++i)
#define reps(i, n) for (int i = (int)(1); i <= (int)(n); ++i)
#define SORT(v, n) sort(v, v + n);
#define vsort(v) sort(v.begin(), v.end());
#define coutd(d) cout<<std::setprecision(10)<<d<<endl;
#define cinline(n) getline(cin,n);
#define PI (acos(-1))
 
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using pii = pair<int, int>;
 
const int MOD = 1e9+7;
const int INF = 1001001001;
const ll LINF = 1e18;
 
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

int odd[100005];
int even[100005];

signed main()
{
  int n; cin>>n;
  vi v(n);
  rep(i,n) cin>>v[i];
  map<int,int> mOdd;
  map<int,int> mEven;
  int oddCnt=0;
  int evenCnt=0;
  int a,b;
  rep(i,n){
    if(i%2){
      odd[v[i]]++;
      if(chmax(oddCnt,odd[v[i]])){
        a=v[i];
      }
    }else{
      even[v[i]]++;
      if(chmax(evenCnt,even[v[i]])){
        b=v[i];
      }
    }
  }
  if(a==b){
    int amax=0;
    int bmax=0;
    rep(i,100005){
      if(i==a)continue;
      chmax(amax,odd[i]);
      chmax(bmax,even[i]);
    }
    if(amax>bmax){
      oddCnt=amax;
    }else{
      evenCnt=bmax;
    }
  }
  int ans=(n/2-evenCnt)+(n/2-oddCnt);
  cout<<ans<<endl;
}


Measured memory_bytes: 1408
#pragma GCC optimize("Ofast")
#define _USE_MATH_DEFINES
#include "bits/stdc++.h"

using namespace std;

using u8 = uint8_t;
using u16 = uint16_t;
using u32 = uint32_t;
using u64 = uint64_t;
using i32 = int32_t;
using i64 = int64_t;
constexpr char newl = '\n';

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; }
#define FOR(i,a,b) for (int i = (a); i < (b); i++)
#define F0R(i,b) FOR(i,0,b)
#define RFO(i,a,b) for (int i = ((b)-1); i >=(a); i--)
#define RF0(i,b) RFO(i,0,b)
//#define F first
//#define S second
#define debug(x) cout << #x << ": " << x << '\n';

#if 1


// INSERT ABOVE HERE
signed main() {
  cin.tie(0);
  ios_base::sync_with_stdio(false);

  int K, A, B;
  cin >> K >> A >> B;

  bool result = false;
  FOR(i, A, B + 1) {
    if (i % K == 0) {
      result = true;
      break;
    }
  }

  cout << (result ? "OK" : "NG");
}
#endif


Measured memory_bytes: 3640
#include <bits/stdc++.h>
using namespace std;
const int MAX = 25;
struct Ghjattu{
    int B;
    int C;
}G[MAX];
int A[MAX];
int main(){
    int n;
    while(cin>>n){
        for(int i=1;i<=n;i++)
            cin>>A[i];
        for(int i=1;i<=n;i++)
            cin>>G[i].B;
        for(int i=1;i<n;i++)
            cin>>G[i].C;
        int ans=0;
        for(int i=1;i<=n;i++){
            ans+=G[A[i]].B;
            if(i==1) continue;
            if(A[i]-A[i-1]==1)
                ans+=G[A[i-1]].C;
        }
        printf("%d\n", ans);
    }
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<map>
#include<cstdio>
#include<string>
#include<cstring>
 
using namespace std;
 
int main(void){
  int n;
  string s;
  map<string,int>mp;
 
  while(cin >> n,n){
    mp.clear();
    cin.ignore();
    while(n--){
      getline(cin,s);
      string temp;
      for(int i=0;i<s.size();i++){
    if(s[i]==' '){
      mp[temp]++;
      temp.clear();
      i++;
    }
    else if(i==s.size()-1){
      temp+=s[i];
      mp[temp]++;
      temp.clear();
      i++;
    }
    temp+=s[i];
      }
    }
    char ch;
    cin >> ch;
    int mx=0;
 
    int cnt=0;
  
      for(map<string,int>::iterator i=mp.begin();i!=mp.end();i++){
    string tmp=i->first;
    if(tmp[0]==ch)cnt++;
      }
 
      if(cnt==0){
    cout << "NA" << endl;
    continue;
      }
 
      cnt = cnt>5?5:cnt;
    while(cnt--){
      mx=0;
      for(map<string,int>::iterator i=mp.begin();i!=mp.end();i++){
    string t=i->first;
    if(t[0]==ch)mx=max(i->second,mx);
      }
       
      for(map<string,int>::iterator it=mp.begin();it!=mp.end();it++){
     
     
    string tmp=it->first;
    if(it->second==mx && tmp[0]==ch){
      cout << it->first;
      if(cnt==0)cout << endl;
      else cout << " ";
      it->second=-1;
      break;
    }
      }
    }
  }
   
  return 0;
}

Measured memory_bytes: 940
import java.util.Scanner;

public class Main {

	static long[] ans;
	static boolean[] seen;

	public static void main(String[] args) {
		Scanner in = new Scanner(System.in);
		int K = in.nextInt();
		int A = in.nextInt();
		int B = in.nextInt();
		int money = 0;
		long ans = 1;
		while (K > 0) {
			if (money > 0 && A < B) {
				money--;
				ans += B;
			} else if (K > 1 && ans >= A && A < B && (B - A > 1)) {
				money++;
				ans -= A;
			} else {
				ans++;
			}
			K--;
		}
		System.out.println(ans);
		in.close();
	}
}

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

def solve(N):
    s = ''
    if N==0:
        s += '0'
    elif N==1:
        s += '1'
    else:
        if N%2==0:
            s += '0'
            s += solve(int(N / (-2)))
        else:
            s += '1'
            s += solve(int((N - 1) / (-2)))
    return s

print(solve(N)[::-1])


Measured memory_bytes: 38256
#include <bits/stdc++.h>
using namespace std;
const int N=1e5+5;
int a[N];
int main()
{
    int n;
    cin>>n;
    long long ans=0;
    for(int i=1;i<=n;i++)
    {
        cin>>a[i];
    }
    for(int i=1;i<=n;i++)
    {
        for(int j=1;j<=n;j++)
            if(i!=j)
            ans+=a[i]*a[j];
    }
    cout<<ans/2<<endl;
    //cout << "Hello world!" << endl;
    return 0;
}


Measured memory_bytes: 256
import collections

n = int(input())
v = [int(i) for i in input().split()] 

odd=v[1::2]
even=v[::2]

if len(collections.Counter(v))==1:
    max_eq = max(len(odd),len(even))
    print(n - max_eq)
    exit()

odd_most = collections.Counter(odd).most_common(2)
even_most = collections.Counter(even).most_common(2)

max_count=0
for odd_top in odd_most:
    for even_top in even_most:
        if odd_top[0] == even_top[0]:
            continue
        max_count = max(max_count,odd_top[1]+even_top[1])
print(n-max_count)

Measured memory_bytes: 20576
import sys

read = sys.stdin.read
readline = sys.stdin.readline
readlines = sys.stdin.readlines
sys.setrecursionlimit(10 ** 9)
INF = 1 << 60
MOD = 1000000007


def main():
    D, T, S = map(int, readline().split())
    
    if D / S <= T:
        print('Yes')
    else:
        print('No')
    
    return


if __name__ == '__main__':
    main()


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

int main(){
    int a, b;
    cin >> a >> b;
    string s, t;
    s = to_string(a);
    rep(i,b){
        t+=s;
    }
    string x, y;
    x = to_string(b);
    rep(i,a){
        y+=x;
    }
    if(y>=t) cout << t << endl;
    else cout << y << endl;

    return 0;
}

Measured memory_bytes: 256
if __name__ == '__main__':
    _n = input()
    n = int(_n)

    songs = [("", 0)] * n
    for i in range(n):
        inp = input().split()
        songs[i] = (inp[0], int(inp[1]))

    x = input()

    start = 0

    for i in range(0, len(songs)):
        s, _ = songs[i]
        if s == x:
            start = i + 1
            break

    res = 0
    for i in range(start, len(songs)):
        _, t = songs[i]
        res += t

    print(res)


Measured memory_bytes: 3064
#include <stdio.h>
#include <math.h>

double area(int a, int b, double radians)
{
  return (a * b * sin(radians)) / 2;
}

double circum(int a, int b, double radians)
{
  double c = sqrt(pow(a, 2) + pow(b, 2) - 2 * a * b * cos(radians));
  return a + b + c;
}

double height(int a, int b, double radians)
{
  return sinl(radians) * b;
}

int main(void)
{
  int a, b, angle;
  double radians;
  scanf(" %d %d %d", &a, &b, &angle);
  radians = ((double) angle / 180) * M_PI;
  printf("%lf\n", area(a, b, radians));
  printf("%lf\n", circum(a, b, radians));
  printf("%lf\n", height(a, b, radians));
  return 0;
}



Measured memory_bytes: 2120
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for (int i = 0; i < (int)(n); i++)
typedef long long ll;
typedef pair<int, int> P;
const int INF = 1e9;
int main() {
  ll N;
  cin >> N;
  vector<ll> A(N);
  ll ans = 0;
  REP(i, N) { cin >> A[i]; }
  for (int i = 1; i < N; i++) {
    if (A[i - 1] % 2 == 0) continue;
    if (A[i] > 0) {
      ans++;
      A[i - 1]--, A[i]--;
    }
  }
  REP(i, N) { ans += A[i] / 2; }
  cout << ans << endl;
}

Measured memory_bytes: 4060
// #pragma GCC target("avx2")  // CPU 処理並列化
// #pragma GCC optimize("O3")  // CPU 処理並列化
// #pragma GCC optimize("unroll-loops")  // 条件処理の呼び出しを減らす
#include<stdio.h>
#include<math.h>
#include<algorithm>
#include<queue>
#include<deque>
#include<stack>
#include<string>
#include<string.h>
#include<vector>
#include<set>
#include<map>
#include<bitset>
#include<stdlib.h>
#include<cassert>
#include<time.h>
#include<bitset>
#include<numeric>
using namespace std;
const long long mod=1000000007;
const long long inf=mod*mod;
const long long d2=(mod+1)/2;
const double EPS=1e-10;
const double INF=1e+10;
const double PI=acos(-1.0);
const int C_SIZE = 3121000;
long long fact[C_SIZE];
long long finv[C_SIZE];
long long inv[C_SIZE];
long long Comb(int a,int b){
 	if(a<b||b<0)return 0;
 	return fact[a]*finv[b]%mod*finv[a-b]%mod;
}
void init_C(int n){
	fact[0]=finv[0]=inv[1]=1;
	for(int i=2;i<n;i++){
		inv[i]=(mod-(mod/i)*inv[mod%i]%mod)%mod;
	}
	for(int i=1;i<n;i++){
		fact[i]=fact[i-1]*i%mod;
		finv[i]=finv[i-1]*inv[i]%mod;
	}
}
long long pw(long long a,long long b){
	if(a<0LL)return 0;
	if(b<0LL)return 0;
	long long ret=1;
	while(b){
		if(b%2)ret=ret*a%mod;
		a=a*a%mod;
		b/=2;
	}
	return ret;
}
int ABS(int a){return max(a,-a);}
long long ABS(long long a){return max(a,-a);}
double ABS(double a){return max(a,-a);}
int sig(double r) { return (r < -EPS) ? -1 : (r > +EPS) ? +1 : 0; }
// ここから編集しろ
int UF[4100];
vector<int>s[4100];
int FIND(int a){
	if(UF[a]<0)return a;
	return UF[a]=FIND(UF[a]);
}
void UNION(int a,int b){
	a=FIND(a);b=FIND(b);if(a==b)return;
	if(UF[a]>UF[b])swap(a,b);
	UF[a]+=UF[b];UF[b]=a;
	for(int i=0;i<s[b].size();i++)s[a].push_back(s[b][i]);
	s[b].clear();
}
pair<int,pair<int,int> > edge[410000];
vector<pair<int,pair<int,int> > >v;
int neg[4100][4100];

int main(){
	int a,b;scanf("%d%d",&a,&b);
	for(int i=0;i<b;i++){
		int p,q,r;scanf("%d%d%d",&p,&q,&r);
		p--;q--;
		edge[i]=make_pair(r,make_pair(p,q));
	}
	std::sort(edge,edge+b);
	long long tmp=0;
	for(int i=0;i<a;i++)s[i].push_back(i);
	for(int i=0;i<a;i++)UF[i]=-1;
	for(int i=0;i<b;i++){
		if(FIND(edge[i].second.first)==FIND(edge[i].second.second))continue;
		for(int j=0;j<s[FIND(edge[i].second.first)].size();j++){
			for(int k=0;k<s[FIND(edge[i].second.second)].size();k++){
				neg[s[FIND(edge[i].second.first)][j]][s[FIND(edge[i].second.second)][k]]=
				neg[s[FIND(edge[i].second.second)][k]][s[FIND(edge[i].second.first)][j]]=
				edge[i].first;
			}
		}
		UNION(edge[i].second.first,edge[i].second.second);
		v.push_back(edge[i]);
		tmp+=edge[i].first;
	}
	int c;scanf("%d",&c);
	while(c--){
		int x,y;scanf("%d%d",&x,&y);x--;y--;
		if(x>y)swap(x,y);
		long long ret=tmp-neg[x][y];
		printf("%lld\n",ret);
	}
}

Measured memory_bytes: 73472
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<math.h>
#include<iomanip>
#include<set>
#include<numeric>
#include<cstring>
#include<cstdio>
#include<functional>
#include<bitset>
#include<limits.h>
#include<cassert>
#include<iterator>
#include<complex>
#include<stack>
#include<sstream>
using namespace std;
typedef  long long int lint;
typedef pair<int, int> P;
typedef pair<lint, lint> LLP;
typedef pair<char, char>CP;
#define rep(i, n) for (int i = 0; i < n; i++)
#define repr(i, n) for (int i = n; i >= 0; i--)
#define sort(v) sort((v).begin(), (v).end())
#define reverse(v) reverse((v).begin(), (v).end())
#define upper(v,hoge) upper_bound(v.begin(),v.end(),hoge)
#define lower(v,hoge) lower_bound(v.begin(),v.end(),hoge)
#define llower(v,hoge) *lower_bound(v.begin(), v.end(), hoge)
#define lupper(v,hoge) *upper_bound(v.begin(), v.end(), hoge)
/*
vector<char>al(26);
al = {'a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z'};
vector<char>AL(26);
AL = {'A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z'};
vector<char>NUM(10);
	NUM = { '0','1','2' ,'3' ,'4' ,'5' ,'6' ,'7' ,'8' ,'9' };
*/



int main() {
	int A, B;
	cin >> A >> B;
	if (A <= 5) {
		cout << 0 << endl;
	}
	else if (A <= 12) {
		cout << B / 2 << endl;
	}
	else {
		cout << B << endl;
	}
}

Measured memory_bytes: 256
use std::io;

fn read_line()-> String {
    let mut s = String::new();
    let _ = io::stdin().read_line(&mut s).unwrap();
    s.trim().to_string()
}

fn main() {
	let s = read_line();
	let s2 = s.trim().split("").collect::<Vec<&str>>();
	if s2.contains(&"a") == true && s2.contains(&"b") == true && s2.contains(&"c") == true {
		println!("Yes");
	}else{
		println!("No");
	}
}


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

int main() {
    int64_t n;
    cin >> n;
    vector<int64_t> a(n);
    for (auto& e : a) cin >> e;
    partial_sum(begin(a), end(a), begin(a));
    int64_t ans = 1e18;
    for (int64_t i = 0; i+1 < n; i++) ans = min(ans, abs((a.back() - a[i]) - a[i]));
    cout << ans << endl;
}


Measured memory_bytes: 1792
import core.bitop, std.algorithm, std.ascii, std.bigint, std.conv, std.math,
    std.functional, std.numeric, std.range, std.stdio, std.string, std.random,
    std.typecons, std.container, std.format;

// dfmt off
T lread(T = long)(){return readln.chomp.to!T();}
T[] lreads(T = long)(long n){return generate(()=>readln.chomp.to!T()).take(n).array();}
T[] aryread(T = long)(){return readln.split.to!(T[])();}
void scan(TList...)(ref TList Args){auto line = readln.split();
foreach (i, T; TList){T val = line[i].to!(T);Args[i] = val;}}
alias sread = () => readln.chomp();enum MOD = 10 ^^ 9 + 7;
alias PQueue(T, alias less = "a<b") = BinaryHeap!(Array!T, less);
// dfmt on

void main()
{
    long N = lread();
    auto f = factorize(N);
    long ans;
    foreach (key, val; f)
    {
        // writeln(key, " ", val);
        long i = 1;
        while (i * (i + 1) <= val * 2)
            i++;
        ans += i - 1;
    }
    writeln(ans);
}
/// 素因数分解
long[long] factorize(long x)
{
    assert(0 < x, "x is negative");
    long[long] ps;
    while ((x & 1) == 0)
    {
        x /= 2;
        ps[2] = (2 in ps) ? ps[2] + 1 : 1;
    }
    for (long i = 3; i * i <= x; i += 2)
        while (x % i == 0)
        {
            x /= i;
            ps[i] = (i in ps) ? ps[i] + 1 : 1;
        }
    if (x != 1)
        ps[x] = (x in ps) ? ps[x] + 1 : 1;
    return ps;
}


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

int main()
{
	int i;
	char str[1000];
	scanf("%s",str);
	for(i=0;i<strlen(str);i++)putchar((((str[i]-'A'+23)%26)+'A'));
	putchar('\n');
	return 0;
}

Measured memory_bytes: 520
#include <algorithm>
#include <iostream>
#include <string>
#include <vector>

using namespace std;

typedef long long ll;

int main(){
  ll n,w,t;
  cin >> n >> w >> t;
  ll x[n+1];
  for(int i=1;i<=n;i++) cin >> x[i];
  ll ans=0;
  for(int i=1;i<=n-1;i++){
    if((x[i+1]-x[i])*w > t){
      ans=ans+t;
    }else{
      ans=ans+(x[i+1]-x[i])*w;
    }
  }
  cout << ans << endl;
}

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

using namespace std;
#define int long long
const int MOD = 1000000007;

signed main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int a, b, c;
    cin >> a >> c;
    cin >> b >> c;
    if (a == b) {
        cout << 0 << endl;
    } else {
        cout << 1 << endl;
    }
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <stack>
#include <queue>
using namespace std;
int main(void){
    int n;
    cin>>n;
    vector<int> s(n);
    for(int i=0;i<n;i++){
        cin>>s[i];
    }
    int q;
    cin>>q;
    vector<int> t(q);
    for(int i=0;i<q;i++){
        cin>>t[i];
    }
    sort(s.begin(),s.end());
    sort(t.begin(),t.end());
    int ans=0;
    for(int i=0;i<q;i++){
        for(int j=0;j<n;j++){
            if(t[i]==s[j]){
                ans++;
                i++;
            }
        }
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 3140
N = int(input())
A = list(map(int, input().split(' ')))
temp = A

while 1:
  pick = min(temp)
  diff = list(filter(lambda x: 0 < x, map(lambda x: x % pick, temp)))

  if len(diff) == 0:
    print(pick)
    break

  diff.append(pick)
  temp = diff


Measured memory_bytes: 14224
#include <bits/stdc++.h>
#define be(v) (v).begin(),(v).end()
#define pb(q) push_back(q)
typedef long long ll;
using namespace std;
const ll mod=1000000007;
#define doublecout(a) cout<<fixed<<setprecision(10)<<a<<endl;
ll dp[3000][3000];
ll a[3000];
ll n;
bool maki[3000][3000];
ll solve(ll x,ll y){
    if(x>y)return 0;
    if(maki[x][y])return dp[x][y];
    maki[x][y]=1;
    return dp[x][y]=(((n-(y-x))&1)?max(solve(x+1,y)+a[x],solve(x,y-1)+a[y]):min(solve(x+1,y)-a[x],solve(x,y-1)-a[y]));
}
int main(){
    cin.tie(0);
    cout.tie(0);
    ios::sync_with_stdio(false);
    cin>>n;
    memset(maki,0,sizeof(maki));
    for(int i=0;i<n;i++)cin>>a[i];
    cout <<(solve(0,n-1))<<endl;
    return 0;
}


Measured memory_bytes: 78464
def nCk(n, k):
    if k == 0:
        return 1
    elif k == 1:
        return n
    elif k == 2:
        return n * (n - 1) // 2
    else:
        return n * (n - 1) * (n - 2) // 6


def solve(N, K):
    if N == 0 and K > 0:
        return 0

    if K == 0:
        return 1

    M = len(str(N))
    hd, tl = divmod(N, 10 ** (M - 1))

    res = nCk(M - 1, K) * (9 ** K)
    if hd == 0:
        return res

    res += solve(tl, K - 1)
    res += (hd - 1) * nCk(M - 1, K - 1) * (9 ** (K - 1))

    return res


N = int(input())
K = int(input())

print(solve(N, K))

Measured memory_bytes: 3064
N = int(input())
A = list(map(int, input().split()))
mx = max(A)
A.remove(mx)
ans = 10**9
ans_dist = ans
med = mx // 2

for a in A:
    if ans_dist > abs(med - a):
        ans, ans_dist = a, abs(med - a)
print(mx, ans)


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

typedef long long ll;
typedef pair<int, int> i_i;
typedef pair<ll, ll> l_l;
 
#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
//const ll mod = 1000000007;

int n;
int a[1000000];
int g1[1000000], h1[1000000];
int g, h;
int r;
int tmp;
int gcd (int c, int b) {
    if(c<b){
    tmp = c;
    c = b;
    b = tmp;
  }
    r = c % b;
  while(r!=0){
    c = b;
    b = r;
    r = c % b;
  }
  // cout << "r " << b << endl;
  return b;
}
int main() {
    cin >> n;
    for (int i=0;i<n;i++) {
        cin >> a[i];
    }
    sort (a,a+n);
    for (int i=0;i<n;i++) {
        g1[i] = gcd(a[0],a[i]);
        h1[i] = gcd(a[1],a[i]);
        // cout << h1[i] << endl;
    }
    sort(g1,g1+n);
    sort(h1,h1+n);
    g1[0] = g1[1];
    h1[0] = h1[1];
    for (int i=0;i<n;i++) {
        g1[0] = gcd(g1[0],g1[i]);
        h1[0] = gcd(h1[0],h1[i]);
    }
    g = g1[0];
    h = h1[0];
    // cout << g << " " << h << endl; 
    int ans = max(g,h);
    cout << ans << endl;
}

Measured memory_bytes: 8832