akhauriyash/Code-Regression huggingface dataset:
#pragma target("avx")
#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> P;
typedef vector<ll> V;
typedef unordered_map<ll, ll> U_MAP;
typedef priority_queue<ll> pq;
typedef priority_queue<ll, vector<ll>, greater<ll>> rpq;
const int INF = 1e9, MOD = 1e9 + 7, ohara = 1e6 + 10;
const ll LINF = 1e18;

#define rep(i, n) for (ll(i) = 0; (i) < (int)(n); (i)++)
#define rrep(i, a, b) for (ll i = (a); i < (b); i++)
#define rrrep(i, a, b) for (ll i = (a); i >= (b); i--)
#define all(v) (v).begin(), (v).end()
#define Size(n) (n).size()
#define Cout(x) cout << (x) << endl
#define doublecout(a) cout << fixed << setprecision(15) << a << endl;
#define fi first
#define se second
#define m_p make_pair
#define p_b push_back
string to_string(string s) { return '"' + s + '"'; }
string to_string(const char* s) { return to_string((string)s); }
string to_string(bool b) { return (b ? "true" : "false"); }
template <typename A, typename B>
string to_string(pair<A, B> p) {
  return "(" + to_string(p.first) + ", " + to_string(p.second) + ")";
}
template <typename A>
string to_string(A v) {
  bool first = true;
  string res = "{";
  for (const auto& x : v) {
    if (!first) {
      res += ", ";
    }
    first = false;
    res += to_string(x);
  }
  res += "}";
  return res;
}
void debug_out() { cerr << endl; }
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
  cerr << " " << to_string(H);
  debug_out(T...);
}
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)

//------ Believe yourself as a genius!!!!!! ------

int dy[] = {1, 0, -1, 0};
int dx[] = {0, 1, 0, -1};
// int dy[]={-1,0,1,-1,1,-1,0,1};int dx[]={-1,-1,-1,0,0,1,1,1};
string alph("abcdefghijklmnopqrstuvwxyz"), s;
ll n, cnt, ans, a[ohara], b, c, d, tmp, m, h, w, x, y, sum, k, q;

ll lcm(ll aaa, ll bbb) {
  ll g = __gcd(aaa, bbb);
  return aaa / g * bbb;
}

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

  cin >> n >> m;
  rep(i, n) { cin >> a[i]; }
  tmp = a[0] / 2;
  rrep(i, 1, n) {
    tmp = lcm(tmp, a[i] / 2);
    if (tmp > m) {
      Cout(0);
      return 0;
    }
  }
  rep(i, n) {
    if (tmp % a[i] == 0) {
      Cout(0);
      return 0;
    }
  }
  ans = m / tmp;
  ans = (ans + 1) / 2;
  Cout(ans);
  return 0;
}

Measured memory_bytes: 1024
#define _USE_MATH_DEFINES
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define rep(i,n)         for(int i=0; i<(n); i++)
#define P pair<int, int>
#define prtd(n, var)     cout << fixed << setprecision(n) << var << "\n"

//----------------------------------------------------

const int INF = 100100100;
int a[12][12];

int main(){
    int x, y, z;
    cin >> x >> y >> z;
    cout << x*y/2 << endl;
}

Measured memory_bytes: 3624
#include<bits/stdc++.h>
#define rep(i,n,m) for(int i = (n); i <(m); i++)
using namespace std;
using ll = long long;
const int MAX_N = 200000;
int num_leaf;

int segtree[MAX_N * 4];

void update(int x, int value)
{
    segtree[num_leaf - 1 + x] = value;
    int now = ((num_leaf - 1 + x) - 1) / 2;
    while (true)
    {
        segtree[now] = max(segtree[now * 2 + 1], segtree[now * 2 + 2]);
        if (now == 0) break;
        now = (now - 1) / 2;
    }
}

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

    num_leaf = 1;
    while (num_leaf < n) num_leaf <<= 1;

    rep(i, 0, n)
        cin >> segtree[num_leaf - 1 + i];
    
    for (int i = num_leaf - 2; i >= 0; i--)
        segtree[i] = max(segtree[2 * i + 1], segtree[2 * i + 2]);
    
    rep(i, 0, n)
    {
        int pool = segtree[num_leaf - 1 + i];
        update(i, 0);
        cout << segtree[0] << endl;
        update(i, pool);
    }
    return 0;
}

Measured memory_bytes: 3456
#include<iostream>
#include<string>
#include<stack>/*** LIFO *** stack<type> var;
push(), top():to get data, pop():to remove, size(), empty() ***/
using namespace std;

#define Fp(I, STAT, END) for(int I = STAT; I < END; I++)
#define Fm(I, STAT, END) for(int I = STAT; I > END; I--)

int main(){
    int N, K;
    string S;
    cin >> N >> K;
    cin >> S;
    switch(S[K - 1]){
        case 'A':
            S[K - 1] = 'a';
            break;
        case 'B':
            S[K - 1] = 'b';
            break;
        case 'C':
            S[K - 1] = 'c';
            break;
        default:
            cout << "error" << endl;
    }
    cout << S << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <math.h>
using namespace std;

int main()
{
    long long L, R;
    cin >> L >> R;
    if(R-L < 2019){
        // 全通り
        long long ret = pow(10, 9);
        for(long long i = L;i <= R;i++){
            for(long long j = i+1;j <= R;j++){
                ret = min(ret, (i*j)%2019);
            }
        }
        cout << ret << endl;
    }else{
        cout << 0 << endl;
    }
    return 0;
}


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

int main(void){
  int N;
  cin >> N;
  set<int> st;
  int d;
  for(int i = 0; i < N; i++){
    cin >> d;
    st.insert(d);
  }
  
  cout << st.size() << endl;
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <limits>

template <class T>
struct Edge {
    int from, to;
    T cost;
    Edge(int from, int to, T cost) : from(from), to(to), cost(cost){};

    bool operator<(const Edge<T>& e) const { return this->cost < e.cost; }
    bool operator>(const Edge<T>& e) const { return this->cost > e.cost; }
};

template <class T = int>
class Graph {
public:
    explicit Graph(int N = 0) : size(N) { path.resize(size); }
    void span(int u, int v, T cost = 1) { path[u].push_back(Edge<T>(u, v, cost)); }
    std::vector<Edge<T>> operator[](int v) const { return path[v]; }

    int size;
    std::vector<std::vector<Edge<T>>> path;
};

const int INF = std::numeric_limits<int>::max();

template <class T>
std::vector<std::vector<T>> warshall_floyd(const Graph<T>& graph) {
    std::vector<std::vector<T>> dist(graph.size, std::vector<T>(graph.size, INF));

    for (int v = 0; v < graph.size; ++v) {
        dist[v][v] = 0;
        for (const auto& e : graph[v]) {
            dist[v][e.to] = e.cost;
        }
    }

    for (int k = 0; k < graph.size; ++k) {
        for (int u = 0; u < graph.size; ++u) {
            for (int v = 0; v < graph.size; ++v) {
                if (dist[u][k] < INF && dist[k][v] < INF) {
                    dist[u][v] = std::min(dist[u][v], dist[u][k] + dist[k][v]);
                }
            }
        }
    }

    for (int v = 0; v < graph.size; ++v) {
        if (dist[v][v] < 0) return std::vector<std::vector<T>>();
    }

    return dist;
}

int main() {
    int N, M;
    std::cin >> N >> M;

    Graph<int> graph(N);
    for (int i = 0; i < M; ++i) {
        int u, v, d;
        std::cin >> u >> v >> d;
        graph.span(u, v, d);
    }

    auto dist = warshall_floyd(graph);

    if (dist.empty()) {
        std::cout << "NEGATIVE CYCLE" << std::endl;
        return 0;
    }

    for (const auto& d : dist) {
        for (int i = 0; i < d.size(); ++i) {
            if (d[i] == INF) {
                std::cout << "INF";
            } else {
                std::cout << d[i];
            }
            std::cout << " \n"[i == d.size() - 1];
        }
    }
    return 0;
}



Measured memory_bytes: 3260
// Author: 23forever
#include <iostream>
#include <cstdio>
#include <cmath>
#include <cstring>
#include <vector>
#include <queue>
typedef long long LL;
const int MAXN = 200000;
using namespace std;

inline void enableFileIO() {
  freopen("test.in", "r", stdin);
  freopen("test.out", "w", stdout);
}

inline int read() {
  int x = 0, w = 1;
  char c = ' ';

  while (c < '0' || c > '9') {
    c = getchar();
    if (c == '-') w = -1;
  }
  while (c >= '0' && c <= '9') {
    x = (x << 1) + (x << 3) + (c ^ 48);
    c = getchar();
  }

  return x * w;
}

int n, k;

void init() {
  //enableFileIO();
  
  n = read();
  k = read();
}

int main() {
  init();

  LL ans = 1LL * (n / k) * (n / k) * (n / k);
  if (k % 2 == 0) ans += 1LL * ((n + k / 2) / k) * ((n + k / 2) / k) * ((n + k / 2) / k);    
  printf("%lld\n", ans);
  return 0;
}

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

using E = System.Linq.Enumerable;

public class Program
{
    public static void Main()
    {
        var ab = Console.ReadLine().Split().Select(x => int.Parse(x)).ToArray();

        Console.WriteLine(ab[0] < 9 && ab[1] < 9 ? "Yay!" : ":(");
    }
}

Measured memory_bytes: 13268
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <string>
#include <cstring>
#include <utility>
#include <set>
#include <stack>
#include <climits>
#include <cmath>
#include <iomanip>
#include <unordered_map>
#include <map>
#include <boost/multiprecision/cpp_int.hpp>

#define rep(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define rep1(i,n) for(int i=1, i##_len=(n); i<=i##_len; ++i)
#define reps(i,s,n) for(int i=s, i##_len=(n); i<i##_len; ++i)
#define all(x) (x).begin(),(x).end()
#define MEMSET(v, h) memset((v), h, sizeof(v))
typedef long long ll;
typedef long double ld;
const char sp = ' ';

using namespace boost::multiprecision;
using namespace std;

int main(void){
    ll N;
    cin>>N;
    if(N<1000) cout<<"ABC"<<endl;
    else cout<<"ABD"<<endl;
    return 0;
}


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

using namespace std;

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

ll dp[100005][2];
vector<int> edges[100005];
const int MOD = 1000000007;

ll solve(int curr, int par) {
  dp[curr][0] = 1;
  dp[curr][1] = 1;
  for(int out: edges[curr]) {
    if(out == par) continue;
    solve(out, curr);
    dp[curr][0] *= (dp[out][0] + dp[out][1]);
    dp[curr][1] *= dp[out][0];
    dp[curr][0] %= MOD;
    dp[curr][1] %= MOD;
  }
  return dp[curr][0] + dp[curr][1];
}

void solve() {
  int n;
  cin >> n;
  for(int i = 1; i < n; i++) {
    int a, b;
    cin >> a >> b;
    edges[a].push_back(b);
    edges[b].push_back(a);
  }
  cout << solve(1, -1)%MOD << endl;
}

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


Measured memory_bytes: 14208
#include <bits/stdc++.h>
using namespace std;
typedef unsigned long long ULL;
typedef long long LL;
#define FOR(i, a, b) for(LL i=(LL)(a);i<(LL)(b);i++)
#define REP(i,x) for(LL i=0;i<(LL)(x);i++)

int main()
{
    ios::sync_with_stdio(false);
    cin.tie(NULL);
    // cout << fixed << setprecision(10);
    LL x;
    cin >> x;
    LL c500 = x / 500;
    LL c5 = (x - c500 * 500) / 5;

    cout << c500 * 1000 + c5 * 5 << endl;
    return 0;
}

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

#define rep(i,n) for(long long i=0; i<(long long)(n);i++)
#define rep2(i,s,n) for(long long i=(s); i<(long long)(n);i++)

#define mod 1e9+7;
#define inf 1e18+7;

typedef long long ll;

int main() {
    int a,b,c,k;
    cin>>a>>b>>c>>k;

    int m=max({a,b,c});
    int M=m;
    rep(i,k){
        M*=2;
    }

    cout<<a+b+c+M-m<<endl;
}


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

#define rep(i,n) for(i = 0;i < n;++i)
#define all(v) v.begin(), v.end()
using ll = long long;

int main()
{
    ll i,j;
    ll k;
    cin >> k;
    if(k == 0){
        cout << 2 << endl;
        cout << 1 << " " << 1 << endl;
        return 0;
    }else if(k == 1){
        cout << 2 << endl;
        cout << 2 << " " << 0 << endl;
        return 0;
    }
    if(k < 50){
        ll n = k;
        vector<ll> a(n);
        for(i = 0;i < n;++i){
            a.at(i) = i;
        }
        for(i = 0;i < k;++i){
            rep(j,n){
                if(j == i) a.at(j) += n;
                else --a.at(j);
            }
        }
        cout << n << endl;
        for(i = 0;i < n-1;++i){
            cout << a.at(i) << " ";
        }
        cout << a.at(i) << endl;
        return 0;
    }
    ll n = 50;
    vector<ll> a(n);
    for(i = 0;i < n;++i){
        a.at(i) = i;        
    }
    ll m = k/n;
    k %= n;
    for(i = 0;i < n;++i){
        a.at(i) += m;
    }
    for(i = 0;i < k;++i){
        rep(j,n){
            if(j == i) a.at(j) += n;
            else --a.at(j);
        }
    }
    cout << n << endl;
    for(i = 0;i < n-1;++i){
        cout << a.at(i) << " ";
    }
    cout << a.at(i) << endl;
    return 0;
}

Measured memory_bytes: 256
# -*- coding: utf-8 -*-
K, A, B = map(int, input().split(' '))

n1 = 1 + K

m = (K - A + 1) // 2
if m <= 0:
    print(n1)
    exit()

n2 = A + (B - A) * m
n2 +=  (K - A + 1) - (2 * m)

print(max(n1, n2))






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

typedef long long ll;
typedef unsigned int uint;
typedef unsigned long long ull;
static const double EPS = 1e-12;
static const double PI = acos(-1.0);

template <class T>
using V = vector<T>;
template <class T>
using VV = V<V<T>>;

#define FOR(i, a, b) for (int i = (int)(a); i < (int)(b); i++)
#define REP(i, n) for (int i = 0; i < (int)(n); i++)
#define ALL(a) (a).begin(), (a).end()
#ifdef LOCAL
#define dbg(x) cerr << __LINE__ << " : " << #x << " = " << (x) << endl
#else
#define dbg(x) true
#endif

void solve(long long N, long long X, long long T) {
  cout << (N + X - 1) / X * T << endl;
}

int main() {
  long long N;
  scanf("%lld", &N);
  long long X;
  scanf("%lld", &X);
  long long T;
  scanf("%lld", &T);
  solve(N, X, T);
  return 0;
}


Measured memory_bytes: 3760
#include<iostream>

using namespace std;

int main ()
{
int H,N;
int A[100000];
cin>>H>>N;
for (int i=0;i<N;i++){
	

cin>>A[i];
}
for (int i=0; i<N;i++){
	
H-=A[i];
}
if (H>0)
cout<<"No"<<endl;

else
cout<<"Yes";

return 0;
}

Measured memory_bytes: 640
#include<iostream>
#include<cmath>
#include<algorithm>
#include<string>
#include<vector>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef pair<int,P> P1;
typedef pair<P,P> P2;
#define pu push
#define pb push_back
#define mp make_pair
#define eps 1e-7
#define INF 1000000000
#define fi first
#define sc second
#define rep(i,x) for(int i=0;i<x;i++)
#define repn(i,x) for(int i=1;i<=x;i++)
#define SORT(x) sort(x.begin(),x.end())
#define ERASE(x) x.erase(unique(x.begin(),x.end()),x.end())
#define POSL(x,v) (lower_bound(x.begin(),x.end(),v)-x.begin())
#define POSU(x,v) (upper_bound(x.begin(),x.end(),v)-x.begin())

const int MAX = 510000;
const int MOD = 1000000007;

int main(){
  ll N,Z,W;cin>>N>>Z>>W;
  ll i,j,k,l;
  vector<ll> a(N);
  rep(i,N) cin>>a[i];
  if(N==1) cout<<abs(a[N-1]-W)<<endl;
  else{
    ll score = max(abs(a[N-1]-W),abs(a[N-1]-a[N-2]));
    cout<<score<<endl;
  }



}


Measured memory_bytes: 256
import std.stdio,std.ascii,std.conv,std.string,std.algorithm,std.range,std.functional,std.math,core.bitop;

void main(){
    auto ar=array(map!(to!int)(readln().strip().split()));
    int count=0;
    int[] b;
    foreach(i,n;ar){
        b~=n;
    }
    while(true){
        if(array(ar.filter!(a=>ar.reduce!"min(a,b)"==a)).length==3){
            break;
        }
        foreach(ref n;b){
            if(array(ar.filter!(a=>ar.reduce!"min(a,b)"==a)).length==2){
                if(n==ar.reduce!"min(a,b)"){
                    n+=1;
                }
            }else{
                if(n==ar.reduce!"min(a,b)"){
                    n+=2;
                }
            }
        }
        foreach(i,n;b){
            ar[i]=n;
        }
        count++;
    }
    writeln(count);
    
}

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

int main() {
    int n,q;
    string s;
    cin >> n >> q >> s;
    vector<int> l(q),r(q);
    for(int i = 0; i < q; i++)
    {
        cin >> l.at(i) >> r.at(i);
    }
    vector<int> sum((int)s.size() + 1);
    int g = 0;
    for(int i = 0; i < (int)s.size() - 1; i++)
    {
        if (s.at(i) == 'A' && s.at(i + 1) == 'C') {
            g++;
        }
        sum.at(i + 2) = g;
    }
    for(int i = 0; i < q; i++)
    {
        cout << sum.at(r.at(i)) - sum.at(l.at(i)) << endl;
    }
}

Measured memory_bytes: 2176
import numpy as np

def gcd(a,b):
    while b:
        a,b = b,a%b
    return a

def lcm(a,b):
    return a*b//gcd(a,b)


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

x = list(map(int,input().split()))

x.append(xx)

x.sort()

y = []

for i in range(len(x)-1):
    y.append(x[i+1]- x[i])


ans = y[0]
for i in range(1,len(y)):
    ans = gcd(ans,y[i])

print(ans)



Measured memory_bytes: 23076
def factorization(n):
    arr = []
    temp = n
    for i in range(2, int(-(-n**0.5//1))+1):
        if temp%i==0:
            cnt=0
            while temp%i==0:
                cnt+=1
                temp //= i
            arr.append([i, cnt])

    if temp!=1:
        arr.append([temp, 1])

    if arr==[]:
        arr.append([n, 1])

    return arr
  
##############################################  
from math import factorial
N=int(input())
if N==1:
  print(0)
else:
  ans=0
  a=factorization(N)
  for b in a:
    p=1
    for i in range(1,10**18):
      if i*(i+1)//2 <=b[1]:
        p=i
      else:
        break
    #print(p)
    ans +=p
  print(ans)

Measured memory_bytes: 9500
#include <algorithm>
#include <iostream>
#include <vector>
#include <cassert>
using namespace std;
template<class T> ostream& operator<<(ostream& os, const vector<T>& vec) { for (auto &vi: vec) os << vi << " "; return os; }

int main() {
    int n; cin >> n;
    vector<int> x(n), y(n);
    for (int i = 0; i < n; i++) cin >> x[i] >> y[i];
    bool pari = (abs(x[0]) + abs(y[0])) % 2;
    for (int i = 0; i < n; i++) {
        if ((abs(x[i]) + abs(y[i])) % 2 != pari) return !(cout << -1 << endl);
    }
    vector<int> ds;
    for (int i = 30; i >= 0; i--) ds.emplace_back(1 << i);
    if (!pari) ds.emplace_back(1);
    cout << ds.size() << endl << ds << endl;
    for (int i = 0; i < n; i++) {
        int gx = x[i], gy = y[i];
        int cx = 0, cy = 0;
        for (int d: ds) {
            if (abs(cx - gx) >= abs(cy - gy)) {
                if (cx >= gx) cx -= d, cout << "L";
                else cx += d, cout << "R";
            } else {
                if (cy >= gy) cy -= d, cout << "D";
                else cy += d, cout << "U";
            }
        }
        cout << endl;
        assert(cx == gx && cy == gy);
    }
    return 0;
}


Measured memory_bytes: 256
var
        x:array[1..10,0..20]of longint;
        n,m,o,p,k,l,i,j:longint;
begin
        read(n,m);
        for i:=1 to n do
                for j:=1 to m do read(x[i,j]);
        for i:=1 to n do
                for j:=i+1 to n do
                begin
                        p:=0;
                        for k:=1 to m do
                        begin
                                p:=p+sqr(x[i,k]-x[j,k]);
                        end;
                        if sqrt(p)=trunc(sqrt(p)) then o:=o+1;
                end;
        writeln(o);
end.

Measured memory_bytes: 128
N, K = map(int, input().split())
L = list(map(int, input().split()))
dic = {}
for i in range(N):
    dic.setdefault(L[i], 0)
    dic[L[i]] += 1

cnt = len(dic.keys())
tmp = 0
if cnt <= K:
    print(0)
else:
    for k, v in sorted(dic.items(), key = lambda x:x[1]):
        tmp += v
        cnt -= 1
        if cnt <= K:
            break
    print(tmp)

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

using namespace std;

#define ll long long

int main(){
    int n,x,sum=0;
    cin>>n>>x;
    int a[n];
    for(int i=0; i<n; i++){
        cin>>a[i];
        sum=sum+a[i];
    }
    sort(a,a+n);
    int c=(x-sum)/a[0];
    cout<<n+c<<endl;


}


    



Measured memory_bytes: 256
//Circle Pond
#include <iostream>
#include <vector>
#include <math.h>
#include <string>
#include <map>
#include <stdio.h>
#include <string.h>
#include <initializer_list>
#include <algorithm>
#include <numeric>
#include <iomanip>
#include <queue>
#include <set>
using namespace std;
const int INF = 1 << 29;
int main ()
{
    double R;
    cin >> R;
    printf("%.10f", (double)R * 3.14159265359f * 2.0f);
    return 0;
}

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

using namespace std;

int main(){
    int N, K;
    cin >> N >> K;
    vector<int> h;
    int data;

    while(cin >> data) h.push_back(data);
    sort(h.begin(), h.end(), greater<int>());

    vector<int> diff;

    for(int i = 0; i+K-1 < N; i++){
        diff.push_back(h[i] - h[i+K-1]);
    }

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

    cout << diff[0] << endl;

}


Measured memory_bytes: 1400
/*
title:

url:
*/

#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <functional>
#include <queue>
#include <limits>
#include <string>
#include <utility>
#include <cstring>
#include <map>
#include <cmath>
#include <iterator>

using namespace std;

#define rep(i, n) for (int i = 0; i < (n); i++)
#define INF 1000000007

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

int main()
{
    int n, a, b;
    cin >> n >> a >> b;
    int ans = 0;
    for (int i = 1; i <= n; i++)
    {
        string tmp = to_string(i);
        int tmp_sum = 0;
        rep(i, tmp.size())
        {
            tmp_sum += tmp[i] - '0';
        }
        if (tmp_sum >= a && tmp_sum <= b)
        {
            ans += i;
        }
    }

    cout << ans << endl;
}

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


int main() {
	size_t a[3];
	std::cin >> a[0] >> a[1] >> a[2];
	std::sort(std::begin(a), std::end(a));
	bool f = std::count_if(std::begin(a), std::end(a), [](auto x) {
		return  x % 2 == 0;
	});
	if (f) {
		std::cout << "0\n";
	}
	else {
		std::cout<<a[0] * a[1] << "\n";
		
	}
	//std::cout << a[0] << a[2] << "\n";

	return 0;
}

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

#define LSOne(S) ((S) & (-S))

#define EPS 1e-6
#define MOD 1000000007

#define fi first
#define se second
#define pb push_back
#define ende '\n'

#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define mset(x, y) memset(&x, (y), sizeof(x))

using ll = long long;
using ii = pair<int, int>;
using vi = vector<int>;

int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  int n;
  cin >> n;
  int i;
  if (n == 1) return cout << "Yes" << ende, 0;
  for (i = 2; i < 10; i++) {
    if ((n % i == 0) && (n/i < 10))
      return cout << "Yes" << ende, 0;
  }
  cout << "No" << ende;
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define SaveTime ios_base::sync_with_stdio(false);cin.tie(NULL);
#define pb push_back 
#define eb emplace_back
#define fn for(int i =0 ;i <n;i++)
#define fn1 for( int i =1;i<=n;i++)
#define fm for(int j =0 ;j <m;j++)
#define fm1 for(int j =1;j<=m;j++)
#define fi first
#define se second
#define MOD 1000000007
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(),v.rend()
const int N = 1e2+5;
int ar[N];
int dp[N];

signed main(){
 	// #ifndef ONLINE_JUDGE
 	// freopen("input.txt","r",stdin);
 	// freopen("output.txt","w",stdout);
 	// #endif
	SaveTime;
	int T=1;
	// cin >> T;
	while(T--){
		int n ;
		cin >> n ;
		fn{
			int x ;
			cin  >> x;
			int j=0;
			while(x!=0){
				dp[j]+=x%2;
				x/=2;
				j++;
			}
		}
		int k=1;
		int ans=0;
		for(int i=0;i<61;i++){
			int now=dp[i];
			now=now*(n-now);
			now%=MOD;
			now*=k;
			ans+=now;
			k*=2;
			k%=MOD;
			ans%=MOD;
		}
		cout <<ans;
	}
	
    cerr << "Time elapsed : " << 1.0 * clock() / CLOCKS_PER_SEC << " sec \n";
	return 0;
}


Measured memory_bytes: 256
object Main extends App {
  val in = scala.io.Source.stdin.getLines.toSeq
  val ls = in.map(_.toInt)
  val sl = ls.sortBy(e => (e + 9) % 10)
  val dl = sl.tail.map(e=> (e + 9) / 10 * 10)
  val ret = dl.sum + sl.head  
  println(ret)
}


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

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int A, B;
    cin >> A >> B;
    ll answer = A;
    if (A > B)
    {
        answer--;
    }
    cout << answer << endl;
    return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String S1 = sc.next();
		String S2 = sc.next();
		String S3 = sc.next();
		sc.close();
		System.out.printf("%c%c%c\n", S1.charAt(0), S2.charAt(0), S3.charAt(0));
	}
}

Measured memory_bytes: 21844
#include<stdio.h>
  int N,M,Q,max=0;
  int a[55],b[55],c[55],d[55];
  int A[15];
  int check(){
    int ans=0;
    for(int i=1;i<=Q;i++){
      if(A[b[i]]-A[a[i]]==c[i]){
        ans+=d[i];
      }
    }
    return ans;
  }//問題文の条件をチェックする、これをするためにA[i]を別のところで作成する必要がある
  void make(int i,int t){
    if(i==N+1){
      int x=check();//作成されたA[i]が長さNを満たした時関数checkに移行する
      if(x>max){
        max=x;
      }//返ってきたd[i]の総和をmaxと比較
      return ;
    }
    for(int j=t;j<=M;j++){//再帰でA[i]を作成している全探索の際に用いる？
      A[i]=j;
      make(i+1,j);
    }
  }
  int main(){
    scanf("%d%d%d",&N,&M,&Q);
    int i=1;
    for(i=1;i<=Q;i++){
      scanf("%d%d%d%d",&a[i],&b[i],&c[i],&d[i]);
    }
    make(1,1);
    printf("%d",max);
    return 0;
  }

Measured memory_bytes: 1700
#include<cmath>
#include<iostream>
#include<algorithm>
#include<iomanip>
#include<vector>
#include<string>
#include<queue>
#include<stack>
#include<cstdio>
#include<map>
#define rep(i,n) for(int i=0;i<n;i++)
#define fori(i,k,n) for(int i=k;i<n;i++)
using namespace std;
const int dx[4] = { 0, 1, 0, -1 }, dy[4] = { 1, 0, -1, 0 };
const int dX[8] = { 0, 1, 1, 1, 0, -1, -1, -1 }, dY[8] = { 1, 1, 0, -1, -1, -1, 0, 1 };
/*
(char)'1' - (int)48 = (int)1; 


*/


int main()
{

	int n, m, p;
	cin >> n >> m >> p;
	while (n != 0|| m != 0 || p != 0)
	{
		int a[110];
		double al = 0;
		for (int i = 0; i < n; i++)
		{
			cin >> a[i];
			al += a[i]*100;
		}
		al = al*(100-p)/100;
		if (a[m - 1] == 0)
		{
			cout << 0 << endl;
		}
		else
		{
			al /= a[m - 1];
			int ans = al;
			cout << ans << endl;
		}



		cin >> n >> m >> p;
	}
}

Measured memory_bytes: 1160
#include <iostream>
#include <string>
#include <cmath>
#include<algorithm>
#include<stack>
#include<queue>
#include<map>
#include<set>
#include<iomanip>
#define _USE_MATH_DEFINES
#include <math.h>
#include <functional>
using namespace std;

#define rep(i,x) for(ll i=0;i<x;i++)
#define repn(i,x) for(ll i=1;i<=x;i++)

typedef long long ll;
const ll INF = 1e17;
const ll MOD = 1000000007;
const ll MAX = 1000001;

ll max(ll a, ll b) {
	if (a > b) { return a; }
	return b;
}

ll min(ll a, ll b) {
	if (a > b) { return b; }
	return a;
}

ll gcd(ll a, ll b) {
	if (b == 0) { return a; }
	if (a < b) { return gcd(b, a); }
	return gcd(b, a % b);
}

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

struct edge {
	ll ind;
	ll fr;
	ll to;
	ll d;
};

class mint {
    long long x;
public:
    mint(long long x = 0) : x((x% MOD + MOD) % MOD) {}
    mint operator-() const {
        return mint(-x);
    }
    mint& operator+=(const mint& a) {
        if ((x += a.x) >= MOD) x -= MOD;
        return *this;
    }
    mint& operator-=(const mint& a) {
        if ((x += MOD - a.x) >= MOD) x -= MOD;
        return *this;
    }
    mint& operator*=(const  mint& a) {
        (x *= a.x) %= MOD;
        return *this;
    }
    mint operator+(const mint& a) const {
        mint res(*this);
        return res += a;
    }
    mint operator-(const mint& a) const {
        mint res(*this);
        return res -= a;
    }
    mint operator*(const mint& a) const {
        mint res(*this);
        return res *= a;
    }
    mint pow(ll t) const {
        if (!t) return 1;
        mint a = pow(t >> 1);
        a *= a;
        if (t & 1) a *= *this;
        return a;
    }
    // for prime MOD
    mint inv() const {
        return pow(MOD - 2);
    }
    mint& operator/=(const mint& a) {
        return (*this) *= a.inv();
    }
    mint operator/(const mint& a) const {
        mint res(*this);
        return res /= a;
    }

    friend ostream& operator<<(ostream& os, const mint& m) {
        os << m.x;
        return os;
    }
};

///////////////////////////


int main() {
    ll N, M;
    string S, T;
    cin >> N >> M >> S >> T;

    ll L = lcm(N, M);
    ll X = L / N;
    ll Y = L / M;

    ll b = 1;
    rep(i, N) {
        if (X * i % Y != 0) { continue; }
        if (S[i] != T[X * i / Y]) { b = 0; }
    }
    
    if (b == 1) { cout << L; }
    else { cout << -1; }
	
	system("PAUSE");
}


Measured memory_bytes: 760
#pragma GCC optimize("Ofast")
#include<bits/stdc++.h>
//#include<boost/multiprecision/cpp_int.hpp>
//#include<boost/multiprecision/cpp_dec_float.hpp>
//namespace mp=boost::multiprecision;
//#define mulint mp::cpp_int
//#define mulfloat mp::cpp_dec_float_100
using namespace std;
struct __INIT{__INIT(){cin.tie(0);ios::sync_with_stdio(false);cout<<fixed<<setprecision(15);}} __init;
#define max3(a,b,c) max(a,max(b,c))
#define min3(a,b,c) min(a,min(b,c))
constexpr int MOD=1000000007;
//constexpr int MOD=998244353;
#define INF (1<<30)
#define LINF (lint)(1LL<<56)
#define endl "\n"
#define rep(i,n) for(lint (i)=0;(i)<(n);(i)++)
#define reprev(i,n) for(lint (i)=(n-1);(i)>=0;(i)--)
#define Flag(x) (1<<(x))
#define Flagcount(x) __builtin_popcountll(x)
#define pint pair<int,int>
#define pdouble pair<double,double>
#define plint pair<lint,lint>
#define fi first
#define se second
typedef long long lint;
int dx[8]={1,1,0,-1,-1,-1,0,1};
int dy[8]={0,1,1,1,0,-1,-1,-1};
const int MAX_N=2e5+5;
//struct edge{lint to,num;};

multiset<lint> decomp(lint N){
    multiset<lint> res;
    lint num=N;
    for(lint i=2;i*i<=num;i++){
        while(N%i==0) N/=i,res.insert(i);
        if(N==1) break;
    }
    if(N!=1) res.insert(N);
    return res; 
}

int main(void){
    lint N,P;
    cin >> N >> P;
    multiset<lint> res=decomp(P);
    lint ans=1;
    while(!res.empty()){
        auto itr=res.begin();
        lint cnt=res.count(*itr);
        while(cnt>=N) cnt-=N,ans*=*itr;
        res.erase(*itr);
    }
    cout << ans << endl;
}


Measured memory_bytes: 3644
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for( int i = 0 ; i < n ; i++ )
typedef long long ll ;
int main() {
  ll ans = 0 ;
  string S ;
  cin >> S ;
  string T ;
  rep(i,1<<S.size()-1){
  	rep(j,S.size()){
    	T += S[j] ;
    	if( i>>j & 1){
      		ans += stoll(T) ;
      		T = "" ;
    	}
    }
    ans += stoll(T) ;
    T = "" ;
  }
  cout << ans << endl;
}

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

int main(){
  stack<int>s1;
  stack<pair<int,int>>s2;
  int ans=0;
  char c;
  for(int i=0;cin>>c;i++){
    if(c=='\\'){
      s1.push(i);
    }
    else if(c=='/'&&s1.size()>0){
      int j=s1.top();s1.pop();
      int a=i-j;
      ans+=a;
      while(s2.size()>0&&s2.top().first>j){
        a+=s2.top().second;s2.pop();
      }
      s2.push(make_pair(i,a));
    }
  }
  cout <<ans<<endl;
  vector<int>w;
  while(s2.size()){
    w.push_back(s2.top().second);s2.pop();
  }
  cout << w.size();
  reverse(w.begin(),w.end());
  for(int i=0;i<w.size();i++){
    cout << " ";
    cout << w[i];
  }
  cout <<endl;
}


Measured memory_bytes: 3232
#include<stdio.h>
#include<algorithm>
using namespace std;
pair<int,int> unagi[1000000];
pair<int,int> wolf[1000000];
int u_row[500];
int u_col[500];
int w_row[500];
int w_col[500];
int main(){
	int a,b,c,d;
	scanf("%d%d%d%d",&a,&b,&c,&d);
	for(int i=0;i<1000000;i++){
		unagi[i]=make_pair(-1,-1);
		wolf[i]=make_pair(-1,-1);
	}
	for(int i=0;i<a;i++)
		for(int j=0;j<a;j++){
			int p;
			scanf("%d",&p);
			unagi[p-1]=make_pair(i,j);
		}
	for(int i=0;i<a;i++)
		for(int j=0;j<a;j++){
			int p;
			scanf("%d",&p);
			wolf[p-1]=make_pair(i,j);
		}
	int UL=0;
	int UR=0;
	int WL=0;
	int WR=0;
	int u=0;int w=0;
	if(a==1){
		for(int i=0;i<d;i++){
			int e;
			scanf("%d",&e);e--;
			if(~unagi[e].first)u++;
			if(~wolf[e].first)w++;
		if(u>=b&&w>=c){
			printf("DRAW\n");
			return 0;
		}
		if(u>=b){
			printf("USAGI\n");
			return 0;
		}
		if(w>=c){
			printf("NEKO\n");
			return 0;
		}
		}
		printf("DRAW\n");
		return 0;
	}
	for(int i=0;i<d;i++){
		int e;
		scanf("%d",&e);e--;
		if(~unagi[e].first){
			u_row[unagi[e].first]++;
			if(u_row[unagi[e].first]==a)u++;
			u_col[unagi[e].second]++;
			if(u_col[unagi[e].second]==a)u++;
			if(unagi[e].first==unagi[e].second){
				UL++;
				if(UL==a)u++;
			}
			if(unagi[e].first+unagi[e].second==a-1){
				UR++;
				if(UR==a)u++;
			}
		}
		if(~wolf[e].first){
			w_row[wolf[e].first]++;
			if(w_row[wolf[e].first]==a)w++;
			w_col[wolf[e].second]++;
			if(w_col[wolf[e].second]==a)w++;
			if(wolf[e].first==wolf[e].second){
				WL++;
				if(WL==a)w++;
			}
			if(wolf[e].first+wolf[e].second==a-1){
				WR++;
				if(WR==a)w++;
			}
		}
		if(u>=b&&w>=c){
			printf("DRAW\n");
			return 0;
		}
		if(u>=b){
			printf("USAGI\n");
			return 0;
		}
		if(w>=c){
			printf("NEKO\n");
			return 0;
		}
	}
	printf("DRAW\n");
}

Measured memory_bytes: 16640
#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
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <iomanip>
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
#include <math.h>
#include <stdlib.h>
#include <stdio.h>
using namespace std;
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; }
const int INF = 1000000000;
const int MOD = 1000000007;

typedef pair<int, int> P;
int myAbs(int num) {
    if (num > 0)
        return num;
    else
        return -num;
}

long long gcd(long long a, long long b) {
    if (b == 0) return a;
    else return gcd(b, a % b);
}
long long lcm(long long a, long long b) {
    return a * b / gcd(a, b);
}

using Graph = vector<vector<int>>;
//再帰とかグラフを使うときは予めNの最大値のグローバル配列を取っておく
int N;
bool E[101][101];
vector<bool> seen;
typedef pair<int, int> P;
int D[101];
int F[101];
//頂点状態を表すcolor[]において、0は未訪問、1は訪問中、2は完了を表す。
int color[101];
int find_time = 0;

void dfs_search(int u) {
    //出発点を訪問済みにする＆行きのタイムスタンプを記録
    int v;

    color[u] = 1;
    D[u] = ++find_time;
    //cout << u+1 << " " << color[u] << " " << endl;
    for (v = 1; v <= N; v++) {
        //出発点からvへの辺があるか
        if (!E[u][v]) continue;
        //辺がある&&未訪問なら発見した頂点を出発点にして再帰
        if (color[v] == 0) dfs_search(v);
    }
    //今回訪問した頂点より深い未訪問の頂点がない時にその頂点を完了する。
    color[u] = 2;
    F[u] = ++find_time;
}

void dfs() {
    int u;
    find_time = 0;
    for (int i = 0; i < N; i++) color[i] = 0;
    for (u = 1; u <= N; u++) {
        //未訪問のuを出発点にしてDFS
        if (color[u] == 0 || color[u] == 1) dfs_search(u);
    }
    //出力
    for (int i = 1; i <= N; i++) {
        cout << i << " " << D[i] << " " << F[i] << endl;
    }
}

int main() {
    //boolで辺を管理
    cin >> N;
    int u, k;
    for (int i = 1; i <= N; i++) {
        for (int j = 1; j <= N; j++) {
            E[i][j] = false;
        }
        D[i] = 0;
        F[i] = 0;
    }

    //辺の配列E[][]において、falseは無辺、trueは有辺を表す。
    //有向グラフなのでE[i][j]のみ(無向だとE[j][i]も)
    for (int i = 1; i <= N; i++) {
        cin >> u >> k;
        for (int j = 0; j < k; j++) {
            int v; cin >> v;
            //v--;
            //u--;
            E[u][v] = true;
        }
    }

    dfs();

}



Measured memory_bytes: 3120
#include <stdio.h>

int partition(int *,int,int);

int main(){
  int c,i,n,A[100000];
  
  scanf("%d", &n);
  
  if(n < 1 || n > 100000)return 0;
   for(i = 0; i < n; i++){
     scanf("%d", &A[i]);
     if(A[i] < 0 || A[i] > 100000)return 0;
   }
  c = partition(A,0,n-1);
  
  for(i = 0; i < n; i++){
    if(i > 0)printf(" ");
    
    if(i == c)printf("[%d]",A[c]);
    else printf("%d",A[i]);
  }
   printf("\n");
  return 0;
}

int partition(int A[],int p,int r){
  int c,x,i,j;
  i = p-1;
  x = A[r];
  
  for(j = p; j < r;j++){
    if(A[j] <= x){
      i += 1;
      c = A[j];
      A[j] = A[i];
      A[i] = c;
    }
  }
  c = A[i+1];
  A[i+1] = A[r];
  A[r] = c;

  return i+1;
}



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

int main(){
int A , B , C , D , i;
cin >> A >> B >> C >> D;

for(i = 1; i < 1000; i++){

if(C - B > 0){
    C = C - B;
}
else{
    cout << "Yes" << endl;
    break;
}

if(A - D > 0){
    A = A - D;
}
else{
    cout << "No" << endl;
    break;
}
}
}

Measured memory_bytes: 3636
import java.util.Scanner;
 
class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        int b = sc.nextInt();
        int x = sc.nextInt();
        double p = (2.0 * a*a*b-2.0*x)/(1.0*a*a);
        double radian = Math.atan(p/a);
        if(a*a*b / 2.0 > x)
            radian = Math.PI / 2.0 - Math.atan(2.0*x/(a*b*b));
        System.out.println(Math.toDegrees(radian));
    }
}

Measured memory_bytes: 22732
#include <iostream>
#include <cstring>
#include <cstdlib>
#include <set>
#include <vector>
#include <map>
#include <cstdio>
#include <utility>
#include <algorithm>
#include <cmath>
#include <queue>
#include <stack>
#include <cassert>
#include <climits>
using namespace std;
typedef long long ll;
#define DEBUG
#ifdef DEBUG
	#define debug printf
#else
	#define debug(...)
#endif
int main(int argc, char const *argv[])
{
	string s;
	cin>>s;
	if(s[0] == s[1] || s[1] == s[2] || s[2] == s[3])
	{
		printf("Bad\n");
	}
	else
	{
		printf("Good\n");
	}
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
typedef long long ll;
typedef pair<int,int> P;
 
const int INF = 1e9;
const int mod = 1e9+7;
 
int dx[] = {0,1,0,-1};
int dy[] = {1,0,-1,0};

int main()
{
    int h,w;
    cin >> h >> w;
    char s[55][55];
    for(int i = 0; i < h; i++){
        for(int j = 0; j < w; j++){
            cin >> s[i][j];
        }
    }
 
    for(int i = 0; i < h; i++){
        for(int j = 0; j < w; j++){
            if(s[i][j] == '#'){
                int flag = 1;                         
                for(int k = 0; k < 4; k++){
                    int x = j + dx[k],y = i + dy[k];
                    if(0 <= x && x < w && 0 <= y && y < h && s[y][x] == '#') flag = 0;

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

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<algorithm>
#include<set>
#include<map>
#include<vector>
#include<stack>
#include<queue>
#include<cmath>
#include<numeric>
using namespace std;

int search(int a,int b){
    if(a%b==0){return b;}
    else{return search(b,a%b);}
}


int main(){
    int x,y;
    cin>>x>>y;
    int c=search(x,y);
    cout<<c<<endl;
    
    return 0;
}



Measured memory_bytes: 3080
from fractions import gcd

N, X = map(int, input().split())
x = list(sorted(list(map(int, input().split())) + [X]))
d = []
for a, b in zip(x, x[1:]):
  d.append(b - a)
g = 0
for v in d:
  g = gcd(g, v)
print(g)

Measured memory_bytes: 16280
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(ll i = 0; i < n; i++)
#define rep1(i, n) for(ll i = 1; i < n+1; i++)
#define all(A) A.begin(),A.end()
typedef long long ll;

int main(){
  ll n;
  ll k;
  cin >> n >> k;
  vector<ll> a(n);
  rep(i,n){
    cin >> a[i];
  }
  sort(all(a));
  const ll INF = (ll)pow(10,18)+1;
  ll xng = INF;//xng...無限大だと絶対オーバー
  ll xok = -INF;//xok...無限小だと絶対ok
  //お気持ち...なるべくオーバーしたくない。k未満だったらok。
  while(abs(xok-xng)>1){
    ll xmid = (xok+xng)/2;
    ll cnt = 0;//okだった数を数える
    rep(i,n){
      ll ng;
      ll ok;
      //a[i]*a[mid]がxmid未満だったらok
      if(a[i] < 0){
        ng = i;
        ok = n;//なるべく少なくしたいから相手は最大
      }
      if(a[i] >= 0){
        ng = n;
        ok = i;//なるべく少なくしたいから相手は最小
      }
      while(abs(ok-ng)>1){
        ll mid = (ok+ng)/2;
        if(a[i]*a[mid] < xmid) ok = mid;
        else ng = mid;
      }
      if(a[i] < 0) cnt += n-ok;//okな範囲は右側
      else cnt += ok-i;//okな範囲は左側
    }//i
    if(cnt < k) xok = xmid;
    else xng = xmid;
  }//while
  cout << xok << endl;
}

Measured memory_bytes: 4724
PROGRAM piyo
      IMPLICIT NONE
      integer(16) :: n
      integer(16),allocatable :: a(:),counter(:),memo(:)
      integer(16) :: i,mm,buffer,memo2
      
      read*,n
      allocate( a(n),counter(n),memo(n) )
      read*,a(:)
      
      counter = 0
      do i = 1,n
        counter( a(i) ) = counter( a(i) ) + 1
      end do
      
      do i = 1,n
        mm = counter(i)
        memo( i ) = mm*(mm-1)/2
      end do
      memo2 = sum( memo )
      
      
      do i = 1,n
        mm = counter(a(i))
        buffer = memo2
        buffer = buffer - mm*(mm-1)/2
        mm = mm-1
        buffer = buffer + mm*(mm-1)/2
        print*,buffer
      end do
      
      
      
      
      END PROGRAM

Measured memory_bytes: 12672
#include<stdio.h>
#include<stdlib.h>

typedef long long llint;

int revcmp(const void *a,const void *b){
    return *(llint*)a - *(llint*)b ? *(llint*)a > *(llint*)b ? -1 : 1 : 0;
}

int main(void){
    register int i,j;
    int x,y,z,k;
    scanf("%d %d %d %d",&x,&y,&z,&k);
    llint a[x],b[y],c[z];
    for(i = 0;i < x;i++)scanf("%lld",&a[i]);
    for(i = 0;i < y;i++)scanf("%lld",&b[i]);
    for(i = 0;i < z;i++)scanf("%lld",&c[i]);
    llint ab[x*y];
    int abp = 0;
    for(i = 0;i < x;i++)for(j = 0;j < y;j++){
        ab[abp] = a[i] + b[j];
        abp++;
    }
    qsort(ab,x*y,sizeof(llint),revcmp);
    llint abc[(k < x*y ? k : x*y)*z];
    int abcp = 0;
    for(i = 0;i < (k < x*y ? k : x*y);i++)for(j = 0;j < z;j++){
        abc[abcp] = ab[i] + c[j];
        abcp++;
    }
    qsort(abc,(k < x*y ? k : x*y)*z,sizeof(llint),revcmp);
    for(i = 0;i < k;i++)printf("%lld\n",abc[i]);
}

Measured memory_bytes: 54908
#include <bits/stdc++.h>
#define rep(i,n) for (int i=0; i<(n); ++i)
using namespace std;
using ll=long long;
int main(){
    int n,k,x,y;
    cin>>n>>k>>x>>y;
    int ans=n*x;
    if(n>k){
        ans-=(n-k)*(x-y);
    }
    cout<<ans<<endl;
}

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

typedef long long                   ll;
typedef long double                 ld;
typedef pair<ll,ll>                 pll;
typedef pair<ld,ld>                 pld;


#define all(x)          (x).begin(),(x).end()
#define Sort(x)         sort(all(x))
#define sep             ' '
#define endl            '\n'
#define tab             '\t'
#define X               first
#define Y               second
#define fast_io         ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define file_io         freopen("in.txt" , "r" , stdin) ; freopen("out.txt" , "w" , stdout);
#define set_random      mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count());
const ll MOD = 1e9 + 7,
         MAXN= 1e6+10,
         INF=1e18;
ll dp[110][MAXN],n,w,ans=-1;
pll a[MAXN];
int main()
{
    fast_io;
    cin>>n>>w;
    for(ll i=1;i<=n;i++){
        cin>>a[i].X>>a[i].Y;
    }
    dp[0][0]=0;
    for(ll i=1;i<=n;i++){
        for(ll j=0;j<=MAXN;j++){
            dp[i][j]=dp[i-1][j];
            if(a[i].X<=j){
                dp[i][j]=max(dp[i-1][j],dp[i-1][j-a[i].X]+a[i].Y);
            }
        }
    }
    for(ll i=1;i<=w;i++)ans=max(ans,dp[n][i]);
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 784640
#include <iostream>
using namespace std;
static const int N = 100000;

int main() {
    int n;
    int A[N];
    long long int ans = 0;
    int pre = 0, b;
    int rest;

    cin >> n;
    for (int i = 0; i < n + 1; i++) cin >> A[i];
    for (int i = 0; i < n; i++) {
        if (pre > 0) {
            ans += (pre - A[i] >= 0 ? A[i] : pre);
            A[i] -= pre;
        }
        cin >> b;
        if (A[i] > 0) {
            rest = b - A[i];
            ans += (rest >= 0 ? A[i] : b);
            pre = (rest > 0 ? rest : 0);
        } else {
            pre = b;
        }
    }
    ans += (pre - A[n] > 0 ? A[n] : pre);

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 640
/*  -*- coding: utf-8 -*-
 *
 * 1587.cc: Plants
 */

#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<iostream>
#include<string>
#include<vector>
#include<map>
#include<set>
#include<stack>
#include<list>
#include<queue>
#include<deque>
#include<algorithm>
#include<numeric>
#include<utility>
#include<complex>
#include<functional>
 
using namespace std;

/* constant */

const int MAX_W = 50;
const int MAX_H = 50;

/* typedef */

/* global variables */

int flds[MAX_H][MAX_W];

/* subroutines */

/* main */

int main() {
  int w, h, t, p;
  scanf("%d%d%d%d", &w, &h, &t, &p);

  for (int i = 0; i < p; i++) {
    int xi, yi, ti;
    scanf("%d%d%d", &xi, &yi, &ti);
    flds[yi][xi]++;
  }

  int sum = 0;
  for (int y = 0; y < h; y++)
    for (int x = 0; x < w; x++) {
      int s;
      scanf("%d", &s);
      if (s) sum += flds[y][x];
    }

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



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

using namespace std;

const int N = 3e3+7;

int n, t, res;
int dp[N][N];

struct Node
{
    int a, b;
    friend bool operator < (const Node &x, const Node &y) {
        return x.a < y.a;
    }
} c[N];

int main()
{
    cin >> n >> t;
    for (int i = 1; i <= n; ++i)
        cin >> c[i].a >> c[i].b;
    sort(c+1, c+n+1);
    for (int i = 1; i <= n; ++i) {
        for (int j = 0; j < t; ++j) {
            dp[i][j] = dp[i-1][j];
        }
        for (int j = c[i].a; j < t; ++j) {
            dp[i][j] = max(dp[i-1][j], dp[i-1][j-c[i].a]+c[i].b);
        }
        dp[i][t] = max(dp[i-1][t], dp[i-1][t-1]+c[i].b);
    }
    cout << dp[n][t] << endl;
    return 0;
}


Measured memory_bytes: 35456
# print('input >>')
N = input()
A = list(map(int,(input().split())))

A_tuple_list = []

for i in range(len(A)):
    A_tuple_list.append((i, A[i]))

A_tuple_list.sort(key= lambda x:x[1])

# print('----------output----------')
for a in A_tuple_list:
    print(a[0]+1, end=' ')

Measured memory_bytes: 19196
/*
　　　∫ ∫ ∫
　　　ノヽ
　　（＿　 ）
　（＿　　　 ）
（＿＿＿＿＿＿ ）
　ヽ(´･ω･)ﾉ　
　　 |　 /
　　 UU
*/
#include <bits/stdc++.h>
typedef long long ll;
using namespace std;
using P = pair<ll, ll>;
typedef vector<int> vi;
const int MOD = (int)1e9 + 7;
const ll INF = 1LL << 60;
const int inf = 1<<30;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
#define REP(i, n) for (int i = 0; i < (n); i++)
#define FOR(i,s,n) for (int i = s; i < (n); i++)
#define ALL(obj) (obj).begin(), (obj).end() //コンテナじゃないと使えない!!
#define debug(x) cerr << #x << ": " << x << "\n";
#define mp make_pair
template <typename T>
ostream& operator<<(ostream& os, vector<T> &V){
    int N = V.size();
    REP(i,N){
        os << V[i];
        if (i!=N-1) os << " ";
    }
    os << "\n";
    return os;
}
template <typename T>
ostream& operator<<(ostream& os, pair<T,T> const&P){
    os << P.first;
    os << " ";
    os << P.second;
    return os;
}
template <typename T>
ostream& operator<<(ostream& os, set<T> &S){
    auto it=S.begin();
    while(it!=S.end()){
        os << *it;
        os << " ";
        it++;
    }
    os << "\n";
    return os;
}
template <typename T>
ostream& operator<<(ostream& os, deque<T> &q){
    for(auto it=q.begin();it<q.end();it++){
        os<<*it;
        os<<" ";
    }
     os<<endl;
    return os;
}
vector<pair<int,int>> dxdy = {mp(0,1),mp(1,0),mp(-1,0),mp(0,-1)};
//fixed<<setprecision(10)<<ans<<endl;
//約数列挙
vector<ll> divs(ll n){
    ll copy = n;
    vector<ll> res;
    for(ll i=1;i*i<=copy;i++){
        if(n%i==0){
            res.push_back(i);
            // if(i*i!=N) res.push_back(N/i);
        }
    }
    return res;
}


int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll N;
    cin >> N;
    auto A = divs(N);
    
    int ans=inf;
    for(auto a:A){
        auto b = N/a;
        // cout << a << " " << to_string(a).size() << " " << to_string(b).size() << endl;
        chmin(ans, (int)max(to_string(a).size(), to_string(b).size()));
    }

    cout << ans << endl;
}

Measured memory_bytes: 256