akhauriyash/Code-Regression huggingface dataset:
#include <map>
#include <set>
#include <ctime>
#include <queue>
#include <stack>
#include <cmath>
#include <vector>
#include <bitset>
#include <cstdio>
#include <cctype>
#include <string>
#include <numeric>
#include <cstring>
#include <cassert>
#include <climits>
#include <cstdlib>
#include <iostream>
#include <algorithm>
#include <functional>
using namespace std ;
#define rep(i, a, b) for (register int i = (a); i <= (b); ++i)
#define per(i, a, b) for (register int i = (a); i >= (b); --i)
#define loop(it, v) for (auto it = v.begin(); it != v.end(); it++)
#define cont(i, x) for (register int i = head[x]; i; i = edge[i].nex)
#define clr(a) memset(a, 0, sizeof(a))
#define ass(a, cnt) memset(a, cnt, sizeof(a))
#define cop(a, b) memcpy(a, b, sizeof(a))
#define lowbit(x) (x & -x)
#define all(x) x.begin(), x.end()
#define SC(t, x) static_cast <t> (x)
#define ub upper_bound
#define lb lower_bound
#define pqueue priority_queue
#define mp make_pair
#define pb push_back
#define pof pop_front
#define pob pop_back
#define fi first
#define se second
#define y1 y1_
#define Pi acos(-1.0)
#define iv inline void
#define enter putchar('\n')
#define siz(x) ((int)x.size())
#define file(x) freopen(x".in", "r", stdin),freopen(x".out", "w", stdout)
typedef double db ;
typedef long long ll ;
typedef unsigned long long ull ;
typedef pair <int, int> pii ;
typedef vector <int> vi ;
typedef vector <pii> vii ;
typedef queue <int> qi ;
typedef queue <pii> qii ;
typedef set <int> si ;
typedef map <int, int> mii ;
typedef map <string, int> msi ;
const int maxn = 1e6 + 100 ;
const int inf = 0x3f3f3f3f ;
const int iinf = 1 << 30 ;
const ll linf = 2e18 ;
const ll mod = 1e9 + 7 ;
const double eps = 1e-5 ;

ll n;

ll c[55][55], f[55][55];

signed main()
{
	scanf("%lld", &n);
	c[0][0] = 1;
	rep(i, 1, n)
	{
		c[i][0] = 1;
		rep(j, 1, i) c[i][j] = (c[i - 1][j] + c[i - 1][j - 1]) % mod;
	}
	f[1][0] = n, f[1][1] = n;
	rep(i, 1, n - 1) rep(j, 0, i) rep(k, max(j, 1), n - i)
	{
		if((k - j) & 1) continue;
		rep(x, 0, k) (f[i + k][abs(x - (k - j) / 2)] += c[n - i][k] * c[k][x] % mod * f[i][j] % mod) %= mod;
	}
	printf("%lld\n", f[n][0]);
	return 0;
}

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


int N;
long long A[100000];
vector<pair<int, int> > adj[100000];
long long edge_label[100000];
bool visited[100000], visited2[100000];

long long make_edge_label(int now){
    // 子ノードへのedgeのlabelの和を返す
    visited[now] = true;
    long long ret = 0;
    for(int i = 0; i < adj[now].size(); i++){
        int next = adj[now][i].first;
        int edge_idx = adj[now][i].second;
        if(visited[next]){
            continue;
        }
        if(adj[next].size() == 1){
            edge_label[edge_idx] = A[next];
            ret += edge_label[edge_idx];
        }else{
            long long tmp = make_edge_label(next);
            edge_label[edge_idx] = 2*A[next] - tmp;
            if(edge_label[edge_idx] < 0){
                cout << "NO" << endl;
                exit(0);
            }
            ret += edge_label[edge_idx];
        }
    }
    return ret;
}

void check_consistency(int now){
    visited2[now] = true;
    for(int i = 0; i < adj[now].size(); i++){
        int next = adj[now][i].first;
        if(visited2[next] == false){
            visited2[next] = true;
            check_consistency(next);
        }
    }
    if(adj[now].size() == 1){
        return;
    }
    long long sum = 0, max_label = 0;
    for(int i = 0; i < adj[now].size(); i++){
        int edge_idx = adj[now][i].second;
        sum += edge_label[edge_idx];
        max_label = max(max_label, edge_label[edge_idx]);
    }
    if(sum % 2 != 0 || 2*max_label > sum){
        cout << "NO" << endl;
        exit(0);
    }
}


int main(){
    cin >> N;
    for(int i = 0; i < N; i++){
        cin >> A[i];
    }
    for(int i = 0; i < N - 1; i++){
        int a, b;
        cin >> a >> b;
        a--;
        b--;
        adj[a].push_back(make_pair(b, i));
        adj[b].push_back(make_pair(a, i));
    }

    long long label_0 = make_edge_label(0);
    if(adj[0].size() == 1){
        if(label_0 != A[0]){
            cout << "NO" << endl;
            return 0;
        }
    }else{
        if(label_0 != 2 * A[0]){
            cout << "NO" << endl;
            return 0;
        }
    }

    check_consistency(0);
    /*
    for(int i = 0; i < N - 1; i++){
        cout << edge_label[i] << endl;
    }
    */
    cout << "YES" << endl;
    
        
}



Measured memory_bytes: 12800
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define int long long
const int mod =1000000007;
signed main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n,q,s,h,d;
    cin>>q>>h>>s>>d>>n;
    h=min(h,2*q);
    s=min(s,2*h);
    d=min(d,2*s);
    cout<<n/2*d+(n-n/2*2)*s;
}

Measured memory_bytes: 256
import qualified Data.Text.Lazy as T
import qualified Data.Text.Lazy.IO as T
import qualified Data.Text.Lazy.Read as T

main :: IO ()
main = do
  let
    modulus = 1000000007 :: Int
    modAdd :: Int -> Int -> Int
    modAdd x y = (x + y) `mod` modulus
    modMul :: Int -> Int -> Int
    modMul x y = (x * y) `mod` modulus
    go :: Int -> Int -> [Int] -> Int
    go s c (x : xs) = go (s `modAdd` (c `modMul` x)) (c `modAdd` x) xs
    go s c _        = s
  n <- unsafeTextToInt <$> T.getLine :: IO Int
  as <- map unsafeTextToInt . T.words <$> T.getContents :: IO [Int]
  print . go 0 0 $ as

unsafeTextToInt :: T.Text -> Int
unsafeTextToInt s = case T.signed T.decimal s of
  Right (n, _) -> n
{-# INLINE unsafeTextToInt #-}


Measured memory_bytes: 4904
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <cmath>
#include <utility>
using namespace std;
typedef long long ll;

const ll MOD = 1e9+7;


int main()
{
	ll r,d,x;
	ll ans=0;
	cin>>r>>d>>x;
	for(int i=0;i<10;i++)
	{
		x=r*x-d;
		cout<<x<<endl;
	}
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#pragma GCC optimize("unroll-loops,no-stack-protector")
#pragma GCC target("sse,sse2,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#define watch(x) cout <<(#x)<<" is "<<(x)<<endl
#define debug cout <<"hi"<<endl
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
const int MOD=1e9+7;
const int INF32=1<<30;
const ll INF64=1LL<<60;

void solve(){
  int n,m; cin >>n >>m;  
  vector<int>s[m]; int p[m],sum=0;
  for(int i=0; i<m; i++){
    int k; cin >>k;
    for(int j=0; j<k; j++){
      int x; cin >>x;
      s[i].push_back(x);
    }
  }
  for(auto &i:p) cin >>i;
  for(int i=0; i<1<<n; i++){
    int x=i;
    bool b[n],bb=1; memset(b,0,sizeof(b));
    for(int j=0; j<n; j++){
      b[j]=x%2; x/=2;
    }
    for(int j=0; j<m; j++){
      int cnt=0;
      for(auto z:s[j]) if(b[z-1]) cnt++;
      if(cnt%2!=p[j]){bb=0; break;}
    }
    if(bb) sum++;
  }
  cout <<sum;
}

int main(){
  ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
  solve();
return 0;}

Measured memory_bytes: 3636
import sys
def get_array(): return list(map(int , sys.stdin.readline().strip().split()))
def get_ints(): return map(int, sys.stdin.readline().strip().split())
def input(): return sys.stdin.readline().strip()

n = int(input())
Arr = get_array()
ans = 0
for i in range(n):
  for j in range(i+1,n):
    ans+=Arr[i]*Arr[j]
print(ans)

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

int main (){
	char huruf[10000];
	int input;
	scanf("%d",&input);
	getchar();
	scanf ("%[^\n]",&huruf);
	int len = strlen (huruf);
	input = input % 26;
	for (int i = 0 ; i < len; i++){
		if (huruf[i]-'A' + input >= 26){
			huruf[i] = ((huruf[i]-'A' + input) % 26 )+'A';
		} else {
			huruf [i] +=input; 
		}
		printf("%c", huruf[i]);
	}
	
}


Measured memory_bytes: 1672
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <math.h>
#include <algorithm>
#include <iostream>
using namespace std;
struct ST
{
   long long time;
   long long ending;
}stu[200000];
bool cmp(struct ST a,struct ST b)
{
    return a.ending<b.ending?true:false;
}
int main()
{
    int n;
    scanf("%d",&n);
    int i;long long sum=0,flag=0;
    for(i=0;i<n;i++)
        scanf("%lld%lld",&stu[i].time,&stu[i].ending);
    sort(stu,stu+n,cmp);
    for(i=0;i<n;i++)
    {
        sum+=stu[i].time;
        if(sum>stu[i].ending) {flag=1;break;}
    }
    if(flag==0)
        printf("Yes\n");
    else
        printf("No\n");
    return 0;
}


Measured memory_bytes: 3456
#include<iostream>
#include<vector>
#include<algorithm>

using namespace std;

int main()
{
	int n;
	cin >> n;
	vector<long long> a(3*n);
	for(int i=0;i<n*3;i++)
		cin >> a[i];
	
	sort(a.begin(),a.end());
	reverse(a.begin(),a.end());

	long long ans=0;
	for(int i=0;i<n;i++)
	{
		ans+=a[i*2+1];
	}

	cout << ans << endl;
}


Measured memory_bytes: 2560
#include<stdio.h>
int main()
{
  int n,i,j,k,v,x,cnt=0,m=0;
  int A[1000000];
  int G[1000000];
  scanf("%d",&n);
   
  for(i=0;i<n;i++){
    scanf("%d",&A[i]);
    }
   
  G[0]=1;
  for(i=1;G[i-1]<=n;i++){
    m++;
    G[i]=G[i-1]*3+1;
    if(m>100)break;
  }
  for(i=0;i<m/2;i++){
    x=G[i];
    G[i]=G[m-i-1];
    G[m-i-1]=x;
  }
   
   
  for(i=0;i<m;i++){
    for(j=G[i];j<n;j++){
      v=A[j];
      k=j-G[i];
      while(k>=0&&A[k]>v){
    A[k+G[i]]=A[k];
        k=k-G[i];
    cnt++;
      }
      A[k+G[i]]=v;
    }
  }
   
  printf("\n%d\n",m);
  for(i=0;i<m;i++){
    printf("%d ",G[i]);
  }
  printf("\n%d\n",cnt);
  for(i=0;i<n;i++){
    printf("%d\n",A[i]);
    }
  return 0;
}

Measured memory_bytes: 6156
#include <bits/stdc++.h>
using namespace std;
typedef pair<int, int> P;
typedef long long ll;
ll read()
{  ll f=1,x=0;
   char ch=getchar();
   for(;ch>'9'||ch<'0';ch=getchar())if(ch=='-') f=-1;
   for(;ch<='9'&&ch>='0';ch=getchar())x = x * 10 + ch - '0';
   return x*f;
}
ll n, K, a[200055],dis[200055],sum,flag;
int main()
{     cin>>n>>K;
      for(int i=1;i<=n;i++)a[i]=read();
      for(ll k=1;k<=K;k++)
      {   memset(dis,0,sizeof(dis));
          sum=0,flag=1;
          for(ll i=1;i<=n;i++)
           {   ll x=max(i-a[i],(ll)1);
               ll y=min(i+a[i]+1,n+1);
               dis[x]++;
               dis[y]--;
           }
          for(ll i=1;i<=n;i++)
          {  sum=sum+dis[i];
             a[i]=sum;
            // printf("%lld ",a[i]);
             if(a[i]!=n)flag=0;
          }
          //printf("k=%lld\n",k);
          if(flag)break;
      }
      for(int i=1;i<=n;i++)printf("%lld ",a[i]);



      return 0;
}


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

struct Point { double x, y; };

void koch(int n, Point a, Point b){
    if (n==0) return;
    Point s,t,u;
    double th=M_PI*60.0/180.0;
    
    s.x=(2.0*a.x+1.0*b.x)/3.0;
    s.y=(2.0*a.y+1.0*b.y)/3.0;
    t.x=(1.0*a.x+2.0*b.x)/3.0;
    t.y=(1.0*a.y+2.0*b.y)/3.0;
    u.x=(t.x-s.x)*cos(th)-(t.y-s.y)*sin(th)+s.x;
    u.y=(t.x-s.x)*sin(th)+(t.y-s.y)*cos(th)+s.y;
    
    koch(n-1,a,s);
    printf("%.8f %.8f\n", s.x, s.y);
    
    koch(n-1,s,u);
    printf("%.8f %.8f\n", u.x, u.y);
    
    koch(n-1,u,t);
    printf("%.8f %.8f\n", t.x, t.y);
    
    koch(n-1,t,b);
}

int main(){
    Point a,b;
    int n;
    
    scanf("%d", &n);
    
    a.x=0;
    a.y=0;
    b.x=100;
    b.y=0;
    
    printf("%.8f %.8f\n", a.x, a.y);
    koch(n, a, b);
    printf("%.8f %.8f\n", b.x, b.y);
    
    return 0;
}


Measured memory_bytes: 2756
n = gets.chomp.to_i
a = []
n.times{a << gets.to_i}
b = a
c = a.sort
max = c[-1]
second = c[n-2]
for i in 0..(n-1)
    if max != b[i]
        puts max
    else 
        puts second
    end
end

Measured memory_bytes: 8224
package main

import (
	"fmt"
	"math"
)

func main() {
	var n int
	fmt.Scan(&n)

	a := make([]int, n)
	for i := 0; i < n; i++ {
		fmt.Scan(&a[i])
	}

	ans := 999999999999
	for i := -100; i <= 100; i++ {
		sum := 0
		for j := 0; j < n; j++ {
			x := math.Abs(float64(i - a[j]))
			sum += int(x * x)
		}
		if sum < ans {
			ans = sum
		}
	}
	fmt.Println(ans)
}

func round(f float64) float64 {
	return math.Floor(f + .5)
}


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

int N;
vector<int> cnt; 
vector<int> G[200010];

void dfs(int v, int p = -1){ // pはvの親
  for(int nv : G[v]){
    if(nv == p) continue;
    cnt[nv] += cnt[v];
    dfs(nv, v);
  }
}

int main(){
  int Q; cin >> N >> Q; 
  for(int i = 1; i < N; i++){
    int a, b; cin >> a >> b;
    a--; b--; //0スタートの木に変える
    G[a].push_back(b);
    G[b].push_back(a);
  }
  cnt.resize(N);
  for(int i = 0; i < Q; i++){
    int p, x; cin >> p >> x;
    p--;
    cnt[p] += x; 
  }
  dfs(0); //index0が根
  for(int i = 0; i < N; i++){
    cout << cnt[i] << " ";
  }
}

Measured memory_bytes: 23424
#include<iostream>
#include<vector>
#include<stdlib.h>
#include<time.h>
#include<math.h>
#include<string.h>
#include<algorithm>
#include<queue>
#include<map>
#include<iomanip>

using namespace std;
int main(void){
 int format1=0;
 int format2=0;
 int check1,check2;
 char s[5];

 cin>>s;
 format1=(s[0]-'0')*10+(s[1]-'0');
 format2=(s[2]-'0')*10+(s[3]-'0');

 if(format1==0 || format1>12)check1=1;
 else check1=0;
 
 if(format2==0 || format2>12)check2=1;
 else check2=0;
 
 if(check1==0 && check2==0)cout<<"AMBIGUOUS"<<endl;
 else if(check1==1 && check2==0)cout<<"YYMM"<<endl;
 else if(check1==0 && check2==1)cout<<"MMYY"<<endl;
 else cout<<"NA"<<endl;

 return 0;
}

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

long long digit(long long sum);

int main()
{
    long long a, b;
    while(cin >> a >> b)
    {
    long long sum = a+b; 
    
    cout<< digit(sum) << endl;
    }
    
    
    
return 0;
}


long long digit(long long sum)
{
     if(sum<10)
      return 1;
     else
         return (1 + digit(sum/10));
}

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

int main () {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int n;
  cin >> n;
  for (int i = 1; i < n+1; ++i) {
    int x = i * 1.08;
    if (x == n) {
      cout << i << endl;
      return 0;
    }
  }
  cout << ":(" << endl;
}

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

int main(){
    int n;
    cin>>n;
    int cnt=0;
    int ans=0;
    for(int i=1;i<=n;i=i+2){
        cnt=0;
        for(int j=1;j<=i;j++){
            if(i%j==0)cnt++;
        }
        if(cnt==8)ans++;
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 3596
#include <iostream>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <map>
#include <queue>

static const int MOD = 1000000007;
using ll = long long;
using u32 = unsigned;
using namespace std;

template<class T>
constexpr T INF = ::numeric_limits<T>::max() / 32 * 15 + 208;

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

    if(k == 0){
        cout << n*n << "\n";
        return 0;
    }

    for (ll b = k+1; b <= n; ++b) {
        ans += n/b*(b-k)+max(n%b-k+1, 0LL);
    }
    cout << ans << "\n";
    return 0;
}


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

int main() {
    long long n;
    cin >> n;
    if (n % 2 == 0) {
        cout << n << endl;
        return 0;
    }
    cout << n*2 << endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>

long solve(long n, long capacity, const std::vector<long>& weights, const std::vector<long>& values)
{
    std::vector< std::vector<long> > dp;
    dp.resize(n);
    dp[0].resize(capacity + 1);

    for (long w = weights[0]; w <= capacity; w++) {
        dp[0][w] = values[0];
    }

    for (long i = 1; i < n; i++) {
        dp[i].resize(capacity + 1);
        for (long w = 0; w <= capacity; w++) {
            if (weights[i] <= w) {
                dp[i][w] = std::max(dp[i - 1][w - weights[i]] + values[i], dp[i - 1][w]);
            } else {
                dp[i][w] = dp[i - 1][w];
            }
        }
    }

    return dp[n - 1][capacity];
}

int main()
{
    long n;
    long capacity;
    std::vector<long> weights;
    std::vector<long> values;

    std::cin >> n >> capacity;
    weights.resize(n);
    values.resize(n);

    for (long i = 0; i < n; i++) {
        std::cin >> weights[i] >> values[i];
    }

    std::cout << solve(n, capacity, weights, values) << std::endl;
    return 0;
}


Measured memory_bytes: 78592
#include<iostream>
#include<algorithm>
#include<climits>
#include<cmath>
#include<cstdio>
#include<cstdlib>
#include<ctime>
#include<string>
#include<cstring>
#include<vector>
#include<stack>
#include<queue>
#include<set>
#include<bitset>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;

template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }

#define mod 1000000007LL
#define eps 0.0001
#define pi acos(-1)
#define INF 10000000000000000

#define rep(i, n) for(int i = 0;i < n;++i)
#define rep1(i, n) for(int i = 1;i < n;++i)
#define pri(x) cout << (x) << "\n"
#define pri2(x, y) cout << (x) << " " << (y) << "\n"
#define pri3(x, y, z) cout << (x) << " " << (y) << " " << (z) << "\n"
#define chmin

#define lset(h, n) memset(h, n, sizeof(h));
    

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    // ---------------------
    // コーディング開始
    // ---------------------
    ll n;
    cin >> n;
    ll ans = n / 11ll;
    ll t = n%11ll;
    ans*=2ll;
    if(t>6){
        ans+=2ll;
    }else if(t!=0){
        ans++;
    }
    pri(ans);
    
    return 0;
}



Measured memory_bytes: 256
#include <stdio.h>
#define c 1000000000

int main(void)
{
	long long int xa,xb,xc,ya,yb,yc;
	long long int S;
	scanf("%lld",&S);
	xa = 0,ya = 0,xb = c;yb = 1;
	
	
	yc = S/c;
	yc++;
	xc = yc*c-S;
	
	
	if(S/c==c&&S%c==0)
	{
		printf("0 0 1000000000 0 0 1000000000");
		return 0;
	}
	printf("%lld %lld %lld %lld %lld %lld",xa,ya,xb,yb,xc,yc);
	
	return 0;
}



Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
const ll MOD = 1e9+7;
const ll INF = 1e18;
#define rep(i,m,n) for(ll i = (m); i <= (n); i++)
#define rrep(i,m,n) for(ll i = (m); i >= (n); i--)
#define print(x) cout << (x) << endl;
#define printa(x,m,n) for(ll i = (m); i <= n; i++){cout << (x[i]) << " ";} cout<<endl;

ll n, a;
string s;

int main(){
	cin.tie(0); ios::sync_with_stdio(false);
	
	cin >> n;
	ll itr = 1;
	ll ans = 0;
	rep(i, 1, n){
		cin >> a;
		if(a == itr){
			itr++;
		}
		else{
			ans++;
		}
	}
	if(ans == n){
		ans = -1;
	}
	print(ans)
	return 0;
}

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

int k, ans[555][555];

void doit(int n){
    if (k<n) return;
    int p=0;
    for (int i=0;i<n;++i){
        int now= k-p-2>=(n-i-1)? 2: 1;
        for (int j=0;j<n;++j)
            ans[j][(j+i)%n]=j%now+p;
        p+=now;
    }
    cout<<n<<endl;
    for (int i=0;i<n;++i){
        for (int j=0;j<n;++j) printf("%d ",ans[i][j]+1);
        puts("");
    }
    exit(0);
}

int main(){
    cin>>k;
    doit((k+1)/2+((k+1)/2&1?1:0));
    puts("1\n1");
}

Measured memory_bytes: 2304
#include<iostream>
#include<algorithm>
#include<string>
using namespace std;
int m(int num){if(num%2)return -1;else return 1;}
int main(){
	int N,A[100000];
	cin>>N>>A[0];
	for(int i=1;i<N;i++){
		cin>>A[i];
		A[i]=A[i]*m(i)+A[i-1];
	}
	cout<<A[N-1]<<" ";
	for(int i=1;i<N;i++){
		cout<<(A[N-1]-A[i-1])*m(i)-A[i-1]*m(i)<<" ";
	}
	return 0;
}

Measured memory_bytes: 1792
#include<iostream>
#include <vector>
using namespace std;
int main() {
	int N;
	cin >> N;
	vector<int> H(N);
	for (int i = 0; i < N; i++)
	{
		cin >> H[i];
	}
	int ans = 0;
	for (int i = 0; i < N; i++) {
		bool flag = true;
		for (int j = 0; j < i; j++)
		{
			if (H[j] > H[i])flag = false;
		}
		if (flag) ans++;
	}
	cout << ans << endl;
}

Measured memory_bytes: 256
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <algorithm>
#include <iostream>
using namespace std;
int d,n;
int main()
{
cin>>d>>n;
if (d==0)
{
    if (n<100) printf("%d\n",n); else printf("101\n");
} else
if (d==1)
{
    if (n<100)
    printf("%d\n",n*100); else printf("10100\n");
} else
if (d==2)
{
    if (n<100)
    printf("%d\n",n*100*100);
    else printf("1010000\n");
}
    return(0);
}


Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Atcoder
{
    class Program
    {
        static void Main(string[] args)
        {
            var tmp = Console.ReadLine().Split(' ');
            var A = int.Parse(tmp[0]);
            var B = int.Parse(tmp[1]);
            var T = int.Parse(tmp[2]);
            var result = (int)(T + 0.5) / A * B;
            Console.Write(result);

        }
    }

    //var N = int.Parse(Console.ReadLine());
    //var S = Console.ReadLine();
    //var K = Console.ReadLine().Split(' ');
}


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

int main() {
    int n;
    int f = 0;
    cin >> n;
    for (int i = n; i > 0; i /= 10) {
        f += i % 10;
    }
    if (n % f == 0) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
    
}

Measured memory_bytes: 3612
import sys
sys.setrecursionlimit(10**7) #再帰関数の上限,10**5以上の場合python
import math
from copy import copy, deepcopy
from copy import deepcopy as dcp
from operator import itemgetter
from bisect import bisect_left, bisect, bisect_right#2分探索
#bisect_left(l,x), bisect(l,x)#aはソート済みである必要あり。aの中からx未満の要素数を返す。rightだと以下
from collections import deque, defaultdict
#deque(l), pop(), append(x), popleft(), appendleft(x)
#q.rotate(n)で → にn回ローテート
from collections import Counter#文字列を個数カウント辞書に、
#S=Counter(l),S.most_common(x),S.keys(),S.values(),S.items()
from itertools import accumulate,combinations,permutations,product#累積和
#list(accumulate(l))
from heapq import heapify,heappop,heappush
#heapify(q),heappush(q,a),heappop(q) #q=heapify(q)としないこと、返り値はNone
#import fractions#古いatcoderコンテストの場合GCDなどはここからimportする
from functools import reduce,lru_cache#pypyでもうごく
#@lru_cache(maxsize = None)#maxsizeは保存するデータ数の最大値、2**nが最も高効率
from decimal import Decimal

def input(): 
    x=sys.stdin.readline()
    return x[:-1] if x[-1]=="\n" else x
def printe(*x):print("## ",*x,file=sys.stderr)
def printl(li): _=print(*li, sep="\n") if li else None
def argsort(s, return_sorted=False): 
    inds=sorted(range(len(s)), key=lambda k: s[k])
    if return_sorted: return inds, [s[i] for i in inds]
    return inds
def alp2num(c,cap=False): return ord(c)-97 if not cap else ord(c)-65
def num2alp(i,cap=False): return chr(i+97) if not cap else chr(i+65)
def matmat(A,B):
    K,N,M=len(B),len(A),len(B[0])
    return [[sum([(A[i][k]*B[k][j]) for k in range(K)]) for j in range(M)] for i in range(N)]
def matvec(M,v):
    N,size=len(v),len(M)
    return [sum([M[i][j]*v[j] for j in range(N)]) for i in range(size)]
def T(M):
    n,m=len(M),len(M[0])
    return [[M[j][i] for j in range(n)] for i in range(m)]
def main():
    mod = 1000000007
    #w.sort(key=itemgetter(1),reverse=True)  #二個目の要素で降順並び替え

    N = int(input())
    #N, K = map(int, input().split())
    A = tuple(map(int, input().split())) #1行ベクトル
    #L = tuple(int(input()) for i in range(N)) #改行ベクトル
    #S = tuple(tuple(map(int, input().split())) for i in range(N)) #改行行列

    cnt=0
    for i,a in enumerate(A):
        if i%2==0 and a%2==1:
            cnt+=1
    print(cnt)



if __name__ == "__main__":
    main()

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

int main()
{
	int N, M;
	cin >> N >> M;
	vector<pair<int, int> > SC(M);
	for (int i = 0; i < M; i++)
		cin >> SC.at(i).first >> SC.at(i).second;
	sort(SC.begin(), SC.end());
	for (int i = 0; i < M; i++)
		SC.at(i).first--;
	vector<int> ans(N, -1);
	bool is_exist = true;
	for (int i = 0; i < M; i++){
		if (ans.at(SC.at(i).first) == -1)
			ans.at(SC.at(i).first) = SC.at(i).second;
		else if (ans.at(SC.at(i).first) != SC.at(i).second)
			is_exist = false;
	}
	if (N != 1 && ans.at(0) == 0) is_exist = false;
	if (is_exist){
		for (int i = 0; i < N; i++){
			if (ans.at(i) != -1) cout << ans.at(i);
			else{
				if (i == 0){
					if (N == 1) cout << 0;
					else cout << 1;
				}else
					cout << 0;
			}
		}
	}else cout << -1;
	cout << endl;
}


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


int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    int N, M;
    cin >> N >> M;

    bool even = (M % 2 == 0);
    int left = 1;
    int right = M;

    if (!even) ++right;
    while (left < right) {
        cout << left << ' ' << right << endl;
        ++left;
        --right;
    }

    left = M+1;
    if (!even) ++left;
    right = left + M;
    if (!even) --right;
    while (left < right) {
        cout << left << ' ' << right << endl;
        ++left;
        --right;
    }
    return 0;
}

Measured memory_bytes: 3620
#include <iostream>
#include <cctype>
#define N 56

using namespace std;
int n, k;
char tab[N];

int main(){
    ios_base::sync_with_stdio(0);
    cin.tie(NULL);
    cin >> n >> k;
    for(int i = 0; i < n; ++i){
        cin >> tab[i];
    }
    tab[k-1] = tolower(tab[k-1]);
    for(int i = 0; i < n; ++i) cout << tab[i];
    return 0;
}


Measured memory_bytes: 888
#include<bits/stdc++.h>
using namespace std;
int main(){
    string s;
    cin>>s;
    int n=s.size();
    vector<int> ans(n,0);
    for(int i=0;i<2;i++){
        int count=0;
        for(int j=0;j<n;j++){
            if(s[j]=='L'){
                ans[j-1]+=(count+1)/2;
                ans[j]+=count/2;
                count=0;
            }else{
                count++;
            }
        }
        reverse(ans.begin(),ans.end());
        reverse(s.begin(),s.end());
        for(int i=0;i<n;i++){
        if(s[i]=='R')s[i]='L';
        else s[i]='R';
    }
    }
    for(int i=0;i<n;i++){
        cout<<ans[i]<<" ";
    }
    cout<<endl;
    return 0;
}


Measured memory_bytes: 1024
#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;

int main(){
  string s,t;
  cin>>s>>t;
  int n=s.size();
  rep(i,n){
    if(s[i]!=t[i]){
      cout<<"No"<<endl;
      return 0;
    }
  }
  cout<<"Yes"<<endl;
}



Measured memory_bytes: 3596
#include<stdio.h>

int main(){
  int k = 0;
  int s = 0;
  int i = 0;
  int j = 0;
  long long cnt = 0;
  scanf("%d %d",&k,&s);
  for(i=0;i<=k;i++){
    for(j=0;j<=k;j++){
      if(0 <= s-j-i && s-j-i <= k){
        cnt++;
      }
    }
  }
  
  printf("%lld",cnt);
  return 0;
}
        
    

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

using namespace std;

typedef long long i64;
typedef i64 int_t;
typedef vector<int_t> vi;
typedef vector<vi> vvi;

typedef pair<int_t, int_t> pi;

#define tr(c, i) for(auto i = (c).begin(); i != (c).end(); i++)
#define pb push_back
#define sz(a) i64((a).size())
#define all(c) (c).begin(), (c).end()
#define REP(s, e, i) for(i=(s); i < (e); ++i)

class UnionFindTree {
public:
  UnionFindTree(i64 N) : trees(N, -1), height(N, 1), count(N, 1) {
  }

  void merge(i64 ia, i64 ib) {
    if(is_same_group(ia, ib)) {
      return;
    }

    if(height[ia] > height[ib]) {
      swap(ia, ib);
    }

    i64 rb = find_root(ib), ra = find_root(ia);
    count[rb] += count[ra];
    count[ra] = 0;

    while(trees[ia] != -1) {
      i64 next = trees[ia];
      trees[ia] = ib;
      ia = next;
    }
    trees[ia] = ib;
  }

  bool is_same_group(i64 ia, i64 ib) {
    return find_root(ia) == find_root(ib);
  }

  i64 find_root(i64 ia) {
    vi children;
    i64 i;
    while(trees[ia] != -1) {
      children.pb(ia);
      ia = trees[ia];
    }
    REP(0, sz(children), i) {
      trees[children[i]] = ia;
    }
    return ia;
  }

  vi trees;
  vi height;
  vi count;
};

int main(int argc, char *argv[]) {
  i64 N, Q, i;
  cin >> N >> Q;
  UnionFindTree tree(N);
  REP(0, Q, i) {
    i64 t, u, v;
    cin >> t >> u >> v;
    if(t == 0) {
      tree.merge(u, v);
    }
    else {
      cout << (tree.find_root(u) == tree.find_root(v) ? 1 : 0) << endl;
    }
  }

  return 0;
}


Measured memory_bytes: 7520
import java.util.Scanner;

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

		Scanner scan = new Scanner(System.in);

		while ((scan.hasNext())) {
			int area = 0;
			int d = scan.nextInt();
			for (int i = 0; i * d < 600; i++) {
				area = area + (d * (d * i) * (d * i));
			}
			System.out.println(area);
		}
	}
}

Measured memory_bytes: 11000
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define REP(i, a, b) for(ll i=(a); i<(b); i++)
#define PER(i, a, b) for(ll i=(a); i>=(b); i--)
#define rep(i, n) REP(i, 0, n)
#define per(i, n) PER(i, n, 0)
#define ALL(a)  (a).begin(),(a).end()
const ll INF = 1e18+18;
const ll MAX = 200000;
const ll MOD = 1000000007;
#define Yes(n) cout << ((n) ? "Yes" : "No") << endl;
#define YES(n) cout << ((n) ? "YES" : "NO") << endl;



int main(){
  string S;
  cin>>S;
  ll Size=S.size();
  ll Ans=0;
  ll A=0;
  ll B=0;
  ll Cou=0;
  ll Tri=1;
  rep(i, Size){
    if(S.at(i)=='A'){
      A+=Tri;
    }
    if(S.at(i)=='B'){
      B+=A;
    }
    if(S.at(i)=='C'){
      Ans+=B;
    }
    if(S.at(i)=='?'){
      ll AA=A*3+Tri;
      ll BB=A+B*3;
      Ans=Ans*3+B;
      A=AA;
      B=BB;
      Cou++;
      Tri*=3;
    }
    A%=MOD;
    B%=MOD;
    Ans%=MOD;
    Tri%=MOD;
	//cout<<A<<" "<<B<<" "<<Ans<<endl;

  }
  cout<<Ans<<endl;
} 

Measured memory_bytes: 3700
#-*-coding:utf-8-*-
import sys
input=sys.stdin.readline

def main():
    a,b,c,x,y = map(int,input().split())
    ans1=99999999999999999999999999
    if a+b>2*c:
        if x > y:
            ans1=2*c*y+a*(x-y)
        elif y > x:
            ans1=2*c*x+b*(y-x)
    ans2=c*2*max(x,y)
    ans3=a*x+b*y
    print(min(ans1,ans2,ans3))

if __name__=="__main__":
    main()

Measured memory_bytes: 9160
package main

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

func main() {
	protagonist(os.Stdin, os.Stdout)
}

func protagonist(r basicIO.Reader, w basicIO.Writer) {
	io := NewIO(r, w)
	str := io.nextString()

	l := len(str)
	acc := 0
	for i := 0; i < l/2; i++ {
		if str[i] != str[l-1-i] {
			acc++
		}
	}
	io.PutInt(acc)
}

type IO struct {
	Scanner *bufio.Scanner
	Writer  basicIO.Writer
}

func NewIO(r basicIO.Reader, w basicIO.Writer) *IO {
	s := bufio.NewScanner(r)
	s.Split(bufio.ScanWords)
	return &IO{
		Scanner: s,
		Writer:  w,
	}
}

func (io *IO) nextString() string {
	io.Scanner.Scan()
	return io.Scanner.Text()
}

func (io *IO) nextInt() int {
	io.Scanner.Scan()
	i, _ := strconv.Atoi(io.Scanner.Text())
	return i
}

func (io *IO) PutInt(v int) {
	fmt.Fprintf(io.Writer, "%d\n", v)
}

func (io *IO) PutString(s string) {
	fmt.Fprintf(io.Writer, "%s\n", s)
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
#include <boost/multiprecision/cpp_dec_float.hpp>
#include <boost/multiprecision/cpp_int.hpp>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(), (x).end()
typedef long long ll;
namespace mp = boost::multiprecision;
using Mint = mp::cpp_int;

int main() {
	int a, b;
	cin >> a >> b;

	string sa;
	string sb;
	rep(i, b) sa += to_string(a);
	rep(i, a) sb += to_string(b);

	cout << min(sa, sb) << endl;
}

Measured memory_bytes: 256
import scala.io.StdIn.readLine
import scala.collection.mutable.Queue

object Main extends App {
  val l = readLine.split(" ").map(_.toInt)
  val q = new Queue[(String,Int)]

  for(i<-0 until l(0)) {
    val m = readLine.split(" ")
    q += ((m(0), m(1).toInt))
  }

  def rrobin(total:Int):Unit = {
    if(q.isEmpty) return
    else {
      val (p,t) = q.dequeue
      val newTotal =
        if(t>l(1)) {
          q += ((p,t-l(1)))
          total + l(1)
        } else {
          println(p + " " + (t+total))
          total + t
        }
      rrobin(newTotal)
    }
  }

  rrobin(0)
}

Measured memory_bytes: 105256
#include <iostream>
#include "bits/stdc++.h"
using namespace std;
#define print(x) cout<<x<<endl;
#define rep(i,a,b) for(int i=a;i<b;i++)
#define REP(i,a) for(int i=0;i<a;i++)
#define jkl int debug = 0;
#define RREP(i,a) for(int i=a-1;i>=0;i--)
#define rrep(i,a,b) for(int i=a-1;i>=b;i--)
#define printall(n,array) {for(int i=0;i<n;i++){cout<<array[i]<<" ";}cout<<endl;}
#define U() cout<<endl;
typedef long long ll;
typedef pair<int, int> Pi;
typedef pair<int, Pi> V;
typedef vector<ll> VE;
const ll mod = 1e9 + 7; //10^9+7


int main(){
    ll n;
    ll a[200002];
    cin >> n;
    REP(i, n)cin >> a[i];
    VE ans;
    for(ll q = n - 1; q >= 0; q -= 2)ans.push_back(a[q]);
    for(ll q = n % 2 ? q = 1 : q = 0; q < n; q += 2)ans.push_back(a[q]);
    REP(i, ans.size() - 1)cout << ans[i] << " ";
    cout << ans[ans.size() - 1];
}

Measured memory_bytes: 5360
#include <bits/stdc++.h>
#define rep(i, start, end) for (long long i = start; i < end; ++i)
#define srt(x) sort((x).begin(), (x).end());
#define rsrt(x) sort((x).rbegin(), (x).rend());
#define deb(x) cout<<#x<<" = "<<(x)<<" (L"<<LINE<<")"<<endl;
#define vdeb(x) {cout<<#x<<" = { "; rep(i, x.size()) cout<<x[i]<<' '; cout <<'}'<<" (L"<<LINE<<")"<<endl;}
using namespace std;
using ll = long long;
using vi = vector<int>;
using vivi = vector<vi>;
using vll = vector<long long>;
using vllvll = vector<vll>;
using vs = vector<string>;
using um = unordered_map<long long, long long>;

int main()
{
    ll N, K;
    ll d;
    cin >> N >> K;
    um dict;
    ll tmp;
    rep(i, 0, N) {
        dict[i] = 0;
    }
    rep(i, 0, K) {
        cin >> d;
        rep(j, 0, d) {
            cin >> tmp;
            dict[tmp-1] += 1;
        }
    }

    ll s = 0;
    rep(i, 0, N) {
        if (dict[i] == 0) {
            ++s;
        }
    }

    cout << s << endl;


}

Measured memory_bytes: 3632
#include<iostream>
using namespace std;
int l1,l2,r1,r2;
int main()
{
	cin>>l1>>l2>>r1>>r2;
	if(l1+l2>r1+r2)cout<<"Left"<<endl;
	else if(l1+l2==r1+r2)cout<<"Balanced"<<endl;
	else cout<<"Right"<<endl;
	return 0;
}

Measured memory_bytes: 256
def main():

	
	n = int(input())
	ans = 0
	if n < 100 and n >=10:
		print(9)
	elif n < 10:
		print(n)
	else:
		for i in range(100,n+1):
			if len(str(i)) % 2 != 0:
				ans += 1
		print(ans+9)

 
if __name__ == '__main__':
	main()

Measured memory_bytes: 39920
///   ***   ---   |||         In the name of ALLAH        |||   ---   ***   ///



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


typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vi> vvi;
typedef vector<vl> vvl;
typedef pair<int,int> pii;
typedef pair<double, double> pdd;
typedef pair<ll, ll> pll;
typedef vector<pii> vii;
typedef vector<pll> vll;
typedef double dl;

#define endl '\n'
#define PB push_back
#define F first
#define S second
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define sz(x) (int)x.size()

const double PI = acos(-1);
const double eps = 1e-9;
const int inf = 2000000000;
const ll infLL = 9000000000000000000;
#define MOD 1000000007

#define mem(a,b) memset(a, b, sizeof(a) )
#define sqr(a) ((a) * (a))

#define optimize() ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define fraction() cout.unsetf(ios::floatfield); cout.precision(10); cout.setf(ios::fixed,ios::floatfield);


#define dbg(args...) do {cerr << #args << " : "; faltu(args); } while(0)
void faltu () {            cerr << endl;}
template < typename T, typename ... hello>void faltu( T arg, const hello &... rest) {cerr << arg << ' ';faltu(rest...);}


int main()
{
    optimize();


    int a, b;
    cin >> a >> b;
    a += b;

    if ( a % 2 ) cout << "IMPOSSIBLE";
    else cout << a / 2;


    return 0;
}


















Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long
#define sort(a) sort(a.begin(), a.end())
#define loop(n) for(ll i = 0; i<n; i++)
using namespace std;

int main(){
    string a, b;
    cin>>a>>b;
    cout<<b<<a;
    return 0;
}

Measured memory_bytes: 256
S=input()
Count=0
N=len(S)
new_S= S[::-1]
if S[0:(N-1)//2]==new_S[(N+3)//2-1:N]:
  Count=0
else:
  Count=1

if Count==0:
  if S[0:(N-1)//2]==S[(N+3)//2-1:N]:
    Count=0
  else:
    Count=1
if Count==0:
  print("Yes")
else:
  print("No")

Measured memory_bytes: 3064
import java.util.Arrays;
import java.util.Scanner;

public class Main {

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

        int a=gi();
        int b=gi();
        int c=gi();
        int d=gi();
        
	    
	    
        //System.out.println((int)Math.ceil((double)h/(double)a));
        if (a+b>c+d) {
        	System.out.print("Left");
        }else if(a+b==c+d){
        	System.out.print("Balanced");
        }else {
        	System.out.print("Right");
        }


	}

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

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

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

Measured memory_bytes: 35664
#include<iostream>
#include<string>
using namespace std;
int main(){
	string s;
	int n = 0,sum=0;
	while(cin >>s){
		for(int i=0; i<=(int)s.size(); i++){
			if(isdigit(s[i])){n = n*10+s[i]-'0';}
			else{sum+=n;n = 0;}
		}
	}
	cout <<sum<<endl;
	return 0;
}

Measured memory_bytes: 0
import java.util.*;

import java.lang.*;

import java.math.*;



public class Main {

	Scanner sc = new Scanner(System.in);

	int dp[] = {0,1,2,3,4,5,6,7,8,9,5,4,3,2,1,0,1,2,3,4,5,6,7,8,9,5,4,3,2,1};

	void run(){

		int n = sc.nextInt();

		for(int i = 0; i < n ; i++){

			int start = sc.nextInt();

			int end = sc.nextInt();

			String ans1 = "";

			boolean trig1 = false;

			for(int j = 0; j < dp.length; j++){

				if(dp[j] == start){

					ans1 = "";

					trig1 = true;

				}

				if(trig1){

					ans1+=dp[j]+" ";

				}

				if(trig1&&dp[j] == end){

					trig1 = false;

					break;

				}

			}

			System.out.println(ans1.trim());

		}

	}

	public static void main(String[] args){

		Main m = new Main();

		m.run();

	}

}

Measured memory_bytes: 12000
// In the name of God
#include <iostream>
#include <cstdio>
#include <cmath>
#include <algorithm>
#include <set>
#include <map>
#include <queue>
#include <vector>
#include <iomanip>
#include <ctime>
#include <queue>
using namespace std;

template <typename T>
T next_int() {  
    T x = 0, p = 1;
    char ch;
    do { ch = getchar(); } while(ch <= ' ');
    if (ch == '-') {
        p = -1;
        ch = getchar();
    }
    while(ch >= '0' && ch <= '9') {
        x = x * 10 + (ch - '0');
        ch = getchar();
    }
    return x * p;
}

const int max_n = (int)2e5 + 227 + 1;
const int max_int = (int)1e9 + 227 + 1;
const int mod = (int)1e9 + 7;

int main() {
//    freopen(".in", "r", stdin);

    int n = next_int<int>();
    int m = next_int<int>();

    vector<string> a(n);
    for(int i = 0; i < n; i++) cin >> a[i];

    sort(a.begin(), a.end());

    string ans = "";

    for(int i = 0; i < n; i++) ans += a[i];

    cout << ans << "\n";
}


Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;


public class Main {


    public static void main(String[] args) throws IOException {

        BufferedReader br = new BufferedReader( new InputStreamReader(System.in));
        String input = br.readLine().toLowerCase();
        if (input.length() == 3) {
            if (input.matches("[ox]*")) {
                long count = input.chars().filter(ch -> ch == 'o').count();
                long price = 700;
                if (count > 0)
                    System.out.println(price + 100 * count);
                else
                  System.out.println(price);
            } else {
                System.out.println("Error!");
            }

        } else {
            System.out.println("Error!");
        }
    }
}

Measured memory_bytes: 27092
N = int(input())
A = [int(x) for x in input().split()]

def solve():
    B = [None] * N
    B[0] = sum(A[i] * (-1 if i%2==1 else 1) for i in range(N))
    for i in range(N-1, 0, -1):
        B[i] = 2 * A[i] - B[(i+1) % N]
    return B

print(*solve())

Measured memory_bytes: 65124
#include<iostream>
#include<vector>
#include<string>
using namespace std;
int main()
{
  string name,type,ans;
  string upper="ABCDEFGHIJKLMNOPQRSTUVWXYZ";
  string under="_";
  int start;
  while(cin>>name>>type,type!="X"){
    vector<string>word;
    vector<string>::iterator it;
    start=0;
    if(name.find("_")!=string::npos){
      for(int i=0;i<name.size();i++){
	if(under.find(name[i])!=string::npos){
	  word.push_back(name.substr(start,i-start));
	  start=i+1;
	}
      }
      word.push_back(name.substr(start,name.size()-start));
    }else{
      if(upper.find(name[0])!=string::npos)name[0]+='a'-'A';
      for(int i=0;i<name.size();i++){
	if(upper.find(name[i])!=string::npos){
	  name[i]+='a'-'A';
	  word.push_back(name.substr(start,i-start));
	  start=i;
	}
      }
      word.push_back(name.substr(start,name.size()-start));
    }
    ans="";
    for(it=word.begin();it!=word.end();it++){
      if(it==word.begin()){
	if(type=="U")(*it)[0]+='A'-'a';
	ans+=*it;
	continue;
      }
      if(type=="D")*it="_"+*it;
      else (*it)[0]+='A'-'a';
      ans+=*it;
    }
    cout<<ans<<endl;
  }
}

Measured memory_bytes: 0
N = int(input())

res = 0
bhogea = 0
bhoge = 0
hogea = 0

for i in range(N):
    s = input()
    res += s.count('AB')
    if s[0] == 'B' and s[-1:] == 'A':
        bhogea += 1
    elif s[0] == 'B':
        bhoge += 1
    elif s[-1:] == 'A':
        hogea += 1

res = res + max(0, bhogea - 1)

if bhogea != 0:
    if bhoge != 0:
        bhoge = bhoge - 1
        res += 1
    if hogea != 0:
        hogea = hogea - 1
        res += 1

res = res + min(bhoge, hogea)

print(res)






Measured memory_bytes: 44328
inpl = lambda: list(map(int,input().split()))
N = int(input())
a = inpl()
ans = []
c = []
l, r = 0, N-1
while l < r:
    if a[l] <= 0:
        c.append((0,l))
        l += 1
        continue
    elif a[r] >= 0:
        c.append((1,r))
        r -= 1
        continue
    elif a[l] + a[r] <= 0:
        c.append((0,l))
        ans.append((r+1, l+1))
        l += 1
    else:
        c.append((1,r))
        ans.append((l+1, r+1))
        r -= 1

for s, b in c[::-1]:
    if s == 0:
        ans.append((b+2, b+1))
    else:
        ans.append((b, b+1))

print(len(ans))
for x, y in ans:
    print(x, y)

Measured memory_bytes: 38384
#include<iostream>
#include<vector>
#include<algorithm>
#include<map>
#include<cstring>
#include<math.h>
#include<bitset>
#include<queue>
#include<set>
#include<iomanip>
#include<math.h>
#include<assert.h>
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
constexpr long long int INFLL = 1LL << 60;
constexpr int INF = 1000000007;
const int mod = 1000000007;
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
template<class T> inline bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template<class T> inline bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}

int N,M;
vector<vector<int>> G;
int dp[100100];

int rec(int v){
  if(dp[v] != -1){
    return dp[v];
  }
  int res=0;
  for(int nv: G[v]){
    chmax(res, rec(nv)+1);
  }
  return dp[v] = res;
}

int main(){
  cin >> N >> M;
  G.assign(N,vector<int>());
  for(int i=0; i<M; i++){
    int x,y;
    cin >> x >> y;
    x--;
    y--;
    G[x].push_back(y);
  }
  for(int i=0; i<N; i++){
    dp[i] = -1;
  }
  int res=0;
  for(int i=0; i<N; i++){
    chmax(res, rec(i));
  }
  cout << res << endl;
  return 0;
}


Measured memory_bytes: 8192
#include "bits/stdc++.h"
#define rep(i,b) for(ll i=0;i<b;i++)
#define ll long long
using namespace std;
/*--Input//////////////////////////////////////////////////*/
inline void IN(void){return;}
template <typename First, typename... Rest>
void IN(First& first, Rest&... rest){cin >> first;IN(rest...);return;}
#define SS(T, ...)      T __VA_ARGS__; IN(__VA_ARGS__);
#define SV(type,c,n) vector<type> c(n);for(auto& i:c)cin >> i;
/*--Output/////////////////////////////////////////////////*/
inline int p(void){cout << endl; return 0;}
template<class Head> int p(Head&& head){cout << head;p();return 0;} template<class Head,class... Tail> int p(Head&& head,Tail&&... tail){cout<<head<<" ";p(forward<Tail>(tail)...);return 0;}
struct ProconInit {
    static constexpr bool AUTOFLUSH = false;
    ProconInit() {
        cin.tie(nullptr);
        ios::sync_with_stdio(false);
        cout << fixed << setprecision(15);
        if(AUTOFLUSH)
            cout << unitbuf;
    }
} PROCON_INIT;

#define YES(n) cout << ((n) ? "YES" : "NO"  ) << endl
#define Yes(n) cout << ((n) ? "Yes" : "No"  ) << endl
#define vl vector<ll>
#define debug(x) cerr<<#x<<" "<<x<<'\n';
#define all(x) (x).begin(),(x).end()
#define bit(n) (1LL<<(n))
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
bool cmp(pair<ll,ll> a, pair<ll,ll> b) { return a.first+a.second > b.first+b.second; }

signed main() {
  SS(ll,a,b,c,k)
  if(a>=k){
    p(k);
  }else{
    k-=a;
    if(b>=k){
      p(a);
    }else{
      k-=b;
      p(a-k);
    }
  }
}

Measured memory_bytes: 3648
#include<bits/stdc++.h>
#pragma GCC target("avx2")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
#define rep(i, x) for(ll i = 0; i < x; i++)
#define rep2(i, x) for(ll i = 1; i <= x; i++)
#define all(a) (a).begin(),(a).end()
using ll = long long;
using ld = long double;
using namespace std;
const ll INF = 1000000000000000000;
const ll mod = 1000000007;
const ld pi = 3.141592653589793238;

ll par[2134567];//親
ll depth[2134567];//木の深さ
//n要素で初期化
void init(ll n) {
	for (int i = 0; i <= n; i++) {
		par[i] = i;
		depth[i] = 0;
	}
}
//木の根を求める
ll find(ll x) {
	if (par[x] == x) {
		return x;
	}
	else {
		return par[x] = find(par[x]);
	}
}
//xとyの属する集合を併合
void unite(ll x, ll y) {
	x = find(x); y = find(y);
	if (x == y) { return; }
	if (depth[x] < depth[y]) {
		par[x] = y;
	}
	else {
		par[y] = x;
		if (depth[x] == depth[y])depth[x]++;
	}
}
//xとyが同じ集合に属するか否か
bool same(ll x, ll y) {
	return find(x) == find(y);
}

signed main() {
	ios::sync_with_stdio(false);
	std::cin.tie(nullptr);
	
	ll n, q; cin >> n >> q; init(n + 2);
	rep(i, q) {
		ll a, b, c; cin >> a >> b >> c;
		if (a == 0) { unite(b, c); }
		else {
			if (same(b, c)) { cout << 1 << endl; }
			else { cout << 0 << endl; }
		}
	}
	return 0;
}

Measured memory_bytes: 6604
#include <iostream>
#include <functional>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <climits>

using namespace std;
typedef long long int ll;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
#define MOD = 1000000007;
#define INF (1e9)
#define print(x) cout << x << endl;

ll gcd(ll a, ll b) { return b ? gcd(b,a%b) : a;}
ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }
typedef pair <ll,ll> P;


int main()
{
    ll a, b;
    cin >> a >> b;
    if (a*b % 2 == 0) {
        print("Even");
    } else print("Odd");
    return 0;
}


Measured memory_bytes: 256
def getN():
    return int(input())
def getNM():
    return map(int, input().split())
def getList():
    return list(map(int, input().split()))
from bisect import bisect_right

n = getN()
mx = []
k = 0
for i in range(n):
    num = -(getN())
    ins = bisect_right(mx, num)
    if ins == k:
        mx.append(num)
        k += 1
    else:
        mx[ins] = num
    # print(ins, mx)

print(len(mx))

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

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
const int INF = (1<<30) - 1;
const ll LINF = (1LL<<60) - 1;
const int mod = 1e9 + 7;

int main(){
    char a;
    cin >> a;
    if ('a' <= a && a <= 'z') cout << 'a' << endl;
    else cout << 'A' << endl;
}

Measured memory_bytes: 3592