akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <vector>
#include <algorithm>
#include <fstream>
#include <string>
#include <math.h>
#include <cstdlib>
#include <istream>
#include <sstream>
#include <cctype>
using namespace std;

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

	for(int i=0;i<S.size();i++){
		int tt;
		char t;
		tt=(int)S[i]+N;
		if(tt<=90){
			t = (int)S[i]+N;
			cout << t;
		}
		else{
			t = (int)S[i]+N-26;
			cout << t;
		}
	}
	cout << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using VI = vector<int>;
using VL = vector<ll>;
#define FOR(i,a,n) for(int (i)=(a);(i)<(n);++(i))
#define eFOR(i,a,n) for(int (i)=(a);(i)<=(n);++(i))
#define rFOR(i,a,n) for(int (i)=(n)-1;(i)>=(a);--(i))
#define erFOR(i,a,n) for(int (i)=(n);(i)>=(a);--(i))
#define SORT(i) sort((i).begin(),(i).end())
#define rSORT(i,a) sort((i).begin(),(i).end(),(a))
#define all(i) (i).begin(),(i).end()
constexpr ll INF = 1000000000;
constexpr ll LLINF = 1LL << 60;
constexpr ll mod = 1000000007;
constexpr ll MOD = 998244353;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; }return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; }return 0; }
inline void init() { cin.tie(nullptr); cout.tie(nullptr); ios::sync_with_stdio(false); cout << fixed << setprecision(15); }
template<class T>inline istream& operator>>(istream& input, vector<T>& v) { for (auto& elemnt : v)input >> elemnt; return input; }

int main() {
    init();
        
    VI a(3); cin >> a;
    bool ok = true;
    ok &= a[0] <= a[2];
    ok &= a[1] >= a[2];
    cout << (ok ? "Yes\n" : "No\n");
}


Measured memory_bytes: 256
use std::io::Read;
use std::cmp;

fn main() {
    let mut buf = String::new();
    std::io::stdin().read_to_string(&mut buf).unwrap();
    let mut iter = buf.split_whitespace();

    let n: usize = iter.next().unwrap().parse().unwrap();
    let m: usize = iter.next().unwrap().parse().unwrap();

    let mut g: Vec<Vec<usize>> = vec![Vec::new(); n];
    let mut s: Vec<usize> = Vec::with_capacity(m);
    let mut t: Vec<usize> = Vec::with_capacity(m);
    for i in 0..m {
        s.push(iter.next().unwrap().parse().unwrap());
        t.push(iter.next().unwrap().parse().unwrap());
        s[i] -= 1;
        t[i] -= 1;
        g[s[i]].push(t[i]);
    }

    let mut arrive: Vec<f32> = vec![0.0; n];
    arrive[0] = 1.0;
    for u in 0..n {
        for v in &g[u] {
            arrive[*v] += arrive[u] / g[u].len() as f32;
        }
    }

    let mut aisle: Vec<f32> = vec![0.0; n];
    for u in (0..n).rev() {
        for v in &g[u] {
            aisle[u] += aisle[*v] + 1.0;
        }
        aisle[u] /= cmp::max(1, g[u].len()) as f32;
    }

    let mut ans: f32 = aisle[0];
    for i in 0..m {
        if g[s[i]].len() == 1 { continue; }

        let mut res: f32 = 0.0;
        res += aisle[s[i]] * g[s[i]].len() as f32;
        res -= aisle[t[i]] + 1.0;
        res /= (g[s[i]].len() - 1) as f32;
        res = aisle[s[i]] - res;
        res = aisle[0] - res * arrive[s[i]];
        ans = f32::min(res, ans);
    }

    println!("{:.10}", ans);
}

Measured memory_bytes: 12540
#include <bits/stdc++.h>
#define int long long
#define foru(i, a, b) for(int i = a; i < b; ++i)
#define ford(i, a, b) for(int i = a; i > b; --i)
#define vi vector < int >
#define vii vector < vi >
#define ld long double
using namespace std;

int n, m;
vi a;
int reserved = (int)1e14;
vector < vector < pair < int, int > > > g;
void no(){
    cout << "No";
    exit(0);
}
void dfs(int v, int curdst){
    a[v] = curdst;
    for(auto u: g[v]){
        if(a[u.first] == reserved){
            dfs(u.first, curdst + u.second);
        } else {
            if(a[u.first] != curdst + u.second)no();
        }
    }
}


signed main()
{
    cin >> n >> m;
    g.resize(n);
    a.resize(n, reserved);
    foru(i, 0, m){
        int l, r, d;
        cin >> l >> r >> d;
        l--, r--;
        g[r].push_back({l, -d});
        g[l].push_back({r, d});
    }
    foru(i, 0, n){
        if(a[i] == reserved)dfs(i, 0);
    }
    cout << "Yes";
}


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

int main()
{
	int A, B;
	int count=0;

	scanf("%d%d", &A, &B);

	int N=1;
	while (N < B)
	{
		N += A - 1;
		count++;
	}

	printf("%d", count);
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<int,int>;
#define INF 1000000007
//0=48,A=65,a=97

int main() {
    int n;
    cin >> n;
    string s;
    cin >> s;
 
    vector<int> lbfw(n);//left brack from white
    int nlb=0;//now left brack;

    for(int i = 0; i < n; i++) {
        if(s[i]=='#') nlb++;
        else lbfw[i]=nlb;
    } 

    int rw=0;//right white
    int ans=INF;

    for(int i = n-1; i >= 0; i--) {
        if(s[i]=='.'){
            ans = min(ans, lbfw[i]+rw);
            rw++;
        }
    }
    ans = min(ans, rw);
    if(ans==INF) ans = 0;

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 4432
#define  _CRT_SECURE_NO_WARNINGS
#include <stdio.h>
#include <algorithm>
#include <utility>
#include <functional>
#include <cstring>
#include <queue>
#include <stack>
#include <math.h>
#include <iterator>
#include <vector>
#include <string>
#include <set>
#include <math.h>
#include <iostream>
#include <random>
#include<map>
#include <iomanip>
#include <time.h>
#include <stdlib.h>
#include <list>
#include <typeinfo>
#include <list>
#include <set>
#include <cassert>
#include<fstream>
#include <unordered_map>
#include <cstdlib>
#include <complex>
using namespace std;
using ll = long long;
#define Ma_PI 3.141592653589793
#define eps 0.00000001
#define LONG_INF 3000000000000000000
#define rep(i,n) for(long long i = 0;i < n;++i)    
#define seg_size 524288
const int mod = 1000000007;

struct mint {
  ll x; // typedef long long ll;
  mint(ll x=0):x((x%mod+mod)%mod){}
  mint operator-() const { return mint(-x);}
  mint& operator+=(const mint a) {
    if ((x += a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator-=(const mint a) {
    if ((x += mod-a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator*=(const mint a) { (x *= a.x) %= mod; return *this;}
  mint operator+(const mint a) const { return mint(*this) += a;}
  mint operator-(const mint a) const { return mint(*this) -= a;}
  mint operator*(const mint a) const { return mint(*this) *= a;}
  mint pow(ll t) const {
    if (!t) return 1;
    mint a = pow(t>>1);
    a *= a;
    if (t&1) a *= *this;
    return a;
  }

  // for prime mod
  mint inv() const { return pow(mod-2);}
  mint& operator/=(const mint a) { return *this *= a.inv();}
  mint operator/(const mint a) const { return mint(*this) /= a;}
};
istream& operator>>(istream& is, const mint& a) { return is >> a.x;}
ostream& operator<<(ostream& os, const mint& a) { return os << a.x;}
int main(){
    int n;
    cin>>n;
    vector<ll>a(n);
    rep(i,n)cin>>a[i];
    mint ans=0;
    rep(i,60){
        mint x=0,y=0;
        rep(j,n){
            if(a[j]>>i&1)x+=1;
            
        }
        
        mint num=x*(n-x.x);
        //cout<<i<<"桁目"<<endl;
        //cout<<x<<endl<<num<<endl;
        rep(j,i)num*=2;
        ans+=num;
        //cout<<"ans="<<ans<<endl<<endl;

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

Measured memory_bytes: 2560
/**
 *    author:  tourist
 *    created: 28.04.2018 16:16:25       
**/
#include <bits/stdc++.h>

using namespace std;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n;
  long long s;
  cin >> n >> s;
  vector<long long> x(n);
  vector<long long> p(n);
  for (int i = 0; i < n; i++) {
    cin >> x[i] >> p[i];
  }
  vector<long long> route;
  long long ans = 0;
  int i = 0, j = n - 1;
  while (true) {
    if (x[j] < s) {
      route.push_back(x[i]);
      break;
    }
    if (x[i] > s) {
      route.push_back(x[j]);
      break;
    }
    if (p[i] >= p[j]) {
      route.push_back(x[j]);
      p[i] += p[j];
      j--;
    } else {
      route.push_back(x[i]);
      p[j] += p[i];
      i++;
    }
  }
  for (int ii = (int) route.size() - 1; ii >= 0; ii--) {
    ans += abs(s - route[ii]);
    s = route[ii];
  }
  cout << ans << '\n';
  return 0;
}


Measured memory_bytes: 2936
while 1:
    n, x = map(int, input().split())
    if n == 0 and x == 0:
        break
    a =[]
    for i in range(1, n + 1):
        for j in range(2, n + 1):
            for k in range(3, n + 1):
                if i + j + k == x:
                    if i != j:
                        if j != k:
                            if i != k:
                                a.append([i, j, k])
    b = []
    for i in a:
        b.append(sorted(i))

    c = []
    c = sorted(b)

    if len(c) == 0:
        cnt = 0
    else:
        cnt = 1
        t = c[0]
        for i in c:
            if t != i:
                cnt += 1
                t = i
    print(cnt)

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

using namespace std;

#define int long long
#define MOD 1000000007

#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define RFOR(i, a, b) for (int i = (b)-1; i >= (a); i--)
#define rep(i, n) for (int i = 0; i < (n); i++)
#define rep1(i, n) for (int i = 1; i < (n); i++)
#define rrep(i, n) for (int i = (n)-1; i >= 0; i--)
#define all(i) (i).begin(), (i).end()
#define rall(i) (i).begin(), (i).end(), greater<int>()

#define elif else if
#define eb emplace_back
#define pb push_back
#define mp make_pair
#define fst first
#define sec second
template <typename T>
void print(T x)
{
    std::cout << x << '\n';
}

//typedef long long ll;
#define TENNINE 1000000005
#define TENFIVE 100005
//#define int long long

int N;
vector<int> A;

signed main()
{
    cin >> N;
    A.resize(N);
    rep(i, N)
    {
        cin >> A[i];
    }

    vector<int> B(N);
    rep(i, N)
    {
        B[i] = A[i] - i;
    }

    sort(all(B));
    int ans1;
    if (N % 2 == 1)
    {
        ans1 = B[(N - 1) / 2];
    }
    else
    {
        ans1 = B[N / 2];
    }

    int ans = 0;

    rep(i, N)
    {
        ans += abs(A[i] - i - ans1);
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 3328
N=int(input())
S=[input() for _ in range(N)]

list_march=[]
march=['m', 'a', 'r', 'c', 'h']
for i in march:
    for j in march:
        if j==i: break
        for k in march:
            if k==j: break
            if i!=j and j!=k and k!=i:
                list_march.append([i, j, k])

list_b=[[],[],[],[],[]]
for i in S:
    if i[0]=='M':
        list_b[0].append(i)
    elif i[0]=='A':
        list_b[1].append(i)
    elif i[0]=='R':
        list_b[2].append(i)
    elif i[0]=='C':
        list_b[3].append(i)
    elif i[0]=='H':
        list_b[4].append(i)

ans=0
for mar in list_march:
    list_xyz=[]
    for j in range(0,3):
        for k, m in enumerate(march):
            if mar[j]==m:
                list_xyz.append(len(list_b[k]))
    ans+=list_xyz[0]*list_xyz[1]*list_xyz[2]
print(ans)


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

int main(){
    cin.tie(0);
    ios::sync_with_stdio(0);
    
    int n;
    cin >> n;
    string ans = "";
    while(n != 0){
        if(n % 2 != 0){
            n--;
            ans = "1" + ans;
        } else ans = "0" + ans;
        n /= -2;
    }
    if(ans == "") ans = "0";
    
    cout << ans << endl;
}


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

using namespace std;
#define int long long

int32_t main()
{
    int n; cin >> n;
    int mn = 1e9, ans = 0;
    for (int i = 1; i <= n; i++) {
        int x; cin >> x;
        if (x < mn) ans++, mn = x;
    }
    cout << ans << "\n";
}


Measured memory_bytes: 256
def q3():
    def lcm(x, y):
        """ xとyの最小公倍数を求める """
        # import math
        import fractions
        return (x * y) // fractions.gcd(x, y)

    A, B = (int(i) for i in input().split())
    print(lcm(A, B))


if __name__ == '__main__':
    q3()


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

int main(){
    int n;
    cin >> n;
    vector<int> x(n);
    vector<int> y(n);
    vector<int> h(n);

    for(int i = 0; i < n ; i++){
        cin >> x[i] >> y[i] >> h[i];
    }

    for(int posY = 0; posY <= 100; posY++){
        for(int posX = 0; posX <= 100; posX++){
            int needH = -1;

            for(int i = 0; i < n; i++){
                if(h[i] > 0){
                    int tmp = h[i] + abs(posY - y[i]) + abs(posX - x[i]);
                    if(needH == -1){
                        needH = tmp;
                    }
                    else {
                        if(needH != tmp){
                            needH = -2;
                            break;
                        }
                    }
                }
            }
            if(needH == -2){
                continue;
            }

            for(int i = 0; i < n; i++){
                if(h[i] == 0){
                    int dist = abs(posY - y[i]) + abs(posX - x[i]);
                    if(needH > dist){
                        needH = -2;
                        break;
                    }
                }
            }
            
            if(needH == -2){
                continue;
            }

            cout << posX << " " << posY << " " << needH << endl;
            return 0;
        }
    }
}

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

int main() {
  string a;
  cin >> a;
  if (a == "000") {
    cout << 0 << endl;
  }
  else if (a == "001" || a == "010" || a == "100") {
    cout << 1 << endl;
  }
  else if (a == "110" || a == "101" || a == "011") {
    cout << 2 << endl;
  }
  else {
    cout << 3 << endl;
  }
}

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

// int/long:		-2,147,483,648 - 2,147,483,648 (-2^31 <= int < 2^31)
// long/long long:	-9,223,372,036,854,775,808 - 9,223,372,036,854,775,807 (-2^63 <= long < 2^63)

#define	INF (1<<29)
//536,870,912

// lower_bound(A.begin(), A.end(), N)
// upper_bound(...

// A.erase(unique(A.begin(), A.end()), A.end())

// bit: &/and, |/or, ^/xor, ~/not

// getline(cin, String)

// Graph
// Warshall-Floyd: Distance between each node, N^3
// Dijkstra: Distance from the start node, N^2
// DFS(Depth-First Search)

#define	MOD 1000000007

int	main() {
	long N, K;
	cin >>N >>K;
	vector<vector<int>> A(N+1);
	for (long i=1; i<N; i++) {
		int a, b;
		cin >>a >>b;
		A.at(a).push_back(b);
		A.at(b).push_back(a);
	}
	long S=K;
	vector<int> q;
	int ixq=0;
	vector<bool> Done(N+1, false);
	q.push_back(1);
	long KK=K-1;
	while(ixq<q.size()) {
		int I=q.at(ixq);
		if (Done.at(I))
			continue;
		for (int j=0; j<A.at(I).size(); j++) {
			int J=A.at(I).at(j);
			if (Done.at(J))
				continue;
			q.push_back(J);
			S *=KK;
			S %=MOD;
			KK--;
			if (0==S) {
				cout <<0 <<endl;
				return 0;
			}
		}
		Done.at(I)=true;
		ixq++;
		KK=K-2;
	}
	cout <<S <<endl;
	return 0;
}



Measured memory_bytes: 6904
'''
    Auther: ghoshashis545 Ashis Ghosh
    College: jalpaiguri Govt Enggineering College

'''
from os import path
import sys
from functools import cmp_to_key as ctk
from collections import deque,defaultdict as dd 
from bisect import bisect,bisect_left,bisect_right,insort,insort_left,insort_right
from itertools import permutations
from datetime import datetime
from math import ceil,sqrt,log,gcd
def ii():return int(input())
def si():return input()
def mi():return map(int,input().split())
def li():return list(mi())
abc='abcdefghijklmnopqrstuvwxyz'
mod=1000000007
#mod=998244353
inf = float("inf")
vow=['a','e','i','o','u']
dx,dy=[-1,1,0,0],[0,0,1,-1]

def bo(i):
    return ord(i)-ord('a')

file = 0

def solve():
    



    # for _ in range(ii()):

    n=ii()
    n%=1000
    if n!=0:
        n=1000-n
    print(n)









  
















if __name__ =="__main__":

    if(file):

        if path.exists('input1.txt'):
            sys.stdin=open('input1.txt', 'r')
            sys.stdout=open('output1.txt','w')
        else:
            input=sys.stdin.readline
    solve()

Measured memory_bytes: 68124
#include <stdio.h>

typedef struct {
	int key, id;
} data;

typedef struct {
	data obj[400001];
	int size;
} min_heap;

void push(data x, min_heap* h)
{
	int i = ++(h->size);
	data tmp;
	h->obj[i] = x;
	while (i > 1) {
		if (h->obj[i].key < h->obj[i>>1].key) {
			tmp = h->obj[i>>1];
			h->obj[i>>1] = h->obj[i];
			h->obj[i] = tmp;
			i >>= 1;
		} else break;
	}
}

data pop(min_heap* h)
{
	int i = 1, j = 2;
	data output = h->obj[1], tmp;
	h->obj[1] = h->obj[(h->size)--];
	while (j <= h->size) {
		if (j < h->size && h->obj[j^1].key < h->obj[j].key) j ^= 1;
		if (h->obj[j].key < h->obj[i].key) {
			tmp = h->obj[j];
			h->obj[j] = h->obj[i];
			h->obj[i] = tmp;
			i = j;
			j = i << 1;
		} else break;
	}
	return output;
}

void add_BIT(int N, int BIT[], int i, int k)
{
	while (i <= N) {
		BIT[i] += k;
		i += (i & -i);
	}
}

int sum_BIT(int BIT[], int r)
{
	int sum = 0;
	while (r > 0) {
		sum += BIT[r];
		r -= (r & -r);
	}
	return sum;
}

int main()
{
	int i, H, W, A, B;
	scanf("%d %d", &H, &W);
	
	int j, k, s[200002], t[200002], left[200002], right[200002], BIT[200002] = {}, L, R, M, tmp;
	data d;
	min_heap h;
	h.size = 0;
	for (i = 0; i <= W + 1; i++) {
		s[i] = i;
		t[i] = i;
		left[i] = i - 1;
		right[i] = i + 1;
	}
	for (i = 1, d.key = 0; i <= W; i++) {
		d.id = i;
		push(d, &h);
		add_BIT(W, BIT, i, 1);
	}
	for (i = 1; i <= H; i++) {
		scanf("%d %d", &A, &B);
		tmp = sum_BIT(BIT, A - 1);
		if (sum_BIT(BIT, B) == tmp) {
			if (h.size > 0) printf("%d\n", h.obj[1].key + i);
			else printf("-1\n");
			continue;
		}
		
		L = A;
		R = B;
		while (L < R) {
			M = (L + R) / 2;
			if (sum_BIT(BIT, M) == tmp) L = M + 1;
			else R = M;
		}
		left[B+1] = left[L];
		right[left[L]] = B + 1;
		if (s[B+1] == -1) add_BIT(W, BIT, B + 1, 1);
		for (j = L; j <= B; j = right[j]) {
			t[s[j]] = B + 1;
			s[B+1] = (s[j] > s[B+1])? s[j]: s[B+1];
			s[j] = -1;
			add_BIT(W, BIT, j, -1);
		}
		if (j != B + 1) {
			left[j] = B + 1;
			right[B+1] = j;
		}
		if (B + 1 <= W) {
			d.key = B + 1 - s[B+1];
			d.id = s[B+1];
			push(d, &h);
		}
		
		while (h.size > 0 && t[h.obj[1].id] > h.obj[1].key + h.obj[1].id) pop(&h);
		if (h.size > 0) printf("%d\n", h.obj[1].key + i);
		else printf("-1\n");
	}
	
	fflush(stdout);
	return 0;
}

Measured memory_bytes: 7376
'use strict'
function Main(input) {
  	const lines = input.split('\n');
  	const day = lines.shift();
	const days = ['SUN','MON','TUE','WED','THU','FRI','SAT'];

	console.log(7 - days.indexOf(day));
}

Main(require("fs").readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 7372
#include <bits/stdc++.h>
using namespace std;
int main(){
    int c[3][3]={}, cmin=1000;
    for(int i=0; i<3; i++){
        for(int j=0; j<3; j++){
            cin >> c[i][j];
        }
    }
    for(int i=0; i<3; i++){
        for(int j=0; j<3; j++){
            cmin = min(cmin, c[i][j]);
        }
        for(int j=0; j<3; j++){
            c[i][j] -= cmin;
        }
        cmin=1000;
    }
    
    for(int j=0; j<3; j++){
        for(int i=0; i<3; i++){
            cmin = min(cmin, c[i][j]);
        }
        for(int i=0; i<3; i++){
            c[i][j] -= cmin;
        }
        cmin=1000;
    }

    for(int i=0; i<3; i++){
        for(int j=0; j<3; j++){
            if(c[i][j]!=0){
                cout << "No" << endl;
                return 0;
            }
        }
    }
    cout << "Yes" << endl;
    return 0;
}


Measured memory_bytes: 256
#!/usr/bin/env python3
#ABC136 C

import sys
import math
import bisect
sys.setrecursionlimit(1000000000)
from heapq import heappush, heappop
from collections import defaultdict
from itertools import accumulate
from collections import Counter
from collections import deque
from operator import itemgetter
from itertools import permutations
mod = 10**9 + 7

n = int(input())
h = list(map(int,input().split()))
f = 1
ma = 0
for i in range(n):
    if ma < h[i]:
        ma = h[i]
    else:
        if ma - h[i] >= 2:
            f = 0
            break
if f:
    print('Yes')
else:
    print('No')


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

#define N 32

const int k_operafan[ ]
  = { 0,
      1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
      1, 1, 1, 1, 2, 3, 6, 10, 19, 34,
      62, 113, 207, 381, 701, 1288, 2369, 4357, 8014, 14740 };

/** Application main entry point. */
int main (
  int     argc,
  char  * argv[ ]
  )
{
  for ( ; ; )
  {
    int n;

    scanf ( "%d", &n );
    if ( !( n ) ) break ;

    printf ( "%d\n", k_operafan[ n ] );
  }

  return ( 0 );
}

Measured memory_bytes: 0
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define FOR(i,l,r) for(ll i=(l);i<(r);++i)
#define REP(i,n) FOR(i,0,n)
#define REPS(i,n) FOR(i,1,n+1)
#define RFOR(i,l,r) for(ll i=(l);i>=(r);--i)
#define RREP(i,n) RFOR(i,n-1,0)
#define RREPS(i,n) RFOR(i,n,1)
#define pb push_back
#define eb emplace_back
#define SZ(x) ((ll)(x).size())
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
template<class T = ll> using V = vector<T>;
template<class T = ll> using VV = V<V<T>>;
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; }
inline void Yes(bool b = true) {cout << (b ? "Yes" : "No") << '\n';}
inline void YES(bool b = true) {cout << (b ? "YES" : "NO") << '\n';}
inline void err(bool b = true) {if(b) {cout << -1 << '\n'; exit(0);}}
template<class T> inline void fin(bool b = true, T e = 0) {if(b) {cout << e << '\n'; exit(0);}}
template<class T> T Roundup_div(T x, T y) {return (x+(y-1))/y;}
const ll INF = 1e18;

char maze[6][6];

int main(){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int h, w, k; cin >> h >> w >> k;
    int res = 0;
    REP(i,h)REP(j,w) cin >> maze[i][j];
    REP(i,(1 << h)) REP(j,(1 << w)){
        int count = 0;
        REP(s,h)REP(t,w){
            if(((i >> s) & 1) or((j >> t) & 1)) continue;
            if(maze[s][t] == '#') count++;
        }
        if(count == k) res++;
    }
    cout << res << endl;
}

Measured memory_bytes: 3644
#include<stdio.h>
#include<string.h>
int main()
{
	char a[10],b[10],c[10];
	int o,p,q;
	
	scanf("%s%s%s",&a,&b,&c);
	
	o=strlen(a)-1;
	p=strlen(b)-1;
	if(a[o]==b[0]&&b[p]==c[0])puts("YES");
	else puts("NO");

	return 0;
}

Measured memory_bytes: 128
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10**5)

N, M = map(int, input().split())
a = [int(i) for i in input().split()]

# 最大公約数
def gcd(a, b) :
    if b > a : 
        a, b = b, a
    
    while b != 0 :
        a, b = b, a % b
    return a
    
# 最小公倍数
def lcm(a, b) :
    return a * b // gcd(a, b)

def solve() :
  f = a[0]
  if N >= 2 :
    for i in range(1, N) :
      f = lcm(f, a[i])
      if f > M * 2 :
        return 0
      
  cnt = 0
  while a[0] % 2 == 0 :
    a[0] //= 2
    cnt += 1
  
  for i in range(1, N) :
    tmp = 0
    while a[i] % 2 == 0 :
      a[i] //= 2
      tmp += 1
    if tmp != cnt :
      return 0
      
  return int(M / f + 0.5)
      
print(solve())


Measured memory_bytes: 59632
s = input()
flag = True
for i in range(len(s)-1):
  if s[i] == s[i+1]:
    flag = False
    print(i+1, i+2)
    break
if flag:
  for i in range(len(s)-2):
    if s[i] == s[i+2]:
      flag = False
      print(i+1, i+3)
      break
if flag:
  print(-1, -1)

Measured memory_bytes: 3188
N=int(input())
s=[]
for _ in range(N):
    s.append(int(input()))

s=sorted(s)
total=sum(s)
if total%10==0:
    for i in range(N):
        if s[i]%10!=0:
            total-=s[i]
            break
if total%10==0:
    total=0
print(total)


Measured memory_bytes: 3060
#include <iostream>
using namespace std;
long long gcd(long long a, long long b) {
  return b != 0 ? gcd(b, a % b) : a;
}

int main(){
  int n,i;cin>>n;
  long long t,s,ans=1;
  for(i=0;i<n;++i){
    scanf("%lld",&t);
    s=gcd(t,ans);
    ans=ans/s*t;
  }
  cout<<ans<<endl;    
  return 0;
}


Measured memory_bytes: 256
import sys
a1 = list(map(lambda x: int(x),input().split()))
a2 = list(map(lambda x: int(x),input().split()))
a3 = list(map(lambda x: int(x),input().split()))

ans = []
n = int(input())
for _ in range(n):
    b = int(input())
    if b in a1 :
        a1[a1.index(b)] = 101
    if b in a2 :
        a2[a2.index(b)] = 101
    if b in a3 :
        a3[a3.index(b)] = 101

for i in range(3) :
    if a1[i] == 101 and a2[i] == 101 and a3[i] == 101 :
        print('Yes')
        sys.exit()

if a1.count(101) == 3 or a2.count(101) == 3 or a3.count(101) == 3 :
    print('Yes')
    sys.exit()

if a1[0] == 101 and a2[1] == 101 and a3[2] == 101 :
    print('Yes')
    sys.exit()

if a1[2] == 101 and a2[1] == 101 and a3[0] == 101 :
    print('Yes')
    sys.exit()
print('No')


Measured memory_bytes: 3064
#include<cstdio>
#include<bits/stdc++.h>
typedef long long int ll;
#define REP(i, n) for(int i = 0; i < (n); i++)
#define FOR_IN(i, a, b) for(int i = (a); i < (b); i++)
#define BETWEEN(x, a, b) ((x) >= (a) && (x) <= (b))
#define LOG_F 1
#define LOG(...) if(LOG_F) fprintf(stderr, __VA_ARGS__)

using namespace std;

/*

 */
char s[20];

int main(){
  cin>>s;
  s[5] = ' ';
  s[13] = ' ';
  cout << s<<endl;

  return 0;
}


Measured memory_bytes: 384
x, k, d = map(int, input().split())
  
x = abs(x)

if x > k * d:
  print(x - k * d)
else:
  f = int(x / d)
  x = x - f * d
  g = (k - f) % 2
  if g == 1:
    x = x - d
  print(abs(x))

Measured memory_bytes: 9180
#include <bits/stdc++.h>
#define ST first
#define ND second
#define PB push_back
#define _ ios_base::sync_with_stdio(0); cin.tie(0);

using namespace std;

using ll = long long;
using vi = vector<int>;
using pi = pair<int,int>;

const int nax = 100+10,INF=1e9;
int h,w;
char t[nax][nax];
int dp[nax][nax];


int main() {_
    cin >> h >> w;
    for(int i=1; i<=h; ++i) {
        for(int j=1; j<=w; ++j) {
            cin >> t[i][j];
        }
    }
    for(int i=2; i<=h; ++i) dp[i][0] = INF;
    for(int i=2; i<=w; ++i) dp[0][i] = INF;
    for(int i=1; i<=h; ++i) {
        for(int j=1; j<=w; ++j) {
            if(t[i][j]=='.') dp[i][j] = min(dp[i-1][j],dp[i][j-1]);
            else {
                dp[i][j] = INF;
                if(t[i][j-1]=='#') dp[i][j] = min(dp[i][j],dp[i][j-1]);
                else dp[i][j] = min(dp[i][j],dp[i][j-1]+1);
                if(t[i-1][j]=='#') dp[i][j] = min(dp[i][j],dp[i-1][j]);
                else dp[i][j] = min(dp[i][j],dp[i-1][j]+1);
            }
            //cout << dp[i][j] << " ";
        }
        //cout << "\n";
    }
    cout << dp[h][w];
}


Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
int a[200010];
int b[200010];
int main()
{
	int n, m;
	scanf("%d",&n);
	int i;
	for(i=0; i<n; i++) scanf("%d",&a[i]);
	scanf("%d",&m);
	for(i=0; i<m; i++) scanf("%d",&b[i]);
	printf("%d\n",includes(a, a+n, b, b+m));
	return 0;
}


Measured memory_bytes: 4748
#include<bits/stdc++.h>
bool p(int n){
    int sum=0;
    for(int i=3;i<32;i++){
        for(int j=2;j<7;j++){
            if(pow(i,j)==n){
                sum++;
            }
        }
    }
    if(n==1||n==2||n==4||n==8||n==16||n==32||n==64||n==128||n==256||n==512){
        sum++;
    }
    if(sum>0){
        return true;
    }
    else{
        return false;
    }
}
#define int long long
using namespace std;
signed main(){
    int n;
    cin>>n;
    for(int k=n;k>0;k--){
        if(p(k)==1){
            cout<<k<<endl;
            return 0;
        }
    }
}

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

int main() {
    int ans;
    int n, m;
    cin >> n >> m;
    int l[m], r[m];
    int l_max = 0, r_min = 100000;
    for(int i = 0; i < m; i++){
        cin >> l[i] >> r[i];
        l_max = max(l_max, l[i]);
        r_min = min(r_min, r[i]);
    }
    ans = r_min - l_max + 1;
    if(ans < 0)
        ans = 0;
    cout << ans << endl;
    return (0);
}

Measured memory_bytes: 1024
fun main(args: Array<String>) {
    val n = readLine()!!.toInt()
    val sList = mutableListOf<String>()
    (0 until n).forEach { sList.add(readLine()!!.toCharArray().sorted().joinToString("")) }
    sList.sort()

    var ans = 0L
    var c = 1L
    for (i in 0 until n - 1) {
        if (sList[i].equals(sList[i + 1])) {
            ans += c
            c++
        } else {
            c = 1L
        }
    }
    println(ans)
}


Measured memory_bytes: 78264
import java.util.*;
import java.io.*;
import java.math.*;
 
public class Main
{
    public static void process(int test_number)throws IOException
    {
        int A = ni(), B = ni(), C = ni(), k = ni();

        while(k > 0 && B <= A){
            B *= 2;
            k--;
        }

        while(k > 0 && C <= B){
            C *= 2;
            k--;
        }

        pn((B > A && C > B) ? "Yes" : "No");
    }
 
    static final long mod = (long)1e9+7l;
    
    static FastReader sc;
    static PrintWriter out;
    public static void main(String[]args)throws IOException
    {
        out = new PrintWriter(System.out);
        sc = new FastReader();
 
        long s = System.currentTimeMillis();
        int t = 1;
        //t = ni();
        for(int i = 1; i <= t; i++)
            process(i);
 
        out.flush();
        System.err.println(System.currentTimeMillis()-s+"ms");
    }

    static void trace(Object... o){ System.err.println(Arrays.deepToString(o)); };
    static void pn(Object o){ out.println(o); }
    static void p(Object o){ out.print(o); }
    static int ni()throws IOException{ return Integer.parseInt(sc.next()); }
    static long nl()throws IOException{ return Long.parseLong(sc.next()); }
    static double nd()throws IOException{ return Double.parseDouble(sc.next()); }
    static String nln()throws IOException{ return sc.nextLine(); }
    static long gcd(long a, long b)throws IOException{ return (b==0)?a:gcd(b,a%b);}
    static int gcd(int a, int b)throws IOException{ return (b==0)?a:gcd(b,a%b); }
    static int bit(long n)throws IOException{ return (n==0)?0:(1+bit(n&(n-1))); }
    
    static class FastReader{ 
        BufferedReader br; 
        StringTokenizer st; 
  
        public FastReader(){ 
            br = new BufferedReader(new InputStreamReader(System.in)); 
        } 
  
        String next(){ 
            while (st == null || !st.hasMoreElements()){ 
                try{ st = new StringTokenizer(br.readLine()); } catch (IOException  e){ e.printStackTrace(); } 
            } 
            return st.nextToken(); 
        } 
  
        String nextLine(){ 
            String str = ""; 
            try{ str = br.readLine(); } catch (IOException e) { e.printStackTrace(); } 
            return str; 
        } 
    } 
}


Measured memory_bytes: 36628
#include <stdio.h>
#include <string.h>
int main(void){
    int i, top, bottom, side1, side2, side3, side4, tmp;
    char c[101];
    
    scanf("%d %d %d %d %d %d\n", &top, &side1, &side2, &side3, &side4, &bottom);
    scanf("%s", c);
    
    for(i=0; c[i]!='\0'; i++){
        switch(c[i]){
            case 'N':
                tmp = top;
                top = side1;
                side1 = bottom;
                bottom = side4;
                side4 = tmp;
                break;
            case 'S':
                tmp = top;
                top = side4;
                side4 = bottom;
                bottom = side1;
                side1 = tmp;
                break;
            case 'W':
                tmp = top;
                top = side2;
                side2 = bottom;
                bottom = side3;
                side3 = tmp;
                break;
            case 'E':
                tmp = top;
                top = side3;
                side3 = bottom;
                bottom = side2;
                side2 = tmp;
                break;
            default:
                break;
        }
    }
    
    printf("%d\n", top);
    return 0;
}



Measured memory_bytes: 2112
#include<bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < n; ++i)
#define rep2(i,s,n) for (int i = s; i < n; ++i)
#define all(a) a.begin(),a.end()
using namespace std;
using ll = long long;
using P = pair<int,int>;

int main() {
    int r,d,now;
    cin >> r >> d >> now;
    rep(i,10) {
        now = r*now-d;
        cout << now << endl;
    }
}

Measured memory_bytes: 256
def main():
    N, M = map(int, input().split())
    H = [int(h) for h  in input().split()]
    E = [None]*M
    G = [1]*N
    for p in range(M):
        A, B = map(int, input().split())
        if G[A-1] == 0 and G[B-1] == 0:
            continue
        if H[A-1] > H[B-1]:
            G[B-1] = 0
        elif H[A-1] == H[B-1]:
            G[A-1] = 0
            G[B-1] = 0
        else:
            G[A-1] = 0
        
    print(sum(G))


if __name__ == "__main__":
    main()

Measured memory_bytes: 85112
#include "bits/stdc++.h"

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

const long long INF = 1e18;

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

int main() {
	int H;
	int W;
	int K;//泳げる距離
	cin >> H >> W >> K;
	int Sx;
	int Sy;
	int Gx;
	int Gy;
	cin >> Sx >> Sy >> Gx >> Gy;
	--Sx;
	--Sy;
	--Gx;
	--Gy;

	vector<string>g(H);
	for (int n = 0; n < H; ++n) {
		string str;
		cin >> g[n];
	}

	auto told= [&](int i, int j, int v) {
		return (i * W + j) * 4 + v;
	};

	auto modceil = [&](long long x) {//切り上げ
		return (x + K - 1) / K * K;
	}; 

	vector< long long>dist(H*W * 4, INF);
	priority_queue<LP ,vector< LP>,greater<LP> > q;//小さいもの順
	auto push = [&](int i, int j, int v, long long x) {
		int id = told(i,j,v);
		if (dist[id] <= x) {
			return;
		}
		dist[id] = x;
		q.emplace(x,id);
	};
	
	for (int n = 0; n < 4; ++n) {
		push(Sx, Sy, n, 0);
	}

	while (!q.empty()) {
		long long d = q.top().first;
		int id = q.top().second;
		q.pop();
		if (dist[id] != d) {//古いデータは捨てる
			continue;
		}

		int i = id / W / 4;
		int j = id / 4 % W;
		int v = id % 4;
		//方向転換
		for (int n = 0;n < 4;++n) {
			push(i, j, n, modceil(d));
		}
		//直進
		int nx = i + dx[v];
		int ny = j + dy[v];
		if ((0 <= nx) && (H > nx) && (0 <= ny) && (W > ny)) {
			if (g[nx][ny]== '.') {
				push(nx, ny, v, d + 1);
			}
		}
	}
	
	long long ans = INF;
	for (int n = 0;n < 4;++n) {
		ans = min(ans, dist[told(Gx, Gy, n)]);
	}
	if (INF == ans) {
		cout << -1 << endl;
	}
	else {
		ans = modceil(ans) / K;
		cout << ans << endl;
	}

	return 0;
}

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

int main()
{
	int n;
	cin >> n;
	vector<int> A( n );
	for( int i = 0; i < n; i++ ) {
		cin >> A[i];
	}

	set<int> st;
	for( int b = 0; b < 1 << n; b++ ) {
		int sum = 0;
		for( int i = 0; i < n; i++ ) {
			if( (b >> i) & 1 ) {
				sum += A[i];
			}
		}
		st.insert( sum );
	}

	int q;
	cin >> q;
	for( int i = 0; i < q; i++ ) {
		int m;
		cin >> m;
		string ans = "yes";
		if( st.count( m ) == 0 ) {
			ans = "no";
		}
		cout << ans << endl;
	}
}



Measured memory_bytes: 3228
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define ll long long
#define all(x) (x).begin(),(x).end()
template<class T> inline bool chmax(T& a, T b) {if (a < b) {a = b;return true;}return false;}
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
const int INF = 1000000000;

vector<pair<long long, long long> > prime_factorize(long long N) {
    vector<pair<long long, long long> > res;
    for (long long a = 2; a * a <= N; ++a) {
        if (N % a != 0) continue;
        long long ex = 0; // 指数

        // 割れる限り割り続ける
        while (N % a == 0) {
            ++ex;
            N /= a;
        }

        // その結果を push
        res.push_back({a, ex});
    }

    // 最後に残った数について
    if (N != 1) res.push_back({N, 1});
    return res;
}

int main() {
    ll N;
    cin >> N;
    vector<pair<ll, ll>>primes;
    primes = prime_factorize(N);
    int cnt = 0;
    for (int i=0; i<primes.size(); i++){
        pair<ll,ll>aprime = primes[i];
        for (int j=1; aprime.second > 0; j++){
            if (aprime.second < j)break;
            aprime.second -= j;
            cnt++;
        }

    }
    cout << cnt << endl;


}

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

int main(){
    int h, w;
    cin >> h >> w;
    vector<vector<char>>  c(h, vector<char>(w));
    for(int i=0; i<c.size(); i++){
        for(int j=0; j<c[i].size(); j++){
            cin >> c[i][j];
        }
    }
    for(int i=0; i<h; i++){
        for(int j=0; j<w; j++){
            cout << c[i][j];
        }
        cout << endl;
        for(int k=0; k<w; k++){
            cout << c[i][k];
        }
        cout << endl;
    }
}

Measured memory_bytes: 256
import sys
import math
mod=10**9+7
inf=float("inf")
from math import sqrt
from collections import deque
from collections import Counter
input=lambda: sys.stdin.readline().strip()
sys.setrecursionlimit(11451419)
from functools import lru_cache
#メモ化再帰defの冒頭に毎回 @lru_cache(maxsize=10**10)
#引数にlistはだめ
#######ここまでテンプレ#######
#######ここから天ぷら########
n,k=map(int,input().split())
ans=1
now=k
while now<n:
    
    ans+=1
    now+=k-1
print(ans)



Measured memory_bytes: 3564
n,Y=map(int,input().split())

y1=Y/1000 #1000円で表す最高枚数
g=0
for i in range(0,n+1):
    if (y1-i)%5==0 and (y1-i)>=0:
        h=(y1-i)/5
        for j in range(0,n-i+1):
            if (h-j)%2==0 and (i+j+int((h-j)/2))==int(n):
                k=int((h-j)/2)
                g=1
                break
    if g==1:
        break
if g==0:
    print("-1 -1 -1")
else:
    print(str(k)+" "+str(j)+" "+str(i))

Measured memory_bytes: 3188
#include<bits/stdc++.h>
using namespace std;
int main()
{
int n,k;
cin>>n>>k;
map<int,int>freq;
for(int i=0; i<k; ++i)
{
int a;
cin>>a;
int arr[a];
for(int j=0; j<a; ++j)
{
cin>>arr[j];
++freq[arr[j]];
}
}
int cnt(0);
for(int i=0; i<n; ++i)
cnt+=(freq[i+1]==0?1:0);
cout<<cnt;
}


Measured memory_bytes: 3632
#include <bits/stdc++.h>
#define r(i,n) for(int i = 0; i<n; i++)
using namespace std;
 
int main() {
  int n, a;
  cin >> n >> a;
  if((n%500)<=a)cout << "Yes" << endl;
  else cout << "No" << endl;
}


Measured memory_bytes: 256
def main():
    N, M = map(int, input().split())
    x = sorted(list(map(int, input().split())))

    sa = []
    for i in range(M-1):
        sa.append(x[i+1] - x[i])
    sa = sorted(sa, reverse=True)
    # print(sa)
    if N >= M:
        print(0)
    else:
        print(sum(sa[N-1:]))


if __name__ == "__main__":
    main()

Measured memory_bytes: 13960
# coding: utf-8
N,K=map(int,input().split())
P=list(map(int,input().split()))


num=0
S=0
ans=0

for i in range(K):
    num=P[i]
    S=P[i]*(P[i]+1)//2
    ans+=S/num
A=[ans]
for i in range(N-K):
    m=(P[i]*(P[i]+1)//2)/P[i]
    a=(P[i+K]*(P[i+K]+1)//2)/P[i+K]
    ans-=m
    ans+=a
    A.append(ans)
ans=A[0]
for i in range(1,N-K+1):
    if A[i]>ans:
        ans=A[i]
#print(A)
print(ans)

Measured memory_bytes: 71792
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <math.h>
#include <vector>
#include <queue>
#include <algorithm>
#include <sstream>
#include <string>
using namespace std;
#define FOR(I,N) for(int I = 0; I < (int)(N); I++)
#define FIN(V) cout<<V<<endl
#define pb push_back
#define INF (1 << 30)
typedef pair<int, int> P;

int solve();
int dx[4] = {1, -1, 0, 0};
int dy[4] = {0, 0, 1, -1};
int w, h, tx, ty, kx, ky;
int maps[52][52];
int memo[52][52][52][52];


struct Data{
    P pt, pk;
    int cnt;
    Data(P pt_, P pk_, int cnt_){
        pt = pt_;
        pk = pk_;
        cnt = cnt_;
    }
    Data(){}
};

int main(void){
    while(cin >> w >> h, w){
        cin >> tx >> ty;
        cin >> kx >> ky;
        fill_n(*maps, 52*52, 1);
        FOR(i, h)FOR(j, w){
            cin >> maps[i+1][j+1];
        }
        int a = solve();
        if(a == -1 || a >= 100)FIN("NA");
        else FIN(a);
    }
    return 0;    
}


int solve(){
    int ans = -1;
    fill_n(***memo, 52*52*52*52, INF);
    queue<Data> que;
    que.push(Data(P(tx,ty), P(kx, ky), 0));
    while(que.size()){
        Data data = que.front();
        que.pop();
        int x1 = data.pt.first;
        int y1 = data.pt.second;
        int x2 = data.pk.first;
        int y2 = data.pk.second;
        int cost = data.cnt;
        if(cost > 100)break;
        if(memo[x1][y1][x2][y2] <= cost)continue;
        memo[x1][y1][x2][y2] = cost;
        if(x1 == x2 && y1 == y2){ans = cost;break;};
        FOR(i, 4){
            int nx1 = x1 + dx[i];
            int ny1 = y1 + dy[i];
            int nx2 = x2 - dx[i];
            int ny2 = y2 - dy[i];
            if(maps[ny1][nx1] == 1){nx1 = x1;ny1 = y1;};
            if(maps[ny2][nx2] == 1){nx2 = x2;ny2 = y2;};
            que.push(Data(P(nx1,ny1), P(nx2, ny2), cost+1));
        }
    }

    return ans;
}

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

int n, k;
int a[100010];
int dp[100010];

int rek(int x) {
	if (x == n-1) {
		return 0;
	}
	
	int &ret = dp[x];
	if (ret != -1) return ret;
	
	ret = rek(x+1) + abs(a[x]-a[x+1]);
	for (int i = 2; i <= k; i ++) {
		if (x+i >= n) break;
		
		ret = min(ret, rek(x+i) + abs(a[x] - a[x+i]));
	}
	
	return ret;
}

int main () {
	
	cin >> n >> k;
	for (int i = 0; i < n; i ++) {
		cin >> a[i];
		dp[i] = -1;
	}
	
	cout << rek(0);
	
	return 0;
}

Measured memory_bytes: 4096
#include <bits/stdc++.h>
using namespace std;
int main(){
  string S,T,ans;
  cin >>S;
  T=S;
  int K;
  cin >>K;
  sort(T.begin(), T.end());
  for(int i=0; i<T.size()-1; i++){
    if(T[i]==T[i+1]){
      T.erase(T.begin()+i);
      i--;
    }
  }
  bool finish=false;
  for(int i=0; i<T.size(); i++){
  vector<string> Z;
    for(int j=0; j<S.size(); j++){
//      cout<<"i:"<<i<<" j:"<<j;
//      cout<<"T[i]:"<<T[i]<<" S[j]:"<<S[j]<<endl;
      if(T[i]==S[j]){
        string a="";
        int b=S.size()-j;
//        cout<<"b:"<<b;
        for(int k=0; k<min(K,b); k++){
          a+=S[j+k];
//          cout<<" a:"<<a<<endl;
          Z.push_back(a);
        }
      }
      if(j==S.size()-1){
        sort(Z.begin(), Z.end());
        int c=Z.size()-1;
        for(int m=0; m<c; m++){
          if(Z[m]==Z[m+1]){
            Z.erase(Z.begin()+m);
            m--, c--;
          }
        }
//        cout<<"K:"<<K<<" Zs:"<<Z.size()<<endl;
        if(Z.size()>=K){
          ans=Z[K-1];
          finish=true;
        }
        else K-=Z.size();        
      }
      if(finish) break;
    }
    if(finish) break;
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 1660
#include <iostream>
#include <algorithm>
#include <tuple>
#include <vector>
#include <string>
#include <queue>
#include <cmath>
#include <set>
#include <map>
#include <cassert>

using namespace std;
using ll = long long;

int main()
{
    int h, w;
    cin >> h >> w;
    vector<vector<char>> s(h, vector<char>(w));
    for(int i = 0; i < h; i++){
        for(int j = 0; j < w; j++){
            cin >> s[i][j];
        }
    }
    vector<vector<int>> L(h, vector<int>(w, 0)), R(h, vector<int>(w, 0)), D(h, vector<int>(w, 0)), U(h, vector<int>(w, 0));
    for(int i = 0; i < h; i++){
        for(int j = 0; j < w; j++){
            if(s[i][j] == '#') continue;
            else{
                if(j == 0) L[i][j] = 1;
                else{
                    L[i][j] = L[i][j-1] + 1;
                }
            }
        }
    }

    for(int i = 0; i < h; i++){
        for(int j = w-1; j >= 0; j--){
            if(s[i][j] == '#') continue;
            else{
                if(j == w-1) R[i][j] = 1;
                else{
                    R[i][j] = R[i][j+1] + 1;
                }
            }
        }
    }

    for(int i = h-1; i >= 0; i--){
        for(int j = 0; j < w; j++){
            if(s[i][j] == '#') continue;
            else{
                if(i == h-1) D[i][j] = 1;
                else{
                    D[i][j] = D[i+1][j] + 1;
                }
            }
        }
    }

    for(int i = 0; i < h; i++){
        for(int j = 0; j < w; j++){
            if(s[i][j] == '#') continue;
            else{
                if(i == 0) U[i][j] = 1;
                else{ 
                    U[i][j] = U[i-1][j] + 1;
                }
            }
        }
    }


    int ans = 0;
    for(int i = 0; i < h; i++){
        for(int j = 0; j < w; j++){
            int num = L[i][j] + R[i][j] + D[i][j] + U[i][j]-3;
                // for(int k = 0; k < 4; k++){
                //     int nowx = i, nowy = j;
                //     if(nowx+x[k] < 0 || nowx+x[k] >= h || nowy+y[k] < 0 || nowy+y[k] >= w) {
                //         continue;
                //     }

                //     // while(s[nowx+x[k]][nowy+y[k]] == '.'){
                //     //     num++;
                //     //     nowx = nowx+x[k];
                //     //     nowy = nowy+y[k];
                //     //     if(nowx+x[k] < 0 || nowx+x[k] >= h || nowy+y[k] < 0 || nowy+y[k] >= w) {
                //     //         break;
                //     //     }
                //     // }
                // }
            ans = max(ans, num);
        }
        
    }

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

Measured memory_bytes: 70020
import java.util.*;
public class Main{
  	public static void main(String[] args){
      Scanner sc =new Scanner(System.in);
     
      int L=sc.nextInt();
      int R=sc.nextInt();
      int d=sc.nextInt();
      
      int a=(L-1)/d;
      int b=R/d;
      int c=b-a;
 
      System.out.println(c);
    }
}

Measured memory_bytes: 35652
#include<stdio.h>
int main(){
  int n,q,i,j,c=0,r,l,m;
  int s[100000],t[50000];
  scanf("%d",&n);
  for(i=0;i<n;i++) scanf("%d",&s[i]);

  scanf("%d",&q);
  for(i=0;i<q;i++) scanf("%d",&t[i]);

  for(i=0;i<q;i++){

    l=0;
    r=n;
    
    while(l<r){
      m=(l+r)/2;
      
      if(t[i]==s[m]){
	c++;
	break;
      }

      else if(t[i]<s[m]) r=m;

      else if(t[i]>s[m]) l=m+1;

      else l=m+1;
    }
    
  }

  printf("%d\n",c);

  return 0;
}



Measured memory_bytes: 2280
#![allow(unused)]

//入力マクロここから
//https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8
macro_rules ! input_inner { ( $ next : expr ) => { } ; ( $ next : expr , ) => { } ; ( $ next : expr , $ var : ident : $ t : tt $ ( $ r : tt ) * ) => { let $ var = read_value ! ( $ next , $ t ) ; input_inner ! { $ next $ ( $ r ) * } } ; }
macro_rules ! read_value { ( $ next : expr , ( $ ( $ t : tt ) ,* ) ) => { ( $ ( read_value ! ( $ next , $ t ) ) ,* ) } ; ( $ next : expr , [ $ t : tt ; $ len : expr ] ) => { ( 0 ..$ len ) . map ( | _ | read_value ! ( $ next , $ t ) ) . collect ::< Vec < _ >> ( ) } ; ( $ next : expr , chars ) => { read_value ! ( $ next , String ) . chars ( ) . collect ::< Vec < char >> ( ) } ; ( $ next : expr , usize1 ) => { read_value ! ( $ next , usize ) - 1 } ; ( $ next : expr , $ t : ty ) => { $ next ( ) . parse ::<$ t > ( ) . expect ( "Parse error" ) } ; }
macro_rules ! input { ( source = $ s : expr , $ ( $ r : tt ) * ) => { let mut iter = $ s . split_whitespace ( ) ; let mut next = || { iter . next ( ) . unwrap ( ) } ; input_inner ! { next , $ ( $ r ) * } } ; ( $ ( $ r : tt ) * ) => { let stdin = std :: io :: stdin ( ) ; let mut bytes = std :: io :: Read :: bytes ( std :: io :: BufReader :: new ( stdin . lock ( ) ) ) ; let mut next = move || -> String { bytes . by_ref ( ) . map ( | r | r . unwrap ( ) as char ) . skip_while ( | c | c . is_whitespace ( ) ) . take_while ( | c |! c . is_whitespace ( ) ) . collect ( ) } ; input_inner ! { next , $ ( $ r ) * } } ; }
//入力マクロここまで

//input
//use std::io::Read;

//collections
//use std::collections::BTreeMap;
//use std::collections::BTreeSet;
//use std::collections::HashMap;
//use std::collections::HashSet;
//use std::collections::VecDeque;
//use std::collections::BinaryHeap;

//use std::cmp::*;

fn main() {
    input! {
        n: i64,
        k: i64,
    }

    if (n - k).abs() >= n {
        println!("{}", n);
        return;
    }

    let mut n = n % k;

    loop {
        let t = (n - k).abs();
        if t >= n {
            break;
        }
        n = t;
    }

    println!("{}", n);
}


Measured memory_bytes: 4352
#include "bits/stdc++.h"

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

// [debug]

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

void Main() {
  int a, b;
  cin >> a >> b;
  cout << max(0, a - 2 * b) << endl;
}

int main() {
  std::cin.tie(nullptr);
  std::ios_base::sync_with_stdio(false);
  std::cout << std::fixed << std::setprecision(15);
  Main();
  return 0;
}


Measured memory_bytes: 256
import numpy as np

N=int(input())
S=np.zeros((100000,),np.int) # 席

for _ in range(N):
    l,r=list(map(int,input().split(" ")))
    S[l-1]+=1 # 始点

    if r<len(S): # 終点+1
        S[r]+=-1

Scum=np.cumsum(S) # 累積和をとる
print((Scum>0).sum()) # 1以上のところ

Measured memory_bytes: 14148