akhauriyash/Code-Regression huggingface dataset:
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		try (Scanner sc = new Scanner(System.in)) {
			// nがあり、nの数だけの整数の入力
			int n = sc.nextInt();
			int k = sc.nextInt();
			List<Integer> hn = new ArrayList<>();
			for (int i = 0; i < n; i++) {
				hn.add(sc.nextInt());
			}
			// 出力(整数)
			int result = 0;
			for (int i : hn) {
				if (k <= i) {
					result++;
				}
			}
			System.out.println(result);
		}
	}
}


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

using namespace std;

#define INF 1001000100010001000
#define MOD 1000000007
#define EPS 1e-10
#define int long long
#define rep(i, N) for (int i = 0; i < N; i++)
#define Rep(i, N) for (int i = 1; i < N; i++)
#define For(i, a, b) for (int i = (a); i < (b); i++)
#define pb push_back
#define eb emplece_back
#define mp make_pair
#define i_i pair<int, int>
#define vi vector<int>
#define vvi vector<vi >
#define vb vector<bool>
#define vvb vector<vb >
#define vp vector< i_i >
#define all(a) (a).begin(), (a).end()
#define Int(x) int x; scanf("%lld", &x);
#define int2(x, y) int x, y; scanf("%lld %lld", &x, &y);
#define fir first
#define sec second
#define ffir first.first
#define fsec first.second
#define sfir second.first
#define ssec second.second

//int dxy[5] = {0, 1, 0, -1, 0};
// assign avl ncm dijkstra geo2 kruskal graph uf lca BIT
// matrix

typedef int Weight;
typedef int Flow;
struct Edge {
    int s, d; Weight w; Flow c;
    Edge() {};
    Edge(int s, int d, Weight w = 1) : s(s), d(d), w(w), c(w) {};
};
bool operator<(const Edge &e1, const Edge &e2) { return e1.w < e2.w; }
bool operator>(const Edge &e1, const Edge &e2) { return e2 < e1; }
inline ostream &operator<<(ostream &os, const Edge &e) { return (os << '(' << e.s << ", " << e.d << ", " << e.w << ')'); }

typedef vector<Edge> Edges;
typedef vector<Edges> Graph;
typedef vector<Weight> Array;
typedef vector<Array> Matrix;

void addArc(Graph &g, int s, int d, int w = 1) {
    g[s].push_back(Edge(s, d, w));
}
void addEdge(Graph &g, int a, int b, int w = 1) {
    addArc(g, a, b, w);
    addArc(g, b, a, w);
}

signed main()
{
    int2(n, m);
    Edges yui(m);
    vvi g(n, vi(n, INF));
    rep(i, n) g[i][i] = 0;
    rep(i, m) {
        int2(a, b);Int(c);
        a--; b--;
        yui[i] = Edge(a, b, c);
        g[a][b] = c; g[b][a] = c;
    }
    rep(k, n) {
        rep(i, n) {
            rep(j, n) {
                g[i][j] = min(g[i][j], g[i][k] + g[k][j]);
            }
        }
    }
    /*
    rep(i, n) {
        rep(j, n) {
            cout << g[i][j] << " ";
        }cout << endl;
    }*/
    int ans = 0;
    rep(i, m) {
        if (yui[i].w > g[yui[i].s][yui[i].d]) {
            ans++;
        }
    }
    std::cout << ans << std::endl;


    return 0;
}





Measured memory_bytes: 384
#include <bits/stdc++.h>
#define all(v) (v).begin(), (v).end()
typedef long long int lint;
using namespace std;

long double sadness(vector<int>& a, long double b) {
    long double res = 0;
    for (int i = 0; i < a.size(); i++) {
        res += abs((long double)a[i] - b);
    }
    return res;
}

// upper<=x<lowerとしたい
int upper(double x) {
    return x >= 0 ? (int)x + 1 : (int)x;
}
int lower(double x) {
    return upper(x) - 1;
}

int main() {
    int n;
    cin >> n;
    vector<int> a(n);
    long double M = INT_MIN, m = INT_MAX;
    for (int i = 0; i < n; i++) {
        cin >> a[i];
        a[i] -= i + 1;
        M = max(M, (long double)a[i]);
        m = min(m, (long double)a[i]);
    }
    while (M - m >= 0.5) {
        long double l = (m * 2 + M) / 3;
        long double r = (M * 2 + m) / 3;
        if (sadness(a, l) < sadness(a, r)) {
            M = r;
        } else {
            m = l;
        }
    }
    lint ans = LLONG_MAX;
    ans = min(ans, (lint)sadness(a, upper(m)));
    ans = min(ans, (lint)sadness(a, upper(M)));
    ans = min(ans, (lint)sadness(a, lower(m)));
    ans = min(ans, (lint)sadness(a, lower(M)));
    cout << ans << endl;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define ll long long
#define endl '\n'
#define PI acos(-1)
#define sz 100010
#define RUN_FAST ios::sync_with_stdio(false);
using namespace std;

int main()
{
    RUN_FAST; cin.tie(nullptr);
    int n, i, j, mn, mx, sum, ans, tmp;
    cin >> n;
    int arr[n];
    mn=1000, mx=0;
    for (i=0; i<n; i++) {
        cin >> arr[i];
        mn=min(arr[i], mn);
        mx=max(arr[i], mx);
    }
    ans=1000000000;
    for (i=mn; i<=mx; i++) {
        sum=0;
        for (j=0; j<n; j++) {
            tmp=arr[j]-i;
            sum+=tmp*tmp;
        }
        ans=min(ans, sum);
    }
    cout << ans << endl;
    return 0;
}


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

int main() {
    string a; cin >> a;
    if (a.at(0) == a.at(1)) {
        cout << "Bad" << endl;
        return 0;
    }
    if (a.at(1) == a.at(2)) {
        cout << "Bad" << endl;
        return 0;
    }
    if (a.at(2) == a.at(3)) {
        cout << "Bad" << endl;
        return 0;
    }
    cout << "Good" << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define ii pair<int, int>
#define vi vector<int>
#define pb emplace_back
#define sz(x) (int)x.size()
#define all(v) v.begin(), v.end()
#define x first
#define y second
#define rep(i, j, k) for(i=j; i<k; i++)
#define sep(i, j, k) for(i=j; i>k; i--)
const int N = 3e2+5, inf = 1e9+7;
int n, k, i, j;
int A[N];
bool done[N][N][N];
long double dp[N][N][N];

long double dfs(int a, int b, int c){
    if(a<0 || b<0 || c<0) return 0;
    if(a==0 && b==0 && c==0) return 0;
    if(done[a][b][c]) return dp[a][b][c];
    done[a][b][c]=1;
    return dp[a][b][c] = (dfs(a-1, b, c)*a+dfs(a+1, b-1, c)*b+dfs(a, b+1, c-1)*c+n)/(a+b+c);
}

signed main()
{
    ios_base::sync_with_stdio(false); cin.tie(0);
    int i, j, a, b, ans = 0;
    cin>>n;
    rep(i, 0, n) cin>>a, A[a]++;
    cout<<fixed<<setprecision(10)<<dfs(A[1], A[2], A[3]);
}

Measured memory_bytes: 277248
#include <iostream>
#include <vector>
#include <queue>
using namespace std;
typedef long long ll;

int main() {
  int n, m; cin >> n >> m; int a;
  priority_queue<int, vector<int>, less<int>> p;
  for(int i=0; i<n; i++) {
    cin >> a; p.push(a);
  }
  for(int i=0; i<m; i++) {
    int x = p.top(); p.pop();
    x /= 2; p.push(x);
  }
  long long an = 0;
  while(p.size()) {
    an += p.top(); p.pop();
  }
  cout << an << endl;
}

Measured memory_bytes: 892
INF = float('inf')
# n -> ノード数, edges -> グラフ. Vec<(start, end, cost)>で構成, s -> 始点, e -> 目的地
def bellman_ford(n, edges, s, e):
    
    # 各点への最短距離を保持する配列
    min_dist = [INF] * n

    # start地点への距離は0
    min_dist[s] = 0

    for i in range(n):
        for (start, end, cost) in edges:
            if min_dist[start] != INF and min_dist[start] + cost < min_dist[end]:
                min_dist[end] = min_dist[start] + cost
                # 最短経路の更新がn回目でもまだ行われているようなら閉路あり
                if i == n - 1 and end == n - 1:
                    return INF 
    return min_dist

n, m = map(int, input().split())
# graph -> (start, end, cost) で管理する
graph = []

for i in range(m):
    a, b, c = map(int, input().split())
    graph.append((a - 1, b - 1, -c))

dist = bellman_ford(n, graph, 0, n - 1)
if dist == INF:
    print("inf")
else:
    print(-dist[n - 1])


Measured memory_bytes: 3384
//include
//------------------------------------------
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <bits/stdc++.h>
#include<queue>
#include <numeric>
using namespace std;
 
//conversion
//------------------------------------------
inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}
 
//math
//-------------------------------------------
template<class T> inline T sqr(T x) {return x*x;}
 template<class T>bool chmin(T &a, const T &b) { if (b<a) { a = b; return 1; } return 0; }
//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;
 
//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())
 
//repetition
//------------------------------------------
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define fore(i,a) for(auto &i:a)

//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI  = acos(-1.0);
 
//clear memory
#define CLR(a) memset((a), 0 ,sizeof(a))
 
//debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;
 

LL gcd(LL a, LL b){
    if(b == 0) return a;
    return gcd(b,a%b);
}

LL lcm(LL a, LL b){
    LL g = gcd(a,b);
    return a/g *b;
}

int main(){
    int N;
    cin >> N;
    int P[N];
    REP(i,N) cin>> P[i];
    int num_max=P[0];
    int num_min=P[0];
    int sum=1;
    for(int i=1;i<N;++i){
        if(num_min>=P[i]){
            ++sum;
        }
        num_max=max(num_max,P[i]);
        num_min=min(num_min,P[i]);
        }
    cout << sum;
}

Measured memory_bytes: 1024
s=input()
s=list(s)
ct=0
for i in range(len(s)):
    if s[i]=='R' and (i+1)%2==0:
        ct=1
    if s[i]=='L' and (i+1)%2==1:
        ct=1
if ct==1:
    print('No')
else:
    print('Yes')

Measured memory_bytes: 3060
import sys

n = int(input())
ab = [list(map(int, input().split())) for _ in range(n)]
ab.sort(key=lambda x: x[1])
t = 0

for i in range(n):
    if t+ab[i][0] > ab[i][1]: print("No"); sys.exit()
    else: t += ab[i][0]
else:
    print("Yes")

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

#define COUT(x) cout << #x << " = " << (x) << ", "
template<class T> ostream& operator << (ostream &s, vector<T> P)
{ for (int i = 0; i < P.size(); ++i) { if (i > 0) { s << " "; } s << P[i]; } return s; }
typedef long long ll;
const int MOD = 1000000007;

int main(){
  int A,B;
  cin >> A >> B;
  if(A + B >= 10){
    cout << "error" << endl;
  }else{
    cout << A + B << endl;
  }
}


Measured memory_bytes: 256
#include <stdio.h> 
int main(){
  int a,b,c,d,e,f,g,h,i,j;
  int S,N;
  scanf("%d",&N);
  a=N%10;
  b=((N-a)/10)%10;
  c=(((N-a)-10*b)/100)%10;
  d=((N-a-b*10-c*100)/1000)%10;
  e=((N-a-b*10-c*100-d*1000)/10000)%10;
  f=((N-a-b*10-c*100-d*1000-e*10000)/100000)%10;
  g=((N-a-b*10-c*100-d*1000-e*10000-f*100000)/1000000)%10;
  h=((N-a-b*10-c*100-d*1000-e*10000-f*100000-g*1000000)/10000000)%10;
  i=((N-a-b*10-c*100-d*1000-e*10000-f*100000-g*1000000-h*10000000)/100000000)%10;
  j=((N-a-b*10-c*100-d*1000-e*10000-f*100000-g*1000000-h*10000000-i*100000000)/1000000000)%10;
  S=a+b+c+d+e+f+g+h+i+j;
  if((N%S)==0){
  printf("Yes"); 
  }else{
  printf("No");
  }
}

Measured memory_bytes: 128
N = int(input())
L = []
ans = 0
for i in range(N) :
    a,b = map(int,input().split())
    L.append([a,b,a+b])
L = sorted(L,key=lambda x:x[2],reverse=True)
takapoint = 0
aokipoint = 0
for i in range(N) :
    if i % 2 == 0 :
        takapoint += L[i][0]
    else :
        aokipoint += L[i][1]
ans = takapoint - aokipoint
print(ans)


Measured memory_bytes: 25216
#include <iostream>
#include <string>
#include <vector>
#include <deque>
#include <queue>
#include <stack>
#include <map>
#include <algorithm>
#include <set>
#include <sstream>
#include <numeric>
#include <bitset>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <climits>
#include <cctype>
#include <cassert>
using namespace std;

typedef long long ll;
static const double EPS = 1e-8;
static const double PI = 4.0 * atan(1.0);
bool ISINT(double x){return fabs(x-(int)x)<EPS;}
bool ISEQ(double x,double y){return fabs(x-y)<EPS;}
string itos(ll x){stringstream ss;ss<<x;return ss.str();}
#define REP(i,a,b) for(int i=a;i<b;i++)
#define rep(i,n) REP(i,0,n)
#define EREP(i,a,b) for(int i=a;i<=b;i++)
#define erep(i,n) EREP(i,0,n)
#define foreach(itr,c) for(__typeof(c.begin()) itr=c.begin();itr!=c.end();itr++)

typedef pair<int,int> P;
typedef pair<int,P> State;

int w,h;
int dp[2502][2502];
vector<P> t[2502];

int main(void){
  while(cin>>w>>h,w||h){
    rep(i,2502) t[i].clear();

    int gx,gy;
    int maxDig = 0;
    rep(i,h){
      rep(j,w){
        string s;
        cin>>s;
        if(s == "S"){
          t[0].push_back(P(j,i));
        }
        else if(s == "G"){
          gx = j;
          gy = i;
        }
        else if(s != "."){
          int dig = atoi(s.c_str());
          maxDig = max(maxDig,dig);
          t[dig].push_back(P(j,i));
        }
      }
    }
    t[maxDig+1].push_back(P(gx,gy));

    rep(i,maxDig+2) rep(j,t[i].size()) dp[i][j] = INT_MAX;
    dp[0][0] = 0;

    rep(i,maxDig+1){
      rep(j,t[i].size()){
        rep(k,t[i+1].size()){
          int dist = abs(t[i+1][k].first - t[i][j].first) + abs(t[i+1][k].second - t[i][j].second);
          dp[i+1][k] = min(dp[i+1][k],dp[i][j]+dist);
        }
      }
    }

    cout<<dp[maxDig+1][0]<<endl;
  }
}

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

using namespace std;

int n, x;
const int maxn = 55;
int a[maxn];
long long dp[maxn][maxn * maxn][maxn];

long long solve (int p, int s, int k) {
  if (p >= n) {
    return (k > 0 && x * k == s);
  }
  if (dp[p][s][k] != -1) return dp[p][s][k];
  long long tot = 0;
  tot += solve (p + 1, s, k);
  tot += solve (p + 1, s + a[p], k + 1);
  return dp[p][s][k] = tot;
}

int main () {
  memset(dp, -1, sizeof(dp));
  cin >> n >> x;
  for (int i = 0; i < n; i++) {
    cin >> a[i];
  }
  cout << solve (0, 0, 0) << '\n';
  return 0;
}

Measured memory_bytes: 71680
#include <iostream>
#include <string> 
#include <vector> 
#include <algorithm> 
#include <utility> 
#include <tuple> 
#include <cstdint> 
#include <cstdio> 
#include <map> 
#include <queue> 
#include <set> 
#include <stack> 
#include <deque> 
#include <unordered_map> 
#include <unordered_set> 
#include <bitset> 
#include <cctype> 
#include<math.h>
using namespace std;

#define int long long
#define endl "\n"
#define fir first
#define sec second
#define fro front
#define m_p make_pair
#define mod 1000000007
#define all(v)  v.begin(),v.end()
#define rep(i,n)  for(int i=0; i<(int) (n); i++)
#define all(v)  v.begin(),v.end()
#define vecin(v) for(int i=0; i<(int)v.size(); i++)cin>>v[i];
using namespace std;

const int MAX = 510000;
const int MOD = 1000000007;
long long fac[MAX], finv[MAX], inv[MAX];
int jousu(int x00, int y00) {
	int z00 = 1;
	for (int i = 0; i < y00; i++) {
		z00 *= x00;
	}
	return z00;
}
int keta(int x00) {
	int z00 = x00;
	int w00 = 0;
	while (z00 != 0) {
		z00 /= 10;
		w00++;
	}
	return w00;
}

int modinv(int a, int m) {
	int b = m, u = 1, v = 0;
	while (b) {
		int t = a / b;
		a -= t * b; swap(a, b);
		u -= t * v; swap(u, v);
	}
	u %= m;
	if (u < 0) u += m;
	return u;
}
int modpow(int a, int n) {
	int res = 1;
	while (n > 0) {
		if (n & 1) res* a% mod;
		a = a * a % mod;
		n >>= 1;
	}
	return res;
}
int gcd(int xx, int yy) {
	int p = xx;
	int q = yy;
	if (q > p)swap(p, q);
	while (p % q != 0) {
		p %= q;
		swap(p, q);
	}
	return q;
}
int lcm(int xx, int yy) {
	return xx * yy / gcd(xx, yy);
}
bool prime(int xx) {
	int a = xx;
	for (int i = 2; i * i <= xx; i++) {
		if (xx % i == 0) {
			return 0;
		}
	}
	return 1;
}
int com(int xx, int yy) {
	int zz = 1;
	for (int i = xx; i > xx - yy; i--) {
		zz *= i;
		zz %= mod;
	}
	for (int i = 1; i <= yy; i++) {
		zz *= modinv(i, mod);
		zz %= mod;
	}
	return zz;
}



signed main() {
	int a, p;
	cin >> a >> p;
	cout << (a * 3 + p) / 2 << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i,b) for(int i=1;i<=b;i++)
#define drep(i,b) for(int i=b;i>=1;i--)
#define Rep(i,a,b) for(int i=a;i<=b;i++)
#define int long long
#define endl '\n'
using namespace std;
const int N=2e5+5;
const int mod=1e9+7;
int n,m,k,t,x,y,z;
//pr
//
#define mid (l+r)/2
#define ls i<<1
#define rs i<<1|1
//vec
//alg

int a[6000],az;

void solve(int sum=0) {
    string s;
    cin>>s;
    if(s[1]=='R') cout<<"ABC"<<endl;
    else cout<<"ARC"<<endl;
}

#undef int
int main() {
    ios::sync_with_stdio(false);
    //int T;cin>>T;
    //while(T--)
        solve();
}


Measured memory_bytes: 3652
#include<bits/stdc++.h>
using namespace std;
double n[10000];
double cnt[10000];
int main(){
	int x;
	cin>>x;
	for(int i=0;i<x;i++)cin>>n[i];
	double res=0; 
	for(int i=0;i<x;i++){
		res+=n[i];
	}
	res/=x;
	double ans=1e10;
	for(int i=0;i<x;i++){
		cnt[i]=max(n[i],res)-min(n[i],res);
		ans=min(ans,cnt[i]);
	}
	for(int i=0;i<x;i++){
		if(cnt[i]==ans){
			cout<<i<<endl;
			return 0;
		}
	}
	return 0;
}

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

#define rep(i, n) for (int i = 0; i < int(n); i++)
#define rrep(i, n) for (int i = int(n) - 1; i >= 0; i--)
#define reps(i, n) for (int i = 1; i <= int(n); i++)
#define rreps(i, n) for (int i = int(n); i >= 1; i--)
#define repi(i, a, b) for (int i = (a); i < int(b); i++)
#define all(a) (a).begin(), (a).end()
#define bit(b) (1ll << (b))
#define uniq(v) (v).erase(unique(all(v)), (v).end())
#define rsort(v) sort(all(v)); reverse(all(v))

using namespace std;
using i32 = int;
using i64 = long long;
using f80 = long double;
using vi32 = vector<i32>;
using vi64 = vector<i64>;
using vf80 = vector<f80>;
using vstr = vector<string>;

void ioinit() { ios::sync_with_stdio(0); cin.tie(0); cout << fixed << setprecision(16); }
i64 gcd(i64 a, i64 b) { if (a % b == 0) return b; else return gcd(b, a % b); }
i64 lcm(i64 a, i64 b) { return a / gcd(a, b) * b; }
template <class T> bool amax(T &x, T y) { if (x < y) { x = y; return 1; } else return 0; }
template <class T> bool amin(T &x, T y) { if (x > y) { x = y; return 1; } else return 0; }
template <class T> i64 lbi(vector<T> &v, T e) { return lower_bound(all(v), e) - v.begin(); }
template <class T> i64 ubi(vector<T> &v, T e) { return upper_bound(all(v), e) - v.begin(); }

int main() {
  ioinit();
  int n, k;
  cin >> n >> k;
  vector<int> v0, v1;
  vi32 t(n), d(n);
  rep(i, n) cin >> t[i] >> d[i];
  {
    vector<pair<int, int>> p;
    rep(i, n) p.emplace_back(d[i], t[i]);
    rsort(p);
    rep(i, n) d[i] = p[i].first, t[i] = p[i].second;
  }
  i64 sum = 0;
  set<i32> st;
  stack<i32> stk;
  rep(i, k) {
    if (st.count(t[i])) stk.push(d[i]);
    sum += d[i];
    st.insert(t[i]);
  }
  i64 ans = sum + (i64) st.size() * (i64) st.size();
  repi(i, k, n) {
    if (stk.size() == 0) break;
    if (st.count(t[i])) continue;
    st.insert(t[i]);
    sum -= stk.top(); stk.pop();
    sum += d[i];
    amax(ans, sum + (i64) st.size() * (i64) st.size());
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 4196
#include<iostream>
#include<vector>
#include<algorithm>
#include<cmath>
#include<string>
#include<utility>
#include<queue>
#include<tuple>
#include<stdio.h>
#define rep(i, n) for(int i=0;i<n;i++)
using namespace std;
int main(){
	int n, m;
	cin>>n>>m;
	vector<pair<int, int>> v;
	int a, b;
	int f=0;
	rep(i, m){
		cin>>a>>b;
		v.push_back(make_pair(a, b));
		if(a==1 && b==0){
			f=1;
			if(n==1)
				f=0;
		}
	}
	if(f==1){
		cout<<-1<<endl;
		return 0;
	}
	sort(v.begin(), v.end());
	int long long c=0;
	rep(i, m){
		if(i!=0 && v[i].first==v[i-1].first && v[i].second!=v[i-1].second){
			cout<<-1<<endl;
			return 0;
		}
		else if(i!=0 && v[i].first==v[i-1].first && v[i].second==v[i-1].second){
			continue;
		}
		c+=pow(10, n-v[i].first)*v[i].second;
	}
	if(c<pow(10, n-1)){
		if(pow(10, n-1)==1)
			c--;
		c+=pow(10, n-1);
	}
	cout<<c<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <sstream>
#include <string>
#include <set>
#include <vector>
#include <map>
#include <queue>
#include <list>
#include <algorithm>
#include <ctime>
#include <limits>
#include <iomanip>
#include <functional>
#include <array>
#include <climits>
#include <cmath>

using namespace std;
using ll = long long;
const ll MOD = (ll)1e9 + 7;
const ll LL_MAX = 0x7fffffffffffffff;

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

    char c = s[k - 1];
    for (int i = 0; i < n; i++)
    {
        if (s[i] != c)
        {
            s[i] = '*';
        }
    }
    cout << s;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, a, b) for (int i = a; i < (b); i++)
#define rrep(i, a, b) for (int i = a; i >= (b); i--)
#define all(x) (x).begin(), (x).end()
using namespace std;
using ll = long long;
using P = pair<int, int>;
template <class T>
inline bool chmin(T& a, T b) {
   if (a > b) {
      a = b;
      return true;
   }
   return false;
}
template <class T>
inline bool chmax(T& a, T b) {
   if (a < b) {
      a = b;
      return true;
   }
   return false;
}
void hr() { cerr << "--------------" << endl; }
const int INF = 1001001001;
const int MOD = 1000000007;

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

   int s, w;
   cin >> s >> w;
   if (w >= s) cout << "unsafe" << endl;
   else
      cout << "safe" << endl;return 0;
}

Measured memory_bytes: 3652
#include <iostream>
#include <algorithm>
#include <bitset>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <utility>
#include <vector>
#include <complex>
#include <string.h>
#include <numeric>
using namespace std;

#define int long long
#define reps(i,s,n) for(int (i)=(s);(i)<(n);++(i))
#define rep(i,n) reps(i,0,n)
#define rept(i,n) rep(i,(n)+1)
#define repst(i,s,n) reps(i,s,(n)+1)
#define reprt(i,n,t) for(int (i)=(n);(i)>=(t);--(i))
#define repr(i,n) reprt(i,n,0)
#define each(i,v) for(auto &(i):(v))
#define eachr(i,v) for(auto &(i)=(v).rbegin();(i)!=(v).rend();(i)++)
#define all(c) (c).begin(),(c).end()
#define rall(c) (c).rbegin(),(c).rend()
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define tmax(x,y,z) max(x,max(y,z))
#define tmin(x,y,z) min(x,min(y,z))
#define chmin(x,y) x=min(x,y)
#define chmax(x,y) x=max(x,y)
#define ln '\n'
#define bln(i,n) (((i)==(n)-1)?'\n':' ')
#define dbg(x) cout<<#x" = "<<(x)<<ln<<flush
#define dbga(x,n) {cout<<#x" : ";for(int (i)=0;i<(n);++i){cout<<((x)[i])<<(i==((n)-1)?'\n':' ')<<flush;}}
#define zero(a) memset(a,0,sizeof(a))
#define unq(a) sort(all(a)),a.erase(unique(all(a)),a.end())

//typedef complex<double> P;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<string> vst;
typedef vector<pii> vpii;
typedef vector<pll> vpll;
typedef vector<vector<int> > mat;

const ll inf = (ll)1e9+10;
const ll linf = (ll)1e18+10;
const ll mod = (ll)(1e9+7);
const int dx[] = {0, 1, 0, -1};
const int dy[] = {1, 0, -1, 0};
const int ddx[] = {0, 1, 1, 1, 0, -1, -1, -1};
const int ddy[] = {1, 1, 0, -1, -1, -1, 0, 1};
const double eps = 1e-10;

ll mop(ll a,ll b,ll m=mod) {ll r=1;a%=m;for(;b;b>>=1){if(b&1)r=r*a%m;a=a*a%m;}return r;}
ll gcd(ll a,ll b) {return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b) {return a/gcd(a,b)*b;}
bool ool(int x,int y,int h,int w) {return((x<0)||(h<=x)||(y<0)||(w<=y));}
bool deq(double a,double b) {return abs(a-b)<eps;}

struct oreno_initializer {
	oreno_initializer() {
		cin.tie(0);
		ios::sync_with_stdio(0);
	}
} oreno_initializer;



int n, x, y, dp[5050][5050][2], dp2[5050][2], sz[5050], g[5050], res;
vector<int> e[5050];

void rec(int v, int p) {
	sz[v] = 1, dp[v][1][0] = 1;
	each(i,e[v]) if (i!=p) {
		rec(i,v);
		memset(dp2,0,sizeof(dp2));
		reps(x,1,sz[v]+1) reps(y,1,sz[i]+1) {
			// v-i間の辺を取り除く場合
			(dp2[x][0] += dp[v][x][0]*dp[i][y][1]%mod*g[y] + dp[v][x][1]*dp[i][y][0]%mod*g[y]) %= mod;
			(dp2[x][1] += dp[v][x][0]*dp[i][y][0]%mod*g[y] + dp[v][x][1]*dp[i][y][1]%mod*g[y]) %= mod;
			// 取り除かない場合
			(dp2[x+y][0] += dp[v][x][0]*dp[i][y][0] + dp[v][x][1]*dp[i][y][1]) %= mod;
			(dp2[x+y][1] += dp[v][x][0]*dp[i][y][1] + dp[v][x][1]*dp[i][y][0]) %= mod;
		}
		swap(dp[v],dp2);
		sz[v] += sz[i];
	}
}

signed main() {
	g[2] = 1;
	reps(i,4,5050) g[i] = g[i-2]*(i-1) %mod;
	cin >> n;
	rep(i,n-1) {
		cin >> x >> y;
		x--, y--;
		e[x].push_back(y), e[y].push_back(x);
	}
	rec(0,-1);
	reps(i,1,n+1) (res += (dp[0][i][0]-dp[0][i][1])*g[i]) %= mod;
	(res += mod) %= mod;
	cout << res << endl;
}

Measured memory_bytes: 395648
#include <iostream>
#include <algorithm>
#include <numeric>
#include <cstring>
#include <cctype>
#include <cstdio>
#include <sstream>
#include <cmath>
#include <bits/stdc++.h>
#include <string>


using namespace std;

int main()
{
    string a,b,str;
    cin>>a>>b;
    str=a+b;
    int c;
    istringstream(str)>>c;
    int i = sqrt(c);
    if(i*i==c){
        cout<<"Yes"<<endl;
    }else{
        cout<<"No"<<endl;
    }


    return 0;
}

Measured memory_bytes: 256
#pragma GCC optimize("O2")
#pragma GCC optimize("unroll-loops")
#include<bits/stdc++.h>
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define pb push_back
using namespace std;
using ll = long long;
//using arr = array;
using pi = pair<ll, ll>;
using vi = vector<ll>;
using vpi = vector<pi>;
using ld = long double;
const int maxn = 1<<17, mod = 1e9 + 7, lg = 19;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
int main() {
	ios::sync_with_stdio(0);
	cin.tie(0);
	ll n, ans = 0;
	cin >> n;
	for(int i = 1; i <= n; i++)
		if((i%5)&&(i%3)) ans += i;
	cout << ans;
	return 0;
}


Measured memory_bytes: 3660
import java.util.*;
public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int number = sc.nextInt();
    int min = 30;
    for (int i = 0; i < number; i++) {
      int value = sc.nextInt();
      int count = 0;
      while(value % 2 == 0) {
        value /= 2;
        count++;
      }
      if (count < min) {
        min = count;
      }
      
    }
    System.out.println(min);
  }
}

Measured memory_bytes: 21204
import re

SUM = 0
while True:
    try:
        text = input()
        while True:
            try:
                pattern = '.*?(\d+)'
                result = re.match(pattern, text)
                SUM += int(result.group(1))
                
                textlist = list(text)
                i = text.find(str(result.group(1)))
                del(textlist[0:i+len(str(result.group(1)))])
                text = ''.join(textlist)
            except:
                break
        continue
    except:
        break
print(SUM)


Measured memory_bytes: 6548
n = int(input())
def count(s):
    if len(s) == len(str(n)):
        if ('3' in s) and ('5' in s) and ('7' in s) and (int(s) <= n) and not ('0' in str(int(s))):
            #print(s)
            return 1
        else:
            return 0
    ret = 0
    for i in "0357":
        ret += count(s+i)
    return ret

print(count(""))


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

int main() {
    vector<ll> t(2),a(2),b(2);
    for (int i=0;i<2;i++) cin >> t[i];
    for (int i=0;i<2;i++) cin >> a[i];
    for (int i=0;i<2;i++) cin >> b[i];
    if (a[0]<b[0]) {
        swap(a[0],b[0]);
        swap(a[1],b[1]);
    }
    a[0]=a[0]-b[0];
    b[0]=0;
    a[1]=a[1]-b[1];
    b[1]=0;
    for (int i=0;i<2;i++) {
        a[i]*=t[i];
        b[i]*=t[i];
    }
    ll p=a[0]+a[1];
    if (p==0) cout << "infinity" << endl;
    else if (p>0) cout << 0 << endl;
    else {
        ll s=a[0]/(-p),t=a[0]%(-p);
        if (t==0) cout << 2*s << endl;
        else cout << 2*s+1 << endl;
    }
}

Measured memory_bytes: 256
using System;

namespace Unchi
{
    class unchi
    {
        static void Main()
        {
            while (true)
            {
                int N = int.Parse(Console.ReadLine());
                if (N == 0) break;

                long res = dfs(N) / 10 / 365;

                Console.WriteLine(res + 1);
            }
        }

        static long[] dfsMemo = new long[31];

        static long dfs(int count)
        {
            if (count == 0)
            {
                return 1;
            }
            else if (count < 0)
            {
                return 0;
            }
            return dfsMemo[count] = dfs(count - 1) + dfs(count - 2) + dfs(count - 3);
        }
    }
}

Measured memory_bytes: 8956
// bismillah .....
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////
#define  boost ios_base::sync_with_stdio(false);cin.tie(NULL);
#define ull unsigned long long
#define deb(x) cout<<#x<<" "<<x<<endl;
#define deb2(x,y) cout<<#x<<" "<<x<<" "<<#y<<" "<<y<<endl;
#define deb2l(x,y,i) cout<<#x<<i<<" "<<x<<" "<<#y<<i<<" "<<y<<endl;

#define fr(i,l,r) for(ll i=l;i<r;i++)
#define mems(a,x) memset(a,x,sizeof(a))
#define mod 998244353
#define ff first
#define ss second
#define pb(x) push_back(x)
#define vll vector<ll>
#define pbp(x,y) push_back(make_pair(x,y))
#define  mat vector<vector<ll>>
 void solve(){
    ll a,b,c;
    cin>>a>>b>>c;
    ll ans=a+b-c;
    ans=abs(ans);
    ans*=ans;
  //  deb2(ans,4*a*b)
    if(ans>4*a*b && a+b-c<0)
    cout<<"Yes";
    else cout<<"No";

 }
int main(){
    boost;
    ll t=1;
   // cin>>t;
    while(t--){
        solve();
        cout<<endl;
    }
    return 0;
}

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

typedef long long int ll;

int main(){
	ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
	int n, m;
	ll k;
	cin >> n >> m >> k;
	ll a[n], b[m];
	for (int i = 0; i < n; i++) cin >> a[i];
	for (int i = 0; i < m; i++) cin >> b[i];

	ll A[n+1], B[m+1];
	A[0] = 0;
	B[0] = 0;
	for (int i = 1; i <= n; i++) A[i] = a[i-1] + A[i-1];
	for (int i = 1; i <= m; i++) B[i] = b[i-1] + B[i-1];

	int maxo = 0, j = m;
	for (int i = 0; i <= n; i++){
		while(j > 0 && A[i] + B[j] > k) --j;

		if (A[i] + B[j] > k)
			break;

		if (i + j > maxo) {
			maxo = i + j;
		}
	}
	cout << maxo << '\n';
}

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

#define int long long

int field[1500001] = {0};
signed main()
{
    int n, m;
    while(cin>>n>>m, n) {
        for(int i=0; i<1500000; ++i) field[i] = 0;
        vector<int> h(n+1);
        vector<int> w(m+1);
        for(int i=1; i<=n; ++i) {
            cin >> h[i];
            h[i] += h[i-1];
        }
        for(int i=1; i<=m; ++i) {
            cin >> w[i];
            w[i] += w[i-1];
        }

        for(int i=0; i<=n; ++i) {
            for(int j=i+1; j<=n; ++j) {
                field[h[j]-h[i]]++;
            }
        }
        int ans = 0;
        for(int i=0; i<=m; ++i) {
            for(int j=i+1; j<=m; ++j) ans += field[w[j]-w[i]];
        }
        cout << ans << endl;
    }
    return 0;
}

Measured memory_bytes: 14816
# encoding: utf-8
N, M = list(map(int, input().split()))

d_sym = {}
sym = 0

# refresh

ans = 0
for A in map(int, input().split()):
    sym = (sym + A) % M
    #
    if sym == 0: ans += 1
    # 
    if str(sym) in d_sym.keys(): d_sym[str(sym)] += 1
    else: d_sym[str(sym)] = 1

print(int(ans + sum([val * (val - 1) / 2 for val in d_sym.values()])))


Measured memory_bytes: 17464
#include <stdio.h>

main() {
  int i, j, H, W;
  
  while(1){
    
    scanf("%d %d", &H, &W);
    
    if (H == 0 && W == 0) break; 
    for (i = 0; i < H; i++) {
      for (j = 0; j < W; j++) {
	if ( (i % 2 == 0 && j % 2 == 0) || (i % 2 == 1 && j % 2 == 1)) {
	  printf("#");
	} else {
	  printf(".");
	}
      }
      printf("\n");
    }
    printf("\n");
  }
  return 0;
}

Measured memory_bytes: 572
#
#    ------------------------------------------------
#           ____          _     Generatered using
#          / ___|        | |
#         | |    __ _  __| | ___ _ __  ______ _
#         | |   / _` |/ _` |/ _ \ '_ \|_  / _` |
#         | |__| (_| | (_| |  __/ | | |/ / (_| |
#          \____\____|\____|\___|_| |_/___\____|
#
#      GNU Affero General Public License v3.0
#    ------------------------------------------------
#    Author   : prophet
#    Created  : 2020-07-25 08:05:35.508699
#    UUID     : idTjzDkOmGFPLyah
#    ------------------------------------------------
#
production = True

import sys, math, collections

def input(f = 0, m = 0):

    if m > 0: return [input(f) for i in range(m)]
    else:
        l = sys.stdin.readline()[:-1]

        if f >= 10:
            u = False
            f = int(str(f)[-1])
        else: u = True

        if f == 0: p = [l]
        elif f == 1: p = list(map(int, l.split()))
        elif f == 2: p = list(map(float, l.split()))
        elif f == 3: p = list(l)
        elif f == 4: p = list(map(int, list(l)))
        elif f == 5: p = l.split()

        return p if u else p[0]

def out(l, f = 0, n = True):

    if f == 0: p = str(l)
    elif f == 1: p = " ".join(map(str, l))
    elif f == 2: p = "\n".join(map(str, l))
    elif f == 3: p = "".join(map(str, l))

    print(p, end = "\n" if n else "")

def log(*args):
    if not production:
        print("$$$", end = "")
        print(*args)

enu = enumerate
ter = lambda a, b, c: b if a else c
ceil = lambda a, b: -(-a // b)
flip = lambda a: (a + 1) & 1

def mapl(i, f = 0):

    if f == 0: return list(map(int, i))
    elif f == 1: return list(map(str, i))
    elif f == 2: return list(map(list, i))

#
#   >>>>>>>>>>>>>>> START OF SOLUTION <<<<<<<<<<<<<<
#


def solve():

    a, b, c = input(1)
    k = input(11)

    while b <= a:
        b *= 2
        k -= 1

    while c <= b:
        c *= 2
        k -= 1

    log(k)
    out(ter(k >= 0, "Yes", "No"))

    return


solve()

#
#   >>>>>>>>>>>>>>>> END OF SOLUTION <<<<<<<<<<<<<<<
#


Measured memory_bytes: 65348
<?php
list($H, $N) = array_map("intval", explode(" ", trim(fgets(STDIN))));
$dp = array_fill(0, $H + 1, 10**18);
$dp[0] = 0;
for($i = 1; $i <= $N; $i++){
  fscanf(STDIN, "%d%d", $a, $b);
  for($j = 1; $j <= $H; $j++){
    if($j - $a >= 0){
      if($dp[$j]>$dp[$j-$a]+$b)$dp[$j] = $dp[$j-$a]+$b;
    }else{
      if($dp[$j]>$b)$dp[$j] = $b;
    }
  }
}
echo $dp[$H];

Measured memory_bytes: 4728
#include<bits/stdc++.h>
using namespace std;
#define fs first
#define sc second
#define mp make_pair
#define pb push_back
#define eb emplace_back
#define ALL(A) A.begin(),A.end()
#define RALL(A) A.rbegin(),A.rend()
typedef long long LL;
typedef pair<LL,LL> P;
const LL mod=1e9+7;
const LL LINF=1LL<<62;




int main(){
    int n;cin >> n;
    vector<LL> a(1<<n);
    for (int i = 0; i < (1<<n); i++) {
        cin >> a[i];
    }
    vector<P> dp(1<<n,P(-1,-1));
    for (int k = 0; k < (1<<n); k++) {
        vector<P> t;
        t.pb(P(a[k],k));
        for (int i = 0; i < n; i++) {
            if(k&(1<<i)){
                P p = dp[k-(1<<i)];
                if(p.fs!=-1) t.pb(P(a[p.fs],p.fs));
                if(p.sc!=-1) t.pb(P(a[p.sc],p.sc));
            }
        }
        sort(ALL(t),greater<P>());
        t.erase(unique(ALL(t)),t.end());
        if(t.size()>=2) dp[k]=P(t[0].sc,t[1].sc);
        else if(t.size()==1) dp[k]=P(t[0].sc,-1);
    }
    LL ans = 0;
    for (int i = 1; i < (1<<n); i++) {
        ans = max(ans,a[dp[i].fs]+a[dp[i].sc]);
        cout << ans << endl;
    }
    return 0;
}



Measured memory_bytes: 9216
#include <iostream>
#include <cstdio>
#include <cstring>
#include <climits>
#include <string>
#include <algorithm>
#include <cmath>
#include <vector>
#include <stack>
#include <queue>
#include <map>
#include <unordered_map>
#include <set>
#include <unordered_set>
#include <sstream>
#include <numeric>
#include <iomanip>
// #include <boost/multiprecision/cpp_dec_float.hpp>
// #include <boost/multiprecision/cpp_int.hpp>

///////////////////////////////////////////////////////////////
// namespace
///////////////////////////////////////////////////////////////
using namespace std;
// namespace mp = boost::multiprecision;

///////////////////////////////////////////////////////////////
// types
///////////////////////////////////////////////////////////////
using ll = long long int;
using ld = long double;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
// using mpi = mp::cpp_int;
// using mpf = mp::number<mp::cpp_dec_float<1024>>;

///////////////////////////////////////////////////////////////
// mod https://qiita.com/drken/items/3b4fdf0a78e7a138cd9a
///////////////////////////////////////////////////////////////
// ll MOD = 1000000007;
//
//  ll mod(ll val) {
//      ll res = val % MOD;
//      if (res < 0) res += MOD;
//      return res;
//  }
//
// ll modinv(ll a) {
//     ll b = MOD, u = 1, v = 0;
//     while (b) {
//         ll t = a / b;
//         a -= t * b; swap(a, b);
//         u -= t * v; swap(u, v);
//     }
//     u %= MOD;
//     if (u < 0) u += MOD;
//     return u;
// }
//
// const int MAX = -1;
// ll fac[MAX], finv[MAX], inv[MAX];
// void com_init() {  // initialize nCk table with O(N)
//     fac[0] = fac[1] = 1;
//     finv[0] = finv[1] = 1;
//     inv[1] = 1;
//     for (int i = 2; i < MAX; i++){
//         fac[i] = fac[i - 1] * i % MOD;
//         inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
//         finv[i] = finv[i - 1] * inv[i] % MOD;
//     }
// }
// ll com(int n, int k){  // nCk
//     if (n < k) return 0;
//     if (n < 0 || k < 0) return 0;
//     return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
// }


int main() {
    ll n; cin >> n;
    vector<ll> v;
    unordered_map<ll, vector<ll>> m;
    for (ll i = 0; i < n; ++i) {
        ll a; cin >> a;
        v.push_back(i + a);
        m[i - a].push_back(i);
    }
    ll ans = 0;
    for (int i = 0; i < n; ++i) {
        ans += distance(upper_bound(m[v[i]].begin(), m[v[i]].end(), i), m[v[i]].end());
    }
    cout << ans << endl;
    // cout << setprecision(10);
    return 0;
}


Measured memory_bytes: 31780
n,m=map(int,input().split())
ls=[]
count,cnt=0,0
a=0

for i in range(n):
  ls.append(list(map(int,input().split())))
  
for i in range(1,m+1):
  for j in ls:
    if i in ls[a][1:]:
      count+=1
      
    a+=1
      
  if count==n:
    cnt+=1
    
  a=0
  count=0
    
print(cnt)

Measured memory_bytes: 3064
// Template {{{
#include <bits/stdc++.h>
#define REP(i,n) for(int i=0; i<(int)(n); ++i)
using namespace std;
typedef long long LL;

#ifdef LOCAL
#include "contest.h"
#else
#define dump(x) 
#endif

const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
inline bool valid(int x, int w) { return 0 <= x && x < w; }

void iostream_init() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.setf(ios::fixed);
    cout.precision(12);
}
//}}}

int main(){
    iostream_init();
    LL N, X;
    cin >> N >> X;
    LL H = N - X;
    LL W = X;
    LL ans = W + H;
    while(W > 0) {
        LL k = H / W;
        ans += k * 2 * W;
        if(H % W == 0) ans -= W;
        LL tmpH = H;
        H = W;
        W = tmpH % W;
    }
    cout << ans << endl;
    return 0;
}



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

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

	int A, B, C;
	cin >> A >> B >> C;
	int s[100];
	for (int i = 1; i < B; i++) {
		if (A * i % B == C) {
			cout << "YES";
			return 0;
		}
	}
	cout << "NO";
	
}


Measured memory_bytes: 256
# include <iostream>
# include <stdio.h>
using namespace std;
int main(){
  string number;
  int sum,check;
  sum = 0;
  while(1){
    cin >> number;
    check = number[0] - '0';
    if( check == 0){
      break;
    }
    for(int i = 0;i < number.size();i++){
      sum += number[i] - '0';
    }
    cout << sum << "\n";
    sum = 0;
  }
  return 0;
}


Measured memory_bytes: 3156
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#pragma GCC optimize("unroll-loops")

#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace std;
using namespace __gnu_pbds;

#define DEBUG
#ifdef DEBUG
#define debug(...) __f(#__VA_ARGS__, __VA_ARGS__)
	template <typename Arg1>
	void __f(const char* name, Arg1&& arg1)
	{
		cerr << name << " = " << arg1 << endl;
	}
	template <typename Arg1, typename... Args>
	void __f(const char* names, Arg1&& arg1, Args&&... args)
	{
		const char* comma = strchr(names + 1, ','); cerr.write(names, comma - names) << " = " << arg1 << " || ";
		__f(comma+1, args...);
	}
#else
#define debug(...)
#endif

template <class Ch, class Tr, class Container>
basic_ostream <Ch, Tr> & operator << (basic_ostream <Ch, Tr> & os, Container const& x) {
    os << "{ ";
    for(auto& y : x) os << y << " ; ";
    return os << "}";
}

template <class X, class Y>
ostream & operator << (ostream & os, pair <X, Y> const& p) {
	return os << "[ " << p.first << ", " << p.second << "]" ;
}

#define FAST_IO std::ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define ll long long int
#define pb push_back
#define mp make_pair
#define ld long double
#define sz(a) (ll)(a).size()
#define endl "\n"

// priority_queue<ll, vector<ll>, less<ll>>pq;     // Max Heap
// priority_queue<ll, vector<ll>, greater<ll>>pq;  // Min Heap

typedef tree<ll,null_type,less<ll>,rb_tree_tag,tree_order_statistics_node_update> ordered_set;
//K-th smallest
//cout << k << "kth (1 based indexing) smallest: " << *A.find_by_order(k - 1) << endl;
//NO OF ELEMENTS < X
//cout << "No of elements less than " << X << " are " << A.order_of_key(X) << endl;

int main()
{
	FAST_IO;

 	ll n, m;
 	cin >> n >> m;
 	cout << ((n * (n - 1)) + (m * (m - 1))) / 2 << endl;   
    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
int main()
{
  int r;
  int g;
  int b;
  scanf("%d %d %d",&r,&g,&b);
  int c=r*100+g*10+b;
  if (c%4==0)
  {
    printf("%s\n","YES");
  }
  else
  {
    printf("%s\n","NO");
  }
}

Measured memory_bytes: 128
#include<stdio.h>
#include<stdlib.h>

int main(void){
    int s,n4,n3,n2,n1,f,l;

    scanf("%d",&s);

    for(n4 = 0; s >= 1000; n4++){
        s = s - 1000;
    }
    for(n3 = 0; s >= 100; n3++){
        s = s - 100;
    }
    for(n2 = 0; s >= 10; n2++){
        s = s - 10;
    }
    for(n1 = 0; s >= 1; n1++){
        s = s - 1;
    }

    f = 10*n4 + n3;
    l = 10*n2 + n1;
    

    if(f >= 1 && f <= 12){
        if(l >= 1 && l <= 12){
            printf("AMBIGUOUS");
        }else{
            printf("MMYY");
        }
        exit (0);
    }
    if(l >= 1 && l <= 12){
        if(f >= 1 && f <= 12){
            printf("AMBIGUOUS");
        }else{
            printf("YYMM");
        }
        exit (0);
    }
    printf("NA");




}

Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
using ll  = long long;
using vvl = vector<vector<ll>>;
using vl  = vector<ll>;
#define _GLIBCXX_DEBUG
#define acc_io cin.tie(0);ios::sync_with_stdio(false)
#define all(x) x.begin(),x.end()
#define rep(i,sta,end) for(ll i=sta;i<end;++i)
#define lcm(a,b) (a)/__gcd((a),(b))*(b)
#define pb push_back
#define DBG(a,b,c,d) cout<<a<<" "<<b<<" "<<c<<" "<<d<<" "<<endl
const ll MOD = 1000000007;
const double PI = acos(-1);  
//name[i]   -> vl  name(i)
//name[i][j]-> vvl name(i,vl(j))
//or-> ||
//map<int,int>mp

signed main(){
	acc_io;
	int h,w;
	cin>>h>>w;
	vector<string>s(h);
	rep(i,0,h) cin>>s[i];
	rep(i,0,h){
		cout<<s[i]<<endl;
		cout<<s[i]<<endl;
	}
	return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
using namespace std;
int main() {
	int a, b;
	string c;
	cin >> a >> b >> c;
	for (int i = 1; i <= b; i++) {
		for (int z = 1; z <= a; z++) {
			if (i == 1||i==b) {
				if (z == 1 || z == a) {
					cout << "+";
					if (z == a) {
						cout << endl;
					}
				}
				else {
					cout << "-";
				}
			}
			else {
				if (z == 1 || z == a) {
					cout << "|";
					if (z == a) {
						cout << endl;
					}
				}
				else {
					if ((a + 1) / 2 == z && (b + 1) / 2 == i) {
						cout << c;
					}
					else {
						cout << ".";
					}
				}
			}
		}
	}
}


Measured memory_bytes: 3168
void main()
{
    long n = rdElem;
    long[] a = rdRow;

    long total;
    long[long] lists;
    ++lists[total];
    foreach (i; 0 .. n)
    {
        total += a[i];
        ++lists[total];
    }

    long result;
    foreach (x; lists.byValue)
    {
        result += x * (x - 1) / 2;
    }

    result.writeln;
}

enum long mod = 10^^9 + 7;
enum long inf = 1L << 60;

T rdElem(T = long)()
if (!is(T == struct))
{
    return readln.chomp.to!T;
}

alias rdStr = rdElem!string;
alias rdDchar = rdElem!(dchar[]);

T rdElem(T)()
if (is(T == struct))
{
    T result;
    string[] input = rdRow!string;
    assert(T.tupleof.length == input.length);
    foreach (i, ref x; result.tupleof)
    {
        x = input[i].to!(typeof(x));
    }
    return result;
}

T[] rdRow(T = long)()
{
    return readln.split.to!(T[]);
}

T[] rdCol(T = long)(long col)
{
    return iota(col).map!(x => rdElem!T).array;
}

T[][] rdMat(T = long)(long col)
{
    return iota(col).map!(x => rdRow!T).array;
}

void wrMat(T = long)(T[][] mat)
{
    foreach (row; mat)
    {
        foreach (j, compo; row)
        {
            compo.write;
            if (j == row.length - 1) writeln;
            else " ".write;
        }
    }
}

import std.stdio;
import std.string;
import std.array;
import std.conv;
import std.algorithm;
import std.range;
import std.math;
import std.numeric;
import std.traits;
import std.container;
import std.functional;
import std.typecons;
import std.ascii;
import std.uni;

Measured memory_bytes: 25228
#include <bits/stdc++.h>
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n) FOR(i,0,n)
#define repr(i,n) for(int i=(n)-1;0<=i;--i)
#define each(e,v) for(auto&& e:(v))
#define all(v) begin(v),end(v)
#define dump(x) cerr<<#x<<": "<<(x)<<endl
using namespace std;
using vint = vector<int>;
using ll = long long;
using vll = vector<ll>;
template <class T> void chmin(T& a, const T& b) { a = min(a, b); }
template <class T> void chmax(T& a, const T& b) { a = max(a, b); }
void yes() { cout << "Yes" << endl; exit(0); }
void no() { cout << "No" << endl; exit(0); }

int main() {
    int n; cin >> n;
    vint a(n);
    rep(i, n) cin >> a[i];
    vint b;
    int cnt = 1;
    FOR(i, 1, n) {
        if(a[i-1] != a[i]) {
            b.push_back(cnt);
            cnt = 1;
        } else {
            cnt++;
        }
    }
    b.push_back(cnt);

    int ans = 0;
    for(int m: b) {
        if(m == 1) continue;
        ans += m / 2;
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
n = int(input())
v = list(map(int,input().split()))
c = list(map(int,input().split()))
get =[]
for i in range(n):
    get.append(v[i]-c[i])
ans = 0
for i in range(n):
    if get[i]>= 0:
        ans += get[i]
    else:
        continue
print(ans)

Measured memory_bytes: 38460