akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <string>
#include <cstdlib>
#include <cstdio>
#include <queue>
#include <stack>
#include <list>
#include <utility>
#include <vector>
#include <set>
#include <algorithm>

#include <cmath>

using namespace std;
int in(){
    int temp;
    scanf("%d",&temp);
    return temp;
}


int main() {
    
    int N = in(); int K = in();
    
    vector<int> D = {0,1,2,3,4,5,6,7,8,9};
    
    for(auto i = 0; i<K; i++){
        
        auto it = find(D.begin(),D.end(),in());
        
        if (it != D.end()){
            D.erase(it);
        }
    }

    vector<int> v;
    queue<int> q;
    
    for(auto i : D){
        v.push_back(i);
        q.push(i);
    }
    
    int tempval = 0;
    int qs;
    while(tempval < N){
        qs = (int)q.size();
        for(auto i = 0; i < qs; i++){
            tempval = q.front();
            q.pop();
            for(auto d: D){
                v.push_back(tempval*10 +d);
                q.push(tempval*10 +d);
            }
        }
    }
    
    sort(v.begin(),v.end());
    
    cout << *lower_bound(v.begin(),v.end(),N) << endl;

    return 0;
    
}




Measured memory_bytes: 1016
#include <algorithm>
#include <cstdio>
#include <iostream>
#include <map>
#include <cmath>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
#include <stdlib.h>
#include <stdio.h>
#include <bitset>
#include <cstring>
#include <deque>
using namespace std;
#define FOR(I,A,B) for(int I = (A); I < (B); ++I)
#define CLR(mat) memset(mat, 0, sizeof(mat))
typedef long long ll;
bool dpR[4040][16010], dpU[4040][16010];
int main()
{
  ios::sync_with_stdio(false);
  cin.tie(0);
  string s; cin >> s;
  int x, y; cin >> x >> y;
  int sx = 0, sy = 0;
  vector<int> r, u;
  bool ud = false;
  int i = 0;
  bool start = true;
  while(i < s.length()) {
    if(s[i] == 'T') {
      ud = ud ^ 1;
      i++;
      start = false;
    }
    int cntF = 0;
    while(s[i] == 'F') {
      i++;
      cntF++;
    }
    if(ud) u.push_back(cntF);
    else {
      if(start) {
        sx = cntF;
        start = false;
      }
      else r.push_back(cntF);
    }
  }
 
  CLR(dpR);
  CLR(dpU);
  int cen = 8000;
  dpR[0][cen+sx] = true;
  dpU[0][cen] = true;
  FOR(i,0,r.size()) {
    FOR(j,0,16001) {
      if(dpR[i][j]) {
        dpR[i+1][j+r[i]] = true;
        dpR[i+1][j-r[i]] = true;
      }
    }
  }
  FOR(i,0,u.size()) {
    FOR(j,0,16001) {
      if(dpU[i][j]) {
        dpU[i+1][j+u[i]] = true;
        dpU[i+1][j-u[i]] = true;
      }
    }
  }
  bool ans = dpR[r.size()][x+cen] && dpU[u.size()][y+cen];
  if(ans) cout << "Yes" << endl;
  else cout << "No" << endl;
  return 0;
}

Measured memory_bytes: 126720
#include<bits/stdc++.h>
using namespace std;
int main()
{
  string s;
  string t;
  cin>>s>>t;
  int cnt=0;
  for(int i=0;i<3;i++)
    if(t[i]==s[i])
      cnt++;
  cout<<cnt<<'\n';
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cmath>

using namespace std;

int main(void){
    int a,b,c;
    while (cin>>a>>b>>c && a) {
        int x = 50001, y = 50001;
        for (int i = 0; i < 10001; i++) {
            int t = a*i+c;
            if (t % b == 0) {
                int j = t/b;
                if (i+j < x+y || (i+j==x+y && a*i+b*j < a*x+b*y)) x = i, y = j;
            }
            t = abs(c-(a*i));
            if (t % b == 0) {
                int j = t/b;
                if (i+j < x+y || (i+j==x+y && a*i+b*j < a*x+b*y)) x = i, y = j;
            }
        }
        cout << x << " " << y << endl;
    }
}

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

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

    int n = max(a,b);
    vector<int> ans;
    int count = 0;

    for (int i = 1; i < n + 1; ++i) {
        if(a % i == 0 && b % i == 0){
            ans.push_back(i);
            //print(ans[count]);
            count++;
        }
    }
    print(ans[count - k]);
}


Measured memory_bytes: 892
//https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8 より
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

macro_rules! input_inner {
    ($iter:expr) => {};
    ($iter:expr, ) => {};
    ($iter:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($iter, $t);
        input_inner!{$iter $($r)*}
    };
}

macro_rules! read_value {
    ($iter:expr, ( $($t:tt),* )) => {
        ( $(read_value!($iter, $t)),* )
    };
    ($iter:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()
    };
    ($iter:expr, chars) => {
        read_value!($iter, String).chars().collect::<Vec<char>>()
    };
    ($iter:expr, usize1) => {
        read_value!($iter, usize) - 1
    };
    ($iter:expr, $t:ty) => {
        $iter.next().unwrap().parse::<$t>().expect("Parse error")
    };
}

//

fn run() {
    input! {
        n: usize,
        a: [u32; n],
    }
    let mut a = a;
    a.sort();
    a.dedup();
    let ans = a.len();
    println!("{}", ans);
}

fn main() {
    run();
}



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

int main () {
  int n;
  cin >> n;
  vector<vector<int>> a(n,vector<int>(2));
  rep(i, n) {
    cin >> a.at(i).at(0);
    cin >> a.at(i).at(1);
  }
  rep(i, n - 2) {
    if(a.at(i).at(0) == a.at(i).at(1)) {
      if(a.at(i+1).at(0) == a.at(i+1).at(1)) {
        if(a.at(i+2).at(0) == a.at(i+2).at(1)) {
          cout << "Yes" << endl;
          return 0;
        }
      }
    }
  }
  cout << "No" << endl;
  return 0;
}

Measured memory_bytes: 3632
#include <stdio.h>

int main(){
	int i, n, m, c[100010], a, b, r[100010]={1};
	scanf("%d %d", &n, &m);

for(i=0;i<n;i++)
	c[i]=1;

	while(m--){
		scanf("%d %d", &a, &b);
		c[--b]++;
		c[--a]--;
		r[b]|=r[a];
		if(c[a]==0)
			r[a]=0;
	}

	for(i=m=0;i<n;i++)
		m+=r[i];

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

	return 0;
}

Measured memory_bytes: 896
#include <iostream>
#include <string>
#include <queue>
#include <vector>
#include <set>
#include <map>
#include <algorithm>
#include <utility>
#include <iomanip>

#define ll long long int
#define pb push_back
#define mk make_pair
#define pq priority_queue

using namespace std;
typedef pair<int, int> P;
typedef pair<ll, int> Pl;
const int inf = 1e9;
const ll linf = 1LL << 50;

int main(int argc, char const* argv[])
{
	int a, b;
	cin >> a >> b;
	cout << (a + b + 1) / 2 << endl;
	return 0;
}


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

using namespace std;

int main() {
    string s, read, red;
    cin >> s;
    
    red = s[0];
    int ans = 1;
    for (int i=1; i<s.size(); i++) {
        int next = 0;
        read = s[i];
        while (red == read && i+next < s.size()) {
            next++;
            read += s[i+next];
        }
        if (i+next < s.size())
            ans++;
        red = read;
        i += next;
    }

    cout << ans << endl;
}


Measured memory_bytes: 1336
N=int(input())
A=[int(n) for n in input().split()]
import sys

div=10**9+7

A.sort()

if N % 2 == 0:
    for i in range(int(N/2)):
        if A[2*i] != 2*i+1 or A[2*i+1] != 2*i+1:
            print (0)
            sys.exit() 
    print(2**int(N/2) % div)
if N % 2 == 1:
    if A[0]!=0:
        print(0)
        sys.exit()
    for i in range(int((N-1)/2)):
        if A[2*i+1] !=2*i+2  or A[2*i+2]!= 2*i+2:
            print(0)
            sys.exit()
    print(2**int((N-1)/2) % div)


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

struct RAQ{
private:
	struct Node{
		long long sum; long long buf;
		Node(long long s, long long b) : sum(s), buf(b){}
	};
	vector<Node> node;
	long long defval;
	int N;
	int n;
public:
	void init(int n, long long defval = 0){
		N = 1;
		while(N < n)N<<=1;
		this->n = n;
		this->defval = defval;
		node.assign(N*2-1, Node(defval, 0));
	}
	long long query(int a, int b, int l = 0, int r = -1, int i = 0){
		if(r == -1) r = N;
		if(b <= l || r <= a) return defval;
		if(a <= l && r <= b) return node[i].sum;
		int rag = min(r, b) - max(l, a);
		return query(a,b,l,(l+r)/2,i*2+1) + query(a,b,(l+r)/2,r,i*2+2) + node[i].buf * rag;
	}
	void update(int a, int b, long long v, int l = 0, int r = -1, int i = 0){
		if(r == -1) r = N;
		if(b <= l || r <= a) return;
		if(a <= l && r <= b) { node[i].buf += v; node[i].sum += v * (r-l); return; }
		
		update(a,b,v,l,(l+r)/2,i*2+1);
		update(a,b,v,(l+r)/2,r,i*2+2);

		node[i].sum = node[i*2+1].sum + node[i*2+2].sum + node[i].buf * (r-l);
	}

};


int main() {
	int n, q; cin >> n >> q;
	RAQ tr; tr.init(n, 0);

	vector<long long> ans;

	for(int i = 0; i < q; i++){
		int c; cin >> c;
		if(c == 0){
			int s,t,x; cin >> s >> t >> x;
			tr.update(s-1, t, x);
		}
		else {
			int s, t; cin >> s >> t;
			ans.push_back(tr.query(s-1, t));
		}
	}

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

    return 0;
}



Measured memory_bytes: 7964
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
int main(){
	ll n; cin >> n;
	ll po[n + 1][3];
	for(ll i = 1; i <= n; i++) cin >> po[i][0] >> po[i][1] >> po[i][2];
	po[0][0] = po[0][1] = po[0][2] = 0;
	for(ll i = 1; i<= n; i++){
		ll dt = (ll)abs(po[i][0] - po[i - 1][0]);
		ll dx = (ll)abs(po[i][1] - po[i - 1][1]);
		ll dy = (ll)abs(po[i][2] - po[i - 1][2]);
		if(!(dx + dy <= dt && (dt - dx - dy) % 2 == 0)){
			cout << "No\n";
			return 0;
		}
	}
	cout << "Yes\n";
	return 0;
}

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

namespace ConsoleApp1
{
    class Program
    {
        static void Main(string[] args)
        {
            var ABCD = Console.ReadLine().Split(' ').Select(s=>int.Parse(s)).ToArray();
            var A = ABCD[0];
            var B = ABCD[1];
            var C = ABCD[2];
            var D = ABCD[3];
            var result = Math.Max(0,Math.Min(B, D) - Math.Max(A, C));
            Console.WriteLine(result);
        }
    }
}


Measured memory_bytes: 13268
#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

typedef long long ll;
typedef pair<ll, ll> P;

#define MOD 1000000007
#define REP(i, N) for (int i = 0; i < N; ++i)
#define REP1(i, N) for (int i = 1; i <= N; ++i)
#define RREP(i, N) for (int i = N - 1; i >= 0; --i)
#define ALL(a) a.begin(), a.end()

int main()
{
  string s;
  cin >> s;
  int N = s.size();
  int ans = 0;
  REP(i, N)
  {
    if (i % 2 == 0 && s[i] == 'p')
      ans--;
    else if (i % 2 == 1 && s[i] == 'g')
      ans++;
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 512
import java.util.*;

public class Main {
    public static void main(String[] args)
    {
        Scanner s = new Scanner(System.in);
        StringTokenizer st = new StringTokenizer(s.nextLine());
        int K = Integer.parseInt(st.nextToken());
        int N = Integer.parseInt(st.nextToken());
        st = new StringTokenizer(s.nextLine());
        int[] houses = new int[N+1];
        for(int i=0;i<N;i++)
        {
            houses[i] = Integer.parseInt(st.nextToken());
        }
        houses[N] = K + houses[0];
        int distance = Integer.MAX_VALUE;
        for(int i=0;i<N;i++)
        {
            int start = houses[i];
            int end = houses[i+1];
            int d = K - (Math.abs(start - end));
            distance = Math.min(distance, d);
        }
        System.out.println(distance);
    }
}


Measured memory_bytes: 53280
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<set>
#include<map>
#include<queue>
#define REP(i,a) for (int i = 0;i < (a);++i)
#define FOR(i,a,b) for (int i = (a);i < (b); ++i)
#define FORR(i,a,b) for (int i = (a);i >= (b); --i)
#define ALL(obj) (obj).begin(),(obj).end()
#define SORT(list) sort(ALL((list)));
#define MOD 1000000007
using namespace std;
using ll = long long;
int main(){
    int n;
    cin >> n;
    vector<int>a(n);
    REP(i,n)cin >> a[i];

    REP(i,n){
        if(a[i]%2 == 0){
            if(a[i]%3 != 0 && a[i]%5 != 0){
                cout << "DENIED" << endl;
                return 0;
            }
        }
    }

    cout << "APPROVED" << endl;

    return 0;
}

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

long long a[100000];
int cnt[41];

int main() {
	int n;
	long long k;

	scanf("%d %lld", &n, &k);

	for (int i = 0;i < n;++i)
		scanf("%lld", &a[i]);

	for (int i = 0;i < n;++i)
		for (int j = 40;j >= 0;--j)
			if (((1LL << j) & a[i]) == 0)
				cnt[j]++;

	long long tot1 = 0, tot2 = 0;
	bool chk = false;
	for (int i = 40;i >= 0;--i) {
		if ((tot1 | (1LL << i)) <= k && cnt[i] >= n - cnt[i])
			tot1 |= 1LL << i;
		if (chk && (tot2 | (1LL << i)) <= k && cnt[i] >= n - cnt[i])
			tot2 |= 1LL << i;
		if (k >= (1LL << i))
			chk = true;
	}

	long long ans1 = 0, ans2 = 0;
	for (int i = 0;i < n;++i) {
		ans1 += tot1 ^ a[i];
		ans2 += tot2 ^ a[i];
	}

	printf("%lld", std::max(ans1, ans2));

	return 0;
}


Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
int n,m;
int main()
{
	int N;
	cin>>N;
	int res=0;
	for(int i=2;i<55556;i++){
		int cnt = 0;
		for(int j=2;j<i;j++){
			if(i%j == 0) cnt++;
		}
		if(cnt == 0 && i%5 == 1){
			cout << i << endl;
			res++;
			if(res == N) break;
		}
	}
    return 0;
}


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

using namespace std;

int a[302] = {};
double dp[302][302][302] = {};
double p[302][302][302] = {};
double add[302][302][302] = {};

int main() {
	
	int i,j,k;
	int N;
	
	cin >> N;
	for( i=1; i<=N; i++) {
		cin >> a[i];
	}
	
	int cnt[4] = {};
	for( i=1; i<=N; i++) {
		cnt[ a[i] ]++;
	}
	
	p[ cnt[1] ][ cnt[2] ][ cnt[3] ] = 1;
	for( i= N; i>=0; i--) {
		for( j= N; j>=0; j--) {
			for( k= N; k>=0; k--) {
				if( k > 0)
					p[k-1][j][i] += p[k][j][i] * (double) k / (k+j+i);
				if( j > 0)
					p[k+1][j-1][i] += p[k][j][i] * (double) j / (k+j+i);
				if( i > 0)
					p[k][j+1][i-1] += p[k][j][i] * (double) i / (k+j+i);
			}
		}
	}
	
	for( i= N; i>=0; i--) {
		for( j= N; j>=0; j--) {
			for( k= N; k>=0; k--) {
				double pt = 0;
				dp[k][j][i] += ( dp[k+1][j][i] + (double) N / (k+1+j+i) ) * p[k+1][j][i] * (k+1) / (k+1+j+i);
				pt += p[k+1][j][i] * (k+1) / (k+1+j+i);
				if( k > 0) {
					dp[k][j][i] += ( dp[k-1][j+1][i] + (double) N / (k+j+i) ) * p[k-1][j+1][i] * (j+1) / (k+j+i);
					pt += p[k-1][j+1][i] * (j+1) / (k+j+i);
				}
				if( j > 0) {
					dp[k][j][i] += ( dp[k][j-1][i+1] + (double) N / (k+j+i) ) * p[k][j-1][i+1] * (i+1) / (k+j+i);
					pt += p[k][j-1][i+1] * (i+1) / (k+j+i);
				}
				
				if( pt == 0)
					continue;
				dp[k][j][i] /= pt;
//				dp[k][j][i] += (double) N / (k+j+i);
			}
		}
	}
	double ans = dp[0][0][0];
//	while(1) {
//		int q1, q2, q3, q4;
//		scanf("%d %d %d", &q1, &q2, &q3);
//		printf(">>> p = %.15f, dp = %.15f\n", p[q1][q2][q3], dp[q1][q2][q3]);
//	}
	
	printf("%.15f\n", ans);
	
	return 0;
} 

Measured memory_bytes: 433344
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <math.h>
int main(void){
   int i,j;
   char S[11],T[11],U[11];
   int A,B;
   
    scanf("%s %s",S,T);
    scanf("%d",&A);
    scanf("%d",&B);
    scanf("%s",U);
    
   if(strcmp(S,U)==0){
    A=A-1;
  }
  if(strcmp(T,U)==0){
    B=B-1;
  }
   printf("%d %d\n",A,B);
 
    return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
#define fi first
#define se second
#define rep(i, s, n) for (int i = (s); i < (n); ++i)
#define rrep(i, n, g) for (int i = (n)-1; i >= (g); --i)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define len(x) (int)(x).size()
#define dup(x, y) (((x) + (y)-1) / (y))
#define pb push_back
#define Field(T) vector<vector<T>>
using namespace std;
using ll = long long;
using P = pair<int, int>;

int main() {
  int x;
  cin >> x;
  if(x == 7 || x == 5 || x == 3) cout << "YES" << endl;
  else cout << "NO" << endl;
}

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

#define REP(i, n) for(int i = 0; i < n; ++i)
#define rREP(i, n) for(int i = n-1; i >= 0; --i)

using namespace std;

int main()
{
    int N, A, B;
    cin >> N >> A >> B;

    int num = 0;

    REP(i, N+1){

        int tmp1 = i, tmp2 = i, cnt = 0;

        while (tmp1 != 0) {
            cnt += tmp1 % 10;
            tmp1 /= 10;
        }
        
        if (A <= cnt && cnt <= B)
            num += tmp2;
    }
    cout << num << endl;
}

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

using namespace std;
typedef long long ll;
#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define FOR(i, a) for (int i = 0; i < (a); i++)

const int N = int(1e8) + 7;

void init(){

}

void solve(){
    char c[4];
    scanf("%s", c);
    if(c[0] == c[1] || c[1] == c[2] || c[2] == c[3])
        puts("Bad");
    else puts("Good");
}

const bool mtc = false;

int main(){
    int t;
    if(mtc){
        scanf("%d", &t);
        while(t--) solve();
    }
    else solve();
}



Measured memory_bytes: 256
/*
ID: learnin7
TASK: test
LANG: C++                 
*/
/* LANG can be C++11 or C++14 for those more recent releases */
#include<bits/stdc++.h>

using namespace std;
typedef long long ll;

int main(){
        
    ios_base::sync_with_stdio(0);
    //ofstream fout ("test.out");
    //ifstream fin ("test.in");
    //fin >> a >> b;
    //fout << a+b << endl;
    string s;
    cin>>s;
    int n = s.length();
    n -= 2;
    while(n>=2){
        int m = n/2;
        string res1 = "", res2="";
        for(int i=0;i<m;i++)   res1 += s[i];
        for(int i=m;i<n;i++)   res2 += s[i];
        
        if(res1==res2){
            cout<<n<<endl;
            return 0;
        }
        n -= 2;
    }
    return 0;
}



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

int main(){
    int n;
    bool m[51][51];
    while(cin>>n&&n!=0){
        set<int> schedules[101];    
        //for(int i = 0; i < 101; i++)
        //    schedules[i].clear();
        for(int i = 0; i < n; i++){
            int t;
            cin>>t;
            for(int j = 0; j < t; j++){
                int p;
                cin>>p;
                schedules[i].insert(p);
            }
        }
        // ツつサツづェツつシツづェツつェツつ「ツづ慊づづ個地ツ図ツづーツ篠敖づづつ「ツづゥツつゥ
        memset(m,0,sizeof(m));
        for(int i = 0; i < n; i++)
            m[i][i]=true;
        int idx=31;
        for(int i = 1; i <= 30; i++){
            vector<int> v;
            set<int> s;
            for(int j = 0; j < n; j++){
                if(schedules[j].find(i)!=schedules[j].end()){
                    v.push_back(j);
                    for(int k = 0; k < n; k++){
                        if(m[j][k])
                            s.insert(k);
                    }
                }
            }
            if(s.size()==n){
                idx=i;
                break;
            }
            for(set<int>::iterator it = s.begin(); it!=s.end(); it++)
                for(int j = 0; j < v.size(); j++)
                    m[v[j]][*it]=true;
            v.clear();
            s.clear();
        }
        if(idx==31)
            cout<<-1<<endl;
        else
            cout<<idx<<endl;
    }

    return 0;
}

Measured memory_bytes: 956
#include<bits/stdc++.h>
using namespace std;
#define ll long long 
// memo  fixed  setprecision(20);
using vvll = vector<vector<ll>>;
ll mod =1e9+7;
/*"itob" int to "N"base */           template<typename TypeInt> string itob(const TypeInt v, int base){static const char table[] = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ";string ret;static numeric_limits<TypeInt> t;TypeInt n = v;if (t.is_signed) {if (v < 0) n *= -1;}while (n >= base) {ret += table[n%base];n /= base;}ret += table[n];if (t.is_signed) {if (v < 0 && base == 10) ret += '-';}reverse(ret.begin(), ret.end());return ret;}
/*"chmin" a = MAX*/                  template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
/*"chmax" a = MIN*/                  template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
/*"ctoi"  char to int*/              int ctoi(char c) {return c-'0';}
/*"gcd"   MAX Euclidean */           ll gcd(ll a,ll b){if(b==0)return a; return gcd(b,a%b);}
/*"lcm"   MIN*/                      ll lcm(ll a,ll b){ll g = gcd(a,b);return a/g*b;}
/*"primecheck"If prime,return true.*/bool primecheck(ll n){if(n < 2) return false;else{for(int i = 2; i * i <= n; i++){if(n % i == 0) return false;}return true;}}
string  reverserange(string s,ll a,ll b){reverse(s.begin()+a-1,s.begin()+b); return s;}
ll modpow(ll a,ll n, ll mod){ll res = 1;while(n>0){if (n%2==1){res = res * a % mod;}a = a * a % mod;n/=2;}return res;}
ll ncd(ll n,ll d){
    ll x = 1,y=1;
    if(d<0||d>n)return 0;
    for(int i=0;i<d;i++){
        x = x*(n-i)%mod;
        y = y*(i+1)%mod;
    }
    return x*modpow(y,mod-2,mod)%mod;
}
int main() {
    ll n,a,b;
    cin >> n >> a >> b;
    ll ans = modpow(2,n,mod)-1 -ncd(n,a)-ncd(n,b);

    while(ans<0){
        ans+=mod;
    }
    ans%=mod;
    cout <<ans <<endl;
}
    



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

int main() {
  int n;
  cin >> n;
  vector<int> v(n);
  for (int i = 0; i < n; i++) {
    cin >> v.at(i);
  }
  
  sort(v.begin(), v.end());
  
  reverse(v.begin(), v.end());
  
  int count = 0;
  
  for (int i = 0; i < n - 2; i++) {
    for (int j = i + 1; j < n - 1; j++) {
      if (v.at(i) == v.at(j))
        continue;
      for (int k = j + 1; k < n; k++) {
        if (v.at(k) == v.at(j))
          continue;
        
        if (v.at(i) < v.at(j) + v.at(k))
          count++;
        else
          break;
      }
    }
  }
  cout << count << endl;
}


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

int main() {
    int n;
    cin >> n;
    
    int a[n];
    for(int i = 0; i < n; i++) {
        cin >> a[i];
    }
    
    int sum = 0;
    for(int i = 0; i < n; i++) {
        while(a[i] % 2 == 0) {
            a[i] /= 2;
            sum++;
        }
    }
    
    cout << sum << endl;
}


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

using namespace std;

typedef long long ll;

const ll INF = 10000000000000000;

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll n, e, t;
    cin >> n >> e >> t;
    vector<ll> x(n);
    for (int i = 0; i < n; i++) cin >> x[i];
    ll ans = e;
    vector<ll> dp(n + 1, INF);
    dp[0] = 0;
    vector<ll> dp2(n + 1, INF);
    for (int i = 1; i <= n; i++) {
        dp2[i] = min(dp2[i - 1], dp[i - 1] - x[i - 1] * 2);
        int j = upper_bound(x.begin(), x.begin() + i, (2 * x[i - 1] - t) / 2) - x.begin();
        dp[i] = min(dp[j] + t, 2 * x[i - 1] + dp2[j]);
    }
    ans += dp[n];                    
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 2688
#include <bits/stdc++.h>
using namespace std;
#define REP(i,a,n) for(int i=(a); i<(int)(n); i++)
#define rep(i,n) REP(i,0,n)
#define FOR(it,c) for(__typeof((c).begin()) it=(c).begin(); it!=(c).end(); ++it)
#define ALLOF(c) (c).begin(), (c).end()
typedef long long ll;
typedef unsigned long long ull;

ll dp[100105];

int main(){
  int N, K;
  cin >> N >> K;
  vector<int> v;
  rep(i,N){
    int h;
    cin >> h;
    v.push_back(h);
  }

  rep(i,100105) dp[i] = (ll)(1e15);
  dp[0] = 0;
  rep(i,N){
    REP(j,1,K+1){
    dp[i+j] = min(dp[i+j], dp[i] + abs(v[i+j]-v[i]));
    }
  }

  cout << dp[N-1] << endl;
  
  return 0;
}


Measured memory_bytes: 1528
H, W = map(int, input().split())
A = [[0 if x == "." else 1 for x in input()] for _ in range(H)]
A = [a for a in A if sum(a) != 0]
W_cut = [w for w in range(W) if sum([a[w] for a in A]) == 0]
for a in A:
    line = ""
    for w in range(W):
        if w in W_cut:
            continue
        line += "." if a[w] == 0 else "#"
    print(line)


Measured memory_bytes: 3060
MOD = 10**9+7

N, K = map(int, input().split())
A = list(map(int, input().split()))
A.sort()

f = [1]
for i in range(10**5):
    f.append(f[-1] * (i+1) % MOD)

def nCr(n, r, mod=MOD):
    return f[n] * pow(f[r], mod-2, mod) * pow(f[n-r], mod-2, mod) % mod

ans = 0
for i in range(N-K+1):
    ans -= (A[i] - A[-1-i]) * nCr(N-1-i, K-1)
    ans %= MOD

print(ans)


Measured memory_bytes: 14416
import java.util.Scanner;

public class Main {

	public static void main(String[] args) throws Exception {

		Scanner sc = new Scanner(System.in);
	    StringBuilder out;

		int n = sc.nextInt();
		int[] a = new int[n];

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

		sort(a);

	}

	static void sort(int[] a) {

		printArray(a);

		for(int i = 1; i < a.length; i++ ) {

			int v = a[i];
			int j = i - 1;

			while(j >= 0 && a[j] > v) {
				a[j + 1] = a[j];
				j--;
			}

			a[j + 1] = v;
			printArray(a);

		}

	}

	static void printArray(int[] a) {

		for(int i = 0; i < a.length - 1; i++) {
			System.out.print(a[i] + " ");
		}

		System.out.println(a[a.length - 1]);
	}
}


Measured memory_bytes: 35048
// AOJ 2195: Cat Numbers!
// 2017.12.10

#include <stdio.h>
#include <stdlib.h>

int f[17][10] = {{0},
{2,5,3},
{2,5,3,11},
{2,5,3,37},
{2,5,3,11,101},
{2,5,3,41,271},
{2,5,3,7,11,13,37},
{2,5,3,239,4649},
{2,5,3,11,73,101,137},
{2,5,3,37,333667},
{2,5,3,11,41,271,9091},
{2,5,3,21649,513239},
{2,5,3,7,11,13,37,101,9901},
{2,5,3,53,79,265371653},
{2,5,3,11,239,4649,909091},
{2,5,3,31,37,41,271,2906161},
{2,5,3,11,17,73,101,137,5882353}};

int p[17][10] = {{0},
{1,1,2},
{2,2,2,1},
{3,3,3,1},
{4,4,2,1,1},
{5,5,2,1,1},
{6,6,3,1,1,1,1},
{7,7,2,1,1},
{8,8,2,1,1,1,1},
{9,9,4,1,1},
{10,10,2,1,1,1,1},
{11,11,2,1,1},
{12,12,3,1,1,1,1,1,1},
{13,13,2,1,1,1},
{14,14,2,1,1,1,1},
{15,15,3,1,1,1,1,1},
{16,16,2,1,1,1,1,1,1}};

long long fp[17][10] = {{0},
{2, 5, 9},
{4, 25, 9, 11},
{8, 125, 27, 37},
{16, 625, 9, 11, 101},
{32, 3125, 9, 41, 271},
{64, 15625, 27, 7, 11, 13, 37},
{128, 78125, 9, 239, 4649},
{256, 390625, 9, 11, 73, 101, 137},
{512, 1953125, 81, 37, 333667},
{1024, 9765625, 9, 11, 41, 271, 9091},
{2048, 48828125, 9, 21649, 513239},
{4096, 244140625LL, 27, 7, 11, 13, 37, 101, 9901},
{8192, 1220703125LL, 9, 53, 79, 265371653LL},
{16384, 6103515625LL, 9, 11, 239, 4649, 909091},
{32768, 30517578125LL, 27, 31, 37, 41, 271, 2906161},
{65536, 152587890625LL, 9, 11, 17, 73, 101, 137, 5882353}};

long long tens[17];

int a, b;

typedef struct { long long A, B; } T;
T ans[500]; int sz;

int cmp(T *a, T *b)
{
	if (a->A - b->A) { if (a->A < b->A) return -1; else return 1; }
	if (a->B < b->B) return -1;
	return 1;
}

void check(long long x, long long y)
{
	long long A, B;

	A = x+y+1, B = y-x+1;
	if ((A & 1) || (B & 1)) return;
	A = (A >> 1) - tens[b];
	if (A < tens[a-1] || A >= tens[a]) return;
	B >>= 1;
	if (B < tens[b-1] || B >= tens[b]) return;

	ans[sz].A = A, ans[sz++].B = B;
}

void rec(int k, long long x, long long y)
{

	int i;
	long long s, t;

	if (!f[b][k]) {
		if (x >= tens[b-1])	check(x, y);
		return;
	}
	rec(k+1, x, y);
	s = fp[b][k], t = f[b][k];
	rec(k+1, x, y*s);
	for (i = 0; i < p[b][k]; i++) {
		x *= t;
		s /= t;
		if (x >= tens[b]) break;
		rec(k+1, x, y*s);
	}
}

int main()
{
	int cno, i;
	long long x;

	for (x = 1, i = 0; i <= 16; i++, x *= 10) tens[i] = x;

    scanf("%d", &cno);
	while (cno--) {
		scanf("%d%d", &a, &b);
		sz = 0;
		rec(0, 1, 1);

		qsort(ans, sz, sizeof(T), cmp);
		if (!sz) puts("No cats.");
		else for (i = 0; i < sz; i++) printf("%lld %lld\n", ans[i].A, ans[i].B);
	}
	return 0;
}

Measured memory_bytes: 1780
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
const ll MOD=1000000007;
const ll MOD2=998244353;
const double PI=acos(-1);
const ll INF=1e18;
typedef pair<ll,ll> P;
typedef vector<ll> vl;
typedef vector<vl> vvl;
#define FOR(i,a,b) for(ll i=a;i<b;i++)
#define rep(i,n) FOR(i,0,n)
string abc="abcdefghijklmnopqrstuvwxyz";
string ABC="ABCDEFGHIJKLMNOPQRSTUVWXYZ";
struct edge{ll to,cost;};

ll q(ll a,ll b){
    cout << "? " << a << " " << b << endl;
    cout.flush();
    ll d;
    cin >> d;
    return d;
}

int main() {
    ll n;
    cin >> n;
    ll x,c,mx=0;
    if(n==1){
        cout << "! 1"<< endl;
    }
    else{
    rep(i,n-1){
        x=q(1,i+2);
        if(mx<x){
            mx=x;
            c=i+2;
        }
    }
    vl ans(n);
    ans[0]=c;
    rep(i,n){
        if(i+1==c){
            continue;
        }
        else{
            x=q(i+1,c);
            ans[x]=i+1;
        }
    }
    cout << "!";
    rep(i,n){
        cout << " " << ans[i];
    }
    cout << endl;
    }
}






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

int main(){
	int n,a,b,c,r;
	
	while(cin >> a >> b >> c && a || b || c){
		vector<int>part(a+b+c+1,0);
		int d[1000][4];
		cin >> n;
		for(int i=0;i<n;i++){
			cin >> d[i][0] >> d[i][1] >> d[i][2] >> d[i][3];
		}
		for(int k=0;k<n;k++){
			for(int i=0;i<n;i++){
				if(d[i][3]){
					part[ d[i][0] ] = part[ d[i][1] ] = part[ d[i][2] ] = 1;
				}else{
					//cout <<d[i][0] << " " << d[i][1] << " " << d[i][2] << endl;	
					if(	 part[ d[i][1] ]>0 && part[ d[i][2] ]>0)part[ d[i][0] ]=-1;
					else if(part[ d[i][0] ]>0 && part[ d[i][2] ]>0)part[ d[i][1] ]=-1;
					else if(part[ d[i][0] ]>0 && part[ d[i][1] ]>0)part[ d[i][2] ]=-1;
				}
			}
		}
				
		for(int i=1;i<part.size();i++){
			if(part[i]==0)cout << 2;
			if(part[i]==-1)cout << 0;
			if(part[i]==1)cout << 1;
			cout << endl;
		}
	}
}

Measured memory_bytes: 0
using System;
using System.IO;
using System.Linq;
using System.Text;
using System.Collections.Generic;
using System.Diagnostics;
using Enu = System.Linq.Enumerable;

public class Program
{
    public void Solve()
    {
        var S = Reader.String();
        long N = S.Length;
        long ans = N * (N - 1) / 2;
        var count = new int[256];
        foreach (var c in S) count[c]++;
        foreach (var c in S) ans -= --count[c];
        Console.WriteLine(ans + 1);
    }
}


class Entry { static void Main() { new Program().Solve(); } }
class Reader
{
    static TextReader reader = Console.In;
    static readonly char[] separator = { ' ' };
    static readonly StringSplitOptions op = StringSplitOptions.RemoveEmptyEntries;
    static string[] A = new string[0];
    static int i;
    static void Init() { Dispose(); A = new string[0]; }
    public static void Set(TextReader r) { Init(); reader = r; }
    public static void Set(string file) { Init(); reader = new StreamReader(file); }
    public static bool HasNext() { return CheckNext(); }
    public static string String() { return Next(); }
    public static int Int() { return int.Parse(Next()); }
    public static long Long() { return long.Parse(Next()); }
    public static double Double() { return double.Parse(Next()); }
    public static int[] IntLine() { return Array.ConvertAll(Split(Line()), int.Parse); }
    public static int[] IntArray(int N) { return Range(N, Int); }
    public static int[][] IntTable(int H) { return Range(H, IntLine); }
    public static string[] StringArray(int N) { return Range(N, Next); }
    public static string[][] StringTable(int N) { return Range(N, () => Split(Line())); }
    public static string Line() { return reader.ReadLine().Trim(); }
    public static T[] Range<T>(int N, Func<T> f) { var r = new T[N]; for (int i = 0; i < N; r[i++] = f()) ; return r; }
    public static void Dispose() { reader.Dispose(); }
    static string[] Split(string s) { return s.Split(separator, op); }
    static string Next() { CheckNext(); return A[i++]; }
    static bool CheckNext()
    {
        if (i < A.Length) return true;
        string line = reader.ReadLine();
        if (line == null) return false;
        if (line == "") return CheckNext();
        A = Split(line);
        i = 0;
        return true;
    }
}

Measured memory_bytes: 13140
#!/usr/bin/env python3


def read_h(typ=int):
    return list(map(typ, input().split()))


def read_v(n, m=1, typ=int):
    return [tuple(map(typ, input().split())) if m > 1 else typ(input()) for _ in range(n)]


def main():
    W, H, N = read_h()
    pts = read_v(N, m=3)
    rec = [0, 0, W, H]

    for x, y, a in pts:
        if a == 1:
            rec[0] = max(rec[0], x)
        elif a == 2:
            rec[2] = min(rec[2], x)
        elif a == 3:
            rec[1] = max(rec[1], y)
        elif a == 4:
            rec[3] = min(rec[3], y)

        if rec[2] - rec[0] <= 0 or rec[3] - rec[1] <= 0:
            print(0)
            return

    ans = (rec[2] - rec[0]) * (rec[3] - rec[1])
    print(ans)


if __name__ == '__main__':
    main()


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

int main()
{
    string num;
    cin >> num;
    int n = 0;
    int N=0;
    for(int i=0; i<num.size(); i++){
        n += num[i]-'0';
        N = N*10 + (num[i]- '0');
    }
    //cout << n << " " << N << endl;
    if(N%n==0)
        cout << "Yes\n";
    else
        cout << "No\n";
    return 0;
}


Measured memory_bytes: 256
fn main() {
    let s: String = {
        let mut s = String::new();
        std::io::stdin().read_line(&mut s).unwrap();
        s.trim_right().to_owned()
    };

    let s_len = s.chars().count();
    let s_half_len = (s_len - 1) / 2;

    let before = s.chars().take(s_half_len).collect::<String>();
    let after = s.chars().skip(s_half_len + 1).collect::<String>();
    if before == after.chars().rev().collect::<String>() {
        let is_half_odd = s_half_len % 2 == 1;
        let s_half_half_len = if is_half_odd {
            (s_half_len - 1) / 2
        } else {
            s_half_len / 2
        };
        let before = s.chars().take(s_half_half_len).collect::<String>();
        let skip_index = if is_half_odd {
            s_half_half_len + 1
        } else {
            s_half_half_len
        };
        let after = s
            .chars()
            .skip(skip_index)
            .take(s_half_half_len)
            .collect::<String>();
        if before == after.chars().rev().collect::<String>() {
            println!("Yes");
        } else {
            println!("No");
        }
    } else {
        println!("No");
    }
}

// 回文であることを判定する
// trueなら1-(n-1)/2文字目が回文であることを判定する


Measured memory_bytes: 4352
import sys
input = sys.stdin.readline
N = int(input())
XY = [tuple(map(int,input().split())) for i in range(N)]
XY.sort(key=lambda x:x[0])

ys = []
for _,y in XY:
    ys.append(y)
ys.sort()
yd = {y:i for i,y in enumerate(ys)}

class BinaryIndexedTree:
    def __init__(self,size):
        self.N = size
        self.bit = [0]*(size+1)
    def add(self,x,w): # 0-indexed
        x += 1
        while x <= self.N:
            self.bit[x] += w
            x += (x & -x)
    def _sum(self,x): # 1-indexed
        ret = 0
        while x > 0:
            ret += self.bit[x]
            x -= (x & -x)
        return ret
    def sum(self,l,r): # [l,r)
        return self._sum(r) - self._sum(l)
    def __str__(self): # for debug
        arr = [self.sum(i,i+1) for i in range(self.N)]
        return str(arr)

lbit = BinaryIndexedTree(N)
lu = []
ld = []
for i,(_,y) in enumerate(XY):
    d = lbit._sum(yd[y])
    u = i - d
    lu.append(u)
    ld.append(d)
    lbit.add(yd[y],1)

rbit = BinaryIndexedTree(N)
ru = []
rd = []
for i,(_,y) in enumerate(XY[::-1]):
    d = rbit._sum(yd[y])
    u = i - d
    ru.append(u)
    rd.append(d)
    rbit.add(yd[y],1)

MOD = 998244353
ans = 0
for a,b,c,d in zip(ld,lu,rd[::-1],ru[::-1]):
    pa,pb,pc,pd = pow(2,a,MOD),pow(2,b,MOD),pow(2,c,MOD),pow(2,d,MOD)
    ans += (pa-1) * (pd-1) * pb * pc
    ans += (pb-1) * (pc-1) * pa * pd
    ans -= (pa-1) * (pb-1) * (pc-1) * (pd-1)
    ans %= MOD
ans += N * pow(2,N-1,MOD)
ans %= MOD
print(ans)

Measured memory_bytes: 169216
def get_i() #空白区切の入力を数値(整数)の配列で返す
  return gets.chomp.split(" ").map(&:to_i)
end
def get_f() #空白区切の入力を数値(実数)の配列で返す
  return gets.chomp.split(" ").map(&:to_f)
end
def get() #空白区切の入力を文字列の配列で返す
  return gets.chomp.split(" ")
end
def get_nsp() #入力されたものを一文字ずつに区切った文字列の配列で返す
  return gets.chomp.split("")
end
def yn_judge(bool,y="Yes",n="No") #boolに真偽を投げることで、trueならy、falseならnの値を出力する
  return bool ? y : n 
end
def array(size1,init=nil,size2=-1) #size2に二次元配列時の最初の要素数、size1に次の配列の大きさ、initに初期値を投げることでその配列を返す
  if size2==-1
    return Array.new(size1){init}
  else
    return Array.new(size2){Array.new(size1){init}}
  end
end

X=gets.to_i
ans=array(1000+1,false)
ans[1]=true
2.upto((X**0.5).to_i) do|i|
  k=2
  while i**k<=X
      ans[i**k]=true
      k+=1
  end
end
max=0
ans.each_with_index do|b,i|
    max=i if b
end
puts max

Measured memory_bytes: 1788
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define INF 1LL<<62
#define inf 1000000007

int main() {
	ll n;
	cin>>n;
	for(ll i=1;i<=9;i++){
		for(ll j=1;j<=9;j++){
			if(i*j==n){
				cout << "Yes";
				return 0;
			}
		}
	}
	cout << "No";
	// your code goes here
	return 0;
}

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

int main() {
	int n, x;
	cin >> n >> x;
	vector<int>m(n);
	for (int i = 0; i < n; i++)cin >> m.at(i);
	for (int i = 0; i < n; i++)x -= m.at(i);
	sort(m.begin(), m.end());
	ll ans = n;
	ans += x / m.at(0);
	cout << ans << endl;
}

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

int n, q, a[25];

bool solve( int i, int m ){
    if( !m ) return true;
    if( i >= n ) return false;
    return solve( i + 1, m ) || solve( i + 1, m - a[i] );
}

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

    cin >> q;
    for( int i = 0; i < q; i++ ){
        int m; cin >> m;
        cout << ( solve( 0, m ) ? "yes" : "no" ) << endl;
    }

    return 0;
}



Measured memory_bytes: 3104
#include <vector>
#include <algorithm>
#include <iostream>
#include <cassert>
#include <cstdlib>
#include <cmath>
#include <cstring>
#include <cstdio>
#include <ctime>
#include <map>
#include <set>
#include <string>
#include <cassert>
 
#define INFLL 2000000000000000000
#define INF 2000000000
#define MOD 1000000007
#define PI acos(-1.0)
 
typedef std::pair <int, int> pii;
typedef long long ll;
typedef std::vector <ll> vll;
 
using namespace std;
 
vector <int> vec;
int dp[500009][3];
char buff[500009];

int solve(int start) {
	if (start + 1 >= vec.size())
		return 0;
	dp[start][0] = 0;
	dp[start][1] = vec[start];
	dp[start][2] = 0;
	// for (int i = start; i < vec.size(); i++) {
	// 	cout << vec[i] << " ";
	// }
	// cout << endl << "____" << endl;
	for (int i = start + 1; i + 1 < vec.size(); i++) {
		if (vec[i] > 1) {
			dp[i][1] = max(dp[i - 1][0] + vec[i], max(dp[i - 1][2] + vec[i], dp[i - 1][1] + vec[i] - 1));
			dp[i][0] = dp[i - 1][2] + vec[i];
			dp[i][2] = max(dp[i - 1][2] + vec[i] - 1, max(dp[i - 1][1], dp[i - 1][0]));
		} else {
			dp[i][1] = max(dp[i - 1][2] + 1, dp[i - 1][0] + 1);
			dp[i][2] = max(dp[i - 1][2], dp[i - 1][0]);
			dp[i][0] = max(dp[i - 1][0], max(dp[i - 1][1], dp[i - 1][2]));
		}
	}
	return max(dp[vec.size() - 2][2] + vec[vec.size() - 1], max(dp[vec.size() - 2][1], dp[vec.size() - 2][0]));
}
 
int main() {
	//freopen("input.txt", "r", stdin);
	//freopen("output.txt", "w", stdout);
	
		int len;
		scanf("%d\n", &len);
		int ans = 0;
		scanf("%s\n", buff);
		int last = 0;
		int cnt = 0;
		for (int i = 0; i < len; i++) {
			if (buff[i] == '0' && (i + 1 == len || buff[i + 1] == '0')) {
				if (cnt > 0) {
					vec.push_back(cnt);
				}	
				ans += solve(last);
				last = vec.size();
				cnt = 0;
			}
			else if (buff[i] == '0') {
				if (cnt > 0)
					vec.push_back(cnt);
				cnt = 0;
			}	
			else {
				cnt++;
				if (i == len - 1) {
					vec.push_back(cnt);
					ans += solve(last);	
				}
			}
		}
		printf("%d\n", ans);
		vec.clear();
	
	return 0;
}

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

using namespace std;

using ll = long long;

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

    int k;
    cin >> k;

    const int INF = 9 * 5;
    vector<int> d(k, INF);
    deque<int> st;
    st.push_front(1);
    d[1] = 1;

    while (!st.empty()) {
        auto cur = st.front(); st.pop_front();
        if (cur == 0) break;

        if (d[cur] < d[(10 * cur) % k]) {
            d[(10 * cur) % k] = d[cur];
            st.push_front((10 * cur) % k);
        }
        if (d[cur] + 1 < d[(cur + 1) % k]) {
            d[(cur + 1) % k] = d[cur] + 1;
            st.push_back((cur + 1) % k);
        }
    }

    cout << d[0] << endl;

    return 0;
}


Measured memory_bytes: 896
#include <cassert>

#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <ccomplex>
#include <cfenv>
#include <cinttypes>
#include <cstdbool>
#include <cstdint>
#include <ctgmath>
#include <cwchar>
#include <cwctype>

// C++
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#include <array>
#include <atomic>
#include <chrono>
#include <condition_variable>
#include <forward_list>
#include <future>
#include <initializer_list>
#include <mutex>
#include <random>
#include <ratio>
#include <regex>
#include <scoped_allocator>
#include <system_error>
#include <thread>
#include <tuple>
#include <typeindex>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>
#define rep(i,j,k) for(int i=(int)j;i<(int)k;i++)
#define ll long long
#define Sort(v) sort(all(v))
#define INF 1000000000
#define END return 0
#define pb push_back
#define se second
#define fi first
#define pb push_back
#define all(v) (v).begin() , (v).end()
#define MP make_pair
#define MOD 1000000007LL;
using namespace std;
int day[12]={31,28,31,30,31,30,31,31,30,31,30,31};



int main(){
    int n;
    cin>>n;
    int t=111;
    while(t<n){
        t+=111;
    }
    cout<<t<<endl;
    





    return 0;
}


Measured memory_bytes: 256
/*--------------------------------
  Author: The Ace Bee
  Blog: www.cnblogs.com/zsbzsb
  This code is made by The Ace Bee
--------------------------------*/
#include <algorithm>
#include <iostream>
#include <cstring>
#include <cstdlib>
#include <cstdio>
#include <cctype>
#include <cmath>
#include <ctime>
#include <set>
#define rg register
using namespace std;
typedef long long LL;
template < typename T > inline void read(T& s) {
	s = 0; int f = 0; char c = getchar();
	while (!isdigit(c)) f |= (c == '-'), c = getchar();
	while (isdigit(c)) s = s * 10 + (c ^ 48), c = getchar();
	s = f ? -s : s;
}
const int _ = 200010;
int n;
struct node{ int a, b; }t[_];
inline bool cmp(const node& x, const node& y) { return x.a < y.a; }
multiset < int > L, R;
inline LL calc()
{ return 1ll * (*L.rbegin() - *L.begin()) * (*R.rbegin() - *R.begin()); }
int main() {
	read(n);
	for (rg int a, b, i = 1; i <= n; ++i) {
		read(a), read(b);
		if (a > b) swap(a, b);
		t[i] = (node) { a, b };
		L.insert(a), R.insert(b);
	}
	LL ans = calc();
	sort(t + 1, t + n + 1, cmp);
	for (rg int i = 1; i <= n; ++i) {
		int a = t[i].a;
		int b = t[i].b;
		L.erase(L.find(a)), R.insert(a);
		R.erase(R.find(b)), L.insert(b);
		ans = min(ans, calc());
	}
	printf("%lld\n", ans);
	return 0;
}
//asfdadf


Measured memory_bytes: 20608
#include<iostream>
#include<algorithm>
#include<cmath>
#include<stack>
#include<queue>
#include<vector>

using namespace std;

int main() {
  int N; 
  cin >> N;
  vector<int> a(N);
  for (int i=0; i<N; i++) {
    cin >> a[i];
    a[i] -= i+1;
  }

  sort(a.begin(), a.end());
  long res = 0, res2 = 0;
  int b = a[N/2];
  int c = a[N/2 + 1];
  for (int i=0; i<N; i++) {
    res += abs(a[i] - b);
    res2 += abs(a[i] - c);
  }

  cout << ((res>res2)? res2: res) << endl;
}



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

int main() {
    int H, N; cin >> H >> N;
    vector<int> A(N);
    int hp = 0;
    for (int i = 0; i < N; i++) {
        cin >> A.at(i);
        hp += A.at(i);
    }
    if (hp >= H) { cout << "Yes" << endl;}
    else { cout << "No" << endl;}
}

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

int main(void)
{
	long long N, K;
	cin >> N >> K;
	vector<int> vec(N);
	for (int i = 0; i < N; i++)
		cin >> vec[i];

	long long current = 1;
	long long time = 0;
	long long div = 0;
	vector<long long> visited(N, -1);

	if (K <= N)
		goto GOTO1;

	while (true)
	{
		visited[current - 1] = time;
		current = vec[current - 1];
		time++;
		if (visited[current - 1] != -1) {
			div = time - visited[current - 1];
			break;
		}
	}
	
	K = (long long)K - time;
	K = (long long)K % div;
GOTO1:
	for (long long i = 0; i < K; i++)
		current = vec[current - 1];

	cout << current << endl;
}

Measured memory_bytes: 5632
#include <bits/stdc++.h>
using namespace std;
int main(void)
{
	long long w, h, x, y;
	cin >> w >> h >> x >> y;
	printf("%.08Lf ", (long double)w*h/2.0);
	if (2*x == w && 2*y == h)
		printf("1\n");
	else
		printf("0\n");
	return 0;

}


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

using namespace std;

int main(){
    int n,a,b,x;
    int total=0;
    int total2=0;
    
    cin >> n >> a >> b;

    for (int i=1;i<=n;i++){
        x=i;
        while(true){
            total += x%10;
            if (x/10==0) break;
            x = x/10;
        }
        if (total>=a && total<=b) total2+=i;
        total = 0;
    }
    cout << total2 << endl;
    return 0;
}

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

const long long mod=1e9+7;

const int MAX_N=5003;

long long dp[MAX_N][MAX_N];

int main(){
	int n;
	string str;
	cin>>n>>str;
	dp[0][0]=1;
	for(int i=1;i<=n;i++){
		for(int j=0;j<=i;j++){
			if(j)dp[j][i]=(2*dp[j-1][i-1]+dp[j+1][i-1])%mod;			
			else dp[j][i]=(dp[j+1][i-1]+dp[j][i-1])%mod;
		}
	}
	long long ans=dp[str.size()][n];
	for(int i=0;i<str.size();i++){
		ans=(ans*500000004)%mod;
	}
	cout<<ans<<endl;
}


Measured memory_bytes: 116864
import sys
from collections import deque
sys.setrecursionlimit(10**6)

INF = 10**10


def search(table, visit):
    d = deque()
    d.append(1)
    while(len(d) > 0):
        next = d.popleft()
        for x in table[next]:
            if visit[x] != INF:
                continue
            visit[x] = next
            d.append(x)


def main(input, print):
    n, m = map(int, input().split())
    table = [[] for _ in range(n+1)]
    visit = [INF]*(n+1)
    for i in range(m):
        a, b = map(int, input().split())
        table[a].append(b)
        table[b].append(a)
    search(table, visit)
    is_ok = True
    for i in range(2, n+1):
        if visit[i] == INF:
            is_ok = False
            break
    if is_ok:
        print('Yes')
        for i in range(2, n+1):
            print(visit[i])
    else:
        print('No')


if __name__ == '__main__':
    main(sys.stdin.readline, print)


Measured memory_bytes: 94564
N, K = map(int, input().split())
ps = input().split()
ans = 0
temp = 0
for i in range(K):
  temp += (1+int(ps[i]))/2
ans = temp
for i in range(N-K):
  temp = temp + (1+int(ps[i+K]))/2 - (1+int(ps[i]))/2
  ans = max(ans, temp)
print(ans)

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

int N;

int DigitSum(int n){
    int sum = 0;
    while(n > 0){
        sum += n % 10;
        n /= 10;
    }
    return sum;
}

int main(void) {
    
    cin >> N;
    
    int result = INT_MAX;
    for(int a = 1; a < N; ++a){
        int a_ds = DigitSum(a);
        int b_ds = DigitSum(N - a);
        result = min(result, a_ds + b_ds);
    }
    
    cout << result << endl;
  
    return 0;
}

Measured memory_bytes: 384