akhauriyash/Code-Regression huggingface dataset:
s = input()
a = []
for i in range(4):
    a.append(int(s[i]))
ans= 7- a[0]
for op in range(1<<3):
    sans = [str(a[0])]
    tmp = ans
    for i in range(3):
        if (op//2**i)%2 == 0:
            tmp -= a[i+1]
            sans.append('+')
            sans.append(str(a[i+1]))
        else:
            tmp += a[i+1]
            sans.append('-')
            sans.append(str(a[i+1]))
    if tmp == 0:
        break
for i in range(len(sans)):
    print(sans[i],end="")
print('=7')

Measured memory_bytes: 3064
n,a = map(int,input().split())
m = [tuple(map(int,input().split())) for _ in range(a)]

l,r=m[0][0],m[0][1]

for i in range(1,a):
    l = max(m[i][0],l)
    r = min(m[i][1],r)

print(max(r-l+1,0))


Measured memory_bytes: 16628
#include <iostream>
using namespace std;
struct node{
	int key;
	node *left = NULL;
	node *right = NULL;
	node *parent = NULL;
	node(int k, node*l = NULL, node*r = NULL, node*p = NULL) : key(k), left(l), right(r), parent(p) {}
};
node *Tree;

void insert(int z)
{
	node *y = NULL;
	node *x = Tree;
	while(x != NULL){
		y = x;
		if(z < x->key)
			x = x->left;
		else
			x = x->right;
	}
	if(y == NULL)
		Tree = new node(z);
	else if(z < y->key)
		y->left = new node(z, NULL, NULL, y);
	else
		y->right = new node(z, NULL, NULL, y);
}

void midprint(node *root)
{
	if(root == NULL) return;
	midprint(root->left);
	cout << " " << root->key;
	midprint(root->right);
}

void preprint(node *root)
{
	if(root == NULL) return;
	cout << " " << root->key ;
	preprint(root->left);
	preprint(root->right);
}

node* find(int k)
{
	node *x = Tree;
	while(x != NULL && x->key != k){
		if(k < x->key)
			x = x->left;
		else
			x = x->right;
	}
	return x;
}

node* TreeSuccessor(node* x)
{
	
	x = x->right;
	while(x != NULL && x->left != NULL)
		x = x->left; 
	return x;
}

void del(int k)
{
	node *z = find(k);
	if(z == NULL) return;
	
	node *y = NULL;
	if(z->left == NULL || z->right == NULL) y = z;
	else y = TreeSuccessor(z);
	
	node* x;
	if(y->left != NULL)
		x = y->left;
	else
		x = y->right;
	
	if(x != NULL)
		x->parent = y->parent;
	
	if(y->parent == NULL)
		Tree = x;
	else{
		if(y == y->parent->left)
			y->parent->left = x;
		else
			y->parent->right = x;
	}
	if( y != z)
		z->key = y->key;
	delete y;
}


void print(node *root)
{
	midprint(root);
	cout << endl;
	preprint(root);
	cout << endl;
}

int main()
{
	int n;
	cin >> n;
	while(n--){
		string s;
		cin >> s;
		if(s[0] == 'i'){
			int k;
			cin >> k;
			insert(k);
		}
		else if(s[0] == 'p')
			print(Tree);
		else if(s[0] == 'f'){
			int k;
			cin >> k;
			node *ans = find(k);
			if(ans == NULL ) cout << "no" << endl;
			else 		cout << "yes" <<endl; 
		}
		else if(s[0] == 'd'){
			int k;
			cin >> k;
			del(k);
		}
	}
	return 0;
}

Measured memory_bytes: 21924
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
using P = pair<int,int>;
using pll = pair<ll,ll>;
using Graph = vector<vector<ll>>;
#define all(v) v.begin(), v.end()
#define rep(i, n) for(ll i = 0; i < (ll)(n); i++)
#define rep2(i,l,r) for(ll i = (l); i <= (ll)(r); i++)
#define rep3(i,l,r) for(ll i = (l); i >= (ll)(r); i--)
#define dup(x,y) (((x)+(y)-1)/(y)) // x/yの除算の切り上げ
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
const int inf = 1e8;
const ll INF = 1LL << 60;
const ll mod = 1000000007; //1000000007;
const ld pi = acos(-1);

int g(vector<P> a) {
  sort(a.begin(), a.end());
  int res = inf;
  for (int i = 1; i < a.size(); ++i) {
    if (a[i-1].second == 0 && a[i].second != 0) {
      res = min(res, a[i].first-a[i-1].first);
    }
  }
  return res;
}
int f(map<int,vector<P>> mp) {
  int res = inf;
  for (auto p : mp) {
    res = min(res, g(p.second));
  }
  return res;
}

int main() {
  
  ios::sync_with_stdio(false);
  cin.tie(0);
  
  int n;
  cin >> n;
  vector<int> x(n), y(n), dir(n);
  rep(i,n) {
    char c;
    cin >> x[i] >> y[i] >> c;
    if (c == 'U') dir[i] = 0;
    if (c == 'R') dir[i] = 1;
    if (c == 'D') dir[i] = 2;
    if (c == 'L') dir[i] = 3;
  }

  int ans = inf;
  rep(ri,4){
    { 
      map<int,vector<P>> mp;
      rep(i,n) {
        if (dir[i] != 0 && dir[i] != 2) continue;
        mp[x[i]].emplace_back(y[i],dir[i]);
      }
      ans = min(ans, f(mp)*5);
    }
    { 
      map<int,vector<P>> mp;
      rep(i,n){
        if (dir[i] != 0 && dir[i] != 1) continue;
        mp[x[i]+y[i]].emplace_back(y[i],dir[i]);
      }
      ans = min(ans, f(mp)*10);
    }
    rep(i,n){
      int px = x[i], py = y[i];
      x[i] = py;
      y[i] = -px;
      dir[i] = (dir[i]+1)%4;
    }
  }
  if (ans == inf) cout << "SAFE" << endl;
  else cout << ans << endl;

}

Measured memory_bytes: 48828
s=input()
m=[s[i]=="B" for i in range(len(s))]
m1=[None for i in range(len(s))]
m1[0]=m[0]
for i in range(1,len(s)):
  m1[i]=m1[i-1]+m[i]
m2=[None for i in range(len(s))]
m2[len(s)-1]=m[len(s)-1]
for i in range(len(s)-1,0,-1):
  m2[i-1]=m2[i]+m[i]
  
ans1=0
ans2=0
for i in range(1,len(s)):
  if s[i]=="W":
    ans1+=m1[i]
    ans2+=m2[i]
    
print(ans1)



Measured memory_bytes: 61692
/* Dsingh_24 */

#include<bits/stdc++.h>
#define ll          long long
#define pb          push_back
#define	endl		'\n'
#define pii         pair<ll int,ll int>
#define vi          vector<ll int>
#define all(a)      (a).begin(),(a).end()
#define F           first
#define S           second
#define sz(x)       (ll int)x.size()
#define hell        1000000007
#define rep(i,a,b)	for(ll int i=a;i<b;i++)
#define lbnd        lower_bound
#define ubnd        upper_bound
#define bs          binary_search
#define mp          make_pair
#define ios	    ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
using namespace std;

#define N  100005
ll cnt[3][N];
int main()
{
	ios
	ll n,i,j,ans=0;
	cin>>n;
	string s;
	cin>>s;
	for(i=n-1;i>=0;i--){
		for(j=0;j<3;j++)
			cnt[j][i]=cnt[j][i+1];
		if(s[i]=='R'){
			cnt[0][i]+=1;
		}else
		if(s[i]=='G'){
			cnt[1][i]+=1;
		}else{
			cnt[2][i]+=1;
		}
	}
	// cout<<cnt[1][0]<<"\n";
	for(i=0;i<n;i++){
		for(j=i+1;j<n;j++){
			if(s[i]!=s[j]){
				ll dis=j-i;
				if(s[i]!='R'&&s[j]!='R'){
					ans+=cnt[0][j+1];
					if(j+dis<n&&s[j+dis]=='R')ans--;
					// cout<<ans<<"\n";
				}else
				if(s[i]!='G'&&s[j]!='G'){
					ans+=cnt[1][j+1];
					if(j+dis<n&&s[j+dis]=='G')ans--;
					// cout<<ans<<"\n";
				}else{
					ans+=cnt[2][j+1];
					if(j+dis<n&&s[j+dis]=='B')ans--;
					// cout<<ans<<"\n";
				}
			}
		}
	}
	cout<<ans;
	return 0;
}

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

int main(){
    string a, b;
    cin >> a >> b;
    int n = a.size();
    int res = 0;
    for(int i=0;i<n;i++)
        if(a[i] != b[i]) res++;
    cout << res << endl;
}


Measured memory_bytes: 3916
import bisect
N = int(input())
A_arr = list(map(int,input().split()))
A_arr.sort()
B_arr = list(map(int,input().split()))
B_arr.sort()
C_arr = list(map(int,input().split()))
ans = 0
check_array = [0] * N
for i in range(N):
    check_array[i] = check_array[i-1]+bisect.bisect_left(A_arr,B_arr[i])
for i in C_arr:
    B_index = bisect.bisect_left(B_arr,i)
    if B_index == 0:
        continue
    ans += check_array[B_index-1]
print(ans)

Measured memory_bytes: 23360
#include <iostream>
#include <string>
#include <vector>
using namespace std;
typedef long long int ll;
int main(){
int n;
cin >> n;
int t[n];
ll sum=0;
for(int i=0;i<n;i++) {
  cin >>t[i];
  sum+=t[i];
}
int m;
cin >>m;
vector <pair<ll,ll>> v;
ll p,x;
for(int i=0;i<m;i++){
  cin >> p>>x;
  v.push_back(make_pair(p,x));
}
for(int i=0;i<m;i++){
      cout << sum+v[i].second-t[v[i].first-1]<<endl;
  }
}


Measured memory_bytes: 256
n = gets.to_i
numbers = gets.chomp.split(" ").map(&:to_i)
deducted_numbers = numbers.map.with_index { |item, index| item - (index + 1) }
deducted_numbers.sort!
median = deducted_numbers[deducted_numbers.size / 2]
answer_numbers = deducted_numbers.map { |item| (item - median).abs }
puts answer_numbers.inject(:+)

Measured memory_bytes: 21092
#include<iostream>
#include<vector>
#include<string>
#define rep(i, start, end) for (int i = (int)start; i < (int)end; ++i)
#define rrep(i, start, end) for (int i = (int)start - 1; i >= (int)end; --i)
#define all(x) (x).begin(), (x).end()
using namespace std;
using ll = long long;
template<typename T> inline bool chmax(T& a, T b) {if (a < b) {a = b; return true;} return 0;}
template<typename T> inline bool chmin(T& a, T b) {if (a > b) {a = b; return true;} return 0;}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int A;
    cin >> A;
    int B = 1;
    int ans = 0;
    rep(i, 0, 3) {
        B *= A;
        ans += B;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3612
#include "bits/stdc++.h"

using namespace std;

typedef long long ll;
const int MOD = 1e9 + 7;

// a^b
ll mypow(ll a, ll b) {
    if (b == 0) return 1;
    ll tmp = mypow(a, b / 2);
    if (b % 2) return (((tmp*tmp) % MOD)*a) % MOD;
    else return (tmp*tmp) % MOD;
}

vector<ll> fact(111111,1),inv(111111,1);
// nCk
ll comb(ll n, ll k) {
	if(n<k) return 0;
    ll res = fact[n];
	res *= inv[k]; res %= MOD;
	res *= inv[n-k]; res %= MOD;
    return res;
}

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

	int n;cin>>n;
	fact[1]=1; inv[1]=1;
	for(ll i=2;i<=100010;i++){
		fact[i] = fact[i-1]*i;
		fact[i] %= MOD;
		inv[i] = mypow(fact[i],MOD-2);
	}
	vector<int> a(n+2);
	int st,gt;
	map<int,int> mp;
	for(int i=1;i<=n+1;i++){
		cin>>a[i];
		if(mp[a[i]]){
			st=mp[a[i]];
			gt=i;
		}
		else{
			mp[a[i]]=i;
		}
	}
	ll cand=(st-1)+(n+1-gt);
	for(ll k=1;k<=n+1;k++){
		ll res=comb(n+1,k);
		res -= comb(cand,k-1);
		res += MOD; res %= MOD;
		cout<<res<<endl;
	}
	return 0;
}


Measured memory_bytes: 8064
#include<iostream>

int main() {
	double x1, y1, x2, y2, x3, y3, xp, yp;
	while (std::cin >> x1 >> y1 >> x2 >> y2 >> x3 >> y3 >> xp >> yp) {
		double abx, aby, bpx, bpy, bcx, bcy, cpx, cpy, cax, cay, apx, apy, z1, z2, z3;
		abx = x2 - x1; aby = y2 - y1;
		bpx = xp - x2; bpy = yp - y2;
		bcx = x3 - x2; bcy = y3 - y2;
		cpx = xp - x3; cpy = yp - y3;
		cax = x1 - x3; cay = y1 - y3;
		apx = xp - x1; apy = yp - y1;
		z1 = abx*bpy - aby*bpx;
		z2 = bcx*cpy - bcy*cpx;
		z3 = cax*apy - cay*apx;
		if ((z1 > 0 && z2 > 0 && z3 > 0) || (z1 < 0 && z2 < 0 && z3 < 0)) {
			std::cout << "YES" << std::endl;
		}
		else {
			std::cout << "NO" << std::endl;
		}
	}
	return 0;
}

Measured memory_bytes: 3216
#include <iostream>
using namespace std;
int main(void){
    int n,x;
    
    while(true){
        cin>>n>>x;
        if(n==0&&x==0)  break;
        else{
            int sum=0;
            int i,j,k,A;
            for(i=1;i<=n-2;i++){
                for(j=i+1;j<=n-1;j++){
                    for(k=j+1;k<=n;k++){
                      A=i+k+j;
                      if(A==x)   sum=sum+1;
                      
                    }
                }
            }
            cout<<sum;
            cout<<endl;
        }
    }
}
                    


Measured memory_bytes: 3084
#include <cstdio>
#include <cstdlib>
#include <stack> 
using namespace std;
stack<int> s;
char a[10];
int main () {
	while (~scanf ("%s",a)) {
		if (a[0]=='+') {
			int tmp1,tmp2;
			tmp1=s.top();
			s.pop();
			tmp2=s.top();
			s.pop();
			s.push(tmp1+tmp2);
		} else if (a[0]=='-') {
			int tmp1,tmp2;
			tmp1=s.top();
			s.pop();
			tmp2=s.top();
			s.pop();
			s.push(tmp2-tmp1);
		} else if (a[0]=='*') {
			int tmp1,tmp2;
			tmp1=s.top();
			s.pop();
			tmp2=s.top();
			s.pop();
			s.push(tmp1*tmp2);
		} else s.push(atoi(a));
	}
	printf ("%d\n",s.top());
    return 0;
}


Measured memory_bytes: 2744
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
#define rep(i,n) for(int i=0;i<n;i++)
int main() {
  ll n;
  cin>>n;
  for(int i=1;i<=n;i++){
    ll ans=0;
    for(ll x=1;x*x<=i;x++){
      for(ll y=1;x*x+y*y+x*y<=i;y++){
        for(ll z=1;x*x+y*y+z*z+x*y+y*z+z*x<=i;z++){
          if(x*x+y*y+z*z+x*y+y*z+z*x==i) ans++;
        }
      }
    }
    cout<<ans<<endl;
  }
}

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

#define REP(i, n) for (int i = 0; i < n; ++i)
#define FOR(i, a, b) for (int i = a; i <= b; ++i)
#define FORR(i, a, b) for (int i = a; i >= b; --i)
#define ALL(c) (c).begin(), (c).end()

typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n, a;
    cin >> n >> a;
    cout << ((n % 500) <= a ? "Yes" : "No") << endl;

    return 0;
}


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

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

struct fastio {
    fastio() {
        ios::sync_with_stdio(false);
        cout << setprecision(10) << fixed;
        cin.tie(0);
    }
};

fastio _fast_io;

int a, b;
int main() {
    cin >> a >> b;
    if (a <= 5)
        cout << 0 << endl;
    else if (a <= 12)
        cout << b / 2 << endl;
    else
        cout << b << endl;

    return 0;
}


Measured memory_bytes: 3648
#include <string>
#include <vector>
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<stack>
#include<queue>
#include<cmath>
#include<algorithm>
#include<functional>
#include<list>
#include<deque>
#include<bitset>
#include<set>
#include<map>
#include<unordered_map>
#include<unordered_set>
#include<cstring>
#include<sstream>
#include<complex>
#include<iomanip>
#include<numeric>
#include<cassert>
#define X first
#define Y second
#define pb push_back
#define rep(X,Y) for (int (X) = 0;(X) < (Y);++(X))
#define reps(X,S,Y) for (int (X) = S;(X) < (Y);++(X))
#define rrep(X,Y) for (int (X) = (Y)-1;(X) >=0;--(X))
#define rreps(X,S,Y) for (int (X) = (Y)-1;(X) >= (S);--(X))
#define repe(X,Y) for ((X) = 0;(X) < (Y);++(X))
#define peat(X,Y) for (;(X) < (Y);++(X))
#define all(X) (X).begin(),(X).end()
#define rall(X) (X).rbegin(),(X).rend()
#define eb emplace_back
#define UNIQUE(X) (X).erase(unique(all(X)),(X).end())
#define Endl endl
#define NL <<"\n"

using namespace std;
using ll=long long;
using pii=pair<int,int>;
using pll=pair<ll,ll>;
template<class T> using vv=vector<vector<T>>;
template<class T> inline bool MX(T &l,const T &r){return l<r?l=r,1:0;}
template<class T> inline bool MN(T &l,const T &r){return l>r?l=r,1:0;}
//#undef NUIP
#ifdef NUIP
#include "benri.h"
#else
#define out(args...)
#endif
#ifdef __cpp_init_captures
template<typename T>vector<T> table(int n, T v){ return vector<T>(n, v);}
template <class... Args> auto table(int n, Args... args){auto val = table(args...); return vector<decltype(val)>(n, move(val));}
#endif
const ll MOD=1e9+7; //998244353
const ll INF=1e16;
template<class T,class G>
void dij(vv<pair<G,T>> &g,int s,vector<T> &d){
  typedef pair<T,G> Que;
  priority_queue<Que,vector<Que>,greater<Que> > que;
  int n=g.size();
  d.resize(n);
  fill(all(d),INF);
  d[s]=0;
  que.emplace(0,s);
  while(que.size()){
    Que p=que.top();que.pop();
    if(d[p.Y]<p.X)continue;
    for(auto e:g[p.Y]) if(MN(d[e.X],d[p.Y]+e.Y)) que.emplace(d[e.X],e.X);
  }
}

int main(){
  ios_base::sync_with_stdio(false); cin.tie(0);
  cout<<fixed<<setprecision(0);
	ll N;
  cin>>N; N;
  ll M;
  cin>>M; M;
  vector<ll> L(M);
  vector<ll> R(M);
  vector<ll> C(M);
	vv<pll> g(N);
  rep(i,M){
    cin>>L[i]; --L[i];
    cin>>R[i]; --R[i];
    cin>>C[i]; C[i];
		g[L[i]].eb(R[i],C[i]);
  }
	reps(i,1,N) g[i].eb(i-1,0);
	vector<ll> dst;
	dij(g,0,dst);
	cout<<(dst[N-1]==INF?-1:dst[N-1]) NL;
	return 0;
}


Measured memory_bytes: 11512
n, m = [int(i) for  i in input().split()]
h = [int(i) for i in input().split()]
edges = [[] for i in range(n)]
for _ in range(m):
  edge = [int(i)-1 for i in input().split()]
  edges[edge[0]].append(edge[1])
  edges[edge[1]].append(edge[0])
cnt = 0

for i in range(n):
  flg = True
  for j in edges[i]:
    if h[i] <= h[j]:
      flg = False
      break
  if flg:
    cnt += 1
print(cnt)

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

#if defined(DEBUG)

#include <unistd.h>
#include <sys/fcntl.h>
#define DLOG(...)        cerr << dbgFormat(__VA_ARGS__) << endl
#define DCALL(func, ...) func(__VA_ARGS__)

template <class... Args>
string dbgFormat(const char* fmt, Args... args) {
  size_t len = snprintf(nullptr, 0, fmt, args...);
  char buf[len + 1];
  snprintf(buf, len + 1, fmt, args...);
  return string(buf);
}

#else  // defined(DEBUG)

#define DLOG(...)
#define DCALL(func, ...)

#endif // defined(DEBUG)
// ----------------------------------------------------------------------

// ----------------------------------------------------------------------
int main(int argc, char *argv[]) {
#if defined(DEBUG)
  // GDB on Cygwin ignores redirection at run command.
  if (argc == 2) dup2(open(argv[1], 0), 0);
#else
  // For performance.  We should not use C-style stdio functions
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);
#endif
  cout << setprecision(20);

  int N; cin >> N;
  vector<int> B(N-1);
  for (int i = 0; i < N-1; i++) cin >> B.at(i);

  int sum = B.at(0) + B.at(N-2);
  for (int i = 0; i < N-2; i++) {
    sum += min(B.at(i), B.at(i+1));
  }
  cout << sum << endl;

  return 0;
}



Measured memory_bytes: 256
fn main() {
    let (r, w) = (std::io::stdin(), std::io::stdout());
    let mut sc = IO::new(r.lock(), w.lock());

    let s = sc.chars();
    let ans = match s.last().unwrap().to_digit(10) {
        Some(3) => "bon",
        Some(0) | Some(1) | Some(6) | Some(8) => "pon",
        _ => "hon",
    };
    println!("{}", ans);
}

pub struct IO<R, W: std::io::Write>(R, std::io::BufWriter<W>);

impl<R: std::io::Read, W: std::io::Write> IO<R, W> {
    pub fn new(r: R, w: W) -> IO<R, W> {
        IO(r, std::io::BufWriter::new(w))
    }
    pub fn write<S: ToString>(&mut self, s: S) {
        use std::io::Write;
        self.1.write(s.to_string().as_bytes()).unwrap();
    }
    pub fn read<T: std::str::FromStr>(&mut self) -> T {
        use std::io::Read;
        let buf = self
            .0
            .by_ref()
            .bytes()
            .map(|b| b.unwrap())
            .skip_while(|&b| b == b' ' || b == b'\n' || b == b'\r' || b == b'\t')
            .take_while(|&b| b != b' ' && b != b'\n' && b != b'\r' && b != b'\t')
            .collect::<Vec<_>>();
        unsafe { std::str::from_utf8_unchecked(&buf) }
            .parse()
            .ok()
            .expect("Parse error.")
    }
    pub fn vec<T: std::str::FromStr>(&mut self, n: usize) -> Vec<T> {
        (0..n).map(|_| self.read()).collect()
    }
    pub fn chars(&mut self) -> Vec<char> {
        self.read::<String>().chars().collect()
    }
}

Measured memory_bytes: 2084
// Malisetti Samrat
// 

#pragma GCC optimize ("O3")
#pragma GCC optimize("Ofast")
#include   <bits/stdc++.h>
#include   <algorithm>
#include   <queue>
#include   <list>
#include   <map>
#include   <math.h>
#include   <numeric>
#include   <iomanip>
using      namespace        std;
#define    endl             '\n'
#define    FAST             ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define    ipfile           ifstream cin ("input.txt");std::cin.rdbuf(std::cin.rdbuf())
#define    pb(x)            push_back(x)
#define    int              long long int
#define    ull              unsigned long long int
#define    db               long double
#define    mod              1000000007
#define    vll              vector<int>
#define    all(v)           v.begin(),v.end()
#define    GCD(m,n)         __gcd(m,n)
#define    LCM(m,n)         m*(n/GCD(m,n))
#define    REVVEC(v)        reverse(v.begin(),v.end())
#define    REVARR(a)        reverse(a,a+n)
#define    maxc(v)          max_element(all(v))
#define    minc(v)          min_element(all(v))
#define    inputarr(a,n)    for(int xxx=0;xxx<n;++xxx) cin>>a[xxx]
#define    outputarr(a,n)   for(int xxx=0;xxx<n;xxx++) cout<<a[xxx]<<" "
#define    rep(i,m, n)      for(int i = m; i < (n); ++i)
#define    sp               setprecison(10)
#define    sz(v)            v.size()
#define    len(s)           s.length()


const double pi=3.14159265358;

const double g=6.67259e-11;

clock_t time_p = clock();
void time()
{
  time_p = clock() - time_p;
  cerr << "Time elapsed : " << (double)(time_p)/CLOCKS_PER_SEC <<endl;
}

const int MA=87000009;

bool prime[MA];

vector<int>v;

void Seive() // finding primes using sieve pre-computation
{
    prime[0]=false;prime[1]=false;
    for (int p=2; p*p<=MA; p++) 
    { 
        if (prime[p] == true) 
        { 
            for (int i=p*p; i<=MA; i += p) 
                prime[i] = false; 
        } 
    }
    
    int s=0;
    for(int i=0;i<=MA;i++){
        if(prime[i])
                s+=1;
            v.pb(s);}
}


void TestCase1()
{
    
    

}


void TestCase()
{
    
    int n;
    cin>>n;
    if(n%2!=0)
    cout<<(n/2)+1<<endl;
    else
    cout<<(n/2)<<endl;
        
}

signed main() {
	    
	ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    
  // int T; cin>>T; while( T -- > 0){

   TestCase();
   
   //TestCase1();
  	
    //}
    
    time();
	return 0;
}





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

int main() {
 
  string s;
  int a = 0;
  int z = 0;
  cin >> s;
  
  for(int i = 0; i < s.size(); i++) {
    if(s[i] == 'A') {
      a = i+1;
      break;
    }
  }
  reverse(s.begin(), s.end());
  for(int i = 0; i < s.size(); i++) {
    if(s[i] == 'Z') {
      z = s.size() - i;
      break;
    }
  }
  
  cout << (z - a) + 1 << endl;
  
  return 0;
}

Measured memory_bytes: 640
n=int(input())
ans=10e5
for a in range(1,n//2+1):
    b=n-a
    ans=min(ans,sum([int(i) for i in str(a)])+sum([int(i) for i in str(b)]))
    ans=min(ans,sum([int(i) for i in str(a)])+sum([int(i) for i in str(b)]))
print(int(ans))

Measured memory_bytes: 9160
#include<iostream>
#include<string.h>
int main(){int m=1,n=999999,o,c=n/2+1,d;bool*v=new bool[c];for(memset(v,1,c);m<499;m++)for(o=m*2+1,d=o*3;v[m]&&d<n+1;d+=o*2)v[d/2]=0;for(;!(std::cin>>n).eof();printf("%d\n",c))for(c=n-->1,m=1;m<n/2+1;)c+=v[m++];delete[]v;}

Measured memory_bytes: 0
import sys
input = sys.stdin.readline
N, K = map(int, input().split())
S = input()
c0, c1 = [], []
if S[0] == '1':
    c0.append(0)
i = 0
while i < N:
    p = S[i]
    c = 1
    i += 1
    while i < N and S[i] == p:
        i += 1
        c += 1
    if p == '0':
        c0.append(c)
    else:
        c1.append(c)
if S[N-1] == '0':
    c1.append(0)
l0 = len(c0)
if l0 < K:
    K = l0
ans = sum(c0[0:K]) + sum(c1[0:K])
for i in range(1, l0):
    c0[i] += c0[i-1]
    c1[i] += c1[i-1]
l = l0 - K + 1
if l0 == 2 and S[0] == '1':
    ans = N
else:
    for i in range(1, l):
        tmp = c0[i+K-1] - c0[i-1] + c1[i+K-1]
        if i - 2 >= 0:
            tmp -= c1[i-2]
        if ans < tmp:
            ans = tmp
print(ans)


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

int main(){
  int a,b,c,d;
  cin>>a>>b>>c>>d;
  
  if((a+b)>(c+d))
    cout<<"Left"<<endl;
  else if((a+b)<(c+d))
    cout<<"Right"<<endl;
  else
    cout<<"Balanced"<<endl;

}

Measured memory_bytes: 3628
import java.util.Scanner;
public class Main {
    public static void main(String[] args) {
        Scanner input = new Scanner(System.in);
        int A,B,C;
        A = input.nextInt();
        B = input.nextInt();
        C = input.nextInt();
        if(A==5&B==5&C==7)
            System.out.println("YES");
        else if(A==7&B==5&C==5)
            System.out.println("YES");
        else if(A==5&B==7&C==5)
            System.out.println("YES");
        else
            System.out.println("NO");
    }
    
}


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

#define ll long long
#define fornum(A,B,C) for(A=B;A<C;++A)
#define pii pair<int,int>
#define pll pair<ll,ll>

using namespace std;

/////////////////////////////////////////////////////
#define MOD (ll)(1e9+7)

ll N,M;
ll dp[5050][5050];
ll p2[5555];

ll i, j, k;
ll ans;

int main(){
    scanf("%lld%lld", &N, &M);
    p2[0] = 1;
    fornum(i,0,5050){
        p2[i + 1] = p2[i] * 2 % MOD;
        dp[0][i] = 1;
    }

    fornum(i,0,N){
        ll a = 0, b = 0;
        fornum(j,0,M+1){
            (dp[i + 1][j] += dp[i][j] * (j + 1) + a) %= MOD;
            (a *= 2) %= MOD;
            a += dp[i][j] * j;
            //printf("%lld ", dp[i + 1][j]);
        }
        //printf("\n");
    }
    printf("%lld\n", dp[N][M]);

    return 0;
}

Measured memory_bytes: 201112
#include <iostream>
#include <algorithm>
#include <iomanip>
using namespace std;
string alphabet = "abcdefghijklmnopqrstuvwxyz";
string ALPHABET = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";

int main(){
  int a , b , c;
  cin >> a >> b >> c;
  if(b - a == c - b)cout << "YES" << endl;
  else cout << "NO" << endl;
}


Measured memory_bytes: 256
n,k = map(int,input().split())
X = list(map(int,input().split()))
T = []
for i in range(n-k+1):
    if X[i+k-1]<0:
        T += [-X[i]]
    elif X[i]>0:
        T += [X[i+k-1]]
    elif X[i]+X[i+k-1]<0:
        T += [-X[i]+2*X[i+k-1]]
    else:
        T += [-2*X[i]+X[i+k-1]]
print(min(T))

Measured memory_bytes: 14384
N, M = map(int, input().split())
A = list(map(int, input().split()))

Asum = sum(A)
hyou = Asum * (1/(4*M))
count = 0
for i in A:
    if i >= hyou:
     count += 1

if count >= M:
    print("Yes")
else:
    print("No")

Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
int main () {
  int N, M;
  cin >> N >> M;
  vector<vector<long>> data(N, vector<long> (N, 1000000)), sub(N, vector<long> (N));
  vector<pair<long, long>> A(M);
  for(int i = 0; i < M; i++){
    cin >> A.at(i).first >> A.at(i).second;
    A.at(i).first--;
    A.at(i).second--;
    data.at(A.at(i).first).at(A.at(i).second) = 1;
    data.at(A.at(i).second).at(A.at(i).first) = 1;
  }
  for(int i = 0; i < N; i++){
    data.at(i).at(i) = 0;
  }
  long count = 0, flag;
  for(int i = 0; i < M; i++){
    sub = data;
    sub.at(A.at(i).first).at(A.at(i).second) = 1000000;
    sub.at(A.at(i).second).at(A.at(i).first) = 1000000;
    for(int j = 0; j < N; j++){
      for(int k = 0; k < N; k++){
        for(int l = 0; l < N; l++){
          sub.at(k).at(l) = min(sub.at(k).at(l), sub.at(k).at(j) + sub.at(j).at(l));
        }
      }
    }
    flag = 1;
    for(int j = 0; j < N; j++){
      for(int k = 0; k < N; k++){
        if(sub.at(j).at(k) == 1000000){
          flag = 0;
          break;
        }
      }
      if(flag == 0)break;
    }
    if(flag == 0)count++;
  }
  cout << count << endl;
  return 0;
}

Measured memory_bytes: 256
r, g, b, n = map(int, input().split())
cnt = 0
for i in range(3001):
    for j in range(3001):
        k = int((n - (r * i + g * j)) / b)
        if k >= 0 and r * i + g * j + b * k == n:
            cnt += 1

print(cnt)


Measured memory_bytes: 41708
var input = require('fs').readFileSync('/dev/stdin', 'utf8');
var Arr=(input.trim()).split("\n");
var L=Arr.shift();
for(var i=0;i<L;i++){
   var str=Arr[i];
   str=str.replace(/\-\>/g,"A");
   str=str.replace(/\<\-/g,"Z");
   var abc=str.split("");
   var arr=[];
   var n=0;
   abc.forEach(function(v){
      if(v=="A")n++;
      else if(v=="Z")n--;
      else {
         if(n==0){arr.unshift(v);n=1;}
         if(n>arr.length)arr.push(v);
      }
   });
   console.log(arr.join(""));
}

Measured memory_bytes: 9520
s = input()
t = input()
s_list = []
j = 0

for i in range(len(t),len(s)+1):
    s_list.append(s[j:i])
    j += 1

differ = len(t)
mojiretu = ''
for i in range(len(s_list)):
    tmp = 0
    for j in range(len(t)):
        if s_list[i][j] != t[j]:
            tmp += 1
    if tmp < differ:
        differ = tmp
        mojiretu = s_list[i]
    tmp = 0

print(differ)


Measured memory_bytes: 9252
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        long a = sc.nextLong();
        long b = sc.nextLong();
        long k = sc.nextLong();

        if (k > 0) {
            if (a > k) {
                long tmp = a - k;
                k -= a;
                a = tmp;
            } else {
                k -= a;
                a = 0;
            }
        }

        if (k > 0) {
            if (b > k) {
                long tmp = b - k;
                k -= b;
                b = tmp;
            } else {
                k -= b;
                b = 0;
            }
        }

        System.out.println(a + " " + b);
    }

}


Measured memory_bytes: 22740
#include<bits/stdc++.h>
using namespace std;
int main(){
  ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
  int n,m; cin>>n>>m;
  vector<int> v(m);
  int sum=0;
  for(int i=0;i<m;i++) {
    cin>>v[i]; sum+=v[i];
    }
    if(sum>n) cout<<"-1";
    else cout<<n-sum;
    return 0;
 }
           
                               

Measured memory_bytes: 3676
#include <iostream>
using namespace std;
int main()
{
    int d;
    while (cin >> d) {
        int sum = 0;
        for (int i=1; i<600/d; i++) {
            sum += d * (d * i) * (d * i);
        }
        cout << sum << endl;
    }
    return 0;
}

Measured memory_bytes: 1160
//Robs Code
/***********HEADER***************/
#include<bits/stdc++.h>
/***********MACROS***************/
#define int long long int
#define fri(l,k) for (i=l;i<=k;i++)
#define frj(l,k) for (j=l;j>=k;j--)
#define fij(a,b,l,k) for(i=a;i<=b;i++) for(j=l;j<=k;j++)
#define all(x) x.begin(),x.end()
#define allr(x) x.rbegin(),x.rend()
#define endl "\n"
#define pb push_back
#define _1 first
#define _2 second
#define mxsz 10000007
#define mxval 1e9
#define grt [](auto x,auto y){return x>y;}
#define pii pair<int,int>
/*********VARIABLE****************/
using namespace std;
int i,j,n,m,k,l,q,t,a,b,sum[3],tot[3],cnt[3];
/***********MAIN******************/
signed main(){
	ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
	int n,a,b,c,d;
    cin>>n>>a>>b>>c>>d;
    string s;
    cin>>s;
    s = "#" + s + "#";
    for(i=a;i<c;i++){
        if(s[i]==s[i+1]&&s[i]=='#'){
            cout<<"No";
            return 0;
        }
    }
    for(i=b;i<d;i++){
        if(s[i]==s[i+1]&&s[i]=='#'){
            cout<<"No";
            return 0;
        }
    }
    if(c>d){
        bool flag=0;
        for(i=b;i<=d;i++){
            if(s[i-1]==s[i]&&s[i]==s[i+1]&&s[i]=='.'){
                flag=1;
                break;
            }
        }
        if(flag==0){
            cout<<"No";
            return 0;
        }
    }
    cout<<"Yes";
	return 0;
}
//.........



Measured memory_bytes: 720
/**
 *  http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=ALDS1_5_C
 */
#include <iostream>
#include <iomanip>

#define SQRT_3 1.73205080757

using namespace std;

constexpr double
ccw60x(const double ax, const double ay, const double bx, const double by)
{
    return (bx - ax) / 2 - (by - ay) * SQRT_3 / 2 + ax;
}
constexpr double
ccw60y(const double ax, const double ay, const double bx, const double by)
{
    return (bx - ax) * SQRT_3 / 2 + (by - ay) / 2 + ay;
}

void
koch(const int n, const double ax, const double ay, const double bx, const double by)
{
    if (n == 0) return;

    double sx = (2 * ax + bx) / 3;
    double sy = (2 * ay + by) / 3;
    koch(n - 1, ax, ay, sx, sy);
    cout << sx << ' ' << sy << endl;

    double tx = (ax + 2 * bx) / 3;
    double ty = (ay + 2 * by) / 3;
    double ux = ccw60x(sx, sy, tx, ty);
    double uy = ccw60y(sx, sy, tx, ty);
    koch(n - 1, sx, sy, ux, uy);
    cout << ux << ' ' << uy << endl;
    koch(n -1, ux, uy, tx, ty);
    cout << tx << ' ' << ty << endl;
    koch(n -1, tx, ty, bx, by);
}

int
main()
{
    ios_base::sync_with_stdio(false);

    int n;
    cin >> n; cin.ignore();

    double ax = 0;
    double ay = 0;
    double bx = 100;
    double by = 0;
    cout << fixed << setprecision(8) << ax << ' ' << ay << endl;
    koch(n, ax, ay, bx, by);
    cout << bx << ' ' << by << endl;

    return 0;
}

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

int main() {
	int x,a,b;
    cin >> x >> a >> b;
    int s = a-x;
    int t = b-x;
    if(s<0){
      s = -s;
    }
    if(t<0){
      t = -t;
    }
    if(s<t){
      cout << "A" << endl;
    }
    else{
      cout << "B" << endl;
    }
}


Measured memory_bytes: 256
#include <stdio.h>
#include <cmath>
#include <algorithm>
#include <cfloat>
#include <stack>
#include <queue>
#include <vector>
#include <string>
#include <iostream>
#include <map>
typedef long long int ll;
typedef unsigned long long int ull;
#define BIG_NUM 2000000000
#define MOD 1000000007
#define EPS 0.000000001
using namespace std;

int calc(char ch){

	if(ch >= '1' && ch <= '9'){
		return ch-'0';
	}else{
		return 10;
	}
}


void func(){

	char first[2],second[2];
	scanf("%s %s",first,second);

	char pile[8][2];
	for(int i = 0; i < 8; i++){
		scanf("%s",pile[i]);
	}

	int num;
	bool is_ace = false;

	if(first[0] != 'A' && second[0] != 'A'){

		num = calc(first[0]) + calc(second[0]);

	}else if(first[0] == 'A' && second[0] != 'A'){

		num = 11 + calc(second[0]);
		is_ace = true;

	}else if(first[0] != 'A' && second[0] == 'A'){

		num = calc(first[0]) + 11;
		is_ace = true;

	}else if(second[0] == 'A' && second[0] == 'A'){

		num = 12;
		is_ace = true;
	}

	if(num == 21){
		printf("blackjack\n");
		return;
	}else if((num >= 18) || (num == 17 && is_ace == false)){
		printf("%d\n",num);
		return;
	}

	for(int i = 0; i < 8; i++){
		if(pile[i][0] != 'A'){
			num += calc(pile[i][0]);

			if(num > 21 && is_ace == true){
				num -= 10;
				is_ace = false;
			}

			if(num > 21){
				printf("bust\n");
				return;
			}else if((num >= 18) || (num == 17 && is_ace == false)){
				printf("%d\n",num);
				return;
			}

		}else{

			if(num <= 10){
				num += 11;
				is_ace = true;
			}else{
				num += 1;
			}

			if(num > 21 && is_ace == true){
				num -= 10;
				is_ace = false;
			}

			if(num > 21){
				printf("bust\n");
				return;
			}else if((num >= 18) || (num == 17 && is_ace == false)){
				printf("%d\n",num);
				return;
			}
		}
	}
}


int main(){

	int N;
	scanf("%d",&N);

	for(int i = 0; i < N; i++)func();

	return 0;
}

Measured memory_bytes: 3172
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
 
int main() {
  	string s;	cin >> s;
  	if(s == "Sunny") cout << "Cloudy" << endl;
  	if(s == "Cloudy") cout << "Rainy" << endl;
  	if(s == "Rainy" ) cout << "Sunny" << endl;
}

Measured memory_bytes: 256
#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 k,x; cin >> k >> x;
  if(k*500>=x) cout << "Yes" << endl;
  else cout << "No" << endl;
}


Measured memory_bytes: 3624
import java.util.*;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		// 整数の入力
      int N = sc.nextInt(); // 合計値
      int S = sc.nextInt();
      if(N <= S){
      	System.out.println("Yes");
      } else {
        System.out.println("No");
      }
   }
}


Measured memory_bytes: 21844
def solve(S, T):
    sm = {}
    tm = {}
    for s, t in zip(S, T):
        if s in sm and sm[s] != t:
            return "No"
        sm[s] = t

        if t in tm and tm[t] != s:
            return "No"
        tm[t] = s

    return "Yes"


if __name__ == "__main__":
    S = input()
    T = input()
    print(solve(S, T))

Measured memory_bytes: 3632
import java.util.*;

public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int a = sc.nextInt();
    int b = sc.nextInt();
    int c = sc.nextInt();
    int d = c;
    
    for(int i=1;i<=10;i++){
      System.out.println(a*d-b);
      d = a*d-b;
    }
  }
}

Measured memory_bytes: 23380
a = list(map(int,input().split()))
if not a[1] ==0:
  b = list(map(int,input().split()))
  b2 = sorted(b)##小さい順に並べる
  if abs(a[0]-b2[0]) <= abs(a[0]-b2[a[1]-1]):#bがすべて連続の場合の対策
    c = b2[0]-a[0]-1
  else:
    c = b2[a[1]-1]-a[0]+1
  if a[0] < b2[0]:
    print(a[0])
  elif a[0] > b2[a[1]-1]:
    print(a[0])
  else:
    for i in range(a[1]-1):
      if abs(b2[i+1]-b[i])>1:
        for j in range(b2[i+1]-b2[i]-1):##差分が1より大きい場合ソート
          if abs(c) > abs(b2[i]-a[0]+j+1):
            c = b2[i]-a[0]+j+1
          elif abs(c) == abs(b2[i]-a[0]+j+1) and c > b2[i]-a[0]+j+1:
            c = b2[i]-a[0]+j+1
    print(c+a[0])
else:
  print(a[0])

Measured memory_bytes: 9280
#include<iostream>
#include<string>
#include<algorithm>
using namespace std;
int main() {
	int h, w; cin >> h >> w;
	char m[60][60];
	for (int i = 0; i < h; i++) {
		for (int j = 0; j < w; j++) {
			cin >> m[i][j];
		}
	}
	for (int i = 0; i < h; i++) {
		for (int j = 0; j < w; j++) {
			if (m[i][j] == '#') {
				if (i > 0 && m[i - 1][j] == '#')goto heaven;
				if (j > 0 && m[i][j - 1] == '#')goto heaven;
				if (i < h - 1 && m[i + 1][j] == '#')goto heaven;
				if (j < w - 1 && m[i][j + 1] == '#')goto heaven;
				cout << "No\n";
				return 0;
			}
		heaven:;
		}
	}
	cout << "Yes\n";
}

Measured memory_bytes: 256
module Main where
 
import Control.Applicative
import Control.Monad
import Data.List
import Data.Array
import Text.Printf

solve [a,b,c,d,e,f] = [x,y] where
  det = a * e - b * d
  x = (c * e - b * f) / det
  y = (a * f - c * d) / det

printAns [x,y] = printf "%.3f %.3f\n" xx yy
  where
    xx = if x == (-0.0) then 0.0 else x
    yy = if y == (-0.0) then 0.0 else y

main :: IO ()
main = do
    -- _ <- getLine
    ns <- fmap (fmap (read :: String -> Float) . words) . lines <$> getContents
    -- ns <- fmap (fmap (read :: String -> Float) . words) . lines <$> (return "2 -1 -3 1 -1 -3\n2 -1 -3 -9 9 27\n1 2 3 4 5 6\n2 -1 -2 -1 -1 -5")
    forM_ [0..length ns-1] $ \i -> do
      printAns $ solve (ns !! i)

Measured memory_bytes: 4480
import java.util.Scanner

fun main(args :Array<String>){
    val cin = Scanner(System.`in`)
    val a = cin.nextInt()
    val b = cin.nextInt()
    val c = cin.nextInt()
    var div :Int = 0
    
    var i :Int = a
    while(a <= i && i <= b){
	if(c % i == 0) div++ 
	i++
    }
    println("$div")
}



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

vector<string> List{"zzzzz", "zzzzz", "zzzzz", "zzzzz", "zzzzz" };

void slide(int i, string s){
    for(int j = 4; j > i; --j){
        List[j] = List[j - 1];
    }
    List[i] = s;
}

void add_list(string s){
    for(int i = 0; i < 5; ++i){
        if(s == List[i]){
            break;
        } else if(s < List[i]){
            slide(i, s);
            break;
        }
    }
}

int main() {
    string s;
    int K;
    
    cin >> s >> K;
    
    int len = s.size();
    string x;
    
    for(int i = 0; i < len; ++i){
        for(int j = 1; j <= len - i; ++j){
            x = s.substr(i, j);
            if(List[4] < x){
                break;
            }
            add_list(x);
        }
    }
    
    cout << List[K - 1] << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define pb push_back
#define INF 0x3f3f3f3
#define LINF 0x3f3f3f3f3f3f3f
#define MAXN int(3005)
#define fim '\n'
#define ll long long
#define f first
#define s second
#define FAST cin.tie(0), cout.tie(0), ios::sync_with_stdio(0)
#define debug(x) cout << "DEBUG " << x << fim
#define debug2(x, y) cout << "DEBUG " << x << " " << y << fim
#define debug3(x, y, z) cout << "DEBUG " << x << " " << y << " " << z<< fim
#define max3(x, y, z) max(x, max(y, z))
using namespace std;
typedef pair<int, int> pii;
typedef pair<string, int> psi;
typedef pair<int, pair<int, int> > piii;
ll dp[MAXN][MAXN], n, vet[MAXN], paro;

ll solve(int l, int r) {

    if(l > r)
        return 0;
    if(dp[l][r] != -INF)
        return dp[l][r];

    if( ((l+r) % 2) == paro ) return dp[l][r] = max(solve(l+1, r)+vet[l], solve(l, r-1)+vet[r]);
    else return dp[l][r] = min(solve(l+1, r)-vet[l], solve(l, r-1)-vet[r]);

}

int main() {
    FAST;
    cin >> n;
    for(int i = 1; i <= n; i++)
        cin >> vet[i];
    for(int i = 0; i < MAXN; i++)
        for(int j = 0; j < MAXN; j++)
            dp[i][j] = -INF;
    paro = (n%2 == 0 ? 1 : 0);
    cout << solve(1, n) << fim;
}



Measured memory_bytes: 70912
#include<bits/stdc++.h>
#define range(i,a,b) for(int i = (a); i < (b); i++)
#define rep(i,b) for(int i = 0; i < (b); i++)
#define all(a) (a).begin(), (a).end()
#define show(x)  cerr << #x << " = " << (x) << endl;
#define int long long
using namespace std;

template <typename X, typename T>
auto vectors(X x, T a) {
	return vector<T>(x, a);
}

template <typename X, typename Y, typename Z, typename... Zs>
auto vectors(X x, Y y, Z z, Zs... zs) {
	auto cont = vectors(y, z, zs...);
	return vector<decltype(cont)>(x, cont);
}

template<typename T>
ostream& operator << (ostream& os, vector<T>& v){
	rep(i,v.size()){ os << v[i] << (i == v.size() - 1 ? "" : " "); } return os;
}
template<typename T>
istream& operator >> (istream& is, vector<T>& v){
	for(T& x: v){ is >> x; } return is;
}

const int M = 1000000007;

signed main(){
	int n;
	string s;
	cin >> n >> s;

	vector<int> num(26, 0);
	for(auto i : s){
		num[i - 'a']++;
	}


	int ans = 1;
	rep(i,num.size()){
		(ans *= num[i] + 1) %= M;
	}

	cout << ans - 1 << endl;
}


Measured memory_bytes: 512
import bisect
import heapq
import itertools
import math
import operator
import os
import re
import string
import sys
from collections import Counter, deque, defaultdict
from copy import deepcopy
from decimal import Decimal
from fractions import gcd
from functools import lru_cache, reduce
from operator import itemgetter, mul, add, xor

import numpy as np

if os.getenv("LOCAL"):
    sys.stdin = open("_in.txt", "r")

sys.setrecursionlimit(2147483647)
INF = float("inf")
IINF = 10 ** 18
MOD = 10 ** 9 + 7

N, X = list(map(int, sys.stdin.readline().split()))


def pyramid(row):
    ret = [row]
    while len(row) >= 3:
        r = []
        for r1, r2, r3 in zip(row, row[1:], row[2:]):
            r.append(int(np.median([r1, r2, r3])))
        row = r
        ret.append(row)
    ret.reverse()
    return ret


# aa = {}
# for seq in itertools.permutations(reversed(range(1, N * 2))):
#     prmd = pyramid(seq)
#     aa[prmd[0][0]] = prmd
#
# for k, prmd in aa.items():
#     for row in prmd:
#         print(*row)
#     print()


if 1 < X < N * 2 - 1:
    row = list(range(1, N * 2))
    if X <= N:
        for i in range(N):
            row[i] = (i + X) % N + 1
    else:
        for i in range(N):
            row[i + N - 1] = (i + X) % N + N
    print('Yes')
    print(*row, sep='\n')
else:
    print('No')


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

typedef long long ll;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef pair<ll,ll> pll;
typedef vector<bool> vb;
const ll oo = 0x3f3f3f3f3f3f3f3f;
const double eps = 1e-9;
#define sz(c) ll((c).size())
#define all(c) begin(c), end(c)
#define FOR(i,a,b) for (ll i = (a); i < (b); i++)
#define FORD(i,a,b) for (ll i = (b)-1; i >= (a); i--)
#define mp make_pair
#define pb push_back
#define eb emplace_back
#define xx first
#define yy second
#define TR(X) ({ if(1) cerr << "TR: " << (#X) << " = " << (X) << endl; })

int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	
	ll a, b;
	cin >> a >> b;

	ll k = 0;
	while (1 + k*(a-1) < b) k++;
	cout << k << endl;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
#define rep(X,N) for(ll X = 0; X < (N); X++)
#define PI (acos(-1.0))
#define sorta(V) sort(V.begin(), V.end())
#define pback push_back
#define mpair make_pair
#define MODN 1000000007
#define ALL(V) (V).begin(),(V).end() 

using namespace std;

int digit(ll n){
    int d = 1;

    while(n >= 10){
        n = n / 10;
        d++;
    }

    return d;
}

int f(ll a, ll b){
    return max(digit(a), digit(b));
}

int main(){

    //総当たりでいけるはず
    //O(N logN)か？

    ll n;
    cin >> n;

    int ans = INT_MAX;

    for(ll i = 1; i * i <= n; i++){
        if(n % i == 0){
            ans = min(ans, f(i, n / i));
        }
    }

    cout << ans << endl;

    return 0;
}

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

int main(void){
  int n,i,tmp,cnt=0,min=1e9;
  long long int sum=0;
  scanf("%d",&n);
  int a[n];
  for(i=0;i<n;i++){
    scanf("%d",&a[i]);
    if(a[i]<0){
      tmp=a[i]*(-1);
      sum+=tmp;
      cnt++;
      if(min>tmp) min=tmp;
    }else{
      sum+=a[i];
      if(min>a[i]) min=a[i];
    }
  }
  if(cnt%2==0){
    printf("%lld\n",sum);
  }else{
    printf("%lld\n",sum-(2*min));
  }
  return 0;
}

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

int main(){
//	m*n = LCM * GCD
	unsigned long long m, n;
	while(cin >> m >> n){
		int LCM, GCD;
		
		if(m<n){
			int swap;
			swap = m;
			m = n;
			n = swap;
		}

		int m_, n_;
		m_ = m;
		n_ = n;
		do {
			if(n_==0){
				GCD = m_;
				break;
			}
			
			int swap = m_ % n_;
			m_ = n_;
			n_ = swap;
		} while(1);
		
		LCM = (m*n)/GCD;
		cout << GCD << " " << LCM << endl;
	}

	return 0;
}

Measured memory_bytes: 0
#include<bits/stdc++.h>
using namespace std;
#define mod 1000000007
vector<int> adj[200005], vis(200005, 0);
int k;
void dfs(int i) {
	vis[i] = 1;
	k++;
	for (auto it : adj[i]) {
		if (!vis[it]) {
			dfs(it);
		}
	}
}
int main() {
#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif
	int n, m;
	cin >> n >> m;
	for (int i = 0; i < m; i++) {
		int x, y;
		cin >> x >> y;
		adj[x].push_back(y);
		adj[y].push_back(x);

	}
	int  ans = 0;
	for (int i = 0; i < n; i++) {
		k = 0;
		if (!vis[i]) {
			dfs(i);
		}
		ans = max(ans, k);
	}
	cout << ans << endl;

}

Measured memory_bytes: 20996
import sys

def debug(*args):
    print(*args, file=sys.stderr)


x_diff_of_5th_factor = int(input())


for a in range(-118, 119):
    for b in range(-119, 118):
        if a ** 5 - b ** 5 == x_diff_of_5th_factor:
            print('{} {}'.format(a, b))
            sys.exit(0)

sys.exit(1)


Measured memory_bytes: 9116
from math import ceil,floor,comb,factorial,gcd,pow,sqrt,log2,cos,sin,tan,acos,asin,atan,degrees,radians,pi,inf
from itertools import accumulate,permutations,combinations,product,combinations_with_replacement
from collections import deque,defaultdict,Counter
from bisect import bisect_left,bisect_right
from operator import itemgetter
from heapq import heapify,heappop,heappush
from copy import deepcopy
from time import time
import string
import sys
sys.setrecursionlimit(10 ** 7)
def input() : return sys.stdin.readline().strip()
def INT()   : return int(input())
def MAP()   : return map(int,input().split())
def LIST()  : return list(MAP())

s = input()
t = input()
a = [0]*26
b = [0]*26

for i in range(len(s)):
    x = ord(s[i])-ord('a')
    y = ord(t[i])-ord('a')
    a[x] += 1
    b[y] += 1

if sorted(a) == sorted(b):
    print("Yes")
else:
    print("No")

Measured memory_bytes: 10276
program march
  implicit none
  integer :: n, i, j, k
  integer(8) :: cnt(0:5) = 0_8, ans = 0_8
  character(10) :: s
  read(*,*) n
  do i = 1, n
    read(*,*) s
    j = f(ichar(s(1:1))-64)
    cnt(j) = cnt(j)+1_8
  end do
  do concurrent (i = 1:5, j = 1:5, k = 1:5, i < j .and. j < k)
    ans = ans+cnt(i)*cnt(j)*cnt(k)
  end do
  write(*,'(i0)') ans
contains
  integer function f(x)
    integer, intent(in) :: x
    f = x
    if (x == 1 .or. x == 3) return
    f = (164-8*x)/(28-x)
    if (x == 8 .or. x == 13 .or. x == 18) return
    f = 0
  end
end program march

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

int main()
{
  int n,m,l;
  long long nm[101][101],ml[101][101],nl[101][101]={};

  cin>>n>>m>>l;
  for(int i=0;i<n;i++){
    for(int j=0;j<m;j++)cin>>nm[i][j];
  }
  for(int i=0;i<m;i++){
    for(int j=0;j<l;j++)cin>>ml[i][j];
  }

  for(int i=0;i<n;i++){
    for(int j=0;j<m;j++){
      for(int k=0;k<l;k++){
	nl[i][k]+=nm[i][j]*ml[j][k];
      }
    }
  }
  for(int i=0;i<n;i++){
    for(int j=0;j<l-1;j++)cout<<nl[i][j]<<" ";
    cout<<nl[i][l-1]<<endl;
  }
  return 0;
}

Measured memory_bytes: 1408