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

const int DIM = 5e1 + 5;

long long sum[DIM], cnt[DIM];
long long arr[DIM], cmb[DIM][DIM];

int main( void ) {
    
    int n, a, b;
    cin >> n >> a >> b;
    
    for( int i = 1; i <= n; i ++ )
        cin >> arr[i];
    
    sort( arr + 1, arr + n + 1 );
    reverse( arr + 1, arr + n + 1 );
    
    for( int i = 0; i <= n; i ++ ) {
        cmb[i][0] = 1;
        
        for( int j = 1; j <= i; j ++ )
            cmb[i][j] = cmb[i - 1][j] + cmb[i - 1][j - 1];
    }
    
    long long x(0), y(1), ans(0);
    for( int i = 1; i <= n; i ++ ) {
        int p1(i), p2(i);
        
        while( arr[p1 - 1] == arr[p1] )
            p1 --;
        while( arr[p2 + 1] == arr[p2] )
            p2 ++;

        sum[i] = sum[i - 1] + arr[i];
        cnt[i] = cmb[p2 - p1 + 1][i - p1 + 1];
        
        if( i < a || i > b )
            continue;
        
        if( x * i <  sum[i] * y )
            x = sum[i], y = i, ans = 0;
        if( x * i == sum[i] * y )
            ans += cnt[i];
    }
    
    cout << setprecision(6) << fixed << 1.0 * x / y << endl << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<vector>
#include<map>
#include<queue>

using namespace std;

int main(void){
	int a;
	int nn,m;
	int b[1001];
	int n[1001];
	int p=1;
	while(1){
		for(a=0;a<=1000;a++){
			n[a]=0;
			b[a]=0;
		}
		p=1;
		cin >> nn >> m;
		if(nn==0 && m==0)break;
		for(a=1;a<=nn;a++){
			cin >> n[a];
		}
		for(a=1;a<=m;a++){
			cin >> b[a];
		}
		for(a=1;a<=m;a++){
			p+=b[a];
			p+=n[p];
			if(p>=nn){
				printf("%d\n",a);
				break;
			}
		}
	}
	return 0;
}

Measured memory_bytes: 0
<?php

const SEARCH_NUM = 9;

$result = false;

$num = trim(fgets(STDIN));  

if(floor($num / 10) == SEARCH_NUM){
	$result = true;
}
if(($num % 10) == 9){
	$result = true;
}

if($result){
	echo "Yes";
}else{
	echo "No";
}

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

using namespace std;

#define int long long

int maxi=1000000000000000;

vector < int > waste[100005];

int row[100005];

int32_t main()
{
        string s;
        cin>>s;

        for(int i=0;i<s.length()-1;i++)
        {
                if(s[i]==s[i+1])
                {
                        cout<<i+1<<" "<<i+2<<endl;
                        return 0;
                }
                else if(s[i]==s[i+2])
                {
                        cout<<i+1<<" "<<i+3<<endl;
                        return 0;
                }
        }
        cout<<"-1 -1"<<endl;
        return 0;
}



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

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

int main()
{
	int x, y;
	cin >> x >> y;
	cout << ((y % 2 == 0 && 2 * x <= y && y <= 4 * x) ? "Yes" : "No" )<< endl;
}

Measured memory_bytes: 3612
#include <bits/stdc++.h>
#define inf 1000000000 //1E+9
#define mod 1000000007
using namespace std;

int main(){
	int n,c;cin>>n>>c;
	int d[c][c];for(int i=0;i<c*c;i++)cin>>d[i/c][i%c];
	int color[n][n];for(int i=0;i<n*n;i++){cin>>color[i/n][i%n];color[i/n][i%n]--;}

	vector<vector<int>> Cs(3,vector<int>(c));
	for(int i=0;i<n;i++){
	for(int j=0;j<n;j++){
		Cs[(i+j)%3][color[i][j]]++;
	}}

	//cost[i][j]......i -> j
	vector<vector<int>> cost(3,vector<int>(c));

	for(int i=0;i<3;i++){
		for(int j=0;j<c;j++){
			for(int k=0;k<c;k++)cost[i][j]+=d[k][j]*Cs[i][k];
		}
	}
	int ans=inf;
	for(int i=0;i<c;i++){
	for(int j=0;j<c;j++){
	for(int k=0;k<c;k++){
		if(i==j||j==k||k==i)continue;
		ans= min(ans,cost[0][i]+cost[1][j]+cost[2][k]);
	}}}
	cout<<ans<<endl;
	return 0;
}



Measured memory_bytes: 1280
#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define ll long long
#define P pair<int,int>
#define PI 3.141592653589793
const int INF = 1001001001;
const ll MX = 1e18;

int main() {
	int n;
	cin >> n;
	vector<ll> a(n);
	rep(i, n) cin >> a[i];

	sort(a.rbegin(), a.rend());
	ll ans = a[0];

	int ii = 1;
	bool ok = true;
	rep(i, n - 2) {
		if (ok) {
			ans += a[ii];
			ok = false;
			continue;
		}
		ok = true;
		ans += a[ii];
		ii++;
	}
	cout << ans << endl;
}

Measured memory_bytes: 4848
#include <bits/stdc++.h>
using namespace std;
#define reps(i,s,n) for(int i = s; i < n; i++)
#define rep(i,n) reps(i,0,n)
#define Rreps(i,n,e) for(int i = n - 1; i >= e; --i)
#define Rrep(i,n) Rreps(i,n,0)
#define ALL(a) a.begin(), a.end()
#define fi first
#define se second
#define endl "\n"
typedef long long ll;
typedef vector<ll> vec;
typedef vector<vec> mat;

//const ll MOD = 998244353;
const ll MOD = (1e+9) + 7;
const ll INF = 2e+9 + 10;
typedef pair<ll, ll> P;


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

  string s; cin >> s;
  cout << s[0] << s.size()-2 << s[s.size()-1] << endl;

  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) REP(i,0,n)
#define REP(i,s,e) for(int i=(s); i<(int)(e); i++)
#define repr(i, n) REPR(i, n, 0)
#define REPR(i, s, e) for(int i=(int)(s-1); i>=(int)(e); i--)
#define pb push_back
#define all(r) r.begin(),r.end()
#define rall(r) r.rbegin(),r.rend()
#define fi first
#define se second

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

const ll INF = 1e18;
const ll MOD = 1e9 + 7;
const double EPS = 1e-8;

template<typename T> T chmax(T& a, const T& b){return a = (a > b ? a : b);}
template<typename T> T chmin(T& a, const T& b){return a = (a < b ? a : b);}

int main(){
    string s;
    cin >> s;
    if(s[1] == 'R') s[1] = 'B';
    else s[1] = 'R';
    cout << s << '\n';
    return 0;
}

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

int main() {
  int s1s2s3, s1, s2, s3;
  cin >> s1s2s3;
  s1=s1s2s3/100;
  s2=(s1s2s3-100*s1)/10;
  s3=s1s2s3-100*s1-10*s2;
  cout << s1+s2+s3 << endl;
}


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

#define REP(i,n) for(int i=0;i<n;i++)
#define rep(i,n) for(int i=0;i<n;i++)
#define INF 1<<29
#define LINF LLONG_MAX/3
#define MP make_pair
#define PB push_back
#define EB emplace_back
#define ALL(v) (v).begin(),(v).end()
#define debug(x) cerr<<#x<<":"<<x<<endl
#define debug2(x,y) cerr<<#x<<","<<#y":"<<x<<","<<y<<endl
#define CININIT cin.tie(0),ios::sync_with_stdio(false)
template<typename T> ostream& operator<<(ostream& os,const vector<T>& vec){ os << "["; for(const auto& v : vec){ os << v << ","; } os << "]"; return os; }

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<vi> vvi;



int main(){
    int n;
    cin>>n;
    string s;
    vector<string> a(10);
    a[1] = ".,!? ";
    a[2] = "abc";
    a[3] = "def";
    a[4] = "ghi";
    a[5] = "jkl";
    a[6] = "mno";
    a[7] = "pqrs";
    a[8] = "tuv";
    a[9] = "wxyz";

    while(n--){
        cin>>s;
        int n=s.size();
        string ans;
        int cnt=0;
        rep(i,n){
            if(cnt==0 and s[i]=='0') continue;
            if(s[i]=='0'){
                int idx = s[i-1]-'0';
                cnt--;
                cnt %= a[idx].size();
                ans.push_back(a[idx][cnt]);
                cnt = 0;
            }else{
                cnt++;
            }
        }
        if(ans=="") continue;
        cout << ans << endl;
    }
}

Measured memory_bytes: 3112
use std::io::*;
use std::str::FromStr;

fn main() {
    let stdin = stdin();
    let mut lock = stdin.lock();
    let mut str1 = String::new();
    lock.read_line(&mut str1).unwrap();
    let mut iter1 = str1.trim().split_whitespace();
    //let mut n: Vec<_> = iter1.next().unwrap().bytes().map(|x| (x-48) as u32).collect();
    let n = u32::from_str(iter1.next().unwrap()).unwrap();
    let a = u32::from_str(iter1.next().unwrap()).unwrap();
    let b = u32::from_str(iter1.next().unwrap()).unwrap();
    //let mut p: Vec<u32> = vec![0, 0, 0, 0];
    let mut value = 0;
    if (a == 1 && n == 10000) {
        value = 10000;
    }
    /*
    while n.len() < 4 {
        n.insert(0, 0u32);
    }
    */
    /*
    for i in 0..10 {
        if i > b  || 1000 * i > n {
            break;
        }
        for j in 0..10{
            if i + j > b || 1000 * i + 100 * j > n {
                break;
            }
            for k in 0..10{
                if i + j + k > b  || 1000 * i + 100 * j + 10 * k > n {
                    break;
                }
                for l in 0..10 {
                    let ijkl = i + j + k + l;
                    if ijkl >= a && ijkl <= b {
                        let ijkl2 = 1000 * i + 100 * j + 10 * k + l;
                        if ijkl2 <= n {
                            value += ijkl2;
                        }
                    } else if ijkl > b {
                        break;
                    }
                }
            }
        }
    }
    */
    for i in 0..10 {
        for j in 0..10{
            for k in 0..10{
                for l in 0..10 {
                    let ijkl = i + j + k + l;
                    if ijkl >= a && ijkl <= b {
                        let ijkl2 = 1000 * i + 100 * j + 10 * k + l;
                        if ijkl2 <= n {
                            value += ijkl2;
                        }
                        /*
                    } else if ijkl > b {
                        break;
                        */
                    }
                }
            }
        }
    }
    // 0 : 48hh
    println!("{}", value);
}

Measured memory_bytes: 4352
x = {"S": list(range(1, 14)), "H": list(range(1, 14)),
     "C": list(range(1, 14)), "D": list(range(1, 14))}
n = int(input())
for i in range(n):
    tmp = input().split()
    key = tmp[0]
    num = int(tmp[1])
    x[key].remove(num)

keys = ["S", "H", "C", "D"]
for key in keys:
    if len(x[key])==0:
        pass
    else:
        for i in x[key]:
            print(key, i)

Measured memory_bytes: 7764
import java.util.*;
public class Main {

  public static void main(String[] args) { 
      Scanner sc = new Scanner(System.in);
      int n = sc.nextInt();
      int head_b_cnt = 0;
      int tail_a_cnt = 0;
      int h_t_b_a_cnt = 0;
      long cnt = 0;
      for(int i = 0; i < n; i++) {
        String s = sc.next();
        int len = s.length();
        if(s.charAt(0) == 'B' && s.charAt(len - 1) == 'A')
          h_t_b_a_cnt++;
        else if(s.charAt(0) == 'B')
          head_b_cnt++;
        else if(s.charAt(len-1) == 'A')
          tail_a_cnt++;
        cnt += cntAB(s);
      }

      if(h_t_b_a_cnt > 0) {
        cnt += h_t_b_a_cnt - 1;
        if(head_b_cnt > 0) {
            cnt++; head_b_cnt--;
        }
        if(tail_a_cnt > 0) {
            cnt++; tail_a_cnt--;
        }
      }
      int minCnt = Math.min(head_b_cnt, tail_a_cnt);
      cnt += minCnt;
      System.out.println(cnt);
  }

  private static int cntAB(String s) {
    int cnt = 0;
    for(int i = 0; i < s.length() - 1; i++) {
      if(s.charAt(i) == 'A' && s.charAt(i+1) == 'B') {
        cnt++;
        i++;
      }
    }
    return cnt;
  }
}

Measured memory_bytes: 31872
A, B, C, X = [int(input()) for _ in range(4)]

ans = 0
for a in range(A + 1):
  for b in range(B + 1):
    for c in range(C + 1):
      if X == 500 * a + 100 * b + 50 * c:
        ans += 1
print(ans)

Measured memory_bytes: 3060
// Last Change: 07/30/2019 18:05:40.
#include <algorithm>
#include <array>
#include <bitset>
#include <cmath>
#include <cstdlib>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <memory>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>

using namespace std;
using ll = long long;

int main() {
  int N, cnt = 0, ipt;
  cin >> N;
  for (int i = 0; i < N; ++i) {
    cin >> ipt;
    if (ipt != i + 1) {
      ++cnt;
    }
  }
  if (cnt <= 2) {
    cout << "YES" << endl;
  } else {
    cout << "NO" << endl;
  }
}


Measured memory_bytes: 256
#include <vector>
#include <stack>
#include <queue>
#include <list>
#include <bitset>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <algorithm>
#include <numeric>
#include <iostream>
#include <iomanip>
#include <string>
#include <chrono>
#include <random>
#include <cmath>
#include <cassert>
#include <climits>
#include <cstring>
#include <cstdlib>
#include <functional>
#include <sstream>

using namespace std;


int main(int argc, char** argv) {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout << fixed << setprecision(12);

    int n;
    cin >> n;
    long double res = 0;
    for (int i = 0; i < n; ++i) {
        int x;
        cin >> x;
        res += 1.0 /x;
    }
    res = 1.0/res;
    cout << res << "\n";

    return 0;
}

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

const int maxn = 1e5 + 5;
char str[maxn];

int main()
{
    while(scanf("%s",str) != EOF)
    {
        int n = strlen(str);
        if(str[0] == str[n - 1])
        {
            if(n % 2 == 0)
            {
                printf("First\n");
            }
            else
            {
                printf("Second\n");
            }
        }
        else
        {
            if(n % 2 == 0)
            {
                printf("Second\n");
            }
            else
            {
                printf("First\n");
            }
        }
    }
    return 0;
}

Measured memory_bytes: 384
package main
 
import(
  "fmt"
	"bufio"
	"os"
	"strings"
	//"strconv"
)
 
var sc = bufio.NewScanner(os.Stdin)

//fmt.Scan(&a)とかの方が楽ではある。
//1行に二つ以上の塊があるパターン
//for r = append(r, s[0])
//的な感じ
//ただ、sc.scanでいくとテキスト配列を返してしまうのでそこを考えねばならない
func Rr() []string {
  sc.Scan()
  slice := strings.Split(sc.Text(), " ")
  return slice
}

func values(m map[string]int) []int {
    vs := []int{}
    for _, v := range m {
        vs = append(vs, v)
    }
    return vs
}
 
func abc053d(x int){
	m := make(map[int]int)
	var in int
	for i := 0; i < x; i++{
		fmt.Scan(&in)
		m[in]++
	}
	if len(m) % 2 == 0{
		fmt.Println(len(m)-1)
	}else{
		fmt.Println(len(m))
	}
}
 
func main(){
	x := 0
	fmt.Scan(&x)
	abc053d(x)
}

Measured memory_bytes: 7936
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		double r;
		r = sc.nextDouble();
		double b = 3.141592653589;
		System.out.printf("%f %f\n", r * r * b, r * 2 * b);
		sc.close();
	}
}



Measured memory_bytes: 28232
#include <cstdio>

int main()
{
    int a, b, c;
    scanf("%d %d %d", &a, &b, &c);
    if (a != b and b != c and c != a)
    {
    	printf("3");
	}
	else if ((a == b and b != c and a != c) or (b == c and b != a and c != a) or (a == c and c != b and a != b))
	{
		printf("2");
	}
	else if (a == b and b == c and c == a)
	{
		printf("1");
	}
}

Measured memory_bytes: 1648
#include <algorithm>
#include <array>
#include <bitset>
#include <cctype>
#include <cinttypes>
#include <climits>
#include <cmath>
#include <complex>
#include <cstddef>
#include <cstdint>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <fstream>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <limits>
#include <list>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <queue>
#include <random>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>

using namespace std;

int main() {
  int N;
  cin >> N;
  int A[3]{};
  for (auto i = 0; i < N; ++i) {
    int x;
    cin >> x;
    ++A[x - 1];
  }
  static long double F[301][301];
  auto M = A[0] + A[1] * 2 + A[2] * 3;
  for (auto m = 1; m <= M; ++m)
     for (auto i = min(m / 3, A[2]); i >= max(0, m - N * 2 - 1); --i)
      for (auto j = min((m - i * 3) / 2, A[2] + A[1]); j >= max(0, m - N - i * 2); --j) {
        auto k = m - i * 3 - j * 2;
        auto n = i + j + k;
        auto f = (long double) N;
        if (i)
          f += F[i - 1][j + 1] * i;
        if (j)
          f += F[i][j - 1] * j;
        if (k)
          f += F[i][j] * k;
        F[i][j] = f / n;
      }
  cout << fixed << setprecision(12) << F[A[2]][A[1]] << endl;
  return 0;
}


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

using namespace std;

int a[111];
int s[111];

int main(){
	int n;
	scanf("%d", &n);
	for (int i = 1; i <= n; i++){
		scanf("%d", a + i);
		s[i] = s[i - 1] + a[i];
	}
	int ans = INT_MAX;
	for (int i = 1; i <= n - 1; i++){
		ans = min(ans, abs(s[i] - (s[n] - s[i])));
	}
	printf("%d\n", ans);
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define mp       make_pair
#define pb       push_back
#define all(x)   (x).begin(),(x).end()
#define YES() printf("YES\n")
#define NO() printf("NO\n")
#define Yes() printf("Yes\n")
#define No() printf("No\n")
#define in(x,y,h,w) x >= 0 && x < h && y >= 0 && y < w

#define int long long
//typedef    long long          ll;
typedef    vector<bool>       vb;
typedef    vector<int>        vi;
typedef    vector<vb>         vvb;
typedef    vector<vi>         vvi;
typedef    pair<int,int>      P;

template <typename T> T &chmin(T &a, const T &b) { return a = min(a, b); }
template <typename T> T &chmax(T &a, const T &b) { return a = max(a, b); }
 
const int INF=1e+18;
const double EPS=1e-9;
const int MOD=1000000007;
 
const int dx[]={1,0,-1,0},dy[]={0,-1,0,1};

struct edge{ int to,cost; };

int n,m,s,t,d[100000];
vector<edge> G[100000];
vector<P> vec;

void dijkstra(int s){
	priority_queue<P,vector<P>,greater<P> > que;
	for(int i = 0;i < n;i++) d[i] = INF;
	d[s] = 0;
	que.push(P(0,s));
	while(!que.empty()){
		P p = que.top();
		que.pop();
		int v = p.second;
		if(d[v] < p.first) continue;
		for(int i = 0;i < G[v].size();i++){
			edge e = G[v][i];
			if(d[e.to] > d[v] + e.cost){
				d[e.to] = d[v] + e.cost;
				que.push(P(d[e.to],e.to));
			}
		}
	}
}

signed main(){
	int nums[100000] = {},numt[100000] = {},ans;
	cin >> n >> m >> s >> t; s--;t--;
	for(int i = 0;i < m;i++){
		int a,b,c;
		cin >> a >> b >> c; a--;b--;
		G[a].push_back({b,c});
		G[b].push_back({a,c});
	}
	dijkstra(s);
	for(int i = 0;i < n;i++) vec.push_back(P(d[i],i));
	sort(all(vec));
	nums[s] = 1;
	numt[t] = 1;
	for(int i = 0;i < n;i++){
		int v = vec[i].second;
		for(edge e : G[v]){
			if(d[e.to] == d[v] + e.cost) nums[e.to] = (nums[e.to] + nums[v]) % MOD;
		}
	}
	for(int i = n - 1;i >= 0;i--){
		int v = vec[i].second;
		for(edge e : G[v]){
			if(d[e.to] == d[v] - e.cost) numt[e.to] = (numt[e.to] + numt[v]) % MOD;
		}
	}
	ans = nums[t] * nums[t];
	for(int i = 0;i < n;i++){
		if(d[i] * 2 == d[t]) ans = (ans - nums[i] * nums[i] % MOD * numt[i] % MOD * numt[i] % MOD + MOD) % MOD;
		for(edge e : G[i]){
			if(d[i] + e.cost == d[e.to] && d[i] * 2 < d[t] && d[t] < d[e.to] * 2) ans = (ans - nums[i] * nums[i] % MOD * numt[e.to] % MOD * numt[e.to] % MOD + MOD) % MOD;
		}
	}
	cout << ans << endl;
	return 0;
}

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


x = []
for i in range(1,n+1):
    x.append(l + i - 1)


m = 10 ** 12
k = 10 ** 12
for i in range(n):
    diff = abs(x[i])
    if m >= diff:
        m = diff
        k = x[i]

        
print(sum(x) - k)


Measured memory_bytes: 3060
#include <bits/stdc++.h>
#define be(v) (v).begin(),(v).end()
#define pb(q) push_back(q)
typedef long long ll;
using namespace std;
const ll mod=1000000007, INF=mod*mod*3LL;
#define doublecout(a) cout<<fixed<<setprecision(10)<<a<<endl;

int main() {
    cin.tie(0);
    cout.tie(0);
    ios::sync_with_stdio(false);
    double a, b, h, m;
    cin >> a >> b >> h >> m;
    double degm = M_PI * 2 / 60.0;
    degm *= m;
    double degh = M_PI * 2 / 12.0;
    degh *= h;
    degh += m * M_PI / 360.0;
    double hx, hy, mx, my;
    hx = cos(degh) * a;
    hy = sin(degh) * a;
    mx = cos(degm) * b;
    my = sin(degm) * b;
    doublecout(hypot(abs(hx - mx), abs(hy - my)));
    return 0;
}


Measured memory_bytes: 4168
def memoize(f):
    cache={}
    def helper(*args):
        if args not in cache:
            cache[args] = f(*args)
        return cache[args]
    return helper

@memoize
def ans(N):
    if N==0:
        return 2
    elif N==1:
        return 1
    else:
        return ans(N-1)+ans(N-2)

N=int(input())
print(ans(N))


Measured memory_bytes: 38384
# -- coding: utf-8 --
from collections import deque
N = int(input())
red = []
for i in range(N):
    red.append(list(map(int, input().split(' '))))
blue = []
for i in range(N):
    blue.append(list(map(int, input().split(' '))))
red = deque(sorted(red, key=lambda x:(x[1], x[0]), reverse=True))
blue = deque(sorted(blue))
count = 0
flag = [0] * N
for b in blue:
    for i, r in enumerate(red):
        if r[0] < b[0] and r[1] < b[1] and flag[i] == 0:
            count += 1
            flag[i] = 1
            break

print(count)

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

#define ran 55

int n;
int a[ran], c[ran];

int main() {
	scanf("%d", &n);
	for(int i=1;i<=n;i++) scanf("%d", &a[i]);
	
	int s = 0;
	for(int i=1;i<=n;i++) {
		int x; scanf("%d", &x);
		s+=x;
	}
	for(int i=1;i<n;i++) scanf("%d", &c[i]);
	for(int i=2;i<=n;i++)
		if(a[i-1]==a[i]-1) s += c[a[i-1]];
	
	printf("%d\n", s);
	
	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 p=0;
        while(true){
            int m=sc.nextInt();
            int f=sc.nextInt();
            int r=sc.nextInt();
            if(m==-1&&f==-1&&r==-1){
                break;
            }  
              p=m+f;
                 if(80<=p){
                     System.out.println("A");
                 }
                 else if(m==-1){
                     System.out.println("F");
                 }
                 else if(f==-1){
                     System.out.println("F");
                 }     
            
                 else if(65<=p&&p<80){
                     System.out.println("B");
                 }
            	 else if(50<=p&&p<65||50<=r){
                     System.out.println("C");
                 }
             	 else if(30<=p&&p<50){
                     System.out.println("D");
                 }
                 else if(p<30){
                     System.out.println("F");
                 } 
            
        }
       sc.close();  
    }
}



Measured memory_bytes: 26260
#[macro_use]
mod input {

use std;
use std::io;

const SPLIT_DELIMITER: char = ' ';

#[macro_export]
#[allow(unused_macros)]
macro_rules! input {
    ( $($x:expr ),*) => {
        {
            let temp_str = input_line_str();
            let mut split_result_iter = temp_str.split_whitespace();
                $(
                let buf_split_result = split_result_iter.next();
                let buf_split_result = buf_split_result.unwrap();
                    ($x) = buf_split_result.parse().unwrap();
                )*
        }
    };
}

#[allow(dead_code)]
pub fn input_line_str() -> String {
    let mut s = String::new();
    io::stdin().read_line(&mut s).unwrap();
    s.trim().to_string()
}

#[allow(dead_code)]
pub fn p<T>(t: T)
where
    T: std::fmt::Display,
{
    println!("{}", t);
}

#[allow(dead_code)]
pub fn input_vector2d<T>(line: usize) -> Vec<Vec<T>>
where
    T: std::str::FromStr,
{
    let mut v: Vec<Vec<T>> = Vec::new();

    for _ in 0..line {
        let vec_line = input_vector();
        v.push(vec_line);
    }
    v
}

#[allow(dead_code)]
pub fn input_vector<T>() -> Vec<T>
where
    T: std::str::FromStr,
{
    let mut v: Vec<T> = Vec::new();

    let s = input_line_str();
    let split_result = s.split(SPLIT_DELIMITER);
    for z in split_result {
        let buf = match z.parse() {
            Ok(r) => r,
            Err(_) => panic!("Parse Error"),
        };
        v.push(buf);
    }
    v
}

#[allow(dead_code)]
pub fn str2vec(s: &str) -> Vec<char> {
    let mut v: Vec<char> = Vec::new();
    for c in s.chars() {
        v.push(c);
    }
    v
}

}

use input::*;
use std::collections::BinaryHeap;
use std::collections::HashMap;

fn main() {
    let n: usize;
    input!(n);
    let a = input_vector::<usize>();
    let mut map = HashMap::new();
    let mut heap = BinaryHeap::new();

    for z in &a {
        let po = map.entry(*z).or_insert(0);
        *po += 1;
        if *po == 2 {
            *po = 0;
            heap.push(*z);
        }
    }

    if heap.len() < 2 {
        p(0);
    } else {
        let e1 = heap.pop().unwrap();
        let e2 = heap.pop().unwrap();
        p(e1 * e2);
    }
}

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

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

ll mod = 998244353;

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

  double d = 0;
  for(int i = 0;i < n;i++){
    double a;
    cin >> a;
    d += 1.0 / a;
  }
  cout << fixed << setprecision(10);
  cout << 1.0 / d << endl;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

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

        String sankaNum = sc.next();
        String startPoint = sc.next();
        String correctAnswer = sc.next();
        String[] correctUsers = new String[Integer.parseInt(correctAnswer)];
        for (int i = 0; i < Integer.parseInt(correctAnswer); i++) {
            correctUsers[i] = sc.next();
        }

        int lifePoint = Integer.parseInt(startPoint) - Integer.parseInt(correctAnswer);
        int[] points = new int[Integer.parseInt(sankaNum)];

        for (int i = 0; i < Integer.parseInt(correctAnswer); i++) {
            points[Integer.parseInt(correctUsers[i] )- 1]++;
        }

        for (int i = 0; i < points.length; i++) {
            points[i] += lifePoint;
            System.out.println(points[i] > 0 ? "Yes" : "No");
        }
    }
}


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

int main() {
  int a, b, c;
  cin >> a >> b >> c;
  if (b - a == c - b) cout << "YES" << endl;
  else cout << "NO" << endl;
}

Measured memory_bytes: 256
#include <cstdio>
#include <cstring>
#include <vector>
#include <queue>
#include <string>
#include <algorithm>
#include <iostream>
#include <string>
#include <map>
#include <set>
#include <functional>
#include <iostream>
#define MOD 1000000007LL
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
int n;

ll ma,md,ms,mh;

struct data{
	ll h,a,d,s;
	data(){}
	data(ll hh,ll aa,ll dd,ll ss){
		h=hh;
		a=aa;
		d=dd;
		s=ss;
	}
	bool operator <(const data& da)const{
		ll turn=(h+(ma-d-1LL))/(ma-d);
		ll dturn=(da.h+(ma-da.d-1LL))/(ma-da.d);
		ll sum=turn*max(0LL,a-md)+(turn+dturn)*max(0LL,da.a-md);
		ll dsum=(turn+dturn)*max(0LL,a-md)+dturn*max(0LL,da.a-md);
		return sum<dsum;
	}
};


vector<data> vec;

int main(void){
	scanf("%d",&n);
	ll sum=0;
	scanf("%lld%lld%lld%lld",&mh,&ma,&md,&ms);
	for(int i=0;i<n;i++){
		ll h,a,d,s;
		scanf("%lld%lld%lld%lld",&h,&a,&d,&s);
		if(ma-d<=0LL){
			if(a-md>0){
				printf("-1\n");
				return 0;
			}
		}else{
			sum+=max(0LL,a-md);
			vec.push_back(data(h,a,d,s));
		}
	}
	sort(vec.begin(),vec.end());
	ll res=0;
	for(int i=0;i<vec.size();i++){
		ll turn=(vec[i].h+(ma-vec[i].d-1LL))/(ma-vec[i].d);
		res+=turn*sum;
		if(vec[i].s<ms)res-=max(0LL,vec[i].a-md);
		if(res>=mh){
			printf("-1\n");
			return 0;
		}
		sum-=max(0LL,vec[i].a-md);
	}
	printf("%lld\n",res);
	return 0;
}

Measured memory_bytes: 4900
//#pragma comment(linker, "/stack:200000000")
//#pragma GCC optimize("Ofast")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
//#pragma GCC optimize("unroll-loops")
 
#include <iostream>
#include <stdlib.h>
#include <cmath>
#include <algorithm>
#include <vector>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <random>
#include <assert.h>
#include <memory.h>
#include <time.h>
#include <bitset>
 
#define uint unsigned int
#define ll long long
#define ull unsigned long long
#define ld long double
#define rep(i, l, r) for (int i = (l); i < (r); i++)
#define repb(i, r, l) for (int i = (r); i > (l); i--)
#define sz(a) (int)a.size()
#define fi first
#define se second
#define mp(a, b) make_pair(a, b)
#define mt(a,b,c) make_tuple(a,b,c)
#define rank qwertyuio
#define next dfghjk
#define plus fsghsf
#define minus ytryr
#define pb push_back
using namespace std;
 
inline bool setmin(int &x, int y) { return (y < x) ? x = y, 1 : 0; }
inline bool setmax(int &x, int y) { return (y > x) ? x = y, 1 : 0; }
inline bool setmin(ll &x, ll y) { return (y < x) ? x = y, 1 : 0; }
inline bool setmax(ll &x, ll y) { return (y > x) ? x = y, 1 : 0; }
 
const int N = 100000;
const int inf = (int)1e9 + 1;
const ll big = (ll)1e18 + 1;
const int P = 239;
const int P1 = 31;
const int P2 = 57;
const int MOD = (int)1e9 + 7;
const int MOD1 = (int)1e9 + 9;
const int MOD2 = 998244353;
const ld eps = 1e-12;
const double pi = atan2(0, -1);
const int ABC = 26;
#define ent '\n'

bool sortbysec(const pair<int,int> &a, 
              const pair<int,int> &b) 
{ 
    return (a.second < b.second); 
} 
int main()
{
    //freopen("a.in", "r", stdin);
    //freopen("a.out", "w", stdout);
    
    int M1,D1,M2,D2;
    cin>>M1>>D1>>M2>>D2;
    if(M1==M2){
        cout<< 0;
    }
    else{
        cout<<1;
    }






        
    


    return 0;
}

Measured memory_bytes: 256
// https://atcoder.jp/contests/abc160/tasks/abc160_c

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

int main()
{
    long k, n;
    cin >> k >> n;

    long ma = -1;

    long start, frm, to;
    cin >> start;
    frm = start;
    for (int i = 0; i < n - 1; i++)
    {
        cin >> to;
        ma = max(ma, to - frm);
        frm = to;
    }
    ma = max(ma, k - frm + start);
    cout << k - ma << endl;
    return 0;
}

Measured memory_bytes: 3604
#include <stdio.h>
#include <math.h>
#include <bitset>
#include <vector>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <cstring>
#include <string>
#include <sstream>
#include <algorithm>
#include <iomanip>
#include <iostream>

#define VARIABLE(x) cerr << #x << "=" << x << endl
#define BINARY(x) cerr << #x << "=" << static_cast<bitset<16> >(x) << endl;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define REP(i,m,n) for (int i=m;i<(int)(n);i++)
#define if_range(x, y, w, h) if (0<=(int)(x) && (int)(x)<(int)(w) && 0<=(int)(y) && (int)(y)<(int)(h))

const int INF = 100000000;
typedef double D;
const double EPS = 1e-8;
const double PI = 3.14159;
int dx[4]={-1, 0, 1, 0}, dy[4]={0, -1, 0, 1};
using namespace std;
typedef pair<int, int> PII;

struct  P {
	int x, y;
	P() {}
	P(int x_, int y_) : x(x_), y(y_) {}
};

/** Problem2005 : Water Pipe Construction **/
int d[110][110];
int V;

void warshall_floyd()
{
	rep(k, V) {
		rep(i, V) {
			rep(j, V) {
				d[i][j] = min(d[i][j], d[i][k]+d[k][j]);
			}
		}
	}
}

int main()
{
	int M, S, G1, G2;
	while (cin>>V>>M>>S>>G1>>G2, V||M||S||G1||G2) {
		S--; G1--; G2--;
		
		fill(d[0], d[0]+110*110, INF);
		rep(i, 110) {
			d[i][i]=0;
		}
		
		rep(i, M) {
			int a, b, c;
			cin>>a>>b>>c;
			a--; b--;
			d[a][b]=c;
		}
		
		warshall_floyd();
	
		int ans=d[S][G1]+d[S][G2];
		rep(i, V) {
				int tmp = d[S][i]+d[i][G1]+d[i][G2];
				ans = min(ans, tmp);
		}
		cout << ans << endl;
	}
}

Measured memory_bytes: 1208
n = gets.chomp.to_i
a_arr = gets.chomp.split(" ").map(&:to_i).sort.reverse

alice = 0
bob = 0
a_arr.each_with_index do |a, i|
  if i % 2 == 0 then
    alice += a
  else
    bob += a
  end
end

puts alice - bob



Measured memory_bytes: 1788
def main() -> None:
    N = int(input())
    pos = [[int(i) for i in input().split()] for _ in range(N)]
    pos = sorted(pos, key=lambda x: x[2], reverse=True)
    x, y, h = pos[0]
    for CX in range(101):
        for CY in range(101):
            H = h + abs(x - CX) + abs(y - CY)
            if all(posh == max(H - abs(posx - CX) - abs(posy - CY), 0) for posx, posy, posh in pos):
                print('{x} {y} {h}'.format(x=CX, y=CY, h=H))
                exit()


if __name__ == '__main__':
    main()


Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define MOD 1000000007
using namespace std;

int N, A, B, C, D;
int dp[1005][1005], c[1005][1005], f[1000005], gc[1005][1005];

int qexp(int b, int p, int m) {
	if (p == 1) return b % m;
	if (p == 0) return 1 % m;
	if (p % 2 == 0) {
		int sub = qexp(b, p/2, m);
		return ((long long)sub * sub) % m;
	} else {
		long long sub = qexp(b, p/2, m);
		sub *= sub;
		sub %= m;
		sub *= b;
		return sub % m;
	}
}

int mod_inv(int x) {
	return qexp(x, MOD - 2, MOD);
}

int choose(int n, int k) {
	if (k < 0) return 0;
	if (k > n) return 0;
	if (n == 0) return 1;
	if (n == 1) return 1;
	if (c[n][k] != -1) return c[n][k];
	return c[n][k] = (choose(n - 1, k) + choose(n -1, k-1)) % MOD;
}

int main() {
	long long cur = 1;
	f[0] = 1;
	for (int i = 1; i <= 1000000; i++) {
		cur *= i;
		cur %= MOD;
		f[i] = cur;
	}
	
	memset(c, -1, sizeof(c));
	scanf("%d%d%d%d%d", &N, &A, &B, &C, &D);
	for (int i = 1; i <= N; i++) {
		long long denom = 1;
		for (int k = 0; k <= N/i; k++) {
			gc[k][i] = ((long long)f[k * i] * mod_inv(denom)) % MOD;
			gc[k][i] = ((long long)mod_inv(f[k]) * gc[k][i]) % MOD;
			//gc[k][i] %= MOD;
			denom *= f[i];
			denom %= MOD;
			//printf("%d %d = %d\n", k, i, gc[k][i]);
		}
	}
	dp[0][0] = 1;
	for (int i = 1; i <= N; i++) {
		for (int j = 0; j <= N; j++) {
			long long cc = 1;
			// i - group size considering, j - current number
			for (int k = 0; k <= j/i; k++) {
				if (!(k == 0 || (i >= A && i <= B && k >= C && k <= D))) continue;
				long long cur = ((long long)dp[i - 1][j - k * i] * choose(N - (j - k * i), k * i)) % MOD;
				cur *= gc[k][i];
				cur %= MOD;
				dp[i][j] += cur;
				
				dp[i][j] %= MOD;
				
			}
			//printf("%d %d = %d\n", i,j,dp[i][j]);
		}
	}
	printf("%d\n", dp[N][N]);
}


Measured memory_bytes: 16000
#include <iostream>
#include <vector>
#include <cassert>
#include <algorithm>
#include <functional>
#include <cmath>
#include <queue>
#include <set>
#include <stack>
#include <deque>
#include <map>
#include <iomanip>
#include <limits>
using ll = long long;
using ld = long double;
int MOD = 1e9 + 7;
using namespace std;
struct UnionFind
{
    vector<int> par; // par[i]:iの親の番号　(例) par[3] = 2 : 3の親が2

    UnionFind(int N) : par(N)
    { //最初は全てが根であるとして初期化
        for (int i = 0; i < N; i++)
            par[i] = i;
    }

    int root(int x)
    { // データxが属する木の根を再帰で得る：root(x) = {xの木の根}
        if (par[x] == x)
            return x;
        return par[x] = root(par[x]);
    }

    void unite(int x, int y)
    {                     // xとyの木を併合
        int rx = root(x); //xの根をrx
        int ry = root(y); //yの根をry
        if (rx == ry)
            return;   //xとyの根が同じ(=同じ木にある)時はそのまま
        par[rx] = ry; //xとyの根が同じでない(=同じ木にない)時：xの根rxをyの根ryにつける
    }

    bool same(int x, int y)
    { // 2つのデータx, yが属する木が同じならtrueを返す
        int rx = root(x);
        int ry = root(y);
        return rx == ry;
    }
};
ll dx[] = {-1, 0, 1, 0};
ll dy[] = {0, -1, 0, 1};
vector<vector<char>> vec;
vector<vector<ll>> reg;
ll h, w;
void dfs(ll y,ll x,ll temp, char color){
    reg[y][x] = temp;
  //  cout<<y<<" "<<x<<" "<<color<<endl;
    color = vec[y][x];
    for (int i = 0; i < 4;i++){
        if(y+dy[i]>=0&&y+dy[i]<h&&x+dx[i]>=0&&x+dx[i]<w&&reg[y+dy[i]][x+dx[i]]==-1&&vec[y+dy[i]][x+dx[i]]!=color){
            dfs(y + dy[i], x + dx[i], temp, color);
        }
    }
    return;
}
int main()
{
    cin >> h >> w;
    vec.resize(h, vector<char>(w));
    reg.resize(h, vector<ll>(w, -1));
    for (int i = 0;i<h;i++){
        string s;
        cin>>s;
        for (int j = 0; j < w;j++){
            vec[i][j] = s[j];
        }
    }
    ll temp = 0;
    for (int i = 0; i < h;i++){
        for (int j = 0; j < w;j++){
            if(reg[i][j]==-1){
                dfs(i, j, temp,'?');
                temp++;
            }
        }
    }
   // cout<<endl<<endl;
    vector<vector<ll>> res(h * w + 1,vector<ll>(2));
    for (int i = 0; i < h;i++){
        for (int j = 0; j < w;j++){
            if(vec[i][j]=='#'){
                res[reg[i][j]][0]++;
            }else{
                res[reg[i][j]][1]++;
            }
        }
    }
    ll sum=0;
    for (int i = 0; i < h * w;i++){
      //  cout<<res[i][0]<<" "<<res[i][1]<<endl;
        sum += res[i][0] * res[i][1];
    }
    cout << sum << endl;
}

Measured memory_bytes: 20480
#include<stdio.h>
#include<string.h>
#define RATE 380000
int main(){
    int n,i;
    double x,income=0;
    char u[4];
    scanf("%d",&n);
    for(i=0;i<n;i++){
        scanf("%lf%s",&x,u);
        if(strcmp(u,"BTC")==0){
            income+=RATE*x;
        }else{
            income+=x;
        }
    }
    printf("%lf\n",income);
    return 0;
}

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


struct s{
  int t;
  int x;
  int y;
};

int main(){
  int n;
  int t, x, y;
  scanf("%d", &n);

  vector
 v;
  v.push_back({0, 0, 0});

  REP (i, n) {
    scanf("%d %d %d", &t, &x, &y);
    v.push_back({t, x, y});
  }

  bool flag = true;
  FOR (i, 1, n + 1) {
    int time = v[i].t - v[i - 1].t;
    int dist = abs(v[i].x - v[i - 1].x) + abs(v[i].y - v[i - 1].y);
    if (time < dist || time % 2 != dist % 2) flag = false;
  }
  if (flag) cout << "Yes" << endl;
  else cout << "No" << endl;
}


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

int main() {
  int N,D; cin >> N >> D;
  vector<int> X(N);
  vector<int> Y(N);
  for (int i =0; i<N; i++) {
    cin >> X.at(i) >> Y.at(i);
  }
  
  int ans =0;
  for (int i =0; i<N; i++) {
    long dist = (long)X.at(i) * X.at(i) + (long)Y.at(i) * Y.at(i);
    if (dist <= (long)D * D) ans++;
  }
  
  cout << ans << endl;
}

Measured memory_bytes: 4832
#include <bits/stdc++.h>
#define ll long long

using namespace std;

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

    ll N, W;
    cin >> N >> W;
    vector<ll> dp(100001, 1e18L+9);
    // dp[i] = minimum weight required for value i
    dp[0]=0;
    for(ll i=0; i<N; i++){
        ll w, v;
        cin >> w >> v;
        for(ll j=100000; j>=0; j--){
            if(j+v<=100000)
                dp[j+v]=min(dp[j+v], dp[j]+w);
        }
    }
    ll ans;
    for(ll i=100000; i>=0; i--){
        if(dp[i]<=W){
            ans=i;
            break;
        }
    }
    cout << ans << endl;
	return 0;
}


Measured memory_bytes: 3988
#include <iostream>
#include <stdio.h>
#include <string>
#include <cstdlib>
#include <cmath>
#include <cstring>
#include <math.h>
#include <vector>
#include <algorithm>

using namespace std;

typedef unsigned long long ull;
typedef long long ll;

int main(){
	int n;
	cin >> n;
	if(n==1){
		cout << "Hello World" << endl;
		return 0;
	}
	else{
		int a, b;
		cin >> a >> b;
		cout << a+b << endl;
	}
	return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<stdlib.h>
#include<math.h>

int binarySearch(int,int *,int);
int main(){
  int n,q,*S,i,key,cnt=0;
  while(1){
    
    scanf("%d",&n);
    if(n<=pow(10,5)) break;
  }
     S = (int *)malloc((n+1)*sizeof(int));
    for(i=0;i<n;i++){
      scanf("%d",&S[i]);
      if(S[i]<0&&S[i]>pow(10,9)) exit(2);
    }
     while(1){
    
    scanf("%d",&q);
    if(q<=pow(10,4)*5) break;
  }

 for(i=0;i<q;i++){
      scanf("%d",&key);
      if(key<0||key>pow(10,9)) exit(2);
      if(binarySearch(key,S,n)) cnt++;
 }
 printf("%d\n",cnt);
 return 0;
}

int binarySearch(int key,int *S,int n){
  
  int left =0,right=n,mid;

  while(left <right) {
    mid = (left + right)/2;
    if(S[mid] ==key) return 1;
    else if(key<S[mid]) right = mid;
    else left = mid +1;
   
    
  }
  return 0;
  
}



Measured memory_bytes: 2108
#include <stdio.h>
#include <string.h>
#include <stdbool.h>
#include <stdint.h>
#include <stdlib.h>
#include <limits.h>
#include <math.h>
int acs(const void *a, const void *b){return *(int*)a - *(int*)b;} /* 1,2,3,4.. */
int des(const void *a, const void *b){return *(int*)b - *(int*)a;} /* 8,7,6,5.. */
int cmp_char(const void *a, const void *b){return *(char*)a - *(char*)b;} /* a,b,c,d.. */
int cmp_str(const void *a, const void *b){return strcmp(*(const char **)a, *(const char **)b);} /* aaa,aab.. */
#define min(a,b) (a < b ? a: b)
#define max(a,b) (a > b ? a: b)

typedef long long int lli;

lli gcd(lli a, lli b)
{
  lli max = max(a, b);
  lli min = min(a, b);
  
  if (max % min == 0) return min;
  else return gcd(max % min, min);
}

int main(void) {
  lli a, b;
  scanf("%lld %lld", &a, &b);

  lli max = gcd(a, b);

  lli i, div, ans = 1;
  for (i = 2; i <= (int)sqrt(max) + 1; i++) {
    if (max % i == 0) {
      ans++;
      while (max % i == 0) max /= i;
    }
  }
  if (max > 1) ans++;
  printf("%lld\n", ans);
  return 0;
}


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

a_list=[int(i) for i in input().split()]
b_list=[int(i) for i in input().split()]
c_list=[int(i) for i in input().split()]

satisfaction=0

for i in range(n):
    satisfaction+=b_list[a_list[i]-1]
    if i<n-1:
        
        if a_list[i+1]==a_list[i]+1:
            satisfaction+=c_list[a_list[i]-1]
            
print(satisfaction)


Measured memory_bytes: 9196
#include <iostream>
#include <vector>
#include <cmath>
#include <map>
 
using namespace std;
int N, M;
vector<int> A;

int main()
{
  int i;
  int sum=0;
  int th;
  int cn=0;

  cin >> N >> M;

  A.resize(N);
  for (i=0; i<N; i++) {
    cin >> A[i];
    sum += A[i];
  }
  th = sum/4/M;
  for (i=0; i<N; i++) {
    if (A[i]*4*M>=sum) cn++;
  }
//  printf("sum=%d, cn=%d\n", sum, cn);
  if (cn>=M)
    printf("Yes\n");
  else
    printf("No\n");
  
  return 0;
}


Measured memory_bytes: 256
#![allow(unused_imports)]
#![allow(unused_macros)]
#![allow(unused_variables)]

use std::cmp::{max, min};

macro_rules! input {
  (source = $s:expr, $($r:tt)*) => {
    let mut iter = $s.split_whitespace();
    input_inner!{iter, $($r)*}
  };
  ($($r:tt)*) => {
    let s = {
      use std::io::Read;
      let mut s = String::new();
      std::io::stdin().read_to_string(&mut s).unwrap();
      s
    };
    let mut iter = s.split_whitespace();
    input_inner!{iter, $($r)*}
  };
}

macro_rules! input_inner {
  ($iter:expr) => {};
  ($iter:expr, ) => {};
  ($iter:expr, $var:ident : $t:tt $($r:tt)*) => {
    let $var = read_value!($iter, $t);
    input_inner!{$iter $($r)*}
  };
}

macro_rules! read_value {
  ($iter:expr, ( $($t:tt),* )) => {
    ( $(read_value!($iter, $t)),* )
  };
  ($iter:expr, [ $t:tt ; $len:expr ]) => {
    (0..$len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()
  };
  ($iter:expr, chars) => {
    read_value!($iter, String).chars().collect::<Vec<char>>()
  };
  ($iter:expr, usize1) => {
    read_value!($iter, usize) - 1
  };
  ($iter:expr, $t:ty) => {
    $iter.next().unwrap().parse::<$t>().expect("Parse error")
  };
}

fn main() {
  input! {
    n: i32,
    a: i32,
    b: i32,
    s: String,
  }
  let mut x = 0;
  let mut y = 0;
  for c in s.chars() {
    if c == 'a' {
      if x < a + b {
        print!("Yes ");
        x += 1;
      } else {
        print!("No ");
      }
    } else if c == 'b' {
      if x < a + b && y < b {
        print!("Yes ");
        x += 1;
        y += 1;
      } else {
        print!("No ");
      }
    } else {
      print!("No ");
    }
  }
}


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

a=list(map(int,input().split(' ')))

r=[]
for it in a:
    r.append(it)

r.append(a[N-2])

for idx,it in enumerate(a):
    if(r[idx+1]>it):
        r[idx+1]=it
print(sum(r))
            


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

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

    while (true) {
        bool is_prime = true;

        for (int i = 2, n = x; i < n; i++)
            if (x % i == 0) {
                is_prime = false;
                break;
            }

        if (is_prime)
            break;
        else
            x++;
    }


    cout << x << endl;
}

Measured memory_bytes: 3600
#include <bits/stdc++.h>
using namespace std;
#define pp pair<int,int>
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define rep2(i,m,n) for(int (i)=(m);(i)<(n);(i)++)
#define ll long long
#define ld long double
#define all(a) (a).begin(),(a).end()
#define mk make_pair
int main(){
  ld a,b;
  cin>>a>>b;
 ll ans=floor(a*b);
  cout<<ans<<endl;
return 0;
}

Measured memory_bytes: 3728
n=int(input())
lis=list(map(int,input().split()))
lis2=list(map(int,input().split()))
abslis=[0 for i in range(n)]

for i in range(n):
    abslis[i]=abs(lis[i]-lis2[i])

print("{:.6f}".format(sum(abslis)))
summ=0
for i in range(n):
    summ+=abslis[i]**2
summ**=0.5
print("{:.6f}".format(summ))
summ=0
for i in range(n):
    summ+=abslis[i]**3
summ**=(1/3)
print("{:.6f}".format(summ))
print("{:.6f}".format(max(abslis)))


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

#define int long long
#define double long double
#define all(a) (a).begin(), (a).end()
#define x first
#define y second
#define lb(v, z) lower_bound(all(v), z)
#define ub(v, z) upper_bound(all(v), z)
#define fill(a, z) memset(a, z, sizeof(a))
#define rep(i, a, b) for (i = (a); i <= (b); i++)
#define rdp(i, a, b) for (i = (a); i >= (b); i--)
#define cns(z) cout << z << ' '
#define cnl(z) cout << z << '\n'
#define M 1000000007
#define M2 998244353
#define endl "\n"
#define iip(t) \
	int t;     \
	cin >> t;
#define iip2(a, b) \
	int a, b;      \
	cin >> a >> b;
#define dip(a) \
	double a;  \
	cin >> a;
#define dip2(a, b) \
	double a, b;   \
	cin >> a >> b;
#define garr(ip)       \
	for (auto &x : ip) \
		cin >> x;
#define parr(ip)          \
	for (auto &x : ip)    \
		cout << x << " "; \
	cout << endl;
#define test   \
	int _t;    \
	cin >> _t; \
	while (_t--)

typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<pair<int, int>> vp;

signed main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	int n, k, c;
	cin >> n >> k >> c;
	string s;
	cin >> s;
	vi l(k), r(k);
	int day = 0;
	int i;
	rep(i, 0, k-1)
	{
		while (s[day] == 'x')
			day++;
		l[i] = day + 1;
		day += c + 1;
	}
	day = n - 1;
	rdp(i, k-1, 0)
	{
		while (s[day] == 'x')
			day--;
		r[i] = day + 1;
		day -= c + 1;
	}
	rep(i,0,k-1)
	{
		if(l[i] == r[i])
		cnl(l[i]);
	}
}

Measured memory_bytes: 5012
#pragma GCC optimize("O3")
#include<stdio.h>
int main(void){
  printf("1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1");
  return 0;
}

Measured memory_bytes: 1604