akhauriyash/Code-Regression huggingface dataset:
import java.util.*;

public class Main {

  public static void main (String[] args) {

    Scanner sc = new Scanner(System.in);

    int N = sc.nextInt();

    int[] a = new int[N+1];
    for (int i = 1; i < N+1; i++) {
      a[i] = sc.nextInt();
    }

    sc.close();

    int[] b = new int[N+1];

    for (int i = N; 1 <= i; i--) {
      int count = 0;
      for (int j = i; j <= N; j += i) {
        if (b[j] == 1) {
          count++;
        }
      }
      if (count % 2 == a[i]) {
        b[i] = 0;
      } else {
        b[i] = 1;
      }
    }

    Queue<Integer> result = new ArrayDeque<>();
    for (int i = 1; i < N+1; i++) {
      if (b[i] == 1) {
        result.add(i);
      }
    }

    System.out.println(result.size());

    int count = 0;
    for (Integer value : result) {
      count++;
      System.out.print(value);
      if (count != result.size()) {
        System.out.print(" ");
      } else {
        System.out.println("");
      }
    }

  }

}

Measured memory_bytes: 90788
#include <iostream>
#include <vector>
#include <map>
#include <string>
#include <algorithm>

using namespace std;
typedef long long LL;
LL NAN = -1000000000000000000LL;

bool traverse(vector<vector<pair<LL,LL>>>& edge, vector<LL>& memo, int cur, LL pos){
    if(memo[cur] != NAN){
        //cerr << "cur=" << cur << ", pos=" << pos << ", memo=" << memo[cur] << endl;
        if(pos != memo[cur]){
            return false;
        }
        return true;
    }
    //cerr << "i=" << cur << ", pos=" << pos << endl;
    memo[cur] = pos;
    for(int i = 0; i < edge[cur].size(); ++i){
        //cerr << cur << " to " << edge[cur][i].first << endl;
        if(!traverse(edge, memo, edge[cur][i].first, pos + edge[cur][i].second)){
            return false;
        }
    }
    return true;
}

int main(){
    int n, m;
    cin >> n >> m;
    vector<vector<pair<LL,LL>>> edge(n);
    for(int i = 0; i < m; ++i){
        LL l, r, d;
        cin >> l >> r >> d;
        edge[l-1].push_back(pair<LL,LL>(r-1, d));
        edge[r-1].push_back(pair<LL,LL>(l-1, -d));
    }
    vector<LL> memo(n, NAN);
    for(int i = 0; i < n; ++i){
        if(memo[i] != NAN) continue;
        if(!traverse(edge, memo, i, 0)){
            cout << "No" << endl;
            return 0;
        }
    }
    cout << "Yes" << endl;
    return 0;
}


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

int w, h;
int s[32][32];
int cost[4];

// dir
// 0 : right
// 1 : up
// 2 : left
// 3 : down
const int dr[4] = {0, -1, 0, 1};
const int dc[4] = {1, 0, -1, 0};
const int dd[4] = {0, 3, 2, 1};

typedef std::pair<int, int> Pii;

class Node {
public:
  Node() {}
  Node(int r_, int c_, int dir_) : r(r_), c(c_), dir(dir_) {}
  int r, c, dir;
};

class Data {
public:
  Data() {}
  Data(Node s_, Node t_, int cost_) : s(s_), t(t_), cost(cost_) {}
  Node s, t;
  int cost;
};

inline bool operator < (const Data& a, const Data& b) {
  return a.cost > b.cost;
}

int dist[32][32][8];
int dijkstra() {
  std::priority_queue<Data> q;
  int r = 0;
  int c = 0;
  int dir = 0;
  dist[r][c][dir] = 0;
  for(int k = 0; k < 4; ++k) {
    int nd = (dir + dd[k]) % 4;
    int nr = r + dr[nd];
    int nc = c + dc[nd];
    if( not ( 0 <= nr and nr < h and 0 <= nc and nc < w ) ) continue;
    q.push(Data(Node(r, c, dir), Node(nr, nc, nd), k == s[r][c] ? 0 : cost[k]));
  }
  while( not q.empty() ) {
    Data t = q.top(); q.pop();
    int r = t.t.r, c = t.t.c, dir = t.t.dir;
    if( dist[r][c][dir] <= dist[t.s.r][t.s.c][t.s.dir] + t.cost ) continue;
    dist[r][c][dir] = dist[t.s.r][t.s.c][t.s.dir] + t.cost;
    if( r == h - 1 and c == w - 1 ) continue;
    for(int k = 0; k < 4; ++k) {
      int nd = (dir + dd[k]) % 4;
      int nr = r + dr[nd];
      int nc = c + dc[nd];
      if( not ( 0 <= nr and nr < h and 0 <= nc and nc < w ) ) continue;
      q.push(Data(Node(r, c, dir), Node(nr, nc, nd), k == s[r][c] ? 0 : cost[k]));
    }
  }
  int res = (1 << 30);
  for(int i = 0; i < 4; ++i) {
    res = std::min(res, dist[h-1][w-1][i]);
  }
  return res;
}

void Init() {
  for(int i = 0; i < 32; ++i) {
    for(int j = 0; j < 32; ++j) {
      for(int k = 0; k < 4; ++k) {
        dist[i][j][k] = (1 << 29);
      }
    }
  }
}

int main() {
  for(;;) {
    Init();
    scanf("%d %d", &w, &h);
    if( w == 0 and h == 0 ) break;
    for(int i = 0; i < h; ++i) {
      for(int j = 0; j < w; ++j) {
        scanf("%d", &s[i][j]);
      }
    }
    for(int i = 0; i < 4; ++i) {
      scanf("%d", &cost[i]);
    }
    int res = dijkstra();
    printf("%d\n", res);
  }
  
  return 0;
}

Measured memory_bytes: 8684
#include <bits/stdc++.h>
using namespace std;
#define endl '\n'
#define fastIO ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define int long long int
#define pb push_back
#define ff first
#define ss second
#define all(v) (v).begin(), (v).end()
#define mod (int)(998244353)
#define PI 3.14159265358979323846264338327950L
// ------------------ Debugging ------------------
#define trace(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args);cout << endl; }
void err(istream_iterator<string> it) {}
template<typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args) {
    cerr << "[ " << *it << " = " << a << " ] ";
    err(++it, args...);
}
template <typename Tk, typename Tv> ostream& operator<<(ostream& os, const pair<Tk, Tv> &p){os << "{" << p.first << ',' << p.second << "}";return os;}
template <typename T> ostream& operator<<(ostream& os, const vector<T> &p){os << "[ "; for (T x: p) os << x << " "; os << "]" << endl; return os;}
template <typename T> ostream& operator<<(ostream& os, const set<T> &p){os << "{ "; for (T x: p) os << x << " "; os << "}" << endl; return os;}
template <typename Tk, typename Tv> ostream& operator<<(ostream& os, const map<Tk, Tv> &p){os << "{ "; for (pair<Tk, Tv> x: p) os << x << " "; os << "}" << endl; return os;}
// -----------------------------------------------

signed main(){

    fastIO

    int t = 1;
    // cin >> t;
    while (t--){
   		string s, t;
   		cin >> s >> t;
   		int ans = 1e9;
   		if ((int) s.size() == (int)t.size()) {
   			ans = 0;
   			for (int i = 0; i < (int)s.size(); i++) {
   				if (s[i] != t[i]) ans++;
   			}
   		} else {
	   		for (int i = 0; i < (int)s.size() - (int)t.size(); i++) {
	   			int chg = 0;
	   			for (int j = 0; j < (int)t.size(); j++) {
	   				if (s[i+j] != t[j]) {
	   					chg++;
	   				}
	   			}
	   			ans = min(chg, ans);
	   		}
	   	}
   		cout << ans << endl;
    }
    
    return 0;
}

Measured memory_bytes: 3612
package main

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

func main() {
	io, flush := NewIO()
	defer flush()

	n := io.ScanInt()
	giftMap := map[string]bool{}
	var giftCount int
	for i := 0; i < n; i++ {
		gift := io.ScanString()
		if _, ok := giftMap[gift]; !ok {
			giftMap[gift] = true
			giftCount++
		}
	}
	fmt.Println(giftCount)
}

type IO struct {
	scanner *bufio.Scanner
	writer  *bufio.Writer
}

func NewIO() (*IO, func()) {
	io := &IO{
		scanner: newScanner(),
		writer:  newWriter(),
	}
	return io, func() { io.writer.Flush() }
}

func newScanner() *bufio.Scanner {
	s := bufio.NewScanner(os.Stdin)
	s.Buffer(make([]byte, 10000000), 10000000)
	s.Split(bufio.ScanWords)
	return s
}

func newWriter() *bufio.Writer {
	return bufio.NewWriter(os.Stdout)
}

func (io *IO) ScanBytes() []byte {
	if !io.scanner.Scan() {
		panic("scan string failed")
	}
	return io.scanner.Bytes()
}

func (io *IO) ScanString() string {
	if !io.scanner.Scan() {
		panic("scan string failed")
	}
	return io.scanner.Text()
}

func (io *IO) ScanStrings(n int) []string {
	strs := make([]string, n)
	for i := 0; i < n; i++ {
		strs[i] = io.ScanString()
	}
	return strs
}

func (io *IO) Scan2DStrings(y, x int) [][]string {
	strings := make([][]string, y)
	for i := 0; i < y; i++ {
		strings[i] = io.ScanStrings(x)
	}
	return strings
}

func (io *IO) Scan2DGraph(y int) [][]string {
	strs := make([][]string, y)
	for i := 0; i < y; i++ {
		strs[i] = strings.Split(io.ScanString(), "")
	}
	return strs
}

func (io *IO) ScanInt() int {
	return int(io.ScanInt64())
}

func (io *IO) ScanInt2() (int, int) {
	return int(io.ScanInt64()), int(io.ScanInt64())
}

func (io *IO) ScanInt3() (int, int, int) {
	return int(io.ScanInt64()), int(io.ScanInt64()), int(io.ScanInt64())
}

func (io *IO) ScanInt4() (int, int, int, int) {
	return int(io.ScanInt64()), int(io.ScanInt64()), int(io.ScanInt64()), int(io.ScanInt64())
}

func (io *IO) ScanInts(n int) []int {
	ints := make([]int, n)
	for i := 0; i < n; i++ {
		ints[i] = io.ScanInt()
	}
	return ints
}

func (io *IO) Scan2DInts(y, x int) [][]int {
	ints := make([][]int, y)
	for i := 0; i < y; i++ {
		ints[i] = io.ScanInts(x)
	}
	return ints
}

func (io *IO) ScanInt64() int64 {
	i, err := strconv.ParseInt(io.ScanString(), 10, 64)
	if err != nil {
		panic(err)
	}
	return i
}

func (io *IO) ScanFloat64() float64 {
	i, _ := strconv.ParseFloat(io.ScanString(), 64)
	return i
}

func (io *IO) ScanFloat64s(n int) []float64 {
	floats := make([]float64, n)
	for i := 0; i < n; i++ {
		floats[i] = io.ScanFloat64()
	}
	return floats
}

func (io *IO) Println(a ...interface{}) {
	fmt.Fprintln(io.writer, a...)
}



Measured memory_bytes: 18088
#include <bits/stdc++.h>
using namespace std;
#define eb emplace_back
#define emp emplace
#define fi first
#define se second
#define INF 0x3f3f3f3f
typedef long long ll;
typedef pair<int, int> ii;

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

	int n, a, b; cin >> n >> a >> b;

	if ((b-a+1)%2) {
		cout << "Alice" << endl;
	} else {
		cout << "Borys" << endl;
	}

	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define MN 100005
typedef long long ll;
int n,q,N;
ll num[MN],que[MN],mul[MN];
void calc(int x,ll nn,ll&gg)
{
	if(!nn) return;
	int pos=std::upper_bound(que+1,que+x,nn)-que-1;
	if(!pos) return(void)(num[n]+=gg*(nn/n),num[nn%n]+=gg);
	mul[pos]+=(nn/que[pos])*gg;
	calc(pos,nn%que[pos],gg);
}
int main()
{
	scanf("%d%d",&n,&q);
	for(int i=1;i<=q;i++)
	{
		ll x;
		scanf("%lld",&x);
		for(;N&&x<=que[N];N--);
		que[++N]=x;
	}
	mul[N]=1;que[0]=n;
	for(int i=N;i>=1;i--) {
		calc(i,que[i]%que[i-1],mul[i]);
		mul[i-1]+=mul[i]*(que[i]/que[i-1]);
	}
	num[n]+=mul[0];
	for(int i=n;i>1;i--) num[i-1]+=num[i];
	for(int i=1;i<=n;i++) printf("%lld\n",num[i]);
}

Measured memory_bytes: 6132
def LIHW(h):
    return [list(map(int, input().split())) for _ in range(h)]


def LIH(h):
    return [int(input()) for _ in range(h)]


card = LIHW(3)
N = int(input())
num = LIH(N)
bingo = [[0, 0, 0] for _ in range(3)]
for i in num:
    for a in range(3):
        for b in range(3):
            if i == card[a][b]:
                bingo[a][b] = 1
                break
ans = "No"
for i in range(3):
    if bingo[i][0] == 1 and bingo[i][1] == 1 and bingo[i][2] == 1:
        ans = "Yes"
for i in range(3):
    if bingo[0][i] == 1 and bingo[1][i] == 1 and bingo[2][i] == 1:
        ans = "Yes"
if bingo[0][0] == 1 and bingo[1][1] == 1 and bingo[2][2] == 1:
    ans = "Yes"
if bingo[0][2] == 1 and bingo[1][1] == 1 and bingo[2][0] == 1:
    ans = "Yes"
print(ans)


Measured memory_bytes: 9204
#include <bits/stdc++.h>
#include <iomanip>
#include <math.h>
#define rep(i,x) for(ll i = 0;i<x;i++)
#define all(a) (a).begin(),(a).end()
using ll = long long;
using ld = long double;
using namespace std;
using dou = double;
const ll INF = 1LL << 60;
const ll mod = 1000000007;
typedef pair<ll,ll> P;
using graph = vector<vector<ll>>;
template<class T> inline bool chmax(T& a, T b){if(a < b){a = b; return true;}return false;}
template<class T> inline bool chmin(T& a, T b){if(a > b){a = b; return true;}return false;}
ll gcd(ll a,ll b){
    if(a < b)swap(a,b);
    if(a % b == 0)return b;
    else return gcd(b,a%b);
}
bool isp(ll n){
    bool res = true;
    if(n == 1)return false;
    else{
        for(ll i = 2;i * i <= n;i++){
            if(n % i == 0){
                res = false;
                break;
            }
        }
        return res;
    }
}
//printf("%.10f\n", N);
/*
ll fibo(ll n){
    if(memo[n] != 0)return memo[n];
    if(n <= 1)return n;
    else return memo[n] = fibo(n - 1)+ fibo(n - 2);
}*/
/*  vector<ll> vec = {1,2,5,6,8,9,10};
    cout << binary_search(all(vec),5) << endl; -> true*/
/*
    vector<ll> vec = {1,2,5,6,8,9,10};
    auto n = upper_bound(all(vec),4);
    cout << *n << endl; -> 5*/
/*
    cout << fixed << setprecision(15);
    */
int main(){
    ll X,Y;
    cin >> X >> Y;
    if(X % Y != 0)cout << X << endl;
    else cout << -1 << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <ios>
using namespace std;
struct Node
{
	Node(int k) : depth(0) { vChildId.resize(k, -1); }
	int depth;
	vector<int> vChildId;
};

void SetNodeDepthRecursive(Node* n, vector<Node*>& vNode)
{
	int s = n->vChildId.size();
	if (0 == s) return;
	for (int i = 0; i < s; ++i){
		Node* cn = vNode[n->vChildId[i]];
		cn->depth = n->depth + 1;
		SetNodeDepthRecursive(cn, vNode);
	}
}

int main()
{
	ios::sync_with_stdio(false);
	cin.tie(0);
	int nu, id, k, c;
	cin >> nu;
	vector<int> vParentId(nu, -1);
	vector<Node*> vNode(nu, (Node*)0);
	while (nu--){
		cin >> id >> k;
		vNode[id] = new Node(k);
		for (int j = 0; j < k; ++j){
			cin >> c;
			vNode[id]->vChildId[j] = c;
			vParentId[c] = id;
		}
	}
	vector<Node*> vRoot;
	for (int i = 0; i < vNode.size(); ++i){
		if (vParentId[i] == -1)
			vRoot.push_back(vNode[i]);
	}
	for (int i = 0; i < vRoot.size(); ++i)
		SetNodeDepthRecursive(vRoot[i], vNode);

	Node* n;
	int pid;
	for (int i = 0; i < vNode.size(); ++i){
		n = vNode[i];
		pid = vParentId[i];
		cout << "node " << i << ": parent = " << pid << ", depth = " << n->depth << ", ";
		if (pid == -1){
			cout << "root, [";
			if (n->vChildId.size() == 0)
				cout << "]\n";
		}
		else if (n->vChildId.size() == 0) cout << "leaf, []\n";
		else cout << "internal node, [";
		if (n->vChildId.size() != 0){
			int cs = n->vChildId.size();
			for (int j = 0; j < cs; ++j){
				cout << n->vChildId[j];
				if (j < cs - 1)
					cout << ", ";
			}
			cout << "]\n";
		}
		delete n;
	}

	return 0;
}

Measured memory_bytes: 7340
#include <iostream>

using namespace std;

int main()
{


    int n,m,newval;
    cin >> n>>m;
    newval=m;
    for (int j =1 ; j<n ;j++){
        newval--;
    }
    for (int z = 1 ; z <n;z++){
      cout << newval<<" ";
      newval++;
    }
    cout << m <<" ";
    newval=m;
    for(int i =1 ;i<n ;i++){
        newval++;
        cout << newval<<" ";
    }

    return 0;
}


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

#define U1 unsigned char
#define S1 char
#define	S4 int

#define MAX_LENGTH (21)  /* ヌル文字込みの最大入力文字数 */

S4 main()
{
	U1 u1_tp_input[MAX_LENGTH];		/* 反転したい文字列 */
	S1 s1_t_idx;					/* 文字列反転処理で処理中の文字を指すインデックス */
	U1 u1_t_strLength;				/* 文字列の長さ */

	/* 入力 */
	scanf("%s", u1_tp_input);

	/* 文字列の長さを計算 */
	u1_t_strLength = (U1)strlen((const char*)u1_tp_input);

	/* 末尾から先頭に向かって文字を出力 */
	for (s1_t_idx = (S1)u1_t_strLength; s1_t_idx > (S1)0; s1_t_idx--)
	{
		printf("%c", u1_tp_input[s1_t_idx - 1]);
	}
	printf("\n");

	return((S4)0);
}



Measured memory_bytes: 1788
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define pi 3.1415926536
#define pb push_back
#define N 1000000007
#define M 998244353
int main(){
    ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    ll i,t,m,j,x,y,l,n,k;
    cin>>n>>m;
    map<ll,ll> mp,mp2;
    
    ll c1 = 0,c2=0;
    while(m--){
    	cin>>x;
    	string s;
    	cin>>s;
    	if(s == "AC"){
    		if(mp[x] == 1) continue;
    		else{
    			c1++;
    			mp[x] = 1;
			}
		}else{
			if(mp[x] == 1) continue;
			else{
				mp2[x]++;
			}
		}
	}
	for(i=1;i<=n;i++){
		if(mp[i] == 1) c2 += mp2[i];
	}
	cout<<c1<<" "<<c2;
}


Measured memory_bytes: 12800
#include<iostream>
#include <cstdio>
#include <iostream>
#include <cstring>
#include <string>
#include <cmath>
#include <queue>
#include <set>
#include <map>
#include <complex>
#include <algorithm>
#include <vector>

using namespace std;
typedef long long ll;
typedef long double db;
typedef pair<int,int> pii;
typedef vector<int> vi;
#define de(x) cout << #x << "=" << x << endl
#define rep(i,a,b) for(int i=a;i<(b);++i)
#define all(x) (x).begin(),(x).end()
#define sz(x) (int)(x).size()
#define mp make_pair
#define pb push_back
#define fi first
#define se second
int main()
{
	int n,t,sum=0;
	cin>>n;
	rep(i,1,n+1)
	{
		//de(i);
		scanf("%d",&t);
		if(t==i)
		{
			sum++;
			i++;
			if(i<=n)
			scanf("%d",&t);
		}
	}
	cout<<sum;
	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
int main(void){
    int i,j;            //  ループ文に使用
    int x,y,z;
    int n;
    int count,count2;   //  カウント用に使用
    char s[256];        //  文字列
    
    count = 0;
    count2 = 0;
    
    //  入力処理
    
    scanf("%d",&n);
    
    //  計算処理
    
    if (n < 10){
        count = n;
    }else if (n < 100){
        count = 9;
    }else if (n < 1000){
        for (i = 100 ; i <= n; i++){
            count++;
        }
        count = count + 9;
    }else if (n < 10000){
        count = 9 + 900;
    }else if (n < 100000){
        for (i = 10000 ; i <= n; i++){
            count++;
        }
        count = count + 9 + 900;
    }else if (n == 100000){
        count = 9 + 900 + 90000;
    }
    //  出力処理
    
    printf("%d",count);
    
    
}


Measured memory_bytes: 128
H,W = map(int, input().split())
field = []
countd = 0
for _ in range(H):
    ls = []
    st = str(input())
    for ss in st:
        ls.append(ss)
        if ss =='.':
            countd += 1
    field.append(ls)
import heapq

def caldis(field):#ある点を黒にして計算できる距離の中で際異端のものを求める
    used = [[False]*50 for i in range(50)]
    dis = [[float('inf')]*51 for i in range(51)]
    dis[0][0] = 0
    que = []
    heapq.heappush(que,[0,0,0])
    while len(que)>0:
        pre = heapq.heappop(que)
        d = pre[0]
        px = pre[1]
        py = pre[2]
        if used[px][py] ==True:
            continue
        used[px][py] = True
        dis[px][py] = d
        for dx in [-1,1]:
            for dy in [-1,1]:
                if 0<=px+dx<=H-1:
                    if field[px+dx][py]=='.':
                        heapq.heappush(que,[d+1,px+dx,py])
                if 0<=py+dy<=W-1:
                    if field[px][py+dy]=='.':
                        heapq.heappush(que,[d+1,px,py+dy])
    res = dis[H-1][W-1]
    return res
an = caldis(field)
if an==float('inf'):
    print(-1)
else:
    print(countd-an-1)


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

using namespace std;

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

  if(s == "Sunny") cout << "Cloudy" << endl;
  else if(s == "Cloudy") cout << "Rainy" << endl;
  else if(s == "Rainy") cout  << "Sunny" << endl;
  return 0;
}


Measured memory_bytes: 256
#include<cstdio>
#include<cstring>
#define For(i,A,B) for(i=(A);i<=(B);++i)
const int N=200050;
int a[N],b[N],n;
inline bool check(){
	int i;
	For(i,1,n)if(a[i]<n)return 0;
	return 1;
}
int main(){
	int k,i,j;
	scanf("%d%d",&n,&k);
	For(i,1,n)scanf("%d",a+i);
	For(j,1,k)if(!check()){
		memset(b,0,sizeof(b));
		For(i,1,n){++b[i>a[i]?i-a[i]:1];if(i+a[i]<n)--b[i+a[i]+1];}
		For(i,2,n)b[i]+=b[i-1];
		memcpy(a,b,sizeof(a));
	}else break;
	For(i,1,n)printf("%d ",a[i]);
	putchar('\n');
	return 0;
}

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

def factorization(n):
    arr = dict()
    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[i] = cnt

    if temp!=1:
        arr[temp] = 1

    if arr==[]:
        arr[n] = 1

    return arr

fact = factorization(N)
cnt = 0

for value in fact.values():
    tmp = 3
    next_num = 3
    tmp_cnt = 1
    while tmp <= value:
        tmp += next_num
        next_num += 1
        tmp_cnt += 1
    

    cnt += tmp_cnt
    
print(cnt)

Measured memory_bytes: 9492
#include<iostream>
#include<algorithm>
#include<vector>
#include<string>
#include<cmath>
#include<cstdio>
#include<queue>
#include<deque>
#include<map>
#include<stack>
#include<set>
#include<utility>
using namespace std;
typedef pair<int,int> pii;
typedef pair<int,pii> pipii;
typedef long long ll;
typedef pair<ll,ll> pll;
int dy[]={1,0,-1,0};
int dx[]={0,1,0,-1};
const int MAXN=100000;
const int MAXE=100000;
const int MAXV=10000;
const ll INF=2e18;
const ll MOD=1e9+7;
struct edge{
    int to;
    int cost;
};
int main(){
    ll N,W;cin>>N>>W;
    vector<ll> w(N),v(N);
    for(int i=0;i<N;++i){
        cin>>w[i]>>v[i];
    }
    ll m=w[0];
    for(int i=0;i<N;++i){
        w[i]-=m;
    }
    ll DP[N+1][N+1][301];
    for(int i=0;i<=N;++i){
        for(int j=0;j<=N;++j){
            for(int k=0;k<=300;++k){
                DP[i][j][k]=0;
            }
        }
    }
    for(int i=0;i<N;++i){
        for(int j=0;j<=N;++j){
            for(int k=0;k<=300;++k){
                DP[i+1][j][k]=max(DP[i+1][j][k],DP[i][j][k]);
                if(j>0&&k>=w[i]){
                    DP[i+1][j][k]=max(DP[i+1][j][k],DP[i][j-1][k-w[i]]+v[i]);
                }
            }
        }
    }
    ll ans=0;
    for(int j=0;j<=N;++j){
        for(int k=0;k<=300;++k){
            if(j*m+k<=W) ans=max(ans,DP[N][j][k]);
        }
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 27568
#include <iostream>
#include <iomanip>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <algorithm>
#include <cmath>
#include <climits>
#include <math.h>
#include <bitset>

#define P pair
#define X first
#define Y second
#define VSORT(v) sort(v.begin(), v.end())
#define VREV(v) reverse(v.begin(), v.end())
#define VMAX_P(v) max_element(v.begin(), v.end())
#define VMIN_P(v) min_element(v.begin(), v.end())
#define VMAX_IDX(v) distance(v.begin(), VMAX_P(v))
#define VMIN_IDX(v) distance(v.begin(), VMIN_P(v))
#define VCOPY(src, dst) copy(src.begin(), src.end(), back_inserter(dst))
#define SUPPER(src, dst) transform(src.begin(), src.end(), dst.begin(), toupper);
#define SLOWER(src, dst) transform(src.begin(), src.end(), dst.begin(), tolower);

using namespace std;
using ll = long long;

void displayVec(vector<int> v)
{
    for (int i = 0; i < v.size(); i++)
    {
        cout << v[i] << endl;
    }
    cout << endl;
}

int binarySearch(vector<int> v, int target)
{
    int left = -1;
    int right = v.size();

    while (right - left > 1)
    {
        int mid = left + (right - left) / 2;

        if (v[mid] >= target)
        {
            right = mid;
        }
        else
        {
            left = mid;
        }
    }

    if (right < v.size() && v[right] == target)
    {
        return right;
    }
    return -1;
}

int countDays(int year, int month, int day)
{
    int days[12] = {31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
    int cnt = day;

    if (month == 1)
    {
        return cnt;
    }

    for (int i = 0; i < month - 1; i++)
    {
        cnt += days[i];
    }

    if (month >= 3 && ((year % 4 == 0 && year % 100 != 0) || year % 400 == 0))
    {
        cnt++;
    }

    return cnt;
}

int main(int argc, const char *argv[])
{
    int n;
    vector<int> a(n), b(n - 1);

    cin >> n;
    for (int i = 0; i < n - 1; i++)
    {
        cin >> b[i];
    }

    a[0] = b[0];
    a[n - 1] = b[n - 2];
    for (int i = 1; i < n - 1; i++)
    {
        a[i] = min(b[i], b[i - 1]);
    }

    ll sum = 0;
    for (int i = 0; i < n; i++)
    {
        sum += a[i];
    }
    cout << sum << endl;
}


Measured memory_bytes: 512
#include <algorithm>
#include <iostream>

using namespace std;
typedef long long lint;

lint N, A, B;
lint ans;

void resolve()
{
    cin >> N >> A >> B;
    if ((B - A) % 2 == 1) {
        ans = min(B - 1, N - A);
        ans = min(ans, ((A - 1) + (B - 1) + 1) / 2);
        ans = min(ans, ((N - A) + (N - B) + 1) / 2);
    } else {
        ans = (B - A) / 2;
    }
    cout << ans << endl;
}

int main()
{
    resolve();
    return 0;
}


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


public class A
{
	public static void Main()
	{
		long S = GetLong();
		long mod = (long)1e9;
		long x = (mod - (S % mod)) % mod;
		long y = (S + x) / mod;
		Console.WriteLine($"0 0 {mod} 1 {x} {y}");
	}
}


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

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

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

Measured memory_bytes: 13140
#include<stdio.h>
int main(){
  int n,h,w,i;
  int a,b,count;
  scanf("%d %d %d",&n,&h,&w);
  for(i=0;i<n;i++){
    scanf("%d %d",&a,&b);
    if(a>=h && b>=w){
      count++;
    }
  }
  printf("%d\n",count);
  return 0;
}


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

int main()
{
    //freopen("a.inp","r",stdin);

    string a, b; int ans = 0;
    cin >> a >> b;
    for(int i=0; i<3; ++i) ans += a[i] == b[i];
    cout << ans;
}


Measured memory_bytes: 764
#https://atcoder.jp/contests/dp/tasks/dp_f
s = str(input())
t = str(input())
dp = [[0 for _ in range(len(t) + 1)] for _ in range(len(s) + 1)]

for i in range(len(s)):
    for j in range(len(t)):
        if s[i] == t[j]:
            dp[i + 1][j + 1] = dp[i][j] + 1
        dp[i + 1][j + 1] = max(dp[i + 1][j + 1], dp[i + 1][j], dp[i][j + 1])

ans = ''
i = len(s)
j = len(t)

while i > 0 and j > 0:
    if dp[i][j] == dp[i - 1][j]:
        i -= 1
    elif dp[i][j] == dp[i][j - 1]:
        j -= 1
    else:
        ans = s[i - 1] + ans
        i -= 1
        j -= 1

print(ans)

Measured memory_bytes: 120412
#include <algorithm>
#include <array>
#include <bitset>
#include <cassert>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <functional>
#include <iostream>
#include <map>
#include <memory>
#include <numeric>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <unordered_map>
#include <vector>

using namespace std;

typedef long long lint;

int main() {
  int n;
  scanf("%d", &n);
  vector<int> sides(n);
  for (int i = 0; i < n; ++i)
    scanf("%d", &sides[i]);
  sort(sides.rbegin(), sides.rend());
  vector<int> lengths;
  for (int j = 0, i = j; i < (int)sides.size(); i = j) {
    while (j < (int)sides.size() && sides[j] == sides[i]) ++j;
    int length = sides[i], many = j - i;
    while (lengths.size() < 2 && many >= 2) {
      lengths.push_back(length);
      many -= 2;
    }
  }
  if (lengths.size() == 2) printf("%lld\n", (lint)lengths[0] * lengths[1]);
  else printf("0\n");
  return 0;
}


Measured memory_bytes: 640
n = int(input())
mozi = list()
for i in range(n):
    mozi.append(input())

di = dict()
for i in mozi:
    if (i in di.keys()):
        di[i] += 1
    else :
        di[i] = 1

m = max(di.values())
di = sorted(di.items())

for i in di:
    if (i[1] == m):
        print(i[0])

Measured memory_bytes: 43920
N=int(input())
l=[int(i) for i in input().split()][:N]
arr=[-1]*N
arr[0]=l[0]
for i in range(1,N):
    arr[i]=arr[i-1]+l[i]
cnt=0
for i in range(N-1):
    cnt+=(l[i]*(arr[-1]-arr[i]))%1000000007
print(cnt%1000000007)

Measured memory_bytes: 31588
#include<bits/stdc++.h>
using namespace std;
struct edge
{
	int x,y;
}e[200010];
int n,dep[200010],d[200010],sx,sy,fa[200010];
bool used[200010],vis[200010];
int cnt,head[200010],to[400010],nxt[400010];
vector<int> v[200010];
queue<int> q;
void add(int x,int y)
{
	cnt++;
	to[cnt]=y;
	nxt[cnt]=head[x];
	head[x]=cnt;
}
void dfs(int x)
{
	for (int i=head[x];i;i=nxt[i])
	{
		int y=to[i];
		if (y==fa[x])
		{
			continue;
		}
		fa[y]=x;
		dep[y]=dep[x]+1;
		dfs(y);
	}
}
bool check(int x,int y)
{
	if (dep[x]>dep[y])
	{
		swap(x,y);
	}
	if (x==fa[y] || x==fa[fa[y]])
	{
		return true;
	}
	if (fa[x]==fa[y])
	{
		return true;
	}
	return false;
}
int main()
{
	scanf("%d%d%d",&n,&sy,&sx);
	for (int i=1;i<n;i++)
	{
		int x,y;
		scanf("%d%d",&e[i].x,&e[i].y);
	}
	for (int i=1;i<n;i++)
	{
		int x,y;
		scanf("%d%d",&x,&y);
		add(x,y);
		add(y,x);
	}
	dep[sx]=1;
	dfs(sx);
	for (int i=1;i<n;i++)
	{
		int x,y;
		x=e[i].x;
		y=e[i].y;
		if (!check(x,y))
		{
			used[x]=used[y]=true;
		}
		else
		{
			//cerr<<x<<" "<<y<<endl;
			v[x].push_back(y);
			v[y].push_back(x);
		}
	}
	memset(d,-1,sizeof(d));
	d[sy]=1;
	vis[sy]=true;
	q.push(sy);
	while (!q.empty())
	{
		int x=q.front();
		q.pop();
		for (int i=0;i<v[x].size();i++)
		{
			int y=v[x][i];
			if (d[y]!=-1)
			{
				continue;
			}
			d[y]=d[x]+1;
			if (d[y]<dep[y])
			{
				//cerr<<y<<endl;
				vis[y]=true;
				q.push(y);
			}
		}
	}
	int mx=0;
	for (int i=1;i<=n;i++)
	{
		if (used[i] && vis[i])
		{
			puts("-1");
			return 0;
		}
		if (vis[i])
		{
			mx=max(mx,dep[i]);
		}
	}
	cout<<(mx-1)*2<<endl;
	return 0;
}
//初见你时你给我你的心，里面是一个春天的早晨。
//再见你时你给我你的话，说不出的是炽烈的火夏。
//三次见你你给我你的手，里面藏着个叶落的深秋。
//最后见你是我做的短梦，梦里有你还有一群冬风。
//——《季候》

Measured memory_bytes: 24704
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Contest
{
    class Scanner
    {
        private string[] line = new string[0];
        private int index = 0;
        public string Next()
        {
            if (line.Length <= index)
            {
                line = Console.ReadLine().Split(' ');
                index = 0;
            }
            var res = line[index];
            index++;
            return res;
        }
        public int NextInt()
        {
            return int.Parse(Next());
        }
        public long NextLong()
        {
            return long.Parse(Next());
        }
        public string[] Array()
        {
            line = Console.ReadLine().Split(' ');
            index = line.Length;
            return line;
        }
        public int[] IntArray()
        {
            return Array().Select(int.Parse).ToArray();
        }
        public long[] LongArray()
        {
            return Array().Select(long.Parse).ToArray();
        }
    }

    class Program
    {


        public void Solve()
        {
          
            var sc = new Scanner();
            Console.WriteLine($"{sc.Next()[0]}{sc.Next()[0]}{sc.Next()[0]}");
        }



        static void Main(string[] args)
        {
            new Program().Solve();
        }
    }
}

Measured memory_bytes: 13140
#include <stdio.h>
#include <iostream>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <string>
#include <sstream>
#include <memory.h>
#include <time.h>
#include <stdlib.h>
#include <assert.h>
#include <algorithm>
using namespace std;
typedef long long ll;
int n, A, v[50];
ll dp[50][51][50 * 50 + 1];
ll calc(int i, int rem, int s) {
	if (!rem)
		return !s;
	if (i == n || s <= 0)
		return 0;
	ll &ret = dp[i][rem][s];
	if (ret != -1)
		return ret;
	ret = calc(i + 1, rem, s);
	ret += calc(i + 1, rem - 1, s - v[i]);
	return ret;
}
int main()
{
	scanf("%d%d", &n, &A);
	for (int i = 0; i < n; ++i)
		scanf("%d", v + i);
	memset(dp, -1, sizeof(dp));
	ll res = 0;
	for (int i = 0; i < n; ++i)
		res += calc(0, i + 1, (i + 1)*A);
	cout << res << endl;
	return 0;
}

Measured memory_bytes: 50048
#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
typedef pair<int, int> P;
template<typename T> inline void chkmin(T &a, const T &b) { a = a < b ? a : b; }
template<typename T> inline void chkmax(T &a, const T &b) { a = a > b ? a : b; }

const int MAXN = 200005, MAXT = 1 << 19, MOD = 1e9 + 7;
inline int add(int a, int b) { a += b - MOD; return a + (a >> 31 & MOD); }
LL modpow(LL a, int b) {
	LL res = 1;
	for (; b; b >>= 1) {
		if (b & 1) res = res * a % MOD;
		a = a * a % MOD;
	}
	return res;
}

int sum[MAXT], cnt[MAXT], tag[MAXT], A[MAXN], suf[MAXN], n;
vector<int> pla[MAXN];
void push_up(int k) {
	sum[k] = add(sum[k << 1], sum[k << 1 | 1]);
	cnt[k] = cnt[k << 1] + cnt[k << 1 | 1];
}
void cover(int k, int t) {
	tag[k] = (LL)tag[k] * t % MOD;
	sum[k] = (LL)sum[k] * t % MOD;
}
void push_down(int k) {
	if (tag[k] == 1) return;
	int &t = tag[k];
	cover(k << 1, t), cover(k << 1 | 1, t);
	t = 1;
}

void modify(int p, int x, int l = 1, int r = n, int k = 1) {
	if (l == r) { sum[k] = x, cnt[k] = 1; return; }
	int mid = (l + r) >> 1;
	push_down(k);
	if (p <= mid) modify(p, x, l, mid, k << 1);
	else modify(p, x, mid + 1, r, k << 1 | 1);
	push_up(k);
}

int query(int a, int b, int l = 1, int r = n, int k = 1) {
	if (a > r || b < l) return 0;
	if (a <= l && b >= r) return sum[k];
	int mid = (l + r) >> 1;
	push_down(k);
	return add(query(a, b, l, mid, k << 1), query(a, b, mid + 1, r, k << 1 | 1));
}

int gsum(int a, int b, int l = 1, int r = n, int k = 1) {
	if (a > r || b < l) return 0;
	if (a <= l && b >= r) return cnt[k];
	int mid = (l + r) >> 1;
	return gsum(a, b, l, mid, k << 1) + gsum(a, b, mid + 1, r, k << 1 | 1);
}

int main() {
	fill(tag, tag + MAXT, 1);
	scanf("%d", &n);
	if (n == 1) return puts("0"), 0;
	for (int i = 1; i <= n; i++) {
		scanf("%d", A + i);
		++suf[A[i]];
		pla[A[i]].push_back(i);
	}
	for (int i = n; i > 0; i--) suf[i] += suf[i + 1];
	LL prod = 1, ans = 0;
	const LL inv2 = (MOD + 1) / 2;
	for (int i = 1; i <= n; i++) {
		suf[i] -= n - i;
		if (suf[i] <= 0) return puts("0"), 0;
		prod = prod * suf[i] % MOD;
	}
	for (int i = n; i > 0; i--) {
		LL mul = (suf[i] - 1) * modpow(suf[i], MOD - 2) % MOD;
		for (int j : pla[i])
			ans = (ans + prod * gsum(1, j) + (query(j, n) - query(1, j) + MOD) * inv2) % MOD;
		int sz = pla[i].size();
		ans = (ans + (LL)sz * (sz - 1) / 2 % MOD * prod % MOD * inv2) % MOD;
		for (int j : pla[i]) modify(j, prod);
		cover(1, mul);
	}
	printf("%lld\n", ans);
	return 0;
}

Measured memory_bytes: 18944
#include <stdio.h>
#include <string.h>
#include <stdbool.h>

#define M (244140624 / 13)
#define L 13

bool isExist[M][L] = {{false}};

void insert(char *in_str);
bool find(char *target_str);

int num_inserted = 0;

int main(void)
{
    int num_op;
    scanf("%d", &num_op);

    char op[6];
    char word_str[13];

    while (num_op--) {
        scanf("%s %s", op, word_str);
        if (strcmp(op, "insert") == 0) {
            insert(word_str);
        } else if (strcmp(op, "find") == 0) {
            if (find(word_str)) {
                printf("yes\n");
            } else {
                printf("no\n");
            }
        } else {
            printf("ERROR! Wrong operation.\n");
        }
    }

    return 0;
}

int char2int(char in);
long str2long(char *in_str);

long hashFunc1(long in);
int hashFunc2(long in);

void insert(char *in_str)
{
    if (find(in_str) == false) {
        long in_long = str2long(in_str);
        long hash1 = hashFunc1(in_long);
        int hash2 = hashFunc2(in_long);
        isExist[hash1][hash2] = true;
    }
}

int char2int(char in)
{
    if (in == 'A') {
        return 1;
    } else if (in == 'C') {
        return 2;
    } else if (in == 'G') {
        return 3;
    } else if (in == 'T') {
        return 4;
    } else {
        printf("ERROR! Wrong character.\n");
        return -1;
    }
}

long str2long(char *in_str)
{
    int i;

    int p = 1;
    int in_long = 0;
    for (i = 0; i < (int)(strlen(in_str)); i++) {
        in_long += p * char2int(in_str[i]);
        p *= 5;
    }

    return in_long;
}

long hashFunc1(long in)
{
    return (in % M);
}

int hashFunc2(long in)
{
    return (in % L);
}

bool find(char *target_str)
{
    long target_long = str2long(target_str);
    long hash1 = hashFunc1(target_long);
    int hash2 = hashFunc2(target_long);
    return isExist[hash1][hash2];
}

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

typedef unsigned long long ull;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<double, double> pdd;
const ull mod = 1e9 + 7;
#define REP(i,n) for(int i=0;i<(int)n;++i)

//debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

template<class S, class T> ostream& operator << (ostream& os, const pair<S, T> v){
  os << "(" << v.first << ", " << v.second << ")"; return os;
}
template<class T> ostream& operator << (ostream& os, const vector<T> v){
  for(int i = 0; i < v.size(); i++){if(i > 0){os << " ";} os << v[i];} return os;
}
template<class T> ostream& operator << (ostream& os, const vector<vector<T>> v){
  for(int i = 0; i < v.size(); i++){if(i > 0){os << endl;} os << v[i];} return os;
}

ll calc(vector<ll> &x, ll m){
	ll res = 0;
	REP(i, x.size()) res += abs(x[i]-m);
	return res;
}

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

    ll N;
    cin >> N;
    vector<ll> A(N);
    REP(i, N) cin >> A[i];

    REP(i, N) A[i] -= i;
    sort(A.begin(), A.end());
    ll mi = (1ll << 60);
    
    mi = min(calc(A, A[N/2]), mi);
    cout << mi << endl;
    return 0;
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
 
using namespace std;
using ll=long long;
 
int main() {
    ll N;
    cin >> N;
    ll A[200000] = {};
    ll cnt[200001] = {};
    for (int i = 0; i < N; ++i) {
        cin >> A[i];
        cnt[A[i]]++;
    }
 
    ll res = 0;
    ll comb = 0;
    for (int i = 1; i <= N; ++i) {
        comb += (cnt[i] * (cnt[i] - 1)) / 2;
    }
    for (int k = 0; k < N; ++k) {
        res = comb - (cnt[A[k]] - 1);
        cout << res << endl;
    }
 
    return 0;
}

Measured memory_bytes: 5760
#include <iostream>

using namespace std;

int main(int argc, char *argv[]) {
	int A, B, C;
	cin >> A >> B >> C;
	int cnt[11] = {};
	cnt[A]++; cnt[B]++; cnt[C]++;
	if (cnt[5] == 2 && cnt[7] == 1) printf("YES\n");
	else printf("NO\n");
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<boost/algorithm/string/replace.hpp>
#include<boost/multiprecision/cpp_int.hpp>
using namespace std;
using namespace boost::algorithm;
using namespace boost::multiprecision;
 
#define rep(i,n) for(int i=0 ; i<(n) ; i++)
#define repr(i,n) for(int i=(n) ; i>=0 ; i--)
#define ALL(x) (x).begin(),(x).end()

typedef long long ll;
typedef unsigned long long ull;
 
const ll INF = 1LL<<60;
const int mINF = 1e9;
const int MOD = 1e9+7;

template<typename T> bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<typename T> bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

template<typename T>
T GCD(T a,T b){ return b ? GCD(b,a%b) : a ;}
template<typename T>
T LCM(T a,T b){ return a*b / GCD(a,b) ;}

template<typename T>//文字列の置換/Boost:replace_all()
T replace_str(T str, string target, string str_to) {
    string::size_type pos = 0;
    while (pos = str.find(target, pos), pos != string::npos) {
        str.replace(pos, target.length(), str_to);
        pos += str_to.length();
    }
    return str;
}

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

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

int main(){
    string S,T;
    while(cin >> S >> T, S != "0" && T != "0"){
        set<char> st;
        for(char& c : S) st.insert(c);

        int hit = 0;
        int blow = 0;
        for(int i = 0; i < T.size(); i++){
            if(S[i] == T[i]) hit++;
            else blow += st.count(T[i]);
        }

        cout << hit << " " << blow << endl;
    }
}


Measured memory_bytes: 3108
#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;



#define SIZE 200005

ll N;
ll W[SIZE];
ll ans;
vector<int> G[SIZE],ADJ[SIZE];

ll extgcd(ll a,ll b,ll &x,ll &y){
	ll d = a;
	if(b != 0){
		d = extgcd(b,a%b,y,x);
		y -= (a/b)*x;
	}else{
		x = 1;
		y = 0;
	}
	return d;
}

ll mod_pow(ll x,ll count, ll mod){

	if(count == 0)return 1;
	ll ret = mod_pow((x*x)%mod,count/2,mod);
	if(count%2 == 1){

		ret = (ret*x)%mod;
	}
	return ret;
}


ll mod_inverse(ll a,ll m){
    ll x,y;
    extgcd(a,m,x,y);
    return (m+x%m)%m;
}


ll dfs(int node_id,int pre){

	ll ret = 1; //部分木のサイズ
	ll tmp;

	for(int i = 0; i < G[node_id].size(); i++){

		int child = G[node_id][i];
		if(child == pre)continue;

		tmp = dfs(child,node_id);
		ret += tmp;

		ADJ[node_id].push_back(tmp); //子の部分木のサイズ
	}

	if(pre != -1){

		ADJ[node_id].push_back(N-ret); //根方向の部分木のサイズ
	}

	//余事象(含まれない数を数え上げ、それを全体から引く)で、node_idが白としてSに含まれる場合の数を求める
	tmp = mod_pow(2,N-1,MOD); //自分のノードは白、自分以外は2^(N-1)通り
	tmp--; //全て白
	if(tmp < 0){

		tmp += MOD;
	}

	for(int i = 0; i < ADJ[node_id].size(); i++){

		ll work = mod_pow(2,ADJ[node_id][i],MOD); //部分木に少なくとも1つ黒があり、他の部分木が全て白
		work--; //黒を含む部分木が全て白の場合を除く
		if(work < 0){

			work += MOD;
		}
		tmp -= work;
		if(tmp < 0){

			tmp += MOD;
		}
	}

	ans += tmp;
	ans %= MOD;

	return ret;
}

int main(){

	scanf("%lld",&N);

	int from,to;

	for(int i = 0; i < N-1; i++){

		scanf("%d %d",&from,&to);
		from--;
		to--;

		G[from].push_back(to);
		G[to].push_back(from);
	}

	ans = 0;
	dfs(0,-1);

	ll mult = mod_pow(2,N,MOD);
	mult = mod_inverse(mult,MOD);

	ans *= mult;
	ans %= MOD;

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

	return 0;
}


Measured memory_bytes: 36352
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define endl "\n"

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(0);
    
    bool u[105] = {false};
    int a[105], x, n, ans, ans1;
    cin >> x >> n;
    for(int i = 0; i < n; i++){
        cin >> a[i];
        u[a[i]] = true;
    }
    if(u[x] == false){
        cout << x;
    }
    else{
        int trex = x - 1;
        int crex = x + 1;
        while(true){
            if(u[trex] == false){
                ans = abs(trex - x);
                break;
            }
            trex--;
        }
        while(true){
            if(u[crex] == false){
                ans1 = abs(crex - x);
                break;
            }
            crex++;
        }
        if(ans <= ans1){
            cout << trex;
        }
        else{
            cout << crex;
        }
    }

    return 0;
}

Measured memory_bytes: 3636
use std::io::prelude::*;

fn input<T: std::str::FromStr>() -> T {
    let stdin = std::io::stdin();
    let token: String = stdin
        .lock()
        .bytes()
        .map(|c| c.unwrap() as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().unwrap()
}

fn main() {
    let w: i32 = input();
    let h: i32 = input();
    let x: i32 = input();
    let y: i32 = input();

    println!(
        "{} {}",
        w as f64 * h as f64 * 0.5,
        if 2 * x == w && 2 * y == h { 1 } else { 0 }
    );
}


Measured memory_bytes: 4352
import java.io.*;

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

        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        String num1 = br.readLine();
        String[] num2 = num1.split(" ");

        int a = Integer.parseInt(num2[0]);
        int b = Integer.parseInt(num2[1]);
        int c = Integer.parseInt(num2[2]);
        int count = 0;

        for(int i=a; i<=b; i++){
            if(c % i == 0){
                count++;
            }
        }

        System.out.println(count);
    }
}

Measured memory_bytes: 24344
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
int main() {
    long n,ans=0;
    cin >> n;
    int a[n];
    map<int,int> mp;
    rep(i,n){
        cin >> a[i];
        ans += mp[i-a[i]];//iよりも前の番号で加算されていれば答えに足す
        mp[i+a[i]]++;
    }
    cout << ans << endl;
}

Measured memory_bytes: 21472
#include <bits/stdc++.h>
//----***やべーやつら***----
using namespace std;
#define int long long

//----***型定義***----
using ll = long long;
using P = pair<int,int>;

//----***Like a Pythonista***----
#define REP(ii,jj,nn) for (ll ii=jj;ii<(nn);ii++)
#define RREP(ii,nn,jj) for (ll ii = nn; jj<ii;ii--)
#define each(i,...) for (auto&& i:__VA_ARGS__)
#define ALL(vec) (vec).begin(),(vec).end()
#define sum(...) accumulate(ALL(__VA_ARGS__),0LL)
#define dsum(...) accumulate(ALL(__VA_ARGS__),0.0)
#define vec(type,name,...) vector<type> name(__VA_ARGS__)
template<class T> inline auto max(const T& a){ return *max_element(ALL(a)); }
template<class T> inline auto min(const T& a){ return *min_element(ALL(a)); }
inline ll gcd(ll a,ll b){if(b == 0) return a;return  gcd(b,a%b);}
inline ll lcm(ll a,ll b){ll g = gcd(a,b);return a / g * b;}

//----***定数***----
#define MOD 1000000007
#define INF 100000000000000000
#define EPS 1e-9
const vector<vector<int>> DXY={{-1,0},{1,0},{0,-1},{0,1}};

//----***パーツ***----
#define fi first
#define se second
#define pb push_back
#define re return
#define br break

//----***入出力***---
void print() { std::cout << "\n"; }
template <class T>void print(const T &x) {std::cout << x<<"\n";}
template <class T, class... Args>void print(const T &x, const Args &... args) {std::cout << x << " ";print(args...);}
#define debug(var)  do{std::cerr << #var << " ↓ "<<"\n";view(var);}while(0);
#define dbg cerr<<"🥺🥺🥺🥺🥺🥺"<<endl;
template<typename T> void view(T e){std::cout << e << std::endl;}
template<typename T> void view(const std::vector<T>& v){for(const auto& e : v){ std::cout << e << " "; } std::cout << std::endl;}
template<typename T> void view(const std::vector<std::vector<T> >& vv){ for(const auto& v : vv){ view(v); } }

//----***初期時読み込み***----
struct initial{initial(){cin.tie(0); ios::sync_with_stdio(0); cout<<fixed<<setprecision(15);};}initial_;

signed main(){
  int H,W;cin>>H>>W;
  string S;
  REP(w,0,W+2){
    cout<<'#';
  }
  cout<<"\n";
  REP(h,0,H){
    cin>>S;
    cout<<'#'<<S<<'#'<<"\n";
  }
  REP(w,0,W+2){
    cout<<'#';
  }
  cout<<"\n";

}


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

N, M = [int(x) for x in input().strip().split()]

K = [0] * M
S = [0] * M
P = [0] * M

for i in range(M):
    t_ = [int(x) for x in input().strip().split()]
    K[i], S[i] = t_[0], t_[1:]

P = [int(x) for x in input().strip().split()]

def check(sw, s, p, M):
    for m in range(M):
        if sum([sw[i-1] for i in s[m]]) % 2 != p[m]:
            return 0
    else:
        return 1

def f(sw, s, p, M, i, K, N):
    if i == N:
        return check(sw, s, p, M)
    ans = 0
    for j in (0, 1):
        sw_ = sw[:]
        sw_[i] = j
        ans += f(sw_[:], s, p, M, i+1, K, N)
    return ans

print(f([0 for _ in range(N)], S, P, M, 0, K, N))

Measured memory_bytes: 3188
#include<stdio.h>
#include<string.h>
int main(){
	int n;
	scanf("%d" , &n);
	char str[n];
	scanf("%s" , &str);
	if(n%2 == 1){
		printf("No\n");
		return 0;
	}
	for(int i = 0 ; i < n / 2 ; i++){
		if(str[i] == str[i + n / 2]){
			continue;
		}
		else{
			printf("No\n");
			return 0;
		}
	}
	printf("Yes\n");
	return 0;
}

Measured memory_bytes: 1664
#include <bits/stdc++.h>
using namespace std;
const int maxn = 2e5 + 5;
int a[maxn], b[maxn];
int main(){
    int n;
    cin >> n;
    for(int i = 1; i <= n; i ++) cin >> a[i];
    for(int i = 1; i <= n; i ++) cin >> b[n-i+1];
    int ok = 0;
    for(int i = 1; i <= n; i ++){
        if(a[i] != b[i]) continue;
        int f = 0;
        for(int j = 1; j <= n; j ++){
            if(a[i] != b[j] && a[j] != b[i]){
                f = 1;
                swap(b[i], b[j]);
                break;
            }
        }
        if(!f){
            ok=1;
            break;
        }
    }
	
    if(ok==1){
        cout << "No" << endl;
    }else{
		cout << "Yes" << endl;
		for(int i = 1; i <= n; i ++){
			if(i != 1)cout << " ";
			cout << b[i];
		}
    	cout << endl;
	}
    return 0;
}


Measured memory_bytes: 5132
using System;
using System.Linq;

namespace ABC172B
{
    class Program
    {
        static void Main(string[] args)
        {
            var s = Console.ReadLine();
            var t = Console.ReadLine();

            var sList = s.ToCharArray().Select(x => x.ToString()).ToList();
            var tList = t.ToCharArray().Select(x => x.ToString()).ToList();
            var count = 0;
            for (var i = 0; i < s.Length; i++)
            {
                if(sList[i] != tList[i])
                {
                    count++;
                }
            }
            Console.WriteLine(count);
        }
    }
}


Measured memory_bytes: 41816