akhauriyash/Code-Regression huggingface dataset:
#![allow(unused_mut, non_snake_case,unused_imports)]
use std::iter;
use std::cmp::{max, min, Ordering};
use std::mem::{swap};
use std::collections::{HashMap,BTreeMap,HashSet,BTreeSet,BinaryHeap,VecDeque};
use std::iter::FromIterator;

//　高速 EOF要
//macro_rules! input {(source = $s:expr, $($r:tt)*) => {let mut iter = $s.split_whitespace();input_inner!{iter, $($r)*}};($($r:tt)*) => {let mut s = {use std::io::Read;let mut s = String::new();std::io::stdin().read_to_string(&mut s).unwrap();s};let mut iter = s.split_whitespace();input_inner!{iter, $($r)*}};}
//macro_rules! input_inner {($iter:expr) => {};($iter:expr, ) => {};($iter:expr, $var:ident : $t:tt $($r:tt)*) => {let $var = read_value!($iter, $t);input_inner!{$iter $($r)*}};}
//macro_rules! read_value {($iter:expr, ( $($t:tt),* )) => {( $(read_value!($iter, $t)),* )};($iter:expr, [ $t:tt ; $len:expr ]) => {(0..$len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()};($iter:expr, chars) => {read_value!($iter, String).chars().collect::<Vec<char>>()};($iter:expr, usize1) => {read_value!($iter, usize) - 1};($iter:expr, $t:ty) => {$iter.next().unwrap().parse::<$t>().expect("Parse error")};}
// 低速 EOF不要
macro_rules! input {(source = $s:expr, $($r:tt)*) => {let mut iter = $s.split_whitespace();let mut next = || { iter.next().unwrap() };input_inner!{next, $($r)*}};($($r:tt)*) => {let stdin = std::io::stdin();let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));let mut next = move || -> String{bytes.by_ref().map(|r|r.unwrap() as char).skip_while(|c|c.is_whitespace()).take_while(|c|!c.is_whitespace()).collect()};input_inner!{next, $($r)*}};}
macro_rules! input_inner {($next:expr) => {};($next:expr, ) => {};($next:expr, $var:ident : $t:tt $($r:tt)*) => {let $var = read_value!($next, $t);input_inner!{$next $($r)*}};}
macro_rules! read_value {($next:expr, ( $($t:tt),* )) => {( $(read_value!($next, $t)),* )};($next:expr, [ $t:tt ; $len:expr ]) => {(0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()};($next:expr, chars) => {read_value!($next, String).chars().collect::<Vec<char>>()};($next:expr, usize1) => {read_value!($next, usize) - 1};($next:expr, $t:ty) => {$next().parse::<$t>().expect("Parse error")};}

/*
 <url:>
 問題文============================================================
 =================================================================
 解説=============================================================
 ================================================================
 */
fn main(){
    input!(V:[i32;3]);
    let mut V:Vec<i32> = V;
    V.sort();
    println!("{}",V[2]*10+V[1]+V[0]);
}

Measured memory_bytes: 4352
#include <bits/stdc++.h>
#include <boost/multiprecision/cpp_int.hpp>
using namespace std;
using bint = boost::multiprecision::cpp_int;
using ll = long long;
using pint = pair<int, int>;
using pll = pair<ll, ll>;
#define rep(i,n) for (int i = 0; i < (n); i++)
#define repSE(i,s,n) for (int i = (s); i < (n); i++)
#define rrepSE(i,s,e) for (int i = (s); i > (e); i--)
#define ssort(v) sort(v.begin(), v.end())
#define gsort(v) sort(v.rbegin(), v.rend())
template<typename T> istream &operator>>(istream &is, vector<T> &vec){ for (auto &v : vec) is >> v; return is; }
template<typename T> ostream &operator<<(ostream &os, const vector<T> &vec){ os << "["; for (auto v : vec) os << v << ","; os << "]"; return os; }
template<typename T> ostream &operator<<(ostream &os, const deque<T> &vec){ os << "deq["; for (auto v : vec) os << v << ","; os << "]"; return os; }
template<typename T> ostream &operator<<(ostream &os, const set<T> &vec){ os << "{"; for (auto v : vec) os << v << ","; os << "}"; return os; }
template<typename T> ostream &operator<<(ostream &os, const unordered_set<T> &vec){ os << "{"; for (auto v : vec) os << v << ","; os << "}"; return os; }
template<typename T> ostream &operator<<(ostream &os, const multiset<T> &vec){ os << "{"; for (auto v : vec) os << v << ","; os << "}"; return os; }
template<typename T> ostream &operator<<(ostream &os, const unordered_multiset<T> &vec){ os << "{"; for (auto v : vec) os << v << ","; os << "}"; return os; }
template<typename T1, typename T2> ostream &operator<<(ostream &os, const pair<T1, T2> &pa){ os << "(" << pa.first << "," << pa.second << ")"; return os; }
template<typename TK, typename TV> ostream &operator<<(ostream &os, const map<TK, TV> &mp){ os << "{"; for (auto v : mp) os << v.first << "=>" << v.second << ","; os << "}"; return os; }
template<typename TK, typename TV> ostream &operator<<(ostream &os, const unordered_map<TK, TV> &mp){ os << "{"; for (auto v : mp) os << v.first << "=>" << v.second << ","; os << "}"; return os; }
template<typename T> bool chmax(T &m, const T q) { if (m < q) {m = q; return true;} else return false; }
template<typename T> bool chmin(T &m, const T q) { if (q < m) {m = q; return true;} else return false; }
#define DEBUG_PRINT(var) std::cout << #var << " = " << var << "\n";

vector<int> divisors(int n) {
    vector<int> divs;
    repSE(i, 1, int(sqrt(n))+1) {
        if (n % i == 0) {
            divs.push_back(i);
            if (i != n / i) {
                divs.push_back(n/i);
            }
        }
    }
    return divs;
}

int main()
{
    int n, m;
    cin >> n >> m;
    vector<int> divs = divisors(m);
    int ans = 1;
    rep(i,divs.size()) {
        if (divs[i] <= m / n)
            ans = max(ans, divs[i]);
    }
    cout << ans << "\n";
    return 0;
}


Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Arrays;

public class Main {

    public static void main(String[] args) throws NumberFormatException, IOException {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

        int[] input = new int[10];

        for(int i = 0; i < 10; i++){
            input[i] = Integer.parseInt(br.readLine());
        }

        //?°??????????????????????
        Arrays.sort(input);

        for(int i = 9 ; i >= 7; i--){
            System.out.println(input[i]);
        }

    }

}

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

using namespace std;

#define rep(i, n) for(int i = 0; i < n; i++)
#define inv(n, a) for(int i = 0; i < n; i++) cin >> a[i]
#define MOD 1000000007
#define INF 1e7
#define LINF 1e15
typedef long long ll;
typedef long double ld;
using Graph = vector<vector<int>>;
// 'a' = 97 'z' = 122 => 'a' = 0 'z' = 25

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

int main() {
    int k; cin >> k;
    int ans = 0;
    for(int i = 1; i <= k; i++){
        for(int j = 1; j <= k; j++){
            for(int l = 1; l <= k; l++){
                ans += gcd(gcd(i, j), l);
            }
        }
    }
    cout << ans << endl;
    return 0;
}




Measured memory_bytes: 3636
#include <math.h>
#include <algorithm>
#include <set>
#include <iostream>
#include <vector>
#include <queue>
#include <map>
#include <string>
#include <cstring>
#include <functional>
#include <stack>
#include <unordered_map>
#include <unordered_set>
#include <random>
#include <chrono>
#include <climits>
#include <bitset>
using namespace std ;
#define ld long double
#define int long long
#define ii pair<int,int>
#define FAST_IO ios_base::sync_with_stdio(false) ;cin.tie(NULL);cout.tie(NULL); clock_t beg = clock()
#define dbg(x) cerr << #x << " is " << x << endl;
#define ms(x,a) memset(x,(int)(a),sizeof(x))
#define all(x) (x).begin(), (x).end()
#define sz(x) ((int)(x).size())
#define vi vector<int >
#define pb push_back
#define endl '\n'
#define ff first
#define ss second
const int N = 3e5+7 ;
const int INF = 1e18 ;
const int MOD = 1e9 + 7 ;
string s ;

void solve(){
	int n , k ;
	cin >> n >> k ;
	int r = n%k ;
	int ans = min(r,k-r) ;
	cout << ans ;
	
}

int32_t main(){
	FAST_IO ;
	int t = 1 ;
//	cin >> t ;
	while(t--){
		solve() ;
	}
    cerr << "\nExecution time: " << (clock() - beg) / 1000 << '\n';
}


Measured memory_bytes: 764
n = int(input())
xs = [0] + list(map(int, input().split()))
xs.append(0)

full = sum(abs(xs[i-1] - xs[i]) for i in range(1, n+2))

ans = [full - abs(xs[i-1] - xs[i]) - abs(xs[i] - xs[i+1]) + abs(xs[i-1] - xs[i+1]) for i in range(1, n+1)]

print('\n'.join(map(str, ans)))


Measured memory_bytes: 19416
#include <bits/stdc++.h>
#include <vector> 
# include <cstdint>
#define FOR(i,l,r) for(int i=(l);i<(r);++i)
#define RFOR(i,l,r) for(int i=(l);i>=(int)(r);i--)
#define rep(i,n)  FOR(i,0,n)
#define rrep(i,n)  RFOR(i,n-1,0)

#define int long long
using namespace std;
const int MX = 1e6;
const int inf = 1e9+5;
const int mod = 998244353;

vector<int> fac(300001); //n!(mod M)
vector<int> ifac(300001); //k!^{M-2} (mod M)

long long fpow(long long a,long long n){
  long long ret=1;
  if(n==1) return a;
  if(n%2==0) {
      ret = fpow(a*a%mod, n/2) %mod ;
  }else {
      ret = (a%mod)*fpow(a*a%mod, n/2) %mod;
  }
  return ret %mod;
}
int comb(int a, int b){ //aCbをmod計算
    if(a == 0 && b == 0)return 1;
    if(a < b || a < 0)return 0;
    int tmp = ifac[a-b]* ifac[b] % mod;
    return tmp * fac[a] % mod;
}
const double PI=3.14159265358979323846;
int dp[100][100];
int tmp[100][100];
signed main(){
    int a, b, c, d;
    cin >> a >> b >> c >> d;
    int ans = b-a+1;
    int aa = a-1;
    int tmp1 = b/d + b/c - b/(d*c/__gcd(d,c));
    int tmp2 =  aa/d + aa/c - aa/(d*c/__gcd(d,c));
    //cout << ans << " " <<tmp1 <<" " << tmp2 << endl;
    ans -= (tmp1- tmp2);

    cout << ans << endl;

    return 0;

}


Measured memory_bytes: 4992
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cstring>
#include <climits>
#include <vector>
#include <map>
#include <set>
#include <list>
#include <stack>
#include <queue>
#include <algorithm>
#include <iostream>
#include <string>

#define REP(i,n) for(long long i=0;i<n;++i)
#define REPR(i,n) for(long long i=n;i>=0;--i)
#define REPI(itr,v) for(auto itr=v.begin();itr!=v.end();++itr)
#define REPIR(itr,v) for(auto itr=v.rbegin();itr!=v.rend();++itr)
#define FOR(i,a,b) for(long long i=a;i<b;++i)
#define SORT(v,n) sort(v, v+n)
#define SORTV(v) sort(v.begin(), v.end())
#define ALL(v) v.begin(),v.end()
#define llong long long
#define INF 999999999
#define SUR 1000000007
#define pb push_back
#define pf push_front
#define MP make_pair
#define SV(v) {for(long long sitr=0;sitr<v.size();++sitr){cin>>v[sitr];}}

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

using namespace std;

typedef pair<int,int> pii;

int main(){


  while(true){
    int n, w;
    scanf("%d %d", &n, &w);
    if(n == 0 && w == 0) break;

  
    vector<int> v(n);

    int max_num = 0;
    REP(i,n){
      scanf("%d", &v[i]);
      max_num = max(max_num, v[i]);
    }

    int hist_num = max_num / w + 1;
    vector<int> hist(hist_num);
     REP(i,hist_num){
      hist[i] = 0;
    }
  
    REP(i,n){
      hist[v[i] / w]++;
    }

    int max_height = 0;
    REP(i,hist_num){
      max_height = max(max_height, hist[i]);
    }

    double ans = 0.01;
    REP(i,hist_num-1){
      ans += double(hist_num - 1 - i) / double(hist_num - 1) * hist[i] / (double)max_height;
    }

    printf("%.8f\n", ans);
  }
  return 0;
}




Measured memory_bytes: 3108
#[allow(unused_macros)]
macro_rules ! read_value {($ next : expr , ($ ($ t : tt ) ,* ) ) => {($ (read_value ! ($ next , $ t ) ) ,* ) } ; ($ next : expr , [$ t : tt ; $ len : expr ] ) => {(0 ..$ len ) . map (| _ | read_value ! ($ next , $ t ) ) . collect ::< Vec < _ >> () } ; ($ next : expr , chars ) => {read_value ! ($ next , String ) . chars () . collect ::< Vec < char >> () } ; ($ next : expr , usize1 ) => {read_value ! ($ next , usize ) - 1 } ; ($ next : expr , $ t : ty ) => {$ next () . parse ::<$ t > () . expect ("Parse error" ) } ; }
#[allow(unused_macros)]
macro_rules ! input_inner {($ next : expr ) => {} ; ($ next : expr , ) => {} ; ($ next : expr , $ var : ident : $ t : tt $ ($ r : tt ) * ) => {let $ var = read_value ! ($ next , $ t ) ; input_inner ! {$ next $ ($ r ) * } } ; }
#[allow(unused_macros)]
macro_rules ! input {(source = $ s : expr , $ ($ r : tt ) * ) => {let mut iter = $ s . split_whitespace () ; let mut next = || {iter . next () . unwrap () } ; input_inner ! {next , $ ($ r ) * } } ; ($ ($ r : tt ) * ) => {let stdin = std :: io :: stdin () ; let mut bytes = std :: io :: Read :: bytes (std :: io :: BufReader :: new (stdin . lock () ) ) ; let mut next = move || -> String {bytes . by_ref () . map (| r | r . unwrap () as char ) . skip_while (| c | c . is_whitespace () ) . take_while (| c |! c . is_whitespace () ) . collect () } ; input_inner ! {next , $ ($ r ) * } } ; }

fn main() {
    input! {
        a_: i64,
        b_: i64,
        k_: i64,
    }
    let mut a = a_;
    let mut b = b_;
    let mut k = k_;

    if a < k {
        k -= a;
        a = 0;
    } else {
        a -= k;
        k = 0;
    }

    if b < k {
        k -= b;
        b = 0;
    } else {
        b -= k;
        k = 0;
    }

    println!("{} {}", a, b);
}


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

#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
using namespace __gnu_pbds; 
  
#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update> 
 
#define FS              ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define ll              long long int
#define ld              long double
#define pb              push_back
#define bp              __builtin_popcount
#define sz              size()
#define ff              first
#define ss              second
#define vll             vector<ll>
#define vbool           vector<bool>
#define vpll            vector<pair<ll,ll>>
#define pll             pair<ll,ll>
#define vllv            vector<vector<ll>>
#define setpri(x)       cout<<setprecision(x)<<fixed;
#define all(v)          v.begin(),v.end()
#define allr(v)         v.rbegin(),v.rend()
#define yesr {cout<<"YES"<<endl;return;}
#define nor {cout<<"NO"<<endl;return;}
// getline (std::cin,name);
ll MOD=1e9+7;
ll ceil1(ll n,ll x){return (n-1)/x+(n>0);}

ll gcd(ll a,ll b){return __gcd(a,b);}
ll lcm(ll a,ll b){return (max(a,b)/gcd(a,b))*min(a,b);}

ll pow1(ll n,ll m ,ll mod=MOD );
ll pow2(ll n,ll k);

ll modinv(ll n,ll mod=MOD){  return pow1(n,mod-2,mod);}

bool func(pair<ll,ll> &a,pair<ll,ll> &b ){
        if(a.ff != b.ff)return a.ff < b.ff;
        return a.ss > b.ss;
}
ll const N=(ll)1e5+111;
ll const LG=(ll)log2(N)+1;


void solve(){
        ll i,j,k,l,n,m,x,y,z,r;
        
        cin>>n;
        ll ans=0;
        for(i=1;i<=n;i++){
                cin>>x;
                
                if(i%2==1 && x%2==1)ans++;
        }
        cout<<ans;
        
        
}       
int main(){
        FS;
        
        ll i,j,k,n,m,x,y,z,q;
        q=1;
        // cin>>q;
        while(q--){
                solve();
        }
        return 0;
}


ll pow1(ll n,ll m,ll mod){
        if(m==0)return 1;
        
        if(m%2==0)return pow1((n*n)%mod,m/2,mod);
    	
    	return (pow1((n*n)%mod,m/2,mod)*n)%mod;
}

ll pow2(ll n,ll k){
        ll ans=1;
            while(k>0){
                if(k%2==1)ans=ans*n;
                n=n*n;
                k/=2;
            }
            return ans;
}


Measured memory_bytes: 3596
N = int(input())
Sset = set()
str_dict = {"M": 0, "A": 0, "R": 0, "C": 0, "H": 0}
for _ in range(N):
    S = input()
    if S in Sset:
        continue
    if S[0] in {"M", "A", "R", "C", "H"}:
        Sset.add(S)
        str_dict[S[0]] += 1

non0 = []
for item in str_dict.items():
    if item[1] > 0:
        non0.append(item[0])

num = 0
from itertools import combinations
for comb in combinations(non0, 3):
    num += str_dict[comb[0]] * str_dict[comb[1]] * str_dict[comb[2]]

print(num)


Measured memory_bytes: 14316
#include <bits/stdc++.h> 
#define ll long long
#define pb push_back
#define pf push_front
#define popb pop_back
#define popf pop_front
#define F first
#define S second
#define mp make_pair
#define PII pair<int,int>
#define PLL pair<long long,long long>
#define pq priority_queue
#define M map
#define UM unordered_map
#define graph unordered_map<int,vector<int>>
#define graphw unordered_map<int,vector<pair<int,int>>>
#define V vector
#define mod 1000000007
#define inf 3000000000000000007ll
#define P pair
#define Fast ios_base::sync_with_stdio(false);cin.tie();cout.tie();
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(), a.rend()
#define sz(a) signed(a.size())
#define FIXED cout << fixed << setprecision(12)
#define L list
#define D deque
#define ld long double
using namespace std;
// pair operation
template<class T, class U>istream& operator>>(istream& in, pair<T,U> &rhs){in >> rhs.first;in >> rhs.second;return in;}
template<class T, class U>ostream& operator<<(ostream& out,const pair<T,U> &rhs){out << rhs.first;out << " ";out << rhs.second;return out;}
template<class T, class U>pair<T,U> operator+(pair<T,U> &a, pair<T,U> &b){return pair<T,U>(a.first+b.first,a.second+b.second);}
template<class T, class U>pair<T,U> operator-(pair<T,U> &a, pair<T,U> &b){return pair<T,U>(a.first-b.first,a.second-b.second);}
// Linear STL
// VECTOR
template<class T>istream& operator>>(istream& in, vector<T> &a){for(auto &i: a)cin >> i;return in;}
template<class T>ostream& operator<<(ostream& out, const vector<T> &a){for(auto &i: a)cout << i << " ";return out;}
// SET
template<class T>ostream& operator<<(ostream& out, const set<T> &a){for(auto &i: a)cout << i << " ";return out;}
template<class T>ostream& operator<<(ostream& out, const unordered_set<T> &a){for(auto &i: a)cout << i << " ";return out;}
template<class T>ostream& operator<<(ostream& out, const multiset<T> &a){for(auto &i: a)cout << i << " ";return out;}
// MAP
template<class T,class U>ostream& operator<<(ostream& out, const map<T,U> &a){for(auto &i: a)cout << "(" << i.first << ", " << i.second << "(\n";return out;}
template<class T,class U>ostream& operator<<(ostream& out, const unordered_map<T,U> &a){for(auto &i: a)cout << "(" << i.first << ", " << i.second << "(\n";return out;}

int main() {
    Fast;
    int t=1;
    // cin>>t;
    while(t--){
        int n;
        cin>>n;
        int val=n/500;
        n=n%500;
        val=val*1000;
        val=val+(n/5)*5;
        cout<<val<<endl;
    }
}


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

using namespace std;
using ll = long long;
using ld = long double;
using ull = unsigned long long;
#define all(x) (x).begin(),(x).end()

const int MOD = 998244353;

int add(int a, int b) {
	a += b;
	if (a >= MOD) a -= MOD;
	return a;
}

int sub(int a, int b) {
	a -= b;
	if (a < 0) a += MOD;
	return a;
}

int mul(int a, int b) {
	return (ll) a * b % MOD;
}

const int MAXN = 3010;
int n, s;
int a[MAXN];
int pows[MAXN];

int dp[MAXN];

void solve() {
	cin >> n >> s;
	for (int i = 1; i <= n; i++)
		cin >> a[i];
	int ans = 0;
	for (int i = 0; i < MAXN; i++)
		dp[i] = 0;
	for (int i = 1; i <= n; i++) {
		for (int w = s + 1; w >= 1; w--) {
			int nxt = w + a[i];
			if (nxt > s + 1) nxt = s + 1;
			dp[nxt] = add(dp[nxt], dp[w]);
		}
		int nxt = a[i];
		if (nxt > s + 1) nxt = s + 1;
		dp[nxt] = add(dp[nxt], i);
		ans = add(ans, dp[s]);
	}
	cout << ans << endl;
}

signed main() {
	ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
	cout.precision(20);
	int t;
	//cin >> t;
	t = 1;
	while (t--)
		solve();
	return 0;
}

Measured memory_bytes: 384
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		solve();
	}

	public static void solve() {
		Scanner sc = new Scanner(System.in);

		while (true) {
			int n = sc.nextInt();
			if (n == 0) {
				break;
			}
			int[] tensuu = new int[n];
			for (int i = 0; i < n; i++) {
				tensuu[i] = sc.nextInt();
			}

			int max = tensuu[0];
			int min = tensuu[0];
			int sum = 0;

			for (int j = 1; j < tensuu.length; j++) {
				if (max < tensuu[j]) {
					max = tensuu[j];
				}
				if (min > tensuu[j]) {
					min = tensuu[j];
				}
			}

			for (int t = 0; t < tensuu.length; t++) {
				sum += tensuu[t];
			}

			int ave = (sum - (max + min)) / (tensuu.length - 2);
			System.out.println(ave);
		}
	}

}

Measured memory_bytes: 28960
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
#define F first
#define S second
const ll inf = 1e18;
const string dir = "URDL";
const int dy[] = {1, 0, -1, 0};
const int dx[] = {0, 1, 0, -1};
ll sol1D(vector<pii> & v)
{
    sort(v.begin(), v.end());
    ll ret = inf;
    for (int i = 0; i + 1 < v.size(); ++i) 
        if (v[i].S > 0 && v[i + 1].S < 0)
            ret = min(ret, (v[i + 1].F - v[i].F) / 2ll);
    return ret;
}
ll sol2D(vector<pii> & v)
{
    sort(v.begin(), v.end());
    ll ret = inf;
    for (int i = 0; i + 1 < v.size(); ++i) 
        if (v[i].S == 0 && v[i + 1].S == 1)
            ret = min(ret, ll(v[i + 1].F - v[i].F));
    return ret;
}
int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    int n;
    cin >> n;
    vector<int> x(n), y(n), d(n);
    map<int, vector<pair<int, int>>> my, mx, mRU, mLD, mRD, mLU;
    for (int i = 0; i < n; ++i) {
        char c;
        cin >> x[i] >> y[i] >> c;
        x[i] *= 10;
        y[i] *= 10;
        d[i] = find(dir.begin(), dir.end(), c) - dir.begin();
        if (d[i] % 2)
            my[y[i]].emplace_back(x[i], dx[d[i]]);
        else
            mx[x[i]].emplace_back(y[i], dy[d[i]]);
        if (c == 'R') {
            mRU[x[i] + y[i]].emplace_back(x[i], 0);
            mRD[x[i] - y[i]].emplace_back(x[i], 0);
        }
        if (c == 'U') {
            mRU[x[i] + y[i]].emplace_back(x[i], 1);
            mLU[x[i] - y[i]].emplace_back(x[i], 0);
        }
        if (c == 'L') {
            mLD[x[i] + y[i]].emplace_back(x[i], 1);
            mLU[x[i] - y[i]].emplace_back(x[i], 1);
        }
        if (c == 'D') {
            mLD[x[i] + y[i]].emplace_back(x[i], 0);
            mRD[x[i] - y[i]].emplace_back(x[i], 1);
        }
    }
    ll ans = inf;
    for (auto & p : my)
        ans = min(ans, sol1D(p.second));
    for (auto & p : mx)
        ans = min(ans, sol1D(p.second));
    for (auto & p : mRU)
        ans = min(ans, sol2D(p.second));
    for (auto & p : mLD)
        ans = min(ans, sol2D(p.second));
    for (auto & p : mRD)
        ans = min(ans, sol2D(p.second));
    for (auto & p : mLU)
        ans = min(ans, sol2D(p.second));
    if (ans == inf)
        cout << "SAFE\n";
    else
        cout << ans << endl;
}


Measured memory_bytes: 70404
//#pragma comment(linker, "/STACK:134217728")

#include <iostream>
#include <sstream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <memory>
#include <cctype>
#include <cstring>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <algorithm>
#include <numeric>
using namespace std;

typedef long long Int;
typedef pair<int,int> PII;
typedef vector<int> VInt;

#define FOR(i, a, b) for(i = (a); i < (b); ++i)
#define RFOR(i, a, b) for(i = (a) - 1; i >= (b); --i)
#define CLEAR(a, b) memset(a, b, sizeof(a))
#define SIZE(a) int((a).size())
#define ALL(a) (a).begin(),(a).end()
#define PB push_back
#define MP make_pair

int main()
{
	int a, b, c;
	Int k;
	scanf("%d%d%d%lld", &a, &b, &c, &k);
	printf("%d\n", (k & 1) == 0 ? a - b : b - a);

	return 0;
};


Measured memory_bytes: 256
N = int(input())
S = 0
A = [0 for i in range(N)]
B = [0 for i in range(N)]
for i in range(N):
    A[i], B[i] = map(int, input().split())
for i in range(N):
    S += (-A[N-1-i])%B[N-1-i]
    if i != N-1:
        A[N-2-i]+= S
print(S)


Measured memory_bytes: 15016
import sys,queue,math,copy,itertools,bisect,collections,heapq

def main():
    sys.setrecursionlimit(10**7)
    INF = 10**18
    MOD = 10**9 + 7
    LI = lambda : [int(x) for x in sys.stdin.readline().split()]
    _LI = lambda : [-int(x) for x in sys.stdin.readline().split()]
    NI = lambda : int(sys.stdin.readline())
    SI = lambda : sys.stdin.readline().rstrip()
    DD = ((1,0),(0,1),(-1,0),(0,-1))

    N = NI()
    c = [0] * (10**5+1)
    ans = 0
    for x in sys.stdin.readline().split():
        x = int(x)
        c[x] += 1
        ans += x

    Q = NI()
    for _ in range(Q):
        i,j = LI()
        k = c[i]
        ans += (j-i) * k
        c[j] += k
        c[i] = 0
        print(ans)


if __name__ == '__main__':
    main()

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

#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,s,n) for(int i=(s);i<(n);i++)
#define repr(i,n) for(int i=n-1;i>=0;i--)
#define REPR(i,s,n) for(int i=(s);i>=(n);i--)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define Eunique(v) v.erase(unique(all(v)),v.end())
#define Eback(s) s.erase(s.end()-1,s.end())
#define pb push_back
#define pf push_front
#define mod 1000000007
#define m_p make_pair
#define DOUBLE fixed << setprecision(15)
#define OK puts("OK")
#define OK1 puts("OK1")
#define OK2 puts("OK2")
#define SIZE(s) (int)s.size()
#define INF ((1LL<<62)-(1LL<<31))

typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<double> vd;
typedef long long ll;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef pair<ll,ll> pll;
typedef pair<int,int> pii;
typedef vector<pair<int,int>> vpii;
typedef vector<pair<ll,ll>> vpll;
typedef vector<string> vs;
const double pi = acos(-1.0);

template<class A, class B>
ostream& operator<<(ostream& ost, const pair<A, B>&p) {
	ost << "{" << p.first << ", " << p.second << "} ";
	return ost;
}

template<class T>
ostream& operator<<(ostream& ost, const vector<T>&v) {
	ost << "{";
	for (int i = 0; i<(int)v.size(); i++) {
		if (i)ost << " ";
		ost << v[i];
	}
	ost << "} \n";
	return ost;
}

template<class A, class B>
ostream& operator<<(ostream& ost, const map<A, B>&v) {
	ost << "{";
	for (auto p:v) {
		ost << "{" << p.first << ", " << p.second << "} ";
	}
	ost << "} ";
	return ost;
}

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

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

ll gcd(ll x, ll y) { return (y == 0) ? x : gcd(y, x % y); }
ll lcm(ll x, ll y) { return x * y / gcd(x, y); }

int main()
{
	ll a,b,c;
	cin >> a >> b >> c;
	if(a==b && b==c) cout << "No\n";
	else if(a==b || b==c || a==c) cout << "Yes\n";
	else cout << "No\n";
	return 0;
}

Measured memory_bytes: 256
a, b, k = map(int, input().split())
 
if a < b:
  c = a
else:
  c = b
  
cnt = 0
for i in range(c, 0, -1):
  if a%i == 0 and b%i == 0:
    cnt += 1
  if cnt == k:
    print(i)
    break

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

using namespace std;
using ll = long long;
using P = pair<int, int>;

const ll INF = 1LL << 60;
const int MOD = 1000000007;

int main() {
#ifdef MYLOCAL
    ifstream in("input.txt");
    cin.rdbuf(in.rdbuf());
#endif

    int k, s; cin >> k >> s;
    ll count = 0;
    for (int i = 0; i <= k; ++i) {
        for (int j = 0; j <= k; ++j) {
            int l = s - i - j;
            if (0 <= l && l <= k){
                ++count;
            }
        }
    }
    cout <<  count << endl;
    return 0;
}



Measured memory_bytes: 256
import java.util.*;

class Main {
  	static final int INF = Integer.MAX_VALUE;
	public static void main(String[] args) {
    	Scanner sc = new Scanner(System.in); 
		char[] as = sc.next().toCharArray(), 
			   bs = sc.next().toCharArray(),
			   cs = sc.next().toCharArray();
      
      	int a = 0, b = 0, c = 0;
      	int w = 'a';
      
      	while (true) {
        	switch (w) {
              case 'a':
                if (a == as.length) { System.out.println("A"); return; }
                w = as[a];
                a++;
                break;
              case 'b':
                if (b == bs.length) { System.out.println("B"); return; }
                w = bs[b];
                b++;
                break;
              case 'c':
                if (c == cs.length) { System.out.println("C"); return; }
                w = cs[c];
               	c++;	
                break;
            }
        }
    }
}

Measured memory_bytes: 22608
#include<iostream> 
#include<vector> 
#include<algorithm> 
#include<iomanip> 
#include<stack> 
#include<unordered_map>
#include<queue> 
#include<deque>
#include<map> 
#include<climits>
#include<set> 
#include<string> 
//#include<time.h>
//#include<bits/stdc++.h> 
using namespace std; 
#define lld long long int 
#define eb emplace_back
//to insert pair use eb
#define mp make_pair
#define fi first
#define se second
#define pb push_back

#define X 1000000007
#define Y 998244353
#define E4 10000
#define E5 100000
#define E6 1000000
#define inf 2001001001001001001
#define pi 3.1415926535

# define rec2(i,a,n) for(lld i=a;i<n;i++) 
#define rec(i,n) for(lld i=0;i<n;i++)
#define rev(i,a,n) for(lld i=n-1;i>=a;i--)
#define all(v) (v).begin(), (v).end()
#define large(v)  *max_element(all(v))
#define small(v)  *min_element(all(v)) 
#define v vector 
#define p(x,y)  pair<x,y> 
const double EPS = 1e-6;

void google(int i)
{  cout<<"Case #"<<i<<": "; }

//prime sieve if needed 
//prime factors of number
lld prime[E6+1]; 
void sieve(lld n) 
{ rec(i,n+1) 
    prime[i]=1; 
   for(lld i=2;i*i<=n;i++) 
     { if(prime[i]!=1) 
          continue; 
         for(lld j=i*i;j<=n;j=j+i) 
          if(prime[i]==1)
           prime[j]=i; 
      }
}

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

//fermat a^(m-2)%mod
lld binarymul(lld a,lld n,lld m)
{  lld res=1; 
 while(n) 
  { if(n%2) 
      { res=(res*a)%m; 
         n--; 
      } 
     a=(a*a)%m; 
     n/=2; 
  }
  return res; 
}
/*
void complexity(time_t end,time_t start)
{ 
  double taken = double(end - start); 
    cout<<"Time : "; 
    cout<<fixed<<taken<<setprecision(8);         cout<<" sec "<<endl;
}
*/ 
void bfs(lld s,v<lld> g[],lld n)
{ 
   bool vis[n]; 
   rec(i,n) 
    vis[i]=false; 
    
   vis[s]=true; 
   deque<lld> q; 
   q.pb(s); 
   
   while(!q.empty()) 
   {  
      s=q.front(); 
     q.pop_front(); 
      
     for(lld i=0;i<g[s].size();i++) 
      {  
        if(!vis[g[s][i]])
         { vis[g[s][i]]=true; 
            q.pb(g[s][i]); 
         }
      }
   }
}

void dfs(lld u,v<lld> g[],bool *vis)
{ 

   vis[u]=true; 
   for(lld i=0;i<g[u].size();i++) 
     if(!vis[g[u][i]])
          dfs(g[u][i],g,vis); 
       
}
void contest(lld t); 
int main()
{   
    /*
    time_t start, end; 
    time(&start); 
    */
   ios_base::sync_with_stdio(false); 
   cin.tie(0);
     #ifdef PUNEET_GOEL
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
    #endif
   //sieve(E6); 
    lld T=1; 
   // cin>>T;
    rec(t,T) 
    {
      contest(t); 
    }
    /*
     time(&end); 
    complexity(end,start);
    */
	return 0;
}

void contest(lld t)
{ 
  lld n,ans=0; 
  cin>>n; 
  lld a[n],b[n]; 
  
   rec(i,n)
  cin>>a[i]; 
  
  b[0]=a[0];
   for(lld i=1;i<n;i++) 
   b[i]=b[i-1]+a[i]; 
 
  rec(i,n) 
  { 
    lld x=(b[n-1]-b[i]+X)%X; 
      x=(a[i]*x)%X; 
    ans+=x ;  
    ans%=X; 
  } 
  cout<<ans<<endl; 
}

Measured memory_bytes: 6760
import java.io.*;
import java.math.*;
import java.util.*;
public class Main { 
 
	public static void main(String[] args) { 
		FastScanner I = new FastScanner(); //Input
		OutPut O = new OutPut(); //Output
		int N = I.nextInt();
		long[] dp = new long[87];
		dp[0]=2;
		dp[1]=1;
		for (int i = 2; i <= 86; i++) dp[i]=dp[i-1]+dp[i-2];
		O.pln(dp[N]);
	}
	public static ArrayList<String> perms(int N,int limit){
		if (N==1) {
			ArrayList<String> ret = new ArrayList<String>();
			for (int i = 0; i < limit; i++) {
				 ret.add(Integer.toString(i));
			}
			return ret;
		}
		ArrayList<String> prev = perms(N-1,limit);
		ArrayList<String> ret = new ArrayList<String>();
		for (int i = 0; i < prev.size(); i++) {
			String cur = prev.get(i);
			boolean[] vis = new boolean[10];
			for (int j = 0; j < cur.length(); j++) {
				int dig = Integer.parseInt(cur.substring(j,j+1));
				vis[dig]=true;
			}
			if (!vis[1]) {
				for (int next = 0; next < limit; next++) {
					if (!vis[next]) {
						String add = cur;
						add+=Integer.toString(next);
						ret.add(add);
					}
				}
			}else ret.add(cur); //Just use previous end on 1 sequence	
		}
		return ret;
	}
	public static long ceil(long num, long den) {long ans = num/den; if (num%den!=0) 
	ans++; return ans;}
	public static long GCD(long a, long b) {
		if (a==0||b==0) return Math.max(a,b);
		return GCD(Math.min(a, b),Math.max(a, b)%Math.min(a, b));
	}
	public static long FastExp(long base, long exp, long mod) {
		long ans=1;
		while (exp>0) {
			if (exp%2==1) ans*=base;
			exp/=2;
			base*=base;
			base%=mod;
			ans%=mod;
		}
		return ans;
	}
	public static long ModInv(long num,long mod) {return FastExp(num,mod-2,mod);}
	static class FastScanner {
		BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
		StringTokenizer st=new StringTokenizer("");
		String next() {
			while (!st.hasMoreTokens())
				try {
					st=new StringTokenizer(br.readLine());
				} catch (IOException e) {
					e.printStackTrace();
				}
			return st.nextToken();
		}
		int nextInt() {return Integer.parseInt(next());}
		long nextLong() {return Long.parseLong(next());};
	}
	static class OutPut{
		PrintWriter w = new PrintWriter(System.out);
		void pln(double x) {w.println(x);w.flush();}
		void pln(int x) {w.println(x);w.flush();}
		void pln(long x) {w.println(x);w.flush();}
		void pln(String x) {w.println(x);w.flush();}
		void pln(char x) {w.println(x);w.flush();}
		void pln(StringBuilder x) {w.println(x);w.flush();}
		void p(int x) {w.print(x);w.flush();}
		void p(long x) {w.print(x);w.flush();}
		void p(String x) {w.print(x);w.flush();}
		void p(char x) {w.print(x);w.flush();}
		void p(StringBuilder x) {w.print(x);w.flush();}
	}
}


Measured memory_bytes: 25396
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0; i < n; i++)
#define REP(i,s,n) for(int i = s; i < n; i++)
#define all(x) (x).begin(),(x).end()
typedef long long ll;
using Graph = vector<vector<pair<int,int>>>;
ll gcd(ll a, ll b) { return b ? gcd(b, a%b) : a; }
int main(){
  ll n,k;
  cin >> n >> k;
  vector<ll>cnt(100001);
  rep(i,n){
    ll a,b;
    cin >> a >> b;
    cnt[a] += b;
  }
  ll cn = 0;
  REP(i,1,100001){
    if(cn <= k && k <= (cn + cnt[i])){
      cout << i << endl;
      return 0;
    }
    cn += cnt[i];
  } 
  return 0;
}


Measured memory_bytes: 4044
#include <bits/stdc++.h>
using namespace std;
int main()
{
	int x,y,a,b,c;cin>>x>>y>>a>>b>>c;
	int t1[a];for(int &i:t1) cin>>i; sort(t1,t1+a,greater<int>());
	int t2[b];for(int &i:t2) cin>>i; sort(t2,t2+b,greater<int>());
	int t3[c];for(int &i:t3) cin>>i; sort(t3,t3+c,greater<int>());
 
	map<int,int> p,q;
	for(int i=0;i<x;i++) ++p[t1[i]];
	for(int i=0;i<y;i++) ++q[t2[i]];

	for(int i:t3){
		int p_mi=p.begin()->first;
		int q_mi=q.begin()->first;
		if(i>p_mi||i>q_mi){
			if(p_mi<q_mi){
				++p[i];
				--p[p_mi];
				if(p[p_mi]==0) p.erase(p_mi);
			}else{
				++q[i];
				--q[q_mi];
				if(q[q_mi]==0) q.erase(q_mi);
			}
		}
	}

	long long sum=0;
	for(auto i:p) sum+=1LL*(i.first)*(i.second);
	for(auto i:q) sum+=1LL*(i.first)*(i.second);
	cout<<sum;
	return 0;
}

Measured memory_bytes: 11904
#include<bits/stdc++.h>
#define int long long
#define f(i,n) for(int i=0;i<n;i++)
#define F first
#define S second
#define mod 1000000007
#define P pair<int,int>
using namespace std;
int x[20];
signed main(){
	int a,b,c,ans=0;
	cin>>a>>b>>c;
	f(i,b){
		cin>>x[i];
	}
	f(i,a){
		int e=0,sum=0;
		f(j,b){
			cin>>e;
			sum+=e*x[j];
		}
		if(sum+c>0) ans++;
	}
	cout<<ans<<endl;
}


Measured memory_bytes: 256
//$g++ -std=c++11 Template.cpp 

//#include <bits/stdc++.h>
#include <iostream>
#include <complex>
#include <sstream>
#include <string>
#include <algorithm>
#include <deque>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <vector>
#include <set>
#include <limits>
#include <cstdio>
#include <cctype>
#include <cmath>
#include <cstring>
#include <cstdlib>
#include <ctime>
#include <climits>
#define REP(i, n) for(int i = 0; i < (int)(n); i++)
#define FOR(i, j, k) for(int i = (int)(j); i < (int)(k); ++i)
#define ROF(i, j, k) for(int i = (int)(j); i >= (int)(k); --i)
#define FORLL(i, n, m) for(long long i = n; i < (long long)(m); i++)
#define SORT(v, n) sort(v, v+n)
#define REVERSE(v) reverse((v).begin(), (v).end())

using namespace std;
using ll = long long;
const ll MOD=1000000007LL;
typedef pair<int, int> P;

ll ADD(ll x, ll y) { return (x+y) % MOD; }
ll SUB(ll x, ll y) { return (x-y+MOD) % MOD; }
ll MUL(ll x, ll y) { return x*y % MOD; }
ll POW(ll x, ll e) { ll v=1; for(; e; x=MUL(x,x), e>>=1) if (e&1) v = MUL(v,x); return v; }
ll DIV(ll x, ll y) { /*assert(y%MOD!=0);*/ return MUL(x, POW(y, MOD-2)); }

priority_queue<int> q_descending;
priority_queue<int, vector<int>, greater<int> > q_ascending;

int
main(void){  
  ios_base::sync_with_stdio(false);

  int n, k;
  cin >> n >> k;
  int a[n];
  REP(i, n) cin >> a[i];

  /*
  int itr = 0;
  REP(i, n){
    if(a[i] == 1){
      itr = i;
    }
  }
  */

  double dtmp = (double)(n-1)/(k-1);
  //cout << dtmp << endl;
  
  int ans = ceil(dtmp);

  cout << ans << endl;

  

  
  return 0;
}


Measured memory_bytes: 640
dx = [-1,0,1,0]; dy = [0,-1,0,1];
while 1:
    w,h = map(int, raw_input().split())
    if w==h==0: break;
    m = []; s = []; sx = sy = 0;
    m.append('#'*(w+2))
    for i in range(h):
        m.append("#"+raw_input()+"#")
    m.append('#'*(w+2))
    f = [[0 for i in range(w+2)] for j in range(h+2)]
    for i in range(1,h+1):
        for j in range(1,w+1):
            if m[i][j]=='@':
                sx = j; sy = i;
    s.append([sx,sy]);
    f[sy][sx] = 1; ans = 1;
    while len(s)>0:
        x,y = s.pop(0)
        for k in range(4):
            if m[y+dy[k]][x+dx[k]]!='#' and f[y+dy[k]][x+dx[k]]==0:
                s.append([x+dx[k],y+dy[k]])
                f[y+dy[k]][x+dx[k]] = 1; ans += 1;
    print ans

Measured memory_bytes: 4308
N=int(input())
C=str(N)
ans=0
j=9
for i in range(len(C)):
    if (i+1)%2!=0:
        if len(C)!=i+1:
            ans+=j
        else:
            if N%10!=0:
                ans+=N-10**i+1
            else:
                ans+=1
    j=9*(10**(i+1))
print(ans)

Measured memory_bytes: 3060
function main(input){
  input = input.split('\n');
  const k = Number(input[0]);
  const s = input[1];
  
  if(s.length <= k){
    console.log(s);
  }else{
    console.log(s.slice(0, k) + '...');
  }
  
}

main(require('fs').readFileSync('/dev/stdin', 'utf8').trim());

Measured memory_bytes: 29588
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <map>
#include <unordered_map>
#include <math.h>
#include <stdio.h>
#define INF 1000000000
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
typedef long long int ll;
using namespace std;

int main() {

	int a, b, c; cin >> a >> b >> c;
	if (c - (a - b) < 0) { cout << 0 << endl; }
	else cout << c - (a - b) << endl;

	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
 
using namespace std;
 
int main() 
{
    ios::sync_with_stdio(false);

    int n, x, m = 1000, b, s;
    cin >> n >> x;
    s= n;

    while (n--)
    {
        cin >> b;
        if (b < m) m = b;
        x -= b;
    }

    s = s + x/m;

    cout << s << endl;

    return 0;
}


Measured memory_bytes: 3620
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <algorithm>
#include <string>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <stack>
#include <queue>
#define llong long long
#define INF (__INT32_MAX__ / 2)
#define EPS 10e-8
#define MAX_N 500

using namespace std;
typedef pair<int, int> ipair;
llong modulo(llong left, llong right) { return (left % right + right) % right; }

int N, M, Q;
int trains[MAX_N][MAX_N];
int sum[MAX_N][MAX_N];
int main() {
    cin >> N >> M >> Q;
    for(int i = 0; i < M; ++i) {
        int L, R;
        cin >> L >> R;
        trains[L - 1][R - 1]++;
    }

    //累積和
    for(int i = 0; i < N; ++i)
        for(int j = 0; j < N; ++j) {
            sum[i][j] = trains[i][j];
            if(i > 0)
                sum[i][j] += sum[i - 1][j];
            if(j > 0)
                sum[i][j] += sum[i][j - 1];
            if(i * j > 0)
                sum[i][j] -= sum[i - 1][j - 1];
        }
    
    for(int i = 0; i < Q; ++i) {
        int p, q;
        cin >> p >> q;
        int res = sum[q - 1][q - 1];
        if(p > 1)
            res += - sum[p - 2][q - 1] - sum[q - 1][p - 2] + sum[p - 2][p - 2];
        cout << res << endl;
    }
    
}

Measured memory_bytes: 2816
#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();
    cout << *it_first_item;
    for (auto it = ++it_first_item; it != s.end(); it++) {
        cout << ", " << *it;
    }
    return cout << "}";
}

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();
    cout << *it_first_item;
    for (auto it = ++it_first_item; it != s.end(); it++) {
        cout << ", " << *it;
    }
    return cout << "}";
}

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();
    cout << it_first_item->first << ": " << it_first_item->second;
    for (auto it = ++it_first_item; it != m.end(); it++) {
        cout << ", " << 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();
    cout << it_first_item->first << ": " << it_first_item->second;
    for (auto it = ++it_first_item; it != m.end(); it++) {
        cout << ", " << 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;
}

int main() {
    cin.tie(0); cout.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(10);
    lint N, M, K; cin >> N >> M >> K;
    range(i, 0, N + 1) range(j, 0, M + 1) {
        lint num_blacks = i * (M - j) + (N - i) * j;
        if (num_blacks == K) {
            cout << "Yes" << "\n";
            return 0;
        }
    }
    cout << "No" << "\n";
}

Measured memory_bytes: 256
#include <algorithm>
#include <bitset>
#include <cassert>
#include <chrono>
#include <climits>
#include <cmath>
#include <complex>
#include <cstring>
#include <deque>
#include <functional>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <unordered_map>
#include <unordered_set>
#include <vector>
#include <cstdint>
using namespace std;
typedef long long ll;
#define MP make_pair
#define PB push_back
#define inf (1LL<<60)
#define mod 1000000007
#define rep(i,n) for(int i = 0; i < (int)(n); ++i)

int main(){
    ll n,x;
    cin >> n >> x;
    vector<ll> b(n),l(n),u(n);
    rep(i,n){
        cin >> b[i] >> l[i] >> u[i];
    }
    ll sm = 0;
    rep(i,n){
        sm += b[i]*l[i];
    }
    vector<pair<pair<ll,ll>,pair<ll,ll> > > v;
    rep(i,n){
        v.push_back(MP(MP(l[i]*b[i]+u[i]*(x-b[i]),b[i]),MP(l[i],u[i])));
    }
    sort(v.begin(),v.end(),greater<pair<pair<ll,ll>,pair<ll,ll> > >());
    ll sk = 0;
    ll sk2 = 0;
    ll k = 0;
    rep(i,n){
        ll val = v[i].first.first;
        if(sk+val==sm){
            cout << x*(k+1) << endl;
            return 0;
        }
        if(sk+val>sm){
            sk2 = sk + val;
            break;
        }else{
            sk += val;
            k++;
        }
    }
    ll mi = inf;
    rep(i,n){
        ll res = x*k;
        ll val = v[i].first.first;
        ll B = v[i].first.second;
        ll L = v[i].second.first;
        ll U = v[i].second.second;
        if(i<k){
            ll s = sk2 - val;
            ll c = sm - s;
            if(c <= B*L){
                res += (c+L-1)/L;
            }else{
                res += B + (c-B*L+U-1)/U;
            }
            mi = min(mi,res);
        }else{
            if(sk + val < sm)continue;
            ll s = sk;
            ll c = sm - s;
            if(c <= B*L){
                res += (c+L-1)/L;
            }else{
                res += B + (c-B*L+U-1)/U;
            }
            mi = min(mi,res);


        }
    }
    cout << mi << endl;
    return 0;
}

Measured memory_bytes: 8816
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time

sys.setrecursionlimit(10**7)
inf=10**20
mod=10**9+7

def LI(): return list(map(int,input().split()))
def I(): return int(input())
def LS(): return input().split()
def S(): return input()

def main():
  n=S()

  f=False
  for i in range(1,len(n)):
    if n[i]!='9':
      f=True

  if f:
    return int(n[0])-1+9*(len(n)-1)
  else:
    return int(n[0])+9*(len(n)-1)

print(main())

Measured memory_bytes: 5420
n = int(input())
a = list(map(int, input().split()))

ans = 0
sigma = 0
r = 0
for l in range(n):
    while r < n and sigma + a[r] == sigma ^ a[r]:
        sigma += a[r]
        r += 1
    ans += r - l
    if l == r:
        r += 1
    else:
        sigma -= a[l]

print(ans)

Measured memory_bytes: 77772
N = int(input())
W = [int(i) for i in input().split()]
ans = 1000
for i in range(1, N):
    tmp = abs(sum(W[:i]) - sum(W[i:]))
    # スライスで区切って和をとる，最小値を更新していく
    if ans > tmp:
        ans = tmp
print(ans)

Measured memory_bytes: 3060
n = input()
k = int(input())

l = len(n)
dp = [[[0 for _ in range(k+1)] for j in range(2)] for i in range(l+1)]
dp[0][0][0] = 1

for i in range(l):
    for j in range(2):
        for m in range(k+1):
            ni = int(n[i])
            if j == 0:
                for num in range(ni+1):
                    if num == ni:
                        if ni == 0:
                            dp[i+1][0][m] += dp[i][j][m]
                        else:
                            if m+1 <= k:
                                dp[i+1][0][m+1] += dp[i][j][m]
                    else:
                        if num == 0:
                            dp[i+1][1][m] += dp[i][j][m]
                        else:
                            if m+1 <= k:
                                dp[i+1][1][m+1] += dp[i][j][m]
            else:
                for num in range(10):
                    if num == 0:
                        dp[i+1][1][m] += dp[i][j][m]
                    else:
                        if m+1 <= k:
                            dp[i+1][1][m+1] += dp[i][j][m]



print(dp[l][0][k] + dp[l][1][k])

Measured memory_bytes: 40688
n = int(input())
list = []
for i in range(3, n + 1):
    if i % 3 == 0:
        list.append(i)
    else:
        x = i
        while x:
            if x % 10 == 3:
                list.append(i)
                break
            else:
                x = x // 10
print("", *list)


Measured memory_bytes: 5976
from collections import deque
def main():

    s = deque(input())

    

    ans = 0
    while len(s)>1:
        if s[0]==s[-1]:
            s.popleft()
            s.pop()
            continue
        if s[0]!='x' and s[-1]!='x':
            ans = -1
            break
        if s[0]=='x':
            ans+=1
            s.popleft()
        if s[-1]=='x':
            ans+=1
            s.pop()
    
    print(ans)

if __name__ == "__main__":
    main()

Measured memory_bytes: 4212