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

#define ll long long
#define ld long double
#define pb push_back
#define mp make_pair
#define forn(i,n) for(ll i=0;i<n;i++)
#define fore(i,a,b) for(ll i=a;i<=b;i++)
#define ford(i,n) for(ll i=n-1;i>=0;i--)
#define fi first
#define se second
#define endl "\n"
#define all(a) a.begin(),a.end()
#define sync ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define PI 3.14159265

/******************************************************************************************************/
void file(){
    #ifndef ONLINE_JUDGE
    // for getting input from input.txt
    freopen("input.txt", "r", stdin);
    // for writing output to output.txt
    freopen("output.txt", "w", stdout);
    #endif
}
/******************************************************************************************************/

const ll nax=2e5+1,mod=1e9+7;



int main(){

    sync
  //  file();
    

    ll n,m,p1;
    cin>>n>>m>>p1;

    pair<ll,pair<ll,ll> > p[m];
    forn(i,m) cin>>p[i].fi>>p[i].se.fi>>p[i].se.se, p[i].se.se = p[i].se.se-p1;
    vector<ll> dist(n+1,-1e15);
    dist[1] = 0;
    forn(i,n-1){
        forn(i,m){
            if(dist[p[i].fi]+p[i].se.se>dist[p[i].se.fi]) 
            {
                dist[p[i].se.fi] = dist[p[i].fi]+p[i].se.se;
            }
        }
    }
        ll ans = dist[n];
        forn(i,n){
        forn(i,m){
            if(dist[p[i].fi]+p[i].se.se>dist[p[i].se.fi]) dist[p[i].se.fi] = dist[p[i].fi]+p[i].se.se;
        }
    }
    if(ans!=dist[n]){
        cout<<-1;
    }
    else{
        cout<<max(ans,0LL);
    }
  return 0;
}


Measured memory_bytes: 384
#include <iostream>
#include <vector>
#include <algorithm>
#include <iterator>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <string>
#include <cmath>
using namespace std;
#define MOD 1000000007
#define INF 1<<30
#define LINF 1LL<<62
#define MAX 510000
#define rep(i,n) for(ll i=0; i<(n); i++)
#define REP(i,a,b) for(ll i=(a); i<(b); i++)
#define all(x) (x).begin(),(x).end()
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef pair<ll, ll> P;
typedef vector<pair<ll, ll>> vpl;
const int mod = 1e9 + 7;

int main(){
    ll n; cin >> n;
    ll t = sqrtl(2*n);
    if(2*n%t == 0 && 2*n/t == t+1){
        puts("Yes");
        cout << t+1 << endl;
        ll size = t;
        vvl ans(t+1);
        vl cnt(n+1,0);
        ll streak = 1;
        rep(i,t+1){
            ll tt = 0;
            while(tt < size){
                if(tt==0){
                    rep(j,i){
                        for(auto k : ans[j]){
                            if(cnt[k]<=1){
                                ans[i].push_back(k);
                                cnt[k]++;
                                tt++;
                                break;
                            }
                        }
                    }
                }
                if(tt==size) break;
                ans[i].push_back(streak);
                cnt[streak]++;
                streak++;
                tt++;
            }
        }
        rep(i,t+1){
            cout << size << " ";
            for(auto j : ans[i]) cout << j << " ";
            cout << endl;
        }
    }else{
        puts("No");
    }
}

Measured memory_bytes: 3968
n,k=map(int,input().split())
l=[input().split() for _ in range(n)]
w=[[0]*(k+1) for _ in range(k+1)]
b=[[0]*(k+1) for _ in range(k+1)]
for i in range(n):
    if ((int(l[i][0])//k+int(l[i][1])//k)%2==0)^(l[i][2]=='W'):
        b[int(l[i][0])%k][int(l[i][1])%k]+=1
    else:
        w[int(l[i][0])%k][int(l[i][1])%k]+=1

for i in range(1,k):
    b[0][i]+=b[0][i-1]
    b[i][0]+=b[i-1][0]
    w[0][i]+=w[0][i-1]
    w[i][0]+=w[i-1][0]
for i in range(1,k):
    for j in range(1,k):
        b[i][j]+=b[i-1][j]+b[i][j-1]-b[i-1][j-1]
        w[i][j]+=w[i-1][j]+w[i][j-1]-w[i-1][j-1]

ans=0
for i in range(k):
    for j in range(k):
        ans=max(ans,b[k-1][k-1]-b[i][k-1]-b[k-1][j]+2*b[i][j]+w[i][k-1]+w[k-1][j]-2*w[i][j])
        ans=max(ans,w[k-1][k-1]-w[i][k-1]-w[k-1][j]+2*w[i][j]+b[i][k-1]+b[k-1][j]-2*b[i][j])
print(ans)


Measured memory_bytes: 94936
#include <bits/stdc++.h>
#define REP(i,n) for(int i=0;i<(n);++i)
#define ALL(v)   (v).begin(),(v).end()
#define debug(x) cerr<<#x<<": "<<(x)<<endl
using namespace std;
using llong = long long;
using vi    = vector<int>;
using vvi   = vector<vi >;
using vvvi  = vector<vvi >;
using pii   = pair<int,int>;
constexpr int    INF=1e9;
constexpr double EPS=1e-9;
constexpr int    MOD=1e9+7;
template<class Type>
void line(const Type &a){int cnt=0;for(const auto &elem:a){cerr<<(cnt++?' ':'>');cerr<<elem;}cerr<<endl;}

using vl   = vector<long long>;
using vvl  = vector<vl >;
using vvvl = vector<vvl >;

template<typename T>
class SegmentTree{
	using F=function<T(T,T)>;
	int n,offset;	//n:=(葉の数（2の階乗数）),offset:=(n-1).
	const T e;		//e:=(単位元).
	vector<T> node;
	const F f;		//f:=(二項演算処理).
	
	int bufsize(int n_){//木に必要なノード数を返す.
		n=1;
		while(n<n_) n<<=1;
		offset=n-1;
		return 2*n-1;
	}
	void build(int l=0,int r=-1){//木を構築する. O(N).
		if(r<0) r=n;
		l+=offset, r+=offset;
		do{
			l=(l-1)/2, r=(r-1)/2;
			for(int i=l;i<r;++i) node[i]=f(node[2*i+1],node[2*i+2]);
		}while(l>0);
	}
	
public:
	/*constructor.*/
	SegmentTree(int n_,T e_,F f_):node(bufsize(n_),e_),e(e_),f(f_){}
	SegmentTree(const vector<T> &v_,T e_,F f_):node(bufsize(v_.size()),e_),e(e_),f(f_){
		copy(ALL(v_),node.begin()+offset);//<algorithm>.
		build();
	}
		
	void init(){fill(ALL(node),e);}//初期化する.
	void update(int k,T a){//k番目の要素をaに更新する. O(log N).
		k+=offset;
		node[k]=a;
		while(k>0){
			k=(k-1)/2;//parent.
			node[k]=f(node[2*k+1],node[2*k+2]);
		}
	}
	void add(int k,T a){update(k,node[k+offset]+a);}//k番目の要素にaを加算する.
	/*[a,b)間のクエリ結果を返す. O(log N).
	（後ろの3つの引数は計算の簡単のための引数. kはノード番号,lとrはそのノードが[l,r)に対応づいているかを表す. 外からはquery(a,b,0,0,n)と呼ぶ.）*/
	T query(int a,int b,int k=0,int l=0,int r=-1){
		if(r<0) r=n;
		if(b<=l or r<=a) return e;			//[a,b)と[l,r)が交差しなければe.
		if(a<=l and r<=b) return node[k];	//[a,b)が[l,r)を完全に含んでいれば,この節点の値.
		T vl=query(a,b,2*k+1,l,(l+r)/2);
		T vr=query(a,b,2*k+2,(l+r)/2,r);
		return f(vl,vr);					//交差する場合,2つの子をクエリ処理して比較.
	}
	
	typename vector<T>::reference operator[](int i){return node[i+offset];}
};

int main(){
	llong n;
	int x,mod;
	cin>>n>>x>>mod;
	
	vl next(mod);
	REP(i,mod) next[i]=(llong)i*i%mod;
	
	vl v;
	int p=x;
	bool jud[mod]={};
	while(1){
		v.push_back(p);
		jud[p]=true;
		
		p=next[p];
		if(jud[p]) break;
	}
	
	using Type=llong;
	auto f=[](Type a,Type b)->Type{return a+b;};
	SegmentTree<Type> tree(v,0,f);
	
	llong ans=0LL;
	
	int pp=0;
	while(v[pp]!=p) pp++;
	ans+=tree.query(0,pp);
	n-=pp;
	
	ans+=tree.query(pp,v.size())*(n/(v.size()-pp));
	
	ans+=tree.query(pp,pp+n%(v.size()-pp));
	
	cout<<ans<<endl;
}

Measured memory_bytes: 5644
#include <iostream>
#include <vector>
#include <string>

using namespace std;

#define NIL -2000000001

struct Node {
	int key;
	int left = NIL;
	int right = NIL;
};

Node tree[500000];

void preorder(int s) {
	if (s != NIL) {
		cout << " " << tree[s].key;
		if (tree[s].left != NIL) {
			preorder(tree[s].left);
		}
		if (tree[s].right != NIL) {
			preorder(tree[s].right);
		}
	}
}

void inorder(int s) {
	if (s != NIL) {
		if (tree[s].left != NIL) {
			inorder(tree[s].left);
		}
		cout << " " << tree[s].key;
		if (tree[s].right != NIL) {
			inorder(tree[s].right);
		}
	}
}

void insert(int s) {
	int y = NIL;
	int x = 0;

	while (x != NIL) {
		y = x;
		if (tree[s].key < tree[x].key) {
			x = tree[x].left;
		}
		else {
			x = tree[x].right;
		}
	}

	if (s == 0) {
		return;
	}

	if (tree[s].key < tree[y].key) {
		tree[y].left = s;
	}
	else {
		tree[y].right = s;
	}
}

void find(int s, int v) {
	if (v == tree[s].key) {
		cout << "yes" << endl;
		return;
	}
	else if (v < tree[s].key) {
		if (tree[s].left == NIL) {
			cout << "no" << endl;
			return;
		}
		find(tree[s].left, v);
	}
	else {
		if (tree[s].right == NIL) {
			cout << "no" << endl;
			return;
		}
		find(tree[s].right, v);
	}
}

int main() {
	int n, value;
	string str;

	cin >> n;
	for (int i = 0; i < n; i++) {
		cin >> str;
		if (str == "insert") {
			cin >> value;
			tree[i].key = value;
			insert(i);
		}
		else if (str == "print") {
			inorder(0);
			cout << endl;
			preorder(0);
			cout << endl;
		}
		else if (str == "find") {
			cin >> value;
			find(0, value);
		}
	}

	return 0;
}

Measured memory_bytes: 9000
# N, D = [int(i) for i in input().split()]
N = int(input())
C = list(input())
l = 0
r = N - 1
count = 0
while l < r:
  if C[l] == 'W' and C[r] == 'R':
    C[l], C[r] = C[r], C[l]
    l += 1
    r -= 1
    count += 1
  else:
    if C[l] == 'R':
      l += 1
    if C[r] == 'W':
      r -= 1
print(count)


Measured memory_bytes: 75936
// and it belongs to the other side

#include <bits/stdc++.h>
#include <vector>

#define s second
#define f first
#define pb push_back
#define int ll
#define D(x) cout<<#x<<": "<<x<<endl
#define D2(x) cout<<#x<<": "<<x<<' '

using namespace std;

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

const long long MAX=2e3,mod=1e9+7,INF=1e15;

int n,m,k,a[MAX][MAX];

vi v;

main()
{
    ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
    cin >> n >> m >> k;
    for(int i=1;i<=k;i++){
        int x;
        cin >> x;
        for(int j=0;j<x;j++){
            v.pb(i);
        }
    }
    int y=0;
    for(int i=0;i<n;i++){
        for(int j=0;j<m;j++){
            a[i][j]=v[y];
            y++;
        }
    }
    for(int i=1;i<n;i+=2){
        reverse(a[i],a[i]+m);
    }
    for(int i=0;i<n;i++){
        for(int j=0;j<m;j++){
            cout << a[i][j] << ' ';
        }
        cout << '\n';
    }
    return -0;
}


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

int main() {
    long n, a, b;
    cin>>n>>a>>b;
    long nn = n;
    long ans = 1;
    while(n!=0){
        long tmp=1;
        long tmpans = 2;
        while(true){
            tmp *= 2;
            if(tmp>n){
                tmp /= 2;
                break;
            }
            tmpans *= tmpans;
            tmpans %= 1000000007;
        }
        ans *= tmpans;
        ans %= 1000000007;
        n -= tmp;
    }

    long ans1 = 1;
    long ans2 = 1;
    for(int i=0;i<a;++i){
        ans1 *= nn-i;
        ans1 %= 1000000007;
    }
    for(int i=0;i<b;++i){
        ans2 *= nn-i;
        ans2 %= 1000000007;
    }
    long a1 = 1;
    long b1 = 1;
    for(int i=0;i<a;++i){
        a1 *= a-i;
        a1 %= 1000000007;
    }
    for(int i=0;i<b;++i){
        b1 *= b-i;
        b1 %= 1000000007;
    }
    long ans11 = 1;
    long ans22 = 1;
    long p1 = 1000000005;
    long p2 = 1000000005;
    while(p1!=0){
        long tmp=1;
        long tmpans = a1;
        while(true){
            tmp *= 2;
            if(tmp>p1){
                tmp /= 2;
                break;
            }
            tmpans *= tmpans;
            tmpans %= 1000000007;
        }
        ans11 *= tmpans;
        ans11 %= 1000000007;
        p1 -= tmp;
    }
    while(p2!=0){
        long tmp=1;
        long tmpans = b1;
        while(true){
            tmp *= 2;
            if(tmp>p2){
                tmp /= 2;
                break;
            }
            tmpans *= tmpans;
            tmpans %= 1000000007;
        }
        ans22 *= tmpans;
        ans22 %= 1000000007;
        p2 -= tmp;
    }
    ans -= 1 + (ans1*ans11)%1000000007 + (ans2*ans22)%1000000007;
    while (ans < 0) {
        ans += 1000000007;
    }
    cout<<ans%1000000007<<endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define modulo 1000000007
#define mod(mod_x) ((((long long)mod_x+modulo))%modulo)
#define Inf 1000000000

vector<int> bfs(vector<vector<pair<int,int>>> &E,int start){
	vector<int> ret(E.size(),Inf);
	
	ret[start] = 0;
	queue<int> Q;
	Q.push(start);
	
	while(Q.size()!=0){
		int from = Q.front();
		Q.pop();
		
		for(int i=0;i<E[from].size();i++){
			int to = E[from][i].first;
			if(ret[to]!=Inf)continue;
			ret[to] = ret[from] + 1;
			Q.push(to);
		}
	}
	
	return ret;
}

int main(){
	
	int N;
	cin>>N;
	
	vector<vector<pair<int,int>>> E(N,vector<pair<int,int>> ());
	
	for(int i=0;i<N-1;i++){
		int a,b;
		cin>>a>>b;
		a--;b--;
		
		E[a].emplace_back(b,i);
		E[b].emplace_back(a,i);
	}
	
	int M;
	cin>>M;
	
	vector<bitset<50>> B(M,(bitset<50>)0);
	
	for(int i=0;i<M;i++){
		int u,v;
		cin>>u>>v;
		
		u--;v--;
		vector<int> D1 = bfs(E,u),D2 = bfs(E,v);
		
		int X = D1[v];
		
		for(int j=0;j<N;j++){
			for(int k=0;k<E[j].size();k++){
				if(D1[j] + D2[E[j][k].first] + 1 == X){
					B[i][E[j][k].second] = true;
				}
			}
		}
	}
	
	long long ans = 0;
	
	for(int i=0;i<(1<<M);i++){
		bitset<50> BB((bitset<50>)0);
		
		int cnt = 0;
		for(int j=0;j<M;j++){
			if((1<<j)&i){
				cnt++;
				BB |= B[j];
			}
		}
		
		long long x = 1;
		for(int j=0;j<N-1;j++){
			if(!BB[j])x*=2;
		}
		//cout<<x<<endl;
		if(cnt%2==0)ans += x;
		else ans -= x;
	}

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


Measured memory_bytes: 256
s = raw_input()

def solve(s):
    # s = raw_input()
    N = len(s)
    for i in xrange(N - 1):
        if s[i] == s[i + 1]:
            return i + 1, i + 2
    for i in xrange(N - 2):
        if s[i] == s[i + 2]:
            return i + 1, i + 3
    return -1, -1

print ' '.join(map(str, solve(s)))


Measured memory_bytes: 2692
n=gets.to_i;m=Math.sqrt(2*n).floor;puts m*m+m==n*2?(a=["#{m}"]*-~m;x=0;[*0..m].combination(2){|i,j|a[i]+=s=" #{x+=1}";a[j]+=s};[:Yes,m+1,a]): :No

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

const int MAX_N = 100000, MAX_A = 100000;

int main() {
  int N, A[MAX_A+1];
  int ma = 0, ans = 0, e = 0;
  cin >> N;
  for (int i=0; i<MAX_A+1; i++) {
    A[i] = 0;
  }
  for (int i=0; i<N; i++) {
    int tmp;
    cin >> tmp;
    ma = max(ma, tmp);
    A[tmp]++;
  }
  for (int i=1; i<=ma; i++) {
    if (A[i]) ans++;
    if ((A[i] & 1) == 0 && A[i]) e++;
  }
  ans -= (e & 1);
  cout << ans << endl;
  return 0;
}


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

const int MOD = 1000000007;
const int INF = 999999999;

int main(){
   string s;
   cin >> s;
   if(s[2] == s[3] && s[4] == s[5]){
      cout << "Yes" << endl;
   }else{
      cout << "No" << endl;
   }
return 0;}

Measured memory_bytes: 256
#include <cstdio>
#include <iostream>
#include <cmath>
#include <algorithm>
#include <vector>
#include <queue>
#include <map>

using namespace std;

int odd[200000];

vector<int> G[200000];

bool search_(int n, int hoge){
	//cout << n << " " << odd[n] << " " << hoge << endl;
	if(odd[n] == hoge){
		return true;
	}else if(odd[n] != -1 && odd[n] != hoge){
		return false;
	}
	odd[n] = hoge;
	bool res = true;
	int hoge2 = (hoge + 1) % 2;
	
	for(int i = 0; i < G[n].size(); i++){
		//cout << n << " " << G[n][i] << " " << hoge2 << endl;
		bool res2 = search_(G[n][i], hoge2);
		res = res && res2;
	}
	
	return res;
}

int main(){
	
	long long int N, M;
	cin >> N >> M;
	
	for(int i = 0; i <= N; i++){
		odd[i] = -1;
	}
	
	for(int i = 0; i < M; i++){
		int p1, p2;
		cin >> p1 >> p2;
		G[p1].push_back(p2);
		G[p2].push_back(p1);
	}
	
	bool res = search_(1, 0);
	
	long long int ans;
	
	if(res){
		long long int count1 = 0;
		long long int count2 = 0;
		for(int i = 1; i <= N; i++){
			if(odd[i] == 0){
				count1++;
			}else{
				count2++;
			}
		}
		ans = count1 * count2 - M;
	}else{
		ans = N * (N - 1) / 2 - M;
	}
	
	cout << ans << endl;
	
	return 0;
}

Measured memory_bytes: 9216
#include <bits/stdc++.h>
using namespace std;
int main() {
  ios::sync_with_stdio(false);
  /* code */
  int n ;
  int k ;
  int q ;
  cin >> n >> k >> q;
  vector<int> a(n);

  for (int i = 0; i < n; i++) {
    /* code */
    a[i]=0;
  }

    
  for (int i = 0; i < q; i++) {
    int x;
    cin >> x;
    a[x-1]++  ;
  }
  
  for (int i = 0; i < n; i++) {
    cout << ((k-q+a[i]<=0)?"No":"Yes") <<"\n";
  }
  
  return 0;
}


Measured memory_bytes: 1024
import java.util.*;

public class Main {
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int[] N = new int[n];
        int idx = 0;
        while(sc.hasNext()) N[idx++]=sc.nextInt();
        int max = N[0];
        int ans =1;
        for (int i=1;i<N.length;++i){
            if (N[i]>=max) {max = N[i];++ans;}
        }
        System.out.println(ans);
    }
}


Measured memory_bytes: 21716
N = int(input())
S = input()

ans = 0

for i in range(N):
    s1 = S[0 : i+1]
    s2 = S[i+1 : N]
    set1 = set(s1)
    set2 = set(s2)
    if ans <= len(set1 & set2):
        ans = len(set1 & set2)

print(ans)        

Measured memory_bytes: 3060
import java.io.*;
import java.util.ArrayList;

public class Main{
    
    public static void main(String[] args) throws IOException {
        
        int n = 0;
        int m = 0;
        
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        
        String[] line = br.readLine().split(" ");
        n = Integer.parseInt(line[0]);
        m = Integer.parseInt(line[1]);
        
        int num_a[][];
        num_a = new int[n][m];
        
        for (int i = 0; i < n; i++) {
            
            String[] line1 = br.readLine().split(" ");
            
            for (int x = 0; x < m; x++) {
                num_a[i][x] = Integer.parseInt(line1[x]);
            }
            
        }
        
        int num_b[];
        int num_c[];
        num_b = new int[m];
        num_c = new int[n];
        
        for(int i = 0; i < m; i++) {
            num_b[i] = Integer.parseInt(br.readLine());
        }
        
        
        for(int i = 0; i < n; i++) {
            
            for(int x = 0; x < m; x++) {
                num_c[i] += num_a[i][x] * num_b[x];
            }
            
        }
        
        for(int i = 0; i < n; i++) {
            System.out.println(num_c[i]);
        }
    }
    
}

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

struct Node{
  vector<int> AJ;
  bool visit;
  int d, f;
};

Node G[101];
int t = 0;

void dfs(int idx){
  G[idx].visit = true;
  G[idx].d = ++t;
  for(int i = 0; i < G[idx].AJ.size(); i++){
    if(!G[G[idx].AJ[i]].visit) dfs(G[idx].AJ[i]);
  }
  G[idx].f = ++t;
}

int main(){
  int n, u, k, v;
  cin >> n;
  for(int i = 0 ; i < 101; i++) G[i].visit = false;
  for(int i = 0; i < n; i++){
    cin >> u >> k;
    for(int j = 0; j < k; j++){
      cin >> v;
      G[u].AJ.push_back(v);
    }
  }
  for(int i = 1; i <= n; i++) if(!G[i].visit) dfs(i);
  for(int i = 1; i <= n; i++) cout << i << " " << G[i].d << " " << G[i].f << endl;
  return 0;
}


Measured memory_bytes: 3176
#include "bits/stdc++.h"
using namespace std;

typedef long long ll;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
typedef pair<ll, ll> P;
#define rep(i, n) for(ll i = 0; i < n; i++)
#define REP(i, a, b) for(ll i = a; i <= b; i++)
#define out(x) std::cout << x << '\n'
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define pb push_back
#define sz(x) ((int)(x).size())
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }
ll lcm(ll a, ll b) { ll g = gcd(a, b); return a / g * b; }
const int dx[4] = { 1, 0, -1,  0 };
const int dy[4] = { 0, 1,  0, -1 };
const int INF = (int)1e9;
const ll  inf = (ll)1e18;
const int mod = 1000000007;
const int MAX_N = 100010;
const double PI = acos(-1);

int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	cout << fixed << setprecision(10);
	/*------------------------------*/

	int n, k;
	cin >> n >> k;
	int d[101];
	int a[101][101];
	bool ans[101] = {};
	rep(i, k) {
		cin >> d[i];
		rep(j, d[i]) {
			cin >> a[i][j];
			a[i][j]--;
			ans[a[i][j]] = true;
		}
	}

	int cnt = 0;
	rep(i, n) {
		if (!ans[i]) {
			cnt++;
		}
	}

	out(cnt);

	return 0;
}

Measured memory_bytes: 3680
#include<iostream>
#include<cstdio>
using namespace std;
int a,b,c,i,cf;

int main(){
	
	cin>>a>>b>>c;
	
	for (i=1; i<=1000; i++){
		cf+=a;
		if (cf%b==c){
			cout<<"YES"<<endl;
			return 0;
		}
	}
	
	cout<<"NO"<<endl;	
	
	return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner scanner = new Scanner(System.in);
		System.out.println(Math.sqrt(Double.parseDouble(String.valueOf(scanner.nextInt()) + String.valueOf(scanner.nextInt()))) % 1 == 0.0 ? "Yes" : "No");
		scanner.close();
	}

}


Measured memory_bytes: 23764
import java.util.*;
import java.lang.*;
import java.math.*;
import java.io.*;

import static java.lang.Math.*;
import static java.util.Arrays.*;

public class Main{

	Scanner sc;

	static final int INF=1<<28;
	static final double EPS=1e-9;

	int n=9;
	int[][] map;
	boolean[][] check;

	void run(){
		sc=new Scanner(System.in);
		int T=sc.nextInt();

		for(int t=0; t<T; t++){
			map=new int[n][n];
			check=new boolean[n][n];
			for(int j=0; j<n; j++)
				for(int i=0; i<n; i++)
					map[j][i]=sc.nextInt();
			row();
			column();
			g();
			for(int j=0; j<n; j++){
				for(int i=0; i<n; i++){
					print(check[j][i]?"*":" ");
					print(map[j][i]+"");
				}
				println("");
			}
			if(t!=T-1)
				println("");
		}
		sc.close();
	}

	void row(){
		for(int j=0; j<n; j++){
			int[] count=new int[n+1];
			for(int i=0; i<n; i++)
				count[map[j][i]]++;
			for(int i=0; i<n; i++)
				if(count[map[j][i]]>1)
					check[j][i]=true;
		}
	}

	void column(){
		for(int i=0; i<n; i++){
			int[] count=new int[n+1];
			for(int j=0; j<n; j++)
				count[map[j][i]]++;
			for(int j=0; j<n; j++)
				if(count[map[j][i]]>1)
					check[j][i]=true;
		}
	}

	void g(){
		for(int q=0; q<n; q+=3){
			for(int p=0; p<n; p+=3){
				int[] count=new int[n+1];
				for(int j=0; j<3; j++)
					for(int i=0; i<3; i++)
						count[map[q+j][p+i]]++;
				for(int j=0; j<3; j++)
					for(int i=0; i<3; i++)
						if(count[map[q+j][p+i]]>1)
							check[q+j][p+i]=true;
			}
		}
	}

	void print(String s){
		System.out.print(s);
	}

	void println(String s){
		System.out.println(s);
	}

	public static void main(String[] args){
		new Main().run();
	}
}

Measured memory_bytes: 12000
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, srt, end) for (long long i = (srt); i < (long long)(end); i++)

ll keta(ll a){
    string s = to_string(a);
    return s.size();
}

int main(){
    ll N;
    cin >> N;

    ll ans = 1e18;
    for(ll a = 1; a*a <= N; a++){
        if(N % a != 0) continue;
        ll b = N/a;
        ans = min(ans, max(keta(a), keta(b)));
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<cstdio>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<ciso646>
#include<random>
#include<map>
#include<set>
#include<complex>
#include<bitset>
#include<stack>
#include<unordered_map>
#include<utility>
using namespace std;
typedef long long ll;
const ll mod = 1000000007;

#define rep(i,n) for(int i=0;i<n;i++)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)

void solve() {
	int n; cin >> n;
	vector<int> a(n);
	rep(i, n)cin >> a[i];
	vector<int> ans;
	map<int, int> mp;
	rep(i, n) {
		mp[a[i]]++;
		if (mp[a[i]] == 0)mp.erase(a[i]);
		mp[a[n - i - 1]]--;
		if (mp[a[n - i - 1]] == 0)mp.erase(a[n - i - 1]);
		if (mp.size() == 0)ans.push_back(i + 1);
	}
	int m = ans.size();
	rep(i, m) {
		cout << ans[i];
		if (i != m - 1)cout << " ";
	}
	cout << endl;
	return;
}

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


Measured memory_bytes: 4336
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
#define all(x) (x).begin(),(x).end()
#define pll pair<ll,ll>
#define rep(i,n) for(int i=0;i<n;i++) 
const ll INF = 1LL<<60;
const ll mod = (int)1e9 + 7;

int main() {
    //ll N; cin >> N;
    //ll N,M; cin >> N >> M;
    string S; cin >> S;
    //ll H,W; cin >> H >> W;
    string T; cin >> T;
    int cnt=0;
    if(S[0]==T[0])cnt++;
    if(S[1]==T[1])cnt++;
    if(S[2]==T[2])cnt++;
    cout << cnt;

}

/*



 */



Measured memory_bytes: 256
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<iostream>
#include<cmath>
using namespace std;
int main()
{
     int sx,sy,tx,ty;
     while(cin>>sx>>sy>>tx>>ty)
     {
     	int a=abs(sy-ty);
		for(int i=1;i<=a;i++)
		{
			printf("U");
		}
     	int b=abs(sx-tx);
     	for(int i=1;i<=b;i++)
     	{
     		printf("R");
		}
		for(int i=1;i<=a;i++)
		{
			printf("D");
		}
     	for(int i=1;i<=b;i++)
     	{
     		printf("L");
		}
		printf("L");
		for(int i=1;i<=a+1;i++)
		printf("U");
		for(int i=1;i<=b+1;i++)
		printf("R");
		printf("D");
		printf("R");
		for(int i=1;i<=a+1;i++)
		printf("D");
		for(int i=1;i<=b+1;i++)
		printf("L");
		printf("U\n");
	 }
return 0;
}

Measured memory_bytes: 256
#include<cstdio>

int main(){
    int H,W;
    for(int c = 1;; c++){
        scanf("%d %d",&H,&W);
            if(H == 0 && W == 0){
                break;
            }
            else if(H != 0 && W != 0){
                for(int i = 1; i <= H; i++){ //高さ1~Hまでループ
                    if(i % 2 == 1){ //高さ奇数の場合
                        for(int j = 1; j <= W; j++){
                            if(j % 2 == 1){
                                printf("#");
                            }
                            else if(j % 2 == 0){
                                printf(".");
                            }
                            if(j == W){
                                printf("\n");
                            }
                        }
                    }
                    else if(i % 2 == 0){ //高さ偶数の場合
                        for(int j = 1; j <= W; j++){
                            if(j % 2 == 1){
                                printf(".");
                            }
                            else if(j % 2 == 0){
                                printf("#");
                            }
                            if(j == W){
                                printf("\n");
                            }
                        }
                    }
                }
                printf("\n");
            }
        }
    return 0;
}


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

#define rep(i, n) for (ll i=0;i<(n); i++)

using namespace std;
typedef long long ll;
typedef pair<ll, ll> pi;

//vector<vector<ll> > comb(ll n, ll b){

class tree{
 public:
  vector<tree> children;
  ll X;

  tree();
  void Add_x(ll x);
};

tree::tree(){
  X = 0;
}

void tree::Add_x(ll x){
  X += x;
  rep(i, this->children.size()) this->children[i].Add_x(x);
}




int main(){
  ll n,q,a,b,p,x,m;

  cin >> n >> m;
  q = 0;
  
  if (n-m/2>=0) q += m/2;
  else {
    q += n;
    m = m-2*n;
    q += m / 4;
  }

  cout << q << endl;
  
  
  
    
    
  
}


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

int main(){
  int N,K;
  cin >> N >> K;
  vector<int> A(N);
  for(int i=0;i<N;i++) cin >> A[i];
  sort(A.begin(),A.end());
  
  int ans=0;
  for(int i=0;i<K;i++) ans += A[i];
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 3632
#include <iostream>
#include <algorithm>
#include <queue>
#include <vector>
#include <set>
#include <map>
#include <cmath>
#include <string>
#define FOR(i,a,b) for(int i=a;i<b;i++)
#define ROF(i,a,b) for(int i=b-1;i>=a;i--)
#define FI first
#define SE second
#define SI size()
#define MA(i,j) make_pair(i,j)
#define PA pair<int,int>
#define PF push_front
#define PB push_back
#define VE vector<int>
#define VP vector<PA>
#define LL long long
#define YES(i) cout<<(i?"YES":"NO")<<endl
#define Yes(i) cout<<(i?"Yes":"No")<<endl
using namespace std;
//
const int MOD=1e9+7;
const int INF=1e9+7;
//
int N;
LL A[100000];
int main(){
  cin>>N;
  FOR(i,0,N){
    cin>>A[i];
  }
  LL S=0;
  int now=0;
  while(now<N){
    LL sum=0;
    while(now<N&&A[now]!=0){
      sum+=A[now];
      now++;
    }
    S+=sum/2;
    now++;
  }
  cout<<S<<endl;
  return 0;
}


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

#define int long long
#define forn(i,a,n) for (int i=a; i<n; i++)

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

	//freopen("input.txt","r",stdin);
	//freopen("output.txt","w",stdout);

	int k;
	cin>>k;
	queue<int> q;
	forn(i,1,10) q.push(i);
	while (--k){
		int x=q.front();
		q.pop();
		int y=x%10;
		forn(i,y-1,y+2){
			if (i<0 || i>=10) continue;
			q.push(x*10+i);
		}
	}
	cout<<q.front()<<endl;
	return 0;
}

Measured memory_bytes: 4768
#include"bits/stdc++.h"
using namespace std;

#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define rep3(i,m,n) for(int (i)=m;(i)<=(n);(i)++)
#define rep3rev(i,m,n) for(int (i)=m;(i)>=(n);(i)--)
#define all(a) (a.begin()),(a.end())
#define rall(a) (a.rbegin()),(a.rend())
#define fi first
#define se second

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

/*** MOD CALCULATION ***/

const int MOD = 1e9+7;
const int MAX = 510000;

ll addM(ll a, ll b){
	return (a + b) % MOD;
}

ll mulM(ll a, ll b){
	ll temp = (a * b) % MOD;
  	while(temp<0){ temp += MOD; }
  	return temp;
}

ll powM(ll a, ll b){
	if(b == 0) return 1;
  	else if(b == 1) return a%MOD;
  	else if(b%2==0) return mulM(powM(a,b/2),powM(a,b/2));
  	else return mulM(a,mulM(powM(a,(b-1)/2),powM(a,(b-1)/2)));
}

// b^{-1} = b^{p-2} (mod p)
// a/b = a*b^{p-2} (mod p)
ll divM(ll a, ll b){ 
  	return mulM(a,powM(b,MOD-2));
}

// n!, (n!)^{-1} のテーブル作成
ll fac[MAX], finv[MAX], inv[MAX];
void COMBinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    rep3(i,2,MAX-1){
        fac[i] = fac[i-1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i-1] * inv[i] % MOD;
    }
}

// 二項係数計算
ll COMB(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;
}

/*** MOD CALCULATION ここまで ***/

void Main()
{
	int n;
  	cin >> n;
  	string s1, s2;
  	cin >> s1 >> s2;
  	ll ans = 1;
  	int past, now; // 1: aa 横並び 2: ab 縦並び

  	rep(i,n){
      	if(i == 0){
        	if(s1[i] == s1[i+1]){
				ans = 6;
          		i++;
              	past = 1;
            }
          	else{
            	ans = 3;
              	past = 2;
            }
        }
    	else{
          	if(s1[i] == s1[i+1]){
        		now = 1;
          		i++;
        	}
      		else{
          		now = 2;
        	}
      		if(past + now == 2){
        		ans = (ans * 3) % MOD;
        	}
      		else if(past == 2){
        		ans = (ans * 2) % MOD;
	    	}
          	past = now;
        }
    }
  	cout << ans << endl;
	return;
}

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

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using vb=vector<bool>;
using vvb=vector<vb>;
using vd=vector<double>;
using vvd=vector<vd>;
using vi=vector<int>;
using vvi=vector<vi>;
using vl=vector<ll>;
using vvl=vector<vl>;
using pll=pair<ll,ll>;
using tll=tuple<ll,ll>;
using vs=vector<string>;
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define rep(i,n) range(i,0,n)
#define rrep(i,n) for(int i=(n)-1;i>=0;i--)
#define range(i,a,n) for(int i=(a);i<(n);i++)

#define LINF    	((ll)1ll<<60)
#define INF     	((int)1<<30)
#define EPS     	(1e-9)
#define MOD     	(1000000007ll)
#define fcout(a)	cout<<setprecision(a)<<fixed
#define fs 			first
#define sc			second
#define PI			(3.1415926535897932384)

int dx[]={1,0,-1,0,1,-1,-1,1},dy[]={0,1,0,-1,1,1,-1,-1};
template<class S,class T>ostream&operator<<(ostream&os,pair<S,T>p){os<<"["<<p.first<<", "<<p.second<<"]";return os;};
template<class S>auto&operator<<(ostream&os,vector<S>t){bool a=1; for(auto s:t){os<<(a?"":" ")<<s; a=0;} return os;}
template<class T> void chmax(T &a, const T &b){if(a<b)a=b;}
template<class T> void chmin(T &a, const T &b){if(a>b)a=b;}
void YN(bool b){cout<<(b?"YES":"NO")<<endl;}
void Yn(bool b){cout<<(b?"Yes":"No")<<endl;}
void yn(bool b){cout<<(b?"yes":"no")<<endl;}

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	vl v;
	ll in;
	while(cin>>in){
		v.push_back(in);
	}
	sort(all(v),greater<ll>());
	rep(i,3){
		cout<<v[i]<<endl;
	}

}




Measured memory_bytes: 3084
#include <iostream>
#include <vector>
#include <queue>
#define REP(i,n) for(int i=0;i<n;i++)

struct edge{
    int to;
    long long cost;
};

using namespace std;

//ダイクストラで多用する型
typedef pair<long long, int> P;//(その頂点までの距離,頂点)として使う。

vector<edge> G[300'010];//頂点iから出る辺の配列G[i]の配列。
int dist[300'010];//特定の頂点から各頂点への距離が格納される。
bool used[300'010];//dijkstra実行中に、頂点iまでの距離を確定したかどうかを持つ。

void dijkstra(int v){//vは始点。
    //以下のリンクでpriority_queueの使い方を参照
    //http://shirokurostone.hatenablog.com/entry/20110522/1306052844
    priority_queue<P, vector<P>, greater<P>> que;
    que.push(P(0, v));
    while(!que.empty()){
        P top = que.top();
        que.pop();
        int u = top.second;
        long long d = top.first;
        //cout << u << ' ' << d << endl;
        if(used[u]) continue;
        dist[u] = d;
        used[u] = true;
        for(int i = 0; i < G[u].size(); i++){
            if(!used[G[u][i].to]){
                que.push(P(d+G[u][i].cost, G[u][i].to));
                //cout << G[u][i].to << ' ' <<  d+G[u][i].cost << endl;
            }
        }
    }
}

int main(){
    int n,m;
    cin >> n >> m;
    int u,v;
    int s,t;
    REP(i,m){
        cin>>u>>v;
        u--;v--;
        REP(j,3){
          G[u+j*n].push_back(edge{v+((j+1)%3)*n, 1});
          //G[v+((j+1)%3)*n].push_back(edge{1, u+j*n});
        }
    }
    cin>>s>>t;
    s--;t--;
    dijkstra(s);
    if(used[t]){
      cout<<dist[t]/3<<endl;
    }else{
      cout<<-1<<endl;
    }
    return 0;
}


Measured memory_bytes: 19572
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#define ll long long
using namespace std;

const ll mod = 1e9 + 7;

ll C[2005][2005];
ll dp[100005][13];

int main(){
    ll a,N,M;
    ll ans = 0, wa = 0;
    cin >> N >> M;
    vector<ll> p(M+5,0);
    vector<string> S(M+5);
    vector<ll> CA(N+5,0);
    vector<ll> CA_miss(N+5,0);
    for (ll i = 0; i < M; i++){
        cin >> p[i] >>S[i];
        if(S[i] == "AC"){
            if(CA[p[i]-1] == 0){
                ans++;
                CA[p[i]-1] = 1;
            }
        }else{
            if(CA[p[i]-1] == 0){
                CA_miss[p[i]-1]++;
            }
        }
    }
    for (ll i = 0; i < N; i++){
        if(CA[i] == 1){
            wa += CA_miss[i];
        }
    }
    cout << ans <<  " " << wa << endl; 
}

Measured memory_bytes: 8064
#include <iostream>
#include <sstream>
#include <string>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <queue>
#include <set>
#include <map>
#include <cstdlib>
#include <cstdio>
#include <cmath>
#include <bitset>
using namespace std;
  
  
const double EPS = 1e-9;
  
int main(){
 
    int n;
    while(cin >> n, n){
        priority_queue<int, vector<int>, greater<int> > pq;
        int k;
        for(int i = 0; i < n; i++){
            cin >> k;
            pq.push(k);
        }
        long long wt = 0;
        while(!pq.empty()){
            wt += pq.top()*(pq.size()-1);
            pq.pop();
        }
 
        cout << wt << endl;
    }
  
    return 0;
}

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

int main() {
  int N; cin >> N;
  string S; cin >> S;
  ll cnt = 0;
  rep(i,0,10) rep(j,0,10) rep(k,0,10) {
    ll a[3];
    a[0] = i; a[1] = j; a[2] = k;
    int now = 0;
    rep(l,0,S.size()) {
      if((S.at(l) - '0') == a[now]) {
        now++;
      }
      if(now==3) {
        cnt++;
        break;
      }
    }
  }
  cout << cnt << endl;
  return 0;
}


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

int main(){
    string s;
    cin >> s;
    int n = s.size();
    for (int bit = 0; bit < (1 << n); bit++){
        ll ans = s[0] - '0';
        for (int i = 0; i < n - 1; i++){
            if (bit & (1 << i)){
                ans += s[i+1] - '0';
            }else{
                ans -= s[i+1] - '0';
            }
        }
        if (ans == 7){
            for (int i = 0; i < n - 1; i++){
                cout << s[i];
                if (bit & (1 << i)){
                    cout << '+';
                }else{
                    cout << '-';
                }
            }
            cout << s[n-1] << "=7" << endl;
            return 0;
        }
    }
}

Measured memory_bytes: 256
/*
* @author:  codancer
* @createTime:  2020-02-16, 20:00:57
*/
#include<bits/stdc++.h>

using namespace std;
typedef long long ll;
const ll mod = 1e9+7;
#define pb push_back
#define SZ(x) ((int)(x).size())
#define fi first
#define se second
typedef vector<int> VI;
typedef pair<int,int> pii;
int main(){
	int a,b,c;
	cin>>a>>b>>c;
	set<int> st;
	st.insert(a);
	st.insert(b);
	st.insert(c);
	if(st.size()==2){
		cout<<"Yes"<<endl;
	}else{
		cout<<"No"<<endl;
	}
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
    long long int n, num = 1, k, cnt = 0;
    bool occurence = false;
    cin >> n;
    for(int i = 0; i < n; i++){
        cin >> k;
        if(k == num)
            num++;
        else
            cnt++;
        if(k == 1)
            occurence = true;
    }
    if(occurence)
        cout << cnt;    
    else
        cout << -1;
    return 0;
}


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

int main()
{
    int64_t a, b, c;
    cin >> a >> b >> c;
    if (a == b && b == c)
    {
        if (a & 1)
        {
            cout << 0 << endl;
        }
        else
        {
            cout << -1 << endl;
        }
        return 0;
    }
    int64_t res = 0;
    while (a % 2 == 0 && b % 2 == 0 && c % 2 == 0)
    {
        res++;
        int64_t new_a = b / 2 + c / 2;
        int64_t new_b = a / 2 + c / 2;
        int64_t new_c = a / 2 + b / 2;
        a = new_a;
        b = new_b;
        c = new_c;
    }
    cout << res << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#define N 20
using namespace std;

int n, ans, a[N], x[N][N], y[N][N];
int main() {
	int i, j, b, fl;
	cin >> n;
	for(i=0; i<n; i++) {
		cin >> a[i];
		for(j=0; j<a[i]; j++) {
			cin >> x[i][j] >> y[i][j];
			x[i][j]--;
		}
	}
	for(b=1; b<1<<n; b++) {
		fl = 1;
		for(i=0; i<n; i++) {
			if(!(b & 1<<i)) continue;
			for(j=0; j<a[i]; j++) {
				if((b>>x[i][j] & 1) ^ y[i][j]) {fl = 0; break;}
			}
			if(!fl) break;
		}
		if(fl) ans = max(ans, __builtin_popcount(b));
	}
	cout << ans;
	return 0;
}


Measured memory_bytes: 256
package main

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

func main() {
	sc := NewScanner()

	n := sc.ReadInt()
	a := make([]int, n)
	b := make([]int, n)
	for i := 0; i < n; i++ {
		a[i] = sc.ReadInt()
		b[i] = sc.ReadInt()
	}

	sort.Ints(a)
	sort.Ints(b)

	if n%2 == 1 {
		min := a[n/2]
		max := b[n/2]
		ans := max - min + 1
		fmt.Println(ans)
	} else {
		min := a[n/2-1] + a[n/2]
		max := b[n/2-1] + b[n/2]
		ans := max - min + 1
		fmt.Println(ans)
	}
}

// util
// *   math/simple

func Abs(x int) int {
	if x >= 0 {
		return x
	}
	return -x
}

func Min(values ...int) int {
	if len(values) == 0 {
		panic("no values")
	}
	min := values[0]
	for _, v := range values {
		if v < min {
			min = v
		}
	}
	return min
}

func Max(values ...int) int {
	if len(values) == 0 {
		panic("no values")
	}
	max := values[0]
	for _, v := range values {
		if v > max {
			max = v
		}
	}
	return max
}

func Pow(base int, exponent uint) int {
	answer := 1
	for i := uint(0); i < exponent; i++ {
		answer *= base
	}
	return answer
}

func Ceil(divident, dividor int) int {
	quo := divident / dividor
	rem := divident % dividor

	if rem != 0 {
		if (divident > 0 && dividor > 0) ||
			(divident < 0 && dividor < 0) {
			return quo + 1
		}
	}
	return quo
}

// *   sortutil

func ReverseInts(a []int) {
	sort.Sort(sort.Reverse(sort.IntSlice(a)))
}

func ReverseStrings(a []string) {
	sort.Sort(sort.Reverse(sort.StringSlice(a)))
}

// *   io

type Scanner struct {
	bufScanner *bufio.Scanner
}

func NewScanner() *Scanner {
	bufSc := bufio.NewScanner(os.Stdin)
	bufSc.Split(bufio.ScanWords)
	bufSc.Buffer(nil, 100000000)
	return &Scanner{bufSc}
}

func (sc *Scanner) ReadString() string {
	bufSc := sc.bufScanner
	bufSc.Scan()
	return bufSc.Text()
}

func (sc *Scanner) ReadInt() int {
	bufSc := sc.bufScanner
	bufSc.Scan()
	text := bufSc.Text()

	num, err := strconv.Atoi(text)
	if err != nil {
		panic(err)
	}
	return num
}

func (sc *Scanner) ReadFloat() float64 {
	bufSc := sc.bufScanner
	bufSc.Scan()
	text := bufSc.Text()

	num, err := strconv.ParseFloat(text, 64)
	if err != nil {
		panic(err)
	}
	return num
}


Measured memory_bytes: 8352
#include <iostream>
#include <vector>
#include <deque>
#include <cmath>
#include <map>
#include <set>
#include <unordered_set>
#include <unordered_map>
#include <algorithm>
#include "iomanip"
#include <cstdio>
#include <cstring>
#include <set>
#include <vector>
#include <fstream>
#include <algorithm>
#include <queue>
#include <cassert>
#include <stack>


using namespace std;



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

    int a, b, res = INT32_MIN;
    cin >> a >> b;
    res = max(a - b,res);
    res = max(a + b,res);
    res = max(a * b,res);
    cout << res;
    return 0;
}




Measured memory_bytes: 256
n=int(input())
v=list(map(int,input().split()))
v.insert(0,0) #数合わせ
check=0 #全部同じ数字か？0なら全部同じ数字
now=v[1]
for i in range(2,n):
    if now!=v[i]:
        check=1
        break
        
odd=[]
even=[]
for i in range(1,n+1):
    if i%2==1:
        odd.append(v[i])
    else:
        even.append(v[i])
        
odd2=sorted(odd)
even2=sorted(even)
now_odd,now_even=odd2[0],even2[0]
rensa_odd,rensa_even=1,1
half=n//2
count_odd=[]
count_even=[]

for i in range(1,half):
    if odd2[i]==now_odd:
        rensa_odd+=1
    else:
        count_odd.append([rensa_odd,now_odd])
        now_odd=odd2[i]
        rensa_odd=1
count_odd.append([rensa_odd,now_odd])

for i in range(1,half):
    if even2[i]==now_even:
        rensa_even+=1
    else:
        count_even.append([rensa_even,now_even])
        now_even=even2[i]
        rensa_even=1
count_even.append([rensa_even,now_even])
count_odd2=sorted(count_odd,reverse=True)
count_even2=sorted(count_even,reverse=True)
#print(count_even2)

if check==0:
    print(half)
else:
    if count_odd2[0][1]!=count_even2[0][1]: #最頻値が違う
        print((half-count_odd2[0][0])+(half-count_even2[0][0]))
    else:
        if len(count_odd2)==1:
            print((half-count_odd2[0][0])+(half-count_even2[1][0]))
        elif len(count_even2)==1:
            print((half-count_odd2[1][0])+(half-count_even2[0][0]))
        else:
            print(min((half-count_odd2[0][0])+(half-count_even2[1][0]),(half-count_odd2[1][0])+(half-count_even2[0][0])))

Measured memory_bytes: 19580
NK = input("").split()

N = int(NK[0])
K = int(NK[1])

if N == K or K==1:
    print(0)

elif N > K:
    A = N % K
    if A > K-A:
        print(K-A)

    else:
        print(A)

else:
    if N <= K-N:
        print(N)
    else:
        print(K-N)


Measured memory_bytes: 3060
#include <iostream>
#include <string>
#include <vector>
#include <math.h>
using namespace std;

int main(void)
{
    int n; cin >> n;
    string c; cin >> c;
    int left_w = 0;
    int right_R = 0;
    for (int i = 0; i < n; i++)
    {
        if (c[i] == 'R') right_R++;
    }
    int ans = max(left_w, right_R);
    for (int i = 0; i < n; i++)
    {
        if (c[i] == 'R') right_R--;
        else left_w++;
        ans = min(ans, max(left_w, right_R));
    }
    cout << ans;
}

Measured memory_bytes: 3692
#include <iostream>
#include <string>
using namespace std;
int main(int argc, char* argv[])
{
	int H,W;
	cin>>H>>W;
	string s;
	int i;
	for (i=0;i<W+2;i++){
		cout<<"#";
	}
	cout<<endl;

	for (i=0;i<H;i++){
		cin>>s;
		cout<<"#"<<s<<"#"<<endl;
	}

	for (i=0;i<W+2;i++){
		cout<<"#";
	}
	cout<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
#define REP(i,n) for(int i=0;i<n;++i)
#define REP1(i,n) for(int i=1;i<=n;++i)
#define SZ(i) int(i.size())
#define eb emplace_back
#define ALL(i) i.begin(),i.end()
#define X first
#define Y second
#ifdef tmd
#define IOS()
#define debug(...) fprintf(stderr,"#%d: %s = ",__LINE__,#__VA_ARGS__),_do(__VA_ARGS__);
template<typename T> void _do(T &&x){cerr<<x<<endl;}
template<typename T, typename ...S> void _do(T &&x, S &&...y){cerr<<x<<", ";_do(y...);}
template<typename It> ostream& _printRng(ostream &os,It bg,It ed)
{
    os<<"{";
    for(It it=bg;it!=ed;it++) {
        os<<(it==bg?"":",")<<*it;
    }
    os<<"}";
    return os;
}
template<typename T> ostream &operator << (ostream &os,vector<T> &v){return _printRng(os,v.begin(), v.end());}
template<typename T> void pary(T bg, T ed){_printRng(cerr,bg,ed);cerr<<endl;}
#else
#define IOS() ios_base::sync_with_stdio(0);cin.tie(0);
#define endl '\n'
#define debug(...)
#define pary(...)
#endif

const int MAXN = 100005;
const ll MOD = 1000000007;

ll mpow (ll bs, ll ep) {
    ll ret = 1;
    while (ep) {
        if (ep & 1) {
            ret = ret * bs % MOD;
        }
        ep >>= 1;
        bs = bs  * bs % MOD;
    }
    return ret;
}

int n, a, b;

ll cob (ll x, ll r) {
    ll ans = 1;
    for (int i=1; i<=r ;i++) {
        ans = ans * (x-i+1) % MOD;
        ans = ans * mpow(i, MOD-2) % MOD;
    }

    return ans;
}
/*********************GoodLuck***********************/
int main () {
    IOS();
    cin >> n >> a >> b;

    ll ans = mpow(2, n) - 1;
    ans -= cob(n, a);
    ans -= cob(n, b);

    ans %= MOD;
    if (ans < 0) {
        ans += MOD;
    }

    cout << ans << endl;
}


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

int main(){
	int N,X,Y;
    cin>>N>>X>>Y;
  	int ans[N-1];
  	for(int h=1;h<N;h++)ans[h]=0;
  	for(int i=1;i<N;i++){
    	for(int j=i+1;j<=N;j++){
        	ans[min({abs(j-i),abs(X-i)+1+abs(Y-j),abs(X-j)+1+abs(Y-i)})]++;
        }
    }
  	for(int k=1;k<N;k++)cout<<ans[k]<<endl;
	return 0;
}

Measured memory_bytes: 256
#ifndef LOCAL
#pragma GCC optimize("O3")
#endif
#include "bits/stdc++.h"
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
using namespace std;
#define sim template < class c
#define ris return * this
#define dor > debug & operator <<
#define eni(x) sim > typename \
  enable_if<sizeof dud<c>(0) x 1, debug&>::type operator<<(c i) {
sim > struct rge { c b, e; };
sim > rge<c> range(c i, c j) { return rge<c>{i, j}; }
sim > auto dud(c* x) -> decltype(cerr << *x, 0);
sim > char dud(...);
struct debug {
#ifdef LOCAL
~debug() { cerr << endl; }
eni(!=) cerr << boolalpha << i; ris; }
eni(==) ris << range(begin(i), end(i)); }
sim, class b dor(pair < b, c > d) {
  ris << "(" << d.first << ", " << d.second << ")";
}
sim dor(rge<c> d) {
  *this << "[";
  for (auto it = d.b; it != d.e; ++it)
    *this << ", " + 2 * (it == d.b) << *it;
  ris << "]";
}
#else
sim dor(const c&) { ris; }
#endif
};
#define imie(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "
#define fastio ios_base::sync_with_stdio(false);cin.tie(0);
typedef long long ll;
typedef tree<ll,null_type,less<ll>,rb_tree_tag,tree_order_statistics_node_update> indexed_set;
int main(){
    fastio
    int n ; 
    cin >> n ; 
    cout << fixed << setprecision(12) << ((n + 1) / 2) / (double) n << endl;
    return 0 ;
}


Measured memory_bytes: 384