akhauriyash/Code-Regression huggingface dataset:
#include <cstdio>
#include <cstdlib>
#include <iostream>
#include <string>
#include <cmath>
#include <algorithm>
#include <vector>
#include <queue>
#include <stack>
#include <map>
#include <set>


using namespace std;
typedef long long ll;

#define mod 1000000007
#define INF 2000000000
#define LLINF 4000000000000000000
#define SIZE 100


void calc(int w,int h){
    int dp[4][110][110]={0}; //0?????????,1?????????,2?????????,3?????????
    
    dp[2][1][1] = 1;
    dp[3][1][1] = 1;

    
    for(int i=1;i<=w;i++){
        for(int j=1;j<=h;j++){
            dp[0][i][j+1] += dp[2][i][j] + dp[0][i][j]; //up
            dp[1][i+1][j] += dp[3][i][j] + dp[1][i][j]; //right
            dp[2][i][j+1] += dp[1][i][j]; //right-up
            dp[3][i+1][j] += dp[0][i][j]; //up-right
            
            for(int k=0;k<4;k++)
                dp[k][i+(k%2)][j+((k+1)%2)]%=100000;
        }
    }
    
    
    printf("%d\n",(dp[0][w][h]+dp[1][w][h]+dp[2][w][h]+dp[3][w][h])%100000);
    
    return;
}

int main(){
    int w,h;
    
    while(1){
        scanf("%d%d",&w,&h);
        if(w==0) break;
        calc(w,h);
    }
    
    return 0;
}

Measured memory_bytes: 1384
#include<stdio.h>
#include<string.h>
int main (){
	char S[10];
	scanf("%s",S);
	char weather[4][10]={"Sunny","Cloudy","Rainy","Sunny"};
	int i;
	for (i=0;i<4;i++){
		if (S[0]==weather[i][0]){
			printf("%s",weather[i+1]);
		}
	}
	return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(n);++i)
#define rrep(i,n) for(int i=1;i<(n);++i)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define maxs(a, b) a = max(a, b)
#define mins(a, b) a = min(a, b)
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
const ll linf = (1ll << 61);
const int inf = 1001001001;
const int mod = 1000000007;

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	int n, m;
	cin >> n >> m;
	vector<int> h(n);
	rep(i, n) cin >> h[i];
	vector<vector<int>> g(n);
	rep(i, m) {
		int a, b;
		cin >> a >> b;
		a--; b--;
		g[a].push_back(b);
		g[b].push_back(a);
	}
	int ans = 0;
	rep(i, n) {
		bool ok = true;
		for (int c : g[i]) if (h[i] <= h[c]) ok = false;
		if (ok) ans++;
	}
	cout << ans << endl;
	return 0;
}

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

int main() {
  int a, b, c, d;
  cin >> a >> b >> c >> d;
  if ((a+b) > (c+d)) {
    cout << "Left" << endl;
  }else if ((a+b) == (c+d)) {
    cout << "Balanced" << endl;
  }else{
    cout << "Right" << endl;
  }
}

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

signed main(){
    //cout << setprecision(16) ;
    ios::sync_with_stdio(false);
	cin.tie(0);

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

    k = min(k,15);

    string s;
    cin>>s;

    char c='z';
    for(int i=0;i<n;i++) c = min(c,s[i]);
    reverse(s.begin(),s.end());

    while(k--){
        string rev = s;
        reverse(rev.begin(),rev.end());
        s = rev + s;
        vector<string> v;
        //cerr<<s<<endl;
        if(k){
            for(int i=n-1;i<n*2;i++){
                if(s[i] == c){
                    string t = s.substr(i-n+1, n);
                    reverse(t.begin(),t.end());
                    v.push_back(t);
                }
            }
            sort(v.begin(),v.end());
            s=v[0];
        }
        else{
            for(int i=0;i<=n;i++){
                if(s[i] == c){
                    string t = s.substr(i, n); 
                    v.push_back(t);
                    //cerr<<t<<endl;
                }
            }
            sort(v.begin(),v.end());
            s = v[0];
        }
    }
    cout<<s<<endl;

}

Measured memory_bytes: 40260
n = int(input())
a = [int(i) for i in input().split()]

a_dict = {}
for v in a:
    if v in a_dict:
        a_dict[v] += 1
    else:
        a_dict[v] = 1

can = True
if n % 2 == 0:
    possible_list = {i: True for i in range(1, n, 2)}
    for k, v in a_dict.items():
        if v != 2 or k not in possible_list:
            can = False
            break
else:
    possible_list = {i: True for i in range(0, n, 2)}
    if 0 not in a_dict:
        can = False
    elif a_dict[0] != 1:
        can = False
    else:
        a_dict[0] = 2
        for k, v in a_dict.items():
            if v != 2 or k not in possible_list:
                can = False
                break

if can:
    print(2 ** (n // 2) % (10 ** 9 + 7))
else:
    print(0)


Measured memory_bytes: 17888
#include <bits/stdc++.h>
using namespace std;
#define ios ios_base::sync_with_stdio(false);cin.tie(0);
#define setnow clock_t tStart=clock();
#define time (double)(clock() - tStart)/CLOCKS_PER_SEC;
#define setin(x) ifstream cin(x);
#define setout(x) ofstream cout(x);
typedef long long ll;
typedef long long int lli;
typedef pair < int, int> dbl;
const int maxInt = 1e9*2;
const lli maxLong = 1e18*2;
int v[10];
int n,m ;
int adj[100][100];
int ans = 0;

bool valid(int k){
    bool vv = true;
    for(int i = 1; i < k; i++)
        if(v[i] == v[k])
            vv = false;
    return vv;
}

void check(int k){
    //for(int i = 1; i <= n; i++)
    //        cout  << v[i] << ' ';
    //cout << endl;
    if(v[1] != 1)
            return;
    for(int i = 2; i <= n; i++)
        if(!adj[v[i - 1]][v[i]])
            return;
    ans++;
}


void backt(int k){
    for(int i = 1; i <= n; i++){
        v[k] = i;
        if(valid(k)){
                if(k == n)
                        check(k);
                backt(k+1);
        }
    }
}

int main(){
        cin >> n >> m;
        for(int i = 0; i < m; i++){
                int a, b;
                cin >> a >> b;
                adj[a][b] = 1;
                adj[b][a] = 1;
        }
        backt(1);
        cout << ans;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main() {
  #define int long long
  int X,Y,A,B,C,D;
  
  cin >> X >> Y;
  if(X>Y){
    cout << "safe" << endl;
  }else{
    cout << "unsafe" << endl;
  }
  
}






Measured memory_bytes: 3636
N, D = map(int, input().split())
X = []
for i in range(N):
    X.append(list(map(int, input().split())))

ans = 0

for i in range(N):
    for j in range(i + 1, N):
        sm = 0
        temp = 0
        for k in range(D):
            sm += (X[i][k] - X[j][k]) ** 2
        temp = sm ** 0.5
        if temp // 1 == temp:
            ans += 1
print(ans)


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

int main(){
	int a;
	cin >> a;
	
	if((a%100) % 10 == 7){
		cout << "Yes";
	}else if((a/10)%10 == 7){
		cout << "Yes";
	}else if(a/100 == 7){
		cout << "Yes";
	}else{
		cout << "No";
	}
	
	return 0;
}


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

using namespace std;

typedef long long ll;

const int INF = 1e9;
const ll LLINF = 1e18;
const ll MOD = (ll)1e9 + 7;

int main()
{
  int A, B, C, D, E, F;
  scanf("%d %d %d %d %d %d", &A, &B, &C, &D, &E, &F);
  int ans_s = 0, ans_water = -1;
  for (int op1 = 0; op1 * 100 * A <= F; ++op1) {
    for (int op2 = 0; op2 * 100 * B <= F; ++op2) {
      int water = op1 * 100 * A + op2 * 100 * B;
      if (water > F or water == 0) { continue; }
      int sugar = E * water / 100;
      for (int op3 = 0; op3 * C <= sugar; ++op3) {
        for (int op4 = 0; op4 * D <= sugar; ++op4) {
          int s = op3 * C + op4 * D;
          if (s > sugar or s + water > F) { continue; }
          if (ans_water == -1) {
            ans_water = water;
            ans_s = s;
          }
          else if (s * (ans_s + ans_water) > ans_s * (s + water)) {
            ans_s = s;
            ans_water = water;
          }
        }
      }
    }
  }
  printf("%d %d\n", ans_s + ans_water, ans_s);
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include<vector>
#include<algorithm>
#define ll long long
#define INVALID -1
#define mod 1e9+7
#define rep(n) for(int i=0;i<n;++i)
using namespace std;
int main(void){
    // Your code here!

int n,m;

cin>>n>>m;
vector<ll> dp(n+1,0);
dp[0]=1;
dp[1]=1;
for(int i=0;i<m;i++){
    int a;
    cin>>a;
    dp[a]=INVALID;
}

for(int i=2;i<=n;i++){
    if(dp[i]!=INVALID){
        if(dp[i-1]!=INVALID)
            dp[i]+=(dp[i-1]);
        if(dp[i-2]!=INVALID)
            dp[i]+=dp[i-2];
            dp[i]=dp[i]%1000000007;
           // cout<<dp[i]<<" ";
    }
    
}
cout<<dp[n]%1000000007;
}


Measured memory_bytes: 3616
#include <bits/stdc++.h>
using namespace std;
#define modulo N
#define mod(mod_x) ((((long long)mod_x+modulo))%modulo)
#define Inf 1000000005



int main(){
	
	int N,M,X;
	cin>>N>>M>>X;
	
	vector<int> C(N);
	vector<vector<int>> A(N,vector<int>(M));
	
	for(int i=0;i<N;i++){
		cin>>C[i];
		for(int j=0;j<M;j++)cin>>A[i][j];
	}
	
	int ans = Inf;
	
	for(int i=0;i<(1<<N);i++){
		vector<int> t(M,0);
		int cost = 0;
		for(int j=0;j<N;j++){
			if((i>>j)&1){
				for(int k=0;k<M;k++){
					t[k]+=A[j][k];
				}
				cost+=C[j];
			}
		}
		
		bool f = true;
		for(int j=0;j<M;j++){
			if(t[j]<X){
				f=false;
			}
		}
		if(f)ans = min(ans,cost);
	}
	
	if(ans==Inf)cout<<-1<<endl;
	else cout<<ans<<endl;
	
	return 0;
}


Measured memory_bytes: 3636
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx")
#pragma GCC optimize("unroll-loops")
//#pragma warning(disable : 4996)

#ifdef _MSC_VER
#include <intrin.h>
#define __builtin_popcount __popcnt
#define __builtin_popcountll __popcnt64

#endif

#include <limits.h>
#include <math.h>
#include <time.h>

#include <algorithm>
#include <array>
#include <bitset>
#include <cassert>
#include <complex>
#include <cstdio>
#include <cstring>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <map>
#include <numeric>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>

using namespace std;

#define REP(i, n) for (int i = 0; i < (n); ++i)
#define REPR(i, n) for (int i = n - 1; i >= 0; --i)
#define FOR(i, m, n) for (int i = m; i < n; ++i)
#define FORR(i, m, n) for (int i = m - 1; i >= n; --i)
#define SORT(v, n) sort(v, v + n);
#define VSORT(v) sort(v.begin(), v.end());
#define REVERSE(v, n) reverse(v, v + n);
#define VREVERSE(v) reverse(v.begin(), v.end())
#define ll long long
#define print(x) cout << (x) << '\n'
#define pe(x) cout << (x) << " "
#define DEBUG(x) cout << #x << ": " << x << endl
#define lb(v, n) lower_bound(v.begin(), v.end(), (n))
#define ub(v, n) upper_bound(v.begin(), v.end(), (n))
#define int long long
//#define double long double
#define all(x) (x).begin(), (x).end()
#define print_space(v) REP(i, v.size()) cout << v[i] << " \n"[i==(int)v.size()-1]
template <typename T1, typename T2> inline void chmin(T1& a, T2 b) { if (a > b) a = b; }
template <typename T1, typename T2> inline void chmax(T1& a, T2 b) { if (a < b) a = b; }
typedef pair<int, int> pii;
typedef pair<long long, long long> pll;
std::random_device rd;
std::mt19937 mt(rd());
constexpr ll MOD = 1e9 + 7;
constexpr int MAX = 500050;
const double pi = acos(-1);
constexpr double EPS = 1e-8;
constexpr ll LINF = 1e17 + 1;
constexpr int INF = 1e9 + 1;
//int dx[4] = { 0,0,-1,1 }, dy[4] = { 1,-1,0,0 };


void solve() {
	int D, T, S; cin >> D >> T >> S;
	if (S*T >= D)print("Yes");
	else print("No");
}



signed main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	//int q;
	//cin >> q;
	//while (q--)
	solve();

}


Measured memory_bytes: 3668
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,o,n) for(long long i = o;i<n;i++)
#define oneforall ios::sync_with_stdio(false);cin.tie(0);
#define all(v) (v).begin(),(v).end()
#define ini(...) int __VA_ARGS__; in(__VA_ARGS__)
#define inl(...) long long __VA_ARGS__; in(__VA_ARGS__)
#define ins(...) string __VA_ARGS__; in(__VA_ARGS__)
#define int long long 
const long long INF=1e18;
void in(){} template <typename T,class... U> void in(T &t,U &...u){ cin >> t; in(u...);}
void out(){cout << "\n";} template <typename T,class... U> void out(const T &t,const U &...u){ cout << t; if(sizeof...(u)) cout << " "; out(u...);}
typedef vector<int> vi;
typedef vector<long long> vl;
typedef long long ll;
typedef vector<pair<long, long > > vpll;
typedef vector<pair<int, int > > vpii;



int32_t main() {
	oneforall
	oneforall
	oneforall
	oneforall
	oneforall
	oneforall
	oneforall
	oneforall
	oneforall
	oneforall
	oneforall
	oneforall
	oneforall
	oneforall
	
	ini(n);
	vi morty;
	morty.push_back(0);
	FOR(i,0,n){
		ini(x);
		morty.push_back(x);
	}
	map<int,int> morty1;
	map<int,int> morty2;
	FOR(i,1,n+1){
		if(i%2){
			morty1[morty[i]]++;
			//out(morty1[morty[i]]);
		}
		else {
			morty2[morty[i]]++;
		}
	}
	//for(auto x:morty1)out(x.first);
	vpii fujiwara;
	vpii fujiwara1;
	fujiwara.push_back(make_pair(-1,-1));
	fujiwara.push_back(make_pair(-1,-1));
	fujiwara1.push_back(make_pair(-1,-1));
	fujiwara1.push_back(make_pair(-1,-1));
	for(auto x:morty1)fujiwara.push_back(make_pair(x.second,x.first));
	for(auto x:morty2)fujiwara1.push_back(make_pair(x.second,x.first));
	sort(all(fujiwara));
	//for(auto x:fujiwara)out(1,x.second);
	//for(auto x:fujiwara1)out(x);
	sort(all(fujiwara1));
	if(fujiwara.back().second!=fujiwara1.back().second){
		int tmp = 0;
		FOR(i,1,n+1){
		if(i%2){
			if(morty[i]!=fujiwara.back().second)tmp++;
		}
		else {
			if(morty[i]!=fujiwara1.back().second)tmp++;
		}
	}
		out(tmp);
	}
	else{
		int tmp1 = fujiwara[fujiwara.size()-2].second;
		//out(tmp1);
		int tmp2 = fujiwara1[fujiwara1.size()-2].second;
		int tmptest = INF;
		int  tmp = 0;
		FOR(i,1,n+1){
			if(i%2){
				if(morty[i]!=tmp1)tmp++;
			}
			else {
				if(morty[i]!=fujiwara1.back().second)tmp++;
			}
		}
			tmptest = min(tmp,tmptest);
		tmp = 0;
		FOR(i,1,n+1){
			if(i%2){
			if(morty[i]!=fujiwara.back().second)tmp++;
			}
			else {
				if(morty[i]!=tmp2)tmp++;
			}
		}
			tmptest = min(tmp,tmptest);
		out(tmptest);

	}
	
	
















	return 0;
}


Measured memory_bytes: 9588
<?php

fscanf(STDIN, "%d %d", $n, $h);

$a = array();
$b = array();

for ($i = 0; $i < $n; $i++) {
    fscanf(STDIN, "%d %d", $a[], $b[]);
}
rsort($b);
rsort($a);
$b_total = 0;
$cnt = 0;
foreach ($b as $value) {
    if ($value > $a[0]) {
        $b_total += $value;
        $cnt ++;
        if ($b_total >= $h) {
            break;
        }
    }
}

if ($b_total < $h) {
    $cnt += floor(($h - $b_total) / $a[0]);
    if (($h - $b_total) % $a[0] != 0) {
        $cnt++;
    }
}
echo $cnt;


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

int main() {
  int H, W, A, B;
  cin >> H >> W >> A >> B;

  vector<vector<int>> ans(H, vector<int>(W));
  rep(i,H) {
    rep(j,W) {
      if (i<B && j<A) cout << 0;
      else if (i<B) cout << 1;
      else if (j<A) cout << 1;
      else cout << 0;
    }
    cout << endl;
  }
  return 0;
}

Measured memory_bytes: 5120
#exec({'RUBY_THREAD_VM_STACK_SIZE'=>'100000000'},'/usr/bin/ruby', $0) if !ENV['RUBY_THREAD_VM_STACK_SIZE']

def inpf() a=gets.chomp.split(" ").map(&:to_f)end

def inps() a=gets.chomp.split(" ")end

def copy(a) Marshal.load(Marshal.dump(a)) end

def kaijo(n,r = 10**9+7)(n < 2)? 1 : (2..n).inject{|memo,u|memo=(memo*u)%r} end

def na(n,d=0) Array.new(n,d)end

def na2(n,m,d=0) Array.new(n){Array.new(m,d)}end

def na3(n,m,l,d=0) Array.new(n){Array.new(m){Array.new(l,d)}}end

def inp() a=gets.chomp.split(" ").map(&:to_i)end

def r_up(a, b) (a+b-1)/b end

def sum(a) a.inject(:+) end

n = inp[0]
ct = na(n,0)
mt = na(n,0)
ans = na2(n,n,false)
c = 0
turn = 1
ct[0] = n
while mt.uniq.size!=n
  cc = 0
  now = 0
  pls = 0
  ctn = na(n,0)
  n.times do |i|
    pls += 1 if(cc == r_up(ct[mt[i]],2))
    cc += 1
    cc = 0 if(cc == ct[mt[i]])
    mt[i] = mt[i]+pls
    ctn[mt[i]] += 1

  end
  ct = ctn
  (n).times do |i|
    ((i+1)...n).each do |j|
      if(mt[i]+mt[j]).odd?
        ans[i][j] = turn unless(ans[i][j])
      end
    end
  end
  turn += 1
end
ans.each.with_index do |a, i|
  puts a[(i+1)...n].join(" ")
end


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

int main(){
    int w, a, b;
    cin >> w >> a >> b;
    if(a == b){
        cout << 0 << endl;
        return 0;
    }
    else if (b > a){
        if (b <= a + w){
            cout << 0 << endl;
            return 0;
        }
        else{
            cout << b - a - w << endl;
            return 0;
        }
    }
    else{
        if (a <= b + w){
            cout << 0 << endl;
            return 0;
        }
        else{
            cout << a - b - w << endl;
        }
    }
    
}

Measured memory_bytes: 256
#include <iostream>
#include <array>
using namespace std;
array<array<char,12>,12> maap;

void dfs(int x,int y){
	maap[x][y] = '0';
	int dx[]={0,-1,1,0},dy[]={1,0,0,-1};
	for (int i = 0; i < 4; i++) {
		int nx = x+dx[i] , ny = y+dy[i];
		if(nx >= 0 && nx < 12 && ny >= 0 && ny < 12 && maap[nx][ny] == '1')
			dfs(nx,ny);
	}
	return;
}

int main(){
	while (1) {
		for (auto& i : maap)
			for (auto& j : i){
				cin>>j;
				if(cin.eof())return 0;
			}
		int cnt = 0;
		for (int i = 0; i < 12; i++)
			for (int j = 0; j < 12; j++)
				if(maap[i][j] == '1'){
					dfs(i,j);
					cnt++;
				}
		cout<<cnt<<endl;
	}
	return 0;
}

Measured memory_bytes: 1148
package main

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

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 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
}

const rate = 1.08

func main() {
	sc := NewScanner()
	N := sc.nextFloat()
	ans := math.Ceil(N / rate)
	ans2 := math.Floor(ans * rate)
	if N != ans2 {
		fmt.Println(":(")
	} else {
		fmt.Println(ans)
	}
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define debug(a, n) rep(hoge, n) printf("%d%c", a[hoge], hoge == n - 1? '\n' : ' ');
#define all(a) (a).begin(), (a).end()

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

signed main() {
    int n;
    string s, t;
    cin >> n >> s >> t;
    string ans = "";
    rep(i, n) {
        ans += s[i];
        ans += t[i];
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
N, M = map(int, input().split())
A = list(map(int, input().split()))
BC = []
for i in range(M):
    bc = list(map(int, input().split()))
    BC.append(bc)
BC.sort(key = lambda x : x[1])
irekae = []
count = 0
i = 0
while count < N:
    tmpb = BC[M-1-i][0]
    tmpc = BC[M-1-i][1]
    irekae += [tmpc for i in range(tmpb)]
    count += tmpb
    i += 1
    if i == M:
        break
ans = A + irekae
ans.sort(reverse = True)
print(sum(ans[:N]))

Measured memory_bytes: 36016
#include <stdio.h>

int main(void)
{
    int x, y;
    int small, large;

    while (1){
        scanf("%d %d",&x, &y);
        if (x != 0 || y != 0){
            if (x <= y){
                small = x;
                large = y;
            }else{
                small = y;
                large = x;
            }
            printf("%d %d\n", small, large);
        }else{
            break;
        }
    }

    return 0;
}

Measured memory_bytes: 600
#include<stdio.h>
#define COUNT_RESET 0
#define LOOP_RESET 0
unsigned short serch_word(unsigned char * word, unsigned char * sent);
unsigned short s_scan_word(unsigned char * str, unsigned short length_max);

int main(){
	unsigned char word[10];
	unsigned char sent[1000];
	unsigned short word_length, sent_length;
	unsigned short count = 0;
	unsigned char sentence_end[] = {"END_OF_TEXT\n"};
	unsigned short i;
	
	for(i = 0;i < 10;i++){
		word[i] = 0;
	}
	for(i = 0;i < 1000;i++){
		sent[i] = 0;
	}
	
	word_length = s_scan_word(word, 1000);
	
	while(1){
		sent_length = s_scan_word(sent, 1000);
		if(serch_word(sentence_end, sent) == 1){
			break;
		}
		
		for(i = 0;i < word_length;i++){
			word[i] |= 0x60;
		}
		for(i = 0;i < sent_length;i++){
			sent[i] |= 0x60;
		}
		if(word_length == sent_length){
			count += serch_word(word, sent);
		}
		for(i = 0;i <= sent_length;i++){
			sent[i] = 0;
		}
	}
	
	printf("%d\n", count);
	return 0;
}

/* 関数名：文字列入力 */
/* 概要：文字列を入力する。入力された文字列の長さを返す */
/* 引数：文字列を格納する配列の先頭アドレス、その配列の大きさ */
/* 戻り値：入力された文字列の長さ */
unsigned short s_scan_word(unsigned char * str, unsigned short length_max)
{
	unsigned short usW_C_count_text = COUNT_RESET;  	/* 文字列長カウンタ */
	unsigned short usW_C_i;                         	/* ループ変数 */

	/* 文字列の入力 */
	for(usW_C_i = LOOP_RESET;usW_C_i < length_max;usW_C_i++){
		scanf("%c", str + usW_C_i);
		/* 入力終了の処理 */
		if((*(str + usW_C_i) == ' ') || (*(str + usW_C_i) == '\n')){
			break;
		}
		/* 文字数をカウント */
		usW_C_count_text++;
	}

	/* 文字列長を返す */
	return usW_C_count_text;
}

unsigned short serch_word(unsigned char * word, unsigned char * sent)
{
	unsigned int frg = 0;
	unsigned int i = 0;
	while(1){
		if(*(word + i) == '\n'){
			frg =1;
		}
		if(*(word + i) != *(sent + i)){
			break;
		}
		i++;
	}
	
	return frg;
}


Measured memory_bytes: 2040
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Q4
{
    class Program
    {
        static void Main(string[] args)
        {
            string line = Console.ReadLine();
            string[] strs = line.Split(' ');
            int H = int.Parse(strs[0]);
            int W = int.Parse(strs[1]);
            //true #  false .
            bool[,] map = new bool[H, W];
            int[,] L = new int[H, W];
            int[,] R = new int[H, W];
            int[,] U = new int[H, W];
            int[,] D = new int[H, W];
            for (int i = 0; i < H; i++)
            {
                line = Console.ReadLine();
                for (int j = 0; j < W; j++)
                {
                    if (line[j] == '#')
                        map[i, j] = true;
                }
            }
            for (int i = 0; i < H; i++)
            {
                for (int j = 0; j < W; j++)
                {
                    if (map[i, j]) L[i, j] = 0;
                    else if (j == 0) L[i, j] = 1;
                    else L[i, j] = L[i, j - 1] + 1;
                    if (map[i, j]) U[i, j] = 0;
                    else if (i == 0) U[i, j] = 1;
                    else U[i, j] = U[i - 1, j] + 1;
                }
            }
            for (int i = H - 1; i >= 0; i--)
            {
                for (int j = W - 1; j >= 0; j--)
                {
                    if (map[i, j]) R[i, j] = 0;
                    else if (j == W - 1) R[i, j] = 1;
                    else R[i, j] = R[i, j + 1] + 1;
                    if (map[i, j]) D[i, j] = 0;
                    else if (i == H - 1) D[i, j] = 1;
                    else D[i, j] = D[i + 1, j] + 1;
                }
            }
            int max = 0;
            int light = 0;
            for (int i = 0; i < H; i++)
            {
                for (int j = 0; j < W; j++)
                {
                    light = L[i, j] + R[i, j] + U[i, j] + D[i, j] - 3;
                    if (max < light) max = light;
                }
            }
            Console.WriteLine(max);
        }
    }
}


Measured memory_bytes: 81476
#include <bits/stdc++.h>
using namespace std;
struct fast_ios { fast_ios(){ cin.tie(0); ios::sync_with_stdio(false); cout << fixed << setprecision(20); }; } fast_ios_;
#define FOR(i, begin, end) for(int i=(begin);i<(end);i++)
#define REP(i, n) FOR(i,0,n)
#define IFOR(i, begin, end) for(int i=(end)-1;i>=(begin);i--)
#define IREP(i, n) IFOR(i,0,n)
#define Sort(v) sort(v.begin(), v.end())
#define Reverse(v) reverse(v.begin(), v.end())
#define all(v) v.begin(),v.end()
#define SZ(v) ((int)v.size())
#define Lower_bound(v, x) distance(v.begin(), lower_bound(v.begin(), v.end(), x))
#define Upper_bound(v, x) distance(v.begin(), upper_bound(v.begin(), v.end(), x))
#define Max(a, b) a = max(a, b)
#define Min(a, b) a = min(a, b)
#define bit(n) (1LL<<(n))
#define bit_exist(x, n) ((x >> n) & 1)
#define debug(x) cout << #x << "=" << x << endl;
#define vdebug(v) cout << #v << "=" << endl; REP(i_debug, v.size()){ cout << v[i_debug] << ","; } cout << endl;
#define mdebug(m) cout << #m << "=" << endl; REP(i_debug, m.size()){ REP(j_debug, m[i_debug].size()){ cout << m[i_debug][j_debug] << ","; } cout << endl;}
#define pb push_back
#define f first
#define s second
#define int long long
#define INF 1000000000000000000
template<typename T> istream &operator>>(istream &is, vector<T> &v){ for (auto &x : v) is >> x; return is; }
template<typename T> ostream &operator<<(ostream &os, vector<T> &v){ for(int i = 0; i < v.size(); i++) { cout << v[i]; if(i != v.size() - 1) cout << endl; }; return os; }
template<typename T> void Out(T x) { cout << x << endl; }
template<typename T1, typename T2> void Ans(bool f, T1 y, T2 n) { if(f) Out(y); else Out(n); }

using vec = vector<int>;
using mat = vector<vec>;
using Pii = pair<int, int>;
using PiP = pair<int, Pii>;
using PPi = pair<Pii, int>;
using bools = vector<bool>;
using pairs = vector<Pii>;

//int dx[4] = {1,0,-1,0};
//int dy[4] = {0,1,0,-1};
//char d[4] = {'D','R','U','L'};

const int mod = 1000000007;
//const int mod = 998244353;
#define Add(x, y) x = (x + (y)) % mod
#define Mult(x, y) x = (x * (y)) % mod

signed main(){
    int N,T; cin>>N>>T;
    vec t(N); REP(i,N) cin>>t[i];
    int ans = T;
    REP(i,N-1){
        ans += min(T,t[i+1]-t[i]);
    }
    Out(ans);
}

Measured memory_bytes: 1792
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <array>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <sstream>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <list>
#include <numeric>
#include <stack>
#include <iomanip>
#include <random>
#include <complex>
#include <functional>
#include <tuple>

using namespace std;

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

#define Yes(q) ((q) ? "Yes" : "No")
#define YES(q) ((q) ? "YES" : "NO")
#define Possible(q) ((q) ? "Possible" : "Impossible")
#define POSSIBLE(q) ((q) ? "POSSIBLE" : "IMPOSSIBLE")

using ll = long long;

using pint = std::pair<int, int>;
using pll = std::pair<ll, ll>;

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

namespace {
    template<typename T> void chmax(T& a, T b) { a = std::max(a, b); }
    template<typename T> void chmin(T& a, T b) { a = std::min(a, b); }
    template<typename T> void chadd(T& a, T b) { a = a + b; }

    void Cout(long long x, const char* end = "\n") { std::cout << x << end; }
    template <typename T> void Cout(const T& x, const char* end = "\n") { std::cout << x << end; }
    template <typename T> void Cout(const std::vector<T>& x, const char* sep = " ", const char* end = "\n") { for (std::size_t i = 0, sz = x.size(); i < sz; i++) { std::cout << x[i] << (i == sz - 1 ? end : sep); } }

    // 標準入出力
    struct inp {
        std::size_t sz;
        inp(std::size_t _sz = 1) : sz(_sz) {}
        template <typename T> operator T () const { T a; std::cin >> a; return a; }
        template <typename T> operator std::vector<T>() const { vector<T> a(sz); for (std::size_t i = 0; i < sz; i++) std::cin >> a[i]; return a; }
        template <typename T, typename U> operator std::pair<T, U>() const { T f; U s; std::cin >> f >> s; return std::pair<T, U>(f, s); }
    };

    inp inp1; // input one
}

int main() {

    int n = inp1;
    vector<int> l = inp(n);

    sort(allof(l));

    int sn = 1001;
    vector<int> sum(sn, 0);
    rep(i, n) {
        ++sum[l[i]];
    }
    rep(i, sn - 1) {
        sum[i + 1] += sum[i];
    }

    ll ans = 0;

    rep(i, n) {
        Rep(j, i + 1, n) {
            int a = l[i];
            int b = l[j];

            int c_min = max(a - b, b - a) + 1;
            int c_max = a + b - 1;
            
            // この範囲のやつがいくつ存在するか
            int num = sum[min(c_max, sn - 1)] - sum[c_min - 1];
            if (a >= c_min && a <= c_max) --num;
            if (b >= c_min && b <= c_max) --num;

            ans += num;
        }
    }

    Cout(ans / 3);

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main() {
	ios_base::sync_with_stdio(0); cin.tie(0);
	int n; cin >> n;
	int a[n]; for(int i = 0; i < n; i++) cin >> a[i];
	bool ok = 0, asc = 1;
	for(int k = 1; k < n; k++){
		if (a[k] < a[k - 1]){
			asc = 0; break;
		}
	}
	if (asc) ok = 1;
	for(int i = 0; i < n - 1; i++)
		for(int j = i + 1; j < n; j++){
			{int c = a[i]; a[i] = a[j], a[j] = c;}
			bool asc = 1;
			for(int k = 1; k < n; k++){
				if (a[k] < a[k - 1]){
					asc = 0; break;
				}
			}
			if (asc) ok = 1;
			{int c = a[i]; a[i] = a[j], a[j] = c;}
		}
	cout << (ok ? "YES" : "NO");
}

Measured memory_bytes: 256
#pragma GCC target("avx")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for (long long i = 0; i < (long long)(n); i++)
using ll = long long;
using P = pair<ll,ll>;

int main(){
ios::sync_with_stdio(false);
std::cin.tie(nullptr);
ll n;
cin >> n;
ll ans = 1000;
for(int i = 1; i <= sqrt(n); i++){
    if(n % i == 0){
        ll k = n / i;
        string s = to_string(k);
        ans = min<ll>(ans,s.size());
    }
}
cout << ans << endl;
}

Measured memory_bytes: 3744
#include <bits/stdc++.h>
using namespace std;
#define F first
#define S second
#define pi M_PI
#define R cin>>
#define Z class
#define ll long long
#define ln cout<<'\n'
#define in(a) insert(a)
#define pb(a) push_back(a)
#define pd(a) printf("%.10f\n",a)
#define mem(a) memset(a,0,sizeof(a))
#define all(c) (c).begin(),(c).end()
#define iter(c) __typeof((c).begin())
#define rrep(i,n) for(int i=(int)(n)-1;i>=0;i--)
#define REP(i,m,n) for(int i=(int)(m);i<(int)(n);i++)
#define rep(i,n) REP(i,0,n)
#define tr(it,c) for(iter(c) it=(c).begin();it!=(c).end();it++)
template<Z A>void pr(A a){cout<<a;ln;}
template<Z A,Z B>void pr(A a,B b){cout<<a<<' ';pr(b);}
template<Z A,Z B,Z C>void pr(A a,B b,C c){cout<<a<<' ';pr(b,c);}
template<Z A,Z B,Z C,Z D>void pr(A a,B b,C c,D d){cout<<a<<' ';pr(b,c,d);}
template<Z A>void PR(A a,ll n){rep(i,n){if(i)cout<<' ';cout<<a[i];}ln;}
ll check(ll n,ll m,ll x,ll y){return x>=0&&x<n&&y>=0&&y<m;}
const ll MAX=1000000007,MAXL=1LL<<61,dx[4]={-1,0,1,0},dy[4]={0,1,0,-1};
typedef pair<int,int> P;

void Main() {
  ll n,m;
  cin >> n >> m;
  int c[n];
  mem(c);
  rep(i,m) {
    int x,y;
    cin >> x >> y;
    x--,y--;
    c[x]++;
    c[y]++;
  }
  rep(i,n) {
    if(c[i]%2) {
      pr("NO");
      return;
    }
  }
  pr("YES");
}

int main(){ios::sync_with_stdio(0);cin.tie(0);Main();return 0;}


Measured memory_bytes: 640
#!/usr/bin/env python3
# -*- coding: utf-8 -*-

if __name__ == "__main__":
    n = int(input())
    ids = [input() for i in range(n)]
    m = int(input())
    locked = True
    for j in range(m):
        t = input()
        if t in ids:
            if locked:
                print("Opened by {}".format(t))
                locked = False
            else:
                print("Closed by {}".format(t))
                locked = True
        else:
            print("Unknown {}".format(t))

Measured memory_bytes: 7752
from collections import defaultdict
S = input()
alphabet = "abcdefghijklmnopqrstuvxyz"

if S == "zyxwvutsrqponmlkjihgfedcba":
    print(-1)
    exit()

dict = defaultdict(int)
for s in S:
    dict[s] += 1

if len(S) < len(alphabet):
    for a in alphabet:
        if dict[a] == 0:
            print(S + a)
            exit()
else:
    for i in range(24, -1, -1):
        for j in range(25, i, -1):
            if S[i] < S[j]:
                print(S[:i] + S[j])
                exit()
print(-1)

Measured memory_bytes: 3316
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define rep(i, n) for (ll i = 0; i < n; ++i)
#define P pair<ll, ll>
#define Graph vector<vector<P>>
#define fi first
#define se second
constexpr ll mod = 1000000007;
constexpr ll INF = (1ll << 60);
constexpr double pi = 3.14159265358979323846;
template <typename T>inline bool chmax(T &a, T b){if (a < b){a = b;return 1;}return 0;}
template <typename T>inline bool chmin(T &a, T b){if (a > b){a = b;return 1;}return 0;}

int main(){
    ll n;cin>>n;
    double sum=0;
    rep(i,n){
        ll a;cin>>a;
        sum+=1.0/a;
    }

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

Measured memory_bytes: 3712
#include <bits/stdc++.h>
using namespace std;
int main(){
  long long n,m,ans=0;
  cin >> n;
  long long t[n];
  for(int i=0;i<n;i++){
    cin >> t[i];
  }
  cin >> m;
  long long p[m],x[m];
  for(int i=0;i<m;i++){
    cin >> p[i] >> x[i];
    ans=0;
    for(int j=0;j<n;j++){
      if(j+1==p[i]){
        ans+=x[i];
      }else{
        ans+=t[j];
      }
    }
    cout << ans << endl;
  }
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
         
typedef long long ll;
using namespace std;
        
#define F first
#define S second
#define sqr(x) x*x
#define pb push_back
#define mp make_pair
#define sz(x) ((int) (x).size())
#define all(x) (x).begin(), (x).end()
#define allr(x) (x).rbegin(), (x).rend()
#define repit(i, n) for(auto it = n.begin(); it != n.end(); ++it)
       
const ll mod=1000000007;
ll powmod(ll a,ll b) {ll res=1;a%=mod; assert(b>=0);for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}
ll gcd(ll a,ll b){if(b==0)return a;else return gcd(b,a%b);}
int lcm(int a,int b){return abs(a*b)/gcd(a,b);}
     
int main(){ios_base::sync_with_stdio(0);cin.tie(0); 
    string s;
    cin >> s;
    int dl = 0, mini = 100100;
    for(int i = 0; i < sz(s);++i){
        if(s[i] == 'A'){
            dl = i;
            mini = min(dl,mini); 
        }
    }
    int maxi = 0;
    for(int i = mini; i < sz(s); ++i){
        if(s[i] == 'Z'){
            dl = i;
            maxi = max(dl,maxi); 
        }
    }
     cout << (maxi - mini) + 1;
}

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

using namespace std;

typedef long long li;
const int MOD = 1e9 + 7;

int main()
{
    int n;
    cin >> n;
    
    vector<int> a;
    
    int lastx = -1;
    for (int i = 0; i < n; i++)
    {
        int x;
        cin >> x;
        x = min(x, lastx + 2);
        lastx = x;
        
        a.push_back(x);
    }
    int bitch = 1;
    
    vector<int> free;
    for (int i = 0; i < n; i++)
        if (i + 1 < n && a[i] + 1 == a[i + 1])
            free.push_back(i + 2);
        
    for (int i = 0; i < n; i++)
    {
        int x = (2 * i < (int)free.size() ? free[2 * i] : n) - i;
        bitch = bitch * (li)x % MOD;
    }
    
    cout << bitch << endl;
    
    return 0;
}

Measured memory_bytes: 1400
let array_of_string s = Array.init (String.length s) (fun i -> s.[i])

let () = Scanf.scanf "%d\n%s\n" @@ fun _ s ->
  array_of_string s
  |> Array.fold_left (fun (acc, curr) c ->
      let curr =
        curr + if c = 'I' then 1 else (-1) in
      (max acc curr, curr)) (0, 0)
  |> fst
  |> Printf.printf "%d\n"


Measured memory_bytes: 384
import java.util.*;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		// 整数の入力
        int n = sc.nextInt();
     	int count = 0,check;
        String tmp ;
        Map<String,Integer> map = new TreeMap<>();
        for(int i = 0;i < n;i++){
          tmp = sc.next();
          if(map.containsKey(tmp)){
            check = map.get(tmp) + 1; 
          }else{
            check = 1;
          }
          map.put(tmp,check);
          count = Math.max(count,check);
        } 
      
        for(var ans : map.entrySet()){
          if(count == ans.getValue()){
            System.out.println(ans.getKey());
          }else{
          }
        }
    }
}

Measured memory_bytes: 80440
#include <iostream>
#include<cstring>
using namespace std;
int main(){
	string s;
	cin>>s;
	int flag=0;
	for(int i=0;i<s.length();i++){
		for(int j=i+1;j<s.length();j++){
			if(s[i]==s[j]){
				flag=1;
			}
		}
	}
	if(flag==0){
		cout<<"yes"<<endl;
	}
	if(flag==1){
		cout<<"no"<<endl;
	}
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
#define ld long double
#define loop(i,a,b) for(ll i=a;i<b;i++)
#define rloop(i,a,b) for(ll i=a;i>b;i--)
const int inf=1e9+7;



int main()
{

ll n;
cin>>n;
ld p,ans=0;
vector<ld>dp(n+1);
dp[0]=1;
	loop(coins,0,n)
	{
		
	cin>>p;
	
	rloop(i,coins+1,-1)
	{
		dp[i]=((i)?dp[i-1]*p:0 )+dp[i]*(1-p);
	}
		
	}
	ll tails;
	loop(heads,0,n+1)
	{
		tails=n-heads;
		if(heads>tails)
		ans+=dp[heads];
	}
	
	
cout<<setprecision(12)<<ans;
	
}


Measured memory_bytes: 256
#include<cstdio>
int main(){
    char s[3][11];
    scanf("%s%s%s",s[0],s[1],s[2]);
    printf("%c%c%c",s[0][0]-'a'+'A',s[1][0]-'a'+'A',s[2][0]-'a'+'A');
    return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <array>
#include <string>

using namespace std;

constexpr int SURFACE_NUM = 6;
enum {TOP, FRONT, RIGHT, LEFT, BACK, BOTTOM};

class Dice {
private:
    array<int, SURFACE_NUM> m_surface;

public:
    // constructor
    Dice(array<int, SURFACE_NUM> surface)
        : m_surface(surface) {}

    // getter
    int surface(int i) const
    {
        return m_surface.at(i);
    }

    // roll and spin
    void roll(char direction)
    {
        switch (direction) {
        case 'N':
            roll(TOP, FRONT, BOTTOM, BACK);
            break;
        case 'S':
            roll(TOP, BACK, BOTTOM, FRONT);
            break;
        case 'E':
            roll(TOP, LEFT, BOTTOM, RIGHT);
            break;
        case 'W':
            roll(TOP, RIGHT, BOTTOM, LEFT);
            break;
        }
    }

    void roll(int i, int j, int k, int l)
    {
        int tmp = m_surface.at(i);
        m_surface.at(i) = m_surface.at(j);
        m_surface.at(j) = m_surface.at(k);
        m_surface.at(k) = m_surface.at(l);
        m_surface.at(l) = tmp;
    }

    void spin()
    {
        int tmp = m_surface.at(FRONT);
        m_surface.at(FRONT) = m_surface.at(LEFT);
        m_surface.at(LEFT) = m_surface.at(BACK);
        m_surface.at(BACK) = m_surface.at(RIGHT);
        m_surface.at(RIGHT) = tmp;
    }

    // is equal
    bool isEqual(const Dice& one)
    {
        for (int i = 0; i < 6; i++) {
            (i % 2)? (*this).roll('N'): (*this).roll('E');
            for (int j = 0; j < 4; j++) {
                (*this).spin();
                if (*this == one) {
                    return true;
                }
            }
        }

        return false;
    }

    bool operator==(const Dice& one)
    {
        bool is_equal = true;
        for (int i = 0; i < SURFACE_NUM; i++) {
            if (m_surface.at(i) != one.surface(i)) {
                is_equal = false;
                break;
            }
        }

        return is_equal;
    }

    // debag
    void printDice() const
    {
        cout << m_surface.at(TOP) << m_surface.at(FRONT)
             << m_surface.at(RIGHT) << m_surface.at(LEFT)
             << m_surface.at(BACK) << m_surface.at(BOTTOM) << endl;
    }
};

array<int, SURFACE_NUM> inputDice();

int main()
{
    Dice one(inputDice());
    Dice anothor(inputDice());

    cout << ((one.isEqual(anothor))? "Yes": "No") << endl;
}

array<int, SURFACE_NUM> inputDice()
{
    array<int, SURFACE_NUM> init;
    for (auto i = 0; i < SURFACE_NUM; i++) {
        cin >> init.at(i);
    }
    return init;
}

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

int main(){
	string s;
	int l=0,i;
	
	cin>>s;
	
	for(i=0;i<s.size();i++){
		if(s[i]=='1'){
			l++;
		}
	}
	cout<<l<<endl;
	
	return 0;
}

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

typedef pair<int,int> P;

priority_queue<P> Q;

void check(int num, int l){
  
  if( l % 2 == 0 ){
    
    if( num * 2 % l == 0 && num % l != 0 ){

      int a0 = num / l - l / 2 + 1;
      
      if( a0 >= 1 ) Q.push( P( l, a0 ) );
      
    }
    
  }
  else{
    
    if( num % l == 0 ){
      
      int a0 = num / l - l / 2;
      
      if( a0 >= 1 ) Q.push( P( l, a0 ) );
      
    }
    
  }
  
}

signed main(){
  
  while(1){
    
    int b;
    cin>>b;
    
    if( b == 0 ) break;
    
    while( !Q.empty() ) Q.pop();
        
    for(int i=1;i<=100000;i++){
      
      check( b, i );
      
      if( b % i == 0 ) check( b, b / i );
      
    }
    
    cout<<Q.top().second<<' '<<Q.top().first<<endl;
    
  }
    
  return 0;
}



Measured memory_bytes: 3076
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define PI 3.141592653589793
#define rep(i, n) for (int i = 0; i < (n); i++)
#define REP(i, a, n) for (int i = a; i < (n); i++)
#define rrep(i, n, k) for (int i = (n); i >= (k); i--);
#define all(x) (x).begin(), (x).end()
#define vi vector<int>
template<class T> istream &operator>>(istream&is,vector<T>&v){for(auto &elemnt:v)is>>elemnt;return is;}
template<class T,class U> istream &operator>>(istream&is,pair<T,U>&p){is>>p.first>>p.second;return is;}
template<class T>vector<T> make_vector(size_t a){return vector<T>(a);}
template<class T, class... Ts>auto make_vector(size_t a, Ts... ts){return vector<decltype(make_vector<T>(ts...))>(a, make_vector<T>(ts...));}
const int MOD = 1e9+ 7;
const int INF = 2e18;

signed main() {
    int X;
    cin >> X;
    int ans = (X / 500) * 1000;
    X %= 500;
    ans += (X / 5) * 5;
    cout << ans << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define syosu(x) fixed<<setprecision(x)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef pair<double,double> pdd;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<string> vs;
typedef vector<P> vp;
typedef vector<vp> vvp;
typedef vector<pll> vpll;
typedef pair<int,P> pip;
typedef vector<pip> vip;
const int inf=1<<30;
const ll INF=1ll<<60;
const double pi=acos(-1);
const double eps=1e-8;
const ll mod=1e9+7;
const int dx[4]={1,0,-1,0},dy[4]={0,1,0,-1};

int n,m,q;
vvi a;

int main(){
	cin>>n>>m>>q;
	n--;
	a=vvi(m,vi(n,-1));
	for(int i=0;i<q;i++){
		int A,B,C;
		cin>>A>>B>>C;
		a[A-1][B-1]=C;
	}
	int S=1<<n;
	vi dp(S),c(S);
	vvp b(S);
	dp[0]++;
	int sum=0;
	for(int i=1;i<S;i++){
		vi b_;
		if(i&1) b_.push_back(0);
		for(int j=0;j<n-1;j++) if(i&1<<(j+1)&&!(i&1<<j)) b_.push_back(j);
		c[i]=b_.size();
		b[i]=vp(1<<c[i]);
		for(int j=0;j<1<<c[i];j++){
			int T=i,t=-1;
			for(int k=0;k<c[i];k++) if(j&1<<k) T-=1<<b_[k],t*=-1;
			b[i][j]={T,t};
		}
	}
	for(int i=0;i<m;i++){
		vi DP(S);
		for(int j=0;j<S;j++){
			DP[j]=dp[j];
			for(int k=1;k<1<<c[j];k++){
				int T=b[j][k].first,t=b[j][k].second;
				if(t==1) (DP[j]+=DP[T])%=mod;
				else DP[j]=(DP[j]-DP[T]+mod)%mod;
			}
		}
		for(int j=0;j<S;j++) for(int k=0;k<n;k++) if(a[i][k]!=-1&&(j>>(n-k-1))%2!=a[i][k]) DP[j]=0;
		dp=DP;
	}
	int res=0;
	for(int i=0;i<S;i++) (res+=dp[i])%=mod;
	cout<<res<<endl;
}

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

#define mp make_pair
#define sz(x) (int)((x).size())
#define all(x) (x).begin(),(x).end()
#define FO(x) {freopen(#x".in","r",stdin);freopen(#x".out","w",stdout);}
#define eb emplace_back

typedef pair< int, int > pii;
typedef pair< long long, long long > pll;
typedef long long ll;
typedef unsigned long long ull;
typedef vector< int > vi;
typedef vector< vi > vvi;
typedef vector< ll > vll;
typedef vector< vll > vvll;
typedef vector< pii > vpii;
typedef vector< vpii > vvpii;
typedef vector< pll > vpll;
typedef long double ld;
typedef vector< ld > vld;
typedef unsigned int uint;
 
template <uint MD> struct ModInt {
    using M = ModInt;
    const static M G;
    uint v;
    ModInt(ll _v = 0) { set_v(uint(_v % MD + MD)); }
    M& set_v(uint _v) {
        v = (_v < MD) ? _v : _v - MD;
        return *this;
    }
    explicit operator bool() const { return v != 0; }
    M operator-() const { return M() - *this; }
    M operator+(const M& r) const { return M().set_v(v + r.v); }
    M operator-(const M& r) const { return M().set_v(v + MD - r.v); }
    M operator*(const M& r) const { return M().set_v(uint(ull(v) * r.v % MD)); }
    M operator/(const M& r) const { return *this * r.inv(); }
    M& operator+=(const M& r) { return *this = *this + r; }
    M& operator-=(const M& r) { return *this = *this - r; }
    M& operator*=(const M& r) { return *this = *this * r; }
    M& operator/=(const M& r) { return *this = *this / r; }
    bool operator==(const M& r) const { return v == r.v; }
    const bool operator<(const M& o) const {return v < o.v; }
    M pow(ll n) const {
        M x = *this, r = 1;
        while (n) {
            if (n & 1) r *= x;
            x *= x;
            n >>= 1;
        }
        return r;
    }
    M inv() const { return pow(MD - 2); }
    friend ostream& operator<<(ostream& os, const M& r) { return os << r.v; }
};
 
using Mint = ModInt<(int)998244353>;
 
int main() { 
    #ifdef BLAT
        freopen("stdin", "r", stdin);
        freopen("stderr", "w", stderr);
    #endif
 
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    cout.precision(12);
    srand(time(NULL));
    
    int n, s;
    cin >> n >> s;

    vi v(n);

    for(auto &x : v) cin >> x;

    vector< Mint > dp(s + 1);

    dp[0] = 1;

    for(auto &x : v) {
        for(int i = s; ~i; --i) {
            /// il adaug
            if(i + x <= s) dp[i+x] += dp[i];
            dp[i] += dp[i];
        }
    }

    cout << dp[s] << '\n';
    return 0;
}

Measured memory_bytes: 3656
#include <bits/stdc++.h>
#define LOCAL
using namespace std;
template <typename A, typename B>
ostream& operator <<(ostream& out, const pair<A, B>& a) {
out << "(" << a.first << "," << a.second << ")";
return out;
}
template <typename T, size_t N>
ostream& operator <<(ostream& out, const array<T, N>& a) {
out << "["; bool first = true;
for (auto& v : a) { out << (first ? "" : ", "); out << v; first = 0;} out << "]";
return out;
}
template <typename T>
ostream& operator <<(ostream& out, const vector<T>& a) {
out << "["; bool first = true;
for (auto& v : a) { out << (first ? "" : ", "); out << v; first = 0;} out << "]";
return out;
}
template <typename T, class Cmp>
ostream& operator <<(ostream& out, const set<T, Cmp>& a) {
out << "{"; bool first = true;
for (auto& v : a) { out << (first ? "" : ", "); out << v; first = 0;} out << "}";
return out;
}
template <typename U, typename T, class Cmp>
ostream& operator <<(ostream& out, const map<U, T, Cmp>& a) {
out << "{"; bool first = true;
for (auto& p : a) { out << (first ? "" : ", "); out << p.first << ":" << p.second; first = 0;} out << "}";
return out;
}
#ifdef LOCAL
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
#else
#define trace(...) 42
#endif
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
cerr << name << ": " << arg1 << endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
const char* comma = strchr(names + 1, ',');
cerr.write(names, comma - names) << ": " << arg1 << " |";
__f(comma + 1, args...);
}
#define rep(i,n) for(int i=0; i<(n); i++)
using ll = long long;
#define int long long
using P = pair<int,int>;
//#########################################
signed main(){
    int n,m,k;cin >> n >> m >> k;
    vector<int> a(n),b(m);
    rep(i,n)cin >> a[i];
    rep(i,m)cin >> b[i];
    vector<int> sa(n+1),sb(m+1);
    rep(i,n)sa[i+1] = sa[i] + a[i];
    rep(i,m)sb[i+1] = sb[i] + b[i];
    int ret = 0;
    for(int i = 0,j = m;i < n+1;i++){
        for(;j >= 0 && sb[j] + sa[i] > k;j--);
        if(sa[i] + sb[j] <= k)ret = max(ret,i+j);
    }
    cout << ret << endl;
    return 0;
}

Measured memory_bytes: 9572