akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define int long long

typedef long long ll;
typedef unsigned long long ull;
typedef unsigned __int128 HASH;
typedef pair<int,int> pii;
typedef pair<ll, ll> pll;
typedef pair<ull, ull> pullull;
typedef pair<ll,int> plli;
typedef pair<double, int> pdbi;
typedef pair<int,pii> pipii;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<vi> vvi;
typedef vector<vvi> vvvi;
typedef vector<pii> vpii;
typedef vector<vector<int>> mat;

#define rep(i,n) for (int i=0;i<(n);i++)
#define rep2(i,a,b) for (int i=(a);i<(b);i++)
#define rrep(i,n) for (int i=(n);i>0;i--)
#define rrep2(i,a,b) for (int i=(a);i>b;i--)
#define pb push_back
#define fi first
#define se second
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()

const ll hmod1 = 999999937;
const ll hmod2 = 1000000000 + 9;
const ll INF = 1<<30;
const ll mod = 1000000000 + 7;
const int dx4[4] = {1, 0, -1, 0};
const int dy4[4] = {0, 1, 0, -1};
const int dx8[8] = {1, 1, 1, 0, 0, -1, -1, -1};
const int dy8[8] = {0, 1, -1, 1, -1, 0, 1, -1};
const double pi = 3.141592653589793;

#define addm(X, Y) ((X) = ((X) + (Y) % mod) % mod)

int n;
int a[100000 + 5];
int diff[100000 + 5];

signed main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    cin >> n;
    ll su = 0;
    int mn = 1e9;
    int mx = 0;
    rep(i, n) {
        cin >> a[i];
        su += a[i];
        mn = min(mn, a[i]);
        mx = max(mx, a[i]);
    }
    if (su % (n * (n + 1) / 2) != 0) {
        cout << "NO" << endl;
        return 0;
    }
    int m = su / (n * (n + 1) / 2);
    if (mn < m || n * m < mx) {
        cout << "NO" << endl;
        return 0;
    }
    su = 0;
    rep(i, n) {
        diff[i] = a[(i + 1) % n] - a[i];
        su += diff[i];
    }
    if (su != 0) {
        cout << "NO" << endl;
        return 0;
    }
    int cnt = 0;
    rep(i, n) {
        if ((m - diff[i]) % n != 0) {
            cout << "NO" << endl;
            return 0;
        }
        cnt += (m - diff[i]) / n;
    }
    cout << (cnt == m ? "YES" : "NO") << endl;

}


Measured memory_bytes: 1792
#include <string>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <vector>
#include <queue>
#include <set>
#include <utility>
#include <algorithm>
#include <numeric>
#include <iostream>
#include <iterator>
#include <sstream>

using namespace std;

int main()
{
	double n;
	while(cin>>n) printf("%.15lf\n",n * 7.81481481481481481);
	return 0;
}

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

int main()
{
    string S;
    cin >> S;
    int n = S.size();

    for (int i = 2; i <= S.size(); i+=2){
        string sub = S.substr(0, S.size() - i);
        int half = sub.size() / 2;
        if(sub.substr(0,half)==sub.substr(half,half)){
            cout << S.size() - i << endl;
            return 0;
        }
    }
    return 0;
}

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

#define ll long long


using namespace std;

const string ans[2] = {"Yes", "No"};

ll n, k, q, a[100005], x;
int main()
{
    cin >> n >> k >> q;
    for(int i = 0;i < q;i++){
        cin >> x;
        a[x]++;
    }
    for(int i = 1;i <= n;i++)
        cout << ans[((k - q + a[i]) <= 0)]<< "\n";

    return 0;
}


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

// #define int long long
#define rep(i, n) for (long long i = (long long)(0); i < (long long)(n); ++i)
#define reps(i, n) for (long long i = (long long)(1); i <= (long long)(n); ++i)
#define rrep(i, n) for (long long i = ((long long)(n)-1); i >= 0; i--)
#define rreps(i, n) for (long long i = ((long long)(n)); i > 0; i--)
#define irep(i, m, n) for (long long i = (long long)(m); i < (long long)(n); ++i)
#define ireps(i, m, n) for (long long i = (long long)(m); i <= (long long)(n); ++i)
#define SORT(v, n) sort(v, v + n);
#define REVERSE(v, n) reverse(v, v+n);
#define vsort(v) sort(v.begin(), v.end());
#define all(v) v.begin(), v.end()
#define mp(n, m) make_pair(n, m);
#define cout(d) cout<<d<<endl;
#define coutd(d) cout<<std::setprecision(10)<<d<<endl;
#define cinline(n) getline(cin,n);
#define replace_all(s, b, a) replace(s.begin(),s.end(), b, a);
#define PI (acos(-1))
#define FILL(v, n, x) fill(v, v + n, x);
#define sz(x) long long(x.size())

using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using vs = vector<string>;
using vpll = vector<pair<ll, ll>>;
using vtp = vector<tuple<ll,ll,ll>>;
using vb = vector<bool>;

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 ll INF = 1e9+10;
const ll MOD = 1e9+7;
const ll LINF = 1e18;

ll dp[100005][3];

signed main()
{
  cin.tie( 0 ); ios::sync_with_stdio( false );
  
  ll n; cin>>n;
  vll a(n); rep(i,n) cin>>a[i];
  
  ll ans=1;
  
  rep(i,n){
    ll cnt=0;
    bool flg=1;
    rep(j,3){
      if(dp[i][j]==a[i]){
        cnt++;
        if(flg) dp[i+1][j]=dp[i][j]+1, flg=false;
      }
      chmax(dp[i+1][j], dp[i][j]);
    }
    (ans*=cnt)%=MOD;
  }
  
  // rep(i,n+1){
  //   rep(j,3){
  //     cout<<dp[i][j]<<' ';
  //   }
  //   cout<<endl;
  // }
  
  cout<<ans<<endl;
}

Measured memory_bytes: 6424
from collections import Counter, defaultdict
import sys
sys.setrecursionlimit(10 ** 5 + 10)
input = sys.stdin.readline
from math import factorial
import heapq, bisect


def main():
    node_num, edge_num, p = map(int, input().split())
    data = [list(map(int, input().split())) for i in range(edge_num)]
    # graph_data = defaultdict(set)
    # weight_graph = defaultdict(int)

    # for i in range(edge_num):
    #     a, b, c = data[i]
    #     graph_data[a].add(b)
    #     weight_graph[(a, b)] = c - p

    inf = 10 ** 10
    length_data = [inf for i in range(node_num + 1)]
    length_data[1] = 0
    for i in range(node_num):
        for j in range(edge_num):
            a, b, c = data[j]
            weight = -1 * (c - p)
            length_data[b] = min(length_data[b], length_data[a] + weight)


    ans = length_data[node_num]
    for i in range(node_num):
        for j in range(edge_num):
            a, b, c = data[j]
            weight = -1 * (c - p)
            length_data[b] = min(length_data[b], length_data[a] + weight)

    ans2 = length_data[node_num]

    if ans2 < ans:
        print(-1)
    else:
        print(max(0, ans * -1))







if __name__ == '__main__':
    main()


Measured memory_bytes: 45036
N = int(input())
A = int(input())
B = int(input())
C = int(input())
D = int(input())
E = int(input())

arr = [A,B,C,D,E]
key = arr.index(min(arr))

ans = 4 + ((N + arr[key] - 1) // arr[key])

print(ans)


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

using namespace std;

using ll = long long;

int main(void){
    int n, m;

    cin >> n >> m;

    vector<ll> a(n,0),b(n,0),c(m,0),d(m,0);

    for(int i=0; i<n; i++)
        cin >> a[i] >> b[i];
        
    for(int i=0; i<m; i++)
        cin >> c[i] >> d[i];

    for(int i=0; i<n; i++){
        ll min_dist = 1000000000;
        ll ans = 0;
        for(int j=0; j<m; j++){
            ll dist = abs(a[i]-c[j])+abs(b[i]-d[j]);

            if(min_dist > dist){
                min_dist = dist;
                ans = j;
            }
        }
        cout << ans+1 << endl;
    }

    return 0;
}

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

typedef long long ll;
#define FOR(i, a, n) for (ll i=(ll)a;i<(ll)n;i++)
#define REP(i, n) FOR(i, 0, n)

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

    int ans = H*W -  h*W - H*w + h*w;

    cout << ans << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <cmath>
#include <queue>
#include <map>
#include <set>
#include <list>
#include <iomanip>
#include <vector>
#include <functional>
#include <algorithm>
#include <cstdio>
#include <random>
#include <ctime>
#include <cstdlib>
#include <unordered_map>
#include <string.h>
#include <iostream>

using namespace std;
typedef long long ll;
typedef pair<int, int> P;
#define rep(begin, i, end) for (int i = begin; i < (int)(end); i++)
#define all(v) v.begin(), v.end()
const int MOD = 1000000007;

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


Measured memory_bytes: 3620
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.lang.reflect.Array;
import java.util.Arrays;
import java.util.StringTokenizer;
import java.io.IOException;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */

public class Main {
    public static void main(String[] args) {
        InputStream    inputStream    = System.in;
        OutputStream outputStream = System.out;
        InputReader    in                      = new InputReader(inputStream);
        PrintWriter      out                    = new PrintWriter(outputStream);
        Task                 solver               = new Task();
        solver.solve(1, in, out);
        out.close();
    }

    static class Task {
    	public void solve(int testNumber, InputReader in, PrintWriter out) {
    		int N = in.nextInt();
    		int A = in.nextInt();
    		String str = "No";
    		int count = 0;
    		if(N % 500 <= A) {
    			str = "Yes";
    		}
    		out.println(str);
    	}
    }

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

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

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

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

    }
}



Measured memory_bytes: 21460
import java.io.BufferedReader;
import java.io.Closeable;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.PrintWriter;

public class Main {

    public static void main(String[] args) throws IOException {
        try (InputReader reader = new InputReader(System.in)) {
            solve(reader);
        }
    }

    private static void solve(InputReader reader) throws IOException {
        int n = reader.readInt();

        for (int i = 0; i <= n; i+=7) {
            for (int j = 0; i+j <= n; j+=4) {
                if (i + j == n) {
                    System.out.println("Yes");
                    return;
                }
            }
        }
        System.out.println("No");
    }
}

class Util {
    static int gcd(int m, int n) {
        int min = Math.min(m, n);
        int max = Math.max(m, n);
        while (min != 0) {
            int tmp = min;
            min = max % tmp;
            max = tmp;
        }

        return max;
    }

    static int lcm(int m, int n) {
        return m / gcd(m, n) * n;
    }
}

class InputReader implements Closeable, AutoCloseable {
    private final BufferedReader br;

    InputReader(InputStream inputStream) {
        this.br = new BufferedReader(new InputStreamReader(inputStream));
    }

    String readLine() throws IOException {
        return this.br.readLine();
    }

    int readInt() throws IOException {
        return Integer.parseInt(this.readLine());
    }

    long readLong() throws IOException {
        return Long.parseLong(this.readLine());
    }

    double readDouble() throws IOException {
        return Double.parseDouble(this.readLine());
    }

    String[] readStringsSplitByDelimiter(String delimiter) throws IOException {
        return this.readLine().split(delimiter);
    }

    int[] readIntsSplitByDelimiter(String delimiter) throws IOException {
        String[] strings = this.readStringsSplitByDelimiter(delimiter);

        int stringsLength = strings.length;
        int[] ints = new int[stringsLength];
        for (int i = 0; i < stringsLength; i++) {
            ints[i] = Integer.parseInt(strings[i]);
        }

        return ints;
    }

    long[] readLongsSplitByDelimiter(String delimiter) throws IOException {
        String[] strings = this.readStringsSplitByDelimiter(delimiter);

        int stringsLength = strings.length;
        long[] longs = new long[stringsLength];
        for (int i = 0; i < stringsLength; i++) {
            longs[i] = Long.parseLong(strings[i]);
        }

        return longs;
    }

    double[] readDoublesSplitByDelimiter(String delimiter) throws IOException {
        String[] strings = this.readStringsSplitByDelimiter(delimiter);

        int stringsLength = strings.length;
        double[] doubles = new double[stringsLength];
        for (int i = 0; i < stringsLength; i++) {
            doubles[i] = Double.parseDouble(strings[i]);
        }

        return doubles;
    }

    @Override
    public void close() throws IOException {
        this.br.close();
    }
}


Measured memory_bytes: 23252
#include<bits/stdc++.h>
#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define REPS(i,n) for(int i=1, i##_len=(n); i<i##_len; ++i)
#define all(x) (x).begin(),(x).end()
using ll = long long;
using namespace std;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
#define INF 1e9
#define PI (acos(-1))
int main() {
    int r;
    cin>>r;
    cout<<r*r<<endl;
    return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        // write your code here
        Scanner scanner=new Scanner(System.in);
        int n=scanner.nextInt();
        int min=Integer.MAX_VALUE;
        int result=Integer.MIN_VALUE;
        int x=0;
        for(int i=0;i<n;i++){
            x=scanner.nextInt();
            result=x-min>result?x-min:result;
            min=min>x?x:min;
        }
        System.out.println(result);
    }

}



Measured memory_bytes: 68364
using System;

public class Hello
{
    public static void Main()
    {
        var s = Console.ReadLine().Trim();
        var sL = s.Length;
        var p = 0;
        while (p <= sL - 1)
        {
            Console.Write(s[p]);
            p += 2;
        }
        Console.WriteLine();
    }
}


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

#define all(a) (a).begin(), (a).end()
#define rall(a) (a).rbegin(), (a).rend()
#define MIN(a) *min_element(all(a))
#define MAX(a) *max_element(all(a))
#define SUM(a) accumulate(all(a), 0LL)
#define REP(i, n) for(int (i)=0; (i)<(n); (i)++)
#define RREP(i, n) for(int (i)=(n)-1; (i)>=0; (i)--)
#define FOR(i, m, n) for(int (i)=(m); (i)<(n); i++)
#define FORR(i, m, n) for(int (i)=(n)-1; (i)>=(m); i--)
#define debug(x) cerr << #x << " = " << x << endl
//#define int long long

typedef long long ll;
//ll const MOD = 998244353;
ll const MOD = 1e9+7;
int const inf = 1e9;
ll const INF = 1e18;

inline void ios_(){cin.tie(0); ios::sync_with_stdio(false);}
template<typename T> int size(const T& a){return (int)a.size();}
template<typename T> T Div(T a, T b){return (a + b - 1) / b;}
template<typename T> bool chmin(T& a, const T& b){if(a > b){a = b; return true;} return false;}
template<typename T> bool chmax(T& a, const T& b){if(a < b){a = b; return true;} return false;}

ll BinarySearch(ll ng, ll ok, const function<bool(ll)>& judge){
    while(abs(ok - ng) > 1){
        ll mid = (ok + ng) / 2;
        if(judge(mid)) ok = mid;
        else ng = mid;
    }
    return ok;
}


signed main(){
    ll k;
    cin >> k;
    vector<ll> v(k);
    for(auto&& i : v) cin >> i;

    ll rem = 2;

    auto fn = [&](ll x){
        REP(i, k){
            x -= x % v[i];
            if(x < rem){
                return false;
            }
        }
        return true;
    };

    ll mi = BinarySearch(0, 1e18, fn);
    rem = 3;
    ll ma = BinarySearch(0, 1e18, fn) - 1;

    if(mi > ma){
        cout << -1 << endl;
    }else{
        cout << mi << " " << ma << endl;
    }

    return 0;
}


Measured memory_bytes: 1024
#include <iostream>
using namespace std;
int main() {
    int N, V[20], C[20], ans = 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]) ans += V[i] - C[i];
    cout << ans << endl;
}


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

typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;

#define fi first
#define se second
#define repl(i,a,b) for(ll i=(ll)(a);i<(ll)(b);i++)
#define rep(i,n) repl(i,0,n)
#define all(x) (x).begin(),(x).end()
#define dbg(x) cout<<#x"="<<x<<endl
#define mmax(x,y) (x>y?x:y)
#define mmin(x,y) (x<y?x:y)
#define maxch(x,y) x=mmax(x,y)
#define minch(x,y) x=mmin(x,y)
#define uni(x) x.erase(unique(all(x)),x.end())
#define exist(x,y) (find(all(x),y)!=x.end())
#define bcnt __builtin_popcountll

#define INF 1e16
#define mod 1000000007

ll n;
ll g[2],s[2],b[2];
ll dp[30000000];

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

  cin>>n;
  rep(i,2)cin>>g[i]>>s[i]>>b[i];

  rep(i,2){
    ll j=1-i;
    rep(k,n+1)dp[k]=k;
    dp[0]=0;
    rep(k,n+1){
      if(k-g[i]>=0)maxch(dp[k],dp[k-g[i]]+max(g[i],g[j]));
      if(k-s[i]>=0)maxch(dp[k],dp[k-s[i]]+max(s[i],s[j]));
      if(k-b[i]>=0)maxch(dp[k],dp[k-b[i]]+max(b[i],b[j]));
    }
    ll nxt=dp[n];
    n=nxt;
  }
  cout<<n<<endl;

  return 0;
}


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

int main(int argc, char const *argv[]) {
    int A, B;
    cin >> A >> B;
    if (A >= 10 || B >= 10) {
        cout << -1 << endl;
    } else {
        cout << A * B << endl;
    }
    return 0;
}


Measured memory_bytes: 256
class UnionFind:
    def __init__(self, elems):
        self.parent = dict()
        self.children = dict()
        for e in elems:
            self.parent[e] = e
            self.children[e] = 1

    def root(self, e):
        if self.parent[e] == e:
            return e

        return self.root(self.parent[e])

    def same(self, x, y):
        return self.root(x) == self.root(y)

    def unite(self, x, y):
        if self.same(x, y):
            return

        rx, ry = self.root(x), self.root(y)
        # ry <- rx
        if self.members(ry) < self.members(rx):
            rx, ry = ry, rx

        self.children[ry] += self.children[rx]
        self.parent[rx] = ry

    def members(self, x):
        return self.children[self.root(x)]


n, m = map(int, input().split())

uf = UnionFind(range(1, n+1))
c = 0
for _ in range(m):
    x, y, z = map(int, input().split())
    if uf.same(x, y):
        continue
    else:
        c += 1
        uf.unite(x, y)

print(n - c)

Measured memory_bytes: 124508
#include <algorithm>
#include <bitset>
#include <cassert>
#include <chrono>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <vector>

using namespace std;

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

int x[105];
int y[105];
int h[105];

void solve() {
  int n;
  cin >> n;
  for(int i = 0; i < n; i++) {
    cin >> x[i] >> y[i] >> h[i];
  }
  for(int xx = 0; xx <= 100; xx++) {
    for(int yy = 0; yy <= 100; yy++) {
      set<int> ret;
      for(int i = 0; i < n; i++) {
        if(h[i] == 0) continue;
        ret.insert(h[i] + abs(xx - x[i]) + abs(yy - y[i]));
      }
      if(ret.size() == 1) {
        int hh = *ret.begin();
        bool valid = true;
        for(int i = 0; i < n; i++) {
          valid &= h[i] == max(0, hh - abs(xx-x[i]) - abs(yy-y[i]));
        }
        if(valid) cout << xx << " " << yy << " " << *ret.begin() << "\n";
      }
    }
  }
}

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL); cout.tie(NULL);
  /*
  int t;
  cin >> t;
  for(int i = 1; i <= t; i++) {
    cout << "Case #" << i << ": ";
    solve();
  }
  */
  solve();
}


Measured memory_bytes: 256
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author I.E
 */

#include <iostream>
#include <fstream>

#include <iostream>
#include <string>
#include <map>
#include <vector>
#include <math.h>
#include <iomanip>
#include <algorithm>

using namespace std;

#define ll long long
#define ld long double
#define fr(i,a,b) for(int i=a;i<b;++i)
#define frn(i,a,b) for(int i=a;i>b;i--)
#define rep(i,n) fr(i,0,n)
#define present(container, element) (container.find(element) != container.end())
#define cpresent(container, element) (find(all(container),element) != container.end())
#define sz(a) int((a).size())
#define srt(container, lambda) sort(container.begin(), container.end(), lambda)

typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vi> vvi;
typedef vector<vl> vvl;
typedef pair<int,int> ii;

int int_pow(int x, int p)
{
    if (p == 0) return 1;
    if (p == 1) return x;

    int tmp = int_pow(x, p/2);
    if (p%2 == 0) return tmp * tmp;
    else return x * tmp * tmp;
}

void fill(istream& in, vi& a, int n) {
    int elm;
    rep(i, n) {
        in >> elm;
        a.push_back(elm);
    }
}

void fill(istream& in, vl& a, int n) {
    ll elm;
    rep(i, n) {
        in >> elm;
        a.push_back(elm);
    }
}

void fill(vi& a, int n, int val) {
    rep(i, n) {
        a.push_back(val);
    }
}

void fill(vl& a, int n, ll val) {
    rep(i, n) {
        a.push_back(val);
    }
}

int sum(vi arr) {
    int s = 0;
    for (auto& x: arr)
        s += x;
    return s;
}

int max(vi a) {
    return *max_element(a.begin(), a.end());
}

int min(vi a) {
    return *min_element(a.begin(), a.end());
}

void print(ostream& out, vi a) {
    for (auto& x: a) {
        out << x << " ";
    }
    out << endl;
}

void print(ostream& out, vl a) {
    for (auto& x: a) {
        out << x << " ";
    }
    out << endl;
}

#pragma GCC optimize("Ofast")
static auto speedup = [](){
    ios_base::sync_with_stdio(0);
    cin.tie(nullptr);
    cout.tie(nullptr);
    return 0;
}();



class DKnapsack1 {
public:
	void solve(std::istream& in, std::ostream& out) {
	    int n, w;
	    in >> n >> w;
	    vvl wv;
	    int elm;
	    rep(i, n) {
	        vl l;
	        in >> elm; l.push_back(elm);
            in >> elm; l.push_back(elm);
	        wv.push_back(l);
	    }
	    vl dp (w+1, 0);
	    rep(i, n){
	        frn(j, w, wv[i][0] - 1) {
                dp[j] = max(dp[j], dp[j - wv[i][0]] + wv[i][1]);
            }
	    }
	    out << dp[w] << endl;
	}
};


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


Measured memory_bytes: 3564
#include<iostream>
using namespace std;
int h,w;
int ans=0;
int c[10][10],a[200][200];
int main()
{
	cin>>h>>w; 
	for(int i=0;i<10;i++)
	    for(int j=0;j<10;j++)
	        cin>>c[i][j];
	for(int i=0;i<h;i++)
	    for(int j=0;j<w;j++)
	        cin>>a[i][j];
	for(int k=0;k<10;k++)
	    for(int i=0;i<10;i++)
	        for(int j=0;j<10;j++)
	        {
	        	if(i==j)
	        	    continue;
	        	c[i][j]=min(c[i][j],c[i][k]+c[k][j]);
			}
	for(int i=0;i<h;i++)
        for(int j=0;j<w;j++)
        {
        	if(a[i][j]!=-1)
        	    ans+=c[a[i][j]][1];
		}
	cout<<ans;
	return 0;
}

Measured memory_bytes: 384
#!/usr/bin/env python3
import sys


def solve(S: str):
    if S == 'SUN':
        print(7)
    if S == 'MON':
        print(6)
    if S == 'TUE':
        print(5)
    if S == 'WED':
        print(4)
    if S == 'THU':
        print(3)
    if S == 'FRI':
        print(2)
    if S == 'SAT':
        print(1)
    return


# Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    S = next(tokens)  # type: str
    solve(S)

if __name__ == '__main__':
    main()


Measured memory_bytes: 3064
INF = 10**9
N, A, B, C = gets.split.map(&:to_i)
L = []
N.times do |i|
  L[i] = gets.to_i
end

"自分で思いつかなかったのでeditorialのパクり"
def dfs(i, a, b, c)
  pa, pb, pc = 0, 0, 0
  if i==N
    return (a-A).abs + (b-B).abs + (c-C).abs - 30 if [a,b,c].min > 0
    # a,b,cに1つでも0があれば指定のサイズで作れないのでINFにしておく
    return INF if [a,b,c].min <= 0
  end
  p0 = dfs(i+1, a, b, c)
  pa = dfs(i+1, a+L[i], b, c) + 10
  pb = dfs(i+1, a, b+L[i], c) + 10
  pc = dfs(i+1, a, b, c+L[i]) + 10
  return [p0, pa, pb, pc].min
end

puts dfs(0, 0, 0, 0)

Measured memory_bytes: 1788
#include <bits/stdc++.h>
#define ROOP(i, N) for(int i=0; i++; i<N)
#define RVROOP(i, N) for(int i=N; i--; i>=0)
#define INF 1e9
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;
int main() {
  int N; cin>>N;
  double ans=N*100/108;
  int ansans=0;
  for(int i=ans-1; i<=ans+1; i++){
    if(i*108/100==N){
      ansans=1;
      ans=i;
    }
  }
  if(ansans==1){
    cout<<ans<<endl;
  }
  else{
    cout<<":("<<endl;
  }
}

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

using namespace std;
typedef long long ll;

#define MOD (long long)(1e9+7)
#define INF (1LL<<60)
#define rep(i,n) for(ll i = 0; i < (n); i++)
#define rep1(i,n) for(ll i = 1; i <= (n); i++)

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;
}


// 最大公約数
ll gcd(ll a, ll b)
{
  if(b == 0) return a;
  return gcd(b, a % b);
}

// mod m におけるa の逆元
ll modinv(ll a, ll m) {
  ll b = m, u = 1, v = 0;
  while (b) {
    ll t = a / b;
    a -= t * b; swap(a, b);
    u -= t * v; swap(u, v);
  }
  u %= m;
  if (u < 0) u += m;
  return u;
}

// 素因数分解
vector<pair<ll, ll>> prim;
void pf(ll n)
{
  ll s = sqrt(n);
  ll r = 0;
  for(ll i = 2; i <= s; i++) {
    if((n % i) == 0) {
      r = 0;
      do {
	r++;
	n = n / i;
      } while((n % i) == 0);
      prim.push_back({i, r});
    }
  }
  if(n > s) {
    prim.push_back({n, 1});
  }
}

void solve()
{
  ll K = 26;
  
  ll N; cin >> N;
  
  string ans = "";
  
  do  {
    N--;
    ll a;
    a = N % K;
    ans.push_back(a + 'a');
    N /= K;
  } while(N > 0);
  reverse(ans.begin(), ans.end());
  //  ans[0] -= 1;
  
  cout << ans << endl;
  
}


int main(void)
{
  // ll t; cin >> t; rep(i, t)
  solve();
}


Measured memory_bytes: 3688
import java.util.Scanner;
import java.util.List;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
	int a = sc.nextInt();
    int b = sc.nextInt();
    int c = sc.nextInt();
    if (a>=b && a>=c) {
      System.out.println(a*10+b+c);
    } else if (b>=a && b>=c) {
      System.out.println(a+b*10+c);
    } else {
      System.out.println(a+b+c*10);
    }
  }
}

Measured memory_bytes: 21716
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ

		Scanner sc = new Scanner(System.in);
		String n = sc.next();
		sc.close();

		String[] array = n.split("");

		long tmp = 0L;

		for(String str : array) {
			tmp = tmp+Integer.parseInt(str);
			tmp = tmp%9;
		}

		if(tmp%9==0) {
			System.out.println("Yes");
		}else {
			System.out.println("No");
		}


//		BigDecimal aa = new BigDecimal("10");
//		BigDecimal zero = new BigDecimal("0");
//		BigDecimal tmp = aa;
//
//		BigDecimal bigN = new BigDecimal(n);
//
//		while(tmp.compareTo(bigN)==-1) {
//			tmp = tmp.multiply(aa);
//		}
//
//		tmp = tmp.divide(aa);
//		System.out.println(tmp);
//
//		while(bigN.compareTo(zero)==1) {
//			bigN = bigN.subtract(tmp);
////			tmp = tmp.multiply(aa);
////			System.out.println(bigN);
//		}
//		bigN = bigN.add(tmp);
//		System.out.println(bigN);




	}
}


Measured memory_bytes: 54496
#pragma GCC optimize("Ofast")
#include <iostream>
#include <cstdio>
#include <fstream>
#include <algorithm>
#include <iterator>
#include <math.h>
#include <cmath>
#include <stdlib.h>
#include <vector>
#include <queue>
#include <stack>
#include <set>
#include <regex>
#include <unordered_set>
#include <string>
#include <map>
#include <iomanip>
#include <sstream>
#include <cassert>
#include <time.h>
#include <numeric>
#include <complex>
 
using namespace std;
using ull = unsigned long long;
using ll = long long;
using ld = long double;
using D = double;
using ii = pair<int, int>;
using vi = vector<int>;
using vii = vector<ii>;
 
#define pb push_back
#define mp make_pair
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(),x.rend()
#define makeunique(x) sort(all(x)), (x).resize(unique(all(x)) - (x).begin())
#define rep(i, x)  for(int i = 0; i < (x); i++)
#define rrep(i, x) for(int i = (x - 1); i >= 0; i--)
#define sqrt(x) sqrt(abs(x))
#define y1 y1_1234413
#define j1 j1_235
#define y0 y0_235
#define j0 j0_256
#define fi first
#define se second
#define re return
#define prev PREV
#define next next
#define sz(x) ((int)x.size())
 
template<typename T> T sqr(T a) { re a * a; }
template<typename T> T gcd(T a, T b) { re b ? gcd(b, a % b) : a; }
template<typename T> T sgn(T a) { re a > 0 ? 1 : (a < 0 ? -1 : 0); }
template<typename T> T abs(T a) { re a > 0 ? a : -a; }
 
const ld st = 0.000001;
const ld pi = acos((ld)-1);
const int mod = 1000000007;
 
 
#define FILENAME ""
 
const ll MAXN = 100002;

ll f (ll n) {
 	ll ans = 100000000000000;
	for (int i = 2; i <= sqrt(n); i++) {
	 	if (n % i == 0) {
	 		ans = min(ans, i + n/i); 	
	 	}
	}
	ans = min(ans, 1 + n);
	re ans;
}
                          
int main()
{
    ios::sync_with_stdio(0);
    cin.tie(NULL), cout.tie(NULL);
    //freopen("sum2.in", "r", stdin);
    //freopen("sum2.out", "w", stdout);
	ll n;
	cin >> n;
	cout << f(n) - 2;
    re 0;
}

Measured memory_bytes: 256
// skip until line 65
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <deque>
#include <fstream>
#include <functional>
#include <iostream>
#include <istream>
#include <iterator>
#include <sstream>
#include <list>
#include <map>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <utility>
#include <vector>
#include <iomanip>
using namespace std;

#define BR "\n"
#define REP(i, n) for(int (i)=0;(i)<(n);++(i))
#define ALL(cont) begin(cont),end(cont)
#define AS_MOD(a, b) ((((a) % (b) ) + (b)) % (b))
#define MO(a) AS_MOD(a,mod)
#define FEACH(it, cont) for(auto (it) = begin(cont); it!=end(cont);++it)
#define FEACHR(it, cont) for(auto (it) = rbegin(cont); it!=rend(cont);++it)
#define pb push_back
#define pob pop_back
#define fi first
#define se second
#define getll() ([](){ll s;scanf("%lld", &s);return s;})()
#define getld() ([](){ld s;scanf("%Lf", &s);return s;})()
#define prl(P) printf("%lld", P)
#define prd(P) printf("%.10Lf", P)
#define pr(P) printf(P)
#define MAX(V, T) V=max(V,T)
#define MIN(V, T) V=min(V,T)

#define DumpArray(cont, from, to) for(int __i=from;__i<to;++__i) {cout<<"(" <<__i<<": " << cont[__i]<<")";} cout<<endl;

/*
 * ***_bound(6)
 * 5 6 6 6 6 6 7 7 7
 *   ^lower    ^upper
 * void reverse(c.begin(), c.end())
 *
 * graph
 * seg tree
 * dp
 * brute force
 */
struct Comparator{
    int operator()(int l, int r) const {
        return r<l;
    }
};
struct Vec;
//set<int, Comparator> S;

// solution below
typedef long long ll;
typedef long double ld;
typedef pair<ll,ll> P;
ll N;
ll f(ll n,ll v) {
    if (n>=v) {
        if (n%v==0) {
            return f(n/v,v);
        } else {
            return f(n%v,v);
        }
    }else {
        return n;
    }
}
int main() {
    cout.precision(10);
    cout << fixed;
    cin >> N;
    set<ll> Ans;
    Ans.insert(N);
    Ans.insert(N-1);
    for(ll i=1;i*i<=N;++i) {
        if ((N-1)%i==0) {
            Ans.insert(i);
            Ans.insert((N-1)/i);
        }
    }
    set<ll> fac;
    for(ll i=2;i*i<=N;++i) {
        if ((N)%i==0) {
            fac.insert(i);
            fac.insert(N/i);
        }
    }
    for(ll v:fac) {
        if (f(N,v)==1)Ans.insert(v);
    }

    if (Ans.count(1)>0)
        Ans.erase(1);
    cout<<Ans.size()<<endl;
}


Measured memory_bytes: 3752
n = int(input())
a = {}
for i in range(n):
    a[i] = int(input())

max_i, MAX = max(a.items(), key=lambda x: x[1])
del a[max_i]

SECOND = max(a.values())


for i in range(n):
    if i == max_i:
        print(SECOND)
    else:
        print(MAX)


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

const int N=2e5+100;
const int mod=1e9+7;
typedef long long ll;

int n,m;

int f[N],d[N];

int _find(int root)
{
    if(f[root]!=root){
        int fa=f[root];
        f[root]=_find(f[root]);
        d[root]+=d[fa];
    }
    return f[root];
}
int main()
{
    ios::sync_with_stdio(0);cin.tie(0);

    cin >> n >> m;

    for(int i=1;i<=n;i++) f[i]=i;
    int ff=1;
    for(int i = 1; i <= m; i++){
        int l,r,z;
        cin>> l >> r >> z;

        int lr=_find(l),rr=_find(r);
        if(lr == rr && d[l] - d[r] != z){
            ff=0;
        }
        if(lr != rr){
            f[lr] = rr;
            d[lr] = z+d[r]-d[l];
        }
    }
    if(ff==0) cout<<"No"<<endl;
    else cout<<"Yes"<<endl;
    return 0;
}


Measured memory_bytes: 4452
import java.util.*;
 
public class Main {
	public static void main (String[] args) {
		Scanner in = new Scanner(System.in);
		
		int n = in.nextInt();
      	int nam = 0;
      	int sum = 0;
      	int nam1[] = new int[n];
      	int nam2[] = new int[n-1];
      
      for(int i = 0;i < n;i++){
       nam1[i] = in.nextInt();
      }
     
      for(int i = 0;i < n;i++){
       sum += in.nextInt();
      }   

      for(int i = 0;i < n-1;i++){
       nam2[i] = in.nextInt();
      }
      
      for(int i = 0; i < n-1;i++){
      nam = nam1[i] +1;
      if(nam==nam1[i+1]){
      sum += nam2[nam-2];
      }
      }
      System.out.print(sum);
	}
}

Measured memory_bytes: 21716
#include <iostream>
#include <stdio.h>

using namespace std;

int main()
{
    int n,k;
    cin >> n >> k;
    double p[n];
    double sum[n];
    for(int i=0; i<n; i++){
        int tmp;
        cin >> tmp;
        p[i] = ((double)tmp+1.0)/2.0;
        if(i == 0){
            sum[i] = p[i];
        }else{
            sum[i] = sum[i-1] + p[i];
        }
        //cout << sum[i] << ", ";
    }
    //cout << endl;
    
    double ans = 0.0;
    for(int i=0; i<=n-k; i++){
        double tmp;
        if(i == 0){
            tmp = sum[i+k-1] - 0.0;
        }else{
            tmp = sum[i+k-1] - sum[i-1];
        }
        //cout << tmp << ", ";
        if(tmp > ans) ans = tmp;
    }
    //cout << endl;
    printf("%.7lf\n", ans);
    return 0;
}

Measured memory_bytes: 3328
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define rrep(ri,n) for(int ri = (int)(n-1); ri >= 0; ri--)
#define rep2(i,x,n) for(int i = (int)(x); i < (int)(n); i++)
#define rrep2(ri,x,n) for(int ri = (int)(n-1); ri >= (int)(x); ri--)
#define repit(itr,x) for(auto itr = x.begin(); itr != x.end(); itr++)
#define rrepit(ritr,x) for(auto ritr = x.rbegin(); ritr != x.rend(); ritr++)
#define ALL(x) x.begin(), x.end()
using ll = long long;
using namespace std;

int main(){
  int n, x, y;
  cin >> n >> x >> y;
  x--; y--;
  vector<vector<int>> gr(n);
  rep(i, n){
    int pr = i - 1, nx = i + 1;
    if(i != 0) gr.at(i).push_back(pr);
    if(i != n-1) gr.at(i).push_back(nx);
  }
  gr.at(x).push_back(y);
  gr.at(y).push_back(x);
  vector<int> ans(n-1, 0);
  rep(i, n-1){
    vector<int> d(n, -1);
    queue<int> q;
    q.push(i);
    d.at(i) = 0;
    while(!q.empty()){
      int now = q.front(); q.pop();
      for(auto nx : gr.at(now)){
        if(d.at(nx) != -1) continue;
        d.at(nx) = d.at(now) + 1;
        q.push(nx);
      }
    }
    rep2(j, i+1, n){
      ans.at(d.at(j)-1)++;
    }
  }
  for(auto o : ans){
    cout << o << endl;
  }
  return 0;
}

Measured memory_bytes: 3696
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

class Main {
	public static void main(String args[]) throws IOException {
		BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
		Solver solver = new Solver();
		solver.init();
		solver.readHead(in.readLine());
		// for (; solver.hasNext();) {
		// solver.readBody(in.readLine());
		// }
		// solver.solve();
	}
}

class Solver {
	int N;
	int cnt;

	public void init() {
		N = 0;
		cnt = 0;
	}

	public void readHead(String str) {
		String[] strArr = str.split(" ");
		N = Integer.parseInt(strArr[0]);
		// System.out.println(N);
		int s = 0;
		for (int n = N; n > 0; n /= 10) {
			s += n % 10;
		}
		if (N % s == 0)
			System.out.println("Yes");
		else
			System.out.println("No");
	}

	public boolean hasNext() {
		return cnt < N;
	}

	public void readBody(String str) {
		// System.out.println(str);
		cnt++;
	}

	public void solve() {

	}
}


Measured memory_bytes: 24916
/** author: __nishad__ **/

#include<bits/stdc++.h>
using namespace std;


typedef long long ll ;
typedef vector<ll> vll ;

#define IOS ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define all(v) (v).begin(),(v).end()
#define precision(k) cout<<setprecision(k)<<fixed;
#define loop(i,a) for(int i=0; i<a;i++)
#define loop2(i,a,b) for(int i=(a);i<=(b);++i)
#define minv(v) *min_element(all(v))
#define maxv(v) *max_element(all(v))
#define getpos(v,x) (lower_bound(v.begin(),v.end(),x)-v.begin())
#define unq(v) sort(all(v)),(v).erase(unique((v).begin(),(v).end()),(v).end())
#define pb push_back
#define pi 3.14159265358979323
#define endl "\n"

int main()
{
    IOS;

    int64_t x, ans=0, yr=100, i;
    cin>>x;

    while(1){
        yr = yr + yr*.01;

        ans++;
        if(yr >= x)
            break;
    }


    cout<<ans;




}




Measured memory_bytes: 3628
from collections import defaultdict

N, K = map(int, input().split())
TD = [list(map(int, input().split())) for _ in range(N)]

TD.sort(key = lambda x: -x[1])
#print(TD)

tmp = [[] for _ in range(N + 1)]
cnt = defaultdict(int)
out_candidate = []
kiso = 0
kind = 0
for i in range(K):
    t, d = TD[i]
    tmp[t].append(d)
    if cnt[t]:
        out_candidate.append([t, d])
    else:
        kind += 1
    kiso += d
    cnt[t] += 1
out_candidate.sort(key = lambda x: -x[1])
#print(tmp)
#print(cnt)
#print(out_candidate)
#print(kiso, kind)

answer = []
answer.append(kiso + kind ** 2)

in_candidate = []
if K < N:
    for i in range(K, N):
        in_candidate.append(TD[i])
in_candidate.sort(key = lambda x: x[1])
#print(in_candidate)

while out_candidate and in_candidate:
    in_t, in_d = in_candidate.pop()
    if cnt[in_t] == 0:
        cnt[in_t] += 1
        out_t, out_d = out_candidate.pop()
        kiso += in_d - out_d
        kind += 1
        answer.append(kiso + kind ** 2)
        
print(max(answer))

Measured memory_bytes: 83672
//  Copyright © 2020 Diego Garcia Rodriguez del Campo. All rights reserved.
#include<bits/stdc++.h>
#define MAX 200005
#define optimiza_io cin.tie(0); ios_base::sync_with_stdio(0);
#define what_is(x) cerr << #x << " is " << x << endl;
#define pii pair < int , int >
#define fi first
#define se second
using namespace std;
typedef long long ll;

ll A, ans;
string B;

int main()
{
    optimiza_io
    cin >> A >> B;
    ll num = (B[0]-'0')*100+(B[2]-'0')*10+(B[3]-'0')*1;
    ans = A * num / 100;
    cout << ans << "\n";
    return 0;
}

// CHECAR LIMITES 

Measured memory_bytes: 3648
use proconio::{input, fastout};
use std::collections::BTreeMap;

#[fastout]
fn main() {
    input! {
        n: usize,
        ll: [usize; n],
    }

    let mut map = BTreeMap::new();

    for l in ll {
        *map.entry(l).or_insert(0) += 1;
    }

    let mut lengths = vec![];
    let mut counts = vec![];

    for (key, value) in map {
        lengths.push(key);
        counts.push(value);
    }

    let mut count = 0;

    for i in 0..lengths.len() {
        for j in i+1..lengths.len() {
            for k in j+1..lengths.len() {
                if lengths[i] + lengths[j] > lengths[k] {
                    count += counts[i] * counts[j] * counts[k];
                }
            }
        }
    }

    println!("{}", count);
}


Measured memory_bytes: 2208
#include <iostream>
#include <string>
#include <set>
#include <vector>
using namespace std;

int main(){

    int N;

    cin >> N;
    vector<int> l(N);
    for(int i = 0; i < N; ++i){
        cin >> l[i];
    }

    sort(l.begin(), l.end(), greater<int>() );

    cout << l[0] - l[N-1] << endl;
}

Measured memory_bytes: 256
import java.io.*;

class Main {
	public static void main(String[] args){
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		try{
			int S = Integer.parseInt(br.readLine());
			System.out.println((S / 60 / 60) + ":" + ((S % (60 * 60))/ 60) + ":" + S % 60);
		}catch(Exception e){
		}
	}
}


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

int b[6][2] = { {0,1}, {0,1}, {0,2}, {0,2}, {1,2}, {1,2} };

int main(){
    vector<pair<int,int>> v;
    int x, y;

    for(int i = 0; i < 6; i++){
        cin >> x >> y;
        if(x > y)   swap(x, y);
        v.push_back({x, y});
    }

    sort(v.begin(), v.end());

    bool judge = true;
    int a[3] = {v[0].first, v[0].second, v[2].second};
    
    for(int i = 0; i < 6; i++){
        judge &= v[i].first == a[b[i][0]];
        judge &= v[i].second == a[b[i][1]];
    }

    if(judge)   cout << "yes" << endl;
    else        cout << "no" << endl;

    return 0;
}


Measured memory_bytes: 3128
import java.util.*;

public class Main {
	static Scanner sc = new Scanner(System.in);
	public static void main(String[] args) {
        int N = sc.nextInt();
        int A = sc.nextInt();
        int B = sc.nextInt();

        int sum = 0;
        for (int i=1; i<=N; i++) {
            int n = i;
            int digSum = 0;
            while ( n > 0) {
                digSum += n % 10;
                n /= 10;
            }
            if (digSum >= A && digSum <= B)
                sum += i;
        }
        System.out.println(sum);
	}
}

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

#define rep(i,m,n) for(int (i)=(int)(m);i<(int)(n);++i)
#define rep2(i,m,n) for(int (i)=(int)(n)-1;i>=(int)(m);--i)
#define REP(i,n) rep(i,0,n)
#define REP2(i,n) rep2(i,0,n)
#define FOR(i,c) for(decltype((c).begin())i=(c).begin();i!=(c).end();++i)
#define all(hoge) (hoge).begin(),(hoge).end()
#define en '\n'
using ll = long long;
using ull = unsigned long long;
template <class T> using vec = vector<T>;
template <class T> using vvec = vector<vec<T>>;
typedef pair<ll, ll> P;
constexpr long long INF = 1LL << 60;
constexpr int INF_INT = 1 << 25;
constexpr long long MOD = (ll) 1e9 + 7;
//constexpr long long MOD = 998244353LL;
using ld=long double;
static const ld pi = 3.141592653589793L;
typedef vector<ll> Array;
typedef vector<Array> Matrix;


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;
}

struct Edge {
	ll to, cap, rev;
	Edge(ll _to, ll _cap, ll _rev) {
	to = _to; cap = _cap; rev = _rev;
	}
};
using Edges = vector<Edge>;
using Graph = vector<Edges>;

void add_edge(Graph& G, ll from, ll to, ll cap, bool revFlag, ll revCap) {
	G[from].push_back(Edge(to, cap, (ll)G[to].size()));
	if (revFlag)G[to].push_back(Edge(from, revCap, (ll)G[from].size() - 1));
}

void solve(){
    ll n,k;
    cin>>n>>k;
    Array a(n);
    REP(i,n) cin>>a[i];
    Array sum1(n+1,0),sum2(n+1,0);
    REP(i,n){
        sum1[i+1]+=sum1[i]+a[i];
        sum2[i+1]+=sum2[i]+max(a[i],0LL);
    }

    ll ans=0;
    REP(i,n){
        if(i+k>n) break;
        ll x=sum2[i] + sum2[n]-sum2[i+k];
        chmax(ans,x);
        x+=sum1[i+k]-sum1[i];
        chmax(ans,x);
    }
    cout<<ans<<en;
}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
	
	solve();
	//ll t;cin>>t;REP(i,t) solve();

    return 0;
}

Measured memory_bytes: 2560
// C - Sentou
#include <bits/stdc++.h>
using namespace std;

int main(){
	int N,T; cin>>N>>T;
	long long ans = 0;
	int start; cin>>start;
	int end = T;
	while(--N){
		int now; cin>>now;
		ans += end>=now? now - start: T;
		start = now;
		end = now + T;
	}
	cout<< ans + T <<endl;
}

Measured memory_bytes: 256
import heapq

N, K = map(int, input().split())
S = []
for i in range(N):
    t, d = map(int, input().split())
    heapq.heappush(S, (-d, t))

sum_d = 0
types = set()
surplus = []
for i in range(K):
    _d, t = heapq.heappop(S)
    sum_d += -_d
    if t in types:
        heapq.heappush(surplus, -_d)
    else:
        types.add(t)
len_types = len(types)
ans = sum_d + len_types * len_types

while S and surplus:
    _d, t = heapq.heappop(S)
    if t in types:
        continue
    types.add(t)
    removed_d = heapq.heappop(surplus)
    sum_d += -_d - removed_d
    len_types += 1
    ans = max(ans, sum_d + len_types * len_types)
print(ans)


Measured memory_bytes: 79064
int main(){
    int S_s, h, m, s;
    scanf("%d",&S_s);
    h = S_s / 3600;
    m = (S_s - h*3600) / 60 ;
    s = (S_s - h*3600) % 60 ;
    printf("%d:%d:%d\n",h, m, s);
    return 0;
}


Measured memory_bytes: 2104
/* package whatever; // don't place package name! */

import java.util.*;
import java.lang.*;
import java.io.*;

/* Name of the class has to be "Main" only if the class is public. */
public class Main
{
	static String sorting(int[] arr){
			int n = arr.length;
			int count = 0;
			for(int i=0;i<n;i++){
				if(arr[i]!=i+1){
					count++;
				}
			}
			return((count==2||count==0)?"YES":"NO");
	}
	
	public static void main (String[] args) throws java.lang.Exception
	{
		Scanner scan = new Scanner(System.in);
		int n = scan.nextInt();
		int[] arr = new int[n];
		for(int i=0;i<n;i++){
			arr[i] = scan.nextInt();
		}
		System.out.println(sorting(arr));

	}
}


Measured memory_bytes: 21844
#include <stdio.h>

void bubble(int a[],int n);

int main()
{
	int a[100],ans[20];
	int n=0,i=0,j=0,temp=0;	

	while(1){
		scanf("%d",&n);
		if(n==0)
			break;
		for(i=0;i<n;i++)
			scanf("%d",&a[i]);
		bubble(a,n);
		for(i=1;i<n-1;i++)
			temp+=a[i];
		ans[j]=temp/(n-2);
		j++;
		temp=0;	
	}
	for(i=0;i<j;i++)
		printf("%d\n",ans[i]);

	return 0;
}

void bubble(int a[],int n)
{
	int i,j;
	for(i=0;i<n;i++){
		for(j=n-1;j>i;j--){
			if(a[j]<a[j-1]){
				int temp=a[j];
				a[j]=a[j-1];
				a[j-1]=temp;
			}
		}
	}
}

Measured memory_bytes: 596
#include<bits/stdc++.h>
using namespace std;
#define Fast ios::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define int long long
typedef vector<int>Vl;
typedef pair<int,int>pii;
typedef vector<pii>Vll;
typedef vector<pair<int,pii> >Vlll;
typedef priority_queue<int>PQL;
typedef map<int,int>M;
#define S second
#define F first
#define mp make_pair
#define ms(x,y) memset(x,y,sizeof(x))
#define pb push_back
#define sl(n) cin>>n
#define pl(n) cout<<n
const int mod=1e9+7;
const int sze=1e5+2;
const int inf= (int)(1e19+10LL);
void solve()
{
	int n;
	sl(n);
	string str;
	sl(str);
	int r=0,g=0,b=0;
	for(int i=0;i<n;i++){
		if(str[i]=='R')r++;
		else if(str[i]=='G')g++;
		else b++;
	}
	int ans=r*g*b;
	for(int i=0;i<n;i++){
		for(int d=1;i+2*d<n;d++){
			int j=i+d;
			int k=i+2*d;
			if(str[i]!=str[j] && str[j]!=str[k] && str[k]!=str[i])ans--;
		}
	}
	cout<<ans<<endl;
}
 
signed main(){
   int test=1;
   //sl(test);
   while(test--){
      solve();
 
   }
  return 0;
}


Measured memory_bytes: 3596