akhauriyash/Code-Regression huggingface dataset:
//////////////      VATSAL AGARWAL       ////////////////////////
////////////// Codeforces id : warhead38 ////////////////////////
////////////// Codechef   id : vatsal38  //////////////////////// 


#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
using namespace std;
using namespace __gnu_pbds;
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> pbds;
#define ll long long int
#define ull unsigned long long int
#define ld long double
#define endl '\n'
#define loop(var,a,b,c) for(ll var=a;var<=b;var+=c)
#define intarr(arr,n) ll arr[n];for(ll i=0;i<n;i++)cin>>arr[i]
#define inparr(arr,n) for(ll i=0;i<n;i++)cin>>arr[i]
#define inpvec(vec,n) for(ll i=0;i<n;i++){ll var;cin>>var;vec.push_back(var);}
#define pb push_back
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);
#define mod 1000000007
#define newline cout<<endl
#define ump unordered_map<ll,ll>
#define vec vector<ll>
#define mkp make_pair
#define disp(var1,var2) cout<<var1<<" "<<var2<<endl;
#define all(v)             v.begin(),v.end()
#define cout(var) cout<<var<<endl
#define mod2 998244353
#define fbo find_by_order  /// find kth smallest by passing k-1
#define ook order_of_key  //// find no of smaller items less than k
#define teensort(a,r,g,b) a[0]=r;a[1]=g;a[2]=b;sort(a,a+3);
#define ss second
#define ff first
#define displayarray(a,n) for(ll i=0;i<n;i++)cout<<a[i]<<" "; cout<<endl;
#define pi pair<ll,ll>
#define meramax 1e18
#define meramin -1e18
#define percentile 1000000007
#define PI 3.14159265358979323846
#define input2darr(n,m,in) ll a[n+1][m+1];if(in==0){loop(i,0,n-1,1)loop(j,0,m-1,1)cin>>a[i][j];}else{loop(i,1,n,1)loop(j,1,m,1)cin>>a[i][j];}
#define output2darr(n,m,in) if(in==0){loop(i,0,n-1,1){loop(j,0,m-1,1)cout<<a[i][j]<<" ";cout<<endl;}}else{loop(i,1,n,1){loop(j,1,m,1)cout<<a[i][j]<<" ";}cout<<endl;}
#define minheap priority_queue<ll>
#define maxheap priority_queue<ll,vector<ll>,greater<ll>>
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////                                     ///////////////////////////////////////////////////////////////
////////////////////////////////////////              CODE                   ///////////////////////////////////////////////////////////////
////////////////////////////////////////                                     ///////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

void AcDegaYe()
{
    ll n,h,w;
    cin>>n>>h>>w;
    cout((n-h+1)*(n-w+1));
}
int main()
{   
    fastio

    // #ifndef ONLINE_JUDGE
    // freopen("input.txt", "r", stdin);
    // freopen("output.txt", "w", stdout);
    // #endif

    //ll t;
    //cin>>t;
    ll t=1;
    while(t--)
    {
        AcDegaYe();
    }
    //cerr << "\nTime elapsed: " << 1000 * clock() / CLOCKS_PER_SEC << "ms\n";
    return 0;
}


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

using namespace std;

#define rep(i,n) for(int i=0;i<(n);i++)
#define repa(i,a,n) for(int i=(a);i<(n);i++)
#define rrep(i,n) for(int i=n;i>=0;i--)
#define rrepa(i,a,n) for(int i=n;i>=(a);i--)
#define all(a) (a).begin(),(a).end()
#define MOD 1000000007
#define cmax(a,b) a=max(a,b)
#define cmin(a,b) a=min(a,b)
#define vc vector

typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef pair<int,int> pi;

int main(){

    int n,m,x;
    cin>>n>>m>>x;
    vi c(n);
    vvi a(n,vi(m));
    rep(i,n){
        cin>>c[i];
        rep(j,m){
            cin>>a[i][j];
        }
    }

    int ans=100000*n+1;
    int q=pow(2,n);
    vi rikai(m);
    rep(i,q){
        int price=0;
        vi(m).swap(rikai);
        rep(j,n){
            if(1&(i>>j)){
                price+=c[j];
                rep(k,m){
                    rikai[k]+=a[j][k];
                }
            }
        }
        bool ok=true;
        rep(j,m){
            if(rikai[j]<x){
                ok=false;
                break;
            }
        }
        if(ok)cmin(ans,price);
    }

    if(ans==100000*n+1)ans=-1;

    cout<<ans<<"\n";


    return 0;
}

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

using namespace std;

#define ll long long




void solve() {

	ll l, r;
	cin >> l >> r;
	ll mn = 1e9;
	for(ll i = l; i <= r; i++) {
		for(ll j = i + 1; j <= r; j++) {
			mn = min(mn, (i * j) % 2019);
			if(mn == 0) {
				cout << mn;
				return;
			}
		}
	}
	cout << mn;


	




	
}

int main() {

	ios_base::sync_with_stdio(0);
	cin.tie(NULL);
	solve();

	return 0;
}

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

int main() {
	int a;
	int b;
	int d;
	int r;
	double f;
	
	cin >> a;
	cin >> b;
	
	d = a/b;
	r = a%b;
	f = (double)a/b;
	
	cout << d << " " << r << " " ;
	cout << fixed << f << endl;
	
	return 0;
}

Measured memory_bytes: 3276
#include <iostream>
using namespace std;
long long h[5],n,i,j,k,num;
int main()
{
	string s;
	cin>>n;
	for (i=0;i<n;i++)
	{
		cin>>s;
		if(s[0]=='M')  h[0]++;
		if(s[0]=='A')  h[1]++;
		if(s[0]=='R')  h[2]++;
		if(s[0]=='C')  h[3]++;
		if(s[0]=='H')  h[4]++;
	}
	for (i=0;i<3;i++)
		for (j=i+1;j<4;j++)
			for (k=j+1;k<5;k++)
				num+=h[i]*h[j]*h[k];
	cout<<num;
	return 0; 
}

Measured memory_bytes: 256
/*Rabbi Zidni Ilma*/
 
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define sct(tc) scanf("%lld",&tc)
#define scl(n) scanf("%lld",&n)
#define scll(n,m) scanf("%lld%lld",&n,&m)
#define pb push_back
#define mp make_pair
#define fr first
#define sc second
#define read freopen("input.txt","r",stdin)
#define write freopen("output.txt","w",stdout)
 
 
int main()
{
	ll i,sum=0;
	string s;
	cin >> s;
	ll len=s.length();
	for(i=0;i<len;i++)
	{
		sum+=s[i]-'0';
	}
	if(sum%9==0)
	printf("Yes\n");
	else
	printf("No\n");
}

Measured memory_bytes: 3728
#include <iostream>
#include <string>
#include <vector>
#include <deque>
#include <queue>
#include <algorithm>
#include <set>
#include <map>
#include <bitset>
#include <cmath>
#include <functional>
#include <iomanip>
#define vll vector<ll>
#define vvv vector<vvl>
#define vvi vector<vector<int> >
#define vvl vector<vector<ll> >
#define vv(a, b, c, d) vector<vector<d> >(a, vector<d>(b, c))
#define vvvl(a, b, c, d) vector<vvl>(a, vvl(b, vll (c, d)));
#define rep(c, a, b) for(ll c=a;c<b;c++)
#define re(c, b) for(ll c=0;c<b;c++)
#define all(obj) (obj).begin(), (obj).end()
typedef long long int ll;
typedef long double ld;
typedef __int128_t lll;
using namespace std;

vvl G = vv(100001, 0, 0, ll);
ll n, INF=1000000000;

ll test(){
  ll m = 0, idx = 0;
  for(int i=0;i<n;i++) if(m<G[i].size()) m = G[i].size(), idx = i;
  if(m==1||m==2){
    std::cout << 1 << '\n';
    exit(0);
  }
  return idx;
}
vvl dp = vv(100001, 2, 0, ll);

vll dfs(ll now, ll from){
  ll c=0, to;
  for(int i=0;i<G[now].size();i++) if(G[now][i]!=from) c++, to=G[now][i];
  if(c==0) return dp[now] = vll{0, 1};
  if(c==1) return dp[now] = dfs(to, now);
  ll s = 0, m = 0;
  for(int i=0;i<G[now].size();i++){
    if(G[now][i]==from) continue;
    vll tmp = dfs(G[now][i], now);
    s += tmp[1], m = max(m, tmp[1] - tmp[0]);
  }
  return dp[now] = vll{INF, s - m};
}
int main(int argc, char const *argv[]) {
  ll a, b;std::cin >> n;
  re(i, n-1){
    std::cin >> a >> b;
    G[a].push_back(b);
    G[b].push_back(a);
  }
  ll root = test();
  vll x = dfs(root, -1);
  //re(i, n) std::cout << "now" << i << "  "<< dp[i][0] << " " << dp[i][1] << '\n';
  if(x[0]!=INF) std::cout << x[0] << '\n';
  else std::cout << x[1] << '\n';
  return 0;
}


Measured memory_bytes: 20992
N = int(input())
a = [int(input()) for _ in range(N)]
b = [-1] * N
botan = a[0]

cnt = 0

for i in range(N):
    if botan == 2:
        print(cnt + 1)
        exit()
    cnt += 1
    botan = a[botan - 1]

print(-1)


Measured memory_bytes: 7884
#include <bits/stdc++.h>
#include <vector>
#include <algorithm>
#include <deque>
#include <numeric>
#include <utility>
#define sign(a) ((a>0)-(a<0))
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define LL long long
#define INF (LL)(1LL<<60)

using namespace std;

void solve(std::string s){
    vector<deque<LL>> qs(26);
    for(LL i=0; i<s.size(); i++)
        qs[s[i]-'a'].push_back(i);

    for(int i=0; i<26; i++){
        auto q=qs[i];
        auto n=q.size();
        if(n<2)continue;
        auto l=q.front(), r=q.back();
        q.pop_front();
        q.pop_back();

        while(true){
            if(2*n > r-l+1) {
                cout << l + 1 << " " << r + 1 << endl;
                return;
            }
            if(q.empty())break;

            if(q.front()-l > r-q.back()){
                l=q.front();
                q.pop_front();
            }else{
                r=q.back();
                q.pop_back();
            }
            n--;
        }
    }
    cout << -1 << " " << -1 << endl;
}

int main(){
    std::string s;
    std::cin >> s;
    solve(s);
    return 0;
}


Measured memory_bytes: 1536
A,B,C,D = input()
A = int(A)
B = int(B)
C = int(C)
D = int(D)
sum = 0
ope = ["", "",""]
for i in range(2):

    for j in range(2):

        for k in range(2):
            if (i == 0):
                sum += A + B
                ope[0] = "+"
            if (i == 1):
                sum += A - B
                ope[0] = "-"
            if (j == 0):
                sum += C
                ope[1] = "+"
            if (j == 1):
                sum -= C
                ope[1] = "-"
            if (k == 0):
                sum += D
                ope[2] = "+"
                if (sum == 7):
                    break
                else:
                    sum = 0
            if(k==1):
                sum -= D
                ope[2] = "-"
                if (sum == 7):
                    break
                else:
                    sum = 0
        if (sum == 7):
            break

    if (sum == 7):
        break
print("{}{}{}{}{}{}{}=7".format(A,ope[0],B,ope[1],C,ope[2],D))

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
int main()
{
  ios::sync_with_stdio(false);
  cin.tie(0);
  string s;
  cin >> s;
  long long res = 0;
  int c = 0;
  long long nr = 0;
  if (s[c] == '>')
  {
    while (s[c] == '>')
    {
      nr++;
      c++;
    }
  }
  res += 1LL*nr*(nr+1)/2;
  for (int i = c; i < s.size(); ++i)
  {
    if (s[i] == '<')
    {
      long long nr1 = 0, nr2 = 0;
      while (s[i] == '<')
      {
        nr1++;
        i++;
      }
      while (s[i] == '>')
      {
        nr2++;
        i++;
      }
      if (nr1 > nr2)
        res += 1LL*nr1*(nr1+1)/2 + 1LL*nr2*(nr2-1)/2;
      else 
        res += 1LL*nr1*(nr1-1)/2 + 1LL*nr2*(nr2+1)/2;
      i--;
    }
  }
  cout << res << '\n';
}


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

const int inf = 1e9+7;

int main() {
	int n,ma,mb; cin>>n>>ma>>mb;
	vector<int> a(n),b(n),c(n);
	for (int i=0; i<n; i++)
		cin>>a[i]>>b[i]>>c[i];

	int dp[n+1][500][500];
	for (int i=0; i<=n; i++)
	for (int j=0; j<500; j++)
	for (int k=0; k<500; k++)
		dp[i][j][k]=inf;
	dp[0][0][0]=0;

	for (int i=0; i<n; i++)
	for (int j=0; j<500; j++)
	for (int k=0; k<500; k++) {
		if (dp[i][j][k]==inf) continue;
		dp[i+1][j][k] = min(dp[i+1][j][k], dp[i][j][k]);
		dp[i+1][j+a[i]][k+b[i]] = min(dp[i+1][j+a[i]][k+b[i]], dp[i][j][k]+c[i]);
	}

	int ans=inf;
	for (int i=0; i<=n; i++)
	for (int j=1; j<500; j++)
	for (int k=1; k<500; k++)
		if (j*mb == k*ma)
			ans = min(ans,dp[i][j][k]);
	
	if (ans<inf) cout << ans << endl;
	else cout << -1 << endl;
	return 0;
}


Measured memory_bytes: 40320
#include<iostream>
#include<numeric>
using namespace std;
typedef long long int ll;

ll gcd(ll a, ll b)
{
  	if(a==0)
      return b;
  	return gcd(b%a, a);
}

ll lcm(ll a, ll b)
{
  	return a*b/gcd(a,b);
}
int main()
{
  	ll A,B,C,D; cin>>A>>B>>C>>D;
  	ll E = lcm(C,D); ll aC,aD,aE,bC,bD,bE,aS,bS,answer;
  	aC = (A-1)/C; aD = (A-1)/D; aE = (A-1)/E;
  	bC = B/C; bD = B/D; bE = B/E;
  	aS = aC + aD - aE; bS = bC + bD -bE;
  	answer = B - (A-1) - (bS - aS);
  	cout<<answer<<endl;
  	return 0;
}

Measured memory_bytes: 256
using System;

public class p0218
{
	p0218(){
		string str;
		string[] st;
		int n;
		
		while((str = Console.ReadLine()) != null){
			n = int.Parse(str);
			
			while(0 < n--){
				st = (Console.ReadLine()).Split(' ');
				Console.WriteLine("{0}", func(int.Parse(st[0]), int.Parse(st[1]), int.Parse(st[2])));
			}
			
		}
	}
	
	char func(int s, int t, int u){
		if(s == 100 || t == 100 || u == 100) return 'A';
		if(s+t >= 180) return 'A';
		if(s+t+u >= 240) return 'A';
		if(s+t+u >= 210) return 'B';
		if(s+t+u >= 150 && (s >= 80 || t >= 80)) return 'B';
		
		return 'C';
	}
	
	public static int Main(string[] args){
		new p0218();
		return 0;
	}
}

Measured memory_bytes: 5460
#include <cstdio>
#include <algorithm>

using namespace std;

int main()
{
  int a[5];
  for (int i = 0; i < 5; i++) {
    scanf(" %d ", &a[i]);
    a[i] = -a[i];
  }
  sort(a, &a[5]);
  for (int i = 0; i < 5; i++) {
    printf("%d", -a[i]);
    if (i != 4) {printf(" ");}
    else {printf("\n");}
  }

  return 0;
}

Measured memory_bytes: 0
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cstring>
#include <cmath>
#include <limits>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <functional>
#include <iomanip>

//--boost--
#include <boost/multiprecision/cpp_dec_float.hpp>
#include <boost/multiprecision/cpp_int.hpp>
#include <boost/rational.hpp>
namespace mp = boost::multiprecision;
// 任意長整数型
using Bint = mp::cpp_int;
// 仮数部長が32の浮動小数点数型
using Real32 = mp::number<mp::cpp_dec_float<32>>;
// 仮数部長が1024の浮動小数点数型
using Real1024 = mp::number<mp::cpp_dec_float<1024>>;
// ついでに有理数型
using Rat = boost::rational<Bint>;
//!--boost--

using namespace std;

#ifdef LOCAL
#define eprintf(...) fprintf(stderr, __VA_ARGS__)
#else
#define eprintf(...) 42
#endif
using ll = unsigned long long;
using vll = std::vector<ll>;
using vvll = std::vector<vll>;
using vvvll = std::vector<vvll>;
#define reps(i, S, E) for (ll i = (S); i <= (E); i++)
#define rep(i, N) reps(i, 0, N-1)
#define deps(i, E, S) for (ll i = (E); i >= (S); i--)
#define dep(i, N) deps(i, N-1, 0)
const ll INF = 1LL << 60;
const int INF_INT = 1 << 30;

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

struct Fast {
	Fast() {
		cin.tie(0);
		ios::sync_with_stdio(false);
		cout << fixed << setprecision(std::numeric_limits<double>::max_digits10);
	}
} fast; //cin,cout高速化のおまじない＋桁数指定


//void solve()
//{
//	ll N;
//	cin >> N;
//	vector<ll> A(N);
//	rep(i, N) {
//		cin >> A[i];
//		if (A[i] == 0) {
//			cout << 0 << endl;
//			return;
//		}
//	}
//
//	unsigned long long result = 1;
//	rep(i, N) {
//		unsigned long long temp = (A[i] + (unsigned long long)1000000000000000000 - 1);
//		temp /= A[i];
//		if (result > temp) {
//			cout << -1 << endl;
//			return;
//		}
//		else {
//			result *= A[i];
//			if (result > (unsigned long long)1000000000000000000) {
//				cout << -1 << endl;
//				return;
//			}
//		}
//	}
//
//	cout << result << endl;
//}

void solve() {
	ll N;
	cin >> N;
	vector<ll> A(N);
	rep(i, N) {
		cin >> A[i];
		if (A[i] == 0) {
			cout << 0 << endl;
			return;
		}
	}

	Bint result = 1;

	rep(i, N) {
		result *= A[i];
		if (result > (Bint)1000000000000000000) {
			cout << -1 << endl;
			return;
		}
	}

	cout << result << endl;
}

int main() {
#if TEST && LOCAL
	ll t; cin >> t;
	rep(i, t) { solve(); }
#else
	solve();
#endif
	return 0;
}


Measured memory_bytes: 4016
#include <iostream>
#include <vector>
#include <algorithm>
#include <cstdlib>

#define REP(i,a,b) for(int i=int(a);i<int(b);i++)

using namespace std;

typedef long long int lli;

int main () {
    int t;
    string num;
    while (cin >> t >> num, t != 0 || num != "0") {
        int ans = -1;
        int cnt = 0;
        vector<int> nl;
        REP (i, 0, num.size()) {
            vector<int> dis(num.size() - 1, false);
            for (int j = dis.size() - 1; j > int(dis.size() - i - 1); j--) dis[j] = true;
            do {
                int a = num[0] - '0';
                int sum = 0;
                bool mis = false;
                vector<int> prt;
                REP (k, 0, dis.size()) {
                    if (dis[k]) {
                        prt.push_back(a);
                        sum += a;
                        a = 0;
                    }
                    a = a * 10 + num[k + 1] - '0';
                }
                prt.push_back(a);
                sum += a;
                if (!mis && sum <= t) {
                    if (ans == sum) {
                        cnt++;
                    } else if (ans < sum){
                        cnt = 1;
                        ans = sum;
                        nl = prt;
                    }
                }
            } while (next_permutation(dis.begin(), dis.end()));
        }
        if (cnt >= 2) {
            cout << "rejected" << endl;
        } else if (ans == -1) {
            cout << "error" << endl;
        } else {
            cout << ans;
            for (int a : nl) {
                cout << ' ' << a;
            }
            cout << endl;
        }
    }
    return 0;
}

Measured memory_bytes: 3116
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int (i) = 0;(i) < (int)(n);(i)++)
int main(void){
    int r,c;
    cin >> r >> c;
    vector<vector<int> > table(r,vector<int>(c));
    vector<int> r_sum(c,0);
    vector<int> c_sum(r,0);
    int total_sum = 0;
    rep(i,r){
        rep(j,c){
            cin >> table[i][j];
            r_sum[j] += table[i][j];
            c_sum[i] += table[i][j];
            cout << table[i][j] << " ";
        }
        cout << c_sum[i] << endl;;
    }
    rep(j,c){
        cout << r_sum[j] << " ";
        total_sum += r_sum[j];
    } 
    cout << total_sum << endl;
}



Measured memory_bytes: 3204
n = int(input())
S = [input() for i in range(n)]
cnt = 0
a = 0
b = 0
ba = 0
for i in range(n):
    cnt += S[i].count("AB")
    if S[i].startswith("B") and S[i].endswith("A"):
        ba += 1
    elif S[i].startswith("B"):
        b += 1
    elif S[i].endswith("A"):
        a += 1
if ba >= 1:
    cnt += ba - 1
    if a >= 1:
        cnt += 1
        a -= 1
    if b >= 1:
        cnt += 1
        b -= 1
    cnt += min(a, b)
elif a >= 1 and b >= 1:
    cnt += min(a, b)
print(cnt)


Measured memory_bytes: 3700
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#define For(i, n) for(int i = 0; i < (n); i ++)
#define Cin(type, val) type val; cin >> val;
#define Cout(val) cout << (val) << "\n";
#define Range(container) container.begin(), container.end()
using namespace std;
using ll = long long;

int main(void){
    Cin(int, x);
    Cin(int, y);
    Cout(x + y/2);
}

Measured memory_bytes: 256
n=int(input())
count=[[[0 for i in range(10)] for j in range(3)] for k in range(4)]
for x in range(n):
    b,f,r,v=map(int,input().split())
    count[b-1][f-1][r-1] += v

for i in range(4):
    for j in range(3):
        for k in range(10):
            print(" "+str(count[i][j][k]),end="") 
        print() 
    if i<3:
        print("#"*20)




Measured memory_bytes: 5624
N = int(input())

words = {'na': 0}  # 選択しない

for i in range(N):

    s = input()

    if s in words:
        words[s] += 1
    else:
        words[s] = 1

M = int(input())

for i in range(M):

    t = input()

    if t in words:
        words[t] -= 1

print(max(words.values()))


Measured memory_bytes: 38384
#include <stdio.h>

int main(void){
  int a, b, c, x;
  int i, j, k, ans;

  scanf("%d", &a);
  scanf("%d", &b);
  scanf("%d", &c);
  scanf("%d", &x);

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

  printf("%d\n", ans);

  return 0;
}

Measured memory_bytes: 128
import collections

N, M = map(int, input().split())
edge_list = [list(map(int, input().split())) for i in range(M)]
all = {i for i in range(1, N+1)}

start = 1
count = 0

for i in range(M):
    graph = collections.defaultdict(list)
    visited = {1}
    q = []
    for idx, edge in enumerate(edge_list):
        if idx != i:
            graph[edge[0]].append(edge[1])
            graph[edge[1]].append(edge[0])
    q.extend(graph[start])
    while q:
        a = q.pop()
        if a in visited:
            continue
        else:
            visited.add(a)
            q.extend(graph[a])
    # print(all, visited)
    if all != visited:
        count += 1
print(count)

Measured memory_bytes: 40688
#include <iostream>
#include <iomanip>
#include <queue>
typedef long long ll;
using namespace std;
const ll INF = 1e9;
const ll MOD = 1e9 + 7;
#define repi(i, n, init) for (ll i = init; i < (n); i++)

int main()
{
    int n;
    cin >> n;
    priority_queue<int> q;
    int a[n];
    repi(i, n, 0)
    {
        cin >> a[i];
        q.push(a[i]);
    }
    repi(i, n, 0)
    {
        if (q.top() != a[i])
        {
            cout << q.top() << endl;
        }
        else
        {
            q.pop();
            cout << q.top() << endl;
            q.push(a[i]);
        }
    }
    return 0;
}

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

int main()
{
	map<string, int> cnt;
	string s;
	while (cin >> s) {
		cnt[s]++;
	}
	int ma = 0, le = 0;
	string res1, res2;
	for (auto p : cnt) {
		if (p.second > ma) {
			ma = p.second;
			res1 = p.first;
		}
		if ((int)p.first.size() > le) {
			le = p.first.size();
			res2 = p.first;
		}
	}
	cout << res1 << ' ' << res2 << endl;
	return 0;
}



Measured memory_bytes: 3172
#include <bits/stdc++.h>
using namespace std;
int main() {
	double num;
	while(cin>>num,num>0){
	    string str;
		for(int i=7;i>-5;i--){
			str+=int(num/pow(2,i))+'0';
			if(num/pow(2,i)>=1)num-=pow(2,i);
			if(i==0)str+='.';
		}
		if(num/pow(2,-5)>0)cout<<"NA"<<endl;
		else cout<<str<<endl;
	}
}

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

using namespace std;

typedef long long  ll;

const int MAX_N = 200002;
int r[MAX_N], max_n[MAX_N], n;

int main()
{
    scanf("%d", &n);
    for (int i = 0; i < n; ++i)
        scanf("%d", &r[i]);

    max_n[n - 2] = r[n - 1];
    for (int i = n - 3; i >= 0; --i)
        max_n[i] = max(r[i + 1], max_n[i + 1]);

    int ans = -1e9 - 1;
    for (int i = 0; i < n - 1; ++i)
        ans = max(ans, max_n[i] - r[i]);

    printf("%d\n", ans);

    return 0;
}

Measured memory_bytes: 2732
from operator import itemgetter

N, M = list(map(int, input().split()))
A = [[1, a] for a in list(map(int, input().split()))]
BC = [list(map(int, input().split())) for i in range(M)]

q = sorted(A+BC, key=itemgetter(1), reverse=True)

ans = 0
i = 0

while N:
    n = min(q[i][0], N)
    ans += q[i][1] * n
    N -= n
    i += 1
print(ans)


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

using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef pair<ll,int> pli;
typedef pair<ll,ll> pll;
const ll INF = 2e18;
const int inf = 1e9+10;
const int maxN = 200010;
const int maxD = 15;
const int maxH = 100; 
const int MOD = 1000000007;

ll a[maxN];
ll b[maxN];
ll c[maxN];
int main()
{

	int n;
	scanf("%d",&n);
	for(int i=1;i<=n;i++)
	{
		scanf("%lld",&a[i]);
	}
	for(int i=1;i<=n;i++)
	{
		b[i] = i + a[i];
		c[i] = i - a[i];
	}
	unordered_map<ll,ll> F;
	F[b[1]]++;
	ll ans = 0;
	for(int i=2;i<=n;i++)
	{
		ans += F[c[i]];
		F[b[i]]++;
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 23160
#include <bits/stdc++.h>
#define _USE_MATH_DEFINES
#include <math.h>
#include <algorithm>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define acc(v) accumulate(v.begin(), v.end(), 0)

using namespace std;
typedef long long ll;
const int INF = 1e9;
const ll LINF = 1e18;
const ll MOD = 1e9 + 7;

bool prime(int x){
	for (int i = 2; i * i <= x; i++){
		if(x%i == 0){
			return false;
		}
	}
	return true;
}
int main()
{
	int x;
	cin >> x;
	while(true){
		if (prime(x)){
			cout << x << endl;
			return 0;
		}
		x++;
	}
}


Measured memory_bytes: 256
#include <iostream>
#include <stdio.h>
#include <algorithm>
#include <vector>
#include <cstdio>
#include <cmath>

using namespace std;
#define rep(i,n) for(int i=0;i<(n);i++)
#define rep2(i,n) for(int i=1;i<(n);i++)
typedef long long ll;

ll gcd(ll a, ll b){
    if(a<b) swap(a,b);
    if(a%b == 0) return b;
    else return gcd(b,a%b);
}

int main(){
    int n;
    string x;
    cin >> n >> x;
    int rcnt = 0, ans = 0;
    rep(i,n){
        if(x[i] == 'R') rcnt++;
    }
    ans = rcnt;
    int wcnt = 0;
    int now = rcnt;
    rep(i,n){
        if(x[i] == 'R') rcnt--;
        else wcnt++;

        now = max(rcnt,wcnt);
        if(now < ans) ans = now;
    }
    cout << ans << endl;
}

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

#ifdef LOCAL
#include "dump.hpp"
#else
#define dump(...)
#define dumpv(...)
#endif

#define rep(i, n) for (int i = 0; i < (n); i++)
typedef long long ll;
typedef pair<int, int> P;
typedef vector<int> vi;
typedef vector<vi> vvi;
const int MOD = 1e9 + 7;
const int INF = 1001001001;
const ll LINF = 1001002003004005006ll;

void solve() {
  int n, k;
  cin >> n >> k;
  vi a(n);
  rep(i, n) cin >> a[i];
  vector<ll> s1(n + 1), s2(n + 1);
  rep(i, n) s1[i + 1] = s1[i] + a[i];
  rep(i, n) s2[i + 1] = s2[i] + max(0, a[i]);
  dump(a);
  dump(s1);
  dump(s2);

  int left = 0;
  int right = 0;
  ll val = 0; // 区間[left, right)の合計値
  ll ans = -INF;
  for (int i = 0; i < n - k + 1; i++) {
    left = i;
    right = i + k;
    val = max(0ll, s1[right] - s1[left]);
    dump("1", left, right, val);
    val += (s2[i] - s2[0]);
    val += (s2[n] - s2[right]);
    dump("2", left, right, val);
    ans = max(ans, val);
  }
  cout << max(0ll, ans) << endl;
}

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(15);
  // freopen("temp.1", "r", stdin);
  solve();
  return 0;
}

Measured memory_bytes: 2176
#pragma GCC optimize("Ofast")
#include <iostream>
#include <vector>
#include <algorithm>
#include <iomanip>
#include <utility>
using namespace std;

template<typename T> void fastin(T &num) {
  T c;
  num = 0;
  c = getchar_unlocked();
  for (; (c > 47 && c < 58); c = getchar_unlocked()) num = (num << 3) + (num << 1) + c - 48;
}

struct task{
  int year, id;
};

int main(){
  int n, m; fastin(n); fastin(m);
  vector<vector<task>> v(101010);
  for (int i = 0; i < m; ++i) {
    int p, y; fastin(p); fastin(y);
    v[p].push_back({y, i + 1});
  }

  vector<int> ans1(101010), ans2(101010);

  for (int i = 1; i <= n; ++i) {
    if (v[i].empty()) continue;
    sort(v[i].begin(), v[i].end(), [](const task &x, const task &y){
      return x.year < y.year;
    });
  }

  for (int i = 1; i <= n; ++i) {
    for (int j = 0; j < (int) v[i].size(); ++j) {
      ans1[v[i][j].id] = i;
      ans2[v[i][j].id] = j + 1;
    }
  }

  for (int i = 1; i <= m; ++i) {
    cout << setfill('0') << right << setw(6) << ans1[i] << setfill('0') << right << setw(6) << ans2[i] << '\n';
  }

  return 0;
}

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

int main(){
int a;
long long int sum = 0, x = 0;
long long int arr[200005];
scanf("%d", &a);
for(int i = 0; i < a;i++){
	scanf("%lld", &arr[i]);
}
for(int j = 0;j < a;j++){
	sum = (sum + x * arr[j]) % 1000000007;
	x = (x + arr[j]) % 1000000007;
}
printf("%lld", sum);
return 0;
}

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

using namespace std;

typedef long long LL;
typedef pair<int, int> PII;
typedef pair<LL, LL> PLL;
typedef long double LD;
typedef pair<LD, LD> PLDLD;

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define CLR(a) memset((a), 0 ,sizeof(a))
#define ALL(a) a.begin(),a.end()

const double eps=1e-5;
const int INF=1e9;


int main()
{
    string s;
    cin>>s;
    int ans=INF;
    REP(tt,26)
    {
        int cnt=0;
        string t=s;
        char c=tt+'a';
        bool flag=1;
        REP(i,t.size())
        {
            if(t[i]!=c)
            flag=0;
        }
        if(flag)
        {
            cout<<0<<endl;
            return 0;
        }
        flag=1;
        while(flag)
        {
            flag=0;
            REP(i,t.size()-1-cnt)
            {
                if(t[i]==c || t[i+1]==c)
                    t[i]=c;
                else
                {
                    flag=1;
                }
            }
            cnt++;
        }
        ans=min(ans,cnt);
    }
    cout<<ans<<endl;
}


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

using namespace std;

#define intt long long
#define FAST ios_base::sync_with_stdio(0); cin.tie(0);

int n;

int main() {

	FAST;

	cin >> n;
	intt ans = 0;
	for (int i = 1; i <= n; i ++) {
		int m = n / i;
		ans += 1LL * i * m * (m + 1) / 2;
	}
	cout << ans << '\n';
	return 0;
}

Measured memory_bytes: 3584
# -*- coding: utf-8 -*-
import sys
import math
from bisect import bisect_left
from bisect import bisect_right
import collections
import copy
import heapq
from collections import defaultdict
from heapq import heappop, heappush
import itertools
input = sys.stdin.readline

##### リストの 二分木検索 #####
# bisect_left(lists, 3)
# bisect_right(lists, 3)

##### プライオリティキュー #####
# heapq.heapify(a) #リストaのheap化
# heapq.heappush(a,x) #heap化されたリストaに要素xを追加
# heapq.heappop(a) #heap化されたリストaから最小値を削除＆その最小値を出力

# heapq.heappush(a, -x) #最大値を取り出す時は、pushする時にマイナスにして入れよう
# heapq.heappop(a) * (-1) #取り出す時は、-1を掛けて取り出すこと

##### タプルリストのソート #####
# sorted(ans) #(a, b) -> 1st : aの昇順, 2nd : bの昇順
# sorted(SP, key=lambda x:(x[0],-x[1])) #(a, b) -> 1st : aの昇順, 2nd : bの降順
# sorted(SP, key=lambda x:(-x[0],x[1])) #(a, b) -> 1st : aの降順, 2nd : bの昇順
# sorted(SP, key=lambda x:(-x[0],-x[1])) #(a, b) -> 1st : aの降順, 2nd : bの降順

# sorted(SP, key=lambda x:(x[1])) #(a, b) -> 1st : bの昇順
# sorted(SP, key=lambda x:(-x[1])) #(a, b) -> 1st : bの降順

def inputInt(): return int(input())
def inputMap(): return map(int, input().split())
def inputList(): return list(map(int, input().split()))

def main():
	aa,bb = inputMap()

	a = str(aa)
	b = str(bb)

	A = ""
	B = ""

	for i in range(bb):
		A += a

	for i in range(aa):
		B += b

	if A < B:
		print(A)
	else:
		print(B)



if __name__ == "__main__":
	main()


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

int main() {
  string S, T; cin >> S >> T;
  int M = S.size(), N = T.size();
  if (N > M) cout << "UNRESTORABLE" << endl;
  else {
    string min_s(M, '~');
    for (int i = 0; i <= M - N; i++) {
      bool sat = true;
      for (int j = 0; j < N; j++) {
        if (S[i+j] != '?' && S[i+j] != T[j]) sat = false;
      }
      if (sat) {
        string s(S);
        for (int i = 0; i < M; i++) {
          if (s[i] == '?') s[i] = 'a';
        }
        for (int j = 0; j < N; j++) s[i+j] = T[j];
        min_s = min(min_s, s);
      }
    }
    if (min_s[0] == '~') cout << "UNRESTORABLE" << endl;
    else cout << min_s << endl;
  }
}

Measured memory_bytes: 3628
#include "bits/stdc++.h"

int main() {

    int N;
    std::cin >> N;

    //make prime
    std::vector<int> primes;
    primes.reserve(N);
    primes.push_back(2);
    for (int i = 3; i <= N; i += 2) {
        if (std::all_of(begin(primes), end(primes), [&](int p) { return i % p != 0; }))
            primes.push_back(i);
    }

    //count
    std::map<int, int> counts;
    for (int i = 1; i <= N; ++i) {
        for (auto& v : primes)for (int num = i; num % v == 0; num /= v)++counts[v];
    }

    int64_t ans = 1;
    for (auto& v : counts)
        ans = (ans * (v.second + 1)) % 1000000007;

    std::cout << ans << std::endl;
    
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <ctime>
#define INF 100000000
using namespace std;

int n;
int a[101],e[101],r[101];
int dp[101][20001];

int main() {

  while(1) {
    int d;
    cin >> d >> n;
    if(d==0 && n ==0) break;
    int maxr,maxe,mina,flg;
    maxr=maxe=flg=0;
    maxr = -1;
    mina = INF;
    for(int i=0;i<n;i++) {
      cin >> a[i] >> e[i] >> r[i];
    }

    int N = 101;
    int ans = INF;
    
    for(int i=0;i<=d;i++) for(int j=0;j<=N;j++)dp[i][j] = INF;
    dp[d][0] = 0;

    int cnt = 0;
    int c = 0;
      for(int j=0;j<=N;j++) { //?????¨???????¨????
	cnt++;
	for(int i=d;i>=0;i--) {//?????????????????????
	  if(dp[i][j] == INF) continue;
	  for(int k=0;k<n;k++) {
	    if(j < r[k]) continue;
	    c++;
	    int na = i - a[k];
	    int ne = j + e[k];
	    if(na < 0) na = 0;
	    if(ne > N) ne = N;
	    dp[na][ne] = min(dp[i][j]+1,dp[na][ne]);
	  }
	}
	ans = min(ans,dp[0][j]);
      }


      /*      
    for(int j=0;j<=cnt;j++) { //?????¨???????¨????
      cout << j <<"|";
      for(int i=d;i>=0;i--) {//?????????????????????
	if(dp[i][j] == INF) cout <<"#"<<" ";
	else  cout << dp[i][j]<<" ";
      }
      cout << endl;
    }
      */
      

      //      cout <<"time="<< clock() <<endl;   
      //cout << c<<endl; 
    if(ans == INF) cout << "NA" <<endl;
    else cout << ans <<endl;
   
  }


  return 0;
}

Measured memory_bytes: 5476
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int H,W;
        while(sc.hasNextLine()){
            String[] str = sc.nextLine().split(" ");
            H = Integer.parseInt(str[0]);
            W = Integer.parseInt(str[1]);
            if(H == 0 && W == 0) break;
            for(int y = 0; y < H; y++){
                for(int x = 0;x < W; x++){
                    if((y + x) % 2 == 0) System.out.print("#");
                    else System.out.print(".");
                }
                System.out.println();
            }
            System.out.println();
        }
    }

}




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

int main()
{
	int n;cin>>n;int arr[n];set<int> s;
	int ans=0;
	for(int i=0;i<n;i++)cin>>arr[i];
	for(int i=0;i<n && ans>=0;i++){
      	int x=arr[i];
		for(int j=2;j*j<=arr[i] && ans>=0;j++){
			if(arr[i]%j==0)
            {
              if(s.count(j))ans=-1;
              else s.insert(j);
              while(arr[i]%j==0)
                	arr[i]/=j;
            }
		}
		if(arr[i]>1)
		{
			if(s.count(arr[i]))
				ans=-1;
			else
				s.insert(arr[i]);
		}
		arr[i]=x;
	}
	if(ans>=0)cout<<"pairwise coprime";
	else{
		int gcd=__gcd(arr[1],arr[0]);for(int i=2;i<n;i++)gcd=__gcd(gcd,arr[i]);
		if(gcd==1)cout<<"setwise coprime";
		else cout<<"not coprime";
	}
	return 0;
}

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

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

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

    int n;
    cin >> n;

    if(n==0){
        cout << 0 << endl;
        return 0;
    }

    string s;
    int d = -1;
    while (n != 0) {

        int t = n % 2;

        if (t==0){
            s += '0';
        }else{
            t = 1;
            s += '1';
        }

        n = (n + d * t) / 2;
        d *= -1;
    }
    reverse(s.begin(), s.end());

    cout << s << endl;
}

Measured memory_bytes: 256
// In god we trust
 
#include <bits/stdc++.h>
#include <chrono>
#include <algorithm>
#include <signal.h>
#include <thread>
 
#define pb push_back
#define fi first
#define se second
#define Vi vector<int>
#define Vb vector<bool>
#define Pi pair<int, int>
#define MP make_pair
#define MT make_tuple
#define Q queue
#define Qi Q<int>
#define INF 1000000000 
#define LINF 1000000000000000000
#define int long long
using namespace std;
using namespace std::chrono;



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

  int n, k;
  cin >> n >> k;

  bool mark[n];
  for (int i = 0; i < n; i++)
    mark[i] = false;

  int a, d;
  for (int i = 0; i < k; i++){
    cin >> d;
    for (int j = 0; j < d; j++){
      cin >> a;
      mark[a - 1] = true;
    }
  }

  int cnt = 0;
  for (int i = 0; i < n; i++)
    if(not mark[i])
      cnt++;
  cout << cnt << endl;
  
  
}


Measured memory_bytes: 3596
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int n,k;
	cin>>n>>k;
	int a[n+1];
	int dp[n+1];
	for(int i=1;i<=n;i++)
	{
		cin>>a[i];
	}
	dp[1]=0;
	for(int i=2;i<=n;i++)
	{
		dp[i]=INT_MAX;
		for(int j=i-1;j>=1&&(i-j)<=k ;j--){
		
			dp[i]=min(dp[i],abs(a[i]-a[j])+dp[j]);
		}
	}
	
	cout<<dp[n];
}

Measured memory_bytes: 1024
def main():  
  import sys
  read = sys.stdin.buffer.read
  readline = sys.stdin.buffer.readline
  readlines = sys.stdin.buffer.readlines

  h,w = map(int,readline().split())
  a = []
  for i in range(h):
    s = list(map(int,readline().split()))
    a.append(s)
  b = []
  for i in range(h):
    t = list(map(int,readline().split()))
    b.append(t)
  C = [[0]*w for _ in range(h)]
  for i in range(h):
      for j in range(w):
          C[i][j] = abs(a[i][j] - b[i][j])

  dp = [[[0]*6321 for i in range(w)] for _ in range(h)]
  dp[0][0][C[0][0]] = 1

  for i in range(h):
    for j in range(w):
      for k in range(6321):
        if dp[i][j][k]:
          if i < h-1:
            c = C[i+1][j]
            if k+c < 6321:
              dp[i+1][j][k+c] = 1
            dp[i+1][j][abs(k-c)] = 1
          if j < w-1:
            d = C[i][j+1]
            if k+d < 6321:
              dp[i][j+1][k+d] = 1
            dp[i][j+1][abs(k-d)] = 1

  for i in range(6321):
    if dp[h-1][w-1][i]:
      print(i)
      break
      
if __name__ == "__main__":
    main()

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

/* constant */

const int MAX_N = 52;
const int MAX_C = 13;

/* typedef */

/* global variables */

int n;
int cs[MAX_C + 1], ans[MAX_N];

/* subroutines */

bool rec(int k, int sum) {
  if (k == n - 1) {
    ans[k] = sum;
    return true;
  }
  
  for (int i = 1; i <= MAX_C; i++)
    if (cs[i] > 0 && sum % i == 0) {
      cs[i]--;
      ans[k] = i;
      if (rec(k + 1, sum - i)) return true;
      cs[i]++;
    }

  return false;
}

/* main */

int main() {
  for (;;) {
    cin >> n;
    if (n == 0) break;

    int sum = 0;
    memset(cs, 0, sizeof(cs));

    for (int i = 0; i < n; i++) {
      int ci;
      cin >> ci;
      cs[ci]++;
      sum += ci;
    }
    //cout << sum << endl;

    if (rec(0, sum)) {
      for (int i = n - 1; i >= 0; i--) {
	if (i < n - 1) cout << ' ';
	cout << ans[i];
      }
      cout << endl;
    }
    else
      cout << "No" << endl;
  }
  
  return 0;
}

Measured memory_bytes: 1160
num = int(input())
list = [int(x) for x in input().split()]

count = 0
any = 0

color = []

for i in range(num):
    if 1 <= list[i] < 400:
        color.append("gray")
    elif 400 <= list[i] < 800:
        color.append("brown")
    elif 800 <= list[i] < 1200:
        color.append("green")
    elif 1200 <= list[i] < 1600:
        color.append("sky")
    elif 1600 <= list[i] < 2000:
        color.append("blue")
    elif 2000 <= list[i] < 2400:
        color.append("yellow")
    elif 2400 <= list[i] < 2800:
        color.append("orange")
    elif 2800 <= list[i] < 3200:
        color.append("red")
    else:
        color.append("any")



if "gray" in color:
    count += 1
else:
    None


if "brown" in color:
    count += 1
else:
    None


if "green" in color:
    count += 1
else:
    None


if "sky" in color:
    count += 1
else:
    None


if "blue" in color:
    count += 1
else:
    None


if "yellow" in color:
    count += 1
else:
    None


if "orange" in color:
    count += 1
else:
    None


if "red" in color:
    count += 1
else:
    None



if count == 0:
    print("1",color.count("any"))
else:
    print(count,count+color.count("any"))

Measured memory_bytes: 3064
#include <algorithm>
#include <bitset>
#include <climits>
#include <complex>
#include <fstream>
#include <functional>
#include <iostream>
#include <map>
#include <memory>
#include <queue>
#include <regex>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <thread>
#include <tuple>
#include <type_traits>
#include <vector>

#include <stdio.h>

using ll = long long;
using namespace std;

vector<vector<bool>> v;

int main() {
    ios::sync_with_stdio(false);
    int n;
    cin >> n;
    int x, l;

    priority_queue<pair<int, int>, vector<pair<int, int>>,
                   function<bool(const pair<int, int>, const pair<int, int>)>>
        q([](const pair<int, int>& l, const pair<int, int> r) {
            return l.second > r.second;
        });
    for (int i = 0; i < n; i++) {
        cin >> x >> l;
        q.emplace(x - l, x + l);
    }

    int last = INT_MIN;
    int ans = 0;
    while (!q.empty()) {
        pair<int, int> p = q.top();
        q.pop();
        if (p.first < last) {
            ans++;
            continue;
        }
        last = p.second;
    }
    cout << (n - ans) << endl;

    return 0;
}


Measured memory_bytes: 3776
#include <stdio.h>
int main()
{
    double L[10];
    double V1, V2;
    double meet_pos, railway_lenth;
    int cnt, output_cnt;
    int output[50];
    
    output_cnt = 0;
    /*Input and process*/
    while(scanf("%lf,", &L[0]) != EOF){
    	for(cnt = 1; cnt < 10; cnt++)
			scanf("%lf,", &L[cnt]);
		scanf("%lf,%lf", &V1, &V2);
    	
    	railway_lenth = 0;
    	for(cnt = 0; cnt < 10; cnt++)
			railway_lenth += L[cnt];
    	meet_pos = railway_lenth * V1 / (V1 + V2);
    	
    	railway_lenth = 0;
    	for(cnt = 0; railway_lenth < meet_pos; cnt++)
			railway_lenth += L[cnt];
    	output[output_cnt] = cnt;
    	output_cnt++;
    }
    /*Output*/
    for(cnt = 0; cnt < output_cnt; cnt++)
		printf("%d\n", output[cnt]);
    
    return 0;
} 

Measured memory_bytes: 624
#include <iostream>
#include <map>
#include <sstream>
#include <vector>
#include <algorithm>

using namespace std;

typedef long long ll;

string int_to_str(int n) {
	stringstream ss;
	string ret;

	ss << n;
	ss >> ret;

	return ret;
}


int keta(int n) {
	string str = int_to_str(n);

	return str.size();
}

int main() {
	int n;
	while (cin >> n, n) {
		bool f = false;
		map<int, ll> datas;
		vector<int> noes;
		for (int i = 0; i < n; ++i) {
			ll no, a, b; cin >> no >> a >> b;

//			if ( find( noes.begin(), noes.end(), no) == noes.end() )
//				noes.push_back(no);

			if (datas[no] < 1000000) {
				if ((datas[no] += a * b) >= 1000000) {
					cout << no << endl;
					f = true;
				}
			}
		}
/*
		for (int i = 0; i < noes.size(); ++i)
			if (datas[noes[i]] >= 1000000)
				cout << noes[i] << endl;
*/
		if (!f) cout << "NA" << endl;
	}
}

Measured memory_bytes: 0
import java.io.PrintWriter;
import java.util.Scanner;

public class Main {
    void solve(Scanner sc, PrintWriter pw) {
        int L = sc.nextInt();
        int R = sc.nextInt();
        int d = sc.nextInt();
        pw.println(R / d - (L - 1) / d);
    }
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        PrintWriter pw = new PrintWriter(System.out);
        new Main().solve(sc, pw);
        pw.flush();
        pw.close();
        sc.close();
    }
}


Measured memory_bytes: 35668
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<ll> vl;
#define rep(i, n) for(ll i = 0;i < n;i++)
#define all(i) i.begin(), i.end()
template<class T, class U> void cmax(T& a, U b) { if (a<b) a = b; }
template<class T, class U> void cmin(T& a, U b) { if (a>b) a = b; }

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

  int n;
  cin >> n;

  vector<pii> ans;
  rep(i, n) {
    rep(j, n) {
      if (n%2 == 0) {
        if (i < j && i+1 + j+1 != n+1)
          ans.push_back(pii(i+1, j+1));
      } else {
        if (i < j && i+1 + j+1 != n)
          ans.push_back(pii(i+1, j+1));
      }
    }
  }

  cout << ans.size() << endl;
  for (auto&& i : ans) {
    cout << i.first << " " << i.second << endl;
  }
}


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

int main(void){
    int h, w, n;
    
    cin >> h >> w;
    cin >> n;
    
    int a[10005];
    int field[200][200];

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

    int k=0, cnt=0, l=0;

    for(int i=0; i<n; i++){
        for(int j=0; j<a[i]; j++){
            field[k][l++] = i+1;
            cnt++;
            if(cnt >= w){
                k++;
                l = 0;
                cnt = 0;
            }
        }
    }

    for(int i=1; i<h; i += 2){
        for(int j=0; j<w/2; j++){
            int tmp = field[i][j];
            field[i][j] = field[i][w-1-j];
            field[i][w-1-j] = tmp;
        }
    }

    for(int i=0; i<h; i++){
        for(int j=0; j<w; j++){
            cout << field[i][j];
            if(j != w-1){
                cout << " ";
            }
        }
        cout << endl;
    }

    return 0;
}



Measured memory_bytes: 384
#include <iostream>
#include <cstdio>
#include <string>
#include <vector>
#include <algorithm>
#include <list>
#include <iomanip>
#include <queue>
#include <functional>
#include <cassert>
#include <cmath>


#define REP(i, n) for(int i = 0; i < (n); i++)
#define FOR(i, a, b) for(int i = (a); i < (b), i++)
#define NL << endl

using namespace std;
using ll = long long;
using ull = unsigned long long;

int main() {

	vector<int> a;
	int n, k;
	int n1;
	int p;

	cin >> n >> k;
	n1 = n - 1;
	a.resize(n);
	REP(i, n) {
		cin >> a[i];
		if (a[i] == 1) {
			p = i;
		}
	}

	int ans = 1;
	ans += (n - k) / (k - 1);
	if ((n - k) % (k - 1) != 0) {
		ans++;
	}

	cout << ans NL;



	return 0;
}

Measured memory_bytes: 640
n = int(input())
a = list(map(int,input().split()))
b = list(map(int,input().split()))
c = [0 for _ in range(n+1)]
for ai in a:
  c[ai] += 1
for bi in b:
  c[bi] += 1
if max(c) > n:
  print("No")
  exit()
print("Yes")
b.reverse()
flag = True
si = -1
ti = -1
for i in range(n):
  if flag:
    if a[i] == b[i]:
      si = i
      flag = False
  else:
    if a[i] != b[i]:
      ti = i-1
      break
if si == -1:
  for bi in b:
    print(bi,end=" ")
  exit()
if ti == -1:
  ti = n-1
s = a[si]
ni = [0 for _ in range(ti-si+1)]
xi = 0
for i in range(n):
  if xi >= ti-si+1:
    break
  if a[i] != s and b[i] != s:
    ni[xi] = b[i]
    b[i] = s
    xi += 1
nb = b[0:si] + ni + b[ti+1:]
for nbi in nb:
  print(nbi,end=" ")

Measured memory_bytes: 122984
#include <iostream>
using namespace std;
int main(void) {
    int N,a,b,c,d;
    cin>>N;
    a=N/1000;
    b=N/100;
    b=b%10;
    c=N/10;
    c=c%10;
    d=N%10;
    if(a==b && b==c){
        cout<<"Yes"<<endl;
    }else if(b==c && c==d){
        cout<<"Yes"<<endl;
    }
    else{
        cout<<"No"<<endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <string.h>
#include <queue>
#include <algorithm>
#include<iostream>
#include<vector>
#include<map>
#include<string>
#include <iomanip>
#include<deque>
#include<stack>
#include<set>
#include <numeric>

using namespace std;
typedef unsigned int uint;
typedef long long ll;
//typedef pair<int, int> P;
const int INF = 111111111;
const ll LLINF = 1e17 + 1;
const int DX[9] = { 0,0,1,-1, 1, 1, -1, -1, 0 }; // 4;４近傍
const int DY[9] = { 1,-1,0,0, 1, -1, 1, -1, 0 }; // 8:８近傍 9:(0,0)を含む
const int DIV = 1000000007; //10^9 + 7
const double PI = 3.14159265358979323846264338327950288;




int main() {

	//==================================
	cin.tie(nullptr);
	ios_base::sync_with_stdio(false);
	cout << fixed << setprecision(15);
	//==================================

	int N, M, K;
	cin >> N;
	vector<int> X(N), Y(N);
	for (int i = 0; i < N; i++) {
		cin >> X[i] >> Y[i];
	}

	int p = 1;
	for (int i = 1; i <= N - 1; i++) {
		p *= i;
	}

	double sum = 0;
	for (int i = 0; i < N; i++) {
		for (int j = i + 1; j < N; j++) {
			double len = sqrt((X[i] - X[j]) * (X[i] - X[j]) + (Y[i] - Y[j]) * (Y[i] - Y[j]));
			sum += len * p;
		}
	}


	double ans = sum / (p * N);

	cout << ans * 2;

}	


Measured memory_bytes: 256