akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <set>
using namespace std;

bool search(vector<int> tehai) {
  sort(tehai.begin(), tehai.end());
  /*for (int i = 0; i < tehai.size(); i++) {
    printf("%d", tehai[i]);
    }
    printf("\n");*/
  for (int i = 0; i < tehai.size() - 2; i++) {
    if ((tehai[i] == tehai[i + 1] && tehai[i] == tehai[i + 2])) {
      vector<int> _tehai = tehai;
      _tehai.erase(_tehai.begin() + i, _tehai.begin() + (i + 3));
      /*printf("\t");
	for (int j = 0; j < _tehai.size(); j++) {
	printf("%d", _tehai[j]);
	}
	printf("\n");*/
      if (_tehai.empty()) {
	return true;
      }
      if(search(_tehai)) {
	return true;
      }
    }
  }
  for (int i = 0; i < tehai.size() - 1; i++) {
    if (tehai[i + 1] == tehai[i] + 1) {
      for (int j = i + 2; j < tehai.size(); j++) {
	if (tehai[j] == tehai[i] + 2) {
	  vector<int> _tehai = tehai;
	  _tehai.erase(_tehai.begin() + i, _tehai.begin() + i + 2);
	  _tehai.erase(_tehai.begin() + (j - 2));
	  if (_tehai.empty()) {
	    return true;
	  }
	  if (search(_tehai)) {
	    return true;
	  }
	}
      }
    }
  }
  return false;
}

int main()
{
  vector<int> tehai(13);
  while (scanf("%1d ", &tehai[0]) == 1) {
    set<int> result, full;
    for (int i = 1; i < 13; i++) {
      scanf("%1d ", &tehai[i]);
    }
    sort(tehai.begin(), tehai.end());
    for (int i = 0; i < tehai.size() - 3; i++) {
      if (tehai[i] == tehai[i + 1] && tehai[i] == tehai[i + 2] && tehai[i] == tehai[i + 3]) {
	full.insert(tehai[i]);
      }
    }
    for (int i = 1; i <= 9; i++) {
      if (full.find(i) != full.end()) {
	continue;
      }
      vector<int> _tehai = tehai;
      _tehai.push_back(i);
      sort(_tehai.begin(), _tehai.end());
      for (int j = 0; j < _tehai.size(); j++) {
	if (_tehai[j + 1] == _tehai[j]) {
	  vector<int> __tehai = _tehai;
	  __tehai.erase(__tehai.begin() + j, __tehai.begin() + (j + 1) + 1);
	  if (search(__tehai)) {
	    result.insert(i);
	    goto next;
	  }
	}
      }
    next:;
    }

    set<int>::iterator it = result.begin();
    if (result.empty()) {
      printf("0\n");
      goto end;
    }
    printf("%d", *result.begin());

    it++;
    for (;it != result.end(); it++) {
      printf(" %d", *it);
    }
    printf("\n");
  end:;
  }
  return 0;
}

Measured memory_bytes: 0
import java.util.*;
// warm-up
public class Main {

	static void solve() {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt(), Y = sc.nextInt(), i = 0, j = 0, k = 0;
		for (i=0; i<=Y/10000; i++) {
			for (j=0; j<=Y/5000; j++) {
				k = (Y-((10000*i)+(5000*j)))/1000;
				if (k>=0 && i+j+k==N) {
					if (((10000*i)+(5000*j)+(1000*k))!=Y) continue;
					System.out.println(i+" "+j+" "+k);
					System.exit(0);
				}
			}
		}
		System.out.println("-1 -1 -1");
		sc.close();		
	}

	public static void main(String args[]) {
		solve();
	}

}

Measured memory_bytes: 39336
n = int(input())
a = input()
b = input()
c = input()

ans = 0
for i in range(n):
    cnt = 2
    if a[i]==b[i]: cnt -= 1
    if b[i]==c[i]: cnt -= 1
    if c[i]==a[i]: cnt -= 1
    if cnt<0: cnt = 0
    ans += cnt

print(ans)


Measured memory_bytes: 3060
#include <iostream>
#include <sstream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <ctime>
#include <cstring>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <bitset>
#include <numeric>
#include <utility>
#include <iomanip>
#include <algorithm>
#include <functional>
using namespace std;
const int INF=1e9;

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

int main(){
    map<string, int> mp;
    int n;
    cin>>n;
    for(int i=0; i<n; i++){
        string s;
        cin>>s;
        mp[s]++;
    }
    int m;
    cin>>m;
    for(int i=0; i<m; i++){
        string t;
        cin>>t;
        mp[t]--;
    }
    int ans=0;
    for(auto it=mp.begin(); it!=mp.end(); it++)chmax(ans, it->second);
    cout<<ans<<endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#if 1
#define int long long
#define MAX LLONG_MAX
#define MIN LLONG_MIN
#define stoi stoll
#else
#define MAX INT_MAX
#define MIN INT_MIN
#endif
#define INF MAX/2
#define ALL(obj) (obj).begin(), (obj).end()
#define fi first
#define se second
const int NIL = -1;
const int MOD = 1000000007;
#define REP(i,n) for (int (i)=0; (i) < (n); ++(i))
#define FOR(i,a,b) for (int (i)=(a); (i) < (b); ++(i))
using namespace std;

int pow(int x, int n) {int res=1; while(n){if(n&1)res*=x;x*=x;n>>=1;} return res;}
int get_gcd(int a, int b) {while(1){if (a < b) swap(a, b); if (b == 0) return a; a %= b;}}
int get_lcm(int a, int b) {return a * b / get_gcd(a, b);}
bool chmin(int &a, int b) {if(a>b){a=b; return true;} else return false;}
bool chmax(int &a, int b) {if(a<b){a=b; return true;} else return false;}
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};

//-------------------------テンプレここまで-------------------------//

signed main () {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);

  int N;
  cin >> N;
  vector<pair<int,int>> v(N);
  REP(i,N) {
    v[i].fi = i + 1;
    cin >> v[i].se;
  }

  sort(ALL(v), [](pair<int,int>&a, pair<int,int>&b){return a.se < b.se;});

  REP(i,N) cout << v[i].fi << " ";
  cout << endl;

  return 0;
}


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

#define REP(i, n) for(int64_t i = 0; i < n; i++)
#define REPR(i, n) for(int64_t i = n; i >= 0; i--)
#define FOR(i, m, n) for(int64_t i = m; i < n; i++)
#define FORR(i, m, n) for(int64_t i = m; i >= n; i--)
#define ALL(v) v.begin(), v.end()
typedef long long ll;
template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
    fill( (T*)array, (T*)(array+N), val );
}
template<class T>
inline bool chmax(T &a, T b) {if(a < b) {a = b;return true;}return false;}
template<class T>
inline bool chmin(T &a, T b) {if(a > b) {a = b;return true;}return false;}
const ll INF= 1ll << 60;
const ll MOD = 1000000007;
double EPS = 1e-10;
//----------------------------------------------------------

int N,d[100];

int main(){
    cin >> N;
    FOR(i,1,N+1)cin >> d[i];
    int ans=0;
    FOR(i,1,N){
        FOR(j,i+1,N+1)
        {
            ans += d[i] * d[j];
        }
    }
    cout << ans << endl;
    return 0;
}

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

typedef long long ll;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
typedef pair<ll, ll> P;
#define rep(i, n) for(ll i = 0; i < n; i++)
#define REP(i, a, b) for(ll i = a; i <= b; i++)
#define out(x) std::cout << x << '\n'
#define all(a) a.begin(), a.end()
#define pb push_back
#define sz(x) ((int)(x).size())
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }
ll lcm(ll a, ll b) { ll g = gcd(a, b); return a / g * b; }
const int dx[4] = { 1, 0, -1,  0 };
const int dy[4] = { 0, 1,  0, -1 };
const int INF = (int)1e9;
const ll  inf = (ll)1e18;
const int mod = 1000000007;
const int MAX_N = 100010;

bool cmp(P a, P b) { return a.second < b.second; }

int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	cout << fixed << setprecision(10);
	/*------------------------------*/

	int n, m;
	cin >> n >> m;
	vector<P> a(m);
	rep(i, m) {
		cin >> a[i].first >> a[i].second;
	}

	sort(a.begin(), a.end(), cmp);
	
	int res = 0;
	int endtime = 0;
	rep(i, m) {
		if (a[i].first >= endtime) {
			res++;
			endtime = a[i].second;
		}
	}

	out(res);

	return 0;
}

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

const int N = 1e5 + 10, M = 2e5 + 30;
int n, m;
struct edge {
	int y, nxt, id;
}e[M << 1];
int lin[M], len;
int dis[N], pos[N];
bool vis[N];
set<int> c[N];

inline int read() {
	int s = 0, f = 1;
	char ch;
	for(; ch < '0' || ch > '9'; ch = getchar())	if(ch == '-')	f = -1;
	for(; ch >= '0' && ch <= '9'; ch = getchar())	s = (s << 1) + (s << 3) + ch - '0';
	return s * f;
}

inline void add(int xx, int yy, int vv) {
	e[++len] = (edge){yy, lin[xx], vv};
	lin[xx] = len;
}

inline void Dijkstra() {
	priority_queue< pair < int, int > > q;
	memset(dis, 0x3f, sizeof(dis));
	memset(vis, 0, sizeof(vis));
	dis[1] = 0;
	q.push(make_pair(0, 1));
	while(!q.empty()) {
		int x = q.top().second; q.pop();
		if(vis[x])	continue;
		vis[x] = 1;
		for(int i = lin[x]; i; i = e[i].nxt) {
			int y = e[i].y, v = c[x].count(e[i].id) ? 0 : 1;
			if(dis[y] > dis[x] + v) {
				dis[y] = dis[x] + v;
				q.push(make_pair(-dis[y], y));
				c[y].clear();
				c[y].insert(e[i].id);
			} else if(dis[y] == dis[x] + v)	c[y].insert(e[i].id);
		}
	}
}

int main() {
	n = read(), m = read(); 
	if(m == 0) { puts("-1"); return 0; }
	for(int i = 1; i <= m; ++i) {
		int xx = read(), yy = read(), vv = read();
		add(xx, yy, vv);
		add(yy, xx, vv);
	}
	Dijkstra();
	printf("%d\n", dis[n] == 0x3f3f3f3f ? -1 : dis[n]);
	return 0;
}

Measured memory_bytes: 23180
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); i++)
#define repe(i,n) for (int i = 0; i <= (n); ++i)
#define repe1(i,n) for (int i = 0; i <= (n); ++i)
#define all(x) (x).begin(),(x).end()
#define pb(x) push_back(x)
#define eb(k,v) emplace_back(k,v)
#define ct(res) cout << res << "\n";
using namespace std;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
typedef long long ll;
const int INF = 1e9;
const ll mod = 1000000007;
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b){return a * b / gcd(a, b);}
 
ll pow_kai(ll a, ll n) {
    ll x = 1;
    while(n > 0) {
        if(n&1) {
            x = x*a;
        }
        a = a*a;
        n >>= 1;
    }
    return x;
}

using Graph = vector<vector<int>>;

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int n;
    cin >> n;
    vector<ll> A(n+1);
    vector<ll> B(n);
    rep(i,n+1) cin >> A[i];
    rep(i,n) cin >> B[i];
    ll sum = 0;
    rep(i,n) {
        if (A[i]>=B[i]) {
            sum+=B[i];
            continue;
        } else {
            sum+=A[i];
            B[i] -= A[i];
        }
        if (A[i+1]>=B[i]) {
            sum+=B[i];
            A[i+1] -= B[i];
        } else {
            sum+=A[i+1];
            A[i+1] = 0;
        }
    }
    cout << sum << "\n";
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
#define rep(i,a,b) for(int i=(a);i<=(b);i++)
#define per(i,a,b) for(int i=(a);i>=(b);i--)
#define ms(s,x) memset(s,x,sizeof(s))
#define pb push_back
#define inf 0x3f3f3f3f
#define IOS ios::sync_with_stdio(false);cin.tie(0)
typedef long long ll;
using namespace std;

const double PI = acos(-1.0);
const double eps = 1e-8;
const int MAXN = 5e5+5;
const ll MOD = 1e9+7;

int num[MAXN], tmp[MAXN];
int ans = 0;

void mergesort(int l, int r)
{
    if (r-l > 1)
    {
        int mid = (l+r)>>1;
        int i = l, j = mid, k = l;
        mergesort(l, mid);
        mergesort(mid, r);
        while (i < mid && j < r)
        {
            ans++;
            if (num[i] <= num[j])
                tmp[k++] = num[i++];
            else
                tmp[k++] = num[j++];
        }
        while (i < mid){
            ans++;
            tmp[k++] = num[i++];
        }
        while (j < r){
            ans++;
            tmp[k++] = num[j++];
        }
        rep(h, l, r-1){
            num[h] = tmp[h];
        }
    }
    return;
}

int main()
{
    int n;
    cin >> n;
    rep(i, 0, n-1){
        cin >> num[i];
    }
    mergesort(0, n);
    rep(i, 0, n-1)
    {
        if (i)
            putchar(' ');
        cout << num[i];
    }
    cout << endl << ans << endl;

    return 0;
}



Measured memory_bytes: 7016
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n,q;
    string s;
    cin >> n >> s >> q;
    for(int it = 1; it <= q; it++)
    {
        int k;
        cin >> k;
        int r = -1;
        long long ans = 0;
        long long cur = 0;
        long long sum = 0;
        int cnt = 0;
        for(int i = 0; i < n; i++)
        {
            while(r + 1 - i < k && r + 1 < n)
            {
                r++;
                if(s[r] == 'M')
                    cur++;
                if(s[r] == 'C')
                {
                    //cout<<'#'<<r<<endl;
                    cnt++;
                    sum += cur;
                }
            }
            if(i != 0)
            {
                if(s[i - 1] == 'M')
                {
                    cur--;
                    sum -= cnt;
                }
                if(s[i - 1] == 'C')
                {
                    cnt--;
                }
            }
            if(s[i] == 'D')
                ans += sum;
          //  cout << cnt<<' '<<cur<<' '<<sum<<' '<<r<<' '<<ans<<'!'<<endl;
        }
        cout << ans<<'\n';
    }

}


Measured memory_bytes: 1412
import collections
import math

n = int(input())
m = 0
mod = 10 ** 9 + 7
c = []
d = []
frac = []

for _ in range(n):
    a, b = map(int, input().split())
    if a == 0 and b == 0:
        n -= 1
        m += 1
        continue
    if a == 0:
        frac.append('0/1')
    elif b == 0:
        frac.append(('1/0'))
    else:
        gcd = abs(math.gcd(a, b))
        sign = 1 if a * b > 0 else -1
        a = sign * abs(a) // gcd
        b = abs(b) // gcd
        frac.append('{}/{}'.format(a, b))

frac = collections.Counter(frac)

def inverse(key):
    if key == '0/1':
        return '1/0'
    elif key == '1/0':
        return '0/1'
    elif key[0] != '-':
        a, b = key.split('/')
        return '-{}/{}'.format(b, a)
    else:
        a, b = key[1:].split('/')
        return '{}/{}'.format(b, a)

for key, value in frac.items():
    if key[0] == '-' or key[0] == '0': continue
    if frac[inverse(key)] > 0:
        c.append(value)
        d.append(frac[inverse(key)])

ans = pow(2, n - sum(c) - sum(d), mod)
for i, j in zip(c, d):
    tmp = (pow(2, i, mod) + pow(2, j, mod) - 1) % mod
    ans = ans * tmp % mod
ans = (ans - 1 + m) % mod

print(ans)

Measured memory_bytes: 44988
h,*s=open(0)
h,w=map(int,h.split())
r=range
a,b,c,d=eval('eval("w*[0],"*h),'*4)
for i in r(h*w):i,j=i//w,i%w;a[i][j]=-~a[i][j-1]*(s[i][j]>'#');b[i][~j]=-~b[i][-j]*(s[i][-j-2]>'#');c[i][j]=-~c[i-1][j]*(s[i][j]>'#');d[~i][j]=-~d[-i][j]*(s[~i][j]>'#')
print(max(a[i][j]+b[i][j]+c[i][j]+d[i][j]-3for i in r(h)for j in r(w)))

Measured memory_bytes: 188680
#include <algorithm>
#include <cassert>
#include <cctype>
#include <chrono>
#define _USE_MATH_DEFINES
#include <cmath>
#include <cstdio>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iostream>
#include <map>
#include <queue>
#include <random>
#include <set>
#include <sstream>
#include <string>
#include <tuple>
#include <vector>
using namespace std;

#define FOR(i,m,n) for(int i=(m);i<(n);++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) (v).begin(),(v).end()

const int INF = 0x3f3f3f3f, MOD = 1000000007;
const long long LINF = 0x3f3f3f3f3f3f3f3fLL;
/*-----------------------------------------*/
int main() {
  cin.tie(0); ios::sync_with_stdio(false);
  // freopen("input.txt", "r", stdin);

  int a, b, q; cin >> a >> b >> q;
  vector<long long> s(a), t(b);
  REP(i, a) cin >> s[i];
  REP(i, b) cin >> t[i];
  while (q--) {
    long long x; cin >> x;
    int ss = lower_bound(ALL(s), x) - s.begin(), tt = lower_bound(ALL(t), x) - t.begin();
    if (ss == a) {
      if (tt == b) {
        long long mukau = min(s[ss-1], t[tt-1]);
        cout << x - mukau << '\n';
      } else {
        long long ans = LINF;
        long long tmp1 = x - s[ss-1], tmp2 = t[tt] - x;
        ans = min(ans, tmp1 + tmp2 + min(tmp1, tmp2));
        if (tt > 0) ans = min(ans, x - min(s[ss-1], t[tt-1]));
        cout << ans << '\n';
      }
    } else if (tt == b) {
      long long ans = LINF;
      long long tmp1 = s[ss] - x, tmp2 = x - t[tt-1];
      ans = min(ans, tmp1 + tmp2 + min(tmp1, tmp2));
      if (ss > 0) ans = min(ans, x - min(s[ss-1], t[tt-1]));
      cout << ans << '\n';
    } else {
      long long ans = LINF;
      ans = min(ans, max(s[ss], t[tt]) - x);
      if (tt > 0) {
        long long tmp1 = s[ss] - x, tmp2 = x - t[tt-1];
        ans = min(ans, tmp1 + tmp2 + min(tmp1, tmp2));
      }
      if (ss > 0) {
        if (tt > 0) ans = min(ans, x - min(s[ss-1], t[tt-1]));
        long long tmp1 = t[tt] - x, tmp2 = x - s[ss-1];
        ans = min(ans, tmp1 + tmp2 + min(tmp1, tmp2));
      }
      cout << ans << '\n';
    }
  }
  return 0;
}


Measured memory_bytes: 2944
#include <iostream>
#include <iomanip>
#include <string>
#include <vector>
#include <algorithm>
#include <map>
#include <unordered_map>

//#define int long long

using namespace std;

void Main()
{
	int A, B;
	cin >> A >> B;
	if (A > 9 || B > 9) {
		cout << -1 << endl;
		return;
	}
	else {
		cout << A * B << endl;
	}
}

int32_t main()
{
	Main();
	return 0;
}

/*
void sample()
{
	vector<int> v;
	sort(v.begin(), v.end());
	sort(v.begin(), v.end(), greater<int>());

}
*/



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

using ll=long long;
#define int ll

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

int read(){
	int i;
	scanf("%lld",&i);
	return i;
}

signed main(){
	int n=read();
	int a[n];
	REP(i,n){
		a[i]=read();
	}
	//if(n%2!=0){
		for(int i=n-1;i>=0;i-=2){
			cout << a[i] << " ";
		}
		for(int i=0;i+1<n;i+=2){
			if(n%2==0) cout << a[i] << " ";
			else cout << a[i+1] << " ";
		}
	//}
}

Measured memory_bytes: 3712
n = int(input())
s = list(input())

e = s.count('E')
w = 0
c = 10**6
for i in range(n):
    if s[i] == 'E':
        e -= 1
        c = min(c, w + e)
    else:
        c = min(c, w + e)
        w += 1

print(c)


Measured memory_bytes: 6056
#include <iostream>

using namespace std;


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

    int line[n] = {0};

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

    int cur = 0;
    for(int i=0; i<n; ++i){
        cur += line[i];
        if(cur>x){
            cout << i+1 << endl;
            return 0;
        }
    }

    cout << n+1 << endl;
    return 0;
}

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

#define pb         push_back

const int INF = 100000000;

int main(void) {
	int n, m;
	set<string> id;
	cin >> n;
	for(int i=0; i<n; i++){
		string t;
		cin >> t;
		id.insert(t);
	}
	cin >> m;
	int state = 1;
	for(int i=0; i<m; i++){
		string t;
		cin >> t;
		if(id.find(t) == id.end()){
			cout << "Unknown " << t << endl;
		}else if(state == 1){
			cout << "Opened by " << t << endl;
			state = 0;
		}else if(state == 0){
			cout << "Closed by " << t << endl;
			state = 1;
		}
	}
	
	return 0;
}

Measured memory_bytes: 1232
#include <algorithm>
#include <iostream>
#include <string>

using namespace std;

int main() {
	long long n; cin >> n;
	if (n == 0) {
		cout << "a\n";
		return 0;
	}
	string s;
	while (n) {
		n--;
		s.append(1, n % 26 + 'a');
		n /= 26;
	}
	reverse(s.begin(), s.end());
	cout << s << '\n';
	return 0;
}


Measured memory_bytes: 3612
#include <cstdio>
#include <iostream>
#include <algorithm>
using namespace std;
int A[25];
int n;
int dp[25][2010];

bool solve(int i,int k){
	if(dp[i][k]==1) return 1;
	if(k==0) dp[i][k]=1;
	else if(i>=n) dp[i][k]=0;
	else if(solve(i+1,k)) dp[i][k]=1;
	else if(solve(i+1,k-A[i])) dp[i][k]=1;
	else dp[i][k]=0;
	return dp[i][k];
}

int main (){
	int q,k;
	cin>>n;
	for(int i=0;i<n;i++) cin>>A[i];
	cin>>q;
	for(int i=0;i<q;i++) {
		cin>>k;
		if(solve(0,k)==true) cout<<"yes"<<endl;
		else cout<<"no"<<endl;
	}
	return 0;
}


Measured memory_bytes: 3240
#include <stdio.h>

int main(void)
{
    double a;
    double r;
    
    a = 3.141592653589;
    // 3.141592653589
    
    scanf("%lf", &r);
    printf("%f %f\n", r*r*a, 2*r*a);
    return (0);
}


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

int main(void){
        int N;
        int *str;

        scanf("%d",&N);
        str = (int *)malloc(sizeof(int) * N); 

        if(str==NULL)exit(0);

        for(int i=0;i<N;i++){
            scanf("%d",&str[i]);
        }   

        int ans = 0;

        for(int i=0;i<N;i++){
            for(int j=i+1;j<N;j++){
                ans += str[i] * str[j];
            }   
        }   

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

        free(str);


        return 0;
}


Measured memory_bytes: 128
#include <algorithm>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <deque>
#include <iostream>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
using namespace std;
typedef long long unsigned int ll;

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
#define rep(i, n) for (int i = 0; i < n; i++)

// int getNumOfAc(string s) {
//   int count = 0;
//   bool prevIsA = false;
//   for (char c : s) {
//     if (c == 'C' && prevIsA) {
//       count++;
//     }

//     if (c == 'A') {
//       prevIsA = true;
//     } else {
//       prevIsA = false;
//     }
//   }
//   return count;
// }

int main() {
  int N, Q;
  cin >> N >> Q;

  string S;
  cin >> S;

  int DP1[N];
  int DP2[N];

  rep(i, N) { DP1[i] = 0; }
  rep(i, N) { DP2[i] = 0; }

  for (int i = 1; i < N; i++) {
    DP1[i] = DP1[i - 1];
    if (S[i - 1] == 'A' && S[i] == 'C') {
      DP1[i]++;
    }
    DP2[N - 1 - i] = DP2[N - 1 - i + 1];
    if (S[N - 1 - i] == 'A' && S[N - 1 - i + 1] == 'C') {
      DP2[N - 1 - i]++;
    }
    // cout << "i " << i << ", j " << j << ", DP" << DP[i][j] << endl;
  }

  vector<int> L;
  vector<int> R;
  rep(i, Q) {
    int l, r;
    cin >> l >> r;
    L.push_back(l);
    R.push_back(r);
    // string sub = S.substr(l - 1, r - l + 1);
    // cout << "sub: " << sub << endl;
  }

  rep(i, Q) {
    // cout << "ALL: " << DP2[0] << endl;
    // cout << "pre: " << DP1[L[i] - 1] << endl;
    // cout << "next: " << DP2[R[i] - 1] << endl;
    cout << DP1[N - 1] - DP1[L[i] - 1] - DP2[R[i] - 1] << endl;
  }

  // cout << DP[0][0] << endl;
  return 0;
}


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

#define ll long long
#define ull unsigned long long

using namespace std;

int main() {
	string s, t;
	cin >> s >> t;
	
	int n = s.size();

	map<char, char> m, invm;
	for (int ii = 0; ii < n; ++ii){
		//mのチェック
		if (m[s[ii]] == 0){
			m[s[ii]] = t[ii];
		} else {
			if (m[s[ii]] != t[ii]){
				cout << "No" << endl;
				return 0;
			}
		}
		//invmのチェック
		if (invm[t[ii]] == 0){
			invm[t[ii]] = s[ii];
		} else {
			if (invm[t[ii]] != s[ii]){
				cout << "No" << endl;
				return 0;
			}
		}
	}


	cout << "Yes" << "\n";	

	return 0;
}


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

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

//infinity
#define INTINF 2000000000
#define LONGINF 2000000000

//debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

int main(){
	long long N, M;
	cin >> N >> M;
	
	long long flipped = N * M;

	if( N == 1 && M == 1 ){
		flipped = 1;
	}else if( N == 1){
		flipped = M - 2;
	}else if( M == 1){
		flipped = N - 2;
	}

	if( N != 1 && M != 1){
		flipped -= (N * 2 + M * 2 - 4);
	}


	
	cout << flipped << endl;

	return 0;
}


Measured memory_bytes: 256
from fractions import gcd
K = int(input())
from collections import defaultdict
d = defaultdict(int)
gcd_dict = dict()
for a in range(1,K+1):
  for b in range(1,K+1):
    ab = tuple(sorted([a,b]))
    d[ab] += 1
gcd_dict = defaultdict(int)
for (a,b),value in d.items():
  # print(a,b,value,"->",gcd(a,b))
  gcd_dict[gcd(a,b)] += value

res = 0
for c in range(1,K+1):
  for key,value in gcd_dict.items():
    # print(c,key)
    res += value * gcd(key,c)

print(res)

Measured memory_bytes: 80960
#include <stdio.h>

       int f(int x){
        return x*x;
    }
    int area(int d)
    {
        int i=0,a,b,c=0;
        a=600/d;
        for(i=0;i<a;i++) {
            b= d*f(i*d);
            c=c+b;
        }
        return c;
    }  
    
    
    int main(void)
    {
        int d;
        while(scanf("%d",&d)!=EOF){
            printf("%d\n",area(d));
        }
        return(0);
    }
    


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


bool solve(){
    int tx,ty;
    string s;
    cin>>s>>tx>>ty;
    int n = s.size();
    bool xmode = true;
    vector<int> xmove,ymove;
    int cnt = 0;
    int sumx=0,sumy=0;
    int init = 0;
    while(s[init]=='F')init++;
    tx -= init;

    for(int i = init; i < n; i++){
        if(s[i]=='F'){
            cnt++;
        }else{
            if(cnt>0){
                if(xmode) {
                    xmove.push_back(cnt);
                    sumx += cnt;
                } else {
                    ymove.push_back(cnt);
                    sumy += cnt;
                }
                cnt = 0;
            }
            xmode = !xmode;
        }
    }
    if(cnt>0){
        if(xmode) {
            xmove.push_back(cnt);
            sumx += cnt;
        } else {
            ymove.push_back(cnt);
            sumy += cnt;
        }
    }

    if((sumx-tx)&1) {
        return false;
    }
    if((sumy-ty)&1) return false;
    int needx = (sumx-tx)/2;
    int needy = (sumy-ty)/2;
    bool dpx[8010]={true},dpy[8010]={true};
    for(auto plusx : xmove){
        for(int i = needx; i>=0; i--){
            if(dpx[i]) dpx[i+plusx] = true;
        }
    }
    for(auto plusy : ymove){
        for(int i = needy; i>=0; i--){
            if(dpy[i]) dpy[i+plusy] = true;
        }
    }

    return dpx[needx] && dpy[needy];
}

int main(void){

    cout<<(solve() ? "Yes" : "No")<<endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i,N) for(int i=0;i<(N);i++)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
using namespace std;
const long long MOD = 1e9 + 7;
const long long INF = 1e12;
const int inf = 1e9;
typedef long long ll;
typedef pair<ll,int> P;
typedef set<int> S;
int h,n;
int main(){
    cin>>h>>n;
    vector<int> a(n,0),b(n,0);
    rep(i,n) cin>>a[i]>>b[i];
    vector<int> dp(h+1,inf);
    //配るDP
    dp[0]=0;
    for(int i=0;i<n;i++){
        for(int j=0;j<h+1;j++){
            int nj = min(j+a[i],h);
            dp[nj]=min(dp[nj],dp[j]+b[i]);
        }
    }
    /*
    rep(i,n+1){
        rep(j,h+1) cout<<dp[i][j]<<" ";
        cout<<endl;
    }*/
    cout<<dp[h]<<endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
typedef long long T;
 
struct point { 
    T x,y;
    int i; 
    point operator - (const point &rhs) {
        return {x-rhs.x, y-rhs.y, 0};
    }
    T dot(const point &rhs) {
        return x*rhs.x + y*rhs.y;
    }
    T cross(const point &rhs) {
        return x*rhs.y - y*rhs.x;
    }
    T len2() {
        return x*x + y*y;
    }
};
 
int compare(T x, T y) {
    if(y-x > 0) return -1;
    if(x-y > 0) return 1;   
    return 0;
}
 
T cross(point p, point q, point r) { return (r-q).cross(p-q); }
 
int turn(point p, point q, point r) { return compare(cross(p,q,r), 0); }
 
int cw(point p, point q, point r) { return turn(p,q,r) < 0; }
 
 /*
double angle(point p, point q, point r) 
{
    point v = r - q;
    point u = p - q;
    return acos(v.dot(u) / sqrt(v.len2() * u.len2())); 
}
*/
T dot(point p, point q) { return p.x * q.x + p.y * q.y; }
// modulo^2 de un punto (distance to origin)
double norm2(point p) { return p.x * p.x + p.y * p.y; }


double angle(point a, point o, point b) // angle AOB (radians)
{
   point u = {a.x - o.x, a.y - o.y}; // u: vector oa
   point v = {b.x - o.x, b.y - o.y}; // v: vector ob
   return acos(dot(u,v) / sqrt(norm2(u) * norm2(v))); // dot product
}

 
bool cmp(const point &p, const point &q)
{
    return p.x < q.x || (p.x == q.x && p.y < q.y);
}
 
vector<point> convex_hull(vector<point> &p)
{
    int n = (int)p.size(), k = 0;
    vector<point> h(2 * n);
    sort(p.begin(), p.end(), cmp);
    for(int i = 0; i < n; i++) 
    {
        while(k >= 2 && cw(h[k-2], h[k-1], p[i])) k--;
        h[k++] = p[i];
    }
    for(int i = n - 2, t = k + 1; i >= 0; i--) 
    {
        while(k >= t && cw(h[k-2], h[k-1], p[i])) k--;
        h[k++] = p[i];
    }
    h.resize(k); h.pop_back(); 
    return h;
}
 
int main()
{
    ios_base::sync_with_stdio(false); cin.tie(0);
    cout << fixed << setprecision(10);
    int n,m;
    vector<point> p,h;
    double ans[105];
    while(cin >> n)
    {
        p = vector<point>(n);
        for(int i = 0; i < n; i++)
        {
            cin >> p[i].x >> p[i].y;
            p[i].i = i;
        }
        h = convex_hull(p);
        for(int i = 0; i < n; i++)
            ans[i] = 0;
        m = h.size();
        for(int i = 0; i < m; i++)
            ans[h[i].i] = (M_PI - angle(h[(i-1+m)%m], h[i], h[(i+1)%m])) / (2*M_PI);
        for(int i = 0; i < n; i++)
            cout << ans[i] << '\n';
    }
    return 0;
} 

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int dis[2004];
int main(){
	int n,x,y;
	int tmp;
	scanf("%d%d%d",&n,&x,&y);
	for(int i=1;i<=n;i++){
		for(int j=i+1;j<=n;j++){
			tmp=min(j-i,abs(x-i)+abs(j-y)+1);
			tmp=min(tmp,abs(j-x)+abs(y-i)+1);
			dis[tmp]++;
		}
	}
	for(int i=1;i<=n-1;i++)printf("%d\n",dis[i]);
}

Measured memory_bytes: 384
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Scanner;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        Scanner in = new Scanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        EBomber solver = new EBomber();
        solver.solve(1, in, out);
        out.close();
    }

    static class EBomber {
        public void solve(int testNumber, Scanner in, PrintWriter out) {
            // 入力
            int h = Integer.parseInt(in.next());
            int w = Integer.parseInt(in.next());
            int m = Integer.parseInt(in.next());
            int[] hm = new int[m];
            int[] wm = new int[m];
            int[] rowcnt = new int[h];
            int[] colcnt = new int[w];
            for (int i = 0; i < m; i++) {
                hm[i] = Integer.parseInt(in.next()) - 1;
                wm[i] = Integer.parseInt(in.next()) - 1;
                rowcnt[hm[i]]++;
                colcnt[wm[i]]++;
            }
            int ymax = 0;
            for (int i = 0; i < h; i++) {
                ymax = Math.max(ymax, rowcnt[i]);
            }
            int xmax = 0;
            for (int j = 0; j < w; j++) {
                xmax = Math.max(xmax, colcnt[j]);
            }
            int yc = 0;
            for (int i = 0; i < h; i++) {
                if (rowcnt[i] == ymax) yc++;
            }
            int xc = 0;
            for (int j = 0; j < w; j++) {
                if (colcnt[j] == xmax) xc++;
            }
            long cnt = (long) xc * yc;
            for (int i = 0; i < m; i++) {
                if (rowcnt[hm[i]] + colcnt[wm[i]] == xmax + ymax) {
                    cnt--;
                }
            }
            out.println(cnt == 0 ? xmax + ymax - 1 : xmax + ymax);
        }

    }
}



Measured memory_bytes: 65056
#include <stdio.h>

int u[101] = {0};
int d[101] = {0};
int f[101] = {0};
int next[101][101] = {0};

int cost = 1;

int top = 0;
int s[101];
 
void push(int x) {
  top++;
  s[top] = x;
}
 
int pop() {
  top--;
  return s[top + 1];
}

int next_look(int r) {
  int i = 0;
  int rr;
  for (i = 0; i < 101; i++) {
    if ((next[r][i] != 0) && (d[next[r][i]] == 0)) {
      return next[r][i];
    }
  }
  pop();
  f[r] = cost++;
  return 0;
}

void depth_first_search(int v) {
  int rr = v;
  int ll;
  push(rr);
  d[rr] = cost++;
    while (top >= 1) {
      ll = next_look(rr);
      if (ll == 0) {
	rr = s[top];
      }
      else {
	d[ll] = cost++;
	push(ll);
	rr = ll;
      }
    }
}

int main(void) {
  int n;
  int k;
  //int rr;
  //int ll;
  
  scanf("%d", &n);
  
  for (int i = 1; i <= n; i++) {
    scanf("%d", &u[i]);
    scanf("%d", &k);
    for (int j = 0; j < k; j++) {
      scanf("%d", &next[u[i]][j]);
    }
  }

  for (int i = 1; i <= n; i++) {
    if (f[i] == 0)
      depth_first_search(i);
  }

  for (int i = 1;i <= n; i++) { 
    printf("%d %d %d\n", u[i], d[i], f[i]);
  }

  return 0;
}


Measured memory_bytes: 2104
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <stack>
#include <queue>
#include <set>
#include <map>
using namespace std;
#define MOD @
#define ADD(X,Y) ((X) = ((X) + (Y)%MOD) % MOD)
typedef long long i64; typedef vector<int> ivec; typedef vector<string> svec;

int N, K;
int dp[1 << 21][21];
int ans[1 << 21];

int genmask(int head, int tail, int hlen, int tlen)
{
	return (head | (tail << hlen)) | (1 << (hlen + tlen));
}

int ctzs[1 << 20];

int getctz(int v)
{
	return ctzs[v & ((1 << N) - 1)];
	//return __builtin_ctz(v);
}

void propagate(int mask, int pos)
{
	if (dp[mask][pos] == 0) return;

	int dpv = dp[mask][pos];

	int len = sizeof(int) * 8 - __builtin_clz(mask) - 1;
	//printf("%d\n", len);
	mask ^= 1 << len;

	int head = mask & ((1 << pos) - 1);
	int tail = mask >> pos;

	int zero = getctz(~tail), one = getctz(tail);
	int hlen = pos;
	int tlen = len - pos;
	//printf("%d (t %d) %d %d: %d [%d %d]\n", mask, tail, len, pos, dp[mask][pos], zero, one);

	if (zero < tlen) {
		//printf("->(0) %d, %d [%d]\n", genmask(head, tail >> (zero + 1), hlen + 1, tlen - (zero + 1)), hlen + 1, dpv);
		dp[genmask(head, tail >> (zero + 1), hlen + 1, tlen - (zero + 1))][hlen + 1] += dpv;
	}
	if (one < tlen) {
		//printf("->(1) %d, %d\n", genmask(head | (1 << hlen), tail >> (one + 1), hlen + 1, tlen - (one + 1)), hlen + 1);
		dp[genmask(head | (1 << hlen), tail >> (one + 1), hlen + 1, tlen - (one + 1))][hlen + 1] += dpv;
	}
	// summarize
	ans[head | (1 << pos)] += dpv;
}

char S[1100000];

int bitflip(int v, int l)
{
	int ret = 0;
	for (int i = 0; i < l; ++i) {
		ret |= ((v >> (l - 1 - i)) & 1) << i;
	}
	return ret;
}

int main()
{
	scanf("%d%d", &N, &K);

	for (int i = 0; i <= N; ++i) {
		scanf("%s", S);
		for (int j = 0; j < (1 << i); ++j) {
			if (S[j] == '1') {
				dp[j | (1 << i)][0] += 1;
			}
		}
	}

	ctzs[0] = 31;
	for (int i = 1; i < (1 << N); ++i) {
		int cnt = 0;
		int v = i;
		while ((v & 1) == 0) {
			v >>= 1;
			++cnt;
		}
		ctzs[i] = cnt;
	}

	for (int i = 0; i <= N; ++i) {
		for (int j = 0; j < (2 << N); ++j) {
			propagate(j, i);
		}
	}

	int ret = 0, rlen = 0;

	for (int len = 0; len <= N; ++len) {
		for (int m = 0; m < (1 << len); ++m) {
			//printf("%d %d: %d\n", m, len, ans[m + (1 << len)]);
			if (ans[m + (1 << len)] >= K) {
				//printf("%d %d\n", m, len);
				//int mf = bitflip(m, len);
				if (rlen < len) {
					ret = m;
					rlen = len;
				} else if (rlen == len) {
					ret = min(ret, m);
				}
			}
		}
	}

	for (int i = rlen - 1; i >= 0; --i) printf("%c", ((ret >> i) & 1) + '0');
	puts("");

	return 0;
}

Measured memory_bytes: 185728
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <string>
#include <cstring>
#include <vector>
#include <iostream>
#include <queue>
#include <unordered_map>
#include <cmath>
#include <queue>
#include <string>
#include <random>
using namespace std;
typedef long long ll;
const int maxn = 100005;



int main() {
#ifdef suiyuan2009
  freopen("/Users/suiyuan2009/CLionProjects/icpc/input.txt", "r", stdin);
  //freopen("/Users/suiyuan2009/CLionProjects/icpc/input.txt", "w", stdout);
#endif
  int n,k;
  cin>>n>>k;
  if((n + 1)/2 <k)cout<<"NO"<<endl;
  else cout<<"YES"<<endl;
  return 0;
}

Measured memory_bytes: 764
# import sys
# import math #sqrt,gcd,pi
# import decimal
# import queue # queue
# import bisect
# import heapq # priolity-queue
# import time
# from itertools import product,permutations,\
#     combinations,combinations_with_replacement
# 重複あり順列、順列、組み合わせ、重複あり組み合わせ
# import collections # deque
# from operator import itemgetter,mul
# from fractions import Fraction
# from functools import reduce

mod = int(1e9+7)
# mod = 998244353
INF = 1<<50

def readInt():
    return list(map(int,input().split()))

def main():
    h,w = readInt()
    a = [input() for i in range(h)]
    H = []
    W = []
    for i in range(h):
        f = True
        for j in range(w):
            if a[i][j]=='#':
                f = False
                break
        if f:
            H.append(i)
    for i in range(w):
        f = True
        for j in range(h):
            if a[j][i]=='#':
                f = False
                break
        if f:
            W.append(i)
    ans = []
    for i in range(h):
        if i in H:
            continue
        x = []
        for j in range(w):
            if j in W:
                continue
            x.append(a[i][j])
        ans.append(x)
    for i in range(len(ans)):
        print(''.join(ans[i]))
    return

if __name__=='__main__':
    main()


Measured memory_bytes: 3188
using System;
using System.Linq;

namespace ABC115_C
{
    class Program
    {
        static void Main(string[] args)
        {
            var NK = Console.ReadLine().Split().Select(int.Parse).ToArray();
            var N = NK[0];
            var K = NK[1];
            var h = new int[N];

            for (int i = 0; i < N; i++)
            {
                h[i] = int.Parse(Console.ReadLine());
            }

            Array.Sort(h);

            var min = int.MaxValue;
            for (int i = 0; i + K <= N; i++)
            {
                min = Math.Min(min, h[i + K - 1] - h[i]);
            }

            Console.WriteLine(min);
        }
    }
}


Measured memory_bytes: 17632
#include<bits/stdc++.h>
using namespace std;
string a,b;
int main()
{
	getline(cin,a);
	getline(cin,b);
	sort(b.begin(),b.end(),greater<char>()); 
    sort(a.begin(),a.end());
	if(a<b)	cout<<"Yes"<<endl;
	else	cout<<"No"<<endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
using namespace std;
int main()
{
  long int N;
  long int A;
  long int B;
  
  cin >> N;
  cin >> A;
  cin >> B;
  if((A+B)%2==0){
    cout << (B-A)/2;
  }else if((N-B)<(A-1)){
	cout << N-B+1+(B-A-1)/2;
  }else{
    cout << A-1+1+(B-A-1)/2;
  }
}


Measured memory_bytes: 256
using System;
namespace Ino{
    class Ino{
        static void Main(){
            string[] n_q = Console.ReadLine().Split(' ');
            int n = int.Parse(n_q[0]);
            int q = int.Parse(n_q[1]);
            char[] s = Console.ReadLine().ToCharArray();
 
            int[] a = new int[n+1];
            a[0] = 0;
            for(int i=1;i<n;i++){
                if(s[i-1]=='A' && s[i]=='C'){
                    a[i]=a[i-1]+1;
                }
                else{
                    a[i]=a[i-1];
                }
            }
            a[n]=a[n-1];
 
            for(int i=0;i<q;i++){
                string[] l_r = Console.ReadLine().Split(' ');
                int l = int.Parse(l_r[0]);
                int r = int.Parse(l_r[1]);
                Console.WriteLine(a[r-1]-a[l-1]);
            }
        }
    }
}

Measured memory_bytes: 16584
#include<bits/stdc++.h>
#define rep(i,j,k) for(int i=j;i<=k;i++)
using namespace std;
template<typename T> void read(T &num){
	char c=getchar();T f=1;num=0;
	while(c<'0'||c>'9'){if(c=='-')f=-1;c=getchar();}
	while(c>='0'&&c<='9'){num=(num<<3)+(num<<1)+(c^48);c=getchar();}
	num*=f;
}
template<typename T> void qwq(T x){
	if(x>9)qwq(x/10);
	putchar(x%10+'0');
}
template<typename T> void write(T x){
	if(x<0){x=-x;putchar('-');}
	qwq(x);putchar('\n');
}

int main(){
	int n,m;read(n);read(m);
	puts((n==m)?"Yes":"No");
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repr(i, n) for (int i = (int)(n); i >= 0; i--)
#define REP(i, m, n) for (int i = (int)(m); i <= (int)(n); i++)
#define all(v) v.begin(), v.end()
typedef long long ll;

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

const long long INF = 1LL << 60;

int main(){
  string s;
  cin >> s;

  int cnt = 0;
  rep(i, s.size()){
    if(s[i] == '1') cnt++;
  }

  cout << cnt << endl;

  return 0;
}


Measured memory_bytes: 256
fun main(arr:Array<String>) {
    val s = readLine()!!
    numbers.addAll(s.map { it.toString().toInt() })
    val ans = getAns(0, 0L, 0L)
    println(ans)
}

fun getAns(index:Int, subTotal:Long, prev:Long):Long {
    if(index >= numbers.size) {
        return subTotal + prev
    }
    var ret = getAns(index+1, subTotal + prev, numbers[index].toLong())
    if(index > 0) {
        ret += getAns(index+1, subTotal, prev*10+numbers[index])
    }
    return ret
}
val numbers = mutableListOf<Int>()

Measured memory_bytes: 33684
#include <iostream>
#include <stdio.h>
#include <math.h>
#include <time.h>
#include <algorithm>
#include <cmath>
#include <vector>
#include <regex> //正規表現
#include <map>
#include <set>
#include <cassert> //assart
#include <numeric>

using namespace std;
#define ll long long int
#define FOR(i,min,max) for(int i=(min);i<(max);i++)
#define FOReq(i,min,max) for(int i=(min);i<=(max);i++)
#define FORREV(i,max,min) for(int i=(max)-1;i>=(min);i--)
#define FORREVeq(i,max,min) for(int i=(max);i>=(min);i--)
const int  MOD=1e9+7;
const int  INF=2000000000;
const int INF2=  10000000;
const double  Micro=1e-5;

int UnUsedVariable(){
    if(INF || Micro || MOD || INF2){;}
    return 0;
}

#define pf printf
#define sf scanf
#define inarray(array,min,max) FOR(i,min,max){cin>>array[i];}
#define inarrayW(arrayA,arrayB,min,max) FOR(i,min,max){cin>>arrayA[i]>>arrayB[i];}
inline int isEven(int x){return x%2==0;}
inline int isOdd (int x){return x%2==1;}
#define br printf("\n");
#define OutputAndReturn0(x) {cout<<(x)<<endl;return 0;}

int EintN(int array[],const int num){
    for(int i=0;i<num;i++){printf("%d ",array[i]);}
    br;
    return 0;
}
int EintNN(const int heighth,const int width,int array[heighth][width]){
    FOR(i, 0, heighth){
        FOR(k, 0, width){
            {printf("%d ",array[i][k]);}
        }
        br;
    }
    br;
    return 0;
}
int E(string str,const int num){
    cerr<<str<<" is "<<num<<" now."<<endl;
    return 0;
}
//#define int long long int

/*
 1.困った時こそ冷静に問題文を見直す！制約条件を見ろ！乱択アルゴリズムとかO(N^3)とか！
 2.一度に大量のことをやろうとしない。デバッグしやすいように細かく！
 3.プログラミングは半分数学だし、もう半分は数学ではない！
 4.できない問題はできない！！！！！
 */

int experiment(){
    int ans;ans=0;
    int N,K;cin>>N>>K;
    K=min(K,2*N);
    
    int V[N+2];inarray(V, 1, N+1);V[0]=0;V[N+1]=0;
    
    int fore[N+2],back[N+2];
    fore[0]=0;
    FOR(i, 1, N+2){
        fore[i]=fore[i-1]+V[i];
    }
    back[0]=0;
    FOR(i,1,N+2){
        back[i]=back[i-1]+V[N+1-i];
    }
    
    //EintN(fore, N+2);
    //EintN(back, N+2);
    
    //K回取り出した時の最大値

    
    //K-a回取り出してa回入れた時の最大値
    
    
    
    vector<int> sortArray;
    int maxget=min(N,K);
    FOReq(getnum, 0, maxget){
        int MAXpush=min(maxget,K-getnum);
        FOReq(leftget, 0, getnum){
            int SumOfGet=fore[leftget]+back[getnum-leftget];
            
            FOReq(i,1, leftget){sortArray.push_back(V[i]);}
            FOReq(i,1, getnum-leftget){sortArray.push_back(V[(N+1)-i]);}
            sort(sortArray.begin(), sortArray.end());
            int MinusNum=(lower_bound(sortArray.begin(), sortArray.end(), 0) )-(sortArray.begin()); // 0 -- getnum(=N)
            
            int SumOfRemove=0;
            FOR(i, 0, min(MinusNum,MAXpush)){
                SumOfRemove+=sortArray[i];
            }
            
            ans=max(ans,SumOfGet-SumOfRemove);
            //cout<<"getnum is "<<getnum<<".  leftget is "<<leftget<<".  SumOfGet is"<<SumOfGet<<".  SumOfRemove is "<<SumOfRemove<<".  ans is "<<ans<<"."<<endl;
            
        sortArray.clear();
        }
    }
    
    
    
    //E("ans",ans);
    OutputAndReturn0(ans);
    return 0;
}
signed main(){
    assert(1);
    experiment();
    return 0;
}



Measured memory_bytes: 256
fn main() {
    let n: usize = atcoder::read_single_num();
    let k: usize = atcoder::read_single_num();
    let x: usize = atcoder::read_single_num();
    let y: usize = atcoder::read_single_num();

    let cost = if k < n {
        k * x + (n - k) * y
    } else {
        n * x
    };

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

#[allow(dead_code)]
mod atcoder {
    pub fn read_single_num<T: ::std::str::FromStr>() -> T
        where <T as ::std::str::FromStr>::Err: ::std::fmt::Debug {
            let mut buffer = String::new();
            ::std::io::stdin().read_line(&mut buffer).unwrap();
            buffer.trim().parse().unwrap()
    }

    pub fn read_multiple_num<T: ::std::str::FromStr>() -> Vec<T>
        where <T as ::std::str::FromStr>::Err: ::std::fmt::Debug {
            let mut buffer = String::new();
            ::std::io::stdin().read_line(&mut buffer).unwrap();
            buffer.split_whitespace().map(|i| i.parse().unwrap() ).collect()
    }

    pub fn read_single_string() -> String {
            let mut buffer = String::new();
            ::std::io::stdin().read_line(&mut buffer).unwrap();
            buffer.trim().to_string()
    }

    pub fn read_multiple_string() -> Vec<String> {
            let mut buffer = String::new();
            ::std::io::stdin().read_line(&mut buffer).unwrap();
            buffer.split_whitespace().map(|s| s.to_string() ).collect()
    }
}

Measured memory_bytes: 380
import scala.io.StdIn._
object Main extends App {
  val Array(n, m, d) = readLine.split(" ").map(_.toLong)
  val ans = Double.box((n - d).toDouble * (if (d == 0) 1 else 2) / (n * n) * (m - 1))
  println(String.format("%1$.10f", ans))
}

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

int main() {
    ios::sync_with_stdio(false);
    ll N;
    cin >>N;
    vector<queue<ll>> vq(N);
    for(int i=0;i<N;i++)for(int j=0;j<N-1;j++){
        ll A;
        cin >> A;
        --A;
        vq[i].push(A);
    }

    ll remain = N*(N-1);
    ll ans =0;
    while(remain){
        vector<bool> skip(N,false);
        bool changed = false;
        for(int i=0;i<N;i++){
            if(skip[i]){
                continue;
            }
            if(!vq[i].empty()){

                ll t = vq[i].front();
                // cerr <<"i=" <<i <<" t = " << t << endl;
                if(vq[t].front() ==i && !skip[t]){
                    remain -=2;
                    changed = true;
                    skip[t] = true;
                    skip[i] = true;
                    vq[t].pop();
                    vq[i].pop();
                }
            }
        }
        if(!changed){
            cout <<-1 << endl;
            return 0;
        }

        ans++;
    }
    cout << ans << endl;



    return 0;
}

Measured memory_bytes: 12280