akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;

int main(void) {
    int N,A,B;
    int sum,dig,num;
    int result=0;

    cin >> N >> A >> B;
    
    for(int i=1; i<=N; i++){
        sum = 0;
        num = i;
        for(int j=0; j<5; j++){
            sum += num % 10;
            num /= 10;
        }
        if(A<=sum && sum<=B) result += i;
    }

    cout << result << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(void){
    int n,m;
    cin>>n>>m;
    vector<int> A(n),B(n);
    for(int i=0;i<n;i++){
        cin>> A[i]>>B[i];
    }
    vector<pair<int,int>> AB(n);
    for(int i=0;i<n;i++){
        AB[i]=make_pair(A[i],B[i]);
    }
    sort(AB.begin(), AB.end());
 
	long long ans = 0;
    for(int i=0;i<n;i++){
        int buy = min(m, AB[i].second);
        ans+=(long long)buy*AB[i].first;
        m-=buy;
        
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 1792
#include<bits/stdc++.h>
    using namespace std;
    #define ll long long
    #define pb push_back
    #define printV(v) for(int i=0;i<v.size();i++){cout << v[i]<< " ";} cout << endl
    #define printRev(v) for(int i=v.size()-1;i >= 0;i--){cout << v[i] << " ";} cout << endl
    #define sortV(v) sort(v.begin(),v.end())
    #define revV(v) reverse(v.begin(),v.end())
    #define FOR(i,n) for(int i=0;i<n;i++)
    ll a,b,c,d,e,f,g,n,m,k,t,p,x;
 
    ll mod = 998244353;
    
    void solve(){
       cin >> m >> n;
       vector<ll> arr(n);
        for(int i=0;i<n;i++){
            cin >> arr[i];
        }
        //sortV(arr);
        ll cnt = 9999999999;
        for(int i=0;i<n;i++){
            if(i == 0){
                cnt =  min(cnt,min(m - arr[i+1] + arr[i], arr[n-1] - arr[0]));
            }else if(i==n-1){
                cnt = min(cnt,min(arr[i] - arr[0], m - arr[i] + arr[n-2]));
            }else{
                cnt = min(cnt,min(arr[i] + m - arr[i+1], m - arr[i] + arr[i-1]));
            }
          
        }
        cout << cnt;
    }
 
    int main(){
        ios_base::sync_with_stdio(false);
       
        int cases = 1; 
        //cin >> cases;
       
        while(cases--){
            solve();
        }
        return 0;
 
    }

Measured memory_bytes: 1792
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int i,s,j,a[10];
    for(i=0;i<10;i++)
    {
        cin>>a[i];
    }
    for(i=0;i<10;i++)
    {
        for(j=i+1;j<10;j++){
            if(a[i]<a[j])
            {
                s=a[j];
                a[j]=a[i];a[i]=s;
            }
        }
    }
    for(i=0;i<3;i++){
        cout<<a[i]<<endl;
    }
}

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

void pop_number(vector<int>& A, int& y, int& z) {
  z = A.back();
  A.pop_back();
  y = A.back();
  A.pop_back();
}

int main() {
  vector<int> A;
  int x;
  int y;
  int z;
  string temp;

  getline(cin, temp);
  stringstream ss{temp};
  while (getline(ss, temp, ' ')) {
    if(temp == "*") {
      pop_number(A, y, z);
      A.push_back(y * z);
    } else if (temp == "+") {
      pop_number(A, y, z);
      A.push_back(y + z);
    } else if (temp == "-") {
      pop_number(A, y, z);
      A.push_back(y - z);
    } else {
      A.push_back(atoi(temp.c_str()));
    }
  }
  cout << A.back() << endl;
}



Measured memory_bytes: 3200
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const int N = 100005;

int q, l, r;
int psum[N];

bitset<N> val;
set<int> primes;

void sieve() {
    val.set();
    for (int i = 2; i < N; i++) {
        if (val[i]) {
            primes.insert(i);
            for (int j = i + i; j < N; j += i) val[j] = false;
        }
    }
}

void precomp() {
    for (int i = 3; i < N; i++) {
        if (i % 2) {
            if (primes.find(i) != primes.end() && primes.find((i + 1) / 2) != primes.end()) psum[i]++;
        }
        
        psum[i] += psum[i - 1];
    }
}

int main() {
    cin.sync_with_stdio(0); cin.tie(0);
    sieve();
    precomp();
    
    cin >> q;
    while (q--) {
        cin >> l >> r;
        cout << psum[r] - psum[l - 1] << '\n';
    }
}


Measured memory_bytes: 1536
# keyence2019_c.py
N = int(input())
A = list(map(int,input().split()))
B = list(map(int,input().split()))
if sum(A)<sum(B):
    print(-1)
    exit()

C = []
diff = 0
cnt = 0
for i in range(N):
    d = A[i] - B[i]
    if d < 0:
        cnt += 1
        diff += d
    else:
        C.append(d)
C.sort(reverse=True)
for i in C:
    if diff >= 0:
        break 
    diff += i
    cnt+=1
print(cnt)

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

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

  string s;
  cin >> s;

  map<char, vector<ll>> ind;
  for (ll i = 0; i < n; i++) {
    ind[s[i]].push_back(i);
  }

  ll ans = 0;
  for (ll i = 0; i < n; i++) {
    for (ll j = i + 1; j < n; j++) {
      if (s[i] == s[j]) continue;
      set<char> cols = {'R', 'G', 'B'};
      cols.erase(s[i]);
      cols.erase(s[j]);
      char c = *cols.begin();

      auto begin = lower_bound(ind[c].begin(), ind[c].end(), j + 1);
      auto exist = binary_search(begin, ind[c].end(), 2*j - i);
      if (exist) ans += ind[c].end() - begin - 1;
      else ans += ind[c].end() - begin;
    }
  }

  cout << ans << endl;
}


Measured memory_bytes: 3628
#include <bits/stdc++.h>
 
using namespace std;
 
#define ll long long int
#define mod 1000000007
 
#define REP(i, n) for(int i = 0; i < (n); i++)
#define SREP(i, s) for(int i = 0; i < (s.size()); i++)
#define SORT(v, n) sort(v, v+n);
#define GSORT(v, n) sort(v, v+n, greater<int>());
#define VSORT(v) sort(v.begin(),v.end());
#define VGSORT(v) sort(v.begin(),v.end(),greater<int>());
#define REV(a) reverse(begin(a),end(a));
#define FIND(v,i) find(v.begin(),v.end(),i);

int main(){
	ios::sync_with_stdio(false);cin.tie(0);
////////////////////////////////////////////
	int n;
    cin >> n;
    ll ans=1;
    REP(i,n){
        ans=ans*(i+1)%mod;
    }
    cout << ans << endl;
/////////////////////////////////////////////
}

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

using namespace std;

int N, K;
int h[100005];
long long int dp[100005];

int main(void) {

	cin >> N >> K;

	for (int i = 1; i <= N; i++) {
		cin >> h[i];
	}

	for (int i = 1; i <= N; i++) {
		dp[i] = 99999999999;
	}

	dp[1] = 0;
	

	for (int i = 1; i <= N; i++) {
		for (int j = max(1,i - K); j <= i - 1; j++) {
			dp[i] = min(dp[i], dp[j] + abs(h[j] - h[i]));
		}
	}

	cout << dp[N] << endl;


	//system("pause");
	return 0;
}


Measured memory_bytes: 1408
#pragma GCC optimize(2) 
#include<bits/stdc++.h>
#define rg register
#define il inline
using namespace std;
typedef long long ll;
const int mod=1e9+7,O=1000010,inf=0x3f3f3f3f;
struct Edge{int to,nt,w;}e[O];
struct Data{
	int dis,u;
	il bool operator<(Data rhs)const
		{return dis==rhs.dis?u<rhs.u:dis<rhs.dis;}
};
il int gi(){
	rg int o=0,fl=1;char ch=getchar();
	while(!isdigit(ch)&&ch!='-')ch=getchar();
	if(ch=='-')fl=-1,ch=getchar();
	while(isdigit(ch))o=o*10+ch-'0',ch=getchar();
	return fl*o;
}
bool vis[O];
set<int>S[O];
priority_queue<Data>q;
int n=gi(),m=gi(),head[O],cnt,dis[O];
il void add(int u,int v,int w){
	e[++cnt]=(Edge){v,head[u],w};
	head[u]=cnt;
}
int main(){
	for(int i=1;i<=m;++i){
		int x=gi(),y=gi(),z=gi();
		add(x,y,z);add(y,x,z);
	}
	memset(dis,0x3f,sizeof dis);
	dis[1]=0;
	q.push((Data){0,1});
	while(!q.empty()){
		int now=q.top().u;q.pop();
		if(vis[now])continue;vis[now]=1;
		for(int i=head[now];i;i=e[i].nt){
			int v=e[i].to,w=!S[now].count(e[i].w);
			if(dis[v]>dis[now]+w){
				dis[v]=dis[now]+w;
				q.push((Data){-dis[v],v});
				S[v].clear();
				S[v].insert(e[i].w);
			}
			else if(dis[v]==dis[now]+w)S[v].insert(e[i].w);
		}
	}
	printf("%d\n",dis[n]==inf?-1:dis[n]);
	return 0;
}


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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

#define REP(i, n) for(int i=0; i<(n); ++i)
#define FOR(i, a, b) for(int i=(a); i<(b); ++i)
#define FORR(i, a, b) for(int i=(b)-1; i>=(a); --i)

#define DEBUG(x) cout<<#x<<": "<<(x)<<'\n'
#define DEBUG_VEC(v) cout<<#v<<":";REP(i, v.size())cout<<' '<<v[i];cout<<'\n'
#define ALL(a) (a).begin(), (a).end()

template<typename T> inline void CHMAX(T& a, const T b) {if(a<b) a=b;}
template<typename T> inline void CHMIN(T& a, const T b) {if(a>b) a=b;}

constexpr ll MOD=1000000007ll;
// constexpr ll MOD=998244353ll;
#define FIX(a) ((a)%MOD+MOD)%MOD

const double EPS=1e-11;
#define EQ0(x) (abs((x))<EPS)
#define EQ(a, b) (abs((a)-(b))<EPS)

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  // cout<<setprecision(10)<<fixed;
  int n, a[252521];
  cin>>n;
  int cur=1;
  int ans=0;
  REP(i, n){
    cin>>a[i];
    if(a[i]==cur){
      ++cur;
    }
    else{
      ++ans;
    }
  }
  cout<<(ans==n ? -1 : ans)<<'\n';
  return 0;
}


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

#define v(type) vector<type> 
#define map(type1,type2) map<type1,type2>
#define INF 1000000005
#define pb push_back
#define mp make_pair
#define f0(i,n) for(i = 0; i < ( n ); i ++)
#define f1(i,n) for(i = 1; i <= ( n ); i ++)
#define f(i,m,n) for(i = ( m ); i <= ( n ); i ++)
#define nl cout<<endl

typedef long long int ll;
typedef unsigned long long int ull;

int main()
{
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    int H,A;
    cin>>H>>A;
    cout<<ceil((float)H/A);
    return 0;   
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define endl '\n'
#define maxl __LONG_LONG_MAX__
#define pb push_back
#define F first
#define S second
#define mp make_pair
#define rep(i, n) for(int i = 0; i < n; i++)
#define rev(i, n) for(int i = n-1; i >= 0; i--)
#define rep1(i, n) for(int i=1; i < n; i++)
#define rev1(i, n) for(int i=n ; i > 0; i--)
#define FOR(i, a, b) for(int i=a ; i < b; i++)

typedef long long int ll;
typedef long double ld;
typedef pair<ll,ll> pll;
typedef vector<ll> vll;
typedef vector<pair<ll, ll>> vpll;
typedef vector<vector<ll>> vvll;
typedef stack<ll> stk;
typedef queue<ll> que;
typedef map<ll,ll>::iterator mit;
typedef set<ll>::iterator sit;
typedef vector<ll>::iterator vit;

ll mod = 1e9 + 7;

void solve()
{
	ll n;
	cin>>n;
	vll h(n+1, 0);
	rep1(i, n+1)
		cin>>h[i];
	vll dp(n+1, 0);
	dp[1] = 0;
	dp[2] = abs(h[2] - h[1]);
	for(ll i = 3; i <= n; i++)
	{
		dp[i] = min(dp[i-1] + abs(h[i] - h[i-1]), dp[i-2] + abs(h[i] - h[i-2]));
	}
	cout<<dp[n]<<endl;
	return;
}


int main()
{
	ios_base::sync_with_stdio(false); 
    cin.tie(NULL);
    cout.tie(NULL);
	ll t = 1;
	//cin>>t;
	rep(i, t)
	{
		solve();
	}
	return 0;	
}

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

void solve(long long N, long long D, std::vector<long long> X, std::vector<long long> Y) {
    ll ans = 0;
    rep(i, N) {
        if (sqrt(X[i] * X[i] + Y[i] * Y[i]) <= D) {
            ans++;
        }
    }
    cout << ans << endl;
}

int main() {
    long long N;
    scanf("%lld", &N);
    long long D;
    scanf("%lld", &D);
    std::vector<long long> X(N);
    std::vector<long long> Y(N);
    for (int i = 0; i < N; i++) {
        scanf("%lld", &X[i]);
        scanf("%lld", &Y[i]);
    }
    solve(N, D, std::move(X), std::move(Y));
    return 0;
}


Measured memory_bytes: 6488
#include <algorithm>
#include<iostream>
#include<vector>
#include<deque>
#include<queue>
#include<stack>
#include<list>
#include<map>
#include<set>
#include<string>
#include <sstream>
#include<bitset>

#include<stdlib.h>
#include<string.h>
#include<math.h>
#include<limits.h>
const int INF = 0x7fffffff;
using lll = long long;
using ull = unsigned long long;
using namespace std;


int main(){
  lll ii,jj,kk;
  vector<int> ret;

  int x,n;
  //  vector<int> p;

  cin >> x >> n;
  set<int> p;
  //p.resize(n);
  int a;
  for(ii=0;ii<n;ii++){
    cin >> a;
    p.insert(a);
  }

  //sort(p.begin(),p.end());

//  for(ii=0;ii<n;ii++){
//
//  }

  int ans;
  for(ii=0;ii<=101;ii++){
    if(p.find(x - ii) == p.end()){
      ans = x-ii;
      break;
    }
    if(p.find(x + ii) == p.end()){
      ans = x+ii;
      break;
    }
  }

  cout << ans;
  return 0;
}


Measured memory_bytes: 3628
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<double> vd;
typedef vector<long long> vll;
typedef vector<string> vs;
typedef vector<bool> vb;
typedef pair<int, int> pii;
struct cww{cww(){ios::sync_with_stdio(false);cin.tie(0);}}star;
#define all(c) (c).begin(), (c).end()
#define rall(c) (c).rbegin(), (c).rend()
#define vv(type, c, m, n, i) vector<vector<type>> c(m, vector<type>(n, i))
#define mat(type, c, m, n) vector<vector<type>> c(m, vector<type>(n));for(auto& r:c)for(auto& i:r)cin>>i;
#define rep(i,a,n) for(int i=(a), i##_len=(n); i<i##_len; ++i)
#define rrep(i,a,n) for(int i=(a), i##_len=(n); i>i##_len; --i)
#define each(x,y) for(auto &(x):(y))
#define var(type, ...)type __VA_ARGS__;Scan(__VA_ARGS__);
template<typename T> void Scan(T& t) { cin >> t; }
template<typename First, typename...Rest>void Scan(First& first, Rest&...rest) { cin >> first; Scan(rest...); }
#define vec(type, c, n) vector<type> c(n);for(auto& i:c) cin>>i;
#define len(x) ((int)(x).size())
#define mp make_pair
#define eb emplace_back
#define em emplace
#define pb pop_back
#define fi first
#define se second
#define get(a, i) get<i>(a)
#define bit_count __builtin_popcount
#define mt make_tuple
inline string zero(int a,string s,char c='0'){return string(a-len(s),c)+s;}
inline string zero(int a,int t,char c='0'){return zero(a, to_string(t), c);}
inline string zero(int a,ll t,char c='0'){return zero(a, to_string(t), c);}
#define mini min_element
#define maxi max_element
#define sum accumulate
#define chmax(a,b) if(a<b)a=b
#define chmin(a,b) if(a>b)a=b
template <class T> inline void print(T t){cout << t << '\n';}
template <class H, class... T> inline void print(H h, T... t){cout << h << " ";print(t...);}
void solve() {
	var(string, s);
	string ans = "";
	rep(i, 0, 1 << 3) {
		int cnt = s[0] - '0';
		ans = s[0];
		rep(j, 0, 3) {
			if (i >> j & 1) {
				ans += '+';
				cnt += s[j + 1] - '0';
			} else {
				ans += '-';
				cnt -= s[j + 1] - '0';
			}
			ans += s[j + 1];
		}
		if (cnt == 7)
			break;
	}
	print(ans + "=7");
}
int main() {
	solve();
	return 0;
}


Measured memory_bytes: 256
function main(input) {
    const args = input.split('\n');
    const [H, W] = args[0].split(' ');

    let iArray = new Array(H);
    for(let i = 0; i < H; i++) {
        iArray[i] = args[i+1];
    }

    for(let i = 0; i < H; i++) {
        console.log( iArray[i] );
        console.log( iArray[i] );
    }
}

main( require('fs').readFileSync('/dev/stdin', 'utf8') );

Measured memory_bytes: 29824
s = input()
cnt = 0

if s[0] == 'A':
    for i in s[2:-1]:
        if i == 'C':
            cnt += 1
    if cnt == 1:
        s = s.replace('A', '')
        s = s.replace('C', '')
        if s.islower() and ('C' not in s):
            print('AC')
            exit()
print('WA')

Measured memory_bytes: 3060
#include<stdio.h>
#include<string.h>
#include<assert.h>

#define MAX 1000003
#define len 14

char T[MAX][len];

int getChar(char c){
  if (c == 'A') return 1;
  else if (c == 'C') return 2;
  else if (c == 'G') return 3;
  else if (c == 'T') return 4;
}

int getKey(char str[]){
  int sum = 0, p = 1, i;
  for (i=0;i<strlen(str);i++){
    sum += p*(getChar(str[i]));
    p *= 5;
  }
  return sum;
}
int hash1(int key){
  return key%MAX;
}
int hash2(int key){
  return 1+key%(MAX-1);
}
int search(char str[]){
  int key = getKey(str);
  int i, j;

  for(i=0;i<MAX;i++){
    //    j=(hash1(key)+i*hash2(key))%MAX;
    j=((hash1(key)+i*hash2(key))&0x7fffffff)%MAX;
    if(strcmp(str, T[j])==0)return 1;
    if(T[j][0]=='\0') break;

  }
  return 0;
}

int insert(char str[]){
  int key = getKey(str);
  int i, j;
  for(i=0;T[j]=='\0'||i<MAX;i++){
    j=((hash1(key)+i*hash2(key))&0x7fffffff)%MAX;
    //   j=(hash1(key)+i*hash2(key))%MAX;
    if(T[j][0]=='\0'){
      strcpy(T[j], str);
      return 1;
    }
  }
  return 0;
}

int main(){
  int i,n;
  char com[8],str[len];
  for (i=0;i<MAX;i++) T[i][0] = '\0';
  scanf("%d",&n);

  for (i=0;i<n;i++){
    scanf("%s %s",com,str);
    if (com[0]=='i'){
      insert(str);
    } else {
      if (search(str)){
	printf("yes\n");
      } else {
	printf("no\n");
      }
    }
  }
  return 0;
}

Measured memory_bytes: 14280
#define _CRT_SECURE_NO_WARNINGS
#include<iostream>
#include<cstdio>
#include<string>
#include<algorithm>
#include<cmath>
using namespace std;

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

long long CalcSS(long long H, long long W) {
	long long ans = 20000000010;
	long long S1, S2, S3;
	long long halfH = H / 2;
	long long maxn, minn;

	//最初に縦に線を入れて，次に横に割る場合
	for(int i = 1; i < W; i++) {//横に走査
		S1 = H * i;

		S2 = (W - i) * halfH;
		S3 = (W - i) * (H - halfH);

		maxn = max(S1, max(S2, S3));
		minn = min(S1, min(S2, S3));
		ans = min(ans, maxn - minn);
	}

	//最初に横に線を入れて，次に横に割る場合
	for (int i = 1; i < H - 1; i++) {//縦に走査
		S1 = W * i;

		halfH = (H - i) / 2;
		S2 = W * halfH;
		S3 = W * (H - halfH - i);

		maxn = max(S1, max(S2, S3));
		minn = min(S1, min(S2, S3));
		ans = min(ans, maxn - minn);
	}

	return ans;
}

int main() {
	long long H, W;
	cin >> H >> W;
	long long ans;

	if (H == W) ans = CalcSS(H, W);
	else ans = min(CalcSS(H, W), CalcSS(W, H));

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

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define MAX_N 100001
#define INF_INT 2147483647
#define INF_LL 9223372036854775807
#define REP(i,COUNT) for(int i=0;i<(int)(COUNT);i++)
typedef long long ll;
#define MOD 1000000007
ll dp[1001][1001];
int main()
{
  ll H,W;
  char a[1001][1001];
  
  REP(i,1001)REP(j,1001)dp[i][j] = 0;
  cin >> H >> W;
  dp[1][1] = 1;
  REP(i,H)cin >> a[i];
  for(int i=1;i<=H;i++){
    for(int j=1;j<=W;j++){
      if(i == j && i == 1)
        continue;
      if(a[i-1][j-1] == '#'){
        dp[i][j] = 0;
      }else{
        dp[i][j] = (dp[i-1][j]+ dp[i][j-1])%MOD;
      }
    }
  }
  cout << dp[H][W] << endl;
  return 0;
}



Measured memory_bytes: 9088
#include <iostream>
#include <string>
#include <cstdio>
#include <algorithm>
#include <cstdlib>
#include <cmath>
#include <vector>
#include <utility>
#include <queue>
#include <deque>
#include <stack>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <bitset>
using namespace std;
#define INF 1000000007
#define LINF 8000000000000000007
#define MOD 1000000007
#define int long long
#define rep(i, n) for (int i = 0; i < (n); i++)
#define repb(i, n) for (int i = n - 1; i >= 0; i--)
#define MODE 1
#ifdef MODE
#define DEB(X) cout << #X << ": " << X << " ";
#define ARDEB(i, X) cout << #X << "[" << i << "]: " << X[i] << " ";
#define END cout << endl;
#else
#define DEB(X) \
    {          \
    }
#define ARDEB(i, X) \
    {               \
    }
#define END \
    {       \
    }
#endif
typedef pair<int, int> P;
struct edge{int to,cost;};

typedef long long ll;

using namespace std;

int ans,ans2;
int n,m;
string s[111111];

signed main(){

    cin>>n;
    rep(i,n){
        cin>>s[i];
        sort(s[i].begin(),s[i].end());
    }
    sort(s,s+n);
    int co=0;
    s[n]="111";
    rep(i,n){
        if(s[i]==s[i+1])co++;
        else{
            co++;
            ans+=co*(co-1)/2;
            co=0;
        }
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 7424
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <math.h>
#include <iomanip>
#include <map>
using namespace std;

#define INF 1e9
#define LLINF 1e18
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
typedef long long ll;

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


int main() {
    int k, s;
    cin >> k >> s;
    int ans = 0;
    for (int i = 0; i <= k; i++) {
        for (int j = i; j <= k; j++) {
            for (int h = j; h <= k; h++) {
                if (i + j + h == s) {
                    if (i == j && j == h) ans++;
                    else if (i != j && j != h && h != i) ans += 6;
                    else ans += 3;
                }
            }
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
from bisect import bisect_left,bisect_right
p=10**9+7
n,k=map(int,input().split())
a=sorted(list(map(int,input().split())))
pi=1
ni=0
ans=1
i=0
while i<k-1:
  if a[ni]*a[ni+1]>a[-pi]*a[-pi-1]:
    ans=ans*a[ni]*a[ni+1]%p
    ni+=2
    i+=2
  else:
    ans=ans*a[-pi]%p
    pi+=1
    i+=1
if i==k-1:
  ans=ans*a[-pi]%p
if a[-1]<0 and k%2==1:
  ans=1
  for i in a[n-k:]:
    ans=ans*i%p
print(ans)

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

const int Mod = 1000000007;
class mll {
public:
	long long x;
	mll(long long x = 0) : x((x% Mod + Mod) % Mod) {};
	void operator += (const mll& a) {
		if ((x += a.x) >= Mod) x -= Mod;
	}
};

int main() {
	int N;
	cin >> N;
	vector<mll> before(64, 1), now(64, 0);
	before[0 * 16 + 2 * 4 + 1] = 0;
	before[0 * 16 + 1 * 4 + 2] = 0;
	before[2 * 16 + 0 * 4 + 1] = 0;
	string s = "ACGT";
	for (int i = 3; i < N; i++) {
		for (int a = 0; a < 4; a++) {
			for (int b = 0; b < 4; b++) {
				for (int c = 0; c < 4; c++) {
					now[a * 16 + b * 4 + c] = 0;
					if (a == 0 && b == 2 && c == 1) continue;
					if (a == 2 && b == 0 && c == 1) continue;
					if (a == 0 && b == 1 && c == 2) continue;
					for (int d = 0; d < 4; d++) {
						if (d == 0 && a == 2 && b == 1) continue;
						if (d == 2 && a == 0 && b == 1) continue;
						if (d == 0 && a == 1 && b == 2) continue;
						if (d == 0 && b == 2 && c == 1) continue;
						if (d == 0 && a == 2 && c == 1) continue;
						now[a * 16 + b * 4 + c] += before[d * 16 + a * 4 + b];
					}
				}
			}
		}
		for (int i = 0; i < 64; i++) before[i] = now[i];
	}
	mll ans = 0;
	for (int i = 0; i < 64; i++) ans += before[i];
	cout << ans.x << endl;
}


Measured memory_bytes: 3632
#include <bits/stdc++.h>
#define mp make_pair
#define pb push_back
#define all(x) x.begin(),x.end()
#define cmin(a,b) (a>b?a=b:a)
#define cmax(a,b) (a<b?a=b:a)
#define mem(a,k) memset(a,k,sizeof(a))
#define lop(i,s,t) for(int i=s;i<(t);++i)
#define rep(i,s,t) for(int i=s;i<=(t);++i)
#define dec(i,s,t) for(int i=s;i>=(t);--i)
#define fore(i,v) for(int i=g[v],d=es[i].d;i;i=es[i].nxt,d=es[i].d)
using namespace std;
 
#define Pr(f,...) fprintf(stderr,f,##__VA_ARGS__),fflush(stderr)
 
typedef long long ll;
 
template<typename T>
void read(T &x){
	x=0; 
	char c;
	for(c=getchar();!isdigit(c);c=getchar()); 
	for(;isdigit(c);c=getchar())x=x*10+c-'0'; 
}
 
/*
const int N=,P=;
 
int mul(int a,int b){ return 1ll*a*b%P; }
int add(int a,int b){ a+=b; return a>=P?a-P:a; }
int sub(int a,int b){ a-=b; return a<0?a+P:a; }
int gcd(int a,int b){ return !b?a:gcd(b,a%b); }
*/
 
ll calc(ll a,ll b){
	if(a>b){ return a*(a+1)/2+b*(b-1)/2; }
	else return b*(b+1)/2+a*(a-1)/2;
}
int main(int argc,char *argv[]){
#ifdef CURIOUSCAT
	//freopen("d.in","r",stdin);
#endif
	string s;
	cin>>s;
	ll cl=0,cr=0,ans=0;
	for (char c:s){
		if(c=='<'){
			if(!cr)++cl;
			else if(cr){
				ans+=calc(cl,cr);
				cl=1,cr=0;
			}
		}else ++cr;
	}
	if(cl||cr)ans+=calc(cl,cr);
	printf("%lld\n",ans);
	return 0;
}




Measured memory_bytes: 900
#include <bits/stdc++.h>
#define N 301
using namespace std;
typedef complex <double> P;
const double EPS = 1e-8;
P p[N];
int n;

int cnt(P c){
  int res=0;
  for(int i=0;i<n;i++)if(abs(c-p[i])<1+EPS) res++;
  return res;
}

P get_C(P a,P b){
  double x=abs(b-a);
  return P(x/2,sqrt(1-x*x/4))*(b-a)/abs(b-a)+a;  
}


int main(){
  while(1){
  cin>>n;
  if(!n)break;
  double a,b;
  for(int i=0;i<n;i++)cin>>a>>b,p[i]=P(a,b);
  
  int ans=1;
  for(int i=0;i<n;i++)
    for(int j=i+1;j<n;j++)
      if(abs(p[i]-p[j])<=2){
	ans=max(ans,cnt(get_C(p[i],p[j])));
	ans=max(ans,cnt(get_C(p[j],p[i])));
      }
  cout <<ans<<endl;  
  }
  return 0;
}

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

using namespace std;

#define FOR0(i, a, b, s) for (int i = a; s > 0 ? i < b : i > b; i += s)
#define FOR1(n) FOR0(i, 0, n, 1)
#define FOR2(i, n) FOR0(i, 0, n, 1)
#define FOR3(i, a, b) FOR0(i, a, b, 1)
#define FOR4(i, a, b, s) FOR0(i, a, b, s)
#define GET5(_1, _2, _3, _4, _5, ...) _5
#define FOR(...) GET5(__VA_ARGS__, FOR4, FOR3, FOR2, FOR1)(__VA_ARGS__)

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n;
  cin >> n;
  vector<int> a(n);
  FOR(n) cin >> a[i];
  long long mon = 1000;
  long long sto = 0;
  FOR(n - 1) {
    if (a[i] < a[i + 1]) {
      sto += mon / a[i];
      mon -= mon / a[i] * a[i];
    } else if (a[i] > a[i + 1]) {
      mon += sto * a[i];
      sto = 0;
    }
  }
  mon += sto * a[n - 1];
  cout << mon << '\n';
  return 0;
}

Measured memory_bytes: 3652
#include <iostream>
#include <string>

using namespace std;

int  main(){
    int n,sum=0;
    cin >> n;
    int l[n],r[n];
    for(int i=0;i<n;i++){
        cin >> l[n] >> r[n];
        sum +=  r[n]-l[n]+1;
    }
    cout << sum << endl;
    return 0;
}

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

#define ff first
#define ss second
#define mp(a,b) make_pair(a,b)
#define pb(a) push_back(a)
#define boost ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define debug(x) cout << #x << " : " << (x) << endl
#define all(v) v.begin(),v.end() 
#define allr(v) v.rbegin(),v.rend() 
//#define endl '\n'  
typedef  long long ll; 
typedef  unsigned long long ull; 
typedef vector< ll > edge; 
typedef pair< ll , ll > mypair;
typedef priority_queue <ll> max_heap;
typedef priority_queue <ll, vector<ll>, greater<ll> > min_heap;
const ll mod=1000000007;
const ll inf=1e15;
const ll N=2e5+10;

int main()
{
  boost;
  ll a,b;
  cin>>a>>b;
  if(a>=13) cout<<b;
  else if(a>=6) cout<<b/2;
  else cout<<"0";
  return 0;
}

Measured memory_bytes: 256
#include <map>
#include <algorithm>
#include <iostream>
#include <vector>
#include <string>
#define rep(i,n) for(int i=0;i<n;i++)

//abbreviations
typedef long long ll;
#define vi vector<int>
#define vl vector<ll>
#define vs vector<string>
#define vb vector<bool>
#define vvi vector<vector<int>>

using namespace std;

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

    sort(A.begin(), A.end());
    bool flag = true;
    rep(i, N-1){
        if(A[i]==A[i+1]){
            cout << "NO" << endl;
            flag = false;
            break;
        }
    }
    if(flag){
        cout << "YES" << endl;
    }

    return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<b;i++)
#define per(i,b,a) for(int i=b;i>=a;i--)
#define For(i,a,b) for(int i=a;i<=b;i++)
#define Forenska(it,c) for(__typeof((c).begin()) it=(c).begin();it!=(c).end();it++)
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define fi first
#define se second
#define all(x) x.begin(),x.end()
#define sqr(x) ((x)*(x))
#define lowbit(x) ((x)&(-x))
#define GREATER(x) x,vector<x>,greater<x>
#define randIn(L,R) (((LL)rand()*rand())%(R-L)+L)
#define __lcm(a,b) ((a)/__gcd(a,b)*(b))
using namespace std;
typedef long long LL;
typedef pair<int,int> pii;
typedef pair<LL,LL> pLL;
typedef vector<int> vec;
typedef vector<LL> vecL;
typedef vector<pii> vecP;
typedef vector<pLL> vecPL;
typedef vector<string> vecS;
typedef vector<vec> mat;
typedef complex<double> point;
const long double PI=3.14159265358979323846264338327950288419716939937510582097;
const LL INFLL=0x3f3f3f3f3f3f3f3f;
const int INF=0x3f3f3f3f;
const long double EPS=1e-10;
int read()
{
    int x=0;
    char ch=' ';
    bool flag=false;
    while(ch<'0' || ch>'9')
    {
        if(ch=='-')flag=true;
        ch=getchar();
    }
    while(ch>='0' && ch<='9')
    {
        x=(x<<3)+(x<<1)+ch-'0';
        ch=getchar();
    }
    return flag?-x:x;
}
const int MAX_N=200005;
LL a[MAX_N],sum[MAX_N]; 
int n;
int main()
{
	cin>>n;
	For(i,1,n)
	{
		cin>>a[i];
		sum[i]=sum[i-1]+a[i];
	}
	LL ans=INF;
	int x=0,y=0;
	For(i,2,n-2)
	{
		while(sum[x+1]*2<=sum[i])x++;
		while(sum[y+1]-sum[i]<=sum[n]-sum[y+1])y++;
		For(j,0,1)
		{
			For(k,0,1)
			{
				ans=min(ans,max({sum[x+j],sum[i]-sum[x+j],sum[y+k]-sum[i],sum[n]-sum[y+k]})-min({sum[x+j],sum[i]-sum[x+j],sum[y+k]-sum[i],sum[n]-sum[y+k]}));
			}
		} 
	}
	cout<<ans<<endl;
	return 0;
}



Measured memory_bytes: 3328
#include <iostream>
#include <string>
#include <cmath>
#include <algorithm>
using namespace std;

#define Rep(i, n) for(int i = 0; i < (int)(n); i++)
#define PrintLn(X) cout << X << endl

typedef long long ll;

int main(void)
{
	int N, M;
	cin >> N >> M;

	ll ans = 1;
	Rep(i, M) ans *= 2;
	ans *= (1900 * M + 100 * (N - M));

	PrintLn(ans);
	return 0;
}


Measured memory_bytes: 256
import bisect
N = int(input())
lsA = list(map(int,input().split()))
lsB = list(map(int,input().split()))
lsC = list(map(int,input().split()))
lsA.sort()
lsB.sort()
lsC.sort()
ans = 0
for i in range(N):
    B = lsB[i]
    indexA = bisect.bisect(lsA,B-1)
    indexC = N - bisect.bisect(lsC,B)
    ans += indexA*indexC
print(ans)

Measured memory_bytes: 29560
#include<cstdio>
#include<algorithm>
#include<cstring>
using namespace std;
int sum[400005],lazy[400005],n,m;;
struct obj
{
    int l,r;
}p[300005];
bool cmp(obj x,obj y)
{
    return x.r-x.l<y.r-y.l;
}
void push_down(int k,int l,int r)
{
    if(l==r)
    {
        sum[k]+=lazy[k];
    }
    else
    {
        lazy[k<<1]+=lazy[k];
        lazy[k<<1|1]+=lazy[k];
        sum[k]+=lazy[k]*(r-l+1);
    }
    lazy[k]=0;
}
void change(int k,int l,int r,int x,int y,int w)
{
    if(l>=x&&r<=y)
    {
        lazy[k]+=w;
    }
    else
    {
        push_down(k,l,r);
        int mid=(l+r)>>1;
        if(!(y<l||x>mid))
        {                 
            change(k<<1,l,mid,x,y,w);
        }             
        if(!(y<mid+1||x>r))
        {                
            change(k<<1|1,mid+1,r,x,y,w);
    	}
    }
}
int query(int k,int l,int r,int x)
{
    push_down(k,l,r);
    if(l==r)
    {
        return sum[k];
    }
    int mid=(l+r)>>1;
    if(x<=mid)
    {
        return query(k<<1,l,mid,x);
    }
    return query(k<<1|1,mid+1,r,x);
}
int main()
{
    scanf("%d%d",&n,&m);
    for(int i=0;i<n;i++)
    {
        scanf("%d%d",&p[i].l,&p[i].r);
    }
    int i=0;
    sort(p,p+n,cmp);
    for(int d=1;d<=m;d++)
    {
        while(i<n&&p[i].r-p[i].l<d)
        {
            change(1,1,m,p[i].l,p[i].r,1);
            i++;
        }
        int ans=n-i;
        for(int k=d;k<=m;k+=d)
        {
            ans+=query(1,1,m,k);
        }
        printf("%d\n",ans);
    }
    return 0;
}

Measured memory_bytes: 5760
import math

def comb(n, r, mod):
    return math.factorial(n + r - 1)//(math.factorial(n - 1)*math.factorial(r))%mod

s = int(input())
mod = 10**9 + 7
ans = 1

if s < 3:
    ans = 0

for i in range(2, 700): #分割数, 1の時は1通りなので除外
    if s/i < 3:
        break
    r = s - i*3
    ans = (ans + comb(i, r, mod))%mod

print(ans)

Measured memory_bytes: 9196
#include<iostream>
using namespace std;
long long int gcd(long long int a, long long int b)// greatest common divisor 
{
	if (b == 0) {
		return a; 
	}
	return gcd(b, a%b);
}

long long int lcm(long long int a, long long int b)// least common multiple
{
	return a * b / gcd(a, b);
}

int main() {
	long long int a, b;
	while (cin>>a>>b) {
		cout << gcd(a, b) << ' ' << lcm(a, b)<<'\n';
	}
	return 0;
}

Measured memory_bytes: 3012
#include <iostream>
#include <cmath>
#include <iomanip>
#include <vector>
#include <stack>
#include <queue>
#include <list>
#include <map>
#include <set>
#include <bitset>
#include <string>
#include <algorithm>
#include <iterator>
#include <unordered_map>
#include <unordered_set>
#include <sstream>

using namespace std;

#define fori(t) for(int i = 0; i < t; ++i)
#define forj(n) for(int j = 0; j < n; ++j)
#define fork(n) for(int k = 0; k < n; ++k)
#define forai(a) for(auto i : a)
#define foraj(a) for(auto j : a)
#define forak(a) for(auto k : a)
#define forp(s, n, d) for(int p = s; p < n; p += d)
#define fast cin.tie(0); cout.tie(0); std::ios_base::sync_with_stdio(0);
#define pb(a) push_back(a);
#define pob(a) pop_back(a);
#define sorti(a) sort(a.begin(), a.end());
#define sortm(a, n) sort(a, a + n);
#define fi first
#define se second
#define yes cout << "YES\n";
#define no cout << "NO\n";
#define ans(a) cout << a << '\n';
#define res(a, n) a.resize(n);
#define read(a, n) a.resize(n); fori(n) cin >> a[i];
//#define int long long

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> ii;
typedef pair<long long, long long> llll;
typedef vector<int> vi;
typedef vector<long long> vll;
typedef vector<pair<int, int>> vii;
typedef vector<pair<long long, long long>> vllll;
typedef vector<vector<int>> vvi;
typedef vector<bool> vb;
typedef pair<char, char> cc;
typedef pair<pair<char, char>, char> ccc;
typedef vector<char> vc;
typedef pair<int, char> ic;
typedef pair<ii, char> iic;
typedef vector<bool> vb;

const int INF = 2147483647;
const ll LONGINF = 9223372036854775807;
const ll MOD = 998244353;

int gcd(int a, int b)
{
    while (a * b != 0)
    {
        if (a > b) a %= b;
        else b %= a;
    }
    return a + b;
}

void solve()
{
    int K;
    cin >> K;
    ll res = 0;
    fori(K)
    {
        forj(K)
        {
            fork(K)
            {
                res += gcd(i + 1, gcd(j + 1, k + 1));
            }
        }
    }
    ans(res)
}

signed main()
{
    fast
    bool mult = false;
    if (mult)
    {
        int t;
        cin >> t;
        while (t--) solve();
    }
    else solve();
}


Measured memory_bytes: 3636
#include <cstdio>
#include <set>
#include <algorithm>

int n, k;
std::set<int> set({0, 1, 2, 3, 4, 5, 6, 7, 8, 9});

int solve(int v, int depth)
{
  if (v >= n) return v;
  
  int min = 1e9;
  for (int d : set)
  {
    if (d == 0 && depth == 0) continue;
    min = std::min(min, solve(v * 10 + d, depth + 1));
  }
  return min;
}

int main()
{
  scanf("%d%d", &n, &k);
  for (int i = 0; i < k; ++i)
  {
    int a;
    scanf("%d", &a);
    set.erase(a);
  }
  printf("%d\n", solve(0, 0));
  return 0;
}

Measured memory_bytes: 256
/* Author: $%U%$
 * Time: $%Y%$-$%M%$-$%D%$ $%h%$:$%m%$:$%s%$
**/
#include <bits/stdc++.h>
using namespace std;
#define fore(i, a, b) for (int i = a, to = b; i < to; i++)
#define foref(i, a, b) for (int i = b - 1, to = a; i >= to; i--)
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()
#define SZ(v) (int)v.size()
#define pb push_back
typedef long long Long;
typedef pair<int, int> Pair;
bool vis[102];
void solve() {
  int x, n;
  cin >> x >> n;
  fore(i, 0, n) {
    int num;
    cin >> num;
    vis[num] = 1;
  }
  int mini = 200;
  int ans = -1;
  fore(i, 0, 102) {
    if (!vis[i]) {
      if (abs(i - x) < mini) {
        mini = abs(i - x);
        ans = i;
      }
    }
  }
  cout << ans << '\n';
}
int main() {
  ios::sync_with_stdio(0);
  cin.tie(NULL);
  int t = 1;
  //cin >> t;
  while (t--) solve();

  return 0;
}

Measured memory_bytes: 3652
#include <iostream>

using namespace std;

int main() {
  string number;
  cin >> number;
  int count = 0;
  if (number[0] == '1') {
    count++;
  }
  if (number[1] == '1') {
    count++;
  }
  if (number[2] == '1') {
    count++;
  }
  cout << count << endl;
}


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

static int try_attack(long long a, long long b, int ntry, int num, long long list[]);

int main(int argc, char *argv[])
{
    int n, i;
    long long list[100000] = {0}, a, b;
    int max = 1000000000, min = 0, v, ntry = 0;

    scanf("%d %d %d\n", &n, &a, &b);
    for ( i = 0; i < n; i++ ){
        scanf("%d\n", &v);
        list[i] = v;
    }

    do {
        ntry = (max + min)/2;
        if ( try_attack(a, b, ntry, n, list) == 0 ){
            min = ntry;
        } else {
            max = ntry;
        }
        if ( max - min < 10 ){
            break;
        }
    } while(1);

    for ( i = min; i <= max; i++ ){
        if ( try_attack(a, b, i, n, list) ){
            printf("%d\n", i);
            break;
        }
    }

    return 0;
}

static int try_attack(long long a, long long b, int ntry, int num, long long list[])
{
    long long tmp[100000];
    int i, add = ntry;

    if ( num < 0 ){
        return 0;
    }

    memcpy(tmp, list, sizeof(tmp));
    for ( i = 0; i < num; i++ ){
        tmp[i] -= (b*ntry);
        if ( tmp[i] > 0 ){
            if ( tmp[i] % (a-b) == 0 ){
                add -= (tmp[i]/(a-b));
            } else {
                add -= (tmp[i]/(a-b) + 1);
            }
            if ( add < 0 ){
                return 0;
            }
        }
    }
    return 1;
}

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

using ll = long long int;
int main()
{
	ll n, x, m; cin >> n >> x >> m;
	vector<int> parent(m+1);
	for(int i = 0; i <=m; ++i) parent[i] = i;
	ll pre = x;
	ll remain = n - 1;
	parent[x] = -1;
	ll ans = x;
	while(remain)
	{
		ll next = (pre * pre) % m;

		if(parent[next] == next)
		{
			parent[next] = pre;
		}
		else
		{
			break;
		}
		
		ans += next;
		--remain;
		pre = next;
	}
	if(!remain) cout << ans;
	else
	{
		//find length of cycle;
		
		ll cycleLen = 1;
		ll cycleTotal = pre;
		ll startPos = pre;
		ll next = (pre * pre) % m;

		while(next != startPos)
		{
			cycleTotal += next;
			next = (next * next) % m;
			++cycleLen;
		}
		ll times = remain / cycleLen;
		remain = remain % cycleLen;
		ans += (cycleTotal * times);

		next = (next * next) % m;
		while(remain)
		{
			ans += next;
			next = (next * next) % m;
			--remain;
		}
		cout << ans;
	}

	return 0;
}

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

using namespace std;
using ll = long long;

#define rep(i, n) for (int i = 0; i < (int)(n); ++i)

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

  int sum = 0;
  rep(i, m) {
    int a;
    cin >> a;
    sum += a;
  }

  if (sum > n) {
    cout << -1 << endl;
  } else {
    cout << n - sum << endl;
  }
  return 0;
}


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

using namespace std;
using ll = long long;
using Graph = vector<vector<int>>;
using pint = pair<int, int>;
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};
const int MOD = 1000000009;
const long long INF = 1LL << 60;

int main() {
    string S, T;
    cin >> S >> T;
    ll res = INF;
    for (int i = 0; i < S.length(); ++i) {
        if (i + T.length() > S.length()) break;
        ll tmp = 0;
        for (int j = 0; j < T.length(); ++j) {
            if (S[i + j] != T[j]) ++tmp;
        }
        res = min(res, tmp);
    }
    cout << res << endl;
    return 0;
}

Measured memory_bytes: 3624
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
int acs(const void *x, const void *y) { 
  return *(int*)x - *(int*)y;
} /* 1,2,3,4.. */
int des(const void *a, const void *b) {
  return *(int*)b - *(int*)a;
} /* 8,7,6,5.. */
int cmp_char(const void *a, const void *b) { 
  return *(char*)a - *(char*)b;
} /* a,b,c,d.. */
int cmp_str(const void *a, const void *b) {
  return strcmp(*(const char **)a, *(const char **)b);
} /* aaa,aab.. */
#define min(a,b) (a < b ? a : b)
#define max(a,b) (a > b ? a : b)
#define rep(i, l, r) for (int i = l; i < r; i++)
#define MAX 100001
#define MOD 1000000007
#define INF 1000000009
typedef long long int lli;

int main(void) {
	int n, m;
	scanf("%d %d", &n, &m);
	int h[MAX], a[MAX], b[MAX];
	rep(i, 1, n+1) scanf("%d", &h[i]);
	rep(i, 0, m) scanf("%d %d", &a[i], &b[i]);

	int maxh[MAX] = {0};
	rep(i, 0, m) {
		maxh[a[i]] = max(h[b[i]], maxh[a[i]]);
		maxh[b[i]] = max(h[a[i]], maxh[b[i]]);
	}
	int ans = 0;
	rep(i, 1, n+1) if (maxh[i] < h[i]) ans++;
	printf("%d\n", ans);
  return 0;
}


Measured memory_bytes: 3296
#include <cstdio>

bool dp[1<<16] = {false};
int n;

int main(){
	for(int i = 2; i < (1<<16); i++){
		if(!dp[i]){
			for(int j = i*2; j < (1<<16); j += i){
				dp[j] = true;
			}
		}
	}

	while(scanf("%d",&n), n!= 0){
		int ans = 0;
		for(int i = 2; i <= n / 2; i++){
			if(!dp[i] && !dp[n-i]){
				ans++;
			}
		}
		printf("%d\n",ans);
	}
	return 0;
}

Measured memory_bytes: 2804
#include<algorithm>//sort,二分探索,など
#include<bitset>//固定長bit集合
#include<cmath>//pow,logなど
#include<complex>//複素数
#include<deque>//両端アクセスのキュー
#include<functional>//sortのgreater
#include<iomanip>//setprecision(浮動小数点の出力の誤差)
#include<iostream>//入出力
#include<map>//map(辞書)
#include<numeric>//iota(整数列の生成),gcdとlcm(c++17)
#include<queue>//キュー
#include<set>//集合
#include<stack>//スタック
#include<string>//文字列
#include<unordered_map>//イテレータあるけど順序保持しないmap
#include<unordered_set>//イテレータあるけど順序保持しないset
#include<utility>//pair
#include<vector>//可変長配列
using namespace std;

typedef long long ll;

//マクロ
#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=(ll)(n)-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=(a);i<=(b);i++)
#define FORD(i,a,b) for(ll i=(a);i>=(b);i--)
#define ALL(x) (x).begin(),(x).end() //sortなどの引数を省略したい
#define SIZE(x) ((ll)(x).size()) //sizeをsize_tからllに直しておく
#define MAX(x) *max_element(ALL(x))
#define INF 1000000000000 //10^12
#define MOD 10000007 //10^9+7
#define MAXR 100000 //10^5:最大のrange(素数列挙などで使用)


int main(void){
    int n;
    cin >> n;
    string s;
    cin >> s;
    vector<int> a, b, c;
    REP(i, n) {
        if(s[i] == 'R') a.push_back(i+1);
        if(s[i] == 'G') b.push_back(i+1);
        if(s[i] == 'B') c.push_back(i+1);
    }
    ll sum = a.size()*b.size()*c.size();
    
    //とびとびのものを数えて引く
    for(int i=1; i<n; i++) {
        for(int j=0; j+i+i<n; j++) {
            if(s[j] == s[j+i] || s[j+i] == s[j+i+i] || s[j] == s[j+i+i]) continue;
            sum--;
        }
    }

    cout << sum << endl;
    return 0;
}


Measured memory_bytes: 3640
#include <iostream>
#include <algorithm>
#include <math.h>
#include <vector>
#include <string>
#include <queue>
#include <map>
#include <utility>
#include <iomanip>  // std::setprecision()
#include <set>

using namespace std;
using ll = long long;
#define rep(i,a,b) for(ll i=(a); i<(b); i++)
#define YES cout << "YES" << endl;
#define NO cout << "NO" << endl;
#define yes cout << "Yes" << endl;
#define no cout << "No" << endl;
#define pai 3.14159265358979323846
ll gcd(ll a, ll b){if (a%b == 0)  return(b);else  return(gcd(b, a%b));}
ll lcm(ll a, ll b){return a * b / gcd(a, b);}
/* map<string,int> */
/* 大文字を小文字に変換 tolower*/
/* 小文字を大文字に変換 toupper*/
/* 辞書順 next_permutation(a.begin(),a.end()) */
void printVec(std::vector<char> &vec) {
  std::cout << "";
  for (auto it = vec.begin(); it != vec.end(); ++it) {
    std::cout << *it << " ";
  }
  std::cout << std::endl;
}
 
int main() {
    vector <int> a(3);
    rep(i,0,3) {
        cin >> a[i];
    }
    int k;
    cin >>k;
    sort(a.begin(), a.end());
    rep(i,0,k) {
        a[2] *=2;
    }
    int sum =0;
    rep(i,0,3) {
        sum += a[i];
    }
    cout << sum << endl;
}

Measured memory_bytes: 3192
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rrep(i, n) for(int i = n-1; i >= 0; i--)
#define  all(x) (x).begin(),(x).end()     // 昇順ソート
#define  rall(v) (v).rbegin(), (v).rend() // 降順ソート
#define  FastIO ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0)
typedef long long ll;
using P = pair<int,int>;
using VI = vector<int>;
using VVI = vector<vector<int>>;
using VL = vector<ll>;
using VVL = vector<vector<ll>>;
using VP = vector<P>;
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return true; } return false; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return true; } return false; }

vector<vector<P>> g;
VI dist, visited;

bool dfs(int v, int dis){
    if (visited[v] == 1){
        if (dis != dist[v]){
            return true;
        }else{
            return false;
        }
    }

    visited[v] = 1;
    dist[v] = dis;

    for(P p: g[v]){
        if (dfs(p.first, dis + p.second)){
            return true;
        }
    }
    return false;
}

int main(){
    int n, m;
    cin >> n >> m;
    
    g.resize(n);
    dist.resize(n, -1);
    visited.resize(n, -1);

    rep(i,m){
        int l, r, d;
        cin >> l >> r >> d;
        l--; r--;
        g[l].emplace_back(r, d);
        g[r].emplace_back(l, -d);
    }

    rep(i,n){
        if (visited[i] != -1) continue;
        if (dfs(i, 0)){
            cout << "No" << endl;
            return 0;
        }
    }
    cout << "Yes" << endl;
    return 0;
}

Measured memory_bytes: 14456
n,m=map(int,input().split())
#約分
def make_divisors(n):  
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)
    # divisors.sort()
    return divisors
l=make_divisors(m)
l.sort()
a=[li for li in l if li >=n][0]
print(m//a)

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

using namespace std;
typedef long long ll;
const int N = 1e5+10;

int main() {
	int n,k;
	cin>>n>>k;
	int a=1;
	for(int x=0;x<n;x++){
		if(a*2<a+k){
			a*=2;
		}else{
			a+=k;
		}
	}
	cout << a << endl;
}

Measured memory_bytes: 256
from operator import itemgetter

N = int(input())
AB = [[int(x) for x in input().split()]for _ in range(N)]
sum_time = sum([a for a,b in AB])
AB.sort(key=itemgetter(0))
AB.sort(key=itemgetter(1),reverse=True)
for a,b in AB:
    if(sum_time>b):
        print('No')
        break
    else:
        sum_time-=a
else:
    print('Yes')


Measured memory_bytes: 97548
import java.lang.Math.*

fun main(args: Array<String>){
    val (N, K) = readLine()!!.split(" ").map { it.toInt() }
    val X = readLine()!!.split(" ").map { it.toLong() }

    var min = Long.MAX_VALUE / 10
    for(i in 0..N - K){
        min = min(min, abs(X[i]) + abs(X[i] - X[i + K - 1]))
        min = min(min, abs(X[i + K - 1]) + abs(X[i] - X[i + K - 1]))
    }
    println(min)
}

Measured memory_bytes: 51676
import sys
def input(): return sys.stdin.readline().rstrip()
def main():
    n,k=map(int,input().split())
    S=input()
    lis=[0]
    for i in range(1,n):
        if S[i-1]!=S[i]:
            lis.append(i)
    lis.append(n)
    len_lis=len(lis)
    ans=[]
    for i in range(len_lis-1):
        if S[lis[i]]=='0':
            ans.append(lis[min(i+2*k,len_lis-1)]-lis[i])
        else:
            ans.append(lis[min(i+2*k+1,len_lis-1)]-lis[i])
    print(max(ans))

if __name__=='__main__':
    main()

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


void solve(long long N, long long M, std::vector<long long> s, std::vector<long long> c){
    for(int i=0;i<1000;i++){
        bool isOk= true;
        for(int j=0;j<M;j++){
            if((i%(int)pow(10,N-s[j]+1))/(int)pow(10,N-s[j])!=c[j]){
                isOk = false;
            }
        }
       
        if(to_string(i).length() != N){
            continue;
        }    
        if(isOk){
            cout << i << endl;
            return;
        }
    }
    cout << -1 << 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(){
    long long N;
    scanf("%lld",&N);
    long long M;
    scanf("%lld",&M);
    std::vector<long long> s(M);
    std::vector<long long> c(M);
    for(int i = 0 ; i < M ; i++){
        scanf("%lld",&s[i]);
        scanf("%lld",&c[i]);
    }
    solve(N, M, std::move(s), std::move(c));
    return 0;
}


Measured memory_bytes: 256