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

#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#pragma GCC optimize ("unroll-loops")
#pragma GCC optimize("Ofast")
#pragma GCC optimize ("O3")
#pragma GCC target ("avx")

#define fio ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define mpq priority_queue<int,vector<int>,greater<int>>
#define debug(a) cerr << #a << ": " << a << endl
#define umii unordered_map<int64_t,int64_t>
#define ftt int t;cin>>t;for(int tt=1;tt<=t;++tt)
#define forr(i,n) for((i)=1;(i)<=(n);(i)++)
#define Rev(v) reverse(v.begin(),v.end());
#define Sort(v) sort(v.begin(),v.end());
#define mem(a,b) memset(a,b,sizeof(a))
#define deb(x) cout<<"\nhi"<<x<<"\n"
#define pq priority_queue<int>
#define dbg cout<<"\nhi\n"
#define sayy cout<<"YES\n"
#define sayn cout<<"NO\n"
#define pii pair<int,int>
#define mii map<int,int>
#define vb vector<bool>
#define vi vector<int>
#define eb emplace_back
#define nl cout<<"\n"
#define pb push_back
#define pf push_front
#define popb pop_back
#define popf pop_front
#define sp <<" "<<
#define int long long
#define double long double
#define se second
#define fi first

const int MOD = 1000000007;
const double PI = 3.1415926535898;
const int LIM = 100005;

using namespace std;

int fpow( int x,int y) {
    int temp;
    if(y == 0)
        return 1;
    temp = fpow(x, y/2);
    if (y%2 == 0)
        return temp*temp;
    else
        return x*temp*temp;}

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

void sieve(int n) {
     bool prime[5*LIM];
     memset(prime, true, sizeof(prime));
     for (int p=2; p*p<=n; p++)
          if (prime[p] == true)
               for (int i=p*p; i<=n; i += p)
                    prime[i] = false;
     prime[1]=0;}

inline int read(){
    int p=1,ans=0;
    char ch=getchar();
    while(ch<48||ch>57)
    {
        if(ch=='-')p=-1;
        ch=getchar();
    }
    while(ch>=48&&ch<=57)
    {
        ans=(ans<<3)+(ans<<1)+ch-48;
        ch=getchar();
    }
    return ans*p;
}

int fun(int n)
{
    if(n % 2 != 0)
        return n;
    while(n % 2 == 0)
        n /= 2;
    return n;
}

/*int cnt, sum = 0, mid, mx = -1e17, mn = 1e17, a[2*LIM];
int n, m, d, t, i, j, k, l, r, x, y, z;
bool f, f1, f2;
string s;*/

//*************************************************************************************************************************


int32_t main()
{    fio;

     char c;
     cin>>c;
     if((int)c >= 97)
        cout<<'a';
    else
        cout<<'A';
     return 0;
}





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

int main(){
	string s;
  	cin>>s;
  	if(s.find("a",0)==-1||s.find("b",0)==-1||s.find("c",0)==-1)cout<<"No"<<endl;
  	else cout<<"Yes"<<endl;
  	return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <iostream>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <string>
#include <vector>
#include <list>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <bitset>
#include <numeric>
#include <climits>
#include <cfloat>
#include <functional>
using namespace std;

int main()
{
    for(;;){
        int n, s;
        cin >> n >> s;
        if(n == 0)
            return 0;

        vector<vector<long long> > dp(n+1, vector<long long>(s+1, 0));
        dp[0][0] = 1;
        for(int i=0; i<=100; ++i){
            for(int j=n-1; j>=0; --j){
                for(int k=0; k<=s; ++k){
                    int a = k + i;
                    if(a <= s)
                        dp[j+1][a] += dp[j][k];
                }
            }
        }

        cout << dp[n][s] << endl;
    }
}

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

using namespace std;

#define int long long
#define all(v) (v).begin(), (v).end()
#define resz(v, ...) (v).clear(), (v).resize(__VA_ARGS__)
#define reps(i, m, n) for(int i = (int)(m); i < (int)(n); i++)
#define rep(i, n) reps(i, 0, n)

template<class T1, class T2> void chmin(T1 &a, T2 b){if(a>b)a=b;}
template<class T1, class T2> void chmax(T1 &a, T2 b){if(a<b)a=b;}

typedef pair<int, int> Pi;
typedef tuple<int, int, int> Ti;
typedef vector<int> vint;

const int inf = 1LL << 55;
const int mod = 1e9 + 7;

struct Point {
  double x, y;
  Point(){}
  Point(double x, double y):x(x), y(y){}
};

int m;
vector<Point> ps;


double crossY(Point p, Point q, double X) {
  return (p.y-q.y)*(X-p.x)/(p.x-q.x)+p.y;
}

typedef pair<double, double> Pd;

vector<Pd> crossY(int X) {
  vector<Pd> res;
  rep(i, m) {
    int lx = min(ps[i].x, ps[(i+1)%m].x);
    int rx = max(ps[i].x, ps[(i+1)%m].x);
    if(lx == rx) continue;
    if(lx <= X && X+1 <= rx) {
      double cy1 = crossY(ps[i], ps[(i+1)%m], X);
      double cy2 = crossY(ps[i], ps[(i+1)%m], X+1);
      if(cy1 < cy2) swap(cy1, cy2);
      res.emplace_back(cy1, cy2);
    }
  }
  sort(all(res));
  reverse(all(res));
  return res;
}

signed main()
{
  cin.tie(0);
  ios_base::sync_with_stdio(0);
  cout << fixed << setprecision(12);

  while(cin >> m, m) {
    resz(ps, m);
    rep(i, m) {
      cin >> ps[i].x >> ps[i].y;
    }
    int ans = 0;
    reps(X, -2100, 2100) {
      vector<Pd> cy = crossY(X);
      int py = 2100;
      for(int i = 0; i < (int)cy.size()-1; i+=2) {
	int ty = min((int)ceil(cy[i].first), py);
	int by = floor(cy[i+1].second);
	ans += ty-by;
	py = by;
      }
    }
    cout << ans << endl;
  }

  return 0;
}

Measured memory_bytes: 3100
#include <iostream>
#include <vector>

using namespace std;

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

int main()
{
  int n,b;
  vector<int> a;
  cin >> n;

  REP(i,n){
    cin >> b;
    a.push_back(b);
  }

  b=0;
  int i=0;

  while(i<n){
    while(a[i]%2==0){
      b++;
      a[i]/=2;
    }
    i++;
  }

  cout << b << endl;

}


Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
#define endl '\n'
#define int long long
#define pb push_back
#define ppb pop_back
#define vi vector<int>
#define rep(i,n) for(int i=0;i<n;i++)
#define ren(i,n) for(int i=n-1;i>=0;i--)
#define iter(it,v) for(auto it:v)
#define iterp(it,v) for(auto it=v.begin(),it!=v.end();it++)
#define itern(it,v) for(auto it=v.rbegin();it!=v.rend();it++)
#define w(n) while(n--)
#define forp(i,a,b) for(int i=a;i<=b;i++)
#define forn(i,a,b) for(int i=a;i>=b;i--)
#define sc(a) scanf("%d",&a)
#define pf(a) printf("%d",a)
#define init(a,r) for(auto&i:a) i=r;
#define initi(a,r) memset(a,r,sizeof(a))
#define inpt(a,n) for(int i=0;i<n;i++) cin>>a[i];
#define inp(a) for(int&i:a) cin>>i;
#define diss(a) for(int i:a) cout<<i<<' ';
#define disn(a) for(int i:a) cout<<i<<'\n';
#define debug(a) cout<<#a<<": ";for(auto i:a)cout<<i<<" ";cout<<'\n';
#define mpii map<int,int>
#define sii set<int>
#define ub upper_bound
#define lb lower_bound
#define bs binary_search
#define all(v) v.begin(),v.end()
#define bitc __builtin_popcount
#define fst ios::sync_with_stdio(false); cin.tie(0),cout.tie(0);
#define pq priority_queue
#define pii pair<int,int>
#define cs(a) cout<<a<<' '
#define cn(a) cout<<a<<'\n'
#define deb(a,b) cout<<a<<' '<<b<<endl;
#define yy "YES"
#define nn "NO"
#define ff first
#define ss second
typedef long long ll;
const int mod=1e9+7,mod1=998244353;
const int N=2e5+6;
vi ar[N];
int depth[N],visited[N];
int ans=0;
void dfs(int node,int parent=-1){
    if(visited[node])
        return;
    visited[node]=true;
    int k=1;
    iter(child,ar[node]){
        if(child!=parent){
            dfs(child,node);
            k=max(k,depth[child]+1);
        }
    }
    depth[node]=k;
    ans=max(ans,k-1);
}
void a_b_l(){
    ans=1;
    int n,m;
    cin>>n>>m;
    w(m){
        int a,b;
        cin>>a>>b;
        ar[a].pb(b);
        //ar[b].pb(a);
    }
    initi(visited,false);
    forp(i,1,n){
        dfs(i);
    }
    cn(ans);
}
signed main(){
    fst;
    int t=1;
    //cin>>t;
    w(t)
    	a_b_l();
}

Measured memory_bytes: 13952
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#include<stack>
#include<string>
#include<map>
#include<set>
#include<tuple>
#include<cmath>
#include<iomanip>


using namespace std;
typedef long long ll;
typedef vector<ll> v;
typedef vector<vector<ll>> vv;


#define MOD 1000000007
#define INF 1001001001
#define MIN -1001001001
#define rep(i,k,N) for(int i=k;i<N;i++)
#define MP make_pair
#define MT make_tuple //tie,make_tuple は別物
#define PB push_back
#define PF push_front
#define all(x) (x).begin(),(x).end()


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


int main(){
    ll N,D;
    cin>>N>>D;
    ll x,y;
    ll ans=0;
    rep(i,0,N){
        cin>>x>>y;
        if(x*x + y*y <= D*D)ans++;
    }
    cout<<ans;
    return 0;
}

Measured memory_bytes: 3628
/*
  AOJ 0557
  Title:A First Grader
  @kankichi573
*/
#include <stdio.h>
#include <string.h>

int N;
int a[100];
long long x[100][21];


void calc_left()
{
        int i,j,sum,dif;

        x[0][a[0]]=1;

        for(i=1;i<N-1;i++)
                for(j=0;j<=20;j++)
                {
                        sum=j+a[i];
                        if(sum >= 0 && sum <= 20)
                                x[i][sum] += x[i-1][j];
                        dif=j-a[i];
                        if(dif >= 0 && dif <= 20)
                                x[i][dif] += x[i-1][j];
                }

}

void dump1()
{
        int i,j;

        for(j=0;j<=N-1;j++)
        {
                for(i=0;i<=20;i++)
                        printf("%2lld|",x[j][i]);
                printf("\n");
        }
        
}

long long solve()
{
        long long ret;
        int i,j;

        calc_left();

        //dump1();

        ret = x[N-2][a[N-1]];

        return(ret);

}




main()
{
        int i;
        long long ret;

        scanf("%d",&N);

        for(i=0;i<N;i++)
                scanf("%d",&a[i]);

        ret=solve();
        printf("%lld\n",ret);

  return(0);
}

Measured memory_bytes: 616
#include <iostream>
#include <cmath>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <set>
#include <map>
using namespace std;
#define rep(i,q) for(int i = 0; (q) > i; i++)
int main(){
  int n,m;cin>>n>>m;
  vector<int> a;
  rep(i,m){
    int tmp;cin>>tmp;
    a.push_back(tmp);
  }
  sort(a.begin(),a.end());
  rep(i,m-1){
    a[i] = a[i+1]-a[i];
  }
  a[a.size()-1] = 0;
  sort(a.begin(),a.end());
  long long sm = 0;
  rep(i,m-n+1){
    sm += a[i];
  }
  cout << sm << endl;

}

Measured memory_bytes: 892
# include <iostream>
# define MAX 202

using namespace std;

int N;
long long A[MAX];

int main(){
    cin >> N;
    for ( int i = 0; i < N; i++ ){
        cin >> A[i];
    }
    
    int ans = 0;
    bool flag = false;
    while ( true ) {
        for ( int i = 0; i < N; i++){
            if ( A[i] % 2 == 0 ) { A[i] = A[i] / 2; }
            else { flag = true; break;}
        }
        if ( flag == true ) { break; }
        ans ++;
    }

    cout << ans;

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const long double PI = 3.14159265358979323846;

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

    ll x;
    cin >> x;
    ll balance = 100;
    int years = 0;
    while (balance < x) {
        ++years;
        balance += (balance / 100);
    }

    cout << years << '\n';

    return 0;
}

Measured memory_bytes: 3636
#include <bits/stdc++.h>
#include <algorithm>
using namespace std;
typedef long long ll;
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;}

const int INF = 100000; 

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

    for(int i = a; i <= a * b; i += a){
        if(i % b == c){
            cout << "YES" << endl;
            return 0;
        }
    }

    cout << "NO" << endl;

    return 0;
}


Measured memory_bytes: 256
#include <iostream>
int main(void){
  int n,a,b,max=0,c=21;
  std::cin>>n;
  for(int i=0;i<n;i++){
    std::cin>>a>>b;
    if(max<=b){
      if(max==b){
	if(c>a)c=a;
	continue;
      }
      max=b;
      c=a;
    }
  }
  std::cout<<c<<" "<<max<<'\n';
  return 0;
}

Measured memory_bytes: 1164
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <vector>
#include <string>
#include <set>
#include <map>
#include <queue>
#include <deque>
#include <bitset>
#include <numeric>
#include <sstream>
#include <cmath>
#include <cstdlib>
#include <cstring>
#include <stack>

using namespace std;

#define int long long

#define rep(i,n) for(int i = 0; i<n ; i++)
#define FOR(i,a,n) for(int i=a; i<n; i++)
#define REPSTR(i,s) for(int i=0; (s)[i]; i++)
#define REPITR(i,s) for(auto i=(s).begin(); i!=(s).end();i++)

#define RANGE(a,i,b) ((a)<=(i)&&(i)<=(b))

#define pb push_back
#define mp make_pair

#define ALL(a) (a).begin(), (a).end()

#define EXIST(s,x) ((s).find(x)!=(s).end())

#define SET(a,c) memset(a,c,sizeof(a))
#define CLR(a) memset(a,0,sizeof(a))

#ifdef _DEBUG
#define DEBUG(x) cerr<<#x<<":"<<x<<endl
#else
#define DEBUG(x)
#endif

#define PRINTJOIN(x,n) rep(i,n){if(i)cout<<" ";cout<<x[i];}cout<<endl 

#define INF 1001001001
#define LLINF 1001001001001001001LL

typedef long long ll;
typedef pair<int, int> PII;
typedef vector<int> VI;
typedef stringstream SS;

#define PQ priority_queue

#define FST first
#define SEC second

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

signed main(void) {
	cin.tie(0);
	ios::sync_with_stdio(false);
    
    int a,b;
    a=0;b=1123456789; // a:ng, b:ok
    int n,k;
    VI w;
    w.reserve(112345);
    cin>>n>>k;
    rep(i,n){
        int t;cin>>t;w.pb(t);
    }
    while(b-a>1) {
        int c = (a+b)/2;
        int p=0;
        rep(i,k) {
            int x=0;
            while(x+w[p]<=c) {
                x+=w[p++];
                if(p == w.size()) break;
            }
        }
        if(p<n) a=c;
        else b=c;
    }
    cout << b<< endl;
	return 0;
}


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

int main(){
  int H,W;
  while(1){
    cin >> H >> W ;
    if(H == 0 && W == 0 )
      break;

    for(int i=1;i<=H;i++){
      for(int j=1;j<=W;j++){
        if((i+j)%2==0){
          cout << "#" ;
        }else{
          cout << "." ;
        }
      }
      cout << endl;
    }
    cout << endl;
  }

  return 0;
}



Measured memory_bytes: 3088
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef unsigned long long int ull;
typedef pair<ll, ll> PLL;
#define _overload3(_1, _2, _3, name, ...) name
#define _rep(i, n) repi(i, 0, n)
#define repi(i, a, b) \
  for (int i = static_cast<int>(a); i < static_cast<int>(b); ++i)
#define rep(...) _overload3(__VA_ARGS__, repi, _rep, ) (__VA_ARGS__)  // NOLINT

ll N, M, P;

// i番目の要素を採用できるか否か
bool f(vector<ll> a, ll V, ll i) {
  if (i < P)
    return true;

  // 自分自身
  a[i] += M; V--;
  if (a[P-1] > a[i])
    return false;

  // 自分自身より小さいものはどうでもよい
  ll t = 0;
  t += (N-1 - (i+1) +1) * M;

  // 1 ~ P-1番目のものはどうでもよい
  t += (P-1) * M;

  // P番目までは逆転したい -> j = P-1 ~ i-1 に、つまりできるだけ分散させたい
  for (ll j=P-1; j<i; j++) {
    t += min(M, max(0ll, a[i] - a[j]));
  }

  return t >= M * V;
}

signed main() {
  ll V;
  cin >> N >> M >> V >> P;
  vector<ll> a(N);
  rep(i, N) cin >> a[i];
  sort(begin(a), end(a), greater<ll>());
  ll ok = -1, ng = N;
  while (ok + 1 < ng) {
    ll m = (ok+ng)/2;
    if (f(a, V, m)) ok = m;
    else ng = m;
  }
  cout << ng << endl;
  return 0;
}


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

using namespace std;

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

int main(){
    char ss[4];
    cin >> ss;
    int f = int(ss[0]-'0')*10+int(ss[1]-'0');
    int s = int(ss[2]-'0')*10+int(ss[3]-'0');
    bool y = false;
    bool m = false;
    if(s > 0 && s < 13)y = true;
    if(f > 0 && f < 13)m = true;
    if(y&&m)cout << "AMBIGUOUS" << endl;
    if(y&&(!m))cout << "YYMM" << endl;
    if((!y)&&m)cout << "MMYY" << endl;
    if((!y)&&(!m))cout << "NA" << endl;
    return 0;
}

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

typedef long long ll;
const ll MOD = 1e9 + 7;

int main() {
    ll n, m;
    cin >> n >> m;
    vector<ll> vecA(n), vecB(m);
    for (int i = 0; i < n; ++i) {
        cin >> vecA[i];
    }
    for (int i = 0; i < m; ++i) {
        cin >> vecB[i];
    }
    set<ll> setA(vecA.begin(), vecA.end());
    set<ll> setB(vecB.begin(), vecB.end());
    sort(vecA.begin(), vecA.end());
    sort(vecB.begin(), vecB.end());
    if (setA.size() != vecA.size() || setB.size() != vecB.size()) {
        cout << 0 << endl;
        return 0;
    }
    ll ans = 1;
    ll total = n * m;
    ll cnt;
    for (cnt = 1; cnt <= total; ++cnt) {
        if (setA.count(cnt) && setB.count(cnt)) {
            continue;
        } else if (setA.count(cnt)) {
            auto ub = upper_bound(vecB.begin(), vecB.end(), cnt);
            ans = (ans * distance(ub, vecB.end())) % MOD;
        } else if (setB.count(cnt)) {
            auto ub = upper_bound(vecA.begin(), vecA.end(), cnt);
            ans = (ans * distance(ub, vecA.end())) % MOD;
        } else {
            auto uba = upper_bound(vecA.begin(), vecA.end(), cnt);
            auto ubb = upper_bound(vecB.begin(), vecB.end(), cnt);
            ans = (ans * (distance(uba, vecA.end()) * distance(ubb, vecB.end()) - (total - cnt))) % MOD;
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 384
# 07-Repetitive_Processing-How_Many_Divisors.py

# ?´???°?????°
# ???????????´??° aa???bb???cc ??????????????????aa ?????? bb ?????§?????´??°????????????cc ????´???°?????????????????????????±???????????????°????????????????????????????????????

# Input
# aa???bb???cc ?????????????????????????????§??????????????????????????????
# Output
# ?´???°?????°???????????????????????????????????????

# Constraints
# 1???a,b,c???10000
# a???b
# Sample Input
# 5 14 80
# Sample Output
# 3

aa,bb,cc = map(int,input().split())
count=0

for i in range(bb-aa+1):
	if cc%(aa+i)==0:
		count+=1

print(count)

Measured memory_bytes: 7644
#include <bits/stdc++.h>
#define ll long long 
using namespace std;
const ll mod = 1e9+7;
const ll nax = 3e3+7;
const ll INF = 1e18;

ll dp[nax][nax];
string a,b;

int main(){
//	freopen("input.inp","r",stdin);
//	freopen("output.out","w",stdout);
	
	ios_base::sync_with_stdio(false);
	cin.tie(0);cout.tie(0);
	
	cin>>a>>b;
	
	ll n=a.size(),m=b.size();
	
	for (ll i=0;i<n;++i){
		for (ll j=0;j<m;++j){
			if (a[i]==b[j]) dp[i+1][j+1]=dp[i][j]+1;
			else dp[i+1][j+1] = max(dp[i+1][j],dp[i][j+1]);
		}
	}
	
	ll i=n,j=m;
	stack<char> stk;
	
	while (i&&j){
		if (a[i-1]==b[j-1]) {
			stk.push(a[i-1]);
			i--;
			j--;
		}
		
		else {
			if (dp[i][j-1]>dp[i-1][j]) j--;
			else i--; 
		}
	}
	
	while (stk.size()) {
		cout<<stk.top();
		stk.pop();
	}
	
//	cout<<"\n"<<dp[n][m];
	
}

Measured memory_bytes: 74100
#include <bits/stdc++.h>
#define ll long long
#define fi first
#define se second
#define sz(a)  int((a).size())
#define pb  push_back
#define eb  emplace_back
#define FOR(var,from,to) for(int var=(from);var<=(to);++var)
#define rep(var,n)  for(int var=0;var<(n);++var)
#define rep1(var,n)  for(int var=1;var<=(n);++var)
#define repC2(vari,varj,n)  for(int vari=0;vari<(n)-1;++vari)for(int varj=vari+1;varj<(n);++varj)
#define repC3(vari,varj,vark,n)  for(int vari=0;vari<(n)-2;++vari)for(int varj=vari+1;varj<(n)-1;++varj)for(int vark=varj+1;vark<(n);++vark)
#define ALL(c)  (c).begin(),(c).end()
#define RALL(c)  (c).rbegin(),(c).rend()
#define tr(i,c)  for(auto i=(c).begin(); i!=(c).end(); ++i)
#define mset(arr,val)  memset(arr,val,sizeof(arr))
#define mid(x,y) ((x)+((y)-(x))/2)
#define IN(x,a,b) ((a)<=(x)&&(x)<=(b))
using namespace std;
template<typename T> void Out(T x) { cout << x << endl; }
template<typename T1, typename T2> void Ans(bool f, T1 y, T2 n) { if(f) Out(y); else Out(n); }


int main() {
    int A,B,C,D,N;
    double ans;
    cin>>N;
    ans=1-((double)(N/2)/(double)N);
    Out(ans);
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)  
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define RVSORT(v) sort(v.rbegin(), v.rend());
#define ll long long
#define pb(a) push_back(a)
#define INF 999999999
#define MOD 1000000007
using namespace std;
typedef pair<int, int> P;
typedef pair<ll, ll> LP;
typedef pair<int, P> PP;
typedef pair<ll, LP> LPP;

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

int gcd(int a,int b){return b?gcd(b,a%b):a;}

ll modpow(ll n,ll k){
  if(k == 1){
    return n;
  }else if(k == 0){
    return 1;
  }else if(k%2==0){
    ll memo = modpow(n,k/2)%MOD;
    return memo*memo%MOD;
  }else{
    return n * modpow(n,k-1)%MOD;
  }
}

int main(){

  string s;cin>>s;
  int n = s.size();
  int a[n];
  REP(i,n){
    a[i] = 0;
  }
  int satan,utan;
  satan = 0;
  utan = 0;
  REP(i,n-1){
    if(s[i]=='R'&&s[i+1]=='L'){
      int j = i+1;
      utan = j;
      while(j<n-1){
        if(s[j]=='L'&&s[j+1]=='R'){
          utan = j;
          break;
        }else if(j==n-2){
          utan = n-1;
          break;
        }
        j++;
      }
      a[i] += ceil((i-satan+1)/2.0);
      a[i+1] += (i-satan+1)/2;
      a[i+1] += ceil((utan-i)/2.0);
      a[i] += (utan-i)/2;
      i = utan;
      satan = utan+1;
    }
  }

  REP(i,n){
    cout<<a[i]<<" ";
  }

 

  return 0;
}

Measured memory_bytes: 1024
import java.util.ArrayList;
import java.util.Comparator;
import java.util.List;
import java.util.Scanner;


public class Main {
    public static void main(String[] args) {
        Scanner input = new Scanner(System.in);

        long N = input.nextLong();
        List<Long> divisor = new ArrayList();

        for(long i = 1; i <= Math.sqrt(N); i ++){
            if (N % i == 0){
                if (i == Math.sqrt(N))
                    divisor.add(i);
                else {
                    divisor.add(i);
                    divisor.add(N/i);
                }
            }
        }
        divisor.sort(Comparator.naturalOrder());

        if (divisor.size()==2){
            System.out.println(N-1);
        }else if (divisor.size()%2 == 0){
            System.out.println(computeResult(N,divisor.get(divisor.size()/2)));
        }else {
            System.out.println((int)Math.sqrt(N)*2-2);
        }
    }

    static public long computeResult(long N, long input){
        long result;
        result = input + N/input - 2;

        return result;
    }
}

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

using namespace std;

long long n, a[5000], minn[2001][2001];

int main()
{
    cin >> n;
    long long x;
    long long ans = 0;
    cin >> x;
    for (int i = 0; i < n; i++)
    {
        scanf("%d", &a[i]);
    }
    for (int i = 0; i < n; i++)
    {
        ans+=a[i];
        minn[i][i] = a[i];
        for (int j = i + 1; j < n; j++)
        {
            minn[i][j] = min(a[j], minn[i][j - 1]);
        }
    }
    for (int k = 0; k < n; k++)
    {
        long long t = k * x;
        for (int i = 0; i < n; i++)
        {
            if (i - k >= 0)
            {
                t += minn[i - k][i];
            }
            else
            {
                t += min(minn[i - k + n][n - 1], minn[0][i]);
            }
        }
        ans = min(ans, t);
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 31104
/* ＵＴＦ－８ */
#include <iostream>
#include <string>
#include <vector>
#include <deque>
#include <list>
#include <set>
#include <unordered_set>
#include <map>
#include <unordered_map>
#include <array>
#include <queue>
#include <stack>
#include <algorithm>
#include <tuple>
#include <numeric>
#include <type_traits>
#include <limits>

#include <stdio.h>
#include <unistd.h>
#include <fcntl.h>
#include <string.h>

#define USE_COLORED 1

#ifdef USE_COLORED
static const char stdout_pre[]  = "\033[1m"; // bold black
static const char stderr_pre[]  = "\033[31;1m"; // bold red
static const char stdxxx_post[] = "\033[m";

// 当然ながら GCC(g++)/libstdc++ 依存
#include <ext/stdio_filebuf.h>
using stdio_filebuf = __gnu_cxx::stdio_filebuf<char>;
class colored_stdio_filebuf : public stdio_filebuf {
private:
	const char* const pre_;
	const char* const post_;

public:
	colored_stdio_filebuf(FILE* fp, const char* pre, const char* post) : stdio_filebuf(fp, std::ios_base::out), pre_(pre), post_(post)
	{
	}

protected:
	std::streamsize xsputn(const char* s, std::streamsize count) override
	{
		stdio_filebuf::xsputn(pre_, strlen(pre_));
		auto ret = stdio_filebuf::xsputn(s, count);
		stdio_filebuf::xsputn(post_, strlen(post_));
		return ret;
	}
};
#endif

int main()
{
#ifdef USE_COLORED
	if (getenv("DEBUG")) {
		std::cout.rdbuf(new colored_stdio_filebuf(stdout, stdout_pre, stdxxx_post));
		std::cerr.rdbuf(new colored_stdio_filebuf(stderr, stderr_pre, stdxxx_post));
	} else
#endif
	{
		int fd = open("/dev/null", O_WRONLY);
		dup2(fd, 2);
		close(fd);
	}
	
	int x;
	std::cin >> x;
	if (x < 1200)
		std::cout << "ABC\n";
	else
		std::cout << "ARC\n";
}


Measured memory_bytes: 512
#include <iostream>
#include <cassert>
#include <iomanip>
#include <cmath>

using namespace std;

int N, a2[202020], a5[202020], cnt[100][100];
int main(){
    cin >> N;
    for(int i = 0; i < N; i++){
        
        string word;  
        cin>> word;

        long long int a = 0;
        int end = -1;
        for(int i = 0; i < word.size(); i++){
            if(word[i] == '.'){
                end = i + 1;
                break;
            }
            a *= 10;
            a += (word[i] - '0');
        }
        for(int i = 0; i < 9; i++){
            a *= 10;
            if(end != -1 && i + end < word.size())a += (word[i + end] - '0');
        }
        //cout << a << '\n';

        while(a % 2 == 0)a2[i]++, a /= 2;
        while(a % 5 == 0)a5[i]++, a /= 5;
        //cout << a2[i] << " " << a5[i] << '\n';
        cnt[a2[i]][a5[i]]++;
    }
    
    for(int i = 99; i >= 0; i--){
        for(int j = 99; j >= 0; j--){
            if(i < 99)cnt[i][j] += cnt[i + 1][j];
            if(j < 99)cnt[i][j] += cnt[i][j + 1];
            if(i < 99 && j < 99)cnt[i][j] -= cnt[i + 1][j + 1];
            assert(cnt[i][j] >= 0);
        }
    }

    long long int result = 0;
    for(int i = 0; i < N; i++){
        int need2 = max(0, 18 - a2[i]);
        int need5 = max(0, 18 - a5[i]);

        //cout << a2[i] << " " << a5[i] << " - " << need2 << " " << need5 << '\n';

        result += cnt[need2][need5];

        if(a2[i] >= need2 && a5[i] >= need5)result--;
    }
    assert(result % 2 == 0);
    cout << result / 2 << '\n';
}

Measured memory_bytes: 5120
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
#define all(x) x.begin(),x.end()

int main(){
  ll n,tmp;
  string s = "Yes";
  bool judge = true;
  cin >> n;
  cin >> tmp;
  for(ll i=0;i<n-1;i++){
    ll x;
    cin >> x;
    if(tmp == x+1 && judge){
      judge = false;
      tmp = x;
    }
    else if((tmp == x+1 && !judge) || tmp>x+1){
      s = "No";
      break;
    }
    else if(tmp == x && !judge){
      tmp = x;
    }
    else{
      judge = true;
      tmp = x;
    }
  }
  cout << s << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <fstream>
#include <numeric>
using namespace std;
typedef long long int ll;

#define EPS (1e-7)
#define INF 1e18
#define max(p,q)((p)>(q)?(p):(q))
#define min(p,q)((p)<(q)?(p):(q))
#define PI (acos(-1))

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

int main() {

    string s;
    cin >> s;
    int ans = 0;
    REP(i, 3) if (s[i] == '1') ans++;
    cout << ans << endl;

    return 0;
}



Measured memory_bytes: 256
#include <cstdio>
#include <cstdlib>
#include <vector>
#include <algorithm>
#include <map>
#include <bitset>
#include <unordered_set>
#include <set>
typedef long long LL;
using namespace std;
int n, t;
int main() {
    scanf("%d %d", &n, &t);
    vector<int> num(n);
    for(int i = 0; i < n; i++) {
        scanf("%d", &num[i]);
    }
    int res = 0;
    for(int i = 1; i < n; i++) {
        res += min(t, num[i] - num[i - 1]);
    }
    res += t;
    printf("%d\n", res);
    
    return 0;
}


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

const int Nmax = 501;
int N;
int C[Nmax], S[Nmax], F[Nmax];

int main() {
	cin >> N;
	for (int i = 1; i < N; i++) {
		cin >> C[i] >> S[i] >> F[i];
	}

	for (int i = 1; i <= N; i++) {
		int t = 0;
		for (int j = i; j < N; j++) {
			int t_dep = S[j];
			while (t_dep < t) {
				t_dep += F[j];
			}
			t = t_dep + C[j];
		}
		cout << t << endl;
	}
}

Measured memory_bytes: 256
edge = [[-1, 0, 1, -1, -1, -1],\
        [-1, -1, -1, 1, -1, -1],\
        [-1, 0, -1, -1, -1, -1],\
        [-1, -1, -1, -1, 0, 1],\
        [-1, -1, 1, -1, -1, 0],\
        [-1, 1, 0, -1, -1, -1]]

while True:
    s = input()
    if (s == '#'):
        break

    place = 0;
    for i in range(len(s)):
        num = int(s[i])
        if (num not in edge[place]):
            place = -1
            break
        for j in range(6):
            if (edge[place][j] == num):
                place = j
                break

    if (place == 5):
        print('Yes')
    else:
        print('No')

Measured memory_bytes: 7644
//inlclude before define 
#define _USE_MATH_DEFINES

//include
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<cmath>
#include<type_traits>
#include<numeric>
#include<assert.h>
//#include<deque>
#include<iomanip>
#include<set>
#include<tuple>
#include<map>
using namespace std;

//typedef
typedef vector<int> VI;
typedef vector<string> VS;
typedef vector<char> VC;
typedef pair<int, int> P1;
typedef long long int ll;

//define
#define INF 1e9
#define NUM 1000000007
#define all(x) begin(x), end(x)
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define repi(i,a,b) for(int i=int(a);i<int(b);++i)
#define REP(i,a,b) for(int i=int(a);i<int(b);i++)
#define chmin(a,b) a=min((a),(b))
#define chmax(a,b) a=max((a),(b))


int main() {
	string s;
	cin >> s;
	int num = 753,a;
	int size = s.size();
	int minv = INF;

	if (size == 3) a = 0;
	else if (size == 4) a = 1;
	else a = size-2;

	for (int i = 0; i <= a; i++) {
		string su = s.substr(i, 3);
		int a = stoi(su);
		//cout << a << endl;
		chmin(minv, abs(num - a));
	}
	cout << minv << endl;

}





Measured memory_bytes: 256
// AOJ 1179
#include<iostream>
using namespace std;

int abs(int y, int m, int d, int acc) {
  if (m == 1 and d == 1) {
    if (y == 1) {
      return acc;
    } else if (y % 3 == 1) {
      return abs(y - 1, 1, 1, acc + 200);
    } else {
      return abs(y - 1, 1, 1, acc + 195);
    }
  } else if (d == 1) {
    return abs(y, m - 1, 1, acc + ((y%3==0||m%2==0)?20:19));
  } else {
    return abs(y, m, 1, acc+d-1);
  }
}

int solve(int y, int m, int d) {
  return abs(1000,1,1,1) - abs(y,m,d,1);
}

int main() {
  int n;
  cin >> n;
  int y, m, d;
  for (int i = 0; i < n; i++) {
    cin >> y >> m >> d;
    cout << solve(y, m, d) << endl;
  }
}

Measured memory_bytes: 1160
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
using namespace std;
const pair<int, int> INF = {1 << 30, -(1 << 30)};
signed main() {
  ios::sync_with_stdio(false); cin.tie(0);
  int n, m, l;
  cin >> n >> m >> l;
  vector<vector<int>> g(n, vector<int>(n, -1));
  for (int i = 0; i < m; i++) {
    int a, b, c;
    cin >> a >> b >> c;
    a--;
    b--;
    if (c > l) continue;
    g[a][b] = g[b][a] = c;
  }
  auto comp = [&] (const pair<int, int>& x, const pair<int, int>& y) {
    if (x.first != y.first) return x.first < y.first;
    return x.second > y.second;
  };
  vector<vector<pair<int, int>>> dist(n, vector<pair<int, int>>(n, INF));
  for (int st = 0; st < n; st++) {
    dist[st][st] = {0, l};
    vector<bool> used(n, false);
    while (true) {
      int nxt = -1;
      for (int i = 0; i < n; i++) {
        if (!used[i] && (nxt == -1 || comp(dist[st][i], dist[st][nxt]))) nxt = i;
      }
      if (nxt == -1) break;
      used[nxt] = true;
      for (int i = 0; i < n; i++) {
        int cost = g[nxt][i];
        if (cost == -1) continue;
        int fuel = dist[st][nxt].first;
        int rem = dist[st][nxt].second;
        if (rem >= cost) {
          rem -= cost;
        } else {
          fuel++;
          rem = l - cost;
        }
        if (comp({fuel, rem}, dist[st][i])) dist[st][i] = {fuel, rem};
      }
    }
  }
  int q;
  cin >> q;
  while (q--) {
    int a, b;
    cin >> a >> b;
    a--;
    b--;
    cout << (dist[a][b].first == 1 << 30 ? -1 : dist[a][b].first) << '\n';
  }
  return 0;
}

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

using namespace std;

const int md = 998244353;

inline void add(int &a, int b) {
  a += b;
  if (a >= md) a -= md;
}

inline void sub(int &a, int b) {
  a -= b;
  if (a < 0) a += md;
}

inline int mul(int a, int b) {
  return (int) ((long long) a * b % md);
}

inline int power(int a, long long b) {
  int res = 1;
  while (b > 0) {
    if (b & 1) {
      res = mul(res, a);
    }
    a = mul(a, a);
    b >>= 1;
  }
  return res;
}

inline int inv(int a) {
  a %= md;
  if (a < 0) a += md;
  int b = md, u = 0, v = 1;
  while (a) {
    int t = b / a;
    b -= t * a; swap(a, b);
    u -= t * v; swap(u, v);
  }
  assert(b == 1);
  if (u < 0) u += md;
  return u;
}

const int N = 2020;

int main() {
  vector<int> fac(N), finv(N);
  fac[0] = finv[0] = 1;
  for (int i = 1; i < N; i++) {
    fac[i] = mul(fac[i - 1], i);
    finv[i] = inv(fac[i]);
  }

  auto comb = [&](int n, int m) {
    if (m < 0) return 0;
    int res = fac[n];
    res = mul(res, finv[m]);
    res = mul(res, finv[n - m]);
    return res;
  };

  string s;
  cin >> s;
  int n = s.length();

  vector< vector<int> > dp(n + 1, vector<int>(n + 1));
  dp[0][0] = 1;
  int red = 0, blue = 0;
  for (int i = 1; i <= n; i++) {
    if (s[i - 1] == '0') red += 2;
    if (s[i - 1] == '1') red++, blue++;
    if (s[i - 1] == '2') blue += 2;
    for (int j = 0; j <= i; j++) {
      if (j <= red && i - j <= blue) {
        if (j > 0) add(dp[j][i - j], dp[j - 1][i - j]);
        if (i - j > 0) add(dp[j][i - j], dp[j][i - j - 1]);
      }
    }
  }
  int res = 0;
  for (int i = 0; i <= n; i++) {
    add(res, mul(dp[i][n - i], comb(n, red - i)));
  }
  cout << res << '\n';
  return 0;
}

Measured memory_bytes: 16000
from heapq import heappop,heappush

n = int(input())
a = list(map(int,input().split()))
dic = dict()
for i,ai in enumerate(a,1):
    if(ai-1 in dic):
        print('No')
        eixt()
    dic[ai-1] = i

hq = []
for i,ai in enumerate(a[1:],2):
    heappush(hq,(ai-i,i-1,i))

others = []
ans = []
for ind in range(n**2):
    if ind in dic:
        i = dic[ind]
        ans.append(i)
        others += [i] * (n-i)
        continue

    if(hq):
        num,rem,i = heappop(hq)
        if(num < ind):
            print('No')
            exit()
        elif(rem==1):
            ans.append(i)
        else:
            ans.append(i)
            heappush(hq,(num+1,rem-1,i))
    else:
        if(others):
            ans.append(others.pop())
        else:
            print('No')
            exit()



print('Yes')
print(' '.join(map(str,ans)))

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

int main(){
    int X, Y;
    long ans = 0;
    cin >> X >> Y;

    if(X == 3){
        ans += 100000;
    }
    if(X == 2){
        ans += 200000;
    }
    if(X == 1){
        ans += 300000;
    }
    if(Y == 3){
        ans += 100000;
    }
    if(Y == 2){
        ans += 200000;
    }
    if(Y == 1){
        ans += 300000;
    }
    if(X == 1 && Y == 1){
        ans += 400000;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int s, tama;
  cin >> s;
  if (s == 0) tama = 0;
  if (s == 1) tama = 1;
  if (s == 10) tama = 1;
  if (s == 100) tama = 1;
  if (s == 11) tama = 2;
  if (s == 101) tama = 2;
  if (s == 110) tama = 2;
  if (s == 111) tama = 3;
  
  cout << tama;
}

Measured memory_bytes: 256
#include<stdio.h>
#pragma GCC optimize("O2")
#define swap(a,b) (a+=b,b=a-b,a-=b)
static inline char CH()
{
  static char buf[100000],*ptr1=buf,*ptr2=buf;
  return ptr1==ptr2&&(ptr2=(ptr1=buf)+fread(buf,1,100000,stdin),ptr1==ptr2)?EOF:*ptr1++;
}
static inline int IN(void)
{
  int x=0,f=0,c=CH();while(c<48||c>57){f^=c==45,c=CH();}
  while(c>47&&c<58){x=x*10+c-48,c=CH();}return f?-x:x;
}
int main(void)
{
  int N=IN(),i=0,u,v;long x=N;
  while(i++<N-1){u=IN(),v=IN();if(u>v){swap(u,v);}x+=1l*(i+1)*(N-i)-1l*u*(N+1-v);}
  return printf("%ld",x),0;
}

Measured memory_bytes: 1648
#include <iostream>
#include <cmath>

using namespace std;

int path(int pedra);

int n_pedras, pulo_maximo;

int altura_pedras[100001];

int custos[100001];

int main(){
    cin >> n_pedras >> pulo_maximo;

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

    for(int i = 1; i <= n_pedras; i++){
        custos[i] = -1;
    }

    int custo_minimo = path(1);

    cout << custo_minimo << endl;

    return 0;
}

int path(int pedra){
    if(pedra == n_pedras){
        return 0;
    }

    if(custos[pedra] == -1){
        int custo_minimo = INT_MAX;

        for(int i = 1; i <= pulo_maximo; i++){
            if(pedra + i <= n_pedras){
                int escolha = abs(altura_pedras[pedra] - altura_pedras[pedra + i]) + path(pedra + i);

                if(escolha < custo_minimo){
                    custo_minimo = escolha;
                }
            }
        }

        custos[pedra] = custo_minimo;
    }

    return custos[pedra];
}

Measured memory_bytes: 7296
class UnionFind
  def initialize(n)
    @tree = Array.new(n, -1)
  end
  def find(x)
    @tree[x] < 0 ? x : @tree[x] = find(@tree[x])
  end
  def unite(x,y)
    x,y = find(x),find(y)
    if x != y
      x,y = y,x if @tree[x] > @tree[y]
      @tree[x] += @tree[y]
      @tree[y] = x
    end
  end
  def size(x)
    -@tree[find(x)]
  end
  def parents
    @tree.map.with_index {|n,i| n < 0 ? i : n }
  end
end

N,M = gets.split.map(&:to_i)
AB = readlines.map {|s| s.split.map(&:to_i) }

uf = UnionFind.new(N)
AB.each {|a,b| uf.unite(a-1,b-1) }
puts uf.parents.uniq.map {|n| uf.size(n) }.max


Measured memory_bytes: 45436
import itertools
N,M=map(int,input().split())
edges={tuple(sorted(map(int,input().split()))) for i in range(M)}
ans=0
for i in itertools.permutations(range(2,N+1)):
    l=[1]+list(i)
    ans+=sum(1 for edge in zip(l,l[1:]) if tuple(sorted(edge)) in edges)==N-1
print(ans)

Measured memory_bytes: 9120
#include<bits/stdc++.h>
using namespace std;
int main(){
    int n;
    cin>>n;
    int i,p[n];
    for(i=0;i<n;i++) cin>>p[i];
    sort(p,p+n);
    cout<<p[n/2]-p[n/2-1]<<endl;
    //for(i=1;i<(n-1);i++
    return 0;
}

Measured memory_bytes: 640
#define _GLIBCXX_DEBUG//TLEの原因になるので注意！！！！！！！！！！！
#include<cmath>
#include <bits/stdc++.h>
typedef long long ll;
using namespace std;
vector<int> arr;
stack<int> st;
queue<int> qu;
queue<pair<int,int> > qu2;
priority_queue<int> pq;
#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define rep2(i,n) for(int i=1; i<=(int)(n); i++)
#define mins(x,y) x=min(x,y)
#define maxs(x,y) x=max(x,y)
typedef set<int> set_t;
typedef set<string> set_g;
typedef complex<double> xy_t;
static const int NIL = -1;
static const int INF = 1000000007;
#define mp make_pair
#define sz(x) int(x.xise())
#define mod 1000000007
#define reps(i,s,n) for(int i = s; i < n; i++)
deque<int> deq;
//#define int long long

//cerrはコメントアウトしなくても通る//ただしTLEを引き起こすことがある

int main(){
    int n;
    cin >> n;
    string s;
    cin >> s;
    int m=s.size();
    rep(i,m){
        if(s[i]-'A'+n>=26){
            s[i]=s[i]+n-26;
        }else{
            s[i]=s[i]+n;
        }
    }
    cout<<s<<endl;
    return 0;
}

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

#define ASC(vec) vec.begin(), vec.end()		// 昇順ソート 例：sort(ASC(vec));
#define DESC(vec) vec.rbegin(), vec.rend()	// 降順ソート 例:sort(DESC(vec));
#define rep(i, n) for(int i = 0; i < (n); i++)
#define Rep(i, n) for(int i = 1; i < n; i++)

const int mod = 1000000007;
const int inf = (int)1e9 + 7;
const long long INF = 1LL << 60;

using ii = pair<int, int>;
using ll = long long;
using vi = vector<int>;
using vd = vector<double>;
using vb = vector<bool>;
using vl = vector<ll>;
using vs = vector<string>;
using vvi = vector<vector<int>>;
using vvl = vector<vector<ll>>;
using vvb = vector<vector<bool>>;
using vii = vector<pair<int, int>>;

template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }

ll GCD(ll a, ll b) { return b ? GCD(b, a % b) : a; }
ll LCM(ll a, ll b) { return (a * b) / GCD(a, b); }
int round_int(int a, int b) { return (a + (b - 1)) / b; }

// 素因数分解; 返り値は(素数, 乗数)のvector配列
vector<pair<ll, int>> factorize(ll n) {
	vector<pair<ll, int>> res;
	for (ll i = 2; i * i <= n; ++i) {
		if (n % i) continue;
		res.emplace_back(i, 0);
		while (n % i == 0) {
			n /= i;
			res.back().second++;
		}
	}
	if (n != 1) res.emplace_back(n, 1);
	return res;
}

constexpr array<int, 9> dx = { 0, 1, 0, -1, -1, 1, 1, -1, 0 };
constexpr array<int, 9> dy = { 1, 0, -1, 0, 1, 1, -1, -1, 0 };
constexpr auto MAX = 100000;

// ──────────────────────────────────────────────────────────────────

int main() {
	int h, w;
	cin >> h >> w;

	char t[50][50];
	int b = 0;
	rep(i, h) {
		rep(j, w) {
			cin >> t[i][j];
			if (t[i][j] == '#') b++;
		}
	}

	// bfs
	vvi d(h, vi(w, -1));
	queue<ii> que;
	
	que.push({ 0,0 });
	d[0][0] = 0;
	int c = -1;

	while (!que.empty()) {
		ii now = que.front(); que.pop();

		if (now.first == h - 1 && now.second == w - 1)
			c = d[now.first][now.second];

		rep(i, 4) {
			int y = now.first + dy[i], x = now.second + dx[i];

			if (0 <= x && x < w &&
				0 <= y && y < h &&
				d[y][x] == -1 &&
				t[y][x] == '.') {
				d[y][x] = d[now.first][now.second] + 1;
				que.push({ y, x });
			}
		}
	}

	if (c == -1) cout << -1 << endl;
	else cout << h * w - c - b - 1 << endl;
}

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

int main(void){
    string o, e;
    int i;
    
    cin >> o >> e;
    
    for(i = 0; i < o.length(); i++){
        if(i < o.length() - 1){
            cout << o[i] << e[i];
        }
        
        else{
            if(o.length() == e.length()){
                cout << o[i] << e[i];
            }
            else{
                cout << o[i];
            }
        }
    }
    
    cout << endl;
    
    return 0;
}

Measured memory_bytes: 256
A=int(input())
B=int(input())
C=int(input())
X=int(input())

count = 0
for a in range(min([A,X//500])+1):
  for b in range(min([B,(X-500*a)//100])+1):
#    print(a*500,b*100,X-500*a-100*b, (X-500*a-100*b)%50==0,(X-500*a-100*b)/50<=C)
    if (X-500*a-100*b) % 50 == 0 and (X-500*a-100*b) / 50 <= C:
#      print(a*500,b*100,X-500*a-100*b, (X-500*a-100*b)%50==0,(X-500*a-100*b)/50<=C)
      
      count = count + 1

print(count)

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

int main()
{
    ll l, r; cin >> l >> r;
    int ans = 2019;
    if(l+2019 <= r)
        ans = 0;
    l %= 2019; r %= 2019;
    for (int i = l; i < r; i++)
    {
        for (int j = i+1; j <= r; j++)
        {
            ans = min(ans, ((i * j) % 2019));
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
using System;
using System.Linq;

namespace B
{
    class Program
    {
        static void Main(string[] args)
        {
            var abcd = Console.ReadLine().Split(' ').Select(x => long.Parse(x)).ToList();
            long max = long.MinValue;
            foreach (var ab in abcd.Take(2))
            {
                foreach (var cd in abcd.Skip(2))
                {
                    max = Math.Max(max, ab * cd);
                }
            }
            Console.WriteLine(max);
        }
    }
}


Measured memory_bytes: 28244
n = int(input())
ansl = [0]*(n+1)
for x in range(1,10**2+1):
    for y in range(1,10**2+1):
        for z in range(1,10**2+1):
            v = x**2 + y**2 + z**2 + x*y + y*z + z*x 
            if v <= n:
                ansl[v] += 1

for v in ansl[1:]:
    print(v)

Measured memory_bytes: 74112
import collections

N, K = map(int, input().split())
R, S, P = map(int, input().split())
T = list(input())

for i in range(N-K):
    if T[i] == T[i+K]:
        T[i+K] = "a"

c = collections.Counter(T)

print(c["r"]*P + c["s"]*R + c["p"]*S)

Measured memory_bytes: 4340
#include <bits/stdc++.h>
using namespace std;
int main() {
    // 入力受け取り, 入次数も管理する
int n;
    cin >> n;
double sum=0;
double te=0;
for(int i=0;i<n;i++){
cin >> te;
sum+=1/te;
}
sum=1/sum;
cout << sum;

}


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

typedef long long ll;
typedef long double ld;
typedef double db; //
typedef string str; //
//
typedef pair<int,int> pi;
typedef pair<ll,ll> pl; //
typedef pair<db,db> pd; //
//
typedef vector<int> vi;
typedef vector<ll> vl; //
typedef vector<db> vd; //
typedef vector<str> vs; //
typedef vector<pi> vpi;
typedef vector<pl> vpl; //
typedef vector<pd> vpd; //

#define mp make_pair
#define f first
#define s second
#define sz(x) (int)x.size()
#define all(x) begin(x), end(x)
#define rall(x) (x).rbegin(), (x).rend() //
#define rsz resize
#define ins insert //
#define ft front() //
#define bk back()
#define pf push_front //
#define pb push_back
#define eb emplace_back //
#define lb lower_bound //
#define ub upper_bound //

#define FOR(i,a,b) for (int i = (a); i < (b); ++i)
#define F0R(i,a) FOR(i,0,a)
#define ROF(i,a,b) for (int i = (b)-1; i >= (a); --i)
#define R0F(i,a) ROF(i,0,a)
#define trav(a,x) for (auto& a: x)

const int MOD = 1e9+7; // 998244353;
const int MX = 2e5+5; //
const ll INF = 1e18; //
const ld PI = acos((ld)-1);
const int xd[4] = {1,0,-1,0}, yd[4] = {0,1,0,-1}; //
mt19937 rng((uint32_t)chrono::steady_clock::now().time_since_epoch().count()); //
//
template<class T> bool ckmin(T& a, const T& b) {
	return b < a ? a = b, 1 : 0; }
template<class T> bool ckmax(T& a, const T& b) { //
	return a < b ? a = b, 1 : 0; } //
constexpr int pct(int x) { return __builtin_popcount(x); } //
constexpr int bits(int x) { return 31-__builtin_clz(x); } // floor(log2(x)) //
constexpr int cdiv(int a, int b) { return a/b+!(a<0||a%b == 0); } // division of a by b rounded up, assumes b > 0 //
// IGNORE
int fstTrue(function<bool(int)> f, int lo, int hi) {
	hi ++; assert(lo <= hi); // assuming f is increasing
	while (lo < hi) { // find first index such that f is true
		int mid = (lo+hi)/2;
		f(mid) ? hi = mid : lo = mid+1;
	}
	return lo;
}
template<class T> void remDup(vector<T>& v) {
	sort(all(v)); v.erase(unique(all(v)),end(v)); }

int main(){
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	string s, t;
	cin >> s >> t;
	int cnt = 0;
	for(int a = 0; a < s.size(); a++){
		if(s[a] == t[a])
			cnt++;
	}
	cout << s.size() - cnt << endl;
}

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

int a[10005];
int n;

int gettimes(int n) {
	int ans = 0;
	while (n % 2 == 0) {
		n /= 2;
		ans++;
	}
	return ans;
}

int main() {
	cin >> n;
	for (int i = 1; i <= n; i++) cin >> a[i];
	int ans = 0;
	for (int i = 1; i <= n; i++) {
		ans += gettimes(a[i]);
	}
	cout << ans << endl;
}

Measured memory_bytes: 256