akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <cstdio>
#include <string>
#include <vector>
#include <iterator>  // std::back_inserter()
#include <tuple>  // std::tuple std::get
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <algorithm>  // std::copy()
#include <functional>  // std::greater<T>()
#include <utility>  // std::swap()
#include <numeric>  // accumulate(ALL(vec), 0)  0 は初期値
#include <bitset>  // static_cast<std::bitset<8>>
#include <sstream>  // std::stringstream
#include <cmath>
#include <climits>  // INT_MIN
#include <cctype>  // std::isdigit()
#include <iomanip>  // std::setprecision()
using namespace std;

#define ALL(obj) (obj).begin(), (obj).end()
#define REP(i, n) for (int i=0; i < (int)(n); i++)  // 0 ~ n-1
#define REPN(i, n) for (int i=1; i <= (int)(n); i++)  // 1 ~ n
#define MIN(vec) min_element(ALL((vec)))  // イテレータのため、値を取り出すときは * を先頭につける
#define MAX(vec) max_element(ALL((vec)))
#define IDX(vec, element_iter) distance((vec).begin(), element_iter)
#define SUM(vec) accumulate(ALL((vec)), 0)  // 0 は初期値
#define COPY(vec1, vec2) copy(ALL(vec1), back_inserter(vec2))  // vec1をvec2にコピーする vec2は空にしておく必要あり
typedef long long ll;

const int MOD = 1000000007;  // 1 000 000 007


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

    // input
    string str;
    cin >> str;
    
    // calculation
    size_t len = str.length();
    
    cout << str[0] << len-2 << str[len-1] << "\n";
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <vector>
#include <algorithm>
#include <set>
using namespace std;

int main()
{
    int n;
    string s;
    cin >> n >> s;
    vector<int> array(1);
    array.at(0) = 0;
    int i,x = 0;
    for(i = 0;i < n;++i){
        if(s.at(i) == 'I'){
            ++x;
        }else{
            --x;
        }
        array.push_back(x);
    }
    sort(array.begin(),array.end());
    cout << array.at(n) << endl;
    return 0;
}

Measured memory_bytes: 256
#pragma GCC optimize ("O3")
#include <bits/stdc++.h>
#ifdef ONLINE_JUDGE
#define LLD "%I64d"
#else
#define LLD "%lld"
#endif
#define fu(a,b,c) for(int a=b;a<=(int)c;++a)
#define fd(a,b,c) for(int a=b;a>=(int)c;--a)
#define cu(a,b,c) for(int a=b;a<(int)c;++a)
#define cd(a,b,c) for(int a=(b)-1;a>=(int)c;--a)
#define gcd(a,b) __gcd(a,b) 
#define pii pair<int,int>
#define pll pair<long long,long long>
#define all(a) a.begin(),a.end()
#define F first
#define S second
#define pb push_back
#define pf push_front
#define uint unsigned int
#define MOD 1000000007
#define MAXN 200005
#define MAXH 4
#define MAXM 100
#define INF 1LL << 60
#define ll long long
#define ull unsigned long long
#define RNG rng mt19937(time(NULL))
#define udist(a,b) uniform_int_distribution<uint32_t> distribution(a,b)
#define max3(a,b,c) max(a, max(b, c))
#define min3(a,b,c) min(a, min(b, c))
#define gmax(a,b) a = max(a, b)
#define gmin(a,b) a = min(a, b)
#define whatis(x) cerr << #x << " is " << x << endl;
#define mat vector<vector<T>>
#define T long long
#define fast_io() ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define cld complex<long double>
using namespace std;
const int N = 1005;
ll xa,ya,xb,yb;
vector<pll> g[N];

long double d[N];

inline ll sq(ll x){
	return x * x;
}

struct circ{
	ll x,y,r;
	long double dist(const circ &a){
		return max(sqrt(sq(x - a.x) + sq(y - a.y)) - r - a.r, 0.0) ;	
	}
} c[N];

int main(){
	fast_io();
	cin >> xa >> ya >> xb >> yb;
	int n;cin >> n;
	c[0] = {xa,ya,0};
	fu(i,1,n){
		int x,y,r;cin >> x >> y >> r;	
		c[i]	= {x,y,r};
	}
	c[n+1] = {xb,yb,0};
	fu(i,0,n+1)d[i] = 1e18;
	priority_queue<pair<long double,int>, vector<pair<long double,int>>, greater<pair<long double,int>>> pq;
	pq.push({0,0});
	while(pq.size()){
		long double dist = pq.top().F;
		int ind = pq.top().S;
		pq.pop();
		if(d[ind] > dist){
			d[ind] = dist;
			fu(i,1,n+1){
				if(i == ind)continue;
				long double ext = c[ind].dist(c[i]);
				if(dist + ext < d[i]){
					pq.push({dist + ext, i});	
				}
			}
		}
	}
	cout.precision(19);
	cout << d[n+1] << '\n';
}


Measured memory_bytes: 18664
#include <stdio.h>

int main(void)
{
	int n, m, i, j;
	scanf("%d %d", &n, &m);

	int A[n][m];
	int b[m];

	for (i = 0; i < n; i++) {
		for (j = 0; j < m; j++) {
			int a_ij;
			scanf("%d", &a_ij);
			A[i][j] = a_ij;
		}
	}

	for (i = 0; i < m; i++) {
		int b_i;
		scanf("%d", &b_i);
		b[i] =b_i;
	}

	for (i = 0; i < n; i++) {
		int c_i = 0;
		for (j = 0; j < m; j++) {
			c_i += A[i][j] * b[j];
		}
		printf("%d\n", c_i);
	}

	return 0;
}

Measured memory_bytes: 640
#include<stdio.h>
#include<stdlib.h>
#include<math.h>

int main()
{
    long long int N, i, sum=0;
    scanf("%lld", &N);
    for(i=1;i<=N;i=i+1)
    {
        if(i%5==0 && i%3==0)
        {
            continue;
        }
        else if(i%5!=0 && i%3==0)
        {
            continue;
        }
        else if(i%5==0 && i%3!=0)
        {
            continue;
        }
        else
        {
            sum=sum+i;
        }
    }
    printf("%lld\n", sum);   
}

Measured memory_bytes: 1736
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <math.h>
#include <limits.h>
int main(){
    long long n,passed=0,j=0,k=0,div=1,i=0,l=0,a[20]={};
    char ans[20]={};
    scanf("%lld",&n);
    if(n<=26){
        printf("%c",96+n);
        return 0;
    }
    while(n>0){
        a[k]=(n%26);
        if(n%26==0){
            a[k]=26;
            n-=26;
        }
        n-=(n%26);
        n/=26;
        k++;
    }
    for(i=k-1; i>=0; i--){
        ans[i]=a[k-1-i]+96;
    }
    printf("%s",ans);
    return 0;
}

Measured memory_bytes: 1728
#include <iostream>
#include <algorithm>
#include <cstring>
#include <cmath>
#include <vector>
#include <set>
#include <queue>
#include <map>
#include <string>

#define rep(i, a, b) for ( int i = (a); i < (b); i++ )
#define per(i, a, b) for ( int i = (b)-1; i >= (a); i--)
#define pb push_back
#define mp make_pair
#define bg begin()
#define en end()
#define all(v) (v).begin(), (v).end()
#define sz(v) (int)(v).size()


using namespace std;

typedef long long ll;

static const long long MOD = 1000000007;
static const long long LINF = (long long)(1e18+99);
static const int INF = 1000000099;

ll n,  c[30], ans = 1;
string s;
 //解説あり
int main(void) {
  cin >> n >> s;
  rep(i, 0, n) c[s[i]-'a']++;
  
  rep(i, 0, 26){
    if (c[i]>0) ans *= c[i]+1;
    ans %= MOD;
  }
  
    cout << ans-1 << endl;
    return 0;
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define EPS 0.0000000001
#define INF 1000000000
#define MOD 1000000007
typedef long long ll;

int main()
{
    int n;
    cin>>n;
    vector<pair<int,int>> p(n);
    vector<int> r(n);
    for(int i=0;i<n;i++){
        cin>>p.at(i).first;
        p.at(i).second=i;
        r.at(i)=p.at(i).first;
    }
    sort(all(p));
    ll count=0;
    for(int i=0;i<n;i++){
        if(p.at(i).second!=i){
            count++;
        }
    }
    if(count==0||count==2){
        cout<<"YES"<<endl;
    }
    else{
        cout<<"NO"<<endl;
    }


}

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

int main(){
    int N, tmp, ans=0;
    cin >> N;
    for (int n = 1; n <= N; ++n){
        tmp = 0;
        if (n%2 == 0) continue;

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

        if (tmp==8) ans += 1;
    }
    cout << ans << endl;
}

Measured memory_bytes: 3540
#include<iostream>
#include <deque>
using namespace std;
int main(){
    deque<int> deq;
    int n;
    cin>>n;
    int a,b,c;
    while(n--){
        cin>>a;
        if(a==0){
            cin>>b>>c;
            if(b==0){
                deq.push_front(c);
            }
            else {
                deq.push_back(c);
            }
        }
        else if(a==1){
            cin>>b;
            cout<<deq[b]<<endl;
        }
        else{
            cin>>b;
            if(b==0){
                deq.pop_front();
            }
            else{
                deq.pop_back();
            }
        }
    }
    return 0;
}


Measured memory_bytes: 4588
#include<iostream>
#include<vector>
#define rep(i,n) for(int i=0; i<n; i++)
using namespace std;

int main(){
    int N, d, sum=0;
    vector<int> v;

    cin >> N;
    rep(i, N){
        cin >> d;
        v.push_back(d);
    }

    rep(i, N-1){
        for(int j=i+1; j<N; j++){
            sum += v[i] * v[j];
        }
    }
    cout << sum;

    return 0;
}

Measured memory_bytes: 256
while True:
    a,op,b = input().split()
    a = int(a)
    b = int(b)
    if op == '?':
        break
    if op == '+':
        print(a+b)
    elif op == '-':
        print(a-b)
    elif op == '*':
        print(a*b)
    elif op == '/':
        print(a//b)



Measured memory_bytes: 5596
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
#define rep(i, n) for(int i = 0; i < n; i++)
#define REP(i, a, b) for(int i = a; i <= b; i++)
#define all(x) x.begin(), x.end()
#define fi first
#define se second
#define debug(...) cerr<<__LINE__<<" ["<<#__VA_ARGS__<<"]:",debug_out(__VA_ARGS__)
template <typename T> ostream &operator<<(ostream &os, const vector<T> &vec)
{ for (auto v : vec) os << v << ' '; os << '\n'; return os; }
template <typename T1, typename T2> ostream &operator<<(ostream &os, const pair<T1, T2> &pa)
{ os << '(' << pa.first << ',' << pa.second << ')'; return os; }
void debug_out() { cerr << endl; }
template <typename Head, typename... Tail> void debug_out(Head H, Tail... T)
{ cerr << " " << H; debug_out(T...); }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
const int INF = (1<<30) - 1;
const ll LINF = (1LL<<60) - 1;

void solve() {
    int n;
    cin >> n;
    vector<int> V(n);
    rep(i, n) cin >> V[i];
    sort(all(V));
    double ans = V[0];
    rep(i, n - 1) {
        ans += V[i + 1];
        ans /= 2;
    }
    cout << ans << endl;
}

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


Measured memory_bytes: 3836
N,T = (int(i) for i in input().split())

kei = []
for _ in range(0, N):
    c,t = (int(i) for i in input().split())
    kei.append((c,t))

res = 10000
for tmp in kei:
    if tmp[1] <= T:
        if res > tmp[0]:
            res = tmp[0]

if res == 10000:
    print("TLE")
else:
    print(res)


Measured memory_bytes: 3060
#include <bits/stdc++.h>
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define sz(x) (int)((x).size())
#define debug(x) cout << #x << ":" << x << ' ';
#define debugg(x) cout << #x << ":" << x << ' ' << "\n";
#define endl "\n"
#define L(X) ((X)<<1)
#define R(X) (((X)<<1)|1)
#define M(X,Y) (((X)+(Y))>>1)

using namespace std;
using ll = long long;
using ull = unsigned long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;

const int MAXN = 110;
const int MOD = 1e9 + 7;
const int INF = 0x3f3f3f3f;
const long long int LLINF = 0x3f3f3f3f3f3f3f3f;
const double EPS = 1e-9;
const double PI = acos(-1);

template<typename T>   T max_self(T& a, T b) { if (a < b) a = b; return a; }
template<typename T>   T min_self(T& a, T b) { if (a > b) a = b; return a; }
template<typename T>   T add(T x, T y) { return ((x % MOD)  + (y % MOD)) % MOD;}
template<typename T>   T mul(T x, T y) { return ((x % MOD) * (long long)(y % MOD)) % MOD;}
template<typename T>   T sub(T x, T y) { return add(x, -y + MOD);}
template<typename T>   T gcd(T a, T b) { return b ? gcd(b, a % b) : a;}
template<typename T>   T lcm(T a, T b) { return a / gcd(a, b) * b;}
template<typename T>   vector<T> read(vector<T>& v, int n) {v.resize(n); for (auto &x : v)cin >> x;}
template<typename T>   void trav(vector<T> &v) {for (int i = 0 ; i < (int)v.size() ; ++i) {cout << v[i]; if (i != (int)v.size() - 1) cout << ' ';}}
int lg2(long long x)   {   return 64 - __builtin_clzll(x) - 1;	}
int lg2(int x)   {   return 32 - __builtin_clzll(x) - 1;	}

ll dp[MAXN][100005];
ll weight[MAXN], value[MAXN];

ll solve(int n, int w) {
	if(w < 0) return -INF;
	if(n < 1 && w >= 0) return 0;
	if(n < 1 || w < 0) return -INF;
	if(dp[n][w] != -1) return dp[n][w];
	return dp[n][w] = max(value[n] + solve(n - 1, w - weight[n]), solve(n - 1, w));
}

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

	int n, w;
	cin >> n >> w;

	memset(dp, -1, sizeof dp);

	for(int i = 1 ; i <= n ; ++i) {
		cin >> weight[i] >> value[i];
	}

	cout << solve(n, w) << endl;

	return 0;
}


Measured memory_bytes: 86272
//fast i/o functions will not work for negative values
 
 
#include<bits/stdc++.h>
using namespace std;
typedef long long lo;
typedef pair<lo,lo> ll;//pair
typedef vector<lo> vl;  //vector of long
typedef vector<ll > vll;   //vector of pair
typedef priority_queue<lo>p_q;
//#define mp(a,b) make_pair((a),(b))
#define REP(a,b) for(lo i=(a);i<(b);i++)//no need to declare variable i
#define REPE(a,b,c,d) REP(a,b)for(lo j=(c);j<(d);j++)//no need to declare vaiables i,j 
#define REPV(a,b,c) for((a)=b;(a)<(c);(a)++)//a is the variable 
#define IREP(a,b) for(lo i=(a);i>=(b);i--)
#define IREPV(a,b,c) for((a)=b;(a)>=(c);(a)--)
#define all(v) (v).begin(),(v).end()
#define TRvl(c) for (vl::iterator it = (c).begin(); it != (c).end(); it++)
#define TRvll(c) for (vll::iterator it = (c).begin(); it != (c).end(); it++)
#define INF 2000000000
#define gc getchar_unlocked
#define pc putchar_unlocked
#define pb(a) push_back((a))
 
lo fact(lo n)
{
    if(n > 1)
        return n * fact(n - 1);
    else
        return 1;
}
 
 
int main(){
	lo t,n,m,x,i,j,sum;
	string s;
	cin>>s;
	REP(0,s.length()){
		if(i%2==0){cout<<s[i];}
	}
	return 0;
}

Measured memory_bytes: 512
#include <vector>
#include <queue>
#include <algorithm>
#include <iostream>
#include <string>
#include <tuple>
#include <set>
#include <map>
#include <unordered_map>
#include <complex>
#include <iomanip>
#include <cmath>
using namespace std;
typedef long long ll;

int main()
{
  int a, b;
  cin >> a >> b;
  cout << 2 * b - a << endl;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#define N 101
#define WHITE 0
#define GRAY 1
#define BLACK 2
 

int STACK[N];
int top = 0;
int n;
int TIME = 0;
int A[N][N];
int color[N];
int dis[N];
int fin[N];

void S_push(int i){
  top++;
  STACK[top] = i;
}

void S_pop(){
  top--;
 
}
int S_top(){
  return STACK[top];
}
int next (int a){
  int i;

  for(i=1;i<=n;++i){
    if(A[a][i]==1 && color[i]==WHITE) return i;
  }

  return -1;
}


void visit(int r){
  int u,v,i;

  S_push(r);
  color[r] = GRAY;
  dis[r] = ++TIME;

  while(top != 0){
    u = S_top();
    v = next(u);

    if(v != -1){
      S_push(v);
      color[v] = GRAY;
      dis[v] = ++TIME;
    }

    else {
      S_pop();
      color[u] = BLACK;
      fin[u] = ++TIME;
    }
  }
  
}

void dfs(){
  int i;

  for(i=1;i<=n;++i){
    color[i] = WHITE;
  }
  
  for(i=1;i<=n;++i){
    if(color[i] == WHITE) visit(i);
  }
  
}



int main(){
  int i,j,m,l,b;
 
  scanf("%d",&n);

  for(i=1;i<=n;++i){
    for(j=1;j<=n;++j)A[i][j]=0;
  }
  

  for(i=1;i<=n;++i){
    scanf(" %d %d",&m,&l);
     
    for(j=1;j<=l;++j){
      scanf("%d",&b);
      A[m][b] = 1;
    }
  }

  
  dfs();

  for(i=1;i<=n;++i){
    printf("%d %d %d\n",i,dis[i],fin[i]);

  }
 
  return 0;
}



Measured memory_bytes: 2128
#include <iostream>
#include <fstream>
#include <set>
#include <map>
#include <string>
#include <vector>
#include <queue>
#include <deque>
#include <stack>
#include <functional>
#include <algorithm>
#include <climits>
#include <cmath>
#include <iomanip>
using namespace std;
#define ll long long int
#define rep(i,n) for( int i = 0; i < n; i++ )
#define rrep(i,n) for( int i = n; i >= 0; i-- )
#define REP(i,s,t) for( int i = s; i <= t; i++ )
#define RREP(i,s,t) for( int i = s; i >= t; i-- )
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define INF 2000000000
#define mod 1000000007
#define INF2 1000000000000000000

int c[10] = {0, 2, 5, 5, 4, 5, 6, 3, 7, 6};
int dp[5010][10010];
int main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N, M;
    cin >> N >> M;
    int A[10];
    
    
    rep(i, 5010) rep(j, 10010) dp[i][j] = -INF;
    dp[0][N] = 0;
    rep(i, M) cin >> A[i];
    sort(A, A + M, greater<int>());
    for(int i = 0; i < N/2; i++) {        
        for(int k = 10000; k >= 0; k--) {
            for(int j = 0; j < M; j++) {
                dp[i + 1][k] = max(dp[i + 1][k], dp[i][k]);
                int cost = k - c[A[j]];
                if(cost >= 0) {
                    dp[i + 1][cost] = max(dp[i + 1][cost], dp[i][k] + 1);
                }
            }
        }
    }
    string T;
    int num = 0;
    for(int i = N/2; i > 0; i--) {
        for(int j = 0; j < M; j++) {
            if(dp[i][num] == dp[i - 1][num + c[A[j]]] + 1) {
                num += c[A[j]];
                T += (char)('0' + A[j]);
                break;
            }
        }
    }
    cout << T << endl;



    return 0;
}


Measured memory_bytes: 199516
#include <bits/stdc++.h>
using namespace std;
int main() {
  int x, ans = 1;
  cin >> x;
  int n = sqrt(x);
  for (int i = n; i > 1; i--) {
    int j = i * i;
    while (j <= x) {
      ans = max(ans, j);
      j *= i;
    }
  }
  cout << ans;
}

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

#define ll long long
#define INF 99999999
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()

template < typename T > std::string to_string( const T& n )
{
    std::ostringstream stm ;
    stm << n ;
    return stm.str() ;
}

int main()
{
    int N,K,R,S,P;
    cin >> N >> K >> R >> S >> P;

    string T;
    cin >> T;

    vector<multiset<char> >t(K);
    vector<set<char> > key(K);
    rep(i,T.size())
    {
        if( i < K )
        {
            t[i].insert( T[i] );
            key[i].insert( T[i] );
        }
        else if( T[i] != T[i-K] )
        {
            t[ i%K ].insert( T[i] );
            key[i%K].insert( T[i] );
        }
        else T[i] = '*';
    }
    ll ans = 0;
    rep(i,t.size())
    {
        ll R_ans = 0;
        ll P_ans = 0;
        ll S_ans = 0;
        for( set<char>::iterator itr = key[i].begin(); itr != key[i].end(); itr++ )
        {
            if( *itr == 'r' ) P_ans += t[i].count(*itr);
            else if( *itr == 'p' ) S_ans += t[i].count(*itr);
            else R_ans += t[i].count(*itr);
        }
        //cout << "R is " << R_ans << " and S is " << S_ans << " and P is " << P_ans << endl;
        ans += R_ans * R + S_ans * S + P_ans * P;
    }
    cout << ans << endl;
}


Measured memory_bytes: 17536
use std::collections::BTreeSet;

fn main() {
    let s = std::io::stdin();
    let mut sc = Scanner { stdin: s.lock() };
    let n: usize = sc.read();
    let k: usize = sc.read();
    let a: Vec<usize> = sc.vec(n);
    let max_a = a.iter().cloned().max().unwrap();
    let mut next = vec![vec![]; max_a + 1];
    let mut pos = vec![0; n];
    for (i, &a) in a.iter().enumerate() {
        pos[i] = next[a].len();
        next[a].push(i);
    }

    let mut jumped = false;
    let mut cur_t = 0;
    let mut cur_pos = 0;
    let mut prev = vec![std::usize::MAX; n];
    prev[0] = cur_t;
    loop {
        let pos = pos[cur_pos];
        if next[a[cur_pos]].len() == pos + 1 {
            if cur_t == k - 1 {
                let mut ans = vec![];
                let mut set = BTreeSet::new();
                for i in cur_pos..n {
                    if set.contains(&a[i]) {
                        while let Some(tail) = ans.pop() {
                            set.remove(&tail);
                            if tail == a[i] {
                                break;
                            }
                        }
                    } else {
                        ans.push(a[i]);
                        set.insert(a[i]);
                    }
                }

                for (i, a) in ans.into_iter().enumerate() {
                    if i > 0 {
                        print!(" ");
                    }
                    print!("{}", a);
                }
                println!();
                return;
            }
            cur_t += 1;
            cur_pos = next[a[cur_pos]][0];
        } else {
            cur_pos = next[a[cur_pos]][pos + 1]
        }
        cur_pos += 1;
        if cur_pos == n {
            if cur_t == k - 1 {
                println!();
                return;
            }
            cur_t += 1;
            cur_pos = 0;
        }
        if !jumped && prev[cur_pos] < cur_t {
            let dt = cur_t - prev[cur_pos];
            let z = (k - prev[cur_pos] - 1) / dt;
            cur_t = prev[cur_pos] + dt * z;
            assert!(cur_t < k);
            jumped = true;
        } else {
            prev[cur_pos] = cur_t;
        }
    }
}

pub struct Scanner<R> {
    stdin: R,
}

impl<R: std::io::Read> Scanner<R> {
    pub fn read<T: std::str::FromStr>(&mut self) -> T {
        use std::io::Read;
        let buf = self
            .stdin
            .by_ref()
            .bytes()
            .map(|b| b.unwrap())
            .skip_while(|&b| b == b' ' || b == b'\n')
            .take_while(|&b| b != b' ' && b != b'\n')
            .collect::<Vec<_>>();
        unsafe { std::str::from_utf8_unchecked(&buf) }
            .parse()
            .ok()
            .expect("Parse error.")
    }
    pub fn vec<T: std::str::FromStr>(&mut self, n: usize) -> Vec<T> {
        (0..n).map(|_| self.read()).collect()
    }
    pub fn chars(&mut self) -> Vec<char> {
        self.read::<String>().chars().collect()
    }
}


Measured memory_bytes: 28028
#include <bits/stdc++.h>
using namespace std;
#define endl '\n'

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

    int n;

    cin >> n;

    if(n<1200) cout << "ABC";
    else if(n<2800) cout << "ARC";
    else cout << "AGC";
}


Measured memory_bytes: 892
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <algorithm>
#include <numeric>
#include <sstream>
#include <iostream>
#include <iomanip>
#define _USE_MATH_DEFINES
#include <cmath>
#include <climits>
#include <cstdlib>
#include <cstring>
#include <cfloat>
#include <cmath>
#include <ctime>
#include <cassert>
#include <cctype>
#include <cstdio>
#include <cassert>
using namespace std;

#define EPS 1e-12
#define ull unsigned long long
#define ll long long
#define VI vector<ll>
#define PII pair<ll, ll> 
#define VVI vector<vector<ll> >
#define VVVI vector<vector<vector<ll>>>
#define VVVVI vector<vector<vector<vector<ll>>>>
#define REP(i,n) for(ll i=0,_n=(n);(i)<(ll)_n;++i)
#define REPR(i,n) for(ll i=(ll)(n)-1;0<=(i);--i)
#define RANGE(i,a,b) for(ll i=(ll)a,_b=(ll)(b);(i)<_b;++i)
#define RANGER(i,a,b) for(ll i=(ll)(b)-1,_a=(ll)(a);(_a)<=i;--i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)
#define ALL(c) (c).begin(), (c).end()
#define ALLR(c) (c).rbegin(), (c).rend()
#define PB push_back
#define MP(a, b) make_pair(a, b)
#define POPCOUNT __builtin_popcount
#define POPCOUNTLL __builtin_popcountll
#define CLEAR(table, v) memset(table, v, sizeof(table));
#define UNIFORM_DOUBLE(a, b) (((b-a)*(double)rand()/RAND_MAX)+a) // [a, b) 
#define UNIFORM_LL(a, b) (ll)UNIFORM_DOUBLE(a, b) // [a, b) 
#define IN(v, lo, hi) ((lo)<=(v) && (v)<(hi))
#define DD(v) cout<<#v<<": "<<v<<endl
#define FI first
#define SE second
template <typename T0, typename T1> std::ostream& operator<<(std::ostream& os, const map<T0, T1>& v) { for( typename map<T0, T1>::const_iterator p = v.begin(); p!=v.end(); p++ ){os << p->first << ": " << p->second << " ";} return os; }
template <typename T0, typename T1> std::ostream& operator<<(std::ostream& os, const pair<T0, T1>& v) { os << v.first << ": " << v.second << " "; return os; }
template <typename T> std::ostream& operator<<(std::ostream& os, const vector<T>& v) { for( int i = 0; i < (int)v.size(); i++ ) { os << v[i] << " "; } return os; }
template <typename T> std::ostream& operator<<(std::ostream& os, const set<T>& v) { vector<T> tmp(v.begin(), v.end()); os << tmp; return os; }
template <typename T> std::ostream& operator<<(std::ostream& os, const deque<T>& v) { vector<T> tmp(v.begin(), v.end()); os << tmp; return os; }
template <typename T> std::ostream& operator<<(std::ostream& os, const vector<vector<T> >& v) { for( int i = 0; i < (int)v.size(); i++ ) { os << v[i] << endl; } return os; }
template<typename T>void maxUpdate(T& a, T b) {a = max(a, b);}
template<typename T>void minUpdate(T& a, T b) {a = min(a, b);}

#define MOD 1000000007LL
#define INF (1LL<<60)

ll f(ll a, ll b, ll c) {
	if(c<b && b<a) return 1;
	if(a<b && b<c) return 1;
	return 0;
}

int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	ll N;
	while(cin>>N) {
		VI w(N);
		REP(i, N) cin>>w[i];
		ll ans = 0;
		RANGE(i, 1, N-1) {
			ans += f(w[i-1], w[i], w[i+1]);
		}
		
		cout<<ans<<endl;
	}
	
	return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<set>
#include<string>
#include<stack>
#include<cstdio>
#include<cmath>
using namespace std;

typedef long long ll;
typedef long double ld;
typedef pair<int,int> P;
typedef pair<int,P> P1;

#define fr first
#define sc second
#define mp make_pair
#define pb push_back
#define rep(i,x) for(int i=0;i<x;i++)
#define rep1(i,x) for(int i=1;i<=x;i++)
#define rrep(i,x) for(int i=x-1;i>=0;i--)
#define rrep1(i,x) for(int i=x;i>0;i--)
#define sor(v) sort(v.begin(),v.end())
#define rev(s) reverse(s.begin(),s.end())
#define lb(vec,a) lower_bound(vec.begin(),vec.end(),a)
#define ub(vec,a) upper_bound(vec.begin(),vec.end(),a)
#define uniq(vec) vec.erase(unique(vec.begin(),vec.end()),vec.end())
#define mp1(a,b,c) P1(a,P(b,c))

const int INF=1000000000;
const int dir_4[4][2]={{1,0},{0,1},{-1,0},{0,-1}};
const int dir_8[8][2]={{1,0},{1,1},{0,1},{-1,1},{-1,0},{-1,-1},{0,-1},{1,-1}};

const ll M = 1000000007;

ll kaijou[500010];
void init(){
	kaijou[0] = 1;
	rep1(i,500009){
		kaijou[i] = kaijou[i-1] * i;
		kaijou[i] %= M;
	}
}

struct BIT{
	int siz;
	int s[1<<20+1];
	void init(){
		siz = 1<<20;
		rep1(i,siz)s[i] = 0;
	}
	void add(int a){
		while(a <= siz){
			s[a] ++;
			a += a&-a;
		}
	}
	int sum(int a){
		int ret = 0;
		while(a > 0){
			ret += s[a];
			a -= a&-a;
		}
		return ret;
	}
}bit;

int main(){
	init();
	bit.init();
	static int n;
	static int p[500010];
	scanf("%d",&n);
	rep(i,n)scanf("%d",&p[i]);
	
	static int K[500010] = {} , cnt[500010] = {};
	rep1(i,n)cnt[i] = 1;
	rep(i,n){
		K[i] = K[i-1];
		if(p[i] == 0){
			K[i] ++;
		}
		else {
			cnt[p[i]] = 0;
		}
	}
	K[n] = K[n-1];
	rep1(i,500009)cnt[i] += cnt[i-1];
	
	ll c=0,d=0,hoge = 0;
	rep1(i,n){
		if(cnt[i] > cnt[i-1]){
			c += i-1;
			d += cnt[i-1];
		}
	}
	c *= K[n]-1;
	c %= M;
	d %= M;
	
	ll ret = 0;
	rep(i,n){
		if(p[i] != 0){
			ll _ret = 0;
			_ret = kaijou[K[n]]*(p[i]-1-bit.sum(p[i])); _ret %= M;
			_ret += M-( (kaijou[K[n]-1]*K[i])%M*cnt[p[i]] )%M;
			_ret *= kaijou[n-i-1]; _ret %= M;
			ret += _ret; ret %= M;
			bit.add(p[i]);
			hoge += K[n]-cnt[p[i]];
			hoge %= M;
		}
		else {
			ll _ret = c;
			_ret +=M-( (K[n]-1)*hoge )%M;
			_ret +=M-( d*((i==0)?0:K[i-1]) )%M;
			_ret *= kaijou[n-i-1]; _ret %= M;
			_ret *= (K[n] < 2)?0:kaijou[K[n]-2];
			_ret %= M;
			ret += _ret;
			ret %= M;
		}
		/*else {
			ll _ret = 0;
			rep1(j,n){
				if(cnt[j] == cnt[j-1])continue;
				//cout << "__" << i << " " << j << endl;
				ll __ret = 0;
				__ret = kaijou[K[n]-1]*(j-1-bit.sum(j)); __ret %= M;
				//cout << __ret << endl;
				__ret += M-( (kaijou[K[n]-2]*((i==0)?0:K[i-1]))%M*cnt[j-1] )%M;
				//cout << __ret << endl;
				__ret *= kaijou[n-i-1]; __ret %= M;
				//cout << __ret << endl;
				_ret += __ret;
			}
			ret += _ret; ret %= M;
		}*/
		//cout << i << " " << ret << endl;
	}
	
	cout << (ret+kaijou[K[n]])%M << endl;
}


Measured memory_bytes: 14080
#include <bits/stdc++.h>
#include <string>
#define ft first
#define sc second
#define pt(sth) cout << sth << "\n"
#define chmax(a, b) (a)=max(a, b)
#define chmin(a, b) (a)=min(a, b)
#define moC(a, s, b) (a)=((a)s(b)+MOD)%MOD
using namespace std;
typedef long long ll;
typedef pair<ll, ll> pll;
static const ll INF=1e18;
static const ll MAX=101010;
static const ll MOD=1e9+7;

/*
 for(i=0; i<N; i++)
   cin >> a[i];
*/



int main(void) {
  ll i, j, k;
  
  ll K;
  cin >> K;
  ll a, b;
  cin >> a >> b;
  
  for(i=a; i<=b; i++) {
    if(i%K==0) {
      pt("OK");
      return 0;
    }
  }
  
  pt("NG");
  
}
 
 


Measured memory_bytes: 3636
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
sys.setrecursionlimit(10 ** 7)

n, k = map(int, read().split())
memo = (n // k) ** 3
if k % 2 == 0:
    memo += ((n + k // 2) // k) ** 3
print(memo)


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

//#pragma GCC optimize ("Ofast")
//#pragma GCC target ("avx,avx2")

#define rep(i, n)    for(int i = 0; i < (n); ++i)
#define repA(i, a, n)  for(int i = a; i <= (n); ++i)
#define repD(i, a, n)  for(int i = a; i >= (n); --i)
#define mp make_pair
#define pb push_back
#define X first
#define Y second
#define dbg(x) cerr<<#x<<" : "<<x<<endl

typedef long long int ll;
typedef long double ld;
typedef pair<ll, ll> pii;
typedef vector<ll> vi;
typedef vector<pii> vii;
const ll INF = 1e18+1;
const ll MOD = 1000000007L;
clock_t time_p=clock();
void timer(){time_p=clock()-time_p;cerr<<"Time Taken : "<<(float)(time_p)/CLOCKS_PER_SEC<<"\n";}

template <typename Arg1> ostream& operator << (ostream& out, const vector<Arg1> &a) {out<<"[ ";for(const auto &x:a)out<<x<<" ";return out<<"]";}

vector<set<ll>>adj;


int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);

    ll n;
    cin>>n;
    adj.assign(n,{});
    rep(i,n-1){
        ll u,v;
        cin>>u>>v;
        u--;v--;
        adj[u].insert(v);
        adj[v].insert(u);
    }

    if(n<=3){
        if(n%2==1) cout<<"First\n";
        else cout<<"Second\n";
        exit(0);
    }

    vi white(n,0);
    queue<ll>q;
    vi visited(n,0);
    rep(i,n){
        if(adj[i].size() == 1){ //leaf
            q.push(i);
            visited[i]=1;
        }
    }


    ll ctr = n;
    vi processed(n,0);

    while(!q.empty()){ //leaves
        ll cur = q.front();
        /*
         *for(auto x:adj[cur]) cout<<x<<",";
         *cout<<endl;
         */

        q.pop();
        if(processed[cur] == 1){
            continue;
        }
        if(adj[cur].size() == 0) {
            cout<<"First\n"; exit(0);
        }
        ll par=*adj[cur].begin();
        visited[par]=1;

        processed[par]=1;
        processed[cur]=1;

        vi toRemove;
        for(auto x : adj[par]){
            if(x != cur){
                adj[x].erase(par);
                if(adj[x].size() == 0) {
                    cout<<"First\n"; exit(0);
                }
                if(adj[x].size() == 1){
                    visited[x] = 1;
                    q.push(x);
                }
            }
            toRemove.pb(x);
        }
        adj[cur].erase(par);
        for(auto x:toRemove) adj[par].erase(x);
    }

    cout<<"Second\n";
    exit(0);


    timer();
    return 0;
}


Measured memory_bytes: 17152
package main

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

var sc *bufio.Scanner

const BufferSize = 1024

func nextString() string {
	if !sc.Scan() {
		panic(nil)
	}
	return sc.Text()
}

var production bool

func debugf(format string, v ...interface{}) {
	if !production {
		fmt.Printf(format, v...)
	}
}
// ? .. 1
// ?? .. 8 (5,18,31,44,57,70,83,96)
// ??? ..

func answer(reader io.Reader, writer io.Writer) {
	sc = bufio.NewScanner(reader)
	buf := make([]byte, BufferSize)
	sc.Buffer(buf, 1e+6)
	sc.Split(bufio.ScanWords)
	s := nextString()
	a := make([]int, 13)
	b := make([]int, 13)
	mod := int(1e9) + 7
	offset := 1
	// i == 0
	if string(s[len(s)-1]) == "?" {
		m := 0
		for j:=0;j<10;j++{
			a[m] = 1
			m += offset
			m %= 13
		}
	} else {
		n, _ := strconv.Atoi(string(s[len(s)-1]))
		m := (offset * n) % 13
		a[m%13] = 1
	}
	debugf("a[%d]: %v\n", 0, a)
	for i:=0;i<13;i++{
		b[i] = a[i]
		a[i] = 0
	}
	offset = (offset * 10) % 13

	// i> 0
	for i:=1;i<len(s);i++{
		if string(s[len(s)-i-1]) == "?" {
			m := 0
			for j:=0;j<10;j++{
				for k:=0;k<13;k++{
					a[(k+m)%13] += b[k]
					a[(k+m)%13] %= mod
				}
				m += offset
				m %= 13
			}
		} else {
			n, _ := strconv.Atoi(string(s[len(s)-i-1]))
			m := (offset * n) % 13
			for k:=0;k<13;k++{
				a[(k+m)%13] = b[k]
			}
		}
		debugf("a[%d]: %v\n", i, a)
		for i:=0;i<13;i++{
			b[i] = a[i]
			a[i] = 0
		}
		offset = (offset * 10) % 13
	}
	debugf("b: %v\n", b)
	_, _ = fmt.Fprintf(writer, "%d", b[5])
}

func main() {
	production = true
	answer(os.Stdin, os.Stdout)
}


Measured memory_bytes: 5376
#include <bits/stdc++.h>
using namespace std;
typedef long long       ll;
typedef pair<int,int>   ii;
typedef vector<int>     vi;
typedef vector<ii>      vii;
typedef set<int>        si;
typedef set<ii>         sii;

#define all(x) x.begin(),x.end()
#define clr(x,v) memset(x,v,sizeof x)
#define sz(x) (int)x.size()
#define forn(i,a,b) for(int i=a;i<b;i++)
#define re return

template<typename T> T sgn (T x)      {re x<0? -1:(x>0? 1:0); }
template<typename T> T gcd (T a, T b) {re a ? gcd (b % a, a) : b; }
template<typename T> T abs (T x)      {re x < 0 ? -x : x; }
template<typename T> T sqr (T x)      {re x*x;}

#define _ ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define pb push_back
#define ins insert
#define y second
#define x first
#define endl "\n"
#define MOD (int)1e9+7
#define N (int)2e5+123

int n;

void solve(){
    cin >> n;
}
int main(){_
    ll sa,fa,sb,fb;
    cin >> sa >> fa >> sb >> fb;
    int i=0;
    while(1){
        sb-=fa;
        if(sb<=0){
            cout<<"Yes"<<endl;
              return 0;
        }
        sa-=fb;
        if(sa<=0){
            cout << "No"<<endl;
            return 0;
        }
        
    }
    
}

Measured memory_bytes: 3632
#include<iostream>
#include<algorithm>
#include<vector>
#include<string>
#include<stdio.h>
#include<deque>
#include<map>
#include<queue>

typedef long long ll;

#define debug(x) cout << #x << "=" << x << endl;
#define debug_arr(a, n) for(ll i = 0; i < n; i++)cout << a[i] << " "
#define inf 100000000000
#define loop(i,n) for(ll i = 0; i < n; i++)
#define graph vector<vector<ll>>
#define P pair<ll,ll>

using namespace std;

ll mod = 1000000007;

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

ll exp(ll x, ll n){
    if(n == 1)return x;
    if(n % 2 == 1) return multipy(exp(x,n-1) ,x );

    ll a = exp(x, n/2);
    return multipy(a,a);
}

// aCb
ll combination(ll a,ll b){
    if(b == 0)return 1;

    ll result = 1;

    for(ll i=a; i>a-b; i--){
        result = multipy(i,result);
    }

    ll bunbo = 1;
    for(ll i = 1; i <= b; i++){
        bunbo = multipy(bunbo,i);
    }


    bunbo = exp(bunbo, mod - 2);

    return multipy(bunbo, result);

}

int main(){
    ll x,y,a,b;
    cin >>x >>y;

    ll haveAnswer = 0;

    for(ll i = 0;i<= x;i++){
        a = i;
        if((x - i) % 2 == 1) continue;
        b = (x - i) / 2;
        if(y == b + a * 2) {
            haveAnswer = 1;
            break;
        }
    }

    
    if(!haveAnswer){
        cout << 0 << endl;
        return 0;
    }

    ll result;
    result =  combination(a+b,a);

    cout << result << endl;

    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include<math.h>
#include<list>
#include <algorithm>
#include<set>
#include<vector>
#include<math.h>
#include<map>
#include<string>
#include <numeric>
#include <queue>
#include <sstream>
#include <bitset>
#include<stack>
#include<functional>
#include<unordered_set>
#include<unordered_map>

using namespace std;
using ll = long long;
using vll = vector<long long>;
using sll = set<long long>;
const long long ll_max = 9223372036854775807;
const long long ll_min = -9223372036854775807;
const int int_max = 2147483647;

template<typename T>
T gcd(T a, T b) { return b ? gcd(b, a % b) : a; }
template<typename T>
T lcm(T a, T b) { return a / gcd(a, b) * b; }

template<typename T>
map<T, T> getPrimeFactor(T n) {
	map<T, T> ret;
	for (T i = 2; i * i <= n; ++i) {
		while (n % i == 0) {
			ret[i] ++;
			n /= i;
		}
	}
	if (n != 1) ret[n] = 1;
	return ret;
}

template<typename T>
bool IsPrimeNumber(T num)
{
	if (num <= 2) return true;
	else if (num % 2 == 0) return false;

	double sqrtNum = sqrt(num);
	for (int i = 3; i <= sqrtNum; i += 2)
	{
		if (num % i == 0)
		{
			return false;
		}
	}

	return true;
}

template<typename T>
T modinv(T a, T m) {
	T b = m, u = 1, v = 0;
	while (b) {
		long long t = a / b;
		a -= t * b; swap(a, b);
		u -= t * v; swap(u, v);
	}
	u %= m;
	if (u < 0) u += m;
	return u;
}



// 繰り返し二乗法
ll pow2(ll n, ll p, ll mod) {
	if (p == 0 || n == 1) {
		return 1;
	}
	else {
		ll ret = pow2(n * n % mod, p / 2, mod);
		if (p % 2 == 1) {
			ret *= n;
		}
		return ret % mod;
	}
}


#define rep(i,s,e) for(ll i=s;i<e;i++)
#define repeq(i,s,e) for(ll i=s;i<=e;i++)



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

	ll ans = 0;
	ll x = n / k;
	ans = x * x * x;
	if (!(k & 1)) {
		
		ll y = n / (k / 2) - x;
		ans += y * y * y;
	}

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


Measured memory_bytes: 3624
import java.util.Scanner;

public class Main {

	static Scanner scanner;

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

	    long A=gl();
	    long B=gl();
	    long ab=A*B;

	    	System.out.print(ab);

//        if (flg) {
//        	System.out.print("YES");
//        }else {
//        	System.out.print("NO");
//        }


	}

	// 文字列として入力を取得
	public static String gs() {
		return scanner.next();
	}

	// intとして入力を取得
	public static int gi() {
		return Integer.parseInt(scanner.next());
	}

	// longとして入力を取得
	public static long gl() {
		return Long.parseLong(scanner.next());
	}

	// doubleとして入力を取得
	public static double gd() {
		return Double.parseDouble(scanner.next());
	}
}

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

using namespace std;
typedef long long ll;
inline int read()
{
	int x=0,f=1; char ch=getchar();
	while(ch<'0'||ch>'9'){if(ch=='-')f=-1; ch=getchar();}
	while(ch>='0'&&ch<='9'){x=x*10+ch-'0'; ch=getchar();}
	return x*f;
}
struct edge
{
	int v,next,w;
}vs[300010];
int n,ee,st[300010],size[300010],Rt,vl;
ll Ans;
inline void addedge(int u,int v,int w)
{
	//cout << u << " " << v << " " << w << endl;
	vs[++ee].v=v; vs[ee].next=st[u];
	st[u]=ee; vs[ee].w=w;
}
inline void dfs(int rt,int pr)
{
	int mx=0; size[rt]=1;
	for(int i=st[rt];i;i=vs[i].next)
	{
		if(vs[i].v==pr) continue;
		dfs(vs[i].v,rt);
		Ans+=1ll*min(size[vs[i].v],n-size[vs[i].v])*vs[i].w;
		size[rt]+=size[vs[i].v];
		mx=max(mx,size[vs[i].v]);
	}
	if(n-size[rt]>mx) mx=n-size[rt];
	if(mx<vl) Rt=rt,vl=mx;
}
int main()
{
	n=read(); Rt=-1; vl=n;  for(int i=1;i<n;i++)
	{
		int u=read(), v=read(), w=read();
		addedge(u,v,w); addedge(v,u,w);
	}
	dfs(1,0); dfs(Rt,0); 
	int minz=0x3fffffff;
	for(int i=st[Rt];i;i=vs[i].next)
	{
		if(size[vs[i].v]==n/2&&n%2==0)
		{
			minz=vs[i].w; break;
		}
		minz=min(minz,vs[i].w);
	}
	cout << Ans - minz << endl;
	return 0 ;
}

Measured memory_bytes: 6144
#include <cstdio>
#include <cstring>
#include <vector>
#include <queue>
#include <string>
#include <algorithm>
#include <iostream>
#include <string>
#include <map>
#include <set>
#include <functional>
#include <iostream>
#define MOD 1000000007LL
using namespace std;
typedef long long ll;
typedef pair<int,int> P;

int n;
ll a[1000005];
ll dp[1000005][2];

int main(void){
	scanf("%d",&n);
	for(int i=0;i<n;i++){
		scanf("%lld",&a[i]);
	}
	memset(dp,-1,sizeof(dp));
	dp[0][0]=0;
	for(int i=0;i<n;i++){
		for(int j=0;j<2;j++){
			if(dp[i][j]<0)continue;
			ll use=(ll)a[i]+j;
			dp[i+1][min(use%2,a[i])]=max(dp[i+1][min(use%2,a[i])],dp[i][j]+use/2LL);
		}
	}
	printf("%lld\n",max(dp[n][0],dp[n][1]));
	return 0;
}


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

using namespace std;

using ll = long long;

constexpr char newl = '\n';

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

    int n, x, t;
    cin >> n >> x >> t;
    cout << (n + x - 1) / x * t << newl;

    return 0;
}

Measured memory_bytes: 3564
#include <bits/stdc++.h>
#define F first
#define S second

using namespace std;
typedef long long int64;

int64 a, b, n;

int64 f(int64 x) {
	int64 res = a * x / b - a * (x / b);
	return res;
}

int64 ternary_search(int64 l, int64 r) {
    while (r > l) {
        int64 m1 = l + (r - l) / 3;
        int64 m2 = r - (r - l) / 3;
        int64 f1 = f(m1);
        int64 f2 = f(m2);
        if (f1 <= f2)
            l = m2;
        else
            r = m1;
    }
    return max({f(l), f(min(l + 1, n)), f(max(1LL, l - 1))});
}

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

	cin >> a >> b >> n;
	cout << ternary_search(1, min(n, b));	
}

Measured memory_bytes: 3608
#include<stdio.h>
#include<math.h>

int isprime(int x){
	if(x==2){
		return 1;
	}else if(x<2 || x%2==0){
		return 0;
	}else{
		int i=3;
		while(i<=sqrt(x)){
			if(x%i==0){
				return 0;
			}
			i=i+2;
		}
	return 1;
	}
}


int main(){
	int A[10000], n, i, sum=0;
	scanf("%d", &n);
	for(i=0; i<n; i++){
		scanf("%d", &A[i]);
	}
	
	for(i=0; i<n; i++){
		sum=sum + isprime(A[i]);
	}

	printf("%d\n", sum);

return 0;

}

Measured memory_bytes: 628
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		int a, b, c;
		Scanner sc = new Scanner(System.in);
		a = sc.nextInt();
		b= sc.nextInt();
		c = sc.nextInt();
		if(a < c && c < b) {
			System.out.println("Yes");
		}else if(b < c && c < a) {
			System.out.println("Yes");
		}else {
			System.out.println("No");
		}
		sc.close();
	}
}


Measured memory_bytes: 20948
import bisect

N = int(input())
L = sorted([int(x) for x in input().split()])
ans = 0
for i in range(N-2):
    for j in range(i+1,N-1):
        ab = L[i] + L[j]
        r = bisect.bisect_left(L,ab)
        l = j + 1
        ans += r - l

print(ans)

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

using namespace std;

int main(void) {
    int i, len, start, end;
    string s;
    cin >> s;
    len = s.length();
    for (i=0;i<len;i++) {
        if (s[i] == 'A') {
            start = i-1; break;
        }
    }
    for (i=len-1;i>=0;i--) {
        if (s[i] == 'Z') {
            end = i; break;
        }
    }
    cout << end-start << endl;

    return 0;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
#define rep(i,N) for (int i = 0; i < (N); ++i)
#define all(v) v.begin(), v.end()
using namespace std;
using ll = long long;
using P = pair<int, int>;
int main(void){
  int s;
  cin >> s;

  set<int> st;  //すでに現れた数の集合

  int x = s;
  while (st.count(x) == 0){
    st.insert(x);
    if (x % 2 == 0){
      x /= 2;
    }else{
      x = x * 3 + 1;
    }
  }
  cout << st.size() + 1 << endl;
}


Measured memory_bytes: 3596
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		
		int num = sc.nextInt();
		
		String input = sc.next();
		
		for(int i = 0; i < input.length(); i++) {
			int tmp = (input.charAt(i) + num);
			
			if(tmp > 'Z')
				tmp = tmp - 'Z' + 'A' -1;
			System.out.print((char)(tmp));
		}
	}
}

Measured memory_bytes: 25676
#include <bits/stdc++.h>
using namespace std;
int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    int a,b;
    cin>>a>>b;
    int ans1=a+b,ans2=a-b,ans3=a*b;
    int ans=ans1;
    ans=max(ans,ans3);
    ans=max(ans,ans2);
    cout<<ans<<'\n';
    return 0;
}


Measured memory_bytes: 256
N,M = list(map(int,input().split()))
lis_s =[]
count = 0
for _ in range(M):
  lis_s.append(tuple(map(int,input().split())))

graph = [[False for i in range(N+1)] for k in range(N+1)]

for tp in lis_s:
  graph[tp[0]][tp[1]] = True
  graph[tp[1]][tp[0]] = True


visited = [False]*(N+1)
bridge = False

def dfs(v):
  visited[v] = True
  for vs in range(1,N+1):
    if (graph[v][vs] == True) and (visited[vs] == False):
      dfs(vs)

ans = 0

for num in range(M):
  graph[lis_s[num][0]][lis_s[num][1]] = False
  graph[lis_s[num][1]][lis_s[num][0]] = False
  for i in range(N+1):
    visited[i] = False
  
  dfs(1)
  
  bridge = False
  for check in range(1,N+1):
    if visited[check] == False:
      bridge = True
  
  if bridge:
    ans += 1
  
  graph[lis_s[num][0]][lis_s[num][1]] = True 
  graph[lis_s[num][1]][lis_s[num][0]] = True
  
  
print(ans)

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

 using namespace std;

 int main() {
   int N;
   string S;
   cin >> N >> S;

   if (N % 2 == 1) cout << "No" << endl;

   else if (S == S.substr(0, N / 2) + S.substr(0, N / 2)) cout << "Yes" << endl;
   else cout << "No" << endl;
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<string>
#include<cmath>
using namespace std;
int main() {
    int A, B;
    cin >> A >> B;
    for(int i = 1; i <= 1000; i++){
        if((int)(i*0.08) == A && (int)(i*0.10) == B){
            
            cout << i << endl;
            return 0;
        }        
    }

    cout << "-1" << endl;

    return 0;
}

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

int main(void){
    int N;
    cin>>N;
    vector<int> a(N);
    for (int i=0;i<N;i++) {
        int temp;
        cin>>temp;
        a[i] = temp-1;
    }
    vector<bool> used(N,false);
    int point = 0;
    used[0] = true;
    int ans = 0;

    while (point!=1) {
        if (used[a[point]]) {
            ans = -1;
            break;
        }
        point = a[point];
        used[point] = true;
        ans++;
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 640
//shan61916
#include <bits/stdc++.h>
  using namespace std;
typedef   long long ll;
typedef   unsigned long long ull ;
typedef   double dll ;

#define   mp make_pair
#define   pb push_back
#define   ff first 
#define   ss second
#define   IOS ios::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define   endl "\n" 
#define   pll pair<ll, ll>
#define   all(x) x.begin(), x.end()
#define   vll vector<ll> 

const ll inf = (ll)(1e17 + 17);
const ll mod = (ll)(1e9 + 7);


int main(){
 IOS
#ifdef SHAN
    freopen("input.txt" , "r" , stdin);  
#endif
  string s, t;
  cin >> s >> t;
  ll ct = 0;
  for(ll i = 0; i < s.length(); i++) {
  	if(s[i] != t[i]) ct++;
  }
  cout << ct;
  return 0;
} //good night.

Measured memory_bytes: 3740
#include<bits/stdc++.h>
using namespace std;
#define MOD 1000000007
#define LL long long
#define N 3011
int n,q,a[N],x,y;
LL f[N][N],ans,inv2; 
LL q_pow(LL a,LL b){
	LL res=1;
	while(b){
		if(b&1ll) res=res*a%MOD;
		b>>=1ll;
		a=a*a%MOD;
	}
	return res;
}
int main(){
	scanf("%d%d",&n,&q);
	for(int i=1;i<=n;i++)scanf("%d",&a[i]);
	for(int i=1;i<=n;i++)
	  for(int j=1;j<=n;j++){
	  	if(i==j) continue;
	  	f[i][j]=(a[i]>a[j]);
	  }
	inv2=q_pow(2,MOD-2);
	for(int Q=1;Q<=q;Q++){
		scanf("%d%d",&x,&y);
		swap(a[x],a[y]); 
		for(int i=1;i<=n;i++){
			if(i!=x&&i!=y){
				f[x][i]=f[y][i]=inv2*(f[x][i]+f[y][i])%MOD;
				f[i][x]=f[i][y]=inv2*(f[i][x]+f[i][y])%MOD;
			}
		}
		f[x][y]=f[y][x]=inv2*(f[x][y]+f[y][x])%MOD;
	}
	ans=0;
	for(int i=1;i<=n;i++)
	  for(int j=1;j<i;j++)
	    ans=(ans+f[j][i])%MOD;
	ans=ans*q_pow(2,q)%MOD;
	printf("%lld\n",ans);
}

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

//#define int long long
#define ll long long
#define all(v) (v).begin(), (v).end()
#define rep(i,n) for(int i=0;i<n;++i)
#define rep1(i,n) for(int i=1;i<n;++i)
#define exrep(i, a, b) for(ll i = a; i < b; i++)
#define out(x) cout << x << endl
#define EPS (1e-7)
#define gearup ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
typedef pair<ll, ll> P;
typedef vector<ll> vl;
typedef vector<vector<ll> > vvl;
typedef vector<vector<vector<ll> > > vvvl;
ll MOD = 1000000007;
const long long L_INF = 1LL << 60;
const int INF = 2147483647; // 2^31-1
const double PI = acos(-1);
//cout<<fixed<<setprecision(10);

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;}
template<class T> void debug(T v){rep(i,v.size()) cout<<v[i]<<" ";cout<<endl;}
const ll dx[8] = {1, 1, 0, -1, -1, -1, 0, 1};
const ll dy[8] = {0, 1, 1, 1, 0, -1, -1, -1};

signed main()
{   
    gearup;
    int n;cin>>n;
    vl a(n);
    rep(i,n)cin>>a[i];
    ll res = 0;
    while(1){
        rep(i,n){
            if(a[i] & 1){
                out(res);
                return 0;
            }
            else a[i]/=2;
        }
        res++;
    }
}


Measured memory_bytes: 256