akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
#include<ctype.h>
# define pb push_back
#define fst first
#define sec second
#define For(i,a,b) for(int i=a;i<b;i++)
#define ll long long int
#define ull unsigned long long int
#define mod 1000000007
#define fo(i,n) for(ll i=0;i<n;i++)
#define endl "\n"
#define rev(i,n) for(ll i=n-1;i>=0;i--)
#define fo1(i,n) for(ll i=1;i<=n;i++)
using namespace std;
template<typename T>
void showvector(vector <T> v)
{
    for(T x:v)
        cout<<x<<" ";
    cout<<endl;

}
template<typename T>
void showset(set <T> s)
{
    for(T x: s)
        cout<<x<<" ";
    cout<<endl;
}
template<class T>
void showvectorpair(vector<T> v)
{
    for(auto it=v.begin();it!=v.end();it++)
        cout<<it->first<<" "<<it->second<<endl;
    cout<<endl;
}
template<typename T,typename P>
void showmap(map <T,P> m)
{
    for(auto it=m.begin();it!=m.end();it++)
        cout<<it->first<<" "<<it->second<<endl;
    cout<<endl;
}
template<typename T>
bool comp(T a,T b)
{
    return (a>b);
}
template<class T>
bool comppair(T a,T b)
{
    if(a.first==b.first)
        return(a.second>b.second);
    return (a.first>b.first);
}
bool sameparity(ll a,ll b)
{
    return (a%2==b%2);
}
bool difparity(ll a,ll b)
{
    return !(a%2==b%2);
}
bool isprime(ll x)
{
    for(ll i=2;i<=sqrt(x);i++)
    {
        if(x%i==0)
            return false;
    }
    return true;
}
bool iseven(ll x)
{
    return !(x%2);
}
bool isodd(ll x)
{
    return (x%2);
}
void fun()
{

}
/// check for test case before submitting
void vfun()
{
    ll n,k;
    cin>>n;
    vector <ll> v(n);
    fo(i,n)
    cin>>v[i];

}

int main()
{
    #ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
    #endif
    ios_base::sync_with_stdio(0); ///cant use scanf, printf
    cin.tie(0);cout.tie(0); /// no longer auto flush cout before each cin, remove for interactive
    //cout << fixed << setprecision(11); /// no scientific output
    ll test=1;
   // cin>>test;
    while(test--)
    {
        string s;
        cin>>s;
        ll n=s.size();
        stack <char> st;
        fo(i,n)
        {
            if(s[i]=='B')
            {
                if(!st.empty())
                    st.pop();
            }
            else
                st.push(s[i]);
        }
        s="";
        while(!st.empty())
        {
            s+=st.top();
            st.pop();
        }
        reverse(s.begin(),s.end());
        cout<<s<<endl;
        //fun();
     //   vfun();
//         if(vfun())
//            cout<<"YES\n";
//         else
//            cout<<"NO\n";
    }
}
///before sub
/// check for value of zero and single input in array
///loop vars,1LL in mult, equal, one, bounds, int v ll, endl, finish taking inputs
/// check whether test cases are given or not



Measured memory_bytes: 3684
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <cmath>
#include <stdio.h>
#include <queue>
#include <deque>
#include <cstdio>
#include <set>
#include <map>
#include <bitset>
#include <stack>
#include <cctype>
using namespace std;
long long t[100010], a[100010];
long long y[100010] = { 0 };
int main() {
	int n;
	cin >> n;
	for (int i = 0; i < n; i++) {
		cin >> t[i];
	}
	for (int i = 0; i < n; i++) {
		cin >> a[i];
	}
	if (t[n - 1] != a[0]) {
		cout << "0" << endl;
		return 0;
	}
	
	y[0] = t[0];
	y[n - 1] = a[n - 1];
	for (int i = 1; i < n; i++) {
		if (t[i - 1] != t[i]) {
			if (a[i - 1] != a[i]) {
				cout << "0" << endl;
				return 0;
			}
			if (y[i] != 0 && y[i] != t[i]) {
				cout << "0" << endl;
				return 0;
			}
			y[i] = t[i];
		}
	}
	for (int i = n - 1; i >= 1; i--) {
		if (a[i - 1] != a[i]) {
			if (t[i-1] != t[i]) {
				cout << "0" << endl;
				return 0;
			}
			if (y[i - 1] != 0 && y[i - 1] != a[i - 1]) {
				cout << "0" << endl;
				return 0;
			}
			y[i - 1] = a[i - 1];
		}
	}
	long long ans = 1;
	for (int i = 0; i < n; i++) {
		if (y[i] == 0) {
			ans = ans * min(a[i], t[i]) % 1000000007;
		}
		else if (y[i] > min(a[i], t[i])) {
			cout << "0" << endl;
			return 0;
		}
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 2560
#include<bits/stdc++.h>
using namespace std;
int main(){
  string s;int k;cin>>s;cin>>k;
  int n=s.size();
  set<string>v;
  for(int i=0;i<k;i++){
    for(int j=0;j<n-i;j++){
      v.insert(s.substr(j,i+1));
    }
  }
  auto itr=v.begin();
  for(int i=0;i<k-1;i++) itr++;
  cout<<*itr<<endl;
}
  

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

using namespace std;
#define X first
#define Y second
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<vi> vvi;

#define debug(x) cerr << #x << " = " << (x) << endl;
template<typename T>
ostream& operator<<(ostream& o, vector<T>& v) {
    for (auto& x : v) o << x << ' ';
    return o;
}

const int MAXN = 1e5 + 5;
int n, w;
int arr[MAXN];
int val[MAXN];
ll memo[105][MAXN];
ll dp(int i, int v) {
  ll &res = memo[i][v];
  if (res != -1) return res;
  if (i == n) {
    if (v == 0) return res = 0;
    return res = LLONG_MAX / 2;
  }
  res = dp(i+1, v);
  if (val[i] <= v) {
    res = min(res, dp(i+1, v - val[i]) + arr[i]);
  }
  return res;
}

int main(){
    std::ios_base::sync_with_stdio(false); cin.tie(0);
    cin >> n >> w;
    for (int i = 0; i < n; i++)
      cin >> arr[i] >> val[i];
    memset(memo, -1, sizeof memo);
    int maxval = -1;
    for (int v = 0; v <= accumulate(val, val + n, 0); v++) {
      if (dp(0, v) <= w) {
        maxval = max(maxval, v);
      }
    }
    cout << maxval << endl;
}


Measured memory_bytes: 82304
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int a,b,c;
    cin>>a>>b>>c;
    int count=0;
    for(int i=a;i<=b;i++)
    {
        if(i%c==0)count++;
    }
    cout<<count<<endl;
    return 0;
}


Measured memory_bytes: 3508
#include <bits/stdc++.h>
using namespace std;
//Author: Ezio Sam
/* Shorthands */
#define ll long long
#define pb push_back
#define em emplace_back
#define mp make_pair
#define sp " "
#define cs "Case "
#define fi first
#define sn second

/* STL */
#define mem(a,n) memset(a, n, sizeof(a));
#define all(x) x.begin(),x.end()
#define alr(x) x.rbegin(),x.rend()
#define sz(x)  (int)x.size()
#define mx(v)  *max_element(v.begin(),v.end())
#define mxi(v) distance(v.begin(),max_element(v.begin(),v.end()))
#define mxa(a) *max_element(a, a.size())
#define r(a)   reverse(a.begin(),a.end())
/* loops */
#define fr(i,n)   for(__typeof(n) i=0;i<(n);i++)
#define fn(i,n)   for(__typeof(n) i=1;i<=(n);i++)
/*Special*/
#define Ezio ios::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define db(something)  cerr<<#something<<" - "<<something<<"\n";

int main()
{

   Ezio
   ll t,m,n,x,a,b;
   string s;

   cin>>n;

   if(n>=400 and n<600){
    cout<<8<<endl;
   }
   if(n>=600 and n<800){
    cout<<7<<endl;
   }
   if(n>=800 and n<1000){
    cout<<6<<endl;
   }
   if(n>=1000 and n<1200){
    cout<<5<<endl;
   }
   if(n>=1200 and n<1400){
    cout<<4<<endl;
   }
   if(n>=1400 and n<1600){
    cout<<3<<endl;
   }
   if(n>=1600 and n<1800){
    cout<<2<<endl;
   }
   if(n>=1800 and n<2000){
    cout<<1<<endl;
   }

   return 0;
}


Measured memory_bytes: 3552
#!/usr/bin/env python3

import sys
# import math
# import re                                    # re.compile(pattern) => ptn obj; p.search(s), p.match(s), p.finditer(s) => match obj; p.sub(after, s)
# from collections import deque                # deque class. deque(L): dq.append(x), dq.appendleft(x), dq.pop(), dq.popleft(), dq.rotate()
# from collections import defaultdict          # subclass of dict. defaultdict(facroty)
# from collections import Counter              # subclass of dict. Counter(iter): c.elements(), c.most_common(n), c.subtract(iter)
# from heapq import heapify, heappush, heappop # built-in list. heapify(L) changes list in-place to min-heap in O(n), heappush(heapL, x) and heappop(heapL) in O(lgn).
# from heapq import nlargest, nsmallest        # nlargest(n, iter[, key]) returns k-largest-list in O(n+klgn).
# from itertools import count, cycle, repeat   # count(start[,step]), cycle(iter), repeat(elm[,n])
# from itertools import groupby                # [(k, list(g)) for k, g in groupby('000112')] returns [('0',['0','0','0']), ('1',['1','1']), ('2',['2'])]
# from itertools import starmap                # starmap(pow, [[2,5], [3,2]]) returns [32, 9]
# from itertools import product                # product(iter, repeat=n)
# from itertools import accumulate             # accumulate(iter[, f])
# from functools import reduce                 # reduce(f, iter[, init])
# from functools import lru_cache              # @lrucache ...arguments of functions should be able to be keys of dict
# from bisect import bisect_left, bisect_right # bisect_left(a, x, lo=0, hi=len(a)) returns i such that all(val<x for val in a[lo:i]) and all(val>-=x for val in a[i:hi]).
# from copy import deepcopy                    # to copy multi-dimentional matrix without reference
# from fractions import gcd                    # for Python 3.4


def main():
    mod = 1000000007                  # 10^9+7
    inf = float('inf')
    sys.setrecursionlimit(10**6)    # 1000 -> 1000000
    def input(): return sys.stdin.readline().rstrip()
    def ii():  return int(input())
    def mi():  return map(int, input().split())
    def mi_0(): return map(lambda x: int(x)-1, input().split())
    def lmi(): return list(map(int, input().split()))
    def lmi_0(): return list(map(lambda x: int(x)-1, input().split()))
    def li():  return list(input())
    
    
    n = ii()
    p = lmi()
    q = sorted(p)
    cnt = 0
    for i in range(n):
        if p[i] != q[i]:
            cnt += 1
    print('YES') if cnt == 0 or cnt == 2 else print('NO')

if __name__ == "__main__":
    main()

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

using namespace std;
#define sqr(x) ((x)*(x))
#define cube(x) ((x)*(x)*(x))
#define GCD(a, b) __gcd(a, b)
#define LCM(a, b) ((a)*(b)/GCD(a,b))
#define MP make_pair
#define n1 first
#define n2 second
#define PII pair<int,int>
#define PLL pair<ll,ll>
#define SI set<int>
#define SL set<ll>
#define MS multiset
#define MSI multiset<int>
#define MSLL multiset<ll>
#define PB push_back
#define PF push_front
#define VI vector<int>
#define VPI vector<pair<int,int>>
#define VLL vector<ll>
#define SZ(x) ((int)x.size())

typedef long long ll;

typedef unsigned long long ull;
typedef long double ld;
typedef double db;
const int INF = 1e9;
const int MOD = 1000000007;
const int N = 202055;
const int M = 1211;

void solve() {
    int n, k;
    cin >> k >> n;

    set <int> s;
    for (int i = 1; i <= n; i++){
        int x;
        cin >> x;
        s.insert(x);
    }

    for (int i = k; i <= 1e6; i++){
        int x = i;
        string str;
        while (x > 0){
            str += x % 10 + '0';
            x /= 10;
        }
        int cnt = 0;
        for (int j = 0; j < SZ(str); j++){
            int y = str[j]-'0';
            if (!s.count(y)) cnt++;
        }
        if (cnt == SZ(str)){
            cout << i;
            return;
        }
    }

}

int main() {
    ios_base::sync_with_stdio(false);

    int T = 1;
    //cin >> T;

    while (T--){
        solve();
    }

    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <limits.h>
 
using namespace std;
 
int main(){
    int n,tmp,min=INT_MAX,max=INT_MIN;
    scanf("%d",&n);
    for(int i = 0; i < n; i++){
        scanf("%d",&tmp);
        if(max < tmp-min) max = tmp - min;
        if(min > tmp) min = tmp;
    }
    printf("%d\n",max);
    return 0;
}


Measured memory_bytes: 2764
from copy import deepcopy
N, M, Q = map(int, input().split())
a, b, c, d = [], [], [], []
for i in range(Q):
    tmp = list(map(int, input().split()))
    a.append(tmp[0])
    b.append(tmp[1])
    c.append(tmp[2])
    d.append(tmp[3])

ans = 0
def dfs(A):
    global ans
    if len(A) == N + 1:
        now = 0
        for i in range(Q):
            if A[b[i]] - A[a[i]] == c[i]:
                now += d[i]
        ans = max(ans, now)
        return

    A.append(A[-1])
    while A[-1] <= M:
        dfs(deepcopy(A))
        A[-1] += 1

dfs([1])
print(ans)

Measured memory_bytes: 86696
#include <algorithm>
#include <iostream>
#include <vector>

using namespace std;

int main(){

        int n, l;
        int ans = 0;
        vector<int> v, v2;

        cin >> n ;
        for(int i=0; i<n; i++){
                cin >> l;
                v.push_back(l);
                v2.push_back(l);
        }

        sort(v2.begin(), v2.end());
        v2.erase(unique(v2.begin(), v2.end()), v2.end());

        for(int i=0; i< v2.size(); i++){
                for(int j=i+1; j< v2.size(); j++){
                        for(int k=j+1; k< v2.size(); k++){
                                if(v2[i]+v2[j] > v2[k] and v2[i]+v2[k] > v2[j] and v2[j]+v2[k] > v2[i]){
                                        ans = ans + (count(v.begin(), v.end(), v2[i]) * count(v.begin(), v.end(), v2[j]) * count(v.begin(), v.end(), v2[k]));
                                }
                        }
                }
        }
        cout << ans << endl;

}

Measured memory_bytes: 3644
#include<iostream>

using namespace std;

int A[20], N;

bool exhaustiveSearch(int m, int s, int n){
    if(n==N+1) return false;//it's over
    if(s==m) return true;

    int next = n+1;
    if (exhaustiveSearch(m,s,next)) {
        return true;
    }else
    {
        s+=A[n];
        return exhaustiveSearch(m,s,next);
    }
}

int main(){
    int i,q;
    cin >> N;
    for(i=0;i<N;i++){
        cin>>A[i];
    }
    cin>>q;
    for(i=0;i<q;i++){
        int m;
        cin >> m;
        exhaustiveSearch(m,0,0)?cout<<"yes":cout<<"no";
        cout<<endl;
    }
}


Measured memory_bytes: 3100
#include <iostream>
using namespace std;
int main(){
  int n;
  cin >> n;

  if (n >= 100) n = n % 100;
  if(n >= 10) n = n % 10;

  if(n == 3) cout << "bon" << endl;
  else if(n == 0 || n == 1 || n == 6 || n == 8) cout << "pon" << endl;
  else cout << "hon" << endl;

  return 0;
}


Measured memory_bytes: 3624
//Bi-smi llāh

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



int main(){
	ll x; cin >> x;
	ll p = 100, cnt = 0;

	while(p < x){
			p += p / 100;
			cnt++;
		}
	cout << cnt << "\n";
	return 0;
	}



Measured memory_bytes: 3592
#include<bits/stdc++.h>
#define ll long long 
using namespace std;
const int mod=1e9+7;
inline int rd(){
	int x=0,f=1;char ch=getchar();
	while(ch<'0'||ch>'9'){if(ch=='-') f=0;ch=getchar();}
	while(ch>='0'&&ch<='9'){x=(x<<3)+(x<<1)+(ch^48);ch=getchar();}
	return f?x:-x;
}
inline void add(int &x,int y){
	x+=y;
	if(x>=mod) x-=mod;
}
int f[305][305][305],n,m,k,L,R,ans;
vector<int>g[305][4];
inline void update(int p){
	for(int i=1;i<=3;i++){
		for(int j=g[p][i].size()-1,l;j>=0;j--){
			l=g[p][i][j];
			for(int a=0;a<=p;a++){
				for(int b=0;b<=p;b++){
					for(int c=(a<p&&b<p)?p:0;c<=p;c++){
						if((a>=l)+(b>=l)+(c>=l)!=i) f[a][b][c]=0; 
					}
				}
			}
		}
	}
}
void work(){
	f[0][0][0]=1;
	for(int i=1;i<=n;i++){
		for(int j=0;j<i;j++){
			for(int l=0,now;l<i;l++){
				for(int u=(j<i-1&&l<i-1)?i-1:0;u<i;u++){
					now=f[j][l][u];
					add(f[i][l][u],now);
					add(f[j][i][u],now);
					add(f[j][l][i],now);
				}
			}
		}
		update(i);
	}
	for(int j=0;j<=n;j++){
		for(int l=0;l<=n;l++){
			for(int u=(j<n&&l<n)?n:0;u<=n;u++){
				add(ans,f[j][l][u]);
			}
		}
	}
}
int main(){
	n=rd(),m=rd();
	for(int i=1;i<=m;i++){
		L=rd(),R=rd(),k=rd();
		g[R][k].push_back(L);
	}
	work();
	cout<<ans;
	return 0;
}

Measured memory_bytes: 110848
#include<bits/stdc++.h>
using namespace std;
int main()
{
  string s;
  cin>>s;
  //  //Sunny, Cloudy, or Rainy

  if(s=="Sunny")
  {
      cout<<"Cloudy"<<endl;
  }
  else if(s=="Cloudy")
  {
      cout<<"Rainy"<<endl;
  }
  else
  {
      cout<<"Sunny"<<endl;
  }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define Rep(i,n) for(int i=0;i<(int)(n);i++)
#define For(i,n1,n2) for(int i=(int)(n1);i<(int)(n2);i++)
#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define RREP(i,n) for(ll i=((ll)(n)-1);i>=0;i--)
#define FOR(i,n1,n2) for(ll i=(ll)(n1);i<(ll)(n2);i++)
#define RFOR(i,n1,n2) for(ll i=((ll)(n1)-1);i>=(ll)(n2);i--)
#define all(a)  (a).begin(),(a).end()
#define SORT(a) sort((a).begin(),(a).end())
#define oorret 0
#define oor(x) [&](){try{x;} catch(const out_of_range& oor){return oorret;} return x;}()
#define IOS cin.tie(0),ios::sync_with_stdio(false)
typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;
template<typename T1, typename T2> inline bool chmin(T1& a, T2 b) { if (a > b) { a = b; return 1; }return 0; }
template<typename T1, typename T2> inline bool chmax(T1& a, T2 b) { if (a < b) { a = b; return 1; }return 0; }
template<class Type>struct is_vector : std::false_type {};
template<class ValueType, class Alloc>struct is_vector<std::vector<ValueType, Alloc>> : std::true_type {};
template <typename T> inline ostream& operator << (ostream& out, const vector<T>& v) {
	if (v.empty())return out;
	constexpr bool is_vector_v = is_vector<T>::value;
	if (is_vector_v)for (auto itr = v.begin(); itr != v.end();)out << (*itr), out << ((++itr != v.end()) ? "\n" : "");
	else for (auto itr = v.begin(); itr != v.end();)out << (*itr), out << ((++itr != v.end()) ? " " : "");
	return out;
}
inline void put() {}
template<class T> inline void put(const T& first) { std::cout << first << "\n"; }
template<class T, class... N> inline void put(const T& first, const N& ... rest) { std::cout << first << " "; put(rest...); }
inline void putn() {}
template<class T, class... N> inline void putn(const T& first, const N& ... rest) { std::cout << first << "\n"; putn(rest...); }


int main() {
	string s;
	cin >> s;
	ll n = s.size()+1;
	vector<ll> a(n,-1);
	queue<int> q1,q2;
	REP(i, n-1) {
		if (i == 0 && s[i] == '<') {
			a[i] = 0;
			q1.push(i);
			q2.push(i);
		} else if (i == n - 2 && s[i] == '>') {
			a[i+1] = 0;
			q1.push(i+1);
			q2.push(i+1);
		}
		if (s[i] == '>' && s[i + 1] == '<') {
			a[i+1] = 0;
			q1.push(i + 1);
			q2.push(i + 1);
		}
	}
	while (!q1.empty()) {
		int p = q1.front();
		q1.pop();
		if (p > 0 && s[p - 1] == '>') {
			chmax(a[p - 1], a[p] + 1);
			q1.push(p - 1);
		}
	}
	while (!q2.empty()) {
		int p = q2.front();
		q2.pop();
		if (p < n-1 && s[p] == '<') {
			chmax(a[p + 1], a[p] + 1);
			q2.push(p + 1);
		}
	}

	ll res = 0;
	REP(i, n) {
		res += a[i];
	}
	put(res);
	return 0;
}

Measured memory_bytes: 5636
#include<bits/stdc++.h>
using namespace std;
#define rep(i, a, b) for(int i = (a), i##_end_ = (b); i <= i##_end_; ++i)
#define drep(i, a, b) for(int i = (a), i##_end_ = (b); i >= i##_end_; --i)
#define clear(a, b) memset((a), (b), sizeof(a))
typedef long long LL;
int read() {
	int x = 0, flag = 1;
	char ch = getchar();
	while(!isdigit(ch)) {
		if(ch == '-') flag = -1;
		ch = getchar();
	}
	while(isdigit(ch)) {
		x = x * 10 + ch - 48;
		ch = getchar();
	}
	return x * flag;
}
 
#define Maxn 100009
struct node{
	int id, val;
}a[Maxn];
int n, b[Maxn];
int cmp(node a, node b) {
	return a.val < b.val;
}
int ans;
int main() {
#ifdef Qrsikno
	freopen("AGC003_3.in", "r", stdin);
	freopen("AGC003_3.out", "w", stdout);
#endif
	n = read();
	rep(i, 1, n) a[i].id = i, a[i].val = read();
	sort(a + 1, a + n + 1, cmp);
	rep(i, 1, n) a[i].val = a[i].id, a[i].id = i;
	sort(a + 1, a + n + 1, cmp);
	rep(i, 1, n)
		ans += (i & 1) ^ (a[i].id & 1);
	printf("%d\n", ans >> 1);
	return 0;
}

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

int main() {
    int N, W[110];
    cin >> N;
    for (int i = 0; i < N; i++) cin >> W[i];

    int sum[N + 1] = {};
    for (int i = 1; i <= N; i++) sum[i] = sum[i - 1] + W[i - 1];

    int ans = 1001001;
    for (int i = 1; i < N; i++) {
        int S1 = sum[i];
        int S2 = sum[N] - sum[i];
        ans = min(ans, abs(S1 - S2));
    }

    cout << ans << endl;
}

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

using namespace std;

int main(){
  int N;
  cin >> N;
  if(N == 0 || N == 2){
    cout << 1 << endl;
  }else if(N == 1){
    cout << 2 << endl;
  }else{
    cout << 0 << endl;
  }
  return 0;
}

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

using ll = long long;

int main() {
    double t, x;
    cin >> t >> x;
    cout << setprecision(10) << t / x << endl;
    return 0;
}

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

int main(){
  string s;
  int r=0;
  cin >> s;
  for(int i;i<s.size();i++){
    if(s[i]!=s[(s.size())-1-i]){
      r++;
    }
  }
  cout << r/2;
  return 0;
}
       
      
    

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

count = [[0]*10 for i  in range(10)]

for i in range(1,n+1):
    i_str = str(i)
    mae = int(i_str[0])
    usi = int(i_str[-1])
    count[mae][usi] += 1

ans = 0
for i in range(10):
    for j in range(10):
        ans += count[i][j] * count[j][i]

print(ans)

Measured memory_bytes: 41580
import java.io.*
import java.util.*

var pw = PrintWriter(System.out)
const val YES = "Yes"
const val NO = "No"
fun solve(N: Long){
    if (N % N.toString().map{ it-'0' }.sum().toLong() == 0L){
        println(YES)
    }else println(NO)
    return
}


fun main(args: Array<String>) {
    fun StringArray(size: Int, init: (Int) -> String = { "\u0000" }): Array<String> {
        return Array<String>(size, init)
    }
    class Scanner(stream: InputStream) {
        private val reader = BufferedInputStream(stream).bufferedReader()
        private var st: StringTokenizer? = null
        fun next(): String {
            while (!(st?.hasMoreTokens() ?: false)) st = StringTokenizer(reader.readLine())
            return st!!.nextToken()
        }
    }
    val sc = Scanner(System.`in`)
    val N = sc.next().toLong()
    solve(N)
}



Measured memory_bytes: 31620
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N, A;
  cin >> N >> A;
  int z;
  z = N % 500;
  if ( z <= A ) {
    cout << "Yes" << endl;
  }
  else {
    cout << "No" << endl;
  }
}

Measured memory_bytes: 256
#include<stdio.h>
int main(){
	char a,b;
	scanf("%c %c",&a,&b);
	if(a=='H'){
		if(b=='H'){
			printf("H");
		}
		else{
			printf("D");
		}
	}
	if(a=='D'){
		if(b=='H'){
			printf("D");
		}
		else{
			printf("H");
		}
	}
	printf("\n");
	return 0;
}

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

int main()
{
    int X;
    cin >> X;
    if(400<=X&&X<=599)
    {
        cout << 8 << endl;
    }else if(600<=X&&X<=799)
    {
        cout << 7 << endl;
    }else if(800<=X&&X<=999)
    {
        cout << 6 << endl;
    }else if(1000<=X&&X<=1199)
    {
        cout << 5 << endl;
    }else if(1200<=X&&X<=1399)
    {
        cout << 4 << endl;
    }else if(1400<=X&&X<=1599)
    {
        cout << 3 << endl;
    }else if(1600<=X&&X<=1799)
    {
        cout << 2 << endl;
    }else if(1800<=X&&X<=1999)
    {
        cout << 1 << endl;
    }
}


Measured memory_bytes: 3620
use proconio::input;
use proconio::marker::Chars;

fn main() {
    input! {
        n: Chars
    };
    let ans = if n.iter().filter(|&&c| c == '7').count() > 0 {
        "Yes"
    } else {
        "No"
    };
    println!("{}", ans);
}


Measured memory_bytes: 2172
def m():
    def is_satisfied(p):
        for i in range(N):
            if i + 1 == p[i]: return False
        return True

    def swap(i):
        tmp = p[i]
        p[i] = p[i + 1]
        p[i + 1] = tmp

    N = int(input())
    p = list(map(int, input().split()))
    if is_satisfied(p):
        return 0

    cnt = 0
    for i in range(N):
        if i + 1 == p[i]:
            if i + 1 == N:
                cnt += 1
                tmp = p[i - 1]
                p[i - 1] = p[i]
                p[i] = tmp
            else:
                swap(i)
                cnt += 1
    return cnt


print(m())


Measured memory_bytes: 14008
#include <bits/stdc++.h>
using namespace std;
#define int long long
const int M = 2e5 + 5;
int a, b, c, k, ans;
 
int32_t main() 
{
	ios_base::sync_with_stdio(0);	cin.tie(0);	cout.tie(0);
	cin >> a >> b >> c >> k;
	if(a >= k)		cout << k;
	else if(a + b >= k)	cout << a;
	else			cout << a - (k - (a + b));
    	return 0;
}

Measured memory_bytes: 3548
#include <iostream>
#include <string>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <vector>
#include <cmath>
#include <cstdlib>
#include <queue>
#include <stack>
#include <iomanip>

using namespace std;

#define REP(i, n) for(ll i = 0;i < n;i++)
#define REPR(i, n) for(ll i = n;i >= 0;i--)
#define FOR(i, m, n) for(ll i = m;i < n;i++)
#define FORR(i, m, n) for(ll i = m;i >= n;i--)
#define REPO(i, n) for(ll i = 1;i <= n;i++)
#define ll long long
#define INF (ll)1 << 60
#define MINF (-1 * INF)
#define ALL(n) n.begin(),n.end()
#define MOD 1000000007
#define P pair<ll, ll>

ll a, n, m, ans;

ll powmod(ll a, ll b) {
	a %= MOD;
	ll res = 1;
	while (b > 0) {
		if (b % 2 == 1)res = res * a % MOD;
		a = a * a % MOD;
		b /= 2;
	}
	return res;
}
int main() {
	cin >> a >> n >> m;
	REPO(i, INF) {
		ll now = powmod(i, n), sum = 0;
		if (now > m)break;
		string s = to_string(now);
		REP(i, s.size())sum += s[i] - '0';
		if (now == powmod(a + sum, n))ans++;
	}
	cout << ans << endl;
}


Measured memory_bytes: 3276
#include<cstdio>
#include<queue>
using namespace std;

const int INF = -1;

int G[110][110] = {};
int d[110] = {};

void bfs(int s, int n)
{
  int v;
  queue<int> que;

  for(int i = 1;i <= n;i++) d[i] = INF; //init

  que.push(s);
  d[s] = 0;
  
  while(que.size()){
    v = que.front();
    que.pop();

    for(int i = 1;i <= n;i++){
      if(G[v][i] != 1) continue;
      if(d[i] != INF) continue;

      que.push(i);
      d[i] = d[v]+1;
    }
  }
}

int main()
{
  int n;
  int i,j;
  int u,k,v;

  scanf("%d", &n);

  for(i = 0;i < n;i++){
    scanf("%d%d", &u, &k);

    for(j = 0;j < k;j++){
      scanf("%d", &v);
      G[u][v] = 1;
    }
  }

  for(i = 1;i <= n;i++)
    if(d[i] == 0) bfs(i, n);

  for(i = 1;i <= n;i++)
    printf("%d %d\n", i, d[i]);

  return 0;
}



Measured memory_bytes: 2700
#include<cstdio>
#include<map>
using namespace std;
typedef long long ll;
const ll mod = 1000000007;

ll n;
char s[100001], t[100001];
map<char, ll> mp;

int main() {
  scanf("%lld%s%s", &n, s, t);
  mp[s[0]] = 1;
  for (ll i = 1; i < n-1; i++) {
    mp[s[i]] = (mp[t[i]] + mp[s[i]]) % mod;
  }
  printf("%lld\n", mp[t[n-1]]);
}



Measured memory_bytes: 2944
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace __gnu_pbds;
#define ordered_set tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update>

using namespace std;

#define int long long
#define endl '\n'
#define maxn 100010
const int MOD = 1000000007;
using int32 = __uint32_t;

void solve() {
    int a, b;
    cin >> a >> b;

    if(b >= a)cout<<"unsafe";
    else cout << "safe";
}

int32_t main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);

    int t = 1;
//    cin >> t;

    while (t--)
        solve();
    return 0;
}


Measured memory_bytes: 3652
#include <iostream>
#include <string>
#include <cmath>
#include <iomanip>
#define PI 3.1415926535
using namespace std;

int main(void){
	double a, b, rad, h, s, l;
	cin >>a >>b >>rad;
	rad*=PI/180;
	h=b*sin(rad);
	s=a*h*0.5;
	l=a+b+sqrt(pow(a, 2)+pow(b, 2)-2*a*b*cos(rad));
	cout <<fixed <<setprecision(10) <<s <<endl <<l <<endl <<h <<endl;
    return 0;
}

Measured memory_bytes: 1284
#include"bits/stdc++.h"
#define int long long
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=(a);i<(b);++i)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define itr(i,x) for(auto i=(x).begin();i!=(x).end();++i)
#define All(x) (x).begin(),(x).end()
#define rAll(x) (x).rbegin(),(x).rend()
using namespace std;
typedef pair<int,int> P;
typedef vector<int> vi;
typedef vector<vi> vvi;
const int mod=1000000007;
int gcd(int x,int y){return y?gcd(y,x%y):x;}
int lcm(int x,int y){return x*y/gcd(x,y);}
void YN(bool flg){cout<<(flg?"YES":"NO")<<endl;}
void Yn(bool flg){cout<<(flg?"Yes":"No")<<endl;}
void yn(bool flg){cout<<(flg?"yes":"no")<<endl;}
signed main(){
	int n;cin>>n;
	vector<int> c(n-1),s(n-1),f(n-1);
	rep(i,n-1) cin>>c[i]>>s[i]>>f[i];
	rep(i,n){
		int now=i;
		int ans=0;
		while(now<n-1){
			ans=max(s[now],((ans-1)/f[now]+1)*f[now]);
			ans+=c[now];
			now++;
		}
		cout<<ans<<endl;
	}
}


Measured memory_bytes: 256
import std.stdio, std.array, std.string, std.conv, std.algorithm;
import std.typecons, std.range, std.random, std.math, std.container;
import std.numeric, std.bigint, core.bitop, core.stdc.stdlib;

immutable long MOD = 10^^9 + 7;

void main() {
    auto s = readln.split.map!(to!int);
    auto N = s[0];
    auto K = s[1];

    auto dp = new long[](K + 1);
    dp[K] = 1;

    foreach_reverse (i; 1..K) {
        dp[i] = powmod(K / i, N, MOD);
        for (int j = i + i; j <= K; j += i) {
            dp[i] -= dp[j];
            dp[i] = (dp[i] % MOD + MOD) % MOD;
        }
    }

    long ans = 0;
    foreach (i; 1..K+1) (ans += dp[i] * i % MOD) %= MOD;
    ans.writeln;
}

long powmod(long a, long x, long m) {
    long ret = 1;
    while (x) {
        if (x % 2) ret = ret * a % m;
        a = a * a % m;
        x /= 2;
    }
    return ret;
}


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

int main(){
  vector<string> v = {"dream", "dreamer", "erase", "eraser"};

  string S;
  cin >> S;

  // 後ろから解くかわりにすべての文字列を「左右反転」する
  reverse(S.begin(), S.end());
  //cout << S << endl;

  for(int i = 0; i < v.size(); i++){
    reverse(v[i].begin(), v[i].end());
  }
  /*
  for(int i = 0; i < v.size(); i++){
    cout << v[i] << endl;
  }
  */

 // 一致するか
  bool match = true;
  for(int i = 0; i < S.size(); ){
    bool sw = false;
    for(int j = 0; j < v.size(); j++){
      string str = v[j];
      if(S.substr(i, str.size()) == str){
        sw = true;
        i += str.size();
        break;
      }
    }
    if(!sw){
      match = false;
      break;
    }
  }

  if(match){
    cout << "YES" << endl;
  }else{
    cout << "NO" << endl;
  }
}

Measured memory_bytes: 512
#include <iostream>
#include <vector>
#include <string>

using namespace std;



int main()
{
    int n,m;
    cin>>n>>m;
    int cnt[50]={0};
    for(int i=0;i<n;i++)
    {
        int j;
        cin>>j;
        for(int k=0;k<j;k++)
        {
            int a;
            cin>>a;
            cnt[a]++;
        }
    }
    int ans=0;
    for(int i=1;i<=m;i++)
    {
        if(cnt[i]==n)
            ans++;
    }
    cout<<ans;
    return 0;
}


Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
#define watch(x) cout << (#x) << " is " << (x) << endl
#define MOD 1000000007
int main(){
  ios::sync_with_stdio(false);
  cin.tie(0);

  long long n;
  cin>>n;

  long long k;  
  cin>>k;  
  //for each interval of i numbers>=k,we can compose every sum from min to max of this size
  long long ans=0; 


 for(long long i=k;i<=n+1;i++){
   		ans+=i*n-i*(i-1)/2 -(i-1)*i/2 +1;  //max sum - min sum+1,max sum being the sum of last i numbers 


 }  

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


Measured memory_bytes: 3656
#include <iostream>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <map>
#include <queue>
#include <set>

static const int MOD = 1000000007;
using ll = long long;
using u32 = unsigned;
using namespace std;

template<class T>
constexpr T INF = ::numeric_limits<T>::max() / 32 * 15 + 208;

int main() {
    int n;
    cin >> n;
    string s, a, b;
    cin >> s;
    for (int i = 0; i < n; ++i) {
        a += s[i];
        b += s[i+n];
    }
    reverse(b.begin(), b.end());
    map<pair<string, string>, int> v;
    for (int i = 0; i < (1 << n); ++i) {
        string k, l;
        for (int j = 0; j < n; ++j) {
            if (i & (1<<j)) k += a[j];
            else l += a[j];
        }
        v[make_pair(k, l)]++;
    }
    ll ans = 0;
    for (int i = 0; i < (1 << n); ++i) {
        string k, l;
        for (int j = 0; j < n; ++j) {
            if (i & (1<<j)) k += b[j];
            else l += b[j];
        }
        ans += v[make_pair(k, l)];
    }
    cout << ans << "\n";
    return 0;
}


Measured memory_bytes: 91904
N, M = map(int, input().split())
As = list(map(int, input().split()))
def f(l):
    b, c = l
    return c
cards =[list(map(int, input().split())) for _ in range(M)]
cards.sort(key = f)
cnt = 0
while cards and cnt <= N:
    b, c = cards.pop()
    for i in range(b):
        As.append(c)
    cnt += b
As.sort(reverse = True)
print(sum(As[:N]))

Measured memory_bytes: 34884
let n, t = Scanf.scanf " %d %d" @@ fun a b -> a, b
let cts = Array.to_list @@ Array.init n @@ fun _ -> Scanf.scanf " %d %d" @@ fun a b -> a, b
let _ = match List.filter (fun (_, t0) -> t0 <= t) cts |> List.sort compare with
  | [] -> print_endline "TLE"
  | (c, _) :: _ -> c |> Printf.printf "%d\n"

Measured memory_bytes: 2432
import sys
from collections import deque
import heapq
MAX_INT = int(10e10)
MIN_INT = -MAX_INT
mod = 1000000007
sys.setrecursionlimit(1000000)
def IL(): return list(map(int,input().split()))
def SL(): return input().split()
def I(): return int(sys.stdin.readline())
def S(): return input()

N,M = IL()
ab = [IL() for i in range(N)]
data = [[] for i in range(M+1)]
able = []

hpop = heapq.heappop
hpush = heapq.heappush

for d,v in ab:
  if d > M:
    continue
  else:
    data[d].append(-v)

ans = 0
for i in range(1,M+1):
  if data[i] == 0:
    continue
  else:
    #print(data[i])
    for l in data[i]:
      hpush(able,l)
  #print(able)
  if able:
    ans -= hpop(able)
    #print(ans)

print(ans)

Measured memory_bytes: 82136
#include <iostream>
#include <algorithm>
#include <unordered_set>
#include <cstring>
using namespace std;

bool used[27];
bool prec[27];
char s[27];
int main() {
	scanf("%s", s);
	if (strcmp(s, "zyxwvutsrqponmlkjihgfedcba") == 0) {
		printf("-1\n");
		return 0; 
	} 
	int n = strlen(s);
	if (n != 26) {
		for (int i = 0; i < n; i++) used[ s[i] - 'a' ] = true;
		printf("%s", s);
		for (int i = 0; i < 26; i++) 
			if (!used[i]) {
				printf("%c\n", i + 'a');
				return 0;
			}
	}
	for (int i = 0; i < n; i++) used[i] = true;
	for (int i = n - 1; i >= 0; i--) {
//		bool ok = false;
		for (int j = s[i] - 'a' + 1; j < n; j++) 
			if (!used[j]) {
				s[i] = '\0';
				printf("%s%c\n", s, j + 'a');
				return 0;
			}
		used[ s[i] - 'a' ] = false;
	}
	
	return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<vector>
int N, K;
bool DP[5010][5010];
std::vector<int> A;
bool solve(int x) {
	for (int i = 0; i <= N; i++) {
		for (int j = 0; j < K; j++) {
			DP[i][j] = false;
		}
	}
	DP[0][0] = true;
	/*for (int j = 0; j <= N; j++) {
		std::cout << "    " << j << std::endl;

		for (int i = K - A[x]; i < K; i++) {
			if (DP[j][i]) {
				std::cout << "   " << i << std::endl;
			}
		}
	}*/
	for (int i = 0; i < N; i++) {
		for (int j = 0; j < K; j++) {
			if (DP[i][j]) DP[i + 1][j] = true;
			if (i == x) continue;
			if (j + A[i] < K && DP[i][j]) DP[i + 1][j + A[i]] = true;
		}
	}
	for (int i = K - A[x]; i < K; i++) {
		if (DP[N][i])return true;
	}
	return false;
}

int main() {
	std::cin >> N >> K;
	for (int i = 0; i < N; i++) {
		int tmp;
		std::cin >> tmp;
		A.push_back(tmp);
	}
	std::sort(A.begin(), A.end());
	int lb = -1;
	int ub = N;
	while (ub - lb > 1) {
		int mid = (ub + lb) / 2;
		if (A[mid] >= K) {
			ub = mid;
			continue;
		}
		if (solve(mid)) {
			ub = mid;
		}
		else {
			lb = mid;
		}
	}
	std::cout << lb + 1 << std::endl;
	return 0;
}

Measured memory_bytes: 24832
# https://atcoder.jp/contests/tenka1-2018-beginner/tasks/tenka1_2018_d
# D - Crossing

N=int(input())
a=set()
b={}

for i in range(1000):
    if i*(i+1)%2==0:
        s= i*(i+1)//2
        if s<=10**5:
            a.add(s)
            b[s]=i
        else:
            break
            
if N not in a:
    print("No")
else:
    print("Yes")
    print(b[N]+1)
    r=[0 for _ in range(N)] #kaisuu
    t=[ [] for _ in range(b[N]+1)]
    for i in range(b[N]):
        r[i] +=1
    t[0]= [i+1 for i in range(b[N])]
    print(b[N],*t[0])

    for i in range(1,b[N]+1):
        for j in range(i):
            for k,num in enumerate(t[j]):
                if r[num-1]==1:
                    t[i].append(num)
                    r[num-1]+=1
                    break
        for k in range(N):
            if r[k]==0:
                r[k] +=1
                t[i].append(k+1)
                if len(t[i])>=b[N]:
                    break
        print(b[N],*t[i])

        
        
        
        
        #print("i=",i)
        #print(r)
#        for j,num in enumerate(r):
#            if num==1:
#                t[i].append(j+1)
#                r[j]+=1
#                break
        #print("t",t)
        #print(r)
#        for k,num in enumerate(r):
#            if num==0:
#                t[i].append(k+1)
#                r[k]+=1
#            if len(t[i])==b[N]:   
#                break
#        else:
#            pass
#        print(b[N],*t[i])

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

int main(){
	int n,k,t;
	bool f=true;
	vector<int> s;
	
	while(1){
		cin >> n >> k;
		if(n==0&&k==0) break;
		for(int i=0;i<k;i++){
			cin >> t;
			s.push_back(t);
		}
		for(int i=0;i<n;i++){
			for(int j=0;j<k;j++){
				cin >> t;
				s[j]-=t;
			}
		}
		
		for(int i=0;i<k;i++){
			if(s[i]<0){ f=false; }
		}
		if(f){
			cout << "Yes" << endl;
		} else {
			cout << "No" << endl;
		}
		
		s.erase(s.begin(),s.end());
		f=true;
	}
	
	
}

Measured memory_bytes: 892
#include <stdio.h>
#define _USE_MATH_DEFINES
#include <math.h>
int main(){    
int a, b, angle;    
double s, l, h;    
scanf("%d %d %d", &a, &b, &angle);      
h=b*sin(angle*M_PI/180.0);    
s=a*h/2;    
l=a+b+sqrt((a*a+b*b-2*a*b*cos(angle*M_PI/180.0)));   
printf("%f\n", s);    
printf("%f\n", l);    
printf("%f\n", h);    
return 0;}


Measured memory_bytes: 2104
#include <bits/stdc++.h>
using namespace std;
typedef long long int lld;
typedef vector<lld> vi;
typedef pair<int,int> pi;
#define F first
#define S second
#define MOD 1000000007
#define PB push_back
#define MP make_pair
#define rep(i,a,b) for (int i = a; i < b; i++)
static lld r,j,cu=0,x,y,a,nu=0,b,m,n,s,q,i,z,p,k,d,t;string s1,s2,s3,s4;
vi v[100001];
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cin>>m>>n;
    p=q=x=0;
    p=n/10000;
    q=n/5000;
    x=n/1000;
    for(i=0;i<=p&&(i<=m);i++)
    {
      for(j=0;j<=q&&((i+j)<=m);j++)
      {
        for(k=0;k<=x&&((i+j+k)<=m);k++)
        {
          if((((10000*i)+(5000*j)+(1000*k)==n)&&(i+j+k)==m))
          {
            cout<<i<<" "<<j<<" "<<k;return 0;
          }
        }
      }
    }
cout<<"-1 -1 -1";
  } 

Measured memory_bytes: 2560
# coding:utf-8

INF = float('inf')


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


def solve():
    for cx in range(101):
        for cy in range(101):
            ch = D[0][0] + abs(D[0][1] - cx) + abs(D[0][2] - cy)
            for h, x, y in D:
                if h != max(ch - (abs(x - cx) + abs(y - cy)), 0):
                    break
            else:
                return cx, cy, ch


if __name__ == '__main__':
    N = int(input())
    D = []
    for i in range(N):
        x, y, h = inpl()
        D.append([h, x, y])
    D.sort()
    D.reverse()
    ans = solve()
    print(' '.join(map(str, ans)))


Measured memory_bytes: 3064
#include <stdio.h>

int main () {
	int A, B;
	char op;
	scanf ("%d %c %d", &A, &op, &B);
	if (op=='+')
		printf ("%d\n", A+B);
	else if (op=='-')
		printf ("%d\n", A-B);
	return 0;
}

Measured memory_bytes: 128
#include "bits/stdc++.h"
#define ed cout<<"\n";
#define speed ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define ll long long int
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define All(obj) (obj).begin(),(obj).end()

using namespace std;


int main() {
	speed;
	int n;
	vector<int> d;
	cin >> n;
	rep(i, n) {
		int a;
		cin >> a;
		d.push_back(a);
	}
	sort(All(d));

	int harf = d.at((n / 2)-1);
	int nxHarf = d.at(n / 2);
	int ans = nxHarf - harf;
	cout << ans;
	ed;
	return 0;
}


Measured memory_bytes: 892
#include <stdio.h>
 
int main(void){
  int i,sum;
  char num[1001];
 
  for(;;){
    scanf("%s", &num);
    if(num[0] == '0') break;
     
    sum = 0;
    for(i=0;num[i]!='\0';i++)
      sum += num[i] - '0';
    printf("%d\n", sum);
  }
   
  return 0;
}


Measured memory_bytes: 2108
#include<cstdio>
int h[100100];
int ans[100100];
int cost(int a, int b)
{
    int ret = a - b;
    return ret >= 0 ? ret : -ret;
}
int min(int a, int b)
{
    return a < b ? a : b;
}
int main()
{
    int n;
    while(scanf("%d", &n) != EOF)
    {
        for(int i = 1; i <= n; i++)
        {
            scanf("%d", &h[i]);
        }
        ans[2] = cost(h[1], h[2]);
        ans[3] = min(cost(h[1], h[3]), ans[2] + cost(h[2], h[3]));
        for(int i = 4; i <= n; i++)
        {
            ans[i] = min(ans[i - 2] + cost(h[i - 2], h[i]), ans[i - 1] + cost(h[i - 1], h[i]));
        }
        printf("%d\n", ans[n]);
    }
    return 0;
}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
#define int long long
#define f(i,n) for(int i=0;i<n;i++)
#define F first
#define S second
#define mod 1000000007
#define P pair<int,int>
using namespace std;
signed main(){
	int a,b;
	cin>>a>>b;
	if(b*2-1<=a)puts("YES");
	else puts("NO");
	return 0;
}


Measured memory_bytes: 764
#include <bits/stdc++.h>
#define endl "\n"
using namespace std;
typedef long long ll;
typedef pair<int,int> ii;
int c[1000] , s[1000], f[1000];
int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n; cin>>n;
    for(int i=0; i<n-1; ++i) 
        cin>>c[i]>>s[i]>>f[i];
    for(int j=0; j<n-1; ++j)
    {
        ll t = s[j] + c[j];
        for(int i=j+1; i<n-1; ++i) {
            ll curr = s[i];
            if(t < curr) {
                t = curr;
            }
            else if(t > curr) {
                ll add = ceil((double)(t - curr)/(double)f[i]);
                t = curr + (add*f[i]);
            }
            else
                t = curr;
            t += c[i];
        }
            cout<<t<<endl;
    }
        cout<<0<<endl;




    return 0;
}



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

using namespace std;

typedef long long int ll;

const ll mod = 1e9 + 7;

ll pwr(ll a, ll b){
  ll res = 1;
  while(b > 0){
    if(b & 1) res = (res * a) % mod;
    a = (a * a) % mod;
    b >>= 1;
  }
  return res;
}

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

  ll n, k;
  cin >> n >> k;

  vector < ll > gcd(k + 1);
  for(int i = 1; i <= k; i++){
    gcd[i] = pwr(k / i, n);
  }
  for(int i = k; i >= 1; i--){
    for(int j = 2 * i; j <= k; j += i) gcd[i] = (gcd[i] - gcd[j] + mod) % mod;
  }

  ll ans = 0;
  for(int i = 1; i <= k; i++){
    ans = (ans + gcd[i] * i) % mod;
  }

  cout << ans << '\n';
}


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

#define MAX 150
#define LEN 1000

int max(int a,int b){
  return (a > b)? a : b;
}

int lcs(char *x, char *y){
  int i, j, lenx, leny;
  int c[LEN + 1][LEN + 1] = {};
  lenx = strlen(x);
  leny = strlen(y);

  //  0 A C D B A
  //0 0 0 0 0 0 0
  //A 0 1 1 1 1 1
  //C 0 1 2 2 2 2
  //B 0 1 2 2 3 3<-
  
  for(i = 0; i < lenx; i++){
    for(j = 0; j < leny; j++){
       if(x[i] == y[j])
	c[i + 1][j + 1] = c[i][j] + 1;
      else
	c[i + 1][j + 1] = max(c[i + 1][j], c[i][j + 1]);
    }
  }

  return c[lenx][leny];
}

int main(){
  int i,q;
  char x[LEN],y[LEN];

  
  scanf("%d",&q);
  for(i = 0; i < q; i++){
    scanf("%s",x);
    scanf("%s",y);
    printf("%d\n",lcs(x,y));
  }
  
  
  return 0;
}



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

typedef long long ll;
ll n, c;

ll f(ll p) {
	ll re = 0;
	while (p > 0) p /= 10, re++;
	return re;
}

ll h(ll p) {
	ll re = 0;
	while (p > 0) re = p % 10, p /= 10;
	return re;
}

ll g(ll p) {
	ll re = 0, t, i;
	ll fr, bk = p % 10;
	fr = h(p);
	if (fr == bk) re++;
	for (i = 10; bk * i + fr <= n; i *= 10) {
		if (f(i) == f(n) && bk == h(n)) {
			re += (n - bk * i) / 10;
			if (fr <= n % 10) re++;
		} else {
			re += i / 10;
		}
	}
	return re;
}

int main()
{
	ll i;
	cin >> n;
	for (i = 1; i <= n; i++) {
		if (i % 10 == 0) continue;
		c += g(i);
	}
    cout << c << endl;
    return 0;
}

Measured memory_bytes: 256
N,W=map(int,input().split())
data_list=[]
for j in range(N):
    w,v=map(int,input().split())
    data_list.append((w,v))
from collections import defaultdict
data = defaultdict(int)
data[0] = 0
for w, v  in data_list:
    for cw, cv in list(data.items()):
        if cw + w <= W:
            data[cw+w] = max(data[cw+w], cv + v)
print(max(data.values()))

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

using namespace std;

template <class T> inline bool chmin(T &a, T b) { /* {{{ */
  if (a > b) {
    a = b;
    return true;
  }
  return false;
} /* }}} */

int main() {
  int N, K;
  cin >> N >> K;
  vector<int> X(N);
  for (auto &x : X) cin >> x;

  int ans = 1e9 + 5;
  for (int i = 0; i <= N - K; i++) {
    int j = i + K - 1;
    int a;
    if (X[i] < 0 and X[j] > 0) {
      a = abs(X[i]) + abs(X[j]) + min(abs(X[i]), abs(X[j]));
    } else {
      a = max(abs(X[i]), abs(X[j]));
    }
    chmin(ans, a);
  }
  cout << ans << endl;

  return 0;
}
/* vim:set fdm=marker: */


Measured memory_bytes: 640
#include <iostream>
#include <string>
#include <stack>
#include <queue>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <algorithm>

using namespace std;
#define rep(i, n) for (int i = 0; i < (n); i++)
#define rep1(i, s, n) for (int i = (s); i <= (n); i++)
#define rrep(i, n) for (int i = (n) - 1; i >= 0; i--)
typedef long long ll;
typedef unsigned long long ull;

int main()
{
	int A, B;
	int ans;
	cin >> A >> B;
	if (A >= 13) ans = B;
	else if (A <= 5) ans = 0;
	else ans = B / 2;
	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 256
function Main(input) {
     var line=String(input)
     var array=line.split("")
     var front=array.indexOf("A");
     var back=array.lastIndexOf("Z");
     var len=array.slice(front,back+1);
     console.log(len.length);
}
Main(require("fs").readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 12620
//ITP1-8-B: Sum of Numbers
//2019.05.18

#include <stdio.h>
#include <string.h>

int main(void){
  int sum;
  int i, sz;
  char num[1001];

  while (1) {
    sum = 0;
    scanf("%s\n", num);
    if (num[0] == '0') break;
    sz = strlen(num);
    for (i = 0; i < sz; i++) {
      sum = sum + (num[i] - '0');
    }
    printf("%d\n", sum);
  }

  return 0;
}


Measured memory_bytes: 2104
#include<bits/stdc++.h>
using namespace std;
#define sc(a) scanf("%d", &a)
#define sc2(a,b) scanf("%d%d", &a, &b)
#define sc3(a,b,c) scanf("%d%d%d", &a, &b, &c)
#define pri(x) printf("%d\n", x)
#define mp make_pair
#define pb push_back
#define BUFF ios::sync_with_stdio(false);
#define imprime(v) for(int X=0;X<v.size();X++) printf("%d ", v[X]); printf("\n");
#define endl "\n"
const int INF= 0x3f3f3f3f;
const long double pi= acos(-1);
typedef long long int ll;
typedef long double ld;
typedef pair<int,int> ii;
typedef vector<int> vi;
typedef vector< vector< int > > vvi;
const int MOD=1e9+7;
const ll LINF=0x3f3f3f3f3f3f3f3f;

bitset<4000001> can;
int n, a[2005];
int toadd[4000004];
int id;

bool ok(int i) { return can[i]; }

int main() {
  sc(n);
  int sum = 0;
  int max_value = 0;
  for(int i = 0; i < n; i++) {
    sc(a[i]);
    sum += a[i];
  }
  if(n == 1) {
    cout << a[0] << endl;
    return 0;
  }
  sort(a, a + n);
  for(int i = 0; i < n; i++) {
    int new_max = max_value;
    //cout << "antes de botar " << a[i] << endl;
    //cout << can << endl;
    //cout << "dps" << endl;
    can |= (can << a[i]);
    can[a[i]] = 1;
    //cout << can << endl;
  }
  int target = (sum + 1) / 2;
  for(int i = target; i <= sum; i++) {
    if(ok(i)) {
      cout << i << endl;
      return 0;
    }
  }
  return 0;
}

Measured memory_bytes: 1664