akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <iomanip>
#include <cmath>
#include <string>
#include <vector>
#include <cstdlib>
#include <map>
#include <queue>
#include <deque>
#include <algorithm>
#include <stack>
#include <functional>
#include <sstream>
#define rep(i,j,n) for(i=j;i<(n);i++)
#define rrep(i,j,n) for(i=j;i>(n);i--)
typedef long long int lli;
#define N 1000000007
#define M 998244353

using namespace std;

int main(){
    lli n,k,r,s,p,sum=0;
    string t;
    vector<string> ans;
    lli i,j;
    cin>>n>>k>>r>>s>>p>>t;
    rep(i,0,n){
        if(i<k){
            ans.push_back(t.substr(i,1));
        }
        else{
            ans[i%k]+=t.substr(i,1);
        }
    }
    rep(i,0,ans.size()){
        vector<vector<lli>> dp;
        dp.assign(ans[i].size(),vector<lli>(3,0));
        rep(j,0,ans[i].size()){
            switch(ans[i][j]){
                case 'r':dp[j][2]=p;break;
                case 's':dp[j][0]=r;break;
                case 'p':dp[j][1]=s;break;
            }
            if(j>0){
                dp[j][0]+=max(dp[j-1][1],dp[j-1][2]);
                dp[j][1]+=max(dp[j-1][0],dp[j-1][2]);
                dp[j][2]+=max(dp[j-1][1],dp[j-1][0]);
            }
        }
        sum+=max({dp[j-1][0],dp[j-1][1],dp[j-1][2]});
    }
    cout<<sum<<endl;
}


Measured memory_bytes: 5888
a,b=map(int,input().split())


if (a==1or a==3 or a==5 or a==7 or a==8 or a==10 or a==12) and (b==1or b==3 or b==5 or b==7 or b==8 or b==10 or b==12):
    print("Yes")
elif (a==4 or a==6 or a==9 or a==11) and (b==4 or b==6 or b==9 or b==11):
    print("Yes")
else:
    print("No")
    

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

using namespace std;

int main()
{
    int n;
    cin >> n;
    vector<int> a(n);
    for(int i = 0; i < n; i++)
    {
        cin >> a[i];
    }
    int count = 0;
    for(int i = 1; i < n - 1; i++)
    {
        if((a[i] < a[i - 1] && a[i] > a[i + 1]) || (a[i] > a[i - 1] && a[i] < a[i + 1]))
        {
            count++;
        }
    }
    cout << count;

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int, int> P;
typedef pair<ll, ll> Pll;
using Graph = vector<vector<int>>;
using Graphl = vector<vector<ll>>;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define Rep(i, k, n) for (int i = k; i < (int)(n); i++)
#define RRep(i, k, n) for (int i = k; i > (int)(n); i--)
#define FOR(itr, v) for (auto itr = (v).begin(); itr != (v).end(); ++itr)
#define COUT(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << endl
#define ALL(a)  (a).begin(),(a).end()
#define rALL(a)  (a).rbegin(),(a).rend()
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 T> void PrintVector(const vector<T> &vec) {for (auto val : vec) cout << val << " "; cout << endl;}
const long long INF = 1LL << 60;
const long long minusINF = -(1LL << 40);
const int MOD = 1000000007;
const double PI = acos(-1); //3.14~
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};

vector<ll> divisor(ll n)
{
    vector<ll> ret;
    for (ll i = 1; i * i <= n; i++)
    {
        if (n % i == 0)
        {
            ret.push_back(i);
            if (i * i != n) ret.push_back(n / i);
        }
    }
    sort(ret.begin(), ret.end()); // 昇順に並べる
    return ret;
}

int main()
{
    ll n; cin >> n;
    vector<ll> a(n);
    vector<ll> used(1000010, 0);
    rep(i, n)
    {
        cin >> a[i];
        used[a[i]]++;
    }

    ll ans = 0;
    rep(i, n)
    {
        vector<ll> b = divisor(a[i]);
        int f = 1;
        for (auto it : b)
        {
            if ((used[it] > 0 && it < a[i]) || (used[it] > 1 && a[i] == it))
            {
                f = 0;
                break;
            }
        }
        if (f) ans++;
    }
    cout << ans << endl;
}

Measured memory_bytes: 12664
package main

import (
	"bufio"
	"fmt"
	"os"
	"strings"
)

func main() {
	S := readLine()

	v := (len(S) + 3) / 2
	if !ReverseCheck(S) {
		goto Fail
	}
	if !ReverseCheck(S[:(len(S)-1)/2]) {
		goto Fail
	}
	if !ReverseCheck(S[v-1:]) {
		goto Fail
	}

	fmt.Println("Yes")
	return
Fail:
	fmt.Println("No")
}

func ReverseCheck(s string) bool {
	sa := strings.Split(s, "")

	for i := 0; i < len(sa); i++ {
		if sa[i] != sa[len(sa)-i-1] {
			return false
		}
	}
	return true
}

/////////////////////////////////////////

//func readLineInt() []int {
//	result := make([]int, 0)
//	for _, v := range strings.Split(readLine(), " ") {
//		i, _ := strconv.Atoi(v)
//		result = append(result, i)
//	}
//	return result
//}

var reader = bufio.NewReaderSize(os.Stdin, 1e6)

func readLine() string {
	result := make([]byte, 0, 1e6)
	for {
		line, remains, e := reader.ReadLine()
		if e != nil {
			panic(e)
		}
		result = append(result, line...)
		if !remains {
			break
		}
	}
	return string(result)
}


Measured memory_bytes: 640
#include<bits/stdc++.h>
    #include<ext/pb_ds/assoc_container.hpp>
    #include<ext/pb_ds/tree_policy.hpp>
    using namespace __gnu_pbds;
    using namespace std;
    template <typename T>
    using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
    # define ll long long
    # define int long long  //comment it out when MLE
    //# define endl "\n"
    #define gok ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    //# define m 163577857
    # define mo 1000000007
    # define pi acos(-1)
    # define fi first
    # define se second
    #define REP(i,n) for (int i = 1; i <= n; i++)
    const ll mod = 998244353;
    //const int K = 2;
    //typedef vector<vector<int> > matrix;
    /*
    int add(int a, int b,int mod) {
        a%=mod;
        b%=mod;
        a += b;
        if (a >= mod) a -= mod;
        if(a<0)
        {
            a += mod;
            a %= mod;
        }
        return a;
    }

    int mul(ll a, int b,int mod) {
        a%=mod;
        b%=mod;
        a *= b;
        a += mod;
        return a % mod;
    }
    int po(int a,int b,int mod)
    {
        if(b==0)
            return 1;
        if(b%2==0)
            return po(mul(a,a,mod),b/2,mod);
        return mul(a,po(mul(a,a,mod),(b-1)/2,mod),mod);
    }


    ll fact[1000003];
    ll inv[1000003];

    void fact0()
    {
        int i,j;
        fact[0]=1;
        for(i=1;i<=600000;i++)
        {
            fact[i]=i*fact[i-1]%mod;
        }
        inv[0]=1;
        inv[1]=1;
        ll p=mod;
        for (i=2; i<=600000; i++)
            inv[i] = (p - (p/i) * inv[p%i] % p) % p;

        for(i=2;i<=600000;i++)
        {
            inv[i]*=inv[i-1];
            inv[i]%=mod;
        }
    }
    int help(int a,int b)
    {
       // cout<<a<<" "<<b<<endl;
        int an = fact[a];
        //cout<<an<<endl;
        an *= inv[b];
        an %= mod;
        an *= inv[a-b];
        an %= mod;
        return an;
    }
    */

signed main(){
       gok

   string s;
   cin>>s;
   for(int i=0;i<s.size();)
   {
       if(s[i]=='?')
       {
           if(i!=0 && s[i-1]=='P')
           {
               s[i]='D';
           }
           else if(i!=s.size()-1 && s[i+1]=='D')
           {
               s[i]='P';
           }
           else if(i!=s.size()-1 && s[i+1]=='?')
           {
               s[i]='P';
               s[i+1]='D';
               i++;
           }
           else
           s[i]='D';
       }
       i++;
   }
   cout<<s;




















        return 0;
    }


Measured memory_bytes: 3768
//include
//------------------------------------------
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <climits>
#include <queue>

using namespace std;

//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;

//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())

//repetition
//------------------------------------------
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)

//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI  = acos(-1.0);

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

  int K; double R, L; cin >> K >> R >> L;
  double P, E, T; cin >> P >> E >> T;
  typedef tuple<double,double,double> TD;
  queue<TD> q[2];
  double ans = 0.;
  int crt = 0, nxt = 1;
  q[crt].push(TD(1., R, L));
  REP(k,K){
	while(!q[crt].empty()){
	  double p, r, l;
	  tie(p, r, l) = q[crt].front(); q[crt].pop();
	  double H = (r + l) / 2.;
	  if(T-E <= r && l <= T+E){
		ans += p;
		continue;
	  }
	  else if(l < T-E || T+E < r)
		continue;
	  
	  if(H >= T){
		q[nxt].push(TD(p*(1-P), r, H));
		q[nxt].push(TD(p*P, H, l));
	  }
	  else{
		q[nxt].push(TD(p*P, r, H));
		q[nxt].push(TD(p*(1-P), H, l));
	  }
	}
	swap(crt, nxt);
  }

  while(!q[crt].empty()){
	double p, r, l;
	tie(p, r, l) = q[crt].front(); q[crt].pop();	 
	if(abs((r+l)/2. -T) <= E)
	  ans += p;
  }
  cout << fixed << setprecision(9) << ans << endl;

  return 0;
}

Measured memory_bytes: 1308
#include <algorithm>
#include <cstdint>
#include <iostream>
#include <string>
#include <vector>
using namespace std;

#define REP(i, n) for (int i = 0; i < (int)(n); ++i)
#define FOR(i, a, b) for (int i = (int)(a); i < (int)(b); ++i)
#define ALL(c) (c).begin(), (c).end()

inline int digit_to_int(char c) {
    return c - '0';
}

int main() {
    string S; cin >> S;

    string R = S;
    reverse(ALL(R));

    vector<int> M(S.size() + 1);
    M[0] = 0;
    int mag = 1;
    FOR(i, 1, M.size()) {
        M[i] = (M[i-1] + digit_to_int(R[i-1]) * mag) % 2019;
        mag = (10 * mag) % 2019;
    }

    vector<int> freq(2019);
    REP(i, M.size()) {
        freq[M[i]]++;
    }

    int64_t ans = 0;
    REP(i, freq.size()) {
        int64_t f = freq[i];
        ans += f * (f - 1) / 2;
    }

    cout << ans << endl;
}


Measured memory_bytes: 4384
#include <stdio.h>

int main(void) {
  int i, j, n, m;
  while ( 1 ) {
    scanf("%d%d", &n, &m);
    if(!n && !m) break;
    char flag[n];
    for(i = 0; i < n; ++i) flag[i] = 0;
    int a[m], b[m];
    for(i = 0; i < m; ++i) {
      scanf("%d%d", &a[i], &b[i]);
      a[i]--, b[i]--;
      if(!a[i]) flag[b[i]] = 1;
      if(!b[i]) flag[a[i]] = 1;
    }
    flag[0] = 1;
    for(i = 1; i < n; ++i) {
      if(flag[i] == 1)
      for(j = 0; j < m; ++j) {
        if(a[j] == i && !flag[b[j]]) flag[b[j]] = 2;
        if(b[j] == i && !flag[a[j]]) flag[a[j]] = 2;
      }
    }
    int ans = -1;
    for(i = 0; i < n; ++i) if(flag[i]) ++ans;
    //for(i = 0; i < n; ++i) printf("%d ", flag[i]);
    printf("%d\n", ans);
  }
  return 0;
}


Measured memory_bytes: 2756
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n)for(int i=0;i<(n);i++)
#define ALL(a) (a).begin(), (a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define pb push_back
using ll = long long;
using P = pair<int, int>;

int main(){
    int n, k; cin >> n >> k;
    vector<int> x(n);
    rep(i,n) cin >> x[i];
    int ans = 1001001001;
    for(int i = 0; i < n - k + 1; ++i){
        int lid = i;
        int rid = i + k - 1;
        int tmp = 0;
        if(x[rid] <= 0){
            tmp = abs(x[lid]);
        }else if(x[lid]>=0){
            tmp = x[rid];
        }else{
            int time1 = abs(x[lid]) + abs(x[rid] - x[lid]);
            int time2 = x[rid] + abs(x[lid] - x[rid]);
            tmp = min(time1, time2);
        }
        ans = min(ans, tmp);
    }
    cout << ans << endl;
}

Measured memory_bytes: 640
<?php
// abc079_d
list($h, $w) = ints();
for ($i = 0; $i < 10; ++$i)
    foreach (ints() as $j => $v) $cost[$i][$j] = $v;
for ($i = 0; $i < 10; ++$i) $d[$i] = dijkstra($i, 10);
$ans = 0;
for ($i = 0; $i < $h; ++$i)
    foreach (ints() as $v) $ans += $v !== -1 ? $d[$v][1] : 0;
echo $ans;

function ints()
{
    return array_map('intval', explode(' ', trim(fgets(STDIN))));
}

// ノードsからの各ノードへの最短距離
function dijkstra($s, $n)
{
    global $cost, $root;
    $d = array_fill(0, $n, INF);
    $d[$s] = 0;
    $root[$s] = array_fill(0, $n, [$s]); // 各ノードまでの最短経路を格納
    $used = array_fill(0, $n, false);
    while (true) {
        $v = -1;
        // 残りのノードのうち最短で到達出来るノードを選択
        for ($i = 0; $i < $n; ++$i) {
            if (!$used[$i] && $v === -1) $v = $i;
            elseif (!$used[$i] && $d[$i] < $d[$v]) $v = $i;
        }
        if ($v === -1) break;
        for ($i = 0; $i < $n; ++$i) {
            if ($d[$v] + $cost[$v][$i] < $d[$i]) {
                $d[$i] = $d[$v] + $cost[$v][$i];
                $root[$s][$i] = array_merge($root[$s][$v], [$i]);
            }
        }
        $used[$v] = true;
    }
    return $d;
}


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

int main(){
    long long int x;
    cin >> x;
    
    // double l = log(100 * x) / log(1.01);

    int i = 0;
    for(long long int a = 100; a < x; a *= 1.01){
        i++;
    }
    cout << i << endl;
    
    return 0;
}

Measured memory_bytes: 3648
import java.util.*;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);

		int a = sc.nextInt();
		int b = sc.nextInt();
		int c = sc.nextInt();
		int k = sc.nextInt();

		for ( int i=0; i<k; i++ ) {
			if ( a>=b )  b *= 2;
			else if ( b>=c )  c *= 2;
		}

		if ( a<b && b<c ) {
			System.out.println("Yes");
		} else {
			System.out.println("No");
		}
	}
}

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

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

fn main() {
    let input = read_stdin();
    let tokens = &mut input.split_whitespace();
    let n: usize = scan(tokens);
    let mut count: Vec<Vec<usize>> = vec![vec![0; 10]; 10];
    for i in 1..n + 1 {
        count[first(i)][last(i)] += 1;
    }
    let mut ans = 0;
    for i in 0..10 {
        for j in 0..10 {
            ans += count[i][j] * count[j][i];
        }
    }
    println!("{}", ans);
}

fn first(n: usize) -> usize {
    let mut n = n;
    while n >= 10 {
        n /= 10;
    }
    n
}

fn last(n: usize) -> usize {
    n % 10
}


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

// Macros
#define F  first
#define S  second
#define PB push_back

// Rename Datatypes
using ll  = long long;
using ld  = long double;
using pii = pair<int,int>;

// Common Functions
ll fastpow(ll a, ll ex){ ll res = 1; while(ex){ if(ex & 1) res *= a; a *= a; ex >>= 1; } return res; }
ll fastpow(ll a, ll ex, ll m){ a %= m; ll res = 1; while(ex){ if(ex & 1) res = (a*res) % m; a = (a*a) % m; ex >>= 1; } return res; }
ll modinverse(ll a, ll m){ ll m0 = m, y = 0, x = 1; while (a > 1){ ll q = a / m; a %= m; swap(a,m); x -= q*y; swap(x,y); } if(x < 0) x += m0; return x; }

// HELPERS
//  Tedious Grid Movements
vector<pii> moves_grid = { {0,1} , {0,-1} , {1,0} , {-1,0} };
inline bool move_okay(int x, int y, int n, int m) { return 0 <= x and x < n and 0 <= y and y < m; }
//  Remember:
//   * vec.assign() GOOD; vec.resize() BAD
//   * comparator uses <

// Output, Common Containers
template <typename T> ostream& operator << (ostream &os, const vector<T> &v) { for (T i : v) os << i << ' '; return os; }
template <typename T> ostream& operator << (ostream &os, const set<T> &v)    { for (T i : v) os << i << ' '; return os; }
template <typename T, typename S> ostream& operator << (ostream &os, const pair<T,S> &v) { os << "(" << v.F << "=>" << v.S << ") "; return os; }
template <typename T, typename S> ostream& operator << (ostream &os, const map<T,S> &v)  { for (auto i : v) os << i << ' '; return os; }

// Debugging
#ifdef SANYAM1101
	#define trace(args...) do{ cerr << "TRACE ON! (Line: " << __LINE__ << ")\n"; auto _stream = istringstream{string{#args}}; d_f(_stream, args); } while(0)
	void d_f(__attribute__((unused)) istringstream& _stream) {}
	template<typename Head, typename... Tails> void d_f(istringstream& _stream, Head H, Tails... T) { string _name; _stream >> _name; if(_name.back() == ',') _name.pop_back(); cerr << "\t" << _name << " <=> [" << H << "]\n"; d_f(_stream, T...); }
#else
	#define trace(args...)
#endif


// CODE STARTS HERE

void solve(){
	int a, b;
	cin >> a >> b;

	if(a <= 9 and b <= 9) cout << a * b << "\n";
	else cout << "-1\n";
}

signed main (void){
	// Fast_IO
	ios::sync_with_stdio(false);
	cin.tie(nullptr);

	// Set Fixed Notation (default sucks), High Precision for Floating-Point Output
	cout << fixed << setprecision(20);

	// Multiple TCs
	int tt = 1;
	// cin >> tt;
	while(tt--) solve();
}


Measured memory_bytes: 3592
use std::io;


/// https://beta.atcoder.jp/contests/arc100/tasks/arc100_a
fn main() {
    let n = read_one::<usize>();
    let an = read::<isize>();

    let mut bn = Vec::new();
    for i in 0..n {
        bn.push(an[i] - i as isize + 1);
    }
    bn.sort();
    let mut ans = 0;
    let med = bn[bn.len() / 2];
    for b in bn {
        ans += (b - med).abs();
    }
    println!("{}", ans);
}


#[allow(dead_code)]
fn read<T>() -> Vec<T>
where T:
    std::str::FromStr,
    T::Err: std::fmt::Debug {

    let mut buf = String::new();
    io::stdin().read_line(&mut buf).unwrap();
    buf.split_whitespace()
        .map(|s| s.trim().parse().unwrap())
        .collect()
}

#[allow(dead_code)]
fn read_one<T>() -> T
where T:
    std::str::FromStr,
    T::Err: std::fmt::Debug {

    let mut buf = String::new();
    io::stdin().read_line(&mut buf).unwrap();
    buf.trim().parse().unwrap()
}

Measured memory_bytes: 10492
#import<cstdio>
int main(){int i,j,t,n,a,b,d,f[101];scanf("%d",&t);for(i=t;scanf("%d",&n),i;--i,printf("%d %d\n",-b,a))for(d=a=b=j=0;j<n;++j)scanf("%d",f+j),j?d=f[j-1]-f[j],(a=a>d?a:d),b=b<d?b:d:0;}

Measured memory_bytes: 0
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define M 1000000007
#define opt ios_base::sync_with_stdio(false); cin.tie(NULL);

void freak__()
{
    string s;
    cin >> s;
    int cnt1=0,cnt2=0,flag=1,i=0;
    while(s[i])
    {
        if((s[i]-48)!=flag) cnt1++;
        flag=1-flag;
        i++;
    }
    i=0;
    flag=0;
    while(s[i])
    {
        if((s[i]-48)!=flag) cnt2++;
        flag=1-flag;
        i++;
    }
    cout << min(cnt1,cnt2) << "\n";
}

int main()
{
    opt;
    freak__();
    return 0;
}

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

using namespace std;

int main() {
    int n, z, w, a[20000];

    scanf("%d %d %d", &n, &z, &w);

    for (int i=0; i<n; i++) scanf("%d", &a[i]);

    int res = abs(a[n-1] - w);
    res = max(res, abs(a[n-1]-a[n-2]));

    cout << res << endl;

    return 0;
}

Measured memory_bytes: 256
//#define NDEBUG
#include <cstddef>
#include <cstdint>
#include <vector>

namespace n91 {

using i8 = std::int_fast8_t;
using i32 = std::int_fast32_t;
using i64 = std::int_fast64_t;
using u8 = std::uint_fast8_t;
using u32 = std::uint_fast32_t;
using u64 = std::uint_fast64_t;
using isize = std::ptrdiff_t;
using usize = std::size_t;

constexpr usize operator"" _z(unsigned long long x) noexcept {
  return static_cast<usize>(x);
}

class rep {
  const usize f, l;

public:
  class itr {
    friend rep;
    usize i;
    constexpr itr(const usize x) noexcept : i(x) {}

  public:
    void operator++() noexcept { ++i; }
    constexpr usize operator*() const noexcept { return i; }
    constexpr bool operator!=(const itr x) const noexcept { return i != x.i; }
  };
  constexpr rep(const usize first, const usize last) noexcept
      : f(first), l(last) {}
  constexpr itr begin() const noexcept { return itr(f); }
  constexpr itr end() const noexcept { return itr(l); }
};
class revrep {
  const usize f, l;

public:
  class itr {
    friend revrep;
    usize i;
    constexpr itr(usize x) noexcept : i(x) {}

  public:
    void operator++() noexcept { --i; }
    constexpr usize operator*() const noexcept { return i; }
    constexpr bool operator!=(const itr x) const noexcept { return i != x.i; }
  };
  constexpr revrep(usize first, usize last) noexcept : f(--first), l(--last) {}
  constexpr itr begin() const noexcept { return itr(l); }
  constexpr itr end() const noexcept { return itr(f); }
};
template <class T> using vec_alias = std::vector<T>;
template <class T> auto md_vec(const usize n, const T &value) {
  return std::vector<T>(n, value);
}
template <class... Args> auto md_vec(const usize n, Args... args) {
  return std::vector<decltype(md_vec(args...))>(n, md_vec(args...));
}
template <class T> constexpr T difference(const T &a, const T &b) {
  return a < b ? b - a : a - b;
}

} // namespace n91

#include <algorithm>
#include <iostream>
#include <utility>

namespace n91 {

void main_() {
  u32 n, a, b;
  std::cin >> n >> a >> b;
  std::cout << std::min(a * n, b) << std::endl;
}

} // namespace n91

int main() {
  n91::main_();
  return 0;
}


Measured memory_bytes: 256
N,M=map(int,input().split())
A=list(map(int,input().split()))
lim=sum(A)/(4*M)
A.sort(reverse=True)

count=0
for i in range(M):
    if A[i] >= lim:
        count+=1

if count == M:
    print('Yes')
else:
    print('No')

Measured memory_bytes: 3064
using System;
using System.Collections.Generic;
using System.Linq;

namespace PaizaTest
{
    class Program
    {
        static void Main(string[] args)
        {

            var x = Console.ReadLine().Split().Select(int.Parse).ToList();

            var result = x.IndexOf(0) + 1;

            Console.WriteLine(result);

        }
    }
}


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

using ll = long long;
using ld = long double;
using vi = vector<int>;
using vll = vector<ll>;
using P = pair<int, int>;

const int INF = 1e9;
const ll INFLL = 1e18;
const int MOD = 1e9 + 7;
const int NIL = -1;
const ld PI = acosl(-1);

#define rep(i,n) for(int i=0; i<(n); ++i)
#define all(n) n.begin(),n.end()

template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

int main() {
	ios::sync_with_stdio(false); cin.tie(nullptr);
	//cout << fixed << setprecision(6);
	int x, y, a, b, c;
	cin >> x >> y >> a >> b >> c;
	vi p(a), q(b), r(c);
	rep(i, a) cin >> p[i];
	rep(i, b) cin >> q[i];
	rep(i, c) cin >> r[i];

	sort(all(p)); reverse(all(p));
	sort(all(q)); reverse(all(q));
	vi tbl;
	rep(i, x) tbl.push_back(p[i]);
	rep(i, y) tbl.push_back(q[i]);
	rep(i, c) tbl.push_back(r[i]);
	sort(all(tbl));
	reverse(all(tbl));
	ll ans = 0;
	rep(i, x + y){
		ans += tbl[i];
	}

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

Measured memory_bytes: 3572
import math
num = int(input())
syou = math.floor(num/15)
amari = num % 15
sum = 0

list = [1,2,0,4,0,0,7,8,0,0,11,0,13,14,0]
if syou >=1:
    for x in range(syou):
        sum += 60 + 120 * x


    for i in range(amari):
        if list[i] == 0:
            None
        else:
            sum += list[i] + 15 * (syou)

    print(sum)

else:
    for d in range(num):
        sum += list[d]
    print(sum)

Measured memory_bytes: 9208
N = gets.to_i
a_list = gets.split.map(&:to_i)
if a_list.count { |a| a < 0 }.even?
  ans = a_list.reduce(0) { |acc, a| acc + a.abs }
  puts ans
else
  sum = a_list.reduce(0) { |acc, a| acc + a.abs }
  min = a_list.min_by(&:abs)
  ans = sum - min.abs * 2
  puts ans
end


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


#define ll unsigned long long
#define ALL(x) x.begin(),x.end()
#define maxn 2005
#define FASTIO ios::sync_with_stdio(false),cin.tie(0),cout.tie(0);
using namespace std;
const int MOD = 1e9+7;

/*
ll power(ll x, ll int y){
    int res = 1; // Initialize result

    while (y > 0) {
        // If y is odd, multiply x with result
        if (y & 1)
            res = (res * x + MOD)%MOD;

        // n must be even now
        y = y >> 1; // y = y/2
        x = (x * x)%MOD; // Change x to x^2
    }
    return res;
}
*/

int up[maxn][maxn],down[maxn][maxn],lef[maxn][maxn],righ[maxn][maxn];

int main(){
    FASTIO

    int H,W;cin >> H >> W;
    char arr[H+3][W+3];
    for(int i=1;i<=H;i++) cin >> (arr[i]+1);

    for(int i=1;i<=H;i++){

        for(int j = 1;j<=W;j++){

            up[i][j] = (up[i-1][j] + 1)*(arr[i][j] == '.');
            lef[i][j] = (lef[i][j-1] + 1)*(arr[i][j] == '.');
        }
    }

    for(int i=H;i > 0;i--){

        for(int j=W;j>0;j--){

            down[i][j] = (down[i+1][j] + 1) * (arr[i][j] == '.');
            righ[i][j] = (righ[i][j+1] + 1)*(arr[i][j] == '.');
        }
    }
    int ans = 0;
    for(int i = 1;i <= H;i++){

        for(int j = 1;j <= W;j++){

            ans = max(ans,up[i][j] + lef[i][j] + righ[i][j] + down[i][j] - 3);
        }
    }
    cout << ans;
}

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

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

        string s = sc.Next();

        string answer = s.Replace(",", " ");

        Console.WriteLine(answer);
    }

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

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

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

            return _line[_index++];
        }

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

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

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

Measured memory_bytes: 11092
#include "bits/stdc++.h"
using namespace std;
const int MAX = 700000;
const int MOD = 1000000007;

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

// テーブルを作る前処理
void COMinit() {
	fac[0] = fac[1] = 1;
	finv[0] = finv[1] = 1;
	inv[1] = 1;
	for (int i = 2; i < MAX; i++) {
		fac[i] = fac[i - 1] * i % MOD;
		inv[i] = MOD - inv[MOD % i] * (MOD / i) % MOD;
		finv[i] = finv[i - 1] * inv[i] % MOD;
	}
}

// 二項係数計算
long long COM(int n, int k) {
	if (n < k) return 0;
	if (n < 0 || k < 0) return 0;
	return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}
/*第二引数で第一引数を割ったときの切り上げの計算*/
long long int maxtime(long long int x, long long int y) {
	return(x + y - 1) / y;

}
/*最大公約数*/
long long int lcm(long long int number1, long long int number2) {
	long long int m = number1;
	long long int n = number2;

	if (number2 > number1) {
		m = number2;
		n = number1;
	}
	long long int s = -1;
	while (s != 0) {
		s = m % n;
		m = n;
		n = s;
	}
	return m;
}
/*最大公倍数*/
long long int gcd(long long int number1, long long int number2) {
	long long int m = number1;
	long long int n = number2;
	return m / lcm(m, n) * n;
}
/*逆元計算*/
long long int  modinv(long long a, long long m) {
	long long int b = m, u = 1, v = 0;
	while (b) {
		long long int t = a / b;
		a -= t * b; swap(a, b);
		u -= t * v; swap(u, v);
	}
	u %= m;
	if (u < 0) u += m;
	return u;
}
// index が条件を満たすかどうか
vector<long long int >meguru;
bool isOK(int index, int key) {
	if (meguru[index] >= key) return true;
	else return false;
}
// 汎用的な二分探索のテンプレ
int binary_search(int key) {
	int left = -1; //「index = 0」が条件を満たすこともあるので、初期値は -1
	int right = (int)meguru.size(); // 「index = a.size()-1」が条件を満たさないこともあるので、初期値は a.size()
	/* どんな二分探索でもここの書き方を変えずにできる！ */
	while (right - left > 1) {
		int mid = left + (right - left) / 2;

		if (isOK(mid, key)) right = mid;
		else left = mid;
	}
	/* left は条件を満たさない最大の値、right は条件を満たす最小の値になっている */
	return right;
}
long long modpow(long long a, long long n, long long mod) {
	long long res = 1;
	while (n > 0) {
		if (n & 1) res = res * a % mod;
		a = a * a % mod;
		n >>= 1;
	}
	return res;
}

int main() {
	int n;
	string s;
	cin >> n;
	cin >> s;
	int R = 0;
	for (int i = 0; i < s.size(); i++) {
		if (s[i] == 'R') {
			R++;
		}
	}
	int ans = 0;
	for (int i = 0; i < R; i++) {
		if (s[i] != 'R') {
			ans++;
		}
	}
	cout << ans;
}

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

	private static Scanner sc=new Scanner(System.in);
	
	public static String findLCS(String s,String t){
		int dp[][]=new int[s.length()+1][t.length()+1];
		for(int i=0;i<=s.length();i++)
			dp[i][0]=0;
		for(int i=0;i<=t.length();i++)
			dp[0][i]=0;
		for(int i=1;i<=s.length();i++){
			for(int j=1;j<=t.length();j++){
				if(s.charAt(i-1)==t.charAt(j-1)){
					dp[i][j]=dp[i-1][j-1]+1;
				}
				else{
					dp[i][j]=Math.max(dp[i-1][j],dp[i][j-1]);
				}
			}
		}
		
		// for(int i=0;i<=s.length();i++){
			// for(int j=0;j<=t.length();j++){
				// System.out.print(dp[i][j]+" ");
			// }
			// System.out.println("");
		// }
		
		StringBuffer sb=new StringBuffer("");
		int i=s.length(),j=t.length();
		while(i>0 && j>0){
			if(s.charAt(i-1)==t.charAt(j-1)){
				sb.append(s.charAt(i-1));
				i--;
				j--;
			}
			else{
				if(i-1>0 && j-1>0 && dp[i-1][j]>=dp[i][j-1])
					i--;
				else
					j--;
			}
		}
		return sb.reverse().toString();
	}
	
	public static void main(String []args){
		String s,t;	
		s=sc.next();
		t=sc.next();
		System.out.println(findLCS(s,t));
	}
	
}

Measured memory_bytes: 86576
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.StringTokenizer;
import java.io.IOException;
import java.util.InputMismatchException;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        TaskA solver = new TaskA();
        solver.solve(1, in, out);
        out.close();
    }

    static class TaskA {
        public void solve(int testNumber, InputReader in, PrintWriter out) {
            int n = in.nextInt();
            int a = in.nextInt();

            if (n % 500 <= a) {
                out.println("Yes");
            } else {
                out.println("No");
            }
        }

    }

    static class InputReader {
        BufferedReader in;
        StringTokenizer tok;

        public String nextString() {
            while (!tok.hasMoreTokens()) {
                try {
                    tok = new StringTokenizer(in.readLine(), " ");
                } catch (IOException e) {
                    throw new InputMismatchException();
                }
            }
            return tok.nextToken();
        }

        public int nextInt() {
            return Integer.parseInt(nextString());
        }

        public InputReader(InputStream inputStream) {
            in = new BufferedReader(new InputStreamReader(inputStream));
            tok = new StringTokenizer("");
        }

    }
}



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

vector<pair<long long, long long>> prime_factorize(long long N)
{
    vector<pair<long long, long long>> res;
    for (long long a = 2; a * a <= N; ++a)
    {
        if (N % a != 0)
            continue;
        long long ex = 0;
        while (N % a == 0)
        {
            ++ex;
            N /= a;
        }
        res.push_back({a, ex});
    }
    if (N != 1)
        res.push_back({N, 1});
    return res;
}

int main()
{
    long long N, cnt = 0;
    cin >> N;
    for (long long C = 1; C < N; ++C)
    {
        const auto &pf = prime_factorize(N - C);
        long long res = 1;
        for (auto p : pf)
            res *= p.second + 1;
        cnt += res;
    }
    cout << cnt << endl;
}

Measured memory_bytes: 3172
import math


def main():
    N, K = list(map(int, input().split(' ')))
    A = list(map(int, input().split(' ')))
    M = max(A)
    g = A[0]
    for a in A[1:]:
        g = math.gcd(g, a)
    if K <= M and K % g == 0:
        print('POSSIBLE')
    else:
        print('IMPOSSIBLE')


if __name__ == '__main__':
    main()

Measured memory_bytes: 20200
def num_min_ops(a, b, c):
    res = 0
    for triple in zip(a, b, c):
        m = len(set(triple))
        res += m - 1
    return res


def main():
    _ = int(input())
    a = input()
    b = input()
    c = input()
    r = num_min_ops(a, b, c)
    print(r)


if __name__ == "__main__":
    main()

Measured memory_bytes: 3064
import java.util.Scanner;
public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int i, max = -1000000, min = 1000000;
		long sum = 0;
		int a = sc.nextInt();
		int b[] = new int[a];

		for(i = 0; i < a; i++){
			int c = sc.nextInt();
			b[i] = c;
		}
		for(i = 0; i < a; i++){
			if(b[i] >= max) max = b[i];
		}
		for(i = 0; i < a; i++){
			if(b[i] <= min) min = b[i];
		}
		for(i = 0; i < a; i++){
			sum += b[i];
		}
		System.out.println(min + " " + max + " " + sum);
	}
}



Measured memory_bytes: 41172
#include <bits/stdc++.h>
#define rep(i,n)for(long long i=0;i<(long long)(n);++i)
#define all(a) a.begin(), a.end()
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
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; }
  
const ll MOD=1e9+7;
const ll INF=1e18;
const double pi=acos(-1);
int dx[8] = {1,0,-1,0,1,1,-1,-1};
int dy[8] = {0,1,0,-1,-1,1,1,-1};
 
const int MAX=510000;

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false); 
   
  
  ll n;
  cin >> n;
  for(ll x=1;x<=3500;x++)for(ll y=1;y<=3500;y++){
    if(4*x*y-n*(x+y)==0)continue;
    if((n*x*y)%(4*x*y-n*(x+y))==0){ 
      ll z = n*x*y/(4*x*y-n*(x+y));
      if(1<=z && z<=3500){
        cout << x << " " << y << " " << z << endl;
        return 0;
      }
    }
  }
       
  return 0;
}


Measured memory_bytes: 3652
#include<stdio.h>
#include<string.h>

int main(){
	char moji[2][27]={"abcdefghijklmnopqrstuvwxyz","ABCDEFGHIJKLMNOPQRSTUVWXYZ"};
	char uketori[1202];
	int i,j,mojisuu,count[26]={0};
	while(fgets(uketori,sizeof(uketori),stdin)!=NULL){
		mojisuu=strlen(uketori);
		
		for(i=0;i<mojisuu;i++){
			for(j=0;j<26;j++){
				if(uketori[i]==moji[0][j]){
					count[j]++;
				}else if(uketori[i]==moji[1][j]){
					count[j]++;
				}
				
			}
			
		}
		
		
	}
	
	
	for(i=0;i<26;i++){
		printf("%c : %d\n",moji[0][i],count[i]);
	}
	
	return 0;
}

Measured memory_bytes: 2700
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0;i<(n);i++)
#define rep2(i,a,n) for(int i=a;i<n;i++)
#define been(ix) (ix).begin(),(ix).end()
using namespace std;
typedef long long ll; 
typedef vector<int> vi;
typedef vector<long long> vl;
const ll INFL = 1e18;
const int INF = 1001001001; 
typedef pair<int,int> P;
#define foreach(ix,i) for(auto& (ix) : (i))
typedef long double ld;
const int mod =1000000007;
const double PI = acos(-1);
int main(){
	ll a;cin>>a;
	string b;cin>>b;
	ll ans = a*(b[0]-'0');
	ans+=(a/10)*(b[2]-'0');
	ans+=(a/100)*(b[3]-'0');
	string s= to_string(a);
	int n =s.length();
	double mi = (double(s[n-1]-'0')/10.0*(b[2]-'0'))+(double(s[n-2]-'0')/10.0*(b[3]-'0'))+(double(s[n-1]-'0')/100.0*(b[3]-'0'));
	int p =float(mi);
	p =max(p,0);
	cout<<ans+p<<endl;
}

Measured memory_bytes: 3692
#include<iostream>
using namespace std;
int main()
{
	char a,b,c;
	while(cin>>a>>b>>c)
	{
		if(a=='A' && b=='A' && c=='A')
		cout<<"No";
		else if(a=='B' && b=='B' && c=='B')
		cout<<"No";
		else
		cout<<"Yes";
		cout<<endl;
	}
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
using namespace std;

int main() {
  string s; cin >> s;
  int n = s.size();
  vector<int> ans(n);
  for(int ri = 0; ri < 2; ++ri) {
    int cnt = 0;
    for(int i = 0; i < n; ++i) {
      if(s[i] == 'R') cnt++;
      else {
        ans[i] += cnt/2;
        ans[i-1] += (cnt+1)/2;
        cnt = 0;
      }
    }
    reverse(ans.begin(), ans.end());
    reverse(s.begin(), s.end());
    for(int i = 0; i < n; ++i) {
      if(s[i] == 'L') s[i] = 'R';
      else s[i] = 'L';
    }
  }

  for(int i = 0; i < n; ++i)
    std::cout << ans[i] << ' ';
  std::cout << std::endl;
  return 0;
}


Measured memory_bytes: 1024
package main

import (
	"fmt"
	"math"
)

const d = 1000000007

func main() {
	var n, p int
	fmt.Scan(&n)
	fmt.Scan(&p)

	var n1 int64
	fmt.Scan(&n1)
	mdans := map[int64]int64{
		n1: n1,
	}

	for index := 1; index < p; index++ {
		var n1 int64
		fmt.Scan(&n1)
		mdans[n1] = n1
	}

	dp := make([]int64, n+1, n+1)
	dp[0] = 1

	for index := 0; index < n; index++ {
		// fmt.Printf("%#v\n", Min(n, index+2))
		for j := index + 1; j <= Min(n, index+2); j++ {
			if _, ok := mdans[int64(j)]; !ok {
				dp[j] += dp[index]
				dp[j] %= d
			}
		}
	}

	// fmt.Printf("%#v\n", "******")
	// fmt.Printf("%#v\n", dp)
	fmt.Printf("%#v\n", dp[n])
}

func Min(nums ...int) int {
	if len(nums) == 0 {
		panic("function min() requires at least one argument.")
	}
	res := nums[0]
	for i := 0; i < len(nums); i++ {
		res = int(math.Min(float64(res), float64(nums[i])))
	}
	return res
}


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

int main() {

    int N;
    int t[110000], x[110000], y[110000];

    cin >> N;
    t[0] = x[0] = y[0] = 0;

    for (int i = 0; i < N; ++i){
        cin >> t[i+1] >> x[i+1] >> y[i+1];
    } 

    bool can = true;
    for (int i = 0; i < N; ++i) {
        int dt = t[i+1] - t[i];
        int dist = abs(x[i+1] - x[i]) + abs(y[i+1] - y[i]);

        if (dt < dist) {
            can = false;
        }

        if (dist % 2 != dt % 2) {
            can = false;
        }
    }

    if (can) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
}

Measured memory_bytes: 1408
import sys
from collections import deque


def main():
    N, M, *AB = map(int, sys.stdin.buffer.read().split())
    
    g = [[] for _ in range(N + 1)]

    for A, B in zip(*[iter(AB)] * 2):
        g[A].append(B)
        g[B].append(A)

    queue = deque([1])
    d = [None] * (N + 1)
    d[0] = 0
    d[1] = 0

    while queue:
        v = queue.popleft()
        for i in g[v]:
            if d[i] is None:
                d[i] = v
                queue.append(i)

    if None in d:
        print("No")
    else:
        print("Yes")
        print("\n".join(map(str, d[2:])))


if __name__ == '__main__':
	main()

exit()


Measured memory_bytes: 46268
#include <cstdio>
#include <iostream>
#include <cmath>
#include <cstring>
#include <sstream>
#include <algorithm>
#include <cstdlib>
#include <map>
#include <queue>
#include <utility>
#include <vector>
#include <set>
#include <memory.h>
#include <iomanip>
#include <bitset>
#include <list>
#include <stack>
#include <deque>

using namespace std;

#define mod 1000000007

class SegTree
{
private:
	vector<int> v;
	int n;

public:
	SegTree(int k)
	{
		n = 1;
		while(n < k) n = (n << 1);
		v = vector<int>(2 * n, mod);
	}

	void update(int tl, int tr, int val)
	{
		update(tl, tr, val, 0, 0, n);
	}

	void update(int tl, int tr, int val, int k, int nl, int nr)
	{
		// cout << tl << " " << tr << " " << k << " " << nl << " " << nr << endl;
		if(tr <= nl || tl >= nr) return;
		if(tl <= nl && nr <= tr){
			v[k] = val;
		} else {
			update(tl, tr, val, 2 * k + 1, nl, (nl + nr) / 2);
			update(tl, tr, val, 2 * k + 2, (nl + nr) / 2, nr);
		}
	}

	int getmin(int k)
	{
		k += n - 1;
		int result = v[k];
		while(k > 0){
			k = (k - 1) / 2;
			result = min(result, v[k]);
		}
		return result;
	}

};

int main()
{
	int n, q;
	cin >> n >> q;
	vector<pair<int, pair<int, int> > > v;
	for(int i = 0; i < n; i++){
		int s, t, x;
		cin >> s >> t >> x;
		t--;
		v.push_back(make_pair(x, make_pair(s, t)));
	}
	sort(v.begin(), v.end());
	reverse(v.begin(), v.end());

	int d[200002];
	d[0] = -mod;
	for(int i = 1; i <= q; i++){
		cin >> d[i];
	}
	d[q + 1] = mod;
	SegTree st(q + 2);
	for(int i = 0; i < v.size(); i++){
		int x = v[i].first;
		int s = (v[i].second).first;
		int t = (v[i].second).second;
		int l = lower_bound(d, d + q + 2, s - x) - d;
		int r = upper_bound(d, d + q + 2, t - x) - d;
		st.update(l, r, x);
	}

	for(int i = 1; i <= q; i++){
		int res = st.getmin(i);
		if(res == mod) cout << -1 << endl;
		else cout << res << endl;
	}
}

Measured memory_bytes: 7920
/*
 * author :Sadik Hassan
 *
*/
#include "bits/stdc++.h"
using namespace std;
#define ll            long long
#define nl            "\n"
#define PB            push_back
#define fi            first
#define se            second
#define _SAD()        ios::sync_with_stdio(0),cin.tie(0), cout.tie(0);
#define rep(i,n)      for(int i=0;i<n;i++)
#define repn(i,n)     for(int i=1;i<=n;i++)
#define rrep(i,n)     for(int i=n-1;i>=0;i--)
#define SZ(s)         s.size()
#define SRT(x,y)      sort(x,x+y)
#define REV(a,b)      reverse(a,a+b)
#define VSRT(x)       sort(x.begin(),x.end())
#define VREV(x)       reverse(x.begin(),x.end())
#define TSFL(s)       transform(s.begin(),s.end(),s.begin(),::toupper);
#define TSFH(s)       transform(s.begin(),s.end(),s.begin(),::tolower);
/*---------------------------------------------------------------------*/
typedef vector<int> vi;
typedef vector<ll> vii;
const int N = 2e5+10;
const int INF = (int)1e9+5;

int main()
{
    _SAD()
    ll n,k;
    cin>>n>>k;
    n-=k*(n/k);
    cout<<min(n,-(n-k))<<nl;
    return 0;
}


Measured memory_bytes: 256
N, M = map(int, input().split())
A = [list(input()) for _ in range(N)]
B = [list(input()) for _ in range(M)]

for i in range(N-M+1):
    for j in range(N-M+1):
        flag = True
        for k in range(M):
            if A[i+k][j:j+M] != B[k]:
                flag = False
                break
        if flag:
            print("Yes")
            exit(0)

print("No")

Measured memory_bytes: 62712
#include<iostream>
#include<vector>
#include<map>
#include<set>
#include<string>
#include<algorithm>
#include<numeric>
#include<cmath>
#include<queue>
#include<stack>
#include<list>
#include<unordered_map>
#include<unordered_set>
#include<cctype>
#include<iomanip>

using namespace std;
typedef long long int ll;typedef pair<int, int> P;
const long long mod = 1e9 + 7;
#define rep(i,n) for(int i=0;i<(int)n;i++)
#define all(a) (a).begin(),(a).end()
#define allg(a) (a).begin(),(a).end(),greater<>()
#define SUM(a) accumulate((a).begin(),(a).end(),0)
const double PI = 3.14159265359;

int main(void) {
	int n; string str; cin >> n >> str;
	int ans = 0;
	for (int i = 0; i < n - 1; i++) {
		int cnt = 0;
		set<char> s1, s2;
		for (int j = 0; j <= i; j++)
			s1.insert(str[j]);
		for (int j = i + 1; j < n; j++)
			s2.insert(str[j]);
		for (auto x : s1)
			if (s2.count(x))cnt++;
		ans = max(ans, cnt);
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <string>
#include <algorithm>
#include <vector>

constexpr size_t di[]={size_t(-1), 0, 1, 0};
constexpr size_t dj[]={0, size_t(-1), 0, 1};

int main() {
  size_t H, W;
  scanf("%zu %zu", &H, &W);

  // Note: H == 1 or W == 1
  std::vector<std::string> s(H);
  for (size_t i=0; i<H; ++i) {
    char buf[64];
    scanf("%s", buf);
    s[i] = buf;
  }

  auto is_tsurai=[&](size_t i, size_t j) {
    if (s[i][j] == '.') return false;
    for (size_t k=0; k<4; ++k) {
      size_t ni=i+di[k], nj=j+dj[k];
        if (!(ni < H && nj < W)) continue;
        if (s[i][j] == s[ni][nj]) return false;
    }
    return true;
  };

  for (size_t i=0; i<H; ++i)
    for (size_t j=0; j<W; ++j)
      if (is_tsurai(i, j))
        return !printf("No\n");

  printf("Yes\n");
}


Measured memory_bytes: 256
from collections import Counter

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

c = Counter(A).items()

res = 0
for num,cnt in c:
    if cnt % 2 == 0:
        res += 1

ans = len(c)
if res % 2 == 1:
    ans -= 1
print(ans)

Measured memory_bytes: 18656
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rng(i, a, b) for (int i = int(a); i < int(b); i++)
#define rep(i, b) rng(i, 0, b)
#define gnr(i, a, b) for (int i = int(b) - 1; i >= int(a); i--)
#define per(i, b) gnr(i, 0, b)
#define bg begin()
#define ed end()
#define all(x) x.bg, x.ed
#define vi vector<int>
template <class t, class u>
bool chmax(t &a, u b)
{
    if (a < b)
    {
        a = b;
        return true;
    }
    return false;
}
template <class t, class u>
bool chmin(t &a, u b)
{
    if (b < a)
    {
        a = b;
        return true;
    }
    return false;
}

int main()
{
    int a=0;
    int b=0;
    int n,t;
    int ans = 0;
    cin >> n >> t;
    rep(i,n){
        int c;
        cin >> c;
        if(b<c){
            ans += b - a;
            a=c;
            b = c + t;
        }
        else{
            b = c + t;
        }
    }
    ans+=b-a;
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
N,A,B=input().split()
N=int(N)
A=int(A)
B=int(B)
i=0
k=0
for i in range(1,N+1):
    l=i
    j=0
    while i>0:
        j=j+i%10
        i=i//10
    if A<=j<=B:
        k=k+l
print(k)

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

using namespace std;
#define pb push_back
#define sz(x) ((int)x.size())
#define all(x) x.begin(), x.end()
#define se second
#define fi first

using ll=long long;

using pii=pair<ll, ll>;
const int mn = 2e5 + 5;
const int mod = 1e9 + 7;
int n, h, w;

struct node {
    int x, y, value;

    bool operator<(const node &p) const {
        return value > p.value;
    }
};

namespace Union_find_set {
    int f[mn];
    int sz[mn];// 并查集 i 的大小

    void init(int n) { // 初始化
        for (int i = 1; i <= n; i++) {
            f[i] = i;
            sz[i] = 1;
        }
    }

    int sf(int x) { // 找爸爸
        if (f[x] == x) return x;
        if (sf(f[x]) != f[x]) {
            f[x] = sf(f[x]);
        }
        return f[x];
    }

    void Union(int u, int v) { // 合并
        u = sf(u), v = sf(v);
        if (u != v) {
            f[u] = v;// 把 u 接到 v 尾部
            sz[v] += sz[u];
            sz[u] = 0;
        }
    }

    int getSize(int x) {
        return sz[sf(x)];
    }
}
using namespace Union_find_set;

int main() {
    //cin.sync_with_stdio(0);
#ifdef trote
    freopen("../1.txt", "r", stdin);
#endif
    scanf("%d%d%d", &n, &h, &w);
    init(h + w);
    vector<node> g;
    for (int i = 1; i <= n; i++) {
        int a, b, c;
        scanf("%d%d%d", &a, &b, &c);
        g.pb({a, b, c});
    }
    sort(all(g));
    ll ans = 0;
    for (auto &&p:g) {
        if (sf(p.x) == sf(p.y + h)) {
            if (getSize(p.x) < 1) {
                continue;
            } else {
                sz[sf(p.x)]--;
                ans += p.value;
            }
        } else {
            if (getSize(p.x) + getSize(p.y + h) < 1) {
                continue;
            } else {
                ans += p.value;
                Union(p.x, p.y + h);
                sz[sf(p.x)]--;
            }
        }
    }
    printf("%lld\n", ans);

}

Measured memory_bytes: 3448
#include <stdio.h>
int main(){
  
  int x,y,z,r;
  
  
  scanf("%d%d",&x,&y);
  
  if(x<y){
    z=x;
    x=y;
    y=z;
  }
  
  r=x%y;
  
  while(r!=0){
    x=y;
    y=r;
    r=x%y;
    
    if(r==0) break;
  }
  
  
  
  printf("%d\n",y);
  
  return 0;
  
}

Measured memory_bytes: 592