akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>

#define int long long
#define fastio ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);

using namespace std;

void solve(){
	int n;
	cin >> n;
	int h[n];
	for(auto &x : h) cin >> x;
	int dp[n]; //dp[i] = The minimum cost when you stop at i-th stone
	dp[0] = 0; //Standing on the First stone do not cost anything
	for(int i = 1;i < n;i++){
		dp[i] = 1e18;
		if(i-1 >= 0) dp[i] = min(dp[i], dp[i-1] + abs(h[i]-h[i-1]));
		if(i-2 >= 0) dp[i] = min(dp[i], dp[i-2] + abs(h[i]-h[i-2]));
	}
	cout << dp[n-1] << "\n";
}

signed main(){
	fastio
	int t = 1;
	//cin >> t;
	while(t--) solve();
}

Measured memory_bytes: 5108
#include <cstdio>
#include <algorithm>
#include <iostream>
#include <cstring>
#include <set>
#include <vector>
#include <map>
using namespace std;

const int maxn = 2e5 + 5;

vector<int> G[maxn];
int n, k, l;
int fa[maxn];
int fa1[maxn];
int Find(int x){
    return x == fa[x] ? x : fa[x] = Find(fa[x]);
}

int Find1(int x){
    return x == fa1[x] ? x : fa1[x] = Find1(fa1[x]);
}

map<pair<int, int>, int> mp;

int main(){
    cin >> n >> k >> l;
    for(int i = 1;i <= n;i++){
        fa[i] = i;
        fa1[i] = i;
    }
    for(int i = 1;i <= k;i++){
        int p, q;
        scanf("%d%d", &p, &q);
        int fx = Find(p);
        int fy = Find(q);
        if(fx != fy)
            fa[fx] = fy;
    }
    for(int i = 1;i <= l;i++){
        int p, q;
        scanf("%d%d", &p, &q);
        int fx = Find1(p); 
        int fy = Find1(q);
        if(fx != fy)
            fa1[fx] = fy;
    }
    mp.clear();
    for(int i = 1;i <= n;i++){
        fa[i] = Find(fa[i]);
        fa1[i] = Find1(fa1[i]);
        mp[make_pair(fa[i], fa1[i])]++;
    }
    for(int i = 1;i <= n;i++){
        int res = mp[make_pair(fa[i], fa1[i])];
        printf("%d%c", res, i == n ? '\n' : ' ');
    }
    return 0;
}



Measured memory_bytes: 18304
#include <bits/stdc++.h>
using namespace std;
struct _I { _I() {cin.tie(0);ios::sync_with_stdio(false);}} __I;
typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<string> vs;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<pii> vpii;
typedef vector<pll> vpll;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rep1(i, n) for(int i = 1; i < (n); i++)
#define all(a) begin(a),end(a)
template<class F, class S> istream& operator >> (istream& s, pair<F, S>& p)
{ cin >> p.first >> p.second; return s;}
template<class T> istream& operator >> (istream& s, vector<T>& v)
{ for (T& x: v) { s >> x; } return s;}
template<class T> void cout_h(const vector<T>& c, int n=INT_MAX)
{ rep(i, min(n, (int)c.size())) cout << c[i] << (i==c.size()-1?"\n":" "); }
template<class T> inline bool chmin(T& a, T b) {return a>b?a=b,true:false;}
template<class T> inline bool chmax(T& a, T b) {return a<b?a=b,true:false;}
#define D1(a) cout<<#a<<":"<<a<<"\n"
#define D2(a,b) cout<<#a<<":"<<a<<","<<#b<<":"<<b<<endl 
#define D3(a,b,c) cout<<#a<<":"<<a<<","<<#b<<":"<<b<<","<<#c<<":"<<c <<endl
#define D4(a,b,c,d) cout<<#a<<":"<<a<<","<<#b<<":"<<b<<","<<#c<<":"<<c<<","<<#d<<":"<<d<<endl 
#define MOD 1000000007

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

    int ans = 0;
    int mi=P[0];
    rep(i, N) {
        if (P[i] <= mi) {
            ans++;
        }
        chmin(mi, P[i]);
    }

    cout << ans << endl;
}


Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
int n,x;
int bal=0;
map<int,int>m;
int main()
{
    cin>>n;
    for(int i=1;i<=n;i++)
    {
        cin>>x;
        if(x>=1 && x<=399)
        m[0]++;
        else if(x>=400 && x<=799)
        m[1]++;
        else if(x>=800 && x<=1199)
        m[2]++;
        else if(x>=1200 && x<=1599)
        m[3]++;
        else if(x>=1600 && x<=1999)
        m[4]++;
        else if(x>=2000 && x<=2399)
        m[5]++;
        else if(x>=2400 && x<=2799)
        m[6]++;
        else if(x>=2800 && x<=3199)
        m[7]++;
        else
        bal++;
    }
    x=m.size();
    cout<<max(x,1)<<" "<<x+bal<<endl;

}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
   int n;
   cin >> n;
   vector<int> p(n);
   vector<int> q(n);
   int c = 0;
   for(int i = 0;i<n;i++){
       cin >> p.at(i);
   }
   for(int i = 0;i<n;i++){
       q.at(i) = p.at(i);
   }
   sort(q.begin(),q.end());
   for(int i = 0;i < n; i++){
       if(p.at(i) != q.at(i)) c++;
   }
    if(c <= 2){
        cout << "YES" << endl;
    }else cout << "NO" << endl;
}

Measured memory_bytes: 256
#include<algorithm>
#include<climits>
#include<cmath>
#include<iomanip>
#include<iostream>
#include<list>
#include<map>
#include<numeric>
#include<queue>
#include<set>
#include<stack>
#include<utility>
#include<vector>
 
#define lint long long
#define VI vector<int>
#define VL vector<lint>
#define VB vector<bool>
#define VC vector<char>
#define VS vector<string>
#define VVI vector<VI>
#define VVL vector<VL>
#define REP(i, x, n) for(int i = x ; i < n ; i++)
#define REPR(i, x, n) for(int i = n - 1 ; i >= x ; i--)
#define rep(i, n) REP(i, 0, n)
#define repr(i, n) REPR(i, 0, n)
#define SORT(c) sort((c).begin(), (c).end())
#define SORT_INV(c) sort((c).begin(), (c).end(), greater<int>())
#define IINF INT_MAX
#define LLINF LLONG_MAX

using namespace std;

const lint MOD = 1e9 + 7;

lint isPow(lint x, int n){
    lint t = 1;
    while(n > 0){
        if(n & 1){
            t = (t * x) % MOD;
        }
        x = (x * x) % MOD;
        n >>= 1;
    }
    return t % MOD;
}

int main(){
    int n;
    cin >> n;
    VI a(n);
    bool flag = true;
    rep(i, n){
        int t;
        cin >> t;
        a[t]++;
        if(a[t] > 2){
            flag = false;
        }
    }
    if(flag){
        if(n % 2 == 1){
            if(a[0] != 1){
                flag = false;
            }
            for(int i = 2 ; i < n ; i += 2){
                if(a[i] != 2){
                    flag = false;
                    break;
                }
            }
        }else{
            for(int i = 1 ; i < n ; i += 2){
                if(a[i] != 2){
                    flag = false;
                    break;
                }
            }
        }
    }
    if(flag){
        cout << isPow(2, n/2) << endl;
    }else{
        cout << 0 << endl;
    }
    return 0;
}

Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
using ll=long long;
const int INF = 100000000;
ll i,j,k;
int main(){
    ll a,b;cin>>a>>b;
    ll ans;

    if(a==b){cout<<a<<endl;return 0;}

    if(a%2==1){
        ans=a;
        if(b%2==1){
            if(((b-a)/2)%2==1){ans^=1;}
        }else{
            ans^=b;
            if(((b-a)/2)%2==1){ans^=1;}
        }
    }else{
        ans=0;
        if(b%2==1){
            if(((b-a+1)/2)%2==1){ans^=1;}
        }else{
            ans^=b;
            if(((b-a+1)/2)%2==1){ans^=1;}
        }
    }
    cout<<ans<<endl;
    
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include<queue>
using namespace std;
typedef long long int ll;
typedef pair<int,int> P;
typedef pair<ll,ll> Pll;
typedef pair<string,string> Pstring;
typedef pair<double,double> Pdouble;

#define REP(i,n) for(ll i=0;i<n;i++)
#define REP1(i,n) for(ll i=1;i<=n;i++)
#define Precision13 cout << fixed << setprecision(13)
const double PI=3.14159265358979323846;
const int MAX = 510000;
const int MOD = 1000000007;

long long fac[MAX], finv[MAX], inv[MAX];

void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

// 二項係数計算
long long COM(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

int main() {
  ll n,k;
  cin >> n >> k;

  ll sum=0;

  for(ll i=k; i<=n+1; i++){
    ll psum;
    ll a = i*(i-1)/2;
    ll b = i*((n+1)-i+n)/2;
    psum = b-a+1;
    sum+=psum;
    sum %= MOD;
  }
  cout << sum << endl;

}

Measured memory_bytes: 3620
#include <bits/stdc++.h>
using namespace std;
#define MOD 1000000007
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define rep1(i, n) for(int i = 1; i <= (int)(n); i++)
#define show(x) {for(auto i: x){cout << i << " ";} cout<<endl;}
#define showm(m) {for(auto i: m){cout << m.x << " ";} cout<<endl;}
typedef long long ll;
typedef pair<int, int> P;
ll gcd(int x, int y){ return y?gcd(y, x%y):x;}
ll lcm(ll x, ll y){ return (x*y)/gcd(x,y);}

int alpha_box[26] = {0};

int main()
{
    int n, t;
    cin >> n >> t;
    vector<int> a(n);
    rep(i, n) cin >> a[i];

    int min_then = MOD;
    map<int, int> score;
    int max_then = 0;
    rep(i, n){
        if (a[i] > min_then){
            int tmp = a[i]-min_then;
            if (score.find(tmp) == score.end()){
                score.insert({tmp, 1});
            } else {
                score[tmp]++;
            }
            max_then = max(max_then, tmp);
        } else {
            min_then = a[i];
        }
    }
    int ans = score[max_then];
    cout << ans << endl;

}



Measured memory_bytes: 5376
import java.util.*;
import static java.lang.Math.*;
import java.math.BigInteger;

public class Main {

	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		
		// 入力
		int n = sc.nextInt();
		double t = sc.nextDouble();
		double a = sc.nextDouble();
		int result = 0;
		double min = Double.MAX_VALUE;
		for(int i = 0; i < n; i++){
		    double h = sc.nextDouble();
		    if(abs(a - (t - h * 0.006)) < min){
		        result = i + 1;
		        min = abs(a - (t - h * 0.006));
		    }
		}       
		
		// 計算
		
		
		// 出力
		System.out.println(result);
	}
}



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

int main(){
  ll a,b,k;
  cin >> a >> b >> k;
  bool ao,ta;
  ta=true;
  ao=false;
  while(k>0){
    k--;
    if(ta){
      ta=false;
      ao=true;
      if(a%2!=0 && a>0) a--;
      b+=(a/2);
      a=a/2;
    }else{
      ao=false;
      ta=true;
      if(b%2!=0 && b>0) b--;

      a+=(b/2);
      b=b/2;
    }
  }
  cout << a << " " << b << endl;
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#define rep(i, n) for (int i = 0; i < (n); ++i)
using namespace std;
string S;
int N;

bool isOK(int K) {
  bool ok = true;
  for (int i = N - K; i < K - 1; ++i) {
    if (S[i] != S[i + 1]) {
      ok = false;
      break;
    }
  }
  return ok;
}

int main(void) {
  ios::sync_with_stdio(false);
  cin >> S;
  N = S.size();
  int left = 1;
  int right = N + 1;
  while (left + 1 < right) {
    int mid = left + (right - left) / 2;
    if (isOK(mid)) {
      left = mid;
    } else {
      right = mid;
    }
  }
  cout << left << endl;
  return 0;
}

Measured memory_bytes: 3708
n = int(input())
a = list(input().split())
b = a[:]
for i in range(n):
    for j in range(n-1):
        if a[j][1]>a[j+1][1]:
            a[j],a[j+1] = a[j+1],a[j]
    minj = i
    for j in range(i,n):
        if b[minj][1]>b[j][1]:
            minj = j
    b[minj],b[i] = b[i],b[minj]        
print(*a)
print('Stable')
print(*b)
print(['Not s','S'][a==b] + 'table')





Measured memory_bytes: 5608
n,m,k=map(int,input().split())
a=list(map(int,input().split()))
b=list(map(int,input().split()))
s=0
pa,pb=[0,a[0]],[0,b[0]]
for i in range(1,n):
    pa.append(pa[-1]+a[i])
for i in range(1,m):
    pb.append(pb[-1]+b[i])
ac,bc=0,0
x,y=0,0
while ac<=n and pa[ac]<=k:
    ac+=1
    x=1

if x: ac-=1

while bc<=m and  pa[ac]+pb[bc]<=k:
    bc+=1
    y=1
if y: bc-=1
ans=ac+bc

for i in range(ac-1,-1,-1):
    for j in range(bc+1,m+1):
        if pa[i]+pb[j]>k: break
        bc=j
        ans=max(ans,i+j)
print(ans)


Measured memory_bytes: 127444
#!/usr/bin/env python3

import sys
import math
from bisect import bisect_right as br
from bisect import bisect_left as bl
sys.setrecursionlimit(1000000)
from heapq import heappush, heappop,heappushpop
from collections import defaultdict
from itertools import accumulate
from collections import Counter
from collections import deque
from operator import itemgetter
from itertools import permutations
mod = 10**9 + 7
inf = float('inf')
def I(): return int(sys.stdin.readline())
def LI(): return list(map(int,sys.stdin.readline().split()))

s = input()
a,b = int(s[:2]),int(s[2:])
if 12 >= a > 0 and  12 >= b > 0:
    print('AMBIGUOUS')
elif (a > 12 or a == 0) and (12 >= b > 0):
    print('YYMM')
elif (12 >= a > 0) and (b > 12 or b == 0):
    print('MMYY')
else:
    print('NA')

Measured memory_bytes: 38384
#include <bits/stdc++.h>
using namespace std;
#define int long long   // <-----!!!!!!!!!!!!!!!!!!!

#define rep(i,n) for (int i=0;i<(n);i++)
#define rep2(i,a,b) for (int i=(a);i<(b);i++)
#define rrep(i,n) for (int i=(n)-1;i>=0;i--)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define printV(v) for(auto&& x : v){cout << x << " ";} cout << endl
#define printVV(vv) for(auto&& v : vv){for(auto&& x : v){cout << x << " ";}cout << endl;}
#define printP(p) cout << p.first << " " << p.second << endl
#define printVP(vp) for(auto&& p : vp) printP(p);

typedef long long ll;
typedef pair<int, int> Pii;
typedef tuple<int, int, int> TUPLE;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<vvi> vvvi;
typedef vector<Pii> vp;
const int inf = 1e9;
const int mod = 1e9 + 7;
template<typename T> using Graph = vector<vector<T>>;


struct edge { int to, cap, rev; };

const int MAX_V = 100;
vector<edge> G[MAX_V];
bool used[MAX_V];

void add_edge(int from, int to, int cap) {
    G[from].emplace_back((edge){to, cap, (int)G[to].size()});
    G[to].emplace_back((edge){from, 0, (int)G[from].size() - 1});
}

int dfs(int v, int t, int f) {
    if (v == t) return f;
    used[v] = true;
    for (int i = 0; i < G[v].size(); i++) {
        edge &e = G[v][i];
        if (!used[e.to] && e.cap > 0) {
            int d = dfs(e.to, t, min(f, e.cap));
            if (d > 0) {
                e.cap -= d;
                G[e.to][e.rev].cap += d;
                return d;
            }
        }
    }
    return 0;
}

int max_flow(int s, int t) {
    int flow = 0;
    for (;;) {
        memset(used, 0, sizeof(used));
        int f = dfs(s, t, inf);
        if (f == 0) return flow;
        flow += f;
    }
}

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

    int V, E;
    cin >> V >> E;
    rep(i, E) {
        int a, b, c;
        cin >> a >> b >> c;
        add_edge(a, b, c);
    }
    cout << max_flow(0, V - 1) << endl;
}

Measured memory_bytes: 3292
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <cstring>
#include <string>
#include <vector>
#include <queue>
#include <cmath>
#include <stack>
#include <set>
#include <map>
typedef long long ll;
using namespace std;

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

  int a[N], b[N];
  for(int i = 0; i < N; i++){
    a[i] = 30000 * (i + 1);
    b[i] = 30000 * (N - i);
  }

  for(int i = 0; i < N; i++){
    b[p[i] - 1] += i;
  }

  for(int i = 0; i < N; i++) cout << a[i] << " ";
  cout << endl;
  for(int i = 0; i < N; i++) cout << b[i] << " ";
  cout << endl;

  return 0;
}

Measured memory_bytes: 896
#include<bits/stdc++.h>
using namespace std;
const int maxn = 3e5;
int arr[30],c[maxn];
int a[20][30];

int main()
{
	int n,m,x;
	cin>>n>>m>>x;
	for(int i=1;i<=n;i++)
	{
		cin>>c[i];
		for(int j=1;j<=m;j++)
		{
			cin>>a[i][j];
		}
	}
	int ok=0;
	int minn=100000000;
	for(int st=1;st<(1<<n);st++)
	{
		int money=0;
		memset(arr,0,sizeof(arr));
		for(int i=1;i<=n;i++)
		{
			if((1<<(i-1))&st)
			{
				money+=c[i];
				for(int j=1;j<=m;j++) arr[j]+=a[i][j];
			}
		}
		int flag=0;
		for(int j=1;j<=m;j++)
		{
			if(arr[j]<x) flag=1;
		}
		if(flag==0)
		{
			ok=1;
			minn=min(minn,money);
		}
	}
	if(ok) cout<<minn<<endl;
	else cout<<-1<<endl;
	return 0;
} 

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

int main() {
	ll n;
	cin >> n;
	vector<int> l(n);
	rep(i,n) cin >> l[i];
	sort(l.begin(),l.end());
	int cnt = 0;
	for(int i = 0;i < n-2;i++){
		for(int j = i+1;j < n-1;j++){
			for(int k = j+1;k < n;k++){
				if(l[i] + l[j] > l[k]){
					cnt++;
				}else{
					break;
				}
			}
		}
	}
	cout << cnt << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define PB push_back
#define ZERO (1e-10)
#define INF int(1e9+1)
#define CL(A,I) (memset(A,I,sizeof(A)))
#define DEB printf("DEB!\n");
#define D(X) cout<<"  "<<#X": "<<X<<endl;
#define EQ(A,B) (A+ZERO>B&&A-ZERO<B)
typedef long long ll;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef pair<int,int> ii;
typedef vector<ii> vii;
#define IN(n) int n;scanf("%d",&n);
#define FOR(i, m, n) for (int i(m); i < n; i++)
#define F(n) FOR(i,0,n)
#define FF(n) FOR(j,0,n)
#define FT(m, n) FOR(k, m, n)
#define aa first
#define bb second
void ga(int N,int *A){F(N)scanf("%d",A+i);}
map<int,int> T;
int a,S;
int main(void){
    IN(_)F(_)scanf("%d",&a),++T[a];
    for(auto&h:T)if(h.bb>=h.aa)S+=h.bb-h.aa;
                 else S+=h.bb;
    printf("%d\n",S);
    return 0;
}


Measured memory_bytes: 4736
#include <bits/stdc++.h>
#include <math.h>
#include <vector>
#include <queue>
#include <iomanip>
#include <string>
using namespace std;
using Graph = vector<vector<int>>;
#define rep(i,n) for(int i=0;i<n;i++)
#define rep_1 (i,j,n) for(int i=j;i<n;i++)
typedef long long ll;
typedef long l;
const ll l_INF = 101010101000;
const int INF = 1010101010;
const int dx[4] = {-1,0,1,0};
const int dy[4] = {0,-1,0,1};
using vi = vector<int>;
using vvi = vector<vi>;
using pii = pair<int,int>;

int main(){
  int x, n;
  vi p(101);
  cin >> x >> n;
  rep(i,n){
    int y;
    cin >> y;
    p[y]++;
  }
  rep(i,101){
    if(p[x-i]==0){
      cout << x-i;
      return 0;
    }else if(p[x+i]==0){
      cout << x+i;
      return 0;
    }
  }
}

Measured memory_bytes: 3632
#include<bits/stdc++.h>
using namespace std;
using Int = long long;
template<typename T1,typename T2> inline void chmin(T1 &a,T2 b){if(a>b) a=b;}
template<typename T1,typename T2> inline void chmax(T1 &a,T2 b){if(a<b) a=b;}

//INSERT ABOVE HERE
Int calc(string s){
  using P = pair<char, Int>;
  vector<P> vp;
  for(char c:s){
    if(vp.empty()||vp.back().first!=c) vp.emplace_back(c,0);
    vp.back().second++;
  }
  Int res=0;
  for(auto p:vp)
    res+=p.second/2;
  return res;
}

signed main(){
  string s;
  Int k;
  cin>>s>>k;
  if(s==string(s.size(),s[0])){
    cout<<(s.size()*k/2)<<endl;
    return 0;
  }
  cout<<calc(s)+(calc(s+s)-calc(s))*(k-1)<<endl;
  return 0;
}


Measured memory_bytes: 256
N=int(input())
S=input()
if N%2==1:
    print("No")
elif N==2:
    if S[0]==S[1]:
        print("Yes")
    else:
        print("No")
else:
    if S[0:int(N//2)-1]==S[N//2:N-1]:
        print("Yes")
    else:
        print("No")


Measured memory_bytes: 3060
import java.util.*;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		
		int N = sc.nextInt();
		long[] XplusY = new long[N];
		long[] XminusY = new long[N];
		for(int i=0; i<N; i++) {
			int x = sc.nextInt();
			int y = sc.nextInt();
			XplusY[i] = (long)x + y;
			XminusY[i] = (long)x - y;
		}
		
		Arrays.sort(XplusY);
		Arrays.sort(XminusY);
		
		System.out.println(Math.max(XplusY[N-1]-XplusY[0], XminusY[N-1]-XminusY[0]));
		
		sc.close();
	}
}



Measured memory_bytes: 54196
import java.util.*;

public class Main{
  public static void main(String[] args){
    Scanner scan = new Scanner(System.in);
    long a = scan.nextLong();
    long b = a%500;
    long c = (long) (a-b)/500;
    long d = b%5;
    long e = (long) (b-d)/5;
    System.out.println(e*5+c*1000);
  }
}


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

int main()
{
   ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
   int t;t=1;while(t--)
   {
       ll n;cin>>n;
       ll res=0,ans;
       if(n>=500) 
       {
           ans=(n/500);
           res+=(ans*1000);
            n-=(500*ans);
       }
       if(n>=5)
       {
           ans=n/5;
           res+=(ans*5);
       }
       cout<<res;
       
   }
}


Measured memory_bytes: 256
#include "iostream"
#include "vector"
#include "string"
#include "algorithm"
#include "math.h"
#include "cstring"
#include "stack"
#include "queue"

using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<vector<int> > mat;

//文字列を辞書順に並び替える
string str_sort(string s)
{
  int size = s.size();
  char c[size];
  for (int i = 0; i < size; i++)
  {
    c[i] = s[i];
  }
  sort(c, c + size);
  string ans = "";
  for (int i = 0; i < size; i++)
  {
    ans += c[i];
  }
  return ans;
}

int main()
{
  string s;
  cin >> s;
  s = str_sort(s);
  int size = s.size();
  bool ans = true;
  if (size % 2 != 0)
  {
    ans = false;
  }
  for (int i = 0; i < size - 1; i += 2)
  {
    if (s[i] != s[i + 1])
    {
      ans = false;
    }
  }
  cout << (ans ? "Yes" : "No") << "\n";
}

Measured memory_bytes: 384
#include <stdio.h>
int main(){
    int x;

    do{
        scanf("%d",&x);
    }while(x<0||x>1000000000);

    int a,b,c;
    a = x/500;
    b = x - a*500;
    c = b/5;

    printf("%d", a*1000 + c*5);


    return 0;
}


Measured memory_bytes: 1704
#include <bits/stdc++.h>
#define ll long long
#define rep(i, begin, end) for (__typeof(end) i = (begin) - ((begin) > (end)); i != (end) - ((begin) > (end)); i += 1 - 2 * ((begin) > (end))) // rep(i, 1, 5) --> {1,2,3,4} // rep(i, 5, 1) --> {4,3,2,1} // rep(it, end(v), begin(v)) --> *it

using namespace std;

int main()
{
    int a, b, c, d;
    cin >> a >> b >> c >> d;
    while (a > 0 && c > 0)
    {
        c -= b;
        a -= d;
        // cout << a << endl;
    }
    if (c <= 0)
        cout << "Yes";
    else 
        cout << "No";
    return 0;
}

Measured memory_bytes: 3636
N, L = map(int, input().split())
moji_list = []
for i in range(N):
    moji = input()
    moji_list.append(moji)
moji_sort = sorted(moji_list)
#print(moji_sort)
ans = ""
for i in moji_sort:
    ans += i
print(ans)

Measured memory_bytes: 3060
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
#define ll long long 
#define fast ios_base::sync_with_stdio(false); cin.tie(0);cout.tie(0);
const ll mod=998244353;
typedef tree<ll, null_type, less<ll>, rb_tree_tag, tree_order_statistics_node_update> data_struct;

int main()
{
	ll a,b,n;
	cin>>a>>b>>n;
	if(n<b || n==1)
	{
		ll ans=(a*n)/b;
		ans-=(a*(n/b));
		cout<<ans;
	}
	else if(n==b)
	{
		ll ans=(a*(n-1))/b;
		ans-=(a*((n-1)/b));
		cout<<ans;
	}
	else
	{
		ll ans=(a*(b-1))/b;
		ans-=(a*((b-1)/b));
		cout<<ans;
	}
}

Measured memory_bytes: 3632
#include<map>
#include<bitset>
#include<cstdio>
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#include<string>
#include<stack>
#define REP(i,x,y) for(ll i=x;i<=y;i++)
typedef long long ll;
using namespace std;

ll a[30];

int main() {
	ll n, m;
	cin >> n >> m;
	REP(i, 0, 25) {
		a[i] = 0;
	}
	REP(i, 1, n*m) {
		char x;
		cin >> x;
		a[x - 'a']++;
	}
	ll t = (n / 2) * (m / 2);
	ll cnt = 0;
	ll odd = (n*m) % 2;
	REP(i, 0, 25) {
		if (a[i] % 2 == 1) {
			odd--;
			if (odd < 0) {
				cout << "No" << endl;
				return 0;
			}
		}
		cnt += a[i] / 4;
		
		
	}
	if (cnt >= t) {
		cout << "Yes" << endl;
	}
	else {
		cout << "No" << endl;
	}
}

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

typedef struct {
  int back;
  int next;
} list;

int main(){
  int  p, k, n;
  long long j;
  list l[104731];
  for(k = 2; k < 104731; k++) {
    l[k].back = k-1;
    l[k].next = k+1;
  }
  for(p = 2; p < 104730;p = l[p].next)
    {
      for(k = p; k < 104730; k = l[k].next)
	{
	  for(j = (long long)k * p; j < 104730; j*= p)
	    {
	      l[l[j].back].next = l[j].next;
	      l[l[j].next].back = l[j].back;
	    }
	}
    }
  while(cin >> n && n)
    {
      j = 0;
      for(p = 2; n > 0; n--)
	{
	  j += p;
	  p = l[p].next;
	}
      cout << j << endl;
    }
  return 0;
}

Measured memory_bytes: 1972
import java.util.*;

public class Main {

	public static void main(String[] args) {
		Scanner in = new Scanner(System.in);
		int H = in.nextInt();
		int W = in.nextInt();
		int h = in.nextInt();
		int w = in.nextInt();
		in.close();

		int result = H * W - H * w - h * W + h * w;
		System.out.println(result);
	}

}


Measured memory_bytes: 23252
#include<bits/stdc++.h>
//#pragma comment(linker,"/STACK:1024000000,1024000000")
//251103FD
//4008802802
//4008160009
using namespace std;
#define PB pop_back
#define PF pop_front
#define np next_permutation
#define eb emplace_back
#define pb push_back
#define bf push_front
#define mp make_pair
#define s second
#define f first
#define foreach(it, a) for(__typeof((a).begin()) it=(a).begin(); it!=(a).end(); it++)
#define Foreach(it, a) for(__typeof((a).rbegin()) it=(a).rbegin(); it!=(a).rend(); it++)
#define forn(i, a) for(register int i=0; i<a; i++)
#define Forn(i, a) for(register int i=1; i<=a; i++)
#define memINF 127
#define all(x) x.begin(), x.end()
#define FAST ios::sync_with_stdio(false)

typedef long long ll;
typedef pair<int,int> pi;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef unsigned int uint;

inline int in() 
{
    int x=0, c;
    while((uint)((c=getchar())-48)>=10) 
		if(c=='-') 
			return -in();
    do 
	{ x=(x<<3)+(x<<1)+(c^48); }
	while((uint)((c=getchar())^48)<10);
    return x;
}
inline int lcm(int a, int b){return a*b/__gcd(a, b);}

const int MAX=1e6+5;
const int n=1e5+5;

struct DSU
{
    int par[MAX];
    inline void init(int x)
    {
        par[x]=x;
    }
    inline int find(int x)
    {
        return par[x]==x?x:par[x]=find(par[x]);
    }
    inline void unite(int x, int y)
    {
        x=find(x), y=find(y);
        if(x==y)
            return;
        par[x]=y;    
    }
}dsu;

int N, M, a, b, c, tot, to[n], dist[MAX];
vector<pi> e[MAX];
vi adj[MAX];
bool inside[n];
queue<int> q;

int main()
{
    N=in(), M=in();
    while(M--)
    {
        a=in(), b=in(), c=in();
        e[c].eb(mp(a, b));
    }
    tot=N;
    Forn(i, 1000000)
    {
        if(!e[i].size())
            continue;
        int pa;
        foreach(it, e[i])
        {
            dsu.init(it->f);
            dsu.init(it->s);
            inside[it->f]=false;
            inside[it->s]=false;
            to[it->f]=-1;
            to[it->s]=-1;
        }
        foreach(it, e[i])
            dsu.unite(it->f, it->s);
        foreach(it, e[i])
        {
            if(!inside[it->f])
            {
                pa=dsu.find(it->f);
                inside[it->f]=true;
                if(to[pa]<=0)
                    to[pa]=++tot;
                adj[to[pa]].eb(it->f);
                adj[it->f].eb(to[pa]);
            }
            if(!inside[it->s])
            {
                pa=dsu.find(it->s);
                inside[it->s]=true;
                if(to[pa]<=0)
                    to[pa]=++tot;
                adj[to[pa]].eb(it->s);
                adj[it->s].eb(to[pa]);
            }
        }
    }
    memset(dist, -1, sizeof(dist));
    dist[1]=0;
    q.push(1);
    while(!q.empty())
    {
        int t=q.front();
        q.pop();
        foreach(it, adj[t])
            if(dist[*it]<0)
                dist[*it]=dist[t]+1, q.push(*it);
    }
    printf("%d\n", dist[N]<0?-1:dist[N]>>1);
    return 0;
} 

Measured memory_bytes: 69504
#pragma GCC optimize(3,"Ofast","inline")
#include<bits/stdc++.h>
#define IOS ios::sync_with_stdio(false),cin.tie(0),cout.tie(0)
#define ms(a,b) memset(a,b,sizeof(a))
#define msn(a,n,b) for(int i=0;i<=n;i++)a[i]=b
#define lson l,mid,rt<<1
#define rson mid+1,r,rt<<1|1
#define fi first
#define se second
using namespace std;
mt19937 rng_32(chrono::steady_clock::now().time_since_epoch().count());
typedef long long ll;
typedef long double ld;
typedef pair<int,int> P;
const int mod=1e9+7;
const int seed=233;
const double PI=acos(-1.0);
const double eps=1e-7;
const int inf=0x3f3f3f3f;
const int max_n=200005;
ll ceil(ll x,ll y){if(x==0)return 0;if(y<0)x=-x,y=-y;bool sign=x>0;x=abs(x);return sign?(x+y-1)/y:-x/y;}
ll floor(ll x,ll y){if(x==0)return 0;if(y<0)x=-x,y=-y;bool sign=x>0;x=abs(x);return sign?x/y:-(x+y-1)/y;}
namespace {
    inline int Add(int x,int y){return (x+=y)>=mod?x-mod:x;}
    inline int Sub(int x,int y){return (x-=y)<0?x+mod:x;}
    inline int Mul(int x,int y) {return 1ll*x*y%mod;}
    inline int Pow(int x,int y=mod-2){if(y==0)return 1;int res=1;while(y){if(y&1)res=1ll*res*x%mod;x=1ll*x*x%mod;y>>=1;}return res;}
}
/**********************head************************/
int n,k,h[max_n];
int main(){
    scanf("%d%d",&n,&k);
    for(int i=1;i<=n;i++)scanf("%d",h+i);
    sort(h+1,h+n+1);
    ll ans=0;
    for(int i=1;i<=n-k;i++)ans+=h[i];
    printf("%lld\n",ans);
    return 0;
}

Measured memory_bytes: 1024
#include <math.h>
#include <bits/stdc++.h>//一括で読み込み
typedef long long ll;
using namespace std;

ll factMax = 2000010;//nCkにおけるnの最大値
ll factMaxP = 2000011;
ll factorials[2000011];//i!(mod p)をO(n)で先にメモ。
ll factorialRs[2000011];//i!^-1(mod p), pは素数でO(n)。
ll p = 1000000007;

ll MathPow(ll x, ll a)//戻り値はx^a。O(loga)
{
  ll num = 2;
  ll answer = 1;
  ll check = a;
  ll memo = x;

  while(check > 0)
  {
    if(check % num == num / 2)
    {
      check -= num / 2;
      answer *= memo;
    }
  memo *= memo;
  num *= 2;
  }
  return answer;
}

ll DivideMod(ll x, ll a, ll p)//戻り値はx^a(mod p)。O(loga)
{
  ll num = 2;
  ll answer = 1;
  ll check = a;
  ll memo = x%p;
  
  while(check > 0)
  {
    if(check % num == num / 2)
    {
      check -= num / 2;
      answer *= memo;
      answer %= p;
    }
  memo *= memo;
  memo %= p;
  num *= 2;
  }
  return answer;
}

ll DivideModReverse(ll x, ll p)//戻り値はx^-1(mod p), pは素数。O(logp)
{
  ll answer = DivideMod(x, p-2, p);
  return answer;
}

ll ModFactorial(ll x, ll p)//戻り値はx!(mod p)
{
  ll answer = 1;
  for(int i = 2; i <= x; i++)
  {
    answer *= i;
    answer %= p;
  }
  return answer;
}

ll DivideModFactorial(ll x, ll p)//戻り値はx!^-1(mod p), pは素数
{
  ll answer = 1;
  for(ll i = x; i >= 2; i--)
  {
    answer *= DivideModReverse(i, p);
    answer %= p;
  }
  return answer;
}

ll Comb(ll a, ll b, ll p)//組み合わせC(a,b)(mod p)をO(1)で返す
{
  if(a-b < 0) return 0;//引数a-bが負なら0を返す
  ll answer = 1;
  answer *= factorials[a];
  answer %= p;
  answer *= factorialRs[a-b];
  answer %= p;
  answer *= factorialRs[b];
  answer %= p;
  return answer;
}

int main()
{
    factorials[0] = 1;
		factorialRs[factMax] = DivideModFactorial(factMax,p);
		for(ll i = 1; i <= factMax; i++)
		{
		  factorials[i] = (factorials[i-1]*i)%p;//i!(mod p)
		  factorialRs[factMax-i] = (factorialRs[factMax+1-i]*(factMax+1-i))%p;//逆元も先にメモ
		}

    ll r1,c1,r2,c2;
		cin >> r1 >> c1 >> r2 >> c2;

    ll answer = 0;
    for(ll i = r1; i <= r2; i++)
    {
      answer += Comb(i+c2+1,i+1,p);
      answer %= p;
      if(answer < 0) answer += p;

      answer -= Comb(i+c1,i+1,p);
      answer %= p;
      if(answer < 0) answer += p;
    }

    cout << answer << endl;
}


Measured memory_bytes: 31488
let rec gcd n m =
  if m = 0 then n
  else gcd m (n mod m)

let () = Scanf.scanf "%d\n" @@ fun n ->
  let as_ = Array.init n @@ fun _ -> Scanf.scanf "%d " @@ fun a -> a in
  Printf.printf "%d\n" @@ Array.fold_left gcd 0 as_


Measured memory_bytes: 4736
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cstring>

#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <queue>
#include <stack>
#include <map>
#include <set>

#include <functional>
#include <cassert>

typedef long long ll;
using namespace std;

#define mod 1000000007 //1e9+7
#define INF 1000000000 //1e9
#define LLINF 2000000000000000000LL //2e18
#define SIZE 21

void calc(int n){
  int l=1,sum=1;
  int ans = 0;

  for(int r=2;r<n;r++){
    sum += r;

    while(sum > n)sum -= l++;

    if(sum==n) ans++;
  }  

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

int main(){
  int n;
  
  while(1){
    scanf("%d",&n);
    if(n==0) break;
    calc(n);
  }

  return 0;
}

Measured memory_bytes: 3116
N, K = map(int, input().split())
S = input()

if(S[0] == "1"):
    s = []
else:
    s = [0]
cnt = 1
tmp = S[0]
for i in range(1, len(S)):
    if(tmp == S[i]):
        cnt += 1
    else:
        s.append(cnt)
        tmp = S[i]
        cnt = 1
s.append(cnt)
tmp1 = 0
if(len(s)//2 <= K):
    ans = sum(s)        
else:
    ans = sum(s[:(2*K+1)])
    tmp = ans
    cnt = 0
    for i in range(2*K+1, len(s)-1, 2):
        if(ans < tmp-s[cnt]-s[cnt+1]+s[i]+s[i+1]):
            ans = tmp-s[cnt]-s[cnt+1]+s[i]+s[i+1]
            tmp = tmp-s[cnt]-s[cnt+1]+s[i]+s[i+1]
        else:
            tmp = tmp-s[cnt]-s[cnt+1]+s[i]+s[i+1]
        cnt += 2
    ss = s[::-1]
    if(S[-1] == "0"):
        tmp1 = sum(ss[:(2*K)])
    else:
        tmp1 = sum(ss[:(2*K+1)])
print(max(ans, tmp1))

Measured memory_bytes: 5328
#include <bits/stdc++.h>
using namespace std;
const int Q=(1<<19)+1,MOD=1e9+7;
inline int mul(int a,int b)
{return 1LL*a*b%MOD;}
char s[Q];
int main()
{
	int als=1;
	int n;
	scanf("%d%s",&n,s+1);
	for(int i=1;i<=n;i++)als=mul(als,i);
	n<<=1;
	if(s[1]=='W'||s[n]=='W')return 0&puts("0");
	int ct=0;
	for(int i=1,now,lst;i<=n;i++){
		if(i==1)now=0;
		else if(i==n)now=1;
		else now=(s[i]==s[i-1])^lst;
		if(!now)++ct,lst=0;
		else{
			lst=1;
			if(!ct)return puts("0")&0;
			als=mul(als,ct),--ct;
		}
	}
	if(ct)return puts("0")&0;
	printf("%d\n",als);
	return 0;
}

Measured memory_bytes: 384
#include<iostream>
#include<algorithm>
#include<queue>
#include<cmath>
#include<map>
#include<vector>
#include<iomanip>
using namespace std;
typedef long long ll;
ll inf = 100000000;
ll v[205];
ll x[20000005];
ll a[10000005];
ll b[10000005];
ll dp[10005][10005];
ll ex = 1000000007;
int dx[4] = { 1,-1,0,0 };
int dy[4] = { 0,0,1,-1 };
typedef pair<ll, ll> P;
double q[200005];
ll gcd(ll a, ll b) {
	return b ? gcd(b, a % b) : a;
}
int h, w;
char s[25][25];
int bfs(int x, int y) {
	int dist[25][25];
	for (int i = 0; i < h; i++) {
		for (int j = 0; j < w; j++) {
			dist[i][j] = inf;
		}
	}
	queue<P>q;
	dist[x][y] = 0;
	q.push(P{ x,y });
	while (q.size()) {
		P now = q.front();
		q.pop();
		for (int i = 0; i < 4; i++) {

			int a = now.first + dy[i];
			int b = now.second + dx[i];
			if (dist[a][b] == inf && s[a][b] != '#') {
				dist[a][b] = dist[now.first][now.second] + 1;
				q.push(P{ a,b });
			}
		}
	}

	int res = 0; 
	for (int i = 0; i < h; i++) {
		for (int j = 0; j < w; j++) {
			if (s[i][j] != '#') {
				res = max(res, dist[i][j]);
			}
		}
	}
	return res;
}


int main() {
	cin >> h >> w;
	for (int i = 0; i < h; i++) {
		for (int j = 0; j < w; j++) {
			cin >> s[i][j];
		}
	}
	int ans =0;
	int kai = 0;
	for (int i = 0; i < h; i++) {
		for (int j = 0; j < w; j++) {
			if (s[i][j] == '.') {
				ans = bfs(i, j);
				kai = max(kai, ans);
			}
		}
	}
	cout << kai << endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0;i < n;i++)
#define ll long long
using namespace std;
//typedef vector<unsigned int>vec;
//typedef vector<ll>vec;
//typedef vector<vec> mat;
typedef pair<int, int> P;
typedef pair<ll,ll> LP;
const int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
const int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
const int INF = 1000000000;
const ll LINF = 1000000000000000000;//1e18
const ll  MOD = 1000000007;
const double PI = acos(-1.0);
const double EPS = 1e-10;

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


int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N, P;
    string S;
    cin >> N >> P >> S;

    map<ll, ll> mp;
    ll ans = 0;

    if(P == 2 || P == 5){
        for(int i=N-1;i>=0;i--){
            int d = S[i] - '0';
            if(P == 2 || P == 5){
                if(d % P == 0) ans += i + 1;
            }
        }
    }
    else{
        ll cur = 0;
        ll base = 1;
        mp[0]++;
        for(int i=N-1;i>=0;i--){
            int d = S[i] - '0';
            cur = cur + (base * d) % P;
            cur %= P;
            base *= 10;
            base %= P;
            mp[cur]++;
        }
        for(auto x : mp) ans += x.second * (x.second - 1) / 2;
    }
    cout << ans << endl;
}

Measured memory_bytes: 1044
N,W = map(int,input().split())

v = [0] * N
w = [0] * N
for i in range(N):
    w[i],v[i] = map(int,input().split())
sumv = sum(v)+1
dp = [[float('inf')] * (sumv) for _ in range(N+1)]
for i in range(N):
    dp[i][0] = 0
for i in range(1, N+1):
    for j in range(1, sumv):
        if v[i-1] > j:
            dp[i][j] = dp[i-1][j]
        else:
            dp[i][j] = min(dp[i-1][j],w[i-1]+dp[i-1][j-v[i-1]])
ans = 0
for i in range(1, sumv+1):
    if dp[N][-i] <= W:
        ans = sumv - i
        break
print(ans)

Measured memory_bytes: 371912
import java.util.Scanner;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		// 整数の入力
		int N = sc.nextInt();
		int A = sc.nextInt();
		int output = N * N - A;
		// 文字列の入力
		String s = Integer.toString(output);
		// 出力
		System.out.println(s);
	}
}

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

int main(){
  int a,b;
  string s;
  cin>>a>>b>>s;
  if(s[b-1]=='A') s[b-1]='a';
  if(s[b-1]=='B') s[b-1]='b';
  if(s[b-1]=='C') s[b-1]='c';
  cout<<s;
}

Measured memory_bytes: 256
while True:
    H, W = [int(x) for x in input().split(" ")]
    if H == W == 0:
        break
    for i in range(H):
        if i == 0 or i == (H - 1):
            print("#" * W)
        else:
            print("#" + "." * (W - 2) + "#")
    print("")
    

Measured memory_bytes: 7596
using System;
using System.Linq;

namespace arc102_a
{
	class Program
	{
		static void Main(string[] args)
		{
			int[] x = Console.ReadLine().Split().Select(int.Parse).ToArray();
			int a = 0; int b = 0;
			for (int i = 1; i <= x[0]; i++)
			{
				if (i % x[1] == 0) a++;
				else if (i * 2 % x[1] == 0) b++;
			}
			Console.WriteLine((long)Math.Pow(a, 3) + (long)Math.Pow(b, 3));
		}
	}
}

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

#define pb          push_back
#define F           first
#define S           second
#define rep(i,a,b)  for(int i=a; i<b; i++)
#define all(a)      (a).begin(),(a).end()
#define wa(x)       cout << (#x) << " -------- " << (x) << endl
#define line1	    printf("---------------------------\n")

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

void pvi(auto v){
	for(auto it:v) cout << it << " ";
	cout << endl;
}

void solve();
signed main() {
	//ios_base::sync_with_stdio(false); cin.tie(NULL);

	int t=1; 
	//cin>>t;
	while(t--) solve();
	return 0;
}

//___________________________________________________________________________________________________________

void solve() {

	vi v(5,0);
	rep(i,0,5) cin>>v[i];

	int t = 0;
	rep(i,0,5){
		int k = (v[i]/10)*10;
		if(k!=v[i]) k += 10;

		t += k;
	}

	rep(i,0,5){
		v[i] = v[i]%10;
		if(v[i]==0) v[i] = 10;
	}

	t = t - 10 + *min_element(all(v));
	cout << t << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<vector>
#include<iomanip>
#include<algorithm>
#include<queue>
#include<stack>
#include<map>
using namespace std;
#define ll long long
int main(){
    int a,b;
    cin>> a>> b;
    if(a==1)a+=13;
    if(b==1)b+=13;
    if(a>b)cout << "Alice";
    if(a<b)cout << "Bob";
    if(a==b)cout << "Draw";
    return 0;
}


Measured memory_bytes: 256
/*      Abhijith    */
#include<bits/stdc++.h>
#include<iomanip>
#define lld long long int
#define ld long double
#define mod 1000000007
#define all(v) v.begin(),v.end()
#define rep(i,a,b)	for(lld i=a;i<=b;i++)
#define repr(i,a,b) for(lld i=a;i>=b;i--)
#define pb push_back
#define mp make_pair
using namespace std;
int main()
{
     ios_base::sync_with_stdio(false);
     cin.tie(0);
     cout.tie(0);
     char s;
     cin>>s;
     if(s=='A')
     {
         cout<<"T"<<endl;
     }
     else if(s=='T')
     {
         cout<<"A"<<endl;
     }
     else if(s=='C')
     {
         cout<<"G"<<endl;
     }
     else if(s=='G')
     {
         cout<<"C"<<endl;
     }
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <vector>
#include <list>
#include <algorithm>
#include <cmath>
#include <stack>
#include <map>
#include <numeric>
#include <sstream>
#include <queue>
#include <iomanip>
using namespace std;

#define REP(i,n) for(int (i)=0; (i)<(n); (i)++)
#define FOR(i,a,b) for(int (i)=(a); (i)<(b); (i)++)
#define PUSH(n,v) for(int i=0; i<(n); i++) {int j; cin >> j; v.push_back(j);}
#define ALL(v) v.begin(), v.end()
#define print(s) cout << (s) << endl

int main() {
    vector<pair<int,int>> w;
    int n;
    cin >> n;
    REP(i,n) {
        int a, v;
        cin >> a >> v;
        w.push_back(make_pair(100-v, a));
    }
    sort(w.begin(),w.end());
    cout << w[0].second << " " << 100-w[0].first << endl;
    return 0;
}

Measured memory_bytes: 3096
PROGRAM-ID.                      ABC_105_A.
DATA                             DIVISION.
WORKING-STORAGE                  SECTION.
    01 INP     PIC X(7).
    01 N       PIC 9(3).
    01 K       PIC 9(3).
    01 ans     PIC X(3).

    01 d       PIC 9(3).
    01 r       PIC 9(3).

PROCEDURE                        DIVISION.
    ACCEPT INP.

    UNSTRING INP
    DELIMITED BY SPACE
    INTO N K.

    DIVIDE K INTO N GIVING d REMAINDER r.

    IF ZERO = r
        DISPLAY ZERO
    ELSE
        DISPLAY 1
    END-IF.

    STOP RUN.


Measured memory_bytes: 636
#include <bits/stdc++.h>
using    namespace std;
#define  int long long int 
#define  endl '\n'

void solveTestCase()
{

	int a, b;
	cin >> a >> b;

	int res = a*b;

	if(((res/(a*2) >= a) and (res/(a*2)) <= (a*2)) and (res % (a*2)) == 0) {
		cout << "Yes\n";
	}
	else {
		cout << "No\n";
	}

	/*int x, n;
	cin >> x >> n;

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

	vector<int>v(n);

	unordered_map < int, int > mp;

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

	int ma = *max_element(v.begin(), v.end());
	int mi = *min_element(v.begin(), v.end());

	for(int i=0; i<=max(abs(ma-x),abs(mi-x))+1; i++)
	{
		if(mp.find(x-i) == mp.end()){
			cout << (x-i) << endl;
			return ;
		}
		else if (mp.find(x+i) == mp.end()){
			cout << (x+i) << endl;
			return ;
		}

	}*/

	/*for(int i=0; i<n; i++)
	{
		if(ans > abs(x-v[i]))
		{
			ans = abs(x - v[i]);
			ele = v[i];
		}
		if(ans == abs(x-v[i])){
			if(ele > v[i])
				ele = v[i];
		}
	}

	cout << ele << endl;*/
}

int32_t main()
{

	solveTestCase();

	return 0;

}

Measured memory_bytes: 3616
from collections import defaultdict,deque
import sys,heapq,bisect,math,itertools,string,queue,datetime
sys.setrecursionlimit(10**8)
INF = float('inf')
mod = 10**9+7
eps = 10**-7
def inpl(): return list(map(int, input().split()))
def inpl_s(): return list(input().split())

A,B = inpl()
print(A*B-A-B+1)


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

#define N 0
#define INF 0x3f3f3f3f
#define LL long long
#define mz(x) ms(x,0)
#define ms(x,y) memset(x,y,sizeof(x))
#define mc(x,y) memcopy(x,y,sizeof(y))
#define MOD 1000000007

using namespace std ;

int main()
{
	int n ;
	scanf ("%d", &n) ;
	
	LL ans = 0 ;
	for (int k=1; k<n; k++)
		ans += (n - 1) / k ;
		
	cout << ans << endl ;

	return 0 ;
}

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

using namespace std;

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);

  int h, w, n;
  cin >> h >> w >> n;
  vector<int> a(n);
  for (auto &e : a) {
    cin >> e;
  }
  vector<vector<int>> ans(h, vector<int>(w));
  int posx = 0, posy = 0;
  int dx[] = {1, 0, -1, 0};
  int dy[] = {0, 1, 0, -1};
  int dir = 0;
  int ci = 0;
  for (int i = 0; i < h * w; ++i) {
    if (a[ci] == 0)
      ++ci;
    ans[posy][posx] = ci + 1;
    a[ci]--;

    for (int j = 0; j < 2; ++j) {
      int nx = posx + dx[dir], ny = posy + dy[dir];
      if (nx < 0 || ny < 0 || w == nx || h == ny || 0 != ans[ny][nx]) {
        dir = (dir + 1) % 4;
        continue;
      }
      posx = nx, posy = ny;
      break;
    }
  }

  for (auto &row : ans) {
    for (auto &col : row) {
      cout << col << " ";
    }
    cout << "\n";
  }
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
using i64 = long long;

int main() {
    int n;
    std::string a, b, c;
    std::cin >> n >> a >> b >> c;
    int ret = 0;
    for (int i = 0; i < n; i++) {
        std::set<char> cs;
        cs.insert(a[i]);
        cs.insert(b[i]);
        cs.insert(c[i]);
        ret += cs.size() - 1;
    }
    std::cout << ret << std::endl;

    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <iostream>
#include <algorithm>
#include <set>
#include <vector>
#include <map>
#include <deque>
#include <math.h>
#include <cstring>
#include <string.h>
#include <iomanip>
#include <stdlib.h>
#include <queue>
#include <stack>
#include<cassert>
#include <cfloat>
#include <list>
using namespace std ;
#define ll long long
#define submitStage int TCF = 1 ;
#define testStage int TCF = 1000 ;
#define testMyStupedCode TCF--
void FastInputOutput(){
    ios_base :: sync_with_stdio( 0 ) ;
    cin.tie( 0 ) ;
    cout.tie( 0 ) ;
}
void ReadFromFile( string name , string extention ){
    string fullPath = name + "." + extention ;
    freopen( fullPath.c_str() , "r" , stdin ) ;
}
inline int D(){
    int t ;
    scanf( "%d" , &t ) ;
    return t ;
}
inline ll LLD(){
    ll t ;
    scanf( "%lld" , &t ) ;
    return t ;
}
inline char C(){
    char c ;
    scanf( "%c" , &c ) ;
    return c ;
}
inline ll power(ll x, ll p, ll m){
    ll res = 1;
    while(p){
        if(p & 1)
            res = (res * x) % m;
        x = (x * x) % m;
        p >>= 1;
    }
    return res;
}
long double ModLog(long double base, long double x) {
    return (logl(x) / logl(base));
}

const int N = 1e6;
int n, k;
int dp[N][4];
int a[4][N];
int solve(int idx, int last){
     if(idx == n)
          return 0;
     int &ret = dp[idx][last];
     if(~ret)
          return ret;
     ret = 0;
     for(int i = 1; i <= 3; ++i){
          if(last == i)
               continue;
          ret = max(ret, a[i][idx] + solve(idx + 1, i));
     }
     return ret;
}
int main(){
     memset(dp, -1, sizeof(dp));
     n = D();
     for(int i = 0; i < n; ++i)
          a[1][i] = D(), a[2][i] = D(), a[3][i] = D();
     printf("%d", solve(0, 0));
}


Measured memory_bytes: 35200
#include<iostream>
#include<cstring>
#include<algorithm>
#include<vector>
#include<queue>
#include<math.h>
using namespace std;
const int N=1e6+10;
int n,m,k;
int main()
{
	int ans,num;
	
	cin >> ans>>num;
	for(int i=0;i<num;i++) {
		int x;
		cin >> x;
		ans-=x;
	}
	if(ans>=0) cout <<ans<<endl;
	else cout<<-1<<endl;
}


Measured memory_bytes: 3636
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
constexpr ll INF = LLONG_MAX;
constexpr double PI = M_PI;
 
int main(){
  cin.tie(0);
  cout.tie(0);
  ios::sync_with_stdio(false);
 
  long long n;
  string s;
  cin >> n >> s;
  if(n%2){
    cout << "No\n";
    return 0;
  }
  for(int i = 0; i < n/2; i++){
    if(s[i] != s[i+n/2]){
      cout << "No\n";
      return 0;
    }
  }
  cout << "Yes\n";
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
    
    int N, x;
    int ans = 0;
    cin >> N >> x;
    vector<int> a(N);
    for(int i = 0; i < N; i++)
        cin >> a[i];
        
    sort(a.begin(), a.end());
    for(int i = 0; i < N; i++){
        x -= a[i];
        if(x < 0) break;
        else if(i != N-1 && x >= 0) ans++;
        else if(x == 0) ans++;
    }    
    
    cout << ans << endl;
}

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

using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
typedef map<ll,ll>::iterator itll;
typedef long double ld;
typedef map<ll,ll> mapll;

#define con continue
#define pb push_back
#define fi first
#define se second
#define fr front()
#define INF 1000000000000000000
#define all(vl) vl.begin(),vl.end()
#define m_p make_pair 
#define sz(a) sizeof(a)
#define forn(mp,it) for(it = mp.begin();it!=mp.end();it++)
#define FOR(i,a,n) for(int i=a;i<n;i++) 
#define FORE(i,a,n) FOR(i,a,n+1)
#define Endl endl
#define eNdl endl
#define enDl endl
#define endL endl

int main()
{
	string s;
	cin>>s;
	FOR(i,0,s.size())cout<<'x';
	cout<<Endl;
	return 0;
}


Measured memory_bytes: 3556