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

typedef long long ll;
typedef pair<int, int> P;
typedef pair<ll, ll> Pl;

const int INT_INF = 2147483646;
const ll LL_INF = 9223372036854775807;

bool SecondCompare(const pair<int,int> &a,const pair<int,int> &b)
{
       return a.second<b.second;
}
 
bool SecondCompareDes(const pair<int,int> &a,const pair<int,int> &b)
{
       return a.second>b.second;
}

ll minll(ll a, ll b){
    if(a >= b)  return b;
    else    return a;
}

ll maxll(ll a, ll b){
    if(a >= b)  return a;
    else    return b;
}

ll n, ans;
const ll mo = 1E9+7;
ll mera[1001];

int main(){
    for(int i = 2; i <= 1000; i++){
        for(int j = 2; j <= 1000/i; j++){
            mera[i*j] = 1;
        }
    }

    vector<int> so, c;
    for(int i = 2; i <= 1000; i++){
        if(mera[i] == 0){
            so.push_back(i);
            c.push_back(0);
        }
    }


    cin >> n;
    ans = 1;
    ll mem, memj;

    for(int j = 1; j <= n; j++){
        memj = j;
        for(int i = 0; i < so.size(); i++){
            if(memj == 1)   break;
            while(memj%so[i] == 0){
                c[i]++;
                memj/=so[i];
            }
        }
    }

    for(int i = 0; i< c.size(); i++){
        ans *= c[i]+1;
        ans %= mo;
    }

    cout << ans << endl;
}

Measured memory_bytes: 256
#pragma GCC optimize ("Ofast")
#include<bits/stdc++.h>
using namespace std;
inline void rd(int &x){
  int k;
  int m=0;
  x=0;
  for(;;){
    k = getchar_unlocked();
    if(k=='-'){
      m=1;
      break;
    }
    if('0'<=k&&k<='9'){
      x=k-'0';
      break;
    }
  }
  for(;;){
    k = getchar_unlocked();
    if(k<'0'||k>'9'){
      break;
    }
    x=x*10+k-'0';
  }
  if(m){
    x=-x;
  }
}
inline void rd(char &c){
  int i;
  for(;;){
    i = getchar_unlocked();
    if(i!=' '&&i!='\n'&&i!='\r'&&i!='\t'&&i!=EOF){
      break;
    }
  }
  c = i;
}
inline int rd(char c[]){
  int i;
  int sz = 0;
  for(;;){
    i = getchar_unlocked();
    if(i!=' '&&i!='\n'&&i!='\r'&&i!='\t'&&i!=EOF){
      break;
    }
  }
  c[sz++] = i;
  for(;;){
    i = getchar_unlocked();
    if(i==' '||i=='\n'||i=='\r'||i=='\t'||i==EOF){
      break;
    }
    c[sz++] = i;
  }
  c[sz]='\0';
  return sz;
}
inline void wt_L(char a){
  putchar_unlocked(a);
}
inline void wt_L(int x){
  int s=0;
  int m=0;
  char f[10];
  if(x<0){
    m=1;
    x=-x;
  }
  while(x){
    f[s++]=x%10;
    x/=10;
  }
  if(!s){
    f[s++]=0;
  }
  if(m){
    putchar_unlocked('-');
  }
  while(s--){
    putchar_unlocked(f[s]+'0');
  }
}
int N;
int M;
int P;
char S[4];
int res1;
int res2;
int ok[100000];
int ng[100000];
int main(){
  int Lj4PdHRW, i;
  rd(N);
  rd(M);
  for(Lj4PdHRW=(0);Lj4PdHRW<(M);Lj4PdHRW++){
    rd(P);P += (-1);
    rd(S);
    if(ok[P]){
      continue;
    }
    if(S[0]=='A'){
      ok[P]++;
    }
    else{
      ng[P]++;
    }
  }
  for(i=(0);i<(N);i++){
    if(ok[i]){
      res1++;
      res2 += ng[i];
    }
  }
  wt_L(res1);
  wt_L(' ');
  wt_L(res2);
  wt_L('\n');
  return 0;
}
// cLay varsion 20200112-1

// --- original code ---
// int N, M, P; char S[4];
// int res1, res2, ok[1d5], ng[1d5];
// {
//   rd(N,M);
//   rep(M){
//     rd(P--,S);
//     if(ok[P]) continue;
//     if[S[0]=='A', ok[P], ng[P]]++;
//   }
//   rep(i,N) if(ok[i]) res1++, res2 += ng[i];
//   wt(res1,res2);
// }


Measured memory_bytes: 1024
#include <bits/stdc++.h>
typedef long long ll;
#define  rep(i,a,b)for(long long i=a;i<b;++i)
#define  rrep(i,a,b)for(int i=a;i>=b;--i)
#define  yesno(flag)if(flag)cout<<"Yes"<<endl; else cout<<"No"<<endl;
using namespace std;
const ll INF=100000000000000LL;
const ll r197=1000000007;
typedef pair<ll,ll>P;
typedef pair<int,P>Pa;
bool Inframe(int a,int b,int c,int d,int h,int w){
	if(a+b>=0&&a+b<h&&c+d>=0&&c+d<w)return true;
	return false;
}
//void swap(ll a,ll b){
//	ll d;
//	d=a;
//	a=b;
//	b=d;
//	return;
//}
ll mypow(ll x,int m){
	if(m==0)return 1;
	if(m%2==0){
		int x2=mypow(x,m/2);
		return x2*x2;
	}else{
		int x2=mypow(x,m/2);
		return x2*x2*x;
	}
}
long long modinv(long long a, long long m) {
    long long b = m, u = 1, v = 0;
    while (b) {
//    	cout<<b<<endl;
        long long t = a / b;
        a -= t * b; swap(a, b);
        u -= t * v; swap(u, v);
    }
    u %= m;
    if (u < 0) u += m;
    return u;
}
ll X,Y;
ll x,y;
int main() {
	cin>>X>>Y;
	if((2*Y-X)%3!=0){
		cout<<0<<endl;
		return 0;
	}
	if((2*X-Y)%3!=0){
		cout<<0<<endl;
		return 0;
	}
	x=(2*X-Y)/3;
	y=(2*Y-X)/3;
	if(x<0||y<0){
		cout<<0<<endl;
		return 0;
	}
	ll xy=x+y;
	ll r=1,l=1;
	for(int i=xy;i>xy-x;--i){
		r=(r*i)%r197;
	}
	for(int i=2;i<=x;++i){
//		cout<<"a"<<endl;
		l=(l*modinv(i,r197))%r197;
	}
	cout<<(r*l)%r197<<endl;
	return 0;
}


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

using namespace std;

typedef long long ll;

#define rep(i,p,q) for(ll i = p; i < q; i++)
#define repD(i,p,q) for(ll i = p; i > q; i--)

int main(void){
    ll n;
    string s;
    cin >> n >> s;
    vector<ll> r = vector<ll>(n,0);
    vector<ll> g = vector<ll>(n,0);
    vector<ll> b = vector<ll>(n,0);
    repD(i,n-1,-1){
        if(i == n - 1){
             if(s[i] == 'R') r[i] = 1;
        }
        else {
            if(s[i] == 'R') r[i] = r[i+1] + 1;
            else r[i] = r[i+1];
        }
    }
    repD(i,n-1,-1){
        if(i == n - 1){
             if(s[i] == 'G') g[i] = 1;
        }
        else {
            if(s[i] == 'G') g[i] = g[i+1] + 1;
            else g[i] = g[i+1];
        }
    }
    repD(i,n-1,-1){
        if(i == n - 1){
             if(s[i] == 'B') b[i] = 1;
        }
        else {
            if(s[i] == 'B') b[i] = b[i+1] + 1;
            else b[i] = b[i+1];
        }
    }
    ll ans = 0;
    rep(i,0,n - 2){
        switch(s[i]){
            case 'R':
                rep(j,i+1,n-1){
                    if(s[j] == 'G'){
                        ans += b[j+1];
                        if(2 * j - i < n && s[2 * j - i] == 'B') ans--;
                    }
                    else if(s[j] == 'B'){
                        ans += g[j+1];
                        if(2 * j - i < n && s[2 * j - i] == 'G') ans--;
                    }
                }
            break;
            case 'G':
                rep(j,i+1,n-1){
                    if(s[j] == 'R'){
                        ans += b[j+1];
                        if(2 * j - i < n && s[2 * j - i] == 'B') ans--;
                    }
                    else if(s[j] == 'B'){
                        ans += r[j+1];
                        if(2 * j - i < n && s[2 * j - i] == 'R') ans--;
                    }
                }
            break;
            case 'B':
                rep(j,i+1,n-1){
                    if(s[j] == 'G'){
                        ans += r[j+1];
                        if(2 * j - i < n && s[2 * j - i] == 'R') ans--;
                    }
                    else if(s[j] == 'R'){
                        ans += g[j+1];
                        if(2 * j - i < n && s[2 * j - i] == 'G') ans--;
                    }
                }
            break;
        }
    }
    cout << ans << endl;
}

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

using namespace std;

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

  bool flag = 0;
  for(int i = s.size()-1; ; i = s.size()-1) {
    s.erase(i,1);
    for(int j = 0; j < s.size()/2; j++) {
      if(s.size() % 2 != 0) {
        flag = 0;
        break;
      }
      else {
        if(s[j] != s[s.size()/2+j]) {
          flag = 0;
          break;
        }
        else flag = 1;
      }
    }
    if(flag) {
      cout << s.size() << endl;
      return 0;
    }
  }

  
}


Measured memory_bytes: 3576
#include<stdio.h>
#include<stdbool.h>
#include<string.h>

static inline int root(int *uf_array,int index){
    if(index == uf_array[index])return index;
    else return uf_array[index] = root(uf_array,uf_array[index]);
}

static inline void merge(int *uf_array,int ind_a,int ind_b){
    int pa_a = root(uf_array,ind_a);
    int pa_b = root(uf_array,ind_b);
    if(pa_a == pa_b)return;
    uf_array[pa_a] = pa_b;
}

static inline bool judge(int *uf_array,int ind_a,int ind_b){
    return root(uf_array,ind_a) == root(uf_array,ind_b);
}

int main(void){
    int n,m;
    scanf("%d %d",&n,&m);
    int p[n],x_ar[m],y_ar[m];
    for(int i = 0;i < n;i++)scanf("%d",&p[i]);
    for(int i = 0;i < m;i++)scanf("%d %d",&x_ar[i],&y_ar[i]);
    int uf[n];
    for(int i = 0;i < n;i++)uf[i] = i;
    for(int i = 0;i < n;i++)p[i]--;
    for(int i = 0;i < m;i++){x_ar[i]--;y_ar[i]--;}
    for(int i = 0;i < m;i++)merge(uf,x_ar[i],y_ar[i]);
    int count = 0;
    for(int i = 0;i < n;i++)if(judge(uf,i,p[i]))count++;
    printf("%d",count);
    return 0;
}

Measured memory_bytes: 1664
#include <iostream>
#include <string>
#include <cstdlib>
#include <cstdio>
#include <queue>
#include <stack>
#include <list>
#include <utility>
#include <vector>
#include <set>
#include <algorithm>
#include <cmath>
#include <climits>
#include <map>
#include <unordered_map>
#include <string.h>
#include<iomanip>
#include <iterator>
#include <locale>

#define all(a) a.begin(),a.end()
#define VV(T) vector<vector< T > >
#define rep(i,N) for(int i = 0; i <N; i++)
#define repsg(i,s,g) for(int i = s; i <g; i++)
#define name(x) #x
using namespace std;


const int INF = 10000000;
const long long INFL = (1LL<<40);
const int MOD = pow(10,9)+7;
int dy[]={0, 0, 1, -1, 0};
int dx[]={1, -1, 0, 0, 0};

typedef long long ll,LL;
typedef vector<int> vint;
typedef vector<vector<int> > vvint;
typedef vector<long long> vll, vLL;
typedef vector<vector<long long> > vvll, vvLL;
typedef pair<int,int> pii;
typedef pair<LL, LL> pLL;


// vector入力
template<typename T>
istream& operator >> (istream& is, vector<T>& vec){
    for(T& x: vec) is >> x;
    return is;
}
// vector出力
template<typename T>
ostream& operator << (ostream& os, vector<T>& vec){
    for(int i=0; i<vec.size(); i++){
        os << vec[i] << ( i+1 == vec.size() ? "" : " " );
    }
    return os;
}

template< typename T >
struct edge{
    int src, to;T cost;
    edge(int to,T cost) :src(-1),to(to),cost(cost){}
    edge(int src, int to, T cost) :src(src),to(to),cost(cost){}edge
    &operator=(const int &x){
        to =x;
        return *this;
    }
    operator int() const{ return to;}
};

double dist (double a, double b,  double c, double d){
    
    return sqrt((a-c)*(a-c) + (b-d)*(b-d));
    
}

int main() {
    string sa, sb, sc;
    cin >> sa >> sb >> sc;
    
    char player = 'a';
    int ia =0, ib = 0, ic = 0;
    int win;
    while(1){
        if (player == 'a') {
            
            if(ia == sa.size()) {win = 0; break;}
            
            ia++; player = sa[ia-1];
            
        }
        if (player == 'b') {if(ib == sb.size()) {win = 1; break;}; ib++; player = sb[ib-1];}
        if (player == 'c') {if(ic == sc.size()) {win = 2; break;}ic++; player = sc[ic-1];}
    }
    
    if(win == 0) cout << "A" << endl;
    else if (win == 1) cout << "B" << endl;
    else cout <<"C" << endl;
    
    return 0;
}






Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main(){

    int x,y;
   cin>>x>>y;
    if((x==1 || x==3 || x==5 || x==7 || x== 8 || x==10 || x==12)&&(y==1 || y==3 || y==5 || y==7 || y== 8 || y==10 || y==12))
      cout<<"Yes"<<endl;
    else if((x==4 || x== 6 || x== 9 || x==11)&&(y==4 || y==6 || y== 9 || y==11))
     cout<<"Yes"<<endl;
    else if(x==2 && y==2)
        cout<<"Yes"<<endl;
    else  cout<<"No"<<endl;
    return 0;

return 0;
}


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

using namespace std;

int main()
{
    string a = "AtCoder Beginner Contest ";
    string b = "AtCoder Regular Contest";
    int s1 = a.size();
    int s2 = b.size();
    a[0] = toupper(a[0]);
    b[0] = toupper(b[0]);
    int x;
    cin >> x;
    if(x<1200)
    {

    for(int i =0; i<s1; i++)
    {
        if(a[i-1] == ' ')
            a[i] = toupper (a[i]);
    }
    cout << "ABC" <<endl;
    }
    else if(x>=1200)
    {
        for(int j =0; j<s2; j++)
    {
        if(b[j-1] == ' ')
            b[j] = toupper (b[j]);
    }
    cout << "ARC" <<endl;
    }
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<cmath>
#include<cstdio>
#include<cstdlib>

using namespace std;

long long llpow(long long t, long long a){
  long long ret = 1;
  for(int i = 0; i < a; ++i){
    ret *= t;
  }
  return ret;
}

int len;
int ans[32];
#define POSITIVE 1
#define NEGATIVE 2

long long lim(int type, int a)
{
  if(type==POSITIVE){
    long long ret=0;
    for(int i=a-1;i>=0;--i){
      if(i%2==0)ret+=9*llpow(10,i);
    }
    return ret;
  }else{
    long long ret=0;
    for(int i=a-1;i>=0;--i){
      if(i%2==1)ret+=9*llpow(10,i);
    }
    return ret;
  }
}

void solve(long long n)
{
  if(n==0)return ;
  int a=0;
  if(n>0){
    long long L=9;
    while(true){
      if(n<=L)break;
      L=100*L+9;
      a+=2;
    }
  }else{
    long long L=-90;
    a=1;
    while(true){
      if(n>=L)break;
      L=100*L-90;
      a+=2;
    }
  }
  len=max(a,len);
  long long B=llpow(-10,a);
  if(B<0){
    int t=0;
    while(true){
      if(t*B<=n){
	break;
      }
      ++t;
    }
    if(t*B+lim(POSITIVE,a)<n)--t;
    n-=t*B;
    ans[a]=t;
    solve(n);
  }else{
    int t=0;
    while(true){
      if(t*B>=n){
	break;
      }
      ++t;
    }
    if(t*B-lim(NEGATIVE,a)>n)--t;
    n-=t*B;
    ans[a]=t;
    solve(n);
  }
  return ;
}

int main()
{
  long long n;
  while(EOF!=scanf("%lld", &n)){
    if( n == 0 ) break;
    len = 0;
    for(int i = 0; i < 32; ++i){
      ans[i]=0;
    }
    solve(n);
    for(int i = len; i >= 0; --i){
      printf("%d", ans[i]);
    }
    putchar('\n');
  }
  return 0;
}

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

using ll = int64_t;
#define int ll

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

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

template <class T, class U>
ostream &operator<<(ostream &os, const pair<T, U> &p) {
  os << "(" << p.first << "," << p.second << ")";
  return os;
}

template <class T> ostream &operator<<(ostream &os, const vector<T> &v) {
  os << "{";
  REP(i, (int)v.size()) {
    if (i)
      os << ",";
    os << v[i];
  }
  os << "}";
  return os;
}

ll read() {
  ll i;
  scanf("%" SCNd64, &i);
  return i;
}

void printSpace() { printf(" "); }

void printEoln() { printf("\n"); }

void print(ll x, int suc = 1) {
  printf("%" PRId64, x);
  if (suc == 1)
    printEoln();
  if (suc == 2)
    printSpace();
}

string readString() {
  static char buf[3341000];
  scanf("%s", buf);
  return string(buf);
}

char *readCharArray() {
  static char buf[3341000];
  static int bufUsed = 0;
  char *ret = buf + bufUsed;
  scanf("%s", ret);
  bufUsed += strlen(ret) + 1;
  return ret;
}

template <class T, class U> void chmax(T &a, U b) {
  if (a < b)
    a = b;
}

template <class T, class U> void chmin(T &a, U b) {
  if (b < a)
    a = b;
}

template <class T> T Sq(const T &t) { return t * t; }

const int mod = 1e9 + 7;

signed main() {
  int a = read(), b = read(), ans = 0;
  for (int i = a; i <= b; i++) {
    int d[5], tmp = i, j = 0;
    while (j < 5) {
      d[j] = tmp % 10;
      tmp /= 10;
      j++;
    }
    if (d[0] == d[4] && d[1] == d[3]) {
      ans++;
    }
  }
  print(ans);
}


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

#define mod 1000000007

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

using namespace std;
typedef long long ll;
const long long INF = 1LL << 60;
 
int main(void){
	
	int A, B, C, K;
    cin >> A >> B >> C >> K;

    int ans = 0;

    for(int i = 1; i <= K; i++){
        if(i <= A)
            ans++;
        else if(i <= A + B)
            continue;
        else
            ans--;
    }

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

Measured memory_bytes: 3640
#include<bits/stdc++.h>
using namespace std;
#define FastRead ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define ll long long int
#define endl '\n'
#define ld long double
#define FOR(i,a,n) for (int i=(a);i<=(n);++i)
#define RFOR(i,a,n) for (int i=(n);i>=(a);--i)
#define FI(i,n) for (int i=0; i<(n); ++i)
#define ZERO(a) memset((a),0,sizeof((a)))
#define MINUS(a) memset((a),-1,sizeof((a)))
#define f first
#define s second
#define pb push_back
#define mk make_pair
#define all(g) g.begin(),g.end()
int fastMax(int x, int y) { return (((y-x)>>(32-1))&(x^y))^y; }
int fastMin(int x, int y) { return (((y-x)>>(32-1))&(x^y))^x; }
 
/*
░░░░░░░░░░░░░░░░░░░░░░░░░
░░█▀▀▄░░░░░░░░░░░▄▀▀█░░░░
░░█░░░▀▄░▄▄▄▄▄░▄▀░░░█░░░░
░░░▀▄░░░▀░░░░░▀░░░▄▀░░░░░
░░░░░▌░▄▄░░░▄▄░▐▀▀░░░░░░░
░░░░▐░░█▄░░░▄█░░▌▄▄▀▀▀▀█░
░░░░▌▄▄▀▀░▄░▀▀▄▄▐░░░░░░█░
░▄▀▀▐▀▀░▄▄▄▄▄░▀▀▌▄▄▄░░░█░
░█░░░▀▄░█░░░█░▄▀░░░░█▀▀▀░
░░▀▄░░▀░░▀▀▀░░▀░░░▄█▀░░░░
░░░░█░░░░░░░░░░░▄▀▄░▀▄░░░
░░░░█░░░░░░░░░▄▀█░░█░░█░░
░░░░█░░░░░░░░░░░█▄█░░▄▀░░
░░░░█░░░░░░░░░░░████▀░░░░
░░░░▀▄▄▀▀▄▄▀▀▄▄▄█▀░░░░░░░
░░░░░░░░░░░░░░░░░░░░░░░░░
*/
 
// I want to be the very best, like no one ever was, I will battle everyday to claim my rightful place
// #include <ext/pb_ds/assoc_container.hpp> // Common file
// #include <ext/pb_ds/tree_policy.hpp>     // Including tree_order_statistics_node_updat
// using namespace __gnu_pbds;
// typedef tree<ll, null_type, less<ll>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;
 
// I am questioning life and universe and 
// everything else after looking at this

void solve(){
    ll A,B,C; cin>>A>>B>>C;

    ll left = A - B;

    ll ans = max(0LL,C-left);

    cout<<ans<<endl;
} 
 
signed main(){
 
   FastRead;    
 
 
    ll t;
    t = 1; 
    //cin>>t;
    FOR(i,1,t){
        // cout<<"Case #"<<i<<": ";
        solve();
    }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define int long long
using namespace std;
typedef pair<int,int> P;
const int INF=pow(2,31)-1;
std::vector<P> v(1e6,P(INF,-1));
int N=1;
void update(int a,int b,int c,int d,int k,int l,int r){
  if(r<=a||b<=l)return;
  if(a<=l&&r<=b)v[k]=P(c,d);
  else{
    update(a,b,c,d,k*2+1,l,(l+r)/2);
    update(a,b,c,d,k*2+2,(l+r)/2,r);
  }
}
int ma(int a){
  int k=a+N-1;
  P res=v[k];
  while(k){
    k=(k-1)/2;
    if(res.second<v[k].second)res=v[k];
  }
  return res.first;
}

signed main(){
  int n,M;
  cin>>n>>M;
  while(n>N)N*=2;
  std::vector<int> ans;

  for(int i=0;i<M;i++){
    int q;cin>>q;
    if(q){
      int a;cin>>a;
      ans.push_back(ma(a));
    }
    else{
      int s,t,x;cin>>s>>t>>x;
      update(s,t+1,x,i,0,0,N);
    }
  }
  for(int p:ans)cout<<p<<endl;
}



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

int main()
{
    int n, ans = 0;
    cin >> n;
    vector<int> h(n + 1);
    int s = 0;
    h[0] = 0;
    for (int i = 1; i <= n; i++) {
        cin >> h[i];
        if (h[i - 1] < h[i]){
            s += h[i] - h[i - 1];
        }
    }
    cout << s << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <cmath>
#include <cstdlib>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <iterator>
#include <climits>
#include <unordered_map>
#include <functional>
#include <queue>

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

#define p2(a, b) cout << a << "\t" << b << endl
#define p3(a, b, c) cout << a << "\t" << b << "\t" << c << endl

using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;

inline int ctoi(char c) {
    return (int)(c -'0');
}

// ----------------------------------------------------------

int main() {
    string a, b;
    cin >> a >> b;
    ll num = stol(a + b);
    double he = sqrt(num);
    cout << ((he - ll(he) == 0.0) ? "Yes" : "No") << endl;
    return 0;
}


Measured memory_bytes: 256
import numpy as np
s = np.array(list(input()))
t = np.array(list(input()))
s_sub = np.array(list((s[i:i+len(t)] for i in range(len(s)-len(t)+1))))
ans = [0]*len(s_sub)
for i in range(len(s_sub)):
    ans[i] = np.count_nonzero(s_sub[i] == t)
print(len(t)-max(ans))


Measured memory_bytes: 27392
#include <bits/stdc++.h>
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define all(x) (x).begin(),(x).end()
#define INF 10000000
using ll = long long ;
ll gcd(ll a, ll b) {
  if(b == 0) return a;
  return gcd(b, a % b);
}
template< int id > struct CompTupleBy
{
  template<class T> 
  bool operator()( const T& a, const T& b ) const {
    return std::get<id>(a) < std::get<id>(b);
  }
};

using namespace std;

int main(){
    ll h,n;
    cin >> h >> n;
    vector<ll> A(n);
    ll goukei = 0;
    rep(i,n){
        cin >> A[i];
        goukei += A[i];
    }
    if (goukei>=h){
      cout << "Yes" << endl;
    }else{
      cout << "No" << endl;
    }

}

Measured memory_bytes: 1024
import math
s = input().split()
hour_len = int(s[0])
min_len = int(s[1])
hour = int(s[2])
minutes = int(s[3])
total_minutes = hour * 60 + minutes

hour_rad_per_one_minute = 360 / (12 * 60)

min_rad_per_one_minute = 360 / 60

hour_rad = hour_rad_per_one_minute * total_minutes
min_rad = min_rad_per_one_minute * minutes

rad = abs(hour_rad - min_rad)

length_2 = hour_len ** 2 + min_len ** 2 - 2 * hour_len * min_len * math.cos(math.radians(rad))

length = math.sqrt(length_2)
print(length)

Measured memory_bytes: 9444
from sys import stdin
from collections import defaultdict
N = int(stdin.readline().rstrip())
d = defaultdict(int)

for x in range(1,101):
  for y in range(1,101):
    for z in range(1,101):
      v = x**2 + y**2 + z**2 + x*y + y*z + z*x
      d[v] += 1

for i in range(1,N+1):
    print(d[i])

Measured memory_bytes: 79460
N = int(input())
a = [input() for i in range(N)]
c0 = a.count("AC")
c1 = a.count("WA")
c2 = a.count("TLE")
c3 = a.count("RE")
print("AC x", c0)
print("WA x", c1)
print("TLE x", c2)
print("RE x", c3)


Measured memory_bytes: 16164
#include <bits/stdc++.h>
using namespace std;
const int mod = 1e9+7;
long long f1[400002], f2[400002];
long long p(long long a, long long b){
    long long ans = 1;
    while(b > 0){
        if((b&1) == 1) ans = ans*a%mod;
        a = a*a%mod;
        b/=2;
    }
    return ans;
}
long long cal(int a, int b){
    return f1[a]*f2[b]%mod*f2[a-b]%mod;
}
int main(){
    f1[0] = 1;
    for(int i=1;i<=400000;i++) f1[i] = f1[i-1]*i%mod;
    for(int i=0;i<=400000;i++) f2[i] = p(f1[i], mod-2);
    int n, k;
    scanf("%d%d", &n, &k);
    long long ans = 0;
    for(int i=0;i<=min(n-1, k);i++){
        int l = i, r = n-i;
        long long temp = cal(n, l);
        temp *= cal(n-r+r-1, r-1);
        temp %= mod;

        ans += temp;
        ans%=mod;
    }   
    printf("%lld\n", ans);
}

Measured memory_bytes: 6528
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<iomanip>
#include<math.h>
#include<complex>
#include<queue>
#include<deque>
#include<stack>
#include<map>
#include<set>
#include<bitset>
#include<functional>
#include<assert.h>
#include<numeric>
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 main(){
    int n;
    cin>>n;
    cout<<(n-1)/2<<endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  cin >> n;
  vector<int> a(n);
  for (int i = 0; i < n; i++) {
    cin >> a[i];
  }
  sort(a.begin(), a.end());
  int x = 0;
  for (int i = 0; i < n; i++) {
    x += a[i];
  }
  if (a[n-1] >= x-a[n-1]) {
    cout << "No" << endl;
  }
  else {
    cout << "Yes" << endl;
  }
}

Measured memory_bytes: 3588
import sys

input = sys.stdin.readline


def main():
    a, b, x = map(int, input().split())

    q, r = divmod(a, x)
    A = x * q + x * (r != 0)
    q, r = divmod(b, x)
    B = x * q

    if B < A:
        print(0)
    else:
        print((B - A) // x + 1)


if __name__ == "__main__":
    main()


Measured memory_bytes: 3060
#include<iostream>
using namespace std;
 
main(){
  long long s_n,c_n,r=0;
  cin>>s_n>>c_n;
  
  long long s_n_2 = s_n*2;
  
  
  if( s_n_2<= c_n ){
    r += s_n;
    c_n -= s_n_2;
    s_n = 0;
  }
  else{
    r += c_n/2;
    s_n -= r;
    c_n -= 2*c_n;
  }
  
  if (c_n>3){
    r += c_n/4;
  } 
  cout<< r <<endl;
  return 0;
}

Measured memory_bytes: 256
#include<cstdio>
#include<vector>

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

using namespace std;

class union_find{
	vector<int> a,h;
public:
	union_find(int n):a(n,-1),h(n){}
	int find(int x){
		if(a[x]<0) return x;
		int p=find(a[x]);
		h[x]+=h[a[x]];
		return a[x]=p;
	}
	void update(int x,int y,int w){
		int rx=find(x);
		int ry=find(y);
		if(rx!=ry){
			a[rx]+=a[ry];
			a[ry]=rx;
			h[ry]=w-h[y]+h[x];
		}
	}
	int query(int x,int y){
		return h[y]-h[x];
	}
};

int main(){
	for(int n,q;scanf("%d%d",&n,&q),n;){
		union_find U(n);
		while(q--){
			char c;
			int a,b; scanf(" %c%d%d",&c,&a,&b); a--; b--;
			if(c=='!'){ // update
				int w; scanf("%d",&w);
				U.update(a,b,w);
			}
			else{ // query
				if(U.find(a)!=U.find(b)) puts("UNKNOWN"); else printf("%d\n",U.query(a,b));
			}
		}
	}

	return 0;
}

Measured memory_bytes: 2576
#include<iostream>
#include<cstring>
#include<cstdio>
using namespace std;
int main()
{
    char str[15];
    scanf("%s",str);
    int len=(int)strlen(str);
    if(len%2||str[0]!='h'){
        printf("No\n");return 0;
    }
    int flag=1;
    for(int i=0;i<len-1;i+=2){
        if(str[i]!='h')flag=0;
        if(str[i]=='h'&&str[i+1]!='i')flag=0;
    }
    if(!flag)printf("No\n");
    else printf("Yes\n");
}

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

int main()
{
    std::string S;
    std::cin >> S;

    const int N = S.size();
    int count = 0;
    for(int i=1; i<N; i++){
        if(S[i-1] != S[i]) count++;
    }

    printf("%d\n", count);
}

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

int main(){
  vector<int> a(3);
for(int i=0;i<3;++i) cin>>a[i];
  sort(a.begin(), a.end());
  int ans = 0;
  for(int i=0;i<2;++i) {
    ans += a[i+1]-a[i];
  }
  cout<<ans<<endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#pragma GCC optimize("unroll-loops,no-stack-protector")
#pragma GCC target("sse,sse2,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#define watch(x) cout << (#x) << " is " << (x) << endl
#define debug cout << "hi" << endl

using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;

ll gcd(ll a, ll b) {return (!b ? a : gcd(b, a % b));}
ll lcm(ll a, ll b) {return ((a*b)/gcd(a,b));}
bool cmp(int a,int b){return a>b;}

const ll mod = 1e9 + 7;
const int INF32 = 1<<30;
const ll INF64 = 1LL<<60;
const ld pi = 3.141592653589793;
const int N = 1e6 + 10;

long long modpow(long long n, long long k, long long mod)
{
if (k == 0) return 1;
long long r = modpow(n * n % mod, k >> 1, mod);
if (k & 1) r = r * n % mod;
return r;
}
map< pair<int,int>,int >mp;
vector< vector<int> >adj(1e5+10);
vector<int>color(1e5+10,0);
void dfs(int v,int prev,int c){
 for(int i = 0;i<adj[v].size();i++){
        //debug;
    int vi = adj[v][i];
    if(vi==prev) continue;
    if(mp[{v,vi}]%2) color[vi] = (c^1);
    else color[vi] = c;
    //cout << mp[{v,vi}] <<endl;
    dfs(vi,v,color[vi]);
 }
}

void solve(){
    int n;cin >> n;
    for(int i = 0;i<n-1;i++){
        int v,u,w;
        cin >> v >> u >> w;
        mp[{v,u}] = w;
        mp[{u,v}] = w;
        adj[v].push_back(u);
        adj[u].push_back(v);
    }
    dfs(1,0,0);
    for(int i = 1;i<=n;i++){
        cout << color[i] <<endl;
    }
}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);cout.tie(NULL);
    solve();
    return 0;
}

Measured memory_bytes: 25812
n = int(input())
a = list(map(int, input().split()))
count = 0
sum_a = sum(a)
p = 0
for i in range(n):
    count += a[i]
    if count > sum_a//2:
        p = i
        break
if p == 0:
    ans = abs(sum_a - count*2)
else:
    ans = min(abs(sum_a - count*2), abs(sum_a - (count-a[p])*2))
print(ans)

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

int main() {
    int N, L, memo;
    cin >> N >> L;
    int mini = 1000, sum = 0;
    rep(i, N) {
        if(abs(mini) > abs(L + i)) {
            mini = L + i;
        }
        sum = sum + L + i;
    }
    cout << sum - mini << endl;
    return 0;
}


Measured memory_bytes: 3644
#include <bits/stdc++.h>
using namespace std;
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define pb push_back
#define mp make_pair
#define all(a)      (a).begin(),(a).end()
#define debug_array(a,n) for (ll bccc=(0); bccc<(n); bccc++) cout<<a[bccc]<<" "<<"\n"
#define debug_vector(a) for(ll bccc=(0); bccc<(a.size());bccc++) cout<<a[bccc]<<" "<<"\n"
#define F           first
#define S           second
#define debug_set(s) for(auto p:s) cout<<p<<" "
#define debug_map(m) for(auto p:m) cout<<p.F<<" "<<p.S<<"\n"
#define trace(x) cerr<<#x<<": "<<x<<" "<<endl;
typedef long long ll;
using namespace __gnu_pbds;
typedef tree<pair<ll,ll>,null_type,less<pair<ll,ll> >,rb_tree_tag,tree_order_statistics_node_update> ordered_multiset;
/* ll t = 0;
ordered_multiset me;
...
me.insert({x, t++});
me.erase(me.lower_bound({x, 0}));
cout << me.order_of_key({x, 0}) << "\n";

///////////   t is insertion time
*/
//#pragma GCC optimize("Ofast")  // works very well
#define ordered_set tree<ll, null_type,less<ll>, rb_tree_tag,tree_order_statistics_node_update>
mt19937 rng(chrono::high_resolution_clock::now().time_since_epoch().count());
typedef long double lld;
lld pi=3.14159265358;
ll powr(ll a,ll b)
{
    ll c=1;
    ll kjk;
    for(kjk=0;kjk<b;kjk++)
        c*=a;
    return c;
}
ll hell=1000000007;
//ll hell=998244353   ;
ll power(ll x, ll y, ll p)
{
    ll res = 1;
    x = x % p;
    while (y > 0)
    {
        if (y & 1)
            res = (res*x) % p;
        y = y>>1;
        x = (x*x) % p;
    }
    return res;
}
//freopen("input.txt", "r", stdin);
//freopen("output.txt", "w", stdout);
// to generate random number , use rng() ... eg cout<<rng();
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    srand(chrono::high_resolution_clock::now().time_since_epoch().count());
    ll n,m;
    cin>>n>>m;
    if(n==m)
    {
        for(ll i=0;i<n;i++)
            cout<<m;
        return 0;
    }
    if(n<m)
        swap(n,m);
    for(ll i=0;i<n;i++)
        cout<<m;
    return 0;
}


Measured memory_bytes: 256
import java.util.HashMap;
import java.util.Map;
import java.util.Scanner;

/**
 * Divisible Substring
 * 
 * https://atcoder.jp/contests/abc158/tasks/abc158_e
 */
public class Main {

    static Scanner sc = new Scanner(System.in);

    public static void main(String[] args) throws Exception {
        int N = sc.nextInt();
        int P = sc.nextInt();
        String S = sc.next();

        int[] A = new int[N];
        for (int i = 0; i < N; i++) {
            A[i] = S.charAt(i) - '0';
        }

        long ans = 0;

        if (P == 2 || P == 5) {
            int c = 0;
            for (int i = N - 1; i >= 0; i--) {
                if (A[i] % P == 0) {
                    c++;
                }
                ans += c;
            }
        } else {
            int m = 0;
            int k = 1;
            Map<Integer, Integer> count = new HashMap<>();
            count.put(0, 1);
            for (int i = N - 1; i >= 0; i--) {
                m = (A[i] * k + m) % P;

                Integer c = count.get(m);

                if (c == null) {
                    c = 1;
                } else {
                    ans += c;
                    c++;
                }

                count.put(m, c);

                k = (k * 10) % P;
            }
        }

        System.out.println(ans);
    }

}


Measured memory_bytes: 35304
@A=glob<>;@l=<>;printf sort{$a-$b}map{$x=@v=//;$v[$t=$'>>2*$_&3]+=$t&&$l[$x+=10,$_]for 0..7;$x+=abs$A[$_]-($v[$_]||@@)for 1..3;$x-31}@@=1..1e5

Measured memory_bytes: 17280
#include <stdio.h>
#include <stdlib.h>
#define ll long long
#define rep(i,l,r)for(ll i=(l);i<(r);i++)
 
ll cnt[55];
ll pena[55];

int c(const void*a,const void*b){
	ll p=*(ll*)a,q=*(ll*)b;
	if(cnt[p]>cnt[q])return -1;
	if(cnt[p]<cnt[q])return 1;
	if(pena[p]<pena[q])return -1;
	if(pena[p]>pena[q])return 1;
	if(p<q)return -1;
	return 1;
}

ll team[55];
int main(){
	ll t,p,q;
	while(scanf("%lld%lld%lld",&t,&p,&q),t){
		ll a[55][11]={};
		rep(i,0,t+2)cnt[i]=pena[i]=0;
		rep(i,0,t)team[i]=i+1;
		rep(i,0,q){
			ll tt,pp,time;
			char s[10];
			scanf("%lld%lld%lld %s",&tt,&pp,&time,s);
			if(*s=='C'){
				cnt[tt]++;
				pena[tt]+=time+a[tt][pp];
			}else{
				a[tt][pp]+=1200;
			}
		}
		qsort(team,t,sizeof(ll),c);
		rep(i,0,t)printf("%lld %lld %lld\n",team[i],cnt[team[i]],pena[team[i]]);
	}
}


Measured memory_bytes: 2104
#include <iostream>
#include <string>
#include <algorithm>

using namespace std;

int main() {
	int N;
	int cnt = 0, ans = 0;
	cin >> N;
	for (int i = 1; i < N + 1; i++) {
		if (i % 2) {
			cnt = 0;
			for (int k = 1; k < i + 1; k++) {
				if (!(i % k)) cnt++;
			}
			if (cnt == 8) ans++;
		}
	}
	cout << ans << endl;
	return 0;
}

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

int main()
{
    int a, b, sum = 0;
    cin >> a >> b;
    if (b > a)
    {
        cout << 2*b-1 << endl;
    }
    else if (b == a)
    {
        cout << 2*b << endl;
    }
    else
    {
        cout << 2*a-1 << endl;
    }
    return 0;
}


Measured memory_bytes: 256
n, k, s = map(int, input().split())
o = 10 ** 9
ans = []
if s == 10 ** 9:
    o = 1

for _ in range(k):
    ans.append(s)
for _ in range(n-k):
    ans.append(o)
    
print(' '.join(map(str, ans)))

Measured memory_bytes: 12056
#include <stdio.h>
#include <string.h>
#define N 100
int main(void){
	int ans,i,A[N];
	char str[N];

	for( ;fgets(str,sizeof(str),stdin)!=NULL; ){
		ans=5;
		for(i=0;i<9;i++){
			if(str[i]=='o')
				A[i+1]=1;
			else if(str[i]=='x')
				A[i+1]=0;
			else if(str[i]=='s')
				A[i+1]=5;
		}
		for(i=1;i<8;i+=3){
			if(A[i]==A[i+1] && A[i+1]==A[i+2] && A[i]!=5){
				ans=A[i];
				goto out;
			}
		}
		for(i=1;i<4;i+=1){
			if(A[i]==A[i+3] && A[i+3]==A[i+6] && A[i]!=5){
				ans=A[i];
				goto out;
			}
		}
		if(A[1]==A[5] && A[5]==A[9] && A[1]!=5){
			ans=A[1];
			goto out;
		}
		if(A[3]==A[5] && A[5]==A[7] && A[3]!=5){
			ans=A[3];
			goto out;
		}
		out:;
		if(ans==1)
			printf("o\n");
		else if(ans==0)
			printf("x\n");
		else
			printf("d\n");
		
	}
	return 0;
}

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

int main(){

    int N, M, X;
    cin >> N >> M >> X;

    map<int, int> cost;
    for (int i=0; i<M; i++){
        int temp;
        cin >> temp;
        cost[temp]++; 
    }

    int cost_r = 0,cost_l = 0;
    for (int i=X; i<N+1; i++){
        if (cost.count(i)) cost_r++;
    }
    for (int i=X; i>=0; i--){
        if (cost.count(i)) cost_l++;
    }

    cout << min(cost_l, cost_r) << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <iomanip>
#include <stack>
#include <array>
#include <deque>
#include <forward_list>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <algorithm>
#include <iterator>
#include <string>
#include <cstring>
//#include <fstream>
#include <complex>
#define _USE_MATH_DEFINES
#include <cmath>
#include <math.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
#define REP(i,n) for(int i=0;i<(n);i++)
#define RREP(i,n) for(int i=n;i>0;i--)
#define arep(a,i,n) for(int i=(a);i<(n);i++)
#define SORT(v) sort((v).begin(),(v).end())
const ll INF = (1LL << 50);
typedef pair<int, int> P;

int main() {

	int n;
	cin >> n;

	vector<int>x(n);

	REP(i, n) cin >> x[i];

	int minv = 10000000;
	for (int i = 1; i <= 100; i++) {
		int sum = 0;

		for (int j = 0; j < n; j++) {
			sum += (x[j] - i)*(x[j] - i);
		}

		minv = min(minv, sum);

	}

	cout << minv << endl;

	return 0;

}

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

namespace AtCoder_solve
{
    class Program
    {
        public const ulong mod = 1000000007;

        static void Main(string[] args)

        {

            double a = double.Parse(Console.ReadLine()) / 3.0;
            double ans = a * a * a;

                Console.WriteLine(ans);




        }

       
        static public long Input()
        {
            return long.Parse(Console.ReadLine());
        }

        static public string[] Input2()
        {
            return Console.ReadLine().Split();
        }

        static public ulong[] Input3()
        {
            string[] data = Console.ReadLine().Split();
            ulong[] res = new ulong[data.LongLength];
            for(long i = 0; i < data.LongLength; i++)
            {
                res[i] = ulong.Parse(data[i]);
            }
            return res;
        }
        public static long Choose(long n, long a)
        {
            long x = 1;
            long y = 1;
            for (long i = 0; i < a; i++)
            {
                x *= n - i;
                y *= i + 1;
            }
            return x / y;
        }
    }
}


Measured memory_bytes: 11220
// In the name of God 
#include <bits/stdc++.h>

using namespace std ;

#define int long long
#define all(v) v.begin() , v.end()

template<typename T> inline bool smin(T &a, const T &b){ return b < a ? a = b,1:0;}
template<typename T> inline bool smax(T &a, const T &b){ return a < b ? a = b,1:0;}

const int N = 2000 + 10 ; 

int n ; 
bitset < N * N > bs ; 

int32_t main()
{
	ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
	cin >> n ;
	bs [ 0 ] = 1 ;
	int sum = 0 ; 
	while ( n -- ) {
		int x ;
		cin >> x ;
		sum += x ; 
		bs = ( bs << x ) | bs ; 
	}
	for ( int j = 0 ; j < N * N ; ++j )
		if ( j + j >= sum && bs [ j ] )
			return cout << j << '\n' , 0 ; 
}


Measured memory_bytes: 2176
N = int(input())
A = list(map(int, input().split()))


def selection_sort(Ary):
    N = len(Ary)
    count = 0
    for i in range(N-1):
        min_j = i
        flag = 0
        for j in range(N-i):
            if Ary[j+i] < Ary[min_j]:
                min_j = j+i
                flag = 1
        Ary[i], Ary[min_j] = Ary[min_j], Ary[i]
        if flag == 1:
            count += 1
            flag = 0
    return Ary, count

A_sorted , count = selection_sort(A)
print(' '.join(map(str, A_sorted)))
print(count)



Measured memory_bytes: 5600
#include <iostream>
#include <utility>
#include <queue>
#include <stack>
#include <algorithm>
#include <cstring>
#include <functional>

std::pair<int, int> road[101][101]; //first距離 second敵
int dp[101][101];//[残金][場所] = 既に襲われた数

struct Node {
	int pos, money, attacked;
	bool operator > (const Node& rhs) const {
		return attacked > rhs.attacked;
	}
	bool operator < (const Node& rhs) const {
		return attacked < rhs.attacked;
	}
};

int main() {
	int n, m, l;
	while (std::cin >> n >> m >> l && (n || m || l)) {
		std::memset(dp, -1, sizeof(dp));
		for (int i = 0; i < 101; i++) for (int j = 0; j < 101; j++) road[i][j] = std::make_pair(0, 0);
		for (int i = 0; i < m; i++) {
			int x, y, d, e;
			std::cin >> x >> y >> d >> e;
			road[x][y] = std::make_pair(d, e);
			road[y][x] = std::make_pair(d, e);
		}

		std::stack<Node> s;
		//std::priority_queue<Node> s;
		s.push({1, l, 0});

		int min = 1919810;
		while (!s.empty()) {
			auto node = s.top(); s.pop();

			for (int i = 1; i <= n; i++) {
				if (!road[node.pos][i].first) continue;
				auto next = node;
				next.pos = i;

				//雇わない
				{
					auto n2 = next;
					n2.attacked += road[node.pos][i].second;
					if (dp[n2.money][i] == -1 || dp[n2.money][i] > n2.attacked) {
						dp[n2.money][i] = n2.attacked;
						if (i == n) min = std::min(min, n2.attacked); //ごーーる
						else {
							//よりお金を残して今と同等かそれ以下の襲撃数なら意味なし
							bool isOk = true;
							for (int j = n2.money + 1; j <= l; j++) {
								if (dp[j][i] >= 0 && dp[j][i] <= n2.attacked) {
									isOk = false;
									break;
								}
							}
							if (isOk) {
								s.push(n2);
							}
						}
					}
				}
				//雇う
				if (next.money >= road[node.pos][i].first) {
					next.money -= road[node.pos][i].first;
					if (dp[next.money][i] == -1 || dp[next.money][i] > next.attacked) {
						dp[next.money][i] = next.attacked;
						if (i == n) min = std::min(min, next.attacked); //ごーーる
						else {
							//よりお金を残して今と同等かそれ以下の襲撃数なら意味なし
							bool isOk = true;
							for (int j = next.money + 1; j <= l; j++) {
								if (dp[j][i] >= 0 && dp[j][i] <= next.attacked) {
									isOk = false;
									break;
								}
							}
							if (isOk) {
								s.push(next);
							}
						}
					}
				}
			}
		}
		std::cout << min << std::endl;
	}

	return 0;
}


Measured memory_bytes: 3092
#include <stdio.h>
#include <string.h>
   
int main()
{
  char temp, str[1001], re[1001], p[101];
  int i, j, a, b, q;
   
  scanf("%s", str);
  scanf("%d", &q);
 
  for(i = 0; i < q; i++)
  {
    scanf(" %s%d%d", p, &a, &b);
 
    if(strcmp(p, "print") == 0)
    {
      for(j = a; j <= b; j++)
      {
          printf("%c", str[j]);
      }
 
      printf("\n");
    }
 
    else if(strcmp(p, "reverse") == 0)
    {
      for(j = 0; a+j < b-j; j++)
      {
         temp = str[a+j];
         str[a+j] = str[b-j];
         str[b-j] = temp;
      }
    }
 
    else if(strcmp(p, "replace") == 0)
    {
      scanf(" %s", re);
      for(j = 0; a+j <= b; j++)
      {
          str[a+j] = re[j];
      }
    }
  }
  return 0;
}


Measured memory_bytes: 2148
#include<iostream>
#include<iomanip>
#include<algorithm>
#include<cstring>
#include<string>
#include<cmath>
#include<vector>
#include<queue>
#include<stack>
#include<map>
#include<set>
using namespace std;
const int inf=1e9,dx[]={-1,0,1,0},dy[]={0,-1,0,1};
const long long llinf=1e18;
int n,a[105],ans;
int main(){
	ans=-inf;
	cin>>n;
	for(int i=1;i<=n;i++)
		cin>>a[i];
	for(int i=1;i<n;i++)
		for(int j=i+1;j<=n;j++)
			ans=max(ans,abs(a[i]-a[j]));
	cout<<ans;
	return 0;
}


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

using namespace std;

int n, pos;
vector<int> pre, in, post;

void rec(int l, int r){
    if(l>= r) return;
    int root = pre[pos++];
    int m = distance(in.begin(), find(in.begin(), in.end(), root));
    rec(l, m);
    rec(m+1, r);
    post.push_back(root);
}

void solve(){
    pos = 0;
    rec(0, pre.size());
    for(int i=0;i<n;i++){
        if(i) cout << " ";
        cout << post[i];
    }
    cout << endl;
}

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

    for(int i=0;i<n;i++){
        cin >> k;
        pre.push_back(k);
    }

    for(int i=0;i<n;i++){
        cin >> k;
        in.push_back(k);
    }

    solve();

    return 0;
}


Measured memory_bytes: 3168
#include <memory.h>

#include <algorithm>
#include <bitset>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <deque>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <utility>
#include <vector>

using namespace std;

#define MOD 1000000007

long long int res[3010][3010][4] = {};
long long int v[3010][3010] = {};

int main()
{
    int r, c, k;
    cin >> r >> c >> k;
    for (int i = 0; i < k; i++)
    {
        int r, c, tmpv;
        cin >> r >> c >> tmpv;
        r--;
        c--;
        v[r][c] = tmpv;
    }
    for (int i = 0; i <= r; i++)
    {
        for (int j = 0; j <= c; j++)
        {
            for (int l = 0; l <= 3; l++)
            {
                // cout << i << " " << j << " " << l << " " << res[i][j][l] << endl;
                res[i + 1][j][0] = max(res[i + 1][j][0], res[i][j][l]);
                res[i][j + 1][l] = max(res[i][j + 1][l], res[i][j][l]);
                if (l + 1 <= 3)
                {
                    res[i + 1][j][0] = max(res[i + 1][j][0], res[i][j][l] + v[i][j]);
                    res[i][j + 1][l + 1] = max(res[i][j + 1][l + 1], res[i][j][l] + v[i][j]);
                }
            }
        }
    }
    cout << max({res[r][c][0], res[r][c][1], res[r][c][2]}) << endl;
}


Measured memory_bytes: 356308
import java.util.*;
public class Main {
	public static void main(String[] args) {
	Scanner scan = new Scanner(System.in);
	int a = scan.nextInt();
	int h = a / 3600;
	int m = (a % 3600)/60;
	int s = (a % 3600)%60;
	System.out.println(h+":"+m+":"+s);
	}
}

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

struct fast_ios { fast_ios(){ cin.tie(nullptr); ios::sync_with_stdio(false); cout << fixed << setprecision(20); }; } fast_ios_;

// Binary Indexed Tree (Fenwick Tree)
// https://youtu.be/lyHk98daDJo?t=7960
template<typename T>
struct BIT {
  int n;
  vector<T> d;
  BIT(int n=0):n(n),d(n+1) {}
  void add(int i, T x=1) {
    for (i++; i <= n; i += i&-i) {
      d[i] += x;
    }
  }
  T sum(int i) {
    T x = 0;
    for (i++; i; i -= i&-i) {
      x += d[i];
    }
    return x;
  }
  T sum(int l, int r) {
    return sum(r-1) - sum(l-1);
  }
};

int main() {
  int n, q;
  cin >> n >> q;
  vector<int> a(n);
  rep(i,n) cin >> a[i];
  vector<int> pi(n+1,-1);
  vector<vector<int>> ps(n);
  rep(i,n) {
    int l = pi[a[i]];
    if (l != -1) ps[l].push_back(i);
    pi[a[i]] = i;
  }

  vector<vector<P>> qs(n);
  rep(qi,q) {
    int l, r;
    cin >> l >> r;
    --l; --r;
    qs[l].emplace_back(r,qi);
  }

  vector<int> ans(q);
  BIT<int> d(n);
  for (int x = n-1; x >= 0; --x) {
    for (int y : ps[x]) d.add(y,1);
    for (P query : qs[x]) {
      int r = query.first, i = query.second;
      ans[i] = (r-x+1) - d.sum(r);
    }
  }

  rep(i,q) cout << ans[i] << ' ';
  return 0;
}


Measured memory_bytes: 59880
import java.io.*;
import java.util.Scanner;

public class Main{
  public static void main(String[] args){
    Scanner sc=new Scanner(System.in);
    int m;
    int h;
    String s;
    String card;
    String card2;
    while(true){
      card=sc.next();
      if(card.startsWith("-")) break;
      m=sc.nextInt();
      for(int i=0;i<m;i++){
        h=sc.nextInt();
        card2=card.substring(0,h);
        card=card.substring(h);
        card=card+card2;
      }
      System.out.println(card);
    }
  }
}



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

int main() {
  string n, ans;
  cin >> n;
  int sum = 0;
  for(int i = 0; i < n.size(); i++) {
    sum += (int)('0' - n[i]);
  }
  ans = sum % 9 == 0? "Yes": "No";
  cout << ans;
}

Measured memory_bytes: 3700
main(n,f,x){unsigned int u;for(scanf("%d",&n);n--;){
	scanf("%x",&u);
	f=(u&0x7f)*78125;
	for(x=7;x>1&&!(f%10);f/=10)x--;
	printf("%s%d.%0*d\n",u&(1<<31)?"-":"",(u&0x7fffff80)>>7,x,f);
}exit(0);}

Measured memory_bytes: 616
#include<iostream>
using namespace std;
int main()
{
	int a,b,c,x,n=0;
	cin>>a>>b>>c>>x;
	for(int d=0;d<=a;d++)
	{
		for(int e=0;e<=b;e++)
		{
			for(int f=0;f<=c;f++)
			{
				if(d*500+e*100+f*50==x)n++;
			}
		}
	}
	cout<<n<<endl;
	return 0;
}

Measured memory_bytes: 256
using System;
using System.Linq;
using System.Collections.Generic;
using System.IO;

namespace atcorder2
{
    class Program
    {
        public static long Read()
        {

            return long.Parse(Console.ReadLine());
        }

        public static long[] Reads()
        {

            return Console.ReadLine().Split().Select(long.Parse).ToArray();
        }

       




        static void Main(string[] args)
        {
            var sw = new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
            Console.SetOut(sw);

            var nl = Reads();
            var n = nl[0];
            var l = nl[1];
            var s = new string[n];
            for (int i = 0; i < n; i++)
            {
                s[i] = Console.ReadLine();
            }
            Array.Sort(s);
            var ans = "";
            for (int i = 0; i < n; i++)
            {
                ans += s[i];
            }
            Console.WriteLine(ans);


            Console.Out.Flush();
        }
    }
}




Measured memory_bytes: 13536