akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <cmath>
using namespace std;

bool is_palindrome(string s, int left, int right) {
    for(int i = 0; i < (right-left+1)/2; i++) {
        if (s[left+i] != s[right-i]) {
            return false;
        }
    }
    return true;
}

int main() {
    string s; // 長さは奇数
    cin >> s;
    int n = s.length();
    int p = (n-1) / 2, q = (n+3) / 2;
    n--; p--; q--;

    if (is_palindrome(s, 0, n) && is_palindrome(s, 0, p) && is_palindrome(s, q, n)) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
}

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

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

#define FOR(i, n, m) for (ll(i) = (m); (i) < (n); ++(i))
#define REP(i, n) FOR(i, n, 0)
#define OF64 std::setprecision(10)

const ll MOD = 1000000007;
const ll INF = (ll)1e15;

struct Vertex
{
    vector<int> node;
};

Vertex V[100005];
bool U[100005];
int S[2];

int main()
{
    int N;
    cin >> N;
    REP(i, N - 1)
    {
        int a, b;
        cin >> a >> b;
        a--;
        b--;
        V[a].node.push_back(b);
        V[b].node.push_back(a);
    }
    S[0] = S[1] = 0;
    queue<pll> q;
    q.push(pll(0, 0));
    q.push(pll(1, N - 1));
    U[0] = U[N - 1] = true;
    while (!q.empty())
    {
        pll t = q.front();
        q.pop();
        REP(i, V[t.second].node.size())
        {
            int n = V[t.second].node[i];
            if (U[n])
                continue;
            U[n] = true;
            S[t.first]++;
            q.push(pll(t.first, n));
        }
    }
    if (S[0] > S[1])
        cout << "Fennec" << endl;
    else
        cout << "Snuke" << endl;
    return 0;
}

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

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int N, K, X, Y;
  cin >> N >> K >> X >> Y;
  if(N <= K)
    cout << N * X << endl;
  else
    cout << X * K + (N - K) * Y << endl;
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
  long long int a, b, n;
  cin >> a >> b >> n;
  if(n < b){
    cout << (n * a / b) << endl;
  }else{
    cout << ((b - 1) * a / b) << endl;
  }
}

Measured memory_bytes: 3636
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define ll long long
int main(){
    ll x;
    ll kane=100;
    cin >>x ;
    ll cnt=0;
    while(1){
        cnt ++ ;
        kane += kane/100;
       
        if (kane >= x) break;

    }
    cout << cnt <<endl;
}

Measured memory_bytes: 3524
#include<bits/stdc++.h>
using namespace std;
int maxi(int a,int b,int c){
  if(a>=b&&a>=c)
    return a;
  else if(b>=a&&b>=c)
    return b;
  else return c;
}
int main(){
  int n;
  cin>>n;
  int a[n][3];
  for(int i=0;i<n;i++)
    cin>>a[i][0]>>a[i][1]>>a[i][2];
  int b[n][3];
  b[0][0]=a[0][0];
  b[0][1]=a[0][1];
  b[0][2]=a[0][2];
  for(int i=1;i<n;i++){
    b[i][0]=a[i][0]+max(b[i-1][1],b[i-1][2]);
    b[i][1]=a[i][1]+max(b[i-1][0],b[i-1][2]);
    b[i][2]=a[i][2]+max(b[i-1][0],b[i-1][1]);
  }
  cout<<maxi(b[n-1][0],b[n-1][1],b[n-1][2]);
  return 0;
}


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

#define F first
#define S second
#define PB push_back
#define PF push_front
#define MP make_pair
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
const int maxn = 5e3 + 10;
const int mod = 1e9 + 7;
int s[maxn], w[maxn];
int arr[maxn];

bool Compare (int fi, int se) {
	return s[fi] - w[se] < s[se] - w[fi];
}

ll dp[maxn];

int main() {
	int n;
	cin >> n;
	for (int i = 1; i <= n; i++) {
		cin >> s[i] >> w[i];
		arr[i] = i;
	}
	sort (arr + 1, arr + n + 1, Compare);
	memset (dp, 63, sizeof dp);
	dp[0] = 0;
	int ans = 0;
	for (int i = 1; i <= n; i++) {
		for (int j = i; j >= 1; j--) {
			if (dp[j - 1] <= s[arr[i]]) {
				dp[j] = min (dp[j], dp[j - 1] + w[arr[i]]);
			}
		}
	}
	for (int i = 1; i <= n; i++)
		if (dp[i] != dp[n + 1])
			ans = i;
	cout << ans << endl;
}


Measured memory_bytes: 384
S = list(str(input()))
T = list(str(input()))
listS = list(range(len(S)-1))
for i in range(len(S)):
    if S == T:
        print('Yes')
        break
    else:
        lastS = S[len(S)-1] 
        for j in listS[::-1]:
            S[j+1] = S[j]
        S[0] = lastS
        if i == len(S)-1:
            print('No')

Measured memory_bytes: 3064
#include<bits/stdc++.h>
#define ll long long
#define vl vector
#define pb push_back
#define ff first
#define ss second
using namespace std;

vl<ll> divisor(ll n)
{
    vl<ll> v;
    for(int i=1;i<=sqrt(n);i++)
    {
        if(n%i==0) 
        {
            if(n/i==i) v.pb(i);
            else
            {
                v.pb(i);
                v.pb(n/i);
            }
        }
    }
    return v;
}

int main()
{
    ll a,b,i,j,n,m,k,t;
    cin>>n>>k>>t;
    ll arr[n];
    for(i=0;i<n;i++) arr[i]=k;
    for(i=0;i<t;i++)
    {
        cin>>a;
        a--;
        arr[a]++;
    }
    for(i=0;i<n;i++) arr[i]-=t;
    for(i=0;i<n;i++)
    {
        if(arr[i]<=0) cout<<"No";
        else cout<<"Yes";
        cout<<endl;
    }
}

Measured memory_bytes: 4400
s = input()

if s=="SUN":
    print(7)
elif s=="MON":
    print(6)
elif s=="TUE":
    print(5)
elif s=="WED":
    print(4)
elif s=="THU":
    print(3)
elif s=="FRI":
    print(2)
elif s=="SAT":
    print(1)

Measured memory_bytes: 3060
INF = float('inf')
N = int(input())

dp = [INF for _ in range(N+1)]
dp[0] = 0

for i in range(1, N+1):
    # 1円玉を使う場合
    dp[i] = min(dp[i], dp[i-1] + 1)
    # 6べき円玉を使う場合
    power = 6
    while power <= i:
        dp[i] = min(dp[i], dp[i-power] + 1)
        power *= 6
    # 9べき円玉を使う場合
    power = 9
    while power <= i:
        dp[i] = min(dp[i], dp[i-power] + 1)
        power *= 9

print(dp[N])


Measured memory_bytes: 3864
#include<iostream>

int main(){

	int m, f, r;
	while (std::cin >> m >> f >> r){
		if (m == -1 && f == -1 && r == -1)break;

		if ((m == -1 || f == -1) || m + f < 30)std::cout << "F" << std::endl;
		else if (m + f >= 80)std::cout << "A" << std::endl;
		else if (m + f >= 65 && m + f < 80)std::cout << "B" << std::endl;
		else if (m + f >= 50 && m + f < 65)std::cout << "C" << std::endl;
		else if (m + f >= 30 && m + f < 50){
			if (r >= 50)std::cout << "C" << std::endl;
			else std::cout << "D" << std::endl;
		}
	}

	return 0;
}

Measured memory_bytes: 1160
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>	
#include<map>
#include<set>
#include<utility>
#include<cmath>
#include<cstring>
#include<queue>
#include<stack>
#include<cstdio>
#include<sstream>
#include<iomanip>
#include<assert.h>
#define loop(i,a,b) for(int i=a;i<b;i++) 
#define rep(i,a) loop(i,0,a)
#define pb push_back
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)
using namespace std;
//kaewasuretyuui
typedef long long ll;
typedef ll Def;
typedef pair<Def,Def> pii;
typedef vector<Def> vi;
typedef vector<vi> vvi;
typedef vector<pii> vp;
typedef vector<vp> vvp;
typedef vector<string> vs;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef pair<Def,pii> pip;
typedef vector<pip>vip;
//#define mt make_tuple
//typedef tuple<double,int,double> tp;
//typedef vector<tp> vt;
template<typename A,typename B>bool cmin(A &a,const B &b){return a>b?(a=b,true):false;}
template<typename A,typename B>bool cmax(A &a,const B &b){return a<b?(a=b,true):false;}
const double PI=acos(-1);
const double EPS=1e-7;
Def inf=sizeof(Def)==sizeof(long long)?2e18:1e9;
int dx[]={0,1,0,-1};
int dy[]={1,0,-1,0};
int LIS(vi in){//Longest Increasing Subsequence
	ll n=in.size();
	ll r=1;
	vi out(n+1,inf);
	rep(i,n){
		*lower_bound(all(out),in[i])=in[i];
	}
	return lower_bound(all(out),inf)-out.begin();
}
int main(){
	ll a,b,c,d;
	cin>>a>>b>>c>>d;
	if(a>c){
		swap(a,c);
		swap(b,d);
	}
	ll n;
	cin>>n;
	vp in;
	rep(i,n){
		ll x,y;
		cin>>x>>y;
		if(a<=x&&x<=c&&min(b,d)<=y&&y<=max(b,d)){
			if(b>d)x*=-1;
			in.pb({x,y});
		}
	}
	sort(all(in));
	vi lis;
	rep(i,in.size())lis.pb(in[i].second);
	ll co=LIS(lis);
	if(a==c||b==d){
		if(co)cout<<shosu(14)<<100*(abs(a-c)+abs(b-d))-20+10*PI<<endl;
		else cout<<100*(abs(a-c)+abs(b-d))<<endl;
	}else{
		if(min(abs(a-c),abs(b-d))+1==co)cout<<shosu(14)<<100*(abs(a-c)+abs(b-d))-20+10*PI-(co-1)*(20-20/4.*PI)<<endl;
		else cout<<shosu(14)<<100*(abs(a-c)+abs(b-d))-co*(20-20/4.*PI)<<endl;
	}
}








Measured memory_bytes: 9452
///*
#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;

int main() {
	
	vector<int> mountain(10);
	for (int number = 0; number < 10; number++)cin >> mountain[number];
	
	sort(mountain.rbegin(), mountain.rend());

	for (int number = 0; number != 3; number++)cout << mountain[number] << endl;

	return 0;
}
//*/


Measured memory_bytes: 3112
#include <stdio.h>

int c[50][50];
int w, h;

void visit(int i, int j) {
  int di[8] = {0, -1, -1, -1, 0, 1, 1, 1};
  int dj[8] = {1, 1, 0, -1, -1, -1, 0, 1};
  int ni, nj, r;

  c[i][j] = 0;
  for(r = 0; r < 8; r++) {
    ni = i + di[r];
    nj = j + dj[r];
    if(ni >=0 && ni < h && nj >= 0 && nj < w && c[ni][nj] == 1)
      visit(ni, nj);
  }
}

int main() {
  int i, j, count;
  while(1) {
    scanf("%d %d", &w, &h);
    if(w == 0 && h == 0) break;

    for(i = 0; i < h; i++) {
      for(j = 0; j < w; j++) {
	scanf("%d", &c[i][j]);
      }
    }

    count = 0;
    for(i = 0; i < h; i++) {
      for(j = 0; j < w; j++) {
	if(c[i][j] == 1) {
	  count++;
	  visit(i, j);
	}
      }
    }

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

Measured memory_bytes: 0
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;

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

    int n = scanner.nextInt();

    List<Integer> numbers = new ArrayList<>();
    for (int i = 0; i < n; i++) {
      numbers.add(scanner.nextInt());
    }

    int count = 0;


    List<Integer> numbers2 = new ArrayList<>();

    while (true) {

      List<Integer> nextNumbers = new ArrayList<>();

      boolean allEven = numbers.stream().allMatch(number -> {
        nextNumbers.add(number / 2);
        return number % 2 == 0;
      });

      if (allEven) {
        count++;

        numbers = nextNumbers;
      } else {
        break;
      }
    }

    System.out.println(count);
    scanner.close();
  }
}


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

const int LOG = 60;

int main() {
    int n;
    ll k;
    cin >> n >> k;
    vector<int> g(n);
    for (int i = 0; i < n; i++) cin >> g[i], g[i]--;

    vector<vector<int>> to(LOG + 1, vector<int>(n, 0));
    for (int i = 0; i < n; i++) to[0][i] = g[i];
    for (int i = 0; i < LOG; i++) {
        for (int j = 0; j < n; j++) {
            to[i + 1][j] = to[i][to[i][j]];
        }
    }

    int cur = 0;
    for (int i = 0; i < LOG; i++) {
        if (k >> i & 1) cur = to[i][cur];
    }
    cout << cur + 1 << endl;
}

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

#define rep(i,N) for(int i=0;i<(int)(N);++i)
#define rrep(i,N) for(int i=(int)(N)-1;i>=0;--i)
#define debug(x) cout<<#x<<"="<<x<<endl;
constexpr ll MOD=1000000007;
constexpr ll INF=1LL<<60;
template<class T> inline bool chmin(T& a,T b){if(a>b){a=b;return true;}return false;}
template<class T> inline bool chmax(T& a,T b){if(a<b){a=b;return true;}return false;}
template<typename T> void fail(T v){cout << v << endl;exit(0);}
//template end

void solve(){
    int N;
    cin>>N;
    vector<int> imos(100100,0);
    rep(i,N){
        int a,b;cin>>a>>b;a--;
        imos[a]++;imos[b]--;
    }
    int res=0;
    rep(i,100010)imos[i+1]+=imos[i];
    rep(i,100010)if(imos[i]>=i)res=i;
    cout<<res<<endl;
}

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(20);
    solve();
    return 0;
}


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

using namespace std;

#define debug(n) cerr << #n << ':' << n << endl;
#define dline    cerr << __LINE__ << endl;

using ll = long long;
template<class T, class U> using P = pair<T,U>;
template<class T> using Heap = priority_queue<T>;
template<class T> using heaP = priority_queue<T,vector<T>,greater<T>>;
template<class T,class U> using umap = unordered_map<T,U>;
template<class T> using uset = unordered_set<T>;

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

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

template<class T, size_t N, class U>
void Fill(T (&a)[N], const U&v){
    fill((U*)a,(U*)(a+N),v);
}

template<class T>
istream& operator >> (istream&is, vector<T>&v){
  for(auto&e:v)is >> e;
  return is;
}

inline void YN(const bool f, string y = "Yes", string n = "No"){
  if(f) cout << y << endl;
  else cout << n << endl;
}

int main(){
  int h,n; cin >> h >> n;
  vector<ll> v(n); cin >> v;  
  YN(accumulate(v.begin(), v.end(), 0LL) >= h);
  return 0;  
}


Measured memory_bytes: 1024
#include <iostream>
#include <queue>
#include <vector>
#include <string>
#include <map>
#include <set>
#include <algorithm>
#include <cmath>
#include <iomanip>

using namespace std;

#define REP(i,n) for(ll (i) = (0); (i) < (n); ++i)
#define PB push_back
#define MP make_pair
#define FI first
#define SE second
#define ALL(v) v.begin(),v.end()
#define INF 1100000000
#define LLINF 1000000000000000000LL
#define MOD 1000000007
#define Decimal fixed << setpresicion(20)


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

ll dp[500][500];
int main()
{
  ll N;
  cin >> N;
  vector<ll> a(N);
  REP(i, N) cin >> a[i];
  vector<ll> asum(a);
  REP(i, N-1) asum[i + 1] += asum[i];
  REP(i, N) REP(j, N) dp[i][j] = LLINF;
  REP(i, N) dp[i][i] = 0;

  for (int k = 1; k < N; k++) {
    REP(i, N) {
      if (i + k >= N) break;
      for (int a = i; a < i + k; a++) {
        dp[i][i + k] = min(dp[i][i + k], dp[i][a] + dp[a + 1][i + k]);
      }
      if (i > 0) dp[i][i + k] += asum[i + k] - asum[i - 1];
      else dp[i][i + k] += asum[i + k];
    }
  }
  cout << dp[0][N-1] << endl;
  return 0;
}

Measured memory_bytes: 1920
import java.util.Scanner;

/**
 *
 * @author psygn
 */
public class Main {

    /**
     * @param args the command line arguments
     */
    public static void main(String[] args) {

        Scanner scanner = new Scanner(System.in);
        int N = scanner.nextInt();
        int K = scanner.nextInt();
        String str = scanner.nextLine();
        int ans = (N - 1) / (K - 1);
        if ((N - 1) % (K - 1) > 0) {
            ans += 1;

        }
        System.out.println(ans);
    }
}

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

int main()
{
  int N, K;
  cin >> N >> K;
  int V[105] = {};
  for (int i = 0; i < N; i++)
  {
    cin >> V[i];
  }
  
  int mx_ans = 0;
  for (int k = 0; k <= K; k++) // 操作をk回行う
  {
    for (int a = 0; a <= k / 2; a++)
    {
      int put_out = k - a, put_in = a; // 出す回数はput_out、入れる回数はput_in
      if (put_out > N) continue;
      for (int b = 0; b <= put_out; b++)
      {
        int left = b, right = put_out - b; // 左から出す回数はleft、右から出す回数はright
        vector<int> negative = {}; // 負の価値を持つ宝石を「negative」に保存したい
        int ans = 0;
        for (int i = 0; i < left; i++) // 左から出す
        {
          ans += V[i];
          if (V[i] < 0) negative.push_back(V[i]);
        }
        for (int i = N - 1; i >= N - right; i--) // 右から出す
        {
          ans += V[i];
          if (V[i] < 0) negative.push_back(V[i]);
        }
        sort(negative.begin(), negative.end()); // negativeかつ絶対値の大きいのを入れたい
        for (int j = 0; j < put_in; j++) // 入れられる最高回数はput_in
        {
          if (negative.empty()) break;
          ans -= negative[0];
          negative.erase(negative.begin());
        }
        if (mx_ans < ans)
          mx_ans = ans;
      }
    }
  }
  
  cout << mx_ans << endl;
  return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <cstring>
#include <string>
#include <vector>
#include <set>
#include <map>
#include <utility>
#include <cstdlib>
#include <memory>
#include <queue>
#include <cassert>
#include <cmath>
#include <ctime>
#include <complex>
#include <bitset>
#include <fstream>
#include <unordered_map>
#include <unordered_set>
#include <numeric>

using namespace std;

#define ws ws_____________________
#define y1 y1_____________________
#define y0 y0_____________________
#define left left_________________
#define right right_______________
#define next next_________________
#define prev prev_________________
#define hash hash_________________

#define pb push_back
#define fst first
#define snd second
#define mp make_pair 
#define sz(C) ((int) (C).size())
#define forn(i, n) for (int i = 0; i < int(n); ++i)
#define ford(i, n) for (int i = int(n) - 1; i >= 0; --i)
#define all(C) begin(C), end(C)

typedef long long ll;
typedef unsigned long long ull;
typedef unsigned int uint;
typedef pair<int,int> pii;
typedef pair<ll, ll> pll;
typedef vector<ll> vll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<pii> vii;
typedef long double ld;
typedef complex<double> cd;

#ifdef LOCAL
#define eprintf(args...) fprintf(stderr, args), fflush(stderr)
#else
#define eprintf(...) ;
#endif

#define FILE_NAME "a"


ll k;

bool read() {
	if  (scanf("%lld", &k) < 1) {
		return 0;
	}
	return 1;
}

const int n = 50;

int brut(vll a) {
	int pos = max_element(all(a)) - a.begin();
	if  (a[pos] < sz(a)) {
		return 0;
	}
	for (auto& x : a) {
		++x;
	}
	a[pos] -= 1;
	a[pos] -= sz(a);
	return 1 + brut(a);
}

vll solve(ll k) {
	if  (k < n) {
		const ll x = n;
		ll small = x - n + (n - k - 1);
		ll big = x + (n - k);
		vll a(n);
		forn(i, n - k) {
			a[i] = small;
		}
		for (int i = n - k; i < n; ++i) {
			a[i] = big;
		}
		return a;
	}
	vll a = solve(k % n);
	for (auto& x : a) {
		x += k / n;
	}
	return a;
}

vll solve() {
	return solve(k);
}

int main() {
#ifdef LOCAL
	freopen(FILE_NAME ".in", "r", stdin);
	// freopen(FILE_NAME ".out", "w", stdout);
#endif

	while (read()) {
		vll a = solve();

		printf("%d\n", sz(a));
		for (ll x : a) {
			printf("%lld ", x);
		}
		puts("");

		// printf("BRUT = %d\n", brut(a));
	}

#ifdef LOCAL
	cerr.precision(5);
	cerr << "Time: " << fixed << (double) clock() / CLOCKS_PER_SEC << endl;
#endif
	return 0;
}


Measured memory_bytes: 256
import java.io.IOException;
import java.util.NoSuchElementException;

import java.io.InputStream;
import java.io.PrintWriter;

import java.util.Arrays;

@SuppressWarnings("unchecked")
public class Main {
    public static void main(String[] args) throws IOException {
        FastScanner fs = new FastScanner();
        PrintWriter out = new PrintWriter(System.out);

        final int N = fs.nextInt();

        int[] X = new int[N];

        for (int i = 0; i < N; i++) X[i] = fs.nextInt();

        int[] Y = new int[N];

        System.arraycopy(X, 0, Y, 0, X.length);

        Arrays.sort(Y);

        int left = Y[N / 2 - 1];
        int right = Y[N / 2];

        for (int i = 0; i < N; i++)
            out.println(X[i] <= left ? right : left);

        out.flush();
    }
}

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: 42160
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner in = new Scanner(System.in);
		String input = in.nextLine();
		int result = 700;
		for (int i = 0; i < 3; ++i) {
			if (input.charAt(i) == 'o') {
				result += 100;
			}
		}
		System.out.println(result);
		in.close();
	}

}


Measured memory_bytes: 21844
a = gets.chomp

h = {}
('a'..'z').each{|c|
  h[c] = 0
}

len = a.size
 
sum = 1 + len*(len+1)/2
a.each_char{|c|
  h[c] += 1
}
('a'..'z').each{|c|
  ct = h[c]
    sum -= ct*(ct+1)/2
}
p sum


Measured memory_bytes: 2172
n, k = [int(_) for _ in input().split()]
h = [int(_) for _ in input().split()]
inf = 1e9
dp = [inf] * n
dp[0] = 0
for i in range(1, n):
    cnt = 1
    while cnt <= k and i - cnt > -1:
        dp[i] = min(dp[i], dp[i - cnt] + abs(h[i] - h[i - cnt]))
        cnt += 1
print(dp[-1])

Measured memory_bytes: 54752
# -*- coding: utf-8 -*-

def main(a=''):
    # 整数の入力
    a = int(input())
    # a = int(a)
    # スペース区切りの整数の入力
    # b, c = map(int, input().split())
    # b, c = map(int, input())

    # # 文字列の入力
    # a = input()
    # 出力
    # print("{} {}".format(a+b+c, s))
    sum = 0
    for i in range(a+1):
        if i % 3 == 0:
            continue
        elif i % 5 == 0:
            continue
        else:
            sum += i
    print(sum)


if __name__ == '__main__':
    # main('1')
    # main('15')
    # main('1000000')
    main()

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

/* メモリ食い過ぎ注意 */
#define int long long

typedef long long ll;

ll gcd(ll a, ll b)
{
    if (a < b)
        gcd(b, a);
    if (b == 0)
        return a;
    int r;
    while ((r = a % b))
    {
        a = b;
        b = r;
    }
    return b;
}

/* define const */
const ll INF = (1ll << 60);
const ll MOD = (ll)1e9 + 7;
/* end defineing */

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

    if (c >= a && c <= b)
        cout << "Yes" << endl;
    else
        cout << "No" << endl;
}


Measured memory_bytes: 256
// https://atcoder.jp/contests/abc151/tasks/abc151_d
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define REP(i, n) FOR(i, 0, n)
#define REPR(i, n) for (int i = n - 1; i >= 0; i--)
#define FOR(i, s, n) for (int i = (s), i##_len = (n); i < i##_len; ++i)
#define ALL(obj) (obj).begin(), (obj).end()
#define ALLR(obj) (obj).rbegin(), (obj).rend()
#define DIV(a, b) ((a - 1) / b + 1)

vector<vector<int>> grid_bfs(vector<string> &s, char start,
                             const char &wall = '#') {
    const int vx[] = {0, 1, 0, -1}, vy[] = {1, 0, -1, 0};
    vector<vector<int>> min_cost(s.size(), vector<int>(s[0].size(), -1));
    queue<pair<int, int>> que;
    for (int i = 0; i < s.size(); i++) {
        for (int j = 0; j < s[i].size(); j++) {
            if (s[i][j] == start) {
                que.emplace(i, j);
                min_cost[i][j] = 0;
            }
        }
    }
    while (!que.empty()) {
        auto p = que.front();
        que.pop();
        for (int i = 0; i < 4; i++) {
            int ny = p.first + vy[i], nx = p.second + vx[i];
            if ((nx >= 0 && ny >= 0 && nx < s[0].size() && ny < s.size()) &&
                min_cost[ny][nx] == -1 && s[ny][nx] != wall) {
                min_cost[ny][nx] = min_cost[p.first][p.second] + 1;
                que.emplace(ny, nx);
            }
        }
    }
    return min_cost;
}

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

    int h, w;
    cin >> h >> w;
    vector<string> vs(h);
    for (int i = 0; i < h; i++) {
        cin >> vs[i];
    }

    // 最大値を探す
    int maxv = 0;
    REP(i, h) REP(j, w) {
        if (vs[i][j] == '.') {
            vector<string> t = vs;
            t[i][j] = 'S';
            vector<vector<int>> ret = grid_bfs(t, 'S');
            for (auto &x : ret) {
                for (auto &y : x) {
                    maxv = max(maxv, y);
                }
            }
        }
    }
    cout << maxv << endl;
    return 0;
}


Measured memory_bytes: 256
import java.util.*;
public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
    	int N = sc.nextInt(), M = sc.nextInt();
        int[] H = new int [N];
        for (int i=0; i<N; i++) {
        	H[i] = sc.nextInt();
        }
        int[] array = new int [N];
        for (int i=0; i<M; i++) {
            int a = sc.nextInt()-1, b = sc.nextInt()-1;
            array[a] = Math.max(array[a],H[b]);
            array[b] = Math.max(array[b],H[a]);
        }
        int ans = 0;
        for (int i=0; i<N; i++) {
            ans += (H[i] > array[i])?1: 0;
        }
        H = null; array = null;
        sc.close();
        System.out.println(ans);
	}
}

Measured memory_bytes: 60152
#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 <array>
#include <atomic>
#include <chrono>
#include <condition_variable>
#include <forward_list>
#include <future>
#include <initializer_list>
#include <mutex>
#include <random>
#include <ratio>
#include <regex>
#include <scoped_allocator>
#include <system_error>
#include <thread>
#include <tuple>
#include <typeindex>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>
using namespace std;
using ll = long long;
#define MAX_N 1000001
#define MAX_M 100010
const long long mod = 1e9 + 7;
#define vec vector<int>
#define vecll vector<ll>
#define vecllvec vector<vector<ll>>
#define vecb vector<bool>
#define vecBvec vector<vector<bool>>
#define vecst vector<string>
#define veche vector<char>
#define vecd vector<double>
#define vecvec vector<vector<int>>
#define vecDvec vector<vector<double>>
#define vecHvec vector<vector<char>>
#define all(x) (x).begin(),(x).end()
#define ent cout<<endl
#define printvec(vec) for(int aqw=0;aqw<vec.size();aqw++){cout<<vec[aqw]<<" ";}ent;
#define rep(i,n) for(int i=0;i<(int)n;++i)
#define REP(i,m,n) for(int i=m;i<(int)n;++i)
#define INF 1e+9
#define P pair<int, int>;
#define PLL pair<ll, ll>;
#define MAX_V 1000
#define PI 3.141592653589793
// cout << setprecision(15) << std::fixed;

int main()
{
	int n, k;
	cin >>n>>k;
	map<int, int> M;
	vec A(n),L;
	for (int i = 0;i < n;i++) {
		cin >> A[i];
		if(M[A[i]]==0) L.push_back(A[i]);
		M[A[i]]++;
	}
	priority_queue<int, vector<int>, greater<int> > que;
	for(int i = 0;i < L.size();i++) {
		que.push(M[L[i]]);
	}
	int ans = 0;
	for (int i=L.size();i > k;i--) {
		ans+=que.top();
		que.pop();
	}
	cout << ans << endl;
}


Measured memory_bytes: 12660
#include <iostream>
#include <algorithm>
#include <cmath>
#include <string>
#include <array>
#include <vector>
#include <functional>
#include <unordered_map> 
#include <map> 
#include <numeric>
#include <limits>
#include <utility>
#include <queue>
#include <random>
#include <bitset>
using namespace std;
typedef long long LL;

int main(void) {
	int n;
	cin >> n;
	vector<char> s(n);
	for (int i = 0; i < n; i++) {
		cin >> s[i];
	}
	

	for (int i = 0; i < n; i++) {
		if (s[i]=='Y') {
			cout << "Four" << endl;
			return 0;
		}
	}

	cout << "Three" << endl;

	return 0;
}

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

using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int,int> pii;

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

#define DEBUG(x) cout<<#x<<": "<<x<<endl
#define DEBUG2(x,y) cout<<#x<<": "<<x<<" "<<#y<<": "<<y<<endl
#define DEBUG_VEC(v) cout<<#v<<":";REP(i,v.size())cout<<" "<<v[i];cout<<endl
#define ALL(a) (a).begin(),(a).end()

const ll MOD = 1000000007ll;
#define FIX(a) ((a)%MOD+MOD)%MOD

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

    ll ans=0;
    while(true){
        int n,x;
        cin>>n>>x;

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

        ans=0;
        //FOR(i,1,n-2) FOR(j,i+1,n-1) FOR(k,j+1,n){
        FOR(i,1,n-1) FOR(j,i+1,n){
            int k=x-i-j;
            //重複なしの組み合わせ
            if(k>i && k>j && k<=n) {
                ans++;
            }
        }
        cout << ans << endl;
    }
    
    
    return 0;
}


Measured memory_bytes: 3128
#include <iostream>
#include <fstream>

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

typedef long long ll;
#define tr(container, it) \
        for (auto it = container.begin(); it != container.end(); it++)
#define scontains(c, x) ((c).find(x) != (c).end())   //O(log n)
#define contains(c, x) (find((c).begin(),(c).end(),x) != (c).end()) //O(n)
#define pll pair<ll,ll>
#define pii pair<int,int>
#define mll map<ll,ll>
#define intv(x, a, b)((x)>=a && (x)<=b)
#define  rep(i, begin, end) for (__typeof(end) i = (begin) - ((begin) > (end)); i != (end) - ((begin) > (end)); i += 1 - 2 * ((begin) > (end)))
#define  _for(i, end) for (__typeof(end) i = 0; i < (end); i += 1)
#define all(x) (x).begin(),(x).end()
//#define len(array)  (sizeof(array)/sizeof((array)[0]))
#define what_is(x) cerr << #x << " is " << x << endl;
#define error(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args); }
#define mod(x, m) ((((x) % (m)) + (m)) % (m))
const double PI = 2 * acos(.0);
const int INF = 0x3f3f3f3f;
const ll LLINF = 1000000000000000005LL;;
const ll MOD = (ll) (1e9) + 7;
void _mod(ll &x){x = mod(x, MOD);}
//const ll MOD = (ll) 998244353 ;
const double EPS = 1e-10;

template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val) {
    std::fill((T *) array, (T *) (array + N), val);
}



int H,W;
int sh,sw;
int N;
string S, T;

class BLRUDGame {
public:
void solve(std::istream& cin, std::ostream& cout) {
    cin >> H >> W >> N >> sh >> sw >> S >> T;
    int l1=0,r1=0,u1=0,d1=0,l2=0,r2=0,u2=0,d2=0;
    _for(i,N){
        char c = S[i];
        if(c == 'L')l1 ++;
        else if(c == 'R')r1 ++;
        else if(c == 'U')u1 ++;
        else d1++;
        c = T[i];
        if(l1 - r2 >= sw || r1 - l2 >= W - sw + 1 || u1 - d2 >= sh || d1 - u2 >= H - sh +1){
            cout << "NO\n";return;
        }
        if(c == 'L')l2 ++;
        else if(c == 'R')r2 ++;
        else if(c == 'U')u2 ++;
        else d2++;
        l2 = min(l2, sw -  1 + r1);
        r2 = min(r2, W - sw + l1);
        u2 = min(u2, sh -1 + d1);
        d2 = min(d2, H - sh + u1);

    }
    cout << "YES\n";

}
};

int main() {
	BLRUDGame solver;
	std::istream& in(std::cin);
	std::ostream& out(std::cout);
	solver.solve(in, out);
	return 0;
}


Measured memory_bytes: 776
#include<bits/stdc++.h>
#define int long long
using namespace std;
int n;
int ch(string s){
  int dp[4][s.size()+1],ans=0;
  memset(dp,0,sizeof(dp));
  dp[0][0]=1;
  s="+"+s;
  string t="+JOI";
  for(int i=1;i<4;i++){
    for(int j=1,x=0;j<s.size();j++){
      x+=dp[i-1][j-1];
      if(s[j]==t[i]){
        dp[i][j]=x;
        if(i==3)ans+=dp[i][j];
      }
    }
  }
  return ans;
}
int ch2(string s){
  int ans=0;
  s="@"+s+"@";
  for(int i=1;i<(int)s.size();i+=2)s.insert(s.begin()+i,'O');
  int dp1[s.size()]={};
  int dp2[s.size()]={};
  for(int i=1;i<s.size();i++)dp1[i]=dp1[i-1]+(s[i-1]=='J');
  for(int i=s.size()-2;i>=0;i--)dp2[i]=dp2[i+1]+(s[i+1]=='I');
  for(int i=0;i<s.size();i++)ans=max(ans,dp1[i]*dp2[i]);
  return ans;
}
main(){
  string s;
  cin>>n>>s;
  int p1=ch(s);
  int p2=ch("J"+s);
  int p3=ch(s+"I");
  int p4=p1+ch2(s);
  cout<<max(p4,max(p3,p2))<<endl;
}

Measured memory_bytes: 6644
N, T = map(int, input().split())
c = []
t = []
for i in range(N):
    hoge1, hoge2 = map(int, input().split())
    c.append(hoge1)
    t.append(hoge2)
candidate = [c[i] for i in range(len(t)) if t[i] <= T]
if len(candidate) == 0:
    print("TLE")
else:
    print(min(candidate))


Measured memory_bytes: 3060
#include <bits/stdc++.h>
#define int long long
#define moder 1234567
#define inf 1000000000000000000
#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,n) for(int i=1;i<n;i++)
#define P pair<int,int>
#define all(v) v.begin(),v.end()
#define prique(T) priority_queue<T,vector<T>,greater<T>>
#define vecunique(vec) sort(vec.begin(), vec.end());decltype(vec)::iterator result = std::unique(vec.begin(), vec.end());vec.erase(result, vec.end())
using namespace std;


signed main() {
	int n;
	cin>>n;
	if(n<1200)cout<<"ABC"<<endl;
	else cout<<"ARC"<<endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define fi first
#define se second
#define pb push_back
using namespace std;
typedef long long ll;
typedef pair<ll,int>pii;
//struct _IO { _IO() { ios::sync_with_stdio(0); cin.tie(0); } }_io;
int main(){
 string s,t;
 cin>>s>>t;
 int ans=t.size();
 if(ans==1){
 	for(int i=0;i<s.size();i++){
 		if(t[0]==s[i]) return cout<<0<<'\n',0;
 	}
 	cout<<1<<'\n';
 	return 0;
 }
 for(int i=0;i<s.size()-t.size()+1;i++){
	 int c=0;
	 for(int j=i,k=0;k<t.size();k++,j++){
		 if(s[j]!=t[k]) c++;
	}
	ans=min(c,ans);
 }
 cout<<ans<<'\n';
}


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

using LL = long long;
using LD = long double;
 
LL mod = 1e9+7;

int main()
{
	LL n, k;
	cin >> n >> k;
	unordered_map<LL, LL> mp;

	while (k--) {
		LL d;
		cin >> d;
		while (d--) {
			LL x;
			cin >> x;
			mp[x]++;
		}
	}
	LL cnt = 0;
	for (LL i = 1; i <= n; ++i) {
		if (!mp[i]) {
			cnt++;
		}
	}
	cout << cnt << "\n";

}

Measured memory_bytes: 3612
# include <iostream>
# include <algorithm>
# include <vector>
# include <string>
# include <set>
# include <cmath>
# include <iomanip>
# include <functional>
# include <utility>
using namespace std;

int main() {
	int n;
	string s;
	cin >> n >> s;
	int x = 0, max = 0;
	for (int i = 0; i < n; i++) {
		if (s[i] == 'I') {
			x++;
		}
		else if (s[i] == 'D') {
			x--;
		}
		if (max < x) {
			max = x;
		}
	}
	cout << max << endl;
}

Measured memory_bytes: 256
using System;


class AOJ
{

    public static void Main()
    {
        int n = int.Parse(Console.ReadLine());
        double debt = 100000;

        for(int i=0; i<n; i++){
            debt *= 1.05;
            if (debt % 1000 != 0)
            debt = ((int)debt / 1000)*1000 + 1000;
        }
        Console.WriteLine(debt);
        
    }
}
        
       

Measured memory_bytes: 5644
#include <bits/stdc++.h>
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define f first
#define s second

using namespace std;

typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;
typedef unsigned int uint;
typedef pair <int, int> pii;
typedef vector <int> vi;
typedef vector <vi> vvi;
typedef vector < vector <pii> > graph;


signed main()
{
   ios_base::sync_with_stdio(0);
   cin.tie(0);
   int n, k, s;
   cin >> n >> k >> s;
   for(int i = 0; i < k; i++) {
       cout << s << ' ';
   }
   for(int i = k; i < n; i++) {
       cout << (s != 1000000000 ? 1000000000: 1000000000 - 1) << ' ';
   }
   return 0;
}


Measured memory_bytes: 1280
<?php
$num = intval(trim(fgets(STDIN)));
$line = fgets(STDIN);
$array = explode(" ", $line);
$resCount = 0;
while (true) {
    foreach ($array as $key => $value) {
        if ($value % 2 == 1) {
            echo "$resCount";
            break 2;
        }
        $array[$key] = $value / 2;
        if ($key == $num - 1) {
            $resCount += 1;
        }
    }
}

Measured memory_bytes: 4604
#include <cstdio>
#include <algorithm>
#include <vector>
#include <utility>
#include <queue>
using namespace std;
int a[100001];
long long ans[100001];
int main() {
    int n;
    scanf("%d", &n);
    for(int i = 1; i <= n; i++)
        scanf("%d", a + i);
    vector<int> v;
    v.push_back(0);
    for(int i = 1; i <= n; i++)
        if(a[i] > a[v.back()])
            v.push_back(i);
    reverse(v.begin(), v.end());
    priority_queue<int> pq;
    for(int i = 0, last = n, cnt = 0; i < (int) v.size() - 1; i++) {
        while(last > v[i + 1])
            pq.push(a[last--]);
        ans[v[i]] = (long long) cnt * (a[v[i]] - a[v[i + 1]]);
        while(!pq.empty() && pq.top() > a[v[i + 1]]) {
            int x = pq.top();
            pq.pop();
            cnt++;
            ans[v[i]] += x - a[v[i + 1]];
        }
    }
    for(int i = 1; i <= n; i++)
        printf("%lld\n", ans[i]);
}



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

typedef long long int ll;

const int mod = 1000000007;
//const int mod = 998244353;
struct mint {
  ll x; // typedef long long ll;
  mint(ll x=0):x((x%mod+mod)%mod){}
  mint operator-() const { return mint(-x);}
  mint& operator+=(const mint a) {
    if ((x += a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator-=(const mint a) {
    if ((x += mod-a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator*=(const mint a) { (x *= a.x) %= mod; return *this;}
  mint operator+(const mint a) const { return mint(*this) += a;}
  mint operator-(const mint a) const { return mint(*this) -= a;}
  mint operator*(const mint a) const { return mint(*this) *= a;}
  mint pow(ll t) const {
    if (!t) return 1;
    mint a = pow(t>>1);
    a *= a;
    if (t&1) a *= *this;
    return a;
  }

  // for prime mod
  mint inv() const { return pow(mod-2);}
  mint& operator/=(const mint a) { return *this *= a.inv();}
  mint operator/(const mint a) const { return mint(*this) /= a;}
};
istream& operator>>(istream& is, mint& a) { return is >> a.x;}
ostream& operator<<(ostream& os, const mint& a) { return os << a.x;}


ll sum (int l, int r){
	return (l+r)*(r-l+1)/2;
}

int main(){
	int n,k;
	cin >>n >> k;
	long long  ans = 0;
	
	for(ll i=k;i<=n+1;++i){
	//for(int i=k;i<=n+1;++i){
		//ll l = sum(0,i-1), r = sum(n-i+1,n);
		//ll r = i*(n*2-i+1)/2;
		ll r = i * (n * 2 - i + 1) / 2;
		//ll l = i*(i-1)/2;
		ll l = i * (i - 1) / 2;
		ans += (r - l + 1) % mod;
		ans %= mod;
		//ans += sum(n-i+1,n) - sum(0,i-1) + 1;
	}
	cout << ans << endl;
	
	return 0;
}


Measured memory_bytes: 3184
#include <iostream>
#include <string>
#include <algorithm>
#include <functional>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <cstdio>
#include <cmath>
#include <tuple>
#include <iomanip>
#include <numeric>
#include <unordered_map>
#include <sstream>   
#include<limits.h>
#include<float.h>
#include<list>
#include <array>
#include <complex>
using namespace std;
#define i64  long long
#define int  long long
 
#define I32_MAX 2147483647
#define I64_MAX 9223372036854775807LL
#define I64_MAX2 1223372036854775807LL
#define INF I64_MAX2
#define MOD 1000000007
#define MEM_SIZE 10000
#define DEBUG_OUT true

// int DP[MEM_SIZE][MEM_SIZE] = {0};
// int GMEM[MEM_SIZE][MEM_SIZE] = {0};
template<typename T> void DEBUG(T e){if(DEBUG_OUT == false)return;std::cout << e << std::endl;}
template<typename T> void DEBUG(const std::vector<T>& v){if(DEBUG_OUT == false)return;for(const auto& e : v){ std::cout << e << " "; } std::cout << std::endl;}
template<typename T> void DEBUG(const std::vector<std::vector<T> >& vv){if(DEBUG_OUT == false)return;for(const auto& v : vv){ DEBUG(v); } }
template<class T> void DEBUG(string str, T e){if(DEBUG_OUT == false)return;std::cout <<str<<" ";DEBUG(e);};
template <class T> void corner(bool flg, T hoge) {if (flg) {cout << hoge << endl; exit(0);}}
template< typename T1, typename T2 > inline bool chmax(T1 &a, T2 b) { return a < b && (a = b, true); }
template< typename T1, typename T2 > inline bool chmin(T1 &a, T2 b) { return a > b && (a = b, true); }


//CODE
void solve(void)
{
  int N;
  cin>>N;
  vector<int> data(N);
  int MUL = 1;
  for (int i = 0; i < N; i++)
  {
    cin>>data[i];
    MUL *= data[i];
    MUL %= MOD;
  }

  int ANS  = 0;
    int SUM = 0;
    for (int j = 0; j < N; j++)
    {
      SUM += data[j]-1;
    }
    cout<<SUM<<endl;
  
  
  

  return;
}


int32_t main(int32_t argc, const char *argv[])
{
  std::ios::sync_with_stdio(false);
  std::cin.tie(0);

  std::cout << std::fixed;
  std::cout << std::setprecision(9);
  solve();
  

 
  return 0;
}


Measured memory_bytes: 256
fn main() {
	let mut s = String::new();
	std::io::stdin().read_line(&mut s).unwrap();
	let mut s = s.split_whitespace();
	let mut a: u8 = s.next().unwrap().parse().unwrap();
	let mut b: u8 = s.next().unwrap().parse().unwrap();
	let mut ans = 0;
	if a < b {
		ans = b;
		b -= 1;
	} else {
		ans = a;
		a -= 1;
	}
	ans += std::cmp::max(a, b);
	println!("{}", ans);
}


Measured memory_bytes: 4352
#include <iostream>
#include <string>
#include <cstring>
#include <vector>
#include <set>
using namespace std;
#define rep2(x,from,to) for(int x=(from); x<(to); (x)++)
#define rep(x,to) rep2(x,0,to)
int main() {
	string s;
	vector<string> str1;
	set<string> str2;
	while(cin >> s) {
		str1.push_back(s);
		str2.insert(s);
	}
	int w = 0;
	string ret;
	rep(i,str1.size()) {
		if(w < str1[i].length()) {
			w = str1[i].length();
			ret = str1[i];
		}
	}

	int cnt[1000];
	rep(i,1000) {
		cnt[i] = 0;
	}
	int c = 0;
	for(auto it=str2.begin(); it != str2.end(); ++it) {
		rep(j,str1.size()) {
			if(*it == str1[j]) cnt[c]++;
		}
		c++;
	}
	int max = 0, r = 0;
	string ret2;
	for(auto it=str2.begin(); it != str2.end(); ++it) {
		if(max < cnt[r]) {
			max = cnt[r];
			ret2 = *it;
		}
		r++;
	}
	cout << ret2 << " " << ret<< endl;
	return 0;
}

Measured memory_bytes: 1204
using System;
using System.Collections;
using System.IO;
using System.Linq;
using System.Text;
using System.Text.RegularExpressions;
using System.Collections.Generic;
using System.Threading.Tasks;

class Program
{
	//Main
	static void Main(string[] args)
	{
		//出力準備（AutoFlushを切る）
		var sw = new StreamWriter(Console.OpenStandardOutput()){AutoFlush = false};
		Console.SetOut(sw);
		//解答
		Solve();
		//出力終了
		Console.Out.Flush();
	}

	//与えられた整数n以下の素数をリストで返す関数
	//所謂「エラトステネスの篩」を使う。
	//タイプはintとする
	static List<int> SieveOfEratosthenes(int n)
	{
		//素数を格納するリスト
		List<int> primeNumbers = new List<int>();

		//検索用の配列を初期化
		int[] searchArr = new int[n+1];
		for(int i=0; i<n+1; i++){
			searchArr[i] = i;
		}

		//入力値の平方根
		int root = (int)Math.Sqrt(n);

		//現在の最小の素数
		int p = 2;

		//平方根を超えるまでループ
		while(p <= root){
			//素数ではない場合、次へ
			if(searchArr[p] == 0){
				p ++;
				continue;
			}
			//素数の場合
			else{
				//素数リストに加える
				primeNumbers.Add(p);

				//当該素数pで割り切れる数を全て排除
				//p^2から始めれば良い
				for(int i=p*p; i<n+1; i++){
					if(i % p == 0){
						searchArr[i] = 0;
					}
				}

				//pを次へ
				p++;
			}
		}

		//平方根を超えた以降も加える
		for(int i=root+1; i<n+1; i++){
			if(searchArr[i] != 0){
				primeNumbers.Add(i);
			}
		}

		//出力
		return primeNumbers;
	}

	//2017に似た数の合計数（累積和）
	static int[] numArr;

	//クエリに応答
	static void Answer(){
		string[] S = Console.ReadLine().Split(' ');
		int L = int.Parse(S[0]);
		int R = int.Parse(S[1]);

		//累積和から、個数を計算
		int ans = numArr[R-1];
		if(L > 1){
			ans -= numArr[L-2];
		}

		Console.WriteLine(ans);
	}

	static void Solve(){
		//読み込む
		int Q = int.Parse(Console.ReadLine());

		//素数のリストを取得
		int max = 100000;
		List<int> primeLs = SieveOfEratosthenes(max);

		//累積和の配列を埋める
		numArr = new int[max];
		for(int i=1; i<max; i++){
			numArr[i] += numArr[i-1];

			//i+1が2017に似た数かどうか調べる
			int num = i+1;
			int idx = primeLs.BinarySearch(num);
			//そもそも素数でない場合、次へ
			if(idx < 0 || max <= idx){
				continue;
			}
			else if(primeLs[idx] != num){
				continue;
			}
			else{
				//(N+1)/2が素数でない場合は飛ばす
				int num2 = (num+1)/2;
				int idx2 = primeLs.BinarySearch(num2);
				if(idx2 < 0 || max <= idx2){
					continue;
				}
				else if(primeLs[idx2] != num2){
					continue;
				}
				else{
					numArr[i] ++;
				}
			}
		}

		/*debug
		for(int i=0; i<max; i++){
			Console.Write("arr[{0}]={1}, ", i, numArr[i]);
		}
		*/

		//クエリに応答
		for(int i=0; i<Q; i++){
			Answer();
		}
	}
}



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

int main() {
  int N, L;
  cin >> N >> L;
  vector<string> str(N);
  for (int i=0; i<N; i++) {
    cin >> str.at(i);
  }
  sort(str.begin(), str.end());
  for (int i=0; i<N; i++) {
    cout << str.at(i);
  }
  cout << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define REP(i,n) for (int64_t i=0; i<(n); ++i)
#define P pair<int,int>
using ll=int64_t;
using namespace std;
#define ketasuu(n) fixed<<setprecision(n)
#define btoe(p) p.begin(),p.end()
#define etob(p) p.rbegin(),p.rend()
#define chmax(x,y) x=max(x,y)




int main(){
    int a,b; cin>>a>>b;
    cout<<b*2-a<<endl;
}

Measured memory_bytes: 3580
#include <bits/stdc++.h>
using namespace std;
#define rep(i,N) for(int i=0;i<int(N);++i)
#define rep1(i,N) for(int i=1;i<int(N);++i)
#define all(a) (a).begin(),(a).end()
#define print(v) { cerr<<#v<<": [ "; for(auto _ : v) cerr<<_<<", "; cerr<<"]"<<endl; }
#define printpair(v) { cerr<<#v<<": [ "; for(auto _ : v) cerr<<"{"<<_.first<<","<<_.second<<"}"<<", "; cerr<<"]"<<endl; }
#define dump(x) cerr<<#x<<": "<<x<<endl;
#define bit(k) (1LL<<(k))
typedef long long ll;
typedef pair<int, int> i_i;
typedef pair<ll, ll> l_l;
template <class T> using vec = vector<T>;
template <class T> using vvec = vector<vec<T>>;
template< typename T1, typename T2 >
ostream &operator<<(ostream &os, const pair< T1, T2 >& p) {
  os << "{" <<p.first << ", " << p.second << "}";
  return os;
}
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; }

const int INF = (ll)1e9;
const ll INFLL = (ll)1e18+1;
const ll MOD = (ll)1e9+7;
const double PI = acos(-1.0);
/*
const int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
const int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
const string dir = "DRUL";
*/

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(20);
    string S;
    cin >> S;
    int x = (S[0] - '0') * 10 + S[1] - '0';
    int y = (S[2] - '0') * 10 + S[3] - '0';
    cerr << x << " " <<  y << endl;
    auto check = [&](int X){
        return 0 < X && X <= 12;
    };
    if(check(y)){
        if(check(x)){
            cout << "AMBIGUOUS" << endl;
        }
        else{
            cout << "YYMM" << endl;
        }
    }
    else{
        if(check(x)){
            cout << "MMYY" << endl;
        }
        else{
            cout << "NA" << endl;
        }
    }
}


Measured memory_bytes: 3656