akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
#define lowbit(x) x&(-x)
using namespace std;
 
typedef long long ll;
 
const int maxn=1005;
 


int main()
{
    int a,b,c,k;
    cin>>a>>b>>c>>k;
    int ans=min(k,a);
    k-=min(k,a);
    k-=min(k,b);
    ans-=min(k,c);
    k-=min(k,c);
    cout<<ans<<endl;
}

Measured memory_bytes: 3636
#include<bits/stdc++.h>
using namespace std;
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define ll long long int
#define ff first
#define ss second
#define mp make_pair
#define pb push_back
#define pii pair<int , int>
#define pll pair<long long int,long long int>
#define mod 1000000007
#define inf 1e18+7
#define eps 0.00001
#define endl '\n'
int main()
{
    fastio;
    
    ll a,b,x;
    cin>>a>>b>>x;
    ll c=a+b;
    if(x<=c && x>=a)
        cout<<"YES";
    else
        cout<<"NO";   
}

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

using namespace std;

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

int main() {
  int n, q, c = (int)1e9+7;
  cin >> n >> q;
  tuple<int, int> a[2*n+q];
  rep(i,n) {
    int s, t, x;
    cin >> s >> t >> x;
    a[2*i]   = tuple<int, int> (s - x, x);
    a[2*i+1] = tuple<int, int> (t - x, x);
  }
  rep(i,q) {
    int d;
    cin >> d;
    a[2*n+i] = tuple<int, int> (d, c);
  }
  
  sort(a, a+2*n+q);
  
  int r[q], j = 0;
  set<int> s = {c};
  rep(i,2*n+q) {
    int k = get<1>(a[i]);
    if(k == c) {
      r[j] = *s.begin();
      if(r[j] == c) r[j] = -1;
      j++;
    } else {
      if(s.count(k)) s.erase(k);
      else s.insert(k);
    }
  }
  
  rep(i,q) cout << r[i] << endl;
  return 0;
}

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

using namespace std;

#define DIM 3007
#define INF 1000000000

long long a[DIM], F[DIM][DIM], mid[DIM][DIM], sum[DIM];
int n,m,k,i,j,res;
long double f[DIM][DIM], p[DIM];
long double pa,pb;

int main() {
    //freopen("input.txt", "r", stdin);
    cin >> n;
    for(int i = 1; i <= n; i++) cin >> p[i];
    f[0][0] = 1;
    for(int i = 1; i <= n; i++) {
        f[i][0] = f[i-1][0] * (1-p[i]);

        for(int j = 1; j <= i; j++) {
            pa = f[i-1][j-1] * p[i];
            pb = f[i-1][j] * (1-p[i]);
            f[i][j] = pa + pb;
        }
    }
    long double r = 0;
    for(int i = 0; i <= n; i++)
        if(i > n/2) r += f[n][i];
    cout<<fixed<<setprecision(20)<<r<<endl;

    return 0;
}


Measured memory_bytes: 141824
#include<iostream>
#include<vector>
#include<string>
#include<array>
#include<cmath>
#include<algorithm>
#include<map>
#include<set>

int main()
{
long long int a, b, c;
std::cin >> a >> b >> c;
long long int count = 0;
long long int a1, a2, b1, b2, c1, c2;
long long int a3 = 0;
long long int b3 = 0;
long long int c3 = 0;
a1 = (b + c) / 2;
b1 = (a + c) / 2;
c1 = (a + b) / 2;
a2 = (b1 + c1) / 2;
b2 = (a1 + c1) / 2;
c2 = (a1 + b1) / 2;
count = 2;
if(a%2 + b%2 + c%2 != 0){
    std::cout << count - 2 << std::endl;
} else if(a1%2 + b1%2 + c1%2 != 0){
    std::cout << count - 1 << std::endl;
} else if(a2%2 + b2%2 + c2%2 != 0) {
    std::cout << count<< std::endl;
} else {
    while(a3 % 2 + b3 % 2 + c3 % 2 == 0){
        count++;
        a3 = (a2 + a1) / 2;
        b3 = (b2 + b1) / 2;
        c3 = (c2 + c1) / 2;
        if((a1 == a2 && a3 == a2) && (b1 == b2 && b3 == b2) && (c1 == c2 && c3 == c2)){
            count = -1;
            break;
        }
        a1 = a2;
        a2 = a3;
        b1 = b2;
        b2 = b3;
        c1 = c2;
        c2 = c3;
    }
    std::cout << count << std::endl;
}
return 0;
}

Measured memory_bytes: 256
s = input().strip()
a = (s[0] == "A")
c_cnt = 0
for e in s[2:(-1)]:
    if e == "C":
        c_cnt += 1
if a and c_cnt == 1 and s[1:].replace("C", "").islower():
    print("AC")
else:
    print("WA")


Measured memory_bytes: 38256
#include <cstdio>
#include <cstdlib>
#include <cassert>
#include <algorithm>
#include <functional>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
#include <bitset>
#define repi(i,a,b) for(ll i=(a);i<(b);++i)
#define rep(i,a) repi(i,0,a)
#define repdi(i,a,b) for(ll i=(a)-1;i>=(b);--i)
#define repd(i,a) repdi(i,a,0)
#define itr(it,a) for( auto it = (a).begin(); it != (a).end(); ++it )
#define all(a) (a).begin(), (a).end()
#define rall(a) (a).rbegin(), (a).rend()

using ll = long long;
using P = std::pair<ll, ll>;

constexpr ll INF = 1ll<<60;

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; }

template<class S, class T>
std::ostream& operator<< ( std::ostream& out, const std::pair<S,T>& a )
{ std::cout << '(' << a.first << ", " << a.second << ')'; return out; }

template<class T>
std::ostream &operator<< ( std::ostream& out, const std::vector<T>& a )
{ std::cout << '['; rep( i, a.size() ){ std::cout << a[i]; if( i != a.size()-1 ) std::cout << ", "; } std::cout << ']'; return out; }

ll N, M;
ll V[(1<<18)+10], W[(1<<18)+10];
ll Q;
ll dp[(1<<9)+10][100010];

void dfs1( ll v, ll p = 0, ll dep = 0 ) {
  if( dep >= (N+1)/2 )
    return;

  rep( j, 100001 ) {
    chmax( dp[v][j], dp[p][j] );

    if( j-W[v] >= 0 )
      chmax( dp[v][j], dp[p][j-W[v]]+V[v] );
  }

  for( auto u : { 2*v, 2*v+1 } ) {
    dfs1( u, v, dep+1 );
  }

  return;
}

ll depth[(1<<18)+1];
std::map<ll, std::vector<ll> > mp;
std::map<ll, ll> par;

int main() {
  std::cin >> M;

  ll two = 1, cnt = -1;

  repi( i, 1, M+1 ) {
    if( i == two )
      two <<= 1, ++cnt;

    depth[i] = cnt;
  }

  N = depth[M];

  rep( i, M )
    std::cin >> V[i+1] >> W[i+1];

  dfs1( 1 );

  std::cin >> Q;

  rep( q, Q ) {
    ll v, L;
    std::cin >> v >> L;

    std::vector<ll> vs;

    while( depth[v] >= (N+1)/2 && v > 0 ) {
      vs.emplace_back( v );
      v >>= 1;
    }

    ll ans = 0;

    rep( bit, 1<<(vs.size()) ) {
      ll wsum = 0, vsum = 0;

      rep( j, vs.size() ) if( bit>>j&1 ) {
        wsum += W[vs[j]];
        vsum += V[vs[j]];
      }

      if( wsum <= L ) {
        chmax( ans, vsum+dp[v][L-wsum] );
      }
    }

    std::cout << ans << std::endl;
  }

  return 0;
}

Measured memory_bytes: 408220
#include <bits/stdc++.h>
#include <atcoder/all>
using namespace std;
using namespace atcoder;
typedef long long int ll;
#define FOR(i,l,r) for(i=l;i<r;i++)
#define REP(i,n) FOR(i,0,n)
#define ALL(x) x.begin(),x.end()
#define P pair<ll,ll>
#define F first
#define S second
signed main(){
  ll N,i,j,x,y;cin>>N;vector<P>D(N),X(N);dsu d(N);
  REP(i,N){cin>>x>>y;D.at(x-1)=P(y,i);}i=0;
  while(i<N){
    ll M=D.at(i).F,j=i;
    while(i<N&&N-j-M!=i-j){M=min(M,D.at(++i).F);d.merge(D.at(i).S,D.at(j).S);}
    i++;
  }
  REP(i,N)cout<<d.size(i)<<endl;
  return 0;
}

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

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

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

  int t = 1900*m + 100*(n-m);
  cout << t * pow(2,m);
}

Measured memory_bytes: 4036
#include<bits/stdc++.h>
using namespace std;
#define MAX_V 1000
#define MAX_E 2000
#define INF 1e9
struct edge {
  int from, to, cost;
};
int V, E, d[MAX_V];
edge es[MAX_E];
bool find_negative_loop(int s)
{
    int cnt = 0;
    for (int i = 0; i < V; i++) {
	d[i] = INF;
    }
    d[s] = 0;
    while (true) {
	bool update = false;
	cnt++;
	for (int i = 0; i < E; i++) {
	    edge e = es[i];
	    if (d[e.from] != INF && d[e.to] > d[e.from] + e.cost) {
		d[e.to] = d[e.from] + e.cost;
		if (cnt == V) {
                    return true;
                }
		update = true;
	    }
	}
	if (!update) {
            break;
        }
    }
    return false;
}

int main()
{
    int r;
    cin >> V >> E >> r;
    for (int i = 0; i < E; i++) {
	cin >> es[i].from >> es[i].to >> es[i].cost;
    }
    if (find_negative_loop(r)) {
	cout << "NEGATIVE CYCLE" << endl;
    } else {
	for (int i = 0; i < V; i++) {
	    if (d[i] == INF) {
		cout << "INF" << endl;
	    } else {
		cout << d[i] << endl;
	    }
	}
    }
    return 0;
}

Measured memory_bytes: 3124
#include <bits/stdc++.h>
using namespace std;
const int N=1e6+7,M=1e9;

#define C getchar()-48
int read()
{
  int s=0,t=1,k=C;
  for (;k<0||9<k;k=C) if (k==-3) t=-1;
  for (;0<=k&&k<=9;k=C) s=(s<<1)+(s<<3)+k;
  return s*t;
}

  int n,k;
  int a[N];
void in()
{
  cin>>n>>k;
  for (int i=0;++i<=n;)
    a[read()]=i;
}

  struct tr
    {
      int l,r,m;
    }tr[N+N];
#define ls(k) k*2
#define rs(k) k*2+1
void bui(int k,int l,int r)
{
  tr[k].l=l;tr[k].r=r;
  tr[k].m=M;
  if (l==r) return;
  int m=l+r>>1;
  bui(ls(k),l,m);
	bui(rs(k),m+1,r);
}

void add(int k,int p,int v)
{
  tr[k].m=v;
  if (tr[k].l==tr[k].r)
    return;
  if (tr[ls(k)].r<p)
    add(rs(k),p,v);
  else
    add(ls(k),p,v);
}

int que(int k,int l,int r)
{
  if (tr[k].r<l||r<tr[k].l)
    return M;
  if (l<=tr[k].l&&tr[k].r<=r)
    return tr[k].m;
  int x=que(ls(k),l,r),
      y=que(rs(k),l,r);
  return min(x,y);
}

  int t;
  int h[N],d[N];
  struct hh
    {
      int n,r;
    }e[N];
void ins(int x,int y)
{
  e[++t]=(hh){h[x],y};
	h[x]=t;++d[y];
}

  set<int> S;
  int A[N];
#define P(i) e[i].r
void top()
{
  for (int i=0;++i<=n;)    
    if (!d[i]) S.insert(i);
  for (int j=0;++j<=n;)
    {
      int x=*S.begin();
      A[x]=j;
      S.erase(x);
      for (int i=h[x];i;i=e[i].n)
        if (--d[P(i)]==0)
          S.insert(P(i));
    }
}

void wor()
{
  bui(1,1,n);
  for (int i=n,x;i;--i)
    {
      x=que(1,a[i]-k+1,a[i]);
      if (x<=n) ins(a[i],a[x]);
      x=que(1,a[i],a[i]+k-1);
      if (x<=n) ins(a[i],a[x]);
      add(1,a[i],i);
    }  
  top();
}

void out()
{
  for (int i=0;++i<=n;)
    printf("%d\n",A[i]);
}

int main()
{
  in();
  wor();
  out();
  exit(0);
}

Measured memory_bytes: 49408
from sys import stdin
N = int(stdin.readline().rstrip())
dp = [[0, 0, 0] for i in range(N+1)]
A = [[0, 0, 0] for i in range(N+1)]
for i in range(N):
    a, b, c = [int(_) for _ in stdin.readline().rstrip().split()]
    A[i][0], A[i][1], A[i][2] = a, b, c 

for i in range(N):
    for j in range(3):
        for k in range(3):
            if j == k :
                continue
            dp[i][j] = max(dp[i][j], dp[i-1][k]+A[i][j])
print(max(dp[N-1]))

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

/*******  All Required define Pre-Processors and typedef Constants *******/
#define all(cont) cont.begin(), cont.end()
#define rall(cont) cont.rbegin(), cont.rend()
#define rep(i,n) for(int i=0; i<(n); ++i)
#define rep1(i,n) for(int i=1; i<=(n); ++i)
#define Dcout(a) cout << setprecision(20) << a << endl
#define MP make_pair
#define PB push_back
#define EPS 1e-9
#define PI 3.1415926535897932384626433832795
#define MOD 1000000007
using ll = long long;
using PAIR = pair<int, int>;
using Graph = vector<vector<int>>;
const double pi=acos(-1.0);
#define debug cout << "line : " << __LINE__ << " debug" << endl
/****** Template of some basic operations *****/
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; }
/**************************************/

/******** User-defined Function *******/
map<long long, long long> prime_factorize(long long n) {
    map<long long, long long> res;
    for (long long p = 2; p * p <= n; ++p) {
        while (n % p == 0) { ++res[p]; n /= p; }
    }
    if (n != 1) res[n] = 1;
    return res;
}
/**************************************/

/********** Main()  function **********/
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);

    string s; cin >> s;
    char c[4] = { 'A', 'T', 'G', 'C'};

    int seq = 0;
    int ans = -1;
    rep(i,s.size()){
        bool flag = false;
        rep(j,4){
            if(s[i]==c[j]){
                seq++;
                flag = true;
                break;
            }
        }

        if(flag==false){
            chmax(ans, seq);
            seq = 0;
        }else if(i==s.size()-1){
            chmax(ans, seq);
        }
    }

    cout << ans << endl;
}
/********  Main() Ends Here *************/


Measured memory_bytes: 3588
#include<stdio.h>
#include<string.h>
#include<algorithm>
using namespace std;
int main(){
	char s[250];
	scanf("%s",s);
	int n;
	n=strlen(s)-1;
	for(int i=1;i<strlen(s);i++){
		int num=0;
		int cnt=0;
		if(n%2==0){
			for(int j=0;j<n/2;j++){
				if(s[j]==s[n/2+j])
					num++;
				if(num==n/2){
					cnt=1;
					printf("%d\n",n);
				}
			}
	    }
	    n--;
	    if(cnt==1)
	    break;
	}
	return 0;
 }

Measured memory_bytes: 128
using System;
using System.Collections.Generic;
using System.Linq;

class Program
{
    static void Main(string[] args)
    {
        string[] In1 = Console.ReadLine().Split(' ');
        int x = int.Parse(In1[0]);
        int n = int.Parse(In1[1]);
        if (n == 0)
        {
            Console.WriteLine(x);
        }
        else
        {
            string[] In2 = Console.ReadLine().Split(' ');
            var C = new List<int>();//correct
            C = Enumerable.Range(1, 101).ToList();
            for (int i = 0; i < n; i++)
            {
                C.Remove(int.Parse(In2[i]));
            }
            int big = 101, small = 0;
            for (int i = 0; i < C.Count(); i++)
            {
                if (C[i] >= x)
                {
                    big = C[i];
                    break;
                }
            }
            for (int i = C.Count()-1; i >= 0; i--)
            {
                if (C[i] <= x) 
                {
                    small = C[i];
                    break;
                } 
            }
            if (big - x >= x-small) Console.WriteLine(small);
            else if (big - x < x-small) Console.WriteLine(big);
        }
    }
}



Measured memory_bytes: 28268
#include <bits/stdc++.h>
#define LL long long
#define PII pair<int,int>
#define PIII pair<int,PII>
#define PLL pair<LL,LL>
#define PLII pair<LL,PII>
#define VI vector<int>
#define FF first
#define SS second
#define MP make_pair
#define PB push_back
#define MX 50
#define EPS 0.00000000001
#define MOD 1000000007
#define PI acos(-1)
#define INF 100000000
#define loop(i,b,n) for(int i=b;i<n;++i)
#define rev_loop(i,b,n) for(int i=b;i>=n;--i)
using namespace std;

int main()
{
    ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    LL x;
    cin>>x;
    LL n = x/500;
    LL ans = n * 1000;
    LL l = x % 500;
    n = l/5;
    ans += (n * 5);
    cout<<ans<<'\n';

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
using ld = long double;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using pli = pair<ll, int>;
using pil = pair<int, ll>;
using uint = unsigned int;
template <typename T>
using Graph = vector<vector<T>>;
const int MOD = 1e9 + 7;
const ld PI = acosl(-1);

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

    int N;
    cin >> N;
    ll ans = 0;
    for (int i = 1; i <= N;++i){
        ll tmp = N / i;
        ans += tmp * (tmp + 1) / 2 * i;
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 3648
#include <bits/stdc++.h>
 
using namespace std;
 
typedef long long ll;
typedef long double ld;
 
typedef pair<int, int> pi;
typedef pair<ll, ll> pl;
 
#define pb push_back
#define f first
#define s second
#define all(x) x.begin(), x.end()
 
const ll MOD = 1000000007;
 
int main() {
   int n; scanf("%d", &n);
   printf("%d", n * n * n);
   return 0;
}

Measured memory_bytes: 256
n = int(input())
p = [int(i) for i in input().split()]

count = 0
for i in range(len(p)-2):
  if max(p[i],p[i+2]) > p[i+1] and min(p[i],p[i+2]) < p[i+1]:
    count += 1

print(count)


Measured memory_bytes: 2940
import java.util.*;
public class Main {
 
         
        public static void main(String[] args) throws java.io.IOException{
            Scanner scan = new Scanner(System.in);
            while(true){
                int a =scan.nextInt();
                int b = scan.nextInt();
                if((a|b)==0)break;
                if(b>a){
                    a=a^b;
                    b=a^b;
                    a=a^b;
                }
                int c=0;
                while(b!=0){
                    a=a%b;
                    a=a^b;
                    b=a^b;
                    a=a^b;
                    c++;
                }
                System.out.println(a+" "+c);
            }
  
        }
   
}

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

#define rep(i, j) for (int i = 0; i < j; i++)
#define all(obj) (obj).begin(), (obj).end()
#define rall(obj) (obj).rbegin(), (obj).rend()
typedef long long int ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<vi> vvi;

int main() {

    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.precision(10);
    cout << fixed;

    vector<string> vs = {"SUN","MON","TUE","WED","THU","FRI","SAT"};
    string s;
    cin >> s;
    for(int i = 0; i < vs.size(); i++) {
        if (vs[i] == s) {
            cout << 7 - i << endl;
            return 0;
        }
    }

    return 0;
}


Measured memory_bytes: 256
import sys
N,T = map(int,input().split())
c = []
t = []
cmin = 1000
for i in range(N):
    c1,t1=[int(i) for i in input().split()]
    c.append(c1)
    t.append(t1)
if min(t) > T:
  print("TLE")
  sys.exit()    
for i in range (0,N):
  if t[i] <= T:
    cmin = min(c[i],cmin)
print(cmin)

Measured memory_bytes: 3064
#include<bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < n; ++i)
#define rrep(i, n) for(int i = n-1; i >= 0; --i)
#define fi first
#define se second
using namespace std;
using lint = long long;
using uint = unsigned int;
using ulint = unsigned long long;
using ldouble = long double;
using pii = pair<int, int>;
using pli = pair<lint, lint>;
using pdd = pair<double, double>;
using pld = pair<ldouble, ldouble>;
using v1i = vector<int>;
using v1li = vector<lint>;
using v2i = vector<vector<int>>;
using v2li = vector<vector<lint>>;
using v3i = vector<vector<vector<int>>>;
using v3li = vector<vector<vector<lint>>>;
using v1b = vector<bool>;
using v2b = vector<vector<bool>>;
using v3b = vector<vector<vector<bool>>>;
using v1c = vector<char>;
using v2c = vector<vector<char>>;
using v3c = vector<vector<vector<char>>>;
constexpr lint mod1 = 1e9+7;
constexpr lint mod2 = 998244353;

int main(){
  int n; cin >> n;
  vector<string> v(n); rep(i, n) cin >> v[i];
  v1i two(n, 0), five(n, 0), ten(n, 0); v1li u(n);
  rep(i, n){
    string a = "";
    rep(j, v[i].size()){
      if(v[i][j] == '.') ten[i] = v[i].size() - j - 1;
      else a += v[i][j];
    }
    u[i] = stol(a);
    while(u[i] % 2 == 0){
      two[i]++;
      u[i] /= 2;
    }
    while(u[i] % 5 == 0){
      five[i]++;
      u[i] /= 5;
    }
  }
  lint ans = 0;
  v3li e(50, v2li(20, v1li(15, 0))), f;
  rep(i, n) e[two[i]][five[i]][ten[i]]++;
  f = e;
  rep(i, 50) rep(j, 20) rrep(k, 14) f[i][j][k] += f[i][j][k+1];
  rep(i, 50){
    rep(j, 20){
      if(f[i][j][0] == 0) continue;
      rep(k, 15){
        if(e[i][j][k] == 0) continue;
        lint tmp = e[i][j][k];
        rep(l, 50){
          rep(m, 20){
            if(f[l][m][0] == 0) continue;
            int g = min(i+l, j+m) - k;
            rep(o, 15){
              if(g - o < 0) break;
              if(i == l && j == m && k == o) ans += tmp * (tmp - 1);
              else ans += tmp * e[l][m][o];
            }
          }
        }
      }
    }
  }
  cout << ans / 2 << endl;
  return 0;
}

Measured memory_bytes: 13740
#include <bits/stdc++.h>
typedef long long int ll;
typedef long double ld;
using namespace std;
const long long int INF = 1e18;
const long long int mod = 1e9+7;

typedef pair<ll, ll> pairs;
typedef vector<pairs> p;

struct edge{
    ll to, cost;
};


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

ll lcm(ll a, ll b){
    return a / gcd(a, b) * b;
}

ll keta(ll N){
    int tmp{};
    while( N > 0 ){
        tmp += ( N % 10 );
        N /= 10;
    }
    N = tmp;
    return N;
}

// 回文
bool kai(string S){
    bool flag = true;
    for(ll i=0;i<S.size()/2;++i){
        if(S[i] != S[S.size()-i-1]){
            flag = false;
            break;
        }
    }
    return flag;
}
// ---------------------------------------------

int main(){
    string s,t;
    cin>>s>>t;
    ll ans = 0;
    for(ll i=0;i<s.size();++i){
        if(s[i] != t[i]){
            ans++;
        }
    }
    cout<<ans<<endl;
}

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

using namespace std;
typedef long long int ll;
typedef pair <ll,ll> P;
#define REP(i, n) for(int i = 0; i < (int)(n); i++)
#define REPR(i, n) for(int i = n-1; i >= 0; i--)
#define FOR(i, n, m) for(int i = n; i < (int)(m); i++)
#define PRINT(x) cout << x << endl
#define ALL(v) v.begin(), v.end()

ll gcd(ll a, ll b) { return b ? gcd(b,a%b) : a;}
ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }

ll MOD = 1000000007;


int main()
{
    ll H, W;
    cin >> H >> W;
    vector<vector<ll>> mat(H, vector<ll>(W, 0));
    REP(i, H) {
        string str;
        cin >> str;
        REP(j, W) {
            if (str[j] == '#') mat[i][j] = 1;
        }
    }
    vector<vector<ll>> dp(H, vector<ll>(W, 0));
    FOR(i, 0, H) {
        FOR(j, 0, W) {
            if (i == 0) {
                if (j == 0) {
                    if (mat[0][0] == 1) dp[0][0] = 1;
                } else {
                    if (mat[i][j-1] == 0 && mat[i][j] == 1) {
                        dp[i][j] = dp[i][j-1] + 1;
                    } else {
                        dp[i][j] = dp[i][j-1];
                    }
                }
            } else {
                if (j == 0) {
                    if (mat[i-1][j] == 0 && mat[i][j] == 1) {
                        dp[i][j] = dp[i-1][j] + 1;
                    } else {
                        dp[i][j] = dp[i-1][j];
                    }
                } else {
                    ll t1, t2;
                    if (mat[i-1][j] == 0 && mat[i][j] == 1) {
                        t1 = dp[i-1][j] + 1;
                    } else {
                        t1 = dp[i-1][j];
                    }

                    if (mat[i][j-1] == 0 && mat[i][j] == 1) {
                        t2 = dp[i][j-1] + 1;
                    } else {
                        t2 = dp[i][j-1];
                    }
                    dp[i][j] = min(t1, t2);
                }
            }
        }
    }
    PRINT(dp[H-1][W-1]);
    return 0;
}


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

#define INF 1e9
#define LLINF 1e18
#define pi 3.14159265358979323
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
typedef long long ll;

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


int main() {
    ll n, p;
    ll ans = 1;
    cin >> n >> p;
    if (n == 1) {
        cout << p << endl;
        return 0;
    }
    long double g = (long double)1 / n;
    long double root = powl((long double) p, g);
    for (ll i = 2; (long double)i < root + 0.1; i++) {
        ll a;
        a = pow(i, n);
        if (p % a == 0) {
            ans = i;
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 4104
/*
 * @Author: Kaizyn
 * @Date: 2020-05-10 20:57:59
 * @LastEditTime: 2020-05-10 20:59:58
 */
#include <bits/stdc++.h>

// #define DEBUG

using namespace std;

const double eps = 1e-7;
const double PI = acos(-1);
typedef pair<int, int> pii;
const int MOD = 998244353;
const int INF = 0x3f3f3f3f;

string s, t;

inline void solve() {
  cin >> s >> t;
  cout << (t.substr(0, s.size()) == s ? "Yes" : "No") << endl;
}

signed main() {
  ios::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
  int T = 1;
  // cin >> T;
  for (int t = 1; t <= T; ++t) {
    solve();
  }
  return 0;
}

Measured memory_bytes: 3600
#include <stdio.h>
#include <math.h>
#include <stdlib.h>
#define GOOD 'a'-'A'

int pos[8],graph[50][50],used[8];
int SET;
char cube[8][8];

void roll(int* a,int *b){
	int c=7-*b;
	*b=*a;
	*a=c;
}

void swap (int* x,int* y){
	int z;
	z=*x;
	*x=*y;
	*y=z;
}

void set(int t,int* a,int* b){
	*a=(t/4)*3+(t)%3+1;
	*b=(t/4)*3+(t+1)%3+1;
}

//
int step3(int s6,int s7,int s4){
	int i,r,sa=0,sb,sc;
	for(i=1;i<8;i++)if(!used[i])break;
	if(i==8)fprintf(stderr,"!!\n");
	for(r=0;r<24;r++){
		if(r%4==0){sa++;set(sa,&sb,&sc);}
		if(graph[s4][6*i+sa-1]==SET && graph[s6][6*i+sb-1]==SET && graph[s7][6*i+sc-1]==SET)return 1;
		roll(&sb,&sc);
	}

	return 0;
}

int step2a(int da,int sa,int db,int sb,int dice,int *tc){
	int i,j,ta,tb;
	for(i=0;i<6;i++){
		if(graph[da*6+sa-1][dice*6+i]!=SET)continue;
		set(i+1,&ta,&tb);
		for(j=0;j<4;j++){
			if(graph[db*6+sb-1][dice*6+ta-1]==SET){
				*tc=tb;
				return 1;
			}
			roll(&ta,&tb);
		}
	}
	return 0;
}

int step2(int s5,int s3,int s2){
	int d5=s5/6,d2=s2/6,d3=s3/6;
	int t5=s5%6+1,t2=s2%6+1,t3=s3%6+1;
	int s5a,s5b,s2a,s2b,s3a,s3b;
	int s6c,s7c,s4c;
	int r,i,j,k;

	set(t5,&s5a,&s5b);
	set(t2,&s2a,&s2b);
	set(t3,&s3a,&s3b);

	for(r=0;r<64;r++){

		for(i=1;i<8;i++){
			if(used[i] || !step2a(d2,s2a,d5,s5b,i,&s6c))continue;
			used[i]=1;

			for(j=1;j<8;j++){
				if(used[j] || !step2a(d5,s5a,d3,s3b,j,&s7c))continue;
				used[j]=1;

				for(k=1;k<8;k++){
					if(used[k] || !step2a(d3,s3a,d2,s2b,k,&s4c))continue;
					used[k]=1;
					if(step3(i*6+s6c-1,j*6+s7c-1,k*6+s4c-1))return 1;
					used[k]=0;
				}

				used[j]=0;
			}

			used[i]=0;
		}


		roll(&s5a,&s5b);
		if(r%4==3)roll(&s2a,&s2b);
		if(r%16==15)roll(&s3a,&s3b);
	}

	return 0;
}

int step1(){
	int st=6,sa=2,sb=3,r,i,j,k;

	for(r=0;r<8;r++){

		for(i=6;i<48;i++){
			if(graph[st-1][i]!=SET)continue;
			used[i/6]=1;

			for(j=6;j<48;j++){
				if(used[j/6] || graph[sa-1][j]!=SET)continue;
				used[j/6]=1;

				for(k=6;k<48;k++){
					if(used[k/6] || graph[sb-1][k]!=SET)continue;
					used[k/6]=1;
					if(step2(i,j,k))return 1;
					used[k/6]=0;
				}

				used[j/6]=0;
			}

			used[i/6]=0;
		}

		roll(&sa,&sb);
		if(r==3){swap(&sa,&sb);st=1;}
	}

	return 0;
}

int main(){
	int i,j;
	used[0]=1;
	while(scanf("%s",cube[0])){
		SET++;
		if(cube[0][0]=='0')break;
		for(i=1;i<8;i++){scanf("%s",cube[i]);used[i]=0;}
		for(i=0;i<48;i++){
			for(j=0;j<48;j++){
				if(i/6!=j/6 && abs(cube[i/6][i%6]-cube[j/6][j%6])==GOOD)graph[i][j]=SET;
			}
		}
		if(step1())printf("YES\n"); else printf("NO\n");
	}
	return 0;
}

Measured memory_bytes: 528
n = int(input())
a = list(map(int,input().split()))

total = 0
ans = 0
r = 0

for l in range(n):
    while r < n and total+a[r] == total^a[r]:
        total += a[r]
        r += 1
    ans += r-l
    if l == r:
        r += 1
    else:
        total -= a[l]

print(ans)

Measured memory_bytes: 24840
import java.util.*;

public class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        long a = sc.nextInt();
        long b = sc.nextInt();
        sc.close();
        long lcm = (a * b) / gcd(a,b);
        System.out.println(lcm);
        
    }

    private static long gcd(long a,long b){

        if(a < b){
            long tmp = a;
            a = b;
            b = tmp;
        }

        long d = a%b;

        if(d==0)return b;
        else return gcd(b,d);
        
    }
}





Measured memory_bytes: 23764
import numpy as np
INF = 10 **18
N= int(input())
# ans =1
A= list(map(int,input().split()))
# if 0 in A:
#     print(0)
# else:
def calc(A):
    if 0 in A:
        return 0
    ans = A.pop()
    for a in A:


        ans *= a
        if ans > INF:
            # print(-1)
            return -1
    return ans

# ans = np.prod(A)
# ans = -1 if ans > INF else ans
# hoge =[1]*(10 **5)
# hoge.append(10**18 +1)
# print(calc(hoge))
print(calc(A))

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

int main()
{
  string S;
  cin >> S;
  int count = 0;
  for (int i = 0, _i = S.length(); i < _i/2; ++i)
    if (S[i] != S[_i - 1 - i])
      ++count;
  cout << count;
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long
using namespace std;
int main(){
  ll n,m;
  cin>>n>>m;
  if(m>n)
  {
      for(ll i=0;i<m;i++)
      {
          cout<<n;
      }
      cout<<"\n";
  }
    
  else{
    for(ll i=0;i<n;i++)
      {
          cout<<m;
      }
      cout<<"\n";
  }
  
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#ifdef ENABLE_DEBUG
#define dump(a) cerr<<#a<<"="<<a<<endl
#define dumparr(a,n) cerr<<#a<<"["<<n<<"]="<<a[n]<<endl
#else
#define dump(a) 
#define dumparr(a,n) 
#endif
#define FOR(i, a, b) for(int i = a;i < b;i++)
#define For(i, a) FOR(i, 0, a)
#define REV(i, a, b) for(int i = b-1;i >= a;i--)
#define Rev(i, a) REV(i, 0, a)
#define REP(a) For(i, a)

typedef long long int ll;
typedef unsigned long long ull;
typedef unsigned int uint;
typedef pair<ll, ll> pll;
typedef pair<ll,pll> ppll;
typedef vector<ll> vll;

const ll INF=(1LL<<50);

template<class S,class T>
std::ostream& operator<<(std::ostream& os,pair<S,T> a){
  os << "(" << a.first << "," << a.second << ")";
  return os;
}
template<class T>
std::ostream& operator<<(std::ostream& os,vector<T> a){
  os << "[ ";
  REP(a.size()){
    os<< a[i] << " ";
  }
  os<< " ]";
  return os;
}


void solve(long long N, std::vector<long long> d){
  sort(d.begin(),d.end());
  cout<<d[N/2]-d[N/2-1]<<endl;
}

int main(){
    long long N;
    scanf("%lld",&N);
    std::vector<long long> d(N);
    for(int i = 0 ; i < N ; i++){
        scanf("%lld",&d[i]);
    }
    solve(N, std::move(d));
    return 0;
}


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

#define int long long
#define ff first
#define ss second
#define endl "\n"
#define all(x) (x).begin(), (x).end()
#define sz(x) (int)(x.size())
int powmod(int a,int l, int md){a%=md; int res=1;while(l){if(l&1)res=res*a%md;l/=2;a=a*a%md;}return res;}
int binpow(int a,int l){int res=1;while(l){if(l&1)res=res*a;l/=2;a=a*a;}return res;}
int invmod(int a, int md){return powmod(a,md-2,md);}
typedef long long ll; typedef unsigned long long ull; typedef long double ld;
typedef vector<int> vi; typedef pair<int, int> ii; typedef vector< ii > vii;
#define pb push_back
int __set(int b, int i) {return b|(1LL<<i);} //set ith bit
int __unset(int b, int i) {return b&(~(1UL<<i));}
int __check(int b, int i) {return b&(1LL<<i);} //returns 0 if ith bit is 0
int mulmod(int a, int b, int md) {return (((a%md)*(b%md))%md+md)%md;}
int addmod(int a, int b, int md) {return ((a%md+b%md)%md+md)%md;}
int submod(int a, int b, int md) {return (((a%md-b%md)%md)+md)%md;}
int divmod(int a, int b, int md) {return mulmod(a, powmod(b, md-2, md), md);} //if md is prime;
const ll inf = 0xFFFFFFFFFFFFFFFL; //very large number
priority_queue<int, vector<int>, greater<int> > pq; //for min priority_queue
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);



signed main(void)
{
	IOS;
	int n; cin>>n;
	cout<<(1000-n%1000)%1000<<endl;
	return 0;
}

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

int main(){
    stack<int> S;
    string s;
    int a,b;

    while(cin>>s){
        if(s[0]=='+'){
            a=S.top();S.pop();
            b=S.top();S.pop();
            S.push(a+b);
        }else if(s[0]=='-'){
            a=S.top();S.pop();
            b=S.top();S.pop();
            S.push(b-a);
        }else if(s[0]=='*'){
            a=S.top();S.pop();
            b=S.top();S.pop();
            S.push(a*b);
        }else{
            S.push(stoi(s));
        }
    }
    
    cout<<S.top()<<endl;

    return 0;
}


Measured memory_bytes: 3208
alpha=[chr(ord('a') + i) for i in range(26)]
a=list(input())
N=int(input())
for i in range(len(a)):
   s=26-alpha.index(a[i])
   if s<=N and s!=26:
      a[i]="a"
      N-=s
s=alpha.index(a[-1])
s=(s+N)%26
a[-1]=alpha[s]
print(*a,sep="")

Measured memory_bytes: 11580
#include "bits/stdc++.h"
#define ll long long
#define rep2(i,a,b) for(int i=a;i<=b;++i)
#define rep(i,n) for(int i=0;i<n;i++)
#define pii pair<int,int>
#define tii tuple<int,int,int>
#define pq priority_queue<int>
#define pqg priority_queue<int,vector<int>,greater<int>>
#define pb push_back
#define edge(v,a,b) v[a].pb(b);v[b].pb(a);
int MOD=1e9+7;
#define INF 2*1e9
#define N 310000 
using namespace std;
string alphabet("abcdefghijklmnopqrstuvwxyz");

main(){
    int n,m;
    cin>>n>>m;
    vector<pii> p;
    rep(i,m){
        int a,b;
        cin>>a>>b;
        p.pb({b,a});
    }
    sort(p.begin(),p.end());
    int pre=-1,ans=0;
    rep(i,m){
        if(p[i].second<pre) continue;
        ans++;
        pre=p[i].first;
    }
    cout<<ans;
    return 0;
}



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

template <typename InputIterator>
typename InputIterator::value_type summation(InputIterator first,
                                             InputIterator last) {
  return std::accumulate(first, last, typename InputIterator::value_type());
}
template <typename T>
std::istream &operator>>(std::istream &stream, std::vector<T> &v);
template <typename T1, typename T2>
std::istream &operator>>(std::istream &stream, std::pair<T1, T2> &p);
template <typename T>
std::istream &operator>>(std::istream &stream, std::vector<T> &v) {
  for (auto &i : v) {
    stream >> i;
  }
  return stream;
}
template <typename T1, typename T2>
std::istream &operator>>(std::istream &stream, std::pair<T1, T2> &p) {
  stream >> p.first >> p.second;
  return stream;
}
template <typename T>
std::vector<T> prime(const T max) {
  std::vector<bool> sieve(max - 1, true);
  const auto lim = std::floor(std::sqrt(max));

  if (max < 2) {
    return {};
  }

  T var = 2;
  while (var <= lim) {
    for (T i = 2; i * var <= max; i++) {
      sieve[i * var - 2] = false;
    }
    do {
      var++;
    } while (!sieve[var - 2] && var <= lim);
  }

  std::vector<T> ans;
  ans.reserve(std::count(sieve.cbegin(), sieve.cend(), true));
  for (T i = 0; i < max - 1; i++) {
    if (sieve[i]) {
      ans.push_back(i + 2);
    }
  }

  return ans;
}

int main() {
  int64_t x;
  std::cin >> x;
  const auto p = prime(x * 10);

  std::cout << *std::lower_bound(p.cbegin(), p.cend(), x) << std::endl;
  return 0;
}


Measured memory_bytes: 1024
import sys


def solve(n, m, links):
    v4 = set()
    v6 = 0
    for v, link in enumerate(links):
        l = len(link)
        if l % 2 == 1:
            return False
        if l == 4:
            v4.add(v)
        elif l >= 6:
            v6 += 1
    if v6 > 0:
        return True
    if len(v4) > 2:
        return True
    if len(v4) < 2:
        return False
    s = v4.pop()
    t = v4.pop()
    for c in links[s]:
        visited = {s, t}
        q = [c]
        while q:
            v = q.pop()
            if v in visited:
                continue
            visited.add(v)
            for u in links[v]:
                if v != c and u == s:
                    return True
                if u not in visited:
                    q.append(u)
    return False


n, m = map(int, input().split())
links = [set() for _ in [0] * n]
for line in sys.stdin:
    a, b = map(int, line.split())
    a -= 1
    b -= 1
    links[a].add(b)
    links[b].add(a)
print('Yes' if solve(n, m, links) else 'No')


Measured memory_bytes: 35072
#include <iostream>
#include <algorithm>
#define ll long long
using namespace std;
int n,m;
ll d[100010];
int main()
{
	cin >>n>>m;
	for (int tr=0;tr<n;tr++)
	{
		int x,y;
		cin >>x>>y;
		for (int j=m-x;j>=0;j--) d[j+x]=max(d[j+x],d[j]+y);
	}
	cout <<*max_element(d+1,d+m+1);
	return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h> 
using namespace std; 
int gcd(int a,int b){
	if(b==0) return a;
	return gcd(b,a%b);
}
int main () 
{ 
int n;cin>>n;
long long int sum=0;
 
 for(int i=1;i<=n;i++){
 	for(int j=1;j<=n;j++){
 		int g=gcd(max(i,j),min(i,j));
 		for(int k=1;k<=n;k++){
 			sum+=gcd(max(g,k),min(g,k));
		 }
	 }
 }
  cout<<sum;
	return 0; 
} 


Measured memory_bytes: 3644
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#define _USE_MATH_DEFINES
#include <math.h>
#include <iomanip>
#include <stdio.h>
#include <numeric>
#include <cmath>
#include <limits>
#include <bitset> 
#include <iterator> 
#include <map>
#include <unordered_map>
#include <queue>
#include <set>
#include<deque>
#include <regex>
#include <list> 
#define rep(i,n) for(ll i=0;i<(n); ++i)
#define per(i,n) for(ll i=n-1;i>=0; --i)
#define all(x) (x).begin(),(x).end()
#define _GLIBCXX_DEBUG
using namespace std;
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 long long INF = 1LL << 60;
typedef long long ll;
const ll MOD = 1000000007;
ll getDigit(ll n) {
	ll cnt = 0;
	while (n != 0) {
		n /= 10;
		cnt++;
	}
	return cnt;
}
ll gcd(ll a, ll b) {
	if (b == 0) return a;
	return gcd(b, a % b);
}
typedef pair<double, long long> pair_t;
bool comp(const pair_t& a, const pair_t& b) {
	if (a.first == b.first)return  a.second > b.second;
	else {
		return a.first > b.first;
	}
}

int main() {
	ll n,k;
	cin >> n >> k;
	cout << floor((double)log(n) / log(k)) + 1 << endl;
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
//#define DEBUG
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
template <class T>
void print_vect(std::vector<T> v){
    for(int i = 0 ; i < v .size(); i++) cout << v[i] << " ";
    cout << endl;
}

void solve(){
    int A, B;
    cin >> A >> B;
    if( B == 1){
        cout << 0 << endl;
        return;
    }
    int ans = ( B - A) / (A - 1);
    if( B <= A){
        cout << 1 << endl;
        return;
    }
    if( (B - A) % (A-1) == 0){
        ans = ans + 1;
    }else{
        ans = ans + 2;
    }
    cout << ans << endl;
}

int main()
{
    //making data IO Fast
    std::ios_base::sync_with_stdio(false);
    std::cin.tie(NULL);
    /****************************/

    #ifdef DEBUG
    int TEST_CASES = 2;
    while(TEST_CASES--){
    #endif // DEBBUG

    solve();

    #ifdef DEBUG
    }
    #endif // DEBUG
    
    return 0;
}



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

char c;

int main(){
    cin >> c;
    if(c=='a'||c=='e'||c=='i'||c=='o'||c=='u'){
		cout << "vowel" << endl;
	}else{
		cout << "consonant" << endl;
	}
	
    return 0;
}


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

using namespace std;

long long gcd(long long a,long long b){
return a%b==0?b:gcd(b,a%b);
}



int main() {

    int n;
    scanf("%d",&n);
    map<int,int>m;
    int a[n];
    for(int i=0;i<n;i++){
        scanf("%d",&a[i]);
        m[a[i]]++;
    }
    int mm;
    scanf("%d",&mm);
    for(int j=0;j<mm;j++){
        int b;
        scanf("%d",&b);
        m[b]--;
        if(m[b]<0){
            puts("NO");
            return 0;
        }
    }
    puts("YES");
    return 0;

}


Measured memory_bytes: 10368
a = int(input())
b = int(input())
c = int(input())
d = int(input())
e = int(input())
input_list = [a,b,c,d,e]
ten_up_list = []
amari_list = []
total = 0
for i in input_list:
    amari = i % 10
    if amari == 0:
        ten_up_list.append(i)
    else:
        ten_up_list.append(i + 10 - amari)
        amari_list.append(amari)
for i in ten_up_list:
    total += i
if len(amari_list) != 0:
    amari_list.sort()
    total = total - 10 + amari_list[0]
print(total)

Measured memory_bytes: 3064
import sys
stdin = sys.stdin
 
sys.setrecursionlimit(10**5) 
 
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 itertools import accumulate

def add_sentinel(t: list, v: list):
    t = [0] + [0] + t + [t[-1]]
    v = [0] + v + [0]
    return t,v
    
def find_max_vel(ti: int, v: list, intervals: list):
    ret = float('inf')
    for inti, interval in enumerate(intervals):
        st, ed = interval
        
        if ti < st:
            ret = min(ret, v[inti] + (st - ti))
        elif st <= ti <= ed:
            ret = min(ret, v[inti])
        else:
            ret = min(ret, v[inti] + (ti - ed))
            
    return ret

n = ni()
t = list(li())
v = list(li())

t,v = add_sentinel(t, v)
t = list(accumulate(t))
intervals = [(st, ed) for st, ed in zip(t[:-1], t[1:])]

vels = []
for ti in range(2*max(t)+1):
    timestamp = ti/2
    vels.append(find_max_vel(timestamp, v, intervals))
    
ans = 0
for left, right in zip(vels[:-1], vels[1:]):
    ans += (left + right) * 0.5 * 0.5
    
print(ans)

Measured memory_bytes: 46684
#include<iostream>
#include<cstdio>
#include<cstring>
using namespace std;
const int _=2e5+5;
const int M=2010;
const int mod=1e9+7;
inline int read()
{
	char ch='!';int z=1,num=0;
	while(ch!='-'&&(ch<'0'||ch>'9'))ch=getchar();
	if(ch=='-')z=-1,ch=getchar();
	while(ch<='9'&&ch>='0')num=(num<<3)+(num<<1)+ch-'0',ch=getchar();
	return z*num;
}
int n,a[_],b[_],ans;
int f[4500][4500];
int jc[9005],inv[9005];
void add(int &a,int b){a+=b;if(a>=mod)a-=mod;if(a<0)a+=mod;}
inline int C(int n,int m)
{
	if(n<0||m<0||n<m)return 0;
	return 1ll*jc[n]*inv[m]%mod*inv[n-m]%mod;
}
int main()
{
	n=read();
	for(int i=1;i<=n;++i)
	{
		a[i]=read(),b[i]=read();
		f[M-a[i]][M-b[i]]++;
	}
	jc[0]=1;inv[0]=inv[1]=1;
	for(int i=2;i<=(M<<2);++i)inv[i]=(mod-1ll*mod/i*inv[mod%i]%mod)%mod;
	for(int i=1;i<=(M<<2);++i)jc[i]=1ll*jc[i-1]*i%mod,inv[i]=1ll*inv[i-1]*inv[i]%mod;
	for(int i=1;i<=M*2;++i)
		for(int j=1;j<=M*2;++j)
			f[i][j]=(f[i][j]+(f[i-1][j]+f[i][j-1])%mod)%mod;
	for(int i=1;i<=n;++i)
		add(ans,(f[M+a[i]][M+b[i]]+mod-C((a[i]+b[i])<<1,a[i]<<1))%mod);
	printf("%lld\n",1ll*ans*inv[2]%mod);
	return 0;
}

Measured memory_bytes: 74752
#define _CRT_SECURE_NO_WARNINGS
#include <cstdio>
#include <cstdlib>
#include <string>
#include <iostream>
#include <climits>
#include <list>
#include <queue>

using namespace std;

list<int> *AdjacenceyList;
int CID;
int *ComponentID;
queue<int> Q;

void bfs(int v) {
	ComponentID[v] = CID;
	Q.push(v);
	while (Q.empty() != true) {
		v = Q.front();
		Q.pop();
		for (list<int>::iterator it = AdjacenceyList[v].begin(); it != AdjacenceyList[v].end(); it++) {
			if (ComponentID[*it] == 0) {
				ComponentID[*it] = CID;
				Q.push(*it);
			}
		}
	}
	CID++;
}

int main() {
	int n;
	int m;
	int s, t;
	int q;
	int i;
	cin >> n >> m;

	AdjacenceyList = new list<int>[n];
	
	ComponentID = new int[n];
	for (i = 0; i < n; i++) {
		ComponentID[i] = 0;
	}
	CID = 1;

	for (i = 1; i <= m; i++) {
		cin >> s >> t;
		AdjacenceyList[s].push_back(t);
		AdjacenceyList[t].push_back(s);
	}

	for (i = 0; i < n; i++) {
		if (ComponentID[i] == 0) {
			bfs(i);
		}
	}

	cin >> q;
	for (i = 1; i <= q; i++) {
		cin >> s >> t;
		if (ComponentID[s] == ComponentID[t]) {
			printf("yes\n");
		}
		else {
			printf("no\n");
		}
	}

	delete[] AdjacenceyList;
	delete[] ComponentID;
	return 0;
}

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

int main() {
	long long n;
	unsigned long long res = 0;
	scanf("%lld", &n);
	for(int i = 1; (long long) i * i <= n; i++)
		if(n % i == 0) {
			long long k = n / i;
			if(i < k - 1) res += k - 1;
		}
	printf("%llu\n", res);
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define int long long
#define rep(i, a, n) for(int (i) = (int)(a);(i) < (int)(n);++(i))
#define repe(i, a, n) for(int (i) = (int)(a);(i) <= (int)(n);++(i))
#define repif(i, a, x) for(int (i) = (int)(a);(x);++(i))
#define repr(i, a, n) for(int (i) = ((int)(a)-1);(i) >= (int)(n);--(i))
#define reper(i, a, n) for(int (i) = (int)(a);(i) >= (int)(n);--(i))
#define SZ(x) ((int)(x).size())
#define ALL(x) (x).begin(), (x).end()
#define RNG(x, a, n) &((x)[a]), &((x)[n])
#define ADD(a, b) ((((a+MOD)%MOD)+((b+MOD)%MOD))%MOD)
#define MUL(a, b) ((((a)%MOD)*((b)%MOD))%MOD)
#define CHADD(a, b) (a = ADD(a, b))
#define CHMUL(a, b) (a = MUL(a, b))
#define CEIL(x) ((int)ceil(((double)x)))
#define POW(x, y) ((int)pow(x, y))
#define UNIQUE(x) (x).erase(unique(ALL((x))), (x).end())
#define YES cout << "YES" << endl
#define NO cout << "NO" << endl
#define Yes cout << "Yes" << endl
#define No cout << "No" << endl
#define yes cout << "yes" << endl;
#define no cout << "no" << endl;
#define fcout cout << fixed << setprecision(10)
#define pb push_back
#define lb lower_bound
#define ub upper_bound
#define PI (acos(-1))
#define EPS (1e-10)
#define INF LLONG_MAX
#define MOD 1000000007
using namespace std;
using VI = vector<int>;
using PII = pair<int, int>;
using VPII = vector<PII>;
using Complex = complex<double>;
template<typename T, template<typename> typename C> using PQ = priority_queue<T, vector<T>, C<T>>;
template<typename T> bool chmax(T& a, const T& b){ if(a<b){ a=b; return true; } return false; }
template<typename T> bool chmin(T& a, const T& b){ if(a>b){ a=b; return true; } return false; }


int N, M;
bool a[100010];
int dp[100010];


signed main(){
    cin >> N >> M;
    rep(i, 0, M){
        int x;
        cin >> x;
        a[x] = true;
    }

    dp[0] = 1;
    if(!a[1]) dp[1] = 1;
    repe(i, 2, N)
        if(!a[i]) CHADD(dp[i], ADD(dp[i-1],dp[i-2]));

    cout << dp[N] << endl;

    return 0;
}

Measured memory_bytes: 1152
/**
  * author : thegeniushead
**/
#include <bits/stdc++.h>
 
/*.....DEFINITIONS...... */
#define FIO ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define T() int tt; cin>>tt; while(tt--)
#define rep(i,start,lim) for(int i=start;i<lim;i++)
#define rep1(i,start,lim) for(int i=start; i<=lim; ++i)
#define repd(i,start,lim) for(int i=start;i>=lim;i--)
#define mp make_pair
#define pb push_back
#define lchild (2*node+1)
#define rchild (2*node+2)
#define ff first
#define ss second
#define br cout<<"\n"
#define MOD (1000000007LL)
#define all(v) (v).begin(), (v).end()
#define eps (1e-6)
#define sll(n) scanf("%lld", &n);
#define si(n) scanf("%d", &n);
#define what_is(x) cerr << #x << " is " << x << "\n";
#define infll 9e18
#define inf 1e9
#define int long long int

using namespace std;
 
/*.....TYPEDEFS ....*/
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef pair<long long, long long> pll;
typedef long double ld;
 
/*....USEFUL FUNCTIONS....*/
ll pwr(ll base, ll exp, ll mod=MOD){ll res=1; while(exp>0){if(exp%2){res=(res*base)%mod;}base=(base*base)%mod;exp/=2;}return res;}
ll gcd(ll a, ll b){ if(b==0)return a; else gcd(b, a%b);}
bool isPrime(ll n){if(n<=1)return false;if(n<=3)return true;if (n%2==0||n%3==0)return false;for(int i=5; i*i<=n; i=i+6)if(n%i==0||n%(i+2)==0)return false;return true;}
 
/*....I/O Functions...*/
inline string rs(){char x[1234567];scanf("%s", x);string s = x; return s;}
inline int ri(){int x; scanf("%d", &x);return x;}
inline long long rl(){long long x; scanf("%lld", &x); return x;}
 
/*---------Solution below this line --------*/
 
const int N = 1234567;

string s1, s2, s3;

int32_t main()
{
	//FIO
	//freopen("input.txt", "r", stdin);
	//freopen("output.txt", "w", stdout);
	
	s1 = rs();
	s2 = rs();
	s3 = rs();
	
	putchar(toupper(s1[0]));
	putchar(toupper(s2[0]));
	putchar(toupper(s3[0]));
	
	
	
	return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);

		int x = sc.nextInt();
		int y = sc.nextInt();
		int z = sc.nextInt();

		System.out.println(z + " " + x + " " + y);
	}
}

Measured memory_bytes: 23636
from collections import deque

S = input()

d = deque(S)


left = 0
right = len(d) - 1

count = 0
while left < right:
    #print(f'{left=}, {right=}')
    if d[right] == d[left]:
        left += 1
        right -= 1
    else:
        if d[right] == 'x':
            count += 1
            right -= 1
        elif d[left] == 'x':
            count += 1
            left += 1
        else:
            count = -1
            print(-1)
            break

if count != -1:
    print(count)


Measured memory_bytes: 4340