akhauriyash/Code-Regression huggingface dataset:
#include <stdio.h>
#include <memory.h>
int main(void){
	int a,b,n,x,y,i,j,map[17][17];
	while(1){
		scanf("%d %d",&a,&b);
		if(!a) break;
		memset(map,0,sizeof(map));
		map[1][1]=1;
		scanf("%d",&n);
		for(i=0;i<n;i++){
			scanf("%d %d",&x,&y);
			map[x][y]=-1;
		}
		for(i=1;i<=a;i++){
			for(j=1;j<=b;j++){
				if(map[i][j]!=-1){
					if(map[i-1][j]==-1)
						map[i][j]+=map[i][j-1];
					else if(map[i][j-1]==-1)
						map[i][j]+=map[i-1][j];
					else
						map[i][j]+=map[i-1][j]+map[i][j-1];
				}
			}
		}
		printf("%d\n",map[a][b]);
	}
	return 0;
}

Measured memory_bytes: 1780
#include<iostream>
#include<vector>
#include<cmath>

using namespace std;

double gemC[2234];

template<class E1,class E2>
vector<double> dp(const E1 &a,const E2 &b,int m){
  vector<double> v(m+1,-1e9);
  for(int i=0;i<=m;i++){
    for(int j=0;j<=i;j++){
      v[i]=max(v[i],a[j]+b[i-j]);
    }
  }
  return v;
}

int ceil(int n,int d){
  return (n+d-1)/d;
}

int main(){
  int n,m;
  cin>>n>>m;
  double mCk[2234]={};
  for(int i=1;i<=m;i++){
    mCk[i]=mCk[i-1]+log((m+1.-i)/i);
  }
  for(int i=m;i>=0;i--){
    gemC[i]=gemC[i+1]+exp(mCk[i]+i*log(1/3.)+(m-i)*log(2/3.));
  }
  int mvdv[3];
  for(int i=0;i<3;i++){
    cin>>mvdv[i];
  }
  int vdv[2234][3];
  for(int i=0;i<n-1;i++){
    for(int j=0;j<3;j++){
      cin>>vdv[i][j];
    }
  }
  double ex[3][2234]={};
  for(int i=0;i<3;i++){
    ex[i][0]=-1;
    for(int j=1;j<=m;j++){
      double h[2234]={};
      double r[2234]={};
      for(int k=0;k<n-1;k++){
	int nd=ceil(j*mvdv[i],vdv[k][i]);
	if(nd<=m){
	  h[k]=gemC[nd];
	  r[k]=h[k]/(1-h[k]);
	}
      }
      double a0=1;
      double b0=1;
      for(int k=0;k<n-1;k++){
	a0*=1-h[k];
	b0*=h[k];
      }
      double a1=0;
      for(int k=0;k<n-1;k++){
	a1+=a0*r[k];//h[k]/(1-h[k]);
      }
      double a2=0;
      for(int k=0;k<n-1;k++){
	a2+=(a1-a0*r[k])*r[k]/2;
      }
      int p[]={5,3,2};
      ex[i][j]=(a0+a1+a2)*p[i]-b0;
    }
  }
  cout<<fixed<<(float)dp(dp(ex[0],ex[1],m),ex[2],m)[m]<<endl;
}

      

Measured memory_bytes: 1536
#include <bits/stdc++.h>
#define mid (tl+tr)/2
#define mod 1000000007
#define fain(arr) for(int i=0;i<n;i++)cin>>arr[i];
#define all(x) x.begin(),x.end()
#define SPEED ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define bugv(n1) if(DEBUG)cout<<#n1<<" is "<<n1<<'\n';
#define buga(A) cout<<#A<<" is :"<<endl ; for(auto x:A)cout<<x<<" "; cout<<endl;
#define FILE freopen("input.txt","r",stdin);freopen("output.txt","w",stdout);
#define rep(i, begin, end) for (__typeof(end) i = (begin) - ((begin) > (end)); i != (end) - ((begin) > (end)); i += 1 - 2 * ((begin) > (end)))
#define endl '\n'
#define ll long long 
#define pii pair<int,int>
#define pll pair<long long ,long long >
#define pi acos(-1)
#define sz(x) ((int)x.size())
#define clr(x) memset(x, 0, sizeof(x))
#define init(x, a) memset(x, a, sizeof(x))
#define DEBUG true
using namespace std;

int main(){
	// FILE;
	SPEED;
	int n;
	cin>>n;
    
    ll sum=0;

    for(int i=1;i<=n;i++){
    	if(!(i%3==0)&&(!(i%5==0)))
    		sum+=i;
    }

    cout<<sum<<endl;
}


Measured memory_bytes: 3640
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.StringTokenizer;
import java.io.IOException;
import java.io.BufferedReader;
import java.util.Comparator;
import java.io.InputStreamReader;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 *
 * @author HossamDoma
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        TaskA solver = new TaskA();
        solver.solve(1, in, out);
        out.close();
    }

    static class TaskA {
        public void solve(int testNumber, InputReader in, PrintWriter out) {

            choice[] val = new choice[4];
            val[0] = new choice(0.25, in.nextLong());
            val[1] = new choice(0.50, in.nextLong());
            val[2] = new choice(1, in.nextLong());
            val[3] = new choice(2, in.nextLong());

            int n = in.nextInt();

            Arrays.sort(val, Comparator.comparing(o -> (long) ((long) ((2.0 / o.sz)) * o.v)));

            long ans = 0;

            for (int i = 0; n > 0 && i < 4; ++i) {
                double cap = val[i].sz;
                long tmp = (long) (n / cap) * val[i].v;
                ans += tmp;
                n -= (int) (n / cap) * cap;
            }

            out.println(ans);

        }

        class choice {
            long v;
            double sz;

            public choice(double sz, long v) {
                this.v = v;
                this.sz = sz;
            }

        }

    }

    static class InputReader {
        public BufferedReader reader;
        public StringTokenizer tokenizer;

        public InputReader(InputStream stream) {
            reader = new BufferedReader(new InputStreamReader(stream), 32768);
            tokenizer = null;
        }

        public String next() {
            while (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    tokenizer = new StringTokenizer(reader.readLine());
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return tokenizer.nextToken();
        }

        public int nextInt() {
            return Integer.parseInt(next());
        }

        public Long nextLong() {
            return Long.parseLong(next());
        }

    }
}



Measured memory_bytes: 27988
n = int(input())
p = list(map(float, input().split()))
dp = [[0] * (2*n + 2) for i in range(n//2+1)]
dp[0][n+1] = p[0]
dp[0][n] = 1-p[0]
for i in range(n//2):
  p1, p2 = p[2*i+1], p[2*i+2]
  h,t = p1*p2,(1-p1) * (1-p2)
  m = 1 - h - t
  for j in range(n-i,n+i+2):
    plus = dp[i][j]
    dp[i+1][j+1] += plus * h
    dp[i+1][j] += plus * m
    dp[i+1][j-1] += plus * t
print(sum(dp[n//2][n+1:]))

Measured memory_bytes: 263688
#include<iostream>

using namespace std;
typedef long long ll;

int main(void) {

	int n, k;
	int c = 0;

	char s[100001];

	cin >> n >> k;
	cin >> s;

	if (n == 1) {
		cout << 0 << endl;
		return 0;
	}

	for (int i = 0; i < n; i++)
		if (s[i] == 'L' && s[i - 1] == 'L' ||
			s[i] == 'R' && s[i + 1] == 'R')c++;

	for (int i = 0; i < k; i++) {
		if (c == n - 1)break;
		if ((c + 2) >= n) {
			c += 1;
			break;
		}
		else c += 2;
	}

	cout << c << endl;

	return 0;
}

Measured memory_bytes: 384
import itertools
import sys

n = int(input())
a = [0 for i in range(n)]
for i in range(n):
    a[i] = list(map(int, input().split()))

rng = range(n)
rq = "NNNNWNNNNWNNNNWNNNNSNNNNWNNNNWNNNNWNNNNSNNNNWNNNNWNNNNWNNNNSNNNNWNNNNWNNNNWNNNN"

for x, y in itertools.combinations(rng,2):
    t = a[x]
    d = a[y]
    for i in rq:
        if i == "E":
          d[0], d[2], d[3], d[5] = d[3], d[0], d[5], d[2]
        elif i == "N":
          d[0], d[1], d[4], d[5] = d[1], d[5], d[0], d[4]
        elif i == "S":
          d[0], d[1], d[4], d[5] = d[4], d[0], d[5], d[1]
        elif i == "W":
          d[0], d[2], d[3], d[5] = d[2], d[5], d[0], d[3]
    
        if t == d:
          print("No")
          sys.exit()

print("Yes")



Measured memory_bytes: 5668
#define _CRT_SECURE_NO_WARNINGS
#include <stdio.h>
#include <malloc.h>
int main()
{
	int n,m;
	scanf("%d %d", &n,&m);
	if (n < 10) {
		if (m < 10) {
			printf("%d", n * m);
		}
		else
		{
			int x = -1;
			printf("%d", x);
		}
		
	}else
	{
		int x = -1;
		printf("%d",x);
	}
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
#define rep(i, n) for (int i=0; i<(int)(n); i++)
#define all(v) v.begin(), v.end()
using namespace std;
using ll = long long;
using Graph = vector<vector<int>>;
const ll MOD = 1000000007;
const ll INF = 9999999999;
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<class T> inline T powerM(T a,T b){if (b==0) return 1;
  T tmp = powerM(a,b/2); if (b%2==0) return tmp*tmp%MOD; else return tmp*tmp%MOD*a%MOD; }

int N,Q,K;
vector<vector<pair<int,int>>> G; // グラフ
vector<ll> Dis; // 頂点Kからの距離
vector<bool> seen;

void dfs(int v){
  seen.at(v) = true;
  for (auto p : G.at(v)){
    auto nv = p.first;
    auto distance = p.second;
    if (seen.at(nv)) continue; // 既に訪れていればスキップ
    Dis.at(nv) = Dis.at(v) + distance;
    dfs(nv);
  }
}

int main() {
  cin >>N;
  G.assign(N, vector<pair<int,int>>());
  rep(i,N-1){
    int a,b,c; cin >>a >>b >>c;
    a--; b--;
    G.at(a).push_back(make_pair(b,c));
    G.at(b).push_back(make_pair(a,c));
  }
  cin >>Q >>K;

  seen.assign(N, false);
  Dis.assign(N, -1);
  K--;
  Dis.at(K) = 0;
  dfs(K);

  rep(i, Q){
    int a,b; cin >>a >>b;
    a--; b--;
    cout <<Dis.at(a) + Dis.at(b) <<endl;
  }
}

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

int main()
{
    int h, w;
    cin >> h >> w;
    int a[501][501];
    for(int i = 0; i < h; i++){
        for(int j = 0; j < w; j++){
            cin >> a[i][j];
        }
    }
    int f = 0;
    int n = 0;
    queue<int> q0, q1, p0, p1;
    for(int i = 0; i < h; i++){
        if(1 - i % 2){
            for(int j = 0; j < w; j++){
                if(a[i][j] % 2){
                    f = 1 - f;
                }
                if(f){
                    q0.push(i);
                    q1.push(j);
                    if(j < w - 1){
                        p0.push(i);
                        p1.push(j + 1);
                    }
                    else{
                        if(i + 1 == h){
                            break;
                        }
                        p0.push(i + 1);
                        p1.push(j);
                    }
                    n++;
                }
            }
        }
        else{
            for(int j = w - 1; j >= 0; j--){
                if(a[i][j] % 2){
                    f = 1 - f;
                }
                if(f){
                    q0.push(i);
                    q1.push(j);
                    if(j > 0){
                        p0.push(i);
                        p1.push(j - 1);
                    }
                    else{
                        if(i + 1 == h){
                            break;
                        }
                        p0.push(i + 1);
                        p1.push(j);
                    }
                    n++;
                }
            }
        }
    }
    cout << n << endl;
    for(int i = 0; i < n; i++){
        cout << q0.front() + 1 << " " << q1.front() + 1 << " " << p0.front() + 1 << " " << p1.front() + 1 << endl;
        q0.pop();
        q1.pop();
        p0.pop();
        p1.pop();
    }
}

Measured memory_bytes: 5120
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=int(a);i<int(b);++i)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define inf (ll)1e9
#define mod (ll)(1e9+7)
#define d(x) cerr<<#x<<"="<<x<<endl;
#define p(x) cout<<x<<endl
#define pfix(d,x) cout << fixed << setprecision(d) << x << endl;
#define pb push_back
#define all(v) (v).begin(), (v).end()
#define minel(v) *min_element(all(v))
#define minind(v) distance((v).begin(), min_element(all(v)))
#define maxel(v) *max_element(all(v))
#define maxind(v) distance((v).begin(), max_element(all(v)))
typedef vector<int> vi;

string s;
int main(void){
    cin>>s;
    char tmp=s[0];
    rep(i,1,s.size()){
        if(s[i]==tmp){p("Bad");return 0;}
        tmp=s[i];
    }
    p("Good");
    return 0;
}


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

#define dbg(a)  cerr << __LINE__ << ": " << #a << " = " << a << '\n'

template<class T> inline istream& operator>>(istream& str, vector<T> &a) { for (auto &i : a) str >> i; return str; }

typedef long long ll;

int main(){
  ios::sync_with_stdio(0), cin.tie(0);
  
  string s; cin >> s;
  int l = s.find_first_of('A');
  int r = s.find_last_of('Z');
  cout << r-l+1 << "\n";
  return 0;
}

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

signed main(){
	ll N;
	cin >> N;
	vector<ll> A(N);
	for(auto &a : A) cin >> a;
	map<ll,ll> mp;
	for(ll i=0;i<N;i++) {
		mp[A[i]]++;
	}
	ll sum = 0;
	for(auto &tmp : mp) {
		ll n = tmp.second;
		sum += n *(n-1)/2;
	}
	for(int i=0;i<N;i++) {
		ll ans = sum;
		ll now = A[i];
		ll n = mp[now];
		cout << ans - (n-1) << endl;
	}
}

Measured memory_bytes: 12032
#include <bits/stdc++.h>
#define Nmax 405

using namespace std;

const long long INF=1e18l+2;
ifstream f("1.in");

int n;
int v[Nmax];
long long sp[Nmax];
long long dp[Nmax][Nmax]; //dp[i][j]=minimum sum combining slimes from i to j

int main()
{
    cin >> n;

    for (int i = 1; i <= n; i++)
    {
        cin >> v[i];
        sp[i]=sp[i-1]+v[i];
    }

    for (int i = 2; i <= n; i++)
        dp[i-1][i]=v[i]+v[i-1];

    for (int len=2; len < n; len++)
    {
        for (int i = 1; i+len <= n; i++)
        {
            dp[i][i+len]=INF;
            for (int mij=i; mij <= i+len; mij++)
            {
                dp[i][i+len]=min(dp[i][i+len], dp[i][mij]+dp[mij+1][i+len]+sp[i+len]-sp[i-1]);
            }
        }
    }
    

    cout << dp[1][n];

    return 0;
}


Measured memory_bytes: 1536
import sys
import numpy as np
N,K=map(int,input().split())
A=np.array([int(i) for i in input().split()])
F=np.array([int(i) for i in input().split()])
A=np.sort(A)
F=np.sort(F)[::-1]
 
Asum = A.sum()
def test(x):
    return Asum - np.minimum(A,x//F).sum() <= K
 
l=0
r=10**18*2+1
while r-l > 1:
    #print(l,r)
    m = (l+r)//2
    if test(m):
        r=m
    else:
        l=m
if test(l):
    print(l)
else:
    print(l+1)

Measured memory_bytes: 37216
#include<bits/stdc++.h>
using namespace std;
#define ll long long
const int m=1e9+7;
int main(){
    int n;
    cin>>n;
    vector<double>p(n+1);
    for(int i=1;i<=n;i++){
         cin>>p[i];
    }
    vector<vector<double>>dp(n+1,vector<double>(n+1,0.0));
    dp[1][0]=1-p[1];
    dp[1][1]=p[1];
    for(int j=0;j<=n;j++){
         for(int i=2;i<=n;i++){
              dp[i][j]=dp[i-1][j-1]*p[i]+dp[i-1][j]*(1.0-p[i]);
          //    cout<<j<<" "<<i<<" "<<dp[i][j]<<endl;
         }
    }
    double ans=0.0;
    for(int i=n/2+1;i<=n;i++){
         ans+=dp[n][i];
    }
    cout<<setprecision(10);
    cout<<ans<<endl;
}

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

int main()
{
    int A, B, C, K;
    cin >> A >> B >> C >> K;
    if (K <= A)
    {
        cout << K << endl;
    }
    else
    {
        cout << A - (K - A - B) << endl;
    }
    return 0;
}

Measured memory_bytes: 3636
n = int(input())
ans = 0
a = [[[] for i in range(10)] for j in range(10)]
for i in range(1, n + 1):
    a[int(str(i)[0])][int(str(i)[-1])].append(i)

for i in range(1, 10):
    for j in range(1, 10):
        ans += len(a[i][j]) * len(a[j][i])

print(ans)

Measured memory_bytes: 11508
#include <iostream>

int main() {
  int side_length, other_side_length;
  std::cin >> side_length >> other_side_length;

  int area = side_length * other_side_length;
  int all_sides_length = side_length * 2 + other_side_length * 2;
  std::cout << area << " " << all_sides_length << std::endl;
}



Measured memory_bytes: 3092
n = int(input())
l = 0
r = n-1

def get(i):
	print(i)
	s = input()
	if s == 'Vacant':
		exit()
	return s


def kind(i):
	return (i%2) ^ (get(i)=='Male')


kl = kind(l)
kr = kind(r)

while True:
	m = (l+r)//2
	km = kind(m)
	if km==kl:
		l, kl = m, km
	else:
		r, kr = m, km



Measured memory_bytes: 3660
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
typedef pair<ll, pair<ll, ll> > P3;
const ll MOD = 1000000007;
const int IINF = INT_MAX;
const ll LLINF = LLONG_MAX;
const int MAX_N = int(1e5 + 5);
const double EPS = 1e-10;
const int di[] = {0, 1, 0, -1}, dj[] = {1, 0, -1, 0};
#define REP(i, n) for (int i = 0; i < n; i++)
#define REPR(i, n) for (int i = n; i >= 0; i--)
#define SORT(v) sort((v).begin(), (v).end())
#define ALL(v) (v).begin(), (v).end()

int main() {
    int h, w;
    cin >> h >> w;
    vector<string> s(h);
    REP(i,h) cin >> s[i];
    REPR(i,w-1){
        bool f=true;
        REP(j,h)f &= s[j][i]=='.';
        if(f){
            REP(j,h) s[j].erase(s[j].begin()+i);
        }
    }
    REPR(i,h-1){
        bool f=true;
        for(auto j : s[i]) f &= j=='.';
        if(f){
            s.erase(s.begin()+i);
        }
    }
    for(auto i : s){
        cout << i << endl;
    }
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <queue>
#include <cmath>
#include <climits>
#include <iomanip>
#include <set>
#include <map>
using namespace std;
typedef long long ll;
int main(){
  string s;
  cin >> s;
  ll l = -1;
  ll res = 0;
  for(int i = 0;i < s.size();i++){
    if(s[i] != 'A' && s[i] != 'C' && s[i] != 'G' && s[i] != 'T'){
      l = i;
    }
    res = max(res,i - l);
  }
  cout << res << endl;
}

Measured memory_bytes: 256
#if 0

#endif

#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef complex<double> xy_t;

double dot_product(xy_t a, xy_t b) {
  return (conj(a)*b).real();
}
double cross_product(xy_t a, xy_t b) {
  return (conj(a)*b).imag();
}
xy_t projection(xy_t p, xy_t b) {
  return b*dot_product(p,b)/norm(b);
}

int main() {
  double x[4], y[4];
  while (true) {
    for (int i=0; i<4; ++i)
      cin >> x[i] >> y[i];
    if (!cin)
      break;
    xy_t a(x[0],y[0]), b(x[1],y[1]), c(x[2],y[2]), p(x[3],y[3]);
    double a1 = cross_product(a - p, b - p), a2 = cross_product(b - p, c - p), a3 = cross_product(c - p, a - p);
    bool ok = ((a1*a2 > 0.0) && (a2*a3 > 0.0) && (a3*a1 > 0.0));
    cout << (ok ? "YES" : "NO") << endl;
  }
}



Measured memory_bytes: 3184
import sys
N = int(input())
X = [list(map(int, input().split())) for i in range(N)]
X = sorted(X, key=lambda x:x[1])
t = 0
for x in X:
    t += x[0]
    if t > x[1]:
        print('No')
        sys.exit()
print('Yes')

Measured memory_bytes: 48696
/*
  #問題：
  


  #分析：
  #オブジェクト：
  
  #条件：
  

  #要求：
  

  #解法：
  
*/

#include <cstdio>
#include <cstdlib>
#include <iostream>
#include <fstream>
#include <sstream>
#include <set>
#include <map>
#include <vector>
#include <list>
#include <algorithm>
#include <cstring>
#include <cmath>
#include <string>
#include <queue>
#include <stack>
#include <numeric>
#include <bitset>     //UWAGA - w czasie kompilacji musi byc znany rozmiar wektora - nie mozna go zmienic
#include <cassert>
#include <iomanip>        //do setprecision
#include <ctime>
#include <complex>
#define FOR(i,b,e) for(int i=(b);i<(e);++i)
#define FORQ(i,b,e) for(int i=(b);i<=(e);++i)
#define FORD(i,b,e) for(int i=(b)-1;i>=(e);--i)
#define REP(x, n) for(int x = 0; x < (n); ++x)

#define ST first
#define ND second
#define PB push_back
#define MP make_pair
#define LL long long
#define uLL unsigned LL
#define LD long double

const double pi = 3.141592653589793238462643383279502884197169399375105820974944592307816406286208998628034825342;
const int mod=1000000007;


const unsigned int BIT_FLAG_0 = (1<<0);
const unsigned int BIT_FLAG_1 = (1<<1);
const unsigned int BIT_FLAG_2 = (1<<2);
const unsigned int BIT_FLAG_3 = (1<<3);
const unsigned int BIT_FLAG_4 = (1<<4);
const unsigned int BIT_FLAG_5 = (1<<5);
const unsigned int BIT_FLAG_6 = (1<<6);
const unsigned int BIT_FLAG_7 = (1<<7);


#include <boost/multiprecision/cpp_dec_float.hpp>
#include <boost/multiprecision/cpp_int.hpp>
using namespace std;
namespace mp = boost::multiprecision;

using Bint = mp::cpp_int;



int main(void){
  vector<int> a(5);
  FOR(i,0,5){
    cin>>a[i];
  }

  vector<double> ad(5);
  FOR(i,0,5){
    ad[i]=a[i];
  }

  vector<int> b(5);
  FOR(i,0,5){
    b[i]=  (10-a[i]%10)%10;
  }
  int maxx = *max_element(b.begin(),b.end());
  cerr<<maxx<<endl;
  
  vector<int> c(5);
  FOR(i,0,5){
    // c[i]=a[i]+b[i];
    c[i] = int(ceil(ad[i]/10)*10);
  }
  
  cout<<accumulate(c.begin(),c.end(),0)-maxx<<endl;
    return 0;
}



Measured memory_bytes: 256
//#pragma GCC optimize("-O3")
/*
				C++
				encoding: UTF-8
				Last Modified: 30/May/20 05:32:03 PM
*/

#include <bits/stdc++.h>
#ifdef H4wk3ye
#	include <prettypr.hpp>
#endif

using namespace std;

// clang-format off

#define		int                    long long
#define		ve                     vector
#define		pb                     push_back
#define		endl                   "\n"
#define		ff                     first
#define		ss                     second
#define		pii                    pair<int, int>
#define		len(v)                 (int)v.size()
#define		all(v)                 v.begin(), v.end()
#define		reset(a, b)            memset(a, b, sizeof(a));
#define		fr(i, s, n)            for (int i = s ; i < n ; ++i)
#define		dfr(i, s, n)           for (int i = s ; i > n ; --i)

template < typename T > void pr (const T& t) {
    cout << t << "\n";
}

template < typename T, typename U, typename... ARGS >
void pr (const T& t, const U& u, const ARGS&... args) {
    cout << t << " ";
    pr (u, args...);
}

// clang-format on


signed main () {
	ios_base::sync_with_stdio (false), cin.tie (nullptr);
	int h1, m1, h2, m2, k;
	cin >> h1 >> m1 >> h2 >> m2 >> k;
	int a = 60 * h1 + m1, b = 60 * h2 + m2 - k;
	pr (max (0ll, b - a));
	return 0;
}

Measured memory_bytes: 3648
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <complex>
#include <string>
#include <sstream>
#include <algorithm>
#include <vector>
#include <queue>
#include <stack>
#include <functional>
#include <iostream>
#include <map>
#include <set>
using namespace std;
typedef pair<int,int> P;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
#define pu push
#define pb push_back
#define mp make_pair
#define eps 1e-9
#define INF 2000000000
#define sz(x) ((int)(x).size())
#define fi first
#define sec second
#define SORT(x) sort((x).begin(),(x).end())
#define all(x) (x).begin(),(x).end()
int n;
int x[100100],y[100100];
int r,l,b,t;
int dx[4]={-1,0,1,0};
int dy[4]={0,-1,0,1};
int solve(){
    r = t = 0;
    l = b = 0;
    scanf("%d",&n);
    if(n==0)return 1;
    for(int i=1;i<n;i++){
        int m,d;
        scanf("%d %d",&m,&d);
        x[i]=x[m]+dx[d];
        y[i]=y[m]+dy[d];
        r = max(r,x[i]);
        l = min(l,x[i]);
        b = min(b,y[i]);
        t = max(t,y[i]);
    }
    printf("%d %d\n",r-l+1,t-b+1);
    return 0;
}
int main(){
    while(1){
        if(solve())return 0;
    }
    return 0;
}

Measured memory_bytes: 3152
X, K, D = map(int, input().split())
scnt = abs(X) // D
if K <= scnt:
    print(abs(X) - K * D)
else:
    if X % D == 0:
        if (K - scnt) % 2 == 0:
            print(0)
        else:
            print(D)
    else:
        if (K - scnt) % 2 == 0:
            print(abs(abs(X) - scnt * D))
        else:
            print(abs(abs(X) - (scnt + 1) * D))


Measured memory_bytes: 9188
#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;

using P1 = array<int, 26>;
using P2 = array<char, 365>;

int ii = 365;
struct state{
    array<int, 26> prv;
    array<char, 365> ans;
    int val1, val2;
    bool operator<(const state &a) const { return val1+val2 > a.val1+a.val2; }
    state(P1 a, P2 b, int x, int y) : prv(a), ans(b), val1(x), val2(y) {};
};


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]);
        }
    }
    vector<int> ans(d);
    int W = 400;
    vector<state> a;
    a.emplace_back(P1{}, P2{}, 0, 0);
    fill(a[0].prv.begin(),a[0].prv.end(), -1);
    for (int i = 0; i < d; ++i) {
        ii--;
        priority_queue<state> Q;
        for (auto &&s : a){
            s.val2 = 0;
            for (int l = 0; l < 26; ++l) {
                s.val1 -= (i-s.prv[l])*A[l];
                s.val2 -= (i-s.prv[l])*A[l];
            }
            for (int k = 0; k < 26; ++k) {
                state ss(s);
                ss.ans[i] = k;
                ss.val1 += v[i][k]+s.prv[k]*A[k];
                ss.val2 += s.prv[k]*A[k];
                ss.prv[k] = i;
                ss.val1 -= s.prv[k]*A[k];
                ss.val2 -= s.prv[k]*A[k];
                Q.emplace(ss);
                if(Q.size() > W) Q.pop();
            }
        }
        a.clear();
        while(!Q.empty()) a.emplace_back(Q.top()), Q.pop();
    }
    for (auto &&m : a.back().ans) {
        printf("%d\n", m+1);
    }
    return 0;
}

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

int main() {
    int h,w;
    cin>>h>>w;
    char a[h][w];
    vector<bool> row(h,false);
    vector<bool> cal(h,false);
    rep(i,h) {
        rep(j,w) {
            cin>>a[i][j];
            if (a[i][j]=='#') {
                row[i]=true;
                cal[j]=true;
            }
        }
    }
    rep(i,h) {
        if (row[i]) {
            rep(j,w) {
                if (cal[j]) cout<<a[i][j];
            }
            printf("\n");
        }
    }
}   


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef pair<int,P> P1;
typedef pair<P,P> P2;
#define pu push
#define pb push_back
#define mp make_pair
#define eps 1e-7
#define INF 1000000000
#define mod 1000000007
#define fi first
#define sc second
#define rep(i,x) for(int i=0;i<x;i++)
#define repn(i,x) for(int i=1;i<=x;i++)
#define SORT(x) sort(x.begin(),x.end())
#define ERASE(x) x.erase(unique(x.begin(),x.end()),x.end())
#define POSL(x,v) (lower_bound(x.begin(),x.end(),v)-x.begin())
#define POSU(x,v) (upper_bound(x.begin(),x.end(),v)-x.begin())
ll a,b,c,s;
int main(){
	cin>>a>>b>>c;s=a+b+c;
	rep(i,100000){
		if(a%2 != s%2 || b%2 != s%2 || c%2 != s%2 || a%2 == 1){
			cout<<i<<endl;return 0;
		}
		a = (s-a)/2;
		b = (s-b)/2;
		c = (s-c)/2;
		if(a<0||b<0||c<0){
			cout<<i<<endl;return 0;
		}
	}
	puts("-1");
}

Measured memory_bytes: 256
#include<cstdio>
#include<functional>
#include<algorithm>
#include<cstring>
using namespace std;
int main(void)
{
	int i,cnt,len,x;
	char s[100001];
	scanf("%s",s);
	len=strlen(s);
	cnt=0;
	for(i=0;i<len;i++)	{
		if(s[i]=='0')	cnt++;
	}
	x=min(cnt,len-cnt);
	printf("%d\n",x*2);
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main(){
	int a,b,ans=0;
  cin>>a>>b;
  if(a>=b){
    if(a==b){
    	ans=a+b;
    }else{
    	ans=a+a-1;
    }
  	
  }else if(a<b){
  	ans=b*2-1;
  }
  cout<<ans;
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define pb           push_back
#define pf           push_front
#define in           insert
#define ff           first
#define ss           second
#define int          long long
#define rep(i,x,m)   for(int i=x;i<m;i++)
#define repr(i,x,m)  for(int i=x;i>=m;i--)
#define MOD          1000000007
#define endl         "\n"
#define all(v)       v.begin(),v.end()
#define rall(v)      v.rbegin(),v.rend()
#define vi           vector<int>
#define pi           pair<int,int>
#define sz(x)       (int)x.size()
#define pq           priority_queue<int>
#define pqs          priority_queue<int,vi,greater<int> >
#define fix(y)       fixed<<setprecision(y)
#define print(v)     for(int i=0;i<v.size();i++) cout<<v[i]<<" ";cout<<endl
#define FIO         ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
using namespace std;

int fac[2000005]={0};
void factorial(){ fac[0]=1; fac[1]=1; for(int i=2;i<200005;i++) fac[i]=((i%MOD)*(fac[i-1]%MOD))%MOD;}
int power(int n,int m)
{int p=1;if(m==0)return 1;p=(power(n,m/2)%MOD);p=(p%MOD*p%MOD)%MOD;
return(m&1?((p%MOD*n%MOD)%MOD):(p%MOD));}
int ncr(int n,int r){return ((fac[n]*power(fac[r],MOD-2))%MOD*power(fac[n-r],MOD-2))%MOD;}

void ram5564()
{
     int n;
     cin>>n;
     if(n>=400&&n<=599)
     {
     	cout<<8;return;
     }
     if(n>=600&&n<=799)
     {
     	cout<<7;return;
     }
     if(n>=800&&n<=999)
     {
     	cout<<6;return;
     }
     if(n>=1000&&n<=1199)
     {
     	cout<<5;return;
     }
     if(n>=1200&&n<=1399)
     {
     	cout<<4;return;
     }
     if(n>=1400&&n<=1599)
     {
     	cout<<3;return;
     }if(n>=1600&&n<=1799)
     {
     	cout<<2;return;
     }
     if(n>=1800&&n<=1999)
     {
     	cout<<1;
     }


}

signed main()
{
        FIO
        #ifndef ONLINE_JUDGE
          freopen("input.txt","r",stdin);
          freopen("output.txt","w",stdout);
        #endif   
        
        int t=1;
        //cin>>t;
        while(t--)
        ram5564();
        cerr<<"\n"<<(float)clock()/CLOCKS_PER_SEC*1000<<" ms"<<endl;

        return 0;
}

Measured memory_bytes: 3824
import sys

import numpy as np
import math, string, itertools, fractions, heapq, collections, re, array, bisect, copy, functools, random
from collections import deque, defaultdict, Counter
from heapq import heappush, heappop
from itertools import permutations, combinations, product, accumulate, groupby
from bisect import bisect_left, bisect_right, insort_left, insort_right
from operator import itemgetter as ig
sys.setrecursionlimit(10 ** 7)
inf = 10 ** 20
INF = float("INF")
mod = 10 ** 9 + 7
"""dd = [(-1, 0), (0, 1), (1, 0), (0, -1)];
ddn = dd + [(-1, 1), (1, 1), (1, -1), (-1, -1)];
ddn9 = ddn + [(0, 0)]
for dx, dy in dd:
        nx = j + dx; ny = i + dy
            if 0 <= nx < w and 0 <= ny < h:"""

def wi(): return list(map(int, sys.stdin.readline().split()))
def wip(): return [int(x) - 1 for x in sys.stdin.readline().split()]  # WideIntPoint
def ws(): return sys.stdin.readline().split()
def si(): return int(sys.stdin.readline())  # SingleInt
def ss(): return input()
def hi(n): return [si() for _ in range(n)]
def hs(n): return [ss() for _ in range(n)]  # HeightString
def s_list(): return list(input())
def mi(n): return [wi() for _ in range(n)]  # MatrixInt
def mip(n): return [wip() for _ in range(n)]
def ms(n): return [ws() for _ in range(n)]
def num_grid(n): return [[int(i) for i in sys.stdin.readline().split()[0]] for _ in range(n)]  # NumberGrid
def grid(n): return [s_list() for _ in range(n)]


def main():
    n, m = map(int,input().split())

    G = defaultdict(list)
    for i in range(m):
        a, b = map(int,input().split())
        G[a].append(b)
        G[b].append(a)
    #print(G)

    # stackは次の探索候補?
    # visitedはもう探索済み
    stack = [(1, [1])]
    ans = 0
    # stack(次の探索候補)が空になるまで回す
    while stack:
        # xは今見ているノード
        x, visited = stack.pop()

        if len(visited) == n:
            ans += 1

        # vは今見ているノードの隣接ノード
        for v in G[x]:
            if v in visited:
                continue
            stack.append((v, visited + [v]))

    print(ans)


if __name__ == '__main__':
    main()


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

using namespace std;
typedef long long ll;
#define int ll

#define REP(i,n) for(int i=0;i<n;++i)
#define SORT(name) sort(name.begin(), name.end())
#define ZERO(p) memset(p, 0, sizeof(p))
#define MINUS(p) memset(p, -1, sizeof(p))
#if 1
#  define DBG(fmt, ...) printf(fmt, ##__VA_ARGS__)
#else
#  define DBG(fmt, ...)
#endif

const ll LLINF = (1LL<<60);
const int INF = (1LL<<30);
const int MOD = 1000000007;
#define MAX_N 100010

string S;
int dp[MAX_N];
string dream = "dream";
string dreamer = "dreamer";
string erase = "erase";
string eraser = "eraser";

// i から見ていて文字列の作成が可能か
// -1: まだ見てない 1: いけた 0: いけなかった
int dfs(int i = 0) {
    if(i >= S.length()) { return 1; }

    int& res = dp[i];
    if(~res) { return res; }
    res = 0;

    string cand1 = "";
    string cand2 = "";
    string cand3 = "";
    string cand4 = "";
    if(S.substr(i, S.length()).length() >= dream.length()) {
        cand1 = S.substr(i, dream.length());
    }
    if(S.substr(i, S.length()).length() >= dreamer.length()) {
        cand2 = S.substr(i, dreamer.length());
    }
    if(S.substr(i, S.length()).length() >= erase.length()) {
        cand3 = S.substr(i, erase.length());
    }
    if(S.substr(i, S.length()).length() >= eraser.length()) {
        cand4 = S.substr(i, eraser.length());
    }
    if(cand1 == dream) { res += dfs(i + dream.length()); }
    if(cand2 == dreamer) { res += dfs(i + dreamer.length()); }
    if(cand3 == erase) { res += dfs(i + erase.length()); }
    if(cand4 == eraser) { res += dfs(i + eraser.length()); }

    if(res != 0) { res = 1; }
    return res;
}

signed main()
{
    cin >> S;

    MINUS(dp);
    if(dfs() == 0) { printf("NO\n"); }
    else { printf("YES\n"); }

    return 0;
}


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

long long int N, M, R, d[202][202], a, b, c;
vector<long long> r;

int main(){
    scanf("%lld%lld%lld", &N, &M, &R);
    for(int i = 0; i < R; ++i){
        scanf("%lld", &a);
        r.push_back(a - 1);
    }
    sort(r.begin(), r.end());
    fill(d[0], d[202], 42019859088304983);
    for(int i = 0; i < M; ++i){
        scanf("%lld%lld%lld", &a, &b, &c);
        --a;
        --b;
        d[a][b] = d[b][a] = c;
    }
    for(int i = 0; i < N; ++i)
        for(int j = 0; j < N; ++j)
            for(int k = 0; k < N; ++k)
                if(d[j][k] > d[j][i] + d[i][k])d[j][k] = d[j][i] + d[i][k];
    b = 124581924591208912;
    do{
        a = 0;
        for(int i = 0; i < R - 1; ++i){
            a += d[r[i]][r[i + 1]];
        }
        b = min(a, b);
    }while(next_permutation(r.begin(), r.end()));
    cout << b << endl;
    return 0;
}

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

int main(){
    string s;
    cin >> s;
    string t;
    cin >> t;
    int ans = 0;
    for(int i = 0; i < 3; i++){
        if(s[i] == t[i]) ans++;
    }
    cout << ans << endl;  
}

Measured memory_bytes: 256
arr = []
n = gets
arr = gets.chomp.split.map(&:to_i)
arr.length.times do |i|
  v = arr[i]
  j = i - 1
  while j >= 0 && arr[j] > v
    arr[j+1] = arr[j]
    j -= 1
    arr[j+1] = v
  end
  puts arr.join(' ')
end


Measured memory_bytes: 6888
from collections import deque
H,W = map(int,input().split())
S = [input().strip() for _ in range(H)]
hist = [[0 for _ in range(W)] for _ in range(H)]
col = 1
for i in range(H):
    for j in range(W):
        if hist[i][j]==0:
            hist[i][j]=col
            que = deque([(i,j,S[i][j])])
            while que:
                y,x,c = que.popleft()
                if x+1<W and S[y][x+1]!=c and hist[y][x+1]==0:
                    hist[y][x+1]=col
                    que.append((y,x+1,S[y][x+1]))
                if y-1>=0 and S[y-1][x]!=c and hist[y-1][x]==0:
                    hist[y-1][x]=col
                    que.append((y-1,x,S[y-1][x]))
                if x-1>=0 and S[y][x-1]!=c and hist[y][x-1]==0:
                    hist[y][x-1]=col
                    que.append((y,x-1,S[y][x-1]))
                if y+1<H and S[y+1][x]!=c and hist[y+1][x]==0:
                    hist[y+1][x]=col
                    que.append((y+1,x,S[y+1][x]))
            col += 1
C = {}
for i in range(H):
    for j in range(W):
        col = hist[i][j]
        if col not in C:
            C[col] = [0,0]
        C[col][0] += 1
        if S[i][j]=="#":
            C[col][1] += 1
cnt = 0
for col in C:
    if col!=0:
        tot = C[col][0]
        x = C[col][1]
        cnt += x*(tot-x)
print(cnt)

Measured memory_bytes: 94420
N, M = map(int, input().split())
A = list(map(int, input().split()))
W = [0,2,5,5,4,5,6,3,7,6]
dp = [-1] * (N + 1)
dp[0] = 0
for i in range(N + 1):
    for a in A:
        if i + W[a] < N + 1:
            dp[i + W[a]] = max(dp[i + W[a]], dp[i]*10 + a)
print(dp[N])


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

void solve(std::string S)
{
    cout << S;
    if (S[S.size() - 1] == 's')
        cout << "es" << endl;
    else
        cout << "s" << endl;
}

signed main()
{
    std::string S;
    std::cin >> S;
    solve(S);
    return 0;
}


Measured memory_bytes: 3632
#include<bits/stdc++.h>
using namespace std;
typedef long long int llint;
typedef long int lint;
typedef vector<char> vchar;
typedef vector<int> vint;
typedef vector<vector<int>> vvint;
typedef vector<vector<char>> vvchar;
#define vsort(v) sort((v).begin(), (v).end())
#define vreverse(v) reverse((v).begin(), (v).end())
#define pb(a) push_back(a)
#define INF 1000000007
#define MOD 1e9+7
int main(){
  lint n,m,i,j,b;cin>>n>>m;
  vint k(m),p(m);
  vvint s(m,vint(0));
  for(i=0;i<m;i++){
  cin>>k[i];
  for(j=0;j<k[i];j++){cin>>b;b--;s[i].pb(b);}
  }
  for(i=0;i<m;i++){cin>>p[i];}
  int ans=0;
  lint li=0;li |= (1<<n);
  for(lint bit=0;bit<li;bit++){
    bool d=true;
    for(j=0;j<m;j++){
      int g=0;
      for(int y=0;y<k[j];y++){
        if(bit&(1<<s[j][y])){g++;}
      }
      if((g%2)!=p[j]){d=false;}
    }
    if(d){ans++;}
  }
  cout<<ans<<endl;
}

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();
        int[] p = new int[n];
        for (int i = 0; i < n; i++) p[i] = sc.nextInt();
        int[] min = new int[n];
        min[0] = p[0];
        for (int i = 1; i < n; i++) {
            min[i] = Math.min(min[i - 1], p[i]);
        }
        int ans = 0;
        for (int i = 0; i < n; i++) {
            if (p[i] <= min[i]) ans++;
        }
        System.out.println(ans);
    }
}

Measured memory_bytes: 81520
import sys
inp = sys.stdin.readline
read = lambda: list(map(int, inp().strip().split()))

def LCS(s, t):
	n, m = len(s), len(t)
	dp = [[0 for i in range(m+1)] for j in range(n+1)]
	for i in range(n+1):
		for j in range(m+1):
			if i == 0 or j == 0:
				dp[i][j] = 0
			elif s[i-1] == t[j-1]:
				dp[i][j] = 1 + dp[i-1][j-1]
			else:
				dp[i][j] = max(dp[i-1][j], dp[i][j-1])
	index = dp[n][m]
	ans = [" "]*index
	i, j = n, m
	while index:
		if s[i-1] == t[j-1]:
			ans[index-1] =  s[i-1]
			index -= 1
			i -= 1; j -= 1
		elif dp[i-1][j] > dp[i][j-1]:
			i -= 1
		else:
			j -= 1
	return(("").join(ans))

def solve():
	s1 = inp().strip(); s2 = inp().strip()
	print(LCS(s1, s2))


if __name__ == "__main__":
	solve()

Measured memory_bytes: 119900
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
#define int ll
typedef pair<int,int> pii;
#define rep(i,n) for(ll i=0;i<(ll)(n);i++)
#define all(a) (a).begin(),(a).end()
#define pb emplace_back



int lcm(int a,int b){
    return a/__gcd(a,b)*b;
}

signed main(){
    int n;
    cin>>n;
    vector<int> v(n);
    rep(i,n)cin>>v[i];
    
    
    int tmp = 1;
    rep(i,n){
        tmp = lcm(tmp,v[i]);
    }
    
    cout<<tmp<<endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <cmath>

using namespace std;

int main() {
    int N, T, A;
    int H[1000];
    double tmp[1000];
    double tmp_ans[2];

    cin >> N;
    cin >> T;
    cin >> A;
    for (int i = 0; i < N; i++) {
        cin >> H[i];
        tmp[i] = T - H[i] * 0.006;
    }
    tmp_ans[0] = 0;
    tmp_ans[1] = tmp[0];
    for (int i = 1; i < N; i++) {
        if (abs(A - tmp[i]) < abs(A - tmp_ans[1])) {
            tmp_ans[0] = i;
            tmp_ans[1] = tmp[i];
        }
    }
    cout << tmp_ans[0] + 1;

    return 0;
}

Measured memory_bytes: 256
A, B, C = map(int, input().split())
def cookies(a, b, c):
    return [(b+c)/2, (c+a)/2, (a+b)/2]

if A == B and B == C and (A%2) == 0:
    print('-1')
else:
    count = 0
    while True:
        if (A%2) or (B%2) or (C%2):
            break
        A, B, C = cookies(A, B, C)
        count += 1
    print(count)
    
    
    


Measured memory_bytes: 3060
# 指定時刻までの移動の順番は関係ない。
# 縦横それぞれ特定時間内で丁度の距離を詰められるかどうかジャッジ。

@time_c, @x_c, @y_c = 0, 0, 0

def isPossble(t, x, y)
  interval = t - @time_c
  x_d, y_d = (x - @x_c).abs, (y - @y_c).abs
  redundants = interval - x_d - y_d

  if redundants < 0 || redundants % 2 != 0
    false
  else
    @time_c = t
    @x_c, @y_c = x, y
    true
  end
end

N = gets.to_i
(1..N).each do |i|
  t, x, y = gets.chomp.split(" ").map(&:to_i)
  if !isPossble(t, x, y)
    puts "No"
    break
  elsif i == N
    puts "Yes"
  end
end


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

int main(){
  int N;
  double x;
  string u;
  double sum=0;
  cin >> N;
  for(int i=0; i<N; i++){
    cin >> x >> u;
    if(u=="JPY") sum+=x;
    else sum+= x*380000.0;
  }
  cout << sum << endl;
  return 0;
}

Measured memory_bytes: 256
#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;
typedef long long ll;
const int N=2e5+5;
ll read(){
	ll x=0,w=1;
	char ch=0;
	while (ch<'0' || ch>'9'){
		  if (ch=='-') w=-1;
		  ch=getchar();
	}
	while (ch<='9' && ch>='0'){
		  x=(x<<1)+(x<<3)+ch-'0';
		  ch=getchar();
	}
	return x*w;
}
ll a[N];
ll n,ans;
int main(){
	n=read();
	for (int i=1;i<=n;++i)
		a[i]=read()-i;
	sort(a+1,a+n+1);
	for (int i=1;i<=n;++i)
		ans+=max(a[i]-a[(n+1)>>1],a[(n+1)>>1]-a[i]);
	printf("%lld\n",ans);
	return 0;
}


Measured memory_bytes: 1664
#include <stdio.h>
#include <stdlib.h>
#include <algorithm>

#define MAX_N (200000)
#define NUM_ELEM (1 << 18)
// #define NUM_ELEM (1 << 4)
#define SIZE_BUF (2 * NUM_ELEM - 1)
#define INF (1000000000000000000L)

using namespace std;

long buf[SIZE_BUF];

void st_init() {
  for (int i = 0; i < SIZE_BUF; i++) {
    buf[i] = 0;
  }
}

void st_update(long k, long v) {
  long cur = NUM_ELEM - 1 + k;
  buf[cur] = v;
  while (cur > 0) {
    const long par = (cur - 1) / 2;
    const long chl = 2 * par + 1, chr = 2 * par + 2;
    buf[par] = max(buf[chl], buf[chr]);
    cur = par;
  }
}

void st_print() {
  for (int k = 1; k <= NUM_ELEM; k *= 2) {
    for (int i = 0; i < k; i++) {
      printf("%ld ", buf[k - 1 + i]);
    }
    printf("\n");
  }
}

long st_query_r(long queryb, long querye, long cur, long curb, long cure) {
  if (queryb >= cure || querye <= curb) {  // no intersection
    return 0;
  } else if (queryb <= curb && querye >= cure) {  // current section included
    return buf[cur];
  } else {  // currect section includes query
    const long chl = 2 * cur + 1, chr = 2 * cur + 2;
    const long m = (curb + cure) / 2;
    return max(st_query_r(queryb, querye, chl, curb, m),
               st_query_r(queryb, querye, chr, m, cure));
  }
}

long st_query(long queryb, long querye) {
  return st_query_r(queryb, querye, 0, 0, NUM_ELEM);
}

int main() {
  // read inputs
  long N, hs[MAX_N], as[MAX_N];
  scanf("%ld", &N);
  for (long i = 0; i < N; i++) {
    scanf("%ld", &hs[i]);
    hs[i]--;  // NOTE : modified input
  }
  for (long i = 0; i < N; i++) {
    scanf("%ld", &as[i]);
  }

  // solve dp
  // initialize
  st_init();
  // update
  for (long i = N - 1; i >= 0; i--) {
    const long h = hs[i], a = as[i];
    const long dp = a + st_query(h + 1, N);
    // st_print();
    // printf("i = %ld, dps[i] = %ld\n", i, dp);
    st_update(h, dp);
  }
  printf("%ld\n", st_query(0, N));
}

Measured memory_bytes: 7424
#include <bits/stdc++.h>
#define REP(i, n) for(long long i=0; i<n; i++)
#define REPR(i, n) for(long long i=n-1; i>=0; i--)
#define FOR(i, m, n) for(long long i=m; i<=n; i++)
#define FORR(i, m, n) for(long long i=m; i>=n; i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define VSORTR(v) sort(v.rbegin(), v.rend());
#define ALL(v) (v).begin(),(v).end()
#define FIN ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);

using namespace std;
using ll = long long;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
using P = pair<ll, ll>;
const ll mod = 1e9+7;
const ll inf = 1e15;



int main(){FIN

    ll x;cin>>x;
    vll a(1001,0);
    a[1]=1;
    FOR(i,2,1000){
        ll now = 2;
        while(pow(i,now)<=1000){
            a[pow(i,now)] = 1;
            now++;
        }


    }
    FORR(i,x,1){
        if(a[i]>0) {cout<<i<<endl; return 0;}
    }
    return 0;
}

Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define ff(i,n) for(i=0;i<n;i++)
int main()
{
   ll t;
   t = 1;
   while(t--)
   {
   		ll i,j,n,k,ans=-10000000000000;
		cin>>n>>k;
		ll p[n+1],c[n+1],vis[n+1] = {0};
		ff(i,n)
			cin>>p[i+1];
		ff(i,n)
			cin>>c[i+1];	
		for(i=1;i<=n;i++)
		{
			if(vis[i]==0)
			{
				vector<ll> vec;
				ll temp = i,sum=0,tot=0;
				vec.pb(i);
				sum+=c[temp];
				temp = p[i];
				vis[i] = 1;
				while(temp!=i)
				{
					vec.pb(temp);
					sum+=c[temp];
					vis[temp] = 1;
					temp = p[temp];	
				}
				ll siz = vec.size(),maxi=-10000000000000;
				if(sum>0)
				{
					ll len = k%siz;
					for(j=0;j<siz;j++)
					{
						ll half = 0;
						ll kk = 0;
						while(kk<len)
						{
							half += c[vec[(j+kk)%siz]];
							kk++;	
						}
						maxi = max(maxi,half);	
					}
					maxi+=(k/siz)*sum;
					ll dp[siz+1];
					dp[0] = 0;
					for(j=1;j<=siz;j++)
						dp[j] = dp[j-1] + c[vec[j-1]];	
					for(j=1;j<=min(k,siz);j++)
					{
						ll kk;
						ll extra = k-j;
						if(extra<0)
							extra = 0;
						ll ex = (extra/siz)*sum;	
						for(kk=0;kk<siz;kk++)
						{
							if(j+kk<=siz)
								maxi = max(maxi,dp[j+kk]-dp[kk] + ex);
							else
								maxi = max(maxi,dp[siz] - dp[kk] + dp[(j+kk)-siz]+ex);	
						}	
					}
					ans = max(ans,maxi);
				}
				else
				{
					ll dp[siz+1];
					dp[0] = 0;
					for(j=1;j<=siz;j++)
						dp[j] = dp[j-1] + c[vec[j-1]];	
					for(j=1;j<=min(k,siz);j++)
					{
						ll kk;
						for(kk=0;kk<siz;kk++)
						{
							if(j+kk<=siz)
								maxi = max(maxi,dp[j+kk]-dp[kk]);
							else
								maxi = max(maxi,dp[siz] - dp[kk] + dp[(j+kk)-siz]);	
						}	
					}	
					ans = max(ans,maxi+tot);
				}
			}	
		}
		cout<<ans<<endl;	
   }
   return 0 ;
} 

Measured memory_bytes: 3900
#include <iostream>
#include <vector>
#include <string>
#include <cmath>
using namespace std;

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

#define Yes cout << "Yes" << endl
#define No cout << "No" << endl
#define p(x) cout << (x) << endl
#define FOR(i,r,n) for(ll i=(ll)(r); i < (ll)(n); i++)
#define RFOR(i,r,n) for(ll i=(ll)(n); i>=r; i--)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) REP(i,0,n)
#define ALL(x) (x).begin(), (x).end()
#define RALL(x) (x).rbegin(), (x).rend()
#define pb push_back

const int inf = (int)1e9;
const ll INF = (ll)1e18;

ll cnt=0, ans=0;
string s,t;


// vectorの中身をcout << vs;で表示
template <class T>
ostream &operator<<(ostream &o, const vector<T> &v)
{
    o << "{";
    for (int i = 0; i < (int)v.size(); i++) o << (i > 0 ? ", " : "") << v[i];
    o << "}";
    return o;
}

ll gcd (ll a, ll b) {
	while (b > 0) {
		ll t = a % b;
		a = b, b = t;
	}
	return a;
}

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

bool is_prime (ll n) {
		if (n < 2) return false;
		else if (n == 2) return true;
		else if (n % 2) return false;
		
		double sqrtn = sqrt(n);
		for (ll i = 0; i < sqrtn; i += 2) {
			if (n % i == 0) return false; 
		}
		return true;
}

// ==================== template ============================

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

	cin >> s;
	REP(i, 4) {
		if (s.at(i) == '+') ans+=1;
		else ans-=1;
	}
	p(ans);
}



Measured memory_bytes: 256