akhauriyash/Code-Regression huggingface dataset:
// 12/07/2020  @ 19:54:17
// *****************************************************************
// *****************************************************************
#include <bits/stdc++.h>
// *****************************************************************
// *****************************************************************
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0); srand(chrono::high_resolution_clock::now().time_since_epoch().count());
#define fr(i,n) for(llu i=0;i<n;i++)
#define fl(j,a,b) for(llu j=a;j<=b;j++)
#define Pi 3.1415926535897932384626
#define mod 1e9+7
#define MID(a,b) ((a + b) >> 1)
#define MAX(a,b) ((a) > (b) ? (a): (b))
#define MIN(a,b) ((a) < (b) ? (a) :(b))
#define pb push_back
#define mp make_pair
#define deb(x) cout << #x << "=" << x << endl
#define deb2(x, y) cout << #x << "=" << x << "," << #y << "=" << y << endl
#define all(x) x.begin(), x.end()
#define vi vector<int>
#define vl vector<ll>
#define pi pair<int, int>
#define pl pair<ll, ll>
#define printer(a, n) fr(i,n) cout << a[i] << " ";
// *****************************************************************
// *****************************************************************
typedef long long unsigned int llu;
typedef long long int ll;
// *****************************************************************
// *****************************************************************
using namespace std;
// *****************************************************************
// *****************************************************************

                   // Dream it. Wish it. Do it.

                         // tannatsri //

              // Without tact you can learn nothing.

// *****************************************************************
// *****************************************************************
bool rev(ll a, ll b) {
    return a > b;
}
// *****************************************************************
void solution() {
	string s;
	 cin >> s;
	 if(s[1] == 'B') cout << "ARC";
	 else cout << "ABC";
}
// *****************************************************************
int main() {
    IOS;
    // #ifndef ONLINE_JUDGE
        // freopen("C:/Users/Mr.Tanishq/Desktop/noc/input.txt", "r", stdin);
        // freopen("C:/Users/Mr.Tanishq/Desktop/noc/output.txt", "w", stdout);
        // freopen("C:/Users/Mr.Tanishq/Desktop/noc/error.txt", "w", stderr);
    // #endif
    // *****************************************************************
    // *****************************************************************
    int t = 1;
    // cin >> t;
    while(t--) {

       solution();
       cout << "\n";
    }
    return 0;
}

Measured memory_bytes: 3648
#include<stdio.h>
#define ll long long

int main(){
	ll n, rev, i = 0;
	scanf("%lld", &n);
	char str[100];
	while(n){
		if(n == 0){
			break;
		}
		n--;
		rev = n % 26;
		n /= 26;
		str[i] = 'a' + rev;
		i++;
	}
	for(ll j = i - 1; j >= 0; j--){
		printf("%c", str[j]);
	}
	puts("");
	return 0;
}

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

void input(int& rnLimit, vector<llong>& rvnCostA, vector<llong>& rvnCostB)
{
  int nCostASiz, nCostBSiz;
  cin >> nCostASiz >> nCostBSiz >> rnLimit;
  rvnCostA.resize(nCostASiz + 1);
  rvnCostB.resize(nCostBSiz + 1);

  for (int i = 1; i < rvnCostA.size(); i++)
  {
    int nOneCost;
    cin >> nOneCost;
    rvnCostA[i] = rvnCostA[i - 1] + nOneCost;
  }

  for (int i = 1; i < rvnCostB.size(); i++)
  {
    int nOneCost;
    cin >> nOneCost;
    rvnCostB[i] = rvnCostB[i - 1] + nOneCost;
  }
}

int calcMaxSelect(int nLimit, const vector<llong>& cnrvnCostA, 
                              const vector<llong>& cnrvnCostB)
{
  int nCntA = cnrvnCostA.size() - 1;
  
  while ( cnrvnCostA[nCntA] > nLimit )
    --nCntA;

  int nMaxSelect = nCntA;
  int nBgnB = 0;
  int nCntB;

  while ( nCntA >= 0    &&
          nBgnB < cnrvnCostB.size() )
  {
    while ( nCntA >= 0                &&
            nBgnB < cnrvnCostB.size() &&
            cnrvnCostA[nCntA] + cnrvnCostB[nBgnB] <= nLimit )
    {
      nCntB = nBgnB;
      ++nBgnB;
    }

    nMaxSelect = max(nMaxSelect, nCntA + nCntB);

    nBgnB = nCntB;
    --nCntA;
  }
  return nMaxSelect;
}
 
int main()
{
  int nLimit;
  vector<llong> vnCostA, vnCostB;

  input(nLimit, vnCostA, vnCostB);
  cout << calcMaxSelect(nLimit, vnCostA, vnCostB) << endl;

  return 0;
}

Measured memory_bytes: 6308
#include <bits/stdc++.h>
using namespace std;
#define  rep(i, n) for(int i = 0; i < n; i++) 
#define  all(x) (x).begin(),(x).end()     // 昇順ソート
#define  rall(v) (v).rbegin(), (v).rend() // 降順ソート
#define  INF 1LL << 60
typedef long long int LL;
typedef long long int ll;
#define pll pair<ll, ll>
#define F first
#define S second
const int MOD = 1000000007;
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return true; } return false; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return true; } return false; }
//sort(all(x))とするとソートできるよ
// 10^x は pow(10,(x)) 
// 任意のlogは　対数の底の変換を使う    log(N) / log(任意の底)

int main(){
    int H,W;cin >> H >> W;
    int N;cin >> N;
    vector<int> a(N);rep(i,N)cin >> a[i];

    int right = 1;
    vector<vector<int>> ans(H,vector<int>(W,0));

    int x = 0;
    int y = 0;


    rep(i,N){
        int lim = a[i];
        for(int j = 1;j <= lim;j++){
            if(right > 0){
                ans[y][x] = i+1;
                if(x != W-1)x++;
                else{
                    y++;
                    right *= -1;
                }
            }
            else{
                ans[y][x] = i+1;
                if(x != 0)x--;
                else{
                    y++;
                    right *= -1;
                }
            }
        }
    }

    rep(i,H){
        rep(j,W)cout << ans[i][j] << " ";
    cout << endl;
    }

}


Measured memory_bytes: 384
def add(x, y):
    return x + y


def sub(x, y):
    return x - y


def mul(x, y):
    return x * y


def div(x, y):
    return x // y


while True:
    a, op, b = input().split()

    a = int(a)
    b = int(b)

    if op == "+":
        print(add(a, b))
    elif op == "-":
        print(sub(a, b))
    elif op == "*":
        print(mul(a, b))
    elif op == "/":
        print(div(a, b))
    else:
        break



Measured memory_bytes: 5596
#include<bits/stdc++.h>
using namespace std;
const int MOD = 998244353;
int comb[4020][4020];
int pow2[4020];
int ans[4020];
int main()
{
  int K, N; scanf("%d%d", &K, &N);
  pow2[0] = comb[0][0] = 1;
  for(int i=1; i<=4010; ++i)
  {
    comb[i][0] = comb[i][i] = 1;
    pow2[i] = pow2[i-1]*2%MOD;
    for(int j=1; j<i; ++j)
      comb[i][j] = (comb[i-1][j-1] + comb[i-1][j])%MOD;
  }
  for(int i=2; i<=K+1; i += 2)
  {
    long long a = 0;
    for(int j=0; j<=i/2; ++j)
    {
      if(K+N-i-1 < 0 || N-j < 0) continue;
      a += 1LL*pow2[j]*comb[K+N-i-1][N-j]%MOD*comb[i/2][j]%MOD;
      //printf("2^%d %dC%d %dC%d\n",j, K+N-i-1, N-j, i/2, j);
    }
    ans[i] = ans[i+1] = a%MOD;
  }
  for(int i=K+2; i<=2*K; ++i)
    ans[i] = ans[2*K+2-i];
  for(int i=2; i<=2*K; ++i) printf("%d\n", ans[i]);
}

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

int main(int argc, const char * argv[]) {

    int n,k;
    int keijiban=1;
    
    cin >> n;
    cin >> k;
    
    for(int i=0;i<n;i++){
        if(keijiban>k){
            keijiban=keijiban+k;
        }
        else{
            keijiban=keijiban*2;
        }
    }
    
    cout << keijiban << endl;
    
    return 0;
}


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

namespace ziyuutyou
{
    class Program
    {
        static void Main(string[] args)
        {
            var sen = Array.ConvertAll(Console.ReadLine().Split(' '), int.Parse);

            var mai = sen[0] / sen[1];

            var aaa = sen[0] % sen[1];

            if (aaa == 0)
            {
                Console.WriteLine(0);
            }
            else
            {
                Console.WriteLine(Math.Abs(1));
            }
            
        }
    }
}


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

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define FORD(i, a, b) for(int i = (a); i >= (b); --i)
#define VAR(v, i) __typeof(i) v=(i)
#define FORE(i, c) for(VAR(i, (c).begin()); i != (c).end(); ++i)
#define all(v) (v).begin(),(v).end()

#define PII pair<int,int>
#define mp make_pair
#define st first
#define nd second
#define pb push_back
#define lint long long int
#define VI vector<int>

#define debug(x) {cerr <<#x <<" = " <<x <<endl; }
#define debug2(x,y) {cerr <<#x <<" = " <<x << ", "<<#y<<" = "<< y <<endl; } 
#define debug3(x,y,z) {cerr <<#x <<" = " <<x << ", "<<#y<<" = "<< y << ", " << #z << " = " << z <<endl; } 
#define debugv(x) {{cerr <<#x <<" = "; FORE(itt, (x)) cerr <<*itt <<", "; cerr <<endl; }}
#define debugt(t,n) {{cerr <<#t <<" = "; FOR(it,0,(n)) cerr <<t[it] <<", "; cerr <<endl; }}

#define make( x) int (x); scanf("%d",&(x));
#define make2( x, y) int (x), (y); scanf("%d%d",&(x),&(y));
#define make3(x, y, z) int (x), (y), (z); scanf("%d%d%d",&(x),&(y),&(z));
#define make4(x, y, z, t) int (x), (y), (z), (t); scanf("%d%d%d%d",&(x),&(y),&(z),&(t));
#define makev(v,n) VI (v); FOR(i,0,(n)) { make(a); (v).pb(a);} 
#define IOS ios_base::sync_with_stdio(0)
#define HEAP priority_queue

#define read( x) scanf("%d",&(x));
#define read2( x, y) scanf("%d%d",&(x),&(y));
#define read3(x, y, z) scanf("%d%d%d",&(x),&(y),&(z));
#define read4(x, y, z, t) scanf("%d%d%d%d",&(x),&(y),&(z),&(t));
#define readv(v,n) FOR(i,0,(n)) { make(a); (v).pb(a);}

#define CD complex<double>
#define PDD pair<double, double> 
using namespace std;

const int max_n = 6e5+10;

lint gcd(lint a, lint b) {
	return a == 0 ? b : gcd(b%a, a);
}

void ans(int x) {
	x ? printf("Yes\n") : printf("No\n");
}

void solve() {
	lint a, b, c, d;
	scanf("%lld %lld %lld %lld", &a, &b, &c, &d);
	if (b > a) return ans(0);
	if (b > d) return ans(0);
	if (c >= b) return ans(1);
	a = a%b;
	if (a <= c) {
		lint x = (c-a)/b + 1;
		a += x*b;
		while (a-b > c) a = a-b;
	}
	a = a-b;
	if (a < 0) return ans(0);
	lint D = gcd(b, d);
	lint u = ((c+D-1)/D)*D;
	lint u2 = u+(a%D)+D;
	while (u2 > c) {
		if (u2 < b) return ans(0);
		u2 -= D;
	}
	return ans(1);
}



int main() {
	make(t);
	while (t--) {
		solve();
	}
}





Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text.RegularExpressions;
using Console = System.Console;

namespace Atcoder
{
    class Program
    {
        static void Main(string[] args)
        {
            var N = int.Parse(Console.ReadLine());
            if (N >= 1000)
            {
                Console.WriteLine("ABD");
            }
            else
            {
                Console.WriteLine("ABC");
            }
        }
    }
}

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

typedef pair<int, int> pii;
typedef long long ll;
typedef pair<ll, ll> pll;
typedef vector<int> vi;

#define pb push_back
#define eb emplace_back
#define mp make_pair
#define fi first
#define se second
#define rep(i,n) rep2(i,0,n)
#define rep2(i,m,n) for(int i=m;i<(n);i++)
#define ALL(c) (c).begin(),(c).end()

int A ,B, C;
int ret = 1e8;

int f(int d)
{
	if (d <= 0) return abs(d);
	else {
		if (d % 2) {
			return (d + 1) / 2 + 1;
		} else {
			return d / 2;
		}
	} 
}

int main() {
	cin >> A >> B >> C;

	for (int d = -200; d <= 200; ++d) {
		int t = f(d - A) + f(d - B) + f(d - C);
		ret = min(ret, t);
	}
	cout << ret << endl;

	return 0;
}

Measured memory_bytes: 256
#include<stdio.h>

int selectionSort(int a[], int N){
  int i, j, temp, minj;
  int sw = 0;

  for (i=0; i<N-1; i++) {
    minj = i;
    for (j=i; j<N; j++) {
      if (a[j] < a[minj])
        minj = j;
    }
    temp    = a[i];
    a[i]    = a[minj];
    a[minj] = temp;
    if (i != minj)
      sw++;
  }
  return sw;
}

int main(){
  int a[100], N, i, sw;

  scanf("%d", &N);
  for (i=0; i<N; i++)
    scanf("%d", &a[i]);

  sw = selectionSort(a, N);

  for (i=0; i<N; i++) {
    if (i>0)
      putchar(' ');
    printf("%d", a[i]);
  }
  printf("\n%d\n", sw);

  return 0;
}

Measured memory_bytes: 1852
#include<stdio.h>

int main(void){

int N, M, C, i, k;
int count = 0;
int a[20];
int b[20];
int sum = 0;

for(i = 0; i < 20; i++){
    a[i] = 0;
    b[i] = 0;
}

scanf("%d", &N);
scanf("%d", &M);
scanf("%d", &C);

for(i = 0; i < M; i++){
    scanf("%d", &b[i]);
}

for(i = 0; i < N; i++){
    for(k = 0; k < M; k++){
        scanf("%d", &a[k]);
        sum += a[k] * b[k];
    }
    if(sum + C > 0){
        count += 1;
    }
    sum = 0;
}




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

return 0;
}


Measured memory_bytes: 128
#define _USE_MATH_DEFINES
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <cmath>
#include <map>
#include <iomanip>
#include <deque>
#include <set>

typedef long long ll;
#define rep(i,a,b) for(int i=a;i<b;++i)
#define rrep(i,a,b) for(int i=a;i>=b;--i)
using namespace std;
using vi = vector<int>;
using vll = vector<ll>;
ll mod = 1e9 + 7;
//ll llmax = 10000000000000000000ll;
using namespace std;
using Graph = vector<vector<int>>;
Graph G;
const int AMAX = 100000;
/*int cnt_digit(ll N)
{
	int digit = 0;

	while (N > 0)
	{
		N /= 10;
		digit++;
	}
	return digit;
}



int n;
vll a;

ll solve(bool isp)
{
	ll sum = 0ll;
	ll ret = 0ll;

	for (int i = 0; i < n; i++)
	{
		sum += a[i];
		if (isp and sum <= 0)
		{
			ret += -sum + 1;
			sum = 1ll;
		}
		if (not isp and sum >= 0)
		{
			ret += sum + 1;
			sum = -1ll;
		}
		isp ^= 1;
	}
	return ret;
}

*/


/*
 * 最大公約数計算
 */
ll gcd(ll a, ll b)
{
	if (b == 0) {
		return a;
	}
	else {
		return gcd(b, a % b);
	}
}

ll lcm(ll a, ll b)
{
	ll g = gcd(a, b);

	return a / g * b;
}

int main()
{
	cin.tie(0);
	ios::sync_with_stdio(false);
	
	int N;
	cin >> N;
	vector<int> mem(N);
	vector<int> ans(N);
	for (int i = 1;i<N;i++)
	{
		cin >> mem[i];
		ans[mem[i]-1]++;
	}

	for (int i = 0;i<N;i++)
	{
		cout << ans[i] << endl;
	}
	
	
	return 0;

}

Measured memory_bytes: 4752
N = int(input().rstrip())
 
A = [int(n) for n in input().rstrip().split(' ')]
 
ans = []
for i in range(1, 100+1):
  temp = 0
  for j in range(len(A)):
    temp += (A[j]-i)**2
  ans.append(temp)
print(min(ans))

Measured memory_bytes: 38640
#include <iostream>
#include <map>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <sstream>
#include <cmath>
#include <math.h>
#include <string>
using namespace std;
typedef long long ll;
 
int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n;
    cin >> n;
    int a[3][n + 1];
    for ( int i = 0 ; i <= 2 ; i++ ) {
        for ( int j = 0 ; j <= n ; j++ ) a[i][j] = 0;
    }
    for ( int i = 1 ; i <= 2 ; i++ ) {
        for ( int j = 1 ; j <= n ; j++ ) {
            int x;
            cin >> x;
            a[i][j] = max( a[i - 1][j] , a[i][j - 1] ) + x;
        }
    }
    cout << a[2][n];
}



Measured memory_bytes: 3600
N = int(input())
A = list(map(int,input().split()))
B = list(map(int,input().split()))
C = list(map(int,input().split()))
stack = A[0]
total = 0
for a in A:
  if stack == a-1:
    total += B[a-1]+C[stack-1]
  else:
    total += B[a-1]
  stack = a
print(total)

Measured memory_bytes: 3064
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <queue>
#include <iomanip>
#include <bitset>
#include <cassert>
#include <cmath>
#include <cstring>
#include <climits>

using namespace std;

#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define REP(i, n) FOR(i, 0, n)
#define SORT(c) sort((c).begin(), (c).end())

typedef long long ll;
typedef pair<int, int> P;
typedef vector<int> V;
typedef map<int, int> M;

constexpr ll INF = 1e18;
constexpr ll MOD = 1e9 + 7;
constexpr double PI = 3.14159265358979323846;
constexpr int di[] = {0, 0, 1, -1};
constexpr int dj[] = {1, -1, 0, 0};

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

    int h, w;
    string s[110];

    cin >> h >> w;
    for (int i = 0; i < h; i++)
    {
        cin >> s[i];
    }

    int dp[110][110];
    for (int i = 0; i <= h; i++)
        for (int j = 0; j <= w; j++)
            dp[i][j] = 1e9;

    if (s[0][0] == '.')
        dp[0][0] = 0;
    else
        dp[0][0] = 1;

    for (int i = 0; i < h; i++)
    {
        for (int j = 0; j < w; j++)
        {
            if (i + 1 < h)
            {
                if (s[i][j] == '.' && s[i + 1][j] == '#')
                {
                    dp[i + 1][j] = min(dp[i + 1][j], dp[i][j] + 1);
                }
                else
                {
                    dp[i + 1][j] = min(dp[i + 1][j], dp[i][j]);
                }
            }

            if (j + 1 < w)
            {
                if (s[i][j] == '.' && s[i][j + 1] == '#')
                {
                    dp[i][j + 1] = min(dp[i][j + 1], dp[i][j] + 1);
                }
                else
                {
                    dp[i][j + 1] = min(dp[i][j + 1], dp[i][j]);
                }
            }
        }
    }

    cout << dp[h - 1][w - 1] << endl;

    return 0;
}


Measured memory_bytes: 384
#include <stdlib.h>
#include <iostream>
#include <vector>
#include <string>

#define MAX(a,b) ((a)>(b) ? (a) : (b))
#define MIN(a,b) ((a)<(b) ? (a) : (b))


using namespace std;

int main(){
	int N;
	string str;
	int ans,x;
	x=ans=0;

	cin>>N;
	cin>>str;

	for (int i = 0; i < str.length(); i++) {
		ans = MAX(ans, x);
		if (str[i]=='I') {
			x++;
		} else if (str[i]=='D') {
			x--;
		}
		ans = MAX(ans, x);
	}

	cout<<ans<<endl;
}

Measured memory_bytes: 256
/* ex 5_4
   Rikuta */

#include <stdio.h>
//strlenを使うためのヘッダファイルのインクルード
#include <string.h>

int main(void)
{ 
    //最高文字列数は10なのでヌル文字も含め11
    char sequence[11];
    //最大の長さと何文字連続しているかが入る配列の初期化
    int i,max = 0,array[10]={0};
    //入力
    scanf("%s", sequence);
    for ( i = 0; i < strlen(sequence); i++)
    {   
        //読み取った文字が，A,C,G,Tで，
        if (sequence[i]=='A'||sequence[i]=='C'||sequence[i]=='G'||sequence[i]=='T')
        {   
            if (i==0)
            {   
                //最初の文字の時は連続1文字目
                array[i] = 1;
            }
            else
            {   
                //最初の文字でない時は，前の連続数に1を足したものが
                //その連続数．
                array[i] = array[i - 1] + 1;
            }
            if (array[i] >= max)
            {   
                //その連続数が最高記録ならば最高記録を更新
                max = array[i];
            }
        }
    }
    //最高連続記録の出力
    printf("%d\n", max);
    return 0;
}

Measured memory_bytes: 1728
#include<bits/stdc++.h>
#define QS ios_base::sync_with_stdio(false);
typedef long long ll;
const ll INF = 1e18;
const int MOD = 1e9+7;
using namespace std;

int color[100005];
bool vis[100005];
vector<pair<int, int>> adj[100000+1];
void coloredge(int u);

int main(){
//freopen("output.txt", "w", stdout);
    QS
    int n; cin >> n;

    int cur = 0;
    for(int i = 1; i < n; ++i){
        int u, v;
        cin >> u >> v;
        adj[u].push_back({v, i});
        adj[v].push_back({u, i});
    }
    for(int i = 0; i <= n; ++i){
        color[i] = -1;
    }
    coloredge(1);
    int mx = -1;
    for(int i = 1; i < n; ++i){
        mx = max(mx, color[i]);
    }
    cout << mx + 1 <<'\n';
    for(int i = 1; i < n; ++i){
        cout << color[i] + 1 << '\n';
    }
}

void coloredge(int u){
    queue<int> q;
    int c = 0;
    set<int> colored;
    if(vis[u]) return;
    vis[u] = true;

    for(auto v : adj[u]){
        if(color[v.second] != -1){
            colored.insert(color[v.second]);
        }
    }
    for(auto v : adj[u]){
        if(!vis[v.first]){
            q.push(v.first);
        }
        if(color[v.second] == -1){

            while(colored.find(c) != colored.end()) c++;

            color[v.second] = c;
            colored.insert(c); c++;
        }
    }
    while (!q.empty()) {
        int temp = q.front();
        q.pop();
        coloredge(temp);
    }
}


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

#define mod 1000000007

using namespace std;
typedef long long ll; 
 
int main(void){
	
	int A[3];
	
	cin >> A[0] >> A[1] >> A[2];
	
	sort(A, A+3, greater<int>());
	
	cout << abs(A[1] - A[0]) + abs(A[2] - A[1]);
	
	return 0;
}

Measured memory_bytes: 256
n = int(input())
lst = list(map(int, input().split()))
zero = False
fl = False
x = 1
for i in lst:
    if(i==0):
        zero = True
        break
    if not fl:
        x*=i
    if(x>1e18):
        fl = True
if zero:
    print(0)
elif fl:
    print(-1)
else:
    print(x)

Measured memory_bytes: 21640
#include <iostream>
#include <string>

using namespace std;

int main(){
  string S;
  cin >> S;
  bool f = true;
  if (S.size() % 2 != 0){
    f = false;
  }
  else{
    for (int i=0; i<S.size(); i += 2){
      if (S.substr(i, 2) != "hi"){
        f = false;
        break;
      }
    }
  }
  cout << (f ? "Yes" : "No") << endl;
          
  return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
#define ll long long

typedef struct miti{
  long A,B;
}tunagu;

long hantei(tunagu a,ll hei[]){
  if(hei[a.A]<hei[a.B])return a.A;
  else if(hei[a.A]>hei[a.B])return a.B;
  else return 0;
};
  

int main(){
  long N,M,ans=0;
  scanf("%ld%ld",&N,&M);
  ll H[N+1];
  ll tow[100001]={};
  for(int j=1;j<=N;j++){
    scanf("%lld",&H[j]);
  };
  tunagu road[M];
  for(int i=0;i<M;i++){
    scanf("%ld%ld",&road[i].A,&road[i].B);
    if(hantei(road[i],H)==0){
      tow[road[i].A]++;
      tow[road[i].B]++;
    }
    else tow[hantei(road[i],H)]++;
  };
  for(int x=1;x<=N;x++)
    if(tow[x]==0)ans++;
  printf("%ld",ans);
};

Measured memory_bytes: 4844
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
//template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
//template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
 
/* attention
    long longのシフト演算には気をつけよう
    タイポした時のデバッグが死ぬほどきつくなるので変数名は最低3字くらい使った方がいいかも
*/

int main(){
    int N, K; cin >> N >> K;
    int ans = 0;

    for(int i=0; i<N; i++){
        int x; cin >> x;
        ans += 2*min(x, abs(K-x));
    }

    cout << ans << endl;
}

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

unum = min(a)
vnum = max(a)

u = a.count(unum)
v = a.count(vnum)

exist = False

if vnum-unum == 1:
  if u+1 <= vnum <= u+v//2:
    exist = True
    
elif vnum == unum:
  if vnum == n-1 or vnum <= n//2:
    exist = True
    
print("Yes" if exist else "No")


Measured memory_bytes: 13964
#include<iostream>
#include<cmath>
#include<cstdio>
#include<algorithm>
#include<vector>
#include<cstring>
#include<queue>

using namespace std;

#define INF 999999999
#define REP(i,n) for(int i=0; i<(int)(n); i++)

int main(){
	int n, m, q;
	string s;
	vector <string> b(2);
	bool ans[36][1000];
	while(1){
		cin >> n >> m >> q;
		if(!n) break;
		b[1]= "";
		REP(i,m)b[1] = b[1] + "0";
		REP(i,n){
			REP(j,m){
				ans[i][j]=1;
			}
		}
		//cout << b[1] <<endl;
		REP(i,q){
			cin >> s >> b[0];
			REP(j,n){
				if(s[j]=='1'){
					REP(k,m){
						if(b[0][k]==b[1][k]) ans[j][k]=0;
					}
				}
				else if(s[j]=='0'){
					REP(k,m){
						if(b[0][k]!=b[1][k]) ans[j][k]=0;
					}
				}
			}
			/*
			REP(j,n){
				REP(k,m) cout << ans[j][k];
				cout << endl;
			}
			*/
			b[1] = b[0];
		}
		REP(i,m){
			int flag=0;
			REP(j,n){
				if(ans[j][i]){
					if(!flag)flag = j+1;
					else{
						flag = -1;
						break;
					}
				}
			}
			if(flag>=1&&flag<=10) cout << flag-1;
			else if(flag==-1) cout << "?";
			else printf("%c",'A'+flag-11);
		}
		cout << endl;
	}
	return 0;
}

Measured memory_bytes: 1260
n,m = map(int, input().split())
l = 1
r = n
for i in range(m):
    a,b = map(int, input().split())
    if a > l:
        l = a
    if b < r:
        r = b
if r - l < 0:
    print(0)
else:
    print(r - l + 1)

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

int32_t main() {
    int n, W;
    cin >> n >> W;

    vector<int> weight(n), value(n);
    for (int i = 0; i < n; ++i)
        cin >> weight[i] >> value[i];

    int sum_val = 0;
    for (int i : value) sum_val += i;

    vector<int> dp(sum_val + 1, 1e9);
    dp[0] = 0;

    for (int i = 0; i < n; ++i) {
        for (int j = sum_val - value[i]; j >= 0; --j) {
            dp[j + value[i]] = min(dp[j + value[i]], \
                dp[j] + weight[i]);
        }
    }

    int ans = 0;

    for (int i = 0; i <= sum_val; ++i) {
        if (dp[i] <= W) {
            ans = max(ans, i);
        }
    }

    cout << ans << "\n";
} 

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

signed main(){
    ios_base::sync_with_stdio(0);

    int h,w,k;
    cin >> h >> w >> k;

    string grid[h];
    for(auto& i : grid)
        cin >> i;

    int ans=0;
    for(int bit_i=0;bit_i<(1ll<<h);bit_i++){
        for(int bit_j=0;bit_j<(1ll<<w);bit_j++){
            string new_grid[h];
            for(int l=0;l<h;l++)
                new_grid[l] = grid[l];

            for(int i=0;i<h;i++){
                for(int j=0;j<w;j++){
                    int x = (bit_i>>i)&1;
                    int y = (bit_j>>j)&1;
                    if(x == 0 && y == 0) continue;
                    new_grid[i][j] = '1';
                }
            }

            int cnt=0;
            for(int i=0;i<h;i++){
                for(int j=0;j<w;j++){
                    if(new_grid[i][j] == '#') cnt++;
                }
            }

            if(cnt == k) ans++;
        }
    }

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


Measured memory_bytes: 3652
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <queue>
#include <string>
#include <list>
#define rep(i,n) for(int i = 0; i < n;i++)

using namespace std;
int main(int argc, const char * argv[]){
    int n,r;
    int p,c;
    int A[100];
    while(cin >> n >> r && n){
        for(int i=0;i < n;i++){
            A[i]=n-i;
        }
        for(int i = 0;i < r;i++){
            cin >> p >> c;
            rotate(A,A+p-1,A+p+c-1);

        }
        cout << A[0] << endl;
    }
}

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

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
const int INF = (1<<30) - 1;
const ll LINF = (1LL<<60) - 1;

int main(){
    ll x, k, d;
    cin >> x >> k >> d;
    x = abs(x);

    if (x / d > k){
        cout << x - k * d << endl;
    } else{
        k -= x/d;
        x -= x/d * d;

        cout << ((k % 2) ? d - x : x) << endl;
    }
}

Measured memory_bytes: 3636
n=int(input())
a,b=[int(s) for s in input().split()]
P=[int(s) for s in input().split()]

lea=[p for p in P if p<=a]
gealeb=[p for p in P if a<p<=b]
gtb=[p for p in P if p>b]

print(min(len(lea),len(gealeb),len(gtb)))

Measured memory_bytes: 3064
uses math;
var i, j, n, k : longint;
    h, dp : array[1..100005] of longint;
const inf = 2000000000;
 
begin
    readln(n, k);
    for i := 1 to n do 
    begin
        read(h[i]);
        dp[i] := inf;
    end;
    dp[1] := 0;
    for i := 2 to n do
    begin
        for j := max(1, i - k) to i - 1 do
        begin
            dp[i] := min(dp[i], dp[j] + abs(h[j] - h[i]));
        end;
    end;
    writeln(dp[n]);
end.

Measured memory_bytes: 1024
#include<cstdio>
#include<cctype>
#include<algorithm>
using namespace std;
const int N=200010;
const double pi=3.14159265358979;
int n,X1,Y1,X2,Y2,tot,tp,flgx=1,flgy=1,tmp[N];
pair<int,int>p[N];
char buffer[1000010],*hd,*tl;
char Getchar(){
    if(hd==tl){
        int len=fread(buffer,1,1000000,stdin);
        hd=buffer,tl=hd+len;
        if(hd==tl)
            return EOF;
    }
    return *hd++;
}
int rd(){
    int x=0;
    char c;
    do c=Getchar();
    while(!isdigit(c));
    do{
        x=(x<<1)+(x<<3)+(c^48);
        c=Getchar();
    }while(isdigit(c));
    return x;
}
void ReadData(){
	X1=rd(),Y1=rd(),X2=rd(),Y2=rd(),n=rd();
	if(X1>X2){
		flgx=-1;
		X1=-X1;
		X2=-X2;
	}
	if(Y1>Y2){
		flgy=-1;
		Y1=-Y1;
		Y2=-Y2;
	}
	for(int i=1;i<=n;i++){
		int x=rd(),y=rd();
		x*=flgx;
		y*=flgy;
		if(X1<=x&&x<=X2&&Y1<=y&&y<=Y2)
			p[++tot]=make_pair(x,y);
	}
	return;
}
void LIS(){
	sort(p+1,p+tot+1);
	for(int i=1;i<=tot;i++){
		if(!tp||tmp[tp]<p[i].second)
			tmp[++tp]=p[i].second;
		else tmp[lower_bound(tmp+1,tmp+tp+1,p[i].second)-tmp]=p[i].second;
	}
	return;
}
double getans(){
	double ret=100.0*(X2-X1+Y2-Y1)+tp*(5.0*pi-20.0);
	if(tp==min(X2-X1+1,Y2-Y1+1))
		ret+=5.0*pi;
	return ret;
}
int main(){
	ReadData();
	LIS();
	printf("%.12lf",getans());
	return 0;
}

Measured memory_bytes: 3456
def PF(n):
    fs = []
    q = int(n ** 0.5) 
    for i in range(2, q + 1):
        if n % i == 0:
            r = 0
            while n % i == 0:
                n //= i
                r += 1
            fs.append([i, r])
    if n != 1:
        fs.append([n, 1])
    return fs

n = int(input())
p = [0] * 1001
for i in range(2, n + 1):
    for j in PF(i):
        p[j[0]] += j[1]

ans = 1
mod = int(1e9 + 7)
for i in range(2, n + 1):
    ans = ans * (p[i] + 1) % mod
print(ans)

Measured memory_bytes: 3188
#include<cstring>
#include<cstdlib>
#include<cstdio>
#include<cmath>
#include<iostream>
#include<algorithm>
#define N 110000
#define lowbit(x) (x&(-x))
using namespace std;
int a[3][N],n,d[5],flip[2],inv[2],s[N],lt[N],w[N];
void change(int x,int d)
{
	for(int i=x;i;i-=lowbit(i)) lt[i]+=d;
}
int find(int x)
{
	int sum=0;
	for(int i=x;i<=n;i+=lowbit(i)) sum+=lt[i];
	return sum;
}
int main()
{
	scanf("%d",&n);
	for(int i=0;i<=2;i++)
		for(int j=1;j<=n;j++)
			scanf("%d",&a[i][j]);
	for(int i=1;i<=n;i++)
	{
		d[0]=a[0][i];d[1]=a[1][i];d[2]=a[2][i];
		sort(d,d+3);
		if(d[2]%3 || d[0]+1!=d[1] || d[1]+1!=d[2] || d[1]!=a[1][i]) 
		{printf("No\n");return 0;}
		int j=d[2]/3;
		if((i-j)%2) 
		{printf("No\n");return 0;}
		inv[i%2]=(inv[i%2]+(a[0][i]>a[2][i]))%2;
		s[i]=j;
	}
	for(int i=1;i<=n;i++) w[s[i]]=i;
	for(int i=1;i<=n;i+=2)
	{
		int now=w[i]+2*find(w[i]);
		flip[1]=(flip[1]+abs(i-now)/2)%2;
		change(w[i],1);
	}
	for(int i=1;i<=n;i++) lt[i]=0;
	for(int i=2;i<n;i+=2)
	{
		int now=w[i]+2*find(w[i]);
		flip[0]=(flip[0]+abs(i-now)/2)%2;
		change(w[i],1);
	}
	if(flip[0]!=inv[1] || flip[1]!=inv[0]) printf("No\n");
	else printf("Yes\n");
	return 0;
}

Measured memory_bytes: 2560
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace ConsoleApplication2
{
    class Program
    {
        static void Main(string[] arggs)
        {
            System.Console.ReadLine();
            var r = System.Console.ReadLine().Split(new char[] {' '}).Select(s=>long.Parse(s)).ToArray<long>();


            System.Console.WriteLine("{0} {1} {2}",r.Min(),r.Max(),r.Sum());
        }
    }
}

Measured memory_bytes: 10652
#include <stdio.h>

int main(void){
  int a,b; //a,bは整数
  int i;
  int sum;
  int count = 1;

  while(scanf("%d %d" ,&a ,&b) != EOF){
    sum = a + b;

    while(sum >= 10){
      sum /= 10;
      count++;
    }

    printf("%d\n" ,count);
    count = 1;
  }

  return 0;
} 

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

using namespace std ;

const int MAX = 1e5 + 10 ;

int arr[MAX] ;
int n ;

int main()
{
	ios_base::sync_with_stdio(0) ;
	cin.tie(0) ;
	string s ;
	cin>>s ;
	n = s.size() ;
	for(int i = 0 ; i < n ; ++i)
		cout<<"x" ;
	return cout<<"\n" , 0 ;
}		

Measured memory_bytes: 256
class Array
    def max_length
        l = 0
        m = 0
        each do |x|
            if x == 1
                l += 1
                m = l if l > m
            else
                l = 0
            end
        end
        m
    end
end

loop do
    n = gets.to_i
    break if n == 0

    a = (1..n).map { gets.split("").map(&:to_i) }
    m = 0

    (a + a.transpose).each do |r|
        l = r.max_length
        m = l if l > m
    end

    (0..n-1).to_a.product((0..n-1).to_a).group_by{|i, j| i + j}.values.each do |ijs|
        r = ijs.map{|i, j| a[i][j]}
        l = r.max_length
        m = l if l > m
    end

    (0..n-1).to_a.product((0..n-1).to_a).group_by{|i, j| i - j}.values.each do |ijs|
        r = ijs.map{|i, j| a[i][j]}
        l = r.max_length
        m = l if l > m
    end

    p m
end

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

const int N=3005,inv=499122177;
const int MOD=998244353;
int n,s,a[N];
long long p[N],dp[N][N],ans;

int main()
{
	scanf("%d%d",&n,&s),p[0]=1;
	for(int i=1;i<=n;i++) p[i]=p[i-1]*2%MOD;
	for(int i=1;i<=n;i++)
	{
		scanf("%d",&a[i]);
		dp[i-1][0]=p[n];
		for(int j=1;j<=s;j++)
		{
			dp[i][j]=dp[i-1][j];
			if(j>=a[i]) dp[i][j]=(dp[i][j]+dp[i-1][j-a[i]]*inv%MOD)%MOD;
//			cout<<i<<' '<<j<<' '<<dp[i][j]<<endl;
		}
	}
	printf("%lld\n",dp[n][s]);
}

Measured memory_bytes: 74268
#include<iostream>
using namespace std;
int main(){
    int a,b,c,d,e,f,g,h,x,y;
    
    while (cin >> a >> b >> c >> d) {
    x = 0;
    y = 0;
    cin >> e >> f >> g >> h;
        if (a==e){x=x+1 ;e=e+10;} 
        if (b==f){x=x+1;f=f+10;} 
        if (c==g){x=x+1;g=g+10;}
        if (d==h){x=x+1;h=h+10;}
        if (e==a || e==b || e==c || e==d){y=y+1;}
        if (f==a || f==b || f==c || f==d){y=y+1;}
        if (g==a || g==b || g==c || g==d){y=y+1;}
        if (h==a || h==b || h==c || h==d){y=y+1;}
        cout << x << " " <<  y << endl;
    }
    
return 0 ;
}



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

typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<double> vd;
typedef vector<ll> vl;
typedef vector<char> vc;
typedef vector<string> vs;
const ll mod = 1e9+7;
const ll inf = 1e17;
const int INF = 1e9;
const double PI = acos(-1);
#define fo(i, a, b) for(int i = a; i < b; i++)
#define re(i, n) fo(i, 0, n)
#define pb push_back
#define mp make_pair
#define all(s) s.begin(), s.end()
ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }
ll lcm(ll a, ll b) { ll g = gcd(a, b); return a / g * b; }
int main()
{
  int a, b;
  cin >> a >> b; //時針, 分針
  int h, m;
  cin >> h >> m; //h時m分

  double c = fabs(30 * h + 0.5 * m - 6 * m); //時針と分針の角度
  c = min(c, fabs(360 - c));
  double r_c = c * PI / 180;
  cout << fixed << setprecision(15)<< sqrt(a * a + b * b - 2 * a * b * cos(r_c)) << endl;

  return 0;
}


Measured memory_bytes: 4160
#include <algorithm>
#include <cassert>
#include <cmath>
#include <deque>
#include <functional>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>
#define all(x) (x).begin(), (x).end()
using namespace std;
using ll = long long;

template <typename T, typename F>
constexpr bool chmin(
    T &a, T b, F f = [](T a, T b) { return a > b; }) {
  // when f is true, b is more 'smaller'
  if (f(a, b)) {
    swap(a, b);
    return true;
  }
  return false;
}
template <typename T> constexpr bool chmax(T &a, T b) {
  return chmin(a, b, [](T a, T b) -> bool { return a < b; });
}
template <typename ite> void print_ite(ite start, ite end, char c = ' ') {
  for (auto i = start; i != end; i++)
    cout << i << c;
  cout << endl;
}
template <typename ite> void scan_ite(ite start, ite end) {
  for (auto i = start; i != end; i++)
    cin >> (*i);
}
inline void Yes(bool condition) { cout << (condition ? "Yes\n" : "No\n"); }

int main() {
  int x, y, a, b, c;
  cin >> x >> y >> a >> b >> c;
  vector<int> p(a), q(b), r(c);
  scan_ite(all(p));
  scan_ite(all(q));
  scan_ite(all(r));
  sort(all(p), greater<int>());
  sort(all(q), greater<int>());
  sort(all(r), greater<int>());
  ll ans = 0;
  for (int i = 0; i < x; i++) {
    ans += p[i];
  }
  for (int i = 0; i < y; i++) {
    ans += q[i];
  }
  int ac = x, bc = y;
  for (int i = 0; i < c; i++) {
    ll cand1 = ac == 0 ? 0 : ans - p[ac - 1] + r[i];
    ll cand2 = bc == 0 ? 0 : ans - q[bc - 1] + r[i];
    //cout << ans << " " << cand1 << " " << cand2 << "\n";
    if (cand1 > cand2) {
      if (chmax(ans, cand1))
        ac--;
    } else {
      if (chmax(ans, cand2))
        bc--;
    }
  }
  cout << ans << endl;
}


Measured memory_bytes: 1536
import java.io.IOException;
import java.io.InputStream;
import java.util.NoSuchElementException;
import java.util.PriorityQueue;

public class Main {
	

	public static void main(String[] args) {
		FastScanner sc = new FastScanner();
		
		int n = sc.nextInt();
		
		Node[] V = new Node[n];
		PriorityQueue<Node> que = new PriorityQueue<>(11, (a, b) -> a.d - b.d);
		for(int i=0; i<n; i++) {
			sc.nextInt();
			int k = sc.nextInt();
			int[] v = new int[k];
			int[] c = new int[k];
			for(int j=0; j<k; j++) {
				v[j] = sc.nextInt();
				c[j] = sc.nextInt();
			}
			V[i] = new Node(v, c);
		}
		V[0].d = 0;
		que.add(V[0]);
		
		while(!que.isEmpty()) {
			Node node1 = que.poll();
			for(int i=0; i<node1.v.length; i++) {
				Node node2 = V[node1.v[i]];
				if(node2.d > node1.d + node1.c[i]) {
					if(que.contains(node2)) {
						que.remove(node2);
					}
					node2.d = node1.d + node1.c[i];
					que.add(node2);
				}
			}
		}
		
		for(int i=0; i<n; i++) {
			System.out.println(i + " " + V[i].d);
		}
	}
	
	static class Node {
		int d = Integer.MAX_VALUE;
		int[] v;
		int[] c;
		
		Node(int[] v, int[] c) {
			this.v = v;
			this.c = c;
		}
	}

	static class FastScanner {
	    private final InputStream in = System.in;
	    private final byte[] buffer = new byte[1024];
	    private int ptr = 0;
	    private int buflen = 0;
	    private boolean hasNextByte() {
	        if (ptr < buflen) {
	            return true;
	        }else{
	            ptr = 0;
	            try {
	                buflen = in.read(buffer);
	            } catch (IOException e) {
	                e.printStackTrace();
	            }
	            if (buflen <= 0) {
	                return false;
	            }
	        }
	        return true;
	    }
	    private int readByte() { if (hasNextByte()) return buffer[ptr++]; else return -1;}
	    private static boolean isPrintableChar(int c) { return 33 <= c && c <= 126;}
	    private void skipUnprintable() { while(hasNextByte() && !isPrintableChar(buffer[ptr])) ptr++;}
	    public boolean hasNext() { skipUnprintable(); return hasNextByte();}
	    public String next() {
	        if (!hasNext()) throw new NoSuchElementException();
	        StringBuilder sb = new StringBuilder();
	        int b = readByte();
	        while(isPrintableChar(b)) {
	            sb.appendCodePoint(b);
	            b = readByte();
	        }
	        return sb.toString();
	    }
	    public long nextLong() {
	        return Long.parseLong(next());
	    }
	    public int nextInt(){
	    	return Integer.parseInt(next());
	    }
	}
	
	
}

Measured memory_bytes: 68264
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<numeric>
#include<map>
#include<unordered_map>
#include<set>
#include<stack>
#include<queue>

#define reps(i,j,k) for(int i=(j);i<(k);i++)
#define rep(i,j) reps(i,0,j)
#define fs first
#define sc second
#define pb push_back
#define mk make_pair

using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef vector<int> vi;

template<class S,class T>
ostream &operator<<(ostream &out, const pair<S,T> p){
	return out << "(" << p.fs << ", " << p.sc << ")";
}

template<class T>
ostream &operator<<(ostream &out, const vector<T> &v){
	out << "{";
	rep(i,v.size()) out << v[i] << ", ";
	return out << "}" << endl;
}

int main(){
	int n;
	while(cin >> n, n){
		vector<string> v(n);
		vector<char> c;
		vi num(10);
		rep(i,10) num[i] = i;
		rep(i,n){
			cin >> v[i];
			rep(j,v[i].length()){
				char ch = v[i][j];
				rep(k,c.size()) if(ch == c[k]){
					ch = 0;
					break;
				}
				if(ch) c.pb(ch);
			}
		}
		while(c.size() < 10) c.pb(0);
		sort(c.begin(), c.end());
		int cnt = 0;
		vi istop(256);
		rep(i,n){
			if(v[i].length() == 1) continue;
			istop[v[i][0]] = 1;
		}
		vi keisu(256);
		rep(i,n){
			int t = 1;
			reverse(v[i].begin(), v[i].end());
			rep(j, v[i].length()){
				keisu[v[i][j]] += i != n-1 ?t : -t;
				t *= 10;
			}
		}
		do{
			if(istop[c[0]]) continue;
			int sum = 0;
			rep(i,10) sum += keisu[c[i]] * i;
			cnt += sum == 0;
		}while(next_permutation(c.begin(), c.end()));		
		cout << cnt << endl;;
	}
	return 0;
}

Measured memory_bytes: 3124
#include <cstdio>
#include <cmath>
#include <cstdint>
#include <cinttypes>
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>

using namespace std;

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

    long start0 = 0;
    long start1 = 0;
    for(size_t i = 0 ; i < s.length(); i++){
        if(i % 2 == 0){
            if(s[i] == '0'){
                start1++;     
            } else {
                start0++;
            }
        } else {
            if(s[i] == '1'){
                start1++;
            }else {
                start0++;
            }
        }
    }

    cout << (start0 < start1 ? start0 : start1);

    return 0;
}


Measured memory_bytes: 512
//#include <iostream>
//#include <string>
#include <stdio.h>

//using namespace std;

/*long long a[21]={0, 298790200, 797380500, 1095170800, 1392951000, 1891731200, 2190321500, 2589111800, 2987902000, 3285592200, 3783282500, 5082072800, 5380853000, 5879533200, 7178223500, 7577013800, 7973805000, 8272395200, 8771185500, 9059975800, 9358757000};
char b[100000]={};

long long int number(int n){
  long long int h=0;
  int p=0;

  p=(n/50000000)*50000000;
  h=a[p/50000000];

  while(p<n){
    h++;
    if(b[h%100000]==1 && b[h/100000]==1)
      p++;
    }

  return h;
}


int main() {
    ios::sync_with_stdio(false);
    int s;
    int m=0;
    while(m<=99999){
      int t=m;
      while(t>0){
	if(t%10==4 || t%10==6)
	  {b[m]--;break;}
	else{
	  t=t/10;      
	}
      }
      b[m]++;
      m++;
    }
    
    int p,q;
    
    while (1) {
      cin >> s;
      if(s != 0){
	cout << number(s) << endl;
      }
      else
	break;
    }

    return 0;
}
*/

char str[15];

char* number(int n){
  sprintf(str, "%o", n);
  int i;
  for(i=0;i<15;i++){
    if(str[i]>='4')
      {str[i]++;}
    if(str[i]>='6')
      str[i]++;
  }
  
  return str;
}



int main(){
  int s;
  while (1) {
    scanf("%d", &s);
    if(s != 0){
      //cout << number(s) << endl;
      printf("%s\n", number(s));
    }
    else
      break;
  }
  
  return 0;
}

Measured memory_bytes: 2728
#include <iostream>
#include <string>
#include <sstream>
#include <map>
#include <set>

using namespace std;

int main() {
    map<int, int> m;
    int n, cnt;
    char comma;

    while(true) {
        string str;
        getline(cin, str);
        if(str == "") break;

        istringstream is(str);
        is >> n >> comma >> cnt;
        m[n]++;
    }

    set<int> s;
    while(cin >> n >> comma >> cnt) {
        if(m.count(n) > 0) {
            m[n]++;
            s.insert(n);
        }
    }

    for(set<int>::iterator it = s.begin(); it != s.end(); ++it)
        cout << *it << ' ' << m[*it] << endl;
    return 0;
}

Measured memory_bytes: 0
import sys
from collections import deque
import copy
import math
def get_read_func(fileobject):
    if fileobject == None :
        return raw_input
    else:
        return fileobject.readline

def main():
    if len(sys.argv) > 1:
        f = open(sys.argv[1])
    else:
        f = None
    read_func = get_read_func(f);
    input_raw = read_func().strip().split()
    [N, M] = [long(input_raw[0]), long(input_raw[1])]
    input_raw = read_func().strip().split()
    X = []
    for i in range(M):
        X.append(int(input_raw[i]))

    if len(X) <= N:
        print 0
        return
    if N == 1:
        print max(X) - min(X)
        return

    X.sort()

    subX = []
    for i in range(M - 1):
        subX.append((X[i + 1] - X[i], i + 1))

    subX.sort(reverse = True)

    count = 0
    for i in range(N):
        if i == N - 1:
            count += X[M - 1] - X[subX[i - 1][1]]
        elif i != 0:
            count += X[subX[i][1] - 1] - X[subX[i - 1][1]]
        else:
            count += X[subX[i][1] - 1] - X[0]
    print count


if __name__ == '__main__':
    main()


Measured memory_bytes: 25740
a,b,k=map(int,input().split())
s=[a,b]
for i in range(k):
  x,y=int((1-(-1)**i)/2),int((1+(-1)**i)/2)
  if s[x]%2==1:
    s[x]-=1
  s[y]+=s[x]//2
  s[x]-=s[x]//2
print(s[0],s[1])

Measured memory_bytes: 3064
#include <iostream>
#include <array>

int main() {
    std::array<int, 4> a, b;

    while (std::cin >> a[0] >> a[1] >> a[2] >> a[3] 
                    >>b[0] >> b[1] >> b[2] >> b[3]) {
        int cnt_hits = 0, cnt_blows = 0;
        
        for (int i = 0; i < 4; ++i) {
            for (int j = 0; j < 4; ++j) {
                if (a[i] == b[j]) {
                    i != j ? ++cnt_blows : ++cnt_hits;
                }
            }
        }

        std::cout << cnt_hits << " " << cnt_blows << std::endl;
    }

    return 0;
}

Measured memory_bytes: 1160
#include<bits/stdc++.h>
#define F first
#define S second
#define endl '\n'
#define lcm( a, b ) ((a)/__gcd(a,b)*(b))
#define MP make_pair
#define pb push_back
#define all(x) (x).begin(),(x).end()

using namespace std;

typedef long long LL;
typedef pair<int, int> P;
typedef pair<int, P> iP;
typedef pair< LL, LL > LP;

const int INF = INT_MAX;
const int MIN = INT_MIN;
const LL LINF = LLONG_MAX;
const int MOD = 1000000000 + 7;
const int SIZE = 300005;

vector< int > Div( int n ) {
    vector< int > ret;
    for( int i = 1; i * i <= n; ++i ) {
        if( n % i ) {
            ret.pb( i );
            if( i * i != n ) ret.pb( n / i );

        }
    }
    sort( all( ret ) );
    return ret;
}

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

    string s;
    for( int i = 0; i < 3; ++i ) {
        cin >> s;
        cout << (char)(s[0] - ('a' - 'A'));

    }
    cout << endl;
    return 0;
}



Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
using namespace std;
int main(){
    int n, num;
    string S;
    cin >> n;
    int cards[4][13];
    for(int i = 0; i < 4; i++){
        for(int j = 0; j < 13; j++){
            cards[i][j] = 0;
        }
    }
    for(int i = 0; i < n; i++){
        cin >> S >> num;
        if(S == "S") cards[0][num - 1] = 1;
        if(S == "H") cards[1][num - 1] = 1;
        if(S == "C") cards[2][num - 1] = 1;
        if(S == "D") cards[3][num - 1] = 1;
    }
    for(int i = 0; i < 4; i++){
        for(int j = 0; j < 13; j++){
            if(cards[i][j] == 0){
                if(i == 0) cout << "S" << " " << j + 1 << endl;
                if(i == 1) cout << "H" << " " << j + 1 << endl;
                if(i == 2) cout << "C" << " " << j + 1 << endl;
                if(i == 3) cout << "D" << " " << j + 1 << endl;
            }
        }
    }

return 0;
}

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

const int MOD = 1000000007;

int a[25][25];
int64_t dp[1<<21];
int bitcnt[1<<21];

int main() {
    int n;
    cin >> n;
    rep(i,n) rep(j,n) cin >> a[i][j];
    dp[0] = 1;
    for (int s = 1; s < (1<<n); s++) {
        bitcnt[s] = bitcnt[s/2] + s%2;
        for (int l = 0; l < n; l++) {
            if ((s >> l) % 2 == 0) continue;
            dp[s] += dp[s - (1 << l)] * a[bitcnt[s] - 1][l];
            dp[s] %= MOD;
        }   
    }
    cout << dp[(1 << n) - 1] << endl;
}

Measured memory_bytes: 24832
#include <stdio.h>

int n;
int a[20];

int solve(int,int);

int main(){
  int q,i,m;

  scanf("%d",&n);
  for(i = 0;i < n;i++){
    scanf("%d",&a[i]);
  }
  scanf("%d",&q);
  for(i = 0;i < q;i++){
    scanf("%d",&m);
    m = solve(0,m);
    if(m == 1) printf("yes\n");
    else printf("no\n");
  }

  return 0;  
}

int solve(int i,int m){
  int res = 0;
  if(m == 0) return 1;
  if(i >= n) return 0;
  res = solve(i + 1, m) || solve(i + 1, m - a[i]);
  return res;
}



Measured memory_bytes: 2108