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

using namespace std;

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

#define rep(i,n) for(int i=0;i<(n);++i)
#define repi(i,a,b) for(int i=int(a);i<(b);i++)
#define repr(i,b,a) for(int i=int(b);i>=(a);i--)
#define all(x) x.begin(),x.end()

const ll mod = 1e9+7;
const ll INF = 1e9;

ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};
bool valid(int lx,int ux,int ly,int uy,int x,int y){
	return lx<=x&&x<ux&&ly<=y&&y<uy; 
}
ll power(ll x,ll p){
	if(p==0)return 1;
	ll res=power(x*x%mod,p/2);
	if(p%2==1)res=res*x%mod;
	return res;
}

// typedef struct Line{
// 	int l,r,idx;
// 	Line(int l,int r,int idx):l(l),r(r),idx(idx){};
// 	Line(){l=0,r=0,idx=0;};
// 	bool operator<(const Line &line) const{
//         return l < line.l;
//     }
// }Line;
typedef tuple<int,int,int> Line;

int main()
{
	int n;
	cin>>n;
	vector<Line> line(n);
	rep(i,n){
		int l,r;
		cin>>l>>r;
		line[i]=make_tuple(l,r,i);
	}

	sort(all(line));

	set<P> LeftLSet,LeftRSet,RightLSet,RightRSet;

	LeftLSet.insert(P(get<0>(line[0]),get<2>(line[0])));
	LeftRSet.insert(P(get<1>(line[0]),get<2>(line[0])));

	repi(i,1,n){
		RightLSet.insert(P(get<0>(line[i]),get<2>(line[i])));
		RightRSet.insert(P(get<1>(line[i]),get<2>(line[i])));
	}
	int ans=0;
	//cout<<"LeftRSet = "<<LeftRSet.begin()->first<<" LeftLset = "<<LeftLSet.rbegin()->first<<endl;
	//cout<<"RightRSet = "<<RightRSet.begin()->first<<" rightLset = "<<RightLSet.rbegin()->first<<endl;
	int Llength=max(0,LeftRSet.begin()->first-LeftLSet.rbegin()->first+1);
	int Rlength=max(0,RightRSet.begin()->first-RightLSet.rbegin()->first+1);
	ans=Llength+Rlength;

	repi(i,1,n-1){
		// cout<<ans<<endl;
		RightLSet.erase(P(get<0>(line[i]),get<2>(line[i])));
		RightRSet.erase(P(get<1>(line[i]),get<2>(line[i])));

		LeftLSet.insert(P(get<0>(line[i]),get<2>(line[i])));
		LeftRSet.insert(P(get<1>(line[i]),get<2>(line[i])));

		Llength=max(0,LeftRSet.begin()->first-LeftLSet.rbegin()->first+1);
		Rlength=max(0,RightRSet.begin()->first-RightLSet.rbegin()->first+1);
		int res=max(0,Llength+Rlength);
		ans=max(ans,res);
	}

	RightLSet.erase(P(get<0>(line[n-1]),get<2>(line[n-1])));
	RightRSet.erase(P(get<1>(line[n-1]),get<2>(line[n-1])));
	LeftLSet.insert(P(get<0>(line[n-1]),get<2>(line[n-1])));
	LeftRSet.insert(P(get<1>(line[n-1]),get<2>(line[n-1])));

	rep(i,n){
		LeftLSet.erase(P(get<0>(line[i]),get<2>(line[i])));
		LeftRSet.erase(P(get<1>(line[i]),get<2>(line[i])));

		Llength=max(0,LeftRSet.begin()->first-LeftLSet.rbegin()->first+1);
		ans = max(ans,get<1>(line[i])-get<0>(line[i])+1 + Llength);

		LeftLSet.insert(P(get<0>(line[i]),get<2>(line[i])));
		LeftRSet.insert(P(get<1>(line[i]),get<2>(line[i])));
	}


	cout<<ans<<endl;

	return 0;
}

Measured memory_bytes: 10752
#include<iostream>
using namespace std;
int main()
{
	string a;
	cin>>a;
	for(int i=0;i<5;i++)
	{
	
		if(a[i]==a[i-1])
		{
			cout<<"Bad";
			return 0;
		}
	}
	cout<<"Good";
 } 

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

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

int main() {

    int a, b;
    scanf("%d %d", &a, &b);

    printf("%d %d %.7lf\n", a / b, a % b, (double)a / b);

    return 0;
}



Measured memory_bytes: 3220
#include <iostream>
#include <cstdio>
#define MAX 101
using namespace std;

int n;
int t=1;
int a[MAX][MAX]={};
int d[MAX]={},f[MAX]={};

void track(int p){
  if(d[p]==0){
    d[p]=t;
    t++;
  }
  for(int i=1;i<=n;i++){
    if(a[p][i]==1&&d[i]==0){
      track(i);
    }
  }
  f[p]=t; t++;
}

int main(){

  cin>>n;
  for(int i=1;i<=n;i++){
    int u,k; cin>>u>>k;
    for(int j=0;j<k;j++){
      int v; cin>>v;
      a[i][v]=1;
    }
  }

  for(int i=1;i<=n;i++){
    if(d[i]==0) track(i);
  }

  for(int i=1;i<=n;i++){
    cout<<i<<" "<<d[i]<<" "<<f[i]<<endl;
  }
}

Measured memory_bytes: 3152
using System;
using System.Collections.Generic;
using System.Text;
using System.Linq;

class Program{
	static void Main(){
		int a,b,c,d,e,k;
		a = int.Parse(Console.ReadLine());
		b = int.Parse(Console.ReadLine());
		c = int.Parse(Console.ReadLine());
		d = int.Parse(Console.ReadLine());
		e = int.Parse(Console.ReadLine());
		k = int.Parse(Console.ReadLine());
		string ans = e - a > k ? ":(" : "Yay!";
		Console.WriteLine(ans);
	}
}

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

class Program
{
    public Program() { }

    Scanner cin;

    void myon()
    {
        cin = new Scanner();

        int a = cin.nextInt();
        int b = cin.nextInt();


        Console.WriteLine(6 - a - b);        
    }


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


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);
        i = 0;
        return next();
    }

    public int nextInt()
    {
        return int.Parse(next());
    }

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

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

}

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

struct UnionFind
{
    vector<int> par, rank;
    vector<int> last;
    
    UnionFind(int n){
        par.resize(n);
        rank.resize(n);
        for(int i = 0; i < n; i++){
            par[i] = i;
            rank[i] = 0;
        }
    }
    
    int find(int i){
        if(i == par[i]) return i;
        return find(par[i]);
    }
    
    bool same(int i, int j){
        return find(i) == find(j);
    }
    
    void unite(int i, int j){
        i = find(i), j = find(j);
        if(i == j) return;
        if(rank[i] < rank[j]){
            par[i] = j;
            last.push_back(i);
        }
        else{
            par[j] = i;
            if(rank[i] == rank[j]) rank[i]++;
            last.push_back(j);
        }
    }
    
    void undo(){
        if((int)last.size() == 0) return;
        int i = *(--last.end());
        par[i] = i;
        last.pop_back();
    }
};

int main()
{
    int n, m;
    cin >> n >> m;
    int x[100002], y[100002], z[100002];
    for(int i = 0; i < m; i++){
        cin >> x[i] >> y[i] >> z[i];
        x[i]--;
        y[i]--;
    }
    UnionFind uf(n);
    for(int i = 0; i < m; i++){
        uf.unite(x[i], y[i]);
    }
    set<int> s;
    for(int i = 0; i < n; i++){
        s.insert(uf.find(i));
    }
    cout << s.size() << endl;
}

Measured memory_bytes: 6784
#include <bits/stdc++.h>
using namespace std;
int ct[2019];
string s;
long long cur = 0;
long long ans = 0;
long long mul = 1;
int main(){
    cin >> s;
    ct[0] = 1;
    for (int i = s.size()-1; i >= 0; i--){
        cur += (s[i]-'0')*mul;
        cur %= 2019;
        //printf("%d %d\n",cur,ct[cur]);
        ans += ct[cur];
        ct[cur]++;
        mul *= 10;
        mul %= 2019;
    }
    printf("%lld",ans);
}


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

int main ()
{
    int n;
    cin >> n;
    while (n--) {
        string st, tr;
        cin >> st >> tr;
        for (int i = st.size() - 1; i >= 0; i--) {
            char t;
            switch (st[i])
            {
            case 'J':
            {
                tr = tr[tr.size() - 1] + tr.substr(0, tr.size() - 1);
                break;
            }
            case 'C':
            {
                tr = tr.substr(1, tr.size() - 1) + tr[0];
                break;
            }
            case 'E':
            {
                if (tr.size() % 2) {
                    tr = tr.substr(tr.size() - tr.size() / 2, tr.size() / 2) + tr[tr.size() / 2] + tr.substr(0, tr.size() / 2);
                } else {
                    tr = tr.substr(tr.size() - tr.size() / 2, tr.size() / 2) + tr.substr(0, tr.size() / 2);
                }
                break;
            }
            case 'A':
            {
                string tmp = tr;
                for (int j = 0; j < tr.size(); j++) {
                    tr[j] = tmp[tr.size() - 1 - j];
                }
                break;
            }
            case 'M':
            {
                for (int j = 0; j < tr.size(); j++) {
                    if ('0' <= tr[j] && tr[j] <= '8') {
                        tr[j]++;
                    } else if (tr[j] == '9') {
                        tr[j] = '0';
                    }
                }
                break;
            }
            case 'P':
            {
                for (int j = 0; j < tr.size(); j++) {
                    if ('1' <= tr[j] && tr[j] <= '9') {
                        tr[j]--;
                    } else if (tr[j] == '0') {
                        tr[j] = '9';
                    }
                }
                break;
            }
            default: break;
            }
        }
        cout << tr << endl;
    }

    return 0;
}

Measured memory_bytes: 1208
import java.util.*;

public class Main {
	public static void main (String[] args) {
		Scanner sc = new Scanner(System.in);
		char[] arr = sc.next().toCharArray();
		int x = sc.nextInt();
		int y = sc.nextInt();
		ArrayList<Integer> xValues = new ArrayList<>();
		ArrayList<Integer> yValues = new ArrayList<>();
		boolean isX = true;
		boolean isFirst = true;
		int value = 0;
		for (char c : arr) {
		    if (c == 'T') {
		        if (isFirst) {
		            x -= value;
		            isX = false;
		            isFirst = false;
		        } else if (isX) {
	                xValues.add(value);
		            isX = false;
		        } else {
	                yValues.add(value);
		            isX = true;
		        }
		        value = 0;
		    } else {
		        value++;
		    }
		}
        if (isFirst) {
            x -= value;
        } else if (isX) {
            xValues.add(value);
        } else {
            yValues.add(value);
        }
        Collections.sort(xValues);
        Collections.sort(yValues);
        for (int i = xValues.size() - 1; i >= 0; i--) {
            if (x >= 0) {
                x -= xValues.get(i);
            } else {
                x += xValues.get(i);
            }
        }
        for (int i = yValues.size() - 1; i >= 0; i--) {
            if (y >= 0) {
                y -= yValues.get(i);
            } else {
                y += yValues.get(i);
            }
        }
        if (x == 0 && y == 0) {
            System.out.println("Yes");
        } else {
            System.out.println("No");
        }
   }
}




Measured memory_bytes: 24276
#include<bits/stdc++.h>
using namespace std;
using ll=long long;
using ld=long double;
using pll=pair<ll,ll>;
using graph=vector<vector<int>>;
using wgraph=vector<vector<pll>>;

const ll MOD=1000000007;
const int dx[4]={1,0,-1,0};
const int dy[4]={0,1,0,-1};
const int ex[8]={1,1,0,-1,-1,-1,0,1};
const int ey[8]={0,1,1,1,0,-1,-1,-1};

ll abs1(ll a){
  if(a>=0)return a;
  else return -a;
}

ll pow1(ll a,ll b,ll p=LLONG_MAX){
  ll ret=1;
  while(b!=0){
    if((b&1)==1){
      ret*=a;
    }
    a*=a;
    if(a>=p)a%=p;
    b=b>>1;
  }
  return ret;
}

int digit(ll a,ll b){
  int i=0;
  while(a!=0){
    a/=b;
    i++;
  }
  return i;
}

ll gcd1(ll a,ll b){
  if(a==0 && b==0)return 0;
  ll n;
  while(a%b!=0){
    n=a%b;
    a=b;
    b=n;
  }
  return b;
}

ll solveLinear(ll n,ll m,ll c){
  if(n==0 && m==0)return 0;
  ll a[100],b[100];
  a[0]=n;b[0]=m;
  int i=1;
  while(b[i-1]!=0){
    a[i]=b[i-1];
    b[i]=a[i-1]%b[i-1];
    i++;
  }
  n=i;
  if(c%a[n-1]!=0){
    return 0;
  }
  ll x=c/a[n-1],y=0;
  for(i=1;i<n;i++){
    ll cnt=x;
    x=y;
    y=cnt-(a[n-i-1]/b[n-i-1])*y;
  }
  return x;
}

ll modRev(ll a,ll p=MOD){
  a%=p;
  ll n=solveLinear(a,p,1);
  n%=p;
  if(n<0)return n+p;
  return n;
}

ll fact(ll n,ll p=MOD){
  if(n<0)return 0;
  int i;
  ll ret=1;
  for(i=0;i<n;i++){
    ret=ret*(i+1);
    if(ret>=p)ret%=p;
  }
  return ret;
}

ll perm(ll n,ll k,ll p=MOD){
  if(n<0 || k<0 || n<k)return 0;
  int i;
  ll ret=1;
  for(i=0;i<k;i++){
    ret=ret*(n-i);
    if(ret>=p)ret%=p;
  }
  return ret;
}

ll binom(ll n,ll k,ll p=MOD){
  if(n<0 || k<0 || n<k)return 0;
  int i;
  ll ret=1,fact=1;
  for(i=0;i<k;i++){
    ret=ret*(n-i);
    fact*=i+1;
    if(ret>=p)ret%=p;
    if(fact>=p)fact%=p;
  }
  return (ret*modRev(fact))%p;
}

void pushHeap(vector<pll>& h,pll n){
  int i=h.size();
  h.push_back(n);
  while(i!=0 && h[(i-1)/2]>h[i]){
    swap(h[i],h[(i-1)/2]);
    i=(i-1)/2;
  }
  h[i]=n;
}

pll popHeap(vector<pll>& h){
  int n=h.size()-1;
  if(n==-1)return pll(0,0);
  ll i;
  pll ret=h[0];
  swap(h[0],h[n]);
  h.pop_back();
  for(i=0;i<n;){
    int j=2*i+1;
    if(j>=n)break;
    if(j!=n-1 && h[j]>h[j+1])j++;
    if(h[i]>h[j]){
      swap(h[i],h[j]);
    }
    i=j;
  }
  return ret;
}

int bis(vector<int> v,int key){
  int left=-1,right=v.size();
  while(abs1(right-left)>1){
    int mid=left+(right-left)/2;
    if(v[mid]<=key)left=mid;
    else right=mid;
  }
  return left;
}

int main(){
  int i,j,k,l,m,cnt=0;
  int x,y,z;
  cin>>x>>y>>z>>k;
  ll a[x],b[y],c[z];
  for(i=0;i<x;i++)cin>>a[i];
  for(i=0;i<y;i++)cin>>b[i];
  for(i=0;i<z;i++)cin>>c[i];
  sort(a,a+x,greater<ll>());
  sort(b,b+y,greater<ll>());
  sort(c,c+z,greater<ll>());
  vector<ll> d;
  for(i=0;i<x;i++){
    for(j=0;j<y;j++){
      int p=(int)ceil(k/((i+1)*(j+1)));
      for(l=0;l<min(p,z);l++){
        d.push_back(a[i]+b[j]+c[l]);
      }
    }
  }
  sort(d.begin(),d.end(),greater<ll>());
  for(i=0;i<k;i++){
    cout<<d[i]<<endl;
  }
}

Measured memory_bytes: 1400
#include<iostream>
#include<cmath>
using namespace std;
int main()
{
	int t,n,m;
	cin>>t>>n>>m;
	double p[10005];
	for(int i=0;i<t;i++){
		int a;
		cin>>a;
		p[i]=fabs((n-0.006*a)-m);
	}
	double sum=10000000.0;
	int g=0;
	for(int i=0;i<t;i++){
		if(sum>p[i]){
			sum=p[i];
			g=i+1;
		}
	}
	cout<<g<<endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <cmath>

#include <vector>
#include <algorithm>
#include <limits>
#include <unordered_set>
#include <array>
#include <queue>

using namespace std;


int main() {
    int n;
    cin >> n;
    vector<int> x(n);
    vector<int> l(n);
    vector<tuple<int, int, int>> intervals(n);
    for (int i = 0; i < n; ++i) {
        cin >> x[i] >> l[i];
        intervals[i] = make_tuple(i,x[i] - l[i],  x[i] + l[i]);
    }
    sort(intervals.begin(), intervals.end(), [](tuple<int, int, int> x1, tuple<int, int, int> x2) {
        return get<2>(x1) < get<2>(x2);
    });
    int cnt  = 0;
    int idx = 0;
    while(idx < n) {
        auto interval = intervals[idx];
        ++idx;
        ++cnt;
        for (; idx < n; ) {
            if (get<2>(interval) > get<1>(intervals[idx])) {
                ++idx;
            } else {
                break;
            }
        }
    }
    cout << cnt << endl;
}


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

int main()
{
    uint64_t n;
    vector<int> tbl;

    cin >> n;
    while (n > 0) {
        n -= 1;
        const auto q = n % 26;
        tbl.push_back(q);
        n /= 26;
    }

    vector<char> print_table;
    for (int i = 0; i < 26; i++) {
        print_table.push_back('a' + i);
    }
    for (auto it = tbl.rbegin(); it != tbl.rend(); ++it) {
        cout << print_table[*it];
    }
    cout << endl;

    return 0;
}

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

using namespace std;

#define DUMP(x) std::cerr << (#x) << " = " << (x) << "\n"
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
#define REP(i, k, n) for (int i = (k); i < (int)(n); ++i)
#define ALL(r) r.begin(), r.end()
#define YES puts("YES")
#define Yes puts("Yes")
#define NO puts("NO")
#define No puts("No")
#define IMP puts("IMPOSSIBLE")
#define Imp puts("Impossible")
#define imp puts("impossible")
#define M1 puts("-1")
#define pb emplace_back

template <typename T>
ostream &operator<<(ostream &os, vector<T> &v)
{
    os << "{";
    rep(i, v.size()) os << v[i] << (i == (int)v.size() - 1 ? "" : ", ");
    os << "}";
    return os;
}
template <typename T>
T dup(T x, T y)
{
    return (x + y - 1) / y;
};
template <typename A, size_t N, typename T>
inline void arrayFill(A (&array)[N], const T &val) { std::fill((T *)array, (T *)(array + N), val); }
struct in
{
    const size_t n = 0;
    in() = default;
    in(size_t n) : n(n){};
    template <typename T>
    operator T()
    {
        T ret;
        cin >> ret;
        return ret;
    }
    template <typename T>
    operator vector<T>()
    {
        assert(n != 0);
        vector<T> ret(n);
        for (auto &x : ret)
            cin >> x;
        return ret;
    }
};

using ll = int64_t;
using vint = vector<int32_t>;
using vvint = vector<vint>;
using vll = vector<ll>;
using vvll = vector<vll>;
using vstr = vector<string>;
using pint = pair<int32_t, int32_t>;
using vpint = vector<pint>;
using pll = pair<ll, ll>;
using setint = set<int32_t>;
using setstr = set<string>;
using qint = queue<int32_t>;
using qpint = queue<pint>;

constexpr std::int32_t INF = 1001001001;
constexpr std::int64_t LINF = 1001001001001001001;

void Main()
{
    int n, m;
    cin >> n >> m;
    vint ac(n, 0);
    vint wa(n, 0);
    rep(i, m)
    {
        int p = in();
        --p;
        string s = in();
        if (s == "AC")
        {
            ac[p] = 1;
        }
        else
        {
            if (!ac[p])
            {
                ++wa[p];
            }
        }
    }

    int wacnt = 0;
    rep(i, n)
    {
        if (ac[i])
            wacnt += wa[i];
    }

    cout << accumulate(ALL(ac), 0) << " " << wacnt << endl;
}

signed main()
{
    std::cin.tie(nullptr);
    std::ios_base::sync_with_stdio(false);
    std::cout << std::fixed << std::setprecision(15);
    Main();
    return 0;
}


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

int main() {
  int N;
  cin >> N;
  vector<int> a={0};
  int i,j;
  cin>>a.at(0);
  //dainyu-
  for(i=1;i<N;i++){
  int s,flag=1;
  cin >> s;
    for(j=0;j<a.size();j++){
      if(a.at(j)==s)flag=0;
    }
    if(flag==1)a.push_back(s) ;

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


Measured memory_bytes: 256
import math
a,b,x = list(map(int, input().split()))
h = x / ((a**2)*b)
# print(h)
height = (2 * x)/(a**2) - b
if height >= 0:
    angle = math.degrees(math.atan((b-height)/a))
    print(angle)
else:
    base = (2 * x)/(b*a)
    angle = math.degrees(math.atan(b/base))
    print(angle)


Measured memory_bytes: 3060
import sys
input = sys.stdin.readline
N = int(input())
a = list(map(int, input().split()))
a.sort()
cs = [0] * (N + 1)
for i in range(N): cs[i + 1] = cs[i] + a[i]
#print(cs, a)
res = 0
for i in range(1, N):
  if cs[i] * 2 >= a[i]: res += 1
  else: res = 0
print(res + 1)

Measured memory_bytes: 59632
#include <iostream>
using namespace std;
using ll = long long;

ll dig(ll b, ll n);

int main() {
    ll n, s;

    cin >> n >> s;

    if ((s > (n + 1) / 2 && s < n) || s > n) {
        cout << -1 << endl;
        return 0;
    }

    if (s == n) {
        cout << n + 1 << endl;
        return 0;
    }

    ll ans = 1ll << 60ll;
    for (ll i = 2; i * i <= n; i++) {
        if (dig(i, n) == s) {
            ans = min(ans, i);
        }
    }

    for (ll i = 1; i * i <= n; i++) {
        ll j = s - i;
        ll b = (n - j) / i;

        if (b >= 2 && dig(b, n) == s && i >= 0 && j >= 0) {
            ans = min(ans, b);
        }
    }

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

ll dig(ll b, ll n) {
    if (n >= b) {
        return dig(b, n / b) + n % b;
    }
    else {
        return n;
    }
}


Measured memory_bytes: 256
import sys, re, os
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import permutations, combinations, product, accumulate
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from fractions import gcd
 
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def S_MAP(): return map(str, input().split())
def LIST(): return list(map(int, input().split()))
def S_LIST(): return list(map(str, input().split()))
 
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

x = INT()
cnt = 0
ans = 0
# for i in range()

ans += x // 11 * 2
x %= 11
# print(x)
# print(ans)

# もう一回6で埋める必要
if 0 < x <= 6:
    ans += 1
# 6,5で埋める必要
elif x >= 7:
    ans += 2
print(ans)




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

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

	if (n == 1) {
		cout << 1;
		return 0;
	}

	sort(a.begin(), a.end());
	int ans = 0;
	rep(i,n - 1) {
		if (a[i] != a[i + 1]) ans++;
		else i++;
		if (i == n - 2) ans++;
	}
	cout << ans;
	return 0;
}


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

using namespace std;
using u64 = std::uint_fast64_t;

class UnionFind {
public:
  vector<int> parent;

  UnionFind(int n) : parent(n, -1) {
  }

  int root(int x) {
    if (parent[x] < 0) {
      return x;
    } else {
      return parent[x] = root(parent[x]);
    }
  }

  bool issame(int x, int y) {
    return root(x) == root(y);
  }

  int size(int x) {
    return -parent[root(x)];
  }

  bool unite(int x, int y) {
    int rx = root(x), ry = root(y);
    if (rx == ry) return false;
    if (parent[rx] > parent[ry]) swap(rx, ry);
    parent[rx] += parent[ry];
    parent[ry] = rx;
    return true;
  }
};

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int N, M;
  cin >> N >> M;
  UnionFind uf(2 * N);
  for (int i = 0; i < M; i++) {
    int a, b;
    cin >> a >> b;
    a--, b--;
    uf.unite(a, b + N);
    uf.unite(b, a + N);
  }
  if (uf.issame(0, N)) {
    cout << static_cast<u64>(N) * (N - 1) / 2 - M << '\n';
    return 0;
  }

  u64 cnt = 0;
  for (int i = 0; i < N; i++) {
    if (uf.issame(0, i)) cnt++;
  }

  cout << (static_cast<u64>(N) - cnt) * cnt - M << '\n';
  return 0;
}


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

int main() {
  int K;
  string S;
  
  cin >> K >> S;
  
  if(S.length() > K) {
    for(int i = 0; i < K; i++) {
      cout << S[i];
    }
    cout << "..." << endl;
  }
  else {
    cout << S << endl;
  }
  
  return 0;
}

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

// 1 2 3 4 5
int main() {
    int n;
    cin >> n;
    vector<int>v(n);
    int all = 0;
    for(int i = 0;i < n;i++){
        int a;
        cin >> a;
        v[i] = a;
        all ^= a;
    }
    for(int i = 0;i < n;i++){
        int a = all ^ v[i];
        cout << a << " ";
    }
}

Measured memory_bytes: 3948
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <cmath>

using namespace std;

typedef pair< int, int > PI;
typedef pair< double, PI > PDD;

vector< PDD > ans;


int main() {
	int h, w;

	for(int h = 1; h < 200; h++) {
		for(int w = 1; w < 200; w++) {
			if(w > h) {
				ans.push_back(PDD(sqrt((double)(h * h + w * w)), PI(h, w)));
			}
		}
	}

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

	while(true) {
		cin >> h >> w;

		if(!h && !w) {
			break;
		}

		for(int i = 0; i < ans.size(); i++) {
			if(ans[i].second.first == h && ans[i].second.second == w) {
				cout << ans[i + 1].second.first << " " << ans[i + 1].second.second << endl;
				break;
			}
		}
	}
}

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

int main(){
  	//const int origin = 100;
	long long x;
  	long long yy = 1000000000000000000; 
  	cin >> x;
  	//cin >> a >> b;
    int cnt=0;
  	long long money = 100;
  	for (int i=0 ; i < yy ; i ++){
    money = money * 1.01;
    cnt++;
    //cout << cnt <<endl;
    if (money >= x)
      break;
    
    }
    cout << cnt << endl; 
}
    

Measured memory_bytes: 3644
#pragma target("avx")
#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> P;
typedef vector<ll> V;
typedef unordered_map<ll, ll> U_MAP;
typedef priority_queue<ll> pq;
typedef priority_queue<ll, vector<ll>, greater<ll>> rpq;
const int INF = 1e9, MOD = 1e9 + 7, ohara = 1e6 + 10;
const ll LINF = 1e18;

#define rep(i, n) for (ll(i) = 0; (i) < (int)(n); (i)++)
#define rrep(i, a, b) for (ll i = (a); i < (b); i++)
#define rrrep(i, a, b) for (ll i = (a); i >= (b); i--)
#define all(v) (v).begin(), (v).end()
#define Size(n) (n).size()
#define Cout(x) cout << (x) << endl
#define doublecout(a) cout << fixed << setprecision(15) << a << endl;
#define fi first
#define se second
#define m_p make_pair
#define p_b push_back

//------ Believe yourself as a genius!!!!!! ------

int dy[] = {1, 0, -1, 0};
int dx[] = {0, 1, 0, -1};
// int dy[]={-1,0,1,-1,1,-1,0,1};int dx[]={-1,-1,-1,0,0,1,1,1};
string alph("abcdefghijklmnopqrstuvwxyz"), s;
ll n, cnt, ans, a[ohara], b, c, d, tmp, m, h, w, x, y, sum, k, q;
U_MAP mp;

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

  cin >> n >> k;
  if(k==1){
    Cout(0);
    return 0;
  }
  rep(i, n) cin >> a[i];
  rrep(i, 1, n) { a[i] += a[i - 1]; }
  rep(i, n) a[i] -= (i + 1);
  rep(i, n) a[i] %= k;

  mp[0]++;
  k--;
  rep(i, n) {
    ans += max(mp[a[i]], 0LL);
    mp[a[i]]++;
    if (i >= k)
      mp[a[i - k]]--;
    else if (i - k == -1)
      mp[0]--;
  }
  Cout(ans);
  return 0;
}

Measured memory_bytes: 10056
n,m = gets.split.map(&:to_i)

b = Array.new(n+1){[1,false]}
b[1][1] = true

m.times do
    x,y = gets.split.map(&:to_i)
   
    b[y][1] = true if b[x][1]
    b[x][1] = false if b[x][0] == 1
    b[x][0] -= 1
    b[y][0] += 1
end

puts b.count{|e| e[1]}

Measured memory_bytes: 9340
#include <algorithm>
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(), (x).end()
#define ll long long
#define inf 1e9
#define INF 1000000000000000000
#define PI 3.14159265359

int main() {
    int N, M;
    cin >> N >> M;
    vector<int> x(M), y(M), now(N, 1);
    vector<bool> reach(N, false);
    reach[0] = true;
    rep(i, M) {
        cin >> x[i] >> y[i];
        x[i]--, y[i]--;
    }

    int cnt = 0;
    rep(i, M) {
        if (reach[x[i]]) {
            reach[y[i]] = true;
            if (now[x[i]] == 1)
                reach[x[i]] = false;
        }
        now[x[i]]--;
        now[y[i]]++;
    }

    rep(i, N) {
        if (reach[i])
            cnt++;
    }

    cout << cnt << endl;
}

Measured memory_bytes: 1408
#include <bits/stdc++.h>
using namespace std;
vector<int> E[200010];
int P[200010]; 
int cnt[2]; 
int ans[200010]; 
bool used[200010]; 
void dfs(int i, int p, int n){
	P[i] = n; 
	cnt[n] ++; 
	for(auto v : E[i]){
		if(v == p) continue; 
		dfs(v, i, 1-n); 
	}
}
int main(){
	int N; cin >> N; 
	for(int i = 0; i < N-1; i++){
		int a, b; cin >> a >> b; 
		a--; b--; 
		E[a].push_back(b); E[b].push_back(a); 
	}
	dfs(0, -1, 0); 
	int mn = min(cnt[0], cnt[1]); 
	if(cnt[0] > cnt[1]){
		for(int i = 0; i < N; i++) P[i] = 1 - P[i]; 
	}
	if(mn <= N / 3){
		int now = 3; 
		for(int i = 0; i < N; i++){
			if(P[i] == 0){
				ans[i] = now; now += 3; 
				used[ans[i]] = true; 
			}
		}
		now = 1; 
		for(int i = 0; i < N; i++){
			if(ans[i]) continue; 
			while(used[now]) now ++; 
			ans[i] = now ++; 
		}
	}else{
		int now1 = 1; int now2 = 2; 
		for(int i = 0; i < N; i++){
			if(P[i] == 0 && now2 <= N){
				ans[i] = now2; now2 += 3; 
				used[ans[i]] = true; 
			}
			if(P[i] == 1 && now1 <= N){
				ans[i] = now1; now1 += 3; 
				used[ans[i]] = true; 
			}
		}
		int now = 1; 
		for(int i = 0; i < N; i++){
			if(ans[i]) continue; 
			while(used[now]) now ++; 
			ans[i] = now ++; 
		}
	}
	for(int i = 0; i < N; i++) cout << ans[i] << " "; 
	cout << "\n"; 
}

Measured memory_bytes: 23852
#include <bits/stdc++.h> 
 
#define INF (1<<31)//INT_MAX/2
#define MOD 1000000007
 
using ll  = long long;
using ull = unsigned long long;
 
int main(int argc, char *argv[])
{
    int N;
    std::cin >> N;

    ull ans = 1;
    for (int i = 1; i <= N; i++) {
        ans *= i;
        ans %= MOD;
    }

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

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
int main() {
  int n;
  cin >> n;
  for(int i=1; i<=9; i++){
    for(int j=1; j<=9; j++){
      if(i*j == n){
        cout << "Yes" << endl;
        return 0;
      }
    }
  }
  cout << "No" << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <cmath>
using namespace std;
const int MOD = 1e9+7;
using ll = long long;
using vi = vector<int>;
#define rep(i, n) for (int i = 0; i < n; i++)
#define ALL(x) x.begin(), x.end()
int main() {
  string a;
  cin >> a;
  int b = a.size();
  for(int i=0;i<b;i++){
    for(int j = i+1;j<b;j++){
      if(a.at(i)==a.at(j)){
        cout << "no";
        return 0;
      }
    }
  }
  cout << "yes";
}

Measured memory_bytes: 3624
import sys

readline = sys.stdin.readline
readall = sys.stdin.read
ns = lambda: readline().rstrip()
ni = lambda: int(readline().rstrip())
nm = lambda: map(int, readline().split())
nl = lambda: list(map(int, readline().split()))
prn = lambda x: print(*x, sep='\n')

def solve():
    n = ni()
    f, s, *a = nm()
    x = 0
    for c in a: x ^= c
    if (f + s - x) % 2 or ((f + s - x) // 2) & x:
        print(-1)
        return
    y = (f + s - x) // 2
    for i in range(40, -1, -1):
        if x & (1 << i) and y | (1 << i) <= f:
            y |= 1 << i
    print(f - y if f >= y > 0 else -1)
    return

solve()


Measured memory_bytes: 9160
#include <iostream>
using namespace std;
#define in(v) v; cin >> v;
#define rep(i,n) for(int i=0,_i=(n);i<_i;++i)
int main() {
  int in(N);
  int in(C);

  int D[C][C];
  rep(i, C) rep(j, C)
    cin >> D[i][j];

  int count[3][30];
  rep(i, 3) rep(j, C)
    count[i][j] = 0;
  rep(i, N) rep(j, N) {
    int c; cin >> c;
    --c;
    ++count[(i+j)%3][c];
  }

  int ans = 2e9;
  rep(a, C) rep(b, C) rep(c, C) {
    if (a == b || b == c || a == c)
      continue;
    int tmp = 0;
    rep(i, C) {
      tmp += D[i][a] * count[0][i];
      tmp += D[i][b] * count[1][i];
      tmp += D[i][c] * count[2][i];
    }
    ans = min(ans, tmp);
  }
  cout << ans << endl;



  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
long long i,j,a[1000000],n,ans;
map <int,int> m;
int main() 
{
  cin>>n;
  for(int i=1;i<=n;i++)
  {
      cin>>a[i];
  }
  for(int i=1;i<=n;i++)
  {
      m[a[i]+i]++;
  }
  for(int i=1;i<=n;i++)
  {
      ans+=m[i-a[i]];
  }
  cout<<ans;
}
//a[i]+i=j-a[j]

Measured memory_bytes: 22156
from collections import Counter

N = int(input())

dic = {chr(ord('a')+i):50 for i in range(26)}

for i in range(N):
  s = input()
  tmp = Counter(s)
  for j in range(26):
    dic[chr(ord('a')+j)] = min(dic[chr(ord('a')+j)], tmp[chr(ord('a')+j)])
    
rlt = ''
for k in dic:
  if dic[k] > 0:
    rlt += k*dic[k]
    
print(rlt)

Measured memory_bytes: 67592
#include<bits/stdc++.h>
#define int long long int
#define inf 1000000000000
#define hell (int)(1e9+7)

using namespace std;

int power(int x,int n){
    if(n==0)
        return 1;
    if(n%2==0)
        return power((x*x)%hell,n/2)%hell;
    else
        return (x*(power((x*x)%hell,n/2)%hell))%hell;
}

void solve(){
    int n;
    cin>>n;
    vector <int> a(n);
    for(int i=0;i<n;i++)
        cin>>a[i];
    vector <bool> prime(1000005,true);
    prime[0]=prime[1]=false;
    int mp[1000005];
    for(int i=2;i*i<1000005;i++){
        if(prime[i]){
            for(int j=i*i;j<1000005;j+=i){
                prime[j]=false;
                mp[j]=i;
            }
        }
    }
    for(int i=2;i<1000005;i++){
        if(prime[i])
            mp[i]=i;
    }
    vector <int> pp(1000005,0);
    for(int x:a){
        while(x>1){
            int c=0,p=mp[x];
            while(x>1&&x%p==0){
                x/=p;
                c++;
            }
            pp[p]=max(pp[p],c);
        }
    }
    int lcm=1;
    for(int i=2;i<1000005;i++)
        lcm=(lcm*power(i,pp[i]))%hell;
    int ans=0;
    for(int x:a){
        ans=(ans+(lcm*power(x,hell-2))%hell)%hell;
    }
    cout<<ans;
}

signed main()
{
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	int t;
	//cin>>t;
	t=1;
	while(t--){
		solve();
	}
	return 0;
}


Measured memory_bytes: 16128
n,k=map(int,input().split())
x=list(map(int,input().split()))

ans=float("inf")

for i in range(n-k+1):
  range=x[i+k-1]-x[i]
  temp=min(abs(x[i]),abs(x[i+k-1]))
  ans=min(ans,temp+range)

print(ans)

Measured memory_bytes: 14388
use std::io::*;
use std::str::FromStr;
use std::cmp::Ordering;

fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char) 
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}

pub trait BinarySearch<T> {
    fn lower_bound(&self, x: &T) -> usize;
    fn upper_bound(&self, x: &T) -> usize;
}

impl<T: Ord> BinarySearch<T> for [T] {
    fn lower_bound(&self, x: &T) -> usize {
        let mut low = 0;
        let mut high = self.len();

        while low != high {
            let mid = (low + high) / 2;
            match self[mid].cmp(x) {
                Ordering::Less => {
                    low = mid + 1;
                }
                Ordering::Equal | Ordering::Greater => {
                    high = mid;
                }
            }
        }
        low
    }

    fn upper_bound(&self, x: &T) -> usize {
        let mut low = 0;
        let mut high = self.len();

        while low != high {
            let mid = (low + high) / 2;
            match self[mid].cmp(x) {
                Ordering::Less | Ordering::Equal => {
                    low = mid + 1;
                }
                Ordering::Greater => {
                    high = mid;
                }
            }
        }
        low
    }
}

fn main() {
    let n: usize = read();
    let mut ai: Vec<usize> = (0..n).map(|_| read()).collect();
    let mut bi: Vec<usize> = (0..n).map(|_| read()).collect();
    let mut ci: Vec<usize> = (0..n).map(|_| read()).collect();

    ai.sort();
    bi.sort();
    ci.sort();

    let mut ans = 0;
    for b in bi {
        let lower = ai.lower_bound(&b);
        let upper = n - ci.upper_bound(&b);
        let addend = lower * upper;
        ans += addend;
    }

    println!("{}", ans);
}


Measured memory_bytes: 8444
#include<iostream>
using namespace std;
int main()
{
    int a,b,c;
    cin>>a>>b>>c;
    if(a+b<b+c && a+b<c+a)
        cout<<a+b<<endl;
    else if(b+c<a+b && b+c<c+a)
        cout<<b+c<<endl;
    else
        cout<<c+a<<endl;
    return 0;
}


Measured memory_bytes: 3156
import math

N, D = map(int, input().split())
Xs = [list(map(float, input().split())) for _ in range(N)]

ans = 0
for i in range(N-1):
    for j in range(i+1, N):
        sums = 0
        for k in range(D):
            sums += (Xs[j][k] - Xs[i][k])**2
        if math.sqrt(sums).is_integer():
            ans += 1

print(ans)

Measured memory_bytes: 38256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;


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

    vector<int> v(N);
    for(int i = 0; i < N; i++) cin >> v[i];
    sort(v.begin(), v.end());

    int ans = 1000000000;
    for(int i = 0; i < N-K+1; i++){
        ans = min(ans, v[i+K-1]-v[i]);
    }
    cout << ans << endl;
}


Measured memory_bytes: 640
n,m = [int(x) for x in input().split()]
li = []
for _ in range(m):
    li.append([int(x) for x in input().split()])
z = sorted(li,key=lambda x:x[1])
ans = 0
res = 0
for i in z:
    if res < i[0]:
        ans += 1
        res = i[1]-0.5
print(ans)

Measured memory_bytes: 66136
#include <iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<cmath>
#include<set>

using namespace std;

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

	if (A == B && A != C) {
		cout << C << endl;
	}
	else if (A == C && A != B) {
		cout << B << endl;
	}
	else if (B == C && B != A) {
		cout << A << endl;
	}
	
}


Measured memory_bytes: 3560
#include<bits/stdc++.h>
#define MAX 100010
#define inf 1<<29
#define linf 1e18
#define eps (1e-8)
#define mod 1000000007
#define pi M_PI
#define f first
#define s second
#define mp make_pair
#define pb push_back
#define all(a) (a).begin(),(a).end()
#define pd(a) printf("%.10f\n",(double)(a))
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define equals(a,b) (fabs((a)-(b))<eps)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef pair<double,int> pdi;
typedef vector<int> vi;
typedef vector<pii> vpi;
const int dx[8]={1,0,-1,0,1,1,-1,-1};
const int dy[8]={0,1,0,-1,1,-1,1,-1};

int n,q;
ll a[MAX];

int main()
{
  cin>>n>>q;
  FOR(i,0,n)cin>>a[i];
  FOR(k,0,q){
    ll x,ans=0,sum=0;
    int j=0;
    cin>>x;
    FOR(i,0,n){
      sum+=a[i];
      while(x<sum){
        sum-=a[j];
        j++;
      }
      ans+=(i-j+1);
    }
    cout<<ans<<endl;
  }
  
  return 0;
}

Measured memory_bytes: 3864
#include <bits/stdc++.h>
using namespace std;
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int q;
  cin >> q;
  while (q--) {
    long long a, b;
    cin >> a >> b;
    long long ok(0), ng(2e9 + 1);
    while (ng - ok > 1) {
      long long mid = (ok + ng) >> 1;
      if ((mid * mid - (mid & 1)) / 4 < a * b) {
        ok = mid;
      }
      else ng = mid;
    }
    if (a == b) {
      cout << ok - 1 << '\n';
    } else {
      cout << ok - 2 << '\n';
    }
  }
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using Graph = vector<vector<int>>;
#define ll long long
#define _GLIBCXX_DEBUG
const ll MOD = 1000000007;
const int MAX = 510000;

int main() {
  ll N, A, B;
  cin >> N >> A >> B;
  ll ans;
  if (A>B) ans = 0LL;
  else if (N==1) {
    if (A!=B) ans = 0LL;
    else ans = 1LL;
  }
  else ans = (B-A)*(N-2)+1;
  cout << ans << endl;
}

Measured memory_bytes: 256
#include<stdio.h>

int main(){
    
    int a, b, i, j;
    
    while(1){
        scanf("%d %d", &a, &b );
        if(a==0 && b==0) 
        break;
        
        for(i=0; i<a; i++){
            for(j=0; j<b; j++)
           printf("#");
           printf("\n");
        }
          printf("\n");
    }
    return 0;
}


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

using namespace std;
typedef long long ll;

//マクロ
//forループ関係
//引数は、(ループ内変数,動く範囲)か(ループ内変数,始めの数,終わりの数)、のどちらか
//Dがついてないものはループ変数は1ずつインクリメントされ、Dがついてるものはループ変数は1ずつデクリメントされる
#define REP(i,n) for(ll i=0;i<ll(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=a;i<=ll(b);i++)
#define FORD(i,a,b) for(ll i=a;i>=ll(b);i--)
//xにはvectorなどのコンテナ
#define ALL(x) x.begin(),x.end() //sortなどの引数を省略したい
#define SIZE(x) ll(x.size()) //sizeをsize_tからllに直しておく
#define LEN(x) ll(x.length()) //lengthをsize_tからllに直しておく
//定数
#define INF 1000000000000 //10^12:極めて大きい値,∞
#define MOD 1000000007 //10^9+7:合同式の法
#define MAXR 100000 //10^5:配列の最大のrange(素数列挙などで使用)
//略記
#define PB emplace_back //vectorヘの挿入
#define MP make_pair //pairのコンストラクタ
#define F first //pairの一つ目の要素
#define S second //pairの二つ目の要素
#define Umap unordered_map
#define Uset unordered_set

struct UnionFind{
    // 自身が親であれば、その集合に属する頂点数に-1を掛けたもの
    // そうでなければ親のid
    vector<int> r;
 
    UnionFind(int n){
        r = vector<int>(n, -1);
    }
 
    int root(int x){
        if (r[x] < 0) return x;
        return r[x] = root(r[x]);
    }
 
    bool unite(int x, int y){
        x = root(x);
        y = root(y);
        if (x == y) return false;
        if (r[x] > r[y]) swap(x, y);
        r[x] += r[y];
        r[y] = x;
        return true;
    }
 
    int size(int x){
        return -r[root(x)];
    }

    bool is_parent(int x){
        if(r[x] < 0) return true;
        else return false;
    }
};

int main(){
    ll n, m;
    cin >> n >> m;
    // 集合を作る
    UnionFind UF(n);
    for(int i = 0; i < m; i++){
        int a, b;
        cin >> a >> b;
        a -= 1; b -= 1;
        UF.unite(a, b);
    }
    ll ans = -1;
    REP(i, n){
        if(UF.is_parent(i)) ans++;
    }
    cout << ans;
    return 0;
}

Measured memory_bytes: 3784
#include <stdio.h>

int main (){
	int A, B, C;
	scanf("%d %d %d", &A, &B, &C);
	if((A==C&&B==A&&B==C)||(A!=C&&B!=A&&B!=C))
	{
	puts("No"); 
	}
	else 
	{
	puts("Yes");	
	}
return 0;
}

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

int main()
{
    int n;
    long long sum=0,ans=0;
    cin >> n;
    vector<int> p(n);
    map<long long,int> cnt;
    for(int i=0;i<n;i++) cin >> p[i];
    cnt[0]=1;
    for(int i=0;i<n;i++){
        sum+=p[i];
        ans+=cnt[sum];
        cnt[sum]++;
    }

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

Measured memory_bytes: 13568
import java.util.*;
public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		Map<String, Integer> m = new TreeMap<>();
		int max = 1;
		for(int i = 0; i < N; i++) {
			String S = sc.next();
			if(m.containsKey(S)) {
				m.put(S, m.get(S)+1);
				max = Math.max(max, m.get(S));
			}
			else
				m.put(S, 1);
		}
		List<String> l = new ArrayList<>();
		for(String s : m.keySet()) {
			if(m.get(s) == max)
				l.add(s);
		}
		Collections.sort(l);
		for(String s : l)
			System.out.println(s);

	}

}

Measured memory_bytes: 83848
#include <bits/stdc++.h>
#define rep(i, a, n) for(int i = a; i < n; i++)
#define int long long
using namespace std;
typedef pair<int, int> P;
const int mod = 1000000007;
const int INF = 1e18;

signed main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    int ans = 0;
    int n;
    cin >> n;
    vector<int> d(n);
    for(int i = 0; i < n; i++) cin >> d[i];
    for(int i = 0; i < n; i++){
        for(int j = i + 1; j < n; j++){
            ans += d[i] * d[j];
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
S = input()
prev = S[0]
count = 0
sc = 1
ac = 0
for c in S[1:]:
    if prev == c:
        sc += 1
    else:
        if sc == 1:
            count += 1
            ac = 0
        else:
            if ac == 1:
                sc -= 1
                count += 1
            if sc == 1:
                count += 1
                ac = 0
            else:
                count += (sc - 2) // 3 * 2 + (sc - 2) % 3 + 1
                if (sc - 2) % 3 == 0:
                    ac = 1
                else:
                    ac = 0
        prev = c
        sc = 1
else:
    if sc == 1:
        count += 1
        ac = 0
    else:
        if ac == 1:
            sc -= 1
            count += 1
        if sc == 1:
            count += 1
        else:
            count += (sc - 2) // 3 * 2 + (sc - 2) % 3 + 1

print(count)

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

using namespace std;

const int maxN = 200000;

int N;
int A[maxN];

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

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

	for (int i = 0; i < N; i++)
		A[i] -= i + 1;

	sort(A, A + N);

	long long lft = 0, rht = accumulate(A, A + N, 0ll), ans = LLONG_MAX;
	for (int i = 0; i < N; i++) {
		ans = min(ans, rht - lft + (long long)A[i] * (i * 2 - N));
		lft += A[i];
		rht -= A[i];
	}

	cout << ans << '\n';

	return 0;
}


Measured memory_bytes: 1024
#include <iostream>
#include<algorithm>
#include<sstream>
#include<cmath>
#include<vector>
#include<iomanip>
#include<map>
#include<set>
#include<queue>
#include<deque>
#include<list>
using namespace std;
typedef long long ll;
typedef long double ld;
#define rep(i,n) for(int i = 0; i < n;i++)
#define ALL(a)  (a).begin(),(a).end()
const int MOD = 1000000007;
ll l,x,y,s = 0,d,n,m;
int main() {
    cin >> n; vector<int> a(n),b(n);
    rep(i, n) cin >> a[i] >> b[i];
    for(int i = n - 1;i >= 0;i--) {
        y = s + a[i];
        if (y % b[i] != 0) s += b[i] - (y % b[i]);
    }
    cout << s << endl;
}

Measured memory_bytes: 1024
#include<bits/stdc++.h> 
using namespace std;
using ll=long long;
typedef pair<ll,ll> P;
#define fi first
#define se second
#define all(v) (v).begin(),v.end()
const ll inf=(1e18);
const ll mod=1000000007;
const ll mod2=998244353;
ll gcd(ll a,ll b) {return b ? gcd(b,a%b):a;}
ll lcm(ll c,ll d){return c/gcd(c,d)*d;}
//ios_base::sync_with_stdio(false);
//cin.tie(NULL);
struct edge{ll to,cost;};
vector<vector<edge>> graph;
vector<int> d1;
int n,m;
int s,t;
void dijkstra(ll s){
    d1.resize(3*n);
    for(int i=0;i<3*n;i++)d1[i]=INT_MAX;//訪れていない頂点をinfで初期化
    d1[s]=0;
    priority_queue<P,vector<P>,greater<P>> q;
    q.push(P(0,s));//始点を０で置く
    while(!q.empty()){
        P a=q.top();
        q.pop();
        if(d1[a.se]<a.fi)continue;
        for(int i=0;i<graph[a.se].size();i++){
            edge e=graph[a.se][i];
            if(d1.at(e.to)>d1[a.se]+e.cost){
                d1.at(e.to)=d1[a.se]+e.cost;//訪れていないorより低いコストの経路を発見した時、値を更新
                q.push(P(d1[e.to],e.to));//コストの低いところ優先のbfs
            }
        }
    }
}
int main(){
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
   cin>>n>>m;
   graph.resize(3*n);
   for(int i=0;i<m;i++){
       int a,b;
       cin>>a>>b;
       a--;b--;
       graph[a].push_back(edge{b+n,1});
       graph[a+n].push_back(edge{b+2*n,1});
       graph[a+2*n].push_back(edge{b,1});
   }
   cin>>s>>t;
   //t=t+2*n;
   s--;t--;
   dijkstra(s);
   if(d1[t]%3!=0){
       cout<<-1<<endl;
   }
   else cout<<d1[t]/3<<endl;
}


Measured memory_bytes: 17792
import java.util.*;

public class Main {

	static Scanner sc = new Scanner(System.in);
	static int w,h;
	static int[] dx = {-1, -1, -1, 0, 1, 1, 1, 0};
	static int[] dy = {-1, 0, 1, 1, 1, 0, -1, -1};
	static int[][] field;
	
	static boolean read() {
		w = sc.nextInt();
		h = sc.nextInt();
		if(w == 0 && h == 0)
			return false;
		
		field = new int[h+1][w+1];
		for(int i = 1; i <= h; i++)
			for(int j = 1; j <= w; j++)
				field[i][j] = sc.nextInt();
		return true;
	}
	
	static boolean inField(int x, int y) {
		return (x >= 1 && x <= w && y >= 1 && y <= h);
	}
	
	static void dfs(int x, int y) {
		field[y][x] = 0;
		for(int k = 0; k < 8; k++)  {
			int nx = x + dx[k], ny = y + dy[k];
			if(inField(nx, ny) && field[ny][nx] == 1)
				dfs(nx, ny);
		}
			
	}
	
	static int solve() {
		int ret = 0;
		for(int i = 1; i <= h; i++) {
			for(int j = 1; j <= w; j++) {
				if(field[i][j] == 1) {
					ret++;
					dfs(j, i);
				}
			}
		}
		return ret;
	}
	
	public static void main(String[] args) {
		while(read()) {
			System.out.println(solve());
		}
	}
}

Measured memory_bytes: 13000
#include <bits/stdc++.h>
using namespace std;
using vi = vector<int>;

int main(){
    string s,t; cin >> s >> t;
    int ans=10001;
    for(int ix=0;ix+(int)t.size()<=(int)s.size();ix++){
        string tmp = s.substr(ix,t.size());
        int cnt=0;
        for(int ix2=0;ix2<t.size();ix2++){
            if(tmp.at(ix2)!=t.at(ix2)) cnt++;
        }
        //cout << cnt << endl;
        ans = min(ans,cnt);
    }
    cout << ans << endl;
}


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

using namespace std;

typedef long long ll;

#define pii pair<ll,ll>
#define F first
#define S second
#define mp make_pair

int main()
{
    ll n , i , j , k , st , en ;
    scanf("%lld",&n);

    vector<pii > vec;

    for(i = 0 ;i < n ;i ++)
    {
        scanf("%lld %lld",&k,&en);

        vec.push_back(mp(en,k));
    }

    ll now = 0;

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

    for(i = 0 ; i < n ; i++)
    {
        now = now + vec[i].S;
        if(now > vec[i].F)return !printf("No\n");
    }
    printf("Yes\n");


    return 0;
}



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

#define ll long long

int main()
{
   ios_base::sync_with_stdio(false);
   cin.tie(0);
   cout.tie(0);
    
   string s;
   cin>>s;
   
   int len = s.length();
   
   if(len%2 != 0)
   {
       int count = 0;
       for(int i=0;i<=floor(len/2)-1;i++)
       {
           if(s[i] != s[len-i-1])
           count++;
       }
       
       cout<<count<<endl;
   }
   else
   {
       int count = 0;
       for(int i=0;i<=(len/2)-1;i++)
       {
           if(s[i] != s[len-i-1])
           count++;
       }
       
       cout<<count<<endl;
   }
}

Measured memory_bytes: 256