akhauriyash/Code-Regression huggingface dataset:
n,a,b = map(int,input().split())
current_num = 0
ans = 0
for i in range(1,n+1):
    current_num = (i%10) + (i//10 - (i//100)*10) + (i//100 - (i//1000)*10) + (i//1000 - (i//10000)*10) + (i//10000)
    if current_num >= a and current_num <= b:
        ans += i
        # print(i)
print(ans)

Measured memory_bytes: 3060
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author Yulian
 */



#include <iostream>

#include <fstream>
#include <vector>
#include <set>
#include <cmath>
#include <queue>
#include <deque>
#include <string>
#include <algorithm>
#include <map>
#include <numeric>
#include <limits>


#include <ostream>
#include <sstream>


using namespace std;

class C {
public:
  void solve(std::istream &in, std::ostream &out) {
    ios::sync_with_stdio(false);
    long long int n, t, x, tmp, lastend;
    x = lastend = 0;
    in >> n >> t;
    for (int i = 0; i < n; ++i) {
      in >> tmp;
      x += t - max(0ll, lastend - tmp);
      lastend = tmp + t;
    }
    out << x;
  }
};


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


Measured memory_bytes: 256
#include "bits/stdc++.h"
#define rep(i,n) for(int i = 0; i < (n); ++i)
using namespace std;
typedef long long int ll;
typedef pair<int, int> P;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

const int MX = 200005;
bool from1[MX], fromN[MX];

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n, m;
    cin >> n >> m;
    rep(i,m){
        int a, b;
        cin >> a >> b;
        if(a == 1) from1[b] = true;
        if(b == n) fromN[a] = true;
    }
    for(int i = 1; i <= n; ++i){
        if(from1[i] && fromN[i]){
            cout << "POSSIBLE" << endl;
            return 0;
        }
    }
    cout << "IMPOSSIBLE" << endl;
    return 0;
}


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

using namespace std;


using int64 = long long;
const int mod = 998244353;

const int64 infll = (1LL << 62) - 1;
const int inf = (1 << 30) - 1;

struct IoSetup {
  IoSetup() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(10);
    cerr << fixed << setprecision(10);
  }
} iosetup;


template< typename T1, typename T2 >
ostream &operator<<(ostream &os, const pair< T1, T2 > &p) {
  os << p.first << " " << p.second;
  return os;
}

template< typename T1, typename T2 >
istream &operator>>(istream &is, pair< T1, T2 > &p) {
  is >> p.first >> p.second;
  return is;
}

template< typename T >
ostream &operator<<(ostream &os, const vector< T > &v) {
  for(int i = 0; i < (int) v.size(); i++) {
    os << v[i] << (i + 1 != v.size() ? " " : "");
  }
  return os;
}

template< typename T >
istream &operator>>(istream &is, vector< T > &v) {
  for(T &in : v) is >> in;
  return is;
}

template< typename T1, typename T2 >
inline bool chmax(T1 &a, T2 b) { return a < b && (a = b, true); }

template< typename T1, typename T2 >
inline bool chmin(T1 &a, T2 b) { return a > b && (a = b, true); }

template< typename T = int64 >
vector< T > make_v(size_t a) {
  return vector< T >(a);
}

template< typename T, typename... Ts >
auto make_v(size_t a, Ts... ts) {
  return vector< decltype(make_v< T >(ts...)) >(a, make_v< T >(ts...));
}

template< typename T, typename V >
typename enable_if< is_class< T >::value == 0 >::type fill_v(T &t, const V &v) {
  t = v;
}

template< typename T, typename V >
typename enable_if< is_class< T >::value != 0 >::type fill_v(T &t, const V &v) {
  for(auto &e : t) fill_v(e, v);
}

template< typename F >
struct FixPoint : F {
  FixPoint(F &&f) : F(forward< F >(f)) {}

  template< typename... Args >
  decltype(auto) operator()(Args &&... args) const {
    return F::operator()(*this, forward< Args >(args)...);
  }
};

template< typename F >
inline decltype(auto) MFP(F &&f) {
  return FixPoint< F >{forward< F >(f)};
}


int main() {
  int N;
  cin >> N;
  vector< int64 > A(N);
  cin >> A;

  int64 sum = 0;
  for(int i = 0; i < N; i++) sum += A[i];

  int64 latte = 0, ret = infll;
  for(int i = 0; i < N; i++) {
    latte += A[i];
    int64 malta = sum - latte;
    chmin(ret, abs(latte - malta));
  }
  cout << ret << endl;
}






Measured memory_bytes: 1792
ansli=[]

while 1:
    a=input().split()
    if a[0]=="0" and a[1]=="0" and a[2]=="0":
        break
    for i in range(len(a)):
        a[i]=int(a[i])
    x=[]
    for i in range(a[0]):
        x.append(int(input()))

    sum0=0
    for i in x:
        sum0+=i
    sum=sum0*(100-a[2])
    hit=x[a[1]-1]
    if hit==0:
        ansli.append(0)
    else:
        ansli.append(int(sum/hit))

for i in ansli:
    print(i)



Measured memory_bytes: 5612
#include<iostream>
#include<map>
#include<deque>
#include<algorithm>
#include<string>
using namespace std;
#define REP(i,b,e) for(int i=(int)b;i<(int)e;i++)
#define Rep(i,n) REP(i,0,n)
#define rep(i,n) REP(i,1,n+1)
typedef long long ll;

int A[4];
int main(){
    Rep(i,3) cin>>A[i];
    sort(A,A+3);
    if(A[0]==5&&A[1]==5&&A[2]==7) cout<<"YES"<<endl;
    else cout<<"NO"<<endl;


    return 0;
}

Measured memory_bytes: 256
s = input()
t = input()
Ps = [[] for i in range(26)]
Pt = [[] for i in range(26)]
for i in range(len(s)):
    Ps[ord(s[i])-97] += [i]
for i in range(len(t)):
    Pt[ord(t[i])-97] += [i]
Ps.sort()
Pt.sort()
if Ps == Pt:
    print('Yes')
else:
    print('No')   

Measured memory_bytes: 20656
package main

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

const MaxBuf = 200100
var buf []byte
var sc = bufio.NewScanner(os.Stdin)

func init() {
   sc.Split(bufio.ScanWords)
   sc.Buffer(buf,MaxBuf)
}

func readString() string {
   sc.Scan()
   return sc.Text()
}

func readInt64() int64 {
   sc.Scan()
   r,_ := strconv.ParseInt(sc.Text(),10,64)
   return r
}

func readInt() int {
   sc.Scan()
   r,_ := strconv.Atoi(sc.Text())
   return r
}

type student struct {
	x int
	y int

}

type ss []student

func (s ss) Len() int {	return len(s) }
func (s ss) Less(i,j int) bool {return s[i].x < s[j].x}
func (s ss) Swap(i,j int) {
	s[i].x ,s[j].x = s[j].x ,s[i].x
	s[i].y ,s[j].y = s[j].y ,s[i].y
}


func main() {
	n := readInt()
	a := make([]student,n)
	for i := 1; i <=n ; i++ {
		a[i-1].x = readInt()
		a[i-1].y = i
	}
	as := ss(a)
	sort.Sort(as)

	for i := 0; i < n ; i++ {
		fmt.Printf("%d ",as[i].y)
	} 
	
}

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

int N;
int main(){
	cin>>N;
	REP(i,100){
		REP(j,100){
			if (4*i+7*j==N){
				cout<<"Yes"<<endl;
				return 0;
			}
		}
	}
	cout<<"No"<<endl;
	return 0;
}

Measured memory_bytes: 256
N = gets.to_i
A = Array.new(N,1 << 20)
B = gets.split.map(&:to_i)
B.each_with_index do |b, i|
  A[i] = b if A[i] >= b
  A[i + 1] = b if A[i + 1] >= b 
end
puts A.inject(0, &:+)

Measured memory_bytes: 1788
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<set>
#include<map>
#include<queue>
#define REP(i,a) for (int i = 0;i < (a);++i)
#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 SORT(list) sort(ALL((list)));
#define MOD 1000000007
using namespace std;
using ll = long long;
int main(){
    ll a,b,c;
    cin >> a >> b >> c;
    if(b+1 >= c){
        cout << b+c << endl;
        return 0;
    }
    if(a+b+1>=c){
        cout << b+c << endl;
        return 0;
    }
    cout << b+a+1+b << endl;
    return 0;
}

Measured memory_bytes: 256
n = input()
a=[]
for  i in range(4):
  a.append(int(n[i]))
out=[]
pi=[]
for i in range(2):
  for j in range(2):
    for k in range(2):
      
      if a[0]+(i*2-1)*a[1]+(j*2-1)*a[2]+(k*2-1)*a[3] ==7:

        if i*2-1 ==1:
          pi.append('+')
        else:
          pi.append('-')
        if j*2-1 ==1:
          pi.append('+')
        else:
          pi.append('-')
        if k*2-1 ==1:
          pi.append('+')
        else:
          pi.append('-')
              
        for h in range(3):
          print(a[h],end="")
          print(pi[h],end="")
        print(a[3],end="")
        print('=7')
        exit()  
      else:
        f=0

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int n, m, an, am, k, res = 0;
ll dp[400001], a[200001], b[200001];
int main()
{
    cin.sync_with_stdio(0); cin.tie(0);
    cin >> n >> m >> k;
    for(int i = 1; i <= n; i++){
        cin >> a[i];
        if(i == 1)continue;
        a[i] += a[i-1];
    }
    for(int i = 1; i <= m; i++){
        cin >> b[i];
        if(i == 1)continue;
            b[i] += b[i-1];
    }
    for(int i = 1; i <= n; i++){
        if(a[i] > k)break;
        an = i;
    }
    for(int i = 1; i <= m; i++){
        if(b[i] > k)break;
        am = i;
    }
    int i = 0, j = am;
    while(i <= an && j >= 0){
        if(a[i]+b[j] <= k)res = max(res,i+j);
        else{
            while(j >= 0){
                j--;
                if(a[i]+b[j] <= k){
                    res = max(res, i+j);
                    break;
                }
            }
        }
        i++;
    }
    cout << res << endl;
    return 0;
}


Measured memory_bytes: 6780
#include <iostream>                                             
#include <cstdio>                                               
#include <cmath>                                                
using namespace std;                                            
                                                                
int main() {                                                    
  double a, b, c, d, e, f;                                      
  while (cin >> a >> b >> c >> d >> e >> f) {                   
    double x = (b*f-c*e)/(b*d-a*e);                             
    double y = (c-a*x)/b;                                       
    x = round(1000*x)/1000;                                     
    y = round(1000*y)/1000;                                     
    if (x==0) {                                                 
      x = 0;                                                    
    }                                                           
    if (y==0) {                                                 
      y = 0;                                                    
    }                                                           
    printf("%.3f %.3f\n", x, y);                                
  }                                                             
  return 0;                                                     
}                                                               
                           

Measured memory_bytes: 3244
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#define ALL(x) (x).begin(),(x).end()
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define vi vector<int>
#define vvi vector<vector<int>>
#define vvc vector<vector<char>>
#define vll vector<long long>
#define pii pair<int,int>
#define vpii vector<pair<int,int>>

using namespace std;

int main() {
    int t; cin >> t;
    vi ans(t);

    for (int i = 0; i < t; i++) {
        int N, K; cin >> N >> K;
        int cost = 0;
        vi x(N); rep(j, N) {
            cin >> x[j];
        }
        cost = x[N - 1] - x[0];
        if (N == 1) {
            cost = 0;
            ans[i] = cost;
        }
        else {
            vi diff(N - 1); 
            for (int ti = 1; ti < N; ti++) {
                diff[ti - 1] = x[ti] - x[ti - 1];
            }
            sort(ALL(diff), greater<int>());

            for (int k = 0; k < min(K - 1, N - 1); k++) {
                cost -= diff[k];
            }

            ans[i] = cost;
        }
    }

    for (int elem : ans) {
        cout << elem << endl;
    }
}


Measured memory_bytes: 3676
n,a,b=map(int,input().split())
MOD=10**9+7
def pos(x, n, m):
    if n == 0:
        return 1
    res = pos(x*x%m, n//2, m)
    if n%2 == 1:
        res = res*x%m
    return res

def comb(n,k):
    if n<k:
        return 0
    if n<0 or k<0:
        return 0
    k=min(n-k,k)
    ans=1
    inv=[1]*(k+1)
    if k>=1:
        ans*=(n-k+1)%MOD
    for i in range(2,k+1):
        inv[i]=MOD-inv[MOD%i]*(MOD//i)%MOD
        ans=ans*(n-k+i)*inv[i]%MOD
    return ans

na=comb(n,a)
nb=comb(n,b)

ans=(pos(2,n,MOD)-na-nb-1)%MOD

print(ans)

Measured memory_bytes: 10932
#ifdef DEBUG
#define _GLIBCXX_DEBUG
#endif
#pragma GCC optimize("O3")
#include <bits/stdc++.h>
using namespace std;
typedef long double ld;
typedef long long ll;
const int mod = 998244353;
int sum(int a, int b) {
    int s = a + b;
    if (s >= mod) s -= mod;
    return s;
}
int mult(int a, int b) {
    return (1LL * a * b) % mod;
}
int sub(int a, int b) {
    int s = a - b;
    if (s < 0) s += mod;
    return s;
}
const int maxN = (int)1e6 * 5 + 10;
int fact[maxN], invfact[maxN], inv[maxN];
int n;
int pref[maxN];
int pw2[maxN];
int cnk(int a, int b) {
    if (a < b || b < 0) return 0;
    return mult(fact[a], mult(invfact[a - b], invfact[b]));
}
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    //freopen("input.txt", "r", stdin);
    cin >> n;
    n /= 2;
    fact[0] = invfact[0] = inv[1] = fact[1] = invfact[1] = 1;
    for (int i = 2; i < maxN; i++) {
        inv[i] = mult(mod - mod / i, inv[mod % i]);
        fact[i] = mult(fact[i - 1], i);
        invfact[i] = mult(invfact[i - 1], inv[i]);
    }
    pw2[0] = 1;
    for (int i = 1; i < maxN; i++) pw2[i] = mult(2, pw2[i - 1]);
    for (int i = 0; i <= n; i++) {
        pref[i] = mult(pw2[i], cnk(n, i));
        if (i > 0) pref[i] = sum(pref[i], pref[i - 1]);
    }
    int coef = 1;
    for (int i = 0; i < 2 * n; i++) coef = mult(coef, 3);
    int tot = 0;
    for (int i = 1; i <= n; i++) {
        tot = sum(tot, mult(pref[i - 1], mult(cnk(n, i), pw2[n - i])));
    }
    coef = sub(coef, mult(2, tot));
    cout << coef;
    return 0;
}

Measured memory_bytes: 97920
from collections import deque
h,w = map(int, input().split())
maze = [list(input()) for i in range(h)]
emp = []

#迷路と始点を引数に、最も遠い点までの距離を返す
def bfs(maze, sx, sy):
    d = [[-float("inf")] * w for i in range(h)]

    dx = [1, 0, -1, 0]
    dy = [0, 1, 0, -1]

    que = deque([])
    que.append((sy, sx))
    d[sy][sx] = 0

    while que:
        p = que.popleft()
        # if p[0] == gy and p[1] == gx:
        #     break
        for i in range(4):
            nx = p[0] + dx[i]
            ny = p[1] + dy[i]
            if 0 <= nx < h and 0 <= ny < w and maze[nx][ny] != "#" and d[nx][ny] == -float("inf"):
                que.append((nx, ny))
                d[nx][ny] = d[p[0]][p[1]] + 1
    an = 0
    for i in d:
        an = max(an,max(i))
    return an

# 取りうる全ての始点と終点の最短経路の最大値を求める
ans = 0
for i in range(h):
    for j in range(w):
        if maze[i][j]!="#":
            ans = max(ans, bfs(maze, j, i))

print(ans)


Measured memory_bytes: 3316
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <math.h>
#include <complex>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <unordered_map>
#include <set>
#include <bitset>
#include <functional>
#include <assert.h>
#define int long
#define ll long long
#define rng(i,a,b) for(int i=int(a);i<int(b);i++)
#define rep(i,b) rng(i,0,b)
#define gnr(i,a,b) for(int i=int(b)-1;i>=int(a);i--)
#define per(i,b) gnr(i,0,b)
#define eb emplace_back
#define all(x) x.begin(),x.end()
#define SZ(x) x.size()
#define fi first
#define se second
const int INF = 1e9;
using namespace std;

template<class t> using vc=vector<t>;
template<class t> using vvc=vc<vc<t>>;

using pi=pair<int,int>;
using vi=vc<int>;

int N,M; 
bool edge[51][51];
vi G[55];
bool vis[55];

void dfs(int n){
    if(vis[n]) return;
    vis[n] = true;
    for(int a:G[n]){
        if(edge[n][a]) dfs(a);
    }
}

signed main() {
    cin.tie(0);
    ios::sync_with_stdio(0);
    cout<<fixed<<setprecision(20);

    cin >> N >> M;
    vc<pi> p;
    rep(i,N) rep(j,N) edge[i][j] = false;
    rep(i,M){
        int a,b; cin >> a >> b;
        a--; b--;
        G[a].eb(b);
        G[b].eb(a);
        p.eb(a,b);
        edge[a][b] = true;
        edge[b][a] = true;
    }
    int ans=0;
    rep(i,M){
        pi a = p[i];
        edge[a.fi][a.se] = false;
        edge[a.se][a.fi] = false;
        bool frag = true;
        rep(i,N) vis[i] = false;
        dfs(0);
        rep(i,N) {
            if(!vis[i]) frag=false;
        }
        if(!frag) ans++;
        edge[a.fi][a.se] = true;
        edge[a.se][a.fi] = true;
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
using P = pair<ll, ll>;
#define rep(i, n)  for (int i = 0; i <  (int)(n); i++)
#define rep1(i, n) for (int i = 1; i <= (int)(n); i++)
#define all(x) (x).begin(), (x).end()
const ll INF = ll(1e18)+1;

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

    ll h,w,k;
    cin >> h >> w >> k;
    vector<vector<char>> cij(h,vector<char>(w));
    rep(i,h)rep(j,w){
        cin >> cij[i][j];
    }

    ll result = 0;
    rep(i,pow(2,w)+1){
        // cout << "i=" << i << "\n";
        vector<ll> temp_vec(h,0);
        rep(j,w){
            if(bitset<64>(i)[j]){
                rep(k,h){
                    if(cij[k][j] == *"#"){
                        temp_vec[k]++;
                    }
                }
            }
        }

        // rep(j,h) cout << temp_vec[j];
        // cout << "\n";
        
        rep(j,pow(2,h)+1){
            ll temp = 0;
            rep(k,h){
                if(bitset<64>(j)[k]){
                    temp += temp_vec[k];
                }
            }
            if(temp == k) result++;
        }
    }

    cout << result;
}

Measured memory_bytes: 4092
#include <bits/stdc++.h>
 
using namespace std;
 
int scanint() { 
	register char c = getchar_unlocked();
	int x = 0;
	for(; (c<48)||(c>57);c = getchar_unlocked());
	for(; (c>47)&&(c<58);c = getchar_unlocked())
		x = 10 * x + c - 48;
    return x;
} 
 
int main() {
 
    cin.tie(0);
    ios::sync_with_stdio(false);
 
    constexpr int A_MAX = 1000000;
 
    vector<int> min_factor(A_MAX);
    // q[n] = i where n = i * p^e, p = min_factor[n], p does not divide i. + 1);
    vector<int> q(A_MAX + 1, 1);
    vector<int> primes;
    for (int i = 2; i <= A_MAX; ++i) {
        min_factor[i] = i;
    }
    for (int i = 2; i <= A_MAX; ++i) {
        if (min_factor[i] == i) {
            primes.push_back(i);
        }
        for (int p : primes) {
            int n = i * p;
            if (n > A_MAX) {
                break;
            }
            min_factor[n] = p;
            if (p == min_factor[i]) {
                q[n] = q[i];
                break;
            } else {
                q[n] = i;
            }
        }
    }
 
    int N = scanint();
    vector<int> a(A_MAX + 1);
    for (int i = 0; i < N; ++i) {
        ++a[scanint()];
    }
 
    bool is_pairwise_coprime = true;
    for (int n = A_MAX; n > 1; --n) {
        if (a[n] > 1) {
            if (a[n] == N) {
                cout << "not coprime" << endl;
                return 0;
            }
            is_pairwise_coprime = false;
        }
        a[min_factor[n]] += a[n];
        a[q[n]] += a[n];
    }
    if (is_pairwise_coprime) {
        cout << "pairwise coprime" << endl;
    } else {
        cout << "setwise coprime" << endl;
    }
 
    return 0;
}

Measured memory_bytes: 15532
#include <bits/stdc++.h>
using namespace std;
 
#define rep(i, n) for(int i = 0; i < n; i++)
#define repr(i, n) for(int i = n;i >= 0;i--)
 
int main() {
  int n, m;
  cin >> n >> m;
  cout << (n-1) * (m-1) << endl;
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define REP(i,n) for(int i=0;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 ALL(a) a.begin(),a.end()
typedef long long ll;
#define INF 1<<30

int main()
{
    int A,B,C,K;
    cin >> A >> B >> C >> K;
    REP(i,K){
        if(A>=B)B *= 2;
        else C *= 2;
    }
    //cout << A << B << C << endl;
    if(A<B&&B<C)cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0;
}

Measured memory_bytes: 3632
import java.util.*;

class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
	int n = Integer.parseInt(sc.next());
    String s = sc.next();
    
    if (n < 3200) {
      System.out.println("red");
      return;
    } else {
      System.out.println(s);
      return;
    }
  }
}


Measured memory_bytes: 21712
/*input
0 5 1
*/
#include <bits/stdc++.h>
#pragma GCC optimize("unroll-loops,no-stack-protector")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef pair<double,double> pdd;
#define IOS ios_base::sync_with_stdio(0); cin.tie(0)
#define ALL(a) a.begin(),a.end()
#define SZ(a) ((int)a.size())
#define F first
#define S second
#define REP(i,n) for(int i=0;i<((int)n);i++)
#define pb push_back
#define MP(a,b) make_pair(a,b)
#define SORT_UNIQUE(c) (sort(c.begin(),c.end()), c.resize(distance(c.begin(),unique(c.begin(),c.end()))))
#define GET_POS(c,x) (lower_bound(c.begin(),c.end(),x)-c.begin())
template<typename T1,typename T2>
ostream& operator<<(ostream& out,pair<T1,T2> P){
	out<<'('<<P.F<<','<<P.S<<')';
	return out;
}

//}}}
const ll maxn=300005;
const ll maxlg=__lg(maxn)+2;
const ll INF64=8000000000000000000LL;
const int INF=0x3f3f3f3f;
const ll MOD=ll(1e9+7);
const double PI=acos(-1);
//const ll p=880301;
//const ll P=31;

ll mypow(ll a,ll b){
	ll res=1LL;
	while(b){
		if(b&1) res=res*a%MOD;
		a=a*a%MOD;
		
		b>>=1;
	}
	return res;
}
int main()
{
	IOS;
	ll a,b,x;
	cin>>a>>b>>x;
	cout<<b/x-(a-1)/x+(a==0&&x!=1);
	return 0;
}


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

using namespace std;

int main() {
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	int N;
	cin >> N;
	long long ans = 0;
	for (int i = 1; i <= N; i++){
		if(i % 15 == 0){
			continue;
		}else if(i % 5 == 0){
			continue;
		}else if(i % 3 == 0){
			continue;
		}else{
			ans += i;
		}
	}

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 3668
#include <iostream>
#include <cmath>
#include <iomanip>
using namespace std;
#define EPS 1e-4
#define PI 3.14159265358979

struct Point{double x, y;};

void koch(int d, Point p1, Point p2){
  if(d == 0) return;
  Point s, u, t;
  double th = PI * 60.0 / 180.0;

  s.x = (2.0 * p1.x + 1.0 * p2.x) / 3.0;
  s.y = (2.0 * p1.y + 1.0 * p2.y) / 3.0;
  t.x = (1.0 * p1.x + 2.0 * p2.x) / 3.0;
  t.y = (1.0 * p1.y + 2.0 * p2.y) / 3.0;
  
  u.x = (t.x - s.x) * cos(th) - (t.y - s.y) * sin(th) + s.x;
  u.y = (t.x - s.x) * sin(th) + (t.y - s.y) * cos(th) + s.y;

  koch(d-1, p1, s);
  cout << fixed << setprecision(8) << s.x << " " << s.y << endl;
  koch(d-1, s, u);
  cout << fixed << setprecision(8) << u.x << " " << u.y << endl;
  koch(d-1, u, t);
  cout << fixed << setprecision(8) << t.x << " " << t.y << endl;
  koch(d-1, t, p2);
}

int main(void){
  int n;
  cin >> n;
  
  Point p1, p2;
  p1.x = 0.0; p1.y = 0.0;
  p2.x = 100.0; p2.y = 0.0;

  cout << fixed << setprecision(8) << p1.x << " " << p1.y << endl;
  koch(n, p1, p2);
  cout << fixed << setprecision(8) << p2.x << " " << p2.y << endl;
  
  return 0;
}

Measured memory_bytes: 1248
#include<bits/stdc++.h>
using namespace std;
#define arep(i,x,n) for(int i=int(x);i<(int)(n);i++)
#define rep(i,n) for(long long i = 0;i < n;++i)
#define rrep(i,n) for(int i=int(n);i>0;i--)
#define fs first
#define sc second
#define all(x) (x).begin(), (x).end()
#define pi 3.141592653589793
#define eps 0.00000001
#define INF 1e9+5  
using ll = long long; 
using P=pair<int,int>;
using lP=pair<ll,ll>;
using fP=pair<double,double>;
using PPI=pair<P,int>;
//ll const mod=998244353;
ll const mod=1e9+7;
const ll MAX=1000005;
using vi=vector<int>;
using vl=vector<ll>;
using vc=vector<char>;
using vd=vector<double>;
using vs=vector<string>;
using vp=vector<P>;
using vb=vector<bool>;
using vvi =vector<vector<int>>;
using vvl =vector<vector<ll>>;
using vvd=vector<vector<double>>;
using vvc=vector<vector<char>>;
using vvp =vector<vector<P>>;
using vvb=vector<vector<bool>>;
template <typename T>
bool chmax(T &a, const T b){if(a < b){a = b; return true;} return false;}
template <typename T>
bool chmin(T &a, const T b){if(a > b){a = b; return true;} return false;}


//////////////////////////////////////
int main(){
    ll n;
    cin>>n;
    n--;
    ll index=1;
    ll tmp=n;
    vc ans;
    int cnt=1;
    while(1){
        index*=26;
        
        if(tmp-index>=0){
            tmp-=index;
            cnt++;
        }
        else{
            index/=26;
            break;
        }
    }
    rep(i,cnt){
        int a=tmp/index;
        ans.push_back('a'+a);
        
        tmp-=a*index;
        index/=26;
    }
    rep(i,cnt)cout<<ans[i];
    cout<<endl;
    return 0;
}

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

#define FOR(i, a, b) for(int i = (a); i < (b); ++i)
#define REP(i, n) for(int i = 0; i < (n); ++i)
#define REPr(i, n) for(int i = (n)-1; i >= 0; --i)
#define FORq(i, m, n) for(int i = (m); i <= (n); ++i)
#define FORqr(i, m, n) for(int i = (n); i >= (m); --i)
#define MP make_pair
#define SIN(x, S) (S.count(x) != 0)
#define M0(x) memset(x, 0, sizeof(x))
#define FILL(x, y) memset(x, y, sizeof(x))
#define MM(x) memset(x, -1, sizeof(x))
#define ALL(x) (x).begin(), (x).end()
#define DB(x) cerr << #x << " = " << x << endl
#define DB2(x, y)                                                              \
    cerr << "(" << #x << ", " << #y << ") = (" << x << ", " << y << ")\n";
#define DEBUG                                                                  \
    int x12345;                                                                \
    cin >> x12345;
typedef pair<int, int> PII;
typedef pair<long long, long long> PLL;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<long long> VL;
typedef long long ll;
typedef long long integer;
const long long MOD = 1e9 + 7;
///////////////////////////////////////////////
// for template
template <class T> inline bool chmin(T &a, T b) {
    if(a > b) {
        a = b;
        return true;
    }
    return false;
}
template <class T> inline bool chmax(T &a, T b) {
    if(a < b) {
        a = b;
        return true;
    }
    return false;
}
///////////////////////////////////////////////
/// 🍈( '-' 🍈 |AC|
int main() {
    int N;
    cin >> N;
    vector<ll> A(N);
    REP(i,N){
        cin >> A[i];
    }
    ll ans = 0;
    REP(i,N){
        if (i == 0) continue;
        if (A[i - 1] <= A[i]) continue;
        ans += A[i - 1] - A[i];
        A[i] = A[i - 1];
    }
    cout << ans << endl;
}

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

int32_t main(){
	// freopen("input.txt", "r", stdin);
	// freopen("output.txt", "w", stdout);
	ios::sync_with_stdio(0),cin.tie(0);
	int n;
	cin >> n;
	int f[10][10];
	memset(f,0,sizeof f);
	for(int i=1;i<=n;i++){
		int a=i%10,b=i;
		while(b>9)b/=10;
		f[a][b]++;
	}
	int ans=0;
	for(int i=1;i<10;i++){
		for(int j=1;j<10;j++){
			ans+=f[i][j]*f[j][i];
		}
	}
	cout << ans;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int H, W;
  cin >> H >> W;
  vector<vector<char>> matrix(H, vector<char>(W));
  for (int i = 0; i < H; i++){
    string s;
    cin >> s;
    for (int j = 0; j < W; j++){
      matrix.at(i).at(j) = s.at(j);
    }
  }
  
  bool a = true;
  
  for (int i = 0; i < H; i++){
    for (int j = 0; j < W; j++){
      if (matrix.at(i).at(j) == '#'){
        a = false;
      }
    }
    if (a){
      for (int j = 0; j < W; j++){
        matrix.at(i).at(j) = '\0';
      }
    }
    a = true;
  }
  
  for (int j = 0; j < W; j++){
    for (int i = 0; i < H; i++){
      if (matrix.at(i).at(j) == '#'){
        a = false;
      }
    }
    if (a){
      for (int i = 0; i < H; i++){
        matrix.at(i).at(j) = '\0';
      }
    }
    a = true;
  }
  
  bool b = false;
  
  for (int i = 0; i < H; i++){
    for (int j = 0; j < W; j++){
      if (matrix.at(i).at(j) == '.' || matrix.at(i).at(j) == '#'){
        cout << matrix.at(i).at(j);
      }
      if (matrix.at(i).at(j) == '.' || matrix.at(i).at(j) == '#'){
        b = true;
      }
    }
    if (b){
      cout << endl;
    }
  }
}

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

using namespace std;

typedef long long int ll;

const ll MAXN = 1e5 + 5;

vector < ll > parent(MAXN), sz(MAXN);

void make_set(ll u){
  parent[u] = u;
  sz[u] = 1;
}

ll find_set(ll u){
  if(u == parent[u]) return u;
  return parent[u] = find_set(parent[u]);
}

void union_sets(ll u, ll v){
  u = find_set(u);
  v = find_set(v);
  if(u != v){
    if(sz[u] > sz[v]) swap(u, v);
    parent[u] = v;
    sz[v] += sz[u];
  }
}

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

  ll n, m;
  cin >> n >> m;
  vector < ll > a(m), b(m);
  for(int i = 0; i < m; i++) cin >> a[i] >> b[i];

  for(int i = 1; i <= n; i++) make_set(i);

  ll c = (n * (n - 1)) / 2, cnt = 0;
  vector < ll > ans(m);
  ans[m - 1] = c;
  for(int i = m - 1; i >= 0; i--){
    if(find_set(a[i]) != find_set(b[i])){
      ll sza = sz[find_set(a[i])], szb = sz[find_set(b[i])];
      cnt += sza * szb;
    }
    union_sets(a[i], b[i]);
    if(i != 0) ans[i - 1] = c - cnt;
  }

  for(int i = 0; i < m; i++) cout << ans[i] << '\n';
}


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

int main()
{
  int N;
  int V[20] = {0};
  int C[20] = {0};
  int result = 0;

  cin >> N;
  for (int i = 0; i < N; i++) {
    cin >> V[i];
  }
  for (int i = 0; i < N; i++) {
    cin >> C[i];
  }
  
  for (int i = 0; i < N; i++) {
    if (V[i] > C[i]) {
      result += V[i] - C[i];
    }
  }
  
  cout << result << endl;
  
  return 0;
}

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

#define INF 1001001001
#define LINF 1001001001001001001
#define MOD 1000000007
#define MOD2 998244353

#define all(a)  (a).begin(),(a).end()
#define dig(n)  to_string(n).length()

#define pb push_back
#define eb emplace_back
#define mkp make_pair

#define se second
#define fi first

#define rep(i,n) for(int i=0,_i=(n);i<_i;++i)
#define rep1(i,a,b) for(int a_=(a),b_=(b),i=a_;i<b_;++i)
#define repr(i,n) for(int _i=(n),i=_i;i>0;--i)

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

int main(){

    bool flag=false;
    ll ans=0,sum=0;

    string s;
    cin >>s;
    int n=s.length();

    int a=0;
    rep(i,n){
        if(s[i] == 'A')++a;
        else if(i+1<n && s[i]=='B' && s[i+1]=='C'){
            ans += a;
            ++i;
        }else a=0;
    }

    //cout <<fixed<<setprecision(16)<< << endl;
    cout << ans << endl;

    //if(flag)cout << "Yes" <<endl;
    //else cout << "No" <<endl;
    return 0;
}

// A BC A  CCB  A BC BC A A BC  B

// BC CCB BC BC BC  A A A A A  B




Measured memory_bytes: 640
#include <stdio.h>
#include <string.h>
#include <limits.h>
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <map>
#include <set>

#ifndef U_L_LONG
typedef unsigned long long U_L_LONG;
#endif
#ifndef L_LONG
typedef long long L_LONG;
#endif


static void ABC108C_TriangularRelationship();

#if 1
int main()
{
	ABC108C_TriangularRelationship();

	fflush(stdout);
	return 0;
}
#endif

static void ABC108C_TriangularRelationship()
{
	//	けんちょん先輩のブログはさすがです
	//	http://drken1215.hatenablog.com/entry/2018/09/02/011000
	int N, K;
	scanf(" %d %d", &N, &K);

	std::vector<long long> num(K, 0);
	for (int i = 1; i <= N; ++i) {
		num[i % K]++; // num[x] = kで割ってxあまる数が1以上N以下に何個あるか
	}
	L_LONG res = 0;
	for (int a = 0; a < K; a++) {
		int b = (K - a) % K;
		int c = (K - a) % K;
		if ((b + c) % K != 0) {
			continue;
		}
		res += num[a] * num[b] * num[c];
	}
	std::cout << res << std::endl;
}


Measured memory_bytes: 1792
#include <fstream>
#include <iostream>
#include <string>
#include <complex>
#include <math.h>
#include <set>
#include <vector>
#include <map>
#include <queue>
#include <stdio.h>
#include <stack>
#include <algorithm>
#include <iomanip>
#include <list>
#include <ctime>
#include <memory.h>
#include <bitset>
#include <climits>
#include <iostream>
#include <stdlib.h>

#define F first
#define S second
#define endl "\n"
#define pb push_back
#define mp make_pair
#define bs 1000000007
#define pi 3.141592653589793
#define y1 kjdfshnvoavaofobiopj
using namespace std;

string st;
int n, found[30];
bool error;

int main(){
//freopen("input.txt", "r", stdin);
ios_base::sync_with_stdio(0);
cin.tie(0);

cin>>st;
n = st.size();
for(int i = 0; i < n; i++)
	++found[st[i]-97];
for(int i = 0; i < 30; i++)
	if(found[i]&1)
		error = true;
if(!error)
	cout<<"Yes"<<endl;
else
	cout<<"No"<<endl;

return 0;}


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

int main() {
  string s;
  cin >> s;

  string a,b;
  for(int i = 0; i < s.size(); i++) {
    if(i & 1) {
      a += '1';
      b += '0';
    }
    else {
      a += '0';
      b += '1';
    }
  }

  int ans1 = 0;
  int ans2 = 0;
  for(int i = 0; i < s.size(); i++) {
    if(s[i] != a[i]) ans1++;
    if(s[i] != b[i]) ans2++;
  }

  cout << min(ans1,ans2) << endl;
}


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

using namespace std;

struct A {
    long long a, b;
    bool operator < (const A &x) const { return b < x.b; }
} a[200005];
long long n, zeit;
bool flag = true;

int main(void)
{
    scanf("%lld", &n);
    for (int i = 1; i <= n; ++i)
        scanf("%lld%lld", &a[i].a, &a[i].b);
    sort(a + 1, a + 1 + n);
    for (int i = 1; i <= n; ++i) {
        zeit += a[i].a;
        if (zeit > a[i].b) flag = false;
    }
    if (flag) printf("Yes\n");
    else printf("No\n");
    return 0;
}

Measured memory_bytes: 3328
#include<bits/stdc++.h>
using namespace std;
int main(){
  int N;
  int sum=0;
  cin>>N;
  for(int i=0;i<N;i++){
    int l,r;
    cin>>l>>r;
    sum=sum+r-l+1;
  }
  cout<<sum<<endl;
}

Measured memory_bytes: 256
N = int(input())
h_s = list(map(int,input().split()))
INF = 10^3
dp = [INF]*N

dp[0] = 0
dp[1] = abs(h_s[1] - h_s[0]) + dp[0]
for i in range(2,len(h_s)):
    dp[i] = min((dp[i-1] + abs(h_s[i] - h_s[i-1])),(dp[i-2] + abs(h_s[i] - h_s[i-2])))
print(dp[N-1])

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

using namespace std;

int main(){
    int N;
    while(cin >> N){
        vector<int> A(N);
        for(int i=0;i<N;i++){
            cin >> A[i];
            A[i] -= i+1;
        }
        sort(A.begin(), A.end());
        int b = A[N/2];
        long long res = 0;
        for(auto& t : A) res += abs(t-b);
        cout << res << endl;
    }
}

Measured memory_bytes: 1024
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {

        Scanner sc = new Scanner(System.in);
        int A =  sc.nextInt();
        int B =  sc.nextInt();
        int K = sc.nextInt();

        for (int i = 0; i < K; i++) {
            int watasu=0;
            if(i %2 ==0){
                if(A%2==0){
                    watasu = A/2;
                }else{
                    A--;
                    watasu = A/2;
                }
                A -= watasu;
                B += watasu;
            }else{
                if(B%2==0){
                    watasu = B/2;
                }else{
                    B--;
                    watasu = B/2;
                }
                watasu = B/2;
                A += watasu;
                B -= watasu;
            }

        }

        System.out.println(A +" "+B );

    }
}


Measured memory_bytes: 21588
import math
a, b, x = map(int, input().split())
# = int(input())
# = input()
# = list(map(int, input().split()))

if x > (a**2)*b/2:
	print(math.degrees(math.atan((2*((a**2)*b-x))/(a**3))))
else:
	print(math.degrees(math.atan(a*(b**2)/(2*x))))


Measured memory_bytes: 3060
#include <iostream>
typedef long long ll;
using namespace std;

ll dp[105][100005];
int n,W;
ll w[105];
ll v[105];
int main() {
  cin >> n >> W;
  for(int i = 0; i < n; i++) cin >> w[i] >> v[i];
  
  for(int i = 0; i <= n; i++) {
    fill(dp[i],dp[i] + W + 1,-1);
  }

  dp[0][0] = 0;
  if(w[0] <= W) dp[0][w[0]] = v[0];

  for(int i = 1; i < n; i++) {
    for(int j = 0; j <= W; j++) {
      if(dp[i-1][j] == -1) continue;
      dp[i][j] = max(dp[i][j],dp[i-1][j]);
      if(j + w[i] <= W) {
	dp[i][j+w[i]] = max(dp[i][j+w[i]],dp[i-1][j] + v[i]);
      }
    }
  }

  ll ans = 0;
  for(int i = 0; i <= W; i++) {
    ans = max(ans,dp[n-1][i]);
  }

  cout << ans << endl;
}

  


Measured memory_bytes: 80128
#include<iostream>
#include<vector>
#include<array>
using namespace std;

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

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

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

const long long INF = 1LL << 60;

const int SIZE = 100010;

array<ll, SIZE> h;
array<ll, SIZE> dp;

ll rec(const int& i) {
    if (dp[i] < INF) {
        return dp[i];
    }

    if (i == 0) return 0;

    ll res = INF;
    chmin(res, rec(i-1) + abs(h[i] - h[i-1]));
    if (i > 1) {
        chmin(res, rec(i-2) + abs(h[i] - h[i-2]));
    }

    return dp[i] = res;
}

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

    rep(i, n) {
        cin >> h[i];
    }

    rep(i, n) {
        dp[i] = INF;
    }

    dp[0] = 0;

    cout << rec(n - 1) << endl;

    return 0;
}

Measured memory_bytes: 6528
#include<iostream>
#include<algorithm>
#include<functional>
#include<cmath>
#include<string>
#include<vector>
using namespace std;
const int mod = 1000000007;
#define ll long long

int main()
{
	int D; cin >> D;
	cout << "Christmas";
	while (D < 25) {
		cout << " Eve";
		D++;
	}
	cout << endl;
}

Measured memory_bytes: 256
#include<stdio.h>

int main(){
  int n, array[100], i, j, tmp, min, count=0;
  scanf("%d", &n);
  for(i=0;i<=n-1;i++)scanf("%d",&array[i]);
  for(i=0;i<=n-1;i++){
    min = i;
    for(j=i;j<=n-1;j++)if(array[j]<array[min])min=j;
    if(min!=i){
      tmp = array[i];
      array[i] = array[min];
      array[min] = tmp;
      count++;
    }
  }
  for(i=0;i<=n-1;i++){
    if(i>=1)printf(" ");
    printf("%d", array[i]);
  }
  printf("\n");
  printf("%d\n", count);
  return 0;
}

Measured memory_bytes: 1032
#include "bits/stdc++.h"
using namespace std;


int main() {
	long n;
	string str;
	cin >> n >> str;
	int min = 300001;
	int* wcounter = new int[n];
	int* ecounter = new int[n];

	int wcount = 0;
	int ecount = 0;

	for (int i = 0; i < str.size(); i++) {
		if (str[i] == 'W')
			wcount++;
		wcounter[i] = wcount;
	}
	for (int i = str.size() - 1; 0 <= i; i--) {
		if (str[i] == 'E')
			ecount++;
		ecounter[i] = ecount;
	}

	for (int i = 0; i < str.size(); i++) {
		int count = wcounter[i] + ecounter[i] - 1;
		if (count < min)
			min = count;
	}
	
	cout << min << endl;
	return 0;
}

Measured memory_bytes: 3076
#include<stdio.h>

int main(void) {
int N;
scanf("%d", &N);
long long int A[N];
for (int i = 0; i < N; i++) {
scanf("%lld", &A[i]);
}

int i = 0;
while (i < 30) {
int j = 0;
int flag = 0;
while (j < N) {
if (A[j]%2 != 0) {
 flag = 1;
}
A[j] = A[j]/2;
j++;
}
if (flag == 1) break;
i++;
}

printf("%d", i);

 return 0;
}

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

#define rep(i,x,y) for(int i=(x);i<(y);++i)
#define debug(x) #x << "=" << (x)

#ifdef DEBUG
#define _GLIBCXX_DEBUG
#define print(x) std::cerr << debug(x) << " (L:" << __LINE__ << ")" << std::endl
#else
#define print(x)
#endif

const int inf=1e9;
const int64_t inf64=1e18;
const double eps=1e-9;

template <typename T> ostream &operator<<(ostream &os, const vector<T> &vec){
    os << "[";
    for (const auto &v : vec) {
    	os << v << ",";
    }
    os << "]";
    return os;
}

void solve(int p,int q){
    vector<string> a(p),b(q);
    rep(i,0,p) cin >> a[i];
    rep(i,0,q) cin >> b[i];
    vector<vector<int>> correct;
    rep(r,1,21){
        rep(c,1,21){
            rep(s,1,21){
                vector<int> count={0,0,0};
                bool ok=true;
                rep(i,0,p){
                    rep(j,0,a[i].size()){
                        if(a[i][j]!='.'){
                            if(j!=count[0]*r+count[1]*c+count[2]*s) ok=false;
                            break;                       
                        }
                    }
                    if(!ok) break;
                    rep(j,0,a[i].size()){
                        if(a[i][j]=='(') ++count[0];
                        if(a[i][j]=='{') ++count[1];
                        if(a[i][j]=='[') ++count[2];
                        
                        if(a[i][j]==')') --count[0];
                        if(a[i][j]=='}') --count[1];
                        if(a[i][j]==']') --count[2];                                 
                    }
                }
                if(ok) correct.push_back({r,c,s});
            }
        }
    }
    
    vector<int> count={0,0,0};
    rep(i,0,q){
        int indent;
        set<int> st;
        rep(j,0,correct.size()){
            int tmp=0;
            rep(k,0,3) tmp+=correct[j][k]*count[k];
            indent=tmp;
            st.insert(tmp);
        }
        
        if(st.size()>=2) cout << -1;
        else cout << indent;
        
        if(i!=q-1) cout << " ";
        else cout << endl;
        
        rep(j,0,b[i].size()){
            if(b[i][j]=='(') ++count[0];
            if(b[i][j]=='{') ++count[1];
            if(b[i][j]=='[') ++count[2];
            
            if(b[i][j]==')') --count[0];
            if(b[i][j]=='}') --count[1];
            if(b[i][j]==']') --count[2];                                 
        }
    }
}

int main(){
    std::cin.tie(0);
    std::ios::sync_with_stdio(false);
    cout.setf(ios::fixed);
    cout.precision(10);
    for(;;){
        int p,q;
        cin >> p >> q;
        if(!p and !q) break;
        solve(p,q);
    }
    return 0;
}

Measured memory_bytes: 3476
using System;
using System.Collections.Generic;
using System.Linq;

namespace ConsoleApplication1
{
  class Program
  {
    static void Main(string[] args)
    {
      List<int> mountains = new List<int>();
      foreach(var i in Enumerable.Range(0, 10))
      {
        mountains.Add(int.Parse(Console.ReadLine()));
      }
      mountains.Sort();
      Console.WriteLine(mountains[9]);
      Console.WriteLine(mountains[8]);
      Console.WriteLine(mountains[7]);
    }
  }
}

Measured memory_bytes: 9516
c=[list(map(int,input().split())) for _ in range(3)]
for i in range(3):
  for j in range(3):
    if c[i][j]!=c[i][(j+1)%3]+c[(i+1)%3][j]-c[(i+1)%3][(j+1)%3]:
      print('No')
      exit()
print('Yes')

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

const int INF = 1000;

int main() {
  double n, t, a;
  cin >> n >> t >> a;
  vector<double> h(n);
  for (int i = 0; i < n; i++)
    cin >> h.at(i);
  
  double near = INF;
  int res = 0;
  for (int i = 0; i < n; i++) {
    double avg = t - h.at(i) * 0.006;
    
    double gap = abs(avg - a);
    
    if (gap < near) {
      near = gap;
      res = i + 1;
    }
  }
  
  cout << res << endl;
  
  return 0;
}  
  

Measured memory_bytes: 256
/**/
#include<bits/stdc++.h>
using namespace std;
int a,b,c[10001],ans;
int main(){
	ios::sync_with_stdio(false);
	cin>>a>>b;
	for(int i=0;i<a;i++){
		cin>>c[i];
	}
	sort(c,c+a);
	for(int i=a-1;i>=a-b;i--){
		ans+=c[i];
	}
	cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
using namespace std;
  
int main(void){
   string s,p;
   cin >> s >> p;
        
   string ans = "No";
   for(int i = 0; i < (int)s.length(); i++){
       bool flag=true;
       for(int j = 0; j < (int)p.length(); j++){
           if(s[(i+j)%(int)s.length()] != p[j]){
               flag = false;
               break;
           }
       }
       if(flag){
           ans = "Yes";
           break;
       }
   }
   cout << ans << endl;
}


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

using namespace std;

typedef long long ll;

const int N = (1 << 17) + 10;
const int mod = 1e9 + 7;

int n, x, y, z, ans;
int lim, Haiku, dp[45][N];

ll PowMod(ll a, ll b) {
	ll res = 1 % mod;
	while(b) {
		if(b & 1) res = res * a % mod;
		a = a * a % mod;
		b >>= 1;
	}
	return res;
}

int main() {
	cin >> n >> x >> y >> z;
	dp[0][0] = 1; lim = (1 << (x + y + z)) - 1;
	Haiku = (1 << (x - 1)) + (1 << (x + y - 1)) + (1 << (x + y + z - 1));
	// cout << n << " " << lim << endl;
	for(int i = 1;i <= n; ++i) {
		for(int S = 0;S <= lim; ++S) {
			if(!dp[i - 1][S]) continue;
			for(int j = 1;j <= 10; ++j) {
				int T = (((S << j) | (1 << (j - 1)))) & lim;
				if((T & Haiku) == Haiku) continue;
				dp[i][T] += dp[i - 1][S];
				dp[i][T] %= mod;
			}
		}
	}
	for(int i = 0;i <= lim; ++i) 
		ans = (ans + dp[n][i]) % mod;
	ans = (PowMod(10, n) - ans + mod) % mod;
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 22264
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();
    
    int num = b-a;
    int sum = 0;
    
    for(int i = 1 ; i < num+1 ; ++i){
      sum += i;
    }
    
    int ans = sum - b;
    System.out.println(ans);

  }
}


Measured memory_bytes: 35740
#include <iostream>

int main(int argc, char *argv[]){
    unsigned int L,R;
    unsigned int divisor = 2019;
    std::cin >> L >> R;
    unsigned int modMin;
    if(R-L > divisor){
        modMin = 0;
    }else{
        unsigned int i,j;
        unsigned int modTmpI,modTmpJ,modTmp;
        for(i=L;i<R;++i){
            modTmpI = i%divisor;
            for(j=R;j>i;--j){
                modTmpJ = j%divisor;
                modTmp = (modTmpI*modTmpJ)%divisor;
                if((i==L && j==R) || modTmp<modMin){
                    modMin = modTmp;
                }
            }
        }
    }

    std::cout << modMin << std::endl;

    return 0;
}

Measured memory_bytes: 256
var input = require("fs").readFileSync("/dev/stdin", "utf8").trim().split("\n");
var obj = {
  "list" : input,
  "index" : 0,
  "max" : input.length,
  "next" : function(){
    if(!this.hasNext()){throw "NoSuchElementException:次に要素は無いよ";}
    var returnObj = this.list[this.index];
    this.index++;
    return returnObj;
  },
  "hasNext" : function(){return (this.index < this.max);}
}
Main();
function next(){return obj.next();}
function hasNext(){return obj.hasNext();}
function myout(t){console.log(t);}//standard output
function myerr(t){console.error(t);}//standard error
//[no]要素の扱い。数値型
//不明値、異常時:引数そのまま返す
//1:数値へ変換 2:半角SPで分割 4:半角SPで分割し、数値配列へ
//6:1文字に分割 7:1文字に分割し、数値配列へ
//8:半角SPで結合 9:改行で結合 0:文字なしで結合
function myconv(i,no){try{switch(no){case 1:return parseInt(i);case 2:return i.split(" ");case 4:return i.split(" ").map((a)=>Number(a));case 6:return i.split("");case 7:return i.split("").map((a)=>Number(a));case 8:return i.join(" ");case 9:return i.join("\n");case 0:return i.join("");default:return i;}}catch(e){return i;}}
function Main(){
  var N = myconv(next(),1);
  var list = myconv(next(),4);
  //0がある、またはマイナスの個数が偶数個なら、マイナス全消しできる。
  //そうでないなら、要素中、絶対値が一番小さいやつにマイナスがつき、他はプラス
  if(list.indexOf(0) != -1){
     var output = 0;
     for(var i = 0; i < N; i++){
       output += Math.abs(list[i]);
     }
     myout(output);
  }else{
    var min = 1000000007;
    var minIndex = 0;
    var minusCount = 0;
    var output = 0;
    for(var i = 0; i < N; i++){
      output += Math.abs(list[i]);
      if(list[i] < 0){
         minusCount++;
      }
      if(min > Math.abs(list[i])){
         min = Math.abs(list[i]);
        minIndex = i;
      }
    }
    if(minusCount % 2 == 1){
       output -= (min * 2);
    }
    myout(output);
  }
}

Measured memory_bytes: 29672
#include<iostream>
#include<algorithm>
using namespace std;
typedef long long ll;

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

    ll ans = 1e18;
    for(ll i=1; i*i<=n; i++){
        if(n%i != 0) continue;
        ll j = n/i;
        ans = min(ans, i+j-2);
    }
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256