akhauriyash/Code-Regression huggingface dataset:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace ConsoleApplication1
{
    class Program
    {
        static readonly double EPS = 1E-10;

        static void Main(string[] args)
        {
            double[] input;

            input = Array.ConvertAll(Console.ReadLine().Split(' '), double.Parse);
            Point3D uaz = new Point3D(input[0], input[1], input[2]);

            input = Array.ConvertAll(Console.ReadLine().Split(' '), double.Parse);
            Point3D enemy = new Point3D(input[0], input[1], input[2]);

            Point3D[] barrier = new Point3D[3];

            for (int i = 0; i < 3; i++)
            {
                input = Array.ConvertAll(Console.ReadLine().Split(' '), double.Parse);
                barrier[i] = new Point3D(input[0], input[1], input[2]);
            }

            Point3D d = (barrier[1] - barrier[0]).Cross(barrier[2] - barrier[0]);

            Point3D ub = uaz - barrier[0];
            Point3D eb = enemy - barrier[0];

            if (d.Dot(ub) * d.Dot(eb) > 0)
            {
                Console.WriteLine("HIT");
            }
            else
            {
                Point3D v = uaz + (enemy - uaz) * Math.Abs(d.Dot(ub)) / (Math.Abs(d.Dot(ub)) + Math.Abs(d.Dot(eb)));

                if ((barrier[1] - barrier[0]).Cross(v - barrier[1]).Dot((barrier[2] - barrier[1]).Cross(v - barrier[2])) > -EPS &&
                    (barrier[1] - barrier[0]).Cross(v - barrier[1]).Dot((barrier[0] - barrier[2]).Cross(v - barrier[0])) > -EPS)
                {
                    Console.WriteLine("MISS");
                }
                else
                {
                    Console.WriteLine("HIT");
                }
            }
        }
    }

    struct Point3D
    {
        internal double x, y, z;

        public Point3D(double x, double y, double z)
        {
            this.x = x;
            this.y = y;
            this.z = z;
        }

        public Point3D Cross(Point3D other)
        {
            Point3D ret;
            ret.x = y * other.z - z * other.y;
            ret.y = z * other.x - x * other.z;
            ret.z = x * other.y - y * other.x;
            return ret;
        }

        public double Dot(Point3D other)
        {
            return x * other.x + y * other.y + z * other.z;
        }

        public static Point3D operator +(Point3D a, Point3D b)
        {
            return new Point3D(a.x + b.x, a.y + b.y, a.z + b.z);
        }

        public static Point3D operator -(Point3D a, Point3D b)
        {
            return new Point3D(a.x - b.x, a.y - b.y, a.z - b.z);
        }

        public static Point3D operator *(Point3D p, double m)
        {
            return new Point3D(p.x * m, p.y * m, p.z * m);
        }

        public static Point3D operator /(Point3D p, double m)
        {
            return new Point3D(p.x / m, p.y / m, p.z / m);
        }
    }
}

Measured memory_bytes: 9344
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
#define oo 666666666

ll n,m;
vector<int>g[100001];
vector<ll>pf[100001];
vector<ll>sf[100001];
ll UP[100001];
ll DOWN[100001];

void dfs(int c, int p = 0)
{
    DOWN[c]=1;

    for(auto&u:g[c])
        if(u!=p)
    {
        dfs(u,c);
        DOWN[c] = (DOWN[c] * (DOWN[u]+1)) % m;
    }
}

void dfs2(int c, int p=0, ll up = 1)
{
    UP[c]=up;

    for(int i=0; i<g[c].size(); i++)
        if(g[c][i]==p)
    {
        swap(g[c][i],g[c].back());
        g[c].pop_back();
        break;
    }

    pf[c][0]=sf[c][g[c].size()]=1;

    for(int i=0; i<g[c].size(); i++)
        pf[c][i+1]=(pf[c][i]*(DOWN[g[c][i]]+1))%m;

    for(int i=g[c].size()-1; i>=0; i--)
        sf[c][i]=(sf[c][i+1]*(DOWN[g[c][i]]+1))%m;

    for(int i=0; i<g[c].size(); i++)
    {
        ll ways = (pf[c][i] * sf[c][i+1])%m;
        ways = (ways * up)%m;
        dfs2(g[c][i],c,(ways+1));
    }
}

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

    for(int i=1; i<n; i++)
    {
        int u,v;
        cin>>u>>v;
        g[u].push_back(v);
        g[v].push_back(u);
    }

    for(int i=1; i<=n; i++)
        pf[i].resize(g[i].size()+2),sf[i].resize(g[i].size()+2);

    dfs(1);
    dfs2(1);

    for(int i=1; i<=n; i++)
        {
            //cout<<i<<" "<<DOWN[i]<<" "<<UP[i]<<"\n";
            cout<<(DOWN[i]*UP[i])%m<<"\n";
        }
}


Measured memory_bytes: 27392
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
using namespace std;
#define int long long int
#define pb push_back
#define F first
#define S second
#define vi vector<int>
#define pi pair<int, int>
#define PI 3.14159265
#define all(x) x.begin(),x.end()
#define er(n) cout << "error " << n << endl;
#define pbds tree<int, null_type, less_equal<int>, rb_tree_tag, tree_order_statistics_node_update>
#define mod 1000000007

void Abhay() {
    ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif
}

int32_t main() {
    //Abhay();
    int n, k; cin >> n >> k;
    int a[n], dp[n];
    for (int i = 0 ; i < n ; i++) {
        cin >> a[i];
        dp[i] = INT_MAX;
    }
    dp[0] = 0;
    for (int i = 0 ; i < n - 1 ; i++) {
        for (int j = 1 ; j <= k && i + j < n ; j++) {
            dp[i + j] = min(dp[i + j], dp[i] + abs(a[i + j] - a[i]));
        }
    }
    cout << dp[n - 1] << endl;
    return 0;
}

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

int main(void){
	int N,A=0;
	bool judge=true;
	string s;
	cin>>N;
	while(N--)
	{
		cin>>s;
		if(s=="A")A++;
		else if(A)A--;
		else judge=false;
	}

	cout<<(judge && A==0 ? "YES" : "NO")<<endl;

	return 0;
}

Measured memory_bytes: 3128
import numpy

if __name__ == "__main__":
	hour_len, min_len, hours, minutes = map(int, input().strip().split(' '))
	angle_minute = 2 * numpy.pi * (minutes / 60)
	angle_hour = 2 * numpy.pi * (((hours * 60) + minutes) / 720)
	if angle_hour >= angle_minute:
		final_angle = angle_hour - angle_minute
	elif angle_minute > angle_hour:
		final_angle = angle_minute - angle_hour
	answer = (hour_len * hour_len) + (min_len * min_len) - (2 * min_len * hour_len * numpy.cos(final_angle))
	print(numpy.sqrt(answer))

Measured memory_bytes: 27216
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define repI(i, d, n) for (int i = (d); i < (n); ++i)
#define reps1(i, n) for (int i = 1; i < (n); ++i)
using namespace std;
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; }

using ll = long long;
using P = pair<int, int>;
using Pl = pair<ll, ll>;
using M = map<int, int>;
using Ml = map<ll, ll>;
ll const INF = 1ll<<61;
double pi = 3.141592653589793238;

int main() {
  ll a, b, c;
  cin >> a >> b >> c;
  set<ll> s;
  s.insert(a);
  s.insert(b);
  s.insert(c);
  cout << s.size() << endl;

  return 0;
}


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

using namespace std;
int main(){
    string s;
    cin >> s;
    int flag = 0;
    for(int i=0; s[i]!='\0'; i++){
       if(i%2){
           if(s[i]!='L' && s[i]!='U' && s[i]!='D') flag = 1;
       }
       else{
           if(s[i]!='R' && s[i]!='U' && s[i]!='D') flag = 1;
       }

    }
    if(flag==0)
    cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0;
}

Measured memory_bytes: 3620
#include<bits/stdc++.h>
#define int long long
using namespace std;
constexpr int mod=1e9+7;
int mypow(int x,int n){
    if(n==0)
        return 1;
    if(n%2==1)
        return mypow(x,n-1)*x%mod;
    int tmp=mypow(x,n/2);
    return tmp*tmp%mod;
}
signed main(){
    int n;
    cin>>n;
    cout<<(mypow(10,n)+mypow(8,n)-2*mypow(9,n)+2*mod)%mod<<endl;
}


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

int main(){
  int cnt = 0;
  int n;
  cin >> n;
  vector<int> a(n);
  vector<int> b(n);
  for(int i = 0; i < n; i++){
    cin >> a.at(i);
    cin >> b.at(i);
  }
  for(int i = 0; i < n; i++){
    if(a.at(i) == b.at(i)){
      cnt++;
    }else{
      cnt = 0;
    }
    if(cnt >= 3){
      cout << "Yes" << endl;
      return 0;
    }
  }
  cout << "No" << endl;
}

Measured memory_bytes: 3632
#include<iostream>
#include <algorithm>
#include <vector>
#include <string>

using namespace std;
int main(){
    int N;
   
    cin >> N;
    vector<int> A(N),B(N),C(N);
    for(int i = 0 ; i < N ; ++i){
        cin >> A[i];
    }
    for(int i = 0 ; i < N ; ++i){
        cin >> B[i];
    }
    for(int i = 0 ; i < N ; ++i){
        cin >> C[i];
    }
    sort(A.begin(), A.end());
    sort(B.begin(), B.end());
    sort(C.begin(), C.end());

    long long int cnt=0;
    for(int i = 0 ; i < N ; ++i){
        cnt += distance(A.begin(), lower_bound(A.begin(), A.end(),B[i])) * distance(upper_bound(C.begin(), C.end(),B[i]),C.end());
    }
    cout << cnt << endl;
    return 0;
}

Measured memory_bytes: 1408
#include <bits/stdc++.h>
#define sz(arr) (int)arr.size()

using namespace std;

int main() {
  vector<int> v(3);
  for (auto &e : v) cin >> e;
  sort(v.begin(), v.end());

  cout << v[0] + v[1] << endl;

  return 0;
}

Measured memory_bytes: 256
quit() = exit(0)
in_1() = parse(Int, readline())
in_a() = [parse(Int,s) for s in split(readline())]
in_t() = (in_a()...,)
yesno(b) = b ? "Yes" : "No"

function main()
  N, R = in_a()
  if N < 10
    R += 100(10-N)
  end
  R |> println
end

isempty(ARGS) && main()


Measured memory_bytes: 110352
use proconio::input;

fn main() {
    input! {
        (n, m) : (usize, usize)
    };
    let mo = m - 1 + m%2;
    let me = m/2*2;
    for i in 0..n {
        if i >= mo - i { break; }
        println!("{} {}", i+1, mo+1-i);
    }
    for i in 0..n {
        if i >= me - i { break; }
        println!("{} {}", mo+i+2, mo+2+me-i);
    }
}


Measured memory_bytes: 2144
#[allow(unused_imports)]
use std::cmp::{max, min};
use std::io::{stdin, stdout, BufWriter, Write};

#[derive(Default)]
struct Scanner {
    buffer: Vec<String>,
}

impl Scanner {
    fn next<T: std::str::FromStr>(&mut self) -> T {
        loop {
            if let Some(token) = self.buffer.pop() {
                return token.parse().ok().expect("Failed parse");
            }
            let mut input = String::new();
            stdin().read_line(&mut input).expect("Failed read");
            self.buffer = input.split_whitespace().rev().map(String::from).collect();
        }
    }
}

fn main() {
    let mut scan = Scanner::default();
    let out = &mut BufWriter::new(stdout());
    loop {
        let h:i32 = scan.next();
        let w:i32 = scan.next();
        if h == 0 && w == 0 { break; }
        for i in 0..h {
            for j in 0..w {
                if i == 0 || i == h-1 || j == 0 || j == w-1 {
                    write!(out, "#").ok();
                } else {
                    write!(out, ".").ok();
                }
            }
            writeln!(out).ok();
        }
        writeln!(out).ok();
    }
}


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

#define endl '\n'
#define ends ' '
#define die(x) return cout << x << endl, 0
#define all(v) v.begin(), v.end()
#define sz(x) (int)(x.size())
void debug_out() { cerr << endl; }
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) { cerr << ends << H; debug_out(T...); }
#define debug(...) cerr << "{" << #__VA_ARGS__ << "}:", debug_out(__VA_ARGS__)
typedef long long ll;
typedef pair<int, int> pii;
const int INF = 1e9;
const ll MOD = 1e9 + 7;
 
////////////////////////////////////////////////////////////////////
 
const int N = 5e3 + 5;

int DP[N][N], S[N][N];

int main() {
 
	ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
	mt19937 Rnd(time(0));
	
	// DP[i][j] = (j + 1) * DP[i - 1][j] + S[i][j];
	// S[i][j] = Sigma(k = 1, k < j, k * F[i - 1][j] * 2 ^ (j - k - 1));
	// S[i][j] = S[i][j - 1] * 2 + (j - 1) * DP[i - 1][j - 1]; 

	for (int i = 1; i < N; i++) DP[0][i] = DP[i][0] = 1;
	for (int i = 1; i < N; i++) {
		for (int j = 1; j < N; j++) {
			S[i][j] = (2LL * S[i][j - 1] % MOD + 1LL * (j - 1) * DP[i - 1][j - 1] % MOD) % MOD;
			DP[i][j] = (1LL * (j + 1) * DP[i - 1][j] % MOD + S[i][j]) % MOD;
		}
	}
	
	int n, m; cin >> n >> m;
	cout << DP[n][m] << endl;

	return 0;
}


Measured memory_bytes: 199344
s = input()

l = len(s)
n = 1
rl = []
for i in range(l-1):
    if s[i] == s[i+1] and i != l-2:
        n += 1
    elif s[i] == s[i+1] and i == l-2:
        n += 1
    else:
        rl.append(n)
        n = 1

rl.append(n)

ans = [0]*l
rl_length = len(rl)//2
position = rl[0]

for i in range(rl_length):
    ans[position-1] += -(-rl[i*2]//2) + rl[i*2+1]//2
    ans[position] += rl[i*2]//2 - (-rl[i*2+1]//2)
    if i != rl_length - 1:
        position += (rl[i*2+1] + rl[i*2+2])

for i in range(l):
    if i == l-1:
        print(ans[l-1])
    else:
        print(ans[i],end=" ")


Measured memory_bytes: 5624
import sys
sys.setrecursionlimit(10**7)
def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x) - 1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def II(): return int(sys.stdin.readline())
def SI(): return sys.stdin.readline().strip()
INF = 10 ** 18
MOD = 10 ** 9 + 7

def even_digits(i):
    if (1 <= i <= 9) or (100 <= i <= 999) or (10000 <= i <= 99999) or (1000000 <= i <= 9999999):
        return True
    else: return False

def main(): 
    N = II()
    H = LI()

    if N == 1:
        print('Yes')
        return

    for i in range(1, N):
        if H[i-1] < H[i]:
            H[i] -= 1
        elif H[i-1] == H[i]:
            continue
        else:
            print('No')
            break
    else:
        print('Yes')

main()

Measured memory_bytes: 59632
#include <bits/stdc++.h>
using namespace std;
#define dump(x) cout << (x) << endl
typedef long long ll;
typedef pair<int, int> pi;
typedef vector<int> V;

int main() {
  ll n, k;
  cin >> n >> k;
  ll x = k;
  for (int i = 0; i < n-1; i++) {
    x *= (k-1);
  }
  dump(x);
  return 0;
}


Measured memory_bytes: 256
#pragma gcc optimize("Ofast")
#include <bits/stdc++.h>

using namespace std;
using ll = long long;

#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) FOR(i, 0, n)
#define ALL(V) (V).begin(),(V).end()
#define SORT(V) sort(ALL(V)) //小さい方からソート
#define REV(V) reverse(ALL(V)) //リバース
#define RSORT(V) SORT(V);REV(V) //大きい方からソート
#define NPN(V) next_permutation(ALL(V)) //順列
#define pb(n) push_back(n)
#define endl '\n'
#define Endl '\n'
#define DUMP(x)  cout << #x << " = " << (x) << endl
#define YES(n) cout << ((n) ? "YES" : "NO"  ) << endl
#define Yes(n) cout << ((n) ? "Yes" : "No"  ) << endl
#define Yay(n) cout << ((n) ? "Yay!": ":(") << endl
#define RAPID cin.tie(0);ios::sync_with_stdio(false)
#define IN(n) cin >> n
#define IN2(a,b) cin >> a >> b
#define IN3(a,b,c) cin >> a >> b >> c 
#define IN4(a,b,c,d) cin >> a >> b >> c >> d
#define VIN(V) for(int i = 0; i < (V).size(); i++) {cin >> (V).at(i);}
#define OUT(n) cout << n << endl
#define VOUT(V) REP(i, (V).size()) {cout << (V)[i] << endl;}
#define VOUT2(V) REP(i, (V).size()) {cout << (V)[i] << " ";} cout<<endl;

// 型マクロ定義
#define int long long
#define P pair<ll,ll>
#define Vi vector<ll>
#define Vd vector<double>
#define Vs vector<string>
#define Vc vector<char>
#define M map<ll,ll>
#define S set<ll>
#define PQ priority_queue<ll>
#define PQG priority_queue<ll,V,greater<ll>
//

const int MOD = 1000000007;
const int INF = 1061109567;
const double EPS = 1e-10;
const double PI  = acos(-1.0);

int gcd(int a,int b){return b?gcd(b,a%b):a;} //最小公倍数

// デフォルト変数定義
int n,m,a,b,c,d,x,y,z;
string s,t;
//

signed main() {
  RAPID;
  IN(s);
  Yes(s[0]=='9'||s[1]=='9');
}

Measured memory_bytes: 256
#include <iostream>
#include <sstream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <ctime>
#include <cstring>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <bitset>
#include <numeric>
#include <utility>
#include <iomanip>
#include <algorithm>
#include <functional>
using namespace std;

#define COUT(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << endl
#define EACH(i, s) for (__typeof__((s).begin()) i = (s).begin(); i != (s).end(); ++i)

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; }
template<class T1, class T2> ostream& operator << (ostream &s, pair<T1,T2> P)
{ return s << '<' << P.first << ", " << P.second << '>'; }
template<class T> ostream& operator << (ostream &s, vector<T> P)
{ for (int i = 0; i < P.size(); ++i) { if (i > 0) { s << " "; } s << P[i]; } return s; }
template<class T> ostream& operator << (ostream &s, vector<vector<T> > P)
{ for (int i = 0; i < P.size(); ++i) { s << endl << P[i]; } return s << endl; }
template<class T1, class T2> ostream& operator << (ostream &s, map<T1,T2> P)
{ EACH(it, P) { s << "<" << it->first << "->" << it->second << "> "; } return s << endl; }


const int MAX = 210000;
long long N, K;
long long A[MAX], B[MAX];

int main() {
    while (cin >> N >> K) {
        for (int i = 0; i < N; ++i) cin >> A[i] >> B[i];
        
        long long res = 0;
        
        // all
        for (int n = 0; n < N; ++n) {
            bool ok = true;
            for (int j = 0; j < 31; ++j) {
                if ( !(K & (1LL<<j)) && (A[n] & (1LL<<j)) ) ok = false;
            }
            if (ok) {
                //cout << "all" << ", " <<bitset<10>(K) << ", " << bitset<10>(A[n]) << endl;
                res += B[n];
            }
        }
        
            
        for (int i = 0; i < 31; ++i) {   // the first digit - same
            long long tmp = 0;
            

            
            for (int n = 0; n < N; ++n) {
                bool ok = true;
                if (!(K & (1LL<<i))) continue;
                if (A[n] & (1LL<<i)) continue;
                for (int j = i+1; j < 31; ++j) {
                    if ( !(K & (1LL<<j)) && (A[n] & (1LL<<j)) ) ok = false;
                }
                if (ok) {
                    //cout << i << ", " << bitset<10>(K) << ", " << bitset<10>(A[n]) << endl;
                    tmp += B[n];
                }
            }
            chmax(res, tmp);
        }
        cout << res << endl;
    }
}





Measured memory_bytes: 1792
# coding: utf-8
# Your code here!

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

b = list(map(int,input().split()))

k = [0]*a[2]
pp = 0
su = 0

for i in b:
    for j in range(a[2]):
        if j >= i - a[1]   and j <= i + a[1] - 1:
                k[j] += 1
            
for i in range(a[2]):
    if k[i] == 0:
        su += 1
        
print(su)



Measured memory_bytes: 5644
#include<iostream>
#include<string>
#include<iomanip>
#include<cmath>
#include<vector>
#include<algorithm>
#include<utility>

using namespace std;

#define int long long
#define endl "\n"

constexpr long long INF = (long long)1e18;
constexpr long long MOD = 1'000'000'007; 

struct fast_io {
	fast_io(){
		std::cin.tie(nullptr);
		std::ios::sync_with_stdio(false);
	};
} fio;
int N, K;
vector<int> A;

bool solve(int num){
	vector<int> B, sum;
	
	for(int i = 0; i < N; i++){
		if(A[i]%num) B.push_back(A[i]%num);
	}
	
	if(B.size() == 0)return true;  
	
	sort(B.begin(), B.end());
	
	sum.resize(B.size()+1);
	
	// cout<<endl;
	// cout<<"num = "<<num<<endl;
	
	for(int i = 0; i < B.size(); i++){
		sum[i+1] += sum[i] + num - B[i];
		// cout<<"B = "<<B[i]<<" "<<sum[i+1]<<endl;
	}
	
	for(int i = 0, s = 0; i < B.size(); i++){
		// cout<<s<<" == "<<sum[B.size()] - sum[i]<<endl;
		if(s == sum[B.size()] - sum[i] && s  <= K) return true;
		s += B[i];
	}
	
	return false;
}
signed main(){
	cout<<fixed<<setprecision(10);
	
	
	int sum = 0;
	int ans = 1;
	
	cin>>N>>K;
	
	A.resize(N);
	
	for(int i = 0; i < N; i++){
		cin>>A[i];
		sum += A[i];
	}
	
	for(int i = 1; i * i <= sum; i++){
		if(solve(i)) ans = max(ans, i);
		if(solve(sum/i)) ans = max(ans, sum/i);
	}
	
	cout<<ans<<endl;
	
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long int
using namespace std;
ll n,W,dp[105][100005],w[100005],v[100005];
ll fun(ll i,ll W)
{
  ll p1=0;
  if(i>=n+1||W<0)return 0;
  if(dp[i][W]!=-1)return dp[i][W];
  if(W-w[i]>=0)p1=v[i]+fun(i+1,W-w[i]);
  ll p2=0;
  p2=fun(i+1,W);
  dp[i][W]=max(p1,p2);
  return dp[i][W];

}
int main()
{
  ll m,i,j,t;
  while(cin>>n>>W)
  {
    memset(dp,-1,sizeof(dp));
    for(i=1;i<=n;i++)cin>>w[i]>>v[i];
    cout<<fun(1,W)<<endl;
  }

  return 0;
}


Measured memory_bytes: 82432
#include <iostream>
#include <algorithm>
#include <cstdio>
#include <vector>
#include <cmath>
#include <iomanip>
#include <bitset>
#include <string>
#include <cstring>
#include <stdlib.h>
using namespace std;
//cout <<  << endl;
typedef long long int ll;
typedef long double ld;

using Graph = vector<vector<ll>>;

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

#define MAX_N 2010

const long long INF = 1LL << 60;

//境界値に注意！！！

int main() {
    ll n,ans=0;
    bool x[100];
    cin >> n;
    for (ll i=0;i<100;i++)x[i]=false;
    for (ll i=0;i<n;i++){
        ll a;
        cin >> a;
        x[a-1]=true;
    }
    for (ll i=0;i<100;i++)if(x[i])ans++;
    cout << ans << endl;
    return 0;
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
ll powerLL(ll x, ll y, ll MOD)
{
  ll res = 1;
  while(y)
  {
    if(y&1)
      res = (res * x)%MOD;
    y = y>>1;
    x = (x*x)%MOD;
  }
  return res;
}
const ll MOD = 1e9+7;
int main()
{
  ll n;
  cin >> n;
    ll val = powerLL(10, n, MOD);
    ll v1 = powerLL(9,n,MOD);
    ll v2 = powerLL(8,n,MOD);
    cout << ((val-(2*v1-v2))%MOD+MOD)%MOD << endl;
}


Measured memory_bytes: 3644
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<long long> vll;
typedef vector<pair<int,int>> vp;
typedef pair<int,int> pii;
#define INF (int)(1e9)
#define MAXX 1.1529215e+18
#define inf 999999
#define EPS (1e-7)
#define rep(i,n) for(int i=0; i<(int)(n);i++)
#define REP(i,n) for(int i=1;i<=(int)(n);i++)
#define FOR(i,k,n) for(int i=(k);i<(int)(n);i++)
#define ALL(a)  a.begin(),a.end()
#define RALL(a) a.begin(),a.end(),greater<int>()
#define ROT(a) a.begin(),a.begin()+1,a.end()
#define RROT(a) a.begin(),a.end()-1,a.end()
#define PB push_back
#define MP make_pair
#define PI acos(-1.0)
#define sz(a) a.size()
const ll MOD = 1e9+7;
template<typename T1, typename T2> inline bool chmin(T1 &a, T2 b) { if (a > b) { a = b; return 1; } return 0; }
template<typename T1, typename T2> inline bool chmax(T1 &a, T2 b) { if (a < b) { a = b; return 1; } return 0; }
template<typename T> T gcd(T a, T b) { if (b == 0) return a; return gcd(b, a % b); }
//cout << 'H' << endl;
/*--------------------------------------------*/

int main(){
    //cout.precision(10);
    cin.tie(0);
    ios::sync_with_stdio(false);

    int N;
    cin >> N;
    string s,t;
    cin >> s >> t;

    rep(i,N){
        cout<<s[i]<<t[i];
    } 
    cout << endl;
}

Measured memory_bytes: 256
N,A,B = map(int,input().split())

res =0

for i in range(N+1):
    s = str(i)
    l = len(s)
    sum = 0
    
    for j in range(l):
        sum += int(s[j])
        
    if sum >=A and B>=sum:
        res += i
        
        
print(res)

Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
int dx[] = {-1, 1, 0, 0};
int dy[] = {0, 0, -1, 1};
int w, h;
int x_s, y_s;
int a[30][30];
const int MAX_N = 1000000;
int dfs(int y, int x, int cnt)
{
    int ans = MAX_N;
    if (cnt >= 10)
        return ans;
    for (int k = 0; k < 4; k++)
    {
        int ny = y + dy[k];
        int nx = x + dx[k];
        if (a[ny][nx] == 1)
            continue;
        while (a[ny][nx] == 0)
        {
            ny += dy[k];
            nx += dx[k];
        }
        if (a[ny][nx] == 3)
        {
            ans = min(ans, cnt + 1);
        }
        if (a[ny][nx] == 1)
        {
            //障害物を破壊
            a[ny][nx] = 0;
            ans = min(ans, dfs(ny - dy[k], nx - dx[k], cnt + 1));
            a[ny][nx] = 1;
        }
    }
    return ans;
}
int main()
{
    while (cin >> w >> h)
    {
        if (w == 0 || h == 0)
            return 0;
        for (int i = 0; i < 30; i++)
        {
            for (int j = 0; j < 30; j++)
            {
                a[i][j] = 10;
            }
        }
        for (int i = 1; i <= h; i++)
        {
            for (int j = 1; j <= w; j++)
            {
                cin >> a[i][j];
            }
        }
        for (int i = 1; i <= h; i++)
        {
            for (int j = 1; j <= w; j++)
            {
                if (a[i][j] == 2)
                {
                    y_s = i, x_s = j;
                    a[i][j] = 0;
                    break;
                }
            }
        }
        int ans = dfs(y_s, x_s, 0);
        if (ans == MAX_N)
            cout << -1 << endl;
        else
            cout << ans << endl;
    }
}


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

ll N = 100;
vector<ll> ans1;
vector<ll> ans2;
vector<bool> seen;
ll C = 0;

ll gcd(ll a, ll b) { return b?gcd(b,a%b):a;}
ll lcm(ll a, ll b) { return b/gcd(a,b)*b;}


void dfs(vector< vector<ll> > &G, int v) {
  seen[v] = true;
  // v から行ける各頂点 next_v について
  for (auto next_v : G[v]) {
    if (seen[next_v]) continue; // next_v が探索済だったらスルー
    ans1[next_v] = ++C;
    //printf("ans1[%d] = %d\n", next_v+1, C);
    dfs(G, next_v); // 再帰的に探索
    ans2[next_v] = ++C;
    //printf("ans2[%d] = %d\n", next_v+1, C);
  }
}

int main() {
  cin >> N;
  vector< vector<ll> > G(N);
  G.resize(N);
  seen.resize(N, false);
  ans1.resize(N, 0);
  ans2.resize(N, 0);
  int k;
  int tmp;
  rep(i, N) {
    cin >> tmp >> k;
    rep(j, k) {
      int tmp;
      cin >> tmp;
      G[i].push_back(tmp-1);
    }
  }

  rep(i, N) {
    if (!seen[i]) {
      ans1[i] = ++C;
      dfs(G, i);
      ans2[i] = ++C;
    }
  }
  rep(i, N) {
    cout << i+1 << " " << ans1[i] << " " << ans2[i] << endl;
  }
  return 0;
}


Measured memory_bytes: 3156
#include <bits/stdc++.h>
#define range(i, l, r) for(long long int (i) = (l); (i) < (r); (i)++)
#define reversed_range(i, l, r) for (long long int (i) = (r) - 1; (i) >= l; (i)--)
using namespace std;
template <typename T>
using vec = vector<T>;
using lint = long long;
using ulint = unsigned long long;
using pint = pair<int, int>;
using plint = pair<lint, lint>;

template <typename S, typename T>
ostream& operator <<(ostream& os, pair<S, T> p) {
    os << "(";
    os << p.first << ", " << p.second;
    return os << ")";
}

template <typename T>
ostream& operator <<(ostream& os, vec<T> v) {
    os << "[";
    if (v.size() == 0) return os << "]";
    for (int i = 0; i < v.size() - 1; i++) {
        os << v.at(i) << ", ";
    }
    return os << v.at(v.size() - 1) << "]";
}

template <typename T>
ostream& operator <<(ostream& os, set<T>& s) {
    os << "{";
    if (s.begin() == s.end()) return os << "}";
    auto it_first_item = s.begin();
    os << *it_first_item;
    for (auto it = ++it_first_item; it != s.end(); it++) {
        os << ", " << *it;
    }
    return os << "}";
}

template <typename T>
ostream& operator <<(ostream& os, unordered_set<T>& s) {
    os << "{";
    if (s.begin() == s.end()) return os << "}";
    auto it_first_item = s.begin();
    os << *it_first_item;
    for (auto it = ++it_first_item; it != s.end(); it++) {
        os << ", " << *it;
    }
    return os << "}";
}

template <typename K, typename V>
ostream& operator <<(ostream& os, map<K, V> m) {
    os << "{";
    if (m.begin() == m.end()) return os << "}";
    auto it_first_item = m.begin();
    os << it_first_item->first << ": " << it_first_item->second;
    for (auto it = ++it_first_item; it != m.end(); it++) {
        os << ", " << it->first << ": " << it->second;
    }
    return os << "}";
}

template <typename K, typename V>
ostream& operator <<(ostream& os, unordered_map<K, V> m) {
    os << "{";
    if (m.begin() == m.end()) return os << "}";
    auto it_first_item = m.begin();
    os << it_first_item->first << ": " << it_first_item->second;
    for (auto it = ++it_first_item; it != m.end(); it++) {
        os << ", " << it->first << ": " << it->second;
    }
    return os << "}";
}

lint pow(lint num, lint e, lint MOD) {
    lint res = 1;
    lint cur_num = num;
    while (e) {
        if (e & 1) {
            res *= cur_num;
            res %= MOD;
        }
        cur_num *= cur_num;
        cur_num %= MOD;
        e >>= 1;
    }
    return res;
}

using ld = long double;
int main() {
    cin.tie(0); cout.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(10);
    lint A, B, H, M; cin >> A >> B >> H >> M;
    ld deg_long = (ld)360 * (H + (ld)M / 60) / 12, deg_short = (ld)360 * M / 60;
    ld deg_triangle = min(abs(deg_long - deg_short), 360 - abs(deg_long - deg_short));
    ld ans = sqrt(A * A + B * B - 2 * A * B * cos(deg_triangle * M_PI / 180));
    cout << ans << '\n';
}

Measured memory_bytes: 4104
N = int(input())
C = list(input())

R_count = C.count('R')
W_count = C.count('W')
# print(f'{R_count=}, {W_count=}')

if R_count == 0 or W_count == 0:
    print(0)
    exit()

# print(f'start {C=}')

i, j = 0, -1
cnt = 0
while i < N + j:
    if C[i] == 'W':
        while i < N + j:
            if C[j] == 'R':
                C[i] = 'R'
                C[j] = 'W'
                cnt += 1
                # print(f'{C=}, {i=}, {j=}')
                i += 1
                j -= 1
                break
            else:
                j -= 1
    else:
        i += 1

# print(f'end {C=}')
print(cnt)


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

using namespace std;
#define all(a)a.begin(),a.end()
using ll=long long;
const int INF = 1<<30;
const ll INFll =1LL<<62;
const int mod= int(1e9)+7;
using P = pair<ll,ll>;
using ld=long double;

ll d(P a,P b){
    return abs(a.first-b.first)+abs(a.second-b.second);
}

int main(){
    int n,m;cin >>n>>m;
    vector<P>stu(n);
    vector<P>p(m);
    for (int i = 0; i < n; ++i) {
        ll a,b;cin >>a>>b;
        stu[i]={a,b};
    }
    for (int i = 0; i < m; ++i) {
        ll c,d;cin >>c>>d;
        p[i]={c,d};
    }
    vector<int>ans(n);
    for (int i = 0; i < n; ++i) {
        int now=INF;
        for (int j = 0; j < m; ++j) {
            if(now>d(stu[i],p[j])){
                now=d(stu[i],p[j]);
                ans[i]=j+1;
            }
        }
    }
    for (int i = 0; i < n; ++i) {
        cout <<ans[i]<<endl;
    }
}


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

for i in range(1,n+1):
    x = i
    if x%3 == 0:
        print(" {0}".format(i),end="")
    else:
        while(x):
            if x%10 ==3:
                print(" {0}".format(i),end="")
                break
            x = x//10
print()



Measured memory_bytes: 5876
#include <iostream>
#include <algorithm>
using namespace std;
 
int main(void) {
  int N;
  //int a[300010];
  cin >> N;
  int a[3*N];
  for (int i = 0; i < 3*N; i++) cin >> a[i];
  sort(a, a+3*N, greater<int>());
  //reverse(a, a+3*N);
  long int sum = 0;
  for (int i = 1; i < 2*N; i += 2) {
    sum += a[i];
    //cout << a[i] << endl;
  }
  cout << sum << endl;
  
  return 0;
}

Measured memory_bytes: 1408
sx,sy,tx,ty = map(int, input().split())
x = tx-sx
y = ty-sy
a = "R"*x+"U"*y
b = "L"*x+"D"*y
c = "D"+"R"*(x+1)+"U"*(y+1)+"L"
d = "U"+"L"*(x+1)+"D"*(y+1)+"R"
print(a+b+c+d)

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


int main() {
    long double a, b, h, m, angle, length, pi;
    cin >> a >> b >> h >> m;
    angle = abs((h+(m/60))/12 - m/60);
    angle = angle * 2* 3.1415926535897932384626433832795028841971;
    length = pow(a, 2) + pow(b, 2) - 2 * a * b * cos(angle);
    length = sqrt(length);
    cout << setprecision(20) << length << "\n";
}

Measured memory_bytes: 4164
import java.util.*;
import java.io.InputStreamReader;
import java.io.BufferedReader;
import java.util.Arrays;
import java.util.List;
import java.util.ArrayList;
import java.util.ArrayDeque;
import java.util.Deque;
import java.util.Collections;
import java.awt.Point;


public class Main {
    public static void main(String[] args) throws Exception {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        int n = Integer.parseInt(br.readLine());
        String[] s = br.readLine().split(" ");
        int[] h = new int[n];
        
        for (int i = 0; i < n; i++) {
            h[i] = Integer.parseInt(s[i]);
        }
        
        int count = 0;
        boolean end = true; 
        boolean toCount = false;
        while (true) {
            end = true;
            for (int i = 0; i < n; i++) {
                if (h[i] != 0) {
                    end = false;
                    break;
                }
            }
            
            if (end) {
                break;
            }
            
            
            toCount = false;
            for (int i = 0; i < n; i++) {
                if (h[i] > 0) {
                    h[i]--;
                    toCount = true;
                }
                else {
                    if (toCount) count++;
                    toCount = false;
                    continue;
                }
            }
            if (toCount) count++;
        }
        
        System.out.println(count);
    }
}



Measured memory_bytes: 22228
#include <stdio.h>
int main (){
    int n,s[100],i,j,nondec,sum=0;

            scanf("%d",&n);

            for(i=0;i<n;i++){
                scanf("%d",&s[i]);
                sum+=s[i];
            }

            if(sum%10 != 0) printf("%d\n",sum);
            else{
        int k;

        for(i=0;i<n;i++){
            for(j=0;j<n-i;j++){
                if(s[j]>s[j+1]){
                    k=s[j];
                    s[j]=s[j+1];
                    s[j+1]=k;
                }
            }
        }

        int count=0;

        for(i=n-1;i>=0;i--){
            if(s[i]%10!=0){
                    nondec=s[i];
                    count++;
            }
            }

            if(count==0)printf("0\n");
            else     printf("%d\n",sum-nondec);

                }

                return 0;

        }

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

#define FOR(s, i, n) for(int i = s; i n; i++)
typedef long long ll;
const int INF = 1e9;

vector<int> cost;
vector<vector<int>> value;
vector<int> knowl;
int n,m,x;
int solve(int it, int money){
	if (it==n){
		FOR(0, i, <m){
			if(knowl[i] < x){
				return INF;
			}
		}
		return money;
	}
	FOR(0, i, <m){
		knowl[i] += value[it][i];
	}
	int ans = solve(it+1, money + cost[it]);
	FOR(0, i, <m){
		knowl[i] -= value[it][i];
	}
	return min(ans, solve(it+1, money));
}
int main(){
	ios::sync_with_stdio(false);
	cin.tie(NULL);
	
	cin>>n>>m>>x;
	cost.resize(n);
	value.resize(n, vector<int>(m));
	knowl.resize(n, 0);
	FOR(0, i, <n){
		cin>>cost[i];
		FOR(0, j, <m){
			cin>>value[i][j];
		}
	}
	int ans = solve(0, 0);
	if(ans == INF){
		cout<<-1<<'\n';
	}else{
		cout<<ans<<'\n';
	}
	return 0;
}

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

int arr[2][105],dp[2][105];

int main(){
  int n;
  cin>>n;
  for(int i=0;i<2;i++){
    for(int j=0;j<n;j++){
      cin>>arr[i][j];
    }
  }
  dp[0][0]=arr[0][0];
  dp[1][0]=dp[0][0]+arr[1][0];
  for(int i=1;i<n;i++){
    dp[0][i]=arr[0][i]+dp[0][i-1];
    dp[1][i]=max(dp[1][i-1],dp[0][i])+arr[1][i];
  }

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

Measured memory_bytes: 256
import java.util.Arrays;
import java.util.Scanner;

public class Main {
  public static void main(String[] args) {
    // TODO 自動生成されたメソッド・スタブ
    // TODO 自動生成されたメソッド・スタブ
    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();
    int p[] = new int[n];
    int q[] = new int[n];

    int p_order = 0;
    int q_order = 0;

    for (int i = 0; i < n; i++) {
      p[i] = sc.nextInt();
    }

    for (int i = 0; i < n; i++) {
      q[i] = sc.nextInt();
    }

    int pos = 0;
    for (int i = 0; i < n; i++) {
      pos += (index(p[i], Arrays.copyOfRange(p, i, n)) - 1) * kaijyo(n - i - 1);
    }

    int q_pos = 0;
    for (int i = 0; i < n; i++) {
      q_pos += (index(q[i], Arrays.copyOfRange(q, i, n)) - 1) * kaijyo(n - i - 1);
    }
    System.out.println(Math.abs((pos + 1) - (q_pos + 1)));
  }

  public static int index(int i, int list[]) {
    int a = 1;
    for (int j = 0; j < list.length; j++) {
      if (list[j] < i) {
        a++;
      }
    }
    return a;
  }

  public static int kaijyo(int i) {
    if (i == 0) {
      return 1;
    }
    return i * kaijyo(i - 1);
  }
}


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

int main(){
	int s[101][101] = {0};
	int i, j, r, c;
	
	cin >> r >> c;
	
	for(i = 0; i < r; i++){
		for(j = 0; j < c; j++){
			cin >> s[i][j];
			s[i][c] += s[i][j];
			s[r][j] += s[i][j];
		}
		s[r][c] += s[i][c];
	}
	
	for(i = 0; i < r + 1; i++){
		for(j = 0; j < c + 1; j++){
			cout << s[i][j];
			if(j != c){
				cout << " ";
			}
		}
		cout << endl;
	}
    return 0;
}

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

int main() {
  int H, W;
  cin >> H >> W;
  vector<vector<char>> table(H, vector<char>(W)); //H行W列の行列
  
  for (int i = 0; i < H; i++) {
    for (int j = 0; j < W; j++) {
      cin >> table.at(i).at(j);
    }
  }
  
  vector<bool> row(H, false);
  vector<bool> col(W, false);
  for (int i = 0; i < H; i++) {
    for (int j = 0; j < W; j++) {
      if (table.at(i).at(j) == '#') {
        row.at(i) = true;
        col.at(j) = true;
      }
    }
  }
  
  for (int i = 0; i < H; i++) {
    if (row.at(i)) {
      for (int j = 0; j < W; j++) {
        if (col.at(j)) {
          cout << table.at(i).at(j);
        }
      }
      cout << endl;
    }
  }
}

    
  
  
    
    

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <vector>
#include <map>
#include <algorithm>
#include <string>
#include <cmath>
#include <set>

#define lowbit(x) (x&(-x))
#define MAX(a,b) (a<b?b:a)
#define MIN(a,b) (a<b?a:b)
using namespace std;

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
const int N = 1e7;
const int maxn = 3e2 + 5;
ll mod = 1e9 + 7;

char s[maxn];
int k;

int f[maxn][maxn][maxn];

int main()
{
	scanf("%s%d", s, &k);
	int n = strlen(s);
	if (n == 1)
	{
		printf("1");
		return 0;
	}
	for (int i = 0; i < n; i++) f[i][i][0] = 1;

	for(int len = 2;len<=n;++len)
	{
		for(int l = 0;l<n;l++)
		{
			int r = l + len - 1;
			if (r >= n) break;
			for (int x = 0; x <= k; x++)
			{
				f[l][r][x] = MAX(f[l + 1][r][x], f[l][r - 1][x]);
				if (s[l] == s[r]) f[l][r][x] = MAX(f[l][r][x], f[l + 1][r - 1][x] + 2);
				if (x)
				{
					f[l][r][x] = MAX(f[l][r][x], f[l][r][x - 1]);
					f[l][r][x] = MAX(f[l][r][x], f[l + 1][r - 1][x - 1] + 2);
				}
			}
		}
	}
	
	printf("%d", f[0][n - 1][k]);
}

Measured memory_bytes: 110848
#include<bits/stdc++.h>
using namespace std;
#define IOS ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
using ll = long long int;
int main()
{
    //freopen("inputfile.txt","r",stdin);
    IOS;
    ll n,x,t;
    cin>>n>>x>>t;
    ll ans = (n/x);
    if((n%x)!= 0)ans++;
    cout<<(t*ans)<<endl;
}


Measured memory_bytes: 3660
/**
 *  winners never quit
**/

#include <bits/stdc++.h>

using namespace std;

#define pb push_back
#define pp pop_back
#define mp make_pair
#define IO cin.tie(0),cout.tie(0)
#define ISWS ios::sync_with_stdio(0)
typedef long long Long;
void FastIO(){ISWS;IO;}

const int N = 1e5;

bool mark[N+N+1];
vector <vector <int> > g(N+N+1);
int cnt;

void dfs(int id){
  if (mark[id])return;
  mark[id] = true;
  cnt++;
  for (int i = 0;i < g[id].size();i++){
    dfs(g[id][i]);
  }
}

int main()
{
  FastIO();
  int tc, ca = 0;
  int n, m;
  cin >> n >> m;
  for (int i = 0;i < m;i++){
    int a, b;
    cin >> a >> b;
    g[a].pb(b);
    g[b].pb(a);
  }
  int ans = 0;
  for (int i = 1;i <= n;i++){
    if (mark[i]==false){
      cnt = 0;
      dfs(i);
      ans = max(ans, cnt);
    }
  }
  cout << ans << '\n';
  return 0;
}


Measured memory_bytes: 20692
L=int(input())
count=0
k=1
max=0
LL=format(L,'b')
N=len(LL)
M=(len(LL)-1)*2+LL.count('1')-1
#print(LL)
print(N,M)
max=2**(N-1)-1
for n in range(1,N):
    print(n,n+1,0)
    print(n,n+1,k)
    k*=2
    if LL[::-1][n-1]=='1' and n!=N:
        print(n,N,max+1)
        max+=2**(n-1)

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

using namespace std;

typedef long long ll;

ll mod;

ll powimod(ll x,ll n,ll mod){
    ll res=1;
    while(n){
        if(n&1) res=(res*x)%mod;
        x=(x*x)%mod;
        n>>=1;
    }
    return res;
}

ll powi(ll x,ll n){
    ll res=1;
    while(n){
        if(n&1) res*=x;
        x*=x;
        n>>=1;
    }
    return res;
}

vector<int> z_function(string s) {
    int n = (int) s.length();
    vector<int> z(n);
    for (int i = 1, l = 0, r = 0; i < n; ++i) {
        if (i <= r)
            z[i] = min (r - i + 1, z[i - l]);
        while (i + z[i] < n && s[z[i]] == s[i + z[i]])
            ++z[i];
        if (i + z[i] - 1 > r)
            l = i, r = i + z[i] - 1;
    }
    return z;
}

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    ll x,k,d;
    cin>>x>>k>>d;
    x=abs(x);
    ll var=x/d;
    if(var>=k) x=x-k*d;
    else
    {
    ll t=k-var;
    t=t/2;
    k=k-2*t;
    k=k*d;
    x=x-k;
    x=abs(x);
    }
    cout<<x;
}


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

int main() {
  string s;

  cin >> s;

  int tmp = s.size();

  sort(s.begin(), s.end());
  s.erase(unique(s.begin(), s.end()), s.end());

  if ((int)s.size() == tmp)
    cout << "yes";
  else
    cout << "no";

  return 0;
}

Measured memory_bytes: 256
N = int(input())
A = list(map(int, input().split()))
S = sum(A)
count = [0 for _ in range(int(1e5)+1)]
for a in A:
    count[a] += 1    

Q = int(input())
for i in range(Q):
    b, c = map(int, input().split())
    S += (c-b) * count[b]
    count[c] += count[b]
    count[b] = 0
    print(S)

Measured memory_bytes: 83344
#include<iostream>
#include<cmath>
#include<algorithm>
static const int MAX=200005;
using namespace std;
int main(void){
	int N;	cin >> N;
	int A[MAX];
	for(int i=0;i<N;i++){
		int b;
		cin >> b;
		A[i]=b-(i+1);
	}
	sort(A,A+N);
	
	long ans=0;
	for(int i=0;i<N;i++)
		ans+=abs(A[i]-A[N/2]);
	cout << ans << endl;
	return 0;
}


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


using namespace std;

using ll   = long long;
using ii   = pair   < int , int >;
using i3   = pair   < int , ii  >;
using li   = pair   < ll  , int >;
using lii  = pair   < ll  , ii  >;
using pll  = pair   < ll  , ll  >;
using vi   = vector < int       >;
using vl   = vector < ll        >;
using vii  = vector < ii        >;
using vli  = vector < li        >;
using vpll = vector < pll       >;
using vi3  = vector < i3        >;
using vlii = vector < lii       >;


const int N = 2e5 + 5;
const ll INF = 1e17 + 7;
const double eps = 1e-9 , PI = acos(-1);



int n , m;


void solve(int testCase){

    scanf("%d" , &n);
    string s;
    cin >> s;

    int ans = 0;
    for(int i = 1 ; i < n-1 ; i ++){
            if(s[i] == 'B' && s[i-1] == 'A' && s[i+1] == 'C')ans ++;
    }
    printf("%d\n" , ans);


}

main(){

    int t = 1;
    // scanf("%d" , &t);

    for(int testCase = 1 ; testCase <= t ; testCase ++){
            solve(testCase);
    }

    return 0;
}


Measured memory_bytes: 256
import itertools
N = int(input())

XY = [[int(x) for x in input().split()] for _ in range(N)]

vectors = []

for xy1,xy2 in itertools.combinations(XY,2):
  p = xy2[0] - xy1[0]
  q = xy2[1] - xy1[1]
  vectors.append((p,q))
  vectors.append((-p,-q))

from collections import Counter
c = Counter(vectors)

if N >= 2:
  x = max(c.values())
  answer = N - x
else:
  answer = 1
print(answer)


Measured memory_bytes: 3828
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define srep(i,s,t) for(int i = s; i < t; ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
using namespace std;
typedef long long int ll;
typedef pair<int,int> P;
#define yn {puts("Yes");}else{puts("No");}
#define MAX_N 200005

int main() {
    int x, n;
    cin >> x >> n;
    int mi = -1001001001;
    int ma = 1001001001;
    int a[n];
    rep(i,n)cin >> a[i];
    int f[200] = {};
    rep(i,n)f[a[i]] = 1;
    drep(i,x+1){
        if(f[i] == 0){
            mi = i;
            break;
        }
    }
    srep(i,x,200){
        if(f[i] == 0){
            ma = i;
            break;
        }
    }

    if(abs(x-mi) <= abs(x-ma)){
        cout << mi << endl;
    }else{
        cout << ma << endl;
    }

    return 0;
}




Measured memory_bytes: 3636
#include <bits/stdc++.h>
using namespace std;
#define fi first
#define se second
#define countof(array) (sizeof(array) / sizeof(array[0]))
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,n,s) for(int i = s; i < (n); ++i)
#define rsrep(i,n,s) for(int i = (n)-1; i >= s; --i)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define aall(a) (a), (a)+countof(a)//for array sorting
#define raall(a) (a), (a)+countof(a), greater<>()
#define show(x) cout<<#x<<" = "<<x<<endl;
#define vfind(v, a) find(all(v), a) != v.end()
#define yn(f) { if (f) puts("YES"); else puts("NO"); }
#define yns(f) { if (f) puts("Yes"); else puts("No"); }
#define show_ary(...) { cout<<#__VA_ARGS__<<" = "; for (const auto& x : (__VA_ARGS__)) { cout<<x<<" "; } cout<<endl; }
#define show_pair(...) cout<<#__VA_ARGS__<<" = "<<endl; for (const auto& x : (__VA_ARGS__)) { cout<<"  "<<x.fi<<" : "<<x.se<<endl; }
#define out_ary(...) { for (const auto& x : (__VA_ARGS__)) { cout<<x<<" "; } cout<<endl; }
#define argmax(v) distance((v).begin(), max_element(all(v)))
#define argmin(v) distance((v).begin(), min_element(all(v)))
#define vmax(v) *max_element(all(v))
#define vmin(v) *min_element(all(v))
typedef long long int ll;
typedef pair<int, int> P;
typedef vector<P> vpair;
typedef vector<int> vint;
typedef vector<ll> vll;
typedef vector<double> vdouble;
typedef vector<string> vstr;
typedef vector<bool> vbool;
typedef vector<vint> vvint;
typedef vector<vll> vvll;
typedef vector<vstr> vvstr;
typedef vector<vbool> vvbool;
const ll LINF = 2000000000000000000ll;
const int INF = 1000000100;
const ll MOD = 1e9+7;

int main() {
    int n, k;
    cin >> n >> k;
    int h;
    int ans = 0;
    rep(i, n) {
        cin >> h;
        if (h >= k) ans++;
    }

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

Measured memory_bytes: 256
N=input()

L=[]
for i in range(N):
	a,b=map(int,raw_input().split())
	L.append( (a+b,a,b) ) 


L.sort(key=lambda x: -x[0])


ans=0
for i in range(N):
	if i%2==0:
		ans+=L[i][1]
	else:
		ans-=L[i][2]

print ans


Measured memory_bytes: 53020
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <functional>
#include <vector>
#include <string>

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

vector<int> cut(vector<int> c, int k){
	
	int i;
	vector<int> res;
	
	for(i=k; i<c.size(); i++) res.push_back(c[i]);
	for(i=0; i<k; i++) res.push_back(c[i]);

	return res;
		
}

vector<int> re(vector<int> c, int n){

	int i;
	vector<int> res,a,b;
	
	for(i=0; i<n; i++) a.push_back(c[i]);
	for(i=n; i<c.size(); i++) b.push_back(c[i]);

	rep(i,n){
		res.push_back(a[i]);
		res.push_back(b[i]);
	}
	
	return res;
}


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

	int n,m,k;
	vector<int> cards;

	cin >> n;
	rep(i,n*2) cards.push_back(i+1);

	cin >> m;
	rep(i,m){
		cin >> k;

		if(k) cards = cut(cards, k);
		else  cards = re(cards, n);		
	}

	rep(i,cards.size()) cout << cards[i] << "\n";

	return 0;
}

Measured memory_bytes: 1228
ex = []
for i in range(1001):
    e = 0
    j = i 
    while j != 0:
        e += j / i
        j-=1
    ex.append(e)

n, k = map(int, input().split())
p = list(map(int, input().split()))

total = 0
mx = 0

for i in range(n):
    if i < k:
        total += ex[p[i]]
    else:
        total = total + ex[p[i]] - ex[p[i-k]]
    if mx < total:
        mx = total

print(mx)

Measured memory_bytes: 24804