akhauriyash/Code-Regression huggingface dataset:
import java.util.*;
//import java.lang.Math;
public class Main{
    public static void main(String[] args){
        Scanner sc=new Scanner(System.in);
        while(true){
            int n=sc.nextInt();
            int s=sc.nextInt();
            if(n==0 && s==0) break;
            int ans=0;
            for(int i=0;i<(1<<10);i++){
                int on=0;
                int sum=0;
                for(int j=0;j<10;j++) if((i&(1<<j))!=0){
                    on++;
                    sum+=j;
                }
                if(on!=n) continue;
                if(sum==s) ans++;
            }
            System.out.println(ans);
        }
    }
}


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

using namespace std;
#define rep(i,n) for(int i=0; i<(n); i++)
typedef long long ll;
#define INF 1e9



int main(){
    int R,G,B,n; cin >> R >> G >> B >> n;
    int cnt=0;
    
    for(int r=0; R*r <= n; r++){
        for(int g=0; G*g <= n; g++){
            if((R*r+G*g)>n){
                break;
            }
            int a = n-(R*r+G*g);
            if(a%B==0) cnt++;
            
        }
    }
    
    cout << cnt << endl;


}


Measured memory_bytes: 256
# coding: utf-8

n = int(input().rstrip())

numbers = list(map(int, input().rstrip().split(" ")))

tmp = list(sorted([ [numbers[i] - i, i] for i in range(n)]))


ans = 1000000000 * n

target = tmp[int(n/2)][0]
if n % 2 == 0:
    target = int((tmp[int(n/2)][0]+tmp[int(n/2)-1][0])/2)

ans = [abs(numbers[i] - (target + i)) for i in range(n)]
print(sum(ans))


Measured memory_bytes: 54548
#include <stack>
#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <cmath>
#include <array>
#include <iomanip>
using namespace std;
int gcd(int a, int b)
{
   if (a%b == 0)
   {
       return(b);
   }
   else
   {
       return(gcd(b, a%b));
   }
}
int mod = 1000000000 + 7;
long long minmax(int n, int k){
    long long ans = 0;
    int tmp1 = 0;
    int tmp2 = n;
    for(int i = 0; i < k; i++){
        ans += tmp2 - tmp1;
        ans %= mod;
        tmp1 ++;
        tmp2 --;
    }
    return ans;
}
int main(){
    //std::stack<int> stack;
    
    int n;
    cin >> n;
    vector<string> s(n);
    for(int i = 0; i < n; i++){
        cin >> s[i];
    }
    std::sort(s.begin(), s.end());
    int ans = 1;
    for(int i = 1; i < n; i++){
        if(s[i-1] != s[i]){
            ans ++;
        }
    }
    cout << ans << endl;
    return 0;
}





Measured memory_bytes: 9544
#include<stdio.h>

void call(int n);
int main(void)
{
	int num;

	scanf("%d",&num);
	if(3<=num && num<=10000) call(num);
	return 0;
}

void call(int n)
{
	int i,x;

	for(i=1;i<=n;i++){
		x=i;
		if(x % 3 == 0) printf(" %d",i);
		else{
			while(x){
				if(x % 10 == 3){
					printf(" %d",i);
					break;
				}
				x/=10;
			}
		}
	}
	printf("\n");
	return;
}

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

using namespace std;
using llong = long long;
using P = pair<llong, llong>;

#define BE(x) x.begin(), x.end()

const llong inf = llong(1e18)+7;
const llong mod = 1e9+7;

int main(){
	string o,e;
	cin >> o >> e;

	for(int i = 0; i < (int)e.size(); i++)
		cout << o[i] << e[i];
	if(o.size() > e.size())
		cout << o[(int)o.size()-1] << endl;
	else
		cout << endl;

	return 0;
}

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

using namespace std;

typedef long long  ll;

typedef ll Weight;
const Weight INF = 1e9;

typedef vector<Weight> Array;
typedef vector<Array> Matrix;

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

    int n, k, flag, x, y, c;

    while (cin >> n >> k, n || k) {
        Matrix d(n, Array(n, INF));

        for (int i = 0; i < n; ++i)
            d[i][i] = 0;

        for (int i = 0; i < k; ++i) {
            cin >> flag;
            if (flag == 0) { // ??¢
                cin >> x >> y;
                --x, --y;
                cout << (d[x][y] >= INF ? -1 : d[x][y]) << '\n';
            }
            else if (flag == 1) { // ??????
                cin >> x >> y >> c;
                --x, --y;
                for (int j = 0; j < n; ++j)
                    for (int k = j + 1; k < n; ++k)
                        d[k][j] = d[j][k] = min(d[j][k], min(d[j][x] + d[y][k] + c,
                                                             d[j][y] + d[x][k] + c));
            }
        }
    }
    return 0;
}

Measured memory_bytes: 1308
#include <bits/stdc++.h>
using namespace std;
using Graph = vector<vector<int>>;
#define ll long long
#define _GLIBCXX_DEBUG
const ll MOD = 1000000007;
const int MAX = 510000;

int main() {
  vector<vector<char>> c(3, vector<char>(3));
  for (int i=0; i<3; i++) {
    for (int j=0; j<3; j++) cin >> c[i][j];
  }
  cout << c[0][0] << c[1][1] << c[2][2] << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> pl;
#define all(a) (a).begin(),(a).end()
#define overload4(_1, _2, _3, _4, name, ...) name
#define rep1(n) for(ll i = 0;i < (n);i++)
#define rep2(i,n) for(ll i = 0;i < (n);i++)
#define rep3(i,a,b) for(ll i = (a);i < (b);i++)
#define rep4(i,a,b,c) for(ll i = (a);i < (b);i += (c))
#define rep(...) overload4(__VA_ARGS__, rep4, rep3, rep2, rep1)(__VA_ARGS__)
#define rrep1(n) for(ll i = (n)-1;i >= 0;i--)
#define rrep2(i,n) for(ll i = (n)-1;i >= 0;i--)
#define rrep3(i,a,b) for(ll i = (a)-1;i >= (b);i--)
#define rrep4(i,a,b,c) for(ll i = (a)-1;i >= (b);i -= (c))
#define rrep(...) overload4(__VA_ARGS__, rrep4, rrep3, rrep2, rrep1)(__VA_ARGS__)
#define SHOW(x) cout << #x << ": " << x << endl;
template<class T> ll sumArr(const T& a){ return accumulate(all(a), 0LL);}
template<class T> auto minArr(const T& a){ return *min_element(all(a));}
template<class T> auto maxArr(const T& a){ return *max_element(all(a));}
template<class T> void DEBUG_PRINT(T tmp){cout<<tmp<<endl;}
template<class T1,class... T2> void DEBUG_PRINT(T1 tmp,T2... tmp2){cout<<tmp<<" ";DEBUG_PRINT(tmp2...);}
ll gcd(ll a, ll b){ while(b){ ll c = b; b = a % b; a = c; } return a; }
const ll INF=1e18,MOD = 1e9+7;
const int iINF = 1e9;


int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    int x;
    cin>>x;
    rep(i,-1000,1000)rep(j,-1000,1000){
        if(pow(i,5) - pow(j,5) == x){
            cout<<i<<" "<<j<<endl;
            return 0;
        }
    }
    return 0;
}


Measured memory_bytes: 4080
# Q3
import bisect,collections,copy,heapq,itertools,math,numpy,string
import sys
from functools import lru_cache

def I(): return int(sys.stdin.readline().rstrip())
def LI(): return list(map(int,sys.stdin.readline().rstrip().split()))
def S(): return sys.stdin.readline().rstrip()
def LS(): return list(sys.stdin.readline().rstrip().split())

N = I()
A_i = LI()

total_fumidai = 0
prev_num = -1
for num in A_i:
    if prev_num < 0:
        prev_num = num
        continue

    if prev_num <= num:
        prev_num = num
    else:
        total_fumidai += (prev_num - num)
print(total_fumidai)

Measured memory_bytes: 50596
//https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8 より
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")
    };
}

//

fn run() {
    input! {
        n: usize,
        k: usize,
        a: [u32; n],
    }
    let mut a = a;
    a.sort();
    let mut ans = std::u32::MAX;
    for i in (k - 1)..n {
        ans = std::cmp::min(ans, a[i] - a[i - k + 1]);
    }
    println!("{}", ans);
}

fn main() {
    run();
}


Measured memory_bytes: 6396
#include <vector>
#include <iostream>
#include <algorithm>
#include <functional>
using namespace std;
int main() {
	int N, K;
	cin >> N >> K;
	vector<int> t(N), d(N);
	for (int i = 0; i < N; ++i) {
		cin >> t[i] >> d[i]; --t[i];
	}
	vector<vector<int> > g(N);
	for (int i = 0; i < N; ++i) {
		g[t[i]].push_back(d[i]);
	}
	vector<long long> cl, cr;
	for (int i = 0; i < N; ++i) {
		if (!g[i].empty()) {
			sort(g[i].begin(), g[i].end(), greater<int>());
			cl.push_back(g[i][0]);
			for (int j = 1; j < g[i].size(); ++j) {
				cr.push_back(g[i][j]);
			}
		}
	}
	sort(cl.begin(), cl.end(), greater<int>());
	sort(cr.begin(), cr.end(), greater<int>());
	vector<long long> sl(cl.size() + 1), sr(cr.size() + 1);
	for (int i = 0; i < cl.size(); ++i) sl[i + 1] = sl[i] + cl[i];
	for (int i = 0; i < cr.size(); ++i) sr[i + 1] = sr[i] + cr[i];
	long long ans = 0;
	for (int i = 0; i <= cl.size() && i <= K; ++i) {
		int t = K - i;
		if (t <= cr.size()) ans = max(ans, 1LL * i * i + sl[i] + sr[t]);
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 8180
#A = list(map(int, input().split()))
#n, k = map(int, input().split())
n = int(input())
A = list(map(int, input().split()))
i = 0
j = 0
money = 1000
while True:
  i = i+j
  j = 0
  while A[i] >= A[i+1]:
    i += 1
    if i + 1 == n:
      break
    #i が谷
  if i + 1 == n:
    break
  while A[i+j] <= A[i+j+1]:
    j += 1
    if i+j+1 == n:
      break
    #i+jが山
  if i+j+1 == n:
    money += (money // A[i]) * (A[i+j] - A[i])
    break
  money += (money // A[i]) * (A[i+j] - A[i])
print(money)

Measured memory_bytes: 9224
#include<iostream>
#include<stdio.h>
#include<string>
#include<vector>
#include<map>
#include<tuple>
#include<algorithm>
#include<cmath>
#include<limits>
#include<set>
#include<deque>
#include<queue>
using namespace std;
#define int long  long int
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }
int lcm(int a, int b) { return a / gcd(a, b) * b; }
typedef pair<int, int>P;
const int MOD = 1e9 + 7;
//const int MOD = 998244353;
const int INF = 1e10;
const long double PI = (acos(-1));


vector<int>table(1e5 + 5, 0);
void f() {
	for (int i = 2; i <= 1e5; i++) {
		bool isPrime = true;
		for (int j = 2; j * j <= i; j++) {
			if (i % j == 0)isPrime = false;
		}
		if (isPrime)table[i] = 1;
	}
}

signed main() {
	f();
	int Q;
	cin >> Q;
	vector<int>l(Q), r(Q);
	rep(i, Q)cin >> l[i] >> r[i];
	vector<int>v(1e5 + 5);
	v[0] = 0;
	for (int i = 1; i <= 1e5; i++) {
		if (i % 2 == 0)v[i] = v[i - 1];
		else v[i] = v[i - 1] + (table[i] && table[(i + 1) / 2]);
	}
	rep(i, Q) {
		int ans = v[r[i]] - v[l[i] - 1];
		cout << ans << endl;
	}
}

Measured memory_bytes: 3712
#include<bits/stdc++.h>
using namespace std;
 
#define pb push_back
#define ff first
#define ss second
#define N 100005
#define mod 1000000007
#define fo(n) for(int i=1;i<=n;i++)
typedef long long int ll;
typedef long int li;

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0); cout.tie(0);
    
    string s;
    cin>>s;
    for(int i=0;i<s.length();i++) {
        if((i+1)&1) {
            if(s[i] == 'L') {cout<<"No"; return 0;}
        }
        else {
            if(s[i] == 'R') { cout<<"No"; return 0; }
        }
    }
    cout<<"Yes";
    return 0;
}

Measured memory_bytes: 256
n = input()
a = list(map(int, input().split()))
b = list(map(int, input().split()))
c = list(map(int, input().split()))

ans = sum(b)
for i in range(len(a)-1):
  if a[i] + 1 == a[i+1]:
    ans += c[a[i]-1]
print(ans)

Measured memory_bytes: 3064
#include <iostream>
#include <cstring>
#include <cctype>
using namespace std;

int n, p;
string str;

string dfs(){
    int res = 0;
    string st = "";
    while (p < str.size()) {
        if (isdigit(str[p])) {
            res = 0;
            while (isdigit(str[p])) {
                res *= 10;
                res += str[p] - '0';
                p++;
            }
        }else if (isalpha(str[p])){
            st = "";
            while (isalpha(str[p])) {
                st += str[p++];
            }
        }else if (str[p] == '('){
            p++;
            string s = dfs();
            for (int i = 0; i < res; i++) {
                if (st.size() > n) {
                    return st;
                }
                st += s;
            }
        }else if (str[p] == ')'){
            p++;
            return st;
        }
    }
    return st;
}

string gen_new_str(){
    int p = 0;
    string st = "";
    while (p < str.size()) {
        if (!isalpha(str[p]) && isalpha(str[p+1])) {
            st += str[p];
            if (isdigit(str[p])) {
                st += "(";
            }else{
                st += "1(";
            }
            p++;
            while (isalpha(str[p])) {
                st += str[p++];
            }
            st += ")";
        }else{
            st += str[p++];
        }
    }
    return st;
}

int main()
{
    while (true) {
        cin >> str >> n;
        if (str == "0") {
            break;
        }
        p = 0;
        str = gen_new_str();
        string ans = dfs();
        if (ans.size() <= n) {
            cout << 0 << endl;
        }else{
            cout << ans[n] << endl;
        }
    }

    return 0;
}

Measured memory_bytes: 6880
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using P = pair<ll, ll>;
using Pld = pair<ld, ld>;
using Vec = vector<ll>;
using VecP = vector<P>;
using VecB = vector<bool>;
using VecC = vector<char>;
using VecD = vector<ld>;
using VecS = vector<string>;
using Graph = vector<VecP>;
template <typename T>
using Vec1 = vector<T>;
template <typename T>
using Vec2 = vector<Vec1<T> >;
#define REP(i, m, n) for(ll i = (m); i < (n); ++i)
#define REPN(i, m, n) for(ll i = (m); i <= (n); ++i)
#define REPR(i, m, n) for(ll i = (m)-1; i >= (n); --i)
#define REPNR(i, m, n) for(ll i = (m); i >= (n); --i)
#define rep(i, n) REP(i, 0, n)
#define repn(i, n) REPN(i, 1, n)
#define repr(i, n) REPR(i, n, 0)
#define repnr(i, n) REPNR(i, n, 1)
#define all(s) (s).begin(), (s).end()
#define pb push_back
#define fs first
#define sc second
template <typename T>
bool chmax(T &a, const T b){if(a < b){a = b; return true;} return false;}
template <typename T>
bool chmin(T &a, const T b){if(a > b){a = b; return true;} return false;}
template <typename T>
ll pow2(const T n){return (1LL << n);}
template <typename T>
void cosp(const T n){cout << n << ' ';}
void co(void){cout << '\n';}
template <typename T>
void co(const T n){cout << n << '\n';}
template <typename T1, typename T2>
void co(pair<T1, T2> p){cout << p.fs << ' ' << p.sc << '\n';}
template <typename T>
void co(const Vec1<T> &v){for(T i : v) cosp(i); co();}
template <typename T>
void co(initializer_list<T> v){for(T i : v) cosp(i); co();}
template <typename T>
void ce(const T n){cerr << n << endl;}
void sonic(){ios::sync_with_stdio(false); cin.tie(0);}
void setp(const ll n){cout << fixed << setprecision(n);}
constexpr int INF = 1e9+1;
constexpr ll LINF = 1e18+1;
constexpr ll MOD = 1e9+7;
// constexpr ll MOD = 998244353;
constexpr ld EPS = 1e-11;
const ld PI = acos(-1);

int main(void){
	ll n;
	cin >> n;
	Vec r(n + 1);
	repn(i, n){
		ll t = i;
		ll cnt = 0;
		while(t){
			cnt += t & 1;
			t >>= 1;
		}
		r[i] = r[i % cnt] + 1;
	}
	// co(r);

	string s;
	cin >> s;
	ll cnt = 0;
	rep(i, n) if (s[i] == '1') cnt++;

	Vec p1(n), p2(n);
	repr(i, n){
		if (cnt == 1 || cnt == 0) break;
		if (i == n - 1) p1[i] = 1 % (cnt - 1);
		else
			p1[i] = p1[i + 1] * 2 % (cnt - 1);
	}

	repr(i, n){
		if (i == n - 1) p2[i] = 1;
		else
			p2[i] = p2[i + 1] * 2 % (cnt + 1);
	}

	ll x1 = 0, x2 = 0;
	rep(i, n){
		x1 <<= 1, x2 <<= 1;
		if (s[i] == '1') x1++, x2++;
		if(cnt != 1 && cnt != 0) x1 %= (cnt - 1);
		x2 %= (cnt + 1);
	}

	rep(i, n){
		if(s[i] == '0'){
			co(r[(x2 + p2[i]) % (cnt + 1)] + 1);
		}else{
			if (cnt == 1) co(0);
			else
				co(r[(x1 - p1[i] + cnt - 1) % (cnt - 1)] + 1);
		}
	}

	return 0;
}


Measured memory_bytes: 8388
#include<bits/stdc++.h>
typedef long long ll;
typedef double ld;

using namespace std;

int main()
{
	ll n, x;
	cin>>n>>x;

	int L[n+1];
	int D[n+1];
	int cnt = 1;
	D[1] = 0;
	for(int i=1;i<=n;i++)
	{
		cin>>L[i];
		D[i+1] = D[i]+L[i];
		if(D[i+1] <= x)
			cnt++;
	}
	
	cout<<cnt<<endl;
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rep1(i, n) for(int i = 1; i <= (n); i++)
#define co(x) cout << (x) << "\n"
#define cosp(x) cout << (x) << " "
#define ce(x) cerr << (x) << "\n"
#define cesp(x) cerr << (x) << " "
#define pb push_back
#define mp make_pair
#define Would
#define you
#define please

void pakuri_sort(int N, int A[]) {
	const int b = 8;
	int tmp[100001];
	rep(k, 4) {
		int kazu[1 << b] = {}, kazu2[1 << b] = {};
		rep(i, N) kazu[A[i] >> k * b & ((1 << b) - 1)]++;
		rep(i, (1 << b) - 1) kazu[i + 1] += kazu[i];
		for (int i = N - 1; i >= 0; i--) tmp[--kazu[A[i] >> k * b & ((1 << b) - 1)]] = A[i];
		k++;
		rep(i, N) kazu2[tmp[i] >> k * b & ((1 << b) - 1)]++;
		rep(i, (1 << b) - 1) kazu2[i + 1] += kazu2[i];
		for (int i = N - 1; i >= 0; i--) A[--kazu2[tmp[i] >> k * b & ((1 << b) - 1)]] = tmp[i];
	}
}

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

	int N, K;
	cin >> N >> K;
	int saidai[100000] = {};
	int shurui = 0;
	int sonota[100001];
	int k = 0;
	rep(i, N) {
		int t, d;
		cin >> t >> d;
		t--;
		if (!saidai[t]) {
			shurui++;
			saidai[t] = d;
		}
		else {
			if (saidai[t] < d) {
				swap(saidai[t], d);
			}
			sonota[k++] = d;
		}
	}

	pakuri_sort(100000, saidai);
	pakuri_sort(k, sonota);

	ll sonota2[100000];
	sonota2[k - 1] = sonota[k - 1];
	for (int i = k - 1; i >= 1; i--) {
		sonota2[i - 1] = sonota2[i] + sonota[i - 1];
	}

	ll kari = 0;
	ll kotae = 0;
	for (int i = 1; i <= min(K, shurui); i++) {
		kari += saidai[100000 - i];
		ll kari2 = kari;
		if (K - i > 0 && 0 <= k - K + i) kari2 += sonota2[k - K + i];
		kari2 += 1ll * i * i;
		kotae = max(kotae, kari2);
	}

	printf("%lld", kotae);

	Would you please return 0;
}

Measured memory_bytes: 2176
#include <stdio.h>
#include <math.h>
struct xy{
	double x;
	double y; 
};
int kock(int n,struct xy,struct xy);
int main(){
	struct xy p1 ={0,0}, p2 ={100,0};
	int n;
	scanf("%d",&n);
	printf("%.8lf %.8lf\n",p1.x,p1.y);
	kock(n,p1,p2);
	printf("%.8lf %.8lf\n",p2.x,p2.y);
	return 0;
}

int kock(int n,struct xy p1,struct xy p2){
	struct xy s,t,u;
	if(n==0) return 0;
	s.x = (2*p1.x+1*p2.x)/3;
	s.y = (2*p1.y+1*p2.y)/3;
	t.x = (1*p1.x+2*p2.x)/3;
	t.y = (1*p1.y+2*p2.y)/3;
	u.x=(t.x-s.x)/2 -(t.y-s.y)*sqrt(3)/2 +s.x;
	u.y=(t.x-s.x)*sqrt(3)/2 +(t.y-s.y)/2 +s.y;
	kock(n-1,p1,s);
	printf("%.8lf %.8lf\n",s.x,s.y);
	kock(n-1,s,u);
	printf("%.8lf %.8lf\n",u.x,u.y);
	kock(n-1,u,t);
	printf("%.8lf %.8lf\n",t.x,t.y);
	kock(n-1,t,p2);
}


Measured memory_bytes: 2104
#include<bits/stdc++.h>
using namespace std;
#define ll long long

ll a[2100],b[2100][2100] = {};

int main()
{
	ll n,x,min1 = 9e18,num,ans = 0;
	cin>>n>>x;
	for (int i = 1;i<=n;i++)
	{
		scanf("%lld",&a[i]);
		if (min1 > a[i])	min1 = a[i],num = i;
		b[0][i] = a[i];
		ans += a[i];
	}
	//cout<<min1<<' '<<num<<'\n';
	for (int t = 1;t<=n-1;t++)
	{
		int i = num,border = num - 1;
		b[t][i] = b[t-1][i];
		ll temp = b[t-1][i];
		if (border == 0) border = n;
		while (i != border)
		{
			i++;
			if (i == n + 1) i = 1;
			if (i - 1 <= 0) b[t][i] = min(b[t - 1][n],b[t-1][i]);
			else b[t][i] = min(b[t-1][i-1],b[t-1][i]);
			temp += b[t][i];
		}
		if (ans > x * t + temp)
		{
			ans = min(ans,x * t +temp);
			/*cout<<t<<'\n';
			for (int i = 1;i<=n;i++) cout<<b[t][i]<<' ';
			cout<<ans<<endl;*/
		}
	}
	cout<<ans;
	
	return 0;
}

Measured memory_bytes: 33024
#include <bits/stdc++.h>
using namespace std;
#pragma GCC optimize("Ofast")
#define rep(i,n) for(int i=0;i<n;i++)
const long long MOD = 1000000007;
const long long INF = MOD*MOD;
typedef pair<int,int> P;
typedef long long ll;
ll n,m,k;
string s,s1,s2;

int main(){
  cin >> n >> k;
  if(500*n >= k) cout << "Yes\n";
  else cout << "No\n";
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstring>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <cstdlib>
#include <queue>
#include <stack>
#include <map>
#include <utility>
#include <set>
#include <climits>

using namespace std;

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

int main() {
    int N;
    scanf ("%d", &N);
    int S = (N & 1) ? N : N + 1;
    vector<pii> result;
    for (int i = 1; i <= N; ++i) {
        for (int j = i + 1; j <= N; ++j) {
            if (i + j == S) {
                continue;
            }
            result.push_back(make_pair(i, j));
        }
    }
    int result_count = result.size();
    printf("%d\n", result_count);
    for (int i = 0; i < result_count; ++i) {
        printf("%d %d\n", result[i].first, result[i].second);
    }
    return 0;
}



Measured memory_bytes: 384
#include <iostream>
#include <fstream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <cstring>
#include <string>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <deque>
#include <bitset>
#include <algorithm>
#include <complex>
using namespace std;
 
#define REP(i,n) for(int i=0; i<n; ++i)
#define FOR(i,a,b) for(int i=a; i<=b; ++i)
#define FORR(i,a,b) for (int i=a; i>=b; --i)
#define ALL(c) (c).begin(), (c).end()
 
typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<VI> VVI;
typedef vector<VL> VVL;
typedef pair<int,int> P;
typedef pair<ll,ll> PL;

int in() { int x; scanf("%d", &x); return x; }
ll lin() { ll x; scanf("%lld", &x); return x; }

int main() {
    int n = 5;
    VI a(n);
    REP(i,n) a[i] = in();
    int k = in();
    sort(ALL(a));
    cout << (a[n - 1] - a[0] <= k ? "Yay!" : ":(") << endl;
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
using namespace std;
int n,x;
int main(){
    cin>>n;
    if(n%1000==0){ 
        cout<<0<<endl;
        return 0;
    }
    else{ 
        x=n%1000;
    }
    cout<<1000-x<<endl;
    return 0;
}

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

typedef long long int ll;
ll MOD = 1000000007;
ll INFL = 1ll << 60;
ll INF = 1 << 28;

// ====================================================================

int main() {
  ll h, w;
  cin >> h >> w;
  if (h == 1 || w == 1) {
    cout << 1 << endl;
    return 0;
  }
  cout << (h * w + 1) / 2ll << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
constexpr ll INF = 1'010'000'000'000'000'017LL;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(v) v.begin(), v.end()

int gcdd(int a, int b) {
    if(a < b)
        swap(a, b);

    if(a % b == 0)
        return b;
    return gcdd(a % b, b);
}

int main() {
    // Atcoder
    // template: cpp
    ll n, x;
    cin >> n >> x;
    vector<ll> y(n);
    rep(i, n) cin >> y[i];

    rep(i, n) { y[i] = abs(y[i] - x); }
    ll res = y[0];

    for(size_t i = 1; i < n; i++) {
        res = gcdd(res, y[i]);
    }
    cout << res;
}

Measured memory_bytes: 1024
#include <iostream>

using namespace std;

int main()
{
    char d[] = {
        'U', 'R', 'D', 'L', 'L', 'U', 'R', 'D', 'R', 'D', 'L', 'U', // tx > sx && ty > sy
    };
    int sx, sy, tx, ty;
    cin >> sx >> sy >> tx >> ty;

    int c1 = ty - sy;
    int c2 = tx - sx;
    for (int i = 0; i < c1; ++i) {
        cout << d[0];
    }
    for (int i = 0; i < c2; ++i) {
        cout << d[1];
    }
    for (int i = 0; i < c1; ++i) {
        cout << d[2];
    }
    for (int i = 0; i < c2; ++i) {
        cout << d[3];
    }
    cout << d[4];
    for (int i = 0; i < c1+1; ++i) {
        cout << d[5];
    }
    for (int i = 0; i < c2+1; ++i) {
        cout << d[6];
    }
    cout << d[7];
    cout << d[8];
    for (int i = 0; i < c1+1; ++i) {
        cout << d[9];
    }
    for (int i = 0; i < c2+1; ++i) {
        cout << d[10];
    }
    cout << d[11] << endl;

    return 0;
}


Measured memory_bytes: 256
#include <string>
#include <vector>
#include <sstream>
#include <iostream>
#include <algorithm>
#include <map>
#include <list>
#include <set>
#include <numeric>
#include <queue>
#include <stack>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <cstring>
#include <climits>
#include <cfloat>
#include <ctime>
#include <complex>
#include <cassert>
#include <array>
#include <bitset> 
#include <unordered_map>
using namespace std;
typedef long long LL;
typedef pair<LL,LL> P;


LL solve(long long H){
	if(H==1){
		return 1;
	}
	return 2*solve(H/2)+1;
}

int main(){
    long long H;
    scanf("%lld",&H);
    cout << solve(H) << endl;
    return 0;
}


Measured memory_bytes: 256
def binarySearch(array,search,left,right):
    mid = int(left + (right - left)//2)
    while right - left > 1:
        if array[mid] <= search:
            left = mid
            mid = int(left + (right - left)//2)
        else:
            right = mid
            mid = int(left + (right - left)//2)
    if array[mid] == search: return mid
    else: return -1

n = int(input())
s = list(map(int,input().split()))
q = int(input())
t = list(map(int,input().split()))
count = 0

for t_tmp in t:
    bs = binarySearch(s,t_tmp,0,len(s))
    if bs != -1:
        count += 1

print(count)

Measured memory_bytes: 18700
#abc160e
x,y,a,b,c=map(int,raw_input().split())
p=map(int,raw_input().split())
q=map(int,raw_input().split())
r=map(int,raw_input().split())
p.sort(reverse=True)
q.sort(reverse=True)
z=p[:x]+q[:y]+r
z.sort(reverse=True)
print sum(z[:x+y])


Measured memory_bytes: 17708
#include <bits/stdc++.h>
#define rep(i, a, n) for(int i = a; i < n; i++)
#define int long long
using namespace std;
typedef pair<int, int> P;
const int mod = 1000000007;
const int INF = 1e18;

struct edge{
   int to, c, id;
};

int n;
vector<edge> G[100010];
int deg[100010];
P es[100010];
map<P, int> mp;

void dfs(int v, int p){
    int used = mp[{v, p}];
    int now = 1;
    for(auto i : G[v]){
        if(i.to == p) continue;
        if(now == used) now++;
        mp[{v, i.to}] = now;
        mp[{i.to, v}] = now;
        dfs(i.to, v);
        now++;
    }
}

signed main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cin >> n;
    rep(i, 0, n - 1){
        int a, b;
        cin >> a >> b;
        a--; b--;
        deg[a]++;
        deg[b]++;
        es[i] = {a, b};
        G[a].push_back({b, -1, i});
        G[b].push_back({a, -1, i});
    }
    int k = 0, idx = -1;
    rep(i, 0, n){
        if(k < deg[i]){
            k = deg[i];
            idx = i;
        }
    }
    cout << k << endl;
    mp[{idx, -1}] = -1;
    mp[{-1, idx}] = -1;
    dfs(idx, -1);
    rep(i, 0, n - 1){
        cout << mp[es[i]] << endl;
    }
}

Measured memory_bytes: 24576
#include <bits/stdc++.h>
using namespace std;
#define e1 first
#define e2 second
#define pb push_back
#define mp make_pair
#define boost ios_base::sync_with_stdio(false)
#define eb emplace_back
#define OUT(x) {cout << x; exit(0); }
#define FOR(i,a,b) for(int i=(a);i<=(b);++i)
#define scanf(...) scanf(__VA_ARGS__)?:0
typedef long long int ll;
typedef unsigned long long ull;
typedef pair <int, int> PII;
typedef pair <ll, ll> PLL;
typedef pair <PLL, int> PLLI;
typedef pair <PLL, PLL> PP;
typedef pair <PII, int> PPI;
typedef pair <ll, int> PLI;
typedef unsigned int ui;
const int mod = 998244353;
const int inf = 1e9+9;
const ll MOD = 1e9+696969;
const long long INF = 1e18+3;

inline ll det(PII a, PII b) {
	return (ll)a.e1 * b.e2 - (ll)a.e2 * b.e1;
}
inline bool isLine(PII a, PII b, PII c) {
	return (det(a, b) + det(b, c) + det(c, a) == 0);
}

inline void submod(ll &x, int val) {
	x -= val;
	while (x < 0) x += mod;
}

const int maxn = 210;
int n;
bool bylo[maxn][maxn];
PII tab[maxn];
ll pot[maxn];
vector <int> vec;

ll fun(ll sz) {
	ll ile = pot[sz];
	submod(ile, 1);
	submod(ile, sz);
	submod(ile, sz * (sz - 1) / 2);
	return ile;
}

int main()
{
	boost;
	cin >> n;
	if (n <= 2) OUT(0);
	pot[0] = 1;
	FOR(i, 1, n) pot[i] = (pot[i-1] * 2)%mod;
	FOR(i, 1, n) cin >> tab[i].e1 >> tab[i].e2;
	ll res = pot[n];
	submod(res, 1);
	submod(res, n);
	submod(res, n * (n - 1) /2);
	
	FOR(i, 1, n)
		FOR(j, i + 1, n)
		{
			if (bylo[i][j]) continue;
			vec.clear();
			vec.pb(i); vec.pb(j);
			FOR(k, 1, n)
				if (k != i && k != j && isLine(tab[i], tab[j], tab[k])) vec.pb(k);
			
			for (auto u : vec)
				for (auto v : vec) bylo[u][v] = 1;
				
			int sz = (int)vec.size();
			if (sz <= 2) continue;
			submod(res, fun(sz));
		}
		
	cout << res;
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i=0;i<(int)(n);i++)
#define all(x)    (x).begin(),(x).end()
typedef long long ll;
const int MOD = (int)1e9 + 7;

int main(){
  int n,a,b;
  cin>>n>>a>>b;
  cout<<min(b,n*a)<<endl;
}



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

using namespace std;
typedef long long ll;

const int N = 1e5 + 10 , OO = 0x3F3F3F3F;


int a, b ,c;


int main()
{
    
    
    cin >> a >> b >> c;
    int ans = a + b + c;
    if(ans >= 22)
        cout << "bust\n";
    else 
        cout << "win\n";
    
    
    
    
    
    
    return 0;
}


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

using namespace std;

 bool even(string s){

  int len = s.size();

  for(int i=0;i<len/2;i++){
     if(s[i] != s[i+len/2]){
        return false;
          }
  }

  return true;
 }

int main(){

 string s;
 cin>>s;
 int len = s.size(),dec=2,ans;

 while(s.size() >= 2){

     s = s.substr(0,len-dec);

    if(even(s)){
    ans = s.size();

    break; }
   dec += 2;
 }

 cout<<ans<<endl;

 return 0;
 }


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


#define rep2(x,fr,to) for(int (x)=(fr);(x)<(to);(x)++)
#define rep(x,to) for(int (x)=0;(x)<(to);(x)++)
#define repr(x,fr,to) for(int (x)=(fr);(x)>=(to);(x)--)
#define all(c) (c).begin(),(c).end()
#define sz(v) (int)(v).size()

using namespace std;
typedef long long ll; typedef vector<int> VI; typedef pair<int,int> pii;
const int MD = (int)1e9 + 7; typedef vector<ll> VL;
void dbg(){ cerr << "\n"; }  template <class T, class ...T2>
void dbg(const T& fst, const T2&...rst){ cerr << fst << ": "; dbg(rst...); }
template <class T, class T2> void amin(T& a,T2 b){ if(a > b) a = b;}

int main()
{
	cin.tie(0); ios_base::sync_with_stdio(false);
	int n; ll a, b;
	cin >>n >> a >>b;
	VL h(n);
	rep(i, n) cin >>h[i];
	
	
	auto ck=[&](ll md){
		ll df = a - b,  zz = 0;
		rep(i, n){
			zz += max(0LL, (h[i] - (b*md) + df-1)/ df);
			if(zz > md) return false;
		}
		return zz <= md;
	};
	
	ll xc = *max_element(all(h));
	ll rg = (xc + b-1)/ b;
	ll lf = 0;
	while(rg - lf >1){
		ll md = (rg + lf) >> 1;
		if( ck(md) ) rg = md; else lf = md; 
	}
	cout << rg <<"\n";
	
	
	return 0;
}


Measured memory_bytes: 1024
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
using namespace std;
typedef long long ll;

int main() {
	int n;
	cin >> n;
	string s;
	cin >> s;
	if (n >= 3200) cout << s << endl;
	else cout << "red" << endl;
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<vector>
#include<map>
#include<algorithm>
using namespace std;
int main(){

  int N;
  cin>>N;
  int max=0;
  vector<string>S(N);
  map<string,int>data; 
  for(int i=0;i<=N-1;i++){
  
    cin>>S[i];
    data[S[i]]++;
    if(data[S[i]]>max){
    
      max=data[S[i]];
    }
  }
  vector<string>ans(1);
  int count=0;
  for(auto i=data.begin();i!=data.end();i++){
  
    if(i->second==max){
  
      ans[count]=i->first;
      count++;
      i->second=0;
    }
  }
  sort(ans.begin(),ans.end());
  for(int i=0;i<=count-1;i++){
  
    cout<<ans[i]<<endl;
  }
  return 0;
}

Measured memory_bytes: 31492
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0, i##_len = (n); i < i##_len; ++i)
#define rep2(i, x, n) for(int i = x, i##_len = (n); i < i##_len; ++i)
#define all(n) begin(n), end(n)
using ll = long long;
using P = pair<int, int>;
using vi = vector<int>;
using vl = vector<ll>;
using vs = vector<string>;
using vc = vector<char>;
using vb = vector<bool>;
using vd = vector<double>;
vi dir = {-1, 0, 1, 0, -1, -1, 1, 1, -1};

int main() {
  int ans = 0;
  rep(i, 4) {
    char c;
    cin >> c;
    if(c == '+')
      ans++;
    else
      ans--;
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
import itertools
import copy

S = list(input())

answer = 0
length = len(S)
for pattern in itertools.product((True, False), repeat=length-1):
    S2 = S[:]
    for i in range(length-1):
        if pattern[i]:
            S2.insert(length-i-1, '+')
    answer += eval(''.join(S2))

print(answer)

Measured memory_bytes: 3568
#include <bits/stdc++.h>
using namespace std;
typedef long long lnt;
#define REP(i, n) for (lnt i = 0; i < (n); i++)
#define FOR(i, a, b) for (lnt i = (a); i < (b); i++)
#define ALL(a) a.begin(), a.end()
#define MAXELM max_element
#define MINELM min_element
#define BIT(i) POW(2, i)
#define INF 2e18 // cf. LLONG_MAX ≒ 9x10^18
#define START int main
#define SET unordered_set
#define MAP unordered_map
#define CNT (lnt) count
#define SZ (lnt) size
#define DIST (lnt) distance
#define ABS abs<lnt>
#define MAX max<lnt>
#define MIN min<lnt>
#define F first
#define S second
#define LB lower_bound
#define UB upper_bound
#define PB push_back

lnt POW(const lnt x, const int y) {
  lnt init = 1;
  for (int i = 0; i < y; i++) {
    init *= x;
  }
  return init;
}

START() {
  lnt n;
  cin >> n;
  vector<lnt> x, y, h;
  REP(i, n) {
    lnt a, b, c;
    cin >> a >> b >> c;
    x.PB(a);
    y.PB(b);
    h.PB(c);
  }

  REP(cx, 101) {
    bool fOKx = false;
    REP(cy, 101) {
      lnt ch;
      REP(i, n) {
        if (h[i]) {
          ch = h[i] + abs(x[i] - cx) + abs(y[i] - cy);
          break;
        }
      }

      bool fOKy = true;
      REP(i, n) {
        if (h[i] != MAX(0, ch - ABS(x[i] - cx) - ABS(y[i] - cy))) {
          fOKy = false;
          break;
        }
      }
      if (fOKy) {
        cout << cx << " " << cy << " " << ch << endl;
        break;
        fOKx = true;
      }
    }
    if (fOKx) {
      break;
    }
  }
}


Measured memory_bytes: 256
n = int(input())
s = [input() for _ in range(n)]
from collections import Counter
c = Counter(s)

if 'AC' in c.keys():
    print('AC x', c['AC'])
else:
    print('AC x 0')
if 'WA' in c.keys():
    print('WA x', c['WA'])
else:
    print('WA x 0')
if 'TLE' in c.keys():
    print('TLE x', c['TLE'])
else:
    print('TLE x 0')
if 'RE' in c.keys():
    print('RE x', c['RE'])
else:
    print('RE x 0')


Measured memory_bytes: 79512
#include <bits/stdc++.h>
#include <climits>
#define rep(i, begin, end) for (__typeof(end) i = (begin) - ((begin) > (end)); i != (end) - ((begin) > (end)); i += 1 - 2 * ((begin) > (end)))
#define srep(i, begin, end) for (__typeof(end) i = begin; i != end; i++)
#define si(x) int x = scanInt();
#define sll(x) LL x = scanLong();
#define sci(x) int x; scanf("%d", &x);
#define scll(x) LL x; scanf("%lld", &x);
#define pi(x) printf("%d ", x)
#define pll(x) printf("%lld ", x)
#define nl printf("\n")
#define clr(a) memset(a, 0, sizeof(a))
#define PB push_back
#define MP make_pair
using namespace std;
typedef unsigned int UI; // 32 bit integer
typedef long int LI; // 32 bit integer
typedef unsigned long int ULI; // 32 bit unsigned integer
typedef long long int LL; // 64 bit integer
typedef unsigned long long int ULL; // 64 bit unsigned integer
typedef long double LD;
typedef vector<int> VI;
typedef vector<LL> VLL;
typedef deque<int> DI;
typedef deque<LL> DLL;
typedef pair<int, int> PII;
typedef pair<LL, LL> PLL;
const LL MOD = 1e9+7;

/* Fast I/O */
inline int scanInt() {
	int n = 0;
	char ch = getchar();
	int sign = 1;
	while(ch < '0' || ch > '9') {
		if(ch == '-')	sign = -1;
		ch = getchar();
	}
	while(ch >= '0' && ch <= '9') {
		n = (n<<1)+(n<<3)+(int)(ch-'0');
		ch = getchar();
	}
	return n*sign;
}

inline LL scanLong() {
	LL n = 0;
	char ch = getchar();
	LL sign = 1;
	while(ch < '0' || ch > '9') {
		if(ch == '-')	sign = -1;
		ch = getchar();
	}
	while(ch >= '0' && ch <= '9') {
		n = (n<<1)+(n<<3)+(LL)(ch-'0');
		ch = getchar();
	}
	return n*sign;
}

int main() {
	sll(a); sll(b);
	pll(a*b); nl;
}


Measured memory_bytes: 3764
import sys
input = sys.stdin.readline
INF = 1001001001001001
def main():
    n = int(input())
    p = [0] * (n+1)
    for i in range(n):
        p[i], p[i+1] = map(int, input().split())
    dp = [[INF]*(n+1) for _ in range(n+1)]
    for i in range(n+1):
        dp[i][i] = 0
    for l in range(2, n+1):
        for i in range(n-l+2):
            j = i + l - 1
            for k in range(i, j):
                dp[i][j] = min(dp[i][j], dp[i][k]+dp[k+1][j]+p[i-1]*p[k]*p[j])
    print(dp[1][n])
if __name__ == '__main__': main()


Measured memory_bytes: 5684
#include <stdio.h>
#include <math.h>

long modpow(long a, long n, long mod){
  long size;
  for (long i = 1; ; i++) {
    if (pow(2,i) > n) {
      size = i;
      break;
    }
  }
  long bit[size];
  bit[0] = n;
  for (long i = 1; i < size; i++) {
    bit[i] = bit[i-1]/2;
    bit[i-1] %= 2;
  }
  long powa[size];
  powa[0] = a;
  for (long i = 1; i < size; i++) {
    powa[i] = powa[i-1]*powa[i-1];
    powa[i] %= mod;
  }
  long answer = 1;
  for (long i = 0; i < size; i++) {
    if (bit[i] == 1) {
      answer *= bit[i]*powa[i];
      answer %= mod;
    }
  }
  return answer;
}

long Combination(long n, long r, long mod) {
  long answer;
  if (n-r < r) {
    r = n-r;
  }
  long nu = 1;
  long de = 1;
  for (long i = 1; i <= r; i++) {
    nu *= n+1-i;
    nu %= mod;
    de *= i;
    de %= mod;
  }
  answer = nu;
  answer *= modpow(de,mod-2,mod);
  answer %= mod;
  return answer;
}

int main(void) {

  long n,a,b;
  scanf("%ld %ld %ld", &n, &a, &b);
  long mod = pow(10,9)+7;
  long all = modpow(2,n,mod);
  long minus = Combination(n,a,mod)+Combination(n,b,mod)+1;
  minus %= mod;
  long answer = all+mod-minus;
  answer %= mod;
  printf("%ld\n", answer);

  return 0;
}

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

int main(){
  int N;
  cin >> N;
  vector<double> x(N);
  vector<string> u(N);
  for(int i=0;i<N;i++){
    cin >> x.at(i);
    cin >> u.at(i);
  }
  double P=0;
  double S=0;
  for(int i=0;i<N;i++){
    if(u.at(i) == "JPY"){
      P += x.at(i);
    }
    else if(u.at(i) == "BTC"){
      S += x.at(i)*380000;
    }
  }
  cout << P+S;
}


Measured memory_bytes: 256
A,B,C = (int(i) for i in input().split())

ans = 0

max_num = max(A,B,C)

ans += (max_num - A)//2
ans += (max_num - B)//2
ans += (max_num - C)//2

A = A + ((max_num - A)//2) * 2 - max_num
B = B + ((max_num - B)//2) * 2 - max_num
C = C + ((max_num - C)//2) * 2 - max_num

nums = [A,B,C]
if A==B and B==C:
  print(ans)
elif nums.count(-1) == 2:
  print(ans+1)
else:
  print(ans+2)


Measured memory_bytes: 3064
#include<stdio.h>
int main(void)
{
  int i,a;
  char str[3];
  a=0;
  scanf("%s",str);
  for (i=0;i<3;i++){
    if(str[i]=='1'){
      a++;
    }
  }
  printf("%d\n",a);
  return 0;
}

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

using namespace std;

#define gc c=getchar()
#define r(x) read(x)

#define For(i, a, b) for (i = a; i <= b; i++)
#define Step(i, a, b, x) for (i = a; i <= b; i += x)

template<typename T>
inline void read(T&x){
    x=0;T k=1;char gc;
    while(!isdigit(c)){if(c=='-')k=-1;gc;}
    while(isdigit(c)){x=x*10+c-'0';gc;}x*=k;
}

const int p=998244353;

map<string,int>F;
map<string,int>G;

int f(string s);

int g(string s){
	if(G[s])return G[s];
	int &ans=G[s],n=s.size();
	if(n==1)return ans=s[0]-'0'+1;
	for(int i=1;i<n;++i){
		if(n%i)continue;
		string t="";
		for(int j=0;j<i;++j){
			int c=1;
			for(int k=j;k<n;k+=i)c&=s[k]-'0';
			t+=char(c+'0');
		}
		ans=(ans+f(t))%p;
	}
	return ans;
}

int f(string s){
	if(F[s])return F[s];
	int &ans=F[s],n=s.size();
	if(!n)return ans=1;
	for(int i=1;i<=n;++i)ans=(ans+(long long)g(s.substr(0,i))*f(s.substr(i,n)))%p;
	return ans;
}

string s;

int main(){
	cin>>s;
	cout<<f(s);
	return 0;
}


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

#define Solved int main()
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define SpeedForce ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0)
#define forn(i, n) for(int i = 1; i <= n; i++)
#define rep(i, x, y) for(int i = x; i <= y; i++)
#define sz(x) (int)x.size()
#define pii pair<int, int>
#define ll long long
#define ull unsigned long long
#define ld long double
#define mii map<int, int>
#define all(x) x.begin(), x.end()
using namespace std;

inline ll bip(ll x,ll n,ll mod){ll res=1;while(n){if(n&1){res=(res*x)%mod;}x=(x*x)%mod;n>>=1;}return res;}

const int maxn = 1e9;
const ll inf = 1e18;
const int mod = 998244353;
//const int mod = 1e9 + 7;
const int N = 1e5 + 10;

int n;
ll a[N];
ll dp[N];

void solve() {
    cin >> n;

    for (int i = 1; i <= n; i++)
        cin >> a[i];

    dp[2] = abs(a[2] - a[1]);
    for (int i = 3; i <= n; i++) {
        dp[i] = min(dp[i - 1] + abs(a[i] - a[i - 1]), dp[i - 2] + abs(a[i] - a[i - 2]));
    }
    cout << dp[n];
}

Solved {
    SpeedForce;
	int tt = 1;
    //cin >> tt;
	while (tt--) {
		solve();
		cout << '\n';
	}

}


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

#define mp make_pair
#define mt make_tuple
#define fi first
#define se second
#define pb push_back
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define forn(i, n) for (int i = 0; i < (int)(n); ++i)
#define for1(i, n) for (int i = 1; i <= (int)(n); ++i)
#define ford(i, n) for (int i = (int)(n) - 1; i >= 0; --i)
#define fore(i, a, b) for (int i = (int)(a); i <= (int)(b); ++i)

using namespace std;

typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<pii> vpi;
typedef vector<vi> vvi;
typedef long long i64;
typedef vector<i64> vi64;
typedef vector<vi64> vvi64;
typedef pair<i64, i64> pi64;
typedef double ld;

template<class T> bool uin(T &a, T b) { return a > b ? (a = b, true) : false; }
template<class T> bool uax(T &a, T b) { return a < b ? (a = b, true) : false; }

map<i64, i64> memo;
i64 a, b, c, d;

i64 dp(i64 n) {
//    if (n < 0) return 1e18;
    if (n == 0) return 0;
    if (memo.count(n)) return memo[n];
    i64 &res = memo[n];
    res = 1e18;
    if (abs(n) < 2e9) res = abs(n) * d;
    fore(delta, -4, 4) {
        i64 x = n + delta;
        if (x % 2 == 0) uin(res, dp(x / 2) + a + abs(delta) * d);
        if (x % 3 == 0) uin(res, dp(x / 3) + b + abs(delta) * d);
        if (x % 5 == 0) uin(res, dp(x / 5) + c + abs(delta) * d);
    }
    return memo[n] = res;
}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.precision(10);
    cout << fixed;
#ifdef LOCAL_DEFINE
    freopen("input.txt", "rt", stdin);
#endif

    int T;
    cin >> T;
    while (T--) {
        i64 n;
        cin >> n >> a >> b >> c >> d;
        memo.clear();
        cout << dp(n) << '\n';
    }

#ifdef LOCAL_DEFINE
    cerr << "Time elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " s.\n";
#endif
    return 0;
}


Measured memory_bytes: 6512
def solve():
    N = int(input())
    T, A = map(int, input().split())
    Hlist = list(map(int, input().split()))

    templist = []

    for i in range(N):
        templist.append(abs((T-Hlist[i]*0.006)-A))

    print(templist.index(min(templist))+1)


if __name__ == "__main__":
    solve()


Measured memory_bytes: 38384
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <stdint.h> // uint64_t

#define max(a,b) ((a) > (b) ? (a) : (b))
#define min(a,b) ((a) > (b) ? (b) : (a))

int get_int(void) {
  int num;
  scanf("%d", &num);
  return num;
}

int get_int2(int *a1, int *a2) {
  scanf("%d %d", a1, a2);
  return 0;
}

#define M_MAX 17
#define NUM_MAX (2<<M_MAX)

int main(void) {
    int m, k;
    get_int2(&m, &k);
    if(m == 1) {
        if(k == 0) {
            printf("0 0 1 1\n");
            return 0;
        }
        goto impossible;
    }
    int ulimit = (1<<m);
    if(k >= ulimit) goto impossible;

    static int ans[NUM_MAX];
    int idx = 0;
    ans[idx++] = k;
    int i;
    for(i = 0; i < ulimit; i++) {
        if(i == k) continue;
        ans[idx++] = i;
    }
    ans[idx++] = k;
    for(i = ulimit-1; i >= 0; i--) {
        if(i == k) continue;
        ans[idx++] = i;
    }

    for(i = 0; i < idx; i++) {
        printf("%d%c", ans[i], (i == idx-1) ? '\n' : ' ');
    } 
    return 0;


impossible:
    printf("-1\n");
    return 0;
}

Measured memory_bytes: 2816
#include <bits/stdc++.h>
using namespace std;
struct Node {int l, r, x;};
int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int n, l;
    cin >> n >> l;
    vector<int> a(n);
    for (int i = 0; i < n; ++i)
        cin >> a[i];
    struct Node {
        int pre, nxt, val, l, r;
        bool isNew;
    };
    vector<Node> t(n);
    vector<pair<int, int>> s;
    for (int i = 0; i < n; ++i) {
        t[i].pre = i - 1;
        t[i].nxt = i == n - 1 ? -1 : i + 1;
        t[i].l = t[i].r = 1;
        t[i].val = a[i];
        t[i].isNew = false;
        s.emplace_back(a[i], i);
    }
    sort(s.begin(), s.end(), greater<pair<int, int>>());
    long long ans = 0;
    auto connect = [&](int l, int r) {
        if (l != -1)
            t[l].nxt = r;
        if (r != -1)
            t[r].pre = l;
    };
    while (!s.empty()) {
        int x = s.back().first;
        vector<int> v, v1;
        while (!s.empty() && s.back().first == x) {
            int p = s.back().second;
            if (t[p].pre == -1 || t[t[p].pre].val != x)
                v.push_back(p);
            if ((t[p].pre == -1 || t[t[p].pre].val != x || !t[t[p].pre].isNew) && t[p].isNew)
                v1.push_back(p);
            s.pop_back();
        }
        for (int p : v1) {
            vector<int> ver;
            for (int i = p; ; i = t[i].nxt) {
                if (i == -1 || t[i].val != x || !t[i].isNew)
                    break;
                ver.push_back(i);
            }
            int sum = 0;
            for (int i = l - 1; i < (int)ver.size(); ++i) {
                sum += t[ver[i - l + 1]].l;
                ans -= 1LL * sum * t[ver[i]].r;
            }
        }
        for (int p : v) {
            vector<int> ver;
            for (int i = p; ; i = t[i].nxt) {
                if (i == -1 || t[i].val != x)
                    break;
                ver.push_back(i);
            }
            if ((int)ver.size() < l) {
                connect(t[p].pre, -1);
                connect(-1, t[ver.back()].nxt);
                continue;
            }
            int sum = 0;
            for (int i = l - 1; i < (int)ver.size(); ++i) {
                sum += t[ver[i - l + 1]].l;
                ans += 1LL * sum * t[ver[i]].r;
            }
            int cnt = ver.size() / l;
            vector<int> newL(cnt), newR(cnt);
            for (int i = l - 1; i < (int)ver.size(); ++i) {
                newL[cnt - (i - l + 1) / l - 1] += t[ver[ver.size() - i - 1]].l;
                newR[(i - l + 1) / l] += t[ver[i]].r;
            }
            int lst = t[p].pre;
            for (int i = 0; i < cnt; ++i) {
                ++t[ver[i]].val;
                t[ver[i]].isNew = true;
                t[ver[i]].l = newL[i];
                t[ver[i]].r = newR[i];
                connect(lst, ver[i]);
                s.emplace_back(t[ver[i]].val, ver[i]);
                lst = ver[i];
            }
            connect(lst, t[ver.back()].nxt);
        }
    }
    cout << ans + n << endl;
    return 0;
}

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

int n, m;
const int MAX_N = 100;
int d[MAX_N + 1];
int sum = 0;

int main() {
  cin >> n >> m;

  for (int i = 0; i < n; i++) {
    cin >> d[i];
    sum += d[i];
  }

  sort(d, d + n, greater<int>());

  if (d[m - 1] >= sum / (4.0 * m)) {
    printf("Yes");
  } else {
    printf("No");
  }

  return 0;
}

Measured memory_bytes: 256