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

#define rep(i, j) for (int i = 0; i < j; i++)
#define all(obj) (obj).begin(), (obj).end()
#define rall(obj) (obj).rbegin(), (obj).rend()
typedef long long int ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<vi> vvi;

template<class T,class U> void chmax(T& a, U b) {if(a<b)a=b;}
template<class T,class U> void chmin(T& a ,U b) {if(b<a)a=b;}

vector<int> edges[10000];

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.precision(10);
    cout << fixed;

    int n;
    cin >> n;
    vector<pii> ab(n - 1);
    rep(i, n - 1) {
        int a, b;
        cin >> a >> b;
        a--, b--;
        ab[i].first = a;
        ab[i].second = b;
        edges[a].push_back(b);
        edges[b].push_back(a);
    }
    vi c(n);
    rep(i, n) {
        cin >> c[i];
    }
    sort(rall(c));

    vi d(n, -1);
    deque<int> deq;
    deq.push_back(0);
    ll ans = 0;
    int idx = 0;
    while(!deq.empty()) {
        int u = deq.front(); deq.pop_front();
        if (d[u] >= 0) continue;
        d[u] = c[idx++];
        for(auto v : edges[u]) {
            if (d[v] >= 0) continue;
            deq.push_back(v);
        }
    }

    rep(i, n - 1) {
        ans += min(d[ab[i].first], d[ab[i].second]);
        // cout << ab[i].first << " " << ab[i].second << endl;
    }

    cout << ans << endl;
    rep(i, n) {
        cout << d[i] << " ";
    }
    cout << endl;


    return 0;
}


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

int main(){
  int H,W;
  while(1){
    cin >> H >> W;
    if (H == 0 && W == 0){
      break;
    }else{
      for (int i = 0; i < H; i++){
        for (int j = 0; j < W; j++){
          cout << "#";
        }
        puts("");
      }
      puts("");
    }
  }
  return 0;
}



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

int main() {
    int n, q; cin >> n >> q;
    string s; cin >> s;
    vector<int>l(q);
    vector<int>r(q);
    rep(i,q){
        int li, ri; cin >> li >> ri; li--; ri--;
        l[i] = li; r[i] = ri;
    }
    
    vector<int> cnt(n,0);
    int c = 0;
    rep(i,n-1){
        if(s[i] == 'A' && s[i+1] == 'C') c++;
        cnt[i+1] = c;
    }
    rep(i,q){
        cout << cnt[r[i]] - cnt[l[i]] << endl;
    }
}


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

#define ll long long

int main() {
    ll N;
    ll A[200005];
    ll cnt[200005];
    memset(cnt, 0, sizeof(cnt));

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

    ll ans = 0;
    for(int i = 0; i < N; i++) {
        if(cnt[i] > 1) {
            ans += (cnt[i]) * (cnt[i] - 1) / 2;
        }
    }
    for(int i = 0; i < N; i++) {
        cout << ans - (cnt[A[i]] - 1) << endl;
    }
}

Measured memory_bytes: 5760
#include<bits/stdc++.h>
typedef long long ll;
typedef unsigned long long ull;
using namespace std;
#define pb push_back
int dy[]={0, 0, 1, -1, 0};
int dx[]={1, -1, 0, 0, 0};
 
#define FOR(i,a,b) for (int i=(a);i<(b);i++)
#define RFOR(i,a,b) for (int i=(b)-1;i>=(a);i--)
#define REP(i,n) for (int i=0;i<(n);i++)
#define RREP(i,n) for (int i=(n)-1;i>=0;i--)

int main(){
    int n;
    ll m = 100000;
    scanf("%d",&n);

    REP(i,n){
        ll l = m * 5 / 100;
        m += l;
        m = (m + 999) / 1000 * 1000;
    }
    printf("%lld\n",m);
    return 0;
}

Measured memory_bytes: 3176
N = int(input())
D = list(map(int, input().split()))

fq = [0] * (N + 10)

for d in D:
    fq[d] += 1

if not (D[0] == 0 and fq[0] == 1):
    print(0)
    exit()

ans = 1
for i in range(2, N+1):
    ans = (ans * (fq[i-1] ** fq[i] % 998244353)) % 998244353

print(ans)

Measured memory_bytes: 13908
#include <iostream>

using namespace std;
typedef long long ll;
int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);

    int a,b,c;
    cin>>a>>b>>c;
    if(a==5&&b==5&&c==7) cout<<"YES";
     else if(a==7&&b==5&&c==5) cout<<"YES";
    else  if(a==5&&b==7&&c==5) cout<<"YES";
      else cout<<"NO";

}


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

int main()
{
	ll N;
	cin >> N;
	
	ll best = 1;
	for (ll f = sqrt(N); f > 1; --f)
	{
		if (N % f == 0)
		{
			best = f;
			break;
		}
	}
	cout << best + N / best - 2 << '\n';
}


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

using namespace std;


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

	if (a <= 8 && b <= 8) {
		printf("Yay!");
	}
	else {
		printf(":(");
	}
}

Measured memory_bytes: 256
#include <stdio.h>

int main(void){
  int a, b, c, d, n, count;

  while(scanf("%d", &n) != EOF){
    count = 0;
    if(n < 37){
      for(a = 0; a < 10; a++){
        for(b = 0; b < 10; b++){
          for(c = 0; c < 10; c++){
            for(d = 0; d < 10; d++){
              if(a+b+c+d > n)  break;
              if(a+b+c+d == n)  count++;
            }
          }
        }
      }
    }
    printf("%d\n", count);
  }
  return 0;
}

Measured memory_bytes: 596
#include <bits/stdc++.h>
using namespace std;
#define IOS ios::sync_with_stdio(false); cin.tie(0);
#define FOR(i,s,n) for(int i = s; i < (n); i++)
#define REP(i,n) FOR(i,0,n)
#define ALL(n) (n).begin(), (n).end()
#define RALL(n) (n).rbegin(), (n).rend()
#define ATYN(n) cout << ( (n) ? "Yes":"No") << '\n';
#define CFYN(n) cout << ( (n) ? "YES":"NO") << '\n';
#define OUT(n) cout << (n) << '\n';
using ll = long long;
using ull = unsigned long long;
using pii = pair<int,int>;
using pll = pair<ll,ll>;

constexpr int MOD = 1000000007;

int mod(const ll &x){
    return x > 0 ? x % MOD : (x+MOD) % MOD;
}

int modm(const ll &x,const ll &m){
    return (x % MOD) * (m % MOD) % MOD;
}

int modpow(ll x, ll p) {
    int ret = 1;
    while(p > 0) {
        if (p & 1) ret = modm(ret,x);
        x = modm(x,x);
        p >>= 1;
    }
    return ret;
}

// x * modinv(d)
int modd(ll x,ll d) {
    return modm(x,modpow(d,MOD-2));
}

int main(void)
{
    IOS
    constexpr int N = 1000000;
    vector<int> prime;
    vector<bool> erato(N+5);
    FOR(i,2,N+1) {
        if (erato[i]) continue;
        prime.push_back(i);
        for(int j = 1; i * j <= N; j++) erato[i*j] = true;
    }

    int n; cin >> n;
    vector<int> v(n);
    map<int,int> mp;
    REP(i,n) {
        cin >> v[i];
        map<int,int> tmp;
        int t = v[i];
        for(auto x:prime) {
            if (t == 1 || x * x > v[i]) break;
            while(t % x == 0) {
                tmp[x]++;
                t /= x;
            }
        }
        if (t != 1) tmp[t]++;
        for(auto x:tmp) {
            mp[x.first] = max(mp[x.first],x.second);
        }
    }

    int l = 1;
    for(auto x:mp) {
        l = modm(l,modpow(x.first,x.second));
    }

    int ans = 0;
    REP(i,n) {
        ans = mod(ans + modd(l,v[i]));
    }

    cout << ans << '\n';


    return 0;
}


Measured memory_bytes: 1144
#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>;

int main()
{
    double L;
    cin >> L;

    double ans = (L / 3.0) * (L / 3.0) * (L / 3.0); 
    
    cout << fixed << setprecision(15) << ans << endl;

    return 0;
}

Measured memory_bytes: 3764
N = int(input())
A = list(map(int, input().split()))
A.sort()
A.reverse()
ans = 1
flg = 0
if A[-1] == 0:
    print(0)
else:
    for i in range(N):
        ans = ans * A[i]
        if ans > 10**18:
            flg = 1
            break


    if flg == 1:
        print(-1)
    else:
        print(ans)

Measured memory_bytes: 84640
#include<stdio.h>
int main() {
	char a, b, c;
	int x = 0;
	scanf("%c%c%c", &a, &b, &c);
	if (b == 'R') {
		x++;
		if (a == 'R') {
			x++;
		}
		if (c == 'R') {
			x++;
		}
	}else {
		if (a == 'R') {
			x++;
		}else {
			if (c == 'R') {
				x++;
			}
		}
	}
	printf("%d\n", x);
}

Measured memory_bytes: 1672
#include <algorithm>
#include <iostream>
#include <map>
#include <numeric>
#include <set>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>
#include <queue>
#define MOD (1000000007l)
#define rep(i, n) for(long i = 0; i < n; i++)

using namespace std;

void solve() {
  string s;
  cin >> s;
  string foo = s.substr(0, 4);
  string bar = s.substr(4, 8);
  cout << foo << " " << bar << endl;
}

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


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
long long gcd(long long a,long long b)
{
    if (a%b==0) return(b);
    else return(gcd(b,a%b));
}
 long long lcm(long long a,long long b){
 long long g = gcd(a,b);
 return a / g * b; 
 }
int main(void){
    int n; cin>>n;
    vector <long long> nums(n);
    for(int i=0;i<n;i++){
    cin>>nums[i];
    }
    if(n==1) {cout<<nums[0]<<endl; return 0;}
    long long tmp=nums[0];
    for(int i=0;i<n-1;i++){
        
        tmp=lcm(tmp,nums[i+1]);
    }
    cout<<tmp<<endl;
}

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

int main( void )
{
  int N, M, A, B;
  cin >> N >> M;
  
  vector<int> ans( N );

  for( int i = 0; i < M; i++ ) {
    cin >> A >> B;
    ans.at( A - 1 )++;
    ans.at( B - 1 )++;
  }

 for( int i = 0; i < N; i++ )
   cout << ans.at( i ) << endl;
}

Measured memory_bytes: 3604
#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
LL dp[10][12]; //dp[i][j]代表以i开头的j位数有多少个lun number 
LL k, ans[12]; //ans[i]表示i位lun number的个数
int bit;

void dfs(int num, int lst) {
	if(num > bit) return ;
	if(num == 1) { //第一位直接枚举1 ~ 9
		for(int i = 1; i <= 9; i++) {
			if(k > dp[i][bit - num + 1]) k -= dp[i][bit - num + 1];
			else {
				cout << i;
				dfs(num + 1, i);
				break;
			}
		}
	}
	else {
		for(int i = lst - 1; i <= lst + 1; i++) {
			if(i < 0 || i > 9) continue;
			if(k > dp[i][bit - num + 1]) k -= dp[i][bit - num + 1];
			else {
				cout << i;
				dfs(num + 1, i);
				break;
			}
		}
	}
}

int main() {
	cin >> k;
	for(int i = 0; i < 10; i++) dp[i][1] = 1;
	ans[1] = 9LL;
	for(int j = 2; j <= 10; j++) { //位数:2 ~ 10
		for(int i = 0; i < 10; i++) { //最高位:0 ~ 9
			if(i == 0) dp[i][j] = dp[i][j - 1] + dp[i + 1][j - 1];
			//最高位i = 0时的j位数只能以i和i + 1作最高位的j - 1位数作为后缀
			else if(i == 9) dp[i][j] = dp[i - 1][j - 1] + dp[i][j - 1];
			//最高位i = 9时的j位数只能以i - 1和i作最高位的j - 1位数作为后缀
			else dp[i][j] = dp[i - 1][j - 1] + dp[i][j - 1] + dp[i + 1][j - 1]; 
			//最高位非0非9时, 以i - 1、i本身、i + 1作最高位的j - 1位数均可作为最高位是i的j位数的后缀
			if(i) ans[j] += dp[i][j]; //没有前导0时就将dp[i][j]表示的个数存入ans[j]
		}
	}
	for(int i = 1; i <= 20; i++) {
		if(k > ans[i]) k -= ans[i];
		else {
			bit = i; //所求转化为:位数为bit位的所有数中的第k小的那个(将当前k定位在bit位)
			break;
		}
	}
	dfs(1, 0);
	cout << endl;
	return 0;
}

/*
<-- 数位dp + 构造 -->
设dp[i][j]表示最高位是i, 位数是j的lun number的个数
根据极限样例, j最多为10位, i在0 ~ 9
首先初始化所有dp[i][1] = 1 (以i开头的一位数就是i本身, 只有1个)
转移方程3种情况:
1) dp[i][j] = dp[i][j - 1] + dp[i + 1][j - 1];
//最高位i = 0时的j位数只能以i和i + 1作最高位的j - 1位数作为后缀
2) dp[i][j] = dp[i - 1][j - 1] + dp[i][j - 1];
//最高位i = 9时的j位数只能以i - 1和i作最高位的j - 1位数作为后缀
3) dp[i][j] = dp[i - 1][j - 1] + dp[i][j - 1] + dp[i + 1][j - 1]; 
//最高位非0非9时, 以i - 1、i本身、i + 1作最高位的j - 1位数均可作为最高位是i的j位数的后缀

接下来进行构造:
首先定位第k小的lun number的位数bit
统计所有i位数中有多少lun number, 做一遍前缀和存进ans[i]
从低位向高位遍历, 找到第一个大于等于k的位数即为k的位数bit

确定好位数之后, 开始枚举每一位是什么
如果是第一位, 我们暴力枚举1 ~ 9
用找位数同样的方法, 我们可一个确定第一个位置的数(我们记录了以i开头, 有j位的lun number有多少个)
然后后面的位置的数只有最多三种选择: 上次减一; 上次同样; 上次加一 (不能小于0或大于9)
然后记忆化搜所即可
*/

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

bitset<6> bh;
bitset<6> bw;

int main() {
    int H, W, K, c;
    cin >> H >> W >> K;
    vector<vector<char>> M(H, vector<char>(W));
    for (int i = 0; i < H; i++) {
        for (int j = 0; j < W; j++) {
            cin >> M[i][j];
        }
    }

    int ans = 0;
    for (int bi = 0; bi < 1 << H; bi++) {
        bh = bi;
        for (int bj = 0; bj < 1 << W; bj++) {
            bw = bj;

            c = 0;
            for (int i = 0; i < H; i++) {
                for (int j = 0; j < W; j++) {
                    if (bh.test(i) & bw.test(j) & (M[i][j]=='#')) {
                        c++;
                    }
                }
            }
            if (c == K) {
                ans++;
            }
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 3636
//include
//------------------------------------------
#include <vector>
#include <list>
#include <map>
#include <climits>
#include <set>
#include <deque>
#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>
#include <queue>
#include <random>
#include <complex>
#include <regex>

using namespace std;

#define SHOW_VECTOR(v) {std::cerr << #v << "\t:";for(const auto& xxx : v){std::cerr << xxx << " ";}std::cerr << "\n";}
#define SHOW_MAP(v){std::cerr << #v << endl; for(const auto& xxx: v){std::cerr << xxx.first << " " << xxx.second << "\n";}}

int main() {

    int n;
    cin >> n;

    vector<long long> a(n), b(n);
    for (auto &x : a) cin >> x;
    for (auto &x : b) cin >> x;

    long long sum_a = accumulate(a.begin(), a.end(), 0LL);
    long long sum_b = accumulate(b.begin(), b.end(), 0LL);

    long long diff = 0;
    for (int i = 0; i < n; i++) diff += max(0LL, -(b[i] - a[i]));
    long long plus = 0;
    for (int i = 0; i < n; i++) {
        if (b[i] >= a[i]) {
            plus += (b[i] - a[i]) / 2;
            plus += (b[i] - a[i]) % 2;
        }
    }

    long long sum_ab = sum_b - sum_a;
    if (sum_ab >= diff && sum_ab >= 0 && plus <= sum_ab) cout << "Yes" << endl;
    else cout << "No" << endl;

}

































Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
struct edge {
    int to;     // 辺の行き先
    int weight; // 辺の重み
    edge(int t, int w) : to(t), weight(w) { }
};
using Graph = vector<vector<int>>;
using dou =long double;
string Yes="Yes";
string YES="YES";
string NO="NO";
string No="No";
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 rep(i, n)         for(int i = 0; i < (int)(n); i++)
#define brep(n)           for(int bit=0;bit<(1<<n);bit++)
#define erep(i,container) for (auto i : container)
#define irep(i, n)        for(int i = n-1; i >= (int)0; i--)
#define rrep(i,m,n) for(int i = m; i < (int)(n); i++)
#define reprep(i,j,h,w) rep(i,h)rep(j,w)
#define all(x) (x).begin(),(x).end()
#define aall(x,n) (x).begin(),(x).begin()+(n)
#define VEC(type,name,n) std::vector<type> name(n);rep(i,n)std::cin >> name[i];
#define pb push_back
#define pf push_front
#define lb lower_bound
#define ub upper_bound
#define res resize
#define as assign
#define fi first
#define se second
#define itn int
#define mp make_pair
#define sum(a) accumulate(all(a),0ll)
#define keta fixed<<setprecision
#define vvector(name,typ,m,n,a)vector<vector<typ> > name(m,vector<typ> (n,a))
#define vvvector(name,t,l,m,n,a) vector<vector<vector<t> > > name(l, vector<vector<t> >(m, vector<t>(n,a)));
#define vvvvector(name,t,k,l,m,n,a) vector<vector<vector<vector<t> > > > name(k,vector<vector<vector<t> > >(l, vector<vector<t> >(m, vector<t>(n,a)) ));
 
typedef long long ll;
//typedef long long T;
const int INF = 2000000000;
const ll INF64 = 922337203685477580ll;
const int mod = 1000000007ll;
const ll  MOD = 1000000007LL;

int main(){
    string s;
    std::cin >> s;
    string a="keyence";
    int c=0;
    rep(i,7){
        if(a[i]==s[i])c++;
        else break;
    }
    rep(i,7){
        if(a[6-i]==s[s.size()-1-i])c++;
        else break;
    }
    if(c>=7)std::cout << YES << std::endl;
    else std::cout << NO << std::endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
typedef long long int ll;
using namespace std;
int main(){
	ios_base::sync_with_stdio(false);  
	cin.tie(NULL);
	ll n,a,b;cin>>n>>a>>b;
	ll ans = a*(n/(a+b));
	ans += min(a,n%(a+b));
	cout<<ans<<endl;
}


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

#define gcd(a,b)		__gcd(a,b)
#define lcm(a,b)		(a*b)/gcd(a,b)
#define ff              first
#define ss              second
#define int             long long
#define float			double
#define pb              emplace_back
#define mp              make_pair
#define pii             pair<int,int>
#define vi              vector<int>
#define vc				vector<char>
#define vb				vector<bool>
#define vf				vector<float>
#define vs				vector<string>
#define mii             map<int,int>
#define pqb             priority_queue<int>
#define pqs             priority_queue<int,vi,greater<int>>
#define hashmap         unordered_map
#define setbits(x)      __builtin_popcountll(x)
#define zrobits(x)      __builtin_ctzll(x)
#define mod             1000000007
#define inf             INT64_MAX
#define ps(x,y)         fixed<<setprecision(y)<<x
#define mk(arr,n,type)  type *arr=new type[n];
#define w(x)            int x; cin>>x; while(x--)
#define all(x)			x.begin(),x.end()
#define digits(x)		floor(log10(x))+1
#define FIO				ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)

template<class T>
void printV(vector<T> a) {for (auto v : a)cout << v << " ";}
template<class T>
void readV(vector<T>& a) {int n = a.size(); for (int i = 0 ; i < n ; i++)cin >> a[i];}
template<class T>
void printA(T* a , int n) {for (int i = 0; i < n  ; i++)cout << a[i] << " ";}
template<class T>
void readA(T* a , int n) {for (int i = 0 ; i < n ; i++)cin >> a[i];}
auto clk = clock();
mt19937_64 rang(chrono::high_resolution_clock::now().time_since_epoch().count());
void run_time() {cout << endl<<"Time elapsed: " << (double)(clock() - clk) / CLOCKS_PER_SEC << endl;}

void aryan_pandeya() {
#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif
}


int32_t main() {
	aryan_pandeya();
	FIO;
 
	char x ; 
	cin>>x;
	char y = x+1;
	cout<<y;


	return 0;
}


Measured memory_bytes: 3632
n = int(input())
a = list(map(int, input().split()))
a.sort(reverse=True)
i = 0
x = 0
y = 0
while i < n-1:
    if x == 0:
        if a[i] == a[i+1]:
            x = a[i]
            i += 1
    elif y == 0:
        if a[i] == a[i+1]:
            y = a[i]
            i += 1
    i += 1
print(x*y)

Measured memory_bytes: 62704
#include <iostream>
#include <vector>
#include <string>
using namespace std;
//変数デバッグ
#define DEB(variable) cout << #variable << '=' << variable << endl

//for簡易表記(引数ミス防止)
#define FOR(LoopVariable,numberOFbegin,numberOFend) for (int LoopVariable = (numberOFbegin); (LoopVariable) < (numberOFend); (LoopVariable)++)
#define REP(LoopVariable,numberOFend) for(int LoopVariable = 0;(LoopVariable)<(numberOFend);LoopVariable++)

int main(){

    string a;
    cin >> a;
    
    int n;
    cin >> n;
    
    REP(i,n){
        if(a[i]!='1'){
            cout << a[i] << endl;
            return 0;
        }

    }

    cout << 1 << endl;

    return 0;
}

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

namespace Atcoder
{
    class Atcoderrrrrr
    {
        static void Main(string[] args)
        {
            string[] s = Console.ReadLine().Split(' ');
            int obj = int.Parse(s[0] + s[1]);

            string ans = "No";
            for (int i = 0; i <317; i++)
            {
                if(i * i == obj)
                {
                    ans = "Yes";
                    break;
                }
            }
            Console.WriteLine(ans);
        }
    }
}

Measured memory_bytes: 11092
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
using namespace std;
typedef long long ll;
typedef pair<int,int> pp;
const int INF = 1e9;
const int MOD = 1000000007;


int main(){
        int n;
        cin >> n;
        vector<vector<int>> Graph(n,vector<int>());
        rep(i,n){
                 int u,k;
                cin >>u >>k;
                --u;
                rep(j,k){
                         int p;
                        cin >> p;
                        --p;
                        Graph.at(u).push_back(p);
                }
        }
        
        vector<int> seen(n,-1);
        queue<int> q;
        q.push(0);
        seen.at(0) = 0;
        while(!q.empty()){
                int now = q.front();
                q.pop();
                for(int p:Graph.at(now)){
                        if(seen.at(p) >= 0) continue;
                        seen.at(p) = seen.at(now) + 1;
                        q.push(p);
                }
        }
        
        rep(i,n){
                 cout << i+1 << " " << seen.at(i) << endl;
        }                

        return 0;
}



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

namespace abc105_d
{
    class Program
    {
        static void Main(string[] args)
        {
            int[] x = Console.ReadLine().Split().Select(int.Parse).ToArray();
            int[] a = Console.ReadLine().Split().Select(int.Parse).ToArray();
            long sum = 0;
            Dictionary<long, long> dic = new Dictionary<long, long>();
            dic[0] = 1;
            for (int i = 0; i < x[0]; i++)
            {
                sum += a[i]; sum %= x[1];
                if (!dic.ContainsKey(sum)) dic[sum] = 0;
                dic[sum]++;
            }
            long ret = 0;
            foreach (var item in dic)
            {
                ret += item.Value * (item.Value - 1) / 2;
            }
            Console.WriteLine(ret);
        }
    }
}

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

namespace ABC053
{
    class ProblemB
    {
        static void Main(string[] args)
        {
            var sw = new System.IO.StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
            Console.SetOut(sw);

            string s = Console.ReadLine();

            int idxA = 200001;
            int idxZ = 0;
            for(int i = 0; i < s.Length; i++)
            {
                if (s[i] == 'A' & i < idxA) idxA = i;
                if (s[i] == 'Z' & i > idxZ ) idxZ = i;
            }

            string result = (idxZ - idxA + 1).ToString();
            Console.WriteLine(result);
               
            Console.Out.Flush();
        }
    }
}


Measured memory_bytes: 26436
#include<bits/stdc++.h>
using namespace std;
 
typedef    long long          ll;
typedef    vector<long long>    vi; 
typedef    vector<vi>         vvi; 
typedef    pair<long,long>      ii; 
#define    sz(a)              long((a).size()) 
#define    pb                 push_back 
#define    mp                   make_pair
#define    all(c)             (c).begin(),(c).end() 
#define    tr(c,i)            for(typeof((c).begin() i = (c).begin(); i != (c).end(); i++) 
#define    present(c,x)       ((c).find(x) != (c).end()) 
#define    cpresent(c,x)      (find(all(c),x) != (c).end())  
#define    input(v,n)           for(ll i = 0 ; i<n ; i++) cin>>v[i]
#define    output(v,n)          for(ll i = 0 ; i<n ; i++) cout<<v[i]<<" "

ll mod = 1e9 + 7;
 
ll dp[4000000];
ll a[22][22];

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


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

  dp[0]=1;

  for(i=0;i<(1<<n);i++)
  {
    for(j=0;j<n;j++)
    {
      if(((1<<j) & i))continue;
      
      ll p = __builtin_popcountll(i);
      if(a[j][p] == 1)
      {
        dp[((1<<j) | i)]+=dp[i];
        dp[((1<<j) | i)]%=mod;
      }
    }
  }

  cout<<dp[((1<<n) - 1)]<<"\n";


  return 0;
}


Measured memory_bytes: 18688
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n)   FOR(i,0,n)
#define pb emplace_back
typedef long long ll;
typedef pair<int,int> pint;

int n,k;
int v[51];
int main(){
    cin>>n>>k;
    rep(i,n) cin>>v[i];
    vector<ll> g;
    ll ans=0;
    rep(i,n+1){
        rep(j,n-i+1)if(i+j<=k){
            g.clear();
            ll scr=0;
            rep(l,i) g.pb(v[l]),scr+=v[l];
            rep(r,j) g.pb(v[n-1-r]),scr+=v[n-1-r];
            sort(g.begin(),g.end());
            rep(kk,min((int)g.size(),k-i-j)){
                if(g[kk]<0)scr-=g[kk];
            }
            ans=max(ans,scr);
        }
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include <cstdio>
#include <ctype.h>
#include <functional>
#include <iostream>
#include <cassert>
#include <cfloat>
#include <climits>
#include <complex>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <time.h>
#include <vector>
using namespace std;
typedef long long ull;

int main() {
	int N,T;
	cin>>N>>T;
	vector<int> A(N);
	int mini=1000000001;
	int maxi=-1;
	for (int i = 0; i < N; i++) {
		cin>>A[i];
		if(A[i]<mini){
			mini=A[i];
		}
		if(maxi<A[i]-mini){
			maxi=A[i]-mini;
		}
	}
	int res=0;
	bool f=false;
	mini=1000000001;
	for (int i = 0; i < N; i++) {
		if(A[i]<mini){
			if(f){
				res++;
			}
			mini=A[i];
			f=false;
		}
		if(A[i]-mini==maxi){
			f=true;
		}
	}
	if(f){
		res++;
	}
	cout << res << endl;
	
	return 0;
}

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

int main(){
	int N, X;
	cin >> N >> X;
	vector<int> L(N);
	for(int i = 0; i < N; i++){
		cin >> L.at(i);
	}
	
	int now = 0;
	int jump = 0;
	while(now <= X){
		now += L[jump];
		jump++;
		if(jump > N){
			break;
		}
	}
	cout << jump << endl;
}

Measured memory_bytes: 256
import sys

read = sys.stdin.buffer.read
input = sys.stdin.buffer.readline
inputs = sys.stdin.buffer.readlines


# mod=10**9+7
# rstrip().decode('utf-8')
# map(int,input().split())
#import numpy as np

def main():
	n,m=map(int,input().split())
	s=input().rstrip().decode('utf-8')
	t=s[::-1]
	
	ans=[]
	
	now=0
	while now<n:
		for i in range(min(m,n-now),0,-1):
			
			if t[now+i]=="0":
				now+=i
				ans.append(i)
				break
			else:
				continue
		else:
			print(-1)
			exit(0)
	
	print(*ans[::-1])
	
	
	
	
	
	
	



if __name__ == "__main__":
	main()


Measured memory_bytes: 50928
def slove():
    import sys
    input = sys.stdin.readline
    h, w = list(map(int, input().rstrip('\n').split()))
    cnt = 0
    for i in range(h):
        cnt += str(input().rstrip('\n')).count("#")
    print("Possible" if cnt == (h + w - 1) else "Impossible")


if __name__ == '__main__':
    slove()


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

#define int long long
#define rep(i, n) for (int i = 0; i < (int) (n); i++)
#define reps(i, n) for (int i = 1; i <= (int) (n); i++)
#define all(x) (x).begin(), (x).end()
#define uniq(x) (x).erase(unique(all(x)), (x).end())
#define bit(n) (1LL << (n))
#define dump(x) cerr << #x " = " << (x) << endl
using vint = vector<int>;
using vvint = vector<vint>;
using pint = pair<int, int>;
using vpint = vector<pint>;
template<typename T> using priority_queue_rev = priority_queue<T, vector<T>, greater<T>>;
constexpr double PI = 3.1415926535897932384626433832795028;
constexpr int DY[9] = {0, 1, 0, -1, 1, 1, -1, -1, 0};
constexpr int DX[9] = {1, 0, -1, 0, 1, -1, -1, 1, 0};
int sign(int x) { return (x > 0) - (x < 0); }
int gcd(int a, int b) {
    while (b) { swap(a %= b, b); }
    return a;
}
int lcm(int a, int b) { return a / gcd(a, b) * b; }
int cdiv(int a, int b) { return (a - 1 + b) / b; }
template<typename T> void fin(T mes) {
    cout << mes << endl;
    exit(0);
}
template<typename T> T sq(T x) { return x * x; }
template<typename T, typename U> bool chmax(T &a, const U &b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
template<typename T, typename U> bool chmin(T &a, const U &b) {
    if (b < a) {
        a = b;
        return true;
    }
    return false;
}
template<typename T, typename U> ostream &operator<<(ostream &os, const pair<T, U> &rhs) {
    os << "(" << rhs.first << ", " << rhs.second << ")";
    return os;
}
template<typename T> ostream &operator<<(ostream &os, const vector<T> &rhs) {
    os << "{";
    for (auto itr = rhs.begin(); itr != rhs.end(); itr++) {
        os << *itr << (next(itr) != rhs.end() ? ", " : "");
    }
    os << "}";
    return os;
}
template<typename T> ostream &operator<<(ostream &os, const deque<T> &rhs) {
    os << "{";
    for (auto itr = rhs.begin(); itr != rhs.end(); itr++) {
        os << *itr << (next(itr) != rhs.end() ? ", " : "");
    }
    os << "}";
    return os;
}
template<typename T> ostream &operator<<(ostream &os, const set<T> &rhs) {
    os << "{";
    for (auto itr = rhs.begin(); itr != rhs.end(); itr++) {
        os << *itr << (next(itr) != rhs.end() ? ", " : "");
    }
    os << "}";
    return os;
}
template<typename T> ostream &operator<<(ostream &os, const multiset<T> &rhs) {
    os << "{";
    for (auto itr = rhs.begin(); itr != rhs.end(); itr++) {
        os << *itr << (next(itr) != rhs.end() ? ", " : "");
    }
    os << "}";
    return os;
}
template<typename T, typename U> ostream &operator<<(ostream &os, const map<T, U> &rhs) {
    os << "{";
    for (auto itr = rhs.begin(); itr != rhs.end(); itr++) {
        os << *itr << (next(itr) != rhs.end() ? ", " : "");
    }
    os << "}";
    return os;
}
struct setup {
    static constexpr int PREC = 20;
    setup() {
        cout << fixed << setprecision(PREC);
        cerr << fixed << setprecision(PREC);
    };
} setup;

signed main() {
    int N;
    cin >> N;
    int ans = 0;
    reps(i, N) {
        ans += (N - 1) / i;
    }
    cout << ans << endl;
}



Measured memory_bytes: 3628
/*Bismillahir Rahmanir Rahim*///{
#include <bits/stdc++.h>
#include <ext/numeric>
using namespace std; using __gnu_cxx::power;
using ll = long long; using ull = unsigned long long; using ld = long double;
const ll llinf = (1ll<<61)-1; const double eps = 1e-6, ldeps = 1e-9;
struct Dbg { static constexpr auto &os = cout;   // replace by cerr in interactive.
template<class C> static auto o(C *x)->decltype(os << *x, 0);
template<class C> static char o(...);
template<class C> typename enable_if<sizeof o<C>(0)!=1,Dbg&>::type operator<<(const C &x) {os<<x; return *this;}
template<class C> Dbg &dump(C b, C e) {
    for (struct{C i;int j;} i={(*this<<"\n[",b),0}; i.i!=e and i.j<26; i.i++, i.j++) *this<<", "+2*(i.i==b)<<*i.i;
    return *this << ']';
}
template<class C> typename enable_if<sizeof o<C>(0)==1, Dbg&>::type operator<<(const C &x) {
    return dump(begin(x), end(x));
}
template<class C, size_t X> typename enable_if<!is_same<C, const char>::value, Dbg&>::type operator<<(C (&x)[X]) {
    return dump(begin(x), end(x));
}
template<class B, class C> Dbg &operator<<(const pair<B, C> &x) {return *this<<'{'<<x.first<<", "<<x.second<<'}';}
Dbg &operator<<(ostream&(*x)(std::ostream&)) { os << x; return *this; }
} dbg;
void err(istringstream *iss) { delete iss; }
template<class C, class... Args> void err(istringstream *iss, const C &val, const Args &... args) {
    string name; *iss >> name; if (name.back()==',') name.pop_back();
    dbg << name << " = " << val << "; ", err(iss, args...);
}
#define bug(args...) dbg << __LINE__ << ": ", err(new istringstream(#args), args), dbg << endl
#define cbug(a, args...) if (a) bug(args);
#define ASSERT(a, o, b, args...) if (!((a)o(b))) bug(a, b, ##args), assert((a)o(b));
#define sl(a) int(strlen(a))
#define sz(a) int(a.size())
int T, Q, cn;//}
const int inf = 1000000007, mxn = -1;
#define yes cout << "Yes\n"
#define no cout << "No\n"
#define YN(x) cout << ((x) ? "Yes\n" : "No\n")

signed main() { cin.tie(0)->sync_with_stdio(0); cin.exceptions(cin.failbit); cout.precision(11), cout.setf(ios::fixed);
    int x, y;
    cin >> x >> y;
    for (int i = 0; i <= x; i++) {
        if (i*2+(x-i)*4 == y) return yes, 0;
    }
    no;
}

Measured memory_bytes: 3648
#pragma region
#define _USE_MATH_DEFINES
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <cstdlib>
#include <vector>
#include <map>
#include <queue>
#include <stack>
#include <set>
#include <list>
#include <iomanip>
#include <cstdint>
#include <bitset>

using namespace std;
typedef long long ll;
//#define rep(i, s, e) for (int(i) = (s); (i) < (e); ++(i))
#define rep(i, e) for (int(i) = 0; (i) < (e); ++(i))
#define rrep(i, s) for (int(i) = (s) - 1; (i) >= 0; --(i))
#define all(x) x.begin(),x.end()

#pragma region UnionFind
struct UnionFind
{
	vector<int> par;

	UnionFind(int n) : par(n, -1) {}
	void init(int n) { par.assign(n, -1); }

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

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

	bool merge(int x, int y)
	{
		x = root(x); y = root(y);
		if (x == y) return false;
		if (par[x] > par[y]) swap(x, y);
		par[x] += par[y];
		par[y] = x;
		return true;
	}

	int size(int x)
	{
		return -par[root(x)];
	}
};
#pragma endregion
#pragma region GCD
ll gcd(ll a, ll b)
{
	if (b == 0)return a;
	return gcd(b, a%b);
}
#pragma endregion
#pragma region LCM
ll lcm(ll a, ll b)
{
	return a / gcd(a, b) * b;
}
#pragma endregion
#pragma region chmin
template<class T> inline bool chmin(T& a, T b)
{
	if (a > b)
	{
		a = b;
		return true;
	}
	return false;
}
#pragma endregion
#pragma region chmax
template<class T> inline bool chmax(T& a, T b)
{
	if (a < b)
	{
		a = b;
		return true;
	}
	return false;
}
#pragma endregion
#pragma endregion


int main()
{
	ll n; cin >> n;
	vector<ll> div;
	for (ll i = 2; i*i <= n; ++i)
	{
		if (n%i != 0)continue;
		div.push_back(i);
		if (n / i != i)div.push_back(n / i);
	}
	if (n != 1)div.push_back(n);
	ll res = 0;
	for (ll m : div)
	{
		--m;
		if (n / m == n % m)res += m;
	}
	cout << res << endl;
}

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

int main() {
    int N,K;
    cin >> N >> K;
    long long ans = K;
    for(int i = 1;i<=N-1;i++){
        ans *= K-1;
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
import java.util.*;

public class Main {
	public static void main(String[]args){
		
		Scanner sc = new Scanner(System.in);
		
		int x = sc.nextInt();
		
		int y = sc.nextInt();
		
		int[]a = new int[y];
		
		for (int i = 0;i < y; i++){
			a[i] = sc.nextInt();
		}
		
		Arrays.sort(a);
		
		System.out.println(Math.max(a[y-1]-(x-a[y-1])-1, 0));
		
		sc.close();
	}
}


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

int main()
{
	int A[21];
	int B[51];
	int C[51];
	int N;
	long long cnt = 0;

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

	for (int i = 0; i < N; i++)
	{
		cin >> B[i];
	}

	for (int i = 0; i < N-1; i++)
	{
		cin >> C[i];
	}

	for (int i = 0; i < N; i++)
	{
		cnt += B[A[i]-1];
		if (i != N - 1)
		{
			if (A[i + 1] == A[i] + 1)cnt += C[A[i]-1];
		}
	}

	cout << cnt << endl;
}

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

int main() {
  int a, b, c, d, l, r;
  cin >> a >> b >> c >> d;
  
  l = a+b;
  r = c+d;
  
  if(l > r){
    cout << "Left" << endl;
  }
  else if(l < r){
    cout << "Right" << endl;
  }
  else{
    cout << "Balanced" << endl;
  }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
using P = pair<ll,ll>;
const ll mod = 1e9+7;
#define ALL(x) (x).begin(),(x).end()
#define REP(i,n) for(ll (i)=0;(i)<(n);(i)++)
#define REPS(i,n) for(ll (i)=1;(i)<=(n);(i)++)
#define RREP(i,n) for(ll (i)=(n-1);(i)>=0;(i)--)
#define RREPS(i,n) for(ll (i)=(n);(i)>0;(i)--)
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define UNIQUE(v) v.erase(unique(ALL(v)),v.end());

template<class T> inline void chmin(T& a, T b){
    if (a > b){
        a = b;
    }
}

template<class T> inline void chmax(T& a, T b){
    if (a < b){
        a = b;
    }
}

/* modとる */
inline ll modu(ll a){
    return(a % mod + mod) % mod;
}

/* modつき二項係数 前処理必要*/
const ll binomialmax = 510000;
ll fac[binomialmax], finv[binomialmax], inv[binomialmax];

void cominit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (ll i = 2; i < binomialmax; i++){
        fac[i] = modu(fac[i - 1] * i);
        inv[i] = modu(-inv[mod % i] * (mod / i));
        finv[i] = modu(finv[i - 1] * inv[i]);
    }
}

/* 二項係数計算 */
ll com(ll n, ll k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return modu(fac[n] * (modu(finv[k] * finv[n - k])));
}

signed main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout<<fixed<<setprecision(10);
    cominit();
    int H,W,K;
    cin >> H >> W >> K;
    vector<vector<int>> num(H+50,vector<int>(W));
    num[0][0] = 1;
    vector<int> wi(W);
    REP(i,W){
        if(i <= 1){
            wi[i] = 1;
        }else if(i == 2){
            wi[i] = 2;
        }else if(i <= 5){
            wi[i] = com(i-1,2) + 2;
        }else if(i == 6){
            wi[i] = com(i-1,2) + 3;
        }else{
            wi[i] = com(i-1,2) + 6;
        }
    }
    REP(i,H){
        if(W == 1)break;
        REP(l,W){
            if(l == 0){
                num[i+1][l] = modu(num[i][l]*modu(wi[W-l-1]*wi[l]) + num[i][l+1]*modu(wi[W-l-2]*wi[l]));
            }else if(l == W-1){
                num[i+1][l] = modu(num[i][l]*modu(wi[W-l-1]*wi[l]) + num[i][l-1]*modu(wi[W-l-1]*wi[l-1]));
            }else{
                num[i+1][l] = modu(num[i][l]*modu(wi[W-l-1]*wi[l]) + num[i][l-1]*modu(wi[W-l-1]*wi[l-1]) + num[i][l+1]*modu(wi[W-l-2]*wi[l]));
            }
        }
    }
    if(W == 1){
        cout << 1 << "\n";
    }else{
        cout << num[H][K-1] << "\n";
    }
}

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

using ll = long long;

int main() {
    string S, T;
    cin >> S >> T;
    int n = S.size();
    vector<set<int>> a(26), b(26);
    rep(i, n) {
        a[S[i] - 'a'].insert(T[i] - 'a');
        b[T[i] - 'a'].insert(S[i] - 'a');
    }
    rep(i, 26) {
        if (a[i].size() > 1 || b[i].size() > 1) {
            cout << "No\n";
            return 0;
        }
    }
    cout << "Yes\n";
}

Measured memory_bytes: 904
import sys

read = sys.stdin.read
readline = sys.stdin.readline
readlines = sys.stdin.readlines
sys.setrecursionlimit(10 ** 9)
INF = 1 << 60
MOD = 1000000007


class BIT:
    def __init__(self, n):
        self.n = n
        self.data = [0] * (n + 1)

    def add(self, i, x=1):
        i += 1
        while i <= self.n:
            self.data[i] += x
            i += i & -i

    def get_sum(self, i):
        i += 1
        x = 0
        while i > 0:
            x += self.data[i]
            i -= i & -i
        return x

    # Return sum for [l, r)
    def get_sum_range(self, l, r):
        return self.get_sum(r - 1) - self.get_sum(l - 1)


def main():
    N = int(readline())
    S = readline().strip()
    Q = int(readline())
    query = [readline().split() for _ in range(Q)]

    bit = [BIT(N) for _ in range(26)]
    for i, c in enumerate(S):
        bit[ord(c) - ord('a')].add(i)

    S = list(S)
    ans = []

    for q in query:
        if q[0] == '1':
            i = int(q[1]) - 1
            c = q[2]
            bit[ord(S[i]) - ord('a')].add(i, -1)
            bit[ord(c) - ord('a')].add(i, 1)
            S[i] = c
        else:
            res = 0
            l, r = int(q[1]) - 1, int(q[2]) - 1
            for i in range(26):
                if bit[i].get_sum_range(l, r + 1):
                    res += 1
            ans.append(res)

    print(*ans, sep='\n')

    return


if __name__ == '__main__':
    main()


Measured memory_bytes: 203660
#include <iostream>
#include <algorithm>
#include <fstream>
#include <vector>
#include <deque>
#include <assert.h>
#include <stack>
#include <set>
#include <map>
#include <stdio.h>
#include <string.h>
#include <utility>
#include <math.h>
#include <bitset>
#include <iomanip>
#include <complex>
#include <queue>
using namespace std;
#define rng(i,a,b) for(int i=int(a);i<int(b);i++)
#define rep(i,b) rng(i,0,b)
#define gnr(i,a,b) for(int i=int(b)-1;i>=int(a);i--)
#define per(i,b) gnr(i,0,b)
#define ALL(x) (x).begin(),(x).end()
#define RALL(x) (x).rbegin(),(x).rend()
#define IDX(vec, element_iter) distance((vec).begin(), element_iter)
#define print(x) cout<<(x)<<'\n'
#define print_vec(v) rep(i,v.size()){if(i!=0)cout<<" ";cout<<v[i];}cout<<'\n'
#define pe(x) cout<<(x)<<" "
#define DEBUG(x) cout<<#x<<": "<<x<<'\n'
#define DEBUG_VEC(v) cout<<#v<<":";rep(i,v.size())cout<<" "<<v[i];cout<<'\n'
#define pb push_back
#define mp make_pair
#define MOD 1000000007 //10^9+7
#define fi first
#define sc second
using ll=long long;
using pll=pair<ll,ll>;
using vll=vector<ll>;
using vvll=vector<vll>;
using vstr=vector<string>;

ll N;
vll A,B;
vector<pll> ranges;
void solve() {
    cin >> N;
    ll a,b;
    rep(i,N){
        cin >> a >> b;
        A.pb(a);
        B.pb(b);
        ranges.pb(mp(a,b));
    }
    sort(ALL(A));
    sort(ALL(B));
    ll ans;
    double l,r;
    if(N%2){
        l = A[N/2];
        r = B[N/2];
        ans = r-l+1;
    }else{
        l = (A[N/2-1]+A[N/2])/2.0;
        r = (B[N/2-1]+B[N/2])/2.0;
        ans = 2*(r-l)+1;
    }
    print(ans);
}
 
int main() {
    cin.tie(nullptr);
    ios_base::sync_with_stdio(false);
	cout<<fixed<<setprecision(20);
    //int q; cin >> q;
	//while (q--)
		solve();
    return 0;
}

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

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

	int g[n][d];

	for (int k = 0; k < n; k++) {
		for (int l = 0; l < d; l++) {
			cin >> g[k][l];
		}
	}

	double ans = 0;
	int count = 0;
	for (int m = 0; m < n - 1; m++) {
		for (int p = 1; p < n - m; p++) {
			ans = 0;
			for (int o = 0; o < d; o++) {
				ans += (g[m][o] - g[m + p][o])*(g[m][o] - g[m + p][o]);
			}
			ans = sqrt(ans);
			if (ans - floor(ans) == 0) count++;
		}
	}
	cout << count << endl;
	return 0;
}


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


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

    for(int i=0; i<n; i++){
        cin >> h;
        sum += 1/h;
    }

    cout << 1/sum << endl;
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main()
{
	int n;
	cin >> n;
	int j=0, o=0;
	for (int i = 1; i <= n; i++)
	{
		if (i % 2 == 0)
			o++;
		else
			j++;
	}
	cout << o * j << endl;


}

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

using namespace std;

int main(){
    int n;
    cin>>n;
    int arr[n];
    for(int i= 0;i< n;i++){
        cin>>arr[i];
    }
    int dp[n];
    memset(dp,0, sizeof(dp));
    dp[0] = 0;
    dp[1] = abs(arr[1] - arr[0] );
    for(int i=2;i< n;i++){
        dp[i] = min(dp[i-1] + abs(arr[i] - arr [i-1]), dp[i-2] + abs(arr[i] - arr[i-2]));
    }
    cout<<dp[n-1]<<endl;
}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
int main()
{
ios_base::sync_with_stdio(false);
cin.tie(NULL);
//freopen("input.txt","r",stdin);
//freopen("output.txt","w",stdout);
double D,T,S;
cin>>D>>T>>S;
if(D/S <= T)
cout<<"Yes\n";
else
cout<<"No\n";



return 0;
}

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

int main() {
  int a,b,c,x,ans=0,cnt=0;
  cin >> a >> b >> c >> x;

  for (int i = 0; i < a+1; i++) {
    for (int j = 0; j < b+1; j++) {
      for (int k = 0; k < c+1; k++) {
        ans = i*500 + j*100 + k*50;
        if (ans == x) {
          cnt++;
        }
      }
    }
  }
  cout << cnt << endl;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define  rep(i, n) for(int i = 0; i < n; i++) 
#define  all(x) (x).begin(),(x).end()     // 昇順ソート
#define  rall(v) (v).rbegin(), (v).rend() // 降順ソート
#define  INF 1LL << 60
typedef long long int LL;
typedef long long int ll;
#define pll pair<ll, ll>
#define F first
#define S second
const int MOD = 1000000007;
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return true; } return false; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return true; } return false; }
//sort(all(x))とするとソートできるよ
// 10^x は pow(10,(x)) 
// 任意のlogは　対数の底の変換を使う    log(N) / log(任意の底)

int main(){
    int A,B,C;cin >> A >> B >> C;
    int ch = 0;
    if(A == B)ch++;
    if(A == C)ch++;
    if(B == C)ch++;

    if(ch == 1)cout << "Yes" << endl;
    else cout << "No" << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include<vector>
#include<cstdio>
#include<string>
#include<numeric>
#include<algorithm>
#include<complex>
#include<queue>

using namespace std;

int main(){
    int X,Y;
    cin >> X >> Y;
    cout << X+Y/2 << endl;
    return 0;
}


Measured memory_bytes: 256
N, K = map(int, input().split())

MOD = 10**9 + 7

ans = 0

# 選ぶ個数で場合分け
# 選べる個数はK,K+1,K+2,...,N+1

# 等差数列の和S
# 項数n, 初項a,末項l,公差d
# S=(n/2)*(a+l)
# S=(n/2)*{2a+(n-1)d}
# 0+1+2+...（項数=i）

for i in range(K, N + 2):
    min_sum = i * (i - 1) // 2  # 0+1+...(項数=i)
    max_sum = (2 * N - i + 1) * i // 2  # N+(N-1)+...(項数=i)
    ans += max_sum - min_sum + 1  # minとmaxの間の数を全て取れる
    ans %= MOD

print(ans)


Measured memory_bytes: 9024
#include<bits/stdc++.h>
using namespace std;
int n,k,x,y,cnt=0;
int main(){
	scanf("%d%d%d%d",&n,&k,&x,&y);
	if(n<k){
		printf("%d",n*x);
	}else printf("%d",k*x+(n-k)*y);
}

Measured memory_bytes: 256
#include <iostream>
#include <cmath>
#include <iomanip>
#include <vector>
#include <algorithm>
#include <set>
#include <map>
#include <queue>
#include <cassert>
#include <random>
#include <bitset>
using namespace std;
 

#define FAST_IO ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define all(x) x.begin(), x.end()
#define ff first
#define ss second
#define pb push_back
#define forn(i, n) for (int i = 0; i < n; ++i)
#define int long long

 
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;

 
const int MAXN = 3e5 + 5;
const ll MOD = 1e9 + 7;
const ll INF = INT64_MAX;


random_device rd;
mt19937 rnd(rd());


signed main() {
	FAST_IO;
	int l, r, d;
	cin >> l >> r >> d;
	int ans = 0;
	for (int i = l; i <= r; i++) {
		if (i % d == 0) {
			ans++;
		}
	}
	cout << ans << "\n";
 	return 0;
}

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

int main() {
    int N;
    cin >> N;
    for (int i = 1; i <= N; i++) {
        int x = i;
        if (x % 3 == 0) {
            cout << " " << i;
            continue;
        }
        while (x > 0) {
            if (x % 10 == 3) {
                cout << " " << i;
                break;
            }
            x /= 10;
        }
    }
    cout << endl;
}


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

#define loop(v, f, l) for(int v = (f), v##_ = (l); v < v##_; ++v)

using namespace std;

typedef long long int lint;
static inline int in(){ int x; scanf("%d", &x); return (x); }
static inline lint inl(){ lint x; scanf("%lld", &x); return (x); }

int main()
{
	int sum = 0;
	for(int i = 0; i < 10; i++)
	{
		sum += in();
	}
	printf("%d\n", sum);
	return (0);
}

Measured memory_bytes: 1188