akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
//#pragma GCC optimize("Ofast")
//#pragma GCC optimize ("unroll-loops")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
//#pragma comment(linker, "/stack:200000000")
using namespace std;
#define F first
#define S second
#define EB emplace_back
#define MP make_pair
#define all(o) (o).begin(), (o).end()
#define mset(m,v) memset(m,v,sizeof(m))
#define fr(i,n) for(lli i=0;i<(n);++i)
#define rep(i,a,b) for(lli i=a;i<=b;++i)
#define per(i,a,b) for(lli i=a;i>=b;i--)
#define remin(a,b) (a=min((a),(b)))
#define remax(a,b) (a=max((a),(b))) 
#define sz(x) (lli)(x).size()
#define endl '\n'
typedef long long lli;        typedef long double ld;
typedef pair<lli,lli> ii;     typedef vector<lli> vi;
typedef vector<ii> vii;       typedef vector<vi> graph;
long long MOD=1000000007;     long double EPS=1e-9;
#ifndef ONLINE_JUDGE
#define debarr(a,n)cerr<<#a<<":";for(int i=0;i<n;i++)cerr<<a[i]<<" ";cerr<<endl;
#define debmat(mat,row,col)cerr<<#mat<<":\n";for(int i=0;i<row;i++){for(int j=0;j<col;j++)cerr<<mat[i][j]<<" ";cerr<<endl;}
#define pr(...)dbs(#__VA_ARGS__,__VA_ARGS__)
template<class S,class T>ostream &operator<<(ostream &os,const pair<S,T> &p){return os<<"("<<p.first<<","<<p.second<<")";}
template<class T>ostream &operator<<(ostream &os,const vector<T> &p){os<<"[";for(auto&it:p)os<<it<<" ";return os<<"]";}
template<class T>ostream &operator<<(ostream &os,const set<T>&p){os<<"[";for(auto&it:p)os<<it<<" ";return os<<"]";}
template<class T>ostream &operator<<(ostream &os,const multiset<T>&p){os<<"[";for(auto&it:p)os<<it<<" ";return os<<"]";}
template<class S,class T>ostream &operator<<(ostream &os,const map<S,T>&p){os<<"[";for(auto&it:p)os<<it<<" ";return os<<"]";}
template<class T>void dbs(string str,T t){cerr<<str<<":"<<t<<"\n";}
template<class T,class...S>void dbs(string str,T t,S... s){int idx=str.find(',');cerr<<str.substr(0,idx)<<":"<<t<<",";dbs(str.substr(idx+1),s...);}
#else
#define pr(...){}
#define debarr(a,n){}
#define debmat(mat,row,col){}
#endif
lli binpow(lli b,lli p,lli mod){lli ans=1;b%=mod;for(;p;p>>=1){if(p&1)ans=ans*b%mod;b=b*b%mod;}return ans;}

void pre(){

}

void solve(){
    char ch;cin>>ch;
    cout<<char(ch+1)<<endl;
}

signed main(){
    ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
    //freopen("in.txt","r",stdin);
    //freopen("out.txt","w",stdout);
    //cout<<fixed<<setprecision(15);
    //clock_t begin = clock();
    pre();lli _t=1;//cin>>_t;
    for(lli i=1;i<=_t;i++){
        //cout<<"Case #"<<i<<": ";
        solve();
    }
    // clock_t end = clock();double elapsed_secs = double(end - begin) / CLOCKS_PER_SEC;cerr << elapsed_secs;
}

Measured memory_bytes: 256
import bisect

n = int(input())
d = list(map(int, input().split()))

d.sort()
i = d[0]
a = 0
for v in d:
    a = bisect.bisect_left(d, v)
    if a>=int(n/2):
        break

if a >int(n/2):
    print(0)
else:
    print(d[a]-d[a-1])

Measured memory_bytes: 53036
#include<bits/stdc++.h>
typedef long long ll;
const int maxn = 3e6;
using namespace std;
int n, k;

#define P pair<string, string>

map<P, int> mp;
string ss;

int main() {
    ios::sync_with_stdio(0);
    while(cin >> n >> ss) {
        for(int i = 0; i < (1 << n); i++) {
            string x, y;
            for(int k = 0; k < n; k++) {
                if(i & (1 << k)) x += ss[k];
                else y += ss[k];
            }
            mp[P(x, y)]++;
        }
        
        ll ans = 0;
        for(int i = 0; i < (1 << n); i++) {
            string x, y;
            for(int k = 0; k < n; k++) {
                if(i & (1 << k)) x += ss[2 * n - k - 1];
                else y += ss[2 * n - k - 1];
            }
            ans += mp[P(x, y)];
        }
        cout << ans << endl;
    }
    return 0;
}


Measured memory_bytes: 91904
import java.util.Scanner;
import java.util.List;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
	int a = sc.nextInt();
    int b = sc.nextInt();
    System.out.println(a-b+1);
  }
}

Measured memory_bytes: 21332
#include<bits/stdc++.h>
#define int long long
#define rep(i,x,y) for(int i=x;i<y;i++)
#define repr(i,x,y) for(int i=x;i>=y;i--) 
#define mod 1000000007
using namespace std;

void Onigiri()
{
 int n;
 cin>>n;
 set<string> s;
 rep(i,0,n)
 {
  string ss;
  cin>>ss;
  s.insert(ss);
 }
 cout<<s.size();
}
signed main()
{
   ios_base::sync_with_stdio(false);cin.tie(NULL);
   #ifdef Zoro
   freopen("in", "r", stdin);freopen("out", "w", stdout);
   #endif  
 
   int t=1; 
   //cin>>t;
 
   while(t--)
   {Onigiri();cout<<"\n";}

   cerr<<"\n"<<(float)clock()/CLOCKS_PER_SEC*1000<<" ms"<<endl;
   return 0;
}

Measured memory_bytes: 19404
#include <bits/stdc++.h>
using namespace std;
int main(){
	int a,b,c,i;
  	cin>>a>>b;
	
  	c=a*pow(10,(int)(log10(b)+1))+b;
  
  	for(i=1;i<=sqrt(c);i++){
      if(i*i==c){
        cout<<"Yes"<<endl;
      	return 0;
      }
    }
  
  	cout<<"No"<<endl;
  
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i=0; i<(n); ++i)
#define y_n(ans) cout<<(ans?"Yes":"No")<<endl;

int main() {
    int n, x, t;
    cin >> n >> x >> t;
    cout << (n + x - 1) / x * t << endl;
}

Measured memory_bytes: 3632
#include <stdio.h>
#include <stdlib.h>
#include <vector>

#define NUM_MOD (1000000007L)

using namespace std;

void copy_mat(const vector<vector<long>> &ass, vector<vector<long>> &bss) {
  const long M = ass.size(), N = ass[0].size();
  for (long i = 0; i < M; i++) {
    for (long j = 0; j < N; j++) {
      bss[i][j] = ass[i][j];
    }
  }
}

void mat_mult_mat(const vector<vector<long>> &ass,
                  const vector<vector<long>> &bss, vector<vector<long>> &css) {
  const long L = ass.size(), M = ass[0].size(), N = bss[0].size();
  // initialize
  for (long i = 0; i < L; i++) {
    for (long j = 0; j < N; j++) {
      css[i][j] = 0;
    }
  }
  // calculate
  for (long i = 0; i < L; i++) {
    for (long k = 0; k < M; k++) {
      for (long j = 0; j < N; j++) {
        css[i][j] = (css[i][j] + ass[i][k] * bss[k][j]) % NUM_MOD;
      }
    }
  }
}

void mat_pow(const vector<vector<long>> &ass, long k,
             vector<vector<long>> &bss) {
  const long N = ass.size();
  // initialize
  for (long i = 0; i < N; i++) {
    for (long j = 0; j < N; j++) {
      bss[i][j] = i == j;
    }
  }
  // calculate
  vector<vector<long>> xss(N, vector<long>(N, 0)), tss(N, vector<long>(N, 0));
  copy_mat(ass, xss);
  while (k > 0) {
    if (k % 2) {
      mat_mult_mat(bss, xss, tss);
      copy_mat(tss, bss);
    }
    k /= 2;
    mat_mult_mat(xss, xss, tss);
    copy_mat(tss, xss);
  }
}

int main() {
  // read inputs
  long N, K;
  vector<vector<long>> ass;
  scanf("%ld %ld", &N, &K);
  for (long i = 0; i < N; i++) {
    ass.push_back(vector<long>(N, 0));
    for (long j = 0; j < N; j++) {
      scanf("%ld", &ass[i][j]);
    }
  }

  // solve
  vector<vector<long>> bss(N, vector<long>(N, 0));
  long ans = 0;
  mat_pow(ass, K, bss);
  for (long i = 0; i < N; i++) {
    for (long j = 0; j < N; j++) {
      ans = (ans + bss[i][j]) % NUM_MOD;
    }
  }
  printf("%ld\n", ans);
}

Measured memory_bytes: 384
//Codes by: Umar Bin Qamar

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

bool compare(int a,int b){
    return a>b;
}

int32_t main(){

//int count=0;
  int n,m;
  cin>>n>>m;
  //cin>>p;
  int arr[10010];
  for(int i=0;i<m;i++){
    cin>>arr[i];
  }
  int count=0;
  for(int i=0;i<m;i++){
   count=count +arr[i];
 //   count=count-n;
  }
  if(n-count>=0){
    cout<<n-count<<endl;
  }
  else{
    cout<<"-1"<<endl;
  }


    return 0;
}



Measured memory_bytes: 3616
#include <stdio.h>
#include <cstdio>
#include <iostream>
#include <iomanip>
#include <queue>
#include <set>
#include <vector>
#include <string>
#include <cstring>
#include <algorithm>
#include <cmath>

int main(){

  long long int N, tmp1, tmp2, tmp;
  std::vector<long long int> A;

  scanf("%lld", &N); 
  std::vector<std::vector<long long int> > x(N), y(N);


  for(long long int i = 0; i < N; i++){
    scanf("%lld", &tmp);
    A.push_back(tmp);
    for(long long int j = 0; j < A[i]; j++){
      scanf("%lld%lld", &tmp1, &tmp2);
      x[i].push_back(tmp1-1);
      y[i].push_back(tmp2);
    }
  }

  // solve problem
  std::vector<long long int> table(N);
  long long int N_honest, flag, ans = 0;

  long long int S = 0;
  for(S = 0; S < (1<<N); S++){
    // make table
    N_honest = 0;
    for(long long int i = 0; i < N; i++){
      table[i] = (S>>i) & 1;
      if(table[i])N_honest++;
    }
    // check validity of honest people
    flag = 1;
    for(long long int i = 0; i < N; i++){
      if(table[i]){
        for(long long int j = 0; j < A[i]; j++){
          if(table[x[i][j]] != y[i][j]){
            flag = 0;
            break;
          }
        }
      }
    }

    // update answer
    if(flag){
      ans = std::max(ans, N_honest);
    }
  }

  std::cerr << "Answer: " << std::endl;
  std::cout << ans << std::endl;

  return 0;
}


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

static const int MAX = 500;
int c[MAX], s[MAX], f[MAX];

int main(){
    int n;
    cin >> n;
    for(int i = 0; i < n-1; i++){
        cin >> c[i] >> s[i] >> f[i];
    }
    for(int i = 0; i < n-1; i++){
        int t = s[i] + c[i];
        for(int j = i+1; j < n-1; j++){
            if(t >= s[j]){
                t = (t + f[j] - 1) / f[j] * f[j];
            } else {
                t = s[j];
            }
            t += c[j];
        }
        cout << t << endl;
    }
    cout << 0 << endl;
    return 0;
}

Measured memory_bytes: 256
/*suri_kumkaran*/

#include <bits/stdc++.h>

using namespace std;

#define UB upper_bound
#define LB lower_bound
#define BS binary_search
#define MP make_pair
#define EB emplace_back
#define endl "\n"
#define PI 3.1415926535897932384626433832795
#define MOD 1000000007
#define F first
#define S second
#define ALL(a) (a).begin(),(a).end()
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0)

typedef long long int int64;
typedef vector<int64> VI64;
typedef vector<pair<int64,int64>> VII64;
typedef vector<string> VS;
typedef vector<vector<int64>> VVI;

int main()
{
    IOS;
    int64 T=1;
    //cin>>T;
    while(T--)
    {
        int64 n,i;
        cin>>n;
        int64 a[n][3];
        int64 dp[n][3];
        cin>>a[0][0]>>a[0][1]>>a[0][2];
        dp[0][0]=a[0][0];
        dp[0][1]=a[0][1];
        dp[0][2]=a[0][2];
        for(i=1;i<n;i++)
        {
            cin>>a[i][0]>>a[i][1]>>a[i][2];
            dp[i][0]=a[i][0]+max(dp[i-1][1],dp[i-1][2]);
            dp[i][1]=a[i][1]+max(dp[i-1][0],dp[i-1][2]);
            dp[i][2]=a[i][2]+max(dp[i-1][0],dp[i-1][1]);
        }
        cout<<max({dp[n-1][0],dp[n-1][1],dp[n-1][2]});
    }

    return 0;
}

Measured memory_bytes: 4992
#include <bits/stdc++.h>
#include <iostream>
#include <string>
#include <string.h>
#include <ctype.h>
#include <algorithm>
#include <math.h>

using namespace std;

int main() {
  int x,y,z;
  cin >> x >> y >> z;

  for(int i = 1; ; i++) { 
    if(x < ((i+1)*z + i*y)) {
      cout << i-1 << endl;
      return 0;
    }
  }
}

Measured memory_bytes: 3584
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
#define INF 100000000
#define rep(i,s,n) for (int i = (int)(s); i < (int)(n); i++)
#define mp make_pair
ll mod = 10e9+7;
ll mod2 = 998244353;

struct edge {int to, cost;};
vector<edge> G[100010];
vector<int> ans(100010,-1);

int dfs(int v,int d){
    if (ans[v]!=-1) return 0;
    ans[v] = d%2;
    for (auto e:G[v]){
        dfs(e.to,e.cost+d);
    }
}

int main(){
    int n;cin>>n;
    rep(i,0,n-1){
        int u,v,w;cin>>u>>v>>w;
        edge x = {u-1,w%2};
        edge y = {v-1,w%2};
        G[u-1].push_back(y);
        G[v-1].push_back(x);
    }
    dfs(0,0);
    rep(i,0,n){
        cout<<ans[i]<<endl;
    }
}

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

const int INF = 1145141919;

int D, G;
vector<int> P, C;

int solve(int S){
    int sum = 0;
    int count = 0;
    int mi = -1;
    for(int i=0; i<D; i++){
        if((S>>i)&1){
            sum += P[i]*(i+1) + C[i];
            count += P[i];
        }else{
            mi = i;
        }
    }
    if(G <= sum)
        return count;
    if(G <= (P[mi]-1)*(mi+1) + sum){
        return (G - sum + mi) / (mi+1) + count;
    }else{
        return INF;
    }
}

int main(){
    cin >> D >> G;
    G /= 100;
    P.resize(D); C.resize(D);
    for(int i=0; i<D; i++){
        cin >> P[i] >> C[i];
        C[i] /= 100;
    }
    
    int ans = INF;
    for(int s=0; s<1<<D; s++){
        ans = min(ans, solve(s));
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
int main() {
  int A,B,C;
  cin >>A>>B>>C;
  if(A<=C&&C<=B)puts("Yes");
  else puts("No");

  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
const long long int mod = 1000000007;



int main() {
    int N;
	cin >> N;
    vector<int>U(N+1);
	for (size_t i = 1; i <= N; i++)
	{
		cin >> U.at(i);
	}
	int now = 1,past=0;
	for (size_t i = 0; i <= N+1; i++)
	{
		
		if (now == 2) { cout << i; return 0; }
		now = U.at(now);
	}
	cout << -1;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
string str,now,last;
int ans = 1;
int main() {
	cin >> str;
	last = str[0];
	for (size_t i = 1;i < str.size();i++) {
		now += str[i];
		if (now == last) continue;
		last = now;
		now = "";
		ans++;
	}
	printf("%d",ans);
	return 0;
}

Measured memory_bytes: 640
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		try (Scanner sc = new Scanner(System.in)) {
			int n = sc.nextInt();
			long k = sc.nextLong();
			int q = sc.nextInt();

			int[] narr = new int[n];
			for (int i = 0; i < q; i++) {
				narr[sc.nextInt() - 1]++;
			}

			for (int i : narr) {
				if (k - (q - i) <= 0) {
					System.out.println("No");
				} else {
					System.out.println("Yes");
				}
			}
		}
	}
}


Measured memory_bytes: 55396
#include <bits/stdc++.h>
#define MAX_N 110000
using namespace std;
using ll = long long;
int main() {
    int q;
    cin >> q;
    vector<int> nums;
    vector<bool> is_prime(MAX_N, true);
    is_prime[0] = is_prime[1] = false;
    for (ll i = 2; i < MAX_N; i++) {
        if (!is_prime[i]) continue;
        if (is_prime[(i+1)/2] && i % 2 == 1) nums.push_back(i);
        for (ll j = i * i; j < MAX_N; j += i) {
            is_prime[j] = false;
        }
    }
    for (int i = 0; i < q; i++) {
        int l, r;
        cin >> l >> r;
        auto ans = upper_bound(nums.begin(), nums.end(), r) - lower_bound(nums.begin(), nums.end(), l);
        cout << ans << endl;
    }
    return 0;
}

Measured memory_bytes: 3612
//
// Created by kuribohkute on 20/04/2019.
//
#include <algorithm>
#include <iostream>
#include <cstring>
#include <vector>
#include <map>
using namespace std;
#define mp make_pair
#define X first
#define Y second
#define CL(x) (x << 1)
#define CR(x) (CL(x) + 1)
const int N = 100005;
int n, m;
long long a[N];
const long long oo = 1ll * N * 1003 * 1003 * 1003;

struct Segtree {
    long long it[4 * N], lz[4 * N];
    int L[4 * N], H[4 * N];
    void build(int x, int l, int h) {
        L[x] = l;
        H[x] = h;
        lz[x] = oo;
        if (l == h) {
            it[x] = a[l];
            return;
        }
        int mid = (l + h) / 2;
        build (CL(x), l, mid);
        build (CR(x), mid + 1, h);
        it[x] = min(it[CL(x)], it[CR(x)]);
    }
    void down(int x) {
        it[CL(x)] = min(it[CL(x)], lz[x]);
        it[CR(x)] = min(it[CR(x)], lz[x]);
        lz[CL(x)] = min(lz[CL(x)], lz[x]);
        lz[CR(x)] = min(lz[CR(x)], lz[x]);
        lz[x] = oo;
    }
    void update(int x, int u, int v, long long val) {
        if (L[x] > v || H[x] < u) {
            return;
        }
        if (u <= L[x] && H[x] <= v) {
            it[x] = min(it[x], val);
            lz[x] = min(lz[x], val);
//            lz[x] = val;
            return;
        }
        if (lz[x] != oo) {
            down(x);
        }
        update(CL(x), u, v, val);
        update(CR(x), u, v, val);
        it[x] = min(it[CL(x)], it[CR(x)]);
    }
    long long get(int x, int u, int v) {
        if (L[x] > v || H[x] < u) {
            return oo;
        }
        if (u <= L[x] && H[x] <= v) {
            return it[x];
        }
        if (lz[x] != oo) {
            down(x);
        }
        return min(get(CL(x), u, v), get(CR(x), u, v));
    }
} IT;

struct Segs {
    int l, r, c;
    Segs(int _l, int _r, int _c) {
        l = _l;
        r = _r;
        c = _c;
    }
    bool operator < (Segs x) {
        return r < x.r || (r == x.r && l < x.l);
    }
};
vector <Segs> segs;

int main () {
    cin >> n >> m;
    for (int i = 1; i <= n; i++) {
        a[i] = oo;
    }
    a[1] = 0;
    IT.build(1, 1, n);
    for (int i = 0; i < m; i++) {
        int l, r, c;
        cin >> l >> r >> c;
        segs.emplace_back(Segs(l, r, c));
    }
    sort(segs.begin(), segs.end());
    for (auto seg: segs) {
        long long mn = IT.get(1, seg.l, seg.r - 1);

        IT.update(1, seg.l + 1, seg.r, mn + seg.c);
//        if (seg.l == 6 && seg.r == 10) {
//            cout << mn << " " << seg.c<< " Gs\n";
//            cout << IT.get(1, n, n) << " fdsgf\n";
//        }
    }
//    for (int i = 1; i <= n; i++) {cout << IT.get(1, i, i) << " ";}cout << "\n";
    long long res = IT.get(1, n, n);
    if (res == oo) {
        cout << -1;
    } else {
        cout << res;
    }
    return 0;
}


Measured memory_bytes: 11512
#include <bits/stdc++.h>
using namespace std;
int main(){
  int a,b;
  cin>>a>>b;
  
  int res=0;
  for(int i=a;i<=b;i++){
    int s = i % 10 , t = i / 10000 % 10;
    int u = i / 10 % 10 , v = i / 1000 % 10; 
    
    if(s==t&&u==v)++res;
  }
  cout<<res<<endl;
}

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

int main() 
{
    int N; cin >> N;
    vector<vector<pair<int,bool>>> T(N);
    for(int i=0;i<N;i++)
    {
        int A; cin >> A;
        while(A--) 
		{
            int x, y;
            cin >> x >> y;
            T[i].emplace_back(--x, y);
        }
    }
    int ans = 0;
    for(int mask=0;mask<(1<<N);mask++)
    {
        bool ok = true;
        for(int i=0;i<N;i++)
		{
            if(mask&(1<<i))
			{
                for(auto &t:T[i])
				{
                    bool s=mask&(1<<t.first);
                    if(t.second^s) ok=false;
                }
            }
        }
        if(ok) ans=max(ans,__builtin_popcount(mask));
    }
    cout<<ans<<'\n';
    return 0;
}

Measured memory_bytes: 256
use std::io::*;
use std::str::FromStr;

/* 
The read function reads a string according to each one. 
*/
fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char) 
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}

//main function
fn main() {
    let x: i32 = read();
    if x < 1200 {
	println!("ABC");
    }else{
	println!("ARC");
    }
}


Measured memory_bytes: 4476
#include <bits/stdc++.h>
#define be(v) (v).begin(),(v).end()
#define pb(q) push_back(q)
typedef long long ll;
using namespace std;
const ll mod=1000000007;

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    bitset<4000001> bit(1);
    ll n,a,sum=0;
    cin>>n;
    for(ll i=0;i<n;i++){
        cin>>a;
        bit|=(bit<<a);
        sum+=a;
    }
    for(ll i=(sum+1)/2;;i++){
        if(bit[i]==1){
            cout << i<<endl;
            return 0;
        }
    }
    return 0;
}


Measured memory_bytes: 1792
#include <iostream>
#include <assert.h>
#include <vector>
#include <unordered_map>
#include <queue>
#include <climits>
#include <cmath>
#include <algorithm>
using namespace std;
constexpr int64_t MOD = 1e9 + 7;

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

  string N;
  cin >> N;
  uint32_t s = N.size();
  int32_t res = 0;
  bool c = false;
  for (int32_t i = s - 1; i >= 0; i--) {
    int dig = N[i] - '0';
    if (c == true) dig++;
    if (dig > 5) {
      c = true;
      res += 10 - dig;
    } else if (dig == 5) {
      res += 5;
      int32_t next;
      if (i == 0) {
        next = 0;
      } else {
        next = N[i-1] - '0';
      }
      if (next >= 5) {
        c = true;
      } else {
        c = false;
      }
    } else {
      c = false;
      res += dig;
    }
  }
  if (c == true) {
    res++;
  }
  cout << res << endl;
  return 0;
}


Measured memory_bytes: 1948
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#include <iostream>
#include <string>
#include <algorithm>
#include <set>
#include <cmath>
#include <vector>
using namespace std;

vector<int> v;

void numbadd(int x,set<int> s,int n){
    if(x > (int)pow(10,n-1)){
        v.push_back(x);
    }
    else{
        for(auto m:s){
        auto scopy = s;
            scopy.erase(m);
            numbadd(x*10+m,scopy,n);
        }
    }
}

int main(){
    int n;
    int p=0;
    int q=0;
    int pnum,qnum;
    set<int> ss;
    cin >>n;
    rep(i,n){
        ss.insert(i+1);
    }
    rep(i,n){
        int a;
        cin >> a;
        p = p*10+a;
    }
    rep(i,n){
        int a;
        cin >> a;
        q = q*10+a;
    }
    numbadd(0,ss,n);
    sort(v.begin(),v.end());
    rep(i,v.size()){

        
        if(p == v[i]){
            pnum = i;
        } 
        if(q == v[i]){
            qnum =i;
        }
    }
    cout << abs(qnum-pnum) << endl;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vll = vector<ll>;
using vvll = vector<vll>;
using vc = vector<char>;
using vvc = vector<vc>;
using pll = pair<ll, ll>;
using vpll = vector<pll>;
const ll INF = 1LL << 60;
const ll MOD = 1e9 + 7;
#define rep(i, n) for (ll i = 0; i < (n); i++)
#define debug(x) cerr << #x << ": " << x << endl;
template<typename T1,typename T2> inline void chmin(T1 &a,T2 b){if(a>b) a=b;}
template<typename T1,typename T2> inline void chmax(T1 &a,T2 b){if(a<b) a=b;}

int main() {
    ll k, a, b;
    cin >> k >> a >> b;
    bool ok = false;
    for(ll i = a; i <= b; i++) {
        if(i % k == 0) ok = true;
    }
    if(ok) cout << "OK" << endl;
    else cout << "NG" << endl;
}

Measured memory_bytes: 3644
#include <iostream>
#include <iomanip>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <algorithm>
#include <math.h>
#include <sstream>
#include <numeric>
#include <string>
#include <cassert>
#include <bitset>

using namespace std;
typedef long long ll;

int main() {
  int N;
  cin >> N;
  string S = to_string(N);
  for (int i = 0; i < 3; ++i) {
    if (S[i] == '7') {
      cout << "Yes" << endl;
      return 0;
    }
  }
  cout << "No" << endl;
  return 0;
}


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

#define ll long long

using namespace std;

int
main(void){
	int n; cin >> n;
	vector<ll> vec(n);
	for(int i = 0; i < n; i++) cin >> vec[i];
	for(int i = 1; i < n; i++) vec[i] += vec[i - 1];
	ll ans = INT_MAX;
	for(int i = 0; i < n - 1; i++){
		ans = min(ans, (ll)fabs((vec[n - 1] - vec[i]) - vec[i]));
	}
	cout << ans;
} 

Measured memory_bytes: 1792
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int K = sc.nextInt();
		sc.close();
		System.out.println(N >= 10 ? K : K+(100*(10-N)));
	}
}

Measured memory_bytes: 21844
#include <iostream>
#include <string>
#include <cstdlib>
#include <vector>
#include <array>
#include <map>
#include <algorithm>
#include <queue>
#include <stack>
#include <cmath>

using namespace std;
typedef long long int ll;

int main(int argc, char const *argv[])
{
	ll n, k;
	string s;
	cin >> n;
	cin >> s;
	cin >> k;

	for (ll i = 0; i < s.size(); i++)
	{
		if(s[i]!=s[k-1]){
			s[i] = '*';
		}
	}

	cout << s << endl;
}

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

const int MOD = 1000000007;

//long long
using ll = long long;

//出力系
#define print(x) cout << x << endl
#define yes cout << "Yes" << endl
#define YES cout << "YES" << endl
#define no cout << "No" << endl
#define NO cout << "NO" << endl
 
// begin() end()
#define all(x) (x).begin(),(x).end()

//for
#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)

//最大公約数 
unsigned gcd(unsigned a, unsigned b) {
  if(a < b) return gcd(b, a);
  unsigned r;
  while ((r=a%b)) {
    a = b;
    b = r;
  }
  return b;
}

// 最小公倍数
unsigned lcm(unsigned a, unsigned b){
    return a / gcd(a, b) * b; 
}

int main(){
int N;
cin >> N;
string A, B, C;
cin >> A >> B >> C;
int cnt = 0;
REP(i, N){
    if(A[i] != B[i] && A[i] != C[i] && B[i] != C[i]) cnt += 2;
    if(A[i] == B[i] && B[i] != C[i]) cnt++;
    if(A[i] == C[i] && B[i] != C[i]) cnt++;
    if(B[i] == C[i] && B[i] != A[i]) cnt++;
}
print(cnt);
}



Measured memory_bytes: 256
def bfs():
   while len(que)>0:
      now=que.popleft()
      now_step=steps[now[0]][now[1]]
      for dy,dx in (-1,0),(1,0),(0,-1),(0,1):
         ny=now[0]+dy
         nx=now[1]+dx
         if 0<=ny<=H-1 and 0<=nx<=W-1:
            if maze[ny][nx]==".":
               maze[ny][nx]="#"
               que.append([ny,nx])
               steps[ny][nx]=now_step+1

from collections import deque

H,W=map(int,input().split())
maze=[]
for i in range(H):
   A=input()
   A=[c for c in A]
   maze.append(A)

steps=[[-1]*W for i in range(H)]
que=deque([])
for i in range(H):
   for j in range(W):
      if maze[i][j]=="#":
         que.append([i,j])
         steps[i][j]=0

bfs()

max_step=0
for i in range(H):
   for j in range(W):
      max_step=max(max_step,steps[i][j])

print(max_step)

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

namespace ITP1_4A
{
    class Program
    {
        static void Main(string[] args)
        {
            string[] inString = Console.ReadLine().Split(' ');
            int intA = int.Parse(inString[0]);
            int intB = int.Parse(inString[1]);

            int intD = intA / intB;
            int intR = intA % intB;
            double doubleF = (double)intA / (double)intB;

            //Console.WriteLine(intD + " " + intR + " " + floatF.ToString("F5"));
            //Console.WriteLine(intD + " " +  intR + " " + floatF.ToString("0.00000"));
            Console.WriteLine(intD + " " + intR + " " + doubleF.ToString("0.0000000000"));
            //    Math.Round(doubleF, 5, MidpointRounding.AwayFromZero));
        }
    }
}

Measured memory_bytes: 9328
class DictNode
	def initialize(parent = nil, character = nil)
		@length = (parent ? parent.length + 1 : 0)
		@parent = parent
		@character = character
		@children = {}
	end

	def child(c)
		@children[c]
	end

	def add_child(c)
		@children[c] = self.class.new(self, c)
	end

	def to_s
		return "" if !@parent
		@parent.to_s + @character
	end

	attr_reader :length
end

loop do
	h, w = gets.split.map(&:to_i)
	break if w == 0
	donut = (1..h).map { gets.chomp.split("") }
	dict = DictNode.new
	spell = ''
	len = 0

	(0..h-1).each do |i0|
		(0..w-1).each do |j0|
			[-1, 0, 1].repeated_permutation(2) do |di, dj|
				next if di == dj && di == 0
				u = dict
				i, j = i0, j0
				loop do
					c = donut[i][j]
					if v = u.child(c)
						if v.length > len
							spell = v.to_s
							len = v.length
						elsif v.length == len
							s = v.to_s
							if s < spell
								spell = s
								len = v.length
							end
						end
					else
						u.add_child(c)
					end
					u = u.child(c)
					i = (i + di) % h
					j = (j + dj) % w
					break if i == i0 && j == j0
				end
			end
		end
	end
	puts spell.size > 1 ? spell : 0
end

Measured memory_bytes: 194672
function C167(_input) {
    var lines = _input.split("\n");
    var first = lines.shift().split(' ').map(v => v*1);
    var sankonum = first[0];
    var algoNum = first[1];
    var score = first[2];
    // var power = Array(algoNum).fill(0);
    var price = 0;

    var cost = []; // c0 = 0番目のコスト
    var power = []; // p00 = 本0の0の理解度、p01 = 本0の1の理解度

    for (var i = 0; i < sankonum; i++) {
        var item = lines.shift().split(' ').map(v => v*1);

        cost[i] = item.shift();
        power[i] = item;
    }

    var answer = 100000000000;
    for (var i = 0; i < (1<<sankonum); i++) {
        // 0, 1, 0, 0, 0, 1のようなパターン
        var price = 0;
        var d = Array(algoNum).fill(0);
        for (var j = 0; j < sankonum; j++) {
            if (i>>j&1 === 1) {
                price += cost[j];

                for (var k = 0; k < algoNum; k++) {
                    d[k] += power[j][k];
                }
            }
        }
        var test = d.some((v) => v < score);
        if (!test) {
            answer = Math.min(answer, price);
        }
    }

    if (answer === 100000000000) {
        console.log(-1);
        return;
    }

    console.log(answer);
}
C167(require("fs").readFileSync("/dev/stdin", "utf8"));


Measured memory_bytes: 33348
#include <iostream>
#include <algorithm>
#include <functional>
#include <string>
#include <vector>
using namespace std;
#define MAXSIZE 200
#define MAXL 100
typedef long long int lli;

int get_abs(int x);

int main(){
    int a, b, c;
    cin >> a >> b >> c;

    bool able = false;
    for(int i = 1; i <= b; i++){
        if(i * a % b == c){
            able = true;
            break;
        }
    }
    
    string ans = (able)? "YES" : "NO";
    cout << ans << endl;
    return 0;
}

int get_abs(int x){
    return (x > 0)? x : -x;
}

Measured memory_bytes: 256
N, K = map(int, input().split())
h = [0] * N
for i in range(N):
    h[i] = int(input())
h = sorted(h, reverse=True)

ans = float("inf")
for i in range(N - K + 1):
    ans = min(ans, h[i] - h[i + K - 1])
print(ans)

Measured memory_bytes: 8240
object Main {
  def main(args: Array[String]): Unit = {
    import scala.io.StdIn.readLine
    val Array(datN) = readLine.split(" ").map(_.toInt)
    val datA = readLine.split(" ").map(_.toInt)

    val ans = ((datA.map(_ % 2).sum % 2) != 1) || (datN == 1)
    println(if(ans) "YES" else "NO")
  }
}


Measured memory_bytes: 42472
main = interact $ sol . last . lines

sol s = (replicate (m-b) '(') ++ s ++ (replicate m ')')
  where (b,m) = foldr f (0,0) s

f '(' (b,m) = (b+1,max m (b+1))
f ')' (b,m) = (b-1,m)

Measured memory_bytes: 508
/**
 *      ABC 45 B
 *      author  : kyomukyomupurin
 *      created : 2018-09-21 01:36:19
**/

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

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    
    string SA, SB, SC; cin >> SA >> SB >> SC;
    int sizeA = SA.size(); int sizeB = SB.size(); int sizeC = SC.size();
    int countA = 0; int countB = 0; int countC = 0;
    char turn = 'A';

    while (1){
        if (turn == 'A'){
            ++countA;
            if (countA > sizeA){
                cout << 'A' << endl; return 0;
            }
            if (SA[countA - 1] == 'a'){
                turn = 'A';
            }
            else if (SA[countA - 1] == 'b'){
                turn = 'B';
            }
            else if (SA[countA - 1] == 'c'){
                turn = 'C';
            }
        }
        else if (turn == 'B'){
            ++countB;
            if (countB > sizeB){
                cout << 'B' << endl; return 0;
            }        
            if (SB[countB - 1] == 'a'){
                turn = 'A';
            }
            else if (SB[countB - 1] == 'b'){
                turn = 'B';
            }
            else if (SB[countB - 1] == 'c'){
                turn = 'C';
            }
        }
        else if (turn == 'C'){
            ++countC;
            if (countC > sizeC){
                cout << 'C' << endl; return 0;
            }        
            if (SC[countC - 1] == 'a'){
                turn = 'A';
            }
            else if (SC[countC - 1] == 'b'){
                turn = 'B';
            }
            else if (SC[countC - 1] == 'c'){
                turn = 'C';
            }
        }
    }
}

Measured memory_bytes: 256
#include<cstdio>
using namespace std;
inline int abs(int x){
	return x<0?-x:x;
}
inline int max(int x,int y){
	return x>y?x:y;
}
int n,a,b,c;
int x[113],y[113],h[113];
int main(){
	scanf("%d",&n);
	for(register int i=0;i<n;++i)
		scanf("%d%d%d",x+i,y+i,h+i);
	for(a=0;a<=100;++a){
		for(b=0;b<=100;++b){
			c=h[0]+abs(a-x[0])+abs(b-y[0]);
			for(register int i=1;i<n;++i)
				if(c>(h[i]+abs(a-x[i])+abs(b-y[i])))
					c=h[i]+abs(a-x[i])+abs(b-y[i]);
			for(register int i=0;i<n;++i)
				if(h[i]!=max(0,c-abs(a-x[i])-abs(b-y[i]))){
					c=-1;break;
				} 
			if(c==-1)continue;
			printf("%d %d %d",a,b,c);
			return 0;
		}
	}
	return 0;
} 

Measured memory_bytes: 128
text = input()
a = text[:2]
b = text[2:]
m = ['01', '02', '03', '04', '05', '06', '07', '08', '09', '10', '11', '12']
if a in m:
    if b in m:
        print('AMBIGUOUS')
    else:
        print('MMYY')
else:
    if b in m:
        print('YYMM')
    else:
        print('NA')

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

using namespace std;

int main()
{
	string a,b;
	cin >> a >> b;
	int equalFlag=1;
	int sizeA=a.length(),sizeB = b.length();
	if (sizeA>sizeB)
		cout << "GREATER";
	else if (sizeA<sizeB)
		cout << "LESS";
	else
	{

		for (int i=0;i<sizeA;i++)
		{
			if (a[i]>b[i])
			{
				equalFlag = 0;
				cout << "GREATER";
				break;
			}
			else if (a[i]<b[i])
			{
				equalFlag = 0;
				cout << "LESS";
				break;
			}
			
		}
		if (equalFlag)
			cout << "EQUAL";
	}


	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <iosfwd>
#include <iomanip>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <ctime>
#include <cmath>
#include <cassert>
#include <cctype>
#include <climits>
#include <vector>
#include <bitset>
#include <set>
#include <queue>
#include <stack>
#include <map>
#include <deque>
#include <string>
#include <list>
#include <iterator>
#include <sstream>
#include <complex>
#include <fstream>
#include <functional>
#include <numeric>
#include <utility>
#include <algorithm>
#include <assert.h>
#include <unordered_map>

using namespace std;
const int N = 1e6 + 500;
const long long mod = 1e9 + 7;
const long long INF = 1LL << 57;
const int LN = 22;

long long n, m, u, v, k, t, q, x, d, p, a, b, c, s;


int main() {
   ios::sync_with_stdio(false);cin.tie(0);
   cin >> a >> b >> c;
   a -= b;
   c -= a;
   if (c < 0) c = 0;
   cout << c << endl;
}


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

int main(){
  int a,b;
  cin>>a>>b;
  if(a>0 && b>0){
    cout<<"Positive"<<endl;
  }else if(a==0 || b==0){
    cout<<"Zero"<<endl;
  }else if((a>0 && b<0)||(a<0 && b>0)){
    cout<<"Zero"<<endl;
  }else{
    if((abs(a)-abs(b)+1)%2==0){
      cout<<"Positive"<<endl;
    }else{
      cout<<"Negative"<<endl;
    }
  }
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef vector<vector<pair<int, int> > > vvp;
typedef vector<pair<int, int> > vp;
typedef vector<vector<int> > vvi;
typedef vector<int> vi;
typedef vector<vector<ll> > vvl;
typedef vector<ll> vl;
typedef vector<vector<bool> > vvb;
typedef vector<bool> vb;
typedef vector<string> vs;
typedef pair<string, int> psi;
typedef pair<int, int> pii;
#define rep(i,s,n) for(int i = (s); i < (n); i++)
#define all(x) (x).begin(), (x).end()
#define yn(f) (f?"yes":"no")
#define YN(f) (f?"YES":"NO")
#define Yn(f) (f?"Yes":"No")
#define mod (1e9+7)
#define inf (1e9+7)
#define nil -1
ull power(int m,int n) {
	if (n == 0) {
		return 1;
	}
	else if (n==1) {
		return m;
	}
	else{
		ull res = power(m % (ull)inf * m % (ull)inf, n / 2)%(ull)inf;
		if (n%2==1) {
			res*=m;
			res %= (ull)inf;
		}
		return res;
	}

}
int main() {
	int m, n;
	cin >> m >> n;
	cout << power(m,n) << endl;
}



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

#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,n) FOR(i,0,n)
#define MAX(a, b) ((a) > (b) ? (a) : (b))
#define PB push_back
#define MP make_pair
typedef long long ll;
typedef double db;
typedef pair<int,int> pii;
const double PI=acos(-1.0);
const int INF=1e9;
const double EPS=1e-10;
const ll MOD=1e9+7;


int main(){
char b,a;
  cin>>b;
  if(b=='T')a='A';
  if(b=='A')a='T';
  if(b=='G')a='C';
  if(b=='C')a='G';
  cout<<a<<endl;
return 0;
}

Measured memory_bytes: 256
n = int(input())
a = [int(i) for i in input().split()]
l = [0] * n

cnt = 0
for i in range(1, n + 1)[::-1]:
    s = sum([l[(j + 2) * i - 1] for j in range(n // i - 1)])
    l[i - 1] = (s + a[i - 1]) % 2
    cnt += l[i - 1]

print(cnt)
ju = 0
for i, k in enumerate(l):
    if k != 0:
        if (ju == 1):
            print(" ", end="")
        if (ju == 0):
            ju = 1
        print(i + 1, end="")
if ju == 1:
    print()


Measured memory_bytes: 8784
#include<bits/stdc++.h>
using namespace std;
#define LL long long
const int N = 2e4 + 11;
const int inf = 1e9;
int head[N], to[N], nex[N], size = 1;
int dl[N], fr[N];
int n, S = 3000, T = 3001;
LL dis[N], wei[N], cst[N], ans;
bool mark[N];
void add(int x, int y, int z, int k){
	to[++size] = y; nex[size] = head[x]; head[x] = size; cst[size] = k; wei[size] = z;
	to[++size] = x; nex[size] = head[y]; head[y] = size; cst[size] = -k; wei[size] = 0;
}
void spfa(){
	int hd = 0, tl = 1;
	dl[1] = S;
	for(int i = 1;i <= T; i++)dis[i] = -1e18;
	dis[S] = 0; mark[S] = 1;
	while(hd < tl){
		int u = dl[++hd];
		for(int i = head[u];i;i = nex[i]){
			if(wei[i] <= 0)continue;
			int v = to[i];
			if(dis[v] < dis[u] + cst[i]){
				dis[v] = dis[u] + cst[i];
				fr[v] = i;
				if(!mark[v])dl[++tl] = v, mark[v] = 1;
			}
		}
		mark[u] = 0;
	}
}
void MCMF(){
	while(1){
		spfa();
		LL ma = dis[T]; 
		if(ma == -1e18)return ;
		LL flow = 1e9;		
//		printf("ma=%lld ans=%lld\n", ma, ans);
		for(int u = T;u != S;u = to[fr[u]^1])flow = min(flow, wei[fr[u]]);
		ans += flow * ma;
		for(int u = T;u != S;u = to[fr[u]^1])wei[fr[u]] -= flow, wei[fr[u]^1] += flow;
	}
}
int main(){
	cin>>n;
	int x, y, w;
	for(int i = 1;i <= n; i++){
		scanf("%d%d%d", &x, &y, &w);
		add(S, i, w, 0);
		add(i, 2 * n + 1, inf, x + y);
		add(i, 2 * n + 2, inf, x - y);
		add(i, 2 * n + 3, inf, -x + y);
		add(i, 2 * n + 4, inf, -x - y);
	}
	for(int i = 1;i <= n; i++){
		scanf("%d%d%d", &x, &y, &w);
		add(i + n, T, w, 0);
		add(2 * n + 1, i + n, inf, -x - y);
		add(2 * n + 2, i + n, inf, -x + y);
		add(2 * n + 3, i + n, inf, x - y);
		add(2 * n + 4, i + n, inf, x + y);
	}
	MCMF();
	printf("%lld\n", ans);
	return 0;
}

Measured memory_bytes: 768
#include <cstdint>
#include <iostream>
#include <vector>

using namespace std;

constexpr int64_t kMod = 1e9+7;

int main() {
  int64_t N;
  cin >> N;
  
  int64_t full = 1;
  int64_t non = 1;
  int64_t both = 1;
  for (int64_t n = 0; n < N; ++n) {
    full *= 10; full %= kMod;
    non *= 9; non %= kMod;
    both *= 8; both %= kMod;
  }
  int64_t res = full - non - non + both;
  res %= kMod;
  res += kMod; res %= kMod;
  cout << res << endl;

  return 0;
}


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

int main(int argc, char const *argv[])
{
    /* code */
    int N;
    scanf("%d", &N);
    int result = 0;
    if(N % 2 == 0)
    {
        result = N / 2;
    }
    else
    {
        result = N / 2 + 1;
    }
    printf("%d", result);
    return (0);
}

Measured memory_bytes: 128
#include "iostream"
#include "climits"
#include "list"
#include "queue"
#include "stack"
#include "set"
#include "functional"
#include "algorithm"
#include "string"
#include "map"
#include "unordered_map"
#include "iomanip"
#include "cmath"

using namespace std;

const long long int MOD = 1000000007;

long long int N, M, K, H, W, L, R;

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	cin >> W >> H;
	while (H) {
		vector<vector<int>>edge(H*W);
		vector<int>dis(H*W, INT_MAX);
		dis[0] = 0;
		string s;
		getline(cin, s);
		for (int i = 0; i < H * 2 - 1; i++) {
			getline(cin, s);
			if (i % 2) {
				for (int j = 0; j < W*2-1; j += 2) {
					if (s[j] == '0') {
						//cout << (i / 2)*W + j / 2 << " " << (i / 2 + 1)*W + j / 2 << endl;
						edge[(i / 2)*W + j / 2].push_back((i / 2 + 1)*W + j / 2);
						edge[(i / 2 + 1)*W + j / 2].push_back((i / 2)*W + j / 2);
					}
				}
			}
			else {
				for (int j = 1; j < W*2-1; j += 2) {
					if (s[j] == '0') {
						//cout << (i / 2)*W + j / 2 << " " << (i / 2)*W + j / 2 + 1 << endl;
						edge[(i / 2)*W + j / 2].push_back((i / 2)*W + j / 2 + 1);
						edge[(i / 2)*W + j / 2 + 1].push_back((i / 2)*W + j / 2);
					}
				}
			}
		}
		queue<int>Q;
		Q.push(0);
		while (!Q.empty()) {
			int cn = Q.front();
			//cout << cn << endl;
			Q.pop();
			for (auto i : edge[cn]) {
				//cout << " " << i << endl;
				if (dis[i] > dis[cn] + 1) {
					dis[i] = dis[cn] + 1;
					Q.push(i);
				}
			}
		}
		if (dis[H*W - 1] == INT_MAX) {
			cout << 0 << endl;
		}
		else {
			cout << dis[H*W - 1] + 1 << endl;
		}
		cin >> W >> H;
	}
	return 0;
}

Measured memory_bytes: 3140
from heapq import heappush,heappop

def int_raw():
    return int(input())

def ss_raw():
    return input().split()

def ints_raw():
    return list(map(int, ss_raw()))


N, K = ints_raw()
S = input()
cts = []
ctree = {}



def main():
    ans = 0
    kukan = 1
    start = 0
    if S[0]=="0":
        cts.append(["1",0,0])
    for i in range(1,len(S)):
        if S[i-1]!=S[i]:
            cts.append([S[i-1],kukan,start])
            start = i
            kukan=0
        kukan+=1
    cts.append([S[-1],kukan,start])
    if S[-1]=="0":
        cts.append(["1",0, N-1])
    if K*2+1 >= len(cts):
        return N
    buf = sum([cts[i][1] for i in range(K*2+1)])
    ans = buf
    for i in range(K*2+1,len(cts)):
        n_buf = buf-cts[i-(K*2+1)][1]+cts[i][1]
        if cts[i][0]=="1":
            ans =max(ans,n_buf)
        buf = n_buf
    return ans

print(main())



Measured memory_bytes: 16916
#include<stdio.h>

int main()
{
  int matrix[100][100];
  int n;
  int i=0,j=0;
  int k=0;
  int num;
  int array[100];

  for(i=0;i<100;i++)
    {
      for(j=0;j<100;j++)
	{
	  matrix[i][j] = 0;
	}
    }

  scanf("%d",&n);

  for(i=0;i<n;i++)
    {
      scanf("%d",&array[i]);
      scanf("%d",&k);
      for(j=0;j<k;j++)
	{
	  scanf("%d",&num);
	  matrix[i][num-1] = 1;
	}
    }
  for(i=0;i<n;i++)
    {
      for(j=0;j<n;j++)
	{
	  printf("%d",matrix[i][j]);
	  if(j!=n-1)
	    {
	      printf(" ");
	    }
	  else
	    {
	      printf("\n");
	    }
	}
    }


  return 0;
}

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

int main() {
  string S;
  cin >> S;
  int i=0,j=0;
  for(;i<3;i++){
    if(S.at(i)=='a'){
      j++;
    }else if(S.at(i)=='b'){
      j+=10;
    }else{
      j+=100;
    }
  }
  if(j==111){
    cout << "Yes" << endl;
  }else{
    cout << "No" << endl;
  }
}



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

int Range = 10;

int main(void) {
    int n, count;
    
    while(cin >> n) {
        count = 0;
        for(int a = 0; a < Range; a++) {
            for(int b = 0; b < Range; b++) {
                for(int c = 0; c < Range; c++) {
                    for(int d = 0; d < Range; d++) {
                        if((a + b + c + d) == n) {
                            count++;
                        }
                    }
                }
            }
        }
        cout << count << endl;
    }
}


Measured memory_bytes: 3104
#include <bits/stdc++.h>
#define rep(i, a, b) for(int i = a; i < b; i++)
#define Rep(i, a, b) for(int i = a; i <= b; i++)
#define _GLIBCXX_DEBUG
#define Vl vector<ll>
#define Vs vector<string>
#define Vp vector<pair<ll, ll>>
#define ll long long
#define ALL(v) (v).begin(),(v).end()
#define endl "\n"
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
#define co(x) cout << x << endl;
using namespace std;  
const double pi = acos(-1.0);
const ll MOD = 1e9 + 7;
const ll INF = 1LL << 60;



int main() {
  ll n; cin >> n;
  Vl a(n), b(n);
  ll sum_a = 0, sum_b = 0;
  ll ans = 0;
  rep(i, 0, n){
    cin >> a[i];
    sum_a += a[i];
  } 
  rep(i, 0, n){
    cin >> b[i];  
    sum_b += b[i];
  }
  if(sum_a < sum_b){
    cout << -1 << endl;
    return 0;
  }

  Vl v = {}; ll need = 0;
  rep(i, 0, n){
    if(a[i] < b[i]){ 
      ans++;
      need += b[i]-a[i];
    }
    if(a[i] > b[i]) v.push_back(a[i]-b[i]);
  }
  sort(ALL(v), greater<ll>());
  rep(i, 0, v.size()){
    if(need <= 0) break;
    ans++;
    need -= v[i];
  }
  cout << ans << endl;


  return 0;
}

Measured memory_bytes: 2428
#include <cstdio>
#include <algorithm>
#include <vector>

int main() {
    std::vector<int> v;
    int a, b, k;
    scanf("%d %d %d", &a, &b, &k);
    int bigger = (a > b) ? a : b;
    int smaller = (b >= a) ? a : b;
    for (int i = 1; i <= smaller; i++) {
        if (smaller % i == 0) {
            v.push_back(i);
        }
    }
    int count = 1;
    std::reverse(v.begin(), v.end());
    for (int tmp : v) {
        if (bigger % tmp == 0) {
            if (count == k) {
                std::printf("%d\n", tmp);
                return 0;
            }
            count++;
        }
    }
}


Measured memory_bytes: 256
import collections
def main():

    N, C = map(int, input().split())
    d = collections.defaultdict(list)

    for _ in range(N):
        s, t, c  = map(int, input().split())
        d[c].append([s, t])

    for c in d:
        d[c].sort()
        lv = []
        for i in range(len(d[c])):
            if i == 0:
                lv.append(d[c][i])
            else:
                if lv[-1][1] == d[c][i][0]:
                    lv[-1][1] = d[c][i][1]
                else:
                    lv.append(d[c][i])
        d[c] = lv

    # print(d)
    index = dict()
    for c in d: index[c] = 0
    bound = max([d[c][-1][1] for c in d])
    ans = 0
    for i in range(1, bound + 1):
        cnt = 0
        for c in d:
            while index[c] < len(d[c]) and d[c][index[c]][1] < i:
                index[c] += 1
            if index[c] < len(d[c]) and d[c][index[c]][0] <= i <= d[c][index[c]][1]:
                cnt += 1
        # print(i, cnt)
        ans = max(ans, cnt)
    return ans


if __name__ == '__main__':
    print(main())

Measured memory_bytes: 63832
#include <bits/stdc++.h>
using namespace std;
int main()
{
    int n;
    cin>>n;
    int a,b;
    a>0;
    b>0;
    int tuple{0};
    for(int i{1};i<n;i++)
        {   b=i;
            //cout<<b<<'\n';
            for(int x{1};x<n;x++)
                {
                    a=x;
                    //cout<<a<<'\n';
                    if(a*b>=n)
                    {
                        break;
                    }
                    if(a=b)
                    {
                        tuple++;
                    }
                    else
                    {
                        tuple=tuple+2;
                    }

                }
        }
        cout<<tuple;

}


Measured memory_bytes: 3636
#include <bits/stdc++.h>
#define ALL(a)  (a).begin(),(a).end()
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
typedef pair<long long, long long> Pll;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<long long> vll;
typedef vector<vector<long long>> vvll;
template <typename T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template <typename T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
const long long INF = 1LL << 60;
const int INT_INF = 1LL << 30;

bool is_OK(ll N, ll x){
  if(N == 1) return true;
  if(N < x) return false;

  if(N % x == 0) return is_OK(N/x, x);
  else if((N-1)%x != 0) return false;
  else return is_OK(N - N/x * x, x);
}

int main(){
  ll N;
  cin >> N;
  if(N == 2){
    cout << 1 << endl;
    return 0;
  }
  ll ans = 1; //Nは必ず答え

  //N-1の素因数分解
  ll tmp = 1;
  ll NN = N-1;
  for(ll i = 2; i*i <= NN; i++){
    if(NN%i) continue;
    if(NN%i == 0){
      ll counter = 0;
      while(NN%i == 0){
        NN /= i;
        counter++;
      }
      tmp *= counter + 1;
    }
  }
  if(NN != 1) tmp *= 2;
  tmp--;
  ans += tmp;

  //if(sqrt(N) * sqrt(N) == N) ans++; //平方数なら平方根は答え
  vll A(0); //平方根未満の約数
  for(ll i = 2; i*i <= N; i++){
    if(N%i == 0) A.push_back(i);
  }
  for(int i = 0; i < A.size(); i++){
    if(is_OK(N, A.at(i))) ans++;
  }
  cout << ans << endl;
}

Measured memory_bytes: 256