akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
// Including Policy Based DS
//#include <ext/pb_ds/assoc_container.hpp>
// Including tree_order_statistics_node_update
//#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
//using namespace __gnu_pbds;

#define LL long long
#define ULL unsigned long long
LL INF=10000000000000001LL;
#define PI 2.0*acos(0.0)

typedef pair<int,int> pii;
typedef pair<LL,LL> pll;
typedef vector<int> vi;
typedef vector<LL> vl;
typedef vector<pii> vii;
typedef vector<pll> vll;

//typedef tree<
//int,
//null_type,
//less<int>,
//rb_tree_tag,
//tree_order_statistics_node_update>
//ordered_set;

#define READ 		freopen("in.txt","r",stdin)
#define WRITE  		freopen("out.txt","w",stdout)
#define BOOST		ios_base::sync_with_stdio(false);cin.tie(NULL)
#define sf 			scanf
#define pf 			printf
#define F  			first
#define S  			second
#define pb 			push_back
#define NL			pf("\n")
#define ALL(v)		v.begin(),v.end()
#define si(x)		sf("%d",&x);
#define sii(x,y)	sf("%d%d",&x,&y);
#define siii(x,y,z)	sf("%d%d%d",&x,&y,&z);
#define sl(x)		sf("%lld",&x);
#define sll(x,y)	sf("%lld%lld",&x,&y);
#define slll(x,y,z)	sf("%lld%lld%lld",&x,&y,&z);
#define clr(x,y) 	memset(x,y,sizeof (x) )
#define ch 			printf("Came Here!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!\n")
#define SV(v)		sort(v.begin(),v.end())
#define SVR(v,cmp)	sort(v.begin(),v.end(),cmp)
#define FOR(i,n)	for(int i=0;i<n;i++)
#define cnd			tree[idx]
#define lc			tree[idx*2]
#define rc			tree[idx*2+1]
#define lnd 		(2*idx),(b),((b+e)/2)
#define rnd 		((2*idx)+1),(((b+e)/2)+1),(e)

// graph direction array [4]
//LL X[4]={0,0,1,-1};
//LL Y[4]={1,-1,0,0};
// graph direction array [8]
//int X[8]={0,0,1,-1,-1,1,1,-1};
//int Y[8]={1,-1,0,0,-1,-1,1,1};
// Bishop direction array [8]
//int X[8]={0,0,1,-1,-1,1,1,-1};
//int Y[8]={1,-1,0,0,-1,-1,1,1};
// Knight Direction Array
//int KX[8] = {1,1,2,2,-1,-1,-2,-2};
//int KY[8] = {2,-2,1,-1,2,-2,1,-1};

bool Check(int N,int pos){return (bool)(N & (1<<pos));} // check bit
int Set(int N,int pos){	return N=N | (1<<pos);}// set bit

const LL mod=2091573227LL;
LL modMul(LL a, LL b){
    LL ans = 0;
    a = a % mod;
    while (b > 0){
        if ( b % 2 )ans = (ans%mod+ a%mod) % mod;
        a = (a%mod * 2%mod) % mod;
        b /= 2;
    }
    return ans % mod;
}

LL powerMod( LL a,LL b ){
	if( b==0 )return 1%mod;
	LL x=powerMod( a,b/2 );
	x = ( x%mod * x%mod )%mod;
	if( b%2==1 )x = ( x%mod * a%mod )%mod;
	return x%mod;
}

LL lcm( LL a,LL b ){
	LL g = __gcd(a,b);
	return (a*b)/g;
}
const int mx = 100005;
//-------------------------------------------------------------------------------



int main(){
//  READ;
//  WRITE;
//	BOOST;
    LL t,n,k;
    LL a,b,c;
    cin>>a>>b>>c;
    k = 0;
    if( a==b && b==c ){
		if( a%2 )cout<<0<<endl;
		else cout<<"-1"<<endl;
		return 0;
    }
    LL ta,tb,tc;
    while( 1 ){
        if( a%2 || b%2 || c%2 )break;
        ta = a,tb = b,tc = c;
        a = tb/2+tc/2;
        b = ta/2+tc/2;
        c = tb/2+ta/2;
//        cout<<a<<" "<<b<<" "<<c<<endl;
        k++;
    }

    cout<<k<<endl;



//    main();


    return 0;
}



Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#include <iostream>
#include <memory>
#include <memory.h>
#include <fstream>
#include <cmath>
#include <math.h>
#include <numeric>
#include <vector>
#include <stack>
#include <string>
#include <queue>
#include <sstream>
#include <cstdlib>
#include <cassert>
#include <cstdio>
#include <cstring>
#include <map>
#include <set>
#include <iomanip>
#include <list>
#include <cctype>
#include <algorithm>
#include <complex>
using namespace std;

typedef complex<double> xy_t;
typedef pair<xy_t, xy_t> line;
typedef long long ll;
typedef pair<int, int> P;
typedef pair<double, double> Pd;
typedef pair<int, P> PP;
typedef pair<int, PP> PPP;
const int INF = 1 << 28;
const double EPS = 1E-10;

#define rep(i, n) for(int i = 0; i < n; i++)
#define rep2(i, m, n) for(int i = m; i < n; i++)

int main(){
	vector<int> nums;
	int n, m;
	int t;
	while(cin >> n >> m && (n || m)){
		nums.clear();
		nums.push_back(0);
		rep(i, n + m){
			cin >> t;
			nums.push_back(t);
		}
		sort(nums.begin(), nums.end());
		int res = 0;
		rep(i, n + m){
			res = max(res, nums[i+1] - nums[i]);
		}
		cout << res << endl;
	}
	return 0;
}

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

int main(){
    char s[10000],s1[10000],s2[10000];
    int i,j=0,n;

    scanf("%s",&s);

    for(i=0;i<(strlen(s)-1)/2;i++){
        s1[i]=s[i];
    }
    for(i=(strlen(s)+1)/2;i<strlen(s);i++){
        s2[j]=s[i];
        j++;
    }

    if(strcmp(s1,s2)==0){
        printf("Yes\n");
    }
    else{
        printf("No\n");
    }

return 0;
}

Measured memory_bytes: 128
import java.util.*;
class Main{
  public static void main(String args[]){
    Scanner sc = new Scanner(System.in);
    int a = sc.nextInt(),b = sc.nextInt(),c = sc.nextInt(),d = sc.nextInt();
    int x = a/d+aa(a%d),y = c/b+aa(c%b);
    if(x>=y){
      pl("Yes");
    }else{
      pl("No");
    }
  }

  public static int aa(int n){
    if(n>0){return 1;}
    return 0;
  }

  public static void pr(String str){
    System.out.print(str);
  }
  public static void pl(String str){
    System.out.println(str);
  }
}


Measured memory_bytes: 35812
#include <bits/stdc++.h>
//#include <chrono>
//#pragma GCC optimize("Ofast")
using namespace std;
#define reps(i,s,n) for(int i = s; i < n; i++)
#define rep(i,n) reps(i,0,n)
#define Rreps(i,n,e) for(int i = n - 1; i >= e; --i)
#define Rrep(i,n) Rreps(i,n,0)
#define ALL(a) a.begin(), a.end()
#define fi first
#define se second

using ll = long long;
using vec = vector<ll>;
using mat = vector<vec>;

ll N,M,H,W,Q,K,A,B;
string S;
typedef pair<ll, ll> P;
const ll INF = (1LL<<58);

int main() {
    cin>>N;
    rep(i, N) cout<<"ACL";
    cout<<endl;
}


Measured memory_bytes: 3632
import java.util.Scanner;

public class Main{

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

        int a = scan.nextInt();
        int b = scan.nextInt();

        if((a*b)%2 == 0){
            System.out.println("Even");
        }else{
            System.out.println("Odd");
        }

        scan.close();
        
    }
}

Measured memory_bytes: 23252
#include <bits/stdc++.h>
	
using namespace std;
 
#define int long long
 
#define PB	push_back
#define ALL(x)	(x).begin(), (x).end()
#define ALLR(x)	(x).rbegin(), (x).rend()
#define MP	make_pair
 
template <typename A, typename B>
string to_string(pair<A, B> p);
 
template <typename A, typename B, typename C>
string to_string(tuple<A, B, C> p);
 
template <typename A, typename B, typename C, typename D>
string to_string(tuple<A, B, C, D> p);
 
string to_string(const string& s) {
  return '"' + s + '"';
}
 
string to_string(const char* s) {
  return to_string((string) s);
}
 
string to_string(bool b) {
  return (b ? "true" : "false");
}
 
string to_string(vector<bool> v) {
  bool first = true;
  string res = "{";
  for (int i = 0; i < static_cast<int>(v.size()); i++) {
    if (!first) {
      res += ", ";
    }
    first = false;
    res += to_string(v[i]);
  }
  res += "}";
  return res;
}
 
template <size_t N>
string to_string(bitset<N> v) {
  string res = "";
  for (size_t i = 0; i < N; i++) {
    res += static_cast<char>('0' + v[i]);
  }
  return res;
}
 
template <typename A>
string to_string(A v) {
  bool first = true;
  string res = "{";
  for (const auto &x : v) {
    if (!first) {
      res += ", ";
    }
    first = false;
    res += to_string(x);
  }
  res += "}";
  return res;
}
 
template <typename A, typename B>
string to_string(pair<A, B> p) {
  return "(" + to_string(p.first) + ", " + to_string(p.second) + ")";
}
 
template <typename A, typename B, typename C>
string to_string(tuple<A, B, C> p) {
  return "(" + to_string(get<0>(p)) + ", " + to_string(get<1>(p)) + ", " + to_string(get<2>(p)) + ")";
}
 
template <typename A, typename B, typename C, typename D>
string to_string(tuple<A, B, C, D> p) {
  return "(" + to_string(get<0>(p)) + ", " + to_string(get<1>(p)) + ", " + to_string(get<2>(p)) + ", " + to_string(get<3>(p)) + ")";
}
 
void debug_out() { cerr << endl; }
 
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
  cerr << " " << to_string(H);
  debug_out(T...);
}
#define LOCAL
#ifdef LOCAL
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#else
#define debug(...) 42
#endif
 
#define FAST_IO ios::sync_with_stdio(false); cin.tie(0)
 
typedef pair<int, int> ii;
typedef pair<pair<int, int>, int> iii;
typedef vector<int> vi;
typedef vector<iii> viii;
typedef vector<vi> vvi;
typedef vector<ii> vii;
typedef vector<string> vs;
typedef vector<bool> vb;
typedef unsigned long long ull;
 
const int INF = LONG_LONG_MAX/2;
const int NINF = LONG_LONG_MIN/2;
const double PI = 3.141592653589793238;

int32_t main() {
	FAST_IO;
	
	char c;
	cin >> c;
	
	if (isupper(c)) {
		cout << "A" << endl;
	} else {
		cout << 'a' << endl;
	}
}
// g++ -Wall -Wextra -Wshadow -fsanitize=undefined -std=c++17


Measured memory_bytes: 3612
#include <iomanip>
#include <iostream>
#include <vector>
#define rep(i, n) for (int i = 0; i < (n); i++)
using namespace std;

int main(void) {
  ios::sync_with_stdio(false);
  int H, W, K;
  cin >> H >> W >> K;
  vector<vector<char>> C(H, vector<char>(W));
  rep(i, H) {
    rep(j, W) { cin >> C[i][j]; }
  }

  int answer = 0;
  rep(i, (1 << H)) {
    rep(j, (1 << W)) {
      int black = 0;
      rep(m, H) {
        if (i & (1 << m)) continue;
        rep(n, W) {
          if (j & (1 << n)) continue;
          if (C[m][n] == '#') ++black;
        }
      }
      if (black == K) ++answer;
    }
  }
  cout << answer << endl;
  return 0;
}


Measured memory_bytes: 3616
#include<iostream>
#include<stdio.h>
using namespace std;
int main(){
    while(1){
    int a = 0;
    string number;
    cin >> number;
        if(number == "0"){
            break;
        }
        for(int i = 0;i < (int)number.size();i++){
            a += number[i] - '0';
        }
        cout << a << endl;
    }
    return 0;
}


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

int main() {
  int64_t N;
  cin>>N;
  int64_t Z=0;
  for(int i=1;i<=N;i++){
    if(i%3!=0&&i%5!=0){
      Z+=i;
    }
  }
  cout<<Z<<endl;
}

Measured memory_bytes: 3632
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <map>
#include <set>
using namespace std;
int main(void){
    long long int n;
    cin>>n;
    vector<long long int> a(n),b(n);
    b.clear();
    for(int i=0;i<n;i++){
        cin>>a[i];
    }
    int p=n/2;
    b[p]=a[0];
    if(n%2==0){
        for(int i=1;i<n;i++){
            if(i%2==1){b[p-i]=a[i];p-=i;}
            else{b[p+i]=a[i];p+=i;}
        }
    }
    else if(n%2==1){
        for(int i=1;i<n;i++){
            if(i%2==1){b[p+i]=a[i];p+=i;}
            else{b[p-i]=a[i];p-=i;}
        }
    }
    for(int i=0;i<n;i++){
        cout<<b[i]<<" ";
    }
    return 0;
}

Measured memory_bytes: 5376
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll,ll>pll;
const int N=1e6;
ll v[N+10];
ll pos[N];
int main()
{

   string str;

   cin>>str;

   ll sz=str.size();

   if(str[sz-1]=='s')
   {
       cout<<str<<"es"<<endl;
   }
   else cout<<str<<'s'<<endl;


}










Measured memory_bytes: 3628
import java.util.*;

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

    for(int i=0;i<n-1;i++){
      for(int j=n-1;j>i;j--){
        if(a[j-1] > a[j]){
          double tmp = a[j];
          a[j] = a[j-1];
          a[j-1] = tmp;
        }
      }
    }
    for(int i=0;i<n-1;i++){
      //System.out.println(a[i]);
      a[i+1] = (a[i]+a[i+1])/2;
    }
    System.out.println(a[n-1]);
  }
}

Measured memory_bytes: 23508
#include<iostream>
#include<algorithm>
#include<string>
#include<vector>
#include<set>
#include<map>
#include<queue>
using namespace std;

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

#define pb push_back
#define fr first
#define sc second

ll POW[20];
void init(){
	POW[0] = 1;
	for(int i = 1 ; i < 20 ; i ++){
		POW[i] = POW[i-1]*10;
	}
}

int keta(ll x){
	if(x == 0)return 0;
	return keta(x/10)+1;
}

ll sol(ll D,int l,ll ret,bool t){
	//cout << D << " " << l << " " << ret << endl;
	if(l == 0)return (D==0)?ret:0;
	if(l == 1)return (D==0)?(ret*10):0;
	int k = keta(abs(D));
	if(k > l)return 0;
	ll d = (10+D%10); if(d >= 10)d -= 10;
	if(d == 0)return sol(D/10,l-2,ret*(t?9:10),false);
	ll T = POW[l-1]-1;
	return sol((D-(10-d)*T)/10,l-2,ret*d,false) + sol((D+d*T)/10,l-2,ret*(t?(9-d):(10-d)),false);
}

int main(){
	init();
	
	ll D;
	cin >> D;
	
	ll ret = 0;
	int k = keta(D);
	for(int l = k ; l <= 2*k ; l ++){
		ret += sol(-D,l,1,true);
	}
	cout << ret << endl;
}



Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<vector>
using namespace std;
int main() {
	vector<int> s(26,0);
	int i, j,k, len, num;
	char u;
	string str;
	while (true) {
		getline(cin, str);
		if (str == "")break;
		len = str.length();
		for (i = 0; i < 26; i++) {
			num = 0;
			for (j = 0; j < len; j++) {
				if (str[j] == 'a' + i) {
					num += 1;
				}
				else if (str[j] == 'A' + i) {
					num += 1;
				}
			}
			s[i] += num;
		}
	}
	for (k = 0; k < 26; k++) {
		u = k + 'a';
		cout << u << " : " << s[k] << endl;
	}
	return 0;
}


Measured memory_bytes: 3140
#[allow(dead_code)]
fn is_whitespace(c: &char) -> bool {
    c.is_whitespace()
}

#[allow(dead_code)]
fn is_eol(c: &char) -> bool {
    ['\r', '\n'].contains(c)
}

#[allow(unused_macros)]
macro_rules! input {
    ($var:ident, $($r:tt)*) => {
        input_inner!{$var, $($r)*}
    };

    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        #[allow(unused_mut, unused_variables, bare_trait_objects)]
        let mut next = move |f: &Fn(&char)->bool| -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|f(&c))
                .take_while(|c|!f(&c))
                .collect()
        };
        input_inner!{next, $($r)*};
    };
}

#[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)*}
    };

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

#[allow(unused_macros)]
macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; eol ]) => {
        $next(&is_eol).split(' ').map(|x| x.parse::<$t>().unwrap()).collect::<Vec<_>>()
    };

    ($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, bytes) => {
        read_value!($next, String).into_bytes()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, parser) => {
        $next
    };

    ($next:expr, $t:ty) => {
        $next(&is_whitespace).parse::<$t>().expect("Parse error")
    };
}

#[allow(unused_imports)]
use std::cmp::{max, min};
#[allow(unused_imports)]
use std::collections::{BinaryHeap, HashMap, HashSet};

#[allow(dead_code)]
struct Edge {
    from: usize,
    to: usize,
}

#[allow(dead_code)]
type Graph = Vec<Vec<usize>>;
#[allow(dead_code)]
const M: usize = 1_000_000_007;

fn main() {
    input! {
        h: usize,
    }

    let mut x = 1;
    let mut cur = 1usize;
    while x * 2 <= h {
        cur = 1 + cur * 2;
        x *= 2;
    }
    println!("{}", cur);
}


Measured memory_bytes: 4352
#include <iostream>
using std::cin;
using std::cout;
using std::endl;

int main(){
    int a, b, c;
    cin >> a >> b >> c;
    
    if((a < b) && (b < c)){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }
}



Measured memory_bytes: 3020
#include<bits/stdc++.h>
using namespace std;
int main(){
    int a,b,c,d;
    cin >> a >> b >> c >> d;
    if(abs(a-b)<= d && abs(b-c)<=d)cout << "Yes" << endl;
    else if(abs(a-c)<=d)cout << "Yes" << endl;
    else cout << "No" << endl; 
}

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

int main() {
  int a,b;
  string s;
  cin>>a>>b>>s;
  bool ex=true;
  rep(i,a){
    if(s.at(i)=='-'){
      ex=false;
    }
  }
  rep2(i,s.size()-b,s.size()){
    if(s.at(i)=='-'){
      ex=false;
    }
  }
  if(s.at(a)!='-'){
    ex=false;
  }
  if(ex){
    cout<<"Yes"<<endl;
  }
  else{
    cout<<"No"<<endl;
  }
}

Measured memory_bytes: 256
n, k =  map(int, input().split())
r, s, p = map(int, input().split())
t = str(input())

r_count = t.count('r') *p
s_count = t.count('s') *r
p_count = t.count('p') *s
tot = r_count + s_count + p_count

count = 0
for i in range(k):
    List = [x for x in t[i::k]]
    for j in range(1, len(List)):
        if List[j-1] == List[j]:
            if List[j] == 'r':
                count += p
            elif List[j] == 's':
                count += r
            else:
                count += s
            List[j] = 'z'
          
ans = tot - count
print(ans)



Measured memory_bytes: 4084
<?php
// Your code here!    fscanf(STDIN,"%d %d %d",$A,$B,$C);
    // echo $A.$B.$C;
    
    $input_line = str_split(fgets(STDIN));
    
    foreach($input_line as $string){
        if(ctype_upper($string)){
            $array[] = strtolower($string);
        }elseif(ctype_lower($string)){
            $array[] = strtoupper($string);
        }else{
            $array[] = $string;
        }
    }
    $A= implode("",$array);
    
    echo $A;
    
    
?>


Measured memory_bytes: 9640
#include <stdio.h>

long long W[101];
long long V[101];

long long dp[101][100001];

long long max(long long a, long long b) {
    if (a >= b) return a;
    else return b;
}

long long q (int k, long long w) {
    if (dp[k][w] != -1) return dp[k][w];
    if (k == 0) dp[k][w] = 0;
    else if (w < W[k]) dp[k][w] = q(k-1, w);
    else {
        dp[k][w] = max(V[k] + q(k-1, w - W[k]), q(k-1, w));
    } 
    return dp[k][w];
}

int main(void) {

    int N;
    long long M;
    scanf("%d%lld", &N, &M);

    for (int i = 1; i <= N; i++) {
        scanf("%lld%lld", &W[i], &V[i]);
    }


    for (int i = 0; i <= N; i++) {
        for (long long j = 0; j <= M; j++) {
            dp[i][j] = -1;
        }
    }

    printf("%lld\n", q(N, M));


    return 0;
}

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

using namespace std;
using ll = long long;

int main() {
    int n;
    cin >> n;
    string s;
    cin >> s;

    vector<int> r(n + 1, 0);
    vector<int> g(n + 1, 0);
    vector<int> b(n + 1, 0);
    for (int i = 0; i < n; i++) {
        switch (s.at(i)) {
            case 'R' : r.at(i + 1)++; break;
            case 'G' : g.at(i + 1)++; break;
            case 'B' : b.at(i + 1)++; break;
        }
        r.at(i + 1) += r.at(i);
        g.at(i + 1) += g.at(i);
        b.at(i + 1) += b.at(i);
    }

    ll sum = 0;
    char front, middle;
    for (int i = 0; i < n - 2; i++) {
        front = s.at(i);
        for (int j = i + 1; j < n - 1; j++) {
            middle = s.at(j);
            if (front == middle) continue;
            if (front != 'R' && middle != 'R') {
                sum += r.at(n) - r.at(j + 1);
                if (j + j - i < n) {
                    if (s.at(j + j - i) == 'R') {
                    sum--;
                    }
                }
            }
            if (front != 'G' && middle != 'G') {
                sum += g.at(n) - g.at(j + 1);
                if (j + j - i < n) {
                    if (s.at(j + j - i) == 'G') {
                    sum--;
                    }
                }
            }
            if (front != 'B' && middle != 'B') {
                sum += b.at(n) - b.at(j + 1);
                if (j + j - i < n) {
                    if (s.at(j + j - i) == 'B') {
                    sum--;
                    }
                }
            }
        }
    }

    cout << sum << endl;
    return 0;
}

Measured memory_bytes: 3632
#include<iostream>
#include<cstdio>
#include<cmath>
#include<algorithm>
#include<cstring>
using namespace std;
const int N=1010;
int n,m,i,j,k,a[N][N];
bool b[N][N];
char ch[N];
bool f(int k){
	for (int i=1;i<=m;i++) if (a[k][i]) return false;return true;
}
bool ff(int k){
	for (int i=1;i<=n;i++) if (a[i][k]) return false;return true;
}
int main(){
	scanf("%d%d",&n,&m);for (i=1;i<=n;i++){scanf("%s",ch);for (j=0;j<m;j++) if (ch[j]=='.') a[i][j+1]=0; else a[i][j+1]=1;}
	for (i=1;i<=n;i++) if (f(i)) for (j=1;j<=m;j++) b[i][j]=true;
	for (i=1;i<=m;i++) if (ff(i)) for (j=1;j<=n;j++) b[j][i]=true;
	for (i=1;i<=n;i++){bool flag=false;for (j=1;j<=m;j++) if (!b[i][j]){flag=true;if (a[i][j]) printf("#"); else printf(".");}
	if (flag) printf("\n");}return 0;
}

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

#define sws ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define INFINITO 1000000000
#define ll long long
#define vi vector<int>
#define pb push_back
#define pii pair<int, int>
#define mp make_pair
#define ff first
#define ss second
#define vvi vector<vi>
#define all(x) x.begin(), x.end()
#define fo(i, n) for( int i = 0; i < n; i++ )


int main() {

    ll a, b, c, k;
    cin >> a >> b >> c >> k;

    if ( k & 1 ) cout << b - a << endl;
    else cout << a - b << endl;

    return 0;
}

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

int main() {
  int N, K, X, Y;
  cin >> N >> K >> X >> Y;
  if (N <= K) {
    cout << N * X << endl;
  }
  else {
    cout << K * X + (N - K) * Y << endl;
  }
}

Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
using namespace std;


bool twodiv_search(const int n, int S[], const int key)
{
    int start = 0;
    int end = n;
    int mid;
    bool res = false;

    while (end - start > 0) {
        mid = (start + end) / 2;
//        printf("s %d e %d mid %d S[mid] %d\n", start, end, mid, S[mid]);
        if (S[mid] < key) {
            if (start == mid) break;
            start = mid;
        }
        else if (S[mid] > key) {
            if (end == mid) break;
            end = mid;
        }
        else {
            res = true;
            break;
        }
    }
    return res;
}

int main (void) {

    int n;
    int q;
    int key;
    int count = 0;

    scanf("%d", &n);
    int *S = new int[n+1];
    for (int i = 0; i < n; i++) scanf("%d", &S[i]);

    scanf("%d", &q);
    for (int i = 0; i < q; i++) {
        scanf("%d", &key);
        count += twodiv_search(n, S, key);
    }
    printf("%d\n", count);

    return 0;
}





Measured memory_bytes: 2992
N, K = map(int, input().split())
A = list(map(int, input().split()))

buckets = {}
for i in A:
    if i in buckets:
        buckets[i] += 1
    else:
        buckets[i] = 1

kinds = sorted(buckets.values(), reverse=True)
if K < len(kinds):
    mini = N-sum([kinds[i] for i in range(K)])
    print(mini)
else:
    print(0)

Measured memory_bytes: 33312
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(ll i=0;i<n;i++)
#define all(vec) vec.begin(), vec.end()
#define tmax(x,y,z) max((x),max((y),(z)))
#define tmin(x,y,z) min((x),min((y),(z)))
typedef long long ll; ll MM = 1000000000;ll mod = MM + 7; ll MMM=9223372036854775807;//2^63 -1
ll GCD(ll x, ll y) {if (y == 0) return x;else return GCD(y, x % y);}
ll LCM(ll x, ll y) { return x / GCD(x, y) * y;}
//cout << fixed << setprecision(10);

int main(){
    ll n,a,b; cin>>n>>a>>b;
    ll x= min(n%(a+b),a);
    cout<<(n/(a+b))*a + x ;
}

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

#define debug(s) cout << s << endl
#define debug1(s, t) cout << s << " " << t << endl
#define debug2(s, t, u) cout << s << " " << t << " " << u << endl
#define printvec(v)       \
    for (auto &&i : v)    \
        cout << i << " "; \
    cout << endl

using namespace std;
using i64 = long long;

bool pred(int c, int a, int b)
{
    return ((int)(c * 0.08) == a) && ((int)(c * 0.1) == b);
}

int main()
{
    int a, b;
    cin >> a >> b;

    int ok = 0;
    for (int c = 1; c <= 1000; c++)
    {
        if (pred(c, a, b))
        {
            ok = c;
            break;
        }
    }

    if (ok == 0)
        cout << -1 << endl;
    else
        cout << ok << endl;

    return 0;
}

Measured memory_bytes: 256
import java.io.IOException;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) throws IOException {

		Scanner scan = new Scanner(System.in);

		int x = scan.nextInt();

		if (x < 1200) {
			System.out.println("ABC");
		} else {
			System.out.println("ARC");
		}
	}

	//***********************以下共通関数************************************************
	/**
	 * 文字列を反転して返す
	 * @param pStr 文字列
	 * @return 反転した文字列
	 */
	public static String myReverse(String pStr) {
		if (pStr.length() < 1) {
			return "";
		}

		StringBuffer sb = new StringBuffer(pStr);
		return sb.reverse().toString();
	}

	/**
	 * 余りを求める。
	 * @param a
	 * @param b
	 * @return 余り。余りがマイナスの時はプラスで返す。
	 */
	public static long myMod(long a, long b) {
		long ret = 0;

		ret = a % b;

		if (ret < 0) {
			ret += b;
		}

		return ret;
	}

	/**
	 * 乗数を求める ※mod対応
	 * @param kisu 基数
	 * @param josu 乗数
	 * @param primeNumMod_0 法 mod値 使わない場合は「0」
	 * @return
	 */
	public static long myPowWithMod(long kisu, long josu, long primeNumMod_0) {

		long ans = 1;

		//乗数が0の場合→1
		if (josu == 0)
			return 1;

		if (primeNumMod_0 == 0) {
			//modを使わないとき

			while (josu > 0) {

				if (josu % 2 == 0) {
					//累乗が偶数の時

					kisu *= kisu;
					josu = josu / 2;
				} else {
					//累乗が奇数の時
					ans *= kisu;
					josu--;
				}
			}

			return ans;

		} else {
			//modを使うとき

			//初めに桁を落とす
			kisu = myMod(kisu, primeNumMod_0);

			while (josu > 0) {

				if (josu % 2 == 0) {
					//累乗が偶数の時

					kisu *= myMod(kisu, primeNumMod_0);
					josu = josu / 2;

				} else {
					//累乗が奇数の時
					ans *= myMod(kisu, primeNumMod_0);
					josu--;

				}
			}

			return myMod(ans, primeNumMod_0);

		}

	}

}


Measured memory_bytes: 27092
#include <stdio.h>
int main()
{
    int n,i;
    long long sum;
    scanf("%d",&n);
    if(n == 1)
    {
        printf("1\n");
    }
    else
    {
        for(i = 1,sum = 1; i <= n; i++)
            sum =(sum % (1000000000+7)) * (i %(1000000000+7));
        printf("%lld\n",sum%(1000000000+7));
    }
    return 0;
}


Measured memory_bytes: 128
#include <iostream>
#include <cmath>
#include <algorithm>
#include <vector>
#include <set>
#include <unordered_set>
#include <queue>
#include <deque>
#include <string>
#include <sstream>
#include <iomanip>
#include <map>
#include <unordered_map>
#include <stack>
#include <cstdio>
#include <climits>
#include <tuple>
#include <ctime> 
#define full(a) a.begin(), a.end()

#define sz(x) ((ll)(x).size())
#define ll long long
#define ull unsigned long long
using namespace std;

ll inp() {
    ll n; cin >> n;
    return n;
}

ll gcd(ll a, ll b) {
    while (b) {
        a %= b;
        swap(a, b);
    }
    return a;
}

template<class T>

void prvc(vector<T> vec) {
    for (auto i : vec)cout << i << " ";
    cout << endl;
}

pair<int, int> hat(pair<int, int> l, pair<int, int> r) {
    pair<int, int> ans;
    if (l.first > r.first)swap(l, r);
    if (r.first > l.second) {
        return pair<int, int>(-2e9, -2e9);
    }
    ans.first = r.first;
    ans.second = min(l.second, r.second);
    return ans;
}

ll cnm(ll n, ll m) {
    ll k = n - m;
    if (k < m)std::swap(k, m);
    ll l1 = 1;
    for (int i = k + 1; i <= n; i++) {
        l1 *= i;
        if (l1 % m == 0)l1 /= m, m--;
    }
    for (int i = 2; i <= m; i++)
    {
        l1 /= i;
    }
    return l1;
}

vector<ll> divs(ll n) {
    vector<ll> divisors;
    for (ll i = 1; i <= n; i++) {
        if (n % i == 0)divisors.push_back(i);
    }
    return divisors;
}

std::vector<std::string> split(const std::string& s, char delimiter)
{
    std::vector<std::string> tokens;
    std::string token;
    std::istringstream tokenStream(s);
    while (std::getline(tokenStream, token, delimiter))
    {
        tokens.push_back(token);
    }
    return tokens;
}

void solve() {
    string k; cin >> k;
    if (k[k.size() - 1] == 's') {
        k += "es";
    }
    else k += 's';
    cout << k << endl;
}


int main()
{
    ios::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
    //ll n; cin >> n;
    //while (n--)
        solve();

    return 0;
}

Measured memory_bytes: 3672
#include<cstdio>
#include<iostream>
#include<cstring>
using namespace std;

int main ()
{
	string s;
	cin>>s;
	if(s[0]=='Y'&&s[1]=='A'&&s[2]=='K'&&s[3]=='I')
		cout<<"Yes"<<endl;
	else
		cout<<"No"<<endl;
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
long long a[200001];
bool cmp(int x,int y)
{
	return x>y;
}
int main()
{
   long long n,x;
   cin>>n>>x;
   if(n<=x)
    {
    	cout<<0<<endl;
    	return 0;
	}
   for(int i=0;i<n;i++)
   {
   	   cin>>a[i];
   }
   partial_sort(a,a+x+1,a+n,cmp);
   long long ans=0;
   for(int i=x;i<n;i++)
   {
   	    ans+=a[i];
   }
   cout<<ans<<endl;
   return 0;
}


Measured memory_bytes: 1792
#include <bits/stdc++.h>
#include <boost/range/adaptor/reversed.hpp>
#include <boost/range/algorithm/sort.hpp>
#include <boost/range/irange.hpp>

using namespace std;
using boost::irange;
using boost::sort;
using boost::adaptors::reversed;

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

    double a = 100;
    long i = 0;

    while (1) {
        a = floor(a * 1.01);
        i++;
        if (a >= x) break;
    }

    cout << i << endl;
}


Measured memory_bytes: 3724
#include <iostream>

using namespace std;

using ll = long long;
const int AMAX = 100000;
ll cnt[AMAX + 1];

int main(void) {
    int N;
    ll K;
    cin >> N >> K;

    for (int i = 0; i < N; ++i) {
        int A, B;
        cin >> A >> B;
        cnt[A] += B;
    }

    for (int ans = 1; ans <= AMAX; ++ans) {
        if (K <= cnt[ans]) {
            cout << ans << endl;
            break;
        }
        K -= cnt[ans];
    }

    return 0;
}

Measured memory_bytes: 1024
#include<stdio.h>
int main(void){
    int before,after;
    int i;
    int flag = 0;
   scanf("%d %d",&before,&after);
if(before == 0 && after == 0)return 0;
        for(i = before;i <= after;i++){
            if(i % 4 == 0&&i % 100 != 0||i%400==0){
                    flag = 1;
                    printf("%d\n",i);
                }
            
        }
        if(flag == 0){
            printf("NA\n");
        }
        flag = 0;


    while(1){
scanf("%d %d",&before,&after);
        if(before == 0 && after == 0){
            break;
        }
puts("");
        for(i = before;i <= after;i++){
            if(i % 4 == 0&&i % 100 != 0||i%400==0){
                    flag = 1;
                    printf("%d\n",i);
                }
            
        }
        if(flag == 0){
            printf("NA\n");
        }
        flag = 0;

    }
    return 0;
}

Measured memory_bytes: 612
import java.util.*;
 
public class Main {
  public static void main (String[] args) {
    Scanner in = new Scanner(System.in);
    int f = in.nextInt();
    for (int i = 0; i < 3; i++) {
      int dum = in.nextInt();
    }
    int l = in.nextInt();
    int w = in.nextInt();
    String ans = w < l - f ? ":(" : "Yay!";
    System.out.println(ans);
  }
}

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

int main(){
	int lim,ju;
	lim = ju = 0;
	int c;
	for(int  i = 0 ; i < 3 ; i ++ ){
		cin>>c;
		if(c==5) lim++;
		if(c==7) ju++;
	}
	if(lim==2 && ju == 1) printf("YES\n");
	else printf("NO\n");
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG
#define rep(i, n) for (int64_t i = 0; i < (int64_t)(n); i++)
using vi = vector<int64_t>;
using vvi = vector<vi>;
int64_t INF = 1000000007;

int main() {
    // fasten cin
    cin.tie(0);
    ios::sync_with_stdio(false);
    // implement
    int64_t n;
    cin >> n;
    vi t(n);
    rep(i,n) cin >> t.at(i);
    // 最小公倍数ってことか
    int64_t gcd = t.at(0);
    int64_t lcm = t.at(0);
    rep(i,n){
        gcd = __gcd(t.at(i), lcm);
        lcm = t.at(i) * (lcm / gcd);
    }
    cout << lcm << endl;
}

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

int main(){
	string S;
  cin>>S;
  int count=0;
  for(int i=0;i<S.size()-1;i++){
  	for(int j=i+1;j<S.size();j++){
    	if(S.at(i)==S.at(j)){
          count++;
        	break;
        }
      if(count!=0)
        break;
    }
  }
  if(count==0)
    cout<<"yes"<<endl;
  else
    cout<<"no"<<endl;
}

Measured memory_bytes: 256
#include <algorithm>
#include <chrono>
#include <climits>
#include <cmath>
#include <deque>
#include <iostream>
#include <map>
#include <memory>
#include <numeric>
#include <set>
#include <string>
#include <utility>
#include <vector>

using namespace std;

using llong = long long;
using ullong = unsigned long long;

#ifndef __MACRO_H__
#define __MACRO_H__

#define all(collection)  (collection).begin(), (collection).end()
#define loop(i, times) for(llong i = 0; i < times; i++)
#define rloop(i, times) for(llong i = times -1; 0 <= i; i--)

std::chrono::system_clock::time_point  start;

void TimeStart(void)
{
	start = std::chrono::system_clock::now();
}

void TimeEnd(void)
{
	auto time = std::chrono::system_clock::now() - start;
	auto msec = std::chrono::duration_cast<std::chrono::milliseconds>(time).count();
	cerr << endl <<msec << " msec" << endl;
}

#endif

class AGC001B
{
public:
	AGC001B()
	{
		cin >> n_;
		cin >> x_;
		ans_ = 0;
	}
	void Run(void)
	{
		ans_ += x_;
		if (LoopLength1(x_, n_ - x_))
		{
			cout << ans_;
			return;
		}
		LoopLength2(n_ - x_, n_ % (n_ - x_));
		cout << ans_;
	}
private:
	/**
	@brief 繰り返し1回目の反射光の軌跡を計算する関数
	@param n 台形の下底の長さ
	@param x 反射光の長さ
	@note
	 下底の長さnの台形を長さxの反射光が反射したときの軌跡を求める。
	 出発点に戻ったらtrue、そうでなければfalseを返す。
	**/
	bool LoopLength1(llong n, llong x)
	{
		if (n % x == 0)
		{
			ans_ += (n / x * 2) * x;
			return true;
		}

		ans_ += (n / x * 2 + 1) * x;
		return false;
	}
	/**
	@brief 繰り返し2回目以降の反射光の軌跡を計算する関数
	@param n 平行四辺形の長さ
	@param x 反射光の長さ
	@note
	 長さnの平行四辺形を長さxの反射光が反射したときの軌跡をansに加算する。
	 反射光が出発点に戻るまで再帰的に繰り返す。
	**/
	void LoopLength2(llong n, llong x)
	{
		llong next_n = x;
		llong next_x = n % x;

		if (next_x == 0)
		{
			ans_ += (n / x * 2 - 1) * x;
			return;
		}
		
		ans_ += (n / x * 2) * x;
		LoopLength2(next_n, next_x);
	}
	llong n_;
	llong x_;
	llong ans_;
};

int main()
{
	AGC001B agc001b;

	TimeStart();
	agc001b.Run();
	TimeEnd();

	return 0;
}


Measured memory_bytes: 384
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

var sc = bufio.NewScanner(os.Stdin)

func nextInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}

func main() {
	sc.Split(bufio.ScanWords)
	var N, M int
	fmt.Scan(&N, &M)

	A := make([]int, N)

	Vote := 0
	for i := 0; i < N; i++ {
		num := nextInt()
		Vote += num
		A[i] = num
	}

	Count := 0
	for i := 0; i < N; i++ {
		if Vote <= A[i]*4*M {
			Count++
		}
	}

	if Count >= M {
		fmt.Println("Yes")
	} else {
		fmt.Println("No")
	}
}


Measured memory_bytes: 640
n, m=gets.split.map &:to_i
p=0.5**m
q=1-p
a=1900*m+100*(n-m)
res=p*a
2.upto(1000){|i|
    x=i*a*p*q
    res+=x
    break if x<1e-2
    q*=1-p
}
p res.ceil


Measured memory_bytes: 1788
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <array>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <sstream>
#include <stdio.h>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <list>
#include <numeric>
#include <stack>

using namespace std;

#define Rep(i,a,b) for(int i = a; i < b; i++)
#define rep(i,b) Rep(i,0,b)
#define rrep(i,a) for(int i = a; i >= 0; i--)
#define allof(a) (a).begin(), (a).end()

typedef long long ll;
const int inf = 1e9 + 7;
const ll infll = 1ll << 60ll;
const ll mod = 1e9 + 7;
// 0~3までは右左下上 4~7までは斜め
constexpr int dx[] = { 1, 0, -1, 0, 1, 1, -1, -1 };
constexpr int dy[] = { 0, -1, 0, 1, 1, -1, -1, 1 };

/*
// 最大公約数
ll gcd(ll a, ll b) {
	if (b == 0) return a;
	return gcd(b, a % b);
}

// 最小公倍数
ll lcm(ll a, ll b) {
	return a / gcd(a, b) * b;
}*/

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

	ll n, W;
	cin >> n >> W;
	vector<ll> w(n), v(n);
	rep(i, n) cin >> w[i] >> v[i];

	// dp[i][j]:= i番目までの商品を見たときの重さj以下での価値の最大値
	vector<vector<ll>> dp(n + 1, vector<ll>(W + 1, 0));

	Rep(i, 1, n + 1) {
		rep(j, W + 1) {
			if(j - w[i - 1] >= 0)
				dp[i][j] = max(dp[i][j], dp[i - 1][j - w[i - 1]] + v[i - 1]);
			dp[i][j] = max(dp[i][j], dp[i - 1][j]);
		}
	}

	cout << dp[n][W] << endl;

	return 0;
}


Measured memory_bytes: 80256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> l_l;
typedef pair<int , int> i_i;
typedef vector<ll> vl;
typedef vector<int> vi;
typedef vector<char> vec;
typedef vector<bool> veb;
typedef vector<string> ves;
typedef vector<vector<ll>> vvl;
typedef vector<vector<int>> vvi;
typedef vector<vector<char>> vvec;
typedef vector<vector<bool>> vveb;
typedef vector<vector<string>> vves;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep1(i,n) for(int i=1;i<(int)(n);i++)
#define rep2(i,n) for(int i=2;i<(int)(n);i++)
#define repk(i,k,n) for(int i=k;i<(int)(n);i++)
#define fs first
#define sc second
#define pb push_back
#define pp pop_back
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define maxel(a) *max_element(all(a))
#define minel(a) *min_element(all(a))
#define acc accumulate
#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
#define mod (1000000007)
typedef long long int64;
//const int64 INF = 1LL << 58;
#define dame { puts("-1"); return 0;}
#define YES { cout << "YES" << endl; return 0; }
#define NO { cout << "NO" << endl; return 0; }
#define Yes { cout << "Yes" << endl; return 0; }
#define No { cout << "No" << endl; return 0; }
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 (a>b) { a=b; return 1; } return 0; }
int dx[] = {0, 0, -1, 1};
int dy[] = {1, -1, 0, 0};

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
  
  	int a,b;
  	cin >> a >> b;
  	if(a<b){rep(i,b){cout << a ;}}
    else{rep(i,a){cout << b ;}}  
  	cout << endl;  	
    return 0;
}

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

int main(){
  int n;
  cin >> n;
  map<string, int> mp;
  rep(i,n){
    string s;
    cin >> s;
    mp[s]++;
  }
  int cntmax = 0;
  for(auto p : mp) cntmax = max(cntmax, p.second);
  for(auto p : mp){
    if(p.second == cntmax) cout << p.first << endl;
  }
}


Measured memory_bytes: 19152
#include<bits/stdc++.h>
#define pi 3.141592653897932384626
//freopen("in.txt","r",stdin);freopen("out.txt","w",stdout);
using namespace std;
int main()
{
    long a,b,x;
    cin>>a>>b>>x;
    if(x<=a+b&&x>=a)cout<<"YES";
    else cout<<"NO";
    cout<<endl;
	return 0;
}


Measured memory_bytes: 256
#設定
import sys
input = sys.stdin.buffer.readline

#ライブラリインポート
from collections import defaultdict
from heapq import heappop, heappush

con = 10 ** 9 + 7
INF = float('inf')

#入力受け取り
def getlist():
	return list(map(int, input().split()))

class Graph(object):
	def __init__(self):
		self.graph = defaultdict(list)

	def __len__(self):
		return len(self.graph)

	def add_edge(self, a, b, w):
		self.graph[a].append((b, w))

	def get_nodes(self):
		return self.graph.keys()

class Dijkstra(object):
	def __init__(self, graph, s):
		self.g = graph.graph
		self.dist = defaultdict(lambda: INF)
		self.dist[s] = 0
		self.Q = []
		heappush(self.Q, (self.dist[s], s))

		while self.Q:
			dist_u, u = heappop(self.Q)
			if self.dist[u] < dist_u:
				continue
			for v, w in self.g[u]:
				alt = dist_u + w
				if self.dist[v] > alt:
					self.dist[v] = alt
					heappush(self.Q, (alt, v))


#処理内容
def main():
	N, M, S = getlist()
	G = Graph()
	#グラフ構築
	for _ in range(M):
		U, V, A, B = getlist()
		for i in range(2500 - A + 1):
			G.add_edge(U * (10 ** 5) + 2500 - i, V * (10 ** 5) + 2500 - A - i, B)
			G.add_edge(V * (10 ** 5) + 2500 - i, U * (10 ** 5) + 2500 - A - i, B)

	for i in range(N):
		#i + 1が都市番号
		C, D = getlist()
		for j in range(2500):
			G.add_edge((i + 1) * (10 ** 5) + j, (i + 1) * (10 ** 5) + min(j + C, 2500), D)

	#ダイクストラ
	D = Dijkstra(G, 10 ** 5 + min(2500, S))

	for i in range(2, N + 1):
		ans = INF
		for j in range(2501):
			ans = min(D.dist[i * (10 ** 5) + j], ans)
		print(ans)
	




if __name__ == '__main__':
	main()

Measured memory_bytes: 136372
import sys
import math
import itertools
import collections
from collections import deque

sys.setrecursionlimit(1000000)
MOD = 10 ** 9 + 7
input = lambda: sys.stdin.readline().strip()

NI = lambda: int(input())
NMI = lambda: map(int, input().split())
NLI = lambda: list(NMI())
SI = lambda: input()

def main():
    N = NI()
    XL = [NLI() for _ in range(N)]
    
    #print(XL)
    arm_range = []
    for n in range(N):
        arm_range.append([XL[n][0]-XL[n][1],XL[n][0]+XL[n][1]])
    #print(arm_range)
    
    sorted_arm_range = sorted(arm_range, key=lambda x: x[1])  #[1]に注目してソート
    #print(sorted_arm_range)
    
    ans = 1
    arm_end = sorted_arm_range[0][1]
    
    if N == 1:
        ans = 1
    else:
        for n in range(N-1):
            if sorted_arm_range[n+1][0] >= arm_end:
                arm_end = sorted_arm_range[n+1][1]
                ans += 1

    print(ans)

if __name__ == '__main__':
    main()

Measured memory_bytes: 44728
#include <stdio.h>

int main(void){
  int n, i, x, min, max;
  long sum;
  
  scanf("%d", &n);
  scanf("%d", &x);
 
  min = max = sum = x;
  for(i=1;i<n;i++){
    scanf("%d",&x);
    sum += x;
    if( min > x ){
      min = x;
    }
    else if( max < x){
      max = x;
    }
  }
  printf("%d %d %ld\n", min, max, sum);
  
  return 0;
}

Measured memory_bytes: 1852
#!/usr/bin/env python3
import sys, math, fractions, itertools, collections, copy, heapq


def solve(N: int, A: "List[int]"):
    A = [1/a for a in A]
    s = 1/sum(A)
    print('%.10f' % s)
    return


# Generated by 1.1.4 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    A = [ int(next(tokens)) for _ in range(N) ]  # type: "List[int]"
    solve(N, A)

if __name__ == '__main__':
    main()


Measured memory_bytes: 5588
#include <algorithm>
#include <cmath>
#include <vector>


class ClosestPair {
private:
  std::vector<double> x, y;
  struct x_cmp {
    const ClosestPair &cp;
    x_cmp(const ClosestPair &cp) : cp(cp) {} 
    bool operator() (int i, int j) {
      return cp.x[i] < cp.x[j];
    }
  };
  struct y_cmp {
    const ClosestPair &cp;
    y_cmp(const ClosestPair &cp) : cp(cp) {} 
    bool operator() (int i, int j) {
      return cp.y[i] < cp.y[j];
    }
  };
  x_cmp xc;
  y_cmp yc;
  double dist2(int i, int j) const {
    return pow(x[i] - x[j], 2) + pow(y[i] - y[j], 2);
  }

  double min_brute_force(const std::vector<int> & v) const {
    double mi = 1.0 / 0.0;
    int n = v.size();
    for (int i = 0; i < n; ++i) {
      for (int j = 0; j < n; ++j) {
	if (i == j) {
	  continue;
	}
	mi = std::min(mi, dist2(v[i], v[j]));
      }
    }
    return mi;
  }


  double min_strip(const std::vector<int> &v, double d) const {
    double mi = d;
    int n = v.size();
    for (int i = 0; i < n; ++i) {
      for (int j = i + 1; j < n && pow(y[v[j]] - y[v[i]], 2) < mi; ++j) {
	mi = std::min(mi, dist2(v[i], v[j]));
      }
    }
    return mi;
  }

  /*
   */
  double min_pair_util(const std::vector<int> &vx) const {
    int n = vx.size();
    if (n <= 4) {
      return min_brute_force(vx);
    }
    // divide at middle
    int mid = n / 2;
    double mid_x = x[vx[mid]];
    double ml = min_pair_util(std::vector<int>(vx.begin(), vx.begin() + mid));
    double mr = min_pair_util(std::vector<int>(vx.begin() + mid, vx.end()));
    double dist = std::min(ml, mr);
    std::vector<int> strip;
    for(int i = 0; i < n; ++i) {
      if (pow(x[vx[i]] - mid_x, 2) < dist) {
	strip.push_back(vx[i]);
      }
    }
    std::sort(strip.begin(), strip.end(), yc);
    double res = min_strip(strip, dist);
    return res;
  }
  ClosestPair(const std::vector<double> &xs, const std::vector<double> &ys) : x(xs), y(ys), xc(*this), yc(*this) {
  }
  double internal_solve(void) const {
    int n = x.size();
    std::vector<int> v(n);
    for (int i = 0; i < n; ++i) {
      v[i] = i;
    }
    std::sort(v.begin(), v.end(), xc);
    return std::sqrt(min_pair_util(v));
  }
public:
  static double solve(const std::vector<double> &xs, const std::vector<double> &ys) {
    return ClosestPair(xs, ys).internal_solve();    
  }
};
#define REP(i,s,n) for(int i=(int)(s);i<(int)(n);i++)

#include <cstdio>
#include <iostream>

using namespace std;
typedef long long int ll;
typedef vector<int> VI;
typedef pair<int, int> PI;
const double EPS=1e-9;

int main(void){
  int n;
  cin >> n;
  vector<double> x(n), y(n);
  REP(i, 0, n) {
    cin >> x[i] >> y[i];
  }
  printf("%.9f\n", ClosestPair::solve(x, y));
}

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

using namespace std;

int main()
{
    //system("chcp 65001");
    int dist[5];
    int k;
    int i,j;
    bool ans = true;
    for(i = 0;i <= 4;i++)
    {
        cin >> dist[i];
    }
    cin >> k;

    for(i = 0;i <= 4;i++)
    {
        for(j = i;j <= 4;j++)
        {
            if(i != j)
            {
                //cout << i << " " << j << endl;
                if(dist[j] - dist[i] > k)
                {
                    ans = false;
                }
            }
        }
    }

    if(ans == false)
    {
        cout << ":(";
    }
    else
    {
        cout << "Yay!";
    }
    
    //cout << N;

    return 0;
}

Measured memory_bytes: 256
#!/usr/bin/env python
# -*- coding: utf-8 -*-

import sys  # {{{
import os
import time
import re
from pydoc import help
import string
import math
from operator import itemgetter
from collections import Counter
from collections import deque
from collections import defaultdict as dd
import fractions
from heapq import heappop, heappush, heapify
import array
from bisect import bisect_left, bisect_right, insort_left, insort_right
from copy import deepcopy as dcopy
import itertools
# }}}

# pre-defined{{{
sys.setrecursionlimit(10**7)
INF = 10**20
GOSA = 1.0 / 10**10
MOD = 10**9+7
ALPHABETS = [chr(i) for i in range(ord('a'), ord('z')+1)]  # can also use string module
def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def DP(N, M, first): return [[first] * M for n in range(N)]
def DP3(N, M, L, first): return [[[first] * L for n in range(M)] for _ in range(N)]
from inspect import currentframe
# }}}

def solve():
    s = input()
    if s == "ABC":
        print("ARC")
    else:
        print("ABC")

    return 0

if __name__ == "__main__":# {{{
    solve()

# vim: set foldmethod=marker: }}}


Measured memory_bytes: 79868
a, v = map(int, input().split())
b, w = map(int, input().split())
t = int(input())

if v > w:
    # 1秒あたり距離はv-wだけ縮まる
    # t秒の時の距離は(v-w)*t
    # それが|a-b| の距離に間に合うor追い越せるかどうか
    if abs(a - b) <= (v - w) * t:
    # if t <= abs(a - b):
        print("YES")
    else:
        print("NO")
else:
    print("NO")

Measured memory_bytes: 9012
#include<bits/stdc++.h>
using namespace std;
int main()
{
  string s;
  cin>>s;
  int k=0;
  int ma=0;
  for(int i=0;i<3;i++)
  {if(s[i]=='R')
      k++;
   else
     k=0;
   ma=max(ma,k);
  }
  cout<<ma;
}

Measured memory_bytes: 3616