akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <set>
#include <queue>
#include <map>

using namespace std;

typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<ld> vld;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

#define INF ((int)1e9)
#define INFLL ((ll)1e18)
#define MOD (1000000007LL)

ll gcd(ll n, ll m)
{
    if (n == 0) return abs(m);
    if (m == 0) return abs(n);
    
    if (n < 0) n = -n;
    if (m < 0) m = -m;
    if (n == m) return n;
    if (n > m) return gcd(m, n%m);
    else return gcd(n, m%n);
}

int main(int argc, const char * argv[]) {
    ios_base::sync_with_stdio(false);
    int N; ll X;
    cin >> N >> X;
    vll x;
    for (int n = 0; n < N; ++n) {
        ll tmp;
        cin >> tmp;
        tmp -= X;
        x.push_back(tmp);
    }
    ll Res = abs(x[0]);
    for (int n = 1; n < N; ++n) {
        Res = gcd(Res, x[n]);
    }
    cout << Res << endl;

    return 0;
}


Measured memory_bytes: 1400
#include <bits/stdc++.h>
using namespace std;
using Int = long long int;
template<typename T> void swap(T *t1, T *t2){ T* tmp=t1; t1=t2; t2=tmp;}
Int tmpi = 0;
double tmpd = 0.0;


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

    char s[10];
    cin >> s;

    Int max = 0;
    Int len = strlen(s);

    Int i = 0;
    Int cnt = 0;
    while(i < len){
        if(s[i]=='A' || s[i]=='T' || s[i]=='C' || s[i]=='G'){
            cnt++;
            max = cnt > max ? cnt : max;
        }else{
            cnt = 0;
        }
        i++;
    }
    cout << max << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using vi=vector<int>;
using vvi=vector<vi>;
using vs=vector<string>;
using msi=map<string,int>;
using mii=map<int,int>;
using pii=pair<int,int>;
using vlai=valarray<int>;
using ll=long long;
#define rep(i,n) for(int i=0;i<n;i++)
#define range(i,s,n) for(int i=s;i<n;i++)
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define fs first
#define sc second
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define INF 1e9
#define EPS 1e-9

string solve(string s){
    int d=0,dep=0;
    string ans=s;
    stack<int> p;
    for(int i=0;i<s.size();i++){
        char c=s[i];
        if(c=='[') p.push(i);
        else if(c==']'){
            int f=p.top(),l; p.pop();
            string inner=s.substr(f+1,i-f-1);
            l=inner.length()+2;
            inner=solve(s.substr(f+1,i-f-1));
            reverse(all(inner));
            auto tmp=s.substr(0,f)+inner+s.substr(i+1);
            s=tmp;
            i-=l-inner.length();
        }
        else if(c=='+') d++,dep++;
        else if(c=='-') d--,dep++;
        else{
            char tt;
            if(c=='?')tt='A';
            else tt=(char)((c-'A'+d+2600)%26+'A');
            auto tmp=s.substr(0,i-dep)+tt+s.substr(i+1);
            i-=dep;
            s=tmp;
            d=dep=0;
        }
    }
    return s;
}

string bur(string s){
    // string ans(100,'Z');
    // if(count(all(s),'?')==0) return solve(s);
    // rep(i,26){
    //     string os=s;
    //     os[s.find('?')]='A'+i;
    //     ans=min(ans,bur(os));
    // }
    return solve(s);
}



int main(){
    string o;
    while(cin>>o,o!="."){
        cout<<bur(o)<<endl;
    }
	return 0;
}



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

int main(){
	
	string s;
	while( cin >> s ){
		int c = 1;
		for( int i = 0 ; i < s.size() ; ){
			if( s[i] == '@' ){
				c = s[i+1] - '0';
				i += 2;
			}else{
				cout << string(c,s[i]);
				c = 1;
				i++;
			}
		}
		cout << endl;
	}
}

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

typedef long long ll;
typedef int64_t i6;

#define rep(i, n) for (ll i = 0; i < n; ++i)
#define rep2(i, n) for (ll i = 1; i <= n; ++i)
#define ALL(v) (v).begin(), (v).end()
#define Sort(x) sort(ALL(x))
#define Sort_rev(x) Sort(x);reverse(ALL(x))

template<typename V,typename T>
T find_num(V v, T num) {
    if ( find(ALL(v), num) == v.end() ) {
        return false;
    } else {
        return true;
    }
}

// π M_PI
// deg = rad*180/M_PI

int main() {
    ll n;
    cin >> n;
    ll ans = 0;
    rep2(i, n) {
        if ( i%3 == 0 || i%5 == 0 ) {
            continue;
        } else {
            ans += i;
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 3592
#include <bits/stdc++.h>
using namespace std;
int main(){
	string s;
	cin >> s;
	if(s.at(2)==s.at(3)&&s.at(4)==s.at(5)){
		cout << "Yes" << endl;
	}
	else{
		cout << "No" << endl;
	}
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
char a;
int FLAG=0,OK=0;
int main()
{
	while(cin>>a)
	{
		if(a=='C')FLAG=1;
		if(a=='F'&&FLAG==1)OK=1;
	}
	if(OK&&FLAG)
	{
		cout<<"Yes";
		return 0;
	}
	cout<<"No";
	return 0;
}

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

int main(void){
    vector<ll> lun[11];
    lun[1] = {1,2,3,4,5,6,7,8,9};
    for(int d = 2; d <= 10; d++){
        for (ll s : lun[d-1]){
            ll r = s%10;
            lun[d].push_back(s*10 + r);
            if (r < 9) lun[d].push_back(s*10 + r+1);
            if (r > 0) lun[d].push_back(s*10 + r-1);
        }
    }
    vector<ll> luns = {0};
    for(int d = 1; d <= 10; d++){
        for (ll s : lun[d]){
            luns.push_back(s);
        }
    }
    sort(all(luns));

    ll k;
    cin >> k;
    cout << luns[k] << endl;
    return 0;
}


Measured memory_bytes: 4084
#include <bits/stdc++.h>
#include<algorithm>
#include<math.h>
#include<string>
#include<iostream>
#include <vector>
#include <cstdlib>
using namespace std;
 
template <class T> using V = vector<T>;

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

const long long INF = 1LL << 60;
 
using ll = long long;
using db = double;
using st = string;
using ch = char;
using bl = bool;
using vll = V<ll>;
using vpll =V<pair<ll,ll>>;
using vst = V<st>;
using vdb = V<db>;
using vch = V<ch>;
using vbl = V<bl>;
 
 
#define FOR(i,a,b) for(ll i=(a);i<(b);i++)
#define rFOR(i,a,b) for(ll i=(a);i>(b);i--)
#define oFOR(i,a,b) for(ll i=(a);i<(b);i+=2)
#define bgn begin()
#define en end()
#define SORT(a) sort((a).bgn,(a).en)
#define REV(a) reverse((a).bgn,(a).en)
#define M(a,b) max(a,b)
#define rM(a,b) min(a,b)
#define fi first
#define se second
#define sz size()
#define gcd(a,b) __gcd(a,b)
#define co(a) cout<<a<<endl;
#define ci(a) cin>>a;
 
 
ll sum(ll n) {
  ll m=0;
  FOR(i,0,20){
    m+=n%10;
    n/=10;
    if(n==0){
      break;
    }
  }
  return m;
}
 
 
ll combi(ll n,ll m) {
  ll ans=1;
  rFOR(i,n,n-m){
    ans*=i;
  }
  FOR(i,1,m+1){
    ans/=i;
  }
  return ans;
}
 
 
ll lcm(ll a,ll b){
  ll n;
  n=a/gcd(a,b)*b;
  return n;
}
 
 
/****************************************\
| Thank you for viewing my code:)        |
| Written by RedSpica a.k.a. RanseMirage |
| Twitter:@asakaakasaka                  | 
\****************************************/
 
 
signed main() {
  ll n;
  ci(n);
  vll A(4);
  FOR(i,0,4){
    A[i]=n%10;
    n/=10;
  }
  FOR(i,0,3){
    if(A[i]==A[i+1]){
      co("Bad")
        break;
    }
    
    if(i==2){
      co("Good")
    }
  }
}


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

namespace MyProgram
{
    public class Program
    {	
        public static void Main(string[] args)
        {
            string s = Console.ReadLine();
            int n = int.Parse(s);
            
            int x = 0;
            
            char[] c = s.ToCharArray();
            for(int i = 0 ; i < c.Length ; i++)
            {
                x += (int)(c[i]-'0');
            }
            if(n%x == 0) Console.WriteLine("Yes");
            else Console.WriteLine("No");
        }
    }
}

Measured memory_bytes: 11092
W,H,N = [int(x) for x in input().split()]
a = [0]
b = [W]
c = [0]
d = [H]
for i in range(N):
    l = [int(x) for x in input().split()]
    if l[2] == 1:
        a.append(l[0])
    elif l[2] == 2:
        b.append(l[0])
    elif l[2] == 3:
        c.append(l[1])
    else:
        d.append(l[1])
aa = max(a)
bb = min(b)
cc = max(c)
dd = min(d)
if aa-bb >= 0 or cc - dd >= 0:
    print(0)
else:
    print((bb-aa)*(dd-cc))

Measured memory_bytes: 38256
#include <stdio.h>
#include <stdlib.h>

#define INIT_CAP 10
#define INF 1000000000

typedef struct {
	int to, w;
} Edge;

typedef struct {
	Edge *elem;
	int cap, size;
} VecEdge;

typedef struct {
	int num, d;
} PNumDis;

VecEdge adj[10000];
PNumDis heap[500000];
int hsize;
int d[10000];

void init(int n) {
	while (n--)
		adj[n] = (VecEdge){malloc(sizeof(Edge) * INIT_CAP), INIT_CAP, 0};
}

inline void add(int from, int to, int w) {
	if (adj[from].size == adj[from].cap) {
		adj[from].cap <<= 1;
		adj[from].elem = realloc(adj[from].elem, sizeof(Edge) * adj[from].cap);
	}
	adj[from].elem[adj[from].size++] = (Edge){to, w};
}

inline void insert(int num, int d) {
	int i;
	for (i = hsize++; i > 0 && d < heap[i - 1 >> 1].d; i = i - 1 >> 1)
		heap[i] = heap[i - 1 >> 1];
	heap[i] = (PNumDis){num, d};
}

inline int calcNextIdx(int i) {
	return i * 2 + 1 + (i * 2 + 2 < hsize && heap[i * 2 + 1].d > heap[i * 2 + 2].d);
}

inline PNumDis delete(void) {
	int i;
	int nextIdx;
	const PNumDis root = heap[0], last = heap[--hsize];

	for (i = 0; i * 2 + 1 < hsize && last.d > heap[nextIdx = calcNextIdx(i)].d; i = nextIdx)
		heap[i] = heap[nextIdx];
	heap[i] = last;

	return root;
}

void dijkstra(int n, int s) {
	int i;

	for (i = 0; i < n; i++)
		d[i] = INF;

	d[s] = 0;
	insert(s, 0);
	while (hsize > 0) {
		const PNumDis fromP = delete();

		if (fromP.d > d[fromP.num])
			continue;

		for (i = 0; i < adj[fromP.num].size; i++) {
			const Edge e = adj[fromP.num].elem[i];
			if (fromP.d + e.w < d[e.to]) {
				d[e.to] = fromP.d + e.w;
				insert(e.to, d[e.to]);
			}
		}
	}
}

int main(void) {
	int i;
	int n;

	scanf("%d", &n);

	init(n);
	for (i = 0; i < n; i++) {
		int u, k;
		scanf("%d %d", &u, &k);
		while (k--) {
			int v, c;
			scanf("%d %d", &v, &c);
			add(u, v, c);
		}
	}

	dijkstra(n, 0);

	for (i = 0; i < n; i++)
		printf("%d %d\n", i, d[i]);

	return 0;
}

Measured memory_bytes: 5688
#include <iostream>
#include <cstdio>
#include <vector>
#include <cstring>
#include <algorithm>
using namespace std;
typedef long long ll;
#define rep(i,n) for(int i=0;i<(n);i++)
const int INF = 1e9;
const int MAX_V = 300;

int X, Y;
struct Flow{
    struct edge{
        int to, cap, rev;
    };
    vector<edge> G[MAX_V];//??£??\?????????
    bool used[MAX_V];

    void add_edge(int from, int to, int cap){
        G[from].push_back((edge){to, cap, (int)G[to].size()});//from -> to
        G[to].push_back((edge){from, 0, (int)G[from].size() - 1});//to -> from
    }

    //?¢???????????????¢???
    int dfs(int v, int t, int f){
        if(v == t) return f;
        used[v] = true;
        for (int i = 0; i < G[v].size(); ++i){
            edge &e = G[v][i];
            if(!used[e.to] && e.cap > 0){
                int d = dfs(e.to, t, min(f, e.cap));
                if(d > 0){
                    e.cap -= d;
                    G[e.to][e.rev].cap += d;
                    return d;
                }
            }
        }
        return 0;
    }
    //s??????t???????????§???
    int max_flow(int s, int t){
        int flow = 0;
        while(1){
            memset(used, 0, sizeof(used));
            int f = dfs(s, t, INF);
            if(f == 0) return flow;
            flow += f;
        }
    }
};

int main(void){
	int e; cin >> X >> Y >> e;
	int s = X + Y;
	int t = X + Y + 1;
	Flow mf;
	//s -> x
	rep(i, X){
		mf.add_edge(s, i, 1);
	}
	// y -> t
	rep(i, Y){
		mf.add_edge(X + i, t, 1);
	}
	// x -> y
	rep(i, e){
		int tx, ty; cin >> tx >> ty;
		mf.add_edge(tx, X + ty, 1);
	}

	printf("%d\n", mf.max_flow(s, t));
}

Measured memory_bytes: 3408
#include <bits/stdc++.h>
#define REP(i,n) for (int i = 0; i < (n); ++i)
template<class T> inline bool chmin(T& a, T b) {if (a > b) {a = b;return true;}return false;}
template<class T> inline bool chmax(T& a, T b) {if (a < b) {a = b;return true;}return false;}
using namespace std;
using ll = long long;
using P = pair<int,int>;
using Pl = pair<long long,long long>;
using veci = vector<int>;
using vecl = vector<long>;
using vecveci = vector<vector<int>>;
using vecvecl = vector<vector<long long>>;
 
vector<pair<long long, long long> > prime_factorize(long long N) {
    vector<pair<long long, long long> > res;
    for (long long a = 2; a * a <= N; ++a) {
        if (N % a != 0) continue;
        long long ex = 0; // 指数
 
        // 割れる限り割り続ける
        while (N % a == 0) {
            ++ex;
            N /= a;
        }
 
        // その結果を push
        res.push_back({a, ex});
    }
 
    // 最後に残った数について
    if (N != 1) res.push_back({N, 1});
    return res;
}

int main() {
    ll N;
    cin >> N;
    vector<Pl> res = prime_factorize(N);
    ll ans = 0;
    for(auto p : res) {
        ll x = p.first;
        ll ex = p.second;
        ll cnt = 1;
        while(1) {
            if(ex >= cnt) {
                ans++;
                ex -= cnt;
                cnt++;
            } else break;
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 3648
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i,n) for(int i=0;i<(int)(n);++i)
#define all(x) (x).begin(),(x).end()
#define pb push_back
#define fi first
#define se second
#define dbg(x) cout<<#x" = "<<((x))<<endl
template<class T,class U> ostream& operator<<(ostream& o, const pair<T,U> &p){o<<"("<<p.fi<<","<<p.se<<")";return o;}
template<class T> ostream& operator<<(ostream& o, const vector<T> &v){o<<"[";for(T t:v){o<<t<<",";}o<<"]";return o;}

template< int mod >
struct ModInt {
  int x;

  ModInt() : x(0) {}
  ModInt(int64_t y) : x(y >= 0 ? y % mod : (mod - (-y) % mod) % mod) {}

  ModInt &operator+=(const ModInt &p) {
    if((x += p.x) >= mod) x -= mod;
    return *this;
  }
  ModInt &operator-=(const ModInt &p) {
    if((x += mod - p.x) >= mod) x -= mod;
    return *this;
  }
  ModInt &operator*=(const ModInt &p) {
    x = (int) (1LL * x * p.x % mod);
    return *this;
  }
  ModInt &operator/=(const ModInt &p) {
    *this *= p.inverse();
    return *this;
  }

  ModInt operator-() const { return ModInt(-x); }
  ModInt operator+(const ModInt &p) const { return ModInt(*this) += p; }
  ModInt operator-(const ModInt &p) const { return ModInt(*this) -= p; }
  ModInt operator*(const ModInt &p) const { return ModInt(*this) *= p; }
  ModInt operator/(const ModInt &p) const { return ModInt(*this) /= p; }
  bool operator==(const ModInt &p) const { return x == p.x; }
  bool operator!=(const ModInt &p) const { return x != p.x; }

  ModInt inverse() const {
    int a = x, b = mod, u = 1, v = 0, t;
    while(b > 0) {
      t = a / b;
      swap(a -= t * b, b);
      swap(u -= t * v, v);
    }
    return ModInt(u);
  }

  ModInt pow(int64_t n) const {
    ModInt ret(1), mul(x);
    while(n > 0) {
      if(n & 1) ret *= mul;
      mul *= mul;
      n >>= 1;
    }
    return ret;
  }

  friend ostream &operator<<(ostream &os, const ModInt &p) {
    return os << p.x;
  }

  friend istream &operator>>(istream &is, ModInt &a) {
    int64_t t;
    is >> t;
    a = ModInt< mod >(t);
    return (is);
  }

  static int get_mod() { return mod; }
};

const int mod = 1e9+7;
using mint = ModInt< mod >;

const int N = 1010;

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

    vector<int> a(k);
    rep(i,k) cin >>a[i];

    vector<vector<mint>> C(N, vector<mint>(N,1));
    for(int i=1; i<N; ++i){
        C[i][0] = C[i][i] = mint(1);
        for(int j=1; j<i; ++j) C[i][j] = C[i-1][j-1]+C[i-1][j];
    }

    vector<mint> dp(n+1);
    dp[0] = 1;
    rep(i,k){
        vector<mint> nx(n+1);
        rep(p,n+1){
            for(int q=p; q<=n; ++q){
                int b = q-p;
                if(a[i] < b) continue;

                nx[q] += dp[p]*C[n-p][b]*C[n-b][a[i]-b];
            }
        }

        swap(dp,nx);
    }
    cout << dp[n] << "\n";
    return 0;
}


Measured memory_bytes: 4224
#include <stdio.h>
#include <math.h>
int main(void){
	int i=0;
	char s[10];
	scanf("%s",s);
	if(s[0]=='R'&&s[1]=='R'&&s[2]=='R'){i=3;}
	else if(s[0]=='R'&&s[1]=='R'){i=2;}
	else if(s[1]=='R'&&s[2]=='R'){i=2;}
	else if(s[0]=='R'){i=1;}
	else if(s[1]=='R'){i=1;}
	else if(s[2]=='R'){i=1;}
	else{i=0;}
	printf("%d",i);
}

Measured memory_bytes: 1736
#include <bits/stdc++.h>
using namespace std;
#define rep(i,a,n) for (int i=a;i<n;i++)
#define per(i,a,n) for (int i=n-1;i>=a;i--)
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define fi first
#define se second
#define SZ(x) ((int)(x).size())
#define fast ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
typedef vector<int> VI;
typedef long long ll;
typedef pair<int,int> PII;
typedef double db;
bool comp(int a,int b){
return a>b;
}
mt19937 mrand(random_device{}());
const ll mod=1000000007;
int rnd(int x) { return mrand() % x;}
ll powmod(ll a,ll b) {ll res=1;a%=mod; assert(b>=0); for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}
ll gcd(ll a,ll b) { return b?gcd(b,a%b):a;}
int main()
{
	fast;
	ll x;
	cin>>x;
	if(x>=30)
	cout<<"Yes";
	else
	cout<<"No";

}



Measured memory_bytes: 3660
#include <bits/stdc++.h>
 using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
 int main(){
 int n;
   cin>>n;
   if(n/100==7||n%10==7||(n/10)%10==7)
     cout<<"Yes"<<endl;
   else
     cout<<"No"<<endl;
}


Measured memory_bytes: 3592
#include <algorithm>
#include <iostream>
#include <string>
#include <vector>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (n); ++i)
int main(void) {
  ll n;
  cin >> n;
  if(!n) {
    cout << 0 << endl;
    return 0;
  }
  string ans = "";
  while(n != 1) {
    if(n < 0 && n % 2) {
      n -= 2;
      n = (-n / 2);
      ans.push_back('1');
    } else if(n % 2) {
      n /= 2;
      n = -n;
      ans.push_back('1');
    } else {
      n /= 2;
      n = -n;
      ans.push_back('0');
    }
  }
  ans.push_back('1');
  reverse(ans.begin(), ans.end());
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
#include<iostream>

using namespace std;

int main(){
    int h, n;
    cin >> h >> n;
    for (int i = 0; i < n; i++)
    {
        int a;
        cin >> a;
        h -= a;
    }
    if (h > 0)
    {
        cout << "No" << endl;
    }
    else
    {
        cout << "Yes" << endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
 
int main(void){
  int n,m,i,sum=0;
  int a[10000];
  int out;
  
  do{
    scanf("%d %d",&n,&m);
  }while(n<1 || n>1000000 || m<1 || m>10000);
  
  for(i=0; i<m; i++){
    do{
      scanf("%d",&a[i]);
    }while(a[i]<1 || a[i]>10000);
    sum += a[i];
  }
  
  out = n-sum;
  
  if(out>=0){
    printf("%d",out);
  }
  else{
    puts("-1");
  }
  
  return 0;
}

Measured memory_bytes: 1664
import sys

stdin = sys.stdin

ns = lambda: stdin.readline().rstrip()
ni = lambda: int(stdin.readline().rstrip())
nm = lambda: map(int, stdin.readline().split())
nl = lambda: list(map(int, stdin.readline().split()))

n,s = nm()
a = nl()
mod = 998244353
ans = 0
dp = [[0]*(s+1) for i in range(n+1)]
dp[0][0] = 1
for i,v in enumerate(a):
    dp[i+1][0] = 1
    for j in range(s+1):
        dp[i+1][j] += dp[i][j]
        if j >= v: dp[i+1][j] += dp[i][j-v]
        dp[i+1][j] %= mod
    ans += dp[i+1][s]
print(ans%mod)


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

using namespace std;

const int N = 200005;

int n, m, k, a, b;
vector<int> V[2][N];
bool vis[2][N];
int comp[2][N];
int cnt;
map<pair<int, int>, int> countComps;

void DFS(int w, int d) {
    vis[d][w] = true;
    comp[d][w] = cnt;
    for (int u : V[d][w]) {
        if (!vis[d][u]) {
            DFS(u, d);
        }
    }
}

int main() {
    
    scanf("%d %d %d", &n, &m, &k);
    
    for (int i = 1; i <= m; i++) {
        scanf("%d %d", &a, &b);
        V[0][a].push_back(b);
        V[0][b].push_back(a);
    }
    
    
    for (int i = 1; i <= k; i++) {
        scanf("%d %d", &a, &b);
        V[1][a].push_back(b);
        V[1][b].push_back(a);
    }
    
    for (int i = 1; i <= n; i++) {
        if (!vis[0][i]) {
            cnt++;
            DFS(i, 0);
        }
    }
    
    for (int i = 1; i <= n; i++) {
        if (!vis[1][i]) {
            cnt++;
            DFS(i, 1);
        }
    }
    
    for (int i = 1; i <= n; i++) {
        countComps[{comp[0][i], comp[1][i]}]++;
    }
    
    for (int i = 1; i <= n; i++) {
        printf("%d ", countComps[{comp[0][i], comp[1][i]}]);
    }
    printf("\n");
    
    return 0;
}

Measured memory_bytes: 28288
#include<bits/stdc++.h>
using namespace std;
#define fast                         ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define int                          long long int
#define double                       long double
#define ff                           first
#define ss                           second
#define pb                           push_back
#define eb                           emplace_back
#define all(x)                       (x).begin(), (x).end()
#define sz(x)                        ((int)(x).size())
#define len(x)                       ((int)(x).length())
#define pii                          pair<int,int>
#define vi                            vector<int>
#define vd                           vector<double>
#define vs                            vector<string>
#define mp                          map<int,int>
#define ms(x,y)                     memset(x,y,sizeof(x))
#define ump                         unordered_map<int,int>

#define lb                            lower_bound
#define ub                            upper_bound
#define nx                            cout<<"\n";
#define inf                           9223372036854775807
#define PI                            3.14159265

const int MOD = 1e9 + 7;

inline int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }
inline int lcm(int a, int b) { return a * b / gcd(a, b); }
inline int add(int a, int b) {    return ((a % MOD) + (b % MOD)) % MOD;}

inline int multi(int a, int b) {   return ((a % MOD) * (b % MOD)) % MOD;}

inline int sub(int a, int b) {       a %= MOD; b %= MOD; a -= b; if (a < 0) a += MOD; return a;}

inline int power(int a, int b) {       a %= MOD; int res = 1; while (b > 0) {if (b & 1) {res = multi(res, a);} a = multi(a, a); b >>= 1;}  return res;}

bool isPrime(int  x) {      if (x <= 4 || x % 2 == 0 || x % 3 == 0) {return x == 2 || x == 3;} for (int i = 5; i * i <= x; i += 6) {if (x % i == 0 || x % (i + 2) == 0) { return 0;}} return 1;}

int32_t main()
{
  fast ;


  int n, k; cin >> n >> k;
  int arr[n];
  for (int i = 0; i < n; i++)cin >> arr[i];

  int dp[k + 1][2];
  ms(dp, 0);

  for (int i = 1; i <= k; i++)
  {
    for (int j = 0; j < n; j++)
    {
      if (arr[j] < i) {
        if (!dp[i - arr[j]][1])dp[i][0] = 1;
        if (!dp[i - arr[j]][0])dp[i][1] = 1;
      }
      else if (arr[j] == i) {
        dp[i][0] = dp[i][1] = 1;
      }
    }
    //cout << i << " " << dp[i][0] << " " << dp[i][1] << endl;
  }
  if (dp[k][0])cout << "First";
  else cout << "Second";


}



Measured memory_bytes: 1792
#include <stdio.h> 

int main(){
	int a;
	int b;
	int c;

	char buf[256];
	fgets(buf,256,stdin);
	sscanf(buf,"%d %d %d" ,&a,&b,&c);

	int pattarn[3];

	pattarn[0] = a+b;
	pattarn[1] = b+c;
	pattarn[2] = a+c;

	if(pattarn[0]<=pattarn[1] && pattarn[0]<=pattarn[2]){
	printf("%d\n",pattarn[0]);
	}else if(pattarn[1]<=pattarn[0] && pattarn[1]<=pattarn[2]){
	printf("%d\n",pattarn[1]);
	}else if(pattarn[2]<=pattarn[0] && pattarn[2]<=pattarn[1]){
	printf("%d\n",pattarn[2]);
	}
	return 0;
}


Measured memory_bytes: 128
#!/usr/bin/env python
import sys
sys.setrecursionlimit(10**9)
from collections import deque
import heapq
from itertools import combinations
import bisect

n,k=map(int,input().split())
a=list(map(int,input().split()))
for i in range(n):
    a[i]-=1
v=[-1]*n
s=0
c=0
while True:
    if v[s]!=-1:
        break
    if c==k:
        print(s+1)
        exit()
    v[s]=c
    c+=1
    s=a[s]
p=c-v[s]
k-=c
k%=p
for i in range(k):
    s=a[s]
print(s+1)


Measured memory_bytes: 103860
# coding: utf-8
# Your code here!

EPS = 0.0000000001

COUNTER_CLOCKWISE = 1
CLOCKWISE = -1
ONLINE_BACK = 2
ONLINE_FRONT = -2
ON_SEGMENT = 0

class Point:
    
    global EPS
    
    def __init__(self, x = 0, y = 0):
        self.x = x
        self.y = y
        
        
    def __add__(a, b):
        s = a.x + b.x
        t = a.y + b.y
        return Point(s, t)
        
    def __sub__(a, b):
        s = a.x - b.x
        t = a.y - b.y
        return Point(s, t)
            
    def __mul__(self, a):
        s = a * self.x
        t = a * self.y
        return Point(s, t)
        
    def __truediv__(self, a):
        s = self.x / a
        t = self.y / a
        return Point(s, t)
            
            
            
            
    def norm(self):
        return self.x * self.x + self.y * self.y
        
    def abs(self):
        return self.norm() ** 0.5
            
    
            
            
    def __eq__(self, other):
        return abs(self.x - other.y) < self.EPS and abs(self.y - other.y) < self.EPS
            
            
            
    def dot(self, b):
        return self.x * b.x + self.y * b.y
        
    def cross(self, b):
        return self.x * b.y - self.y * b.x
    
    
class Segment:
    def __init__(self, p1, p2):
        self.p1 = p1
        self.p2 = p2

def project(s, p):
    base = s.p2 - s.p1
    hypo = p - s.p1
    r = hypo.dot(base) / base.norm()
    return s.p1 + base * r

def reflecton(s, p):
    return p + (project(s,p) - p) * 2


def getDistance(a, b):
    return (a-b).abs()

def getDistanceLP(l, p):
    return abs((l.p2-l.p1).cross(p-l.p1)) / ((l.p2-l.p1).abs())

def getDistanceSP(s, p):
    if (s.p2 - s.p1).dot(p-s.p1) < 0:
        return (p-s.p1).abs()
    elif (s.p1 - s.p2).dot(p-s.p2) < 0:
        return (p-s.p2).abs()
    return getDistanceLP(s,p)


def getDistanceSS(s1, s2):
    if intersectS(s1, s2):
        return 0
    return min(getDistanceSP(s1, s2.p1), getDistanceSP(s1, s2.p2), getDistanceSP(s2, s1.p1), getDistanceSP(s2, s1.p2))



def ccw(p0, p1, p2):
    a = p1-p0
    b = p2-p0
    
    if a.cross(b) > 0:
        return COUNTER_CLOCKWISE
    elif a.cross(b) <0:
        return CLOCKWISE
    elif a.dot(b) < 0:
        return ONLINE_BACK
    elif a.abs() < b.abs():
        return ONLINE_FRONT
    else:
        return ON_SEGMENT

def intersect(p1, p2, p3, p4):
    return ccw(p1, p2, p3) *ccw(p1, p2, p4) <=0 and ccw(p3, p4, p1) * ccw(p3, p4, p2) <= 0

def intersectS(s1, s2):
    return intersect(s1.p1, s1.p2, s2.p1, s2.p2)




n = int(input())
for i in range(n):
    
    nums=list(map(int,input().split()))
    s1 = Segment(Point(nums[0], nums[1]), Point(nums[2], nums[3]))
    s2 = Segment(Point(nums[4], nums[5]), Point(nums[6], nums[7]))
    print(getDistanceSS(s1, s2))







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

int main() {
  long long N;
  cin >> N;
 vector<long long> number(N);
  for(int i = 0; i < N; i++){
    cin >>  number.at(i);
    }
  long long  count = 1;
  long long  ans = 0;
  sort(number.begin(), number.end());
  for(int i = 0; i < N-1; i++){
  if(number.at(i) ==  number.at(i+1) ){
    count++;
    continue;
  }
  else{
    ans += count % 2;
    count = 1;
  }
  }
   ans += count % 2;
 cout << ans << endl;
}


Measured memory_bytes: 1024
using System;
using System.Collections;
using System.Collections.Generic;
using System.Text;
using static MyIO;


public class B
{
	public static void Main()	
	{
		int N = GetInt();
		int M = GetInt();
		int[] a = new int[N];
		int[] b = new int[N];
		for(int i = 0; i < N; i++)
		{
			a[i] = GetInt();
			b[i] = GetInt();
		}
		int[] c = new int[M];
		int[] d = new int[M];
		for(int i = 0; i < M; i++)
		{
			c[i] = GetInt();
			d[i] = GetInt();
		}

		for(int i = 0; i < N; i++)
		{
			int minDist = int.MaxValue;
			int checkPoint = 0;
			for(int j = 0; j < M; j++)
			{
				int dist = Math.Abs(a[i] - c[j]) + Math.Abs(b[i] - d[j]);
				if(dist < minDist)
				{
					minDist = dist;
					checkPoint = j + 1;
				}
			}
			Console.WriteLine(checkPoint);
		}
	}
}


public static class MyIO
{
	private static string[] args = null;
	private static int num = -1;
	private static int used = -1;

	private static string getArg()
	{
		if(used == num)
		{
			args = Console.ReadLine().Split(' ');
			num = args.Length;
			used = 0;
		}
		return args[used++];
	}

	public static int GetInt(){ return int.Parse(getArg()); }
	public static long GetLong(){ return long.Parse(getArg()); }
	public static double GetDouble(){ return double.Parse(getArg()); }
	public static string GetString(){ return getArg(); }
}


Measured memory_bytes: 11092
x ,K, D = map(int, input().split())
if abs(x) >= K * D:
  print(abs(x) - K * D)
else:
  n = abs(x) // D
  x = abs(x) - D * n
  x = x if (K - n) % 2 == 0 else abs(x - D)
  print(x)


Measured memory_bytes: 61608
import java.util.Scanner;
public class Main {
	public static void main(String[] args){
		Scanner as = new Scanner(System.in);
		long n = Long.parseLong(as.next());
		long a = Long.parseLong(as.next());
		long b = Long.parseLong(as.next());
		if(n%(a+b)<=a){
			System.out.println(n/(a+b)*a+n%(a+b));
		}else{
			System.out.println(n/(a+b)*a+a);
		}
	}
}

Measured memory_bytes: 23764
#include <bits/stdc++.h>
#define s second
#define f first
#define pb push_back
#define endl '\n'
using namespace std;


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

const int INF = 0x3f3f3f3f;
const ll LINF = 0x3f3f3f3f3f3f3f3fLL;

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

	ll d,t,s;
	cin >> d >> t >> s;
	
	bool can = (d <= t*s);

	cout << (can ? "Yes" : "No") << endl;

	return 0;
}


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

int main() {
	string S; cin >> S;
	int cnt = 0;

	for (int i = 0; i < S.size(); i++) {
		if (S[i] == 'o') cnt++;
	}

	if (8 - cnt <= 15 - S.size()) {
		cout << "YES" << endl;
	}
	else {
		cout << "NO" << endl;
	}
}

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

using namespace std;

int main() {
    constexpr long MOD = 1e9 + 7;

    auto pow = [&] (long x, long y) {
        long r = 1;
        while(y) {
            if(y&1) r *= x;
            r %= MOD;
            x *= x;
            x %= MOD;
            y >>= 1;
        }
        return r;
    };

    string l;
    cin >> l;

    int s = l.size();
    long o = 0;
    long r = 0;
    for(int i=0; i<s; i++) {
        if(l[i] == '1') {
            r += (pow(2, o) * pow(3, s-i-1)) % MOD;
            r %= MOD;
            o++;
        }
    }
    r += pow(2, o);
    r %= MOD;
    cout << r << endl;

}


Measured memory_bytes: 512
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String S = sc.nextLine();
        String T = sc.nextLine();
        Map<String,String> map = new HashMap<>();
        // アルファベットの対応表をマッピングする
        for(int i = 0;i < T.length();i++){
            char t = T.charAt(i);
            char s = S.charAt(i);
            // 対応表登録済みのアルファベットに異なる文字が対応したらNoで終了
            if(map.containsKey(String.valueOf(s)) && !map.get(String.valueOf(s)).equals(String.valueOf(t))){
                println("No");
                return;
            }
            map.put(String.valueOf(s),String.valueOf(t));
        }
        // 対応表に重複する文字があればNoを出力する
        long count = map.values().stream().distinct().count();
        long count2 = map.values().stream().count();
        println(count != count2 ? "No" : "Yes");
        return;
    }
    static long getLong(String val) {return Long.parseLong(val);}
    static int getInt(String val) {return Integer.parseInt(val);}
    static String[] split(String val) {return val.split(" ");}
    static List<String> toSortedList(String[] s){ return sortList(Arrays.asList(s));}
    static List<String> sortList(List<String> list){
        Collections.sort(list, Comparator.comparingInt(val -> Integer.parseInt(String.valueOf(val))));
        return list;
    }

    static void println(String val){System.out.println(val);}
    static void println(int val){System.out.println(val);}
    static void println(long val){System.out.println(val);}
}

Measured memory_bytes: 47688
line = input().split(' ')
neccessary = int(line[0])
itemA =int(line[1])
numA = 0
if neccessary % itemA == 0:
    numA = neccessary // itemA
else:
    numA = neccessary // itemA + 1
priceA = int(line[2])
itemB =int(line[3])
numB = 0
if neccessary % itemB == 0:
    numB = neccessary // itemB
else:
    numB = neccessary // itemB + 1
priceB = int(line[4])
price1 = priceA * numA
price2 = priceB * numB
print(min(price1,price2))


Measured memory_bytes: 5596
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <map>
#define rep(i,n) for(int i=0;i<n;++i)
#define rep1(i,n) for(int i=1;i<=n;++i)
using namespace std;
template<class T>bool chmax(T &a, const T &b) { if(a < b){ a = b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if(a > b){ a = b; return 1; } return 0; }
typedef long long ll;
int main()
{
  string s;cin >> s;
  int n = s.size();
  vector<vector<ll>> dp(2, vector<ll>(2019,0));
  ll res = 0;
  rep(i,n) {
    int x = s[i] - '0';
    rep(j,2019) {
      dp[1][(j*10+x)%2019] += dp[0][j];
    }
    res += dp[1][0];
    dp[1][x]++;
    dp[0] = dp[1];
    dp[1].assign(2019,0);
  }

  cout << res << "\n";

  return 0;
}


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

int main(){
  string s;
  cin >> s;
  for(int i=0;i<3;i++){
    if(s[i]==s[i+1]){
      cout << "Bad" <<endl;
      break;
    }
    else{
      if(i==2){
        cout << "Good" <<endl;
      }
      continue;
      
    }
  }
}
      

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  double sum;
  int s,a;

  cin >> s;
  sum = 0;

  for (int i = 0; i < s; i++){
    cin >> a;
    sum += (1.0 / a);
  }
  cout << 1.0 / sum << endl;
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <math.h>
#include <algorithm>
#include <functional>

using namespace std;

int main()
{
	long S, W;

	cin >> S >> W;

	if (S <= W)
		cout << "unsafe";
	
	else
		cout << "safe";
	

	return 0;
}

Measured memory_bytes: 3632
N, K = map(int, input().split())
scores = list(map(int, input().split()))
tables = {'s': 0, 'p': 1, 'r': 2}

patterns = input()
answer = 0
losers = [0 for _ in range(N)]
for i in range(N):
  if i - K < 0:
    answer += scores[tables[patterns[i]]]
  else:
    if patterns[i] == patterns[i-K]:
      if losers[i-K] == 0:
        losers[i] = 1
      else:
        answer += scores[tables[patterns[i]]]
    else:
      answer += scores[tables[patterns[i]]]
print(answer)

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

int main(){
  int w, h, x, y, r;
  cin >> w >> h >> x >> y >> r;
  if(w-x<r||h-y<r||x<r||y<r){
    cout << "No" << endl;
  }
  else{
    cout << "Yes" << endl;
  }

  return 0;
}


Measured memory_bytes: 3100
#!usr/bin/env python3
from collections import defaultdict,deque
from heapq import heappush, heappop
import sys
import math
import bisect
import random
def LI(): return [int(x) for x in sys.stdin.readline().split()]
def I(): return int(sys.stdin.readline())
def LS():return [list(x) for x in sys.stdin.readline().split()]
def S():
    res = list(sys.stdin.readline())
    if res[-1] == "\n":
        return res[:-1]
    return res

def IR(n):
    return [I() for i in range(n)]
def LIR(n):
    return [LI() for i in range(n)]
def SR(n):
    return [S() for i in range(n)]
def LSR(n):
    return [LS() for i in range(n)]

sys.setrecursionlimit(1000000)
mod = 1000000007

#A
def A():
    a,b,c = LI()
    c -= a-b
    print(max(0,c))
    return

#B
def B():
    n = I()
    ans = 0
    for i in range(1,n+1):
        s = str(i)
        if len(s)%2:
            ans += 1
    print(ans)
    return

#C
def C():

    return

#D
def D():

    return

#E
def E():

    return

#F
def F():

    return

#Solve
if __name__ == "__main__":
    B()


Measured memory_bytes: 40432
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define inf 1000000000
#define ninf -1000000000
inline long long  MAX2(long long  a, long long int b){return (a)>(b)?(a):(b);}
inline long long  MAX3(long long  a, long long  b,long long  c){return (a)>(b)?((a)>(c)?(a):(c)):((b)>(c)?(b):(c));}
inline long long  MIN2(long long  a, long long  b){return (a)<(b)?(a):(b);}
inline long long  MIN3(long long  a, long long b,long long c){return (a)<(b)?((a)<(c)?(a):(c)):((b)<(c)?(b):(c));}
using namespace std;
typedef pair<int,int> ii;
typedef vector<int> vi;
typedef vector<long long> vll;
typedef vector< pair<int,int> > vii;
typedef long long ll;
 
#define  modu 1000000007


int main() {
    
    {
        int n,a,b,c;
        cin>>a>>b>>c;
        int min1= MIN3(a,b,c);
        int min3=MAX3(a,b,c);
        int min2= a+b+c-min1-min3;
        int ans=(min3-min2)+(min2-min1)/2+((min2-min1)%2)*2;
        cout<<ans;
        
     
    }
    return 0;
}

Measured memory_bytes: 256
N, K = map(int, input().split())

SUNUKE = []
for i in range(0,N):
        SUNUKE.append(0)
for i in range(0,K):
        d = 0
        A = []
        d = int(input())
        A = list(map(int, input().split()))
        for j in range(0,d):
                if SUNUKE[A[j] - 1] == 0:
                        SUNUKE[A[j] - 1] = 1

cnt = 0
for i in SUNUKE:
        if i == 0:
                cnt += 1

print(cnt)

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

int main()
{
  int N;
  cin >> N;
  vector<int long long> a(N);
  for(int i=0;i<N;i++)cin >> a[i];
  sort(a.begin(),a.end());
  for(int i=1;i<=N;i++){
    if(i==N){
      cout << "YES" << endl;
      break;
    }
    else if(a[i-1]==a[i]){
      cout << "NO" << endl;
      break;
    }
  }
}

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

int main() {
    string N;
    cin>>N;
    int dig = 0;
    for(int i=0; i<N.length(); i++) {
        dig += (N[i] - '0');
    }
    if(dig % 9) {
        cout<<"No"<<endl;
    } else {
        cout<<"Yes"<<endl;
    }
    return 0;
}

Measured memory_bytes: 3752
#include <bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );
using namespace std;
using ll = long long;
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;
const ll MOD = 1e9 + 7;


int main(){
    ll n;
    cin >> n;

    ll ans = 0;
    for(ll i=1; i<=n; i++){
        ll x = n/i;
        ans += (x*(x+1)/2) * i;
    }

    cout << ans << endl;
}

Measured memory_bytes: 3672
N,K=map(int,input().split())
h=[int(i) for i in input().split()]
dp=[0]
for i in range(1,N):
    dp.append(1000000000)
for i in range(0,N):
    li=[j+i for j in range(1,K+1)]
    #print(li)
    for j in li:
        if(j<N):
            dp[j]=min(dp[j],dp[i]+abs(h[i]-h[j]))
#print(dp)
print(dp[N-1])

Measured memory_bytes: 56672
def yes_no(flg):
    """
        if True return Yes
        if False return No
    """
    if flg:
        print('Yes')
    else:
        print('No')

n = int(input())
s = input()
flg = False
yes_no(n % 2 == 0 and s[:n//2] == s[n//2:]) 

Measured memory_bytes: 3064
#include <stdio.h>

#define MAX 2000

int solve(int i, int m);
int A[MAX],n;
int main(){
 
  int q,mi[MAX],i,j,res;
 
  scanf("%d",&n);
  for (i = 0; i < n; i++){
    scanf("%d",&A[i]);
  }

  scanf("%d",&q);
  for (i = 0; i < q; i++){
    scanf("%d",&mi[i]);
  }

  for (i = 0; i < q; i++){
    if(solve(0,mi[i])==1){
      printf("yes\n");
    }
    else {
      printf("no\n");
    }
  }
    return 0;
  }

int solve(int i, int m){

    if (m == 0)
      return 1;
    if (i >= n)
      return 0;
    if(solve(i + 1, m) == 1 || solve(i + 1, m - A[i]) == 1)
      return 1;
  }

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

typedef long long int ll;
ll MOD = 1000000007;
ll INFL = 1ll << 60;
ll INF = 1 << 30;

// ===============================================================================

int main() {
  int a, b, c, x, y;
  cin >> a >> b >> c >> x >> y;
  int m = min(x, y);
  ll ans = 0;
  if (a + b > c * 2) {
    ans = c * m * 2;  // ABピザがお安いとき
  } else {
    ans = (a + b) * m;
  }

  x -= m;
  y -= m;

  if (x > 0) {  // Aビザがまだ必要
    if (a > c * 2) {
      ans += c * x * 2;
    } else {
      ans += a * x;
    }
  } else {
    if (b > c * 2) {
      ans += c * y * 2;
    } else {
      ans += b * y;
    }
  }

  cout << ans << endl;
}


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

//////全探索したいときに開けよ////////
vector<vector<int>> fspattern;
vector<int> fspattern_draft;
int fspcnt = 0;

void setfspattern_core(int floor,int number,int degree){
  if(floor==degree){
    fspattern.at(fspcnt) = fspattern_draft;
    fspcnt++;
  }else{
    rep(i,number){
      fspattern_draft.at(floor) = i;
      setfspattern_core(floor+1,number,degree);
    }
  }
}

void setfspattern(int number,int degree){
  int64_t array_num = 1;
  rep(i,degree){
    array_num *= number;
  }
  fspattern = vector<vector<int>>(array_num,vector<int>(degree));
  fspattern_draft = vector<int>(degree);
  setfspattern_core(0,number,degree);
}

//////nCrのmodを求めたいときに開けよ/////////
//int64_t univMod = 1000000007;
//int64_t factnum = 100000
//vector<int64_t> modfact(factnum);
//vector<int64_t> modinvfact(factnum);

/*void setmodfact(){
  for(int i=0;i<factnum;i++){
    if(i == 0){
      modfact.at(i) = 1;
    }else{
      modfact.at(i) = (modfact.at(i-1)*i)%univMod;
    }
  }
}

int64_t calcmodpower(int64_t a,int64_t n){
  int64_t res = 1;
  while(n != 0){
    if(n & 1){
      res = (res * a) % univMod;
    }
    a = (a*a) % univMod;
    n = n >> 1;
  }
  return res;
}

int64_t calcinverse(int64_t n){
	return calcmodpower(n,univMod-2);
}

void setmodinvfact(){
  for(int i=0;i<factnum;i++){
    if(i==0){
      modinvfact.at(i) = 1;
    }else{
      modinvfact.at(i) = calcmodpower(modfact.at(i),univMod-2);
    }
  }
}

int64_t calcmodcomb(int64_t n,int64_t r){
  return (((modfact.at(n)*modinvfact.at(r))%univMod)*modinvfact.at(n-r))%univMod;
}

int64_t calcmodpositive(int64_t n){
  return (n + ((abs(n)+univMod-1)/univMod)*univMod)%univMod;
}
  
    */


/*
int64_t calcGCD(int64_t a,int64_t b){
	int64_t p = a;
	int64_t q = b;
	int64_t c = a%b;
	while(c != 0){
		p = q;
		q = c;
		c = p%q;
	}
	return q;
}
*/

int main(){
  string s,t;
  cin >> s;
  int cur = 0;
  while(cur < s.size()){
    if(s.at(cur) == 'A'){
      t.push_back('x');
      cur += 1;
    }else if(s.at(cur) == 'B' && 
             cur+1 < s.size() && s.at(cur+1) == 'C'){
      t.push_back('o');
      cur += 2;
    }else{
      t.push_back('*');
      cur += 1;
    }
  }
  //cout << t << endl;
  int xcnt = 0;
  int64_t totalcnt = 0;
  rep(i,t.size()){
    if(t.at(i) == 'x'){
      xcnt++;
    }else if(t.at(i) == 'o'){
      totalcnt += xcnt;
    }else{
      xcnt = 0;
    }
  }
  cout << totalcnt << endl;
}
      

    
    
  

Measured memory_bytes: 776
#include <iostream>
#include <vector>

using namespace std;

int main() {
    int n, max = 0, now = 0;
    cin >> n;
    vector<int> pos(n + 2, 0);
    for (int i = 1; i <= n; ++i) {
        int p;
        cin >> p;
        pos.at(p) = i;
    }
    for (int i = 1; i <= n; ++i) {
        if (pos.at(i - 1) > pos.at(i)) {
            if (max < now) max = now;
            now = 0;
        }
        ++now;
    }
    if (max < now) max = now;
    cout << n - max << endl;
    return 0;
}


Measured memory_bytes: 1152
#include<iostream>
#include<stdlib.h>
using namespace std;

int main()
{
    int a, b, x, c, d;
    cin >> x >> a >> b;

    c = abs(x-a);
    d = abs(x-b);
     if (c<d)
         {
            cout <<"A"<<endl;
         }
    else
         cout << "B" <<endl;
    return 0;
}


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


signed main() {
    int N, M;
    cin >> N >> M;

    vector<ll> H(N);
    rep (i, N) cin >> H[i];

    vector<ll> R(N);
    rep (i, M) {
        int a, b;
        cin >> a >> b;
        if (H[a-1] < H[b-1]) {
            R[a-1] = -1;
        } else if (H[a-1] > H[b-1]) {
            R[b-1] = -1;
        } else {
            R[a-1] = -1;
            R[b-1] = -1;
        }
    }

    int ans = 0;
    rep (i, N) {
        if (R[i] != -1) ans++;
    }

    cout << ans << endl;
}

Measured memory_bytes: 4832
# dpテーブル用意: Nの最大値分まで計算できるように確保
dp = [float('INF')] * (100000*2)
dp[0] = 0

N = int(input())

# 配るdp
for i in range(N+1):
    # 1円更新
    dp[i+1] = min(dp[i+1], dp[i]+1)
    
    # 6の累乗群
    for j in range(1, 7):
        dp[i+(6**j)] = min(dp[i+(6**j)], dp[i]+1)
    
    # 9の累乗群
    for k in range(1, 6):
        dp[i+(9**k)] = min(dp[i+(9**k)], dp[i]+1)


print(dp[N])

Measured memory_bytes: 4596
import sys

def I(): return int(sys.stdin.readline())
def MI(): return map(int, sys.stdin.readline().split())
def LI(): return list(map(int, sys.stdin.readline().split()))
def main():
    d, n = MI()
    if n%100 == 0:
        n += 1
    ans = (100**d)*n
    print(ans)

if __name__ == '__main__':
    main()

Measured memory_bytes: 9120
#include <iostream>
#include <iomanip>
#include <random>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <cmath>
#include <numeric>
#include <cstdlib>
#include <cstring>
#include <deque>
#include <sstream>
#include <bitset>
#include <cassert>
#include <fstream>
#include <queue>

#define len(X) ((int)(X).size())

#ifdef __LOCAL
	#define DBG(X) cout << #X << "=" << (X) << '\n';
	#define SAY(X) cout << (X) << '\n';
#else
	#define DBG(X)
	#define SAY(X)
#endif
 
using namespace std;

using ll = long long int;
using ull = unsigned long long int;
using ld  = long double;
using pii = pair<int, int>;
using pll = pair<ll, ll>;

const int INT_INF = (int)(2e9);
const ll  LL_INF  = (ll)(2e18);

const int NIL = -1;
static mt19937 _g(time(nullptr));

inline ll randint(ll a, ll b) { ll w = (_g() << 31LL) ^ _g(); return a + w % (b - a + 1); }
inline void fast_io() { ios_base::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr); };
template<typename T> inline T sign(T x) { return T(x > 0) - T(x < 0); }
template<typename T, typename S> inline ostream& operator<<(ostream& os, const pair<T, S> p) { cout << "[" << p.first << ";" << p.second << "]"; return os; }
template<typename T> inline ostream& operator<<(ostream& os, const vector<T>& v) { for(auto el: v) cout << el << " "; return os; }
template<typename T> inline T fetch() { T ret; cin >> ret; return ret; }
template<typename T> inline vector<T> fetch_vec(int sz) { vector<T> ret(sz); for(auto& elem: ret) cin >> elem; return ret; }

void solve() {
	int n = fetch<int>();

	for(int i = 1; i < 10; ++i) {
		for(int j = 1; j < 10; ++j) {
			if(i * j == n) {
				cout << "Yes\n";
				return;
			}
		}
	}

	cout << "No\n";
}

int main() {
	fast_io();
	solve();

	return 0;
}


Measured memory_bytes: 636
import Control.Arrow
import Control.Monad
import Data.List
import qualified Data.ByteString.Char8 as B
import Text.Printf

main :: IO ()
main = readLine >>= check 

check :: [Int] -> IO ()
check [n, k] 
    | k > an = print (-1)
    | otherwise = print (n - 1 + an - k) >> printBase >> printOthers 
    where
        an = ((n - 2) * (n - 1)) `div` 2

        printBase = mapM_ (pf . (: [1])) [2..n]
        printOthers = mapM_ pf $ take (an - k) [[i, j] | i <- [2..n], j <- [(i + 1)..n]]

pf :: [Int] -> IO ()
pf [u, v] = printf "%d %d\n" u v

readLine :: IO [Int]
readLine = unfoldr (fmap (second (maybe B.empty snd . B.uncons)) . B.readInt) <$> B.getLine

readContents :: Int -> IO [[Int]]
readContents = flip replicateM readLine

Measured memory_bytes: 1020