akhauriyash/Code-Regression huggingface dataset:
# include "bits/stdc++.h"
using namespace std;
using LL = long long;
using ULL = unsigned long long;
const double PI = acos(-1);
template<class T>constexpr T INF() { return ::std::numeric_limits<T>::max(); }
template<class T>constexpr T HINF() { return INF<T>() / 2; }
template <typename T_char>T_char TL(T_char cX) { return tolower(cX); };
template <typename T_char>T_char TU(T_char cX) { return toupper(cX); };
typedef pair<LL, LL> pii;
const int vy[] = { -1, -1, -1, 0, 1, 1, 1, 0 }, vx[] = { -1, 0, 1, 1, 1, 0, -1, -1 };
const int dx[4] = { 0,1,0,-1 }, dy[4] = { 1,0,-1,0 };
int popcnt(unsigned long long n) { int cnt = 0; for (int i = 0; i < 64; i++)if ((n >> i) & 1)cnt++; return cnt; }
int d_sum(LL n) { int ret = 0; while (n > 0) { ret += n % 10; n /= 10; }return ret; }
int d_cnt(LL n) { int ret = 0; while (n > 0) { ret++; n /= 10; }return ret; }
LL gcd(LL a, LL b) { if (b == 0)return a; return gcd(b, a%b); };
LL lcm(LL a, LL b) { LL g = gcd(a, b); return a / g*b; };
# define ALL(qpqpq)           (qpqpq).begin(),(qpqpq).end()
# define UNIQUE(wpwpw)        sort(ALL((wpwpw)));(wpwpw).erase(unique(ALL((wpwpw))),(wpwpw).end())
# define LOWER(epepe)         transform(ALL((epepe)),(epepe).begin(),TL<char>)
# define UPPER(rprpr)         transform(ALL((rprpr)),(rprpr).begin(),TU<char>)
# define FOR(i,tptpt,ypypy)   for(LL i=(tptpt);i<(ypypy);i++)
# define REP(i,upupu)         FOR(i,0,upupu)
# define INIT                 std::ios::sync_with_stdio(false);std::cin.tie(0)

int n;

string trance(int a){
    string ret;
    if(a==0)return "0";
    while (a)
    {
        ret = char(a % 4 + '0') + ret;
        a /= 4;
        //cerr << a << endl;
    }
    return ret;
}

int main(){
    INIT;
    while(cin>>n&&n!=-1){
        cout << trance(n) << endl;
    }
}


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

#define lli long long
#define FOR(i,a,b) for (lli i=(a);i<(b);i++)
#define REP(i,n) for (lli i=0;i<(n);i++)
#define rep(i,n) for (lli i=0;i<(n);i++)

#define INF INT_MAX/3
#define PB push_back
#define pb push_back
#define all(a) (a).begin(),(a),end()
#define pll pair<lli,lli>

int main(){
  lli r,c,sum=0;
  lli mat[101][101];
  lli sumr[101]={0},sumc[101]={0};

  cin>>r>>c;
  rep(i,r){
    rep(j,c){
      cin>>mat[i][j];
      sumr[i]+=mat[i][j];
      sumc[j]+=mat[i][j];
      cout<<mat[i][j]<<" ";
    }
    cout<<sumr[i]<<endl;
  }
  rep(i,c){
    cout<<sumc[i]<<" ";
    sum += sumc[i];
  }
  cout<<sum<<endl;

  return 0;
}

Measured memory_bytes: 3156
#include<iostream>

 using namespace std ;

 int main()

{

 int A, B, C, D, x, y, z, k;

 cin>>A;

 cin>>B;

 cin>>C;

 cin>>D;

x=(A+C);

y=(A+D);

z=(B+C);

k=(B+D);

if (x<=y&&x<=z&&x<=k)

{

  cout<<x<<endl;

}

if  (y<=k&&y<x&&y<=z)

{

  cout<<y<<endl;

}

if (z<y&&z<x&&z<=k)

{

  cout<<z<<endl;

}

if (k<y&&k<z&&k<x)

{

  cout<<k<<endl;

}

}

Measured memory_bytes: 3608
#include <bits/stdc++.h>
typedef long long ll;
const int INF=1e9,MOD=1e9+7,ohara=1e6;
const ll LINF=1e18;
using namespace std;

#define rep(i,n) for(ll (i)=0;(i)<(int)(n);(i)++)
#define rrep(i,a,b) for(ll i=(a);i<(b);i++)
#define rrrep(i,a,b) for(ll i=(a);i>=(b);i--)
#define all(v) (v).begin(), (v).end()
#define pb(q) push_back(q)
#define Size(n) (n).size()
#define Cout(x) cout<<(x)<<endl

ll n,cnt=0,ans=0,a,b,c,d,cmp,cmpp,m,h,w,x,y,sum=0,pos,k;
int dy[]={1,0,-1,0};
int dx[]={0,1,0,-1};
//int dy[]={-1,0,1,-1,1,-1,0,1};
//int dx[]={-1,-1,-1,0,0,1,1,1};
string alph("abcdefghijklmnopqrstuvwxyz"),s;
bool fl;
struct edge{int to,cost;};

//-------------------------↓↓↓↓↓↓------------------------

int main(void){
       cin.tie(0);
    ios::sync_with_stdio(false);
      
    cin>>a>>b>>k;
    rep(i,k){
        if(i%2==0){
           if(a%2==1)a--;
           a/=2;
           b+=a;
        }
        else{
            if(b%2==1)b--;
            b/=2;
            a+=b;
        }
    }
    cout<<a<<" "<<b<<"\n";
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>                   // below comment for pbds
#include<ext/pb_ds/assoc_container.hpp>   // to use it make ordered_set
#include<ext/pb_ds/tree_policy.hpp>       // all set fnct + = 1. order_of_key(x); // number of 
#define ll long long                      //element strictly smaller than it;
#define ld long double                    // 2. find_by_order(x),pointer el at x pos after sort  use as s.f();
#define ordered_set tree<ll, null_type,less<ll>, rb_tree_tag,tree_order_statistics_node_update>
using namespace std;                     
using namespace __gnu_pbds;
// assert(a[i]<n ) // if we want to check for special cond , used for debug
// make less_equal in order to make a multiset pbds
const ll Mod = (int)1e9;
ll CaseN=1;
ll fast_power(ll a,ll b,ll mod){
	ll ans=1;
	while(b>0){
	if(b&1){
	ans=(a*ans)%mod;
	}
	b=b>>1;
	a=(a*a)%mod;
	}
	return ans;
	}


ll nCr(ll n ,ll r)
{
ll p= n;
r = min(r,n-r);
ll a =1;
ll b=1;	
while(r)
{
	a = a*p;
	b = b*r;
	
	int g = __gcd(a,b);
	
	a = a/g;
	b = b/g;
	
	p--;
	r--;	
}	
return a;
	
}



void solve()
{
    ld a,b;
    cin>>a>>b;
    ll ans = (ll)(a*b);

  //cout<<"Case #"<<CaseN<<": ";
   CaseN++;
	// print your ans below;
 cout<<ans<<endl;
return ;
}


signed main() {
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	int t=1;
	//cin>>t;
	while(t--)
	{
	solve();	
	}
}


Measured memory_bytes: 3740
#include "bits/stdc++.h"
using namespace std;
#define sim template < class c
#define ris return * this
#define dor > debug & operator <<
#define eni(x) sim > typename \
enable_if<sizeof dud<c>(0) x 1, debug&>::type operator<<(c i) {
sim > struct rge { c b, e; };
sim > rge<c> range(c i, c j) { return rge<c>{i, j}; }
sim > auto dud(c* x) -> decltype(cerr << *x, 0);
sim > char dud(...);
struct debug {
#ifdef LOCAL
~debug() { cerr << endl; }
eni(!=) cerr << boolalpha << i; ris; }
eni(==) ris << range(begin(i), end(i)); }
sim, class b dor(pair < b, c > d) {
ris << "(" << d.first << ", " << d.second << ")";
}
sim dor(rge<c> d) {
*this << "[";
for (auto it = d.b; it != d.e; ++it)
*this << ", " + 2 * (it == d.b) << *it;
ris << "]";
}
#else
sim dor(const c&) { ris; }
#endif
};
#define imie(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "
#define cool ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define int  long long int
#define pb push_back
#define fe first
#define lb lower_bound 
#define ub upper_bound
#define pii pair<pair<int,int>,pair<int,int> >
#define se second
#define endl "\n"
#define pi pair<int, int>
#define mi          map<int,int>
#define mii         map<pi,int>
#define vi vector<int> 
#define vvi vector<vi>
#define bs   binary_search
#define rep(i,a,b) for(int i=a;i<b;i++)
#define rep1(i,a,b) for(int i=a;i<=b;i++)	
#define all(c) (c).begin(),(c).end()
#define sz(x)       (int)x.size() 
#define PI 3.14159265358979323846

 const int N=2e5+5;

 int mod= 1e9+7;
 int dx[4]={0,0,+1,-1};
 int dy[4]={+1,-1,0,0};  
 
 
int po(int a, int b) {
	a %= mod;
	int res = 1;
	while (b > 0) {
		if (b & 1)
			res = (res * a) % mod;
		a =(a*a) % mod;
		b >>= 1;
	}
	 return res;	
   }
  

   
 void solve() {
	  int a,b,c,d;
	  cin>>a>>b>>c>>d;
	  int f=0;
	  while(a>0 && c>0) {
		    if(!f) c-=b;
		    else a-=d;
		    f^=1;
		  }
		  //~ cout<<a<<" "<<b<<endl;
		  if(a<=0) cout<<"No\n";
		  else cout<<"Yes\n";	  	  
						   
 }

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


return 0;	   
}


Measured memory_bytes: 3644
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
const ll MOD = 1e9+7;
const ll INF = 1e18;
#define rep(i,m,n) for(int i = (m); i <= (n); i++)
#define zep(i,m,n) for(int i = (m); i < (n); i++)
#define rrep(i,m,n) for(int i = (m); i >= (n); i--)
#define print(x) cout << (x) << endl;
#define printa(x,m,n) for(int i = (m); i <= n; i++){cout << (x[i]) << " ";} cout<<endl;

int main(){
    cin.tie(0); ios::sync_with_stdio(false);
    
    ll a, b; cin >> a >> b;
    ll ans = 0;
    rep(i, a, b){
        string s = to_string(i);
        if(s[0] == s[4] && s[1] == s[3]){
            ans++;
        }
    }
    print(ans)
    return 0;
}

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

h = [[0, 0, 0] for i in range(N + 1)]

# a: 0 / b: 1 / c: 2
for i in range(1, N + 1):
    a, b, c = map(int, input().split())
    
    h[i][0] = max(h[i - 1][1] + a, h[i - 1][2] + a)
    h[i][1] = max(h[i - 1][0] + b, h[i - 1][2] + b)
    h[i][2] = max(h[i - 1][0] + c, h[i - 1][1] + c)

print(max(h[N]))

Measured memory_bytes: 59552
x, y, a, b, c = map(int, input().split())

ra = list(map(int, input().split()))
gb = list(map(int, input().split()))
sc = list(map(int, input().split()))

ra.sort(reverse=True)
gb.sort(reverse=True)
sc.sort(reverse=True)

curr_red_min_val = ra[x-1]
curr_green_min_val = gb[y-1]
tmp_x = x
tmp_y = y

for i in range(c):
  if tmp_x > 0 and curr_red_min_val < curr_green_min_val:
    if sc[i] > curr_red_min_val:
      ra[tmp_x-1] = sc[i]
      tmp_x -= 1
      if tmp_x != 0:
        curr_red_min_val = ra[tmp_x-1]
      else:
        curr_red_min_val = ra[0]
  elif tmp_y > 0:
    if sc[i] > curr_green_min_val:
      gb[tmp_y-1] = sc[i]
      tmp_y -= 1
      if tmp_y != 0:
        curr_green_min_val = gb[tmp_y-1]
      else:
        curr_green_min_val = gb[0]
      
print(sum(ra[:x])+sum(gb[:y]))

Measured memory_bytes: 23328
#include<bits/stdc++.h>
using namespace std;
#define MAX_N 100005
#define MAX_M 100005

int n,m,ans;
int x[MAX_M],y[MAX_M],w[MAX_M];
vector<int> G[MAX_N];
vector<int> g[MAX_N];
vector<int> group[MAX_N];
int id[MAX_N];
bool visited[MAX_N];
vector<int> vd;
int dp[MAX_N];
int d[MAX_N];

bool dfs(int pos,int prev,int root){
  id[pos]=root;
  visited[pos]=true;
  group[root].push_back(pos);
  for(int i=0;i<(int)G[pos].size();i++){
    int to=G[pos][i];
    if(to==prev)continue;
    if(i&&to==G[pos][i-1])return true;
    if(visited[to])return true;
    if(dfs(to,pos,root))return true;
  }
  return false;
}

bool check(){
  memset(visited,false,sizeof(visited));
  for(int i=0;i<n;i++)
    if(!visited[i]&&dfs(i,-1,i))return true;

  vector<int> deg(n);
  for(int pos=0;pos<n;pos++)
    for(int to:g[pos])
      deg[ id[to] ]++;

  queue<int> Q;
  for(int i=0;i<n;i++)
    if(deg[i]==0&&id[i]==i)
      Q.push(i);
  
  while(!Q.empty()){
    int root=Q.front();Q.pop();
    vd.push_back(root);
    for(int pos:group[root]){
      for(int to:g[pos]){
        deg[ id[to] ]--;
        if(deg[ id[to] ]==0)Q.push(id[to]);
      }
    }
  }
  for(int i=0;i<n;i++)
    if(deg[i]>0)return true;
  return false;
}

int solve(int S){
  for(int pos:group[id[S]])d[pos]=-1;
  queue<int> Q;
  Q.push(S);
  d[S]=0;
  while(!Q.empty()){
    int pos=Q.front();Q.pop();
    for(int to:G[pos]){
      if(d[to]!=-1)continue;
      d[to]=d[pos]+1;
      Q.push(to);
    }
  }
  int res=S;
  for(int pos:group[id[S]]){
    if(d[pos]+dp[pos]>d[res]+dp[res])res=pos;
    ans=max(ans,d[pos]+dp[S]);
    for(int to:g[pos])dp[to]=max(dp[to],d[pos]+dp[S]+1);
  }
  return res;
}

int main(){
  scanf("%d %d",&n,&m);
  for(int i=0;i<m;i++){
    scanf("%d %d %d",&x[i],&y[i],&w[i]);
    x[i]--,y[i]--;
    if(w[i]==1){
      g[x[i]].push_back(y[i]);
    }
    if(w[i]==2){
      G[x[i]].push_back(y[i]);
      G[y[i]].push_back(x[i]);
    }
  }
  if(check()){
    printf("Infinite\n");
    return 0;
  }
  for(int root : vd )
    if(root==id[root])
      solve(solve(solve(root)));
  printf("%d\n",ans);  
  return 0;
}

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

int n;
string s;
int niz[40];
map< pair<string, string>, int > m;
long long int sol = 0;

void rek(int x) {
	if (x == n) {
		
		string s1 = "", s2 = "";
		for (int i = n-1; i >= 0; i --) {
			if (niz[i] == 0) s1 += s[i];
			else s2 += s[i];
		}
		
		m[ make_pair(s1, s2) ] ++;
		return;
	}
	
	
	niz[x] = 0;
	rek(x+1);
	niz[x] = 1;
	rek(x+1);
}

void rj(int x) {
	if (x == 2*n) {
		
		string s1 = "", s2 = "";
		for (int i = n; i < 2*n; i ++) {
			if (niz[i] == 0) s1 += s[i];
			else s2 += s[i];
		}
		
		sol += m[ make_pair(s1, s2) ];
		return;
	}
	
	niz[x] = 0;
	rj(x+1);
	niz[x] = 1;
	rj(x+1);
}

int main () {

	cin >> n >> s;
	rek(0);
	rj(n);
	cout << sol;

	return 0;
}

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

using namespace std;
using ll = long long int;
using ld = long double;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using vi = vector<int>;
using vl = vector<ll>;
using vb = vector<bool>;
using vs = vector<string>;
using vvi = vector<vector<int>>;
using vvl = vector<vector<ll>>;
using vvb = vector<vector<bool>>;
using vvs = vector<vector<string>>;
template<typename T> using vv = vector<vector<T>>;
template<typename T> using vvv = vector<vector<vector<T>>>;
template<typename T> using pq = priority_queue<T>;
template<typename T> using pqg = priority_queue<T, vector<T>, greater<T>>;

const int INF = 1e9;
const ll LINF = 1e18;
const ll MOD = 1e9 + 7;
const int DX[4] = {1, 0, -1, 0};
const int DY[4] = {0, 1, 0, -1};

#define _sel(_1, _2, x, ...) x
#define repn(i, n) for (ll i = 0; i < (n); i++)
#define reps(i, a, b) for (ll i = (a); i < (b); i++)
#define rep(i, ...) _sel(__VA_ARGS__, reps, repn)(i, __VA_ARGS__)
#define reppn(i, n) for (ll i = 1; i <= (n); i++)
#define repps(i, a, b) for (ll i = (a); i <= (b); i++)
#define repp(i, ...) _sel(__VA_ARGS__, repps, reppn)(i, __VA_ARGS__)
#define rrepn(i, n) for (ll i = (n) - 1; i >= 0; i--)
#define rreps(i, a, b) for (ll i = (b) - 1; i >= (a); i--)
#define rrep(i, ...) _sel(__VA_ARGS__, rreps, rrepn)(i, __VA_ARGS__)
#define rreppn(i, n) for (ll i = (n); i >= 1; i--)
#define rrepps(i, a, b) for (ll i = (b); i >= (a); i--)
#define rrepp(i, ...) _sel(__VA_ARGS__, rrepps, rreppn)(i, __VA_ARGS__)

#define pb push_back
#define mp make_pair
#define mt make_tuple
#define fi first
#define se second
#define rng(v) (v).begin(), (v).end()
#define rrng(v) (v).rbegin(), (v).rend()
#define siz(x) int((x).size())
#define pow2(x) (1ll << (x))
#define bit(x, n) ((x) >> (n) & 1)
#define prt(x) cout << (x) << endl
#define dbg(x) dbgn(#x, x)

template<typename T, typename U> inline bool umax(T& m, U x) { if (m < x) { m = x; return true; } return false; }
template<typename T, typename U> inline bool umin(T& m, U x) { if (m > x) { m = x; return true; } return false; }
template<typename T> inline void errv(T& v) { for (auto x: v) cerr << x << " "; cerr << endl; }
inline void errv(vb& v) { for (auto x: v) cerr << (x ? 1 : 0) << " "; cerr << endl; }
template<typename T> inline void dbgn(string n, T x) { cerr << n << ": " << x << endl; }
template<typename T> inline void dbgn(string n, vector<T>& v) { cerr << n << ": "; errv(v); }
template<typename T> inline void dbgn(string n, vv<T>& m) { cerr << n << ":" << endl; for (auto& v: m) errv(v); }


int main() {
    int n;
    cin >> n;
    if (n % 1000 == 0)
        prt(0);
    else
        prt(1000 - n % 1000);

    return 0;
}


Measured memory_bytes: 3628
#include "bits/stdc++.h"
#define FOR(i, a, b) for (int i = a; i < b; i++)
#define mFOR(i, a, b) for (int i = a; i > b; i--)
#define MP make_pair
#define PB push_back
#define ALL(v) v.begin(), v.end()
#define N 100007
#define INF 1000000007
using namespace std;

typedef long long ll;

ll gcd(ll a, ll b) { return b == 0 ? a : gcd(b, a % b); }
ll fceil(ll a, ll b) { return (a % b == 0 ? a / b : a / b + 1); }
int main()
{
   int a, b;
   cin >> a >> b;

   int aa = ceil(a/0.08);
   int bb = ceil(b/0.1);
   if((int)(aa*0.1) == b)
      cout << aa << endl;
   else if((int)(bb*0.08) == a)
      cout << bb << endl;
   else
      cout << "-1" << endl;
   

   return 0;
}


Measured memory_bytes: 256
#include<stdio.h>

int A[100001];
int Partition(int p,int r){
  int i,j,x,key;
  x=A[r];
  i=p-1;
  
  for(j=p;j<r;j++){
    if(A[j]<=x){
      i++;
      key=A[i];
      A[i]=A[j];
      A[j]=key;
    }
  }
  
  key=A[i+1];
  A[i+1]=A[r];
  A[r]=key;
  return i+1;
}

int main(){
 
  int n,i,k;

  scanf("%d",&n);
  for(i=1;i<=n;i++) scanf("%d",&A[i]);

   k=Partition(1,n);
   for(i=1;i<=n;i++){
     if(i==n){
printf("%d",A[i]);    
 break;
     }
 if(i!=k)  printf("%d ",A[i]);
     else printf("[%d] ",A[i]);
   }
   printf("\n");
  return 0;
}

Measured memory_bytes: 992
#include <iostream>
#include <iomanip>
#include <string>
#include <vector>
#include <cmath>
#include <cstdlib>
#include <algorithm>
#include <numeric>
#include <map>
#include <queue>
#include <deque>
#include <set>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define FOR(i,a,b) for (int i = (a) ; i <= (b); ++i)
#define all(x) (x).begin(), (x).end()
//#define repitr(itr, st) for(auto itr = st.begin(); itr != st.end(); ++itr)
#define P_B push_back
#define PO_B pop_back
#define E_B emplace_back
#define M_P make_pair
#define fi first
#define se second
#define debug(x) cout << #x << ": " << x << endl
//#define print(x) printf("%d\n", x)

using namespace std;
using ll = long long;
using Pii = pair<int,int>;
using Pll = pair<ll,ll>;
using VI = vector<int>;
using VL = vector<ll>;
using VVI = vector<vector<int> >;
using VVL = vector<vector<ll> >;
//int dx[4] = {1, 0, -1, 0};
//int dy[4] = {0, 1, 0, -1};
//const ll LINF = (ll)1e18 - 1;
//const int INF = 1e9 - 1;
//int:±2*10^9くらい　ll:±9*10^18くらい


void Main(){
	int N, x, nx=0, ans = 1;
	cin >> N >> x;
	VI L(N);
	rep(i,N) cin >> L[i];

	int s = 0;
	while(s < N){
		nx += L[s];
		s++;
		if(nx > x) break;
		ans++;
	}

	cout << ans << endl;







}

int main()
{
	cin.tie(nullptr);
  ios_base::sync_with_stdio(false);
	cout << fixed << setprecision(15);
	Main();

  return 0;
}


Measured memory_bytes: 3536
#include<bits/stdc++.h>
#define rep(i,n) for(int (i) = 0;(i) < (n);(i)++)
#define SORT(c) sort((c).begin(),(c).end())
#define MOD 1000000007 //S(vector).size()
using namespace std;
typedef long long ll;

int main(void){
	int n, k;
	cin >> n >> k;
	vector<int> h(n);
	rep(i, n) cin >> h[i];

	SORT(h);
	int ans = MOD;
	for(int i = 0; i < n - k + 1; i++){
		int sa = h[i + k - 1] - h[i];
		ans = min(ans, sa);
	}
	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 640
N, M = map(int, input().split())
A = [int(i) for i in input().split()]

modDict = {}
B = 0
for i in range(N):
    B += A[i]
    if B%M in modDict:
        modDict[B%M] = modDict[B%M] + 1
    else:
        modDict[B%M] = 1

count = (modDict[0] if 0 in modDict else 0)
for i in modDict:
    count += (modDict[i] * (modDict[i] -1))//2
print(count)

Measured memory_bytes: 14252
// H - Grid 1
// A. Bacca
#include <bits/stdc++.h>
using namespace std;

int H, W;
vector <vector <char> > grid;
vector <vector <long long> > dp_grid;

long long M(long long x) { return x % (1000000000+7); }

void Recibir() {
	cin >> H >> W;
	grid.resize(H);
	for (int i=0; i<H; i++) {
		grid[i].resize(W);
		for (int j=0; j<W; j++) cin >> grid[i][j];
	}
	dp_grid.resize(H);
	for (int i=0; i<H; i++) {
		dp_grid[i].resize(W);
		for (int j=0; j<W; j++) dp_grid[i][j] = -1;
	}
}

long long Recorrer(int h, int w) {
	// DP
	if (dp_grid[h][w] != -1) return dp_grid[h][w];
	
	// Caso base
	if (h == H-1 && w == W-1) return dp_grid[h][w] = M(1);
	// Lateral derecho
	else if (w == W-1) return dp_grid[h][w] = M(grid[h+1][w] == '#' ? 0 : Recorrer(h+1, w));
	// Lateral bajo
	else if (h == H-1) return dp_grid[h][w] = M(grid[h][w+1] == '#' ? 0 : Recorrer(h, w+1));
	// Medio
	else return dp_grid[h][w] = M((grid[h+1][w] == '#' ? 0 : Recorrer(h+1, w)) + (grid[h][w+1] == '#' ? 0: Recorrer(h, w+1)));
}

int main() {
	Recibir();
	cout << Recorrer(0, 0);
}

Measured memory_bytes: 9216
#include<vector>
#include<string>
#include<algorithm>
#define rep(i,n) for(int i=0;i<n;i++)
using namespace std;
typedef vector<int> vi;

bool ng(string &s){
	return s.size()>1&&s[s.size()-1]=='X';
}
vi pl(string &t1,string &t2,int x){
	vi r(130);
	rep(i,129){
		int a=0,b=0;
		if(i<t1.size())a=t1[i]=='X'?x:t1[i]-'0';
		if(i<t2.size())b=t2[i]=='X'?x:t2[i]-'0';
		r[i]+=a+b;
		while(r[i]>9)r[i]-=10,r[i+1]++;
	}
	return r;
}
vi ev(string &s,int x){
	vi r(130);
	rep(i,130){
		int a=0;
		if(i<s.size())a=s[i]=='X'?x:s[i]-'0';
		r[i]=a;
	}
	return r;
}

int main(){
	string s,t1,t2,rhs;
	while(cin>>s){
		reverse(s.begin(),s.end());
		int ans=-1, p=s.find("=");
		rhs=s.substr(0,p); s=s.substr(p+1); if(s.find("=")!=s.npos)return 1;
		p=s.find("+"); t2=s.substr(0,p); t1=s.substr(p+1);
		rep(x,10){
			if(x==0&&(ng(t1)||ng(t2)||ng(rhs)))continue;
			if(pl(t1,t2,x)==ev(rhs,x)){
				ans=x;
				break;
			}
		}
		if(ans<0)cout<<"NA";
		else cout<<ans;
		cout<<endl;
	}
	return 0;
}

Measured memory_bytes: 0
# coding: utf-8
# Your code here!
SIZE=1000001; MOD=998244353 #ここを変更する

SIZE += 1
inv = [0]*SIZE  # inv[j] = j^{-1} mod MOD
inv[1] = 1
for i in range(2,SIZE):
    inv[i] = MOD - (MOD//i)*inv[MOD%i]%MOD


import sys
#sys.setrecursionlimit(10**6)
readline = sys.stdin.readline 

n = int(input())
a = [int(i) for i in readline().split()]

num = [0]*1000001
db = [0]*1000001
for i in a:
    num[i] += i
    db[i] += i*i
    db[i] %= MOD

def zeta(a,n):
    sieve = [True]*(n+1)
    for p in range(2,n):
        if sieve[p]:
            for k in range(n//p,0,-1):
                sieve[k*p] = False
                a[k] += a[k*p]
                a[k] %= MOD
    return a


def meb(a,n):
    sieve = [True]*(n+1)
    for p in range(2,n):
        if sieve[p]:
            for k in range(1,n):
                if k*p >= n: break
                sieve[k*p] = False
                a[k] -= a[k*p] 
                a[k] %= MOD
    return a


#n = 1000000

n = 1000000

#zn = [i*i for i in zeta(num,n)]
#zdb = zeta(db,n)
#print(zn[:20])
#print(zdb[:20])

zn = [i*i for i in zeta(num,n)]
zdb = zeta(db,n)
ans = [i-j for i,j in zip(zn, zdb)]

#ans = [i*i-j for i,j in zip(zeta(num,n), zeta(db,n))]

#print(ans[:20])
#print(meb(ans,n)[:20])

res = 0
for i,c in enumerate(meb(ans,n+1)):
    res = (res + c*inv[i])%MOD
        
print(res*inv[2]%MOD)









Measured memory_bytes: 154900
N, P = map(int, input().split())


def factorization(n):
    arr = []
    temp = n
    for i in range(2, int(-(-n ** 0.5 // 1)) + 1):
        if temp % i == 0:
            cnt = 0
            while temp % i == 0:
                cnt += 1
                temp //= i
            arr.append([i, cnt])

    if temp != 1:
        arr.append([temp, 1])

    if not arr:
        arr.append([n, 1])

    return arr


fp = factorization(P)
ans = 1
for f in fp:
    ans *= f[0]**(f[1]//N)

print(ans)


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

struct rest{
  int p,i;
  string s;
  rest(string s,int p,int i):s(s),p(p),i(i){}
};

int main(){
  vector<rest> rests;
  int n; cin >> n;
  for(int i=1;i<=n;i++){
    string s;
    int p;
    cin >> s >> p;
    rests.emplace_back(s,p,i);
  }
  auto cmp=[&](rest a, rest b){
    if(a.s!=b.s) return a.s < b.s;
    else return a.p > b.p;
  };
  
  sort(rests.begin(),rests.end(),cmp);
  for(auto r:rests) cout << r.i << endl;
}


Measured memory_bytes: 256
import java.util.Scanner;
public class Main {
	public static void main(String[] args) {
		Scanner sc=new Scanner(System.in);
		long n=sc.nextLong(),k=sc.nextLong();
		System.out.println(Math.min(n%k, Math.abs(n%k-k)));
		sc.close();
	}
}

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

int count_divisor(int n){
  int c = 0;
  
  for(int i = 0; i < n; i++){
    if (n % (i + 1) == 0) c++;
  }

  return c;
}

int main(int argc, char** argv){
  int n;
  
  while(cin >> n) {
    int c = 0;
    
    for (int i = 1; i <= n; i += 2){
      if (count_divisor(i) == 8) {
	c++;
      }
    }

    cout << c << endl;
  }

  return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<sstream>
#include<algorithm>
#include<vector>
#include<iomanip>
#include<cmath>
#include<complex>
#include<queue>
#include<deque>
#include<stack>
#include<map>
#include<set>
#include<bitset>
#include<functional>
#include<numeric>
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
using namespace std;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
using ll = long long;
const int inf=1e9+7;
const ll longinf=1LL<<60 ;
const ll mod=1e9+7 ;
int dx[4] = {1,0,-1,0}, dy[4] = {0,1,0,-1};

// int robots[(int)(1e9+7)]={0};
using Graph = vector<vector<int>>;

int main()
{
    ll N;
    vector<pair<ll,ll>> arms;

    cin >> N;
    for (int i=0; i<N; ++i)
    {
        ll x,l;
        cin >> x >> l;
        // --l;
        arms.push_back({x+l,x-l}); //{right,left}
    }
    sort(arms.begin(),arms.end());
    // ll cnt = 0;
    ll now = -(1LL << 60);
    ll ans = 0;
    for (int i=0; i<N; ++i)
    {
        // if(arms[i].second<=now) ++cnt;
        // else
        // {
        //     now = arms[i].first;
        // }
        if(now<=arms[i].second)
        {
            ++ans;
            now = arms[i].first;
        }
    }
    // cout << N-cnt << endl;
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 2420
import java.io.InputStream;
import java.io.PrintStream;
import java.util.*;

public class Main {

  public static void main(String[] args) {
    solve(System.in, System.out);
  }

  static void solve(InputStream is, PrintStream os) {
    Scanner sc = new Scanner(is);

    /* read */
    int n = sc.nextInt();
    int k = sc.nextInt();

    int[] values = new int[n];
    for (int i = 0; i < n; i++) {
      values[i] = sc.nextInt();
    }

    int max = 0;
    for (int leftOperation = 0; leftOperation <= k; leftOperation++) {
      int rightOperation = k - leftOperation;

      for (int leftTaking = 0; leftTaking <= Math.min(leftOperation, n); leftTaking++) {
        for (int rightTaking = 0; rightTaking <= Math.min(Math.min(rightOperation, n - leftTaking), n); rightTaking++) {
          int leftDrop = Math.min(leftTaking, leftOperation - leftTaking);
          int rightDrop = Math.min(rightTaking, rightOperation - rightTaking);

          List<Integer> left = new ArrayList<>();
          for (int i = 0; i < leftTaking; i++) {
            left.add(values[i]);
          }
          List<Integer> right = new ArrayList<>();
          for (int i = 0; i < rightTaking; i++) {
            right.add(values[n - 1 - i]);
          }
          Collections.sort(left);
          Collections.sort(right);
          while (left.size() > 0 && leftDrop > 0 && left.get(0) < 0) {
            left.remove(0);
            leftDrop--;
          }
          while (right.size() > 0 && rightDrop > 0 && right.get(0) < 0) {
            right.remove(0);
            rightDrop--;
          }
          int sum = 0;
          for (int l : left) {
            sum += l;
          }
          for (int r : right) {
            sum += r;
          }
          max = Math.max(max, sum);
        }
      }
    }

    os.println(max);
  }
}

Measured memory_bytes: 83132
#include <bits/stdc++.h>
using namespace std;
 
typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef vector<string> vs;
typedef vector<bool> vb;
typedef pair<int, int> P;

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()

void YN(bool flg){if(flg) cout << "YES" << endl; else cout << "NO" << endl;}
void Yn(bool flg){if(flg) cout << "Yes" << endl; else cout << "No" << endl;}
void yn(bool flg){if(flg) cout << "yes" << endl; else cout << "no" << endl;}

int main() {
   string s;
   cin >> s;
   rep(i, s.size()) {
       if(s[i] == ',') cout << " ";
       else cout << s[i];
   }
   cout << endl;

    return 0;
}


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

int main() {
  string s,t;cin>>s>>t;
  map<int,int> prevS;
  map<int,int> prevT;
  for(int i=0;i<s.size();i++){
    int s1=s[i]-'a',t1=t[i]-'a';
    if(prevS[s1]!=prevT[t1]){
      cout<<"No"<<endl;
      return 0;
    }
    prevS[s1]=prevT[t1]=i;
  }
  cout<<"Yes"<<endl;
}


Measured memory_bytes: 776
#include <algorithm>
#include <cassert>
#include <chrono>
#include <cmath>
#include <functional>
#include <iomanip>
#include <iostream>
#include <numeric>
#include <queue>
#include <string>
#include <unordered_map>
#include <vector>
using namespace std;
using ll = int64_t;
#define rep(i, j, n) for (int i = j; i < (int)n; ++i)
#define rrep(i, j, n) for (int i = (int)n - 1; j <= i; --i)

constexpr ll MOD = 1000000007;

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

  unordered_map<int, ll> mp;
  rep(m, 2, n + 1) {
    int d = m;
    for (int i = 2; i * i <= d; ++i)
      while (d % i == 0) {
        ++mp[i];
        d /= i;
      }
    if (d != 1) ++mp[d];
  }

  ll ans = 1;

  for (auto p : mp) ans = ans * (p.second + 1) % MOD;
  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 3628
import java.io.*;
import java.math.BigInteger;
import java.util.Scanner;

public class Main {
    @SuppressWarnings("resource")
    public static void main(String[] args) throws IOException {
        Scanner in = new Scanner(System.in);
            String path = System.getProperty("user.dir");
          BufferedReader br =
                    new BufferedReader(new InputStreamReader(System.in));
            String line = br.readLine();
            String[] temp = line.split(" ");
            int arraySize = Integer.parseInt(temp[0]);
            int[] array = new int[arraySize];
            long sumOfArray = 0;
            line = br.readLine();
            temp = line.split(" ");
            for (int i = 0; i < arraySize; i++) {
                array[i] = Integer.parseInt(temp[i]);
                sumOfArray += array[i];
            }
            line = br.readLine();
            temp = line.split(" ");
            int inputSize = Integer.parseInt(temp[0]);
            int[][] inputArray = new int[inputSize][2];
            for (int i = 0; i < inputSize; i++) {
                line = br.readLine();
                temp = line.split(" ");
                inputArray[i][0] = Integer.parseInt(temp[0]);
                inputArray[i][1] = Integer.parseInt(temp[1]);
            }
            int[] indexingOfArray = new int[100001];
            for (int i = 0; i < arraySize; i++) {
                indexingOfArray[array[i]]++;
            }
            long[] output = new long[inputSize];
            for (int i = 0; i < inputSize; i++) {
                int preValue = inputArray[i][0];
                int newValue = inputArray[i][1];
                int noOfTimesPreValueCome = indexingOfArray[preValue];
                indexingOfArray[preValue] = 0;
                indexingOfArray[newValue] = indexingOfArray[newValue] + noOfTimesPreValueCome;
                BigInteger bPreValue = new BigInteger(String.valueOf(preValue));
                BigInteger bNewValue = new BigInteger(String.valueOf(newValue));
                BigInteger bNoOfTimesPreValueCome = new BigInteger(String.valueOf(noOfTimesPreValueCome));
                BigInteger bSumOfArray = new BigInteger(String.valueOf(sumOfArray));
                BigInteger bTempOutput = bSumOfArray.subtract( (bPreValue.multiply(bNoOfTimesPreValueCome) ) ).add( (bNewValue.multiply(bNoOfTimesPreValueCome) ) );
                output[i]=bTempOutput.longValue();
                sumOfArray = output[i];
                System.out.println(output[i]);
            }


    }
}


Measured memory_bytes: 66900
while n = gets
	n = n.to_i
	count = 0
	if n <= (9 * 4)
		10.times { |a|
			10.times { |b|
				10.times { |c|
					10.times { |d|
						count += 1 if n == a + b + c + d
					}
				}
			}
		}
	end
	puts count
end

Measured memory_bytes: 2276
n = int(input())
a = [-1] + list(map(int, input().split())) + [10**7]
a.sort()

# print(a)
ans = 0
furui = [True]*(10**6+1)
for i in range(1,n+1):
    if not furui[a[i]]: continue
    if a[i-1] != a[i] and a[i] != a[i+1]:
        ans += 1
    for j in range(a[i],10**6+1,a[i]):
        furui[j] = False

print(ans)

Measured memory_bytes: 98548
import bisect
import cmath
import heapq
import itertools
import math
import operator
import os
import random
import re
import string
import sys
from collections import Counter, deque, defaultdict
from copy import deepcopy
from decimal import Decimal
from fractions import gcd
from functools import lru_cache, reduce
from operator import itemgetter, mul, add, xor

import numpy as np

if os.getenv("LOCAL"):
    sys.stdin = open("_in.txt", "r")

sys.setrecursionlimit(10 ** 9)
INF = float("inf")
IINF = 10 ** 18
MOD = 10 ** 9 + 7
# MOD = 998244353

a, b = list(map(int, sys.stdin.buffer.readline().split()))

s = 0
for i in range(b - a):
    s += i
ans = s - a
print(ans)


Measured memory_bytes: 14900
#include<iostream>
#include<string>
#include<algorithm>
#include<cstdlib>
#include<cmath>
#include<vector>
#include<list>
#include<cstdint>
#include<bits/stdc++.h>
#include<queue>
#include<set>

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define rep_r(i, n) for(int i = n-1; i >= 0; i--)
#define rep1(i, n) for(int i = 1; i <= (int)(n); i++)
#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define all(x) (x).begin(),(x).end()
#define SZ(x) ((ll)(x).size())
#define bit(n) (1LL<<(n))
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );

#define INF bit(60)
#define pb push_back
#define mod 1000000007

template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

using namespace std;
using uif=uint_fast64_t;
using ll=long long int;

int qp(int a,ll b){int ans=1;do{if(b&1)ans=1ll*ans*a%mod;a=1ll*a*a%mod;}while(b>>=1);return ans;}
int qp(int a,ll b,int mo){int ans=1;do{if(b&1)ans=1ll*ans*a%mo;a=1ll*a*a%mo;}while(b>>=1);return ans;}

int gcd(int a,int b){return b?gcd(b,a%b):a;}
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};


#define FACSIZE 2002

ll invfac[FACSIZE];
ll fac[FACSIZE];

ll mod_pow(ll ,ll );
ll mod_add(ll ,ll );
ll mod_mul(ll ,ll );
ll mod_div(ll ,ll );
void make_fact(ll );
void make_invfact(ll );



int main(void){

  ll n;
  cin>>n;
  vector<ll> p(n);
  vector<ll> idx(n);
  rep(i,n){
    cin>>p[i];
    idx[ p[i]-1 ]=i;
  }
  multiset<ll> se;
  se.insert(-1);
  se.insert(-1);
  se.insert(n);
  se.insert(n);

  ll ans=0;

  rep_r(i,n){

    auto x=i+1;
    auto pos=idx[i];

    auto t_z=se.upper_bound(pos);
    auto t_w=t_z;
    t_w++;
    auto s_y=t_z;
    s_y--;
    auto s_x=s_y;
    s_x--;
    
    if(i==n-1){
      se.insert( pos );
    }
    else{
      ans+=x*( ( *s_y - *s_x)*(*t_z-pos)+( pos - *s_y )*( *t_w - *t_z ) );
      se.insert( pos );
    }

  }

  cout << ans << endl;  
  
  return 0;

}

ll mod_pow(ll x,ll r){
  if(r==0) return 1;
  else if(r==1) return x%mod;
  else if(r%2==0){
    ll t=mod_pow(x,r/2)%mod;
    return t*t %mod;
  } 
  else{
    ll t=mod_pow(x,r/2)%mod;
    ll k= t*t %mod;
    return k*x%mod;
  } 
}
ll mod_add(ll a,ll b){
  return (a+b)%mod;
}

ll mod_mul(ll a,ll b){
  return (a*b)%mod;
}

ll mod_div(ll a,ll b){
  return mod_mul(a,mod_pow(b,mod-2));
}

void make_fact(ll n){
  fac[0]=1;
  rep(i,n){
    fac[i+1]=mod_mul(fac[i],i+1);
  }  
}

void make_invfact(ll n){
  invfac[n]= mod_pow( fac[n] ,mod-2);
  for(int i=n-1;i>=0;i--){
    invfac[i]=mod_mul(invfac[i+1],i+1);
  }

}

Measured memory_bytes: 6528
#include<cstdio>
#include<algorithm>
using namespace std;
int n;
long long T, a, M, S;
int main() {
    int i;
    scanf("%d%lld", &n, &T);
    for (i = 1; i <= n; i ++ ) {
        scanf("%lld", &a);
        M = max(M, a);
 
        printf("%lld\n", max(T - S+M-a, 0ll) / M + 1);
 
        S += a;
    }
}

Measured memory_bytes: 2756
/*
問題の名称：Graph I - Breadth Forst Search
問題のURL：http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=ALDS1_11_C&lang=jp
所要時間：50分程度
学んだこと：幅優先探索
着席位置：中央　中央
*/
#include <iostream>
#include <queue>
using namespace std;
const int INF = -1;

int main()
{
	int n;
	cin >> n;
	vector<int> edges[n];
	vector<int> d(n);

	d[0] = 0;

	for (int i = 1; i < n; ++i)
	{
		d[i] = INF;
	}

	int u,k,v;

	for (int i = 0; i < n; ++i)
	{
		cin >> u >> k;

		for (int j = 0; j < k; ++j)
		{
			cin >> v;
			edges[i].push_back(v-1);
		}
	}

	queue<int> Q;
	Q.push(0);
	int temp,next;
	while(!Q.empty())
	{
		temp = Q.front();
		Q.pop();
		for (int i = 0; i < edges[temp].size(); ++i)
		{
			next = edges[temp][i];
			if (d[next] == INF)
			{
				Q.push(next);
				d[next] = d[temp] + 1;
			}
		}
	}

	for (int i = 0; i < n; ++i)
	{
		cout << i+1 << " " << d[i] << endl;
	}
	return 0;
}


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

public class Main{
	public static void main(String[] args){
		solve();
	}
	public static void solve(){
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int a = sc.nextInt();
		int b = sc.nextInt();
		System.out.println((int)Math.min(n*a,b));	
	}
}


Measured memory_bytes: 21972
N = int(input())
A = list(map(int,("0 "+input()+" 0").split()))
A_d = [abs(A[i]-A[i+1]) for i in range(N+1)]
s = sum(A_d)
for i in range(1,N+1):
    print(s-A_d[i-1]-A_d[i]+abs(A[i-1]-A[i+1]))

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

if N%2==1:
    print(0)
else:
    k2, k5 = 0, 0
    s = 1
    while 1:
        v = N//(2**s)
        if v==0:
            break
        else:
            k2 += v
        s+=1

    s = 1
    while 1:
        v = N//(5**s)
        if v==0:
            break
        else:
            k5 += (v//2)
        s+=1
    
    print(min(k2, k5))

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

const int ALP_NUM = 26;

int main() {
    int d;
    cin >> d;
    vector<int> C(ALP_NUM);
    rep(i, ALP_NUM) cin >> C[i];
    vector<vector<int>> S(d, vector<int>(ALP_NUM));
    rep(i, d) rep(j, ALP_NUM) cin >> S[i][j];
    vector<int> T;
    vector<set<int>> schedules(ALP_NUM);
    rep(i, ALP_NUM) schedules[i].insert(-1);
    

    auto get_score = [&](vector<int> A, int n) {
        int res = 0;
        vector<int> D(ALP_NUM, -1);
        rep(i, n) {
            int t = A[i];
            res += S[i][t];
            D[t] = i;
            rep(j, ALP_NUM) {
                res -= (i-D[j]) * C[j];
            }
        }
        return res;
    };

    auto change = [&](int nd, int nt) {
        int pt = T[nd];
        int res = S[nd][nt] - S[nd][pt];

        auto it_l = schedules[pt].lower_bound(nd);
        auto it_r = schedules[pt].upper_bound(nd);
        --it_l;
        int pt_ld = *it_l;
        int pt_rd;
        if (it_r != schedules[pt].end()) pt_rd = *it_r;
        else pt_rd = d;
        res -= C[pt] * (nd-pt_ld) * (pt_rd-nd);

        it_l = schedules[nt].lower_bound(nd);
        it_r = schedules[nt].upper_bound(nd);
        --it_l;
        int nt_ld = *it_l;
        int nt_rd;
        if (it_r != schedules[nt].end()) nt_rd = *it_r;
        else nt_rd = d;
        res += C[nt] * (nd-nt_ld) * (nt_rd-nd);

        return res;
    };

    rep(i, d) {
        int tmp = 0, max_diff = 0;
        T.push_back(0);
        schedules[0].insert(i);
        rep(j, ALP_NUM) {
            int diff = change(i, j);
            if (diff > max_diff) {
                max_diff = diff;
                tmp = j;
            }
        }
        T[i] = tmp;
        schedules[0].erase(i);
        schedules[tmp].insert(i);
    }
    

    rep(i, d) {
        cout << T[i]+1 << endl;
    }

    //cout << get_score(T, d) << endl;

    return 0;
}

Measured memory_bytes: 3676
#include <cstdio>
#include <cstdint>
#include <algorithm>

constexpr intmax_t INF = 1e10;

intmax_t f(intmax_t h, intmax_t w) {
  intmax_t res = INF;
  for (intmax_t i = 1; i < h; ++i) {
    intmax_t s0 = w*i;
    intmax_t s1 = (w/2)*(h-i);
    intmax_t s2 = (w-w/2)*(h-i);
    res = std::min(res, std::max({s0, s1, s2})-std::min({s0, s1, s2}));
  }
  return res;
}

int main() {
  intmax_t H, W;
  scanf("%jd %jd", &H, &W);

  if (H % 3 == 0 || W % 3 == 0)
    return puts("0"), 0;

  printf("%jd\n", std::min({H, W, f(H, W), f(W, H)}));
}


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

const int INF = pow(2, 31) - 1;
#define ll long long
#define DEBUG(x) cout << "DEBUG>" << #x << ":" << x << endl;
#define REP(i,n) for(ll i=0;i<(n);i++)
#define FOR(i,a,b) for(ll i=(a);i<=(b);i++)
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}

int main() {
  int N;
  cin >> N;
  int ans = INF;
  FOR(i, 0, N) {
    int ans_cmp = 0;
    int p = 0;
    int t = i;
    while(t > 0) {
      ans_cmp += (int)floor(t / pow(6, p)) % 6;
      t -= (int)pow(6, p) * ((int)floor(t / pow(6, p)) % 6);
      p++;
    }
    t = N - i;
    p = 0;
    while(t > 0) {
      ans_cmp += (int)floor(t / pow(9, p)) % 9;
      t -= (int)pow(9, p) * ((int)floor(t / pow(9, p)) % 9);
      p++;
    }
    ans = min(ans, ans_cmp);
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 384
#include <stdio.h>
#include <string.h>
int max(int x,int y){
  if(x>y) return x;
  else return y;
}


int main(void){
  char s[15];
  scanf("%s", s);
  int c =strlen(s);
  int sum =0;
  int ans =0;
  
  for(int i=0;i<c;i++){
    if(s[i]=='A'||s[i]=='T'||s[i]=='G'||s[i]=='C'){
      sum++;
    }else{
      
      sum=0;
    }
    ans=max(sum,ans);
  }
  
  printf("%d", ans);
  return 0;
}

Measured memory_bytes: 1736
#include <stdio.h>
#include <iostream>
#include <algorithm>
#include <string.h>
#include <string>
#include <vector>
#include <stack>
#include <utility>
#include <queue>
#include <math.h>
#define MAX 100000
#define ll long long
using namespace std;

ll n;
vector<ll> adj[100005];
void bfs(ll x, ll dist, vector<ll>& distance)
{
	distance[x] = dist;
	for (auto y : adj[x])
		if (distance[y] == -1)
			bfs(y, dist + 1, distance);
}
int main(void)
{
	cin >> n;
	ll u, v, i, a, b;
	vector<ll> f(100005, -1), l(100005, -1);
	for (i = 1; i < n; i++)
	{
		cin >> u >> v;
		adj[u].push_back(v);
		adj[v].push_back(u);
	}
	bfs(1, 0, f);
	bfs(n, 0, l);
	a = b = 0;
	for (i = 2; i < n; i++)
	{
		if (f[i] <= l[i]) a++;
		else b++;
	}
	if (a > b)
		cout << "Fennec\n";
	else
		cout << "Snuke\n";
	return false;
}

Measured memory_bytes: 11904
#include <bits/stdc++.h>
#define ll long long
#define mod 1000000007
#define pb push_back
#define fi first
#define se second
#define mp make_pair
#define pi pair<ll,ll>
using namespace std;
int dist(int ax,int ay,int bx,int by){
	return abs(ax-bx)+abs(ay-by);
}
int main(){
	//	freopen("in.txt","r",stdin);
	int N,M;
	int a[51],b[51],c[51],d[51];
	cin >> N >> M;

	for (int i = 0; i < N; ++i)
	{
		scanf("%d%d",&a[i],&b[i]);
	}
	for (int i = 0; i < M; ++i)
	{
		scanf("%d%d",&c[i],&d[i]);
	}
	for (int i = 0; i < N; ++i)
	{
		int tmin = numeric_limits<int>::max();
		int ans = 0;
		for (int j = 0; j < M; ++j)
		{
			int val = dist(a[i],b[i],c[j],d[j]);
			if(tmin > val){
				tmin = val;
				ans = j;
			}
		}
		cout << ans+1 << endl;
	}
	return 0;
}

Measured memory_bytes: 256
num_list = [int(i) for i in input().split()]
have_list = [list(map(int, input().split())) for i in range(num_list[1]*2)]
user_list = [have_list[i] for i in range(len(have_list)) if i % 2 != 0]

check_set = []
for i in user_list:
    check_set += i
check_set = set(check_set)

ans_num = num_list[0] - len(check_set)
print(ans_num)

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

int main() {
  int a, b, c;
  cin >> a >> b >> c;
  int ans = 500000;
  if(a + b < ans) ans = a + b;
  if(a + c < ans) ans = a + c;
  if(b + c < ans) ans = b + c;
  cout << ans;
 return 0;
}



Measured memory_bytes: 3604
A = list(map(int, list(input())))
N = len(A)
ans = 1<<29

for x in range(2):
    tmp = 0
    B = [0 for _ in range(N)]
    for i in range(x, N, 2):
        B[i] = 1
    for i in range(N):
        if A[i] != B[i]:
            tmp += 1
    ans = min(ans, tmp)

print (ans)

Measured memory_bytes: 5404
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace SoundHound3
{
    public class Program
    {
        public static void Main(string[] args)
        {
            var line = Console.ReadLine().Split(' ');
            var n = int.Parse(line[0]);
            var m = int.Parse(line[1]);
            var d = int.Parse(line[2]);

            var r = Calc(n, m, d);
            Console.WriteLine(r);
        }

        public static double Calc(int n = 2, int m = 3, int d = 1)
        {
            double numPattern;

            if (d != 0)
            {
                int c = n - d; 
                numPattern = c * 2;
            }
            else
            {
                numPattern = n;
            }

            return (numPattern / Math.Pow(n, 2)) * (m - 1);
        }
    }
}


Measured memory_bytes: 11092
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define all(x) (x).begin(),(x).end()
#define pb push_back
#define eb emplace_back
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vi> vvi;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
ll gcd(ll a, ll b) { return b?gcd(b,a%b):a;}
ll lcm(ll a, ll b) { return a/gcd(a,b)*b;}
int const INF = 1001001001;
ll const MOD = 1000000007;


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

int N;
cin >> N;
vector<string> w(N);
rep(i,N) cin >> w[i];

bool ok = true;

set <string> st;
st.insert(w[0]);

for(int i = 1 ; i < N ; i++ ) {
    st.insert(w[i]);
    int s = w[i-1].size();
    if(w[i][0] != w[i-1][s-1]) ok = false;
}

if( st.size() != N ) ok = false;

if(ok) cout << 'Y' << 'e' << 's' << endl;
else cout << 'N' << 'o' << endl;

return 0;
}

Measured memory_bytes: 256
import math
N,D = map(int,input().split())
s = []
cnt = 0
for i in range(N):
    s.append(list(map(int,input().split())))
for i in range(N-1):
    for j in range(i+1,N):
        sub = 0
        dis = 0
        for k in range(D):
            sub += math.pow(abs(s[i][k] -s[j][k]),2)
            
        dis = math.sqrt(sub)
        if dis.is_integer():
            cnt += 1
print(cnt)

Measured memory_bytes: 3064
from heapq import *
import sys
from collections import *

from itertools import *
from decimal import *
import copy
from bisect import *
import time

import math

def gcd(a,b):
    if(a%b==0):return(b)
    return (gcd(b,a%b))
sys.setrecursionlimit(10**7)
input=lambda :sys.stdin.readline().rstrip()
N,M=map(int,input().split())
print(N*(N-1)//2 + M*(M-1)//2)


Measured memory_bytes: 60524
#include <iostream>
#include <algorithm>
using namespace std;
int main(void){
    int num;
    int a,b,c;
    int rest;
    int M;
    cin >> num;
    for(int i=0;i<num;i++){
        cin >>a>>b>>c;
        M=max(a,max(b,c));
        M=M*M;
        rest=a*a+b*b+c*c;
        rest=rest-M;
        if(M==rest){
            cout <<"YES"<<endl;
        }else{
            cout <<"NO"<<endl;
        }
    }
}

Measured memory_bytes: 1152
#include <bits/stdc++.h>
#define VI vector<int> 
#define SI set<int>
#define QI queue<int> 
#define PII pair<int,int>
#define PB push_back
#define REP(i,a,b) for(int i = a; i < b; ++i)
#define FIO ios_base::sync_with_stdio(false);cin.tie(NULL);
#define ll long long int
#define M 1000000007
using namespace std;

bool cmp(PII p1, PII p2) {
	return (p1.first > p2.first or (p1.first == p2.first and p1.second < p2.second));
}

int main() 
{
    FIO
    vector<PII> v;
    int x,y,a,b,c,temp; cin>>x>>y>>a>>b>>c;
    REP(i,0,a) { cin>>temp; v.PB(make_pair(temp,1)); }
    REP(i,0,b) { cin>>temp; v.PB(make_pair(temp,2)); }
    REP(i,0,c) { cin>>temp; v.PB(make_pair(temp,3)); }

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

    int n = x + y;
    ll delcs=0;
    int idx = 0;
    int i = a+b+c-1,z=0;

    while (x > 0 or y > 0) {
		if (v[i].second == 1 and x > 0) {delcs += v[i].first; x--;}
		else if (v[i].second == 2 and y > 0) {delcs += v[i].first; y--;}
		else if(v[i].second == 3) {	
			z++;
			delcs += v[i].first;
		}
		i--;
		if(x+y == z or i < 0) break;	
    }

    cout<<delcs<<endl;


    return 0;
}

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

using namespace std;
using ll = long long;
using ull = unsigned long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vl = vector<ll>;
using vvl = vector<vl>;

void AGC034B()
{
	string s;
	cin >> s;
	int i = 0;
	int nA = 0;
	ll ct = 0;
	for (; i < s.size() -1; ++i)
	{
		if (s[i] == 'A')
		{
			++nA;
		}
		else if (s[i] == 'B' && s[i + 1] == 'C')
		{
			ct += nA;
			++i;
		}
		else
		{
			nA = 0;
		}
	}
	cout << ct << endl;
}
int main()
{
	AGC034B();
	return 0;
}

Measured memory_bytes: 640