akhauriyash/Code-Regression huggingface dataset:
#include <iostream>                                          
using namespace std;                                         
                                                             
int main() {                                                 
  int a, b, c;                                               
  cin >> a >> b >> c;                                        
  int ans = 0;                                               
  for (int i=a; i<=b; i++) {                                 
    if (c%i==0) {                                            
      ans++;                                                 
    }                                                        
  }                                                          
  cout << ans << endl;                                       
  return 0;                                                  
}               

Measured memory_bytes: 3120
x, y = [int(i) for i in input().split()]

if x == y == 2:
  print("Yes")
elif x in (4, 6, 9, 11) and y in (4, 6, 9, 11):
  print("Yes")
elif x in (1, 3, 5, 7, 8, 10, 12) and y in (1, 3, 5, 7, 8, 10, 12):
  print("Yes")
else:
  print("No")


Measured memory_bytes: 38384
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;

int n, a[100009], b[100009], sum, G, dp[100009]; vector<int>x[100009]; bool used[100009], flag = false;

int solve(vector<int>F) {
	int res = 0;
	for (int i = 0; i < F.size(); i++) res = max(res, F[i] + F[F.size() - 1 - i]);
	return res;
}

int dfs(int pos) {
	if (flag == true) return (1 << 30);
	used[pos] = true;
	vector<int>I;
	for (int i = 0; i < x[pos].size(); i++) {
		if (used[x[pos][i]] == true) continue;
		I.push_back(dfs(x[pos][i]) + 1);
		if (flag == true) return (1 << 30);
	}
	if (I.size() == 0) {
		dp[pos] = 0;
		return 0;
	}
	sort(I.begin(), I.end());
	if (I[I.size() - 1] > G) {
		flag = true;
		return (1 << 30);
	}
	dp[pos] = (1 << 30);
	if (I.size() % 2 == 0) {
		if (solve(I) <= G) {
			dp[pos] = 0;
			return 0;
		}
	}
	if (x[pos].size() % 2 == 1) I.pop_back();
	if (I.size() % 2 == 0) {
		if (solve(I) <= G) {
			dp[pos] = 0;
			return 0;
		}
	}
	if (I.size() % 2 == 1) {
		int L = 0, R = I.size(), M, maxn = (1 << 30);
		for (int i = 0; i < 20; i++) {
			M = (L + R) / 2;
			vector<int>J; for (int j = 0; j < I.size(); j++) { if (j != M) J.push_back(I[j]); }
			int ret = solve(J);
			if (ret <= G) { R = M; maxn = min(maxn, M); }
			else { L = M; }
		}
		if (maxn != (1 << 30)) {
			dp[pos] = min(dp[pos], I[maxn]);
		}
	}
	if (dp[pos] == (1 << 30)) {
		flag = true;
	}
	return dp[pos];
}

int main() {
	cin >> n;
	for (int i = 1; i <= n - 1; i++) {
		cin >> a[i] >> b[i];
		x[a[i]].push_back(b[i]);
		x[b[i]].push_back(a[i]);
	}
	for (int i = 1; i <= n; i++) { if (x[i].size() % 2 == 1) sum++; }
	int L = 1, R = n + 1, M, minx = (1 << 30);
	for (int i = 0; i < 20; i++) {
		M = (L + R) / 2; G = M;
		for (int j = 1; j <= n; j++) used[j] = false; flag = false;
		int F = dfs(1);
		if (F <= M) { R = M; minx = M; }
		else { L = M; }
	}
	cout << sum / 2 << " " << minx << endl;
	return 0;
}

Measured memory_bytes: 25600
#ifndef _GLIBCXX_NO_ASSERT
#include <cassert>
#endif
#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>

#ifdef __GXX_EXPERIMENTAL_CXX0X__
#include <ccomplex>
#include <cfenv>
#include <cinttypes>
#include <cstdbool>
#include <cstdint>
#include <ctgmath>
#include <cwchar>
#include <cwctype>
#endif

#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>

#ifdef __GXX_EXPERIMENTAL_CXX0X__
#include <array>
#include <atomic>
#include <chrono>
#include <condition_variable>
#include <forward_list>
#include <future>
#include <initializer_list>
#include <mutex>
#include <random>
#include <ratio>
#include <regex>
#include <system_error>
#include <thread>
#include <tuple>
#include <typeindex>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>
#endif

using namespace std;

#define MAX 1000

int tax1[MAX] = {};
int tax2[MAX] = {};

int main()
{
	int a, b, c;
	while (cin >> a >> b >> c, a&&b&&c)
	{
		for (size_t i = 0; i < MAX; i++)
		{
			tax1[i] = i*(100 + a) / 100;
			tax2[i] = i*(100 + b) / 100;
		}
		int ans = 0;
		int j = MAX - 1;
		int i = 1;
		while (1)
		{
			if (tax1[i] + tax1[j] == c)
			{
				ans = max(ans, tax2[i] + tax2[j]);
				j--;
				i++;
			} else if (tax1[i] + tax1[j] > c)
			{
				j--;
			} else
			{
				i++;
			}
			if (j==1||j == i-1||i==MAX)break;
		}
		cout << ans << endl;
	}
}

Measured memory_bytes: 1168
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using vb=vector<bool>;
using vvb=vector<vb>;
using vd=vector<double>;
using vvd=vector<vd>;
using vi=vector<int>;
using vvi=vector<vi>;
using vl=vector<ll>;
using vvl=vector<vl>;
using pll=pair<ll,ll>;
using tll=tuple<ll,ll>;
using vs=vector<string>;
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define rep(i,n) range(i,0,n)
#define range(i,a,n) for(ll i=(a);i<(n);i++)
#define LINF ((ll)1ll<<60)
#define INF ((int)1<<30)
#define EPS (1e-9)
#define MOD (1000000007ll)
#define fcout(a) cout<<setprecision(a)<<fixed
#define fs first
#define sc second
#define PI 3.1415926535897932384

int dx[]={1,0,-1,0,1,-1,-1,1},dy[]={0,1,0,-1,1,1,-1,-1};
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;}
template<class S>S sum(vector<S>&a){return accumulate(all(a),S());}

template<class T>void puta(T&&t){cout<<t<<endl;}
template<class H,class...T>void puta(H&&h,T&&...t){cout<<h<<' ';puta(t...);}
template<class S,class T>void tf(bool b,S t,T f){if(b)puta(t);else puta(f);}
void OUT(bool b){tf(b,"YES","NO");}
void Out(bool b){tf(b,"Yes","No");}
void out(bool b){tf(b,"yes","no");}
template<class S,class T>ostream&operator<<(ostream&os,pair<S,T>p){os<<"["<<p.first<<", "<<p.second<<"]";return os;};
template<class S>auto&operator<<(ostream&os,vector<S>t){bool a=1;for(auto s:t){os<<(a?"":" ")<<s;a=0;}return os;}
template<class S>auto&operator>>(istream&is,vector<S>&t){for(S&a:t)cin>>a;return is;}

int popcnt(int x){return __builtin_popcount(x);}
int popcnt(ll x){return __builtin_popcountll(x);}
int bsr(int x){return 31 - __builtin_clz(x);}
int bsr(ll x){return 63 - __builtin_clzll(x);}
int bsf(int x){return __builtin_ctz(x);}
int bsf(ll x){return __builtin_ctzll(x);}

/*他のライブラリを入れる場所*/

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	ll n,k;
	cin>>n>>k;
	vl a(n);
	cin>>a;

	vvl dp(41,vl(2,-1));
	dp[0][0]=0;
	rep(i,40){
		ll mask=1ll<<(39-i);
		ll cnt=0;
		rep(i,n)if(a[i]&mask)cnt++;

		if(dp[i][1]>=0){
			chmax(dp[i+1][1],dp[i][1]+mask*max(cnt,n-cnt));
		}
		if(dp[i][0]>=0){
			if(k&mask){
				chmax(dp[i+1][1],dp[i][0]+mask*cnt);
				chmax(dp[i+1][0],dp[i][0]+mask*(n-cnt));
			}else{
				chmax(dp[i+1][0],dp[i][0]+mask*cnt);
			}
		}
	}
	puta(max(dp[40][0],dp[40][1]));
	return 0;
}

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

talk = []
for i in range(N):
        talk_num = int(input())
        tmp_talk = [list(map(int, input().split())) for j in range(talk_num)]
        talk.append(tmp_talk) 


ans = 0
for i in range(2 ** N):
        tmp = []
        flag = False
        for j in range(N):
                if ((i >> j) & 1):
                        tmp.append(1)
                else:
                        tmp.append(0)
        for k in range(len(tmp)):
                if tmp[k] == 0:
                        continue
                else:
                        for x in talk[k]:
                                #矛盾していないかを確認
                                if x[1] != tmp[x[0] - 1]:
                                        flag = True
                                        break
                if flag:
                        break
        if flag == False:
                ans = max(ans, sum(tmp))             

print(ans)

Measured memory_bytes: 45292
#include<iostream>
#include<algorithm>
using namespace std;
int main(){
	int n;
	cin>>n;
	for(int i=0;i<n;i++){
		int ha,hb,hc;
		cin>>ha>>hb>>hc;
		if(ha>hc){
			swap(ha,hc);
		}if(hb>hc){
		swap(hb,hc);
		}
		if(ha*ha+hb*hb==hc*hc){
			cout<<"YES"<<endl;
		}else
			cout<<"NO"<<endl;
		


	}
}

Measured memory_bytes: 1152
import java.util.*;

public class Main {

  public static void main(String[] args) {
    Scanner scanner = new Scanner(System.in);
    int m1 = scanner.nextInt();
    int d1 = scanner.nextInt();
    int m2 = scanner.nextInt();
    int d2 = scanner.nextInt();

    if(m1 < m2) {
      System.out.println(1);
    } else {
      System.out.println(0);
    }
  }

}

Measured memory_bytes: 22996
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N;
  cin >> N;
  bool l=true;
  vector <int>vec(N);
  for (int X=0; X<N; X++){
    cin >> vec.at(X);
    if (vec.at(X)%2==0){
      if (!(vec.at(X)%3==0) && !(vec.at(X)%5==0)){
        l=false;
      }
    }
  }
  if (l==false){
    cout << "DENIED" << endl;
  }
  else {
    cout << "APPROVED" << endl;
  }
}

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

using namespace std;

bool isLeft(int a, int b){ // b is left side to a
  if(a==9||a==6||a==3)return true;
  else if(a==8||a==2){
    if(b==8||b==2||b==7||b==4||b==1)
      return true;
    return false;
  }else if(a==7||a==4||a==1){
    if(b==7||b==4||b==1)
      return true;
    return false;
  }
  return false;
}

bool isRight(int a, int b){ // b is right side to a
  if(a==7||a==4||a==1)return true;
  else if(a==8||a==2){
    if(b==8||b==2||b==9||b==6||b==3)
      return true;
    return false;
  }else if(a==9||a==6||a==3){
    if(b==9||b==6||b==3)
      return true;
    return false;
  }
  return false;
}

int minimumStep(const vector<int> &t, int st){
  int left=7;
  int right=9;
  int ret=0;
  
  if(st==0){
    left=t.front();
  }else{
    right=t.front();
  }
  
  for(int now=1;now<(int)t.size();++now){
    if(st==0){
      if(isRight(left,t[now])){
	right=t[now];
	st=1;
      }else{
	left=t[now];
	++ret;
      }
    }else{
      if(isLeft(right,t[now])){
	left=t[now];
	st=0;
      }else{
	right=t[now];
	++ret;
      }
    }
  }
  return ret;
}

int main()
{
  while(true){
    string s;
    cin >> s;
    if(s=="#")break;
    
    vector<int> v;
    for(int i = 0; i < (int)s.length(); ++i){
      v.push_back( s[i]-'0' );
    }

    int res = v.size()+1;
    res = min( res, minimumStep(v,0) );
    res = min( res, minimumStep(v,1) );
    cout << res << endl;
   
  }
  return 0;
}

Measured memory_bytes: 1692
#include<bits/stdc++.h>
using namespace std;
#define gc getchar_unlocked
#define fo(i,n) for(i=0;i<n;i++)
#define Fo(i,k,n) for(i=k;k<n?i<n:i>n;k<n?i+=1:i-=1)
#define ll long long
#define si(x)	scanf("%d",&x)
#define sl(x)	scanf("%lld",&x)
#define ss(s)	scanf("%s",s)
#define pi(x)	printf("%d\n",x)
#define pl(x)	printf("%lld\n",x)
#define ps(s)	printf("%s\n",s)
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define deb(x) cout << #x << "=" << x << endl
#define deb2(x, y) cout << #x << "=" << x << "," << #y << "=" << y << endl
#define all(x) x.begin(), x.end()
#define clr(x) memset(x, 0, sizeof(x))
#define sortall(x) sort(all(x))

#define PI 3.1415926535897932384626
typedef pair<int, int>	pii;
typedef vector<int>		vi;
typedef vector<pii>		vpii;
typedef vector<vi>		vvi;
//=======================
const int MOD = 1'000'000'007;
const int N = 2e6+13, M = N;
//=======================
vi g[N];
int a[N];
int n, m, k;
//=======================

int  count_digits(int n) 
{ 
    string num = to_string(n); 
    return num.size() ;
} 
bool solve() {
    int i,j;
    int n;
    cin>>n;
    vpii v;
    int ans=0;
    for(i=0;i<n;i++){
        int t,r;
        cin>>t>>r;
        v.push_back(make_pair(t,r));
    }
    fo(j,n-2){
        if(v[j].F==v[j].S&&v[j+1].F==v[j+1].S&&v[j+2].F==v[j+2].S){return true;}
    }
    return false;

}

int main() {
    ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
    int t = 1;
   // cin >> t;
    while(t--) {
      //solve();
      solve()?  cout << "Yes" : cout << "No "; 
      cout<<endl;
    }

    return 0;
}

Measured memory_bytes: 50532
S=input()

if(S[0]==S[1]==S[2]==S[3]):
    print("No")

elif(S[0]==S[1] and S[2]==S[3]):
    print("Yes")

elif(S[0]==S[2] and S[1]==S[3]):
    print("Yes")

elif(S[0]==S[3] and S[1]==S[2]):
    print("Yes")

else:
    print("No")


Measured memory_bytes: 3060
#include<bits/stdc++.h>
#define se second
#define fi first
#define pb push_back
#define cn cout<<"\n"
#define rep(i,a,b) for(int i = a; i < b; i++)
#define repr(i,a,b) for(int i = a; i >= b; i--)
#define all(v) v.begin(), v.end()
#define allr(v) v.rbegin(), v.rend()

#define _ ios::sync_with_stdio(0); cin.tie(0);

#define vi vector<int>
#define ii pair<int,int>
#define vii vector<ii>
#define ll long long
#define vll vector<ll>
#define flush fflush(stdout)

const int INF = 1e8;
const ll MOD = 1e9 + 7;

using namespace std;

int main(){
	_

	int t = 1;

	string s;
	cin>>s;

	int ans = 0;
	rep(i, 0, s.size()){
		rep(j, i, s.size()){
			int cur = 0;
			rep(r, i, j + 1)
				if(s[r] == 'A' || s[r] == 'T' or  s[r] == 'C' or s[r] == 'G')
					cur++;
			if(cur == (j - i + 1)) ans = max(ans, cur);
		}
	}

	cout<<ans; cn;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#include <math.h>
#include <stdio.h>
#include <vector>
using namespace std;
typedef long long ll;
int main(){
	int a,b;
	cin >> a>>b ;
	cout << max(a + b, max(a * 2 - 1, b * 2 - 1))<< endl;
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> iint;
typedef pair<ll,ll> llll;
#define ALL(x) (x).begin(),(x).end()
const ll zero = 0;
const ll one = 1;
const ll INF = 9223372036854775807; //10^18
const int inINF = 2147483647; //10^9
const ll MOD = 1000000007; //10^9+7
const ll MOD2 = 998244353;
void Yes() {printf("Yes\n");}
void No() {printf("No\n");}
void YES() {printf("YES\n");}
void NO() {printf("NO\n");}

bool f(vector<ll> &F, vector<ll> &A, ll X, ll K, ll N){
    vector<ll> B(N);
    for (ll i = 0; i < N; i++) {
        B[i] = X / F[i];
    }
    ll tmp = 0;
    for (ll i = 0; i < N; i++) {
        tmp += max(A[i] - B[i], zero);
    }
    if(tmp <= K){
        return true;
    }
    else{
        return false;
    }

}

int main(){
    ll N, K;
    cin >> N >> K;
    vector<ll> A(N), F(N);
    for (ll i = 0; i < N; i++) {
        cin >> A[i];
    }
    for (ll i = 0; i < N; i++) {
        cin >> F[i];
    }
    sort(ALL(A), greater<ll> ());
    sort(ALL(F));

    ll ng = -1;
    ll ok = 100000000000000;
    while(ng + 1 < ok){
        ll mid = (ok + ng) / 2;
        if(f(F, A, mid, K, N)){
            ok = mid;
        }
        else{
            ng = mid;
        }
    }
    printf("%lld\n", ok);

}

Measured memory_bytes: 7988
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <map>
#include <cmath>
#include <queue>
#include <set>
#include <stack>
#include <numeric>




typedef long long ll;
#define PI 3.14159265359
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define mp make_pair
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(),v.rend()
#define decp(n) cout<<fixed<<setprecision((int)n)
#define _GLIBCXX_DEBAC
#include <functional>
/*map<Keyの型, Valueの型> 変数名;
queue<型> 変数名;
priority_queue<型> 変数名;
priority_queue<型, vector<型>, greater<型>> 変数名;*/
//copy(v1.begin(), v1.end(), back_inserter(v2));
using namespace std;

ll gcd(ll a, ll b) {
	ll c;
	if (a < b) {
		c = a; a = b; b = c;
	}
	while (b != 0) {
		c = a % b; a = b; b = c;
	}
	return a;
}

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

int sort_greater(int m, int n) {
	vector<int> a(m);
	for (int i = 0; i < m; i++) {
		cin >> a[i];
	}
	sort(a.begin(), a.end(), greater<int>());
	for (int i = 0; i < n; i++) {
		cout << a[i];
	}
	return 0;
}

int bubblesort(int a[], int n) {
	int sw = 0;
	bool flag = 1;
	for (int i = 0; flag; i++) {
		flag = 0;
		for (int j = n - 1; j >= i + 1; j--) {
			if (a[j] < a[j - 1]) {
				swap(a[j], a[j - 1]);
				flag = 1;
				sw += 1;
			}
		}
	}
	return sw;
}

int a_z()
{
	for (int i = 0; i <= ('Z' - 'A'); i++) {
		cout << (char)('A' + i);
	}
	return 0;
}

int selecttionsort(int a[], int n) {
	int t, sw = 0, minj;
	for (int i = 0; i < n - 1; i++) {
		minj = i;
		for (int j = 0; j < n - 1; j++) {
			if (a[j] < a[minj]) {
				minj = j;
			}
		}
		t = a[i]; a[i] = a[minj]; a[minj] = t;
		if (i != minj) sw += 1;

	}
	return sw;
}

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

const ll mod = 1000000007;


map<string, int> memo;

using P=pair<int, int>;




/*void dfs(int v, int p = -1) {
	for (int u : to[v]) {
		if (u == p) continue;
		ans[u] += ans[v];
		dfs(u, v);
	}
}*/
ll findIndex(int value, vector<ll> a)
{

	for (ll i = 0; i < (ll)a.size(); i++) {
		if (a[i] == value) {
			return i;
		}
	}
	return -1;
}
ll nCr(ll n, ll r) {
	ll a = 1;
	for (ll i = n; i > n - r; --i) {
		a = a * i;
	}
	for (ll i = 1; i < r + 1; ++i) {
		a = a / i;
	}
	return a;
}

void comb(vector<vector <long long int> >& v) {
	for (ll i = 0; i < v.size(); i++) {
		v[i][0] = 1;
		v[i][i] = 1;
	}
	for (ll k = 1; k < v.size(); k++) {
		for (ll j = 1; j < k; j++) {
			v[k][j] = (v[k - 1][j - 1] + v[k - 1][j]);
		}
	}
}



int main() {
	int n,k;
	cin >> n>>k;
	int ans = 0;
	vector<int> cnt(n+1);
	rep(i, k) {
		int d; cin >> d;
		vector<int> a(d);
		rep(j, d)cin >> a[j];
		rep(j, d)cnt[a[j]-1]++;
	}
	rep(i, n) {
		if (cnt[i] == 0)ans++;
	}
	cout << ans;
	return 0;
}













Measured memory_bytes: 3632
#include <bits/stdc++.h>
using namespace std;
int main(){
long int n;
  cin >> n;
  long int a[n],k=1;
  long int ans=0;
  for(int i=0;i<n;i++){
  cin >> a[i];
   ans+=a[i]-1; 
 }
  cout << ans << endl;
}

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

int main() {
    int n, m;
    cin >> n >> m;
    vector<int> a(n);
    map<int, int, greater<int>> dict;
    rep(i, n){
        cin >> a[i];
        dict[a[i]] += 1;
    }
    rep(i, m){
        int b, c;
        cin >> b >> c;
        dict[c] += b;
    }
    ll ans = 0;
    ll count = n;
    for(auto x : dict){
        ll key = x.first;
        ll value = x.second;
        if (count < value) value = count;
        ans += key*value;
        count -= value;
        if (count == 0)break;
    };
    cout << ans << endl;
}

Measured memory_bytes: 12848
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef pair<ll,ll> mp;
ll inf =  1e9;


int main(){
 while(1){
  ll n;
  cin>>n;
  if( n == 0 ) break;
  vector<ll> collect(31,0);
  vector<vector<ll> > f(31);
  for(ll i=0;i<n;i++){
   ll tmp;
   cin>>tmp;
   for(ll j=0;j<tmp;j++){
    ll a;
    cin>>a;
    f[a].push_back( i );
    collect[a] |= 1<<i;
   }
  }
 // cout<<"OK"<<endl;
  vector<ll> state(n,0);
  bool flag = false;
  for(ll i=0;i<n;i++) state[i] = 1ll<<i;
 
  for(ll i=1;i<31&&!flag;i++){
   
   ll ss = 0;
   for(ll j=0;j<f[i].size();j++){
    ss |= state[ f[i][j] ];
    /*for(ll k=0;k<f[i].size();k++){
     state[f[i][j]] |= state[f[i][k]];
    }*/
   }
   for(ll j=0;j<f[i].size();j++){
    state[f[i][j]] |= ss;
   }
  
   if( ss == (1ll<<n)-1 ){
    flag = true;
    cout<<i<<endl;
    break;
   }
   /*for(ll j=0;j<n;j++) if( state[j] == (1<<n)-1 ){
    flag = true;
    cout<<i<<endl;
    break;
   }*/

  }
  if( !flag ) cout<<-1<<endl;
 
 }
    return 0;
}



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

using namespace std;

const long long int MOD = 1e9 + 7;
long long int mypow(long long int x,long long int n)
{
	long long int res = 1;
	while(n>0)
	{
		if(n%2==1)
		{
			res = ((res%MOD)*(x%MOD)%MOD)%MOD;
			res%=MOD;
		}
		x = ((x%MOD)*(x%MOD)%MOD)%MOD;
		x%=MOD;
		n/=2;
	}
	return res;
}
long long int f[2000001];

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

	long long int res = 0;
	long long int x,y;

	cin >> x >> y;

	f[0] = 1;
	for(int i=1;i<=2000000;i++)
	{
		f[i] = ((f[i-1]%MOD)*(i%MOD)%MOD)%MOD;
		f[i]%=MOD;
	}

	for(int a=0;a<=x;a++)
	{
		int b = x - a;
		if(b%2!=0)
		{
			continue;
		}
		b/=2;
		if(2*a + b == y)
		{
			long long int ways = f[a+b];
			ways = ((ways%MOD)*(mypow(f[a],MOD-2)%MOD)%MOD)%MOD;
			ways%=MOD;
			ways = ((ways%MOD)*(mypow(f[b],MOD-2)%MOD)%MOD)%MOD;
			ways%=MOD;
			res = ((res%MOD) + (ways%MOD)%MOD)%MOD;
			res%=MOD;			
		}
	}

	cout << res << '\n';

	return 0;
}


Measured memory_bytes: 19228
#include <iostream>
#include <string>
#include <algorithm>
#include <cstdio>
#include <vector>
#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
using namespace std;

int main(){
    int n, money = 100000;
    cin >> n;
    REP(i, n){
    	int tmp;
    	money *= 1.05;
    	tmp = money % 1000;
    	if(tmp > 0){
    		money -= tmp;
    		money += 1000;
    	}
    }
    cout << money << endl;
}


Measured memory_bytes: 3064
N = int(input())
S = input()

char_after_n = {}


def get_nth_ascii(original_ascii, n):
    NUM_ASCII = 26
    c = original_ascii + (n % NUM_ASCII)
    if c > ord('Z'):
        return c - NUM_ASCII
    return c


# create map A to Z
for c in range(ord('A'), ord('Z') + 1):
    char_after_n[c] = get_nth_ascii(c, N)

for mapped_char in map(lambda s: chr(char_after_n[ord(s)]), S):
    print(mapped_char, end="")



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

#ifdef LOCAL
#include "dump.hpp"
#else
#define dump(...)
#define dumpv(...)
#endif

#define rep(i, n) for (int i = 0; i < (n); i++)
#define mins(x, y) (x = min(x, y))
#define maxs(x, y) (x = max(x, y))
typedef long long ll;
typedef pair<int, int> P;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<vl> vvl;
const int MOD = 1e9 + 7;
const int INF = 1001001001;
const ll LINF = 1001002003004005006ll;

void solve() {
  ll n, m;
  cin >> n >> m;
  vl a(n);
  rep(i, n) cin >> a[i];
  sort(a.begin(), a.end());
  // sort(a.rbegin(), a.rend());
  dump(n, m, a);
  ll sum = 0;
  auto calc = [&](ll x) {
    ll num = 0;
    sum = 0;
    int j = n - 1;
    rep(i, n) {
      while (j >= 0 && a[i] + a[j] >= x) {
        sum += a[j] * (n - i);
        j--;
      }
      sum += (n - (j + 1)) * a[i];
      num += n - (j + 1);
      dump(i, j, num, sum);
    }
    return num;
  };
  ll ng = -1;
  ll ok = 100000 * 2 + 1;
  while(abs(ok - ng) > 1) {
    int mid = (ok + ng) / 2;
    if (calc(mid) <= m)
      ok = mid;
    else
      ng = mid;
    dump(ng, ok);
  }
  ll x = calc(ok);
  ll s = sum;
  ll ans = sum + (m - x) * ng;
  dump(ans);
  dump(ng, ok, sum);
  cout << ans << endl;
}

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(15);
  // freopen("temp.1", "r", stdin);
  solve();
  return 0;
}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
const int maxn=200003,D=100000,INF=1050000000;
int t[maxn],n,a[maxn],sum[maxn];
void add(int pos){while(pos<maxn)t[pos]++,pos+=pos&-pos;}
int query(int pos){int ret=0;while(pos)ret+=t[pos],pos-=pos&-pos;return ret;}
bool check(int x){
	for(int i=1;i<=n;i++)sum[i]=sum[i-1]+(a[i]>=x?1:-1);
	long long tot=0;
	memset(t,0,sizeof(t));
// printf("chk %d\n",x);
	for(int i=1;i<=n;i++){
		add(sum[i-1]+D);
		tot+=query(sum[i]+D);
// printf("query %d: %d\n",sum[i],query(sum[i]+D));
		if(tot>=(long long)n*(n+1)/4)return 1;
	}
	return 0;
}
int main(){
	int l=INF,r=0,mid,ans;
	scanf("%d",&n);
	for(int i=1;i<=n;i++){
		scanf("%d",a+i);
		l=min(l,a[i]);
		r=max(r,a[i]);
	}
	while(l<=r){
		mid=(l+r)>>1;
		if(check(mid))ans=mid,l=mid+1;
		else r=mid-1;
	}
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  vector<string> s(3);
  cin >> s.at(0) >>s.at(1) >>s.at(2);
  int now = 0;
  while(true){
    if(s.at(now) == ""){
      cout << char( 'A' +now);
      return 0;
    }
    char t = s.at(now).at(0);
    s.at(now).erase(s.at(now).begin());

    now = t -'a';
    
  }
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int a[111],b[111];
int main()
{
    int n,m,x;
    cin>>n>>m>>x;
    for(int t, i=1;i<=m;i++)
    {
        cin>>t;
        a[t]=1;
    }
    for(int i=1;i<=n;i++)
    {
        if(i==1) b[i]=a[i];
        else b[i]=b[i-1]+a[i];
    }
    /*for(int i=1;i<=n;i++)
    {
        cout<<b[i]<<" ";
    }*/
    if(b[x-1]<(b[n]-b[x]))
    cout<<b[x-1];
    else cout<<b[n]-b[x];

    return 0;

}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <string.h>
#include <math.h>
#include <cmath>
#include <vector>
#include <set>
#include <map>
#include <algorithm>
#include <utility>
#include <deque>
#include <queue>

#define rep(i, n) for(int i = 0; i < n; ++i)
#define REP(i, m, n) for(int i = m; i < n; ++i)
#define rrep(i,n) for(int i = n; i >= 0; --i)
#define RREP(i, m, n) for(int i = n; i >= m; --i)

typedef long long ll;
typedef unsigned long long ull;
typedef std::pair<int, int> pii;
typedef std::pair<long long, long long> pll;

using namespace std;

const long long mod = 1000000007;

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

	int a, b;
	cin >> a >> b;
	cout << max(0, a - b * 2) << "\n";

    return 0;
}


Measured memory_bytes: 256
N = int(input())
ans = 0
for i in range(1, N + 1):
    n = N // i  # 項数n
    cnt = (n * (2 * i + (n - 1) * i)) // 2  # 初項i, 項数n の等差数列の和の公式
    ans += cnt
print(ans)

Measured memory_bytes: 9192
/*
これを入れて実行
g++ code.cpp
./a.out
 */
 
#include <iostream>
#include <vector>
#include <string>
#include <queue>
#include <deque>
#include <algorithm>
#include <utility>
#include <set>
#include <map>
#include <cmath>
#include <math.h>
#include <tuple>
#include <iomanip>
 
using namespace std;
typedef long long ll;
typedef long double ld;
 
int dy4[4] = {-1, 0, +1, 0};
int dx4[4] = {0, +1, 0, -1};
int dy8[8] = {-1, -1, 0, 1, 1, 1, 0, -1};
int dx8[8] = {0, 1, 1, 1, 0, -1, -1, -1};
 
const long long INF = 1LL << 60;
const ll MOD = 1e9 + 7;
 
bool greaterSecond(const pair<int, int>& f, const pair<int, int>& s){
    return f.second > s.second;
}
 
ll gcd(ll a, ll b){
	if (b == 0)return a;
	return gcd(b, a % b);
}
 
ll lcm(ll a, ll b){
    return a / gcd(a, b) * b;
}
 
ll nCr(ll n, ll r){
    if(r == 0 || r == n){
        return 1;
    } else if(r == 1){
        return n;
    }
    return (nCr(n - 1, r) + nCr(n - 1, r - 1));
}
 
ll nPr(ll n, ll r){
    r = n - r;
    ll ret = 1;
    for (ll i = n; i >= r + 1; i--) ret *= i;
    return ret;
}
 
//-----------------------ここから-----------

int main(void){
    string s;
    cin >> s;

    int f = 0;
    int b = s.size() - 1;
    int ans = 0;
    while(f < b){
        if(s[f] == s[b]){
            f++;
            b--;
        } else {
            if(s[f] == 'x'){
                ans++;
                f++;
            } else if(s[b] == 'x'){
                ans++;
                b--;
            } else {
                cout << -1 << endl;
                return 0;
            }
        }
    }

    cout << ans << endl;

}

Measured memory_bytes: 512
/*
    author: kartik8800
*/
#include<bits/stdc++.h>
#define ll long long
#define pb push_back
#define fr(a,b) for(ll i = a; i < b; i++)
#define mod 1000000007
#define all(x) (x).begin(), (x).end()
#define prDouble(x) cout << fixed << setprecision(10) << x 
#define triplet pair<ll,pair<ll,ll>>
#define fast_io ios_base::sync_with_stdio(false);cin.tie(NULL)
using namespace std;

double dp[3001][3001];
double solve(vector<double>& ar, int i, int heads)
{
    if(heads <= 0)
        return 1;
    if(i == 0)
        return 0;
    if(dp[i][heads] > -0.9) 
        return dp[i][heads];
    return dp[i][heads] = ar[i]*solve(ar, i-1, heads-1) + (1-ar[i])*solve(ar, i-1, heads);
}

int main() {
    int n;
    cin >> n;
    memset(dp, -1, sizeof dp);
    vector<double> ar(n+1);
    fr(1,n+1)
        cin >> ar[i];    
    prDouble(solve(ar, n, (n+1)/2));
}


Measured memory_bytes: 70784
#include<stdio.h>
int n;
int i,j;
int ans;
int order;
typedef struct{
	int wl,wr,tl,tr,le,ri;
	bool flag;
}t_stick;
t_stick st[100];

int max(int a,int b){
	if(a>=b)return a;
	else return b;
}

int min(int a,int b){
	if(a<=b)return a;
	else return b;
}

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

int main(){
	int n,m;
	while(1){
		scanf("%d",&n);
		if(n==0)return 0;
		ans=0;
		order=0;
		for(i=0;i<n;i++){
			int p,q,r,s;
			scanf("%d %d %d %d",&p,&q,&r,&s);
			st[i].tl=p;
			st[i].tr=q;
			st[i].le=r-1;
			st[i].ri=s-1;
		}
		for(i=0;i<n;i++){
			st[i].wl=0;
			st[i].wr=0;
			st[i].flag=false;	
		}
		while(1){
			for(i=0;i<n;i++){
				if(st[i].le!=-1&&st[st[i].le].flag){
					st[i].wl=st[st[i].le].wl+st[st[i].le].wr;
					st[i].le=-1;
				}
				if(st[i].ri!=-1&&st[st[i].ri].flag){
					st[i].wr=st[st[i].ri].wl+st[st[i].ri].wr;
					st[i].ri=-1;
				}
				if(!st[i].flag&&st[i].le==-1&&st[i].ri==-1){
					if(st[i].wl==0&&st[i].wr==0){
						st[i].wl=st[i].tr/gcd(st[i].tl,st[i].tr);
						st[i].wr=st[i].tl/gcd(st[i].tl,st[i].tr);
					}
					else if(st[i].wl==0){
						int x=st[i].tl/gcd(st[i].tl,st[i].tr);
						st[i].wr*=x/gcd(st[i].wr,x);
						st[i].wl=st[i].wr*st[i].tr/st[i].tl;
					}
					else if(st[i].wr==0){
						int x=st[i].tr/gcd(st[i].tl,st[i].tr);
						st[i].wl*=x/gcd(st[i].wl,x);
						st[i].wr=st[i].wl*st[i].tl/st[i].tr;
					}else{
						int x=st[i].tr*st[i].wr/gcd(st[i].tr*st[i].wr,st[i].tl);
						st[i].wl*=x/gcd(st[i].wl,x);
						st[i].wr=st[i].wl*st[i].tl/st[i].tr;
					}
					st[i].flag=true;
					if(order==n-1)ans=st[i].wl+st[i].wr;
					order++;
				}
			}
			if(order==n)break;
		}
		printf("%d\n",ans);
	}
}

Measured memory_bytes: 1028
#include <iostream>
#include <vector>
#include <map>

using namespace std;

map<int, int> m;

bool cmp(int l, int r) {
    return m[r] < m[l];
}

int main(void) {
    int n, k;
    cin>>n>>k;
    for (int i=0; i<n; ++i) {
        int d;
        cin>>d;
        if (m.find(d) == m.end()) {
            m[d] = 0;
        }
        m[d] += 1;
    }

    int sz = m.size();

    vector<int> v(sz);
    int idx = 0;
    for (map<int, int>::iterator it = m.begin(); it != m.end(); it++) {
        v[idx++] = it->first;
    }

    sort(v.begin(), v.end(), cmp);

    int cnt = 0;
    for (int i=k; i<sz; ++i) {
        cnt += m[v[i]];
    }

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


Measured memory_bytes: 10368
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const ll INF = 1e16;
const ll mod = 1000000007;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)

int main() {
  ll r;
  cin >> r;
  cout << 3*r*r << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, m, n) for(int i = m; i < (n); i++)
#define print(x) cout << (x) << endl;
#define printa(x,n) for(int i = 0; i < n; i++){ cout << (x[i]) << " ";} cout << endl;
#define printa2(x,m,n) for(int i = 0; i < m; i++){ for(int j = 0; j < n; j++){ cout << x[i][j] << " ";} cout << endl;}
#define printp(x,n) for(int i = 0; i < n; i++){ cout << "(" << x[i].first << ", " << x[i].second << ") "; } cout << endl;
#define INF (1e9)
using namespace std;
typedef long long ll;
typedef struct{
    int x;
    int y;
} P;
typedef struct{
    ll to;
    ll cost;
} edge;
typedef pair<ll, ll> lpair;

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll N;
    cin >> N;
    vector<ll> dd;
    for(ll i = 1; i*i <= N; i++){
        if(N % i == 0){
            dd.push_back(i);
            if(i * i != N){
                dd.push_back(N/i);
            }
        }
    }
    sort(dd.begin(), dd.end());
    ll f_min = 1e9;
    rep(i,0,dd.size()){
        ll l1 = to_string(dd[i]).size();
        ll l2 = to_string(N/dd[i]).size();
        f_min = min(f_min, max(l1,l2));
    }
    print(f_min);

}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <boost/math/constants/constants.hpp>
using namespace std;
typedef long long ll;
long double e = boost::math::constants::e<long double>();
long double pi = boost::math::constants::pi<long double>();
// 条件を見落としていませんか？
int H, W, K;
int d[10][1010];
int main () {
    cin >> H >> W >> K;
    for (int i = 0; i < H; i++) {
        string S;
        cin >> S;
        S = "#"+S;
        for (int j = 1; j < S.size(); j++) {
            d[i][j] = d[i][j-1]+(S[j]-'0');
        }
    }
    ll ans = INT_MAX;
    for (int i = 0; i < (1 << (H-1)); i++) {
        vector<int> v;
        v.push_back(0);
        ll res = 0;
        for (int j = 0; j < H-1; j++) {
            if (i & (1 << j)) {
                v.push_back(j+1);
                res++;
            }
        }
        v.push_back(H);
        for (int j = 1; j <= W; j++) {
            for (int k = 1; k < v.size(); k++) {
                int a = 0;
                for (int l = v[k-1]; l < v[k]; l++) {
                    a += d[l][j]-d[l][j-1];
                }
                if (a > K) {
                    res = INT_MAX;
                }
            }
        }
        int jj = 0;
        for (int j = 1; j <= W; j++) {
            bool f = 1;
            for (int k = 1; k < v.size(); k++) {
                int a = 0;
                for (int l = v[k-1]; l < v[k]; l++) {
                    a += d[l][j]-d[l][jj];
                }
                if (a > K) {
                    f = 0;
                }
            }
            if (!f) {
                res++;
                jj = j-1;
            }
        }
        ans = min(ans, res);
    }
    cout << ans << endl;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
using P = pair<ll,ll>;
const ll mod = 1e9+7;
#define ALL(x) (x).begin(),(x).end()
#define pow(x,y) modpow(x,y)
#define REP(i,n) for(ll (i)=0;(i)<(n);(i)++)

template <class T = int>T in(){
    T x;
    cin >> x;
    return (x);
}

signed main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout<<fixed<<setprecision(10);
    int N = in();
    vector<int> A(N);
    REP(i,N)A[i] = in();
    vector<int> number(100050);
    REP(i,N)number[A[i]]++;
    vector<int> sub(100050);
    sub[0] = number[0];
    REP(i,number.size()-1)sub[i+1] = sub[i] + number[i+1];
    int maximum = 0;
    for(int i = 2;i < 100050;i++){
        maximum = max(maximum,sub[i]-sub[i-3]);
    }
    cout << maximum << "\n";
}

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

int main() {
  int a;
  cin >> a;
  
  int b = a/100;
  int c = a % 100;
  
  if(!(b == 0) && b <= 12 && c >= 13 || !(b == 0) && b <= 12 && c == 0){
    cout << "MMYY" << endl;
  }
  
  else if((b == 0 || b >= 13) && c <= 12 && !(c == 0)){
    cout << "YYMM" << endl;
  }
  
  else if(b <= 12 && c <= 12 && !(c == 0)){
    cout << "AMBIGUOUS" << endl;
  }
          
  else{
    cout << "NA" << endl;
  }

  
  
  
}


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

int main() {
    int n;
    cin >> n;
    vector<int> v(n);
    for(int i = 0; i < n; i++){
        cin >> v[i];
    }
    sort(v.begin() , v.end());
    int m;
    cin >> m;
    for(int i = 0; i< m; i++){
        int p;
        cin >> p;
      
        auto itr = std::equal_range(v.begin(), v.end(), p);
        cout << itr.first - v.begin() << " " << itr.second - v.begin() << endl;
    }
}


Measured memory_bytes: 3148
#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < n; i++)
#define All(V) V.begin(), V.end()
typedef long long int ll;
typedef pair<int, int> P;
const ll MOD = 1e9+7, INF = 1e9;

int main()
{
    int n; cin >> n;
    vector<ll> v(n);
    rep(i, n) cin >> v[i];
    ll t = v[0];
    for(int i = 1; i < n; i++){
        t ^= v[i];
    }
    rep(i, n){
        v[i] ^= t;
        cout << v[i] << endl;
    }
    system("pause");
}

//https://www.geisya.or.jp/~mwm48961/kou3/base2.htm
//https://math.nakaken88.com/textbook/basic-base-conversion-of-integers/
/*ll n; cin >> n;
    vector<char> ans(100, 'Z');
    int cnt = 0;
    while(n > 0){
        ll k = n % 26;
        ans[cnt++] = 'a'+k-1;
        n /= 26;
    }
    int i = 0;
    while(ans[i] != 'Z'){
        cout << ans[i++];
    }
    cout << endl;*/

Measured memory_bytes: 4716
use std::io::*;
fn main() {
    let mut s: String = String::new();
    std::io::stdin().read_to_string(&mut s).ok();
    let mut itr = s.trim().split_whitespace();
    let s = itr.next().unwrap();

    let n = s.len();
    for i in 0..n {
        for j in i..n {
            let t = &s[..i];
            let u = t.to_string();
            let v = &s[j..];
            if u + v == "keyence" {
                println!("YES");
                return;
            }
        }
    }
    println!("NO");
}


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



int main() {
   int n;
   cin >> n;
   int a, b;
   cin >> a >> b;
   for (int i=a; i<b+1; i++) {
      if (i % n == 0) {
         cout << "OK" << endl;
         return 0;
      }
   }
   cout << "NG" << endl;
   return 0;
}

Measured memory_bytes: 3588
#include<bits/stdc++.h>
 
using namespace std;
 
 
#define mod(cans) cans%10**9+7
#define debug(x) cout << "Debug" << x << "\n"
#define rep(i,n) for(int i=0;i<n;i++)
#define repr(i,n) for(int i=n-1;i>=0;i--)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define cin_pl(n,x) rep(i,n){cin>>x[i];}
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define prians(Answer) cout<<Answer<<"\n"
#define TF(X) X==1?cout<<"Yes\n":cout<<"No\n"
#define elcon else{continue;}
#define Quit(n) if(n>0) break;
 
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<string> vs;
typedef vector<vector<int> > matrix;
typedef pair<int,int> pii;
typedef vector<pii> vpi;
typedef greater<int> gi;
typedef vector<unsigned> vu;


ll gcd(ll x, ll y) { return (y == 0) ? x : gcd(y, x % y); }
bool is_prime(const unsigned n){
    switch(n){
        case 0:
        case 1: return false;
        case 2: return true;
    }
 
 
    for(unsigned i=2;i<n;++i){
        if(n%i == 0) return false;
    }
 
    return true;
}


int main()
{
    int n,k,ans;cin>>n>>k;
    multiset<int> a;rep(i,k){int x;cin>>x;a.insert(x);}
    for(int i=n;i<=100000;i++)
    {
        int tmp=i;
        ans=i;
        multiset<int>b,c;
        while(tmp>0)
        {
            b.insert(tmp%10);
            tmp=tmp/10;
        }
        set_intersection(all(a),all(b),inserter(c,c.end()));
        if(c.empty())break;
    }
    cout<<ans;
}


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

int main() {
    int k, s;
    cin >> k >> s;
    int z;
    ll cnt = 0;
    for(int x = 0; x <= k; ++x){
        for(int y = 0; y <= k; ++y){
            z = s-x-y;
            if(z>=0&&z<=k) cnt++;
        }
    }
    cout << cnt << endl;
    return 0;
}

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

int main() {
    int N;
    cin >> N;
    int a[N];
    rep(i, N) cin >> a[i];

    int now = 1, ans = 0;
    rep(i, N) {
        if (a[i] == now) {
            now++;
        } else {
            ans++;
        }
    }
    if (now == 1) ans = -1;
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 1024
// You got a dream , you gotta protect it .
#include <bits/stdc++.h>
#define FAST ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0);
using namespace std;
typedef long long ll;
typedef long double ld;
const long double EPS = 1e-6;
const long double pi = acos(-1);
const int INF = 1e9 + 10;
int main(){
    FAST
    ll n , cnt = 0;
    cin >> n;
    string s;
    cin >> s;
    for(ll i = 0; i < n - 2; i++){
        if(s[i] == 'A' && s[i + 1] == 'B' && s[i + 2] == 'C'){
            cnt++;
        }
    }
    cout << cnt << endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(v) begin(v), end(v)
using namespace std;
using P = pair<int, int>;

int main() {
  for (int h, w; cin >> h >> w, h;) {
    vector<string> s(h);
    rep(i, h) cin >> s[i];
    multiset<string> st;
    auto f = [&](int i, int j) { return s[i % h][j % w]; };
    auto g = [](string t) {
      int n = t.length();
      rep(i, n / 2) {
        if (t[i] != t[n - 1 - i]) return false;
      }
      return true;
    };
    auto calc = [&](string t) {
      rep(i, t.length() - 1) {
        auto tmp = t.substr(0, i + 2);
        st.insert(tmp);
      }
    };
    string t;
    P cur, goal;
    rep(i, h) rep(j, w) {
      goal = {i, j};

      t = "";
      rep(k, h) t += f(i + k, j);
      calc(t);
      reverse(all(t));
      calc(t);

      t = "";
      rep(k, w) t += f(i, j + k);
      calc(t);
      reverse(all(t));
      calc(t);

      t = "";
      cur = {i, j};
      while (true) {
        t += f(cur.first, cur.second);
        cur = {(cur.first + 1) % h, (cur.second + 1) % w};
        if (cur == goal) break;
      }
      calc(t);
      reverse(all(t));
      calc(t);

      t = "";
      cur = {i, j};
      while (true) {
        t += f(cur.first, cur.second);
        cur = {(cur.first + 1) % h, (cur.second - 1 + w) % w};
        if (cur == goal) break;
      }
      calc(t);
      reverse(all(t));
      calc(t);
    }
    int m = 0;
    for (auto x : st) {
      if (st.count(x) >= 2) m = max(m, (int)x.length());
    }
    bool ok = false;
    for (auto x : st) {
      // cerr << x << ' ' << st.count(x) << endl;
      if (x.length() != m || st.count(x) < 2) continue;
      cout << x << endl;
      ok = true;
      break;
    }
    if (!ok) cout << 0 << endl;
  }
}



Measured memory_bytes: 29992
import java.util.Scanner;

public class Main {
	public static void main(String[] args){
			Scanner sc = new Scanner(System.in);
			for(int i = 1;;i++){
				int x = sc.nextInt();
				if(x == 0)
					break;
				System.out.println("Case "+i+": "+x);
			}
		}
}

Measured memory_bytes: 33016
fn read<T: std::str::FromStr>(
    stdin_lock: &mut std::io::StdinLock,
    buf: &mut Vec<u8>,
    delimiter: u8,
) -> T {
    buf.clear();
    let l = std::io::BufRead::read_until(stdin_lock, delimiter, buf).unwrap();
    buf.truncate(l - 1); // remove delimiter
    let s = unsafe { std::str::from_utf8_unchecked(&buf) };
    s.parse().unwrap_or_else(|_| panic!("read"))
}

fn main() {
    let stdin = std::io::stdin();
    let mut stdin_lock = stdin.lock();
    let mut buf: Vec<u8> = Vec::new();
    let s: String = read(&mut stdin_lock, &mut buf, b'\n');

    let ans = if s == "Sunny" {
        "Cloudy"
    } else if s == "Cloudy" {
        "Rainy"
    } else if s == "Rainy" {
        "Sunny"
    } else {
        unreachable!()
    };
    println!("{}", ans);
}


Measured memory_bytes: 4352
// Problem : A - Kyu in AtCoder
// Contest : AtCoder - M-SOLUTIONS Programming Contest 2020
// URL : https://atcoder.jp/contests/m-solutions2020/tasks/m_solutions2020_a
// Memory Limit : 1024 MB
// Time Limit : 2000 ms
// Powered by CP Editor (https://github.com/cpeditor/cpeditor)

/*

WINNERS NEVER QUIT AND QUITTERS NEVER WIN!!

*/

#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef pair<long,long> pl;
typedef pair<ll,ll> pll;
typedef vector<long> vl;
typedef vector<bool> vb;
typedef vector<ll> vll;
typedef vector<vl> vvl;
typedef vector<vb> vvb;
typedef vector<vll> vvll;
typedef vector<pll> vpll;
typedef vector<string> vs;
typedef unordered_map<ll,ll> umll;

#define FOR(i,a,b) for(long long i=a;i<b;++i)
#define REV(i,a,b) for(long long i=a;i>=b;i--)
#define F first
#define S second
#define pb push_back
#define mp make_pair
#define ub upper_bound
#define lb lower_bound
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(),v.rend()
#define tc ll tests;cin>>tests;while(tests--)
#define io ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define coutv(v) for(auto it: (v))cout<<it<<" ";newl;
#define cout2d(v) for(auto it: (v)) {for(auto j:it) cout<<j<<" ";newl;}
#define cinv(v,n) vll (v)(n);FOR(i,0,(n)){cin>>v[i];}
#define cinvg(v,n) (v).resize(n);FOR(i,0,(n)){cin>>v[i];}
#define cin2d(v,n,m) vvll (v)(n,vll(m,0));FOR(i,0,n){FOR(j,0,m){cin>>v[i][j];}}
#define cin2dg(v,n,m) (v).resize(n,vll(m));FOR(i,0,n){FOR(j,0,m){cin>>v[i][j];}}
#define newl cout<<"\n"
#define mod 1000000007
#define INF LLONG_MAX/2

int main()
{
    io;
    ll x;
    cin>>x;
    if(x>=400 & x<=599){cout<<8;}
    else if(x>=600 & x<=799){cout<<7;}
    else if(x>=800 & x<=999){cout<<6;}
    else if(x>=1000 & x<=1199){cout<<5;}
    else if(x>=1200 & x<=1399){cout<<4;}
    else if(x>=1400 & x<=1599){cout<<3;}
    else if(x>=1600 & x<=1799){cout<<2;}
    else if(x>=1800 & x<=1999){cout<<1;}
    return 0;
}



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

#define FOR(i, a, b) for (int i = int(a); i < int(b); i++)
#define REP(i, b) FOR(, 0, b)
#define MP make_pair
#define PB push_back
#define EB emplace_back
#define ALL(x) x.begin(), x.end()

using pi = pair<int, int>;
using vi = vector<int>;
using ld = long double;

int main() {
    int sx, sy, tx, ty;
    cin >> sx >> sy >> tx >> ty;

    string ans = "";
    /// s < t　より
    int x = tx - sx;
    int y = ty - sy;

    //１周目
    ans += string(y, 'U');
    ans += string(x, 'R');
    ans += string(y, 'D');
    // ２周目
    // 1周目と別の経路を通る必要がある
    ans += string(x + 1, 'L');
    ans += string(y + 1, 'U');
    ans += string(x + 1, 'R');
    ans += "DR";
    ans += string(y + 1, 'D');
    ans += string(x + 1, 'L');
    ans += "U";

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

Measured memory_bytes: 256
# -*- coding: utf-8 -*-

N, M = map(int, input().split())

# A[i], B[i] はまとめてしまう
stores = [list(map(int, input().split())) for n in range(N)]

# 安さ順にソート
stores.sort(key = lambda s: s[0])

remaining = M
cost = 0

while True:
  store = stores[0]
  if store[1] >= remaining: # もしこの店で買いきれるなら
    cost += store[0] * remaining
    break
  else: #買い切れないなら
    cost += store[0] * store[1]
    remaining -= store[1]
    stores.pop(0)

print(cost)

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

using namespace std;

using ll = long long;

const int N = 2e5 + 5;
int a[N];
int main() {
  int n;
  cin >> n;
  for (int i = 0; i < n; i++)
    cin >> a[i];
  sort(a, a + n);
  int ans = 0;
  for (int i = 1; i <= N; i++) {
    int x = upper_bound(a, a + n, i) - a;
    if (x == n / 2) {
      ans++;
    }
  }
  cout << ans << '\n';
	return 0;
}


Measured memory_bytes: 640
void main() {
	auto S = rs;
	auto w = ri;
	string res;
	foreach(i; iota(0, S.length, w)) {
		res ~= S[i];
	}
	res.writeln;
}

// ===================================

import std.stdio;
import std.string;
import std.functional;
import std.conv;
import std.algorithm;
import std.range;
import std.traits;
import std.math;
import std.container;
import std.bigint;
import std.numeric;
import std.conv;
import std.typecons;
import std.uni;
import std.ascii;
import std.bitmanip;
import core.bitop;

T readAs(T)() if (isBasicType!T) {
	return readln.chomp.to!T;
}
T readAs(T)() if (isArray!T) {
	return readln.split.to!T;
}

T[][] readMatrix(T)(uint height, uint width) if (!isSomeChar!T) {
	auto res = new T[][](height, width);
	foreach(i; 0..height) {
		res[i] = readAs!(T[]);
	}
	return res;
}

T[][] readMatrix(T)(uint height, uint width) if (isSomeChar!T) {
	auto res = new T[][](height, width);
	foreach(i; 0..height) {
		auto s = rs;
		foreach(j; 0..width) res[i][j] = s[j].to!T;
	}
	return res;
}

int ri() {
	return readAs!int;
}

double rd() {
	return readAs!double;
}

string rs() {
	return readln.chomp;
}

Measured memory_bytes: 256