akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
int main(){
  string s;
  cin>>s;
  if(s.at(0)=='A'){
    int count=0,count2=0;
    for(int i=2;i<s.size()-1;i++){
      if(s.at(i)=='C'){
        count++;
      }
    }
    for(int i=1;i<s.size();i++){
      if(s.at(i)=='A'||s.at(i)=='B'||s.at(i)=='C'||s.at(i)=='D'||s.at(i)=='E'
         ||s.at(i)=='F'||s.at(i)=='G'||s.at(i)=='H'||s.at(i)=='I'||s.at(i)=='J'
         ||s.at(i)=='K'||s.at(i)=='L'||s.at(i)=='M'||s.at(i)=='N'||s.at(i)=='O'
         ||s.at(i)=='P'||s.at(i)=='Q'||s.at(i)=='R'||s.at(i)=='S'||s.at(i)=='T'
         ||s.at(i)=='U'||s.at(i)=='V'||s.at(i)=='W'||s.at(i)=='X'||s.at(i)=='Y'
         ||s.at(i)=='Z')count2++;
    }
    if(count==1&&count2==1)
       cout<<"AC"<<endl;
    else cout<<"WA"<<endl;
  }
  else cout<<"WA"<<endl;
}

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

template<class S,class T>ostream& operator<<(ostream&os,pair<S,T>p){os<<"["<<p.first<<", "<<p.second<<"]";return os;};
template<class S>auto&operator<<(ostream&os,vector<S>t){bool a=1; for(auto s:t){os<<(a?"":" ")<<s; a=0;} return os;}

int main(){
	cin.tie(0);
   	ios::sync_with_stdio(false);
	
	int n;
	cin>>n;
	if(n%2==1 and n%8!=1) cout<<"YES"<<endl;
	else cout<<"NO"<<endl;
	return 0;
}


Measured memory_bytes: 256
/*input
10 9
9 6 5 7 5 9 8 5 6 7
8 6 8 5 5 7 9 9 7

*/
#include <bits/stdc++.h>
using namespace std;

// ALL DEFFINES HERE
#define ll long long int
#define ii pair<int, int>
#define mp make_pair
#define N 100005
#define rep(i, n) for(int i=0; i < n; i++)
#define Rep(i, k, n) for(int i=k; i < n; i++)
#define pb push_back
#define vi vector<int>
#define vii vector< vector<int> >
#define vl vector<ll>
#define F first
#define S second
#define all(v) v.begin(), v.end()

// ALL declarations here const ints etc
const  ll mod = 1e9+7; 

// IMPORTANT FUNCTION DECLARATIONS , 
//SORRY FOR THE BAD PRESENTATION
ll gcd(ll a, ll b)
{
	if ( b==0)
		return a;
	return gcd(b, a%b);
}
ll absl(ll a )
{
	return  a>= 0 ?a:-a;
}
ll maxl(ll a, ll b)
{
	return a >= b? a:b;
}
ll exp(ll a, ll n)
{
	if ( n==0)
		return 1;
	if ( n==1 )
		return a;
	if ( n & 1)
		return (a%mod * exp((a*a)%mod, n/2)%mod)%mod;
	else
		return exp((a*a)%mod, n/2)%mod;
}
// --->>> main starts here
// m*h >= l + k
double mi( double a , double b)
{
	return a < b? a : b;
}
double mx( double a , double b)
{
	return a >= b ? a : b;
}
struct type{
	int l, r;
};
void solve()
{
	int n , m;
	cin >> n >> m;
	vi s(n+1) , t(m+1);
	for ( int i=1; i <= n; i++)
		cin >> s[i];
	for ( int i=1 ; i <= m; i++)
		cin >> t[i];
	vector< vector<ll> > v( n+1 , vector<ll>( m+1 , 1));
	for ( int i=1; i <= n; i++)
		for ( int j =1; j <= m; j++)
		{
			v[i][j] = (v[i-1][j]%mod + v[i][j-1]%mod)%mod;
			if ( s[i]!= t[j])
				v[i][j] =(v[i][j]%mod -v[i-1][j-1]%mod + mod)%mod;

		}
	cout << v[n][m] << "\n";
	// for ( int i=0; i <= n; i++)
	// {
	// 	for ( int j =0; j <= m; j++)
	// 	{
	// 		cout << v[i][j] << " ";
	// 	}
	// 	cout << "\n";
	// }



	
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  // auto beginProgram = chrono::steady_clock::now();
  // int t; cin >> t;
  // while (t--) 
  {
    solve();
  }
  // auto endProgram = chrono::steady_clock::now();
  // std::chrono::duration<double> diff = endProgram - beginProgram;
  // cout << "\nTime: " <<diff.count()*1000 << " ms\n";
  return 0;
}

Measured memory_bytes: 31616
#include<bits/stdc++.h>
using namespace std;
#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")
#pragma GCC optimize ("-ffloat-store") // to restrict undesirable precision
#pragma GCC optimize ("-fno-defer-pop")// to pop argument of function as soon as it returns
#define all(a) a.begin(),a.end()
#define ll long long int
#define ld long double
ll power(ll a,ll b,ll m){ if(b==0) return 1; if(b==1) return a%m; ll t=power(a,b/2,m)%m; t=(t*t)%m; if(b&1) t=((t%m)*(a%m))%m; return t;}
ll modInverse(ll a, ll m) { return power(a, m-2, m); }
#define ps push_back
#define fs first
#define sc second
#define takeline cin.ignore();
#define iactive cout.flush();
#define N 3000005
#define endl "\n"
#define mod 1000000007
//((1.0l)*BIG MULTIPLY MAGIC?)
// string to integer stoi()
// string to long long stoll()
// string.substr(position,length);
// integer to string to_string();
//-----------------------------------------------
int main(){

	ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
	
	char c;
	cin>>c;
	c++;
	cout<<c;
	
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <string>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <cassert>

using namespace std;
typedef long long LL;
template <typename F, typename S> std::ostream& operator<<(ostream& os, const pair<F,S>& p) {
    os << "(" << p.first << "," << p.second << ")"; return os; }
template <typename T> ostream& operator<<(ostream& os, const vector<T>& v) {
    os << "["; for(const T& a: v){ os << a << ", "; } os << "]"; return os; }
template <typename K, typename V> ostream& operator<<(ostream& os, const map<K,V>& m) {
    os << "{"; for(const auto& p: m){ os << p.first <<":"<< p.second << ", "; } os << "}"; return os; }

struct Node{
    LL cnt;
    LL leaf_cnt;
    LL symbol;
    vector<Node*> children;
    vector<LL> symbol_cnt;
    Node():symbol(0), leaf_cnt(0), cnt(0), children(26, nullptr), symbol_cnt(26){}
};

void addString(Node& node, string& s, LL cur){
    node.cnt++;
    if(cur == s.size()){
        node.leaf_cnt++;
    }else{
        if(node.children[s[cur] - 'a'] == nullptr){
            node.children[s[cur] - 'a'] = new Node();
            node.children[s[cur] - 'a']->symbol = s[cur] - 'a';
        }
        addString(*(node.children[s[cur] - 'a']), s, cur+1);
    }
}

void process(Node& node, LL& ans){
    for(LL i = 0; i < 26; ++i){
        if(node.children[i] != nullptr){
            process(*node.children[i], ans);
        }
    }
    //cerr << "node " << char(node.symbol + 'a') << endl;
    for(LL i = 0; i < 26; ++i){
        if(node.children[i] == nullptr) continue;
        for(LL j = 0; j < 26; ++j){
            node.symbol_cnt[j] += node.children[i]->symbol_cnt[j];
        }
    }
    for(LL i = 0; i < 26; ++i){
        if(node.children[i] == nullptr) continue;
        LL cnt = node.children[i]->leaf_cnt;
        ans += cnt * node.symbol_cnt[i];
        if(cnt > 0){
            ans += cnt * (cnt-1) / 2;
        }
        //cerr << "child " << char('a' + i) << " " << node.symbol_cnt[i] << " " << cnt << endl;
        node.symbol_cnt[i] += cnt;
    }
    node.symbol_cnt[node.symbol] +=  node.cnt - node.leaf_cnt - node.symbol_cnt[node.symbol];
}

int main(){
    LL n;
    cin >> n;
    Node root;
    for(LL i = 0; i < n; ++i){
        string s;
        cin >> s;
        reverse(s.begin(), s.end());
        addString(root, s, 0);
    }
    LL ans = 0;
    process(root, ans);
    cout << ans << endl;
    return 0;
}



Measured memory_bytes: 543248
#include<stdio.h>
#define MAX 10000
#define NIL -1

struct Node{
    int p,l,r;
};
struct Node T[MAX];
int n;

void preParse(int u){
    if(u==NIL) return;
    printf(" %d",u);
    preParse(T[u].l);
    preParse(T[u].r);
}

void inParse(int u){
    if(u==NIL) return;
    inParse(T[u].l);
    printf(" %d",u);
    inParse(T[u].r);
}

void postParse(int u){
    if(u==NIL) return;
    postParse(T[u].l);
    postParse(T[u].r);
    printf(" %d",u);
}

int main(){
    int i,v,l,r,root;

    scanf("%d",&n);

    for(i=0;i<n;i++){
        T[i].p=NIL;
    }

    for(i=0;i<n;i++){
        scanf("%d %d %d",&v,&l,&r);
        T[v].l=l;
        T[v].r=r;
        if(l!=NIL) T[l].p=v;
        if(r!=NIL) T[r].p=v;
    }

    for(i=0;i<n;i++){
        if(T[i].p==NIL) root=i;
    }

    printf("Preorder\n");
    preParse(root);
    printf("\n");

    printf("Inorder\n");
    inParse(root);
    printf("\n");

    printf("Postorder\n");
    postParse(root);
    printf("\n");

    return 0;
}


Measured memory_bytes: 2108
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define fastio ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define gcd(a,b) __gcd((a),(b))
#define lcm(a,b) ((a)*(b))/gcd((a),(b))
const int maxn = 1e9 + 5;
#define INF 100000000000
const int MOD = 1e9+7;
const double PI = 3.14159265358979323846264338;
const int MAXN = 201+5;



int main() {
#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif
	fastio
	ll a,b;
	cin >> a >> b;
	ll suma = gcd(a,b);
	ll ama = a*b;
	cout << ama/suma << endl;
    return 0;
}




Measured memory_bytes: 3616
#include<iostream>
#include<string>
using namespace std;
int main() {
	string a;
	int s = 0;
	while (true) {
		cin >> a;
		if (a == "0")break;
		int len = a.length();
		for (int i = 0; i < len; i++) {
			s += (int)a[i]-(int)'0';
		}
		cout << s << endl;
		s = 0;
	}
	return 0;
}

Measured memory_bytes: 1188
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < n; i++)
#define repp(i, n, m) for (int i = (int)(n); i < (int)(m); i++)
#define rrep(i, n, m) for (int i = n; i >= m; i--)
#define ALL(a) (a).begin(),(a).end()
#define p(a, b) printf(a, b);
#define c(s) cout << (s) << endl;
#define yes cout << "Yes" << endl;
#define no cout << "No" << endl;
#define YES cout << "YES" << endl;
#define NO cout << "NO" << endl;
#define cyn(c) cout << (c ? "Yes" : "No") << endl;
#define cYN(c) cout << (c ? "YES" : "NO") << endl;
#define pyn(c) printf("%s\n", c ? "Yes" : "No");
#define pYN(c) printf("%s\n", c ? "YES" : "NO");
#define INF 1e18
typedef long long LL;
typedef unsigned long long ULL;
typedef pair<LL, LL> P;
template <class T>
bool contain(const std::string &s, const T &v)
{
    return s.find(v) != std::string::npos;
}
ULL mod = 1e9 + 7;

int main() {
    long long A,B,C,K; cin>>A>>B>>C>>K;
    if(K%2==0){
        if((A-B>INF)){
            c("Unfair");
        }else{
            c(A-B);
        }
    }else{
        if((B-A>INF)){
            c("Unfair");
        }else{
            c(B-A);
        }
    }
}

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

typedef long long ll;

string bit(ll x,int n){
	string res="";
	for(int i=0;i<n;i++){
		if(x%2)res="1"+res;
		else res="0"+res;
		x/=2;
	}
	return res;
}

int main(){
	ll n;
	while(cin >> n,n){
		string s; cin >> s;
		reverse(s.begin(),s.end());
		ll a=0,b=0;
		s+="1";
		for(int i=0;i<s.size();i++){
			if(s[i]=='1')a+=(1LL<<i);
		}
		ll now=a;
		while(1){
			// (1LL>>53)以上になるまで足す回数は？
			if(a==0)break;
			ll add=((1LL<<53)-now+a-1)/a;
			add=min(add,n);
			now+=a*add;
			while(now>=(1LL<<53)){
				// 超えた分右シフト
				now>>=1;
				a>>=1;
				b++;
			}
			n-=add;
			if(n==0)break;
		}
		cout << bit(b,12) << bit(now,52) << endl;
	}
}


Measured memory_bytes: 3140
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define REP(i, n) for (int i = 0; i < (n); ++i)
#define SORT(v) sort((v).begin(), (v).end())
#define RSORT(v) sort((v).rbegin(), (v).rend())
const ll MOD = 1000000007;
const ll nmax = 8;
const ll INF = 1e9;
bool graph[nmax][nmax];
vector<vector<ll>> dist = vector<vector<ll>>(nmax, vector<ll>(nmax, INF));
void warshall_floyd(ll n)
{
    for (size_t i = 0; i < n; i++)
    {
        for (size_t j = 0; j < n; j++)
        {
            for (size_t k = 0; k < n; k++)
            {
                dist[j][k] = min(dist[j][k], dist[j][i] + dist[i][k]);
            }
        }
    }
}

class UnionFind
{
public:
    vector<ll> Parent;

    UnionFind(ll N)
    {
        Parent = vector<ll>(N, -1);
    }
    ll find(ll A)
    {
        if (Parent[A] < 0)
            return A;
        return Parent[A] = find(Parent[A]);
    }

    ll size(ll A)
    {
        return -Parent[find(A)];
    }

    bool Union(ll A, ll B)
    {
        A = find(A);
        B = find(B);
        if (A == B)
        {
            return false;
        }
        if (size(A) < size(B))
            swap(A, B);

        Parent[A] += Parent[B];
        Parent[B] = A;

        return true;
    }
};

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

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

ll mulMod(ll a, ll b)
{
    return (((a % MOD) * (b % MOD)) % MOD);
}

ll powMod(ll a, ll p)
{
    if (p == 0)
    {
        return 1;
    }
    else if (p % 2 == 0)
    {
        ll half = powMod(a, p / 2);
        return mulMod(half, half);
    }
    else
    {
        return mulMod(powMod(a, p - 1), a);
    }
}

void solve(long long R, long long G, long long B, long long N)
{
    int ans = 0;
    for (int i = 0; i < 4000; i++)
    {
        for (int j = 0; j < 4000; j++)
        {
            int remain = N - R * i - G * j;
            if(remain >= 0 && remain % B == 0)
            {
                ans++;
            }
        }
    }
    cout << ans << endl;
}

// Generated by 1.1.4 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
int main()
{
    long long R;
    scanf("%lld", &R);
    long long G;
    scanf("%lld", &G);
    long long B;
    scanf("%lld", &B);
    long long N;
    scanf("%lld", &N);
    solve(R, G, B, N);
    return 0;
}


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

const ll 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, mint& a) { return is >> a.x;}
ostream& operator<<(ostream& os, const mint& a) { return os << a.x;}

int main(){
  ll n,k;cin >> n >> k;
  vector<ll> l(k),r(k);
  rep(i,k) cin >> l.at(i) >> r.at(i);
  vector<mint> dp(n+1);
  vector<mint> dpsum(n+1);
  dp.at(1 ) = 1;
  dpsum.at(1) = 1;
  for(ll i=2;i<=n;++i){
    rep(j,k){
      ll li = i - r.at(j);
      ll ri = i - l.at(j);
      if( ri < 0 ) continue;
      li = max(li,1LL);
      dp.at(i) += dpsum.at(ri) - dpsum.at(li-1);
    }
    dpsum.at(i) = dpsum.at(i-1)+dp.at(i);
  }

  cout << dp.at(n) << endl;

  return 0;
}

Measured memory_bytes: 6324
#include <bits/stdc++.h>
using namespace std;
typedef pair<int,int> P;
typedef long long ll;
typedef long double ld;
const int inf=1e9+7;
const ll longinf=1LL<<60;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
#define F first
#define S second
constexpr char ln = '\n';

const int mx=100010;
const ll mod=1e9+7;

int main(){
  int n;
  cin >> n;
  vector<ll> a(n);
  ll odd = 0;
  rep(i,n){
    cin >> a[i];
    odd ^= a[i];
  }
  rep(i,n){
    a[i] &= ~odd;
  }

  vector<ll> base;
  rep(i,n){
    ll tmp = a[i];
    for(auto it:base){
      tmp = min(tmp, (tmp^it));
    }
    if(tmp!=0){ base.emplace_back(tmp); }
  }
  ll even = 0;
  for(auto it:base){
    even = max(even, (even^it));
  }

  ll ans = odd + even*2;
  cout << ans << ln;
  return 0;
}

Measured memory_bytes: 1024
n, m = map(int, input().split())

if n == 1:
  if m == 1:
    print(1)
  else:
    print(m - 2)
elif n == 2:
  print(0)
else:
  if m == 1:
    print(n - 2)
  elif m == 2:
    print(0)
  else:
    print(n * m - (n * 2 + m * 2 - 4))

Measured memory_bytes: 3060
#include <iostream>
#include <sstream>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <algorithm>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cctype>
#include <cmath>
#include <memory.h>
#include <cassert>

using namespace std;


#define all(c) ((c).begin()), ((c).end())
#define debug(c) cerr << "> " << #c << " = " << (c) << endl;
#define iter(c) __typeof((c).begin())
#define present(c, e) ((c).find((e)) != (c).end())
#define cpresent(c, e) (find(all(c), (e)) != (c).end())
#define tr(i, c) for (iter(c) i = (c).begin(); i != (c).end(); i++)
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define REP(i, a, b) for (int i = (int)(a); i <= (int)(b); i++)

#define mp make_pair
#define fst first
#define snd second
#define pb push_back


const double EPS = 1e-10;


typedef long long ll;
typedef vector<int> vi;
typedef pair<int, int> pii;
typedef complex<double> P;


bool check(int a) {
	return !(~a & 0x1c0) || !(~a & 0x38) || !(~a & 0x7) || !(~a & 0x124) || !(~a & 0x92) || !(~a & 0x49) || !(~a & 0x111) || !(~a & 0x54);
}

int main() {
	for (string s; cin >> s; ) {
		int m = 0, b = 0;
		rep(i, 9) {
			if (s[i] == 'o') m |= 1 << (8 - i);
			if (s[i] == 'x') b |= 1 << (8 - i);
		}
		if (check(m)) cout << "o" << endl;
		else if (check(b)) cout << "x" << endl;
		else cout << "d" << endl;
	}
	return 0;
}

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

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

    int x, a;
    cin >> x >> a;

    if(x < a){
        cout << 0 << endl;
    }else{
        cout << 10 << endl;
    }

    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#include <assert.h>
#include <fstream>
#include <iostream>
#include <algorithm>
#include <bitset>
#include <array>
#include <vector>
#include <queue>
#include <set>
#include <cmath> // 変数名にy1が使えなくなるかも…。
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <string>

typedef __int128_t int128_t;
std::istream &operator>>(std::istream& input, int128_t& value) { // int128_tの入力。入力が64bitに収まる前提。
    long long tmp; input >> tmp; value = tmp;
    return input;
}
std::ostream &operator<<(std::ostream& output, const int128_t value) { // int128_tの出力。出力が64bitに収まる前提。
    output << (long long)value;
    return output;
}

const int MAX_N = 100050;
int N, K;
int h[MAX_N];

main(int argc, char **argv) {
    std::cin >> N >> K;

    for (int i = 1; i <= N; i++) {
        std::cin >> h[i];
    }

    std::sort(h + 1, h + 1 + N);

    int ret = h[N] - h[1];
    for (int i = 1; i + K - 1 <= N; i++) {
        ret = std::min(ret, h[i+K-1] - h[i]);
    }

    std::cout << ret << std::endl;
}

Measured memory_bytes: 640
//参考：https://qiita.com/DaikiSuyama/items/9dba963ba74396b9b7fd
//インクルード(アルファベット順)
#include <algorithm>     //sort,二分探索,など
#include <bitset>        //固定長bit集合
#include <cmath>         //pow,logなど
#include <complex>       //複素数
#include <deque>         //両端アクセスのキュー
#include <functional>    //sortのgreater
#include <iomanip>       //setprecision(浮動小数点の出力の誤差)
#include <iostream>      //入出力
#include <iterator>      //集合演算(積集合,和集合,差集合など)
#include <map>           //map(辞書)
#include <numeric>       //iota(整数列の生成),gcdとlcm(c++17)
#include <queue>         //キュー
#include <set>           //集合
#include <stack>         //スタック
#include <string>        //文字列
#include <unordered_map> //イテレータあるけど順序保持しないmap
#include <unordered_set> //イテレータあるけど順序保持しないset
#include <utility>       //pair
#include <vector>        //可変長配列
using namespace std;
typedef long long ll;
//マクロ
//forループ関係
//引数は、(ループ内変数,動く範囲)か(ループ内変数,始めの数,終わりの数)、のどちらか
//Dがついてないものはループ変数は1ずつインクリメントされ、Dがついてるものはループ変数は1ずつデクリメントされる
#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 FOR(i, a, b) for (ll i = a; i <= (ll)(b); i++)
#define FORD(i, a, b) for (ll i = a; i >= (ll)(b); i--)
//xにはvectorなどのコンテナ
#define ALL(x) (x).begin(), (x).end() //sortなどの引数を省略したい
#define SIZE(x) ((ll)(x).size())      //sizeをsize_tからllに直しておく
//定数
#define INF 1000000000000 //10^12:極めて大きい値,∞
#define MOD 1000000007    //10^9+7:合同式の法
#define MAXR 100000       //10^5:配列の最大のrange(素数列挙などで使用)
//略記
#define PB push_back //vectorヘの挿入
#define MP make_pair //pairのコンストラクタ
#define F first      //pairの一つ目の要素
#define S second     //pairの二つ目の要素
signed main()
{
    //入力の高速化用のコード
    ios::sync_with_stdio(false);
    cin.tie(nullptr);

    ll N;
    cin >> N;

    ll s = 0;
    ll n = N;
    REPD(i, 10)
    {
        ll D = pow(10, i);
        ll Q = n / D;
        if (Q > 0)
        {
            n -= D * Q;
            s += Q;
        }
    }

    cout << ((N % s == 0) ? "Yes" : "No") << endl;

    return 0;
}


Measured memory_bytes: 3972
#!/usr/bin/env python3
x,y,a,b,c = map(int,input().split())
p = list(map(int,input().split()))
q = list(map(int,input().split()))
r = list(map(int,input().split()))
p.sort()
q.sort()
z = p[-x:]
z.extend(q[-y:])
z.extend(r)
z.sort()
#print(z)
print(sum(z[-x-y:]))

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

using namespace std;

const int N = 1e5 + 10;

vector <int> A , res;
int n;
int main(){
	scanf("%d",&n);
	A.resize(n + 1);
	for (int i = 1;i <= n;i++){
		scanf("%d",&A[i]);
	}
	
	while ((int)A.size() > 1){
		bool flag = false;
		for (int i = (int)A.size() - 1;i >= 1;i--){
			if (A[i] == i){
				res.push_back(i);
				A.erase(A.begin() + i);
				flag = true;
				break;
			}
		}
		if (!flag) break;
	}
	if ((int)res.size() != n) puts("-1");
	else{
		reverse(res.begin(),res.end());
		for (int i = 0;i < n;i++)printf("%d\n",res[i]);
	}
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
const ll mod = 1000000007;
ll euclid(ll x, ll y){
    ll ma=max(x,y);
    ll mi=min(x,y);
    if(ma%mi==0)return mi;
    else return(mi, ma%mi);
}

int main(){
    ll A,B;
    cin>>A>>B;
    const ll ca=A;
    const ll cb=B;

    set<ll> a,b;
    for(ll i=2;i*i<=ca;i++){
        while(A%i==0){
            a.insert(i);
            A/=i;
        }
    }
    a.insert(A);
    a.insert(1);

    for(ll i=2;i*i<=cb;i++){
        while(B%i==0){
            b.insert(i);
            B/=i;
        }
    }
    b.insert(B);
    b.insert(1);

    ll ans=0;

    for(ll x:a){
        if(b.count(x))ans++;
    }

    cout<<ans<<endl;


}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define INF 1e18
#define int long long
#define Rep(i, a, n) for (int i = (a); i < (n); i++)
#define Repr(i, n, a) for (int i = (n); i >= (a); i--)
#define rep(i, n) Rep(i, 0, n)
#define repr(i, n) Repr(i, n, 0)
#define all(a) a.begin(), a.end()
using namespace std;
typedef pair<int, int> P;
typedef pair<int, P> PP;
const int mod = 1000000007;

int n;
vector<P> a[100010];
int col[100010];
bool vis[100010];

void solve(int pos, int f)
{
    if (vis[pos])
        return;
    vis[pos] = true;
    if (f == 0)
        col[pos] = 0;
    else
        col[pos] = 1;
    rep(i, a[pos].size()) solve(a[pos][i].first, (f + a[pos][i].second) % 2);
    return;
}

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

    cin >> n;
    rep(i, n - 1)
    {
        int x, y, z;
        cin >> x >> y >> z;
        x--, y--;
        a[x].push_back(P{y, z});
        a[y].push_back(P{x, z});
    }
    solve(0, 0);
    rep(i, n) cout << col[i] << endl;
}

Measured memory_bytes: 10240
#include <stdio.h>
int main()
{
  int i,j,n,x,y;
  char c,t;
  int map[30][30];
  int r_x,r_y;
  for(;scanf("%d",&n),n;)
    {
      for(i=0;i<30;i++)
	for(j=0;j<30;j++)
	  map[i][j]=0;
      for(j=n;j--;)
	{
	  scanf("%d%d",&x,&y);
	  map[x][y]=1; 
	}
      scanf("%d",&j);
  	  getchar();
      for(r_y=10,r_x=10;j--;)
	{
	  i=0;
	  c=0;
	  while((t=getchar())!='\n')
	    {
	      if(t>='0' &&t<='9')
		{
		  i=i*10+t-'0';
		}
	      else if(t>'A' && t<'Z')
		{
		  c=t;
		}
	    }
	  for(;i--;)
	    {
	      if(c=='N')
		r_y++;
	      if(c=='E')
		r_x++;
	      if(c=='S')
		r_y--;
	      if(c=='W')
		r_x--;
	      if(map[r_x][r_y]==1)
		{
		  map[r_x][r_y]=0;
		  n--;
		}
	      //printf("now point %d %d jue=%d\n",r_x,r_y,n);
	    }
	}
      if(n==0)
	puts("Yes");
      else
	puts("No");
      
    }
  return 0;
}

Measured memory_bytes: 0
def getN():
    return int(input())
def getNM():
    return map(int, input().split())
def getList():
    return list(map(int, input().split()))
def getArray(intn):
    return [int(input()) for i in range(intn)]
def input():
    return sys.stdin.readline().rstrip()
def rand_N(ran1, ran2):
    return random.randint(ran1, ran2)
def rand_List(ran1, ran2, rantime):
    return [random.randint(ran1, ran2) for i in range(rantime)]
def rand_ints_nodup(ran1, ran2, rantime):
  ns = []
  while len(ns) < rantime:
    n = random.randint(ran1, ran2)
    if not n in ns:
      ns.append(n)
  return sorted(ns)

def rand_query(ran1, ran2, rantime):
  r_query = []
  while len(r_query) < rantime:
    n_q = rand_ints_nodup(ran1, ran2, 2)
    if not n_q in r_query:
      r_query.append(n_q)
  return sorted(r_query)

from collections import defaultdict, deque, Counter
from sys import exit
from decimal import *
import heapq
import math
from fractions import gcd
import random
import string
import copy
from itertools import combinations, permutations, product
from operator import mul
from functools import reduce
from bisect import bisect_left, bisect_right

import sys
sys.setrecursionlimit(1000000000)
mod = 10 ** 9 + 7


#############
# Main Code #
#############

X, Y, A, B, C = getNM()
P = getList()
Q = getList()
R = getList()

P.sort()
Q.sort()

lista = P[-X:] + Q[-Y:] + R
lista.sort()
print(sum(lista[-(X + Y):]))

Measured memory_bytes: 120424
// clang-format off
#include <bits/stdc++.h>
#define int long long
#define main signed main()
#define loop(i, a, n) for (int i = (a); i < (n); i++)
#define rep(i, n) loop(i, 0, n)
#define forever while (true)
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()
#define prec(n) fixed << setprecision(n)
template<typename A> using V = std::vector<A>;
template<typename A> using F = std::function<A>;
template<typename A, typename B> using P = std::pair<A, B>;
using pii = P<int, int>;
using vi = V<int>;
using vd = V<double>;
using vs = V<std::string>;
using vpii = V<pii>;
using vvi = V<vi>;
using vvpii = V<vpii>;
constexpr int INF = sizeof(int) == sizeof(long long) ? 1000000000000000000LL : 1000000000;
constexpr int MOD = 1000000007;
constexpr double PI = acos(-1);
template<typename A, typename B> bool cmin(A &a, const B &b) { return a > b ? (a = b, true) : false; }
template<typename A, typename B> bool cmax(A &a, const B &b) { return a < b ? (a = b, true) : false; }
template<typename T> std::istream &operator>>(std::istream &is, std::vector<T> &v) { for (T &x : v) is >> x; return is; }
using namespace std;
// clang-format on

template<typename InputIterator> constexpr std::string join(InputIterator first, InputIterator last, const std::string &sep) {
  if (first == last) return "";
  std::stringstream ss;
  ss << *(first++);
  for_each(first, last, [&](auto &x) { ss << sep << x; });
  return ss.str();
}

main {
  int n;
  cin >> n;
  vi a(n);
  cin >> a;
  int c = 0;
  rep(i, n) {
    int minj = i;
    loop(j, i, n) if (a[j] < a[minj]) minj = j;
    swap(a[i], a[minj]);
    c += minj != i;
  }
  cout << join(all(a), " ") << endl;
  cout << c << endl;
}

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

using namespace std;

#define EPS 1e-5

struct point{
	double x;
	double y;
};

struct line{
	double a; // 傾き
	double b; // y切片
};

istream& operator >> ( istream& s , point& p );
bool get_line( const point& a , const point& b , line *a_b );
bool get_position( const point& a , const point& b , const point& c );
bool get_cross( const point& a , const point& b , const point& c , const point& d );
bool get_convex( const point& a , const point& b , const point& c , const point& d );
bool get_convex_new( const point& a , const point& b , const point& c , const point& d );

int main(void)
{
	point a, b, c, d;
	char comma;

	while(1)
	{
		cin >> a >> comma >> b >> comma >> c >> comma >> d;
		if( cin.eof() ) break;
		if( get_convex_new( a , b , c , d ) ) cout << "YES" << endl;
		else cout << "NO" << endl;
	}

	return 0;
}

istream& operator >> ( istream& s , point& p )
{
	char c;
	return s >> p.x >> c >> p.y;
}

bool get_line( const point& a , const point& b , line *a_b )
{
	if( fabs(a.x - b.x) < EPS ) return false;
	else{
		a_b->a = (a.y - b.y)/(a.x - b.x);
		a_b->b = a.y - (a.x * a_b->a);
		return true;
	}
}

bool get_position( const point& a , const point& b , const point& c )
{
	// 点a, bを通る直線に対する点cの位置を返す。(右、上：ture)

	line a_b;

	bool result = get_line( a , b , &a_b );
	if( result == false ){
		if( c.x > a.x ) return true;
		else return false;
	}
	else{
		if( c.y > a_b.a * c.x + a_b.b ) return true;
		else return false;
	}
}

bool get_cross( const point& a , const point& b , const point& c , const point& d )
{
	// 点a, cを結ぶ線分と、点b, dを通る直線とが交わればtrueを返す。

	bool result_ac_b = get_position( a , c , b );
	bool result_ac_d = get_position( a , c , d );
	if( result_ac_b == result_ac_d ) return false;
	else return true;
}

bool get_convex( const point& a , const point& b , const point& c , const point& d )
{
	// 点a, b, c, dの順に結んだ時にできる四角形が凸であればtrueを返す。

	bool result_ac_bd = get_cross( a , b , c , d ); // 線分acと直線bdの交差判定
	bool result_bd_ac = get_cross( b , a , d , c ); // 線分bdと直線acの交差判定

	if( result_ac_bd == true && result_bd_ac == true ) return true;
	else return false;
}

bool get_convex_new( const point& a , const point& b , const point& c , const point& d )
{
	bool result_ac_bd;
	bool result_bd_ac;

	if( get_position( a , c , b ) != get_position( a , c , d ) ) result_ac_bd = true;
	else result_ac_bd = false;

	if( get_position( b , d , a ) != get_position( b , d , c ) ) result_bd_ac = true;
	else result_bd_ac = false;

	if( result_ac_bd == true && result_bd_ac == true ) return true;
	else return false;
}

Measured memory_bytes: 1216
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <cmath>
#include <vector>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <queue>
#include <ctime>
#include <cassert>
#include <complex>
#include <string>
#include <cstring>
#include <chrono>
#include <random>
#include <queue>
using namespace std;

#ifdef LOCAL
	#define eprintf(...) fprintf(stderr, __VA_ARGS__)
#else
	#define eprintf(...) 42
#endif

typedef long long ll;
typedef pair<int, int> pii;
#define mp make_pair
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

const int N = 111;
int n;
ll a[N];
ll X;

int main()
{
//	freopen("input.txt", "r", stdin);
//	freopen("output.txt", "w", stdout);

	scanf("%d%lld", &n, &X);
	for (int i = 0; i < n; i++)
		scanf("%lld", &a[i]);
	sort(a, a + n);
	int ans = 0;
	for (int i = 0; i < n; i++) {
		X -= a[i];
		if (X >= 0) ans++;
	}
	if (ans == n && X != 0) ans--;
	printf("%d\n", ans);

	return 0;
}


Measured memory_bytes: 764
// #define DEBUGGING
#include <bits/stdc++.h>
#define endl '\n'
#define ALL(V) (V).begin(), (V).end()
#define ALLR(V) (V).rbegin(), (V).rend()
template <typename T> using V = std::vector<T>;
template <typename T> using VV = V<V<T>>;
using ll = std::int64_t;
using ull = std::uint64_t;
using PLL = std::pair<ll, ll>;
using TLL = std::tuple<ll, ll, ll>;
template <typename T> const T& var_min(const T &t) { return t; }
template <typename T> const T& var_max(const T &t) { return t; }
template <typename T, typename... Tail> const T& var_min(const T &t, const Tail&... tail) { return std::min(t, var_min(tail...)); }
template <typename T, typename... Tail> const T& var_max(const T &t, const Tail&... tail) { return std::max(t, var_max(tail...)); }
template <typename T, typename... Tail> void chmin(T &t, const Tail&... tail) { t = var_min(t, tail...); }
template <typename T, typename... Tail> void chmax(T &t, const Tail&... tail) { t = var_max(t, tail...); }
template <typename T> const T& clamp(const T &t, const T &low, const T &high) { return std::max(low, std::min(high, t)); }
template <typename T> void chclamp(T &t, const T &low, const T &high) { return t = clamp(t, low, high); }
namespace init__ { struct InitIO { InitIO() { std::cin.tie(nullptr); std::ios_base::sync_with_stdio(false); std::cout << std::fixed << std::setprecision(30); } } init_io; }
#define mv_rec make_v(init, tail...)
template <typename T> T make_v(T init) { return init; }
template <typename T, typename... Tail> auto make_v(T init, size_t s, Tail... tail) { return V<decltype(mv_rec)>(s, mv_rec); }
#undef mv_rec
using namespace std;
#ifdef DEBUGGING
#include "../../debug/debug.cpp"
#else
#define DEBUG(...) 0
#define DEBUG_SEPARATOR_LINE 0
#endif

ll L, N;

ll calc(const V<ll> &X) {
    V<ll> lsum(N + 1), rsum(N + 1);
    for(ll i = 0; i < N; i++) lsum[i + 1] = lsum[i] + X[i];
    for(ll i = 0; i < N; i++) rsum[i + 1] = rsum[i] + (L - X[N-1 - i]);

    ll ret = 0;
    for(ll i = 0; i <= N; i++) {
        ll val = (i ? X[i - 1] : 0);
        ll rest = N - i;
        if(rest) val *= 2;
        if(2 <= rest) val += rsum[rest/2] * 2;
        if(rest % 2 == 1) val += (rsum[rest/2 + 1] - rsum[rest/2]);
        if(3 <= rest) val += (lsum[i + (rest-1)/2] - lsum[i]) * 2;
        if(rest && rest % 2 == 0) val += (lsum[rest/2 + i] - lsum[rest/2 + i-1]);
        chmax(ret, val);
    }

    return ret;
}

int main() {
    cin >> L >> N;
    V<ll> X(N);
    for(auto &&ele : X) cin >> ele;

    ll ans = calc(X);
    reverse(ALL(X));
    for(auto &&ele : X) ele = L - ele;
    chmax(ans, calc(X));

    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 4992
def gcd(a,b):
    r=1
    while r!=0:
        r=a%b
        a=b
        b=r
    return a
def lcm(a,b):
    ans = a*b//gcd(a,b)
    return ans
ans=1
n = int(input())
t = [int(input()) for i in range(n)]
t1 = list(set(t))
n1 = len(t1)
for i in range(n1):
    ans = lcm(ans,t1[i])
print(ans)


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


 int main () {
 string S;
 int N,K;
 int count=0;
 int ans=0;

      cin >> N >> K;
      cin >> S;
for(int i = 0;i<N;i++){
if(S[i] == 'A' || S[i] == 'B' || S[i] == 'C')count++;
if(count == K) S[i]= S[i]+char(32);
}
cout << S << endl;

 return 0;
 
 }


Measured memory_bytes: 256
#include <cstdio>
#include <cstdlib>

using namespace std;

int compare(const void *a, const void *b)
{
    return *(int*)b - *(int*)a;
}

int main(void)
{
    int N;
    scanf("%d", &N);
    int a[101];
    for (int i = 0; i < N; i++) {
        scanf("%d", &a[i]);
    }
    qsort(a, N, sizeof(int), compare);
    a[N] = 0;

    int A = 0, B = 0;
    for (int i = 0; i < N; i += 2) {
        A += a[i]; B += a[i + 1];
    }

    printf("%d\n", A - B);
    return 0;
}

Measured memory_bytes: 128
/*ex6_2
series2*/

#include <stdio.h>
#include <string.h>
int main(void){
    //各文字の箱を作って読み取り
    char inputs[102];
    fgets(inputs,102,stdin);//改行コードまでの文字列の入力を代入
    printf("%c",inputs[0]);//最初の文字の出力
    printf("%d",strlen(inputs)-3);//前後及び最後の改行コードをなくしたもの
    printf("%c",inputs[strlen(inputs)-2]);//最後の文字の出力
    printf("\n");
    return 0;
}


Measured memory_bytes: 128
#define  _CRT_SECURE_NO_WARNINGS
#pragma comment (linker, "/STACK:526000000")

#include "bits/stdc++.h"

using namespace std;
typedef string::const_iterator State;
#define eps 1e-11L
#define MAX_MOD 1000000007LL
#define GYAKU 500000004LL

#define MOD 998244353LL
#define seg_size 262144 * 4LL
#define pb push_back
#define mp make_pair
typedef long long ll;
#define REP(a,b) for(long long (a) = 0;(a) < (b);++(a))
#define ALL(x) (x).begin(),(x).end()
void init() {

}
typedef struct V {
	int val;
	int left;
	int right;
}V;

int itr[2] = { 1,1 };
V vertexs[2][2001] = {};
int num(State& now) {
	int ans = 0;
	while (*now >= '0' && *now <= '9') {
		ans *= 10;
		ans += *now - '0';
		now++;
	}
	return ans;
}

int make_tree(State& now,int check) {
	if (*now == ')') {
		return 0;
	}
	assert(*now == '(');
	now++;
	int hoge = itr[check];
	itr[check]++;
	vertexs[check][hoge] = V{ 0,make_tree(now,check),0 };
	now++;
	now++;
	vertexs[check][hoge].val = num(now);
	now++;
	now++;
	vertexs[check][hoge].right = make_tree(now, check);
	now++;
	return hoge;
}

string output(int L, int R) {
	string ans;
	if (vertexs[0][L].left != 0 && vertexs[1][R].left != 0) {
		//goto left
		ans += "(" + output(vertexs[0][L].left, vertexs[1][R].left) + ")";
	}
	else {
		ans += "()";
	}
	ans += "[" + to_string(vertexs[0][L].val + vertexs[1][R].val) + "]";
	if (vertexs[0][L].right != 0 && vertexs[1][R].right != 0) {
		//goto right
		ans += "(" + output(vertexs[0][L].right, vertexs[1][R].right) + ")";
	}
	else {
		ans += "()";
	}
	return ans;
}


void solve() {
	int root[2];
	REP(i, 2) {
		string s;
		cin >> s;
		State start = s.begin();
		root[i] = make_tree(start, i);
	}
	cout << output(root[0], root[1]) << endl;
}

int main() {
	init();
	solve();
}


Measured memory_bytes: 3312
#include <bits/stdc++.h>
using namespace std;
using ll = long long; using pii = pair<int, int>; using vi = vector<int>; using vvi = vector<vi>; using vl = vector<ll>; using vvl = vector<vl>;
#define rep(CNT, GOAL) for (int CNT = 0; CNT < (int)(GOAL); CNT++)
#define rep2(CNT, START, GOAL) for (int CNT = (int)(START); CNT < (int)(GOAL); CNT++)
#define rep3(CNT, START, GOAL) for (int CNT = (int)(START); CNT > (int)(GOAL); CNT--)
#define all(CONT) begin(CONT), end(CONT)
template <typename T> void CERR(const T &ELEM) { cerr << ELEM; }
#define dbl(OBJ) cerr << #OBJ << ": "; CERR(OBJ); cerr << "\n"
template <typename T, typename ...Ts> void CERR(const T &FIRST, const Ts &...REST) { CERR(FIRST); cerr << ", "; CERR(REST...); }
#define dbs(...) cerr << "(" << #__VA_ARGS__ << "): ("; CERR(__VA_ARGS__); cerr << ")\n"
#include <atcoder/all>
using namespace atcoder;

int main() {
	int N, M; cin >> N >> M;
	vl a(N); rep(i, N) cin >> a[i];
	vl b(M); rep(i, M) cin >> b[i];
	vl c = convolution(a, b);
	rep(i, N + M - 1) {
		if (i) cout << " ";
		cout << c[i];
	}
	cout << endl;
}

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

using namespace std;
#define ll long long

#define rep(i, a) for (int i = 0; i < (int) (a); i++)
#define reps(i, a, b) for (int i = (int) (a); i < (int) (b); i++)
#define rrep(i, a) for (int i = (int) a-1; i >= 0; i--)
#define rreps(i, a, b) for (int i = (int) (a)-1; i >= (int) (b); i--)
#define MP(a, b) make_pair((a), (b))
#define PB(a) push_back((a))
#define all(v) (v).begin(), (v).end()
#define PRINT(f) if((f)){cout << (TRUE__) << endl;}else{cout << FALSE__ << endl;}
#define TRUE__ "YES"
#define FALSE__ "NO"
#define PERM(v) next_permutation(all(v))
#define UNIQUE(v) sort(all(v));(v).erase(unique(all(v)), v.end())
#define CIN(type, x) type x;cin >> x

#ifdef LOCAL
#define lcout(a) cout << a;
#define lcoutln(a) cout << a << endl;
#define lcerr(a) cerr << a;
#define lcerrln(a) cerr << a << endl;
#else
#define lcout(a) 
#define lcoutln(a) 
#define lcerr(a) 
#define lcerrln(a) 
#endif

#define MOD 1000000007

signed main()
{
	int A, B;
	cin >> A >> B;
	cout << (A+B) % 24 << endl;
}


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

using ll = long long;
using ull = unsigned long long;
using st = string;
using db = double;
using vll = vector<long long>;
using vvll = vector<vll>;
using vchar = vector<char>;
#define rep(i, m, n) for (int i = (int)(m); i < (int)(n); i++)
#define vrep(vec) for(auto& i : vec)
#define vin(vec) for(auto& i : vec) cin >> i
#define all(v) v.begin(), v.end()
ll mod = 1000000007;

int main(){
  st s;
  cin >> s;
  ll ans = 0;
  rep(i, 0, 3) if(s.at(i) == '1') ans++;
  cout << ans << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int a[200000+5];
int main(){
	int n;
	cin>>n;
	int flag=1;
	for(int i=1;i<=n;i++){
		int t;
		scanf("%d",&t);
		if(t==flag){
			if(a[t]==0){
				a[t]=i;
			}
			flag++;
		}
	}
	if(a[1]==0){
		cout<<"-1"<<endl;
		return 0;
	}
	long long num=0;
	a[0]=0;
	for(int i=1;i<=flag-1;i++){
		num+=(a[i]-a[i-1]-1);
	}
	num+=(n-a[flag-1]);
	printf("%lld\n",num);
	return 0;
}

Measured memory_bytes: 1024
#include<iostream>
#include<bits/stdc++.h>
#include<cctype>
#include<string.h>
#include<vector>
#include<set>
#include<map>
#include <string> 
#define ll long long
#define charToInt(c) (c-'0')
using namespace std;

main(){
string s;
cin>>s;
ll n=s.length();
if(s[0]!=s[1] && s[2]==s[3] && s[4]==s[5])
cout<<"Yes"<<endl;
else
cout<<"No"<<endl;
    
    
}

Measured memory_bytes: 256
#include<algorithm>
#include<algorithm>     //sort,二分探索,など
#include<bitset>        //固定長bit集合
#include<cmath>         //pow,logなど
#include<complex>       //複素数
#include<deque>         //両端アクセスのキュー
#include<functional>    //sortのgreater
#include<iomanip>       //setprecision(浮動小数点の出力の誤差)
#include<iostream>      //入出力
#include<iterator>      //集合演算(積集合,和集合,差集合など)
#include<map>           //map(辞書)
#include<numeric>       //iota(整数列の生成),gcdとlcm(c++17)
#include<queue>         //キュー
#include<set>           //集合
#include<stack>         //スタック
#include<string>        //文字列
#include<unordered_map> //イテレータあるけど順序保持しないmap
#include<unordered_set> //イテレータあるけど順序保持しないset
#include<utility>       //pair
#include<vector>        //可変長配列

using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<string> vs;
typedef vector<bool> vb;
typedef vector<vector<int>> vvi;
typedef vector<vector<ll>> vvll;
typedef vector<vector<string>> vvs;
typedef vector<vector<bool>> vvb;
const ll MOD = 1000000007;
const ll INF = 1000000000000000000;
#define rep(i,n) for(int i=0;i<n;i++)
#define repl(i,s,e) for(int i=s;i<e;i++)
#define reple(i,s,e) for(int i=s;i<=e;i++)
#define revrep(i,n) for(int i=n-1;i>=0;i--)
#define all(x) (x).begin(),(x).end()

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()
{
    ios::sync_with_stdio(false);
    cin.tie(nullptr);

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

    vll h(N);
    rep(i, N) cin >> h[i];

    vll dp(N, INF);
    dp[0] = 0;

    //repl(i, 1, N)
    //{
    //    for (int j = i - 1; j >= max(0, i - K); j--)
    //    {
    //        chmin(dp[i], dp[j] + abs(h[i] - h[j]));
    //    }
    //}

    rep(i, N)
    {
        for (int j = i + 1; j < min(N, i + K + 1); j++)
        {
            chmin(dp[j], dp[i] + abs(h[i] - h[j]));
        }
    }

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

    return 0;
}

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

#define int long long
typedef pair<int,int>pint;
typedef vector<int>vint;
typedef vector<pint>vpint;
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define all(v) (v).begin(),(v).end()
#define rep(i,n) for(int i=0;i<(n);i++)
#define reps(i,f,n) for(int i=(f);i<(n);i++)
#define each(it,v) for(__typeof((v).begin()) it=(v).begin();it!=(v).end();it++)
template<class T,class U>inline void chmin(T &t,U f){if(t>f)t=f;}
template<class T,class U>inline void chmax(T &t,U f){if(t<f)t=f;}

signed main(){
    int p,q;
    while(cin>>p>>q,p||q){
        vector<string>P(p),Q(q);
        rep(i,p)cin>>P[i];
        rep(i,q)cin>>Q[i];

        vector<tuple<int,int,int>>vec;

        for(int R=1;R<=20;R++){
            for(int C=1;C<=20;C++){
                for(int S=1;S<=20;S++){
                    int a=0,b=0,c=0;
                    bool ok=true;
                    rep(i,p){
                        int cnt=0;
                        while(cnt<P[i].size()&&P[i][cnt]=='.')cnt++;
                        if(cnt!=R*a+C*b+S*c){
                            ok=false;
                            break;
                        }

                        rep(j,P[i].size()){
                            if(P[i][j]=='(')a++;
                            if(P[i][j]==')')a--;
                            if(P[i][j]=='{')b++;
                            if(P[i][j]=='}')b--;
                            if(P[i][j]=='[')c++;
                            if(P[i][j]==']')c--;
                        }
                    }

                    if(ok)vec.pb(make_tuple(R,C,S));
                }
            }
        }

      

        int a=0,b=0,c=0;
        rep(i,q){
            set<int>s;
            rep(j,vec.size()){
                int R,C,S;
                tie(R,C,S)=vec[j];
                s.insert(R*a+C*b+S*c);
            }
            if(i)cout<<" ";
            if(s.size()!=1)cout<<-1;
            else cout<<*s.begin();

            rep(j,Q[i].size()){
                if(Q[i][j]=='(')a++;
                if(Q[i][j]==')')a--;
                if(Q[i][j]=='{')b++;
                if(Q[i][j]=='}')b--;
                if(Q[i][j]=='[')c++;
                if(Q[i][j]==']')c--;
            }
        }
        cout<<endl;
    }
    return 0;
}

Measured memory_bytes: 3180
import java.util.ArrayList;
import java.util.Arrays;
import java.util.PriorityQueue;
import java.util.Scanner;

public class Main {
	static Scanner sc = new Scanner(System.in);

	public static void main(String[] args) {
		int N = sc.nextInt();
		int K = sc.nextInt();
		int[] C = new int[N];
		int[] R = new int[N];
		for (int i = 0; i < N; ++i) {
			C[i] = sc.nextInt();
			R[i] = sc.nextInt();
		}
		ArrayList<ArrayList<Integer>> g = new ArrayList<ArrayList<Integer>>(N);
		for (int i = 0; i < N; ++i) {
			g.add(new ArrayList<Integer>());
		}
		for (int i = 0; i < K; ++i) {
			int A = sc.nextInt() - 1;
			int B = sc.nextInt() - 1;
			g.get(A).add(B);
			g.get(B).add(A);
		}
		PriorityQueue<St> q = new PriorityQueue<St>();
		q.add(new St(0, 0));
		int[] min = new int[N];
		int[] used = new int[N];
		Arrays.fill(min, 1 << 30);
		Arrays.fill(used, -1);
		min[0] = 0;
		while (true) {
			St cs = q.poll();
			if (cs.p == N - 1) {
				System.out.println(cs.c);
				break;
			}
			if (cs.c > min[cs.p]) continue;
			ArrayList<Integer> cur = new ArrayList<Integer>();
			cur.add(cs.p);
			int nc = cs.c + C[cs.p];
			for (int i = 0; i < R[cs.p] && !cur.isEmpty(); ++i) {
				ArrayList<Integer> next = new ArrayList<Integer>();
				for (int cp : cur) {
					for (int np : g.get(cp)) {
						if (nc < min[np]) {
							min[np] = nc;
							q.add(new St(np, nc));
						}
						if (used[np] != cs.p) {
							used[np] = cs.p;
							next.add(np);
						}
					}
				}
				cur = next;
			}
		}
	}

	static class St implements Comparable<St> {
		int p, c;

		St(int p, int c) {
			this.p = p;
			this.c = c;
		}

		public int compareTo(St o) {
			return this.c - o.c;
		}
	}

}

Measured memory_bytes: 272752
#include <bits/stdc++.h>
#include <algorithm>
#include <string>
#include <math.h>
#include <cstdlib>
#include <cmath> 
#include <vector> 
#include <queue>
using ll = long long;
using namespace std;
int main() {
    int N;cin>>N;
    int L;cin>>L;
    int ans;
    if(L>0){
        ans=(2*L+N)*(double(N-1)/2);
    }else if(L+N>0){
        ans=(2*L+N-1)*(double(N)/2);
    }else{
        ans=(2*L+N-2)*(double(N-1)/2);
    }
    cout<<ans<<endl;
  return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(){

  int W,H,x,y,r;
  scanf("%d%d%d%d%d",&W,&H,&x,&y,&r);

  if(0<=x-r&&x+r<=W){
    if(0<=y-r&&y+r<=H){
      printf("Yes\n");
    }else{
      printf("No\n");
    }
  }else{
    printf("No\n");
  }
 
  
  return 0;
}

Measured memory_bytes: 1012