akhauriyash/Code-Regression huggingface dataset:
//#define _LIBCPP_DEBUG 0
#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>

#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#include <regex>
#define rep(i,n) for(int i = 0; i < n; i++)
#define reps(i,j,n) for(int i = j; i < n; i++)
#define rrep(i,j,n) for(int i = j-1; i >= n; i--)
#define prec(n) fixed << setprecision(n)
#define print_array(v) rep(__k, v.size()) { cout << v[__k]; if(__k != v.size()-1) cout << " "; else cout << endl; }
#define YesorNo(a) printf(a?"Yes\n":"No\n")
#define acc(v) accumulate(v.begin(), v.end(),0);
#define MOD 1e+7;
#define inf 1e9;
#define fi first;
#define se second;
using namespace std;

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int n, m, x;
  cin >> n >> m >> x;
  vector<int> c(n);
  vector<vector<int>>  a(n,vector<int>(m));
  rep(i,n) {
    cin >> c[i];
    rep(j,m) {
      cin >> a[i][j];
    }
  }
  int res = inf;
  for(int bit = 0; bit < (1 << n); bit++) {
    //bitset<12> b(bit);
    int val = 0;
    bool ok = true;
    vector<int> smart(m);
    rep(i,12) {
      if((bit >> i) & 1) {
        val += c[i];
        rep(j,m) smart[j] += a[i][j];
      }
    }
    rep(i,m) if(smart[i] < x) ok = false;
    if(ok) res = min(res, val);
  }
  if(res == 1e9) res = -1;
  cout << res << endl;
  return 0;
}
//templete by private_yusuke

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

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

    for(int i=0;i<min(a.size(),b.size());i++)
        cout<<a[i]<<b[i];

    if(a.size()!=b.size()){
        if(a.size()>b.size())
            cout<<a[a.size()-1];
        else
            cout<<b[b.size()-1];
    }
    
    cout<<endl;

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define FOR(i,a,b) for (int i = (a); i < (b); ++i)
#define RFOR(i,a,b) for (int i = (b)-1; i >= (a); --i)
#define REP(i,n) FOR(i,0,(n))
#define REPS(i,n) FOR(i,1,(n)+1)
#define RREP(i,n) RFOR(i,0,(n))
#define ALL(x) (x).begin(),(x).end()
#define RALL(x) (x).rbegin(),(x).rend()
#define DEBUG(x)  cout << #x << " = " << (x) << endl;
#define SORT(x) sort(ALL(x));
#define RSORT(x) sort(RALL(x));
#define SUM(x) accumulate(ALL(x),0);
#define FI first
#define SE second
#define PB push_back
#define EB emplace_back
#define SZ(x) (int)(x).size()
#define BN(x) ((1<<x)-1)
#define DUP(x,y) (((x)+(y)-1)/(y))
using namespace std;
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using pii = pair<int, int>;
using tiii = tuple<int, int, int>;
const ll mod = 1e9+7;
const int INF = (1<<30)-1;
const ll INFLL = (1LL<<62)-1;
const int dx[4] = {1,0,-1,0};
const int dy[4] = {0,1,0,-1};
//cout << fixed << setprecision(10);

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

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

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

  vi to[200005];

  int N, Q; cin >> N >> Q;
  REP(i,N-1) {
    int a, b; cin >> a >> b;
    --a; --b;
    to[a].PB(b);
    to[b].PB(a);
  }

  vi ans(N);
  //ans.resize(N);
  REP(i,Q) {
    int p, x; cin >> p >> x;
    --p;
    ans[p] += x;
  }

  vector<bool> checked(N,false);
  queue<int> que;
  que.push(0);
  checked[0] = true;

  while (!que.empty()) {
    int node = que.front();
    que.pop();
    for (auto &next : to[node]) {
      if (!checked[next]) {
        ans[next] += ans[node];
        que.push(next);
        checked[next] = true;
      }
    }
  }

  REP(i,N) {
    cout << ans[i] << endl;
  }
  
  return 0;
}

Measured memory_bytes: 15604
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define INF 1LL<<62
#define inf 1000000007 

int main() {
	ll n;
	cin>>n;
	double ans=0;
	for(int i=0;i<n;i++){
		double a;
		string b;
		cin>>a>>b;
		if(b=="JPY"){
			ans+=a;
		}
		else{
			ans+=a*380000.0;
		}
	}
	cout <<ans;
	// your code goes here
	return 0;
}

Measured memory_bytes: 256
def pre_combi1(n, p):
    fact = [1]*(n+1)  # fact[n] = (n! mod p)
    factinv = [1]*(n+1)  # factinv[n] = ((n!)^(-1) mod p)
    inv = [0]*(n+1)  # factinv 計算用
    inv[1] = 1
    # 前処理
    for i in range(2, n + 1):
        fact[i]= fact[i-1] * i % p
        inv[i]= -inv[p % i] * (p // i) % p
        factinv[i]= factinv[i-1] * inv[i] % p
    return fact, factinv

def combi1(n, r, p, fact, factinv):
    """
    k<n<10**7でpが素数のときのnCr % pを求める
    """
    # 本処理
    if r < 0 or n < r:
        return 0
    r = min(r, n-r)
    return fact[n] * factinv[r] * factinv[n-r] % p

S=int(input())
l_max = S//3
ans = 0
p=10**9+7
f,fv = pre_combi1(2000,p)

for l in range(1, l_max+1):
  n = S - 3*l
  if n < 1:
    ans += 1
  else:
    ans += combi1(n+l-1,l-1,p,f,fv)
  ans %= p

print(ans)

Measured memory_bytes: 64720
#include<bits/stdc++.h>
#define LL long long
using namespace std;
const int MAXN = 2e5+7;
const int INF = 2e9 +7;
int a[MAXN];
int L[MAXN];
int R[MAXN];
LL result;
int n;

void merge(int l, int mid, int r){
	int n1 = mid - l;
	int n2 = r - mid;
	for(int i = 0; i<n1;i++){
		L[i] = a[l+i];
	}
	for(int i = 0; i<n2; i++){
		R[i] = a[mid+i];
	}
	L[n1] = INF;
	R[n2] = INF;
	int i, j;
	i = 0; j = 0;
	int k;
	for(k = l; k < r; k++){
		if(L[i] > R[j]){
			result+=(n1-i);
			a[k] = R[j];
			j++;
		}else{
			a[k] = L[i];
			i++;
		}
	}

}
void mergeCount(int l, int r){
	if(l+1<r){
		int mid = (l+r)/2;
		mergeCount(l, mid);
		mergeCount(mid, r);
		merge(l,mid,r);
	}
}
int main(){
	result = 0;
	scanf("%d", &n);
	for(int i = 0; i < n; i++){
		scanf("%d", &a[i]);
	} 
	mergeCount(0, n);
	cout << result <<endl;
	
	return 0;
} 


Measured memory_bytes: 4808
#include<iostream>
#include<string>
#include<array>

int main(){
    
    std::string s;
    std::cin >> s;

    std::array<size_t, 26> cnt = {};

    for(size_t i = 0; i < s.size(); i++){
        cnt.at(s.at(i) - 'a')++;
    }

    for(size_t i = 0; i < cnt.size(); i++){
        if(cnt.at(i) == 0){
            std::cout << static_cast<char>(i + 'a') << std::endl;
            return 0;
        }
    }

    std::cout << "None" << std::endl;
    
    return 0;
}


Measured memory_bytes: 512
#ifdef DAIJOBU
#include "/home/v-o_o-v/deb.h"
#define deb(x...) cerr << "[" << #x << "] = ["; _print(x)
#else
#include <bits/stdc++.h>
#define deb(x...)
#endif 

using namespace std;

#define mp make_pair
#define mt make_tuple
#define fi first
#define se second
#define pb push_back
#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)

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
 
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<pii> vpi;
typedef long long lint;
typedef double ld;

void a();void b();void c();void d();void e();void f();

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

	// a();
	// b();
	c();
	// d();
	// e();
	// f();
	return 0;
}

void a(){
	int n;
	cin >> n;
	n %= 10;
	if(n == 2 || n == 4 || n == 5 || n == 7 || n == 9)puts("hon");
	else if(n == 3)puts("bon");
	else puts("pon");

}

void b(){
	int n;
	string  s;
	cin >> n >> s;
	if((int)s.size() > n){
		cout << s.substr(0, n) << "...";
	}else cout << s;
}

ld calcAngle(double h, double m)  
{  
    
    if (h == 12) h = 0;  
    if (m == 60) m = 0;  
    ld hour_angle = 0.5 * (h * 60 + m);  
    ld minute_angle = 6 * m;  
    ld angle = abs(hour_angle - minute_angle);  
    angle = min(360 - angle, angle);  
    return angle;  
} 
const ld pi = 2 * acos(0);
void c(){
	int a, b, h, m;
	cin >> a >> b >> h >> m;
	ld deg = calcAngle(h, m);
	deg *=  pi / 180.0;
	ld ans = a * a + b * b - 2 * a * b * cos(deg);
	ans = sqrt(ans);
	cout << fixed << setprecision(20) << ans;
	// deb(deg);
}

void d(){

}

void e(){

}

void f(){

}

Measured memory_bytes: 4216
/*
    Created by vasu090 on 19 Apr, 2020
*/
#include <iostream>
#include <cmath>
#include <vector>
#include <algorithm>

using namespace std;

#define rep(i, a, b) for(auto (i)=a;i<b;i++)
#define list(i, N) for(auto (i)=0;i<N;i++)

typedef long long ll;
typedef vector <ll> vi;
typedef pair <ll, ll> pi;
#define mp make_pair
#define pb push_back
#define eb emplace_back

#define int ll
#define INF 1e18+5
#define mod 1000000007

template<class T>
T max(T a, T b, T c) {
    return max(a, max(b, c));
}

int32_t main() {

    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);

    int n; cin >> n;
    vi a(n); list(i,n) cin >> a[i];

    int mx = -INF;
    int mxIdx = -1;
    list(i,n){
        if(a[i] > mx){
            mx = a[i];
            mxIdx = i;
        }
    }

    int mx_new = -INF;
    list(i,n){
        if(a[i] > mx_new && i!=mxIdx){
            mx_new = a[i];
        }
    }

    list(i,n){
        if(i!=mxIdx) cout << mx << "\n";
        else cout << mx_new << '\n';
    }

    return 0;
}

Measured memory_bytes: 3200
# 0028
array = []
while True:
    try:
        a = input()
        array.append(int(a))
    except EOFError: break
s = set(array)
mx = max(sorted(s, reverse=True), key = array.count)
for a in sorted(s, key = array.count, reverse=True):
    print(a)
    if a == mx: break

Measured memory_bytes: 7568
#include <cstdio>

int main()
{
  long long n;
  scanf("%lld", &n);
  
  for (long long h = 1 + n / 4; h <= 3 * n / 4; ++h)
  {
    long long a = 4 * h - n;
    long long b = n * h;
    
    for (long long i = h; i <= 3500; ++i)
    {
      for (long long j = i; j <= 3500; ++j)
      {
        long long aa = i + j;
        long long bb = i * j;
        if (a * bb == b * aa)
        {
          printf("%lld %lld %lld\n", h, i, j);
          return 0;
        }
      }
    }
  }
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
#define all(v) v.begin(), v.end()
 
int main() {
  int N; cin >>N;
  vector<int>X(N);
  for(int i=0;i<N;i++){
    cin>>X.at(i);
  }
  sort(all(X));
  int sum=0;
  int kotae=INT_MAX;
  int j=X.at(0);
  while(j<=X.at(N-1)){
    sum=0;
    //cout<<j<<endl;
    rep(i,N){
      sum+=(X.at(i)-j)*(X.at(i)-j);
    }
    kotae=min(kotae,sum);
    j++;
  }
  cout <<kotae<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main() {
 	char c[10];
  	cin >> c;
  	c[0] = '2';
  	c[1] = '0';
  	c[2] = '1';
  	c[3] = '8';
  	for (int i = 0; i < 10; i++) cout << c[i];
}

Measured memory_bytes: 256
#include <stdlib.h>
#include <algorithm>
#include <iostream>
#include <vector>

using namespace std;

int main() {
  uint16_t N, K;
  cin >> N >> K;
  string S;
  cin >> S;
  if (S[K - 1] == 'A') {
    S[K - 1] = 'a';
  } else if (S[K - 1] == 'B') {
    S[K - 1] = 'b';
  } else if (S[K - 1] == 'C') {
    S[K - 1] = 'c';
  }
  cout << S << endl;
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main() {
    int N;
  cin >> N;
  vector<int>a(N);
  int stop = 0;
  int count = 0;
  for(int i = 0; i< N; i++){
        cin >> a.at(i);
  }
  while(stop == 0){
    for(int i = 0; i< N - 1; i++){
       if(a.at(i) == a.at(i+1)){
         a.at(i+1) = a.at(i+1) + 101*(i+1);
           count++;
           break;
       }
      if(i == N-2){
         stop++;
       }
    }
  }
  cout << count << endl;
}

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

int N;
int d[100];
int ans = 0;

int main() {
    cin >> N;
    for (int i = 0; i < N; i++) cin >> d[i];
    
    int num[110] = {0};
    for (int i = 0; i < N; i++) num[d[i]]++;
    for (int i = 0; i < 110; i++) {
        if (num[i] > 0) ans++;
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define inf 1000000007
#define mod 1000000007
//#pragma GCC optimize(2)
//#define int long long
#define pi 3.1415926535897932384
using namespace std;
template <typename T> void read(T &x){
	x=0;char ch=getchar();int fh=1;
	while (ch<'0'||ch>'9'){if (ch=='-')fh=-1;ch=getchar();}
	while (ch>='0'&&ch<='9')x=x*10+ch-'0',ch=getchar();
	x*=fh;
}
template <typename T> void write(T x) {
	if (x<0) x=-x,putchar('-');
	if (x>9) write(x/10);
	putchar(x%10+'0');
}
template <typename T> void writeln(T x) {
	write(x);
	puts("");
}
signed main()
{
	//freopen(".in","r",stdin);
	//freopen(".out","w",stdout);
	ios::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	double r;
	cin>>r;
	cout<<fixed<<setprecision(12)<<2.0*r*pi<<endl;
	return 0;
}


Measured memory_bytes: 3804
#include <bits/stdc++.h>
#define xx first
#define yy second
#define mp make_pair
#define pb push_back
#define mset(x, y) memset(x, y, sizeof x)
#define mcpy(x, y) memcpy(x, y, sizeof x)
using namespace std;

typedef long long LL;
typedef pair <int, int> pii;

inline int Read()
{
	int x = 0, f = 1, c = getchar();
	for (; !isdigit(c); c = getchar())
		if (c == '-')
			f = -1;
	for (;  isdigit(c); c = getchar())
		x = x * 10 + c - '0';
	return x * f;
}

const int MAXN = 200005;

int n, m, ans, e[MAXN << 2], t[MAXN << 2];
vector <int> a[MAXN];

inline void Modify(int x, int l, int r, int ql, int qr, int v)
{
	if (l == ql && r == qr)
		return (void)(e[x] += v, t[x] += v);
	int mid = l + r >> 1;
	if (qr <= mid)
		Modify(x << 1, l, mid, ql, qr, v);
	else if (ql > mid)
		Modify(x << 1 | 1, mid + 1, r, ql, qr, v);
	else
		Modify(x << 1, l, mid, ql, mid, v), Modify(x << 1 | 1, mid + 1, r, mid + 1, qr, v);
	e[x] = max(e[x << 1], e[x << 1 | 1]) + t[x];
}

inline int Query(int x, int l, int r, int ql, int qr)
{
	if (l == ql && r == qr)
		return e[x];
	int mid = l + r >> 1;
	if (qr <= mid)
		return Query(x << 1, l, mid, ql, qr) + t[x];
	if (ql > mid)
		return Query(x << 1 | 1, mid + 1, r, ql, qr) + t[x];
	return max(Query(x << 1, l, mid, ql, mid), Query(x << 1 | 1, mid + 1, r, mid + 1, qr)) + t[x];
}

int main()
{
#ifdef wxh010910
	freopen("data.in", "r", stdin);
#endif
	n = Read(), m = Read(), ans = max(0, n - m);
	for (int i = 1, l, r; i <= n; i ++)
		l = Read(), r = Read(), a[l].pb(r);
	for (int i = 0; i <= m + 1; i ++)
		Modify(1, 0, m + 1, i, i, i - m - 1);
	for (int i = 0; i <= m; i ++)
	{
		for (auto x : a[i])
			Modify(1, 0, m + 1, 0, x, 1);
		ans = max(ans, Query(1, 0, m + 1, i + 1, m + 1) - i);
	}
	return printf("%d\n", ans), 0;
}


Measured memory_bytes: 14080
#include <iostream>
#include <iomanip>
#include <string>
#include <algorithm>
#include <vector>
#include <cmath>
using namespace std;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep2(i,s,n) for(int i = (s);i<(int)(n);i++)

int main(){
    int a , b , c , d , e;
    cin >> a >> b >> c >> d >> e;
    cout << 15 - (a + b + c + d + e) << endl;
}

Measured memory_bytes: 3636
#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>;
//pow(x,n)
//cout << fixed << setprecision(桁数);
//string = to_string(数値)
//int = stoi(文字列)
//(int)(char-'0')
//string = itoa(int)


int main() {
    int n; cin >> n;
    cout << fixed << setprecision(10);
    cout << n*2*M_PI << endl;
}





Measured memory_bytes: 3784
#include<iostream>
#include<string>
#include<algorithm>
#include<cstdlib>
#include<cmath>

using namespace std;

int main(){


	char a;
	char b;

	cin >> a >> b;

	if(a == 'H'){
		if(b == 'H'){
			cout << "H";
		}else{
			cout << "D";
		}
	}else if(a == 'D'){
		if(b == 'H'){
			cout << "D";
		}else{
			cout << "H";
		}
	}


	return 0;

}


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

int main()
{
    int n,i,j,p,x;
    cin>>n;
    int a[n],b[n];

    for(i=0;i<n;i++)
    {
        scanf("%d",&a[i]);
        b[i] = a[i];
    }
    sort(a,a+n,greater<int>());
    p=a[0];x=a[1];
    for(i=0;i<n;i++)
    {
        if(p== b[i]) printf("%d\n",x);
        else printf("%d\n",p);
    }


    return 0;
}


Measured memory_bytes: 3200
import java.util.Scanner;

public class Main {

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

		double a = scan.nextDouble();
		double b = scan.nextDouble();
		double C = scan.nextDouble();

		double h = Math.sin(Math.PI * C / 180) * b;
		double S = a * h / 2;
		double L = a + b + Math.sqrt(a * a + b * b - 2 * a * b * Math.cos(Math.PI * C / 180));

		System.out.println(S);
		System.out.println(L);
		System.out.println(h);
		scan.close();
		System.exit(0);
	}

}

Measured memory_bytes: 28036
#include <bits/stdc++.h>
using namespace std;
typedef pair<int,int> P;
int main(){
    int N,M;cin >> N >> M;
    vector<P> ab(M);
    for(int i=0; i<M; i++){
        int a,b;
        cin >> a >> b;
        ab[i]=P(b,a);
    }
    sort(ab.begin(),ab.end());
    int fall=0;
    int ans=0;
    for(int i=0; i<M; i++){
        if(ab[i].second<=fall&&fall<ab[i].first) continue;
        else{
            fall=ab[i].first-1;
            ans++;
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 1024
S = input()
N = len(S)
l = []
for i in range(N):
    if S[i] == "A" or S[i] == "C" or S[i] == "G" or S[i] == "T":
        l.append(1)
    else:
        l.append(0)

#print(l)

ans = 0

for i in range(N):
    for j in range(i, N):
        tf = True
        for k in range(i, j + 1):
            if l[k] == 0:
                tf = False
        if tf == True:
            ans = max(ans, j - i + 1)
print(ans)


Measured memory_bytes: 9076
import java.util.*;
import java.lang.*;
public class Main{
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);

		String S = sc.next();
		S = "A" + S;
		if( S.length()==3 ){
			System.out.println(S.charAt(1)==S.charAt(2)?1+" "+2:"-1"+" "+"-1");          
        }else{          
		for( int i=1; i<=S.length()-3; i++ ){
			char ch1 = S.charAt(i);
			char ch2 = S.charAt(i+1);
			char ch3 = S.charAt(i+2);
			if( ch1==ch2 || ch1==ch3 || ch2==ch3 ){
				System.out.println(i+" "+(i+2));
				break;
			}
			if( i==S.length()-3 ){
				System.out.println("-1"+" "+"-1");
			}
		}
        }          
	}
}


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

int main()
{    int M,N;
     cin>>N;
     cin>>M;
    int numbers[M], sum = 0;



    for (int i = 0; i <M; ++i)
    {
        cin >> numbers[i];
        sum += numbers[i];
    }
    if(sum>N)
    {
        cout<<-1<<endl;
        }

    else if(sum<N)
    {
        cout<<(N-sum)<<endl;
    }
    else
    {
        cout<< 0<<endl;
    }


    return 0;
}


Measured memory_bytes: 3192
int main()
{
  int n;
  scanf("%d", &n);
  int b[n - 1], i;
  for (i = 0; i < n - 1; i++)
    scanf("%d", &b[i]);
  int a[i];
  for (i = 0; i < n - 1; i++)
  {
    if (i == 0)
    {
      a[i] = b[i];
      a[i + 1] = b[i];
    }
    else if (i != 0)
    {
      if (a[i] > b[i])
        a[i] = b[i];
      a[i + 1] = b[i];
    }
  }
  int sum = 0;
  for (i = 0; i < n; i++)
    sum += a[i];
  printf("%d", sum);
}

Measured memory_bytes: 128
using System;
namespace atcorderpractice
{
    class Mainclass
    {
        public static void Main(string[] args)
        {
            string[] input = Console.ReadLine().Split(' ');
            int n = int.Parse(input[0]);
            int rate = int.Parse(input[1]);

            if (n >= 10)
            {
                Console.WriteLine(rate);
            }
            else
            {
                Console.WriteLine(rate+(100 * (10 - n)));
            }

            

            


        }
    }
}

Measured memory_bytes: 13140
N = tonumber(io.read())

WU = {}

pW = io.read()
WU[pW] = true

ans = "Yes"

for v = 2, N do
  Wx = io.read()

  if WU[Wx] or string.match(string.reverse(pW), "%a") ~= string.match(Wx, "%a") then
    ans = "No"
    break
  end
  
  WU[Wx] = true

  pW = Wx

end

print(ans)

Measured memory_bytes: 760
a,b,m = map(int,input().split())
a = list(map(int,input().split()))
b = list(map(int,input().split()))
c = [tuple(map(int,input().split())) for i in range(m)]
p = min(a)+min(b)
for t in c:
    p = min(p,a[t[0]-1]+b[t[1]-1]-t[2])
print(p)

Measured memory_bytes: 29032
#include<iostream>
#include<cstdio>
#include<algorithm>
using namespace std;
int a[500000];
int all = 0;
int b[250000], c[250000];
void merge_sort(int left, int midle, int right) {
	for (int i = 0; i < midle - left; i++) {
		b[i] = a[i + left];
	}
	for (int i = 0; i < right - midle; i++) {
		c[i] = a[i + midle];
	}
	int j = 0;
	int k = 0;
	for (int i = left; i < right; i++) {
		if (k==right-midle||(j<midle-left&& b[j]<=c[k]))
		{
			a[i] = b[j];
			j++;
		}
		else{
			a[i] = c[k];
			k++;
		}
		all++;
	}
}
void merge(int left, int right) {
	if (left+1 <right)
	{
		int mid = (left + right) / 2;
		merge(left, mid);
		merge(mid, right);
		merge_sort(left, mid, right);
	}
}
int main(void) {
	int n;
	cin >> n;
	for (int i = 0; i < n; i++) {
		scanf("%d", &a[i]);
	}
	merge(0, n);
	for (int i = 0; i < n; i++) {
		if (i) cout << " ";
		cout << a[i];
	}
	cout << endl << all << endl;
}


Measured memory_bytes: 7048
#include<bits/stdc++.h>
using namespace std;
#define sc(x) scanf("%d",&x)
#define sc2(x,y) scanf("%d%d",&x, &y)
#define sc3(x,y,z) scanf("%d%d%d",&x, &y, &z)
#define pr(a) printf("%d\n",a)
#define all(v) (v).begin(),(v).end()
#define rall(v) (v).rbegin(),(v).rend()
#define ll long long
#define F first
#define S second
#define inf INT_MAX
const int N = 1e5 + 5;
int n, m, x, y, k, ans;
int a[15], sum;
int main(){

	string s[55], r[55];
	cin >> n >> m;
	for (int i = 0; i < n; i++)cin >> s[i];
	for (int j = 0; j < m; j++)cin >> r[j];
	
	for (int i = 0; i < n; i++){
		for (int j = 0; j < n; j++){
			bool f = 1;
			for (int k = 0; k < m; k++){
				for (int l = 0; l < m; l++){
					
					if (s[(k + i)%n][(l + j)%n] != r[k][l])f = 0;
				}
			}
			if (f)ans = 1;
		}
	}
	if (ans == 1)puts("Yes");
	else puts("No");
	
	return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<iomanip>
#include<vector>
#include<algorithm>
#include<map>
#include<array>
#include<cstring>
#include<numeric>
#include<string>
#include<set>
#include<cstdio>
#include<cmath>
#include<unordered_map>
#include<bitset>
typedef long long ll;
typedef long double ld;
using namespace std;

int main()
{
    int n;
    cin>>n;
    cout<<n+(n*n)+(n*n*n)<<"\n";
    return 0;
}


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

typedef long long ll;

//#define DMY_IN

#define MOD 1000000007

// x^n ( mod M ) を求める
//  例えば n = 10 だとすると
//  x^10 = x^(2+8) = x^2 * x^8 = x^2 * ((x^2)^2)^2
//  10 = 'b1010
ll powmod( ll x, ll n) {
  ll ans = 1;
  while ( n > 0 ) {
    if (n & 1) ans = (ans * x) % MOD;
    x = (x * x) % MOD;
    n >>= 1;
  }
  return ans;
}

// MODの逆元
//  a^(p-1) mod p = 1
//  a * a^(p-2) mod p = 1
//  a^(p-2) mod p = 1 / a mod p
ll inv( ll a ) {
  ll x = 1;
  for ( ll i=1; i<a+1; ++i ) {
    x = (i * x) % MOD;
  }
  return powmod( x, MOD-2 ) % MOD;
}

// n C r mod M
//  = n! / ( r! * (n-r)! )
//  = n * (n-1) * (n-2) * ... * (n-r+1) + (r!)^-1 
ll comb( ll n, ll r ) {
  ll ans = 1;
  for ( ll i=n; i>(n-r); --i ) {
    ans = (ans * i) % MOD;
  }
  return (ans * inv(r)) % MOD;
}

int main() {
  int N,M,K;
#ifdef DMY_IN
#else
  cin >> N >> M >> K;
#endif

//  std::chrono::system_clock::time_point  start, end; // 型は auto で可
//  start = std::chrono::system_clock::now(); // 計測開始時間

  // 2点駒を置いた際、残りの駒を置く方法の組み合わせ数
  // (N*M-2) C (K-2)
  ll c = comb( N*M-2, K-2 );
  
  ll ans = 0;

  // X方向
  // ２点間の距離 d
  ll tmpX = ((((N * N)) % MOD) * c ) % MOD;
  for (ll d=1; d<M; ++d ) {
    ans = (ans + (((tmpX * d) % MOD) * (M-d)) % MOD ) % MOD;
  }
//  cout << ans << " " << tmpX << " " << c << endl;
  
  // Y方向
  ll tmpY = ((((M * M)) % MOD) * c ) % MOD;
  for (ll d=1; d<N; ++d ) {
    ans = (ans + (((tmpY * d) % MOD) * (N-d)) % MOD ) % MOD;
  }

  
  cout << ans << endl;

//  end = std::chrono::system_clock::now();  // 計測終了時間
//  double elapsed = std::chrono::duration_cast<std::chrono::milliseconds>(end-start).count(); //処理に要した時間をミリ秒に変換
//  std::cout << elapsed << " ms" << std::endl;
  
}




Measured memory_bytes: 256
#include <bits/stdc++.h>
#ifdef __DEBUG__
    #define DBG(X) cout << #X << " = " << (X) << endl;
    #define SAY(X) cout << (X) << endl;
#else
    #define DBG(X)
    #define SAY(X)
#endif

using namespace std;

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

int dx[]={1, 0, -1, 0, 1,-1, 1,-1};
int dy[]={0, 1, 0, -1, 1, 1,-1,-1};
const int INT_INF = (int)(2e9);
const ll  LL_INF = (ll)(2e18);

inline void fast_io() { ios_base::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr); };
template<typename T, typename S> inline ostream& operator<<(ostream& os, const pair<T, S> p) { cout << "[" << p.first << ";" << p.second << "]"; return os; }
template<typename T, typename S> inline ostream& operator<<(ostream& os, const map<T, S> p) { for (auto el : p) cout << "[" << el.first << ";" << el.second << "]"; return os; }
template<typename T> inline ostream& operator<<(ostream& os, const vector<T>& v) { for (auto el : v) cout << el << " "; return os; }
template<typename T> inline ostream& operator<<(ostream& os, const deque<T>& v) { for (auto el : v) cout << el << " "; return os; }
template<typename T> inline ostream& operator<<(ostream& os, const set<T>& v) { for (auto el : v) cout << el << " "; return os; }
template<typename T> inline vector<T> fetch_vec(int sz) { vector<T> ret(sz); for (auto& elem : ret) cin >> elem; return ret; }

int a,b,c;
void input(){
    fast_io();
    cin >> a >> b >> c;
}

int solve(){
    int ans;
    if(a==b) ans = c;
    else if(b==c) ans = a;
    else ans = b;
    cout << ans << endl;
    return 0;
}   

int main()
{
    input();
    solve();
    return 0;
}

Measured memory_bytes: 256
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>

using namespace std;

//vector string deque break continue
#define forn(i, s, f) for (int i = (int)s; i < (int)f; i++)
#define ll long long
#define ull unsigned long long
#define ld long double
#define pii pair <int, int>
#define fs first
#define sc second
#define pf push_front
#define pb push_back
#define pop_f pop_front
#define pop_b pop_back
#define eb emplace_back
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define sz(x) (int)(x).size()

template <typename T> istream& operator>>(istream& in, vector <T>& a) {for (auto& i : a) in >> i; return in;}
template <typename T> ostream& operator<<(ostream& out, vector <T>& a)  {for (auto& i : a) out << i << " "; return out;}
template <typename T, typename U> void chkmin(T& a, U b) {if (a > b) a = b;}
template <typename T, typename U> void chkmax(T& a, U b) {if (a < b) a = b;}

int main() {
    ios_base::sync_with_stdio(0), cin.tie(0);
    int n, w;
    cin >> n >> w;
    const int MX_COST = 1e5;
    vector <long long> dp(MX_COST + 1, 1e18);
    dp[0] = 0;
    forn (i, 0, n) {
        int weight, cost;
        cin >> weight >> cost;
        for (int j = MX_COST; j >= cost; --j)
            chkmin(dp[j], dp[j - cost] + weight);
    }
    for (int j = MX_COST; j >= 0; --j)
        if (dp[j] <= w)
            return cout << j, 0;
    return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<b;i++)
#define rrep(i,a,b) for(int i=a;i>=b;i--)
#define fore(i,a) for(auto &i:a)
#define all(x) (x).begin(),(x).end()
#pragma GCC optimize ("-O3")
using namespace std; void _main(); int main() { cin.tie(0); ios::sync_with_stdio(false); _main(); }
typedef long long ll; const int inf = INT_MAX / 2; const ll infl = 1LL << 60;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a = b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a = b; return 1; } return 0; }

constexpr int MAX_N = 100;
int N;
int L[MAX_N * 2];

void _main() {
  cin >> N;
  rep(i, 0, 2 * N) cin >> L[i];
  sort(L, L + (N * 2));

  int ans = 0;
  rep(i, 0, N) ans += L[i*2];
  cout << ans << "\n";
}

Measured memory_bytes: 256
N, M = map(int, input().split())
A = [input() for _ in range(N)]
B = [input() for _ in range(M)]

for i in range(N-M+1):
    for j in range(N-M+1):
        if A[i][j] == B[0][0]:
            flg = True
            for k in range(M):
                if flg:
                    for l in range(M):
                        if A[i+k][j+l] != B[k][l]:
                            flg = False
                            break
            if flg:
                print('Yes')
                quit()
print('No')
                    

Measured memory_bytes: 3064
# AtCoder
N = int(input())
l = [list(map(int, input().split())) for i in range(N)]

m = sorted(l, key=lambda x: x[1])
work = 0

for i in range(N):
    work += m[i][0]
    if work > m[i][1]:
        print('No')
        exit()

print('Yes')


Measured memory_bytes: 89560
import java.util.*;
import java.io.*;

public class Main {
    public static void main(String[] args) {
        FastScanner sc = new FastScanner();
        String s = sc.next();
        String t = sc.next();
        int ans = 0;
        for (int i = 0; i < 3; i++) {
            if (s.charAt(i) == t.charAt(i)) {
                ans++;
            }
        }
        System.out.println(ans);
    }
}

class FastScanner {
    private final InputStream in = System.in;
    private final byte[] buffer = new byte[1024];
    private int ptr = 0;
    private int buflen = 0;

    private boolean hasNextByte() {
        if (ptr < buflen) {
            return true;
        } else {
            ptr = 0;
            try {
                buflen = in.read(buffer);
            } catch (IOException e) {
                e.printStackTrace();
            }
            if (buflen <= 0) {
                return false;
            }
        }
        return true;
    }

    private int readByte() {
        if (hasNextByte())
            return buffer[ptr++];
        else
            return -1;
    }

    private static boolean isPrintableChar(int c) {
        return 33 <= c && c <= 126;
    }

    public boolean hasNext() {
        while (hasNextByte() && !isPrintableChar(buffer[ptr]))
            ptr++;
        return hasNextByte();
    }

    public String next() {
        if (!hasNext())
            throw new NoSuchElementException();
        StringBuilder sb = new StringBuilder();
        int b = readByte();
        while (isPrintableChar(b)) {
            sb.appendCodePoint(b);
            b = readByte();
        }
        return sb.toString();
    }

    public long nextLong() {
        if (!hasNext())
            throw new NoSuchElementException();
        long n = 0;
        boolean minus = false;
        int b = readByte();
        if (b == '-') {
            minus = true;
            b = readByte();
        }
        if (b < '0' || '9' < b) {
            throw new NumberFormatException();
        }
        while (true) {
            if ('0' <= b && b <= '9') {
                n *= 10;
                n += b - '0';
            } else if (b == -1 || !isPrintableChar(b)) {
                return minus ? -n : n;
            } else {
                throw new NumberFormatException();
            }
            b = readByte();
        }
    }

    public int nextInt() {
        long nl = nextLong();
        if (nl < Integer.MIN_VALUE || nl > Integer.MAX_VALUE)
            throw new NumberFormatException();
        return (int) nl;
    }

    public double nextDouble() {
        return Double.parseDouble(next());
    }
}


Measured memory_bytes: 21332
import java.util.*;
public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int a=sc.nextInt();
		int b=sc.nextInt();
		int[] c= new int[b];
		int d=a;
		int f=a;
		for(int i =0;i<b;i++) {
			c[i]=sc.nextInt();
		}
		for(int i =0;i<b;i++) {
			if(d==c[i]) {
				d++;
				i=-1;
			
			}
		}
		for(int i =0;i<b;i++) {
			if(f==c[i]&&f>0) {
				f--;
				i=-1;
			
			}
		}
		if(Math.abs(d-a)>=Math.abs(f-a)) {
		System.out.println(f);
		}else {
			System.out.println(d);
		}
		
	}

}


Measured memory_bytes: 36016
#include <algorithm>
#include <bitset>
#include <climits>
#include <cmath>
#include <cstdio>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <unordered_map>
#include <vector>

#define MOD 1000000007
#define MOD2 998244353
#define int long long
#define double long double
#define EPS 1e-9
//#define PI 3.14159265358979

#define rep(i, n) for (int i = 0; i < (int)(n); i++)

using namespace std;

template < typename T >
ostream &operator<<(ostream &os, const vector< T > &A) {
	for (int i = 0; i < A.size(); i++)
		os << A[i] << " ";
	os << endl;
	return os;
}
template <>
ostream &operator<<(ostream &os, const vector< vector< int > > &A) {
	int N = A.size();
	int M;
	if (N > 0)
		M = A[0].size();
	for (int i = 0; i < N; i++) {
		for (int j = 0; j < M; j++)
			os << A[i][j] << " ";
		os << endl;
	}
	return os;
}

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

struct edge {
	int from, to, d, c;
	edge(int _from = 0, int _to = 0, int _d = 0, int _c = 0) {
		from = _from;
		to = _to;
		d = _d;
		c = _c;
	}
	bool operator<(const edge &rhs) const {
		return (d == rhs.d) ? (c < rhs.c) : (d < rhs.d);
	}
};
struct aabb {
	int x1, y1, x2, y2;
	aabb(int x1, int y1, int x2, int y2) : x1(x1), y1(y1), x2(x2), y2(y2) {}
};

typedef vector< edge > edges;
typedef vector< edges > graph;
struct flow {
	int to, cap, rev, cost;
	flow(int to = 0, int cap = 0, int rev = 0, int cost = 0) : to(to), cap(cap), rev(rev), cost(cost) {}
};
typedef vector< vector< flow > > flows;

const int di[4] = {0, -1, 0, 1};
const int dj[4] = {-1, 0, 1, 0};
const int ci[5] = {0, 0, -1, 0, 1};
const int cj[5] = {0, -1, 0, 1, 0};
const ll LINF = LLONG_MAX / 2;
const int INF = INT_MAX / 2;
const double PI = acos(-1);

int pow2(int n) { return 1LL << n; }
template < typename T, typename U >
bool chmin(T &x, const U &y) {
	if (x > y) {
		x = y;
		return true;
	}
	return false;
}
template < typename T, typename U >
bool chmax(T &x, const U &y) {
	if (x < y) {
		x = y;
		return true;
	}
	return false;
}

struct initializer {
	initializer() {
		cout << fixed << setprecision(20);
	}
};
initializer _____;

int N, M, K, T, Q, H, W;
signed main() {
	cin >> N;
	cout << N * 2 * PI << endl;
	return 0;
}

Measured memory_bytes: 3728
import java.io.{BufferedReader, InputStream, InputStreamReader, PrintWriter}
import java.util.StringTokenizer

import scala.collection.mutable
import scala.util.Sorting
import math.{abs, max, min}
import scala.collection.mutable.{ArrayBuffer, ListBuffer}
import scala.reflect.ClassTag

object Main {
  val MOD = 1000000007
  val out = new PrintWriter(System.out)
  def solve(): Unit = {
    val sc = new InputReader(System.in)
    val N = sc.nextInt()
    var two, four = 0
    rep(N) { _ =>
      val a = sc.nextInt()
      if (a % 4 == 0) four += 1
      else if (a % 2 == 0) two += 1
    }
    val one = N - two - four
    val ok = four + 1 >= one + (if (two > 0) 1 else 0)
    val ans = if (ok) "Yes" else "No"

    out.println(ans)
  }


  def main(args: Array[String]): Unit = {
    solve()
    out.flush()
  }


  class InputReader(val stream: InputStream) {
    private val reader = new BufferedReader(new InputStreamReader(stream), 32768)
    private var tokenizer: StringTokenizer = null

    def next: String = {
      while (tokenizer == null || !tokenizer.hasMoreTokens)
        tokenizer = new StringTokenizer(reader.readLine)
      tokenizer.nextToken
    }

    def nextInt(): Int = next.toInt
    def nextLong(): Long = next.toLong
    def nextChar(): Char = next.charAt(0)
  }

  private def rep(n: Int)(f: Int => Unit): Unit = (0 until n) foreach f

  private def map[@specialized A: ClassTag](n: Int)(f: Int => A): Array[A] = {
    val res = Array.ofDim[A](n)
    (0 until n) foreach (i => res(i) = f(i))
    res
  }

  private implicit class ArrayOpts[A](val as: Array[A]) extends AnyVal {
    def maxByOpt[B: Ordering](f: A => B): Option[A] = {
      if (as.nonEmpty) Some(as.maxBy(f)) else None
    }

    def grpBy[K](f: A => K): mutable.Map[K, ArrayBuffer[A]] = {
      val map = mutable.Map.empty[K, ArrayBuffer[A]]
      rep(a => map.getOrElseUpdate(f(a), ArrayBuffer()) += a)
      map
    }

    def rep(f: A => Unit): Unit = {
      as.indices foreach (i => f(as(i)))
    }

    def sumBy[B](f: A => B)(implicit num: Numeric[B]): B = {
      var sum = num.zero
      rep(a => sum = num.plus(sum, f(a)))
      sum
    }
  }

  private implicit class IterableOpts[A](val as: Iterable[A]) extends AnyVal {
    def sumBy[B](f: A => B)(implicit num: Numeric[B]): B = {
      as.foldLeft(num.zero)((acc, a) => num.plus(acc, f(a)))
    }
  }

  def pow(x: Int, n: Int): Int = {
    n match {
      case 0 => 1
      case _ =>
        val r = pow(x * x, n / 2)
        if (n % 2 == 1) r * x else r
    }
  }
}


Measured memory_bytes: 38236
#include <iostream>
#include <cstdio>
#include <vector>
#include <string>
#include <deque>
#include <memory.h>

#define rep(idx, max)			for(int idx = 0, idx##Max = (max); idx < idx##Max; idx ++)
#define rrep(idx, min, max)	for(int idx = (min), idx##Max = max; idx < idx##Max; idx ++)
#define erep(idx, min, max)	for(int idx = (min), idx##Max = max; idx <= idx##Max; idx ++)

#define rev(idx, max)			for(int idx = (max) - 1; idx >= 0; idx --)
#define rrev(idx, min, max)	for(int idx = (max) - 1, idx##Min = (min); idx >= idx##Min; idx --)
#define erev(idx, min, max)	for(int idx = (max), idx##Min = (min); idx >= idx##Min; idx --)

#define foreach(it, obj)	for(auto it = obj.begin(), it##End = obj.end(); it >= it##End; it ++)

using namespace	std;

class CCalc
{
	string	s_;
	int	pos_;
	
	int	IsDigit(int x)	{	return(x <= '9' && x >= '0');	}
	void	SkipSpace()
	{
		cout << "Skipping...";
		for(int c = s_[pos_]; (c == ' ' || c == '\t') && pos_ < s_.size(); pos_ ++);
		cout << "OK" << endl;
	}
	int	Number()
	{
		int num = 0;
		while(IsDigit(s_[pos_]))	{	num	= num * 10 + s_[pos_ ++] - '0';	}
		return(num);
	}
	int	Factor()
	{
		int val;
		if(pos_ >= s_.size())	{	cout << "warning: Out of bounds!" << endl;	}
		if(IsDigit(s_[pos_]))
		{
			val = Number();
			return(val);
		}
		pos_ ++;
		val	= Expr();
		pos_ ++;
		return(val);
	}
	int	Term()
	{
		int	val1	= Factor();
		while(s_[pos_] == '*' || s_[pos_] == '/')
		{
			char	op	= s_[pos_ ++];
			int val2	= Factor();
			switch(op)
			{
				case '*':	val1 *= val2;	break;
				case '/':	val1 /= val2;	break;
			}
		}
		return(val1);
	}
	int	Expr()
	{
		int	val1	= Term();
		while(s_[pos_] == '+' || s_[pos_] == '-')
		{
			char	op	= s_[pos_ ++];
			int val2	= Term();
			switch(op)
			{
				case '+':	val1 += val2;	break;
				case '-':	val1 -= val2;	break;
			}
		}
		return(val1);
	}
	
public:
	int	Eval(string &expression)
	{
		pos_	= 0;
		int pos = 0;
		s_.resize(expression.size());
		rep(i, expression.size())
		{
			if(expression[i] != ' ')
			{	s_[pos ++] = expression[i];	}
		}
		return(Expr());
	}
};

int main()
{
	CCalc	calc;
	string	expression;
	int tc;
	
	for(cin >> tc, cin.ignore(); tc > 0; tc --)
	{
		getline(cin, expression);
		cout << calc.Eval(expression) << endl;
	}
	
//	while(getline(cin, expression), expression.size())
//	{	::printf("%s = %d\n", expression.c_str(), calc.Eval(expression));	}
}

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

int main() {
  int A , B;
  cin >> A >> B;
  int i = A;
  int sum = 0;
  while(i <= B ){
    string s = std::to_string(i);
    if(s[0] == s[4] && s[1] == s[3]){
    sum++;
    }
      i++;
  }
    cout << sum << endl;
}


Measured memory_bytes: 256
#include<stdio.h>
int linearSearch(int*,int,int);

int main(){
  int n,q;
  int i=0;
  int count=0;
  scanf("%d",&n);
  int S[n];
  for(i=0;i < n;i++){
    scanf("%d",&S[i]);
  }
  
  scanf("%d",&q);
  int T[q];
  for(i=0;i < q;i++){
    scanf("%d",&T[i]);
    if(linearSearch(S,T[i],n) == 1) count++;
  }
  printf("%d\n",count);
  return 0;
}

int linearSearch(int *s,int k,int n){
  int i = 0;
  s[n]=k;
  while(s[i] != k){
    i++;
    if(n==i)
      return 0;
  }
  return 1;
}



Measured memory_bytes: 2104
#include <bits/stdc++.h>
using namespace std;
#define ll int64_t
#include <cstdlib> 
#include <math.h>
#include<cstdio>
#include<cstring>
#define FOR(I, A, B) for (ll I = (A); I <= (B); I++)
#define IOS ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define fo(i,n) for(ll i=0;i<n;i++)
#define sz(a) ll((a).size())
#define pb push_back
#define all(c) (c).begin(),(c).end()
#define tr(c,i) for(auto i = (c).begin(); i != (c).end(); i++)
#define present(c,x) ((c).find(x) != (c).end())
#define cpresent(c,x) (find(all(c),x) != (c).end())
#define dbg(x) cout << #x << " = " << x << endl
#define dbg2(x,y) cout << #x << " = " << x << ", " << #y << " = " << y << endl
#define dbg3(x,y,z) cout << #x << " = " << x << ", " << #y << " = " << y << ", " << #z << " = " << z << endl
#define dbg4(x,y,z,q) cout << #x << " = " << x << ", " << #y << " = " << y << ", " << #z << " = " << z << ", " << #q << " = " << q << endl
#define scan(char_array) scanf("%[^\n]s",&char_array);


ll dist[100005][3];
vector<ll> adj[100005];

int main(){

	ll n,m;
	cin>>n>>m;
	ll aa,bb;
	fo(i,m){
		cin>>aa>>bb;
		adj[aa].pb(bb);
	}
	fo(i,100005){
		fo(j,3){
			dist[i][j]=10000000000000000;
		}
	}
	queue<ll> q;
	ll s,t;
	cin>>s>>t;
	dist[s][0]=0;
	q.push(s);
	bool can;
	while(!q.empty()){
		ll tmp=q.front();
		
		q.pop();
		for(auto j:adj[tmp]){
			    can=false;

			
				if(dist[j][1]>dist[tmp][0]+1){
					dist[j][1]=dist[tmp][0]+1;
					can=true;
				}
				if(dist[j][0]>dist[tmp][2]+1){
					dist[j][0]=dist[tmp][2]+1;
					can=true;
				}
				if(dist[j][2]>dist[tmp][1]+1){
					dist[j][2]=dist[tmp][1]+1;
					can=true;
				}
				if(can) q.push(j);
			    
		}
	}
	//dbg(dist[2][1]);
	if(dist[t][0]==10000000000000000) cout<<-1<<endl;
	else cout<<(dist[t][0]/3)<<endl;


}


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

bool isprime(int n){
    double rootn = sqrt(n);
    if (n < 2){
        return false;
    }
    else if (n == 2){
        return true;
    }
    else if (n % 2 == 0){
        return false;
    }
    else{
        for(int i = 3; i <= rootn; i += 2){
            if(n % i == 0){
                return false;
            }
        }
        return true;
    }
}


int main(){
    int R;
    cin >> R;
    cout << M_PI * R * 2 << endl;
    return 0;
}

Measured memory_bytes: 3684
#include <stdio.h>

// 線形探索
int search(int A[], int n, int key)
{
    int i = 0;
    A[n] = key;
    while (A[i] != key)
    {
        i++;
    }
    return i != n;
}

int main()
{
    int i, n, A[10000 + 1], q, key, sum = 0;

    // 配列の総数
    scanf("%d", &n);
    for (i = 0; i < n; i++)
    {
        scanf("%d", &A[i]);
    }

    // 子配列を受け取りつつ探索
    scanf("%d", &q);
    for (i = 0; i < q; i++)
    {
        scanf("%d", &key);
        if (search(A, n, key))
        {
            sum++;
        }
    }
    printf("%d\n", sum);
    return 0;
}


Measured memory_bytes: 2700
#include "bits/stdc++.h"
using namespace std;

int main() {
	long long A,B,N;
	cin >> A>>B>>N;
	//xは0 kara B-1 までみればいい
	long long m = min(N,B-1);
	long long ans = m * A / B;
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 3584
import java.util.*;
public class Main{
    public static void main(String[]args){
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int A = sc.nextInt();
        int B = sc.nextInt();
        
        int sum = 0;
        for(int i=1; i<=N; i++){
            int n = i;
            int digSum = 0;
            while(n >0){
                digSum += n%10;
                n/=10;
            }
            if(digSum >= A && digSum <=B) sum+= i;
        }
        System.out.println(sum);
    }
}


Measured memory_bytes: 23636
H, W = gets.split.map(&:to_i)
Ss = Array.new(H) { gets.chomp }

acc = Array.new(H + 1) { Array.new(W + 1, 0) }

H.times { |i| W.times { |j| acc[i + 1][j + 1] = (Ss[i][j] == '#' ? 1 : 0) } }
(H + 1).times { |i| W.times { |j| acc[i][j + 1] += acc[i][j] } }
H.times { |i| (W + 1).times { |j| acc[i + 1][j] += acc[i][j] } }

# p acc
ans = Array.new(H) do |i|
  Array.new(W) do |j|
    i1 = [i - 1, 0].max
    i2 = [i + 2, H].min
    j1 = [j - 1, 0].max
    j2 = [j + 2, W].min
    # p [i, j, i1, i2, j1, j2]
    if Ss[i][j] == '#'
      '#'
    else
      acc[i2][j2] - acc[i2][j1] - acc[i1][j2] + acc[i1][j1]
    end
  end
end

ans.each { |row| puts row.join }


Measured memory_bytes: 2172
#include <iostream>
#include <climits>
using namespace std;
int main()
{
    int n;
    cin >> n;
    //printf("%d \n", n);
    int input[n];
    for(int i = 0; i < n; i++){
        cin >> input[i];
    }
    long long int sum = 0;
    for(int i = 0; i < n; i++){
        sum = sum + input[i];
    }
    int max = input[0];
    for(int i = 0; i < n; i++){
        if(input[i] > max){
            max = input[i];
        }
    }
    int min = input[0];
    for(int i = 0; i < n; i++){
        if(input[i] < min){
            min = input[i];
        }
    }
    cout << min << " " << max << " " << sum << endl;
}


Measured memory_bytes: 3116
//It doesn't matter how slow you go, Unless you don't stop.
#include<iostream>
#include<algorithm>
#include<bitset>
 
#include<cmath>
#include<cstring>
#include<climits>
 
#include<deque>
#include<queue>
#include<vector>
#include<set>
#include<map>
#include<unordered_set>
#include<unordered_map>
 
#include<fstream>
#include<chrono>
using namespace std;
 
typedef long long LL;
typedef pair<LL,LL> p64;
typedef vector<LL> v64;
typedef map<LL,LL> mp64;
 
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define rep(i,s,e) for(long long i=s;i<=e;i++)
#define brep(i,s,e) for(long long i=s;i>=e;i--)
#define all(x) x.begin(),x.end()
#define mem(x,y) memset(x,y,sizeof(x))
#define DANGER std::ios::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL)
 
void solve()
{
     int n,m;cin>>n>>m;
     int sum = 0;
     for(int i=0;i<m;i++)
     {
         int a;cin>>a;
         sum +=a ;
     }
     if(sum>n)
     {
         cout<<"-1"<<endl;
     }
     else
     {
         cout<<n-sum<<endl;
     }

}
 
int main()
{
    DANGER;
    ofstream out("output.txt");
 
    auto start = chrono::high_resolution_clock::now();
    
    LL t = 1;
    // cin>>t;
    rep(test,1,t)
    {
        solve();
    }
    
    auto stop = chrono::high_resolution_clock::now();
    // auto duration = chrono::duration_cast<chrono::milliseconds>(stop - start); 
    // cout << "Time taken by function: " << duration.count() << " milliseconds" << endl;
}

Measured memory_bytes: 3652
#include <iostream>
#include <cmath>
#include <vector>
#include <map>
#include <stack>
#include <queue>
#include <set>
#include <algorithm>
#include <iomanip>
#include <string.h>

#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()

typedef long long lint;

using namespace std;

int main(){
  string N;
  cin>>N;
  int S=0;
  for(auto c:N){
    S+=c-'0';
  }
  // cerr<<S<<endl;
  cout<<(S%9==0?"Yes":"No")<<endl;
  return 0;
}


Measured memory_bytes: 3748