akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <string>
#include <cstdio>
#include <algorithm>
#include <vector>
#include <cmath>
#include <array>
#include <queue>
#include <map>
#include <set>
#include <stack>
#include <cstdint>
#include <unordered_set>
#include <ctime>
#include <numeric>
#include <cstdint>

using llint = long long int;
using u64 = std::uint_fast64_t;

int read_from_B(const std::vector<llint> cumb, llint k){
  auto pt = std::upper_bound(cumb.begin(), cumb.end(), k);
  return pt - cumb.begin();
}

void solve(void){


  llint n, m, k;
  std::cin >> n >> m >> k;

  std::vector<llint> A(n), B(m);
  for(int i=0; i<n; i++){
    std::cin >> A[i];
  }
  for(int j=0; j<m; j++){
    std::cin >> B[j];
  }

  std::vector<llint> cumB(m);
  for(int i=0; i<m; i++){
    if(i==0) cumB[i] = B[i];
    else     cumB[i] = cumB[i-1] + B[i];
  }

  int j = read_from_B(cumB, k);
  int best = 0 + read_from_B(cumB, k);
  for(int i=0; i<n; i++){
    k-=A[i];
    if(k>=0){
      while(j>0){
        if(cumB[j-1] > k) j--;
        else break;
      }
      //std::cout << i << " " << j << std::endl;
      best = std::max(i+1+j, best);
    } else     break;
  }

  std::cout << best << std::endl;



}

int main(void){

  solve();

  return 0;
}






Measured memory_bytes: 9596
#include <bits/stdc++.h>
      
#define FOR(i,a,b) for( ll i = (a); i < (ll)(b); i++ )
#define REP(i,n) FOR(i,0,n)
#define YYS(x,arr) for(auto& x:arr)
#define ALL(x) (x).begin(),(x).end()
#define SORT(x) sort( (x).begin(),(x).end() )
#define REVERSE(x) reverse( (x).begin(),(x).end() )
#define UNIQUE(x) (x).erase( unique( ALL( (x) ) ) , (x).end() )
#define PW(x) (1LL<<(x))
#define SZ(x) ((ll)(x).size())
#define SHOW(x) cout << #x << " = " << x << endl
     
#define pb emplace_back
#define fi first
#define se second
     
using namespace std;

typedef long double ld;
typedef long long int ll;
typedef pair<int,int> pi;
typedef pair<ll,ll> pl;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<bool> vb;
typedef vector<ld> vd;
typedef vector<pi> vpi;
typedef vector<pl> vpl;
typedef vector<vpl> gr;
typedef vector<vl> ml;
typedef vector<vd> md;
typedef vector<vi> mi;
     
const ll INF = (ll)1e9 + 10;
const ll INFLL = (ll)1e18 + 10;
const ld EPS = 1e-12;
const ll MOD = 1e9+7;
     
template<class T> T &chmin( T &a , const T &b ){ return a = min(a,b); }
template<class T> T &chmax( T &a , const T &b ){ return a = max(a,b); }
template<class T> inline T sq( T a ){ return a * a; }

ll in(){ ll x; scanf( "%lld" , &x ); return x; }
char yuyushiki[1000010]; string stin(){ scanf( "%s" , yuyushiki ); return yuyushiki; }

// head


struct Mod{
  unsigned n;
  Mod() : n(0){}
  Mod( ll x ){
    if( x < 0 ) n = x%MOD+MOD;
    else n = x%MOD;
  }
};
Mod operator + ( Mod a  , Mod b ){ return Mod( a.n + b.n ); }
Mod operator +=( Mod &a , Mod b ){ return a = a + b; }
Mod operator - ( Mod a ){ return Mod( MOD - a.n ); }
Mod operator - ( Mod a  , Mod b ){ return Mod( a.n + MOD - b.n ); }
Mod operator -=( Mod &a , Mod b ){ return a = a - b; }
Mod operator * ( Mod a  , Mod b ){ return Mod( (ll)a.n * b.n ); }
Mod operator *=( Mod &a , Mod b ){ return a = a * b; }
Mod modpow( Mod x , ll k ){
  Mod res = 1;
  while( k ){
    if( k & 1 ) res *= x;
    k /= 2;
    x *= x;
  }
  return res;
}
ll extgcd( ll a , ll b , ll &x , ll &y ){
  ll d = a;
  if( b != 0 ){
    d = extgcd( b , a % b , y , x );
    y -= a / b * x;
  } else {
    x = 1, y = 0;
  }
  return d;
}
Mod inv( Mod a ){ ll x, y; assert( extgcd( a.n , MOD , x , y ) == 1 ); return Mod( x ); }
Mod operator / ( Mod a  , Mod b ){ return Mod( (ll)a.n * inv(b).n ); }
Mod operator /=( Mod &a , Mod b ){ return a = a / b; }


vl factor( ll x ){
  vl res;
  for( ll i = 1; i*i <= x; i++ ){
    if( x % i == 0 ){
      res.pb( i );
      if( i != x/i ) res.pb( x/i );
    }
  }
  return res;
}

ll n, k;
Mod dp[100010];

Mod ans;

int main(){

  n = in();
  k = in();

  vl v = factor( n );
  SORT( v );

  REP( i , SZ(v) ){
    ll a = v[i];
    dp[i] = modpow( k , ( a + 1 ) / 2 );
    REP( j , i ){
      ll b = v[j];
      if( a % b == 0 ){
	dp[i] -= dp[j];
      }
    }
    if( a % 2 == 0 ){
      ans += dp[i] * a / 2;
    } else {
      ans += dp[i] * a;
    }
  }

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


Measured memory_bytes: 640
#include "bits/stdc++.h"
// #include <boost\version.hpp>
#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define pb(a) push_back(a)
#define ALL(x) (x).begin(),(x).end()
#define INF 1145141919
#define MINF -1145141919
#define y0 y1919810

using namespace std;
typedef unsigned int uint;
typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef vector<string> vs;
typedef pair<int, int> P;
typedef pair<ll, ll> LP;
typedef pair<int, P> PP;
typedef pair<ll, LP> LPP;

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

int main() {
	string s; cin >> s;
	for(int i = 0; i < s.length(); i++) {
		if(i % 2 == 0) {
			cout << s[i];
		}
	}
	cout << endl;
	return	0;
}


Measured memory_bytes: 512
#include<bits/stdc++.h>
using namespace std;
char a[50000];
bool c,f;
int main(){
	gets(a);
	for(int i=0;i<strlen(a);i++){
		if(a[i]=='C')c=1;
		if(a[i]=='F'&&c==1)f=1;
	}
	if(c==1&&f==1)cout<<"Yes"<<endl;
	else cout<<"No"<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
#define INF 2001001001
int dp[100001];
       
int main()
{
  int N;
  cin>>N;
  for (int i=0;i<N;i++)
    dp[i]=INF;
  for (int i=N;i>0;i--){
    for (int j=9;j<=i;j*=9)
      dp[i-j]=min(dp[i-j],dp[i]+1);
    for (int j=6;j<=i;j*=6)
      dp[i-j]=min(dp[i-j],dp[i]+1);
    dp[i-1]=min(dp[i-1],dp[i]+1);
  }
  cout<<dp[0]<<endl;
  return 0;
}
    


Measured memory_bytes: 640
#include <iostream>
#include <string>
#include <algorithm>
#include <cstring>
#include <set>
#include <string>
#include <cmath>
#include <vector>
#include <map>
using namespace std;

int main()
{

	int n, h, w;
	cin >> n >> h >> w;
	int ret = 0;
	for (int i = 0; i < n; i++) {
		int x, y;
		cin >> x >> y;
		if (x >= h && y >= w)ret++;
	}
	cout << ret;

}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <unordered_map>
#include <unordered_set>
using namespace std;
#define endl "\n"
#define ll long long
#define oo 0x3f3f3f3fLL
#define sz(s) (int)(s.size())
#define RT(s) return cout<<s,0
#define INF 0x3f3f3f3f3f3f3f3fLL
#define all(v) v.begin(),v.end()
#define watch(x) cout<<(#x)<<" = "<<x<<endl
const int dr[] { -1, -1, 0, 1, 1, 1, 0, -1 };
const int dc[] { 0, 1, 1, 1, 0, -1, -1, -1 };
#if __cplusplus >= 201402L
template<typename T>
vector<T> create(size_t n) {
	return vector<T>(n);
}
template<typename T, typename ... Args>
auto create(size_t n, Args ... args) {
	return vector<decltype(create<T>(args...))>(n, create<T>(args...));
}
#endif
void run() {
	ios::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
#ifdef EZZAT
	freopen("input.in", "r", stdin);
	//freopen("output.out", "w", stdout);
#else
#endif
}

const int N = 2e5 + 9, mod = 1e9 + 7;
vector<int> adj[N];
int size[N];
ll mem[N], mem2[N];
ll fact[N];
ll inv[N]; //mod inverse for i
ll invfact[N]; //mod inverse for i!
void factInverse() {
	fact[0] = inv[1] = fact[1] = invfact[0] = invfact[1] = 1;
	for (long long i = 2; i < N; i++) {
		fact[i] = (fact[i - 1] * i) % mod;
		inv[i] = mod - (inv[mod % i] * (mod / i) % mod);
		invfact[i] = (inv[i] * invfact[i - 1]) % mod;
	}
}

template<typename T>
ll mul(T a) {
	return a;
}
template<typename T, typename ... Args>
ll mul(T a, Args ... b) {
	return (a * mul(b...)) % mod;
}

ll power(int x, int y = mod) {
	if (y == 0)
		return 1;
	if (y == 1)
		return x;
	ll r = power(x, y >> 1);
	return mul(r, r, power(x, y & 1));
}
ll nCr(int n, int r) {
	if (r > n)
		return 0;
	return mul(fact[n], invfact[n - r], invfact[r]);
}

ll dfs(int node, int par) {
	ll ans = 1;
	for (int ch : adj[node]) {
		if (ch == par)
			continue;
		ll tmp = dfs(ch, node);
		size[node] += size[ch];
		ans = mul(ans, tmp, nCr(size[node], size[ch]));
	}
	mem[node] = ans;
	size[node]++;
	return ans;
}

int n;
void dfs2(int node, int par) {
	if (~par) {
		ll tmp = mem2[par];
		ll myAns = mul(mem[node], nCr(n - 1, size[node]));
		tmp = mul(tmp, power(myAns, mod - 2));
		int sz = n - size[node];
		mem2[node] = mul(mem[node], tmp, nCr(n - 1, sz));
	} else
		mem2[node] = mem[node];
	for (int ch : adj[node]) {
		if (ch == par)
			continue;
		dfs2(ch, node);
	}
}
int main() {
	run();
	factInverse();
	cin >> n;
	for (int i = 1; i < n; i++) {
		int u, v;
		cin >> u >> v;
		adj[u].push_back(v);
		adj[v].push_back(u);
	}
	dfs(1, -1);
	dfs2(1, -1);
	for (int i = 1; i <= n; i++)
		cout << mem2[i] << endl;
}


Measured memory_bytes: 22516
#include <bits/stdc++.h>
#define fi first
#define se second
#define pii pair<int,int>
#define mp make_pair
#define pb push_back
#define space putchar(' ')
#define enter putchar('\n')
#define eps 1e-10
#define ba 47
#define MAXN 100005
//#define ivorysi
using namespace std;
typedef long long int64;
typedef unsigned int u32;
typedef double db;
template<class T>
void read(T &res) {
    res = 0;T f = 1;char c = getchar();
    while(c < '0' || c > '9') {
	if(c == '-') f = -1;
	c = getchar();
    }
    while(c >= '0' && c <= '9') {
	res = res * 10 +c - '0';
	c = getchar();
    }
    res *= f;
}
template<class T>
void out(T x) {
    if(x < 0) {x = -x;putchar('-');}
    if(x >= 10) {
	out(x / 10);
    }
    putchar('0' + x % 10);
}
int N;
map<pii,int> zz;
pii poi[55];
void Solve() {
    read(N);
    int x,y;
    for(int i = 1 ; i <= N ; ++i) {
	read(poi[i].fi);read(poi[i].se);
	zz[poi[i]] = 1;
    }
    int ans = N;
    for(int i = 1 ; i <= N ; ++i) {
	for(int j = 1 ; j <= N ; ++j) {
	    if(i == j) continue;
	    int p = poi[i].fi - poi[j].fi,q = poi[i].se - poi[j].se;
	    int tmp = N;
	    for(int h = 1 ; h <= N ; ++h) {
		tmp -= zz[mp(poi[h].fi - p,poi[h].se - q)];
	    }
	    ans = min(ans,tmp);
	}
    }
    out(ans);enter;
    
}
int main(){
#ifdef ivorysi
    freopen("f1.in","r",stdin);
#endif
    Solve();
}


Measured memory_bytes: 4096
#include "bits/stdc++.h"
using namespace std;
/////////////////// TYPES & MACROS ///////////////////////////////
#define mp make_pair
#define eb emplace_back
#define pb push_back
#define all(x) x.begin(),x.end()
#define ff first
#define ss second
#define vv vector
#define exist(s,e) (s.find(e)!=s.end())
#define sz(x) ((int)(x).size())
#define int ll
typedef long long ll; typedef long double ld; typedef double dd;typedef vector<int> vi; typedef pair<int, int> pii;typedef pair<ll,ll> pll;
ll INFLL=(ll)4e18, MOD=1e9+7; const int INF=0x3f6f6f6f;
//////////////////// DEBUG /////////////////////////////////////////
#define D(x) cerr<<#x<<" is:\t"<<x<<'\n';
#define DD(x,y) cerr<<'('<<#x<<','<<#y<<") are:\t"<<x<<' '<<y<<'\n';
#define DDD(x,y,z) cerr<<'('<<#x<<','<<#y<<','<<#z<<") are:\t"<<x<<' '<<y<<' '<<z<<'\n';
/////////////////// VARIABLES & FUNCTIONS//////////////////////////
vv<vv<int>> adj; vi vis, color, level; int dx8[]={0,1,1,1,0,-1,-1,-1}, dy8[]={1,1,0,-1,-1,-1,0,1},dx4[]={0,1,0,-1}, dy4[]={1,0,-1,0};
inline ll mexp(ll x,ll n,ll m=MOD){ll res=1;x%=m;while(n){if(n&1)res=(res*x)%m;n>>=1;x=(x*x)%m;}return res;}
inline ll gcd(ll a, ll b){while (a>0 && b>0){if(a>b)a%=b;else b%=a;}return a+b;}



///////////////////// MAIN STARTS //////////////////////////////////
int32_t main(void){
ios_base::sync_with_stdio(false);cin.tie(NULL); cout.tie(NULL);
cout<<fixed;cerr<<fixed; cout<<setprecision(1); cerr<<setprecision(3);
mt19937 genr(chrono::high_resolution_clock::now().time_since_epoch().count());

string s,t; cin>>s>>t;
int n=sz(s), m=sz(t);
ll dp[n+1][m+1];
for(int i=0;i<=n;++i) dp[i][0]=0;
for(int i=0;i<=m;++i) dp[0][i]=0;

for(int i=1;i<=n;++i) for(int j=1;j<=m;++j){
    dp[i][j]=max(dp[i-1][j], dp[i][j-1]);
    if(s[i-1]==t[j-1]) dp[i][j]=max(dp[i][j], dp[i-1][j-1]+1);
}
int x=n, y=m;
vv<char> ans;
while(x && y){
    if(s[x-1]==t[y-1]) {ans.pb(s[x-1]); x--, y--;}
    else if(dp[x][y]==dp[x-1][y]) x--;
    else y--;
    // DD(x,y);
}
cerr<< dp[n][m] <<'\n'; 
// cout<<"  "; for(auto& e : t) cout<< e <<' '; cout<<'\n'; 
// for(int i=0;i<=n;++i) for(int j=0;j<=m;++j) cout<< dp[i][j] <<" \n"[j==m]; 
reverse(all(ans));
for(auto& e: ans) cout<<e;


return 0;
}


Measured memory_bytes: 70656
#include <iostream>

using namespace std;

int main() {
	string str;
	
	cin >> str;

	if ((str[0] == str[1] && str[1] == str[2]) 
		|| (str[1] == str[2] && str[2] == str[3])) {
		cout << "Yes" << endl;
	}
	else {
		cout << "No" << endl;
	}

	return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
int main()
{
    int a,b,c,sum,sub,mul;
    scanf("%d %d" ,&a,&b);
     sum = a+b;
     sub = a-b;
     mul = a*b;
     if(sum>sub && sum>mul)
     {
         printf("%d\n",sum);
     }
     else if(sub>sum && sub>mul)
     {
         printf("%d\n",sub);
     }
     else if(mul>sum && mul>sub)
     {
         printf("%d\n",mul);
     }
     else
     printf("%d\n",sum);
}


Measured memory_bytes: 128
using System;
using System.IO;
using System.Text;
using static Scanner;

class Program
{
    static void Main(string[] args) {
        var writer = new StreamWriter(Console.OpenStandardOutput()) {AutoFlush = false};
        Console.SetOut(writer);
        Solve();
        Console.Out.Flush();
    }
    static void Solve() {
        int N = ScanInt(), X = ScanInt(), T = ScanInt();
        Console.WriteLine((N + X - 1) / X * T);
    }
}

public static class Scanner
{
    static readonly Stream stdin = Console.OpenStandardInput();
    static readonly byte[] buffer = new byte[1024];
    static int length, p;
    static bool isEof;
    private static byte StdIn() {
        if (isEof) return 0;
        if (p < length) return buffer[p++];
        p = 0;
        if ((length = stdin.Read(buffer, 0, 1024)) > 0) return buffer[p++];
        isEof = true;
        return 0;
    }
    public static char GetChar() {
        var by = StdIn();
        while ((by < '!' || '~' < by) && !isEof) by = StdIn();
        return (char) by;
    }
    public static int ScanInt() {
        var temp = 0;
        for (var ch = GetChar(); '0' <= ch && ch <= '9'; ch = (char) StdIn()) {
            temp = temp * 10 + ch - '0';
        }
        return temp;
    }
}


Measured memory_bytes: 23732
#include <stdio.h>
#include <stdlib.h>
#define NIL NULL

struct node{
  int key;
  struct node *right,*left,*parent;
};
typedef struct node * Node;

Node treeMinimum(Node);
Node treeFind(Node,int);
Node treeSuccessor(Node);
void treeDelete(Node);
void insert(int);
void inorder(Node);
void preorder(Node);

Node root;

/*
Node treeMaximum(Node x){
  }
*/

int main(){
  int n, i, x;
  char com[20];
  scanf("%d", &n);

  for ( i = 0; i < n; i++ ){
    scanf("%s", com);
    if ( com[0] == 'f' ){
      scanf("%d", &x);
      Node t = treeFind(root, x);
      if ( t != NIL ) printf("yes\n");
      else printf("no\n");
    }
    else if ( com[0] == 'i' ){
      scanf("%d", &x);
      insert(x);
    }
    else if ( com[0] == 'p' ){
      inorder(root);
      printf("\n");
      preorder(root);
      printf("\n");
    }
    else if ( com[0] == 'd' ){
      scanf("%d", &x);
      treeDelete(treeFind(root, x));
    }
  }

  return 0;
}


Node treeMinimum(Node x){
  while(x->left != NIL) x = x->left;
  return x;
}

Node treeFind(Node u, int k){
  while(u != NIL && k != u->key){
    if(k < u->key) u = u->left;
    else u = u->right;
  }
  return u;
}

Node treeSuccessor(Node x){
  if(x->right != NIL) return treeMinimum(x->right);
  Node y = x->parent;
  while(y != NIL && x == y->right){
    x = y;
    y = y->parent;
  }
  return y;
}

void treeDelete(Node z){
  Node y; // node to be deleted
  Node x; // child of y

  if(z->left == NIL || z->right == NIL) y = z;
  else y = treeSuccessor(z);
  if(y->left != NIL) x = y->left;
  else x = y->right;

  if(x != NIL) root = x;
  else{
    if(y == y->parent->left) y->parent->left = x;
    else y->parent->right = x;
  }
  if(y != z) z->key = y->key;
  free(y);
}

void insert(int k){
  Node y = NIL;
  Node x = root;
  Node z;

  z = malloc(sizeof(struct node));
  z->key = k;
  z->left = NIL;
  z->right = NIL;

  while(x != NIL){
    y = x;
    if(z->key < x->key) x = x->left;
    else x = x->right;
  }

  z->parent = y;
  if(y == NIL) root = z;
  else{
    if(z->key < y->key) y->left = z;
    else y->right = z;
  }
}

void inorder(Node u){
  if(u == NIL) return;
  inorder(u->left);
  printf(" ");
  printf("%d",u->key);
  inorder(u->right);
}
void preorder(Node u){
  if(u == NIL) return;
  printf(" ");
  printf("%d",u->key);
  preorder(u->left);
  preorder(u->right);
}



Measured memory_bytes: 20476
#include <iostream>
#include <sstream>
#include <stdio.h>
#include<vector>
#include<climits>
#include<algorithm>
#include<bitset>
#include<cmath>
#include<functional>
#include <numeric>
#include <map>
#define FORi(N) for(int i=0;i<N;++i)
#define FORj(N) for(int j=0;j<N;++j)
using namespace std;
using ll = long long;
using ull = unsigned long long;
using ld = long double;
ll gcd(ll m,ll n){
  if(n==0)return abs(m);
  return(gcd(n,m%n));
}
void putYN(bool b){
  if(b){
    cout<<"YES"<<endl;
  }else{
    cout<<"NO"<<endl;
  }
}
void swap(ll &a,ll &b){
  ll tmp=a;
  a=b;
  b=tmp;
}
int main(){
  ll A,P;
  cin>>A>>P;
  ll ca=A*3+P;
  cout<<ca/2<<endl;
  return 0;
}


Measured memory_bytes: 888
#include <iostream>
#include <cstdio>
#define BIG 1000000000
#define N 100005
using namespace std;
int n,k,cnta,cntb,Ans,a[N],b[N];
int main()
{
	scanf("%d%d",&n,&k);
	for (int i=1; i<=n; i++)
	  a[i]=b[i]=BIG;
	for (int i=1; i<=n; i++)
	  {
		int x; scanf("%d",&x);
		if (x<0) a[++cnta]=-x;
		else b[++cntb]=x;
	  }
	for(int i=1; i<=(cnta/2); i++)
	  swap(a[i],a[cnta-i+1]);
	Ans=b[k];
	for (int i=1; i<=min(cnta,k); i++)
		Ans=min(Ans,a[i]+b[k-i]*2);
	Ans=min(Ans,a[k]);
	for(int i=1; i<=min(cntb,k); i++) 
		Ans=min(Ans,b[i]+a[k-i]*2);
	return printf("%d",Ans),0;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using V = vector<int>;
using Vll = vector<ll>;
using Vld = vector<ld>;
using Vbo = vector<bool>;
using VV = vector<V>;
using VVll = vector<Vll>;
using VVld = vector<Vld>;
using VVbo = vector<Vbo>;
using P = pair<int, int>;
using Pll = pair<ll, ll>;
using Pld = pair<ld, ld>;
#define rep2(i, m, n) for(ll i=int(m); i<int(n); ++i)
#define drep2(i, m, n) for(ll i=int(m)-1; i>=int(n); --i)
#define rep(i, n) rep2(i, 0, n)
#define drep(i, n) drep2(i, n, 0)
#define all(a) a.begin(), a.end()
struct fast_ios { fast_ios(){ cin.tie(0); ios::sync_with_stdio(false); cout << fixed << setprecision(20); }; } fast_ios_;
template<typename T> inline bool chmin(T &a, T b) { if (a > b) { a = b; return true; } return false; }
template<typename T> inline bool chmax(T &a, T b) { if (a < b) { a = b; return true; } return false; }
template<typename T1, typename T2> istream &operator>>(istream &is, pair<T1, T2> &p) { is >> p.first >> p.second; return is; }
template<typename T1, typename T2> ostream &operator<<(ostream &os, const pair<T1, T2> &p) { os << "(" << p.first << ", " << p.second << ")"; return os; }
template<typename T> istream &operator>>(istream &is, vector<T> &v) { for (auto &e : v) is >> e; return is; }
template<typename T> ostream &operator<<(ostream &os, const vector<T> &v) { for (auto &e : v) os << e << " "; return os; }
template<typename T> inline int count_between(vector<T> &a, T l, T r) { return lower_bound(all(a), r) - lower_bound(all(a), l); } // [l, r)
inline int Log2(ll x) { int k; for (k = 0; x > 0; ++k) x >>= 1; return k; } // number of binary digits
const int INF  = 1<<30;
const ll INFll = 1ll<<62;
const ld EPS   = 1e-10;
const int MOD  = int(1e9)+7;


pair<int, int> s2p(string s) {
  if (s == "AB") return {0, 1};
  if (s == "BC") return {1, 2};
  if (s == "AC") return {2, 0};
}

string rf = "ABC";

void upd(string &s, Vll &a, int x, int y){
  s += rf[x];
  ++a[x];
  --a[y];
}

int main() {
  ll n; cin >> n;
  Vll a(3); cin >> a;
  vector<string> s(n); cin >> s;
  
  string ans;

  rep(i, n) {
    auto [x, y] = s2p(s[i]);
    if (a[x] == 0 && a[y] == 0) {
      cout << "No" << "\n";
      return 0;
    }
    else if (a[x] == 0) upd(ans, a, x, y);
    else if (a[y] == 0) upd(ans, a, y, x);
    else if (i == n-1)  upd(ans, a, x, y);
    else {
      auto [z, w] = s2p(s[i+1]);
      if (x == z || x == w) upd(ans, a, x, y);
      else upd(ans, a, y, x);
    }
  }

  cout << "Yes" << "\n";
  rep(i, n) cout << ans[i] << "\n";
  return 0;
}


Measured memory_bytes: 6660
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using static System.Console;
using static System.Math;

namespace At
{
    class Program
    {
        static void Main(string[] args)
        {
            var input = ReadInts();
            if (input[0] + input[1] >= 10)
            {
                WriteLine("error");
            }
            else
            {
                WriteLine(input[0] + input[1]);
            }
        }

        private static string Read() { return ReadLine(); }
        private static string[] Reads() { return (Read().Split()); }
        private static int ReadInt() { return int.Parse(Read()); }
        private static long ReadLong() { return long.Parse(Read()); }
        private static double ReadDouble() { return double.Parse(Read()); }
        private static int[] ReadInts() { return Array.ConvertAll(Read().Split(), int.Parse); }
        private static long[] ReadLongs() { return Array.ConvertAll(Read().Split(), long.Parse); }
        private static double[] ReadDoubles() { return Array.ConvertAll(Read().Split(), double.Parse); }
    }
}


Measured memory_bytes: 13140
#include <iostream>
#include <cstring>
#include <cmath> 
#include <algorithm>

using namespace std;

const int maxn=1e5+10;
int n,m;
unsigned long long w[maxn],v[maxn],f[maxn];

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

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

using namespace std;

int main()
{
    int n,k,ans=0,i,cnt=0;
    scanf("%d%d",&n,&k);
    int a[n];
    for(i=0;i<n;i++)
       scanf("%d",&a[i]);
    sort(a,a+n);
    for(i=0;i<k;i++){
        ans=ans+a[i];
    }
    printf("%d\n",ans);
}


Measured memory_bytes: 3816
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
sys.setrecursionlimit(10 ** 7)

s = read().rstrip().decode()
dp = [[0] * 13 for _ in range(len(s))]
mod = 10 ** 9 + 7
if s[0] == '?':
    dp[0] = 10 * [1] + [0] * 3
else:
    dp[0][int(s[0])] += 1
for i, ss in enumerate(s[1:]):
    if ss == '?':
        for j in range(13):
            for k in range(10):
                dp[i + 1][(j * 10 + k) % 13] += dp[i][j]
    else:
        for j in range(13):
            dp[i + 1][(int(ss) + j * 10) % 13] += dp[i][j]
    for j in range(13):
        dp[i + 1][j] %= mod
print(dp[-1][5])


Measured memory_bytes: 61788
import java.util.*;
import java.io.*;

public class Main {

	public static void main(String[] args) {
		FastScanner sc = new FastScanner();
		PrintWriter out = new PrintWriter(System.out);
		
		String str =sc.next();
		StringBuilder sb1 = new StringBuilder();
		StringBuilder sb2 = new StringBuilder();
		int Q = sc.nextInt();
		boolean rev = false;
		
		for(int i = 0; i < Q; i++) {
			int q = sc.nextInt();
			if (q == 1) {
				if (rev) rev = false;
				else rev = true;
			} else {
				int q2 = sc.nextInt();
				String s = sc.next();
				if (!rev && q2 == 1 || rev && q2 == 2) {
					sb1.append(s);
				} else {
					sb2.append(s);
				}
			}
		}
		if (!rev) {
			sb1.reverse();
			out.println(sb1 + str + sb2);
		} else {
			sb2.reverse();
			StringBuilder S = new StringBuilder(str);
			S.reverse();
			out.println(sb2 + S.toString() + sb1);
		}
		
		
		out.close();
	}

static class FastScanner {
    private final InputStream in = System.in;
    private final byte[] buffer = new byte[1024];
    private int ptr = 0;
    private int buflen = 0;
    private boolean hasNextByte() {
        if (ptr < buflen) {
            return true;
        }else{
            ptr = 0;
            try {
                buflen = in.read(buffer);
            } catch (IOException e) {
                e.printStackTrace();
            }
            if (buflen <= 0) {
                return false;
            }
        }
        return true;
    }
    private int readByte() { if (hasNextByte()) return buffer[ptr++]; else return -1;}
    private static boolean isPrintableChar(int c) { return 33 <= c && c <= 126;}
    public boolean hasNext() { while(hasNextByte() && !isPrintableChar(buffer[ptr])) ptr++; return hasNextByte();}
    public String next() {
        if (!hasNext()) throw new NoSuchElementException();
        StringBuilder sb = new StringBuilder();
        int b = readByte();
        while(isPrintableChar(b)) {
            sb.appendCodePoint(b);
            b = readByte();
        }
        return sb.toString();
    }
    public long nextLong() {
        if (!hasNext()) throw new NoSuchElementException();
        long n = 0;
        boolean minus = false;
        int b = readByte();
        if (b == '-') {
            minus = true;
            b = readByte();
        }
        if (b < '0' || '9' < b) {
            throw new NumberFormatException();
        }
        while(true){
            if ('0' <= b && b <= '9') {
                n *= 10;
                n += b - '0';
            }else if(b == -1 || !isPrintableChar(b)){
                return minus ? -n : n;
            }else{
                throw new NumberFormatException();
            }
            b = readByte();
        }
    }
    public int nextInt() {
        long nl = nextLong();
        if (nl < Integer.MIN_VALUE || nl > Integer.MAX_VALUE) throw new NumberFormatException();
        return (int) nl;
    }
    public double nextDouble() { return Double.parseDouble(next());}
}
}



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

#define REP(i, n) for(int i=0; i<n;i++)
#define REPR(i, n) for(int i=n-1 ; i>=0; i--)
#define FOR(i, m, n) for(int i=m; i<n; i++)

#define INF 2e9
#define ll long long

int main(){
    int n, d;
    cin>>n>>d;
    if(n%(1+2*d)==0){
        cout<<n/(1+2*d)<<endl;
    }
    else{
        cout<<(n/(1+2*d))+1<<endl;
    }

        return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
using namespace std;
int main() {
	int a[105];
	int n;
	scanf("%d",&n);
    for(int i=0;i<n;i++){
    	scanf("%d",&a[i]);
	}
	int min=a[0],max=a[0];
	for(int i=0;i<n;i++){
		if(min>a[i]){
			min=a[i];
		}
		if(max<a[i]){
			max=a[i];
		}
	}
	printf("%d",max-min);
	return 0;
}

Measured memory_bytes: 256
// g++ -std=c++14

/*

Today might be the chance to grasp the chance to let your talent bloom.
May be tomorrow, the day after, or next year...
May be even when you are 30. I'm not sure if physique has anything to do with it
but if you think that it will never come, it probably never will.

- Tooru Oikawa.

*/


#include<bits/stdc++.h>

typedef long long ll;
typedef long double lld;
using namespace std;

#define endl "\n"
#define fi first
#define se second
#define MEMS(a,b) memset(a,b,sizeof(a))
#define _ ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define __ freopen("input.txt","r",stdin);freopen("output.txt","w",stdout);
#define all(c) c.begin(),c.end()
#define pii pair<int, int>

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
int rand(int l, int r)
{
	uniform_int_distribution<int> uid(l, r);
	return uid(rng);
}

#define tr(...) cout<<__FUNCTION__<<' '<<__LINE__<<" = ";trace(#__VA_ARGS__, __VA_ARGS__)
template<typename S, typename T>
ostream& operator<<(ostream& out,pair<S,T> const& p){out<<'('<<p.fi<<", "<<p.se<<')';return out;}

template<typename T>
ostream& operator<<(ostream& out,vector<T> const& v){
ll l=v.size();for(ll i=0;i<l-1;i++)out<<v[i]<<' ';if(l>0)out<<v[l-1];return out;}

template <typename T>
ostream &operator<<(ostream &out, set<T> const &v) {
    for (auto i = v.begin(); i != v.end(); i++)
        out << (*i) << ' ';
    return out;
}
template <typename T>
ostream &operator<<(ostream &out, multiset<T> const &v) {
    for (auto i = v.begin(); i != v.end(); i++)
        out << (*i) << ' ';
    return out;
}
template <typename T, typename V>
ostream &operator<<(ostream &out, map<T, V> const &v) {
    for (auto i = v.begin(); i != v.end(); i++)
        out << "\n" << (i->first) <<  ":"  << (i->second);
    return out;
}

template<typename T>
void trace(const char* name, T&& arg1){cout<<name<<" : "<<arg1<<endl;}

template<typename T, typename... Args>
void trace(const char* names, T&& arg1, Args&&... args){
const char* comma = strchr(names + 1, ',');cout.write(names, comma-names)<<" : "<<arg1<<" | ";trace(comma+1,args...);}

#define int ll

const int N =  2e3 + 100;

int n, x, y;
vector<vector<int>> g(N);
int ans[N];
const int inf = 1e9 + 1;
void bfs(int x) {
    vector<int> dist(n + 1, inf);   
    queue<int> q;
    vector<int> visited(n + 1, 0);
    dist[x] = 0;
    visited[x] = 1;
    q.push(x);
    while (!q.empty()) {
        int f = q.front();
        q.pop();
        for (auto u : g[f]) {
            if (!visited[u]) {
                dist[u] = dist[f] + 1;
                q.push(u);
                visited[u] = 1;
            }
        }
    }
    for (int i = x + 1; i <= n; i++) {
        ans[dist[i]]++;
    }
}

int solve() {
    cin >> n >> x >> y;
    for (int i = 1; i < n; i++) {
        g[i].push_back(i + 1);
        g[i + 1].push_back(i);
    }
    g[x].push_back(y);
    g[y].push_back(x);

    for (int i = 1; i <= n; i++) {
        bfs(i);
    }
    for (int i = 1; i <= n - 1; i++) {
        cout << ans[i] << "\n";
    }
    cout << endl;
}

int32_t main(){ _
    int t;
    // cin >> t;
    t = 1;
    while (t--) solve();
}


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

using namespace std;

#define ll long long
#define pb push_back
#define mp make_pair
#define fst first
#define snd second

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

    string s2 = s.substr(0, (n + 1) / 2);
    string s3 = s.substr((n + 1) / 2, n - ((n + 1) / 2));
    if(s2 == s3)
        cout << "Yes";
    else
        cout << "No";

    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define ll long long
#define N 2*10e5
#define precise cout<<fixed<<setprecision(10)
#pragma GCC optimize("O0")
#pragma GCC optimize ("Ofast")
#pragma GCC target ("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#pragma GCC optimize ("-ffloat-store")
using namespace std;
void get(ll arr[],ll n){for(ll i=0;i<n;i++) cin>>arr[i];}
int main()
{
 	ios::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	ll s,w;
	cin>>s>>w;
	if(s>w)
	cout<<"safe";
	else
	cout<<"unsafe";
}




Measured memory_bytes: 3672
def main():
    n, y = map(int, input().split())
    flag = False

    a = -1
    b = -1
    c = -1

    for i in range(0, n + 1):
        for j in range(0, n + 1):

            money = y - 10000 * i - 5000 * j
            k = n - (i + j)
            if k < 0:
                break
            else:
                if 1000 * k == money:
                    a = i
                    b = j
                    c = k
                    flag = True
                    break

        if flag:
            break

    print(a, b, c)


if __name__ == '__main__':
    main()

Measured memory_bytes: 64452
#pragma GCC optimize("O2")
#include<bits/stdc++.h>
using namespace std;
#define all(x) (x).begin(),(x).end()
#define YES() printf("YES\n")
#define NO() printf("NO\n")
#define Yes() printf("Yes\n")
#define No() printf("No\n")
#define ll long long
#define vll vector<ll>
#define vi vector<int>
#define pi pair<int,int>
#define vp vector<pi>
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define f(i,x,z) for(int i=x;i<z;i++)
#define debug(x) cout<<"DEBUG------> "<<x<<endl
#define endl "\n"
#define srt(v) sort(v.begin(), v.end())

int main(){
	ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
 	long long a,b,c;
 	cin>>a;
 	b=a/1000;
    if(a%1000!=0)
    {
        b=b+1;
    }
 	c=b*1000 -a;
 		cout<<c;
 	
   	return 0;		
}

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

int main() {
  int N;
  cin >> N;
  
  vector<int> d(N);
  for (int i = 0; i < N; i++) {
    cin >> d.at(i);
  }
  
  sort(d.begin(), d.end());
  
  int c = 1;
  for (int i = 0; i < N - 1; i++) {
    if (d.at(i) != d.at(i + 1)) {
      c++;
    }
  }
  
  cout << c << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep0(i, n) for (long long i = 0; i < (long long)(n); i++)
#define rep1(i,n) for(long long i=1;i<=(long long)(n);i++)
#define all(v) v.begin(),v.end()
#define Sort(v) sort(all(v))
#define Reverse(v) reverse(all(v))
#define Rsort(v) sort(all(v),greater)
#define pub(v) push_back(v)
#define pob(v) pop_back(v)
typedef long long ll;
typedef vector<ll> vel;
typedef vector<vector<ll>> vel2d;
typedef string str;
typedef pair<ll,ll> pal;
typedef vector<str> ves;


int main() {
    ll a,b,c,d;
    cin>>a>>b>>c>>d;
    ll x=c-a,y=d-b;
    cout<<c-y<<" "<<d+x<<" "<<a-y<<" "<<b+x<<endl;
}

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

works_info_lst = []
for i in range(N):
    A, B = map(int, input().split())
    works_info_lst.append((B, A))

works_info_lst.sort()

A_sum = 0
def judge(works_info_lst, A_sum, N):
    for i in range(N):
        A_sum += works_info_lst[i][1]
        if A_sum > works_info_lst[i][0]:
            return False
    return True

if judge(works_info_lst, A_sum, N):
    print("Yes")
else:
    print("No")

Measured memory_bytes: 29412
#include <iostream>
#include <string>
#include <vector>
#include <cstdio>
#include <algorithm>
#include <array>
#include <cmath>

using namespace std;

using ll = long long int;

struct block_t {
    int beg, end;
    char ch;
};

int main() {
    int N;
    string S;

    cin >> N;
    cin >> S;

    int numofBlack = 0;
    int numofWhite = 0;

    vector<block_t> block;

    // 先頭の境界用
    block.push_back({
        0, 0, (S.front() == '.') ? '#' : '.'
    });

    int beg = 0;
    char prev = S.front();

    for (int i = 0; i < N; i++) {
        if (S[i] != prev) {
            block.push_back({beg, i, prev});
            beg = i;
        }
        if (i == N - 1) {
            block.push_back({beg, i + 1, S[i]});
        }
        prev = S[i];
    }

    // 末尾の境界用
    block.push_back({
        N, N, (S.back() == '.') ? '#' : '.'
    });

    // for (const auto & b : block) {
    //     cout << b.beg << " " << b.end << " " << b.ch << "\n";
    // }
    
    for (const auto & b : block) {
        if (b.ch == '#')    numofBlack += b.end - b.beg;
        else                numofWhite += b.end - b.beg;
    }

    int leftBlackCnt = 0;
    int rightWhiteCnt = numofWhite;

    int min = N;
    for (auto it = block.cbegin(); it != block.cend(); it++) {
        if (it->ch == '.') {
            // ....|####
            rightWhiteCnt -= it->end - it->beg;
        } else {
            // ####|....
            leftBlackCnt += it->end - it->beg;
        }
        
        //cout << leftBlackCnt << " " << rightWhiteCnt << "\n";

        int sum = rightWhiteCnt + leftBlackCnt;

        if (sum < min) min = sum;
    }

    cout << min;

    return 0;
}



Measured memory_bytes: 4472
// by syu
package main

import (
	"bufio"
	"fmt"
	"io"
	"math"
	"os"
	"strconv"
)

var in = NewScanner(os.Stdin, 0)

func main() {
	N, K := in.Int(), in.Int()
	x := in.ArrayInt(N)
	min := math.MaxInt64
	for i := 0; i < N-K+1; i++ {
		a, b := x[i], x[i+K-1]
		sum := Min(Abs(a), Abs(b)) + b - a
		if sum < min {
			min = sum
		}
	}
	Pln(min)
}

type Scanner struct {
	*bufio.Scanner
}

func NewScanner(r io.Reader, max int) *Scanner {
	s := bufio.NewScanner(r)
	s.Split(scanWords)
	if max <= 0 {
		max = 1048576
	}
	s.Buffer([]byte{}, max)
	return &Scanner{s}
}
func (s *Scanner) Int() int {
	s.Scan()
	i, e := strconv.ParseInt(s.Text(), 10, 64)
	if e != nil {
		panic(e)
	}
	return int(i)
}
func (s *Scanner) ArrayInt(n int) (r []int) {
	for i := 0; i < n; i++ {
		r = append(r, s.Int())
	}
	return
}
func isSpace(b byte) bool {
	return b == ' ' || b == '\n' || b == '\r' || b == '\t'
}
func scanWords(data []byte, atEOF bool) (advance int, token []byte, err error) {
	start := 0
	for start < len(data) && isSpace(data[start]) {
		start++
	}
	for i := start; i < len(data); i++ {
		if isSpace(data[i]) {
			return i + 1, data[start:i], nil
		}
	}
	if atEOF && len(data) > start {
		return len(data), data[start:], nil
	}
	return start, nil, nil
}
func Min(arr ...int) (r int) {
	r = arr[0]
	for _, x := range arr {
		if x < r {
			r = x
		}
	}
	return
}
func Abs(n int) int {
	y := n >> 63
	return (n ^ y) - y
}
func Pln(s ...interface{}) {
	fmt.Println(s...)
}


Measured memory_bytes: 6144
#include <iostream>
#include<algorithm>
#include<cstdio>
#include<cmath>
#include<limits>
#include<string.h>
#include<vector>
#include<stack>
#include<queue>
using namespace std;

int main()
{
    int a,b,c,k;
    cin>>a>>b>>c>>k;
    while (b<=a)
    {
        b=b*2;
        k--;
    }
    while (c<=b)
    {
        c=c*2;
        k--;
    }
    if (k>=0)
    {
        cout<<"Yes"<<endl;
    }else
    {
        cout<<"No"<<endl;
    }
    
    
    
    

    return 0;
}

Measured memory_bytes: 3632
#define _USE_MATH_DEFINES
#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 d, g;
    cin >> d >> g;
    int p[d], c[d], sum[d];
    rep(i, d) {
        cin >> p[i] >> c[i];
        sum[i] = p[i] * 100 * (i + 1) + c[i];
    }
    int ans = 99999;
    rep(bit, 1 << d) {
        int tAns = 0, tScore = 0;
        bool used[d];
        rep(i, d) {
            if (1 << i & bit) {
                tScore += sum[i];
                tAns += p[i];
                used[i] = true;
            } else
                used[i] = false;
        }
        if (tScore >= g)
            ans = min(ans, tAns);
        else {
            for (int i = d - 1; i >= 0; i--) {
                if (!used[i]) {
                    if (!((double)((g - tScore) / (100 * (i + 1))) > p[i] - 1))
                        ans = min(ans, tAns + (int)ceil((double)(g - tScore) / (100 * (i + 1))));
                    break;
                }
            }
        }
    }
    cout << ans << endl;
}

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

using namespace std;

int main(){
    long long N;
    long long A[100001], B[100001], C[100001];
    long long sum[100001], bigger[100001];
    cin >> N;
    for(int i = 0; i < N; i++){
        cin >> A[i];
    }
    for(int i = 0; i < N; i++){
        cin >> B[i];
    }
    for(int i = 0; i < N; i++){
        cin >> C[i];
    }
    sort(A, A+N);
    sort(B, B+N);
    sort(C, C+N);
    long long ans = 0;
    for(int i = 0; i < N; i++){
        long long *c;
        c = upper_bound(C, C+N, B[i]);
        if(*c <= B[i]) bigger[i] = 0;
        else bigger[i] = C+N - c;
        //cout << bigger[i] << endl;
    }
    sum[N-1] = bigger[N-1];
    for(int i = N-2; i >= 0; i--){
        sum[i] = sum[i+1] + bigger[i];
    }
    for(int i = 0; i < N; i++){
        long long *b, *c;
        b = upper_bound(B, B+N, A[i]);
        if(*b <= A[i]) break;
        ans += sum[b-B];
        //cout << ans << endl;
    }
    cout << ans << endl;
}

Measured memory_bytes: 4096
import java.util.*;
public class Main {
	static Scanner s = new Scanner(System.in);
	public static void main(String __[]){
		int n=s.nextInt()-2,k=s.nextInt(),npar11=n/11,nmod11=n%11;

		int count1=0,count2=0;
		for(int i=0;i<11;i++) {
			for(int j=0;j<5;j++) {
//				System.out.printf("%2d ",get(i,j)%11);
				if(get(i, j)%11==k)
					count1++;
			}
//			System.out.println();
		}
		for(int i=0;i<nmod11;i++) {
			for(int j=0;j<5;j++)
				if(get(i, j)%11==k)
					count2++;
		}
		System.out.println(count1*npar11+count2);
	}
	static final long get(int y,int x) {
		return (7*y+x)*9+81;
	}
}


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

int main(){
    int n,l;cin>>n>>l;
    int sum=n*(l-1)+n*(n+1)/2;
    if(l+n-1>=0&&l<=0) cout<<sum<<endl;
    else if(l+n-1>=0) cout<<sum-l<<endl;
    else cout<<sum-(l+n-1)<<endl;
}

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

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
typedef long long ll;
using namespace std;

int a, b, c, k;
bool ans = false;

void solve(int depth, int a1, int b1, int c1) {

    // cout << a1 << " " << b1 << " " << c1 << endl;

    if (b1 > a1 && c1 > b1) {
        ans = true;
    }

    if (depth == k) return;
    rep(i, 3) {
        if (i == 0) {
            solve(depth + 1, a1 * 2, b1, c1);
        }
        if (i == 1) {
            solve(depth + 1, a1, b1 * 2, c1);
        }
        if (i == 2) {
            solve(depth + 1, a1, b1, c1 * 2);
        }

    }

}


int main() {
    cin >> a >> b >> c >> k;

    solve(0, a, b, c);

    cout << (ans ? "Yes" : "No") << endl;

    return 0;
}


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

int main() {
    int N, W;
    cin >> N >> W;

    vector<long long> dp(W + 1);
    long long ans = 0;

    for (int i = 0; i < N; i++) {
        int w, v;
        cin >> w >> v;
        for (int k = W - w; k >= 0; k--) {
            dp[k + w] = max(dp[k + w], dp[k] + v);
            ans = max(ans, dp[k + w]);
        }
    }

    cout << ans << endl;
}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
#define taskname "A"
#define pb push_back
#define mp make_pair
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;

typedef long long ll;
typedef long double ld;
typedef pair<int,int> ii;
const int maxn = 2000 + 5;
const int logn = log2(maxn) + 1;
const int mod = 1e9 + 7;

int main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0), cout.tie(0);
    if(fopen(taskname".INP", "r")) {
        freopen(taskname".INP", "r", stdin);
        freopen(taskname".OUT", "w", stdout);
    }
    ll n , s;
    cin >> n >> s;
    if(n == s)return cout << n + 1 , 0;
    if(s > n)return cout << -1 , 0;
    function<ll(ll,ll)> F = [&](ll b , ll n){
        if(b <= 1)return (ll)-1;
        if(n < b)return n;
        return F(b , n / b) + n % b;
    };
    ll res = 1e18;
    for(int i = 2 ; (ll)i * i <= n ; ++i){
        if(F(i , n) == s)res = min(res , (ll)i);
    }
    for(int i = 1 ; (ll)i * i <= n - s ; ++i){
        if((n - s) % i)continue;
        if(F((n - s) / i + 1, n) == s)res = min(res , (n - s) / i+1);
        if(F(i +1, n) == s)res = min(res , (ll)i + 1);
    }
    if(res == 1e18)cout << -1;
    else cout << res;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <vector>
#include <cstring>
#include <queue>
#include <functional>
#include <set>
#include <map>
#include <string>
#include <cmath>
#include <cassert>
 
#define rep(i, n) for (int i = 0; i < n; i++)
#define repd(i, n) for (int i = n; i > 0; i--)
 
using namespace std;
typedef long long int ll;
typedef pair <int, int> P;
 
int main(){
	int n;
	cin>>n;
	vector<string> word(n);
	rep(i,n){
		cin>>word[i];
	}
	rep(i,n){
		rep(j,n){
			if(i!=j&&word[i]==word[j]){
				cout<<"No"<<endl;
				return 0;
			}
		}
	}
	rep(i,n-1){
		if(word[i].at(word[i].size()-1)!=word[i+1].at(0)){
			cout<<"No"<<endl;
			return 0;
		}
	}
	cout<<"Yes"<<endl;
	return 0;
}

Measured memory_bytes: 256
f=lambda:map(int,input().split())
h,w,n = f()

d={}
while n:
 n-=1
 x,y=f()
 for i in range(9):
     a=(x+i%3,y+i//3)
     d[a]=d.get(a,0)+(h>=a[0]>2<a[1]<=w)

c=[list(d.values()).count(i+1)for i in range(9)]

print((h-2)*(w-2)-sum(c))
for i in range(9):
    print(c[i])

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


public class Main {

	public static void main(String[] a){

		BufferedReader bf = new BufferedReader(new InputStreamReader(System.in));

		String tmpString = null;

		try {
			while(null != (tmpString = bf.readLine())){
				int d = Integer.parseInt(tmpString);
				int ans = 0;
				for(int i = d; i < 600; i += d){
					ans += Math.pow(i, 2) * d;
				}
				System.out.println(ans);
			}
		} catch (IOException e) {
		} finally {
			try {
				bf.close();
			} catch (IOException e) {
			}
		}

	}

}

Measured memory_bytes: 9340
#include <bits/stdc++.h>
using namespace std;
 
#include <boost/algorithm/string/join.hpp>
using boost::algorithm::join;
 
int main() {
  int n, l;
  cin >> n >> l;
  vector<string> arr;
  for (int i = 0; i < n; ++i) {
    string s;
    cin >> s;
    arr.emplace_back(s);
  }
  sort(arr.begin(), arr.end());
  string s = join(arr, "");
  cout << s << endl;
}

Measured memory_bytes: 256
#pragma GCC optimize(2)
#pragma GCC optimize(3)
#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
const int N = 2e5 + 10;
#define fi first
#define se second
#define pb push_back
#define wzh(x) cerr<<#x<<'='<<x<<endl;
LL a,b;
LL get(LL x,int y){
  if(x<0)return 0;
  LL z=(x+1)/(1ll<<y+1);
  LL t=(x+1)%(1ll<<y+1);
  z*=1ll<<y;
  if(t>(1ll<<y)){
    t-=1ll<<y;
    z+=t;
  }
 // cout<<z<<endl;
  return z&1;
}
int ch(int x){
  //0  2^x
  //1  2^x
  return (get(a-1,x)-get(b,x)+2)%2;
}
int main() {
  ios::sync_with_stdio(false);
  cin>>a>>b;//1 2 3 4
  //00 01 10 11 00 01 10
  LL ans=0;
  for(int i=0;i<50;i++){
    if(ch(i))ans^=1ll<<i;
  }
  cout<<ans<<'\n';
  return 0;
}

Measured memory_bytes: 3648
#include <bits/stdc++.h>
#define ALL(a)  (a).begin(),(a).end()
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
typedef pair<long long, long long> Pll;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<long long> vll;
typedef vector<vector<long long>> vvll;
template <typename T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template <typename T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
const long long INF = 1LL << 60;
const int INT_INF = 1 << 30;
#define MOD 1000000007LL
#define endl "\n"

int main(){
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  ll X;
  cin >> X;
  ll num = 100LL;
  ll ans = 0;
  while(num < X){
    num += num/100;
    ans++;
  }
  cout << ans << endl;
}

Measured memory_bytes: 3608
#include <stdio.h>
char str[5000];
char ch;
int i;
int num;
int table[26];
 main()
{
while( scanf("%c",&str) != EOF ){	
	
	
	/*???????????°?????°???????????°?????????????¨???????????????¨???*/
	//scanf("%s",str );

	//char str[] = "This is a string.";/*??????*/

	/*??????str???i??????????????????NULL??????(??????????????????)??§????????????*/
		
		
		if (str[i] >= 97 && str[i] <= 122){
			table[str[i] - 97]++;/*?°???????*/
			continue;
		}
		
		if (str[i] >= 65 && str[i] <= 90){
			table[str[i] - 65]++;/*??§??????*/
			continue;
		}
		
		else {continue;}
		
		i++;
		
		if(str[i]<0)break;
		
	
}
for (i=0; i<26; i++) printf("%c : %d\n", 97 + i,table[i]);
//printf("%d charactors are counted.\n", num);

return 0;
}

Measured memory_bytes: 544
#include<iostream>
#include<bits/stdc++.h>
#define int long long
#define mod 1000000007
#define gcd(a,b) __gcd(a,b)
#define lcm(a,b) (a*b)/gcd(a,b)
#define vector vector<int>
#define vectorp vector<pair<int,int>>
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
using namespace std;
int32_t main()
{
   string a,b;
   cin >> a >> b;
   int r,s;
   cin >> r >> s;
   string res;
   cin >> res;
   if(res==a){
     cout<<r-1<<' '<<s;
   }
  else if(res==b){
    cout<<r<<' '<<s-1;
  }
  else{
    cout<<r<<" "<<s;
  }
}



Measured memory_bytes: 256