akhauriyash/Code-Regression huggingface dataset:
#include "bits/stdc++.h"
#include<random>
using namespace std;
typedef long long int lint;
typedef pair<lint, lint> plint;
typedef pair<double long, double long> pld;
#define ALL(x) (x).begin(), (x).end()
#define SZ(x) ((lint)(x).size())
#define POW2(n) (1LL << (n))
#define FOR(i, begin, end) for(lint i=(begin),i##_end_=(end);i<i##_end_;i++)
#define IFOR(i, begin, end) for(lint i=(end)-1,i##_begin_=(begin);i>=i##_begin_;i--)
#define REP(i, n) FOR(i,0,n)
#define IREP(i, n) IFOR(i,0,n)
template<class T>bool chmax(T& a, const T& b) { if (a < b) { a = b; return 1; } return 0; }
template<class T>bool chmin(T& a, const T& b) { if (b < a) { a = b; return 1; } return 0; }
template<typename T1, typename T2> pair<T1, T2> operator+(const pair<T1, T2>& l, const pair<T1, T2>& r) { return make_pair(l.first + r.first, l.second + r.second); }
template<typename T1, typename T2> pair<T1, T2> operator-(const pair<T1, T2>& l, const pair<T1, T2>& r) { return make_pair(l.first - r.first, l.second - r.second); }
const lint MOD = 1e9 + 7, INF = 1e18;


template <std::int_fast64_t Modulus>
class modint
{
	using u64 = std::int_fast64_t;

public:
	u64 a;
	constexpr modint(const u64 x = 0) noexcept : a(x% Modulus) {}
	constexpr u64& value() noexcept { return a; }
	constexpr const u64& value() const noexcept { return a; }
	constexpr modint operator+(const modint rhs) const noexcept
	{
		return modint(*this) += rhs;
	}
	constexpr modint operator-(const modint rhs) const noexcept
	{
		return modint(*this) -= rhs;
	}
	constexpr modint operator*(const modint rhs) const noexcept
	{
		return modint(*this) *= rhs;
	}
	constexpr modint operator/(const modint rhs) const noexcept
	{
		return modint(*this) /= rhs;
	}
	constexpr modint& operator+=(const modint rhs) noexcept
	{
		a += rhs.a;
		if (a >= Modulus)
		{
			a -= Modulus;
		}
		return *this;
	}
	constexpr modint& operator-=(const modint rhs) noexcept
	{
		if (a < rhs.a)
		{
			a += Modulus;
		}
		a -= rhs.a;
		return *this;
	}
	constexpr modint& operator*=(const modint rhs) noexcept
	{
		a = a * rhs.a % Modulus;
		return *this;
	}
	constexpr modint& operator/=(modint rhs) noexcept
	{
		u64 exp = Modulus - 2;
		while (exp)
		{
			if (exp % 2)
			{
				*this *= rhs;
			}
			rhs *= rhs;
			exp /= 2;
		}
		return *this;
	}
};
typedef modint<MOD> ModInt;

ModInt mod_pow(ModInt x, ModInt n) {
	ModInt ret = 1;
	while (n.a > 0) {
		if (n.a & 1) (ret *= x);
		(x *= x);
		n.a >>= 1;
	}
	return ret;
}

ModInt func[200000];
void funcinit(int N)
{
	func[0] = 1;
	for (int i = 1; i <= N; i++)
	{
		func[i] = func[i - 1] * i;
	}
}
ModInt comb(ModInt n, ModInt r)
{
	if (n.a <= 0 || n.a < r.a)
	{
		return 0;
	}
	return func[n.a] / (func[r.a] * func[(n - r).a]);
}

lint A, B;
int main() {
	cin >> A >> B;
	cout << (A + B + 1) / 2 << endl;
}


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

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

    string s;
    cin >> s;

    int ans = 1;
    char prev = s[0];
    for(int i = 1; i < s.size(); i++){
        char c = s[i];
        if(c == prev) {
            prev = '?';
            i++;
        } else {
            prev = s[i];
        }

        if(i >= s.size()) break;
        ans++;
    }
    cout << ans << endl;
}



Measured memory_bytes: 720
#define _USE_MATH_DEFINES

#include <cstdio>
#include <cstdlib>
#include <iostream>
#include <cmath>
#include <cstring>
#include <algorithm>
#include <vector>
#include <queue>
#include <map>

using namespace std;

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

long long int INF = 1e18;
long long int MOD = 1e9 + 7;

int main(){
    int N, M;
    cin >> N >> M;
    long long int A[1100];
    for(int i = 0; i < N; i++){
        cin >> A[i];
    }
    int pos = 0;
    bool flag = true;
    long long int ans = 0;
    while(pos % N != 0 || flag){
        flag = false;
        long long int n1 = 0, n2 = 1000;
        for(int i = 0; i < M; i++){
            n1 = max(n1, A[pos % N]);
            n2 = min(n2, A[pos % N]);
            pos += 1;
        }
        ans += n1 - n2;
    }
    cout << ans << endl;
    return 0;
}


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

using ll = long long;
#define int long long
using P = pair<int, int>;

#define LOG(variable) cout << #variable":\t" << (variable) << endl
#define LOGCON(i, container) for(int (i) = 0; (i) < (container).size(); ++(i)) cout << (i) << ":\t" << (container)[(i)] << endl
#define REP(i, n) for (int i = 0; i < (n); ++i)
#define REPS(i, r, n) for (int i = (r); i < (n); ++i)
#define REPR(i, n) for(int i = (n); i >= 0; --i) // from n to 0
#define REPRS(i, n, r) for(int i = (n); i >= (r); --i) // from n to r
#define REPOBJ(itr, obj) for(auto itr = (obj).begin(); itr != (obj).end() ; ++itr)
#define REPROBJ(itr, obj) for(auto itr = (obj).rbegin(), e = (obj).rend(); itr != e; ++itr)
#define COUTB(x) cout << (x) << "\n"
#define COUTS(x) cout << (x) << " "
#define PB push_back
#define SORT(obj) sort((obj).begin(), (obj).end())
#define SORTR(obj) sort((obj).begin(), (obj).end(), greater<>())
#define ALL(obj) (obj).begin(), (obj).end()
#define MOD 1000000007
#define PI (acos(-1))

/***** MAIN *****/
signed main() {
  int n, k; cin >> n >> k;
  int next_town[n];
  REP(i,n) {
    cin >> next_town[i];
    --next_town[i];
  }
  unordered_map<int, bool> visited;
  vector<int> visited_order;
  int current_town = 0;
  int beginning_of_loop_i = -1;
  while(!visited[current_town]) {
    visited[current_town] = true;
    visited_order.push_back(current_town);
    current_town = next_town[current_town];
  }
  for(int i = 0; i < visited_order.size(); ++i) {
    if(visited_order[i] == current_town) {
      beginning_of_loop_i = i;
      break;
    }
  }
  if(k <= beginning_of_loop_i) {
    cout << visited_order[k] + 1 << endl;
  } else {
    int loop_size = visited_order.size() - beginning_of_loop_i;
    k -= beginning_of_loop_i;
    k %= loop_size;
    cout << visited_order[beginning_of_loop_i+k] + 1 << endl;
  }
  return 0;
}
/***** MAIN *****/


Measured memory_bytes: 14200
#include <iostream>
#include <cstdlib>
#include <time.h>
#include <algorithm>
#include <map>
#include <queue>
#include <stack>
#include <vector>
#include <array>
#include <string>
using namespace std;

typedef long long int ll;

int main(){
	cin.sync_with_stdio(false);
	cin.tie(0);
	ll t;
	cin >> t;
	if(t < 1200)
		cout << "ABC";
	else if(t < 2800)
		cout << "ARC";
	else
		cout << "AGC";
	return 0;
}

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

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repi(i, s, n) for (int i = (s); i < (int)(n); i++)
#define all(x) (x).begin(), (x).end()
#define debug(x) cerr << #x << ": " << x << '\n'

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

const long long INF = 3e18 + 12;
const int inf = 1e9;

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

  string a, b;
  cin >> a >> b;

  string c = a + b;

  int cc = stoi(c);

  rep(i, 1000) {
    if (cc == i * i) {
      cout << "Yes" << endl;
      return 0;
    }
  }

  cout << "No" << endl;
  return 0;
}

Measured memory_bytes: 256
fn get_input() -> String {
    let mut word = String::new();
    std::io::stdin().read_line(&mut word).unwrap();
    word.trim().to_owned()
}

fn main() {
    let n: usize = get_input().parse().unwrap();
    let mut a:Vec<i64> = get_input().split_whitespace().map(|x| x.parse().unwrap()).collect();
    let mut b:Vec<i64> = get_input().split_whitespace().map(|x| x.parse().unwrap()).collect();

    let mut ans = 0;
    for i in 0..n {
        let m = std::cmp::min(b[i], a[i]);
        ans += m;
        b[i] -= m;
        a[i] -= m;

        let m = std::cmp::min(b[i], a[i+1]);
        ans += m;
        a[i+1] -= m;
    }

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

Measured memory_bytes: 9972
from bisect import*
s=input()
t=input()
d={}
for i,c in enumerate(s):
    d.setdefault(c,[]).append(i+1)
m=-1
n=len(s)
r=0
for c in t:
    if not c in d:
        print(-1)
        exit()
    i=bisect(d[c],m)
    if len(d[c])==i:
        r+=1
        m=d[c][0]
    else:
        m=d[c][i]
print(r*n+m)

Measured memory_bytes: 7796
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define mod 998244353LL

vector<int> v[200010];

ll f[200010];
int now[200010],mn[200010],mx[200010],num[200010],n;
char s[200010];

inline int rd()
{
	int x=0;char ch=getchar();
	for (;ch<'0'||ch>'9';ch=getchar());
	for (;ch>='0'&&ch<='9';ch=getchar()) x=x*10+ch-'0';
	return x;
}

inline ll pls(const ll &x,const ll &y) { return (x+y<mod)?x+y:x+y-mod; }
inline ll mns(const ll &x,const ll &y) { return (x-y<0)?x-y+mod:x-y; }
inline ll ksm(ll x,ll y) { ll res=1;for (;y;y>>=1,x=x*x%mod) if (y&1) res=res*x%mod;return res; }

inline int check(int *a,int *b,int len)
{
	for (int i=1;i<=len;i++)
	{
		if (a[i]<b[i]) return 1;
		if (a[i]>b[i]) return -1;
	}
	return 0;
}

int main()
{
	n=rd();
	scanf("%s",s+1);
	for (int i=1;i<=n;i++) if (n%i==0) for (int j=i*2;j<=n;j+=i) v[j].push_back(i);
	for (int i=1;i<=n;i++) num[i]=s[i]-'0';
	ll ans=0;
	for (int i=1;i<=n;i++) if (n%i==0&&(n/i)%2==1)
	{
		for (int k=1;k<=i;k++) now[k]=num[k];
		ll hh=0;
		for (int j=1;j<=i;j++) hh=(hh*2+now[j])%mod;
		f[i]=hh;
		for (int k=1;k<=i;k++) mn[k]=now[k],mx[k]=now[k]^1;
		bool flag=true;
		for (int j=1;j<=n;j+=i)
		{
			for (int k=1;k<=i;k++) now[k]=num[j+k-1];
			if ((j-1)/i%2==0)
			{
				int hh=check(mn,now,i);
				if (hh>0) break;
				if (hh<0) { flag=false;break; }
			}
			else
			{
				int hh=check(mx,now,i);
				if (hh>0) break;
				if (hh<0) { flag=false;break; }
			}
		}
		if (flag) f[i]=pls(f[i],1);
		for (int t:v[i]) f[i]=mns(f[i],f[t]);
		ans=pls(ans,f[i]*i*2%mod);
	}
	printf("%lld\n",ans);
	return 0;
}

Measured memory_bytes: 18304
#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i=0; i<n; i++)
#define rrep(i, n) for(int i=n-1; i>=0; i--)
#define FOR(i, a, b) for(int i=a; i<b; i++)
#define ALL(v) v.begin(),v.end()
#define pb push_back
#define eb emplace_back
#define mp make_pair
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<int, ll> pil;
typedef pair<ll, int> pli;
typedef pair<ll, ll> pll;
const int INF = 1e9;
const ll LLINF = 1e18;
const ll MOD = 1e9+7;
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; }

int n;
string s;

int main() {
    cin >> n >> s;
    int ans = 0;
    for (int i = 2; i < n; i++) {
        if (s[i] == 'C' && s[i-1] == 'B' && s[i-2] == 'A') ans++;
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
//IncubatorMan
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp> 
#include <ext/pb_ds/detail/standard_policies.hpp>
using namespace __gnu_pbds;
using namespace std;
char gap = 32;
template<typename T> 
ostream& operator<<(ostream &os, const vector<T> &v) { 
    os << '{'; 
    for (const auto &x : v) os << gap << x;
        return os << '}'; 
}
template<typename A, typename B> 
ostream& operator<<(ostream &os, const pair<A, B> &p) {
        return os << '(' << p.first << gap << p.second << ')';
}

template <class T>
void read(T &x) {
    char c;
    for (c = getchar(); c < '0' || c > '9'; c = getchar())
        ;
    for (x = 0; c <= '9' && c >= '0'; c = getchar()) x = x * 10 + (c & 15);
}
#define ll long long 
#define lll __int128_t
#define pb push_back
#define mp make_pair
#define All(x) (x).begin(),(x).end()
typedef pair < int,int> ii;
typedef vector<ii> vii;
typedef vector<ll>vl;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef tree<
int,
null_type,
less<int>,
rb_tree_tag,
tree_order_statistics_node_update>
ordered_set;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
ll hashPrime = 1610612741;

void solve(){
    int n,m;
    cin>>n>>m;
    vvi g(n);
    int from,to;
    for(int i=0;i<m;i++){
        cin>>from>>to;
        from--;
        to--;
        g[from].pb(to);
        g[to].pb(from);
    }
    vi dis(n, -1);
    dis[0]=0;
    queue<int> Q;
    Q.push(0);
    vi par(n,-1);
    while(!Q.empty()){
        int src = Q.front();
        Q.pop();
        int lev =  dis[src];
        for(int child : g[src]){
            if(dis[child]==-1){
                dis[child]= lev+1;
                Q.push(child);
                par[child]= src+1;
            }
        }
    }
    int min = *min_element(All(dis));
    if(min == -1) cout<<"No\n";
    else{
        cout<<"Yes\n";
        for(int i=1;i<n;i++){
            cout<<par[i]<<endl;
        }
    }
}

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(0);
        int test=1;
        //read(test);
        //cin>>test;
        while(test--){
            solve();
        }
    return 0;
}

Measured memory_bytes: 10628
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <map>
using namespace std;

int main() {
  int n;
  cin >> n;
  vector<string> s(n);
  vector<int> t(n);
  int ans = 0;
  for (int i = 0; i < n; i++) {
    cin >> s[i] >> t[i];
    ans += t[i];
  }
  string x;
  cin >> x;
  for (int i = 0; i < n; i++) {
    ans -= t[i];
    if (s[i] == x) {
      break;
    }
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
map<int,int> m;
int main(){
	int i,n,ans=0,a,b;
	scanf("%d",&n);
	for(i=1;i<=n;i++){
		scanf("%d",&a);
		m[a]++;
	}
	map<int,int>::iterator it;
	for(it=m.begin();it!=m.end();it++){
		if(it->second%2==1) ans++;
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 4992
#include <iostream>
#include<cstdio>
#include<stdio.h>
using namespace std;

int main() {
	int n,x,count=0;
	while (true) {
		count = 0;
		cin >> n >> x;

		if (n == 0 && x == 0) {
			break;
		}

		for (int i = 1; i <= n; ++i) {
			for (int j = i + 1; j <= n; ++j) {
				for (int k = j + 1; k <= n; ++k) {
					if (i + j + k == x) {
						count++;
					}
				}
			}
		}
		cout << count<< endl;

	}
	




	return 0;
}




Measured memory_bytes: 3096
#include <iostream>
#include <fstream>
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cctype>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <iomanip>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <sstream>
#include <string>
#include <vector>
using namespace std;

#pragma comment(linker, "/STACK:400000000")

#define EPS 1e-9
#define INF MOD
#define MOD 1000000007LL
#define fir first
#define foreach(it,X) for(it=X.begin();it!=X.end();it++)
#define iss istringstream
#define ite iterator
#define ll long long
#define mp make_pair
#define rep(i,n) rep2(i,0,n)
#define rep2(i,m,n) for(int i=m;i<n;i++)
#define pi pair<int,int>
#define pb push_back
#define sec second
#define sh(i) (1LL<<i)
#define sst stringstream
#define sz size()
#define vi vector<int>
#define vc vector
#define vl vector<ll>
#define vs vector<string>

int n,Y,M,D;

int main(){
	cin>>n;
	while(cin>>Y>>M>>D){
		int y=Y,m=M,d=D,ans=0;
		while(1){
			if(y==1000){
				cout<<ans<<endl;
				break;
			}
			ans++;
			d++;
			if(d>(20-((m%2==0)&&(y%3>0))))m++,d=1;
			if(m==11)y++,m=1;
		}
	}
}

Measured memory_bytes: 868
#include <bits/stdc++.h>
#define ll long long int
using namespace std;
#define MAX 200005
#define MOD 1000000007
#define max(a,b) (a>b?a:b)
#define min(a,b) (a<b?a:b)
#define vi vector<int>
#define ii pair<int,int>
#define vii vector<ii>
#define si set<int>
#define mp map<ll,ll>
#define mpi map<ii,ll>
#define fast ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define pb push_back
#include <unordered_map> 
#define ump unordered_map<ll,ll>
int main()
{ 
	ll n;
	map<string,int> ma;
	cin>>n;
	ll i;
	for(i=0;i<n;i++)
	{
		string s;
		cin>>s;
		sort(s.begin(),s.end());
		ma[s]++;
	} 
	ll ans=0;
	for(auto it:ma)
	{
		ll k=it.second;
		ans=ans+(k*(k-1))/2;
	}
	cout<<ans<<endl;
}
	

Measured memory_bytes: 11136
#include<iostream>
#include<string>
#include<cstdio>
#include<algorithm>
#include<queue>
#include<cstring>
#include<vector>
#include<sstream>
#include<cctype>
#include<map>
#include<set>
#include<cmath>
using namespace std;
typedef long long LL;
const int maxn = 100005;

int main(){
    int ans=0,n,d,x;
    cin >> n >> d >> x;
    for(int i=0;i<n;i++){
        int m;
        cin >> m;
        ans+=(d-1)/m+1;
    }
    ans+=x;
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
import java.util.Arrays;
import java.util.Scanner;

public class Main {
    static int n;
    static int[][] permArray;
    static int count = 0;
    public static void main(String[] args) {
        @SuppressWarnings("resource")
        Scanner sc = new Scanner(System.in);
        n = sc.nextInt();
        int[] p = new int[n];
        int[] q = new int[n];
        for (int i = 0 ; i < n ; i++) {
            p[i] = sc.nextInt();
        }
        for (int i = 0 ; i < n ; i++) {
            q[i] = sc.nextInt();
        }
        int array[] = new int[n];
        for (int i = 0 ; i < n ; i++) {
            array[i] = i + 1;
        }
        int d = 1;
        for (int i = 1 ; i <= n ; i++) {
            d *= i;
        }
        permArray = new int[d][n];

        permutation(array);

        int pc = countPerm(p);
        int qc = countPerm(q);
        System.out.println(Math.abs(pc - qc));

    }

    private static void permutation(int[] seed) {
        int[] perm = new int[seed.length];
        boolean[] used = new boolean[seed.length];
        buildPerm(seed, perm, used, 0);
    }

    private static void buildPerm(int[] seed, int[] perm, boolean[] used, int index) {
        if (index == seed.length) {
            for (int i = 0 ; i < n ; i++) {
                permArray[count][i] = perm[i];
            }
            count++;
            return;
        }

        for (int i = 0; i < seed.length; ++i) {
            if (used[i]) continue;
            perm[index] = seed[i];
            used[i] = true;
            buildPerm(seed, perm, used, index + 1);
            used[i] = false;
        }
    }

    private static int countPerm(int[] p) {
        int num = 0;
        for (int i = 0 ; i < permArray.length ; i++) {
            boolean flg = true;
            for (int j = 0 ; j < n ; j++) {
                if (p[j] != permArray[i][j]) flg  =false;
            }
            if (flg) num = i;
        }
        return num;
    }


    /*
     * for Debag
     */
    private static void procPerm(int[] perm) {
        // Use the perm[] here.
        System.out.println(Arrays.toString(perm));
    }

}


Measured memory_bytes: 24148
def judge(s):
    inv_str = s[::-1]
    # print(inv_str)
    if(s == inv_str):
        return 0
    else:
        return 1

x = str(input())
len = len(x)
x1 = x[:int((len-1)/2)]
x2 = x[int((len+3)/2-1):]

if(judge(x1)==0 and judge(x2)==0 and judge(x)==0):
    print("Yes")
else:
    print("No")

Measured memory_bytes: 3060
N = int(input())
L = [0] + list(map(int,input().split()))
N = len(L)
ans = [0 for i in range(N + 2)]
for i in reversed(range(1,N)):
    cnt = 0
    c = i
    while True:
        c += i
        if c > N:
            break
        cnt += ans[c]
    if cnt % 2 == 0 and L[i] == 0:
        ans[i] = 0
    elif cnt % 2 == 0 and L[i] == 1:
        ans[i] = 1
    elif cnt % 2 == 1 and L[i] == 0:
        ans[i] = 1
    else:
        ans[i] = 0 
c = 0
for i in range(len(ans)):
    if ans[i] == 1:
        c = i
ans = ans[1:c+1]

cnt = 0
for x in ans:
    if x == 1:
        cnt += 1
print(cnt)
for i in range(len(ans)):
    if ans[i] == 1:
        print(i+1,end = ' ')


Measured memory_bytes: 72296
n, a, b, c, d = map(int, input().split())
s = list(input())
last = ""
for i in range(a, max(c, d)):
    if last == "#" and s[i] == "#":
        print("No")
        exit()
    last = s[i]
flag = False
if c > d:
    s[b - 1] = "#"
    for i in range(a, c):
        if last == "#" and s[i] == "#":
            flag = True
        last = s[i]
    s[b - 1] = "."
    count = 0
    for i in range(b - 1, d + 1):
        if s[i] == ".":
            count += 1
            if count == 3:
                flag = False
        else:
            count = 0
else:
    for i in range(b, d):
        if last == "#" and s[i] == "#":
            flag = True
        last = s[i]
if not flag:
    print("Yes")
else:
    print("No")


Measured memory_bytes: 4916
/*  -*- coding: utf-8 -*-
 *
 * b.cc: B: Around Square
 */

#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<iostream>
#include<string>
#include<vector>
#include<map>
#include<set>
#include<stack>
#include<list>
#include<queue>
#include<deque>
#include<algorithm>
#include<numeric>
#include<utility>
#include<complex>
#include<functional>
 
using namespace std;

/* constant */

/* typedef */

/* global variables */

/* subroutines */

/* main */

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

  int p = 1;
  while ((p + 1) * (p + 1) <= n) p++;

  printf("%d\n", p * p);
  return 0;
}


Measured memory_bytes: 256
/**
 *    Coded by : lucky_21
 *               --------Lokesh Singh
**/

#include<bits/stdc++.h>
using namespace std;

#include<ext/pb_ds/tree_policy.hpp>
#include<ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
template<class T> using oset=tree<T,null_type,less<T>,rb_tree_tag,tree_order_statistics_node_update>;

#define     F           first
#define     S           second
#define     pb          push_back
#define     lb          lower_bound
#define     ub          upper_bound
#define     pii         pair<int,int>
#define     all(x)      x.begin(),x.end()
#define     fix         fixed<<setprecision(10)
#define     rep(i,a,b)  for(int i=int(a);i<=int(b);i++)
#define     repb(i,b,a) for(int i=int(b);i>=int(a);i--)
#define     FastIO      ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0)

typedef double db;
typedef long long ll;

const int N=2e5+5;
const int mod=1e9+7;

signed main(){
    FastIO;
    int n;
    cin>>n;
    cout<<(n+1000-1)/1000*1000-n;
    return 0;
}


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

using namespace std;

using ll = long long;
using P = pair<ll, ll>;
using Graph = vector<vector<ll>>;
#define rep(i, n) for(ll i=0;i<(ll)(n);i++)
#define rep2(i, m, n) for(ll i=m;i<(ll)(n);i++)
#define rrep(i, n, m) for(ll i=n;i>=(ll)(m);i--)
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
const int ddx[8] = {0, 1, 1, 1, 0, -1, -1, -1};
const int ddy[8] = {1, 1, 0, -1, -1, -1, 0, 1};
const ll MOD = 1000000007;
const ll INF = 1000000000000000000L;
#ifdef __DEBUG

/**
 * For DEBUG
 * https://github.com/ta7uw/cpp-pyprint
 */
#include "cpp-pyprint/pyprint.h"

#endif

void solve() {
    ll N;
    cin >> N;
    ll ans = INF;
    rep(i, 10090) {
        ll y = 1000 * i;
        if (y >= N) ans = min(ans, y - N);
    }
    cout << ans << '\n';
}

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


Measured memory_bytes: 3648
#include<stdio.h>
#include<stdlib.h>
struct node{
  struct node *right;
  struct node *left;
  struct node *parent;
  int key;
};
typedef struct node * Node;
Node root, NIL;
void insert(int);
void inorder(Node);
int main(){
  int i,n, m;
  char c[20];
  scanf("%d", &n);
  for ( i = 0; i < n; i++ ){
    scanf("%s", c);
    if ( strcmp(c, "insert") == 0 ){
      scanf("%d", &m);
      insert(m);
    } else if ( strcmp(c, "print") == 0 ){
      inorder(root);
      printf("\n");
      preorder(root);
      printf("\n");
    }
  }

  return 0;
}
void insert(int k){
  int H;
  Node y = NIL;
  Node x = root;
  Node z;

  z = malloc(sizeof(struct node));
  z->key = k;
  z->left = NIL;
  z->right = NIL;

  while( x != NIL ){
    y = x;
    if ( z->key < x->key ){
      x = x->left;
    } else {
      x = x->right;
    }
  }

  z->parent = y;
  if ( y == NIL ){
    root = z;
  } else {
    if (z->key < y->key) {
      y->left = z;
    } else {
      y->right = z;
    }
  }
}
void inorder(Node a){
  if ( a == NIL ) return;
  inorder(a->left);
  printf(" %d", a->key);
  inorder(a->right);
}
void preorder(Node a){
  if ( a == NIL ) return;
  printf(" %d", a->key);
  preorder(a->left);
  preorder(a->right);
}



Measured memory_bytes: 25156
input_data = STDIN.gets
a_b_c = input_data.split(" ")
a = a_b_c[0].to_i
b = a_b_c[1].to_i
c = a_b_c[2].to_i

if a < c && b < c then
  if a < b then
    print "Yes\n"
  else
    print "No\n"
  end
else
  print "No\n"
end

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

#define int				long long
#define FOR( i, m, n )  for( int (i) = (m); (i) < (n); (i)++ )
#define REP( i, n )     FOR( i, 0, n )
#define REPR( i, m )	for( int (i) = (m); (i) >= 0; (i)-- )
#define REPONE( i, n )	FOR( i, 1, n + 1 )
#define ALL( a )        (a).begin(), (a).end()
#define MP				make_pair

typedef pair<int, int> P;

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

const int INF = 1e9;
const int MOD = 1e9 + 7;

signed main() {
	int a[3]; cin >> a[0] >> a[1] >> a[2];
	sort( a, a + 3 );

	cout << a[0] + a[1] << endl;
}


Measured memory_bytes: 764
import java.util.*;

public class Main {
	public static void main(String[] args) {
		int i,j;
		Scanner sc = new Scanner(System.in);
		int n = Integer.parseInt(sc.next());
		int t = Integer.parseInt(sc.next());
		int a = Integer.parseInt(sc.next());
		int[] h = new int[n];
		for(i = 0; i < n; i++) {
			h[i] = Integer.parseInt(sc.next());
		}
		sc.close();
		double tp = 1000.0;
		double tt;
		int ti = 0;
		for(i = 0; i < n; i++) {
			tt = Math.abs(a - (t - h[i] * 0.006));
			if(tp > tt) {
				tp = tt;
				ti = i;
			}
		}
		System.out.println(ti+1);
	}
}

Measured memory_bytes: 21972
using System;
using System.Linq;
public class Program {
	public static void Main()
	{
		var list = Console.ReadLine().Split(' ').Select(x => int.Parse(x)).ToList();
		
		var sx = list[0];
		var sy = list[1];
		var tx = list[2];
		var ty = list[3];
		//0 0 1 1
		//
		
		var ans = String.Empty;
		for(var i = 0; i < ty - sy; i++)
			ans += "U";

		for(var i = 0; i < tx - sx; i++)
			ans += "R";

		for(var i = 0; i < ty - sy; i++)
			ans += "D";
		
		for(var i = 0; i < tx - sx; i++)
			ans += "L";
		
		ans += "L";
		
		for(var i = 0; i < ty - sy + 1; i++)
			ans += "U";

		for(var i = 0; i < tx - sx + 1; i++)
			ans += "R";

		ans += "DR";
		
		for(var i = 0; i < ty - sy + 1; i++)
			ans += "D";

		for(var i = 0; i < tx - sx + 1; i++)
			ans += "L";

		ans += "U";
		
		Console.WriteLine(ans);
	}
}



Measured memory_bytes: 32852
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <algorithm>
#include <string>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <stack>
#include <queue>
#define llong long long
#define INF (__INT32_MAX__ / 2)
#define EPS 10e-8

using namespace std;
typedef pair<int, int> ipair;
llong modulo(llong left, llong right) { return (left % right + right) % right; }

int N;
int main(int argc, char **argv) {
    cin >> N;
    int res = N * N * N;
    cout << res << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using ll = long long;
using namespace std;
#define rep(i, n) for (int i = 0, i##_len = (int)(n); i < i##_len; i++)
#define reps(i, n) for (int i = 1, i##_len = (int)(n); i <= i##_len; i++)
#define rrep(i, n) for (int i = ((int)(n)-1); i >= 0; i--)
#define rreps(i, n) for (int i = ((int)(n)); i > 0; i--)
#define repi(i, x) \
	for (auto i = (x).begin(), i##_fin = (x).end(); i != i##_fin; i++)
#define all(x) (x).begin(), (x).end()
#define input(array) \
	repi(_itr, array) { cin >> *(_itr); }
#define F first
#define S second
#define mp make_pair
#define mt make_tuple
#define pb push_back
#define eb emplace_back
string solve(bool a) { return ((a) ? "Yes" : "No"); }
typedef vector<int> Vi;
typedef vector<Vi> VVi;
typedef pair<int, int> Pi;
typedef vector<Pi> VPi;
typedef vector<long long> V;
typedef vector<V> VV;
typedef pair<long long, long long> P;
typedef vector<P> VP;
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 long long INFLL = 1LL << 60;
const int INF         = 1 << 30;
const double PI       = acos(-1);
int main() {
	int h, w;
	int ans = INF;
	cin >> h >> w;
	VVi dis(h, Vi(w));
	rep(i, h) { input(dis[i]); }
	const int range = 80 * 82 * 2;
	const int zero  = 80 * 82;
	int cnt;
	rep(i, h) {
		rep(j, w) {
			cin >> cnt;
			dis[i][j] -= cnt;
		}
	}

	vector<vector<vector<bool>>> dp(
	    h, vector<vector<bool>>(w, vector<bool>(range, false)));
	dp[0][0][zero + dis[0][0]] = true;
	dp[0][0][zero - dis[0][0]] = true;
	int at;
	//	return 0;
	rep(I, h) {
		rep(J, w) {
			//   clog<<I<<" "<<J<<endl;
			if (I == h - 1 and J == w - 1) {
				break;
			}
			for (int i = 0; i < range; i++) {
				if (dp[I][J][i] == false) {
					continue;
				}

				if (I < h - 1) {
					at = i+dis[I + 1][J] ;
					if (at < range and at>= 0) {
						dp[I + 1][J][at] = true;
					}
					at =i-dis[I + 1][J] ;
					if (at < range and at >= 0) {
						dp[I + 1][J][at] = true;
					}
				}

				if (J < w - 1) {
					at = i + dis[I][J+1];
					if (at < range and at >= 0) {
						dp[I][J + 1][at] = true;
					}
					at = i - dis[I][J + 1];
					if (at < range and at >= 0) {
						dp[I][J + 1][at] = true;
					}
				}
			}
		}
	}

	for (int i = 0; i < range; i++) {
		if (dp[h - 1][w - 1][i] == true) {
			chmin(ans, abs(i - zero));
		}
	}
	cout << ans << endl;
}
/*
引いて、そのまま足すか、符号を反転して入れるか(DP)
max:80*80=(80^4)
h+w-1こ選んで絶対値の最小値を求める
*/

Measured memory_bytes: 14108
s = input() + 'T'
n = len(s)
x, y = map(int, input().split())
X = [[], [0]]
xy = 0
cnt =0
for i in s:
    if i == 'F':
        cnt += 1
    else:
        X[xy].append(cnt)
        xy = 1 - xy
        cnt = 0

def f(l):
    if len(l) == 0:
        return [0]
    post = [l[0]]
    for i in range(1, len(l)):
        if l[i]:
            pre = sorted(post)
            post = []
            for j in range(len(pre)):
                if j == 0 or pre[j] != pre[j-1]:
                    post.append(pre[j]+l[i])
                    post.append(pre[j]-l[i])
    return post

print('Yes' if x in f(X[0]) and y in f(X[1]) else 'No')


Measured memory_bytes: 46172
n = int(input())

#a,bの最大公約数
def gcd(a, b):
   while b:
       a, b = b, a % b
   return a

#a,bの最小公倍数
def lcm(a, b):
   return a * b // gcd (a, b)

def ceil(a, b):
  return a // b + (a % b > 0)

import math
ans = (1, 1)
for _ in range(n):
   t,a = map(int,input().split())
   b = max(ceil(ans[0],t), ceil(ans[1],a))
   ans = [b*t, b*a]
print(sum(ans))
   



Measured memory_bytes: 3060
#include <set>
#include <map>
#include <queue>
#include <deque>
#include <cstdio>
#include <vector>
#include <string>
#include <bitset>
#include <cstring>
#include <cstdlib>
#include <sstream>
#include <iomanip>
#include <iostream>
#include <algorithm>
using namespace std;
#define N 15
#define mp make_pair
#define pb push_back
#define ll long long
#define uint unsigned int
#define pii pair<int, int>
#define ull unsigned long long
#define sz(v) ((int)(v).size())
#define gc() fgetc(stdin)
template<typename T> void read(T &a) {
	register int b = 1, c; a = 0;
	for (c=gc(); c > 57 || c < 48; c=gc()) if (c == 45) b = -1;
	for (; c >= 48 && c <= 57; c=gc()) a = a * 10 + c - 48;
	a *= b;
}

int n, m;
string s[N], ss[N];

int main() {
	read(n); read(m);
	for (int i = 0; i < n; i++) cin >> s[i];
	for (int i = 0; i < n; i++) {
		ss[i] = s[i];
		sort(ss[i].begin(), ss[i].end());
	}
	for (int msk = 0; msk < (1 << n); msk++) {
		if (__builtin_popcount(msk) != n / 2) continue;
		vector<int> used, unused;
		for (int i = 0; i < n; i++) {
			if (msk & (1 << i)) used.pb(i);
			else unused.pb(i);
		}
		do {
			bool flag = 1;
			map<string, int> M;
			for (int i = 0; i < sz(used); i++) {
				if (ss[used[i]] != ss[unused[i]]) {
					flag = 0; break;
				}
			}
			if (!flag) continue;
/*			for (int i = 0; i < sz(used); i++) {
				printf("%d ", used[i]);
			} printf("\n");
			for (int i = 0; i < sz(unused); i++) {
				printf("%d ", unused[i]);
			} printf("\n");
*/			for (int i = 0; i < m; i++) {
				string str;
				for (int j = 0; j < sz(used); j++) str += s[used[j]][i];
				if (sz(unused) > sz(used)) str += s[unused.back()][i];
				for (int j = sz(used) - 1; j >= 0; j--) str += s[unused[j]][i];
//				printf("%s\n", str.c_str());
				M[str]++;
			}
			bool f = m & 1;
			for (map<string, int>::iterator it = M.begin(); it != M.end(); it++) {
				string str = it->first;
				string str1 = str;
				reverse(str1.begin(), str1.end());
				if (it->second != M[str1]) { flag = 0; break; }
				if (str == str1) {
					if (!f && it->second & 1) { flag = 0; break; }
					if (it->second & 1) f = 0;
				}
			}
			if (flag) {
				printf("YES\n"); return 0;
			}
		} while (next_permutation(unused.begin(), unused.end()));
	}
	printf("NO\n");
	return 0;
}

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

#define int long long

int a[205];
int l,r,n;
signed main()
{
	cin >> n >> l;/*
	r = l+n-1;
//	cout<<r<<"\n";
	if(l < 0 && r > 0) 
	{
	//	cout<<(l+r)<<"\n";
		cout<<(l+r)*n/2<<"\n";
		return 0; 
	}else {
		int ans = (l+r)*n/2;
		if(l < 0 && r < 0) ans -= r;
		else ans -= l;
		cout<<ans<<"\n";
	}*/
	int ans = 0,an = 0x3f3f3f3f,x;
	for(int i = l; i <= l+n-1; i ++)
	{
		ans += i;
		if(abs(i) < an)
		{
			an = abs(i);
			x = i;
		}
	}
	cout<<ans-x<<"\n";
	return 0;
}
/*
200 200
*/

Measured memory_bytes: 256
n = int(input())
h_list = [int(x) for x in input().split()]

temp = 0
ans = 0
for i in range(n - 1):
    if h_list[i] >= h_list[i + 1]:
        temp += 1
    else:
        ans = temp if ans < temp else ans
        temp = 0
ans = temp if ans < temp else ans
print(ans)

Measured memory_bytes: 14252
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define lvector vector<ll>
#define lque queue<ll>
#define lpque priority_queue<ll>
#define dlpque priority_queue<ll,lvector,greater<ll>>
#define P pair<ll,ll>
#define ALL(a) (a).begin(),(a).end()
#define rep(i,n) for(ll (i)=0; (i)<(n); ++(i))
#define print(a) cout << (a) << endl

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  ll h,ans=0,val=1;cin>>h;
  while(h>0) {
    h/=2;
    ans+=val;
    val*=2;
  }
  print(ans);
  return 0;
}

Measured memory_bytes: 256
package main

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

// input scanner
var sc = bufio.NewScanner(os.Stdin)

const (
	initialBufSize = 10e4
	maxBufSize     = 10e6
)

func next() string {
	sc.Scan()
	return sc.Text()
}

func nextInt() int {
	a, _ := strconv.Atoi(next())
	return a
}

func nextInt64() int64 {
	a, _ := strconv.ParseInt(next(), 10, 64)
	return a
}

func nextFloat64() float64 {
	a, _ := strconv.ParseFloat(next(), 64)
	return a
}

func nextInts(n int) []int {
	ret := make([]int, n)
	for i := 0; i < n; i++ {
		ret[i] = nextInt()
	}
	return ret
}
func nextFloats(n int) []float64 {
	ret := make([]float64, n)
	for i := 0; i < n; i++ {
		ret[i] = nextFloat64()
	}
	return ret
}
func nextStrings(n int) []string {
	ret := make([]string, n)
	for i := 0; i < n; i++ {
		ret[i] = next()
	}
	return ret
}

// util
func max(l []int) (int, int) {
	idx := 0
	ans := l[idx]
	for i, n := range l {
		if n > ans {
			idx = i
			ans = n
		}
	}
	return idx, ans
}

func min(l []int) (int, int) {
	idx := 0
	ans := l[idx]
	for i, n := range l {
		if n < ans {
			idx = i
			ans = n
		}
	}
	return idx, ans
}

// main
func main() {
	buf := make([]byte, initialBufSize)
	sc.Buffer(buf, maxBufSize)
	sc.Split(bufio.ScanWords)
	s := next()
	if len(s)%2 != 0 {
		fmt.Println("No")
		return
	}
	for i := 0; i < len(s)-1; i += 2 {
		ss := s[i : i+2]
		if ss != "hi" {
			fmt.Println("No")
			return
		}
	}
	fmt.Println("Yes")
}


Measured memory_bytes: 640
// tsukasa_diary's programing contest code template
#include <bits/stdc++.h>
using namespace std;
#define TSUKASA_DIARY_S_TEMPLATE
// define
#define for_(i,a,b) for(int i=(a);i<(b);++i)
#define for_rev(i,a,b) for(int i=(a);i>=(b);--i)
#define allof(a) (a).begin(),(a).end()
#define minit(a,b) memset(a,b,sizeof(a))
#define size_of(a) int((a).size())
#define cauto const auto
// typedef
typedef long long lint;
typedef double Double;
typedef pair< int, int > pii;
template< typename T > using Vec = vector< T >;
template< typename T > using Matrix = Vec< Vec< T > >;
template< typename T > using USet = unordered_set< T >;
template< typename T, class C > using MyUSet = unordered_set< T, C >;
template< typename T, typename F > using UMap = unordered_map< T, F >;
template< typename T, typename F, class C > using MyUMap = unordered_map< T, F, C >;
// hash
class PiiHash { public: size_t operator () (const pii& p) const { return (p.first << 16) | p.second; } };
// popcount
inline int POPCNT(int x) { return __builtin_popcount(x); }
inline int POPCNT(lint x) { return __builtin_popcount(x); }
// inf
const int iINF = 1L << 30;
const lint lINF = 1LL << 60;
// eps
const Double EPS = 1e-9;
const Double PI = acos(-1);
// inrange
template< typename T >
inline bool in_range(T v, T mi, T mx) { return mi <= v && v < mx; }
template< typename T >
inline bool in_range(T x, T y, T W, T H) { return in_range(x,0,W) && in_range(y,0,H); }
// neighbor clockwise
const int DX[4] = {0,1,0,-1}, DY[4] = {-1,0,1,0};
const int DX_[8] = {0,1,1,1,0,-1,-1,-1}, DY_[8] = {-1,-1,0,1,1,1,0,-1};
// variable update
template< typename T > inline void modAdd(T& a, T b, T mod) { a = (a + b) % mod; }
template< typename T > inline void modMul(T& a, T b, T mod) { a = (a * b) % mod; }
template< typename T > inline void minUpdate(T& a, T b) { a = min(a, b); }
template< typename T > inline void maxUpdate(T& a, T b) { a = max(a, b); }
// converter
template< typename F, typename T >
inline void convert(F& from, T& to) {
	stringstream ss;
	ss << from; ss >> to;
}

int getLastBit(lint X) {
	int cnt = 0;
	while (X) {
		X >>= 1;
		++cnt;
	}
	return cnt-1;
}

lint rec(lint X, lint Y) {
	if (X == Y) return 1;
		
	int lx = getLastBit(X), ly = getLastBit(Y);
	if (lx == ly) return rec(X ^ (1LL << lx), Y ^ (1LL << ly));
	
	int r = ly, k = getLastBit(Y ^ (1LL << ly));
	lint a = (1LL << r) - X;
	lint b = (1LL << r) - 1;
	lint c = (1LL << r) + (1LL << (k+1));
	lint d = (1LL << r) + X;
	lint e = (1LL << (r+1));
	
	return a + (c - b) + (c > d ? e - c : e - d) - 1;
}

int main() {
	lint A, B;
	cin >> A >> B;
	cout << rec(A, B) << endl;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(){
	int n,m;
	int a[100][100];
	int b[100],c[100]={0};
	int i,t;
	scanf("%d %d",&n, &m);
	for(i = 0;i < n; i++){
		for(t = 0;t < m; t++){
			scanf("%d", &a[i][t]);
		}
	}
	for(t =0;t < m; t++){
		scanf("%d", &b[t]);
	}
	for(i = 0;i < n; i++){
		for(t = 0;t < m; t++){
			c[i] += a[i][t] * b[t];
		}
	}
	for(i = 0;i < n; i++){
		printf("%d\n", c[i]);
	}
	return 0;
}

Measured memory_bytes: 640
# https://atcoder.jp/contests/abc152/tasks/abc152_e

# 1 <= i < j <= N (i < j)について AiBi = AjBjが成り立つBの和の最小値
# LCM/Ai

from collections import defaultdict
from math import gcd

MOD = 10 ** 9 + 7

N = int(input())
A = list(map(int, input().split()))

lcm = A[0]
for a in A:
    lcm = (lcm * a) // gcd(lcm, a)
lcm %= MOD

# フェルマーの小定理 a^{P-1} = 1 (mod P)
ans = 0
for a in A:
    ans += lcm * pow(a, MOD - 2, MOD) % MOD
    ans %= MOD
print(ans)

Measured memory_bytes: 74664
#include <stdio.h>
int main(int argc, const char * argv[])
{
    int W, H;
    int i, j;
    while (1) {
        scanf("%d %d", &W, &H);
        if (W==0 && H==0) {
            break;
        }
        for (i=0; i<W; i++) {
            for (j=0; j<H; j++) {
                printf("#");
            }
            printf("\n");
        }
        printf("\n");
    }
    
    return 0;
}



Measured memory_bytes: 2104
#include<stdio.h>
#include<string>
#include<iostream>
#include<math.h>
#include<vector>
#include<set>
#include<algorithm>
#include<list>
using namespace std;

int main() {
	int K, S, num = 0;
	cin >> K >> S;
	for (int X = 0;X <= K;X++) {
		for (int Y = 0;Y <= K;Y++) {
			if ((0 <= S - X - Y)&&(S-X-Y <= K))num++;
			}
		}
	cout << num << endl;
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define f(i,x,n) for(int i=x;i<(int)(n);++i)
#define all(x) (x).begin(),(x).end()
const int mod=1000000007,MAX=50005,INF=1<<29;

int main(){
    
    std::ifstream in("text.txt");
    std::cin.rdbuf(in.rdbuf());
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    while(1){
        int N;cin>>N;
        vector<int> S(200000,0);
        
        for(int i=0;i<N;i++){
            int a,b;cin>>a>>b;
            S[a]++;
            S[b+1]--;
        }
        
        for(int i=1;i<200000;i++) S[i]+=S[i-1];
        
        int ans=0;
        
        for(int i=1;i<200000;i++){
            if(S[i]+1>=i) ans=i-1;
        }
        
        cout<<ans<<endl;
        
        break;
    }
    
}



Measured memory_bytes: 3620
#include  <stdio.h>

int main() {
  int n,co=0,res=0,i,j;
  int A[10000];
  i=0;
  while(1){
    scanf("%d",&n);
    if(1<=n&&n<=10000){
      while(1){
	if(n==i) break;
	scanf("%d", &A[i]);
	if(2<=A[i]&&A[i]<=100000000) i++;
      }
      break;
    }
  }

  for(i=0;i<n;i++){
    if(A[i]==2) {
      res++;
      continue;
    }
    else if(A[i]%2==0) continue;
    if(A[i]==3){
      res++;
      continue;
    }
    j=3;
    while(j*j<=A[i]){
      if(A[i]%j==0) break;
      j=j+2;
    }
    if(A[i]%j==0) continue;
    res++;
  }

  printf("%d\n",res);
   
  return 0;
}



Measured memory_bytes: 2108
#pragma region
#include <bits/stdc++.h>
using namespace std;
inline void ci(void){
  return;
}
template <typename First, typename... Rest>
void ci(First& first, Rest&... rest){
  cin >> first;
  ci(rest...);
  return;
}
inline void co(void){
  cout << "\n";
  return;
}
template <typename First, typename... Rest>
void co(First first, Rest... rest){
  cout << first << " ";
  co(rest...);
  return;
}
#define ll long long
#define ld long double
#define st string
#define dl double
#define wh while
#define mp make_pair
#define mt make_tuple
#define pb push_back
#define tp tuple
#define ft first
#define sc second
#define ve vector
#define tos to_string
#define len length
#define rt return 0
#define br break
#define con continue
#define lcm(n, m) (n * m / gcd(n, m))
#define np next_permutation
#define repi(i, m, n) for(int i=(int)(m);i<(int)(n);i++)
#define rep(i, n) repi(i, 0, n)
#define repill(i, m, n) for(ll i=(ll)(m);i<(ll)(n);i++)
#define repll(i, n) repill(i, 0, n)
#define revi(i, m, n) for(int i=(int)(m);i>(int)(n);i--)
#define rev(i, m) revi(i, m, 0)
#define revill(i, m, n) for(ll i=(ll)(m);i>(ll)(n);i--)
#define revll(i, n) revill(i, 0, n)
#define sz(v) ((int)(v).size()) 
#define each(i, n) for(auto&& i: n)
#define all(n) (n.begin(), n.end())
#define allr(n) (n.rbegin(), n.rend())
#define sp(n) cout << fixed << setprecision(n)
#pragma endregion
// sqrt ルート, int 2*10^9, gcd　最大公約数
// __builtin_popcount bitの個数

int main() {
  ve<int> a(3);
  rep(i, 3){
    ci(a.at(i));
  }
  sort all(a);
  if(a.at(0) + a.at(1) == a.at(2)){
    co("Yes");
  }
  else{
    co("No");
  }
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main(){
	int i,j,k,p,n,ans=0;
	cin>>k>>n;
	for(i=0;i<=k;i++){
		for(j=0;j<=k;j++){
			p=n-i-j;
			if(p>=0&&p<=k) ans++;
		}
	}
	cout<<ans<<endl;
}

Measured memory_bytes: 256
mod = 998244353
max = (10**5)*2 + 1
facts = [1 for i in range(max)]
invs = [1 for i in range(max)]
 
def inv(x):
    return pow(x,mod-2,mod)
 
for i in range(1,max):
    facts[i] = facts[i-1]*i%mod
    invs[i] = inv(facts[i])
 
def nCk(n,r):
    return facts[n]*invs[r] * invs[n-r] % mod



N, M, K = map(int, input().split())
ans = 0
for i in range(K+1):
    ans += pow(M-1, N-1-i, mod) * nCk(N-1, i)
    ans %= mod
ans *= M
print(ans%mod)

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

int main(){
	// n := 人数
	int n;
	while( cin >> n , n ){
		// s[i][j] := i が j さんの個人情報を知っているかどうか.
		int s[101][101] = {0};
		
		for(int i=0 ; i < n ; i++ ){
			int m;
			cin >> m;
			for(int j=0 ; j < m ; j++ ){
				int p;
				cin >> p;
				p--;
				// i さんは p さんの個人情報を知っている.
				s[i][p] = 1;
			}
		}
		// k := 個人情報が漏洩した人数.
		int k;
		cin >> k;
		// L := 個人情報が漏洩した人の番号を保持する配列.
		vector<int> L(k);
		for(int i=0 ; i < k ; i++ ){
			cin >> L[i];
			L[i]--;
		}
		
		// ans := 個人情報を漏らした可能性のある人の番号を保持する配列.
		vector<int> ans;
		
		for(int y=0 ; y < n ; y++ ){
			bool flag = true;
			// foo := y さんが知っている人の番号を保持する配列
			vector<int> foo;
			for(int x=0 ; x < n ; x++ ){
				if( s[y][x] ) foo.push_back( x );
			}
			for(int i=0 ; i < L.size() ; i++ ){
				// y さんは L[i] さんの情報を漏らした可能性がなければ flag を false にしておく.
				if( count(foo.begin(), foo.end(), L[i] ) == 0 ){
					flag = false;
				}
			}
			// y さん が個人情報を漏らした可能性のある人なら ans に追加.
			if( flag ) ans.push_back( y );
		}
		
		// 個人情報を漏らした可能性のある人物が一人だけならその番号を出力, そうでなければ -1 を出力.
		if( ans.size() == 1 ){
			cout << (ans[0]+1) << endl;
		}else{
			cout << -1 << endl;
		}
	}
}

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

#define rep(i, n) for (int i = 0; i < n; ++i)
#define ALL(a) (a).begin(), (a).end()
#define rALL(a) (a).rbegin(), (a).rend()
#define SZ(x) ((int)(x).size())
using ll = long long;
using P = pair<int, int>;
using llP = pair<ll, ll>;
using DoP = pair<double, double>;
const int di[] = {0, 1, 0, -1, 1, 1, -1, -1};
const int dj[] = {1, 0, -1, 0, 1, -1, 1, -1};
const int INF = 1 << 29;
const ll INF64 = 1ll << 55;
const int mod = 1000000007;
//const int mod = 998244353;

template <class T>inline bool chmin(T &a, const T b)
{
  if (a > b)
  {
    a = b;
    return true;
  }
  return false;
}
template <class T>inline bool chmax(T &a, const T b)
{
  if (a < b)
  {
    a = b;
    return true;
  }
  return false;
}
template <class T>inline void line_out(const vector<T> vec) {
  int n = SZ(vec);
  rep(i, n) {
    cout << vec[i];
    if(i < n-1) cout << " ";
  }
  cout << endl;
  return;
}

struct mint
{
  ll x; // typedef long long ll;
  mint(ll x = 0) : x((x % mod + mod) % mod) {}
  mint operator-() const { return mint(-x); }
  mint &operator+=(const mint a)
  {
    if ((x += a.x) >= mod)
      x -= mod;
    return *this;
  }
  mint &operator-=(const mint a)
  {
    if ((x += mod - a.x) >= mod)
      x -= mod;
    return *this;
  }
  mint &operator*=(const mint a)
  {
    (x *= a.x) %= mod;
    return *this;
  }
  mint operator+(const mint a) const
  {
    mint res(*this);
    return res += a;
  }
  mint operator-(const mint a) const
  {
    mint res(*this);
    return res -= a;
  }
  mint &operator++()
  {
    if ((x += 1) >= mod)
      x -= mod;
    return *this;
  }
  mint &operator--()
  {
    if ((x += mod - 1) >= mod)
      x -= mod;
    return *this;
  }
  mint operator*(const mint a) const
  {
    mint res(*this);
    return res *= a;
  }
  mint pow(ll t) const
  {
    if (!t)
      return 1;
    mint a = pow(t >> 1);
    a *= a;
    if (t & 1)
      a *= *this;
    return a;
  }

  // for prime mod
  mint inv() const
  {
    return pow(mod - 2);
  }
  mint &operator/=(const mint a)
  {
    return (*this) *= a.inv();
  }
  mint operator/(const mint a) const
  {
    mint res(*this);
    return res /= a;
  }
};

int main()
{
  int n;
  ll X;
  cin >> n >> X;
  vector<ll> x(n);
  rep(i, n) cin >> x[i];
  x.push_back(X);
  sort(ALL(x));
  ll ans = x[1]-x[0];
  for(int i = 0; i < n; ++i) ans = __gcd(ans, x[i+1]-x[i]);
  cout << ans << endl;
}


Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
struct rev_vector {
	const int magic = 123456;
	vector<int> pk;
	int l, r;
	rev_vector(){
		pk.resize(3 * magic);
		l = magic;
		r = l;
	}
	void shift_right(){
		l--;
		pk[l] = 0;
	}
	int& operator [](int pos){
		while(pos + l <= r) pk[r++] = 0;
		return pk[pos + l];
	}
	void clear(){
		l = magic;
		r = l;
	}
};
const int maxn = 100100;
int ans, k, vis[maxn];
vector<int> e[maxn];
int dfs(int u){
	int dep = 0;
	for(int v : e[u]) {
		int mv = dfs(v);
		if(mv == k - 1 && u){
			ans++;
		} else {
			dep = max(dep, mv + 1);
		}
	}
	return dep;
}
int main(){
	int n; cin >> n >> k;
	vector<int> a(n);
	for(int i = 0; i < n; i++) cin >> a[i], a[i]--;
	if(a[0] != 0){
		a[0] = 0;
		ans++;
	}
	for(int i = 0; i < n; i++){
		if(i != a[i]){
			e[a[i]].push_back(i);
		}
	}
	dfs(0);
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 10752