akhauriyash/Code-Regression huggingface dataset:
n, m = map(int, raw_input().split())
adjacent = [[0 for _ in xrange(n)] for _ in xrange(n)]
for _ in xrange(m):
    i, j = map(int, raw_input().split())
    adjacent[i-1][j-1] = 1
    adjacent[j-1][i-1] = 1

bridge = []
count = 0
while(1):
    for i in xrange(n):
        if sum(adjacent[i]) == 1:
            for j in xrange(n):
                if adjacent[i][j] == 1:
                    if ([i,j] not in bridge) and ([j,i] not in bridge):
                        bridge.append([i,j])
                        count += 1
    if not any(bridge): break
    for i,j in bridge:
        adjacent[i][j] = 0
        adjacent[j][i] = 0
    bridge = []
print count


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

int main() {
  int N,i,j;
  cin >> N;
  vector<int> a(N+1);
  set<int> r;
  for(i=1; i<=N; i++)
    cin >> a.at(i);

  for(i=N; i>=1; i--) {
    if(i>N/2) {
      if(a.at(i))
        r.insert(i);
    } else {
      int x=0, j=i*2;
      while(j<=N) {
        if(r.count(j))
          x++;
        j+=i;
      }
      if(a.at(i) != x%2)
        r.insert(i);
    }
  }

  cout << r.size() << endl;
  for(auto x : r)
    cout << x << " ";
  cout << endl;
}

Measured memory_bytes: 7808
#include <iostream>
#include <cstring>
#include <algorithm>
#include <cstdio>
#include <vector>
#include <string>
#include <cmath>
using namespace std;
const int inf=1e5+20;
int num[inf];
int main()
{
   int n;
   cin>>n;
   for(int i=1;i<=n;i++)
   {
       cin>>num[i];
   }
   int ans=0;
   for(int i=1;i<=n;i++)
    if(num[i]==i)
   {
       swap(num[i],num[i+1]);
       ans++;
   }
   cout<<ans<<endl;
   return 0;
}


Measured memory_bytes: 640
#include <iostream>
#include <sstream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <string>
#include <algorithm>
#include <map>
#include <set>
#include <queue>

#ifdef _DEBUG
#define DMP(x) cerr << #x << ": " << x << "\n"
#else
#define DMP(x) ((void)0)
#endif

const int MOD = 1000000007, INF = 1111111111; 
using namespace std;
typedef long long lint;

int main() {

	cin.tie(nullptr);
	ios::sync_with_stdio(false);

	int N, W;
	cin >> N >> W;

	struct item { int w, val; };
	vector<item> item(N);
	for (int i = 0; i < N; i++) cin >> item[i].w >> item[i].val;

	vector<vector<lint>> dp(N + 1, vector<lint>(W + 1,-INF));
dp[0][0]=0;
	for (int i = 1; i <= N; i++) {

		for (int j = 0; j <= W; j++) {
			if (j - item[i - 1].w >= 0) dp[i][j] = max(dp[i - 1][j - item[i - 1].w] + item[i - 1].val, dp[i - 1][j]);
			else dp[i][j] = dp[i - 1][j];
		}
	}

lint ans = 0;
for(int j=0;j<=W;j++) ans = max(ans,dp[N][j]);
cout<<ans;

	return 0;
}


Measured memory_bytes: 80256
#include <bits/stdc++.h>
using namespace std;
int main(){
  int H,N;
  cin>>H>>N;
  int x=0;
  vector<int> A(N);
  for(int i=0;i<N;i++){
    cin>>A[i];
    x+=A[i];
  }
  x<H?cout<<"No":cout<<"Yes";
}
    

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

using namespace std;
using ll = long long;

#define rep(i, n) for (int i = 0; i < (int)(n); ++i)

int main() {
  int p, q, r;
  cin >> p >> q >> r;
  int ans = p + q + r;
  ans -= max(p, max(q, r));
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 3632
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<iostream>
#include<string>
#include<vector>
#include<stack>
#include<bitset>
#include<cstdlib>
#include<cmath>
#include<set>
#include<list>
#include<deque>
#include<map>
#include<queue>
#include<sstream>
using namespace std;
typedef long long LL;
const int INF = 0x3f3f3f3f;


int main()
{
	int n,m;
	cin >> n>>m;
	if(n - 2*m > 0)
		cout << n - 2 * m << endl;
	else
		cout << 0 << endl;
	return 0;
}


Measured memory_bytes: 256
#!/usr/bin/env python3
import sys


def solve(N: int, x: "List[int]", y: "List[int]"):
    z = [xx+yy for xx, yy in zip(x, y)]
    zz = [xx-yy for xx, yy in zip(x, y)]
    return max(abs(min(z) - max(z)), abs(min(zz) - max(zz)))

# Generated by 1.1.7.1 https://github.com/kyuridenamida/atcoder-tools
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    x = [int()] * (N)  # type: "List[int]"
    y = [int()] * (N)  # type: "List[int]"
    for i in range(N):
        x[i] = int(next(tokens))
        y[i] = int(next(tokens))
    print(solve(N, x, y))

def test():
    import doctest
    doctest.testmod()

if __name__ == '__main__':
    #test()
    main()


Measured memory_bytes: 40724
#include<iostream>
#include<vector>
#include<string>
#include<utility>
#include<algorithm>
#include<unordered_map>
#include<climits>
using namespace std;

const int INF = 1000000000;
int N;
int A;
int B;
int C;
vector<int> ls {};

int dfs(int cur, int a, int b, int c){
    if(cur == N){
        if(a > 0 && b > 0 && c > 0){
            return abs(a - A) + abs(b - B) + abs(c - C) - 30;
        }
        else{
            return INF;
        }
    }
    int ret0 = dfs(cur + 1, a, b, c);
    int ret1 = dfs(cur + 1, a + ls[cur], b, c) + 10;
    int ret2 = dfs(cur + 1, a, b + ls[cur], c) + 10;
    int ret3 = dfs(cur + 1, a, b, c + ls[cur]) + 10;
    int min1 = min(ret0, ret1);
    int min2 = min(ret2, ret3);
    return min(min1, min2);
}

int main()
{
    cin >> N;
    cin >> A;
    cin >> B;
    cin >> C;
    for(int i = 0; i < N; ++i){
        int tmp; cin >> tmp;
        ls.push_back(tmp);
    }

    cout << dfs(0,0,0,0) << endl;
    return 0;
}



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

int main () {
  int n, x, a, b, count = 0, ans = 1;
  cin >> n >> x;
  
  for (int i = 0; i < n; i++) {
    cin >> b;
    a += b;
    if (a <= x) {
      ans ++;
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
#pragma GCC optimize("O3")
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <string>
#include <cstring>
#include <deque>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <cfloat>
#include <climits>
#include <ctime>
#include <cassert>
#include <numeric>
#include <fstream>
#include <functional>
#include <bitset>
using namespace std;

using ll = long long;
using P = pair<int, int>;
using T = tuple<int, int, int>;

template <class T> inline T chmax(T &a, const T b) {return a = (a < b) ? b : a;}
template <class T> inline T chmin(T &a, const T b) {return a = (a > b) ? b : a;}

constexpr int MOD = 1e9 + 7;
constexpr int inf = 1e9;
constexpr long long INF = 1e18;
constexpr double pi = acos(-1);
constexpr double EPS = 1e-10;

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

int dp[110][2][5];

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

    string n; cin>>n;
    int sz = n.size();
    int k; cin>>k;

    dp[0][0][0] = 1;
    for(int i=0; i<sz; i++){
        int cur = n[i] - '0';
        // 未満フラグ
        for(int smaller=0; smaller<2; smaller++){
            // 0 でない数が既に j 個出た
            for(int j=0; j<=k; j++){
                for(int x=0; x<=(smaller ? 9 : cur); x++){
                    dp[i+1][smaller || x < cur][j + (x != 0)] += dp[i][smaller][j];
                }
            }
        }
    }

    cout << dp[sz][0][k] + dp[sz][1][k] << endl;

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
long euclidean_gcd(long a, long b) {
  if(a < b) return euclidean_gcd(b, a);
  while(b!=0){
      long k=b;
      b = a%b;
      a=k;
  }
  return a;
}
int main(){
    long A,B,C,D;cin>>A>>B>>C>>D;
    long g = euclidean_gcd(C,D);
    long E = B/C + B/D -B/(C*D/g);
    long F = (A-1)/C + (A-1)/D -(A-1)/(C*D/g);
    cout<<(B-E)-(A-1-F)<<endl;
}

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

int main(){
	string S,a,b,c,d,S1,S2,S3;
	a = "dream";
	b = "dreamer";
	c = "erase";
	d = "eraser";
	string e = "YES";
	string f = "dreamera";
	cin >> S;
	int x = S.size();
	while (x >= 0){
		S1 = S.substr(0,5);
		if(S1 == a){
			S2 = S.substr(0,7);
			if (S2 == b){
				S3 = S.substr(0,8);
				if (S3 == f){
					S = S.substr(5);
				}
				else{
					S = S.substr(7);
				}
			}
			else{
				S = S.substr(5);
			}
		}
		else if(S1 == c){
			S2 = S.substr(0,6);
			if (S2 == d){
				S = S.substr(6);
			}
			else{
				S = S.substr(5);
			}
		}
		else{
			e = "NO";
			break;
		}
		x = S.size();
			if (x == 0){
				break;
			}
			else if (x < 5){
				e = "NO";
				break;
			}
	}
	cout << e << endl;
}

Measured memory_bytes: 596
#include<iostream>
#include<algorithm>
#include<string>
#include<vector>
#include<queue>
#include<map>
#include<set>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
using namespace std;

int main(){
  
  int n, a[111];

  a[0] = 0;

  cin >> n;
  for (int i = 1; i <= n; i++) {
    int aa;
    cin >> aa;
    a[i] = a[i-1] + aa;
  }

  int ans = 1111111;
  for (int i = 1; i <= n; i++) {
    ans = min( abs((a[n]-a[i])-a[i]), ans);
  }

  cout << ans << endl;

  return 0;
}



Measured memory_bytes: 256
#include <stdio.h>

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

  // get digits
  int u = n % 10;
  int t = (n / 10) % 10;
  int h = n / 100;

  if (h == 7 || t == 7 || u == 7)
    printf("Yes\n");
  else
    printf("No\n");
  
  return 0;
}

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

using namespace std;

string S;
char r[10];
int pos;

int main(){
  cin>>S;
  for(int i=0;i<S.length();i++){
    if(S[i]=='B'){
      if(pos>0) pos--;
      continue;
    }
    r[pos]=S[i];
    pos++;
  }
  for(int i=0;i<pos;i++) cout<<r[i];
  cout<<"\n";
  return 0;
}

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

#ifdef DBG
void debug_(){ cout << endl; }
template<typename T, typename... Args>
void debug_(T&& x, Args&&... xs){
	cout << x << " "; debug_(forward<Args>(xs)...);
}
#define dbg(...) debug_(__VA_ARGS__);
#else
#define dbg(...) 
#endif

int main() {
	ios_base::sync_with_stdio(false);
	ll A, B, N;

	cin >> A >> B >> N;

	ll x = min(B-1, N);

	cout << A*x/B - A*(x/B) << endl;
	return 0;
}


Measured memory_bytes: 3640
if __name__ == '__main__':
    s = input()
    f = s[:2]
    t = s[2:]
    yymm = (int(t) <= 12 and int(t) != 0)
    mmyy = (int(f) <= 12 and int(f) != 0)
    if yymm and mmyy:
        print("AMBIGUOUS")
    elif yymm:
        print("YYMM")
    elif mmyy:
        print("MMYY")
    else:
        print("NA")

Measured memory_bytes: 3064
def min(a,b); a < b ? a : b; end

L, R = gets.split.map(&:to_i).map{|v| v.divmod(2019) }
if L[0] < R[0]
  puts 0
else
  puts (L[1] .. R[1]).to_a.combination(2).inject(2019){|s,(i,j)| break 0 if s.zero? ; min(s, (i * j) % 2019) }
end


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

using namespace std;

main(){
    int n, k;
    cin >> n >> k;
    int sum =0, num;
    for(int i=0;i<n;++i){
        scanf("%d",&num);
        int dis = num*2;
        dis = min(dis,abs(k-num)*2);
        sum += dis;
    }
    printf("%d\n",sum);
}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace AtCoder
{
    class Node
    {
        private readonly char item;
        public bool exists = true;
        public List<Node> edges = new List<Node>();
        public Node(char c)
        {
            item = c;
        }
        public bool Good()
        {
            return edges.Any(edge => edge.item == 'A')
                && edges.Any(edge => edge.item == 'B');
        }
    }
    class Program
    {
        static bool Solve(int N, Node[] nodes)
        {
            var q = new Queue<Node>();
            foreach (var node in nodes)
            {
                if (!node.Good()) { q.Enqueue(node); }
            }
            while (q.Count > 0)
            {
                var node = q.Dequeue();
                if (node.exists && !node.Good())
                {
                    for (int i = 0; i < node.edges.Count; ++i)
                    {
                        var child = node.edges[i];
                        child.edges.Remove(node);
                        q.Enqueue(child);
                    }
                    node.exists = false;
                }
            }
            return nodes.Any(node => node.exists);
        }
        static void Main(string[] args)
        {
            int[] V1 = Array.ConvertAll(Console.ReadLine().Split(), int.Parse);
            int N = V1[0];
            int M = V1[1];
            string s = Console.ReadLine();
            var nodes = new Node[N];
            for (int i = 0; i < N; ++i) { nodes[i] = new Node(s[i]); }
            for (int i = 0; i < M; ++i)
            {
                int[] V2 = Array.ConvertAll(Console.ReadLine().Split(), int.Parse);
                var a = nodes[V2[0] - 1];
                var b = nodes[V2[1] - 1];
                a.edges.Add(b);
                b.edges.Add(a);
            }
            Console.WriteLine(Solve(N, nodes) ? "Yes" : "No");
        }
    }
}


Measured memory_bytes: 44496
inputs_array = list(input())
check_dict = {}

is_words = False
is_two = True

for later in inputs_array:
  if later in check_dict:
    check_dict[later] += 1
  else:
    check_dict[later] = 1
    
for v in check_dict:
  if check_dict[v] == 2:
    continue
  else:
    is_two = False
    break

if len(check_dict) == 2:
  is_words = True
  
if is_words and is_two:
  print('Yes')
else:
  print('No')

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

int main()
{
  const int inf = 200;
  int h, w;
  cin >> h >> w;
  vector<vector<char>> grid(h + 1, vector<char>(w + 1));
  vector<vector<int>> z(h + 1, vector<int>(w + 1, inf));

  for (int y = 0; y < h; y++) {
    string s;
    cin >> s;
    for (int x = 0; x < w; x++) {
      grid[y][x] = s[x];
    }
  }

  z[0][0] = grid[0][0] == '.' ? 0 : 1;

  for (int y = 0; y < h; y++) {
    for (int x = 0; x < w; x++) {
      int t = grid[y][x] == '.' && grid[y][x + 1] == '#' ? 1 : 0;
      z[y][x + 1] = min(z[y][x + 1], z[y][x] + t);
      int u = grid[y][x] == '.' && grid[y + 1][x] == '#' ? 1 : 0;
      z[y + 1][x] = min(z[y + 1][x], z[y][x] + u);
    }
  }

  cout << z[h - 1][w - 1] << endl;
}


Measured memory_bytes: 256
import java.util.*;

public class Main {
	static class Test {
		long b, l, u;

		public Test(long b, long l, long u) {
			this.b = b;
			this.l = l;
			this.u = u;
		}
		
	}
	
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		long X = sc.nextInt();
		Test[] t = new Test[N];
		
		for(int i=0; i<N; i++)
			t[i] = new Test(sc.nextInt(), sc.nextInt(), sc.nextInt());
		
		Arrays.sort(t, new Comparator<Test>() {
			public int compare(Test t1, Test t2) {
				return - Long.compare((X-t1.b)*t1.u + t1.b*t1.l, (X-t2.b)*t2.u + t2.b*t2.l); 
			}
		});
		
		long[] v = new long[N];
		long[] sum = new long[N+1];
		for(int i=0; i<N; i++) {
			v[i] = t[i].b*t[i].l + (X-t[i].b)*t[i].u;
			sum[i+1] = sum[i] + v[i];
		}
		
		long aoki = 0;
		for(int i=0; i<N; i++) {
			aoki += t[i].b*t[i].l;
		}
		
		long ans = X*N;
		int border = Arrays.binarySearch(sum, aoki);
		if(border >= 0) {
			ans = X*border;
		} else {
			border = - border-1;
			for(int i=0; i<border; i++) {
				long rest = aoki-(sum[border]-v[i]);
				if(rest<=0) {
					ans = Math.min(ans, X*(border-1));
				} else if(rest<=t[i].b*t[i].l) {
					ans = Math.min(ans, X*(border-1) + (rest+t[i].l-1)/t[i].l);
				} else {
					rest -= t[i].b*t[i].l;
					ans = Math.min(ans, X*(border-1) + t[i].b + (rest+t[i].u-1)/t[i].u);
				}
			}
			for(int i=border; i<N; i++) {
				long rest = aoki-(sum[border-1]);
				if(rest<=t[i].b*t[i].l) {
					ans = Math.min(ans, X*(border-1) + (rest+t[i].l-1)/t[i].l);
				} else {
					rest -= t[i].b*t[i].l;
					ans = Math.min(ans, X*(border-1) + t[i].b + (rest+t[i].u-1)/t[i].u);
				}
			}
		}
		
		System.out.println(ans);
		sc.close();
	}
}


Measured memory_bytes: 98916
/*~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=
*$* WRITER:kakitamasziru/OxOmisosiru *$*
~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=*/
#ifdef LOCAL_JUDGE
#define _GLIBCXX_DEBUG
#endif
#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 <limits>//setprecision
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set,multiset
#include <stack> // stack
#include <deque> // deque
#include <math.h>//pow,,,
#include <cmath>//abs,,,
#include <bitset> // bitset
#include <numeric> //accumulate,,,
#define endl "\n";
using namespace std;

const long long INF = 4000000000000000001;
const int inf = 1001001001;
int MOD = 2019;
typedef pair<long long,long long> P;

void chmax(long long &a,long long b){if(a < b) a = b;}
void chmin(long long &a,long long b){if(a > b) a = b;}

//Solve N^M. This, mod_pow use Iterative Square Method.
long long mod_pow(long long N, long long M) {
    if (M == 0) return 1;
    long long res = mod_pow((N * N) % MOD, M / 2);
    //When end-of-a bit is 1, times simple N.
    if (M & 1) res = (res * N) % MOD;
    return res %= MOD;
}
long long gcd(long long a, long long b) {
    if (b == 0) return a; else return gcd(b, a % b);
}
long long lcm(long long a, long long b) {
    return a / gcd(a, b) * b ;
}



int main() {
    ios::sync_with_stdio(false);
    std::cin.tie(nullptr);
    
    int N;cin >> N;
    long long P;cin >> P;MOD = P;
    string S;cin >> S;
    if(P == 2){
        long long ans = 0;
        for(long long i = 0;i<N;i++){
            if((S.at(i)-'0') % 2 == 0){
                ans += (i+1);
            }
        }
        cout << ans << endl;
        return 0;
    }
    if(P == 5){
        long long ans = 0;
        for(long long i = 0;i<N;i++){
            if((S.at(i)-'0') == 5 || (S.at(i)-'0') == 0){
                ans += (i+1);
            }
        }
        cout << ans << endl;
        return 0;
    }
    reverse(S.begin(),S.end());
    map<int,long long> remainder;
    remainder[0] = 1;
    long long nowRemain = 0;
    for(long long i = 0;i<S.size();i++){
        long long A = S.at(i)-'0';
        long long now = (A*mod_pow(10,i) + nowRemain) % MOD;
        remainder[now]++;
        nowRemain = now;
        //cout << now << endl;
    }
    long long ans = 0;
    for(auto V : remainder){
        ans += (V.second*(V.second-1))/2;
    }
    cout << ans << endl;
}


Measured memory_bytes: 4092
import math, sys
from bisect import bisect_left, bisect_right
from collections import Counter, defaultdict, deque
from copy import deepcopy
from functools import lru_cache
from heapq import heapify, heappop, heappush
from itertools import accumulate, combinations, permutations
input = sys.stdin.readline
mod = 10**9 + 7
ns = lambda: input().strip()
ni = lambda: int(input().strip())
nm = lambda: map(int, input().split())
nl = lambda: list(map(int, input().split()))

def main():
    s = ns()
    
    if set(s) == set(['a', 'b', 'c']):
        print('Yes')
    else:
        print('No')


if __name__ == '__main__':
    main()

Measured memory_bytes: 3696
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using vb=vector<bool>;
using vvb=vector<vb>;
using vd=vector<double>;
using vvd=vector<vd>;
using vi=vector<int>;
using vvi=vector<vi>;
using vl=vector<ll>;
using vvl=vector<vl>;
using pll=pair<ll,ll>;
using tll=tuple<ll,ll>;
using vs=vector<string>;
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define rep(i,n) range(i,0,n)
#define range(i,a,n) for(ll i=(a);i<(n);i++)
#define LINF ((ll)1ll<<60)
#define INF ((int)1<<30)
#define EPS (1e-9)
#define MOD (1000000007ll)
#define fcout(a) cout<<setprecision(a)<<fixed
#define fs first
#define sc second
#define PI 3.1415926535897932384

int dx[]={1,0,-1,0,1,-1,-1,1},dy[]={0,1,0,-1,1,1,-1,-1};
template<class S,class T>ostream&operator<<(ostream&os,pair<S,T>p){os<<"["<<p.first<<", "<<p.second<<"]";return os;};
template<class S>auto&operator<<(ostream&os,vector<S>t){bool a=1; for(auto s:t){os<<(a?"":" ")<<s;a=0;} return os;}
template<class S>void tf(bool b,S t,S f){cout<<(b?t:f)<<endl;}
void OUT(bool b){tf(b,"YES","NO");}
void Out(bool b){tf(b,"Yes","No");}
void out(bool b){tf(b,"yes","no");}
template<class T>void puta(T&&t){cout<<t<<endl;}
template<class H,class...T>void puta(H&&h,T&&...t){cout<<h<<' ';puta(t...);}

int popcnt(int x){return __builtin_popcount(x);}
int popcnt(ll x){return __builtin_popcountll(x);}
int bsr(int x){return 31 - __builtin_clz(x);}
int bsr(ll x){return 63 - __builtin_clzll(x);}
int bsf(int x){return __builtin_ctz(x);}
int bsf(ll x){return __builtin_ctzll(x);}
template<class T>bool chmax(T&a,T b){if(a<b){a=b; return true;}return false;}
template<class T>bool chmin(T&a,T b){if(a>b){a=b; return true;}return false;}

/*他のライブラリを入れる場所*/

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	int n;
	cin>>n;
	set<int> s;
	rep(i,n){
		int t;cin>>t;
		s.insert(t);
	}
	cout<<s.size()<<endl;
	return 0;
}

Measured memory_bytes: 256
from fractions import gcd
import numpy as np


def get_primes(n):
    ans = 1
    m = int(n**0.5) + 1
    flags = np.zeros(m + 1, dtype=bool)
    for i in range(2, m + 1):
        if flags[i]:
            continue
        if n % i == 0:
            ans += 1
        while n % i == 0:
            n //= i
        flags[i:m + 1:i] = 1
    return ans + 1 if n > 1 else ans


def solve(string):
    a, b = map(int, string.split())
    g = gcd(a, b)
    return str(get_primes(g))


if __name__ == '__main__':
    print(solve(input()))


Measured memory_bytes: 14344
#include<stdio.h>
#include<stdbool.h>
#include<string.h>
#include<math.h>
#include<stdlib.h>
#define rep(i,n) for(int i=0; i <(n); i++)
int main(){
  int x,y;
  scanf("%d%d",&x,&y);
  if(y%2==0){
    if(y<=x*4&&y>=x*2){
      printf("Yes\n");
      return 0;
    }
  }

  printf("No\n");
  return 0;
}

Measured memory_bytes: 1664
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<ll,ll> P;
typedef pair<int,int> Pi;
#define rep(i,n) for(ll i=0;i<n;i++)
#define FOR(i,a,b) for(ll i=a;i<b;i++)
#define fi first
#define se second

template<typename T> inline bool chmax(T &a, T b){if(a<b){a=b;return true;}return false;}
template<typename T> inline bool chmin(T &a, T b){if(a>b){a=b;return true;}return false;}
template<typename T> ostream& operator<<(ostream& s,const complex<T>& d) {return s<<"("<<d.real()<<", "<<d.imag()<< ")";}
template<typename T1, typename T2> ostream& operator<<(ostream& s,const pair<T1,T2>& d) {return s<<"("<<d.first<<", "<<d.second<<")";}
template<typename T> ostream& operator<<(ostream& s, const vector<T>& d){int len=d.size();rep(i,len){s<<d[i];if(i<len-1) s<<" ";}return s;}
template<typename T> ostream& operator<<(ostream& s,const vector<vector<T>>& d){int len=d.size();rep(i,len){s<<d[i]<<endl;}return s;}
template<typename T> ostream& operator<<(ostream& s,const set<T>& v){s<<"{ ";for(auto itr=v.begin();itr!=v.end();++itr) {if (itr!=v.begin()) {s<< ", ";}s<<(*itr);}s<<" }";return s;}
template<typename T1, typename T2> ostream& operator<<(ostream& s,const map<T1,T2>& m){s<<"{"<<endl;for(auto itr=m.begin();itr!=m.end();++itr){s<<" "<<(*itr).first<<" : "<<(*itr).second<<endl;}s<<"}"<<endl;return s;}

const ll mod=1e9+7;
const ll inf=1e17;
const int INF=1e9;
const double PI=acos(-1);
const double EPS=1e-10;

struct state{
	ll w,s,v;
};

ll dp[1010][20010];

int main(){
	cin.tie(0);ios::sync_with_stdio(false);
	int n;
	cin>>n;
	vector<state> g(n);
	rep(i,n){
		cin>>g[i].w>>g[i].s>>g[i].v;
	}
	sort(begin(g),end(g),[](const state &a,const state &b){
		return a.w+a.s<b.w+b.s;
	});
	rep(i,n)rep(j,20010){
		dp[i+1][j]=dp[i][j];
		if(0<=j-g[i].w && j-g[i].w<=g[i].s){
			chmax(dp[i+1][j],dp[i][j-g[i].w]+g[i].v);
		}
	}
	cout<<*max_element(begin(dp[n]),end(dp[n]))<<endl;
	/*
	あるブロックの集合を決め打つと, s+wが小さい順に上から積んでいくのが最適
	(自分の位置以上の重さの上限を与えるものなので)
	あとはナップサック
	*/
}

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

#define debug(a) cout << #a << " " << a << endl;
#define _debug(a, i) cout << #a << "[" << i << "]" << " = " << a[i] << endl;
#define fastio ios_base::sync_with_stdio(false); \
			cin.tie(0);							     \
			cout.tie(0);
#define sz(arr) ll(arr.size())

using namespace std;

using ll = long long;
const ll MOD = 1e9 + 7;
const ll INF = 1e18 + 9;
const double PI = 4.0 * atan(1.0);

ll powmod(ll a, ll b, const ll MOD) { ll res = 1; a %= MOD; assert(b >= 0); for (; b; b >>= 1) { if (b & 1)res = res * a % MOD; a = a * a % MOD; } return res; }
ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }
ll lcm(ll a, ll b) { return (a * b) / gcd(a, b); }
ll modInverse(ll n, const ll p) { return powmod(n, p - 2, p); }
ll div_floor(ll a, ll b) { return a / b - (((a ^ b) < 0) and a % b); }
ll div_ceil(ll a, ll b) { return a / b + (((a ^ b) >= 0) and a % b); }
ll kCn(ll k, ll n, ll f[]) { return (f[n] * modInverse((f[n - k] * f[k]) % MOD, MOD)) % MOD; }



int main() {
	//#ifndef ONLINE_JUDGE
	//	(void)freopen("input.txt", "r", stdin);
	//	(void)freopen("output.txt", "w", stdout);
	//#endif // !ONLINE_JUDGE
	fastio;
	ll n;
	cin >> n;
	vector<ll> a(n), b(n);
	for (int i = 0; i < n; ++i) {
		cin >> a[i];
		b[i] = -a[i] - i;
		a[i] = a[i] - i;
	}
	ll ans = 0;
	map<ll, ll> mp;
	for (int i = 0; i < n; ++i) {
		ans += mp[a[i]];
		mp[b[i]]++;
	}

	cout << ans;
	return 0;
}


Measured memory_bytes: 29040
#include <iostream>
#include <cstdio>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>
#include <map>
#include <algorithm>
#include <limits.h>

#include <sstream>
using namespace std;

int main()
{
    int n, d;
    cin >> n >> d;
    int ans = 0;
    for (int i = 1; i <= n; i += 2 * d + 1) {
        ans++;
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
//PLUS ULTRA

#include<bits/stdc++.h>
using namespace std;
     
     
#define SPEED ios::sync_with_stdio(false); cin.tie(0); cout.tie(0)
#define pb push_back 
#define mp make_pair
#define forn(i,st,n) for(int i = st; i < n ; i++)
#define nfor(i,st,n) for(int i = st; i >= n ; i--)

typedef long long ll;
typedef pair <int , int> pii;

const int N = 1e5 + 10 , mod =  1000000007;



int main(){
    SPEED;
    int n; cin >> n;

    int h[n];

    forn(i,0,n){
  		cin >> h[i];

    }


    int dp[n];

    dp[0] = 0;
    dp[1] = abs(h[1] - h[0]);

    forn(i,2,n){
    	dp[i] = min(dp[i-1] + abs(h[i] - h[i-1]) , dp[i-2] + abs(h[i]- h[i-2]));
    }

    cout << dp[n-1] << endl;


    
    return 0;
}
      
       


Measured memory_bytes: 1024
#include <iostream>
#include <string.h>
using namespace std;
char c[200001];
long tmp,a[27],all,ans,longs;
int main()
{
	cin>>c;
	longs=strlen(c);
	for(int i=0;i<longs;i++)
	{
		tmp=c[i]-'a';
		ans+=all-a[tmp];
		all++,a[tmp]++;
	}
	cout << ans+1<<"\n";
}

Measured memory_bytes: 384
# include <iostream>
# include <algorithm>
# include <vector>
# include <string>
# include <set>
# include <map>
# include <cmath>
# include <iomanip>
# include <functional>
# include <utility>
# include <stack>
# include <queue>
# include <list>
# include <bitset>
# include <complex>
#include<limits.h>
#include<random>
#include<deque>
#include<cstdio>
#include<fstream>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
const int N = 2000100;
const int mod = (int)pow(10, 9) + 7;
const ll INF = 1LL << 60;
#define rep(i,n) for(ll i=(ll)0;i<(ll)n;++i)
#define ALL(x) x.begin(),x.end()
#define pp pair<ll,ll>
#define ppp pair<pp,ll>
#define fi first
#define se second
#define pb push_back
#define fix(n) fixed<<setprecision(n)
#define itr vector<ll>::iterator
#define print(s) cout<<s<<endl
#define inp(s) cin>>s
string yn(bool b) { return (b ? "Yes" : "No"); }
string YN(bool b) { return (b ? "YES" : "NO"); }
ll m, f, b;
int main(){
	cin >> m >>f >> b;
	if (m >= b)cout << 0 << endl;
	else if (m + f >= b)cout << b - m << endl;
	else cout << "NA" << endl;
	return 0;
}


Measured memory_bytes: 3100
#include<stdio.h>
int main(void)
{
	int g,d,c,j,i,n,m,a[1001],b[1001],e[1001],f,max,x,maxf,h;
	max=-1;
	maxf=0;
	scanf("%d %d",&n,&m);
	for(i=1;i<=n;i++){
		e[i]=0;
		scanf("%d",&a[i]);
	}
	for(j=1;j<=m;j++){
		scanf("%d",&b[j]);
	}
	for(d=1;d<=n;d++){
		for(h=1;h<=m;h++){
			if(a[h]<=b[d]){
				e[h]++;
				break;
			}
		}
	}
	for(f=1;f<=n;f++){
		if(e[f]>max){
			max=e[f];
			maxf=f;
		}
	}
	printf("%d\n",maxf);
	return 0;
}

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

int main(){
  int N;
  cin>>N;
  string U;
  double X;
  double ans=0;
  for(int i=0;i<N;i++){
    cin>>X;
    cin>>U;
    if(U=="BTC")ans+=X*380000;
    else ans+=X;
  }
 cout<<ans<<endl;
}


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

using namespace std;

int main()
{
    int n;
    cin >> n;
    int b[n+1];
    for(int i=1;i<n;i++){
        cin >> b[i];
    }
    b[0]=1000000;
    b[n]=1000000;
    int a[n];
    for(int i=0;i<n;i++){
        a[i]=min(b[i],b[i+1]);
    }
    int sum=0;
    for(int i=0;i<n;i++){
        sum+=a[i];
    }

    cout << sum << endl;
    return 0;
}


Measured memory_bytes: 256
package main

import (
	"bufio"
	"fmt"
	"io"
	"math"
	"os"
	"strconv"
)

var sc *bufio.Scanner
var writer io.Writer

func init() {
	sc = bufio.NewScanner(os.Stdin)
	writer = os.Stdout
	sc.Split(bufio.ScanWords)
}

func main() {
	solve()
}

func solve() {
	a, b := nextInt(), nextInt()
	res := math.Max(float64(a+b), math.Max(float64(a*b), float64(a-b)))
	fmt.Fprint(writer, res)
}

func nextWord() string {
	sc.Scan()
	str := sc.Text()
	return str
}

func nextInt() int {
	i, e := strconv.Atoi(nextWord())
	if e != nil {
		panic(e)
	}
	return i
}

Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
int main()
{
    long int a,b,c,d,e=0;
    cin>>a>>b>>c>>d;
    if(a>=d)
    {
        e=d;
        cout<<e;
        return 0;
    }
    else
    {
        d=d-a;
        e=e+a;
        if(b>=d)
        {
            cout<<e;
            return 0;
        }
        else
        {
            d=d-b;
            e=e-d;
            cout<<e;
            return 0;
        }
    }

}


Measured memory_bytes: 3608
#include<iostream>
#include<algorithm>
#include<vector>
#include<stack>
#include<queue>
#include<list>
#include<string>
#include<cstring>
#include<cstdlib>
#include<cstdio>
#include<cmath>
using namespace std;

const int NIL = -1;
const int MAX = 1 << 21;

struct Node {
	int node;
	Node* parent;
};

Node forests[10001];
int height[10001];

int findSet(int x) {
	vector<int>tree;
	while (forests[x].parent->node != forests[x].node) {
		tree.push_back(x);
		x = forests[x].parent->node;
	}
	for (vector<int>::iterator it = tree.begin(); it != tree.end(); it++)
		forests[*it].parent = &forests[x];
	return x;
}

void unite(int x, int y)
{
	int X, Y;
	X = findSet(x);
	Y = findSet(y);
	if (height[x] > height[y]) {
		forests[Y].parent = &forests[X];
	}
	else if (height[x] < height[y]) {
		forests[X].parent = &forests[Y];
	}
	else {
		forests[Y].parent = &forests[X];
		height[X]++;
	}
}

int main(void)
{
	int n, q, com, x, y;
	cin >> n >> q;
	for (int i = 0; i < n; i++) {
		forests[i].node = i;
		forests[i].parent = &forests[i];
	}
	for (int i = 0; i < q; i++) {
		cin >> com >> x >> y;
		if (com) {
			if (findSet(x) == findSet(y))
				cout << "1" << endl;
			else
				cout << "0" << endl;
		}
		else {
			unite(x, y);
		}
	}
	return 0;
}


Measured memory_bytes: 3364
n = int(input())
v = list(map(int,input().split()))

vo = [0] * (10**5 + 1)
ve = [0] * (10**5 + 1)

for i in range(n):
    if (i+1) % 2 == 0:
        ve[v[i]] += 1
    else:
        vo[v[i]] += 1
ve1 = sorted(ve, reverse = True)
vo1 = sorted(vo, reverse = True)
if vo.index(max(vo)) != ve.index(max(ve)):
    print(n - max(vo) - max(ve))
    
elif max(vo) > max(ve):    
    print(n - max(vo) - ve1[1])
elif max(vo) < max(ve):
    print(n - max(ve) - vo1[1])
else:
    print(n - max(vo) - max(ve1[1], vo1[1]))

Measured memory_bytes: 14268
#include<bits/stdc++.h>
using namespace std;
int n,a,b,c,d;
string s;
int dem;
int main(){
	cin>>n>>a>>b>>c>>d;
	cin>>s;
	s=" "+s;
	if(c<d)
	{
		for(int i=a;i<=d-1;i++)
		{
			if(s[i]==s[i+1]&&s[i]=='#')
			{
				cout<<"No";
				return 0;
			}
		}
		cout<<"Yes";
	}
	else
	{
		for(int i=a;i<c;i++)
		{
			if(s[i]==s[i+1]&&s[i]=='#')
			{
				cout<<"No";
				return 0;
			}
		}
		for(int i=b-1;i<=min(d-1,n-2);i++)
		{
			if(s[i]==s[i+1]&&s[i+2]==s[i]&&s[i]=='.')
			{
				dem++;
			}
		}
		if(dem>0)
		{

		cout<<"Yes";
		return 0;
		}
		cout<<"No";
	}
	
}

Measured memory_bytes: 772
#include <iostream>
using namespace std;
     
int sum(int a){
    int ans=0;
    for(int i=1;i<a+1;i++){
        ans += i;
    }
    return ans;
}
int main() {
    int a,b;
    cin >> a >> b;
    int ans = sum(b-a);
    
    cout << ans - b << endl;

}

Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
const int INF = 1e9;
const ll LINF = 1e18;
template<class S,class T> ostream& operator << (ostream& out,const pair<S,T>& o){ out << "(" << o.first << "," << o.second << ")"; return out; }
template<class T> ostream& operator << (ostream& out,const vector<T> V){ for(int i = 0; i < V.size(); i++){ out << V[i]; if(i!=V.size()-1) out << " ";} return out; }
template<class T> ostream& operator << (ostream& out,const vector<vector<T> > Mat){ for(int i = 0; i < Mat.size(); i++) { if(i != 0) out << endl; out << Mat[i];} return out; }
template<class S,class T> ostream& operator << (ostream& out,const map<S,T> mp){ out << "{ "; for(auto it = mp.begin(); it != mp.end(); it++){ out << it->first << ":" << it->second; if(mp.size()-1 != distance(mp.begin(),it)) out << ", "; } out << " }"; return out; }

/*
 <url:>
 問題文============================================================
 =================================================================
 解説=============================================================
 ================================================================
 */

ll solveA(){
    ll res = 0;
    ll A,B; cin >> A >> B;
    res = A*B - A - B + 1;
    return res;
}

// nの約数を列挙する
vector<ll> getdivisor(ll n){
    vector<ll> res;
    for(ll i = 1; i*i <= n;i++){
        if(n%i == 0) {
            res.push_back(i);
            if(n/i != i) res.push_back(n/i);
        }
    }
    sort(res.begin(),res.end());
    return res;
}
ll solveB(){
    ll res = 0;
    ll N; cin >> N;
    for(int i = 1; i <= N;i++){
        if(i%2 == 0) continue;
        if(getdivisor(i).size() == 8) res++;
    }
    return res;
}

ll solveC(){
    ll res = 0;
    string S; cin >> S; ll K; cin >> K;
    res = 1;
    ll onecnt = 0;
    for(int i = 0; S.length();i++){
        if(S[i] == '1'){
            onecnt++;
        }else{
            res = S[i] - '0';
            break;
        }
    }
    if(onecnt >= K) return 1;
    else return res;
}

ll solveD(){
    ll res = 0;
    ll N,M,Q; cin >> N >> M >> Q;
    vector<ll> L(M),R(M);
    vector<vector<ll>> G(N);
    for(int i = 0; i < M;i++){
        cin >> L[i] >> R[i]; L[i]--; R[i]--;
        G[L[i]].push_back(R[i]);
    }
    for(int i = 0; i < N;i++){
        sort(G[i].begin(),G[i].end());
    }
    while(Q--){
        ll p,q; cin >> p >> q;
        p--; q--;
        
        ll Ans = 0;
        for(ll x = p; x <= q;x++){
            Ans += (upper_bound(G[x].begin(), G[x].end(), q) - G[x].begin());
        }
        cout << Ans << endl;
    }
    return 0;
}
int main(void) {
    cin.tie(0); ios_base::sync_with_stdio(false);
    //cout << solveA() << endl;
    //cout << solveB() << endl;
    cout << solveC() << endl;
    //solveD();
    return 0;
}


Measured memory_bytes: 256
#include <cstdio>
#include <algorithm>
const int MAXN=1E5+10;
inline int input(int x=0) {
	return scanf("%d",&x),x;
}
int a[MAXN];
int main() {
	int N=input();
	for(int i=1;i<=N;++i) {
		a[input()]++;
	}
	int cns=0,cnr=0,cnf=0;
	for(int i=1;i<=1E5;++i) {
		if(a[i]>1)cns+=a[i]-1;
	}cnr=cns;cnf=N-cns;
	//cnr=4;
	while(cnr>=3)cnr=cnr/3+cnr%3;
	//printf(">>>%d\n",cnr);
	if(cnr==0||cnr==2) {
		printf("%d\n",std::max(cnf,1));
	}else{
		printf("%d\n",std::max(cnf-1,1));
	}
	return 0;
}

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

#define INF_LL (int64)1e18
#define INF (int32)1e9
#define REP(i, n) for(int64 i = 0;i < (n);i++)
#define FOR(i, a, b) for(int64 i = (a);i < (b);i++)
#define all(x) x.begin(),x.end()
#define fs first
#define sc second

using int32 = int_fast32_t;
using uint32 = uint_fast32_t;
using int64 = int_fast64_t;
using uint64 = uint_fast64_t;
using PII = pair<int32, int32>;
using PLL = pair<int64, int64>;

const double eps = 1e-10;

template<typename A, typename B>inline void chmin(A &a, B b){if(a > b) a = b;}
template<typename A, typename B>inline void chmax(A &a, B b){if(a < b) a = b;}

bool equation(string& s, int32& p, int32& v);
bool formula(string& s, int32& p, int32& v);

bool equation(string& s, int32& p, int32& v){
	bool l = formula(s, p, v);
	assert(s[p] == '=');
	p++;
	bool r = formula(s, p, v);
	return l==r;
}

bool formula(string& s, int32& p, int32& v){
	bool ret = 0;
	if(s[p] == '-'){
		p++;
		ret = !formula(s, p, v);
	}else if(s[p] == '('){
		p++;
		bool l = formula(s, p, v);
		char op = s[p++];
		if(op == '-') p++;
		bool r = formula(s, p, v);
		p++;
		if(op == '*')
			ret = l&r;
		else if(op == '+')
			ret = l|r;
		else
			ret = (!l || l&r);
	}else{
		char c = s[p++];
		if(c == 'T') return 1;
		if(c == 'F') return 0;
		return (v >> (c-'a'))&1;
	}
	return ret;
}

int main(void){
	string s;
	while(cin >> s && s != "#"){
		int32 p = 0;
		int32 mask = 0;
		REP(i, s.size()){
			if(isalpha(s[i]))
				mask |= 1 << (s[i]-'a');
		}
		bool res = 1;
		for(int32 i = mask;i >= 0;i--){
			i &= mask;
			p = 0;
			res = res&equation(s, p, i);
		}
		if(res)
			cout << "YES" << endl;
		else
			cout << "NO" << endl;
	}
}


Measured memory_bytes: 3256
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <map>
#include <cstring>
#include <string>
#include <vector>
#include <cmath>
#include <random>
#include <set>
#include <deque>
#include <queue>
#include <bitset>
#include <stack>

#define mod 1000000007
#define INF2 9999999999
#define INF (1<<30)
#define rep(i,n) for(int (i)=0; (i)<(n); (i)++)
//#define P pair<int, int>

using namespace std;
using ll = __int64_t;

int dx[] = {1, 0, -1, 0};
int dy[] = {0, 1, 0, -1};
int DX[] = {1, 1, 0, -1, -1, -1, 0, 1};
int DY[] = {0, -1, -1, -1, 0, 1, 1, 1};

void solve(){
  int x[3], k;
  rep(i, 3) cin >> x[i];
  cin >> k;

  sort(x, x+3);
  rep(i, k) x[2] = x[2]*2;

  cout << x[0]+x[1]+x[2] << endl;
}

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


Measured memory_bytes: 256
def get_long(a,b)
	return Math.sqrt(a**2+b**2)
end
def get_rad(a,b,c)
	return Math.acos((b**2+c**2-a**2)/(2*b*c))
end
gets.to_i.times{
	x1,y1,x2,y2,x3,y3 = gets.split.map(&:to_f)
	a = get_long(x2-x3,y2-y3)
	b = get_long(x3-x1,y3-y1)
	c = get_long(x1-x2,y1-y2)
	ar = get_rad(a,b,c)
	br = get_rad(b,a,c)
	cr = get_rad(c,a,b)
	sin2a = Math.sin(2 * ar)
	sin2b = Math.sin(2 * br)
	sin2c = Math.sin(2 * cr)
	r = a / (2*Math.sin(ar))
	px = (x1*sin2a+x2*sin2b+x3*sin2c)/(sin2a+sin2b+sin2c)
	py = (y1*sin2a+y2*sin2b+y3*sin2c)/(sin2a+sin2b+sin2c)
	printf("%.3f %.3f %.3f\n",px,py,r)
}

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

int main() {
    int N,A,B;
    cin >> N >> A >> B;
    int buf = 0;
    int amari = 0;
    int count = 0;
    int result = 0;

    for(int i=1;i<N+1;i++) {
        buf = i;
        count = 0;
        while(true) {
            amari = buf % 10;
            buf = (buf - amari)/10;
            count += amari;
            if(buf == 0) {
                break;
            }
        }
        if (A<=count and count <=B) {
            result += i;
        }
    }
    cout << result << endl;
}

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

using namespace std;
typedef vector<int> vii;
typedef long long ll;

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

ll lcm(ll a, ll b){
  return (a*b)/(gcd(a,b));
}

main(){
  ll n1,n2;
  cin >> n1 >> n2;
  string s1, s2;
  cin >> s1 >> s2;
  ll ans = lcm(n1,n2);
  map<ll,char> m;
  ll val = ans/s1.size();
  ll n = 0;
  while(n*val + 1LL <= ans){
    ll temp = n*val + 1LL;
    m[temp] = s1[n]; n++;
  }
  val = ans/s2.size();
  n = 0;
  while(n*val + 1LL <= ans){
    ll temp = n*val + 1LL;
    if(m.find(temp)!=m.end()){
      char a = m[temp];
      if(a!=s2[n]){
	cout << -1 << endl;
	return 0;
      }
    } else m[temp] = s2[n];
    n++;
  }
  cout << ans << endl;
}

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

int main(){
  string s;
  cin >> s;
  if(s == "Sunny") cout << "Cloudy"<< endl;
  else if(s == "Cloudy") cout << "Rainy" << endl;
  else cout << "Sunny" << endl;
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define f(i,a,b) for(register int i=a;i<=b;++i)
#define ff(i,a,b) for(register int i=a;i>=b;--i)
#define debug(x) cerr << #x << " : " << x << " " << endl
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef pair<string, string> pss;
const ll mod = 998244353;
const ull mod1 = 2e18 + 7;
const int inf = 0x3f3f3f3f;
const double tiaohe = 0.57721566490153286060651209;
ll oula(ll x) { ll res = x;f(i, 2, x / i) { if (x % i == 0) { res = res / i * (i - 1);while (x % i == 0) x /= i; } }if (x > 1) res = res / x * (x - 1);return res; }
ll quickmod(ll a, ll n, ll m) { ll s = 1;while (n) { if (n & 1) { s = s * a % m; }a = (a*a) % m;n = n / 2; }return s; }
ll gcd(ll a, ll b) { return b ? gcd(b, a%b) : a; }
void ex_gcd(ll a, ll b, ll &x, ll &y, ll &d) { if (!b) { d = a, x = 1, y = 0; } else { ex_gcd(b, a % b, y, x, d);y -= x * (a / b); } }
ll inv(ll t, ll p) { ll d, x, y;ex_gcd(t, p, x, y, d);return d == 1 ? (x % p + p) % p : -1; }
bool isPrime(ll x) { if (x == 2)return true;if (x % 2 == 0)return false;for (ll i = 2;i*i <= x;i++) if (x % i == 0)return false; return true; }
//double a = log(n) +tiaohe + 1.0 / (2 * n);
double eqa = (1 + sqrt(5.0)) / 2.0;
const int N = 1e5 + 5;
int t;
int a[N];
int main()
{
	//freopen("in.txt", "r", stdin);
	int n;
	string s;
	while (cin >> n >> s)
	{
		int ans = 1;
		f(i, 1, s.size() - 1)
		{
			if (s[i] != s[i - 1])ans++;
		}
		cout << ans << endl;
	}
	return 0;
}

Measured memory_bytes: 3768
using System;
using System.Collections;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Numerics;
using System.Text;
using System.Threading.Tasks;

namespace AtCorder
{
	public class Program
	{
		static void Main(string[] args)
		{
			var cin = new Scanner2();
			int n = cin.Int();
			long[] a = cin.ArrayLong(n);
			var set = new HashSet<long>();
			for (int i = 0; i < n; i++) {
				if (set.Contains(a[i])) {
					Console.WriteLine("NO");
					return;
				}

				set.Add(a[i]);
			}

			Console.WriteLine("YES");
		}
	}

	public class Scanner2
	{
		private readonly char[] delimiter_ = new char[] { ' ' };
		private readonly string filePath_;
		private readonly Func<string> reader_;
		private string[] buf_;
		private int index_;

		public Scanner2(string file = "")
		{
			if (string.IsNullOrWhiteSpace(file)) {
				reader_ = Console.ReadLine;
			} else {
				filePath_ = file;
				var fs = new StreamReader(file);
				reader_ = fs.ReadLine;
			}
			buf_ = new string[0];
			index_ = 0;
		}

		public string Next()
		{
			if (index_ < buf_.Length) {
				return buf_[index_++];
			}

			string st = reader_();
			while (st == "") {
				st = reader_();
			}

			buf_ = st.Split(delimiter_, StringSplitOptions.RemoveEmptyEntries);
			if (buf_.Length == 0) {
				return Next();
			}

			index_ = 0;
			return buf_[index_++];
		}

		public int Int() => int.Parse(Next());
		public long Long() => long.Parse(Next());
		public double Double() => double.Parse(Next());

		public int[] ArrayInt(int N, int add = 0)
		{
			int[] Array = new int[N];
			for (int i = 0; i < N; i++) {
				Array[i] = Int() + add;
			}
			return Array;
		}

		public long[] ArrayLong(int N, long add = 0)
		{
			long[] Array = new long[N];
			for (int i = 0; i < N; i++) {
				Array[i] = Long() + add;
			}
			return Array;
		}

		public double[] ArrayDouble(int N, double add = 0)
		{
			double[] Array = new double[N];
			for (int i = 0; i < N; i++) {
				Array[i] = Double() + add;
			}
			return Array;
		}

		public void Save(string text)
		{
			if (string.IsNullOrWhiteSpace(filePath_)) {
				return;
			}

			File.WriteAllText(filePath_ + "_output.txt", text);
		}
	}
}

Measured memory_bytes: 44876
#include<iostream>
#include<stdio.h>
#include<algorithm>
using namespace std;

int A[1000000], n;

int main(){
    cin >> n;
    
    for(int i = 0; i < n; i++) scanf("%d", &A[i]);
    
    int q, k, sum;
    cin >> q;
    sum = 0;
    for(int i = 0; i < q; i++){
        scanf("%d", &k);
        if(*(lower_bound(A, A+n, k)) == k) sum++;
    }
    
    cout << sum << endl;
}


Measured memory_bytes: 3528
#include<iostream>
#include<string>
#include<string.h>
#include<algorithm>
#include<stdio.h>
#include<cmath>
#include<vector>
#include<utility>
#include<stack>
#include<queue>
#include<list>
 
#define FOR(i, a, b) for(int i=(a);i<=(b);i++)
#define RFOR(i, a, b) for(int i=(a);i>=(b);i--)
#define MOD 1000000007
#define INF 1000000001;
 
using namespace std;
 
 
 
int main(void) {
	string s;
	int p;
 
	cin >> s;
	p = s.rfind("FESTIVAL");
	FOR(i, 0, p - 1) {
		cout << s[i];
	}
 
	cout << endl;
	return 0;
}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace _1_4_A_LinearSearch
{
    class Program
    {
        static void Main(string[] args)
        {
            var n = int.Parse(Console.ReadLine());
            var S = Console.ReadLine().Split(' ').Select(int.Parse).ToArray();
            var q = int.Parse(Console.ReadLine());
            var T = Console.ReadLine().Split(' ').Select(int.Parse).ToArray();

            var C = 0;
            for (int i = 0; i < q; i++)
            {
                if (S.Contains(T[i]))
                {
                    C++;
                }
            }
            Console.WriteLine(C);
        }
    }
}



Measured memory_bytes: 22472
using System;
using System.Diagnostics;
using System.IO;
using System.Text;
using System.Linq;
using System.Collections.Generic;

class Program
{
    const string Yes = "Yes";
    const string No = "No";
    const long Mod = 1000000007;
    static void Main(string[] args) {
#if DEBUG
        MyDebugger.Test(process, "../TextFile1.txt");
        //MyDebugger.Test(process, "../TextFile2.txt");
        //MyDebugger.MakeTestCase("../TextFile2.txt");
#else
        object ret = process(new StreamReader(Console.OpenStandardInput()));
        Console.WriteLine(ret);
#endif
    }

    static object process(TextReader input) {
        var spl = input.ReadLine().Split(' ');
        var k = int.Parse(spl[0]);
        var n = int.Parse(spl[1]);

        var aa = ToIntArray(input.ReadLine(), n);

        aa.Sort();

        List<long> xx = new List<long>();

        for(int i=0; i<n-1; i++) {
            xx.Add(Math.Abs(aa[i] - aa[i + 1]));
        }

        xx.Add(
            Math.Min(
                Math.Abs(aa[n-1] - aa[0]),
                Math.Abs(k - (aa[n-1] - aa[0]))
            ));

        long max = 0;
        int maxi = 0;
        for(int i=0; i<xx.Count; i++) {
            if(xx[i] > max) {
                max = xx[i];
                maxi = i;
            }
        }

        long sum=0;
        for(int i=0; i<xx.Count; i++) {
            if (i != maxi) sum += xx[i];
        }

        return sum;
    }
    static List<long> ToIntArray(string strs, int n) {
        var ret = new List<long>(n);
        var spl = strs.Split(' ');
        for (int i = 0; i < n; i++)
            ret.Add(long.Parse(spl[i]));
        return ret;
    }
}

Measured memory_bytes: 34396