akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
#define forr(i, a, b) for(int i = (a); i < (b); i++)
#define rep(i,n) for(int i = 0; i < (n); i++)
#define rrep(i,n) for(int i = 1; i <= (n); i++)
#define ALL(a) (a.begin()),(a.end())
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef pair<ll, ll> LP;
const ll LINF = 1LL<<60;
const int INF = 1001001001;
const int MOD = 1000000007;

/* --------------------------------------------------- */

int main() {
    string s;
    cin >> s;
    int a, b, c, d;
    a = s[0] - '0';
    b = s[1] - '0';
    c = s[2] - '0';
    d = s[3] - '0';

    if (a - b - c - d ==7) printf ("%d-%d-%d-%d=7\n" ,a ,b ,c , d );
    else if (a - b - c + d ==7) printf ("%d-%d-%d+%d=7\n" ,a ,b ,c , d );
    else if (a - b + c - d ==7) printf ("%d-%d+%d-%d=7\n" ,a ,b ,c , d );
    else if (a - b + c + d ==7) printf ("%d-%d+%d+%d=7\n" ,a ,b ,c , d );
    else if (a + b - c - d ==7) printf ("%d+%d-%d-%d=7\n" ,a ,b ,c , d );
    else if (a + b - c + d ==7) printf ("%d+%d-%d+%d=7\n" ,a ,b ,c , d );
    else if (a + b + c - d ==7) printf ("%d+%d+%d-%d=7\n" ,a ,b ,c , d );
    else if (a + b + c + d ==7) printf ("%d+%d+%d+%d=7\n" ,a ,b ,c , d );


    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define exrep(i, a, b) for(long long i = a; i <= b; i++)
#define rep(i,n)for(long long i=0;i<(long long)(n);i++)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
using namespace std;
typedef unsigned long long ull;
typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> P;
typedef vector<ll> vl;
typedef vector<string> vs;
typedef vector<P> vp;
typedef vector<vector<ll> > vvl;
typedef vector<vector<P> > vvp;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
 
const ll MOD=1e9+7;
const ll INF=1e18;
const int MAX=510000;
const double pi=acos(-1);
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};


// dp[keta][just or smaller][cnt] dp[n.size()][0][k],dp[n.size()][1][k]
ll dp[110][4][2]={};
int main(){
  cin.tie(0);
  ios::sync_with_stdio(false); 
  
  string s;
  int K;
  cin >> s >> K;
  
  int n=s.size();
  
  dp[0][0][0]=1;
  rep(i,n){
    rep(j,4){
      rep(k,2){
        int c=s[i]-'0';
        
        rep(d,10){
          int ni=i+1,nj=j,nk=k;
          if(d!=0)nj++;
          if(nj>K)continue;
          if(k==0){
            if(d>c)continue;
            else if(d<c)nk=1;
          } 
          dp[ni][nj][nk]+=dp[i][j][k];
        }
      }
    }
  }
  cout << dp[n][K][1]+dp[n][K][0] << endl;
  return 0;     
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)

const int INF_32 = 1LL << 30;
const int64_t INF_64 = 1LL << 60;
const int MOD = 1000000007;

typedef long long ll;

ll GCD(ll a, ll b) { return b ? GCD(b, a % b) : a; }

ll LCM(ll x, ll y)
{
    return x * y / GCD(x, y);
}

using Graph = vector<vector<int>>;

typedef pair<int, int> P;
int main()
{
    ll a, b;
    cin >> a >> b;
    ll gcd = GCD(a, b);
    ll mx = (ll)sqrt(gcd);
    ll ans = 1;
    for (int i = 2; i <= mx; i++) {
        if (gcd % i == 0)
            ans++;
        while (gcd % i == 0) {
            gcd /= i;
        }
    }
    if (gcd > 1)
        ans++;

    cout << ans << endl;
}

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

using namespace std;

int mx[4]={0,1,0,-1};
int my[4]={1,0,-1,0};

constexpr int inf = 1e9;

int w,h;

int dfs(pair<int,int>now, int depth, vector<vector<int>> &mp){
    if(depth >= 10)return inf;
    int ret=inf;
    for(int i=0;i<4;++i){
        pair<int,int>next=now;
        while(next.first+my[i] < h && next.first+my[i] >=0 && next.second+mx[i] < w && next.second+mx[i] >= 0){
            if(mp[next.first + my[i]][next.second + mx[i]] == 1){
                if(next == now)break;
                mp[next.first + my[i]][next.second + mx[i]] = 0;
                ret = min(ret, dfs(next, depth+1, mp));
                mp[next.first + my[i]][next.second + mx[i]] = 1;
                break;
            }
            if(mp[next.first + my[i]][next.second + mx[i]] == 3){
                return depth + 1;
            }
            next.first += my[i];
            next.second += mx[i];
        }
    }
    return ret;
}

int main(){
    ios::sync_with_stdio(false);
    while(cin>>w>>h,w){
        vector<vector<int>>mp(h,vector<int>(w));
        pair<int,int>start;
        for(int i=0;i<h;++i){
            for(int j=0;j<w;++j){
                cin>>mp[i][j];
                if(mp[i][j]==2)start={i,j};
            }
        }
        int ans=dfs(start,0,mp);
        if(ans==inf)cout<<"-1"<<endl;
        else cout<<ans<<endl;
    }
}



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

typedef long long ll;
const ll INF = (ll)1e18 + 1;
const ll MOD = 1e9 + 7;

// print(x, y, z);
// printVec(va.begin(), va.end());
void print(){ std::cout << std::endl; }
template <typename Head> void print(Head&& head) { std::cout << head << std::endl; }
template <typename Head, typename... Tail> void print(Head&& head, Tail&&... tail)
{
  std::cout << head << " ";
  print(std::forward<Tail>(tail)...); // or print(tail...);
}
template<typename Iterator> void printVec(Iterator begin, Iterator end)
{
  for (Iterator it = begin; it != end; it++) {
    std::cout << "[" << it - begin << "] " << *it << " ";
    if ((it - begin) % 20 == 19 || it == end - 1) { std::cout << std::endl; }
  }
}
template<typename Iterator> void printVecPair(Iterator begin, Iterator end)
{
  for (Iterator it = begin; it != end; it++) {
    std::cout << "[" << it - begin << "] " << it->first << " " << it->second << " ";
    if ((it - begin) % 10 == 9 || it == end - 1) std::cout << std::endl;
  }
}

template<typename T> T bitnum(T x)
{
  T cnt = 1;
  T ret = 0;
  while (x > 0) {
    ret += (x % 2) * cnt;
    x /= 2;
    cnt *= 10;
  }
  return ret;
}

template<typename T> T lminimum(const std::vector< T >& v) {return *std::min_element(v.begin(), v.end());}
template<typename T> T lmaximum(const std::vector< T >& v) {return *std::max_element(v.begin(), v.end());}
template<typename T> void lunique(std::vector< T >& v) {v.erase(std::unique(v.begin(), v.end()), v.end());}
template<typename T> void lsort(std::vector< T >& v) {std::sort(v.begin(), v.end());}
template<typename T> void lgreatersort(std::vector< T >& v) {std::sort(v.begin(), v.end(), std::greater<>());}
template<typename T> bool lnext_permutation(std::vector< T >& v) {return std::next_permutation(v.begin(), v.end());}

int main(int argc, char* argv[])
{
  ll N;
  cin >> N;
  vector<ll> vp(N);
  for (ll i = 0; i < N; ++i) {
    cin >> vp[i];
    vp[i]--;
  }

  ll cnt = 0LL;
  for (ll i = 0; i < N-1; ++i) {
    if (vp[i] == i && vp[i+1] == i+1) {
      std::swap(vp[i], vp[i+1]);
      cnt++;
    }
  }
  for (ll i = 1; i < N; ++i) {
    if (vp[i] == i && vp[i-1] == i-1) {
      std::swap(vp[i], vp[i-1]);
      cnt++;
    }
  }
  if (vp[0] == 0LL) {
    std::swap(vp[0], vp[1]);
    cnt++;
  }
  for (ll i = 1; i < N; ++i) {
    if (vp[i] == i) {
      std::swap(vp[i], vp[i-1]);
      cnt++;
    }
  }

  print(cnt);
  return 0;
}


Measured memory_bytes: 1152
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
 
int main() {
  ll S;
  cin >> S;
  ll v = pow(10, 9);
  ll t = sqrt(S);
  if (t * t == S) {
    cout << "0 0 " << t << " " << "0 0 " << t << "\n";
    return 0;
  }
  t += 1;
  ll e = t * t - S;
  cout << "0 0 " << t << " " << e << " " << "1 " << t << "\n";
  return 0;
}

Measured memory_bytes: 256
import sys
stdin = sys.stdin

sys.setrecursionlimit(10 ** 7)

def li(): return map(int, stdin.readline().split())
def li_(): return map(lambda x: int(x) - 1, stdin.readline().split())
def lf(): return map(float, stdin.readline().split())
def ls(): return stdin.readline().split()
def ns(): return stdin.readline().rstrip()
def lc(): return list(ns())
def ni(): return int(stdin.readline())
def nf(): return float(stdin.readline())


from heapq import heappop, heappush

n, m = li()
works = [[] for _ in range(m+1)]
for _ in range(n):
    ai, bi = li()
    if m-ai >= 0:
        works[m-ai].append(bi)

pque = []
ans = 0
for mi in range(m, -1, -1):
    if works[mi]:
        for wi in works[mi]:
            heappush(pque, -wi)

    if pque:
        ans += -heappop(pque)

print(ans)

Measured memory_bytes: 18432
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using vb=vector<bool>;
using vvb=vector<vb>;
using vd=vector<double>;
using vvd=vector<vd>;
using vi=vector<int>;
using vvi=vector<vi>;
using vl=vector<ll>;
using vvl=vector<vl>;
using pii=pair<int,int>;
using pll=pair<ll,ll>;
using tll=tuple<ll,ll>;
using tlll=tuple<ll,ll,ll>;
using vs=vector<string>;

#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define rep(i,n) range(i,0,n)
#define rrep(i,n) for(int i=(n)-1;i>=0;i--)
#define range(i,a,n) for(int i=(a);i<(n);i++)

#define LINF ((ll)1ll<<60)
#define INF ((int)1<<30)
#define EPS (1e-9)
#define MOD (1000000007ll)
#define fcout(a) cout<<setprecision(a)<<fixed
#define fs first
#define sc second
#define PI 3.1415926535897932384

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

template<class T>bool chmax(T&a,T b){if(a<b){a=b; return true;}return false;}
template<class T>bool chmin(T&a,T b){if(a>b){a=b; return true;}return false;}
template<class S>S acm(vector<S>&a){return accumulate(all(a),S());}
template<class S>S max(vector<S>&a){return *max_element(all(a));}
template<class S>S min(vector<S>&a){return *min_element(all(a));}
void YN(bool b){cout<<(b?"YES":"NO")<<"\n";}
void Yn(bool b){cout<<(b?"Yes":"No")<<"\n";}
void yn(bool b){cout<<(b?"yes":"no")<<"\n";}
int sgn(const double&r){return (r>EPS)-(r<-EPS);} // a>0  : sgn(a)>0
int sgn(const double&a,const double&b){return sgn(a-b);} // b<=c : sgn(b,c)<=0

ll max(int a,ll b){return max((ll)a,b);} ll max(ll a,int b){return max(a,(ll)b);}
template<class T>void puta(T&&t){cout<<t<<"\n";}
template<class H,class...T>void puta(H&&h,T&&...t){cout<<h<<' ';puta(t...);}
template<class S,class T>ostream&operator<<(ostream&os,pair<S,T>p){os<<"["<<p.first<<", "<<p.second<<"]";return os;};
template<class S>auto&operator<<(ostream&os,vector<S>t){bool a=1; for(auto s:t){os<<(a?"":" ")<<s;a=0;} return os;}

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	ll n,k,ans=0;
	string s;
	cin>>n>>k>>s;
	if(n==1){
		cout<<0<<endl;
		return 0;
	}
	if(s[0]=='R'&&s[1]=='R')ans++;
	if(s[n-2]=='L'&&s[n-1]=='L')ans++;
	range(i,1,n-1){
		if(s[i]=='R'&&s[i+1]=='R')ans++;
		if(s[i]=='L'&&s[i-1]=='L')ans++;
	}
	cout<<min(n-1,ans+k*2)<<endl;
}


Measured memory_bytes: 512
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
#include<math.h>
using ll = long long;
using namespace std;
const ll INF = 10000000000000;
//2次元配列 vector<vector<int>> vec(a,vector<int>(b))
int main() {
	int N;
	cin >> N;
	int ichi = N % 10;
	if (ichi == 3) cout << "bon" << endl;
	else if (ichi == 0 || ichi == 1 || ichi == 6 || ichi == 8) cout << "pon" << endl;
	else cout << "hon" << endl;
}

Measured memory_bytes: 3632
#include <iostream>
#include <string>
using namespace std;
int main(void){
    // Your code here!
    int N,i,j,k,ans,count;
    string S;
    bool flag;
    count=0;
    ans=0;
    flag=false;
    cin >> S;
    
    for (i=0;i<S.size();i++){
        
        if(S[i]=='A' || S[i]=='C' || S[i]=='G' || S[i]=='T'){
            
            if (flag==false){
                flag=true;
                count=1;
                if (count>ans){
                    
                    ans=count;
                }
            
            }
            else{
                
                count+=1;
                if (count>ans){
                    ans=count;
                  
                }
            }
        }
        else{
            flag=false;
            count=0;
        }
        
    }
    
    cout << ans<<endl;

    return 0;
    
}


Measured memory_bytes: 3580
#include <bits/stdc++.h>
using namespace std;
 
int main() {
    char c;
    cin >> c;
    
    if(c == 'a' || c == 'i' || c =='u' || c == 'e' || c == 'o') {
        cout << "vowel" << endl;
    }
    else {
        cout << "consonant" << endl;
    }
}
 

Measured memory_bytes: 3672
import math
n = int(input())
ans = 0



for i in range(1, int(n**0.5)+1):
    n2 = n - i

    if n2 % i == 0:
        #print(i, n2 / i)
        #print(n2+i , n//(n2//i), i)

        try:
            if n//(n2//i) == i:
                ans += math.ceil(n2 / i)
        except:
            pass

print(ans)


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

const ll mod = 1e9 + 7;

int main(void){
    int n;
    cin >> n;
    vector<int> a(n);
    ll sum = 0;
    rep(i, n){
        cin >> a[i];
        sum += a[i];
    }
    ll ans = 0;
    rep(i, n){
        sum -= a[i];
        ans = (ans + a[i] * (sum % mod)) % mod; 
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 4040
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define printVec(v) printf("{"); for (const auto& i : v) { std::cout << i << ", "; } printf("}\n");
#define degreeToRadian(deg) (((deg)/360)*2*M_PI)
#define radianTodegree(rad) (((rad)/2/M_PI)*360)
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; }
using namespace std;
using P = pair<int,int>;
using ll = long long;
const ll INF = 1LL<<60;
const int MOD = 1e9 + 7;
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};

struct UnionFind {
    vector<int> a;
    UnionFind(int n) : a(n) {
        for(int i = 0; i < n; i++) a[i] = i;
    }

    int root(int x) { 
        if (a[x] == x) return x;
        return a[x] = root(a[x]);
    }

    void unite(int x, int y) {
        int rx = root(x);
        int ry = root(y);
        if (rx == ry) return;
        a[rx] = ry;
    }

    bool same(int x, int y) {
        int rx = root(x);
        int ry = root(y);
        return rx == ry;
    } 
};


//cin.tie(0);ios::sync_with_stdio(false);
//cout << fixed << setprecision(15) << y << endl;
int main() {
  int n, m;
  cin >> n >> m;
  UnionFind uf(n);
  rep (i, m) {
    int a, b;
    cin >> a >> b;
    --a; --b;    
    uf.unite(a, b);
  }

  set<int>groups;
  rep (i, n) groups.insert(uf.root(i));
  cout << groups.size() -1 << endl;
  return 0;
}


Measured memory_bytes: 7492
#include <iostream>
#include <bits/stdc++.h>
#include <math.h>
using namespace std;
#define IOS ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define ull unsigned long long 
#define int long long 
#define pb push_back 
#define mp make_pair
#define ff first
#define ss second
#define lb lower_bound
#define ub upper_bound
#define endl "\n"
#define Max(x,y,z) max(x,max(y,z))
#define Min(x,y,z) min(x,min(y,z))
#define MAX 1e18
#define PI 3.14159265
const int mod = 1e9 + 7;

int power(int x, int y) 
{ 
   int res = 1;      
  
   
    while (y > 0) 
    { 
       
        if (y & 1) 
            res = (long long)(res*x); 
  
 
        y = y>>1; 
 
        if (x<=100000000)
        x = (long long)(x*x);
 
        //cout<<x<<'\n'; 
    } 
    return res; 
} 

void solve()
{
    int n;
    cin>>n;

    int a[n];
    for(int i=0;i<n;i++){
        cin>>a[i];

    }

    unordered_map<int,int>m;
    int sum=0;
    for(int i=0;i<n;i++){
        m[a[i]]++;
        sum+=a[i];
    }

   
   
    int q;
    cin>>q;

    for(int i=0;i<q;i++){
        int b,c;
        cin>>b>>c;
        sum+=(-b*m[b]  +  c*m[b]);
        cout<<sum<<endl;
        m[c]+=m[b];
        m[b]=0;


    }
    return;
}

    

    

    


int32_t main()
{
    IOS;
    solve();
    return 0;
}

Measured memory_bytes: 7920
i = input()
while i != 0:
	s = 'IO'*i + 'I'
	i = input()
	j = 0
	ss = raw_input()
	c = 0
	while j != i:
		if ss[j:len(s)+j] == s:
			c = c + 1
		j = j + 1
	print c
	i = input()

Measured memory_bytes: 5640
#include<bits/stdc++.h>
#pragma GCC optimize(3)
#define int ll
namespace ZDY{
	#define res register
	#define ri res int
	#define ll long long
	#define db double
	#define sht short
	#define il inline
	#define MB template <class T> il T
	#define Fur(i,x,y) for(int i=x;i<=y;i++)
	#define fur(i,x,y) for(i=x;i<=y;i++)
	#define Fdr(i,x,y) for(int i=x;i>=y;i--)
	#define clr(x,y) memset(x,y,sizeof(x))
	#define cpy(x,y) memcpy(x,y,sizeof(x))
	#define fl(i,x) for(ri i=head[x],to;to=e[i].to,i;i=e[i].nxt)
	#define inf 21474836470
	#define fin(s) freopen(s".in","r",stdin)
	#define fout(s) freopen(s".out","w",stdin)
	#define l2(n) (ceil(log2(n)))
	il char gc(){static char buf[1000000],*s,*t;return s==t?(((t=(s=buf)+fread(buf,1,1000000,stdin))==s)?-1:*s++) : *s++;}
	il int gi(){int x=0;bool f=0;char c=gc();while(c<'0'||'9'<c){if(c=='-')f=!f;c=gc();}while('0'<=c&&c<='9'){x=x*10+c-48;c=gc();}return f?(-x):x;}
	MB ABS(T x){return x>0?x:-x;}
	MB MAX(T x,T y){return x>y?x:y;}
	MB MIN(T x,T y){return x<y?x:y;}
	MB GCD(T x,T y){return y?GCD(y,x%y):x;}
}using namespace ZDY;using namespace std;
#define N 1010
int a[N],n,d=0,s,k,b[N*N],c[N*N];
signed main(){
	n=gi();k=gi();
	Fur(i,1,n)a[i]=gi();
	Fur(i,1,n){
		s=0;
		Fur(j,i,n)b[++d]=(s+=a[j]);
	}
	s=0;
	Fdr(i,40,0){
		int t=0;
		Fur(j,1,d)if(b[j]&(1ll<<i))c[++t]=b[j];
		if(t>=k){
			s+=(1ll<<i);
			d=t;Fur(j,1,d)b[j]=c[j];
		}
	}
	printf("%lld\n",s);
}

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

int main(int argc, char const *argv[])
{
	int n;
	cin>>n;
	int a[n];
	for (int i = 0; i < n; ++i)
	{
		cin>>a[i];
	}
	long long s=0LL;
	for (int i = 0; i < n; ++i)
	{
		s+=(long long)a[i];
	}
	bitset<4000005> dp;
	dp[0]=1;
	for (int i = 0; i < n; ++i)
	{
		dp|=(dp<<a[i]);
	}
	for (long long i = (s+1LL)/2LL; i < 4000005; ++i)
	{
		if (dp[i])
		{
			cout<<i<<endl;
			return 0;
		}
	}
	return 0;
}


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

int main () {
  string S ;
  cin >> S ;
  bool ans = true ;
  if(S[0]!='A') ans = false ;
  int pre = 0 ;
  int C = 0 ;
  for(int i = 0 ; i < S.size() ; i++ ){
    if(islower(S[i])) pre++ ;
  }
  for(int i = 2 ; i < S.size() - 1; i++  ){
    if(S[i]=='C') C++ ;
  }
  if(C!=1 || (S.size() - pre) != 2 ) ans = false ;
  if(ans) cout << "AC" << endl ;
  else cout << "WA" << endl ;
}


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

int main()
{
  int N, K;

  cin >> N >> K;

  vector<int> p(N);

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

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

  cout << accumulate(p.begin(), p.begin()+K, 0) << endl;

  return 0;
}

Measured memory_bytes: 3632
#include <bits/stdc++.h>
#define ll long long
using namespace std;
ll minn(ll x, ll y){
    if(x<y)
        return x;
    return y;
}
ll maxx(ll x, ll y){
    if(x>y)
        return x;
    return y;
}
int a[3009][3009], i, j, par[3009][3009][2],ii,jj;
int main() {
    string s1,s2;
    cin>>s1>>s2;
    for(i=0;i<=(int)s1.size();i++){
        for(j=0;j<=(int)s2.size();j++){
            if(i==0 ||j==0){
                a[i][j] = 0;
            }
            else {
                // a[i][j] = maxx(a[i-1][j-1] + 1, maxx(a[i-1][j], a[i][j-1]) );
                if(a[i-1][j] > a[i][j-1]){
                    a[i][j] = a[i-1][j];
                    par[i][j][0] = par[i-1][j][0];
                    par[i][j][1] = par[i-1][j][1];
                }
                else{
                    a[i][j] = a[i][j-1];
                    par[i][j][0] = par[i][j-1][0];
                    par[i][j][1] = par[i][j-1][1];
                }
                if(s1[i-1] == s2[j-1] && a[i][j] < a[i-1][j-1]+1){
                    a[i][j] = a[i-1][j-1]+1;
                    par[i][j][0] = i;
                    par[i][j][1] = j;
                }
            }
            // cout<<a[i][j]<<par[i][j][0]<<par[i][j][1]<<" ";
        }
        // cout<<endl;
    }
    // cout<<a[s1.size()][s2.size()]<<endl;
    i = par[s1.size()][s2.size()][0];
    j = par[s1.size()][s2.size()][1];
    // cout<<i<<j<<endl;
    stack <char> s;
    while( i!=0){
        // cout<<s1[i-1]<<endl;
        s.push(s1[i-1]);
        ii = par[i-1][j-1][0];
        jj = par[i-1][j-1][1];
        i = ii; j = jj;
        // cout<<endl<<i<<j<<endl;
    }
    // cout<<endl;
    while(!s.empty()){
        cout<<s.top();
        s.pop();
    }
}


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

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

int main()
{
    int H, W;
    cin >> H >> W;
    char S[H][W+3];
    for(int i = 0; i < H; ++i) cin >> S[i];

    int mp[H][W];
    for(int i = 0; i < H; ++i) {
        for(int j = 0; j < W; ++j) {
            if(S[i][j] == '#') mp[i][j] = -1;
            else {
                int cnt = 0;
                for(int k = 0; k < 8; ++k) {
                    int nx = i + dx[k],
                        ny = j + dy[k];
                    if(0 <= nx && nx < H && 0 <= ny && ny < W )
                        if(S[nx][ny] == '#') ++cnt;
                }
                mp[i][j] = cnt;
            }
        }
    }

    for(int i = 0; i < H; ++i) {
        for(int j = 0; j < W; ++j) {
            if(mp[i][j] == -1) cout << '#';
            else cout << mp[i][j];
        }
        cout << endl;
    }
    return 0;
}

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

using namespace std;

int main()
{
    string s;
    cin>>s;
    int n;
    cin>>n;
    vector<string> v;
    for(int i=0; i<s.size(); i++)
    {
        for(int j=1; j<=n; j++)
        {
            if(i+j>s.size())
            {
                continue;
            }

            else
            {
                v.push_back(s.substr(i,j));
            }
        }
    }
    sort(v.begin(),v.end());
    v.erase(unique(v.begin(), v.end()), v.end());
    cout<<v[n-1]<<endl;
    return 0;
}


Measured memory_bytes: 1660
#include <bits/stdc++.h>
#define ff first
#define ss second
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define rep(i, a, b) for(i = a; i < b; i++)
#define per(i, a, b) for(i = a; i >= b; i--)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define trav(x, it) for(auto it = x.begin(); it != x.end(); it++)
#define pr(x) cout << #x << " = " << x << endl
#define endl "\n"
using namespace std;

typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector< pii > vpii;
typedef vector< pll > vpll;
const ld eps = 1e-7;
const ll mod = 1000000007;
const ll N = 998244353;

ll binpow(ll b, ll p){ ll ans = 1; while(p > 0){if(p & 1) ans = (ans * b) % mod; b = (b * b) % mod; p >>= 1;}return ans;}
ll modinv(ll x){return binpow(x, mod - 2);}

signed main()
{
	ios_base::sync_with_stdio(0);
	cin.tie(0);

	int a;
	cin >> a;
	cout << a + a * a + a * a * a << endl;
}

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

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

#define FOR(i, n, m) for (ll(i) = (m); (i) < (n); ++(i))
#define REP(i, n) FOR(i, n, 0)
#define OF64 std::setprecision(10)

const ll MOD = 1000000007;
const ll INF = (ll)1e15;

ll A[100005];
ll S[100005];

int main()
{
    ll N, M;
    cin >> N >> M;
    REP(i, N)
    {
        cin >> A[i];
        A[i] %= M;
    }
    S[0] = 0;
    FOR(i, N + 1, 1)
    {
        S[i] = A[i - 1];
        S[i] += S[i - 1];
        S[i] %= M;
    }

    std::map<ll, ll> map;
    map[0] = 1;
    ll ans = 0;
    FOR(i, N + 1, 1)
    {
        ans += map[S[i]];
        map[S[i]]++;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 5760
#include <bits/stdc++.h>
#define ll long long
#define ALL(x) x.begin(),x.end()
#define MOD (1000000000+7)
using namespace std;
#define PI 3.14159265359
#define tMOD 998244353
#define mkpr(x,y) make_pair(x,y)

int main(){
  string s;
  ll N;
  cin>>N>>s;
  //26

for(ll i=0;i<s.size();i++){
  
  if(s[i]+N>'Z'){
    s[i]=s[i]+N-26;
  }
  else{
     s[i]=s[i]+N;
  }
}
  
cout<<s<<endl;

}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
static const ll MAX = 1000000000000000;
static const int NIL = -1;
using namespace std;

#pragma GCC target("avx2")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")


int main() {

    ll n; cin >> n;
    string s; cin >> s;
    ll ans = 1;
    ll sum = 0;
    vector<ll> c(26,1);
    rep(i,n){
        c[(int)(s[i]-'a')] ++;
    }
    rep(i,26){
        ans = (ans*c[i])%1000000007;
    }
    ans --;
    cout << ans;
    return 0;
}


Measured memory_bytes: 3776
fn get_line() -> String {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().to_string()
}

fn readln<T>() -> T
    where
        T: std::str::FromStr,
        <T as std::str::FromStr>::Err: std::fmt::Debug {
    get_line().parse().unwrap()
}

use std::collections::BinaryHeap;
use std::cmp::Ordering;

#[derive(Clone, Copy, Eq, PartialEq)]
struct E {
    d: usize,
    v: usize,
}

impl Ord for E {
    fn cmp(&self, other: &Self) -> Ordering {
        other.d.cmp(&self.d)
    }
}

impl PartialOrd for E {
    fn partial_cmp(&self, other: &Self) -> Option<Ordering> {
        Some(self.cmp(other))
    }
}

fn main() {
    let k = readln();
    
    let mut xs = vec![vec![]; k];

    for i in 0..k {
        let j = (i + 1) % k;
        let h = (i * 10) % k;

        xs[i].push((j, 1));
        xs[i].push((h, 0));
    }

    let mut q = BinaryHeap::new();
    let mut ds = vec![None; k];
    ds[1] = Some(1);
    q.push(E {
        d: 1,
        v: 1,
    });

    while let Some(e) = q.pop() {
        if let Some(d) = ds[e.v] {
            if d < e.d {
                continue;
            }
        }

        for &(v, w) in &xs[e.v] {
            if let Some(d) = ds[v] {
                if e.d + w < d {
                    ds[v] = Some(e.d + w);
                    q.push(E {
                        d: e.d + w,
                        v: v,
                    });
                }
            }
            else {
                ds[v] = Some(e.d + w);
                q.push(E {
                    d: e.d + w,
                    v: v,
                });
            }
        }
    }

    println!("{}", ds[0].unwrap());
}

Measured memory_bytes: 16636
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N=2e5+5;
int n,a[N];
int main()
{
    string s;
    cin>>s;
    for(int i=0;i<s.size();i++)
        cout<<'x';
    return 0;
    scanf("%d",&n);
    for(int i=1;i<=n;i++) scanf("%d",&a[i]);
    sort(a+1,a+1+n);
    bool flag=true;
    for(int i=2;i<=n;i++)
        if(a[i]==a[i-1]) flag=false;
    printf(flag?"Yes":"No");
}


Measured memory_bytes: 256
import sys, math

def main():
    N = int(input())
    P = tuple(map(int,input().split()))

    sP = sorted(P)

    counter = 0
    for x,y in zip(P, sP):
        if x != y:
            counter += 1

    if counter <= 2:
        print('YES')
    else:
        print('NO')

if __name__=='__main__':
    main()

Measured memory_bytes: 3060
#include <stdio.h>

#define true 1
#define false 0

#define N 8
#define FREE -1
#define NOT_FREE 1

int row[N],col[N],dpos[2*N-1],dneg[2*N-1];

int X[N][N];

void initialize(void){
  int i;
  for(i=0;i<N;i++){
    row[i]=FREE;
    col[i]=FREE;
  }
  for(i=0;i<2*N-1;i++){
    dpos[i]=FREE;
    dneg[i]=FREE;
  }
}

void print(void){
  int i,j;
  for(i=0;i<N;i++){
    for(j=0;j<N;j++){
      if(X[i][j]){
        if(row[i] != j)return;
      }
    }
  }
  for(i=0;i<N;i++){
    for(j=0;j<N;j++){
      if(row[i]==j)printf("Q");//                                               
      else printf(".");//                                                       
      if(j==7)printf("\n");
    }
  }
}


void recursive(int i){
  int j;
  if(i==N){
    print();return;
  }

  for(j=0;j<N;j++){
    if(NOT_FREE == col[j]||
       NOT_FREE == dpos[i+j] ||
       NOT_FREE == dneg[i-j + N-1]
       )continue;

    //(i,j)にクイーンを配置する                                                 

    row[i]=j;
    col[j]=dpos[i+j]=dneg[i-j+N-1]=NOT_FREE;
    //次の行を試す                                                              
    recursive(i+1);
    //(i,j)に配置されているクイーンを取り除く                                   
    row[i]=col[j]=dpos[i+j]=dneg[i-j+N-1]=FREE;
  }
  //クイーンの配置に失敗                                                        
}


int main(){
  int i,j;
  int k;
  int r,c;
  initialize();

  for(i=0;i<N;i++){
    for(j=0;j<N;j++)X[i][j]=false;
  }
    scanf("%d",&k);
    for(i=0;i<k;i++){
      scanf("%d%d",&r,&c);
      X[r][c]=true;


  }
  recursive(0);

  return 0;

}



Measured memory_bytes: 2084
#include <iostream>

using namespace std;

int main(){
	int N;
	int number;
	double ans;

	cin >> N;

	if(N % 2 == 0){
		number = N / 2;
		ans = (double)number / N;
		cout << ans <<endl;
	}else{
		number = N / 2 + 1;
		ans = (double)number / N;
		cout << ans << endl;
	}
	return 0;
}


Measured memory_bytes: 256
fun main(args: Array<String>) {
    val n = readLine()!!.toInt()
    val p = readLine()!!.split(' ').map { it.toInt() }

    var ans = 0
    var tmp = Int.MAX_VALUE
    repeat(n) { i ->
        if (tmp > p[i]) {
            ans++
            tmp = p[i]
        }
    }
    println(ans)
}


Measured memory_bytes: 61968
#include<bits/stdc++.h>
using namespace std;
using ll=long long;
constexpr ll mod=1e9+7;

int main()
{
  ll a,b,n;
  cin>>a>>b>>n;
  if(n<b-1)
    cout<<(a*n)/b<<endl;
  else
    cout<<(a*(b-1))/b<<endl;
}

Measured memory_bytes: 3572
#include<bits/stdc++.h>
#define rep(i, n) for(int i=0;i<n;i++)
#define repb(i, a, b) for(int i=a;i<b;i++)

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

const int INF = 1<<30;

int main(){
  int a, b;cin>>a>>b;
  if(a>=b)cout<<string(a, char('0'+b))<<endl;
  else cout<<string(b, char('0'+a))<<endl;
  return 0;
}



Measured memory_bytes: 256
# https://beta.atcoder.jp/contests/abc058/tasks/abc058_b


def solve():
    o = input()
    e = input()

    for l, r in zip(o, e):
        print('{}{}'.format(l, r), end="")

    if len(o) != len(e):
        print(o[-1])
    else:
        print()


if __name__ == '__main__':
    solve()


Measured memory_bytes: 2940
k, n = map(int, input().split())
a = list(map(int, input().split()))
 
max_dist = 0
for i in range(n):
    nxt = (i+1) % n
    distance = a[nxt] - a[i]
    if distance < 0:
        distance += k
    max_dist = max(max_dist, distance)
 
print(k-max_dist)

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

int main() {
  int A,B,C,D;
  cin >> A >> B >> C >> D;
  if (A+B == C+D){
    cout << "Balanced" << endl;
  }else if (A+B > C+D){
    cout << "Left" << endl;
  }else{
    cout << "Right" << endl;
  }
}

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

public class AtCoderA
{
    static void Main()
    {
        var sc = new Scanner();

        long n = sc.NextLong();
        long[] aa = sc.LongArray();

        long sum = aa.Sum();

        long answer = 0;
        long min = long.MaxValue;

        for (int i = 0; i < n; i++)
        {
            long diff = Math.Abs(sum - aa[i] * n);
            if (diff < min)
            {
                min = diff;
                answer = i;
            }
        }

        Console.WriteLine(answer);
    }

    class Scanner
    {
        private string[] _line;
        private int _index;
        private const char Separator = ' ';

        public Scanner()
        {
            _line = new string[0];
            _index = 0;
        }

        public string Next()
        {
            while (_index >= _line.Length)
            {
                _line = Console.ReadLine().Split(Separator);
                _index = 0;
            }

            return _line[_index++];
        }

        public int NextInt() => int.Parse(Next());
        public long NextLong() => long.Parse(Next());
        public double NextDouble() => double.Parse(Next());
        public decimal NextDecimal() => decimal.Parse(Next());
        public char NextChar() => Next()[0];
        public char[] NextCharArray() => Next().ToCharArray();

        public string[] Array()
        {
            _line = Console.ReadLine().Split(Separator);
            _index = _line.Length;
            return _line;
        }

        public int[] IntArray() => Array().Select(int.Parse).ToArray();
        public long[] LongArray() => Array().Select(long.Parse).ToArray();
        public double[] DoubleArray() => Array().Select(double.Parse).ToArray();
        public decimal[] DecimalArray() => Array().Select(decimal.Parse).ToArray();
    }
}


Measured memory_bytes: 27600
import fractions
 
PRIME = 10 ** 9 + 7
n = int(input())
a = list(map(int, input().split()))
 
if n == 1:
  print(1)
else:
  lcm = a[0]
  for i in range(1, n):
    lcm = lcm * a[i] // int(fractions.gcd(lcm, a[i]))
  
  ans = 0
  for i in range(n):
    ans += lcm // a[i]
  
  print(ans % PRIME)

Measured memory_bytes: 6112
#include<stdio.h>
int main(){
    int n,m,x,a[100];
    int cnt1=0,cnt2=0;
    scanf("%d%d%d",&n,&m,&x);
    for(int i=0;i<m;i++){
        scanf("%d",&a[i]);
        if(a[i]<x) cnt1++;
        else if(a[i]>x) cnt2++;
    }
    if(cnt1>=cnt2) printf("%d\n",cnt2);
    else printf("%d\n",cnt1);
    return 0;
}

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

#define FOR(i,a,b) for (int i = (a); i < (b); ++i)
#define FORD(i,b,a) for (int i = (int)(b) - 1; i >= a; --i)
#define REP(i,N) FOR(i,0,N)
#define st first
#define nd second
#define pb push_back

typedef pair<int, int> PII;
typedef long long LL;

int main() {
  vector<unsigned int> v(3);
  REP(i,3) scanf("%u", &v[i]);
  int moves = 0;
  unsigned int sm = v[0] + v[1] + v[2];
  while (true) {
    sort(v.begin(), v.end());
    REP(i,3) if (v[i]%2) {
      printf("%d\n", moves);
      return 0;
    }
    if (v[0] == v[2]) {
      printf("-1\n");
      return 0;
    }
    ++moves;
    REP(i,3) v[i] = (sm - v[i]) / 2;
  }    
}


Measured memory_bytes: 256
N, K = gets.split.map(&:to_i)
M = N - K

def fact(num)
  if num < 1
    return 1
  else
    ans = 1
    num.times do |n|
      ans *= n+1
    end
    return ans
  end
end

def comb(n, i)
  fact(n) / (fact(i) * fact(n-i))
end

mod_num = (10**9)+7

(1..K).each do |k|
  if k > M+1
    p 0
  else
    hoge = comb(K-1, k-1)
    fuga = comb(M+1, k)
    p hoge * fuga % mod_num
  end
end


Measured memory_bytes: 5152
import java.util.*;
import java.math.BigDecimal;

public class Main{
    void run(){
        Scanner sc = new Scanner(System.in);
        while(true){
            int n = sc.nextInt();
            int m = sc.nextInt();
            if(n == 0 && m == 0){
                break;
            }
            double[][] g = new double[n][n];
            for(int i = 0; i < n; i++){
                for(int ii = 0; ii < n; ii++){
                    g[i][ii] = sc.nextDouble();
                }
            }

            double[][] dp = new double[m][n];
            Arrays.fill(dp[0], 1.);
            for(int i = 1; i < m; i++){
                for(int cur = 0; cur < n; cur++){
                    for(int pre = 0; pre < n; pre++){
                        dp[i][cur] = Math.max(dp[i][cur], dp[i-1][pre] * g[cur][pre]);
                    }
                }
            }
            /*
            for(double[] d: dp){
                System.out.println(Arrays.toString(d));
            }
            */
            double max = 0;
            for(double d: dp[m-1]){
                    max = Math.max(max, d);
            }
            System.out.println(new BigDecimal(max).setScale(2, BigDecimal.ROUND_HALF_UP));

        }
    }

    public static void main(String[] args){
        new Main().run();
    }
}

Measured memory_bytes: 72220
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0; i < (n) ; i++)
#define rrep(i,n) for(int i = n-1; i >= 0 ; i--)
typedef long long ll;
constexpr auto INFI = 2147483647;
const ll INFL = 9223372036854775807;

int main(){

  double a, b, h, m;
  cin >> a >> b >> h >> m;

  double l_deg = 6 * m;
  double s_deg = 30 * (h + m / 60);
  double deg = abs(l_deg - s_deg);
  deg = deg / 360 * 2 * M_PI;
  double ans = sqrt(a*a + b*b - 2 * cos(deg) * a * b);
  cout << setprecision(11) << ans << endl;
  return 0;
}

Measured memory_bytes: 4216
#include <bits/stdc++.h>
using namespace std;
int main()
{
    string s;
    cin >> s;
    int si[s.size() / 2];
    si[0] = (s[0] - '0') * 10 + (s[1] - '0');
    si[1] = (s[2] - '0') * 10 + (s[3] - '0');
    if((si[0] >= 13 || si[0] == 0) && (si[1] >= 13 || si[1] == 0))
    {
        cout << "NA";
    }
    else if((si[0] >= 1 && si[0] <= 12) && (si[1] >= 1 && si[1] <= 12))
    {
        cout << "AMBIGUOUS";
    }
    else if(si[1] >= 13 || si[1] == 0)
    {
        cout << "MMYY";
    }
    else
    {
        cout << "YYMM";
    }
    
    return 0;
}

Measured memory_bytes: 256
/* 0056*/
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;

std::vector<int> p;
bool s[50001];
int main(void){
	for(int i=0;i<50001;i++)s[i]=true;
	s[0]=s[1]=false;
	for(int i=2;i<50001;i++){
		if(s[i]){
			p.push_back(i);
			for(int j=i*2;j<50001;s[j]=false,j+=i);
		}
	}
	int n;
	while(cin>>n,n){
		int c=0;
		for(int i=0;p[i]<=n/2;i++){
			int a=p[i];
			if(binary_search(p.begin(),p.end(),n-a))c++;
		}
		cout<<c<<endl;
	}
	return 0;
}

Measured memory_bytes: 3216
#include <stdio.h>
int main()
{
    int x, y;
    scanf("%d %d", &x, &y);
    if ((4 * x + y) % 2 == 0 && (2 * x + y) % 2 == 0 && 4 * x - y >= 0 && -2 * x + y >= 0)
    {
        printf("Yes");
    }
    else
    {
        printf("No");
    }
    return 0;
}

Measured memory_bytes: 1732
#include <iostream>
#include <map>

int main(void){
    std::map<char, char> acgt;
    char b;

    acgt['A'] = 'T';
    acgt['C'] = 'G';
    acgt['G'] = 'C';
    acgt['T'] = 'A';

    std::cin >> b;
    std::cout << acgt[b] << '\n';

    return 0;
}

Measured memory_bytes: 256
program main
  implicit none
  integer(8) i, N, lim, m(100), t, ans, exp, level, N1
  !integer(8),allocatable:: A(:,:)
  read(*, *) N
  N1 = N
  lim = 1000000
  !allocate(A(N,2)
  m = 0
  t = 0
  do i = 1,100
    m(i) = t+i
    t = m(i)
  end do
  !read(*, *) (L(i), i = 1,N)
  t = 2
  exp = 0
  level = 0
  ans = 0
  if (N == 1) then
    ans = 0
  else
    do
      if (mod(N,t) == 0) then
        exp = exp + 1
        N = N/t
        if (exp == m(level+1)) then
          level = level + 1
        end if
      else
        ans = ans + level
        exp = 0
        level = 0
        t = t+1
      endif
      if (t > lim) then
        if (N > 1) then
          ans = ans + 1
        endif
        exit
      endif
    end do
  endif
  write(*, *) ans
end program main

Measured memory_bytes: 2836
n, p = map(int, input().split())
if n == 1:
    print(p)
    exit()
l = []
i = 2
while p > 1:
    if p % i == 0:
        p //= i
        l.append(i)
    else:
        i += 1
        if i > p ** (1/2):
            break
        
ans = 1

for i in set(l):
    m = l.count(i)
    if n <= m:
        ans *= i ** (m // n)

print(ans)

Measured memory_bytes: 39920
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for (int i=(a);i<(b);i++)
#define FORR(i,a,b) for (int i=(a);i>=(b);i--)
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define pcnt __builtin_popcount
#define sz(x) (int)(x).size()
#define maxs(x,y) x=max(x,y)
#define mins(x,y) x=min(x,y)
#define show(x) cout<<#x<<" = "<<x<<endl;
#define all(a) (a.begin()),(a.end())
#define each(it,c) for(__typeof((c).begin()) it=(c).begin();it!=(c).end();it++)
#define perm(c) sort(all(c));for(bool c##p=1;c##p;c##p=next_permutation(all(c)))
#define bit(n) (1LL<<(n))
#define randInt(l,r) (uniform_int_distribution<ll>(l,r)(rnd))
#define randDouble(l,r) (uniform_real_distribution<double>(l,r)(rnd))

typedef long long ll;
typedef __int128_t lll;
template <class T> using V = vector<T>;
template <class T> using VV = V<V<T>>;
template<typename A,size_t N,typename T>void Fill(A (&array)[N],const T&v){fill((T*)array,(T*)(array+N),v);}
lll gcd(lll a,lll b,lll &x,lll &y){if(!b){x=1;y=0;return a;}lll d=gcd(b,a%b,y,x);y-=a/b*x;return d;}
ll gcd(ll a,ll b){lll x=0,y=0;return gcd(a,b,x,y);}
ll modPow(lll a,lll n,ll m){if(!a)return a;lll p=1;for(;n>0;n>>=1,a=a*a%m)if(n&1)p=p*a%m;return(ll)p;}
bool isPrime(ll n){if(n<2||n%2==0)return n==2;lll t=n-1,d=t/(t&-t);for(lll a:{2,325,9375,28178,450775,9780504,1795265022})if(a%n){for(t=d,a=modPow(a,t,n);t!=n-1&&a!=1&&a!=n-1;a=a*a%n,t=t*2%n);if(a!=n-1&&t%2==0)return 0;}return 1;}
void dout(double d){printf("%.12f\n",d);}
const int IINF = 1e9+6;
const ll LINF = 1e18;
const int MOD = 1e9+7;
const double PI = acos(-1);
const double EPS = 1e-10;
static random_device rd;
static mt19937 rnd(rd());

const int N = 2e5;

struct Seg{
  typedef ll T;
  const T e = 0;
  inline T m(const T&a, const T&b){return max(a, b);}
//###################################################
  typedef int i;i n;vector<T> d;
  T q(i a,i b,i k,i l,i r){return (r<=a||b<=l)?e:(a<=l&&r<=b)?d[k]:m(q(a,b,k*2+1,l,(l+r)/2),q(a,b,k*2+2,(l+r)/2,r));}

  void init(i m){n=1<<(32-__builtin_clz(m-1));d.resize(2*n-1);for(int i=0;i<2*n-1;i++)d[i]=e;}
  void init(vector<T>&v){init(v.size());for(int j=0;j<v.size();j++)d[j+n-1]=v[j];for(int k=n-2;k>=0;k--)d[k]=m(d[k*2+1],d[k*2+2]);}
  void update(i k,T a){k+=n-1;d[k]=a;while(k>0){k=(k-1)/2;d[k]=m(d[k*2+1],d[k*2+2]);}}
  T query(i a,i b){return q(a,b,0,0,n);}
  T get(i a){return d[n+a-1];}
} seg;
int n, h[N];
ll a[N];

main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  cin >> n;
  seg.init(n+1);
  FOR(i, 0, n) cin >> h[i];
  FOR(i, 0, n) cin >> a[i];
  ll ans = 0;
  FOR(i, 0, n){
    ll t = seg.query(0, h[i]) + a[i];
    maxs(ans, t);
    seg.update(h[i], t);
  }
  cout << ans << endl;
}

Measured memory_bytes: 6656
package main

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

//=====I/O=====

var (
	sc = bufio.NewScanner(os.Stdin)
	wr = bufio.NewWriter(os.Stdout)
)

func scanInt() int {
	sc.Scan()
	a,_ := strconv.Atoi(sc.Text())
	return a
}

func scanInt64() int64 {
	sc.Scan()
	a,_ := strconv.ParseInt(sc.Text(),10,64)
	return a
}

func scanInts(n int) []int {
	res := make([]int, n)
	for i := 0; i < n; i++ { res[i] = scanInt() }
	return res
}

func scanText() string {
	sc.Scan()
	return sc.Text()
}

func printInts(a ...int) {
	for i, e := range a {
		fmt.Fprint(wr, e)
		if i != len(a)-1 { fmt.Fprint(wr, " ") }
	}
	fmt.Fprintln(wr)
	wr.Flush()
}

//=====main=====

func main() {
	sc.Split(bufio.ScanWords)

	n, m := scanInt(), scanInt()

	tree := make([][]int, n)

	for i := 0; i < m; i++ {
		a,b := scanInt()-1, scanInt()-1
		tree[a] = append(tree[a], b)
		tree[b] = append(tree[b], a)
	}

	f := true

	for i := 0; i < n; i++ {
		if len(tree[i])%2 != 0 {
			f = false
		}
	}

	if f {
		fmt.Println("YES")
	} else {
		fmt.Println("NO")
	}
}


Measured memory_bytes: 6912
import numpy as np
A, B = input().split()
A = np.array(A).astype(np.int64)

n = len(B)
Bs = []
for i in range(n):
  if i !=  1:
    Bs.append(np.array(B[i]).astype(np.int64))
Bs

if n == 4:
  sums = A*Bs[0]*100 + A*Bs[1]*10 + A*Bs[2]
elif n ==3:
  sums = A*Bs[0]*100 + A*Bs[1]*10
else:
  sums = A*Bs[0]*100

print(sums//100)

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

using namespace std;

int main()
{
    int L,R,d,sum=0,x;
    cin>>L>>R>>d;
    x=d;
    while(d<=R)
    {
        if(d>=L)
            sum++;
        d+=x;
    }
    cout <<sum<< endl;
    return 0;
}


Measured memory_bytes: 3596
#include <stdio.h>
#include <iostream>
#include <algorithm>
#include <bits/stdc++.h>

using namespace std;
using ll = long long;
ll gcd(ll a, ll b);
int main(){
cin.tie(0);
ll n,d,x,y,result=0;
  
  cin >>n>>d;
  for(ll i=1;i<=n;i++){
   cin>>x>>y;
   if(x*x+y*y<=d*d)result++;
  }
cout<<result;
return 0;
}






ll gcd(ll a, ll b){

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

}

Measured memory_bytes: 3632
#define _USE_MATH_DEFINES
#include<iostream>
#include<string>
#include<queue>
#include<cmath>
#include<map>
#include<set>
#include<list>
#include<iomanip>
#include<vector>
#include<random>
#include<functional>
#include<algorithm>
#include<stack>
#include<cstdio>
#include<bitset>
#include<unordered_map>
#include<climits>
#include<fstream>
using namespace std;
///////////////////library zone!!!!!!!!!!!!!!!!!!!!!!!!!!!!
typedef long long ll;
typedef long double ld;
#define all(a) (a).begin(),(a).end()
#define EPS (1e-5)
#define bit(n,k) ((n>>k)&1)
const ll Mod = 1000000007;
const ll mod = 998244353;
struct H {
	ll x, y;
	bool operator<(const H &b) const {
		if (x != b.x) return x < b.x;
		return y < b.y;
	}
	bool operator>(const H &b) const {
		if (x != b.x) return x > b.x;
		return y > b.y;
	}
	bool operator==(const H &b) const { return x == b.x&&y == b.y; }
	bool operator!=(const H &b) const { return (*this) != b; }
};
struct P {
	ll pos, cost;
	bool operator<(const P &b) const { return cost < b.cost; }
	bool operator>(const P &b) const { return cost > b.cost; }
};
struct B {
	ll to, cost;
};
struct E {
	ll from, to, cost;
	bool operator<(const E &b) const { return cost < b.cost; }
	bool operator>(const E &b) const { return cost > b.cost; }
};
template<typename T, typename U>
void chmin(T &a, U b) {
	if (a > b) a = b;
}
template<typename T, typename U>
void chmax(T &a, U b) {
	if (a < b) a = b;
}
template<typename T>
T max_0(T a) {
	if (a < 0) return 0;
	return a;
}
template<typename T>
T min_0(T a) {
	if (a > 0) return 0;
	return a;
}
ll read() {
	ll u;
	ll k = scanf("%lld", &u);
	return u;
}
ll gcd(ll i, ll j) {
	if (i > j) swap(i, j);
	if (i == 0) return j;
	return gcd(j%i, i);
}
ll mod_pow(ll x, ll n, ll p) {
	ll res = 1;
	while (n > 0) {
		if (n & 1) res = res * x % p;
		x = x * x % p;
		n >>= 1;
	}
	return res;
}//x^n%p
vector<string>split(string s, char c = ' ') {
	vector<string>vec;
	string h = "";
	for (int i = 0; i < s.size();) {
		int j = i;
		while (j < s.size() && s[j] != ' ') {
			h += s[j++];
		}
		if (h.size() > 0) vec.push_back(h);
		h = "";
		i = j + 1;
	}
	return vec;
}
const ll Inf = 3023372036854775807;
const int inf = 1500000000;
#define int long long
//----------------------------------------------------
int a[5];
bool b[5];
int solve(int t,int k) {
	if (k == 5) return t;
	int ans = Inf;
	t = ceil(t / 10.) * 10;
	for (int i = 0; i < 5; i++) {
		if (!b[i]) {
			b[i] = 1;
			ans = min(ans, solve(t + a[i], k + 1));
			b[i] = 0;
		}
	}
	return ans;
}
signed main() {
	cin >> a[0] >> a[1] >> a[2] >> a[3] >> a[4];
	int ans = Inf;
	cout << solve(0, 0) << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
typedef vector<vector<int>> Matrix;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define ALL(x) (x).begin(), (x).end()
static const int INF = 2000000000;


int main(){
  int a, b, h, m;
  cin >> a >> b >> h >> m;
  const double pi = 3.1415926535898;
  double rad = (double)(60*h + m - 12*m) / 720 * 2 * pi;
  double cosine = cos(rad);
  double c = (double)a*a + b*b - 2*a*b*cosine;
  double ans = sqrt(c);
  cout << fixed << setprecision(10) << ans << endl;
} 

Measured memory_bytes: 4172
#include <stdio.h>
#define compexch(A,B) if(A<B){ int t; t=A, A=B, B=t; }

int main(void){
	int i, j, a[5];
	scanf("%d %d %d %d %d",&a[0],&a[1],&a[2],&a[3],&a[4]);
	for(i=0; i<5; i++) for(j=i; j>0; j--) compexch(a[j-1], a[j]);
	printf("%d %d %d %d %d\n",a[0],a[1],a[2],a[3],a[4]);
	return 0;
}

Measured memory_bytes: 0