akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h> 
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
//typedef pair<ll, ll> P;
//typedef pair<int, pair<int, int>> P;
//typedef tuple<int,int,int> T;
ll INFL = 1000000000000000010;//10^18 = 2^60
int INF = 1e9 + 10;//10^9
ll MOD  = 1000000007;
int dy[] = {0,0,1,-1};
int dx[] = {1,-1,0,0};

int main(void){
    int A,B,K;
    cin >> A >> B >> K;
    vector<int> ans;
    for(int i = 0; i < K; i++){
        if(A + i <= B){
            ans.push_back(A + i);
        }
        if(A <= B - i){
            ans.push_back(B - i);
        }
    }
    sort(ans.begin(), ans.end());
    ans.erase(unique(ans.begin(), ans.end()), ans.end());
    for(int i = 0; i < ans.size(); i++) cout << ans[i] << endl;
    
}

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

//repetition
#define FOR(i,a,b) for(ll i=(a);i<(b);++i)
#define rep(i, n) for(ll i = 0; i < (ll)(n); i++)

//container util
#define all(x) (x).begin(),(x).end()

//typedef
typedef long long ll;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<ll> VLL;
typedef vector<VLL> VVLL;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef pair<ll, ll> PLL;


//conversion
inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
inline ll toLL(string s) {ll v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}

ll mod = 1e9 + 7;
int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    int h,w;
    cin >> h >> w;
    string board[h];
    rep(i,h) cin >> board[i];

    ll dp[h][w];
    memset(dp,0,sizeof(dp));
    rep(i,h){
        if(board[i][0] == '#'){break;}
        dp[i][0] = 1;
    }
    rep(i,w){
        if(board[0][i] == '#') break;
        dp[0][i] = 1;
    }
    FOR(i,1,h)FOR(j,1,w){
        int top,left;
        if(board[i-1][j] == '#') top = 0;
        else top = dp[i-1][j];

        if(board[i][j-1] == '#') left = 0;
        else left = dp[i][j-1];

        dp[i][j] = (top + left) % mod;
    }
    cout << dp[h-1][w-1] << endl;
    return 0;
}


Measured memory_bytes: 9088
//

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
// const int INF = 2147483647;
// const ll INF = 9223372036854775807;
// const ll MOD = 1e9 + 7;

int sub[200001];

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

	int A;
	for (int i=2; i<=N; i++) {
		cin >> A;
		sub[A]++;
	}

	for (int i=1; i<=N; i++) {
		cout << sub[i] << endl;
	}

	return 0;
}

Measured memory_bytes: 4404
//
//AtCoder Beginner Contest 161
//B - Popular Vote
//

#include <iostream>
#include <algorithm>
#include <vector>

using namespace std;

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
#define zero(a) memset(a, 0, sizeof(a))

using ll = long long;

int main()
{
    int n, m;

    cin >> n >> m;

    vector<int> a(n);
    int sum = 0;
    rep(i, n) {
        cin >> a[i];
        sum += a[i];
    }
    sort(a.rbegin(), a.rend());

    if ((double)a[m-1] >= (double)sum/(4.0 * (double)m))
        cout << "Yes" << endl;
    else
        cout << "No" << endl;

    return 0;
}


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

// #define int long long
#define rep(i, n) for (long long i = (long long)(0); i < (long long)(n); ++i)
#define reps(i, n) for (long long i = (long long)(1); i <= (long long)(n); ++i)
#define rrep(i, n) for (long long i = ((long long)(n)-1); i >= 0; i--)
#define rreps(i, n) for (long long i = ((long long)(n)); i > 0; i--)
#define irep(i, m, n) for (long long i = (long long)(m); i < (long long)(n); ++i)
#define ireps(i, m, n) for (long long i = (long long)(m); i <= (long long)(n); ++i)
#define SORT(v, n) sort(v, v + n);
#define REVERSE(v, n) reverse(v, v+n);
#define vsort(v) sort(v.begin(), v.end());
#define all(v) v.begin(), v.end()
#define mp(n, m) make_pair(n, m);
#define cout(d) cout<<d<<endl;
#define coutd(d) cout<<std::setprecision(10)<<d<<endl;
#define cinline(n) getline(cin,n);
#define replace_all(s, b, a) replace(s.begin(),s.end(), b, a);
#define PI (acos(-1))
#define FILL(v, n, x) fill(v, v + n, x);
#define sz(x) long long(x.size())

using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using vs = vector<string>;
using vpll = vector<pair<ll, ll>>;
using vtp = vector<tuple<ll,ll,ll>>;
using vb = vector<bool>;

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

const ll INF = 1e15;
const ll MOD = 1e9+7;
const ll LINF = 1e18;

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

ll ngcd(vector<ll> a) {
  ll res = a[0];
  for(ll i=1; i<a.size() && res!=1; i++) res = gcd(a[i], res);
  return res;
}
ll nlcm(vector<ll> a){
  ll res = a[0];
  for(ll i=1; i<a.size(); i++) res = lcm(a[i], res);
  return res;
}
bool is_prime(ll n) {
  if(n < 2) return false;
  for (ll i = 2; i * i <= n; i++) if (n % i == 0) return false;
  return true;
}
ll digsum(ll n) {
  ll res=0;
  while(n) res += n%10, n /= 10;
  return res;
}
ll digcnt(ll n){
  ll res=0;
  while(n) res++, n /= 10;
  return res;
}
vector<ll> divisor(ll n) {
  vector<ll> res;
  for (ll i = 1; i * i <= n; i++) {
    if (n % i == 0) {
      res.push_back(i);
      if (i != n / i) res.push_back(n / i);
    }
  }
  sort(res.begin(), res.end());
  return res;
}
map<ll, ll> prime_factor(ll n) {
  map<ll, ll> res;
  for (ll i = 2; i * i <= n; i++) {
    while (n % i == 0) ++res[i], n /= i;
  }
  if (n != 1) res[n] = 1;
  return res;
}

ll modpow(ll a, ll n) {
  ll res = 1;
  while (n > 0) {
    if (n & 1) res = res * a % MOD;
    (a *= a) %= MOD;
    n >>= 1;
  }
  return res;
}

signed main()
{
  cin.tie( 0 ); ios::sync_with_stdio( false );
  ll n; cin>>n;
  vll a(n);
  map<ll,ll> m;
  rep(i,n){
    cin>>a[i];
    auto p=prime_factor(a[i]);
    for(auto e: p){
      chmax(m[e.first],e.second);
    }
  }
  ll x=1;
  for(auto e: m){
    rep(i,e.second){
      x*=e.first;
      x%=MOD;
    }
  }
  ll ans=0;
  rep(i,n){
    ans+=x*modpow(a[i],MOD-2)%MOD;
    ans%=MOD;
  }
  cout<<ans<<endl;
}

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

int main(){
    int a[5], k, ans = 0;
    for(int i = 0; i < 5; i++)
        cin >> a[i];
    cin >> k;
    for(int i = 0; i < 5; i++)
        for(int j = 0; j < 5; j++)
            if(a[i] < a[j] && a[j] - a[i] > k)
                ans++;
    if(ans)cout << ":(";
    else cout << "Yay!";
    return 0;
}

Measured memory_bytes: 3576
#include <bits/stdc++.h>
#define inf 0x3f3f3f3f3f3f3f3f
#define debug(...) fprintf(stderr, __VA_ARGS__)
#define fi first
#define se second
#define N 100005

using namespace std;
typedef pair<int,int> Pair;
const int mod = 1e9 + 7;
inline int add(int x, int y) { return (x += y) - (x >= mod ? mod : 0); }
inline void inc(int &x, int y) { (x += y) -= (x >= mod ? mod : 0); }
inline int mul(int x, int y) { return 1ll * x * y % mod; }

template <class T> inline void read(T &x) {
	char ch; while (!isdigit(ch = getchar()));
	for (x = ch ^ 48; isdigit(ch = getchar()); x = x * 10 + (ch ^ 48));
}

int n, nowa, nowb;
int fa[N], fb[N], suma[N], sumb[N];
long long S[N], A, B;

int Rank(long long x) { return lower_bound(S, S + n + 1, x) - S - 1; }

int main() {
	read(n), read(A), read(B);
	for (int i = 1; i <= n; ++i) read(S[i]);
	S[0] = -inf;

	suma[1] = sumb[1] = suma[0] = sumb[0] = fa[0] = fb[0] = 1;
	for (int i = 2; i <= n; ++i) {
		long long ma = Rank(S[i] - A + 1), mb = Rank(S[i] - B + 1);
		fa[i - 1] = sumb[mb], fb[i - 1] = suma[ma];
		if (S[i] < S[i - 1] + B) while (nowa < i - 1) suma[nowa++] = 0;
		if (S[i] < S[i - 1] + A) while (nowb < i - 1) sumb[nowb++] = 0;
		suma[i] = suma[i - 1] = add(suma[i - 2], fa[i - 1]);
		sumb[i] = sumb[i - 1] = add(sumb[i - 2], fb[i - 1]);
	}

	printf("%d\n", add(suma[n - 1], sumb[n - 1]));
	return 0;
}


Measured memory_bytes: 2560
#include<bits/stdc++.h>
#define ll long long int
#define ld long double
using namespace std;
 
int main(){
    ll n;
    cin >> n;
    ld ans = 2*n*3.14;
    cout << ans;
    return 0;
}
//                                     #!!{*[$um1t_Kum@r]*}!!#

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

vector<bool> visited;
vector<set<int>> tree;
vector<int> point;

void dfs (int c) {

  // 訪れたことを記録する
  visited[c] = true;

  // 子として繋がっている数だけ繰り返す
  for (int c_ : tree[c]) {

    // 訪れていない場合だけ続ける
    if (visited[c_] == false) {
      
      // ポイントを加える
      point[c_] += point[c];

      // 次に進む
      dfs(c_);

    }

  }

}

int main() {

  int N, Q;
  cin >> N >> Q;

  visited.resize(N);
  tree.resize(N);
  point.resize(N);

  for (int i = 0; i < N - 1; i++) {
    int a, b;
    cin >> a >> b;
    tree[a - 1].insert(b - 1);
    tree[b - 1].insert(a - 1);
  }

  for (int i = 0; i < Q; i++) {
    int p, x;
    cin >> p >> x;
    point[p - 1] += x;
  }

  dfs(0);
  
  for (int i = 0; i < N; i++) {
    cout << point[i] << " ";
  }
  cout << endl;

  return 0;

}

Measured memory_bytes: 41512
#include<bits/stdc++.h>
#define f(i,b,n) for(int i = b ; i<n;i++)
#define pb push_back
#define ll long long
#define newline	"\n"
using namespace std ;



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

		int a,b,c;
		cin>>a>>b>>c;
		cout<<c<<" "<<a<<" "<<b;

return 0;
 	}

 	
 



Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int a[21321];
int main()
{
	int n;
	cin>>n;
	for(int i=1;i<=2*n;i++)
	  {
	  	scanf("%d",&a[i]);
	  }
	sort(a+1,a+1+2*n);
	int ans=0;
	for(int i=1;i<=n;i++)
	  ans+=a[i*2-1];
	cout<<ans;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define reg register
#define ll long long
inline ll read()
{
	ll x=0,w=0;char ch=getchar();
	while(!isdigit(ch))w|=ch=='-',ch=getchar();
	while(isdigit(ch))x=(x<<3)+(x<<1)+(ch^48),ch=getchar();
	return w?-x:x;
}
int a[1000000],b[1000000];
int main()
{
    int n=read();int m=0;
    reg int i,gs,j;
    for(i=1;i<=n;++i)a[i]=read();
    for(i=n;i>=1;--i)
    {
        gs=0;
        for(j=2;j*i<=n;++j)
            gs+=b[j*i];
        gs%=2;
        if(a[i])
        {
            if(gs==0)b[i]=1;
        }
        else
        {
            if(gs)b[i]=1;
        }
    }
    for(i=1;i<=n;++i)m+=b[i];
    cout<<m<<"\n";
    for(i=1;i<=n;++i)
        if(b[i])cout<<i<<" ";cout<<"\n";
	return 0;
}


Measured memory_bytes: 5760
#pragma region include
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <string>
#include <queue>
#include <stack>
#include <cmath>
#include <set>
#include <cstdio>
#define ALL(obj) (obj).begin(),(obj).end()
#define RALL(obj) (obj).rbegin(),(obj).rend()
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define MOD 1000000007
#define INF 1000000000
#define LLINF 4000000000000000000
using namespace std;
typedef long long ll;
typedef pair<int, int> PII;
typedef vector<int> VI;
typedef vector<VI> VVI;
#pragma endregion

//#define __DEBUG__
#ifdef  __DEBUG__
#define dump(x) cerr << #x << " = " << (x) << " [" << __LINE__ << ":" << __FUNCTION__ << "] " << endl;
// vector出力
template<typename T>
ostream& operator << (ostream& os, vector<T>& v) {
    os << "{";
    REP(i, (int)v.size()) { os << v[i] << (i < v.size() - 1 ? ", " : ""); }
    os << "}";
    return os;
}
// pair出力
template<typename T, typename U>
ostream& operator << (ostream& os, pair<T, U>& p) {
    return os << "(" << p.first << ", " << p.second << ")";
}
// map出力
template<typename T, typename U>
ostream& operator << (ostream& os, map<T, U>& map_var) {
    os << "{";
    for (auto itr = map_var.begin(); itr != map_var.end(); itr++) {
        os << "(" << itr->first << ", " << itr->second << ")";
        itr++;
        if (itr != map_var.end()) os << ", ";
        itr--;
    }
    os << "}";
    return os;
}
// set 出力
template<typename T>
ostream& operator << (ostream& os, set<T>& set_var) {
    os << "{";
    for (auto itr = set_var.begin(); itr != set_var.end(); itr++) {
        os << *itr;
        ++itr;
        if (itr != set_var.end()) os << ", ";
        itr--;
    }
    os << "}";
    return os;
}
#endif

int main() {
    cin.tie(0); ios::sync_with_stdio(false);
    int N; cin >> N;
    int a_cnt, b_cnt, ab_cnt;
    a_cnt = b_cnt = ab_cnt = 0;
    ll ans = 0;
    vector<string> S(N);
    REP(i, N) {
        cin >> S[i];
        REP(j, S[i].size() - 1) {
            if (S[i][j] == 'A' && S[i][j + 1] == 'B') {
                ans++;
            }
        }
        if (S[i][0] == 'B' && S[i][S[i].size() - 1] != 'A') b_cnt++;
        else if (S[i][0] != 'B' && S[i][S[i].size() - 1] == 'A') a_cnt++;
        else if (S[i][0] == 'B' && S[i][S[i].size() - 1] == 'A') ab_cnt++;
    }
    if (ab_cnt > 0) {
        if (a_cnt > 0) {
            ans++; a_cnt--;
        }
        if (b_cnt > 0) {
            ans++; b_cnt--;
        }
    }
    cout << ans + min(a_cnt, b_cnt) + max(ab_cnt - 1,0) << endl;
    getchar(); getchar();
}

Measured memory_bytes: 768
class Heap
  attr_reader :size
  def initialize
    @heap = []
    @size = 0
  end
  def sum
    @heap.inject(:+)
  end
  def push(n)
    i = @size
    while i > 0
      pid = (i - 1) / 2
      break if n >= @heap[pid]
      @heap[i] = @heap[pid]
      i = pid
    end
    @heap[i] = n
    @size += 1
  end
  def pop
    top = @heap[0]
    @size -= 1
    n = @heap[@size]
    i = 0
    while i * 2 + 1 < @size
      cid1 = i * 2 + 1
      cid2 = cid1 + 1
      if cid2 < @size && @heap[cid2] < @heap[cid1]
        cid1 = cid2
      end
      break if @heap[cid1] >= n
      @heap[i] = @heap[cid1]
      i = cid1
    end
    @heap[i] = n
    top
  end
end

def input_n
  gets.to_i               # 単一整数
end

def input_s
  gets.chomp              # 文字列。chompを付けないと改行文字がついてくる
end

def input_a
  gets.split.map(&:to_i)  # スペースで区切られた複数の整数
end

def input_o(num)
  num.times.map { gets.to_i }  # 縦に並んだ複数の整数。たまにある
end

def output_f(num)
  puts sprintf("%.12f", num)
end

n, m = input_a
a = input_a

q = Heap.new

a.each do |num|
  q.push(-num)
end

m.times do
  max = q.pop
  q.push(-(-max / 2))
end

puts -q.sum

Measured memory_bytes: 9556
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
#define all(v) v.begin(), v.end()
typedef long long ll;
typedef pair<ll,ll> P;
typedef vector<ll> vec;
typedef vector<vec> mat;
int main(){
    string s;
    cin>>s;
    vector<char> A,B;
    int n=s.size();
    rep(i,(n-1)/2) A.push_back(s[i]);
    for(int i=(n+1)/2;i<n;i++) B.push_back(s[i]);
    int z=1;
    rep(i,n/2) if(s[i]!=s[n-i-1]) z=0;
    rep(i,A.size()/2) if(A[i]!=A[A.size()-i-1]) z=0;
    rep(i,B.size()/2) if(B[i]!=B[B.size()-i-1]) z=0;
    if(z) cout<<"Yes"<<"\n";
    else cout<<"No"<<"\n";
}

Measured memory_bytes: 256
class RailRoad
  attr_accessor :rail, :exit_train

  def initialize
    @rail = []
    @exit_train = []
  end

  def exit
    @exit_train.push @rail.pop
  end

  def enter(num)
    @rail.push num
  end

  def complete
    @exit_train.each { |e| puts e }
  end
end

rail_road = RailRoad.new
STDIN.read.split("\n").map { |e| e.chomp.to_i }.each do |train|
  train == 0 ? rail_road.exit : rail_road.enter(train)
end
rail_road.complete

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

int main() {
	// your code goes here
	long int n,sum=0,t=0,s=0 ;
	int arr[101] ;
	int i,p ;
	cin>>n ;
	for(i=0 ;i<n;i++)
	 { cin>>arr[i] ;
	  
	 }
	 for(i=0 ;i<n;i++)
	    sum=sum+arr[i] ;
	
	 p = (sum/n)+1 ;
	 
	 
	 for(i=0 ;i<n;i++)
	 {
	     t = t + pow((arr[i]-p),2) ;
	 }
	 
	 int q = sum/n ;
	  
	 for(i=0 ;i<n;i++)
	 {
	     s = s + pow((arr[i]-q),2) ;
	 }
	 cout<<min(s,t) ;
	 
	
	return 0;
}


Measured memory_bytes: 256
#include <vector> 
#include <list> 
#include <map> 
#include <set> 
#include <deque> 
#include <queue> 
#include <stack> 
#include <bitset> 
#include <algorithm> 
#include <functional> 
#include <numeric> 
#include <utility> 
#include <sstream> 
#include <iostream> 
#include <iomanip> 
#include <cstdio> 
#include <cmath> 
#include <cstdlib> 
#include <cctype> 
#include <string> 
#include <cstring> 
#include <ctime> 

using namespace std;

#define _int64 long long

char s[1000];

int main()
{
  int i,j,n,best,ans,tmp,prev;
  char c;
  scanf("%s",s);
  n=strlen(s);
  best=2000000000;
  for (c='a';c<='z';c++)
  {
    ans=0;
    prev=-1;
    for (i=0;i<n;i++)
      if (s[i]==c)
      {
        if (prev==-1) tmp=i;
        else tmp=i-prev-1;
        if (tmp>ans) ans=tmp;
        prev=i;
      }
    if (n-1-prev>ans) ans=n-1-prev;
    if (ans<best) best=ans;
  }
  printf("%d\n",best);
  return 0;
}

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

typedef long long ll;
typedef long double ld;

int n, t, r;
string s;

int main(){
	cin>>s;
	for(int i = 0; i < s.size(); ++i){
		t += s[i] - '0';
	}
	if(t % 9 == 0)cout<<"Yes"<<endl;
	else cout<<"No"<<endl;	
	return 0;
}


Measured memory_bytes: 3716
#include <bits/stdc++.h>
#define LL long long
#define mp make_pair
#define pb push_back
#define INF (1<<29)
using namespace std;
typedef pair<int,int>pii;
int n;
vector<int>G[100010];
int df[100010],ds[100010];
void bfs(int fx,int dist[100010]){
	queue<int>qq;
	qq.push(fx);
	for(int i=1;i<=n;i++)dist[i]=-1;
	dist[fx]=0;
	while(!qq.empty()){
		int node=qq.front();
		qq.pop();
		for(auto i:G[node]){
			if(dist[i]!=-1)continue;
			dist[i]=dist[node]+1;
			qq.push(i);
		}
	}
}
int main(){
	cin>>n;
	for(int i=1;i<n;i++){
		int x,y;
		cin>>x>>y;
		G[x].pb(y);
		G[y].pb(x);
	}
	bfs(1,df);
	bfs(n,ds);
	int f=0,s=0;
	for(int i=1;i<=n;i++){
		if(df[i]<=ds[i])f++;
		else s++;
	}
	if(f>s)cout<<"Fennec\n";
	else cout<<"Snuke\n";
//	cout<<f<<' '<<s<<endl;
//	for(int i=1;i<=n;i++)cout<<df[i]<<' ';
//	puts("");
//	for(int i=1;i<=n;i++)cout<<ds[i]<<' ';
//	puts("");
	return 0;
}


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

typedef long long ll;
int main()
{
	ll n;
	cin>>n;
	ll A[n];
	for(int i=0;i<n;i++)
	cin>>A[i];
	ll ans[n][n];
	for(int i=0;i<n;i++)
	{
		if(n%2==0)
		ans[i][i]=-A[i];
		else ans[i][i]=A[i];
	}
	for(int i=1;i<n;i++)
	{
		for(int j=i-1;j>=0;j--)
		{
			if((n-i+j-1)%2==0)
			{
				ans[j][i]=max(ans[j+1][i]+A[j], ans[j][i-1]+A[i]);
			}
			else{
				ans[j][i]=min(ans[j+1][i]-A[j], ans[j][i-1]-A[i]);
			}
		}
	}
	cout<<ans[0][n-1];
	return 0;
}


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

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  int a,b,c;cin>>a>>b>>c;
  if(b>a)swap(a,b);
  if(c>a)swap(a,c);
  a=a-b+a-c;
  if(a%2==0)cout<<a/2<<endl;
  else cout<<a/2+2<<endl;
  return 0;
  }


Measured memory_bytes: 256
#include<cstdio>
#include<cstdlib>
#include<iostream>
#include<algorithm>
#include<cstring>

using namespace std;

int main(){
	int a, b, c;
	int i, j, n, m, flag;
	while(~scanf("%d %d %d", &a, &b, &c)){
		flag = 0;
		for(i = 1; i < 10000; i++){
			n = a * i;
			m = n % b;
			if(m == c)  flag = 1;
		}
		if(flag) cout << "YES" << endl;
		else cout << "NO" << endl;
	}
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>

using namespace std;

#ifdef DEBUG_MODE
	#define DBG(n) n;
#else
	#define DBG(n) ;
#endif

#define REP(i,n) for(ll (i) = (0); (i) < (n); ++i)
#define PB push_back
#define MP make_pair
#define FI first
#define SE second
#define ALL(v) v.begin(),v.end()
#define INF 1100000000
#define LLINF 1000000000000000000LL
#define MOD 1000000007

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


int main()
{
  int N, K;
  cin >> N >> K;
  if(N % K == 0) cout << 0 << endl;
  else cout << 1 << endl;

	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using vin=vector<int>;
using vll=vector<long long>;
using vvin=vector<vector<int>>;
using vvll=vector<vector<long long>>;
using vstr=vector<string>;
using vvstr=vector<vector<string>>;
using vch=vector<char>;
using vvch=vector<vector<char>>;
using vbo=vector<bool>;
using vvbo=vector<vector<bool>>;
using vpii=vector<pair<int,int>>;
using pqsin=priority_queue<int,vector<int>,greater<int>>;
#define mp make_pair
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep2(i,s,n) for(int i=(s);i<(int)(n);i++)
#define all(v) v.begin(),v.end()
#define decp(n) cout<<fixed<<setprecision((int)n)
const int inf=1e9+7;
const ll INF=1e18;

const int DAT_SIZE=1<<18;
const int MAX_N=100050;

int N;
vll datadd(DAT_SIZE),datmin(DAT_SIZE);//datadd:その区間に一様に加算される値を持つ, datamin:その区間の最小値を持つ
vll a(MAX_N);

//[a,b)にxを加算
//0-indexであることに注意
void add(int a,int b,ll x,int k,int l,int r){
    if(r<=a||b<=l)return;
    if(a<=l&&r<=b)datadd[k]+=x;
    else if(l<b&&a<r){
        add(a,b,x,2*k+1,l,(l+r)/2);
        add(a,b,x,2*k+2,(l+r)/2,r);
        datmin[k]=min(datmin[2*k+1]+datadd[2*k+1],datmin[2*k+2]+datadd[2*k+2]);
    }
}

//初期化
void init(int n){
    N=1;
    while(N<n)N*=2;
    //rep(i,n)add(i,i+1,a[i],0,0,n);
}

ll getmin(int a,int b,int k,int l,int r){
    if(r<=a||b<=l)return INF;
    if(a<=l&&r<=b)return datmin[k]+datadd[k];
    ll chl=getmin(a,b,2*k+1,l,(l+r)/2);
    ll chr=getmin(a,b,2*k+2,(l+r)/2,r);
    return min(chl,chr)+datadd[k];
}

int main(){
    int n,q;cin>>n>>q;
    init(n);
    vll ans;
    int c,s,t;ll x;
    rep(i,q){
        cin>>c>>s>>t;
        if(c==0){
            cin>>x;
            add(s,t+1,x,0,0,N);
        }
        else ans.push_back(getmin(s,t+1,0,0,N));
    }
    rep(i,ans.size())cout<<ans[i]<<endl;
}


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

namespace AtCoder_20190707_1
{    class Program
    {
        static void Main(string[] args)
        {
            string[] ND = Console.ReadLine().Split(' ');
            long N = long.Parse(ND[0]);
            long D = long.Parse(ND[1]);

            long count = 0;

            for(int i = 0; i < N; i++)
            {
                string[] XY = Console.ReadLine().Split(' ');

                long X = long.Parse(XY[0]);
                long Y = long.Parse(XY[1]);

                if(X * X + Y * Y <= D * D)
                {
                    count++;
                }
            }

            Console.WriteLine(count);
        }
    }
}

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

int main() {
    int N;
    int o;
    int cnt = 0;
    int ans = 0;

    cin >> N;

    if ( N % 2 == 0 ) o = N - 1;
    else o = N;


    for ( int i = o; i > 0; i = i - 2 ) {
        for ( int j = 1; j <= o; j = j + 2 ) {
            if ( i % j == 0 ) cnt++;
        }
        if ( cnt == 8 ) ans++;
        cnt = 0;
    }

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

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll          long long int
#define uu          first
#define vv          second
#define pii         pair<int,int>
#define pll         pair<ll,ll>
#define tp          tuple<int,int,int>
#define fastio      ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
using namespace std;
const int INF = 1e9;
const ll MOD = 1e9 + 7;

const int N = 1e6 + 6;
int tree[4*N], lazy[4*N][3];


void push(int node, int l , int r) {

	if(lazy[node][0]) {
		tree[node] = lazy[node][2] + l - lazy[node][1];
		if(l != r) {
			for(int i =0 ; i <= 2 ; i++ ) {
				lazy[node<<1][i] = lazy[node][i];
				lazy[node<<1|1][i] = lazy[node][i];
			}
			lazy[node][0] =0;
		}
	}
}

int query(int node , int l , int r , int key ) {
	push(node , l , r);
	if( l > r || l > key || r < key ) return INF;
	if( l == r ) return tree[node];
	int mid = (l+r)/2;
	int q1 = query(node<<1 , l , mid , key);
	int q2 = query(node<<1|1 , mid+1 , r , key);
	return  min(q1 , q2);
}

void update(int node, int l , int r , int frm , int to, int Lid , int Lval) {
	push(node , l , r);
	if(l > r || l > to ||  r < frm) return;
	if(l >= frm && r <= to) {
		lazy[node][0] = 1;
		lazy[node][1] = Lid;
		lazy[node][2] = Lval;
		push(node, l , r);
		return;
	}
	int mid = (l+r)/2;
	update(node<<1 , l , mid , frm , to  , Lid , Lval);
	update(node<<1|1 , mid+1 , r , frm , to , Lid , Lval);
	tree[node] = min(tree[node<<1]  , tree[node<<1|1]);
}

int main()  {
	fastio;

	int h , w;
	cin>>h>>w;


	for(int i = 1 ; i <= h ; i++ ) {
		
		int frm ,to;
		cin>>frm>>to;
		int Lval = query(1 ,1 , w , frm-1 );
		if(frm == 1) Lval = INF;
		update(1 , 1 , w , frm , to , frm-1 , Lval);
		int ret = tree[1] + i;
		if(ret >= INF) ret = -1;
		cout<<ret<<'\n';
	}
    return 0;
    
}

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

string s;
int len;

int main(){
    cin>>s;
    len=s.size();
    for(int i=0;i<len;i++)
        if(s[i]=='C')
            for(int j=i+1;j<len;j++)
                if(s[j]=='F'){
                    cout<<"Yes"<<endl;
                    return 0;
                }
    cout<<"No"<<endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int a[100000+10];
int main()
{
	int n,k;
	int sum=0;
	cin>>n>>k;
	for(int i=0;i<n;i++)
		cin>>a[i];
	for(int i=0;i<n;i++)
	{
		if(a[i]>=k)
			sum++;
	}
	cout<<sum;

	return 0;
}

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

cases = int(input())
account = {'AC': 0, 'WA' : 0, 'TLE':0, 'RE':0}

while cases > 0:
  account[input().split()[0]] += 1
  cases -= 1
  
print('AC x '+ str(account['AC']))
print('WA x '+ str(account['WA']))
print('TLE x '+ str(account['TLE']))
print('RE x '+ str(account['RE']))

Measured memory_bytes: 9124
#include <iostream>
#include <string>
#include <vector>
#include <list>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <functional>
#include <utility>
#include <fstream>

using namespace std;

#define ll long long
#define INF 2000000000
#define LINF 9000000000000000000
#define rep(i,n) for(int i=0;i<(int)n;i++)
#define dum(x) cout<<#x<<'='<<x<<endl
#define dum2(x,y) cout<<#x<<'='<<x<<' '<<#y<<'='<<y<<'\n'<<endl
#define dum3(x,y,z) cout<<#x<<'='<<x<<' '<<#y<<'='<<y<<' '<<#z<<'='<<z<<'\n'<<endl
#define darr(arr,n) rep(i,(n-arr)){cout<<*(arr+i)<<' ';}cout<<endl
#define ddarr(arr,a,b) rep(i,a){rep(j,b){cout<<*(arr+i*b+j)<<' ';}cout<<endl;}
#define ddd ifstream in("Text.txt");cin.rdbuf(in.rdbuf());


struct unionfind {
    vector<int> par; //par[i]:iの親の番号
    vector<int> sizes;//根ノードiの木のサイズ。根ノードでない場合は意味なし。

    unionfind(int N) : par(N), sizes(N, 1) { //最初は全てが根として初期化
        for (int i = 0; i < N; i++) par[i] = i;
    }

    int parfind(int x) {//親探し、どの集合に属しているか判定(直線DFS)
        if (par[x] == x) return x;
        return par[x] = parfind(par[x]);
    }

    void unite(int x, int y) {//木を併合
        x = parfind(x);
        y = parfind(y);
        if (x == y) return; //既に同じ集合
        if (sizes[x] < sizes[y]) swap(x, y);// xの木がyの木より大きくなるようにする
        par[y] = x;
        sizes[x] += sizes[y];
    }

    bool same(int x, int y) { //x, yの属する木が同じならtrueを返す
        return parfind(x) == parfind(y);
    }

    int size(int x) {//xが含まれる木のサイズを返す
        return sizes[parfind(x)];
    }
};

int a[60], b[60];

int main() {
    int N, M;
    cin >> N >> M;
    rep(i, M) {
        cin >> a[i] >> b[i];
        a[i]--; b[i]--;
    }
    int cou = 0;
    rep(i, M) {
        unionfind uf(N);
        rep(j, M) {
            if (i == j)continue;
            uf.unite(a[j], b[j]);
        }
        if (uf.size(0) != N)cou++;
    }
    cout << cou << endl;
}


Measured memory_bytes: 256
#include <stdio.h>
int
main (void)
{
  int h, w, f;
  while (1)
    {
      scanf ("%d%d", &h, &w);
      if (h == 0 && w == 0)
	break;
      f = w << 1;
      for (; h > 0; h--)
	{
	  for (w = f >> 1; w > 0; w--)
	    {
	      if ((f & 0x1) == 0)
		printf ("#");
	      else
		printf (".");
	      f ^= 0x1;
	    }
	  if ((f >> 1 & 1) == 0)
	    f ^= 0x1;
	  puts ("");
	}
      puts ("");
    }
  return 0;
}

Measured memory_bytes: 588
A=[list(map(int,input().split())) for i in range(3)]
N=int(input())
b= [int(input()) for i in range(N)]
 
for i in range(N):
    for j in range(3):
        for k in range(3):
            if b[i]==A[j][k]:
                A[j][k]=0
 
List=[]
                
sum = 0
for i in range(3):
    sum=0
    for j in range(3):
        sum=sum+A[i][j]
    List.append(sum)
 
sum = 0
for i in range(3):
    sum=0
    for j in range(3):
        sum=sum+A[j][i]
    List.append(sum)
 
sum = 0
for i in range(3):
    sum=sum+A[i][i]
List.append(sum)
 
sum= 0
for i in range(3):
    sum =sum+A[i][2-i]
List.append(sum)
 
ans=0
for i in range(len(List)):
    if List[i]==0:
        ans = ans +1
 
if ans !=0:
    print('Yes')
else:
    print('No')

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

#define IL __inline__ __attribute__((always_inline))

#define For(i, a, b) for (int i = a, i##end = b; i <= i##end; ++ i)
#define FOR(i, a, b) for (int i = a, i##end = b; i < i##end; ++ i)
#define Rep(i, a, b) for (int i = a, i##end = b; i >= i##end; -- i)
#define REP(i, a, b) for (int i = (a) - 1, i##end = b; i >= i##end; -- i)

typedef long long LL;

template <class T>
IL bool chkmax(T &a, const T &b) {
  return a < b ? ((a = b), 1) : 0;
}

template <class T>
IL bool chkmin(T &a, const T &b) {
  return a > b ? ((a = b), 1) : 0;
}

template <class T>
IL T mymax(const T &a, const T &b) {
  return a > b ? a : b;
}

template <class T>
IL T mymin(const T &a, const T &b) {
  return a < b ? a : b;
}

template <class T>
IL T myabs(const T &a) {
  return a > 0 ? a : -a;
}

const int INF = 0X3F3F3F3F;
const double EPS = 1E-10, PI = acos(-1.0);

#define DEBUG(...) fprintf(stderr, __VA_ARGS__)
#define OK DEBUG("Passing [%s] in LINE %d...\n", __FUNCTION__, __LINE__)
/*------------------------------header------------------------------*/

const int MAXN = 3000 + 5, MOD = 1000000007;

IL int add(int a, int b) {
  a += b;
  return a >= MOD ? a - MOD : a;
}

IL int mul(int a, int b) {
  return (LL)a * b % MOD;
}

int a[MAXN], f[MAXN][MAXN][2], tag[MAXN][MAXN], power[MAXN];

int main() {
  int n, q;
  scanf("%d%d", &n, &q);
  For(i, 1, n) {
    scanf("%d", &a[i]);
  }
  For(i, 1, n) {
    For(j, i + 1, n) {
      f[i][j][0] = a[i] < a[j];
      f[i][j][1] = a[i] > a[j];
    }
  }
  power[0] = 1;
  For(i, 1, q) {
    power[i] = add(power[i - 1], power[i - 1]);
  }
  For(t, 1, q) {
    int x, y;
    scanf("%d%d", &x, &y);
    if (x > y) {
      std::swap(x, y);
    }
#define update(a, b) f[a][b][0] = mul(f[a][b][0], power[t - tag[a][b] - 1]), f[a][b][1] = mul(f[a][b][1], power[t - tag[a][b] - 1])
    update(x, y);
    f[x][y][0] = f[x][y][1] = add(f[x][y][0], f[x][y][1]);
    tag[x][y] = t;
    FOR(i, 1, x) {
      update(i, x), update(i, y);
      f[i][x][0] = f[i][y][0] = add(f[i][x][0], f[i][y][0]);
      f[i][x][1] = f[i][y][1] = add(f[i][x][1], f[i][y][1]);
      tag[i][x] = tag[i][y] = t;
    }
    FOR(i, x + 1, y) {
      update(x, i), update(i, y);
      f[x][i][0] = f[i][y][1] = add(f[x][i][0], f[i][y][1]);
      f[x][i][1] = f[i][y][0] = add(f[x][i][1], f[i][y][0]);
      tag[x][i] = tag[i][y] = t;
    }
    For(i, y + 1, n) {
      update(x, i), update(y, i);
      f[x][i][0] = f[y][i][0] = add(f[x][i][0], f[y][i][0]);
      f[x][i][1] = f[y][i][1] = add(f[x][i][1], f[y][i][1]);
      tag[x][i] = tag[y][i] = t;
    }
  }
  int answer = 0;
  For(i, 1, n) {
    For(j, i + 1, n) {
      answer = add(answer, mul(f[i][j][1], power[q - tag[i][j]]));
    }
  }
  printf("%d\n", answer);
  return 0;
}

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

using namespace std;

#define int long long
#define endl '\n'
#define maxn 100010
const int MOD = 1000000007;

void solve() {
    int a, b;
    cin >> a >> b;
    
    int lcm = (a * b)/__gcd(a, b);
    cout << lcm << endl;
}

int32_t main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);

    int t = 1;
//    cin >> t;

    while (t--)
        solve();
    return 0;
}

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

int main()
{

	int N;
	int a[100000];
	int tmp;
	cin >> N;

	for (int i = 0; i < N; i++) {
		cin >> tmp;
		a[tmp - 1] = i+1;
	}
	for (int i = 0; i < N; i++) {
		cout << a[i] << " ";
	}

	return 0;
}

Measured memory_bytes: 1152
#include <bits/stdc++.h>
using namespace std;
int main(void){
    ios_base::sync_with_stdio(false);
  string n;
  cin >> n;
  int x,a,b,c,d;
  x = stoi(n);
  a = x/1000;
  b = x/100-a*10;
  c = x/10-a*100-b*10;
  d = x-a*1000-b*100-c*10;
  if(a+b+c-d==7){
      cout << a << "+" << b  << "+" << c << "-" << d << "=7" << endl; 
      return 0;
  }
  else if(a+b-c+d==7){
      cout << a << "+" << b  << "-" << c << "+" << d << "=7" << endl; 
       return 0;
  }
  else if(a-b+c+d==7){
      cout << a << "-" << b  << "+" << c << "+" << d << "=7" << endl; 
       return 0;
  }
  else if(a+b+c+d==7){
      cout << a << "+" << b  << "+" << c << "+" << d << "=7" << endl; 
       return 0;
  }
  else if(a-b-c+d==7){
      cout << a << "-" << b  << "-" << c << "+" << d << "=7" << endl; 
       return 0;
  }
  else if(a+b-c-d==7){
      cout << a << "+" << b  << "-" << c << "-" << d << "=7" << endl; 
       return 0;
  }
  else if(a-b+c-d==7){
      cout << a << "-" << b  << "+" << c << "-" << d << "=7" << endl; 
       return 0;
  }
  else if(a-b-c-d==7){
      cout << a << "-" << b  << "-" << c << "-" << d << "=7" << endl; 
       return 0;
  }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
typedef long long ll;
using namespace std;
 
int main(){
  int N;
  ll M;
  cin >> N;
  vector<ll> L = {2 , 1};
  for(int i=2;i<=N;i++){
    M = L.at(i-2) + L.at(i-1);
    L.push_back(M);
  }
  cout << L.at(N) << endl;
}

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

int main() {
  int n;
  cin>>n;
  ll a[200010];
  a[0]=0;
  rep(i,n){
    ll A;
    cin>>A;
    a[i+1]=a[i]+A;
  }
  ll min_ans=9090909090;
  rep(i,n){
    ll ans;
    ans=abs(a[i]-(a[n]-a[i]));
    min_ans=min(min_ans,ans);
  }
  cout<<min_ans<<endl;
}

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

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

  while(n){
    int a;cin>>a;
    h-=a;
    if(h<=0)break;
    n--;
  }
  
  if(max(h,0))cout<<"No"<<endl;
  else cout<<"Yes"<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(k,i,n) for(ll i=k;i<n;++i)
struct unionfind{
    public:
    vector<ll>par;
    vector<ll>siz;
    unionfind(ll n) :par(n),siz(n,1LL){
        rep(0,i,n)par[i]=i;
    }
    ll root(ll x){
        if(par[x]==x)return x;
        return par[x]=root(par[x]);
    }
    bool merge(ll x,ll y){
        x=root(x);
        y=root(y);
        if(x==y)return false;
        if(siz[x]<siz[y])swap(x,y);
        siz[x]+=siz[y];
        par[y]=x;
        return true;
    }
    bool same(ll x,ll y){
        ll rx=root(x);
        ll ry=root(y);
        return rx==ry;
    }
    ll size(ll x){
        return siz[root(x)];
    }
};
int main(void){
    ll n,m;
    cin>>n>>m;
    vector<pair<ll,ll>> a(m);
    rep(0,i,m)cin>>a[i].first>>a[i].second;
    unionfind tree(n);
    ll ans[m+1];
    rep(0,i,m){
        ll x=a[m-1-i].first,y=a[m-1-i].second;
        --x,--y;
        if(!tree.same(x,y))ans[m-1-i]=tree.size(x)*tree.size(y);
        else ans[m-1-i]=0;
        tree.merge(x,y);
    }
    ll sum=n*(n-1)/2;
    ans[m]=0;
    rep(0,i,m){
        ans[m-1-i]+=ans[m-i];
    }
    rep(0,i,m){
        ans[i+1]=sum-ans[i+1];
        cout<<ans[i+1]<<endl;
    }
}

Measured memory_bytes: 5248
import java.util.Scanner;

class Main{
    
    public static void main(String[] args){
        
        Scanner sc =new Scanner(System.in);
        
        int n=sc.nextInt();
        
        int card[][]=new int[4][14];

        for(int i=0;i<n;i++){
        	
        String a =sc.next();
        int b =sc.nextInt();
        
        switch(a) {
        
        case "S":
        card[0][b]=1; break;
        case "H":
        card[1][b]=1; break;
        case "C":
        card[2][b]=1; break;
        case "D":
        card[3][b]=1; break;
        }
        
        }
        
        for(int i=0;i<4;i++) {
        for(int j=1;j<=13;j++)
    
         if (card[i][j]==0)       	
          switch(i) {         
           case 0:
           System.out.println("S "+j); break;
           case 1:
           System.out.println("H "+j);; break;
           case 2:
           System.out.println("C "+j);; break;
           case 3:
           System.out.println("D "+j);; break;
            }
        }
        
    }
}


Measured memory_bytes: 26440
package main

import(
	"fmt"
	"math"
)

func main() {
	var n int
	fmt.Scan(&n)
	l := make([]int,n)
	for i := 0; i < n; i++ {
		fmt.Scan(&l[i])
	}

	cnt := 0
	for i := 0; i < n-2; i++ {
		for j := i+1; j < n-1; j++ {
			for k := j+1; k < n; k++ {
				if l[i] != l[j] && l[j] != l[k] && l[i] != l[k] {
					if int(math.Abs(float64(l[i]-l[j]))) < l[k] && l[k] < l[i]+l[j] {
						cnt++
					}
				}
			}
		}
	}
	fmt.Println(cnt)
}

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

int main()
{
    ll n;
    cin >> n;
    vector<ll> x(n);
    rep(i, n) cin >> x[i];
    vector<ll> sum(100);
    repl(p, 1, 101) {
        rep(i, n) {
            sum[p - 1] += (x[i] - p) * (x[i] - p);
        }
    }
    ll mini = 100100100;
    rep(i, 100) {
        mini = min(sum[i], mini);
    }
    cout << mini << endl;
    return 0;
}

Measured memory_bytes: 256
n = int(input())
xa = 0
by = 0
ba = 0
counter = 0
for _ in range(n):
  s = input()
  counter += s.count('AB')
  if s[0]=='B':
    if s[-1]=='A':
      ba += 1
    else:
      by += 1
  elif s[-1] == 'A':
    xa += 1
if ba == 0:
  counter += min(xa,by)
else:
  if xa+by== 0:
    counter += ba -1
  else:
    counter += ba + min(xa,by)
print(counter)

Measured memory_bytes: 9192
#include<cstdio>
#include<cstdlib>
#include<iostream>
using namespace std;
int n,m,a,b,f[100002];
bool fa[100002];

void find(int x)
{
	if (f[x]!=x)
	  {
	  	find(f[x]);
	  	f[x]=f[f[x]];
	  }
	  return;
 } 

int main()
{
	scanf("%d%d",&n,&m);
	for (int i=1; i<=n; i++) f[i]=i;
	for (int i=1; i<=m; i++)
	 {
	 	scanf("%d%d",&a,&b);
	 	find(a); find(b);
	 	if (f[a]!=f[b]) f[f[b]]=f[a];
	 }
	 int ans=0;
	for (int i=1; i<=n; i++) find(i);
	for (int i=1; i<=n; i++)
	{
	 if (fa[f[i]]==0) 
	 {ans++;
	  fa[f[i]]=1;
	 }
}
	 ans--;
	printf("%d",ans); 
	return 0;
 } 

Measured memory_bytes: 4316
#include <stdio.h>
int main(void)
{
    char a[5]={};
    scanf("%s",a);
    if(a[0]==a[1]&&a[1]==a[2])printf("Yes");
    else if(a[1]==a[2]&&a[2]==a[3])printf("Yes");
    else printf("No");
}

Measured memory_bytes: 128
n = [int(i) for i in input().split()]
if n[1] == 100 and n[0] == 0:
    print(101)
elif n[1] == 100 and n[0] == 1:
    print(10100)
elif n[1] == 100 and n[0] == 2:
    print(1010000)
elif n[0] == 0:
    print(n[1])

elif n[0] == 1:
    print(100*n[1])
elif n[0] == 2:
    print(10000*n[1])


Measured memory_bytes: 3064
#include <iostream>
#include <vector>
#include <list>
#include<utility>
#include <new>
#include <string>
#include<cmath>
#include<unordered_set>
#include<iomanip>
#include <stack>
#include<queue>
#include<algorithm>
#include<bits/stdc++.h>
using namespace std;
#define loop(i,x,z) for (int i=x;i<z;i++)
using ll =  long long int;
/*bool cmp(pair<ll,ll>a,pair<ll,ll>b){
return a.second<b.second;
}*/
int main()
{int n;
	cin >> n;
	set<int>c;
	int ans=0;
	if(n==1||n==7){
        cout<<"1";
        return 0;
	}
	int num=7;
	while(num){
        num=(num*10+7)%n;
        ans++;
        if(c.find(num)!=c.end()){
            cout<<"-1";
            return 0;
        }
        c.insert(num);
	}
cout<<ans+1;
	return 0;
}


Measured memory_bytes: 50392
#include <stdio.h>
#define CARDS_MAX 5000

short a,b,A[CARDS_MAX],B[CARDS_MAX];

int main(void){
	int i,j,k,m,n,t;
	scanf("%hd%hd",&a,&b);
	i = 0;
	while(i<a)scanf("%hd",A+i++);
	i = 0;
	while(i<b)scanf("%hd",B+i++);	
	i = 0;
	m = 0;
	while(i < b){
		n = 0;
		j = 0;
		k = i;
		while(j < a){
			if(A[j] == B[k])k++,n++;
			j++;
		}
		if(m < n)m = n;
		i++;
	}
	printf("%d\n",m);
	return 0;
}

Measured memory_bytes: 616
N = int(input())
A = list(map(int,input().split()))
B = list(map(int,input().split()))
C = list(map(int,input().split()))
ans = B[A[0]-1]
for i in range(1,N):
  ans += B[A[i]-1]
  if A[i-1] + 1 == A[i]:
    ans += C[A[i-1]-1]
print(ans)


Measured memory_bytes: 3064
#include <iostream>
using namespace std; typedef long long ll; typedef pair<ll,ll> P; const ll INF = 1e15;
void nx(int n, int w[]) {
  int mx[n]; fill(mx,mx+n,0); mx[0]=w[0];
  for(int i=1;i<n;i++) mx[i]=max(mx[i-1], w[i]);
  int l=n-1;
  while(l>0) {
    if (mx[l-1]+1>=w[l]+1) {
      w[l]++; l++;
      for(int i=l;i<n;i++) w[i]=0;
      break;
    }
    else l--;
  }
  //cout<<"Ok"<<endl;
}
int main() {
  int n; cin>>n;
  int w[n]; fill(w,w+n,0);
  while(true) {
    for(int i=0;i<n;i++) {
      cout<<(char)('a'+w[i]);
    } cout<<endl;
    bool ed = true;
    for(int i=0;i<n;i++) {
      if (w[i] != i) ed = false;
    }
    if (ed) break;
    nx(n, w);
  }
}

Measured memory_bytes: 1536
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef vector<vvll> vvvll;
typedef vector<string> vstr;
typedef pair<ll, ll> pll;
typedef vector<pll> vp;
typedef map<string, ll> mstrll;
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define fir first
#define sec second
#define maxs(x, y) (x = max(x, y))
#define mins(x, y) (x = min(x, y))
#define all(x) begin(x), end(x)
#define rall(x) rbegin(x), rend(x)
#define _overload3(_1, _2, _3, name, ...) name
#define _rep(i, n) repi(i, 0, n)
#define repi(i, a, b) for(ll i = ll(a); i < ll(b); i++)
#define rep(...) _overload3(__VA_ARGS__, repi, _rep,)(__VA_ARGS__)
#define each(i, n) for(auto&& i: n)
#define out(x) cout << (x)
#define print(x) cout << (x) << '\n'
#define debug(x) cerr << #x << ": " << (x) << '\n'
ll gcd(ll a, ll b){return b != 0 ? gcd(b, a % b) : a;}
ll lcm(ll a, ll b){return a * b / gcd(a, b);}
const ll INF = 1e16;
const ll MOD = 1e9 + 7;
ll a, b, c, n, m, x, y, z, w, h, ans, cnt, mx, mn;
string s, t;
vll dx = {-1, 0, 1, 0}, dy = {0, -1, 0, 1};
//vll dx = {-1, 0, 1, -1, 1, -1, 0, 1}, dy = {-1, -1, -1, 0, 0, 1, 1, 1};
bool graph[50][50], visited[50];

void dfs(ll v){
    visited[v] = true;
    rep(i, n){
        if(visited[i]){
            continue;
        }else if(graph[v][i]){
            dfs(i);
        }
    }
}

signed main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    while(cin >> n >> m){
        ll a[m], b[m];
        ans = 0;
        rep(i, m){
            cin >> a[i] >> b[i];
            a[i]--, b[i]--;
            graph[a[i]][b[i]] = graph[b[i]][a[i]] = true;
        }
        rep(i, m){
            graph[a[i]][b[i]] = graph[b[i]][a[i]] = false;
            rep(j, n){
                visited[j] = false;
            }
            dfs(0);
            bool flag = false;
            rep(i, n){
                if(visited[i] == false){
                    flag = true;
                    break;
                }
            }
            if(flag){
                ans++;
            }
            graph[a[i]][b[i]] = graph[b[i]][a[i]] = true;
        }
        print(ans);
    }
}



Measured memory_bytes: 256
n, k = map(int, input().split())
A = list(map(int, input().split()))
B = [(1+i)/2 for i in A]
ans = sum(B[:k])
t = ans
for i in range(n-k):
    t-=B[i]
    t+=B[i+k]
    if t>ans: ans=t
print(ans)


Measured memory_bytes: 25060
#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 tlll=tuple<ll,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(ll i=(n)-1;i>=0;i--)
#define range(i,a,n) for(ll 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 T>bool chmax(T&a,T b){if(a<b){a=b; return true;}return false;}
template<class T>bool chmin(T&a,T b){if(a>b){a=b; return true;}return false;}
template<class S>S sum(vector<S>&a){return accumulate(all(a),S());}
template<class S>S max(vector<S>&a){return *max_element(all(a));}
template<class S>S min(vector<S>&a){return *min_element(all(a));}
ll max(int a,ll b){return max((ll)a,b);} ll max(ll a,int b){return max(a,(ll)b);}

template<class T>void puta(T&&t){cout<<t<<"\n";}
template<class H,class...T>void puta(H&&h,T&&...t){cout<<h<<' ';puta(t...);}
template<class S,class T>void tf(bool b,S t,T f){if(b)puta(t);else puta(f);}
void YN(bool b){tf(b,"YES","NO");}
void Yn(bool b){tf(b,"Yes","No");}
void yn(bool b){tf(b,"yes","no");}
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 S>auto&operator>>(istream&is,vector<S>&t){for(S&a:t)cin>>a;return is;}

/*他のライブラリを入れる場所*/


int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	ll n,m;
	cin>>n>>m;
	puta(m==1?0:n-m);
	return 0;
}

Measured memory_bytes: 764
import System.Exit
import Control.Applicative
import Control.Monad

main = do
    ln <- getLine
    case (head ln) of
        '-' -> exitSuccess
        _   -> solve ln
    main

solve :: String -> IO ()
solve ln = do
    x  <- (read :: String -> Int) <$> getLine
    ns <- replicateM x getLine
    let nss = map read ns :: [Int]
     in putStrLn $ helper ln nss
    where
        helper :: String -> [Int] -> String
        helper ln [] = ln
        helper ln (x:xs) = let (an, bn) = splitAt x ln
                            in helper (bn ++ an) xs


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

#define el '\n'

typedef long long ll;

int n;

ll d;

int x;

ll a[10000];

ll tong;

void input()
{
    cin>>n>>d>>x;
    for (int i=0;i<n;i++)
    {
        cin>>a[i];
        tong = tong + d/a[i]+1;
        if (d%a[i]==0) tong--;
    }
    cout<<tong+x;

}

int main ()
{
    ios_base::sync_with_stdio(0);
    //freopen("2.inp","r",stdin);
    //freopen("2.out","w",stdout);
    input();
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii = pair<int, int>;

const int INF = 1 << 30;
int n, m;
int a[55], b[55];
int dp[55][55][55][55][2][3];
bool used[55][55][55][55][2][3];

int dfs(int da, int db, int sa, int sb, int turn, int pass, int pa, int pb) {
  if (pass == 2) return 0;
  if (used[da][db][sa][sb][turn][pass]) return dp[da][db][sa][sb][turn][pass];
  int res;
  if (turn == 0) {
    res = -INF;
    if (da < n) {
      if (a[da] != -1) res = max(res, dfs(da+1, db, sa+1, sb, !turn, 0, pa+a[da], pb));
      else res = max(res, dfs(da+1, db, sa+1, sb, !turn, 0, pa, 0));
    }
    if (sa == 0 && sb == 0) {
      res = max(res, dfs(da, db, 0, 0, !turn, pass+1, 0, 0));
    } else {
      res = max(res, dfs(da, db, 0, 0, !turn, 0, 0, 0) + pa - pb);
    }
  } else {
    res = INF;
    if (db < m) {
      if (b[db] != -1) res = min(res, dfs(da, db+1, sa, sb+1, !turn, 0, pa, pb+b[db]));
      else res = min(res, dfs(da, db+1, sa, sb+1, !turn, 0, 0, pb));
    }
    if (sa == 0 && sb == 0) {
      res = min(res, dfs(da, db, 0, 0, !turn, pass+1, 0, 0));
    } else {
      res = min(res, dfs(da, db, 0, 0, !turn, 0, 0, 0) + pa - pb);
    }
  }
  used[da][db][sa][sb][turn][pass] = true;
  return dp[da][db][sa][sb][turn][pass] = res;
}

int main() {
  cin.tie(0);
  ios_base::sync_with_stdio(false);
  cout << fixed << setprecision(10);
  
  cin >> n >> m;
  for (int i = 0; i < n; i++) {
    cin >> a[i];
  }
  for (int i = 0; i < m; i++) {
    cin >> b[i];
  }
  cout << dfs(0, 0, 0, 0, 0, 0, 0, 0) << endl;

  return 0;
}


Measured memory_bytes: 96456