akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<string>
#include<cstdio>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<ciso646>
#include<random>
#include<map>
#include<set>
#include<complex>
#include<bitset>
#include<stack>
#include<unordered_map>
#include<utility>
using namespace std;
typedef long long  ll;
typedef unsigned long long ul;
typedef unsigned int ui;
const ll mod = 1000000007;
typedef double ld;
typedef complex<ld> Point;
const ll INF = mod * mod;
//careful not to convert INF to int type.
typedef pair<int, int> P;
#define rep(i,a,b) for(int i=a;i<b;i++)
#define per(i,a,b) for(int i=a-1;i>=b;i--)
#define rep0(i,n) for(int i=0;i<n;i++)
#define per0(i,n) for(int i=n+1;i>=0;i--)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define fore(i,a) for(auto &i:a)
#define all(x) (x).begin(),(x).end()
const ld eps = 1e-6;
const ld pi = acos(-1.0);
typedef pair<ld, ld> LDP;
typedef pair<ll, ll> LP;
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; }
 

void solve() {
    int n, w; cin >> n >> w;
    int w_list[n];
    int v_list[n];
    rep(i,0,n){
        cin >> w_list[i] >> v_list[i];
    }
    ll dp[w+10];
    rep(i,0,w+10){
        dp[i] = 0;
    }

    rep(i,0,n){
        per(j,w+1,w_list[i]){
            chmax(dp[j], dp[j-w_list[i]] + v_list[i]);
        }
        //rep(i,0,w+1){
            //cout << dp[i];
        //}
        //cout << '\n';
    }

    cout << dp[w];
    
}
int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	solve();
	return 0;
}

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

int main(void){
	char blood[3];
	int a=0,b=0,o=0,ab=0;
	while(scanf("%*d,%s",blood)!=EOF){
		if(blood[1]=='B')ab++;
		else if(blood[0]=='A')a++;
		else if(blood[0]=='B')b++;
		else if(blood[0]=='O')o++;
	}
	printf("%d\n%d\n%d\n%d\n",a,b,ab,o);
	return 0;
}

Measured memory_bytes: 596
#coding: UTF-8

def HMD(a,b,c):
    counter = 0
    for i in range(a,b+1):
        if c%i == 0:
            counter += 1
    print(counter)

if __name__=="__main__":
    a = input().split(" ")
    HMD(int(a[0]),int(a[1]),int(a[2]))

Measured memory_bytes: 7696
/**
 *   author: bholuakku
 *   prob: A
**/

#include <bits/stdc++.h>

using namespace std;

int main(){
    int n;
    cin>>n;
    vector<long long> h(n), dp(n);
    for(auto &it : h) cin>>it;
    dp[0] = 0;
    dp[1] = abs(h[0]-h[1]);
    for(int i=2; i<n; i++){
        dp[i] = min(dp[i-1] + abs(h[i-1] - h[i]), dp[i-2] + abs(h[i-2] - h[i]));
    }
    cout<<dp[n-1]<<"\n";
    return 0;
}


Measured memory_bytes: 1792
#include <iostream>
#include <set>
#include <algorithm>

using namespace std;

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

  set<int> st;
  for (auto &c:s) {
    st.insert(c);
  }

  for (auto itr=st.begin(); itr!=st.end(); itr++) {
    if (count(s.begin(), s.end(), *itr)%2!=0) {
      cout << "No" << endl;
      return 0;
    }
  }
  cout << "Yes" << endl;
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <sstream>
#include <cstring>
#include <map>
#include <cctype>
#include <set>
#include <vector>
#include <stack>
#include <queue>
#include <algorithm>
#include <cmath>
#include <bitset>
#define rap(i, a, n) for(int i=a; i<=n; i++)
#define rep(i, a, n) for(int i=a; i<n; i++)
#define lap(i, a, n) for(int i=n; i>=a; i--)
#define lep(i, a, n) for(int i=n; i>a; i--)
#define rd(a) scanf("%d", &a)
#define rlld(a) scanf("%lld", &a)
#define rc(a) scanf("%c", &a)
#define rs(a) scanf("%s", a)
#define rb(a) scanf("%lf", &a)
#define rf(a) scanf("%f", &a)
#define pd(a) printf("%d\n", a)
#define plld(a) printf("%lld\n", a)
#define pc(a) printf("%c\n", a)
#define ps(a) printf("%s\n", a)
#define LL long long
#define ULL unsigned long long
#define Pair pair<int, int>
#define mem(a, b) memset(a, b, sizeof(a))
#define _  ios_base::sync_with_stdio(0),cin.tie(0)
//freopen("1.txt", "r", stdin);
using namespace std;
const int maxn = 1100000, INF = 0x7fffffff, MOD = 1e9 + 7;

LL D[maxn], U[maxn];
LL q_pow(LL a, LL b)
{
    LL ret = 1;
    while(b)
    {
        if(b & 1) ret = ret * a % MOD;
        a = a * a % MOD;
        b >>= 1;
    }
    return ret;
}

void init()
{
    U[0] = D[0] = 1;
    for(int i = 1; i < maxn; i++)
    {
        U[i] = U[i - 1] * i % MOD;
        D[i] = q_pow(U[i], MOD - 2);
    }
}

LL C(LL n, LL m)
{
    return U[n] * D[m] % MOD * D[n - m] % MOD;
}

int main()
{
    init();

    LL h, w, a, b, ret = 0;
    cin >> h >> w >> a >> b;
    for(int i = b + 1; i <= w; i++)
    {
        ret = (ret + C(h - a + i - 2, i - 1) * C(a - 1 + w - i, a - 1)) % MOD;
     //   cout << C(h - a + i - 2, i - 1) << "    " << C(a - 1 + w - i, a - 1) << endl;
    }
   ret = (ret % MOD + MOD) % MOD;
   cout << ret << endl;




    return 0;
}

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

vector<int> p,rank,cost;

void makeSet(int x) {
    p.push_back(x);
    rank.push_back(0);
    cost.push_back(0);
}

int findSet(int x) {
    int prep = p[x];
    if(x != p[x]) {
        p[x] = findSet(p[x]);
    }
    cost[x] += cost[prep];
    return p[x];
}

void relate(int x, int y, int z) {
    int rootx = findSet(x), rooty = findSet(y);
    if(rootx == rooty) return;
    z = z + cost[x] - cost[y];
    if(rank[rooty] < rank[rootx]) {
        p[rooty] = rootx;
        cost[rooty] = z;
    }
    else {
        p[rootx] = rooty;
        cost[rootx] = -z;
        if(rank[rootx] == rank[rooty]) rank[rooty]+=1;
    }
}

int main() {
    int n,q,com,x,y,z;
    cin >> n >> q;
    for(int i=0; i<n; i++) makeSet(i);
    for(int i=0; i<q; i++) {
        cin >> com >> x >> y;
        if(com == 0) {
            cin >> z;
            relate(x,y,z);
        }
        else {
            if(findSet(x) == findSet(y)) cout << cost[y]-cost[x] << endl;
            else cout << '?' << endl;
        }
    }
    return 0;
}



Measured memory_bytes: 4208
#include<iostream>
using namespace std;
int N,K;
main()
{
	cin>>N>>K;
	if(N==1)
	{
		if(K==0)cout<<"1 1 0 0"<<endl;
		else cout<<-1<<endl;
	}
	else if(K>=1<<N)cout<<-1<<endl;
	else
	{
		for(int i=0;i<1<<N;i++)if(i!=K)cout<<i<<" ";
		cout<<K<<" ";
		for(int i=1<<N;i--;)if(i!=K)cout<<i<<" ";
		cout<<K<<endl;
	}
}

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

int main() {

	while (1) {
		int m, f, r;
		
		cin >> m >> f >> r;
		int s = m + f;	
		if (m == -1 && f == -1 && r == -1)break;
		
		else if (m == -1 || f == -1) {
			cout << "F" << endl;
		}
		else if ( s >= 80) {
			cout << "A" << endl;
		}
		else if (s >= 65 && s < 80) {
			cout << "B" << endl;
		}
		else if (s >= 50 && s < 65) {
			cout << "C" << endl;
		}
		else if (s >= 30 && s < 50 && r < 50) {
			
			cout << "D" << endl;
		}
		else if (s >= 30 && s < 50 && r >= 50) {
			cout << "C" << endl;
		}
		else if (s < 30) {
			cout << "F" << endl;
		}

		
	}
	return 0;
}


Measured memory_bytes: 3088
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define loop(i,a,b) for(i=a;i<b;i++)
#define rloop(i,a,b) for(i=a;i>=b;i--)
#define vi vector<int>
#define vl vector<ll>
#define vii vector< vector<int> >
#define vll vector< vector<ll> >
#define vs vector<string>
const int inf=1000000001;
const ll INF=1e16;
#define MOD 1000000007
#define mod 1000000009
#define pi 3.14159265358979323846



int main(){
	int n,m,i;
	cin>>n>>m;
	vi cnt(n+1);
	int a,b;
	loop(i,0,m){
		cin>>a>>b;
		cnt[a]++;
		cnt[b]++;
	}
	loop(i,0,n){
		cout<<cnt[i+1]<<endl;
	}
}

Measured memory_bytes: 256
import java.util.Scanner;
//import java.util.Arrays;
public class Main{
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		String a = sc.next();
		String b = sc.next();
		int num = Integer.parseInt(a+b);
		boolean flg = false;
		for(int i = 1; i < num ; i++){
			if(i * i == num){
				flg = true;
				break;
			}
		}
		System.out.println(flg ? "Yes" : "No");
	}
}


Measured memory_bytes: 39416
#include <iostream>
#include <algorithm>
#include <cstdio>
#include <vector>
#include <math.h>
#include <iomanip>
#include <bitset>
#include <string>
#include <cstring>
#include <stdlib.h>
#include <utility>
#include <set>
using namespace std;
//cout <<  << endl;
typedef long long int ll;
typedef long double ld;
bool x[100100];
ll num[100100];

ll eratosthenes(ll n) {
    int p = 0;
    for (ll i=0; i<=n; ++i) x[i] = true;
    x[0] = x[1] = false;
    for(int i=2; i<=n; ++i) {
        if(x[i]) {
            p++;
            for(int j=2*i; j<=n; j+=i) x[j] = false;
        }
        
        num[i] = p;
    }
    
    return p;
}

int main(){
    ll n,k,r,s,p,ans=0;
    string ss;
    cin >> n >> k >> r >> s >> p >> ss;
    bool x[n];
    fill(x,x+n,true);
    for (ll i=0;i<n;i++){
        if (i>=k){
            if (ss[i]==ss[i-k] && x[i-k]){
                x[i]=false;
                continue;
            }
        }
        if (ss[i]=='r')ans+=p;
        else if (ss[i]=='s')ans+=r;
        else if (ss[i]=='p')ans+=s;
    }
    cout << ans << endl;
    return 0;
}




Measured memory_bytes: 512
import java.io.*;
import java.util.*;

public class Main {

	final static long MOD = 1000000007L;
	public static String[] Ws = null;
	public static int wsIndx = 0;
	public static BufferedReader in = null;
	public static ArrayList<int[]> list = new ArrayList<>();
	public static void main(String[] args) throws Exception {

		int N = nextInt();
		int[] s = new int[N];
		int sum = 0;
		for(int i=0;i<N;i++){
			s[i]=nextInt();
			sum+=s[i];
		}
		Arrays.sort(s);

		int sub=0;
		if(sum%10==0){
			boolean flg=false;
			for(int i=0;i<N;i++){
				if(s[i]%10!=0){
					sub=s[i];
					flg=true;
					break;
				}
			}
			if(!flg){
				sub=sum;
			}
		}
		System.out.println((sum-sub));


	}

	public static String[] toStringArray(String s) {
		String[] tmp = new String[s.length()];
		char[] c = s.toCharArray();
		for (int i = 0; i < tmp.length; i++) {
			tmp[i] = String.valueOf(c[i]);
		}
		return tmp;
	}

	public static void check() throws Exception{
		if(in == null){
			in = new BufferedReader(new InputStreamReader(System.in));
		}
		if(Ws==null || Ws.length<=wsIndx){
			Ws = in.readLine().split(" ");
			wsIndx=0;
		}
	}
	public static int nextInt()throws Exception{
		check();
		return Integer.parseInt(Ws[wsIndx++]);
	}

	public static long nextLong()throws Exception{
		check();
		return Long.parseLong(Ws[wsIndx++]);
	}

	public static String nextString()throws Exception{
		check();
		return Ws[wsIndx++];
	}

	public static int[] nextInts()throws Exception{
		check();
		int[] tmp = new int[Ws.length];
		for(int i=0;i<tmp.length;i++){
			tmp[i]=Integer.parseInt(Ws[i]);
		}
		wsIndx=Ws.length;
		return tmp;
	}

	public static long[] nextLongs()throws Exception{
		check();
		long[] tmp = new long[Ws.length];
		for(int i=0;i<tmp.length;i++){
			tmp[i]=Long.parseLong(Ws[i]);
		}
		wsIndx=Ws.length;
		return tmp;
	}

	public static String[] nextStrings()throws Exception{
		check();
		wsIndx=Ws.length;
		return Ws;
	}


}


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

int main(){
    int n;
    cin >> n;
    vector<int> p(n);
    for(int i= 0;i < n;i++){
        cin >> p[i];
    }
    int ans = 0;
    for(int i = 1;i < n-1;i++){
        if((p[i]-p[i-1])*(p[i]-p[i+1]) < 0){
            ans += 1;
        }
    }
    cout << ans << endl;
}

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

using namespace std;

string string_replace(const string &s1, const string &s2, const string &s3)
{
    string t = s1;
    string::size_type pos = s1.find(s2);
    size_t s2_len = s2.length();
    size_t s3_len = s3.length();
    while(pos != string::npos)
    {
        t.replace(pos, s2_len, s3);
        pos = t.find(s2, pos + s3_len);
    }
    return t;
}

vector<string> string_split(const string &s, char delim) {
    vector<string> elems;
    string item;
    for (char ch: s) {
        if (ch == delim) {
            if (!item.empty())
                elems.push_back(item);
            item.clear();
        }
        else {
            item += ch;
        }
    }
    if (!item.empty())
        elems.push_back(item);
    return elems;
}

int
main()
{
    int k;
    cin >> k;

    string x = "1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51";
    vector<string> y = string_split(string_replace(x, " ", ""), ',');
    cout << y[k-1] << endl;
    return 0;
}


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

static const int INF=1e9;
static const int MOD=1000000007;
typedef long long ll;
typedef pair<int,int> P;

vector<int> g[10100];
int ans[10100];
int c[10100];
int tmp=1;

void solve(int u,int pa=-1){
    for(auto v:g[u]){
        if(v==pa) continue;
        ans[v]=c[tmp];
        tmp++;
        solve(v,u);
    }
}

int main(){
    int N; cin >> N;
    int f[N]={};
    for(int i=0;i<N-1;i++){
        int a,b; cin >> a >> b;
        a--; b--;
        f[a]++;f[b]++;
        g[a].push_back(b);
        g[b].push_back(a);
    }
    for(int i=0;i<N;i++){
        cin >> c[i];
    }
    sort(c,c+N,greater<int>());
    int M=0;
    for(int i=1;i<N;i++){
        M+=c[i];
    }
    ans[0]=c[0];
    solve(0);
    cout << M << endl;
    for(int i=0;i<N;i++){
        cout << ans[i] << endl;
    }
}


Measured memory_bytes: 1408
#include<bits/stdc++.h>
using namespace std;
using p=pair<int,int>;
#define int long long
#define rep(i,N) for(int i=0;i<=N;i++)

signed main(){
  int A,B,C;
  cin>>A>>B>>C;
  int ans=(A-B)%C;
  cout<<ans<<endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <cstdio>
#include <string>
#include <map>
#include <vector>

using namespace std;

const int MOD = 998244353;

int n;
string s;
map<string, int> ans;

int solve(string s)
{
    if (ans.count(s)) return ans[s];

    int n = s.size();
    vector<int> f(n + 1, 0);
    f[0] = 1;
    for(int i = 0; i < n; ++ i) {
        (f[i + 1] += f[i]) %= MOD;
        if (s[i] == '1') (f[i + 1] += f[i]) %= MOD;

        for(int len = 2; len + i <= n; ++ len) {
            for(int k = 2; k <= len; ++ k) {
                if (len % k) continue;
                string ns = s.substr(i, len / k);
                for(int j = 0; j < len; ++ j) {
                    if (s[i + j] == '0') ns[j % (len / k)] = '0';
                }
                (f[i + len] += 1ll * f[i] * solve(ns) % MOD) %= MOD;
            }
        }
    }

    ans[s] = f[n];
    return ans[s];
}

void solve()
{
    cin >> s;
    cout << solve(s) << endl;
}

int main()
{
    solve();
    return 0;
}


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

using namespace std;
typedef long long ll;
#define rep(i,j,n) for (int i = j; i < (n); i++)
#define CLR(mat) memset(mat, 0, sizeof(mat))
#define IN(a, b, x) (a<=x&&x<b)
#define out(ans) cout << ans << endl
typedef pair<ll,ll>P;
const ll mod=1e9+7;
const ll INF = 1e9;

int main(){

  int h,w;cin>>h>>w;
  string s[h];
  rep(i,0,h)cin>>s[i];
  const int dx[]={0,-1,1,0},dy[]={-1,0,0,1};

  rep(i,0,h){
    rep(j,0,w){
      if(s[i][j]!='#')continue;
      
      bool e=false;
      rep(k,0,4){
        int x=j+dx[k],y=i+dy[k];
        if(IN(0,w,x)&&IN(0,h,y)&&s[y][x]=='#'){
          e=true;
          break;
        }
      }
      if(!e){out("No");return 0;}
    }
  }

  out("Yes");

  return 0;
}


Measured memory_bytes: 256
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <queue>
#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>

using namespace std;

#define dump(x)  cerr << #x << " = " << (x) << endl;
#define PB push_back
#define MP make_pair
#define ll long long

inline int toInt(string s){int v;istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x){ostringstream sout;sout<<x;return sout.str();}

int main(){
    std::ios::sync_with_stdio(false);
    string s, t;
    cin >> s >> t;
    bool ret = true;

    for(int i=0;i<s.length();++i)
    {
        if(s[i] != t[i]) ret = false;
    }

    ret = ret && (s.length() + 1) == t.length();

    cout << (ret ? "Yes" : "No") << endl;
}

Measured memory_bytes: 3640
#include <bits/stdc++.h>
using namespace std;
using lint = long long;
template<class T = int> using V = vector<T>;
template<class T = int> using VV = V< V<T> >;

int main() {
  cin.tie(nullptr); ios::sync_with_stdio(false);
  int n; cin >> n;
  V<> p(n); for (auto&& e : p) cin >> e;
  for (int j = 0; j < n; ++j) for (int i = 0; i <= j; ++i) {
    auto q = p;
    swap(q[i], q[j]);
    if (is_sorted(begin(q), end(q))) return cout << "YES" << '\n', 0;
  }
  cout << "NO" << '\n';
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define REP(i,x,n) for(int i=x;i<(int)n;i++)
#define rep(i,n) REP(i,0,n)
#define sp(p) cout<<setprecision(16)<<fixed<<p<<endl;
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define SORT(a) sort(all(a))
#define RSORT(a) sort(rall(a))
#define UNIQ(a) unique(all(a))
#define UNIQNUM(a) UNIQ(a)-a.begin()
#define UNIQIT(a) a.erase(UNIQ(a), a.end());
#define VOUT(v,i) rep(i,v.size())cout<<v[i]<<(i==v.size()-1?"\n":" ");
#define vout(v) VOUT(v,z);
#define vdbg(v,i) cout<<#v<<": ";for(int i=0;i<(int)v.size();i++){cout<<v[i]<<" ";}cout<<"\n";
#define vmin(v) *min_element(all(v))
#define vmax(v) *max_element(all(v))
#define vsum(v) accumulate(all(v), 0LL)
#define MOUT(m,r,c) rep(i,r){rep(j,c){cout<<m[i][j]<<" ";}cout<<endl;}
#define mout(m) MOUT(m,m.size(),m[0].size())
#define debg(a) cout<<#a<<": "<<a<<endl;
#define show(a) for(cont &y:a){for(cont &x:y){cout<<x<<" ";}cout<<endl;}
#define digit(a) to_string(a).length();
template<class T>inline int out(const T &t){ print(t); putchar('\n'); return 0; }
// template<class T>inline T gcd(T a,T b){if(b==0)return a; return(gcd(b,a%b));}
// template<class T>inline T lcm(T a,T b){return a/gcd(a,b)*b;}
bool is_palindrome(string s){return s == string(s.rbegin(),s.rend());}
typedef long long ll;
typedef long double ld;
typedef pair<ll,ll> P;
typedef vector<ll> V;
typedef vector<vector<ll>> VV;
// const long long MOD=1000000007;
const long long INF = 1e18;
#define EPS (1e-7)
#define PI (acos(-1))
template<class T>
inline bool chmax(T &a, T b) {
    if(a < b) { a = b; return true; }
    return false;
}
template<class T>
inline bool chmin(T &a, T b) {
    if(a > b) { a = b; return true; }
    return false;
}



int main(){
    unsigned long long N;
    cin >> N;
    unsigned long long q=N;
    unsigned long long r=N%26;
    string s;

    do {
        q--;
        char c='a'+q%26;
        s+=c;
        q/=26;
    } while (q>0);

    reverse(all(s));
    cout << s << endl;
    return 0;
}


Measured memory_bytes: 3624
#include<bits/stdc++.h>
using namespace std;
// #include<boost/multiprecision/cpp_int.hpp>
// using namespace boost::multiprecision;
#define BEGIN ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define END return EXIT_SUCCESS
#define rep(I,N) for(auto I=0;I<(N);++I)
#define up(I,A,B) for(auto I=(A);I<=(B);++I)
#define dw(I,A,B) for(auto I=(A);I>=(B);--I)
#define all(C) (C).begin(),(C).end()
#define rall(C) (C).rbegin(),(C).rend()
#define ft first
#define sd second
#define mp make_pair
#define mt make_tuple
#define pf push_front
#define pb push_back
#define pt pop_front
#define pk pop_back
#define eb emplace_back
#define lb lower_bound
#define ub upper_bound
#define rs resize
template<class T>inline bool chmax(T& a,T b){if(a<b){a=b;return true;}return false;}
template<class T>inline bool chmin(T& a,T b){if(a>b){a=b;return true;}return false;}
template<class T>inline void                                      in(T &p){cin>>p;}
template<class T1,class T2>inline void                            in(T1 &p1,T2 &p2){cin>>p1>>p2;}
template<class T1,class T2,class T3>inline void                   in(T1 &p1,T2 &p2,T3 &p3){cin>>p1>>p2>>p3;}
template<class T1,class T2,class T3,class T4>inline void          in(T1 &p1,T2 &p2,T3 &p3,T4 &p4){cin>>p1>>p2>>p3>>p4;}
template<class T1,class T2,class T3,class T4,class T5>inline void in(T1 &p1,T2 &p2,T3 &p3,T4 &p4,T5 &p5){cin>>p1>>p2>>p3>>p4>>p5;}
template<class T>inline void                             out(T p){cout<<p<<endl;}
template<class T1,class T2>inline void                   out(T1 p1,T2 p2){cout<<p1<<" "<<p2<<endl;}
template<class T1,class T2,class T3>inline void          out(T1 p1,T2 p2,T3 p3){cout<<p1<<" "<<p2<<" "<<p3<<endl;}
template<class T1,class T2,class T3,class T4>inline void out(T1 p1,T2 p2,T3 p3,T4 p4){cout<<p1<<" "<<p2<<" "<<p3<<" "<<p4<<endl;}

inline void solve(void){
  long N;
  in(N);
  vector<string>S(N);
  rep(i,N)in(S[i]);
  string T;
  in(T);
  int l=1,r=N+1;
  rep(i,N){
    string s=S[i];
    if(count(all(s),'?')==0){
      if(s<T)l++;
      if(s>T)r--;
    }
    else{
      string s1=s;
      string s2=s;
      replace(all(s1),'?','a');
      replace(all(s2),'?','z');
      if(s1<T&&s2<T)l++;
      if(s1>T&&s2>T)r--;
    }
  }
  up(i,l,r-1)cout<<i<<" ";
  cout<<r<<endl;
}
int main(int argc,char**argv){
  BEGIN;
  solve();
  END;
}


Measured memory_bytes: 896
import math
N, X = list(map(int, input().split(' ')))
def f(a, b):
    a, b = min([a, b]), max([a, b])
    if b % a == 0:
        return 2 * a * math.floor(b / a) - a
    return 2 * a * math.floor(b / a) + f(a, b % a)
print(N + f(N - X, X))

Measured memory_bytes: 3060
from collections import deque

n, q = map(int, input().split())
name = deque()
time = deque()
for i in range(n):
    tmp_name, tmp_time = input().split()
    name.append(tmp_name)
    time.append(int(tmp_time))

ans_time = 0

while len(time)>0:
    tmp_time = time.popleft()
    tmp_name = name.popleft()
    if tmp_time<=q:
        ans_time += tmp_time
        print(tmp_name + " " + str(ans_time))
    else:
        ans_time += q
        time.append(tmp_time-q)
        name.append(tmp_name)

Measured memory_bytes: 11444
using System;
using System.Linq;//リストの使用
using System.Collections.Generic;
class Program
{
	static void Main()
	{
  int answer = 0;
	string s = Console.ReadLine();
  char[] ss = s.ToCharArray();
  string tt = Console.ReadLine();

    for(int i = ss.Length - 1; i >= tt.Length - 1; i--)
    {
      for(int j = 0; j < tt.Length; j++)
      {
        if(ss[i - j] != tt[tt.Length - 1 - j]
        && ss[i - j] != '?') break;
        if(j == tt.Length - 1)
        {
          for(int k = 0; k < tt.Length; k++)
          {
            ss[i - k] = tt[tt.Length - 1 - k];
          }
          for(int k = 0; k < ss.Length; k++)
          {
            if(ss[k] == '?') ss[k] = 'a';
          }
        Console.WriteLine(ss);
        answer = 1;
        break;
        }
      }
      if(answer != 0) break;
    }

    if(answer == 0) Console.WriteLine("UNRESTORABLE");

	}
}

Measured memory_bytes: 11092
#include <iostream>

using namespace std;

const int INF = 114514810;

int main(void) {
    int e;
    while(cin >> e and e) {
        int ans = INF;
        for(int z = 0; z*z*z <= e; z++)
            for(int y = 0; y*y <= e - z*z*z; y++) 
                ans = min(ans, e + y + z - y*y - z*z*z);

        cout << ans << endl;
    }

    return 0;
}

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

int main() {
	int h, n;
	int* ip;

	cin >> h >> n;
	ip = new int[n];

	int sum = 0;

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

	for (int i = 0; i < n; i++) {
		sum += ip[i];
	}

	if (sum >= h) {
		cout << "Yes\n";
	}
	else {
		cout << "No\n";
	}

	delete[] ip;

	return 0;
}

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

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

int main() {
  int N;
  cin >> N;
  int minv;
  cin >> minv;
  int ans = -1000000000;
  rep(i, N-1) {
    int temp;
    cin >> temp;
    ans = max(ans, temp-minv);
    minv = min(minv, temp);
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 3104
#include<iostream>
using namespace std;
int main()
{
   int n;
   while(cin>>n)
   {
        int a[n];
   for(int i=0;i<n;i++)
       cin>>a[i];
    int m;
    cin>>m;
    int b[m];
    for(int i=0;i<m;i++)
        cin>>b[i];
        int t=0;
    for(int i=0;i<m;i++)
        for(int j=0;j<n;j++)
               {
                    if(b[i]==a[j])
                    {
                        t++;
                         break;
                    }
                    else
                        continue;
                }
    cout<<t<<endl;
   }

    return 0;
}

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

int main(){
    string A;
    cin>>A;
    if(A[0]==A[1]&&A[1]==A[2]){
      cout<<"Yes"<<endl;
    }else if(A[1]==A[2]&&A[2]==A[3]){
      cout << "Yes"<<endl;
    }else {
      cout << "No" << endl;
    }
    return 0;
  }


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

int main() {
    int n, m, x;
    cin >> n >> m >> x;
    vector<int> c(n);
    vector<vector<int>> a(n, vector<int>(m));
    rep(i,n){
        cin >> c[i];
        rep(j, m) cin >> a[i][j];
    }
    int ans = 1e9;
    for (int bit = 0; bit < (1 << n); bit++) {
        vector<int> score(m, 0);
        int price = 0;
        for (int i = 0; i < n; i++) {
            if(bit & (1<<i)){
                for (int j = 0; j < m; j++){
                    score[j] += a[i][j];
                }
                price += c[i];
            }
        }
        bool can = true;
        rep(i, m) {
            if(score[i] < x){
                can = false;
            }
        }
        if(can){
            ans = min(ans, price);
        }
    }
    cout << (ans == 1e9 ? -1 : ans) << endl;
}

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

int main() {
    int a, b, ans = -1;
    cin >> a >> b;
    for (int i = 1; i <= 1009; i++) {
        if (floor(i * 0.08) == a) {
            if (floor(i * 0.1) == b) {
                ans = i;
                break;
            }
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 3660
import queue

h, w = map(int, input().split())
S = [input() for _ in range(h)]
n_black = 0
for s in S:
    n_black += s.count('#')

q = queue.Queue()
if S[0][0] == '.': 
    q.put((0, 0))
else: 
    print(-1)
    exit()

dist = [[-1] * w for _ in range(h)]
dist[0][0] = 1

while True:
    i, j = q.get()

    for ni, nj in ((i-1, j), (i, j-1), (i, j+1), (i+1, j)):
        if ni < 0 or ni >= h or nj < 0 or nj >= w: continue
        if S[ni][nj] == '.' and dist[ni][nj] == -1:
            q.put((ni, nj))
            dist[ni][nj] = dist[i][j] + 1
    
    if q.empty(): break

if dist[-1][-1] == -1: print(-1)
else: print(h * w - dist[-1][-1] - n_black)


Measured memory_bytes: 42856
#include <bits/stdc++.h>
using namespace std;
int a,b,c;

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

return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<map>
#include<set>
#include<list>
#include<queue>
#include<cmath>
#include<string>
#include<string.h>
#include<iomanip>
#include<stdlib.h>
#include<algorithm>
typedef long long ll;
using namespace std;

int main()
{
	int a,b,c;
	int flag = 0;
	cin >> a >> b >> c;
	if(c >= a && c <= b)
		flag = 1;
	if(flag == 1)
		cout << "Yes" << endl;
	else
		cout << "No" << endl;
	return 0;
} 

Measured memory_bytes: 256
import os
import sys
from collections import deque
from collections import Counter
from heapq import heappop,heappush
import math

def main():
	money = int(input())	
	yokin = 100
	count = 0
	while yokin < money:
		yokin = yokin + math.floor((1/100)*yokin)
		count += 1
	print(count)


if __name__ == "__main__":
        main()



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

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

int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    int a, b, c;
    cin >> a >> b >> c;
    int ans = 0;
    if(a==b && b==c)
    {
        ans = 1;
    }
    else if(a==b || b==c || c==a)
    {
        ans = 2;
    }
    else
    {
        ans = 3;
    }
    cout << ans << endl;

    return 0;
}


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

int main(){
	int n;
	cin >> n;
	vector<int> a, b;
	int zero=0;
	for(int i=0; i<n; i++){
		int num;
		cin >> num;
		if(num==0) zero++;
		if(num==0 || num==1){
			b.push_back(num);
		}else{
			a.push_back(num);
		}
	}
	sort(a.begin(), a.end());
	sort(b.begin(), b.end());
	int sa = a.size(), sb = b.size();
	
	if(zero%2==1){
		if(b[sb-1]==0){
			if(!a.empty()){
				b.push_back(a[0]);
				a.erase(a.begin());
				sa--; sb++;
			}
		}
		swap(b[zero-1], b[zero]);
	}
	if(sa>=2 && a[sa-2]==2 && a[sa-1]==3){
		swap(a[sa-2], a[sa-1]);
	}
	
	for(int i=0; i<sa; i++) cout << a[i] << endl;
	for(int i=0; i<sb; i++) cout << b[i] << endl;
	return 0;
}


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

using namespace std;

#define sp(x) cout<<setprecision(x);
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,n) FOR(i,0,n)
#define all(a) (a).begin(), (a).end()
#define inf 10000000
#define linf INT64_MAX*0.99
#define print(s) cout<<(s)<<endl
#define lint long long
#define yes "Yes"
#define no "No"

typedef pair<int, int> P;
 
int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n,k; cin>>n>>k;
    print(n-k+1);
    return 0;
}

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

using namespace std;
int main(){
  int n[4];
  cin >> n[0] >> n[1] >> n[2] >> n[3];

  sort(n, n+4);

  if(n[0]==1 && n[1]==4 && n[2]==7 && n[3]==9){
    cout << "YES" << endl;
  } else {
    cout << "NO" << endl;
  }

  return 0;
}


Measured memory_bytes: 256
#include<cmath>
#include <bits/stdc++.h>
using ll = long long;
using namespace std;
stack<int> st;
queue<int> qu;
queue<pair<int,int> > qu2;
priority_queue<int> pq;
#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define rep2(i,n) for(int i=1; i<=(int)(n); i++)
#define mins(x,y) x=min(x,y)
#define maxs(x,y) x=max(x,y)
#define ALL(a) a.begin(), a.end()
typedef set<int> set_t;
typedef set<string> set_g;
typedef complex<double> xy_t;
static const int NIL = -1;
static const int INF = 1000000007;
#define mp make_pair
#define sz(x) int(x.sise())
#define mod 1000000007
#define reps(i,s,n) for(int i = s; i < n; i++)
#define Rreps(i,n,e) for(int i = n - 1; i >= e; --i)
#define Rrep(i,n) Rreps(i,n,0)
deque<int> deq;
#define fi first
#define se second
//const ll MOD = 998244353;
const ll MOD = (1e+9) + 7;
typedef pair<int, int> P;
typedef vector<ll> vec;
typedef vector<vec> mat;

vector<int> row;

int main(){
    int n;
    cin >> n;
    string s1,s2;
    cin >> s1>> s2;
    int temp=-1;
    int cti=0;
    rep(i,n){
        if(temp==s1[i]-'a'){
            cti++;
        }else{
            if(cti>0){
                if(cti==1){
                    row.push_back(0);
                }
                else{
                    cti=1;
                    row.push_back(1);
                }
            }else{
                cti=1;
            }
            temp=s1[i]-'a';
        }
    }
    if(cti>0){
        if(cti==1){
            row.push_back(0);
        }else{
            cti=1;
            row.push_back(1);
        }
    }
    int now=-1;
    ll ans=1;
    rep(i,row.size()){
        if(now==0&&row[i]==0){
            ans*=2;
        }else if(now==1&&row[i]==0){
            ans*=1;
        }else if(now==0&&row[i]==1){
            ans*=2;
        }else if(now==1&&row[i]==1){
            ans*=3;
        }
        if(now==-1&&row[i]==0){
            ans*=3;
        }else if(now==-1&&row[i]==1){
            ans*=6;
        }
        ans%=mod;
        now=row[i];
        //cerr<<now;
    }
    //cerr<<endl;
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 3640
(defun solve (a b c d e)
  (let ((time-taken 0)
        (most-inefficient 0))
    (loop :for x :in (list a b c d e)
          :do
             (let* ((taken- (- 10 (rem x 10)))
                    (taken (if (= 10 taken-) 0 taken-))
                    (time (+ x taken)))
               (incf time-taken time)
               (setf most-inefficient (max most-inefficient taken))))
    (- time-taken most-inefficient)))

(defun main ()
  (format t "~A~%" (solve (read) (read) (read) (read) (read))))

(main)


Measured memory_bytes: 5860
#include <bits/stdc++.h>
using namespace std;
int h, w;
vector<int> dx = {-1, 0, 1, 0};
vector<int> dy = {0, -1, 0, 1};
vector<vector<char>> a;
struct blackcell {
    int bh;
    int bw;
    int dist;
};

int main() {
    cin >> h >> w;
    a = vector<vector<char>>(h, vector<char>(w, '.'));
    queue<blackcell> que;
    for(int i = 0; i < h; ++i) {
        for(int j = 0; j < w; ++j) {
            cin >> a.at(i).at(j);
            if(a.at(i).at(j) == '#') {
                blackcell first;
                first.bh = i;
                first.bw = j;
                first.dist = 0;
                que.push(first);
            }
        }
    }

    int anscnt = 0;

    while(!que.empty()) {
        blackcell exe;
        exe = que.front();
        anscnt = max(anscnt, exe.dist);
        que.pop();
        for(int i = 0; i < 4; ++i) {
            if(exe.bh+dy.at(i) < h && exe.bh+dy.at(i) >= 0 && exe.bw+dx.at(i) < w && exe.bw+dx.at(i) >= 0) {
                if(a.at(exe.bh+dy.at(i)).at(exe.bw+dx.at(i)) != '#') {
                    a.at(exe.bh+dy.at(i)).at(exe.bw+dx.at(i)) = '#';
                    blackcell next;
                    next.bh = exe.bh+dy.at(i);
                    next.bw = exe.bw+dx.at(i);
                    next.dist = exe.dist + 1;
                    que.push(next);
                }
            }
        }
    }

    cout << anscnt << endl;
}

Measured memory_bytes: 13328
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <queue>
#include <set>
#include <map>
#include <cmath>
using namespace std;
typedef long long i64;
typedef long double ld;
typedef pair<i64,i64> P;
#define rep(i,s,e) for(int i = (s);i <= (e);i++)

int n;
i64 p;
i64 q;

i64 c[505050];

int main(){
    cin >> n >> p >> q;
    priority_queue<i64,vector<i64>,greater<i64>> que;
    i64 sum = 0;
    rep(i,0,n - 1){
        cin >> c[i];
        sum += c[i];

        que.push(i * p + c[i]);
    }

    i64 result = sum;

    for(int i = 0;!que.empty();i++){
        sum += p * q + 2 * i * p;
        sum -= que.top();
        que.pop();
        result = max(result , sum);
    }

    cout << result << endl;
}



Measured memory_bytes: 10952
X = int(input())

a = 1

def f(x, a):
    return 5 * a * (x ** 4) - 10 * (a ** 2) * (x ** 3) + 10 * (a ** 3) * (x ** 2) - 5 * (a ** 4) * x + a ** 5

def df(x, a):
    y = 5 * (x ** 4) + (-20 * a + 10) * (x ** 3) + (30 * (a ** 2) - 30 * a + 10) * (x ** 2) + (-20 * (a ** 3) + 30 * (a ** 2) - 20 * a + 5) * x + 5 * (a ** 4) - 10 * (a ** 3) + 10 * (a ** 2) - 5 * a + 1
    return y

x = 0
a = 1
s = 0
while True:
    s += df(x, a)
    if s == X:
        break
    if s > X:
        x += 1
        a = 0
        s = 0
    a += 1

print(x, x-a)


Measured memory_bytes: 9228
/*
--------------              |   /
      |                     |  /
      |                     | /
      |             *       |/          |    |         ------            *
      |                     |           |    |        /      \
      |             |       |\          |    |       |       |\          |
   \  |             |       | \         |    |       |       | \         |
    \ |             |       |  \        |    |        \     /   \        |
     V              |       |   \        \__/|         -----     \       |
*/
#include <bits/stdc++.h>
using namespace std;

#define EmiliaMyWife ios::sync_with_stdio(0); cin.tie(NULL);
#define mem(i,j) memset(i,j,sizeof (i));
using ll = int64_t;
using ull = uint64_t;
using ld = long double;
using uint = uint32_t;
const double EPS  = 1e-8;
const int INF     = 0x3F3F3F3F;
const ll LINF     = 4611686018427387903;
const int MOD     = 1e9+7;
/*-----------------------------------------------------------------------------------------------------*/

signed main() {
	EmiliaMyWife

	int n;
	cin >> n;
	vector<bool> w(n);
	for(int i = 0, a, b; i < n; i++)
		cin >> a >> b, w[i] = (a == b);
	bool ans = 0;
	for(int i = 2; i < n; i++)
		ans |= (w[i] && w[i - 1] && w[i - 2]);
	cout << (ans ? "Yes" : "No") << '\n';

	return 0;
}


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

int main(){
  int N;
  int d[101];
  int num[101] = {0};

  cin >> N;
  for(int i = 0; i < N; ++i) cin >> d[i];
  
  for(int i = 0; i < N; i++) num[d[i]]++;

  int ans = 0;
  for(int i = 1; i <= 100; i++){
	  if(num[i]) {
		  ++ans;
	  }
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
int main(void){
    int s,a,b,c;
   scanf("%d",&s);
       a=s/3600;
       b=(s-a*3600)/60;
       c=s-(a*3600+b*60);
   
   printf("%d:%d:%d\n",a,b,c);
   return 0;
}

Measured memory_bytes: 2712
#define _USE_NATH_DEFINES
#include <cstdio>
#include <iostream>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <complex>
#include <string>
#include <vector>
#include <list>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <bitset>
#include <numeric>
#include <limits>
#include <climits>
#include <cfloat>
#include <functional>
#include <iterator>
#include <random>
#include <tuple>


using namespace std;
#define REP(i,m,n) for(int i=(int)m ; i < (int) n ; ++i )
#define rep(i,n) REP(i,0,n)
using ll = long long;
#define EPS 1e-9
const int INF = 1050000000;
const long long LINF = 1LL << 60;
const ll MOD = 1e9 + 7;
const int MINF = -1050000000;

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

int main() {
	int a[32] = { 1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51 };
	int k;
	cin >> k;
	cout << a[k - 1] << endl;
	return 0;
}


Measured memory_bytes: 256
#include <stdio.h>

int main(void)
{
    int n;
    scanf("%d", &n);
    int d[n];
    for (int i = 0; i < n; i++){
        scanf("%d", &d[i]);
    }

    int ans = 0;
    for (int i = 0; i < n - 1; i++){
        for (int j = i + 1; j < n; j++){
            ans += d[i] * d[j];
        }
    }
    printf("%d", ans);
    return 0;
}

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

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



int main(){
    int n; scanf("%d",&n);
    string s; cin>>s;
    string ans; ans+=s[0];
    rep(i,0,n-1){
        if(s[i]!=s[i+1])ans+=s[i+1];
    }
    printf("%d\n",(int)ans.size());
    return 0;
}

Measured memory_bytes: 512
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <algorithm>
#include <cmath>
#include <sstream>
#include <iomanip>
#include <set>
using namespace std;
typedef long long int ll;

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define YES cout << "YES" << endl
#define Yes cout << "Yes" << endl
#define yes cout << "yes" << endl
#define NO cout << "NO" << endl
#define No cout << "No" << endl
#define no cout << "no" << endl

const int INF = 1001001001;
const int mod = 1000000007;
#define PI 3.14159265359;

void P(int x) {cout << x << endl;}
void P(long x) {cout << x << endl;}
void P(double x) {cout << x << endl;}
void P(ll x) {cout << x << endl;}
void P(string x) {cout << x << endl;}
void P(char x) {cout << x << endl;}

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

int main() {
  int a, b, c;
  cin >> a >> b >> c;
  P(a * b / 2);

  return 0;
}

Measured memory_bytes: 256
fun main(args: Array<String>) {
    val s = readLine()!!
    val k = readLine()!!.toLong()
    var t = 0
    for (c in s) {
        if (c == '1') {
            t++
        } else {
            break
        }
    }
    if (k > t) {
        println(s[t])
    } else {
        println(1)
    }
}


Measured memory_bytes: 33508
#include "bits/stdc++.h"
// Begin Header {{{
#define all(x)          (x).begin(), (x).end()
#define rep(i, s, n)    for (i64 i = (s), i##_limit = (n); i < i##_limit; ++i)
#define repr(i, s, t)   for (i64 i = (s), i##_limit = (t); i >= i##_limit; --i)
#define var(type, ...)  type __VA_ARGS__; read(__VA_ARGS__);
#ifndef DBG
#define dump(...)
#endif
using namespace std;
using i64 = int_fast64_t;
using pii = pair<i64, i64>;
template <class T, class U> inline bool chmax(T &a, const U &b) { return b > a && (a = b, true); }
template <class T, class U> inline bool chmin(T &a, const U &b) { return b < a && (a = b, true); }
constexpr int INF  = 0x3f3f3f3f;
constexpr i64 LINF = 0x3f3f3f3f3f3f3f3fLL;

template <class T>
inline vector<T> makeV(const T &initValue, size_t sz) {
    return vector<T>(sz, initValue);
}

template <class T, class... Args>
inline auto makeV(const T &initValue, size_t sz, Args... args) {
    return vector<decltype(makeV<T>(initValue, args...))>(sz, makeV<T>(initValue, args...));
}

template <class T>
inline istream& operator>> (istream &is, vector<T> &vec) {
    for (auto &e : vec) is >> e;
    return is;
}

inline void read() {}

template <class Head, class... Tail>
inline void read(Head &head, Tail&... tail) { cin >> head; read(tail...); }

inline void print() { cout << "\n"; }

template <class Head, class... Tail>
inline void print(Head &&head, Tail&&... tail) {
    cout << head;
    if (sizeof...(tail)) cout << ' ';
    print(forward<Tail>(tail)...);
}

template <class T>
inline ostream& operator<< (ostream &os, const vector<T> &vec) {
    static constexpr const char *delim[] = { " ", "" };
    for (const auto &e : vec) os << e << delim[&e == &vec.back()];
    return os;
}

template <class Container>
struct Rev {
    Container &x_;
    inline Rev(Container &x): x_(x) {}
    inline auto begin() { return rbegin(x_); }
    inline auto end() { return rend(x_); }
};
// }}} End Header

int f(i64 n) {
    int cnt = 0;
    while (n > 0 && n % 100 == 0) {
        n /= 100;
        ++cnt;
    }
    return cnt;
}

signed main() {
    ios_base::sync_with_stdio(false); cin.tie(nullptr);

    var(int, D, N);
    int cnt = 0;
    rep(i, 1, 1000000000) {
        if (f(i) == D) ++cnt;
        if (cnt == N) {
            print(i);
            return 0;
        }
    }

    return 0;
}


Measured memory_bytes: 256
n = int(input())
ans = 0
cnt = [[0] * 9 for _ in range(9)]
tmp = 0
for i in range(1, n + 1):
    one = str(i)
    if one[-1] == '0':
        continue
    cnt[int(one[0]) - 1][int(one[-1]) - 1] += 1
for i in range(9):
    for j in range(9):
        ans += cnt[i][j] * cnt[j][i]
print(ans)

Measured memory_bytes: 3064
#include <iostream>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <string>
#include <numeric>
#include <cmath>

typedef long long ll;
#define FOR(i,a,b) for(ll i=(a);i<(b);i++)
#define REP(i,a) FOR(i,0,a)

template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
    std::fill( (T*)array, (T*)(array+N), val );
}

using namespace std;

int main(void) {
    int w, h, n;
    cin >> w >> h >> n;
    int colors[100][100];
    Fill(colors, 1);

    REP(i, n) {
        int x, y, a;
        cin >> x >> y >> a;
        if (a == 1) {
            REP(j, x) {
                REP(k, 100) {
                    colors[j][k] = 0;
                }
            }
        }
        else if (a == 2) {
            FOR(j, x, 100) {
                REP(k, 100) {
                    colors[j][k] = 0;
                }
            }
        }
        else if (a == 3) {
            REP(j, y) {
                REP(k, 100) {
                    colors[k][j] = 0;
                }
            }
        }
        else if (a == 4) {
            FOR(j, y, 100) {
                REP(k, 100) {
                    colors[k][j] = 0;
                }
            }
        }
    }

    int ans = 0;
    FOR(i, 0, w) {
        FOR(j, 0, h) {
            ans += colors[i][j];
        }
    }
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
int m,f,b;
cin>>m>>f>>b;
if(m>=b)
cout<<"0"<<endl;
else{
m=b-m;
if(m<=f)
cout<<m<<endl;
else
cout<<"NA"<<endl;
}
return(0);
}


Measured memory_bytes: 3120
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;
typedef long double ld;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  int a, b;
  cin >> a >> b;
  int cnt = 0;
  FOR(i, a, b + 1) {
    int s = i / 10000;
    int t = i % 10;
    int u = i / 10 % 10;
    int v = (i - s * 10000) / 1000;
    if(s == t && u == v) cnt++;
  }
  cout << cnt << endl;
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <fstream>
#include <set>
#include <map>
#include <string>
#include <vector>
#include <queue>
#include <deque>
#include <stack>
#include <functional>
#include <algorithm>
#include <climits>
#include <cmath>
#include <iomanip>
using namespace std;
#define ll long long int
#define rep(i,n) for( int i = 0; i < n; i++ )
#define rrep(i,n) for( int i = n; i >= 0; i-- )
#define REP(i,s,t) for( int i = s; i <= t; i++ )
#define RREP(i,s,t) for( int i = s; i >= t; i-- )
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define INF 2000000000
#define mod 1000000007
#define INF2 1000000000000000000
#define int long long

signed main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N; cin >> N;
    int a[200010];
    rep(i, N) cin >> a[i];
    rep(i, N) a[i]--;
    int b[200010];
    rep(i, N) b[a[i]] = i;
    set<int> st;
    st.insert(-1);
    st.insert(N);
    int ans = 0;
    rep(i, N) {
        int idx = b[i];
        auto itr2 = --st.lower_bound(idx);
        auto itr = st.lower_bound(idx);
        ans += (i + 1) * (*itr - idx) * (idx - *itr2);
        // cerr << idx << " " << *itr << " " << (*itr - idx) << endl;
        st.insert(idx);
    }
    cout << ans << endl;

    return 0;
}
// 2 1 3

// 1 3 2 4
// 1 1 1 1 
//   3 2 2
//     2 2
//       4

Measured memory_bytes: 16132