akhauriyash/Code-Regression huggingface dataset:
#include <algorithm>
#include <climits>
#include <cmath>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <unordered_map>
#include <vector>

const int mod = 1e9 + 7;
const int kmax = 510000;

long long fact[kmax], fact_inv[kmax], inv[kmax];

void init_comb()
{
    fact[0] = fact[1] = 1;
    fact_inv[0] = fact_inv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < kmax; i++) {
        fact[i] = fact[i - 1] * i % mod;
        inv[i] = mod - inv[mod % i] * (mod / i) % mod;
        fact_inv[i] = fact_inv[i - 1] * inv[i] % mod;
    }
}

long long comb(int n, int r)
{
    if (n < r) {
        return 0;
    }

    if (n < 0 || r < 0) {
        return 0;
    }

    return fact[n] * (fact_inv[r] * fact_inv[n - r] % mod) % mod;
}

template <typename T, T N>
class UnionFind {
    T parent_[N];
    T rank_[N];
    T size_[N];

public:
    UnionFind();
    T Root(T idx);
    bool IsSame(T x, T y);
    void Unite(T x, T y);
    T GetSize(T idx);
};

template <typename T, T N>
UnionFind<T, N>::UnionFind()
{
    for (T i = 0; i < N; i++) {
        parent_[i] = i;
        rank_[i] = 0;
        size_[i] = 1;
    }
}

template <typename T, T N>
T UnionFind<T, N>::Root(T idx)
{
    return parent_[idx] == idx ? idx : parent_[idx] = Root(parent_[idx]);
}

template <typename T, T N>
bool UnionFind<T, N>::IsSame(T x, T y)
{
    return Root(x) == Root(y);
}

template <typename T, T N>
void UnionFind<T, N>::Unite(T x, T y)
{
    x = Root(x);
    y = Root(y);
    if (x == y) {
        return;
    }

    if (rank_[x] < rank_[y]) {
        parent_[x] = y;
        size_[y] += size_[x];
    } else {
        parent_[y] = x;
        size_[x] += size_[y];
        if (rank_[x] == rank_[y]) {
            rank_[x]++;
        }
    }
}

template <typename T, T N>
T UnionFind<T, N>::GetSize(T idx)
{
    return size_[Root(idx)];
}

long long pow_mod(long long n, long long p, long long m)
{
    if (p == 0) {
        return 1;
    }

    if (p % 2 == 0) {
        long long t = pow_mod(n, p / 2, m);
        return t * t % m;
    }
    return n * pow_mod(n, p - 1, m) % mod;
}

long long nCr_mod(long long n, long long r)
{
    long long x = 1;
    for (long long i = n - r + 1; i <= n; i++) {
        x *= i;
        x %= mod;
    }

    long long a = 1;
    for (long long i = 1; i <= r; i++) {
        a *= i;
        a %= mod;
    }

    long long y = pow_mod(a, mod - 2, mod) % mod;

    return x * y % mod;
}

bool is_prime(long long n)
{
    if (n == 1) {
        return false;
    }

    for (long long i = 2; i * i <= n; i++) {
        if (n % i == 0) {
            return false;
        }
    }

    return true;
}

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

    for (int i = 0; i < s.size(); i++) {
        std::cout << 'x';
    }
    std::cout << std::endl;
}


Measured memory_bytes: 256
N = int(input())
R = [[int(i) for i in input().split()] for _ in range(N)]
B = [[int(i) for i in input().split()] for _ in range(N)]

R.sort()
B.sort()

count = 0
tmp = []
for bx, by in B:
    for rx, ry in R:
        if bx > rx and by > ry:
            tmp.append([rx, ry])
    if tmp != []:
        max_red = max(tmp, key=lambda r: r[1])
        count += 1
        R.remove(max_red)
        tmp = []
print(count)



Measured memory_bytes: 3188
#include<iostream>
#include<vector>
#include<algorithm>
#include<queue>
#include<stack>
#include<cstring>
#include<utility>
#include<cmath>
#include<assert.h>
#include<set>
#include<map>
#include<unordered_set>
#include<unordered_map>
#include<complex>
#include<bitset>
#include<numeric>

#define int long long
using namespace std;
#define rep(i, n) for(int i=0;i<(n);++i)
typedef pair<int, int> pii;
const int INF = 1l << 60;
#define u_b upper_bound
#define l_b lower_bound

int R, C, N;
pii XY[100100][2];
const int lef = 0, bottom = 1, righ = 2, top = 3, inner = 4;
vector<pii> side[4];

int type(pii xy) {
    int x = xy.first;
    int y = xy.second;
    if (x == 0)return lef;
    if (y == C)return bottom;
    if (x == R)return righ;
    if (y == 0)return top;
    return inner;
}

void push(int n) {
    pii a1 = XY[n][0], a2 = XY[n][1];
    int t1 = type(a1), t2 = type(a2);
    if (t1 == lef || t1 == righ) {
        side[t1].push_back(pii(a1.second, n));
    } else {
        side[t1].push_back(pii(a1.first, n));
    }
    if (t2 == lef || t2 == righ) {
        side[t2].push_back(pii(a2.second, n));
    } else {
        side[t2].push_back(pii(a2.first, n));
    }
}

signed main() {
    cin >> R >> C >> N;
    rep(i, N) {
        int x1, y1, x2, y2;
        cin >> x1 >> y1 >> x2 >> y2;
        XY[i][0] = pii(x1, y1);
        XY[i][1] = pii(x2, y2);
        if (type(XY[i][0]) != inner && type(XY[i][1]) != inner) {
            push(i);
        }
    }
    sort(side[lef].begin(), side[lef].end());
    sort(side[bottom].begin(), side[bottom].end());
    sort(side[righ].begin(), side[righ].end(), greater<pii>());
    sort(side[top].begin(), side[top].end(), greater<pii>());
    stack<int> sta;
    for (pii e:side[lef]) {
        int n = e.second;
        if (!sta.empty() && sta.top() == n)sta.pop();
        else sta.push(n);
    }
    for (pii e:side[bottom]) {
        int n = e.second;
        if (!sta.empty() && sta.top() == n)sta.pop();
        else sta.push(n);
    }
    for (pii e:side[righ]) {
        int n = e.second;
        if (!sta.empty() && sta.top() == n)sta.pop();
        else sta.push(n);
    }
    for (pii e:side[top]) {
        int n = e.second;
        if (!sta.empty() && sta.top() == n)sta.pop();
        else sta.push(n);
    }
    if (sta.empty())cout << "YES" << endl;
    else cout << "NO" << endl;
    return 0;
}


Measured memory_bytes: 8012
#include<bits/stdc++.h>
using namespace std;
int main()
{
    long long h,c,x;
    while(scanf("%lld",&h)==1){
        c=0,x=1;
        long long d=1;
        while(h){
            if(h==1){
                c++;
                h--;
            }
            else{
                h=h/2;
            if(x>0){
                    c+=2*d;
                    d++;
            x=0;
            }
            else{
            c+=2*d;
            d=2*d;
            }
            }
        }
        printf("%lld\n",c);
    }
}


Measured memory_bytes: 256
# encoding: "utf-8"

import numpy as np

class Stdin:
    @staticmethod
    def read_line(converter=str):
        return [converter(x) for x in input().split()]
    
    @staticmethod
    def read_lines(n, converter=str):
        result = list()
        for _ in range(n):
            result.append(Stdin.read_line(converter))
        return result
    
    @staticmethod
    def convert(data, converter):
        assert(len(data) == len(converter))
        return tuple(map(lambda x, f: f(x), data, converter))

    @staticmethod
    def convert_lines(datas, n, converter):
        return [converter(data, n, converter) for data in datas]


def main():
    _ = input()
    xs = Stdin.read_line(converter=int)
    ys = np.array(list(map(lambda x: [x-1, x, x+1], xs))).flatten()
    ys.sort()
    cnt = 0
    m = 0
    prev = ys[0]
    for y in ys:
        if y == prev:
            cnt += 1
        else:
            if m < cnt:
                m = cnt
            prev = y
            cnt = 1
    print(m)

if __name__ == "__main__":
    main()

Measured memory_bytes: 35576
#include <bits/stdc++.h>
using namespace std;
int64_t INF = 1000000000;

int main()
{
  int64_t H, N, a, b;
  cin >> H >> N;
  vector<int64_t> DP(20000, INF); // HPの減少に対する魔力合計の最小値
  vector<pair<int, int>> vp(N);
  for (int i = 0; i < N; i++)
  {
    cin >> a >> b;
    vp.at(i) = make_pair(a, b);
  }
  DP.at(0) = 0;
  for (int h = 1; h < DP.size(); h++)
  {
    int a = INF;
    for (int n = 0; n < N; n++)
    {
      if (h - vp.at(n).first >= 0)
      {
        if (a > DP.at(h - vp.at(n).first) + vp.at(n).second)
          a = DP.at(h - vp.at(n).first) + vp.at(n).second;
      }
    }
    DP.at(h) = a;
  }
  int64_t res = INF;
  for (int h = H; h < DP.size(); h++)
  {
    if (res > DP.at(h))
      res = DP.at(h);
  }
  cout << res << endl;
}


Measured memory_bytes: 384
N = int(input())
V = list(map(int, input().split(' ')))
C = list(map(int, input().split(' ')))

out = 0
for i in range(N):
   if int(V[i]) - int(C[i]) > 0:
       out = out + int(V[i]) - int(C[i])
print(out)

Measured memory_bytes: 3060
a,b,c = map(int,input().split())
cnt=0
for _ in range(100):
  if a%2!=0 or b%2!=0 or c%2!=0:
    print(cnt)
    exit()
  a,b,c = (b+c)/2,(c+a)/2,(a+b)/2
  cnt += 1
print(-1)

Measured memory_bytes: 3060
/* dsingh_24 */

#include<bits/stdc++.h>
#define ll          long long
#define pb          push_back
#define   endl      '\n'
#define pii         pair<ll ,ll>
#define vll          vector<ll>
#define all(a)      (a).begin(),(a).end()
#define F           first
#define S           second
#define sz(x)       (ll int)x.size()
#define hell        1000000007
#define rep(i,a,b)   for(ll int i=a;i<b;i++)
#define lbnd        lower_bound
#define ubnd        upper_bound
#define bs          binary_search
#define mp          make_pair
#define ios         ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
using namespace std;

#define MAXN  300005
 
int n, A, B, w[MAXN];
 
int main() {
		scanf("%d%d%d", &n, &A, &B);
		if(A+B>n+1) {
			puts("-1");
			return 0;
		}
		if(B==1) {
			if(A<n) {
				puts("-1");
				return 0;
			}
			for(int i = 1 ; i <= n ; ++ i) printf("%d ", i);
			return 0;
		}
		if(A==1) {
			if(B<n) {
				puts("-1");
				return 0;
			}
			for(int i = n ; i >= 1 ; -- i) printf("%d ", i);
			return 0;
		}
		if(A<B) {
			if(B<(n-A-1)/A+2) {
				puts("-1");
				return 0;
			}
			for(int i = A, j = n ; i >= 1 ; -- i, -- j) w[i] = j;
			int nw = B-1;
			int blo = (n-A)/nw, num = 0, ret = n-A-nw*blo, R = n;
			for(int i = 1, L ; i <= nw ; ++ i) {
				if(i<=ret) L = R-blo;
				else L = R-blo+1;
				for(int j = L ; j <= R ; ++ j) w[j] = ++ num;
				R = L-1;
			}
		} else {
			if(A<(n-B-1)/B+2) {
				puts("-1");
				return 0;
			}
			for(int i = 1, j = B ; i <= B ; ++ i, -- j) w[i] = j;
			int nw = A-1;
			int blo = (n-B)/nw, num = n+1, ret = n-B-nw*blo, R = n;
			for(int i = 1, L ; i <= nw ; ++ i) {
				if(i<=ret) L = R-blo;
				else L = R-blo+1;
				for(int j = L ; j <= R ; ++ j) w[j] = -- num;
				R = L-1;
			}
		}
		for(int i = 1 ; i <= n ; ++ i) printf("%d ", w[i]);
		puts("");
	return 0;
}

Measured memory_bytes: 3328
//program luogu.AT2652
#include<iostream>
#include<cstdio>
using namespace std;
int a,b;

int main(){
	scanf("%d%d",&a,&b);
	if( !(a%3) || !(b%3) || (a+b)%3==0 )
		printf("Possible\n");
	else
		printf("Impossible\n");
	return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <string.h>

using namespace std;

namespace {

const size_t kHashSize = 244140624;

class Dictionary {
 public:
  Dictionary() : table_(new int[kHashSize]) {}
  ~Dictionary() { delete[] table_; }

  void insert(const char* k, size_t n) {
    const size_t i = Encode(k, n);
    table_[i] = 1;
  }

  bool find(const char* k, size_t n) const {
    return table_[Encode(k, n)] > 0;
  }

 private:
  int Id(char c) const {
      switch (c) {
        case 'A':
          return 1;
        case 'C':
          return 2;
        case 'G':
          return 3;
        case 'T':
          return 4;
      }
      // should not reach here.
      return 0;
  }

  size_t Encode(const char* k, size_t n) const {
    size_t h = 0;
    size_t p = 1;
    for (size_t i = 0; i < n; ++i) {
      h += p * Id(k[i]);
      p *= 5;
    }
    return h;
  }

  int* table_;
};

} // namespace

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

  Dictionary d;
  char op[7];
  char str[13];
  for (int i = 0; i < n; ++i) {
    scanf("%s ", op);
    scanf("%s", str);
    const char c = op[0];
    const size_t len = strnlen(str, 13);
    if (c == 'i') {
      d.insert(str, len);
      continue;
    }

    if (d.find(str, len)) {
      printf("yes\n");
    } else {
      printf("no\n");
    }
  }

  return 0;
}

Measured memory_bytes: 40424
#include<iostream>
#include<algorithm>
#include<string>
#include<vector>
#define int long long
#define mod 1000000007
#define for0(i, n) for(int i = 0; i < (n); i++)
#define for1(i, n) for(int i = 1; i <= (n);i++)
using namespace std;
int b[123456], p = 0;
signed main() {
	int n; cin >> n;
	int a[123456];
	for (int i = 0; i < n; i++)cin >> a[i];
	if (a[0] != 0) { cout << "0\n"; return 0; }
	sort(a, a + n);
	b[0]++;
	for (int i = 1; i < n; i++) {
		if (a[i] - a[i - 1] > 1) { cout << "0\n"; return 0; }
		b[a[i]]++; p = a[i];
	}
	if (b[0] != 1) { cout << "0\n"; return 0; }
	int ans = 1;
	for (int i = 1; i <= p; i++) for0(j, b[i]) { ans *= b[i - 1]; ans %= 998244353; }
	cout << ans << endl;
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
#include<set>
#include <algorithm>
#define ll long long 
#include <string.h>
#define pb push_back
#define mp make_pair
# define pi 3.14159265358979323846
using namespace std;
int main()
{
	ll int a;
	cin>>a;
	a+=a*a+ a*a*a;
	cout<<a<<endl;
	
}
    
	
		

	
			

		


 







Measured memory_bytes: 3592
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < n; i++)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pi;
typedef pair<ll, ll> pl;
const double EPS = 1e-9;
const ll mod = 1000000007;
const int inf = 1 << 30;
const ll linf = 1LL << 60;
const double PI = 3.14159265358979323846;

int n;
ll s[100000];

int main() {
    cin >> n;
    rep(i,n) cin >> s[i];
    ll ans = 0;
    for (int c = 1; c <= n-1; c++) {
        ll cnt = 0;
        set<int> hoge;
        for (int k = 0; k*c < n-1; k++) {
            cnt += s[k*c] + s[n-1-k*c];
            if (hoge.count(k*c)) break;
            hoge.insert(k*c);
            if (hoge.count(n-1-k*c)) break;
            hoge.insert(n-1-k*c);
            if (c < n-1-k*c) {
                ans = max(ans, cnt);
            }
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 7808
import java.util.*;
import java.io.*;
import static java.lang.Math.*;

public class Main {
    public static void main(String[] args) throws Exception {
		Scanner sc = new Scanner(System.in);
		
		// 入力
		int n = sc.nextInt();

		// 計算
		long result = 0;
		for(int i = 1; i <= n; i++){
		    long cnt = n/i;
		    result += i*cnt*(cnt+1)/2;
		}
		
		// 出力
		System.out.println(result);
	}

	public static class Scanner {
		private BufferedReader br; private StringTokenizer tok;
		public Scanner(InputStream is) throws IOException { br = new BufferedReader(new InputStreamReader(is));}
		private void getLine() throws IOException { while(!hasNext()) tok = new StringTokenizer(br.readLine());}
		private boolean hasNext() { return tok != null && tok.hasMoreTokens();}
		public String next() throws IOException { getLine(); return tok.nextToken();}
		public int nextInt() throws IOException { return Integer.parseInt(next());}
		public long nextLong() throws IOException { return Long.parseLong(next());}
		public double nextDouble() throws IOException { return Double.parseDouble(next());}
	}
}


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

#define     F       first
#define     S       second
typedef pair<int, int>  pi;
typedef long long       ll;

int n;
ll k;
vector<ll> pos, neg;

ll check(ll mid) {
    ll cnt=0;
    if (mid>=0) {
        for (int i=0; i<pos.size(); ++i) {
            if (!pos[i]) {
                cnt+=pos.size()-(i+1);
                continue;
            }

            ll need=mid/pos[i];

            int index=upper_bound(pos.begin(), pos.end(), need)-pos.begin();
            if (index>i) {
                cnt+=index-i-1;
            }
        }

        for (int i=0; i<neg.size(); ++i) {
            ll need=mid/neg[i];

            int index=upper_bound(neg.begin(), neg.end(), need)-neg.begin();
            if (index>i) {
                cnt+=index-i-1;
            }
        }

        cnt+=1LL*pos.size()*neg.size();
        return cnt;
    }

    mid*=-1;
    for (int i=0; i<pos.size(); ++i) {
        if (!pos[i]) {
            continue;
        }

        ll need=mid/pos[i]-(mid%pos[i]==0);

        cnt+=neg.end()-upper_bound(neg.begin(), neg.end(), need);
    }

    return cnt;
}

ll BSFind() {
    ll low=-1e18-18, high=1e18+18, res=0;
    while (low<=high) {
        ll mid=low+(high-low)/2;
        if (check(mid)>=k) {
            high=mid-1;
            res=mid;
        }
        else {
            low=mid+1;
        }
    }

    return res;
}

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

    cin >> n >> k;
    while (n--) {
        int a;
        cin >> a;

        if (a>=0)       pos.push_back(a);
        else            neg.push_back(-a);
    }

    sort(pos.begin(), pos.end());
    sort(neg.begin(), neg.end());

    cout << BSFind();

    return 0;
}


Measured memory_bytes: 2548
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <utility>
#include <cstring>
#include <cmath>
const int MOD = 1e9 + 7;
const int dx[] = {1, -1, 0, 0};
const int dy[] = {0, 0, 1, -1};
using namespace std;
typedef long long ll;
int main()
{
	cin.tie(0);
	ios::sync_with_stdio(false);
	int n;
	cin >> n;
	char ch[n + 1];
	for(int i = 0; i < n; i++)
	{
		cin >> ch[i];
	}
	int left_cnt = 0;
	int right_cnt = 0;
	if(ch[0] == '>' && ch[n -1] == '<')
	{
		cout << n << endl;
		return 0;
	}
	for(int i = 0; i < n; i++)
	{
		if(ch[i] == '<')
			left_cnt++;
		else
			break;
	}
	for(int i = n - 1; i >= 0; i--)
	{
		if(ch[i] == '>')
			right_cnt++;
		else
			break;
	}
	cout << n - min(left_cnt, right_cnt) << endl;
	return 0;
}




Measured memory_bytes: 3272
a = int(input())
b = int(input())
c = int(input())
x = int(input())
answer = 0
for i in range(0,(a + 1)):
    for j in range(0,(b + 1)):
        for k in range(0,(c + 1)):
            if x == 500 * i + 100 * j + 50 * k:
                answer += 1
print(answer)

Measured memory_bytes: 3060
import java.util.Scanner;

class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        
        while(true){
        int a = sc.nextInt();
        String op = sc.next();
        int b = sc.nextInt();
        
            if(op.equals("?")) break;
            if(op.equals("+")) System.out.println(a+b);
            if(op.equals("-")) System.out.println(a-b);
            if(op.equals("*")) System.out.println(a*b);
            if(op.equals("/")) System.out.println(a/b);
        }
    }
}


Measured memory_bytes: 26204
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;
#define AB_BHI_NI_DEGI                \
    ios_base::sync_with_stdio(false); \
    cin.tie(NULL);                    \
    cout.tie(NULL);
#define int long long
#define pb push_back
#define N 100009
#define inf 1e18
const double PI = 3.141592653589793238462643383279;
//int mod = 1e9 + 7;
int mod = 998244353;
#define P pair<int, int>
#define F first
#define S second
#define all(v) v.begin(), v.end()
#define vi vector<int>
#define ld long double

#define ordered_set tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update>

void solve()
{
    int n, k;
    cin >> n >> k;
    int vis[n + 1] = {0};
    int l[k], r[k];
    int dp[n + 1] = {0};
    for (int i = 0; i < k; i++)
    {
        cin >> l[i] >> r[i];
        for (int j = l[i]; j <= r[i]; j++)
            vis[j] = 1;
    }
    int ans = 0;
    for (int i = 2; i <= n; i++)
    {
        dp[i] = dp[i - 1] - vis[i - 2] + vis[i - 1];
        for (int j = 0; j < k; j++)
        {
            int L = l[j];
            int R = r[j];
            if (i - R - 1 > 0)
                dp[i] = (dp[i] - dp[i - R - 1] + mod) % mod;
            if (i - L > 0)
                dp[i] = (dp[i] + dp[i - L]) % mod;
        }
    }
    cout << dp[n] << "\n";
}
int32_t main()
{
    AB_BHI_NI_DEGI
    int Test = 1;
    //cin >> Test;
    //init();
    while (Test--)
        solve();
    return 0;
}
/*

*/

Measured memory_bytes: 6740
#include <bits/stdc++.h>
using namespace std;
#define forx(i, a, b) for (int i = (a); i < (b); i++)
#define rep(j, n) for (int j = 0; j < (n); j++)

typedef long long ll;

int main()
{
    int n,s,m;
    cin >> n;
    m = n;
    while(m>0){
        s += m % 10;
        m /= 10;
    }
    if(n%s==0)
        cout << "Yes" << endl;
    else
        cout << "No" << endl;
    return 0;
}


Measured memory_bytes: 256
n = int(input())
l = list(map(int, input().split()))
check = True
for i in range(1, n):
    if (l[-i - 1] - l[-i] > 1):
        check = False
    if (l[-i - 1] - l[-i] == 1):
        l[-i - 1] -= 1
if check:
    print("Yes")
else:
    print("No")

Measured memory_bytes: 14396
import java.util.*; 
public class Main {

  public static void main(String[] args) {
  
  Scanner sc=new Scanner(System.in);
  int a[]=new int[3];
  a[0] =sc.nextInt();
  a[1] =sc.nextInt();
  a[2] =sc.nextInt();
  Arrays.sort(a);
  System.out.println(a[2]-a[0]);
  }
}

Measured memory_bytes: 23124
#include<cstdio>
#include<algorithm>
#include<cstring>
using namespace std;
const int maxn = 100000 + 5;
char s[maxn];

int main()
{
	int len, j,flag;
	while (scanf("%s",s)!=EOF)
	{
		flag = 1;
		len = strlen(s);
		sort(s, s + len);
		j = 0;
		for (int i = 97; i < 123; i++)
		{
			if (s[j] > i)
			{
				printf("%c\n", i);
				flag = 0;
				break;
			}
			while (s[j] == i)
			{
				j++;
				if (j >=len)
				{
					if(i==122) printf("None\n");
					else
					{
						printf("%c\n", ++i);
					}
					flag = 0;
					break;
				}
			}
		}
		if (flag) printf("None\n");
	}
	return 0;
}

Measured memory_bytes: 256
import java.util.*;

public class Main{
	static final int mod=1000000007;
	static final int[] dx={0,0,1,-1},dy={1,-1,0,0};

	public static void main(String[] $){
		Scanner s=new Scanner(System.in);
		int h=s.nextInt(),w=s.nextInt();

		char[][] f=new char[h][w];
		Arrays.setAll(f,i->s.next().toCharArray());

		int[][] wf=new int[h*w][h*w];
		for(int i=0;i<h*w;++i){
			Arrays.fill(wf[i],999);
			wf[i][i]=0;
		}

		for(int y=0;y<h;++y){
			for(int x=0;x<w;++x){
				if(f[y][x]!='.')
					continue;
				for(int d=0;d<4;++d){
					int ny=y+dy[d];
					int nx=x+dx[d];
					if(0<=nx&&nx<w&&0<=ny&&ny<h&&f[ny][nx]=='.')
						wf[y*w+x][ny*w+nx]=wf[ny*w+nx][y*w+x]=1;
				}
			}
		}

		//wf
		for(int k=0;k<h*w;++k)
			for(int i=0;i<h*w;++i)
				for(int j=0;j<h*w;++j)
					wf[i][j]=Math.min(wf[i][j],wf[i][k]+wf[k][j]);

		int r=0;
		for(int i=0;i<h*w;++i)
			for(int j=0;j<h*w;++j)
				r=Math.max(r,wf[i][j]<999?wf[i][j]:0);
		System.out.println(r);
	}
}


Measured memory_bytes: 28884
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>

using namespace std;
 
int main(){

    int n;
    string s;

    cin >> n;
    cin >> s;

    vector<int> w(n + 1,0);
    vector<int> b(n + 1,0);

    int cnt = 0;

    for(int i = 0; i < n; i++){
        if(s[i] == '#'){
            cnt++;
        }
        w[i + 1] = cnt;
    }

    cnt = 0;

    for(int i = n - 1; i > -1; i--){
        if(s[i] == '.'){
            cnt++;
        }
        b[i] = cnt;
    }

    int ans = n;

    for(int i = 0; i < n + 1; i++){
        //cerr << w.size() << endl;
        //cerr << w[i] << " " << b[i] << endl;
        ans = min(ans,w[i] + b[i]);
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 2180
#include <iostream>
#define REP(i, a, n) for(int i = a; i <= n; i++)
using namespace std;


int H, W;
char C[101][101];

int main(void) {
  cin >> H >> W;
  REP(i, 1, H) REP(j, 1, W) cin >> C[i][j];

  REP(i, 1, H) {
    REP(j, 1, W) {
      cout << C[i][j];
    }
    cout << endl;
    REP(j, 1, W) {
      cout << C[i][j];
    }
    cout << endl;
  }

  return 0;
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
long long a,b,ans;


int main()
{
    //freopen("in.txt","r",stdin);
    //freopen("out.txt","w",stdout);
    scanf("%lld %lld",&a,&b);
    bool odd=b&1;
    for(int i=0;i<63;i++){
        if(!i){
            if(((b+1)/2)&1) ans|=1;
        }else{
            if(!odd&&((b>>i)&1)) ans|=(1ll<<i);
        }
    }
    a--;
    odd=a&1;
    for(int i=0;a>=0&&i<63;i++){
        if(!i){
            if(((a+1)/2)&1) ans^=1;
        }else{
            if(!odd&&((a>>i)&1)) ans^=(1ll<<i);
        }
    }
    printf("%lld",ans);
    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
int main(){
  int stay,i,a,cou;
  char m1[3],m2[3]; 
 while(1){
    scanf("%d",&a);
    if(a==0)break;
    stay=0;
    cou=0;
    for(i=0;i<a/2;i++){
      scanf("%s %s",m1,m2);
      if(stay==0&&m1[1]=='u'&&m2[1]=='u'){
	cou++;
	stay=1;
      }else if(stay==1&&m1[1]=='d'&&m2[1]=='d'){
	cou++;
	stay=0;
      }
    }
    if(a%2==1)scanf("%s",m1);
    printf("%d\n",cou);
  }
  return 0;
}

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


int main() {
  int N,K,m=1;
  cin>>N>>K;

  rep(i,N){
    int A=m*2;
    int B=m+K;
    m=min(A,B);
  }
  cout << m << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define For(i, a, b) for(int (i)=(a); (i)<(b); ++(i))
#define rFor(i, a, b) for(int (i)=(a)-1; (i)>=(b); --(i))
#define rep(i, n) For((i), 0, (n))
#define rrep(i, n) rFor((i), (n), 0)
#define fi first
#define se second
using namespace std;
typedef long long lint;
typedef unsigned long long ulint;
typedef pair<int, int> pii;
typedef pair<int, pii> pip;
typedef pair<int, lint> pil;
typedef pair<lint, lint> pll;
typedef pair<pair<lint, int>, pair<int, int>> ppp;
typedef complex<double> xy_t;
typedef vector<lint> poly;
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;}

const lint mod = 1e9 + 7;
const lint INF = mod*mod;
const int MAX = 200010;

int main(){
    int h, w, K;
    scanf("%d%d%d", &h, &w, &K);
    char c[h][w];
    int ans[h][w];
    rep(i, h)rep(j, w){
        scanf(" %c", &c[i][j]);
        ans[i][j]=0;
    }
    int num=1;
    rep(i, h){
        int cur=0;
        bool flag=false;
        while(cur<w){
            if(c[i][cur]=='.'){
                ++cur;
                continue;
            }
            flag=true;
            ans[i][cur]=num;
            for(int j=cur-1; j>=0 && !ans[i][j]; --j) ans[i][j]=num;
            int r=cur+1;
            while(r<w && c[i][r]=='.') ans[i][r++]=num;
            cur=r;
            ++num;
        }
    }
    rep(i, h)rep(j, w)if(!ans[i][j]){
        if(i-1>=0 && ans[i-1][j]) ans[i][j]=ans[i-1][j];
    }
    rrep(i, h)rep(j, w)if(!ans[i][j]){
        if(i+1<h && ans[i+1][j]) ans[i][j]=ans[i+1][j];
    }

    rep(i, h){
        rep(j, w) printf("%d ", ans[i][j]);
        printf("\n");
    }
}

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

int calculate_cost (int num_traveler, int cost_train, int cost_taxi)
{
	// return value of this function
	int cost;

	cost = std::min(num_traveler * cost_train, cost_taxi);

	// declare the return value of this function
	return cost;
}

int main (void)
{
	// variables for main process
	int N, A, B;

	// STEP.01
	// read out the given data
	std::cin >> N >> A >> B;

	// STEP.02
	// output the answer of this task
	std::cout << calculate_cost (N, A, B) << std::endl;

	// STEP.END
	return 0;
}


Measured memory_bytes: 256
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
#include <iomanip> // fixed, setprecision 
#include <math.h> // double sqrt
#define rep(i,n) for(int i=0;i<(n);++i)
using namespace std;
int main(){
    char s;
    cin>>s;
    if(s>=97)cout<<"a";
    else cout<<"A";
    return 0;
}

Measured memory_bytes: 3032
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int maxn=100010;
ll a[maxn] , b[maxn] , c[maxn] , sum[maxn];
int main()
{
    int n;
    while (~scanf("%d", &n)){
        for (int i=1; i<=n; i++)  scanf("%d", &a[i]);
        for (int i=1; i<=n; i++)  scanf("%d", &b[i]);
        for (int i=1; i<=n; i++)  scanf("%d", &c[i]);
        sort(a+1,a+n+1);
        sort(b+1,b+n+1);

        sum[0] = 0;
        for (int i=1; i<=n; i++){
            int id = upper_bound(a+1,a+n+1,b[i]-1) - a - 1;
            sum[i] = sum[i-1] + id;
        }

        ll ans = 0;
        for (int i=1; i<=n; i++){
            int id = upper_bound(b+1,b+n+1,c[i]-1) - b - 1;
            ans += sum[id];
        }
        printf("%lld\n", ans);
    }
    return 0;
}


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

#define pout(n)  printf ("%d\n", n)
#define rep(i,a,n) for (int i = a;i < n;i++)
#define per(i,n,a) for (int i = n-1;i >= a;i--)
#define BIT(bit,a,n) for (int bit = a;bit < (1<<n);bit++) // {0, 1, ..., n-1} の部分集合の全探索 // n番目のフラグが立っている状態は (1<<n)
const int d4x[4] = {1, 0, -1, 0};
const int d4y[4] = {0, 1, 0, -1};
const int d8x[8] = { 1,1,0,-1,-1,-1,0,1 };
const int d8y[8] = { 0,1,1,1,0,-1,-1,-1 };
#define MAX_N (int)2e5+20
typedef long long ll;
using namespace std;

int n,m;
int ans = 0;
int main(){
    scanf("%d",&n);
    vector<string> s(n);
    rep(i, 0, n) cin >> s[i];
    scanf("%d",&m);
    vector<string> t(m);
    rep(i, 0, m) cin >> t[i];
    int cnt[101] = {0};

    rep(i,0,n){
        rep(j,0,n){
            if(s[i] == s[j]) cnt[i]++;
        }
        rep(j,0,m){
            if(s[i] == t[j]) cnt[i]--;
        }
    }
    int num = max(n,m);
    rep(i,0,num){
        ans = max(ans,cnt[i]);
    }
    pout(ans);
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<cmath>
using namespace std;
int h[100010],f[100010];//f[i]=min(f[i-1]+abs(h[i]-h[i-1]),f[i-2]+abs(h[i]-h[i-2]));
int n;
int main(){
	cin>>n;
	for(int i=1;i<=n;i++){
		cin>>h[i];
	}
	f[1]=0;
	f[2]=abs(h[2]-h[1]);
	for(int i=3;i<=n;i++){
		f[i]=min(f[i-1]+abs(h[i]-h[i-1]),f[i-2]+abs(h[i]-h[i-2]));
	}
	cout<<f[n];
}
//https://atcoder.jp/contests/dp/tasks/dp_a

Measured memory_bytes: 1024
import java.util.*;

public class Main {
    public static void main (String[] args) {

        Scanner sc = new Scanner(System.in);

        int n = sc.nextInt();

        int[] a = new int[n];
        for (int i = 0; i < a.length; i++) {
            a[i] = sc.nextInt();
        }

        Arrays.sort(a);
        System.out.print(a[n - 1] + " ");

        int r = a[0];
        for (int i = 1; i < a.length; i++) {
            if (Math.abs(a[n-1] - 2 * a[i]) < Math.abs(a[n-1] - 2 * r)) {
                r = a[i];
            }
        }

        System.out.println(r);
    }
}

Measured memory_bytes: 52764
import java.util.*;
public class Main{
  public static void main(String args[]){
    Scanner sc = new Scanner(System.in);
    int[] data1 = new int[2];
    int[] data2 = new int[2];

    for (int i = 0 ; i < 2 ; i++ ) {
      data1[i] = sc.nextInt();
    }
    for (int i = 0 ; i < 2 ; i++ ) {
      data2[i] = sc.nextInt();
    }

    if (data2[1] == 1) {
      System.out.println("1");
    } else {
      System.out.println("0");
    }

  }
}


Measured memory_bytes: 23508
#include <algorithm>
#include <cmath>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <tuple>
#include <vector>
using namespace std;
typedef long long ll;
ll const INF = 1LL << 60;

int main() {
  ll N;
  string s, t;
  cin >> N >> s >> t;
  ll double_cnt = 0;
  for (int i = 0; i < s.length(); i++) {
    if (s[i] == t[0]) {
      ll cnt = 1;
      while (i + cnt < s.length() && s[i + cnt] == t[cnt]) {
        cnt++;
      }
      double_cnt = max(double_cnt, cnt);
    }
  }
  ll min_len = s.length() + t.length() - double_cnt;
  cout << max(min_len, N) << endl;
  return 0;
}

Measured memory_bytes: 3520
'use strict'


function Main(input) {
  input = input.trim().split('\n')
  const N = parseInt(input[0])

  const A = input[1].split(' ').map(s => parseInt(s))

  let dp = {}
  for(let i = 0; i < N; ++i) {
    if(!dp[A[i]]) dp[A[i]] = 0
    if(dp[A[i]] > 0) {
      console.log('NO')
      return
    }
    dp[A[i]] += 1
  }

  console.log('YES')
}
Main(require("fs").readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 66476
#include<iostream>
#include <math.h>
 
using namespace std;
 
int main(int argc, const char * argv[]) {
    ios_base::sync_with_stdio(false); cin.tie(NULL);
    
    float r;
    cin>>r;
    cout<<2*M_PI*r<<endl;
    
    return 0;
}

Measured memory_bytes: 3260
#include<bits/stdc++.h>
#include<iostream>
#include<algorithm>
#include<vector>
#include<stdio.h>
#include<cstring>
#include<math.h>
#include<map>
#include<bitset>
#include<iomanip>
#include<queue>
#include<functional>
#include<stack>
#include<tuple>
#include<cassert>
using namespace std;

#define rep(i, n) for (long long i = 0; i < (long long)(n); ++i)
using P = pair<long long, long long>;

int main() {
  long long N, M;
  cin >> N >> M;
  long long a[10000];
  rep(i, M) {
    cin >> a[i];
  }
  long long sum = 0;
  rep(i, M) {
    sum += a[i];
  }
  long long ans = N - sum;
  if(ans < 0) {
    ans = -1;
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 3664
N = int(input())
l = [1,6,9,36,81,216,729,1296,6561,7776,46656,59049]
dp = [N]*(N+1)
dp[0]=0

for i in range(1,N+1):
    for j in l:
        if i-j >= 0:
            dp[i] = min(dp[i],dp[i-j]+1)
print(dp[N])

Measured memory_bytes: 3828
#include "bits/stdc++.h"
using namespace std;
#define ll long long int
#define rep(i,n) for( int i = 0; i < n; i++ )
#define rrep(i,n) for( int i = n; i >= 0; i-- )
#define REP(i,s,t) for( int i = s; i <= t; i++ )
#define RREP(i,s,t) for( int i = s; i >= t; i-- )
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define INF 2000000000
#define mod 1000000007
#define INF2 1000000000000000000
#define int long long int

signed main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
	int N;
	cin >> N;
	int A[N];
	rep(i, N) {
		cin >> A[i];
	}	
	int ans = 0;
	int sum[N + 1] = {};
	map<int, int> mp;
	rep(i, N) {
		sum[i + 1] = sum[i] + A[i];
		if (sum[i + 1] == 0) ans++;
		mp[sum[i + 1]]++;
	}
	rep(i, N) {
		int tmp = mp[sum[i + 1]];		
		ans += tmp * (tmp - 1) / 2;
		mp[sum[i + 1]] = 1;
	}

		cout << ans << endl;

    return 0;
}


Measured memory_bytes: 15872
#include<iostream>
#include<stdio.h>
using namespace std;
int main()
{
  int W,H,x,y;
  cin>>W>>H>>x>>y;
  int c=0;
  if( ((double)W*0.5==(double)x) && ((double)H*0.5==(double)y) ){
    c=1;
  }
  printf("%.10lf %d",W*(H*0.5),c);
}

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

struct Table {
    int ma;
    vector<bool> table;
    Table(int ma) : ma(ma), table(ma + 1) { }
    int next(int x) {
        for (int i = x; i <= ma; i += x) table[i] = true;
        int nxt = x + 1;
        while (table[nxt]) nxt++;
        return nxt;
    }
};

int main() {
    int m, n;
    while (cin >> m >> n, m) {
        Table table(7368791);
        int ans = m;
        while (n--) ans = table.next(ans);
        cout << ans << endl;
    }
    return 0;
}



Measured memory_bytes: 4004
#include <iostream>
#include <cstdio>
#include <algorithm>

using namespace std;

int n, m, x, ans_1, ans_2;
bool is_bad[101];

int main() {
  scanf("%d%d%d", &n, &m, &x);
  for(int i = 1; i <= m; i++) {
    int input;
    scanf("%d", &input);
    is_bad[input] = true;
  }
  for(int i = x - 1; i >= 1; i--)
    if(is_bad[i]) ans_1++;
  for(int i = x + 1; i < n; i++)
    if(is_bad[i]) ans_2++;
  printf("%d\n", min(ans_1, ans_2));
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N = 1e5;
vector<int> g[N];
int n, m, len[N];
int DFS(int u){
    int &len = ::len[u];
    if( len != -1 )
        return len;
    len = 0;
    for(int i=0; i<(int)g[u].size(); ++i)
        len = max(len, DFS(g[u][i])+1);
    return len;
}
int main()
{
    cin >> n >> m;
    while( m -- )
    {
        int f, t;
        cin >> f >> t;
        g[f-1].emplace_back(t-1);
    }
    memset(len, -1, sizeof len);
    int mx = -1;
    for(int i=0; i<n; ++i)
        mx = max(mx, DFS(i));
    cout << mx;
    return 0;
}

Measured memory_bytes: 8192
using System;

namespace ConsoleApp1
{
    class Program
    {
        static int Found(char [] S, int End, char V1, char V2, char V3)
        {
            int mode = 0;

            for (int i=0; i<End; i++)
            {
                if (mode == 0 && S[i] == V1) mode = 1;
                else if (mode == 1 && S[i] == V2) mode = 2;
                else if (mode == 2 && S[i] == V3) return 1;

            }
            return 0;
        }

        static void Main(string[] args)
        {
            var X = int.Parse(Console.ReadLine());
            var S = Console.ReadLine().ToCharArray();

            var count = 0;

            for (int i = 0; i <= 9; i++)
            {
                for (int j = 0; j <= 9; j++)
                {
                    for (int k = 0; k <= 9; k++)
                    {
                        count += Found(S, X, (char)('0' + i), (char)('0' + j), (char)('0' + k));
                    }
                }
            }

            Console.WriteLine(count);
        }
    }
}


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

#define MP make_pair
#define PB push_back
#define ALL(x)      (x).begin(),(x).end()
#define REP(i,n)    for(int i=0;i<(n);i++)
#define REP1(i,n)   for(int i=1;i<(n);i++)
#define REP2(i,d,n) for(int i=(d);i<(n);i++)
#define RREP(i,n)   for(int i=(n);i>=0;i--)
#define CLR(a)      memset((a),0,sizeof(a))
#define MCLR(a)     memset((a),-1,sizeof(a))
#define RANGE(x,y,maxX,maxY) (0 <= (x) && 0 <= (y) && (x) < (maxX) && (y) < (maxY))
 
typedef long long LL;
typedef unsigned long long ULL;
typedef vector<int> VI;
typedef vector<VI > VVI;
typedef vector<string> VS;
typedef vector<LL> VLL;
typedef pair<int,int> PII;
 
const int INF = 0x3f3f3f3f;
const LL INFL = 0x3f3f3f3f3f3f3f3fLL;
const double EPS = 1e-9;
 
const int DX[]={1,0,-1,0},DY[]={0,-1,0,1};



int main(){
    int N;
    cin >> N;
    if(N == 1) {
        cout << "Hello World" << endl;
    } else {
        int a, b;
        cin >> a >> b;
        cout << a + b << 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 n,k,d=1;cin>>n>>k;
    rep(i, n) {
        int a=d*2;int b=d+k;
        if (a>b) d=b;
        else d=a;
    }
    cout<<d<<endl;
}


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

//template
#define rep(i,a,b) for(int i=(a);i<(b);i++)
#define rrep(i,a,b) for(int i=(a);i>(b);i--)
#define ALL(v) (v).begin(),(v).end()
typedef long long int ll; const int inf = 0x3fffffff; const ll INF = 0x3fffffffffffffff;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
template<typename A,size_t N,typename T>void Fill(A(&array)[N],const T &val){fill((T*)array, (T*)(array+N), val);}
//template end



int main(){
    int n,m; scanf("%d%d",&n,&m);
    int a[100010]={};
    rep(i,0,n)scanf("%d",&a[i]),a[i];
    ll imos[200010]={},ans=0;
    rep(i,0,n-1){
        int s=a[i],t=a[i+1]; if(s>t)t+=m;
        int d=t-s; ans+=d;
        imos[s+1]++; imos[t]-=d; imos[t+1]+=d-1;
    }
    rep(rot,0,2)rep(i,0,2*m)imos[i+1]+=imos[i];
    ll dec=0;
    rep(i,0,m)chmax(dec,imos[i]+imos[m+i]);
    printf("%lld\n",ans-dec);
    return 0;
}

Measured memory_bytes: 2176
def min(a,b); a < b ? a : b; end
def max(a,b); a > b ? a : b; end

N = gets.to_i
ans = (1 .. Math.sqrt(N).floor).inject(N) do |s,a|
  N % a == 0 ? min(s, max(a.to_s.size, (N / a).to_s.size)) : s
end
puts ans

Measured memory_bytes: 1788
import java.io.*;
import java.util.*;
class Main{    
	private void compute(){        
		Scanner scanner = new Scanner(System.in);        
		for( int i = 0; i < 7; i++){            
			int nHigh = scanner.nextInt();            
			int nLow = scanner.nextInt();            
			System.out.println(nHigh - nLow);        
			}    
		}    
	public static void main(String args[]){        
		new Main().compute();    
		}     
	}

Measured memory_bytes: 17228
#![allow(unused_imports)]
use std::cmp::*;
use std::collections::*;
use itertools::Itertools;
use proconio::{input, marker::*};
use superslice::*;
use whiteread::parse_line;
use std::collections::HashMap;

fn main() {
    let (n, k): (usize, usize) = parse_line().unwrap();
    let mut v = vec![false; n];

    for _ in 0..k {
        let _: usize = parse_line().unwrap();
        let want_to_candy_list: Vec<usize> = parse_line().unwrap();
        for candy in want_to_candy_list {
            v[candy - 1] = true;
        }
    }
    let mut count: usize = 0;
    for is_get in v {
        count += if is_get { 0 } else { 1 };
    }
    println!("{}", count);
}


Measured memory_bytes: 2156
#include"bits/stdc++.h"
#include<boost/multi_array.hpp>
#include<boost/optional.hpp>
#include<boost/range/irange.hpp>
#include<boost/range/algorithm.hpp>
#include<boost/range/adaptors.hpp>
using namespace std;
namespace adaptor = boost::adaptors;


#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define rep3(i,m,n) for(int (i)=m;(i)<=(n);(i)++)
#define rep3rev(i,m,n) for(int (i)=m;(i)>=(n);(i)--)
typedef long long ll;


void Main()
{
  ll h;
  cin >> h;
  ll temp = 1;
  while(h >= temp){
     temp *= 2;
  }
  ll ans = temp-1;
  cout << ans << endl;

 return;
}


int main()
{
 cin.tie(nullptr);
 ios_base::sync_with_stdio(false);
 cout << fixed << setprecision(15);
 Main();
 return 0;
}


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

int main(){
    int N;
    cin >> N;
    
    string S,T;
    cin >> S >> T;
    
    string A;
    rep(i,N){
        A += S[i];
        A += T[i];
    }
    cout << A << endl;
}


Measured memory_bytes: 256
//https://atcoder.jp/contests/abc135/tasks/abc135_b
#include <bits/stdc++.h>
using namespace std;
using ll=int64_t;
#define FOR(i,a,b) for(int64_t i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
int main() {
    ll N; cin>>N;
    vector<ll> pn(N);
    for(auto&& p:pn){
        cin>>p;
    }
    auto orig=pn;
    sort(pn.begin(),pn.end());
    ll cnt=0;
    REP(i,pn.size()){
        if(orig[i]!=pn[i]){
            ++cnt;
        }
    }
    cout<<(cnt<=2?"YES":"NO")<<endl;
    return 0;
}

Measured memory_bytes: 256
//
// Created by kash on 16/05/20.
//

#include <bits/stdc++.h>

using namespace std;
#define mod 1e9+7
#define ll long long
#define rev_rep(it, last, first) for(int it=last-1;it>=first;--it)
#define out(x) cout << x;
#define pln(x) cout << x << "\n";
#define debug(x) cout << "Debug: " << x << "\n";
#define in(x) cin >> x;
#define rep(it, start, end) for(int it=start;it<end;++it)
#define x first
#define y second


void set_io(int inp) {
#ifndef ONLINE_JUDGE
    string folder = string(getenv("HOME")) + "/CLionProjects/CompetitiveProgramming/inputs/";
    string input_file = folder + "input-" + to_string(inp) + ".txt";
    string output_file = folder + "output-" + to_string(inp) + ".txt";
    freopen(input_file.c_str(), "r", stdin);
    freopen(output_file.c_str(), "w", stdout);
#endif
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);

}


int main() {
    set_io(1);
    int h, w, k;
    in(h >> w >> k);
    string pr[h];
    rep(i, 0, h)in(pr[i]);

    int total = (1 << (h + w));
    int sol = 0;

    rep(i, 0, total) {
        int rows[10] = {}, columns[10] = {};
        int j = 0;
        int cpy = i;
        while (cpy) {
            if (cpy & 1) {
                if (j < h)
                    rows[j]++;
                else
                    columns[j - h]++;
            }
            cpy = cpy/2;
            j++;
        }
        int cnt = 0;
        rep(i, 0, h) {
            if (!rows[i]) {
                rep(j, 0, w) {
                    if (!columns[j] && pr[i][j] == '#')
                        cnt++;
                }
            }
        }
        if (cnt == k)
            sol++;

    }
    out(sol);


    return 0;
}


Measured memory_bytes: 3648
args = input().split()
A = int(args[0])
B = int(args[1])
C = int(args[2])
if B <= C:
    ans = B * 2 + min(C - B, A)
    if C > (A + B):
        ans += 1
else:
    ans = C * 2 + (B - C)
print(str(ans))


Measured memory_bytes: 3060
n,q=map(int,input().split())
s=list(input())
a=[0]*n
for i in range(n-1):
  if s[i]=="A" and s[i+1]=="C":
    a[i+1]=a[i]+1
  else:
    a[i+1]=a[i]
for i in range(q):
  l,r=map(int,input().split())
  print(a[r-1]-a[l-1])

Measured memory_bytes: 8664
import itertools

n,m = map(int,input().split())
ks = [list(map(int,input().split())) for i in range(m)]
p = list(map(int,input().split()))
cn = 0
for i in range(n+1):
    for v in itertools.combinations([k for k in range(1,n+1)], i):
        
        on = 0
        for l,ksp in enumerate(ks):
            onsw= 0
            for sp in ksp[1:]:
                if sp in v:
                    
                    onsw += 1
            if onsw %2 == p[l]:
                
                on += 1
        
        if on == m:
            cn += 1
print(cn)

Measured memory_bytes: 3064
#include <iostream>
#include <algorithm>
#include <cstdio>
#include <vector>
using namespace std;
int n,m;
vector<int>g[5005];
bool vis[5005];
vector<int>tp;
bool e[5005][5005];
void dfs(int v){
    vis[v]=true;
    for(int i=0;i<g[v].size();i++)if(!vis[g[v][i]])dfs(g[v][i]);
    tp.push_back(v);
}
int main(void){
    scanf("%d%d",&n,&m);
    for(int i=0;i<m;i++){
        int s,t;
        scanf("%d%d",&s,&t);
        g[--s].push_back(--t);
        e[s][t]=true;
    }
    for(int i=0;i<n;i++)if(!vis[i])dfs(i);
    for(int i=tp.size()-1;i>=0;i--)cout<<tp[i]+1<<endl;
    bool ok=true;
    for(int i=tp.size()-1;i>0;i--)if(!e[tp[i]][tp[i-1]])ok=false;
    if(ok)cout<<0<<endl;
    else cout<<1<<endl;
}



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

typedef long long LL;

std::vector<int> p; int tot;
void solve(LL n) {
	if (!n) return;
	if (n & 1) solve(n >> 1), p.push_back(++tot);
	else solve(n - 1), p.insert(p.begin(), ++tot);
}
int main() {
	std::ios::sync_with_stdio(0), std::cin.tie(0);
	LL n; std::cin >> n, solve(n);
	std::cout << (p.size() << 1) << '\n';
	for (int i : p) std::cout << i << ' ';
	for (int i = 1; i <= tot; ++i) std::cout << i << ' ';
	std::cout << '\n';
	return 0;
}

Measured memory_bytes: 256
num = gets.to_i
ary = gets.split.map(&:to_i)

count = 0
index_last = num - 2

while index_last >= 0

  for i in 0 .. index_last

    if ary[i] > ary[i + 1]
      ary[i], ary[i + 1] = ary[i + 1], ary[i]
      count += 1
    end
  end

  index_last -= 1
end

(num-1).times{ |j| print "#{ary[j]} "}
print "#{ary[-1]}\n"
puts count


Measured memory_bytes: 8908
#include<cstdio>
#include<cstring>
char cha[10005];
int n;
void f(){
	int len=strlen(cha);
	for(int i=0;i<len;i++){
		if(cha[i]+n>'Z')cha[i]-=26;
		cha[i]+=n;
	}
}
int main(){
	
	scanf("%d",&n);
	scanf("%s",cha);
	f();
	printf("%s",cha);
	
	return 0;
}

Measured memory_bytes: 256