akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <algorithm>
#include <vector>
using namespace std;
int main()
{
  int N, K;
  cin >> N >> K;
  vector<int> l(N);
  for (int i = 0; i < N; i++)
    cin >> l[i];
  sort(l.rbegin(), l.rend());
  int ans = 0;
  for (int i = 0; i < K; i++)
    ans += l[i];
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rrep(i, n) for (int i = 1; i < (int)(n+1); i++)
int main() {
  int A,B;
  cin>>A>>B;
  int ans=0;
  for(int i=A; i<B+1; i++){
      if(i/10000==(i%10)){
      if(i/1000-(i/10000)*10==(i%100-(i%10))/10){
          ans++;
      }
      }
  }
  cout<<ans<<endl;
}



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

#define SIZE 200005
#define MOD 1000000007
 
typedef pair <int,int> P;
 
ll inv[SIZE], fac[SIZE], finv[SIZE];
void make(){
	fac[0] = fac[1] = 1;
	finv[0] = finv[1] = 1;
	inv[1] = 1;
	for(int i=2; i<SIZE; i++)
	{
		inv[i] = MOD - inv[MOD%i]*(MOD/i)%MOD;
		fac[i] = fac[i-1] * (ll) i % MOD;
		finv[i] = finv[i-1] * inv[i] % MOD;
	}
    return ;
}
ll comb(int a,int b){
	if(a < b) return 0;
	return fac[a] * (finv[b] * finv[a-b] % MOD) % MOD;
}



ll beki(int a, int n){
    if(n == 0) return 1;
    ll ans = beki(a, n / 2);
    ans = ans * ans;
    if(n % 2 == 1) ans = ans * a;
    return ans;
}


int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
    //cout << fixed << setprecision(15);
    
	int n;cin>>n;
    ves S(n);vin(S);
    int ac=0, wa =0, tle=0,re=0;
    rep(i,n){
        if(S[i] == "WA") wa++;
        else if(S[i] == "AC") ac++;
        else if(S[i] == "TLE") tle++;
        else re++;
    }
    cout << "AC x " << ac << endl;
    cout << "WA x " << wa << endl;
    cout << "TLE x " << tle << endl;
    cout << "RE x " << re << endl;

}

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

int main()
{
	int N;
	cin >> N;
	std::vector<char> S(N + 1);
	for (int i = 1; i <= N; ++i)
	{
		cin >> S[i];
	}
	int G = 0;
	int W = 0; int P = 0; int Y = 0;
	for (int i = 1; i <= N; ++i)
	{
		if (S[i] == 'P')
		{
			P += 1 ;
		}
		else if (S[i] == 'G')
		{
			G += 1;
		}
		else if (S[i] == 'W')
		{
			W += 1;
		}
		else if (S[i] == 'Y')
		{
			Y += 1;
		}
		else
		{

		}
	}
	if (G != 0 && Y != 0 && W != 0 && P != 0)
	{
		cout << "Four" << endl;
	}
	else
	{
		cout << "Three" << endl;
	}
}

Measured memory_bytes: 256
import sys
from typing import List
import math

n = int(input())
S = [int(i) for i in input().split()]
hikaku = 0


def merge(A: List[int], left: int, mid: int, right: int) -> None:
    global hikaku
    # n1 = mid - left  # left_listのデータ数
    # n2 = right - mid  # right_listのデータ数

    # left_list = [A[left + i] for i in range(n1)]
    # right_list = [A[mid + i] for i in range(n2)]
    left_list = A[left:mid]
    right_list = A[mid:right]
    left_list.append(sys.maxsize)
    right_list.append(sys.maxsize)

    i = 0  # left_listのインデックス
    j = 0  # right_listのインデックス
    for k in range(left, right):
        hikaku += 1
        if left_list[i] <= right_list[j]:
            A[k] = left_list[i]
            i += 1
        else:
            A[k] = right_list[j]
            j += 1


def merge_sort(A: List[int], left: int, right: int) -> int:
    if left + 1 < right:
        mid = math.floor((left + right) / 2)
        merge_sort(A, left, mid)
        merge_sort(A, mid, right)
        merge(A, left, mid, right)


merge_sort(S, 0, len(S))
print(' '.join(map(str, S)))
print(hikaku)



Measured memory_bytes: 72600
#include <bits/stdc++.h>
#include <string>
#include <math.h>
#include <sstream>
using namespace std;

#define endl "\n"
#define fastio ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
//STANDARD DATA TYPES
#define ll long long
#define llu unsigned long long
#define ld long double
//ADV DATA TYPES
#define pii pair < int , int >
#define pll pair < ll, ll >
#define mp make_pair
#define ff first
#define ss second
//C 9/++ DS
#define vi vector < int >
#define vll vector < ll >
#define pb push_back
#define pf push_front
#define iter :: iterator
#define all(x) x.begin(),x.end()
 
//priority_queue < pii, vector < pii >, greater < pii > > pq;
//lower_bound(v.begin(),v.end(),20);//for any sorted container
//CONSTANTS
#define MOD 998244353
#define INF 0x3f3f3f3f
#define MAXN (int)(2e4+20)

#define fori(i,n) for(int i=0; i<n; i++)
#define forl(i,n) for(ll i=0; i<n; i++)
//MOD OPERATIONS
inline ll fpow(ll n, ll k, int p = MOD) {ll r = 1; for (; k; k >>= 1) {if (k & 1) r = r * n % p; n = n * n % p;} return r;}
inline ll inv(ll a, ll p = MOD) {return fpow(a, p - 2, p);}
inline ll addmod(ll a, ll val, ll p = MOD) {{if ((a = (a + val)) >= p) a -= p;} return a;}
inline ll submod(ll a, ll val, ll p = MOD) {{if ((a = (a - val)) < 0) a += p;}return a;}
inline ll mult(ll a, ll b, ll p = MOD) {return (ll) a * b % p;}
const  llu int_max = pow(2,32) - 1 ;

bool compare(const pair<int, int>&i, const pair<int, int>&j)
{
    return i.ff < j.ff;
}

const int nax = 2000001 ;

int main(){

	fastio
	int k,x ;
	cin>>k>>x ;
	for (int i = x-k+1; i <= x+k-1; ++i)
	{
		cout<<i<<" ";
	}
	return 0;

	
}



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

int main() {
  string s;
  cin >> s;
  int n = s.size();
  
  int ans = 0;
  for(int i = 1; i < n; i++){
    if(s.at(i) != s.at(i - 1)) ans++;
  }
  
  cout << ans << endl;
}

Measured memory_bytes: 512
package main

import (
	"bufio"
	_ "container/heap"
	"fmt"
	"os"
	"sort"
	"strconv"
)

// I/O
type Scanner struct {
	sc *bufio.Scanner
}

func NewScanner() *Scanner {
	sc := bufio.NewScanner(os.Stdin)
	sc.Split(bufio.ScanWords)
	sc.Buffer(make([]byte, 1024), int(1e+9))
	return &Scanner{sc}
}

func (s *Scanner) nextStr() string {
	s.sc.Scan()
	return s.sc.Text()
}

func (s *Scanner) nextInt() int {
	i, e := strconv.Atoi(s.nextStr())
	if e != nil {
		panic(e)
	}
	return i
}

func (s *Scanner) nextFloat() float64 {
	f, e := strconv.ParseFloat(s.nextStr(), 64)
	if e != nil {
		panic(e)
	}
	return f
}

func (s *Scanner) nextRuneSlice() []rune {
	return []rune(s.nextStr())
}

func (s *Scanner) nextIntSlice(n int) []int {
	res := make([]int, n)
	for i := 0; i < n; i++ {
		res[i] = s.nextInt()
	}
	return res
}

func (s *Scanner) nextFloatSlice(n int) []float64 {
	res := make([]float64, n)
	for i := 0; i < n; i++ {
		res[i] = s.nextFloat()
	}
	return res
}

// Arithmetic
func max(nums ...int) int {
	m := nums[0]
	for _, i := range nums {
		if m < i {
			m = i
		}
	}
	return m
}

func min(nums ...int) int {
	m := nums[0]
	for _, i := range nums {
		if m > i {
			m = i
		}
	}
	return m
}

func abs(x int) int {
	if x > 0 {
		return x
	}
	return -x
}

func pow(x, y int) int {
	res := 1
	for i := 0; i < y; i++ {
		res *= x
	}
	return res
}

func ceil(a, b int) int {
	if a%b == 0 {
		return a / b
	} else {
		return a/b + 1
	}
}

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

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

// Sort
type RuneSlice []rune

func (a RuneSlice) Len() int           { return len(a) }
func (a RuneSlice) Less(i, j int) bool { return a[i] < a[j] }
func (a RuneSlice) Swap(i, j int)      { a[i], a[j] = a[j], a[i] }

// Main
const MOD = int(1e+9) + 7
const INF = 1 << 60

func main() {
	sc := NewScanner()
	wtr := bufio.NewWriter(os.Stdout)
	defer wtr.Flush()
	N, H := sc.nextInt(), sc.nextInt()
	A := make([]int, N)
	B := make([]int, N)
	maxA := 0
	for i := 0; i < N; i++ {
		A[i] = sc.nextInt()
		B[i] = sc.nextInt()
		if A[maxA] < A[i] {
			maxA = i
		}
	}
	count := 0
	sort.Ints(B)
	for i := N - 1; i >= 0; i-- {
		if A[maxA] <= B[i] {
			H -= B[i]
			count++
		}
		if H <= 0 {
			break
		}
	}
	if H > 0 {
		count += ceil(H, A[maxA])
	}

	fmt.Fprintln(wtr, count)
}


Measured memory_bytes: 4608
#include <stdio.h>

int main(void){
int a,b,c,d,e,gcd,lcm;
while(scanf("%d %d\n",&a,&b)!=EOF)
{
d=a,e=b;
if(a<b) c=a,a=b,b=c;
while(a%b!=0) c=a%b,a=b,b=c;
gcd=b,lcm=d/gcd*e;
printf("%d %d\n",gcd,lcm);
}
return 0;
}

Measured memory_bytes: 600
#include <iostream>
#include <algorithm>
#include <cmath>
#include <vector>
#include <string>
#include <queue>
#include <utility>
#include <map>
#include <bitset>
#include <iomanip>
#define ll long long
using namespace std;
using p = pair<ll, ll>;
ll dx[4] = {-1, 0, 1, 0};
ll dy[4] = {0, 1, 0, -1};

int main(void){
    ll n, m;
    cin >> n >> m;
    vector<p> c;
    vector<ll> check(n+1, 1);
    vector<bool> d(n+1, false);
    d[1] = true;
    check[1] = true;
    for(ll i = 0; i < m; i++){
        ll a, b;
        cin >> a >> b;
        if(check[a]>=1 && d[a]==true)
            d[b] = true;
        check[a]--;
        check[b]++;
        if(check[a]==0) d[a]=false;
    }
    ll ans = 0;
    for(ll i = 1; i <= n; i++){
        //cout << i << " " << check[i] <<"     " << d[i] << endl;
        if(check[i]>=1 && d[i]==true)
            ans++;
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 1024
#include<bits/stdc++.h>
#include<iostream>
#include<cstdio>
#include<vector>
#include<string>
#include<algorithm>
#include<map>
using namespace std;
#define rep(i,x) for(ll i = 0; i < (ll)(x); i++)
#define rrep(i,x) for(ll i = (ll)(x)-1;0 <= i; i--)
#define reps(i,x) for(ll i = 1; i < (ll)(x)+1; i++)
#define rreps(i,x) for(ll i = (ll)(x); 1 <= i; i--)
#define debug(x) cerr << #x << ": " << (x) << "\n";
#define all(x) (x).begin(), (x).end()
typedef long long ll;
typedef long double ld;
typedef pair<int,int> P;
typedef pair<ll,ll> Pll;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
typedef vector<vector<vector<ll>>> vvvl;
const ll INF = numeric_limits<ll>::max()/4;
const int n_max = 1e5+10;

void print() {
    cout << endl;
}

template <class Head, class... Tail>
void print(Head&& head, Tail&&... tail) {
    cout << head;
    if (sizeof...(tail) != 0) cout << ' ';
    print(forward<Tail>(tail)...);
}

template <class T>
void print(vector<T> &vec) {
    for (auto& a : vec) {
        cout << a;
        if (&a != &vec.back()) cout << ' ';
    }
    cout << endl;
}

template <class T>
void print(vector<vector<T>> &df) {
    for (auto& vec : df) {
        print(vec);
    }
}

template<class T, class U>
void print(pair<T,U> &p){
    print(p.first, p.second);
}


int main(){
    ll n; cin >> n;
    vector<Pll> a(n);
    ll sum = 0;
    rep(i,n){
        ll x; cin >> x;
        a[i] = {x, i};
        sum += x;
    }

    vector<ll> ans(n);

    sort(all(a), greater<Pll>());
    // for(auto p : a)print(p);
    auto p = a[0];
    ll cnt = 1;
    while(p.second != 0){
        while(p.first == a[cnt].first && cnt < n){
            p.second = min(a[cnt++].second, p.second);
        }
        if(cnt == n)continue;
        if(p.second == 0)continue;
        ans[p.second] += cnt * (p.first - a[cnt].first);
        sum -= cnt * (p.first - a[cnt].first);
        // print(p);
        p.first = a[cnt].first;
        // print(p);
        // debug(cnt);
        // print();
    }
    ans[0] += sum;
    print(ans);
}

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

int main() {

    int A, B;
    cin >> A >>  B;

    if (A == B) {
        cout << A + B << endl;
    }
    else if (A > B) {
        cout << 2 * A - 1 << endl;
    }
    else {
        cout << 2 * B - 1 << endl;
    }

    return 0;
}


Measured memory_bytes: 256
import sys
sys.setrecursionlimit(10**6)
N = int(input())

V = [[] for _ in range(N)]
C = [-1 for _ in range(N - 1)]


# v:頂点, c:色, p:親
def dfs(v, c, p):
    k = 1
    for _v, _id  in V[v]:
        if _v == p:
            continue
        if k == c:
            k += 1
        C[_id] = k
        dfs(_v, k, v)
        k += 1

for i in range(N-1):
    a, b = map(int, input().split())
    a -= 1
    b -= 1
    V[a].append([b, i])
    V[b].append([a, i])
#print(V)
dfs(0, -1, -1)
print(max(C))
for i in C:
    print(i)


Measured memory_bytes: 78324
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <cmath>
#include <algorithm>
#include <functional>
#include <stack>
#include <numeric>
typedef long long ll;
using namespace std;
const int MOD = (int)1e9 + 7;
const ll INF = (ll)1e18 + 7;
#define int long long
#define vint vector<int>
#define pint pair<int,int>
#define pb(a) push_back(a)
#define all(v) v.begin(),v.end()
#define dbg(x) cerr << #x << " = " << (x) << endl
#define yn(b) cout << ((b) ? "Yes" : "No") << endl
#define YN(b) cout << ((b) ? "YES" : "NO") << endl

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

//各位の和を返す
int GetDigitSum(int num){
	int N = 0;
	while (num > 0){
		N += num % 10;
		num /= 10;
	}
	return N;
}

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

	int N;
	cin >> N;

	yn(N % GetDigitSum(N) == 0);

	return 0;
}

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

double dp[301][301][301];

double f(int x,int y,int z,int &n){
    if(x < 0 || y < 0 || z < 0){return 0;}
    if(x == 0 && y == 0 && z == 0){
        return 0;
    }
    if(dp[x][y][z]>-0.9){
        return dp[x][y][z];
    }
    double ev=n+x*f(x-1,y,z,n)+y*f(x+1,y-1,z,n)+z*f(x,y+1,z-1,n);
    return dp[x][y][z]=ev/(x+y+z);
    
}

int main(){
    memset(dp,-1,sizeof(dp));
    int n,x;
    cin>>n;
    int ones=0,two=0,three=0;
    for(int i=1;i<=n;i++){
        cin>>x;
        if(x==1)ones++;
        else if(x==2)
            two++;
        else
            three++;
        
    }
    cout<<fixed<<setprecision(9)<<f(ones,two,three,n)<<"\n";
    return 0;
}

Measured memory_bytes: 213376
int judge(int state, char *str){
  int l=strlen(str),i=0;
  for(;i<l;i++){
    switch(str[i]){
      case 'L': if(!(state==2||state==4||state==6))return 0;state=1;break;
	  case 'R': if(!(state==1||state==3||state==5))return 0;state=2;break;
      case 'U': if(!(state==1||state==5)){if(!(state==2||state==6))return 0;state=3;}else state=4;break;
	  default:  if(!(state==1||state==3)){if(!(state==2||state==4))return 0;state=5;}else state=6;break;
    }
  }
  return 1;
}

int isacceptable(char *str){
  switch(str[0]){
    case 'L': return judge(1,str+1);
	case 'R': return judge(2,str+1);
	case 'U': return judge(3,str+1)?1:judge(4,str+1);
	default:  return judge(5,str+1)?1:judge(6,str+1);
  }
}

int main(){
  int n; char str[100001];
  scanf("%d",&n);
  for(;n;n--){
    scanf("%s",str);
	printf("%s\n",isacceptable(str)?"Yes":"No");
  }
  return 0;
}

Measured memory_bytes: 684
#include <bits/stdc++.h>
using namespace std;
int i,j,num[4],n;
char s[10];
int main()
{
	scanf("%d",&n);
	for (i=1;i<=n;i++)
	{
		scanf("%s",s);
		if (strcmp(s,"AC")==0) num[0]++;
		if (strcmp(s,"WA")==0) num[1]++;
		if (strcmp(s,"TLE")==0) num[2]++;
		if (strcmp(s,"RE")==0) num[3]++; 
	}
	printf("AC x %d\nWA x %d\nTLE x %d\nRE x %d",num[0],num[1],num[2],num[3]);
}

Measured memory_bytes: 3828
#include<iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <cmath>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
int Max = 1000000;
int main(){

  	string S;
  	cin >> S;

  	int N = S.size();
 	int ans[N];

 	for(int i=0;i<N;i++) ans[i] = 0;

  	int conti = 0;
  	for(int i=0;i<N-1;i++){
  		if(S[i]=='R'){
  			if(S[i+1]=='R'){
  				conti++;
  				ans[i] = 0;
  			}else{
  				ans[i] += conti/2 + 1;
  				ans[i+1] += (conti+1)/2;
  				conti = 0;
  			}
  		}
  	}

  	conti = 0;
  	for(int i=N-1;i>0;i--){
  		if(S[i]=='L'){
  			if(S[i-1]=='L'){
  				ans[i] = 0;
  				conti++;
  			}else{
  				ans[i] += conti/2 + 1;
  				ans[i-1] += (conti+1)/2;
  				conti = 0;
  			}
  		}
  	}

  	for(int i=0;i<N;i++) cout << ans[i] << " ";
  	cout <<endl;
    
  	return 0;
}



Measured memory_bytes: 1152
#include<iostream>
#include<algorithm>
#include<string>
#include<cstdlib>
#include<map>
#include<iomanip>
#include<sstream>
#include<vector>
#include<stack>
#include<math.h>
#include<queue>
using namespace std;

int main() {
	map<long long int, long long int>mp;
	//cout << fixed << setprecision(10);
	long long int n, m, k, L[200001], R[200001], sum[200001] = {},res=0;
	cin >> n >> m;
	for (int i = 1; i <= m; i++) {
		cin >> L[i] >> R[i];
		sum[L[i]]++;
		sum[R[i]+1]--;
	}
	for (int i = 1; i <= n; i++) {
		sum[i] += sum[i - 1];
	}
	for (int i = 1; i <= n; i++) {
		if (sum[i] == m) {
			res++;
		}
	}
	cout << res;
}


Measured memory_bytes: 4992
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<int, int>;

#define int ll

#define _GLIBCXX_DEBUG

#define REP(i,n) for (int i = 0; i < (n); ++i)
#define REPD(i,n) for (int i = (n-1); i >= 0; --i)
#define FORE(i, s, n) for (int i = (s); i <= (int)(n); i++)
#define debug(x) cerr << #x << ": " << x << '\n'
#define hyphen() cerr << "--\n"

#define ALL(vec) (vec).begin(), (vec).end()
#define REVALL(vec) (vec).rbegin(), (vec).rend()

#define fst first
#define snd second
#define pb push_back

const int MOD = (int)1e9 + 7;
const int INF = numeric_limits<int>::max();

signed main() {
    int N, M;

    cin >> N >> M;

    // vector<int> As(N);
    // REP(i, N) {
    //     cin >> As.at(i);
    // }

    // その時点で一番高いものにチケットを適用していく
    // 途中ではdoubleで持っておく
    priority_queue<double> costs;
    REP(i, N) {
        int A;
        cin >> A;

        costs.push(A * 1.0);
    }

    REP(m, M) {
        int a = costs.top();
        costs.pop();

        costs.push(a / 2.0);
    }

    // 計算
    int ans = 0;
    while(!costs.empty()) {
        int c = costs.top();
        costs.pop();

        ans += c;
    }

    cout << ans << endl;

}


Measured memory_bytes: 1400
#include <stdio.h>
#include <string.h>
int main(void){
    char str[101];
    int n;
    int i;

    scanf( "%s", str );
    n = strlen( str );

    for( i = 0; i < n ; i++ ){
        str[i] = 'x';
    }

    printf( "%s\n", str );

    return 0;
}

Measured memory_bytes: 128
#include <algorithm>
#include <iostream>
#include <map>
#include <numeric>
#include <set>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>
#include <queue>
#define MOD (1000000007l)
#define rep(i, n) for(long i = 0; i < n; i++)

using namespace std;

int main(void) {
  string S, T;
  cin >> S >> T;
  for (long i = S.size() - T.size(); i >= 0; i--) {
    bool flag = true;
    for (long j = 0; j < T.size(); j++) {
      if (S[i + j] != '?' and S[i + j] != T[j]) {
        flag = false;
        break;
      }
    }
    if (flag) {
      string ans = S;
      for (long j = 0; j < T.size(); j++) ans[i + j] = T[j];
      for (long j = 0; j < S.size(); j++) if (ans[j] == '?') ans[j] = 'a';
      cout << ans << endl;
      return 0;
    }
  }
  cout << "UNRESTORABLE" << endl;
  return 0;
}


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

void solve(int n,int x)
{
	if(x==1||x==2*n-1){
		cout<<"No"<<endl;
		return;
	}
	vector<int> res;
	if(x==2){
		for(int i=3;i<=n;i++)
				res.push_back(i);
		res.push_back(2*n-1);
		res.push_back(x);
		res.push_back(1);
		res.push_back(2*n-2);
		for(int i=n+1;i<=2*n-3;i++)
				res.push_back(i);
	}
	else{
		for(int i=3;i<=n;i++) if(i!=x)
				res.push_back(i);
		res.push_back(1);
		res.push_back(x);
		res.push_back(2*n-1);
		res.push_back(2);
		for(int i=n+1;i<=2*n-2;i++) if(i!=x)
				res.push_back(i);
	}
	cout<<"Yes"<<endl;
	for(int i=0;i<2*n-1;i++)
		cout<<res[i]<<endl;
}

int main()
{
	for(int n,x;cin>>n>>x&&n|x;)
		solve(n,x);
}


Measured memory_bytes: 2420
N = int(input())
SP = []
for i in range(N):
    line = input().split()
    s = line[0]
    p = int(line[1])
    # レストラン番号と紐付けておく
    SP.append([s, p, i + 1])
# SPの中身はそれぞれ[市名, 点数, 店番号]
# 市名で昇順ソート、更に点数で降順ソート
SP = sorted(SP, key=lambda x: (x[0], -x[1]))
for spi in SP:
    print(spi[2])


Measured memory_bytes: 9052
/*
  Author: @yash_31
*/
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp> 
#include <functional>
#define ll long long int
#define eb emplace_back
#define fatafat ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define MOD 1000000007
#define ft first
#define sd second
#define mkpr make_pair
#define deb(x) std::cout<<#x<<":"<<x<<endl;
#define whole(x) (x).begin(),(x).end()
#define revwhole(x) (x).rbegin(),(x).rend()
#define endl "\n"
#define fbo find_by_order
#define ook order_of_key
#define init0(x) memset(x,0,sizeof(x));
 
using namespace std; 
using namespace __gnu_pbds;
typedef tree<ll, null_type, less<ll>, rb_tree_tag,tree_order_statistics_node_update> gharKaSet;
 
const int mlmt=2e5+2;
const ll inf=1e18;
//TTBDC
 
vector<vector<ll>> mult(vector<vector<ll>> &a,vector<vector<ll>> &b,int n){
  vector<vector<ll>> res(n,vector<ll> (n,0));
  for(int i=0;i<n;i++){
    for(int j=0;j<n;j++){
      for(int k=0;k<n;k++){
        res[i][j] = (res[i][j] + (a[i][k] * b[k][j])%MOD)%MOD;
      }
    }
  }
  return res;
}
 
int main()
{
  fatafat
  int u,v,n,m;
  ll k;
  cin>>n>>k;
  vector<vector<ll>> mat(n,vector<ll> (n,0));
  vector<vector<ll>> ans(n,vector<ll> (n,0));
  for(int i=0;i<n;i++){
    for(int j=0;j<n;j++){
      cin>>mat[i][j];
      ans[i][j] = mat[i][j];
    }
  }
  k--;
  while(k>0){
    if(k&1){ans = mult(ans,mat,n);}
    k>>=1;
    mat = mult(mat,mat,n);
  }
  ll fans = 0;
  for(int i=0;i<n;i++){
    for(int j=0;j<n;j++){
      fans=(fans + ans[i][j])%MOD;
    }
  }
  cout<<fans;
  return 0;
}

Measured memory_bytes: 3708
A = [list(map(int,input().split())) for i in range(3)]

N = int(input())
b = [int(input()) for i in range(N)]

for i in b:
  for j in range(3):
    if i in A[j]:
      A[j][A[j].index(i)] = 0
else:
  for i in range(3):
    if (A[0][i] + A[1][i] + A[2][i] == 0) or (A[i][0] + A[i][1] + A[i][2] == 0):
      print('Yes')
      break
  else:
    if (A[0][0] + A[1][1] + A[2][2] == 0) or (A[0][2] + A[1][1] + A[2][0] == 0):
      print('Yes')
    else:
      print('No')
      

Measured memory_bytes: 3064
macro_rules! get {
    ($t:ty) => {
        {
            let mut line: String = String::new();
            std::io::stdin().read_line(&mut line).unwrap();
            line.trim().parse::<$t>().unwrap()
        }
    };
    ($($t:ty),*) => {
        {
            let mut line: String = String::new();
            std::io::stdin().read_line(&mut line).unwrap();
            let mut iter = line.split_whitespace();
            (
                $(iter.next().unwrap().parse::<$t>().unwrap(),)*
            )
        }
    };
    ($t:ty; $n:expr) => {
        (0..$n).map(|_|
            get!($t)
        ).collect::<Vec<_>>()
    };
    ($($t:ty),*; $n:expr) => {
        (0..$n).map(|_|
            get!($($t),*)
        ).collect::<Vec<_>>()
    };
    ($t:ty ;;) => {
        {
            let mut line: String = String::new();
            std::io::stdin().read_line(&mut line).unwrap();
            line.split_whitespace()
                .map(|t| t.parse::<$t>().unwrap())
                .collect::<Vec<_>>()
        }
    };
    ($t:ty ;; $n:expr) => {
        (0..$n).map(|_| get!($t ;;)).collect::<Vec<_>>()
    };
}

fn main() {
    let s = get!(String).split(',').collect::<Vec<_>>().join(" ");
    println!("{}", s);
}

Measured memory_bytes: 4352
#include<iostream>
#include<iomanip>
#include<cassert>
#include<math.h>
#include<complex>
#include<algorithm>
#include<utility>
#include<queue>
#include<string.h>
#include<string>
#include<set>
#include<map>
#include<unordered_map>
#include<functional>
#include<vector>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
const ll INF=2e18;
const ll MOD=1e9+7;

ll N,Q;
string S;
ll cnt[100010];
int main(){
    cin>>N>>Q>>S;
    for(ll i=2;i<=N;i++){
        cnt[i]=cnt[i-1]+(S[i-1]=='C' && S[i-2]=='A');
    }
    for(ll i=0;i<Q;i++){
        ll l,r;
        cin>>l>>r;
        cout<<cnt[r]-cnt[l]<<endl;
    }
    return 0;
}

Measured memory_bytes: 4508
N, K = map(int, input().split())
num = []

for k in range(N):
    a, b = map(int, input().split())
    num.append((a, b))

num = sorted(num)
cnt = 0
for i in num:
    cnt += i[1]
    if cnt >= K:
        print(i[0])
        break

Measured memory_bytes: 17808
def f(n)
  n.even? ? n / 2 : 3 * n + 1
end

s = gets.chomp.to_i
ary = [s]
cnt = 1
ans = nil

loop do
  cnt += 1
  s = f(s)
  if ary.include? s
    ans = cnt
    break
  end
  ary << s
end

puts ans

Measured memory_bytes: 14336
#include <iostream>
#include <algorithm>


const int MAXN = 1e5 + 1;

long long dp[MAXN];


int main()
{
    std::ios::sync_with_stdio(false);
    std::cout.tie(nullptr);
    std::cin.tie(nullptr);

    int items, maxWeight;
    std::cin >> items >> maxWeight;

    for (int iItem = 0; iItem < items; iItem++)
    {
        int weight; long long value;
        std::cin >> weight >> value;

        for (int iWeight = maxWeight; iWeight >= weight; iWeight--)
            dp[iWeight] = std::max(dp[iWeight], dp[iWeight - weight] + value);
    }

    long long maxValue = 0;
    for (int iWeight = maxWeight; iWeight > -1; iWeight--)
        maxValue = std::max(maxValue, dp[iWeight]);
    std::cout << maxValue << '\n';

    return 0;
}


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

int main() {
  string s;
  int k;
  cin >> s >> k;
  int dp[s.size()][k + 1][2];
  for (int i = 0; i <= k; ++i) {
    dp[0][i][0] = 0;
    dp[0][i][1] = 0;
  }
  dp[0][0][0] = 1;
  if (s[0] != '0') {
    dp[0][1][0] = s[0] - '0' - 1;
  }
  dp[0][1][1] = 1;
  for (int i = 1; i < s.size(); ++i) {
    dp[i][0][0] = 1;
    dp[i][0][1] = 0;
    for (int j = 1; j <= k; ++j) {
      dp[i][j][0] = dp[i - 1][j][0] + dp[i - 1][j - 1][0] * 9;
      if (s[i] == '0') {
        dp[i][j][1] = dp[i - 1][j][1];
      } else {
        dp[i][j][1] = dp[i - 1][j - 1][1];
        dp[i][j][0] += dp[i - 1][j - 1][1] * (s[i] - '0' - 1) + dp[i - 1][j][1];
      }
    }
  }
  cout << dp[s.size() - 1][k][0] + dp[s.size() - 1][k][1];
  return 0;
}


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

int main(){
    int a,b;
    int d = 0;
    cin >> a >> b;
    vector<char> v(b);
    for(int i=0;i<b;i++)cin >> v[i];
    while (true){
        d = 0;
        string s = to_string(a);
        for(int j=0;j<s.size();j++){
            char c = s[j];
            if(find(v.begin(),v.end(),c) != v.end()){
            d = 1;
            break;
        }
        }
        if(d == 0){
            cout << a << endl;
            break;
        }
        a++;
        }
}

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

using namespace std;
using ll = long long;

#define rep(i, a) for (int i = 0; (i) < (int) (a); (i)++)
#define reps(i, a, b) for (int i = (int) (a); (i) < (int) (b); (i)++)
#define rrep(i, a) for (int i = (int) a-1; (i) >= 0; (i)--)
#define rreps(i, a, b) for (int i = (int) (a)-1; (i) >= (int) (b); (i)--)
#define MP(a, b) make_pair((a), (b))
#define PB(a) push_back((a))
#define all(v) (v).begin(), (v).end()
#define PERM(v) next_permutation(all(v))
#define UNIQUE(v) sort(all(v));(v).erase(unique(all(v)), v.end())
#define CIN(type, x) type x;cin >> x
#define TRUE__  "YES"
#define FALSE__ "NO"
#define PRINT(f) if((f)){cout << (TRUE__) << endl;}else{cout << FALSE__ << endl;}
#define RS resize
#define CINV(v, N) do {\
	v.RS(N);\
	rep(i, N) cin >> v[i];\
} while (0);
#define RCINV(v, N) do {\
	v.RS(N);\
	rrep(i, N) cin >> v[i];\
} while (0);

#define MOD 1000000007

void init();
void solve();

signed main()
{
	init();
	solve();
}

int N;
ll G, C, D;

void init()
{
	ll A, B;
	cin >> N >> A >> B >> C >> D;
	G = B - A;
}

void culc(int x, ll& mi, ll& ma)
{
	mi = C * x;
	ma = D * x;
}

void solve()
{
	rep(i, N) {
		ll pma, pmi, mma, mmi;
		culc(i, pmi, pma);
		culc(N-i-1, mmi, mma);
		ll ma = pma - mmi;
		ll mi = pmi - mma;
		if (ma >= G && mi <= G) {
			cout << "YES" << endl;
			return;
		}
	}
	cout << "NO" << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,i0,n) for(int i=i0;i<n;++i)
#define ll long long
#define ALL(x) (x).begin(),(x).end()
#define INF12 1000000000000 //10^12
#define INF9 1000000000 //10^9
#define MOD 10000007 //10^9+7

int K;
vector<ll> runrun;
ll runrun_count;

// digit桁のrunrun数を再帰的に生成しrunrunに格納する
void generateRunrun(ll max_digit, ll current_digit, ll x){
    if(runrun_count >= K) return;

    if(current_digit == max_digit) {
        runrun.push_back(x);
        runrun_count++;
        // cout << runrun_count << ":" << x << endl;
        return;
    }

    int tmp = x % 10;
    if(tmp != 0) {
        int x1 = tmp - 1;
        generateRunrun(max_digit, current_digit+1, 10*x + x1);
    }
    int x2 = tmp;
    generateRunrun(max_digit, current_digit+1, 10*x + x2);
    if(tmp != 9) {
        int x3 = tmp + 1;
        generateRunrun(max_digit, current_digit+1, 10*x + x3);
    }
}

int main() {
    cin >> K;
    rep(i,1,10) runrun.push_back(i);
    runrun_count = 9;

    // int iter = 1;
    // while(true) {
    rep(digit, 2, 12) { // たぶん12桁くらいまで
        rep(i,1,10) generateRunrun(digit, 1, i);
        if(runrun_count >= K) break;
    }
        
    // }

    cout << runrun[K-1] << endl;
    return 0;
}

Measured memory_bytes: 1400
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

macro_rules! input_inner {
    ($iter:expr) => {};
    ($iter:expr, ) => {};

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

macro_rules! read_value {
    ($iter:expr, ( $($t:tt),* )) => {
        ( $(read_value!($iter, $t)),* )
    };

    ($iter:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()
    };

    ($iter:expr, chars) => {
        read_value!($iter, String).chars().collect::<Vec<char>>()
    };

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

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

#[allow(dead_code)]
fn practice_1() {
    input! {
    n: i32,
    m: [i32; 2],
    s: chars,
    }
    let s: Vec<char> = s;
    let s: String = s.into_iter().collect();

    println!("{} {}", n + m[0] + m[1], s);
}

#[allow(dead_code)]
fn abc086_a() {
    input! {
    n: [i32; 2],
    }
    let prod: i32 = n[0] * n[1];
    let res = if prod % 2 == 0 {
        "Even"
    } else {
        "Odd"
    };
    println!("{}", res)
}

#[allow(dead_code)]
fn abc081_a() {
    input! {
    s: chars,
    }
    let s: Vec<char> = s;
    let res: u32 = s.into_iter().map(|n| {
        n.to_digit(10).unwrap()
    }).sum();

    println!("{}", res)
}

fn main() {
    abc081_a()
}



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

#define PI 3.14159265359
#define INF 1e9
#define LINF 1e18
#define IMOD 1000000007 
#define irep(i,n) for(int i = 0; i < (int)(n); i++)
#define irep2(i,a,n) for(int i = (int)(a); i <= (int)(n); i++)
#define lrep(i,n) for(long long  i = 0; i < (long long)(n); i++)
#define lrep2(i,a,n) for(long long i = (long long)(a); i <= (long long)(n); i++)

#define irrep(i,n) for(int i = (int)(n); i > -1; i--)
#define irrep2(i,a,n) for(int i = (int)(n); i >= (int)(a); i--)

typedef long long ll;
typedef std::vector<char> v_char;
typedef std::vector<v_char > v2_char;
typedef std::vector<double> v_double;
typedef std::vector<v_double > v2_double;
typedef std::vector<int> v_int;
typedef std::vector<v_int > v2_int;
typedef std::vector<ll> v_ll;
typedef std::vector<v_ll > v2_ll;
typedef std::vector<std::string> v_string;
typedef std::vector<v_string > v2_string;
typedef std::vector<bool> v_bool;
typedef std::vector<v_bool > v2_bool;
typedef std::pair<ll, ll> pll;
typedef std::pair<int, int> pii;

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

using namespace std; 

int main(void)
{
    ll s, t, k;
    cin >> s >> t >> k;
    
    s -= k;

    if(s <= 0) {
        t += s;
    }

    cout << max(s, (ll)0) << " " << max(t, (ll)0);

    return 0;
}   
/** atcoder **/


Measured memory_bytes: 256
N = int(input())
c = list(input())
c.reverse()
cnt = c.count('W')
ans3 = 0
for i in range(N):
    if c[i] == 'R' and cnt > 0:
        ans3 += 1
        cnt -= 1
    if c[i] == 'W':
        cnt -= 1
    #print(ans3,cnt)
print(ans3)


Measured memory_bytes: 77140
#include<iostream>
#include<vector>
#include<algorithm>
#include<cstdio>
#include<cstdlib>
#include<string>
#include<sstream>
#include<cmath>
#include<numeric>
#include<map>
#include<stack>
#include<queue>
#include<list>
using namespace std;
int inf = 1000000000;

int main(void) {

  vector<string> s(16);
  for(int i=0; i<4; i++) s[i] = "0000000000000000";
  for(int i=12; i<16; i++) s[i] = "0000000000000000";
  while(cin >> s[4]){
    for(int i=5; i<12; i++) cin >> s[i];
    for(int i=4; i<12; i++) s[i] = "0000" + s[i] + "0000";

    bool f = false;
    for(int i=4; i<12; i++){
      for(int j=4; j<12; j++){
        if( f ) continue;
        if( s[i][j] == '0' ) continue;

        if( s[i][j] == '1' && s[i+1][j] == '1' && s[i][j+1] == '1' && s[i+1][j+1] == '1' ) cout << 'A' << endl;
        else if( s[i][j] == '1' && s[i+1][j] == '1' && s[i+2][j] == '1' && s[i+3][j] == '1' ) cout << 'B' << endl;
        else if( s[i][j] == '1' && s[i][j+1] == '1' && s[i][j+2] == '1' && s[i][j+3] == '1' ) cout << 'C' << endl;
        else if( s[i][j] == '1' && s[i+1][j] == '1' && s[i+1][j-1] == '1' && s[i+2][j-1] == '1' ) cout << 'D' << endl;
        else if( s[i][j] == '1' && s[i][j+1] == '1' && s[i+1][j+1] == '1' && s[i+1][j+2] == '1' ) cout << 'E' << endl;
        else if( s[i][j] == '1' && s[i+1][j] == '1' && s[i+1][j+1] == '1' && s[i+2][j+1] == '1' ) cout << 'F' << endl;
        else if( s[i][j] == '1' && s[i][j+1] == '1' && s[i+1][j] == '1' && s[i+1][j-1] == '1' ) cout << 'G' << endl;

        f = true;
      }
    }


  }

  return 0;
}

// EOF

Measured memory_bytes: 3048
#include <iostream>
#include <cstdio>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <iomanip>
#include <stdlib.h>
#include <string.h>
#include <cstring>
#include <cmath>
#include <map>
#include <queue>
#include <deque>
#include <stack>
#include <set>
#include <stdio.h>
#include <tuple>
#include <bitset>
#include <cfloat>
#include <fstream>
#include <limits.h>
#include <list>
#include <math.h>
#include <random>
#include <unordered_map>
#include <unordered_set>
#include <bitset>
#include <numeric>
#include <utility>
#include <sstream>
// *テンプレート*
#define int long long
#define rep(i, n) for (int i = 0; i < (n); i++)
#define P pair<int, int>
#define sz(x) x.size()
#define EPS (1e-10)
// aよりbの方が小さかったら、aの値をbの値に置き換える。(swapではない！)
template<class T> inline bool chmin(T& a, T b) {
	if (a > b) {
		a = b;
		return true;
	}
	return false;
}
// aよりbの方が大きかったら、aの値をbの値に置き換える。
template<class T> inline bool chmax(T& a, T b) {
	if (a < b) {
		a = b;
		return true;
	}
	return false;
}

using namespace std;
typedef long long ll;
using Graph = vector<vector<int>>;
//最大公約数
ll gcd(ll a, ll b) {
	if (a < b)swap(a, b);
	if (b == 0) return a;
	return gcd(b, a % b);
}
//最小公倍数
ll lcm(ll a, ll b) {
	ll g = gcd(a, b);
	return a / g * b;
}
// 素数かどうか判定
bool prime(int n) {
	for (int i = 2; i <= sqrt(n); i++) {
		if (n%i == 0)return false;
	}
	return n != 1;
}

const long long MOD = 1000000007;
const long long INF = 1LL << 60;
// *テンプレートここまで*

// pair -> vector<pair<int,int>> 
//		   AandB.push_back(make_pair(a[i],b[i]))
int s[10];
int n = 0;
int ans = 0;
void dfs(int i, int sum, int now) {
	if (i == n - 1) {
		ans += sum + now;
		return;
	}
	else {
		dfs(i + 1, sum + now, s[i + 1]);
		dfs(i + 1, sum, now * 10 + s[i + 1]);
	}
}

signed main() {
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	string str; cin >> str;
	n = str.size();
	rep(i, n) {
		s[i] = str.at(i) - '0';
	}
	dfs(0, 0, s[0]);
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  vector<int> cook(3);
  for(int i = 0; i < 3; i++){
    cin >> cook[i];
  }
  sort(cook.begin(),cook.end());
  long long A = cook[0],B = cook[1],C = cook[2];
   for (int i = 0; i < 1000; ++i) {
        if (A & 1){
          cout << i;
          return 0;
        }
        if (B & 1){
          cout << i;
          return 0;
        }
        if (C & 1){
          cout << i;
          return 0;
        }
        long long tA = (B + C) / 2;
        long long tB = (C + A) / 2;
        long long tC = (A + B) / 2;
        A = tA, B = tB, C = tC;
    }
    cout << -1;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
typedef pair<LL, LL> PII;

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

template <typename T>
function<T(T, T)> op_max = [](T a, T b) -> T { return max(a, b); };
template <typename T>
function<T(T, T)> op_min = [](T a, T b) -> T { return min(a, b); };

template <typename T>
function<T(T, T)> op_sum = [](T a, T b) -> T { return a + b; };

namespace detail {
template <typename T, std::size_t NDIMS>
struct vector_builder {
  using type = std::vector<typename vector_builder<T, NDIMS - 1>::type>;

  static type make(std::vector<std::size_t> dims, const T& v = {}) {
    const auto vec = std::vector<T>(dims.empty() ? 0 : dims.back(), v);
    if (!dims.empty()) dims.pop_back();
    return vector_builder<std::vector<T>, NDIMS - 1>::make(dims, vec);
  }
};

template <typename T>
struct vector_builder<T, 1> {
  using type = std::vector<T>;

  static type make(std::vector<std::size_t> dims, const T& v = {}) {
    return type(dims.empty() ? 0 : dims.back(), v);
  }
};
}  // namespace detail

template <typename T, typename... SIZE_T>
auto exvector(const T& v, SIZE_T... dims) {
  static_assert(sizeof...(dims) != 0, "invalid dimension");
  std::vector<std::size_t> vec_dims{dims...};
  return detail::vector_builder<T, sizeof...(dims)>::make(vec_dims, v);
}

using namespace std;
//********************  dumps ************************//

template <typename T>
void dump(const T& data, vector<int>& iter) {
  cout << data << " ";
}
template <typename T>
void dump(const vector<T>& data, vector<int>& iter) {
  for (auto elem : data) dump(elem, iter);
  cout << endl;
}

template <typename T>
void dump(const vector<vector<T>>& data, vector<int>& iter) {
  for (auto elem : iter) {
    cout << "[" << elem << "]";
  }
  cout << endl;
  for (int i = 0; i < data.size(); i++) {
    iter.push_back(i);
    dump(data[i], iter);
    iter.pop_back();
  }
  cout << endl;
}

template <typename T>
void dump(const vector<T>& data, int dummy) {
  for (int i = 0; i < data.size(); i++) {
    cout << "[" << i << "] " << data[i] << endl;
  }
}
template <typename T>
void dump(const T& data) {  // T : data, U = base type val.
  vector<int> iter;
  dump(data, iter);
}
///////////////////////////////////////////////

void solve(long long R, long long G, long long B, long long N) {
  LL ans = 0;
  for (int i = 0; i <= 3000; i++)
    for (int j = 0; j <= 3000; j++) {
      LL ret = N;
      ret -= i * R;
      ret -= j * G;

      if (ret >= 0 && ret % B == 0) ans++;
    }
  cout << ans << endl;
}

int main() {
  cout << setprecision(10);
  long long R;
  scanf("%lld", &R);
  long long G;
  scanf("%lld", &G);
  long long B;
  scanf("%lld", &B);
  long long N;
  scanf("%lld", &N);
  solve(R, G, B, N);
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <cstring>
#include <cstdlib>
#include <cmath>
using namespace std;
using ll = long long;

int main() {
    int n, k;
    cin >> n >> k;

    int s[256];
    cin >> s['s'] >> s['p'] >> s['r'];

    string t;
    cin >> t;

    int r = 0;
    for (int h = 0; h < k; h++) {
        int x = 0, p = -1;
        for (int i = h; i < n; i += k) {
            if (t[i] != p) {
                x += s[t[i]];
                p = t[i];
            } else {
                p = -1;
            }
        }
        r += x;
    }

    cout << r << endl;

    //K回前にパーを出したときの最大値

    return 0;
}

Measured memory_bytes: 512
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
using P = pair<int,int>;
/* ちゃんと考えてわかって実装 */

int main(void){
    int n, m, k;
    cin >> n >> m >> k;
    vector<ll> rui_a, rui_b;
    rui_a.push_back(0);
    rui_b.push_back(0);
    for(int i=0; i<n; i++){
        ll A; cin >> A;
        rui_a.push_back(A + rui_a[i]);
    }
    for(int i=0; i<m; i++){
        ll B; cin >> B;
        rui_b.push_back(B + rui_b[i]);
    }

    ll ans = 0;
    ll ok = m;
    for(int i=0; i<=n; i++){
        while(rui_a[i] + rui_b[ok] > k && ok >= 0){
            ok--;
        }
        if(rui_a[i] + rui_b[ok] <= k){
            ans = max(ans, i+ok);
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 7980
import sys
import math
from collections import defaultdict

sys.setrecursionlimit(10**7)
def input():
    return sys.stdin.readline()[:-1]

mod = 10**9 + 7

def I(): return int(input())
def II(): return map(int, input().split())
def III(): return list(map(int, input().split()))
def Line(N):
    read_all = [tuple(map(int, input().split())) for _ in range(N)]
    return map(list,zip(*read_all))

#################

def edges_to_pt(s,t,n,directed=False):
    pt = [[] for _ in range(n)]
    for i in range(len(s)):
        pt[s[i]-1].append(t[i]-1)
        if directed==False:
            pt[t[i]-1].append(s[i]-1)
    return pt

def fact_all(n,M=mod):
    f = [1]*(n)
    ans = 1
    for i in range(1,n):
        ans = ans*i
        ans = ans%M
        f[i] = ans
    return f

def extgcd(a,b):
    r = [1,0,a]
    w = [0,1,b]
    while w[2]!=1:
        q = r[2]//w[2]
        r2 = w
        w2 = [r[0]-q*w[0],r[1]-q*w[1],r[2]-q*w[2]]
        r = r2
        w = w2
    return [w[0],w[1]]

def mod_inv(a,M=mod):
    x = extgcd(a,M)[0]
    return (M+x%M)%M

N,K = II()
if N==1:
    print(K)
    exit()
else:
    a,b = Line(N-1)

pt = edges_to_pt(a,b,N)
v = 0
ans = K
check_visited = [False]*N
check_visited[v] = True
S = [v]
l = 0

f = fact_all(K)
inv = [0]*K
for i in range(K):
    inv[i] = mod_inv(f[i])

while S:
    v1 = S.pop()
    num = 0
    for i in pt[v1]:
        if check_visited[i] == False:
            check_visited[i] = True
            num += 1
            S.append(i)
    if l==0:
        if K-1-num>=0:
            ans *= f[K-1]*inv[K-1-num]
            ans %= mod
            l = 1
        else:
            print(0)
            exit()
    else:
        if K-2-num>=0 and K-2>=0:
            ans *= f[K-2]*inv[K-2-num]
            ans %= mod
        else:
            print(0)
            exit()

print(ans)

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

#define ld long double
#define sf scanf
#define pf printf
#define pb push_back
#define mp make_pair
#define PI ( acos(-1.0) )
#define IN freopen("input.txt","r",stdin)
#define OUT freopen("output.txt","w",stdout)
#define FOR(i,a,b) for(int i=a ; i<=b ; i++)
#define FORD(i,a,b) for(int i=a ; i>=b ; i--)
#define INF 1000000000
#define ll long long int
#define eps (1e-8)
#define sq(x) ( (x)*(x) )
#define all(x) x.begin(),x.end()
#define flog2(n) 64 - __builtin_clzll(n) - 1
#define popcnt(n) __builtin_popcountll(n)

using namespace std;

typedef pair < int, int > pii;
typedef pair < ll, ll > pll;

ll h[100005];
ll d[100005];

int main()
{
    ios::sync_with_stdio(0);
    cin.tie(NULL);
    
    int n, k;
    cin >> n >> k;
    FOR (i, 1, n) {
    	cin >> h[i];
    }

    d[1] = 0;

    FOR (i, 2, n) {
        d[i] = 1e18;
        FOR (j, 1, k) {
            if (i - j > 0) {
                d[i] = min(d[i], d[i - j] + abs(h[i] - h[i - j]));
            }
        }
    }

    cout << d[n] << endl;

	
    return 0;
}

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

int main(){
    int N,L; cin >> N >> L;
    int sum = N*(L+L+N-1)/2;
    int min = L;
    for(int i=L;i<L+N;i++){
        if(abs(min) > abs(i)){
            min = i;
        }
    }
    cout << sum-min << endl;
}

Measured memory_bytes: 256
#!/usr/bin/env python3
import fractions # Atcoderではfractions


N, X = map(int, input().split())
x = list(map(int,input().split()))
x.append(X)
x = sorted(x)
y = [0] * (N)

for i in range(N):
    y[i] = x[i+1]-x[i]

ans = 0
for i in range(N):
    ans = fractions.gcd(y[i],ans)
print(ans)

Measured memory_bytes: 88172
#pragma GCC optimize ("Ofast")
#include <cstdio>
using namespace std;

 int main(){
 	int n,k;
 	scanf("%d%d",&n,&k);

 	int* h = new int[n];
 	int x;
 	for(int i=0;i<n;i++){
 		scanf("%d",&h[i]);
 	}

 	int count = 0;
 	for(int i=0;i<n;i++){
 		if(k <= h[i]){
 			count ++;
 		}
 	}
 	printf("%d",count);
 	return 0;
 }

Measured memory_bytes: 640
n = int(input())
ss = []
for _ in range(n):
    ss.append(input())
hs = dict()
#hhs = dict()
keys = ['M', 'A', 'R', 'C', 'H']
for k in keys:
    hs[k] = 0
ss = sorted(ss)
for i, s in enumerate(ss, 0):
    c = s[0]
    if c in keys:
        if c in hs:
            hs[c] += 1
        else:
            hs[c] = 1
#        if i > 0 and s == ss[i - 1]:
#            if s in hhs:
#                hhs[s] += 1
#            else:
#                hhs[s] = 1
import itertools
combs = list(itertools.combinations(keys,3))
ans = 0
for comb in combs:
    ans += hs[comb[0]] * hs[comb[1]] * hs[comb[2]]
print(ans)

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

typedef long long ll;

int main(){
    ll N;
    cin>>N;
    double n=sqrt(N);
    ll Na=n;
    ll mmr=0;
    ll mmry=0;
    for(ll i=0;i<Na;i++){
        if(N%(Na-i)==0){
            mmr=Na-i;
            mmry=N/(Na-i);
            break;
        }
    }
    cout<<mmry+mmr-2<<endl;
}

Measured memory_bytes: 256
fn main(){
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    let mut ret : bool = false;
    let mut prev : std::option::Option<char> = s.chars().nth(0);
    for c in 0..s.len() - 1 {
        if s.chars().nth(c) != prev 
        {ret = true; break;}
        prev = s.chars().nth(c);
    }

    if ret == true {
        println!("Yes");

    }
    else{
        println!("No");
    }
}

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

using namespace std;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int N;
  cin >> N;
  auto f = [](int x) {
    cout << x << '\n';
    cout << flush;
    string s;
    cin >> s;
    if (s == "Vacant") {
      exit(0);
    } else if (s == "Male") {
      return 0;
    } else {
      return 1;
    }
  };
  int k = f(0);
  int lo = 0, hi = N - 1;
  while (lo <= hi) {
    int mi = (lo + hi) / 2;
    int t = f(mi);
    if ((k == t && mi % 2 == 0) || (k != t && mi % 2 == 1)) {
      lo = mi + 1;
    } else {
      hi = mi - 1;
    }
  }
  return 0;
}


Measured memory_bytes: 852