akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;

int main(){
  int N, ans = 100;
  cin >> N;
  
  for (int i = 0; i < N; i++ ){
    int A, count = 0;
    cin >> A;
    
    //Aを２で何度も割る
    while (A%2 == 0){
      count++;
      A /= 2;
      if(A%2 != 0){
        break;
      }
    }
    
    //count が小さいものを代入する
    if (min(ans, count) == count){
      ans = count;
    }
  }
  
  cout << ans << endl;
}
      

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

int main(){
    int L,R,D;
    cin >> L >> R >> D;
    ll ans = 0;
    for(int i=L;i<=R;i++){
        if(i%D==0) ans++;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3632
n = gets.chomp.split[0].to_i
edge = []
near = Array.new(n).map{Array.new}
degree = Array.new(n).map{Array.new(2,0)}
node = Array.new(n,0)

for i in 1..n-1
    input = gets.chomp.split(" ").map(&:to_i)
    a = input[0]
    b = input[1]
    edge.push(input)
    near[a-1].push(b)
    degree[a-1][1] += 1
    near[b-1].push(a)
    degree[b-1][1] += 1
    degree[i-1][0] = i
end

degree[n-1][0] = n

degree.sort! {|a,b| b[1] <=> a[1]}
c = gets.chomp.split(" ").map(&:to_i)
c.sort!.reverse!

stack = [degree[0][0]]
cnt = 0

while stack.size > 0
    tar = stack.shift
    node[tar-1] = c[cnt]
    cnt += 1
    points = near[tar-1]
    for nxt in points do
        if node[nxt-1] == 0
            stack.push(nxt)
        end
    end
end


score = 0
for i in 1..n-1 do
    a,b = edge[i-1]
    score += [node[a-1],node[b-1]].min
end

p score
for i in 1..n-1 do
    print node[i-1], " "
end
puts node[n-1]

Measured memory_bytes: 4600
package main

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

var sc = bufio.NewScanner(os.Stdin)
var out = bufio.NewWriter(os.Stdout)

func next() string {
	sc.Scan()
	return sc.Text()
}
func nextInt() int {
	a, _ := strconv.Atoi(next())
	return a
}
func nextInts(n int) []int {
	ret := make([]int, n)
	for i := 0; i < n; i++ {
		ret[i] = nextInt()
	}
	return ret
}
func nextInt64() int64 {
	a, _ := strconv.ParseInt(next(), 10, 64)
	return a
}
func readLine(reader *bufio.Reader) string {
	str, _, err := reader.ReadLine()
	if err == io.EOF {
		return ""
	}
	return string(str)
}

func round(f float64) float64 {
	return math.Floor(f + .5)
}

func main() {
	defer out.Flush()
	sc.Split(bufio.ScanWords)
	n := nextInt()
	subMap := map[int]int{}
	for i := 0; i < n-1; i++ {
		subMap[nextInt()]++
	}
	for i := 1; i <= n; i++ {
		count, ok := subMap[i]
		if ok {
			fmt.Fprintln(out, fmt.Sprint(count))
		} else {
			fmt.Fprintln(out, fmt.Sprint(0))
		}
	}
}


Measured memory_bytes: 15268
#include <cstdio>
#include <cstring>
#include <cmath>
#include <utility>
#include <iostream>
#include <functional>
#include <bitset>
#include <algorithm>
#include <vector>
#include <forward_list>
#include <set>
#include <map>
#include <queue>
#include <deque>
#include <stack>
#include <tuple>
#include <numeric>
#define rep(i, s, g) for ((i) = (s); (i) < (g); ++(i))
using namespace std;
using ll = long long;
using P = pair<ll, ll>;
const ll MOD = 1e9 + 7;
const ll INF = (1ll << 60);

int main(void)
{
    int n;
    cin >> n;

    int cnt = 0;
    bool flag = false;

    for (int i = 0; i < n; i++)
    {
        int x, y;
        cin >> x >> y;

        if (x == y)
        {
            cnt++;

            if (cnt == 3)
            {
                flag = true;
            }
        }
        else
        {
            cnt = 0;
        }
    }

    if (flag)
    {
        cout << "Yes" << endl;
    }
    else
    {
        cout << "No" << endl;
    }
}


Measured memory_bytes: 3632
#include <iostream>
#include <cmath>
using namespace std;
typedef long long ll;
ll euclid(ll x,ll y){
  if (y) return euclid(y,x%y);
  else return x;
}
int main(){
  ll a,b,c,d;
  cin >> a >> b >> c >> d;
  ll cnt1=b/c,cnt2=b/d;
  ll l=c*d/euclid(c,d);
  ll cnt3=b/l;
  ll cnt4=(a-1)/c,cnt5=(a-1)/d,cnt6=(a-1)/l;
  cout << b-(cnt1+cnt2-cnt3)-(a-1-(cnt4+cnt5-cnt6)) << endl;
  return 0;
}

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

int main() {
  int N;
  cin >> N;
  deque<int> dq;
  auto m = N % 2;
  int a;
  for(int i = 0; i < N; ++i) {
    cin >> a;
    if(i % 2 == m) {
      dq.push_back(a);
    } else {
      dq.push_front(a);
    }
  }

  for(auto a : dq) {
    cout << a << " ";
  }
  cout << endl;
  return 0;
}

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

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(v) v.begin(), v.end()
#define SP << " " 
#define LLi long long int

using namespace std;

int imax=2147483647;
long long int llimax=9223372036854775807;

//int型vectorを出力
void PV(vector<int> pvv) {
	rep(i, pvv.size()) cout << pvv[i] SP;
	cout << endl;
}

//LLi型vectorを出力
void PVL(vector<LLi> pvv) {
	rep(i, pvv.size()) cout << pvv[i] SP;
	cout << endl;
}

int main(){

	int n, ans=0;

	cin>> n;

	for(int i=1;i<n;i++){
		ans+=(n-1)/i;
	}

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

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

using namespace std;

typedef long long LL;
typedef pair<int, int> PII;


int main() {
    ios_base::sync_with_stdio(false);
    LL n, m;
    cin >> n >> m;
    if (m >= n*2) {
        LL ans = 0;
        m-=(n*2);
        ans+=n;
        m/=4;
        ans+=m;
        cout << ans << endl;
    } else {
        cout << m / 2 << endl;
    }
    return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner s = new Scanner(System.in);
		long a = s.nextLong();
		long b = s.nextLong();
		s.close();
		long disA = 0;
		long disB = 0;

		if(a < 0) {
			disA = a * -1;
		}else {
			disA = a;
		}
		if(b < 0) {
			disB = b * -1;
		}else {
			disB = b;
		}

		long judge = (disA + disB) % 2;
		if(judge == 1) {
			System.out.println("IMPOSSIBLE");
		}else {
			long disC = (disA + disB)/2;
			System.out.println(disC);
		}

	}

}


Measured memory_bytes: 22740
#include<cstdio>

long long  x;
long long ans,a,b;

int main()
{
	scanf("%lld",&x);
	if(x > 6){
		a = x / 11;
	}
	else{
		printf("1\n");
		return 0;
	}
	b = x % 11;
	if(b > 6) ans = 2;
	else if(b == 0) ans = 0;
	else ans = 1;
	ans += 2 * a;
	printf("%lld\n",ans);
}

Measured memory_bytes: 128
#include <iostream>
#include <algorithm>
using namespace std;
int main(void) {
  int k, s;
  cin >> k >> s;
  int ans = 0;
  int xmin = max(0, s - 2 * k);
  int xmax = min(k, s);
  for (int i = xmin; i <= xmax; i++) {
    int ymin = max(0, s - i - k);
    int ymax = min(k, s - i);
    ans += ymax - ymin + 1;
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ

		Scanner scanner = new Scanner(System.in);
		
		//入力表示
		 int N= scanner.nextInt();
		 int ans = (N + 1) / 2; 
		 
		 //計算表示
		System.out.println(ans); 
		
		scanner.close();
	}
}

Measured memory_bytes: 20948
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text.RegularExpressions;
using static System.Console;

class Program
{
    static void Main(string[] args)
    {
        var N = int.Parse(ReadLine());
        var S = ReadLine();

        var r = new Regex("ABC");

        var mc = r.Matches(S);

        var ans = mc.Count;

        WriteLine(ans);
    }
}


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

/* 大文字を小文字に変換 */
char tolower(char c) {return (c + 0x20);}
/* 小文字を大文字に変換 */
char toupr(char c) {return (c - 0x20);}

// if('A'<=s[i] && s[i]<='Z') s[i] += 'a'-'A';

/*
string s = "abcdefg"
s.substr(4) "efg"
s.substr(0,3) "abc"
s.substr(2,4) "cdef"

// イテレータ要素のインデックス
distance(A.begin(), itr);
*/

int main()
{
    int N, K; cin >> N >> K;
    vector<tuple<int, int> > T;
    for(int i=2; i<=N; i++){
        // まず頂点1と他の頂点を結んだグラフを作成する
        T.push_back(make_tuple(1, i));
    }
    int rn = (N-1)*(N-2)/2 - K; // 他に頂点同士を結ぶ回数を確定させる
    if(rn < 0){
        cout << -1 << endl;
        return 0;   // プログラムの終了
    }
    int cnt = 0;
    for(int i=2; i<=N; i++){
        if(rn == 0) break;
        for(int j=i+1; j<=N; j++){
            T.push_back(make_tuple(i, j));
            cnt++;
            if(cnt == rn){
                break;
            }
        }
        if(cnt == rn) break;
    }
    cout << T.size() << endl;
    rep(i,T.size()){
        int u, v;
        tie(u, v) = T[i];
        printf("%d %d\n", u, v);
    }
    return 0;
}

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

int main() {
    set<string> s;
    int N; cin >> N;
    string tmp;
    rep(i, N) {
        cin >> tmp;
        s.insert(tmp);
    }
    cout << s.size() << endl;
}


Measured memory_bytes: 19264
import java.util.*;

public class Main{
        public static void main(String[] args){
                try(Scanner sc = new Scanner(System.in)){
                        long[] A = new long[3], B = new long[3];
                        for(int i = 0; i < 3; i++){
                                B[i] = sc.nextLong();
                                if(B[i] % 2 == 1) {
                                        System.out.println(0);
                                        return;
                                }
                        }
                        Arrays.sort(B);
                        Set<long[]> set = new HashSet<>();
                        long num = 0;
                        while(!Arrays.equals(A, B)){
                                num++;
                                A = Arrays.copyOf(B, B.length);
                                B[0] = (A[0] + A[1]) / 2;
                                B[1] = (A[1] + A[2]) / 2;
                                B[2] = (A[2] + A[0]) / 2;
                                if(B[0] % 2 == 1 || B[1] % 2 == 1 || B[2] % 2 == 1){
                                        System.out.println(num);
                                        return;
                                }
                                Arrays.sort(B);
                        }
                        System.out.println(-1);
                }
        }
}


Measured memory_bytes: 21844
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;++i)
#define rrep(i,n) for(int i=n-1;i>=0;--i)
#define yesno(flg) if(flg){cout<<"YES"<<endl;}else{cout<<"NO"<<endl;}
#define MAX_N 1002
#define i197 1000000007

using namespace std;

typedef long long ll;
typedef pair<ll,ll> P1;
typedef pair<int,int> Pi;
typedef pair<double,Pi> Pdi;
typedef pair<ll,int>Pli;
typedef pair<P1,ll> P2;
const ll INF=1000000000000000001;
struct edge{int to,cost;};
int dy[]={0, 0, 1, -1};
int dx[]={1, -1, 0, 0};
struct Road{double cost;int a,b;};

ll t2=1000000000000001;
int main() {

	ll a,b,c,d,e,n;
	ll total=5;

	cin>>n;
	cin>>a;
	cin>>b;
	cin>>c;
	cin>>d;
	cin>>e;
	t2=min(t2,a);
	t2=min(t2,b);
	t2=min(t2,c);
	t2=min(t2,d);
	t2=min(t2,e);
	if(t2>=n){
		cout<<total<<endl;
	}else{
		total+=n/t2;
		if(n%t2==0)total--;
		cout<<total<<endl;
	}

	return 0;

}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,N) for(int i=0,i##_max=(N);i<i##_max;++i)
#define repp(i,l,r) for(int i=(l),i##_max=(r);i<i##_max;++i)
#define per(i,N) for(int i=(N)-1;i>=0;--i)
#define perr(i,l,r) for(int i=r-1,i##_min(l);i>=i##_min;--i)
#define all(arr) (arr).begin(), (arr).end()
#define SP << " " <<
#define SPF << " "
#define SPEEDUP cin.tie(0);ios::sync_with_stdio(false);
#define MAX_I INT_MAX //1e9
#define MIN_I INT_MIN //-1e9
#define MAX_UI UINT_MAX //1e9
#define MAX_LL LLONG_MAX //1e18
#define MIN_LL LLONG_MIN //-1e18
#define MAX_ULL ULLONG_MAX //1e19
  typedef long long ll;
  typedef pair<int,int> PII;
  typedef pair<char,char> PCC;
  typedef pair<ll,ll> PLL;
  typedef pair<char,int> PCI;
  typedef pair<int,char> PIC;
  typedef pair<ll,int> PLI;
  typedef pair<int,ll> PIL; 
  typedef pair<ll,char> PLC; 
  typedef pair<char,ll> PCL; 

inline void YesNo(bool b){ cout << (b?"Yes" : "No") << endl;}
inline void YESNO(bool b){ cout << (b?"YES" : "NO") << endl;}
inline void Yay(bool b){ cout << (b?"Yay!" : ":(") << endl;}

int main(void){
  SPEEDUP
  cout << setprecision(15);
  double n;
  double m;
  double d;
  cin >> n >> m >> d;
  if(d!=0.0)cout << 2.0*(n-d)*(m-1.0)/(n*n) << endl;
  else cout << (n-d)*(m-1.0)/(n*n) << endl;
  return 0;
}

//n通りある
//n*n通りある．そのうち1*2*(n-d)*n**0通りが成り立つ
//n*n*n通りあるそのうち2*2*(n-d)*n通り
//n**4通りある．そのうち3*2*(n-d)*n**2通りが成り立つ
//n**5通りある．そのうち4*2*(n-d)*n**3通り

//(m-1)*2*(n-d)*n**(m-2);
//2通りある
//4通りある．そのうち2通りが成り立つ


Measured memory_bytes: 256
#include <cstdio>
#include <cstring>
#include <vector>
#include <queue>
#include <string>
#include <algorithm>
#include <iostream>
#include <string>
#include <map>
#include <set>
#include <functional>
#include <iostream>
#define INF 10000000000007LL
using namespace std;
typedef long long ll;
typedef pair<int,ll> P;

int n,m;
int f[2001],t[2001];
ll c[2001];
ll res[1001];
vector<int> g[1001],G[1001];
vector<P> Gd[1001];
bool used[1001];
bool used2[1001];
ll dp[1005][1001];

struct data{
	ll val,v,d;
	data(){}
	data(ll va,ll vv,ll vd){
		val=va;
		v=vv;
		d=vd;
	}
	bool operator<(const data &d)const{
		return val>d.val;
	}
};

void dfs(int v){
	used[v]=true;
	for(int i=0;i<g[v].size();i++){
		if(!used[g[v][i]])dfs(g[v][i]);
	}
}

void dfs2(int v){
	used2[v]=true;
	for(int i=0;i<G[v].size();i++){
		if(!used2[G[v][i]])dfs2(G[v][i]);
	}
}

bool check(){
	memset(res,0,sizeof(res));
	int cnt=0;
	while(true){
		bool upd=false;
		for(int i=0;i<m;i++){
			if(!used[f[i]] || !used[t[i]])continue;
			if(!used2[f[i]] || !used2[t[i]])continue;
			if(res[f[i]]+c[i]>res[t[i]]){
				upd=true;
				res[t[i]]=res[f[i]]+c[i];
			}
		}
		if(!upd)break;
		if(cnt==n-1){
			return true;
		}
		cnt++;
	}
	return false;
}

ll maxi=0;

ll dijk(){
	priority_queue<data> que;
	for(int i=0;i<=n;i++){
		for(int j=0;j<n;j++){
			dp[i][j]=INF*(20LL);
		}
	}
	dp[0][0]=0;
	que.push(data(0,0,0));
	while(que.size()){
		data q=que.top();
		que.pop();
		if(dp[q.d][q.v]<q.val)continue;
		for(int i=0;i<Gd[q.v].size();i++){
			P e=Gd[q.v][i];
			if(!used[e.first] || !used2[e.first])continue;
			e.second=maxi-e.second;
			if(q.d<n && dp[q.d+1][e.first]>q.val+e.second){
				dp[q.d+1][e.first]=q.val+e.second;
				que.push(data(dp[q.d+1][e.first],e.first,q.d+1));
			}
		}
	}
	ll res=-INF;
	for(int i=0;i<=n;i++){
		res=max(res,(ll)i*maxi-dp[i][n-1]);
	}
	return res;
}

int main(void){
	scanf("%d%d",&n,&m);
	for(int i=0;i<m;i++){
		scanf("%d%d%lld",&f[i],&t[i],&c[i]);
		f[i]--;
		t[i]--;
		g[t[i]].push_back(f[i]);
		G[f[i]].push_back(t[i]);
		Gd[f[i]].push_back(P(t[i],c[i]));
		maxi=max(maxi,c[i]);
	}
	dfs(n-1);
	dfs2(0);
	if(check())printf("inf\n");
	else printf("%lld\n",dijk());
	return 0;
}


Measured memory_bytes: 8320
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < n; i++)
#define rep2(i, x, n) for(int i = x; i <= n; i++)
#define rep3(i, x, n) for(int i = x; i >= n; i--)
#define elif else if
#define sp(x) fixed << setprecision(x)
#define pb(x) push_back(x)
#define all(x) x.begin(), x.end()
using ll = long long;
using ld = long double;
using pii = pair<int, int>;
using pil = pair<int, ll>;
using pli = pair<ll, int>;
using pll = pair<ll, ll>;
const ll MOD = 1e9+7;
//const ll MOD = 998244353;
const int inf = 1e9;
const ll INF = 1e18;
const ld EPS = 1e-10;

int main(){
    int K;
    ll ans = 0;
    cin >> K;
    rep2(i, 1, K){
        rep2(j, 1, K){
            rep2(k, 1, K){
                ll g = gcd(i, j);
                g = gcd(g, k);
                ans += g;
            }
        }
    }
    cout << ans << endl;
}

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

int main(){
  int n,l;
  cin>>n>>l;
  vector<string> v(n);
  for(int i=0;i<n;i++)
    cin>>v[i];
  sort(v.begin(),v.end());
  for(int i=0;i<n;i++)
    cout<<v[i];
  cout<<endl;
}


Measured memory_bytes: 256
#include<stdio.h>

#define B 2
#define G 1
#define W 0

int Q[100];
int head = 0, tail = 0;

void enqueue(int x) {
    Q[tail] = x;
    tail = (tail + 1) % 100;
}

int dequeue() {
    int x;
    x = Q[head];
    head = (head + 1) % 100;
    return x;
}

int main() {
    int i, j;
    int u, k, v,ver;
    int col[101], wei[101],adj[101][101];
    int n;

    scanf("%d", &n);

    for (i = 1; i <= n; i++) {
        col[i] = W;
        wei[i] = -1;
        for (j = 1; j <= n; j++) {
            adj[i][j] = 0;
        }
    }
    
    for (i = 0; i < n; i++) {
        scanf("%d%d", &u, &k);
        for (j = 0; j < k; j++) {
            scanf("%d", &v);
            adj[u][v] = 1;
        }
    }

    col[1] = G;
    wei[1] = 0;

    enqueue(1);
    
    while(head!=tail){
        ver = dequeue();

        for (i = 1; i <= n; i++) {
            if (col[i] == W && adj[ver][i]== 1) {
                col[i] = G;
                wei[i] = wei[ver]+1;
                enqueue(i);
            }
        }

        col[ver] = B;
    }

    for (i = 1; i <= n; i++) printf("%d %d\n", i, wei[i]);
    
    return 0;
}



Measured memory_bytes: 2124
n=int(input())
p=list(map(int,input().split()))
dn={x:i for i,x in enumerate(p)}

#####segfunc#####
def segfunc(x, y):
    return x+y
#################

#####ide_ele#####
ide_ele = 0
#################

class SegTree:
    """
    init(init_val, ide_ele): 配列init_valで初期化 O(N)
    update(k, x): k番目の値をxに更新 O(logN)
    query(l, r): 区間[l, r)をsegfuncしたものを返す O(logN)
    """
    def __init__(self, init_val, segfunc=segfunc, ide_ele=ide_ele):
        """
        init_val: 配列の初期値
        segfunc: 区間にしたい操作
        ide_ele: 単位元
        n: 要素数
        num: n以上の最小の2のべき乗
        tree: セグメント木(1-index)
        """
        n = len(init_val)
        self.segfunc = segfunc
        self.ide_ele = ide_ele
        self.num = 1 << (n - 1).bit_length()
        self.tree = [ide_ele] * 2 * self.num
        # 配列の値を葉にセット
        for i in range(n):
            self.tree[self.num + i] = init_val[i]
        # 構築していく
        for i in range(self.num - 1, 0, -1):
            self.tree[i] = self.segfunc(self.tree[2 * i], self.tree[2 * i + 1])

    def update(self, k, x):
        """
        k番目の値をxに更新
        k: index(0-index)
        x: update value
        """
        k += self.num
        self.tree[k] = x
        while k > 1:
            self.tree[k >> 1] = self.segfunc(self.tree[k], self.tree[k ^ 1])
            k >>= 1

    def query(self, l, r):
        """
        [l, r)のsegfuncしたものを得る
        l: index(0-index)
        r: index(0-index)
        """
        res = self.ide_ele

        l += self.num
        r += self.num
        while l < r:
            if l & 1:
                res = self.segfunc(res, self.tree[l])
                l += 1
            if r & 1:
                res = self.segfunc(res, self.tree[r - 1])
            l >>= 1
            r >>= 1
        return res

st=SegTree([0]*n)
ans=0

for k in range(1,n+1):
    i=dn[k]
    # idx=iを含み、区間和が0になる最長の区間を調べる。
    l,r=0,i
    while r-l>1:
        x=(l+r)//2
        if st.query(x,i+1)>0:
            l,r=x,r
        else:
            l,r=l,x
    l0=l if st.query(l,i+1)==0 else r
    l,r=i,n-1
    while r-l>1:
        x=(l+r)//2
        if st.query(i,x+1)>0:
            l,r=l,x
        else:
            l,r=x,r
    r0=r if st.query(i,r+1)==0 else l
    ans+=k*(i-l0+1)*(r0-i+1)
    st.update(i,1)
print(ans)

Measured memory_bytes: 127696
#include <iostream>
#include <memory>
#include <algorithm>
using namespace std;

struct Node;
typedef unique_ptr<Node> NP;
struct Node {
  NP l, r;
};

void test() {
  for (int i = 0; i < 2000000; ++i) NP(new Node());
}

int main() {
  test();
  int a, b, c;
  cin >> a >> b >> c;
  cout << ((a+b+c) == max({a,b,c})*2 ? "Yes" : "No") << endl;
  return 0;
}


Measured memory_bytes: 256
// "include" {{{
#include <deque>
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <deque>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <cstring>
#include <utility>
// }}}
using namespace std;
#define rep(i,n) for(int i=0;i<(n);++i)
#define reps(i,n) for(int i=1;i<=(n);++i)
#define all(x) (x).begin(),(x).end()
#define int long long 
#define pii pair<int,int> 
const int INF = 0x3f3f3f3f;
const long long LINF = 0x3f3f3f3f3f3f3f3fLL;
const long long mod = 1000000007;

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

vector<int> t;
vector<int> a;

signed main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	char b;
	cin >> b;
	if(b == 'A') cout << 'T' << '\n';
	else if(b == 'T') cout << 'A' << '\n';
	else if(b == 'C') cout << 'G' << '\n';
	else if(b == 'G') cout << 'C' << '\n';
	return 0;
}


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

#define FOR(s, i, n) for(int i = s; i n; i++)
typedef long long ll;
const int INF = 1e9;
int main(){
	ios::sync_with_stdio(false);
	cin.tie(NULL);
	
	int n,m;
	cin>>n>>m;
	vector<vector<int>> adj(n, vector<int>());
	vector<int> sign(n, -1);
	for (int i = 0; i < m; i++){
		int u, v;
		cin>>u>>v;
		u--; v--;
		adj[u].push_back(v);
		adj[v].push_back(u);
	}
	queue<int> q;
	q.push(0);
	sign[0] = 0;
	while (!q.empty()){
		int u = q.front();
		q.pop();
		for (auto it: adj[u]){
			if (sign[it] == -1){
				sign[it] = u;
				q.push(it);
			}
		}
	}
	if (find(sign.begin(), sign.end(), -1) != sign.end()){
		cout<<"No\n";
	}else{
		cout<<"Yes\n";
		for (int i = 1; i < n; i++){
			cout<<sign[i]+1<<'\n';			
		}
	}
	return 0;
}

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

#ifdef LOCAL
#include "dump.hpp"
#else
#define dump(...)
#define dumpv(...)
#endif

#define rep(i, n) for (int i = 0; i < (n); i++)
typedef long long ll;
typedef pair<int, int> P;
typedef vector<int> vi;
typedef vector<vi> vvi;
const int MOD = 1e9 + 7;
const int INF = 1001001001;
const ll LINF = 1001002003004005006ll;

void solve() {
  int n;
  cin >> n;
  vi p(n);
  rep(i, n) cin >> p[i];
  rep(i, n) p[i]--;
  vi idx(n);
  rep(i, n) idx[p[i]] = i;
  dump(p, idx);
  set<int> st;
  ll ans = 0;
  for (int x = n - 1; 0 <= x; x--) {
    ll cnt = 0;
    int i = idx[x];
    st.insert(i);
    vi left(2, -1), right(2, n);
    auto it = st.find(i);
    rep(j, 2) {
      if (it == st.begin()) break;
      it--;
      left[j] = *it;
    }
    it = st.find(i);
    rep(j, 2) {
      it++;
      if (it == st.end()) break;
      right[j] = *it;
    }
    vi nl(2), nr(2);
    nl[0] = i - left[0];
    nl[1] = left[0] - left[1];
    nr[0] = right[0] - i;
    nr[1] = right[1] - right[0];
    cnt = (ll)nl[0] * nr[1] + (ll)nl[1] * nr[0];
    dump(left, right, nl, nr, cnt);
    ans += cnt * (x + 1);
  }
  cout << ans << endl;
}

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(15);
  // freopen("temp.1", "r", stdin);
  solve();
  return 0;
}

Measured memory_bytes: 5760
#include <iostream>

using namespace std;

int main(int argc, char* argv[])
{

	int X,Y,Z;

	cin >> X;

	if(X==1){
		cout << "Hello World" << endl;
	}else{
		cin >> Y >> Z;
		cout << Y + Z << endl;
	}



	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
	int a,b,c;
	cin>>a>>b>>c;
	if(a>b){
		a=b;
	}if(a>c){
		a=c;
	}
	int d,e;
	cin>>d>>e;
	if(d>e){
		d=e;
	}
	printf("%d\n",d+a-50);
}


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

int main() {
	int a[4];
	bool b = false;
	bool c = false;
	bool d = false;
	bool e = false;
	
	for(int i = 0; i <= 3; i++){
		cin >> a[i];
		if(a[i] == 1){b = true;}
		if(a[i] == 9){c = true;}
		if(a[i] == 7){d = true;}
		if(a[i] == 4){e = true;}
	}
	if(b && c && d && e){cout << "YES";}
	else{cout << "NO";}
	return 0;
}

Measured memory_bytes: 256
from collections import deque

N = int(input())
G = [[] for _ in range(N + 1)]
# 辺の色を具体的に出力する際、辺の順番が必要になるので記録しておく
edge_order = []
for i in range(N - 1):
    a, b = map(int, input().split())
    G[a].append(b)
    G[b].append(a)
    edge_order.append((a, b))

# どこでも良いが、ここでは1をrootとする
dq = deque([1])

# 辺の色
edge_color = {}
# 子要素を見ていく際、親が既に使った１色だけは使えない、そのチェック
used_color = [0 for _ in range(N + 1)]
# BFSで既に見たかどうか
visited = [False for _ in range(N + 1)]
visited[1] = True

# BFS
while dq:
    # prt = 親
    prt = dq.popleft()
    color = 0

    # cld = 子
    for cld in G[prt]:
        if visited[cld] == False:
            # 訪れたことを記録
            visited[cld] = True
            # 色を決める
            color += 1
            # 親が既に使った色だったらスキップ
            if color == used_color[prt]:
                color += 1

            # この段階で色は確定している

            # 「既に使った色」として記録
            used_color[cld] = color
            # 辺の色を記録
            n1 = min(cld, prt)
            n2 = max(cld, prt)
            edge_color[(n1, n2)] = color
            # キューに追加
            dq.append(cld)

# 使用する色の数
print(max(edge_color.values()))
# 具体的な辺の色を出力
for edge in edge_order:
    print(edge_color[edge])


Measured memory_bytes: 110700
#include <iostream>
#include<bits/stdc++.h>
using namespace std;
typedef long double ld;
ld x1,x2,x3,y,y2,y3,a,b,c,M,r;
int main(void){
    cin>>x1>>y>>x2>>y2>>x3>>y3;
    a=sqrt((y-y2)*(y-y2)+(x1-x2)*(x1-x2));
    b=sqrt((y2-y3)*(y2-y3)+(x2-x3)*(x2-x3));
    c=sqrt((y-y3)*(y-y3)+(x1-x3)*(x1-x3));
    M=max(max(a,b),c);
    r=abs((x2-x1)*(y3-y)-(x3-x1)*(y2-y))/(a+b+c);
    cout<<setprecision(15)<<M/(2+M/r)<<endl;
}


Measured memory_bytes: 256
/*input
32
29 19 7 10 26 32 27 4 11 20 2 8 16 23 5 14 6 12 17 22 18 30 28 24 15 1 25 3 13 21 19 31 9
*/
#include <bits/stdc++.h>
using namespace std;
const long long md=1e9+7;
long long a[100005],n,fac[100005],inv[100005];
unordered_map<long long,long long> mp[100005];
vector<int> v[100005];
long long power(long long a,long long p,long long m=1e9+7,long long k=0){
	return p?k=power(a,p/2,m),(k*k%m)*(p&1?a:1)%m:1;
}
long long ncr(long long n, long long r){
	if(r==0||r==n) return 1;
	if(r<0 || r>n) return 0;
	return fac[n]*(inv[r]*inv[n-r]%md)%md;
}
int main(){
	ios_base::sync_with_stdio(0);
	long long x=0,y=0,ans;
	fac[0]=1;
	for(int i=1;i<100005;++i) 
		fac[i]=i*fac[i-1]%md,inv[i]=power(fac[i],md-2);
	cin>>n;
	for(int i=0;i<n+1;cin>>a[i++]);
	for(int i=0;i<n+1;++i)
		v[a[i]].push_back(i);
	for(int i=1;i<=n;++i)
		if(v[i].size()>1)
			x=v[i][0],y=v[i][1];
	assert(x!=y);
	for(int i=1;i<=n;++i){
		ans=ncr(n-1,i)+ncr(n,i-1)+ncr(n-x-1+x,i-1)-ncr(n-y+x,i-1);
		//cout<<i<<": "<<ncr(n-y+1,i-1)<<'\n';
		cout<<(ans+md)%md<<'\n';
	}
	cout<<1;
}
// 29C2 + 28C2...

Measured memory_bytes: 14464
//Relive your past life.
//Face your demons.
//The past is never dead,it is not even past.
//The memories are not only the key to the past but...also to the future.
//coded in Rusty Lake
#include<cmath>
#include<math.h>
#include<ctype.h>
#include<algorithm>
#include<bitset>
#include<cassert>
#include<cctype>
#include<cerrno>
#include<cfloat>
#include<ciso646>
#include<climits>
#include<clocale>
#include<complex>
#include<csetjmp>
#include<csignal>
#include<cstdarg>
#include<cstddef>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<ctime>
#include<cwchar>
#include<cwctype>
#include<deque>
#include<exception>
#include<fstream>
#include<functional>
#include<iomanip>
#include<ios>
#include<iosfwd>
#include<iostream>
#include<istream>
#include<iterator>
#include<limits>
#include<list>
#include<locale>
#include<map>
#include<memory>
#include<new>
#include<numeric>
#include<ostream>
#include<queue>
#include<set>
#include<sstream>
#include<stack>
#include<stdexcept>
#include<streambuf>
#include<string>
#include<typeinfo>
#include<utility>
#include<valarray>
#include<vector>
#include<string.h>
#include<stdlib.h>
#include<stdio.h>
#define ll   long long
#define pb   push_back
#define mp   make_pair
#define orz  1000000007
//作者:中国江苏南京丁天行
using namespace std;
//数组不要开小了
//数组不要开反了
int q,h,s,d,n;
int main()
{
    cin>>q>>h>>s>>d>>n;
    s=min(s,q*4);
    s=min(s,h*2);
    ll ans1,ans2;
    ans1=s*1ll*n;
    if(n&1)ans2=s+(n/2ll)*1ll*d;
    else ans2=(n/2ll)*1ll*d;
    cout<<min(ans1,ans2)<<endl;
//	system("pause");
	return 0;
}


Measured memory_bytes: 256
S = list(input())

def parse(S):
    N = len(S)
    i = 0
    array = []

    n = 0
    array.append(n)
    while i < N:
        while i < N and S[i] == '<':
            n += 1
            array.append(n)
            i += 1

        while i < N and S[i] == '>':
            array.append(0)
            i += 1

        j = i - 1
        m = 1
        while j >= 0 and S[j] == '>':
            array[j] = max(array[j], m)
            m += 1
            j -= 1
        n = 0
    return array

array = parse(S)
total = 0
for n in array:
    total += n

print(total)

Measured memory_bytes: 27444
import sys

input_methods=['clipboard','file','key']
using_method=0
input_method=input_methods[using_method]

IN=lambda : map(int, input().split())
mod=1000000007

#+++++

def main():
	#a = int(input())
	n, m = IN()
	#s = input()
	sn=[0]*n
	for i in range(m):
		dd=2 ** i
		al=list(IN())
		for ni in al[1:]:
			sn[ni-1] += dd
	
	switch_aa=list(IN())
	switch_aaa=0
	for i, v in enumerate(switch_aa):
		if v == 1:
			switch_aaa+= 2**i
	
	cc=0
	for state_i in range(2 ** n):
		switch_state=0
		for switch_i, is_on in enumerate(bin(state_i+2**12)[14-n+1:]):
			if is_on == '1':
				switch_state = switch_state ^ sn[switch_i]
		else:
			switch_state = switch_state ^ switch_aaa
			if switch_state == 0:
				cc+=1
	print(cc)
			
		
				
			
			
	
	
	
#+++++
isTest=False

def pa(v):
	if isTest:
		print(v)
		
def input_clipboard():
	import clipboard
	input_text=clipboard.get()
	input_l=input_text.splitlines()
	for l in input_l:
		yield l

if __name__ == "__main__":
	if sys.platform =='ios':
		if input_method==input_methods[0]:
			ic=input_clipboard()
			input = lambda : ic.__next__()
		elif input_method==input_methods[1]:
			sys.stdin=open('inputFile.txt')
		else:
			pass
		isTest=True
	else:
		pass
		#input = sys.stdin.readline
			
	ret = main()
	if ret is not None:
		print(ret)

Measured memory_bytes: 3064
#include<iostream>
#include<cstdio>
#include<cstring>
#include<cmath>
#include<algorithm>
#include<set>
using namespace std;
typedef long long LL;
const int M=1e5+5;
int s[M];
int G[105][105];

int main()
{
    int h,w;
    while(scanf("%d%d",&h,&w)!=EOF)
    {
        int n;
        scanf("%d",&n);
        for(int i=1;i<=n;++i)
            scanf("%d",&s[i]);
        int cnt=1;
        for(int i=1;i<=h;++i)
        {
            if(i&1)
            {
                for(int j=1;j<=w;++j)
                {
                   if(s[cnt]>0) {G[i][j]=cnt;--s[cnt];}
                   else if(s[cnt]==0) {++cnt;G[i][j]=cnt;--s[cnt];}
                }
            }else
            {
                for(int j=w;j>=1;--j)
                {
                    if(s[cnt]>0) {G[i][j]=cnt;--s[cnt];}
                    else if(s[cnt]==0) {++cnt;G[i][j]=cnt;--s[cnt];}
                }
            }
        }
        for(int i=1;i<=h;++i)
        {
            for(int j=1;j<=w;++j)
            {
                if(j!=w) printf("%d ",G[i][j]);
                else printf("%d\n",G[i][j]);
            }
        }
    }
    return 0;
}


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

#define rep(i, n) for (int i = 0; i < (n); i++)
#define contains(v, t) (find(v.begin(), v.end(), t) != v.end())
#define MOD 1000000007
typedef long long ll;
typedef unsigned long long ull;

int main() {
  string w;
  cin >> w;
  map<char, int> m;
  rep(i, w.length()) {
    m[w[i]]++;
  }
  rep(i, m.size()) {
    if (m[i] % 2 != 0) {
      cout << "No";
      return 0;
    }
  }
  cout << "Yes";
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for (ll i = 0; i < (ll)(n); ++i)
#define rep2(i, s, n) for (ll i = s; i < (ll)(n); i++)
#define repr(i, n) for (ll i = n; i >= 0; i--)
#define fi first
#define sc second
#define pb push_back
#define COUT(x) cout << (x) << "\n"
#define COUTF(x) cout << setprecision(15) << (x) << "\n"
#define ENDL cout << "\n"
#define DF(x) x.erase(x.begin())  // 先頭文字削除
#define ALL(x) x.begin(), x.end()
#define SZ(x) (ll) x.size()
#define SORT(x) sort(ALL(x))
#define REVERSE(x) reverse(ALL(x))
#define MAX(x, y, z) max(x, max(y, z))
#define MIN(x, y, z) min(x, min(y, z))
#define ANS cout << ans << "\n"
#define RETURN(x)    \
  cout << x << "\n"; \
  return 0
clock_t CLOCK;
#define START_TIMER CLOCK = clock()
#define SHOW_TIMER cerr << "time: " << (ld)(clock() - CLOCK) / 1000000 << "\n"
#define init() \
  cin.tie(0);  \
  ios::sync_with_stdio(false)
#define LINE cerr << "[debug] line: " << __LINE__ << "\n";
#define debug(x) cerr << "[debug] " << #x << ": " << x << "\n";
#define debugV(v)                       \
  cerr << "[debugV] " << #v << ":";     \
  rep(i, v.size()) cerr << " " << v[i]; \
  cerr << "\n";
using namespace std;
using ll = long long;
using ld = long double;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
using mll = map<ll, ll>;
using qll = queue<ll>;
using P = pair<ll, ll>;

constexpr ll INF = 0x3f3f3f3f3f3f3f3f;
constexpr ld PI = 3.141592653589793238462643383279;
ll get_digit(ll x) {
  return to_string(x).size();
}

ll gcd(ll x, ll y) {
  return y ? gcd(y, x % y) : x;
}

ll lcm(ll a, ll b) {
  return a / gcd(a, b) * b;
}

vector<P> factorize(ll n) {
  vector<P> result;
  for (ll i = 2; i * i <= n; ++i) {
    if (n % i == 0) {
      result.pb({i, 0});
      while (n % i == 0) {
        n /= i;
        result.back().second++;
      }
    }
  }
  if (n != 1) {
    result.pb({n, 1});
  }
  return result;
}

vll divisor(ll n) {
  vll ret;
  for (ll i = 1; i * i <= n; i++) {
    if (n % i == 0) {
      ret.push_back(i);
      if (i * i != n) ret.push_back(n / i);
    }
  }
  // SORT(ret);
  return (ret);
}

signed main() {
  init();
  ll N;
  cin >> N;

  vll F(N + 1);
  F[0] = 0;
  rep(i, N + 1) {
    if (i == 0) continue;
    ll num = i;
    while (num <= N) {
      F[num] += 1;
      num += i;
    }
  }

  ll ans = 0;
  rep(i, N + 1) {
    ans += F[i] * i;
  }
  ANS;
  return 0;
}

Measured memory_bytes: 81320
#include <iostream>
#include <iomanip>
#include <random>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <cmath>
#include <numeric>
#include <cstdlib>
#include <cstring>
#include <deque>
#include <sstream>
#include <bitset>
#include <cassert>
#include <fstream>
#include <queue>

#define len(X) ((int)(X).size())

#ifdef __LOCAL
	#define DBG(X) cout << #X << "=" << (X) << '\n';
	#define SAY(X) cout << (X) << '\n';
#else
	#define DBG(X)
	#define SAY(X)
#endif
 
using namespace std;

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

const int INT_INF = (int)(2e9);
const ll  LL_INF  = (ll)(2e18);

const int NIL = -1;
static mt19937 _g(time(nullptr));

inline ll randint(ll a, ll b) { ll w = (_g() << 31LL) ^ _g(); return a + w % (b - a + 1); }
inline void fast_io() { ios_base::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr); };
template<typename T> inline T sign(T x) { return T(x > 0) - T(x < 0); }
template<typename T, typename S> inline ostream& operator<<(ostream& os, const pair<T, S> p) { cout << "[" << p.first << ";" << p.second << "]"; return os; }
template<typename T> inline ostream& operator<<(ostream& os, const vector<T>& v) { for(auto el: v) cout << el << " "; return os; }
template<typename T> inline T fetch() { T ret; cin >> ret; return ret; }
template<typename T> inline vector<T> fetch_vec(int sz) { vector<T> ret(sz); for(auto& elem: ret) cin >> elem; return ret; }

const double PI = acos(-1.);
#define VAR(TYPE, NAME) TYPE NAME = fetch<TYPE>();

void solve() {
	VAR(double, a); VAR(double, b); VAR(double, x);
	double t = 2. * (b / a - x / (a * a * a));
	DBG(t);
	double alpha = atan(t);

	if(2. * x <= a * a * b) {
		double t2 = (a * b * b) / (2. * x);
		DBG(t2);
		double alpha2 = atan(t2);
		alpha = max(alpha, alpha2);
	}

	alpha /= 2. * PI;
	alpha *= 360.;

	cout << fixed << setprecision(12) << alpha << '\n';
}

int main() {
	fast_io();
	solve();

	return 0;
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int a, b;
  cin >> a >> b;
  double c = a * b % 2;
  
  
  if (c == 0) {
    cout << "Even" <<endl;
  }
  else {
    cout << "Odd" << endl;
  }
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define ff first
#define pb push_back
#define pf push_front
#define mp make_pair
#define pu push
#define ss second
#define pp pop_back
#define in insert
#define ld long double
#define sz(v) (int)v.size()
#define prv(a) for(auto x : a) cout << x << ' ';cout << '\n';
#define decimal_digits cout << fixed << setprecision(15);
#define sp cout << " "
#define endl '\n'
#define forrev(high,low,i) for(i = high; i>= low;i--)
#define trace(x) cerr << #x << ": " << x << " " << endl;
#define all(v) v.begin(),v.end()
#define dbg2(a,b) cerr << #a << " = " << a << " " << #b << " = " << b << '\n';              
#define IOS ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL); 
#define lmax 9223372036854775807
#define v3(type, v, x, y, z) vector<vector<vector<type>>> v(x, vector<vector<type>>(y, vector<type>(z)))
#define v2(type, v, n, m) vector<vector<type>> v(n, vector<type>(m))

const ll MOD=1e9+7;
typedef unordered_map<int,int> umi;
typedef unordered_map<ll,ll> uml;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vi> vvi;
typedef vector<vl> vvl;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<pii > vpii;
typedef vector<pll > vpll;


inline ll fpow(ll n, ll k, ll p = MOD) {ll r = 1; for (; k; k >>= 1) {if (k & 1) r = r * n % p; n = (n%p) * (n%p) % p;} return r;}
inline ll inv(ll a, ll p = MOD) {return fpow(a, p - 2, p);}
inline ll addmod(ll a, ll val, ll p = MOD) {{if ((a = (a + val)) >= p) a -= p;} return a;}
inline ll submod(ll a, ll val, ll p = MOD) {{if ((a = (a - val)) < 0) a += p;}return a;}
inline ll mult(ll a, ll b, ll p = MOD) {return (ll) a * b % p;}


int main()
{
	ll i,j,n,m,k,ans,t=1;
	// cin>>t;
	while(t--)
	{
		cin>>n>>m;
		k=0;
		vi v(n);
		for(i=0;i<n;i++)
		{
			cin>>v[i];
			k=k+v[i];
		}
		sort(v.rbegin(),v.rend());
		if(v[m-1]*4*m>=k)
			cout<<"Yes"<<endl;
		else
			cout<<"No"<<endl;	
	}
	
}

Measured memory_bytes: 256
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <algorithm>
#include <vector>
#define MOD 1000000007

using namespace std;

typedef long long ll;

ll dp(int n,int m) {
  ll s1=1,s2=0;
  for(int i=1;i<=m;i++) {
  	ll f=(s1*(((n&1)&&n>1)?2LL:1LL)+s2*(i-1)%MOD*n)%MOD;
  	s2=s1;
  	s1=f;
  }
  return s1;
}

int a[100005],sum[100005];
bool vis[100005],cir[100005];
vector <int> son[100005];

int getlen(int x) {
  vis[x]=1;
  if (!cir[x]&&son[x].size()>=2) {
  	puts("0");
  	exit(0);
  }
  for(int i=0;i<son[x].size();i++)
    if (!cir[son[x][i]]) return getlen(son[x][i])+1;
  return 1;
}

int now[100005],l[100005],pos[100005];

ll calc(int x) {
  do {
  	vis[x]=1;
  	x=a[x];
  } while (!vis[x]);
  int d=0,tot=0;
  do {
  	cir[x]=1;
  	x=a[x];
  } while (!cir[x]);
  int t=x;
  do {
  	pos[x]=++d;
  	l[x]=getlen(x)-1;
  	if (l[x]) now[++tot]=x;
  	x=a[x];
  } while (x!=t);
  if (!tot) {
  	sum[d]++;
  	return 1;
  }
  ll ans=1;
  for(int i=1;i<=tot;i++) {
  	int p=now[i],q=now[i%tot+1];
  	int dis=(pos[q]-pos[p]+d)%d;
  	if (!dis) dis=d;
  	if (dis<l[q]) {
  		puts("0");
  		exit(0);
	  }
	if (dis>l[q]) ans=ans*2LL%MOD;
  }
  return ans;
}

int main() {
  int n;
  scanf("%d",&n);
  for(int i=1;i<=n;i++) {
  	scanf("%d",&a[i]);
  	son[a[i]].push_back(i);
  	if (son[a[i]].size()>2) {
  		puts("0");
  		exit(0);
	  }
  }
  ll ans=1;
  for(int i=1;i<=n;i++)
    if (!vis[i]) ans=(ans*calc(i))%MOD;
  for(int i=1;i<=n;i++)
    if (sum[i]) ans=ans*dp(i,sum[i])%MOD;
  printf("%lld\n",ans);
  return 0;
}

Measured memory_bytes: 7552
#include <stdio.h>

int main(void){
    long long int h;
    scanf("%lld", &h);
    long long int ans=1, cnt=0;
    
    while(h>1){
        h/=2;
        cnt++;
        long long temp=1;
        for(int i=0; i<cnt; i++)temp*=2;
        // printf("%lld\n", temp);
        ans+=temp;
    }
    
    printf("%lld\n", ans);
    return 0;    
}


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

namespace abc051_a
{
    class Program
    {
        static void Main(string[] args)
        {
            string[] x = Console.ReadLine().Split(',');
            Console.Write(x[0]);
            for (int i = 1; i < x.Count(); i++)
            {
                Console.Write(" " + x[i]);
            }
            Console.WriteLine();
        }
    }
}

Measured memory_bytes: 2776
#include <bits/stdc++.h>
#define fastio ios_base::sync_with_stdio(0), cin.tie(0)
using namespace std;

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

int n, t;
int a[3000];
int b[3000];
int dp[3000][3000][2];

int f(int i, int j, int k)
{
	if (i == n) return 0;
	int &ret = dp[i][j][k];
	if (ret != -1) return ret;

	ret = f(i + 1, j, k);
	if (j + a[i] < t)
		ret = max(f(i + 1, j + a[i], k) + b[i], ret);
	
	if (k == 1) ret = max(ret, f(i + 1, j, 0) + b[i]);
	return ret;
}

int main()
{
	fastio;
	cin >> n >> t;
	for (int i = 0; i < n; i++) cin >> a[i] >> b[i];
	memset(dp, -1, sizeof(dp));
	cout << f(0, 0, 1);
}

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

using namespace std;
#define int long long
#define all(v) v.begin(), v.end()
const int N = 2e5 + 5;
int fen[N], a[N];

void add(int idx) {
    for (idx++; idx < N; idx += idx&(-idx)) fen[idx]++;
    return ;
}
int get(int idx) {
    int res = 0;
    for (idx++; idx; idx -= idx&(-idx)) res += fen[idx];
    return res;
}

int32_t main() {
    ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
    int n, k, ans = 0; cin >> n >> k;
    vector <int> vec = {0};
    for (int i = 1; i <= n; i++) cin >> a[i], a[i] += a[i - 1] - k, vec.push_back(a[i]);
    sort(all(vec)), vec.resize(unique(all(vec)) - vec.begin());
    for (int i = 0; i <= n; i++) {
        int x = lower_bound(all(vec), a[i]) - vec.begin();
        ans += get(x), add(x);
    }
    cout << ans << "\n";
}


Measured memory_bytes: 5104
#include <bits/stdc++.h>
#define rep(i,n) for (ll i = 0; i < n; ++i)
#define sz(x) int(x.size())
#define ALL(c) (c).begin(), (c).end()
#define SUM(x) std::accumulate(ALL(x), 0LL)
#define MIN(v) *std::min_element(v.begin(), v.end())
#define MAX(v) *std::max_element(v.begin(), v.end())
#define EXIST(v, x) (std::find(v.begin(), v.end(), x) != v.end())
#define FORV(i, v) for (auto i = v.begin(); i != v.end(); i++)
using namespace std;

using ll = long long;

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; }
const int INF = 1001001001;
const long long INFLL = LLONG_MAX / 3;
const double eps = (1e-9);


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

  int h, w;
  cin >> h >> w;
  vector<string> s(h);
  rep(i, h) cin >> s[i];

  vector<vector<int>> yoko(h, vector<int>(w, 0));
  vector<vector<int>> tate(h, vector<int>(w, 0));

  rep(i, h) {
    int st = -1, ed = -1;
    rep(j, w) {
      if (st == -1 && s[i][j] == '.') {
        st = j; ed = j;
        if (j == w - 1) yoko[i][j] = 1;
      } else if (s[i][j] == '.') {
        ed = j;
        if (j == w - 1) for (int k = st; k <= ed; k++) yoko[i][k] = ed - st + 1;
      } else if (st != -1 && s[i][j] == '#') {
        for (int k = st; k <= ed; k++) yoko[i][k] = ed - st + 1;
        st = -1;
        ed = -1;
      }
    }
  }

//  rep(i, h) {
//    rep(j, w) cerr << yoko[i][j] << " "; cerr << endl;
//  }

  rep(j, w) {
    int st = -1, ed = -1;
    rep(i, h) {
      if (st == -1 && s[i][j] == '.') {
        st = i; ed = i;
        if (i == h - 1) tate[i][j] = 1;
      } else if (s[i][j] == '.') {
        ed = i;
        if (i == h - 1) for (int k = st; k <= ed; k++) tate[k][j] = ed - st + 1;
      } else if (st != -1 && s[i][j] == '#') {
        for (int k = st; k <= ed; k++) tate[k][j] = ed - st + 1;
        st = -1;
        ed = -1;
      }
    }
  }

//  rep(i, h) {
//    rep(j, w) cerr << tate[i][j] << " "; cerr << endl;
//  }

  int ans = 0;
  rep(i, h) rep(j, w) {
    chmax(ans, tate[i][j] + yoko[i][j] - 1);
  }

  cout << ans << endl;

  return 0;
}


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

int main() {
	int h, w, n;
	cin >> h >> w >> n;
	vector<int> c;
	for (int i = 0; i < n; i++) {
		int a;
		cin >> a;
		for (int j = 0; j < a; j++) {
			c.push_back(i + 1);
		}
	}
	for (int i = 0; i < h; i++) {
		for (int j = 0; j < w; j++) {
			if (j) {
				cout << ' ';
			}
			cout << (i % 2 ? c[i * w + (w - 1 - j)] : c[i * w + j]);
		}
		cout << endl;
	}
	return 0;
}


Measured memory_bytes: 384
#include<bits/stdc++.h>
#define mod 1000000007
using namespace std;
int main()
{
	long h,w,i,j;
	cin>>h>>w;
	char s[h][w];

	for(i=0;i<h;i++)
	{
		for(j=0;j<w;j++)
			cin>>s[i][j];

	}

	long ways[h][w];

	if(s[1][0]=='.')
		ways[1][0] = 1;
	else
		ways[1][0] = 0;

	if(s[0][1] == '.')
		ways[0][1] = 1;
	else
		ways[0][1] = 0;

	i = 0;
	for(j=2;j<w;j++)
	{
		if(s[i][j]=='#')
			ways[i][j] = 0;
		else
			ways[i][j] = ways[i][j-1];
	}

	j = 0;
	for(i=2;i<h;i++)
	{
		if(s[i][j]=='#')
			ways[i][j] = 0;
		else
			ways[i][j] = ways[i-1][j];
	}

	for(i=1;i<h;i++)
	{
		for(j=1;j<w;j++)
		{
			if(s[i][j]=='#')
				ways[i][j] = 0;
			else
			{
				ways[i][j] = ((ways[i][j-1]%mod) + (ways[i-1][j]%mod))%mod;;
			}
		}
	}
	cout<<ways[h-1][w-1]<<endl;
}

Measured memory_bytes: 9088
#include <bits/stdc++.h>
using namespace std;
 
#define FAST ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
 
#define MAXX 200010
 
#define PI   3.14159265358979323846264338327950
 
#define PB push_back 
#define F first
#define S second
 
#define ll 	long long  int 
 
#define mod  1000000007


int main()
{
	FAST;
	string s = "Christmas ";
	ll n;
	cin >> n;
	for(ll i = n; i < 25; i ++){
		s += "Eve ";
	}
	cout << s;
	return 0;
}

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

int main() {
	int n;
	scanf("%d", &n);
	vector<int> a(n);
	rep(i, n) {
		scanf("%d", &a[i]);
	}
	sort(a.rbegin(), a.rend());
	int tozan = 0;
	rep(i, n) {
		if (a[i] == a[i + 1]) {
			if (tozan == 0) {
				tozan = a[i];
				i ++;
			} else {
				printf("%lld\n", (long long) tozan * a[i]);
				return 0;
			}
		}
	}
	printf("0\n");
        return 0;
}


Measured memory_bytes: 640
#include <iostream>
#include <fstream>
#include <cmath>
#include <cstdlib>
#include <algorithm>
#include <vector>
#include <string>
#include <cstdio>
#include <stack>

using namespace std;

int main(void) {

	string s;
	cin >> s;

	for (int j = 0; j < s.size(); ++j) {
		if (s.at(j) == 'B' || s.at(j) == 'D' || s.at(j) == 'E' || s.at(j) == 'F' || s.at(j) == 'G' || s.at(j) == 'H' ||
			s.at(j) == 'I' || s.at(j) == 'J' || s.at(j) == 'K' || s.at(j) == 'L' || s.at(j) == 'N' || s.at(j) == 'M' ||
			s.at(j) == 'O' || s.at(j) == 'P' || s.at(j) == 'Q' || s.at(j) == 'R' || s.at(j) == 'S' || s.at(j) == 'T' ||
			s.at(j) == 'U' || s.at(j) == 'V' || s.at(j) == 'W' || s.at(j) == 'X' || s.at(j) == 'Y' || s.at(j) == 'Z') {
			cout << "WA" << endl;
			return 0;
		}
	}



	if (s.at(0) == 'A') {
		int cnt = 0;
		for (int i = 2; i < s.size() - 1; ++i) {
			if (s.at(i) == 'C') {
				cnt++;
			}
		}
		if (cnt == 1) {
			cout << "AC" << endl;
			return 0;
		}
	}

	cout << "WA" << endl;

	return 0;
}

Measured memory_bytes: 384