akhauriyash/Code-Regression huggingface dataset:
import static java.util.Comparator.comparing;

import java.io.InputStream;
import java.io.PrintWriter;
import java.math.BigDecimal;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Objects;
import java.util.PriorityQueue;
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        PrintWriter out = new PrintWriter(System.out);
        Solver solver = new Solver(System.in, out);
        solver.solve();
        out.close();
    }
}
class Solver {
	Scanner sc;
	PrintWriter out;
    public Solver(InputStream in, PrintWriter out) {
    	sc = new Scanner(in);
    	this.out = out;
    }
    // ==========================================================
    Map<PPKEY, Integer> map = new HashMap<>();	// 先頭と末端の組の数を設定する
    // 先頭と末端の数字の組を作る
    PPKEY f(int N) {
    	int a = N % 10;
    	int b = N;
    	while(b >= 10) {
			b /= 10;
		}
//    	out.println("N = " + N + "  a = " + a + "  b = " + b);
    	return new PPKEY(a, b);
    }
    public void solve() {
    	int N = ni();
    	PPKEY wk;
    	for (int i = 1; i <= N; i++) {
			wk = f(i);
			map.merge(wk, 1, Integer::sum);
		}
    	long ans = 0;
    	Integer c;
    	for (int i = 1; i <= N; i++) {
			wk = f(i);
			wk = new PPKEY(wk.val, wk.key);
			c = map.get(wk);
			ans += (c == null ? 0 : c);
    	}
    	out.println(ans);
    }
    final class PPKEY{
    	private final int key, val;
    	public PPKEY(int key, int val) {
    		this.key = key;
    		this.val = val;
    	}
		public int getKey() {
			return key;
		}
		public int getVal() {
			return val;
		}
	    @Override
	    public boolean equals(Object obj) {
	        if (obj instanceof PPKEY) {
	        	PPKEY dest = (PPKEY) obj;
	            return this.key == dest.key && this.val == dest.val;
	        } else {
	            return false;
	        }
	    }
	    @Override
	    public int hashCode() {
	        return Objects.hash(key, val);
	    }
    }
    // ------------------------------------------
    // 入力
    // ------------------------------------------
    public int ni() {
    	return sc.nextInt();
    }
    public long nl() {
    	return sc.nextLong();
    }
    public String ns() {
    	return sc.next();
    }
    public char[] nc() {
    	return sc.next().toCharArray();
    }
    public int[] ndi(int N) {
    	int[] ans = new int[N];
    	for (int i = 0; i < N; i++) {
			ans[i] = ni();
		}
    	return ans;
    }
    public long[] ndl(int N) {
    	long[] ans = new long[N];
    	for (int i = 0; i < N; i++) {
			ans[i] = nl();
		}
    	return ans;
    }
    public String[] nds(int N) {
    	String[] ans = new String[N];
    	for (int i = 0; i < N; i++) {
			ans[i] = ns();
		}
    	return ans;
    }
    public char[][] ndc(int N) {
    	char[][] ans = new char[N][];
    	for (int i = 0; i < N; i++) {
			ans[i] = nc();
		}
    	return ans;
    }
    public int[][] nddi(int N, int S) {
    	int[][] ans = new int[N][S];
    	for (int i = 0; i < N; i++) {
			for (int j = 0; j < S; j++) {
				ans[i][j] = ni();
			}
		}
    	return ans;
    }
}


Measured memory_bytes: 41416
#include <bits/stdc++.h>
#define show(x) std::cerr << #x << " = " << (x) << std::endl
using ll = long long;
template <typename T>
constexpr T MOD = static_cast<T>(1000000007);
template <typename T>
constexpr T INF = std::numeric_limits<T>::max() / 16;
class UnionFind
{
public:
    UnionFind(const std::size_t v) : parent(v), rank(v, 0), size(v, 1) { std::iota(parent.begin(), parent.end(), 0); }
    bool same(const std::size_t a, const std::size_t b) { return find(a) == find(b); }
    void unite(std::size_t a, std::size_t b)
    {
        a = find(a), b = find(b);
        if (a == b) { return; }
        if (rank[a] < rank[b]) { std::swap(a, b); }
        if (rank[a] == rank[b]) { rank[a]++; }
        size[a] += size[b], parent[b] = a;
    }
    std::size_t find(const std::size_t a) { return parent[a] == a ? a : parent[a] = find(parent[a]); }
    std::size_t getSize(const std::size_t a) { return size[find(a)]; }

private:
    std::vector<std::size_t> parent, rank, size;
};
int main()
{
    int N, M;
    std::cin >> N >> M;
    std::vector<ll> X(N);
    for (int i = 0; i < N; i++) { std::cin >> X[i]; }
    std::vector<std::vector<int>> g(N + M);
    UnionFind uf(N);
    int dummy = N;
    std::vector<int> top(N);
    std::vector<ll> w(M + N);
    for (int i = 0; i < N; i++) { top[i] = i; }
    using P = std::pair<int, int>;
    using PP = std::pair<ll, P>;
    std::vector<PP> e(M);
    for (int i = 0; i < M; i++) {
        std::cin >> e[i].second.first >> e[i].second.second >> e[i].first, e[i].second.first--, e[i].second.second--;
    }
    std::sort(e.begin(), e.end());
    for (int i = 0; i < M; i++) {
        int a = e[i].second.first, b = e[i].second.second;
        ll x = e[i].first;
        if (uf.same(a, b)) {
            g[dummy].push_back(top[uf.find(a)]);
            w[dummy] = x;
            top[uf.find(a)] = dummy;
            dummy++;
        } else {
            g[dummy].push_back(top[uf.find(a)]);
            g[dummy].push_back(top[uf.find(b)]);
            uf.unite(a, b);
            top[uf.find(a)] = dummy;
            w[dummy] = x;
            dummy++;
        }
    }
    const int root = dummy - 1;
    std::vector<ll> sub(M + N, 0);
    auto dfs1 = [&](auto&& self, const int s) -> void {
        if (s < N) {
            sub[s] = X[s];
        } else {
            for (const int to : g[s]) {
                self(self, to);
                sub[s] += sub[to];
            }
        }
    };
    dfs1(dfs1, root);
    int ans = 0;
    auto dfs2 = [&](auto&& self, const int s, const ll v) -> void {
        if (w[s] > v) {
            ans++;
            for (const int to : g[s]) {
                self(self, to, sub[to]);
            }
        } else {
            for (const int to : g[s]) {
                self(self, to, v);
            }
        }
    };
    dfs2(dfs2, root, sub[root]);
    std::cout << ans << std::endl;
    return 0;
}

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

long long dp[50][50],b,two,five,ans;

int main(){
  int n;cin>>n;
  while(n--){
    long double a;cin>>a;
    b=(a*1e9)+0.5,two=-9,five=-9;
    while(b%2==0)b/=2,two++;
    while(b%5==0)b/=5,five++;
    for(int i=0;i<50;i++)for(int j=0;j<50;j++)if(i+two>=10&&j+five>=10)ans+=dp[i][j];
    dp[two+10][five+10]++;
  }
  cout<<ans<<endl;
}


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

int main() {
  char c;
  cin >> c;
  if(c == 'a' || c == 'e' || c == 'i' || c == 'o' || c == 'u')
    cout << "vowel" << endl;
  else cout << "consonant" << endl;
}


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

using namespace std;

int main(){
	int N;
    bool flag=false;
  	cin >> N;
  	for(int i=0; i*4<=N; i++){
          for(int j=0; j*7<=N; j++){
              if(i*4==N || j*7==N || i*4 + j*7 == N){
                  flag = true;
              }

        }
    }
    if(flag){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }
    
}

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

int main() {
  string S;
  cin >> S;
  regex R (".*keyence|k.*eyence|ke.*yence|key.*ence|keye.*nce|keyen.*ce|keyenc.*e|keyence.*");
  cout << ((regex_match(S, R)) ? "YES" : "NO") << endl;
}

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

typedef long long ll;

ll hex2dec(string s){
    ll ret = 0;
    for(char c : s) ret = ret*16 + (isdigit(c) ? c-'0' : c-'a'+10);
    return ret;
}

string dec2hex(ll val){
    string ret = "";
    while(val)  ret += (val%16 >= 10 ? val%16-10+'a' : val%16+'0'), val /= 16;
    reverse(ret.begin(), ret.end());
    if(ret == "")   ret = "0";
    return ret;
}

int main(){
    int q;
    cin >> q;
    while(q-- > 0){
        ll u[9];
        for(int i = 0; i < 9; i++){
            string s;   cin >> s;
            u[i] = hex2dec(s);
        }
        ll key = 0, ma = 1ll<<32;
        for(int i = 0; i < 32; i++){
            key += (1ll<<i);
            ll sum = 0;
            for(int j = 0; j < 8; j++)  sum += u[j]^key;
            sum %= ma;
            if(sum%(1ll<<(i+1)) != (u[8]^key)%(1ll<<(i+1)))    key -= (1ll<<i);
        }
        cout << dec2hex(key) << endl;
    }
    return 0;
}


Measured memory_bytes: 3000
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> // Common file
#include <ext/pb_ds/tree_policy.hpp> // Including tree_order_statistics_node_update
using namespace std;
using ll = long long;
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
#define all(c) begin(c), end(c)
#define dump(x) cerr << __LINE__ << ":\t" #x " = " << (x) << endl

using namespace std;
using ll = long long;
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
#define all(c) begin(c), end(c)
#define dump(x) cerr << __LINE__ << ":\t" #x " = " << (x) << endl

int main () {
    int n;
    while (cin >> n) {
        vector<int> a(n);
        rep(i, n) {
            cin >> a[i];
        }
        auto b = a;
        sort(all(b));
        // 1 2 3 4 5 6
        // 1 2 3 3 4 5

        int m1 = b[n / 2 - 1];
        int m2 = b[n / 2];
        rep(i, n) {
            if (a[i] <= m1) {
                cout << m2;
            } else {
                cout << m1;
            }
            cout << ' ';
        }
        cout << endl;
    }
}


Measured memory_bytes: 3712
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include <deque>
#include <set>
using namespace std;

int main()
{
	int N;
	cin >> N;
	long long result = 0;
	for (int i = 1; i <= N; i++) {
		int a = N / i;
		long long b = (long long)i * (a)*(a + 1) / 2;
		result += b;
	}
	printf("%lld%",result);
	return 0;


}

Measured memory_bytes: 3760
import Control.Monad
import Data.List
import Debug.Trace

main :: IO ()
main = do
  [n, c] <- getInts
  ss <- replicateM n $ do
    [s, t, c] <- getInts
    return ((s, t), c)
  print $ solve ss

getInts :: IO [Int]
getInts = map read . words <$> getLine

solve xs = maximum $ go (f xs) []
  where
    f = map fst . sort
      . concatMap (cnct . sort) 
      . groupBy (\(_, c1) (_, c2) -> c1 == c2)
      . sortBy (\(_, c1) (_, c2) -> compare c1 c2)
      where
        cnct [] = []
        cnct [x] = [x]
        cnct (x:y:zs) =
          case (x, y) of
            (((s1, t1), c), ((s2, t2), _))
              | t1 == s2 -> cnct $ ((s1, t2), c) : zs
            _ -> x : cnct (y:zs)
    go [] _ = []
    go ((s, t):ls) qs =
      let qs' =
            t : filter ((>= fromIntegral s  - 0.5) . fromIntegral) qs in
--        trace (show qs')$
      length qs' : go ls qs'


Measured memory_bytes: 107900
#include <iostream>
#include <bits/stdc++.h>
#include <string.h>
#include <cstdlib>
#include <vector>
using namespace std;

int main() {
	string s;
	cin>>s;
	int w;
	cin>>w;
	char c[s.length()];
	strcpy(c,s.c_str());
	for(int j=0;j<s.length();j=j+w){
	    cout<<c[j];
	}
}

Measured memory_bytes: 256
// 10桁でdouble出力するパターン１ 
// printf("%.10f\n", ma);
// 10桁でdouble出力するパターン２
//cout << fixed << setprecision(10);
//  cout << ma << endl;

/*01 02 03 12 13 23　と６回見ていくパターン 
for(int i=0;i<n-1;i++){
  for(int j=i+1;j<n;j++){
    }
  }
*///vector<vector<int>> data(3, vector<int>(4));//int型の2次元配列(3×4要素の)の宣言
//int64_t a;
//10のi乗pow(10, i);
/*string s; stringでの文字列を数字型に変える方法
  cin >> s;
  rep(i,s.size()-2) {
  int a= (s.at(i)-'0')*100 + (s.at(i+1)-'0')*10+ s.at(i+2) -'0';
    */
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
int main() {
  int n;
  cin >> n;
  vector<int>a(n);
  rep(i,n) cin >> a.at(i);
  vector<int>b(100010);
  int ma=0;
  for(int i=0;i<n;i++){
    b.at( a.at(i)  )++;
    b.at( a.at(i) +1 )++;
    b.at( a.at(i) +2 )++;
  }
  for(int i=1;i<=100000;i++){
    ma = max(ma,b.at(i) ) ;
  }
  cout << ma << endl;
}

Measured memory_bytes: 1024
dic = {}
for i in range(3):
  arr = input().split()
  for j in range(3):
    dic[arr[j]] = (i,j)
    
n = int(input())
appear=[[False for _ in range(3)] for __ in range(3)]

for _ in range(n):
  b = input()
  if b in dic:
    i, j = dic[b]
    appear[i][j] = True

ans = 'No'
for i in range(3):
  if appear[i][0] and appear[i][1] and appear[i][2]:
    ans = 'Yes'
    break
  if appear[0][i] and appear[1][i] and appear[2][i]:
    ans = 'Yes'
    break
if appear[0][0] and appear[1][1] and appear[2][2]:
  ans = 'Yes'
if appear[0][2] and appear[1][1] and appear[2][0]:
  ans = 'Yes'
print(ans)


Measured memory_bytes: 3064
#include<iostream>
#include<algorithm>
#include<vector>
#include<string>
#include<set>
#include<queue>
#include<stack>
#include<bitset>
#include<functional>
#include<map>
#include<unordered_set>
using namespace std;
long long p = 998244353;
//long long p = 1000000007;
#define int long long
#define vel vector<long long>
#define vvel vector<vel>
#define rep(i,n) for(int i=0;i<n;i++)
#define sor(v) sort(v.begin(),v.end())
#define mmax(a,b) a=max(a,b)
#define mmin(a,b) a=min(a,b)
#define mkp make_pair
#define pin pair<int,int>
#define qin pair<int,pin>
#define V vector
#define Endl endl
#define veb vector<bool>
#define rev(s) reverse(s.begin(),s.end())
#define lower(h,val) lower_bound(h.begin(),h.end(),val)-h.begin()
#define upper(h,val) upper_bound(h.begin(),h.end(),val)-h.begin()
int max_kai = 150000;
vel kai(max_kai, 1);
vel inv_kai;
int rui(int a, int n) {
	if (n == 0) { return 1; }
	int x = rui(a, n / 2);
	x *= x; x %= p;
	if (n % 2 == 1) { x *= a; x %= p; }
	return x;
}
int inv(int a) { return rui(a, p - 2); }
void make_kai() {
	for (int i = 1; i < max_kai; i++) { kai[i] = kai[i - 1] * i; kai[i] %= p; }
	inv_kai = kai;
	rep(i, max_kai) { inv_kai[i] = inv(kai[i]); }
}
int nCr(int n, int r) {
	int a = kai[n] * inv_kai[r]; a %= p;
	a *= inv_kai[n - r]; a %= p;
	return a;
}
vel pa;
int root(int x) {
	if (pa[x] == -1) { return x; }
	int ans = root(pa[x]); pa[x] = ans;
	return ans;
}
void marge(int x, int y) {
	x = root(x);
	y = root(y);
	if (x != y) {pa[x] = y;}
}

signed main () {
	int n; cin >> n;
	vel a(n), b(n);
	V<pin> c(n);
	rep(i, n) { cin >> a[i]; }
	rep(i, n) { cin >> b[i]; c[i] = mkp(b[i], a[i]); }
	sor(c);
	rep(i, n) { a[i] = c[i].second; b[i] = c[i].first; }
	vel ma = a; sor(ma);
	rep(i, n) { if (ma[i] > b[i]) { cout << "No" << endl; return 0; } }
	vel inv(n, 0);
	rep(i, n) {
		a[i] = lower(b, a[i]);
		inv[a[i]]++;
		if (inv[a[i]] > 1) { cout << "Yes" << endl; return 0; }
	}
	int co = 1;
	int pot = a[0];
	while (pot != 0) { co++; pot = a[pot]; }
	if (co < n) {
		cout << "Yes" << endl;
	}
	else { cout << "No" << endl; }
	return 0;
}

Measured memory_bytes: 6144
n, m, c = map(int, input().split())
b = list(map(int, input().split()))
a = [list(map(int, input().split())) for _ in range(n)]
count = 0
for i in range(n):
    tmp = c
    for j in range(m):
        tmp += a[i][j] * b[j]
    if tmp > 0:
        count += 1
print(count)

Measured memory_bytes: 3060
#include <bits/stdc++.h>
#ifdef JLOCAL
#include "stress.h"
#endif
using namespace std;

#define rep(i, z, n) for (int i = (z); i < int(n); ++i)
#define repr(i, n, z) for (int i = int(n) - 1; i >= (z); --i)
#define shl(n) (1 << (n))
#define hbit(n, i) (((n) >> (i)) & 1)

#define STRESS 1
using lint = long long;

int l[2222];
int r[2222];

void solve(istream& cin, ostream& cout) {
    string a, b;
    cin >> a >> b;
    int n = a.size();
    if (a.find('1') != string::npos && b.find('1') == string::npos) {
        cout << -1;
        return;
    }
    if (a == b) {
        cout << 0;
        return;
    }
    memset(l, 0, sizeof(l));
    memset(r, 0, sizeof(r));
    rep(i, 0, n) {
        int j = i;
        while (b[j] != '1') {
            l[i]++;
            j = (j - 1 + n) % n;
        }
        j = i;
        while (b[j] != '1') {
            r[i]++;
            j = (j + 1) % n;
        }
    }

    int ans = 1e9;

    rep(s, 0, n) {
        int c = 0;
        multiset<pair<int, int> > tl, tr;
        rep(i, 0, n) {
            if (a[i] != b[(i - s + n) % n]) {
                c++;
                tl.insert({l[i], r[i]});
                tr.insert({r[i], l[i]});
            }
        }
        if (c == 0) {
            ans = min(ans, min(s, n - s));
        }
        ans = min(ans, c + n + min(s, n - s));
        while (!tr.empty()) {
            auto x = *tr.begin();
            tl.erase(tl.find({x.second, x.first}));
            tr.erase(tr.begin());
            int t = x.first;
            if (tl.empty()) {
                int v = (s + t) % n;
                ans = min(ans, t + c + min(v, n - v));
            } else {
                t += x.first + tl.rbegin()->first;
                int v = (s - tl.rbegin()->first + n) % n;
                ans = min(ans, t + c + min(v, n - v));
            }
        }
        tl.clear();
        tr.clear();
        rep(i, 0, n) {
            if (a[i] != b[(i - s + n) % n]) {
                tl.insert({l[i], r[i]});
                tr.insert({r[i], l[i]});
            }
        }
        while (!tl.empty()) {
            auto x = *tl.begin();
            tr.erase(tr.find({x.second, x.first}));
            tl.erase(tl.begin());
            int t = x.first;
            if (tr.empty()) {
                int v = (s - t + n) % n;
                ans = min(ans, t + c + min(v, n - v));
            } else {
                t += x.first + tr.rbegin()->first;
                int v = (s + tr.rbegin()->first) % n;
                ans = min(ans, t + c + min(v, n - v));
            }
        }
    }

    cout << ans;
}

int main() {
#if !defined(JLOCAL) || !STRESS
#ifdef JLOCAL
    freopen("input.txt", "r", stdin);
#endif
    ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
    solve(cin, cout);
#else
    srand(151595114);
    for (int ti = 0; ti < 1000; ti++) {
        stress::gen();
        stress::stupid();
        ifstream in("input.txt");
        ofstream out("output.txt");
        solve(in, out);
        out.flush();
        stress::check();
    }
    cout << "ok" << endl;
#endif
    return 0;
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
#include <iostream>
#include <algorithm>
#include <vector>
#include <map>
#include <unordered_map>
#include <set>
using namespace std;
#define pb push_back
#define mp make_pair
#define INF 1e15
#define mod 1000000007
#define eps 1e-6
#define abs(x) ((x)>=0?(x):-(x))
#define y1 solai
#define fi first
#define se second
typedef long long ll;
void read(ll &x)
{
	scanf("%lld",&x);
}
void read(ll &x, ll &y)
{
	scanf("%lld%lld",&x,&y);
}
void read(ll &x, ll &y, ll &z)
{
	scanf("%lld%lld%lld",&x,&y,&z);
}
void print(ll x)
{
	printf("%lld ",x);
}
void println(ll x)
{
	printf("%lld\n",x);
}
const ll N=10000;
ll n,x,s,ans;
map<ll,ll>v;
int main()
{
	cin>>n;
	v[0]=1;
	for(ll i=1;i<=n;i++)
	{
		read(x);
		s+=x;
		ans+=v[s];
		v[s]++;
	}
	cout<<ans;
}

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

def times(n):
  res=0
  while n:
    if n%2==0:
      res+=1
    n//=2
  return res

answer=0
max_d=0
for i in range(1,N+1):
  if times(i)>=max_d:
    max_d=times(i)
    answer=i
  
print(answer)

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

using namespace std;

typedef long long ll;
typedef long double ld;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef vector<vvll> vvvll;
typedef vector<ld> vld;
typedef vector<string> vstr;
typedef pair<ll, ll> pll;
typedef vector<pll> vpll;
typedef priority_queue<ll, vector<ll>, greater<ll>> spqll;  // 小さい順に取り出し
typedef priority_queue<ll, vector<ll>, less<ll>> bpqll;     // 大きい順に取り出し

#define REP(i, n) for (ll i = 0; i < (ll)(n); i++)
#define IREP(i, v) for (auto i = (v).begin(); i != (v).end(); ++i)
#define TS to_string
#define ALL(v) (v).begin(), (v).end()
#define endl "\n"

ll INF = 1e9;
ll MOD = 1000000007;
ll LINF = 1e18;
ld EPS = 1e-9;
ld PI = M_PI;
vll dx = {1, 0, -1, 0, 1, -1, -1, 1};
vll dy = {0, 1, 0, -1, 1, 1, -1, -1};
ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a;} //最大公約数
ll lcm(ll a, ll b) { return a / gcd(a, b) * b;}     //最小公倍数

void yes(){ cout << "Yes" << endl;}
void no(){ cout << "No" << endl;}

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

//-----------------------------------------
int main()
{
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(10);

  ll n;
  cin >> n;
  vll a(n);
  REP(i,n) cin >> a[i];
  ll q;
  cin >> q;
  REP(i,q){
    ll b, e, t;
    cin >> b >> e >> t;
    REP(j,e-b){
      swap(a[b+j],a[t+j]);
    }
  }
  REP(i,n){
    if(i) cout << " ";
    cout << a[i];
  }
  cout << endl;



  return 0;
}




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


int main() {
  int r, D, x;
  cin >> r >> D >> x;
  int X = 0;
  
  for (int i = 0; i < 10; i++) {
    X = r * x - D;
    cout << X << endl;
    x = X;
  }
    
  
  
}



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

int main() {
  
  while (true) {
    
    int H, W; cin >> H >> W;
    
    if (H != 0 && W != 0) {
      
      for (int j = 0; j < W; j++) cout << "#";
      
      cout << endl;
      
      for (int i = 0; i < H - 2; i++) {
        cout << "#";
        for (int j = 0; j < W - 2; j++) cout << ".";
        cout << "#" << endl; 
      }
      
      for (int j = 0; j < W; j++) cout << "#";
      
      cout << endl;
      
    }
    
    else {
      break;
    }
    
    cout << endl;
    
  }
  
}


Measured memory_bytes: 3016
//#pragma GCC optimize ("O3")
//#pragma GCC target ("avx")
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rep1(i, n) for(int i = 1; i <= (n); i++)
#define co(x) cout << (x) << "\n"
#define cosp(x) cout << (x) << " "
#define ce(x) cerr << (x) << "\n"
#define cesp(x) cerr << (x) << " "
#define pb push_back
#define mp make_pair
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
#define Would
#define you
#define please


ll dp[200001][3][2];
int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);


	int N;
	cin >> N;
	int A[200000];
	rep(i, N) cin >> A[i];

	rep(i, N + 1) rep(j, 3) rep(k, 2) dp[i][j][k] = -1e18;
	dp[0][0][0] = 0;
	rep(i, N) {
		int a = A[i];
		chmax(dp[i + 1][1][0], dp[i][0][0]);
		chmax(dp[i + 1][0][1], dp[i][0][0] + a);

		chmax(dp[i + 1][0][0], dp[i][0][1]);

		chmax(dp[i + 1][2][0], dp[i][1][0]);
		chmax(dp[i + 1][1][1], dp[i][1][0] + a);

		chmax(dp[i + 1][1][0], dp[i][1][1]);

		chmax(dp[i + 1][2][1], dp[i][2][0] + a);

		chmax(dp[i + 1][2][0], dp[i][2][1]);
	}

	if (N % 2) {
		ll kotae = dp[N][1][0];
		chmax(kotae, dp[N][2][1]);
		co(kotae);
	}
	else {
		co(max(dp[N][0][0], dp[N][1][1]));
	}

	Would you please return 0;
}

Measured memory_bytes: 13804
N = int(input())
value_list = list(map(int, input().split(" ")))
cost_list = list(map(int, input().split(" ")))

ans = 0

kosupa_list = []
for i in range(N):
    kosupa_list.append(value_list[i] - cost_list[i])
new_list = sorted(kosupa_list, reverse = True)

for j in range(N):
    if new_list[j] <= 0:
        break
    else:
        ans += new_list[j]
print(ans)

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

ans = 0
 
MOD = (10**9+7)
for i in range(62):
    c = 0
    for ai in a:
        if ai&(1<<i): c += 1
    
    r = c*(n-c)
    ans += (1<<i)*r
    ans %= MOD
 
 
print(ans)

Measured memory_bytes: 122808
#include<iostream>
#include<vector>
#include<string>
#include <algorithm>
#include <queue>
#include <climits>
#include<cmath>
#include <sstream>
#include <iomanip>

int main()
{
    int64_t b = 0;
    std::string a;
    int64_t all,current;
    all = 0;
    current = 0;
    std::cin>> a;

    for( int64_t i = 0; i < a.size(); i++ )
    {
        if( a[i] == '<' )
        {
            current += 1;
            all += current;
        }
        else
        {
            int64_t count = 0;
            
            for( int64_t r = i; r < a.size(); r++ )
            {
                if( a[r] == '>' )
                {
                    count += 1;
                }
                else
                {
                    i = r - 1;
                    break;
                }
                
                if( r == a.size() - 1
                    && a[r] == '>' )
                {
                    i = r;
                    break;
                }
            }

            //int64_t check = std::max( current, count );
            //std::cout<< count <<"\n";

            if( current <= count )
            {
                
                all -= current;
                
                for( int64_t r = 1; r <= count; r++ )
                {
                    all += r;
                }

                //std::cout<< all <<"\n";
            }
            else
            {
                for( int64_t r = 1; r <= count - 1; r++ )
                {
                    all += r;
                }
            }

            current = 0;
        }
    }

    std::cout<< all;
}




Measured memory_bytes: 900
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); i++)
#define irep(i, n) for (int i = (n); i >= 0; i++)
using namespace std;
using ll = long long;
using P = pair<int, int>;
const int INF = 1 << 30;
 
int main() {
  ll n, m;
  cin >> n >> m;
  ll ans;
  if (n == 1 && m == 1) ans = 1;
  else if (n == 1) ans = m - 2;
  else if (m == 1) ans = n - 2;
  else ans = (n-2) * (m-2);
  cout << ans << endl; 
  return 0;
}

Measured memory_bytes: 3580
#include <iostream>
#include <string>
#include <vector>
#include <cmath>
#include <unordered_map>
#include <complex>

using namespace std;
using i64 = int_fast64_t;
using u64 = uint_fast64_t;
using i32 = int_fast32_t;
using u32 = uint_fast32_t;

#define int i64

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

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

const int INF = 1LL << 60;
signed main() {
	int n;
	cin >> n;
	vector<int> h(n, 0);
	for(int i = 0; i < n; i++) cin >> h[i];

	vector<int> dp(n, INF);

	dp[0] = 0;
	dp[1] = abs(h[1] - h[0]);
	for(int i = 2; i < n; i++) {
		chmin(dp[i], dp[i - 1] + abs(h[i] - h[i - 1]));
		chmin(dp[i], dp[i - 2] + abs(h[i] - h[i - 2]));
	}

	cout << dp[n - 1] << endl;
	
	return 0;
}


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

int main() {
    /* Input */
    long long int X, K, D;
    cin >> X >> K >> D;
    X = abs(X);

    /* Main Logic */
    long long int straight = min(K, X / D);
    K -= straight;
    X -= straight * D;

    long long int ans = 0;
    if (K % 2 == 0) {
        ans = X;
    } else {
        if(abs(X-D) >= abs(X+D)) X = X + D;
        else if(abs(X-D) <= abs(X+D)) X = X - D;
        ans = X;
    }

    /* Output */
    cout << abs(ans) << endl;
    return 0;
}

Measured memory_bytes: 3628
#include <bits/stdc++.h>
using namespace std;
using Int = long long;
const int MAX = 1000000;
const int MOD = 1000000007;
long long fac[MAX], finv[MAX], inv[MAX];
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; 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() {
    ios::sync_with_stdio(false); cin.tie(nullptr);
    COMinit();
    int X, Y; cin >> X >> Y;
    if ((X + Y) % 3 != 0) {
        cout << 0 << endl;
        return 0;
    }
    int Z = (X + Y) / 3;
    X -= Z, Y -= Z;
    cout << COM(X + Y, X) << endl;
    return 0;
}


Measured memory_bytes: 23680
//minamoto
#include<bits/stdc++.h>
#define R register
#define pb push_back
#define fp(i,a,b) for(R int i=(a),I=(b)+1;i<I;++i)
#define fd(i,a,b) for(R int i=(a),I=(b)-1;i>I;--i)
#define go(u) for(int i=head[u],v=e[i].v;i;i=e[i].nx,v=e[i].v)
template<class T>inline bool cmax(T&a,const T&b){return a<b?a=b,1:0;}
template<class T>inline bool cmin(T&a,const T&b){return a>b?a=b,1:0;}
using namespace std;
const int N=2e5+5;
vector<int>pos[N];int vis[N];
int n,m,k,res,t,mx;
int main(){
	scanf("%d%d%d",&n,&m,&k);
	for(R int i=1,x,y;i<=k;++i)scanf("%d%d",&x,&y),pos[y].pb(x);
	fp(i,1,m)pos[i].pb(n+1),sort(pos[i].begin(),pos[i].end());
	res=pos[1][0]-1,t=0;
	fp(i,2,m){
		mx=0;
		for(auto v:pos[i]){
			if(v<=i+t||vis[v-1])vis[v]=1,cmax(mx,v);
			else{cmin(res,v-1);break;}
		}
		cmax(t,mx-i+1);
	}
	printf("%d\n",res);
	return 0;
}

Measured memory_bytes: 12160
<?php 
    fscanf(STDIN,"%d %d %d %d", $t_hp, $t_attack, $aoki_hp, $aoki_attack);

    $t_count = 0;
    while($aoki_hp > 0){
        $aoki_hp = $aoki_hp - $t_attack;
        $t_count++;
    }

    $aoki_count = 0;
    while($t_hp > 0){
        $t_hp = $t_hp - $aoki_attack;
        $aoki_count++;
    } 

    if($aoki_count >= $t_count){
        echo "Yes";
    } else {
        echo "No";
    }

Measured memory_bytes: 16080
#include <stdio.h>
#include <string.h>

int main(){
char t1[1510];
char t2[1510];
    int n;
    int a=0,b=0;
    int i;
    scanf("%d",&n);
    for(i=0;i<n;i++){
        scanf("%s %s",&t1,&t2);
        if(strcmp(t1,t2)==0) a++,b++;
        if(strcmp(t1,t2)>0) a+=3;
        if(strcmp(t1,t2)<0) b+=3;
    }
    printf("%d %d\n",a,b);
    return 0;
}


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

int main(){

int A, B, C, X;
cin >> A >> B >> C >> X;

int cnt = 0;
for(int a = 0; a <= A; a++){ 
     for(int b = 0; b <= B; b++){ 
          for(int c = 0; c <= C; c++){ 
               if(500 * a + 100 * b + 50 * c == X) cnt++;
          }
     }
}

cout << cnt << endl; 

}

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

using namespace std;

#define MX 35
#define MOD 1'000'000'007
#define F first
#define S second
#define br '\n'

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

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

	int D, n, a;
	cin >> D >> n;
	for(int i=0; i<n; i++)
	{
		cin >> a;
		D -= a;
	}
	if(D < 0)
		D = -1;
	cout << D << endl;

	return 0;
}


Measured memory_bytes: 3648
nums = list(map(int, input().split()))
cases = int(input())


class die:
    face = [0, 0, 0, 0, 0, 0]

    def __init__(self, nums):
        self.face = [nums[f] for f in [0, 3, 1, 2, 4, 5]]

    def roll(self, dirs):

        for di in dirs:
            c_face = list(self.face)
            if di == 'S':
                self.face = [c_face[f] for f in [4, 1, 0, 3, 5, 2]]
            elif di == 'N':
                self.face = [c_face[f] for f in [2, 1, 5, 3, 0, 4]]
            elif di == 'W':
                self.face = [c_face[f] for f in [3, 0, 2, 5, 4, 1]]
            elif di == 'E':
                self.face = [c_face[f] for f in [1, 5, 2, 0, 4, 3]]
            # print(di, self.face)

        return list(self.face)


def four_roll(d, t, f):
    for r in 'SSSS':
        d.roll(r)
        if d.face[0] == t and d.face[2] == f:
            print(d.face[3])
            return True


for _ in range(cases):
    t, f = map(int, input().split())
    for md in (' ', 'W', 'E', 'NW', 'NE', 'WW'):
        d = die(nums)
        d.roll(md)
        four_roll(d, t, f)


Measured memory_bytes: 5608
import           Control.Monad
import           Data.Array.ST
import           Data.Array.Unboxed

main :: IO ()
main = do
  [n,k] <- map read . words <$> getLine :: IO [Int]
  hs <- listArray (1,n) . map read . words <$> getLine :: IO (UArray Int Int)
  print $ solve hs n k ! n

solve :: UArray Int Int -> Int -> Int -> UArray Int Int
solve hs n k = runSTUArray $ do
  dp <- newArray (1,n) 0
  forM_ [1..n] $
    \x -> case x of
      1 -> writeArray dp 1 0
      _ -> minimum <$> forM [(max (x-k) 1)..(x-1)] (\y -> liftM2 (+) (readArray dp y) (return . abs $ hs!x - hs!y)) >>=  writeArray dp x
  return dp


Measured memory_bytes: 30972
#include <bits/stdc++.h>
#define FOR(i, a, b) for(ll i = (a); i < (b); ++i)
#define FORR(i, a, b) for(ll i = (a); i > (b); --i)
#define REP(i, n) for(ll i = 0; i < (n); ++i)
#define REPR(i, n) for(ll i = n; i >= 0; i--)
#define FOREACH(x, a) for(auto &(x) : (a))
#define dump(x) cout << #x << " = " << (x) << endl;
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
using namespace std;
using ll = long long;
using P = pair<ll, ll>;

#define int long long

signed main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int N;
  cin >> N;
  vector<int> A(N);
  REP(i, N) cin >> A[i];
  int ans = 0;
  REP(i, N) {
    while(i + 1 < N && A[i] == A[i + 1])
      ++i;
    if(i + 1 < N && A[i] <= A[i + 1])
      while(i + 1 < N && A[i] <= A[i + 1])
        ++i;
    else if(i + 1 < N && A[i] > A[i + 1])
      while(i + 1 < N && A[i] >= A[i + 1])
        ++i;
    ans++;
  }
  cout << ans << endl;
  return 0;
}

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

bool okay(const vector<int>& A, int K, int m) {
    ll cnt = 0;
    for (int i = 0; i < (int)A.size(); ++i) {
        cnt += (A[i] - 1) / m;
    }
    return cnt <= K;
}

void solve() {
    int N, K;
    cin >> N >> K;
    vector<int> A(N);
    for (int& len : A) cin >> len;

    ll a = 1, b = 1e9 + 1;
    while (a < b) {
        ll m = (a + b) / 2;
        if (okay(A, K, m)) {
            b = m;
        } else {
            a = m + 1;
        }
    } 
    cout << a << "\n";
}

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

    int t = 1;
    while(t--) {
        solve();
    }
}


Measured memory_bytes: 3860
#include <iostream>
#include <cstdio>
#include <vector>
#include <complex>
#include <algorithm>
#include <set>
#include <map>
#include <queue>
#include <string>
#include <cstring>
#include <stack>
#include <cmath>
#include <iomanip>
#include <sstream>
#include <cassert>

using namespace std;

typedef long long ll;
typedef ll li;
typedef pair<int,int> PI;
#define EPS (1e-10L)
#define rep(i,n) for(int i=0;i<(int)(n);++i)
#define F first
#define S second
#define mp(a,b) make_pair(a,b)
#define pb(a) push_back(a)
#define SZ(a) (int)((a).size())
#define ALL(a) a.begin(),a.end()
#define FOR(it,a) for(__typeof(a.begin())it=a.begin();it!=a.end();++it)
void pkuassert(bool t){t=1/t;};

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

string i2s(ll a){
  stringstream ss;
  ss << a;
  return ss.str();
}

ll s2i(string a){
  ll t=0;
  FOR(it,a) t=t*10+*it-'0';
  return t;
}

ll next(ll a){
  string s=i2s(a);
  ll ret=0;
  rep(i,SZ(s)-1) ret=max(ret,s2i(s.substr(i+1))*s2i(s.substr(0,i+1)));
  return ret;
}

void solve(){
  ll n,cnt=0;
  cin >> n;
  while(n>=10){
    ++cnt;
    n=next(n);
  }
  cout << cnt << endl;
}

int main(int argc, char *argv[])
{
  int q;
  cin >> q;
  rep(i,q) solve();
  return 0;
}

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

int main() {
	int x,a,b;
	cin >> x >> a >> b;
	
	int xa,xb;
	
	xa = a - x;
	if (xa < 0){
		xa *= -1;
	}
	
	xb = b - x;
	if (xb < 0){
		xb *= -1;
	}
	
	if(xa <= xb){
		cout << "A" << endl;
	}else{
		cout << "B" << endl;
	}
	
	return 0;
}

Measured memory_bytes: 256
from collections import deque
import sys
input = sys.stdin.readline
h, w = map(int, input().split())
grid = []
graph = [[2000 for i in range(w)] for j in range(h)]
#x,y渡すと、（ｈ、ｗ）に入ってるかどうか判定
def check(s,t):
    if (0 <=  s <= h - 1) and (0 <= t <= w - 1):
        return True
    else:
        return False

#graph => そこまでの距離を保存した二次元配列　grid=>与えられた迷路
def bfs(que):
    finished = set()
    while que:
        x ,y = que.popleft()
        if y*w+x not in finished:
            finished.add(y*w+x)
            for n_x,n_y in [(x+1,y),(x,y+1),(x-1,y),(x,y-1)]:
                if check(n_y,n_x) and graph[n_y][n_x] > graph[y][x] + 1:
                    graph[n_y][n_x] = graph[y][x] + 1
                    que.append((n_x,n_y))
for i in range(h):
    grid.append(list(input()))
que = deque()
for i in range(h):
    for j in range(w):
        if grid[i][j] == "#":
            graph[i][j] = 0
            que.append((j,i))
bfs(que)
ans = 0
for i in range(h):
    ans = max(ans, max(graph[i]))
print(ans)

Measured memory_bytes: 166524
si = lambda: input().strip()
ii = lambda: int(input())
mii = lambda: map(int, input().split())
msi = lambda: map(str, input().split())
lmii = lambda: list(map(int, input().split()))
lmsi = lambda: list(map(str, input().split()))
smii = lambda: sorted(map(int, input().split()))

# ----------


A, B, N = mii()

ans = 0
x = min(N, B)


ans = max(ans, A*x//B - A*(x//B))

if x > 1:
    x -= 1
    ans = max(ans, A*x//B - A*(x//B))

print(ans)

Measured memory_bytes: 9220
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {

	public static void main(String[] args) throws IOException {
		int a = 0;
		int b = 0;
		int d = 0;
		int r = 0;
		double f = 0;

		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String str = br.readLine();
		String[] num = str.split(" ");

		a = Integer.parseInt(num[0]);
		b = Integer.parseInt(num[1]);

		d = a / b;
		r = a % b;
		f = (double) a / (double) b;
		
		String g = String.format("%.5f" , f);

		System.out.print(d);
		System.out.print(" " + r);
		System.out.print(" " + g);
	}
}

Measured memory_bytes: 24656
import java.util.Arrays;
import java.util.Comparator;
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        try (Scanner sc = new Scanner(System.in);) {
            new Main().solve(sc);
        }
    }

    void solve(Scanner sc) {
        int n = sc.nextInt();
        Integer[] ls= new Integer[2*n];
        for (int i = 0; i < 2*n; i++) {
            ls[i] = sc.nextInt();
        }
        Arrays.sort(ls, Comparator.reverseOrder());
        int ans = 0;
        for (int i = 1; i < 2 * n; i += 2) {
            ans += ls[i];
        }
        System.out.println(ans);
    }
}

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

#define maxn 200002
#define FOR(i, l, r) for (int i=l; i<=r; ++i)
#define FORD(i, r, l) for (int i=r; i>=l; --i)
#define REP(i, r) for (int i=0; i<(int)r; ++i)
#define REPD(i, r) for (int i=(int)r-1; i>=0; --i)
#define fi first
#define se second
#define mk make_pair
#define nil NULL
#define y0 __y0
#define y1 __y1
#define x0 __x0
#define x1 __x1
#define next __next
#define sz size
#define Debug(X) {cerr << #X << " = " << X << '\n';}
#define PR(A, n) {cerr << #A << " = "; FOR(i, 1, n) cerr << A[i] << ' '; cerr << '\n';}
#define PR0(A, n) {cerr << #A << " = "; REP(i, n) cerr << A[i] << ' '; cerr << '\n';}
typedef long long ll;
typedef double db;
typedef pair<db, db> dd;
typedef pair<int, int> ii;
typedef vector<int> vi;
const int inf = 1e9;
template<class T> int getbit(T x, int pos) {return (x>>(pos-1)) & 1;}
template<class T> void turn_on(T &x, int pos) {x = x | ((T)1<<(pos-1));}
template<class T> void turn_off(T &x, int pos) {x = x & ~((T)1<<(pos-1));}
template<class T> T sqr(T a) {return a*a;}

int n, m, hist[maxn], a[maxn], cnt, ps[maxn];

void dec(int x) {
    if (x-hist[x]+1>0) {
        cnt += (ps[x-hist[x]+1]==1);
        ps[x-hist[x]+1]--;
    }
    hist[x]--;
}

void inc(int x) {
    if (x-hist[x]>0) {
        cnt -= (ps[x-hist[x]]==0);
        ps[x-hist[x]]++;
    }
    hist[x]++;
}

int main() {
    //freopen("spells.inp", "r", stdin);
    //freopen(".out", "w", stdout);
    //ios::sync_with_stdio(0); cin.tie(0);
    scanf("%d%d", &n, &m);
    FOR(i, 1, n) {
        scanf("%d", &a[i]);
        hist[a[i]]++;
    }
    FOR(i, 1, n) {
        ps[max(1, i-hist[i]+1)]++;
        ps[i+1]--;
    }
    int tmp = 0;
    FOR(i, 1, n) {
        int tmp2 = ps[i];
        ps[i] += tmp;
        tmp += tmp2;
        if (ps[i]==0) ++cnt;
    }
    while (m--) {
        int x, y; scanf("%d%d", &x, &y);
        inc(y);
        dec(a[x]);
        a[x] = y;
        printf("%d\n", cnt);
    }
}


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

int main(){
	
	ll l,r; cin>>l>>r;
	if(r-l>=2019) cout << 0 << endl;
	else{
		int m{2020};
		for(ll i=l; i<r; i++){
			for(ll j=i+1; j<=r; j++){
				m = min<ll>(m,(i*j)%2019);
			}
		}
		cout << m << endl;
	}
	
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <math.h>
#include <algorithm>
#include <cmath>
#include <ios>
#include <ctype.h>
#include <stack>
#include <istream>
#include <stdio.h>
#include <map>
#include <set>
#include <queue>
#include <unordered_map>
#include <functional>
#include <bitset>
#include <list>
#include <deque>
#include <time.h>
#include <random>
#include <iomanip>
#include <fstream>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define REP(i,a,b) for (int i = a; i < (b); ++i)
#define all(x) (x).begin(),(x).end()
#define pint pair<int,int>
const int INF = 1000000007;
const long double EPS = 1e-15;
const long double PI = acos(-1);
typedef long long ll;
using namespace std;
using Graph = vector<vector<int>>;
using Graph_weighted = vector<vector<pair<int,int>>>;
ll gcd(ll a, ll b) { return b ? gcd(b, a%b) : a; }
ll lcm(ll a, ll b) { return (a * b) / gcd(a,b); }
ll ceil(const ll a, const ll b) { return (a + b - 1) / b; }
int main(){
  int n,A,B;
  cin >> n >> A >> B;
  int a = 0,b = 0;
  string s;
  cin >> s;
  rep(i,n){
    if(s[i] == 'a'){
      if(A + B > a + b){
        cout << "Yes" << endl;
        a++;
      }
      else cout << "No" << endl;
    }
    else if(s[i] == 'b'){
      if(A + B > a + b && (b + 1) <= B){
        cout << "Yes" << endl;
        b++;
      }
      else cout << "No" << endl;
    }
    else cout << "No" << endl;
  }
  return 0;
}


Measured memory_bytes: 896
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N;
  cin >> N;
  int num[N];
  for(int i = 0; i<N; i++){
    cin >> num[i]; 
  }
  bool a = true;
  int ans = 0;
  while(a){
    for(int i = 0; i<N; i++){
      if(num[i] % 2 == 1){
        a = false;
        break;
      }
      num[i] /= 2;
    }
    if(a){
      ans++;
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<cmath>
#define maxn 105
#define maxm 14
#define ll long long 
#define uint unsigned int 
#define mo 998244353
using namespace std;

int n,i,j,k,a[maxm][maxn];
ll f[maxm+1][1<<maxm],g[maxm][maxn];
uint s[maxm][maxn];

void prepare(){
	f[0][0]=1;
	for(i=1;i<=maxm;i++) for(int S=0;S<1<<i;S++){
		f[i][S]=f[i-1][S^(S>>i-1<<i-1)]*((S>>i-1&1)+1)%mo;
		for(j=1;j*2<=i;j++){
			int T=S>>i-j;
			for(k=2*j;k<=i;k+=j){
				T&=S>>i-k;
				(f[i][S]+=f[i-k][S^(S>>i-k<<i-k)]*f[j][T])%=mo;
			}
		}
	}
}

ll doit(int d){
	memset(g[d],0,sizeof(ll)*(a[d][0]+1));
	for(int i=1;i<=a[d][0];i++) s[d][i]=s[d][i-1]<<1|a[d][i];
	g[d][0]=1;
	for(int i=1;i<=a[d][0];i++) {
		g[d][i]=g[d][i-1]*(a[d][i]+1)%mo;
		for(int j=1;j*2<=i;j++) if (j<=maxm){
			int T=s[d][i]^(s[d][i-j]<<j);
			for(int k=2*j;k<=i;k+=j){
				T&=s[d][i-k+j]^(s[d][i-k]<<j);
				(g[d][i]+=g[d][i-k]*f[j][T])%=mo;
			}
		} else {
			a[d+1][0]=j;
			for(int k=1;k<=j;k++) a[d+1][k]=a[d][i-j+k];
			for(int k=2*j;k<=i;k+=j){
				for(int l=1;l<=j;l++) a[d+1][l]&=a[d][i-k+l];
				(g[d][i]+=g[d][i-k]*doit(d+1))%=mo;
			}
		}
	}
	return g[d][a[d][0]];
}

int main(){
	prepare();
	char ch=getchar();
	while (ch=='0'||ch=='1') a[0][++a[0][0]]=ch-'0',ch=getchar();
	if (a[0][0]<=maxm){
		k=0;for(i=a[0][0];i>=1;i--) k=(k<<1)|a[0][i];
		printf("%lld\n",f[a[0][0]][k]);
		return 0;
	}
	printf("%lld\n",doit(0));
}

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

typedef long long ll;
typedef pair<ll, ll> pll;

#define m0(x) memset(x, 0, sizeof(x))
#define all(x) x.begin(), x.end()
#define rep(i, n) for(int i = 0; i < (n); i++)
#define asort(x) sort(all(x));
#define dsort(x, t) sort(x.begin(), x.end(), greater<t>());
#define vuni(v) v.erase(unique(v.begin(), v.end()), v.end());
#define mins(m, s) m.insert(make_pair(s, 1));
#define mfin(m, s) m.find(s) != m.end()

#define dump(x)  cout << #x << " = " << (x) << endl
#define YES(n) cout << ((n) ? "YES" : "NO" ) << endl
#define Yes(n) cout << ((n) ? "Yes" : "No" ) << endl

const int INF = 1e9;
const ll LINF = 1e18;
const int mod = 1e9+7;

int main(){
    ll n;
    cin >> n;
    vector<ll> d(n);

    for (ll i = 0; i < n; i++) {
        cin >> d[i];
    }
    asort(d);

    ll diff = d[n / 2] - d[n / 2 - 1];
    cout << diff << endl;
    return 0;
}

Measured memory_bytes: 4036
#include <bits/stdc++.h>
#define rep(i,cc,n) for(int i=cc;i<=n;++i)
#define drep(i,cc,n) for(int i=cc;i>=n;--i)
#define sz(s) (int)(s.size())
#define vecprint(v) rep(i,0,v.size()-1)cout << v[i] << " ";cout << endl;
#define arrprint(v,n) rep(i,0,n-1)cout << v[i] << " ";cout << endl;
#define matprint(v,n,m) rep(i,0,n-1){rep(j,0,m-1){cout << v[i][j] << " ";}cout << endl;}
using namespace std;
const int mod=1000000007;
const int INF=1001001001;
typedef long long ll;
typedef pair<int,int> P;

int main(){
    int n;
    cin >> n;
    map<string,int> mp;
    rep(i,0,n-1){
        string s;
        cin >> s;
        mp[s]++;
    }
    int max_c=0;
    for(auto itr = mp.begin(); itr != mp.end(); ++itr) {
    //first:key, second:value
    // cout << itr->first << " " << itr->second << endl;
    max_c = max(max_c,itr->second);
    }
    vector<string> a;
    for(auto itr = mp.begin(); itr != mp.end(); ++itr) {
    //first:key, second:value
    // cout << itr->first << " " << itr->second << endl;
        if(max_c == itr->second)a.push_back(itr->first);
    }
    sort(a.begin(),a.end());
    rep(i,0,sz(a)-1)cout << a[i] << endl;

    // cout << ans << endl;
//  printf("%.10f\n",ans);

    return 0;
}

Measured memory_bytes: 26868
/*Lucky_Glass*/
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<iostream>
using namespace std;
string card[3];int pos[3];
int main()
{
	for(int i=0;i<3;i++) cin>>card[i];
	int player=0;
	while(true)
	{
		if(pos[player]==card[player].length())
		{
			printf("%c\n",'A'+player);
			return 0;
		}
		int P=card[player][pos[player]++]-'a';
		player=P;
	}
	return 0;
}


Measured memory_bytes: 256
// #include <bits/stdc++.h>
#include<iostream>
#include<stack>
#include<string>
#include<vector>
#include<queue>
#include<map>
#include<algorithm>
#include<iomanip>
#include<set>
#include<bitset>
#include<cmath>
#include<numeric>
#include<limits>
#include<functional>
#include <bitset>

#define REP(i, m, n) for(int i = (m); i < (n); i++)
#define rep(i,n) REP(i,0,n)
#define NIL -1
using namespace std;
typedef long long ll;
typedef long long int lli;
// static const int MOD = 998244353;
// static const int MAX = 100005;
// static const int ls = 101;
// static const int NMAX = 5005;
// static const lli INFTY = 1000000000000;

// typedef priority_queue<int, greater<int>> RevQ;
int n;
string s;
// lli l, r;
// lli gcd(lli a, lli b) {
//   return b ? gcd(b, a%b) : a;
// }



int main(){
  cin >> n;
  cin >> s;
  if (n % 2 == 1) {
    cout << "No" << endl;
  } else {
    int m = n/2;
    int flag = 0;
    rep(i, m) {
      if (s[i] != s[i + m]) flag = 1;
    }
    if (flag) {
      cout << "No" << endl;
    } else {
      cout << "Yes" << endl;
    }
  }
}


Measured memory_bytes: 256