akhauriyash/Code-Regression huggingface dataset:
/// problem link: http://lightoj.com/volume_showproblem.php?problem=1031
/// topic: dp
#include <bits/stdc++.h>
using namespace std;
#define INF 1<<30
#define endl '\n'
#define maxn 100005
#define tc printf("Case %d: ", cs)
#define tcn printf("Case %d:\n", cs);
#define FASTIO ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0);
typedef long long ll;
const double PI = acos(-1.0);

#define dbg1(x) cerr << #x << " = " << x << endl;
#define dbg2(x, y) cerr << #x << " = " << x << ", " << #y << " = " << y << endl;
#define dbg3(x, y, z) cerr << #x << " = " << x << ", " << #y << " = " << y << ", " << #z << " = " << z << endl;
#define dbg4(w,x, y, z) cerr << #w << " = " << w << ", " <<#x << " = " << x << ", " << #y << " = " << y << ", " << #z << " = " << z << endl;


ll dp[3005][3005];
ll a[3005];

ll calc(ll l, ll r)
{
  if (l > r) return 0;
  ll &ret = dp[l][r];
  if (ret != -1) return ret;

  ll sm = 0;
  ll dif = -1e18;
  //for (ll i = l; i <= r; i++) {
  sm += a[l];
  dif = max(dif, sm - calc(l + 1, r));
  //}
  sm = 0;
  //for (ll i = r; i >= l; i--) {
  sm += a[r];
  dif = max(dif, sm - calc(l, r - 1));
  //}
  return ret = dif;
}

int main()
{
  // FASTIO
  /*
  #ifndef ONLINE_JUDGE
  freopen("in.txt", "r", stdin);
  freopen("out.txt", "w", stdout);
  freopen("error.txt", "w", stderr);
  #endif
  //*/
  ll T;
  //scanf("%d", &T);
  T = 1;
  for (ll cs = 1; cs <= T; cs++) {
    ll n;
    scanf("%lld", &n);
    for (ll i = 0; i < n; i++) scanf("%lld", &a[i]);
    memset(dp, -1, sizeof dp);
    printf("%lld\n", calc(0, n - 1ll));
  }
  return 0;
}

Measured memory_bytes: 74532
#pragma GCC optimize(2)
#include<bits/stdc++.h> 
using namespace std;
#define ll long long
#define endl "\n"
const int mod=1e9+7;
const int MAX=1e6+7;

int main(){
    ios_base::sync_with_stdio(0);cin.tie(0);
  	ll n,d;cin>>n>>d;
  	ll x,y,ans=0;
  	for(int i=0;i<n;i++){
  		cin>>x>>y;
  		if(x*x+y*y<=d*d)
		  ans++; 
	  }
  	cout<<ans; 
   
   
   return 0;
} 

Measured memory_bytes: 3652
#include<algorithm>
#include <iostream>
#include <math.h>
#include <cstdio>
#include <string.h>
using namespace std;
int main(void){
	long long int n,x,sum=0;
	cin>>n; 
	x=n;
	while(x!=0){
		sum+=x%10;
		x/=10;
	}
	if(n%sum==0)cout<<"Yes\n";
	else cout<<"No\n";
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <functional>
#include <numeric>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <utility>
#include <sstream>
#include <complex>
#include <fstream>
#include <bitset>
#include <time.h>
#include <tuple>
#include <iomanip>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;
typedef vector<ll> V;
typedef complex<double> Point;

#define PI acos(-1.0)
#define EPS 1e-10
const ll INF = 1e12;
const ll MOD = 1e9 + 7;

#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define rep(i,N) for(int i=0;i<(N);i++)
#define ALL(s) (s).begin(),(s).end()
#define EQ(a,b) (abs((a)-(b))<EPS)
#define EQV(a,b) ( EQ((a).real(), (b).real()) && EQ((a).imag(), (b).imag()) )
#define fi first
#define se second
#define N_SIZE (1LL << 20)
#define NIL -1

ll sq(ll num) { return num*num; }
ll mod_pow(ll x, ll n) {
	if (n == 0)return 1;
	if (n == 1)return x%MOD;
	ll res = sq(mod_pow(x, n / 2));
	res %= MOD;
	if (n % 2 == 1) {
		res *= x;
		res %= MOD;
	}
	return res;
}
ll mod_add(ll a, ll b) { return (a + b) % MOD; }
ll mod_sub(ll a, ll b) { return (a - b + MOD) % MOD; }
ll mod_mul(ll a, ll b) { return a*b % MOD; }

ll n;

int main() {
	cin >> n;
	bool f = 0;
	rep(i, n) {
		string s;
		cin >> s;
		if (s == "Y")f = 1;
	}
	if (f)cout << "Four" << endl;
	else cout << "Three" << endl;
}

Measured memory_bytes: 256
#include<stdio.h>
int main(void){
	int r, d, x;
	scanf("%d",&r);
	scanf("%d",&d);
	scanf("%d",&x);
	for(int i=0; i<10; i++){
		x=x*r-d;
		printf("%d\n", x);
	}
	return 0;
}

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

namespace ABC099
{
  public class Problem_B
  {
    public static void Main()
    {
      var inputs = Array.ConvertAll(Console.ReadLine().Split(), int.Parse);
      int a = inputs[0], b = inputs[1];

      var diff = b - a;
      var ans = Enumerable.Range(1, diff).Sum() - b;
      Console.WriteLine(ans);
    }
  }
}


Measured memory_bytes: 11220
#include<bits/stdc++.h>
using namespace std;
//D問題

int main(){
    long long a,b,n;
    cin >> a >> b>> n;
    if(n<b-1){
        long long x = a*n/b;
        long long y = n/b;   
        cout << x << endl;
    }else if(n>=b-1){
        long long x = a*(b-1)/b;
        long long y = (b-1)/b;
        cout << x << endl;
    }
    return 0;
}


Measured memory_bytes: 3588
//C
#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 <cstdalign>
#include <cstdbool>
#include <cstdint>
#include <ctgmath>
#include <cwchar>
#include <cwctype>

// C++
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#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>

//Others
template<class T> inline bool chmin(T& a, T b) {
	if (a > b) {
		a = b;
		return true;
	}
	return false;
}
template<class T> inline bool chmax(T& a, T b) {
	if (a < b) {
		a = b;
		return true;
	}
	return false;
}
const int dx[8] = { -1,0,1,-1,1,-1,0,1 };
const int dy[8] = { 1,1,1,0,0,-1,-1,-1 };


//LOVE NyantakoGG	https://www.youtube.com/channel/UC6XdFs8T6Ei54O0FYl3PVVA


using namespace std;


int main() {
	int H, W;
	cin >> H >> W;
	vector<vector<char>>data(H, vector<char>(W));
	vector<int>h(H);
	vector<int>w(W);
	for (int i = 0; i < H; i++) {
		for (int j = 0; j < W; j++) {
			cin >> data[i][j];
		}
	}
	for (int i = 0; i < H; i++) {
		for (int j = 0; j < W; j++) {
			if (data[i][j] == '.') {
				h[i]++;
			}
		}
	}
	for (int j = 0; j < W; j++) {
		for (int i = 0; i < H; i++) {
			if (data[i][j] == '.') {
				w[j]++;
			}
		}
	}
	for (int i = 0; i < H; i++) {
		for (int j = 0; j < W; j++) {
			if (h[i] != W && w[j] != H) {
				cout << data[i][j];
			}
		}
		if (h[i] != W) {
			cout << endl;
		}
	}
}


Measured memory_bytes: 256
N, M = map(int, input().split())
A = [int(input()) for _ in range(M)]

ok = [True] * (N + 1)
for a in A:
    ok[a] = False

dp = [0] * (N + 1)
dp[0] = 1

for i in range(N):
    for j in [1, 2]:
        if i + j <= N:
            if ok[i + j]:
                dp[i + j] += dp[i]
                dp[i + j] %= (10 ** 9 + 7)

print(dp[N])

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

int main() {
  int N;
  cin >> N;
  vector<int> A(N);
  for (int i = 0; i < N; ++i)
    cin >> A[i];
  vector<int> B = A;
  sort(B.begin(), B.end());
  int i = 0;
  for (int a = 0; a < N; ++a)
    if (A[a] == B[N - 1])
      i = a;
  for (int a = 0; a < N; ++a)
    if (a == i)
      cout << B[N - 2] << endl;
    else
      cout << B[N - 1] << endl;
}

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

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

int n, a, b, c;
vector<int> d;

int main(){
	while(cin>>n && n) {
		d.clear();
		cin >> a >> b >> c;
		rep(i,n) {
            int inn; cin >> inn;
            d.push_back(inn);
        }
		
		sort(d.rbegin(),d.rend());
		int price = a, cal = c;
		int ans = c / price;
		rep(i,n) {
			price += b;
			cal += d[i];
			ans = max(ans, cal / price);
		}
		
		cout << ans << "\n";
	}
	
	return 0;
}

Measured memory_bytes: 1220
#include <stdio.h>
#include <math.h>

class sai{
public:
  int men[6];

  void e();
  void n();
  void s();
  void w();
};

void sai::e(){
  int t = men[0];
  men[0] = men[3];
  men[3] = men[5];
  men[5] = men[2];
  men[2] = t;
}
void sai::n(){
  int t = men[0];
  men[0] = men[1];
  men[1] = men[5];
  men[5] = men[4];
  men[4] = t;
}
void sai::s(){
  int t = men[0];
  men[0] = men[4];
  men[4] = men[5];
  men[5] = men[1];
  men[1] = t;
}
void sai::w(){
  int t = men[0];
  men[0] = men[2];
  men[2] = men[5];
  men[5] = men[3];
  men[3] = t;
}

int main(){
  sai sa;
  for(int i = 0; i < 6; i++) scanf("%d", &sa.men[i]);
  char s[128];
  scanf("%s", s);
  for(int i = 0; s[i] != '\0'; i++){
    char ch = s[i];
    if(ch == 'E') sa.e();
    else if(ch == 'N') sa.n();
    else if(ch == 'S') sa.s();
    else sa.w();
  }

  printf("%d\n", sa.men[0]);
}



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

#define endl '\n'
#define lfs cout<<fixed<<setprecision(10)
#define ALL(a)  (a).begin(),(a).end()
#define ALLR(a)  (a).rbegin(),(a).rend()
#define spa << " " <<
#define fi first
#define se second
#define MP make_pair
#define MT make_tuple
#define PB push_back
#define EB emplace_back
#define rep(i,n,m) for(ll i = (n); i < (ll)(m); i++)
#define rrep(i,n,m) for(ll i = (ll)(m) - 1; i >= (ll)(n); i--)
using ll = long long;
using ld = long double;
const ll MOD1 = 1e9+7;
const ll MOD9 = 998244353;
const ll INF = 1e18;
using P = pair<ll, ll>;
template<typename T>
bool chmin(T &a,T b){if(a>b){a=b;return true;}else return false;}
template<typename T>
bool chmax(T &a,T b){if(a<b){a=b;return true;}else return false;}
ll median(ll a,ll b, ll c){return a+b+c-max({a,b,c})-min({a,b,c});}
void ans1(bool x){if(x) cout<<"Yes"<<endl;else cout<<"No"<<endl;}
void ans2(bool x){if(x) cout<<"YES"<<endl;else cout<<"NO"<<endl;}
void ans3(bool x){if(x) cout<<"Yay!"<<endl;else cout<<":("<<endl;}
template<typename T1,typename T2>
void ans(bool x,T1 y,T2 z){if(x)cout<<y<<endl;else cout<<z<<endl;}  
template<typename T>
void debug(vector<vector<T>>&v,ll h,ll w){for(ll i=0;i<h;i++)
{cout<<v[i][0];for(ll j=1;j<w;j++)cout spa v[i][j];cout<<endl;}};
void debug(vector<string>&v,ll h,ll w){for(ll i=0;i<h;i++)
{for(ll j=0;j<w;j++)cout<<v[i][j];cout<<endl;}};
template<typename T>
void debug(vector<T>&v,ll n){if(n!=0)cout<<v[0];
for(ll i=1;i<n;i++)cout spa v[i];cout<<endl;};
template<typename T>
vector<vector<T>>vec(ll x, ll y, T w){
  vector<vector<T>>v(x,vector<T>(y,w));return v;}
ll gcd(ll x,ll y){ll r;while(y!=0&&(r=x%y)!=0){x=y;y=r;}return y==0?x:y;}
vector<ll>dx={1,0,-1,0,1,1,-1,-1};
vector<ll>dy={0,1,0,-1,1,-1,1,-1};
template<typename T>
vector<T> make_v(size_t a,T b){return vector<T>(a,b);}
template<typename... Ts>
auto make_v(size_t a,Ts... ts){
  return vector<decltype(make_v(ts...))>(a,make_v(ts...));
}
template<typename T1, typename T2>
ostream &operator<<(ostream &os, pair<T1, T2>&p){
  return os << p.first << " " << p.second;
}  
int main(){
  cin.tie(nullptr);
  ios_base::sync_with_stdio(false);
  ll res=0,buf=0;
  bool judge = true;
  ll x;cin>>x;
  cout<<x/500*1000+x%500/5*5<<endl;
  return 0;
}

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

int main(){
  int a,b;
  cin >> a >> b;
  int count = 0;
  for (int i = a;i<=b;i++){
    int i1,i2,i4,i5;
    i5 = i%10;
    i1 = i/10000;
    i2 = (i%10000)/1000;
    i4 = (i%100)/10;
    if (i5 == i1 && i2 == i4)
      count += 1;
  }
  cout << count << endl;
}
    


Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using static System.Console;
using static System.Math;

namespace D_SMTB2019
{
    class MainClass
    {

        static int[] n, s;

        public static void Main(string[] args)
        {
            long D = 1000000007;
            n = Array.ConvertAll(ReadLine().Split().ToArray(), int.Parse);
            s = Array.ConvertAll(ReadLine().Split().ToArray(), int.Parse);
            int r = 0;
            int g = 0;
            int b = 0;
            long ans = 1;

            for (int i = 0; i < n[0]; i++)
            {
                if (s[i] == r && s[i] == g && s[i] == b)
                {
                    ans = ans * 3;
                    ans = ans % D;
                    r++;

                }
                else if (s[i] == r && s[i] == g)
                {
                    ans = ans * 2;
                    ans = ans % D;
                    r++;
                }
                else if (s[i] == r && s[i] == b)
                {
                    ans = ans * 2;
                    ans = ans % D;
                    r++;
                }
                else if (s[i] == r)
                {
                    ans = ans * 1;
                    ans = ans % D;
                    r++;
                }
                else if (s[i] == g && s[i] == b)
                {
                    ans = ans * 2;
                    ans = ans % D;
                    g++;
                }
                else if (s[i] == g)
                {
                    ans = ans * 1;
                    ans = ans % D;
                    g++;
                }
                else if (s[i] == b)
                {
                    ans = ans * 1;
                    ans = ans % D;
                    b++;
                }
                else{
                    ans = 0;
                }
//                WriteLine(ans);

            }
            WriteLine(ans);

        }
    }
}


Measured memory_bytes: 19680
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0, i##_len = (n); i < i##_len; ++i)
#define rep2(i, x, n) for(int i = x, i##_len = (n); i < i##_len; ++i)
#define all(n) begin(n), end(n)
using ll = long long;
using P = pair<int, int>;
using vi = vector<int>;
using vl = vector<ll>;
using vs = vector<string>;
using vc = vector<char>;
using vb = vector<bool>;
using vd = vector<double>;
vi dir = {-1, 0, 1, 0, -1, -1, 1, 1, -1};

int main() {
  ll n;
  cin >> n;
  vl a(n), b(n), c(n);
  rep(i, n) cin >> a[i];
  rep(i, n) cin >> b[i];
  rep(i, n) cin >> c[i];
  sort(all(b));
  sort(all(c));
  vl v(n + 1, 0);
  rep(i, n) {
    ll in = upper_bound(all(c), b[i]) - c.begin();
    v[i + 1] = v[i] + n - in;
  }
  ll ans = 0;
  rep(i, n) {
    ll in = upper_bound(all(b), a[i]) - b.begin();
    ans += v[n] - v[in];
  }
  cout << ans << endl;
}

Measured memory_bytes: 3328
#include <cstdio>
using namespace std;

int n, m, N, c[102][102], cnt, dir = 1, x = 1, y = 0;

int main() {
	scanf("%d%d%d", &n, &m, &N);
	for(int i = 1; i <= N; ++i) {
		scanf("%d", &cnt);
		while(cnt--) {
			if(dir == 1) {
				if(++y > m) ++x, y = m, dir ^= 1;
				c[x][y] = i;
			} else {
				if(--y < 1) ++x, y = 1, dir ^= 1;
				c[x][y] = i;
			}
		}
	}
	
	for(int i = 1; i <= n; ++i)
		for(int j = 1; j <= m; ++j)
			printf("%d%c", c[i][j], " \n"[j == m]);
	
	return 0;
}

Measured memory_bytes: 256
def s()
  gets().chomp
end
def i()
  gets.to_i
end
def li()
  gets.split.map(&:to_i)
end
def ili()
  n = gets.to_i
  as = gets.split.map(&:to_i)
  [n, as]
end

n, c = li()
as = []
n.times{
  as << li()
}
res = {}
max_size = 100001
as.each{|a|
  if res[a[2]] == nil
    res[a[2]] = Array.new(max_size, 0)
  end
  res[a[2]][a[0]] += 1
  res[a[2]][a[1]] += -1
}

res.each{|k, v|
  1.upto(max_size-1){|i|
    res[k][i] += res[k][i-1]
  }
}
result = []
(max_size-1).times{|i|
  count = 0
  res.each{|k, v|
    if res[k][i] == 1 || res[k][i+1] == 1
      count += 1
    end
  }
  result << count
}

p result.max

Measured memory_bytes: 35916
#include <bits/stdc++.h>
 
#define scd second
#define fst first
#define pb push_back
#define mkp make_pair
#define all(x) x.begin(), x.end()
#define VT(T) vector<T>
 
using namespace std;
 
typedef long long int ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<int> vint;
typedef vector<ll> vlong;
typedef vector<pii> vpii;
typedef vector<pll> vpll;
typedef vector<vint> vvint;
typedef vector<vlong> vvlong;
typedef list<int> lint;
typedef list<ll> llong;
typedef list<pii> lpii;
typedef list<pll> lpll;
typedef list<lint> llint;
typedef list<llong> lllong;
typedef pair<double,double> pdd;

ll const LINF=numeric_limits<long long int>::max();
int const INF=numeric_limits<int>::max();
 
ll gcd(ll a, ll b){
	return b ? gcd(b,a%b) : a;
}
 
ll pow_mod(ll a, ll e, ll m){
	ll res=1;
	while(e){
		if(e&1) res=res*a%m;
		a=a*a%m;
		e>>=1;
	}
	return res;
}
 
ll inv_mod(ll b, ll m){
	b%=m;
	ll x=0, y=1, r, q, a=m;
	while(b){
		q=a/b;
		r=a%b;
		a=b;
		b=r;
		r=x;
		x=y;
		y=r-q*y;
	}
	x+=m;
	return x%m;
}

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

	int n, m;
	cin>>n>>m;
	if(n==m) cout<<"Yes"<<endl;
	else cout<<"No"<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
//#define ll long long
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return 1; } return 0; }
#define rep(i, n) REP(i, 0, n)
#define rep_rev(i, n) for (int (i) = (int)(n) - 1 ; (i) >= 0 ; --(i))
#define ALL(v) v.begin(), v.end()
#define MSG(a) cout << #a << " " << a << endl;
#define REP(i, x, n) for(int i = x; i < n; i++)
#define all(x) (x).begin(),(x).end()
ll t1,t2,t3;
const ll mod = 998244353;
const int INF = 1e9;
const ll INFLONG = 1e18;

struct Info{
    ll x;
    ll y;
    ll p;
};

int main(){
  ll n;
  cin >> n;
  vector<Info> vec(n);
  rep(i,n){
    cin >> t1 >> t2 >> t3;
    vec[i].x = t1;
    vec[i].y = t2;
    vec[i].p = t3;
  }
  ll piv;
  vector<vector<ll>> dis_h(1<<n,vector<ll>(n,INFLONG));
  vector<vector<ll>> dis_w(1<<n,vector<ll>(n,INFLONG));
  vector<ll> arr(n);
  rep(i,1<<n){
    t1 = i;
    rep(j,n){
      if(t1 & 1){
        arr[j] = 1;
      }else{
        arr[j] = 0;
      }
      t1 /= 2;
    }
    rep(k,n){
      chmin(dis_h[i][k],abs(vec[k].x));
    }
    rep(j,n){
      if(arr[j]){
        piv = vec[j].x;
        rep(k,n){
          chmin(dis_h[i][k],abs(vec[k].x - piv));
        }
      }
    }


    rep(k,n){
      chmin(dis_w[i][k],abs(vec[k].y));
    }
    rep(j,n){
      if(arr[j]){
        piv = vec[j].y;
        rep(k,n){
          chmin(dis_w[i][k],abs(vec[k].y - piv));
        }
      }
    }
  }
  vector<ll> ans(n+1,INFLONG);
  ll len = (ll)pow(3,n);
  ll x,y;
  ll cnt;
  rep(i,len){
    x = 0;
    y = 0;
    cnt = 0;
    t1 = i;
    rep(j,n){
      x *= 2;
      y *= 2;
      if(t1 % 3 == 1){
        x++;
        cnt++;
      }else if(t1 % 3 == 2){
        y++;
        cnt++;
      }else{

      }
      t1 /= 3;
    }
    ll sum = 0;
    rep(j,n){
      sum += vec[j].p * min(dis_h[x][j],dis_w[y][j]);
    }
    chmin(ans[cnt],sum);
  }
  rep(i,n+1){
    cout << ans[i] << endl;
  }
}

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

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

	int n = 0;

	for (int i = 0; i < 4; i++) {
		if (S[i] == '+') {
			n++;
		} else {
			n--;
		}
	}

	cout << n << endl;

	return 0;
}

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



int main() {
    int N;
    cin >> N;
    map<string,int> s;
    int val=0;

    for(int i=0;i<N;i++){
        string temp;
        cin>>temp;
        if(s.find(temp)==s.end())s[temp]=0;
        else s[temp]+=1;
    }
    for(auto i=s.begin();i!=s.end();i++){
        val=max(val,i->second);
    };
    vector<string> res;
    for(auto i=s.begin();i!=s.end();i++){
        if(i->second==val)res.emplace_back(i->first);
    };
    sort(res.begin(),res.end());
    for(int i=0;i<(int)res.size();i++)cout<<res[i]<<endl;
    return 0;
}

Measured memory_bytes: 27204
package main

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

var sc = bufio.NewScanner(os.Stdin)

func scanInt() int {
	sc.Scan()
	i, err := strconv.Atoi(sc.Text())
	if err != nil {
		panic(err)
	}
	return i
}

func main() {
	sc.Split(bufio.ScanWords)

	N := scanInt()
	c1, c2, c4 := 0, 0, 0
	for i := 0; i < N; i++ {
		a := scanInt()
		if a%4 == 0 {
			c4++
		} else if a%2 == 0 {
			c2++
		} else {
			c1++
		}
	}

	besides := c1
	if c2 > 0 {
		besides++
	}

	if besides > c4+1 {
		fmt.Println("No")
	} else {
		fmt.Println("Yes")
	}
}


Measured memory_bytes: 3320
#include <stdio.h>
int main()
{
    int a, b, c;
    scanf("%d %d %d", &a, &b, &c);
    int cnt = 3;
    if (a==b) cnt--;
    if (a==c) cnt--;
    if (b==c) cnt--;
    
    if (cnt <= 1)
        printf("%d\n", 1);
    else
        printf("%d\n", cnt);
    return 0;
}

Measured memory_bytes: 128
//
//  division_subtraction.cpp
//  learningCplusplus
//
//  Created by Tran Duc Chinh on 2020/04/04.
//  Copyright © 2020 Tran Duc Chinh. All rights reserved.
//

#include <iostream>
#include <string>
#include <vector>
#include <math.h>
using namespace std;

int countDivisors(const long n) {
  int cnt = 0;
  for (int i = 1; i <= sqrt(n); i++) {
    if (n%i == 0) {
      if (n / i == i) {
        cnt++;
        // std::cout << "i=i" << i << std::endl;
      }
      else {
        cnt = cnt + 2;
        // std::cout << i << std::endl;
        // std::cout << n/i << std::endl;
      }
    }
  }
  cnt--; // exclude 1
  return cnt;
}
int intlog(double base, double x) {
    return (int)(log(x) / log(base)) - 1;
}

int main(int argc, const char* argv[]) {
  long n;
  std::cin >> n;

  int cnt = countDivisors(n-1); // count the numer of k which n%k=1, n
  // std::cout << "n " << n << std::endl;
  for (long i = 2; i <= sqrt(n); i++) {
    if (n % i == 0) {
      long next_n = n / i;
        // std::cout << "i " << i << " next_n " << next_n << " n " << n/i << std::endl;
      while (next_n % i == 0) {
        next_n = next_n / i;
        // std::cout << "i " << i << " next_n " << next_n << std::endl;
      }
      if (next_n % i == 1) {
        // std::cout << "i " << i << " next_n " << next_n << std::endl;
        cnt++;
      }
    }
  }
  cnt++;
  std::cout << cnt << std::endl;
}

Measured memory_bytes: 384
#include<stdio.h>
int main(){
  int A[100],i,j,v,N,x;
  scanf("%d",&N);
  for(i = 0;i < N;i++){
    scanf("%d",&A[i]);
  }
  for(i = 0;i < N;i++){
    if(i > 0) printf(" ");
    printf("%d",A[i]);
  }
  printf("\n");
  for(i = 1;i < N;i++){
    v = A[i];
    j = i-1;
    while(j >= 0 && A[j] > v){
      A[j+1] = A[j];
      j--;
      A[j+1] = v;
    }
    for(x = 0;x < N;x++){
      if(x > 0) printf(" ");
      printf("%d",A[x]);
    }
    printf("\n");
  }
  return 0;
}



Measured memory_bytes: 2124
#include <iostream>
 using namespace std; int main(void){ 
    int n;
    cin>>n;
    int s=0;
    int l=0;
    int a[1000];
    for(int i=0;i<n;i++){
    cin>>a[i];
         }
    for(int i=0;i<n;i++){
        if(a[i]%2==0){
            l++;
            if(a[i]%3==0 or a[i]%5==0){
                a[i]=0;
                s++;
        }
        }
        }
   if(s==l){
    cout<<"APPROVED";
        }else{
        cout<<"DENIED";
        }
    return 0;
    }


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
 int main()
 {
   int n,i,k,c=0,j;
   cin>>n>>k;
   int a[n];
   long long dp[n];
   for(i=0;i<n;i++)
   {
     cin>>a[i];
   }
   dp[0]=0;
   dp[1]=abs(a[1]-a[0]);
   for(i=2;i<=min(k,n-1);i++)
   {
       c=0;
       for(j=i;j>=1;j--)
       {
           if(j==i)
           {
               c=dp[j-1]+abs(a[i]-a[j-1]);
           }
           else
           {
               if(dp[j-1]+abs(a[i]-a[j-1])<c)
               {
                   c=dp[j-1]+abs(a[i]-a[j-1]);
               }
           }
       }
       dp[i]=c;
   }
   for(i=k+1;i<n;i++)
   {
     c=0;
     for(j=i;j>i-k;j--)
     {
           if(j==i)
           {
               c=dp[j-1]+abs(a[i]-a[j-1]);
           }
           else
           {
               if(dp[j-1]+abs(a[i]-a[j-1])<c)
               {
                   c=dp[j-1]+abs(a[i]-a[j-1]);
               }
           }
     }
     dp[i]=c;
   }
   cout<<dp[n-1];
   return 0;
 }


Measured memory_bytes: 1408
import sys
sys.setrecursionlimit(2147483647)
INF=float("inf")
MOD=10**9+7
input=lambda :sys.stdin.readline().rstrip()
def resolve():
    n=int(input())
    E=[[] for _ in range(n)]
    idx={}
    for i in range(n-1):
        a,b=map(int,input().split())
        a-=1; b-=1
        E[a].append(b)
        E[b].append(a)
        idx[(a,b)]=i

    ans=[None]*(n-1)
    k=max(len(E[v]) for v in range(n))

    # DFSで辺に色付け
    Q=[0]
    while(Q):
        v=Q.pop()
        if(v):
            p=min(E[v]) # 親はE[v]の最小値
            c=ans[idx[(p,v)]] # 親につながる色
        cnt=1
        for nv in E[v]:
            if(v==0):
                ans[idx[(v,nv)]]=cnt
                cnt+=1
                Q.append(nv)
            else:
                if(cnt==c): cnt+=1
                if(nv==p): continue
                ans[idx[(v,nv)]]=cnt
                cnt+=1
                Q.append(nv)

    print(k)
    for c in ans:
        print(c)

resolve()

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

int main() {
  int a, b, c,d;
  //string op;
  cin >> a >> b >> c >> d;

  if ((a+b) < (c+d)) {
    cout << "Right" << endl;
  }else if ((a+b) == (c+d)) {
    cout << "Balanced" << endl;
  }else{
    cout << "Left" << endl;
  }
  
  
  
  // ここにプログラムを追記
}


Measured memory_bytes: 3640
#include <iostream>
#include <algorithm>
#include <utility>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <functional>
#include <iomanip>

using namespace std;

using VI = vector<int>;
using VVI = vector<VI>;
using P = pair<int, int>;
using LL = long long;

#define ALL(a) (a).begin(),(a).end()
#define PB push_back
#define MP make_pair
#define SORT(c) sort((c).begin(),(c).end())
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)
#define IN_LL(v) LL v;cin>>v;
#define IN(v) int v;cin>>v;
#define OUT(v) cout<<v<<endl
#define MOD 1000000007

int main() {
  IN(N); IN(M);

  vector<string> A, B;
  REP(i, N) {
    string S;
    cin >> S;
    A.push_back(S);
  }
  REP(i, M) {
    string S;
    cin >> S;
    B.push_back(S);
  }
  REP(di, N-M+1) {
    REP(dj, N-M+1) {
      bool same = true;
      REP(i, M) {
        REP(j, M) {
          if (A[i+di][j+dj] != B[i][j]) {
            same = false;
            break;
          }
        }
        if (!same)
          break;
      }
      if (same) {
        OUT("Yes");
        return 0;
      }
    }
  }
  OUT("No");

  return 0;
}


Measured memory_bytes: 256
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;

//Expression
public class Main{

	static int[] a;
	static int[] order;
	static boolean[] used;
	static String s;

	static class E{
		public int x;
		public String e;
		public E(int x, String e) {
			this.x = x;
			this.e = e;
		}
	}

	static List<E> g(int[] a, int l, int r){
		List<E> result = new ArrayList<E>();
		if(r-l==0){
			result.add(new E(a[l], ""+a[l]));
			return result;
		}
		if(r-l==1){
			result.add(new E(a[l]+a[r], "("+a[l]+" + "+a[r]+")"));
			result.add(new E(a[l]-a[r], "("+a[l]+" - "+a[r]+")"));
			result.add(new E(a[l]*a[r], "("+a[l]+" * "+a[r]+")"));
			return result;
		}
		if(r-l==2){
			List<E> t = g(a, l+1, r);
			for(E e:t){
				result.add(new E(a[l]+e.x, "("+a[l]+" + "+e.e+")"));
				result.add(new E(a[l]-e.x, "("+a[l]+" - "+e.e+")"));
				result.add(new E(a[l]*e.x, "("+a[l]+" * "+e.e+")"));
			}
			t = g(a, l, r-1);
			for(E e:t){
				result.add(new E(e.x+a[r], "("+e.e+" + "+a[r]+")"));
				result.add(new E(e.x-a[r], "("+e.e+" - "+a[r]+")"));
				result.add(new E(e.x*a[r], "("+e.e+" * "+a[r]+")"));
			}
			return result;
		}
		for(int i=l;i<r;i++){
			List<E> t1 = g(a, l, i);
			List<E> t2 = g(a, i+1, r);
			for(E e1:t1){
				for(E e2:t2){
					result.add(new E(e1.x+e2.x, "("+e1.e+" + "+e2.e+")"));
					result.add(new E(e1.x-e2.x, "("+e1.e+" - "+e2.e+")"));
					result.add(new E(e1.x*e2.x, "("+e1.e+" * "+e2.e+")"));
				}
			}
		}
		return result;
	}

	static void f(int k){
		if(!s.equals(""))return;
		if(k==4){
			int[] t = new int[4];
			for(int i=0;i<4;i++)t[i]=a[order[i]];
			for(E e:g(t,0,3)){
				if(e.x==10){
					s = e.e;
					break;
				}
			}
			return;
		}
		for(int i=0;i<4;i++){
			if(!used[i]){
				used[i] = true;
				order[k] = i;
				f(k+1);
				used[i] = false;
			}
		}
	}

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		while(true){
			a = new int[4];
			for(int i=0;i<4;i++)a[i]=sc.nextInt();
			if((a[0]|a[1]|a[2]|a[3])==0)break;
			order = new int[4];
			used = new boolean[4];
			s = "";
			f(0);
			System.out.println(s.equals("")?"0":s);
		}
	}
}

Measured memory_bytes: 12000
/*
Author : N_o_o_B
Created : April 22 2020 15:37:01 
*/
#include <bits/stdc++.h>
using namespace std;
/*
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
*/
#define TRACE
#ifdef TRACE
#define trace(...) { cerr<<"[ "; __trace__(#__VA_ARGS__, __VA_ARGS__);}
#undef endl
template <typename Arg1,typename Arg2>
ostream& operator << (ostream& out, const pair<Arg1,Arg2> &x) {
    return out<<"("<<x.first<<","<<x.second<<")";
}
 
template <typename Arg1>
ostream& operator << (ostream& out, const vector<Arg1> &a) {
    out<<"[";for(const auto &x:a)out<<x<<",";return out<<"]";
}
 
template <typename Arg1>
ostream& operator << (ostream& out, const set<Arg1> &a) {
    out<<"[";for(const auto &x:a)out<<x<<",";return out<<"]";
}
 
template <typename Arg1,typename Arg2>
ostream& operator << (ostream& out, const map<Arg1,Arg2> &a) {
    out<<"[";for(const auto &x:a)out<<x<<",";return out<<"]";
}
 
template <typename Arg1>
void __trace__(const string name, Arg1&& arg1){
    cerr << name << " : " << arg1 << " ] " << endl;
}
 
template <typename Arg1, typename... Args>
void __trace__(const string names, Arg1&& arg1, Args&&... args){
    const string name = names.substr(0,names.find(','));
    cerr<<name<<" : "<<arg1<<" | ";
    __trace__(names.substr(1+(int)name.size()), args...);
}
#else
    #define trace(args...)
#endif
 
typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<pair<int,int>> vii;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<pair<ll,ll>> vll;
typedef vector<vl> vvl;
//typedef tree<pii, null_type, less<pii>, rb_tree_tag, tree_order_statistics_node_update> oset;
#define fori(i,n) for(int i=0;i<n;i++)
#define rep(i,a,b) for(int i=a;i<=b;i++)
#define repd(i,a,b) for(int i=a;i>=b;i--)
#define ford(i,n)  for(int i=n-1;i>=0;i--)
#define trav(x,a) for(auto& x:a)
#define all(x) x.begin(),x.end()
#define pb push_back
#define endl '\n'
#define sz(a) (int)a.size()
#define fi first
#define se second
clock_t time_p=clock();
void time_taken()
{
    time_p=clock()-time_p;
    cerr<<"Time Taken : "<<(float)(time_p)/CLOCKS_PER_SEC<<"\n";
}
//const ll mod=998244353;
const ll mod=1e9+7;
const ll INF=1e18;

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);cout.tie(NULL);
    cout.precision(12);cout << fixed;


    int a,b;
    cin >> a >> b;
    int n = 0;
    int _b = b;
    while(_b){
        _b /= 10;
        n++;
    }
    int num = a*pow(10,n) + b;
    int sq = sqrt(num);
    if(sq*sq == num){
        cout << "Yes" << endl;
    }
    else{
        cout << "No" << endl;
    }


    time_taken();
    return 0;
}

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

int main() {
	int N, M;
	cin >> N >> M;
	vector<int> A(M);
	for(int i = 0; i < M; i++) {
		cin >> A.at(i);
	}
	int sum = 0;
	for(int i = 0; i < M; i++) {
		sum += A.at(i);
	}
	if(N >= sum) {
		cout << N -sum << endl;
	}
	else {
		cout << -1 << endl;
	}
}

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

int main()
{

    int n;
    cin >> n;
    int h[n];
    for (int i = 0; i < n; i++)
    {
        cin >> h[i];
    }
    int dp[n];
    memset(dp, -1, sizeof(dp));
    dp[0] = 0;
    dp[1] = abs(h[1] - h[0]);
    for (int loc = 2; loc < n; loc++)
    {
        dp[loc] = min(dp[loc - 1] + abs(h[loc] - h[loc - 1]), dp[loc - 2] + abs(h[loc] - h[loc - 2]));
    }
    cout << dp[n - 1];
}


Measured memory_bytes: 1024
#include<iostream>
#include<string>
#include<algorithm>
#include<cmath>
#include<iomanip>
#include<cstring>
#include<map>
#include<vector>
#include<queue>
#include<climits>
#include<set>
#include<utility>
using namespace std;
typedef long long int ll;

int main(){

	int cnt[3]={0};
	string s;
	cin >> s;
	for(int i=0; i<3; i++){
		if(s[i]=='a'){
			cnt[0]++;
		} else if(s[i]=='b'){
			cnt[1]++;
		} else if(s[i]=='c'){
			cnt[2]++;
		}
	}
	if(cnt[0]==1 && cnt[1]==1 && cnt[2]==1){
		cout << "Yes" << endl;
	} else {
		cout << "No" << endl;
	}

	return 0;
}

Measured memory_bytes: 768
#define _GLIBCXX_DEBUG
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repr(i, a, b) for (int i = a; i < b; i++)
using namespace std;

#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <iomanip>
#include <tuple>
#include <map>
#include <unordered_map>
#include <queue>
#include <set>
#include <stack>
#include <bitset>

int main() {
	int A, B;
	char op;

	cin >> A >> op >> B;

	if (op == '+') {
		cout << A + B << endl;	
	}
	else {
		cout << A - B << endl;	
	}
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int a,sum=0;
	string s;
	cin>>a;
	cin>>s;
	for(int i=1;i<a;i++)
	{
		if(s[i-1]!=s[i])
		sum++;
	}
	cout<<sum+1;
} 

Measured memory_bytes: 512
#include <iostream>
#include <queue>
#include <cstring>
#include <complex>
#define H (30+2)*2
#define W (30+2)*2
#define ARI 1
#define NASI 0
using namespace std;

typedef struct {
  int x,y, n;
} P;

int w,h;
int m[H][W];

void pr(){
  for( int i=0;i<=2*h;i++ ){
    for( int j=0;j<=2*w;j++ )	
      if( m[i][j]==NASI ) cout << " ";
      else                cout << "#";
    cout << endl;
  }
  cout << endl;
}

int main(){
  P p, pn;
  queue<P> q;
  while( cin >> w >> h && (w||h) ){

    memset( m, NASI, sizeof(m) );

    for( int i=0,lenH=2*h;i<=lenH;i++ ){
      m[i][0]   = ARI;
      m[i][2*w] = ARI;
      if( i==0 || i==lenH ){
	for( int j=1,lenW=2*w;j<lenW;j++ )
	  m[i][j] = ARI;
      } else if( i%2==1 ){
	for( int j=2,lenW=2*w;j<lenW;j+=2 )
	  cin >> m[i][j];
      } else {
	for( int j=1,lenW=2*w;j<lenW;j+=2 )
	  cin >> m[i][j];
      }
    }

    //    pr();

    int ansX = 0;
    while( q.size()>0 ) q.pop();
    p.x=1; p.y=1; p.n=1;
    q.push( p );
    while( q.size()>0 ){
      p = q.front(); q.pop();
      int i=p.y, j=p.x;

      if( m[i][j]==ARI )
	continue;
      /*
      pr();
      cout << i << "," << j << ","<< p.n << endl;      
      */
      if( i==2*h-1 && j==2*w-1 ){
	ansX = p.n;  break;
      }
      m[i][j]=ARI;
      p.n++;
      if( m[i+1][j]==NASI ){
	pn=p; pn.y+=2; q.push( pn );
      }
      if( m[i-1][j]==NASI ){
	pn=p; pn.y-=2; q.push( pn );
      }
      if( m[i][j+1]==NASI ){
	pn=p; pn.x+=2; q.push( pn );
      }
      if( m[i][j-1]==NASI ){
	pn=p; pn.x-=2; q.push( pn );
      }
    }
    cout << ansX << endl;

    //    break;
  }
  return 0;
}

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

using namespace std;

int main() {
  int N, K;
  cin >> N >> K;

  string S;
  cin >> S;

  vector<int> nums;
  int tmp = 1;
  int cnt = 0;
  for (int i = 0; i < N; i++) {
    if (S[i] == (char)('0' + tmp)) {
      cnt++;
    } else {
      nums.push_back(cnt);
      cnt = 1;
      tmp = 1 - tmp;
    }
  }
  if (cnt != 0)
    nums.push_back(cnt);
  if ((int)nums.size() % 2 == 0)
    nums.push_back(0);

  int maxNum = 0;
  for (int i = 0; i < (int)nums.size(); i += 2) {
    int tmp = 0;
    for (int j = 0; (j < K * 2 + 1) && (i + j < (int)nums.size()); j++) {
      tmp += (int)nums[i + j];
    }
    maxNum = max(maxNum, tmp);
  }

  cout << maxNum << endl;
}


Measured memory_bytes: 1020
macro_rules! get {
    (Vec<$t:ty>) => {
        {
            let mut line: String = String::new();
            std::io::stdin().read_line(&mut line).unwrap();
            line.split_whitespace()
                .map(|t| t.parse::<$t>().unwrap())
                .collect::<Vec<_>>()
        }
    };
    ($t:ty) => {
        {
            let mut line: String = String::new();
            std::io::stdin().read_line(&mut line).unwrap();
            line.trim().parse::<$t>().unwrap()
        }
    };
    ($($t:ty),*) => {
        {
            let mut line: String = String::new();
            std::io::stdin().read_line(&mut line).unwrap();
            let mut iter = line.split_whitespace();
            (
                $(iter.next().unwrap().parse::<$t>().unwrap(),)*
            )
        }
    };
    ($t:ty; $n:expr) => {
        (0..$n).map(|_|
            get!($t)
        ).collect::<Vec<_>>()
    };
    ($($t:ty),*; $n:expr) => {
        (0..$n).map(|_|
            get!($($t),*)
        ).collect::<Vec<_>>()
    };
}

fn main() {
    let N = get!(usize);
    let S = get!(String);
    let Q = get!(usize);
    let k = get!(Vec<usize>);

    let mut A = vec!(0; N + 1);
    let mut B = vec!(0; N + 1);
    let mut AB = vec!(0; N + 1);
    let s = S.chars().collect::<Vec<_>>();
    for K in k {
        let (_, _, _, ans) = (0..N).fold(
            (0, 0, 0, 0),
            |(d, m, dm, dmc), i| {
                let D = (s[i] == 'D') as i64;
                let M = (s[i] == 'M') as i64;
                let C = (s[i] == 'C') as i64;
                if i < K {
                    (
                        d + D,
                        m + M,
                        dm + M * d,
                        dmc + C * dm
                    )
                } else {
                    let D2 = (s[i - K] == 'D') as i64;
                    let d2 = d + D - D2;
                    let dm2 = dm - D2 * m + M * d2;
                    (
                        d2,
                        m + M - ((s[i - K] == 'M') as i64),
                        dm2,
                        dmc + C * dm2
                    )
                }
            }
        );
        println!("{}", ans);
    }
}

Measured memory_bytes: 26868
//include
//------------------------------------------
#include <vector>
#include <list>
#include <map>
#include <unordered_map>
#include <climits>
#include <set>
#include <unordered_set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <queue>
#include <random>
#include <complex>
#include <regex>
#include <locale>
#include <random>
#include <type_traits>

using namespace std;

#define SHOW_VECTOR(v) {std::cerr << #v << "\t:";for(const auto& xxx : v){std::cerr << xxx << " ";}std::cerr << "\n";}
#define SHOW_MAP(v){std::cerr << #v << endl; for(const auto& xxx: v){std::cerr << xxx.first << " " << xxx.second << "\n";}}

using LL = long long;

//------------------------------------------
//------------------------------------------

void dfs(int N, int &ans, vector<int> &a, string s, int d) {
    if (d == 6) return;
    for (int i = 0; i < 10; i++) {
        if (a[i] == 0) {
            string t = s + (char) ('0' + i);
            int b = stoi(t);
            if (b >= N) {
                ans = min(ans, b);
            }
            dfs(N, ans, a, t, d + 1);
        }
    }
}

int main() {

    int N, K;
    cin >> N >> K;

    vector<int> a(10, 0);
    for (int i = 0; i < K; i++) {
        int d;
        cin >> d;
        a[d] = 1;
    }

    int ans = INT_MAX;
    dfs(N, ans, a, "", 0);
    cout << ans << endl;

    return 0;
}




































Measured memory_bytes: 256
def main():
    s = int(input())
    visited = set()
    a = s
    visited.add(a)
    i = 1
    while True:
        i += 1
        if a % 2 == 0:
            a = a // 2
        else:
            a = 3*a + 1
        if a in visited:
            return i
        else:
            visited.add(a)

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

Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using P = pair<ll,ll>;
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define rep2(i,m,n) for(int (i)=(m);(i)<(n);(i)++)
#define ALL(obj) (obj).begin(), (obj).end()
#define rALL(obj) (obj).rbegin(), (obj).rend()
const ll INF = 1LL<<60;
const ll MOD = 1e9+7;


int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    ll k; cin>>k;
    ll ans = 0;
    for(int a=1; a<=k; a++)for(int b=1; b<=k; b++)for(int c=1; c<=k; c++){
        ans += __gcd(__gcd(a,b),c);
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 3592
#include <stdio.h>

int main(void)
{
	char s[100];

	scanf("%s", s);

	if (s[2] == s[3] && s[4] == s[5])
	{
		printf("Yes\n");
	}
	else
	{
		printf("No\n");
	}

	return 0;
}

Measured memory_bytes: 128
#include <stdio.h>

int main(){
	int N;
	scanf("%d",&N);
	char S[256],T[256];
    char ans[256];
    for(int i=0;i<256;i++){
        ans[i]='\0';
        S[i]='\0';
        T[i]='\0';
    }
	scanf("%s %s",S,T);
	
	/*printf("S=%s\n",S);
	printf("T=%s\n",T);*/
	for(int i=0;i<N;i++){
		ans[i*2]=S[i];
		ans[i*2+1]=T[i];
		/*printf("%s\n",ans);*/
	}
	
	printf("%s\n",ans);
	return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <vector>
#include <algorithm>
#include <queue>

using namespace std;

const int MAX_POS = 1000 * 1000 * 1000 + 1;

struct cell {
	cell() : area(0), l(true), r(true), u(true), d(true)
	{}

	int code() const {
		int c = 0;
		if (d) c |= 1;
		if (r) c |= 2;
		if (u) c |= 4;
		if (l) c |= 8;
		return c;
	}

	long long area;
	bool l, r, u, d;
};

int main()
{
	int N, M;
	cin >> N >> M;
	vector<int> A(N), B(N), C(N);
	vector<int> D(M), E(M), F(M);
	for (int i = 0; i < N; ++i) {
		cin >> A[i] >> B[i] >> C[i];
	}
	for (int j = 0; j < M; ++j) {
		cin >> D[j] >> E[j] >> F[j];
	}

	vector<long long> p;
	p.push_back(0);
	p.push_back(MAX_POS);
	p.push_back(-MAX_POS);
	for (int i = 0; i < N; ++i) {
		p.push_back(A[i]);
		p.push_back(B[i]);
		p.push_back(C[i]);
	}
	for (int j = 0; j < M; ++j) {
		p.push_back(D[j]);
		p.push_back(E[j]);
		p.push_back(F[j]);
	}
	sort(p.begin(), p.end());
	p.erase(unique(p.begin(), p.end()), p.end());

	const int L = p.size() - 1;

	vector<vector<cell>> f(L, vector<cell>(L));

	for (int i = 0; i < L; ++i) {
		for (int j = 0; j < L; ++j) {
			f[i][j].area = (p[i + 1] - p[i]) * (p[j + 1] - p[j]);
		}
	}

	for (int i = 0; i < N; ++i) {
		auto j = lower_bound(p.begin(), p.end(), C[i]) - p.begin();
		for (int k = 0; k < L; ++k) {
			if (A[i] <= p[k] && p[k + 1] <= B[i]) {
				f[k][j - 1].r = f[k][j].l = false;
			}
		}
	}
	for (int j = 0; j < M; ++j) {
		auto i = lower_bound(p.begin(), p.end(), D[j]) - p.begin();
		for (int k = 0; k + 1 < L; ++k) {
			if (E[j] <= p[k] && p[k + 1] <= F[j]) {
				f[i - 1][k].d = f[i][k].u = false;
			}
		}
	}

	int y0 = lower_bound(p.begin(), p.end(), 0) - p.begin();
	int x0 = y0;

	long long ans = 0;
	vector<vector<bool>> visited(L, vector<bool>(L, false));
	queue<int> q;
	q.push(y0);
	q.push(x0);
	while (!q.empty()) {
		int y = q.front();
		q.pop();
		int x = q.front();
		q.pop();
		if (x < 1 || L <= x || y < 1 || L <= y) {
			cout << "INF" << endl;
			return 0;
		}
		if (!visited[y][x]) {
			visited[y][x] = true;
			ans += f[y][x].area;
			if (f[y][x].l) {
				q.push(y);
				q.push(x - 1);
			}
			if (f[y][x].r) {
				q.push(y);
				q.push(x + 1);
			}
			if (f[y][x].u) {
				q.push(y - 1);
				q.push(x);
			}
			if (f[y][x].d) {
				q.push(y + 1);
				q.push(x);
			}
		}
	}
	cout << ans << endl;
}


Measured memory_bytes: 571168
#include <stdio.h>

int main(void){
	while(1){
		long n;
		int four[100]={0};
		int i=0, j;
		
		scanf(" %ld", &n);
		if(n==-1) break;
		else if(n==0) {
			printf("%ld\n", n);
			continue;
		}
		
		while(n > 0){
			four[i] = n%4;
			i++;
			n /= 4;
		}
		
		for(j=i-1; j>=0; j--)
			printf("%d", four[j]);
		printf("\n");

	}

	return 0;
}

Measured memory_bytes: 600
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
ll gcd(ll a , ll b) { return b==0?a: gcd( b, a%b); }
ll lcm(ll a , ll b) { return a/gcd(a,b) * b ; }
 /*struct cmp{ bool operator() ( const, const )const{}};
  use as set<ll> ,cmp> a*/
int main()
{
  ios::sync_with_stdio(false);cin.tie(0);
  //freopen("input.txt" , "r" , stdin );
  ll n,m;
  cin>>n>>m;
  vector<ll> a[n+1];
  vector<ll> visited(n+1,0);
  visited[1] = 1;
  for(ll i = 0 ;i<m ;i++)
  {
      ll x,y;
      cin>>x>>y;
      a[x].push_back(y);
      a[y].push_back(x);
  }
  queue<ll> q;
  q.push(1);
  vector<ll> position(n+1);
  
  while(!q.empty())
   {
      ll s = q.front();
      q.pop();
      for( auto &it : a[s])
      {
          if(visited[it]) continue;
          visited[it] = 1;
          position[it] = s;
          q.push(it);
      }

  }
  
 
  for(ll i= 1 ; i<=n ; i++)
  {
      if(visited[i]==0) { cout<<"No" ; return 0 ;}
  }
      cout<<"Yes\n";
      for(ll i = 2 ; i<=n ;i++)
        cout<<position[i]<<endl;

  return 0;
}


Measured memory_bytes: 13712
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0; i < n; i++)
typedef long long ll;
typedef pair<int, int> PI;
typedef pair<ll, ll> PL;
using graph = vector<vector<int>>;

const double pi = 3.14159265358979323846;
const ll mod = 1000000007;


int main() {
	cin.tie(0);
   	ios::sync_with_stdio(false);
	int x, y; cin >> x >> y;
	bool ok = false;
	rep(i, x+1){
		if(2*i + 4*(x-i) == y) ok = true;
	}
	if(ok) cout << "Yes" << endl;
	else cout << "No" << endl;
} 

Measured memory_bytes: 3688
#include<iostream>
#include<iomanip>
#include<map>
#include<set>
#include<string>
#include<algorithm>
#include<cmath>
#include<vector>
#include<queue>
#include<stack>
 
using namespace std;
 
#define P(p) cout<<(p)<<endl
#define rep(i,m,n) for(int i = (m); i < (int)(n); i++)
#define rrep(i,m,n) for(int i=(int)(m); i>=(int)(n); i--)
#define vsort(v) sort(v.begin(), v.end());
#define rvsort(v) sort(v.begin(), v.end(),greater<int>());
#define YES cout<<"YES"<< endl
#define NO cout<<"NO"<<endl
#define Yes cout<<"Yes"<<endl
#define No cout<<"No"<<endl  
#define yes cout<<"yes"<<endl
#define no cout<<"no"<<endl
#define ret return
#define C(i) cin>>i
#define C2(i,j) cin>>i>>j
#define C3(i,j,k) cin>>i>>j>>k
#define C4(i,j,k,m) cin>>i>>j>>k>>m
////////////////////////////////////////////////////////////

int main(){
	int n;
	cin >> n;
	bool color[8] = {};
	int free = 0;
	rep(i,0,n){
		int a;
		cin >> a;
		a /= 400;
		if(a < 8)
			color[a]=1;
		else
			free++;
	}
	
	int ans = 0;
	
	rep(i,0,8)
		ans += color[i];
	
	cout << max(ans,1) <<  " " << ans + free << endl;
	ret 0;
}

Measured memory_bytes: 256
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines


x, k, d = map(int, readline().split())
x = abs(x)

a = min((x // d),k)
k -= a

if k % 2 == 0:
    print(x - a * d)
else:
    print(abs(x - a * d - d))

Measured memory_bytes: 9180
n, m = map(int, input().split())
s = list(map(int, input().split()))
t = list(map(int, input().split()))
mod = 10 ** 9 + 7

dp = [[0] * (m+1) for _ in range(n+1)]
for i in range(n+1):
    dp[i][0] = 1
for j in range(m+1):
    dp[0][j] = 1

for i in range(1, n+1):
    for j in range(1, m+1):
        if s[i-1] == t[j-1]:
            dp[i][j] = (dp[i-1][j] + dp[i][j-1]) % mod
        else:
            dp[i][j] = (dp[i-1][j] + dp[i][j-1] - dp[i-1][j-1]) % mod


print(dp[n][m])

Measured memory_bytes: 72540
import sys
import bisect
import itertools
import collections
import fractions
import heapq
import math
from operator import mul
from functools import reduce
from functools import lru_cache


def solve():
    readline = sys.stdin.buffer.readline
    mod = 10 ** 9 + 7
    a = int(input())
    print(a + a ** 2 + a ** 3)

if __name__ == '__main__':
    solve()

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

using namespace std;
#define ll long long
const int mod=1e9+7;
int main(){
int n;
cin>>n;
set<string>s;

for(int i=0;i<n;i++){
 
	string x;
	cin>>x;
	s.insert(x);
}
cout<<s.size()<<"\n";  


return 0;
}


Measured memory_bytes: 19116