akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
#define llu unsigned long long
#define ll long long
#define INF 0x3f3f3f3f
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define endl "\n"

using namespace std;


template <typename T> 
inline void inp(T &any) {
    cin >> any;
}
template <typename T, typename... U> 
inline void inp(T &a, U &...b) {
    cin >> a; inp(b...);
}
// scan vector
template <typename T> 
inline istream &operator>>(istream &in, vector<T> &a) {
    for(auto &x : a) in >> x;
    return in;
}
// scan pair
template <typename T, typename U> 
inline istream &operator>>(istream &in, pair<T,U> &a) {
    in >> a.first >> a.second; 
    return in;
}

int main()	
{
	#ifdef SANS
		freopen("C:\\Users\\ASUS\\Documents\\Sublime\\input_output\\inputf.txt","r",stdin);
		freopen("C:\\Users\\ASUS\\Documents\\Sublime\\input_output\\outputf.txt","w",stdout);
	#endif
	fast
	int t=1;
	// cin>>t;
	while(t--)
	{
		long double a,b;
		cin>>a>>b;
		std::cout<<std::setprecision(17);
		cout<<floor(a*b);
	}
	#ifdef SANS
		cout<<"\nTime Elapsed:"<<1.0*clock()/CLOCKS_PER_SEC <<"sec\n";
	#endif
}

Measured memory_bytes: 3812
#include<bits/stdc++.h>
using namespace std;
 
#define ll long long
#define pb push_back
 
const int maxn = 2e5 + 20;

int a[maxn];

void prnt(vector<int> x)
{
	vector<int> tmp;
	for(auto a : x)
		if(a)
			tmp.pb(a);

	cout << tmp.size() << endl;
	for(auto x : tmp)
		cout << x << " ";
	cout << endl;
}

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

	int n , m;
	cin >> n >> m;

	for(int i = 0; i < m; i++)
		cin >> a[i];

	if(m == 1)
	{
		cout << a[0] << endl;
		prnt({a[0] - 1 , 1});
		return 0;
	}

	vector<int> x , y;
	for(int i = 0; i < m; i++)
	{
		if(a[i] & 1)
			x.pb(a[i]);
		else
			y.pb(a[i]);
	}

	if((int)x.size() > 2)
		return cout << "Impossible" << endl , 0;

	if((int)x.size() >= 1)
		y.insert(y.begin() , x[0]);
	if((int)x.size() >= 2)
		y.pb(x[1]);

	for(auto x : y)
		cout << x << " ";
	cout << endl;
	y[0]--;
	y.back()++;
	prnt(y);
}


















Measured memory_bytes: 256
#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))
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 { return mint(*this) += a;}
  mint operator-(const mint a) const { return mint(*this) -= a;}
  mint operator*(const mint a) const { return mint(*this) *= 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 { return mint(*this) /= a;}
};
istream& operator>>(istream& is, const mint& a) { return is >> a.x;}
ostream& operator<<(ostream& os, const mint& a) { return os << a.x;}
int in() {int x; cin>>x; return x;}
string stin() {string s; cin>>s; return s;}
/***** MAIN *****/
signed main() {
  int n = in();
  int weis[n];
  REP(i,n) {
    cin >> weis[i];
  }
  vector<int> left_v(n), right_v(n);
  REP(i,n) {
    left_v[i] = i - weis[i];
    right_v[i] = i + weis[i];
  }
  SORT(left_v); SORT(right_v);
  int ans = 0;
  REP(i,n) {
    int right = right_v[i];
    auto itr = lower_bound(ALL(left_v), right);
    if(itr == left_v.end()) continue;
    auto itr2 = upper_bound(itr, left_v.end(), right);
    int counter = distance(itr, itr2);
    // int index = itr - left_v.begin();
    // int counter = 0;
    // REPS(j, index, n) {
    //   if(left_v[j] != right) break;
    //   ++counter;
    // }
    ans += counter;
  }
  cout << ans;
  cout << "\n";
  return 0;
}
/***** MAIN *****/


Measured memory_bytes: 8012
#include <bits/stdc++.h>
#include <string.h>
#include <numeric>

using namespace std;

///////////////////////////////////////////
//const long long int INF = 1000000000000000000LL;
const long long int INF = 1000000;
using ll = long long int;
using vi = vector<int>;
using Vi = vector<long long int>;
#define pb push_back
#define all(x) (x).begin(),(x).end()
#define rep(i,N) for(int i=0;i<N;i++)
auto max(auto x,auto y){if(x>y){return x;}else{return y;}}
auto min(auto x,auto y){if(x>y){return y;}else{return x;}}
template<class T>bool chmax(T &former, const T &b) { if (former<b) { former=b; return true; } return false; }
template<class T>bool chmin(T &former, const T &b) { if (b<former) { former=b; return true; } return false; }
template<class T>T sqar(T x){ return x*x; }
#define Sort(v) std::sort(v.begin(), v.end(), std::greater<decltype(    v[0])>()) //降順でVをソート
///////////////////////////////////////////

ll n;
ll box[201]={0};
int cal(int x){
    ll ans = 0;
    rep(i,x){
        if(i==0){

        }else if(x%i==0){
            ans++;
        }else{
            //no action
        }
    }
    return box[x]=ans+1;
}

int main(){
    cin>>n;
    ll ans=0;
    for(int i=1;i<=n;i++){
        if(i%2==1 && cal(i)==8){
            ans++;
        }
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 256
def solve():
  x, y = map(int, input().split())
  ans = float('inf')
  if y>=x:
    ans = min(ans,y-x)
  if y>=-x:
    ans = min(ans,y+x+1)
  if -y>=x:
    ans = min(ans,-y-x+1)
  if -y>=-x:
    ans = min(ans,-y+x+2)
  return ans
print(solve())

Measured memory_bytes: 9128
import numpy as np
import itertools #from itertools import *
N,M=map(int,input().split())
G=np.zeros((N+1,N+1),dtype=np.int32)
for i in range(M):
  a,b=map(int,input().split())
  G[a][b]=1
  G[b][a]=1
#print(G)
ans=0
for i in itertools.permutations(range(2,N+1)):
  cnt=0
  for j in range(N-2):
    if G[i[j]][i[j+1]]!=0:
      cnt+=1
  if G[1][i[0]]==1:
    cnt+=1
  if cnt==N-1:
    ans+=1
print(ans)

Measured memory_bytes: 14400
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define all(x) (x).begin(),(x).end()
#define SZ(x) ((int)(x).size())
#define bit(n) (1<<(n))
#define ii(x) int x; cin >> (x)
#define ii2(x, y) int x, y; cin >> (x) >> (y)
#define ii3(x, y, z) int x, y, z; cin >> (x) >> (y) >> (z)
#define yn(x, ok, ng) cout << ((x)?(ok):(ng)) << endl
using namespace std;
typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vi> vvi;
typedef vector<bool> vb;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
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;}
ll gcd(ll a, ll b) { return b?gcd(b,a%b):a;}
ll lcm(ll a, ll b) { return a/gcd(a,b)*b;}
int const INF = 1001001001;

map< ll, int > prime_factor(ll n) {
  map< ll, int > ret;
  for(ll i = 2; i * i <= n; i++) {
    while(n % i == 0) {
      ret[i]++;
      n /= i;
    }
  }
  if(n != 1) ret[n] = 1;
  return ret;
}

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

ll n; cin >> n;
map<ll,int> mp = prime_factor(n);
ll cnt = 0;
for(auto x : mp) {
    for(ll m = 1;m < 50; ++m) {
        if(x.second < m*(m+1)/2) {
            cnt += m-1;
            break;
        }
    }
}
cout << cnt << endl;
return 0;
}

Measured memory_bytes: 3660
#include <iostream>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <bitset>
#include <algorithm>
typedef long long ll;
using namespace std;
const int maxn=5100;
const ll mod=1000000000+7;
char sz[maxn];
ll f[maxn];
int n,len;
ll dp[maxn][maxn];

ll fast_pow(ll a,ll b){
    ll res=1;
    while(b){
        if(b%2==1) res=(res*a)%mod;
        a=(a*a)%mod;
        b=b/2;
    }
    return res;
}

int main(){
    scanf("%d",&n);
    scanf("%s",sz+1);
    len=strlen(sz+1);
    f[0]=1;
    for(int i=1;i<=len;i++) f[i]=(f[i-1]*2)%mod;
    dp[0][0]=1;
    dp[1][0]=1;dp[1][1]=2;
    for(int i=1;i<=n;i++){
        for(int j=0;j<=i;j++){
            dp[i+1][j+1]=(dp[i+1][j+1]+2*dp[i][j])%mod;
            dp[i+1][max(j-1,0)]=(dp[i+1][max(j-1,0)]+dp[i][j])%mod;
        }
    }
    printf("%lld\n",(dp[n][len]*fast_pow(f[len],mod-2))%mod);
    return 0;
}

Measured memory_bytes: 199296
#include<string>
#include<iostream>
using namespace std;
string A,B;
int i=0;
int main(){
  cin>>A>>B;
  if(A.length()>B.length()){
   cout<<"GREATER"<<endl;
  }else if(A.length()<B.length()){
      cout<<"LESS"<<endl;
  }else{
    while(i<A.length()){
    if(A[i]>B[i]){
      cout<<"GREATER"<<endl;
      break;
    }else if(A[i]<B[i]){
      cout<<"LESS"<<endl;
      break;
    }
      i++;
    }
  if(i==A.length())cout<<"EQUAL"<<endl;
  } 
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < n; ++i)
#define rrep(i, n) for(int i = n-1; i >= 0; --i)
#define fi first
#define se second
using namespace std;
using lint = long long;
using uint = unsigned int;
using ulint = unsigned long long;
using ldouble = long double;
using pii = pair<int, int>;
using pli = pair<lint, lint>;
using pdd = pair<double, double>;
using pld = pair<ldouble, ldouble>;
using v1i = vector<int>;
using v1li = vector<lint>;
using v2i = vector<vector<int>>;
using v2li = vector<vector<lint>>;
using v3i = vector<vector<vector<int>>>;
using v3li = vector<vector<vector<lint>>>;
using v1b = vector<bool>;
using v2b = vector<vector<bool>>;
using v3b = vector<vector<vector<bool>>>;
using v1c = vector<char>;
using v2c = vector<vector<char>>;
using v3c = vector<vector<vector<char>>>;
constexpr lint mod1 = 1e9+7;
constexpr lint mod2 = 998244353;

int main() {
  string s, t; cin >> s;
  int a = s[0]-'0', b = s[1]-'0', c = s[2] - '0', d = s[3] -'0';
  rep(i, 8){
    t = "";
    t += (char)a+'0';
    int u = a;
    if(i & 1 << 0){
      t += '+';
      t += (char)b+'0';
      u += b;
    }
    else{
      t += '-';
      t += (char)b+'0';
      u -= b;
    }
    if(i & 1 << 1){
      t += '+';
      t += (char)c+'0';
      u += c;
    }
    else{
      t += '-';
      t += (char)c+'0';
      u -= c;
    }
    if(i & 1 << 2){
      t += '+';
      t += (char)d+'0';
      u += d;
    }
    else{
      t += '-';
      t += (char)d+'0';
      u -= d;
    }
    if(u == 7) break;
  }
  t += "=7";
  cout << t << "\n";
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,N) for(int i=0;i<int(N);++i)
using ll = long long;
const int MOD = 1e9 + 7;
const int INF = 2147483647;
// const ll INF = 1000000000000000000LL;

int main(){
    ll n;
    cin >> n;
    vector<pair<ll,ll>> pr(n);
    vector<ll> minus(n);
    vector<ll> add(n);
    rep(i,n){
        cin >> pr[i].first;
        pr[i].second = i+1;
        add[i] = pr[i].second + pr[i].first;
        minus[i] = pr[i].second - pr[i].first;
    }
    sort(minus.begin(),minus.end());
    ll cnt = 0;
    rep(i,n){
        ll key = add[i];
        auto upper_Iter = upper_bound(minus.begin(),minus.end(),key);
        auto lower_Iter = lower_bound(minus.begin(),minus.end(),key);
        cnt += upper_Iter - lower_Iter;
    }
    cout << cnt << endl;
    return 0;    
}

Measured memory_bytes: 9592
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <stdio.h>
#include <queue>
#include <stack>
#include <climits>
#include <map>
#include <set>

const int mod = 1e9 + 7;
const int inf = 1e9;
const long long INF = 1LL << 60;
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
using namespace std;

struct edge {ll from,to,cost;};

int main()
{
    int n;
    cin >> n;
    vector<string> s;
    for(int i = 0; i < n; i++){
        string k;
        cin >> k;
        sort(k.begin(),k.end());
        s.push_back(k);
    }
    sort(s.begin(),s.end());
    string tmp = s[0];
    int cnt = 1;
    ll ans = 0;
    ll a = 1;
    while(true){
        if(cnt == n){
            ans += ((a * (a-1))/2);
            break;
        }
        if(tmp == s[cnt] ){
            a++;
        }else{
            ans += ((a * (a-1))/2);
            tmp = s[cnt];
            a = 1;
        }
        cnt++;
    }
    cout << ans << endl;
}

Measured memory_bytes: 5748
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);

        int N = sc.nextInt();
        int T = sc.nextInt();

        int[] costArr = new int[N];
        int[] timeArr = new int[N];
        for (int i = 0; i < N; i++) {
            costArr[i] = sc.nextInt();
            timeArr[i] = sc.nextInt();
        }

        int minCost = Integer.MAX_VALUE;

        for (int i = 0; i < N; i++) {
            if (timeArr[i] <= T) {
                minCost = Math.min(minCost, costArr[i]);
            }
        }

        if (minCost > 1000) {
            System.out.println("TLE");
        } else {
            System.out.println(minCost);
        }


        sc.close();
    }
}

Measured memory_bytes: 21844
#include<iostream>
#include<iomanip>
#include<cstdio>
#include<cmath>
#include<cstring>
#include<algorithm>
using namespace std;
int main(){
	int a;
	double b;
	cin>>a;
	b=(double)a/3*1.0;
	cout<<fixed<<setprecision(12)<<b*b*b*1.0<<endl;
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> iint;
typedef pair<ll,ll> llll;
#define ALL(x) (x).begin(),(x).end()
const ll zero = 0;
const ll INF = 3000000000000000000; //10^18
const int inINF = 1000000000; //10^9
const ll MOD = 1000000007; //10^9+7
const ll MOD2 = 998244353;

int main(){
    int D; cin >> D;
    vector<int> c(27);
    for (int i = 1; i < 27; i++) {
        cin >> c[i];
    }

    vector<vector<int>> s(D+1, vector<int> (27));
    for (int i = 1; i < D+1; i++) {
        for (int j = 1; j < 27; j++) {
            cin >> s[i][j];
        }
    }

    vector<int> t(D+1);
    for (int i = 1; i < D+1; i++) {
        cin >> t[i];
    }


    // そのコンテストが開催された日の集合
    vector<set<int>> day(27, set<int> ());
    for (int i = 1; i < D+1; i++) {
        day[t[i]].insert(i);
    }
    for (int i = 1; i < 27; i++) {
        day[i].insert(0);
        day[i].insert(D+1);
    }

    // 元のスコアを計算。
    ll score = 0;
    int d1, d2;
    auto itr1 = day[1].lower_bound(0);
    for (int d = 1; d < D+1; d++) {
        score += s[d][t[d]];
        d2 = d;
        itr1 = day[t[d]].lower_bound(d);
        itr1--;
        d1 = *itr1;
        score -= c[t[d]] * (d2-d1-1) * (d2-d1) / 2;
    }
    for (int q = 1; q < 27; q++) {
        d2 = D + 1;
        itr1 = day[q].lower_bound(D+1);
        itr1--;
        d1 = *itr1;
        score -= c[q] * (d2-d1-1) * (d2-d1) / 2;
    }


    // 更新していく
    int M;
    cin >> M;
    int dd, qq;
    for (int i = 0; i < M; i++) {
        cin >> dd >> qq; //dd日目をt[dd]からqqに変更
        day[t[dd]].erase(dd);

        score += s[dd][qq];
        score -= s[dd][t[dd]];
        
        itr1 = day[qq].lower_bound(dd);
        d2 = *itr1;
        itr1--;
        d1 = *itr1;
        score += c[qq] * (dd - d1) * (d2 - dd);

        itr1 = day[t[dd]].lower_bound(dd);
        d2 = *itr1;
        itr1--;
        d1 = *itr1;
        score -= c[t[dd]] * (dd - d1) * (d2 - dd);

        // tとsetを更新
        t[dd] = qq;
        day[qq].insert(dd);
        printf("%lld\n", score);

    }





}

Measured memory_bytes: 3716
#include <stdio.h>
//#include <stdlib.h>
//#include <string.h>
//#include <stdbool.h>
//#include <limits.h>
//#include <math.h>

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


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

using namespace std ; 

const int N =1e6 + 7 ; 

int n , k ;  
long long C ; 
using ll = long long ; 

const long long inf = 2e18 ;
 
struct LiChao_min
{
    struct line
    {
        int64_t a, b;
        line() { a = 0; b = 0; }
        line(int64_t _a, int64_t _b) { a = _a; b = _b; }
        int64_t eval(int x) { return a * 1ll * x + (int64_t)b; }
    };
 
    struct node
    {
        node *l, *r; line f;
 
        node() { f = line(); l = nullptr; r = nullptr; }
        node(int64_t a, int64_t b) { f = line(a, b); l = nullptr; r = nullptr; }
        node(line v) { f = v; l = nullptr; r = nullptr; }
    };
 
    typedef node* pnode;
 
    pnode root; int sz;
    void init(int _sz) { sz = _sz + 1; root = nullptr; }
 
    void add_line(int64_t a, int64_t b) { line v = line(a, b); insert(v, -sz, sz, root); }
    int64_t query(int x) { return query(x, -sz, sz, root); }
 
    void insert(line &v, int l, int r, pnode &nd)
    {
        if(!nd) { nd = new node(v); return; }
 
        int64_t trl = nd->f.eval(l), trr = nd->f.eval(r);
        int64_t vl = v.eval(l), vr = v.eval(r);
 
        if(trl <= vl && trr <= vr) return;
        if(trl > vl && trr > vr) { nd->f = v; return; }
 
        int mid = (l + r) >> 1;
        if(trl > vl) swap(nd->f, v);
        if(nd->f.eval(mid) < v.eval(mid)) insert(v, mid + 1, r, nd->r);
        else swap(nd->f, v), insert(v, l, mid, nd->l);
    }
 
    int64_t query(int x, int l, int r, pnode &nd)
    {
        if(!nd) return inf;
        if(l == r) return nd->f.eval(x);
 
        int mid = (l + r) >> 1;
        if(mid >= x) return min(nd->f.eval(x), query(x, l, mid, nd->l));
        return min(nd->f.eval(x), query(x, mid + 1, r, nd->r));
    }
};
 
LiChao_min tree ;

long long dp[N] ;

int main(){

        ios_base::sync_with_stdio(0) ; 
        cin.tie(0) ; 
        //freopen("in.in" , "r" ,stdin) ; 

        cin >> n >> C ;

        tree.init(1e6 + 10) ;
        for(int i = 0 ;i < n;i++){
                long long x ; 
                cin>> x ; 

                if(i){
                        dp[i] = 1LL * x * x + tree.query(x)  + C ; 
                }

                tree.add_line( -2LL * x, dp[i] + x * x ) ; 
        }

        cout<< dp[n-1] ; 
        return 0; 
}


Measured memory_bytes: 14468
#include<iostream>
using namespace std;
 
int main(){
  int n;
  int a;
  int max;
  int min;
  long long sum;
  cin >> n;
  for(int i=0; i<n; i++){
    cin >> a;
    if(i == 0){
      max = a;
      min = a;
      sum = a;
    } else{
      if(max < a)max = a;
      if(min > a)min = a;
      sum += a;
    }
  }
  cout << min << " "<< max << " " << sum << endl;
  return 0;
}

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

namespace Atcoder
{
    class Program
    {
        static void Main(string[] args)
        {
            var a = ReadStringToCharArray();
            var b = ReadStringToCharArray();
            var c = ReadStringToCharArray();
            Console.WriteLine("{0}{1}{2}",a[0],b[1],c[2]);

        }

        static int[] ReadInt()
        {
            return Console.ReadLine().Split(' ').Select(x => int.Parse(x)).ToArray();
        }
        static char[] ReadStringToCharArray()
        {
            return Console.ReadLine().ToArray();
        }
    }
}



Measured memory_bytes: 13268
def dfs(v):
    stack.append(v)
    while len(stack)!=0:
        x = stack.pop()
        vis.append(x)
        for i in range(n):
            if graph[x][i]==False:
                continue
            if i in vis:
                continue
            if i in stack:
                continue
            stack.append(i)
 
n,m = map(int,input().split())
graph = []
for i in range(n):
    graph.append([False]*n)
a=[]
b=[]
for i in range(m):
    aa,bb = map(int,input().split())
    a.append(aa-1)
    b.append(bb-1)
for i in range(m):
    graph[a[i]][b[i]] = True
    graph[b[i]][a[i]] = True

ans=0
for i in range(m):
    graph[a[i]][b[i]]=False
    graph[b[i]][a[i]]=False
    vis=[]
    stack=[]
    dfs(0)
    bridge=False
    if len(vis) < n:
        bridge=True
    if bridge:
        ans+=1
    graph[a[i]][b[i]] = True
    graph[b[i]][a[i]] = True
print(ans)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
string sa,sb;
int f[3030][3030],pos[3030][3030][2];
void output(int i,int j)
{
	if(!i || !j)
		return ;
	output(pos[i][j][0],pos[i][j][1]);
	if(sa[i-1]==sb[j-1])
		cout<<sa[i-1];
	return ;	
}
int main()
{
	cin>>sa>>sb;
	for(int i=1;i<=sa.size();i++)
	{
		for(int j=1;j<=sb.size();j++)
		{
			if(sa[i-1]==sb[j-1])
			{
				f[i][j]=f[i-1][j-1]+1;
				pos[i][j][0]=i-1,pos[i][j][1]=j-1;
			}
			else
			{
				f[i][j]=max(f[i-1][j],f[i][j-1]);
				if(f[i-1][j]>f[i][j-1])
					pos[i][j][0]=i-1,pos[i][j][1]=j;
				else
					pos[i][j][0]=i,pos[i][j][1]=j-1;
			}
		}
	}
	output(sa.size(),sb.size());
	cout<<endl;
	return 0;
}


Measured memory_bytes: 110236
#include <algorithm>
#include <cstdio>
#include <iostream>
#include <map>
#include <math.h>
#include <queue>
#include <set>
#include <stack>
#include <vector>
using namespace std;
typedef long long int ll;
typedef long double ld;
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define Sort(Array) sort(Array.begin(), Array.end())
#define Reverse(a) reverse(a.begin(), a.end())
#define out(ans) cout << ans << endl;
const int MOD = 1000000007;
const int INF = 2147483647;

//------------↓------------- M -------------- E ---------------- M --------------- O ---------------↓--------------//
// コンパイル 
// g++ -std=c++1z
//
// -------型変換--------
// int を string に変換
// string s = to_string(n);
// string を int に変換
// int n = stoi(s);
//
// -------二分探索---------
// k以上の値が最初に現れる時のイテレータ O(logN)
// lower_bound(data.begin(), data.end(), k)
// kより大きい値が最初の現れる時のイテレータ O(logN)
// upper_bound(data.begin(), data.end(), k)
// kがdataに存在するかをtrue or falseで返す O(logN)
// binary_search(data.begin(), data.end(), k)
// 
//
//
//
//
//
// 
//------------↑------------- M -------------- E ---------------- M --------------- O ---------------↑--------------//


int func(int n) {
    if (n == 1) return 1;
    return n * func(n-1);
}


int main() {

    int N; cin >> N;
    int x[N], y[N];
    rep(i,N) cin >> x[i] >> y[i];

    vector<int> order(N);
    rep(i,N) order[i] = i;

    ld ans = 0;
    do {
        rep(i,N-1) {
            ans += sqrt(pow(x[order[i]] - x[order[i+1]], 2) + pow(y[order[i]] - y[order[i+1]], 2));
        }
    } while (next_permutation(order.begin(), order.end()));
    ans /= func(N);
    printf("%.12Lf\n", ans);
    

    return 0;
}










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

int main(){
    int K,S;
    cin>>K>>S;
    int count=0;
    int x,y,z;
    for(x=0;x<=K;x++){
        for(y=x;y<=K;y++){
            for(z=y;z<=K;z++){
                
                if(x+y+z == S){
                    if(x==y&&y==z){
                        count++;
                    }else if(x==y||y==z||z==x){
                       // cout<<x<<y<<z<<endl;
                        count += 3;
                    }else{
                        count +=6;
                   }
                }
            }
        }
    }
    cout<<count<<endl;

}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using int64 = long long;
#define int int64
#define rep(i, n) for(int i=0; i<n; i++)
#define FOR(i, a, b) for(int i=a; i<b; i++)
#define SORT(x) sort(x.begin(), x.end())
#define GSORT(x) sort(x.begin(), x.end(), greater<int>())
#define mk make_pair
#define fi first
#define se second
#define pb push_back
#define ALL(x) x.begin(), x.end()
#define V(T) vector<T>
typedef pair<int, int> P;
typedef pair<P, P> PP;
typedef vector<int> vi;
typedef vector<vi> vvi;
int max(int a, int b) {if(b>a) return b; else return a;}
int min(int a, int b) {if(b<a) return b; else return a;}


signed main() {
    int N, A;
    cin >> N >> A;
    
    if(N%500 <= A) cout << "Yes";
    else cout << "No";
    cout << endl;

    return 0;
}

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

ll facto(ll n){
    ll res=1;
    rep(i,n){
        res*=(i+1);
        res%=inf;
    }
    return res;
}

int main(){
    ll n,m;cin>>n>>m;
    if(n==m)cout<<((2*((facto(n)*facto(m))%inf))%inf)<<endl;
    else if(abs(n-m)==1)cout<<((facto(n)*facto(m))%inf)<<endl;
    else cout<<0<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
ll p = 1e9+7;
ll power(ll x, unsigned ll y)
{
    ll res = 1;
    x = x % p;
    while (y > 0)
    {
        if (y & 1)
            res = (res*x)%p;
        y = y>>1;
        x = (x*x)%p;
    }
    return res;
}
ll C(ll N,ll K)
{
	ll x=1,y=1;
	for(ll i=1;i<=K;i++)
	{
		x=x*(N-i+1)%p;
		y=y*i%p;
	}
	return x*power(y,p-2)%p;
}

int main()
{
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  ll n,a,b;
  cin >> n >> a >> b;
  ll t1 = (power(2,n) - 1 + p)%p;
  ll t2 = (t1 - C(n,a) + p )%p;
  ll t3 = (t2 - C(n,b) + p )%p;
  cout << t3;
}


Measured memory_bytes: 256
n,k=gets.split.map(&:to_i)
p=gets.split.map(&:to_f)
e=[]
sum=[0]
sum[1]=(p[0]+1)/2
ans=sum[1]
(2..n).each do |i|
  e[i]=(p[i-1]+1)/2
  sum[i]=sum[i-1]+e[i]
  ans=[ans,sum[i]-sum[i-k]].max if i-k>=0
end
p ans


Measured memory_bytes: 30016
#include <iostream>
#include <string>

using std::cout;
using std::endl;
using std::cin;
using std::string;

int main() {
	
	int battle_num;	// ???????????°
	string taro_card;	// ????????????????????¢??????????????????
	string hanako_card;	// ??±?????????????????¢??????????????????
	int taro_score = 0;	
	int hanako_score = 0;

	// ??\???
	cin >> battle_num;

	for (size_t i = 0; i < battle_num; i++)
	{
		cin >> taro_card;
		cin >> hanako_card;

		// ??????
		if (taro_card > hanako_card)
		{
			taro_score += 3;
		}
		else if (taro_card < hanako_card) {
			hanako_score += 3;
		}
		else
		{
			taro_score += 1;
			hanako_score += 1;
		}
	}
	cout << taro_score << " " << hanako_score << endl;
	return 0;
}

Measured memory_bytes: 3120
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<queue>
#include<functional>
#include<cmath>
#include<map>
using namespace std;
#define int long long
#define inf   1000000009
#define minf -1000000009

signed main() {
	int r, g;
	cin >> r >> g;
	cout << g * 2 - r << endl;
}

Measured memory_bytes: 256
#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() {
  vector<long> a(3);
  rep (i, 3) cin >> a[i];
  sort(a.begin(), a.end());
  long ans = 0;
  ans += a[1] - a[0];
  ans += a[2] - a[1];
  cout << ans << endl;
}

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


Measured memory_bytes: 256
#include <stdio.h>
#include <string.h>

int main(void)
{
	char str[1001], order[10], tmp[1001];
	int a, b, i, j, q;
	gets(str);
	scanf("%d", &q);
	for (i = 0; i < q; i++)
	{
		memset(tmp, 0, sizeof(tmp));
		scanf("%s", order);
		scanf("%d %d", &a, &b);
		if (strcmp(order, "print") == 0)
		{
			for (j = a; j <= b; j++)
			{
				putchar(str[j]);
			}
			putchar('\n');
		} else if (strcmp(order, "reverse") == 0)
		{
			for (j = 0; j <= b-a+1; j++)
			{
				tmp[j] = str[b - j];
			}
			strncpy(&str[a], tmp, b-a+1);
		} else if (strcmp(order, "replace") == 0)
		{
			scanf("%s", tmp);
			strncpy(&str[a], tmp, b-a+1);
		}
	}
	return 0;
}

Measured memory_bytes: 588
#include <iostream>
#include <cstring>
#include <cstdio>
#include <algorithm>
#include<cmath>
using namespace std;


int main()
{
    int n;
    cin>>n;
    cout<<24-n+24<<endl;
   /*   int T;
      scanf("%d",&T);
      while(T--)
      {

      }*/
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <cmath>
#define rep(i, n) for(int i = 0; i < n; i++)
using namespace std;

int main(){
  int n;
  cin >> n;
  vector<int> a(100, 0);
  rep(i, n+1){
    string s = to_string(i);
    int num = (s[0] - '0') * 10 + (s.back() - '0');
    a[num]++;
  }
  int ans = 0;
  rep(i, 101){
    if (i % 10 == 0) continue;
    int r = (i % 10) * 10 + (i / 10);
    ans += a[i] * a[r];
  }
  cout << ans << endl;
  
  return 0;
}

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

int main() {
  int n;cin>>n;
  long long ans=0;
  map<string,long long> m;
  for(int i=0;i<n;i++){
    string s; cin>>s;
    sort(s.begin(),s.end());
    m[s]++;
  }
  for(auto p:m)ans+=p.second*(p.second-1)/2;

cout<<ans<<endl;

}


Measured memory_bytes: 11136
#include <bits/stdc++.h>
#include <iostream>
#include <algorithm>
#include <ctype.h>
#include <math.h>
#include <stack>
#include <string>
#include <string.h>
using namespace std;
double PI = 3.1415926535897932;
long mod = 1000000007;

const long INF = (1<<30);

int main() {
  double x;
  cin >> x;
  double ans = x*x*x/27;
  cout << fixed << setprecision(8) << ans << endl;
}

Measured memory_bytes: 3776
#include <bits/stdc++.h>
using namespace std;
 
#define MOD (998244353)
#define f first
#define s second
#define pb(x) push_back(x)
#define mp(x,y) make_pair(x,y)
#define all(x) x.begin(), x.end()
#define print(vec,l,r) for(int i = l; i <= r; i++) cout << vec[i] <<" "; cout << endl;
#define forf(i,a,b) for(int i = (a); i < (b); i++)
#define forr(i,a,b) for(int i = (a); i > (b); i--)
#define input(vec,N) for(int i = 0; i < (N); i++) cin >> vec[i];
typedef long long int ll;
#define ld long double
const int N = 2e5+30;

vector < vector < int > > adj(N);
vector < int > vis(N,0);
int n,m;

vector<int> ans;

void dfs(int v) {
    vis[v] = true;
    for (int u : adj[v]) {
        if (!vis[u])
            dfs(u);
    }
    //cout<<v<<'\n';
    ans.push_back(v);
}

void topological_sort() {
    vis.assign(N, false);
    ans.clear();
    for (int i = 1; i <= n; ++i) {
        if (!vis[i])
            dfs(i);
    }
    reverse(ans.begin(), ans.end());
}

void solve(){
   //int n,m;
   cin>>n>>m;
   for(int i=1;i<=m;i++){
     int u,v;
     cin>>u>>v;
     adj[u].pb(v);
   }
   int dp[n+3];
   memset(dp,0,sizeof(dp));
   topological_sort();
   vis.assign(N, false);
   for(auto x : ans){
     //cout<<x<<"\n";
     if(!vis[x]){
       int s = x;
       queue < int > q;
       q.push(s);
       vis[s] = true;
       while(q.size()){
         int v = q.front();
         q.pop();
         for(auto u : adj[v]){
           dp[u] = max(dp[u],dp[v]+1);
           //cout<<u<<" "<<v<<" "<<dp[u]<<'\n';
         }
       }
     }
   }
   cout<<*max_element(dp+1, dp+n+1)<<'\n';
}

 
int main(){
 	ios_base::sync_with_stdio(false);
  cin.tie(NULL);
	int T;
  //cin >> T;
  //cout<<prs.size()<<'\n';
	T = 1;
  //visited[1]=1;
	while(T--){
		solve();
	}
}

Measured memory_bytes: 14960
#include <bits/stdc++.h>
using namespace std;
#pragma GCC optimize("Ofast")
typedef long long lint;
typedef unsigned int uint;
typedef pair<int, int> pii;
typedef pair<lint, lint> pll;
typedef unsigned long long ulint;
#define endl '\n'
#define fst first
#define sed second
#define pb push_back
#define mp make_pair
#define rint register int
#define SZ(x) (int((x).size()))
#define all(x) (x).begin(), (x).end()
#define reveal(x) cerr << #x << " = " << (x) << endl
#define rep(it, f, e) for (rint it = (f); it <= (e); ++it)
#define per(it, f, e) for (rint it = (f); it >= (e); --it)
#define repe(it, x) for (auto it = (x).begin(); it != (x).end(); ++it)
const int MOD = 998244353;
struct Trie {
	int ch[21805 * 1000][2], id[21805 * 1000], cnt, tot;
	Trie () {
		cnt = 0, tot = 0;
		memset(ch, 0, sizeof(ch));
		memset(id, 0, sizeof(id));
	}
	inline int find(string & s) {
		int now = 0;
		for (auto & p : s) {
			if (ch[now][p & 1] == 0) {
				ch[now][p & 1] = ++cnt;
			}
			now = ch[now][p & 1];
		}
		if (!id[now]) id[now] = ++tot;
		return id[now];
	}
}	tr;
int dp[218050 + 233];
inline void chkMOD(int & __) {
	if (__ >= MOD) __ -= MOD;
}
inline int dfs(string s) {
	if (SZ(s) == 0) return 1;
	int id = tr.find(s);
	if (dp[id] != -1) return dp[id];
	dp[id] = (s[0] - 47ll) * dfs(s.substr(1)) % MOD;
	rep (i, 1, SZ(s) - 1) {
		string ns = s.substr(0, i);
		for (int t = 2; t * i <= SZ(s); ++t) {
			rep (p, 0, i - 1) ns[p] = min(ns[p], s[i * (t - 1) + p]);
			chkMOD(dp[id] += dfs(ns) * 1ll * dfs(s.substr(i * t)) % MOD);
		}
	}
	return dp[id];
}
int main() {
	ios::sync_with_stdio(false);
	cin.tie(NULL), cout.tie(NULL);
	string s; cin >> s;
	memset(dp, -1, sizeof(dp));
	cout << dfs(s) << endl;
	return 0;
}

Measured memory_bytes: 256640
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define llong long long
#define pb(a) push_back(a)
#define INF 999999999
using namespace std;
typedef pair<int, int> P;
typedef pair<llong, llong> LP;
typedef pair<int, P> PP;
typedef pair<llong, LP> LPP;

int dy[]={0, 0, 1, -1, 0};
int dx[]={1, -1, 0, 0, 0};

int main() {
    int n, a;
    cin >> n >> a;
    cout << pow(n, 2) - a << endl;
}

Measured memory_bytes: 256
#!/usr/bin/env python3

s=input()
m="keyence"
if s=="keyence":
    print("YES")
elif s[0:7]=="keyence":
    print("YES")
elif s[-8:-1]=="keyence":
    print("YES")
elif s[0]=="k" and s[-1]=="e":
    ans = "NO"
    for i in range(6):
        if s[0:i+1]==m[0:i+1] and s[-6+i:]==m[-6+i:]:
            ans="YES"
    print(ans)

else:
    print("NO")



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

int main(int argc, char const *argv[])
{
	int n,m;
	cin>>n>>m;
	long long a;
	multiset<long long> memo;
	for (int i = 0; i < n; ++i)
	{
		cin>>a;
		memo.insert(a);
	}
	for (int i = 0; i < m; ++i)
	{
		auto itr=memo.end();
		--itr;
		memo.insert(*itr/2LL);
		auto itr2=memo.end();
		--itr2;
		memo.erase(itr2);
	}
	long long ans=0LL;
	for (auto i = memo.begin(); i != memo.end(); ++i)
	{
		ans+=(*i);
	}
	cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 4992
import java.util.*;

public class Main{
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int[] a = new int[n];
        int evenCount = 0;
        for (int i = 0; i < n; i++) {
            a[i] = sc.nextInt();
            if (a[i] % 2 == 0) evenCount++;
        }
        long tmp = 1;
        if (evenCount != 0) {
            tmp = (long) Math.pow(2, evenCount);
        }
        long ans = (long) (Math.pow(3, n) - tmp);
        System.out.println(ans);
    }
}


Measured memory_bytes: 35852
import math

A, B, H, M = map(int, input().split())

# angle velocity
vel_A = 0.5
vel_A_hour = 30
vel_B = 6

# kill periodicity
# convert H -> M
H = H % 12
M = M % 60
#print("H:", H)
#print("M:", M)

# corrent angle
angle_A = H * vel_A_hour
angle_B = M * vel_B


angle_A += vel_A * M
#print("angle_A:", angle_A)
#print("angle_B:", angle_B)

# difference
theta = max(angle_A, angle_B) - min(angle_A, angle_B)
theta = math.radians(theta)
#print("theta:", theta)
#print("cos_theta:", math.cos(theta))


# distance between A, B
d = pow(A, 2) + pow(B, 2) - 2 * A * B * math.cos(theta)
d = math.sqrt(d)

print(d)

Measured memory_bytes: 9540
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Arrays;
import java.util.StringTokenizer;

public class Main {
	// AtCoder Beginner Contest 007
	// https://atcoder.jp/contests/abc007/tasks
	public static void main(String[] args) {
		FastReader sc = new FastReader();
		int n = sc.nextInt();
		int q = sc.nextInt();
		String str = sc.next();
		int[] pre = new int[n];
		
		for (int i = 1; i < n; i++) {
			int inc = 0;
			if (str.charAt(i) == 'C' && str.charAt(i-1) == 'A') {
				inc = 1; 
			}
			pre[i] = pre[i-1] + inc;
		}
		
		for (int i = 0; i < q; i++) {
			int l = sc.nextInt() - 1;
			int r = sc.nextInt() - 1;
			System.out.println(pre[r] - pre[l]);
		}
	}
	
	static class FastReader { 
        BufferedReader br; 
        StringTokenizer st; 
  
        public FastReader() { 
            br = new BufferedReader(new InputStreamReader(System.in)); 
        } 
  
        String next() { 
            while (st == null || !st.hasMoreElements()) { 
                try { 
                    st = new StringTokenizer(br.readLine()); 
                } catch (IOException  e) { 
                    e.printStackTrace(); 
                } 
            } 
            return st.nextToken(); 
        } 
  
        int nextInt() { 
            return Integer.parseInt(next()); 
        } 
  
        long nextLong() { 
            return Long.parseLong(next()); 
        } 
  
        double nextDouble() { 
            return Double.parseDouble(next()); 
        } 
  
        String nextLine() { 
            String str = ""; 
            try{ 
                str = br.readLine(); 
            } catch (IOException e) { 
                e.printStackTrace(); 
            } 
            return str; 
        } 
    } 
}

class Point {
	int x;
	int y;
	public Point(int x, int y) {
		this.x = x;
		this.y = y;
	}
}

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

bool f[10000];

int main()
{
	int n;
	while (scanf("%d", &n), n){
		memset(f, false, sizeof(f));
		for (int i = 1; i < n; i++){
			f[i * i % n] = true;
		}
		vector<int> v;
		for (int i = 0; i < n; i++){
			if (f[i]) v.push_back(i);
		}
		int cnt[10000] = {};
		for (int i = 0; i < v.size(); i++){
			for (int j = 0; j < v.size(); j++){
				if (i == j) continue;
				int x = v[i] - v[j];
				if (x < 0) x += n;
				if (x > (n - 1) / 2) x = n - x;
				cnt[x]++;
			}
		}
		for (int i = 1; i <= (n - 1) / 2; i++){
			printf("%d\n", cnt[i]);
		}
	}
	return 0;
}

Measured memory_bytes: 1308
/*  -*- coding: utf-8 -*-
 *
 * a.cc: C: Not so Diverse
 */

#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 */

const int MAX_N = 200000;

/* typedef */

/* global variables */

int as[MAX_N], cs[MAX_N];

/* subroutines */

/* main */

int main() {
  int n, k;
  scanf("%d%d", &n, &k);

  for (int i = 0; i < n; i++) scanf("%d", &as[i]);
  sort(as, as + n);

  int m = 0, prva = 0;
  for (int i = 0; i < n; i++) {
    if (prva != as[i]) prva = as[i], cs[m++] = 0;
    cs[m - 1]++;
  }

  if (m <= k) puts("0");
  else {
    sort(cs, cs + m);
    int sum = 0;
    for (int i = 0; i < m - k; i++) sum += cs[i];
    printf("%d\n", sum);
  }
  
  return 0;
}


Measured memory_bytes: 1792
// 4_abc084_d
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>// C++
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>

using namespace std;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define rep1(i, n) for(int i = 1; i <= (int)(n); i++)
#define SZ(x) ((int)(x).size())
#define INF (1e16)
#define MOD (1000000007)
typedef long long ll;

vector<bool> eratosthenes(int n){
    // n以下の整数が素数かどうかのbool vector返す
    if(n < 1) cout << "ERROR : eratostenes : n < 1";

    vector<bool> prime(n + 1, true);
    prime[0] = false;
    prime[1] = false;

    if(n < 2) return prime;

    int j = 4;
    while(j <= n){
        prime[j] = false;
        j += 2;
    }

    for(int i = 3; i <= sqrt(n); i += 2){
        if(prime[i]){
            int j = 2 * i;
            while(j <= n){
                prime[j] = false;
                j += i;
            }
        }
    }
    return prime;
}


int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int q;
    cin >> q;
    int n = 100000;
    vector<int> s(n + 1);
    vector<bool> prime = eratosthenes(n);

    s[1] = 0;
    for(int i = 3; i <= n; i += 2){
        if(prime[i] && prime[(i + 1) / 2]){
            s[i] = s[i - 2] + 1;
        }else{
            s[i] = s[i - 2];
        }
    }

    rep(i, q){
        int l, r;
        cin >> l >> r;
        if(l == 1){
            cout << s[r] << endl;
            continue;
        }
        cout << s[r] - s[l - 2] << endl;
    }

    return 0;
}


Measured memory_bytes: 1024
#include <algorithm>
#include <array>
#include <bitset>
#include <cassert>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <functional>
#include <iostream>
#include <map>
#include <memory>
#include <numeric>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <unordered_map>
#include <vector>

using namespace std;

typedef long long lint;

void dfs(int v, int color_v, vector<int> &colors,
         const vector<vector<int>> &adj) {
  if (colors[v] != -1) {
    assert(colors[v] == color_v);
    return;
  }
  colors[v] = color_v;
  for (int u : adj[v])
    dfs(u, 1 - color_v, colors, adj);
}

vector<vector<int>> get_colors(int n, int d) {
  vector<vector<int>> adj(n * n);
  for (int y = 0; y < n; ++y)
    for (int x = 0; x < n; ++x) {
      int y_low = y, y_high = y;
      for (int x2 = n - 1; x2 >= x; --x2) {
        while (y_low >= 0 &&
               (x2 - x) * (x2 - x) + (y_low - y) * (y_low - y) < d)
          --y_low;
        while (y_high < n &&
               (x2 - x) * (x2 - x) + (y_high - y) * (y_high - y) < d)
          ++y_high;

        if (x2 > x && y_low >= 0 &&
            (x2 - x) * (x2 - x) + (y_low - y) * (y_low - y) == d) {
          adj[y * n + x].push_back(y_low * n + x2);
          adj[y_low * n + x2].push_back(y * n + x);
        }
        if (y_high < n &&
            (x2 - x) * (x2 - x) + (y_high - y) * (y_high - y) == d) {
          adj[y * n + x].push_back(y_high * n + x2);
          adj[y_high * n + x2].push_back(y * n + x);
        }
      }
    }

  vector<int> colors(n * n, -1);
  for (int v = 0; v < n * n; ++v)
    if (colors[v] == -1)
      dfs(v, 0, colors, adj);

  vector<vector<int>> result(n, vector<int>(n));
  for (int y = 0; y < n; ++y)
    for (int x = 0; x < n; ++x)
      result[y][x] = colors[y * n + x];
  return result;
}

int main() {
  int n, d1, d2;
  scanf("%d %d %d", &n, &d1, &d2);
  n *= 2;
  vector<vector<int>> colors_d1 = get_colors(n, d1);
  vector<vector<int>> colors_d2 = get_colors(n, d2);

  map<pair<int, int>, vector<pair<int, int>>> points_with_colors;
  for (int y = 0; y < n; ++y)
    for (int x = 0; x < n; ++x)
      points_with_colors[{colors_d1[y][x], colors_d2[y][x]}].emplace_back(y, x);

  vector<pair<int, int>> result =
    max_element(points_with_colors.begin(), points_with_colors.end(),
                [](const auto &kv1, const auto &kv2) {
                  return kv1.second.size() < kv2.second.size();
                })->second;

  assert((int)result.size() >= n * n / 4);
  result.resize(n * n / 4);

  for (const pair<int, int> &point : result)
    printf("%d %d\n", point.first, point.second);

  return 0;
}


Measured memory_bytes: 76672
n = int(input())
raw = []
for _ in range(n):
  raw.append(list(map(int,input().split())))
raw.sort(key= lambda x: x[1])
EF = []
for i in range(n):
  EF.append(raw[i][1])
SL1 = [raw[0][0]]
for i in range(1,n):
  SL1.append(max(SL1[-1],raw[i][0]))
SL2 = [raw[-1][0]]
for i in range(1,n):
  SL2.append(max(SL2[-1],raw[n-i-1][0]))
SL2.reverse()
#print(EF)
#print(SL1)
#print(SL2)
can = []
for i in range(n-1):
  tmp = max(EF[0]-SL1[i]+1,0) + max(EF[i+1]-SL2[i+1]+1,0)
  can.append(tmp)
#print(can)
ans1 = max(can)
xlen = []
xl = []
xr = []
for i in range(n):
  xlen.append(raw[i][1] - raw[i][0] + 1)
  xl.append(raw[i][0])
  xr.append(raw[i][1])
#print(max(xl))
ans2 = max(xlen) + max(0,min(xr)-max(xl)+1)
print(max(ans1,ans2))

Measured memory_bytes: 89432
#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<ll,ll> pint;

vector<pint> vp[100001];
ll d[100001];
ll INF=1000100010001000;
int n;
int dijkstra(int st){
    priority_queue<pint,vector<pint>,greater<pint> > pq;
    rep(i,n) d[i]=INF;
    d[st]=0;
    pq.push(make_pair(0,st));
    while(!pq.empty()){
        pint pi=pq.top();pq.pop();
        int t=pi.second;
        if(d[t]<pi.first) continue;
        for(auto it:vp[t]){
            if(d[it.second]>d[t]+it.first){
                d[it.second]=d[t]+it.first;
                pq.push(make_pair(d[it.second],it.second));
            }
        }
    }
}
pint p[100001];
int main(){
    int m,sr,ds,co;
    ll c,sum=0;
    cin>>n>>m>>c;
    rep(i,m){
        cin>>sr>>ds>>co;
        --sr,--ds;
        vp[sr].pb(co,ds);
        vp[ds].pb(co,sr);
        sum+=co;
    }
    dijkstra(0);
    rep(i,n) p[i]={d[i],i};
    sort(p,p+n);
    ll mn=sum;
    set<int> st;
    rep(i,n){
        int cur=p[i].second;
        for(auto it:vp[cur]){
            if(st.count(it.second)>0) sum-=it.first;
        }
        st.insert(cur);
        mn=min(mn,sum+c*p[i].first);
    }
    cout<<mn<<endl;
    return 0;
}


Measured memory_bytes: 22120
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define inf 1e15
vector<ll>ad[400009];
map<pair<ll,ll>,ll>mp;
bool vis[400009];
ll A;
void dfs(ll a)
{
    vis[a]=true;
    A++;
    ll i,b,l=ad[a].size();
    for(i=0;i<l;i++)
    {
        b=ad[a][i];
        if(!vis[b])
        {
            dfs(b);
        }
    }
}
int main()
{
    ll a,b,c,d,e,i,j,k,l,n,m,x,y,t,p;
    cin>>n>>m;
    for(i=0;i<=n;i++)
    {
        vis[i]=false;
    }
    for(i=1;i<=m;i++)
    {
        cin>>a>>b;
        if(mp[make_pair(a,b)]==0)
        {
            mp[make_pair(a,b)]=1;
            mp[make_pair(b,a)]=1;
        }
        else
        {
            continue;
        }
        ad[a].push_back(b);
        ad[b].push_back(a);
    }

    ll ans=0;
    for(i=1;i<=n;i++)
    {
        if(!vis[i])
        {
            A=0;
            dfs(i);
            ans=max(ans,A);
        }
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 53608