akhauriyash/Code-Regression huggingface dataset:
while True:
  n=int(input())
  x=[0 for i in range(10)]
  if n==0:
    break
  for i in range(n):
    a=int(input())
    if a==0:
      x[0]+=1
    elif a==1:
      x[1]+=1
    elif a==2:
      x[2]+=1
    elif a==3:
      x[3]+=1
    elif a==4:
      x[4]+=1
    elif a==5:
      x[5]+=1 
    elif a==6:
      x[6]+=1
    elif a==7:
      x[7]+=1
    elif a==8:
      x[8]+=1
    else:
      x[9]+=1
  for i in range(10):
    if x[i]==0:
      print('{}'.format('-')) 
    else:
      print('{}'.format(x[i]*'*'))


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



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

  int k;
  int a, b;

  cin >> k;

  a = b = k / 2;
  if(k % 2 == 1){
    a++;
  }

  cout << a * b << endl;

  return 0;
}



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

using namespace std;
typedef long long ll;

int main(){
    string s;
    cin >> s;
    int n = s.length();
    int ans = 10000;
    for(int i=0;i<26;i++){
        int interval = 0;
        int max_interval = 0;
        for(int j=0;j<n;j++){
            if(s[n-1-j]==(char)(i+97)){
                max_interval = max(interval,max_interval);
                interval = 0;
            }else{
                interval += 1;
            }

        }
        max_interval = max(interval,max_interval);
        ans = min(max_interval,ans);
    }
    cout << ans << "\n";

}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
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; }
const ll mod=1e9+7;
const ll inf=1ll<<60;

/* */

int main(){

    // 入力スタンダード（複数指定）
    int n;
    cin >> n;
    
    // **************************************
    int a[n], b[n], c[n];
    ll ah[n], bh[n], ch[n];
    for(int i=0; i<n; i++){
        cin >> a[i] >> b[i] >> c[i];
        //ah[i] = 0;
        //bh[i] = 0;
        //ch[i] = 0;
    } 
    // **************************************
    
    ah[0]=a[0];
    bh[0]=b[0];
    ch[0]=c[0];
    for(int i=1; i<n; i++){
        ah[i]=a[i]+max(bh[i-1], ch[i-1]);
        bh[i]=b[i]+max(ch[i-1], ah[i-1]);
        ch[i]=c[i]+max(ah[i-1], bh[i-1]);


        /*
        ah[i]=max(a[i]+bh[i-1], a[i]+ch[i-1]);
        bh[i]=max(b[i]+ch[i-1], b[i]+ah[i-1]);
        ch[i]=max(c[i]+ah[i-1], c[i]+bh[i-1]);
        */        
    }

    cout << max(ah[n-1],max(bh[n-1], ch[n-1])) << endl;
    
    return 0;
}

Measured memory_bytes: 3840
#include <bits/stdc++.h>
#include<cmath>
#define N 100005
#define A 1000005
#define MOD 998244353 //1000000007 // //100000000
#define INF 1000000000000000000
#define ll long long
//#define M_PI 3.141592653589793238463

using namespace std;

#define pii pair<ll, ll>
#define piii pair<ll, pii>
#define ft first
#define sd second
#define pb push_back
#define rep(i, n) for(ll i = 0; i < n; i++)
#define repr(i, n) for(ll i = n-1; i >= 0; i--)
#define itr(it, x) for(auto it = x.begin(); it != x.end(); it++)
#define mem(a, b) memset(a, (ll)b, sizeof(a))
#define all(v) v.begin(), v.end()
#define allr(v) v.rbegin(), v.rend()
#define edge(v, x, y) v[x].pb(y); v[y].pb(x);
#define popcount __builtin_popcount
#define ANS(s) {cout << s << "\n"; return;}

//~~~~~~fancy print~~~~~~~//
#define printpii(a) cout << a.ft << " " << a.sd << endl;
#define printpiii(a) cout << a.ft << " " << a.sd.ft << " " << a.sd.sd << endl;
#define print(a, n) rep(i, n) cout << a[i] << " "; cout << endl;
#define printv(v) for(auto x: v)cout << x << " "; cout << endl;
#define printm(a, n, m) rep(i, n) { rep(j, m) cout << a[i][j] << "\t"; cout << endl;}

ll dx[4] = {0, 0, 1, -1};
ll dy[4] = {1, -1, 0, 0};

void fast(){ios_base::sync_with_stdio(false);cin.tie(0);cout << setprecision(12) << fixed;}


void solve(){
    ll g=  0, n ;
    cin >> n;
    ll a[n];
    rep(i, n)
    {
        ll x; cin >> x;
        g = __gcd(g, x);
    }
    ll k = 0;
    while(g%2 == 0){
        g /= 2;
        k++;
    }
    cout << k; 
}
main(){
    fast();
    ll t = 1; //cin >> t;
    while(t--){
        solve();
    }
}


Measured memory_bytes: 256
<?php
$input = preg_split('/[\s,]+/', trim(fgets(STDIN)));
$a = $input[0];
$b = $input[1];
if($a == $b){
	echo "Draw\n";
}else if($b == 1){
echo "Bob\n";
}else if($a > $b || $a == 1){
	echo "Alice\n";
}else echo "Bob\n";
?>

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

const char* kWeather[] = {"Sunny", "Cloudy", "Rainy"};

int main() {
  string s;
  cin >> s;
  switch (s[0]) {
  case 'S': cout << "Cloudy\n"; return 0;
  case 'C': cout << "Rainy\n"; return 0;
  case 'R': cout << "Sunny\n"; return 0;
  }
  return 0;
}



Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <cmath>
#include <map>
#include <queue>
#include <iomanip>
#include <set>
#define MOD 1000000007
#define mkp make_pair
typedef long long ll;
using namespace std;

#define mod 2019

int main(){
  ll L,R;
  cin>>L>>R;

  ll ans=2018;
  for(ll i=L;i<=min(R,L+mod);i++){
    for(ll j=i+1;j<=min(R,L+mod);j++){
      ans=min(ans,(i*j)%mod);
    }
  }

  cout<<ans<<endl;



  return 0;
}


Measured memory_bytes: 256
function main(input) {
  const nums = input.split(" ")
  const age = parseInt(nums[0], 10)
  const B = parseInt(nums[1], 10)
  
  if (age >= 13) {
	console.log(B) 
  } else if (age >= 6) {
    console.log(B / 2)
  } else {
	console.log(0)
  }
  
}
 
main(require("fs").readFileSync("/dev/stdin", "utf8"))

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

#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define all(x) (x).begin(),(x).end()
using ll = long long;
string char_to_string(char val) {
    return string(1, val);
}

int main(){
    int X, Y, Z; cin >> X >> Y >> Z;

    cout << Z << " " << X << " " << Y << endl;
}

Measured memory_bytes: 256
package main


import "fmt"
func main(){
    nums := scanNums(2)
    x := nums[0]
    y := nums[1]

    fmt.Printf("%d\n", x + y/2)
}



/**
 * １行に空白区切りで数字を読み込み
 */
func scanNums(len int) (nums []int) {
	nums = make([]int, len)
	for i := 0; i < len; i++ {
		fmt.Scan(&nums[i])
	}
	return
}


Measured memory_bytes: 512
#include<iostream>
#include<algorithm>
#include<math.h>
#include<cstring>
#include<queue>
#include<vector>
#include<map>
#include<set>
#include<deque>
using namespace std;
long long int x[2001];
long long int MOD = 1000000007;
int main() {


	//D
	long long int s;
	
	cin >> s;

	int i, j;
	x[0] = 0; x[1] = 0; x[2] = 0; x[3] = 1; x[4] = 1; x[5] = 1;
	for (i = 6; i < 2001; i++) {
		for (j = 3; j < i; j++) {
			x[i] = (x[i] + x[i- j]) % MOD;
		}
		x[i] = (x[i] + 1) % MOD;
	}
	cout << x[s] << endl;
	return 0;

	//C
	/*long long int n;
	long long int MOD = 1000000007;
	cin >> n;
	int i;
	long long int a, b, c;
	a = 1; b = 2; c = 1;
	for (i = 0; i < n; i++) {
		a = a * 10; b = b * 9; c = c * 8;
		a = a % MOD; b = b % MOD; c = c % MOD;
	}
	a = (a - b + MOD) % MOD;
	a = (a + c) % MOD;
	cout << a << endl;
	return 0;*/

	//B
	/*long long int a, b, c, d;
	cin >> a >> b >> c >> d;

	long long int x[4];
	x[0] = a * c;
	x[1] = a * d;
	x[2] = b * c;
	x[3] = b * d;
	sort(x, x + 4);
	
	
	cout << x[3] << endl;

	return 0;*/
	

	//A
	/*int x;
	cin >> x;
	if (x == 1) {
		cout << 0;
	}
	else {
		cout << 1;
	}
	cout << endl;
	return 0;
	*/

}

Measured memory_bytes: 3624
#include<bits/stdc++.h>
using namespace std;
const int N = 1e5+100;
typedef long long ll;
#define fr(i,a,b) for(int i = a;i <= b; ++i)
#define nfr(i,a,b) for(int i = a;i >= b; --i)

int ish[N],prime[N],pcnt;

inline void Sieve(){
   pcnt = 0;
   fr(i,2,N-1){
      if(!ish[i])prime[++pcnt] = i;
      for(int j = 1;j <= pcnt && prime[j]*i < N; ++j){
         ish[i*prime[j]] = 1;
         if(i%prime[j] == 0)break;
      }
   }
}
map<ll,int> m1;
ll n;
ll ans;

inline void solve(ll a,ll b){
   if(a < b)swap(a,b);
   for(ll w = a;w <= ans;w += a){
      if((w-1)%b == 0){
         ans = min(ans,w-1); return ;
      }
      if((w+1)%b == 0){
         ans = min(ans,w); return ;
      }
   }
}

ll wn;
inline void check_sqr(){
   ll L = 2,R = (int)1e8;
   while(L < R){
      ll mid = (L+R)/2;
      if(mid*mid == wn){
         wn = 1; m1[mid] += 2; return ;
      } else if(mid*mid < wn)L = mid+1;
      else R = mid;
   }
}

pair<ll,int> p1[21];

int main(){
   Sieve();
   scanf("%lld",&n);
   n *= 2;
   wn = n;
   ans = n-1;
   fr(i,1,pcnt){
      while(wn%prime[i] == 0){
         wn /= prime[i]; ++m1[prime[i]];
      }
   }
   check_sqr();
   if(wn > 1)++m1[wn];

   int sz = m1.size(),cnt = 0;
   for(map<ll,int>::iterator i = m1.begin();i != m1.end(); ++i){
      p1[cnt++] = *i;
   }

   fr(i,0,(1<<sz)-1){
      ll w1,w2;
      w1 = w2 = 1;
      fr(j,0,cnt-1){
         if((i >> j)&1){
            fr(z,1,p1[j].second)w1 *= p1[j].first;
         } else {
            fr(z,1,p1[j].second)w2 *= p1[j].first;
         }
      }
      solve(w1,w2);
   }

   printf("%lld\n",ans);
}


Measured memory_bytes: 4268
import qualified Data.ByteString.Char8 as BS
import Data.Maybe

readString = map BS.unpack . BS.words

getString = readString <$> BS.getLine

check :: String -> String -> String
check [] as = as
check (s : ss) as = check ss as'
  where
    as'
      | s `elem` as = as
      | otherwise = s : as

main = do
  [s] <- getString
  let setS = check s ""
  let lenS = length (setS)
  let result
        | odd lenS = "No"
        | lenS == 4 = "Yes"
        | or [and ['N' `elem` setS, 'S' `elem` setS], and ['W' `elem` setS, 'E' `elem` setS]] = "Yes"
        | otherwise = "No"
  putStrLn result


Measured memory_bytes: 508
import copy
n=int(input())
A=[int(input()) for _ in range(n)]
A_=copy.deepcopy(A)
A_.sort()
MA=A_[-1]
mA=A_[-2]
for i in range(n):
    if A[i]<MA:
        print(MA)
    else:
        print(mA)

Measured memory_bytes: 14596
#include <cstdio>
#include <unordered_map>
using namespace std;
const int N=200010;
int n;
int a[N];
unordered_map<int,int> f;
inline void updmax(int &x,int y){
	x=(x>=y)?x:y;
}
void readData(){
	scanf("%d",&n);
	for(int i=1;i<=n;i++) scanf("%d",&a[i]);
}
void solve(){
	int ans=0;
	for(int i=n;i>=1;i--){
		int g=f[a[i]+1]+1;
		f[a[i]]=g;
		updmax(ans,g);
	}
	printf("%d\n",n-ans);
}
int main(){
	readData();
	solve();
	return 0;
}


Measured memory_bytes: 9288
//#pragma GCC optimize ("Ofast")
//#pragma GCC optimize ("unroll-loops")
//#pragma GCC target("avx,avx2,fma")

#include <bits/stdc++.h>
#include<ext/pb_ds/tree_policy.hpp>
#include<ext/pb_ds/assoc_container.hpp>

#define ios ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define file(s) if (fopen(s".in", "r")) freopen(s".in", "r", stdin), freopen(s".out", "w", stdout)
#define all(a) a.begin() , a.end()
#define fi first
#define se second

using namespace std;
using ll = long long;
using namespace __gnu_pbds;


template<typename T> using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

const int N = 3e5 + 10 , inf = 2e9 + 7;
const ll INF = 1e18 , mod = 1e9+7;

void solve() {
    int a,  b , c , k;
    cin >> a >> b >> c >> k;
    int cnt = 0;
    while(b <= a) {
        cnt ++;
        b *= 2;
    }
    while(c <= b) {
        cnt ++;
        c *= 2;
    }
    if(cnt <= k) {
        cout << "Yes";
    }
    else {
        cout << "No";
    }

}
/*
*/
main() {
    ios;
    int tt = 1;
   // cin >> tt;
    while(tt --) {
        solve();
    }
    return 0;
}


Measured memory_bytes: 3648
#include <bits/stdc++.h>  // ver2.3.1
#define int long long
#define endl "\n"
#define ALL(v) (v).begin(),(v).end()
#define COUNT(a,k) upper_bound(ALL(a),k)-lower_bound(ALL(a),k)
#define BIGGER(a,k) a.end()-upper_bound(ALL(a),k)
#define SMALLER(a,k) lower_bound(ALL(a),k)-a.begin()
#define Vi vector<int>
#define VVi vector<Vi>
#define Vs vector<string>
#define Pii pair<int,int>
#define VPii vector<Pii>
#define Tiii tuple<int,int,int>
#define PQi priority_queue<int>
#define PQir priority_queue<int,vector<int>,greater<int>>
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define itos to_string
#define stoi stoll
#define FI first
#define SE second
#define cYES cout<<"YES"<<endl
#define cNO cout<<"NO"<<endl
#define cYes cout<<"Yes"<<endl
#define cNo cout<<"No"<<endl
#define cyes cout<<"yes"<<endl
#define cno cout<<"no"<<endl
#define _ <<' '<<
#define sortr(v) sort(v,greater<>())
#define rep(i,a,b) for(int i=a;i<b;i++)
#define repeq(i,a,b) for(int i=a;i<=b;i++)
#define repreq(i,a,b) for(int i=a;i>=b;i--)
#define leng(n) (int)(log10(n)+1)
#define dem(a,b) ((a+b-1)/(b))
#define Vin(a) rep(iI,0,a.size())cin>>a[iI]
#define Vout(a) rep(lZ,0,a.size()-1)cout<<a[lZ]<<' ';cout<<a.back()<<endl
#define VVout(a) rep(lY,0,a.size()){if(!a[lY].empty()){Vout(a[lY]);}else cout<<endl;}
#define VPout(a) rep(lX,0,a.size())cout<<a[lX].FI<<' '<<a[lX].SE<<endl
#define Verr(a) rep(iZ,0,a.size()-1)cerr<<a[iZ]<<' ';cerr<<a.back()<<endl
#define VVerr(a) rep(J,0,a.size()){if(!a[J].empty()){Verr(a[J]);}else cerr<<'.'<<endl;}
#define VPerr(a) rep(iX,0,a.size())cerr<<a[iX].FI<<' '<<a[iX].SE<<endl
#define INF 3000000000000000000  //  3.0*10^18(MAXの1/3くらい)
#define MAX LLONG_MAX
#define PI 3.141592653589793238462
#define MOD 1000000007  //  10^9 + 7
using namespace std;

int gcd(int a,int b){return b?gcd(b,a%b):a;}  //  最大公約数gcd
int lcm(int a,int b){return a/gcd(a,b)*b;}  //  最小公倍数lcm
int mypow(int x, int n, int m){  //  累乗x^n(mod m)  O(log(n))
if(n==0)return 1;if(n%2==0)return mypow(x*x%m,n/2,m);else return x*mypow(x,n-1,m)%m;}
int scomb(int n, int r){if((n-r)<r)r=n-r;  //  nCr (小さい場合)
int a=1;for(int i=n;i>n-r;--i){a=a*i;}for(int i=1;i<r+1;++i){a=a/i;}return a;}
int comb(int n, int r){if((n-r)<r)r=n-r;  //  nCr (%MOD)
int a=1;for(int i=n;i>n-r;--i){a=a*i%MOD;}for(int i=1;
i<r+1;++i){a=a*mypow(i,MOD-2,MOD)%MOD;}return a%MOD;}
int stpow(int n){  //  階乗(%MOD)
if(n==0)return 1;int a=1;rep(i,1,n+1)a=a*i%MOD;return a;}
Vi stpowV(){Vi a(100001);  //  階乗配列(%MOD)
a[0]=1;repeq(i,1,100000)a[i]=a[i-1]*i%MOD;return a;}
void press(auto &v){v.erase(unique(ALL(v)),v.end());}  //  圧縮



signed main() {
  cin.tie(0);cout.tie(0);ios::sync_with_stdio(false);cout<<fixed<<setprecision(12);
  int n;
  cin >> n;
  string s;
  cin >> s;
  
  rep(i,0,s.size()){
    if(s[i]+n <= 'Z') s[i] = s[i]+n;
    else s[i] = s[i]+n-26;
  }
  cout << s << endl;
  return 0;
}

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

int main(){
    int n;
    cin >> n;

    vector<int> button(n);
    for(int i = 0; i < n; i++){
        cin >> button[i];
    }

    int index = 0;
    int cnt = 0;
    while(true){
        if(index == 1){
            break;
        }
        int tmp = button[index];
        button[index] = 0;
        index = tmp - 1;
        if(index == -1){
            cnt = index;
            break;
        }
        cnt++;
    }

    cout << cnt << endl;

    return 0;
}

Measured memory_bytes: 640
//#pragma GCC optimize ('O3')
#include <bits/stdc++.h>
using namespace std;

typedef long long ll;
typedef pair<ll,ll> pll;
typedef long double ld;
#define mp make_pair
#define f first
#define s second
#define pb push_back

const int N = 5000 + 5;
const int M = 5e5 + 5;
const int OO = 1e9;
const int mod = 1e9 + 7;

int d,g,p[10],c[10],ans=OO;

bool isOn(int bit, int mask) {

    return (1<<bit)&mask;

}

int main() {

    ios_base::sync_with_stdio(false);
    cin.tie(0);

    cin >> d >> g;

    for (int i = 0; i < d; ++i) {
        cin >> p[i] >> c[i];
    }

    for (int mask = 0; mask < (1<<d); ++mask) {

        int cur = 0, cnt = 0;

        for (int bit = 0; bit < d; ++bit) {

            if(isOn(bit,mask)) {

                cnt += p[bit];
                cur += 100*(bit+1)*p[bit] + c[bit];

            }

        }

        for (int bit = d - 1; ~bit ; --bit) {

            if(!isOn(bit,mask)) {

                for (int i = 0; i < p[bit] && cur < g; ++i) {

                    cur += 100*(bit+1);
                    ++cnt;

                }

            }

        }

        ans = min(ans, cnt);

    }

    cout << ans << '\n';

    return 0;
}

Measured memory_bytes: 3648
#include <iostream>
#include <vector>
#include <algorithm>
#include <utility>
#include <string>
#include <queue>
#include <stack>

using namespace std;

typedef long long int ll;
typedef pair<int, int> Pii;

const ll mod = 1000000007;

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

  int n, k;
  cin >> n >> k;
  vector<int> l(n);
  for (auto &x: l) cin >> x;

  sort(l.rbegin(), l.rend());

  int ans = 0;
  for (int i = 0; i < k; i++) ans += l[i];

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 256
n = int(input())
G = [list(map(int, input().split())) for _ in range(n)]

color = ['White']*n
d = [10**6]*n # 移動コスト
d[0] = 0 # 0にはコストゼロ
p = [-1]*n # 親ノード
p[0] = -1 # 0には親なし

def prim():
    while True:
        mincost = 10**6
        u = -1
        # 最小コストを選ぶ
        for i in range(n):
            if color[i] != 'Black' and d[i] < mincost:
                mincost = d[i]
                u = i

        # 道がない
        if mincost == 10**6:
            break

        color[u] = 'Black'

        # 未訪問かつ道があるならコスト表を更新
        for v in range(n):
            if color[v] != 'Black' and G[u][v] != -1:
                if G[u][v] < d[v]:
                    d[v] = G[u][v]
                    p[v] = u
                    color[v] = 'Gray'
    return d

print(sum(prim()))


Measured memory_bytes: 5896
var
  i,a,b:longint;
begin
  read(a,b);
  if a>b then
    begin
      i:=a;
      a:=b;
       b:=i;
    end;
  for i:=a to b do
    if (a*b*i) mod 2=1 then
      begin
        write('Yes');
        exit;
      end;
  write('No');
end.

Measured memory_bytes: 128
#include<stdio.h>
using namespace std;

int main(){

    int a, b;
    int d, r;
    double c;

    scanf("%d %d", &a, &b);

    d = a/b;
    r = a%b;
    c = (double)a/b;

    printf("%d %d %.5f", d, r, c);
    
    return 0;
}


Measured memory_bytes: 2740
#include <iostream>
#include <algorithm>

using namespace std;

int main()
{
	int num[3], d;
	bool flag = true;
	int a, c;
	
	cin >> num[0] >> num[1] >> num[2] >> d;
	
	a = num[0];
	c = num[2];
	
	sort(num, num + 3);
	
	for (int i = 2; i > 0; i--) {
		if (num[i] - num[i-1] > d) {
			flag = false;
			break;
		}
	}
	
	
	if (max(a, c) - min(a, c) <= d) {
		flag = true;
	}
	
	if (flag == true) {
		cout << "Yes" << endl;
	}
	else {
		cout << "No" << endl;
	}
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define int long long
using namespace std;
const int MOD=(int)1e9+7;
int ten_mod[100009];
vector<vector<int>>dp(100009,vector<int>(15,-1));
int func(string &s,int index,int n,int mod)
{
    if(index==n){
        if(mod==5)  return 1;
        else        return 0;
    }
    int ans=0;
    if(dp[index][mod]!=-1)
        return dp[index][mod];
    if(s[index]!='?'){
        int effective=(s[index]-'0')*ten_mod[index];
        effective%=13;
        ans+=func(s,index+1,n,(effective+mod)%13);
        ans%=MOD;
    }else{
        for(int i=0;i<=9;i++){
            int effective=i*ten_mod[index];
            effective%=13;
            ans+=func(s,index+1,n,(effective+mod)%13);
            ans%=MOD;
        }
    }
    return dp[index][mod]=ans;
}
main()
{
    string s;
    cin>>s;
    reverse(s.begin(),s.end());
    int temp=1;
    for(int i=0;i<100009;i++){
        ten_mod[i]=temp%13;
        temp%=13;
        temp*=10;
    }
    // for(int i=0;i<15;i++)
    //     cout<<ten_mod[i]<<" "<<(int)pow(10,i)%13<<"\n";
    cout<<func(s,0,s.size(),0);
}

Measured memory_bytes: 23936
#include <bits/stdc++.h>
using namespace std;
#define MAX 10000

void count_sort(int A[],int n){
    int i,k;
    int B[n],C[MAX+1]={0};
    for(i=0;i<n;i++){
        C[A[i]]++;
    }
    k=0;
    for(i=0;i<MAX+1;i++){
        if(C[i]>0){
            C[i]+=k;
            k=C[i];
        }
    }
    for(i=n-1;i>=0;i--){
        B[C[A[i]]-1]=A[i];
        C[A[i]]--;
    }
    for(i=0;i<n;i++)A[i]=B[i];
    
}

int main(){
    int n,i;
    scanf("%d",&n);
    int A[n];
    for(i=0;i<n;i++){
        scanf("%d",&A[i]);
    }
    count_sort(A,n);
    for(i=0;i<n;i++){
        if(i!=0)printf(" ");
        printf("%d",A[i]);
    }
    printf("\n");
}




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

int main(){
    int N, Q;
    cin >> N;
    ll sum = 0;
    vector<int> A(100005);
    for(int i = 0; i < N; i++){
        int a;
        cin >> a;
        A[a]++;
        sum += a;
    }
    cin >> Q;
    for(int i = 0; i < Q; i++){
        ll b, c;
        cin >> b >> c;
        sum -= A[b]*b;
        sum += A[b]*c;
        A[c] += A[b];
        A[b] = 0;
        cout << sum << endl;
    }
}

Measured memory_bytes: 3716
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <cmath>
#include <queue>
#include <stack>
#include <cstdlib>
#include <map>
#include <iomanip>
#include <set>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
#define int long long
#define pie 3.141592653589793238462643383279
#define mod 1000000007
#define INF 1145141919364364
#define all(vec) vec.begin(),vec.end()
#define P pair<int,int>
#define S second
#define F first
int gcd(int x, int y) {
	if (y == 0)return x;
	return gcd(y, x%y);
}
int lcm(int x, int y) {
	return x / gcd(x, y)*y;
}
bool prime(int x) {
	for (int i = 2; i <= sqrt(x); i++) {
		if (x%i == 0)return false;
	}
	return true;
}

int kai(int x) {
	if (x == 1)return 1;
	return kai(x - 1)*x%mod;
}

int mod_pow(int x, int y, int moder) {
	int res = 1;
	while (y > 0) {
		if (y & 1)res = res * x%moder;
		x = x * x%moder;
		y >>= 1;
	}
	return res;
}

int comb(int x, int y) {
	if (y > x)return 0;
	if (x == y)return 1;
	return kai(x)* mod_pow(kai(x - y), mod - 2, mod) % mod * mod_pow(kai(y), mod - 2, mod) % mod;
}

int n, d;

signed main() {
	cin >> n >> d;
	d = 2 * d + 1;
	if (n%d)cout << n / d + 1 << endl;
	else cout << n / d << endl;
}

Measured memory_bytes: 256
def main():
  n = int(input())
  words = []
  scores = []
  for _ in range(n):
    word, score = input().split()
    words.append(word)
    scores.append(int(score))
  mp = ["#" * 6] + ["#" + input() + "#" for _ in range(4)] + ["#" * 6]
  t = int(input())
  
  def search(word):
    used = [[False] * 6 for _ in range(6)]
    vec = ((1, 0), (1, -1), (0, -1), (-1, -1), (-1, 0), (-1, 1), (0, 1), (1, 1))
    
    def _search(word, pos, x, y):
      if pos == len(word) - 1:return 1
      used[y][x] = True
      ret = 0
      for dx, dy in vec:
        nx, ny = x + dx, y + dy
        if not used[ny][nx] and mp[ny][nx] == word[pos + 1]:
          ret += _search(word, pos + 1, nx, ny)
      used[y][x] = False
      return ret
    
    ret = 0
    for y in range(1, 5):
      for x in range(1, 5):
        if mp[y][x] == word[0]:ret += _search(word, 0, x, y)  
    return ret
  
  values = []
  weights = []
  for word, score in zip(words, scores):
    cnt = search(word)
    acc = 1
    while cnt >= acc:
      cnt -= acc
      values.append(score * acc)
      weights.append(len(word) * acc)
      acc *= 2
    if cnt:
      values.append(score * cnt)
      weights.append(len(word) * cnt)
  
  dp = [0] * (t + 1)
  for v, w in zip(values, weights):
    for x in range(max(-1, t - w), -1, -1):
      dp[x + w] = max(dp[x + w], dp[x] + v)
  print(max(dp)) 

main()


Measured memory_bytes: 6124
#include<iostream>
#include<cstdio>
using namespace std;
int main(void)
{
	int n,m;
	int sum;
	int ans;
	scanf("%d %d",&n,&m);
	for(int i = 0;i<n;i++)
		sum += i+m;
	int a = m,b = m+n-1;
//	int sum = (a+b) * (b-a+1)/2; 求总和
	if(m<=0 && (n+m-1)>=0) ans = sum;
	else if(m >= 0 && (n+m-1)>=0) ans = sum - m;
	else ans = sum - (n+m-1);  
	cout<<ans<<endl;
	return 0;
}

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

int main(){
    
    int N;
    cin >> N;
    int A[N];
    for(int i=0;i<N;i++) cin >> A[i];
    

   //int N =5;
   //int A[5] = {5,3,2,4,1};
    int count=0;
    for (int i=0;i<N;i++){
        for (int j=N-1;j>i;j--){
            if(A[j]<A[j-1]){
                swap(A[j],A[j-1]);
                count++;
            }
        }
    }
    for(int i=0;i<N;i++) {
        if(i!=0)cout << " ";
        cout << A[i];
    }
    cout << endl;
    cout << count << endl;
}


Measured memory_bytes: 3120
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < n; i++)
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
const int MAX_N = 1000005;
ll A[MAX_N],Ac[MAX_N],c[MAX_N];
vector<ll> pri;

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

int main()
{
	int N;
	cin >> N;
	ll stwise = 0;
	bool stcheck = false;
	rep(i,N)
	{
		cin >> A[i];
		Ac[A[i]]++;
		if (i == 0) stwise = A[i];
		else stwise = mygcd(stwise,A[i]);
		//cout << stwise << " ";
	}
	if (stwise != 1)
	{
		cout << "not coprime" << endl;
		return 0;
	}
	else
	{
		stcheck = true;
	}

	for (int i = 2; i < MAX_N; ++i)
	{
		if (Ac[i] > 1)
		{
			cout << "setwise coprime" << endl;
			return 0;
		}
	}

	/*
	for (ll i = 2; i <= 1005; ++i)
	{
		bool flag = true;
		for (ll j = 2; j*j <= i; ++j)
		{
			if (i % j == 0)
			{
				flag = false;
				break;
			}
		}
		if (flag) pri.push_back(i);
	}

	rep(i,pri.size())
	{
		cout << pri[i] << " ";
		int cnt = 0;
		rep(j,N)
		{
			if (A[j] % pri[i] == 0)
			{
				cnt++;
			}
		}
		if (cnt > 1)
		{
			cout << "setwise coprime" << endl;
			return 0;
		}
	}
	cout << "pairwise coprime" << endl;
	*/

	rep(i,N)
	{
		for (int j = 1; j*j < A[i]; ++j)
		{
			if (A[i] % j == 0)
			{
				if (c[j] > 0 || c[A[i]/j] > 0)
				{
					cout << "setwise coprime" << endl;
					return 0;
				}
				if (j != 1) c[j]++;
				if (A[i]/j != 1) c[A[i]/j]++;
			}
		}
	}
	cout << "pairwise coprime" << endl;
	return 0;
}

Measured memory_bytes: 19808
#include<cstdio>
#include<algorithm>
using namespace std;
int main(void){
	int n;
	int box[100];
	int x;
	int i,j;
	int MAX;
	scanf("%d",&n);
	for(i=0;i<n;i++)	scanf("%d",&box[i]);
	MAX=-1;
	for(i=0;i<n-1;i++){
		for(j=i+1;j<n;j++){
			x=box[i]-box[j];
			if(x<0)	x*=-1;
			MAX=max(MAX,x);
		}
	}
	printf("%d\n",MAX);
	return 0;
}

Measured memory_bytes: 128
#include<iostream>
using namespace std;
int main()
{
    long long n,m,mn,i,a,s=1;
    cin>>n;
    cin>>a;
    mn=a;
    for(i=2;i<=n;i++)
    {
        cin>>a;
        if(a<mn)
        {
            s++;
        }
        mn=min(mn,a);
    }
    cout<<s<<endl;  
    return 0;
}

Measured memory_bytes: 3640
#include <bits/stdc++.h>
using namespace std;
#define fi first
#define se second
#define countof(array) (sizeof(array) / sizeof(array[0]))
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,n,s) for(int i = s; i < (n); ++i)
#define rsrep(i,n,s) for(int i = (n)-1; i >= s; --i)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define aall(a) (a), (a)+countof(a)//for array sorting
#define raall(a) (a), (a)+countof(a), greater<>()
#define show(x) cout<<#x<<" = "<<x<<endl;
#define vfind(v, a) find(all(v), a) != v.end()
#define yn(f) { if (f) puts("YES"); else puts("NO"); }
#define yns(f) { if (f) puts("Yes"); else puts("No"); }
#define show_ary(...) { cout<<#__VA_ARGS__<<" = "; for (const auto& x : (__VA_ARGS__)) { cout<<x<<" "; } cout<<endl; }
#define show_pair(...) cout<<#__VA_ARGS__<<" = "<<endl; for (const auto& x : (__VA_ARGS__)) { cout<<"  "<<x.fi<<" : "<<x.se<<endl; }
#define out_ary(...) { for (const auto& x : (__VA_ARGS__)) { cout<<x<<" "; } cout<<endl; }
#define argmax(v) distance((v).begin(), max_element(all(v)))
#define argmin(v) distance((v).begin(), min_element(all(v)))
#define vmax(v) *max_element(all(v))
#define vmin(v) *min_element(all(v))
typedef long long int ll;
typedef pair<int, int> P;
typedef vector<P> vpair;
typedef vector<int> vint;
typedef vector<ll> vll;
typedef vector<double> vdouble;
typedef vector<string> vstr;
typedef vector<bool> vbool;
typedef vector<vint> vvint;
typedef vector<vll> vvll;
typedef vector<vstr> vvstr;
typedef vector<vbool> vvbool;
const ll LINF = 2000000000000000000ll;
const int INF = 1000000100;
const ll MOD = 1e9+7;

int main() {
    ll a, b, x;
    cin >> a >> b >> x;
    ll ans = b/x + 1;
    if (a > 0) ans -= (a-1)/x + 1;

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

Measured memory_bytes: 256
n,k,*a=map(int,open(0).read().split())
for _ in range(k):
  b=[0]*n
  for i,q in enumerate(a):
    b[max(0,i-q)]+=1
    if i+q+1<n:
      b[i+q+1]-=1
  for i in range(1,n):
    b[i]+=b[i-1]
  if a==b:
    break
  a=b[:]
print(*a)

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

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

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

typedef set<pi> spi;

const int INF=INT_MAX;




int main(){
    int N,K,C;
    cin>>N>>K>>C;
    string s;
    cin>>s;
    vi l(K);
    vi R(K);
    int day=0;
    for(int i=0;i<K;i++){
        while(s[day]=='x'){
            day++;
        }
        l[i]=day;
        day+=(C+1);
    }
    day=N-1;
    for(int i=0;i<K;i++){
        while(s[day]=='x'){
            day--;
        }
        R[K-i-1]=day;
        day-=(C+1);
    }
    for(int i=0;i<K;i++){
        if(l[i]==R[i]){
            out(l[i]+1);
        }
    }

    return 0;
}


Measured memory_bytes: 3332
import math


X = int(input())

r = 0

if X == 1:
    r = 1
else:
    for b in range(2, math.ceil(X ** 0.5)):
        for p in range(2, math.ceil(X ** 0.5)):
            if b ** p > X:
                break
            else:
                r = max(r, b ** p)

print(r)


Measured memory_bytes: 3188
#pragma GCC optimize("O3")
#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")
#pragma GCC target("avx,avx2")
#include<stdio.h>
#include<algorithm>
#include<math.h>
#include<vector>
#include<set>
#include<unordered_map>
#include<assert.h>
#include<time.h>
#include<stdlib.h>
#include<random>
#include<queue>
using namespace std;
using lld = long long int;
using pll = pair<lld, lld>;
using lf = double;
using pff = pair<lf, lf>;
using pif = pair<int, lf>;
using pii = pair<int, int>;
using pli = pair<lld, int>;
using pil = pair<int, lld>;
using piii = pair<int, pii>;
int n, m;
void cal(lld a, lld b, lld& res) {
	lld c = a * b;
	if (res < c)res = c;
}
int main() {
	int i, j, k, l;
	int t = 1, tv = 0;
	//scanf("%d", &t);
	while (t--) {
		lld a, b, c, d;
		scanf("%lld %lld %lld %lld", &a, &b, &c, &d);
		lld res = -1000000000000000009LL;
		lld cur;
		cal(a, c, res);
		cal(a, d, res);
		cal(b, c, res);
		cal(b, d, res);
		printf("%lld\n", res);
	}
	return 0;
}

Measured memory_bytes: 1736
import sys

sys.setrecursionlimit(10 ** 6)
int1 = lambda x: int(x) - 1
p2D = lambda x: print(*x, sep="\n")
def MI(): return map(int, sys.stdin.readline().split())
def LI(): return list(map(int, sys.stdin.readline().split()))
def LLI(rows_number): return [LI() for _ in range(rows_number)]

def main():
    n=int(input())
    s=input()
    ans="".join(chr((ord(c)-65+n)%26+65) for c in s)
    print(ans)
main()


Measured memory_bytes: 3060
#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <cmath>
#include <queue>
#include <vector>
#include <utility>
#define maxn 100005
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
int n,Q,a[maxn];
struct Query{
	int val,id;
	bool operator < (const Query &b)const
	{
		return val > b.val;
	}
}q[maxn];
ll ans[maxn],sum[maxn],sumodd[maxn];
bool check(int pos,int x){
	if(a[pos] >= x) return false;
	int pos2 = pos + ((n - pos) >> 1);
	return a[pos2] - x < x - a[pos];
}
int main(){
	scanf("%d%d",&n,&Q);
	for(int i=1;i<=n;i++){
		scanf("%d",&a[i]);
		sum[i] = sum[i - 1] + a[i];
		sumodd[i] = sumodd[i - 1] + ((n - i + 1) & 1) * a[i];
	}
	int x = n;
	for(int i=1;i<=Q;i++){
		scanf("%d",&q[i].val);
		q[i].id = i;
	}
	sort(q + 1,q + Q + 1);
	for(int i=1;i<=Q;i++){
		if(a[n] <= x) ans[q[i].id] = sumodd[n];
		else{
			while(x > 0 && !check(x,q[i].val)) x -= 2;
			if(x == 0) ans[q[i].id] = sum[n] - sum[n >> 1];
			else ans[q[i].id] = sum[n] - sum[x + ((n - x) >> 1)] + sumodd[x];
		}
	}
	for(int i=1;i<=Q;i++){
		printf("%lld\n",ans[i]);
	}
	return 0;
}


Measured memory_bytes: 5248
import sys
sys.setrecursionlimit(100000000)


def main():
    solve()


def solve():
    for data in get_dataset():
        print search(data)


def search(data):
    count = 0
    H = len(data)
    W = len(data[0])
    for i in xrange(H):
        for j in xrange(W):
            if data[i][j] == '.':
                continue
            _search(i, j, H, W, data[i][j], data)
            count += 1
    return count


def _search(i, j, H, W, cell, data):
    data[i][j] = '.'
    for a in xrange(i-1, i+2):
        if not -1 < a < H:
            continue
        for b in xrange(j-1, j+2):
            if not -1 < b < W:
                continue

            if a != i and b != j:
                continue

            if data[a][b] == '.':
                continue

            if cell == data[a][b]:
                _search(a, b, H, W, cell, data)
    return


def get_dataset():
    dataset = []
    while True:
        line = raw_input().rstrip().split()
        H = int(line[0])
        if H == 0:
            break

        data = []
        for i in xrange(H):
            data.append(list(raw_input().rstrip()))
        dataset.append(data)
    return dataset


if __name__ == '__main__':
    main()

Measured memory_bytes: 15748
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <iomanip>
#include <random>
#include <cstdio>
#include <cmath>
#include <map>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (int) n; i++)

int main() {
    int a,b,c; cin >> a >> b >> c;
    for (int i = a; i <= b*a; i+=a)
    {
        if (i % b == c) {
            cout << "YES\n";
            return 0;
        }
    }
    cout << "NO\n";
    return 0;
}

Measured memory_bytes: 256
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <queue>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>

using namespace std;

#define dump(x)  cerr << #x << " = " << (x) << endl;
#define PB push_back
#define MP make_pair
#define ll long long

inline int toInt(string s){int v;istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x){ostringstream sout;sout<<x;return sout.str();}

int main(){
    std::ios::sync_with_stdio(false);
    int n;
    cin >> n;
    long long a[n+1];
    int ans = 0;
    for(int i=0;i<n;++i)
    {
        cin >> a[i];

        while(a[i] % 2 == 0)
        {
            ans++;
            a[i] /= 2;
        }
    }
    cout << ans << endl;
    
}

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

int main()
{
    ll n;
    cin >> n;
    ll a[n];
    for (ll i = 0; i < n; i++) cin >> a[i];
    sort(a, a + n);
    cout << a[n - 1] - a[0] << endl;
}


Measured memory_bytes: 256
# include <bits/stdc++.h>
# define maxn 100005
# define ll long long
# define clock (clock() * 1000.0 / CLOCKS_PER_SEC)
# define rc(s) return cout << s,0
# define _ ios_base::sync_with_stdio(false);cin.tie(0);cerr.tie(0);cout.tie(0);
# define pb push_back
# define mp make_pair
# define int ll
using namespace std;

int n,x,odd,even;

int32_t main(){_
	//freopen("input","r",stdin);
    cin >> n;
    for(int i = 1;i<=n;i++)
    {
		cin >> x;
        if(x % 2) odd++;
        else even++;
    }
    even += odd / 2;
    odd -= (odd/2) * 2;
    if(odd == 1 && even > 0) rc("NO");
	rc("YES");
}



Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define INF 1LL<<62
#define inf 1000000007
const int MAX = 30000000;
const int MOD = 1000000007;

long long fac[MAX], finv[MAX], inv[MAX];
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

// 二項係数計算
long long COM(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

int main() {
	ll x,y;
	cin>>x>>y;
	if((2*y-x)%3!=0||2*y-x<0){
		cout << 0;
		return 0;
	}
	ll b=(2*y-x)/3;
	ll a=y-2*b;
//	cout << a<<b;
    COMinit();

    // 計算例
    ll A=a+b;
    cout << COM(A, a) << endl;
    return 0;
}	

Measured memory_bytes: 703360
#include <iostream>
#include <utility>
#include <map>
#include <vector>
#include <algorithm>
#include <queue>
#include <math.h>
#include <stack>
#include <set>
#include <deque>
#include <cmath>
#include <cassert>

using namespace std;
typedef long long ll;
ll mod = 1e9+7;
#define rep(i,n) for(int i = 0; i < (n); ++i)

vector<int> v,vv;
int pre[26];
 
int main()
{
	rep(i,26) pre[i]=-1;
	string s,t;
	cin>>s>>t;
 
	rep(i,(int)s.size()){
		v.push_back(pre[s[i]-'a']);
		pre[s[i]-'a']=i;
	}
 
	rep(i,26) pre[i]=-1;
	rep(i,(int)t.size()){
		if(pre[t[i]-'a']!=v[i]){
			cout<<"No\n";
			return 0;
		}
		pre[t[i]-'a']=i;
	}
	cout<<"Yes\n";
 
 
	return 0;
}

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

int main() {
  int n, m;
  string s, t;
  map<string, int> mp;
  cin >> n;
  for (int i = 0; i < n; i++) {
    cin >> s;
    mp[s]++;
  }
  cin >> m;
  for (int i = 0; i < m; i++) {
    cin >> t;
    mp[t]--;
  }
  int max = 0;
  for (auto itr = mp.begin(); itr != mp.end(); itr++) {
    if (max < itr->second) max = itr->second;
  }
  cout << max << endl;
  return 0;
}

Measured memory_bytes: 256
#include<iostream> 
#include<bits/stdc++.h> 
using namespace std;
typedef long long ll;
int main(){ 
	ios::sync_with_stdio(false); 
	cin.tie(0); 
	int N;
	cin>>N;
	vector<int> a(N);
	for(int i=0;i<N;i++){
		cin>>a[i];
	}
	vector<vector<ll>> dp(N,vector<ll>(N,0LL));
	int sign=N%2?-1:1;
        for(int i=0;i<N;i++){ 
		dp[i][i]=sign*a[i];
	} 
	bool turn=N%2?true:false; 

	for(int i=1;i<N;i++){
		turn=not turn;
		for(int j=0;j<N-i;j++){ 
			dp[j][j+i]=turn?min(dp[j+1][j+i]-a[j],dp[j][j+i-1]-a[j+i]):max(dp[j+1][j+i]+a[j],dp[j][j+i-1]+a[j+i]); 
		} 
	}
	cout<<-dp[0][N-1]; 


	
	return 0;
} 



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

int main () {
	int W,H,x,y,r;
	cin >> W >> H >> x >> y >> r;	
	if((x+r)<=W&&(x-r)>=0){
		if((y+r)<=H&&(y-r)>=0){	
		cout << "Yes" << '\n';
		}else{
		cout << "No" << '\n';
		}
	}else{
		cout << "No" << '\n';
	}
	return 0;
}
	

Measured memory_bytes: 1124
import java.util.Scanner;


public class Main {

	static Scanner sc = new Scanner(System.in);
	
	static int a[] = new int[4], b[] = new int[4];
	/**
	 * @param args
	 */
	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ

		while(read()){
			solve();
		}
	}
	
	static boolean read(){
		if(!sc.hasNext()) return false;
		
		for(int i=0; i < 4; i++){
			a[i] = sc.nextInt();
		}
		
		for(int i=0; i < 4;i++){
			b[i] = sc.nextInt();
		}
		
		return true;
	}
	
	static void solve(){
		
		int hit=0, blow=0;
		
		for(int i=0; i < 4; i++){
			if(a[i] == b[i]){
				hit++;
			}
			else{
				for(int j=0; j < 4; j++){
					if(a[i] == b[j]){
						blow++;
					}
				}
			}
		}
		
		System.out.println(hit + " " + blow);
	}

}

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


int main() {
    ll N, M;
    cin >> N >> M;
    vector<ll> a(N);
    rep(i,N) cin >> a[i];

    ll num;
    rep(i,N) {
        if (i == 0) num = a[0];
        num = lcm(num, a[i]);
    }
    ll ans = 0;
    rep(i,N) {
        if ((num / a[i]) % 2 != 1) {
            cout << 0 << endl;
            return 0;
        }
    }
    ans += (2 * M / num + 1) / 2;
    cout << ans << endl;
    
}



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

using namespace std;

int ReturnDigitsSum( int n ) {
    int sum = 0;
    while (n > 0) {
        sum += n % 10;
        n /= 10;
    }

    return sum;
}
int main() {
    int n, a, b;
    cin >> n >> a >> b;;
    int sum_soms = 0;
    for (int i = 1; i < n + 1; i++) {
        int sum = ReturnDigitsSum(i);
        if (sum >= a && sum <= b) sum_soms += i;
    }
    cout << sum_soms << endl;
}

Measured memory_bytes: 3632
def main():
    n = int(input())
    xs = list(map(int, input().split()))
    xs_sorted = sorted(xs)
    mid_n2, mid_n1 = (n+1)//2, (n-1)//2
    for x in xs:
        if x == xs_sorted[mid_n1]:
            print(xs_sorted[mid_n2])
        elif x == xs_sorted[mid_n2]:
            print(xs_sorted[mid_n1])
        elif x < xs_sorted[mid_n1]:
            print(xs_sorted[mid_n2])
        else:
            print(xs_sorted[mid_n1])


if __name__ == "__main__":
    main()


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

const int N = 1e5 + 5;
int height[N];
int dp[N];

int solve(int n) {
    //base
    if (n<=1) return 0;
    //lookup
    if (dp[n] != -1) return dp[n];
    int op1 = abs(height[n] - height[n - 1]) + solve(n - 1);
    int op2 = INT_MAX;
    if(n>2)
     op2 = abs(height[n] - height[n - 2]) + solve(n - 2);
    dp[n] = min(op1, op2);    
    return dp[n];
}
    
    
signed main()
{
    int n;
    cin>>n;
    memset(dp, -1, sizeof dp);
    for(int i=1;i<=n;i++) cin>>height[i];
    cout << solve(n);
}

Measured memory_bytes: 8328
#include<bits/stdc++.h>
#define int long long
#define pii pair<int,int>
#define mp make_pair
#define fi fisrt
#define se second

using namespace std;
const int N=1e5+5;
const int mod=1e9+7;
const int inf=0x3f3f3f3f3f3f3f;

vector<int> vec[N];

int n,m,k,ans=inf;
int a[N];
int num[N];
string s,t;
int lens,lent;
int ksm(int xx,int yy,int zz)
{
	int ret;
	while (yy)
	{
		if (yy&1) ret=(ret*xx) % zz;
		xx=(xx*xx)%zz;
		yy>>=1;
	}
	return ret;
}

signed main()
{
	cin>>s>>t;
	lens=s.length();
	lent=t.length();
	for (int i=0;i<lens-lent+1;i++)
	{
		int tmp=0;
		for (int j=0;j<lent;j++)
			tmp+=(t[j]!=s[i+j]);
		ans=min(ans,tmp);
	}
	cout<<ans<<endl;
}


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

int main(){
    int n,i;
    int d1[100];
    int d2[100];
    int flag = 0;
    int zorome = 0;
    scanf("%d",&n);
    
    for(i=0;i<n;i++){
        scanf("%d",&d1[i]);
        scanf("%d",&d2[i]);

        if(d1[i] == d2[i]) zorome++;
        else zorome = 0;

        if(zorome == 3) flag = 1;
   }
    if(flag == 1){
        printf("Yes");
    } else {
        printf("No");
    }

}



Measured memory_bytes: 1736
if __name__=="__main__":
    n, p = [int(i) for i in input().split(' ')]
    if n == 1 :
        print(p)
        exit(0)
    ans = 1
    i = 2
    while i * i <= p:
        if p % i == 0:
            cnt = 0
            while p % i == 0:
                p /= i
                cnt += 1
            while cnt >= n:
                ans *= i
                cnt -= n
        i += 1
    print(ans)

Measured memory_bytes: 3064
#include <stdio.h>

int main(){
	int n = 1, x = 1, cnt, ans = 0;
	int i, j, k;

	while ( 1 ) {
		scanf("%d %d\n", &n, &x);

		if(n == 0 && x == 0){
			break;
		}

		for ( i = 1; i < n-1; i++) {
			for ( j = i + 1; j < n; j++) {
				for ( k = j + 1; k <= n; k++) {
					cnt = i + j + k;
					if(cnt==x){
						ans = ans +1;
					}
				}
			}
		}

		printf("%d\n", ans);
		ans = 0;
	}
	return 0;
}	

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

int main(){
  vector<int> x(3,0);
  REP(i,3) cin>>x.at(i);
  REP(i,3) if(x.at(i)==x.at((i+1)%3)) cout<<x.at((i+2)%3);
}

Measured memory_bytes: 256
N = int(input())
R = sorted([list(map(int, input().split())) for _ in range(N)], key=lambda x:x[0]+x[1])

remain = list(range(N))
ans = N
left = 0
i = 1
while i < N:
  x_l, length_l = R[left]
  x, length = R[i]
  if x-x_l < length_l+length:
    ans -= 1
  else:
    left = i
  i += 1
print(ans)

Measured memory_bytes: 66392
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <cmath>
#include <random>
#include <ctime>
using namespace std;

int main(){
    string ans;
    int a,b,c ;
    cin >> a >> b >> c ;
    if (a > b)
    {
        if (a > c && c > b)
        {
            ans = "Yes" ;
        }else
        {
            ans ="No" ;
        }
        
        
    }else
    {
        if (b > c && c > a)
        {
            ans = "Yes" ;
        }else
        {
            ans = "No" ;
        }
        
        
    }
    cout << ans << endl ;
     

}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		
		Scanner sc = new Scanner(System.in);
		String	s  = new String();
		int H = sc.nextInt();
		int W = sc.nextInt();
		char[][] ans = new char[H+2][W+2];
		
		for(int i = 1;i<=H;i++) 
		{	
			s=sc.next();
			for(int k=1;k<=W;k++)
				ans[i][k] = s.charAt(k-1);
			
		}
		
		for(int i = 1;i<=H;i++) 
			for(int k=1;k<=W;k++)
				if(ans[i][k]=='.')	ans[i][k]='0';
			
		
		for(int i = 1;i<=H;i++) 
			for(int k=1;k<=W;k++) 
			{
				if(ans[i][k]=='#') 	{  ans[i][k]='#'; continue; }
				
				if(ans[i-1][k-1]=='#') ans[i][k]++;
				if(ans[i-1][ k ]=='#') ans[i][k]++;
				if(ans[i-1][k+1]=='#') ans[i][k]++;
				
				if(ans[ i ][k-1]=='#') ans[i][k]++;
				if(ans[ i ][k+1]=='#') ans[i][k]++;
				
				if(ans[i+1][k-1]=='#') ans[i][k]++;
				if(ans[i+1][ k ]=='#') ans[i][k]++;
				if(ans[i+1][k+1]=='#') ans[i][k]++;
			
		}

		for(int i = 1;i<=H;i++) {
			for(int k=1;k<=W;k++) 
			{
				System.out.print(ans[i][k]);
			}
		System.out.println("");}
		
	}

}



Measured memory_bytes: 24276
A, B, C, X, Y = map(int, input().split())

cost1 = A * X + B * Y
cost2 = C * max([X, Y]) * 2

if X > Y:
    cost3 = C * Y * 2 + A * (X - Y)
else:
    cost3 = C * X * 2 + B * (Y - X)

print(min([cost1, cost2, cost3]))

Measured memory_bytes: 3060
s = input()
q = int(input())
for i in range(q):
	input_list = list(input().split())
	a = int(input_list[1])
	b = int(input_list[2])
	if input_list[0] == 'print':
		print(s[a:b+1])
	elif input_list[0] == 'reverse':
		s = s[:a] + s[a:b+1][::-1] + s[b+1:]
	else :
		s = s[:a] + input_list[3] + s[b+1:]



Measured memory_bytes: 5616
#include <bits/stdc++.h>
using namespace std;
using lli = long long int;
using ulli = unsigned long long int;
#define debug(x) cerr << #x << " : " << x << endl

namespace atcoder {
	void judge_outer(bool judge_exp, string ok = "Yes", string ng = "No") {
		if (judge_exp) {
			cout << ok << endl;
		}
		else {
			cout << ng << endl;
		}
	}

	template<typename T>
	T ncr(T left, T right) {
		right = min(left - right, right);
		T ans = 1;
		for (T i = 1; i <= right; i++) {
			ans = ans * (left - right + i) / i;
		}
		return ans;
	}

	const int LIMIT = 1000000007;
	const int tenfive = 100000;
}

using namespace atcoder;

int main() {
	int N,Y;
	cin >> N >> Y;
	int ansA = -1, ansB = -1, ansC = -1;
	for (int x = 0; x <= N; x++) {
		for (int y = 0; y <= N - x; y++) {
			int z = N - y - x;
			if (z < 0)
				continue;
			if (Y == 10000 * x + 5000 * y + 1000 * z) {
				ansA = x;
				ansB = y;
				ansC = z;
			}
		}
	}
	cout << ansA << " " << ansB << " " << ansC << endl;
}


Measured memory_bytes: 256