akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <string>

using namespace std;

int main(){
	string str;
	string str2;
	cin >> str;
	str2=str;
	for(int i=0;i<(int)str.length()/2;i++){
		swap(str[i],str[str.length()-i-1]);
	}
	if(str==str2){
		cout << "Yes" << endl;
	}else{
		cout << "No" << endl;
	}
	return 0;
}

Measured memory_bytes: 256
///////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////
//                       _oo0oo_                         //
//                      o8888888o                        //
//                      88" . "88      ------ hzt1       //
//                      (| -_- |)                        //
//                      0\  =  /0                        //
//                    ___/`---'\___                      //
//                  .' \|     |// '.                     //
//                 / \|||  :  |||// \                    //
//                / _||||| -:- |||||- \                  //
//               |   | \  -  /// |     |                 //
//               | \_|  ''\---/''  |_/ |                 //
//               \  .-\__  '-'  ___/-. /                 //
//             ___'. .'  /--.--\  `. .'___               //
//          ."" '<  `.___\_<|>_/___.' >' "".             //
//         | | :  `- \`.;`\ _ /`;.`/ - ` : | |           //
//         \  \ `_.   \_ __\ /__ _/   .-` /  /           //
//     =====`-.____`.___ \_____/___.-`___.-'=====        //
//                       `=---='                         //
//                                                       //
//                                                       //
//     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~       //
//                                                       //
//                 God-He Bless All.                     //
//           This Code Will Never Explode.               //
//                                                       //
//                                                       //
///////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////
#include<cstdio>
#include<cstring>
#include<cctype>
#include<algorithm>
#define rep(i,a,b) for(int i=(a),i##_end_=(b);i<=i##_end_;i++)
#define dwn(i,a,b) for(int i=(a),i##_end_=(b);i>=i##_end_;i--)
using namespace std;
const int Size=1<<16;
char buffer[Size],*head,*tail;
inline char Getchar() {
    if(head==tail) {
        int l=fread(buffer,1,Size,stdin);
        tail=(head=buffer)+l;
    }
    if(head==tail) return -1;
    return *head++;
}
inline int read() {
    int x=0,f=1;char c=Getchar();
    for(;!isdigit(c);c=Getchar()) if(c=='-') f=-1;
    for(;isdigit(c);c=Getchar()) x=x*10+c-'0';
    return x*f;
}
typedef long long ll;
const int maxn=500010;
int n,m,Q,ans[maxn];
int d[maxn],q[maxn];
int f[maxn];
int main() {
	n=read();m=read();
	rep(i,1,n) d[i]=read();
	f[n+1]=1;
	dwn(i,n,1) {
		if(d[i]>=2*f[i+1]) f[i]=f[i+1];
		else f[i]=f[i+1]+d[i];
	}
	int x=m;
	rep(i,1,n) {
		ans[i]=(f[i+1]<=x);
		x=min(x,abs(x-d[i]));
	}
 	Q=read();
 	while(Q--) {
		int x=read();
		puts(ans[x]?"YES":"NO"); 
	}
	return 0;
}

Measured memory_bytes: 9600
#include<stdio.h>
int main(void)
{
	int a,b;
	scanf("%d%d",&a,&b);
	if(a<b){
		printf("a < b\n");
	}
	if(a>b){
		printf("a > b\n");
	}
	if(a==b){
		printf("a == b\n");
	}
	return 0;
}

Measured memory_bytes: 580
#include <algorithm>
#include <cmath>
#include <cstdint>
#include <cstdio>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
using namespace std;
#define rep(i, n) for(int(i) = 0; (i) < (n); (i)++)
#define FOR(i, m, n) for(int(i) = (m); (i) < (n); (i)++)
#define All(v) (v).begin(), (v).end()
#define pb push_back
#define MP(a, b) make_pair((a), (b))
using ll = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
const int INF = 1 << 30;
const ll LINF = 1LL << 60;
const int MOD = 1e9 + 7;

int main() {
    int H, W;
    cin >> H >> W;
    vector<string> strs(H);
    rep(i, H) { cin >> strs[i]; }
    rep(i, H) {
        strs[i].pb('#');
        reverse(All(strs[i]));
        strs[i].pb('#');
        reverse(All(strs[i]));
    }
    rep(i, W + 2) cout << '#';
    cout << endl;
    rep(i, H) cout << strs[i] << endl;
    rep(i, W + 2) cout << '#';
    cout << endl;
    return 0;
}

Measured memory_bytes: 3624
#include <algorithm>
#include <cmath>
#include <cstdlib>
#include <iostream>
#include <map>
#include <vector>
using namespace std;
typedef long long int ll;

int main(int argc, char const *argv[]) {
  ll N;
  cin >> N;
  map<ll, ll> A;
  for (ll i = 0; i < N; i++) {
    ll temp;
    cin >> temp;
    A[temp]++;
  }
  ll ans = 0;
  for (auto iter = A.begin(); iter != A.end(); iter++) {
    cerr << "iter.second=" << iter->second << endl;
    if (iter->second % 2 == 1) ans++;
  }
  cout << ans << endl;
  return 0;
}

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

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

typedef long long ll;
using namespace std;
int mod = 1000000007;

int main(void){
    int K, X; cin >> K >> X;
    if(500*K >= X) cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define show(x) cerr << #x << " = " << (x) << endl;
using namespace std;
template <typename T>
constexpr T INF = numeric_limits<T>::max() / 16;
struct CostGraph
{
    using T = int;
    CostGraph(const int v) : V{v}, edge(v) {}
    struct Edge
    {
        Edge(const int from, const int to, const T cost) : from{from}, to{to}, cost{cost} {}
        const int from;
        const int to;
        const T cost;
        bool operator<(const Edge& e) const { return cost != e.cost ? cost < e.cost : to < e.to; }
    };
    void addEdge(const int from, const int to, const T cost) { edge[from].push_back(Edge{from, to, cost}), edge[to].push_back(Edge{to, from, cost}); }
    const int V;
    vector<vector<Edge>> edge;
};
vector<CostGraph::T> Dijkstra(const CostGraph& g, const int s)
{
    using T = CostGraph::T;
    assert(s < g.V);
    vector<T> d(g.V, INF<T>);
    using P = pair<T, int>;
    priority_queue<P, vector<P>, greater<P>> q;
    d[s] = 0;
    q.push(make_pair(0, s));
    while (not q.empty()) {
        const T cost = q.top().first;
        const int v = q.top().second;
        q.pop();
        if (d[v] < cost) { continue; }
        for (const auto& e : g.edge[v]) {
            if (d[e.to] > d[v] + e.cost) { d[e.to] = d[v] + e.cost, q.push(make_pair(d[e.to], e.to)); }
        }
    }
    return d;
}
struct Edge
{
    int u, v, d, c;
    bool operator<(const Edge& e) const { return c < e.c; }
};
inline ostream& operator<<(ostream& os, const Edge& e) { return (os << "<" << e.u << "," << e.v << "," << e.d << "," << e.c << ">"); }
template <typename T, typename A>
inline ostream& operator<<(ostream& os, const vector<T, A>& v)
{
    os << "[";
    for (const auto& p : v) { os << p << ","; }
    return (os << "]" << endl);
}
int main()
{
    while (true) {
        int N, M;
        cin >> N >> M;
        if (N == 0 and M == 0) { break; }
        CostGraph g(N);
        vector<Edge> edge(M);
        for (int i = 0; i < M; i++) {
            int u, v, d, c;
            cin >> u >> v >> d >> c;
            u--, v--;
            edge[i] = {u, v, d, c};
            g.addEdge(u, v, d);
        }
        const auto d = Dijkstra(g, 0);
        vector<int> mini(N, INF<int>);
        mini[0] = 0;
        for (const auto& e : edge) {
            if (d[e.u] + e.d == d[e.v]) { mini[e.v] = min(mini[e.v], e.c); }
            if (d[e.v] + e.d == d[e.u]) { mini[e.u] = min(mini[e.u], e.c); }
        }
        cout << accumulate(mini.begin(), mini.end(), 0) << endl;
    }
    return 0;
}



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

int H, W;
vector<vector<char>> m;
vector<vector<int>> n;

void search(int y, int x) {
    if (y < H-1 && n[y+1][x] == -1) return;
    if (x < W-1 && n[y][x+1] == -1) return;

    int a = INT_MAX;
    int b = INT_MAX;
    if (y < H-1) {
        a = n[y+1][x];
        if (m[y+1][x] == '.' && m[y][x] == '#') ++a;
    }
    if (x < W-1) {
        b = n[y][x+1];
        if (m[y][x+1] == '.' && m[y][x] == '#') ++b;
    }
    n[y][x] = min(a, b);

    if (x > 0) {
        search(y, x-1);
    }
    if (y > 0) {
        search(y-1, x);
    }
}

int main() {
    cin >> H >> W;

    m.resize(H);
    rep(i,H) {
        m[i].resize(W);
    }

    char t;
    rep(i,H) {
        rep(j,W) {
            cin >> t;
            m[i][j] = t;
        }
    }

    n.resize(H);
    rep(i,H) {
        n[i].resize(W);
    }
    rep(i,H) {
        rep(j,W) {
            n[i][j] = -1;
        }
    }
    if (m[H-1][W-1] == '#') n[H-1][W-1] = 1;
    else n[H-1][W-1] = 0;

    search(H-1, W-2);
    search(H-2, W-1);

    cout << n[0][0] << endl;
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define maxn 2009
#define mod 1000000007
using namespace std;
int f[maxn][maxn];
int main(){
  int n,k,ans=0;
  scanf("%d%d",&n,&k);
  f[0][n+1]=1;
  for(int i=1;i<k;i++){
    for(int j=n;j>0;j--) f[i-1][j]=(f[i-1][j]+f[i-1][j+1])%mod;
    for(int j=1;j<=n-i+1;j++) f[i][j]=f[i-1][j];
  }
  for(int i=2;i<=n+1;i++) ans=(ans+f[k-1][i])%mod;
  for(int i=1;i<n-k;i++) ans=ans*2%mod;
  printf("%d",ans);
  return 0;
}


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

typedef long long ll;
const ll N = 1e5;

int main()
{
    int n,i,j,m;
    double a,t,c;

    cin>>n;
    cin>>t>>a;
    int b[n+5];
    for(i=0; i<n; i++) cin>>b[i];
    //for(i=0; i<n; i++) cout<<abs(a-t+(b[i]*0.006))<<endl;
    for(i=0; i<n; i++)
    {
        if(!i) m=i;
        else if( abs(a-t+(b[i]*0.006))< abs(a-t+(b[m]*0.006))) m=i;
    }

    cout<<m+1<<endl;

    return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(a,n) for (ll a = 0; a < (n); ++a)
using namespace std;
using ll = long long;
typedef pair<ll,ll> P;
typedef pair<P,ll> PP;
typedef vector<vector<ll> > Graph;
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; }
const ll INF = 1e9;

// auto mod int
// depends on Template

const int mod = 1000000007;
//const int mod = 998244353;
struct mint {
  ll x; // typedef long long ll;
  mint(ll x=0):x((x%mod+mod)%mod){}
  mint operator-() const { return mint(-x);}
  mint& operator+=(const mint a) {
    if ((x += a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator-=(const mint a) {
    if ((x += mod-a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator*=(const mint a) { (x *= a.x) %= mod; return *this;}
  mint operator+(const mint a) const { return mint(*this) += a;}
  mint operator-(const mint a) const { return mint(*this) -= a;}
  mint operator*(const mint a) const { return mint(*this) *= a;}
  mint pow(ll t) const {
    if (!t) return 1;
    mint a = pow(t>>1);
    a *= a;
    if (t&1) a *= *this;
    return a;
  }

  // for prime mod
  mint inv() const { return pow(mod-2);}
  mint& operator/=(const mint a) { return *this *= a.inv();}
  mint operator/(const mint a) const { return mint(*this) /= a;}
};
istream& operator>>(istream& is, const mint& a) { return is >> a.x;}
ostream& operator<<(ostream& os, const mint& a) { return os << a.x;}

long long modpow(long long a, long long n) {
    long long res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}

//input
ll n,m;
vector<ll>x,y;

int main(){
    cin >> n >> m;
    x.resize(n);
    rep(i,n)cin>>x[i];
    y.resize(m);
    rep(i,m)cin>>y[i];
    mint yoko = 0;
    rep(i,n-1){
        mint now = 1;
        now *= x[i+1]-x[i];
        now *= i+1;
        now *= n-i-1;
        yoko += now;
    }
    mint tate = 0;
    rep(i,m-1){
        mint now = 1;
        now *= y[i+1]-y[i];
        now *= i+1;
        now *= m-i-1;
        tate += now;
    }
    mint ans = 1;
    ans *= tate;
    ans *= yoko;
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 4788
#include <bits/stdc++.h>
#define rep(i, a, n) for (int i = a; i < n; i++)
#define repr(i, a, n) for (int i = n - 1; i >= a; i--)
using namespace std;
using ll = long long;
using P = pair<int, int>;

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

  int h, a;
  cin >> h >> a;
  cout << (h + a - 1) / a << endl;
}


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

//型定義
typedef long long ll;

//定数
const int INF=1e+9;
const int MOD=1e+9+7;

//REPマクロ
#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define REP2(i,a,b) for(ll i=a;i<(ll)(b);i++)
#define REPD2(i,a,b) for(ll i=a;i>(ll)(b);i--)

// 多次元 vector 生成
template<class T>
vector<T> make_vec(size_t a){
    return vector<T>(a);
}
template<class T, class... Ts>
auto make_vec(size_t a, Ts... ts){
  return vector<decltype(make_vec<T>(ts...))>(a, make_vec<T>(ts...));
}

//vectorの扱い
#define ALL(x) (x).begin(),(x).end() //sortなどの引数省略
#define SIZE(x) ((ll)(x).size()) //size
#define MAX(x) *max_element(ALL(x)) //最大値
#define MIN(x) *min_element(ALL(x)) //最小値

int main(){
    ll a;
    cin>>a;
    ll ans=a+a*a+a*a*a;
    cout<<ans<<endl;
}

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

int main() {
  long long n;
  long long num;
  long long ans=1e10;

  int cnt=0;

  cin >> n;

  for(long long i=sqrt(n);i>0;i--) {
    if(n%i==0) {
      num = max(i,n/i);
      while(num!=0) {
        num = num/10;
        cnt++;
      }
      ans = cnt;
      break;
    }
  }

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 256
class Sieve:
    """区間[2,n]の値を素因数分解する"""

    def __init__(self, n=1):
        primes = []
        f = [0] * (n + 1)
        f[0] = f[1] = -1
        for i in range(2, n + 1):  # 素数を探す
            if f[i]: continue
            primes.append(i)
            f[i] = i  # 素数には自身を代入
            for j in range(i * i, n + 1, i):  # 合成数に素因数を書き込む
                if not f[j]:
                    f[j] = i  # 最小の素因数を代入
        self.primes = primes
        self.f = f

    def is_prime(self, x) -> bool:  # 素数判定
        return self.f[x] == x

    def factor_list(self, x) -> list:  # 素因数分解の昇順リスト, [2,2,3,5,...]
        res = []
        while x != 1:
            res.append(self.f[x])
            x //= self.f[x]
        return res

    def factor(self, x) -> list:  # 素因数分解の頻度リスト, [[2,x],[3,y],[5,z],...]
        fl = self.factor_list(x)
        if not fl: return []
        res = [[fl[0], 0]]
        for p in fl:
            if res[-1][0] == p:
                res[-1][1] += 1
            else:
                res.append([p, 1])
        return res


def main():
    from collections import defaultdict

    MOD = 10 ** 9 + 7
    A_MX = 10 ** 6

    N = int(input())
    *a, = map(int, input().split())

    s = Sieve(n=A_MX)

    dict_lcm = defaultdict(int)
    for x in a:
        for prime, cnt in s.factor(x):
            dict_lcm[prime] = max(dict_lcm[prime], cnt)

    lcm = 1
    for prime, count in dict_lcm.items():
        lcm = lcm * pow(prime, count, MOD) % MOD

    ans = 0
    for x in a:
        ans = (ans + pow(x, MOD - 2, MOD)) % MOD
    ans = ans * lcm % MOD
    print(ans)


if __name__ == '__main__':
    main()


Measured memory_bytes: 15460
#include<iostream>
#include<vector>
#include<string>
#include<set>
using namespace std;

int main() {
	int a, b, c;
	cin >> a >> b >> c;
	set<int>s;
	s.insert(a);
	s.insert(b);
	s.insert(c);
	cout << s.size() << endl;
}

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

#define ll long long
#define ull unsigned long long int
#define INF 0x3f3f3f3f
#define pb push_back
#define pii pair<int, int>

const int t = 100005;
int n;
int a[t], b[t], c[t];
int memo[t][3];

int solve(int id, int atual) {
    if (id == n)
        return 0;
    int &ans = memo[id][atual];
    if (ans != -1)
        return ans;
    if (atual == 1)
        return ans = a[id] + max(solve(id + 1, 2), solve(id + 1, 3));
    if (atual == 2)
        return ans = b[id] + max(solve(id + 1, 1), solve(id + 1, 3));
    if (atual == 3)
        return ans = c[id] + max(solve(id + 1, 2), solve(id + 1, 1));
}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    
    cin >> n;
    for (int i = 0; i < n; i++) {
        cin >> a[i] >> b[i] >> c[i];
    }
    memset(memo, -1, sizeof memo);
    int ans = solve(0, 1);
    memset(memo, -1, sizeof memo);
    ans = max(ans, solve(0, 2));
    memset(memo, -1, sizeof memo);
    ans = max(ans, solve(0, 3));
    cout << ans << "\n";
    
    //cerr << "\n" << 1.0 * clock() / CLOCKS_PER_SEC << " s.\n";
    return 0;
}

Measured memory_bytes: 7296
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(),x.rend()
#define print(s) cout << s << endl
#define acc(v) accumulate(v.begin(), v.end(), 0)
#define cinv(n,v) rep(i,n) cin >> v[i]
using namespace std;
const int INF = 1e9;
typedef long long ll;
typedef pair<int,int> pii;
typedef vector<int> vint;
typedef vector<string> vstr;
typedef vector<char> vchar;
const ll LINF = 1e18;
const ll MOD = 1e9 + 7;
int x_pos[4] = {1,0,-1,0}, y_pos[4] = {0,1,0,-1};
int ctoi(char c) {
	if (c >= '0' && c <= '9') {
		return c - '0';
	}
	return 0;
}

char upper(char c){
	return c-0x20;
}

char lower(char c){
	return c+0x20;
}

void unique_vector(vector<int>& v){
	sort(all(v));
	v.erase(unique(all(v)), v.end());
}

// n次元配列の初期化。第２引数の型のサイズごとに初期化していく。
template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
    std::fill( (T*)array, (T*)(array+N), val );
}

int gcd(int x, int y) {
  if (y == 0) return x;
  return gcd(y, x%y);
}

int main() {
    int n,a,b;
    cin>>n>>a>>b;
    if(b-a==1){
        cout << "Borys" << endl;
        return 0;
    }
    cout << ((b-a)%2==0 ? "Alice" : "Borys") << endl;
}



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

namespace MyProject
{
    class Program
    {
        static void Main(string[] args)
        {
#if Local
            var sw = new Stopwatch();
            sw.Start();
            Console.SetIn(new StreamReader("input.in"));
#endif

            var solver = new Solver();
            solver.Solve();
#if Local
            Console.WriteLine($"{sw.ElapsedMilliseconds}ms");
#endif
        }
    }

    class Solver
    {
        public void Solve()
        {
            var N = int.Parse(Console.ReadLine());
            var A = Console.ReadLine().Split().Select(elem => int.Parse(elem)).OrderBy(elem => elem).ToArray();
            var table = Enumerable.Range(1, A.Last()).ToDictionary(elem => elem, elem => true);
            foreach (var i in Enumerable.Range(0, N))
            {
                if (table[A[i]] == false)
                {
                    continue;
                }

                for (var j = 2 * A[i]; j <= A.Last(); j += A[i])
                {
                    table[j] = false;
                }
            }

            var answer = 0;
            foreach (var i in Enumerable.Range(0, N))
            {
                if (i + 1 < N && A[i] == A[i + 1])
                {
                    table[A[i]] = false;
                }
                else
                {
                    if (table[A[i]])
                    {
                        answer++;
                    }
                }
            }

            Console.WriteLine(answer);
        }
    }
}


Measured memory_bytes: 87460
def SumofThreeIntegers():
    K, S = map(int, input().split())

    count = 0

    for x in range(K+1):
        for y in range(K+1):
            z = S - x - y
            if 0 <= z <= S and z <= K:
                count += 1
    print(count)

if __name__ == "__main__":
    SumofThreeIntegers()

Measured memory_bytes: 3060
#include "bits/stdc++.h"
using namespace std;
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define sz(x) ((int)(x).size())
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repr(i, n) for (int i = (int)(n)-1; i >= 0; i--)
#define repf(i, x, n) for (int i = (int)(x); i < (int)(n); i++)
#define repfr(i, x, n) for (int i = (int)(x)-1; i >= (int)(n); i--)
#define INF 1e9
using ll = int64_t;
template <class T>
bool chmax(T &a, const T &b)
{
  if (a < b)
  {
    a = b;
    return true;
  }
  return false;
}
template <class T>
bool chmin(T &a, const T &b)
{
  if (b < a)
  {
    a = b;
    return true;
  }
  return false;
}

//10^9 + 7
#define yojo 1000000007

std::int64_t gcd(std::int64_t a, std::int64_t b)
{
  // a >= b && b != 0
  std::int64_t c;
  do
  {
    c = a % b;
    a = b;
    b = c;
  } while (c);

  return a;
}
std::int64_t gcd_s(std::int64_t aa, std::int64_t bb)
{
  std::int64_t a = max(aa, bb);
  std::int64_t b = min(aa, bb);
  std::int64_t c;
  if (b == 0)
  {
    return -1;
  }
  do
  {
    c = a % b;
    a = b;
    b = c;
  } while (c);

  return a;
}
void rle(std::vector<std::pair<char, std::int64_t>> &data, std::string str)
{
  char now = str[0];
  std::int64_t count = 0;
  for (std::int64_t i = 0; i < str.size() + 1; i++)
  {
    if (i == str.size())
    {
      data.push_back(make_pair(str[i - 1], count));
      break;
    }
    else if (now != str[i])
    {
      data.push_back(make_pair(now, count));
      now = str[i];
      count = 0;
    }
    count++;
  }

  return;
}

#define MAX_NUM 200001

void Main()
{
  int n;
  int k;
  int q;
  cin >> n >> k >> q;
  vector<int> a(q);
  vector<int> people(n, k);
  rep(i, q)
  {
    cin >> a[i];
  }

  int count = 0;
  rep(i, q)
  {
    people[a[i] - 1]++;
    count++;
  }

  rep(i, n)
  {
    people[i] -= count;
    if (people[i] <= 0)
    {
      std::cout << "No" << std::endl;
    }
    else
    {
      std::cout << "Yes" << std::endl;
    }
  }

  return;
}

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


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

int main(){
    int S;
    cin >> S;
    int hr,min,sec;
    hr = S / 3600;
    min = (S-hr*3600)/60;
    sec = S-hr*3600-min*60;
    cout << hr << ":" << min << ":" << sec << endl;
    return 0;
}


Measured memory_bytes: 3088
#include <iostream>
using namespace std;
int main() {
	long n, i, j;
	long ans=1;
	cin >> n;
	int x, y, z,a;
	for (x = 2; x <= n; x++) {
		z = 0;
		if (x > 2) {
			for (y = 2; y < x - 1; y++) {
				if (x%y == 0)z++;
			}
		}
		if (z == 0) {
			i = 0;
			j = n;
			while (j > 1) {
				a = j % x;
				j = j - a;
				i = i + j / x;
				j = j / x;
			}
			ans = ans * (i + 1);
			if (ans >= 1000000007) ans = ans % 1000000007;
		}
	}
	cout << ans<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define sz(x) int(x.size())
#define show(x) {for(auto i: x){cout << i << " ";} cout << endl;}
using namespace std;
using ll = long long;
using P = pair<int, int>;

struct UnionFind {
    vector<int> d;
    UnionFind(int n): d(n,-1) {}
    int root(int x) {
        if (d[x] < 0) return x;
        return d[x] = root(d[x]);
    }
    bool unite(int x, int y) {
        x = root(x); y = root(y);
        if (x == y) return false;
        if (d[x] > d[y]) swap(x,y);
        d[x] += d[y];
        d[y] = x;
        return true;
    }
    bool same(int x, int y) { return root(x) == root(y);}
    int size(int x) { return -d[root(x)];}
};  // UnionFind uf(N);  // 0-indexed

int deg[200005];
vector<int> graph[200005];

int main() {
    int N, M;
    cin >> N >> M;
    UnionFind uf(N);
    rep(i, M) {
        int a, b;
        cin >> a >> b;
        --a; --b;
        uf.unite(a, b);       
    }
    int ans = 0;
    rep(i, N) {
        int temp = uf.size(i);
        if (temp > ans) ans = temp;
    }
    cout << ans << '\n';    
    return 0;
}

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

int main () {
	int a, b, c;
	cin >> a >> b >> c;
	if (a==b && a!= c){
		cout << c <<endl;
	} else if (b==c && a!=c){
		cout << a << endl;
	} else if (a==c && a!=b){
		cout << b << endl;
	}

}


Measured memory_bytes: 256
#include<iostream>
#include<cstring>
#include<cstdio>
#include<algorithm>
#include<cmath>
#include<set>
#include<bitset>
#include<map>

#define fo(i,a,b) for(int i=a;i<=b;i++)
#define fd(i,a,b) for(int i=a;i>=b;i--)

using namespace std;

typedef long long LL;
typedef double db;

int get(){
	char ch;
	while(ch=getchar(),(ch<'0'||ch>'9')&&ch!='-');
	if (ch=='-'){
		int s=0;
		while(ch=getchar(),ch>='0'&&ch<='9')s=s*10+ch-'0';
		return -s;
	}
	int s=ch-'0';
	while(ch=getchar(),ch>='0'&&ch<='9')s=s*10+ch-'0';
	return s;
}

const int N = 1e+5+5;

int n;
int a[N],b[N];
int nxta[N],nxtb[N];
map<int,int>ha,hb;
map<int,int>cnt;
int fa[N],siz[N];

int getfather(int x){
	if (fa[x]==x)return x;
	return fa[x]=getfather(fa[x]);
}

int main(){
	n=get();
	fo(i,1,n)a[i]=get();
	fo(i,1,n)b[i]=get();
	fo(i,1,n){
		a[0]^=a[i];
		b[0]^=b[i];
	}
	bool bz=1;
	fo(i,0,n)cnt[a[i]]++;
	fo(i,0,n){
		if (!cnt[b[i]]){bz=0;break;}
		cnt[b[i]]--;
	}
	if (!bz){
		printf("-1\n");
		return 0;
	}
	fo(i,0,n)ha[a[i]]=hb[b[i]]=n+1;
	fd(i,n,0)
	if (i==0||a[i]!=b[i]){
		nxta[i]=ha[a[i]];
		ha[a[i]]=i;
		nxtb[i]=hb[b[i]];
		hb[b[i]]=i;
	}
	fo(i,0,n)fa[i]=i,siz[i]=1;
	for(map<int,int>::iterator h=ha.begin();h!=ha.end();h++){
		int v=(*h).first;
		int f0=getfather(ha[v]);
		for(int x=ha[v];x<=n;x=nxta[x]){
			int f1=getfather(x);
			if (f1!=f0){
				fa[f1]=f0;
				siz[f0]+=siz[f1];
			}
		}
		for(int x=hb[v];x<=n;x=nxtb[x]){
			int f1=getfather(x);
			if (f1!=f0){
				fa[f1]=f0;
				siz[f0]+=siz[f1];
			}
		}
	}
	int ans=0;
	fo(i,0,n)
	if (i==0||a[i]!=b[i]){
		if (getfather(i)==i)ans=ans+siz[i]+1;
	}
	ans=ans-2;
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 18176
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <climits>
#include <cfloat>
#include <ctime>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>
#include <numeric>
#include <list>

using namespace std;

#ifdef _MSC_VER
#define __typeof__ decltype
template <class T> int __builtin_popcount(T n) { return n ? 1 + __builtin_popcount(n & (n - 1)) : 0; }
#endif

#define foreach(it, c) for (__typeof__((c).begin()) it=(c).begin(); it != (c).end(); ++it)
#define all(c) (c).begin(), (c).end()
#define rall(c) (c).rbegin(), (c).rend()
#define popcount __builtin_popcount

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

template <class T> void max_swap(T& a, const T& b) { a = max(a, b); }
template <class T> void min_swap(T& a, const T& b) { a = min(a, b); }

const double EPS = 1e-10;
typedef long long ll;
typedef pair<int, int> pint;


int main()
{
	int w, q;
	while (cin >> w >> q, w | q)
	{
		int p[256];
		fill(p, p + w, -1);
		p[w] = -2;
		while (q--)
		{
			char c;
			cin >> c;
			if (c == 's')
			{
				int id, width;
				cin >> id >> width;
				int i;
				for (i = 0; i < w; ++i)
					if (count(p + i, p + i + width, -1) == width)
						break;
				if (i != w)
				{
					fill_n(p + i, width, id);
					cout << i << endl;
				}
				else
					cout << "impossible" << endl;
			}
			else
			{
				int id;
				cin >> id;
				replace(p, p + w, id, -1);
			}

			getchar();
		}
		cout << "END" << endl;
	}
}

Measured memory_bytes: 0
from collections import deque

N = int(input())

G = [[] for _ in range(N)]
for i in range(N-1):
  a, b = map(int, input().split())
  G[a-1].append([b-1, i])
  G[b-1].append([a-1, i])


q = deque()
q.append([0, 0, 0])

colors = [0] * (N-1)
while q:
  node, parent, edge_color = q.popleft()
  c = 1
  for child, index in G[node]:
    if child == parent:
      continue
    
    if c == edge_color:
      c += 1
    
    q.append([child, node, c])
    colors[index] = c
    c += 1

print(max(colors))
print(*colors, sep='\n')

Measured memory_bytes: 48268
import java.util.Scanner;
import java.util.List;
import java.util.ArrayList;
import java.util.Collections;
public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        List<Integer> a = new ArrayList<>();
        for (int i = 0; i < 3 * n; i++) {
            a.add(sc.nextInt());
        }

        Collections.sort(a, Collections.reverseOrder());
        long ans = 0;
        for (int i = 1; i < 2 * n; i += 2) {
            ans += a.get(i);
        }
        System.out.println(ans);
    }
}


Measured memory_bytes: 97052
#include "bits/stdc++.h"
using namespace std;
#define rep(i,n)for(int i=0;i<(int)(n);i++)
#define PI 3.141592653589793
//vector < vector<int>>a(0, vector<int>(0));二次元配列宣言


int main()
{
	string s;
	cin >> s;
	if (s.at(5) == '0' && s.at(6) >= '1' && s.at(6) <= '4')
		cout << "Heisei" << endl;
	else
		cout << "TBD" << endl;
}

Measured memory_bytes: 3596
#include <algorithm>
#include <cstdint>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>
#include <cfloat>

using namespace std;

using lint=int64_t;
using uint=uint32_t;
using ulint=uint64_t;

template<class T>
using vector2d=vector<vector<T>>;

template<class T>
bool UpdateMax(T &a, const T &b){
  if(a<b){
    a=b;
    return true;
  }else{
    return false;
  }
}

template<class T>
bool UpdateMin(T &a, const T &b){
  if(a>b){
    a=b;
    return true;
  }else{
    return false;
  }
}

template <class T>
void OutVec(const vector<T>& vec){
  for(int i = 0; i < vec.size() - 1; ++i){
    cout<<vec[i]<<" ";
  }
  cout<<vec.back()<<endl;
}

template <class T>
void OutVec2d(const vector2d<T>& vec){
  for(auto v:vec){
    OutVec(v);
  }
}

int main(){
  cout << std::fixed << std::setprecision(16);
  cin.tie(nullptr);
  std::ios::sync_with_stdio(false);

  int n,m;
  cin>>n>>m;
  cout<<(n==m?"Yes":"No")<<endl;

  return 0;
}




Measured memory_bytes: 256
using System;
using System.Text;
using System.Collections.Generic;
using System.Linq;
using System.Numerics;
class AtCoder
{
    const int MOD = 1000000007;
    public void Slove()
    {
        var n = int.Parse(Console.ReadLine());
        long[] hist = new long[26];
        foreach(var c in Console.ReadLine())
        {
            hist[c - 'a']++;
        }
        long ans = hist.Aggregate(1L, (sum, x) => sum * (x + 1) % MOD);
        ans = ans == 0 ? MOD - 1: ans - 1;
        System.Console.WriteLine(ans);
    }
    static void Main()
    {
        var ac = new AtCoder();
        ac.Slove();
    }
}

Measured memory_bytes: 13268
#include<stdio.h>
#include<string.h>
int main()
{
  char s[100001], t1[]={"dream"}, t2[]={"dreamer"}, t3[]="erase", t4[]="eraser";
  int i, j, f=0;

  scanf("%s", s);
  
  i = strlen(s);
  while( i > 0  ){
    if( i >=5 && strncmp( &s[i-5], t1, strlen(t1)) == 0) {
       i -= strlen(t1);
    } else  if( i >=7 && strncmp( &s[i-7], t2, strlen(t2)) == 0) {
       i -= strlen(t2);
    } else  if( i >=5 && strncmp( &s[i-5], t3, strlen(t3)) == 0) {
       i -= strlen(t3);
    } else  if( i >=6 && strncmp( &s[i-6], t4, strlen(t4)) == 0) {
       i -= strlen(t4);
    } else {
       f = 1;
       break;
    }
  }

  if( f ) {
    printf("NO\n");
  } else {
    printf("YES\n");
  }

  return 0;
}


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

#define FOR(i,n,j) for(int i=(j);i<(n);++i)
#define ssort(n) sort((n).begin(),(n).end())
using ll=long long;
using ld=long double;
typedef pair<int,int> P;
#define repl(i,n) for(ll i=0;i<(n);++i)
#define Yes cout << "Yes" << endl
#define No cout << "No" << endl
#define YES cout << "YES" << endl
#define NO cout << "NO" << endl

int main()
{
    string n;
    cin >> n;
    ll ans=0;
    rep(i,n.size()){
        ans+=n[i]-'0';
    }
    if(ans%9==0){
        Yes;
    }else{
        No;
    }
}

Measured memory_bytes: 3752
#include<bits/stdc++.h>
using namespace std;
#define ALL(x) x.begin(),x.end()
#define rep(i,n) for(int i=0;i<(n);i++)
#define debug(v) cout<<#v<<":";for(auto x:v){cout<<x<<' ';}cout<<endl;
#define INF 1000000000
#define mod 1000000007
using ll=long long;
const ll LINF=1001002003004005006ll;
int dx[]={1,0,-1,0};
int dy[]={0,1,0,-1};
// ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
template<class T>bool chmax(T &a,const T &b){if(a<b){a=b;return true;}return false;}
template<class T>bool chmin(T &a,const T &b){if(b<a){a=b;return true;}return false;}
using int128=__int128;

void solve(){
    ll n,a,b,c,d;cin>>n>>a>>b>>c>>d;

    map<int128,int128> memo;
    memo[0]=0;memo[1]=d;
    function<int128(int128)> rec=[&](int128 m){
        if(memo.count(m)) return memo[m];

        int128 res=(int128)m*d;
        if(m%2==0){
            chmin(res,rec(m/2)+a);
        }else{
            if((m+1)/2<m) chmin(res,rec((m+1)/2)+a+d);
            if((m-1)/2<m) chmin(res,rec((m-1)/2)+a+d);
        }

        if(m%3==0){
            chmin(res,rec(m/3)+b);
        }else{
            for(int128 i=1;i<3;i++){
                if(m%3!=i) continue;
                if((m-i)/3<m) chmin(res,rec((m-i)/3)+b+i*d);
                if((m+3-i)/3<m) chmin(res,rec((m+3-i)/3)+b+(3-i)*d);
            }
        }

        if(m%5==0){
            chmin(res,rec(m/5)+c);
        }else{
            for(int128 i=1;i<5;i++){
                if(m%5!=i) continue;
                if((m-i)/5<m) chmin(res,rec((m-i)/5)+c+i*d);
                if((m+5-i)/5<m) chmin(res,rec((m+5-i)/5)+c+(5-i)*d);
            }
        }
        return memo[m]=res;
    };
    cout<<(ll)rec(n)<<endl;
}

signed main(){
    cin.tie(0);
    ios::sync_with_stdio(0);
    
    int q;cin>>q;
    while(q--) solve();    
    return 0;
}


Measured memory_bytes: 4636
from bisect import bisect_right

A, B, Q = map(int, input().split())
INF = 10**18
s = [-INF] + [int(input()) for _ in range(A)] + [INF]
t = [-INF] + [int(input()) for _ in range(B)] + [INF]

for _ in range(Q):
    x = int(input())
    sh_r, te_r = bisect_right(s, x), bisect_right(t, x)
    sh_l, te_l = sh_r - 1, te_r - 1
    SR, SL, TR, TL = s[sh_r], s[sh_l], t[te_r], t[te_l]
    ans = INF
    for i in [SR, SL]:
        for j in [TR, TL]:
            dis = abs(i-x) + abs(i-j)
            dis = min(dis, abs(j-x) + abs(j-i))
            ans = min(ans, dis)
    print(ans)


Measured memory_bytes: 14336
#include<cstdio>
#include<iostream>
#include<cmath>
using namespace std;
int h[100010],f[100010];
int main(){
	int n,k;
	cin>>n>>k;
	for(int i=1;i<=n;i++){
		cin>>h[i];
	}
	for(int i=2;i<=n;i++){
			f[i]=1e9;
		for(int j=1;j<=k&&i-j>0;j++){
			f[i]=min(f[i],f[i-j]+abs(h[i]-h[i-j]) );
		}
	}
	printf("%d\n",f[n]);
} 

Measured memory_bytes: 1024
#include <bits/stdc++.h>
#include<string.h>
#define rep(i,a,n) for(int i=int (a);i<int (n);i++)
#define OUT  freopen("output.txt", "w", stdout)
#define IN  freopen("input.txt", "r", stdin)
#define mem(a,b) memset((a),(b),sizeof(a))
#define NumofDigits(n) ((int)log10(n)+1)
#define NumofBits(n) ((int)log2(n)+1)
#define PI 3.14159265358979323846264
#define vii vector<pair<int,int>>
#define all(x) x.begin(),x.end()
#define pii pair<int,int>
#define pll pair<ll,ll>
#define vi  vector<int>
#define nl  cout<<"\n"
#define pb  push_back
#define mp  make_pair
#define ll  long long 
#define ss  second 
#define ff  first
#define endl "\n"
#define sp  " "
using namespace std;

int main(){
  ll k,c=1;
  cin>>k;
  ll a=7;
  unordered_set<int> b;
  b.insert(7);
  if(k%2 == 0){
    cout<<-1<<"\n";
    return 0;
  }
  else{
    while(a%k != 0){
      ll r = a%k;
      a = r*10+7;
      c++;
      if(b.find(a) != b.end()){
        cout<<-1<<"\n";
        return 0;
      }
      b.insert(a);
    }
    cout<<c;
  }
}


Measured memory_bytes: 42616
#include <iostream>
#include <vector>
#include <string>
#include <cmath>
#include <algorithm>
#include <utility>
#include <queue>
#include <set>
#include <map>
#include <deque>
#include <iomanip>
#include <cstdio>
#include <stack>
#include <numeric>
#include <cassert>
using namespace std;
typedef  long long ll;
typedef pair<int,int> PII;
typedef vector<int> VI;
typedef vector<VI> VVI;
#define  MP make_pair
#define  PB push_back
#define inf 1000000007
#define mod 1000000007
#define rep(i,n) for(int i=0;i<(int)(n);++i)

class tsort {
public:
	int V;
	vector<vector<int> > G;
	vector<int> deg,res;
	tsort(int node_size) : V(node_size), G(V), deg(V, 0){}
	void add_edge(int from,int to){
		G[from].push_back(to);
		deg[to]++;
	}
	bool solve() {
		queue<int> que;
		for(int i = 0; i < V; i++){
			if(deg[i] == 0){
				que.push(i);
			}
		}
		while(!que.empty()){
			int p = que.front();
			que.pop();
			res.push_back(p);
			for(int v : G[p]){
				if(--deg[v] == 0){
					que.push(v);
				}
			}
		}
		return (*max_element(deg.begin(),deg.end()) != 0);
	}
    int calc(){
        int n = res.size();
        vector<int> a(n);
        vector<int>rev(n);
        for(int i=0;i<n;i++){
            rev[res[i]] = i;
        }
        for(int i=n-1;i>=0;i--){
            int c = 1;
            for(auto x:G[res[i]]){
                c = max(c,1+a[rev[x]]);
            }
            a[i] = c;
        }
        
        return *max_element(a.begin(),a.end());
    }
};

int main(){
    int n;
    cin >> n;
    vector<vector<int> > a(n,vector<int>(n-1));
    vector<vector<int> > g(n*(n-1)/2);
    vector<vector<int> > s(n);
    map<pair<int,int>,int> mp;
    int c = 0;
    for(int i=0;i<n;i++){
        for(int j=i+1;j<n;j++){
            mp[MP(i,j)]=c;
            c++;
        }
    }
    rep(i,n){
        rep(j,n-1){
            cin >> a[i][j];
            a[i][j]--;
            int k =0;
            if(a[i][j]>i){
                k = mp[MP(i,a[i][j])];
            }else{
                k = mp[MP(a[i][j],i)];
            }
            s[i].push_back(k);
        }
    }
    tsort ts(n*(n-1)/2);
    rep(i,n){
        rep(j,n-2){
            ts.add_edge(s[i][j],s[i][j+1]);
        }
    }
    if(ts.solve()){
        cout << -1 << endl;
    }else{
        cout << ts.calc() << endl;
    }
    return 0;
}

Measured memory_bytes: 78580
#include <iostream>
#include <vector>
#include <string>
#include <cmath>
#include <set>
#include <algorithm>
#include <array>
#include <complex>
#include <string>
#include <utility>
#include <map>
#include <queue>
#include <list>
#include <functional>
#include <numeric>
#include <stack>
#include <tuple>

using namespace std;
int dx[4] = { -1,0,1,0 };
int dy[4] = { 0,1,0,-1 };
const int INF = 100000000;
const long long LINF = 1000000000000000000;
const int MOD = (int)1e9 + 7;
const double EPS = 1e-6;
using pii = std::pair<int, int>;
using ll=long long;  
using pLL = std::pair<ll, ll>;
#define SORT(v) std::sort(v.begin(), v.end())
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    int n,k;
	cin >> n >> k;
	double ans=0.0;
	for(int i=1;i<=n;++i){
		int now=i;
		double temp=1.0/n;
		while(now<k){
			now*=2;
			temp/=2.0;
		}
		ans+=temp;
	}
	printf("%1.9f\n",ans);
    return 0;
}


Measured memory_bytes: 256
/* AOJ0558 Cheese */

#include <iostream>
#include <queue>
//#include <string.h>

using namespace std;

const int N = 1000;
char grid[N][N];
int w, h, n;

// 各点到当前工厂的距?
int d[N][N];

const int direct[4][2] = {
    { -1, 0 },
    { 1, 0 },
    { 0, -1 },
    { 0, 1 },
};

int factory[10][2];
typedef pair<int, int> P;

int bfs(const int& sx, const int& sy, const int& gx, const int& gy)
{
    //memset(d, -1, sizeof(d));
    for (int i = 0; i < h; ++i)
    {
        for (int j = 0; j < w; ++j)
        {
            d[j][i] = -1;
        }
    }
    queue<P> que;
    que.push(P(sx, sy));
    d[sx][sy] = 0;
    while (que.size())
    {
        const P p = que.front(); que.pop();
        // 如果是?点就?束
        if (p.first == gx && p.second == gy)
        {
            break;
        }

        // 四方向漫游
        for (int i = 0; i < 4; ++i)
        {
            int nx = p.first + direct[i][0];
            int ny = p.second + direct[i][1];
            // 是否可以移?，并且?点没有???
            if (0 <= nx && nx < w && 0 <= ny && ny < h && grid[nx][ny] != 'X' && d[nx][ny] == -1)
            {
                que.push(P(nx, ny));
                d[nx][ny] = d[p.first][p.second] + 1;
            }
        }
    }

    return d[gx][gy];
}

int main()
{

    while(cin >> h >> w >> n) {
        for (int i = 0; i < h; ++i)
            for (int j = 0; j < w; ++j) {
                cin >> grid[j][i];
                if (grid[j][i] == 'S') {
                    factory[0][0] = j;
                    factory[0][1] = i;
                    grid[j][i] = '.';
                }
                else if (isdigit(grid[j][i])) {
                    factory[grid[j][i] - '0'][0] = j;
                    factory[grid[j][i] - '0'][1] = i;
                }
            }


        int minstep = 0;
        for (int i = 0; i < n; ++i) {
            minstep += bfs(factory[i][0], factory[i][1], factory[i + 1][0], factory[i + 1][1]);
        }

        cout << minstep << endl;
    }

    return 0;
}

Measured memory_bytes: 7980
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i,n) for(int i=0;i<n;i++)
int main(void){
    // Your code here!
    vector<string> YN{"NO","YES"};
    vector<string> yn{"No","Yes"};
    int a,b,c;
    cin>>a;
    cout<<"ABC"<<a<<endl;
}


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

#define int ll

typedef long long ll;

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

typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<pii> vpii;
typedef vector<pll> vpll;

#define FOR(i, a, b) for (int i=a; i<(b); i++)
#define F0R(i, a) for (int i=0; i<(a); i++)
#define FORd(i,a,b) for (int i = (b)-1; i >= a; i--)
#define F0Rd(i,a) for (int i = (a)-1; i >= 0; i--)

#define ALL(s) (s).begin(),(s).end()
#define ALLn(s,n) s,s+n
#define F first
#define S second
#define pb push_back
#define tc(t) int t; cin >> t; while(t--)
#define _ ios_base::sync_with_stdio(false); cin.tie(NULL);
#define D1(x) { cerr << " [" << #x << ": " << x << "]\n"; }
#define D2(x) { cerr << " [" << #x << ": "; for(auto it:x) cerr << it << " "; cerr << "]\n"; }

const ll MOD = 1e9 + 7;
const ll MAXN = 1e6 + 7;
const ll INF = LONG_LONG_MAX;


void solve() {
	char c;
	cin >> c;
	if(c >= 'A' && c <= 'Z') cout << 'A';
	else cout << 'a';
}

int32_t main() {_
	
#ifndef ONLINE_JUDGE
	freopen("in", "r", stdin);
	freopen("out", "w", stdout);
#endif
	// tc(t)
		solve();
	cerr << "[ Time : " << (float)clock() / CLOCKS_PER_SEC << " secs ]" << endl;
}

Measured memory_bytes: 3800
#include <stdio.h>
#include<string.h>
#include<stdlib.h>
int string(char a[], char b[])
{
	int i =0;
 
	while (a[i] !='\0')
	{
		if (a[i] != b[i])
			return 0;
		i++;
	}
	if (b[i] != '\0')
		return 0;
	return 1;
}
 
int main()
{
	int B, R;
	int i, j;
	char b[100][10],r[100][10];
	int m,n;
	int fea=0;
 
	scanf("%d",&B);
	getchar();
	for (i = 0; i < B; i++)
	{
		gets(b[i]);
		//getchar();
		//scanf_s("%s", b[i]);
	}
 
	scanf("%d", &R);
	getchar();
	for (i = 0; i < R; i++)
	{
		gets(r[i]);
		//scanf_s("%s", r[i]);
	}
 
	for (i = 0; i < B; i++)
	{
		m = 0;
		n = 0;
		for (j = 0; j < B; j++)
		{
			if (string(b[i], b[j]))
			{
				m++;
				//b[j][0]='X';
				//b[j][1] ='Y';
			}
		}
		for (j = 0; j < R; j++)
		{
			if (string(b[i], r[j]))
			{
				n++;
			}
		}
		if(m-n>fea)
		fea = m - n;
	}
     printf("%d",fea);
 
    return 0;
}
 

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

typedef long long ll;
#define REP(i,n) for(int i=0,_n=(int)(n);i<_n;++i)
#define ALL(v) (v).begin(),(v).end()
#define CLR(t,v) memset(t,(v),sizeof(t))
template<class T1,class T2>ostream& operator<<(ostream& os,const pair<T1,T2>&a){return os<<"("<<a.first<<","<<a.second<< ")";}
template<class T>void pv(T a,T b){for(T i=a;i!=b;++i)cout<<(*i)<<" ";cout<<endl;}
template<class T>void chmin(T&a,const T&b){if(a>b)a=b;}
template<class T>void chmax(T&a,const T&b){if(a<b)a=b;}


int nextInt() { int x; scanf("%d", &x); return x;}
ll nextLong() { ll x; scanf("%lld", &x); return x;}

int main2() {
  int N; cin >> N;
  string s; cin >> s;
  int ans = 0;
  for (int i = 1; i < N; i++) {
    string t1 = s.substr(0, i);
    string t2 = s.substr(i);
    int x = 0;
    for (int i = 0; i < 26; i++) {
      if (count(ALL(t1), 'a' + i) > 0 && count(ALL(t2), 'a' + i) > 0) x++;
    }
    chmax(ans, x);
  }
  cout << ans << endl;
  return 0;
}

int main() {

#ifdef LOCAL
  for (;!cin.eof();cin>>ws)
#endif
    main2();
  return 0;
}

Measured memory_bytes: 256
n = int(input())
a = []
for i in range(n):
    x,y = map(int,input().split())
    a.append([x,y])
count = 0
flag = True
for x in a:
    if x[0] == x[1]:
        count += 1
        if count == 3:
            print('Yes')
            flag = False
            break
    else:
        count = 0

if flag:
    print('No')

Measured memory_bytes: 9188
N="0"+input()
N=N[::-1]
DP=[[0,0]for i in range(len(N))]

DP[0][0]=int(N[0])
DP[0][1]=10-int(N[0])

#print(DP)
#print(N)
for i in range(1,len(N)):
    DP[i][0]=min(DP[i-1][0]+int(N[i]),DP[i-1][1]+int(N[i])+1)
    DP[i][1]=min(DP[i-1][0]+10-int(N[i]),DP[i-1][1]+10-(int(N[i])+1))
#print(DP)
print(min(DP[-1]))

Measured memory_bytes: 139096
#include <bits/stdc++.h>
#include <stdio.h>
#include <cmath>
#include <tgmath.h>

using namespace std;

#define rep(i,n) for(long long i=0; i<(long long)(n);i++)
//rep…「0からn-1まで」の繰り返し
#define rep2(i,s,n) for(long long i=s; i<=(long long)(n);i++)
//rep2…「sからnまで」の繰り返し
#define repr(i,s,n) for(long long i=s;i>=(long long)(n);i--)
//repr…「ｓからnまで」の降順の繰り返し

typedef long long ll;

const ll inf = 1e18+7;
const ll mod = 1e9+7;


int main() {

    int n;
    string s;
    cin>>n>>s;

    int x=0,MAX=0;

    rep(i,n){
        if(s[i]=='I')x++;
        else x--;

        MAX=max(MAX,x);
    }

    cout<<MAX<<endl;
}


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

// input
int N;
vector<ll> T;


void input() {
    cin >> N;
    T = vector<ll>(N);
    rep(i, N) cin >> T[i];
}


// 最大公約数
ll gcd(ll a, ll b) {
    while (b) {
        ll tmp = a % b;
        a = b;
        b = tmp;
    }
    return a;
}


// 最小公倍数
ll lcm(ll a, ll b) {
    if (a < b) swap(a, b);
    return (a / gcd(a, b)) * b;
}


int main() {
    input();
    ll ans = 1;
    rep(i, N) ans = lcm(ans, T[i]);
    cout << ans << endl;
}


Measured memory_bytes: 3616
#include <bits/stdc++.h>
using namespace std;
typedef vector<long long> vi;
typedef vector<vi> vvi;
typedef vector<bool> vb;
typedef vector<vb> vvb;
typedef vector<string> vs;
typedef long long int ll;
typedef unsigned long long int ull;
typedef pair<int, int> pii;

inline bool valid(int x, int n) {
    return 0 <= x && x < n;
}

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

template <typename T>
inline T pop(queue<T>& q) {
    T front = q.front();
    q.pop();
    return front;
}

template <typename T>
inline T gcd(T a, T b) {
    for (; b; a %= b, swap(a, b));
    return a; 
}

template <typename T>
tuple<T, T, T> xgcd(T a, T b) {
    if (b == 0) return {1, 0, a};
    T x, y, g;
    tie(x, y, g) = xgcd(b, a%b);
    return {y, x-(a/b)*y, g};
}

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

    int N, R; cin >> N >> R;
    if (N >= 10) cout << R;
    else {
        cout << 100 * (10 - N) + R;
    }
}

Measured memory_bytes: 256
//...Bismillahir Rahmanir Rahim...
// Code by    Asad Bin Saber
// 04 04 2020

#include <stdio.h>
#include <string.h>
#include <vector>
#include <algorithm>
#include <math.h>
#include <iostream>

using namespace std;

void task()
{
    long long n, k, i;

    cin>>n>>k;

    n = n % k;

    while(1){
        if(n==0) break;
        else if(n<abs(k-n)) break;
        n = abs(n-k);
    }

    cout<<n<<endl;
}

int main()
{
    task();

    return 0;
}


Measured memory_bytes: 256