akhauriyash/Code-Regression huggingface dataset:
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {
	public static void main(String[] age)throws IOException{
		BufferedReader br = new BufferedReader (new InputStreamReader(System.in));

		int i = 1;
		int j = 0;

		while(true){
			String[] input = br.readLine().split(" ");

			int H = Integer.parseInt(input[0]);
			int W = Integer.parseInt(input[1]);

			if( H==0 && W==0 ) break;

			for( i=1 ; i<=H ; i++ ){
				for( j=1 ; j<=W ; j++ ){
					if( i%2==1 ){
						if( j%2==1 ){
							System.out.print("#");
						}else{
							System.out.print(".");
						}
					}else{
						if ( j%2==1 ){
							System.out.print(".");
						}else{
							System.out.print("#");
						}
					}
				}
				System.out.print("\n");
			}
			System.out.print("\n");
		}
	}
}

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

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

    int n;
    cin >> n;
    int ans = 0, x = 0, y = 0, z = 0;
    rep(i, n)
    {
        string s;
        cin >> s;
        if (s[0] == 'B' && s[s.size() - 1] == 'A')
            z++;
        else if (s[0] == 'B')
            x++;
        else if (s[s.size() - 1] == 'A')
            y++;
        rep(j, s.size()) if (s[j] == 'A' && s[j + 1] == 'B') ans++;
    }
    ans += max(0LL, z - 1);
    if (z > 0)
    {
        if (x > 0)
            ans++, x--;
        if (y > 0)
            ans++, y--;
    }
    ans += min(x, y);
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define int long long
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
#define pb push_back
#define F first
#define S second

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

const int MOD=1000000007;
int INF=100100100100100;

int Time[100];
map<string,int> ma;
signed main(){
  int n;cin>>n;
  rep(i,n){
    string s;
    int t;
    cin>>s>>t;
    ma[s]=i;
    Time[i]=t;
  }
  string x;cin>>x;
  int ans=0;
  for(int i=ma[x]+1;i<n;i++)ans+=Time[i];
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 256
use std::io::*;
use std::str::FromStr;

pub fn read<T: FromStr>() -> T {
  let stdin = stdin();
  let stdin = stdin.lock();
  let token: String = stdin
    .bytes()
    .map(|c| c.expect("failed to read char") as char)
    .skip_while(|c| c.is_whitespace())
    .take_while(|c| !c.is_whitespace())
    .collect();
  token.parse().ok().expect("failed to parse token")
}

pub fn read_n<T: FromStr>(n: usize) -> Vec<T> {
  read_n_logic::<T>(n, vec![])
}

pub fn read_n_logic<T: FromStr>(n: usize, mut a: Vec<T>) -> Vec<T> {
  match n {
    0 => a,
    _ => {
      a.push(read::<T>());
      read_n_logic(n - 1, a)
    }
  }
}

fn main() {
  let n: usize = read();
  let a: Vec<i64> = read_n(n);
  let b: Vec<i64> = read_n(n);
  let c: Vec<i64> = read_n(n-1);

  // println!("{:?}", a);
  // println!("{:?}", b);
  // println!("{:?}", c);

  let mut prev = -1;
  let mut ans = 0;

  for i in a {
    ans += b[(i-1) as usize];

    if prev + 1 == i {
      ans += c[(prev-1) as usize];
    }

    prev = i;
  }

  println!("{}", ans);
}


Measured memory_bytes: 4352
N = gets.to_i

def dfs(ns, max_digits)
  included = ns.reduce([false, false, false]) do |(i7, i5, i3), n|
    [
      i7 || n == 7,
      i5 || n == 5,
      i3 || n == 3
    ]
  end.all? { |i| i }
  count = if included
    ns.join('').to_i <= N ? 1 : 0
  else
    0
  end
  if ns.size == max_digits
    count
  else
    [7, 5, 3].reduce(count) do |acc, n|
      acc + dfs(ns + [n], max_digits)
    end
  end
end

ans = dfs([], N.to_s.size)
puts ans


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

vector < int > v[502];

int cal( int a, int b){

    int sum=0,i,x,y;
    for(i=a; i<=b; i++){
        x=lower_bound(v[i].begin(),v[i].end(),a)-v[i].begin();
        y=upper_bound(v[i].begin(),v[i].end(),b)-v[i].begin();
        sum+=(y-x);
    }
    return sum;
}

int main(){

    int a,b, n, m, q, i,j,sum;
    cin>>n>>m>>q;
    for(i=1; i<=m; i++){
        cin>>a>>b;
        v[a].push_back(b);
    }
    for(i=1; i<=n; i++)
        sort(v[i].begin(),v[i].end());
    while(q--){
        cin>>a>>b;
        sum=cal(a,b);
        cout<<sum<<endl;
    }

    return 0;
}

Measured memory_bytes: 4968
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for (int i=(a);i<(b);++i)
#define REP(i,n) for (int i=0;i<(n);++i)
#define all(a) (a).begin(),(a).end()
#define MOD 1000000007
using ll = long long;
using P = pair<int, int>;
using vi = vector<int>;
using vl = vector<ll>;
using vs = vector<string>;
using vc = vector<char>;
using vb = vector<bool>;
const int INFTY =2147483647;
int main(){
    ll x,ans=0,k=100;
    cin>>x;
    while(x>k){
        k+=k/100;
        ans++;
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 3608
#include <cstdio>

const int MAXN=1e5+5;
int n,ans;
int a[MAXN];

int main(){
	scanf("%d",&n);
	for(int i=1;i<=n;++i)
		scanf("%d",&a[i]);
	for(int i=1;i<=n;++i){
		if(a[i]==i){
			++ans;
			++i;
		}
	}
	printf("%d",ans);
	return 0;
}

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

int a[110][110],f[110][110];

int main(){
    int n; cin>>n;
    for(int j=1;j<=2;j++)
        for(int i=1;i<=n;i++)
            cin>>a[j][i];
    for(int i=1;i<=2;i++)
        for(int j=1;j<=n;j++)
            f[i][j]=max(f[i-1][j],f[i][j-1])+a[i][j];
    cout<<f[2][n]<<endl;
    return 0;
}
// 啦啦

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

using namespace std;
typedef long long ll;

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

    vector<ll> nel(n + 1, 0), ner(n + 1, 0);
    for(int i = 0; i < n; ++i){
        nel.at(i + 1) = nel.at(i) + (s.at(i) == 'E');
    }
    for(int i = n - 1; i >= 0; --i){
        ner.at(i) = ner.at(i + 1) + (s.at(i) == 'E');
    }

    ll ans = n;
    for(int i = 0; i < n; ++i){
        ans = min(
            ans,
            (i - nel.at(i)) + ner.at(i + 1)
        );
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 5372
#include <bits/stdc++.h>
//#define int long long

using namespace std;
using LL = long long;
using P = pair<LL, LL>;

#define FOR(i, a, n) for(int i = (int)(a); i < (int)(n); ++i)
#define REP(i, n) FOR(i, 0, n)

#define pb(a) push_back(a)
#define all(x) (x).begin(),(x).end()

const LL INF = (LL)1e9;
const LL INFL = (LL)1e15;
const LL MOD = 1e9 + 7;

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

/*************** using variables **************/
LL N, K;
vector<LL> x, y, xx, yy;
/**********************************************/

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

    cin >> N >> K;
    x.resize(N);
    xx.resize(N);
    y.resize(N);
    yy.resize(N);
    REP(i, N){
        cin >> x[i] >> y[i];
        xx[i] = x[i]; yy[i] = y[i];
    }

    sort(all(xx));
    sort(all(yy));

    LL ans = (xx[N-1] - xx[0]) * (yy[N-1] - yy[0]);

    REP(i, N){
        FOR(j, i+1, N){
            REP(k, N){
                FOR(l, k+1, N){
                    LL min_x = xx[i],
                       max_x = xx[j],
                       min_y = yy[k],
                       max_y = yy[l];

                    LL cnt = 0;
                    REP(m, N){
                        if(x[m] >= min_x && x[m] <= max_x && y[m] >= min_y && y[m] <= max_y) cnt++;
                    }
                    if(cnt >= K){
                        ans = min(ans, 1LL * (max_x - min_x) * (max_y - min_y));
                    }
                }
            }
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <algorithm>
#include <string>
#include <cmath>
#include <cstdio>
#include <iomanip>
#include <fstream>
#include <cassert>
#include <cstring>
#include <numeric>
#include <ctime>
#include <complex>
#include <bitset>
#include <random>
 
using namespace std;
 
typedef long long ll;
typedef long double ld;
 
#define int ll
#define double ld
#define loop(i, n) for(int i = 0; i < (int)n; ++i)
#define loop1(i, n) for(int i = 1; i <= (int)n; ++i)
#define F first
#define S second
#define pb push_back
#define pi pair <int, int>
#define all(x) begin(x), end(x)
#define ti tuple <int, int, int>
#define Point Vect

const int N = 2e5 + 7, INF = 1e15;

int calc[N];

void solve() {
    int n, x, y;
    cin >> n >> x >> y;
    --x; --y;
    loop(i, n)
        for (int j = i + 1; j < n; ++j)
            ++calc[min(j - i, abs(i - x) + abs(j - y) + 1)];
    loop1(i, n - 1)
        cout << calc[i] << "\n";
}
 
signed main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    //int t; cin >> t; loop(i, t)
    solve();
    return 0;
}

Measured memory_bytes: 256
n=int(input())
p=[int(input()) for _ in range(n)]
s=set()
for i in p:
  if i-1 in s:s-={i-1}
  s|={i}
s=[0]+sorted(list(s))
ans=n
for i in range(len(s)-1):
  ans=min(ans,n-s[i+1]+s[i])
print(ans)

Measured memory_bytes: 109056
#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

int main(){

  vector<int> A(3);
  int K=0;

  cin >> A[0] >> A[1] >> A[2];
  cin >> K;

  int sum = 0;

  for(auto itr=A.begin();itr!=A.end();itr++){
    if(itr==std::max_element(A.begin(),A.end())){
      int mul = *itr;
      for(int i=0;i<K;i++){
        mul *= 2;
      }
      sum += mul;
    }else{
      sum += *itr;
    }
  }

  cout << sum << endl;

  return 0;
}


Measured memory_bytes: 256
N=int(input())
A=sorted(list(map(int,input().split())))
# そこまでの累計(の2倍)より大きければ、そこまでに現れた数字はすべてNG

sums=0
least=0
for i in range(N):
  if A[i]>sums*2:
    least=i
  sums+=A[i]
print(N-least)


Measured memory_bytes: 14224
<?php
fscanf(STDIN, "%d%d", $t1, $t2);
fscanf(STDIN, "%d%d", $a1, $a2);
fscanf(STDIN, "%d%d", $b1, $b2);
$a1-=$b1;
$a2-=$b2;
$a1*=$t1;
$a2*=$t2;
if($a1<0){$a1=-$a1;$a2=-$a2;}
if($a1+$a2==0)
  echo "infinity\n";
elseif($a1+$a2>0)
  echo "0\n";
else{
  $a2 = -$a2;
  $a1*=2;
  $a2*=2;
  echo intdiv($a1,($a2-$a1))+intdiv(($a1-1),($a2-$a1))+1;
}

Measured memory_bytes: 4728
using System;

namespace ITP1_5_C{
    class Sample{
        static void Main(string[] args){
             while(true){
                string[] a;
                int h,w;
                a = Console.ReadLine().Split(' ');
                h = int.Parse(a[0]);
                w = int.Parse(a[1]);
                if((h==0)&&(w==0)) break;
                for(int i=0; i<h; i++){
                    for(int j=0; j<w; j++){
                        if(i%2==0){
                            if(j%2==0){
                                Console.Write("#");
                            } else {
                                Console.Write(".");
                            }
                        } else {
                            if(j%2==0){
                                Console.Write(".");
                            } else {
                                Console.Write("#");
                            }
                        }
                    }
                    Console.WriteLine();
                }
                Console.WriteLine();
             }
        }
    }
}


Measured memory_bytes: 15948
#include <bits/stdc++.h>
#define FOR(i, a, b) for(int i=(a); i<(b); i++)
#define REP(i, n) FOR(i, 0, n)
#define all(x) (x).begin(), (x).end()
#define bit(x) (1L << (x))
using ll = long long;
using namespace std;

using graph = vector<vector<int>>;

int main() {
  int n, m; cin >> n >> m;
  vector<int> a(m), b(m);
  graph g(n);

  REP(i, m){
    cin >> a[i] >> b[i];
    --a[i]; --b[i];
    g[a[i]].emplace_back(b[i]);
    g[b[i]].emplace_back(a[i]);
  }

  function<int(int, vector<bool>)> rec = [&](int s, vector<bool> vis){
    vis[s] = true;
    if(find(vis.begin(), vis.end(), false) == vis.end()) return 1;

    int ret = 0;
    for(const auto& next: g[s]){
      if(vis[next]) continue;
      ret += rec(next, vis);
    }

    return ret;
  };

  cout << rec(0, vector<bool>(n, false)) << endl;

  return 0;
}


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

using namespace std;

int a,b,c;

int main()
{
    scanf("%d%d%d",&a,&b,&c);
    if(a==5&&b==5&&c==7)
        printf("YES\n");
    else if(a==5&&b==7&&c==5)
        printf("YES\n");
    else if (a==7&&b==5&&c==5)
        printf("YES\n");
    else
        printf("NO\n");
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
using namespace std;

#define ff              first
#define ss              second
#define int             long long
#define pb              push_back
#define mp              make_pair
#define pii             pair<int,int>
#define vi              vector<int>
#define mii             map<int,int>
#define pqb             priority_queue<int>
#define pqs             priority_queue<int,vi,greater<int> >
#define setbits(x)      __builtin_popcountll(x) //counts no of zeroes in binary rep
#define zrobits(x)      __builtin_ctzll(x) // count no of zeroes to right of first set bit
#define mod             1000000007
#define inf             1e18
#define ps(x,y)         fixed<<setprecision(y)<<x
#define mk(arr,n,type)  type *arr=new type[n];
#define w(x)            int x; cin>>x; while(x--)
#define FIO             ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
mt19937                 rng(chrono::steady_clock::now().time_since_epoch().count());

const int sz = 1e5 + 2;
// pbds works as set data structure. USE pbds.find_by_order() to get element randomly. it returns iterator
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> pbds;

int pwmd(int a, int b) {
	if (a == 1)
		return 1;
	if (b == 0)
		return 1;
	int ans = pwmd(a, b >> 1);
	ans = (ans % mod * ans % mod) % mod;
	if (b & 1)
		return (ans * a) % mod;
	else
		return ans;
}



int32_t main() {
	ios_base::sync_with_stdio(false);
	cin.tie(NULL); cout.tie(NULL);
	int n = 0; cin >> n;
	int k = 0; cin >> k;
	int dp[sz]; // dp[i] stores the frequency of sequences which has gcd i
	memset(dp, 0, sizeof(dp));
	int ans = 0;
	// iterate reverse because we need to subtract the frequency of sequence related to multiples of i
	for (int i = k; i >= 1; --i) {
		dp[i] = pwmd(k / i, n);
		//remove the count of 2*i,3*i,4*i......
		for (int j = 2 * i; j <= k; j += i)
			dp[i] = (dp[i] - dp[j] + mod) % mod;
		ans = (ans % mod + (dp[i] % mod * i % mod ) % mod) % mod;
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 4400
// #define _CRT_SECURE_NO_WARNINGS
// #define _USE_MATH_DEFINES	// M_PI=3.1415...
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <stack>
#include <cmath>
#include <cstdlib>
#include <functional>
#include <locale>
#include <cctype>
#include <sstream>
#include <iomanip>	// 20桁出力 cout << setprecision(20) << double;
#include <queue>
#include <bitset>	// bitset<8> bs1(131uL); // 10000011 bs1[0]は1 01stringからビット集合生成可
#include <numeric>
#include <random>
#include <climits>  // A/Bを計算するときA==LLONG_MIN && B==-1のみ(1ull<<63)で代用
using namespace std;

typedef long long LL;
typedef pair<LL, LL> P;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<LL> VL;
typedef vector<VL> VVL;				// VVL v(100,VL(100,0));
typedef vector<pair<LL, LL> > VP;
typedef vector<string> VS;
typedef map<int, int> MAPII;
typedef multimap<int, char, greater<int> > MuMAPIC;
typedef multimap<int, string, greater<int> > MuMIS;
typedef pair<LL, pair<P, P> > PP;

#define INF 999999999999999997		// 少し加算したらオーバーフローする
#define MP make_pair
#define FAST_IO  cin.tie(0); ios::sync_with_stdio(false);
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define FORL(i,a,b) for(LL i=(a);i<(b);i++)
#define FOR_REV(i,a,b) for(int i=(a);i>=(b);i--)
#define foreach_it(type,it,c) for(type::iterator it=c.begin(),c_end=c.end();it!=c_end;++it)
#define FOR_ITR(d) for(auto itr=d.begin(),d_end=d.end();itr!=d_end;++itr)	// C++11
#define O(s) cout<<s<<endl;

#define DUMP_VVI(b) if(dbgF){FOR(i,0,b.size()){FOR(j,0,b[i].size())printf("%d ",b[i][j]);puts("");}}
#define D_OUT(str,value) if(dbgF){cout<<str<<" : "<<value<<endl;}

template<class T>T IN() { T d; cin >> d; return d; }

LL gcd(LL a, LL b) { return (b > 0) ? gcd(b, a % b) : a; } // 最大公約数（Greatest Common Divisor）
LL lcm(LL a, LL b) { return a / gcd(a, b) * b; } // 最小公倍数（Least Common Multiple）
bool uruu(LL Y) { return (((Y % 4 == 0 && Y % 100 != 0) || Y % 400 == 0) ? true : false); } // うるう年判定
string Replace(string S, string from, string to) { auto p = S.find(from); while (p != string::npos) { S.replace(p, from.size(), to); p = S.find(from, p + to.size()); }return S; }
// 桁和
LL Ketawa_s(string s) { LL a = 0; FOR(i, 0, s.length())a += s[i] - '0'; return a; }

//二項係数 nCk mod pを求める
const LL MAX = 510000, p = 998244353; LL fac[MAX], finv[MAX], inv[MAX];
/* 前処理 */void COM_init() { fac[0] = fac[1] = 1; finv[0] = finv[1] = 1; inv[1] = 1; FOR(i, 2, MAX) { fac[i] = fac[i - 1] * i % p; inv[i] = p - inv[p % i] * (p / i) % p; finv[i] = finv[i - 1] * inv[i] % p; } }
/* 主処理 */LL 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] % p) % p; }

int dx[4] = { 0,1,0,-1 };
int dy[4] = { 1,0,-1,0 };
int dxx[8] = { 0,1,1,1,0,-1,-1,-1 };
int dyy[8] = { 1,1,0,-1,-1,-1,0,1 };

// -------------------------------------------------------------------------------

int main() {
	FAST_IO;
	bool dbgF = true; // for D_OUT(str, value)  ... cout<< str <<" : "<< value <<endl;

	LL A, B, C;
	cin >> A >> B >> C;
	if (A + B >= C) {
		O("Yes");
	}
	else {
		O("No");
	}


	return 0;
}

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

namespace Baumkuchen {
	class Baumkuchen {
		static void Main(string[] args) {
			/*
			System.IO.StreamReader sr = new System.IO.StreamReader("input.txt");
			int N = int.Parse(sr.ReadLine());
			long[] v_list = new long[N + 1];
			v_list[0] = 0;
			for (int n = 1; n < N+1; n++) {
				v_list[n] = v_list[n - 1] + long.Parse(sr.ReadLine());
			}
			sr.Close();
			/*/
			int N = int.Parse(Console.ReadLine());
			long[] v_list = new long[N + 1];
			v_list[0] = 0;
			for (int n = 1; n < N + 1; n++) {
				v_list[n] = v_list[n - 1] + long.Parse(Console.ReadLine());
			}
			//*/
			Baumkuchen baumkuchen = new Baumkuchen(v_list);
			Console.WriteLine(baumkuchen.GetAnwser());
		}

		readonly long[] v_list;
		readonly int N;
		readonly double tripartition;
		public Baumkuchen(long[] _v_list) {
			N = _v_list.Length - 1;
			v_list = _v_list;
			tripartition = v_list[N] / 3.0;
		}
		public long GetAnwser() {
			var n0_list = from n0 in Enumerable.Range(0, N) where tripartition > v_list[n0] select n0;
			long interm_maxV = -1;
			foreach (var n0 in n0_list) {
				long tmp = searchOne(n0);
				if (tmp > interm_maxV) interm_maxV = tmp;
			}
			return interm_maxV;
		}

		private long searchOne(int n0) {
			int[] n1 = findIndex(1 * tripartition + v_list[n0]);
			int[] n2 = findIndex(2 * tripartition + v_list[n0]);
			return (from nn1 in n1 from nn2 in n2 select getMinV(n0, nn1, nn2)).Max();
		}

		private long getMinV(int n0, int n1, int n2) {
			if (n1 == -1 || n2 == -1) return long.MaxValue;
			else {
				long[] V0_V1_V2 = new long[] { v_list[n1] - v_list[n0], v_list[n2] - v_list[n1], v_list[n0] - v_list[n2] + v_list[N] };
				return V0_V1_V2.Min();
			}
		}

		private int[] findIndex(double target) {
			int n_left = 0;
			int n_right = N;
			while (n_right - n_left != 1) {
				int n_mid = (n_right + n_left) / 2;
				if (v_list[n_mid] <= target) n_left = n_mid;
				else n_right = n_mid;
			}
			return new int[] { n_left, n_right };
		}
	}
}

Measured memory_bytes: 20272
#include <iostream>
#include <vector>
#include <utility>
#include <algorithm>
#include <cmath>
#include <string>
#include <map>

#define pb push_back
#define mp make_pair

using namespace std;

typedef vector<int> vi;
typedef pair<int, int> ii;
typedef vector<ii> vii;
typedef unsigned long long ull;
typedef long long ll;

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

  int f1[31] = {0};

  int k1;
  cin >> k1;
  for (int i = 0; i < k1; ++i) {
    int k;
    cin >> k;
    f1[k] = 1;
  }

  for (int i = 0; i < n-1; ++i) {
    int kt;
    cin >> kt;

    int fx[31] = {0};
    for (int j = 0; j < kt; ++j) {
      int a;
      cin >> a;
      fx[a] = 1;
    }

    for (int i = 0; i < 31; ++i) {
      f1[i] = (f1[i] & fx[i]);
    }
  }

  int count = 0;
  for (int i = 0; i < 31; ++i) {
    if (f1[i]) {
      count++;
    }
  }

  cout << count << endl;
  return 0;
}


Measured memory_bytes: 256
n, s = int(input()), input()
w = [1 if s[0] == "W" else 0] + [0]*(n-1)
e = [0]*(n-1) + [1 if s[-1] == "E" else 0]
for i in range(1, n):
    w[i] = w[i-1]+1 if s[i] == "W" else w[i-1]
    e[n-i-1] = e[n-i]+1 if s[n-i-1] == "E" else e[n-i]
w = [0] + w + [0]
e = [0] + e + [0]
print(min(w[i-1]+e[i+1] for i in range(1,n+1)))


Measured memory_bytes: 24640
#include <bits/stdc++.h>
using namespace std;
 
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define rep(i, x, y)   for (__typeof(x) i = x; i < y; i++)
#define repr(i, x, y)   for (__typeof(x) i = x; i > y; i --)
#define all(x)                      (x).begin(),(x).end()
#define Sort(x)                     sort(all((x)))
#define rSort(x)                     sort((x).rbegin(),(x).rend())
#define X                           first
#define Y                           second
#define sep                         ' '
#define SZ(x)                       ll(x.size())
#define MAX(a,b) ((a)>(b)?(a):(b))
#define MIN(a,b) ((a)<(b)?(a):(b))
#define pb                          push_back
#define mp                          make_pair
typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> pll;
typedef pair<double, double> pdd;
typedef vector<ll> vll;
#define first X
#define second Y
 
const ll N = 1e18 + 10;
const ll M = 1e9 + 7;

long long binpow(long long a, long long b) {
    long long res = 1;
    while (b > 0) {
        if (b & 1)
            res = res * a;
        a = a * a;
        b >>= 1;
    }
    return res;
}

int32_t main()
{
  IOS;
  ll n,m,k,ans=0;
  cin >> n >> m >> k;
  char A[n][m],B[n][m];
  rep(i,0,n){
    rep(j,0,m) cin >> A[i][j];
  }
  rep(i,0,pow(2,n)){
    rep(j,0,pow(2,m)){
      rep(l,0,n){
        rep(k,0,m) B[l][k]=A[l][k];
      }
      rep(ii,0,7){
        if((i & (1<<ii)) !=0) {
          rep(x,0,m) B[ii][x]='.';
        }
      }
      rep(jj,0,7){
        if((j & (1<<jj)) !=0) {
          rep(x,0,n) B[x][jj]='.';
        }
      }
      ll cnt=0;
      rep(l,0,n){
        rep(k,0,m) if(B[l][k]=='#') cnt++;
      }
      if (cnt==k) ans++;

    }
  }
  cout << ans;

}

Measured memory_bytes: 4132
#include <bits/stdc++.h>
using namespace std;
int main()
{
  long long int N, K;
  long long int min;
  long long int a;
  cin >> N >> K;
  min = N;
  if (N == 0)
  {
    cout << 0 << endl;
  }
  else if (N == K)
  {
    cout << 0 << endl;
  }
  else if (N < K)
  {
    for (int i = 0;; i++)
    {
      a = abs(N - (K * i));
      //cout << a << endl;
      if (a == 0)
      {
        cout << 0 << endl;
        return 0;
      }
      else if (a > min)
      {
        cout << abs(N - K * (i - 1)) << endl;
        return 0;
      }
      min = a;
    }
  }
  else
  {
    long long int s;
    s = N / K;
    //cout << s << endl;
    for (long long int i = s;; i++)
    {
      a = abs(N - (K * i));
      //cout << a << endl;
      if (a == 0)
      {
        cout << 0 << endl;
        return 0;
      }
      else if (a > min)
      {
        cout << abs(N - K * (i - 1)) << endl;
        return 0;
      }
      min = a;
    }
  }
}

Measured memory_bytes: 256
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let mut s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

macro_rules! input_inner {
    ($iter:expr) => {};
    ($iter:expr, ) => {};

    ($iter:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($iter, $t);
        input_inner!{$iter $($r)*}
    };
}

macro_rules! read_value {
    ($iter:expr, ( $($t:tt),* )) => {
        ( $(read_value!($iter, $t)),* )
    };

    ($iter:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()
    };

    ($next:expr, [$t:tt]) => {
        {
            let len = read_value!($next, usize);
            (0..len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
        }
    };
    ($iter:expr, chars) => {
        read_value!($iter, String).chars().collect::<Vec<char>>()
    };

    ($iter:expr, usize1) => {
        read_value!($iter, usize) - 1
    };

    ($iter:expr, $t:ty) => {
        $iter.next().unwrap().parse::<$t>().expect("Parse error")
    };
}


#[cfg(debug_assertions)]
macro_rules! mydbg {
    //($arg:expr) => (dbg!($arg))
    ($arg:expr) => (println!("{:?}",$arg));
}


#[cfg(not(debug_assertions))]
macro_rules! mydbg {
    ($($arg:expr),*) => {};
}


use std::cmp;

fn main() {


  input! { 
         a: i32, 
         b: i32
    }

    let ret = cmp::max(a+b,cmp::max(a*b,a-b));
   println!("{}",ret);


}


Measured memory_bytes: 4352
#include<iostream>
using namespace std;
typedef long long int ll;

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

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


int main()
{
	ll a, b;
	while (cin >> a >> b) {
		cout << gcd(a, b) << " " << lcm(a, b) << endl;
	}
    return 0;
}

Measured memory_bytes: 3016
#include <iostream>
#include <vector>
#include <algorithm>
#include <string.h>

#define N 110

using namespace std;

int main(void)
{
	int n,m,k;
	int i1,i2;
	int p;
	int info[N][N];

	while(1){
		cin >> n;
		if (n==0) break;

		vector<pair<int,int> > mem(n);

		for(i1=0;i1<n;i1++){
			mem[i1].first = 0;
			mem[i1].second = i1+1;
		}

		memset(info,0,sizeof(info));


		for(i1=1;i1<n+1;i1++){
			cin >> m;

			for(i2=0;i2<m;i2++){
				cin >> p;
				info[i1][p]=1;
			}

		}

		cin >> k;
		for(i1=0;i1<k;i1++){
			cin >> p;

			for(i2=1;i2<n+1;i2++){
				if(info[i2][p]==1){
					mem[i2-1].first++;
				}
			}
		}

		sort(mem.begin(), mem.end());

		if(mem[n-1].first!=k || mem[n-1].first==mem[n-2].first) cout << -1 << endl;
		else cout << mem[n-1].second << endl;
	}

	return 0;
} 

Measured memory_bytes: 1252
S = [list(input()) for _ in range(3)]
member = ['a','b','c']
ans = ['A','B','C']
player = 0
cnt = 0

for i in range(len(S)):
    cnt += len(S[i])

for i in range(cnt):
    if len(S[player]) == 0:
        print(ans[player])
        exit()
    player = member.index(S[player].pop(0))

Measured memory_bytes: 3064
// Vicfred
// https://atcoder.jp/contests/abc167/tasks/abc167_d
#include <iostream>
#include <vector>

using namespace std;

int main() {
    const long long int MAXN = 2LL*10e5+5LL;

    long long n, k;
    cin >> n >> k;

    vector<long long> A(MAXN);
    for(long long i = 1LL; i <= n; i++)
        cin >> A[i];

    vector<long long> visited(MAXN);

    long long current = 1LL;
    long long steps = 0LL;
    long long cycle_length = 0LL;

    while(visited[current] == 0LL and steps < k) {
        visited[current] = steps;
        steps += 1LL;
        current = A[current];
        cycle_length = steps-visited[current];
    }

    //cout << "di " << steps << " pasos" << endl;
    //cout << "inicio del ciclo: " << current << endl;

    //cout << "tamaño del ciclo: " << cycle_length << endl;

    //cout << "di " << visited[current] << " pasos" << endl;
    //cout << "inicio del ciclo: " << current << endl;

    int left = (k-visited[current])%cycle_length;

    //cout << "current: " << current << endl;
    //cout << "left: " << left << endl;

    while(left > 0) {
        current = A[current];
        left -= 1;
    }

    cout << current << endl;

    return 0;
}


Measured memory_bytes: 34396
#include<cstdio>
#include<cstring>
#include<iostream>
using namespace std;
int main()
{
	string s;
	cin>>s;
	for(int i=0;i<3;i++)
		if(s[i]=='9')
			cout<<1;
		else
			cout<<9;
	return 0;
}

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

#define MAX 1000000
#define INF 1000000000

int dp1[MAX + 1], dp2[MAX + 1];

int main()
{
    for (int i = 1; i <= MAX; i++)
    {
        dp1[i] = INF;
        dp2[i] = INF;
    }
    for (int n = 1; n * (n + 1) * (n + 2) / 6 <= MAX; n++)
    {
        int a = n * (n + 1) * (n + 2) / 6;
        for (int i = a; i <= MAX; i++)
        {
            dp1[i] = min(dp1[i], dp1[i - a] + 1);
        }
        if (a % 2 == 0)
            continue;
        for (int i = a; i <= MAX; i++)
        {
            dp2[i] = min(dp2[i], dp2[i - a] + 1);
        }
    }
    while (1)
    {
        int n;
        cin >> n;
        if (n == 0)
            break;
        cout << dp1[n] << " " << dp2[n] << endl;
    }
    return 0;
}


Measured memory_bytes: 10796
#include <bits/stdc++.h>
#include <cstdlib>
#define vsort(v) sort(v.begin(), v.end())
#define ll long long
#define rep(i, s, g) for (ll i = (s); i < (g); i++)
#define MOD 1000000007
using namespace std;
using Graph = vector<vector<ll>>;

ll N, X, Y, ans; 

ll dist(ll i, ll j)
{	
	return min(min(abs(j - i), abs(X - i) + 1 + abs(Y - j)), abs(X - j) + 1 + abs(Y - i));
}

int main()
{
  cin >> N >> X >> Y;
  vector<ll> K(N, 0);
  for (ll i = 1; i < N; i++) {
  	for (ll j = i + 1; j <= N; j++) {
    	K[dist(i, j)]++;
    }
  }
  for (ll i = 1; i < N; i++) {
  	cout << K[i] << endl;
  }
}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<map>
using namespace std;

typedef long long ll;
ll H,W,n;

ll dx[9] = {0,0,0,-1,-1,-1,-2,-2,-2};
ll dy[9] = {0,-1,-2,0,-1,-2,0,-1,-2};

int cnt[12];

map<ll, int> m;

int main()
{
    scanf("%d%d%d", &H, &W, &n);
    ll x,y;
    for(int i = 0; i < n; i++) {
        scanf("%lld%lld", &x, &y);
        for(int j = 0; j < 9; j++) {
            if(x + dx[j] <= 0 || x + dx[j] > H - 2) continue;
            if(y + dy[j] <= 0 || y + dy[j] > W - 2) continue;
            ll rec = (x + dx[j]) * W + (y + dy[j]);
            m[rec]++;
        }
    }
    map<ll, int>::iterator s = m.begin();
    map<ll, int>::iterator t = m.end();
    for(; s != t; s++) {
        int n = s -> second;
        cnt[n]++;
    }
    ll zero = (H - 2) * (W - 2);
    for(int i = 1; i < 10; i++) {
        zero -= (ll)cnt[i];
    }
    cout << zero << endl;
    for(int i = 1; i < 10; i++) {
        printf("%d\n", cnt[i]);
    }
}

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

vector<vector<int>> copyArray(vector<vector<int>> src){
  int h = src.size();
  int w = src[0].size();
  vector<vector<int>> target(h, vector<int>(w));
  rep(i, h){
    rep(j, w){
      target[i][j] = src[i][j];
    }
  }
  return target;
}

int main() {
 int h, w, k;
 cin >> h >> w >> k;
 vector<vector<int>> c(h, vector<int> (w));

 // input
 for(int i = 0; i < h; i++){
   string inp;
   cin >> inp;
   for(int j = 0; j < w; j++){
     char target = inp[j];
     if(target == '#'){
       c[i][j] = 1;
     } else {
       c[i][j] = 0;
     }
   }
 }

 int ansCount = 0;
 for (int tmpH = 0; tmpH < (1 << 6); tmpH++) {
  if (tmpH >= (1 << h)) continue;
  bitset<6> s(tmpH);
  for (int tmpW = 0; tmpW < (1 << 6); tmpW++) {
   if (tmpW >= (1 << w)) break;
   bitset<6> t(tmpW);

   // 配列つくる
   vector<vector<int>> target = copyArray(c);

   // 計算: 対象の行と列を白にする
   rep(i, h){
     if(s.test(i)){
       target[i] = vector<int>(w, 0);
     }
   }
   rep(i, w){
     if(t.test(i)){
       rep(j, h){
        target[j][i] = 0;
       }
     }
   }
   // 集計: 黒の数
   int cntBlack = 0;
   rep(i, h){
    rep(j, w){
      if(target[i][j] == 1) cntBlack++;
    }
   }
   // 結果: 黒の数がKと一致するか
   if (cntBlack == k) ansCount++;
   }
 }
 cout << ansCount << endl;
}


Measured memory_bytes: 3576
#![allow(unused_imports)]
use itertools::Itertools;
use proconio::{input, marker::*};
use std::cmp::*;
use std::collections::*;
use superslice::*;

fn main() {
    input! {
        s: String,
    }
    if s == "ABC" {
        println!("ARC");
    } else {
        println!("ABC");
    }
}


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

using namespace std;
#define rep(i, n) for (ll i = 0; i < (n); ++i)
#define sz(x) ll(x.size())
typedef long long ll;
//typedef pair<int, int> P;
typedef pair<ll, ll> P;
//const double INF = 1e10;
const ll INF = 1001001001;
#define mins(x, y) x = min(x, y)
#define maxs(x, y) x = max(x, y)

const int mod = 1e9 + 7;

struct mint {
    ll x; // typedef long long ll;
    mint(ll x = 0) : x((x % mod + mod) % mod) {}

    mint &operator+=(const mint a) {
        if ((x += a.x) >= mod) x -= mod;
        return *this;
    }

    mint &operator-=(const mint a) {
        if ((x += mod - a.x) >= mod) x -= mod;
        return *this;
    }

    mint &operator*=(const mint a) {
        (x *= a.x) %= mod;
        return *this;
    }

    mint operator+(const mint a) const {
        mint res(*this);
        return res += a;
    }

    mint operator-(const mint a) const {
        mint res(*this);
        return res -= a;
    }

    mint operator*(const mint a) const {
        mint res(*this);
        return res *= a;
    }

    mint pow(ll t) const {
        if (!t) return 1;
        mint a = pow(t >> 1);
        a *= a;
        if (t & 1) a *= *this;
        return a;
    }

    // for prime mod
    mint inv() const {
        return pow(mod - 2);
    }

    mint &operator/=(const mint a) {
        return (*this) *= a.inv();
    }

    mint operator/(const mint a) const {
        mint res(*this);
        return res /= a;
    }
};


struct combination {
    vector<mint> fact, ifact;

    combination(int n) : fact(n + 1), ifact(n + 1) {
        assert(n < mod);
        fact[0] = 1;
        for (int i = 1; i <= n; ++i) fact[i] = fact[i - 1] * i;
        ifact[n] = fact[n].inv();
        for (int i = n; i >= 1; --i) ifact[i - 1] = ifact[i] * i;
    }

    mint operator()(int n, int k) {
        if (k < 0 || k > n) return 0;
        return fact[n] * ifact[k] * ifact[n - k];
    }
};

int main() {

    ll n, m, k;
    cin >> n >> m >> k;

//    mint ans=0;
//    for(ll i=0; i<n; i++) {
//        ans+=i*(n-i)*m*m;
//
//    }
//    for(ll i=0; i<m; i++) {
//        ans+=i*(m-i)*n*n;
//
//    }
//
    mint ans = 0;
    for (ll i = 0; i < n; i++) {
        mint a = i;
        a *= (n - i);
        a *= m;
        a *= m;
        ans += a;

    }

    for (ll i = 0; i < m; i++) {
        mint a = i;
        a *= (m - i);
        a *= n;
        a *= n;
        ans += a;
    }
    mint cb = combination(1001001)(n * m - 2, k - 2);
    ans *= cb;

    cout << ans.x << endl;

}

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

int main(){
  long long int n,i,j,kari=0,saidai=10000000000000000;
  cin>>n;
  int a[n];
  for(i=0;i<n;i++){
    cin>>a[i];
  }
  for(j=1;j<=100;j++){
    for(i=0;i<n;i++){
      kari+=(j-a[i])*(j-a[i]);
    }
    saidai=min(saidai,kari);
    kari=0;
  }
  cout<<saidai;
}

Measured memory_bytes: 256
//
//  main.cpp
//
 
#include <algorithm>
#include <array>
#include <assert.h>
#include <functional>
#include <iostream>
#include <iomanip>
#include <limits>
#include <map>
#include <math.h>
#include <memory>
#include <queue>
#include <random>
#include <set>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <string>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <vector>
 
using namespace std;
 
using ll = long long;
using ull = unsigned long long;
 
template<typename T>
vector<T> make_vec_nd(T init, size_t size) {
	return vector<T>(size, init);
}
template<typename T, typename... Args>
auto make_vec_nd(T init, size_t size, Args... rest) {
	auto inner = make_vec_nd(init, rest...);
	return vector<decltype(inner)>(size, inner);
}

#define rep(i,a,b) for(ll i=(a);i<(b);i++)
#define rrep(i,a,b) for(ll i=(a)-1;i>=(b);i--)

int main() {
	ll N;
	cin >> N;
	vector<ll> Ais(N);
	rep(i,0,N) {
		cin >>	Ais[i];
	}
	ll ans = 0;
	rep(i,0,N) {
		ans += Ais[i] / (N+1);
		Ais[i] = Ais[i] % (N+1);
	}
	rep(i,0,N) {
		Ais[i] += ans;
	}
	sort(Ais.rbegin(), Ais.rend());
	ll add = numeric_limits<ll>::max();
	rep(i,0,N) {
		add = min(add, max((ll)0, (Ais[i]-(N-1)) * N) + i);
		// cout << "i: " << i << " Ais[i]: " 
		//	<< Ais[i] << " N: " << N << "add: " << add << endl;
		Ais[i] -= N;
		rep(j,0,N) {
			if (i != j) {
				Ais[j] += 1;
			}
		}
	}
	ans += add;
	cout << ans << endl;
}



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

int main() {

    ll n; cin >> n;

    vector<ll> x(n),y;
    for (ll i = 0; i < n; i++) cin >> x[i];
    y = x;
    sort(y.begin(), y.end());

    int medianLeft = y[n / 2 - 1];
    int medianRight = y[n / 2];

    for (int i = 0; i < n; i++) {
        if (x[i] <= medianLeft) {
            cout << medianRight << endl;
        }
        else {
            cout << medianLeft << endl;
        }
    }

    return 0;
}

Measured memory_bytes: 5376
#include<stdio.h>
#define M 200000
#define N 10000
#define NIL -1
struct Node{
  int p,q,c;
};
struct Node T[M];
int H[M],D[M],n;
int getheight(int);
int getsibling(int);
void getdepth(int,int);
void print(int);
int main(){
  int i,l,r,m,c,key,depth[M],j,degree=0,root;
  scanf("%d",&n);
  for(i=0;i<n;i++){
    T[i].p=NIL;
  }
  for(i=0;i<n;i++){
    scanf("%d%d%d",&m,&l,&r);
    T[m].q=l;
    T[m].c=r;

    if(l!=NIL){
      T[l].p=m;
    }
    if(r != NIL){
      T[r].p=m;
    }
  }
  for(i=0;i<n;i++){
    if(T[i].p==NIL){
      root=i;
      break;
    }
  }
  getdepth(root,0);
  getheight(root);
  for(i=0;i<n;i++){
    print(i);
  }
  return 0;
}



int getheight(int n){
  int h1=0,h2=0;
  if(T[n].q!=NIL){
    h1=getheight(T[n].q)+1;
  }
  if(T[n].c!=NIL){
    h2=getheight(T[n].c)+1;
  }
  return H[n]=(h1>h2?h1:h2);
}

int getsibling(int n){
  if(T[n].p==NIL) return NIL;
  if(T[T[n].p].q!=n && T[T[n].p].q!=NIL){
    return T[T[n].p].q;
  }
  if(T[T[n].p].c!=n && T[T[n].p].c!=NIL){
    return T[T[n].p].c;
  }
  return NIL;
}

void getdepth(int u,int d){
  if(u == NIL)
    return;
  D[u]=d;
  getdepth(T[u].q,d+1);
  getdepth(T[u].c,d+1);
}


void print(int u){
  int deg=0;
  printf("node %d: ",u);
  printf("parent = %d, ",T[u].p);
  printf("sibling = %d, ",getsibling(u));
  if(T[u].q != NIL)
    deg++;
  if(T[u].c != NIL)
    deg++;
  printf("degree = %d, ",deg);
  printf("depth = %d, ",D[u]);
  printf("height = %d, ",H[u]);

  if(T[u].p == NIL)
    printf("root\n");
  else if(T[u].q == NIL && T[u].c == NIL)
    printf("leaf\n");
  else
    printf("internal node\n");
}







Measured memory_bytes: 2048
fun main(args: Array<String>) {
    fun f(n: Int) = if (n % 2 == 0) n / 2 else 3 * n + 1
    val l = mutableListOf(readLine()!!.toInt())
    for (i in 2..1000000) {
        val r = f(l[l.size - 1])
        if (l.contains(r)) {
            println(i)
            break
        } else l.add(r)
    }
}

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

using namespace std;

typedef pair<int, int> ii;

ii BA[200005];

int main(){
	int N;
	scanf("%d", &N);
	
	for(int i = 0; i < N; i ++){
		int A, B;
		scanf("%d%d", &A, &B);
		BA[i] = ii(B, A);
	}
	
	sort(BA, BA+N);
	
	int temp = 0;
	for(int i = 0; i < N; i ++){
		temp += BA[i].second;
		if(temp > BA[i].first){
			printf("No");
			return 0;
		}
	}
	
	printf("Yes");
	return 0;
}


Measured memory_bytes: 1792
#include<bits/stdc++.h>
#define F first
#define S second
#define MP make_pair
#define pb push_back
#define endl '\n'

using namespace std;

typedef long long LL;
typedef pair< int, int > P;
typedef pair< LL, LL > LP;
typedef pair< int, P > iP;
typedef pair< P, P > PP;

static const int INF = INT_MAX;
static const LL LINF = LLONG_MAX;
static const int MIN = INT_MIN;
static const LL LMIN = LLONG_MIN;
static const int MOD = 1000000007;

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

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    
    int n, a, b;
    cin >> n >> a >> b;
    int cnt = 0;
    for( int i = 1; i <= n; ++i ) {
        int tmp = i;
        int sum = 0;
        while( tmp > 0 ) {
            sum += tmp % 10;
            tmp /= 10;
        }
        if( a <= sum && sum <= b ) cnt += i;
    }

    cout << cnt << endl;
    return 0;
}



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

using namespace std;

#define fst(t) std::get<0>(t)
#define snd(t) std::get<1>(t)
#define thd(t) std::get<2>(t)

using P = std::tuple<int,int>;
using ll = long long;

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

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

    int N, A[100];
    std::cin >> N;

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

    int res = 1001001001;
    for(int i=-100;i<101;i++){
        int cost = 0;
        for(int j=0;j<N;++j){
            cost += (A[j] - i) * (A[j] - i);
        }

        res = min(res, cost);
    }

    std::cout << res << std::endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
 
#define pb push_back
#define ll long long
#define maxn 300005
#define fr(i,j,k) for(int i=j;i<k;i++)
#define f(n) fr(i,0,n)
#define f1(n) fr(i,1,n+1)
#define ms(i) memset(i,0,sizeof(i));
#define ms1(i) memset(i,-1,sizeof(i));
#define F first
#define S second
#define all(x) x.begin(), x.end()
const int mod = 1e9+7;

int main(){
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	bitset<4000000>b;
	b.reset();
	b.set(0);
	int n;
	cin >> n;
	int sm = 0;
	f(n) {
		int x;
		cin >> x;
		b |= (b<<x);
		sm += x;
	}
	for (int i = (sm + 1) / 2 ; ;i++) {
		if (b[i]) {
			cout << i << endl;
			break;
		}
	}
}


Measured memory_bytes: 1792
#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 a, b;
    cin >> a >> b;
    cout << a * b << endl;
}

Measured memory_bytes: 3596
n,m=map(int,input().split())
a=list(map(int,input().split()))
a.sort()
bc=[list(map(int,input().split())) for i in range(m)]
bc.sort(key=lambda x:x[1],reverse=True)
d=[]
i=0
while i<m and len(d)<n:
  d+=[bc[i][1]]*bc[i][0]
  i+=1
d=d[:n]
s=sum(a)
ans=s
for x in range(min(n,len(d))):
  s+=d[x]-a[x]
  ans=max(ans,s)
print(ans)

Measured memory_bytes: 34132
#include<bits/stdc++.h>
using namespace std;
#define cp pair<char, char>
string S;
int N, Q;
int ans;
vector<cp> sp;

int main(){
    cin >> N >> Q >> S;
    ans = N;
    for(int i = 0; i < Q; i++){
        char t, d;
        cin >> t >> d;
        sp.push_back({t, d});
    }
    //左に落ちる奴の中で一番右にいるロボットを特定する
    int lb = -1, ub = N;
    while(ub - lb > 1){
        int mid = (ub + lb) / 2;
        //cout << " " << mid << " " << ub << " " << lb << endl;
        int ad = mid;

        bool flag = false;
        for(auto& u : sp){
            if(S[ad] != u.first) continue;
            if(u.second == 'L') ad--;
            else ad++;
            if(ad == -1){
                flag = true;
                break;
            }else if(ad == N){
                break;
            }
        }
        if(flag) lb = mid;
        else ub = mid;
    }
    ans -= lb + 1;

    //右に落ちる奴の中で一番左にいるロボットを特定する
    lb = -1, ub = N;
    while(ub - lb > 1){
        int mid = (ub + lb) / 2;
        int ad = mid;

        bool flag = false;
        for(auto& u : sp){
            if(S[ad] != u.first) continue;
            if(u.second == 'L') ad--;
            else ad++;
            if(ad == N){
                flag = true;
                break;
            }else if(ad == -1){
                break;
            }
        }
        if(flag) ub = mid;
        else lb = mid;
    }
    ans -= N - ub;
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 1152
#include <bits/stdc++.h>
#define rep(i,n) for (int i=0; i<(n); i++)
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

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

int main(){
    int N; cin >> N;
    vector <ll> A(N);
    rep(i,N) cin >> A[i];
    
    
    ll ans=A[0];
    for (int i=1;i<N; i++){
        ans=gcd(ans,A[i]);
    }
    cout << ans << endl;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
#define all(x) (x).begin(),(x).end()
#define pll pair<ll,ll>
#define pii pair<int,int>
#define rep(i,n) for(int i=0;i<n;i++)
#define sz(x) ((ll)(x).size())
#define pb push_back
#define mp make_pair
#define bit(n) (1LL<<(n))
#define F first
#define S second
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};
const ll INF = 1LL<<60;
const ll mod = (int)1e9 + 7;

int main() {
    int n;
    cin >> n;
    string s;
    cin >> s;
    vector<vector<int>> oc(10);
    rep(i,n){
        oc[s[i]-'0'].pb(i);
    }
    rep(i,10){
        oc[i].pb(mod);
    }
    int cnt=0;
    rep(i,10){
        rep(j,10){
            rep(k,10){
                int on=oc[i][0];
              	if(on==mod)continue;
                auto itw=upper_bound(all(oc[j]),on);
                int tw=oc[j][itw-oc[j].begin()];
                if(tw==mod)continue;
                auto ith=upper_bound(all(oc[k]),tw);
                int th=oc[k][ith-oc[k].begin()];
                if(th==mod)continue;
              	//cerr << i << j << k << endl;
                cnt++;
            }
        }
    }
    cout << cnt;


}

/*



 */



Measured memory_bytes: 512
MOD = 10 ** 9 + 7
INF = 10 ** 10
import sys
sys.setrecursionlimit(100000000)

def main():
    N = int(input())
    G = [[] for _ in range(N)]
    dist = []
    for i in range(N):
        route = [int(i) for i in input()]
        for j in range(N):
            if route[j]:
                G[i].append(j)
            elif i != j:
                route[j] = INF
        dist.append(route)
    
    color = [-1]*N
    color[0] = 0
    stack = [0]
    possible = True
    while stack:
        p = stack.pop()
        for e in G[p]:
            if color[e] >= 0:
                if color[e] == color[p]:
                    possible = False
            else:
                color[e] = color[p]^1
                stack.append(e)
        if not possible:
            break
    
    if possible:
        ans = 0
        for k in range(N):
            for i in range(N):
                for j in range(N):
                    dist[i][j] = min(dist[i][j],dist[i][k] + dist[k][j])
        for i in range(N):
            for j in range(N):
                ans = max(ans,dist[i][j])
        print(ans + 1)
    else:
        print(-1)

if __name__ == '__main__':
    main()

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

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

//int dx[]={1,1,1,0,-1,-1,-1,0},dy[8]={1,0,-1,-1,-1,0,1,1,1};
//
constexpr ll gcd(ll a, ll b) { return b ? gcd(b, a%b) : a; }


int main() {
	int n,m;
	cin >> n>>m;
	cout << ((n*m)%2==0?"No":"Yes") << endl;
}


Measured memory_bytes: 256