akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define lli long long int
using namespace std;
#define mod 1000000007
#define MOD 1000000037
#define mod1 998244353
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL); 
#define INF 2e9


int main()
{
    fastio;
    int n;
    cin >> n;
    vector<int>v(n);
    for(int i=0;i<n;i++)
        cin >> v[i];
    lli x=v[0];
    for(int i=1;i<n;i++)
        x=x^v[i];
    vector<int>ans;
    for(int i=0;i<n;i++)
        ans.push_back(x^v[i]);
    for(int i=0;i<n;i++)
        cout << ans[i] << " ";
    cout << endl;
}

Measured memory_bytes: 5004
a, b, k = map(int, input().split())
if a==0 and b==0:
    print(0, 0)
elif k>a:
    if b-(k-a)>0:
        print(0, b-(k-a))
    else:
        print(0, 0)
elif k<a:
    print(a-k, b)
elif a==k:
    print(0, b)

Measured memory_bytes: 9124
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cmath>
#include<cctype>
#include<math.h>
#include<string>
#include<string.h>
#include<stack>
#include<queue>
#include<vector>
#include<utility>
#include<set>
#include<map>
#include<stdlib.h>
#include<iomanip>
#include<complex>

using namespace std;

#define ll long long
#define ld long double
#define INF 1e9
#define LINF (ll)INF*INF
#define MOD 1000000007
#define rep(i,n) for(int i=0;i<(n);i++)
#define loop(i,a,n) for(int i=a;i<(n);i++)
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)

#define int ll //!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

const double PI=acos(-1);
const double EPS=1e-9; //うまくいかなかったらゆるめる

typedef vector<int> vi;
typedef vector<string> vs;
typedef pair<int,int> pii;
typedef pair<pii,int> ppi;
typedef pair<int,pii> pip;
typedef vector<pii> vp;
typedef vector<vi> vvi;

int gcd(int a, int b){if(b==0) return a;return gcd(b,a%b);}
int lcm(int a, int b){return a/gcd(a,b)*b;}


signed main(void) {
    int a,b,c,d;
    cin >> a >> b >> c >> d;
    while(1){
        c -= b;
        if(c <= 0){
            cout << "Yes" << endl;
            break;
        }
        a -= d;
        if(a <= 0){
            cout << "No" << endl;
            break;
        }
    }
}


Measured memory_bytes: 3632
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N, M, X = 0, Y = 0;
  
  cin >> N;
  vector<string> blue(N);
  for (int i = 0; i < N; i++) cin >> blue.at(i);
  
  cin >> M;
  vector<string> red(M);
  for (int i = 0; i < M; i++) cin >> red.at(i);
  
  for (int i = 0; i < N; i++) {
    if (blue.at(i) != "") {
      
      for (int j = i; j < N; j++) {
        if (blue.at(i) == blue.at(j)) {
          X++;
          if (i < j) blue.at(j) = "";
        }
      }
      for (int j = 0; j < M; j++) {
        if (blue.at(i) == red.at(j)) {
          X--;
          red.at(j) = "";
        }
        if (Y > X) continue;
      }
      
    }
    if (X > Y) Y = X;
    X = 0;
  }
  cout << Y << endl;
}

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

int main() {
  string S,T;
  cin >> S >> T;
  int res = 1;
  if(T.size() != S.size() + 1){
    res = 0;
  }
  else{
  int i = 0;
  	while(i < S.size()){
      if(S.at(i) != T.at(i)){
        res = 0;
        break;
      }
      res = 1;  
      i++;
    }
  }
 if(res == 1){
   cout << "Yes" << endl;
 }
 else if(res == 0){
   cout << "No" << endl;
 }
}




Measured memory_bytes: 3628
N = int(input())

card = list(map(int, input().split()))

Alice = 0
Bob = 0

for i in range(len(card)):
    if i % 2 == 0:
        Alice += max(card)
    else:
        Bob += max(card)
    del card[card.index(max(card))]

print(str(Alice - Bob))

Measured memory_bytes: 3060
"use strict";
function Main(input) {
    let lines = input.split("\n");
    let lines1 = lines[0].split(/\s/).map((v) => v - 0);
    let N = lines1[0] - 0;
    let K = lines1[1] - 0;
    let Hs = lines[1].split(/\s/).map((v) => v - 0);

    Hs.unshift(0);
    let dp = new Array(N+K).fill(Number.MAX_SAFE_INTEGER);
    dp[1] = 0;
    for (let n = 0; n <= N; n++) {
        for (let m = 1; m <= K; m++) {
            dp[n + m] = Math.min(dp[n + m], dp[n] + Math.abs(Hs[n + m] - Hs[n]));
        }
    }
    console.log(dp[N]);
}
Main(require("fs").readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 28492
#include<bits/stdc++.h>
using namespace std;
#define bitCount(num)  __builtin_popcount(num)
#define pb push_back
#define ll long long
#define bye return 0;
#define f(i,a,b) for( long long i=a;i<b;i++)
#define testCases long long t;cin>>t; while(t--)
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL);
#define newLine <<"\n"
#define all(x) (x).begin(), (x).end()
#define vll vector<long long>

void showDP(vector<vector<ll>> dp)
{
	f(i,0,dp.size())
	{
		f(j,0,dp[i].size())
		{
			cout<<dp[i][j]<<" ";
		}
		cout<<endl;
	}
}




ll knapSack_Memo(vector<pair<int,ll>> p,vector<vector<ll>> &dp,int w, int currSum, int n)
{
     

	if(n==0|| currSum==0) 
		return dp[n][currSum]=0;


if(dp[n][currSum]!=-1) return dp[n][currSum];


  if(p[n-1].first<= currSum) 
  	{
  		ll ans1= p[n-1].second+knapSack_Memo(p,dp,w,currSum-p[n-1].first,n-1);
  		ll ans2=knapSack_Memo(p,dp,w,currSum,n-1);
  		return dp[n][currSum] =max(ans1,ans2);
  	}

  else return dp[n][currSum]=knapSack_Memo(p,dp,w,currSum,n-1);

}



int main()
{
    fast

    int n,w;
    cin>>n>>w;
    vector<pair<int,ll>> p(n);

    f(i,0,n)
    {
    	int a;
    	ll b;
    	cin>>a>>b;
    	p[i]={a,b};
    }
    // vector<pair<ll,ll>> p;

//     sort(p_.begin(),p_.end());
// // cout<<p.size()<<endl;
//     for(int i=n-1;i>=0;i--)p.pb(make_pair(p[i].first,p[i].second));
    // cout<<p.size()<<endl;
    vector<vector<ll>> dp(n+1, vector<ll>(w+1,-1));
    // cout<<knapSack_Memo(p,dp,w,w,n);
    // cout<<endl;
   for(int i=0;i<n+1;i++) dp[i][0]=0;
   for(int j=0;j<w+1;j++) dp[0][j]=0;

   	for(int i=1;i<n+1;i++)
   	{
   		for(int j=1;j<w+1;j++)
   		{
   			if(j>=p[i-1].first)
   			{
   				dp[i][j]= max((p[i-1].second+dp[i-1][j-p[i-1].first]), dp[i-1][j]);
   			}
   			else dp[i][j]=dp[i-1][j];
   			// cout<<dp[i][j]<<endl;
   		}
   	}
   	cout<<dp[n][w];





    // showDP(dp);




   
    bye
}

Measured memory_bytes: 83196
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int MOD=1000000007;
#define INF 1LL<<30
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define all(x) (x).begin(),(x).end()

// nCr mod を計算する O(n)
const int MAX_N = 1000010;
ll fac[MAX_N], finv[MAX_N], inv[MAX_N];
// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX_N; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}
// 二項係数計算
long long COM(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

int main(){
    ll x,y;
    cin>>x>>y;
    COMinit();

    if((2*y-x)%3!=0 || (2*x-y)%3!=0){
        cout<<0<<endl;
        return 0;
    }

    ll a=(2*y-x)/3;
    ll b=(2*x-y)/3;

    cout<<COM(a+b,a)<<endl;
}

 

Measured memory_bytes: 23680
#include "bits/stdc++.h"
using namespace std;
#define ll long long int
#define rep(i,n) for( int i = 0; i < n; i++ )
#define rrep(i,n) for( int i = n; i >= 0; i-- )
#define REP(i,s,t) for( int i = s; i <= t; i++ )
#define RREP(i,s,t) for( int i = s; i >= t; i-- )
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define INF 2000000000
#define mod 1000000007
#define INF2 1000000000000000000


int main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int A, B;
    cin >> A >> B;
    A--; B--;
    cout << A * B << endl;

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<b;i++)
#define rrep(i,b,a) for(int i=b;i>=a;i--)
#define fori(a) for(auto i : a )
#define all(a) begin(a), end(a)
#define set(a,b) memset(a,b,sizeof(a))
#define sz(a) a.size()
#define pi 3.14159
#define ll long long
#define ull unsigned long long
#define pb push_back
#define PF push_front //deque
#define mp make_pair
#define pq priority_queue
#define mod 1000000007
#define f first
#define s second
#define pii pair< int, int >
#define vi vector<int>
#define vpii vector<pii>
#define debug(v) for(auto i:v) cout<<i<<" ";
#define tc int t; cin >> t; while(t--)

using namespace std;
string repeat(string s, int n) {
    string s1 = "";
    for (int i=0; i<n;i++)
        s1+=s;
    return s1;
}
string getString(char x) {
    string s(1, x);
    return s;
}

void optimizeIO(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
}
int gcd(int a, int b){
    if (a == 0)  return b;
    return gcd(b % a, a);
}
bool solve(){
  string s,t;
  cin>>s>>t;
  rep(i,0,s.length()){
    if(s[i]!=t[i]) return false;
  }
  return true;
}
int main(){
    optimizeIO();
    // tc
    { bool x=solve();
      if(x) cout<<"Yes\n";
      else cout<<"No\n";
    }
}


Measured memory_bytes: 3680
#include <bits/stdc++.h>
#define ALL(a)  (a).begin(),(a).end()
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
typedef pair<long long, long long> Pll;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<long long> vll;
typedef vector<vector<long long>> vvll;
template <typename T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template <typename T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
const long long INF = 1LL << 60;
const int INT_INF = 1LL << 30;

template<typename T>
bool is_prime(T n){
  for(T i = 2; i * i <= n; i++){
    if(n % i == 0) return false;
  }
  return n != 1;
}

int main(){
  ll N;
  cin >> N;
  vvll prime(5, vll(0));
  prime.at(2).push_back(2);
  for(int i = 3; i <= 55555; i+=2){
    if(is_prime(i)) prime.at(i%5).push_back(i);
  }
  for(int i = 0; i < N; i++){
    cout << prime.at(1).at(i);
    if(i == N-1) cout << endl;
    else cout << ' ';
  }
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
using Graph = vector<vector<int>>; // グラフ型
typedef long long ll;
#define _GLIBCXX_DEBUG
#define rep(i, n) for(int i = 0; i < (n); ++i)




int main() {
  string S, T;
  cin >> S >> T;
  //vector<ll> a(N);
  //vector<vector<int>> data(3, vector<int>(4));
  
  cout << T << S << endl;

  return 0;
}


Measured memory_bytes: 3620
#include <stdio.h>
#include <vector>
#include <algorithm>
using namespace std;

vector<int> v[111111];
int fn[111111], sk[111111], vst_fn[111111], vst_sk[111111];

void dfs_fn(int node, int dst)
{
	int i;

    if (vst_fn[node])
		return;

	vst_fn[node] = 1;
	fn[node] = dst;

	for (i = 0; i < v[node].size(); i++)
		dfs_fn(v[node][i], dst + 1);
}

void dfs_sk(int node, int dst)
{
	int i;

    if (vst_sk[node])
		return;

	vst_sk[node] = 1;
	sk[node] = dst;

	for (i = 0; i < v[node].size(); i++)
		dfs_sk(v[node][i], dst + 1);
}

int main(void)
{
	int n, i;

	scanf("%d" ,&n);
	for (i = 1; i < n; i++)
	{
		int a, b;

		scanf("%d %d" ,&a, &b);

		v[a].push_back(b);
		v[b].push_back(a);
	}

	dfs_fn(1, 0);
	dfs_sk(n, 0);

	int fn_cl = 0, sk_cl = 0, same = 0;

	for (i = 1; i <= n; i++)
        if (fn[i] < sk[i])
			fn_cl++;
		else if (fn[i] > sk[i])
			sk_cl++;
		else
			same++;

    fn_cl += same;

    if (fn_cl > sk_cl)
		puts("Fennec");
	else
		puts("Snuke");
	return 0;
}

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

int main() {
  int a1, a2, a3;
  cin >> a1 >> a2 >> a3;
  
  cout << max(a1+a2+10*a3,max(a1*10+a2+a3,a1+10*a2+a3)) << endl;
}


Measured memory_bytes: 256
//#include <bits/stdc++.h>
#include<iostream>
#include<math.h>
#include<vector>
#include<algorithm>
#include<queue>
using namespace std;
int x,y,a,b,c;
int r[100001];
int g[100001];
int no[100001];

int main(){
    cin>>x>>y>>a>>b>>c;
    for(int i=0;i<a;i++)
        scanf("%d",&r[i]);
    for(int i=0;i<b;i++)
        scanf("%d",&g[i]);
    for(int i=0;i<c;i++)
        scanf("%d",&no[i]);
    sort(r,r+a,greater<int>());
    sort(g,g+b,greater<int>());
    sort(no,no+c,greater<int>());
    vector<int>v;
    for(int i=0;i<x;i++){
        v.push_back(r[i]);
    }
    for(int i=0;i<y;i++){
        v.push_back(g[i]);
    }
    sort(v.begin(),v.end());
    int cnt=0;
    for(int i=0;i<v.size()&&cnt<c;i++){
        v[i]=max(v[i],no[cnt]);
        cnt++;
    }
    long long sum=0;
    for(int i=0;i<x+y;i++){
        sum+=v[i];
    }
    printf("%lld",sum);
    
    

}


Measured memory_bytes: 2552
#include <iostream>
#include <fstream>
#include <vector>
#include <set>
#include <algorithm>
using namespace std;
vector <int> sons;
vector<vector<int>> nxt;
vector<int> parent;
typedef pair<int, int> pint;
int he;
int n;
void dfs(int v, int p, int h) {
	parent[v] = p;
	if (v == n-1) { he = h; };
	for (int i = 0; i < nxt[v].size();i++) {
		int to = nxt[v][i];
		if (to != p) {
			sons[v]++;
			dfs(to, v,h+1);
			sons[v] += sons[to];
		}
	}
}
int main() {
	cin >> n;
	sons= vector <int>(n);
	nxt= vector<vector<int>>(n);
	parent= vector<int>(n);
	for(int i=0; i<n-1;i++){
		int p, q;
		cin >> p >> q;
		p--;q--;
		nxt[p].push_back(q);
		nxt[q].push_back(p);
	}
	dfs(0, 0, 0);
	he = (he-1) / 2;
	n = n - 1;
	for (int i = he; i > 0;i--) {
		n = parent[n];
	}
	int rr = sons[n];
	int r = sons[0] - rr - 1;
	if (r>rr) {
		cout << "Fennec";
	}
	else {
		cout << "Snuke";
	}
	system("pause");
}

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

int main() {
   int n, a[100005], ans=0, count=0;
   cin >> n;
   for(int i=0; i<n; i++) cin >> a[i]; 
   for(int i=0; i<n-1; i++) {
       if(a[i]-a[i+1]>=0) {
           count++;
           ans=max(ans, count);
        }
       else count=0;
    }
    cout << ans;
}

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

long long n, s;
int main() {
    scanf("%lld%lld", &n, &s);
    long long p = abs(n-s), q = sqrt(p), ans = 1e18;
    if(n == s) return !printf("%lld", n+1);
    for(long long k = 1; k <= q; k++) {
        if(p%k==0) {
            long long sum = 0, r = n;
            while(r) sum += r%(k+1), r/=(k+1);
            if(sum == s) ans = min(ans, k+1);
            r = n, sum = 0; long long t = p/k+1;
            while(r) sum += r%t, r/=t;
            if(sum == s) ans = min(ans, t);
        }
    }
    printf("%lld", (ans == 1e18 ? -1 : ans));
}


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

int main()
{
    long long x; cin >> x;

    auto result = 2*(x/11);
    const auto remaining = x%11;

    if (1 <= remaining && remaining <= 6) result += 1;
    else if (remaining >= 7) result += 2;

    cout << result << endl;
}


Measured memory_bytes: 256
fun main(args : Array<String>){
    val A = readLine()!!
    val B = readLine()!!

    for(i in 0 until A.length){
        var flag = true
        for(j in 0 until A.length){
            if(A[j] != B[(i+j) % A.length])flag = false
        }
        if(flag){
            println("Yes")
            return
        }
    }
    println("No")

}


Measured memory_bytes: 33680
#include <iostream>
#include <algorithm>
#include <fstream>
#include <vector>
#include <deque>
#include <assert.h>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <stdio.h>
#include <string.h>
#include <utility>
#include <math.h>
#include <bitset>
#include <iomanip>
#include <complex>
using namespace std;
#define rng(i,a,b) for(int i=int(a);i<int(b);i++)
#define rep(i,b) rng(i,0,b)
#define gnr(i,a,b) for(int i=int(b)-1;i>=int(a);i--)
#define per(i,b) gnr(i,0,b)
#define ALL(x) (x).begin(),(x).end()
#define RALL(x) (x).rbegin(),(x).rend()
#define IDX(vec, element_iter) distance((vec).begin(), element_iter)
#define print(x) cout<<(x)<<'\n'
#define print_vec(v) rep(i,v.size()){if(i!=0)cout<<" ";cout<<v[i];}cout<<'\n'
#define pe(x) cout<<(x)<<" "
#define DEBUG(x) cout<<#x<<": "<<x<<'\n'
#define DEBUG_VEC(v) cout<<#v<<":";rep(i,v.size())cout<<" "<<v[i];cout<<'\n'
#define DEBUG_VEC2(v) rep(i,v.size())cout<<#v<<":"<<v[i]<<'\n'
#define pb push_back
#define mp make_pair
#define MOD 1000000007 //10^9+7
#define fi first
#define sc second
using ll=long long;
using pi=pair<int,int>;
using pll=pair<int,int>;
using vi=vector<int>;
using vll=vector<ll>;
using vstr=vector<string>;
int dx[4]={0,0,-1,1};
int dy[4]={-1,1,0,0};
void yes(bool c) { if (c)print("Yes"); else print("No"); };
void YES(bool c) { if (c)print("YES"); else print("NO"); };


void solve() {
    int a,b,h; cin >> a >> b >> h;
    print((a+b)*h/2);
}

int main() {
    cin.tie(nullptr);
    ios_base::sync_with_stdio(false);
	cout<<fixed<<setprecision(20);
    //int q; cin >> q;
	//while (q--)
		solve();
    return 0;
}


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

typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> ii;
typedef tuple<ll, ll, ll> iii;
typedef vector<ll> vi;
typedef vector<ii> vii;
typedef vector<iii> viii;
typedef vector<vi> vvi;
typedef vector<vii> vvii;
#define REP(i,n) for (ll i = 0; i < n; ++i)
#define REPR(i,n) for (ll i = n-1; i >= 0; --i)
#define FOR(i,m,n) for (int i = m; i < n; ++i)
#define FORR(i,m,n) for (ll i = n-1; i >= m; --i)
#define FORE(x,xs) for (const auto& x : xs)
#define PB push_back
#define MP make_pair
#define MT make_tuple
#define ALL(v) v.begin(), v.end()
#define rALL(v) v.rbegin(), v.rend()

int A, B;

int main() {
    cin >> A >> B;
    int ans = 0;
    int num = 1;
    while (num < B) {
        ans++;
        num += A-1;
    }
    cout << ans << endl;
}

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

const int MAXN = 11;
const int MAXR = 50;
const int INF = 0x3f3f3f3f;

int d[MAXN][MAXN];
int n, V;

void Floyd() {
	for (int k = 0; k < V; ++k) {
		for (int i = 0; i < V; ++i) {
			for (int j = 0; j < V; ++j) {
				d[i][j] = min(d[i][j], d[i][k] + d[k][j]);
			}
		}
	}
}
void solve() {
	Floyd();
	int resSum = INF, resId = -1;
	for (int i = 0; i < V; ++i) {
		long long cur = 0;
		for (int j = 0; j < V; ++j) {
			cur += d[i][j];
		}
		if (cur < resSum) {
			resSum = cur;
			resId = i;
		}
	}
	printf("%d %d\n", resId, resSum);
}
int main(int argc, char const *argv[])
{
#ifdef LOCAL
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif
	while (scanf("%d", &n) && n != 0) {
		for (int i = 0; i < MAXN; ++i) {
			fill(d[i], d[i] + MAXN, INF);
			d[i][i] = 0;
		}
		V = 0;
		for (int i = 0; i < n; ++i) {
			int u, v, w;
			scanf("%d%d%d", &u, &v, &w);
			V = max(V, max(u, v) + 1);
			d[u][v] = w;
			d[v][u] = w;
		}
		solve();
	}
	//system("pause");
	return 0;
}


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

using namespace std;

int main() {
	int H, N;
	cin >> H >> N;
	int Attack = 0;
	for (int n = 0;n<N;++n) {
		int num;
		cin >> num;
		Attack += num;
	}
	if (Attack >= H) {
		cout << "Yes"<< endl;
	}
	else{
		cout << "No" << endl;
	}
	return 0;
}

Measured memory_bytes: 3592
import java.awt.*;
import java.io.*;
import java.util.*;

public class Main {

    private static FastReader in = new FastReader(System.in);
    private static PrintWriter out = new PrintWriter(System.out);

    private static final long MOD = (long) 1e9 + 7;

    public static void main(String[] args) {
        solve();
        out.flush();
    }

    private static void solve() {
        String s = in.next();
        out.println(s.contains("7") ? "Yes" : "No");
    }

    // https://www.geeksforgeeks.org/fast-io-in-java-in-competitive-programming/
    static class FastReader {
        BufferedReader br;
        StringTokenizer st;

        FastReader(InputStream inputStream) {
            br = new BufferedReader(new
                    InputStreamReader(inputStream));
        }

        String next() {
            while (st == null || !st.hasMoreElements()) {
                try {
                    st = new StringTokenizer(br.readLine());
                } catch (IOException  e) {
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }

        int nextInt() {
            return Integer.parseInt(next());
        }

        long nextLong() {
            return Long.parseLong(next());
        }

        double nextDouble() {
            return Double.parseDouble(next());
        }

        String nextLine() {
            String str = "";
            try {
                str = br.readLine();
            } catch (IOException e) {
                e.printStackTrace();
            }
            return str;
        }

        // https://qiita.com/masakinpo/items/5f77f2a879578a85a0bb
        public int[] nextIntArray(int n) {
            int[] a = new int[n];
            for (int i = 0; i < n; i++)
                a[i] = nextInt();
            return a;
        }

        public long[] nextLongArray(int n) {
            long[] a = new long[n];
            for (int i = 0; i < n; i++)
                a[i] = nextLong();
            return a;
        }
    }
}


Measured memory_bytes: 25444
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <cmath>
#include <queue>
#include <functional>
typedef long long ll;

using namespace std;

class Edge
{
	public:
	int cost;
	int next;

	Edge(int n,int c)
	{
		next=n;
		cost=c;
	}
};

vector<Edge> g[100000];
vector<int> path; 
int d[100000];
int pre[100000];
bool used[100000];
int fe[100000];

int dfs(int s,int f)
{
	fe[s]=f;
	for(int i=0;i<g[s].size();i++)
	{
		Edge e = g[s][i];
		if(fe[e.next]==0)
		{
			dfs(e.next,f);
		}
	}
	return 0;
}

int main()
{
	int n;
	int keiro;
	cin>>n;
	for(int i=0;i<n-1;i++)
	{
		int a,b;
		cin>>a>>b;
		a--;
		b--;
		g[a].push_back(Edge(b,1));
		g[b].push_back(Edge(a,1));
	}
	fill(used,used+100000,false);
	fill(d,d+100000,99999999);
	//ダイクストラ
	priority_queue<pair<int,int>,vector<pair<int,int>>,greater<pair<int,int>>> que;
	que.push(make_pair(0,0));
	d[0]=0;
	fill(pre,pre+100000,-1);
	while(!que.empty())
	{
		auto p = que.top();
		que.pop();
		int v = p.second;
		if(d[v]<p.first)
			continue;
		for(int i=0;i<g[v].size();i++)
		{
			Edge e = g[v][i];
			if(d[e.next]>d[v]+e.cost)
			{
				d[e.next]=d[v]+e.cost;
				pre[e.next]=v;
				que.push(make_pair(d[e.next],e.next));
			}
		}
	}
	//ダイクストラここまで
	keiro = d[n-1];
	//経路復元
	for(int t=n-1;t!=-1;t=pre[t])
		path.push_back(t);
	reverse(path.begin(),path.end());

	//最短経路のうちフェネックの取る頂点を求める(fe=1,snuke=-1)
	fill(fe,fe+100000,0);
	for(int i=0;i<keiro/2+1;i++)
		fe[path[i]]=1;
	for(int i=keiro/2+1;i<path.size();i++)
		fe[path[i]]=-1;
	//それぞれの葉に当たるノードをすべて塗りつぶす
	for(int i=0;i<path.size();i++)
	{
		dfs(path[i],fe[path[i]]);
	}
	//累積和を取る
	keiro=0;
	for(int i=0;i<n;i++)
	{
		keiro+=fe[i];
	}
	if(keiro>0)
		cout<<"Fennec"<<endl;
	else
		cout<<"Snuke"<<endl;
	return 0;
}

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


/**
 * AIZU ONLINE JUDGE
 * 3115
 *  2020/5/4
 */
public class Main {


    boolean main() throws IOException {

        Scanner sc = new Scanner(systemin);

        int N = sc.nextInt();
        Set<Integer> set = new HashSet<>();

        for(int i = 0; i < N; i++) {
            int a = sc.nextInt();
            set.add(a);
        }

        result.printf("%d\n", set.size());

        sc.close();
        return false;
    }



    PrintStream log;
    PrintStream result = System.out;
    BufferedReader systemin;

    static Main instance = new Main();

    Main() {
        systemin = new BufferedReader(new InputStreamReader(System.in));
        log = new PrintStream(new OutputStream() { public void write(int b) {} } );
    }

    public static void main(String[] args) throws IOException {

        instance.main();
        instance.systemin.close();
    }


}




Measured memory_bytes: 74096
#include<iostream>
#include<algorithm>
#include<vector>
#include<cmath>
#include<string>
#include <iomanip>
#include <bits/stdc++.h>
#include <fstream>
#include <map>
using namespace std;
typedef long long ll;
//#define INF 1000000000000 //10^12:極めて大きい値,∞
#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=a;i<=(ll)(b);i++)
#define FORD(i,a,b) for(ll i=a;i>=(ll)(b);i--)

int main(){
    string s,t;
    ll ans=0;
    cin >> s >> t;
    REP(i,s.size()){
        if(s[i]!=t[i]) ans++;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3852
import java.util.Scanner;

/**
 * 81
 */
public class Main {

    public static void main(String[] args) throws Exception {
        try (Scanner sc = new Scanner(System.in)) {
            int N = sc.nextInt();

            boolean ans = false;
            for (int i = 1; i <= 9; i++) {
                for (int j = 1; j <= 9; j++) {
                    if (i * j == N) {
                        ans = true;
                        break;
                    }
                }
            }

            System.out.println(ans ? "Yes" : "No");
        }
    }

}


Measured memory_bytes: 21972
def main():
  s = input()
  if len(set(s)) == 2:
    a = 0
    for i in range(1, 4):
      a += 1 if s[0] == s[i] else 0
    print('Yes' if a == 1 else 'No')
  else:
    print('No')


if __name__ == '__main__':
  main()

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

void yon(int n)
{
	if(n == 0)
		return;
	yon(n/4);
	cout << n%4;
}

int main()
{
	int n;
	while(cin >> n){
		if(n == -1){
			break;
		}
		if(n==0)
			cout << 0;
		else
			yon(n);
		cout << endl;
	}
	return 0;
}

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

#define int long long
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()
#define rep(i,n) for(int i=0;i<n;++i)
#define rep1(i,n) for(int i=1;i<n;++i)
#define exrep(i, a, b) for(ll i = a; i < b; i++)
#define out(x) cout << x << endl
#define EPS (1e-7)
#define gearup ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);

typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<char> vc;
typedef vector<bool> vb;
typedef vector<double> vd;
typedef vector<string> vs;
typedef vector<pair<int,int> > vpii;
typedef vector<vector<int> > vvi;
typedef vector<vector<char> > vvc;
typedef vector<vector<bool> > vvb;
typedef vector<vector<double> > vvd;
typedef vector<vector<string> > vvs;
typedef vector<ll> vl;
typedef vector<vector<ll> > vvl;
typedef vector<vector<vector<ll> > > vvvl;
ll MOD = 1000000007;
const long long L_INF = 1LL << 60;
const int INF = 2147483647; // 2^31-1
const double PI = acos(-1);
//cout<<fixed<<setprecision(10);

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;}
template<class T> void debug(T v){rep(i,v.size()) cout<<v[i]<<" ";cout<<endl;}
const ll dx[8] = {1, 1, 0, -1, -1, -1, 0, 1};
const ll dy[8] = {0, 1, 1, 1, 0, -1, -1, -1};
//以降 cin の入力元が 'input.txt' になる
//std::ifstream in("input.txt");
//std::cin.rdbuf(in.rdbuf());

signed main()
{
    gearup;
    string s; cin >> s;
    if(s[0] == '9' || s[1] == '9')out("Yes");
    else out("No");
}


Measured memory_bytes: 3648
def check(i,j):
    if (i+j)%2==0:return'#'
    return'.'

while True:
    H,W=map(int,input().split())
    if H==0 and W==0:
        break
    for i in range(H):
        for j in range(W):
            print(check(i,j),end='')
        print()
    print()


Measured memory_bytes: 7008
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> ii;
typedef vector<ii> vii;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef long double ld;
#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 eb emplace_back
#define fi first
#define se second
#define sz(x) ((int)(x).size())
#define all(a) (a).begin(), (a).end()
#define rall(a) (a).rbegin(), (a).rend()
#define INF 1000000000
#define MOD 1000000007

void solve() {
    int ans = -1;
    float a,b;
    cin >> a >> b;
    int x = a/0.08, y = (b + 1)/0.1;
    rep(i,x,y) {
        if ((int)(i * 0.08) == a && (int)(i * 0.1) == b) {
            ans = i;
            break;
        }
    }
    cout << ans << "\n";
}

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
    int t = 1;
    //cin >> t;
    while (t--)
        solve();
    return 0;
}



Measured memory_bytes: 3712
#include <bits/stdc++.h>
using namespace std;
#define ll	    long long
#define vi      vector <int>
#define vii     vector <pair<int,int>>
#define ii      pair<int,int>
#define loop(n)	for(int i=0;i<n;i++)
ll mod=1e9+7;
bool is_prime(int n)
{
    if(n==2)
        return true;
    if(n%2==0||n<2)
        return false;
    for(int i=3; i<=sqrt(n); i+=2)
    {
        if(n%i==0)
            return false;
    }
    return true;
}
long long power(ll n, ll k){
    if(k==0) return 1;
    ll sq=(power(n,k/2))%mod;
    sq=(sq*sq)%mod;
    if(k%2==1)
        sq=(sq*n)%mod;
    return sq%mod;
}
void low(char &c){
c=tolower(c);
}
void primeFactors(int n)
{
    while (n % 2 == 0)
    {
        cout << 2 << " ";
        n = n/2;
    }

    for (int i = 3; i <= sqrt(n); i = i + 2)
    {
        while (n % i == 0)
        {
            cout << i << " ";
            n = n/i;
        }
    }

    if (n > 2)
        cout << n << " ";
}

#include <iostream>
using namespace std;
void fast();
map<string,ll> M;

int main() {
fast();
int n;
string s;
cin >>n;
loop(n){
    cin >> s;
    sort(s.begin(),s.end());
    M[s]++;
}
ll sum=0;
for(auto it : M){
    sum += (((it.second-1)*it.second)/2);
}
cout << sum;
}





void fast(){
std::ios_base::sync_with_stdio(0);
    cin.tie(NULL);
    cout.tie(NULL);

}


Measured memory_bytes: 11264
#define _CRT_SECURE_NO_WARNINGS
#include <stdio.h>
#include <ctype.h>

int main() {

	int a[100][100], b[100], result[100], n, m, i, s;

	scanf("%d %d", &n, &m);


	for (i = 0; i < n; i++) {

		for (s = 0; s < m; s++) {

			scanf("%d", &a[i][s]);

		}
	}

	for (i = 0; i < n; i++) {

		result[i] = 0;
	}

	for (s = 0; s < m; s++) {

		scanf("%d", &b[s]);

	}
	for (i = 0; i < n; i++) {

	

		for (s = 0; s < m; s++) {
			
			result[i] += b[s] * a[i][s];
		}

	}

	for (i = 0; i < n; i++) {

		printf("%d\n", result[i]);
	}
	
	return 0;
}

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

int main(){
   int n;
   cin >> n;
   ll ans = 0;
   for(int i=1;i<=n;i++){
       for(int j=1;j<=n;j++){
         for(int k=1;k<=n;k++){
             ans += gcd(i,gcd(j,k));
         }  
      }
   } 
   cout << ans << endl;
   return 0;
}


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

int main() {
	
	int n, m; cin >> n >> m;
	ll ans = 0;;
	int e = 1;
	int tmp_m = m;
	while (tmp_m--) {
		e *= 2;
	}
	ans += 1900 * m * e;
	ans += (n - m) * 100 * e;
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 3620
s=input()
YYMM=2
MMYY=2
if int(s[2]+s[3])>12 or int(s[2]+s[3])==0:
    if int(s[0]+s[1])>12 or int(s[0]+s[1])==0:
        YYMM=0
        MMYY=0
    else:
        YYMM=0
        MMYY=1
if (int(s[0]+s[1])>12 or int(s[0]+s[1])==0) and MMYY*YYMM==4:
    MMYY=0
    YYMM=1
if MMYY==0 and YYMM==0:
    print("NA")
elif MMYY==1 and YYMM==0:
    print("MMYY")
elif MMYY==0 and YYMM==1:
    print("YYMM")
else:
    print("AMBIGUOUS")

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



int main()
{
    #ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
    freopen("error.txt", "w", stderr);
    #endif
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);

    long long a,b,c,d;
    cin>>a>>b>>c>>d;
    cout<<max(max(a*c, a*d), max(b*c, b*d))<<endl;



	return 0;
}

Measured memory_bytes: 3216
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> 
using namespace __gnu_pbds;
using namespace std;
#define F first
#define S second
#define pb push_back
#define powerof2 ()
using ll = long long;
const ll M = 1000000007;
const ll infi = 1000000000000000;
const ll md = 998244353;
using vl = vector<ll>;
using pll =  pair<ll,ll>;
typedef tree<int,null_type,less<int>,rb_tree_tag, tree_order_statistics_node_update> is;
ll power(ll x,ll y){
    if(y==0)
    return 1;
    ll res=power(x,y/2);
    res=(res*res)%M;
    if(y&(ll)1)
    res=(res*x)%M;
    return res;
}


/*int n,ma=0;
vector<vector<int>> gr;
vector<int> color;
void dfs(int c,int p)
{
    vector<int> v;
    int j;
    for(j=1;j<gr[c].size()+2;j++)
    {
        if(j==color[c]||j==color[p])
        continue;
        //cout<<j<<" ";
        v.pb(j);
    }
    //cout<<endl;
    j=0;
    for(int i=0;i<gr[c].size();i++)
    {
        if(gr[c][i]!=p)
        {
            color[gr[c][i]]=v[j];j++;
            dfs(gr[c][i],c);
        }
    }
}*/
void solve(){
    string s;
    int q;
    cin>>s>>q;
    string f="",b="";
    int c=0;
    while(q--)
    {
        int ty;cin>>ty;
        if(ty==1)
        {
            c++;
        }
        else
        {
            int p;char ch;
            cin>>p>>ch;
            if(p==1)
            {
                if(c&1)
                b.pb(ch);
                else
                f.pb(ch);
            }
            else
            {
                if(c&1)
                f.pb(ch);
                else
                b.pb(ch);
            }
        }
    }
    reverse(f.begin(),f.end());
    s=f+s+b;
    if(c&1)
    reverse(s.begin(),s.end());
    cout<<s;
}
 
 
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    // int t;
    // cin>>t;
    // while(t--)
    solve();
    return 0;
}

Measured memory_bytes: 1200
#include <iostream>
using namespace std;
int main(void){
   int r, c;
   cin >> r >> c;
   int sheet[r+1][c+1];
   for (int i = 0; i < r; i++) {
       for (int j = 0; j < c; j++) {
           cin >> sheet[i][j];
       }
   }
   for (int i = 0; i < r; i++) {
      sheet[i][c] = 0;
      for (int j = 0; j < c; j++) {
          sheet[i][c] += sheet[i][j];
      }
   }
   for (int i = 0; i < c; i++) {
      sheet[r][i] = 0;
      for (int j = 0; j < r; j++) {
          sheet[r][i] += sheet[j][i];
      }
   }
   sheet[r][c] = 0;
   for (int i = 0; i < r; i++) {
       sheet[r][c] += sheet[i][c];
   }
   for (int i = 0; i < r+1; i++) {
       for (int j = 0; j < c+1; j++) {
           if (j != 0) cout << " ";
           cout << sheet[i][j];
       }
       cout << endl;
   }
}

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

using namespace std;

constexpr int MOD = 1'000'000'007;

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

    int N, K;
    cin >> N >> K;
    vector<int> A(N);
    for (int i = 0; i < N; ++i) {
        cin >> A[i];
    }
    int inv_within = 0;
    for (int i = 0; i < N; ++i) {
        for (int j = i + 1; j < N; ++j) {
            inv_within += A[j] < A[i];
        }
    }
    int inv_betw = 0;
    for (int i = 0; i < N; ++i) {
        for (int j = 0; j < N; ++j) {
            inv_betw += A[j] < A[i];
        }
    }
    inv_within = 1LL * inv_within * K % MOD;
    int num_pairs = 1LL * K * (K - 1) / 2 % MOD;
    inv_betw = 1LL * inv_betw * num_pairs % MOD;
    cout << (inv_within + inv_betw) % MOD << "\n";

    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<string>
#include<cstdlib>
#include<map>
#include<iomanip>
#include<sstream>
#include<vector>
#include<stack>
#include<math.h>
#include<queue>
#include<complex>

using namespace std;
int dp[4005][16005]={};

int main(){
	long long n,k,l=0,odd=0,tmp,memo=0,x,y,len=0;
	bool key=true;
	queue<int>quex,quey;
	string str;
	cin>>str>>x>>y;
	while(str[memo]=='F')
	{
		x--;
		memo++;
	}
	for(int i=memo+1;i<=str.length();i++)
	{
		if((str[i]=='T'||i==str.length())&&key)
		{
			quey.push(len);
			y+=len;
			key=!key;
			len=0;
		}else if(key)
		{
			len++;
		}else if((str[i]=='T'||i==str.length())&&!key)
		{
			quex.push(len);
			x+=len;
			key=!key;
			len=0;
		}else if(!key)
		{
			len++;
		}
	}
	
	if(x<0||y<0)
	{
		cout<<"No";
		return 0;
	}
	tmp=1;
	dp[0][0]=1;
	while(!quex.empty())
	{
		for(int i=0;i<16002-quex.front();i++)
		{
			dp[tmp][i]=max(dp[tmp-1][i],dp[tmp][i]);
			dp[tmp][i+2*quex.front()]=max(dp[tmp-1][i],dp[tmp][i+2*quex.front()]);
		}
		tmp++;
		quex.pop();
	}
	//cout<<x<<" "<<dp[tmp][x];
	if(dp[tmp-1][x]==0)
	{
		cout<<"No"<<endl;
		return 0;
	}
	
	
	for(int i=0;i<=4000;i++)
	{
		for(int j=0;j<=16002;j++)
		{
			dp[i][j]=0;
		}
	}
	
	//cout<<"a";
	tmp=1;
	dp[0][0]=1;
	while(!quey.empty())
	{
		for(int i=0;i<16002-quey.front();i++)
		{
			dp[tmp][i]=max(dp[tmp-1][i],dp[tmp][i]);
			dp[tmp][i+2*quey.front()]=max(dp[tmp-1][i],dp[tmp][i+2*quey.front()]);
		}
		tmp++;
		quey.pop();
	}
	if(dp[tmp-1][y]==0)
	{
		cout<<"No"<<endl;
		return 0;
	}
	cout<<"Yes"<<endl;
}


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

using namespace std;

typedef long long lli;

lli cal(lli h)
{
	if (h == 1) return 1;
	return cal(h / 2) * 2 + 1;
}

int main()
{
	lli h;
	cin>>h;
	cout<<cal(h)<<endl;
	return 0;
}

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

using namespace __gnu_pbds;
using namespace std;

typedef long long int ll;
typedef unsigned long long int ull;
typedef long double ld;
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> indexed_set;

#define mp make_pair
#define pb push_back
#define pf push_front
#define ss second
#define ff first
#define sz(x) (int)x.size()
#define newl "\n"
#define vi vector<int>
#define pii pair<int, int>
#define vii vector<pii>
#define vl vector<ll>
#define pll pair<ll, ll>
#define vll vector<pll>
#define coutp cout << fixed << setprecision(12)
#define mem(x, val) memset(x, val, sizeof(x))
#define fastio                        \
    ios_base::sync_with_stdio(false); \
    cin.tie(NULL);                    \
    cout.tie(NULL);
#define all(v) (v).begin(), (v).end()

const ld pi = 3.14159265359;
ll INF = 1e18 + 10;
ll MOD = 998244353;
ll mod = 1e9 + 7;

inline ll add(ll a, ll b, ll m)
{
    if ((a + b) >= m)
        return (a + b) % m;
    return a + b;
}

inline ll mul(ll a, ll b, ll m)
{
    if ((a * b) < m)
        return a * b;
    return (a * b) % m;
}

ll power(ll x, ll y, ll m)
{
    ll res = 1;
    x = x % m;
    if (x == 0)
        return 0;
    while (y > 0)
    {
        if (y & 1)
            res = (res * x) % m;
        y = y >> 1;
        x = (x * x) % m;
    }
    return res;
}

void solve()
{
    int n,m,k;
    cin>>n>>m>>k;
    vl a(n),b(m);

    for(int i=0;i<n;i++) {
        cin>>a[i];
    }
    for(int i=0;i<m;i++) {
        cin>>b[i];
    }
    for(int i=1;i<n;i++) {
        a[i]+=a[i-1];
    }
    ll fa=0;
    for(int i=1;i<m;i++) {
        b[i]+=b[i-1];
        if(b[i]<=k) {
            fa=i+1;
        }
    }

    for(int i=0;i<n;i++) {
        if(a[i]<=k) {
            ll x = a[i];
            int lo=0,hi=m-1;
            ll ans=i+1;
            ll v = k-x;
            int res=0;
            if(v>0) { 
                while(lo<=hi) {
                    ll mid = (lo+hi)/2;
                    if(b[mid]<=v) {
                        res = mid+1;
                        lo = mid+1;
                    }
                    else {
                        hi=mid-1;
                    }
                }
            }
            fa=max(ans+res,fa);
        }
    }

    cout<<fa;



}


int main()
{
    fastio;
    int t;

    t = 1;
    //cin >> t;
    //int test=t;
    while (t-- > 0)
    {
        //cout<<"Case #"<<(test-t)<<": ";
        solve();
        cout << newl;
    }

    return 0;
}

Measured memory_bytes: 6340
#include <cstring>
#include <sstream>
#include <cstdio>
#include <algorithm>
#include <iostream>
#include <vector>
#include <map>
#include <unordered_map>
#include <cmath>
#include <queue>
#include <set>
#include <stack>

using namespace std;
typedef long long ll;
typedef pair<int, int> P;
#define rep(i, n) for(ll i = 0; i < (ll)(n); i++)
#define repr(i, n) for(ll i = n - 1; i >= 0; i--)
#define repone(i, n) for(ll i = 1; i <= (ll)(n); i++)
#define each(i, mp) for(auto i:mp)
const int dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};
const ll mod = 1000000007;
const ll inf = ll(1e9);
const ll half_inf = ll(1e5);
const ll ll_inf = ll(1e9) * ll(1e9);

unordered_map<ll, ll> mp;

void solve() {
}

ll each_dig(string s) {
    ll ret = 0;
    rep(i, s.size()) {
        ret += (s[i] - '0');
    }
    return ret;
}


int main() {
#ifdef MY_DEBUG
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wmissing-noreturn"
    while (true) {
        mp = unordered_map<ll, ll>();
#pragma clang diagnostic pop
#endif
        int n, a, b;
        cin >> n >> a >> b;
        ll ans = 0;
        repone(i, n) {
            ll temp = each_dig(to_string(i));
            if (temp >= a && temp <= b) ans += i;
        }
        cout << ans << endl;

        solve();

#ifdef MY_DEBUG
    }
#endif
    return 0;
}

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

#define rep(i,n) for(ll i=0;i<(n);++i)
#define reps(i,n) for(ll i=1;i<=(n);++i)
using ll = long long;
using str = string;
constexpr long long INF = (1LL<<60);
constexpr long long MOD = (1e9+7);
template<class T>inline T gcd(T a,T b){if(b==0)return a; return(gcd(b,a%b));}
template<class T>inline T lcm(T a,T b){return a/gcd(a,b)*b;}
template<class T>inline bool chmax(T &a,const T &b){if(a<b){a=b;return true;}return false;}
template<class T>inline bool chmin(T &a,const T &b){if(a>b){a=b;return true;}return false;}
inline void dump(){cout<<endl;}
template<class Head,class... Tail>inline void dump(Head&& head, Tail&&... tail){cout<<head<<", ";dump(forward<Tail>(tail)...);}
template<typename T>inline istream &operator>>(istream&input,vector<T>&v){for(auto &elemnt:v)input>>elemnt;return input;}

main(){
  cin.tie(0);
  ios::sync_with_stdio(0);
  cout<<fixed<<setprecision(10);
  
  string s;
  cin>>s;
  ll n=s.size();

  vector<ll> Ridx,Lidx;
  rep(i,n){
    if(s[i]=='R')Ridx.push_back(i);
    else Lidx.push_back(i);
  }
  
  vector<ll> a(n);
  rep(i,n){
    if(s[i]=='R'){
      auto itr=*upper_bound(Lidx.begin(),Lidx.end(),i);
      ll dif=itr-i;
      if(dif&1)a[itr-1]++;
      else a[itr]++;
    }
    else{
      auto itr=*--lower_bound(Ridx.begin(),Ridx.end(),i);
      ll dif=i-itr;
      if(dif&1)a[itr+1]++;
      else a[itr]++;
    }
  }
  rep(i,n)cout<<a[i]<<" ";
  cout<<endl;


}


Measured memory_bytes: 2372
#include <bits/stdc++.h>
const int mod = (int)1e9+7, NMAX = 1024;
int answ[NMAX][NMAX];
int main() {
    std::ios_base::sync_with_stdio(false);
    std::cin.tie(0);
    for (int R, C; std::cin >> R >> C; ) {
        answ[0][1] = 1;
        for (int r = 1; r <= R; r++) {
            std::string s; std::cin >> s;
            for (int c = 1; c <= C; c++) {
                bool emp = (s[c-1] == '.');
                if (emp) { answ[r][c] = (answ[r-1][c] + answ[r][c-1]) % mod; }
                else { answ[r][c] = 0; }
            }
        }
        std::cout << answ[R][C] << std::endl;
    }
    return 0;
}

Measured memory_bytes: 4352
#include <cstdio>
#include <cstring>
using namespace std;
const int maxn = 105;
int h, w;
char Map[maxn][maxn];
int dir[4][2] = {-1, 0, 1, 0, 0, -1, 0, 1};
void Dfs(int x, int y, char c){
    Map[x][y] = '.';
    for(int i = 0; i < 4; i++){
        int xx = x + dir[i][0];
        int yy = y + dir[i][1];
        if(xx >= 0 && xx < h && yy >= 0 && yy < w && Map[xx][yy] == c){
            Dfs(xx, yy, c);
        }
    }
}
int main(){
    while(~scanf("%d%d",&h, &w)){
        if(!h && !w) break;
        int ans = 0;
        for(int i = 0; i < h; i++)
            scanf("%s",Map[i]);
        for(int i = 0; i < h; i++){
            for(int j  = 0; j < w; j++){
                if(Map[i][j] != '.'){
                    ans++;
                    Dfs(i, j, Map[i][j]);
                }
            }
        }
        printf("%d\n",ans);
    }

    return 0;
}



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

int main() {
    int a,b,c,k;
    bool flag =0;
    cin >> a >> b >> c >> k;
    for (int i = 0; i < k; i++){
        if(a >= b)b *=2;
        else if(b >= c)c*=2;
    }
    if(a<b && b<c)flag=1;
    if(flag)cout << "Yes" << endl;
    else cout << "No" << endl;
}

Measured memory_bytes: 3536
// g++ -std=c++11 a.cpp
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<map>
#include<set>
#include<unordered_map>
#include<utility>
#include<cmath>
#include<random>
#include<cstring>
#include<queue>
#include<stack>
#include<bitset>
#include<cstdio>
#include<sstream>
#include<iomanip>
#include<assert.h>
#include<typeinfo>
#define loop(i,a,b) for(int i=a;i<b;i++)
#define rep(i,a) loop(i,0,a)
#define FOR(i,a) for(auto i:a)
#define pb push_back
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)
#define show1d(v) {rep(_,v.size())cout<<" "<<v[_];puts("");}
#define show2d(v) {rep(__,v.size())show1d(v[__]);}
using namespace std;
//kaewasuretyuui
typedef long long ll;
// #define int ll
typedef int Def;
typedef pair<Def,Def> pii;
typedef vector<Def> vi;
typedef vector<vi> vvi;
typedef vector<pii> vp;
typedef vector<vp> vvp;
typedef vector<string> vs;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef pair<Def,pii> pip;
typedef vector<pip>vip;
#define mt make_tuple
typedef tuple<int,int,int,int> tp;
typedef vector<tp> vt;
template<typename A,typename B>bool cmin(A &a,const B &b){return a>b?(a=b,true):false;}
template<typename A,typename B>bool cmax(A &a,const B &b){return a<b?(a=b,true):false;}
//template<class C>constexpr int size(const C &c){return (int)c.size();}
//template<class T,size_t N> constexpr int size(const T (&xs)[N])noexcept{return (int)N;}
const double PI=acos(-1);
const double EPS=1e-9;
Def inf = sizeof(Def) == sizeof(long long) ? 2e18 : 1e9+10;
// int dx[]={0,1,0,-1};
// int dy[]={1,0,-1,0};//RDLU
#define yes puts("YES")
#define no puts("NO")

struct edge{int to,cap,rev;};//ikisaki youryou gyakuhen
class MF{//max flow
	public:
	int n;
	vector<vector<edge> >G;//[MAX];
	vector<bool>used;//[MAX];
	MF(int size){
		n=size;
		G=vector<vector<edge> >(n);
	}
	void add_edge(int from, int to, int cap){
		edge q={to,cap,int(G[to].size())};
		G[from].push_back(q);
		q={from,0,int(G[from].size()-1)};
		G[to].push_back(q);
	}
	int dfs(int v,int t, int f) {
		if(v==t)return f;
		used[v]=1;
		for(int i=0;i<G[v].size();i++){
			edge &e=G[v][i];
			if(used[e.to]||e.cap<=0) continue;
			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;
	}
	int mf(int s,int t) {//from s to t,ford_fulkerson
		int flow=0,f;
		while(1){
			used=vector<bool>(n,false);
			f=dfs(s,t,inf);
			if(f==0)return flow;
			flow+=f;
		}
	}
};
signed main(){
	ios::sync_with_stdio(false);
	cin.tie(0);

	int a,b,c;
	cin>>a>>b>>c;
	if(a==b&&b==c)cout<<"Yes"<<endl;
	else cout<<"No"<<endl;

}


Measured memory_bytes: 256
# -*- coding: utf-8 -*-
# abc129/abc129_b
import sys

s2nn = lambda s: [int(c) for c in s.split(' ')]
ss2nn = lambda ss: [int(s) for s in list(ss)]
ss2nnn = lambda ss: [s2nn(s) for s in list(ss)]
i2s = lambda: sys.stdin.readline().rstrip()
i2n = lambda: int(i2s())
i2nn = lambda: s2nn(i2s())
ii2ss = lambda n: [i2s() for _ in range(n)]
ii2nn = lambda n: ss2nn(ii2ss(n))
ii2nnn = lambda n: ss2nnn(ii2ss(n))

def main():
    N = i2n()
    W = i2nn()
    sum_W = sum(W)
    min_diff = sum_W
    fsum = 0
    for w in W:
        fsum += w
        min_diff = min(min_diff, abs(sum_W - 2 * fsum))
    print(min_diff)
    return

main()


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

int main(){
  int n;
  cin>>n;
  string s;
  cin>>s;
  vector<int> e(300010),w(300010);
  int E=0,W=0;

  for(int i=1;i<=n;++i){
    if(s[i-1]=='E'){
        E++;
    }else{
        W++;
    }
    e[i]=E;
    w[i]=W;
  }

  int ans=3e5;
  for(int i=1;i<=n;++i){
    ans=min(ans,w[i-1]+e[n]-e[i]);
  }

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


Measured memory_bytes: 3076
#!/usr/bin/env python3
import sys, math, itertools, collections, bisect
input = lambda: sys.stdin.buffer.readline().rstrip().decode('utf-8')
inf = float('inf') ;mod = 10**9+7
mans = inf ;ans = 0 ;count = 0 ;pro = 1

n,k = map(int,input().split())
A = [list(map(int,input().split())) for i in range(n)]
def calc(A,B):
  res = [[0]*n for i in range(n)]
  for i in range(n):
    for j in range(n):
      for k in range(n):
        res[i][j] += A[i][k] * B[k][j]
      res[i][j] %= mod
  return res


def power(A,k):
  if k == 1:
    return A
  elif k % 2 == 0:
    tmp = power(A,k//2)
    return calc(tmp,tmp)
  elif k % 2 == 1:
    return calc(A,power(A,k-1))

result = power(A,k)
print(sum(map(sum,result))%mod)
    


Measured memory_bytes: 67292