akhauriyash/Code-Regression huggingface dataset:
#define _CRT_SECURE_NO_WARNINGS
#include<stdio.h>
#include<vector>
#include<functional>
#include<algorithm>
#include<stdlib.h>
#include<string>
#include<string.h>
#define _USE_MATH_DEFINES
#include<math.h>
#include<deque>
#include<set>
#include<map>
#include<queue>
#include<list>
#include<iostream>
#include <bitset>
using namespace std;
typedef long long ll;
#define rep(i,a,b) for(auto i=a;i<b;i++)
#define all(_x) _x.begin(), _x.end()
#define r_sort(_x) sort(_x, std::greater<int>())
#define vec_cnt(_a, _n) (upper_bound(all(_a), _n) - lower_bound(all(_a), _n))
#define vec_unique(_a) _a.erase(std::unique(all(_a)), _a.end());
#define vvec vector<vector<ll>>
ll gcd(ll a, ll b) { return a % b == 0 ? b : gcd(b, a % b); }
ll lcm(ll a, ll b) { return (a / gcd(a, b)) * b; }
#define INF 1 << 30
const int mod = 1000000007;
ll power(ll x, ll p) { ll a = 1; while (p > 0) { if (p % 2 == 0) { x *= x; p /= 2; } else { a *= x; p--; } }return a; }
ll mpower(ll x, ll p) { ll a = 1; while (p > 0) { if (p % 2 == 0) { x = x * x % mod; p /= 2; } else { a = a * x % mod; p--; } }return a; }
ll ac(ll n, ll k) { ll a = 1; rep(i, 1, k) { a *= n - i + 1; a /= i; }return a; }
ll mc(ll n, ll m) { ll k = 1, l = 1; rep(i, n - m + 1, n + 1) k = k * i % mod; rep(i, 1, m + 1) l = l * i % mod; l = mpower(l, mod - 2); return k * l % mod; }

int main()
{
	int n, c, x, x2;
	cin >> n;
	vector<int> a(n), b, b2;
	rep(i, 0, n)cin >> a[i];
	sort(all(a));
	int k = (int)sqrt(a[0]), k2 = (int)sqrt(a[1]);
	rep(i, 1, k + 1) {
		if (a[0] % i == 0) {
			b.push_back(i);
			b.push_back(a[0] / i);
		}
	}
	r_sort(all(b));
	for (auto v : b) {
		c = 0;
		rep(i, 0, n) {
			if (a[i] % v == 0)c++;
		}
		if (c >= n - 1) {
			x = v;
			break;
		}
	}
	rep(i, 1, k2 + 1) {
		if (a[1] % i == 0) {
			b2.push_back(i);
			b2.push_back(a[1] / i);
		}
	}
	r_sort(all(b2));
	for (auto v : b2) {
		c = 0;
		rep(i, 0, n) {
			if (a[i] % v == 0)c++;
		}
		if (c >= n - 1) {
			x2 = v;
			break;
		}
	}
	printf("%d\n", max(x, x2));
	return 0;
}


Measured memory_bytes: 3816
#include<bits/stdc++.h>
using namespace std;
//ofstream fout("output.txt");
#define ll long long
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define IOS ios_base::sync_with_stdio(0);
#define pi 4*atan(1)
#define f(n) for(int i=0;i<n;++i)
#define fab(a,b) for(int i=a;i<=b;++i)
#define fba(b,a) for(int i=b;i>=a;--i)
#define reset(a,x) memset(a,x,sizeof(a))
typedef pair<int,int> ipair;
typedef vector<int> vi;
int main(){
    IOS
    cin.tie(0);

    

        string s;
        cin>>s;

        if(s[2]==s[3]&&s[4]==s[5])
        {
            cout<<"Yes"<<endl;
        }
        else
            cout<<"No"<<endl;

    





    return 0;
}










Measured memory_bytes: 256
import java.util.*;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();
    int[] a = new int[n];
    for (int i = 0; i < n; i++) {
      a[i] = sc.nextInt();
    }

    double gyaku = 0;
      for (int i = 0; i < n; i++) {
      gyaku += 1d / (double)a[i];
    }

    System.out.println(1d / gyaku);
  }
}

Measured memory_bytes: 21844
import itertools

n = int(input())
p = tuple(int(i) for i in input().split())
q = tuple(int(i) for i in input().split())

l = sorted(map(tuple,list(itertools.permutations(p))))
count  = []

for num, i in enumerate(l):
  if(i == p or i == q):
    count.append(num + 1)
if(len(count) == 1):
  print(0)
else:
  print(abs(count[0] - count[1]))


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

int main()
{ int n,k;
  cin>>n>>k;
  int h[n];
  for( int i =0;i<n;i++)
  {
      cin>>h[i];
  }
   int dp[n];
   dp[0]=0;
   for(int i =1;i<n;i++)
   {dp[i]=INT_MAX;}
   for(int i =1;i<n;i++)
   {
        int ans=INT_MAX;
  for(int j =1;j<=k;j++)
        {if(i-j>=0)
        { int op1 = dp[i-j];
        if(op1!=INT_MAX)
       { op1+= abs(h[i]-h[i-j]); }
        ans= min(ans, op1);
        }
         
         }
        dp[i]= ans;

        

   }

 cout<<dp[n-1]<<endl;


    return 0;

}

Measured memory_bytes: 4388
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
#define rep(i, n) for(int i = 0; i < n; i++)
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define fi first
#define se second
#define pb push_back
#define debug(x) cerr << #x << ": " << x << endl
#define debug_vec(v) cerr << #v << ":"; rep(i, v.size()) cerr << " " << v[i]; cerr << endl
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
const int INF = (1<<30) - 1;
const ll LINF = (1LL<<60) - 1;

void solve() {
    int n, k;
    cin >> n >> k;
    vector<int> P(n), C(n);
    rep(i, n) cin >> P[i], P[i]--;
    rep(i, n) cin >> C[i];

    ll ans = -LINF;

    rep(i, n) {
        int v = i, cnt = 0;
        ll sum = 0;

        do {
            cnt++;
            sum += C[v];
            v = P[v];
        } while(v != i);

        ll x = 0;
        int h = 0;

        do {
            v = P[v];
            x += C[v];
            h++;
            if (h > k) break;
            int m = (k - h) / cnt;
            chmax(ans, max(0LL, sum) * m + x);
        } while(v != i);
    }
    cout << ans << endl;
}

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


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

#define rep(i,n) for(int (i)=0;(i)<(int)(n);(i)++)
#define rept(i,n) for(int (i)=0;(i)<=(int)(n);(i)++)
#define reps(i,s,n) for(int (i)=(s);(i)<(int)(n);(i)++)
#define repst(i,s,n) for(int (i)=(s);(i)<=(int)(n);(i)++)
#define repr(i,n) for(int (i)=(n);(i)>=0;(i)--)
#define each(itr,v) for(auto (itr):(v))
#define all(c) (c).begin(),(c).end()
#define pb push_back
#define mp(x,y) make_pair((x),(y))
#define fi first
#define se second
#define chmin(x,y) x=min(x,y)
#define chmax(x,y) x=max(x,y)
#define ln "\n"
#define show(x) cout << #x << " = " << x ln
#define dbg(x) cout<<#x"="<<x ln

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

const int inf = (int)1e9;
const ll linf = (ll)1e18;
const int mod = (int)(1e9+7);
const int dx[] = {0, 1, 0, -1};
const int dy[] = {1, 0, -1, 0};
const int ddx[] = {0, 1, 1, 1, 0, -1, -1, -1};
const int ddy[] = {1, 1, 0, -1, -1, -1, 0, 1};

struct oreno_initializer {
	oreno_initializer() {
		cin.tie(0);
		ios::sync_with_stdio(0);
	}
} oreno_initializer;

// ━━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…
// .｡.:( ^ω^)・ﾟ＋.｡.:( ^ω^)・ﾟ＋.｡.:( ^ω^)・ﾟ＋.｡.:( ^ω^)・ﾟ＋.｡.:( ^ω^)・ﾟ＋
// ・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・

int n, t, m, a, d[100000], mxd;

int main() {
	cin >> n >> t;
	cin >> m;
	reps(i,1,n) {
		cin >> a;
		d[i] = a-m;
		chmax(mxd, d[i]);
		chmin(m, a);
	}
	int ans = 0;
	rep(i,n) if (d[i]==mxd) ans++;
	cout << ans << ln;
}

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

int main()
{
	char s[101];
	int l = 0;
	bool x = false;

	cin >> s;

	for(int i=0; i<101; i++){
		if(s[i] != '\0'){
			l++;
		}
		else{
			break;
		}
	}

	for(int i=0; i<l; i++){
		if(s[i] == 'C'){
			for(int j=i+1; j<l; j++){
				if(s[j] == 'F'){
					x = true;
				}
			}
		}
	}

	if(x == true){
		cout << "Yes\n";
	}
	else{
		cout << "No\n";
	}

	return 0;
}


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

int main()
{
    int n;
    vector<int> p;
    cin >> n;

    for (int i = 0; i < n; i++)
    {
        int temp;
        cin >> temp;
        p.push_back(temp);
    }
    int ans = 0;
    for (int i = 0; i < n - 2; i++)
    {
        vector<int> temp;
        temp.push_back(p[i]);
        temp.push_back(p[i + 1]);
        temp.push_back(p[i + 2]);
        sort(temp.begin(), temp.end());

        if (temp[1] == p[i + 1])
        {
            ans++;
        }
    }

    cout << ans;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
const long long INF = 1LL << 60;
const int mod = 1e9 + 7;

int main()
{
    string s;
    while (cin >> s)
    {
        if (s == "-")
        {
            break;
        }
        int m;
        cin >> m;
        for (int i = 0; i < m; i++)
        {
            int h;
            cin >> h;
            string f, b;
            f = s.substr(0, h);
            b = s.substr(h, s.size() - f.size() + 1);
            s = b + f;
        }
        cout << s << endl;
    }
    return 0;
}


Measured memory_bytes: 3120
#include<iostream>
using namespace std;
 
int main(){
  
  int X,N;
  
  int P[110];
  
  cin>>X>>N;
  
  if(N == 0){
    cout<<X;
    return 0;
  
  
  }
  
  for(int i = 0;i < N;i++){
    cin>>P[i];
  
  }
  
  int res = 200;
  
  int T = 0;
  int Tn = 0;
  
  int T2 = 0;
  int T2n = 0;
  
  
  for(int i = 101;i >= 0;i--){
    
    bool aru = false;
    for(int j = 0;j < N;j++){
      if(i == P[j])aru = true;
    
    }
    
    if(aru){
    
    }else{
      int tmp = abs(X-i);
      if(min(tmp,res) == tmp){
        res = tmp;
        Tn = res;
        T = i;
      
      }
    
    }
    
    }
  
  res = 200;
  
    for(int i = -101;i <= -1;i++){
      int tmp = abs(X-i);
      if(min(tmp,res) == tmp){
        res = tmp;
        T2n = res;
        T2 = i;
    }
      
    }
      
      if(Tn > T2n){
        cout<<T2;
      }else{
        cout<<T;
      
      }
  
  
  return 0;
}

Measured memory_bytes: 3632
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

public class AtCoderA
{
    static void Main()
    {
        var sc = new Scanner();

        int x = sc.NextInt();
        int t = sc.NextInt();

        int answer = Math.Max(0, x - t);

        Console.WriteLine(answer);
    }

    class Scanner
    {
        private string[] _line;
        private int _index;
        private const char Separator = ' ';

        public Scanner()
        {
            _line = new string[0];
            _index = 0;
        }

        public string Next()
        {
            while (_index >= _line.Length)
            {
                _line = Console.ReadLine().Split(Separator);
                _index = 0;
            }

            return _line[_index++];
        }

        public int NextInt() => int.Parse(Next());
        public long NextLong() => long.Parse(Next());
        public double NextDouble() => double.Parse(Next());
        public decimal NextDecimal() => decimal.Parse(Next());
        public char NextChar() => Next()[0];
        public char[] NextCharArray() => Next().ToCharArray();

        public string[] Array()
        {
            _line = Console.ReadLine().Split(Separator);
            _index = _line.Length;
            return _line;
        }

        public int[] IntArray() => Array().Select(int.Parse).ToArray();
        public long[] LongArray() => Array().Select(long.Parse).ToArray();
        public double[] DoubleArray() => Array().Select(double.Parse).ToArray();
        public decimal[] DecimalArray() => Array().Select(decimal.Parse).ToArray();
    }
}

Measured memory_bytes: 13140
#include<iostream>
using namespace std;
int main() {
	int a, b, c, d, e;
	cin >> a >> b >> c >> d >> e;
	if (c + e <= a && c - e >= 0 && d + e <= b && d - e >= 0) {
		cout << "Yes" << endl;
	}
	else {
		cout << "No" << endl;
	}
}


Measured memory_bytes: 3116
W, H, N = map(int, input().split())
min_H = 0
min_W = 0
max_H = H
max_W = W

for _ in range(N):
    x, y, a = map(int, input().split())

    if a == 1:
        min_W = max(x, min_W)
    elif a == 2:
        max_W = min(x, max_W)
    elif a == 3:
        min_H = max(y, min_H)
    else:
        max_H = min(y, max_H)

if min_W > max_W or min_H > max_H:
    print(0)
else:
    print((max_H - min_H) * (max_W - min_W))


Measured memory_bytes: 3188
#include<iostream>
using namespace std;
int n,t[8][8];
string str;

int tt(int y,int x){
  if(0<=y&&y<=7&&0<=x&&x<=7)return t[y][x];
  return 0;
}

void rec(int y,int x){
  t[y][x]=0;
  for(int i=0;i<=3;i++){
    if(tt(y+i,x)==1)rec(y+i,x);
    if(tt(y-i,x)==1)rec(y-i,x);
    if(tt(y,x+i)==1)rec(y,x+i);
    if(tt(y,x-i)==1)rec(y,x-i);
  }
}

int main(){
  int x,y;
  cin>>n;
  for(int I=1;I<=n;I++){
    for(int i=0;i<8;i++){
      cin>>str;
      for(int j=0;j<8;j++)t[i][j]=str[j]-'0';
    }
    cin>>x>>y;
    rec(y-1,x-1);
    cout<<"Data "<<I<<':'<<endl;
    for(int i=0;i<8;i++){
      for(int j=0;j<8;j++){
	cout<<t[i][j];
      }
      cout<<endl;
    }
  }

  return 0;
}

Measured memory_bytes: 1200
fn read_stdin() -> String {
    use std::io::Read;
    let mut input = String::new();
    std::io::stdin().read_to_string(&mut input).unwrap();
    input
}

fn scan<'a, I: Iterator<Item = &'a str>, T: std::str::FromStr>(tokens: &mut I) -> T {
    tokens.next().unwrap().parse().ok().unwrap()
}

fn main() {
    let input = read_stdin();
    let tokens = &mut input.split_whitespace();
    let n: usize = scan(tokens);
    let mut sns = Sns::new(n);
    let m: usize = scan(tokens);
    let k: usize = scan(tokens);
    for _ in 0..m {
        let a: usize = scan(tokens);
        let b: usize = scan(tokens);
        sns.add_friend(a - 1, b - 1);
    }
    for _ in 0..k {
        let c: usize = scan(tokens);
        let d: usize = scan(tokens);
        sns.add_block(c - 1, d - 1);
    }
    sns.solve();
}

struct Sns {
    n: usize,
    friends: Vec<Vec<usize>>,
    blocks: Vec<Vec<usize>>,
    visited: Vec<bool>,
    root: Vec<usize>,
    count: Vec<usize>,
}

impl Sns {
    fn new(n: usize) -> Sns {
        Sns {
            n: n,
            friends: vec![Vec::new(); n],
            blocks: vec![Vec::new(); n],
            visited: vec![false; n],
            root: vec![0; n],
            count: vec![0; n],
        }
    }
    fn add_friend(&mut self, i: usize, j: usize) {
        self.friends[i].push(j);
        self.friends[j].push(i);
    }
    fn add_block(&mut self, i: usize, j: usize) {
        self.blocks[i].push(j);
        self.blocks[j].push(i);
    }
    fn solve(&mut self) {
        for i in 0..self.n {
            self.dfs(i, i);
        }
        for i in 0..self.n {
            let r = self.root[i];
            let mut cnt = self.count[r] - self.friends[i].len() - 1;
            for &j in &self.blocks[i] {
                if self.root[j] == r {
                    cnt -= 1;
                }
            }
            if i != 0 {
                print!(" ");
            }
            print!("{}", cnt);
        }
        println!("");
    }
    fn dfs(&mut self, i: usize, r: usize) {
        if self.visited[i] {
            return;
        }
        self.visited[i] = true;
        self.root[i] = r;
        self.count[r] += 1;
        for j in self.friends[i].clone() {
            self.dfs(j, r);
        }
    }
}


Measured memory_bytes: 27256
#include<stdio.h>

int main(void){

	int x=1,y=1,i=0;

	while(1){
		scanf("%d %d",&x,&y);
		if(x==0 && y==0){
			break;
		}
		else if(x>y){
			i=x;
			x=y;
			y=i;
		}
		printf("%d %d\n",x,y);
	}

	return 0;

}


Measured memory_bytes: 2028
unittest
{
	assert( [ "12 18" ].parse.expand.solve == 3 );
	assert( [ "420 660" ].parse.expand.solve == 4 );
	assert( [ "1 2019" ].parse.expand.solve == 1 );
	
	assert( [ "1000000000000 1000000000000" ].parse.expand.solve == 3 );		// 追加ケース
	assert( [ "999999999999 999999999999" ].parse.expand.solve == 8 );		// 追加ケース
}



import std.algorithm;
import std.conv;
import std.range;
import std.stdio;
import std.typecons;

void main()
{
	stdin.byLineCopy.parse.expand.solve.writeln;
}

auto parse( Range )( Range input )
if( isInputRange!Range && is( ElementType!Range == string ) )
{
	auto ab = input.front.split.to!( long[] );
	return tuple( ab[ 0 ], ab[ 1 ] );
}

auto solve( long a, long b )
{
	// 公約数のうち、素数のものをカウント
	auto ps = ( ( cast( long ) min( a, b ) ^^ 0.5 ) + 1 ).primes;
	auto aps = a.primefactorize( ps ).uniq;
	auto bps = b.primefactorize( ps ).uniq;
	auto ans = 1L;
	while( !aps.empty && !bps.empty )
	{
		if( aps.front < bps.front )
		{
			aps.popFront;
		}
		else if( bps.front < aps.front )
		{
			bps.popFront;
		}
		else
		{
			ans++;
			aps.popFront;
			bps.popFront;
		}
	}
	return ans;
}

// 素数列
auto primes( long x )
{
	Appender!( long[] ) ps;
	if( x < 2 ) return ps.data;
	
	auto cs = new bool[]( x + 1 );
	ps ~= 2L;
	for( auto i = 3L; i * i < cs.length; i += 2 )
	{
		if( cs[ i ] ) continue;
		for( auto j = i; i * j < cs.length; j++ )
		{
			cs[ i * j ] = true;
		}
	}
	for( auto i = 3L; i < cs.length; i += 2 )
	{
		if( !cs[ i ] ) ps ~= i;
	}
	return ps.data;
}

// 素因数分解
auto primefactorize( long x, long[] ps )
{
	Appender!( long[] ) fs;
	if( x < 2 ) return fs.data;
	
	auto s = ( cast( long ) x ^^ 0.5 ) + 1;
	foreach( p; ps )
	{
		if( s < p ) break;
		while( x % p == 0 )
		{
			x /= p;
			fs ~= p;
		}
		if( x < 2 ) break;
	}
	if( 2 <= x ) fs ~= x;
	return fs.data;
}


Measured memory_bytes: 3836
#include <bits/stdc++.h>
using namespace std;
int main() {
    int N;
    cin >> N;
    vector<int> a(N);
    for(int i = 0; i < N; i++) cin >> a.at(i);
    sort(a.begin(), a.end());
    
    int now = 0;
    int cnt = 0;
    int ans = 0;
    for(int i = 0; i < N; i++) {
        if(a.at(i)!=now) {
            ans += (cnt >= now ? cnt - now : cnt);
            now = a.at(i);
            cnt = 1;
        }
        else cnt++;
    }
    ans += (cnt >= now ? cnt - now : cnt);
    cout << ans << endl;
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int i=0; i<(int)(n); ++i)
#define all(a) (a).begin(), (a).end()
#define rall(a) (a).rbegin(), (a).rend()
using ll = long long;
using vi = vector<int>;
using vl = vector<ll>;
using Graph = vector<vi>;  // vi <=> vl
using P = pair<int, int>;  // int <=> ll
const int MOD = 1e9+7;
const double EPS = 1e-9;

int main() {
  string s; cin >> s;
  int ans = 0;
  rep(i,s.size()-1) if (s[i] != s[i+1]) ++ans;
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
#define MOD 1000000007
#define INF 10000000000000009
//#define INF 9223372036854775807
typedef long long ll;
#define REP(i,n) for(int i=0;i<(n);++i)
#define OREP(i,n) for(int i=1;i<=(n);++i)
#define ORREP(i,n) for(int i=(n);i>=1;--i)
#define ZREP(i,n) for(int i=1;i<(n);++i)
#define RREP(i,n) for(int i=(n)-1;i>=0;--i)
#define rollcall cout<<"I'm Sucu."<<endl;
#define YES(s) s?cout << "YES" << endl:cout << "NO" << endl
#define Yes(s) s?cout << "Yes" << endl:cout << "No" << endl
#define Taka(s) s?cout << "Takahashi" << endl:cout << "Aoki" << endl
#define out(s,t,u) s?cout << t << endl:cout << u << endl
#define int ll
#define Endl endl


signed main(){
    int N;
    int a[25700]={},b[25700]={},p[25700]={};
    cin >> N;
    OREP(i,N){cin >> p[i];}
    OREP(i,N){
        a[p[i]]+=i;
        b[p[i]]+=i;
    }
    OREP(i,N){
        if(i==1)continue;
        a[i]+=a[i-1];
        b[N-i+1]+=b[N-i+2];
    }
    OREP(i,N){
        if(i!=0)cout << " ";
        cout << a[i];
    }cout << endl;
    OREP(i,N){
        if(i!=0)cout << " ";
        cout << b[i];
    }cout << endl;
    return 0;
}   

Measured memory_bytes: 1152
#include<bits/stdc++.h>
using namespace std;
int x,n,n1,n2,n3,a,b;
int main() {
    cin>>n>>a>>b;
    for(int i=1;i<=n;++i) {
        cin>>x;
        if(x<=a) n1++;
        else if(x>a && x<=b) n2++;
        else n3++;
    }
    cout<<min(n1,min(n2,n3));
}

Measured memory_bytes: 256
#include<stdio.h>
#include<string.h>
int main()
{
	char s[200001];
	int i,l,a,z;
	gets(s);
	l = strlen(s);
	for(i=0; ; i++){
		if(s[i]=='A'){
			a=i;
			break;
		}
	}
	for(i=l-1; ; i--){
		if(s[i]=='Z'){
			z=i;
			break;
		}
	}
	printf("%d", (z-a)+1);
	return 0;
}


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

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

long long MOD = 1000000000 + 7;

int main(){
  cout << setprecision(10);
  int N; cin >> N;
  N %= 1000;
  cout << (N==0 ? 0 : 1000 - N ) << endl;

}


Measured memory_bytes: 3632
#include <iostream>

using namespace std;

int main(int argc, char *argv[])
{
	int N, K, ans = 0;
	cin >> N >> K;
	for (int i = 0; i < N; i++) {
		int h;
		cin >> h;
		if (h >= K) {
			ans++;
		}
	}

	cout << ans << endl;

	return 0;
}

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

int main() {
  int n; cin >> n;
  while(n--) {
    double xa,ya,ra,xb,yb,rb;
    cin >> xa >> ya >> ra >> xb >> yb >> rb;
    double dist = sqrt((xb - xa)*(xb - xa) + (yb - ya)*(yb - ya));
    int ans;
    if(ra > dist + rb)
      ans = 2;
    else if(rb > dist + ra)
      ans = -2;
    else if(ra + rb < dist)
      ans = 0;
    else
      ans = 1;
    cout << ans << endl;
  }
}

Measured memory_bytes: 1232
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <cmath>
#include <cctype>
#include <string>

using namespace std;

inline int gi()
{
    int f = 1, x = 0;
    char c = getchar();
    while (c < '0' || c > '9')
    {
        if (c == '-') f = -1;
        c = getchar();
    }
    while (c >= '0' && c <= '9')
    {
        x = x * 10 + c - '0';
        c = getchar();
    }
    return f * x;
}

string s;
int n, k;

int main()
{
	n = gi(), k = gi();
	cin >> s;
	s[k - 1] = s[k - 1] - ('A' - 'a');
	cout << s;
	return 0;
}

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

int32_t main() {
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    int t = 1;
    // cin >> t;
    while (t--) {
        int n;
        cin >> n;
        vector<int> l(n);
        for (int i = 0; i < n; i++) cin >> l[i];
        // sort(l.begin(), l.end());
        int ans = 0;
        for (int i = 0; i < n; i++) {
            for (int j = i + 1; j < n; j++) {
                if (l[i] == l[j]) continue;
                for (int k = j + 1; k < n; k++) {
                    if (l[i] == l[k] || l[j] == l[k]) continue;
                    vector<int> v = {l[i], l[j], l[k]};
                    sort(v.begin(), v.end());
                    if (v[0] + v[1] > v[2]) ans++;
                }
            }
        }
        cout << ans;
    }
    return 0;
}


Measured memory_bytes: 3636
#include <iostream>
#include <vector>
#include <algorithm>
#include <string.h>
#include <iomanip>
#include <math.h>
#include <string>
#include <queue>
#include <map>
#include <set>
#include <functional>

using namespace std;

typedef long long int ll;
typedef std::pair<int, int> pii;
typedef std::pair<ll, int> pli;
typedef std::pair<ll, ll> pll;

#define FOR(i,n,m) for(ll i=(ll)(m);i<(ll)(n);++i)
#define REP(i,n) FOR(i,n,0)
#define IREP(i,n) for(ll i=(ll)(n);i>=0;--i)
#define OF64 std::setprecision(10)

const ll MOD = 1000000007;
const ll INF = (ll)1e15;

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

	cout << (K / 2)*(K / 2 + K % 2) << endl;
	return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<stdlib.h>
int main(){
    int a,b,c;
    int i;
    int r=0;
    scanf("%d%d%d",&a,&b,&c);
    for(i=a;i<=b;++i){
        if(c%i==0){
            r++;
        }
        
    }
    printf("%d\n",r);
    return 0;
}


Measured memory_bytes: 2108
if __name__ == '__main__':
    n, m = map(int, input().split())
    h = [int(i) for i in input().split()]

    list = [0]*n

    for i in range(m):
        a, b = map(int, input().split())
        if h[a-1] > h[b-1]:
           list[b-1] +=1
        elif h[a-1] < h[b-1]:
            list[a - 1] += 1
        else:
            list[a - 1] += 1
            list[b-1] +=1

    count =0
    for i in list:
        if i == 0:
            count+=1
    print(count)






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

#define rep(i,n) for (int i=0;i<(n);i++)
#define rep2(i,a,b) for (int i=(a);i<(b);i++)
#define rrep(i,n) for (int i=(n)-1;i>=0;i--)
#define rrep2(i,a,b) for (int i=(b)-1;i>=(a);i--)
#define all(a) (a).begin(),(a).end()

typedef long long ll;
typedef pair<int, int> P;
typedef vector<int> vi;
typedef vector<P> vp;
typedef vector<ll> vll;

const int INF = 99999999;
const int MAX_V = 1111;

struct edge { int to, cap, rev; };

vector<vector<edge>> G(MAX_V);
bool used[MAX_V];

void add_edge(int from, int to, int cap) {
    G[from].emplace_back((edge){to, cap, (int)G[to].size()});
    G[to].emplace_back((edge){from, 0, (int)G[from].size() - 1});
}

int dfs(int v, int t, int f) {
    if (v == t) return f;
    used[v] = true;
	for (auto& e : G[v]) {
        if (!used[e.to] && e.cap > 0) {
            int d = dfs(e.to, t, min(f, e.cap));
            if (d > 0) {
                e.cap -= d;
                G[e.to][e.rev].cap += d;
                return d;
            }
        }
    }
    return 0;
}

int max_flow(int s, int t) {
    int flow = 0;
    for(;;) {
        memset(used, 0, sizeof(used));
        int f = dfs(s, t, INF);
        if (f == 0) return flow;
        flow += f;
    }
}

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

signed main() {
    int M, N;
    while (~scanf("%d %d", &M, &N) && M) {
    	int V = M + N;
    	int s = V;
    	int t = s + 1;
    	rep(i, M) add_edge(s, i, 1);
    	rep(i, N) add_edge(i + M, t, 1);

        vector<int> b(M);
        rep(i, M) cin >> b[i];
        vector<int> r(N);
        rep(i, N) cin >> r[i];

        rep(i, M) {
            rep(j, N) {
                if (gcd(b[i], r[j]) > 1) {
                    add_edge(i, j + M, 1);
                }
            }
        }

    	cout << max_flow(s, t) << endl;
        G.clear();
        G.resize(MAX_V);
    }
}

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

int main(void)
{
  int n;
  cin >> n;
  string s;
  cin >> s;
  string abc = "ABC";
  int cnt = 0;
  int i = 0;
  while(1)
  {
    if(i > n)
    {
      break;
    }
    string d;
    d = s.substr(i, 3);
    if(d == abc)
    {
      cnt++;
    }
    i++;
  }
  cout << cnt << endl;
}

Measured memory_bytes: 256
require 'set'; require 'prime'
INF=Float::INFINITY; MOD=10**9+7
ai, ao, _, aj, al, _, _ = gets.chomp.split.map(&:to_i)

ans = 0
ans += ai/2*2 + aj/2*2 + al/2*2
ans = [ans, (ai-1)/2*2 + (aj-1)/2*2 + (al-1)/2*2 + 3].max if ai > 0 && aj > 0 && al > 0
ans += ao
puts ans

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

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

struct BIT{
  int d[500005];
  int n;
 void init(int _n){
   n = _n;
   memset(d,0,sizeof(d));
 }
  // i?????????x???????????? ???1????????°?????????
  void add(int i, int x){
    while(i <= n){
      d[i] += x;
      i += i & -i;
    }
  }

  // a1??????ai?????§???????¨?????±???????
  int sum(int i){
    int s = 0;
    while(i > 0){
      s += d[i];
      i -= i & -i;
    }
    return s;
  }
};

ll N,P,Q;
BIT bit;
Pa C[500005];
int main(){
  cin >> N >> P >> Q;
  ll sum = 0;
  for(int i=0;i<N;i++){
    ll c; cin >> c; sum+=c;
    C[i] = Pa( (ll)(Q-i)*P - c , i );
  }
  sort( C, C + N );
  bit.init(N);
  ll res = sum;
  for(int i=N-1;i>-1;i--){
    ll p = N-1-i;
    // cout << C[i].second << endl;
    //cout << sum << " " << C[i].first << " " << p << " = " << sum + C[i].first + 2LL*p*P << endl;
    res = max( res, sum + C[i].first + 2LL*p*P );
    sum = sum + C[i].first + 2LL * p * P;
    bit.add( C[i].second+1, 1 );
  }
  cout << res << endl;
}

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

using namespace std;

#define REP1(i,n) for(int i=1, i##_len=(n); i<i##_len; ++i)
#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define pow(x) x*x
#define ll long long
static const ll MAX = 1000000;
static const ll INFTY = 1e12;
static const ll MOD = 1000000007;

template < typename T > inline string toString( const T &a ) { ostringstream oss; oss << a; return oss.str(); };

struct edge {
    ll to, cost;
};

using Graph = vector<vector<int>>;
using _Graph = vector<vector<edge>>;


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

// 深さ優先探索
vector<bool> seen;
vector<int> colors;

int H, W, N;
int sx, sy, gx, gy; 
vector<vector<char>> field;
vector<vector<int>> dist;
//vector<pair<int, int>> gx, gy;
deque<pair<int, int>> que;

typedef vector<vector<int> > Matrix;

const ll INF = 1e18;

int main() {

   int N; cin >> N;
   N = N % 10;
   if(N==3){
       cout << "bon";
   }else if(N==0 || N == 1 || N == 6 || N == 8){
       cout << "pon";
   }else {
       cout << "hon";
   }

}
/*
みんな、くるくるぱーにな〜れ
　∧＿∧　
（｡･ω･｡)つ━☆・*。
⊂　　 ノ 　　　・゜+.
　しーＪ　　　°。+ *´¨)
　　　　　　　　　.· ´¸.·*´¨) ¸.·*¨)
　　　　　　　　　　(¸.·´ (¸.·'* ☆
*/



Measured memory_bytes: 3632
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define INF 2e9
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;
typedef vector<ll> vll;
typedef vector<vll> vvll;


int main()
{
    ll x, a, b;
    cin >> x >> a >> b;
    string ans;
    if (b - a <= 0) {
        ans = "delicious";
    } else if (b - a > 0 && x >= b - a) {
        ans = "safe";
    } else {
        ans = "dangerous";
    }
    cout << ans << endl;
    return 0;
}

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

using namespace std;

int n, x, y;;
int minx = 1e9, maxx = -1e9, miny = 1e9, maxy = -1e9;


int main(){
	scanf("%d", &n);
	while(n--){
		scanf("%d%d", &x, &y);
		minx = min(minx, x + y);
		maxx = max(maxx, x + y);
		miny = min(miny, x - y);
		maxy = max(maxy, x - y);
	}
	printf("%d", max(maxx - minx, maxy - miny));
	
} 

Measured memory_bytes: 3812
#include <iostream>
#include <vector>

using namespace std;
typedef long long ll;

ll by_bit_brute_force(const string &s)
{
    int n = s.size()-1;
    ll ans = 0, k = 1, sum;
    for(int i=0; i < (1 << n); ++i){
        sum = 0;
        k = 1;
        for(int j=0;j<n;++j){
            if((i >> j) & 1){
                ans += (sum + (s[n-j] - '0') * k);
                k = 1;
                sum = 0;
            }
            else{
                sum += (s[n-j] - '0') * k;
                k *= 10;
            }
        }
        ans += (sum + (s[0] - '0') * k);
    }
    return ans;
}

int main()
{
    string s;
    cin >> s;
    cout << by_bit_brute_force(s) << endl;
}


Measured memory_bytes: 256
#!/usr/bin/env python3
import sys
input = sys.stdin.buffer.readline

def inn(func=int):
    return list(map(func,input().split()))

def ins():
    return input().split()

n,a,b = inn()
mon = int(n/(a+b))
las = n%(a+b)
print(mon*a+min(las,a))

Measured memory_bytes: 3064
#include <cstdio>
#include <cmath>
#include <string>

using namespace std;

int main() {
	
	char in;
	
	scanf("%c", &in);
	
	switch(in){
		case 'A':
			printf("T\n");
			break;
		case 'C':
			printf("G\n");
			break;
		case 'G':
			printf("C\n");
			break;
		default:
			printf("A\n");
			break;
	}
	
	return 0;
	
}


Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define rep(i, n) for (ll i = 0; i < n; i++)
#define FOR(i, a, b) for (ll i = a; i < b; i++)
#define len(v) ll(v.size())
#define fi first
#define se second

template <class T>
void cout_vec(const vector<T> &vec){
  for(auto itr:vec) cout<<itr<<' ';
  cout<<endl;
}

typedef pair<ll,ll> P;
const ll mod=1e9+7;
const ll inf=1e15;

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  int n;
  cin>>n;
  vector<P> a(n);
  rep(i,n){
    cin>>a[i].fi;
    a[i].se=i;
  }
  sort(begin(a),end(a));
  rep(i,n){
    cout<<a[i].se+1<<endl;
  }
}

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

using namespace std;

int explore(int root, const vector< vector<int> >& graph, vector<int>& component_id, int color) {
    component_id[root] = color;
    int tam = 1; // Só o vértice sozinho... 
    for(const auto& viz : graph[root]) {
        if(component_id[viz] == -1) {
            tam += explore(viz, graph, component_id, color);
        }
    }
    return tam;
}


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

    int n, m;
    cin >> n >> m;
    vector< vector<int> > graph(n);

    for(int i = 0; i < m; ++i) {
        int a, b;
        cin >> a >> b;
        --a; --b;
        graph[a].push_back(b);
        graph[b].push_back(a);
    }

    vector<int> component_id(n, -1);
    int cor_atual = 0;
    int maior_tamanho_de_componente = 0;
    
    for(int i = 0; i < n; ++i) {
        if(component_id[i] == -1) {
            int T = explore(i, graph, component_id, cor_atual);
            maior_tamanho_de_componente = max(maior_tamanho_de_componente, T); 
            cor_atual++;
        }
    }
    
    cout << maior_tamanho_de_componente << endl;
    return 0;
}


Measured memory_bytes: 27324
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<ll> vec;
typedef vector<vec> mat;
typedef pair<ll,ll> pll;
const ll mod=1e9+7;
//const ll mod=998244353;
const ll inf=5e18;

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

int main() {
  ll n,x;
  cin >> n >> x;
  vec y(n);
  ll mi=x;
  for(ll i=0;i<n;i++) {
    cin >> y[i];
    y[i]-=x;
    y[i]=abs(y[i]);
  }
  ll ans=-1;
  for(ll i=0;i<n;i++) {
    if(y[i]==0) continue;
    if(ans<0) ans=y[i];
    else ans=gcd(y[i],ans);
  }
  ans=max(ans,0LL);
  cout << ans << endl;
}

Measured memory_bytes: 1024
N, M, C = map(int,input().split())
ans = 0
B = list(map(int,input().split()))
for i in range(N):
  A = list(map(int,input().split()))
  sum = C
  for j in range(M):
    sum += A[j] * B[j]
  if sum > 0:
    ans += 1
print(ans)

Measured memory_bytes: 3060
using System;


class Program
{
    static void Main(string[] args)
    {
        string S = Console.ReadLine();
        string T = Console.ReadLine();
        char[] sList = S.ToCharArray();
        char[] tList = T.ToCharArray();
        Array.Reverse(sList);
        Array.Reverse(tList);
        bool isFinish = false;
        for(int i = 0; i < sList.Length; i++)
        {
            int j = 0;
            while(tList.Length > j)
            {
                try
                {
                    if(sList[i+j] != tList[j] && sList[i+j] != Convert.ToChar("?"))
                    {
                        break;
                    }
                }
                catch (IndexOutOfRangeException)
                {
                    break;
                }
                j++;
                if(j == tList.Length)
                {
                    for(int k = 0; k < tList.Length; k++)
                    {
                        sList[i + k] = tList[k];
                    }
                    isFinish = true;
                    break;
                }
            }
            if (isFinish)
            {
                Array.Reverse(sList);
                string result = new string(sList).Replace("?", "a");
                Console.WriteLine(result);
                break;
            }
        }
        if (!isFinish)
        {
            Console.WriteLine("UNRESTORABLE");
        }

    }
}



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

using namespace std;

typedef long long ll;

typedef int _loop_int;
#define REP(i,n) for(_loop_int i=0;i<(_loop_int)(n);++i)
#define FOR(i,a,b) for(_loop_int i=(_loop_int)(a);i<(_loop_int)(b);++i)
#define FORR(i,a,b) for(_loop_int i=(_loop_int)(b)-1;i>=(_loop_int)(a);--i)

#define DEBUG(x) cout<<#x<<": "<<x<<endl
#define DEBUG_VEC(v) cout<<#v<<":";REP(i,v.size())cout<<" "<<v[i];cout<<endl
#define ALL(a) (a).begin(),(a).end()

#define CHMIN(a,b) a=min((a),(b))
#define CHMAX(a,b) a=max((a),(b))

// mod
const ll MOD = 1000000007ll;

int n;
ll a[125252];
ll mi[125252];

ll sum[125252];

int main(){
  scanf("%d",&n);
  REP(i,n)scanf("%lld",a+i);

  mi[1] = 1;
  FOR(i,2,n+1)mi[i] = MOD-mi[MOD%i]*(MOD/i)%MOD;
  
  REP(i,n+1)sum[i+1] = (sum[i] + mi[i+1]) % MOD;

  ll factn = 1;
  FOR(i,1,n+1)factn = factn*i%MOD;
  
  ll ans = 0;
  REP(i,n){
    ans += (sum[i+1] + sum[n-i] - 1) % MOD * factn % MOD * a[i] % MOD;
    ans %= MOD;
  }

  printf("%lld\n",ans);
  return 0;
}


Measured memory_bytes: 2560
<?php
$N = intval(trim(fgets(STDIN)));
$A = explode(' ', trim(fgets(STDIN)));
$c1=$c2=$c3=0;
foreach($A as $a){
    if($a == '1')$c1++;
    if($a == '2')$c2++;
    if($a == '3')$c3++;
}
$dp = array_fill(0, $N+1, array_fill(0,$N+1, array_fill(0,$N+1,0)));
for($k = 0; $k <= $c3; ++$k){
    $dpk = &$dp[$k];
    if($k>0)$dpkm = $dp[$k-1];
    for($j = 0, $J = $c2 + $c3 - $k; $j <= $J; ++$j){
        $dpkj = &$dp[$k][$j];
        for($i = 0, $I = $c1+$c2+$c3-$k-$j; $i <= $I ; ++$i){
            if($i==0&&$j==0&&$k==0)continue;
            $tmp = $N;
            if($i>0)$tmp+=$i*$dpkj[$i-1];
            if($j>0)$tmp+=$j*$dpk[$j-1][$i+1];
            if($k>0)$tmp+=$k*$dpkm[$j+1][$i];
            $dpkj[$i] = $tmp/($i+$j+$k);
        }
    }
}
echo $dp[$c3][$c2][$c1];


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

#define NDEBUG
#include <cassert>


typedef long long ll;
typedef long double Double;
typedef unsigned long long ull;
typedef pair<int,int> ii;
typedef pair<ll,ll> llll;
typedef pair<double,double> dd;

typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<ii> vii;
typedef vector<vector<ii>> vvii;
typedef vector<ll> vll;
typedef vector<vector<ll>> vvll;
typedef vector<llll> vllll;
typedef vector<bool> vb;
typedef vector<string> vs;
typedef vector<double> vd;
typedef vector<long double> vD;

#define sz(a)  int((a).size())
#define pb  push_back
#define eb  emplace_back
#define FOR(var,from,to) for(int var=(from);var<=(to);++var)
#define rep(var,n)  for(int var=0;var<(n);++var)
#define rep1(var,n)  for(int var=1;var<=(n);++var)
#define repC2(vari,varj,n)  for(int vari=0;vari<(n)-1;++vari)for(int varj=vari+1;varj<(n);++varj)
#define repC3(vari,varj,vark,n)  for(int vari=0;vari<(n)-2;++vari)for(int varj=vari+1;varj<(n)-1;++varj)for(int vark=varj+1;vark<(n);++vark)
#define ALL(c)  (c).begin(),(c).end()
#define RALL(c)  (c).rbegin(),(c).rend()
#define tr(i,c)  for(auto i=(c).begin(); i!=(c).end(); ++i)
#define found(s,e)  ((s).find(e)!=(s).end())
#define mset(arr,val)  memset(arr,val,sizeof(arr))
#define mid(x,y) ((x)+((y)-(x))/2)
#define IN(x,a,b) ((a)<=(x)&&(x)<=(b))
#define cons make_pair
#define clamp(v,lo,hi) min(max(v,lo),hi)

template<typename T1, typename T2> inline void amin(T1 & a, T2 const & b) { if (a>b) a=b; }
template<typename T1, typename T2> inline void amax(T1 & a, T2 const & b) { if (a<b) a=b; }

inline int MD(int x0, int y0, int x1, int y1) {
    return max(x0-x1,x1-x0) + max(y0-y1,y1-y0);
}

void solve(int N, vi& x, vi& y, vi& h) {
    for (int cx=0; cx<=100; ++cx) {
        for (int cy=0; cy<=100; ++cy) {
            vi d(N), e(N);
            rep(i,N) {
                d[i] = MD(cx,cy, x[i],y[i]);
                e[i] = h[i] + d[i];
            }
            int ht = *min_element(ALL(e));
            if (ht == 0) continue;
            bool ok = true;
            rep(i,N) {
                int expected = max(0, ht - d[i]);
                if (h[i] != expected) { ok = false; break; }
            } 
            if (ok) {
                printf("%d %d %d\n", cx, cy, ht);
                return;
            }
            
        }
    }
}

int main() {
    int N; cin >> N;
    vi x(N), y(N), h(N); rep(i,N) cin >> x[i] >> y[i] >> h[i];
    solve(N,x,y,h);
    return 0;
}



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

using namespace std;

int main(int argc, const char *argv[])
{
  string s, t, u;
  int a, b;
  cin >> s >> t >> a >> b >> u;

  if (u == s) {
    cout << a - 1 << " " << b << "\n";
  } else {
    cout << a << " " << b - 1 << "\n";
  }
  return 0;
}

Measured memory_bytes: 256
#define HAVE_STRUCT_TIMESPEC
#include<bits/stdc++.h>
using namespace std;
long long pre[200007];
int main(){
    ios::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    long long n,d,a;
    cin>>n>>d>>a;
    vector<pair<long long,long long> >v;
    for(int i=1;i<=n;++i){
        long long x,y;
        cin>>x>>y;
        long long z=(y-1)/a+1;
        v.push_back({x,z});
    }
    sort(v.begin(),v.end());
    long long ans=0;
    long long sum=0;
    int r=1;//打不到的最近范围
    for(int i=0;i<n;++i){
        while(r<n&&v[r].first<=v[i].first+2*d)
            ++r;
        sum-=pre[i];//sum为当前位置已经预先承受的伤害总量
        v[i].second-=sum;
        if(v[i].second<=0)
            continue;
        sum+=v[i].second;//累计伤害
        pre[r]+=v[i].second;//r位置以前承受的伤害总量
        ans+=v[i].second;
    }
    cout<<ans;
    return 0;
}


Measured memory_bytes: 6512
#include "bits/stdc++.h"
using namespace std;

//template
typedef long long int ll;
#define rep(i,n) for(ll i=0;i<n;i++)
#define rep1(i,n) for(ll i=1;i<n;i++)
#define repr(i,n) for(ll i=n;i>0;i--)
#define all(v) v.begin(),v.end()
#define in cin>>
#define out cout<<
#define en <<endl
const ll INF = 10000000000000;

int main()
{
	ll n, a, b;
	in n >> a >> b;
	ll x = a + b;
	ll ans = 0;
	ans += a * (n / x);
	if (n % x > a)
		ans += a;
	else
		ans += n % x;
	out ans en;
}


Measured memory_bytes: 256
n,k = map(int,input().split())
h = list(map(int,input().split()))
dp = [0] * n
t = []
 
for i in range(1,n):
    for l in range(1,k+1):
        if i - l >= 0:
            t.append(abs(h[i] - h[i-l]) + dp[i-l])
        else:
            break
    dp[i] = min(t)
    t.clear()
 
print(dp[-1])

Measured memory_bytes: 84384
#include <iostream>
using namespace std;
int main() {
    string s;
    cin>>s;
    if (s=="SUN") cout<<'7';
     if (s=="MON") cout<<'6';
      if (s=="TUE") cout<<'5';
       if (s=="WED") cout<<'4';
        if (s=="THU") cout<<'3';
         if (s=="FRI") cout<<'2';
          if (s=="SAT") cout<<'1';

}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
using namespace std;
long long rui(int n) {
	if (n == 0) {
		return 1;
	}
	else {
		long long x = rui(n - 1);
		return 2 * x;
	}
}
int main() {
	int a, b,c,d,e;
	cin >> a >> b>>c>>d>>e;
	if (a < 0) {
		cout << (-a)*c + d +b*e<<endl;
	}
	else {
		cout << (b - a)*e << endl;
	}
}


Measured memory_bytes: 3096
#include <iostream>
#include <cstdio>
#include <deque>
#define int long long
using namespace std;
bool vis[100005];
signed main() {
	int n; cin >> n;
	deque<pair<int, int> > q; q.push_front(make_pair(1, 1));
	while (!q.empty()) {
		pair<int, int> p = q.front(); q.pop_front();
		if (vis[p.first]) continue; vis[p.first] = 1;
		if (!p.first) { cout << p.second << endl; return 0; }
		q.push_front(make_pair((p.first * 10) % n, p.second));
		q.push_back(make_pair((p.first + 1) % n, p.second + 1));
	}
	return 0;
}

Measured memory_bytes: 2048
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <algorithm>
#include <string>
#include <cmath>
#include <cstdio>
#include <iomanip>
#include <fstream>
#include <cassert>
#include <cstring>
#include <numeric>
#include <ctime>
#include <complex>
#include <bitset>
#include <random>

using namespace std;

typedef long long ll;
typedef long double ld;

#define int ll
#define double ld
#define loop(i, n) for(int i = 0; i < (int)n; ++i)
#define loop1(i, n) for(int i = 1; i <= (int)n; ++i)
#define F first
#define S second
#define pb push_back
#define pi pair <int, int>
#define all(x) begin(x), end(x)
#define ti tuple <int, int, int>
#define Point Vect
#define no {cout << "0\n"; return;}
#define mkp make_pair

const int N = 1e5 + 7;

vector <int> g[N];
int h[N];
bitset <N> used;

void solve() {
    int n, m;
    cin >> n >> m;
    loop(i, n)
        cin >> h[i];
    loop(i, m) {
        int u, v;
        cin >> u >> v;
        --u; --v;
        g[u].pb(v);
        g[v].pb(u);
    }
    int ans = 0;
    loop(v, n) {
        for (int u : g[v])
            if (h[u] >= h[v])
                used[v] = 1;
        if (!used[v])
            ++ans;
    }
    cout << ans;
}

signed main() {
    srand(time(NULL));
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    //int t; cin >> t; loop(i, t)
    solve();
    return 0;
}

Measured memory_bytes: 10260
#include <stdio.h>
#define N 10
#define MAX(a,b) ((a>b)?(a):(b))

void point(int,int);

	int k[N][N];
	int nonure=100;
	int maxd=0;
	
int main(void){
	int i,j;
	int x,y,s;
	for(i=0;i<N;i++){
		for(j=0;j<N;j++){
			k[i][j]=0;
		}
	}
	
	while(scanf("%d,%d,%d",&x,&y,&s)!=EOF){
		switch(s){
			case 1:	// ?°???????
			point(x,y);
			point(x+1,y);
			point(x-1,y);
			point(x,y+1);
			point(x,y-1);
			break;
			case 2:
			point(x,y);
			point(x+1,y);
			point(x-1,y);
			point(x,y+1);
			point(x,y-1);
			point(x+1,y+1);
			point(x+1,y-1);
			point(x-1,y+1);
			point(x-1,y-1);
			break;
			case 3:
			point(x,y);
			point(x+1,y);
			point(x-1,y);
			point(x,y+1);
			point(x,y-1);
			point(x+1,y+1);
			point(x+1,y-1);
			point(x-1,y+1);
			point(x-1,y-1);
			point(x,y-2);
			point(x,y+2);
			point(x-2,y);
			point(x+2,y);
			break;
		}
	}
	printf("%d\n%d\n",nonure,maxd);
	return 0;
}

void point(int a,int b){
	if(a>=N) return;
	if(b>=N) return;
	if(a<0) return;
	if(b<0) return;
	
	k[a][b]++;
	if(k[a][b]==1) nonure--;
	maxd=MAX(maxd,k[a][b]);
}

Measured memory_bytes: 600
#include <stdio.h>

#define MAX 200001
 
int main()
{
  int n, i, cnt1 = 0, cnt2 = 0, sum[MAX][2], ans = MAX, x;
  char s[MAX];

  scanf("%d%s", &n, s);

  for (i = 0; i < n; i++) {
    if (s[i] == '.') {
      cnt1++;
    } else {
      cnt2++;
    }
    sum[i][0] = cnt1;
    sum[i][1] = cnt2;
  }

  for (i = 0; i < n - 1; i++) {
    if (s[i] == '.' && s[i + 1] == '#') {
      x = sum[n - 1][0] - sum[i][0] + sum[i][1];
      if (x < ans) {
	ans = x;
      }
    }
  }

  if(sum[n - 1][0] < ans || sum[n - 1][1] < ans) {
    printf("%d\n", (sum[n - 1][0] < sum[n - 1][1] ? sum[n - 1][0] : sum[n - 1][1]));
  } else {
     printf("%d\n", ans);
  }
 
  return 0;
}

Measured memory_bytes: 1920
#include <algorithm>
#include <iostream>
#include <numeric>
#include <vector>
using namespace std;
int main()
{
    int n, k;
    cin >> n >> k;
    vector<long>h(n);
    for(auto &in : h){
        cin >> in;
    }
    sort(h.begin(), h.end());
    vector<long> acdiff(n);
    acdiff[0] = 0;
    for(auto i = 1; i < n; ++i){
        acdiff[i] = h[i] - h[i-1] + acdiff[i - 1];
    }
    long mindiff = 1e9; 
    for(auto i = 0; i < n - k + 1; ++i){
        mindiff = min(mindiff, acdiff[i + k - 1] - acdiff[i]);
    }
    cout << mindiff;
    return 0;
}


Measured memory_bytes: 1792
extern crate core;
 
use std::io::{self, Read};
use std::collections::HashMap;
 
fn main() {
    let mut input = String::new();
    io::stdin().read_to_string(&mut input).unwrap();
    let output = run(input);
    println!("{}", output);
}
 
fn run(input: String) -> String {
    let vec: Vec<i64> = input
        .split("\n")
        .nth(1)
        .unwrap()
        .split_whitespace()
        .map(|x| x.parse::<i64>().unwrap())
        .collect();
 
    let mut map: HashMap<i64, i64> = HashMap::new();
    for x in vec {
        let insert = match map.get(&x) {
            Option::Some(y) => y + 1,
            Option::None => 1,
        };
        map.insert(x, insert);
    }
 
    map.iter()
        .map(|(&k, &v)| {
            if k == v {
                0
            } else if k < v {
                v - k
            } else {
                v
            }
        })
        .fold(0, |sum, i| sum + i)
        .to_string()
}

Measured memory_bytes: 14588
import heapq
N, K = map(int, input().split())
V = list(map(int, input().split()))
ans = 0
for k in range(min(K+1, N+1)):
    for i in range(k+1):
        tmp = 0
        tmp2 = []
        heapq.heapify(tmp2)

        for j in range(k-i):
            tmp += V[j]
            if V[j] < 0:
                heapq.heappush(tmp2, V[j])
        for j in range(i):
            tmp += V[N-1-j]
            if V[N-1-j] < 0:

                heapq.heappush(tmp2, V[N-1-j])

        for j in range(min(k, K-k)):
            if len(tmp2) == 0:
                break
            tmp -= heapq.heappop(tmp2)
        ans = max(tmp, ans)


print(ans)


Measured memory_bytes: 3188