akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
using namespace std;
#include <boost/multiprecision/cpp_int.hpp> 
using boost::multiprecision::cpp_int; 
 
#define ff              first
#define ss              second
// #define ll 				long long int
#define dd             double
#define pb              push_back
#define mp              make_pair
#define pii             pair<int,int>
#define vi              vector<int>
#define mii             map<int,int>
#define pqb             priority_queue<int>
#define pqs             priority_queue<int,vi,greater<int> >
#define setbits(x)      __builtin_popcountll(x)
#define zrobits(x)      __builtin_ctzll(x)
#define mod             1000000007
#define modp            998244353
#define inf             1e18
#define ps(x,y)         fixed<<setprecision(y)<<x
#define w(x)            int x; cin>>x; while(x--)
#define FIO           	ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl 			'\n'
mt19937                 rng(chrono::steady_clock::now().time_since_epoch().count());
 
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> pbds;
 
// void aks()
// {
// #ifndef ONLINE_JUDGE
//     freopen("input.txt", "r", stdin);
//     freopen("output.txt", "w", stdout);
// #endif
// }


void solve()
{
	int n; cin >> n;
	cpp_int a[n];cpp_int res = 1;
	for(int i = 0; i < n; i++)
	{
		cin >> a[i];
	}
	sort(a, a+n);
	for(int i = 0; i < n; i++)
	{
		cin >> a[i];
		res = res*a[i];
		if(res > 1000000000000000000)
		{
			cout << -1 << endl;
			return;
		}
	}
	cout << res << endl;

}
 
int32_t main()
{
	FIO
    //aks();
    //w(t)
    {
    	solve();
    }
    return 0;
}
	

Measured memory_bytes: 6880
#include <iostream>
#include <stack>
using namespace std;
static const int N=100;
static const int WHITE=0;
static const int GRAY=1;
static const int BLACK=2;
 
//???¶?????????°
int n;
//?????\??????
int M[N][N];
//???°??????¶????????¢????
int color[N];
//??\???¶?????????°???¶???
int d[N];
//??\???¶????????????¶???
int f[N];
//???¶???
int tt;
 
int nt[N];
 
//????????????????????????u?????????v
int next(int u){
    for(int v=nt[u];v<n;v++){
        nt[u]=v+1;
        if(M[u][v]&&color[v]==WHITE)
            return v;
    }
    return -1;
}
 
//???¨?????????°??????±??????????????´?¢
void dfs_visit(int r){
    for(int i=0;i<n;i++)
        nt[i]=0;
 
    stack<int> S;
    S.push(r);
    color[r]=GRAY;
    //??????°???¶???
    d[r]=++tt;
 
    while(!S.empty()){
        int u=S.top();
        int v=next(u);
        if(v!=-1&&color[v]==WHITE){
            color[v]=GRAY;
            d[v]=++tt;
            S.push(v);
        }
        else{
            //????????????
            S.pop();
            color[u]=BLACK;
            f[u]=++tt;
        }
    }
}
 
void dfs(){
    //?????§????
    for(int i=0;i<n;i++)
        color[i]=WHITE;
    tt=0;
 
    //??\????????????u??????????????????±??????????????´?¢
    for(int u=0;u<n;u++)
        if(color[u]==WHITE)
            dfs_visit(u);
 
    for(int i=0;i<n;i++)
        cout<<i+1<<" "<<d[i]<<" "<<f[i]<<endl;
}
 
int main(){
    int u,k,v;
 
    cin>>n;
    for(int i=0;i<n;i++)
        for(int j=0;j<n;j++)
            M[i][j]=0;
 
    for(int i=0;i<n;i++){
        cin>>u>>k;u--;
        for(int j=0;j<k;j++){
            cin>>v;v--;
            M[u][v]=1;
        }
    }
 
    dfs();
}

Measured memory_bytes: 3096
def main():
    line = input()
    s1 = []
    s2 = []
    sum = 0
    for i, s in enumerate(line):
        if s == "\\":
            # 谷の位置をスタックに積む
            s1.append(i)
        elif s == "/" and len(s1) > 0:
            # 山で対応する谷があるなら、面積に追加
            j = s1.pop()
            sum += i - j  # 谷から山の距離を水たまりの面積に追加
            # jより前に位置する水たまりの面積を追加
            a = i - j
            while len(s2) > 0 and s2[-1][0] > j:
                a += s2.pop()[1]
            # (水たまりの左端の位置, 水たまりの面積)のタプルをスタックに積む
            s2.append((j, a))

    print(sum)
    print(len(s2), end="")
    for x in s2:
        print(f" {x[1]}", end="")
    print()


if __name__ == "__main__":
    main()



Measured memory_bytes: 6412
import numpy as np

N = int(input())
t = np.array(['0'] + input().split(), np.int64)
v = list(map(int, input().split()))

# 発車してからn秒後の速度を求める

T = np.cumsum(t).tolist()
arrival = T[-1]
times = np.arange(0, arrival + 0.5, 0.5)
speed_limit = np.minimum(times, times[::-1])

for i, j, k in zip(T, T[1:], v):
    speed1 = i - times + k
    speed2 = np.full(arrival * 2 + 1, k, np.float)
    speed3 = times - j + k

    speed = np.maximum(speed1, speed3)
    speed = np.maximum(speed2, speed)
    speed_limit = np.minimum(speed_limit, speed)

answer = np.abs(speed_limit[1:] + speed_limit[:-1]) * 0.5 / 2
print(answer.sum())


Measured memory_bytes: 14964
#include <iostream>
#include <cstdlib>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <stack>
#include <deque>
#include <queue>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <bitset>
#include <random>
#include <vector>
#include <string>
#include <cstring>
#include <cassert>
#include <complex>
#include <ctime>
#include <numeric>
using namespace std;

#define pb push_back
#define pii pair <int, int>
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define reunique(x) (x).resize(unique(all(x)) - (x).begin())
#define ld long double
#define int long long

void SOLVE1() {
	int k, n;
	cin >> k >> n;
	vector <int> a(n);
	for (int i = 0; i < n; i++) cin >> a[i];
	vector <int> v;
	for (int i = 1; i < n; i++) {
		v.pb(a[i] - a[i - 1]);
	}
	v.pb(k - a.back() + a[0]);
	int ans = 0;
	for (auto now : v) ans += now;
	int mx = *max_element(all(v));
	ans -= mx;
	cout << ans << '\n';
}

signed main() {
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	cout << fixed;
	cout.precision(10);
	int Q = 1;
	//cin >> Q;
	while (Q--) {
		SOLVE1();
	}

	return 0;
}

Measured memory_bytes: 3956
def tree(lst):
	if len(lst) == 0:
		return 0
	mi = min(lst)
	lst = [a - mi for a in lst]
	sum = mi
	start = 0
	for i in range(len(lst)):
		if lst[i] == 0:
			sum += tree(lst[start : i])
			start = i + 1
		elif i == len(lst) - 1:
			sum += tree(lst[start:])
	return sum
    
n = int(input())
h = [int(a) for a in input().split()]
print (tree(h))

Measured memory_bytes: 3064
#include<iostream>
using namespace std;
long long int n,m,nd;
int main(){
	cin>>n>>m;
	nd=2*n;
	if(nd>m)cout<<m/2<<endl;
	else if(nd==m)cout<<n<<endl;
	else{
		m-=nd;
		m/=4;
		cout<<n+m<<endl;
	}
	return 0;
}

Measured memory_bytes: 256
/* Code by : Suraj (@suraj1611) */

#include<bits/stdc++.h>
#include <string>

using namespace std;

#define ll long long int
#define rep(i,n) for(int i=0; i<n; i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define mx INT_MAX
#define mn INT_MIN
#define md 1000000007
#define pb push_back
#define mp make_pair
#define maxsize 1100005
#define lb cout<<endl;
#define endl "\n"
#define F first
#define S second
#define label cout<<"hello!"<<endl
#define IOS ios_base::sync_with_stdio(false); cin.tie(NULL);cout.tie(NULL);

ll power(ll x, ll  y) 
{ 
	ll m=md;
   	ll ans=1;
    while (y > 0) 
    {
        if (y & 1)
            ans = (ans * x) % m;
        x = (x * x) % m;
        y >>= 1;
    }
    return ans;
} 

int main()
{
	IOS


	string s,t;
	cin>>s>>t;
	ll n=s.length();
	ll m=t.length();
	ll dp[n+1][m+1];
	string str;
	rep(i,n+1)
	{
		rep(j,m+1)
		{
			if(i==0 or j==0)
				dp[i][j]=0;
			else if(s[i-1]==t[j-1])
			{
				dp[i][j]=1+dp[i-1][j-1];
			}
			else
				dp[i][j]=max(dp[i-1][j],dp[i][j-1]);
		}
	}

	ll i=n,j=m;
	while(i and j)
	{
		if(s[i-1]==t[j-1])
		{
			str=s[i-1]+str;
			i--;
			j--;
		}
		else if(dp[i-1][j]>dp[i][j-1])
			i--;
		else
			j--;
	}
	cout<<str<<endl;


    return 0;
}

Measured memory_bytes: 70656
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<bitset>
#include<set>
#include<map>
#include<stack>
#include<queue>
#include<deque>
#include<list>
#include<iomanip>
#include<cmath>
#include<cstring>
using namespace std;

#define repr(i, a, b) for (int i = (int)(a); i < (int)(b); i++)
#define rep(i, n) repr(i, 0, n)
#define INF 2e9
#define MOD 1000000007
//#define MOD 998244353
#define LINF (long long)4e18
#define jck 3.141592

using ll = long long;
using Pi = pair<int,int>;
using Pl = pair<ll,ll>;




int main(){
	int N; cin >> N;
	vector<int> B(N-1);
	rep(i,N) cin >> B[i];
	vector<int> A(N);
	A[0] = B[0];
	rep(i,N-2){
		A[i+1] = min(B[i],B[i+1]);
	}
	A[N-1] = B[N-2];
	int ans = 0;
	rep(i,N) ans += A[i];
	cout << ans << endl;
}



Measured memory_bytes: 384
#include <iostream>
#include <string.h>
using namespace std;
#define LIM 1000000

bool is_prime[LIM+10];
int sum[LIM + 10];

int main(){
	memset(is_prime, true, sizeof(is_prime));
	is_prime[0] = is_prime[1] = false;

	for(int p=2;p*p<=LIM;p++)if(is_prime[p]){
		for(int k=p*p;k<=LIM;k+=p)is_prime[k] = false;
	}

	sum[0] = 0;
	for(int i=0;i<=LIM;i++){
		sum[i+1] = sum[i] + is_prime[i];
	}


	int n;
	while(cin >> n && n){
		int pay = 0;
		for(int i=0;i<n;i++){
			int p, m;
			cin >> p >> m;

			int low = max(0, p - m);
			int high = min(LIM, p + m);

			pay += sum[high + 1] - sum[low] - 1;
		}

		cout << pay << endl;
	}
	return 0;
}

Measured memory_bytes: 6052
//ProblemD

#ifdef _MYPC
#include "mypc.h"
#endif // _MYPC

#include <iostream>
#include <string>
#include <vector>
#include <bitset>
#include <list>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <queue>
#include <stack>
#include <algorithm>
#include <numeric>
#include <functional>
#include <memory>
#include <complex>
#include <cstdio>
#include <cstring>
#include <cmath>

using namespace std;

//ProblemD

class Solve {
private:

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

		vector<int> p(n, 0);
		vector<int> x(m, 0);
		vector<int> y(m, 0);

		vector<int> q(n, 0);
		for (int i = 0; i < n; i++) {
			cin >> p[i];
			p[i]--;

			q[p[i]] = i;
		}

		vector<vector<int>> edges(n);
		for (int i = 0; i < m; i++) {
			cin >> x[i] >> y[i];
			x[i]--;
			y[i]--;

			edges[x[i]].push_back(y[i]);
			edges[y[i]].push_back(x[i]);
		}

		vector<unordered_set<int>> groups;
		vector<int> visited(n, -1);
		function<void(int)> dfs = [&](int i) {
			groups.back().insert(i);
			visited[i] = groups.size() - 1;
			for (auto e : edges[i]) {
				if (visited[e] == -1) {
					dfs(e);
				}
			}
		};
		for (int i = 0; i < n; i++) {
			if (visited[i] == -1) {
				groups.push_back(unordered_set<int>());
				dfs(i);
			}
		}

		int cnt = 0;
		for (int i = 0; i < n; i++) {
			if (groups[visited[i]].find(q[i]) != groups[visited[i]].end()) {
				cnt++;
			}
		}
		cout << cnt << endl;
	}

public:
	Solve() { solve(); }
};

int main(int argc, char* argv[]) {
	unique_ptr<Solve> solve = make_unique<Solve>();
	return 0;
}


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

int main(){
    int n,ans;
    cin>>n;
    vector<int>d(n);
    ans=0;

    for(int i=0;i<n;i++)cin>>d.at(i);

    for(int i=0;i<n-1;i++){
        for(int j=i+1;j<n;j++){
            ans+=d.at(i)*d.at(j);
        }
    }

    cout << ans <<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
  int N;
  string S;
  cin >> N >> S;
  if (N % 2 == 1){
    cout << "No";
  } else {
    bool res = true;
    for (int i = 0; i < S.size() / 2; i++){
      if (S[i] != S[i + S.size() / 2]) res = false;
    }
    cout << (res ? "Yes" : "No");
  }
}

Measured memory_bytes: 256
/*
 * C.cpp
 *
 *  Created on: 2020/06/21
 *      Author: admin
 */


#include <iostream>
#include <string>

using namespace std;


int main(){
	long long N;
	cin >> N;

	string s[26] =
		{"a","b","c","d","e",
		 "f","g","h","i","j",
		 "k","l","m","n","o",
		 "p","q","r","s","t",
		 "u","v","w","x","y","z"};

	bool Flag = true;
	long index;
	string name;

	while(Flag){
		N-=1;
		if(N < 26){
			Flag = false;
		}
		index = N%26;
		name = s[index] + name;
		N = N/26;
	}
	cout << name;

	return 0;
}






Measured memory_bytes: 3604
#include<bits/stdc++.h>
using namespace std;
using ll=long long;
// 繰り返し2乗法
ll square_method(ll k,ll p,ll m){//k^p(mod m)
  if(p==0)return 1;
  if(p%2==0){
    ll t=square_method(k,p/2,m);
    return t*t%m;
  }
  return square_method(k,p-1,m)*k;
}
//二項定理
const ll MOD=1000000007;
const ll MAX=550000;
ll fanc[MAX],inv[MAX],finv[MAX];
void COMinit(){
  fanc[0]=fanc[1]=1;
  finv[0]=finv[1]=1;
  inv[1]=1;
  for(ll i=2;i<MAX;i++){
    fanc[i]=fanc[i-1]*i%MOD;
    inv[i]=MOD-(MOD/i)*(inv[MOD%i])%MOD;
    finv[i]=finv[i-1]*inv[i]%MOD;
  }
}
ll COM(ll n,ll k){
  if(n<k)return 0;
  if(n<0||k<0)return 0;
  return fanc[n]*(finv[n-k]*finv[k]%MOD)%MOD;
}
int main(){
  int n,a,b;
  cin>>n>>a>>b;
  COMinit();
  ll all=square_method(2,n,MOD);
  ll tmp1=1,tmp2=1;
  for(ll i=n;i>=n-a+1;i--){
    tmp1=tmp1*i%MOD;
  }
  //cout<<tmp1<<endl;
  for(ll i=n;i>=n-b+1;i--){
    tmp2=tmp2*i%MOD;
  }
  //cout<<all<<endl;
  tmp1=tmp1*finv[a]%MOD;
  tmp2=tmp2*finv[b]%MOD;
  ll ans=all-1-tmp1-tmp2;
  while(ans<0){
    ans+=MOD;
  }

  //ここエラーするよ~~~~~~~~~~~~~~~~
  ans=ans%MOD;
  //~~~~~~~~~~~~~~~~~~~~~~~~~
  cout<<ans<<endl;
  
}

Measured memory_bytes: 13184
#include <bits/stdc++.h>
using namespace std;
typedef int64_t int64;

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

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    
    int N, X; cin >> N >> X;
    if(N==1){
        int X0; cin >> X0;
        cout << abs(X0-X) << endl;
        return 0;
    }
    
    vector<int> vX(N+1);
    for(int i=0; i<N; ++i){ cin >> vX[i]; }
    vX[N] = X;
    sort(vX.begin(), vX.end());
    
    int64 gcd_val=gcd(vX[1]-vX[0], vX[2]-vX[1]);
    for(int i=3; i<N; ++i){
        gcd_val = gcd(vX[i]-vX[i-1], gcd_val);
    }
    cout << gcd_val << endl;
    
    return 0;
}

Measured memory_bytes: 640
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <regex>
#include <math.h>
typedef long long ll;
using namespace std;


int main(void){
  ll n;
  cin >> n;
  vector<ll> a(n);
  for(ll i = 0;i < n; i++){
    cin >> a[i];
  }
  sort(a.begin(),a.end());
  ll cont = 0;
  ll last = a[0];
  ll rm = 0;
  for(ll i = 0;i < n; i++){
    if(last != a[i]){
      if(cont >= a[i - 1]){
        rm += cont - a[i - 1];
      }else {
        rm += cont;
      }
      cont = 0;
    }
    cont++;
    if(i == n - 1){
      if(cont >= a[i]){
        rm += cont - a[i];
      }else {
        rm += cont;
      }
    }
    last = a[i];
  }
  cout << rm << endl;
  return 0;
}

Measured memory_bytes: 1024
#include "bits/stdc++.h"
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=int(a),i##_len=(b);i<i##_len;++i)
#define BUGAVOID(x) x
#define rep(...) BUGAVOID(_overload3(__VA_ARGS__,repi,_rep,_rep)(__VA_ARGS__))
#define all(c) c.begin(),c.end()
#define mp make_pair
#define write(x) cout<<(x)<<"\n"
using namespace std; typedef long long ll;
typedef vector<int> vi; typedef vector<ll> vll; template<class T, class U>using vp = vector<pair<T, U>>;
template<class T>using vv = vector<vector<T>>; template<class T, class U>using vvp = vv<pair<T, U>>;
template<class T>vv<T> vvec(size_t n, size_t m, T v) { return vv<T>(n, vector<T>(m, v)); }
template<class T>bool chmax(T& a, const T& b) { return a < b ? a = b, 1 : 0; }
template<class T>bool chmin(T& a, const T& b) { return b < a ? a = b, 1 : 0; }
constexpr int INF = 1 << 28, MAX = 1e5 + 5, MOD = 1e9 + 7;
constexpr ll LINF = 1ll << 60; constexpr double EPS = 1e-6;
constexpr int dy[4] = { 0,1,0,-1 }, dx[4] = { 1,0,-1,0 };
struct aaa { aaa() { cin.tie(0); ios::sync_with_stdio(0); }; }aaaa;

int main() {
    int N;
    cin >> N;
    vi V(N), C(N);
    rep(i, N) {
        cin >> V[i];
    }
    rep(i, N) cin >> C[i];

    int ans = 0;
    rep(i, N) {
        if (V[i] - C[i] > 0) {
            ans += V[i] - C[i];
        }
    }

    write(ans);
}

Measured memory_bytes: 256
#include <algorithm>
#include <functional>
#include <iostream>
#include <iomanip>
#include <vector>
#include <map>
#include <set>
#include <unordered_set>
#include <queue>
#include <numeric>
#include <bitset>
#include <cmath>

using namespace std;
using ll = long long;
using ull = unsigned long long;
// const ll mod =  998244353 ;
const ll mod =  1000000007 ;
const ll inf = 1e18;
const int dx[] = {1, -1, 0, 0};
const int dy[] = {0, 0, 1, -1};


#define REP(i, n) for (ll i = 0; i < (n); ++i)
#define REP_FROM(i, j, n) for (ll i = (j); i < (n); ++i)
#define REP_REV(i, n) for (ll i = n-1; i >= 0; --i)
#define all(x) (x).begin(),(x).end()
#define sz(x) ll(x.size())

template<typename T> void print_vec(vector<T> a) {int n = a.size();REP(i, n) {cout >> a[i]; if(i!=n-1) cout << " "; else cout << endl;}}
ll power(ll base, ll exponent){ if(exponent % 2){ return power(base, exponent - 1) * base % mod; }else if(exponent){ ll root_ans = power(base, exponent / 2); return root_ans * root_ans % mod; }else{ return 1; }}
ll inverse(ll x){ return power(x, mod - 2);}
ll gcd(ll a, ll b) {if(a < b) gcd(b, a);ll r;while(r=a%b) {a=b;b=r;}return b;}
template<typename T> ll sum(T begin, T end) {return accumulate(begin, end, 0ll);}
struct combination{ vector<ll> fact, inv; combination(int sz) : fact(sz + 1), inv(sz + 1){ fact[0] = 1; for(int i = 1; i <= sz; i++){ fact[i] = fact[i - 1] * i % mod; } inv[sz] = power(fact[sz], mod - 2); for(int i = sz - 1; i >= 0; i--){ inv[i] = inv[i + 1] * (i + 1) % mod; } } ll C(int p, int q) const{ if(q < 0 || p < q) return 0; return (fact[p] * inv[q] % mod * inv[p - q] % mod); } };

using Pair = pair<ll, ll>;


signed main() {
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(15);
  ll n;
  cin >> n;
  vector<ll> a(n);
  REP(i,n) cin >> a[i];
  vector<vector<ll>> dp(n+1, vector<ll>(n+1));
  priority_queue<Pair> q;
  REP(i, n) q.emplace(a[i], i);
  REP(i, n) {
    auto x = q.top();q.pop();
    REP(j, i+1) {
      dp[i-j+1][j] = dp[i-j][j] + x.first * abs(x.second - (i - j));
    }
    REP(j, i+1) {
      dp[i-j][j+1] = max(dp[i-j][j+1], dp[i-j][j] + x.first * abs(x.second - (n - 1 - j)));
    }
  }
  ll ans = 0;
  REP(i, n+1) {
    ans = max(ans, dp[i][n-i]);
  }
  cout << ans << endl;
  return 0;
}


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

#define REP(i,n) for(int i=0;i<(n);++i)
#define ll long long
const long long INF = 1LL<<60;
const long long mod = 1e9 + 7;

int main(){
    int N, M;
    cin >> N >> M;
    int A[M];
    REP(i, M) A[i] = 0;
    REP(i,N){
        int K;
        cin >> K;
        int L[K];
        REP(j,K) cin >> L[j];
        REP(k,K) A[L[k]-1] ++;
    }
    int ans = 0;
    REP(i,M){
        if(A[i] == N) ans++;
    }
    cout << ans << endl;
 }

Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>

static int pos = 0;
static int stack[100];

void push(int i){
  stack[pos++] = i;
}

int pop(void){
  return stack[--pos];
}

int main(void){
  char str[16];

  while (scanf("%s ", str) != EOF){
    int a,b;
    switch (str[0]) {
    case '*':
    case '+':
    case '-':
      a = pop();
      b = pop();
      if (str[0] == '*')
        push(b*a);
      else if (str[0] == '+')
        push(b+a);
      else if (str[0] == '-')
        push(b-a);
      break;
    default:
      push (atoi(str));
      break;
    }
  }
    printf("%d\n", pop());
  return 0;
}

Measured memory_bytes: 552
#include<bits/stdc++.h>
using namespace std;
#define rep(i,s, n) for(int i = s; i < (int)(n); i++)
#define co(x) cout<<x<<endl
#define SQvec(i,j) vector<vector<int>> data(i, vector<int>(j))
#define mod 1000000000+7
typedef long long int lint;

int main() {
  lint N;
  cin >> N;
  if(N%2 == 0){co(N);}
  else{co(2*N);}
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <cmath>
using namespace std;
int main(){
    unsigned long long n, a, b;
    cin >> n >> a >> b;
    unsigned long long x = n / (a+b);
    unsigned long long o = x * a + std::min(n%(a+b), a);
    cout << o << endl;
    return 0;
}

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

using namespace std;

int main(int argc, char const *argv[])
{
    int n, x, y;
    cin >> n >> x >> y;
    vector<int> ans(n, 0);

    for(int i = 1; i <= n; i++){
        for(int j = i; j<= n; j++){
            if(i != j)
            ans[min(abs(j-i), abs(x-i) + 1 + abs(y-j))]++;
        }
    }

    for(int i = 1; i < n; i++){
        cout << ans[i] << endl;
    }
    return 0;
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n)  for(long long i=0;i<(long long)(n);i++)
#define REP(i,k,n) for(long long i=k;i<(long long)(n);i++)
#define all(a) a.begin(),a.end()
#define pb push_back
#define eb emplace_back
#define lb(v,k) (lower_bound(all(v),k)-v.begin())
#define ub(v,k) (upper_bound(all(v),k)-v.begin())
#define fi first
#define se second
#define pi M_PI
typedef long long ll;
typedef pair<ll,ll> P;
typedef tuple<ll,ll,ll> PP;
typedef multiset<ll> S;
typedef priority_queue<ll> PQ;
typedef priority_queue<P,vector<P>,greater<P>> SPQ;
using vi=vector<ll>;
using vvi=vector<vi>;
using vvvi=vector<vvi>;
using vp=vector<P>;
using vvp=vector<vp>;
using vb=vector<bool>;
const ll inf=1001001001001001;
const int INF=1001001001;
const int mod=1000000007;
template<class T> bool chmin(T&a,T b){if(a>b){a=b;return true;}return false;}
template<class T> bool chmax(T&a,T b){if(a<b){a=b;return true;}return false;}
template<class T> void out(T a){cout<<a<<'\n';}
template<class T> void outp(T a){cout<<'('<<a.fi<<','<<a.se<<')'<<'\n';}
template<class T> void outvp(T v){rep(i,v.size())outp(v[i]);}
template<class T> void outv(T v){rep(i,v.size()){if(i)cout<<' ';cout<<v[i];}cout<<'\n';}
template<class T> void outvv(T v){rep(i,v.size()){rep(j,v[i].size()){if(j)cout<<' ';cout<<v[i][j];}cout<<'\n';}}
ll gcd(ll a,ll b){if(b==0)return a;return gcd(b,a%b);}
ll modpow(ll a,ll b){a%=mod;if(b==0)return 1;if(b&1)return a*modpow(a,b-1)%mod;ll k=modpow(a,b/2);return k*k%mod;}

int main(){
    ll h,w;cin>>h>>w;
    if(h==1||w==1){
        out(1);
        return 0;
    }
    ll ans=(h*w+1)/2;
    out(ans);
}

Measured memory_bytes: 256
S = input()
max = 0
cnt = 0
for i in range(len(S)):
    if S[i] == "A" or S[i] == "T" or S[i] == "C" or S[i] == "G":
        cnt += 1
    else:
        cnt = 0
    if cnt > max:
        max = cnt
print(max)

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

int low[200000];
int high[200000];
int a[200000];

int part(int a[],int l,int r){
  int i,j,x,t;

  i = l - 1;
  j = r;

  x = a[r];

  while(1){
    while(a[++i] < x);
    while(i < --j && x < a[j]);

    if(i >= j) break;

    t = a[i]; a[i] = a[j]; a[j] = t;
  }

  t = a[i]; a[i] = a[r]; a[r] = t;
  return i;
}

void quicksort(int a[],int n){
  int l,r,v;
  int sp;

  low[0] = 0;
  high[0] = n - 1;
  sp = 1;

  while(sp > 0){
    sp--;
    l = low[sp];
    r = high[sp];

    if(l >= r);

    else {
      v = part(a,l,r);

      if(v - l < r - v){
        low[sp] = v + 1;
        high[sp++] = r;
        low[sp] = l;
        high[sp++] = v - 1;
      }

      else{
        low[sp] = l;
        high[sp++] = v - 1;
        low[sp] = v + 1;
        high[sp++] = r;
      }
    }
  }
}

int main(){

  int n,i;
  int d[100004];
  int mid1,mid2;

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

  quicksort(d,n);

  mid1 = d[(n - 1)/2];
  mid2 = d[(n - 1)/2 + 1];

  printf("%d\n", mid2 - mid1);

  return 0;
}


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

ll euclidean_gcd(ll a, ll b) {
  if(a < b) return euclidean_gcd(b, a);
  ll r;
  while ((r=a%b)) {
    a = b;
    b = r;
  }
  return b;
}

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

    ll ans = b - a + 1;
    
    //cについて
    ll ca, cb;
    ca = a/c;
    cb = b/c;

    ans -= (cb - ca);
    //cout << cb - ca << endl;
    if(a%c==0)  ans--;
    //if(b%c==0)  ans++;

    //dについて
    ll da, db;
    da = a/d;
    db = b/d;

    ans -= (db - da);
    //cout << db - da << endl;
    if(a%d==0)  ans--;
    //if(b%d==0)  ans++;

    //cdについて

    ll gcd = euclidean_gcd(c, d);
    ll kobai = c*d/gcd;

    ll cda, cdb;
    cda = a/kobai;
    cdb = b/kobai;

    ans += (cdb - cda);
    //cout << cdb - cda << endl;
    if(a%kobai==0) ans++;
    //if(b%(c*d)==0) ans--;

    cout << ans << endl;

    
    return 0;
}

Measured memory_bytes: 256
use strict;
use warnings;

my ($n, $m);
{
  my $in = <STDIN>;
  ($n, $m) = split(" ", $in);
}
my @p;
for (my $i=0; $i<$m; $i++)
{
  my @in = split " ", <STDIN>;
  push @p, $in[1] . $in[0];
}
my %h;
$h{$_}++ for grep {/^AC/} @p;
my %k;
for my $key (keys %h) {
  $key =~ s/AC/WA/;
  $k{$key} = 1;
}
my $c = 0;
for (my $i=0; $i<$m; $i++) {
  my $s = $p[$i];
  if ($s =~ /^WA/) {
    if ($k{$s}) {
      $c++;
    }
  } else {
    $s =~ s/AC/WA/;
    $k{$s} = 0;
  }
}
print scalar keys %h;
print " $c\n";

Measured memory_bytes: 43008
import java.util.Scanner;

public class Main {
    public static void main(String args[]){
        long ratio = 100000/1000;
        int n = new Scanner(System.in).nextInt();
        for(int i=0;i<n;i++){
            ratio = (long) Math.ceil(ratio*1.05);
        }
        System.out.println("" + (ratio*1000));
    }
}



Measured memory_bytes: 26312
#include<bits/stdc++.h>
#define INF 0x3f3f3f3f
#define re register
#define LL long long
#define MOD 998244353
#define MAXN 300005
using namespace std;
LL n,ans,bs[3*MAXN];
LL rd(){
	LL x=0,tp=1;char c;c=getchar();
	while(c<'0' || c>'9'){if(c=='-')tp=-1;c=getchar();}
	while(c>='0' && c<='9'){x=(x*10+c-'0');c=getchar();}
	return x*tp;
}
struct Graph{
	LL m,sg[MAXN],f[MAXN];
	vector<int>e[MAXN];
	void work(){
		int x,y;
		m=rd();
		for(int i=1;i<=m;i++){
			x=rd(),y=rd();
			if(x>y)swap(x,y);
			e[x].push_back(y);
		}
		for(int i=n;i>=1;i--){
			set<int>s;
			int sz=e[i].size();
			for(int j=0;j<sz;j++)s.insert(sg[e[i][j]]);
			while(s.count(sg[i]))sg[i]++;
			(f[sg[i]]+=bs[i])%=MOD;
			// printf("sg[%d]=%d\n",i,sg[i]);
		}
	}
}g[3];
int main(){
	// freopen("testdata.in","r",stdin);
	// freopen("shit.out","w",stdout);
	n=rd();int Sqr=sqrt(n);
	bs[0]=1;LL fuck=1000000000000000000ll%MOD;
	for(int i=1;i<=3*n;i++)bs[i]=bs[i-1]*fuck%MOD;
	for(int i=0;i<3;i++)g[i].work();
	for(int i=0;i<=500;i++)
		for(int j=0;j<=500;j++)
			(ans+=g[0].f[i]*g[1].f[j]%MOD*g[2].f[i^j]%MOD)%=MOD;
	printf("%lld\n",ans);
	// printf("%.2lf\n",(double)clock()/CLOCKS_PER_SEC);
	return 0;
}

Measured memory_bytes: 41216
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define For(i,n,k) for(int i=(n);i<(k);i++)
#define ALL(a)  (a).begin(),(a).end()
bool isEven(int n,int r){
    return n == (r | (n-r) );
}
vector<int> solve(vector<int> a){
    int n=a.size();
    vector<int> b(n-1);
    For(i,0,n-1){
        b[i]=abs(a[i]-a[i+1]);
    }
    if(b.size()<4) return b;
    else{
        vector<int> c;
        n=b.size();
        For(i,0,n){
            if(isEven(n-1,i)) c.push_back(b[i]);
        }
        return c;
    }
}
bool Main(){
    int n;cin>>n;
    string s;cin>>s;
    vector<int> a(n);
    For(i,0,n){
        a[i]=(s[i]-'0');
    }
    while(a.size()>1){
        a=solve(a);
    }
    cout<<a[0]<<endl;
}
int main(){
    Main();
    /*
    東方風神録は神が出てくるので当然神ゲー
    */
    return 0;
}

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

int main(){
  int A[3];
  cin >> A[0] >> A[1] >> A[2];
  sort(A, A + 3);
  if(A[0] == A[2]){
    cout << "Yes" << endl;
  }else{
    cout << "No" << endl;
  }
}

Measured memory_bytes: 256
import math

[n, k] = [int(i) for i in input().split()]

a = 0
b = 0
l = []
for i in range(18):
    if (2 ** i >= k / n):
        a = i
        break
for i in range(b, 18):
    if (2 ** i >= k):
        b = i
        break

l.append([a, n - math.ceil(k / (2 ** a)) + 1])
for i in range(a + 1, b + 1):
    c = math.ceil(k / (2 ** (i - 1))) - math.ceil(k / (2 ** i))
    l.append([i, c])

s = 0
for i in l:
    s += i[1] / (2 ** i[0])

print(s / n)


Measured memory_bytes: 3064
//#pragma GCC target("avx2")
//#pragma GCC optimization("O3")
//#pragma GCC optimization("unroll-loops")
//assert(q==w) если q!=w --> runtime error
#include <bits/stdc++.h>

#define pb push_back
#define F first
#define S second
#define all(x) x.begin(),x.end()
#define ub upper_bound
#define lb lower_bound
#define bit __builtin_popcount
#define memset(x) memset(x,0,sizeof(x))

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<vector<int>> matrix;

inline void boost(){
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
}

const ll maxn=2e5+123;
const ll inf=1e9+123;
const ll linf=1e18+123;
const ll mod=1e9+7;
const double eps=1e-9;
const double pi=acos(-1);
int dx[8]={0,1,-1,0,1,-1,1,-1};
int dy[8]={1,0,0,-1,1,1,-1,-1};

int main(){
    boost();
    //freopen("input.txt","r",stdin);
    //freopen("output.txt","w",stdout);
    ll n,a,b,c,d;
    cin>>n>>a>>b>>c>>d;
    for(int i=1;i<=n-1;i++){
        ll l=a+(c*i);
        ll r=a+(d*i);
        ll l2=b+(n-i-1)*c;
        ll r2=b+(n-i-1)*d;
        if(!(l>r2 || l2>r)){
            cout<<"YES";
            return 0;
        }
    }
    cout<<"NO";
	exit(0);
}


Measured memory_bytes: 256
#D
s = str(input())
ans = [0] * len(s)
flag = 0
ch = 0
for i in range(1,len(s)):
    if s[i - 1] == 'R' and s[i] == 'L':
        flag = i
    if (s[i - 1] == 'L' and s[i] == 'R') or i == len(s) - 1:
        if i == len(s) - 1:
            i = len(s)
        a = i - ch
        ans[flag - 1] = a // 2 + (flag - ch) % 2 * (a % 2)
        ans[flag] = a // 2 + (i - flag) % 2 * (a % 2)
        ch = i
print(*ans)


Measured memory_bytes: 6400
#include <stdio.h>
#include <string.h>
int main()
{
	char str[]={"CODEFESTIVAL2016"};
	char find[101];
	gets(find);
	int i,ans=0;
	for(i=0;i<=strlen(find);i++)
		if(find[i]!=str[i])
			ans++;
	printf("%d\n",ans);
}

Measured memory_bytes: 128
/*Lucky_Glass*/
#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;

const int N=12,M=1e3;

int n,m;
int f[M+3][1<<N+1];

int main(){
	memset(f,0x3f,sizeof f);
	int inf=f[0][0];
	f[0][0]=0;
	scanf("%d%d",&n,&m);
	for(int i=1;i<=m;i++){
		int cst,vm,VS=0;
		scanf("%d%d",&cst,&vm);
		for(int j=1;j<=vm;j++){
			int inp;scanf("%d",&inp);
			VS|=(1<<inp-1);
		}
		for(int S=0;S<(1<<n);S++){
			f[i][S|VS]=min(f[i][S|VS],f[i-1][S]+cst);
			f[i][S]=min(f[i][S],f[i-1][S]);
		}
	}
	if(f[m][(1<<n)-1]==inf) printf("-1\n");
	else printf("%d\n",f[m][(1<<n)-1]);
	return 0;
}

Measured memory_bytes: 32256
#include<iostream>
#include<string>
#include<iomanip>
#include<cmath>
#include<vector>
#include<algorithm>

using namespace std;

#define int long long
#define rep(i,n) for(int i = 0; i < (n); i++)
#define INF ((long long)1e18)
#define MOD ((int)1e9+7)
#define endl "\n"

#define yn(f) ((f)?"Yes":"No")
#define YN(f) ((f)?"YES":"NO")

#define MAX

signed main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	cout<<fixed<<setprecision(10);
	
	int n, t;
	int sum = 0, speed = 0;
	vector<int> h;
	vector<pair<int,int>>ans;
	
	cin>>n>>t;
	
	h.resize(n);
	
	for(int i = 0; i < n; i++){
		cin>>h[i];
	}
	
	for(int i = 0; i < n; i++){
		pair<int,int> temp;
		if(sum >= t){
			temp.first = 1;
			temp.second = 1;
		} else {
			// cout<<"sum ->"<<sum<<" sp -> "<<speed<<endl; 
			if(speed <= h[i]){
				temp.first = (t - sum)/h[i] + 1;
				temp.second = ((t - sum)/h[i])*h[i] + sum;
				speed = h[i];
			} else {
				// cout<<t<<" - "<<ans[i-1].second<<" "<<h[i]<<yn(t - ans[i-1].second < h[i])<<endl;
				if(t - ans[i-1].second < h[i]){
					temp.first = ans[i-1].first-1;
					temp.second = ans[i-1].second - speed + h[i];
				} else {
					temp.first = ans[i-1].first;
					temp.second = ans[i-1].second + h[i];
				}
			}
		}
		ans.push_back(temp);
		sum += h[i];
	}
	
	for(int i = 0; i < n; i++){
		// cout<<ans[i].first<<" "<<ans[i].second<<endl;
		cout<<ans[i].first<<endl;
	}
	return 0;
}


Measured memory_bytes: 5720
#include <stdio.h>

int main(void) {
  int i, j, k, a, b, c, ma, mb, ans = 10000, n;
  scanf("%d%d%d", &n, &ma, &mb);
  int dp[n * 10 + 1][n * 10 + 1];
  for(i = 0; i <= n * 10; ++i) for(j = 0; j <= n * 10; ++j) dp[i][j] = 1e9;
  dp[0][0] = 0;
  for(i = 0; i < n; ++i) {
    scanf("%d%d%d", &a, &b, &c);
    for(j = n * 10; j >= 0; --j) for(k = n * 10; k >= 0; --k) if(j + a <= n * 10 && k + b <= n * 10 && dp[j + a][k + b] > dp[j][k] + c) dp[j + a][k + b] = dp[j][k] + c;
  }
  for(i = 1; ma * i <= 10 * n && mb * i <= 10 * n; ++i) if(ans > dp[ma * i][mb * i]) ans = dp[ma * i][mb * i];
  if(ans != 10000) printf("%d", ans);
  else printf("-1");
  return 0;
}

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

#define inf 1000000007

using namespace std;

typedef long long ll;

ll a[200005];

int main()
{
    int n;
    ll z=0;
    scanf("%d",&n);
    for(int i=0;i<n;i++)
    {
        scanf("%lld",&a[i]);
        z=z^a[i];
    }
    for(int i=0;i<n;i++)
    {
        printf("%lld%c",a[i]^z,i+1==n?'\n':' ');
    }
    return 0;
}


Measured memory_bytes: 5368
#include <bits/stdc++.h>
#define rep(i, n) for (ll i = 0; i < (ll)(n); ++i)
#define rep2(i, s, n) for (ll i = s; i < (ll)(n); i++)
#define repr(i, n) for (ll i = n; i >= 0; i--)
#define fi first
#define sc second
#define pb push_back
#define COUT(x) cout << (x) << "\n"
#define COUTF(x) cout << setprecision(15) << (x) << "\n"
#define ENDL cout << "\n"
#define DF(x) x.erase(x.begin())  // 先頭文字削除
#define ALL(x) x.begin(), x.end()
#define SZ(x) (ll) x.size()
#define SORT(x) sort(ALL(x))
#define REVERSE(x) reverse(ALL(x))
#define MAX(x, y, z) max(a, max(b, c))
#define MIN(x, y, z) min(x, min(y, z))
#define ANS cout << ans << "\n"
#define RETURN(x)    \
  cout << x << "\n"; \
  return 0
clock_t CLOCK;
#define START_TIMER CLOCK = clock()
#define SHOW_TIMER cerr << "time: " << (ld)(clock() - CLOCK) / 1000000 << "\n"
#define init() \
  cin.tie(0);  \
  ios::sync_with_stdio(false)
#define LINE cerr << "[debug] line: " << __LINE__ << "\n";
#define debug(x) cerr << "[debug] " << #x << ": " << x << "\n";
#define debugV(v)                       \
  cerr << "[debugV] " << #v << ":";     \
  rep(i, v.size()) cerr << " " << v[i]; \
  cerr << "\n";
using namespace std;
using ll = long long;
using ld = long double;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
using mll = map<ll, ll>;
using qll = queue<ll>;
using P = pair<ll, ll>;

constexpr ll INF = 0x3f3f3f3f3f3f3f;
constexpr ld PI = 3.141592653589793238462643383279;
ll get_digit(ll x) {
  return to_string(x).size();
}

ll gcd(ll x, ll y) {
  return y ? gcd(y, x % y) : x;
}

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

vector<P> factorize(ll n) {
  vector<P> result;
  for (ll i = 2; i * i <= n; ++i) {
    if (n % i == 0) {
      result.pb({i, 0});
      while (n % i == 0) {
        n /= i;
        result.back().second++;
      }
    }
  }
  if (n != 1) {
    result.pb({n, 1});
  }
  return result;
}

vll divisor(ll n) {
  vll ret;
  for (ll i = 1; i * i <= n; i++) {
    if (n % i == 0) {
      ret.push_back(i);
      if (i * i != n) ret.push_back(n / i);
    }
  }
  SORT(ret);
  return (ret);
}

signed main() {
  init();
  ll A, B, Q;
  cin >> A >> B >> Q;
  vll s(A);
  rep(i, A) cin >> s[i];
  vll t(B);
  rep(i, B) cin >> t[i];

  rep(i, Q) {
    ll x;
    cin >> x;
    ll ubA = upper_bound(ALL(s), x) - s.begin();
    ll ubB = upper_bound(ALL(t), x) - t.begin();
    ll lbA = lower_bound(ALL(s), x) - s.begin();
    ll lbB = lower_bound(ALL(t), x) - t.begin();
    ll l_A = ubA != 0 ? s[ubA - 1] : -INF;
    ll l_B = ubB != 0 ? t[ubB - 1] : -INF;
    ll r_A = lbA != (ll)s.size() ? s[lbA] : INF;
    ll r_B = lbB != (ll)t.size() ? t[lbB] : INF;
    ll distance1 = max(abs(l_A - x), abs(l_B - x));
    ll distance2 = max(abs(r_A - x), abs(r_B - x));
    ll distance3 = 2 * abs(r_A - x) + abs(l_B - x);
    ll distance4 = 2 * abs(r_B - x) + abs(l_A - x);
    ll distance5 = 2 * abs(l_A - x) + abs(r_B - x);
    ll distance6 = 2 * abs(l_B - x) + abs(r_A - x);
    ll a = min(distance1, min(distance2, distance3));
    ll b = min(distance4, min(distance5, distance6));
    ll ans = min(a, b);
    COUT(ans);
  }
  return 0;
}

Measured memory_bytes: 4764
#include<cstdio>
#include<iostream>
#include<queue>
#include<cstring>

namespace solve{
	#define INF 0x7fffffff
	typedef long long ll;
	#define N 100005

	struct Edge{
		int nxt,to,w;
	}e[N<<1];

	struct heap{
		int u,d;
		bool operator<(const heap& rhs)const{
			return rhs.d<d;
		}
	};

	int k,cnt;
	int head[N],dis[N];
	
	void addEdge(int u,int v,int w){
		e[++cnt]=(Edge){head[u],v,w};
		head[u]=cnt;
	}

	void init(){
		std::cin>>k;
		for(int i=1;i<k;i++){
			addEdge(i,(i+1)%k,1);
			addEdge(i,(i*10)%k,0);
		}
	}

	void Dijkstra(int s){
		std::priority_queue<heap> q;
		memset(dis,0x3f,sizeof(dis));
		dis[s]=0;
		q.push((heap){s,dis[s]});
		while(!q.empty()){
			heap x=q.top();q.pop();
			int u=x.u;
			if(x.d!=dis[u])continue;
			for(int i=head[u];i;i=e[i].nxt){
				int v=e[i].to,w=e[i].w;
				if(dis[v]>dis[u]+w){
					dis[v]=dis[u]+w;
					q.push((heap){v,dis[v]});
				}
			}
		}
	}

	void work(){
		Dijkstra(1);
		printf("%d\n",dis[0]+1);
	}
}

int main(int argc,char* argv[]){
	solve::init();
	solve::work();
	return 0;
}

Measured memory_bytes: 3964
#define _USE_MATH_DEFINES
#include <cassert>
#include <cstdio>
#include <cstring>
#include <iostream>
#include <string>
#include <sstream>
#include <vector>
#include <queue>
#include <stack>
#include <list>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <algorithm>
#include <complex>
#include <cmath>
#include <numeric>
#include <bitset>

using namespace std;

#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
  cerr << name << ": " << arg1 << endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
  const char* comma = strchr(names + 1, ',');
  cerr.write(names, comma - names) << ": " << arg1 << " |";
  __f(comma + 1, args...);
}

typedef long long int64;
typedef pair<int, int> ii;
const int INF = 1 << 30;
const int MOD = 1e9 + 7;

const int N = 1e3 + 10;
char s[N];
int main() {
  int n;
  scanf("%d%s", &n, s);
  int sum = 0, ret = 0;
  for (int i = 0; i < n; ++i) {
    if (s[i] == '(') ++sum;
    else --sum;
    ret = min(ret, sum);
  }
  int cnt = sum - ret;
  ret = -ret;
  for (int i = 0; i < ret; ++i) putchar('(');
  printf("%s", s);
  for (int i = 0; i < cnt; ++i) putchar(')');
  puts("");
  return 0;
}


Measured memory_bytes: 256
import java.util.*;

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

        String k = sc.next();

        String a = k.substring(0,1);
        String b = k.substring(1,2);
        String c = k.substring(2,3);
        String d = k.substring(3,4);

        Boolean g;

        if(a.equals(b)){
            g = true;
        }else if(b.equals(c)){
            g = true;
        }else if(c.equals(d)){
            g = true;
        }else{
            g = false;
        }

        if(g){
            System.out.println("Bad");
        }else{
            System.out.println("Good");
        }


    }
}

Measured memory_bytes: 21844
import java.util.*;
import java.util.Map.*;
public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int[] a = new int[4];
        for (int i = 0; i < 3; i++) {
            int x = sc.nextInt() - 1;
            int y = sc.nextInt() - 1;
            a[x]++;
            a[y]++;
        }
        for (int i = 0; i < 4; i++) {
            if (a[i] > 2) {
                System.out.println("NO");
                return;
            }
        }
        System.out.println("YES");
    }
}


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

namespace program {
  class Program {
    static void Main()
    {
      var a = Input.ScanInt();
      if(a < 3200){
      Out("red"); return;
      }else{
        Out(Input.ScanStr());
      }
        
    }
    static public void Out(object s) { Console.Write($"{s} "); }
  }
  
  static class Input {
    static public int ScanInt() { return int.Parse(Console.ReadLine()); }
    static public uint ScanUint() { return uint.Parse(Console.ReadLine()); }
    static public double ScanDouble() { return double.Parse(Console.ReadLine()); }
    static public long ScanLong() { return long.Parse(Console.ReadLine()); }
    static public ulong ScanUlong() { return ulong.Parse(Console.ReadLine()); }
    static public int[] ScanIntArray() { return Console.ReadLine().Split().Select(x => int.Parse(x)).ToArray(); }
    static public uint[] ScanUintArray() { return Console.ReadLine().Split().Select(x => uint.Parse(x)).ToArray(); }
    static public double[] ScanDoubleArray() { return Console.ReadLine().Split().Select(x => double.Parse(x)).ToArray(); }
    static public long[] ScanLongArray() { return Console.ReadLine().Split().Select(x => long.Parse(x)).ToArray(); }
    static public ulong[] ScanUlongArray() { return Console.ReadLine().Split().Select(x => ulong.Parse(x)).ToArray(); }

    static public string ScanStr() { return Console.ReadLine(); }
    static public string[] ScanStrArray() { return ScanStr().Split(); }
  }
  
  static class MyMath {
    public static int GCD(int a, int b) {
        Func<int, int, int> gcd = null;
        gcd = (x, y) => y == 0 ? x : gcd(y, x % y);
        return a > b ? gcd(a, b) : gcd(b, a);
    }
    public static long GCD(long a, long b) {
        Func<long, long, long> gcd = null;
        gcd = (x, y) => y == 0 ? x : gcd(y, x % y);
        return a > b ? gcd(a, b) : gcd(b, a);
    }
    public static long extGCD(long a, long b, ref long x, ref long y) {
      if(b==0) {
        x=1; 
        y=0;
        return a;
      }
      var d = extGCD(b, a%b, ref y, ref x);
      y -= a/b *x;
      return d;
    }
    public static int LCM(int a, int b) { return a * b / GCD(a, b); }
    public static long LCM(long a, long b) { return a * b / GCD(a, b); }
  }
}


Measured memory_bytes: 13268
#include<bits/stdc++.h>
using namespace std;
#define inf 1e15

int main(){
  
  long long n,tot,ans=0;
  cin>>n>>tot;
  vector<long long>dp(1e5+5,inf);
  dp[0]=0;
  for(int i=1;i<=n;i++){
    long long i1,i2;
    cin>>i1>>i2;
    for(int j=1e5;j>=0;j--){
      dp[j]=(j<i2)?dp[j]:min(dp[j],dp[j-i2]+i1);
    }
  }
  
  for(int i=0;i<=1e5;i++){
    if(dp[i]<=tot)
      ans=max(ans,1LL*i);
 }
  cout<<ans;
  return 0;
}

Measured memory_bytes: 1024
import java.util.*;

class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int x = sc.nextInt();
		int y = sc.nextInt();
    if(y%2 == 0 && y >= 2*x && y <= 4*x){
      System.out.println("Yes");
    }else System.out.println("No");
	}
}


Measured memory_bytes: 35788
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();
		for (int i=0;i<100;i++) {
			for (int j=0;j<100;j++) {
				if (i*4+j*2==Y&&i+j==X) {
					System.out.println("Yes");
					return ;
				}
			}
		}

		System.out.println("No");
	}
}

Measured memory_bytes: 35820
def main():
    num = [int(x) for x in list(input())]
    num.reverse()
    tot = 0
    N = len(num)

    for m in range(N):
        tot += ((2**(N-4)) * (5**(m) - 1) + (2**(N-m-1)) * (10**(m))) * num[m]

    print(int(tot))

if __name__ == '__main__':
  main()


Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep1(i,n) for(int i=1;i<=(int)(n);i++)
#define all(c) c.begin(),c.end()
#define pb push_back
#define fs first
#define sc second
#define show(x) cout << #x << " = " << x << endl
#define chmin(x,y) x=min(x,y)
#define chmax(x,y) x=max(x,y)
using namespace std;
int H,W;
string s[52];
int dx[4]={-1,0,1,0},dy[4]={0,1,0,-1};
bool vis[52][52];
int dd[3][3]={
	{1,1,2},
	{0,-1,2},
	{0,3,3}
};
int main(){
	cin>>H>>W;
	rep1(i,H) cin>>s[i];
	s[0]=s[H+1]=string(W+2,'#');
	rep1(i,H) s[i]="#"+s[i]+"#";
	H+=2,W+=2;
	int x,y,d;
	rep(i,H) rep(j,W){
		if(s[i][j]=='^') x=i,y=j,d=0;
		if(s[i][j]=='>') x=i,y=j,d=1;
		if(s[i][j]=='v') x=i,y=j,d=2;
		if(s[i][j]=='<') x=i,y=j,d=3;
	}
	int bx=x+dx[(d+1)%4],by=y+dy[(d+1)%4];
	bool ok=0;
	rep(i,50*50*4){
		vis[x][y]=1;
		if(s[x][y]=='G'){
			ok=1;
			break;
		}
		int d=dd[x-bx+1][y-by+1];
		int nx=x+dx[d],ny=y+dy[d];
		if(s[nx][ny]=='#'){
			bx=nx,by=ny;
		}else{
			x=nx,y=ny;
		}
	}
	if(!ok){
		puts("-1");
		return 0;
	}
	int ans=0;
	rep(i,H) rep(j,W) if(vis[i][j]) ans++;
	cout<<ans<<endl;
}

Measured memory_bytes: 1240
N,M = map(int,input().split())
A = []
for n in range(N):
	a,b = map(int,input().split())
	A.append([a,b])
B = []
for m in range(M):
	l = list(map(int,input().split()))
	l.append(m)
	B.append(l)

for a in A:
	R = min([abs(B[i][0] - a[0]) + abs(B[i][1] - a[1]) for i in range(M)])
	B2 = [b for b in B if abs(b[0] - a[0]) + abs(b[1] - a[1]) == R]
	print(min([b[2] for b in B2]) + 1)


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

int main()
{
	int N, sum = 0;
	cin >> N;
	
	int *A = new int[N];
	int *B = new int[N - 1];
	for (int i = 0; i < N - 1; cin >> B[i], i++);

	A[0] = B[0];
	A[N - 1] = B[N - 2];
	for (int i = 1; i < N - 1; A[i] = B[i] > B[i - 1] ? B[i - 1] : B[i], i++);
	for (int i = 0; i < N; sum += A[i], i++);
	cout << sum << endl;
	delete[] A, B;

	return 0;
}

Measured memory_bytes: 256
from sys import stdin
import sys
import math
from functools import reduce
import functools
import itertools
from collections import deque,Counter,defaultdict
from operator import mul
import copy
# ! /usr/bin/env python
# -*- coding: utf-8 -*-
import heapq
sys.setrecursionlimit(10**6)
# INF =  float("inf")
INF = 10**18
import bisect
import statistics
mod = 10**9+7
# mod = 998244353

S, T = map(str, input().split())

print(T+S)

Measured memory_bytes: 77508
#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
#define int long long
#define all(X) (X).begin(), (X).end()
#define reset(X) memset(X, 0, sizeof(X))
#define mp(a, b) make_pair(a, b)
#define pb push_back
#define endl '\n'
#define fi first
#define se second



using namespace __gnu_pbds;
using namespace std;
// const int mod=1e9+7;
 const int mod=998244353;
const int INF=4e18+10;
template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

#define readv(x, n) vector<int> x(n); for(auto &i:x) cin>>i; 


int pow(int a, int b)
{
    int prod=1;
    int mult=a%mod;
    while(b!=0)
    {
        if(b%2)
        {
            prod*=mult;
            prod%=mod;
        }
        mult*=mult;
        mult%=mod;
        b/=2;
    }
    return prod;
}
int mod_inv(int q, int mod)
{
    return pow(q, mod-2);
}



bool is_palindrome(string s)
{
    int n=s.size();
    for(int i=0;i<n;i++)
    {
        if(s[i]!=s[n-1-i])
            return false;
    }
    return true;
}

signed main()

{
     ios_base::sync_with_stdio(false);
     cin.tie(NULL);  
       cout.tie(NULL);
     #ifndef ONLINE_JUDGE
        if(fopen("INPUT.txt","r"))
        {
        freopen ("INPUT.txt" , "r" , stdin);
        freopen ("OUTPUT.txt" , "w" , stdout);
        }
     #endif
    auto clk=clock(); 
    // -------------------------------------Code starts here---------------------------------------------------------------------     
    
    int l;
    cin>>l;
    cout<<setprecision(100)<<((l/3.0)*(l/3.0)*(l/3.0))<<endl;

    // -------------------------------------Code ends here------------------------------------------------------------------

    clk = clock() - clk;
    cerr << fixed << setprecision(6) << "Time: " << ((double)clk)/CLOCKS_PER_SEC << "\n";
    return 0;
 }


Measured memory_bytes: 256
import sys


def solve():
    readline = sys.stdin.buffer.readline
    mod = 10 ** 9 + 7
    s = str(readline().rstrip().decode('utf-8'))
    mt = 0
    for i in range(len(s)):
        tt = ""
        t = 0
        if i != 0:
            m = 10 ** i
            tt = str(int(s) // m * m - 1)
            t = 0
        else:
            tt = s
        for j in range(len(tt)):
            t += int(tt[j])
        mt = max(mt, t)
    print(mt)


if __name__ == '__main__':
    solve()


Measured memory_bytes: 38384