akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<int, int>;
const ll MOD = 1000000007;

int optimal_suger[3001];

int main(){
    int A, B, C, D, E, F;
    cin >> A >> B >> C >> D >> E >> F;

    set<int> able_suger;
    for(int c=0;c*C<F;c++){
        for(int d=0;c*C + d*D<F;d++){
            able_suger.insert(c * C + d * D);
        }
    }

    auto ans = make_pair(100 * A, 0);
    for(int a=0;100*A*a<F;a++){
        for(int b=0;100*B*b<F;b++){
            if(a == 0 && b == 0) continue;
            int water = A * a + B * b;
            int cap = min(water * E, F - 100 * water);
            if(cap < 0) continue;
            auto it = able_suger.upper_bound(cap);
            it--;
            int sugar = *it;
            if(ans.first * sugar > (sugar + 100 * water) * ans.second){
                ans = make_pair(sugar + 100 * water, sugar);
            }
        }
    }
    cout << ans.first << " " << ans.second << endl;

    return 0;
}

Measured memory_bytes: 384
#18
S = input()
N = len(S)
mozi = ["A","C","G","T"]
cou = 0
Max = 0
n = 0
for i in range(N):
    for j in mozi:
        if S[i] == j:
            cou += 1
            n += 1
        if j == "T" and n == 0:
            if cou > Max:
                Max = cou
            cou = 0
        elif j == "T":
            n = 0
        
if cou > Max:
    Max = cou
print(Max)
            

Measured memory_bytes: 9132
L, R = gets.split.map(&:to_i)
MOD = 2019
max = [L + MOD, R].min

ans = Float::INFINITY

L.upto(max - 1).each do |i|
  im = i % MOD

  ((i + 1)..max).each do |j|
    jm = j % MOD

    v = (im * jm) % MOD

    ans = v if ans > v
  end
end

puts ans


Measured memory_bytes: 1788
from collections import Counter

B=[]
n,m=map(int,input().split())
for _ in range(n):
	A=list(map(int,input().split()))
	B+=A[1:]													#listの結合

C=list(Counter(B).values())					#values()をlistに戻す必要がある

print(C.count(n))

Measured memory_bytes: 3316
//--- pD ---//
import java.util.*;
import java.lang.*;
import java.io.*;
public class Main {
	public static void main (String[] args) throws java.lang.Exception {
		new Solution();
	}
}
class Solution {
	Reader reader;
	PrintWriter out;
	public Solution() {
		reader = new Reader();
		out = new PrintWriter(System.out);
		// int t = reader.ni();
		while (reader.hasNext()) {
			run_case();
		}
		out.flush();
	}

	List<Long> list;
	int tar = (int)1e5 + 5;
	private void run_case() {
		int K = reader.ni();

		list = new ArrayList<>();

		for (int i=1; i<=10; i++) {
			char[] arr = new char[i];
			for (int j=1; j<=9; j++) {
				arr[0] = (char)('0' + j);
				dfs(i, 1, arr);
			}
		}

		System.out.println(list.get(K - 1));
		return;
	}

	private void dfs(int len, int idx, char[] arr) {
		if (list.size() > tar) return;
		if (idx == len) {
			list.add(Long.parseLong(String.valueOf(arr)));
			return;
		}

		char pv = arr[idx - 1];
		for (int i=-1; i<=1; i++) {
			if ((pv == '0' && i == -1) || (pv == '9' && i == 1)) continue;
			arr[idx] = (char)(pv + i);
			dfs(len, idx + 1, arr);
		}

		return;
	}
}


class Reader {
	BufferedReader br;
	StringTokenizer st;
	public Reader(){
		try {
			br = new BufferedReader(new InputStreamReader(System.in));
			st = new StringTokenizer(br.readLine());
		} catch (Exception e) {
			e.printStackTrace();
		}
	}
	public String next() {
		if (st.hasMoreTokens()) return st.nextToken();
		try {
			st = new StringTokenizer(br.readLine());
		} catch (Exception e) {
			e.printStackTrace();
		}
		return st.nextToken();
	}
	public boolean hasNext() {
		try {
			if (!st.hasMoreTokens() && !br.ready()) return false;
			else return true;
		} catch (Exception e) {
			e.printStackTrace();
		}
		return false;
	}
	public int ni() {return Integer.parseInt(this.next());}
	public long nl() {return Long.parseLong(this.next());}
	public String ns() {return this.next();}
}


Measured memory_bytes: 33876
#include <iostream>

using namespace std;

int main() {
    int N;
    int Hi, maxHi = -1;
    int numInns = 0;
    cin >> N;
    for (int i = 0; i < N; i++) {
        cin >> Hi;
        if ( Hi >= maxHi ) {
            numInns += 1;
            maxHi = Hi;
        }
    }
    cout << numInns << endl;
}


Measured memory_bytes: 384
#include <iostream>
using namespace std;
int main(void){
	int x0=0, y0=0, xmax, ymax, n;
	cin >> xmax >> ymax >> n;
	while(n--){
		int x, y, a;
		cin >> x >> y >> a;
		switch(a){
			case 1:
				if(x>x0)x0 = x;
				break;
			case 2:
				if(x<xmax)xmax = x;
				break;
			case 3:
				if(y>y0)y0 = y;
				break;
			case 4:
			if(y<ymax)ymax = y;
				break;
		}
	}
	if(xmax<=x0 || ymax<=y0){
		cout << 0 << endl;
	}else cout << (xmax-x0)*(ymax-y0) << endl;
}

Measured memory_bytes: 3584
/*
Author:
Prob:
Link:
Tag:
Comp:
*/

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

#define ll long long
#define ull unsigned long long
#define ii pair<int,int>
#define iii pair<ii, int>
#define dd pair<double, double>

#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define ep emplace_back
#define sz(a) (int) a.size()
#define cl(a) a.clear()

#define vi vector<int>
#define vii vector<ii>

#define FOR(x,a,b) for (int x=a;x<=b;x++)
#define FOD(x,a,b) for (int x=a;x>=b;x--)
#define REP(x,a,b) for (int x=a;x<b;x++)
#define RED(x,a,b) for (int x=a;x>b;x--)

const int MAX = 1e5 + 10;
const int MAXN = 1e4 + 10;
const int MOD = 1e9 + 7;
const int inf = 1e9;
const double pi = acos(-1.0);
const double eps = 1e-9;

inline int cmp(double x){
	if (fabs(x) <= eps) return 0;
	if (x > 0) return 1;
	return -1;
}

int main(){
	// freopen("test.in", "rt", stdin);
	ios::sync_with_stdio(false);

	dd a[20];
	int n, m;
	double d, l, Vy, x, y;
	int flag = 0;

	cin >> d >> n >> m;
	REP(i,0,n)
		cin >> a[i].fi >> a[i].se;
	double res = 1LL << 32LL;
	FOR(i,0,m){
		l = d/(i+1);
		Vy = 0;
		flag = 0;
		REP(j,0,n){
			x = a[j].fi;
			y = a[j].se;
			while (cmp(x-l) >= 0) x -= l;
			if (!cmp(x)){
				flag = 1;
				break;
			}
			double V1 = l*sqrt(y/(2*x*(l-x)));
			if (cmp(V1-Vy) >= 0) Vy = V1;
		}
		if (flag) continue;
		double Vx = l/2.0/Vy;
		double s;
		if (cmp(Vx - Vy) >= 0) Vx = Vy = sqrt(l/2.0);
		s = sqrt(Vx * Vx + Vy * Vy);
		if (cmp(res - s) >= 0) res = s;
	}
	cout << fixed << setprecision(7) << res << endl;

	return 0;
}

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

using namespace std;

int solve(){

    int x,y;
    cin>>x>>y;
    if(y>4*x || y<2*x){
        cout<<"No";
        return 0;
    }
    if(y%2!=0){
        cout<<"No";
        return 0;
    }

    cout<<"Yes";
    return 0;
}

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


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

#define MAX 100000

struct Node{
  int p;
  int l;
  int r;
};

int main(){
  struct Node u[MAX];
  int i,j,n,id,k,d=0,t;

  scanf("%d",&n);

  for(i=0;i<n;i++){
    u[i].p=-1;
    u[i].l=-1;
    u[i].r=-1;
  }

  for(i=0;i<n;i++){
    scanf("%d%d",&id,&k);
    for(j=0;j<k;j++){
      if(j==0){
	scanf("%d",&u[id].l);
	t=u[id].l;
	u[t].p=id;
      }
      else{
	scanf("%d",&u[t].r);
	t=u[t].r;
	u[t].p=id;
      }
    }
  }

  for(i=0;i<n;i++){
    if(u[i].p==-1){
      printf("node %d: parent = -1, depth = 0, root, [",i);
      t=u[i].l;
      while(t!=-1){
	printf("%d",t);
	t=u[t].r;
	if(t!=-1) printf(", ");
      }
      printf("]\n");
    }

    else if(u[i].l==-1){
      d=0;
      printf("node %d: parent = %d, ",i,u[i].p);
      t=u[i].p;
      while(t!=-1){
	t=u[t].p;
	d++;
      }
      printf("depth = %d, leaf, []\n",d);
    }
    
    else{
      d=0;
      printf("node %d: parent = %d, ",i,u[i].p);
      t=u[i].p;
      while(t!=-1){
	d++;
	t=u[t].p;       
      }
      printf("depth = %d, internal node, [",d);
      t=u[i].l;
      while(t!=-1){
	printf("%d",t);
	t=u[t].r;
	if(t!=-1) printf(", ");
      }
      printf("]\n");
    }
  }
  
  return 0;
}

Measured memory_bytes: 1788
//#include<bits/stdc++.h>
#include<cstdio>
#include<iostream>
#include<algorithm>
#include<cstring>
#include<cmath>
#include<map>
#include<queue>
#include<stack>
#include<set>
using namespace std;
#define int long long
#define ll long long
#define str string
#define db double
#define ac() cout<<"Yes"<<endl;
#define wa() cout<<"No"<<endl;
#define ddd cout<<"---debug---"<<endl;
#define ff(a,b) for(signed long long (a)=1;(a)<=(b);(a)++)
#define fff(a,b) for(signed long long (a)=0;(a)<(b);(a)++)
#define re readdd()
#define pr(a) printtt(a)
#define pee puts("");
#define eee putchar(' ');
#define pss(a) push_back(a)
#define ps(a) push(a)
int gcd(int a,int b){return b==0?a:gcd(b,a%b);}//
int ppow(int a,int b,int mod){a%=mod;//
int ans=1%mod;while(b){if(b&1)ans=(long long)ans*a%mod;
a=(long long)a*a%mod;b>>=1;}return ans;}
int readdd(){int x=0,f=1;char c=getchar();//
while(!isdigit(c)&&c!='-')c=getchar();
if(c=='-')f=-1,c=getchar();
while(isdigit(c))x=x*10+c-'0',c=getchar();
return f*x;}
void printtt(int x){if(x<0)putchar('-'),x=-x;
if(x>=10)printtt(x/10);putchar(x%10+'0');}
bool addd(int a,int b){return a>b;};
//
char s[105];
int check(int st,int ed){
    int l=st,r=ed;
    while(l<=r){
        if(s[l]!=s[r])return 0;
        l++,r--;
    }
    return 1;
}
signed main(){
    scanf("%s",s+1);
    int n=strlen(s+1);
    int ok=1;
    if(!check(1,n))ok=0;
    if(!check(1,(n-1)/2))ok=0;
    if(!check((n+3)/2,n))ok=0;
    if(ok)cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
    return 0;
}


Measured memory_bytes: 256
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define EPS (1e-7)
#define INF (1e9)
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) x.begin(),x.end()
const double PI = acos(-1);
const ll MOD = 1000000007;
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;
}
///////////////////////////////////////////////////////////////

int main() {
    ios::sync_with_stdio(false); cin.tie(nullptr);
    int N; cin >> N;
    vector<int> A(N);
    rep(i,N) cin >> A[i];
    
    vector<pair<int, int>> ans(2*N-2);
    int k = -1;
    int num = -1;
    rep(i,N) if (chmax(num,abs(A[i]))) k = i;
    if (A[k] == 0) {
        cout << 0 << endl;
    } else if (A[k] > 0) {
        int q = 0;
        rep(i,N) {
            if (i == k) continue;
            A[i] += A[k];
            ans[q] = make_pair(k+1,i+1);
            q++;
        }
        rep(i,N-1) {
            A[i+1] += A[i];
            ans[q] = make_pair(i+1,i+2);
            q++;
        }
        cout << 2*N-2 << endl;
        rep(i,2*N-2) {
            cout << ans[i].first << " " << ans[i].second << endl;
        }
    } else {
        int q = 0;
        rep(i,N) {
            if (i == k) continue;
            A[i] += A[k];
            ans[q] = make_pair(k+1,i+1);
            q++;
        }
        rep(i,N-1) {
            A[N-2-i] += A[N-1-i];
            ans[q] = make_pair(N-i,N-1-i);
            q++;
        }
        cout << 2*N-2 << endl;
        rep(i,2*N-2) {
            cout << ans[i].first << " " << ans[i].second << endl;
        }
    }
}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;

public class program{
    public static void Main(){
        var inputs = Console.ReadLine().Split(' ').ToArray();
        int a;
        int b;
        var s = new stack<int>();
        foreach(var i in inputs){
            if(i == "+"){
                a = s.pop();
                b = s.pop();
                s.push(a + b);
            }else if(i == "-"){
                a = s.pop();
                b = s.pop();
                s.push(b - a);
            }else if(i == "*"){
                a = s.pop();
                b = s.pop();
                s.push(a * b);
            }else{
                s.push(int.Parse(i));
            }
        }
        Console.WriteLine(s.pop());
    }

}

public class stack<T>{
    private T[] S;
    private int top;
    const int MAX = 200;
    public stack(){
        S = new T[MAX];
    }


    public void initialize(){
        top = 0;
    }

    public bool isEmpty(){
        return top == 0;
    }
    public bool isFull(){
        return top >= MAX - 1;
    }
    public void push(T x){
        S[++top] = x;
    }
    public T pop(){
        top--;
        return S[top+1];
    }
}



Measured memory_bytes: 9540
// Tazoe

#include <iostream>
using namespace std;

void eratos(bool prime[], int n)
{
	if(n>=1){
		prime[0] = false;
	}
	if(n>=2){
		prime[1] = false;
	}

	for(int i=2; i<n; i++){
		prime[i] = true;
	}

	for(int i=2; i*i<n; i++){
		if(!prime[i])
			continue;

		for(int j=i+i; j<n; j+=i){
			prime[j] = false;
		}
	}
}

int main()
{
	bool P[246913];
	eratos(P, 246913);

	while(true){
		int n;
		cin >> n;

		if(n==0)
			break;

		int cnt = 0;

		for(int i=n+1; i<=2*n; i++){
			if(P[i]){
				cnt++;
			}
		}

		cout << cnt << endl;
	}

	return 0;
}

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

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

    multiset<int> S;
    int res = 0;
    for(int i=0; i<N; ++i) {
        auto itr = S.lower_bound(A[i]);
        if(S.empty() || itr == S.begin()) {
            ++res;
            S.insert(A[i]);
        } else {
            S.erase(--itr);
            S.insert(A[i]);
        }
    } 
    cout << res << endl;
}

Measured memory_bytes: 5376
#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;
int main() {
	int koma, num;
	cin >> koma >> num;
	vector<int> pos(num);
	for (int i = 0; i < num; i++) {
		cin >> pos[i];
	}
	sort(pos.begin(), pos.end());
	vector<int> len;
	for (int i = 0; i < pos.size()-1; i++) {
		len.push_back(pos[i + 1] - pos[i]);
	}
	sort(len.begin(), len.end());
	int sum = 0;
	for (int i = 0; i < num - koma; i++) {
		sum += len[i];
	}
	cout << sum << endl;
	return 0;
}


Measured memory_bytes: 1276
// Problem : A - Not
// Contest : AtCoder - AtCoder Beginner Contest 178
// URL : https://atcoder.jp/contests/abc178/tasks/abc178_a
// Memory Limit : 1024 MB
// Time Limit : 2000 ms
// Powered by CP Editor (https://github.com/cpeditor/cpeditor)

#include<bits/stdc++.h>
using namespace std;
const long long int  modu=1e9+7;
#define endl '\n'
#define ll long long int
#define vi vector<int>
#define vl vector<ll>
#define inp(x)  for(auto &t:x) cin>>t;
#define itr     vector<int>::iterator
#define debug(a) cout << #a << "=" << a << ' '<<endl;
#define out(x)  for(auto &t:x) cout<<t<<" "; cout<<endl;
#define ff first
#define ss second
#define pb push_back
#define initialize(a,v)  for(int i=0;i<a.size();++i) a[i]=v;
#define all(x) x.begin(),x.end()
#define mpt(mp) for(auto it=mp.begin();it!=mp.end();it++)
#define trav(x) for(int i=0;i<(int)x.size();++i)
#define mkp(a,b) make_pair(a,b)
#define sz(x)  (int)x.size()

int noofdig(int N)
{
	return floor(log10(N))+1;
}


ll f(ll a)
{

return 0;

}



void pre()
{

}



void solve()
{
	 int n;
    cin>>n;
    cout<<(n^1)<<endl;
    





}



int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);

	int t=1;
//	cin>>t;
	while(t--)
	{
		solve();
	}
}


Measured memory_bytes: 3692
#pragma GCC optimize ("O3")
#include<bits/stdc++.h>


#include <cstdio>
#include <queue>
#include <set>
#include <string>
#include <stdbool.h>
#include<ctime>

#include <cstring>

#define pb push_back
#define p push

#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define ll long long

#define getI(a) scanf("%d",&a)
#define getII(a, b) scanf("%d%d",&a,&b)
#define getIII(a, b, c) scanf("%d%d%d",&a,&b,&c)
#define getL(a) scanf("%lld",&a)
#define getLL(a, b) scanf("%lld%lld",&a,&b)
#define getLLL(a, b, c) scanf("%lld%lld%lld",&a,&b,&c)
#define BEND(c) (c).begin(),(c).end()
#define BEND2(c) (c).rbegin(),(c).rend()
#define fi first
#define se second
#define pi 3.1415926535897932384626
#define getS(a) scanf("%s",a)
#define pfb(a) printf("%.10lf\n",a);
#define pfi(a) printf("%d",a);
#define pfii(a, b) printf("%d%d",a,b);
#define pfl(a) printf("%lld",a);
#define pfll(a, b) printf("%lld%lld",a,b);
#define pfd(a) printf("%.12lf ",a);
#define IOS ios_base::sync_with_stdio(false);cin.tie(0);
#define endl "\n"

#define MOD  ( int)(1e9 + 7)
#define MAXN (ll) ((1e6+5))
#define K 25
#define  ALPHABET_SIZE  26
//#define N (int)(1e5+10)
#define sag (sol|1)
#define sol (root<<1)
#define ort (bas+son)/2
#define INF (ll )1e18
#define int ll
using namespace std;
typedef vector<int> vi;
typedef vector<bool> vb;
typedef vector<vector<int>> vvi;
typedef vector<vector<pair<int, int>>> vvpi;
typedef vector<long long> vl;
typedef vector<pair<int, int>> vpi;
typedef vector<pair<long long, long long>> vpl;
typedef pair<int, int> pii;
typedef pair <ll, ll> pll;
typedef vector<vi> graph;


signed main(){
	IOS

	ll n, k; cin >> n >> k;
	ll ans = 0;
	for (ll i = k; i <= n + 1; i++){
		ans = (ans + i*(2 * n - i + 1) / 2 - i*(i - 1) / 2 + 1) % MOD;
	}
	cout << ans << endl;
}

Measured memory_bytes: 3616
#include <bits/stdc++.h>
#define FOR(i, a, b) for(int i=(a); i<(b); i++)
#define REP(i, n) FOR(i, 0, n)
#define all(x) (x).begin(), (x).end()
#define bit(x) (1L << (x))
using ll = long long;
using namespace std;

int calc(const map<int, int>& mp, int x) {
  int ret = 0;
  for(const auto& itr: mp){
    if(itr.first != x) ret += itr.second;
  }

  return ret;
}

int main() {
  int n; cin >> n;
  vector<int> a(n);
  REP(i, n) cin >> a[i];

  vector<map<int, int>> mp(2);
  vector<multimap<int, int>> mmp(2);
  REP(i, n) mp[i % 2][a[i]]++;
  
  REP(i, 2){
    for(const auto& itr: mp[i]){
      mmp[i].insert(make_pair(itr.second, itr.first));
    }
  }

  multimap<int,int>::reverse_iterator itr[] = {mmp[0].rbegin(), mmp[1].rbegin()};
  int ans = 0;
  if(itr[0]->second != itr[1]->second) {
    REP(i, 2) ans += calc(mp[i], itr[i]->second);

    cout << ans << endl;
    return 0;
  } else {
    REP(i, 2){
      if(next(itr[i]) == mmp[i].rend()){
        if(next(itr[1-i]) == mmp[1-i].rend()){
          ans = n / 2;

          cout << ans << endl;
          return 0;
        } else {
          ans = calc(mp[1-i], next(itr[1-i])->second);

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

    ans = numeric_limits<int>::max();
    REP(i, 2){
      int tmp = 0;
      tmp += calc(mp[i], itr[i]->second);
      tmp += calc(mp[1-i], next(itr[1-i])->second);

      ans = min(ans, tmp);
    }
  }

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 9984
import math

def is_prime(n):
  if n == 1: return False

  for k in range(2, int(math.sqrt(n)) + 1):
    if n % k == 0:
      return False

  return True

n = int(input())

if n % 2 == 0:
  if n == 2:
    print(n)
    exit()
  n += 1

while True:
  if is_prime(n):
    break
  n += 2
print(n)


Measured memory_bytes: 3060
import java.util.Scanner;

public class Main{

	public static void main(String args[]){

		Scanner sc = new Scanner(System.in);

		String st=sc.next();
		char nn[]=st.toCharArray();
		int n[]=new int[3];
		for(int i=0;i<3;++i){
			n[i]=Character.getNumericValue(nn[i]);
		}

		if(n[1]<=n[0] && n[2]<=n[0]){
			System.out.print(n[0]);
			System.out.print(n[0]);
			System.out.println(n[0]);
		}
		else {
			System.out.print(n[0]+1);
			System.out.print(n[0]+1);
			System.out.println(n[0]+1);
		}



	}
}


Measured memory_bytes: 23124
s = list(input())

x = s[0] == "R"
y = s[1] == "R"
z = s[2] == "R"

if x and y and z:
    print(3)
elif (x and y) or (y and z):
    print(2)
elif x or y or z:
    print(1)
else:
    print(0)




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

int main()
{
    int time, hrs, mins, secs, rems;
    cin >> time;
    // min = time / 60;
    hrs = time / 3600;
    rems = time - hrs * 3600;
    mins = rems / 60;
    rems = rems - (mins * 60);
    secs = rems;
    cout << hrs << ":" << mins << ":" << secs << endl;
}


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

using namespace std;
typedef long long ll;
const int maxn = 1005;


ll getans(ll a){
    if(a==0LL) return 0LL;
    ll flag = a % 4LL;
    if(flag == 0LL)
        return a;
    else if(flag == 1LL)
        return 1LL;
    else if(flag == 2LL)
        return a+1LL;
    else
        return 0LL;
}

int main()
{
    ll a, b;
    while(cin>>a>>b){
        ll ans = getans(b) ^ getans(a-1LL);
        cout<<ans<<endl;
    }
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#pragma GCC optimize("O999")
//示例：#define ll long long
//unsigned long long ;
const int INF=0x3f3f3f3f;
const int maxn=50000005;
using namespace std;

int main(){
	//freopen(".in", "r",stdin );
	//freopen(".out","w",stdout);
	ios::sync_with_stdio(0);
	int a;
	cin >> a;
	cout<<a+a*a+a*a*a<<endl;
	return 0;
}

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

int main(){
    int input, hour, minutes, second;

    cin >> input;

    hour = input / 3600;
    minutes = (input % 3600) / 60;
    second = input % 60;

    cout << hour << ":" << minutes << ":" << second << endl;
    return 0;
}



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

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

    long long sum = 0;
    for(long long i = 0; i < s.size(); i++){
        sum += s[i] - '0';
    }

    if(sum % 9 == 0) printf("Yes\n");
    else printf("No\n");

    return 0;
}

Measured memory_bytes: 3720
//============================================================================
// Name        : JOI.cpp
// Author      :
// Version     :
// Copyright   : Your copyright notice
// Description : Hello World in C++, Ansi-style
//============================================================================

#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <math.h>
using namespace std;
typedef long long ll;
string str;
int A,B;
int main(){
    cin>>A>>B;
    cin>>str;
    int R=0;
    for(int i=0;i<A+B+1;i++){
    	if(i==A){
    		if(str[i]=='-')R++;
    	}else{
    		if(str[i]!='-')R++;
    	}
    }
    if(R==(A+B+1)){
    	cout<<"Yes"<<endl;
    }else{
    	cout<<"No"<<endl;
    }
    return 0;

}


Measured memory_bytes: 256
//include
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <cmath> 
#include <iomanip>
#include <math.h>
#include <utility>
#include <functional>
#include <cstdlib>
#include <map>
#include <utility>
//using
using namespace std;
using vi = vector <int>;
using vl = vector <long long>;
using vs = vector <string>;
using vc = vector <char>;
using ll= long long;
using vvl = vector<vector<ll> >;
using vvc = vector<vector<char> >;
//vector<vector<char> > hyou(N, vector<char>(N));
using vd = vector <double>;
//define
//#define int long long
#define rep(i,n) for(int i=0; i<n; i++)
#define print(n) cout<<n<<endl;
#define sortp(d) sort(d.begin(),d.end()) //1234
#define sortm(d) sort(d.rbegin(),d.rend()) //4321
//素数判定　O(√A) 
bool is_prime(int x){
 if(x<=1) return false;
 for(int i=2;i*i<=x;i++)
 if(x%i==0) return false;
 return true;
 }
 //各位の和　
int wa(ll x)
{
ll sum = 0;
while(x!=0){
  sum += x% 10;
  x /= 10;
}
return sum;
}
/*順列生成
do {
  // 順列に対する処理
} while (next_permutation(配列変数.begin(), 配列変数.end()));*/

//絶対値　abs()
//文字→数字　'0' アルファベット→数字　'a'　'A'が65番,'a'が97番だわ
//型キャスト　char('a'+1)
//reverse 回文
//if(isupper('A'))->大なら真


//グローバル変数宣言
ll p=0,q=0,r=0;

int main()
{
  ll n,k;
  cin>>n>>k;
  vl h(n);
  rep(i,n)
  {
    cin>>h[i];
  }
  sortm(h);
  q=h[0];
  rep(i,n-k+1)
  {
    p=h[i]-h[i+k-1];
    q=min(p,q);
  }
  print(q);
}

Measured memory_bytes: 3996
#include <bits/stdc++.h>
#define fi first
#define se second
#define rep(i,n) for(ll i=0;i<(n);i++)
#define rrep(i,n) for(ll i = 1; i <= (n); ++i)
#define drep(i,n) for(ll i = (n)-1; i >= 0; --i)
#define all(v) v.begin(),v.end()
#define len(x) (ll)(x).length()
#define maxs(x,y) x = max(x,y)
#define mins(x,y) x = min(x,y)
#define pb push_back
#define sz(x) (ll)(x).size()
#define v(T) vector<T>
#define vv(T) vector<vector<T>>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
ll gcd(ll a,ll b){if(a%b==0){return b;}else{return(gcd(b,a%b));}}
ll lcm(ll a,ll b){return a/gcd(a,b)*b;}
const int INF=1e9;
const ll MX = 1e18;
const ll MOD=INF+7;
const int di[] = {-1,0,1,0};
const int dj[] = {0,-1,0,1};
const double PI=acos(-1);
#define dame { puts("-1"); return 0;}
#define yn {puts("Yes");}else{puts("No");}
#define YN {puts("YES");}else{puts("NO");}
const ll MAX = 1000001;
long long fac[MAX], finv[MAX], inv[MAX];
void COMinit() {fac[0] = fac[1] = 1;finv[0] = finv[1] = 1;inv[1] = 1;for (ll i = 2; i < MAX; i++){fac[i] = fac[i - 1] * i % MOD;inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;finv[i] = finv[i - 1] * inv[i] % MOD;}}
long long COM(ll n, ll k){if (n < k) return 0;if (n < 0 || k < 0) return 0;return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;}
ll llpow(ll n,ll i){ll cnt=n;  for(ll j=0;j<i-1;j++){n*=cnt;}return n;}

int main() {
  int n;
  cin>>n;
  vi dp(n+1);
  rrep(i,n){
    dp[i]=dp[i-1]+1;
    for(int j=1;i>=llpow(6,j);j++){
      mins(dp[i],dp[i-llpow(6,j)]+1);
    }
    for(int j=1;i>=llpow(9,j);j++){
      mins(dp[i],dp[i-llpow(9,j)]+1);
    }
  }
  cout<<dp[n]<<endl;
}    


Measured memory_bytes: 3768
def read():
    N, M = list(map(int, input().strip().split()))
    S = list()
    C = list()
    for i in range(M):
        s, c = list(map(int, input().strip().split()))
        S.append(s)
        C.append(c)
    return N, M, S, C

def solve(N, M, S, C):
    numbers = list(map(str, range(1000)))
    accepted = list()
    for number in numbers:
        if len(number) != N:
            continue
        is_accepted = True
        for i in range(M):
            if number[S[i]-1] != str(C[i]):
                is_accepted = False
        if is_accepted:
            accepted.append(number)
    if len(accepted) == 0:
        return -1
    return accepted[0]


if __name__ == '__main__':
    inputs = read()
    print("{}".format(solve(*inputs)))


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

using S = long long;
using F = long long;

const S INF = 8e18;
const F ID = 8e18;

// 区間に対する演算方法
S op(S a, S b) { return std::max(a, b); }
// 単位元 a⋅e = e⋅a = a
S e() { return -INF; }
// f(x) を返す関数
S mapping(F f, S x) { return (f == ID ? x : f); }
// f∘g を返す関数
F composition(F f, F g) { return (f == ID ? g : f); }
// id を返す関数
F id() { return ID; }

const long long SZ = 300005;
void solve() {
    int n, k;
    cin >> n >> k;
    vector<S> v(SZ);
    // 1点更新、区間最大値なので遅延ではないセグ木で十分だが、
    // 勉強のため遅延セグ木を用いる。最初の3つの引数は普通のセグ木と同じ。
    lazy_segtree<S, op, e, F, mapping, composition, id> seg(v);

    while (n--) {
        S x;
        cin >> x;
        // 過去に存在した x±k の座標に対する点の数の最大値を求める
        S me = seg.prod(max(0LL, x - k), min(SZ, x + k + 1));
        // 現在のx座標に対して上記+1をセット（区間更新）
        // seg.apply(x, x + 1, me + 1);
        seg.set(x, me + 1);
    }
    cout << seg.all_prod() << endl;
}

signed main() {
    cin.tie(nullptr)->sync_with_stdio(false);
    solve();
}

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

int main()
{
    int n;

    cin >> n;
    vector<int> a(n);                                             // 各要素は個数
    vector<vector<int>> x(n, vector<int>()), y(n, vector<int>()); // 各要素はa[j]個の人の番号

    for (int i = 0; i < n; i++)
    {
        cin >> a[i];

        x[i].resize(a[i]);
        y[i].resize(a[i]);

        //x,yのヴェクタ
        for (int j = 0; j < a[i]; j++)
        {
            int xx, yy;
            cin >> xx >> yy;
            x[i].push_back(xx); // x[i]にa[i]個入る
            y[i].push_back(yy);
        }
    }

    // 全探索の最大数
    int t = 1;
    for (int i = 0; i < n; i++)
    {
        t *= 2;
    }

    // メイン
    int maxAnswer = 0;

    // 全bit探索
    for (int i = 0; i < t; i++)
    {
        // 正直者と不親切な人をbitに変換
        vector<int> bitv(n, 0);

        // iを変えないためにkを導入
        int k = i;

        for (int j = 0; j < n; j++)
        {
            // 0か1を入れる
            //cout << k ;
            bitv[j] = k % 2;
            k = k / 2;
        }
        // ここまで切り出せそう？

        //answerの値の設定
        int answer = 0;
        for (int j = 0; j < n; j++)
        {
            if (bitv[j] == 1)
            {
                answer += 1;
            }
        }

        int frag;
        frag = 1;

        // 矛盾の確認
        for (int j = 0; j < n; j++) // 一回しか回ってない
        {
            // j番目が1ならx[j]にあるa[j]個の真偽を確認
            if (bitv[j] == 1)
            {
                for (int k = 0; k < x[j].size(); k++)
                {
                    if (bitv[x[j][k] - 1] != y[j][k])
                    {
                        frag = 0;
                        break;
                    }
                }
            }
            // frag==0なら矛盾してるのでbreak
            if (frag == 0)
            {
                break;
            }
        }

        // frag==1で大きくなっているなら値を更新
        if (answer > maxAnswer && frag == 1)
        {
            maxAnswer = answer;
        }
    }
    cout << maxAnswer << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<cmath>
using namespace std ;
typedef long long ll ;
ll cal(ll n)
{
   return (ll)(log(n)/log(2));
}
int main()
{
    ll info[50],l=2,sum=0;
    info[0]=1;
    for(int i=1;i<40;i++)
    {
        info[i]=(ll)info[i-1]*l;
    }
    ll n,ans;
    cin >> n ;
    ans=cal(n);
    for(int i=0;i<=ans;i++)
    {
       sum+=info[i];
       ///cout << info[i] << " " ;
    }
    cout << sum << endl;
    return  0 ;
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
#define ALL(A) (A).begin(), (A).end()
#define ll long long
#define rep(i, n) for (int i = 0; i < (n); i++)

using namespace std;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

int dx[] = { 0, 1, -1, 0, 1, -1, 1, -1 };  // i<4:4way i<8:8way
int dy[] = { 1, 0, 0, -1, 1, -1, -1, 1 };

const ll mod = 1e9 + 7;
const ll INF = -1 * ((1LL << 63) + 1);
const int inf = -1 * ((1 << 31) + 1);

const int MAX = 1e7;
const int MOD = 1000000007;

long long fac[MAX], finv[MAX], inv[MAX];

// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

// 二項係数計算
long long COM(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

int main(void){
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(20);
    COMinit();
    ll n,m;
    cin >> n >> m;
    // m を素因数分解する
    vector<pair<int,int>> p;
    for(ll i=2;i*i<=m;i++){
        int cnt = 0;
        while(m%i == 0 && m>1){
            cnt++;
            m/=i;
        }
        if(cnt)p.push_back({i,cnt});
    }
    if(m>1)p.push_back({m,1});
    ll ans = 1;
    for(auto x:p){
        ans *= COM(x.second+n-1,n-1);
        ans %= mod;
    }
    cout << ans%mod << endl;
}

Measured memory_bytes: 234624
using System;

namespace B
{
    class Program
    {
        static void Main(string[] args)
        {
            var S = Console.ReadLine();
            var T = Console.ReadLine();

            var max = 0;
            for (int i = 0; i + T.Length <= S.Length; i++)
            {
                var current = 0;
                for (int j = 0; j < T.Length; j++)
                {
                    if (S[i + j] == T[j]) current++;
                }
                if (max < current) max = current;
            }
            Console.WriteLine(T.Length - max);
        }
    }
}


Measured memory_bytes: 25948
#include<iostream>
#include<iomanip>
#include<cstdio>
#include<string>
#include<cstring>
#include<climits>
#include<algorithm>
#include<vector>
#include<cmath>
#include<map>
#include<set>
#include<stack>
#include<queue>
#include<tuple>
#include<list>
#include<unordered_map>
#define ll long long
#define pii pair<int,int>
#define pll pair<ll,ll>
#define vii vector<int>
#define vll vector<ll>
#define lb lower_bound
#define pb push_back
#define mp make_pair
#define rep(i,n) for(ll i=0;i<n;i++)
#define rep2(i,a,b) for(ll i=a;i<b;i++)
#define repr(i,n) for(ll i=n-1;i>=0;i--)
#define all(x) x.begin(),x.end()
#define INF (1 << 30) - 1
#define LLINF (1LL << 61) - 1
// #define int ll
using namespace std;
const int MOD = 1000000007;
const int MAX = 510000;

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll n,a[100010],cnt=0,cnt2=0,cnt4=0;
    cin>>n;
    rep(i,n){
        cin>>a[i];
        if(a[i]%2==1) cnt++;
        if(a[i]%4==0) cnt4++;
        else if(a[i]%2==0) cnt2++;
    }
    // cout<<cnt<<" "<<cnt2<<" "<<cnt4<<endl;
    if((cnt<=cnt4)||(cnt==cnt4+1 && cnt2==0)) cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
    return 0;
}

Measured memory_bytes: 1024
// #pragma GCC optimize(3, "Ofast", "inline")
#include <bits/stdc++.h>
#define String std::string
#define fir first
#define sec second
#define mp std::make_pair
#define Pair std::pair<int, int>
#define Map std::map< int, int >
#define Vector std::vector<int>

typedef long long ll;
typedef unsigned long long ull;

const int N = 1e5 + 5;
const int MOD = 1e9 + 7;
const int inv2 = 500000004;
const int dx[] = { 0, 1, -1, 0, 1, -1, 1, -1 };
const int dy[] = { 1, 0, 0, -1, 1, -1, -1, 1 };

inline ll read() {
    ll res = 0, f = 1;
    char ch = getchar();
    for (; !isdigit(ch); ch = getchar()) if (ch == '-') f = -1;
    for (; isdigit(ch); ch = getchar()) res = (res << 1) + (res << 3) + ch - '0';
    return res * f;
}

struct Triple {
    int pos;
    int fir, sec;

    bool operator<(const Triple &other) const {
        return pos < other.pos;
    }
} a[10];

int n, fact;
// Pair a[10];

inline int sqr(int x) {
    return x * x;
}

inline double dist(int i, int j) {
    return sqrt(sqr(a[i].fir - a[j].fir) + sqr(a[i].sec - a[j].sec));
}

int main() {
    scanf("%d", &n);
    fact = 1;
    for (int i = 1; i <= n; i++) fact *= i;
    for (int i = 1; i <= n; i++) {
        std::cin >> a[i].fir >> a[i].sec;
        a[i].pos = i;
    }
    double sum = 0;
    do {
        for (int i = 1; i < n; i++) {
            sum += dist(i, i + 1);
        }
    } while (std::next_permutation(a + 1, a + n + 1));
    printf("%.10lf\n", sum / fact);
    return 0;
}

Measured memory_bytes: 256
#include <stdlib.h>
#include <iostream>
#include <algorithm>
#include <vector>
#include <map>
#include <cmath>

using namespace std;


int main(void){

    int n;
    cin >> n;

    int p[n+5];
    for(int i=0;i<n;i++){
        cin >> p[i];
    }

    int ans=0;
    for(int i=0;i<n-1;i++){
        if(i+1 == p[i]){
            int tmp = p[i];
            p[i] = p[i+1];
            p[i+1] = tmp;
            ans++;
        }
    }
    if(p[n-1] == n){
        ans++;
    }
    cout << ans << endl;
    return 0;
}

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

using namespace std;

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

	vector<int> A(M, 0);

	for (int i = 0; i < N; ++i) {
		int K;
		cin >> K;
		for (int j = 0; j < K; ++j) {
			int x;
			cin >> x;
			--x;
			++A[x];
		}
	}

	int ans = 0;
	for (int x : A) {
		if (x == N) {
			++ans;
		}
	}
	cout << ans << endl;
}


Measured memory_bytes: 256
import java.util.Arrays;
import java.util.Comparator;
import java.util.Scanner;

//Village
public class Main{

	double[] x, y;
	
	void run(){
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		double R = sc.nextDouble(), EPS = 1e-8;
		double cos1 = Math.cos(1*Math.PI/180), sin1 = Math.sin(1*Math.PI/180);
		x = new double[n]; y = new double[n];
		for(int i=0;i<n;i++){
			double X = sc.nextDouble(), Y = sc.nextDouble();
			x[i] = cos1*X-sin1*Y;
			y[i] = sin1*X+cos1*Y;
		}
		Integer[] V = new Integer[n];
		for(int i=0;i<n;i++)V[i]=i;
		Arrays.sort(V, new Comparator<Integer>() {
			public int compare(Integer o1, Integer o2) {
				return (int)Math.signum(x[o1]-x[o2]);
			}
		});
		int[] v = new int[n];
		for(int i=0;i<n;i++)v[i]=V[i];
		int res = 0;
		boolean[] u = new boolean[n];
		for(int i=0;i<n;i++){
			int idx = v[i];
			if(u[idx])continue;
			u[idx] = true;
			res++;
			double lx = x[idx]-R-EPS, rx = x[idx]+R+EPS;
			int l = 0, r = n;
			while(r-l>1){
				int m = (l+r)/2;
				if(lx<=x[v[m]])r=m;
				else l=m;
			}
			int k1 = l;
			l = 0; r = n;
			while(r-l>1){
				int m = (l+r)/2;
				if(rx<x[v[m]])r=m;
				else l=m;
			}
			int k2 = r;
			if(k2==r)k2--;
			for(int j=k1;j<=k2;j++){
				int k = v[j];
				if(u[k])continue;
				if((x[idx]-x[k])*(x[idx]-x[k]) + (y[idx]-y[k])*(y[idx]-y[k]) < R*R + EPS){
					u[k] = true;
				}
			}
		}
		System.out.println(res);
	}
	
	public static void main(String[] args) {
		new Main().run();
	}
}

Measured memory_bytes: 20000
// AOJ 1175: And Then. How Many Are There?
// 2017.12.21 bal4u@uu

#include <stdio.h>
#include <string.h>
#include <math.h>

typedef struct { int s, del, m; } Q;
Q q[100000]; int top;
typedef struct { int x, y, r; } T;
T d[25];
int col[4][6], clen[4]; char f[5];
int up[25][25], ulen[25];		// ?????????????????????????????°??¨??????
char visited[16777216];

int main()
{
	int n, i, j, k, a, c, cmax, p, r, s, del, m, ans;

	while (scanf("%d", &n) && n > 0) {
		memset(clen, 0, sizeof(clen)), memset(f, -1, sizeof(f)), cmax = 0;
		for (i = 0; i < n; i++) {
			scanf("%d%d%d%d", &d[i].x, &d[i].y, &d[i].r, &c);
			if  (f[c] >= 0)          c = f[c];
			else f[c] = cmax++, c = cmax-1;

			col[c][clen[c]++] = i;
		}

		memset(ulen, 0, sizeof(ulen));
		for (i = 0; i < n; i++) for (j = i+1; j < n; j++) {
			if (hypot(d[i].x-d[j].x, d[i].y-d[j].y) < d[i].r+d[j].r) up[j][ulen[j]++] = i;
		}

		ans = 0;
		memset(visited, 0, sizeof(visited));
		q[0].s = 0, q[0].del = 0, q[0].m = n, top = 1;
		while (top) {
			s = q[--top].s, del = q[top].del, m = q[top].m;

			if (m == 1 || visited[s]) continue;
			visited[s] = 1;
			for (c = 0; c < cmax; c++)if (clen[c] >= 2) for (p = 0; p < clen[c]; p++) {
				i = col[c][p];
				if (s & (1<<i)) continue;
				for (k = 0; k < ulen[i]; k++) {
					a = up[i][k];
					if (!(s & (1<<a))) goto next;
				}

				for (r = 0; r < clen[c]; r++) {
					if (r == p) continue;
					j = col[c][r];
					if (s & (1<<j)) continue;
					for (k = 0; ; k++) {
						if (k == ulen[j]) {
							if (del+2 > ans) ans = del+2;
							q[top].s = s|(1<<i) | (1<<j), q[top].del = del+2, q[top++].m = m-2;
							break;
						}
						a = up[j][k];
						if (!(s & (1<<a))) break;
					}
				}
				next:;
			}
		}
		printf("%d\n", ans);
	}
	return 0;
}

Measured memory_bytes: 18232
#include<stdio.h>
int main(){
    int N,M,i,j,k,l,ans=0;
    scanf("%d %d",&N,&M);
    int a[M],b[M],canreach[N];
    for (i=0;i<M;i++){
        scanf("%d %d",&a[i],&b[i]);
        a[i]--;
        b[i]--;
    }
    //i番目がループかどうか調べる
    for (i=0;i<M;i++){
        for(j=0;j<N;j++){
            canreach[j]=0;
        }
        canreach[a[i]]=1;
        //たかだかN回探索すれば、N辺より長いループは存在しない
        for(j=0;j<N;j++){
            //canreach[k]==1なるkを端点に持つi番目でない辺(l番目)の、もう片方の端点について、canreach[*]=1にする
            for(k=0;k<N;k++){
                if(canreach[k]==1){
                    for(l=0;l<M;l++){
                        if(l!=i){
                            if(a[l]==k){canreach[b[l]]=1;}
                            if(b[l]==k){canreach[a[l]]=1;}
                        }
                    }
                }
            }
        }
        if(canreach[b[i]]==0){ans++;}
    }
    printf("%d",ans);
    return 0;
}

Measured memory_bytes: 128
n = int(input())
res = ""
if n == 0:
    print(0)
    exit(0)
while n!=1 and n != 0:
    if n%(-2):
        res = "1" + res
    else:
        res = "0" + res
    n = (-(n//2))
if n == 1:
    res = "1" + res
print(res)


Measured memory_bytes: 2940
import heapq

N = int(input())

es = [[] for _ in range(N)]
for _ in range(N-1):
    a,b = map(int, input().split())
    es[a-1].append(b-1)
    es[b-1].append(a-1)

INF = float("inf")


# ダイクストラでフェネック君の開始地点からの距離を探索
dist_f = [INF] * N
dist_f[0] = 0
q = [(0,0)]
while q:
    cost, curr = heapq.heappop(q)
    if dist_f[curr] < cost:
        continue
    for nxt in es[curr]:
        if dist_f[nxt] < dist_f[curr] + 1:
            continue
        dist_f[nxt] = dist_f[curr] + 1
        heapq.heappush(q, (dist_f[nxt], nxt))

# ダイクストラですぬけ君の開始地点からの距離を探索
dist_s = [INF] * N
dist_s[N-1] = 0
q = [(0,N-1)]
while q:
    cost, curr = heapq.heappop(q)
    if dist_s[curr] < cost:
        continue
    for nxt in es[curr]:
        if dist_s[nxt] < dist_s[curr] + 1:
            continue
        dist_s[nxt] = dist_s[curr] + 1
        heapq.heappush(q, (dist_s[nxt], nxt))

cnt_f = 0
cnt_s = 0
for i in range(1,N-1):
    if dist_f[i] <= dist_s[i]:
        cnt_f += 1
    else:
        cnt_s += 1

if cnt_f > cnt_s:
    print("Fennec")
else:
    print("Snuke")



Measured memory_bytes: 29076
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <cstring>
#include <complex>
#include <stack>
#include <queue>
#include <unordered_map>
#include <set>
#include <map>

#define INF 100000000
#define rep(i, a) for (int i = 0; i < (a); i++)
using namespace std;
using P = pair<int, int>;

const int MAX = 1000000;
const int MOD = 1000000007;


long long fac[MAX], finv[MAX], inv[MAX];

/*
//テーブルの前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        //そのまま計算すると負の値になるのでMODを足す
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

// 二項係数計算
long long COM(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

//二分累乗法
long long modpow(long long a, long long n, long long mod) {
    long long res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}
*/


//UnionFind木
struct UnionFind{
   vector<long long int> par; //par[i] : iの親の番号
   vector<long long int> rnk; //root[i] : iの木のサイズ

   //コンストラクタ
   UnionFind(long long int n): par(n), rnk(n){
       //木の初期化
       for(long long int i = 0; i < n; i++){
           par[i] = i;
           rnk[i] = 1;
       }
   }

   //データxが属する木の根を再帰で取得
   long long int root(long long int x){
       if(par[x] == x){
           return x;
       }else{
           return par[x] = root(par[x]);
       }
   }

   //xとyが同じ木に属しているかを判定
   bool same(long long int x, long long int y){
       return root(x) == root(y);
   }

   //xとyの木を併合
   void unite(long long int x, long long int y){
       long long int rx = root(x); //xの根
       long long int ry = root(y); //yの根
       if(rx == ry) return; //根が同じならそのまま

       //併合するときにサイズを足し合わせる
       if(rnk[rx] < rnk[ry]){
           par[rx] = ry;
           rnk[ry] += rnk[rx];
       }else{
           par[ry] = rx;
           rnk[rx] += rnk[ry];
       }
   }

   //属している木のサイズを取得
   long long int size(long long int x){
       return rnk[root(x)];
   }
};


/*
typedef struct edge{
   int to;
   int cost;
} edge;

vector<edge> graph[2010];
long long int d[2010];

void dijkstra(int s){
   priority_queue<P, vector<P>, greater<P> > que;
   for(int i = 0; i < 2010; i++){
       d[i] = INF;
   }
   d[s] = 0;
   que.push(P(s, 0));

   while (!que.empty()) {
       P p = que.top();
       que.pop();
       int v = p.first;
       if (d[v] < p.second) continue;

       for (int i=0; i<graph[v].size(); ++i) {
           edge e = graph[v][i];
           if (d[e.to] > d[v] + e.cost) {
               d[e.to] = d[v] + e.cost;
               que.push(P(e.to, d[e.to]));
           }
       }
   }
}
*/

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

    UnionFind uf(n);

    int i;
    for(i = 0; i < m; i++){
        int x, y, z;
        cin >> x >> y >> z;
        uf.unite(x-1, y-1);
    }

    map<int, int> ma;
    for(i = 0; i < n; i++){
        ma[uf.root(i)]++;
    }

    cout << ma.size() << endl;
}


Measured memory_bytes: 6528
import java.util.Scanner;

public class Main{
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int i,n,a,ave,max=0,min=1000,sum=0;
		while(true){
			n = sc.nextInt();
			if(n==0)break;
			for(i=0;i<n;i++){
				a=sc.nextInt();
				if(max<a)max=a;
				if(min>a)min=a;
				sum+=a;
			}
			sum-=max+min;
			ave = sum/(n-2);
			System.out.println(ave);
			max=0;
			min=1000;
			sum=0;
		}
	}
}



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

using namespace std;

#define inf 1<<30
#define pqueue priority_queue
#define mp make_pair
#define pb push_back
#define fn fill_n
typedef long long llong;
typedef unsigned long long ullong;
typedef pair<int, int> P;


int main(){
	int N;
	vector< vector<int> > happy(100000, vector<int>(3, 0));
	vector< vector<llong> > dp(100000, vector<llong>(3,0));
	cin >> N;
	for(int i = 0; i < N; i++)
		cin >> happy[i][0] >> happy[i][1] >> happy[i][2];

	dp[0][0] = happy[0][0], dp[0][1] = happy[0][1], dp[0][2] = happy[0][2];
	for(int i = 1; i < N; i++){
		for(int j = 0; j < 9; j++){
			int yst = j/3, tdy = j%3;
			if(yst == tdy) continue;
			dp[i][tdy] = max(dp[i][tdy], dp[i-1][yst] + happy[i][tdy]);
		}
	}

	cout << max({dp[N-1][0], dp[N-1][1], dp[N-1][2]}) << endl;

	return 0;
}

Measured memory_bytes: 11136
import java.util.*;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        double[] v = new double[N];
        for(int i = 0; i < N; i++){
            v[i] = sc.nextDouble();
        }
        Arrays.sort(v);
        //System.out.println(Arrays.toString(v));
        double sum = v[0];
        for(int i = 1; i < N; i++){
            sum = (sum + v[i])/2;
        }
        System.out.println(sum);
	}
}

Measured memory_bytes: 23636
import java.util.*;

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

Scanner sc = new Scanner(System.in);
Set<Integer> hs = new HashSet<>();
hs.add(sc.nextInt());
hs.add(sc.nextInt());
hs.add(sc.nextInt());
System.out.println(hs.size());

}
}



Measured memory_bytes: 23764
<?php
//error_reporting(0);
//$N = trim(fgets(STDIN));
list($A,$B) =  explode(" ",trim(fgets(STDIN)));
//$H = explode(" ",trim(fgets(STDIN)));

$tap = 1;
$ans = 0;
while($tap < $B) {
  $tap--;
  $tap+=$A;
  $ans++;
}
printf("%d\n",$ans);


Measured memory_bytes: 4728
#include<bits/stdc++.h>
#define watch(x) cout << (#x) << " is " << (x) << endl
typedef long long ll;
using namespace std;
int static fast = [](){
  ios::sync_with_stdio(false);
  cin.tie(0); cout.tie(0); return 0;
}();
typedef long long ll;
int main() {
    ll k, n, val;
    cin >> n >> k;
    vector<ll> prefix = {0};
    for(int i = 0; i < n; i++) {
        cin >> val;
        val += prefix.back();
        prefix.emplace_back(val);
    }
    unordered_map<ll, vector<int>> grp;
    for(int i = 0; i < prefix.size(); i++) {
        prefix[i] = (prefix[i]-i)%k;
        grp[prefix[i]].push_back(i);
    }
    ll ans = 0;
    for(auto& p: grp) {
        auto& vec = p.second;
        // cout << p.first << ", ";
        for(int i = 0; i< vec.size(); i++) {
            // cout << vec[i] << " ";

            if (vec[i] == 0) continue;
            int lower_val = vec[i] - k;
            auto it = upper_bound(vec.begin(), vec.end(), lower_val);
            ll lower_idx = distance(vec.begin(), it);
            ans += min(i - lower_idx, k-1);
        }
        // cout << endl;
    }
    cout << ans << endl;
    return 0;
}




Measured memory_bytes: 19440