akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;

using ll = long long;
using Pi = pair<int, int>;
using Pl = pair<ll, ll>;
using vint = vector<int>;
using vvint = vector<vint>;
using vvvint = vector<vvint>;
using vdouble = vector<double>;
using vvdouble = vector<vdouble>;
using vvvdouble = vector<vvdouble>;
using vll = vector<ll>;
using vvll = vector<vll>;
using vvvll = vector<vvll>;
using uint = unsigned int;
using ull = unsigned long long;

template<typename T> using uset = unordered_set<T>;
template<typename T1, typename T2> using umap = unordered_map<T1, T2>;

constexpr int INF = (1 << 30) - 1;
constexpr ll LLINF = 1LL << 60;
constexpr int dy[] = {1, 0, -1, 0, 1, -1, -1, 1};
constexpr int dx[] = {0, 1, 0, -1, 1, 1, -1, -1};
constexpr char el = '\n';
constexpr int mod = 1000000007;
constexpr int mod2 = 998244353;
template<typename T> T gcd(T a, T b) { return (b ? gcd(b, a % b) : a); }
template<typename T> T lcm(T a, T b) { return (a / gcd(a, b) * b); }
template<typename T1, typename T2>
inline bool chmin(T1 &a, T2 b) { return (a > b && (a = b, true)); }
template<typename T1, typename T2>
inline bool chmax(T1 &a, T2 b) { return (a < b && (a = b, true)); }

template<typename T>
vector<T> makeVector(size_t a, T b) { return (vector<T>(a, b)); }
template<typename... Ts>
auto makeVector(size_t a, Ts... ts) { 
	return (vector<decltype(makeVector(ts...))>(a, makeVector(ts...)));
}

template<typename T>
bool isin(T y, T x, T h, T w) { return (0 <= y && 0 <= x && y < h && x < w); }
template<typename T>
bool isin1(T y, T x, T h, T w) { return (0 < y && 0 < x && y <= h && x <= w); }

template<typename T>
ostream& operator <<(ostream &os, vector<T> &v) {
	if (v.size()) {
		os << v[0];
		for (int i = 1; i < v.size(); i++) os << " " << v[i];
	}
	return (os);
}

template<typename T>
istream& operator >>(istream &is, vector<T> &v) {
	for (auto &u : v) is >> u;
	return (is);
}

template<typename T1, typename T2>
istream& operator >>(istream &is, pair<T1, T2> &p) {
	return (is >> p.first >> p.second);
}


void Main() {
	int L; cin >> L;
	int n = 0;
	while ((1ll<<n) <= L) n++;
	n--;

	vector<tuple<int, int, int>> ans;
	int val = L-(1ll<<n);

	int ad = 0;
	for (int i = 0; i < n; i++) {
		if ((val>>i)&1) {
			ans.emplace_back(i+1, n+1, (1ll<<n) + ad);
			ad += (1<<i);
		}
		ans.emplace_back(i+1, i+2, 1ll<<i);
		ans.emplace_back(i+1, i+2, 0);
	}

	cout << n+1 << " " << ans.size() << endl;
	for (auto &an : ans) {
		int a, b, c; tie(a, b, c) = an;
		cout << a << " " << b << " " << c << el;
	}
}

int main() {
	cin.tie(0);
	ios::sync_with_stdio(0);
	cout << fixed << setprecision(20);
	Main();
	return (0);
}


Measured memory_bytes: 3656
#include<stdio.h>
#include<math.h>
#include<stdlib.h>
#include<string.h>
#define max(x,y)(x>y?x:y)
#define min(x,y)(x>y?y:x)
typedef long long int ll;
typedef unsigned long long int ull;;
ll asc_cmp(ll x,ll y){if(x<y)return -1;else if(x==y)return 0;else return 1;}
ll desc_cmp(ll x,ll y){if(x<y)return 1;else if(x==y)return 0;else return -1;}

int main(){
    char s[200];scanf("%s",s);
    for(int i=0;i<strlen(s);i++)printf("x");
    printf("\n");
}

Measured memory_bytes: 128
/**
 *      purpose : 
 *      author  : kyomukyomupurin
 *      created : 
**/

// input/output
#include <iostream>
#include <fstream>
#include <sstream>
// container class
#include <array>
#include <deque>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>
// math, algorithm
#include <algorithm>
#include <cmath>
#include <complex>
#include <numeric>
// etc
#include <bitset>
#include <cctype>
#include <cstring>
#include <chrono>
#include <iomanip>
#include <random>
#include <utility>
// using-directive
using namespace std;
// alias template
using int64 = int64_t;
using pii = pair<int, int>;
using pll = pair<int64_t, int64_t>;
// text macro replacement
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()
#define print(x) cout << (x) << '\n'
#define debug(x) cout << #x << ": " << (x) << '\n'


struct SegmentTree{
  private:
    int n;
    vector<int64> dat;
  public:
    SegmentTree(vector<int64> v) {
      int SIZE = v.size();
      n = 1;
      while (n < SIZE) n <<= 1;
      dat.resize(2 * n - 1, 0);
      for (int i = 0; i < SIZE; ++i) dat[i + n - 1] = v[i];
      for (int i = n - 2; i >= 0; --i) dat[i] = __gcd(dat[2 * i + 1], dat[2 * i + 2]);
    }

    void update(int pos, int val){
      pos += n - 1;
      dat[pos] = val;
      while (pos > 0){
        pos = (pos - 1) / 2;
        dat[pos] = __gcd(dat[2 * pos + 1], dat[2 * pos + 2]);
      }
    }

    int64 query(int a, int b, int k = 0, int l = 0, int r = -1){
      if (r < 0) r = n;
      if (r <= a || b <= l) return 0;
      if (a <= l && r <= b) return dat[k];
      int vl = query(a, b, 2 * k + 1, l, (l + r) / 2);
      int vr = query(a, b, 2 * k + 2, (l + r) / 2, r);
      return __gcd(vl, vr);
    }
};

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

  int n; cin >> n;
  
  vector<int64> v(n); rep(i, n) cin >> v[i];
  SegmentTree seg(v);

  int64 ans = max(seg.query(1, n), seg.query(0, n - 1));

  for (int i = 1; i <= n - 2; ++i){
    ans = max(ans, __gcd(seg.query(0, i), seg.query(i + 1, n)));
  }

  print(ans);
  
  return 0;
}


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

    int main() {
        string S;
        cin >> S;
        int N = S.size();
        string S2,S3;
        S2 = S.substr(0,((N-1)/2));
        S3 = S.substr( ((N+3)/2)-1,N-1);

        for(int i=0;i<N/2;i++){
            if(S[i] != S[N-i-1]){
                cout << "No" << endl;
                return 0;
            }
        }

        int N2 = S2.size();

        for(int i=0;i<N2/2;i++){
            if(S2[i] != S2[N2-i-1]){
                cout << "No" << endl;
                return 0;
            }
        }

        
        
        int N3 = S3.size();
        for(int i=0;i<N3/2;i++){
            if(S3[i] != S3[N3-i-1]){
                cout << "No" << endl;
                return 0;
            }
        } 

        


        cout << "Yes" << endl;
        return 0;

    }


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


typedef  long long ll;

ll n,m=0,k=0;

bool test=false,test1=false;

ll const N=1e5+7;

ll const oo=1000000007 ;

ll nChoosek( ll n, ll k )
{
    if (k > n) return 0;
    if (k * 2 > n) /*return*/ k = n-k;  //remove the commented section
    if (k == 0) return 1;

    ll result = n;
    for( ll i = 2; i <= k; ++i ) {
        result *= (n-i+1);
        result /= i;
    }
    return result;
}

vector<ll> v,v1;

vector<pair<ll,ll> > vv;

//ll  t[oo][oo];

map<pair<ll,ll> ,ll> my;

map<ll,ll> my1;

priority_queue<ll> q;

ll t[N];

ll t1[N];

ll dx[4]={0,1,0,-1};
ll dy[4]={1,0,-1,0};



bool in_da_prison(ll x,ll y)
{
    return (x<9   && x>=0  && y<9 && y>=0);
}


ll dp(ll k,ll i)
{if(i==n    && k>0) return 1e18+2;
if(k==0) return 0;

if(my.count(make_pair(k,i))) return my[make_pair(k,i)];
   ll  x=k/(1<<i);
   ll  y=k%(1<<i);
   if(x==0) {x++;y=0;}
    return my[make_pair(k,i)]=min(v[i]*x+dp(y,0),dp(k,i+1));
}
bool cont(ll x)
{
    if(x%10==7 || x/10==7) return true;
    else return false;
}


vector<ll> v2[N];
ll z[N];
void dfs(ll s)
{
    if (z[s]) return;
 z[s] = 1;
 for (ll u=0;u<v2[s].size();u++)
    { dfs(v2[s][u]); }
 }

int main() {


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

ll i=0,j=0,a=0,b=0,c=0,d=-1e18,x=0,y=0,s=0;
string s1,s2,s3,s4,s5;
cin>>x>>a>>b;
x-=a;
cout<<x%b;

   return 0;

}


Measured memory_bytes: 3584
#include <iostream>
#include <algorithm>

using namespace std;

#define MAX_R 10
#define MAX_C 10000

int r,c;
bool a[MAX_R][MAX_C];
int ans;

void solve(int pos){
  if(pos == r){
    int res = 0;
    for(int i = 0 ; i < c ; i++){
      int cnt = 0;     
      for(int j = 0 ; j < r ; j++){
	if(a[j][i]) cnt++;
      }
      cnt = max(cnt,r-cnt);
      res += cnt;
    }
    ans = max(ans,res);
    return;
  }

  solve(pos+1);

  for(int i = 0 ; i < c ; i++){
    a[pos][i] = !a[pos][i];
  }

  solve(pos+1);
}

int main(){
  while(cin >> r >> c , (r | c)){
    for(int i = 0 ; i < r ; i++){
      for(int j = 0 ; j < c ; j++){
	cin >> a[i][j];
      }
    }
    ans = 0;
    solve(0);
    cout << ans << endl;
  }

  return 0;
}

Measured memory_bytes: 1256
n = int(input())
lst = []
for i in range(n):
    x,l = map(int,input().split())
    lst.append((x,max(0,x-l),x+l))

lst.sort(key=lambda x:x[1])

ans = n
pos = 0
tmp_l,tmp_r = 0,0
for i in range(n):
    x,l,r = lst[i]
    if i==0:
        pos = x
        tmp_l, tmp_r = l,r
    else:
        #かぶりなし
        if tmp_r <= l:
            pos = x
            tmp_l = l
            tmp_r = r
        #かぶりあり
        else:
            ans -= 1
            if tmp_r <= r:
                continue
            else:
                pos = x
                tmp_l = l
                tmp_r = r
print(ans)

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

int main() {
  int N;
  cin>>N;
  int a[100001];
  for (int i=0;i<100001;i++) a[i]=0;

  for(int i=0;i<N;i++){
    int b;
    cin>>b;
    if(b==0){
      a[0] ++;
      a[1] ++;
    }
    else{
      a[b-1]++;
      a[b]++;
      a[b+1]++;
    }
  }
  int m=0;
  for(int i=0;i<100001;i++){
    m = max(m,a[i]);
  }
cout<<m<<endl;
}


Measured memory_bytes: 640
import math
from math import gcd,pi,sqrt
INF = float("inf")

import sys
sys.setrecursionlimit(10**6)
import itertools
from collections import Counter,deque
def i_input(): return int(input())
def i_map(): return map(int, input().split())
def i_list(): return list(i_map())
def i_row(N): return [i_input() for _ in range(N)]
def i_row_list(N): return [i_list() for _ in range(N)]
def s_input(): return input()
def s_map(): return input().split()
def s_list(): return list(s_map())
def s_row(N): return [s_input for _ in range(N)]
def s_row_str(N): return [s_list() for _ in range(N)]
def s_row_list(N): return [list(s_input()) for _ in range(N)]

import string

def main():
    n,k = i_map()
    r,s,p = i_map()
    dic = {"r":p,"s":r,"p":s}
    t = list(s_input())
    ans = 0

    for i,j in enumerate(t):
        if i < k:
            ans += dic[j]
        else:
            if j != t[i-k]:
                ans += dic[j]
            else:
                t[i] = "z"
    print(ans)



if __name__=="__main__":
    main()


Measured memory_bytes: 10864
#include <bits/stdc++.h>
#define MAX 100010
using namespace std;
int main(void){
    string s;
    cin >> s;
    int change=0;
    int ans=0;
    for(int i=1;i<s.size();i++){
        if(s.at(i-1)!=s.at(i)){
            change++;
        }
    }
    cout << change<<endl;
 
}


Measured memory_bytes: 512
#include <stdio.h>
 
int main()
{
    int a = 0, b=0;
    int men = 0, shuu=0;
    scanf("%d", &a);
    scanf("%d", &b);

    men=a*b;
    shuu=2*(a+b);
    printf("%d %d\n", men, shuu);
    return 0;
}

Measured memory_bytes: 1024
n = int(input())

factors = set()
factor = 1
while factor * factor <= n:
    if n % factor == 0:
        factors.add(factor)
        factors.add(n // factor)
    factor += 1

total = 0
for factor in factors:
    k = factor - 1
    if k <= 0:
        continue

    div = n // k
    mod = n % k
    if div == mod:
        total += k

print(total)

Measured memory_bytes: 3828
#include <iostream>
#include <string>
#include <bits/stdc++.h>
#include <map>


using namespace std;

using ull = unsigned long long int;
using pp = pair<ull, ull>;

int mod = 1e9 + 7; 
// vector<pp> dp(1e5+1);


pp dfs(const vector<vector<int>>& G, int v, int p=0) {
    pp v_info{1,1};
    // dp[v].first = 1;
    // dp[v].second = 1;

    for (auto &&u : G[v])
    {
        if (u!=p) {
            auto u_info = dfs(G,u,v);
            v_info.first = (v_info.first * (u_info.first + u_info.second)) % mod;
            v_info.second = (v_info.second * u_info.first) % mod;
            // dp[v].first *= (u_info.first + u_info.second) % mod;            
            // dp[v].second *= (u_info.first % mod);
            // dp[v].first %= mod;
            // dp[v].second %= mod;
        } 
    }

    // return dp[v];
    return v_info;
}


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

    int N;
    cin>>N;
    vector<vector<int>> G;
    G.resize(N+1);
    int x,y;
    for (size_t i = 0; i < N-1; i++)
    {
        cin>>x>>y;
        G[x].push_back(y);
        G[y].push_back(x);
    }

    auto pp = dfs(G,1,0);
    cout << (pp.first + pp.second) % mod << "\n";
    
}

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

int main() {
  int n;
  cin >> n;
  for (int i=1; i<=n; i++) {
    if (i % 3 == 0) {
      printf(" %d", i);
    }
    else {
      for (int x = i; x != 0; x /= 10) {
        if (x % 10 == 3) {
          printf(" %d", i);
          break;
        }
      }
    }
  }
  cout << endl;
  return 0;
}



Measured memory_bytes: 3228
N, M, C = map(int, input().split())
Bn = [int(i) for i in input().split()]
An = [[int(j) for j in input().split()] for i in range(N)]


def main():
    ans = 0

    for i in range(N):
        num = 0
        for Bi, Ai in zip(Bn, An[i]):
            num += Ai * Bi
        if 0 < num + C:
            ans += 1

    print(ans)
    return


main()


Measured memory_bytes: 3060
#include<bits/stdc++.h>
#define PI 3.14159265358979323846264338327950L
using namespace std;
int main()
{
   int a, b, h, m;
   scanf("%d%d%d%d", &a, &b, &h, &m);
   long double rad = PI * 2 * ((long double)h / 12.0 + ((long double)m / 60.0) / 12.0 - (long double)m / 60.0);
   long double rsq = (long double)(a * a + b * b) - (long double)(2 * a * b) * cosl(rad);
   printf("%20.20Lf\n", sqrtl(rsq));
   return 0;
}


Measured memory_bytes: 4160
#pragma comment(linker, "/STACK:102400000,102400000")
#include <fstream>
#include <iostream>
#include <functional>
#include <algorithm>
#include <sstream>
#include <cstring>
#include <vector>
#include <string>
#include <cstdio>
#include <cmath>
#include <queue>
#include <stack>
#include <deque>
#include <ctime>
#include <list>
#include <set>
#include <map>
#include <bitset>
#include <cassert>
//#include <unordered_map>
//#include <unordered_set>
using namespace std;

typedef long long ll;
#define eps 1e-8
#define LL_INF 0x3fffffffffffffff
#define INF 0x3f3f3f3f
#define mem(a, b) memset(a, b, sizeof(a))
#define pper(i,n,m) for(int i = n;i >= m; i--)
#define repp(i, n, m) for (int i = n; i <= m; i++)
#define rep(i, n, m) for (int i = n; i < m; i++)
#define sa(n) scanf("%d", &(n))
#define mp make_pair
#define ff first
#define ss second
#define pb push_back
#define DE(val) cout<<#val<<": "<<val<<endl;

const int dx4[5] = { 0,-1,0,1,0 };
const int dy4[5] = { 0,0,1,0,-1 };
const int dx8[9] = { 0,-1,0,1,0,1,1,-1,-1 };
const int dy8[9] = { 0,0,1,0,-1,1,-1,1,-1 };
const int maxn = 2e5 + 5;
const double PI = acos(-1.0);
const ll mod = 1e9 + 7;
ll po(ll a, ll b, ll mod) { ll res = 1; a %= mod; for (; b; b >>= 1) { if (b & 1)res = res*a%mod; a = a*a%mod; }return res; }
ll gcd(ll a, ll b) { if (a == 0) { return b; } else { return gcd(b%a, a); } }
void YES() { puts("YES"); exit(0); }
void Yes() { puts("Yes"); exit(0); }
void NO() { puts("NO"); exit(0); }
void No() { puts("No"); exit(0); }
void one() { puts("-1"); exit(0); }

int n;
pair<ll,ll>val[maxn];
multiset<ll>v1,v2;

void solve()
{
	sa(n);
	if(n==1)
	{
		puts("0");
		return;
	}
	repp(i,1,n)
	{
		int x,y;
		sa(x),sa(y);
		if(x>y)swap(x,y);//x<=y
		val[i].first = x;
		val[i].second = y;
		v1.insert(x);
		v2.insert(y);
	}
	sort(val+1,val+n+1);
	ll ans = 1LL*(*v1.rbegin()-*v1.begin())*(*v2.rbegin()-*v2.begin());
	repp(i,1,n)
	{
		v1.erase(v1.find(val[i].first));
		v2.erase(v2.find(val[i].second));

		v1.insert(val[i].second);
		v2.insert(val[i].first);
		ans = min(ans,1LL*(*v1.rbegin()-*v1.begin())*(*v2.rbegin()-*v2.begin()));
	}
	printf("%lld\n", ans);
}

int main()
{
	solve();
	//system("pause");
	return 0;
}

Measured memory_bytes: 22272
#include <bits/stdc++.h>
typedef unsigned long long ull;
using namespace std;
struct state { ull x; int zero, pre, dist, remain; };
bool operator<(const state& s1, const state& s2) { return s1.dist + s1.remain > s2.dist + s2.remain; }
int a, dist[16][16], goals[16], goals2[16]; ull s, goal = 1147797409030816545;
int dir[4] = { 1, 0, -1, 0 };
inline int getheuri(ull x) {
	int ret1 = 0;
	for (int i = 0; i < 16; i++) {
		int ww = ((x >> (i * 4)) & 15);
		if (!ww) continue;
		ret1 += dist[i][goals2[ww]];
	}
	/*int ret2 = 0;
	for (int i = 0; i < 16; i++) {
		for (int j = i + 1; j < 16; j++) {
			int ww1 = ((x >> (i * 4)) & 15);
			int ww2 = ((x >> (i * 4)) & 15);
			if (((ww1 + 15) & 15) > ((ww2 + 15) & 15)) ret2++;
		}
	}*/
	int ret = ret1;//max(ret1, ret2 / 3 + ret2 % 3);
	return ret;
}
int solve() {
	if (s == goal) return 0;
	int zz = -1;
	for (int i = 0; i < 16; i++) {
		if (!((s >> (i * 4)) & 15)) zz = i;
	}
	int rr = getheuri(s);
	priority_queue<state> que;
	que.push(state{ s, zz, -99, 0, rr });
	while (!que.empty()) {
		state a = que.top(); que.pop();
		ull v = a.x; int z = a.zero;
		for (int i = 0; i < 4; i++) {
			if (abs(i - a.pre) == 2) continue;
			int dx = dir[i], dy = dir[i ^ 1];
			int e = z + dy * 4 + dx;
			int g = ((v >> (e << 2)) & 15);
			if (0 <= e && e < 16 && (e & 3) - (z & 3) == dx) {
				ull w = v;
				w -= ((1ULL * g) << (e << 2));
				w += ((1ULL * g) << (z << 2));
				int xx = getheuri(w);
				if (w == goal) return a.dist + 1;
				que.push(state{ w, e, i, a.dist + 1, xx });
			}
		}
	}
	return -1;
}
int main() {
	for (int i = 0; i < 16; i++) {
		for (int j = 0; j < 16; j++) {
			dist[i][j] = abs((i >> 2) - (j >> 2)) + abs((i & 3) - (j & 3));
		}
	}
	for (int i = 0; i < 15; i++) goals[i] = i + 1; goals[15] = 0;
	for (int i = 0; i < 16; i++) goals2[goals[i]] = i;
	for (int i = 0; i < 16; i++) {
		cin >> a;
		s += ((1ULL * a) << (i * 4));
	}
	cout << solve() << endl;
	return 0;
}

Measured memory_bytes: 52104
letters = list(input())
result = 0
lengs = int(len(letters))
while True:
  if (result + 1) % 2 == 1 and letters[result] == "L":
    print("No")
    break
  elif (result + 1) % 2 == 0 and letters[result] == "R":
    print("No")
    break
  elif (result + 1) == lengs:
    print("Yes")
    break
  else:
    result += 1



Measured memory_bytes: 3064
#include<stdio.h>
int main(){

    int a,b,c,i;
    scanf("%d%d%d",&a,&b,&c);

    if(b>c)
    {
        i=b;
        b=c;
        c=i;
    }

    if(a>c)
    {
        i=c;
        c=a;
        a=i;
    }

    if(a>b)
    {
        i=a;
        a=b;
        b=i;
    }

    printf("%d %d %d\n",a,b,c);

    return 0;
}

Measured memory_bytes: 596
#include <stdio.h>

int main()
{
    int a, b, x;

    scanf("%d %d %d", &a, &b, &x);

    if (x >= a && b > 0 && x < (a + b))
    {
        printf("YES\n");
    }
    else 
    {
        printf("NO\n");
    }

    return 0;
}

Measured memory_bytes: 128
import java.io.*;
import java.util.*;

public class Main{
	public static void main(String args[]){
		try{
			new Main();
		}catch(IOException err){
			err.printStackTrace();
		}
	}

	public Main() throws IOException{
		BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
		List<int[][]> ans = new ArrayList<int[][]>();
		String line;
		while((line = in.readLine()) != null){
			int n = Integer.parseInt(line);

			if(n == 0) break;

			int[][] data = new int[n+1][n+1];

			for(int i=0; i<n; i++){
				line = in.readLine();
				String[] dst = line.split(" ");

				int sum = 0;
				for(int j=0; j<n; j++){
					data[j][i] = Integer.parseInt(dst[j]);
					sum += data[j][i];
				}
				data[n][i] = sum;
			}

			for(int j=0; j<=n; j++){
				int sum = 0;
				for(int i=0; i<n; i++){
					sum += data[j][i];
				}
				data[j][n] = sum;
			}

			ans.add(data);
		}

		for(int m=0; m<ans.size(); m++){
			int[][] dst = ans.get(m);

			for(int i=0; i<dst.length; i++){
				for(int j=0; j<dst.length; j++){
					System.out.printf("%5d", dst[j][i]);
				}
				System.out.println();
			}
		}
	}
}

Measured memory_bytes: 12000
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define sz(x) (int)x.size()
#define all(x) (x).begin(), (x).end()
#define Red ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define rep(i, n) for(int i =0 ; i < n; ++i)
#define Rep(i,a,b) for(int i=a;i<=b;i++)
#define pii pair < int, int >
typedef vector<int> vi;
typedef  long long ll;
const int inf = int(1e9);
const int mod =1e9+7;
const int N = (int)2e5 + 5;



void solve(){
	int n;
	cin>>n;
	string s;
	cin>>s;
	char last=s[0];
	int cnt=1;
	for(int i=1;i<n;i++){
		if(s[i]!=last)last=s[i],cnt++;
	}
	cout<<cnt;
	
}
int main(){
	Red;
	int t=1;
	//cin>>t;
	while(t--)
	solve();
	return 0;
}

Measured memory_bytes: 512
N = int(input())
A,B,Ans = [],[],0
for i in range(N):
    x = list(map(int,input().split()))
    A.append(x[:])
    B.append(x[:])

for k in range(N):
    for i in range(N):
        for j in range(N):
            B[i][j] = min(B[i][j],B[i][k]+ B[k][j])

if A!=B:
    print(-1)
else:
    for i in range(N):
        for j in range(i+1,N):
            exists = True
            for k in range(N):
                if k not in (i,j) and B[i][j]==B[i][k]+B[k][j]:
                    exists = False                    
            if exists:
                Ans += B[i][j]
    print(Ans)



Measured memory_bytes: 46812
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
class Program
    {
        static void Main(string[] args)
        {
            int value = 700;
            string input = GetInput();
            for (int i = 0; i < 3; i++)
                value += (input[i] == 'o')?100:0;
            Output(value);
        }

        #region Tools
        static string GetInput()
        {
            return Console.ReadLine();
        }
        static string[] GetInput(char split)
        {
            return Console.ReadLine().Split(split);
        }
        static int GetInt()
        {
            return int.Parse(Console.ReadLine());
        }
        static int[] GetInt(char split)
        {
            string[] strarray = GetInput(split);
            int[] res = new int[strarray.Length];
            for (int i = 0; i < strarray.Length; i++)
            {
                res[i] = int.Parse(strarray[i]);
            }
            return res;
        }

        static void Output(string str)
        {
            Console.WriteLine(str);
        }
        static void Output(int str)
        {
            Console.WriteLine(str+"");
        }
        #endregion
    }

Measured memory_bytes: 11092
#include <stdio.h>

int main(){

    char letterTest;
    scanf("%c", &letterTest);

    if (letterTest >= 'A' && letterTest  <= 'Z'){
        puts("A");
    }
    else if (letterTest >= 'a' && letterTest <= 'z'){
        puts("a");
	}
    return 0;
}

Measured memory_bytes: 1600
#include <bits/stdc++.h>
using namespace std;  
typedef long long ll;
typedef vector<ll> vint;
int main() {
  ll r;
  cin >> r;
  
  if (r<1200) {
    cout << "ABC";
  }
  else if (r<2800) {
    cout << "ARC";
  }
  else {
    cout << "AGC";
  }
}

Measured memory_bytes: 256
#include <cstdint>
#include <cstdio>
#include <cstdlib>
#include <vector>

#include <atcoder/segtree>

int max_op(int x, int y) { return std::max(x, y); }
int max_e() { return -1e9; }

int main() {
  int n, q;
  scanf("%d %d", &n, &q);

  std::vector<int> a(n);
  for (auto& ai: a) scanf("%d", &ai);

  atcoder::segtree<int, max_op, max_e> max_st(a);

  for (int i = 0; i < q; ++i) {
    int t;
    scanf("%d", &t);

    if (t == 1) {
      int x, v;
      scanf("%d %d", &x, &v);
      --x;
      max_st.set(x, v);
    } else if (t == 2) {
      int l, r;
      scanf("%d %d", &l, &r);
      --l;
      printf("%d\n", max_st.prod(l, r));
    } else if (t == 3) {
      int x, v;
      scanf("%d %d", &x, &v);
      --x;
      printf("%d\n", max_st.max_right(x, [&](int prod) { return v > prod; }) + 1);
    }
  }
}


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

typedef long long ll;

int main()
{
    ll N;
    cin >> N;
    ll t = N - 1;
    if (N == 2)
    {
        cout << 1 << endl;
    }
    else if (N == 1)
    {
        cout << 0 << endl;
    }
    else
    {
        cout << (t) * (t + 1) / 2 << endl;
    }
}

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


int main()
{
    ll N; cin >> N;
    string t; cin >> t;

    string s(t.begin(), t.end());
    while (true) {
        bool isok = true;
        rep(i, s.size()-1) {
            if (s[i] == '(' && s[i+1] == ')') {
                s.erase(i, 2);
                isok = false;
                break;
            }
        }
        if (isok || s == "") {
            break;
        }
    }
    //cout << s << endl;

    if (s == "") {
        cout << t << endl;
        return 0;
    }

    ll f = 0, b = 0;
    rep(i, s.size()) {
        if (s[i] == '(') f++;
        else b++;
    }

    rep(i, b) t.insert(t.begin(), '(');
    rep(i, f) t.push_back(')');

    cout << t << endl;
    return 0;
}

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

int main(void)
{
    int a,b,c,i,j,k,n,x[3];

    cin >> a >> b >>c;
    x[0] = a+b;
    x[1] = b+c;
    x[2] = c+a;

    sort(x,x+3);
    cout << x[0];

    return 0;
}

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

class D {
  static void Main() {
    ulong  n = ulong .Parse(Console.ReadLine());
    var arr = Console.ReadLine().Split(' ').Select(str => ulong .Parse(str));
    ulong [] counts = new ulong [n];

    foreach (ulong  a in arr) {
      counts[a - 1]++;
    }

    ulong  sum = 0;
    foreach (ulong  count in counts) {
      if (count < 2) continue;

      sum += count * (count - 1) / 2;
    }

    var ansList = counts.Select(count => {
      ulong  ans = sum - count * (count - 1) / 2;
      if (count <= 2) return ans;

      return ans + (count - 1) * (count - 2) / 2;
    }).ToArray();

    foreach (ulong  a in arr) {
      Console.WriteLine(ansList[a - 1]);
    }
  }
}


Measured memory_bytes: 35260
#include <bits/stdc++.h>
using namespace std;
void main_sub(void);
int main(int argc, char* argv[]) {
    main_sub();
    return 0;
}
// int を int64_t にする
// g++ に -DUSE_STRICT_INT をつけるか、
// 下のコメントアウトを外すと無効化
// #define USE_STRICT_INT
using i64 = int64_t;
#ifndef USE_STRICT_INT
#define int i64
#endif
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(), (x).end()
constexpr int INF = (1 << 30);
constexpr i64 INFL = (1LL << 62);
constexpr i64 MOD = 1000000007;

void main_sub(void) {
    int n, m;
    cin >> n >> m;
    vector<vector<int>> s(m);
    vector<int> p(m);
    rep(i, m) {
        int k;
        cin >> k;
        rep(j, k) {
            int sj;
            cin >> sj;
            s[i].push_back(sj);
        }
    }
    rep(i, m) { cin >> p[i]; }
    int ans = 0;
    rep(bit, (1LL << n)) {
        int all_on = true;
        rep(i, m) {
            int cnt = 0;
            for (auto& sij : s[i]) {
                if (bit & (1 << (sij - 1))) {
                    cnt++;
                }
            }
            if (cnt % 2 != p[i]) all_on = false;
        }
        if (all_on) ans++;
    }
    cout << ans << endl;
    return;
}

Measured memory_bytes: 256
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <iomanip>
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
#include <math.h>
#include <cmath>
#include <stdlib.h>
#include <stdio.h>
using namespace std;
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; }
const int INF = 1001001000;
const int MOD = 1000000007;

long long gcd(long long a, long long b) {
    if (b == 0) return a;
    else return gcd(b, a % b);
}
long long lcm(long long a, long long b) {
    return a * b / gcd(a, b);
}

using Graph = vector<vector<int>>;
//再帰とかグラフを使うときは予めNの最大値のグローバル配列を取っておく
int N;
vector<int> E[200001];
bool shipment[15][15];
vector<bool> seen;
typedef pair<int, int> P;
int D[101];
//頂点状態を表すcolor[]において、0は未訪問、1は訪問中、2は完了を表す。
int color[101];
int find_time = 0;
int dp[1001][1001];

void solve_LCS(string X,string Y) {
    int S = X.size();
    int T = Y.size();
    for (int i = 0; i < S; i++) {
        for (int j = 0; j < T; j++) {
            //同じ文字だったら、max(今まで+1,今までの最大)をする
            if (X[i] == Y[j]) dp[i + 1][j + 1] = max({ dp[i][j] + 1,dp[i + 1][j],dp[i][j + 1] });
            else dp[i + 1][j + 1] = max(dp[i + 1][j], dp[i][j + 1]);
        }
    }

    cout << dp[S][T] << endl;
}

int main() {
    int Q; cin >> Q;
    vector<string> Xs(Q);
    vector<string> Ys(Q);
    for (int i = 0; i < Q; i++) {
        cin >> Xs.at(i) >> Ys.at(i);
    }
    for (int i = 0; i < Q; i++) {
        solve_LCS(Xs.at(i),Ys.at(i));
    }
}



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

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

  set<char> ATCG{'A', 'T', 'C', 'G'};

  int ans = 0;
  for (int i = 0; i < S.size(); i++) {
    string tmp = "";
    for (int j = i; j < S.size(); j++) {
      if (ATCG.count(S.at(j)) > 0) {
        tmp.push_back(S.at(j));
      } else {
        break;
      }
    }
    int length = tmp.length();
    ans = max(length, ans);
  }

  printf("%d", ans);
  return 0;
}

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

int main()
{
    int num, highest=0, count=0, current;
    cin >> num;
    for(int i=0; i< num;i++){
        cin >> current;
        if(current >= highest){
            count ++;
            highest = current;
        }
    }
    cout << count << endl;
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<map>

using namespace std;

int main()
{    
    string str;
    map<char,int> map;
    cin>>str;
    for(auto c:str)
    {
        auto itr=map.find(c);
        if(itr==map.end())
        {
            map.emplace(c,1);
        }
        else
        {
            itr->second++;
        }
    }
    bool hantei=false;
    if(map.size()==2)
    {
        for(auto itr:map)
        {
            if(itr.second==2)hantei=true;
            else hantei=false;
        }
        if(hantei)cout<<"Yes"<<endl;
        else cout<<"No"<<endl;
    }
    else
    {
        cout<<"No"<<endl;
    }
    

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
typedef long long LL;
#define FOR(i,a,b) for(LL i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)

using namespace std;

class UnionFind {
  std::vector<int> p;

public:
  UnionFind(int n) : p(n, -1) {}
  int root(int x) { return p[x] < 0 ? x : p[x] = root(p[x]); }
  bool same(int x, int y) { return root(x) == root(y); }
  bool unite(int x, int y) {
    x = root(x);
    y = root(y);
    if (x == y) return false;
    if (p[y] < p[x]) std::swap(x, y);
    if (p[x] == p[y]) --p[x];
    p[y] = x;
    return true;
  }
};

int main(void)
{
  LL n;
  cin >> n;
  vector<LL> x(n),y(n);
  REP(i,n) cin >> x[i] >> y[i];
  vector<vector<LL>> xis(131072),yis(130172);
  REP(i,n) xis[x[i]].push_back(i);
  REP(i,n) yis[y[i]].push_back(i);
  UnionFind uf(n);
  for(auto v:xis) {
    LL sz = v.size();
    REP(i,sz-1) uf.unite(v[i],v[i+1]);
  }
  for(auto v:yis) {
    LL sz = v.size();
    REP(i,sz-1) uf.unite(v[i],v[i+1]);
  }
  vector<set<LL>> xon(n),yon(n);
  REP(i,n) {
    xon[uf.root(i)].insert(x[i]);
    yon[uf.root(i)].insert(y[i]);
  }
  LL answer = 0;
  REP(i,n) {
    LL tmp = (LL)xon[i].size() * (LL)yon[i].size();
    answer += tmp;
  }
  cout << answer - n << endl;
  return 0;
}


Measured memory_bytes: 25984
#include"bits/stdc++.h"


#define PB push_back
#define PF push_front
#define LB lower_bound
#define UB upper_bound
#define fr(x) freopen(x,"r",stdin)
#define fw(x) freopen(x,"w",stdout)
#define iout(x) printf("%d\n",x)
#define lout(x) printf("%lld\n",x)
#define REP(x,l,u) for(ll x = (l);x<=(u);x++)
#define RREP(x,l,u) for(ll x = (l);x>=(u);x--)
#define mst(x,a) memset(x,a,sizeof(x))
#define PII pair<int,int>
#define PLL pair<ll,ll>
#define MP make_pair
#define se second
#define fi first
#define dbg(x) cout<<#x<<" = "<<(x)<<endl;
#define sz(x) ((int)x.size())
#define cl(x) x.clear()

typedef  long long ll;
typedef unsigned long long ull;
typedef double db;
typedef long double ld;
using namespace std;

const int maxn = 100010;
const int mod = 1e9+7;
const double eps = 1e-6;
const double PI = acos(-1);

template<typename T> inline void read(T &x){
x=0;T f=1;char ch;do{ch=getchar();if(ch=='-')f=-1;}while(ch<'0'||ch>'9');do x=x*10+ch-'0',ch=getchar();while(ch<='9'&&ch>='0');x*=f;
}

template<typename A,typename B> inline void read(A&x,B&y){read(x);read(y);}
template<typename A,typename B,typename C> inline void read(A&x,B&y,C&z){read(x);read(y);read(z);}
template<typename A,typename B,typename C,typename D> inline void read(A&x,B&y,C&z,D&w){read(x);read(y);read(z);read(w);}
template<typename A,typename B> inline A fexp(A x,B p){A ans=1;for(;p;p>>=1,x=1LL*x*x%mod)if(p&1)ans=1LL*ans*x%mod;return ans;}
template<typename A,typename B> inline A fexp(A x,B p,A mo){A ans=1;for(;p;p>>=1,x=1LL*x*x%mo)if(p&1)ans=1LL*ans*x%mo;return ans;}

#define A has[0]
#define B has[1]
#define C has[2]

int n,m,ok,cnt;

vector<PII> G[maxn];

ll ans;
ll has[3];

int d[maxn];

void dfs(int u,int now){
	if(~d[u]){
		if(d[u]!=now)ok=0;
		return;
	}
	d[u]=now;has[now]++;
	for(auto v:G[u])dfs(v.fi,(now+v.se)%3),cnt++;
}

void Work(){
	REP(i,1,n)d[i]=-1;
	REP(i,1,n)if(d[i]==-1){
		A=B=C=0;ok=1;cnt=0;
		dfs(i,0);
		if(!ok)ans+=(A+B+C)*(A+B+C);
		else if(A&&B&&C)ans+=A*B+B*C+C*A;
		else ans+=cnt/2;
	}
	cout<<ans<<endl;
}

void Init(){
	read(n,m);
	REP(i,1,m){
		int x,y;
		read(x,y);
		G[x].PB(MP(y,1));G[y].PB(MP(x,2));
	}
}

int main(){
	Init();
	Work();
	return 0;
}


Measured memory_bytes: 10752
(n,),*v = $<.map{|l|l.split.map &:to_i}
path = Hash[(1..n).map{|i|[i,[]]}]
v.each{|s,t|
  path[s]+=[t]
}
through = Hash.new(0.0)
through[1] = 1.0
(1..n-1).each{|i|
  th = through[i]/path[i].size
  path[i].each{|j|
    through[j] += th
  }
}
dp_all = {n=>0.0}
dp_del = {n=>0.0}
(1..n-1).reverse_each{|i|
  nextpath = path[i].map{|t|dp_all[t]}
  sum = nextpath.inject(:+)
  dp_del[i] = dp_all[i] = sum/nextpath.size + 1
  if nextpath.size > 1
  	dp_del[i] = (sum - nextpath.max)/(nextpath.size - 1) + 1
  end
}
ans = dp_all[1] - (1..n-1).map{|i|(dp_all[i]-dp_del[i])*through[i]}.max
p ans

Measured memory_bytes: 113172
#include <iostream>
#include <math.h>

using namespace std;

int main(){
    int n, k;
    cin >> n >> k;
    string s;
    cin >> s;
    for(int i = 0; i < n; i++){
        if(i == (k - 1)){
            s[i] += 0x20;
        }
    }
    cout << s << endl;
    return 0;
}

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

int main()
{

    string s;
    cin>>s;

    //パターンは0101か1010
    //2つのパターンとの差をとってカウント
    //小さい方が答え

    int cnt1=0,cnt2=0;
    for(int i=0;i<s.size();i++){
        if(i%2==0){
            if(s.at(i)!='0')
                cnt1++;
            else
                cnt2++;
        }else{
            if(s.at(i)!='1')
                cnt1++;
            else
                cnt2++;
        }
    }

    cout<<min(cnt1,cnt2)<<endl;

    return 0;
}


Measured memory_bytes: 512
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayList;

class Main{
	public static void main(String[] args)throws NumberFormatException, IOException{
	    InputStreamReader input = new InputStreamReader (System. in);
	    BufferedReader buffer = new BufferedReader(input);
	    String read = buffer.readLine();
	    int amount = Integer.parseInt(read);
	    int[][] scanInt = new int[amount][100];	//N?????°???100????¶??????????
	    for(int i=0; i<amount; i++){
	    	read = buffer.readLine();
	    	String[] scan = read.split(" ");
	    	for(int j=0; j<scan.length; j++){
	    		scanInt[i][j] = Integer.parseInt(scan[j]);
	    	}
	    }

    	int nowDepth = 0;
    	int[] foundPosition = new int[amount];
    	boolean visitBranch[] = new boolean[amount];
    	visitBranch[0] = true;
	    ArrayList<Integer> tempList = new ArrayList<Integer>();
	    tempList.add(1);

    	while(true){
    		boolean existBranch = false;
    		ArrayList<Integer> list = new ArrayList<Integer> (tempList);
    		tempList.clear();

    		for(int i=0; i<list.size(); i++){
    			foundPosition[list.get(i) -1 ] = nowDepth;		//??????????????????????????¢????¨???????
    			for(int j=0; j<scanInt[list.get(i)-1][1]; j++){//???????????????????????????????????¢?´¢?????¢????????£????????¨????????????????????????
    				if(visitBranch[ scanInt[list.get(i)-1][j+2] -1] == false){
    					visitBranch[ scanInt[list.get(i)-1][j+2] -1] = true;
    					existBranch = true;
    					tempList.add(scanInt[list.get(i)-1][j+2]);
    				}
    			}
    		}

    		if(existBranch == false){		//??¢?´¢??§?????????????????? ?????¨?????¢?´¢????°?????????´???
    			for(int i=0; i<amount; i++){
    				if(visitBranch[i] == false){	//??°?????§???????????£??????????????¢???-1????????????
    					foundPosition[i] = -1;
    				}
    			}
    			break;
    		}
    		nowDepth += 1;
	    }

    	for(int i=0; i<amount; i++){
    		System.out.println((i+1)+" "+foundPosition[i]);
    	}
	}
}

Measured memory_bytes: 24364
#include<bits/stdc++.h>
#define ll long long int
#define M 1000000007
#define mod 998244353
#define mp(x,y) make_pair(x,y)
#define pb(x) push_back(x)
#define pi pair<ll,ll>
using namespace std;
const ll N=500010;

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

    ll n,m,k;
    ll nn,mm;
    cin>>nn>>mm>>k;
    n=max(nn,mm);
    m=min(nn,mm);
    ll ans=0;
    ll count=0;
    for(ll i=0;i<m;++i)
    {
        if(count>=k){break;}
        count+=n;
        ++ans;
        //cout<<"!!"<<count<<endl;
    }
    cout<<ans;

    return (0);
}


Measured memory_bytes: 256
#include<stdio.h>

using namespace std;

int main(){
 int a, b, i;
 while(scanf("%d%d", &a, &b)!=EOF){
  a += b;
  for(i=0;i<201;i++){
   if(a/10==0){
    printf("%d\n", i+1);
    break;
   }
   else{
    a = a/10;
   }
  }
 }

 return 0;
}

Measured memory_bytes: 1028
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cmath>
#include<math.h>
#include<string>
#include<string.h>
#include<stack>
#include<queue>
#include<vector>
#include<utility>
#include<set>
#include<map>
#include<stdlib.h>
#include<iomanip>

using namespace std;

#define ll long long
#define ld long double
#define EPS 0.0000000001
#define INF 1e9
#define MOD 1000000007
#define rep(i,n) for(i=0;i<n;i++)
#define loop(i,a,n) for(i=a;i<n;i++)
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)

typedef vector<int> vi;
typedef pair<int,int> pii;

int main(void) {
    int i,j;
    int n;
    cin>>n;
    int ans = 0;
    while(n){
        if(n%10 == 1) ans++;
        n /= 10;
    }
    cout << ans << endl;

}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define	fast ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define loop(n,arr)  for(int i=0;i<n;i++)cin>>arr[i]; // 0 => n
#define	pi 3.14159265358979323846
#define	endl "\n"
#define f first
#define s second

typedef long long ll;
typedef unsigned long long ull;
const ll INF=1e18; 
const int N = 1e5+5 , oo=0x3f3f3f3f , mod=1e9+7;
void file(){freopen("out.txt","w",stdout);/*freopen("in.txt","r",stdin);*/}
int a[N];

int bs(int x,int n){
	int c=0,l=0,r=n-1;
	while(l<=r){
		int mid=(l+r)/2;
		if(a[mid]==x){
			c++;
			break;
		}
		else if(a[mid]<x){
			l=mid+1;
			c++;
		}
		else{
			r=mid-1;
			c++;
		}
	}
return c;
}


int main(){
	fast
	int x,y;
	cin>>x>>y;
	cout<<x*y;
	
	return 0;
}

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

int main(){
    char x[1000];

    while (1)
    {
        /* code */
        scanf("%s", &x);
        int sum=0;
        //printf("%s, %d\n", x, atoi(x));

        if(atoi(x)==0){
            break;
        }
        else{
            //printf("len:%d\n", strlen(x));
            for(int i=0; i< strlen(x); i++){
                sum += x[i]-48;
            }
            printf("%d\n", sum);

        }
    }

    return 0;
}


Measured memory_bytes: 2024
n = gets.chomp
a1 = n.to_i
a2 = a1 + 0.9999999
ans1 = ((a1 * 100) /108.to_f)
an1 = ans1.ceil
ans11 = (ans1.ceil).to_s
ans2 = (a2 * 100) / 108.to_f
an2 = ans2.ceil
ans22 = (ans2.floor).to_s
if ans11 == ans22 
    puts ans11
else
    puts ":("
end

Measured memory_bytes: 1788
#include <bits/stdc++.h>
#define SORT(a) sort(a.begin(), a.end())
#define RSORT(a) sort(a.rbegin(), a.rend())
#define REP(i, n) for (long long i = 0; i < n; i++)
#define RREP(i, n) for (long long i = n - 1, 0 <= i; i--)
#define FOR(i, start, end) for (long long i = start; i < end; i++)
#define RFOR(i, start, end) for (long long i = start - 1; 0 <= i; i--)
#define ALL(a) a.begin(), a.end()
#define MOD(a) a %= 1'000'000'007
using ll = long long;
using namespace std;
const int INF32       = 1'050'000'000;
const long long INF64 = 4'000'000'000'000'000'000;
const int MOD7        = 1'000'000'007;
const int MOD9        = 1'000'000'009;
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 print() { std::cout << '\n'; }
template <class H, class... T> void print(H &&head, T &&... args) {
    std::cout << head;
    sizeof...(args) == 0 ? std::cout << "" : std::cout << ' ';
    print(std::forward<T>(args)...);
}
template <class T> void print(std::vector<T> &v) {
    for (int i = 0; i < v.size(); i++) {
        std::cout << v[i];
        i == v.size() - 1 ? std::cout << '\n' : std::cout << ' ';
    }
}
template <class T> void print(std::vector<std::vector<T>> &v) {
    for (int i = 0; i < v.size(); i++) {
        for (int j = 0; j < v[i].size(); j++) {
            std::cout << v[i][j];
            j == v[i].size() - 1 ? std::cout << '\n' : std::cout << ' ';
        }
    }
}

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

    ll N, K;
    cin >> N >> K;
    vector<pair<int, int>> a(N);
    REP(i, N) cin >> a[i].first >> a[i].second;
    SORT(a);
    ll cnt  = 0;
    int ans = 0;
    REP(i, N) {
        if (K <= cnt) {
            break;
        }
        cnt += a[i].second;
        ans = a[i].first;
    }
    print(ans);

    return 0;
}

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

#define gc getchar()
inline int read(){
	int x=0,f=1;char c=gc;
	for(;c<48||c>57;c=gc)
		if(c=='-')f=-1;
	for(;c>47&&c<58;c=gc)
		x=x*10+c-48;
	return x*f;
}
#define io read()

int n,m;
string s;
int cnt[1000],fl;

inline void init(){
	cin>>n>>s;
	s=" "+s;
	m=n<<1;
	for(int i=1;i<=m;++i)++cnt[s[i]];
	for(int i='a';i<='z';++i)if(cnt[i]&1)fl=1;
}

typedef pair<string,string> ps;
map<ps,int> mp;

int a[100];
inline void dfs(int x,string pre,string suf){
	if(x==n){
		++mp[ps(pre,suf)];
		return;
	}
	dfs(x+1,pre+s[x+1],suf);
	dfs(x+1,pre,s[x+1]+suf);
}

ll ans;
inline void dfs2(int x,string pre,string suf){
	if(x==n+1){
		ans+=mp[ps(pre,suf)];
		return;
	}
	dfs2(x-1,pre,s[x-1]+suf);
	dfs2(x-1,pre+s[x-1],suf);
}

inline void solve(){
	dfs(0,"","");
	dfs2(m+1,"","");
	cout<<ans<<endl;
}

int main(){
	init();
	if(!fl)solve();else puts("0");
	return 0;
}

Measured memory_bytes: 84608
import sys

input = sys.stdin.readline

N = int(input().strip())
As = list(map(int, input().strip().split(' ')))
Bs = [0] * N

for i in range(N - 1, -1, -1):
    if i >= N // 2:
        Bs[i] = As[i]
    else:
        Bs[i] = abs(As[i] - (sum(Bs[2 * i + 1::i + 1]) % 2))

M = sum(Bs)
print(M)
if M != 0:
    print(" ".join(str(i+1) for i, b in enumerate(Bs) if b == 1))

Measured memory_bytes: 14772
#include <bits/stdc++.h>
#define For(i, a, b) for(int (i)=(a); (i)<(b); (i)++)
#define rFor(i, a, b) for(int (i)=(a)-1; (i)>=(b); (i)--)
#define rep(i, n) For((i), 0, (n))
#define rrep(i, n) rFor((i), (n), 0)
using namespace std;
typedef long long lint;

template<class T> struct SegTree{
  int n;
  vector<T> node;
  T initv;
  
  SegTree(int n_, T initv_){
    n = 1;
    while(n < n_) n *= 2;
    node.resize(n*2-1);
    initv = initv_;
    rep(i, n*2-1) node[i] = initv;
  }
  
  void update(int i, T val){
    i += n - 1;
    node[i] = val;
    while(i > 0) i = (i-1) / 2, node[i] = max(node[i*2+1], node[i*2+2]);
  }
  
  T getmax(int a, int b, int i, int l, int r){
    if(r<=a || b<=l) return initv;
    if(a<=l && r<=b) return node[i];
    T vl = getmax(a, b, i*2+1, l, (l+r)/2);
    T vr = getmax(a, b, i*2+2, (l+r)/2, r);
    return max(vl, vr);
  }
};

int main(){
    int n = 0; cin >> n;
    int h[n]; rep(i, n) cin >> h[i];
    lint a[n]; rep(i, n) cin >> a[i];
    SegTree<lint> st(n+1, 0);
    rep(i, n) st.update(h[i], st.getmax(0, h[i], 0, 0, st.n) + a[i]);
    cout << st.getmax(0, st.n, 0, 0, st.n) << endl;
}

Measured memory_bytes: 6784
import java.util.*;
public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int A = sc.nextInt(), B = sc.nextInt();
        long ans = 0; //abcba
        for (int a = 1; a <= 9; a++) {
            for (int b = 0; b <= 9; b++) {
                for (int c = 0; c <= 9; c++) {
                    int n = 10000 * a + 1000 * b + 100 * c + 10 * b + a;
                    if (A <= n && n <= B) ans += 1;
                }
            }
        }
        System.out.println(ans);
        sc.close();
    }
}


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

#define ll long long

int main()
{
    string s;
    
    cin >> s;
    
    if(s[2] == s[3] && s[4] == s[5])
        cout << "Yes\n";
    else
        cout << "No\n";

    return 0;
}


Measured memory_bytes: 3124
using namespace std;
#include<bits/stdc++.h>
#define ll long long int
#define ull unsigned long long int
#define INFINITE 1e9 + 5
#define MOD 1000000007
#define MAXN 100005 
#define pll pair<ll,ll>
#define pii pair<int,int>
int dp[MAXN];
int num,arr[MAXN];
int func(int ind)
{
    if(ind==num-1)
    {
        return 0;
    }
    if(ind>=num)
    {
        return INFINITE;
    }
    if(dp[ind]!=-1)
    {
        return dp[ind]; 
    }
    int left=abs(arr[ind]-arr[ind+1])+func(ind+1);
    int right=INFINITE;
    if(ind+2<num)
    {
         right=abs(arr[ind]-arr[ind+2])+func(ind+2);
    }
    return dp[ind]=min(left,right);
}
int main()
{
    cin>>num;
    memset(dp,-1,sizeof(dp));
    for(int i=0;i<num;i++)
    {
        cin>>arr[i];
    }
    cout<<func(0)<<"\n";
}

Measured memory_bytes: 4096
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);

        for (int i = 0;; ++i) {
            int j = scanner.nextInt();

            if (j == 0)
                return;
            System.out.printf("Case %d: %d\n", i+1, j);
        }
    }
}


Measured memory_bytes: 68360