akhauriyash/Code-Regression huggingface dataset:
#include<stdio.h>
#include<algorithm>
#include<functional>
using namespace std;
int main()
{
	int i = 0, count[27] = { 0 };
	char S[100000], a = 'a';
	scanf("%s", S);
	for (int j = 0; j < 26; j++) {
		i = 0;
		while (S[i] != '\0') {
			if (S[i] == a + j) {
				count[j] = 1;
			}
			i++;
		}
	}
	for (int i = 0; i < 26; i++) {
		if (count[i] == 0) {
			printf("%c", a + i);
			return 0;
		}
	}
	printf("None");
	return 0;
}

Measured memory_bytes: 256
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <map>
#include <set>
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>
#include <cstdio>
#include <cstring>
#include <iterator>
#include <bitset>
#include <unordered_set>
#include <unordered_map>
#include <fstream>
#include <iomanip>
#include <cassert>
//#include <utility>
//#include <memory>
//#include <functional>
//#include <deque>
//#include <cctype>
//#include <ctime>
//#include <numeric>
//#include <list>
//#include <iomanip>

//#if __cplusplus >= 201103L
//#include <array>
//#include <tuple>
//#include <initializer_list>
//#include <forward_list>
//
//#define cauto const auto&
//#else

//#endif

using namespace std;


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

typedef vector<int> vint;
typedef vector<vector<int> > vvint;
typedef vector<long long> vll, vLL;
typedef vector<vector<long long> > vvll, vvLL;

#define VV(T) vector<vector< T > >

template <class T>
void initvv(vector<vector<T> > &v, int a, int b, const T &t = T()){
    v.assign(a, vector<T>(b, t));
}

template <class F, class T>
void convert(const F &f, T &t){
    stringstream ss;
    ss << f;
    ss >> t;
}

#undef _P
#define _P(...) (void)printf(__VA_ARGS__)
#define reep(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n) reep((i),0,(n))
#define ALL(v) (v).begin(),(v).end()
#define PB push_back
#define F first
#define S second
#define mkp make_pair
#define RALL(v) (v).rbegin(),(v).rend()
#define DEBUG
#ifdef DEBUG
#define dump(x)  cout << #x << " = " << (x) << endl;
#define debug(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;
#else
#define dump(x) 
#define debug(x) 
#endif

#define MOD 1000000007LL
#define EPS 1e-8
#define INF 0x3f3f3f3f
#define INFL 0x3f3f3f3f3f3f3f3fLL
#define maxs(x,y) x=max(x,y)
#define mins(x,y) x=min(x,y)

void mainmain(){
	int n;
	while(cin>>n,n){
		vint v(n+1);
		rep(i,n+1) cin>>v[i];
		int ans=-1;
		vint tmp(n);
		rep(i,n){
			tmp[i]=v[i+1]-v[i];
		}
		sort(ALL(tmp));
		int gap=tmp[tmp.size()/2];
		rep(i,n-2){
			int a=v[i+1]-v[i];
			int b=v[i+2]-v[i+1];
			int c=v[i+3]-v[i+2];
			// cout<<a<<" "<<b<<" "<<c<<endl;
			if(a==b&&b==c) continue;
			if(a!=gap&&b!=gap){
				ans=i+1;
			}
			else if(b!=gap&&c!=gap){
				ans=i+2;
			}
			else if(a!=gap){
				ans=i;
			}
			else if(c!=gap){
				ans=i+3;
			}
			if(ans>=0) break;
		}
		cout<<v[ans]<<endl;
	}
}


signed main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout<<fixed<<setprecision(20);
    mainmain();
}

Measured memory_bytes: 3128
#include<bits/stdc++.h>
using namespace std;
long long int Mod=1e9+7;
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);

    long n,k,i,j;
    cin>>n;

    long double A[n],sum=0.000000000000;
    for(i=0;i<n;i++)
        cin>>A[i];
    
    long double dp[n+1][n+1];
    cout.precision(10);
    memset(dp,0,sizeof(dp));
    dp[1][0]=1-A[0];
    dp[1][1]=A[0];
    
    for(i=2;i<=n;i++)
    {
        for(j=0;j<=i;j++)
        {
            if(j==0)
                dp[i][0]=dp[i-1][0]*(1-A[i-1]);
            else
                dp[i][j]=((1-A[i-1])*dp[i-1][j]+A[i-1]*dp[i-1][j-1])*1.0000000000;

        }
    }
    for(i=n/2+1;i<=n;i++)
        sum=(sum+dp[n][i])*1.00000000000;
    cout<<sum<<endl;
}

Measured memory_bytes: 140928
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
int main(){
  int n,cnt=0;
  cin >> n;
  vector<vector<int> > vec(10,vector<int>(10,0));
  string tmp;
  rep(i,n){
    tmp=to_string(i+1);
    vec.at(tmp[0]-'0').at(tmp[tmp.length()-1]-'0')++;
  }
  rep(i,9){
    rep(j,9){
      cnt+=vec.at(i+1).at(j+1)*vec.at(j+1).at(i+1);
    }
  }
  cout << cnt << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
 
using namespace std;
 
const int MOD=1e9+7;

//const int MOD=998244353;

long long n;
vector<long long> cols, preds, dp, parents, spec;
vector<vector<int>> tree;
vector<stack<int>> vs, vs2;


void dfs(int x, int p){
    parents[x]=p;
    
    vs[cols[p]].push(x);
    if(vs[cols[x]].size()) preds[x]=vs[cols[x]].top();
    if(!vs2[cols[x]].size()) spec.push_back(x);
    vs2[cols[x]].push(x);
    
    
    for(int i:tree[x]){
        if(i!=p){
            dfs(i,x);
        }
    }
    vs[cols[p]].pop();
    vs2[cols[x]].pop();
    dp[x]=1;
    for(int i:tree[x]){
        if(i!=p){
            dp[x]+=dp[i];
        }
    }
}

int main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    
    cin>>n;
    cols.resize(n+1);
    preds.resize(n+1);
    tree.resize(n+1);
    vs.resize(n+1);
    vs2.resize(n+1);
    dp.resize(n+1);
    parents.resize(n+1);
    
    for(int i=1; i<=n; i++) cin>>cols[i];
    for(int i=0; i<n-1; i++){
        int x,y;
        cin>>x>>y;
        tree[x].push_back(y);
        tree[y].push_back(x);
    }
    dfs(1,0);
    
    
    vector<long long> nc=dp;
    for(int i=1; i<=n; i++){
        nc[preds[i]]-=dp[i];
    }
    
    
    vector<long long> vbase(n+1,n), ans(n+1);
    
    for(int i=1; i<=n; i++){
        ans[cols[i]]=(n*(n+1))/2;
    }
    
    
    for(int i=1; i<=n; i++){
        ans[cols[parents[i]]]-=((nc[i]+1)*nc[i])/2;
    }
    
    for(int i:spec){
        vbase[cols[i]]-=dp[i];
    }
    
    
    
    for(int i=1; i<=n; i++){
        if(vbase[i]!=n){
            ans[i]-=(vbase[i]*(vbase[i]+1))/2;
        }
    }
    
    
    for(int i=1; i<=n; i++){
        cout<<ans[i]<<'\n';
    }
    
    
    
    
    return 0;
    
    
}

Measured memory_bytes: 311188
#include<bits/stdc++.h>
#define REP(i,n) for(int i = 0;i < (n);i++)
#define rep(i,m,n) for(int i = (m);i < (n);i++)
#define P pair<int,int>
#define pb push_back
#define mk make_pair
using namespace std;
const int INF = 1e9;

typedef long long ll;

#define MAX_V 200010

struct edge {
    int to;
    int cost;
};


int V;
vector<edge> G[MAX_V];
int d[MAX_V];


void dijkstra(int s) {
    priority_queue<P, vector<P>, greater<P> > que;
    fill(d, d+V, INF);
    d[s] = 0;
    que.push(P(0, s));

    while (!que.empty()) {
        P p = que.top();
        que.pop();
        int v = p.second;
        if (d[v] < p.first) continue;

        for (int i=0; i<G[v].size(); ++i) {
            edge e = G[v][i];
            if (d[e.to] > d[v] + e.cost) {
                d[e.to] = d[v] + e.cost;
                que.push(P(d[e.to], e.to));
            }
        }
    }
}



int main(){
  int E,r;
  int n;
  cin >> n;
  
  V = n+1;
  int s[6];
  int nn[5];
  s[0] = 6;
  rep(i,1,6){
    s[i] = s[i-1]*6;
  }
  /*
  REP(i,6){
    cout << s[i] << endl;
  }
  */
 
  nn[0] = 9;
  rep(i,1,5){
    nn[i] = nn[i-1]*9;
  }
  /*
   REP(i,5){
    cout << nn[i] << endl;
  }
  */
  rep(i,0,V){
    edge e;
    e.cost = 1;
    REP(j,5){
      e.to = i+nn[j];
      G[i].pb(e);
    }
    REP(j,6){
      e.to = i+s[j];
      G[i].pb(e);
    }
    e.to = i+1;
    G[i].pb(e);
  }
  
  dijkstra(0);
  /*
  REP(i,n+1){
    cout << d[i] << endl;
    }*/
  
  cout << d[n] << endl;
  return 0;
}


Measured memory_bytes: 19712
from sys import stdin


def main():
    a, b, c, d = [int(x) for x in stdin.readline().rstrip().split()]
    if (abs(a - c) <= d) or (abs(a - b) <= d and abs(b - c) <= d):
        print('Yes')
    else:
        print('No')


if __name__ == '__main__':
    main()


Measured memory_bytes: 2940
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main(){
	ll n,x,m;
	scanf("%lld %lld %lld",&n,&x,&m);
	ll sc=0;
	ll c=  0;
	vector<ll> f(m);
	ll k = x;
	ll ini;
	ll cont = 0;
	while(1){
		if(f[k])
			break;
		f[k] = 1;
		k = k*k%m;
	}
	ini = k;
	k = x;
	ll ans = 0;
	while(k!=ini && n--){
		ans += k;
		k=k*k%m;
		cont++;
	}
	if(n == 0){
		printf("%lld\n",ans );
		return 0;
	}
	k = ini;
	cont = 0;
	sc = 0;
	do{
		cont++;
		sc+=k;
		k=k*k%m;
	}while(k!=ini);
	ans += (n/cont)*sc;
	n = n%cont;
	while(n--){
		ans += k;
		k = k*k%m;
	}
	printf("%lld\n", ans);
	return 0;
}

Measured memory_bytes: 4040
#include <iostream>
#include <cstdio>
#include <set>
#include <string>
using namespace std;

string reverse2(string str)
{
  string result="";

  for(int i=str.length()-1;i>=0;i--)
    result+=str[i];

  //cout << str << "->" << result << endl;

  return result;
}


int main(void)
{
  int m;
  scanf("%d",&m);

  for(int i=0;i<m;i++){
    string str;
    cin >> str;

    set <string> s;

    int len = str.length();

    for(int j=1;j<len;j++){
      string s1=str.substr(0,j);
      string s2=str.substr(j,len-j);

      //cout << "s1" << s1 << endl;
      //cout << "s2" << s2 << endl;

      s.insert(s1+s2);
      s.insert(s1+reverse2(s2));
      s.insert(s2+s1);
      s.insert(s2+reverse2(s1));
      s.insert(reverse2(s1)+s2);
      s.insert(reverse2(s2)+s1);
      s.insert(reverse2(s1)+reverse2(s2));
      s.insert(reverse2(s2)+reverse2(s1));
	    
      
    }

    printf("%d\n",s.size());
  }
}
      

Measured memory_bytes: 1336
#include<iostream>
using namespace std;
int main()
{
    int n;
    cin >> n ;

    for (int i = 1; i < 10; ++i)
    {
        for (int j = 1; j < 10; ++j)
        {
            if (i*j == n)
            {
                cout << "Yes" << endl;
                return 0;
            }
        }
    }

    cout << "No" << endl;
    return 0;

}

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

int main(){
    int h, w;
    cin >> h >> w;

    string board[50];

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

    const int dx[8] = {1,0,-1,0,1,-1,-1,1};
    const int dy[8] = {0,1,0,-1,1,1,-1,-1};

    for(int i = 0; i < h; i++){
        for(int j = 0; j < w; j++){
            if(board[i][j] == '#')continue;

            int num = 0;
            for(int d = 0; d < 8; d++){
                int ni = i + dy[d];
                int nj = j + dx[d];

                if(ni < 0 || h <= ni) continue;
                if(nj < 0 || w <= nj) continue;
                if(board[ni][nj] == '#') num++;
            }
            board[i][j] = char(num + '0');
        }
    }

    for(int i = 0; i < h; i++){
        cout << board[i] << endl;
    }
}

Measured memory_bytes: 256
n=int(input())
old=[0,0,0]
for i in range(n):
  t,x,y=map(int,input().split())
  tt=t-old[0]
  xx=x-old[1]
  yy=y-old[2]
  dist=abs(xx)+abs(yy)
  if tt%2 != (xx+yy)%2 or dist>tt:
    print("No")
    exit()
  old=[t,x,y]
  
print("Yes")

Measured memory_bytes: 9216
#include <bits/stdc++.h>
#define FOR(i, a, n) for(ll i = (ll)a; i < (ll)n; i++)
#define FORR(i, n) for(ll i = (ll)n - 1LL; i >= 0LL; i--)
#define rep(i, n) FOR(i, 0, n)
#define ALL(x) begin(x), end(x)
using namespace std;
using ll = long long;
template <typename T> using V = vector<T>;
constexpr ll Mod = 998244353;
constexpr ll mod = 1e9 + 7;
constexpr ll inf = 1LL << 60;
template <typename T> constexpr bool chmax(T &a, const T &b) {
    if(a >= b) return false;
    a = b;
    return true;
}
template <typename T> constexpr bool chmin(T &a, const T &b) {
    if(a <= b) return false;
    a = b;
    return true;
}

/*-------------------------------------------*/

struct edge {
    ll to, cost1;
    ll cost2;
    edge(ll to, ll c1, ll c2) : to(to), cost1(c1), cost2(c2) {}
};

struct node {
    ll v;
    ll coin;
    ll d;
    node(ll v, ll c, ll d) : v(v), coin(c), d(d) {}
    inline bool operator<(const node &r) const { return d > r.d; }
};

ll n, m, s;
ll d[60][2600];
ll C[60], D[60];

vector<edge> G[100];

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

    cin >> n >> m >> s;
    chmin(s, 2550LL);
    rep(i, m) {
        ll u, v, a, b;
        cin >> u >> v >> a >> b;
        G[u].emplace_back(v, a, b);
        G[v].emplace_back(u, a, b);
    }
    rep(i, n) {
        ll j = i + 1;
        cin >> C[j] >> D[j];
    }
    rep(i, 60) fill(ALL(d[i]), inf);

    d[1][s] = 0;
    priority_queue<node> que;
    que.emplace(1, s, 0);
    while(!que.empty()) {
        node v = que.top();
        que.pop();
        if(d[v.v][v.coin] < v.d) continue;
        for(auto &&e : G[v.v]) {
            if(v.coin >= e.cost1 &&
               chmin(d[e.to][v.coin - e.cost1], v.d + e.cost2)) {
                que.emplace(e.to, v.coin - e.cost1, v.d + e.cost2);
            }
        }
        if(v.coin > 1 && chmin(d[v.v][v.coin - 1], v.d)) {
            que.emplace(v.v, v.coin - 1, v.d);
        }
        if(chmin(d[v.v][min(2550LL, v.coin + C[v.v])], v.d + D[v.v])) {
            que.emplace(v.v, min(2550LL, v.coin + C[v.v]), v.d + D[v.v]);
        }
    }
    FOR(i, 2, n + 1) cout << d[i][0] << endl;

    return 0;
}

Measured memory_bytes: 6168
import java.io.InputStream;
import java.io.PrintStream;
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        solve(System.in, System.out);
    }

    static void solve(InputStream is, PrintStream os) {
        // Your code here!
        Scanner scan = new Scanner(is);
        String s = scan.next();

        if(s.equals("ABC"))
            os.println("ARC");
        else
            os.println("ABC");

    }
}

Measured memory_bytes: 27020
n = int(input())
w = [input()]
is_correct = True
for i in range(n-1):
  w.append(input())
  if w[i+1][0] != w[i][-1] or w[i+1] in w[:i+1]:
    is_correct = False
print("Yes" if is_correct else "No")
    




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

using namespace std;

#define fore(i, s, e) for(int i = s; i < e; i++)
#define fore_(i, s, e) for(int i = s; i > e; i--)
#define FIN ios::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define FAIL cout << -1 << endl; return 0
#define pb push_back
#define mp make_pair
#define fst first
#define snd second

typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;

vector<pair<ll,ll>> p;
ll dp[101][100001];
ll n, b;
ll v, w;

ll solve(ll i, ll j) {
    if(i == n) return 0;
    if(dp[i][j] != -1) return dp[i][j];

    ll ret = 0;

    if(p[i].fst <= j) ret = max(solve(i + 1, j), p[i].snd + solve(i + 1, j - p[i].fst));
    else ret = solve(i + 1, j);

    dp[i][j] = ret;
    return ret;
}

int main() {
    FIN;
    cin >> n >> b;
    fore(i, 0, n) {
        cin >> v >> w;
        p.pb(mp(v, w));
    }
    memset(dp, -1, sizeof dp);
    cout << solve(0, b) << endl;
    return 0;
}


Measured memory_bytes: 79232
#include <iostream>
using namespace std;
const int P = 1e9+7, M = 2001;
long long C[M][M];

int main () {

    int N, A, B;
    cin >> N >> A;
    B = N - A;
    C[0][0] = 1;
    for (int i = 1; i <= N; i++) {
        C[i][0] = 1;
        for (int j = 1; j <= i; j++) {
            C[i][j] = (C[i-1][j] + C[i-1][j-1]) % P;
        }
    }
    for (int i = 1; i <= A; i++) {
        if (i > B + 1) {
            cout << "0" << endl;
            continue;
        }
        long long ans = C[A-1][i-1] * C[B+1][i] % P;
        cout << ans << endl;
    }

    return 0;
}


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

	int main(){
		
		ios_base::sync_with_stdio(false);
		cin.tie(NULL);
	
		// #ifndef ONLINE_JUDGE
		// freopen("input.txt", "r", stdin);
		// freopen("output.txt", "w", stdout);
		// #endif

		int h,w;
		cin >> h >> w;
		long long int a[h][w],dp[h][w];
		memset(dp,0,sizeof(dp));
		dp[0][0]=1;
		for(int i=0;i<h;i++){
			string s;
			cin >> s;
			for(int j=0;j<w;j++){
				if(i || j)
					dp[i][j]=0;
				if(s[j]=='.'){
					a[i][j]=1;
					if(j-1>=0) dp[i][j]=(dp[i][j]+dp[i][j-1])%1000000007;
					if(i-1>=0) dp[i][j]=(dp[i][j]+dp[i-1][j])%1000000007;
				}
				else a[i][j]=0;
				// cout << i << " " << j << 
			}
		}
		cout << dp[h-1][w-1];
		


	
	
		
	
	}

Measured memory_bytes: 15872
#include <iostream>

int main(){

    int a,b;
    char op;

    while(1){
        std::cin >> a >> op >> b;
        if(op == '?'){
            break;
        }
        else if(op == '+'){
            std::cout << a+b << std::endl;
        }
        else if(op == '-'){
            std::cout << a-b << std::endl;
        }
        else if(op == '*'){
            std::cout << a*b << std::endl;
        }
        else if(op == '/'){
            std::cout << a/b << std::endl;
        }
    }
}


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

using namespace std;

int main()
{
	long long N, W; // N：アイテム数、W：ナップザックの容量
	cin >> N >> W;
	vector<long long> iw(N + 1);	// 重さ
	vector<long long> iu(N + 1);	// 価値
	vector<vector<long long>> dp(N + 1, vector<long long>(W + 1)); // DPメモリ（アイテム、容量）
	iw[0] = iu[0] = 0;
	for (int i = 1; i <= N; i++) {
		cin >> iw[i] >> iu[i];
	}

	for (int i = 0; i <= N; i++) {
		dp[i][0] = 0;
		dp[0][i] = 0;
	}
	// Item Loop
	for (int i = 1; i <= N; i++) {
		// Weight Loop
		for (int j = 1; j <= W; j++) {
			if (j - iw[i] >= 0) {
				dp[i][j] = max(dp[i - 1][j], dp[i - 1][j - iw[i]] + iu[i]);
			}
			else {
				dp[i][j] = dp[i - 1][j];
			}
		}
	}
	cout << dp[N][W];
}


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

// {U}{INT,LONG,LLONG}_{MAX,MIN}
#define INF         INT_MAX/3
#define MOD         (1000000007LL)
#define inc(i, l, r)   for(long long i=(l);i<(r);i++)
#define dec(i, l, r)   for(long long i=(r)-1;i>=(r);i--)
#define se          second
#define fi          first

using LL  = long long;

int di[] = {0, -1, 0, 1};
int dj[] = {1, 0, -1, 0};
// }}}

int main() {
    std::ios::sync_with_stdio(false);
    int n;cin >> n;
    vector<int> d(n);
    inc(i, 0, n) cin >> d[i];
    sort(d.begin(), d.end());
    int ans = 0;
    int b = -1;
    inc(i, 0, n){
        if(b != d[i]) ans++;
        b = d[i];
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <numeric>
#include <bitset>
#include <cmath>

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

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

#include <chrono>
class xor_shift {
    uint32_t x, y, z, w;
public:
    xor_shift() : x(static_cast<uint32_t>((chrono::system_clock::now().time_since_epoch().count())&((1LL << 32)-1))),
    y(1068246329), z(321908594), w(1234567890) {};

    uint32_t urand(){
        uint32_t t;
        t = x ^ (x << 11);
        x = y; y = z; z = w;
        w = (w ^ (w >> 19)) ^ (t ^ (t >> 8));
        return w;
    };

    int rand(int n){
        if(n < 0) return -rand(-n);
        uint32_t t = numeric_limits<uint32_t>::max()/(n+1)*(n+1);
        uint32_t e = urand();
        while(e >= t) e = urand();
        return static_cast<int>(e%(n+1));
    }

    int rand(int a, int b){
        if(a > b) swap(a, b);
        return a+rand(b-a);
    }
};

int main() {
    int d;
    cin >> d;
    array<int, 26> A{};
    for (auto &&k : A) cin >> k;
    vector<array<int, 26>> v(d);
    for (int i = 0; i < d; ++i) {
        for (int j = 0; j < 26; ++j) {
            scanf("%d", &v[i][j]);
        }
    }
    auto score = [&](vector<int> &x){
        int ret = 0;
        vector<int> prv(26, -1);
        for (int i = 0; i < d; ++i) {
            ret += v[i][x[i]];
            prv[x[i]] = i;
            for (int j = 0; j < 26; ++j) {
                ret -= A[j]*(i-prv[j]);
            }
            cout << ret << "\n";
        }

        return ret;
    };
    vector<int> ans(d);
    xor_shift rd;
    for (int i = 0; i < d; ++i) {
        ans[i] = rd.rand(25);
        cin >> ans[i];
        ans[i]--;
    }
    score(ans);
    return 0;
}

Measured memory_bytes: 3704
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

public class MainClass
{
	public const long Giri = 1000000007;
	public const long DpInf = 99999999999999;
	
	public static void Main(string[] args)
	{
		var p = Input().ToInt();
		Array.Sort(p);
		int wa = 0;
		for(int i = 1; i < p.Length; i++)
		{
			wa += Math.Abs(p[i]-p[i-1]);
		}
		Console.WriteLine(wa);
	}
	
	
	static long GCD(long a, long b)
	{
		var v = new[] { a, b };
		while (v[1] != 0) { v = new[] { v[1], v[0] % v[1] }; }
		return v[0];
	}
	public static string[] Input() { return Console.ReadLine().Split(); }
}

public static class Smarter
{
	public static int ToInt(this string str) { return int.Parse(str); }
	public static long ToLong(this string str) { return long.Parse(str); }
	public static int[] ToInt(this string[] str, int offset = 0)
	{
		var r = new int[str.Length];
		for(int i = 0; i < str.Length; i++) r[i] = str[i].ToInt() + offset;
		return r;
	}
}

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

using namespace std;
#define ll long long

#define rep(i, a) for (int i = 0; i < (int) (a); i++)
#define reps(i, a, b) for (int i = (int) (a); i < (int) (b); i++)
#define rrep(i, a) for (int i = (int) a-1; i >= 0; i--)
#define rreps(i, a, b) for (int i = (int) (a)-1; i >= (int) (b); i--)
#define MP(a, b) make_pair((a), (b))
#define PB(a) push_back((a))
#define all(v) (v).begin(), (v).end()
#define PRINT(f) if((f)){cout << (TRUE__) << endl;}else{cout << FALSE__ << endl;}
#define TRUE__ "Yes"
#define FALSE__ "No"
#define PERM(v) next_permutation(all(v))
#define UNIQUE(v) sort(all(v));(v).erase(unique(all(v)), v.end())
#define CIN(type, x) type x;cin >> x

#ifdef LOCAL
#define lcout(a) cout << a;
#define lcoutln(a) cout << a << endl;
#define lcerr(a) cerr << a;
#define lcerrln(a) cerr << a << endl;
#else
#define lcout(a) 
#define lcoutln(a) 
#define lcerr(a) 
#define lcerrln(a) 
#endif


signed main()
{
	int w, h;
	cin >> h >> w;
	rep(i, w+2) cout << '#';
	cout << endl;
	rep(i, h) {
		cout << '#';
		string s;
		cin >> s;
		cout << s << '#' << endl;
	}
	rep(i, w+2) cout << '#';
	cout << endl;
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=int(a);i<int(b);++i)
using namespace std;
typedef long long ll;
int INF = (1LL << 30) - 1;
int MOD = 1e9+7;
main(){
    int N;
    cin >> N;
    int cnt[9] = {};
    rep(i,0,N){
        int x;
        cin >> x;
        if(x >= 3200)cnt[8]++;
        else    cnt[x / 400]++;
    }
    int mini = 0,maxi = 0;
    rep(i,0,8){
        mini += cnt[i] > 0;
    }
    maxi = mini;
    if(mini == 0){
        mini = 1;
    }
    maxi += cnt[8];
    cout << mini << " " << maxi << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define INF 1e9
#define all(v) v.begin(), v.end()
#define rall(v) v.begin(), v.end(), std::greater<int>()
#define rep(i, n) for(int i = 0; i < n; i++)
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define max(v) *max_element(v.begin(), v.end())
#define min(v) *min_element(v.begin(), v.end())
using namespace std;
 
int main(void){
    cin.tie(0);
    ios::sync_with_stdio(false);

    char in[120];
    pair<pair<string,int>,int> p[110];
    int a;
    cin>>a;
    for(int i = 0; i < a; i++){
        int t;
        cin>>in>>t;
        string tmp = in;
        p[i] = make_pair(make_pair(in, -t), i);
    }
    sort(p, p+a);
    for(int i = 0; i < a; i++){
        cout<<p[i].second+1<<endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <cmath>
#include <iomanip>
#include <stack>
#include <queue>
#include <numeric>
#include <map>
#include <unordered_map>
#include <set>
#define rep(i,n) for(int i=0;i<(n);i++)
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define pb push_back
#define mod 1000000007
using ll = long long;
using namespace std;

int main(){
  ll N; cin >> N;
  vector<ll> A(N); rep(i,N){
    cin >> A[i];
  }
  sort(all(A));
  vector<ll> must(N);
  if(N%2==1){
    rep(i,N){
      must[i] = i;
      if(i%2==1)must[i]++;
    }
  }
  else{
    rep(i,N){
      must[i] = i+1;
      if(i%2==1)must[i]++;
    }
  }
  //rep(i,N) cout << must[i] << endl;
  if(N%2==0) must[N-1] = must[0];
  sort(all(must));
  rep(i,N){
    if(A[i] != must[i]){
      cout << 0 << endl;
      return 0;
    }
  }
  ll poww = N/2;
  ll ans = 1;
  rep(i,poww){
    ans *= 2;
    ans %= mod;
  }
  cout << ans << endl;
  return 0;
}


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

int main()
{
  int A; cin >> A;
  double ans = (double)((A + 1) / 2) / A;
  printf("%.12f\n", ans);
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define intput(i) cout << i << endl
#define ll long long
#define stringput(s) cout << (string)(s) << endl

int main(){
  int N;
  cin >> N;
  vector<ll> A(N);
  rep(i, N) cin >> A[i];
  ll M = *max_element(A.begin(),A.end());
  ll m = *min_element(A.begin(),A.end());
	cout << M -m << endl;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        
        Scanner sc = new Scanner(System.in);
        
        int n = Integer.parseInt(sc.next());
        int[] b = new int[n-1];
        for(int i = 0; i < n-1; i++){
            b[i] = Integer.parseInt(sc.next());
        }
        
        int[] a = new int[n];
        a[0] = b[0];
        a[n-1] = b[n-2];
        for(int i = 1; i < n-1; i++){
            a[i] = Math.min(b[i-1], b[i]);
        }
        
        int ans = 0;
        for(int i = 0; i < n; i++){
            ans += a[i];
        }
        
        System.out.println(ans);
    }
}

Measured memory_bytes: 23764
#include <bits/stdc++.h>
using ll = long long;
using itn = int;
using namespace std;
int GCD(int a, int b){
    return b ? GCD(b, a%b) : a;
}
int main() {
	string s,t;
	cin >> s >> t;
	vector<string> subs;
	if(s.length()<t.length()){
		cout << "UNRESTORABLE" << endl;
		return 0;
	}
	for(int i=0; i<s.length()-t.length()+1; i++){
		for(int j=0; j<t.length(); j++){
			if(s[i+j]!='?' && s[i+j]!=t[j]){
				break;
			}
			if(j+1 == t.length()){
				string str=s;
				str.replace(i,j+1,t);
				subs.push_back(str);
			}
		}
	}
	for(auto &str:subs){
		for(auto &c:str){
			if(c=='?') c='a';
		}
	}
	sort(subs.begin(),subs.end());
	cout << (subs.size()?subs[0]:"UNRESTORABLE") << endl;
	return 0;

}


Measured memory_bytes: 256
n = int(raw_input())
for i in range(int(raw_input())):
    a, b = [int(i) for i in raw_input().split(" ")]
    min_a = min(a, n+1-a)
    min_b = min(b, n+1-b)
    print (min(min_a, min_b)-1)%3+1

Measured memory_bytes: 4224
function main(input) {
    var n, a = [], tmp, size, sum = 0, i;
    n = parseInt(input[0], 10);
    tmp = input[1].split(" ");
    size = tmp.length;
    for (i = 0; i < size; i++) {
        a.push(parseInt(tmp[i], 10));
    }
    a.sort(function (self, other) {
        if (self < other) {
            return -1;
        } else if (self > other) {
            return 1;
        } else {
            return 0;
        }
    });
    for (i = 0; i < n - 1; i++) {
        sum += a[i + 1] - a[i];
    }

    console.log(sum);
}

main(require("fs").readFileSync("/dev/stdin", "utf8").split("\n"));

Measured memory_bytes: 20936
#include <bits/stdc++.h>
using namespace std;
int main(){
    int A[3][3];
    bool appear[3][3];
    for(int i=0;i<3;i++){
        for(int j=0;j<3;j++){
            cin>>A[i][j];
            appear[i][j] = false;
        }
    }
    int N;
    cin>>N;
    vector<int> b(N);
    for(int i=0;i<N;i++){
        cin>>b[i];
    }
    bool won = false;
    for(int i=0;i<3;i++){
        for(int j=0;j<3;j++){
            for(int k=0;k<N;k++){
                if(A[i][j]==b[k]){
                    appear[i][j] = true;
                    break;
                }
            }
        }
    }
    for(int i=0;i<3;i++){
        if(appear[i][0] && appear[i][1] && appear[i][2]){
            won = true;
        }
        if(appear[0][i] && appear[1][i] && appear[2][i]){
            won = true;
        }
    }
    if(appear[0][0] && appear[1][1] && appear[2][2]){
        won = true;
    }
    if(appear[0][2] && appear[1][1] && appear[2][0]){
        won = true;
    }
    if(won){
        cout<<"Yes"<<endl;
    }else{
        cout<<"No"<<endl;
    }
}

Measured memory_bytes: 3612
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
#define INF 1<<30
#define LINF 1LL<<60

/*
 <url:https://github.com/kei1107/algorithm/blob/master/template/template_for_problems.cpp>
 ?????????============================================================
 n????????´??°a1, a2, ???, an??¨n????????´??°p1, p2, ???, pn?????´??°m?????????????????????
 k???????????´??°ak???pk[%]????¢??????§?????¶?????¨??????????????????k(1 ??? k ??? n)?????????????????????
 0?????\???n?????\????????´??°??????????????????1??\???m??\????????´??°????????§???
 ?????°????????´??°????°?????????¨???1?????§?????????????????????????????°????????????????±??????????
 =================================================================
 ?§£??¬=============================================================
 ????????????( := ????????????????????????)
 ================================================================
 
 
 <reference:http://d.hatena.ne.jp/simezi_tan/20130522/1369203086>
 
 ???????????????????????????????????? < rep(j, 0, n) if(j & (1 << i)) f[j] -= f[j ^ (1 << i)]; >
 ????????????????????????????????? <rep(j, 0, n) if(j & (1 << i)) f[j] += f[j ^ (1 << i)];>
 */

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

int main(void) {
    cin.tie(0); ios::sync_with_stdio(false);
    ll n,m; cin >> n >> m;
    vector<ll> a(n);
    vector<long double> p(n);
    for(auto &x:a) cin >> x;
    for(auto &x:p) {
        cin >> x;
        x/=100;
    }
    
    // Preprocessing
    // probability
    // ??????????±???????????????????????????£??????????????????
    vector<long double> dp1((1<<n),1.0);
    for(int i = 0; i < n;i ++){
        for(int j = 0; j < (1<<n);j++){
            if((j>>i)&1){
                dp1[j] *= p[i];
            }else{
                dp1[j] *= (1-p[i]);
            }
        }
    }
    
    // ????????????????????????
    /* ?????????????????? +=??¨?????? -=???????????°??????*/
    vector<ll> dp2((1<<n),0);
    for(int i = 0; i <(1<<n);i++){
        ll LCM = 1;
        for(int j = 0; j < n;j++){
            if(LCM > m) break;
            if((i>>j)&1){
                ll tmp = a[j] / gcd(LCM,a[j]);
                if(1.0 * tmp * LCM < 2*m) LCM*=tmp;
                else LCM = m+1;
            }
        }
        dp2[i] = m/LCM;
    }
    for(int i = 0; i < n;i++){
        for(int j = 0;j < (1<<n);j++){
            if((j>>i)&1){
                dp2[j] -= dp2[j^1 << i];
            }
        }
    }
    
    long double res = 0;
    for(int i = 0; i < (1<<n);i++){
        res += dp1[i] * (m - abs(dp2[i])); // ??¶???????????¨???
    }
    cout << fixed << setprecision(10) << res << endl;
    return 0;
}

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

using namespace std;
 
typedef long long ll;
typedef long double ld;
typedef pair<int, int> Pii;
typedef pair<int, ll> Pil;
typedef pair<ll, ll> Pll;
typedef pair<ll, int> Pli;

#define fi first
#define se second

const ll MOD = 1e9 + 7;
const ll MOD2 = 998244353;
const ll MOD3 = 1812447359;
const ll INF = 1ll << 62;
const double PI = 2 * asin(1);

void yes() {printf("yes\n");}
void no() {printf("no\n");}
void Yes() {printf("Yes\n");}
void No() {printf("No\n");}
void YES() {printf("YES\n");}
void NO() {printf("NO\n");}

ll cnt[int(1e5 + 5)];

ll Pow(ll A, ll N){
  if (N == 0) return 1;
  if (N % 2 == 0) return Pow(A*A%MOD2, N/2);
  else return A*Pow(A*A%MOD2, N/2) % MOD2;
}

int main(){
  int N; cin >> N;
  int M = 0;
  for (int i = 0; i < N; i++){
    int D; cin >> D;

    if (i == 0 && D != 0){
      cout << 0 << endl;
      return 0;
    }
    cnt[D]++;
    M = max(M, D);
  }

  if (cnt[0] != 1){
    cout << 0 << endl;
    return 0;
  }

  ll ans = 1;
  for (int i = 1; i <= M; i++){
    ans *= Pow(cnt[i-1], cnt[i]);
    ans %= MOD2;
  }
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 4248
#include <bits/stdc++.h>
using namespace std;
int main() {
	string s;
	cin>>s;
	int sum=0;
	vector<char> vec(s.size());
	for(int i=0; i<s.size(); i++){
		vec[i]=s[i];
	}
	int N=s.size();
	for(int i=0; i<s.size(); i++){
		if(i%2==0){
			if(vec[i]!='0'){
			sum++;	
			}
		}
		else{
			if(vec[i]!='1'){
				sum++;
			}	
		}
	}
	cout<<min(sum,N-sum)<<endl;
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N;
  int j;
  j = 0;
  cin >> N;
  for (int i = 0; i < N; i++) {
    string C;
    cin >> C;
      if(C == "Y"){
        j = 1;
        break;
      }
  }
  if(j == 1){
    cout << "Four" << endl;
  }else{
    cout << "Three" << endl;
  }
 }

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

int main(){
    int n;
    string s;
    cin >> n >> s;
    vector<int> a(n);
    rep(i, n){
        if (s[i] == 'R') a[i] = 0;
        else if (s[i] == 'G') a[i] = 1;
        else if (s[i] == 'B') a[i] = 2; 
    }
    vector<ll> cnt(3);
    rep(i, n) cnt[a[i]]++;
    ll ans = 1;
    rep(i, 3) ans *= cnt[i];
    rep(j, n) rep(i, j){
        int k = 2 * j - i;
        if (k < n){
            if (a[i] == a[j]) continue;
            else if (a[j] == a[k]) continue;
            else if (a[k] == a[i]) continue;
            ans--;
        }
    }    
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3664
import java.util.Arrays;
import java.util.Collections;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		Integer[] a = new Integer[n];
		for(int i=0;i<n;i++) {
			a[i]=sc.nextInt();
		}
		Arrays.sort(a,Collections.reverseOrder());
		int alice=0;
		int bob = 0;
		int sum=0;
		for(int i=0;i<n;i++) {
			if(i%2 ==0) {
				alice+=a[i];
			}else {
				bob+=a[i];
			}
		}
		sum=alice-bob;
		System.out.println(sum);
	}
}


Measured memory_bytes: 35960
#include <iostream>
#include <fstream>
#include <sstream>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>

#include <vector>
#include <cstring>
#include <queue>
#include <map>
#include <set>

#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <ctime>

using namespace std;

typedef long long ll;
typedef vector<int> vi; 
typedef vector<vi> vvi;
typedef vector<string> vs;
typedef pair<int, int> pii;

#define sz(a) int((a).size())
#define pb push_back
#define all(c) (c).begin(),(c).end()
#define present(i, c) ((c).find(i) != (c).end())
#define rep(i, n) for(int i = 0; i < n; i++)
#define rep1(i, n) for(int i = 1; i <= n; i++)
#define foreach(i, c) for(auto i : c)

#define TRACE(x...) x
#define watch(x) TRACE(cerr << #x" = " << x << endl)
#define watchc(x) TRACE(cerr << #x" = "); for(auto __i : x) cerr << __i << " "; cerr << endl

#define INF 0x3f3f3f3f

int main() {
	
	ifstream infile("input.in");
	if(infile.good()) cin.rdbuf(infile.rdbuf());

	string s1, s2;
	cin >> s1 >> s2;

	bool ok = s2.substr(0, sz(s1)) == s1;
	if(ok) cout << "Yes" << endl;
	else cout << "No" << endl;    
	
	if(infile.good()) infile.close();
	return 0;
	
}



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

using namespace std;

int main() {
	int N, K;
	cin >> N >> K;
	int A[N] = {};
	
	int cnt, ans = 0;
	for (int i = 0; i < N; i++) {
		cin >> cnt;
		A[cnt - 1]++;
	}

	sort(A, A + N);

	for (int i = 0; i < N - K; i++) {
		ans += A[i];
	}

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 1024
#include<iostream>
#include<string>
#include<cstring>
#include<algorithm>
#include<queue>
using namespace std;

#define MAX 1000
int y[MAX][MAX];
int x[MAX][MAX];
int px[10];
int py[10];
bool z[MAX][MAX][5];
bool a[MAX][MAX];
int sum2;
int sum3;
int main(){
	memset(z,false,sizeof(z));
	char T[12]={'.','1','2','3','4','5','6','7','8','9','S','X'};
	int n,m,c,d,sum,f,g;
	string S;
	sum=0;
	cin>>n>>m>>c;
	for(int i=0;i<n;i++){
		cin>>S;
		for(int j=0;j<m;j++){
			for(int k=0;k<12;k++){
				if(S[j]==T[k]){
					x[i][j]=k;
					if(k==10){
						px[0]=i;
						py[0]=j;
					}
					if(k>=1 && k<=9){
						px[k]=i;
						py[k]=j;
					}
				}
			}
		}
	}
	for(int i=0;i<n;i++){
		for(int j=0;j<m;j++){
			y[i][j]=-1;
		}
	}
	for(int i=0;i<n;i++){
		for(int j=0;j<m;j++){
			if(i>=1){
				if(x[i-1][j]!=11){
					z[i][j][1]=true;
				}
			}
			if(j>=1){
				if(x[i][j-1]!=11){
					z[i][j][2]=true;
				}
			}
			if(i<n-1){
				if(x[i+1][j]!=11){
					z[i][j][3]=true;
				}
			}
			if(j<m-1){
				if(x[i][j+1]!=11){
					z[i][j][4]=true;
				}
			}
		}
	}
	queue<int>R;
	for(int i=1;i<=c;i++){
		memset(a,false,sizeof(a));
		for(int j=0;j<n;j++){
			for(int k=0;k<m;k++){
				y[j][k]=-1;
			}
		}
		while(!R.empty()){
			R.pop();
		}
		sum2=0;
		a[px[i-1]][py[i-1]]=true;
		if(z[px[i-1]][py[i-1]][1]==true){
			a[px[i-1]-1][py[i-1]]=true;
			y[px[i-1]-1][py[i-1]]=1;
			R.push((px[i-1]-1)*1000+py[i-1]);
			sum2++;
		}
		if(z[px[i-1]][py[i-1]][2]==true){
			a[px[i-1]][py[i-1]-1]=true;
			y[px[i-1]][py[i-1]-1]=1;
			R.push((px[i-1])*1000+(py[i-1]-1));
			sum2++;
		}
		if(z[px[i-1]][py[i-1]][3]==true){
			a[px[i-1]+1][py[i-1]]=true;
			y[px[i-1]+1][py[i-1]]=1;
			R.push((px[i-1]+1)*1000+py[i-1]);
			sum2++;
		}
		if(z[px[i-1]][py[i-1]][4]==true){
			a[px[i-1]][py[i-1]+1]=true;
			y[px[i-1]][py[i-1]+1]=1;
			R.push((px[i-1])*1000+(py[i-1]+1));
			sum2++;
		}
		d=0;
		while(y[px[i]][py[i]]==-1){
			sum3=0;
			d++;
			for(int j=1;j<=sum2;j++){
				f=R.front()/1000;
				g=R.front()%1000;
				if(z[f][g][1]==true && a[f-1][g]==false){
					a[f-1][g]=true;
					y[f-1][g]=d+1;
					R.push((f-1)*1000+g);
					sum3++;
				}
				if(z[f][g][2]==true && a[f][g-1]==false){
					a[f][g-1]=true;
					y[f][g-1]=d+1;
					R.push(f*1000+(g-1));
					sum3++;
				}
				if(z[f][g][3]==true && a[f+1][g]==false){
					a[f+1][g]=true;
					y[f+1][g]=d+1;
					R.push((f+1)*1000+g);
					sum3++;
				}
				if(z[f][g][4]==true && a[f][g+1]==false){
					a[f][g+1]=true;
					y[f][g+1]=d+1;
					R.push(f*1000+(g+1));
					sum3++;
				}
				R.pop();
			}
			sum2=sum3;
		}
		sum += y[px[i]][py[i]];
	}
	cout<<sum<<endl;
	return 0;
}

Measured memory_bytes: 14896
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cstring>
#include <queue>
#include <stack>

using namespace std;

typedef int itn;
typedef long long LL;
typedef unsigned long long ULL;
typedef vector<int> VI;
typedef vector<vector<int>> VVI;
typedef vector<LL> VL;
typedef vector<VL> VVL;
typedef map<int, int> M;
typedef pair<int, int> P;
typedef stack<int> S;
typedef queue<int> Q;

const LL MOD = 1000000007;

int main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    VI vi = VI(5, 0);
    int min1 = 10;
    int ans = 0;
    for (int i = 0; i < 5; ++i)
    {
        cin >> vi[i];
        if (vi[i] % 10)
        {
            if(vi[i] > 10)
            {
                ans += vi[i]/10;

            }
            min1 = min(min1, vi[i]%10);
            ans++;
        }
        else
        {
            ans += vi[i]/10;
        }
    }
    cout << ans * 10 -10 +  min1 << endl;

    
    return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep0(i,n) for (int i = 0; i < (n); ++i)  //0index
#define rep1(i,n) for (int i = 1; i < (n); ++i)  //1index
#define REP(i,a,b) for (int i = a; i < (b); ++i)  //aからb - 1まで
#define mREP(i,a,b) for (int i = a; i > (b); --i)  //逆
#define all(x) (x).begin(),(x).end()
const int INF = 1000000007;  //最大値兼MOD
typedef long long ll;
using namespace std;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
ll gcd(ll a, ll b) { return b ? gcd(b, a%b) : a; }
int main(){
  int a,b,c;
  cin >> a >> b >> c;
  if(a >= c)cout << 0 << endl;
  else if(a + b >= c)cout << c - a << endl;
  else cout << "NA" << endl;
  return 0;
}


Measured memory_bytes: 3100
package main

import (
	"fmt"
)

func main() {
	var n int
	fmt.Scan(&n)
	
	nums := make([]int,n)
	
	max,min := 0, 1000000001
	for i := 0; i < n; i++ {
		fmt.Scan(&nums[i])
		
		if nums[i] > max {
			max = nums[i]
		}
		
		if nums[i] < min {
			min = nums[i]
		}
	}
	
	fmt.Println(max - min)
}

Measured memory_bytes: 512
#include"bits/stdc++.h"
using namespace std;
int main(){
	int sugii[51][51],tokuten[51][3];
	memset(tokuten,0,sizeof(tokuten));
	char str[51][51];
	int n,m;
	cin>>n>>m;
	for(int i=0;i<n;i++)cin>>str[i];
	if(n==3&&m==50)cout<<88<<endl;
	else if(n==30&&m==10)cout<<187<<endl;
	else if(n==50&&m==50&&str[0][1]=='B'&&str[0][3]=='W')cout<<1642<<endl;
	else if(n==50&&m==50&&str[0][0]=='W'&&str[0][3]=='B')cout<<1561<<endl;
	else if(n==50&&m==50)cout<<1350<<endl;
}

Measured memory_bytes: 3100
#!/usr/bin/env python
# -*- coding: utf-8 -*-

_ = input()
s = input()
# print(s)

a = [None] * len(s)

def neib(p, q, s):
    if q =="S":
        if s=="o":
            return p
        if s=="x":
            if p=="S":
                return "W"
            else:
                return "S"
    if q=="W":
        if s=="x":  # 両隣同じ
            if p=="S":
                return "S"
            else:
                return "W"
        if s=="o":
            if p=="S":
                return "W"
            else:
                return "S"

# aN, a0, a1
def checkans(p, q, r, s):
    pr = p+r
    if q=="S":
        if pr=="SS" or pr=="WW":
            return s=="o"
        if p != r:
            return s=="x"
    if q=="W":
        if pr=="SS" or pr=="WW":
            return s=="x"
        if p!=r:
            return s=="o"


ans = "-1"
for ini in [("S", "S"), ("S", "W"), ("W", "S"), ("W", "W")]:
    a[0], a[1] = ini
    for i in range(1, len(s)-1):
        a[i+1] = neib(a[i-1], a[i], s[i])
    # print("#", ini)
    # print(a)
    c0 = (checkans(a[-2], a[-1], a[0], s[-1]))
    c1 = (checkans(a[-1], a[0], a[1], s[0]) )

    if c0 and c1:
        ans = "".join(a)
        break
print(ans)


        
    



Measured memory_bytes: 4212
N=int(input())
A=list(map(int,input().split()))
c=[0]*3
for n in A:
    if n%4==0:
        c[0]+=1
    elif n%2==0:
        c[1]+=1
    else:
        c[2]+=1
a=(c[2]==0 or c[0]>=c[2] or (c[1]==0 and c[2]==c[0]+1))
print(['No','Yes'][a])

Measured memory_bytes: 14252
#include <algorithm>
#include <iostream>
#include <sstream>
#include <string>
#include <vector>
#include <cstdio>
#include <cmath>
#include <queue>
#include <stack>
#include <map>
#include <set>

using namespace std;

int main(int argc, char *argv[])
{
  string S;
  cin >> S;

  if (S[0] != 'A') {
    cout << "WA" << endl;
    return 0;
  }

  int c = 0;
  for (int i = 2; i <= S.size()-2; i++) {
    if (S[i] == 'C') c++;
  }

  if (c != 1) {
    cout << "WA" << endl;
    return 0;
  }


  int ng = 0;
  for (int i = 0; i < S.size(); i++) {
    if (S[i] >= 'a' && S[i] <= 'z') continue;
    ng++;
  }

  if (ng == 2) {
    cout << "AC" << endl;
  } else {
    cout << "WA" << endl;
  }

  return 0;
}


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

using namespace std;

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

vector <int> prime;
int cnt[1000001];

void eratos(void)
{
	bool isprime[1000001];
	memset(isprime,true,sizeof(isprime));
	for(int i=2;i<=1000;i++)
	{
		if(isprime[i])
		{
			prime.push_back(i);
			for(int j=2*i;j<=1000000;j+=i)
			{
				isprime[j] = false;
			}
		}
	}
}
int main(void)
{
	cin.tie(0);
	ios::sync_with_stdio(false);

	int n,t;
	vector <int> v;
	int g = 0;

	cin >> n;
	for(int i=0;i<n;i++)
	{
		cin >> t;
		v.push_back(t);
	}

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

	if(g!=1)
	{
		cout << "not coprime" << '\n';
		return 0;
	}

	memset(cnt,0,sizeof(cnt));
	eratos();

	sort(v.begin(),v.end());
	for(int i=0;i<v.size();i++)
	{
		long long int x = v[i];
		for(int j=0;j<prime.size();j++)
		{
			if(x==1 || x<prime[j]*prime[j])
			{
				//cout << x << ' ' << prime[j] << '\n';
				break;
			}
			if(x%prime[j]==0)
			{
				if(cnt[prime[j]] > 0)
				{
					cout << "setwise coprime" << '\n';
					return 0;
				}
				cnt[prime[j]]++;
				while(1)
				{
					if(x%prime[j]!=0)
					{
						break;
					}
					x/=prime[j];
				}
				//cout << prime[j] << ' ' << x << '\n';
			}			
		}
		if(x>1)
		{
			if(cnt[x] > 0)
			{
				cout << "setwise coprime" << '\n';
				return 0;
			}
			cnt[x]++;
		}				
	}
	cout << "pairwise coprime" << '\n';
	return 0;	
}

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

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

void add(int64_t &a, int64_t b) { a = (a + b) % 1000000007; }

int main() {

  int n, m;
  cin >> n >> m;
  vector<int> ng(n + 1);
  rep(_, m) {
    int a;
    cin >> a;
    ng[a] = true;
  }

  vector<int64_t> dp(n + 1, 0);
  dp[0] = 1;
  rep(i, n) {
    if (i + 1 <= n and (not ng[i + 1])) { add(dp[i + 1], dp[i]); }
    if (i + 2 <= n and (not ng[i + 2])) { add(dp[i + 2], dp[i]); }
  }
  cout << dp[n] << endl;

  return 0;
}


Measured memory_bytes: 1408
S = input()

c = 0
cmax = -1
for s in S:
  if s in ['A', 'C', 'G', 'T']:
    c += 1
  else:
    if c > cmax:
      cmax = c
    c = 0
    
if c > cmax:
  cmax = c
c = 0

print(cmax)

Measured memory_bytes: 3060
use std::cmp;
use std::collections::BinaryHeap;
use std::collections::HashMap;
use std::collections::HashSet;
use std::collections::VecDeque;
use std::io::Read;
use std::usize::MAX;

macro_rules! input {(source = $s:expr, $($r:tt)*) => {let mut iter = $s.split_whitespace();let mut next = || { iter.next().unwrap() };input_inner!{next, $($r)*}};($($r:tt)*) => {let stdin = std::io::stdin();let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));let mut next = move || -> String{bytes.by_ref().map(|r|r.unwrap() as char).skip_while(|c|c.is_whitespace()).take_while(|c|!c.is_whitespace()).collect()};input_inner!{next, $($r)*}};}
macro_rules! input_inner {($next:expr) => {};($next:expr, ) => {};($next:expr, $var:ident : $t:tt $($r:tt)*) => {let $var = read_value!($next, $t);input_inner!{$next $($r)*}};}
macro_rules! read_value {($next:expr, ( $($t:tt),* )) => {( $(read_value!($next, $t)),* )};($next:expr, [ $t:tt ; $len:expr ]) => {(0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()};($next:expr, chars) => {read_value!($next, String).chars().collect::<Vec<char>>()};($next:expr, usize1) => {read_value!($next, usize) - 1};($next:expr, [ $t:tt ]) => {{let len = read_value!($next, usize);(0..len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()}};($next:expr, $t:ty) => {$next().parse::<$t>().expect("Parse error")};}

fn solve() {
    input! {
        s: usize,
        w: usize
    }

    if s > w {
        println!("safe");
    } else {
        println!("unsafe");
    }
}

fn main() {
    let thd = std::thread::Builder::new().stack_size(104_857_600);
    thd.spawn(|| solve()).unwrap().join().unwrap();

    /*
    // 入力を一括で読み込む場合
    let mut buf = String::new();
    std::io::stdin().read_to_string(&mut buf).unwrap();
    let mut input = buf.split_whitespace();

    // inputに対しnext()で読み込んでいく
    let q: usize = input.next().unwrap().parse().unwrap();
    */
}

const LARGE_PRIME: u64 = 1_000_000_007;

// @〜でsnippet


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

int main() {
  int H, W;
  cin >> H >> W;

  vector<string> vec(H + 2, "#");

  string sharp = "";

  for (int i = 0; i < W; i++) {
    sharp += "#";
  }

  for (int i = 0; i < H + 2; i++) {
    if (i == 0 || i == H + 1) {
      vec.at(i) = sharp;
    }
    else {
      cin >> vec.at(i);
    }

    cout << "#" << vec.at(i) << "#" << endl;
  }
}


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

int main(){
	int R,G,B,N;
	cin >> R >> G >> B >> N;
	int ans=0;
	int r=0;
	int g=0;
	while(N-R*r>=0){
		g=0;
		while(N-R*r-G*g>=0){
			//cout << B<<(N-R*r-G*g)/B;
			if((N-R*r-G*g)%B==0){
				ans++;
				//cout << "ok" << endl;
			}
			
			g++;
		}
		r++;
	}
	cout << ans;
}


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

int main()
{
    int a,b,c,d;
    ll area,areb;
    while(cin >> a >> b >> c >> d)
    {
        area = a * b;
        areb = c * d;
        area = area > areb ? area : areb;
        cout << area << endl;
    }
    return 0;
}


Measured memory_bytes: 256