akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <vector>

using namespace std;

bool valid(const string& s)
{
    int sum = 0;
    for (int i = 0; i < 11; i++) {
        if (i <= 4) {
            sum += (s[i] - '0') * (6 - i);
        } else {
            sum += (s[i] - '0') * (12 - i);
        }
    }
    
    sum %= 11;
    if (sum <= 1) sum = 11;
    return (11 - sum == (s[11] - '0'));
}

void solve(string& s)
{
    int j = -1;
    for (int i = 0; i < 12; i++) {
        if (s[i] == '?') {
            j = i;
            break;
        }
    }

    vector<int> res;
    for (int i = 0; i <= 9; i++) {
        s[j] = (char)('0' + i);

        if (valid(s)) {
            res.emplace_back(i);
        }
    }

    if (res.size() >= 2) {
        cout << "MULTIPLE" << endl;
    } else {
        cout << res[0] << endl;
    }
}

int main()
{
    string s;
    cin >> s;
    solve(s);
    return 0;
}

Measured memory_bytes: 3160
#include"iostream"
using namespace std;
void merge(int a[],int left,int mid,int right);
void mergesort(int a[], int left, int right);
int s = 0;
int main()
{
	int n;
	cin >> n;
	int* a = new int[n];
	for (int i = 0; i < n; ++i)
		cin >> a[i];
	mergesort(a, 0, n - 1);
	cout << a[0];
	for (int i = 1; i < n; ++i)
		cout<<' '<<a[i];
	cout << endl << s << endl;
	delete[]a;
	return 0;
}
void mergesort(int a[], int left, int right)
{
	if (left== right)return;
	int mid = (left + right)/2;
	mergesort(a, left, mid);
	mergesort(a, mid+1, right);
	merge(a, left, mid+1, right);
}
void merge(int a[], int left, int mid, int right)
{
	int* tmp = new int[right - left + 1];
	int i = left, j = mid, k = 0;
	while (i < mid && j <= right)
	{
		if (a[i] < a[j])tmp[k++] = a[i++];
		else tmp[k++] = a[j++];
		s++;
	}
	while (i < mid)
	{
		tmp[k++] = a[i++]; s++;
	}
	while (j <= right)
	{
		tmp[k++] = a[j++]; s++;
	}
	for (i = 0, k = left; k <= right;)a[k++] = tmp[i++];
	delete[]tmp;
}


Measured memory_bytes: 7712
import sys
sys.setrecursionlimit(2147483647)
INF=float("inf")
MOD=10**9+7
input=lambda :sys.stdin.readline().rstrip()
def resolve():
    n,m,x,y=map(int,input().split())
    max_x=max(map(int,input().split()))
    min_y=min(map(int,input().split()))
    print("No War" if x<min_y<=y and max_x<min_y else "War")
resolve()

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

string n;
int k;

bitset<10> avail;

int main() {
    cin.sync_with_stdio(0); cin.tie(0);
    cin >> n >> k;
    avail.set();
    vector<int> a(k);
    for (auto& i : a) {
        cin >> i;
        avail[i] = 0;
    }

    vector<bool> overload((int)n.size(), false);
    for (int i = n.size() - 1; i >= 0; --i) {
        if (i < n.size() - 1) {
            if (overload[i + 1] && n[i] == '9') {
                overload[i] = true;
                continue;
            } else if (overload[i + 1]) {
                n[i]++;
            }
        }

        int pos = false;
        for (int j = n[i] - '0'; j < 10; ++j) {
            if (avail[j]) pos = true;
        }
        if (!pos) overload[i] = true;
    }   

    string ans;
    bool overloaded = false;
    for (int i = 0; i < n.size(); i++) {
        if (overload[i]) {
            if (i == 0) {
                for (int j = 1; j < 10; j++) {
                    if (avail[j]) {
                        ans += j + '0';
                        break;
                    }
                }
            }
            overloaded = true;
        }
        if (overloaded) {
            for (int j = 0; j < 10; ++j) {
                if (avail[j]) {
                    ans += j + '0';
                    break;
                }
            }
        } else {
            for (int j = n[i] - '0'; j < 10; ++j) {
                if (avail[j]) {
                    ans += j + '0';
                    if (j + '0' != n[i]) overloaded = true;
                    break;
                }
            }
        }
    }
    cout << ans;
}   




Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define rep(i, a, b) for (int i = (a); i < (int)(b); ++i)
#define rrep(i, a, b) for (int i = (int)(b) - 1; i >= (int)(a); --i)
#define all(c) c.begin(),c.end()
#define sz(x) ((int)x.size())
using pii = pair<int, int>;
using vvi = vector<vector<int>>;
using vi  = vector<int>;

template <class Monoid>
class SegmentTree {
    using T = typename Monoid::T;
    int size;
    vector<T> data;
    void build() {
        rrep(i, 1, size) {
            data[i] = Monoid::op(data[i * 2], data[i * 2 + 1]);
        }
    }
public:
    SegmentTree(int n) {
        size = 1;
        while (size < n) size *= 2;
        data.assign(size * 2, Monoid::identity());
    }
    template <class It>
    SegmentTree(It first, It last) : SegmentTree(std::distance(first, last)){
        copy(first, last, std::begin(data) + size);
        build();
    }

    // 0-indexed
    void update(int p, const T &value) {
        for (data[p += size] += value; p /= 2; ) {
            data[p] = Monoid::op(data[p * 2], data[p * 2 + 1]);
        }
    }
    // [l, r)  0-indexed
    T query(int l, int r) {
        T resl = Monoid::identity(), resr = Monoid::identity();
        for (l += size, r += size; l < r; l /= 2, r /= 2) {
            if (l & 1) resl = Monoid::op(resl, data[l++]);
            if (r & 1) resr = Monoid::op(data[--r], resr);
        }
        return Monoid::op(resl, resr);
    }
    // 0-indexed
    T get(int p) {
        return data[p + size];
    }
};

struct RMQ {
    using T = int;
    static T op(T a, T b) { return min(a, b); }
    static constexpr T identity() { return (1LL << 31) - 1; }
};

struct RSQ {
    using T = int;
    static T op(T a, T b) { return a + b; }
    static constexpr T identity() { return 0; }
};

signed main() {
    int N, Q;
    cin >> N >> Q;
    SegmentTree<RSQ> seg(N);
    rep(i, 0, Q) {
        int C, X, Y;
        cin >> C >> X >> Y;
        if (C == 0) {
            // add
            X--;
            seg.update(X, Y);
        } else {
            // getsum
            X--, Y--;
            cout << seg.query(X, Y + 1) << endl;
        }
    }
}



Measured memory_bytes: 4864
#include<iostream>

using namespace std;
#define int long long
int N, A;
int x[51];
int S, M;

int memo[51][51*51][51];

int rec(int i, int sum, int used){

   if(memo[i][sum][used]!=-1) return memo[i][sum][used];
   int ret=0;
   if(used==M){
      if(sum==S){
         ret=1;
      }else{// sum>S or sum<S
         ret=0;
      }
   }else if(sum>S){
      ret=0;
   }else if(i==N){
      ret=0;
   }else{
      ret=rec(i+1, sum+x[i], used+1)+rec(i+1, sum+0, used+0);
   }

   return memo[i][sum][used]=ret;
}

signed main(){

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

   int ans=0;
   for(int r=1; r<=N; r++){
      fill((int*)memo, (int*)memo+51*51*51*51, -1);
      S=A*r;
      M=r;
      ans+=rec(0, 0, 0);

   }

   cout<< ans<< endl;

   return 0;
}


Measured memory_bytes: 53120
import java.util.Scanner;
 
class Main
{
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int x;
    for(int i = 1 ; (x = sc.nextInt()) != 0 ; i++)
    {
      System.out.println("Case "+ i +": "+ x);
    }
  }
}

Measured memory_bytes: 40908
x1, y1 = map(int, input().split())
x2, y2 = map(int, input().split())
x3, y3 = map(int, input().split())
a = (((x1 - x2) ** 2) + ((y1 - y2) ** 2)) ** 0.5
b = (((x3 - x2) ** 2) + ((y3 - y2) ** 2)) ** 0.5
c = (((x1 - x3) ** 2) + ((y1 - y3) ** 2)) ** 0.5
max_s = max(max(a, b), c)
s = (a + b + c) / 2
S = (s * (s - a) * (s - b) * (s - c)) ** 0.5
r = S / s
print(r * max_s / (max_s + (2 * r)))

Measured memory_bytes: 3188
#include<bits/stdc++.h>
#define F(i,a,b) for(long long i = (long long)(a); i < (long long)(b); i++)
#define RF(i,a,b) for(long long i = (long long)(a); i >= (long long)(b); i--)
#define MIN3(a,b,c) (a)<(b)?((a)<(c)?(a):(c)):((b)<(c)?(b):(c))
#define MAX(a,b) (a)>(b)?(a):(b)
#define MIN2(a,b) (a)<(b)?(a):(b)
using namespace std;
typedef pair<int, int> ii;
typedef pair<int, ii> iii;
typedef vector<ii> vii;
typedef vector<int> vi;
typedef long long ll;
#define ull unsigned long long
typedef long double ld;
typedef vector<ll> vll;
typedef pair<ll,ll> lll;
#define deb(x )     cerr << #x << " here "<< x << endl;
#define endl    "\n"
#define printCase() "Case #" << caseNum << ": "
inline bool is_palindrome(const string& s){ return std::equal(s.begin(), s.end(), s.rbegin()); }
const ll MOD = 1000000007;
const ll INF = 1e9+5;
const double eps = 1e-7;
const double PI = acos(-1.0);
#define coud(a,d) cout << fixed << showpoint << setprecision(d) << a;
/*----------------------------------------------------------------------*/

const int N = 3005;
double dp[N][N],p[N];

int main(){
    std::ios::sync_with_stdio(false);cin.tie(NULL); cout.tie(NULL);

    memset(dp, 0, sizeof(dp));
    int n;
    cin>>n;

    F(i, 1, n+1) {
    	cin>>p[i];
    }

    dp[0][0]=1.0;
    F(i, 1, n+1) {
    	F(j, 0, i+1) {
    		if(j) {
    			dp[i][j] = (p[i]*dp[i-1][j-1]);
    		}
    		dp[i][j] += (1 - p[i])*dp[i-1][j];
    	}
    }

    double ans = 0.0;
    F(i, n/2+1, n+1) {
    	ans += dp[n][i];
    }
    coud(ans, 10);

    return 0;
}/*

*/


Measured memory_bytes: 70784
using System.Collections.Generic;
    using System.Collections;
    using System.IO;
    using System.Linq;
    using System.Text;
    using System;

    namespace cysharp_test
    {
        class Program
        {
            static void Main (string[] args)
            {
                new Program ().solve ();
            }

            void solve ()
            {
            var s = Console.ReadLine();
            Console.WriteLine(s == "ARC" ? "ABC" : "ARC");
            Console.ReadKey ();
            }
        }
        struct Vector2
        {
            public Vector2 (long x, long y)
            {
                this.x = x;
                this.y = y;
            }

            public long x, y;

            public static Vector2 operator + (Vector2 a, Vector2 b)
            {
                return new Vector2 (a.x + b.x, a.y + b.y);
            }

            public static Vector2 operator - (Vector2 a, Vector2 b)
            {
                return new Vector2 (a.x - b.x, a.y - b.y);
            }

            public static Vector2 operator * (Vector2 a, long scala)
            {
                return new Vector2 (a.x * scala, a.y + scala);
            }

            public static bool operator == (Vector2 a, Vector2 b)
            {
                return (a.x == b.x) && (a.y == b.y);
            }

            public static bool operator != (Vector2 a, Vector2 b)
            {
                return !(a.x == b.x) && (a.y == b.y);
            }

            public override int GetHashCode ()
            {
                return (int) (x + y);
            }

            public override bool Equals (object obj)
            {
                if (!(obj == null) && obj is Vector2)
                {
                    return (this == (Vector2) obj);
                }
                else return false;
            }

            public override string ToString ()
            {
                return ("(" + x + "," + y + ")");
            }
        }
    }

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

int main()
{
  int N, X;
  cin >> N >> X;
  int L;
  int D = 0;
  int i = 1;
  for (; i <= N; ++i)
  {
    cin >> L;
    D += L;
    if (X < D)
      break;
  }
  cout << i;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <math.h>
#define ALL(a)    a.begin(), a.end() 
#define rep(i, K, N)  for(long long int i = K; i < N; i++)
#define ll long long int
using namespace std;

ll H, W, Ans = 0;
vector<string> table;
vector<vector<ll>> V;
vector<ll> dx{-1, 0, 0, 1};
vector<ll> dy{0, -1, 1, 0};
queue<pair<ll, ll>> Q;

void bfs(){
  
  if(!Q.empty()){

    ll Y = Q.front().first, X = Q.front().second;

    Q.pop();

    rep(i, 0, 4){

        ll y = Y + dy[i], x = X + dx[i];

        if(y < 0 || y >= H || x < 0 || x >= W)continue;

        if(table[y][x] == '#' || V[y][x] != -1)continue;

        V[y][x] = V[Y][X] + 1;Ans = max(Ans, V[y][x]);

        Q.push({y, x});

    }

    bfs();
    
  }

}

int main(){
cin >> H >> W;

rep(i, 0, H){

    string S;cin >> S;

    table.push_back(S);

}
  
V.resize(H);
  
rep(i, 0, H){
  
  rep(j, 0, W){
    
    V[i].push_back(-1);
    
  }
  
}

  //rep(i, 0, H){rep(j, 0, W){cout << V[i][j] << " ";}cout << endl;}

rep(i, 0, H){

    rep(j, 0, W){
      
        if(table[i][j] == '#')continue;

        rep(k, 0, H){

            rep(l, 0, W){

                V[k][l] = -1;

            }
        }

        V[i][j]++;Q.push({i, j});

        bfs();

    }
}

cout << Ans;

}


Measured memory_bytes: 3636
def resolve():
    def func(n):
        if n % 2 == 0:
            return n / 2
        else:
            return 3 * n + 1

    res = [int(input())]
    idx = 0
    while True:
        i = func(res[idx])
        if i not in res:
            res.append(i)
        else:
            print(len(res) + 1)
            break
        idx += 1


resolve()

Measured memory_bytes: 3060
N = input()
X = list(map(int, list(str(N))))

dp1 = [float('inf')] * (len(X) + 1)  # dp1[i] := 上からi番目の金額を丁度払う場合の最小値
dp2 = [float('inf')] * (len(X) + 1)  # dp2[i] := 上からi番目の金額を１周り大きい額で支払う場合の最小値
dp1[0] = 0
for i, x in enumerate(X):
    dp1[i + 1] = min(dp1[i] + x, dp2[i] + x)
    dp2[i + 1] = min(dp1[i] + (10 - x) + 1, dp2[i] + (10 - x) - 1)

print(min(dp1[-1], dp2[-1]))


Measured memory_bytes: 90928
flag = True
while True:
    n = int(input())
    if n == 0: break
    answer = {}
    for _ in range(n):
        result = input().split()
        country = result[0]
        win, lose, draw = map(int, result[1:])
        score = win * 3 + draw
        answer[country] = score
    if flag:
        flag = False
    else:
        print()
    for c, s in sorted(answer.items(), key=lambda x: -x[1]):
        print(c + ',' + str(s))
    


Measured memory_bytes: 5592
N=int(input())

a=[int(i) for i in input().split()]

color=[0,0,0,0,0,0,0,0]
alles=0

for i in range(N) :
    
    if a[i]<400 :
        color[0]+=1
    elif a[i]<800 :
        color[1]+=1
    elif a[i]<1200 :
        color[2]+=1
    elif a[i]<1600 :
        color[3]+=1
    elif a[i]<2000 :
        color[4]+=1
    elif a[i]<2400 :
        color[5]+=1
    elif a[i]<2800 :
        color[6]+=1
    elif a[i]<3200 :
        color[7]+=1
    else :
        alles+=1

        
while 0 in color :color.remove(0)


if len(color)==0 :
    print(int(1)," ",len(color)+alles)
else :
    print(len(color)," ",len(color)+alles)





Measured memory_bytes: 3064
n = int(input())
a, b = [list(map(int, input().split())) for _ in range(2)]
bSum = 0
for i in range(n):
    if a[i] >= b[i]:
        bSum += b[i]
        a[i] -= b[i]
    elif a[i] + a[i + 1] >= b[i]:
        bSum += b[i]
        a[i + 1] -= b[i] - a[i]
        a[i] = 0
    else:
        bSum += a[i] + a[i + 1]
        a[i + 1] = 0

print(bSum)


Measured memory_bytes: 82020
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        try (Scanner sc = new Scanner(System.in)) {
            int a = sc.nextInt();
            int b = sc.nextInt();

            int ans = Math.max(a * b, Math.max(a + b, a - b));
            System.out.println(ans);
        }
    }

}


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

using namespace std;
using ll =long long;

#define SORT(a) sort((a).begin(),(a).end())
#define rSORT(a) reverse((a).begin(),(a).end())
#define For(i, a, b)    for(int i = (a) ; i < (b) ; ++i)
#define rep(i, n)       For(i, 0, n)
#define debug(x)  cout << #x << " = " << (x) << endl;
void coY() {cout <<"Yes"<<endl;}
void coN(){cout <<"No"<<endl;}

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 ll INF = 1LL << 60;

//Write From this Line

int main()
{
	vector<int> a(4);
	rep(i,4) cin >> a[i];
	sort(a.begin(),a.end());
	if(a[0] == 1) if(a[1] == 4) if(a[2]==7)if(a[3]==9){
		cout << "YES" << endl;
		return 0;
	}
	cout <<"NO"<<endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <cmath>
#include <vector>
#include <cstdio>
#include <algorithm>
#include <string>

using namespace std;

typedef long long LL;
typedef unsigned int UI;

#define rSort(a) 		sort(a.rbegin(),a.rend())
#define Sort(a) 		sort(a.begin(),a.end())
#define Reverse(a) 		reverse(a.begin(),a.end())
#define Sum(a)  		accumulate(a.begin(), a.end(), 0)
#define REP(i, n) 		for(UI i = 0;i < n;i++)
#define REPR(i, n) 		for(UI i = n;i >= 0;i--)
#define FOR(i, m, n) 	for(UI i = m;i < n;i++)
#define pb(i) 			push_back(i)

#define MOD  			(LL)1e9 + 7;
#define INF  			(LL)1 << 62;


int main(int argc, const char * argv[]) {

	cin.tie(0);
	ios::sync_with_stdio(false);

	LL N;
	double sum = 0;

	cin >> N;
	vector<double> x(N);
	vector<string> u(N);

	REP(i,N){
		cin >> x.at(i) >> u.at(i);
	}

	REP(i,N){
		if(u.at(i)=="BTC"){
			sum+=x.at(i)*380000.0;
		}else{
			sum+=x.at(i);
        }
	}

	cout << sum << endl;

	return 0;

}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
 
int main() {
    while(1){
        int H, W;
        char c[2] = {'#', '.'};
        cin >> H >> W;
        if (H == 0 && W == 0){
            break;
        }
        for(int i = 0; i < H; i++){
            for(int j = 0; j < W; j++){
                cout << c[(i+j) % 2];
            }
            cout << endl;
        }
        cout << endl;
    }
}

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

int main(){

    int H, W, K;
    cin >> H >> W >> K;
    int c[H][W];
    rep (i, H){
        rep (j, W){
            char ch;
            cin >> ch;
            c[i][j] = 1;
            if (ch == '.') c[i][j] = 0;
        }
    }

    int ans = 0;
    rep (bit_H, 1<<H){
        rep (bit_W, 1<<W){
            int copy[H][W];
            rep (i, H) rep (j, W) copy[i][j] = c[i][j];
            rep (i, H){
                if (bit_H & (1<<i)){
                    rep (w, W) copy[i][w] = 0;
                }
            }
            rep (j, W){
                if (bit_W & (1<<j)){
                    rep (h, H) copy[h][j] = 0;
                }
            }
            int cnt = 0;
            rep (i, H) rep (j, W) if (copy[i][j] == 1) cnt++;
            if (cnt == K) ans++;
        }
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 3616
#include <cstdio>
#include <functional>
#include <algorithm>
#include <vector>
#include <limits>
#include <numeric>
#include <type_traits>
#include <iostream>
#include <queue>
#include <math.h>
#include <bits/stdc++.h>
#include <queue>
#include <map>

using namespace std;

#define INF (1ll<<60)
#define INFint (1<<30)
#define MOD 1000000007
#define BOUND 27182818284

typedef long long ll;
typedef long long int lli;
typedef pair<int,int> P;

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

template<class T>
bool umax(T &a, const T &b){
    if (a<b) {
        a=b; return 1;
    }
    return 0;
}

template<class T>
bool umin(T &a, const T &b) {
    if (b<a) {
        a=b; return 1;
    }
    return 0;
}

// gcd
template<typename T>
T gcd(T a, T b){
    if(a==0)
        return b;
    return gcd(b%a,a);
}

// gcd array
int findGCD(int arr[], int n){
    int result = arr[0];
    for (int i=1; i < n; i++)
        result = gcd(arr[i], result);
    return result;
}

template<typename T>
T lcm( T m, T n ){
    // 引数に0がある場合は0を返す
    if ( ( 0 == m ) || ( 0 == n ) )
        return 0;
    return ((m/gcd(m, n)) * n); // lcm = m * n / gcd(m,n)
}

template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
    fill( (T*)array, (T*)(array+N), val );
}


int dx[5]={1,0,-1,0};
int dy[5]={0,1,0,-1};
// v.front() = -BOUND;
// v.back() = BOUND;
bool IsPrime(int num)
{
    if (num < 2) return false;
    else if (num == 2) return true;
    else if (num % 2 == 0) return false; // 偶数はあらかじめ除く

    double sqrtNum = sqrt(num);
    for (int i = 3; i <= sqrtNum; i += 2)
    {
        if (num % i == 0)
        {
            // 素数ではない
            return false;
        }
    }
    // 素数である
    return true;
}

int main() {
    int N;
    cin >> N;
    vector<ll>a(N,0);
    rep(i,N){
        cin >> a[i];
    }
    sort(a.begin(),a.end());
    ll aa=1LL<<60, boarder=1LL<<60;
    auto itr=lower_bound(a.begin(), a.end(), a[N-1]/2);
    if(abs(a[N-1]/2-*itr)<boarder && *itr!=a[N-1]){
        aa=*itr;
        boarder=abs(a[N-1]/2-*itr);
    }
    
    itr--;
    if(itr>=a.begin() && abs(a[N-1]/2-*(itr)) <boarder){
        aa=*itr;
    }

    cout << a[N-1] << " " << aa << endl;
    return 0;
}


Measured memory_bytes: 1024
#include <iostream>
#include <string>
#include <algorithm>
#define rep(i, a, b) for(int i = (a); i < (b); i++)
using namespace std;

int main() {
  int a, c = 0;
  cin >> a;
  while(a >= 500) {
    c += 1000;
    a -= 500;
  }
  while(a >= 5) {
    c += 5;
    a -= 5;
  }
  cout << c;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, a, n) for(int i = a; i < n; i++)
#define int long long
using namespace std;
typedef pair<int, int> P;
const int mod = 1000000007;
const int INF = 1e18;

signed main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    int n;
    double t, a;
    cin >> n >> t >> a;
    double MIN = INF;
    int ans = -1;
    vector<double> h(n);
    rep(i, 0, n) cin >> h[i];
    rep(i, 0, n){
        double tmp = t - h[i] * 0.006;
        if(fabs(tmp - a) < MIN){
            MIN = fabs(tmp - a);
            ans = i;
        }
    }
    cout << ans + 1 << endl;
}

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

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

  if(s <= 'Z'){
    std::cout << "A" << '\n';
  }
  else{
    std::cout << "a" << '\n';
  }
  return 0;
}

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

int main() {
  int x,y,a,b,c;
  cin >> x >> y >> a >> b >> c;
  
  vector<int>p(a);
  vector<int>q(b);
  vector<int>r(c);
  rep(i,0,a) cin >> p[i];
  rep(i,0,b) cin >> q[i];
  rep(i,0,c) cin >> r[i];
  sort(p.begin(),p.end());
  reverse(p.begin(),p.end());
  sort(q.begin(),q.end());
  reverse(q.begin(),q.end());
  
  rep(i,0,a-x) p.pop_back();
  rep(i,0,b-y) q.pop_back();
  
  rep(i,0,x) r.push_back(p[i]);
  rep(i,0,y) r.push_back(q[i]);
  sort(r.begin(),r.end());
  reverse(r.begin(),r.end());
  ll ans = 0;
  rep(i,0,x+y) ans += r[i];
  cout << ans << endl;
}

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

using namespace std;
using ll = long long;

int main(){
    string s;
    cin>>s;
    ll red=0,blue=0;
    for(int i=0;i<s.size();++i){
        if(s[i] == '0'){
            red++;
        }else{
            blue++;
        }
    }
    cout << min(red,blue) * 2<< endl;
    return 0;
}



Measured memory_bytes: 512
# Author: cr4zjh0bp
# Created: Fri Mar  6 13:28:27 UTC 2020
import sys
 
stdin = sys.stdin
inf = 1 << 60
mod = 1000000007
 
ni = lambda: int(ns())
nin = lambda y: [ni() for _ in range(y)]
na = lambda: list(map(int, stdin.readline().split()))
nan = lambda y: [na() for _ in range(y)]
nf = lambda: float(ns())
nfn = lambda y: [nf() for _ in range(y)]
nfa = lambda: list(map(float, stdin.readline().split()))
nfan = lambda y: [nfa() for _ in range(y)]
ns = lambda: stdin.readline().rstrip()
nsn = lambda y: [ns() for _ in range(y)]
ncl = lambda y: [list(ns()) for _ in range(y)]
nas = lambda: stdin.readline().split()

N = ni()
abc = nan(N)
dp = [[0] * 3 for _ in range(N + 1)]
for i in range(N):
    for j in range(3):
        for k in range(3):
            if j != k:
                dp[i + 1][j] = max(dp[i + 1][j], dp[i][k] + abc[i][j])

print(max(dp[N][0], dp[N][1], dp[N][2]))

Measured memory_bytes: 70108
#include<stdio.h>
int main(){
  int n,i;
  scanf("%d",&n);
  char s[n+1],ans[n+2];
  scanf("%*c%s",s);
  ans[0]='S';
  ans[1]='S';
  for(i=1;i<=n;i++){
    if(ans[i]=='S'){
      if(s[i-1]=='o')
        ans[i+1]=ans[i-1];
      else if(ans[i-1]=='S')
        ans[i+1]='W';
      else
        ans[i+1]='S';
    }
    else{
      if(s[i-1]=='x')
        ans[i+1]=ans[i-1];
      else if(ans[i-1]=='S')
        ans[i+1]='W';
      else
        ans[i+1]='S';
    }
  }
  if(ans[0]==ans[n] && ans[1]==ans[n+1]){
    for(i=1;i<=n;i++)
      printf("%c",ans[i]);
    puts("");
    return 0;
  }
  ans[0]='S';
  ans[1]='W';
  for(i=1;i<=n;i++){
    if(ans[i]=='S'){
      if(s[i-1]=='o')
        ans[i+1]=ans[i-1];
      else if(ans[i-1]=='S')
        ans[i+1]='W';
      else
        ans[i+1]='S';
    }
    else{
      if(s[i-1]=='x')
        ans[i+1]=ans[i-1];
      else if(ans[i-1]=='S')
        ans[i+1]='W';
      else
        ans[i+1]='S';
    }
  }
  if(ans[0]==ans[n] && ans[1]==ans[n+1]){
    for(i=1;i<=n;i++)
      printf("%c",ans[i]);
    puts("");
    return 0;
  }
  ans[0]='W';
  ans[1]='S';
  for(i=1;i<=n;i++){
    if(ans[i]=='S'){
      if(s[i-1]=='o')
        ans[i+1]=ans[i-1];
      else if(ans[i-1]=='S')
        ans[i+1]='W';
      else
        ans[i+1]='S';
    }
    else{
      if(s[i-1]=='x')
        ans[i+1]=ans[i-1];
      else if(ans[i-1]=='S')
        ans[i+1]='W';
      else
        ans[i+1]='S';
    }
  }
  if(ans[0]==ans[n] && ans[1]==ans[n+1]){
    for(i=1;i<=n;i++)
      printf("%c",ans[i]);
    puts("");
    return 0;
  }
  ans[0]='W';
  ans[1]='W';
  for(i=1;i<=n;i++){
    if(ans[i]=='S'){
      if(s[i-1]=='o')
        ans[i+1]=ans[i-1];
      else if(ans[i-1]=='S')
        ans[i+1]='W';
      else
        ans[i+1]='S';
    }
    else{
      if(s[i-1]=='x')
        ans[i+1]=ans[i-1];
      else if(ans[i-1]=='S')
        ans[i+1]='W';
      else
        ans[i+1]='S';
    }
  }
  if(ans[0]==ans[n] && ans[1]==ans[n+1]){
    for(i=1;i<=n;i++)
      printf("%c",ans[i]);
    puts("");
    return 0;
  }
  puts("-1");
  return 0;
}

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

#define vec                vector<int>
#define vecll              vector<ll>
#define vecd               vector<double>
#define vecst              vector<string>
#define vecb               vector<bool>
#define vec2(var, n, m)    vector<vector<int>> var(n, vector<int>(m, 0))
#define vecll2(var, n, m)  vector<vector<ll>> var(n, vector<ll>(m, 0))

#define rep(i,n)         for(ll i=(ll)0; i<(ll)n; i++)
#define REP(i,m,n)       for(ll i=(ll)m; i<(ll)n; i++)
#define arr(var, n)      vec var(n); rep(i,n){cin >> var[i];}
#define arrll(var, n)    vecll var(n); rep(i,n){cin >> var[i];}
#define arrst(var, n)    vecst var(n); rep(i,n){cin >> var[i];}
#define all(var)         (var).begin(), (var).end()
#define sortall(var)     sort(all(var))
#define uniqueall(v)     v.erase(unique(v.begin(), v.end()), v.end());
#define f_sum(var)       accumulate(all(var), 0)
#define f_sumll(var)     accumulate(all(var), 0LL)
#define chmin(v1, v2)    v1 = min(v1, v2)
#define chmax(v1, v2)    v1 = max(v1, v2)
#define pb(var)          push_back(var)
#define prt(var)         cout << (var) << "\n"
#define prtd(n, var)     cout << fixed << setprecision(n) << (var) << "\n"
#define prtfill(n, var)  cout << setw(n) << setfill('0') << (var);
#define prt2(v1, v2)     cout << (v1) << " " << (v2) << "\n"
#define prt3(v1, v2, v3) cout << (v1) << " " << (v2) << " " << (v3) << "\n"
#define prtall(v)        rep(i,v.size()){cout<<v[i]<<(i!=v.size()-1?" ":"\n");}
void prtok(bool ok){prt(ok ? "Yes" : "No");}
//----------------------------------------------------------------

int main(void) {
  int d;
  cin >> d;
  arrll(c,26);
  vecll2(s, d, 26);
  rep(i,d){
    rep(j,26){
      cin >> s[i][j];
    }
  }

  vecll ans;

  srand(time(NULL));

  vecll human(26);
  vecll last(26);

  rep(i,d){
    rep(j,26){
      last[j]++;
    }
    vecll manzoku(26);
    rep(j,26){
      manzoku[j] = last[j]*c[j];
    }
    int id = 0;
    ll tmp = manzoku[0];

    rep(j,26){
      if(tmp<manzoku[j]){
        id = j;
        tmp = manzoku[j];
      }
    }
    ans.pb(id+1);
    last[id]=0;
  }

  rep(i,d){
    prt(ans[i]);
  }
}


Measured memory_bytes: 3724
/*
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,avx,avx2")
#pragma GCC optimize("Os")
#pragma GCC target("avx2,fma")
#pragma GCC optimize("Ofast")
#pragma GCC optimize("Os")
*/
 
#include <bits/stdc++.h>
//#include <windows.h>
 
#define ll long long
#define X first
#define Y second
#define MP make_pair
 
using namespace std;
 
                 
const int MAX_MEM = 1e8;
int mpos=0;
char mem[MAX_MEM];
inline void * operator new(size_t n){
	char *res = mem + mpos;
	mpos += n;
	assert(mpos <= MAX_MEM);
	return (void *)res;
}
 
inline void operator delete(void *){}
                

const int N = 2e5 + 123;
const ll mod = 1e9 + 7;

uniform_int_distribution <ll> dst(2, 1e10);
mt19937_64 rnd;
vector< ll > pr;
map< pair<ll, ll>, ll > mp;
bool was[N];
int n, res;

void pre_calc(){
	for(int i = 2;i <= 3533;i++){
		if(was[i])
			continue;
		pr.push_back(i);
		for(int j = i * 2;j <= 3533;j += i){
			was[i] = 1;
		}
	}
}

pair<ll, ll> calc(ll t){
	ll x = 1, y = 1;
	for(int i = 0;i < (int)pr.size() && pr[i] * pr[i] <= t;i++){
		int cnt = 0;
		while(t % pr[i] == 0){
			t /= pr[i];
			cnt++;
		}
		if(cnt % 3 == 1){
			x *= pr[i];
			y *= pr[i] * pr[i];
		}
		else if(cnt % 3 == 2){
			x *= pr[i] * pr[i];
			y *= pr[i];
		}
	}

	x *= t;
	if(t > 1){
		ll ss = sqrt(t);
		if(ss * ss == t){
			y = y * ss;
		}
		else{
			y = y * t * t;
		}
	}
	return MP(x, y);
}

int main () {
	ios::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	rnd.seed(int(clock()));

	pre_calc();

	cin >> n;
	pair<ll, ll> v;
	for(int i = 1;i <= n;i++){
		ll x;
		cin >> x;
		v = calc(x);
		//cout << v.X << " " << v.Y << "\n";
		if(v.X == 1 && res != 1){
			res = 1;
		}
		else if(v.X * v.Y != 1){
			mp[MP(v.X, v.Y)] += 1;
		}
	}

  	for(pair< pair<ll, ll>, ll > u: mp){
  		ll x = u.X.X, y = u.X.Y, cnt1 = u.Y;

  		//cout << x << " " << y << " " << cnt1 << "\n";
  		
  		if(cnt1 == 0){
  			continue;
  		}
  		ll cnt2 = mp[MP(y, x)];
  		res += max(cnt1, cnt2);
  		mp[MP(y, x)] = 0, mp[MP(x, y)] = 0;
  	} 

  	cout << res;

	return 0;
}

Measured memory_bytes: 12544
import sys
def input(): return sys.stdin.readline().strip()
def mapint(): return map(int, input().split())
sys.setrecursionlimit(10**9)

sx, sy, tx, ty = mapint()
ans = ''

ans += 'U'*(ty-sy) + 'R'*(tx-sx)
ans += 'D'*(ty-sy) + 'L'*(tx-sx)
ans += 'L'+'U'*(ty-sy+1)+'R'*(tx-sx+1)+'D'
ans += 'R'+'D'*(ty-sy+1) + 'L'*(tx-sx+1)+'U'

print(ans)

Measured memory_bytes: 9020
N = gets.to_i
array = gets.split.map(&:to_i)
N.times do |n|    
	print("#{array[n]}")
	if n<N-1
		print(" ")
	end
end
print("\n")

1.upto(N-1) do |i|
	v = array[i]
	j = i-1
	while j >= 0 && array[j]>v
		array[j+1] = array[j]
		j-=1
		array[j+1] = v
	end
	N.times do |n|    
	print("#{array[n]}")
	if n<N-1
		print(" ")
	end
end
print("\n")
end

Measured memory_bytes: 8764
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
template <class T, class U> using Pa = pair<T, U>;
template <class T> using vec = vector<T>;
template <class T> using vvec = vector<vec<T>>;

int main(){
    int N;
    cin >> N;
    vec<int> cnt(26,100);
    for(int i=0;i<N;i++){
        string S;
        cin >> S;
        vec<int> v(26);
        for(auto& c:S) v[c-'a']++;
        for(int j=0;j<26;j++) cnt[j] = min(cnt[j],v[j]);
    }
    string ans = "";
    for(int i=0;i<26;i++){
        char c = 'a'+i;
        for(int j=0;j<cnt[i];j++) ans += c;
    }
    cout << ans << "\n";
}

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

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n, k;
    cin >> n >> k;
    int count = 1;
    for (int i = 0; i < n; i++) {
        if (count < k){
            count*=2;
        } else {
            count+=k;
        }
    }
    cout << count << endl;
}

Measured memory_bytes: 256
"use strict"
const create = () => {
    const input = require("fs").readFileSync("/dev/stdin", "utf8").trim().split("\n");
    const res = {
        "list": input, "index": 0, "max": input.length,
        "hasNext": function() {return this.index < this.max},
        "next": function() { if (!this.hasNext()) {throw "ArrayIndexOutOfBoundsException";}else{return this.list[this.index++];}}
    };
    return res;
}
const o = create();
const next = () => o.next()
const nextInt = () => parseInt(o.next())
const nextStrArray = () => o.next().split(" ")
const nextIntArray = () => o.next().split(" ").map(el => parseInt(el))
const nextCharArray = () => o.next().split("")
const hasNext = () => o.hasNext()
const myout = (...x) => console.log(...x)
const Main = () => {
    let n = nextInt()
    let a = nextIntArray()
    for(let val of a){
        if(val % 2 ==0){
            if(val % 3 !== 0 && val % 5 !== 0){
                console.log("DENIED")
                return
            }
        }
    }
    console.log("APPROVED")
}
Main()


Measured memory_bytes: 29364
#include <bits/stdc++.h>
using namespace std;
 
int sumsum(int n){
  int sum =0;
  while(n>0){
    sum += n%10;
    n /= 10;
  }
  return sum;
}
int main() {
  int N,min=1000;
  cin >>N;
  for(int A =1; A<N; A++){
    if(min> sumsum(A) + sumsum(N-A)){
      min =sumsum(A) + sumsum(N-A);
    }
  }
  cout <<min <<endl;
}

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

using namespace std;

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

#define each(i,a) for (auto&& i : a)
#define FOR(i,a,b) for (ll i=(a),__last_##i=(b);i<__last_##i;i++)
#define RFOR(i,a,b) for (ll i=(b)-1,__last_##i=(a);i>=__last_##i;i--)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n)
#define __GET_MACRO3(_1, _2, _3, NAME, ...) NAME
#define rep(...) __GET_MACRO3(__VA_ARGS__, FOR, REP)(__VA_ARGS__)
#define rrep(...) __GET_MACRO3(__VA_ARGS__, RFOR, RREP)(__VA_ARGS__)
#define pb push_back
#define all(a) (a).begin(),(a).end()
#define chmin(x,v) x = min(x, v)
#define chmax(x,v) x = max(x, v)

const ll linf = 1e18;
const int inf = 1e9;
const double eps = 1e-12;
const double pi = acos(-1);

template<typename T>
istream& operator>>(istream& is, vector<T>& vec) {
    each(x,vec) is >> x;
    return is;
}
template<typename T>
ostream& operator<<(ostream& os, const vector<T>& vec) {
    rep(i,vec.size()) {
        if (i) os << " ";
        os << vec[i];
    }
    return os;
}
template<typename T>
ostream& operator<<(ostream& os, const vector< vector<T> >& vec) {
    rep(i,vec.size()) {
        if (i) os << endl;
        os << vec[i];
    }
    return os;
}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    ll w, h;
    while (cin >> w >> h, w || h) {
        vector<vector<vector<P>>> G(h, vector<vector<P>>(w));
        auto add_edge = [&](ll x1, ll y1, ll x2, ll y2) {
            // cout << "add: " << x1 << " " << y1 << " " << x2 << " " << y2 << endl;
            G[y1][x1].pb({x2, y2});
            G[y2][x2].pb({x1, y1});
        };
        auto in1 = [&](ll y) {
            // cout << "in1" << endl;
            rep(x, w-1) {
                ll e; cin >> e;
                if (!e) add_edge(x, y, x+1, y);
            }
        };
        auto in2 = [&](ll y) {
            assert(y < h-1);
            // cout << "in2" << endl;
            rep(x, w) {
                ll e; cin >> e;
                if (!e) add_edge(x, y, x, y+1);
            }
        };
        rep(y, h) {
            in1(y);
            if (y+1 < h) in2(y);
        }
        vector<vector<ll>> dist(h, vector<ll>(w, linf));
        dist[0][0] = 0;
        queue<P> Q; Q.push({0, 0});
        while ( !Q.empty() ) {
            P p = Q.front(); Q.pop();
            ll x, y; tie(x, y) = p;
            // cout << x << " " << y << " " << dist[y][x] << endl;
            each(to, G[y][x]) {
                ll nx, ny; tie(nx, ny) = to;
                if (dist[y][x]+1 < dist[ny][nx]) {
                    dist[ny][nx] = dist[y][x]+1;
                    Q.push({nx, ny});
                }
            }
        }
        ll ans = dist[h-1][w-1]+1;
        if (ans >= linf) ans = 0;
        cout << ans << endl;
    }
}

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

#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;

#define ll          long long
#define pb          push_back
#define vi          vector<ll int>
#define all(a)      (a).begin(),(a).end()
#define F           first
#define S           second
#define rs(v,n)     v.resize(n)
#define hell        1000000007
#define peak        9123372036854775807
#define pii         acos(-1)
#define clr(a,x)    memset(a,x,sizeof(a))
#define ios         ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
using namespace std;
template<typename T>
using ordered_set = tree<T,null_type,less<T>,rb_tree_tag,tree_order_statistics_node_update>;
template<class x,class y> x sum(x a,y b){return a+b;}
template<class x,class y> x mul(x a,y b){return a*b;}
template<class x,class y> x sub(x a,y b){return a-b;}
template<class x,class y> x divi(x a,y b){return a/b;}

template<class x,class y>
istream &operator>>(istream &in,pair<x,y> &p) 
{ 
    in>>p.F>>p.S;
    return in;
}
template<class x>
istream &operator>>(istream &in,vector<x> &v) 
{
    for(auto& i:v)
        in>>i;
    return in;
}
template<class x,class y>
ostream &operator<<(ostream &out,pair<x,y> &p) 
{ 
    out<<"("<<p.F<<","<<p.S<<") ";
    return out; 
}
template<class x>
ostream &operator<<(ostream &out,vector<x> &v) 
{ 
    out<<v.size()<<endl;
    for(auto i:v)
        out<<i<<" ";
    out<<endl;
    return out; 
}
#define N  1000005

int main()
{
    ios;
    ll tt=1;
    // cin>>tt;
    while(tt--)	
    {
    	ll i,j,k,l,m,n;
    	string s;
    	cin>>s;
    	if(s=="ARC")
    		cout<<"ABC";
    	else cout<<"ARC";
    }
    return 0;
}

Measured memory_bytes: 3648
#include<bits/stdc++.h>
using namespace std;
int N,M,K;
int main(){
  cin>>N>>M>>K;
  for(int i=0;i<=N;i++){
    for(int j=0;j<=M;j++){
      int sum=i*j + (N-i)*(M-j);
      if(sum==K || K==0){
        cout<<"Yes"<<endl;
        return 0;
      }
    }
  }
  cout<<"No"<<endl;
  return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <iostream>
#include <algorithm>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <set>
#include <map>
#include <cstdio>
#include <string>
#include <cstdlib>
#include <cstring>
#include <bits/stdc++.h>
 
using namespace std;
typedef long long ll;
typedef string str;
typedef std::pair<ll,ll> pl;
typedef std::map<string, ll> msl;
typedef std::map<ll, ll> mll;
typedef std::vector<ll> vl;
const long double EPS = 1e-9;
 
#define rep(i, n) for(ll (i) = 0; (i) < (n) ; (i)++ )
#define For(i, a, b) for(ll (i) = (a); (i) < (b) ; (i)++ )
#define all(a) (a).begin(), (a).end()
#define rall(a) (a).rbegin(), (a).rend()
#define tol(c) char((c)+0x20)
#define tou(c) char((c)-0x20)
#define pb push_back
#define mp make_pair
#define pr(a) cout << (a)
#define prl(a) cout << (a) << endl
#define prl2(a,b) cout << (a) << " " << (b) << endl
#define prs(a) cout << (a) << " "
#define yn(condition) if ((condition)) prl("Yes"); else prl("No");
#define YN(condition) if ((condition)) prl("YES"); else prl("NO");
#define rpr(i,n,ans) rep((i),(n)) prs((ans[(i)]))
#define cpr(i,n,ans) rep((i),(n)) prl((ans[(i)]))
#define in1(a) cin >> (a)
#define in2(a,b) cin >> (a) >> (b)
#define in3(a,b,c) cin >> (a) >> (b) >> (c)
#define in4(a,b,c,d) cin >> (a) >> (b) >> (c) >> (d)
#define rin1(i,n,a) rep((i),(n)) cin >> (a[(i)])
#define rin2(i,n,a,b) rep((i),(n)) cin >> (a[(i)]) >> (b[(i)])
#define rin3(i,n,a,b,c) rep((i),(n)) cin >> (a[(i)]) >> (b[(i)]) >> (c[(i)])
#define e1 first
#define e2 second
#define ctol(c) ll((c)) - ll('0')
#define ltos(n) to_string((n))
#define items(kv, v) for(auto &(kv): (v))
#define ndig(N, n) ctol(ll(ltos((N))[ll(ltos((N)).length()) - (n)]))
#define beto(a,b,c) (a) < (b) && (b) < (c)
#define betc(a,b,c) (a) <= (b) && (b) <= (c)
#define rsort(a,n) sort(a,a+n,greater<>())
 
const ll mod = 1e9 + 7;
const ll INF = mod * mod;
const ll MAX_N = 100;
 
int main(void){
    ll a,b,c;
    str s,t,u;
    ll c5, c7 = 0;

    in3(a,b,c);
    if (a == 5) c5 ++;
    if (b == 5) c5 ++;
    if (c == 5) c5 ++;
    if (a == 7) c7 ++;
    if (b == 7) c7 ++;
    if (c == 7) c7 ++;
    YN(c5 == 2 && c7 == 1);

    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <functional>
#include <numeric>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <utility>
#include <sstream>
#include <complex>
#include <fstream>
#include <bitset>
#include <time.h>
#include <tuple>

using namespace std;

typedef long long ll;
typedef pair<ll, ll> P;
typedef vector<ll> V;
typedef complex<double> Point;

#define PI acos(-1.0)
#define EPS 1e-10
const ll INF = 1e12;
const ll MOD = 1e9 + 7;

#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define rep(i,N) for(int i=0;i<(N);i++)
#define ALL(s) (s).begin(),(s).end()
#define EQ(a,b) (abs((a)-(b))<EPS)
#define EQV(a,b) ( EQ((a).real(), (b).real()) && EQ((a).imag(), (b).imag()) )
#define fi first
#define se second
#define N_SIZE (1LL << 20)
#define NIL -1
#define MAX_N 100100 * 3

int n;
vector<int> A;

int main() {
	cin >> n;
	A.resize(n);
	rep(i, n)cin >> A[i];
	for (int i = 1; i < n; i++) {
		rep(j, n) {
			if (j != n - 1)cout << A[j] << " ";
			else cout << A[j];
		}
		cout << endl;
		int v = A[i];
		int j = i - 1;
		while (j >= 0 && A[j] > v) {
			A[j + 1] = A[j];
			j--;
		}
		A[j + 1] = v;
	}
	rep(j, n) {
		if (j != n - 1)cout << A[j] << " ";
		else cout << A[j];
	}
	cout << endl;
}

Measured memory_bytes: 3052
#include <iostream>

int main() {
  int N, M;
  std::cin >> N >> M;
  int lmax = -1, rmin = 999999999;
  for (int i = 0; i < M; ++i) {
    int L, R;
    std::cin >> L >> R;
    if (L > lmax) lmax = L;
    if (rmin > R) rmin = R;
  }

  int result = rmin - lmax + 1;

  if (result < 0) result = 0;
  std::cout << result << std::endl;

  return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
int MAX(int a,int b){return a<b?b:a;}
int main(){
  int n,m,a,b,c,i,j,o[400],d[1010]={1};
  scanf("%d",&n);
  while(n--){
    scanf("%d %d %d",&a,&b,&c);
    for(i=0;i<400;i++){
      if(d[i]==0)continue;
      for(j=a;j<=b;j++)d[i+j]=MAX(d[i+j],d[i]+c);
    }
  }
  //for(i=0;i<20;i++)printf("%d %d\n",i,d[i]);
  scanf("%d",&n);
  for(i=0;i<n;i++){
    scanf("%d",&a);
    o[i]=d[a]-1;
    if(d[a]==0)o[0]=-1;
  }
  if(o[0]<0)printf("-1\n");
  else{
    for(i=0;i<n;i++)printf("%d\n",o[i]);
  }
  return 0;
}

Measured memory_bytes: 604
/*
      author : Nishikawa
      created: 06.08.2020 14:40:02
*/

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


int main(){
    int N,K;
    cin >> N >> K;
    vector<int> p(N);
    for(int i=0; i<N; i++){
        cin >> p[i];
    }
    sort(p.begin(), p.end());
    int sum=0;
    for(int i=0; i<K; i++){
        sum+=p[i];
    }
    cout << sum << endl;
    return 0;
}

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





typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef pair<int, int> pii;
typedef pair<ll, int> pli;
typedef pair<int, ll> pil;
typedef vector<pii> vpii;
typedef vector<pil> vpil;
typedef vector<pli> vpli;
typedef set<int> si;
typedef set<ll> sll;

const double pi = acos(-1.0);
const long long INF = 2e18;

#define ff first
#define ss second
#define pb push_back
#define mp make_pair
#define sz size()
#define in insert
#define endl "\n"

#define sqr(a) ((a) * (a))
#define jor(a) !(a&1)
#define bjor(a) (a&1)

#define all(a)  a.begin(), a.end()
#define mem(arr, b) memset(arr, b, sizeof(arr)) //memset only for -1 and 0
//fill(a, a+n, 5) //fill for any value

#define for0(i,b) for(int i=0;i<(b);i++)
#define for1(i,b) for(int i=1;i<=(b);i++)
#define forab(i,a,b) for(int i=(a);i<=(b);i++)
#define forba(i,b,a) for(int i=(b);i>=(a);i--)
#define rep(i,a,b,c) for(int i=(a);i!=(b);i+=(c))

void print(int a[], int n){ // for testing or debugging
    for(int i=0;i<n;i++)cout<<a[i]<<" "; cout<<endl;
}
//_____________________________________________________\\

map<ll,ll>m;

void findPrimeFactors(ll n)
{

    while (n%2== 0) m[2]++, n = n/2;

    for (ll i = 3; i*i <= n; i = i+2)
    {
        while (n%i == 0)
        {
            m[i]++;
            n = n/i;
        }
    }

    if (n > 2) m[n]++;
}


int main()
{
    ios_base::sync_with_stdio(0); cin.tie(NULL); cout.tie(NULL);
    
    int t = 1;
    
    while(t--)
    {
        ll N; cin>>N;
        findPrimeFactors(N);
        vi v;
        int ans=0; bool brk=0;
        for(auto t: m){ //cout<<t.ff<<" "<<t.ss<<endl;
            ll p=t.ss; 
            ll n=t.ff;
            ll q=1;
            
            while(q<=p){
                if(N>1){
                    ll d=1;
                    for(int m=1;m<=q; m++) d*=n;
                    
                    if(N % d==0){ //cout<<d<<endl;
                        N /= d; ans++; q++;
                    }
                    else q++, v.pb(d);
                    
                }
                else {brk=1; break;}
            }
            
            if(brk) break;
        }
        
        
        sort(all(v));
        
        int x=0;
        while(N>1){
        	
            if(N%v[x]==0) N/=v[x], ans++, x++;
            if(N>1 or x == v.sz) break;
        }
        
        cout<<ans;
    }
}

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


void __print(int x) {cerr << x;}
void __print(long x) {cerr << x;}
void __print(long long x) {cerr << x;}
void __print(unsigned x) {cerr << x;}
void __print(unsigned long x) {cerr << x;}
void __print(unsigned long long x) {cerr << x;}
void __print(float x) {cerr << x;}
void __print(double x) {cerr << x;}
void __print(long double x) {cerr << x;}
void __print(char x) {cerr << '\'' << x << '\'';}
void __print(const char *x) {cerr << '\"' << x << '\"';}
void __print(const string &x) {cerr << '\"' << x << '\"';}
void __print(bool x) {cerr << (x ? "true" : "false");}

template<typename T, typename V>
void __print(const pair<T, V> &x) {cerr << '{'; __print(x.first); cerr << ','; __print(x.second); cerr << '}';}
template<typename T>
void __print(const T &x) {int f = 0; cerr << '{'; for (auto &i : x) cerr << (f++ ? "," : ""), __print(i); cerr << "}";}
void _print() {cerr << "]\n";}
template <typename T, typename... V>
void _print(T t, V... v) {__print(t); if (sizeof...(v)) cerr << ", "; _print(v...);}

#define fo(i, n) for(int i=0; i<n; i++)
#define Fo(i, k, n) for(int i=k; i<n; i++)
#define w(x)  int x; cin>>x; while(x--)
#define watch(x) cout << (#x) << " is " << (x) << "\n"
#define watch2(x,y) cout <<(#x)<<" is "<<(x)<<" and "<<(#y)<<" is "<<(y)<<"\n"
#define watch3(x,y,z) cout <<(#x)<<" is "<<(x)<<" and "<<(#y)<<" is "<<(y)<<" and "<<(#z)<<" is "<<(z)<<"\n"
#define watch4(x,y,z,q) cout <<(#x)<<" is "<<(x)<<" and "<<(#y)<<" is "<<(y)<<" and "<<(#z)<<" is "<<(z)<<" and "<<(#q)<<" is "<<(q)<<"\n"
#define MOD 1000000007
#define INF 1000000007;
#define F first
#define S second
#define pb(x) push_back(x);


#define ll  long long
#define all(c) (c).begin(),(c).end()
#define endl "\n"

typedef vector<int> vl;
typedef vector< vl > vvl;
typedef pair< int, int> pll;
typedef map< int, int> mll;


#ifndef ONLINE_JUDGE
#define debug(x...) cerr << "[" << #x << "] = ["; _print(x)
#else
#define debug(x...)
#endif





void c_p_c()
{
#ifndef ONLINE_JUDGE
	ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif
}
void parray(int a[], int n) {
	for (int i = 0; i < n; i++) {
		cout << a[i] << " ";
	}
	cout << endl;
}
int no = 1, n1;
int recu(int n, int k, int val) {


	if (n == n1) {
		return min(val * 2, val + k);
	}
	return min( recu(n + 1, k, 2 * val), recu(n + 1, k, val + k)              );


}
int digit(int n) {

	int temp = 0;
	while (n) {
		temp += n % 10;
		n = n / 10;
		// temp++;
	}



	return temp;
}

bool check(int a[], int n) {
	for (int i = 0; i < n; ++i)
	{
		/* code */
		if (a[i] % 2)
			return false;
	}
	return true;
}


int main() {
	int i, m, n, k, c = 0, sum = 0;
	c_p_c();
		// cout<<"Sd"<<endl;>
	int a,b;

	cin>>n>>a>>b;

	for (int i = 1; i <=n; ++i)
	{
		/* code */
		int ans = digit(i);
		if(ans>=a and ans<=b)
			sum+=i;
	}
	cout<<sum<<endl;





	

}

Measured memory_bytes: 3640