akhauriyash/Code-Regression huggingface dataset:
# import math
# from itertools import permutations as permus
# from fractions import gcd

# import numpy as np
# import scipy as scp

# 入力の受け取り
n,m = map(int,input().split())

arrSC = []
for _ in range(m):
    arrSC.append(list(map(int,input().split()))) # 行列の場合
    
ans = -1

def Ncheck(strnum):
    if len(strnum) != n:
        return False
    return True

def SCcheck(strnum):
    for i in range(m):
        if strnum[arrSC[i][0]-1] != str(arrSC[i][1]):
            return False
    return True

for num in range(1000):
    strnum = str(num)
    if Ncheck(strnum) and SCcheck(strnum):
        ans = num
        break

print(ans)

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

int main() {
    int H, W, cnt=0; cin >> H >> W;
    for(int i=0;i<H;i++){
    	for(int j=0;j<W;j++){
            char x; cin >> x;
            if(x=='#') cnt++;
    	} 
    }
    cout << (cnt==H+W-1?"Possible":"Impossible") << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N,M;
  cin >> N >> M;
  vector<int> road1(M);
  vector<int> road2(M);
  vector<int> machi(N);
  
  for(int i = 0; i < M; i++) {
    cin >> road1.at(i) >> road2.at(i);
  }
  
  for(int i = 0; i < M; i++) {
    
    for(int j = 0; j < N; j++) {
      
       if ( road1.at(i) == j + 1 || road2.at(i) == j + 1) {
         
         machi.at(j)++;
         
      } 
    }
  }
  
  for(int j = 0; j < N; j++) {
    
    cout << machi.at(j) << endl;
  }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using Int = long long;
int main()
{
    int N; cin >> N;
    vector<Int> A(N); for (auto &a : A) cin >> a;
    Int ans = 0, curr = 0;
    for (int i = 0; i < N; i++) {
        int t = (A[i] - 1) / (curr + 1);
        ans += t;
        if (i == 0) curr = 1;
        else if (t == 0) curr = max(curr, A[i]);
    }
    cout << ans << '\n';
    return 0;
}

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

using namespace std;

#define rep(i, n) for (ll i = 0; i < (n); ++i)
#define rrep(i, n) for (ll i = (n - 1); i >= 0; --i)
#define blank(ans) cout << (ans) << " ";
#define mp(p, q) make_pair(p, q)
#define mt(p, q, r) make_tuple(p, q, r)
#define pb(n) push_back(n)
#define all(a) a.begin(), a.end()

typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef string str;

typedef vector<ll> vll;
typedef vector<ld> vd;
typedef vector<bool> vb;
typedef vector<bitset<20>> vbi;
typedef vector<char> vc;
typedef vector<str> vs;
typedef vector<vector<ll>> vvll;
typedef vector<vector<ld>> vvd;
typedef vector<vector<bool>> vvb;
typedef vector<vector<char>> vvc;
typedef vector<vector<str>> vvs;
typedef vector<pair<ll, ll>> vpll;
typedef vector<tuple<ll, ll, ll>> vtlll;

const ld PI = acos(-1.0);
const ll MAX = 9000000000000000000;
const ll MIN = -9000000000000000000;
const ld DMAX = 4500;
const ld DMIN = -4500;
const ll MOD = 1000000007;

template <typename T>
void fin(T a)
{
  cout << a << endl;
  exit(0);
}

//桁数
ll GetDigit(ll num)
{
  return log10(num) + 1;
}

//約数全列挙
vector<ll> enum_div(ll n)
{
  vector<ll> 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(begin(ret), end(ret));
  return ret;
}

//累乗(xのn乗%mod)
ll modpow(ll x, ll n, ll mod = MAX)
{
  ll res = 1;
  while (n > 0)
  {
    if (n & 1)
      res = res * x % mod;
    x = x * x % mod;
    n >>= 1;
  }
  return res;
}

//階乗
ll factorial(ll n)
{
  if (n > 0)
    return n * factorial(n - 1);
  else
    return 1;
}

ll modinv(ll a, ll mod)
{
  ll b = mod, u = 1, v = 0;
  while (b)
  {
    ll t = a / b;
    a -= t * b;
    swap(a, b);
    u -= t * v;
    swap(u, v);
  }
  u %= mod;
  if (u < 0)
    u += mod;
  return u;
}

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

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

void Main()
{
  ll n, h; cin >> n >> h;
  vll a(n), b(n);
  ll A = 0;
  rep(i, n)
  {
    cin >> a[i] >> b[i];
    A = max(A, a[i]);
  }
  sort(all(b));
  reverse(all(b));
  ll flag = 0;
  rep(i, n)
  {
    if(b[i] > A)
    {
      flag++;
      h -= b[i];
    }
    else break;
    if(h <= 0) fin(flag);
  }
  fin(flag + (h + A - 1) / A);
}

//前処理
int main()
{
  //ios::sync_with_stdio(false);
  //cin.tie(0);
  cout << fixed << setprecision(20); //高精度少数表示
  //cout << setfill('0') << internal << setw(4); 0埋め４桁
  Main();
  return 0;
}


Measured memory_bytes: 1792
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10**6)
n,q = map(int,input().split())

g = [[] for _ in range(n)]
c = [0] * n
visited = [False] * n

#根に近い順に累積和
def dfs(i):
    visited[i] = True
    for j in g[i]:
        if visited[j] == True:
            continue
        c[j]+=c[i]
        dfs(j)

for i in range(n - 1):
    a,b = map(int,input().split())
    a-=1
    b-=1
    g[a].append(b)
    g[b].append(a)

for i in range(q):
    p,x = map(int,input().split())
    c[p - 1]+=x

dfs(0)
print(*c)


Measured memory_bytes: 232496
#include<bits/stdc++.h>
using namespace std;
//#define int long long
#define REP(i,m,n) for(int i=(m);i<(n);i++)
#define rep(i,n) REP(i,0,n)
#define pb push_back
#define all(a) a.begin(),a.end()
#define rall(c) (c).rbegin(),(c).rend()
#define mp make_pair
#define endl '\n'
#define vec vector<ll>
#define mat vector<vector<ll> >
#define fi first
#define se second
typedef long long ll;
typedef pair<ll,ll> pll;
typedef long double ld;
const ll inf=1e9+7;
const ll mod=1e4+7;

const int MAX=1000100;

int trie[MAX][26];
int leaf[MAX];

int sz=1;
void add_string(string s){
    int v=0;
    for(auto c:s){
        if(!trie[v][c-'a']){
            trie[v][c-'a']=sz;
            sz++;
        }
        v=trie[v][c-'a'];
    }
    leaf[v]=1;
}

signed main(){
    int n;cin>>n;
    vector<string>a(n);
    rep(i,n){
        cin>>a[i];
        reverse(all(a[i]));
        add_string(a[i]);
    }
    int ans=0;
    rep(i,n){
        string s;
        s=a[i];
        vector<int>cnt(26);
        for(auto c:s){
            cnt[c-'a']++;
        }
        int v=0;
        rep(j,s.size()){
            rep(x,26){
                if(cnt[x]&&trie[v][x]){
                    ans+=leaf[trie[v][x]];
                }
            }
            cnt[s[j]-'a']--;
            v=trie[v][s[j]-'a'];
        }
        ans--;
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 109592
import std.stdio, std.array, std.string, std.conv, std.algorithm;
import std.typecons, std.range, std.random, std.math, std.container;
import std.numeric, std.bigint, core.bitop, core.stdc.stdio;



bool solve() {
    auto s = readln.split.map!(to!int);
    auto C = s[0];
    auto R = s[1];
    auto N = s[2];

    Tuple!(int, int)[] points;

    foreach (i; 0..N) {
        s = readln.split.map!(to!int);
        int x1 = s[0];
        int y1 = s[1];
        int x2 = s[2];
        int y2 = s[3];

        if ((x1 == 0 || x1 == C || y1 == 0 || y1 == R) &&
            (x2 == 0 || x2 == C || y2 == 0 || y2 == R)) {
            if      (y1 == 0) points ~= tuple(x1, i);
            else if (x1 == C) points ~= tuple(C + y1, i);
            else if (y1 == R) points ~= tuple(C + R + (C - x1), i);
            else if (x1 == 0) points ~= tuple(C + R + C + (R - y1), i);
            if      (y2 == 0) points ~= tuple(x2, i);
            else if (x2 == C) points ~= tuple(C + y2, i);
            else if (y2 == R) points ~= tuple(C + R + (C - x2), i);
            else if (x2 == 0) points ~= tuple(C + R + C + (R - y2), i);
        }
    }

    points.sort();
    DList!int stack;

    foreach (p; points) {
        if (stack.empty) stack.insertBack(p[1]);
        else if (stack.back == p[1]) stack.removeBack;
        else stack.insertBack(p[1]);
    }

    return stack.empty;
}

void main() {
    writeln(solve ? "YES" : "NO");
}


Measured memory_bytes: 9468
#include<bits/stdc++.h>
using namespace std;
int n;
long long a[101111];
int main()
{
	cin>>n;
	for(int i=0;i<n;i++)
	{
		cin>>a[i];
	}
	sort(a,a+n);
	reverse(a,a+n);
	int ans=1e9+10;
	long long res;
	for(int i=1;i<n;i++)
	{
		if(abs(a[i]-(a[0]-a[i]))<ans)
		{
			ans=abs(a[i]-(a[0]-a[i]));
			res=a[i];
		}
	}
	cout<<a[0]<<' '<<res<<endl;
	return 0;
}

Measured memory_bytes: 1024
#include <iostream>
using namespace std;
    
int main()
{
    int a = 0;
    int b = 0; 
    cin >> a >> b;
    if (a > b)
    {
        cout << "a > b"<< endl;
    }
    else if (a < b)
    {
        cout << "a < b" << endl;
    }
    else {
        cout << "a == b" << endl;
    }
    return 0;
}

Measured memory_bytes: 3088
#include <bits/stdc++.h>
using namespace std;
using lint = long long;
using pi = pair<int, int>;
const int mod = 1e9 + 7;
const int MAXN = 2000005;

int n;
lint dp[MAXN], sum[MAXN];

int main(){
	cin >> n;
	for(int i=MAXN-1; i>=n; i--) dp[i] = 1, sum[i] = MAXN - i;
	for(int i=n-1; i>=0; i--){
		if(i <= n - 2){
		dp[i] = dp[i + 1] + 1ll * (n - 1) * (n - 1) % mod;
		dp[i] += sum[i + 3] - sum[i + n + 2] + mod;
		dp[i] %= mod;
		}
		else{
			dp[n - 1] = n;
		}
		sum[i] = (sum[i + 1] + dp[i]) % mod;
	}
	cout << dp[0] << endl;
}



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

int main() {
	int N;
	int ans = 0;
	int cnt = 0;
	int prev = 0;

	cin >> N;
	for (int i = 0; i < N; i++) {
		int a;
		cin >> a;
		if (a == prev) {
			cnt++;
		}
		else {
			prev = a;
			ans += cnt / 2;
			cnt = 1;
		}
	}
	ans += cnt / 2;

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <fstream>
#include <set>
#include <map>
#include <vector>
#include <algorithm>
#include <cmath>
#include <chrono>
using namespace std;


int main(int argc, const char * argv[]) {
    
    ios::sync_with_stdio(false);
    cin.tie(0);
    
    int64_t N;
    cin >> N;
    
    int64_t a = 1;
    for (int64_t i = 2; i < sqrt(N) + 1.1; i++) {
        if (N % i == 0) a = i;
    }
    int64_t c = max(a, N / a);
    int64_t cnt = 0;
    while (c > 0) {
        c /= 10;
        cnt++;
    }
    
    cout << cnt << endl;
    
    return 0;
}


Measured memory_bytes: 256
N = int(input())
edges = [[] for i in range(N)]
ans = [-1] * (N - 1)
lines = []

for i in range(N - 1):
    a, b = map(int, input().split())
    lines.append((a, b))
    edges[a - 1].append((b - 1, i,))

q = [(0, 0,)]
max_color = 0
while q:
    v, c = q.pop()
    color = 1
    if c == color:
        color += 1
    for nv, i in edges[v]:
        ans[i] = color
        q.append((nv, color,))
        color += 1
        if c == color:
            color += 1

print(max(ans))
for i in range(N - 1):
    a, b = lines[i]
    print(ans[i])


Measured memory_bytes: 40372
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n,m;
    cin>>n>>m;
    vector<vector<int>> s(n);
    for(int i=0;i<m;++i)
    {
        int k;
        cin>>k;
        for(int j=0;j<k;++j)
        {
            int x;
            cin>>x;
            s[x-1].push_back(i);
        }
    }
    vector<int> p(m);
    for(int i=0;i<m;++i)cin>>p[i];
    int ans = 0;
    for(int i=0;i<(1<<n);++i)
    {
        
        vector<int> cnt(m,0);
        for(int l=0;l<n;++l)
        {
            if(i&(1<<l))
            {
                for(int x : s[l])
                    cnt[x]++;
            }
        }
        bool flag = 0;
        for(int j=0;j<m;++j)
        {
            if(cnt[j]%2 != p[j])
                flag = 1;
        }
        if(!flag)ans++;
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
 
int main() {
	long a,b;
	while (cin>>a>>b){
		long c = a;
	    long d = b;
	while (true) {
		if(c % d == 0) break;
		long e = d;
		d = c % d;
		c = e;
	}cout<<d<<" "<<a*b/d<<endl;
	}
}

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

int main() {
  
  int a, b;
  cin >> a >> b;
  
  int ans = 0, c = 0;  
  REP(i,1000) {
    c += i;
    if (c - a == c + i + 1 - b) cout << c - a;
  }

}


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

int main() {
  // 入力
  string s;
  int k;
  cin >> s >> k;

  // 前から、aにできる時は最小の操作回数でaにしていく貪欲法
  // 残りの操作回数でどの文字もaにできなくなった時は、残りの操作回数分最後の文字に操作をすればよい
  int L = s.size();
  for (int i = 0; i < L - 1; i++) {
    if (s[i] == 'a') continue;
    if (26 - (s[i] - 'a') <= k) {
      k -= 26 - (s[i] - 'a');
      s[i] = 'a';
    }
  }

  // 最後の文字への操作
  k %= 26;
  // k = (k + (s[s.size()-1] - 'a')) % 26;
  // s[s.size()-1] = 'a' + k;
  while (k--) {
    s[L-1]++;
    if (s[L-1] > 'z') s[L-1] = 'a';
  }

  // 解答
  cout << s << endl;

  return 0;
}


Measured memory_bytes: 512
#include <iostream>
#include <cmath>
using namespace std;
int main(void){
    int n;
    int array[1000];
    int dp[101][10000];
    int i,j;
    cin >> n;
    for(i = 0; i < n; i++){
        cin >>array[i];
    }
    dp[0][0] = 1;
    for(i = 1; i <= n; i++){
        for(j = 0; j <= 10000; j++){
            dp[i][j] = dp[i-1][j];
            if(j >= array[i-1]){
                dp[i][j] = dp[i][j] || dp[i-1][j - array[i-1]];
            }
        }
    }
    
    for(i = 10000; i >= 0; i--){
        if(i % 10 == 0)continue;
        if(dp[n][i]){
            cout << i;
            return 0;
        }
    }
    cout << 0;
}


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

using namespace std;
using ll = long long;
using P = pair<int,int>;
const ll mod = 1000000007;


int main()
{
    int n, a, b;
    cin >> n >> a >> b;
    vector<ll> h(n);
    for(int i = 0; i < n; i++)cin >> h[i];
    ll lef = 0, rig = 2000000000LL;
    auto chack = [&](ll num){
        ll sum = b * num;
        ll k = a - b;
        ll cnt = 0;
        for(int i = 0; i < n; i++){
            if(h[i] - sum <= 0)continue;
            ll acc = h[i] - sum;
            cnt += (acc + k - 1) / k;
        }
        return cnt <= num;
    };

    while(rig - lef > 1){
        ll mid = (rig + lef) / 2;
        (chack(mid) ? rig : lef) = mid;
    }
    cout << rig << endl;
}

Measured memory_bytes: 1024
#include <iostream>

using namespace std;

int main(void){
    int N, T;
    int c, t, c_min;

    cin >> N >> T;

    c_min = 10000;
    for(int i = 0;i < N;i++){
        cin >> c >> t;
        if(t <= T){
            if(c_min > c){
                c_min = c;
            }
        }
    }

    if(c_min == 10000){
        cout << "TLE" << endl;
    }else{
        cout << c_min << endl;
    }

    return 0;
}

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

int main(){
	int a,b; cin >> a >> b;
	int ans[3];
	ans[0]=a+b;
	ans[1]=a-b;
	ans[2]=a*b;
	int max=-1e9;
	for(int i=0;i<3;i++){
		if(ans[i]>max) max=ans[i];
	}
	cout << max << endl;
}


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

int main() {
  int n, m;
  cin >> n >> m;
  
  vector<int> a(m);
  vector<int> b(m);
  
  for (int i=0;i<m;i++) {
    cin >> a.at(i) >> b.at(i);
  }
  
  vector<int> road(n);
  for (int i=0;i<m;i++) {
    road.at(a.at(i) - 1) += 1;
    road.at(b.at(i) - 1) += 1; 
  }
  
  for (int i=0;i<n;i++) {
    cout << road.at(i) << endl;
  }
}

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


void solve(long long N, long long K, std::vector<long long> p){
    vector<double> ev(N, 0);
    REP(i, N){
        ev.at(i) = static_cast<double>(p.at(i) + 1) / 2.0;
    }
    vector<double> cs(N, 0);
    REP(i, N){
        if(i == 0){
            cs.at(i) = ev.at(i);
        }else{
            cs.at(i) = cs.at(i - 1) + ev.at(i);
        }
    }
    double ans = 0;
    for(ll i = K - 1; i < N; ++i){
        double tmp = cs.at(i);
        if(i - K >= 0){
            tmp -= cs.at(i - K);
        }
        ans = max(tmp, ans);
    }
    printf("%.10f\n", ans);
}

// Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools
int main(){
    long long N;
    scanf("%lld",&N);
    long long K;
    scanf("%lld",&K);
    std::vector<long long> p(N);
    for(int i = 0 ; i < N ; i++){
        scanf("%lld",&p[i]);
    }
    solve(N, K, std::move(p));
    return 0;
}


Measured memory_bytes: 4992
#include <bits/stdc++.h>
#define ll long long
#define rw freopen("input.txt","r",stdin),freopen("output.txt","w",stdout);
#define pb push_back
#define F first
#define S second
#define pf push_front
#define lp(i,a,b) for (int i=a;i<=(int)b;++i)
#define lp2(i,a,b) for (int i=a;i>=b;--i)
#define f(x) return cout<<x<<"\n",0
#define pii pair<int,int>
#define pll pair<ll,ll>
#define all(c) c.begin(),c.end()
#define allr(c) c.rbegin(),c.rend()
#define p(x) cout<<#x<<" = { "<<x<<" } \n"
#define vi vector<int>
#define vl vector<ll>
#define vii vector<pii>
#define vll vector<pll>
#define EPS 1e-6
// to convert string to number use int a = stoi(string);
// to convert number to string use string s = to_string(int);
#define FAST ios::sync_with_stdio(0),ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0);
#define clr(c,x) memset(c,x,sizeof(c));
using namespace std;
const int N=2e5+5,mod=(int)1e9+7;
ll fast_pow(ll base,int power)
{
    if (!power)
        return 1;
    ll answer=fast_pow(base,power/2)%mod;
    answer*=answer;
    if (answer>=mod)
        answer%=mod;
    if (power&1)
        answer*=base;
    if (answer>=mod)
        answer%=mod;
    return answer;
}
ll fact[N]= {};
int main()
{
#ifdef ONLINE_JUDGE
    FAST;
#endif
    int r,c,rr,cc;
    cin>>r>>c>>rr>>cc;
    fact[0]=1;
    lp(i,1,2e5)
    {
        fact[i]=fact[i-1]*i;
        fact[i]%=mod;
    }
    ll fans=0;
    lp(i,1,r-rr)
    {
        int len=i+cc-2;
        int ch=i-1;
        ll dom=(fact[ch]*fact[len-ch])%mod;
        ll lef=((fact[len]*fast_pow(dom,mod-2))%mod);
        int hs=c-cc;
        int rs=r-i+1;
        len=rs+hs-2;
        ch=rs-1;
        dom=(fact[ch]*fact[len-ch])%mod;
        ll rig=((fact[len]*fast_pow(dom,mod-2))%mod);
        ll ans=lef*rig;
        ans%=mod;
        fans+=ans;
        fans%=mod;
    }
    cout<<fans<<"\n";
    return 0;
}

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

#define	Rep0(i, n)	for (auto i=0; i<n; i++)
#define	Rep1(i, n)	for (auto i=1; i<=n; i++)
#define Sort(P)	sort(P.begin(), P.end())
#define Rev(P)	reverse(P.begin(), P.end())

int	main() {
	int N, K;
	int R, S, P;
	string T;
	cin >>N >>K >>R >>S >>P >>T;
	ll s=0;
	vector<vector<ll>> DP(N, vector<ll> (3, 0));
	Rep0(i, K) {
		ll n=N/K+1;
		char t=T.at(i);
		if ('s'==t)
			DP.at(i).at(0)=R;
		else if ('p'==t)
			DP.at(i).at(1)=S;
		else // 'p'==t
			DP.at(i).at(2)=P;
		ll j;
		for (j=i+K; j<N; j +=K) {
			t=T.at(j);
			if ('s'==t) {
				DP.at(j).at(0)=max(DP.at(j-K).at(1), DP.at(j-K).at(2))+R;
				DP.at(j).at(1)=max(DP.at(j-K).at(0), DP.at(j-K).at(2));
				DP.at(j).at(2)=max(DP.at(j-K).at(0), DP.at(j-K).at(1));
			} else if ('p'==t) {
				DP.at(j).at(0)=max(DP.at(j-K).at(1), DP.at(j-K).at(2));
				DP.at(j).at(1)=max(DP.at(j-K).at(0), DP.at(j-K).at(2))+S;
				DP.at(j).at(2)=max(DP.at(j-K).at(0), DP.at(j-K).at(1));
			} else { // 't'
				DP.at(j).at(0)=max(DP.at(j-K).at(1), DP.at(j-K).at(2));
				DP.at(j).at(1)=max(DP.at(j-K).at(0), DP.at(j-K).at(2));
				DP.at(j).at(2)=max(DP.at(j-K).at(0), DP.at(j-K).at(1))+P;
			}
		}
		j -=K;
		s +=max(DP.at(j).at(0), max(DP.at(j).at(1), DP.at(j).at(2)));
	}
	cout <<s <<endl;
	return 0;
}



Measured memory_bytes: 5760
#include<stdio.h>
#include<string.h>
int main(void)
{
 char s[4];
 int i,r=0;
 scanf("%s",s);
 for(i=0;i<4;i++){
 
 if('+'==s[i]){
 r=r+1;
}else if('-'==s[i]){
 r=r-1;
}
}
printf("%d\n",r);
return 0;
}

Measured memory_bytes: 128
package main

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

var sc *bufio.Scanner = func() *bufio.Scanner {
	sc := bufio.NewScanner(os.Stdin)
	sc.Split(bufio.ScanWords)
	return sc
}()

func nextInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}
func nextInts(n int) []int {
	ints := make([]int, n)
	for i := 0; i < n; i++ {
		ints[i] = nextInt()
	}
	return ints
}

func main() {
	n, a, b := nextInt(), nextInt(), nextInt()
	taxi := n * a
	bus := b
	if taxi < bus {
		fmt.Println(taxi)
	} else {
		fmt.Println(bus)
	}
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
#define ri register
#define int long long
#define E (n+1)
using namespace std; const int N=200010;
inline int read()
{
    int s=0, w=1; ri char ch=getchar();
    while(ch<'0'||ch>'9') { if(ch=='-') w=-1; ch=getchar(); }
    while(ch>='0'&&ch<='9') s=(s<<3)+(s<<1)+(ch^48), ch=getchar();
    return s*w;
}
signed main()
{
    int x,y,z;
    x=read(), y=read(), z=read();
    x-=z;
    printf("%lld\n",x/(y+z));
    return 0;
}

Measured memory_bytes: 3692
#include <iostream>
#include <iomanip>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <vector>
#include <algorithm>
#include <numeric>
#include <random>
#include <bitset>
#include <chrono>

using namespace std;

#define pb push_back
#define fast_cin() ios_base::sync_with_stdio(false); cin.tie(NULL)
mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count());

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

#ifndef ONLINE_JUDGE
// #include "debug.h"
#else
// #define debug(...) 42
#endif

const int M = 1e5+5;
const int MD= 1e9+7;

int cnt[M][3],rcnt[M][3];
int main() {
	fast_cin();
	int t=1;
	// cin>>t;
	while(t--)
	{
		string s;
		int n;
		ll ans=0;
		cin>>n>>s;
		s="#"+s;
		for(int i=1;i<=n;i++){
			cnt[i][0]=cnt[i-1][0],cnt[i][1]=cnt[i-1][1],cnt[i][2]=cnt[i-1][2];
			if(s[i]=='R'){
				cnt[i][0]+=1;
			}
			else if(s[i]=='G'){
				cnt[i][1]+=1;
			}
			else{
				cnt[i][2]+=1;
			}
		}
		for(int i=n;i>=1;i--){
			rcnt[i][0]=rcnt[i+1][0],rcnt[i][1]=rcnt[i+1][1],rcnt[i][2]=rcnt[i+1][2];
			if(s[i]=='R'){
				rcnt[i][0]+=1;
			}
			else if(s[i]=='G'){
				rcnt[i][1]+=1;
			}
			else{
				rcnt[i][2]+=1;
			}
		}
		for(int i=1;i<=n;i++){
			if(s[i]=='R'){
				ans+=cnt[i][1]*rcnt[i][2];
				ans+=cnt[i][2]*rcnt[i][1];
			}
			else if(s[i]=='G'){
				ans+=cnt[i][0]*rcnt[i][2];
				ans+=cnt[i][2]*rcnt[i][0];
			}
			else{
				ans+=cnt[i][0]*rcnt[i][1];
				ans+=cnt[i][1]*rcnt[i][0];
			}
			int L,R;
			L=R=i;
			while(L>0 && R<=n)
			{
				if(s[i]!=s[L] && s[i]!=s[R] && s[L]!=s[R]) ans--;
				L--;
				R++;
			}
		}
		cout<<ans<<endl;
	}	
	return 0;
}

Measured memory_bytes: 3784
#include<cstdio>
#include<algorithm>
using namespace std;
#define MAXN 100010
#define LL long long
int dis[MAXN],id[MAXN],n,m,st[MAXN];
LL k,ans[MAXN];
bool vis[MAXN];
int main()
{
	scanf("%d",&n);
	for(int i=1;i<=n;i++)
	{
		scanf("%d",&dis[i]);
		id[i]=i;
	}
	for(int i=n;i;i--)
		dis[i]=dis[i]-dis[i-1];
	scanf("%d%lld",&m,&k);
	for(int i=1,u;i<=m;i++)
	{
		scanf("%d",&u);
		swap(id[u],id[u+1]);
	}
	for(int i=1;i<=n;i++)
		if(!vis[i])
		{
			int c=0;
			for(int j=i;!vis[j];j=id[j]) st[c++]=j,vis[j]=1;
			for(int j=0;j<c;j++) ans[st[j]]=dis[st[(j+k)%c]];
		}
	for(int i=1;i<=n;i++)
	{
		ans[i]+=ans[i-1];
		printf("%lld\n",ans[i]);
	}
}

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

void f(string s,vector<int> &a){
  vector<int> seen(26);
  int p = 1;
  rep(i,int(s.size())){
    if(seen[s[i]-'a']){
      a[i]=seen[s[i]-'a'];
    }else{
      seen[s[i]-'a'] = p;
      a[i]=p;
      p++;
    }
  }
}

int main(){  
  string s,t;
  cin>>s>>t;
  int n = s.size();
  vector<int> a(n),b(n);
  
  f(s,a); f(t,b);
  
  rep(i,n){
    if(a[i]==b[i]) continue;
    puts("No");
    return 0;
  }
  puts("Yes");
}

Measured memory_bytes: 2568
#include<iostream>
#include<cmath>
int main()
{
    int n;
    std::cin >> n;
    for (int i = 0; i < n; i++)
    {
        double xa, ya, ra, xb, yb, rb;
        std::cin >> xa >> ya >> ra >> xb >> yb >> rb;
        double d = hypot(xa - xb, ya - yb);
        if (d < std::abs(ra - rb))
        {
            std::cout << 2 * (ra < rb ? -1 : 1) << std::endl;
        }
        else if (d <= ra + rb)
        {
            std::cout << 1 << std::endl;
        }
        else
        {
            std::cout << 0 << std::endl;
        }
    }
    return 0;
}


Measured memory_bytes: 3272
#include<bits/stdc++.h>
using namespace std;
int n,I,IO,IOI,cnt;
char str[1000001];
int main(){
  scanf("%d",&n);
  scanf("%s",str);  
  for(int i=0;i<n;i++){
    if(str[i]=='J'){
      I++;
    }else if(str[i]=='O'){
      if(I>0){
        I--;
        IO++;
      }else if(IOI>0){
        IOI--;
        IO+=2;
        cnt+=2;
      }
    }else if(str[i]=='I'){
      if(IO>0){
        IO--;
        if(IO<cnt)cnt--;
        IOI++;
      }else{
        I++;
      }
    }

    // cout<<I<<' '<<IO<<' '<<IOI<<' '<<cnt/2<<endl;
  }
  cout<<IOI+cnt/2<<endl;
  return 0;
}

Measured memory_bytes: 2188
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cmath>
#include<cstring>
#include<vector>
using namespace std;
#define MAXN 100000
int n,u,v,F;
vector<int> G[MAXN+5];
int dfs(int x,int fa){
	int p=0;
	for(int i=0;i<G[x].size();i++){
		int nxt=G[x][i];
		if(nxt==fa)continue;
		p+=dfs(nxt,x);
	}
	if(p>=2)F=1;
	return p^1;
}
int main()
{
	scanf("%d",&n);
	for(int i=1;i<n;i++){
		scanf("%d%d",&u,&v);
		G[u].push_back(v);
		G[v].push_back(u);
	}
	if(dfs(1,0)==0&&!F)printf("Second\n");
	else printf("First");
}

Measured memory_bytes: 5888
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
#include <math.h>
#include <iomanip>
using namespace std;
#define int long long

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

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

    sort(a.begin(),a.end(),greater<int>());
    int ans = a.at(0);

    int h = 0;

    int plus = 1;

    for(int i = 2;i < n;i ++){
        ans += a.at(plus);

        h ++;
        if(h == 2){
            h = 0;
            plus ++;
        }
    }

    cout << ans << endl;
}

Measured memory_bytes: 4776
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define MOD 1000000007
#define all(ppp) ppp.begin(),ppp.end()
#define out(ppp) cout<<(ppp)<<endl
#define out1(ppp) cout<<(ppp) 
#define MAX_CHAR 256

#define FOR(i, a, b) for (int i=a; i<(b); i++)
#define F0R(i, a) for (int i=0; i<(a); i++)
#define FORd(i,a,b) for (int i = (b)-1; i >= a; i--)
#define F0Rd(i,a) for (int i = (a)-1; i >= 0; i--)
#define pb push_back

typedef long double ld;
typedef complex<ld> cd;
 
typedef pair<int, int> pi;
typedef pair<ll,ll> pl;
typedef pair<ld,ld> pd;
 
typedef vector<int> vi;
typedef vector<double> vd;
typedef vector<vi> vvi;
typedef vector<bool> vb;
typedef vector<ll> vl;
typedef vector<pi> vpi;
typedef vector<pl> vpl;
typedef vector<cd> vcd;
typedef vector<vpi> vvpi;

typedef set<pi> spi;

const int INF=INT_MAX;


int main(){
    ll N;
    cin>>N;
    vl A(N+1);
    F0R(i,N){
        cin>>A[i+1];
    }
    vl vt(N+1);
    ll sum=0;
    for(int i=N;i>0;i--){
        int count=0;
        for(int j=2*i;j<=N;j+=i){
            if(vt[j]==1){
                count++;
            }
        }
        if(A[i]==1){
            if(count%2==0){
                vt[i]=1;
                sum++;
            }else{
                vt[i]=0;
            }
        }else{
            if(count%2==0){
                vt[i]=0;
            }else{
                vt[i]=1;
                sum++;
            }
        }
    }
    out(sum);
    for(int i=1;i<=N;i++){
        if(vt[i]==1){
            cout<<i<<" ";
        }
    }
    return 0;
}


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

string N;
int K, l;
ll d[105][4][2]{};

int main() {

    cin >> N >> K;
    l = N.length();

    d[1][0][1] = 1;
    d[1][1][0] = 1;
    d[1][1][1] = N[0] - '0' - 1;
    for (int i = 1; i < l; i++) {
        ll s = N[i] - '0';
        if (s == 0) {
            for (int j = 0; j <= 3; j++) {
                d[i + 1][j][0] = d[i][j][0];
            }
            for (int j = 0; j < 4; j++) {
                d[i + 1][j][1] = d[i][j][1];
            }
            for (int j = 0; j < 3; j++) {
                d[i + 1][j + 1][1] += d[i][j][1] * 9ll;
            }
        } else {
            for (int j = 0; j < 3; j++) {
                d[i + 1][j + 1][0] = d[i][j][0];
            }
            for (int j = 0; j < 4; j++) {
                d[i + 1][j][1] = d[i][j][1] + d[i][j][0];
            }
            for (int j = 0; j < 3; j++) {
                d[i + 1][j + 1][1] += d[i][j][1] * 9ll + d[i][j][0] * (N[i] - '0' - 1);
            }
        }

        
    }
    ll ans = 0;
    cout << d[l][K][0] + d[l][K][1] << "\n";
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define int long long
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using namespace std;
const int MOD = 1000000007;
const int INF = numeric_limits<int>::max() / 2;
typedef pair<int,int> P;
typedef pair<int,pair<int, int>> P1;

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

  int N;
  cin >> N;
  int A[10][10]{};
  for(int i=1;i<=N;i++){
    if(i % 10 == 0) continue;
    int matu = i % 10;
    int sen, M = i;
    while(M){
      sen = M;
      M /= 10;
    }
    ++A[sen][matu];
  }
  int ans = 0;
  rep(i,10){
    rep(j,10){
      ans += A[i][j] * A[j][i];
    }
  }
  cout << ans << endl;
}

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

int main(void){
  int n, y;
  cin >> n >> y;

  for(int man_yen = 0; man_yen <= n; man_yen++){
    for(int gosen_yen = 0; gosen_yen <= (n-man_yen); gosen_yen++){
      int sen_yen = n - man_yen - gosen_yen;
      if(y - (man_yen*10000 + gosen_yen*5000) == sen_yen*1000){
        cout << man_yen << " " << gosen_yen << " " << sen_yen << endl;
        return 0;
      }
    }
  }
  cout << "-1 -1 -1" << endl;
}


Measured memory_bytes: 256
#pragma region include
#include <iostream>
#include <iomanip>
#include <stdio.h>

#include <sstream>
#include <algorithm>
#include <iterator>
#include <cmath>
#include <complex>

#include <string>
#include <cstring>
#include <vector>
#include <tuple>
#include <bitset>

#include <queue>
#include <set>
#include <map>
#include <stack>
#include <list>

#include <fstream>
#include <random>
//#include <time.h>
#include <ctime>
#pragma endregion //#include
/////////
#define REP(i, x, n) for(int i = x; i < n; ++i)
#define rep(i,n) REP(i,0,n)
#define ALL(X) X.begin(), X.end()
/////////
#pragma region typedef
typedef long long LL;
typedef long double LD;
typedef unsigned long long ULL;
typedef std::pair<LL,LL> PLL;//
typedef std::pair<int,int> PII;//
#pragma endregion //typedef
////定数
const int INF = (int)1e9;
const LL MOD = (LL)1e9+7;
const LL LINF = (LL)4e18+20;
const LD PI = acos(-1.0);
const double EPS = 1e-9;
/////////
using namespace::std;

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

	vector<int> C(N),S(N),F(N);//N-1
	for(int i=0;i<N-1;++i){
		cin>>C[i]>>S[i]>>F[i];
	}
	for(int start=0;start<N-1;++start){
		int now = 0;
		for(int pos = start;pos<N-1;++pos){
			if( now < S[pos] ){
				now = S[pos] + C[pos];
			}else{
				now = ((now+F[pos]-1)/F[pos])*F[pos] + C[pos];
			}
		}
		cout << now << endl;
	}
	cout << 0 << endl;
}

#pragma region main
signed main(void){
	std::cin.tie(0);
	std::ios::sync_with_stdio(false);
	std::cout << std::fixed;//小数を10進数表示
	cout << setprecision(16);//小数点以下の桁数を指定//coutとcerrで別	

	solve();
}
#pragma endregion //main()

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
#define REP(i, n) for (ll i = 0, max_i = (n); i < max_i; i++)
#define REPI(i, a, b) for (ll i = (a), max_i = (b); i < max_i; i++)
#define ALL(obj) (obj).begin(), (obj).end()
#define RALL(obj) (obj).rbegin(), (obj).rend()
#define fi first
#define se second
#define pb push_back
#define debug(x) cerr << #x << ": " << (x) << endl
#define debug2(x, y) cerr << #x << ": " << (x) << " " << #y << ": " << y << endl;
#define int long long
using namespace std;
using II = pair<int, int>;
using VII = vector<II>;
using VI = vector<int>;
using VVI = vector<VI>;
using VVVI = vector<VVI>;
template <class T = int> inline T in() { T x; cin >> x; return x; }
template <class T = int> inline bool chmax(T &a, const T &b) { if (a < b) { a = b; return true; } return false; }
template <class T = int> inline bool chmin(T &a, const T &b) { if (a > b) { a = b; return true; } return false; }
template <class T> ostream& operator<<(ostream &s, const vector<T>& d) { int n = d.size(); REP (i, n) s << d[i] << " "; return s; }
template <class T> ostream& operator<<(ostream &s, const vector<vector<T>>& dd) { for (vector<T> d: dd) s << d << endl; return s; }
struct Fast { Fast() { cin.tie(0); ios::sync_with_stdio(false); } } fast;
const int MOD = 1e9 + 7;

// Dinic法 O(E * V^2)
class Graph {
  int t; // ゴール
  VI level, iter;
  void bfs(int s) {
    for (int i = 0; i < level.size(); i++) level[i] = -1;
    queue<int> que;
    level[s] = 0;
    que.push(s);
    while (!que.empty()) {
      int v = que.front(); que.pop();
      for (int i = 0; i < G[v].size(); i++) {
        edge &e = G[v][i];
        if (e.cap > 0 && level[e.to] < 0) {
          level[e.to] = level[v] + 1;
          que.push(e.to);
        }
      }
    }
  }
  int dfs(int v, int f) {
    if (v == t) return f;
    for (int &i = iter[v]; i < G[v].size(); i++) {
      edge &e = G[v][i];
      if (e.cap > 0 && level[v] < level[e.to]) {
        int d = dfs(e.to, min(f, e.cap));
        if (d > 0) {
          e.cap -= d;
          G[e.to][e.rev].cap += d;
          return d;
        }
      }
    }
    return 0;
  }
public:
  int V;
  struct edge {int to, cap, rev; };
  vector<vector<edge>> G;
  Graph(int V) : V(V), G(V), level(V), iter(V) {}

  void add_edge(int from, int to, int cap) {
    G[from].push_back(edge{ to, cap, (int)G[to].size() });
    G[to].push_back(edge{ from, 0, (int)G[from].size() - 1 });
  }

  int max_flow(int s, int t) {
    int flow = 0;
    this->t = t;
    while (1) {
      bfs(s);
      if (level[t] < 0) return flow;
      for (int i = 0; i < iter.size(); i++) iter[i] = 0;
      int f;
      while ((f = dfs(s, (1LL << 60))) > 0) {
        flow += f;
      }
    }
  }
};

signed main() {
  int N = in();
  Graph g(2 * N + 2);
  int s = 2 * N;
  int t = 2 * N + 1;
  VI a(N), b(N), c(N), d(N);
  REP (i, N) {
    cin >> a[i] >> b[i];
  }
  REP (i, N) {
    cin >> c[i] >> d[i];
  }
  REP (i, N) {
    REP (j, N) {
      if (a[i] < c[j] && b[i] < d[j]) {
        g.add_edge(i, N + j, 1);
      }
    }
  }
  REP (i, N) {
    g.add_edge(s, i, 1);
    g.add_edge(N + i, t, 1);
  }
  cout << g.max_flow(s, t) << endl;
}

Measured memory_bytes: 512
#include<bits/stdc++.h>
#include<vector>
#include<string>
#include<algorithm>
#include<cmath>

#define fast ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define int long long int
#define mod 1000000007
#define inf 1e18+42
#define endl "\n"
#define pi 3.1415926535897932384626433832795028841971693993751058
#define maxn 100005

#define out1(a) cout<<#a<<" "<<a<<endl
#define out2(a,b) cout<<#a<<" "<<a<<" "<<#b<<" "<<b<<endl
#define out3(a,b,c) cout<<#a<<" "<<a<<" "<<#b<<" "<<b<<" "<<#c<<" "<<c<<endl

#define rep(i,a,b) for(int i=a;i<b;i++)
#define repr(i,a,b) for(int i=a;i>=b;i--)
#define fori(it,A) for(auto it=A.begin();it!=A.end();it++)

#define ft first
#define sd second
#define pb push_back
#define mp make_pair
#define pq priority_queue
#define all(x) (x).begin(),(x).end()
#define zero(x) memset(x,0,sizeof(x));
#define ceil(a,b) (a+b-1)/b
 
using namespace std;

int binpow(int a, int b) {
    int res = 1;
    while (b > 0) {
        if (b & 1)
            res = res * a;
        a = a * a;
        b >>= 1;
    }
    return res;
}

//START OF CODE ->->->->->->->

void solve()
{
    int n,x,t;
    cin>>n>>x>>t;

    cout<<ceil(n,x)*t<<endl;
}

//END OF CODE ->->->->->->->->

signed main()
{
    fast;
    int t = 1;
    // cin>>t;

    while(t--)
    {
        solve();
    }
    return 0;
}



Measured memory_bytes: 3636
//#define _GLIBCXX_DEBUG

#include<bits/stdc++.h>
using namespace std;

#define endl '\n'
#define lfs cout<<fixed<<setprecision(10)
#define ALL(a)  (a).begin(),(a).end()
#define ALLR(a)  (a).rbegin(),(a).rend()
#define spa << " " <<
#define fi first
#define se second
#define MP make_pair
#define MT make_tuple
#define PB push_back
#define EB emplace_back
#define rep(i,n,m) for(ll i = (n); i < (ll)(m); i++)
#define rrep(i,n,m) for(ll i = (ll)(m) - 1; i >= (ll)(n); i--)
using ll = long long;
using ld = long double;
const ll MOD1 = 1e9+7;
const ll MOD9 = 998244353;
const ll INF = 1e18;
using P = pair<ll, ll>;
template<typename T>
bool chmin(T &a,T b){if(a>b){a=b;return true;}else return false;}
template<typename T>
bool chmax(T &a,T b){if(a<b){a=b;return true;}else return false;}
ll median(ll a,ll b, ll c){return a+b+c-max({a,b,c})-min({a,b,c});}
void ans1(bool x){if(x) cout<<"Yes"<<endl;else cout<<"No"<<endl;}
void ans2(bool x){if(x) cout<<"YES"<<endl;else cout<<"NO"<<endl;}
void ans3(bool x){if(x) cout<<"Yay!"<<endl;else cout<<":("<<endl;}
template<typename T1,typename T2>
void ans(bool x,T1 y,T2 z){if(x)cout<<y<<endl;else cout<<z<<endl;}  
template<typename T>
void debug(vector<vector<T>>&v,ll h,ll w){for(ll i=0;i<h;i++)
{cout<<v[i][0];for(ll j=1;j<w;j++)cout spa v[i][j];cout<<endl;}};
void debug(vector<string>&v,ll h,ll w){for(ll i=0;i<h;i++)
{for(ll j=0;j<w;j++)cout<<v[i][j];cout<<endl;}};
template<typename T>
void debug(vector<T>&v,ll n){if(n!=0)cout<<v[0];
for(ll i=1;i<n;i++)cout spa v[i];cout<<endl;};
template<typename T>
vector<vector<T>>vec(ll x, ll y, T w){
  vector<vector<T>>v(x,vector<T>(y,w));return v;}
ll gcd(ll x,ll y){ll r;while(y!=0&&(r=x%y)!=0){x=y;y=r;}return y==0?x:y;}
vector<ll>dx={1,0,-1,0,1,1,-1,-1};
vector<ll>dy={0,1,0,-1,1,-1,1,-1};
template<typename T>
vector<T> make_v(size_t a,T b){return vector<T>(a,b);}
template<typename... Ts>
auto make_v(size_t a,Ts... ts){
  return vector<decltype(make_v(ts...))>(a,make_v(ts...));
}
template<typename T1, typename T2>
ostream &operator<<(ostream &os, const pair<T1, T2>&p){
  return os << p.first << " " << p.second;
}  
int main(){
  cin.tie(nullptr);
  ios_base::sync_with_stdio(false);
  ll res=0,buf=0;
  bool judge = true;
  ll n;cin>>n;
  vector<ll>a(n);
  rep(i,0,n)cin>>a[i];
  ll rem=0;
  if(n%2==0)rem=1;
  else rem=2;
  auto dp=vec(n+1,rem+1,-INF);
  dp[0][0]=0;
  rep(i,0,n){
    rep(j,0,rem+1){
      ll idx=i+2-(i==0);
      rep(o,0,rem+1){
        if(j+o>rem||idx-1+o>=n)continue;
        chmax(dp[idx+o][j+o],dp[i][j]+a[idx-1+o]);
      }
    }
  }
  //debug(dp,n+1,rem+1);
  ll ret=-INF;
  if(n&1){
    chmax(ret,dp[n][1]);
    chmax(ret,dp[n][2]);
    rep(i,0,rem+1)chmax(ret,dp[n-1][i]);
    chmax(ret,dp[n-2][0]);
  }
  else{
    rep(i,n-1,n+1)rep(j,0,rem+1)chmax(ret,dp[i][j]);
  }
  cout<<ret<<endl;
  return 0;
}

Measured memory_bytes: 15872
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>

#define REP(i, a, b) for (int i = int(a); i < int(b); i++)
#define dump(val) cerr << __LINE__ << ":\t" << #val << " = " << (val) << endl

using namespace std;

typedef long long int lli;

template<typename T>
vector<T> make_v(size_t a, T b) {
    return vector<T>(a, b);
}

template<typename... Ts>
auto make_v(size_t a, Ts... ts) {
    return vector<decltype(make_v(ts...))>(a, make_v(ts...));
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N;
    cin >> N;
    vector<lli> a(N);
    REP(i, 0, N) {
        cin >> a[i];
    }

    int ans = 0;
    REP(i, 0, N) {
        ans |= (a[i] % 2);
    }

    cout << (ans == 0 ? "second" : "first") << endl;

    return 0;
}


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

#define rep(i,n) for(int i = 0;i < n;++i)
#define rep2(i,n,m) for(int i = n;i < m;++i)
#define all(v) v.begin(),v.end()
using namespace std;
using ll = long long;

const int INF = 1001001001;

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    
    int n;
    cin >> n;
    vector<int> dp(n,INF);
    vector<int> a(n);
    rep(i,n){
        cin >> a.at(i);
    }
    dp.at(0) = 0;
    dp.at(1) = abs(a.at(0)-a.at(1));
    rep(i,n){
        if(i > 1)
        dp.at(i) = min(dp.at(i-2)+abs(a.at(i)-a.at(i-2)),dp.at(i-1)+abs(a.at(i)-a.at(i-1)));
    }
    cout << dp.at(n-1) << endl;

    cout << endl;
    return 0;
}

Measured memory_bytes: 1024
#include <iostream>
#include <list>
#include <cmath>

int main(void){
	using namespace std;
	string s;
	cin >> s;
	int n = s.size();
	int z = 0, o = 0;
	for(auto&& c : s){
		if (c == '0')
			z++;
		else
			o++;
	}
	cout << s.size() - abs(z - o) << endl;;
	

}


Measured memory_bytes: 512
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define all(x) (x).begin(),(x).end()
#define fi first
#define se second
#define pb push_back
#define pii pair<long long,long long>
#define endl '\n'
#define N 300001
vector<vector<int>>dp;
vector<int> pref;
void func(vector<int> &v)
{
    pref.assign(v.size(),0);
    pref[0]=v[0];
    for(int i=1;i<v.size();i++)
    pref[i]=pref[i-1]+v[i];
}
int calc(int i , int j)
{
    if(i==0)
    return pref[j];
    return pref[j]-pref[i-1];
}
void solve()
{
    int n; cin>>n;
    vector<int> v(n);
    for(int i=0;i<n;i++)
    cin>>v[i];
    int ans=0;
    func(v);
    dp.assign(n+1,vector<int>(n+1,0));
    for(int l=n-1;l>=0;l--)
    {
        for(int r=l;r<n;r++)
        {
            dp[l][r]=LLONG_MAX;
            if(l==r)
            dp[l][r]=0;
            for(int k=l;k<r;k++)
            dp[l][r]=min(dp[l][r],dp[l][k]+dp[k+1][r]+calc(l,k)+calc(k+1,r));
        }
    }
    cout<<dp[0][n-1]<<endl;
}
int32_t main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    int test; test=1;
    while(test--)
    {
        solve();
    }
    return 0;
}

Measured memory_bytes: 1536
fun main(args: Array<String>) = abc156b()

fun abc156b() {
    val (n, k) = readLine()!!.split(' ').map { it.toInt() }

    for (i in 1..10000) {
        val pow = Math.pow(k.toDouble(), i.toDouble()).toLong()
        if (pow > n) return println(i)
    }
}


Measured memory_bytes: 36312
#include <bits/stdc++.h>
#include <boost/range/irange.hpp>
#include <boost/range/adaptors.hpp>

using namespace std;
using namespace boost;
using namespace boost::adaptors;
using uint = unsigned int;
using ll = long long int;
using ull = unsigned long long int;

int main() {
    ll minimum{numeric_limits<ll>::max()};
    ll W, a, b;
    cin >> W >> a >> b;
    if (b > a + W) cout << b - a - W;
    else if (a > b + W) cout << a - b - W;
    else cout << 0;

    return 0;
}

Measured memory_bytes: 256
using System;
using System.Linq;
class A{
    static void Main(){
        while(true){string s=Console.ReadLine();if(s==null){break;}
string[] n=s.Split();
int a=int.Parse(n[1]);
int b=int.Parse(n[2]);
Console.WriteLine(n[0]+" "+(a+b).ToString()+" "+(a*200+b*300).ToString());
  }
    }
}

Measured memory_bytes: 9036
#include <stdio.h>

void sort(int a[]);
void swap(int *a, int *b);

int main(void)
{
	int n;
	int i, j;
	int a[3];

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

		sort(a);

		if (a[0] * a[0] == (a[1] * a[1] + a[2] * a[2])){
			printf("YES\n");
		}
		else {
			printf("NO\n");
		}
	}

	return (0);
}

void sort(int a[])
{
	int i, j;

	for (i = 0; i < 2; i++){
		for (j = i + 1; j < 3; j++){
			if (a[i] < a[j]){
				swap(a + i, a + j);
			}
		}
	}
}

void swap(int *a, int *b)
{
	*a ^= *b;
	*b ^= *a;
	*a ^= *b;
}

Measured memory_bytes: 580
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
using namespace std;

int main(void){
  string s;
  cin >> s;
  int ans = 0;
  int c = 0;
  for(int i = 0; i < s.length(); i++){
    if(s[i] == 'A' || s[i] == 'C' || s[i] == 'G' || s[i] == 'T') c++;
    else {
      ans = max(ans, c);
      c = 0;
    }
    ans = max(ans, c);
  }
  cout << ans << endl;
  return 0;
}


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


int main(){
  int d;
  cin >> d;
  if (d == 25)
    cout << "Christmas" <<endl;
  else if (d == 24)
    cout << "Christmas Eve" << endl;
  else if ( d == 23)
    cout << "Christmas Eve Eve" <<  endl;
  else
    cout << "Christmas Eve Eve Eve" << endl;
}
    
      
    


Measured memory_bytes: 256
import std.stdio, std.string, std.conv, std.range;
import std.algorithm, std.array, std.typecons, std.container;
import std.math, std.numeric, std.random, core.bitop;

enum inf = 1_001_001_001;
enum infl = 1_001_001_001_001_001_001L;


void main() {
    int N;
    scan(N);
    auto L = new int[](N);
    auto R = new int[](N);
    foreach (i ; 0 .. N) {
        scan(L[i], R[i]);
        R[i]++;
    }

    int Lmax = 0, Rmin = inf;
    foreach (i ; 0 .. N) {
        chmax(Lmax, L[i]);
        chmin(Rmin, R[i]);
    }

    long ans;
    foreach (i ; 0 .. N) {
        chmax(ans, max(Rmin - Lmax, 0) + R[i] - L[i]);
    }

    auto a = new int[](N);
    auto b = new int[](N);
    foreach (i ; 0 .. N) {
        a[i] = max(R[i] - Lmax, 0);
        b[i] = max(Rmin - L[i], 0);
    }

    zip(a, b).sort!"a[1] > b[1]"();
    zip(a, b).sort!"a[0] < b[0]"();

    int bm = b[0];
    foreach (i ; 1 .. N) {
        chmax(ans, a[i] + bm);
        chmin(bm, b[i]);
    }

    writeln(ans);
}



void scan(T...)(ref T args) {
    auto line = readln.split;
    foreach (ref arg; args) {
        arg = line.front.to!(typeof(arg));
        line.popFront;
    }
    assert(line.empty);
}

void fillAll(R, T)(ref R arr, T value) {
    static if (is(typeof(arr[] = value))) {
        arr[] = value;
    }
    else {
        foreach (ref e; arr) {
            fillAll(e, value);
        }
    }
}

bool chmin(T, U...)(ref T x, U args) {
    bool isChanged;
    foreach (arg; args) if (x > arg) {
        x = arg;
        isChanged = true;
    }
    return isChanged;
}

bool chmax(T, U...)(ref T x, U args) {
    bool isChanged;
    foreach (arg; args) if (x < arg) {
        x = arg;
        isChanged = true;
    }
    return isChanged;
}

void yes(bool ok, string y = "Yes", string n = "No") {
    return writeln(ok ? y : n);
}


Measured memory_bytes: 4860
#include<iostream>
// 填上你觉得需要的其他头文件
using namespace std;
int main() {
    int n, m;
    cin>>n>>m;
    int sum = 0;
    int val;
    for (int i=0; i<m; i++) {
        cin >> val;
        sum += val;
    }

    int ans = n - sum;
    if (ans<0) {
        ans = -1;
    }
    cout << ans << endl;
    
    return 0;
}

Measured memory_bytes: 3196
#include <bits/stdc++.h>
#define fast ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
using namespace std;
int main(){
  fast;
  int n;
  double ans=0.0;
  cin>>n;
  vector<double> prob(n);
  for(int i=0;i<n;i++) cin>>prob[i];
  vector<vector<double>> dp(n+1,vector<double>(n+1));
  for(int i=n-1;i>=0;i--){
    for(int j=0;j<=n-i;j++){
      if(i<n-1) dp[i][j]=((j>0)?(prob[i]*dp[i+1][j-1]+(1-prob[i])*dp[i+1][j]):((1-prob[i])*dp[i+1][j]));
      else dp[i][j]=((j>0)?prob[i]:(1-prob[i]));
    }
  }
  
  for(int i=n;i>(n-i);i--)
      ans+=dp[0][i];
  cout<<setprecision(9)<<fixed<<ans<<"\n";
  return 0;
}

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

int main(){
    int K;
    cin >> K;
    int remainder = 0;
    int digit = 0;
    while(digit < 1000000){
      digit++;
      int i = (10 * remainder + 7) % K;
      if (i == remainder) break;
      remainder = i;
      if (remainder == 0) break;
    }
    if (remainder == 0) cout << digit << endl;
    else cout << -1 << endl;
}


Measured memory_bytes: 3632
#include<iostream>
#include<string>
using namespace std;
main(){
  string a,b;
  cin >> a >> b;
  a += b;
  int x = stoi(a);
  for(int i = 2;i * i <= x;i++){
    if(i * i == x){
      cout << "Yes" << endl;
      return 0;
    }
  }
  cout << "No" << endl;
}


Measured memory_bytes: 256