akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <algorithm>
#include <queue>
#include <stack>
#include <cmath>
#include <cstdio>
#include <string>
#include <sstream>

using namespace std;

#define rep(i, n) for(int i = 0; i < (int)n; ++i)
#define repn(i, n) for(int i = 1; i <= (int)n; ++i)
#define pb push_back
#define lb lower_bound
#define mp make_pair
#define ite iterator
#define max2(x, y) ((x) > (y)) ? (x) : (y)
#define max3(x,y,z) max2((x), max2((y),(z)))
#define max4(v,w,x,y) max2(max2((v),(w)), max2((x),(y)))
#define min2(x, y) ((x) > (y)) ? (y) : (x)
#define min3(x,y,z) min2((x), min2((y),(z)))
#define min4(v,w,x,y) min2(min2((v),(w)), min2((x),(y)))
#define ul unsigned long
#define ull unsigned long long
#define INF 1000000007
#define MOD 1000000007
#define fs first
#define sd second

template<typename T>
bool elem(set<T> st, T val){
	return (st.find(val) != st.end());
}

template<typename T>
void printv(vector<T> vt){
    rep(i, vt.size() - 1)
        cout << vt[i] << " ";
    cout << vt[vt.size() - 1] << endl;
}

typedef vector<int> vint;
typedef vector<ul> vul;
typedef vector<ull> vull;
typedef pair<int, int> pii;


int main(void){
    string str;
    cin >> str;
    rep(i, str.length()) cout << str[str.length() - 1 - i];
    cout << endl;
    return 0;
}

Measured memory_bytes: 1168
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using vl = vector<ll>;
using vd = vector<ld>;
using vs = vector<string>;
using vb = vector<bool>;
#define pb push_back
#define eb emplace_back
#define fi first
#define se second
template<class T> using vc = vector<T>;
template<class T> using vvc = vector<vector<T>>;
using Graph = vector<vector<ll>>;
const ll INF = 1LL << 60;
void init() {cin.tie(0);ios::sync_with_stdio(false);cout << fixed << setprecision(15);}
#define tl 1'000'000'007
#define REP(i, n) for (ll i = 0; i < n; i++)
#define REREP(i, n) for (ll i = n; i >= 0; i--)
#define FOR(i, a, n) for (ll i = a; i < n; i++)
#define REFOR(i, n, a) for (ll i = n; i >= a; i--)
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() ) //被り削除
#define debug cout << "line : " << __LINE__ << " debug" << endl;
#define ini(...) int __VA_ARGS__; in(__VA_ARGS__)
#define inl(...) long long __VA_ARGS__; in(__VA_ARGS__)
#define ind(...) long double __VA_ARGS__; in(__VA_ARGS__)
#define ins(...) string __VA_ARGS__; in(__VA_ARGS__)
#define inc(...) char __VA_ARGS__; in(__VA_ARGS__)
void in(){} template <typename T,class... U> void in(T &t,U &...u){ cin >> t; in(u...);}
void out(){cout << endl;} template <typename T,class... U> void out(const T &t,const U &...u){ cout << t; if(sizeof...(u)) cout << " "; out(u...);}
template<typename T>void die(T x){out(x); exit(0);}
#define in1(A) REP(i,A.size()) in(A[i]);
#define in2(A,B) REP(i,A.size()) in(A[i],B[i]);
#define in3(s,t,u) REP(i,sz(s)){in(s[i] , t[i] , u[i]);}
#define in4(s,t,u,v) REP(i,sz(s)){in(s[i] , t[i] , u[i] , v[i]);}
#define each(x,v) for(auto& x : v)
#define all(v) (v).begin(),(v).end()
#define sz(v) ((int)(v).size())
struct Point{ ld x,y; };
ld dist(Point a, Point b){return sqrt(abs(a.x-b.x)*abs(a.x-b.x)+abs(a.y-b.y)*abs(a.y-b.y));} // ２点間の距離 
ll gcd(ll a, ll b) { return b != 0 ? gcd(b, a % b) : a; }
ll lcm(ll a,ll b){ return a / gcd(a,b) * b;} 
ll fact(ll n){ if(n < 2) return 1; return (n * fact(n-1))%tl; } //階乗
// template <class A, class B> inline ll updiv(A &a,const B &b){ return (a + b - 1) / b; } //切り上げ
template<typename T,typename U>ll ceil(T a,U b){return (a + b - 1) / b;}
template <class A, class B> inline bool chmax(A &a, const B &b) { return b > a && (a = b, true); }
template <class A, class B> inline bool chmin(A &a, const B &b) { return b < a && (a = b, true); }
//-------------------------------------------------------------------------------------------------
int main(){
    init();
    inl(n,m);
    map<int,int> T;
    REP(i,m){
        ini(a,b);
        T[a]++;
        T[b]++;
    }
    FOR(i,1,n+1) out(T[i]);
}

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

constexpr ll MOD=1e9+7;
class mod {
public:
    mod() {m_n = 0;}
    mod(ll n) {if (n >= 0) m_n = n % MOD; else m_n = n % MOD + MOD;}
    friend bool operator== (const mod& a, const mod& b) {return a.m_n == b.m_n;}
    friend bool operator!= (const mod& a, const mod& b) {return !(a == b);}
    friend mod operator+ (const mod& a, const mod& b) {return (a.m_n + b.m_n) % MOD;}
    friend mod& operator+= (mod& a, const mod& b) {return a = a + b;}
    friend mod operator- (const mod& a) {return -a.m_n;}
    friend mod operator- (const mod& a, const mod& b) {return (a.m_n + (-b.m_n)) % MOD;}
    friend mod& operator-= (mod& a, const mod& b) {return a = a - b;}
    friend mod operator* (const mod& a, const mod& b) {return (a.m_n * b.m_n) % MOD;}
    friend mod& operator*= (mod& a, const mod& b) {return a = a * b;}
    friend mod mod_pow(const mod& n, ll r) {
        if (r == 0) {
            return 1;
        } else if (r < 0) {
            return mod_pow(n, (MOD - 2) * (-r));
        } else if (r % 2 == 0) {
            mod tmp = mod_pow(n, r / 2);
            return tmp * tmp;
        } else {
            return n * mod_pow(n, r - 1);
        }
    }
    friend mod operator/ (const mod& a, const mod& b) {return a * mod_pow(b, -1);}
    friend mod& operator/= (mod& a, const mod& b) {return a = a / b;}
    friend ostream& operator<< (ostream& os, const mod& n) {os << n.m_n; return os;}
    friend istream& operator>> (istream& is, mod& n) {ll tmp; is >> tmp; n = mod(tmp); return is;}
private:
    ll m_n;
};

const int MAX = 510000;
//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() {
#if LOCAL&0
    std::ifstream in("input.txt");
    std::cin.rdbuf(in.rdbuf());
#endif
    COMinit();

    int N,A,B,C;
    cin>>N>>A>>B>>C;
    mod a=mod(A)/mod(A+B);
    mod b=mod(B)/mod(A+B);
    mod p=mod(A)/mod(100)+mod(B)/mod(100);
    mod invp=1/p; //引き分けの期待値
    mod ans=0;
    //Aの確率p
    //Bの確率q
    for(int i=0;i<N;++i){
        mod ncr = COM(N-1+i,N-1);
        ans+=mod_pow(a,N)*mod_pow(b,i)*ncr*mod(N+i); //N+i回、Aが勝つ:p^n*q^i*(N-1+i)C(N-1)*(N+i)
        ans+=mod_pow(b,N)*mod_pow(a,i)*ncr*mod(N+i); //N+i回、Bが勝つ:q^n*p^i*(N-1+i)C(N-1)*(N+i)
    }
    cout<<ans*invp<<endl;
    return 0;
}

Measured memory_bytes: 12160
#include <bits/stdc++.h>
using namespace std;
#define SC               scanf
#define PF               printf
#define ull              unsigned long long
#define ld               long double
#define D                double
#define F                first
#define S                second
#define pb               push_back
#define pf               push_front
#define MP               make_pair
#define sort_a(a)        sort(a.begin(),a.end());
#define sort_d(a)        sort(a.rbegin(),a.rend());
#define READ(f)          freopen(f, "r", stdin)
#define WRITE(f)         freopen(f, "w", stdout)
#define rev(s)           reverse(s.begin(),s.end())
#define it(it,mp)        for(auto it=mp.begin() ; it!=mp.end() ; it++)
#define IOS              ios_base :: sync_with_stdio(false); cin.tie(NULL);
const int N = 1e5 + 5;
const int inf = 1e9 + 1;
const double eps = 1e-15;
const double EPS = 1e-9;
const double PI = acos(-1.0);
typedef long long int                   ll;
typedef pair<int,int>                   PII;
int main()
{
    IOS
    // READ("test.txt");
    //WRITE("");
    ll a, b, x ;
    cin >> a >> b >> x ;
    if(a==b && a==0){
        return cout<<1<<endl,0;
    }
    cout<<(b/x)-(a==0?-1:(a-1)/x)<<endl;
}


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

using namespace std;

#define ALL(g) (g).begin(),(g).end()
#define REP(i, x, n) for(int i = (int) x; i < (int)n; i++)
#define rep(i,n) REP(i,0,n)
#define RREP(i, x, n) for(int i = (int) n; i > (int)x; i--)
#define rrep(i,n) RREP(i,0,n)
#define F(i,j,k) fill(i[0],i[0]+j*j,k)
#define P(p) cout<<(p)<<endl;
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define INF 1<<25
#define pb push_back
#define SZ(x) ((int)(x).size())

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

int main (){

  int a , b;
  cin >>a >> b;
  if(a+b<=23){
  P(a+b);
  }else{
    P(a+b-24)
      }
  return 0;
}


Measured memory_bytes: 256
package main

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

func wordScanner() *bufio.Scanner {
	sc := bufio.NewScanner(os.Stdin)
	sc.Split(bufio.ScanWords)
	return sc
}

func getInt(sc *bufio.Scanner) int {
	sc.Scan()
	i, err := strconv.Atoi(sc.Text())
	if err != nil {
		panic(err)
	}
	return i
}

func getString(sc *bufio.Scanner) string {
	sc.Scan()
	s := sc.Text()
	return s
}

type task struct {
	a int
	b int
}

type byB []task

func (a byB) Len() int           { return len(a) }
func (a byB) Swap(i, j int)      { a[i], a[j] = a[j], a[i] }
func (a byB) Less(i, j int) bool { return a[i].b < a[j].b }

func main() {
	var n int
	fmt.Scan(&n)

	sc := wordScanner()

	tasks := make([]task, n)
	for i := range tasks {
		tasks[i].a = getInt(sc)
		tasks[i].b = getInt(sc)
	}

	sort.Sort(byB(tasks))

	sum := 0
	ans := "Yes"
	for _, task := range tasks {
		sum += task.a
		if sum > task.b {
			ans = "No"
			break
		}
	}

	fmt.Println(ans)
}


Measured memory_bytes: 6272
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Scanner;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 *
 * @author silviase
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        Scanner in = new Scanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        LCS solver = new LCS();
        solver.solve(1, in, out);
        out.close();
    }

    static class LCS {
        public void solve(int testNumber, Scanner in, PrintWriter out) {

            int q = in.nextInt();
            for (int i = 0; i < q; i++) {
                String s = in.next();
                String t = in.next();
                out.println(Str.LongestCommonSubsequence(s, t));
            }

        }

    }

    static class Str {
        public static int LongestCommonSubsequence(String s, String t) {
            int[][] dp = new int[s.length() + 1][t.length() + 1];
            for (int i = 0; i <= s.length(); i++) {
                for (int j = 0; j <= t.length(); j++) {
                    if (i == 0 || j == 0) {
                        dp[i][j] = 0;
                    } else {
                        if (s.charAt(i - 1) == t.charAt(j - 1)) {
                            dp[i][j] = dp[i - 1][j - 1] + 1;
                        } else {
                            dp[i][j] = Math.max(dp[i - 1][j], dp[i][j - 1]);
                        }
                    }
                }
            }
            return dp[s.length()][t.length()];
        }

    }
}




Measured memory_bytes: 65908
#include<bits/stdc++.h>
#include <bitset>
using namespace std;
#define ll long long 
#define ld long double
#define MOD 1000000007
#define mod9 1000000009
#define mod 1000003
#define fast ios_base :: sync_with_stdio(0);cin.tie(NULL);cout.tie(NULL);
#define mp make_pair
#define pb push_back
#define test ll t;cin>>t;while(t--)
#define bi begin()
#define ei end()
#define fi first 
#define se second  
#define forn(a,b) for(ll i=a;i<b;i++)
#define sz(s) s.size()     
#define pi 3.14159265358979323846
#define sp(x) cout<<fixed<<setprecision(x)

int main()
{
	ll k,a,b;
	cin>>k;
	cin>>a>>b;
	for(ll i=a;i<=b;i++)
	{
		if(i%k==0)
		{
			cout<<"OK"<<endl;return 0;
		}
	}
	cout<<"NG"<<endl;
	return 0;
}

Measured memory_bytes: 3628
function f()
    a = parse(Int, chomp(readline()))
    b = parse(Int, chomp(readline()))
    c = parse(Int, chomp(readline()))
    d = parse(Int, chomp(readline()))
    e = parse(Int, chomp(readline()))
    k = parse(Int, chomp(readline()))

    i1 = abs(a - b)
    i2 = abs(a - c)
    i3 = abs(a - d)
    i4 = abs(a - e)
    i5 = abs(b - c)
    i6 = abs(b - d)
    i7 = abs(b - e)
    i8 = abs(c - d)
    i9 = abs(c - e)
    i10 = abs(d - e)


    if i1 <= k && i2 <= k && i3 <= k && i4 <= k && i5 <= k && i6 <= k && i7 <= k && i8 <= k && i10 <= k 
        print("Yay!")
    else
        print(":(")
    end
end
f()

Measured memory_bytes: 165016
using System;
using System.Collections;
using System.Collections.Generic;
using System.Collections.Specialized;
using System.Linq;
using System.Numerics;

namespace AtCoderWorkspace
{
    public class Solver
    {
        public void Solve()
        {
            var cin = new Scanner();
            var n = cin.nextLong();
            var m = cin.nextLong();
            var sq = n * m;

            if (n == 1 && m == 1)
            {
                Console.WriteLine(1);
                return; 
            }

            if(n == 1 && 1 < m)
            {
                Console.WriteLine(m - 2);
                return;
            }

            if(m == 1 && 1 < n)
            {
                Console.WriteLine(n - 2);
                return;
            }

            var ans = sq - (sq - ((n - 2) * (m - 2)));

            Console.WriteLine(ans);
        }
    }

    class Scanner
    {
        string[] s;
        int i;

        char[] cs = new char[] { ' ' };

        public Scanner()
        {
            s = new string[0];
            i = 0;
        }

        public string next()
        {
            if (i < s.Length) return s[i++];
            string st = Console.ReadLine();
            while (st == "") st = Console.ReadLine();
            s = st.Split(cs, StringSplitOptions.RemoveEmptyEntries);
            if (s.Length == 0) return next();
            i = 0;
            return s[i++];
        }

        public int nextInt()
        {
            return int.Parse(next());
        }
        public int[] ArrayInt(int N, int add = 0)
        {
            int[] Array = new int[N];
            for (int i = 0; i < N; i++)
            {
                Array[i] = nextInt() + add;
            }
            return Array;
        }

        public int[] DPArrayInt(int N, int ex)
        {
            int[] Array = new int[N+ex];
            for (int i = 0; i < N; i++)
            {
                Array[i] = nextInt();
            }
            return Array;
        }

        public long nextLong()
        {
            return long.Parse(next());
        }

        public long[] ArrayLong(int N, long add = 0)
        {
            long[] Array = new long[N];
            for (int i = 0; i < N; i++)
            {
                Array[i] = nextLong() + add;
            }
            return Array;
        }

        public long[] DPArrayLong(int N, int ex)
        {
            long[] Array = new long[N + ex];
            for (int i = 0; i < N; i++)
            {
                Array[i] = nextLong();
            }
            return Array;
        }

        public double nextDouble()
        {
            return double.Parse(next());
        }


        public double[] ArrayDouble(int N, double add = 0)
        {
            double[] Array = new double[N];
            for (int i = 0; i < N; i++)
            {
                Array[i] = nextDouble() + add;
            }
            return Array;
        }
    }   

    class Program
    {
        static void Main(string[] s) => new Solver().Solve();
    }
}


Measured memory_bytes: 13140
#include <bits/stdc++.h>
#define _overload3(_1, _2, _3, name, ...) name
#define _rep(i, n) repi(i, 0, n)
#define repi(i, a, b) for (int i = (a); i < (b); ++i)
#define rep(...) _overload3(__VA_ARGS__, repi, _rep, )(__VA_ARGS__)
#define ALL(x) x.begin(), x.end()
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
using namespace std;
random_device rnd;
mt19937 mt(rnd());
using ll = long long;
using lld = long double;
using VI = vector<int>;
using VVI = vector<VI>;
using VL = vector<ll>;
using VVL = vector<VL>;
using PII = pair<int, int>;
const int IINF = 1 << 30;
const ll INF = 1ll << 60;
const ll MOD = 1000000007;

int main()
{
    int n;
    cin >> n;
    string s;
    cin >> s;
    int ans = 0;
    int i = 0;
    int j = n - 1;
    while (i < j)
    {
        while (i < j && s[i] == 'R')
            i++;
        if (i == j)
            break;
        while (i < j && s[j] == 'W')
            j--;
        if (i == j)
            break;
        ans++;
        s[i] = 'R';
        s[j] = 'W';
    }
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 3724
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define INF 1e9
#define PI 3.14159265359
#define MOD 1000000007
#define ALL(v) v.begin(),v.end()
#define ALLR(v) v.rbegin(),v.rend()
typedef long long ll;
const int dx[4] = {1,0,-1,0};
const int dy[4] = {0,1,0,-1};
//isPrime
//modpow modinv
//getDigit
template<class T> inline bool chmin(T& a, T b) {
  if (a > b) {
    a = b;
    return true;
  }
  return false;
}
template<class T> inline bool chmax(T& a, T b) {
  if (a < b) {
    a = b;
    return true;
  }
  return false;
}
int main() {
  cout << fixed << setprecision(10);
  int n;
  cin >> n;
  int a[n][3];
  int dp[n+1][3];
  rep(i,n+1){
    rep(j,3){
      dp[i][j]=0;
    }
  }
  rep(i,n){
    rep(j,3){
      cin >> a[i][j];
    }
  }
  for(int i=0; i<n; i++){
    rep(j,3){
      rep(k,3){
        if(j==k) continue;
        chmax(dp[i+1][k],dp[i][j]+a[i][k]);
      }
    }
  }
  int ans = 0;
  rep(i,3){
    chmax(ans,dp[n][i]);
  }
  cout << ans << endl;
}


Measured memory_bytes: 2560
#include <iostream>
#include <vector>
#include <string>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <utility>
#include <algorithm>
#include <numeric>
#include <functional>
#include <cassert>
#include <cstring>
#include <cstdio>
#include <cstdlib>
#include <cmath>
using namespace std;

//const long double PIL = 3.141592653589793238462643383279502884L;
//const double PI = 3.14159265358979323846;

typedef long long ll;
typedef pair<int,int> ii;
typedef vector<int> vi;
typedef vector<long long> vll;
typedef vector<pair<int,int>> vii;
#define sz(a) int((a).size())
#define all(c) (c).begin(), (c).end()

int main() {
	//~ ios::sync_with_stdio(0);
	//~ cin.tie(0);
	string s;
	cin >> s;
	int ans1 = 0, ans2 = 0;
	int n = s.length();
	char c = '0';
	for (int i = 0; i < n; i++) {
		if (s[i] != c) ++ans1;
		c = '0' + '1' - c;
	}
	c = '1';
	for (int i = 0; i < n; i++) {
		if (s[i] != c) ++ans2;
		c = '0' + '1' - c;
	}
	cout << min(ans1, ans2) << endl;
}


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

using namespace std;

const int oo = 23041997, maxN = 1e6, modP = 1e9 + 7;

#define FORU(i, l, r) for (int i = l; i <= r; ++i)
#define FORD(i, r, l) for (int i = r; i >= l; --i)
#define REPU(i, r) for (int i = 0; i < r; ++i)
#define LL long long
#define F first
#define S second
#define MP make_pair
#define PB push_back
#define PINT pair < int, int >
#define BIT(x, i) ((x >> i) & 1)
#define NUM_SET_BIT __builtin_popcountll

int n;

LL sum(int x) {
    return (1ll * x * (x + 1)) / 2;
}

int main() {
    cin >> n;
    int res = 0;
    while (sum(res) < n) ++res;
    cout << res;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner stdIn = new Scanner(System.in);
		
		int n = stdIn.nextInt();
		for(int i=0;i<n;i++){
			String s1 = stdIn.next().replaceAll("->", "0");
			String s2 = s1.replaceAll("<-", "1");
			char[] s3 = s2.toCharArray();
			char[] d = new char[1000];
			int idx = 500;
			int front = idx;
			for(int j=0;j<s2.length();){
				d[idx] = s3[j++];
//				System.out.println("d["+idx+"]="+d[idx]);
				if(!(j<s2.length())){
					break;
				}
				else if(s3[j++]=='0'){
					idx++;
				}
				else{
					idx--;
					front = Math.min(front, idx);
				}
			}
			for(int j=front;;j++){
				if(d[j]==0){
					break;
				}
				System.out.print(d[j]);
			}
			System.out.println();
		}
	}
}

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


int main(){
  cin.tie(0);
  ios_base::sync_with_stdio(false);
  int n;
  cin>>n;
  int c=0;
  for(int i=0;i<=n;i++ ){
    if(n==i*108/100){
      c=i;
    }
  }
  if(c==0){
    cout<<":(";
  }else{
    cout<<c;
  }
  
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
const ll MAX=1e5+5;
ll mod=1e9+7;
#define pb push_back
#define se second
#define fi first
#define maxe max_element
#define mine min_element
#define debug(x) cout<<#x<<" :: "<<x<<endl;
#define debug2(x,y) cout<<#x<<" :: "<<x<<"\t"<<#y<<" :: "<<y<<endl;
#define debug3(x,y,z) cout<<#x<<" :: "<<x<<"\t"<<#y<<" :: "<<y<<"\t"<<#z<<" :: "<<z<<endl;
#define debug4(x,y,z,w) cout<<#x<<" :: "<<x<<"\t"<<#y<<" :: "<<y<<"\t"<<#z<<" :: "<<z<<"\t"<<#w<<" :: "<<w<<endl;
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define boost  ios::sync_with_stdio(0); cin.tie(0); cout.tie(0)
vector<int> graph[205];
int color[205];
bool bipartite_jugding(int v, int c){
    color[v] = c;
    for(int i = 0; i < graph[v].size(); ++i){
        if(color[graph[v][i]] == c) return false;
        if(color[graph[v][i]] == 0 && !bipartite_jugding(graph[v][i], -c)){
            return false;
        }
    }
    return true;
}

bool compare(const pair<pair<ll,ll>,pair<ll,ll> >  &a,const pair<pair<ll,ll>,pair<ll,ll> >  &b){
        if(a.fi.fi<b.fi.fi)
            return true;
        if(a.fi.fi==b.fi.fi && a.fi.se<b.fi.se)
            return true;
        if(a.fi.fi==b.fi.fi && a.fi.se==b.fi.se && a.se.fi<b.se.fi)
            return true;
            return false;
        }
long long expo(ll x,ll n,ll M)
{
    if(n==0)
        return 1;
    else if(n%2 == 0)        //n is even
        return expo((x*x)%mod,n/2,mod);
    else                             //n is odd
        return (x*expo((x*x)%mod,(n-1)/2,mod))%mod;

}

void solve(){

}

void input()
{
    int n;
    cin>>n;
    vector<ll> a(n);
    for(int i=0;i<n;i++)
        cin>>a[i];
        vector<vector<int> > dp(300001,vector<int> (60,0));
    for(int i=0;i<n;i++)
    {
        for(int j=0;j<60;j++)
        {
            if(a[i]&(1ll<<j)){
                //cout<<j<<endl;
                dp[i][j]=(i>0)?dp[i-1][j]+1:1;}
            else
                 dp[i][j]=(i>0)?dp[i-1][j]:0;
        }
    }
   /* for(int i=0;i<n;i++)
    {
        for(int j=0;j<60;j++)
        {
            cout<<dp[i][j]<<" ";
        }
        cout<<endl;
    }*/
    int ans=0;
    for(int i=0;i<n;i++)
    {
        for(int j=0;j<60;j++)
        {

            int ones=dp[n-1][j]-dp[i][j];
            int zeros=n-i-1-ones;
            // if(j<2)
              //  cout<<ans;
             //       if(j<2)
          //  debug4(ones,zeros,j,i);
            if(a[i]&(1ll<<j))
            {

                ans+=(((1ll<<j)%mod)*zeros)%mod;
                ans=ans%mod;
            }
            else{
                ans+=(((1ll<<j)%mod)*ones)%mod;
                ans=ans%mod;}
             //   if(j<2)
          //  debug(ans);
        }
    }
    cout<<ans<<endl;
}

int main(){
boost;
  input();
}


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

ll const M = 1000000007;

//べき乗高速化
ll mpow(ll x, ll n){
	ll ans = 1;
	while(n != 0){
		if (n&1) ans = ans * x % M;
		x = x*x % M;
		n  = n >> 1;
	}
	return ans;
}


int main(){
	ll n; cin >> n;
	vector<ll> a(n);
	map<ll,int> mp;
	rep(i,n) {
		cin >> a[i];
		mp[a[i]]++;
	}
	ll ans;
	if(n % 2 == 0){
		bool ok = true;
		rep(i,n){
			if(i % 2 == 0){
				continue;
			} else if(mp[i] != 2) ok = false;
		}
		if(ok){
			ans = mpow(2, n/2);
			cout << ans << endl;
			return 0;
		}else{
			cout << 0 << endl;
			return 0;
 		}
	}else{
		bool ok = true;
		rep(i,n){
			if(i == 0){
				if(mp[i] != 1) ok = false;
			}else if(i % 2 == 1) {
				continue;
			}else if(mp[i] != 2) ok = false;
		}
		if(ok){
			ans = mpow(2, n/2);
			cout << ans << endl;
			return 0;
		}else{
			cout << 0 << endl;
			return 0;
		}
	}
    return 0;
}



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

long long a, b, c;

int main() {

	cin >> a >> b >> c;

	if (a > b) swap(a, b);
	if (b > c) swap(b, c);
	
	cout << a * b * (a & b & c & 1) << endl;

}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <string>
#include <list>
#include<vector>
#include <sstream>
#include <stdio.h>
#include <valarray>
#include <iomanip>
#include <unordered_set>
#include <set>
using namespace std;

int main(void)
{
	vector<int>  UnderNum;
	vector<int>  OverNum;
	int TargetNum = 0;

	int NumberSize;

	int Min;

	int Max;

	cin >> TargetNum >> NumberSize;

	if (NumberSize == 0)
	{
		cout << TargetNum << endl;
		return 0;
	}

	Max = Min = TargetNum;

	int Tmp;
	bool End = true;
	for (int i = 0; i < NumberSize; i++)
	{
		cin >> Tmp;
		if (Tmp==TargetNum)
		{
			End = false;
		}
		if (Tmp < TargetNum)
		{
			UnderNum.emplace_back(Tmp);
		}
		else
			if (Tmp > TargetNum)
			{
				OverNum.emplace_back(Tmp);
			}
	}

	if (End)
	{
		cout << TargetNum << endl;
		return 0;
	}

	//高い数字は昇順
	sort(OverNum.begin(), OverNum.end());

	for (int i = 0; i < OverNum.size(); i++)
	{
		if (abs((OverNum[i] - Max)) > 1)
		{
			Max++;
			break;
		}
		else
		{
			if (OverNum.size() - 1 != i)
			{
				Max = OverNum[i];
			}
			else
			{
				Max = OverNum[i];
				Max++;
			}
		}
	}

	if (OverNum.size() == 0)
	{
		Max++;
	}

	//低い数字は降順
	sort(UnderNum.begin(), UnderNum.end(), [](const int& x, const int& y) { return x > y; });

	for (int i = 0; i < UnderNum.size(); i++)
	{
		if (abs((UnderNum[i] - Min)) > 1)
		{
			Min--;
			break;
		}
		else
		{
			if (UnderNum.size() - 1 != i)
			{
				Min = UnderNum[i];
			}
			else
			{
				Min = UnderNum[i];
				Min--;
			}
		}
	}

	if (UnderNum.size() == 0)
	{
		Min--;
	}


	if (abs((TargetNum - Min)) <= abs((Max - TargetNum)))
	{
		cout << Min << endl;

		return 0;
	}

	cout << Max << endl;

	return 0;
}

Measured memory_bytes: 3192
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define SPEED ios_base::sync_with_stdio(false); cin.tie(NULL);
#define FOR(i, a, b) for (ll i = a; i < b; ++i)
#define RFOR(i, b, a) for (ll i = b; i >= a; --i)
#define ALL(x) x.begin(), x.end()
#define DEBUG(args...) { string _s = #args; replace(ALL(_s), ' ', '\0');\
replace(ALL(_s), ',', ' ');\
stringstream _ss(_s); istream_iterator<string> _it(_ss); _debug(_it, args);}
#define endl "\n"
#define F first
#define S second
#define pb(x) push_back(x)
#define mp(x, y) make_pair(x, y)

using namespace std;
using namespace __gnu_pbds;

template<typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

void _debug(istream_iterator<string>) {}
template<typename T, typename... Args>
void _debug(istream_iterator<string> it, T first, Args... args) {
    cerr << ">> " << *it << " : " << first << endl; _debug(++it, args...);
}
template <typename T1, typename T2>
inline ostream& operator << (ostream& out, const pair<T1, T2>& p) {
    return out << "(" << p.F << ", " << p.S << ")";
}
template<typename T>
inline ostream& operator << (ostream& out, const vector<T>& v) {
    if (v.empty()) return out << "[]";
    else { out << '['; for (auto& e : v) { out << e << ", "; } return out << "\b\b]"; }
}
template<typename T>
inline ostream& operator << (ostream& out, const set<T>& s) {
    if (s.empty()) return out << "{}";
    else { out << '{'; for (auto& e : s) { out << e << ", "; } return out << "\b\b}"; }
}
template<typename T>
inline ostream& operator << (ostream& out, const unordered_set<T>& s) {
    return out << set<T>(ALL(s));
}
template<typename T1, typename T2>
inline ostream& operator << (ostream& out, const map<T1, T2>& m) {
    if (m.empty()) return out << "{}";
    out << '{'; for (auto& p : m) { out << p << ", "; } return out << "\b\b}";
}
template<typename T1, typename T2>
inline ostream& operator << (ostream& out, const unordered_map<T1, T2>& m) {
    return out << map<T1, T2>(ALL(m));
}
template<typename T>
inline ostream& operator << (ostream& out, const ordered_set<T>& s) {
    return out << set<T>(ALL(s));
}

typedef long long ll;
typedef long double ld;
typedef vector<long long> vll;
typedef pair<ll, ll> pll;
typedef vector<pair<ll, ll>> vpll;
typedef unordered_map<ll, ll> STll;
/************************************** MAIN PROGRAM ********************************************/

int main()
{
    //freopen("input.txt", "r", stdin);
    SPEED
    ll h, n;
    cin >> h >> n;
    vector<ll> a(n);
    for (auto &e : a) {
        cin >> e;
    }
    cout << (h <= accumulate(ALL(a), 0ll) ? "Yes" : "No");
}
/************************************** END OF PROGRAM ******************************************/
/** Stuff you should look for:
 * int overflow, array bounds, over-counting, graph is not a tree/connected
 * special cases (n=1?), set/unordered_set TLE, multi-set/set error
 * do something instead of nothing and stay organized
 */


Measured memory_bytes: 1024
#include<iostream>
#include<vector>
#include<cmath>
#include<string>
#include<algorithm>
#include<map>
#include<utility>
#include<cstdio>
#include<bits/stdc++.h>

using namespace std;
using ll = long long;
const long long INF = 1LL<<60;

typedef pair<long long,bool> Pair;

int main(){

ll N,M,A;


cin >> N >> M;

for(long long i = 0;i < M;++i){

    cin  >> A;
    N -= A;

}

cout << ( N >= 0 ? N : -1 ) << endl;

return 0;

}

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

#define ll long long
#define endl "\n"
#define ios ios_base::sync_with_stdio(0); cout.tie(0); cin.tie(0);

using namespace std;

int main() {
    ios
    string s;
    cin >> s;
    if (s[s.size() - 1] == 's') s += 'e';
    s += 's';
    cout << s;
    return 0;
}


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

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

    int n;
    cin >> n;

    vector<int> h(n);
    REP(i, n) cin >> h[i];

    bool ans = true;
    int maxi = 0;
    REP(i, n) {
        if (maxi < h[i] - 1) maxi = h[i] - 1;
        if (maxi > h[i]) {
            ans = false;
            break ;
        }
    }

    if (ans) cout << "Yes" << '\n';
    else cout << "No" << '\n';
    return 0;
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
typedef long long ll;
#define  rep(i,a,b)for(long long i=a;i<b;++i)
#define  rrep(i,a,b)for(int i=a;i>=b;--i)
#define  yesno(flag)if(flag)cout<<"Yes"<<endl; else cout<<"No"<<endl;
using namespace std;
const ll INF=1000000000000LL;
const ll r197=1000000007;
typedef pair<int,int>P;
typedef pair<int,P>Pa;
bool Inframe(int a,int b,int c,int d,int h,int w){
	if(a+b>=0&&a+b<h&&c+d>=0&&c+d<w)return true;
	return false;
}
ll mad=998244353;
int ans;
int n,m,a,b;
bool c[101]={};
ll x;
int main() {
	cin>>x;
	ll k=1,i=1;
	while(i*i<=x){
		if(x%i==0)k=i;
		i++;
	}
	cout<<k+x/k-2<<endl;
	return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include <algorithm>
#include<string>
#include <bitset>
#include <vector>
#include <functional>
#include <climits>
#include <iomanip>
#include <utility>
#include <stack>
#include <queue>
#include <math.h>
#include <iomanip>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <numeric>
using namespace std;
using ll = long long;

typedef pair <int, int> pii;

int main()
{

	ll a = 0, b = 0, c = 0, d = 0, e = 0, f = 0, g = 0, h = 0, ans = 0;
	string s, t;
	ll n;
	ll x1[102] = {};
	ll y1[102] = {};
	ll x2[102] = {};
	ll y2[102] = {};
	cin >> n;
	for (int i = 0; i < n; i++)
	{
		cin >> x1[i];
		cin >> y1[i];
	}
	for (int i = 0; i < n; i++)
	{
		cin >> x2[i];
		cin >> y2[i];
	}
	int temp;
	for (int i = 0; i < n - 1; i++) {
		for (int j = n - 1; j > i; j--) {
			if (x1[j - 1] < x1[j]) {  /* 前の要素の方が大きかったら */
				temp = x1[j];        /* 交換する */
				x1[j] = x1[j - 1];
				x1[j - 1] = temp;
				temp = y1[j];        /* 交換する */
				y1[j] = y1[j - 1];
				y1[j - 1] = temp;
			}
		}
	}
	for (int i = 0; i < n - 1; i++) {
		for (int j = n - 1; j > i; j--) {
			if (x2[j - 1] < x2[j]) {  /* 前の要素の方が大きかったら */
				temp = x2[j];        /* 交換する */
				x2[j] = x2[j - 1];
				x2[j - 1] = temp;
				temp = y2[j];        /* 交換する */
				y2[j] = y2[j - 1];
				y2[j - 1] = temp;
			}
		}
	}
	for (int i = 0; i < n; i++)
	{
		a = 9999999999;
		for (int j = 0; j < n; j++)
		{
			if (x1[i]<x2[j]&&y1[i]<y2[j]&&y2[j]<a)
			{
				b = j;
				a = y2[j];
			}
		}
		if (a!= 9999999999)
		{
			ans++;
			y2[b] = -9999999999;
			x2[b] = -9999999999;
		}
	}




	cout << ans << endl;

	////std::cout << std::fixed;
	//cout << std::setprecision(20) << << endl;
	//cout << d+1 << endl;
	//cout << "" << endl;

	return 0;
}
//char型の文字数字は、-'0'で数値に変換できる
//accumulate(x, x + a, 0);//int型までの配列の合計
//memcpy(x, visited, sizeof(ll)*n);
//void kansuu(ll num, ll visited[10]) {}
//kansuu(1, zz);
//cout << setprecision(15) << v << endl;
//cout << char(z - 'a');
//log10(i) + 1 //10進数の桁数を取得

//int temp;
//for (int i = 0; i < n - 1; i++) {
//	for (int j = n - 1; j > i; j--) {
//		if (w[j - 1] < w[j]) {  /* 前の要素の方が大きかったら */
//			temp = w[j];        /* 交換する */
//			w[j] = w[j - 1];
//			w[j - 1] = temp;
//		}
//	}
//}

//最小公倍数
//ll x = a * b;
//ll tmp;
///* 自然数 a > b を確認・入替 */
//if (a<b) {
//	tmp = a;
//	a = b;
//	b = tmp;
//}
///* ユークリッドの互除法 */
//ll r = a % b;
//while (r != 0) {
//	a = b;
//	b = r;
//	r = a % b;
//}
//a = x / b;//答え

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

#立っている場所の個数
def popcnt(n):
    c = (n & 0x5555555555555555) + ((n>>1) & 0x5555555555555555)
    c = (c & 0x3333333333333333) + ((c>>2) & 0x3333333333333333)
    c = (c & 0x0f0f0f0f0f0f0f0f) + ((c>>4) & 0x0f0f0f0f0f0f0f0f)
    c = (c & 0x00ff00ff00ff00ff) + ((c>>8) & 0x00ff00ff00ff00ff)
    c = (c & 0x0000ffff0000ffff) + ((c>>16) & 0x0000ffff0000ffff)
    c = (c & 0x00000000ffffffff) + ((c>>32) & 0x00000000ffffffff)
    return c

def main():
    n = int(input())
    edge = [[] for i in range(n)]
    for _ in [0]*(n-1):
        a,b = map(int,input().split())
        edge[a-1].append(b-1)
        edge[b-1].append(a-1)
    
    m = int(input())
    dg = 100
    uv = []
    for _ in [0]*m:
        u,v = map(int,input().split())
        uv.append(u*dg-dg+v-1)

    #各点の親を求める
    par = [-2]*n
    root = 0
    par[0] = -1

    tank = [0]
    order = []
    orderIdx = [0]*n
    cnt = 0
    while tank:
        now = tank.pop()
        for nxt in edge[now]:
            if par[nxt] == -2:
                par[nxt] = now
                tank.append(nxt)
        order.append(now)
        orderIdx[now] = cnt
        cnt += 1
    
    res = pow(2,n-1)
    #1ビットだけ立っているもの
    bitOne = set()
    for i in range(m):
        bitOne.add(1<<i)

    #dp
    dp = [0]*(1<<m)
    for i in range(1,1<<m):
        pc = popcnt(i)
        if pc == 1:
            #idx:iで立っているbitの内最後のもののindex
            idx = (-i&i).bit_length()-1
            
            u,v = uv[idx]//dg,uv[idx]%dg

            
            #u,v間の経路の辺を立てたものがdp[i]
            tmp = 0
            while u != v:
                if orderIdx[u] < orderIdx[v]:
                    tmp |= (1<<v)
                    v = par[v]
                else:
                    tmp |= (1<<u)
                    u = par[u]
            dp[i] = tmp
        
        else:
            dp[i] = dp[(-i)&i] | dp[((-i)&i)^i]
    
        res += (-1)**(pc%2)*pow(2,n-1-popcnt(dp[i]))

    print(res)

if __name__ == '__main__':
    main()










Measured memory_bytes: 47472
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<(n); i++)
#define FOR(i,a,b) for(int i=(a); i<(b); i++)
#define ALL(v) v.begin(), v.end()
#define RALL(v) v.rbegin(), v.rend()
typedef long long ll;
int main(){
    int h,w,k; cin >> h >> w >> k;
    vector<vector<char>> s(h, vector<char>(w));
    vector<vector<int>> a(h, vector<int>(w, -1));
    rep(i,h){
        rep(j,w){
            cin >> s[i][j];
        }
    }
    int now = 1;
    rep(i,h){
        rep(j,w){
            if(a[i][j] != -1) continue;
            if(s[i][j] == '#'){
                a[i][j] = now;
                int nj = j;
                while(true){
                    nj--;
                    if(nj >= 0 && a[i][nj] == -1 && s[i][nj] == '.') a[i][nj] = now;
                    else break;
                }
                nj = j;
                while(true){
                    nj++;
                    if(nj < w && a[i][nj] == -1 && s[i][nj] == '.') a[i][nj] = now;
                    else break;
                }
                now++;
            }
        }
    }

    rep(j,w){
        rep(i,h){
            if(a[i][j] != -1){
                int ni = i;
                while(true){
                    ni--;
                    if(ni >= 0 && a[ni][0] == -1){
                        rep(k,w){
                            a[ni][k] = a[i][k];
                        }
                    }
                    else break;
                }
                ni = i;
                while(true){
                    ni++;
                    if(ni < h && a[ni][0] == -1){
                        rep(k,w){
                            a[ni][k] = a[i][k];
                        }
                    }
                    else break;
                }
            }
        }
    }
    rep(i,h){
        rep(j,w){
            printf("%d%c", a[i][j], j==w-1? '\n':' ');
        }
    }
}

Measured memory_bytes: 1280
N,K = map(int,input().split())
h = list(map(int,input().split()))
dp = [0]+[None]*(N-1) 
def func(N,K,h,dp):
  for i in range(1,N):
    dp[i] = min(dp[j] + abs(h[i]-h[j]) for j in range(max(i-K,0),i)) 

func(N,K,h,dp)
print(dp[-1])

Measured memory_bytes: 13980
#include <iostream>
using namespace std;
int main()
{
	int h, n, r, s;
	cin >> h >> n;
	s = 0;
	for (int i = 0; i < n; i++) {
		cin >> r;
		s += r;
	}
	if (h <= s)	cout << "Yes" << endl;
	else {
		cout << "No" << endl;
	}
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <math.h> 
using namespace std;
int main(){
  int n;
  cin >> n;
  int ans = 0;
  for(int i = 0; i < 7; i++){
    if(pow(2,i) <= n) ans = pow(2,i);
  }
  cout << ans << endl;
} 


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

int main(){
	int n; cin >>n;
	vector<int> a(n);
	cinf(n,a);
	sort(a.begin(),a.end());
	cout << a[n-1]-a[0]<< endl;
}


Measured memory_bytes: 256
def abc():
    n, t = map(int, input().rstrip().split())
    costs = []
    for i in range(n):
        a, b = map(int, input().rstrip().split())
        if b <= t:
            costs.append(a)
    if len(costs) == 0:
        print('TLE')
        return
    print(sorted(costs)[0])


abc()


Measured memory_bytes: 2940
package main

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

var sc = bufio.NewScanner(os.Stdin)

func Scan() string {
	sc.Scan()
	return sc.Text()
}
func iScan() int {
	n, _ := strconv.Atoi(Scan())
	return n
}
func fScan() float64 {
	n, _ := strconv.ParseFloat(Scan(), 64)
	return n
}
func stringToInt(s string) int {
	n, _ := strconv.Atoi(s)
	return n
}
func SScan(n int) []string {
	a := make([]string, n)
	for i := 0; i < n; i++ {
		a[i] = Scan()
	}
	return a
}
func iSScan(n int) []int {
	a := make([]int, n)
	for i := 0; i < n; i++ {
		a[i] = iScan()
	}
	return a
}
func abs(x int) int {
	if x < 0 {
		x = -x
	}
	return x
}
func larger(a, b int) int {
	if a < b {
		return b
	} else {
		return a
	}
}
func smaller(a, b int) int {
	if a > b {
		return b
	} else {
		return a
	}
}
func max(a []int) int {
	x := a[0]
	for i := 0; i < len(a); i++ {
		if x < a[i] {
			x = a[i]
		}
	}
	return x
}
func min(a []int) int {
	x := a[0]
	for i := 0; i < len(a); i++ {
		if x > a[i] {
			x = a[i]
		}
	}
	return x
}
func sum(a []int) int {
	x := 0
	for _, v := range a {
		x += v
	}
	return x
}

var mod int = 1000000007

func main() {
	buf := make([]byte, 0)
	sc.Buffer(buf, mod)
	sc.Split(bufio.ScanWords)
	n := iScan()
	a, b := iScan(), iScan()
	if (b-a)%2 == 0 {
		fmt.Println((b - a) / 2)
	} else {
		x := (b-a-1)/2 + a - 1 + 1
		y := (b-a-1)/2 + n - b + 1
		fmt.Println(smaller(x, y))
	}
}


Measured memory_bytes: 1776
#include "bits/stdc++.h"

using namespace std;

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

#define rep(i,n) for(ll i=0;i<(ll)(n);i++)
#define all(a)  (a).begin(),(a).end()
#define pb push_back
#ifdef Debug
#define dump(x)  cerr << #x << " = " << (x) << endl
#else
#define dump(x)
#endif


int par[10000];
int Rank[10000];

void init(int n){
    rep(i,n){
        par[i]=i;
        Rank[i]=0;
    }
}

int find(int x){
    if(par[x]==x) {
        return x;
    }else{
        return par[x]=find(par[x]);
    }
}

void unite(int x,int y){
    x=find(x);
    y=find(y);
    if(x==y) return;
    
    if(Rank[x]<Rank[y]){
        par[x]=y;
    }else{
        par[y]=x;
        if(Rank[x]==Rank[y])Rank[x]++;
    }
}




int main(){
	int n;
	while(cin>>n){
		if(n==0)break;
		pii data[110][110]={};
		rep(i,n)
			rep(j,n)
				cin>>data[i][j].first>>data[i][j].second;

		init(n*n);

		rep(i,n){
			rep(j,n){
				unite(n*i+j,n*data[i][j].second+data[i][j].first);
			}
		}
		bool used[10000]={};
		int sum=0;
		rep(i,n*n){
			int aa=find(i);
			if( used[ aa ]==false ){
				sum++;
				used[aa]=true;
			}
		}
		cout<<sum<<endl;
	}
	return 0;
}

Measured memory_bytes: 1348
#include<iostream>
#include<stack>
using namespace std;
int main(){
	string s;
	cin >> s;
	stack<char> ss;
	for(int i=0;i<s.length();i++){
		if(ss.size()!=0 && s[i]!=ss.top()) ss.pop();
		else ss.push(s[i]);
	}
	cout << s.length()-ss.size() << endl;
	return 0;
}


Measured memory_bytes: 512
#include <stdio.h>

#define N 200000

long a[N+1];

int main(void){
    long n;
    scanf("%ld", &n);
    a[0] = -1;
    for(long i=1; i<=n; i++){
        scanf("%ld", a+i);
    }
    long count=-1;
    for(long i=1; i<=n; i++){
        long d = a[i]-a[i-1];
        if(d>=2){
            puts("-1");
            return 0;
        }else if(d==1){
            count++;
        }else{
            count += a[i];
        }
    }
    printf("%ld\n", count);
    return 0;
}



Measured memory_bytes: 1664
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians, gcd
from itertools import accumulate, permutations, combinations, product, groupby, combinations_with_replacement
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left
from heapq import heappush, heappop
from functools import reduce
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def ZIP(n): return zip(*(MAP() for _ in range(n)))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

N = INT()
L = LIST()
L.sort()

ans = 0
for i, j, k in combinations(L, 3):
    if i == j or j == k or k == i: continue
    if k < i+j:
        ans += 1

print(ans)


Measured memory_bytes: 9896
a, b, k = map(int, input().split(' '))

for i in range(k):

    if i % 2 == 0:
        if a % 2 == 1:
            a -= 1
        
        tmp_a = int(a / 2)

        a = tmp_a
        b = b + tmp_a

    else:
        if b % 2 == 1:
            b -= 1
        
        tmp_b = int(b / 2)

        b = tmp_b
        a = a + tmp_b

print(a, b)

Measured memory_bytes: 3064
/* --- author: dxm --- */
#include<bits/stdc++.h>
using namespace std;

#define INF 1e9
#define Inf 1e18
#define rep(i,n) for(int (i)=0;(i)<n;i++)
#define REP(i,n) for(int (i)=1;(i)<=n;i++)
#define mp make_pair
#define pb push_back
#define pii pair<int,int>
#define fst first
#define snd second
typedef long long ll;
inline void Fail(){printf("0");exit(0);}

const int maxn=200005;
const int maxm=30;
int n;
char c[maxn];
string s,ans;
int nxt[maxn][maxm],dp[maxn];
 
int main(){
	scanf("%s",c);s=c;n=s.size();s="*"+s;
	rep(j,26)nxt[n+1][j]=n+1;
	for(int i=n;i>=1;i--)rep(j,26){
		if(s[i]-'a'==j)nxt[i][j]=i;
		else nxt[i][j]=nxt[i+1][j];
	}
	dp[n+1]=0;
	for(int i=n;i>=0;i--){
		dp[i]=INF;
		rep(j,26)dp[i]=min(dp[i],dp[nxt[i+1][j]]+1);
//		cout<<dp[i]<<endl;
	}
//	printf("%d\n",dp[0]);
	int cur=0,now=0;
	while(cur<n){
		now++;
		rep(i,26){
			if(now+dp[nxt[cur+1][i]]==dp[0]){
				cur=nxt[cur+1][i]; 
				ans+=(char)(i+'a');
				break;
			}
		}
	}
	printf("%s",ans.c_str());
	return 0;
}

/*
Input:
-----------------
Output:
*/

Measured memory_bytes: 24892
n = int(input())
h = list(map(int, input().split()))
dp = [float('inf')] * n

#後者が前者よりも小さい時に更新→DPテーブルをinfに初期化(先頭は0)
def chmin(a,b):
    if(a > b):
        return b
    else:
        return a

dp[0] = 0
for i in range(1,n):
    dp[i] = chmin(dp[i], dp[i-1]+abs(h[i]-h[i-1]))
    if i > 1:
        dp[i] = chmin(dp[i], dp[i-2]+abs(h[i]-h[i-2]))

print(dp[n-1])

Measured memory_bytes: 13900
def main():
    N, X, Y = list(map(int, input().split()))
    X, Y = X - 1, Y - 1
    K = [0] * N
    for i in range(N - 1):
        for j in range(i + 1, N):
            if j <= X or Y <= i:
                K[j - i] += 1
            else:
                K[min(j - i, abs(X - i) + 1 + abs(Y - j))] += 1
    print("\n".join(str(i) for i in K[1:]))

main()


Measured memory_bytes: 42096
using System;
using System.Text;
using System.Linq;
using System.Collections;
using System.Collections.Generic;
using static System.Console;
using static System.Math;

public class Program
{
    public static void Main(string[] args)
    {
        new Program().Solve(new ConsoleInput(Console.In, ' '));
    }

    public void Solve(ConsoleInput cin)
    {
        var n = cin.ReadDouble;
        double ans = (n - ((int)n / 2)) / n;
        WriteLine(ans);
    }
}

public class ConsoleInput
{
    private readonly System.IO.TextReader _stream;
    private char _separator = ' ';
    private Queue<string> inputStream;
    public ConsoleInput(System.IO.TextReader stream, char separator = ' ')
    {
        this._separator = separator;
        this._stream = stream;
        inputStream = new Queue<string>();
    }
    public string Read
    {
        get
        {
            if (inputStream.Count != 0) return inputStream.Dequeue();
            string[] tmp = _stream.ReadLine().Split(_separator);
            for (int i = 0; i < tmp.Length; ++i)
                inputStream.Enqueue(tmp[i]);
            return inputStream.Dequeue();
        }
    }
    public string ReadLine { get { return _stream.ReadLine(); } }
    public int ReadInt { get { return int.Parse(Read); } }
    public long ReadLong { get { return long.Parse(Read); } }
    public double ReadDouble { get { return double.Parse(Read); } }
    public string[] ReadStrArray(long N) { var ret = new string[N]; for (long i = 0; i < N; ++i) ret[i] = Read; return ret; }
    public int[] ReadIntArray(long N) { var ret = new int[N]; for (long i = 0; i < N; ++i) ret[i] = ReadInt; return ret; }
    public long[] ReadLongArray(long N) { var ret = new long[N]; for (long i = 0; i < N; ++i) ret[i] = ReadLong; return ret; }
}


Measured memory_bytes: 13268
#include<bits/stdc++.h>
#define INF 9003372036854775807LL
#define mod 998244353
#define fixed fixed<<setprecision(12)
#define abs(x,y) (max(x,y)-min(x,y))
#define lol long long
#define mp make_pair
#define fi first
#define se second
using namespace std;
using pii=pair<int, int > ;
lol a[100010];
signed main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  string s;
  lol n,m,k,r,x,y;
  cin >>n>>m;
  for(int i=0;i<m;i++){
    cin >>r;
    n-=r;
  }
  cout <<max(n,-1LL)<<'\n';
  return (0);
}


Measured memory_bytes: 3656