akhauriyash/Code-Regression huggingface dataset:
# 方針〜
# Dが10以下なのがポイント
# 全ての部分集合に対して「この集合を全問解いた場合、総合スコアをG点以上にするために何問解くか」をビット全探索すれば良い。
# Dividing Chocolate (ABC159-E)と似たようなもの

# なお、「この集合を全問解いた場合、総合スコアをG点以上にするために何問解くか」を解くときには
# 得点の高い方からGreedyだが、途中でコンプリートした時のボーナスを無視しても正しい答えは出せる。
# それ自体のスコアは間違いになるが、問題数が増える方向に間違うし、正しい部分集合のときには正しい問題数が得られるので。
# 今回は上記の方法でやってみる。

d, goal = list(map(int, input().split()))
problems = [list(map(int, input().split())) for _ in range(d)]

ans = 10 ** 6 * 10 * 2
for completed in range(2 ** d):
    
    point_all = 0
    num_problem = 0

    # 最下位のdigitが100点問題
    for point in range(d):
        if (completed & 2 ** point) > 0:
            point_all += 100 * (point+1) * problems[point][0]
            point_all += problems[point][1]
            num_problem += problems[point][0]
    
    if point_all < goal:
        for point in reversed(range(d)):
            if (completed & 2 ** point) == 0:
                p = (100 * (point+1))
                n = (goal - point_all + p - 1) // p
                n = min(problems[point][0], n)

                point_all += n * p  # ボーナス点は無視する
                num_problem += n

                if point_all >= goal:
                    break

    # 目標点数を達成しているとは限らないことに注意 条件に目標達成を入れる
    if point_all >= goal and num_problem < ans:
        ans = num_problem

print(ans)


Measured memory_bytes: 9232
#include<bits/stdc++.h>
#define forr(i, a, b) for(int i = (a); i < (b); i++)
#define rep(i,n) for(int i = 0; i < (n); i++)
#define rrep(i,n) for(int i = 1; i <= (n); i++)
#define ALL(a) (a.begin()),(a.end())
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef pair<ll, ll> LP;
const ll LINF = 1LL<<60;
const int INF = 1001001001;
const int MOD = 1000000007;

/* --------------------------------------------------- */

int main() {
    int n;
    cin >> n;
    vector<ll> A(n);
    ll ans = 1;
    rep(i, n) {
        cin >> A[i];
        if(A[i] == 0) ans = 0;
    }
    sort(ALL(A), greater<ll>());
    if(ans == 0) {
        cout << ans << endl;
        return 0;
    }
    rep(i, n) {
        if(ans > 1000000000000000000 / A[i]) {
            ans = -1;
            break;
        }
        ans *= A[i];
    }
    
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 4052
#include <stdio.h>
 
int main(void){
 int i;
 int n, t, a;
 float dif, h, min=550.0;
 int ans;
 
 scanf("%d", &n);
 scanf("%d %d", &t, &a);
 for(i=0; i<n; i++){
  scanf("%f", &h);
  h = (float)t-h*0.006;
  if(a<h){
   dif = h-(float)a;
  }else{
   dif = (float)a-h;
  }
  if(dif <= min){
   ans=i;
   min=dif;
  }
 }
 
 printf("%d", ans+1);
 scanf("%d", &i);
 
 return 0;
}

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

#define ll long long
#define ld long double

#define pii pair<int, int>
#define pci pair<char, int>
#define pcc pair<char, char>

#define vi vector <int>
#define vll vector<long long>
#define vld vector<long double>
#define vb vector<bool>
#define vc vector<char>
#define vs vector<string>

#define vvi vector<vi>
#define vvll vector<vll>
#define vvld vector<vld>
#define vvb vector<vb>
#define vvc vector<vc>
#define vvs vector<vs>

#define vpii vector<pii>
#define vpci vector<pci>
#define vpcc vector<pcc>

#define all(v) (v).begin(), (v).end()
#define allrev(v) (v).rbegin(), (v).rend()
#define allcomp(v) (v).begin(), (v).end(), comp
#define allrevcomp(v) (v).rbegin(), (v).rend(), comp

const int MOD = 1e9 + 7;
const ld pi = 3.1415926535897932384626433832;

#define line cout<<"\n";
#define fast ios_base::sync_with_stdio(false) ; cin.tie(0) ; cout.tie(0);

const int MAX = 1e5;

void solve(int test_case){

    int n;
    cin >> n;
    int sum = 0;

    vi v(n);

    for(int i = 0; i < n; i++){
        cin >> v[i];
        sum ^= v[i];
    }

    for(int i = 0;i < n; i++){
        cout << (sum ^ v[i]) << " ";
    }
}

int main(){
    fast
    int test = 1;
    //cin>>test;
    for(int i = 1; i <= test; i++){
        solve(i);
    }
    return 0;
}


Measured memory_bytes: 3988
S=input()
N=len(S)
O={"R","U","D"}
E={"L","U","D"}
A=1
B=1
for i in range(N):
    if i%2==1:
        if S[i] in E:
            B=B*1
        else:
            B=B*0
    else:
        if S[i] in O:
            A=A*1
        else:
            A=A*0


if A*B==1:
    print("Yes")
else:
    print("No")

Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define mn(a, b) (a < b ? a : b)
#define mx(a, b) (a > b ? a : b)
#define f first
#define s second
#define all(v) (v).begin(), (v).end()
#define base 331

using namespace std;

typedef long long ll;
typedef unsigned long long ull;

int const MAXn = 1e5 + 2;

bool dp[MAXn];
int arr[MAXn];

int main(){

    //freopen(".in","r",stdin);
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    int n, k;
    cin>>n>>k;
    for(int i = 1; i <= n; i++)
        cin>>arr[i];
    sort(arr + 1, arr + n + 1);
    for(int i = 1; i <= k; i++){
        int aux = 1;
        for(int j = 1; j <= n; j++){
            if(arr[j] > i) continue;
            aux &= dp[i - arr[j]];
        }
        dp[i] = !aux;
    }
    if(dp[k])
    cout<<"First";
    else
    cout<<"Second";
    return 0;
}


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

int main() {
	ll k;
	cin >> k;
	int n = 50;
	ll a, b;
	a = k / n;
	b = k % n;
	cout << n << endl;
	for (int i = 0; i < n; i++) {
		cout << n - 1 + a - b + (i < b) * n << ' ';
	}
	cout << endl;
	return 0;
}


Measured memory_bytes: 256
//prince_bundela


#include <iostream>
 
using namespace std;
 
int value[3][101];
int sum[3][101];
 
int main() {
	int n;
	cin >> n;
	for (int i = 1; i <= n; i++) cin >> value[1][i];
	for (int i = 1; i <= n; i++) cin >> value[2][i];
	for (int i = 0; i <= 2; i++) sum[i][0] = 0;
	for (int i = 0; i <= n; i++) sum[0][i] = 0;
	for (int i = 1; i <= 2; i++)
		for (int j = 1; j <= n; j++)
			sum[i][j] = max(sum[i][j - 1], sum[i - 1][j]) + value[i][j];
	cout << sum[2][n] << endl;
}

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

amin=min(a)
amax=max(a)

smin=(amax**2)*n
for y in range(amin,amax+1):
    ssum=0
    for i in range(n):
        ssum=ssum+(a[i]-y)**2
    smin=min(smin,ssum)

print(smin)    


Measured memory_bytes: 3060
#include <bits/stdc++.h>
#define fi first
#define se second
#define m_p make_pair
#define p_b push_back
#define e_b emplace_back
#define all(x) (x).begin(),(x).end()
#define sz(x) ((int)(x).size())
using namespace std;
using ll = long long;
using ld = long double;
template<class T> bool chmax(T &a,T b){if(a<b){a=b;return true;}return false;}
template<class T> bool chmin(T &a,T b){if(a>b){a=b;return true;}return false;}

int main(){
  ios_base::sync_with_stdio(false);cin.tie(0);
  int x,y;
  cin >> x >> y;

  for(int i=0;i<=x;i++){
    int cnt=i*2+(x-i)*4;
    if(cnt==y){
      cout << "Yes" << endl;
      return 0;
    }
  }
  cout << "No" << endl;

  return 0;
}

Measured memory_bytes: 3652
from collections import defaultdict as dd
N = int(input())
s = str(input())
maxlen = N//2

def solve(tgt):
    dic = dd(int)
    st = s[tgt:2*tgt]
    dic[st] += 1
    ls = [st]
    for char in s[2*tgt:]:
        st = st[1:]+char
        dic[st] += 1
        ls.append(st)
    st = s[:tgt]
    if dic[st] > 0:
        return True
    dic[ls[0]] -= 1
    for i,char in enumerate(s[tgt:N-tgt]):
        st = st[1:]+char
        if dic[st] > 0:
            return True
        dic[ls[i+1]] -= 1
    return False

ng = maxlen + 1
ok = 0
while ng-ok > 1:
    tgt = (ok+ng)//2
    if solve(tgt):
        ok = tgt
    else:
        ng = tgt
print(ok)


Measured memory_bytes: 155784
import java.util.*;
public class Main {

	public void doIt(){
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		while(n-- > 0){
			StringBuilder str = new StringBuilder(sc.next());
			int len = str.length();
			TreeSet<String> ts = new TreeSet<String>();
			for(int i=len -2; i >= 0; i--){

				StringBuilder str1 = new StringBuilder(str.substring(0, i+1));
				StringBuilder str2 = new StringBuilder(str.substring(i+1));
				StringBuilder str3 = new StringBuilder(str1.toString());
				StringBuilder str4 = new StringBuilder(str2.toString());
				str3.reverse();
				str4.reverse();
				ts.add(str1.toString() + str2.toString());
				ts.add(str1.toString() + str4.toString());
				ts.add(str3.toString() + str2.toString());
				ts.add(str3.toString() + str4.toString());
				ts.add(str2.toString() + str1.toString());
				ts.add(str2.toString() + str3.toString());
				ts.add(str4.toString() + str1.toString());
				ts.add(str4.toString() + str3.toString());
			}
			System.out.println(ts.size());
		}

	}
	public static void main(String[] args) {
		Main obj = new Main();
		obj.doIt();
	}
}

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

using namespace std;

struct UnionFind {
private:
	vector<long> prisize;//属するグラフの頂点数を返す。参照は根でよい。
public:
	vector<long> par;//親を返す
	UnionFind(long N) : prisize(N), par(N) {
		for (int i = 0; i < N; i++) par[i] = i;//全て根である状態
		for (int i = 0; i < N; i++) prisize[i] = 1;
	}

	long root(long i) {//根を返す
		if (par[i] == i) return i;
		return par[i] = root(par[i]); //根に直接繋ぎなおす
	}

	void unite(long x, long y) {//二つの木の統合(rxをryに繋ぐ)
		long rx = root(x);
		long ry = root(y);

		if (rx == ry) return;
		if (prisize[rx] > prisize[ry]) swap(rx, ry);
		par[rx] = ry;
		prisize[ry] += prisize[rx]; //ここ分解を想定していない & size[rx]は更新されない。
	}

	bool same(long x, long y) { return root(x) == root(y); }//根が等しいか
	long size(long i) { return prisize[root(i)]; }
};

int main() { 
	//逆から走査する(UnionFindなので)
	long N, M; cin >> N >> M;
    
	vector<long> F(M + 1);//崩落後の不便さ
	vector<pair<long, long>> bridge(M);//入力リスト
	F[M] = N * (N - 1) / 2;

	UnionFind tree(N);

	for (int i = 0; i < M; i++) {//入力
		long A, B; cin >> A >> B;
		A--; B--;
		bridge[i] = make_pair(A, B);
	}

	for (int i = M - 1; i >= 0; i--) {
		long A, B; 
		A = bridge[i].first;
		B = bridge[i].second;

		if (tree.same(A, B)) {
			F[i] = F[i + 1];
		}
		else {
			F[i] = F[i + 1] - (tree.size(A) * tree.size(B));
			tree.unite(A, B);
		}
	}

	for (int i = 1; i <= M; i++) cout << F[i] << endl;
}

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

int main()
{
  int n, m, x, y;
  cin >> n >> m >> x >> y;
  vector<int> x_city(n), y_city(m);
  for(auto& i : x_city) cin >> i;
  for(auto& i : y_city) cin >> i;
  
  sort(x_city.begin(), x_city.end(), greater<int>());
  sort(y_city.begin(), y_city.end());
  for(int i = x + 1; i <= y; ++i)
  {
    if(x_city[0] < i && y_city[0] >= i)
    {
      cout << "No War" << endl;
      return 0;
    }
  }
  
  cout << "War" << endl;
}

Measured memory_bytes: 256
#include <iostream>
 
typedef unsigned long long int ull;

int main(void){
	ull N;
  	std::cin >> N;
  
  	ull min;
  	std::cin >> min;
  
  	for(int i = 1; i < 5; ++i){
    	ull tmp;
      	std::cin >> tmp;
      	if(min > tmp) min = tmp; 
    }
  	
  	ull count;
  
  	if(min >= N) count = 5; 
  	
  	count = (N % min == 0) ? N/min + 4 : N/min + 5;
  
  	std::cout << count << std::endl;
  	return 0;
}

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

using namespace std;

int main(){
    #ifdef DEBUG
    freopen("input.txt", "r", stdin);
    #endif
    int n;
    cin >> n;
    int ct = 0;
    int ans = 0;
    for (int i = 0; i < n; i++){
        int p;
        cin >> p;
        p--;
        if (p == i){
            ct++;
        } else {
            ans += (ct + 1) / 2;
            ct = 0;
        }
    }
    ans += (ct + 1) / 2;
    cout << ans;
    return 0;
}


Measured memory_bytes: 384
#include <iostream>
#include <random>
#include <fstream> //iostreamのファイル入出力をサポート
#include <vector>
#include <algorithm>
#include <string>
#include <math.h> 
#include <time.h>
#define FOR(i,k,n) for((i)=(k);(i)<(n);(i)++)
#define rep(i,n) for (int i=0;i<(n);i++)
#define REP(i,n) for (int i=0;i<(n);i++)
#define pb push_back
#define all(a) (a).begin(),(a).end()  //greater<int>()
#define ll long long
#define PII pair<int,int>
#define pii pair<int,int>
#define pcc pair<char,char>
#define pic pair<int,char>
#define pci pair<char,int>
#define VS vector<string>
#define vs vector<string>
#define VI vector<int>
#define vi vector<int>
using namespace std;

int main(){
	string S,s1,s2;
	int i,j,t;

	cin>>S;
	
	FOR(i,1,S.length()-1){
		t=S.length()-i;
		if(t%2==0){
			if(S.substr(0,t/2)==S.substr(t/2,t/2)){
				cout<<S.length()-i<<endl;
				return 0;
			}
		}
	}

   	return 0;
}


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

long long mod = 1e9+7;

int main(){
  int N;
  cin >> N;
  vector<long long> A(N);
  for(int i = 0; i < N; i++)
    cin >> A[i];
  long long ans = 0;
  long long sum = 0;
  long long sum2 = 0;
  
  for(int i = 0; i < N; i++){
    sum2 = (sum2 + A[i]*A[i]) % (2*mod);
    sum = (sum + A[i]) % (2*mod);
  }
  
  ans = (sum*sum - sum2)  % (2*mod) / 2;
  
  cout << ans << endl;
}


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

using namespace std;
typedef long long ll;

const int MOD = 1000000007;
int main() {
  string s;
  cin >> s;
  int sl = s.size();
  vector<vector<ll>> dp(sl + 1, vector<ll>(13, 0));
  dp[0][0] = 1;
  for (int i = 0; i < sl; ++i) {
    for (int j = 0; j < 13; ++j) {
      if (s[i] == '?') {
        for (int k = 0; k < 10; ++k) {
          (dp[i + 1][(j * 10 + k) % 13] += dp[i][j]) %= MOD;
        }
      } else {
        int k = s[i] - '0';
        (dp[i + 1][(j * 10 + k) % 13] += dp[i][j]) %= MOD;
      }
    }
  }
  cout << dp[sl][5] << endl;
  return 0;
}


Measured memory_bytes: 13696
#include<stdio.h>
#include<iostream>
using namespace std;


int N;

int isPrime (int x) {
    for(int i=2; i * i <= x; i++) {
        if(x % i == 0 ) return false;
    }
    return true;
}

int main (){
    cin >> N;
    long long int ans = 1;
    for(int i=2; i<=N; i++) {
        if( isPrime(i) ) {
            int r = 1;
            for(int x=N; x/=i; r+=x);
            ans = ans * r % 1000000007;
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#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>;

ll x = 1e9 + 7; 
const int INF = 1001001001;

struct UnionFind {
  vector<int> d;
  UnionFind(int n): d(n,-1) {}
  int find(int x) {
    if (d[x] < 0) return x;
    return d[x] = find(d[x]);
  }
  bool unite(int x, int y) {
    x = find(x); y = find(y);
    if (x == y) return false;
    if (d[x] > d[y]) swap(x,y);
    d[x] += d[y];
    d[y] = x;
    return true;
  }
  bool same(int x, int y) { return find(x) == find(y);}
  int size(int x) { return -d[find(x)];}
};

int deg[100005];
vector<int> to[100005];


int main() {
  int n, m, k;
  cin >> n >> m >> k;
  UnionFind uf(n);
  rep(i,m) {
    int a, b;
    cin >> a >> b;
    --a; --b;
    deg[a]++;
    deg[b]++;
    uf.unite(a,b);
  }
  rep(i,k) {
    int a, b;
    cin >> a >> b;
    --a; --b;
    to[a].push_back(b);
    to[b].push_back(a);
  }
  rep(i,n) {
    int ans = uf.size(i)-1-deg[i];
    for (int u : to[i]) {
      if (uf.same(i,u)) --ans;
    }
    cout << ans << endl;
  }
  return 0;
}

Measured memory_bytes: 9156
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <sstream>
#include <deque>
#include <complex>
#include <stack>
#include <queue>
#include <cstdio>
#include <cctype>
#include <cstring>
#include <ctime>
#include <iterator>
#include <bitset>
#include <numeric>
#include <list>
#include <iomanip>
#include <cassert>

#if __cplusplus >= 201103L
#include <array>
#include <tuple>
#include <initializer_list>
#include <unordered_set>
#include <unordered_map>
#include <forward_list>

#define cauto const auto&
#define ALL(v) begin(v),end(v)
#else
#define ALL(v) (v).begin(),(v).end()
#endif

using namespace std;


namespace{
typedef long long LL;
typedef pair<int,int> pii;
typedef pair<LL,LL> pll;

typedef vector<int> vint;
typedef vector<vector<int> > vvint;
typedef vector<long long> vll, vLL;
typedef vector<vector<long long> > vvll, vvLL;

#define VV(T) vector<vector< T > >

template <class T>
void initvv(vector<vector<T> > &v, int a, int b, const T &t = T()){
	v.assign(a, vector<T>(b, t));
}
template <class T> inline T &chmin(T &x, const T &y){ return x = min(x, y); }
template <class T> inline T &chmax(T &x, const T &y){ return x = max(x, y); }
template <class F, class T>
void convert(const F &f, T &t){
	stringstream ss;
	ss << f;
	ss >> t;
}


#define REP(i,n) for(int i=0;i<int(n);++i)
#define RALL(v) (v).rbegin(),(v).rend()


#define MOD 1000000007LL
#define EPS 1e-8


void mainmain(){
	int a, b, c;
	cin >> a >> b >> c;
	puts(a == b && b == c ? "Yes" : "No");
}



}
int main() try{
//	ios::sync_with_stdio(false); cin.tie(0);
	cout << fixed << setprecision(10);
	cerr << fixed << setprecision(4);
	mainmain();
}
catch(...){
	throw;
}


Measured memory_bytes: 256
#include<stdio.h>
#define MAX 100005
#define NIL -1
struct Node_struct{int p, l, r;}; /*p: 親(parent), l: 一番左の子(left child), r:右の兄弟(right sibling)*/
typedef struct Node_struct Node;
Node T[MAX];
int D[MAX];

void print(int u){
  int i, c;
  printf("node %d: parent = %d, depth = %d, ", u, T[u].p, D[u]);

  if(T[u].p==NIL/*ここを埋める (fill this blank)*/) printf("root, ");
  else if(T[u].l==NIL/*ここを埋める(fill this blank)*/) printf("leaf, ");
  else printf("internal node, ");
  
  printf("[");
  for (i=0, c = T[u].l; c != NIL; i++, c = T[c].r){
    if(i) printf(", ");
    printf("%d", c);
  }
  printf("]\n");
  
}

void calcDepth(int u, int p){
  D[u] = p;
  if(T[u].r!=NIL/*ここを埋める(fill this blank)*/) calcDepth(T[u].r, p/*ここを埋める(fill this blank)*/);
  if(T[u].l!=NIL/*ここを埋める(fill this blank)*/) calcDepth(T[u].l, p+1/*ここを埋める(fill this blank)*/);
}

int main(){
  int i, j, k;
  int n;
  int id, sib, child;
  int root = NIL;
  scanf("%d", &n);
  for(i=0; i<n; i++) T[i].p = T[i].l = T[i].r = NIL;
  
  for(i=0; i<n; i++){
    scanf("%d %d", &id, &k);
    for(j = 0, sib = NIL; j<k; j++){ //子を入力する (input children)
      scanf("%d", &child);
      T[child].p = id;
      if(j == 0) T[id].l = child; //idの一番左の子 (the most left child of id)
      else T[sib].r = child; //左の兄弟に繋げる (connect to left sibling)
      sib = child;//次の子供の左の兄弟 (the left sibling of the next child)
    }
  }

  //根を求める (find the root)
  for(i=0; i<n; i++){
    if(T[i].p == -1) root = i;
  }
  
  //それぞれのノードの深さを求める (find depth of each node)
  calcDepth(root, 0);

  //出力 (output)
  for(i=0; i<n; i++) print(i);
  
  return 0;
}



Measured memory_bytes: 6380
a,b,c,d = map(int,input())
if a + b + c + d == 7:
    print(str(a)+'+'+str(b)+'+'+str(c)+'+'+str(d)+'='+'7')
elif a + b + c - d == 7:
    print(str(a)+'+'+str(b)+'+'+str(c)+'-'+str(d)+'='+'7')
elif a + b - c - d == 7:
    print(str(a)+'+'+str(b)+'-'+str(c)+'-'+str(d)+'='+'7')
elif a - b - c - d == 7:
    print(str(a)+'-'+str(b)+'-'+str(c)+'-'+str(d)+'='+'7')
elif a  + b - c + d == 7:
    print(str(a)+'+'+str(b)+'-'+str(c)+'+'+str(d)+'='+'7')
elif a - b - c + d == 7:
    print(str(a)+'-'+str(b)+'-'+str(c)+'+'+str(d)+'='+'7')
elif a - b + c + d == 7:
    print(str(a)+'-'+str(b)+'+'+str(c)+'+'+str(d)+'='+'7')
else:
    print(str(a)+'-'+str(b)+'+'+str(c)+'-'+str(d)+'='+'7')
    

Measured memory_bytes: 3064
#include<iomanip>
#include<limits>
#include<thread>
#include<utility>
#include<iostream>
#include<string>
#include<algorithm>
#include<set>
#include<map>
#include<vector>
#include<stack>
#include<queue>
#include<cmath>
#include<numeric>
#include<cassert>
#include<random>
#include<deque>
#include<chrono>
using namespace std;
typedef unsigned long long int ull;
typedef long long int ll;
const ll E=1e17+7;
#define F first
#define S second
#define MK make_pair



int main(){
    vector<int> a;
    for(int i=1;i<=9;i++){
        for(int t=0;t<=9;t++){
            for(int h=0;h<=9;h++){
                int k=0;
                k+=i*10001;
                k+=t*1010;
                k+=h*100;
                a.push_back(k);
            }
        }
    }
    int count=0;
    int s,g;
    cin>>s>>g;
    for(int i=0;i<a.size();i++){
        if(s<=a[i] && a[i]<=g){count++;}
    }
    cout<<count<<endl;
    
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define x first
#define y second
using namespace std;

using i64 = long long;
using f64 = double;
using pll = pair<i64, i64>;
using pii = pair<int, int>;
using ptx = pair<f64, f64>;

map<i64, i64> cmp, cnt;
vector<i64> v, primes;
int n;

static void get_primes() {
    const int LIM = 100000;
    bitset<LIM> s = 0;

    for (int i = 2; i * i < LIM; ++i) {
        if (s[i])
            continue;
        for (int j = i * i; j < LIM; j+= i)
            s[j] = 1;
    }
    for (int i = 2; i < LIM; ++i)
        if (!s[i])
            primes.push_back(i);
}

static i64 get_complement(i64 num) {
    i64 c = 1;
    for (auto p: primes) {
        if (p * p > num) {
            c*= num * num;
            break;
        }
        if (num % (p * p) == 0) {
            c*= p;
            num/= p * p;
        }
        else if (num % p == 0) {
            c*= p * p;
            num/= p;
        }
    }
    return c;
}

int main() {
#ifdef HOME
    freopen("agc003d.in", "r", stdin);
    freopen("agc003d.out", "w", stdout);
#endif
    ios::sync_with_stdio(false);
    cin.tie(0), cout.tie(0);
    get_primes();

    cin >> n;
    v.resize(n);
    for (auto &i: v) {
        cin >> i;
        for (auto p: primes) {
            if (p * p * p > i)
                break;
            while (i % (p * p * p) == 0)
                i/= p * p * p;
        }
        cnt[i]++;
        if (cmp[i] == 0) {
            i64 t = get_complement(i);
            cmp[i] = t;
            cmp[t] = i;
        }
    }

    int ans = 0;
    for (auto i: v) {
        if (i == 1) {
            ans+= min(cnt[i], 1LL);
            cnt[i] = 0;
        }
        else {
            ans+= max(cnt[i], cnt[cmp[i]]);
            cnt[i] = cnt[cmp[i]] = 0;
        }
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 26112
#include <iostream>
#include<map>
using namespace std;
int main(void){
    // Your code here!
    int a,n,q,c,b;
    long long sum=0;
    cin>>n;
    int arr[n];
    map<int , int> m;
    for(int i=0;i<n;i++){
        cin>>a;
        m[a]++;
        sum+=a;
    }   
    cin>>q;
    while(q--){
        cin>>c>>b;
        int diff= b-c;
        int count= m[c];
        sum=sum+count*diff;
        cout<<sum<<endl;
        m.erase(c);
        m[b]=m[b]+count;
    }
}


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

typedef long long ll;

int N;
int a[55], b[55];
set<int> probes[55];
ll tot;

int main() {
	scanf("%d", &N);

	for (int i = 0; i < N; ++i) scanf("%d", a+i);
	for (int i = 0; i < N; ++i) scanf("%d", b+i);

	for (int i = 0; i < N; ++i) {
		if (a[i] < b[i] * 2 + 1 && a[i] ^ b[i]) {
			printf("-1\n");
			return 0;
		}
	}

	for (int i = 0; i < N; ++i) probes[i].insert(a[i]);

	for (;;) {
		int i;
		for (i = 0; i < N; ++i) if (probes[i].find(b[i]) == probes[i].end()) break;
		if (i == N) break;

		int cmx = 0;
		for (i = 0; i < N; ++i) if (probes[i].find(b[i]) == probes[i].end()) {
			int cmn = 2e9;
			for (int x : probes[i]) if (x ^ b[i]) {
				for (int k = 1; k <= 50; ++k) {
					if (x % k >= b[i] * 2 + 1 || x % k == b[i]) {
						cmn = min(cmn, k);
						break;
					}
				}
			}
			cmx = max(cmx, cmn);
		}

		tot += 1ll << cmx;

		for (int i = 0; i < N; ++i) if (probes[i].find(b[i]) == probes[i].end()) {
			set<int> n;
			for (int x : probes[i]) {
				n.insert(x);
				if (x % cmx >= b[i] * 2 + 1 || x % cmx == b[i]) n.insert(x % cmx);
			}

			probes[i].clear();
			for (int x : n) probes[i].insert(x);
		}
	}

	printf("%lld\n", tot);
}

Measured memory_bytes: 256
#define _CRT_SECURE_NO_DEPRECATE
#define rep(i, b, e) for (auto i = b; i < e; ++i)
#include <set>
#include <map>
#include <deque>
#include <queue>
#include <stack>
#include <cmath>
#ifndef __GNUC__
#include <intrin.h>
#endif // !__GNUC__
#include <random>
#include <vector>
#include <cstdio>
#include <string>
#include <cstdlib>
#include <numeric>
#include <cstring>
#include <complex>
#include <cassert>
#include <iostream>
#include <algorithm>
#include <functional>

int bsf(int x) {
#ifdef __GNUC__
    return __builtin_ctz(x);
#else
    unsigned long i;
    _BitScanForward(&i, x);
    return i;
#endif
}
int bsr(int x) {
#ifdef __GNUC__
    return 31 - __builtin_clz(x);
#else
    unsigned long i;
    _BitScanReverse(&i, x);
    return i;
#endif
}

using namespace std;
typedef long long int64;
const double pi = 3.14159265358979323846;
const int inf = (int)2e+9 + 2;
const int mod = (int)1e+9 + 7;
const double eps = 1e-8;
const int N = 100000;

int n, m, k;

void solve()
{
    multiset<int> st;
    cin >> n;
    vector<int> a(n);
    rep(i, 0, n) {
        cin >> a[i];
    }
    sort(a.begin(), a.end());
    cin >> n;
    vector<int> b(n);
    rep(i, 0, n) {
        cin >> b[i];
    }
    sort(b.begin(), b.end());
    int p = 0;
    n = (int)a.size();
    bool ok = true;
    for (auto val : b) {
        while (p < n && a[p] < val)
            ++p;
        if (val != a[p]) {
            ok = false;
        }
        ++p;
    }
    if (ok)
        cout << "YES";
    else
        cout << "NO";
}

int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0), cout.tie(0);
    int test = 1;
    //cin >> test;
    for (; test; --test)
        solve();
    return 0;
}

Measured memory_bytes: 1792
using AtCoderBeginnerContest139.Questions;
using AtCoderBeginnerContest139.Extensions;
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;

namespace AtCoderBeginnerContest139.Questions
{
    public class QuestionD : AtCoderQuestionBase
    {
        public override IEnumerable<object> Solve(TextReader inputStream)
        {
            long n = inputStream.ReadLong();
            yield return n * (n - 1) / 2;
        }
    }
}


namespace AtCoderBeginnerContest139
{
    class Program
    {
        static void Main(string[] args)
        {
            IAtCoderQuestion question = new QuestionD();    // 問題に合わせて書き換え
            var answers = question.Solve(Console.In);
            foreach (var answer in answers)
            {
                Console.WriteLine(answer);
            }
        }
    }
}

#region Base Classes

namespace AtCoderBeginnerContest139.Questions
{

    public interface IAtCoderQuestion
    {
        IEnumerable<object> Solve(string input);
        IEnumerable<object> Solve(TextReader inputStream);
    }

    public abstract class AtCoderQuestionBase : IAtCoderQuestion
    {
        public IEnumerable<object> Solve(string input)
        {
            var stream = new MemoryStream(Encoding.Unicode.GetBytes(input));
            var reader = new StreamReader(stream, Encoding.Unicode);

            return Solve(reader);
        }

        public abstract IEnumerable<object> Solve(TextReader inputStream);
    }

}

#endregion

#region Extensions

namespace AtCoderBeginnerContest139.Extensions
{
    internal static class TextReaderExtensions
    {
        internal static int ReadInt(this TextReader reader) => int.Parse(ReadString(reader));
        internal static long ReadLong(this TextReader reader) => long.Parse(ReadString(reader));
        internal static double ReadDouble(this TextReader reader) => double.Parse(ReadString(reader));
        internal static string ReadString(this TextReader reader) => reader.ReadLine();

        internal static int[] ReadIntArray(this TextReader reader, char separator = ' ') => ReadStringArray(reader, separator).Select(int.Parse).ToArray();
        internal static long[] ReadLongArray(this TextReader reader, char separator = ' ') => ReadStringArray(reader, separator).Select(long.Parse).ToArray();
        internal static double[] ReadDoubleArray(this TextReader reader, char separator = ' ') => ReadStringArray(reader, separator).Select(double.Parse).ToArray();
        internal static string[] ReadStringArray(this TextReader reader, char separator = ' ') => reader.ReadLine().Split(separator);
    }
}

#endregion

Measured memory_bytes: 11092
#include <bits/stdc++.h>
//#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
//#include "boost/multiprecision/cpp_int.hpp"
//typedef boost::multiprecision::cpp_int LL;
typedef long double dd;
#define i_7 (ll)(1E9+7)
//#define i_7 998244353
#define i_5 i_7-2

ll mod(ll a){
    ll c=a%i_7;
    if(c>=0)return c;
    return c+i_7;
}
typedef pair<ll,ll> l_l;
typedef pair<dd,dd> d_d;
ll inf=(ll)1E16;
#define rep(i,l,r) for(ll i=l;i<=r;i++)
#define pb push_back
ll max(ll a,ll b){if(a<b)return b;else return a;}
ll min(ll a,ll b){if(a>b)return b;else return a;}
void Max(ll &pos,ll val){pos=max(pos,val);}//Max(dp[n],dp[n-1]);
void Min(ll &pos,ll val){pos=min(pos,val);}
void Add(ll &pos,ll val){pos=mod(pos+val);}
dd EPS=1E-9;
#define fastio ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define fi first
#define se second
#define endl "\n"
#define SORT(v) sort(v.begin(),v.end())
#define ERASE(v) v.erase(unique(v.begin(),v.end()),v.end())
#define POSL(v,x) (lower_bound(v.begin(),v.end(),x)-v.begin())
#define POSU(v,x) (upper_bound(v.begin(),v.end(),x)-v.begin())
//template<class T>void max(T a,T b){if(a<b)return b;else return a;}
//template<class T>void min(T a,T b){if(a>b)return b;else return a;}
//template<class T>bool Max(T&a, T b){if(a < b){a = b;return 1;}return 0;}
//template<class T>bool Min(T&a, T b){if(a > b){a = b;return 1;}return 0;}

//////////////////////////


int main(){fastio
    ll n,k;cin>>n>>k;
    if(k==0){cout<<1<<endl;return 0;}
    ll a[n];rep(i,0,n-1)cin>>a[i];
    ll dp[n+1][k+1];memset(dp,0,sizeof(dp));
    rep(i,0,k)dp[0][i]=1;
    rep(i,1,n){
        rep(j,0,k){
            dp[i][j]=dp[i-1][j];
            if(j-1-a[i-1]>=0)Add(dp[i][j],-dp[i-1][j-a[i-1]-1]);
        }
        rep(j,1,k)Add(dp[i][j],dp[i][j-1]);
    }
    /*
    rep(i,0,n){
        rep(j,0,k)cout<<dp[i][j]<<" ";cout<<endl;
    }*/
    cout<<mod(dp[n][k]-dp[n][k-1])<<endl;
    return 0;
}



Measured memory_bytes: 79232
#include<iostream>
#include<string>
#include<algorithm>
#include<bits/stdc++.h>

using namespace std;

int main(){
  int N,M,X,Y,a,b;
  cin >> N >> M >> X >> Y;
  int xmax=X,ymin=Y;
  for(int i=0; i<N; i++){
    cin >> a;
    xmax=max(a,xmax);
  }for(int i=0; i<M; i++){
    cin >> b;
    ymin=min(b,ymin);
  }
  if(xmax < ymin) cout << "No War" << endl;
  else cout << "War" << endl;
}

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

// Begin {{{
using namespace std;

#define all(x) x.begin(), x.end()
#define rep(i, n) for (i64 i = 0; i < (n); ++i)
#define reps(i, s, n) for (i64 i = (s); i <= (n); ++i)
#define VAR(Type, ...) Type __VA_ARGS__; IN(__VA_ARGS__)
#define Float(x) OUTN(fixed, setprecision(x));

using i64 = int_fast64_t;
using pii = pair<i64, i64>;

template <class A, class B>
inline bool chmax(A &a, const B &b) { return b > a && (a = b, true); }

template <class A, class B>
inline bool chmin(A &a, const B &b) { return b < a && (a = b, true); }

constexpr int INF = 0x3f3f3f3f;
constexpr i64 LINF = 0x3f3f3f3f3f3f3f3fLL;
constexpr int MOD = int(1e9) + 7;

// IN
void IN() {}
template <class Head, class... Tail>
void IN(Head&& head, Tail&&... tail) {
  cin >> head;
  IN(forward<Tail>(tail)...);
}

// OUTS
void OUTS() {}
template <class Head, class... Tail>
void OUTS(Head&& head, Tail&&... tail) {
  cout << head << " \n"[sizeof...(tail)==0];
  OUTS(forward<Tail>(tail)...);
}

template <class T>
void OUTS(vector<T> &vec) { for (auto &e : vec) cout << e << " \n"[&e==&vec.back()]; }

template <class T>
void OUTS(vector<vector<T>> &df) { for (auto &vec : df) OUTS(vec); }

// OUTL
void OUTL() {}
template <class Head, class... Tail>
void OUTL(Head&& head, Tail&&... tail) {
  cout << head << "\n";
  OUTL(forward<Tail>(tail)...);
}

template <class T>
void OUTL(vector<T> &vec) { for (auto &e : vec) cout << e << "\n"; }

// OUTN
void OUTN() {}
template <class Head, class... Tail>
void OUTN(Head&& head, Tail&&... tail) {
  cout << head;
  OUTN(forward<Tail>(tail)...);
}

template <class T>
void OUTN(vector<T> &vec) { for (auto &e : vec) cout << e; }
// }}} End

vector<bool> isPrime;

void sieve(int MAX) {
  if (MAX + 1 > isPrime.size()) isPrime.resize(MAX + 1, true);
  isPrime[0] = false;
  isPrime[1] = false;
  for (int i = 2; i * i <= MAX; ++i) {
    if (isPrime[i]) {
      for (int j = 2; i * j <= MAX; ++j) isPrime[i*j] = false;
    }
  }
}

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

  sieve(10000010);

  int n;
  while (IN(n), n) {
    for (int i = n; i >= 13; --i) {
      if (isPrime[i] && isPrime[i-2] && isPrime[i-6] && isPrime[i-8]) {
        OUTL(i);
        break;
      }
    }
  }

  return 0;
}



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

int main() {
  int h,w;
  cin>>h>>w;
  int k=0;
  std::vector<string> v(h);
  int a=0;
  for(int i=0;i<h;i++)cin>>v[i];
  int i=0;
  int j=0;
  while(k==0){
    v[i][j]='.';
    if(i<h-1){
      if(j<w-1){
        if(v[i+1][j]=='#'){i++;continue;}
        if(v[i][j+1]=='#'){j++;continue;}
      }
      else{
        if(v[i+1][j]=='#'){i++;continue;}
      }
    }
    else{
      if(v[i][j+1]=='#'){j++;continue;}
    }
    a++;
    if(a>1000)break;
  }
  for(i=0;i<h;i++)for(j=0;j<w;j++)if(v[i][j]=='#')k++;
  if(k)cout<<"Impossible"<<endl;
  else cout<<"Possible"<<endl;
}


Measured memory_bytes: 256
<?php
$S = trim(fgets(STDIN));
$T = trim(fgets(STDIN));
$arr1 = str_split($S);
$arr2 = str_split($T);
$N = strlen($S);
$n = 0;
for ($i = 0; $i < $N; $i++) {
  if ($arr1[$i] != $arr2[$i]) {
      $n++;
  }
}
$ans = $n;
print_r ($ans);
?>

Measured memory_bytes: 41468
n=input()
s=[0]*26
k=[0]*4
for i in range(len(n)):
    #print(ord(n[i]))
    if 65<=ord(n[i])<=90:
        s[ord(n[i])-65]+=1
k[0]=s[2]
k[1]=s[10]
k[2]=s[15]
k[3]=s[20]
print(min(k))


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

int main(void){
    long long H;
    cin >> H;
    long long NumMonster = 1;
    long long res = 0;
    for(;H;H/=2,NumMonster*=2){
        res += NumMonster;
    }
    cout << res << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstring>
#include <string>
#include <vector>
#include <cmath>
#include <map>
#include <queue>
#include <set>
#include <algorithm>
#include <iomanip>
#include <cassert>

using namespace std;

const int mod = 1000000007;

int32_t main(){
    ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);

    long long n, m, w;
    cin >> n;
    for (long long h = 1; h <= 3500; h++)
        for (long long m = 1; m <= 3500; m++)
            if (4 * h * m - m * n - n * h != 0 && (n * h * m) % (4 * h * m - m * n - n * h) == 0){
                w = (n * h * m) / (4 * h * m - m * n - n * h);
                if (w > 0){
                    cout << h << " " << m << " " << w ;
                    return 0;
                }
            }
    #ifdef LOCAL
    cout.flush();
    _Exit(0); //GLIBCXX_DEBUG not working without it
    #endif // local
    return 0;
}



Measured memory_bytes: 256
package main

import "fmt"

func main() {
	var k int
	fmt.Scan(&k)
	even := 0
	odd := 0
	even = k / 2
	if k%2 == 0 {
		odd = k / 2
	} else {
		odd = k/2 + 1
	}
	fmt.Println(even * odd)
}


Measured memory_bytes: 512
import { readFileSync } from "fs";

const read = () =>
  readFileSync(0, "utf8")
    .split("\n")
    .map((line) => line.split(" "));

const main = (input: string[][]) => {
  const N = Number(input[0][0]);
  const S = Number(input[0][1]);
  const A = input[1].map(Number);
  const MOD = 998244353;

  const dp = [...Array(N + 1)].map(() => Array(S + 1).fill(0));
  dp[0][0] = 1;

  for (let i = 0; i < N; i++) {
    for (let j = 0; j <= S; j++) {
      dp[i + 1][j] = (dp[i][j] * 2) % MOD;

      if (j - A[i] >= 0) {
        dp[i + 1][j] += dp[i][j - A[i]];
        dp[i + 1][j] %= MOD;
      }
    }
  }

  return dp[N][S];
};

console.log(main(read()));


Measured memory_bytes: 123336
#include <iostream>
#include <cmath>

using namespace std;

int main(int argc, char* argv[]) {
  int N;
  cin >> N;

  int div_up = ceil(float(N) / 1.08);
  int div_down = floor(float(N) / 1.08);

  if (int(div_up * 1.08) == N)
    cout << div_up << endl;
  else if (int(div_down * 1.08) == N)
    cout << div_down << endl;
  else
    cout << ":(" << endl;

  return 0;
}

Measured memory_bytes: 256
w = input()
w_sep = [i for i in w]
w_unqs = set(w_sep)
num_odd = 0
for w_unq in w_unqs:
    num = w_sep.count(w_unq)
    if num % 2 == 0:
        continue
    else:
        num_odd += 1

if  num_odd > 0:
    print('No')
else:
    print('Yes')


Measured memory_bytes: 2940
#include"bits/stdc++.h"
using namespace std;
typedef long long ll;
ll mx,n,j,x,res,d,y,sm,b,k;
const int N = 1e5 + 5;
vector <ll> v[N],ans(N),v2;
string s;
ll a[N][4];
ll dp[N][2][2][2];
ll go(ll idx , ll s ,ll b , ll c , ll n) {
    if(idx == n +1 ) return 0;
    if(dp[idx][s][b][c] != -1) return dp[idx][s][b][c];
    ll xx = 0 , yy = 0 , zz = 0;

    if( s != 1)
       xx = a[idx][1] + go(idx + 1 ,1 ,0 ,0 ,n);
    else
       xx = max ( a[idx][2] + go(idx + 1 ,0 ,1 ,0 ,n) , a[idx][3] + go(idx + 1 ,0 ,0 ,1 , n) );
    if( b != 1)
       yy = a[idx][2] + go(idx + 1 ,0 ,1 ,0 ,n);
    else
       yy = max (a[idx][1] + go(idx + 1 ,1 ,0 ,0 ,n) , a[idx][3] + go(idx + 1 ,0 ,0 ,1 , n) ) ;
    if( c != 1)
      zz = a[idx][3] + go(idx + 1 ,0 ,0 ,1 , n);
    else
      zz = max (a[idx][2] + go(idx + 1 ,0 ,1 ,0 ,n) , a[idx][1] + go(idx + 1 ,1 ,0 ,0 ,n));

   return dp[idx][s][b][c] =  max ( xx , max( yy , zz));


}
int main()
{
    ios_base::sync_with_stdio(0);cin.tie(NULL);cout.tie(NULL);
    cin >> n  ;
    for( ll i = 1; i <= n; i++) {
        for( j = 1; j <= 3; j++)
        cin >> a[i][j];
    }
    memset(dp, -1, sizeof(dp));
    cout << go( 1 , 0 , 0 , 0, n);

    return 0;
}


Measured memory_bytes: 23680
#include <bits/stdc++.h>
using namespace std;
double a[105];
int main(){
	int n,i;
	double sum=0.0;
	cin>>n;
	for(i=1;i<=n;i++){
		cin>>a[i];
		sum+=1.0/a[i];
	}
	sum=1.0/sum;
	cout<<fixed<<setprecision(10)<<sum;
	return 0;
}

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

main() {
  int A,B,C;
  cin >>A>>B>>C;
  int A2=A;
  vector<bool> B2(B);
  for(int i=0;i<1e5;++i){
    B2[A2%B]=true;
    A2+=A;
  }
  cout<<(B2[C]?"YES":"NO")<<endl;
}


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

ll a,b,c,n,m;
ll ans=100000000000;

string s;

int main() {
	cin.tie(0);
  ios::sync_with_stdio(false);
  
  ll ans;
  rep(i,5){
    ll tmp;
    cin>>tmp;
    if(tmp==0)ans=i+1;
  }
  cout<<ans;

  return 0;
}



Measured memory_bytes: 3604
#include <bits/stdc++.h>
using namespace std;
const int maxn=1e5+100;

int main()
{
    int a,b;
    while(cin>>a>>b)
    {
        int c=max(a,b);
        if(c>8)
            cout<<":("<<endl;
        else
            cout<<"Yay!"<<endl;
    }
    return 0;
}


Measured memory_bytes: 256
import java.io.PrintWriter

fun next() = readLine()!!
fun nextInt() = next().toInt()
fun nextLong() = next().toLong()
fun nextDouble() = next().toDouble()
fun nextList() = next().split(" ")
fun nextIntList() = nextList().map(String::toInt)
fun nextLongList() = nextList().map(String::toLong)
fun nextDoubleList() = nextList().map(String::toDouble)

val pw = PrintWriter(System.out)
fun print(s: Any = "") = pw.print(s)
fun println(s: Any = "") = pw.println(s)

fun main(args: Array<String>) {
    main()
    pw.flush()
}

fun main() {
    val (N, M) = nextIntList()
    if (Math.abs(N - M) > 1) {
        println(0)
        return
    }
    val r = if (N == M) MInt(2) else MInt(1)
    val ans = fastfact(N) * fastfact(M) * r
    println(ans)
}

fun fastfact(N: Int): MInt {
    val ar = (1..N).map(::MInt).toTypedArray()
    var t = 1
    while (t <= N) {
        for (i in 0 until N step t.shl(1)) {
            if (t + i < N) {
                ar[i] = ar[i] * ar[i + t]
            }
        }
        t = t.shl(1)
    }
    return ar[0]
}

class MInt {
    private val MOD = 1000000007L
    var v: Long

    constructor(v: Long) {
        this.v = v % MOD
    }

    constructor(v: Int) {
        this.v = v.toLong() % MOD
    }

    operator fun plus(b: MInt): MInt {
        val a = MInt(v)
        a.v += b.v
        if (a.v >= MOD) a.v -= MOD
        return a
    }

    operator fun plus(b: Int) = plus(MInt(b))
    operator fun plus(b: Long) = plus(MInt(b))

    operator fun minus(b: MInt): MInt {
        val a = MInt(v)
        a.v -= b.v
        if (a.v < 0) a.v += MOD
        return a
    }

    operator fun minus(b: Int) = minus(MInt(b))
    operator fun minus(b: Long) = minus(MInt(b))

    operator fun times(b: MInt): MInt {
        val a = MInt(v)
        a.v *= b.v
        a.v %= MOD
        return a
    }

    operator fun div(b: MInt): MInt {
        return MInt(v) * b.inv()
    }

    fun inv(): MInt {
        var a = v
        var b = MOD
        var u = 1L
        var w = 0L
        while (b != 0L) {
            val t = a / b
            a -= t * b
            u -= t * w
            var tmp = a
            a = b
            b = tmp
            tmp = u
            u = w
            w = tmp
        }
        u %= MOD
        if (u < 0) u += MOD
        return MInt(u)
    }

    fun pow(N: Int) = pow(N.toLong())

    fun pow(N: Long): MInt {
        var ans = MInt(1)
        var a = this
        var n = N
        while (n > 0) {
            if (n.and(1) == 1L) {
                ans *= a
            }
            a *= a
            n = n.shr(1)
        }
        return ans
    }

    override fun toString(): String {
        return v.toString()
    }
}

Measured memory_bytes: 45388
#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<int64_t> a(N+1);
  vector<int64_t> b(N);
  int64_t ans = 0;
  
  rep(i, N+1) cin >> a[i];
  rep(i, N) cin >> b[i];
   
  rep(i, N){
    int64_t lft = min(a[i], b[i]);
    ans += lft;
    a[i] -= lft;
    b[i] -= lft;
    
    int64_t rht = min(a[i+1], b[i]);
    ans += rht;
    a[i+1] -= rht;
    
  }
  cout << ans << endl;

}

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


void solve(std::string S){
    if (S == "ABC") {
        cout << "ARC" << endl;
    } else {
        cout << "ABC" << endl;
    }
}

// Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
int main(){
    std::string S;
    std::cin >> S;
    solve(S);
    return 0;
}


Measured memory_bytes: 3628
#ifndef LOCAL
#pragma GCC optimize("O3")
#include <bits/stdc++.h>
#else
#include <iostream>
#include <iomanip> 
#include <sstream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <memory>
#include <cctype>
#include <cstring>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <algorithm>
#include <numeric>
#include <unordered_map>
#include <unordered_set>
#endif
using namespace std;
#define sim template < class c
#define ris return * this
#define dor > debug & operator <<
#define eni(x) sim > typename enable_if<sizeof dud<c>(0) x 1, debug&>::type operator<<(c i) {
sim > struct rge { c b, e; }; sim > rge<c> range(c i, c j) { return rge<c>{i, j}; } sim > auto dud(c* x) -> decltype(cerr << *x, 0); sim > char dud(...);
struct debug {
#ifdef LOCAL
~debug() { cerr << endl; } eni(!=) cerr << boolalpha << i; ris; } eni(==) ris << range(begin(i), end(i)); } sim, class b dor(pair < b, c > d) { ris << "(" << d.first << ", " << d.second << ")"; } sim dor(rge<c> d) { *this << "["; for (auto it = d.b; it != d.e; ++it) *this << ", " + 2 * (it == d.b) << *it; ris << "]"; }
#else
sim dor(const c&) { ris; }
#endif
};
#define imie(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "

// #include <ext/pb_ds/assoc_container.hpp> 
// #include <ext/pb_ds/tree_policy.hpp> 
// using namespace __gnu_pbds; 
// #define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update> 

template<typename T> void setmax(T& x, T y) {x = max(x, y);}
template<typename T> void setmin(T& x, T y) {x = min(x, y);}
#define fix(a) fixed << setprecision(a)
#define forn(i, n) for (int i = 0; i < int(n); i++)
#define rep(i, a, b) for (int i = int(a); i < int(b); i++)
#define all(V) V.begin(), V.end()
#define rall(V) V.rbegin(), V.rend()
#define len(V) (int)V.size()
#define ll long long
#define ld long double
#define ff first
#define ss second
#define pb push_back
#define mp make_pair
#define endl '\n'


void solve(){
  int n, x;
  cin >> n >> x;
  vector<int>a(n);
  forn(i,n) cin >> a[i];
  sort(all(a));
  int ans = 0;
  forn(i,n){
    if (a[i] <= x){
      x -= a[i];
      ans++;
    }
  }
  if (ans == n and x) ans--;
  cout << ans;
}

int main() {
  ios::sync_with_stdio(false);
  int t = 1;
  // cin >> t;
  forn(i, t){
    solve();
  }
}

/* 

1
322123


n - 1
0 ... (n-1) [res ... res] S - (n-1) ... S


 */

Measured memory_bytes: 256
#include <bits/stdc++.h> 
using namespace std; 
#define ll long long
// function to construct new array 
// from gfg
void constructXOR(ll A[], ll n) 
{ 
    // calculate xor of array 
    ll XOR = 0; 
    for (ll i = 0; i < n; i++) 
        XOR ^= A[i]; 
  
    // update array 
    for (ll i = 0; i < n; i++) 
        A[i] = XOR ^ A[i]; 
} 
  
// Driver code 
int main() 
{    
    ll n,i;
    cin>>n;
    ll arr[n];
    for(i=0; i<n; i++)
        cin>>arr[i];
    constructXOR(arr, n); 
  
    // print result 
    for (i = 0; i < n; i++) 
        cout << arr[i] << " "; 
    return 0; 
} 

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

int descending_compare(const void *a, const void *b){
    if (*(int*)a > *(int*)b){
        return -1;
    }else if (*(int*)a == *(int*)b){
        return 0;
    }else{
        return 1;
    }
}

int ascending_compare(const void *a, const void *b){
    if (*(int*)a < *(int*)b){
        return -1;
    }else if (*(int*)a == *(int*)b){
        return 0;
    }else{
        return 1;
    }
}


int lower_bound(int *a, int n, int key){
    int left, mid, right;
    left = 0, right = n;
    mid = (left + right)/2;
    while ((left+1 != mid || mid+1 != right) && mid != left){
        if (key > a[mid]){
            left = mid;
        }else{
            right = mid+1;
        }
        mid = (left + right)/2;
    }
    if (a[left] >= key)return left;
    if (a[mid] >= key)return mid;
    if (a[right] >= key)return right;
    return n;
}

//greatest common divisor
unsigned long  gcd(unsigned long x, unsigned long y){
    if (y == 0){ 
        return x;
    }else if (x > y){
        return gcd(y, x % y);
    }else{
        return gcd(x, y % x);
    }
}



long long factorial(int x){
    long long rtn = 1;
    int i;
    for (i = x; i > 1; i--){
        rtn = (rtn*i);
    }
    return rtn;
}
int edge[15][15] = {0};
int v[15] = {0};
int cnt = 0;
int n, m;

int dfs(int now){
    int flag = 1;
    for (int i = 1; i <= n; i++){
        if (v[i] != 1){
            flag = 0;
        }
    }
    if (flag == 1){
        cnt++;
        return 0;
    }
    for (int i = 1; i <= n; i++){
        if (edge[now][i] == 1 && v[i] != 1){
            v[i] = 1;
            dfs(i);
            v[i] = 0;
        }
    }
    return 0;
}



int main(void){
    int a, b;
    scanf("%d %d", &n, &m);
    for (int i = 0; i < m; i++){
        scanf("%d %d", &a, &b);
        edge[a][b] = 1;
        edge[b][a] = 1;
    }
    v[1] = 1;
    dfs(1);
    printf("%d\n", cnt);

    return 0;

}


Measured memory_bytes: 128
#include <iostream>

int main()
{
	int n;
	while (std::cin >> n) {
		int num_comb = 0;
		for (int a = 0; a < 10; ++a) {
		for (int b = 0; b < 10; ++b) {
		for (int c = 0; c < 10; ++c) {
		for (int d = 0; d < 10; ++d) {
			if (a + b + c + d == n) {
				++num_comb;
			}
		}}}}
		std::cout << num_comb << std::endl;
	}
	return 0;
}

Measured memory_bytes: 1160