akhauriyash/Code-Regression huggingface dataset:
#include <algorithm>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
using namespace std;

typedef long long ll;
typedef pair<int, int> P;
typedef pair<int, char> Pc;
typedef pair<int, string> Ps;

const int dx[4] = {-1, 0, 0, 1};
const int dy[4] = {0, -1, 1, 0};
const int dx8[8] = {0, 1, 1, 1, 0, -1, -1, -1};
const int dy8[8] = {-1, -1, 0, 1, 1, 1, 0, -1};
const string dir8[8] = {"U", "RU", "R", "RD", "D", "LD", "L", "LU"};

// Self settings
// clang-format off
#define MAX_N 100000
#define MAX 100000
#define INFTY (1<<30)
#define EPS (1e-10)
#define equals(a, b) (fabs((a) - (b)) < EPS)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i, N) for (int i = 0; i < (int)(N); ++i)
#define SLN(i,N) (i == N-1 ? "\n" : " ")
ll fact(ll n) { ll res = 1; for(ll i=2;i<=n;++i) res = res * i; return res;}
ll nCr(ll n, ll r) {return (fact(n)/fact(n-r)*fact(r)) ;}
ll gcd(ll a,ll b){if(b==0)return a;return gcd(b,a%b);}
ll lcm(ll a,ll b){return a/gcd(a,b)*b;}
const ll MOD = 1e9+7;
const ll INF = 1LL << 60;
const int inf = 1000100011;
class Point { public: double x, y; Point(double x = 0, double y = 0) : x(x), y(y) {} Point operator+(Point p) { return Point(x + p.x, y + p.y); } Point operator-(Point p) { return Point(x - p.x, y - p.y); } Point operator*(double a) { return Point(a * x, a * y); } Point operator/(double a) { return Point(x / a, y / a); } double abs() { return sqrt(norm()); } double norm() { return x * x + y * y; } bool operator<(const Point& p) const { return x != p.x ? x < p.x : y < p.y; } bool operator==(const Point& p) const { return fabs(x - p.y) < EPS && fabs(y - p.y) < EPS; } };
typedef Point Vector;
double norm(Vector a) { return a.x * a.x + a.y * a.y; }
double abs(Vector a) { return sqrt(norm(a));}
double dot(Vector a, Vector b) { return a.x * b.x + a.y * b.y; }
double cross(Vector a, Vector b) { return a.x * b.y - a.y * b.x; }
struct Segment { Point p1, p2; };
typedef Segment Line;
struct Node { int data; Node *left, *right; Node(int data) : data(data), left(NULL), right(NULL) {} };
// clang-format on

int main(void) {
  cin.tie(0);
  ios::sync_with_stdio(false);
  std::cout << std::fixed << std::setprecision(15);
  int N;
  cin >> N;
  vector<ll> A(N);
  REP(i, N) cin >> A[i];
  map<ll, ll> mp;
  REP(i, N) {
    if (A[i] > 3 * 10e5) continue;
    mp[i + 1 + A[i]]++;
  }
  ll ans = 0;
  REP(j, N) {
    ll id = j + 1;
    ll target = id - A[j];
    if (mp.count(target) > 0) {
      ans += mp[target];
    }
  }
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 16760
using System;
using System.Collections;
using System.Collections.Generic;

namespace ConsoleApplication6
{
    class Program
    {
        static void Main(string[] args)
        {
            Hashtable paper = new Hashtable();
            string read = Console.ReadLine();
            int N = int.Parse(read);
            
            for (int i = 0; i < N; i++)
            {
                read = Console.ReadLine();
                int A = int.Parse(read);
                if (paper[A] == null) paper[A] = 1;
                else paper.Remove(A);
            }
            Console.WriteLine(paper.Count);
        }
    }
}

Measured memory_bytes: 25436
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int a,b,c;
  char d,e;
  cin >> a >> d >> b >> e >> c;
  if(b <= 4){
    cout << "Heisei"  << endl;
  }
  else{
    cout << "TBD"  << endl;
  }
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
const int maxn=300005;
int f[maxn],n,m,cnt;
int getf(int x) {
    if(f[x]==x)return x;
    return f[x]=getf(f[x]);
}
int main() {
    int x,y,z;
    scanf("%d%d",&n,&m);
    for(register int i=1; i<=3*n; i++) {
        f[i]=i;
    }
    for(register int i=1; i<=m; i++) {
        scanf("%d%d%d",&x,&y,&z);
        int fx=getf(x),fy=getf(y);
        f[fy]=fx;
        if(z%2==0) {
            if(getf(x+2*n)==getf(y+n)||getf(x+n)==getf(y+2*n)) {
                puts("0");
                return 0;
            }
            fx=getf(x+n),fy=getf(y+n);
            f[fy]=fx;
            fx=getf(x+2*n),fy=getf(y+2*n);
            f[fy]=fx;
        } else {
            if(getf(x+n)==getf(y+n)) {
                puts("0");
                return 0;
            }
            fx=getf(x+2*n),fy=getf(y+n);
            f[fy]=fx;
            fx=getf(x+n),fy=getf(y+2*n);
            f[fy]=fx;
        }
    }
    for(register int i=1; i<=n; i++) {
        if(f[i]==i) {
            cnt++;
        }
    }
    printf("%d",cnt);
    return 0;
}

Measured memory_bytes: 4948
#define _GLIBCXX_DEBUG
#include<bits/stdc++.h>
#define ll long long
#define ull unsigned long long
#define FIO ios_base::sync_with_stdio(false);cin.tie(NULL);
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define ff first
#define ss second
#define vll vector<ll>
#define pll pair<ll,ll>
#define vpll vector<pll>
#define vvll vector<vll>
#define all(v) v.begin(),v.end()
#define FOR(i,n) for(ll i=0;i<n;i++)
#define ffo(i,a,b) for(ll i=a;i<=b;i++)
#define rfo(i,a,b) for(ll i=a;i>=b;i--)
#define space cout<<"\n\n";
#define endl "\n"
#define pqmx priority_queue<ll>
#define pqmn priority_queue<ll,vll,greater<ll>>
#define fps(x,y) fixed<<setprecision(y)<<x
#define merg(a,b,c) set_union(a.begin(),a.end(),b.begin(),b.end(),inserter(c,c.begin()))
#define set_ar(arr,v) memset(arr,v,sizeof(arr))
#define ctime auto start = high_resolution_clock::now()
#define etime auto stop = high_resolution_clock::now()
#define go_t int testcases; cin>>testcases; ffo(caseno,1,testcases)
#define ptime auto z1z = duration_cast<microseconds>(stop-start); cout<<"Time elapsed : "<<z1z.count()<<" microseconds\n"
#define dbg1(x)             cout <<#x<<": "<<x<<'\n';
#define dbg2(x, y)          cout <<#x<<": "<<x<<" | "<<#y<<": "<<y<<'\n';
#define dbg3(x, y, z)       cout <<#x<<": "<<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<'\n';
#define dbg4(a, b, c, d)    cout <<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<'\n';
#define dbg5(a, b, c, d, e) cout <<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<<": "<<e<<'\n';

using namespace std;
using namespace std::chrono;

const ll mod = 1e9 + 7;
const ll N = 1e6 + 6;
const ll maxN = 2e5 + 5;
const ll MAX_SIZE = 2e6 + 6;
const ll INF = 0x3f3f3f3f3f3f3f3fll;
const double PI = 3.14159265359;

ll powerM(ll x, ll y, ll M = mod) { // default argument
	ll v = 1; x = x % M; while (y > 0) {if (y & 1)v = (v * x) % M; y = y >> 1; x = (x * x) % M;} return v;
}

ll power(ll x, ll y) {
	ll v = 1; while (y > 0) {if (y & 1)v = v * x; y = y >> 1; x = x * x;} return v;
}

ll a[maxN];
ll n, k;

// in previous submissions, I made 2 mistakes
// 1-> if length of rod == len_req , then we don't have to divide it
// 2-> I chose the bounds of binary search wrongly by selecting l=0

bool is_poss(ll len) {
	ll cnt = 0;
	for (ll i = 0; i < n; ++i) {
		if (a[i] > len) cnt += (a[i] / len);
	}
	return cnt <= k;
}

int main()
{
#ifndef ONLINE_JUDGE
	freopen("in2.txt", "r", stdin);
	freopen("out2.txt", "w", stdout);
#endif
	FIO
	cin >> n >> k;
	FOR(i, n) {
		cin >> a[i];
	}

	ll l = 1, r = 1e12;
	while (l < r) {
		ll mid = (l + r) / 2;
		if (is_poss(mid)) {
			r = mid;
		}
		else {
			l = mid + 1;
		}
	}
	cout << l << endl;
	return 0;
}


Measured memory_bytes: 5156
#include<bits/stdc++.h>
#define ull unsigned long long
#define ll long long
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define pii pair<int,int>
#define mod 1000000007
#define INF 1000000000
int dx[4] = {-1,0,1,0};
int dy[4] = {0,-1,0,1};
using namespace std;
vector<vector<int> > g;
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int h,w;
    cin>>h>>w;
    //cout<<h<<' '<<w<<endl;
    int dp[h][w];
    memset(dp,0,sizeof(dp));
    string arr[h];
    for(int i=0;i<h;i++)
    {
        cin>>arr[i];
    }
    dp[0][0] = 1;
    for(int i=1;i<h;i++)
    {
        if(arr[i][0] == '.')
            dp[i][0] = 1;
        else
            break;
    }
    for(int i=1;i<w;i++)
    {
        if(arr[0][i] == '.')
            dp[0][i] = 1;
        else
            break;
    }
    for(int i=1;i<h;i++)
    {
        for(int j=1;j<w;j++)
        {
            if(arr[i][j] == '#')
                dp[i][j] = 0;
            else
            {
                dp[i][j] = (dp[i-1][j] + dp[i][j-1])%mod;
            }
        }
    }
    // for(int i=0;i<h;i++)
    // {
    //     for(int j=0;j<w;j++)
    //         cout<<dp[i][j]<<' ';
    //     cout<<endl;
    // }
    cout<<dp[h-1][w-1];



}

Measured memory_bytes: 5248
#include <cstdio>
#include <cstdlib>
#include <string>
#include <cmath>
#include <cassert>
#include <iostream>
#include <sstream>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <utility>
#include <numeric>
#include <algorithm>
#include <bitset>
#include <complex>

using namespace std;

typedef unsigned uint;
// typedef long long Int;

const int INF = 1001001001;
// const Int INFLL = 1001001001001001001LL;

const long double EPS = 1e-10;

bool eq(long double a, long double b)
{
	return (fabs(a - b) <= EPS);
}

bool lt(long double a, long double b)
{
	return (a - b < -EPS);
}

bool gt(long double a, long double b)
{
	return (a - b > +EPS);
}

struct Event {
	int s1, s2;
	long double time;
	Event(int s1, int s2, long double time) : s1(s1), s2(s2), time(time){}
	Event(){}
};

bool operator < (const Event &a, const Event &b)
{
	return (lt(a.time, b.time));
}

int main()
{
	int n;
	
	while (scanf("%d", &n) && n){
		long double px[256], py[256], pz[256], vx[256], vy[256], vz[256], r[256], vr[256];
		long double ret[256];
		vector<Event> v;
		for (int i = 0; i < n; i++){
			scanf("%Lf %Lf %Lf %Lf %Lf %Lf %Lf %Lf", px + i, py + i, pz + i, vx + i, vy + i, vz + i, r + i, vr + i);
			v.push_back(Event(i, i, r[i] / vr[i]));
			ret[i] = -1;
		}
		
		for (int i = 0; i < n; i++){
			for (int j = i + 1; j < n; j++){
				long double DX = vx[i] - vx[j], DY = vy[i] - vy[j], DZ = vz[i] - vz[j];
				long double PX = px[i] - px[j], PY = py[i] - py[j], PZ = pz[i] - pz[j];
				long double R = r[i] + r[j], VR = vr[i] + vr[j];
				
				long double a = DX * DX + DY * DY + DZ * DZ - VR * VR;
				long double b = 2 * PX * DX + 2 * PY * DY + 2 * PZ * DZ + 2 * R * VR;
				long double c = PX * PX + PY * PY + PZ * PZ - R * R;
				
				if (eq(a, 0)){
					if (!eq(b, 0)){
						// bt + c = 0, t = -c / b
						v.push_back(Event(i, j, - c / b));
					}
				}
				else {
					if (b * b - 4 * a * c > 0){
						long double D = b * b - 4 * a * c;
						v.push_back(Event(i, j, (-b + sqrt(D)) / (2 * a)));
						v.push_back(Event(i, j, (-b - sqrt(D)) / (2 * a)));
					}
				}
			}
		}
		
		sort(v.begin(), v.end());
		
		for (int i = 0; i < v.size(); i++){
			if (lt(v[i].time, 0)) continue;
			if (gt(ret[v[i].s1], 0) || gt(ret[v[i].s2], 0)) continue;
			ret[v[i].s1] = ret[v[i].s2] = v[i].time;
		}
		
		for (int i = 0; i < n; i++){
			printf("%.10Lf\n", ret[i]);
		}
	}
	
	return (0);
}

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

int main() {
  int N, K;
  scanf("%d %d", &N, &K);

  int res = 1;
  for (int i = 0; i < N; ++i)
    res = std::min(res*2, res+K);

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

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

int main() {
  int n;cin>>n;
  set<string> st;
  rep(i,n){
    string s;cin>>s;
    st.insert(s);
  }
  cout<<st.size()<<endl;
}

Measured memory_bytes: 19196
#include <stdio.h>
#include <vector>
#include <iostream>
#include <math.h>
#include <algorithm>
#include <cstring>
#include <string>
using namespace std;
using ll = long long;

int main(){
  string str = "aeiou";
  char c;
  cin >> c;
  if((int)str.find(c) >= 0){
    puts("vowel");
  } else{
    puts("consonant");
  }
  return 0;
}

Measured memory_bytes: 256
import java.util.*;
public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String str = sc.next();
		System.out.println(str.charAt(0) == str.charAt(1) || 
				str.charAt(1) == str.charAt(2) || 
				str.charAt(2) == str.charAt(3) ? "Bad" : "Good");
	}
}

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

int main()
{
	string s;
	int n;
	getline(cin, s);
	n = s.size();
	for (int i = 0; i < n; i++)
	{

		if (s[i] == 'a' && s[i + 1] == 'p' && s[i + 2] == 'p' && s[i + 3] == 'l' && s[i + 4] == 'e')
		{
			s[i] = 'p';
			s[i + 1] = 'e';
			s[i + 2] = 'a';
			s[i + 3] = 'c';
			s[i + 4] = 'h';
			continue;
		}
		
		if (s[i] == 'p' && s[i + 1] == 'e' && s[i + 2] == 'a' && s[i + 3] == 'c' && s[i + 4] == 'h')
		{
			s[i] = 'a';
			s[i + 1] = 'p';
			s[i + 2] = 'p';
			s[i + 3] = 'l';
			s[i + 4] = 'e';
			continue;
		}
	}
	cout << s << endl;


	return 0;
}



Measured memory_bytes: 3100
#include <iostream>
#include <string>
#include <cstdlib>
#include <cmath>
using namespace std;

int main(void) {
	double a, b;
	cin >> a >> b;
	if (a > b)cout << "GREATER";
	else if (a < b)cout << "LESS";
	else cout << "EQUAL";
	
	return 0;
}

Measured memory_bytes: 256
// We only fail when we stop trying
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define mp make_pair
#define endl '\n'
#define D(x) cerr << #x << " = " << (x) << '\n'
#define sz(x) ((int)(x).size())
#define all(x) (x).begin(), (x).end()

const int N = 1e5 + 5;

int n, m;
int h[N];
vector<int> g[N];

int main()
{
  cin >> n >> m;
  for(int i = 0 ; i < n ; i++)
    cin >> h[i];
  for(int i = 0 ; i < m ; i++) {
    int a, b;
    cin >> a >> b;
    g[--a].pb(--b);
    g[b].pb(a);
  }
  int ans = 0;
  for(int i = 0 ; i < n ; i++) {
    int mx = 0;
    for(int v : g[i])
      mx = max(mx, h[v]);
    ans += mx <  h[i];
  }
  cout << ans << endl;
  return 0;
}


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

using namespace std;

int calc(int a, int b, int op)
{
    return (op==0 ? a+b : a-b);
}
int main()
{
    string S;
    cin >> S;

    int i, j, k;
    char op[2] = {'+', '-'};
    bool flag = false;
    for (i = 0; i < 2; i++) {
        for (j = 0; j < 2; j++) {
            for (k = 0; k < 2; k++) {
                if (calc(calc(calc(S[0]-'0', S[1]-'0', i), S[2]-'0', j), S[3]-'0', k) == 7) {
                    flag = true;
                    break;
                }
            }
            if (flag) break;

        }
        if (flag) break;
    }

    cout << S[0] << op[i] << S[1] << op[j] << S[2] << op[k] << S[3] << "=7" << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
    int a;
    cin>>a;
    int coun=0;
    if(a%10==1)
    {
      coun++;
    }
    if((a/10)%10==1)
    {
      coun++;
    }
    if((a/100)%10==1)
    {
      coun++;
    }

    cout<<coun;

    return 0;
}


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

int main()
{
int A,B,C,count=0,ba=0,bb=0,bc=0;scanf("%d %d %d",&A,&B,&C);
while(A%2!=1&&B%2!=1&&C%2!=1)
{
  if(max({ba,bb,bc})==max({A,B,C})&&min({ba,bb,bc})==min({A,B,C})){count=-1;break;}
  int a=A/2,b=B/2,c=C/2;ba=A,bb=B,bc=C;
  A=b+c,B=a+c,C=a+b;
  count++;
}
printf("%d\n",count);
}

Measured memory_bytes: 256
import java.util.HashSet;
import java.util.Scanner;
import java.util.Set;

public class Main{

	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		int[] nums = new int[3];
		for (int i = 0; i < 3; i++) {
			nums[i] = scan.nextInt();
		}
		
		Set<Integer> list = new HashSet<Integer>();
		int cnt = 0;
		for (int x : nums) {
			if (list.contains(x)) {
				cnt++;
			} else {
				list.add(x);
			}
		} 
		
		if (cnt == 1) {
			System.out.println("Yes");
		} else {System.out.println("No");}
		

	}

}

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

using namespace std;


int mp[150000];
int arr[150000];

int main(){
	int n;
	cin>>n;
	mp[n]=1;
	arr[1]=n;
	for(int i=2;i<1000000;i++){
		if(arr[i-1]%2==0){
			arr[i]=arr[i-1]/2;
		}else{
			arr[i]=arr[i-1]*3+1;
		}
		
		if(mp[arr[i]]!=0){
			cout<<i;
			return 0;
		}else{
			mp[arr[i]]=i;
		}
		
	}
	return 0;
} 

Measured memory_bytes: 256
#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 pai 3.14159265358979323846
const int INF = 1001001001;
typedef long long ll;
int A[3][3], N;
bool punched[3][3];
bool ok[3][3];
int a[3][3],n;
using Graph = vector<vector<int>>;
vector<vector<int>> field;
vector<bool> seen;

 
ll gcd(ll m, ll n) {
  if (n == 0) return m;
  else return gcd(n, m % n);
}
 
ll lcm(ll a, ll b) {
  return a / gcd(a, b) * b;
}
 
int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  ll A, B, C, D;
  cin >> A >> B >> C >> D;
  ll ans = B - A + 1;
  ll kc = (B + C) / C - (A + C - 1) / C;
  ll kd = (B + D) / D - (A + D - 1) / D;
  ll g = lcm(C, D);
  ll kg = (B + g) / g - (A + g - 1) / g;
  ans = ans - kc - kd + kg;
  cout << ans << "\n";
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cassert>
#include <climits>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <fstream>

using namespace std;
#define TOSTRING(x) #x
#define SZ(x) (int)(x).size()
#define REP(i,n) for(int i=0;i<(n);i++)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REPR(i,n) for(int i=(n)-1;i>=0;i--)
#define ALL(s) (s).begin(), (s).end()
#define so(V) sort(ALL(V))
#define rev(V) reverse(ALL(V))
#define uni(v) v.erase( unique(ALL(v)) , v.end());
#define PAU system("pause")

typedef long long unsigned int llu;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<bool> vb;
typedef vector<vi> vvi;
typedef vector<vll> vvll;
typedef vector<vb> vvb;
const double EPS = 1e-9;
const int MOD = 1e9 + 7;
const int INF = (1 << 28);
const ll LINF = 1e18;
const double PI = acos(-1);

int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	int A, B, C;
	cin >> A >> B >> C;
	cout << B + min(C, A + B + 1) << endl;
	PAU;
	return 0;
}


Measured memory_bytes: 504
import numpy as np
H,W,K=map(int,input().split())
A=np.zeros((W,W))
mod=10**9+7
for i in range(1<<(W-1)):
    flag=True
    s=0
    for j in range(W-1):
        if i&(1<<j) and s==0:
            s=1
        elif i&(1<<j) and s==1:
            flag=False
            break
        else:
            s=0
    if flag:
        #print(bin(i))
        L=[int(i) for i in range(W)]
        for j in range(W-1):
            if i&(1<<j):
                L[j]=j+1
                L[j+1]=j
        for j in range(W):
            A[j][L[j]]+=1
x=np.zeros(W)
x[0]=1
for i in range(H):
    x=np.dot(A,x)
    x%=mod
print(int(x[K-1]))



Measured memory_bytes: 14452
#include <bits/stdc++.h>
using namespace std;
#define M 1000000007
long long int power(int a,int b)
{
    if(b==0)
        return 1;
    long long int k=power(a,b/2);
    if(b%2==0)
        return ((k%M)*(k%M))%M;
    else
        return ((k%M)*(k%M)*(a%M))%M;
}
long long int fact(long long int n)
{
    if(n==1 || n==0)
        return 1;
    else
        return ((n%M)*(fact(n-1)%M))%M;

}
int div(int n)
{  int c=0;
    for(int i=1;i<sqrt(n);i++)
    {
        if(n%i==0)
        {
          c++;
        }
    }
    c=c*2;
    if(pow(sqrt(n),2)==(sqrt(n)*sqrt(n)))
        c++;
    return  c;
}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
     #ifndef ONLINE_JUDGE
 
    freopen("input.txt","r",stdin);
    freopen("output.txt","w",stdout);
 
   #endif
   int n;
   long long int sum=0;
   cin>>n;
   while(n--)
   {
    int l,r;
    cin>>l>>r;
    sum+=r-l+1;
   }
   cout<<sum;



 return 0;
}








Measured memory_bytes: 3668
n=list(map(int,input()))
keta=len(n)
satsu=0

for i in range(keta):
    tmp = n.pop()
    if i == keta-1:
        n.append(0)
    
    if tmp == 10:
        tmp=0
        n[-1]=n[-1]+1
    if tmp > 5 or (tmp==5 and n[-1] >= 5):
        satsu += 10 - tmp
        n[-1] = n[-1] + 1
    else:
        satsu += tmp

print(satsu+n[0])


Measured memory_bytes: 13508
#include<bits/stdc++.h>
#include<iostream>
#include<algorithm>
#include<vector>
#include<cmath>
using namespace std;
#define MAX 1000000005
 
typedef long long ll;
typedef std::pair<int, int> pr;

int main(int, char**)
{
    int x;
    cin >> x;

    int a = 0;
    int b = 0;
    bool found = false;
    for (int i = -118; !found && i <= 119; i++) {
        for (int j = -119; !found && j <= 118; j ++) {
            if (pow(i, 5) - pow(j, 5) == x) {
                a = i;
                b = j;
                found = true;
            }
        }
    }

    cout << a << " " << b << endl;

    return 0;
}

Measured memory_bytes: 4004
#include <iostream>
using namespace std;
int main(void){
    int dress, party;
    cin >> dress >> party;
    
    if(party % dress == 0){
        cout << party / dress << endl; //ちょうど同じ回数ずつ着まわせる場合
    }
    else cout << party / dress + 1 << endl; //どのドレスかが他より多めに着る場合
    return 0;
}



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

int main()
{
    string s;
    int N, x = 0, maxval = -1000;
    cin >> N >> s;
    for(int i=0; i<N; i++) {
        if(s[i]=='I') x++;
        else if(s[i]=='D') x--;
        maxval = max(max(maxval, x), 0);
    }
    cout << maxval << endl;
    return 0;
}

Measured memory_bytes: 256
/** coder Mohammad Al-Hussein *_^ */
#include <bits/stdc++.h>
#define ll long long
#define F first
#define S second
#define mp make_pair
#define All(v) v.begin(),v.end()
#define mod  1000000007
#define write freopen("output.txt","w",stdout)
#define read freopen("test (1).txt","r",stdin)
#define FIO std::ios_base::sync_with_stdio(false);
using namespace std;

int main()
{
    int n;
    cin >> n;
    ll A = 1LL,B = 1LL;
    for(int i=0; i<n; i++)
    {
        ll x,y;
        cin >> x >> y;
        //if(x != y)
        {
            ll r1 = max(A/x + (A%x != 0),B/y + (B%y != 0));

            A = 1LL * x*r1;
            B = 1LL * y*r1;
        }
    }
    cout << A+B << '\n';








    return 0;
}


Measured memory_bytes: 256
n,x=map(int,input().split())
a=sorted(list(map(int,input().split())))
if a[0]>x:
    print(0)
    exit()
cnt=1
for i in range(1,n):
    a[i]+=a[i-1]
    if a[i]>x:
        break
    cnt+=1
if cnt==n and a[-1]!=x:
    cnt-=1
print(cnt)


Measured memory_bytes: 3060
#include<stdio.h>

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

  while(1){
    r = a % b;
    if(r == 0) break;
    a = b;
    b = r;
  }
  
  printf("%d\n",b);  
  return 0;
  
}

Measured memory_bytes: 592
macro_rules! scan_sub {
    ( $itr:ident, $t:ty ) => {
        let mut buf = String::new();
        let $itr = {
            while buf.trim().len() == 0 {
                buf = String::new();
                std::io::stdin().read_line(&mut buf).unwrap();
            }
            buf.split_whitespace().map(|n| n.parse::<$t>().unwrap())
        };
    };
}

macro_rules! scan {
    ( $x:ident; Vec<$t:ty> ) => {
        scan_sub!(itr, $t);
        let $x = itr.collect::<Vec<_>>();
    };
    ( $( $x:ident ),*; $t:ty ) => {
        scan_sub!(itr, $t);
        let mut itr = itr;
        $(
            let $x = itr.next().unwrap();
        )*
    };
}

fn main() {
    scan!(_n, m; usize);
    scan!(array; Vec<f64>);

    let s: f64 = array.iter().sum();
    let border: f64 = s / (4.0 * m as f64);

    let res = array.iter()
        .filter(|&&a| border <= a)
        .collect::<Vec<_>>()
        .len();

    println!("{}", if m <= res {"Yes"} else {"No"});
}


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

using namespace std;

int main(){
	string str,ans;
	cin>>str;
	for(auto c:str){
		if(c=='1') ans+='1';
		else if(c=='0') ans+='0';
		else if(ans.length()>0) ans.pop_back();
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 256
n = int(input())
a = [0] + list(map(int, input().split())) + [0]

sum_cost = [0 for i in range(0, n + 2)] # sum_cost[i] := i番目の位置につくまでにかかるコスト

for i in range(1, n + 2):
    sum_cost[i] = sum_cost[i - 1] + abs(a[i] - a[i - 1])


for i in range(1, n + 1):
    print(sum_cost[i - 1] + abs(a[i + 1] - a[i - 1]) + sum_cost[n + 1] - sum_cost[i + 1])


Measured memory_bytes: 13920
import sys

def SorW(i):
    if i == 0:
        j = N - 1
    else:
        j = i - 1
    if t[i] == 'S' and t[j] == 'S':
        if s[i] == 'o':
            a = 'S'
        else:
            a = 'W'
    elif t[i] == 'S' and t[j] == 'W':
        if s[i] == 'o':
            a = 'W'
        else:
            a = 'S'
    elif t[i] == 'W' and t[j] == 'W':
        if s[i] == 'o':
            a = 'S'
        else:
            a = 'W'
    else:
        if s[i] == 'o':
            a = 'W'
        else:
            a = 'S'
    return a

N = int(input())
s = str(input())

for t in [['S', 'S'], ['S', 'W'], ['W', 'W'], ['W', 'S']]:
    for i in range(1, N):
        t.append(SorW(i))
    if t[0] == t[N] and t[1] == SorW(0):
        del t[N]
        print(''.join(t))
        sys.exit()
print('-1')


Measured memory_bytes: 6516
#include <iostream>
#include <cstdio>
#include <set>

using namespace std;

long long n;
long long a[100005];
set<long long> se;
long long ans;

int main()
{
    //freopen("input.txt", "r", stdin);
    scanf("%lld", &n);
    for(long long i = 1; i <= n; i++)
    {
        long long t;
        scanf("%lld", &t);
        a[t] = i;
    }
    se.insert(0);
    se.insert(n + 1);
    se.insert(a[n]);
    for(long long i = n - 1; i >= 1; i--)
    {
        set<long long>::iterator it = se.lower_bound(a[i]), it1, it2, it3, it4;
        it1 = it;
        it2 = it;
        it1++, it2--;
        if(it2 != se.begin())
        {
            it3 = it2;
            it3--;
            ans += (*it2 - *it3) * (*it - a[i]) * i;
        }
        if(it1 != se.end())
        {
            ans += (*it1 - *it) * (a[i] - *it2) * i;
        }
        se.insert(a[i]);
    }
    printf("%lld", ans);
    return 0;
}


Measured memory_bytes: 5760
#include <bits/stdc++.h>
using namespace std;
long long n,bf;
int len;
string change1(int k,long long n){
	string s="abcdefghijklmnopqrstuvwxyz",c="";
	while(n>0){
		c=s[n%k]+c;
		n=floor(n/k);
	}
	return c;
}
int main(){
	cin>>n;
	if(n==1){
		cout<<"a";
		return 0;
	}
	while(n>pow(26,len)+bf){
		if(len) bf+=pow(26,len);
		len++;
	}
	n-=bf+1;
	cout<<setw(len)<<setfill('a')<<change1(26,n);
	return 0;
}

Measured memory_bytes: 4100
#include <vector>
#include <list>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <stack>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <bitset>
#include <complex>
using namespace std;
#define REP(i,n) for(int i = 0; i < (int)n; i++)
#define FOR(i,a,b) for(int i = a; i < (int)b; i++)
#define pb push_back
#define mp make_pair
typedef vector<int> vi;
typedef pair<int, int> pi;
typedef long long ll;
typedef unsigned long long ull;
const int dx[] = {1, 0, -1, 0}, dy[] = {0, 1, 0, -1};
const int INF = 1 << 27;
//////////////////////////////
// ??¨?????´???
pi visit(int v, int prev, vector< vector<pi> > &G) {
  pi res(v, 0);
  REP(i, G[v].size()){
    if(G[v][i].first != prev){
      pi t = visit(G[v][i].first, v, G);
      t.second += G[v][i].second;
      if (res.second < t.second) res = t;
    }
  }
  return res;
}
int diameter(vector< vector<pi> > &G) {
  pi r = visit(0, -1, G);
  pi t = visit(r.first, -1, G);
  return t.second; // (r.first, t.first) is farthest pair
}

int main() {
	int v; cin >> v;
	vector<vector<pi> > vp(v);
	REP(i, v-1) {
		int a,b,c; cin >> a >> b >> c;
		vp[a].pb(pi(b, c));
		vp[b].pb(pi(a, c));
	}
	cout << diameter(vp) << endl;

	return 0;
}

Measured memory_bytes: 15956
n = int(input())
A = list(map(int, input().split()))

d = {}
ans = 0
for i in range(n):
    if i-A[i] in d:
        ans += d[i-A[i]]
    if A[i]+i not in d:
        d[A[i]+i] = 1
    else:
        d[A[i]+i] += 1
print(ans)


Measured memory_bytes: 111160
#include <iostream>
#include <vector>
#include <unordered_set>
#include <string>
#include <algorithm>

using namespace std;

int main() {
	int a, b, c;
	cin >> a >> b >> c;
	int cnt = 1;
	if(a != b) cnt++;
	if(c != a && c != b) cnt++;
	cout << cnt << endl;
}

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

using s64 = long long;

int main() {
  s64 n, p;
  cin >> n >> p;
  s64 answer = 1;
  for (int i = 2; (s64)i * i <= p; ++i) {
    if (p % i == 0) {
      int current = 0;
      while (p % i == 0) {
        p /= i;
        ++current;
      }
      current /= n;
      while (current--) {
        answer *= i;
      }
    }
  }
  cout << answer * (n == 1 ? p : 1ll) << endl;

  return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main{
  public  static void main(String[]args){
    Scanner sc = new Scanner(System.in);
    int a = sc.nextInt();
    int b = sc.nextInt();
    int area = a * b;
    int length = (a + b)*2;
    System.out.println(area + " " + length);
    sc.close();
  }
}


Measured memory_bytes: 26188
n = int(input())
l = list(map(int,input().split()))

cnt = 0
for i in range(n):
    for j in range(i+1,n):
        for k in range(j+1,n):
            if (l[i] != l[j] and l[j] != l[k] and l[i] != l[k]) \
            and (l[i] + l[j] > l[k] and l[j] + l[k] > l[i] and l[k] + l[i] > l[j]):
                cnt += 1
                
print(cnt)

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

struct board{
  char M[4][4];
  board(){
    for(int i = 0; i < 4; ++i)for(int j = 0; j < 4; ++j)M[i][j]='*';
  }
  bool isinside(const pair<int,int> &p)const{
    return 0<=p.first&&p.first<4&&0<=p.second&&p.second<4;
  }
  bool fillable(const pair<int,int> &p)const{
    return M[p.first][p.second]=='*';
  }
  bool filled()const{
    for(int i = 0; i < 4; ++i)
      for(int j = 0; j < 4; ++j)
	if(M[i][j]=='*')return false;
    return true;
  }
  bool operator<(const board &b)const{
    for(int i=0;i<4;++i){
      for(int j=0;j<4;++j){
	if(M[i][j]!=b.M[i][j])return M[i][j]<b.M[i][j];
      }
    }
    return false;
  }
  void print()const{
    for(int i = 0; i < 4; ++i){
      for(int j = 0; j < 4; ++j){
	cout << M[i][j] << ' ';
      }
      cout << endl;
    }
    cout << endl;
  }
};

void dfsFill(char c, board &b, pair<int,int> relpos[4], set<board> &vis, set<board> &S){
  if(vis.find(b)==vis.end()){
    vis.insert(b);
  }else return ;
  if(b.filled()){
    S.insert(b);
  }
  for(int i = 0; i < 4; ++i){
    for(int j = 0; j < 4; ++j){
      for(int k = 0; k < 4; ++k){
	pair<int,int> np(i,j);
	pair<int,int> next(i+relpos[k].first,j+relpos[k].second);
	if(b.isinside(next)&&b.fillable(np)&&b.fillable(next)){
	  char t1,t2;
	  t1=b.M[np.first][np.second];
	  b.M[np.first][np.second]=c+k;
	  t2=b.M[next.first][next.second];
	  b.M[next.first][next.second]=c+k;

	  dfsFill(c,b,relpos,vis,S);

	  b.M[next.first][next.second]=t2;
	  b.M[np.first][np.second]=t1;
	}
      }
    }
  }
}

int solve(pair<int,int> relpos[4]){
  board init;
  set<board> S,vis;
  dfsFill('A', init, relpos, vis, S);
  return S.size();
}

int main(){
  while(true){
    pair<int,int> relpos[4];
    for(int i = 0; i < 4; ++i){
      int x,y;
      cin >> x;
      if(x>4)return 0;
      cin >> y;
      relpos[i] = make_pair(y,x);
    }
    cout << solve(relpos) << endl;
  }
  return 0;
}

Measured memory_bytes: 2372
<?php
fscanf(STDIN,'%d',$N);
$L=[];
$L[0]=2;
$L[1]=1;
for ($i=2; $i <=86 ; $i++) {
  // code...
  $L[$i]=$L[$i-2]+$L[$i-1];
}
echo $L[$N];
echo "\n";
 ?>

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

int main() {
	int n,k;
	cin>>n>>k;
	vector<int>val(n);
	vector<int>arr(n);
	int sum=0;
	for(int i=0;i<n;i++){
		cin>>val[i]>>arr[i];
		sum+=arr[i];
	}
	vector<long long>dp(sum+1,1e9+1);
	dp[0]=0;
		for(int j=0;j<n;j++){
			for(int i=sum;i>0;i--){
			if(i-arr[j]>=0) dp[i]=min(dp[i],dp[i-arr[j]]+val[j]);
		}
	}
	int ans=1e9+1;
	for(int i=0;i<=sum;i++){
		if(dp[i]<=k) ans=i;
	}
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 4052
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
#define rep(i, n) for(ll i = 0; i < (n); ++i)
#define FOR(i, m, n) for(ll i = m; i < (n); i++)
#define all(x) (x).begin(),(x).end()
using namespace std;
typedef long long ll;
using vi = vector<int>;
using vii = vector<vi>;
using pii = pair<int, int>; 
using vl = vector<ll>;
using vll = vector<vl>;
using pll = pair<ll, ll>;

int main() {
    double R;
    cin >> R;
    double ans = 2*R*3.1414159;
    cout << fixed << setprecision(6);
    cout << ans;
}

Measured memory_bytes: 3784
import java.util.*

fun main(args: Array<String>) {
    val (H, W) = readLine()!!.split(" ").map{it.toInt()}
    val a = Array(H) { readLine()!!.split(" ").map{it.toInt()}.toTypedArray() }

    val ps = ArrayList<List<Int>>()

    for (i in a.indices) {
        if (i % 2 == 0) {
            for (j in a[i].indices) {
                val ni: Int
                val nj: Int
                if (j == a[i].size - 1) {
                    ni = i + 1
                    nj = j
                } else {
                    ni = i
                    nj = j + 1
                }
                if (a[i][j] % 2 == 1 && ni < a.size) {
                    ps.add(listOf(i + 1, j + 1, ni + 1, nj + 1))
                    a[ni][nj]++
                }
            }
        } else {
            for (j in a[i].indices.reversed()) {
                val ni: Int
                val nj: Int
                if (j == 0) {
                    ni = i + 1
                    nj = j
                } else {
                    ni = i
                    nj = j - 1
                }
                if (a[i][j] % 2 == 1 && ni < a.size) {
                    ps.add(listOf(i + 1, j + 1, ni + 1, nj + 1))
                    a[ni][nj]++
                }
            }
        }
    }

    println(ps.size)
    ps.map { it.joinToString(" ") }.forEach { println(it) }
}


Measured memory_bytes: 99976
Public Class compiler
    Shared Sub Main()
        Const p As Long = 1000000007
        Dim input As String() = Console.ReadLine().split(" ")
        Dim n As Long = Long.Parse(input(0))
        Dim k As Long = Long.Parse(input(1))
        Dim m As Modulo = New Modulo(2000, p)
        For i As Integer = 1 To k
            Dim red As Long = m.Ncr(n - k + 1, i)
            Dim blue As Long = m.Ncr(k - 1, i - 1)
            Console.WriteLine(red * blue Mod p)
        Next
    End Sub

    Class Modulo
        Private Factorial As Long()
        Private Inverse As Long()
        Private M As Long

        Public Sub New(size As Integer, m As Long)
            Me.M = m

            ReDim Factorial(0 To size)
            Factorial(0) = 1
            For i As Integer = 1 To size
                Factorial(i) = Factorial(i - 1) * i Mod m
            Next

            ReDim Inverse(0 To size)
            Inverse(size) = Pow(Factorial(size), m - 2) Mod m
            For i As Integer = size To 1 Step -1
                Inverse(i - 1) = Inverse(i) * i Mod m
            Next
        End Sub

        Public Function Pow(x As Long, y As Long) As Long
            If y = 0 Then Return 1
            If y Mod 2 = 0 Then
                Dim d As Long = Pow(x, y / 2)
                Return (d * d) Mod Me.M
            Else
                Return (x * Pow(x, y - 1)) Mod Me.M
            End If
        End Function

        Public Function Ncr(n As Long, r As Long) As Long
            If n < r Then Return 0
            If n = r Then Return 1
            Return ((Factorial(n) * Inverse(r)) Mod Me.M) * Inverse(n - r) Mod Me.M
        End Function
    End Class
End Class


Measured memory_bytes: 11180
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int a[6];
int ar[4];
int main(){
    //ios::sync_with_stdio(false);
    for (int i = 0; i < 6; i++) {
        cin >> a[i];
    }
    ar[0] = a[5] / 100 / a[0];
    ar[1] = a[5] / 100 / a[1];
    //arg[2] = a[5] / a[2];
    //arg[3] = a[5] / a[3];
    double maxe = -1;
    int ans1, ans2;
    for (int i = 0; i <= ar[0]; i++) {
        int temp = (a[5] - i * 100 * a[0]) / 100;
        for (int j = i == 0 ? 1 : 0; j * a[1] <= temp; j++) {
            int w = i * 100 * a[0] +  j * 100 * a[1];
            if (w== 1700) {
                int eee= -1;
            }
            int s = min(a[4] * w /100, a[5]-w);
            int t2 = s / a[2];
            for (int k = t2; k >= 0; k--) {
                int l = s - a[2] * k;
                for (int m = 0; m *a[3] <= l; m++) {
                    int su = (m *a[3] + a[2] * k);
                    if (1.0 * su / (su + w) > maxe) {
                        maxe = 1.0 * su / (su + w);
                        ans1 = su+w; ans2 = su;
                    }
                }
            }
        }
    }
    cout << ans1 << " " << ans2 << "\n";
    return 0;
}


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

#define FOR(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define RFOR(i,a,b) for(int i=(int)(b)-1;i>=(int)(a);i--)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n)
#define LL long long
#define INF INT_MAX/3

const double EPS = 1e-14;
const double PI  = acos(-1.0);


bool isPrime(int x) {
  if (x < 2) return false;
  else if (x < 4) return true;
  int i = 2;
  while(i * i <= x) {
    if (x % i == 0) return false;
    i++;
  }
  return true;
}

typedef pair<int, int> p;

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

  vector<p> v(n);
  REP (i, n) {
    scanf("%d %d", &l, &r);
    v[i] = make_pair(l, r);
  }

  vector<bool> prime(100000, false);

  FOR (i, 1, 100000) {
    if (isPrime(i)) prime[i] = true;
  }

  vector<int> like(100000);
  like[1] = 0;
  FOR (i, 3, 100000) {
    if (i % 2) {
      like[i] = like[i - 2];
      if (prime[i] && prime[(i + 1) / 2]) like[i]++;
    }
  }

  REP (i, n) {
    if (v[i].first == 1)
      cout << like[v[i].second] << endl;
    else
      cout << like[v[i].second] - like[v[i].first - 2] << endl;
  }
}


Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using ll = long long;
using ld = long double;
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
#define rep3(i, n) for (int i = 1; i < (int)(n+1); i++)
#define rep4(i, s, n) for (int i = (s); i < (int)(n+1); i++)
#define repr(i,n) for (int i = (n-1); i>=0;i--)
#define repr3(i,n) for(int i = (n);i>0;i--)
#define stlen(s) ll s.size()-1
#define all(v) v.begin(), v.end()
#define cout(n) cout<<std::fixed<<std::setprecision(n)
using Graph = vector<vector<int>>;
#define INF const ll INF = 1001001001;
#define PI const ld PI = 3.14159265358979323846;

const int MAX = 510000;
const int MOD = 1000000007;

long long fac[MAX], finv[MAX], inv[MAX];




vector<pair<long long, long long> > prime_factorize(long long N) {
    vector<pair<long long, long long> > res;
    for (long long a = 2; a * a <= N; ++a) {
        if (N % a != 0) continue;
        long long ex = 0; // 指数

        // 割れる限り割り続ける
        while (N % a == 0) {
            ++ex;
            N /= a;
        }

        // その結果を push
        res.push_back({a, ex});
    }

    // 最後に残った数について
    if (N != 1) res.push_back({N, 1});
    return res;
}

int main() {
    ll A,B;
    cin >> A>>B;
    //pairの書き換えが煩雑であるので、素数リストと指数連想配列に分ける
   map<ll,ll> prime_countA;
   vector<ll> prime_listA;
   
    //resに素数のペア(素数、その素数の指数）の配列が入る
    const auto  &resA = prime_factorize(A);
    
   rep(i,resA.size()){
       if(prime_countA[resA[i].first]==0){
           prime_listA.push_back(resA[i].first);
       }
       prime_countA[resA[i].first]+=resA[i].second;
   }
   //pairの書き換えが煩雑であるので、素数リストと指数連想配列に分ける
   map<ll,ll> prime_countB;
   vector<ll> prime_listB;
   
    //resに素数のペア(素数、その素数の指数）の配列が入る
    const auto  &resB = prime_factorize(B);
    
   rep(i,resB.size()){
       if(prime_countB[resB[i].first]==0){
           prime_listB.push_back(resB[i].first);
       }
       prime_countB[resB[i].first]+=resB[i].second;
   }
   
    

   ll ans=1;
   map<ll,ll> bool_prime;
   rep(i,prime_listA.size()){
       if(bool_prime[prime_listA[i]]==0){
           bool_prime[prime_listA[i]]++;
           

       }
       
   }
   rep(i,prime_listB.size()){
       if(bool_prime[prime_listB[i]]!=0){
           
           ans++;

       }
       
   }

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

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

int main(){
    ll n;cin>>n;ll w;cin>>w;
    vector<ll> pro(n),weight(n);

    for(ll i=0;i<n;i++){
        cin>>weight[i]>>pro[i];
    }

    vector<ll> dp(w+1,0);
    ll maxi=0;
    for(ll i=0;i<n;i++){
        for(ll j=w;j>=1;j--){
            if(j-weight[i]>=0){
                dp[j]=max(dp[j],pro[i]+dp[j-weight[i]]);
            }
            maxi=max(maxi,dp[j]);
        }
    }
    cout<<maxi<<endl;
}

Measured memory_bytes: 3932
using System;
using System.Collections;
using System.Collections.Generic;
using System.Text;
using System.Linq;
using static MyIO;


public class A
{
	public static void Main()
	{
		int N = GetInt();
		int H = GetInt();
		int W = GetInt();

		Console.WriteLine((N - H + 1) * (N - W + 1));
	}
}


public static class MyIO
{
	private static string[] args = null;
	private static int num = -1;
	private static int used = -1;

	private static string getArg()
	{
		if(used == num)
		{
			args = Console.ReadLine().Split(' ');
			num = args.Length;
			used = 0;
		}
		return args[used++];
	}

	public static int GetInt(){ return int.Parse(getArg()); }
	public static long GetLong(){ return long.Parse(getArg()); }
	public static double GetDouble(){ return double.Parse(getArg()); }
	public static string GetString(){ return getArg(); }
}

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

#define foru(i, l, r) for(int i = (l); i <= (r); ++i)
#define ford(i, l, r) for(int i = (l); i >= (r); --i)

#define maxn 200010

int main(){
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
//    freopen("abc.inp", "r", stdin); freopen("abc.out", "w", stdout);
    ll a, b, c, d;
    cin >> a >> b >> c >> d;
    cout << max({a * c, a * d, b * c, b * d});
    return 0;
}


Measured memory_bytes: 3624
N = gets.to_i
A = gets.split(" ").map(&:to_i)
B = gets.split(" ").map(&:to_i)
C = gets.split(" ").map(&:to_i)
ans = B.inject(:+)

(N - 1).times do |i|
    if A[i + 1] - A[i] == 1
        ans += C[A[i] - 1]
    end
end

puts ans 


Measured memory_bytes: 3836
#include<iostream>
using namespace std;
int main () {
  int N;
  cin >> N;
  int k = 0;
  for (int i = 0; i < N; i ++) {
    int a;
    cin >> a;
    if (a != i + 1) k ++;
  }
  if (k > 2) cout << "NO" << endl;
  else cout << "YES" << endl;
}


Measured memory_bytes: 256
import bisect

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

A.sort()
C.sort()
ans = 0

for b in B:
    ans += bisect.bisect_left(A, b) * (N - bisect.bisect_right(C, b))

print(ans)


Measured memory_bytes: 23232
#include <iostream>
#include <vector>
#include <string>
#include <map>
#include <set>
#include <algorithm>
#include <cmath>
#include <queue>
using namespace std;


int main()
{
	int d, t, s;
	cin >> d >> t >> s;
	if ((double)d / s > t)
		cout << "No";
	else
		cout << "Yes";
}

Measured memory_bytes: 3616
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
int main(){
  int N, M;
  cin >> N >> M;
  vector<int> a(M);
  int sum = 0;

  rep(i, M){
    cin >> a[i];
    sum += a[i];
  }
  if(N - sum >= 0){
    cout << N - sum << endl;
  }else{
    cout << "-1" << endl;
  }
  return 0;
}


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

int N;
int A[210];

int main() {
  cin >> N;
  for (int i = 0; i < N; ++i) cin >> A[i];
  
  int res = 0;
  
  while (true) {
    bool exist_odd = false;
    for (int i = 0; i < N; ++i) {
      if (A[i] % 2 != 0) exist_odd = true;
    }
    
    if (exist_odd) break;
    
    for (int i = 0; i < N; ++i) {
      A[i] /= 2;
    }
    ++res;
  }
  
  cout << res << endl;
}

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

typedef long long ll;
typedef unsigned long long ull;
typedef string st;
typedef double db;
typedef vector<long long> vecll;
typedef vector<char> vechar;

int main(){
    ll a, b;
    cin >> a >> b;
    if((a + b) % 2 == 0) cout << (a + b) / 2 << endl;
    else cout << "IMPOSSIBLE" << endl;
}

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;
using vi = vector<int>;
using Graph = vector<vi>;
using P = pair<int,int>;
const int MOD=(int)1e9+7;
const int INF=(int)1e9;
const ll LINF=(ll)1e18;

const int dx[4]={0,-1,0,1};
const int dy[4]={-1,0,1,0};
int h,w;
int bfs(const vector<string> &s,int x,int y){
    vector<vector<int>> d(h,vector<int>(w,-INF));
    queue<P> q;
    q.push(make_pair(x,y));
    d[x][y] = 0;
    int ma=0;
    while(!q.empty()){
        int xi = q.front().first;
        int yi = q.front().second;
        q.pop();
        rep(i,4){
            int nx = xi + dx[i];
            int ny = yi + dy[i];
            if(nx>=0 && nx<h && ny>=0 && ny<w && d[nx][ny]==-INF &&s[nx][ny]=='.'){
                q.push(make_pair(nx,ny));
                d[nx][ny] = d[xi][yi] + 1;
                ma = max(ma,d[nx][ny]);
                //cout << d[nx][ny] << endl;
            }
        }
    }
    return ma;
}

int main(){
    cin >> h >> w;
    vector<string> m(h);
    rep(i,h) cin >> m[i];
    int ma = 0;
    rep(i,h) rep(j,w){
        if(m[i][j]=='.') ma = max(ma,bfs(m,i,j));
    }
    cout << ma << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define int long long int
#define gif(a,b) (a/b +(a%b?1:0))
#define pi 3.14159265358
#define watch(x) cout<<(#x)<<" is "<<(x)<<"\n";
#define float long double
using namespace std;

int32_t main()
{   
    cin.tie(NULL);
    std::ios::sync_with_stdio(false);
    int n , k;
	cin >> n >> k;
	int ans = 0;
	int mod = 1000000007;
	for(int i = k; i <= n; ++i)
		ans += ( i * (n - i + 1)) % mod + 1;

  	cout << ans % mod + 1 ;
    return 0;
}


Measured memory_bytes: 3632
#include <bits/stdc++.h>
#define fi first
#define se second
#define pb push_back
#define fio ios::sync_with_stdio(0),cin.tie(0),cout.tie(0)
using namespace std;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef long long ll;

// O(n log n) space, O(1) index query RMQ
struct rmq_ind {
	vector<vector<int> > t;
	int *A;
	rmq_ind(){}
	rmq_ind(int* a, int n):t(32-__builtin_clz(n),vector<int>(n)) {
		A = a;
		for(int i = 0; i < n; ++i)
			t[0][i] = i;
		for(int k = 1, p = 1; k < t.size(); ++k, p<<=1)
			for(int i = 0; i < n; ++i)
				t[k][i] = (i+p<n && a[t[k-1][i+p]] < a[t[k-1][i]])?t[k-1][i+p]:t[k-1][i];
	}
	//inclusive min query
	inline int query(int l, int r) const {
		int p = 31-__builtin_clz(r-l+1), i = t[p][l], j = t[p][r+1-(1<<p)];
		return (A[i]<A[j])?i:j;
	}
};

const int N = 2e5+5;
int evn[N],odd[N],A[N],n,sz=0;

rmq_ind E,O;
vi children[N];
pii data[N];

vector<int> ans;

int solve(int i, int j) {
	int id = sz++,a,b;
	if(i&1) {
		a = O.query(i,j);
		b = E.query(a+1,j);
	} else {
		a = E.query(i,j);
		b = O.query(a+1,j);
	}
	data[id] = pii(A[a],A[b]);
	if(i != a) children[id].pb(solve(i,a-1));
	if(a+1 != b) children[id].pb(solve(a+1,b-1));
	if(b != j) children[id].pb(solve(b+1,j));
	return id;
}

const int INF = 1<<20;
struct cmp {
	bool operator ()(int i, int j) {
		return data[i] > data[j];
	}
};
priority_queue<int,vector<int>,cmp> Q;

int main() {
	scanf("%d",&n);
	for(int i = 0; i < n; ++i) {
		scanf("%d",A+i);
		if(i&1) odd[i] = A[i], evn[i] = INF;
		else evn[i] = A[i], odd[i] = INF;
	}
	E = rmq_ind(evn,n);
	O = rmq_ind(odd,n);
	solve(0,n-1);
	Q.push(0);
	while(Q.size()) {
		int t = Q.top();
		Q.pop();
		ans.pb(data[t].fi), ans.pb(data[t].se);
		for(int j : children[t])
			Q.push(j);
	}
	for(int i = 0; i < n; ++i)
		printf("%d ",ans[i]);
	printf("\n");
}

Measured memory_bytes: 48624