akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<cstdio>
#include<cstring>
#include<ctime>
#include<algorithm>
#include<cstdlib>
#include<cmath>
#include<set>
#include<bitset>
#include<map>
#include<stack>
#include<queue>
#include<vector>
#include<utility>
#define INF 0x3f3f3f3f
#define inf 2*0x3f3f3f3f
#define llinf 1000000000000000000
#define pi acos(-1.0)
#define mod 1000000007
#define lson l,m,rt<<1
#define rson m+1,r,rt<<1|1
#define lrt rt<<1
#define rrt rt<<1|1
#define rep(i,a,b) for(int i=(a);i<(b);i++)
#define per(i,a,b) for(int i=(b)-1;i>=(a);i--)
#define mem(a,b) memset(a,b,sizeof(a))
#define lb(x) (x&-x)
#define gi(x) scanf("%d",&x)
#define gi2(x,y) scanf("%d%d",&x,&y)
#define gll(x) scanf("%lld",&x)
#define gll2(x,y) scanf("%lld%lld",&x,&y)
#define gc(x) scanf("%c",&x)
#define gc2(x,y) scanf("%c%c",&x,&y)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int>P;
int n,t,sum=0,a[200005];
int main()
{
    gi2(n,t);
    rep(i,0,n)gi(a[i]);
    rep(i,1,n)
    {
        sum+=min(t,a[i]-a[i-1]);
    }
    sum+=t;
    cout<<sum;
    return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(n);++i)
#define ALL(A) A.begin(), A.end()

using namespace std;

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

int main()
{
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	int N; cin >> N;
	if (N % 2 == 0){
		cout << N << endl;
	}else{
		cout << 2 * N << endl;
	} // end if

	return 0;
}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;

namespace AtCoder
{
    public static class Program
    {
        static void Main()
        {
            var N = int.Parse(Console.ReadLine());
            var array = new int[N];
            var top = 0;
            var second = 0;
            foreach (var i in Enumerable.Range(0, N))
            {
                var v = int.Parse(Console.ReadLine());
                array[i] = v;
                if (v > top)
                {
                    second = top;
                    top = v;
                    continue;
                }
                second = Math.Max(second, v);
            }
            for (int i = 0; i < array.Length; i++)
            {
                if (array[i] == top)
                {
                    Console.WriteLine(second);
                    continue;
                }
                Console.WriteLine(top);
            }
        }
    }
}


Measured memory_bytes: 18736
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
       Scanner sc = new Scanner(System.in);
       int N = sc.nextInt();
       int K = sc.nextInt();
       int X = sc.nextInt();
       int Y = sc.nextInt();
       int total = 0;
       for(int a = 1;a <= N;a++){
           if(a <= K){
               total += X;
           }else{
               total += Y;
           }
       }
       System.out.println(total);
    }
}


Measured memory_bytes: 23764
#include <stdio.h>

int main() {
    int a[5], i, min=10, ans=0;

    for(i=0; i<5; i++) {
        scanf("%d", &a[i]);
        if(a[i]%10 != 0) {
            ans += 1;
            if(min > a[i]%10) {
                min = a[i] % 10;
            }
        }
        ans += a[i]/10;
        // printf("\n%d\n", ans);
    }

    // printf("%d\n", min);

    ans -= 1;
    ans *= 10;
    ans += min;

    printf("%d\n", ans);


    return 0;
}

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

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();}

typedef long long ll;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<long long> VL;
typedef vector<vector<long long>> VVL;
typedef vector<string> VS;
typedef pair<int, int> P;
typedef tuple<int,int,int> tpl;

#define ALL(a)  (a).begin(),(a).end()
#define SORT(c) sort((c).begin(),(c).end())
#define REVERSE(c) reverse((c).begin(),(c).end())
#define EXIST(m,v) (m).find((v)) != (m).end()
#define LB(a,x) lower_bound((a).begin(), (a).end(), x) - (a).begin()
#define UB(a,x) upper_bound((a).begin(), (a).end(), x) - (a).begin()

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define RFOR(i,a,b) for(int i=(a)-1;i>=(b);--i)
#define RREP(i,n) RFOR(i,n,0)

#define en "\n"

constexpr double EPS = 1e-9;
constexpr double PI  = 3.1415926535897932;
constexpr int INF = 2147483647;
constexpr long long LINF = 1LL<<60;
constexpr long long MOD = 1000000007; // 998244353;

#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

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

void Main(){
    int D; cin >> D;
    VI c(26); REP(i,26) cin >> c[i];
    int s[D][26]; REP(i,D)REP(j,26) cin >> s[i][j];
    VI t(D); REP(i,D){cin >> t[i]; t[i]--;}
    int M; cin >> M;
    REP(_,M){
        int d,q; cin >> d >> q; d--; q--;
        t[d] = q;
        VI last(26,0);
        int ans = 0;
        REP(i,D){
            ans += s[i][t[i]];
            last[t[i]] = i+1;
            REP(j,26) ans -= c[j] * (i+1-last[j]);
        }
        cout << ans << en;
    }
    return;
}

int main(void){
    cin.tie(0);cout.tie(0);ios_base::sync_with_stdio(0);cout<<fixed<<setprecision(15);
    int t=1; //cin>>t;
    REP(_,t) Main();
    return 0;
}

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

using namespace std;

int main() {
	int N;
	cin >> N;
	vector<int>p(N);

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

	int cnt = 0;

	for (int i = 2; i < N; i++)
	{
		if ((p[i - 2] < p[i - 1] && p[i - 1] < p[i]) || (p[i - 2] > p[i - 1] && p[i - 1] > p[i])) {
			cnt++;
		}
	}
	cout << cnt << endl;
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n;
    while(cin>>n,n){
        int num[2000]={},co=n,sum=0;
        for(int i=0;i<n;i++){
            cin>>num[i];
            sum+=num[i];
        }
        for(int i=1;sum>0;i++)sum-=i;
        for(int i=0;;i++){
                //cout<<co<<endl;
            bool kawa=1;
            if(i==10000||sum!=0){
                cout<<-1<<endl;
                break;
            }
            for(int j=0;j<co&&kawa;j++)if(num[j]!=j+1)kawa=0;
            if(kawa){
                cout<<i<<endl;
                break;
            }
            for(int j=0;j<co;j++)num[j]-=1;
            num[co]=co;
            for(int j=0;j<=co;j++){
                if(num[j]==0){
                    for(int k=j+1;k<=co;k++){
                        if(num[k]!=0){
                            swap(num[j],num[k]);
                            break;
                        }
                    }
                }
            }
            for(int j=0;j<=co+1;j++){
                if(num[j]==0||j==co+1){
                    co=j;
                    break;
                }
            }
        }
    }
}

Measured memory_bytes: 1168
#include <bits/stdc++.h>
using namespace std;
#define F first
#define S second
#define pi M_PI
#define R cin>>
#define Z class
#define ll long long
#define ln cout<<'\n'
#define in(a) insert(a)
#define pb(a) push_back(a)
#define pd(a) printf("%.10f\n",a)
#define mem(a) memset(a,0,sizeof(a))
#define all(c) (c).begin(),(c).end()
#define iter(c) __typeof((c).begin())
#define rrep(i,n) for(int i=(int)(n)-1;i>=0;i--)
#define REP(i,m,n) for(int i=(int)(m);i<(int)(n);i++)
#define rep(i,n) REP(i,0,n)
#define tr(it,c) for(iter(c) it=(c).begin();it!=(c).end();it++)
template<Z A>void pr(A a){cout<<a;ln;}
template<Z A,Z B>void pr(A a,B b){cout<<a<<' ';pr(b);}
template<Z A,Z B,Z C>void pr(A a,B b,C c){cout<<a<<' ';pr(b,c);}
template<Z A,Z B,Z C,Z D>void pr(A a,B b,C c,D d){cout<<a<<' ';pr(b,c,d);}
template<Z A>void PR(A a,ll n){rep(i,n){if(i)cout<<' ';cout<<a[i];}ln;}
ll check(ll n,ll m,ll x,ll y){return x>=0&&x<n&&y>=0&&y<m;}
const ll MAX=1000000007,MAXL=1LL<<61,dx[4]={-1,0,1,0},dy[4]={0,1,0,-1};
typedef pair<int,int> P;

void Main() {
  string s;
  R s;
  int l=MAX,r=0;
  rep(i,s.size()) {
    if(s[i]=='A') l=min(l,i);
    if(s[i]=='Z') r=max(r,i);
  }
  pr(r-l+1);
}

int main(){ios::sync_with_stdio(0);cin.tie(0);Main();return 0;}


Measured memory_bytes: 720
#include <iostream>
#include <algorithm>
#include <cstdio>
#include <vector>
#include <math.h>
#include <iomanip>
#include <bitset>
#include <string>
#include <cstring>
#include <stdlib.h>
#include <utility>
#include <set>
#include <map>
using namespace std;
typedef long long int ll;

#define MOD 998244353


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

bool primeNumber(ll n){
    if(n < 2) return false;
    else{
        for(ll i = 2; i * i <= n; i++){
            if(n % i == 0) return false;
        }
        return true;
    }
}
  
  

int main(){
    ll a,b,c;
    cin>>a>>b>>c;
    
    if (c >= a && b >= c)puts("Yes");
    else puts("No");
    
    return 0;
}



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

#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define forn(i, n) for (int i = 0; i < (int)(n); ++i)
#define for1(i, n) for (int i = 1; i <= (int)(n); ++i)
#define ford(i, n) for (int i = (int)(n) - 1; i >= 0; --i)
#define fore(i, a, b) for (int i = (int)(a); i <= (int)(b); ++i)

template<class T> bool umin(T &a, T b) { return a > b ? (a = b, true) : false; }
template<class T> bool umax(T &a, T b) { return a < b ? (a = b, true) : false; }

using namespace std;

int main(int argc, char** argv) 
{
#ifdef HOME
	if(IsDebuggerPresent())
	{
		freopen("../in.txt", "rb", stdin);
		freopen("../out.txt", "wb", stdout);
	}
#endif
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	cout.precision(10);
	cout << fixed;
	int H, W;
	cin >> H >> W;
	vector<string> v(H);
	vector<vector<int> > d(H, vector<int>(W, H*W + 1));
	forn(i, H)
		cin >> v[i];
	if (v[0][0] == '#')
		d[0][0] = 1;
	else
		d[0][0] = 0;

	forn(i, H) forn(j, W)
	{
		if (i + 1 < H)
		{

			d[i + 1][j] = min(d[i][j] + (v[i + 1][j] == v[i][j] || v[i+1][j] != '#' ? 0 : 1), d[i + 1][j]);
		}
		if (j + 1 < W)
		{
			d[i][j + 1] = min(d[i][j] + (v[i][j + 1] == v[i][j] || v[i][j + 1] != '#' ? 0 : 1), d[i][j + 1]);
		}
	}

	/*
	for
	while (d[H - 1][W - 1] > H*W)
	{
		int minh = -1, minw = -1;
		forn(i, H) forn(j, W) if(!u[i][j])
		{
			if (minh == -1 || d[i][j] < d[minh][minw])
			{
				minh = i;
				minw = j;
			}
		}
		u[minh][minw] = true;
		fore(dx, 0, 1) fore(dy,0, 1) if (dx == 0 || dy == 0)
		{
			int ah = minh + dx;
			int aw = minw + dy;
			if (ah < 0 || ah >= H || aw < 0 || aw >= W || u[ah][aw])
				continue;
			d[ah][aw] = min(d[minh][minw] + (v[ah][aw] == '#' ? 1 : 0), d[ah][aw]);
		}
	}*/
	cout << d[H - 1][W - 1] << "\n";
	return 0;
}


Measured memory_bytes: 892
#![allow(unused_imports, unused_variables, dead_code)]
use std::io::*;
use std::fmt::*;
use std::str::*;
use std::cmp::*;
use std::collections::*;

trait InputValue {
    fn parse(s: &str) -> Self;
}

fn read<T: InputValue>() -> T {
    let mut buf = String::new();
    let _ = stdin().read_line(&mut buf);
    T::parse(&buf.trim())
}

fn readnc<T: InputValue>() -> Vec<T> {
    let mut vec = vec![];
    let line: String = read();
    for token in line.split_whitespace() {
        vec.push(T::parse(token));
    }
    vec
}

fn readn<T: InputValue>(n: usize) -> Vec<T> {
    let mut vec = vec![];
    for _ in 0..n {
        vec.push(read());
    }
    vec
}

macro_rules! parse_single_value {
    ($($t:ty),*) => {
        $(
            impl InputValue for $t {
                fn parse(s: &str) -> $t { s.parse().unwrap() }
            }
        )*
	}
}
parse_single_value!(i32, i64, f32, f64, usize, String);

macro_rules! parse_tuple {
	($($t:ident),*) => {
		impl<$($t),*> InputValue for ($($t),*) where $($t: InputValue),* {
			fn parse(s: &str) -> ($($t),*) {
				let mut tokens = s.split_whitespace();
				let t = ($($t::parse(tokens.next().unwrap())),*);
				t
			}
		}
	}
}
parse_tuple!(A, B);
parse_tuple!(A, B, C);

// ===

fn main() {
    let n = read();
    let a: Vec<i32> = readn(n);

    let mut numbers = HashSet::new();
    for a in a {
        if numbers.contains(&a) {
            numbers.remove(&a);
        } else {
            numbers.insert(a);
        }
    }
    println!("{}", numbers.len());
}

Measured memory_bytes: 8444
#include <iostream>
#include <numeric>
#include <string>
#include <vector>
#include <algorithm>
#include <sstream>
#include <iterator>
#include <math.h>
#include <cmath>
#include <set>   
#include <bitset>
#include <cstdio>
#include <iostream>
#include <iomanip>
#include <boost/math/common_factor_rt.hpp>

#define ll long long
using namespace std;
ll l = 1000000007;

ll a[10005000] = {};

int main()
{
	ll n;
	cin >> n;
	for (int i = 0; i < n; i++)
	{
		cin >> a[i];
	}
	ll ans = a[0];
	for (int i = 1; i < n; i++)
	{
		ans = boost::math::gcd(ans, a[i]);
	}
	
	cout << ans << endl;
	
}



Measured memory_bytes: 1024
n=1
i=[]
try:
    while n<=10000:
        x=int(input())
        if x==0:
            break
        else:
            i.append("Case "+str(n)+": "+str(x))
            n+=1
except EOFError:
    pass
i_n="\n".join(i)
print(i_n)


Measured memory_bytes: 6480
#include <iostream>
#include <vector>
#include <cmath>
#include <algorithm>
#include <map>

using namespace std;


void minimization()
{
  int n, k;
  cin >> n >> k;

  cout << ceil((float)(n - 1) / (float)(k - 1)) << "\n";
}


void linear_approximation()
{
  int n;
  cin >> n;
  vector<int> b(n);
  for (int i = 0; i < n; ++i)
  {
    int a;
    cin >> a;
    b[i] = a - (i + 1);
  }

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

  int mid = b[n / 2];
  long long int ans = 0;
  for (int i = 0; i < n; ++i) ans += abs(mid - b[i]);
  cout << ans << "\n";

}


void modulo_summation()
{
  int n;
  cin >> n;
  int ans = 0;
  for (int i = 0; i < n; ++i) {
    int a;
    cin >> a;
    ans += a - 1;
  }

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


//skip
void all_green()
{
  int d, g;
  cin >> d >> g;
  vector<int> p(d);
  vector<int> c(d);
  for (int i = 0; i < d; ++i) cin >> p[i] >> c[i];


}


void base_2_number()
{
  int n;
  cin >> n;

  string s = "";
  if (n == 0) s = '0' + s;
  while (n != 0)
  {
    if (n % 2 != 0)
    {
      --n; //-２進数の整合性
      s = '1' + s;
    }
    else
    {
      s = '0' + s;
    }
    n /= -2;
  }

  cout << s << "\n";
}


void to_infinity()
{
  string s;
  long long int k;
  cin >> s >> k;

  char digit = '1';
  for (int i = 0; i < k; ++i)
  {
    if (s[i] != '1')
    {
      digit = s[i];
      break;
    }
  }
  cout << digit << "\n";
}


void candles()
{
  int n, k;
  cin >> n >> k;
  vector<long long int> x(n);
  for (int i = 0; i < n; ++i) cin >> x[i];

  long long int ans = 100000000000000000;
  for (int i = 0; i < n - k + 1; ++i)
  {
    long long int tmp = abs(x[i + k - 1] - x[i])+ min(abs(x[i]), abs(x[i + k - 1]));
    ans = min(ans, tmp);
  }

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


void triangular_relationship()
{
  int n, k;
  cin >> n >> k;

  if (k % 2 != 0)
  {
    long long int a = n / k;
    cout << a * a * a << "\n";
  }
  else
  {
    long long int a = n / k;
    long long int b = 2 * n / k;
    cout << a * a * a + (b - a) * (b - a) * (b - a) << "\n";
  }
}


long long int gcd(int a, int b)
{
  if (a < b)
  {
    int tmp;
    tmp = a;
    a = b;
    b = tmp;
  }

  int r = a % b;
  while (r != 0)
  {
    a = b;
    b = r;
    r = a % b;
  }

  return b;
}


void skip()
{
  int n, X;
  cin >> n >> X;
  vector<int> d(n);
  for (int i = 0; i < n; ++i)
  {
    int x_tmp;
    cin >> x_tmp;
    d[i] = abs(X - x_tmp);
  }

  int ans = d[0];
  for (int i = 0; i < n; ++i)
  {
    ans = gcd(ans, d[i]);
  }

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


void string_transformation()
{
  string s, t;
  cin >> s >> t;
  
  map<char, int> mp_s, mp_t;
  long long int s_i = 0, t_i = 0;
  string S, T;
  for (int i = 0; i < s.size(); ++i)
  {
    if (mp_s[s[i]] == 0)
    {
      ++s_i;
      mp_s[s[i]] = s_i;
    }
    if (mp_t[t[i]] == 0)
    {
      ++t_i;
      mp_t[t[i]] = t_i;
    }
    S.push_back(mp_s[s[i]]);
    T.push_back(mp_t[t[i]]);
  }

  if (S == T) cout << "Yes\n";
  else cout << "No\n";
}

int main()
{
  //minimization();
  //linear_approximation();
  //modulo_summation();
  //all_green();
  //base_2_number();
  //to_infinity();
  //candles();
  //triangular_relationship();
  //skip();
  string_transformation();
}


Measured memory_bytes: 1204
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Arrays;
import java.util.Comparator;

public class Main {

	public static void main(String[] args) throws IOException {
		// TODO ?????????????????????????????????????????????
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		
		while(true){
			String[] tmpArray = br.readLine().split(" ");
			
			int n = Integer.parseInt(tmpArray[0]);
			int m = Integer.parseInt(tmpArray[1]);

			if(n == 0 && m == 0){
				break;
			}
			
			Place[] places = new Place[m];
			for(int i = 0; i < m; i++){
				places[i] = new Place(i + 1);
			}
			
			for(int i = 0 ; i < n; i++){
				tmpArray = br.readLine().split(" ");
				for(int j = 0; j < m; j++){
					if(Integer.parseInt(tmpArray[j]) == 1){
						places[j].want++;
					}
				}
			}
			
			Arrays.sort(places, new Comparator<Place>() {
				public int compare(Place a, Place b){
					if(a.want > b.want){
						return -1;
					}
					else if(a.want < b.want){
						return 1;
					}
					else {
						return 0;
					}
				}
			});
			
			for(int i = 0; i < m; i++){
				if(i != 0){
					System.out.print(" ");
				}
				
				System.out.print(places[i].id);
			}
			System.out.println();
		}
	}

}

class Place {
	int id;
	int want = 0;
	
	public Place(int id){
		this.id = id;
	}
}

Measured memory_bytes: 43900
def M():return map(int,input().split())
d='URLD'
*b,n=M()
b+=b[::-1]
r,c=M()
o=[b[0]-r+1,c,b[1]-c+1,r]
s=input()
t=[dict(zip(d,d[::-1]))[i] for i in input()]
a=0
for i,j in enumerate(d):
  x=o[i]
  for k in range(n):
    x+=(s[k]==j)
    if x>b[i]:a=1
    if x>1:x-=(t[k]==j)
print('YNEOS'[a::2])

Measured memory_bytes: 63436
K = int(input())
def runrun(num,keta):
    num_str = str(num)
    result = True
    for i in range(keta-1):
        if abs(int(num_str[i]) - int(num_str[i+1])) > 1:
            result = False
            break
    return result
def next_runrun(n):
    if str(n) == "9"*(len(str(n))):
        return n+1
    keta = len(str(n))
    while keta >= 0:
        tmp = n + 10**(len(str(n))-keta)
        if runrun(tmp,keta):
            break
        else:
            keta -= 1
    tmp_str = str(tmp)[0:keta] + "x"*(len(str(n))-keta)
    tmp_array = []
    for t in tmp_str:
        tmp_array.append(t)
    for i in range(len(tmp_array)-1):
        if tmp_array[i+1] == "x":
            j = int(tmp_array[i]) - 1
            j = j if j >= 0 else 0
            tmp_array[i+1] = str(j)
    
    return int(''.join(tmp_array))
cnt = 1
n = 1
while True:
    if cnt == K:
        break
    else:
        n = next_runrun(n)
        cnt += 1
print(n)

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

int main(){
    int n;
    cin >> n;
    int64_t ans = 0;
    for(int i = 1;i <= n;i++){
        if(i % 3 == 0 && i % 5 == 0) continue;
        else if(i % 3 == 0) continue;
        else if(i % 5 == 0) continue;
        else ans += i;
    }
    cout << ans << endl;
}

Measured memory_bytes: 3628
def MI(): return map(int, input().split())
def LI(): return list(map(int, input().split()))
N,M,X=MI()
List=[]
for i in range(N):
  CA=LI()
  List.append(CA)
ans=-1
for i in range(1<<N):
  tmp=[0]*M
  cost=0
  for j in range(N):
    if 1&(i>>j):
      cost+=List[j][0]
      for k in range(M):
        tmp[k]+=List[j][k+1]
      if min(tmp)>=X:
        if ans==-1:
          ans=cost
        else:
          ans=min(ans,cost)
print(ans)      

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

const int N=400005;

int n;
char s[N];
int sE[N],sW[N];

void work()
{
	int ans=N;
	for(int i=1;i<=n;i++){
		int val1=sE[i-1],val2=sW[i+1];
		ans=min(ans,val1+val2);
	}
	cout<<ans<<endl;
}

void init()
{
	scanf("%d",&n);
	scanf("%s",s+1);
	for(int i=1;i<=n;i++) sE[i]=sE[i-1]+(s[i]=='W');
	for(int i=n;i>=1;i--) sW[i]=sW[i+1]+(s[i]=='E');
}

int main()
{
	init();
	work();
	return 0;
}

Measured memory_bytes: 2944
//Aaryan Jagetia
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
#define fi first
#define se second
#define pb push_back
#define all(x) x.begin(),x.end()
#define mp(x,y) make_pair(x,y)
#define mod 1000000007
#define sc(x) scanf("%d", &x)
#define sl(x) scanf("%lld", &x)
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL);
#define test cin>>t;while(t--)
int main()
{    
    fast
string s;
cin>>s;
int n=s.length();
for(int i=0;i<n;i++){
    if(s[i]=='?'){
       s[i]='D';
       /* if(s[i-1]=='P'){
            s[i]='D';
        }
        else if(s[i+1]=='D'&&i<n-1){
            s[i]='P';
        }
        else{
            s[i]='D';
        }*/
    }
}
   
   
cout<<s;
return 0;
}


Measured memory_bytes: 3744
n = int(input())
a = list(map(int,input().split()))
judge1 = 0
judge2 = 0
for i in range(n):
    if a[i] % 2==0:
        judge1+=1
        if a[i] % 3 == 0 or a[i] % 5 ==0:
            judge2+=1
        
if judge1 == judge2:
    print("APPROVED")
else:
    print("DENIED")            

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

int	TTT(int i, int TT, vector<int> &C, vector<int> &S, vector<int> &F, vector<int> &T, int N) {
	//int TT=S.at(i)+C.at(i);
	if (N==i)
		return TT;
	if (TT<=S.at(i))
		return T.at(i);
	else {
		int FF=F.at(i);
		TT=(TT+FF-1)/FF;
		TT *=FF;
		TT +=C.at(i);
		TT =TTT(i+1, TT, C, S, F, T, N);
		return TT;
	}
}


int     main() {
	int N;
	cin >>N;
	vector<int> C(N+1, 0), S(N+1, 0), F(N+1, 1);
	for (int i=1; i<N; i++)
		cin >>C.at(i) >>S.at(i) >>F.at(i);
	vector<int> T(N+1, 0);
	for (int i=N-1; i>0; i--) {
		T.at(i)=TTT(i+1, S.at(i)+C.at(i), C, S, F, T, N);
	}
	for (int i=1; i<=N; i++) {
		cout <<T.at(i) <<endl;
	}
	return 0;
};


Measured memory_bytes: 256
n, k = gets.split.map(&:to_i)
x = gets.split.map(&:to_i)

l_count = x.select{|e| e < 0}.count
r_count = x.select{|e| e >= 0}.count

ans = 10**10
(k+1).times do |l|
    next if l_count < l
    next if r_count < k - l
    if l == 0
        r_dis = x[l_count - 1 + k]
        ans = r_dis if r_dis < ans
    elsif l == k
        l_dis = -1 * x[l_count - k]
        ans = l_dis if l_dis < ans
    else
        l_dis = -1 * x[l_count - l]
        r_dis = x[l_count + k - l - 1]
        if r_dis > l_dis
            dis = 2 * l_dis + r_dis
            ans = dis if dis < ans
        else
            dis = l_dis + 2 * r_dis
            ans = dis if dis < ans
        end
    end
end

p ans

Measured memory_bytes: 9228
#include<stdio.h>
#include<string.h>
int main(){
    int i, r, n, n2, z, x;
    char moji1[201] = {}, tmp1, tmp2;

    for(;scanf("%s",moji1),moji1[0] != '-';){
        scanf("%d", &n);

        for( i = 0; i < n; i++ ){
            scanf("%d", &n2);
            for( r = 0; r < n2; r++ ){
                for( z = 0; z < strlen( moji1 ); z++ ){
                   if( z == 0 ){
                    tmp1 = moji1[z];
                   }else if( z == strlen(moji1) - 1 ){
                        moji1[z - 1] = moji1[z];
                        moji1[z] = tmp1;
                    }else{
                        moji1[z - 1] = moji1[z];
                        tmp2 = moji1[z];
                   }
                }
            }
        }

        printf("%s\n", moji1);
    }
    return 0;
}

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

using ll = int64_t;
#define int ll

#define FOR(i, a, b) for (int i = int(a); i < int(b); i++)
#define REP(i, b) FOR(i, 0, b)
#define MP make_pair
#define PB push_back
#define EB emplace_back
#define ALL(x) x.begin(), x.end()

using pi = pair<int, int>;
using vi = vector<int>;
using ld = long double;

template <class T, class U>
ostream &operator<<(ostream &os, const pair<T, U> &p) {
  os << "(" << p.first << "," << p.second << ")";
  return os;
}

template <class T> ostream &operator<<(ostream &os, const vector<T> &v) {
  os << "{";
  REP(i, (int)v.size()) {
    if (i)
      os << ",";
    os << v[i];
  }
  os << "}";
  return os;
}

ll read() {
  ll i;
  scanf("%" SCNd64, &i);
  return i;
}

void printSpace() { printf(" "); }

void printEoln() { printf("\n"); }

void print(ll x, int suc = 1) {
  printf("%" PRId64, x);
  if (suc == 1)
    printEoln();
  if (suc == 2)
    printSpace();
}

string readString() {
  static char buf[3341000];
  scanf("%s", buf);
  return string(buf);
}

char *readCharArray() {
  static char buf[3341000];
  static int bufUsed = 0;
  char *ret = buf + bufUsed;
  scanf("%s", ret);
  bufUsed += strlen(ret) + 1;
  return ret;
}

template <class T, class U> void chmax(T &a, U b) {
  if (a < b)
    a = b;
}

template <class T, class U> void chmin(T &a, U b) {
  if (b < a)
    a = b;
}

template <class T> T Sq(const T &t) { return t * t; }

const int mod = 1e9 + 7;

signed main() {
  int n = read(), i = 0;
  int digit[4];
  while (n != 0) {
    digit[i++] = n % 10;
    n /= 10;
  }
  int cnt = 0;
  if ((digit[0] == digit[1] && digit[1] == digit[2]) ||
      (digit[1] == digit[2] && digit[2] == digit[3]))
    std::cout << "Yes" << std::endl;
  else
    std::cout << "No" << std::endl;
}


Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<cmath>
#include<string>
#include<cstring>
#include<algorithm>
#include<queue>
#include<map>
#include<set>
typedef long long ll;
const ll longinf=1LL<<60;
using namespace std;

ll n;
struct node
{
    ll x,y;
};
node a[10];
node b[10],c[10];
int t1,t2;

int main()
{
    cin>>n;
    for (int i=0; i<3; ++i)
        cin >> a[i].x;
    for (int i=0; i<3; ++i)
        cin >> a[i].y;
    for (int i=0; i<3; ++i)
    {
        if (a[i].x<a[i].y)
        {
            b[t1].x = a[i].x;
            b[t1].y = a[i].y;
            t1++;
        }else
        {
            c[t2].x = a[i].x;
            c[t2].y = a[i].y;
            t2++;
        }
    }
    ll ans=n;
    if (t1==0)
    {
        // b(2+0) -> a
        for (ll i=0; i<=n; ++i)
        {
            if (i*c[0].y>n) break;
            for (ll j=0; j<=n; ++j)
            {
                ll remain =(n-i*c[0].y-j*c[1].y);
                if (remain<0) break;
                ll k = remain/c[2].y;
                remain = remain%c[2].y;
                ll now;
                now = remain + i*c[0].x + j*c[1].x +k*c[2].x;
                ans = max(ans,now);
            }
        }
    }else if (t1==1)
    {
        ll remain = n;
        ll i = remain/b[0].x;
        remain = remain%b[0].x;
        remain = remain + i*b[0].y;
        for (ll j=0; j<=remain; ++j)
        {
            ll new_remain = remain - j*c[0].y;
            if (new_remain<0) break;
            ll k = new_remain/c[1].y;
            new_remain %=c[1].y;
            new_remain += j*c[0].x + k*c[1].x;
            ans = max(ans,new_remain);
        }
        // a(0+1)->b(1+1) ->a
    }else if (t1==2)
    {
        for (ll i=0; i<=n; ++i)
        {
            ll remain = n-i*b[0].x;
            if (remain<0) break;
            ll j=remain/b[1].x;
            remain%=b[1].x;
            remain +=i*b[0].y+j*b[1].y;
            ll k = remain/c[0].y;
            remain%=c[0].y;
            remain +=k*c[0].x;
            ans = max(ans,remain);
        }
        // a(1+1) -> b(1) -> a
    }else if (t1==3)
    {
        for (ll i=0; i<=n; ++i)
        {
            if (i*b[0].x>n) break;
            for (ll j=0; j<=n; ++j)
            {
                ll remain =(n-i*b[0].x-j*b[1].x);
                if (remain<0) break;
                ll k = remain/b[2].x;
                remain = remain%b[2].x;
                ll now;
                now = remain + i*b[0].y + j*b[1].y +k*b[2].y;
                ans = max(ans,now);
            }
        }
        // a(2+0)->b
    }
    cout<<ans<<endl;
    
    return 0;
}



Measured memory_bytes: 256
#include <cstdio>

#define max(a,b) (a > b ? a : b)
int a,b,n,dp[17][17];

int main(){
	while(scanf("%d%d",&a,&b), a != 0){
		scanf("%d",&n);
		for(int i = 0; i < 17; i++){
			for(int j = 0; j < 17; j++){
				dp[i][j] = 0;
			}
		}

		for(int i = 0; i < n; i++){
			int x,y;
			scanf("%d%d",&x,&y);
			dp[x][y] = -1;
		}

		dp[1][1] = 1;
		for(int i = 1; i <= a; i++){
			for(int j = 1; j <= b; j++){
				if(i != 1 || j != 1){
					if(dp[i][j] != -1){
						dp[i][j] = max(dp[i-1][j],0) + max(dp[i][j-1],0);
					}
				}
			}
		}
		printf("%d\n",dp[a][b]);
	}
	return 0;
}

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

typedef long long ll;
typedef long double ld;
#define pi 3.14159265359
#define inf 2147483647
#define INF 9223372036854775807
#define mod 1000000007
#define mod2 998244353

int main() {
    int N; cin >> N;
    vector<ll> A(N);
    for (int i = 0; i < N; i++) {
        cin >> A.at(i);
    }
    ll ans = 0;
    map<ll, ll> dist, sum;
    for (int i = 0; i < N; i++) {
        ll d = i - A.at(i);
        ll s = i + A.at(i);
        if (dist.count(d)) {
            dist.at(d)++;
        }
        else {
            dist[d] = 1;
        }
        if (sum.count(s)) {
            sum.at(s)++;
        }
        else {
            sum[s] = 1;
        }
    }
    for (int i = 0; i < N; i++) {
        if (dist.count(i) && sum.count(i)) {
            ans += dist.at(i) * sum.at(i);
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 28008
#include <stdio.h>

int
main(void)
{
	int n;

	scanf("%d", &n);

	float x1, y1, x2, y2, x3, y3, x4, y4;

	while (n--) {
		scanf("%f %f %f %f %f %f %f %f",
				   &x1, &y1, &x2, &y2, &x3, &y3, &x4, &y4);

		if ((y2 - y1)/(x2 - x1) == (y4 - y3)/(x4 - x3)) {
			printf("YES\n");
		} else {
			printf("NO\n");
		}
	}

	return 0;
}

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

int f(long long n) {
  int cnt = 0;
  while (n) {
    n /= 10;
    cnt++;
  }
  return cnt;
}

int main() {
  long long n;
  cin >> n;
  int ans = 10;
  for (long long i = 1; i * i <= n; i++) {
    if (n % i == 0) {
      ans = min(ans, f(n / i));
    }
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 3596
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.StringTokenizer;

public class Main {
	
	public static void main(String[] args) throws IOException {
		MyScanner sc = new MyScanner();
		PrintWriter out = new PrintWriter(System.out);
		char[] s = sc.next().toCharArray();
		long ans = 0;
		int as = 0, state = 0;
		for (int i = 0; i < s.length; i++) {
			if (s[i] == 'A') {
				if (state != 0) as = 0;
				state = 0;
				as++;
			}
			if (s[i] == 'B') {
				if (state == 0) {
					state++;
				} else {
					as = 0;
					state = 1;
				}
			}
			if (s[i] == 'C') {
				if (state == 1) {
					ans += as;
					state = 0;
				} else {
					state = 0;
					as = 0;
				}
			}
		}
		out.println(ans);
		
		out.flush();
	}
	
	static class MyScanner {
		private BufferedReader br;
		private StringTokenizer tokenizer;
		
		public MyScanner() {
			br = new BufferedReader(new InputStreamReader(System.in));
		}
		
		public String next() {
			while (tokenizer == null || !tokenizer.hasMoreTokens()) {
				try {
					tokenizer = new StringTokenizer(br.readLine());
				} catch (IOException e) {
					throw new RuntimeException(e);
				}
			}
			return tokenizer.nextToken();
		}
		
		public int nextInt() {
			return Integer.parseInt(next());
		}
		
		public long nextLong() {
			return Long.parseLong(next());
		}
	}
}


Measured memory_bytes: 25832
#include        "algorithm"
#include        "iostream"
#include        "numeric"
#include        "iomanip"
#include        "cstring"
#include        "math.h"
#include        "bitset"
#include        "string"
#include        "vector"
#include        "ctime"
#include        "queue"
#include        "stack"
#include        "map"
#include        "set"

#include        "ext/pb_ds/assoc_container.hpp" // Common file
#include        "ext/pb_ds/tree_policy.hpp" // Including tree_order_statistics_node_update
#include        "ext/pb_ds/detail/standard_policies.hpp"

using namespace std;
using namespace __gnu_pbds;


#define          f first
#define          lgn 25
#define          endl '\n'
#define          sc second
#define          pb push_back
#define          N (int)2e5+5
#define          PI acos(-1.0)
#define          int long long 
#define          vi vector<int>
#define          mod 1000000007
#define          ld long double
#define          eb emplace_back
#define          mii map<int,int>
#define          vpii vector<pii>
#define          pii pair<int,int>
#define          pq priority_queue
#define          BLOCK (int)sqrt(N)
#define          test(x) while(x--)
#define          all(x) begin(x),end(x)
#define          allr(x) x.rbegin(),x.rend()
#define          fo(i,a,n) for(int i=a;i<n;i++)
#define          rfo(i,n,a) for(int i=n;i>=a;i--)
#define          FAST ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define          time() cerr << "Time : " << (double)clock() / (double)CLOCKS_PER_SEC << "s\n"
#define            bug(...)       __f (#__VA_ARGS__, __VA_ARGS__)

typedef tree< int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update > 
OS ;

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

const int inf = 0x3f3f3f3f;
const int INF = 0x3f3f3f3f3f3f3f3f;

int n,m,k,q;
string s;
vi adj[N];
int vis[N],par[N],a[N];

void go()
{
     cin >> n;
     ld nn = n;
     ld xx = 100;

     for( int i = 1; i <= 100000; i++)
     {
         xx = ( 1.01 * 1.0 * xx);
         int yy = xx;
         xx = (ld)yy;

         if( xx >= n )
         {
                cout << i;
                return;
         }
     }
}

int32_t main()
{
     FAST;     
     int t=1; 
     cout << fixed << setprecision(10);
     // cin>>t;
     test(t) go();
}

 

Measured memory_bytes: 8336
import java.util.*;
public class Main { 
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
		int h = Integer.parseInt(sc.next());
        int n = Integer.parseInt(sc.next());
        
        int sum = 0;
        while(n > 0) {
        	sum += sc.nextInt();
            n--;
        }
      	if(sum >= h)
        	System.out.println("Yes");
        else
            System.out.println("No");
    }
}

Measured memory_bytes: 46796
#include <bits/stdc++.h>
using namespace std;
int main(){
    long long n, a[100100], b[100100], c[100100], happy[100100][3]={0}, i, pre=-1;
    cin >> n;
    for(i=0;i<n;i++){
        cin >> a[i] >> b[i] >> c[i];
    }

    happy[0][0]=a[0];
    happy[0][1]=b[0];
    happy[0][2]=c[0];    
    for(i=1;i<n;i++){
       happy[i][0]=max(happy[i-1][1]+a[i], happy[i-1][2]+a[i]);
       happy[i][1]=max(happy[i-1][0]+b[i], happy[i-1][2]+b[i]);
       happy[i][2]=max(happy[i-1][0]+c[i], happy[i-1][1]+c[i]);
    }

    cout << max({happy[n-1][0], happy[n-1][1], happy[n-1][2]}) <<endl;
    return 0;
}


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

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

using namespace std;

/////////////////////////////////////////////////////

ll K;
ll i, j, k;
ll ansCnt;
ll S(ll a){
    ll ret = 0;
    while(a>0){
        ret += a % 10;
        a /= 10;
    }
    return ret;
}
void dfs(ll a,ll ii){
    if(ii==0){
        if(a>0){
            printf("%lld\n", a);
            ++ansCnt;
            if(K==ansCnt){
                exit(0);
            }
        }
        return;
    }
    ll i;
    ll aa = a + ii - 1;
    ll bb = a + ii * 9 + ii - 1;
    if(aa*S(bb)>bb*S(aa)){
        
        printf("%lld\n", bb);
        ++ansCnt;
        if(K==ansCnt){
            exit(0);
        }
        return;
    }

    fornum(i,0,10){
        dfs(a + ii * i, ii / 10);
    }
}

int main(){
    scanf("%lld", &K);
    dfs(0, 1e15);

    


    return 0;
}

Measured memory_bytes: 256
n,m = map(int,input().split())
Psum = [0] * (n+1)
for i in range(m):
    l,r=map(lambda x:int(x)-1,input().split())
    r += 1
    Psum[l] += 1
    Psum[r] -= 1
for i in range(n):
    Psum[i+1] += Psum[i]
cnt = 0
for i in range(n):
    if Psum[i] >= m:
        cnt += 1
print(cnt)


Measured memory_bytes: 6900
#include <bits/stdc++.h>
 
using namespace std;
 
#define endl '\n'
#define f first
#define s second
#define fastio ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);

using ld = long double;
using ll = long long;
using pii = pair <int,int>;
using pll = pair <ll,ll>;
using vi = vector <int>;
using vll = vector <ll>;
using vpii = vector <pii>;
using vpll = vector<pll>;
using vs = vector <string>;


int main(){
  fastio;

  int n;
  cin >> n;
  vi l(n);

  int ans = 0;
  for(int i=0;i<n;i++)
    cin >> l[i];
  
  sort(l.begin(),l.end());

  for(int i=0;i<n;i++)
    for(int j=i+1;j<n;j++)
      for(int k=j+1;k<n;k++){
        if(l[i]==l[j] || l[i]==l[k] || l[k]==l[j])
          continue;
        if(l[i]+l[j]>l[k])
          ans++;
      }
        

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

Measured memory_bytes: 3648
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time,copy,functools

sys.setrecursionlimit(10**7)
inf = 10**1
gosa = 1.0 / 10**9
mod = 10**9 + 7

def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def S(): return input()


def main():
    n = S()
    if n == n[::-1]:
        return 'Yes'


    return 'No'



print(main())



Measured memory_bytes: 6732
#include<bits/stdc++.h>
using namespace std;
int main() {
	int n, l[210], ans = 0;
	cin >> n;
	for (int i = 0; i < 2 * n; i++) {
		cin >> l[i];
	}
	sort(l, l + 2 * n);
	for (int i = 0; i < 2 * n; i += 2) {
		ans += min(l[i], l[i + 1]);
	}
	cout << ans << endl;
}

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

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

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

template<typename T,typename V>
typename enable_if<is_class<T>::value==0>::type
fill_v(T &t,const V &v){t=v;}

template<typename T,typename V>
typename enable_if<is_class<T>::value!=0>::type
fill_v(T &t,const V &v){
  for(auto &e:t) fill_v(e,v);
}

//INSERT ABOVE HERE
signed main(){
  Int w,h;
  while(cin>>w>>h,w){
    auto dp=make_v<Int>(2,2,h+1,w+1);
    fill_v(dp,0);
    dp[0][0][0][1]=dp[1][0][1][0]=1;
    const Int MOD = 1e5;
    for(Int i=0;i<h;i++){
      for(Int j=0;j<w;j++){
	dp[0][0][i][j]%=MOD;
	dp[0][1][i][j]%=MOD;
	dp[1][0][i][j]%=MOD;
	dp[1][1][i][j]%=MOD;
	
	dp[0][0][i][j+1]+=dp[0][0][i][j];
	dp[1][1][i+1][j]+=dp[0][0][i][j];
	
	dp[0][1][i][j+1]+=dp[1][0][i][j];
	dp[1][0][i+1][j]+=dp[1][0][i][j];
	
	
	dp[0][0][i][j+1]+=dp[0][1][i][j];
	dp[1][0][i+1][j]+=dp[1][1][i][j];
	
      }
    }
    
    Int ans=0;
    for(Int i=0;i<2;i++)
      for(Int j=0;j<2;j++)
	ans+=dp[i][j][h-1][w-1];
    ans%=MOD;
    
    cout<<ans<<endl;
  }
  return 0;
}



Measured memory_bytes: 3380
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define ALL(a)  (a).begin(),(a).end()
#define SUM(a)  accumulate((a).begin(),(a).end(),0)
#define SORT(a) sort(ALL(a))
#define REV(a) reverse(ALL(a))
#define dump(x)  cerr << #x << " = " << (x) << endl;
typedef long long ll;
const int INF = 999999999;
const int MOD = (int)1e9 + 7;
const int EPS = 1e-9;

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

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int n;
  cin >> n;
  int a,b;
  int ans = INF;
  FOR(a,1,n/2+1){
      b = n-a;
      ans = min(ans, DigitSum(a)+DigitSum(b));
  }
  cout << ans << endl;
}
  


Measured memory_bytes: 256
#include <bits/stdc++.h>     
 
#define mp make_pair
#define pb push_back
#define f first
#define s second
#define ll long long
#define int ll
#define forn(i, a, b) for(int i = (a); i <= (b); ++i)
#define forev(i, b, a) for(int i = (b); i >= (a); --i)
#define VAR(v, i) __typeof( i) v=(i)
#define forit(i, c) for(VAR(i, (c).begin()); i != (c).end(); ++i)
#define all(x) (x).begin(), (x).end()
#define sz(x) ((int)(x).size())
#define file(s) freopen(s".in","r",stdin); freopen(s".out","w",stdout);
 
using namespace std;
 
const int maxn = (int)108;
const int N = (int)1e5 + 100;
const int mod = (int)1e9 + 7;
 
#define inf mod
 
typedef long double ld;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;   
typedef vector<ll> Vll;               
typedef vector<pair<int, int> > vpii;
typedef vector<pair<ll, ll> > vpll;
 
int n, W, w[maxn], v[maxn];
int dp[maxn][N];

main () {
	cin >> n >> W;
	forn(i, 1, n)
		cin >> w[i] >> v[i];
	forn(i, 0, maxn - 1)
		forn(j, 0, N - 1)
			dp[i][j] = inf * inf;
	dp[0][0] = 0;
	forn(i, 1, n){
		forn(s, 0, N - 1){
			if(s >= v[i])
				dp[i][s] = min(dp[i][s], dp[i - 1][s - v[i]] + w[i]);
			dp[i][s] = min(dp[i][s], dp[i - 1][s]);
		}
	}
	forev(i, N - 1, 0){
		if(dp[n][i] <= W){
			cout << i;
			return 0;
		}
	}
}

Measured memory_bytes: 84736
/*************************************************\
           In the name of almighty ALLAH
                 MD.Faysal Hasan
                Comilla Univesity
\*************************************************/

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

#define     ikarus_101  ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);

typedef     long long             ll;
typedef     long double           ld;
typedef     unsigned long long    ull;
typedef     vector<ll>            vll;
typedef     pair<ll,ll>           pll;
typedef     vector<pll>           vpl;
typedef     map<ll,ll>            mll;
typedef     multiset<ll>          msl;
typedef     multimap<ll,ll>       Mll;
using pqboro=priority_queue<ll,vll,less<ll>>;
using pqchoto=priority_queue<ll,vll,greater<ll>>;

#define    all(str)       str.begin(),str.end()
#define    sajo(str)      sort(str.begin(),str.end())
#define    rev(str)       reverse(str.begin(),str.end())
#define    usajo(str)     sort(str.rbegin(),str.rend())
#define    vin(a)         for(auto &it : a) cin>>it
#define    vout(a)        for(auto it:a) cout<<it<<' ';cout<<nn
#define    pb             push_back
#define    eb             emplace_back
#define    mkp(x,y)       make_pair(x,y)
#define    F              first
#define    S              second
#define    yes            cout<<"YES"<<nn
#define    no             cout<<"NO"<<nn
#define    nn             "\n" ///endl
#define    sss            " "
#define    rep(i,n)       for (i=0;i<n;++i )
#define    rep1(i,n)      for (i=1;i<=n;++i )

#define    min3(a,b,c)    min(a,min(b,c))
#define    max3(a,b,c)    max(a,max(b,c))
#define    sqr(x)         ((x)*(x))
#define    pi             2*acos(0.0)
#define    gcd(a,b)       __gcd(a,b)
#define    lcm(a,b)       (a/gcd(a,b))*b
#define    mem(a,b)       memset(a,b,sizeof (a))
#define    dec(x)         cout<<fixed<<setprecision(x)
#define    none(n)         __builtin_popcountll(n)

template < typename T > string toString ( T Number ) { stringstream ss ; ss << Number ; return ss.str() ; }
template < typename T > ll toll ( T str ) { stringstream ss ; ss << str ; ll num ; ss >> num ; return num ; }

const   int  N   =   2e5+7;
const   int  M   =   1e9+7;
const   ll  inf  =   0x7f7f7f7f7f7f7f7f;

int main() {ikarus_101

    ll n,m,i,j,k,x;

    cin >> i >> j;
    cout << (i<j ? 0 : 10) << nn;





    return 0;
}


Measured memory_bytes: 3612
#include <iostream>
#include <vector>
#include <set>
#include <algorithm>
#include <math.h>
#include <string.h>
#include <map>
#include <numeric>
#include <random>
#include <queue>
#include <deque>
#include <tuple>
#include <iomanip>

using namespace std;
typedef long long ll;

const int INF = (1 << 30) - 1;
const ll INFLL= (1LL << 61) - 1;
const int MOD = 1000000007;
#define ALL(a) (a).begin(),(a).end()
#define rALL(a) (a).rbegin(),(a).rend()

int main()
{
  cin.tie(0);
  ios::sync_with_stdio(false);
  int N;
  cin>>N;
  if(N<=999){
    cout<<"ABC"<<endl;
  }else{
    cout<<"ABD"<<endl;
  }
}


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

#define _USE_MATH_DEFINES

#include <iostream>
#include <sstream>
#include <iomanip>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <algorithm>
#include <numeric>
#include <functional>
#include <utility>
#include <tuple>
#include <vector>
#include <string>
#include <list>
#include <set>
#include <unordered_set>
#include <map>
#include <unordered_map>
#include <queue>
#include <deque>
#include <stack>
#include <iterator>
#include <bitset>
#include <complex>
#include <limits>
#include <random>


using namespace std;

#define rep(i,a,b) for(int i=(a), i##_len=(b);i<i##_len;i++)
#define rrep(i,a,b) for(int i=(b)-1;i>=(a);i--)
#define all(c) begin(c),end(c)

#define int ll
#define SZ(x) ((int)(x).size())
#define pb push_back
#define mp make_pair

typedef unsigned long long ull;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<ll, int> pli;
typedef pair<double, double> pdd;
typedef vector< vector<int> > mat;

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

const int INF = sizeof(int) == sizeof(long long) ? 0x3f3f3f3f3f3f3f3fLL : 0x3f3f3f3f;
const int MOD = (int)1e9 + 7;

const double EPS = 1e-9;

const int MAX = 1000010;

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;
}

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

	int N;
	cin >> N;

	int DP[2][4] = { 0 };

	DP[0][0] = 1;
	int nxt = 1;
	rep(i, 0, N)
	{
		rep(j, 0, 4)DP[nxt][j] = 0;
		rep(j, 0, 4)
		{
			rep(k, 0, 10)
			{
				int nj = j;
				if (k == 0)
				{
					if (nj == 0)nj = 1;
					else if (nj == 2)nj = 3;
				}
				if (k == 9)
				{
					if (nj == 0)nj = 2;
					else if (nj == 1)nj = 3;
				}
				DP[nxt][nj] += DP[nxt^1][j];
				DP[nxt][nj] %= MOD;
			}
		}
		nxt ^= 1;
	}
	nxt ^= 1;

	cout << DP[nxt][3] << endl;

	return 0;
}


Measured memory_bytes: 3640
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define dd double
#define endl "\n"
#define pb push_back
#define all(v) v.begin(),v.end()
#define mp make_pair
#define fi first
#define se second
#define fo(i,n) for(int i=0;i<n;i++)
#define fo1(i,n) for(int i=1;i<=n;i++)
ll mod=1000000007;
ll n,k,t,m,q,flag=0;
ll po(ll k ,ll n,ll ans,ll temp,ll ans1){
    if(n==0)return ans;
    while(temp<=n){
        ans*=ans1;ans%=mod;ans1=ans1*ans1;ans1%=mod;n=n-temp;temp*=2;
    }
    return po(k,n,ans,1,k)%mod;
    //eg. po(2,78,1,1,2);
}
ll min(ll a,ll b){if(a>b)return b;else return a;}
ll max(ll a,ll b){if(a>b)return a;else return b;}
int main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0); cout.tie(0);
    
    //cin>>t;
    t=1;
    while(t--){
        ll x;
        cin>>x;
        cout<<(x/500)*1000 + ((x%500)/5)*5;
    }

    return 0;
}


Measured memory_bytes: 256