akhauriyash/Code-Regression huggingface dataset:
#include <stdio.h>

int main(void)
{	
	short int n, i, count_red = 0, count_blue = 0;

  	scanf("%hd", &n);

  	char str[n+1];

  	scanf("%s", str);

  	for(i = 0; i < n; ++i) {
        if (str[i] == 'R') count_red++;
        else count_blue++;
  	}

  	if (count_red > count_blue) printf("Yes\n");
  	else printf("No\n");
  
  	return 0;
}

Measured memory_bytes: 128
#include <algorithm>
#include <iostream>
#include <math.h>
#include <string>
using namespace std;
int main() {
  int a,b,c; cin>>a>>b>>c;
  int ans;
  for(int i=0;i<a;i++){
    if(a<(b+c)*i+c) {ans=i-1;break;}
  }
  cout<<ans<<endl;
  return 0;
}

Measured memory_bytes: 256
/*
 * Author: Anmol Choudhary
 */
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define rep0(a,b) for(int a=0;a<b;a++)
#define rep1(a,b) for(int a=1;a<=b;a++)
#define repp(a,b,c) for(int a=b;a<c;a++)
#define in insert
#define len length()
#define si size()
#define lb lower_bound
#define ub upper_bound
#define beg begin()
#define en end()
#define f first
#define s second
#define pr(a) cout<<a
#define pr2(a,b) cout<<a<<" "<<b<<"\n"
#define nextl cout<<"\n"
#define deb(x) cout<<#x<<"="<<x<<"\n"
#define deb2(x,y) cout<<"["<<#x<<"="<<x<<"] , ["<<#y<<"="<<y<<"]"<<"\n"
const ll mod = 1000000007;
const ll maxn = 100005;
const double mm = 1e+30;
ll power(ll x, ll y)
{
    ll res = 1;
    x = x % mod;
    while (y > 0)
    {
        if (y & 1)
            res = (res*x) % mod;
        y = y>>1;
        x = (x*x) % mod;
    }
    return res;
}
ll f(ll n){
    if(n==1) return 1;
    return (1+2*f(n/2));
}
void solve()
{
    ll n;
    cin>>n;
    cout<<f(n);
}
int main()
{
    ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    int t=1;
    //cin>>t;
    while(t--){
        solve();
        //nextl;
    }
    return 0;
}


Measured memory_bytes: 256
#!/usr/bin/env python3
import sys
INF = float("inf")


def solve(N: int, S: str):

    m = -INF
    for i in range(1, N):          # S[:i]とS[i:]
        kind = 0
        for c in set(S[:i]):
            if S[i:].count(c) > 0:
                kind += 1
        if kind > m:
            m = kind
        # print(S[:i], S[i:], kind)
    print(m)
    return


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
    S = next(tokens)  # type: str
    solve(N, S)


if __name__ == '__main__':
    main()


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

int main(){

    ios::sync_with_stdio(false);
    cin.tie(0);

    int n, x, t;
    cin >> n >> x >> t;
    int ans = ceil((double)n/x)*t;
    cout<<ans<<'\n';   

    return 0;
}


Measured memory_bytes: 3644
#include <iostream>
#include <string>
using namespace std;
int main(){
    string S,T;
    cin >> S >> T;
    int sl, tl;
    sl = (int) S.length();
    tl = (int) T.length();
    if (sl + 1 != tl) {
        cout << "No" << endl;
        return 0;
    }
    for (int i=0; i<sl; i++){
        if (S.at(i) != T.at(i)){
            cout << "No" << endl;
            return 0;
        }
    }
    cout << "Yes" << endl;
}

Measured memory_bytes: 3632
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <utility>
using namespace std;
typedef long long ll;
#define rep(i, n) for (int i=0;i < (int)(n);i++)

int main(){
   int a,b;
   string s;
   cin >> a >> b;
   cout << 2*b-a << endl;
   return 0;
   
}



Measured memory_bytes: 256
using System;

namespace ABC129
{
    class B
    {
        static void Main(string[] args)
        {
            int N = int.Parse(Console.ReadLine());
            string[] input = Console.ReadLine().Split(' ');

            int[] W = new int[N];
            for (int i = 0; i < N; i++)
            {
                W[i] = int.Parse(input[i]);
            }

            int[] S = new int[N + 1];
            S[0] = 0;
            for (int i = 0; i < N; i++)
            {
                S[i + 1] += S[i] + W[i];
            }

            int[] A = new int[N];
            for (int i = 0; i < N; i++)
            {
                A[i] = Math.Abs(S[N] - 2 * S[i]);
            }

            Array.Sort(A);

            Console.WriteLine(A[0]);

        }
    }
}


Measured memory_bytes: 13140
// Problem : B - I miss you...
// Contest : AtCoder - AtCoder Beginner Contest 154
// URL : https://atcoder.jp/contests/abc154/tasks/abc154_b
// Memory Limit : 1024 MB
// Time Limit : 2000 ms
// Powered by CP Editor (https://github.com/cpeditor/cpeditor)

#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;

//Macros

#define ll long long
#define db long double
#define pb push_back
#define eb emplace_back
#define pii pair<int,int>
#define vi vector<int>
#define vii vector<pii>
#define mi map<int,int>
#define mii map<pii,int>
#define fi first
#define se second
#define all(a) (a).begin(),(a).end()
#define sz(x) (int)x.size()
#define mod 1000000007
#define EPS 1e-9
#define io ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0)
#define inf 1e10
#define PI acos(-1.0)
#define int long long
template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
#define N 100005

//Solution

void solve(){
    string s;
    cin>>s;
    for(char &c : s) c = 'x';
    cout<<s<<endl;
}

signed main(){
    io;
    //freopen("input.txt", "r", stdin); freopen("output.txt", "w", stdout);
    int tests;
    //cin>>tests;
    tests = 1;
    while(tests--){
        solve();
    }
    return 0;
}

Measured memory_bytes: 3652
import java.util.Scanner;

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

		int h = sc.nextInt();
		int a = sc.nextInt();
		int count=1;

		while(h>a) {
			h -= a;
			count++;
		}

		System.out.println(count);
		sc.close();
	}
}


Measured memory_bytes: 35760
#include <bits/stdc++.h>
using namespace std;
#define rep(i,a,b) for(int i=(a);i<(b);i++)
#define all(x) x.begin(), x.end()
#define sz(x) (int)(x).size()
#define trav(a, x) for(auto& a : x)
typedef long long ll;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef long double ld;
ll md = 1e9+7;

int main(){
    cin.sync_with_stdio(0); cin.tie(0);
    cin.exceptions(cin.failbit);

    int n;
    cin >> n;
    string s;
    cin >> s;
    vi numc(26);
    rep(i,0,n){
        numc[s[i]-'a']++;
    }
    ll ans=1;
    rep(i,0,26){
        ans *= numc[i]+1;
        ans %= md;
    }
    ans--;
    if(ans < 0){
        ans += md;
    }

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


Measured memory_bytes: 1104
#include <bits/stdc++.h>
#define f first
#define s second
#define mp make_pair
#define pb push_back
#define lp(i,a,n) for(int i=a;i<=n;++i)
#define lpd(i,a,n) for(int i=a;i>=n;--i)
#define mem(a,b) memset(a,b,sizeof a)
#define all(v) v.begin(),v.end()
#define println(a) cout <<(a) <<endl
#define sz(x) ((int)(x).size())
#define readi(x) scanf("%d",&x)
#define read2i(x,y) scanf("%d%d",&x,&y)
#define read3i(x,y,z) scanf("%d%d%d",&x,&y,&z)
#define mod 1000000007
#define eps 1e-8
#define infi 1000000000
#define infll 1000000000000000000ll
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vll;
typedef set<int> si;
typedef map<int,int> mii;

const int N = 100002;
int n,a[N];

ll check(ll mid){
    lp(i,1,n) mid = mid / a[i] * a[i];
    return mid;
}

int main(){
    readi(n);
    lp(i,1,n) readi(a[i]);

    ll l = 0, r = 1e16;
    while(l < r){
        ll mid = (l + r) / 2;
        if(check(mid) >= 2) r = mid;
        else l = mid + 1;
    }
    if(!l) return cout <<-1, 0;
    ll ans1 = l;

    l = 0, r = 1e16;
    while(l < r){
        ll mid = (l + r) / 2 + 1;
        if(check(mid) <= 2) l = mid;
        else r = mid - 1;
    }
    ll ans2 = l;

    if(ans1 <= ans2) cout <<ans1 <<" " <<ans2;
    else cout <<-1;
}

/*
freopen("input.txt","r",stdin);
freopen("output.txt","w",stdout);
*/


Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
using ll = long long int;
#define INF 100000000
#define rep(i,a,b) for(int (i)=a;(i)<(int)(b);(i)++)

int main(){
    int N;
    string S;
    cin >> N >> S;
    vector<int> R,G,B;
    rep(i,0,N){
        if (S[i] == 'R') R.push_back(i);
        else if (S[i] == 'G') G.push_back(i);
        else B.push_back(i);
    }

    ll sum = R.size() * G.size()* B.size();
    auto res1 = find(B.begin(),B.end(),B[0]);
    auto res2 = find(B.begin(),B.end(),B[0]);
    auto res3 = find(B.begin(),B.end(),B[0]);
    rep(i,0,R.size()){
        rep(j,0,G.size()){
            if (R[i]>G[j]){
                res1 = find(B.begin(),B.end(),R[i] + (R[i]-G[j]));
                res2 = find(B.begin(),B.end(),G[j] - (R[i]-G[j]));
                if((R[i]-G[j])%2 ==0){
                    res3 = find(B.begin(),B.end(),G[j]+(R[i]-G[j])/2);                
                }
                else res3 = B.end();
            }
            else{
                res1 = find(B.begin(),B.end(),G[j] + (G[j]-R[i]));
                res2 = find(B.begin(),B.end(),R[i] - (G[j]-R[i]));
                if((G[j]-R[i])%2 ==0){
                res3 = find(B.begin(),B.end(),R[i]+(G[j]-R[i])/2);                
                }
                else res3 = B.end();
            }

            if(res1 != B.end()) sum --; 
            if(res2 != B.end()) sum --;
            if(res3 != B.end()) sum --;
            //if(res1 == B.end() || res2 != B.end() || res3 != B.end()) sum --;
            
        }
    }
    cout << sum << endl;
}

Measured memory_bytes: 3628
class LazySegmentTreeBase
  def initialize(l, r)
    @l, @r = l, r
    @lazy = nil
    if l == r
      @completed = 0
    else
      c = (l + r) / 2
      @left_child = self.class.new(l, c)
      @right_child = self.class.new(c + 1, r)
    end
  end

  attr_reader :l, :r

  def update(l, r, x)
    if l == @l && r == @r
      defer(x)
    else
      force
      if r <= @left_child.r
        @left_child.update(l, r, x)
      elsif @right_child.l <= l
        @right_child.update(l, r, x)
      else
        @left_child.update(l, @left_child.r, x)
        @right_child.update(@right_child.l, r, x)
      end
    end
  end

  def force
    return if !@lazy
    x = @lazy
    @lazy = nil
    whole_update(x) if @l == @r
    @left_child.update(@left_child.l, @left_child.r, x) if @left_child
    @right_child.update(@right_child.l, @right_child.r, x) if @right_child
  end

  def query(i)
    force
    return @completed if @l == @r
    if i <= @left_child.r
      return @left_child.query(i)
    else @right_child.l <= i
      return @right_child.query(i)
    end
  end
end

class LazySegmentTree < LazySegmentTreeBase
  def defer(x)
    if !@lazy
      @lazy = x.dup
    elsif x[0] == @lazy[-1] + 1
      @lazy[1] = x[1]
    else
      @lazy = [-1, -1]
    end
  end

  def whole_update(x)
    if x[0] == @completed + 1
      @completed = x[1]
    else
      @completed = -1
    end
  end
end

n, k = gets.split.map(&:to_i)
seg = LazySegmentTree.new(1, n)
q = gets.to_i
q.times do
  l, r, x = gets.split.map(&:to_i)
  seg.update(l, r, [x, x])
end

answer = 0
(1..n).each do |i|
  c = seg.query(i)
  answer += 1 if c == k
end
p answer


Measured memory_bytes: 75636
import itertools
#まず＋を入れる場合と入れない場合、すべてのパターンをALLにリストとして入れる
S = input()
ALL = list(itertools.product(["+",""],repeat=len(S)-1))
#たとえばSが125の三文字なら、ALLには以下の４種類が入る。
#[('+', '+'), ('+', ''), ('', '+'), ('', '')]
count = 0
for kigou in ALL:
    #Sの文字と文字の間に、ALLのパターン通りに＋を入れるか入れないかして、
    #1+2+5、1+25、12+5のような式を文字列として生成し、tmpとする
    tmp = ""
    for i in range(len(S)-1):
        tmp += S[i]
        tmp += kigou[i]
    tmp += S[len(S)-1]
    #tmpとして生成した式を計算する。Pythonではevalを使えば済む。
    count += eval(tmp)
#print(ALL)
print(count)

Measured memory_bytes: 3060
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <map>
#include <cmath>
#include <iomanip>
using namespace std;
typedef long long ll;

int main() {
    ll N; cin >> N;
    vector<ll> A(N), S(N+1);
    for(int i = 0; i < N; i++) cin >> A[i];
    S[0] = 0;
    for(int i = 0; i < N; i++) S[i+1] = S[i] + A[i];
    sort(S.begin(), S.end());
    ll cnt=1;
    ll ans = 0;
    for(int i = 1; i < N+1; i++){
        if(S[i-1] != S[i]) {
            if(cnt > 1){
                ans += cnt*(cnt-1)/2;
                //cout << cnt*(cnt-1)/2 << endl;
            }
            cnt=1;
        }
        else cnt++;
    }
    if(cnt > 1) ans += cnt*(cnt-1)/2;
    cout << ans << endl;
}

Measured memory_bytes: 3328
#include <stdio.h>
#include <algorithm>
#include <tuple>
#include <functional>
#include <queue>
#include <set>

using namespace std;
using ll = long long;
using pii = pair<ll, ll>;

int n, m, l, s[(1 << 18) + 10];
multiset<int> task;
vector<int> maked;
int main() {
	scanf("%d", &n);
	m = 1 << n;
	for (int i = 0; i < m; i++)
		scanf("%d", s + i), task.emplace(s[i]);
	multiset<int>::iterator itr = task.end();
	itr--;
	maked.emplace_back(*itr);
	task.erase(itr);

	bool valid = true;
	for (int step = 0; step < n && valid; step++) {
		l = 1 << step;
		for (int i = 0; i < l && valid; i++) {
			itr = task.lower_bound(maked[i]);
			if (itr == task.begin()) {
				valid = false;
				continue;
			}
			itr--;
			maked.emplace_back(*itr);
			task.erase(itr);
		}
	}
	printf(valid ? "Yes\n" : "No\n");
}

Measured memory_bytes: 14716
#include <stdio.h>

int gcd(int a, int b);
int lcm(int a, int b);

int main(void)
{
    int a, b;

    while (scanf("%d %d", &a, &b) != EOF){
        printf("%d %d\n", gcd(a, b), lcm(a, b));
    }

    return (0);
}

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

int lcm(int a, int b)
{
    return (a / gcd(a, b) * b);
}

Measured memory_bytes: 596
#include <limits.h>
#include <stdint.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <time.h>
#include <unistd.h>
#include <math.h>

#define P

int comp(const void *a, const void *b){return *(int*)a-*(int*)b;}

int main(void){
	int n, m, k, i;
	int a[100001], b[100001];
	int amin=INT_MAX, bmin=INT_MAX;
	scanf("%d%d%d", &n, &m, &k);
	for(i=1; i<=n; i++){
		scanf("%d", &a[i]);
		if(a[i]<amin) amin=a[i];
	}
	for(i=1; i<=m; i++){
		scanf("%d", &b[i]);
		if(b[i]<bmin) bmin=b[i];
	}
	int ans=amin+bmin;
	for(i=0; i<k; i++){
		int A, B, x;
		scanf("%d%d%d", &A, &B, &x);
		int now = a[A]+b[B]-x;
		if(now<ans) ans=now;
	}
	printf("%d\n", ans);
}


Measured memory_bytes: 896
#include <stdio.h>
#include <stdlib.h>
int compare(const void *a,const void *b){
    if(*(int *)a<*(int *)b)return 1;
    return -1;
}
int main()
{   int k,t;
    scanf("%d%d",&k,&t);
    int a[t];
    for(int i=0;i<t;i++)
    scanf("%d",&a[i]);
    qsort(a,t,sizeof(int),compare);
    if(a[0]<=k/2){
        printf("0");
        return 0;
    }
    for(int i=1;i<t;i++){
        a[0]-=a[i];
    }
    printf("%d",a[0]-1);
    return 0;
}


Measured memory_bytes: 128
#include <cstdio>
#include <cstring>
#include <iostream>
#include <algorithm>
#include <vector>
using namespace std;
#define rep(i,n) for(int i=0; i<(n); ++i)
#define outl(x) cout<< (x) << '\n'
using pii = pair<int,int>;
using ll = long long;

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

    int N, K;
    cin >> N >> K;

    int a = N / K;
    int b = (N+K-1) / K;

    outl(abs(a-b));

    return 0;
}



Measured memory_bytes: 256
import java.util.*;

class Main{
public static void main(String[] args){
Scanner sc = new Scanner(System.in);
String s = sc.next();

int l =0;
int r = 0;
for(int  i=0;i<s.length() ;i++){
if('A'==s.charAt(i)) {
  
l = i;
break;
}
}
for(int i=s.length()-1;0<i;i--){
if('Z'==s.charAt(i)){



r=i;
break;
}
}
System.out.println(r-l+1);

} 
}

Measured memory_bytes: 24788
//I am so vegetable
//#define _LOCAL_
#pragma GCC optimize(2)
#include <bits/stdc++.h>
#define FIO ios::sync_with_stdio(false), cin.tie(0), cout.tie(0)
#define PB push_back
#define IN insert
#define ER erase
#define CT count
#define EP empty
#define _for(i,a,b) for(ll i = (a);i<(b);++i)
#define _rfor(i,a,b) for(int i = (a);i>(b);--i)
#define _sfor(p,st) for(auto &p:st)
using namespace std;
typedef long long ll;
const int INF = 0x3f3f3f3f;
const ll N = 1e5 + 5;
const int MOD = 998244353;
const double eps = 1e-6;
const double pi = acos(-1);
int gcd(int a, int b) { return b == 0 ? a : gcd(b, a % b); }
ll qpow(ll x, ll y) { ll ans = 1; for (; y > 0; y >>= 1) { if (y & 1)ans *= x; x *= x; }return ans; }

int main() {
	FIO;
	ll x;cin>>x;
	ll ans = x/500*1000;
	x = x - x/500*500;
	ans += x/5*5;
	cout<<ans;
	return 0;
}

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

int main(int argc, const char * argv[]) {
    int P, Q, R;
    
    cin >> P >> Q >> R;
    
    if(P <= R && Q <= R){
        cout << P + Q << endl;
    } else if(P <= Q && R <= Q){
        cout << P + R << endl;
    } else{
        cout << Q + R << endl;
    }
    
    return 0;
}


Measured memory_bytes: 256
//
//  main.cpp
//
// https://atcoder.jp/contests/abc128/tasks/abc128_d

#include <algorithm>
#include <array>
#include <assert.h>
#include <functional>
#include <iostream>
#include <limits>
#include <math.h>
#include <memory>
#include <queue>
#include <random>
#include <set>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <string>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <vector>

using namespace std;

using ll = long long;
using ull = unsigned long long;

int main(int argc, char* argv[]) {
    #ifdef DEBUG
//    if (argc >= 2) {
//        assert(freopen(argv[1], "r", stdin));
//    }
    #endif // DEBUG
    int N, K;
    cin >> N >> K;
    vector<ll> Vis;
    for (int i = 0; i < N; i++) {
        int Vi;
        cin >> Vi;
        Vis.push_back(Vi);
    }
    ll max_value = 0;
    for (int A = 0; A <= N; A++) {
        for (int B = 0; B <= N; B++) {
            if (A + B > N || A + B > K) {
                continue;
            }
            priority_queue<ll, std::vector<ll>, greater<ll>> gems;
            ll value = 0;
            for (int i = 0; i < A; i++) {
                gems.push(Vis[i]);
                value += Vis[i];
            }
            for (int i = 0; i < B; i++) {
                gems.push(Vis[Vis.size() - i - 1]);
                value += Vis[Vis.size() - i - 1];
            }
            int i = 0;
            while (i < K - A - B && !gems.empty() && gems.top() < 0) {
                value -= gems.top();
                gems.pop();
                i++;
            }
            max_value = max(value, max_value);
        }
    }
    cout << max_value << endl;
}



Measured memory_bytes: 888
#include <bits/stdc++.h>
#define pb push_back
typedef long long ll;
typedef long double la;
using namespace std;
 
int main(){
    ll n,x,sum=0;
    cin >> n >> x;
    vector<ll> a(n);
    for(int i=0;i<n;i++){
        cin >> a[i];
        sum += a[i];
    }
    if(sum == x){
        cout << n << endl;
        return 0;
    }
    if(sum < x){
        cout << n-1 << endl;
        return 0;
    }else{
        sort(a.begin(),a.end(),greater<ll>());
        int b = n;
        for(int i=0;i<n;i++){
            sum -= a[i];
            b--;
            if(sum <= x){
                cout << b << endl;
                return 0;
            }
        }
    }
}

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

int main() {
   int A, B, K, curr = 0;
   scanf("%d %d %d", &A, &B, &K);
   for (int i = 100; i >= 1; i--) {
      if (A % i == 0 && B % i == 0)
         curr++;
      if (curr == K) {
         printf("%d\n", i);
         return 0;
      }//if
   }//for
}//main


Measured memory_bytes: 256
#include <stdio.h>
#include <math.h>
#include <algorithm>
#include <queue>

using namespace std;


int main(){

	int L,A,B,C,D,day_kokugo,day_sansu;

	scanf("%d",&L);
	scanf("%d",&A);
	scanf("%d",&B);
	scanf("%d",&C);
	scanf("%d",&D);

	day_kokugo = A/C;
	if(A%C > 0)day_kokugo++;

	day_sansu = B/D;
	if(B%D > 0)day_sansu++;

	printf("%d\n",L-max(day_kokugo,day_sansu));

	return 0;
}



Measured memory_bytes: 2732
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define rep(i,n) for (int i = 0; i < (n); ++i)
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; }
const ll INF=1LL<<60;
const int inf=1<<30;
const int mod=1e9+7;
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    string s;cin >> s;
    int m=2019;
    vector<ll> dp(m);
    int n=s.size();
    ll ans=0;
    rep(i,n){
        vector<ll> tp(m);
        int p=s[i]-'0';
        dp[0]++;
        rep(j,m){
            if(!dp[j]){
                continue;
            }   
            tp[(j*10+p)%m]+=dp[j];
        }
        rep(j,m){
            dp[j]=tp[j];
        }
        ans+=dp[0];
    }
    cout << ans << endl;
}

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

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define REP(i, n) for (int i = 1; i <= (int)(n); i++)
#define all(v) v.begin(), v.end()
using ll = long long;

template <typename T>
bool chmax(T& a, const T& b) {
	if (a < b) {
		a = b;  // aをbで更新
		return true;
	}
	return false;
}

template <typename T>
bool chmin(T& a, const T& b) {
	if (a > b) {
		a = b;  // aをbで更新
		return true;
	}
	return false;
}


int main() {
	string abc = "ABC";
	string arc = "ARC";

	string mae;
	cin >> mae;
	if (mae == abc)cout << arc << endl;
	else cout << abc << endl;
	return 0;
}


Measured memory_bytes: 3632
#include<iostream>
#include<string>
#include<math.h>
#include<vector>
#include<algorithm>
#include<iomanip>
#include<stack>

#define ll long long
#define vl vector<ll>
#define vvl vector< vector<ll> >
#define vb vector<bool>
#define vbb vector< vector<bool> >
#define vs vector<string>
#define vc vector<char>
#define vvc vector< vector<char> >

#define all(a) (a).begin(),(a).end()
using namespace std;

int main(){
	ll a, b, c; cin >> a >> b >> c;
	ll ans = abs(a - b) + abs(a - c) + abs(b - c);
	ans -= max({ abs(a - b), abs(a - c), abs(b - c) });
	cout << ans << endl;
	return 0;
}

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

using namespace std;

int main(){

    ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL); cout.precision(20);
    //freopen("intput.txt", "r", stdin);
    string s;
    cin >> s;
    int ans = 0;
    for(int i = 0; i < s.size(); i++)
        ans += s[i]-'0';
    if(ans == 1 and s.size()>1)
        ans = 10;
    cout << ans << endl;
    

}

Measured memory_bytes: 256
#include <stdio.h>
#include<math.h>
int main(void){
    double x1,y1,x2,y2;
    scanf("%lf %lf %lf %lf\n",&x1,&y1,&x2,&y2);
    printf("%f\n",sqrt((x2-x1)*(x2-x1)+(y2-y1)*(y2-y1)));
    return 0;
}



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

using namespace std;

#define REP(i,n)	for(int i=0, i##_len=(n); i<i##_len; ++i)
#define REPS(i,s,n)	for(int i=(s), i##_len=(n); i<i##_len; ++i)

#define ALL(obj)	(obj).begin(),(obj).end()
#define sz(x) (int)(x).size()
#define v(T) vector<T>
#define VEC vector

typedef unsigned int 			uint;
typedef unsigned long long int	ull;
typedef long long int 			ll;

typedef pair<int,int>			P;
typedef vector<int>				Vint;
typedef vector<Vint>			VV;

template<typename T>string join(const v(T)&v)
{stringstream s;REP(i,sz(v))s<<' '<<v[i];return s.str().substr(1);}
template<typename T>inline ostream& operator<<(ostream&o,const v(T)&v)
{if(sz(v))o<<join(v);return o;}

#undef _P
#define _P(...) (void)printf(__VA_ARGS__)
#define MAX 		100010


const ll LINF = (ll)9e18+7;		//
const int INF = 100100100;			//2,147,483,647 (Max int)
const ll MOD = 1e9+7;
// テンプレ終了
//====================================================================//

// int DP[MAX];


int main(){
	ll N; cin >> N;
	
	string ans;

	while(N){
		N--;
		ans = (char)('a'+N%26) + ans;
		N /= 26;
	}

	cout << ans << endl;

	return 0;
}
 



Measured memory_bytes: 3632
#include<stdio.h>
#include<stdlib.h>

#define NIL -2000000000

typedef struct{
  int k;
  int lk;
  int rk;
}Node;

int main(){

  Node *A;
  int h,i,x;

  scanf("%d",&h);

  A = malloc((h+1)*sizeof(Node));

  for(i = 1 ; i <= h ; i++) A[i].k = A[i].lk = A[i].rk = NIL;


  for(i = 1 ; i <= h ; i++){
    scanf("%d",&x);

    A[i].k = x;
    if(i%2 == 0) A[i/2].lk = x;
    else if(i%2 == 1) A[i/2].rk =x;

  }

  for(i = 1 ; i <= h ; i++){

    printf("node %d: key = %d, ", i, A[i].k);
    if(i != 1) printf("parent key = %d, ",A[i/2].k);
    if(A[i].lk != NIL)  printf("left key = %d, ",A[i].lk);
    if(A[i].rk != NIL)  printf("right key = %d, ",A[i].rk);

    printf("\n");

  }

  return 0;

}

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

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

typedef long long ll;
typedef pair<int, int> P;
typedef tuple<int, int, int> TUPLE;
typedef vector<int> V;
typedef vector<V> VV;
typedef vector<VV> VVV;

const int INF = 1e9;

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

int H, W;
VV a;
set<P> dead;
int ans;

bool inside(int x, int y) {
    return 0 <= x && x < H && 0 <= y && y < W;
}

void dfs(int x, int y, int c) {
    if (c > 10) return;

    rep(k, 4) {
        int nx = x + dx[k], ny = y + dy[k];
        if (!inside(nx, ny)) continue;
        if (a[nx][ny] == 1 && !dead.count(P(nx, ny))) continue;
        while (true) {
            if (!inside(nx, ny)) break;
            if (a[nx][ny] == 1 && !dead.count(P(nx, ny))) {
                dead.insert(P(nx, ny));
                dfs(nx - dx[k], ny - dy[k], c + 1);
                dead.erase(P(nx, ny));
                break;
            }
            else if (a[nx][ny] == 3) {
                ans = min(ans, c);
                // break;
            }

            nx += dx[k], ny += dy[k];
        }
    }
}

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

    int t = 0;
    while (cin >> W >> H, H) {

        a.clear();
        a.resize(H, V(W));
        int sx, sy;
        rep(i, H) rep(j, W) {
            cin >> a[i][j];
            if (a[i][j] == 2) {
                sx = i, sy = j;
            }
        }

        dead.clear();
        ans = INF;
        dfs(sx, sy, 1);

        // t++;
        // cout << "case " << t << ":" << H << " " << W << endl;
        // rep(i, H) {
        //     rep(j, W) {
        //         cout << a[i][j] << " ";
        //     }
        //     cout << endl;
        // }

        cout << (ans == INF ? -1 : ans) << endl;

        // cout << endl;
    }
}

Measured memory_bytes: 3180
#include <bits/stdc++.h>
using namespace std;
int main(void)
{
    int a, b, ans = 0;
    cin >> a >> b;
    if (a <= 5)
    {
        ans = 0;
    }
    else if (a <= 12)
    {
        ans = b / 2;
    }
    else
    {
        ans = b;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 384
A=['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z']
C=str(input())
for i in range(26):
  if A[i]==C:
    print(A[i+1])

Measured memory_bytes: 38256
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <queue>
#include <stack>
#include <set> 
#include <map>
#include <bitset>
#include <cctype>
#include <cmath>
#include <cstring>
#include <iomanip>
#define REP(i,n) for(int i=0; i<(n); ++i)
#define FOR(i,a,b) for(int i=(a); i<(b); ++i)
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
const int INF = 100100100;
const ll INFLL = 100100100100100100;
const int MOD = (int)1e9 + 7;
const ll MODLL = (ll)1e9 + 7;
const double EPS = 1e-9;
 
int main () {
    
    int n; cin >>n;
    vector<double> p(n); REP(i,n) cin >> p[i];

    vector<vector<double> > dp(n+1, vector<double>(n+1, 0));
    dp[0][0] = 1;
    for (int i = 0; i < n; i++) {
        for (int j = 0; j <= n; j++) {
            dp[i+1][j] += dp[i][j]*(1-p[i]);
            if (j >= 1) {
                dp[i+1][j] += dp[i][j-1]*p[i];
            }  
        }
    }

    double ans = 0;
    for (int j = 0; j <= n; j++) {
        if (j > (n/2)) {
            ans += dp[n][j];
        } 
    }

    cout << setprecision(12) << ans << endl;
    return 0;
}

 

Measured memory_bytes: 70784
import java.io.IOException;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.*;
import java.io.*;

class Main
{
 public static void main(String[] args) throws IOException
 {
	 BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
     String str = br.readLine();
     String[] abc = str.split(" ", 0);
     int W = Integer.parseInt(abc[0]);
     int H = Integer.parseInt(abc[1]);
     int x = Integer.parseInt(abc[2]);
     int y = Integer.parseInt(abc[3]);
     int r = Integer.parseInt(abc[4]);
     

     if(r<=H-y){
    	 if (r<=y){
    		 if(r<=W-x){
    			 if(r<=x){
    				 System.out.println("Yes");
    			 }
    			 else{
    	    		 System.out.println("No");}
    		 }
    		 else{
        		 System.out.println("No");}
         }
    	 else{
    		 System.out.println("No");}
    	 }
    	 else{
    		 System.out.println("No");}
    
 }
}

Measured memory_bytes: 24424
#include <iostream>
#include <algorithm>
#include <string>
#include <map>
#include <math.h>
#include <set>

using namespace std;
typedef long long  ll;

#define rep(i,s,n)for(ll i=s;i<n;i++)
#define repe(i,s,n)for(ll i=s;i<=n;i++)
ll MOD = 1000000007;

int main() {
	ll N; string s; cin >> N >> s;
	ll lw = 0, le = 0, rw = 0, re = 0;
	rep(i, 0, s.size()) {
		if (s[i] == 'W')
		{
			rw++;
		}
		else {
			re++;
		}
	}

	ll minV = 1 << 29;

	rep(i, 0, s.size()) {
		if (i > 0) {
			if (s[i - 1] == 'W') {
				lw++;
			}
			else {
				le++;
			}
		}
		if (s[i] == 'W') {
			rw--;
		}
		else {
			re--;
		}
		minV = min(minV, lw + re);
	}
	cout << minV << endl;

	return 0;
}

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

int main(){
	vector<int>a(5); for(auto&i:a)cin>>i;
	int dis=0;
	for(int i=0;i<4;++i){
		for(int j=i+1;j<5;++j){
			dis=max(dis,a.at(j)-a.at(i));
		}
	}
	int k; cin>>k;
	cout<<(dis>k?":("s:"Yay!"s)<<"\n"s;
}


Measured memory_bytes: 256
# coding: utf-8
import sys

stdin = sys.stdin
ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))
ns = lambda: stdin.readline().rstrip() # ignore trailing spaces


def distance(a,b):
    return ((a[0]-b[0])**2 + (a[1]-b[1])**2)**0.5


def main():
    n = ni()
    points = []
    ave1path = 0
    for _ in range(n):
        points += [na()]
    for i in range(n-1):
        for j in range(i+1,n):
            ave1path += distance(points[i], points[j])
    print(ave1path*2 / n)
    return


if __name__ == '__main__':
    main()

Measured memory_bytes: 38384
#include <iostream>
#include <sstream>
#include <algorithm>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <stack>
#include <memory>
#include <complex>
#include <numeric>
#include <cstdio>
#include <iomanip>
#include <random>

#define REP(i,m,n) for(int i=int(m);i<int(n);i++)
#define RREP(i,m,n) for(int i=int(n)-1;i>=int(m);--i)
#define EACH(i,c) for (auto &(i): c)
#define all(c) begin(c),end(c)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort(begin(c),end(c))
#define pb emplace_back
#define MP make_pair
#define SZ(a) int((a).size())
//#define int long long

#ifdef LOCAL
#define DEBUG(s) cout << (s) << endl
#define dump(x)  cerr << #x << " = " << (x) << endl
#define BR cout << endl;
#else
#define DEBUG(s) do{}while(0)
#define dump(x) do{}while(0)
#define BR 
#endif
using namespace std;

using UI = unsigned int;
using UL = unsigned long;
using LL = long long;
using ULL = unsigned long long;
using VI = vector<int>;
using VVI = vector<VI>;
using VLL = vector<LL>;
using VVLL = vector<VLL>;
using VS = vector<string>;
using PII = pair<int,int>;
using VP = vector<PII>;
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; }

long long power(long long x, long long n, long long mod) {
    if (n == 0) return 1;
    if (n % 2 == 0) return power(x * x % mod, n/2, mod);
    else return x * power(x, n-1, mod) % mod;
}

int countbits(long bits)
{
    bits = (bits & 0x55555555) + (bits >> 1 & 0x55555555);
    bits = (bits & 0x33333333) + (bits >> 2 & 0x33333333);
    bits = (bits & 0x0f0f0f0f) + (bits >> 4 & 0x0f0f0f0f);
    bits = (bits & 0x00ff00ff) + (bits >> 8 & 0x00ff00ff);
    return (bits & 0x0000ffff) + (bits >>16 & 0x0000ffff);
}

void solve() {
    int n;
    cin >> n;
    string s;
    cin >> s;
    VI x(n);
    REP(i,0,n) x[i] = s[i] - '0';
    int cnt = 0;
    REP(i,0,n) cnt += x[i];

    VI dp(n+1);
    REP(i,1,n+1) {
        int v = countbits(i);
        dp[i] = dp[i%v] + 1;
    }

    LL tl = 0, ts = 0, sum = 0;
    REP(i,0,n) {
        if (x[i] == 1) {
            tl += power(2,n-1-i,cnt+1);
            tl %= cnt+1;
            if (cnt - 1 <= 0) continue;
            ts += power(2,n-1-i,cnt-1);
            ts %= cnt-1;
        }
        sum += (x[i] << i);
    }
    dump(tl);
    dump(ts);
    dump(sum);

    REP(i,0,n) {
        if (x[i] == 1) {
            if (cnt == 1) {
                cout << 0 << endl;
                continue;
            }
        }

        LL v;
        if (x[i] == 1) {
            v = (ts - power(2,n-1-i,cnt-1) + (cnt-1)) % (cnt-1);
        } else {
            v = (tl + power(2,n-1-i,cnt+1)) % (cnt+1);
        }
        // dump(v);
        cout << dp[v%(cnt+(x[i]==1?-1:1))] + 1 << endl;
    }

    // REP(i,0,n+1) cerr << i << ": " << dp[i] << endl;
}

signed main() {
    solve();
    
    return 0;
}

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


int main()
{
    srand((unsigned)time(NULL));
    int k;
    string s;

    cin >> k >> s;

    //部分文字列をとりだす関数substr
    //文字列の長さをとる.size()
    if (s.size() <= k)cout << s << endl;
    else {
        s = s.substr(0, k);
        s += "...";
        cout << s << endl;
    }
    return 0;
}

Measured memory_bytes: 3096
/* ****revpro**** */
#include<bits/stdc++.h>
#define ll          long long
#define pb          push_back
#define endl       '\n'
#define pii         pair<ll,ll>
#define vi          vector<ll>
#define all(a)      (a).begin(),(a).end()
#define F           first
#define S           second
#define sz(x)       (ll)x.size()
#define hell        1000000007
#define rep(i,a,b)  for(ll i=a;i<b;i++)
#define repr(i,a,b) for(ll i=b-1;i>=a;i--)    
#define lbnd        lower_bound
#define ubnd        upper_bound
#define bs          binary_search
#define mp          make_pair
#define present(c,x) ((c).find(x) != (c).end())
#define cpresent(c,x) (find(all(c),x) != (c).end())
#define mii        map<ll,ll>
using namespace std;

#define N  100005
signed main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    
    int TESTS=1;
//    cin>>TESTS;
    while(TESTS--)
    {
        ll a,b,c;
        cin>>a>>b>>c;
        if(a>=c){
            a-=c;
            c=0;
        }
        else {
            c-=a;
            a=0;
            b=max(0LL,b-c);
        }
        cout<<a<<' '<<b;
    }
    return 0;
}

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

int main() {
  int N;
  cin >> N;
  vector<string> S(N);
  for (int i=0; i<N; i++){
    cin >> S.at(i);
  }
  sort(S.begin(), S.end());
  vector<pair<int, string>> p;
  p.push_back(make_pair(1, S.at(0)));
  int j = 0;
  for (int i=0; i<N-1; i++){
    if (S.at(i) == S.at(i+1)){
      p.at(j).first += 1;
    }
    else{
      j++;
      p.push_back(make_pair(1, S.at(i+1)));
    }
  }
  sort(p.begin(), p.end());
  int i = 0;
  int M = p.size();
  vector<string> st;
  st.push_back(p.at(M-1).second);
  if (p.size() == 1){
    cout << st.at(0) << endl;
    return 0;
  }
  if (p.at(0).first == p.at(M-1).first){
    for (int i=0; i<M-1; i++){
      st.push_back(p.at(i).second);
    }
    sort(st.begin(), st.end());
    for (int i=0; i<st.size(); i++){
      cout << st.at(i) << endl;
    }
    return 0;
  }
  while (p.at(M-i-1).first == p.at(M-i-2).first){
    st.push_back(p.at(M-i-2).second);
    i++;
  }
  sort(st.begin(), st.end());
  for (int i=0; i<st.size(); i++){
    cout << st.at(i) << endl;
  }
}

Measured memory_bytes: 22000
let () =
  let r, g, b, n = Scanf.scanf "%d %d %d %d\n" (fun r g b n -> r, g, b, n) in
  let cnt = ref 0 in
  for i = 0 to 3000 do
    for j = 0 to 3000 do
      let tmp = i * r + j * g in
      if n - tmp >= 0 && (n - tmp) mod b = 0 then cnt := !cnt + 1;
    done;
  done;
  print_int !cnt

Measured memory_bytes: 384
import java.util.Arrays;
import java.util.Scanner;
import java.util.TreeMap;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner((System.in));
		int n = sc.nextInt();
		TreeMap<Integer, Integer> s = new TreeMap<Integer, Integer>();
		int sum = 0;
		String ans = "Yes";

		for (int i = 0; i < n; i++) {
			int a = sc.nextInt();
			int b = sc.nextInt();
			if (s.get(b) != null) {
				s.put(b, s.get(b) + a);
			} else {
				s.put(b, a);
			}
		}

		for (int i : s.keySet()) {
			if (sum + s.get(i) <= i) {
				sum += s.get(i);
			} else {
				ans = "No";
				break;
			}
		}

		System.out.println(ans);

		sc.close();
	}
}


Measured memory_bytes: 124844
#include <iostream>
#include <fstream>
#include <vector>
#include <queue>
#include <string>
#include <limits>
#include <algorithm>
#include <map>
#include <sstream>
#include <unordered_map>

using ll = long long;
using ull = unsigned long long;
using uint = unsigned int;
static ull tenq = 1000000000;
static ull mod = tenq + 7;

using namespace std;

int main()
{
  ll N;
  cin >> N;
  vector<ll> as(N), bs(N), cs(N);
  for (auto i = 0; i < N; i++) cin >> as[i];
  for (auto i = 0; i < N; i++) cin >> bs[i];
  for (auto i = 0; i < N; i++) cin >> cs[i];
  sort(as.begin(), as.end());
  sort(bs.begin(), bs.end());
  sort(cs.begin(), cs.end());

  ll res = 0;
  ll ia = 0, ic = 0;
  for (auto i = 0; i < N; i++) {
    while (ia < as.size() && as[ia] < bs[i]) {
      ia++;
    }
    while (ic < cs.size() && cs[ic] <= bs[i] ) {
      ic++;
    }
//    cout << "ib=" << bs[i] << " ia=" << ia << " ic=" << ic << " num=" << (ia * (cs.size() - ic))  << endl;
    res += ia * (cs.size() - ic);
  }

  cout << res << endl;

  return 0;
}


Measured memory_bytes: 2560
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
const ll MOD = 1e9 + 7;
const double EPS = 1e-10;
int A[100000];
ll fact[100001];
ll sum[100001];
ll mod_pow(ll a, ll b) {
	if (b == 0) return 1;
	if (b % 2 == 0) {
		ll x = mod_pow(a, b / 2);
		return (x*x) % MOD;
	}
	return (a*mod_pow(a, b - 1)) % MOD;
}
int main() {
	int N;
	cin >> N;
	for (int i = 0; i < N; i++) {
		cin >> A[i];
	}
	fact[0] = 1;
	for (int i = 1; i <= N; i++) {
		fact[i] = (fact[i - 1] * i) % MOD;
		sum[i] = (sum[i - 1] + mod_pow(i, MOD - 2)) % MOD;
	}
	ll ans = 0;
	for (int i = 0; i < N; i++) {
		ll add = sum[i + 1] + sum[N - i];
		(add += MOD - 1) %= MOD;
		(add *= fact[N]) %= MOD;
		(add *= A[i]) %= MOD;
		(ans += add) %= MOD;
	}
	cout << ans << endl;
}

Measured memory_bytes: 2176
#include<bits/stdc++.h>
using namespace std;
map<int,int>mp;
int a[100002];
string s;
int main()
{
    int i,j,n,m,k,l,p=0,ac=0;
    cin>>n>>m;
    for(i=0;i<m;i++)
    {
        cin>>l>>s;
        if(s=="WA" && mp[l]==0)
        {
            a[l]++;
        }
        else if(s=="AC" && mp[l]==0)
        {
            ac++;
            mp[l]=1;
        }
    }
    for(i=1;i<=n;i++)
    {
        if(mp[i]==1)
        {
            p+=a[i];
        }
    }
    cout<<ac<<" "<<p<<"\n";
    return 0;
}


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

using namespace std;


//repetition
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define euc_dis(x, y) sqrt(x*x + y*y)
#define each(it,c) for(__typeof((c).begin()) it=(c).begin();it!=(c).end();it++)

#define pb push_back
#define INF 999999999
#define MOD 1000000007
#define sp ' '


//typedef
typedef long long ll;
typedef pair<int, int> pint;
typedef pair<long, long> pll;
typedef map<int, int> mint;
typedef set<int> sint;
typedef vector<int> vint;
typedef vector<char> vchr;
typedef vector<long long> vll;
typedef vector<string> vstr;


ll mod(ll a, ll b){return (a%b+b)%b;}
ll gcd(ll a, ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a, ll b){return a*b/gcd(a,b);}
void Yes(){cout << "Yes" << endl;}
void No(){cout << "No" << endl;}
void Judge(bool b){b?Yes():No();}
void YES(){cout << "YES" << endl;}
void NO(){cout << "NO" << endl;}
void JUDGE(bool b){b?YES():NO();}
ll powMod(ll a, ll b, ll c){ll ans=1; rep(i, b){ans=ans*a%c;} return ans;}
double distance(ll x1, ll y1, ll x2, ll y2){return sqrt((x1-x2)*(x1-x2) + (y1-y2)*(y1-y2));}

template<typename T>
void ppp(T n){cout << n << endl;}
template<typename T>
void dpp(T n){cerr << n << endl;}
template<typename T>
void vpp(T a){rep(i,a.size()){cout << a[i] << endl;}}
template<typename T>
void vdp(T a){rep(i,a.size()){cerr << a[i] << endl;}}

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

int main(){

    cin.tie(0);
    ios::sync_with_stdio(false);

    string s;
    cin >> s;

    reverse(s.begin(), s.end());
    while(!s.empty()){
        if(s.substr(0,7) == "remaerd"){
            s.erase(s.begin(), s.begin()+7);
        }
        else if(s.substr(0,6) == "resare"){
            s.erase(s.begin(), s.begin()+6);
        }
        else if(s.substr(0,5) == "maerd" or s.substr(0,5) == "esare"){
            s.erase(s.begin(), s.begin()+5);
        }
        else{
            break;
        }

    }

    JUDGE(s.empty());


    return 0;
}


Measured memory_bytes: 512
#include<stdio.h>
int h, w, i, j;
char s[52][53];


int main(){
	scanf("%d%d\n", &h, &w);
	for(i=1; i<=h; i++){
		gets(s[i]+1);
	}
	for(i=1; i<=h; i++){
		for(j=1; j<=w; j++){
			if(s[i][j] != '#'){
				s[i][j] = '0' + 
						(s[i-1][j-1]=='#') + (s[i-1][j]=='#') + (s[i-1][j+1]=='#') + (s[i][j-1]=='#') + 
						(s[i][j+1]=='#') + (s[i+1][j-1]=='#') + (s[i+1][j]=='#') + (s[i+1][j+1]=='#');
			}
		}
	}
	for(i=1; i<=h; i++){
		puts(s[i]+1);
	}
}


Measured memory_bytes: 128
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cstdlib>

using namespace std;

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

typedef long long ll;

int main(){
	int n, k;
	
	cin >> n >> k;
	
	int cnt = k;
	
	REP(i,n-1) cnt *= (k-1);
	
	cout << cnt << endl;
	
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<math.h>
#include<string>
#include<map>
#include<vector>
#include<utility>
#include<set>
#include<map>
#include<queue>
#include<stack>
#include<numeric>
#include<iomanip>
#define MAX 500005
#define MOD 1000000007
#define lo long long
#define INF 1e18
#define pp pair<long long , long long>
#define ppp pair<long long, pair<long long, long long> >
#define pb(a) push_back(a)
#define fi first
#define se second
#define PI 3.14159265
using namespace std;

lo dp[MAX];
int main() {

    lo S;
    cin>>S;

    dp[3]=1;  
    dp[4]=1;
    dp[5]=1;
    for(int i=6; i<=S; i++) {
    	dp[i] = 1;
        for(int j=3; j<=i; j++) {
            dp[i] = (dp[i]%MOD + dp[i-j]%MOD)%MOD;
        }

        //cout<<i<<" "<<dp[i]<<endl;
    }

    cout<<dp[S]<<endl;
}

Measured memory_bytes: 3640
import itertools as ite


def dist_cal(point_i, point_j):
    total = 0
    for i, j in zip(point_i, point_j):
        total += (i-j)**2
    return total ** (1/2)


n, d = map(int, input().split())

x = []
for i in range(n):
    _list = list(map(int, input().split()))
    x.append(_list)

cmb = list(ite.combinations(x, 2))

cnt = 0
for i, j in cmb:
    dist = dist_cal(i, j)

    if dist == int(dist):
        cnt += 1

print(cnt)

Measured memory_bytes: 3064
#include <stdio.h>
#include <stdlib.h>
#include <math.h>

int main(void)
{
  int N,M;
  int A[1000];
  int i,j,sum,max,tmp;
  sum = 0;
  scanf("%d %d",&N,&M);
  for(i=0;i<N;i++)
  {
    scanf("%d",&A[i]);
    sum += A[i];
  }

  for(i=0;i<M;i++)
  {
    max = 0;
    tmp = 0;
    for(j=0;j<N;j++)
    {
      if(max < A[j])
      {
        max = A[j];
        tmp = j;
      }
    }
    A[tmp] = 0;
    if(max < (double)sum/(4.0*(double)M))
    {
      printf("No\n");
      break;
    }
    if(i == M-1)
    {
      printf("Yes\n");
    }
  }

  return 0;
}

Measured memory_bytes: 128
N = int(input())
S = input()

count = 0
for p in range(1000):
    v = format(p, '03')
    found = False
    pos1 = S.find(v[0])
    if pos1 == -1:
        continue
    pos2 = S[pos1 + 1:].find(v[1])
    if pos2 == -1:
        continue
    pos3 = S[pos1 + pos2 + 2:].find(v[2])
    if pos3 == -1:
        continue
    count += 1

print(count)


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

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

template<class T> inline bool chmax(T& a, T b) {
    if(a < b) {
        a = b;
        return true;
    }
    return false;
}
struct Unionfind {
    vector<int> par;
    vector<int> sizes;

    Unionfind(int n) : par(n), sizes(n, 1) {
        for(int i = 0; i < n; ++i) par[i] = i;
    }

    int root(int x) {
        if(par[x] == x) return x;
        return par[x] = root(par[x]);
    }

    void unite(int x, int y) {
        int rx = root(x);
        int ry = root(y);
        if(rx == ry) return;
        if(sizes[x] < sizes[y]) swap(x, y);
        par[ry] = rx;
        sizes[rx] += sizes[ry];
    }

    bool same(int x, int y) {
        int rx = root(x);
        int ry = root(y);
        return rx == ry;
    }

    int size(int x) {
        return sizes[root(x)];
    }

};

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

    int n, k;
    cin >> n >> k;

    vector<int> x(n);
    rep(i, n) cin >> x[i];

    int l, r;
    l = r = 0;
    int l_abs, r_abs;
    l_abs = r_abs = 0;
    int MAX = 1e9;

    int to_distance = MAX;
    int ans = MAX;

    for(int i = 0; i < n - k + 1; ++i) {
        l = x[i];
        r = x[i + k-1];
        l_abs = abs(x[i]);
        r_abs = abs(x[i + k-1]);
        to_distance = min( l_abs + abs(x[i+k-1] - x[i]) , r_abs + abs(x[i] - x[i+k-1]) );
        ans = min(ans, to_distance);
    }

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

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

int main()
{
  int x, y, z;
  cin >> x >> y;
  z = (4 * x - y) / 2;
  if(0 <= z && z <= x && 2 * z + 4 * (x - z) == y)
    cout << "Yes" << endl;
  else
    cout << "No" << endl;
  
  return 0;
}

Measured memory_bytes: 3536
#include<iostream>

using namespace std;

int main(){
	int a;
	int b;
	int c;
	int d[10000] = { 0 };
	int e = 0;
	cin >> a;
	cin >> b;
	cin >> c;
	for (int i = 0; i < b - a + 1; i++){
		d[i] = a + i;
	}
	for (int i = 0; i < b - a + 1; i++){
		if (c%d[i] == 0){
			e = e + 1;
		}
	}
	cout << e << endl;
	return 0;
}

Measured memory_bytes: 3140
#include <bits/stdc++.h>
using namespace std;
int main(){
  int a,b,c,d,e,f;
  float s,w;
  int ans1,ans2;
  float ma=0;
  cin >> a >> b >> c >> d >> e >> f;
  for(int n=0; n<=f/(100*a); n++){
    for(int m=0; m<=(f-100*a*n)/(100*b); m++){
      for(int p=0; p<=(f-100*a*n-100*b*m)/c; p++){
        for(int q=0; q<=(f-100*a*n-100*b*m-c*p)/d; q++){
          w = 100*a*n+100*b*m;
          s = c*p+d*q;
          if(s+w==0){break;}
          if(100*s<=w*e && s+w <= f){
            if(ma <= (100*s)/(s+w)){
              ma = (100*s)/(s+w);
              ans1=s+w;
              ans2=s;
            }
          }
        }
      }
    }
  }
  cout << ans1 << " " << ans2 << endl;
}

Measured memory_bytes: 256