akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define F first
#define S second
#define R cin>>
#define Z class
#define ll long long
#define ln cout<<'\n'
#define in(a) insert(a)
#define pb(a) push_back(a)
#define pd(a) printf("%.10f\n",a)
#define mem(a) memset(a,0,sizeof(a))
#define all(c) (c).begin(),(c).end()
#define iter(c) __typeof((c).begin())
#define rrep(i,n) for(ll i=(ll)(n)-1;i>=0;i--)
#define REP(i,m,n) for(ll i=(ll)(m);i<(ll)(n);i++)
#define rep(i,n) REP(i,0,n)
#define tr(it,c) for(iter(c) it=(c).begin();it!=(c).end();it++)
template<Z A>void pr(A a){cout<<a;ln;}
template<Z A,Z B>void pr(A a,B b){cout<<a<<' ';pr(b);}
template<Z A,Z B,Z C>void pr(A a,B b,C c){cout<<a<<' ';pr(b,c);}
template<Z A,Z B,Z C,Z D>void pr(A a,B b,C c,D d){cout<<a<<' ';pr(b,c,d);}
template<Z A>void PR(A a,ll n){rep(i,n){if(i)cout<<' ';cout<<a[i];}ln;}
ll check(ll n,ll m,ll x,ll y){return x>=0&&x<n&&y>=0&&y<m;}
const ll MAX=998244353,MAXL=1LL<<61,dx[4]={-1,0,1,0},dy[4]={0,1,0,-1};
typedef pair<int,int> P;

void extended_euclid(ll x,ll y,ll *c,ll *a,ll *b){
  ll a0,a1,a2,b0,b1,b2,r0,r1,r2,q;r0=x;r1=y;a0=1;a1=0;b0=0;b1=1;
  while(r1>0){q=r0/r1;r2=r0%r1;a2=a0-q*a1;b2=b0-q*b1;r0=r1;r1=r2;a0=a1;a1=a2;b0=b1;b1=b2;}
  *c=r0;*a=a0;*b=b0;
}

ll get_inv(ll n, ll p){
  ll a,b,c;
  extended_euclid(n,p,&c,&a,&b);
  if(a<p) a+=p;
  return a%p;
}

ll fact[2000100],fact_inv[2000100];

void init() {
  fact[0]=1;
  REP(i,1,2000100) fact[i]=fact[i-1]*i%MAX;
  fact_inv[2000050]=get_inv(fact[2000050],MAX);
  rrep(i,2000050)fact_inv[i]=fact_inv[i+1]*(i+1)%MAX;
}

ll nCr(int N,int K){
  if(K<0||K>N)return 0;
  return fact[N]*fact_inv[K]%MAX*fact_inv[N-K]%MAX;
}

void Main() {
  init();
  ll n,a,b,m;
  cin >> n >> a >> b >> m;
  ll ans=0;
  rep(x,n+1) {
    ll y=m-x*a;
    if(y%b) continue;
    y/=b;
    if(x>n||y>n) continue;
    ans+=nCr(n,x)*nCr(n,y)%MAX;
    ans%=MAX;
  }
  pr(ans);
}

int main(){ios::sync_with_stdio(0);cin.tie(0);Main();return 0;}  


Measured memory_bytes: 31488
#include <stdio.h>
#include<vector>
#include<deque>

using namespace std;
#define mygc(c) (c)=getchar_unlocked()
#define mypc(c) putchar_unlocked(c)
inline void reader(int& x) { int k, m = 0; x = 0; for (;;) { mygc(k); if (k == '-') { m = 1; break; }if ('0' <= k&&k <= '9') { x = k - '0'; break; } }for (;;) { mygc(k); if (k<'0' || k>'9')break; x = x * 10 + k - '0'; }if (m) x = -x; }
inline void writer(int x, char c) { int s = 0, m = 0; char f[6]; if (x<0)m = 1, x = -x; while (x)f[s++] = x % 10, x /= 10; if (!s)f[s++] = 0; if (m)mypc('-'); while (s--)mypc(f[s] + '0'); mypc(c); }
inline void writerLn(int x) { writer(x, '\n'); }
#define rep(i,n)for(int i=0;i<n;i++)
vector<int>E[100000];
int u[200000], v[200000], r[200000], ans[200000], d[100000], cnt = 1;
char b[200000], ok[100000];
deque<int>que;

void bfs(int u, char t) {
	que.emplace_back(u);
	while (!que.empty()) {
		int p = que.front(); que.pop_front();
		for (int v : E[p]) {
			if (t) {
				if (d[v] > d[p] && !ok[v]) {
					ok[v] = 1; cnt++; que.emplace_back(v);
				}
			}
			else if (!d[v]) {
				d[v] = d[p] + 1; que.emplace_back(v);
			}
		}
	}
}
int main() {
	ok[0] = d[0] = 1;
	int n, m, q; reader(n); reader(m); reader(q);
	rep(i, m) {
		reader(u[i]); reader(v[i]);
		u[i]--; v[i]--;
		E[u[i]].emplace_back(v[i]); E[v[i]].emplace_back(u[i]);
	}
	bfs(0, 0);
	rep(i, m) {
		if (d[u[i]] > d[v[i]])swap(u[i], v[i]);
	}
	rep(i, n)E[i].clear();
	rep(i, q) {
		reader(r[i]); r[i]--;
		b[r[i]] = 1;
	}
	rep(i, m) {
		if (!b[i]) {
			if (d[v[i]] > d[u[i]]) {
				E[u[i]].emplace_back(v[i]);
			}
		}
	}
	bfs(0, 1);
	for (int i = q - 1; i >= 0; i--) {
		ans[i] = n - cnt;
		if (d[v[r[i]]] > d[u[r[i]]] && !ok[v[r[i]]]) {
			E[u[r[i]]].emplace_back(v[r[i]]);
			if (ok[u[r[i]]]) {
				cnt++; ok[v[r[i]]] = 1;
				bfs(v[r[i]], 1);
			}
		}
	}
	rep(i, q)writerLn(ans[i]);
}

Measured memory_bytes: 13128
#include<stdio.h>

static const int MAX = 500;
static const int INFTY = (1<<21);

main(){
  int n, i, j;
  int M[MAX][MAX];
  int  k, c, u, v;
  int minv;
  int d[MAX];
  int vis[MAX];

  scanf("%d", &n);
  for ( i = 0; i< n; i++ ){
    for ( j = 0; j < n; j++ ){
      M[i][j] = INFTY;
    }
  }

  for ( i = 0; i < n; i++ ){
    scanf("%d %d", &u, &k);
    for ( j = 0; j < k; j++ ){
      scanf("%d %d", &v, &c);
      M[u][v] = c;
    }
  }

  for ( i = 0; i < n; i++ ) {
    d[i] = INFTY;
    vis[i] = 0;
  }

  d[0] = 0;

  while(1){
    minv = INFTY;
    u = -1;
    for ( i = 0; i < n; i++ ){
      if ( minv > d[i] && !vis[i] ){
	u = i;
	minv = d[i];
      }
    }
    if ( u == -1 ) break;
    vis[u] = 1;
    for ( v = 0; v < n; v++ ){
      if ( !vis[v] && M[u][v] != INFTY ){
	if ( d[v] > d[u] + M[u][v] ){
	  d[v] = d[u] + M[u][v];
	}
      }
    }
  }

  for ( i = 0; i < n; i++ ){
    printf("%d %d\n", i, (d[i]==INFTY?-1:d[i]));
  }

  return 0;
}



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

int main(){
  int N,A,B,C,D;
  string S;
  cin >> N >> A >> B >> C >> D >> S;
  A--; B--; C--; D--;
  string ans="Yes";
  if(C<D){
    for(int i=A;i<D;i++){
      if(S[i]=='#' && S[i+1]=='#'){ans="No"; break;}
    }
  }
  else{
    for(int i=A;i<C;i++){
      if(S[i]=='#' && S[i+1]=='#'){ans="No"; break;}
    }
    bool q=false;
    for(int i=B-1;i<=D-1;i++){
      if(S.substr(i,3)=="..."){q=true; break;}
    }
    if(!q){ans="No";}
  }
  cout << ans << endl;
}

Measured memory_bytes: 640
#define CAKE 4 // ケーキの値段
#define DONUT 7 // ドーナツの値段

int main(void){
    // n: 入力
    // i: ケーキの個数
    // j: ドーナツの個数
    int n, i, j;
    scanf("%d", &n); // AtCoderはC99でscanf_sは無い

    for(i = n; i >= 0 ; i -= DONUT){
        if ((i % CAKE) == 0) {
            printf("Yes\n");
            return 0;
        }
    }

    printf("No\n");
    return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
#define FOR(i,bg,ed) for(ll i=(bg);i<(ed);i++)
#define REP(i,n) FOR(i,0,n)
#define REP1(i,n) for(ll i=1;i<=(n);i++)
#define MOD 1000000007
#define int long long
#define all(c) (c).begin(), (c).end()
#define uniq(c) c.erase(unique(all(c)), (c).end())
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
const int INF = 1e9;



signed main()
{
    string A;
    cin >> A;

    static int cnt[26];
    REP(i,A.length()) {
        cnt[A[i]-'a']++;
    }

    int ans = 1;
    REP(i,25) {
        for (int j=i+1; j<26; j++) {
            ans += cnt[i] * cnt[j];
        }
    }

    cout << ans << endl;
}


Measured memory_bytes: 640
import java.util.Scanner;

public class Main {
	static Long num;
	static long mod = 1000000007;
	public static void main(String[] args) {

		try (Scanner sc = new Scanner(System.in)) {
			int S = Integer.parseInt(sc.next());
			long[] dp = new long[S+1];
			dp[0]=1;
			
			long x=0;
			for(int i=3;i<=S;i++) {
				x=(x + dp[i-3])%mod;
				dp[i]=x;
			}
			System.out.println(dp[S]);
		}
	}
}

Measured memory_bytes: 35556
#include <iostream>
#include <iomanip>
#include <tuple>
#include <map>
#include <queue>
#include <vector>
#include <algorithm>
#include <cmath>
#include <limits>
using namespace std;
void init();
#ifdef DEBUG_BUILD
#define DBG(expr) cout << #expr << " = " << expr << endl;
#endif
#define ECHO(expr) cout << expr << endl;
#define REP(var, num) for(ll var = 0; var < num; var++)
#define REP_FROM(var, from, num) for(ll var = from; var < num; var++)
#define MAX_OF(type) numeric_limits<type>::max()
#define MIN_OF(type) numeric_limits<type>::min()
#define SORT(vec) sort(vec.begin(), vec.end())
#define REVERSE(vec) reverse(vec.begin(), vec.end())
#define ALL(vec) vec.begin(), vec.end()
typedef signed long long ll;
typedef unsigned long long ull;

void solve() {
    ll n, m, x, y;
    cin >> n >> m >> x >> y;
    ll x_max = MIN_OF(ll);
    REP(i, n) { ll a; cin >> a; x_max = max(x_max, a); }
    ll y_min = MAX_OF(ll);
    REP(i, m) { ll a; cin >> a; y_min = min(y_min, a); }
    if (x < y && x_max < y_min && x_max < y && x < y_min)
        ECHO("No War")
    else
        ECHO("War")
}

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

#ifdef INPUT_FILE
    if (!freopen(INPUT_FILE, "r", stdin)) {
        perror("freopen");
        exit(1);
    }
#endif

    solve();
    return 0;
}

Measured memory_bytes: 256
//==========================Head files==========================
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<vector>
#include<queue>
#include<cmath>
#include<set>
#include<iostream>
#include<map>
#define LL long long
#define db double
#define mp make_pair
#define pr pair<int, int>
#define fir first
#define sec second
#define pb push_back
#define ms(i, j) memset(i, j, sizeof i)
using namespace std;
//==========================Templates==========================
inline int read() {
    int x = 0, f = 1; char c = getchar();
    while(c < '0' || c > '9'){if (c == '-') f = -1; c = getchar();}
    while(c >= '0' && c <= '9'){x = x * 10 + c - '0'; c = getchar();}
    return x * f;
}
inline LL readl() {
    LL x = 0, f = 1; char c = getchar();
    while(c < '0' || c > '9'){if (c == '-') f = -1; c = getchar();}
    while(c >= '0' && c <= '9'){x = x * 10 + c - '0'; c = getchar();}
    return x * f;
}
int power(int a, int b) {
	int ans = 1;
	while (b) {
		if(b & 1) ans = ans * a;
		b >>= 1; a = a * a;
	}
	return ans;
}
int power_mod(int a, int b, int mod) {
	a %= mod;
	int ans = 1;
	while (b) {
		if(b & 1) ans = (ans * a) % mod;
		b >>= 1, a = (a * a) % mod;
	}
	return ans;
}
LL powerl(LL a, LL b) {
	LL ans = 1ll;
	while (b) {
		if(b & 1ll) ans = ans * a;
		b >>= 1ll;a = a * a;
	}
	return ans;
}
LL power_modl(LL a, LL b, LL mod) {
	a %= mod;
	LL ans = 1ll;
	while (b) {
		if(b & 1ll) ans = (ans * a) % mod;
		b >>= 1ll, a = (a * a) % mod;
	}
	return ans;
}
LL gcdl(LL a, LL b) {return b == 0 ? a : gcdl(b, a % b);}
LL abssl(LL a) {return a > 0 ? a : -a;}
int gcd(int a, int b) {return b == 0 ? a : gcd(b, a % b);}
int abss(int a) {return a > 0 ? a : -a;}
//==========================Main body==========================
#define LD "%I64d"
#define D "%d"
#define pt printf
#define sn scanf
#define pty printf("YES\n")
#define ptn printf("NO\n")
//==========================Code here==========================
const int MAXN = 100000 + 5, MO = 1000000007;
vector<int > G[MAXN];
int n, k;
LL ans = 1;
void dfs(int u, int fa, int dep, int hz) {
	ans = 1ll * ans * max(0, k - min(dep, 2) - hz) % MO;
	for (int cnt = 0, i = 0; i < (int)G[u].size(); ++i) {
		int v = G[u][i];
		if (v != fa) {
			dfs(v, u, dep + 1, cnt++);
		}
	}
}
int main() {
	cin >> n >> k;
	for (int x, y, i = 1; i < n; ++i) scanf("%d%d", &x, &y), G[x].push_back(y), G[y].push_back(x);
	dfs(1, 0, 0, 0);
	cout << ans;
	return 0;
}

Measured memory_bytes: 11520
a = map(int, input().split())
input_set = set(a)

group_a = {1, 3, 5, 7, 8, 10, 12}
group_b = {4, 6, 9, 11}
group_c = {2}

list_of_list = [group_a, group_b, group_c]

count_match = 0

for set_i in list_of_list:
    if set_i.issuperset(input_set):
        count_match += 1
        print('Yes')
        break

if not count_match >= 1:
    print('No')

Measured memory_bytes: 9112
n = int(input())
a = list(map(int, input().split(' ')))

def main():
	count = 0
	for i in range(0, n):
		if i == 0:
			continue
		if a[i - 1] == a[i]:
			a[i] = 0
			count += 1
	print(count)

main()


Measured memory_bytes: 2940
#include<algorithm>
#include<iostream>
#include<vector>
using namespace std;
typedef long long lint;
typedef vector<int>vi;
typedef pair<int,int>pii;
typedef pair<lint,int>pli;
#define rep(i,n)for(int i=0;i<(int)(n);++i)
const int N=210000;
int bit[N];
void add(int i,int x){
  while(i<N){
    bit[i]+=x;
    i+=i&-i;
  }
}

int accum(int i){
  int ans=0;
  while(i>0){
    ans+=bit[i];
    i&=i-1;
  }
  return ans;
}

int main(){
  int n;
  lint k;
  cin>>n>>k;
  vector<lint>a(n);
  rep(i,n)cin>>a[i];
  rep(i,n)a[i]-=k;
  vector<lint>c(n+1);
  rep(i,n)c[i+1]=c[i]+a[i];
  vector<pli> p(n+1);
  rep(i,n+1)p[i]=pli(c[i],i+1);
  sort(p.begin(),p.end());
  lint ans=0;
  rep(i,n+1){
    int v=p[i].second;
    ans+=accum(v-1);
    add(v,1);
  }
  cout<<ans<<endl;
}


Measured memory_bytes: 7296
#include <iostream>
#include <cstdio>
#include <string>
#include <cstring>
#include <deque>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <climits>
#include <ctime>
#include <cassert>
#include <numeric>
#include <functional>
#include <bitset>

using namespace std;
using lint = long long int;
long long int INF = 1001001001001001LL;
int inf = 1000000007;
long long int MOD = 1000000007LL;
double PI = 3.1415926535897932;

template<typename T1,typename T2>inline void chmin(T1 &a,const T2 &b){if(a>b) a=b;}
template<typename T1,typename T2>inline void chmax(T1 &a,const T2 &b){if(a<b) a=b;}

#define ALL(a) a.begin(),a.end()
#define RALL(a) a.rbegin(),a.rend()

/* do your best */

int main() {

  string s; cin >> s;
  if (s[s.size() - 1] == 's') s += "es";
  else s += "s";
  cout << s << endl;
  return 0;
}


Measured memory_bytes: 3064
#include <iostream>
#include <algorithm>
#define PI 3.14159265358979
using namespace std;
long double r;
int main() {
	while(cin >> r, r != 0.0L) {
		for(int i = 1; ; i++) {
			long double t = PI * i - (int)(PI * i);
			if(t / i <= r) {
				printf("%d/%d\n", (int)(PI * i), i); break;
			}
			if((1.0L - t) / i <= r) {
				printf("%d/%d\n", (int)(PI * i) + 1, i); break;
			}
		}
	}
}

Measured memory_bytes: 3184
#include <iostream>
#include <string>

using namespace std;

int main() {
	string s;
	cin >> s;
	if (s[2] == s[3] && s[4] == s[5]) {
		cout << "Yes" << '\n';
	}
	else {
		cout << "No" << '\n';
	}
	return 0;
}

Measured memory_bytes: 256
// vim: foldmethod=marker
// templates {{{
#include <bits/stdc++.h>
using namespace std;

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

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

inline int input(){ int i; scanf("%d%*c", &i); return i; }
inline double dinput(){ double d; scanf("%lf%*c", &d); return d; }
inline void output(int i, char c = '\n'){ printf("%d%c", i, c); }
inline void output(ll l, char c = '\n'){ printf("%lld%c", l, c); }

#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define RFOR(i, a, b) for (int i = (b) - 1; i >= (a); i--)
#define REP(i, n) for (int i = 0; i < (n); i++)
#define RREP(i, n) for (int i = (n) - 1; i >= 0; i--)

#define ALL(o) o.begin(), o.end()
//}}}

const int INF = 1000000000;
const int MOD = 1000000000 + 0;
#define EPS (1e-14)

ll comb[4096];

int main()
{
    int n;

    REP(i, 1001){
        REP(j, 1001){
            comb[i + j]++;
        }
    }
    while (~scanf("%d", &n)){
        ll cnt = 0;

        REP(i, n / 2 + 1){
            if (n - i > 2000) continue;
            ll t = comb[i] * comb[n - i];
            if (n % 2 || i != n / 2) t *= 2;
            cnt += t;
        }
        output(cnt);
    }

    return 0;
}

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

// Shortening code
typedef long long ll;
typedef vector<int> vi;
typedef pair<int, int> pi;
typedef tuple<int, int, int> ti;

// Macros
#define F first
#define S second
#define PB push_back
#define MP make_pair
#define MT make_tuple
#define REP(i, a, b) for (int i = a; i < b; i++)
#define RREP(i, a, b) for (int i = a; i >= b; i--)

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    // Your code
    string s;
    cin >> s;
    if(s[1] == 'R'){
        cout << "ABC";
    }
    else 
        cout << "ARC";
    return 0;
}

Measured memory_bytes: 3616
#pragma comment(linker, "/stack:20000000")
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx")

#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> 
  
#define mp make_pair
#define f first
#define s second
#define ll long long
#define pb push_back
#define popb pop_back
#define popf pop_front

using namespace std;

using namespace __gnu_pbds;
template <typename T> using ordered_set = tree<T, null_type, std::less<T>, rb_tree_tag, tree_order_statistics_node_update>;

const int inf = 2e9+7, mod=1e9+7;
const int N = 1e6+321, E=14e5;

ll xx[8]={1, 1, -1, -1, 1, -1, 0, 0};
ll yy[8]={1, -1, 1, -1, 0, 0, 1, -1};

bool a[200];

int main(){
	ios_base::sync_with_stdio(0); cin.tie(0);cout.tie(0);
	int n, x;
	cin >> x >> n;
	for(int i=0; i<n; i++){
		int q;
		cin >> q;
		a[q]=1;
	}
	if(!a[x]){
		cout << x;
		return 0;
	}
	int k=1;
	while(1){
		if(!a[x-k]){
			cout << x-k;
			return 0;
		}
	
		if(!a[x+k]){
			cout << x+k;
			return 0;
		}
		k++;
	}
    return 0;
}

Measured memory_bytes: 3604
/*https://atcoder.jp/contests/dp/tasks/dp_e*/
#include <iostream>
#include <vector>
using namespace std;
int min(int a, int b){
	return a < b ? a : b;
}
int main(){
	int n, W, S = 0;
	cin >> n >> W;
	vector<int>w(n), v(n);
	for (int i = 0; i < n; i++){
		cin >> w[i] >> v[i];
		S += v[i];
	}
	int inf = 1e9 + 7;
	vector<vector<int>>dp(n + 1, vector<int>(S + 1, inf));
	/*dp[i][j]: weight nho nhat voi i phan tu va co gia tri la j*/
	dp[0][0] = 0;
	
	for (int i = 0; i < n; i++){
		for (int j = 0; j <= S; j++){
			dp[i + 1][j] = dp[i][j];
			if (j - v[i] >= 0){
				dp[i + 1][j] = min(dp[i + 1][j], dp[i][j - v[i]] + w[i]);
			}
		}
	}
	for (int i = n ; i > 0; i--){
		for (int j = S; j >= 0; j--){
			if (dp[i][j] <= W){
				cout << j;
				return 0;
			}
		}
	}
	
}

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

string query(int n) {
	cout << n << '\n' << flush;
	string s; cin >> s;
	if (s == "Vacant") exit(0);
	return s;
}

int main() {
	int n; cin >> n;
	int l = 0;
	int r = n - 1;
	string L = query(l);
	string R = query(r);

	while (true) {
		int m = (l + r) / 2;
		R = query(m);
		if (L == R && m % 2 && l % 2) r = m;
		if (L == R && m % 2 && !(l % 2)) r = m;
		if (L == R && !(m % 2) && !(l % 2)) l = m;
		if (L == R && !(m % 2) && l % 2) l = m;
		if (L != R && m % 2) l = m;
		if (L != R && !(m % 2)) r = m;
	}
	return 0;
}

Measured memory_bytes: 3780
#include <bits/stdc++.h>
 
using namespace std;
 
typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;
typedef pair<ll, P> PP;
 
static const double EPS = 1e-8;
static const double PI = 4.0 * atan(1.0);
static const ll INF = 1023456789;
 
#define REP(i,n)	for(int i=0;i<n;++i)
#define REPR(i,n)	for(int i=n-1;i>=0;--i)
#define FOR(i,s,n)	for(int i=s;i<n;++i)
#define FORR(i,s,n)	for(int i=n-1;i>=s;--i)
#define ALL(c)		(c).begin(),(c).end()
#define CLEAR(v)	memset(v,0,sizeof(v))
#define MP(a,b)		make_pair((a),(b))
#define ABS(a)		((a)>0?(a):-(a))
#define F			first
#define S			second

ll n, a[2][100];
 
int main(int argc, char **argv) {
	cin >> n;
	REP(i, 2) REP(j, n) cin >> a[i][j];
	ll res = 0;
	REP(i, n) {
		ll s = 0;
		REP(j, i+1) s += a[0][j];
		FOR(j, i, n) s += a[1][j];
		res = max(res, s);
	}
	cout << res << endl;
	return 0;
}
 

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

vector<vector<int> > g;

int dfs(int v){
    int res = g[v].size();
    vector<int> a;
    for(auto u : g[v]){
        a.push_back(dfs(u));
    }
    sort(a.rbegin(), a.rend());
    for(int i=0;i<int(a.size());i++){
        res = max(res, a[i]+i+1);
    }
    return res;
}

int main(){
    int n;
    cin >> n;
    g.resize(n);
    for(int i=0;i<n-1;i++){
        int p;
        cin >> p;
        p--;
        g[p].push_back(i+1);
    }
    cout << dfs(0) << endl;
    return 0;
}

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

const int maxn = 1e5 + 5;
const int inf = 0x3f3f3f3f;

int n, v[maxn][3], d[maxn][3] = {0};

int main() {
    cin >> n;
    for (int i = 0; i < n; ++i)
        for (int j = 0; j < 3; ++j)
            cin >> v[i][j];
    for (int i = 0; i < 3; ++i) d[0][i] = v[0][i];
    for (int i = 1; i < n; ++i)
        for (int j = 0; j < 3; ++j)
            d[i][j] = max(d[i - 1][(j + 1) % 3], d[i - 1][(j + 2) % 3]) + v[i][j];
    int ans = 0;
    for (int i = 0; i < 3; ++i) ans = max(ans, d[n - 1][i]);
    printf("%d\n", ans);
    return 0;
}


Measured memory_bytes: 2560
#include <bits/stdc++.h>
using namespace std;
 
int main ()
{
  int N;
  cin >> N;
  vector<double> a(N, 0);
  
  for (int i = 0; i < N; i++) {
    cin >> a.at(i);
    a.at(i) = 1 / a.at(i);
  }
  double s = 0;
  for (double x : a) {
    s += x;
  }
  
  cout << 1 / s;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define ff first
#define ss second
#define quick                    \
    ios::sync_with_stdio(false); \
    cin.tie(0);
#define time cerr << (0.1 * clock()) / CLOCKS_PER_SEC << endl;
#define mod 1000000007
typedef long long ll;
typedef pair<ll, ll> pl;
#define forn(n) for (ll i = 0; i < ll(n); i++)

void solve() {
    ll n;
    cin >> n;
    ++n;
    vector<ll> v(n);
    ll sum = 0;
    forn(n) {
        cin >> v[i];
        sum += v[i];
    }
    ll ans = 0, nodes = 1;
    for (int i = 0; i < n; ++i) {
        // cout << i << " " << nodes << " " << sum << '\n';
        if (nodes < v[i]) {
            cout << -1 << endl;
            return;
        }
        nodes -= v[i];
        sum -= v[i];
        ans += v[i];
        ans += nodes;
        nodes *= 2;
        nodes = min(sum, nodes);
    }
    cout << ans << '\n';
}

int main() {
    quick;
    solve();
    // ll t;
    // cin >> t;
    // while (t--) {
    //     solve();
    // }
}

Measured memory_bytes: 3936
#include <stdio.h>
#include <assert.h>
#include <fstream>
#include <iostream>
#include <algorithm>
#include <array>
#include <vector>
#include <queue>
#include <set>
#include <cmath>
#include <iomanip>
//#include <unordered_map>
//#include <unordered_set>
//#include <boost/container/static_vector.hpp>
//#include <boost/unordered_set.hpp>
//#include <boost/unordered_map.hpp>
//#include <unistd.h>

//#include <cv.h>
//#include <highgui.h>
#include <stdlib.h>
#include <string>

std::string A;
long long nums[26];

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

    for (int i = 0; i < A.size(); i++) {
        nums[A[i] - 'a']++;
    }

    long long N = A.size();
    long long ret = N * (N - 1) / 2;

    for (int i = 0; i < 26; i++) {
        ret -= nums[i] * (nums[i] - 1) / 2;
    }

    std::cout << ret + 1 << std::endl;

    

    return 0;
}


Measured memory_bytes: 640
N,M=map(int, input().split())
inseq=list(map(int, input().split()))
unifier=[[int(i) for i in input().split()] for j in range(M)]

class UnionFindTree:
    def __init__(self, n):
        self.nodes = list(range(n+1))

    def find(self, x):
        if self.nodes[x] == x:
            return x
        parent = self.find(self.nodes[x])
        self.nodes[x] = parent
        return parent

    def unite(self, a, b):
        a = self.find(a)
        b = self.find(b)
        if a == b:
            return
        self.nodes[a] = self.nodes[b]

    def is_same(self, a, b):
        # print(self.nodes)
        return self.find(a) == self.find(b)

union = UnionFindTree(N)
for i,j in unifier:
    union.unite(i, j)

res = 0
for i, v in enumerate(inseq, start=1):
    if union.is_same(i, v):
        res += 1

print(res)


Measured memory_bytes: 29004
#include <iostream>
using namespace std;
int main(void)
{
	int x1,x2;
	int y1,y2;
	int x, y;
	cin >> x1 >> y1 >> x2 >> y2;
	x = x2 - x1;
	y = y2 - y1;
	cout << x2-y <<" "<<y2+x<<" "<<x1-y<<" "<<y1+x;
}


Measured memory_bytes: 256
n = int(input())
s = input()

r = s.count('R')
b = s.count('B')
g = s.count('G')

cnt = 0

for i in range(n):
    for j in range(i + 1, n):
        k = j + j - i
        if k >= n:
            break
        if s[i] != s[j] and s[i] != s[k] and s[j] != s[k]:
            cnt += 1

print(r * b * g - cnt)


Measured memory_bytes: 9204
#include <iostream>
#include <vector>
#include <algorithm>
#include <numeric>
#include <cstdint>
#include <map>
#include <unordered_map>
#include <set>
#include <unordered_set>
#include <cmath>
#include <cstdlib>
#include <sstream>
#include <functional>
#include <bitset>
#include <queue>

#include <boost/range/irange.hpp>
using boost::irange;

#include <boost/utility/string_ref.hpp>
using string_view = boost::string_ref;

#include <boost/function_output_iterator.hpp>

using namespace std;

int main()
{
    int H,W,h,w;
    cin >> H >> W >> h >> w;
    
    cout << (H*W - h*W - H*w + h*w) << '\n';

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(void) {
  string str,stra;
  int j=0,max=0;
  cin >> str;
  for(int i=0;i<str.size();i++){
    j=i;
    stra="";
    while(j<str.size()&&(str.at(j)=='A'||str.at(j)=='T'||str.at(j)=='G'||str.at(j)=='C')){
      stra = stra + str.at(j);
      j++;
    }
    if(stra.size()>max)
    max=stra.size();
  }
  cout << max << endl;
}

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

struct Card {
	char suit;
	int  number;
};

void BubbleSort(Card *array, int size);
void SelectionSort(Card *array, int size);
bool isStable(Card *array1, Card *array2, int size);
string JoinWithSpace(Card *array, int size);

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

	Card array_buble[n];
	Card array_selection[n];
	for (int i = 0; i < n; i++) {
		Card card;
		cin >> card.suit >> card.number;

		array_buble[i] = card;
		array_selection[i] = card;
	}


	BubbleSort(array_buble, n);
	SelectionSort(array_selection, n);

	cout << JoinWithSpace(array_buble, n) << endl;
	cout << "Stable" << endl;

	cout << JoinWithSpace(array_selection, n) << endl;
	if (isStable(array_buble, array_selection, n)) {
		cout << "Stable" << endl;
	} else {
		cout << "Not stable" << endl;
	}

	return 0;
}

void BubbleSort(Card *array, int size) {
	bool exist_adjacent = true;
	while (exist_adjacent) {

		exist_adjacent = false;
		for (int i = size - 1; i > 0; i--) {
			if (array[i].number < array[i -1].number) {
				swap(array[i], array[i - 1]);
				exist_adjacent = true;
			}
		}

	}
}

void SelectionSort(Card *array, int size) {
	for (int i = 0; i < size -1; i++) {

		int min = i;
		for (int j = i; j < size; j++) {
			if (array[j].number < array[min].number) {
				min = j;
			}
		}

		if (i != min) {
			swap(array[i], array[min]);
		}
	}
}

bool isStable(Card *array1, Card *array2, int size) {
	for (int i = 0; i < size; i++) {
		if (array1[i].suit != array2[i].suit) {
			return false;
		}
	}
	return true;
}

string JoinWithSpace(Card *array, int size) {
	ostringstream oss;
	for (int i = 0; i < size - 1; i++) {
		oss << array[i].suit << array[i].number << " ";
	}
	oss << array[size - 1].suit << array[size - 1].number;
	return oss.str();
}

Measured memory_bytes: 1232
#include <bits/stdc++.h>
#define print(...) {for(auto x: __VA_ARGS__) cout<<x<<" ";}
#define debug(...) {cout<<#__VA_ARGS__": ";print(__VA_ARGS__);cout<<endl;}

using namespace std;

int n, x;
int dp[100];

int main() {
    cin >> n >> x;
    dp[0] = 0;
    for(int i = 1; i <= n; i++) {
        int l;
        cin >> l;
        dp[i] = dp[i-1] + l;
        if(dp[i] > x) {
            cout << i << endl;
            return 0;
        }
    }
    cout << n+1 << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define FOR(i,a,b) for(ut i=(a);i<(ut)(b);i++)
#define REP(i,b) FOR(i,0,b)
#define ALL(c) c.begin(),c.end()
#define PB push_back
#define cat cout << __LINE__ << endl;
using namespace std;
typedef long long LL;
typedef double ld;
typedef int ut;
typedef complex<int> cli;
typedef vector<ut> VI;
typedef pair<ut,ut> pr;
typedef pair<ut,pr> ppr;
typedef vector<pr> Vpr;
typedef vector<ppr> Vppr;
typedef priority_queue<pr,Vpr> PQ;
const int INF=1<<30;
bool is(LL a, LL b,LL T,LL A){
	a=(a+T-1)/T*T;
	return a/T*A>=b;
}
int main(){
	LL N,a=1,b=1,T,A;
	cin >> N;
		
	REP(i,N){
		cin >> T >> A;	
		if(is(a,b,T,A)){
			a=(a+T-1)/T*T;
			b=a/T*A;
		}
		else{
			b=(b+A-1)/A*A;
			a=b/A*T;		
		}
	}
	cout << a+b << endl;
	return 0;
}

Measured memory_bytes: 384
n,k = map(int,input().split())

#すぬけ君の人数分の要素をもったリストを作成する
#１にするのは、最終的に和をとって人数を算出するため

treat = [1]*n

#すぬけ君の人数分の要素をもったリストを作成する

for i in range(k):
  d = int(input())
  a = list(map(int,input().split()))

#お菓子を持っているすぬけ君をリストtreat上で１から0にする
#リスト番号は「入力-1」となるので、以下のようにする

  for j in a:
    treat[j-1] = 0

#リスト上で１になっているモノの和が、いたずらされる人数

print(sum(treat))

Measured memory_bytes: 9104
class Dice:
    
    def __init__(self, U, S, E, W, N, D):
        self.u, self.d = U, D
        self.e, self.w = E, W
        self.s, self.n = S, N       
    
    def roll(self, command):
        if command == 'E':
            self.e, self.u, self.w, self.d = self.u, self.w, self.d, self.e
        elif command == 'W':
            self.e, self.u, self.w, self.d = self.d, self.e, self.u, self.w
        elif command == 'S':
            self.s, self.u, self.n, self.d = self.u, self.n, self.d, self.s
        else:
            self.s, self.u, self.n, self.d = self.d, self.s, self.u, self.n


    def __eq__(self, other):

        other_hex = [other.u, other.s, other.e, other.w, other.n, other.d]
        self_hex = [self.u, self.s, self.e, self.w, self.n, self.d]
        if sorted(other_hex) != sorted(self_hex):
            print('No')
            return
        for i in 'NNNNENNNENNNWNNNWNNNENNN':
            self.roll(i)
            if other.u == self.u and other.s == self.s and other.e == self.e \
            and other.w == self.w and other.n == self.n and other.d == self.d:
                   print('Yes')
                   break
        else:
            print('No')

                


U, S, E, W, N, D = [int(i) for i in input().split()]
dice1 = Dice(U, S, E, W, N, D)
U, S, E, W, N, D = [int(i) for i in input().split()]
dice2 = Dice(U, S, E, W, N, D)
dice1 == dice2


Measured memory_bytes: 5612
a,b=map(int,input().split())
#n=int(input())
#s=input()
if a==b:
  print("Draw")
elif a>b and b!=1:
  print("Alice")
elif a>b:
  print("Bob")
elif a<b and a!=1:
  print("Bob")
else:
  print("Alice")

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

#define N 50
int n, a[N];

int main() {
	while (scanf("%d", &n) != EOF) {
		for (int i = 1; i <= n; ++i) {
			scanf("%d", a + i);
		}
		int res = 0;
		for (int i = 2; i < n; ++i) {
			int f = a[i] < a[i - 1];
			int g = a[i] < a[i + 1];
			if (f ^ g) {
				++res;
			}
		}
		printf("%d\n", res);
	}
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <map>
typedef long long ll;
using namespace std;
int main(void){
    int n;
    cin>>n;
    ll num[5]={0};
    for(int i=0;i<n;i++){
        string s;
        cin>>s;
        if(s[0]=='M'){
            num[0]++;
        }else if(s[0]=='A'){
            num[1]++;
        }else if(s[0]=='R'){
            num[2]++;
        }else if(s[0]=='C'){
            num[3]++;
        }else if(s[0]=='H'){
            num[4]++;
        }
    }
    ll ans=0;
    for(int i=0;i<3;i++){
        for(int j=i+1;j<4;j++){
            for(int k=j+1;k<5;k++){
                ans+=num[i]*num[j]*num[k];
            }
        }
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 256
import sys
MOD = 10**9+7

def cmb(n, r):
    if n - r < r: r = n - r
    if r == 0: return 1
    if r == 1: return n

    numerator = [n - r + k + 1 for k in range(r)]
    denominator = [k + 1 for k in range(r)]

    for p in range(2,r+1):
        pivot = denominator[p - 1]
        if pivot > 1:
            offset = (n - r) % p
            for k in range(p-1,r,p):
                numerator[k - offset] /= pivot
                denominator[k] /= pivot

    result = 1
    for k in range(r):
        if numerator[k] > 1:
            result *= int(numerator[k])
            result %= MOD
    return result % MOD

X,Y = map(int,input().split())
if (2*X-Y) % 3 != 0 or (2*Y-X) % 3 != 0:
    print(0)
    sys.exit()
n = (2*X-Y)//3
m = (2*Y-X)//3
k = n + m
if n < 0 or m < 0:
    print(0)
    sys.exit()
if n == 0 and m == 0:
    print(0)
    sys.exit()

print(cmb(k,n) % MOD)


Measured memory_bytes: 44084
n=int(input())
l=[]
if n==1:
    print(1)
    exit()
else:
    for i in range(n):
        x,y=map(int,input().split())
        l.append((x,y))
    x={}
    for i in l:
        for j in l:
            if i!=j:
                t=(i[0]-j[0],i[1]-j[1])
                if t in x:
                    x[t]+=1
                else:
                    x[t]=1
    print(n-max(x.values()))

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

int main()
{
    int a, b, c, d ;
    cin >> a >> b >> c >> d ;
    if(abs(a - b) <= d && abs(b - c) <= d || abs(a - c) <= d)
        cout << "Yes" << endl ;
        else
            cout << "No" << endl ;
}

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

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	Int w, h; cin >> w >> h;
	using P = pair<Int, bool>;
	vector<P> v;
	for(Int i=0; i<w; ++i){
		Int p; cin >> p;
		v.push_back(P(p, 0));
	}
	for(Int i=0; i<h; ++i){
		Int q; cin >> q;
		v.push_back(P(q, 1));
	}
	sort(v.begin(), v.end());
	Int a = h+1, b = w+1, c = 0, ans = 0, e = w*h+w+h;
	for(size_t i=0; i<v.size() && c < e; ++i){
		P p = v[i];
		if(!p.second){
			Int t = min(a, e-c);
			ans += p.first * t;
			c += t;
			--b;
		}else{
			Int t = min(b, e-c);
			ans += p.first * t;
			c += t;
			--a;
		}
	}
	cout << ans << "\n";
}

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

int main() {
	int n;
	cin >> n;
	int ans = n*2;
	if (n%2 == 0) ans /= 2;
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 3620
#include <iostream>
using namespace std;
int deck[201],temp[201],n;

void refull() {
  for(int i=0;i<201;i++) {
    temp[i] = deck[i];
  }
  for(int i=1;i<n+1;i++) {
    deck[2 * i - 1] = temp[i];
    deck[2 * i] = temp[n+i];
  }
}

void cut(int k) {
  for(int i=0;i<201;i++) {
    temp[i] = deck[i];
  }
  for(int i=1;i<2*n-k+1;i++) {
    deck[i] = temp[k+i];
  }
  for(int i=1;i<k+1;i++) {
    deck[i+2*n-k] = temp[i];
  }
}

int main() {
  int m,k;
  cin >> n;
  for(int i=1;i<=n;i++) {
    deck[i] = i;
    deck[n+i] = i+n;
  }
  cin >> m;
  for(int i=0;i<m;i++) {
    cin >> k;
    if(k == 0) refull();
    else cut(k);
  }

  for(int i=1;i<2*n+1;i++) {
    cout << deck[i] << endl;
  }
}

Measured memory_bytes: 0
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>

/*ソートの時に使う
int sort(const void *a, const void *b){
    return *(int*)a-*(int*)b ;
}
    qsort (data,sizeof(data),sizeof(int),sort); 
*/

int main(void){
    int n,y;
    scanf("%d%d",&n,&y);
    for (int i=0; i<=n; i++){
        int y1;
        y1=y-10000*i;
        for (int j=0; j<=n-i; j++){
            int y2;
            y2=y1-5000*j ;
            if (y2==1000*(n-i-j)){
                printf ("%d %d %d\n",i,j,n-i-j);
                exit(0);
            }
        }
    }
    printf ("-1 -1 -1\n");
	return 0 ;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>

using namespace std;
using namespace __gnu_pbds;
 
typedef long long ll;
typedef long double ld;
typedef complex<ld> cd;

typedef pair<int, int> pi;
typedef pair<ll,ll> pl;
typedef pair<ld,ld> pd;

typedef vector<int> vi;
typedef vector<ld> vd;
typedef vector<ll> vl;
typedef vector<pi> vpi;
typedef vector<pl> vpl;
typedef vector<cd> vcd;

template <class T> using Tree = tree<T, null_type, less<T>, rb_tree_tag,tree_order_statistics_node_update>;

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

#define sz(x) (int)(x).size()
#define mp make_pair
#define pb push_back
#define f first
#define s second
#define lb lower_bound
#define ub upper_bound
#define all(x) x.begin(), x.end()

const int MOD = 1000000007;
const ll INF = 1e18;
const int MX = 100001;

int n;
vi adj[MX], ADJ[MX], res;

int co(int x) {
    int leaf = 0;
    for (int i: adj[x]) if (sz(adj[i]) == 1) leaf ++;
    return leaf;
}

void dfs(int x, int y) {
    res.pb(co(x));
    vi v;
    for (int i: ADJ[x]) if (i != y) v.pb(i);
    if (sz(v) > 1) {
        cout << -1;
        exit(0);
    }
    if (sz(v)) dfs(v[0],x);
}

vi gen(vi res) {
    if (res[0]) {
        res[0] --;
        res.insert(res.begin(),0);
    }
    if (res.back()) {
        res.back() --;
        res.insert(res.end(),0);
    }
    vi ans;
    int lst = 0;
    for (int i: res) {
        F0R(j,i) ans.pb(lst+2+j);
        ans.pb(lst+1);
        lst += i+1;
    }
    return ans;
}

int main() {
    ios_base::sync_with_stdio(0); cin.tie(0);
    cin >> n;
    if (n == 2) {
        cout << "1 2";
        exit(0);
    }
    F0R(i,n-1) {
        int a,b; cin >> a >> b;
        adj[a].pb(b), adj[b].pb(a);
    }
    int tot = 0;
    FOR(i,1,n+1) if (sz(adj[i]) > 1) {
        tot ++;
        for (int j: adj[i]) if (sz(adj[j]) > 1)
            ADJ[i].pb(j);
    }
    
    FOR(i,1,n+1) if (sz(adj[i]) > 1 && sz(ADJ[i]) <= 1) {
        dfs(i,0);
        break;
    }
    
    if (sz(res) != tot) {
        cout << -1;
        exit(0);
    }
    
    vi a = gen(res);
    reverse(all(res));
    a = min(a,gen(res));
    for (int i: a) cout << i << " ";
}

// read the question correctly (is y a vowel? what are the exact constraints?)
// look out for SPECIAL CASES (n=1?) and overflow (ll vs int?) ARRAY OUT OF BOUNDSS

Measured memory_bytes: 24056
#include <iostream>
#include <algorithm>
#include <queue>
#include <vector>
#include <map>
#include <string>

using namespace std;

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

    int count = 0;
    while(1) {
        bool ok = true;
        for(int i = 0; i < n; i++) {
            if(a[i] % 2 != 0) ok = false; 
        }
        if(!ok) break;
        count++;
        for(int i = 0; i < n; i++) {
            a[i] /= 2;
        }
    }
    cout << count << endl;


}

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

const ll mod=1000000007;

int main() {
 int a,b,c,d,e;
  cin >> a >> b >> c >> d >> e;
  cout<<60*(c-a)+(d-b)-e<<endl;
}


Measured memory_bytes: 3624
#include <bits/stdc++.h>
using namespace std;
int main(void){
    int n;
    string s;
    cin>>n>>s;
    int sum=1;
    for(int i=1;i<n;i++){
        if(s.at(i-1)!=s.at(i)) sum++;
    }
    cout<<sum;
}


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

int main(){
    int A, B;
    cin >> A >> B;

    if(A <= 5)
        cout << "0" << endl;
    else if(A <= 12)
        cout << B / 2 << endl;
    else
        cout << B << endl;
    
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
bool check(int n,int a,int b)
{
    int sum=0;
    while(n)
    {
        sum+=n%10;
        n/=10;
    }
    return (sum>=a && sum<=b);
}
int main()
{
  int n,a,b;
  cin>>n>>a>>b;
  long long sum=0;
  for(int i=1; i<=n; i++)
  {
      if(check(i,a,b))
      {
          sum+=i;
      }
  }
  cout<<sum<<endl;
}


Measured memory_bytes: 256
while True :
    h,w = map(int,input().split())
    if h == 0 and w == 0 :
        break
    else :
        for i in range(h) :
            for j in range(w) :
                if (i+j)%2 == 0 :
                    print("#",end='')
                else :
                    print(".",end='')
            print('')
        print()



Measured memory_bytes: 7012
#pragma GCC optimize ("O3")
#include<bits/stdc++.h>
using namespace std;
int main(){
	int n;
	cin>>n;
	vector<int> v(n);
	for(int i=0;i<n;i++)
		cin>>v[i];
	multiset<int> M;
	for(int i=0;i<n;i++){
		auto it=M.upper_bound(v[i]*-1);
		if(it!=M.end()){
			M.erase(it);
			M.insert(v[i]*-1);
		}
		else M.insert(v[i]*-1);
	}
	cout<<M.size();
}

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

using namespace std;

typedef long long LL;

#define ARRAY_LENGTH(array) (sizeof(array) / sizeof(array[0]))
#define ALL(a)  (a).begin(),(a).end()
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)

#define dump(x)  cerr << #x << " = " << (x) << endl;

int main() {
  string S, T;
  int n;
  cin >> S;
  cin >> T;
  n = S.size();

  vector<int> r(26), r_inv(26);
  REP(i, r.size()) {
    r[i] = i;
    r_inv[i] = i;
  }

  REP(i, n) {
    char c1 = S[i], c2 = T[i];
    if (r[c1-'a'] == c2-'a') continue;
    
    int val1 = r[c1-'a'];
    r[c1-'a'] = c2-'a';

    int val2 = r_inv[c2-'a'];
    r[val2] = val1;

    r_inv[c2-'a'] = c1-'a';
    r_inv[val1] = val2;
  }
  REP(i, n) {
    char c1 = S[i], c2 = T[i];
    if (r[c1-'a'] != c2-'a') {
      cout << "No" << endl;
      return 0;
    }
  }
  cout << "Yes" << endl;

  return 0;
}

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

int gcd(int p,int q){
    if(p%q == 0){
        return q;
    }
        return gcd(q,p%q);
}

int main(){
    int n; cin >> n;
    int m = 1000000;
    vector<int> a(n);
    rep(i,n){
        cin >> a[i];
    }

    int sum;
    for(int i=-100;i<=100;i++){
        int sum = 0;
        rep(j,n){
            sum += (i-a[j])*(i-a[j]);
        }
        m = min(m,sum);
    }

    cout << m << endl;
}


Measured memory_bytes: 256
#include<utility>
#include<algorithm>
#include<vector>
#include<string>
#include<queue>
#include<deque>
#include<stack>
#include<complex>
#include<cmath>
#include<iostream>
#include<set>
#include<map>
#include<sstream>
#include<fstream>
#include<climits>
#include<chrono>
#include<random>
#include<functional>
#include<regex>

using namespace std;
typedef pair<int, int> P;
typedef long long ll;

// ??§????????°INF
const int INF = (1 << 30);
// ?¨±?????????????????
const double EPS = (1e-10);
// 2??????????????????????????????????????????
#define EQ(a,b) (abs((a)-(b)) < EPS)


int main()
{
	int n;
	while (true) {
		cin >> n;
		if (n == 0)break;
		vector<int> judges(n);
		int total = 0;
		for (int i = 0; i < n; ++i) {
			cin >> judges[i];
			total += judges[i];
		}
		int M = *max_element(judges.begin(), judges.end()),m=*min_element(judges.begin(),judges.end());
		total -= (M + m);
		int ans = total / (n - 2);
		cout << ans << endl;
	}
}

Measured memory_bytes: 1196
n = int(input())
s = input()

alphabet_place = dict()
for idx, c in enumerate(s):
    if c in alphabet_place:
        alphabet_place[c].append(idx)
    else:
        alphabet_place[c] = [idx]

ans = 1
for alph, place in alphabet_place.items():
    # +1: unuse
    ans = (len(place) + 1) * ans

# all unuse
ans = ans - 1
print(ans % (10**9+7))

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

using namespace std;

int main(void)
{
	int n;
	cin >> n;
	vector<int> a(n);
	for (int i = n - 1; i >= 0; i--) {
		cin >> a[i];
	}

	for (int i = 0; i < n; i++) {
		cout << a[i] << (i == n - 1 ? "\n" : " ");
	}

	return 0;
}


Measured memory_bytes: 3112
#include <algorithm>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rrep(i, n) for (int i = 1; i <= (n); ++i)
#define drep(i, n) for (int i = (n)-1; i >= 0; --i)
using namespace std;
const int INF = 1001001001;
const long long LINF = 1001002003004005006ll;
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 (b < a) {
        a = b;
        return 1;
    }
    return 0;
}
typedef long long ll;
typedef pair<int, int> P;

int main() {
    int n, x, t;
    cin >> n >> x >> t;
    int c = (n + x - 1) / x;
    cout << t * c << endl;
}

Measured memory_bytes: 3676
using System;
using System.Collections.Generic;
using System.Windows;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Atcoder
{
    public class Program
    {
        static void Main(string[] args)
        {
            var r1 = ReadSplit();
            var n = r1[0].ToLong();
            var k = r1[1].ToLong();
            var r = ReadSplit();
            var h = new long[n];
            for (long i = 0; i < n; i++)
            {
                h[i] = r[i].ToLong();
            }
            var dp = new long[100100];
            var INF = 9999999999;
            for (int i = 0; i < 100100; i++)
            {
                dp[i] = INF;
            }
            dp[0] = 0;
            for (int i = 1; i < n; i++)
            {
                for (int j = 0; j <= k; j++)
                {
                    if(i >= j) ChangeMin(ref dp[i], dp[i - j] + Math.Abs(h[i] - h[i - j]));
                }
            }
            WriteRead(dp[n - 1]);
        }

        public static string Read()
        {
            return Console.ReadLine();
        }

        public static string[] ReadSplit()
        {
            return Console.ReadLine().Split(' ');
        }

        public static void WriteRead(object str)
        {
            Console.WriteLine(str);
            Read();
        }

        public static void Write(object str)
        {
            Console.WriteLine(str);
        }

        private static bool ChangeMin<T>(ref T a, T b) where T : IComparable
        {
            if (a.CompareTo(b) > 0)
            {
                a = b;
                return true;
            }
            return false;
        }

        private static bool ChangekMax<T>(ref T a, T b) where T : IComparable
        {
            if (b.CompareTo(a) > 0)
            {
                a = b;
                return true;
            }
            return false;
        }
    }
}


public static class Extentions
{
    public static int ToInt32(this object obj)
    {
        return int.Parse(obj.ToString());
    }

    public static long ToLong(this object obj)
    {
        return long.Parse(obj.ToString());
    }

    public static decimal ToDecimal(this object obj)
    {
        return decimal.Parse(obj.ToString());
    }

    public static double ToDouble(this object obj)
    {
        return double.Parse(obj.ToString());
    }

    public static T2 GetValueZero<T1, T2>(this Dictionary<T1, T2> d, T1 key) where T2 : struct
    {
        T2 value;
        if (d.TryGetValue(key, out value))


        {
            return value;
        }
        return new T2();
    }
}



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

typedef long long ll;

//ソート済の配列に対して、クエリの値がどこに当たるか調査。
//配列とクエリを入力、queryより小さい数字の最大値の位置を出力として返す。
//queryより小さい数字がない場合は-1を返す。
int func_ascending(vector<int> input_arr, int query)
{
    int l, r, mid;
    if (query <= input_arr[input_arr.size() - 1]) return -1;
    //二分探索：開始位置は、l:0, r:末尾
    l = 0, r = input_arr.size() - 1;
    while(1){
        mid = (l + r) / 2;
        if ((query > input_arr[mid]) && 
            ((mid == 0) || (query <= input_arr[mid - 1]))) {return mid;}
        else if (query <= input_arr[mid]){ l = mid + 1;}
        else{ r = mid;}
    }
}

int main()
{
    int n;
    cin >> n;
    vector<int> a, b;
    for (int i = 0; i < n; i++)
    {
        int tmp; cin >> tmp;
        a.push_back(tmp);
    }


    for (int i = 0; i < n; i++)
    {
        if (i == 0){
            b.push_back(a[i]);
            continue;
        }

        //どの数字b[]よりも小さい場合
        if (b[b.size() - 1] >= a[i]){
            b.push_back(a[i]);
        } else {
            int k = func_ascending(b, a[i]);
            //printf("%d %d %d", k, i , a[i]);
            b[k] = a[i];
        }

    }
    cout << b.size() << endl;

}

Measured memory_bytes: 1656
n, m=map(int, input().split())
a=[int(input()) for i in range(m)]
mod=10**9 +7
dp=[1]*(n+1)
dp[0]=1
dp[1]=1

for i in range(m):
    dp[a[i]] = 0

for i in range(2, n+1):
    
    if dp[i] > 0:
        dp[i]=(dp[i-1]+dp[i-2])%mod

print(dp[n])

Measured memory_bytes: 7824