akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<cmath>
#include<queue>
#include<string>
#include<cstring>
#include<algorithm>
#include<set>
#include<map>
#include<iomanip>

#define REP(i,n) for(int i=0;i<(n);i++)
#define EPS (1e-7)
#define INF (3e9)

using namespace std;
typedef long long int ll;

int N, K;
int main(void){
    cin >> N >> K;

    double probability = 0.0;

    for(int i=1;i<=N;i++){
        int count = 0;
        if (K > i) count = ceil(log2(double(K)/i));
        probability += 1/double(N) * pow(0.5, count);
    }

    cout << setprecision(12) << probability << endl;

    return 0;
}



Measured memory_bytes: 512
import java.util.*;
 
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		
		String s = sc.next();
		int count = 0;
        int t[] = new int[s.length()];
        int t2[] = new int[s.length()];

		for (int i = 0; i < s.length(); i++) {
            t[i] = Integer.parseInt(s.substring(i, i+1));
            t2[i] = t[i];
		}

		for (int i = 1; i < s.length(); i++) {
			if (t[i] == t[i-1]) {
				if (t[i] == 0) {
					t[i] = 1;
				} else {
					t[i] = 0;
				}
				count++;
			}
        }
        
        int count2 = 0;
        if (s.length() >= 2 && t2[0] == t2[1]) {
            count2++;
            if (t2[0] == 0) {
                t2[0] = 1;
            } else {
                t2[0] = 0;
            }

            for (int i = 2; i < s.length(); i++) {
                if (t2[i] == t2[i-1]) {
                    if (t2[i] == 0) {
                        t2[i] = 1;
                    } else {
                        t2[i] = 0;
                    }

                count2++;
                }
            }
        }

        if (count2 > 0) {
            if (count < count2) {
                System.out.println(count);
            } else {
                System.out.println(count2);
            }
        } else {
            System.out.println(count);
        }
	}
}


Measured memory_bytes: 30604
import java.util.Arrays;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO Auto-generated method stub
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int[] A = new int[n];
		for(int i=0; i<n; i++) {
			A[i] = sc.nextInt();
		}
		sc.close();
		Arrays.sort(A);
		long l1 = 0;
		long l2 = 0;
		for(int i=n-1; i>=1; i--) {
			if(A[i]==A[i-1]) {
				if(l1==0) {
					l1 = A[i];
					i--;
				} else {
					l2 = A[i];
					break;
				}
			}
		}
		System.out.println(l1*l2);
	}
}


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

int main(){
  string s;
  int q;
  cin >> s >> q;
  string s1=s.substr(0,s.size()/2);
  string s2=s.substr(s.size()/2);
  bool flag = true;
  string first;
  vector<int> t(q,0);
  vector<int> f(q,0);
  vector<char> c(q);
  for(int i = 0; i < q; i++){
      cin >> t[i];
      if(t[i] == 1){
          flag = !flag;
      }else{
          cin >> f[i] >> c[i];
          if(flag){
                if(f[i] == 1){
                    
                    first.push_back(c[i]);
                    
                }else{
                    s2.push_back(c[i]);
                }
          }else{
              if(f[i] == 2){
                    
                    first.push_back(c[i]);
                    
                }else{
                    s2.push_back(c[i]);
                }
          }
      }
  } 
  
  
  
  if(flag == false){
      reverse(s1.begin(),s1.end());
      reverse(s2.begin(),s2.end());
      
      s=s2+s1+first;
  }else{
      reverse(first.begin(),first.end());
      s=first+s1+s2;
  }
  cout<<s<<endl; 
}

Measured memory_bytes: 3228
#include<bits/stdc++.h>
using namespace std;
int main(){
    string s;
    cin >> s;
    int first;
    for(int i = 0;i < s.size();i++){
        bool kl =false;
        if(s[i] == 'A'){
            first = i;
            kl =true;
        }
        if(kl) break;
    }
    int end;
    for(int i = s.size()-1;i > 0;i--){
        bool df = false;
        if(s[i] == 'Z'){
            end = i;
            df = true;
        }
        if(df) break;
    }
    cout << end - first + 1 << endl;
}


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

int main(){
    int n,m,MAX,MIN,ans(0);

    cin >> n >> m;
    int l[m],r[m];

    rep(i,m){
        cin >> l[i] >> r[i];
    }
    MAX = l[0]; MIN = r[0];

    rep(i,m){
        MAX = max(MAX,l[i]);
        MIN = min(MIN,r[i]);
    }

    ans = MIN-MAX+1;

    if(ans<0) ans=0;

    cout << ans << endl;

}

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

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

	int sum = 0;

	for (long i = 1; i <= N; i++){
		sum += i - 1;
	}



	cout << (N - 1) * N / 2;

	return 0;
}

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

signed main(){
    int N, M; cin >> N >> M;
    string s, t; cin >> s >> t;
    int L = N / __gcd(N, M) * M;
    int g = __gcd(N, M);
    for(int i = 0, j = 0; i < N; i += N / g, j += M / g){
        if(s[i] != t[j]){
            cout << -1 << endl;
            return 0;
        }
    }
    cout << L << endl;
}

Measured memory_bytes: 512
#include<iostream>
using namespace std;
int main(){
   int S,h,m,s;
   cin >> S;
   h = S / 3600;
   m = (S / 60) % 60;
   s = (S % 60);
   
   
   cout << h << ":" << m  << ":" << s << endl;
    return 0;
}

Measured memory_bytes: 1164
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
int main() {
  vector<int> a(3);
  for (int i = 0; i < 3; ++i) cin >> a[i];
  sort(a.begin(), a.end());
  if (a.back() == a[0]) cout << "Yes" << endl;
  else cout << "No" << endl;
}

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

using namespace std;
#define sqr(x) ((x)*(x))
#define cube(x) ((x)*(x)*(x))
#define GCD(a, b) (__gcd(a, b))
#define LCM(a, b) ((a)/GCD(a,b)*(b))
#define PI (3.141592653589793238462643383279502884197169399375105820974944)
#define MP make_pair
#define n1 first
#define n2 second
#define ALL(x) (x).begin(), (x).end()
#define PII pair<int,int>
#define PLL pair<ll,ll>
#define PDB pair<db,db>
#define SI set<int>
#define SL set<ll>
#define MS multiset
#define MSI multiset<int>
#define MSLL multiset<ll>
#define PB push_back
#define PF push_front
#define VI vector<int>
#define VPI vector<pair<int,int>>
#define VLL vector<ll>
#define VS vector<string>
#define SZ(x) ((int)x.size())

typedef long long ll;

typedef unsigned long long ull;
typedef long double ld;
typedef double db;
const db eps = 0.000001;
const int INF = 1000000007;
const ll LINF = 1000000000000000555;
const int N = 450555;
const int M = 1125;

void solve() {
    ll n;
    cin >> n;

    if (n % 1000 == 0) cout << 0; else
        cout << 1000 - n % 1000;


}

int main() {
    ios_base::sync_with_stdio(false);
#ifdef dxz05
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#else

#endif

    int T = 1;
    //cin >> T;

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

    return 0;
}

Measured memory_bytes: 3608
package main

import (
    "bufio"
    "fmt"
    "os"
    "strconv"
)

func main() {
    N := nextInt()
    H := make([]int, N)
    dp := make([]int, N)

    for i := 0; i < N; i++ {
        H[i] = nextInt()
    }

    dp[0] = 0
    dp[1] = abs(H[0] - H[1])
    for i := 2; i < N; i++ {
        c1 := abs(H[i-1] - H[i])
        c2 := abs(H[i-2] - H[i])
        dp[i] = min(c1 + dp[i-1], c2 + dp[i-2])
    }

    fmt.Println(dp[N-1])
}

func abs(a int) int {
    if a > 0 {
        return a
    }
    return -a
}

func min(a, b int) int {
    if a < b {
        return a
    }
    return b
}

var stdin = initStdin()

func initStdin() *bufio.Scanner {
    bufsize := 1 * 1024 * 1024 // 1 MB
    var stdin = bufio.NewScanner(os.Stdin)
    stdin.Buffer(make([]byte, bufsize), bufsize)
    stdin.Split(bufio.ScanWords)
    return stdin
}

func nextString() string {
    stdin.Scan()
    return stdin.Text()
}

func nextBytes() []byte {
    stdin.Scan()
    return stdin.Bytes()
}

func nextInt() int {
    i, _ := strconv.Atoi(nextString())
    return i
}

func nextInt64() int64 {
    i, _ := strconv.ParseInt(nextString(), 10, 64)
    return i
}


Measured memory_bytes: 3200
N, K, *A = map(int, open(0).read().split())
ls = []
n = 0
for i in range(N):
  m = A[i]
  ls.append(m)
  n = max(n,m)
  for j in range(i+1,N):
    m += A[j]
    ls.append(m)
    n = max(n,m)
s = bin(n)[2:]
L = len(s)
ans = 0
for i in range(L):
  x = L-i
  cnt = 0
  pre = []
  for l in ls:
    if l.bit_length()<x:
      continue
    j = l.bit_length()-x
    if bin(l)[2:][j]=='1':
      cnt += 1
      pre.append(l)
  if cnt>=K:
    ls = pre
    ans += 2**(x-1)
print(ans)

Measured memory_bytes: 27748
#!/usr/bin/env python3


def main():
    S = input()
    if S[0] == S[1]:
        print('Bad')
    elif S[1] == S[2]:
        print('Bad')
    elif S[2] == S[3]:
        print('Bad')
    else:
        print('Good')


if __name__ == '__main__':
    main()


Measured memory_bytes: 2940
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<int,int>;
#define enld '\n'
#define rep(i,n) for(int i=0; i<(n); i++)
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#pragma GCC optimize("Ofast")
constexpr ll INF = 1e18;
constexpr int inf = 1e9;
constexpr ll mod = 1000000007;
constexpr ll mod2 = 998244353;
const double PI = 3.1415926535897932384626433832795028841971;
const int dx[6] = {1, 0, -1, 0,1,1};
const int dy[6] = {0, 1, 0, -1,1,-1};
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; }
// ---------------------------------------------------------------------------

using pll = pair<ll,ll>;

int main(){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int N,M,s,t;
    cin >> N >> M >> s >> t;
    s--;t--;
    vector<vector<pll>> G(N);
    for(int i=0; i<M; i++){
        int a,b,c,d;
        cin >> a >> b >> c >> d;
        a--;b--;c--;
        G[a].emplace_back(b,d);
        G[a].emplace_back(c,d);
        G[b].emplace_back(a,d);
        G[b].emplace_back(c,d);
        G[c].emplace_back(a,d);
        G[c].emplace_back(b,d);
    }
    priority_queue<pll,vector<pll>,greater<pll>> que;
    vector<ll> dist(N,INF);
    que.emplace(0,s);
    dist[s] = 0;
    while(que.size()){
        int v = que.top().second;
        ll cost = que.top().first;
        que.pop();
        if(dist[v] < cost) continue;
        for(auto hoge: G[v]){
            int nv = hoge.first;
            ll ncost = hoge.second;
            if(cost+ncost < dist[nv]){
                dist[nv] = cost+ncost;
                que.emplace(dist[nv],nv);
            }
        }
    }
    cout << dist[t] << "\n";
    return 0;
}


Measured memory_bytes: 23672
#include <bits/stdc++.h>
#include <boost/range/algorithm.hpp>
#include <boost/range/numeric.hpp>
#include <boost/range/irange.hpp>
#include <boost/range/adaptor/indexed.hpp>

using namespace std;
using namespace boost::adaptors;
using namespace std::string_literals;
using ll = int64_t;
using vecint = vector<int>;
using vecll = vector<ll>;
using boost::irange;

constexpr ll MOD = 998244353;

// a^-1 mod p
ll inv(ll a,ll p){
  return ( a == 1 ? 1 : (1 - p*inv(p%a,a)) / a + p );
}

int main()
{
  ll n;
  cin>>n;
  vecll fact(n+1, 0);
  fact[0] = 1;
  for (ll i:irange(0l, n)) {
    fact[i+1] = fact[i] * (i+1) % MOD;
  }
  vecll finv(n+1, 0);
  finv.back() = inv(fact.back(), MOD);
  for (ll i=n-1; i>=0; --i) {
    finv[i] = finv[i+1] * (i+1) % MOD;
  }
  vecll pow2(n+1, 0);
  pow2[0] = 1;
  for (ll i:irange(0l, n)) {
    pow2[i+1] = 2 * pow2[i] % MOD;
  }
  ll sub = 0;
  ll half = n/2;
  for (ll i:irange(half+1, n+1)) {
    ll comb = fact[n] * finv[i] % MOD * finv[n-i] % MOD;
    sub += comb * pow2[n-i] % MOD;
    sub %= MOD;
  }
  sub *= 2;
  sub %= MOD;
  ll pow3 = 1;
  for (ll i:irange(0l, n)) {
    pow3 *= 3;
    pow3 %= MOD;
  }
  ll ans = pow3 + (MOD - sub);
  ans %= MOD;
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 234624
#include<bits/stdc++.h>
using namespace std;
int n,x[105],res=0x3f3f3f3f;
int main()
{
    cin>>n;
    for(int i=1;i<=n;i++)cin>>x[i];
    for(int i=1;i<=100;i++){
        int sum=0;
        for(int j=1;j<=n;j++)sum+=(x[j]-i)*(x[j]-i);
        res=min(res,sum);
    }
    cout<<res<<endl;
    return 0;
}

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

int main() {
    int K;
    int N;
    cin >> K >> N;
    vector<int> A(N);
    int i;
    for (i = 0; i < N; i++){
        cin >> A.at(i);
    }

    vector<int> B(N);
    for (i = 0; i < N-1; i++){
        B.at(i) = A.at(i+1) - A.at(i);
    }
    B.at(N-1) = A.at(0) + K - A.at(N-1);

    sort(B.begin(), B.end());

    cout << K - B.at(N-1) << endl;
}


Measured memory_bytes: 1792
package main

import (
	"fmt"
	"math"
	"sort"
)

var N, ans int

func main() {
	fmt.Scan(&N)
	a := make([]int, N)
	for i := 0; i < N; i++ {
		fmt.Scan(&a[i])
	}

	sort.Ints(a)

	for i := 1; i < N; i++ {
		ans += a[i] - a[i-1]
	}

	fmt.Println(ans)
}

/*  ----------------------------------------  */

func gcd(x, y uint64) uint64 {
	if x%y == 0 {
		return y
	} else {
		r := x % y
		return gcd(y, r)
	}
}

func combination(x, y int) int {
	return permutation(x, y) / permutation(y, y)
}

func permutation(x, y int) int {
	var ans int = 1
	for i := x - y; 0 < i; i-- {
		ans *= i
	}
	return ans
}

func max(x ...int) int {
	var res int = x[0]
	for i := 1; i < len(x); i++ {
		res = int(math.Max(float64(x[i]), float64(res)))
	}
	return res
}

func min(x ...int) int {
	var res int = x[0]
	for i := 1; i < len(x); i++ {
		res = int(math.Min(float64(x[i]), float64(res)))
	}
	return res
}

func pow(x, y int) uint64 { return uint64(math.Pow(float64(x), float64(y))) }
func abs(x int) int       { return int(math.Abs(float64(x))) }
func floor(x int) int     { return int(math.Floor(float64(x))) }

type XY struct {
	x int
	y int
}

type SortBy [][]int

func (a SortBy) Len() int      { return len(a) }
func (a SortBy) Swap(i, j int) { a[i], a[j] = a[j], a[i] }
func (a SortBy) Less(i, j int) bool {
	if a[i][0] == a[j][0] {
		return a[i][1] > a[j][1]
	}
	return a[i][0] > a[j][0]
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
using LL  = long long;
using VI  = vector<LL>;
using VVI = vector<VI>;
using VB  = vector<bool>;
using VS  = vector<string>;
using PII = pair<LL, LL>;
using VP  = vector<PII>;
#define PB           push_back
#define MP           make_pair
#define SZ(a)        LL((a).size())
#define EACH(x, c)   for (auto x : (c))
#define ALL(c)       (c).begin(), (c).end()
#define REVERSE(c)   reverse(ALL(c))
#define SORT(c)      stable_sort(ALL(c))
#define RSORT(c)     stable_sort((c).rbegin(), (c).rend())
#define FSORT(c)     stable_sort(ALL(c), [] (auto& x, auto& y) {return x.first < y.first;});
#define FRSORT(c)    stable_sort(ALL(c), [] (auto& x, auto& y) {return x.first > y.first;});
#define SSORT(c)     stable_sort(ALL(c), [] (auto& x, auto& y) {return x.second < y.second;});
#define SRSORT(c)    stable_sort(ALL(c), [] (auto& x, auto& y) {return x.second > y.second;});
#define FOR(i, a, b) for (LL i = (a); i < (b); ++i)
#define REP(i, n)    FOR(i, 0, n)
#define DEBUG true
#define $(x) {if (DEBUG) {cout << #x << " = " << (x) << endl;}}

unordered_map<LL, LL> factorize(LL n) {
    unordered_map<LL, LL> prime_factors;
    LL m = n;
    FOR(i, 2, (LL)(sqrt(n) + 1)) {
        if (m < i) break;   // 全て割り切った
        while (m % i == 0) {
            prime_factors[i]++;
            m /= i;
        }
    }
    if (m != 1) {   // 残りの素因数(必ず1つの素数となる)
        prime_factors[m]++;
    }
    return prime_factors;
}

int main() {
    LL N;
    cin >> N;
    // 75 = 5 * 5 * 3 = 5 * 15 = 25 * 3

    unordered_map<LL, LL> pfs_all;
    FOR(n, 2, N + 1) {
        auto pfs = factorize(n);
        for (auto pf : pfs) {
            pfs_all[pf.first] += pf.second;
        }
    }

    LL c3 = 0, c5 = 0, c15 = 0, c25 = 0, c75 = 0;
    EACH(pf, pfs_all) {
        if (pf.second >= 2) c3++;
        if (pf.second >= 4) c5++;
        if (pf.second >= 14) c15++;
        if (pf.second >= 24) c25++;
        if (pf.second >= 74) c75++;
    }
    /*$(c3);
    $(c5);
    $(c15);
    $(c25);
    $(c75);*/
    LL ans = c75 + c5 * (c5 - 1) * (c3 - 2) / 2 + c15 * (c5 - 1) + c25 * (c3 - 1);

    cout << ans << endl;
	
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <map>
#include <set>
using namespace std;
bool out(int x,int y,int n){
  return (x < 0 || x >= n || y < 0 || y >= n);
}

int main(){
  int n;
  int cnt = 1;
  while(cin >> n && n){
	vector<vector<int> > field(n,vector<int>(n,0));
	int dx[] = {-1,0,1,1};
	int dy[] = {1,1,-1,0};
	int cx = 0,cy = 0;
	int dir = 2;
	int n_order = 1;
	while(1){
	  field[cy][cx] = n_order++;
	  if(cy == n-1 && cx == n-1)break;

	  int cdir = dir;
	  if(out(cx+dx[dir],cy+dy[dir],n)){
		if(!out(cx + dx[(dir + 1) % 4], cy + dy[(dir + 1) % 4], n)) {
		  cdir = (dir + 1) % 4;
		}
		else {
		  cdir = (dir + 3) % 4;
		}
		dir ^= 2;
	  }

	  cx += dx[cdir];
	  cy += dy[cdir];
	}
	cout << "Case " << cnt++ << ":" << endl;
	
	for(int i = 0; i < n; ++i) {
	  for(int j = 0; j < n; ++j) {
		printf("%3d", field[i][j]);
	  }
	  puts("");
	}
	
  }
  return 0;
}

Measured memory_bytes: 1252
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <climits>
using namespace std;

#define mp make_pair
#define pb push_back
#define mt make_tuple
#define eb emplace_back

vector< vector<int> > adj(123456);
vector<int> val(123456), res(123456);
vector<bool> visited(123456, false);
int current = 0;

int dfs(int x)
{
    res[x] = val[current++];
    visited[x] = true;
    for(int i = 0; i < adj[x].size(); i++)
    {
        if(!visited[adj[x][i]])
        {
            dfs(adj[x][i]);
        }
    }
}

int main()
{
    int n, sum = 0, maxx = INT_MIN; cin >> n;

    int a, b, c;
    for(int i = 0; i < n - 1; i++)
    {
        cin >> a >> b;
        a--; b--;
        adj[a].pb(b);
        adj[b].pb(a);
    }

    for(int i = 0; i < n; i++)
    {
        cin >> val[i];
        sum = sum + val[i];
        maxx = max(maxx, val[i]);
    }
    cout << sum - maxx << endl;
    sort(val.begin(), val.end(), greater<int>());
    dfs(0);

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

    return 0;
}


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

int main()
{
  int k;
  cin >> k;
  string s;
  cin >> s;

  int n = s.size();
  if (k >= n)
    cout << s << endl;
  else
  {
    for (int i = 0; i < k; i++)
    {
      cout << s[i];
    }
    cout << "..." << endl;
  }
  return 0;
}


Measured memory_bytes: 3628
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <math.h>
#define MAX (int)sqrt(1e8)

void Prime(int *a)
{
  int i, j;
  for(i=2; i<MAX; i++){
    for(j=2; j*j<=i; j++){
      if(a[j] && i % j == 0) break;
    }
    if(j*j > i) a[i]=1;
  }
  return;
}

int main()
{
  int n, a=0, i, j, num;
  int *p = (int *)malloc(sizeof(int)*MAX);
  memset(p, 0, sizeof(int) * MAX);
  Prime(p);
  scanf("%d", &n);
  for(i=0; i<n; i++){
    scanf("%d", &num);
    if(num <= MAX && p[num]) a++;
    else{
      for(j=0; j*j<=num; j++){
        if(p[j] && num % j == 0) break;
      }
      if(j*j > num) a++;
    }
  }
  printf("%d\n", a);
  return 0;
}

Measured memory_bytes: 640
#include<bits/stdc++.h>
#define llong long long
#define mkpr make_pair
#define x first
#define y second
#define iter iterator
#define riter reversed_iterator
#define y1 Lorem_ipsum_
#define tm dolor_sit_amet_
using namespace std;

inline int read()
{
	int x = 0,f = 1; char ch = getchar();
	for(;!isdigit(ch);ch=getchar()) {if(ch=='-') f = -1;}
	for(; isdigit(ch);ch=getchar()) {x = x*10+ch-48;}
	return x*f;
}

const int mxN = 1e7;
const int P = 998244353;
llong fact[mxN+3],facti[mxN+3];
int n;

llong quickpow(llong x,llong y)
{
	llong cur = x,ret = 1ll;
	for(int i=0; y; i++)
	{
		if(y&(1ll<<i)) {y-=(1ll<<i); ret = ret*cur%P;}
		cur = cur*cur%P;
	}
	return ret;
}
void initfact(int n)
{
	fact[0] = 1ll; for(int i=1; i<=n; i++) {fact[i] = fact[i-1]*i%P;}
	facti[n] = quickpow(fact[n],P-2); for(int i=n-1; i>=0; i--) {facti[i] = facti[i+1]*(i+1ll)%P;}
}
llong comb(llong x,llong y) {return x<0||y<0||x<y?0ll:fact[x]*facti[y]%P*facti[x-y]%P;}

int main()
{
	initfact(mxN);
	n = read();
	llong ans = quickpow(3ll,n);
	for(int i=n/2+1; i<=n; i++)
	{
		llong tmp = comb(n,i)%P*quickpow(2ll,n-i+1)%P;
		ans = (ans-tmp+P)%P;
	}
	printf("%lld\n",ans);
	return 0;
}

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

#define rep(i,n) for(int (i)=0;(i)<(int)(n);(i)++)
#define rept(i,n) for(int (i)=0;(i)<=(int)(n);(i)++)
#define reps(i,s,n) for(int (i)=(s);(i)<(int)(n);(i)++)
#define repst(i,s,n) for(int (i)=(s);(i)<=(int)(n);(i)++)
#define repr(i,n) for(int (i)=(n);(i)>=0;(i)--)
#define each(itr,v) for(auto (itr):(v))
#define all(c) (c).begin(),(c).end()
#define pb push_back
#define mp(x,y) make_pair((x),(y))
#define fi first
#define se second
#define chmin(x,y) x=min(x,y)
#define chmax(x,y) x=max(x,y)
#define ln "\n"
#define dbg(x) cout<<#x" = "<<(x)<<ln

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vector<int> > mat;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

const int inf = (int)1e9;
const ll linf = (ll)1e18;
const int mod = (int)(1e9+7);
const int dx[] = {0, 1, 0, -1};
const int dy[] = {1, 0, -1, 0};
const int ddx[] = {0, 1, 1, 1, 0, -1, -1, -1};
const int ddy[] = {1, 1, 0, -1, -1, -1, 0, 1};

struct oreno_initializer {
	oreno_initializer() {
		cin.tie(0);
		ios::sync_with_stdio(0);
	}
} oreno_initializer;

// ━━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…
// .｡.:( ^ω^)・ﾟ＋.｡.:( ^ω^)・ﾟ＋.｡.:( ^ω^)・ﾟ＋.｡.:( ^ω^)・ﾟ＋.｡.:( ^ω^)・ﾟ＋
// ・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・

ll n, a[114514], l, c = inf;

int main() {
	cin >> n >> l;
	rep(i,n) cin >> a[i];
	// a[i]+a[i+1]>=lを満たすiが1個でもあればそこが最後に残るように端から切ってけばいい
	// 逆に1個もなければどう切っても最後は2個だけになって切れなくなるから無理
	rep(i,n-1) {
		if (a[i]+a[i+1]>=l) {
			c = i;
			break;
		}
	}
	if (c==inf) {
		cout << "Impossible" << ln;
		return 0;
	}
	cout << "Possible" << ln;
	rep(i,c) cout << i+1 << ln;
	for (int i = n-2; i > c; --i) cout << i+1 << ln;
	cout << c+1 << ln;
}

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

#define REP(i, n) for(int i = 0; i < (int)(n); ++i)
#define FOR(i, m, n) for(int i = (int)(m); i < (int)(n); ++i)


long long solution(vector<pair<long long, long long>>& M, long long D, long long A){
    int N = M.size();
    // 左から見ていくために、座標の昇順でソート
    sort(M.begin(), M.end());

    long long ans = 0, carry = 0;
    queue<pair<long long, long long>> q;
    REP(i, N){
        long long X = M[i].first;
        long long H = M[i].second;
        // これまでの操作の範囲に含まれないものの効果を取り除く
        while(!q.empty() and q.front().first < X){
            carry -= A*q.front().second;
            q.pop();
        }
        H -= carry;
        if(H > 0){
            long long num = (H+A-1)/A;
            ans += num;
            carry += A*num;
            q.emplace(X+2*D, num);
        }
    }
    return ans;
}

int main()
{
    int N, D, A;
    cin >> N >> D >> A;
    vector<pair<long long, long long>> M(N);
    REP(i, N) cin >> M[i].first >> M[i].second;

    cout << solution(M, D, A) << endl;

    return 0;
}

Measured memory_bytes: 4992
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int A = sc.nextInt();
		int B = sc.nextInt();
		int C = sc.nextInt();
		int D = sc.nextInt();
		StringBuilder S = new StringBuilder(sc.next());
		S.setCharAt(A - 1, 'A');
		S.setCharAt(B - 1, 'B');
		
		if(A < B) {
			if(C < D) {
				int now = B;
				while(now < D) {
					if(S.charAt(now) == '.') {
						now++;
					} else if(S.charAt(now + 1) == '.') {
						now += 2;
					} else {
						System.out.println("No");
		//				System.out.println(1);
						return;
					}
				}
				S.setCharAt(B - 1, '.');
				now = A;
				while(now < C) {
					if(S.charAt(now) == '.') {
						now++;
					} else if(S.charAt(now + 1) == '.') {
						now += 2;
					} else {
						System.out.println("No");
			//			System.out.println(2);
						return;
					}
				}
				System.out.println("Yes");
			} else {
				int now = B;
				while(S.charAt(now - 2) == '#' || S.charAt(now) == '#') {
					if(S.charAt(now) == '.') {
						now++;
					} else if(S.charAt(now + 1) == '.') {
						now += 2;
					} else {
						System.out.println("No");
			//			System.out.println(3);
						return;
					}
					if(now == D) {
						S.setCharAt(now - 1, 'B');
						break;
					}
				}
				S.setCharAt(now - 1, 'B');
				S.setCharAt(B - 1, '.');
				now = A;
				while(now < C) {
					if(S.charAt(now) == '.') {
						now++;
					} else if(S.charAt(now + 1) == '.') {
						now += 2;
					} else {
						System.out.println("No");
				//		System.out.println(4);
						return;
					}
				}
				System.out.println("Yes");
			}
		} else {
			if(C > D) {
				int now = A;
				while(now < C) {
					if(S.charAt(now) == '.') {
						now++;
					} else if(S.charAt(now + 1) == '.') {
						now += 2;
					} else {
						System.out.println("No");
			//			System.out.println(5);
						return;
					}
				}
				S.setCharAt(A - 1, '.');
				now = B;
				while(now < D) {
					if(S.charAt(now) == '.') {
						now++;
					} else if(S.charAt(now + 1) == '.') {
						now += 2;
					} else {
						System.out.println("No");
				//		System.out.println(6);
						return;
					}
				}
				System.out.println("Yes");
			} else {
				int now = A;
				while(S.charAt(now - 2) == '#' || S.charAt(now) == '#') {
					if(S.charAt(now) == '.') {
						now++;
					} else if(S.charAt(now + 1) == '.') {
						now += 2;
					} else {
						System.out.println("No");
	//					System.out.println(7);
						return;
					}
					if(now == C) {
						S.setCharAt(now - 1, 'A');
						break;
					}
				}
				S.setCharAt(now - 1, 'A');
				S.setCharAt(A - 1, '.');
				now = B;
				while(now < D) {
					if(S.charAt(now) == '.') {
						now++;
					} else if(S.charAt(now + 1) == '.') {
						now += 2;
					} else {
						System.out.println("No");
		//				System.out.println(8);
						return;
					}
				}
				System.out.println("Yes");
			}
		}
	}
}


Measured memory_bytes: 26872
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():
    N, A, B = map(int, readline().split())

    q, r = N // (A + B), N % (A + B)
    ans = A * q + min(A, r)
    print(ans)
    return


if __name__ == '__main__':
    main()


Measured memory_bytes: 9092
import sys
from collections import Counter


def input(): return sys.stdin.readline().strip()
def I(): return int(input())
def LI(): return list(map(int, input().split()))
def IR(n): return [I() for i in range(n)]
def LIR(n): return [LI() for i in range(n)]
def SR(n): return [S() for i in range(n)]
def S(): return input()
def LS(): return input().split()


INF = float('inf')


s = S()

if s == 'RRR':
    ans = 3
elif s[:2] == 'RR' or s[1:] == 'RR':
    ans = 2
else:
    c = Counter(list(s))
    if c['R'] == 1:
        ans = 1
    elif c['S'] == 3:
        ans = 0
    else:
        ans = 1

print(ans)


Measured memory_bytes: 9360
#include <iostream>
#include <vector>
#include <map>
#include <cstring>
#include <queue>
using namespace std;

int arr[100002];
int main(){ int n, q; long long sum = 0;
    cin >> n;
    for (int i=0; i<n; i++){ int x;
        cin >> x;
        arr[x]++;
        sum += x;
    }
    cin >> q;
    for (int i=0; i<q; i++){ long long x, y;
        cin >> x >> y;
        sum = sum - x*arr[x];
        sum = sum + y*arr[x];
        arr[y] += arr[x];
        arr[x] = 0;
        cout << sum << endl;
    }
    return 0;
}

Measured memory_bytes: 3888
N = int(input())
s = [sorted(input()) for _ in range(N)]
s = sorted(s)
ans = 0
temp = 1
for i in range(1, N):
    if s[i] == s[i - 1]:
        temp += 1
    else:
      ans += temp * (temp - 1) / 2
      temp = 1
ans += temp * (temp - 1) / 2
print(int(ans))

Measured memory_bytes: 25420
#include <iostream>
#include <iomanip>
#include <utility>
#include <cmath>
#include <random>
#include <vector>
#include <map>
#include <set>
#include <deque>
#include <queue>
#include <stack>
#include <string>
#include <algorithm>
using namespace std;

#define rep(i,n) for(int i = 0; i<n; ++i)
#define REP(i,n) for(int i = 1; i<=n; ++i)
#define all(x) begin(x),end(x)
#define show(obj) {for(auto x:obj)cout<<x<<' ';cout<<endl;}
#define line "----------"
typedef long long ll;
typedef pair<int,int> ip;
typedef pair<ll,ll> lp;
const int inf = 1001001000;
const ll INF = 1LL<<60;
const ll MOD = 1e9 + 7;

int main(){
	string s; cin>>s;
	int N = s.size();
	string pure;
	vector<int> ind;
	rep(i,s.size()){
		if(s[i] != 'x'){pure.push_back(s[i]); ind.push_back(i);}
	}
	if(pure.size() == 0){cout<<0<<endl; return 0;}
	string pure_rev = pure; reverse(all(pure_rev));
	if(pure != pure_rev){
		cout<<-1<<endl; return 0;
	}
	int ans = 0;
	if(pure.size()%2 == 0){
		int left = ind[pure.size()/2-1];
		int right = ind[pure.size()/2];
		vector<int> lcnt;
		vector<int> rcnt;
		rep(i,left+1){
			int e = 0;
			while(s[i] == 'x'){ ++e; ++i;}
			lcnt.push_back(e);
		}
		for(int i = N-1; i>=right; --i){
			int e = 0;
			while(s[i] == 'x'){ ++e; --i;}
			rcnt.push_back(e);
		}
		rep(i,max(lcnt.size(),rcnt.size())){
			ans += abs(lcnt[i]-rcnt[i]);
		}
	}else{
		int bor = ind[pure.size()/2];
		vector<int> lcnt;
		vector<int> rcnt;
		rep(i,bor+1){
			int e = 0;
			while(s[i] == 'x'){ ++e; ++i;}
			lcnt.push_back(e);
		}
		for(int i = N-1; i>=bor; --i){
			int e = 0;
			while(s[i] == 'x'){ ++e; --i;}
			rcnt.push_back(e);
		}
		rep(i,max(lcnt.size(),rcnt.size())){
			ans += abs(lcnt[i]-rcnt[i]);
		}
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 1656
#include <iostream>                                                              
#include <string>                                                                
                                                                                 
using namespace std;                                                             
                                                                                 
int main(void) {                                                                 
  string str;                                                                    
  int i;                                                                         
  int count[26] = {};                                                            
  int num = 0;                                                                   
  while (getline(cin, str)) {                                                    
    for (i = 0; i < str.length(); i++) {                                         
      if (islower(str[i])) {                                                     
        num = str[i] - 'a';                                                      
        count[num]++;                                                            
      }                                                                          
      else if (isupper(str[i])) {                                                
        str[i] = tolower(str[i]);                                                
          num = str[i] - 'a';                                                    
          count[num]++;                                                          
      }                                                                          
    }                                                                            
  }                                                                              
  for (i=0; i<26; i++) {                                                         
    cout << char(i + 'a') << " : " << count[i] << endl;                          
    }                                                                            
}                               

Measured memory_bytes: 3196
# -*- coding: utf-8 -*-
"""
AtCoder C
"""
import math
# N = int(input())
# A = list(map(int,input().split())) # N row 1 column
# A = int(input()) for _ in range(N) # 1 row N column
 
# S = str(input()) # str(input()) == input() -> 'abc'
# S = list(input()) # abc -> ['a','b','c']
 
def main():
    N, K = list(map(int,input().split()))
    # N=float(N)
    K=float(K)

    out=0
    for n in range(1,N+1):
        # print(n)
        if n>=K:
            out+=1/float(N)
        else:
            tmp=math.log2(K/n)
            # print(n,0.5**math.ceil(tmp))
            out+=0.5**math.ceil(tmp)/float(N)
    print(out)


if __name__ == "__main__":
    main()

Measured memory_bytes: 3060
#include <bits/stdc++.h>
#define fastIO (cin.tie(0), cout.tie(0), ios::sync_with_stdio(false))
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define precise(i) fixed << setprecision(i)
using lint = long;
using llint = long long;
using namespace std;

int main() {
    fastIO;
    int n, sum = 0;
    cin >> n;
    rep(i, n) sum += (i + 1);
    cout << sum << endl;
}



Measured memory_bytes: 3608
def tax(p,x)
  p*(100+x)/100
end

loop do
  x,y,s = gets.split.map(&:to_i)
  break if x == 0
  max = 0
  for a in 1...s
    for b in 1...s
      max = [max, tax(a,y)+tax(b,y)].max if tax(a,x)+tax(b,x) == s
    end
  end
  puts max
end

Measured memory_bytes: 6104
#include <stdio.h>

int main() {

  int h, w, i, j;
  while(1) {
    scanf("%d %d", &h, &w);
    if ((h == 0) && (w == 0))
      break;
    for (i = 0; i < h; i++) {
      for (j = 0; j < w; j++) {
	if ((i + j) % 2 == 0)
	  printf("#");
	else
	  printf(".");
      }
      printf("\n");
    }
    printf("\n");
  }

  return 0;

}

Measured memory_bytes: 572
#include <stdio.h>
	int main(void){
		int n,i,j;
		int a[10000];
		scanf("%d",&n);
		for(i=0;i<n;i++){
			scanf("%d",&a[i]);
		}
		for(j=n-1;j>0;j--){
			printf("%d ",a[j]);
		}
		printf("%d\n",a[0]);
	return 0;
}

Measured memory_bytes: 600
import java.util.*;
public class Main{
    public static List<Integer> p=Prime(1000000);
    public static int s=p.size();
    public static List<Integer> Prime(int n) {
        List<Integer> primes=new ArrayList<Integer>();
        primes.add(2);
        for(int i=3;i<= n;i++){
            int tmp=(int)(Math.sqrt(i))+1;
            for(int j=2;j<=tmp;j++){
                if(i % j == 0){
                    break;
                }
                if(j == tmp){
                    primes.add(i);
                }
            }
        }
        return primes;
    }
    public static int pri(int n){
	int count=0;
        for(int i=0;i<s;i++){
	    if(p.get(i)<=n){
		count++;
	    }
        }
        return count;
    }
    public static void main(String[] args){
        Scanner sc=new Scanner(System.in);
        int num;
        while(sc.hasNextInt()){
            num=sc.nextInt();
            System.out.println(pri(num));
        }
    }
}



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

int days_of_month(int y, int m) {
  if (y % 3 == 0)
    return 20;
  else if (m % 2 == 1)
    return 20;
  else
    return 19;
}

int main(void) {
  int n;
  cin >> n;
  while (n--) {
    int Y, M, D;
    cin >> Y >> M >> D;
    int days = days_of_month(Y, M) - D + 1;
    for (int y = Y; y < 1000; y++) {
      for (int m = y==Y ? M+1 : 1; m <= 10; m++) {
        days += days_of_month(y, m);
      }
    }
    cout << days << endl;
  }
}


Measured memory_bytes: 3064
#include<bits/stdc++.h>
    #define __STDC_LIMIT_MACROS
    #include <stdint.h>
    using namespace std;
    #define int             long long
     
    bool isPrime(int n)
    {
        if (n <= 1)
            return false;
        if (n <= 3)
            return true;
        if (n % 2 == 0 || n % 3 == 0)
            return false;
        for (int i = 5; i * i <= n; i += 6)
        {
            if (n % i == 0 || n % (i + 2) == 0)
                return false;
     
        }
        return true;
    }
     
    void c_p_c()
    {
    #ifndef ONLINE_JUDGE
        freopen("input.txt", "r", stdin);
        freopen("output.txt", "w", stdout);
    #endif
     
    }
    int32_t main()
    {
        ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
        c_p_c();
        int x,n;
        set<int> s;
        cin>>x>>n;
        int a;
        for(int i = 0; i<n; i++)
        {
            cin>>a;
            s.insert(a);
        }
        if(s.find(x)==s.end()) cout<<x<<endl;
        else
        {
            int left=-100,right=101;
            for(int i = -100; i<=101; i++)
            {
                if(i<=x && s.find(i)==s.end())
                {
                    left = max(i,left);
                }
                if(i>x && s.find(i)==s.end())
                {
                    right = min(i,right);
                }
            }
            if(x-left == right-x) cout<<left<<endl;
            else if(x-left<right-x) cout<<left<<endl;
            else cout<<right<<endl;
        }
    }   

Measured memory_bytes: 3644
#include <iostream>
#include <climits>
#include <set>
#include <string>
#include <algorithm>
#include <vector>
#define MAX 1000000007


using namespace std;
#define ll long long
#define dbg if(0)
#define ISRANGE(val,lo,hi) ((lo<=val)&&(val<hi))


ll top(ll i){
    if(i<10)return i;
    return top(i/10);
}

int main(){
    ll ans=0,ans1=0,n;
    cin>>n;
    /* //模範解答
    ll c[10][10];
    for(int i=0;i<10;i++){
        for(int j=0;j<10;j++){
            c[j][i]=0;
        }
    }
    for(int i=1;i<=n;i++){
        ll a=i%10;//aは0~9のみ
        ll b=top(i);//bは1~9のみ
        c[a][b]++;
    }
    for(int i=0;i<=9;i++){
        for(int j=0;j<=9;j++){
            ans1+=c[i][j]*c[j][i];
            //c[k][0]は常に0が入っているため、for文は0から回しても大丈夫だった
        }
    }
    cout<<ans1<<endl;
    */
    for( int i=1;i<=9;i++){
        for( int j=1;j<=9;j++){
        ll p=0;
        ll t=0;
        ll a=0;
        ll b=0;
            if(i==j && i<=n)p++;
            if(max(i*10+j,j*10+i)<=n)t++;
            ll by=100;
            while(i*by+j<=n){
                a+=(min(((n-(i*by+j))/10),by/10-1))%(by/10)+1;
                by*=10;
            } 
            by=100;
            while(j*by+i<=n){
                b+=(min(((n-(j*by+i))/10),by/10-1))%(by/10)+1;
                by*=10;
            } 
            if(i*10+j!=j*10+i){
                dbg cout<<p<<" "<<t<<" "<<a<<" "<<(p+t+a)*(p+t+b)<<endl;
                ans+=(p+t+a)*(p+t+b);
            }else{//i==jなら→p,t,a全てがまざる
                dbg cout<<p<<" "<<t<<" "<<a<<" "<<(p+t+a)*(p+t+b)<<endl;
                ans+=(p+t+a)*(p+t+b);
            }
        }
    }


    cout <<ans<<endl;

    return 0;

}


Measured memory_bytes: 256
n, k = tuple(map(int, input().split(' ')))
p = [0 for i in range(n)]
for i in range(k):
  d = input()
  a = map(int, input().split(' '))
  for j in a:
    p[j - 1] += 1
ans = 0
for i in range(n):
  if p[i] == 0:
    ans += 1
print(ans)

Measured memory_bytes: 9180
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
int main() {
    int a,b,c,k;
    cin >> a >> b >> c >> k;
    if(k<=a) cout << k << endl;
    else if(a<k&&k<=a+b) cout << a << endl;
    else cout << 2*a+b-k << endl;
}
 

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

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

	int a,b,c,d;

	cin >> a >> b >> c >> d;

	cout << max(a*b,c*d) << '\n';

	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define rep(i, a, b) for(int i = (a), i##_end_ = (b); i <= i##_end_; ++i)
#define drep(i, a, b) for(int i = (a), i##_end_ = (b); i >= i##_end_; --i)
#define clar(a, b) memset((a), (b), sizeof(a))
#define debug(...) fprintf(stderr, __VA_ARGS__)
typedef long long LL;
typedef long double LD;
int read() {
    char ch = getchar();
    int x = 0, flag = 1;
    for (;!isdigit(ch); ch = getchar()) if (ch == '-') flag *= -1;
    for (;isdigit(ch); ch = getchar()) x = x * 10 + ch - 48;
    return x * flag;
}
void write(int x) {
    if (x < 0) putchar('-'), x = -x;
    if (x >= 10) write(x / 10);
    putchar(x % 10 + 48);
}

const int Maxn = 3009;
int n; 
double p[Maxn], dp[Maxn][Maxn];

void init() {
	n = read();
	rep (i, 1, n) scanf("%lf", &p[i]);
}

void solve() {
	dp[0][0] = 1;

	rep (i, 1, n) 
		rep (j, 0, i) {
			if (i >= j) dp[i][j] += dp[i - 1][j - 1] * p[i];
			if (i - 1 >= j) dp[i][j] += dp[i - 1][j] * (1 - p[i]);
		}

	double ans = 0;
	rep (i, 1, n) 
		if (i >= n - i + 1) ans += dp[n][i];
	printf("%.10lf\n", ans);
}

int main() {
//	freopen("I.in", "r", stdin);
//	freopen("I.out", "w", stdout);

	init();
	solve();

#ifdef Qrsikno
    debug("\nRunning time: %.3lf(s)\n", clock() * 1.0 / CLOCKS_PER_SEC);
#endif
    return 0;
}



Measured memory_bytes: 69120
#include<cstdio>
using namespace std;
int main(){
    int a,b,c;
    scanf("%d %d %d",&a,&b,&c);
    if((a<c&&c<b)||(a>c&&c>b)){
        printf("Yes\n");
    }
    else{
        printf("No\n");
    }
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
#define rep(a, n) for (int i = a; i < n; i++)
#define per(a, n) for (int i = n - 1; i >= a; i--)
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(), (x).end()
#define fi first
#define se second
#define SZ(x) ((int)(x).size())
typedef long long ll;
typedef double db;
const ll mod = 1000000007;
ll powmod(ll a, ll b) {
    ll res = 1;
    a %= mod;
    assert(b >= 0);
    for (; b; b >>= 1) {
        if (b & 1)
            res = res * a % mod;
        a = a * a % mod;
    }
    return res;
}
vector<int> li[200010];
vector<bool>vis(200010);

int dfs(int v){
	int cnt = 1;
	vis[v] = true;
	for(auto e: li[v]){
		if(!vis[e]){
			cnt += dfs(e);
		}
	}
	return cnt;
}
ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }
int main() {
	int n,m;
	cin>>n>>m;
	for(int i=0;i<m;i++){
		int a,b;
		cin>>a>>b;
		li[a].push_back(b);
		li[b].push_back(a);
	}
	vis.assign(n+1,false);
	int cnt = 0;
	for(int i=1;i<=n;i++){
		if(!vis[i]){
			cnt = max(cnt,dfs(i));
		}
	}
	cout<<cnt;
}

Measured memory_bytes: 23932
#!/usr/bin/env python3
import sys

YES = "Yes"  # type: str
NO = "No"  # type: str

def solve(N: int, A: int, B: int, C: int, D: int, S: str):
    ret = YES
    ##for i in range(A - 1, C - 1):
    ##    if S[i:i + 2] == '##':
    ##        ret = NO
    ##        print(ret)
    ##        return
    ##for i in range(B - 1, D - 1):
    ##    if S[i:i + 2] == '##':
    ##        ret = NO
    ##        print(ret)
    ##        return
    ##if D < C:
    ##    ret = NO
    ##    for i in range(B - 2, D - 1):
    ##        if S[i:i + 3] == '...':
    ##            ret = YES
    ##            break

    if '##' in S[A - 1:C] or '##' in S[B - 1:D]:
        ret = NO
    else:
        if D < C:
            #if S[B - 2:B] == '..' or S[B - 1:B + 1] == '..':
            if '...' not in S[B - 2:D + 1]:
                ret = NO
    print(ret)
    return


def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    A = int(next(tokens))  # type: int
    B = int(next(tokens))  # type: int
    C = int(next(tokens))  # type: int
    D = int(next(tokens))  # type: int
    S = next(tokens)  # type: str
    solve(N, A, B, C, D, S)

if __name__ == '__main__':
    main()


Measured memory_bytes: 3572
def SieveOfEratosthenes(n):
    prime = [True for i in range(n + 1)]
    p = 2
    while (p * p <= n):

        if (prime[p] == True):

            for i in range(p * 2, n + 1, p):
                prime[i] = False
        p += 1
    lis = []
    for i in range(2,n+1):
        if prime[i]:
            lis.append(i)
    return lis

n = int(input())

lis1 = []

l = SieveOfEratosthenes(n)

for i in l:
    m = n
    z = i
    exp = 0
    while(m>=z):
        exp += m//z
        z*=i
    lis1.append(exp)

mul = 1
for i in lis1:
    mul *= (i+1)

print(mul%(10**9+7))



Measured memory_bytes: 3064
#include <iostream>
#include<string>
#include<math.h>
#include<vector>
#include<algorithm>
#include<array>
#include<functional>
using namespace std;
#define FOR(i,n) for(int (i)=0;(i)<(n);(i)++)


int main(){
    int N;
    cin >> N;
    vector<int> X;
    int Y[N];
     FOR(i,N){
        int tmp;
        cin >>tmp;
        X.push_back(tmp);
        Y[i]=tmp;
    }

    sort(X.begin(),X.end());
    int med1=X[(N-2)/2];
    int med2=X[N/2];

    FOR(i,N){
        if(Y[i]<=med1){
            cout<<med2;
        }else{
            cout <<med1;
        }
        cout << endl;
    }
    return 0;
}

Measured memory_bytes: 3828
N, M = map(int, input().split())
X = [[] for _ in range(N)]
for _ in range(M):
    u, v, d = map(int, input().split())
    X[u-1].append((v-1, d))
    X[v-1].append((u-1, d))
input()    
T = int(input())
t = 0
x = 0
while t < T:
    if t < 5000:
        print(-1)
        t += 1
        continue
    
    y, d = max([(y, d) for y, d in X[x]])
    for i in range(d):
        print(y+1)
        t += 1
        if t >= T:
            break
    x = y

Measured memory_bytes: 4364
#include <bits/stdc++.h>
#include <time.h>
using namespace std;
typedef long long ll;
typedef long double ld;
const ll MOD = 1e9 + 7/*998244353*/;
const ll INF = 1LL << 60;
ll mod_pow(ll, ll, ll); ll mod_fact(ll, ll); ll mod_inv(ll, ll); ll gcd(ll, ll); ll lcm(ll, ll);
//
int main(){
    int l, r, d;
    cin >> l >> r >> d;
    int ans = 0;
    for(int i = l; i <= r; i++){
        if(i % d == 0){
            ans ++;
        }
    }
    cout << ans << "\n";
}

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

using namespace std;

int main()
{
    string s;
    cin >> s;

    string s1 = s;

    reverse(s1.begin(), s1.end());

    int ans = 0;

    for(int i=0;i<s.size();i++)
    {
        if(s1[i] != s[i]) ans++;
    }

    cout << ans/2 << "\n";
}

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

def main():
    n = int(input())
    min_val = float('inf')
    for a in range(1, int(n/2)+1):
        b = n - a
        val = sum([int(c) for c in str(a)]) + sum([int(c) for c in str(b)])
        if val < min_val:
            min_val = val
    print(min_val)

if __name__ == '__main__':
    main()


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

using namespace std;

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

    int a, b, k;
    cin >> a >> b >> k;
    if (k * 2 > b - a + 1) {
        for (int i = a; i <=b ;i ++)
            cout << i << endl;
    }else {
        for (int i = a; i < a + k; i ++)
            cout << i << endl;

        for (int i = b - k + 1; i <=b; i ++)
            cout << i << endl;
    }

    return 0;
}

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

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

int main() {
  int K;
  cin >> K;
  long long sum = 0;
  for (int a = 1; a <= K; a++) {
    for (int b = 1; b <= K; b++) {
      for (int c = 1; c <= K; c++) {
        int tmp = gcd(b, c, max(b, c) % min(b, c));
        sum += gcd(a, tmp, max(a, tmp) % min(a, tmp));
      }
    }
  }
  cout << sum << endl;
}


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

using namespace std;

int main() {
    cin.tie(0);
    cout.tie(0);
    ios_base::sync_with_stdio(0);
    int  n, m;
    cin >> n >>m;
    if(n == m)
        cout << "Yes\n";
    else
        cout <<"No\n";


}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
  
  int A;
  int B;
  string S;
  string T;
  string U;
 
  cin >> S >> T;
  cin >> A >> B;
  cin >> U;
  
  
  if(S[0] == U[0]){
    cout << A - 1 << " " << B << endl;
  }
  else{
    cout << A << " " << B - 1 << endl;
  }
  
  
}


Measured memory_bytes: 256