akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <string>
#include <cstdio>
#include <algorithm>
#include <cstdlib>
#include <cmath>
#include <vector>
#include <utility>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <bitset>
using namespace std;
#define INF 1000000007
#define LINF 1000000000000000007
#define MOD 1000000007
#define int long long
#define rep(i, n) for (int i = 0; i < n; i++)
#define repb(i, n) for (int i = n - 1; i >= 0; i--)
#define MODE 1
#ifdef MODE
#define DEB(X) cout << #X << ": " << X << " ";
#define ARDEB(i, X) cout << #X << "[" << i << "]: " << X[i] << " ";
#define END cout << endl;
#else
#define DEB(X) \
    {          \
    }
#define ARDEB(i, X) \
    {               \
    }
#define END \
    {       \
    }
#endif
typedef pair<int, int> P;
struct edge{int to,cost;};

typedef long long ll;

int ans,ans2;
int h,w,a[555][555];
signed main(){

	
	cin>>h>>w;
	
	rep(i,h)rep(j,w){
		cin>>a[i][j];
	}
	int flag=0,bx,by;
	vector<pair<P,P>> v;
	rep(i,h){
		if(i%2==0)rep(j,w){
			if(flag){
				a[i][j]++;
				v.push_back(make_pair(P(bx,by),P(i+1,j+1)));
			}
			if(a[i][j]%2){
				flag=1;
				a[i][j]--;
			}
			else flag=0;
			bx=i+1;by=j+1;
		}
		else repb(j,w){
			if(flag){
				a[i][j]++;
				v.push_back(make_pair(P(bx,by),P(i+1,j+1)));
			}
			if(a[i][j]%2){
				flag=1;
				a[i][j]--;
			}
			else flag=0;
			bx=i+1;by=j+1;
		}
		
	}
	cout<<v.size()<<endl;
	for(auto x:v){
		cout<<x.first.first<<" "<<x.first.second<<" "<<x.second.first<<" "<<x.second.second<<endl;
	}

	
}


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

#define int long long

#define pii pair<int, int>

#define x1 x1228
#define y1 y1228

#define left left228
#define right right228

#define pb push_back
#define eb emplace_back

#define mp make_pair                                                                

#define ff first                                                                  
#define ss second   

#define matr vector<vector<int> > 

#define all(x) x.begin(), x.end()


using namespace std;
typedef long long ll; 
typedef long double ld; 
                                                                                                   
const int maxn = 3e5 + 7, mod = 1e9 + 7, inf = 1e18, MAXN = 1e6 + 7;
const double eps = 1e-9;
mt19937 rnd(time(0));
int n; 
int cnt[maxn]; 
int calc[maxn]; 
int dp[maxn]; 

void solve() {        
    cin >> n; 
    vector<int> have; 
    for (int i = 0; i < n; ++i) {
        int x; cin >> x; 
        if (have.size() == 0) {
            have.pb(x);
        } else if (have.back() != x) {
            have.pb(x); 
        } 
    }
    n = have.size(); 
    dp[0] = 1; 
    for (int i = 1; i <= n; ++i) {
        dp[i] += calc[have[i - 1]] + dp[i - 1];
        dp[i] %= mod; 
        calc[have[i - 1]] += dp[i - 1];
        calc[have[i - 1]] %= mod;                             
    }
    cout << dp[n]; 
}                                
   
signed main() {
#ifdef LOCAL
    freopen("TASK.in", "r", stdin);
    freopen("TASK.out", "w", stdout);
#else 
    
#endif // LOCAL
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.precision(20); 
    cout << fixed; 
    int t = 1;  
    for (int i = 0; i < t; ++i)              
        solve();
    return 0;
}  

Measured memory_bytes: 5872
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int INF = 0x3f3f3f3f;

int main()
{
	int x,n,k = INF,ans = 0;
	scanf("%d",&n);
	for(int i = 0;i < n;++i){
		scanf("%d",&x);
		if(k >= x) ans++;
		k = min(k,x);
	}
	cout << ans;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int d;
  cin>>d;
  string a;
  cin>>a;
  vector<int> b(a.size());
  for(int i=0; i<a.size(); i++){
    b[i]=a[i]-'A'+d;
  }
  for(int i=0; i<a.size(); i++){
    b[i]%=26;
  }
  string c="ABCDEFGHIJKLMNOPQRSTUVWXYZ";
  for(int i=0; i<a.size(); i++)
  cout<<c[b[i]];
  cout<<endl;
}


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

#define all(x)        (x).begin(),(x).end()
#define eb            emplace_back
#define mp            make_pair
#define pb            push_back
#define fi            first
#define se            second
#define sz(x)         ((int)(x).size())
#define rep(x,y,z)    for(int x=y;x<z;x++)
#define per(x,z,y)    for(int x=z-1;x>=y;x--)
#define trav(y,x)     for(auto& y:x)
#define pii           pair<int, int>
#define pll           pair<ll, ll>
#define vi            vector<int>
#define vpi           vector<pii>

int dbg = 0;
#define cri           if(0)
#define shame         cri cerr<<(++dbg)<<"\n\n";

// aaaaaaaaaaaaaaaa
void solve() {
  int k; string s;
  cin>>k>>s;
  if(sz(s)<=k)cout<<s;
  else cout<<s.substr(0,k)<<"...";
  cout<<'\n';
}

int main() {
  // int _; scanf("%d", &_); while (_--)
  // ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
  // int _; cin >> _; while(_--)
  solve();
	return 0;
}


Measured memory_bytes: 3620
#include<stdio.h>
int main()
{
    int i,j,k,na,c,v,def,dsdsf,dfssfds,sdfdsfd,n;
    scanf("%d",&n);

    int ara[n];
    for(i=0;i<n;i++) scanf("%d",&ara[i]);

    int mn=1000;
    for(i=0;i<n;i++){
        int sum1=0,sum2=0;
        for(j=0;j<=i;j++) sum1=sum1+ara[j];
        for(j=i+1;j<n;j++) sum2+=ara[j];

        int dif=abs(sum1-sum2);
        if(dif<mn) mn=dif;

    }

    printf("%d\n",mn);

}


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

 long long a[10005];
int main()
{
    int n;
    cin>>n;
    for (int i = 0; i < n; i++)
        cin>>a[i];
    long long sum = 0;
    for (int i = 0; i < n; i++)
    {
        if (a[i]%2 == 0)
        {
            do
            {
                sum++;
                a[i]/=2;
            }while (a[i]%2 == 0);
        }
    }
    cout<<sum<<endl;
    return 0;
}


Measured memory_bytes: 384
#include <algorithm>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>
#include <cfloat>

using std::cerr;
using std::cin;
using std::cout;
using std::endl;

int main(void){
  cout << std::fixed << std::setprecision(16);
  cin.tie(0);
  std::ios::sync_with_stdio(false);

  int n;
  cin>>n;
  std::vector<int> l(n);
  for(int i=0;i<n;i++){
    cin>>l[i];
  }
  std::sort(l.begin(), l.end());

  int result=0;

  for(int xi=0;xi<n;xi++){
    for(int yi=xi+1;yi<n;yi++){
      int x=l[xi],y=l[yi];
      int zi_min=yi+1;
      if(zi_min>=n) continue;

      int min=zi_min-1;
      int max=n;
      int mid=(max+min)/2;
      while(max-min>1){
        if(x+y>l[mid]){
          min=mid;

        }else{
          max=mid;

        }
        mid=(max+min)/2;

      }

      if(min>=zi_min){
        result+=(min-zi_min+1);
      }
    }
  }

  cout<<result<<endl;





  return 0;
}


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

int main() {
    long long n;
    cin >> n;

    vector<long long> a(n);
    for (int i = 0; i < n; i++){
        cin >> a.at(i);
    }
    
    long long cnt2=0;
    long long cnt4=0;
    for (int i = 0; i < n; i++){
        if(a[i]%2==0){
            cnt2++;
        }
        if(a[i]%4==0){
            cnt4++;
        }
    }
    if(cnt2+cnt4>=n || cnt4>=n/2){
        cout << "Yes" << endl;
    }
    else{
        cout << "No" << endl;
    }
}




Measured memory_bytes: 3964
#include <bits/stdc++.h>
using namespace std;
 
int main() {
    int ans = 0;
  string a;
  cin >> a;

  string A;
  string B;
  string C;

  A = a.at(0);
  B = a.at(1);
  C = a.at(2);
    
    if(A == "1"){
        ans++;
    }
    if(B == "1"){
        ans++;
    }
    if(C == "1"){
        ans++;
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
#ifdef _DEBUG
#include "dump.hpp"
#else
#define dump(...)
#endif

#define int long long
#define rep(i, a, b) for (int i = (a); i < (b); i++)
#define rrep(i, a, b) for (int i = (b)-1; i >= (a); i--)
#define all(c) begin(c), end(c)
const int INF =
    sizeof(int) == sizeof(long long) ? 0x3f3f3f3f3f3f3f3fLL : 0x3f3f3f3f;
const int MOD = 1e9 + 7;
template <class T>
bool chmax(T &a, const T &b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
template <class T>
bool chmin(T &a, const T &b) {
    if (b < a) {
        a = b;
        return true;
    }
    return false;
}

signed main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N;
    cin >> N;
    vector<int> a(N);
    rep(i, 0, N) { cin >> a[i]; }
    int k = 1;
    int ans = 0;
    rep(i, 1, N) {
        if (a[i - 1] == a[i])
            k++;
        else {
            ans += k / 2;
            k = 1;
        }
    }
    ans += k / 2;
    cout << ans << endl;
    return 0;
}

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

struct UnionFind
{
    vector<int> par;
    UnionFind(int n=0) : par(n, -1) {}
    int find(int x)
    {
        if(par.at(x) < 0) return x;
        return par.at(x) = find(par.at(x)); 
    }
    bool unite(int x, int y)
    {
        int rx = find(x);
        int ry = find(y);
        if(rx == ry) return false;
        if(par.at(rx) > par.at(ry)) swap(rx, ry);
        par.at(rx) += par.at(ry);
        par.at(ry) = rx;
        return true;
    }
    bool same(int x, int y) { return find(x) == find(y);}
    int size(int x) { return -par.at(find(x));}
};

int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    int N, M;
    cin >> N >> M;
    vector<int> P(N);
    for(int i=0; i<N; i++)
    {
        cin >> P.at(i);
        P.at(i)--;
    }
    vector<int> X(M), Y(M);
    UnionFind uf(N);
    for(int i=0; i<M; i++)
    {
        cin >> X[i] >> Y[i];
        X[i]--; Y[i]--;
        uf.unite(X[i], Y[i]);
    }

    int ans = 0;
    for(int i=0; i<N; i++)
    {
        if(uf.same(i, P[i])) ans++;
    }
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 4724
#include<bits/stdc++.h>
using namespace std;
#define all(vec) vec.begin(),vec.end()
typedef long long int ll;
typedef pair<int,int> P;
typedef pair<P,P> PP;
const ll MOD=10000;
const ll INF=1000000000;
const int MAX=100001;
int dx[4]={0,1,0,-1};
int dy[4]={1,0,-1,0};
ll keta(ll n){
    int d=0;
    while(n>0){
        n/=10;
        d++;
    }
    return d;
}
int main(){
    int a,b;
    while(cin>>a>>b){
    cout<<keta(a+b)<<endl;
    }
    return 0;
}

                           



Measured memory_bytes: 3052
#include <bits/stdc++.h>
using namespace std;
using lint     = long long;
const lint inf = 1LL << 60;
const lint mod = 1000000007;

struct mint {
    lint v;
    lint _mod;
    mint() : v(0) {}
    mint(signed v, lint _mod = mod) : v(v), _mod(_mod) {}
    mint(lint t, lint _mod = mod) : _mod(_mod) {
        v = t % _mod;
        if (v < 0)
            v += _mod;
    }

    mint pow(lint k) {
        mint res(1), tmp(v);
        while (k) {
            if (k & 1)
                res *= tmp;
            tmp *= tmp;
            k >>= 1;
        }
        return res;
    }
    static mint add_identity() { return mint(0); }
    static mint mul_identity() { return mint(1); }
    mint inv() { return pow(_mod - 2); }

    mint &operator+=(mint a) {
        v += a.v;
        if (v >= _mod)
            v -= _mod;
        return *this;
    }
    mint &operator-=(mint a) {
        v += _mod - a.v;
        if (v >= _mod)
            v -= _mod;
        return *this;
    }
    mint &operator*=(mint a) {
        v = v * a.v % _mod;
        return *this;
    }
    mint &operator/=(mint a) { return (*this) *= a.inv(); }

    mint operator+(mint a) const { return mint(v) += a; };
    mint operator-(mint a) const { return mint(v) -= a; };
    mint operator*(mint a) const { return mint(v) *= a; };
    mint operator/(mint a) const { return mint(v) /= a; };

    mint operator-() const { return v ? mint(_mod - v) : mint(v); }

    bool operator==(const mint a) const { return v == a.v; }
    bool operator!=(const mint a) const { return v != a.v; }
    bool operator<(const mint a) const { return v < a.v; }
};
ostream &operator<<(ostream &os, mint m) { return os << m.v; }

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    int n;
    cin >> n;
    string s;
    cin >> s;
    vector<int> cnt(26, 0);
    for (int i = 0; i < n; ++i) {
        cnt[s[i] - 'a']++;
    }
    mint ret = 1;
    for (int i = 0; i < 26; ++i) {
        ret *= cnt[i] + 1;
    }
    ret -= 1;
    cout << ret << "\n";
    return 0;
}

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

int main ()
{
	string s;  cin>>s;
	
	if(s[0]==s[1]&&s[1]==s[2])
	{
		cout<<"Yes"<<endl;
	}
	else if(s[1]==s[2]&&s[2]==s[3]){
		cout<<"Yes"<<endl;
	}
	else
	cout<<"No"<<endl;
	


}


Measured memory_bytes: 3596
def main(N, a):

  from queue import Queue as Que

  put = Que.put
  get = Que.get
  emp = Que.empty
  class Tree:
    def __init__(s, N):
      s.N = N
      s.R = {}
    def add(s, a, b):
      if a not in s.R: s.R[a] = [b]
      else: s.R[a].append(b)
    def makeTree(s, root):
      S = Que()
      s.D = [0] * s.N
      put(S, root)
      while not emp(S):
        t = get(S)
        if t not in s.R: continue
        for i in s.R[t]:
          s.D[i] = s.D[t] + 1
          put(S, i)
      s.M = max(s.D) + 1
      s.DL = [[] for _ in range(s.M)]
      for i in range(s.N):
        s.DL[s.D[i]].append(i)
    def sun(s, x):
      if x not in s.R: return []
      else: return s.R[x]

  T = Tree(N)

  for i in range(N - 1):
    T.add(a[i] - 1, i + 1)

  T.makeTree(0)

  D = T.D
  DL = T.DL
  M = T.M
  MEMO = [1] * N

  for i in range(M - 1, -1, -1):
    for n in T.DL[i]:
      R = {}
      L = []
      for s in T.sun(n):
        k = MEMO[s]
        if k in R:
          R[k] += 1
        else:
          R[k] = 1
          L.append(k)
      L.sort()
      mox = 0
      for i in range(len(L)):
        if mox > L[i]:
          mox += R[L[i]]
        else:
          mox = L[i] + R[L[i]]
        
      MEMO[n] = mox

  ans = MEMO[0]
  print(ans)

N = int(input())
a = [int(input()) for _ in range(N - 1)]

main(N, a)

"""
import random
for i in range(10):
  N = random.randrange(4) + 4
  a = [0] * (N - 1)
  L = [0]
  D = [i for i in range(N)]
  for j in range(N - 1):
    if a[j] != 0: continue
    k = L[random.randrange(len(L))]
    n = j + 1
    while n != 0:
      D.remove(n)
      L.append(n)
      a[n - 1] = k + 1
      k = n
      n = D[random.randrange(len(D))]
  print("N", N)
  print("n", [i for i in range(2, N + 1)])
  print("a", a)
  main(N, a)
"""

Measured memory_bytes: 109468
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

var sc = bufio.NewScanner(os.Stdin)

func main() {
	scanInit()

	a := nextInt()
	b := nextInt()
	c := nextInt()
	d := nextInt()

	// A
	ac := (a - 1) / c
	ad := (a - 1) / d
	acd := (a - 1) / lcm(c, d)
	ar0 := ac + ad - acd //aまでに割り切れる個数
	arem := (a - 1) - ar0

	// B
	bc := b / c
	bd := b / d
	bcd := b / lcm(c, d)
	br0 := bc + bd - bcd //bまでに割り切れる個数
	brem := b - br0

	//fmt.Println(br0, brem, ar0, arem)
	fmt.Println(brem - arem)
}
func gcd(a, b int) int {
	if b == 0 {
		return a
	}
	return gcd(b, a%b)
}
func lcm(a, b int, integers ...int) int {
	result := a * b / gcd(a, b)

	for i := 0; i < len(integers); i++ {
		result = lcm(result, integers[i])
	}

	return result
}

// ---- readfunc
func scanInit() {
	const cap = 64 * 1024
	var buf = make([]byte, cap)
	sc.Buffer(buf, cap)
	sc.Split(bufio.ScanWords)
	return
}
func nextInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}
func nextStr() string {
	sc.Scan()
	return sc.Text()
}


Measured memory_bytes: 1780
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
using uint = unsigned int;

int main() {

    int N, K; cin >> N >> K;
    string S; cin >> S;
    if (N == 1) {
        cout << 0 << endl;
        return 0;
    }

    int happiness = 0;
    for (size_t i = 0; i<(S.size()-1); i++) {
        if (S[i] == S[i+1]) happiness++;
    }
    if (happiness == (N - 1) ) {
        cout << happiness << endl;
        return 0;
    }

    int rotate = 0;
    uint left = 0;
    uint right = S.size() - 1;
    // ratate == k で終了
    while (rotate < K) {

        uint diff = 0;
        while ((left + diff) < S.size()) {
            if (S[left] != S[left + diff] ) break;
            ++diff;
        }
        if ((left + diff) == S.size()) break;
        else left = left + diff;

        diff = 0;
        while (right  >= diff) {
            if (S[right] != S[right - diff] ) break;
            ++diff;
        }
        if (right < diff) break;
        else right = right - diff;

        if (left < right) {
            happiness += 2;
        }
        else if (left == right) {
            happiness += 2;
            break;
        }
        else {
            happiness += 1;
            break;
        }

        ++rotate;
        if (happiness == N - 1) break;
    }

    cout << happiness << endl;
}



Measured memory_bytes: 512
from fractions import gcd

a, b = map(int, input().split())
g = gcd(a, b)

ans = 1

if g % 2 == 0:
  ans += 1
while g % 2 == 0:
  g /= 2

i = 3
while i * i <= g:
  if g % i == 0:
    ans += 1
  while g % i == 0:
    g /= i
  i += 2

if g != 1:
  ans += 1

print(ans)

Measured memory_bytes: 5304
#include <stdio.h>

int main (void)
{
    int h, w, i, j;
    char s[52][52];

    for (i = 0; i < h; ++i) {
        for (j = 0; j < w; ++j) {
            s[i][j] = 0;
        }
    }

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

    for (i = 1; i <= h; ++i) {
        for (j = 1; j <= w; ++j) {
            if (s[i][j] != '#') continue;
            if (s[i - 1][j] == '#') continue;
            else if (s[i][j - 1] == '#') continue;
            else if (s[i + 1][j] == '#') continue;
            else if (s[i][j + 1] == '#') continue;
            else {
                puts("No");
                return 0;
            }
        }
    }
    puts("Yes");
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
#include <numeric>
#include <algorithm>
#define REP(i, n) for(int i = 0; i < n; i++)
#define REP1(i, n) for(int i = 1; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define INF 2e9
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;

int main() {
	int a, b; cin >> a >> b;
	int ans = max({ a + (a - 1), a + b, b + (b - 1) });
	cout << ans << endl;
}

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

typedef long long ll;

const int INF = 1e9;
const int MOD = 1e9+7;
const ll LLINF = 1e18;

#define YES(n) cout << ((n) ? "YES" : "NO"  ) << endl
#define Yes(n) cout << ((n) ? "Yes" : "No"  ) << endl

#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define FORR(i,a,b) for(int i=(a);i>=(b);i--)

#define ALL(obj) (obj).begin(),(obj).end()

#define pii pair<int,int>

#define pb(a) push_back(a)
#define mp make_pair

int main()
{
	string s;
	ll k;
	cin >> s >> k;
	FOR(i, 0, (int)s.size()){
		if(s[i] != '1'){
			cout << s[i] << "\n";
			return 0;
		}else if(i == k-1){
			cout << 1 << "\n";
			return 0;
		}
	}
	return 0;
}


Measured memory_bytes: 256
#include<stdio.h>




long int myabs(long int a)
{
  if(a>0)return a;
  return -a;
}

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

  long int a[n],i,min=1000000000,sum=0;
  int count=0,flag=1;
  for(i=0;i<n;i++)
    {
      scanf("%ld",&a[i]);
      if(a[i]==0) flag=0;
      if(a[i]<0 && flag)
	{
	  a[i]=myabs(a[i]);
	 count++;
	}
      else a[i]=myabs(a[i]);
      sum+=a[i];
      if(a[i]<min)
	min=a[i];

    }

  if(flag && count%2==1)
    sum-=min*2;
  printf("%ld",sum);
}




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

int main() {
    int n, x;
    cin >> n >> x;
    vector<int> a(n);
    for (int i = 0; i < n; i++)
        cin >> a[i];
    sort(a.begin(), a.end());
    int ans = 0;
    for (int i = 0; i < n; i++) {
        if (a[i] <= x) {
            ans++;
            x -= a[i];
        } else {
            break;
        }
    }
    if (ans == n && x > 0)
        ans--;
    cout << ans << endl;
    return 0;
}

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


struct Num {
    ll x;
    bool t, f, s;
    Num(ll x, bool t, bool f, bool s) : x(x), t(t), f(f), s(s) {} 
    bool isOk() {return t && f && s;}
    bool operator<(const Num& num) const {return x < num.x;}
};

set<Num> S;
int d;
int n;

void dfs(Num num) {
    if (num.x > n) return;
    S.insert(num);
    dfs(Num(10*num.x + 3, true, num.f, num.s));
    dfs(Num(10*num.x + 5, num.t, true, num.s));
    dfs(Num(10*num.x + 7, num.t, num.f, true));
}

int main() 
{
    cin >> n;

    int m = n;
    while(m>0) {
        m /= 10;
        d++;
    }

    dfs(Num(0, false, false, false));

    int ans = 0;
    for (auto num : S) {
        if (num.isOk()) ans++;
    }
    cout << ans << endl;

    return 0;
}


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

int main(){
	int n;
	cin >> n;

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

Measured memory_bytes: 3820
#include <stdio.h>
int main(){
  int i,j,H,W;
  while(1){
    scanf("%d %d",&H,&W);
    if(H==0 || W==0)break;
    for(i=0;i<H;i++){
      for(j=0;j<W;j++){
	if(i==0 || i==H-1)printf("#");
	else if(i>=1 || i<=H-1){
	  if(j==0 || j==W-1)printf("#");
	  else printf(".");
	}
      }
      printf("\n");
    }
    printf("\n");
  }
  return 0;
}

Measured memory_bytes: 572
import java.io.IOException;
import java.util.Arrays;
import java.util.Scanner;
 
public class Main {
 public static void print(int a,int b,int c){
	 System.out.print(a);
	 System.out.print(" ");
	 System.out.print(b);
	 System.out.print(" ");
	 System.out.println(c);
 }
    public static void main(String[] args) throws IOException {
             
       Scanner sc = new Scanner(System.in);
       int []a=new int[3];
      a[0] = sc.nextInt();
      a[1] = sc.nextInt();
      a[2] = sc.nextInt();
      
      Arrays.sort(a);
      print(a[0],a[1],a[2]);       }
     
      } 
   

Measured memory_bytes: 17156
n=gets.to_i
t,a=gets.split.map(&:to_i)
hs=gets.split.map(&:to_i)

kion=999999999
id=-1
hs.each_with_index{|h,i|
  if kion>((t-h*0.006)-a).abs
    kion=((t-h*0.006)-a).abs
    id=i
  end
}
puts id+1

Measured memory_bytes: 1788
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace AtCoder
{
    class Program
    {
        static void Main(string[] args)
        {
            string[] original_enemy = Console.ReadLine().Split();
            int enemy = int.Parse(original_enemy[0]);
            int special_attack = int.Parse(original_enemy[1]);

            string[] original_hp = Console.ReadLine().Split();
            long[] hp = original_hp.Select(long.Parse).ToArray();
            Array.Sort(hp);
            Array.Reverse(hp);
            if(special_attack > hp.Length)
            {
                special_attack = hp.Length;
            }
            for (int i = 0; i < special_attack; i++)
            {
                hp[i] = 0;
            }
            Console.WriteLine(hp.Sum());
            Console.Read();
        }
    }
}

Measured memory_bytes: 39552
import java.io._
import java.util.StringTokenizer
import scala.util.control.Breaks.{breakable,break}
import scala.collection.mutable.{Map, Stack, Queue, PriorityQueue, Set}

object Main extends App {
  val in = new InputReader(System.in)
  val pw = new PrintWriter(System.out)

  val r1, c1, r2, c2 = in.next().toInt

  //
  val MOD = 1e9.toInt + 7
  val mc = new ModComb(1e6.toInt * 3, MOD)

  def calc(r: Int, c: Int): Long = mc.comb(r+c+2, c+1) - 1

  var ans = 0L
  ans += calc(r2, c2)
  ans += calc(r1-1, c1-1)
  ans %= MOD

  ans += MOD - calc(r2, c1-1)
  ans %= MOD

  ans += MOD - calc(r1-1, c2)
  ans %= MOD

  println(ans)
}

class ModComb(maxNum: Int, mod: Long) {

  private def repeatSquares(x: Long, n: Long): Long = {
    def func(x: Long, n: Long): Long = {
      if(n == 0)
        1
      else if(n % 2 == 0)
        func(x*x % mod, n/2)
      else
        (x * func(x*x % mod, n/2)) % mod
    }

    if (x == 0 && n != 0) 0
    else func(x, n)
  }

  private val fact = new Array[Long](maxNum + 1)

  fact(0) = 1
  for (i <- 1 to maxNum)
    fact(i) = (i * fact(i-1)) % mod

  private val factInv = new Array[Long](maxNum + 1)

  factInv(maxNum) = repeatSquares(fact(maxNum), mod-2)
  for (i <- (1 to maxNum).reverse)
    factInv(i-1) = (i * factInv(i)) % mod


  // nCk
  def comb(n: Int, k: Int): Long = {
    val numer = fact(n)
    val denom = (factInv(n-k) * factInv(k)) % mod

    (numer * denom) % mod
  }

}


class InputReader(stream: InputStream) {
  private[this] val reader = new BufferedReader(new InputStreamReader(stream))
  private[this] var tokenizer: StringTokenizer = new StringTokenizer(reader.readLine())
  def next(): String = {
    while (!tokenizer.hasMoreTokens()) {
      tokenizer = new StringTokenizer(reader.readLine())
    }
    tokenizer.nextToken()
  }
}


Measured memory_bytes: 72768
package main

import "fmt"

func main() {
	var (
		n int
		s string
	)
	fmt.Scan(&n, &s)

	cost := 0
	for i := 1; i < n; i++ {
		if s[i] == 'E' {
			cost++
		}
	}

	min := cost
	for i := 1; i < n; i++ {
		if s[i] == 'E' {
			cost--
		}
		if s[i-1] == 'W' {
			cost++
		}
		if cost < min {
			min = cost
		}
	}
	fmt.Println(min)
}


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

int main() {
	string s;
	cin >> s;
	
	if (s[0] == 'S')
		cout << "Cloudy\n";
	else if (s[0] == 'C')
		cout << "Rainy\n";
	else
		cout << "Sunny\n";
	return 0;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
typedef long long lint;
#define rep(i,n) for(int i=0;i<(n);++i)
#define MAXN 410
#define linf 4223372036854775808
lint dp[MAXN][MAXN];
lint n;
vector<lint> a,s;
lint rec(int l,int r){
	if(dp[l][r]!=-1)return dp[l][r];
	if(r-l==1)return dp[l][r]=0;
	lint tmp,res=linf;
	for(int m=l+1;m<r;++m){
		tmp=rec(l,m)+rec(m,r)+s[r]-s[l];
		if(tmp<res)res=tmp;
	}return dp[l][r]=res;
}
int main(){
	cin.tie(0);cout.tie(0);
	ios::sync_with_stdio(0);

	cin>>n;
	rep(i,n+1)rep(j,n+1)dp[i][j]=-1;
	a.resize(n);s.resize(n+1);
	rep(i,n){
		cin>>a[i];
		s[i+1]=s[i]+a[i];
	}cout<<rec(0,n)<<endl;
	getchar();getchar();
	return 0;
}

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

const double PI = acos(-1);
const double EPS = 1e-15;
using ll = long long;
using ull = unsigned long long;
const int inf = 2e9;
const ll INF = 2e18;
const ll MOD = 1e9+7;
const ll MOD1 = 998244353;
typedef pair<int,int> P;

#define REP(i,n) for (int i = 0; i < (n); i++)
#define sz(s) (s).size()
#define pb push_back
#define fi first
#define se second
#define mp make_pair

int main(){
  int c,n,m,s,d;
  while (cin >> c >> n >> m >> s >> d,c,n,m,s,d) {
    ll dp[110][11];
    REP(i,110) REP(j,11) dp[i][j] = INF;
    s--;
    d--;
    vector<pair<int,ll>> G[110];
    REP(i,m) {
      int a,b;
      ll f;
      cin >> a >> b >> f;
      a--;
      b--;
      G[a].pb({b,f});
      G[b].pb({a,f});
    }
    priority_queue<pair<ll,pair<int,int>>,vector<pair<ll,pair<int,int>>>,greater<pair<ll,pair<int,int>>>> pq;
    dp[s][0] = 0;
    pq.push({0,{s,0}});
    while (!pq.empty()) {
      pair<ll,pair<int,int>> tp = pq.top();
      //cout << tp.fi << " " << tp.se.fi << " " << tp.se.se << endl;
      pq.pop();
      int point = tp.se.fi;
      int ticket = tp.se.se;
      if (tp.fi > dp[point][ticket]) continue;
      //cout << "test" << endl;
      REP(i,sz(G[point])) {
        int next = G[point][i].fi;
        ll cost = G[point][i].se;
        if (dp[point][ticket] + cost < dp[next][ticket]) {
          dp[next][ticket] = dp[point][ticket] + cost;
          pq.push({dp[next][ticket],{next,ticket}});
        }
        if (ticket < c && dp[point][ticket] + cost/2 < dp[next][ticket+1]) {
          dp[next][ticket+1] = dp[point][ticket] + cost/2;
          pq.push({dp[next][ticket+1],{next,ticket+1}});
        }
      }
    }
    ll ans = INF;
    REP(i,c+1) {
      ans = min(ans,dp[d][i]);
    }
    cout << ans << endl;
  }
  return 0;
}




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

int main()
{
    char s1[200001], s2[200001];
    int ln, i, cnt=0;
    cin>>s1>>s2;
    ln = strlen(s1);
    for(i=0; i<ln; i++){
        s1[i]= tolower(s1[i]);
        s2[i]= tolower(s2[i]);
    }
    for(i=0; i<ln; i++){
        if(s1[i]!=s2[i]){
            cnt++;
        }
    }
    printf("%d\n", cnt);
    return 0;
}


Measured memory_bytes: 4108
#include <iostream>
#include <iomanip>
#include <vector>
#include <set>
#include <string>
#include <queue>
#include <algorithm>
#include <map>
#include <cmath>
#include <numeric>
#include <list>
#include <stack>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <tuple>

#define rep(i, n) for (int i = 0; i < (n); i++)
#define rep1(i, n) for (int i = 1; i <= (n); i++)
#define show(a, n) rep(i,n) {cout<<a[i]<<' ';} cout<<endl;

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

const int INF = 1 << 30;
const long long INFL = 1LL << 62;
const int MOD = 1000000007;
const int MAX = 100000;
const int N = 100010;

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


Measured memory_bytes: 256
li = []
n = 3
import collections
for i in range(n):
    a,b = input().split()
    li.append(a)
    li.append(b)
    
c = collections.Counter(li)

def cole(di):
    i = 0
    for k in di.keys():
        if di[k] != 0 and di[k] <= 2:
            i += 1
        else:
            i -= 1
    if i == 4:
        return True
    else:
        return False

if cole(c):
    print("YES")
else:
    print("NO")

Measured memory_bytes: 3316
#include<iostream>
#include<algorithm>
#include<cstdio>

using namespace std;

int main(){
	int sen[10000];
	int bit[1024];
	int num[1024],s;
	for(int i=0;i<1024;i++)
		for(num[i]=0,s=i;s>0;s >>= 1)num[i]+=s&1;
	
  int r,c,cc;
  while(true){
		scanf("%d %d",&r,&c);
		if (!r&&!c)break;
		for(int i=0;i<c;i++) sen[i] = 0;
		
		for(int j=0;j<r;j++){
			for(int i=0;i<c;i++){
				scanf("%d",&cc);
				sen[i] <<= 1;
				sen[i] += cc;
			}
		}
		for(int i=0;i<1024;i++) bit[i] = 0;
		for(int i=0;i<c;i++) bit[sen[i]]++;

		int n,sum = 0,smax = 0,k=1,l;
		k <<= r-1;
		for(int i=0;i<k;i++){
			sum = 0;
			for(int j=0;j<k<<1;j++){
				s = j^i;
				sum += max(num[s],r-num[s]) * bit[j];
			}
			if (sum>smax)smax = sum;
		}
		printf("%d\n",smax);
  }
  return 0;
}

Measured memory_bytes: 0
import java.io.IOException;
import java.util.Arrays;

public class Main {

	public static void main(String[] args) {

		int n = nextInt();
		int m = nextInt();

		Treasure[] treasure = new Treasure[n];

		for (int i = 0; i < n; i++) {
			treasure[i] = new Treasure(nextInt(), nextInt());
		}

		Arrays.sort(treasure);

		for (int q = 0; q < m; q++) {
			int cnt = 0;
			int x1 = nextInt();
			int y1 = nextInt();
			int x2 = nextInt();
			int y2 = nextInt();

			for (int i = 0; i < n; i++) {
				if (treasure[i].x >= x1) {
					for (int k = i; k < n; k++) {
						if (treasure[k].x > x2) {
							i = n;
							k = n;
						} else if (y1 <= treasure[k].y && treasure[k].y <= y2) {
							cnt++;
						}
					}
					break;
				}
			}
			System.out.println(cnt);
		}
	}

	static int nextInt() {
		int c;
		try {
			c = System.in.read();
			while (c != '-' && (c < '0' || c > '9'))
				c = System.in.read();
			if (c == '-')
				return -nextInt();
			int res = 0;
			while (c >= '0' && c <= '9') {
				res = res * 10 + c - '0';
				c = System.in.read();
			}
			return res;
		} catch (IOException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		return -1;
	}
}

class Treasure implements Comparable<Treasure> {
	int x = 0;
	int y = 0;

	public Treasure(int x, int y) {
		this.x = x;
		this.y = y;
	}

	public int compareTo(Treasure t1) {
		return this.x - t1.x;
	}
}

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

#define FOR(i, a, b)  for (int i = (a); i < (b); i++)
#define FORd(i, a, b) for (int i = (a); i >= (b); i--)
#define REP(i, n) FOR(i, 0, n)
#define TRACE(x) cout << #x << " = " << x << "\n"
#define _ << " _ " <<
#define ll long long

using namespace std;

ll a[200010];

int main() {
  ios_base::sync_with_stdio(false);

  ll x, y, sum = 0;
  int n;
  cin >> n;

  REP(i, n) {
    ll tr;
    cin >> tr;
    a[i] = tr;
    if (i) a[i] += a[i - 1];
    sum += tr;
  }
  ll out = 1e18;
  REP(i, n - 1) {
    x = a[i];
    y = (sum - a[i]);
    if (x > y) swap(x, y);
    if (x < 0 && y > 0) out = min(out, -x + y);
    else                out = min(out, abs(y - x));
  }
  cout << out << endl;

  return 0;
}


Measured memory_bytes: 1792
public class Main {
    public static void main(String args[]) {
        for (int i = 1; i <=9; i++) {
            for (int j = 1; j <= 9; j++) {
                int v = i * j;
                System.out.println(String.format("%dx%d=%d", i, j, v));
            }
        }
    }
}

Measured memory_bytes: 24980
//============================================================================
// Name        : JOI.cpp
// Author      :
// Version     :
// Copyright   : Your copyright notice
// Description : Hello World in C++, Ansi-style
//============================================================================

#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <math.h>
using namespace std;
typedef long long ll;
string str;
int main() {
    cin>>str;


    int R=0;
    for(int i=0;i<3;i++){
    	if(str[i]=='1')R++;
    }

    cout<<R<<endl;
    return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main{

	public static void main(String[] args) {
		// TODO ?????????????????????????????????????????????
		new Main().start();
	}
	void start(){
		Scanner in = new Scanner(System.in);
		int n = in.nextInt();
		Card[] originalC = new Card[n];
		for(int i = 0; i < n; i++){
			String card = in.next();
			char suit = card.charAt(0);
			int num = Integer.parseInt(""+card.charAt(1));
			originalC[i] = new Card(suit, num);
		}
		Card[] c1 = new Card[n];
		copy(c1,originalC);
		Card[] bubbleC = bubbleSort(c1,n);
		printArray(bubbleC);
		System.out.println("Stable");	//bubbleSort???????????¨????????\???????????????
		Card[] c2 = new Card[n];
		copy(c2,originalC);
		Card[] selectionC = selectionSort(c2,n);
		printArray(selectionC);
		if(hikaku(bubbleC,selectionC)) System.out.println("Stable");
		else System.out.println("Not stable");
		in.close();
	}
	void copy(Card[] a, Card[]b){
		for(int i = 0; i < a.length; i++){
			a[i] = b[i];
		}
	}
	boolean hikaku(Card[] a, Card[] b){
		for(int i = 0; i < a.length; i++){
			if(a[i].suit != b[i].suit) return false;
		}
		return true;
	}
	Card[] bubbleSort(Card[] c, int n){
		for(int i = 0; i < n-1; i++){
			for(int j = n-1; j >= i+1; j--){
				if(c[j].num  < c[j-1].num){
					Card tmp = c[j];
					c[j] = c[j-1];
					c[j-1] = tmp;
				}
			}
		}
		return c;
	}
	Card[] selectionSort(Card[] c, int n){
		for(int i = 0; i < n; i++){
			int minj = i;
			for(int j = i; j < n;j++){
				if(c[j].num < c[minj].num) minj = j;
			}
			if(minj != i){
				Card tmp = c[i];
				c[i] = c[minj];
				c[minj] = tmp;
			}
		}
		return c;
	}
	void printArray(Card[] c){
		String s = c[0].toString();
		for(int i = 1; i < c.length; i++){
			s += " " + c[i];
		}
		System.out.println(s);
	}
}

class Card{
	char suit;
	int num;
	Card(char suit, int num){
		this.suit = suit;
		this.num = num;
	}
	public String toString(){
		return "" + suit + num;
	}
}

Measured memory_bytes: 26344
k = int(input())
n = len(input())

MOD = 10**9 + 7

fact = [1] * 2200000
invfact = [1] * 2200000

for i in range(1, 2200000):
  fact[i] = fact[i-1] * i % MOD

invfact[-1] = pow(fact[-1], MOD-2, MOD)

for i in range(2200000-1, 0, -1):
  invfact[i-1] = invfact[i] * i % MOD

def nCk(n, k):
  return fact[n] * invfact[k] * invfact[n-k] % MOD

ans = 0

for l in range(n, n+k+1):
  ans += pow(25, l-n, MOD) * nCk(l-1,n-1) * pow(26, n+k-l, MOD) % MOD
  ans %= MOD

print(ans)


Measured memory_bytes: 125804
#include <string>
#include <vector>
#include <iostream>
#include <functional>
using namespace std;
int main() {
	int N, Q; string S;
	cin >> N >> S >> Q;
	for (int i = 0; i < Q; ++i) {
		int x;
		cin >> x;
		int pl = 0, pr = 0, cm = 0, cc = 0; long long score = 0;
		function<void()> move_right = [&](){
			if (S[pr] == 'M') ++cm;
			if (S[pr] == 'C') ++cc, score += cm;
			++pr;
		};
		function<void()> move_left = [&]() {
			if (S[pl] == 'M') --cm, score -= cc;
			if (S[pl] == 'C') --cc;
			++pl;
		};
		for (int i = 0; i < x; ++i) move_right();
		long long ans = 0;
		for (int i = 0; i < N; ++i) {
			if (S[i] == 'D') ans += score;
			if (pr < N) move_right();
			move_left();
		}
		cout << ans << endl;
	}
	return 0;
}

Measured memory_bytes: 1412
#pragma gcc optimize("Ofast")

#include "bits/stdc++.h"
using namespace std;
typedef int64_t lld;
typedef pair<int,int> pii;
typedef pair<lld,lld> pll;
typedef pair<int,pll> pip;
typedef pair<pll,int> ppi;
typedef pair<lld,pll> plp;
typedef pair<pll,lld> ppl;
typedef pair<pll,pll> ppp;
template<typename T>
using maxHeap = priority_queue<T,vector<T>,less<T>>;
template<typename T>
using minHeap = priority_queue<T,vector<T>,greater<T>>;
#define ff first
#define ss second
#define pb push_back
#define all(x) (x).begin(),(x).end()
#define endl '\n'
#define jizz cin.tie(0);cout.tie(0);ios::sync_with_stdio(0);
inline void input(int &_x) {
    _x = 0;
    int _tmp = 1; char _tc = getchar();
    while((_tc < '0' || _tc > '9') && _tc != '-') _tc = getchar();
    if(_tc == '-') _tc = getchar(), _tmp = -1;
    while(_tc >= '0' && _tc <= '9') _x = _x*10+(_tc-48), _tc = getchar();
    _x *= _tmp;
}
inline void output(int _x) {
    char _buff[20]; int _f = 0;
    if(_x == 0)putchar('0');
    while(_x > 0)
    {
        _buff[_f++] = _x%10+'0';
        _x /= 10;
    }
    for(_f-=1; _f >= 0; _f--)
        putchar(_buff[_f]);
    putchar('\n');
}
template<typename Iter>
ostream& _out(ostream &s, Iter b, Iter e) {
    s<<"[";
    for ( auto it=b; it!=e; it++ ) s<<(it==b?"":" ")<<*it;
    s<<"]";
    return s;
}
template<class T1,class T2>
ostream& operator<<(ostream& out, pair<T1,T2> p) {
    return out << '(' << p.first << ", " << p.second << ')';
}
template<typename T>
ostream& operator <<( ostream &s, const vector<T> &c ) {
     return _out(s,c.begin(),c.end());
 }
#ifdef erd1
    #define pprint(x) cerr<<__PRETTY_FUNCTION__<<":"<<__LINE__<<" - "<<(#x)<<"="<<(x)<<endl
#else
    #define pprint(x)
#endif

// code starts here
int r, c;
int id(int x, int y){
    if(y == 0)return x;
    if(x == r)return r+y;
    if(y == c)return r+c+r-x;
    if(x == 0)return r+c+r+c-y;
    return -1;
}
priority_queue<pii,vector<pii>,greater<pii>> Q;
vector<pii> v;
signed main(){
    int n;
    cin >> r >> c >> n;
    for(int i = 0; i < n; i++){
        int a, b, x, y;
        cin >> a >> b >> x >> y;
        int id1 = id(a, b), id2 = id(x, y);
        if(id1 != -1 && id2 != -1)v.pb({min(id1, id2), max(id1, id2)});
    }
    sort(all(v));
    v.pb({INT_MAX, INT_MAX});
    int cnt = 0;
    for(auto p: v){
        while(!Q.empty() && Q.top().ff < p.ff)
            if(Q.top().ss != --cnt)return cout << "NO" << endl, 0;
            else Q.pop();
        Q.push({p.ss, cnt++});
    }
    cout << "YES" << endl;
}


Measured memory_bytes: 1908
#include<bits/stdc++.h>
using namespace std;
#define rep(i, c) for(int i = 0; i < (int)c; i++)
#define ll long long
const int inf = 1000000000; // 10^9

bool is_prime(int x){
    if(x < 2) return false;
    for(int i = 2; i*i <= x; i++){
        if(x%i == 0) return false;
    }
    return true;
}

int main(){
    int x;
    cin >> x;

    int p = x;

    while(!is_prime(p)) p++;
    cout << p << endl;

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = int64_t;
const char nl = '\n';

int main() {
    ll a, b, c; cin >> a >> b >> c;
    ll x = c - a - b;
    if (x < 0) {
        cout << "No\n";
        return 0;
    }
    if (a * b < x * x / 4.0L) {
        cout << "Yes";
    } else {
        cout << "No";
    }
    cout << nl;
    return 0;
}



Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <string>
#include <algorithm>
#include <functional>
#include <set>
#include <map>
#include <unordered_map>
#include <queue>
#include <deque>
#include <cmath>
#include <cstdio>

using namespace std;

typedef long long ll;

#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) for (int i = 0; i < (n); ++i)

int main(int argc, char **argv)
{
    int A[5];
    REP(i, 5) cin >> A[i];

    int B[5];
    int m = 0;
    REP(i, 5) {
        B[i] = ((A[i] + 9) / 10) * 10;
        if (m < B[i] - A[i]) m = B[i] - A[i];
    }
    int t = 0;
    REP(i, 5) t += B[i];
    cout << t - m << endl;
    return 0;
}


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

using namespace std;

long long int N;
string S;


int main() {
	cin >> N >> S;
	string X = S;
	X[0] = 'S';
	X[1] = 'S';
	for( size_t i = 2; i < N; i++ ) {
		if( X[i - 1] == 'S' ) {
			if( S[i - 1] == 'o' ) {
				X[i] = X[i - 2];
			} else {
				X[i] = X[i - 2] == 'S' ? 'W' : 'S';
			}
		} else {
			if( S[i - 1] == 'o' ) {
				X[i] = X[i - 2] == 'S' ? 'W' : 'S';
			} else {
				X[i] = X[i - 2];
			}
		}
	}
	if( (X[N - 1] == X[1] && S[0] == 'o') || (X[N - 1] != X[1] && S[0] == 'x') ) {
		if( S[N - 1] == 'o' && ((X[N - 1] == 'S'&&X[N - 2] == X[0]) || (X[N - 1] == 'W'&&X[N - 2] != X[0]))
			|| (S[N - 1] == 'x' && ((X[N - 1] == 'S'&&X[N - 2] != X[0]) || (X[N - 1] == 'W'&&X[N - 2] == X[0]))
			) ) {

			cout << X << endl;
			return 0;
		}
	}
	X[1] = 'W';
	for( size_t i = 2; i < N; i++ ) {
		if( X[i - 1] == 'S' ) {
			if( S[i - 1] == 'o' ) {
				X[i] = X[i - 2];
			} else {
				X[i] = X[i - 2] == 'S' ? 'W' : 'S';
			}
		} else {
			if( S[i - 1] == 'o' ) {
				X[i] = X[i - 2] == 'S' ? 'W' : 'S';
			} else {
				X[i] = X[i - 2];
			}
		}
	}
	if( (X[N - 1] == X[1] && S[0] == 'o') || (X[N - 1] != X[1] && S[0] == 'x') ) {
		if( S[N - 1] == 'o' && ((X[N - 1] == 'S'&&X[N - 2] == X[0]) || (X[N - 1] == 'W'&&X[N - 2] != X[0]))
			|| (S[N - 1] == 'x' && ((X[N - 1] == 'S'&&X[N - 2] != X[0]) || (X[N - 1] == 'W'&&X[N - 2] == X[0]))
			) ) {
			cout << X << endl;
			return 0;
		}
	}

	X[0] = 'W';
	X[1] = 'S';
	for( size_t i = 2; i < N; i++ ) {
		if( X[i - 1] == 'S' ) {
			if( S[i - 1] == 'o' ) {
				X[i] = X[i - 2];
			} else {
				X[i] = X[i - 2] == 'S' ? 'W' : 'S';
			}
		} else {
			if( S[i - 1] == 'o' ) {
				X[i] = X[i - 2] == 'S' ? 'W' : 'S';
			} else {
				X[i] = X[i - 2];
			}
		}
	}
	if( !((X[N - 1] == X[1] && S[0] == 'o') || (X[N - 1] != X[1] && S[0] == 'x')) ) {
		if( S[N - 1] == 'o' && ((X[N - 1] == 'S'&&X[N - 2] == X[0]) || (X[N - 1] == 'W'&&X[N - 2] != X[0]))
			|| (S[N - 1] == 'x' && ((X[N - 1] == 'S'&&X[N - 2] != X[0]) || (X[N - 1] == 'W'&&X[N - 2] == X[0]))
			) ) {
			cout << X << endl;
			return 0;
		}
	}
	X[1] = 'W';
	for( size_t i = 2; i < N; i++ ) {
		if( X[i - 1] == 'S' ) {
			if( S[i - 1] == 'o' ) {
				X[i] = X[i - 2];
			} else {
				X[i] = X[i - 2] == 'S' ? 'W' : 'S';
			}
		} else {
			if( S[i - 1] == 'o' ) {
				X[i] = X[i - 2] == 'S' ? 'W' : 'S';
			} else {
				X[i] = X[i - 2];
			}
		}
	}
	if( !((X[N - 1] == X[1] && S[0] == 'o') || (X[N - 1] != X[1] && S[0] == 'x')) ) {
		if( S[N - 1] == 'o' && ((X[N - 1] == 'S'&&X[N - 2] == X[0]) || (X[N - 1] == 'W'&&X[N - 2] != X[0]))
			|| (S[N - 1] == 'x' && ((X[N - 1] == 'S'&&X[N - 2] != X[0]) || (X[N - 1] == 'W'&&X[N - 2] == X[0]))
			) ) {
			cout << X << endl;
			return 0;
		}
	}
	cout << -1 << endl;
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
int main(void){
  int n;
  cin >> n;
  if(n<=599){
    cout << '8' << endl;
  }else if(n<=799){
    cout << '7' << endl;
  }else if(n<=999){
    cout << '6' << endl;
  }else if(n<=1199){
    cout << '5' << endl;
  }else if(n<=1399){
    cout << '4' << endl;
  }else if(n<=1599){
    cout << '3' << endl;
  }else if( n<=1799){
    cout << '2' << endl;
  }else if(n<=1999) {
    cout << '1' << endl;
  }else{
    return 0;
  }
  return 0;
}

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

      int a = sc.nextInt();

      int b = sc.nextInt();

      if (a==b) {
        System.out.println("Draw");
        return;
      }
      if(a==1){
        System.out.println("Alice");
        return;
      }
      if(b==1){
        System.out.println("Bob");
        return;
      }
      if(a>b){
        System.out.println("Alice");
        return;
      }
      if(a<b){
        System.out.println("Bob");
        return;
      }
  }
}


Measured memory_bytes: 23632
#include <map>
#include <set>
#include <list>
#include <cmath>
#include <queue>
#include <stack>
#include <cstdio>
#include <string>
#include <vector>
#include <complex>
#include <cstdlib>
#include <cstring>
#include <numeric>
#include <sstream>
#include <iostream>
#include <algorithm>
#include <functional>
  
#define mp       make_pair
#define pb       push_back
#define all(x)   (x).begin(),(x).end()
#define rep(i,n) for(int i=0;i<(n);i++)
  
using namespace std;
  
typedef    long long          ll;
typedef    unsigned long long ull;
typedef    vector<bool>       vb;
typedef    vector<int>        vi;
typedef    vector<vb>         vvb;
typedef    vector<vi>         vvi;
typedef    pair<int,int>      pii;
  
const int INF=1<<29;
const double EPS=1e-9;
  
const int dx[]={1,0,-1,0,1,1,-1,-1},dy[]={0,-1,0,1,1,-1,-1,1};


int main() {
  string S;
  cin >> S;
  for (int i = 0; i < 1 << 3; i++) {
    int now = S[0] - '0';
    for (int j = 0; j < 3; j++) {
      if (i >> j & 1) {
        now += S[j + 1] - '0';
      } else {
        now -= S[j + 1] - '0';
      }
    }
    if (now == 7) {
      cout << S[0];
      for (int j = 0; j < 3; j++) {
        if (i >> j & 1) {
          cout << "+";
        } else {
          cout << "-";
        }
        cout << S[j + 1];
      }
      cout << "=7" << endl;
      return 0;
    }
  }

  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define P pair<ll,ll>
#define FOR(I,A,B) for(ll I = (A); I < (B); ++I)
#define FORR(I,A,B) for(ll I = ((B)-1); I >= (A); --I)
#define TO(x,t,f) ((x)?(t):(f))
#define SORT(x) (sort(x.begin(),x.end())) // 0 2 2 3 4 5 8 9
#define REV(x) (reverse(x.begin(),x.end())) //reverse
ll gcd(ll a,ll b){if(a<b)swap(a,b);if(a%b==0)return b;return gcd(b,a%b);}
ll lcm(ll a,ll b){ll c=gcd(a,b);return ((a/c)*(b/c)*c);}//saisyo kobaisu
#define NEXTP(x) next_permutation(x.begin(),x.end())
const ll INF=1e18+7;
const ll MOD=1e9+7;
#define pri(a) cout << (a) << endl


int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	vector<ll> Yes(100001,0);
	FOR(i,0,100001){
		ll x = i*8 + 1;
		ll p = sqrt(x);
		if(p*p==x){
			//if(p%2==0)cout << 6666666666666666 << endl;
			Yes[i]=(1+p)/2;
		}
	}
	ll N;
	cin >> N;
	if(Yes[N]==0){
		cout << "No" << endl;
		return 0;
	}
	ll K = Yes[N];
	// tyouten -> K
	// hen -> N
	bool same[K+1][K+1]={false};
	vector< vector<ll> > Si;
	Si.resize(K+1);
	ll num=1;
	FOR(i,1,K+1){
		FOR(j,1,K+1){
			if(j==i)continue;
			if(not same[i][j]){
				same[i][j] = same[j][i] = true;
				Si[i].push_back(num);
				Si[j].push_back(num);
				num++;
			}
		}
	}
	cout << "Yes" << endl;
	cout << K << endl;
	FOR(i,1,K+1){
		cout << Si[i].size() << " ";
		FOR(j,0,Si[i].size()){
			cout << Si[i][j] << " ";
		}
		cout << endl;
	}
}


Measured memory_bytes: 4224
import java.util.Scanner;

public class Main {
	int count = 0;
	void run() {
		Scanner sc = new Scanner(System.in);
		int K = sc.nextInt();
		int S = sc.nextInt();
		for(int x = 0; x <= K; x++) {
			for(int y = 0; y <= K; y++) {
				if(S - x - y >= 0 && S - x - y <= K) {
					count++;
				}
			}
		}
		System.out.println(count);
		sc.close();
	}

	public static void main(String[] args) {
		new Main().run();
	}
}

Measured memory_bytes: 21844