akhauriyash/Code-Regression huggingface dataset:
//##MohK..
//09/05/2020 .... 3,02..
//Ya Rab....
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using ld=long double;
int main(){
    bool ok=false;
    ll k,a,b;
    cin>>k>>a>>b;
    for(int i=a;i<=b;i++){
        if(i%k==0){
            ok=true;
            break;
        }
    }
    if(ok==false)cout<<"NG"<<endl;
    else cout<<"OK"<<endl;


    return 0;
}



Measured memory_bytes: 3636
n = int(input())
s = input()
count = 0
for i in range(1000):
    flag = True
    key = str(i + 1000)[1:]
    if key[0] not in s:
        continue
    else:
        s2 = s[s.index(key[0]) + 1:]
        if key[1] not in s2:
            continue
        else:
            s3 = s2[s2.index(key[1]) + 1:]
            if key[2] not in s3:
                continue
            else:
                count += 1
print(count)

Measured memory_bytes: 3188
if __name__ == "__main__":
    s = input()
    t = input()

    test1  = len(s) - len(t) + 1

    test3 = []
    for i in range(test1):
        test2 = s[i:i+len(t)]
        test4 = 0
        for j in range(len(test2)):
            if test2[j] == t[j]:
                test4 += 1
        test3.append(test4)

    print(len(t)-max(test3))


Measured memory_bytes: 9072
def main():
    n = int(input())
    a = list(map(int,input().split()))
    x = 1
    if 0 in a:
        print(0)
        return
    for i in range(len(a)):
        b = a[i]
        x *= b
        if x > 1000000000000000000:
            print(-1)
            return
    print(x)
main()

Measured memory_bytes: 21700
#include<iostream>
#include<vector>
using namespace std;
int main(){
  int n;
  while(true){
    cin >> n;
    if(n == -1)break;
    vector<int> _4bit;
    while(true){
      if(n < 4)break;     
      _4bit.push_back(n%4);
      n /= 4;
    }
    _4bit.push_back(n);
    for(int i=_4bit.size()-1;i>=0;i--){
      cout << _4bit[i];
    }
    cout << endl;

  }
  return 0;
}

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

using i32 = int_fast32_t;
using i64 = int_fast64_t;
using u32 = uint_fast32_t;
using u64 = uint_fast64_t;
using f64 = double;
using f80 = long double;

#define FOR(v, a, b) for(i64 v = (a); v < (b); ++v)
#define FORE(v, a, b) for(i64 v = (a); v <= (b); ++v)
#define REP(v, n) FOR(v, 0, n)
#define REPE(v, n) FORE(v, 0, n)
#define REV(v, a, b) for(i64 v = (a); v >= (b); --v)
#define ALL(x) (x).begin(), (x).end()
#define RALL(x) (x).rbegin(), (x).rend()
#define ITR(it, c) for(auto it = (c).begin(); it != (c).end(); ++it)
#define RITR(it, c) for(auto it = (c).rbegin(); it != (c).rend(); ++it)
#define EXIST(c,x) ((c).find(x) != (c).end())
#define fst first
#define snd second
#define UNIQ(v) (v).erase(unique(ALL(v)), (v).end())
#define bit(i) (1LL<<(i))

#ifdef DEBUG
#include <Mylib/Debug/debug.cpp>
#else
#define dump(...) ((void)0)
#endif

using namespace std;

template <typename I> void join(ostream &ost, I s, I t, string d=" "){for(auto i=s; i!=t; ++i){if(i!=s)ost<<d; ost<<*i;}ost<<endl;}
template <typename T> istream& operator>>(istream &is, vector<T> &v){for(auto &a : v) is >> a; return is;}
template <typename T> void puts_all(const T &value){std::cout << value << "\n";}
template <typename T, typename ...Args> void puts_all(const T &value, const Args&... args){std::cout << value << " ";puts_all(args...);}

template <typename T, typename U> bool chmin(T &a, const U &b){return (a>b ? a=b, true : false);}
template <typename T, typename U> bool chmax(T &a, const U &b){return (a<b ? a=b, true : false);}
template <typename T, size_t N, typename U> void fill_array(T (&a)[N], const U &v){fill((U*)a, (U*)(a+N), v);}
template <typename T> auto make_vector(int n, int m, const T &value){return vector<vector<T>>(n, vector<T>(m, value));}


struct Init{
  Init(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(12);
    cerr << fixed << setprecision(12);
  }
}init;



int main(){
  int H, W, K;
  while(cin >> H >> W >> K){
    vector<string> s(H); cin >> s;

    int ans = INT_MAX;

    REP(i,1<<(H-1)){
      int p = __builtin_popcount(i) + 1;
      vector<int> count(p);
      int temp = __builtin_popcount(i);


      REP(j,W){
        vector<int> a(p);
        a[0] = s[0][j] - '0';

        int x = 0;
        FOR(k,1,H){
          if(i & bit(k-1)){
            x += 1;
          }

          a[x] += s[k][j] - '0';
        }

        bool f = false;

        dump(count, a);

        REP(k,p){
          if(count[k] + a[k] > K){
            f = true;
          }
        }

        if(f){
          count.assign(p, 0);
          ++temp;
        }

        REP(k,p){
          count[k] += a[k];
        }
      }

      bool no = false;
      REP(j,p){
        if(count[j] > K){
          no = true;
        }
      }
      

      dump(temp);

      if(not no) chmin(ans, temp);
    }
    
    puts_all(ans);
  }


  return 0;
}


Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS
#pragma comment(linker, "/stack:512000000")
#include<utility>
#include<iostream>
#include<fstream>
#include<vector>
#include<array>
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<cmath>
#include<ctime>
#include<functional>
#include<random>
#include<climits>
#include<queue>
#include<stack>
#include<deque>
#include<bitset>
#include<map>
#include<set>
#include<unordered_map>
#include<unordered_set>
#include<cassert>
#include<ccomplex>
#include<chrono>

#ifdef ONLINE_JUDGE
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,tune=native")
#pragma GCC optimize("unroll-loops")
#define int128 __int128
#else
#define int128 long long
#endif

#define all(x) x.begin(), x.end()
#define make_unique(x) sort(all((x))); (x).resize(unique(all((x))) - (x).begin())
#define mp make_pair
#define X first
#define Y second

using namespace std;

using ll = long long;
using ull = unsigned long long;
using ld = long double;
mt19937_64 gen(time(nullptr));

struct custom_hash {
    static uint64_t splitmix64(uint64_t x) {
        // http://xorshift.di.unimi.it/splitmix64.c
        x += 0x9e3779b97f4a7c15;
        x = (x ^ (x >> 30)) * 0xbf58476d1ce4e5b9;
        x = (x ^ (x >> 27)) * 0x94d049bb133111eb;
        return x ^ (x >> 31);
    }

    size_t operator()(uint64_t x) const {
        static const uint64_t FIXED_RANDOM = chrono::steady_clock::now().time_since_epoch().count();
        return splitmix64(x + FIXED_RANDOM);
    }
};

ll mod = 1e9 + 7;

namespace {
    ll mul(ll a, ll b) {
        ll val = a * b - (ll)((ld)a * b / mod) * mod;
        if (val < 0) val += mod;
        if (val >= mod) val -= mod;
        return val;
    }
    ll poww(ll a, ll b) {
        ll val = 1;
        a %= mod;
        while (b > 0) {
            if (b % 2) val = mul(a, val);
            a = mul(a, a);
            b >>= 1;
        }
        return val % mod;
    }
    ll inv(ll a) {
        return poww(a, mod - 2);
    }
}

ll const maxn = 3e5 + 5;
ll a[3005][3005];
ll d[3005][3005], used[3005][3005];

vector<ll> dx = { -1,0,1,0 };
vector<ll> dy = { 0, 1, 0, -1 };

ll n, m;

bool good(ll x, ll y) {
    return (x < n and x >= 0 and y < m and y >= 0 and !a[x][y]);
}

signed main() {
    ios_base::sync_with_stdio(0);cin.tie(0); cout.tie(0);
    ll n, x, t; cin >> n >> x >> t;
    cout << ((n + x - 1) / x) * t << endl;


    return 0;
}

/*


*/

/*

*/

Measured memory_bytes: 3536
#![allow(non_snake_case, unused_imports)]

// Input
macro_rules! input { (source = $s:expr, $($r:tt)*) => { let mut iter = $s.split_whitespace(); let mut next = || { iter.next().unwrap() }; input_inner!{next, $($r)*} }; ($($r:tt)*) => { let stdin = std::io::stdin(); let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock())); let mut next = move || -> String{ bytes.by_ref().map(|r|r.unwrap() as char).skip_while(|c|c.is_whitespace()).take_while(|c|!c.is_whitespace()).collect() }; input_inner!{next, $($r)*} }; }
macro_rules! input_inner { ($next:expr) => {}; ($next:expr, ) => {}; ($next:expr, $var:ident : $t:tt $($r:tt)*) => { let $var = read_value!($next, $t); input_inner!{$next $($r)*} };}
macro_rules! read_value { ($next:expr, ( $($t:tt),* )) => { ( $(read_value!($next, $t)),* ) }; ($next:expr, [ $t:tt ; $len:expr ]) => { (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>() }; ($next:expr, chars) => { read_value!($next, String).chars().collect::<Vec<char>>() }; ($next:expr, bytes) => { read_value!($next, String).into_bytes() }; ($next:expr, usize1) => { read_value!($next, usize) - 1 }; ($next:expr, $t:ty) => { $next().parse::<$t>().expect("Parse error") }; }

// Module
use std::cmp::{min,max};
use std::collections::{HashSet,HashMap,BTreeMap,VecDeque};

// Functions

// Main
fn main(){
    input!{
        K: usize,
        S: i64,
    }
    let mut ans = 0;
    for x in 0..K+1{
        for y in 0..K+1{
            let z = S - (x+y) as i64;
            if z >= 0 && z <= K as i64{
                ans += 1;
            }
        }
    }
    println!("{}",ans);
}

Measured memory_bytes: 4352
from collections import Counter
def main():
    M = 10 ** 6
    _ = int(input())
    A = list(map(int,input().split()))
    erato = [True] * (M+10)
    m = sorted(Counter(A).items())
    ans = 0
    for t in m:
        if t[1] == 1 and erato[t[0]]:
            ans += 1
        for i in range(t[0],M+1,t[0]):
            erato[i] = False
            
    print(ans)


if __name__ == '__main__':
    main()

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

using namespace std;
typedef long long ll;
#define mem(dp,a)           memset(dp,a,sizeof dp)
#define rep(i,a,b)          for(int i=a;i<b;i++)
#define repb(i,a,b)         for(ll i=a;i>=b;i--)
#define f(n)                for (ll i=0;i<n;i++)
#define pb(x)               push_back(x)
#define mp(x,y)             make_pair(x,y)
#define tr(c,it)            for(((c).begin())it=(c).begin();it!=(c).end();it++)
#define sz(c)               (c).size()
#define all(c)              (c).begin(),(c).end()
#define sl(a)               scanf("%lld",&a);
#define TH                  1000
#define F                   first
#define S                   second
#define N                   100005
ll MOD=pow(10,9)+7;
ll INF=1ll<<60;

int main()
{
    int n;cin>>n;
    int a[n+1],b[n+1],c[n+1];
    rep(i,1,n+1)
    {
        scanf("%d %d %d",&a[i],&b[i],&c[i]);
    }
    ll dpa[n+1],dpb[n+1],dpc[n+1];;
    mem(dpa,0);mem(dpb,0);mem(dpc,0);
    dpa[1]=a[1],dpb[1]=b[1],dpc[1]=c[1];
    dpa[2]=a[2]+max(dpb[1],dpc[1]);
    dpb[2]=b[2]+max(dpa[1],dpc[1]);
    dpc[2]=c[2]+max(dpa[1],dpb[1]);
    rep(i,3,n+1)
    {
        dpa[i]=a[i]+max(dpb[i-1],dpc[i-1]);
        dpb[i]=b[i]+max(dpa[i-1],dpc[i-1]);
        dpc[i]=c[i]+max(dpa[i-1],dpb[i-1]);
    }
    cout<<max(dpa[n],max(dpb[n],dpc[n]))<<endl;
}

Measured memory_bytes: 3712
void main()
{
    long N = rdElem;

    foreach (h; 1 .. 3501)
    {
        foreach (n; 1 .. 3501)
        {
            long numer = h * n * N;
            long dinom = 4 * h * n - (h + n) * N;
            if (dinom <= 0) continue;

            long w = numer / dinom, rem = numer % dinom;
            if (w > 0 && rem == 0)
            {
                writeln(h, " ", n, " ", w);
                return;
            }
        }
    }
}

T rdElem(T = long)()
if (!is(T == struct))
{
    return readln.chomp.to!T;
}

alias rdStr = rdElem!string;
alias rdDchar = rdElem!(dchar[]);

T rdElem(T)()
if (is(T == struct))
{
    T result;
    string[] input = rdRow!string;
    assert(T.tupleof.length == input.length);
    foreach (i, ref x; result.tupleof)
    {
        x = input[i].to!(typeof(x));
    }
    return result;
}

T[] rdRow(T = long)()
{
    return readln.split.to!(T[]);
}

T[] rdCol(T = long)(long col)
{
    return iota(col).map!(x => rdElem!T).array;
}

T[][] rdMat(T = long)(long col)
{
    return iota(col).map!(x => rdRow!T).array;
}

void wrMat(T = long)(T[][] mat)
{
    foreach (row; mat)
    {
        foreach (j, compo; row)
        {
            compo.write;
            if (j == row.length - 1) writeln;
            else " ".write;
        }
    }
}

import std.stdio;
import std.string;
import std.array;
import std.conv;
import std.algorithm;
import std.range;
import std.math;
import std.numeric;
import std.traits;
import std.container;
import std.functional;
import std.typecons;
import std.ascii;
import std.uni;

Measured memory_bytes: 256
#include <iostream>
#include <string> 
using namespace std;
 
int main() {
 
	string s;
	cin >> s;
	string t="AA";
	t[0] = s[0];
	t[1] = s[1];
	string u = "BB";
	u[0] = s[2];
	u[1] = s[3];
 
	int i = stoi(t);
	int j = stoi(u);

    // 文字列→数値の変換を実施しない場合，入力をint で受け取って，１００で割った商とあまりを
    // iとjに受けさせると良い．つまり
    //int L=a/100;
    //int R=a%100;
	if((i>12 || i==0) && j<=12 && j>0){
		cout << "YYMM" << endl;
	}
	else if (i <= 12 && i>0 && (j > 12 || j==0)) {
		cout << "MMYY" << endl;
	}
	else if (i <= 12 && j <= 12 && i>0 && j>0) {
		cout << "AMBIGUOUS" << endl;
	}
	else {
		cout << "NA" << endl;
	}
 
}

Measured memory_bytes: 256
fn main() {
    let nx = read_vec::<usize>();
    let n = nx[0];
    let x = nx[1];
    let l = read_vec::<usize>();

    let mut d = 0;
    let mut ret = 1;
    for i in 0..n {
        d += l[i];
        if d > x {
            break;
        }
        ret += 1;
    }
    println!("{}", ret);
}

fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().split_whitespace().map(|e| e.parse().ok().unwrap()).collect()
}


Measured memory_bytes: 4352
s = input()
t = input()
n = len(t)
a = [0] * 26
b = [0] * 26
c = []
d = []
fl = "Yes"

for i in range(n):
    ts = ord(s[i]) - 97
    tt = ord(t[i]) - 97
    
    if a[ts] == 0:
        a[ts] = max(a) + 1
    if b[tt] == 0:
        b[tt] = max(b) + 1
        
    if a[ts] != b[tt]:
        fl = "No"
        
print(fl)

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

using namespace std;

#define endl "\n"
typedef long long int ll;

inline void fastio(){ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);}
inline void setPrecision(int n){cout.precision(n);}

//DEBUG
#define dbg(x) cerr<<(#x)<<": "<<x<<endl
#define dbgV(x) cerr<<(#x)<<": "; for(auto it: x) cerr<<it<<" "; cerr<<endl;
#define dbgS(x) cerr<<(#x)<<": "; for(auto it: x) cerr<<it<<" "; cerr<<endl;
#define dbgM(x) cerr<<(#x)<<": "; for(auto it: x) cerr<<"["<<it.f<<", "<<it.s<<"] "; cerr<<endl;
#define dbg2D(x) cerr<<(#x)<<": \n"; for(auto y: x) { for(auto it: y) cerr<<it<<" "; cerr<<endl; } cerr<<endl;
#define dbgA(x, n) cerr<<(#x)<<": "; for(int i=0;i<n;++i) cerr<<x[i]<<" "; cerr<<endl;
#define dbgVP(x) cerr<<(#x)<<": "; for(auto it: x) cerr<<"["<<it.f<<", "<<it.s<<"] "; cerr<<endl;

ll MOD = 1e9 + 7;

int n;
int a[21][21];

ll done[1<<21];

ll pairs(int state){
    int idx = __builtin_popcount(state);
    if(idx == n) return 1;
    if(done[state] != -1) return done[state];
    ll ans = 0;
    for(int i=0;i<n;++i)
        if(a[idx][i] && !(state&(1<<i))){
            ans += pairs(state|(1<<i));
            if(ans >= MOD) ans-=MOD;
        }
    done[state] = ans;
    return ans;
}

int main(){
    fastio();
    cin>>n;
    for(int i=0;i<n;++i)
        for(int j=0;j<n;++j)
            cin>>a[i][j];
    memset(done, -1, sizeof(done));
    cout<<pairs(0);
    return 0;
}


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

#define rep(i, n) for (int i = 0; i < n; ++i)
#define ALL(a) (a).begin(), (a).end()
#define rALL(a) (a).rbegin(), (a).rend()
#define SZ(x) ((int)(x).size())
using ll = long long;
using ull = unsigned long long;
using P = pair<int, int>;
using llP = pair<ll, ll>;
using DoP = pair<double, double>;
const int di[] = {0, 1, 0, -1, 1, 1, -1, -1};
const int dj[] = {1, 0, -1, 0, 1, -1, 1, -1};
const int INF = 1 << 28;
const ll INF64 = 1ll << 55;
const int mod = 1000000007;
//const int mod = 998244353;

template <class T>inline bool chmin(T &a, const T b)
{
  if (a > b)
  {
    a = b;
    return true;
  }
  return false;
}
template <class T>inline bool chmax(T &a, const T b)
{
  if (a < b)
  {
    a = b;
    return true;
  }
  return false;
}
template <class T>inline void line_out(const vector<T> vec) {
  int n = SZ(vec);
  rep(i, n) {
    cout << vec[i];
    if(i < n-1) cout << " ";
  }
  cout << endl;
  return;
}

struct mint
{
  ll x; // typedef long long ll;
  mint(ll 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++()
  {
    if ((x += 1) >= mod)
      x -= mod;
    return *this;
  }
  mint &operator--()
  {
    if ((x += mod - 1) >= mod)
      x -= mod;
    return *this;
  }
  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;
  }
};


int main()
{
  ll a;
  string b;
  cin >> a >> b;
  ll B = 100*(b[0]-'0')+10*(b[2]-'0')+(b[3]-'0');
  a *= B;
  a /= 100;
  cout << a << endl;
}

Measured memory_bytes: 3604
#include<bits/stdc++.h>
#include<string>
using namespace std;
#define test(t) int t;cin>>t;while(t--)
#define lli long long int
#define pb push_back
#define MAX 1000000007
#define mod 1000000007
#include <string>
const lli infl=0x3f3f3f3f3f3f3f3fLL;

int main()
{  ios_base::sync_with_stdio(false);
	cin.tie(NULL);cout.tie(NULL);
  //test(t)
   {
       lli a,b,c,n,d,x,q,k=0,y,r,i,j,l,sum=0;
      string s;
      cin>>a>>b>>c>>d;
      while(a>0&&c>0)
      {
          c=c-b;
          a=a-d;
      }if(c<=0)
      cout<<"Yes";
      else
        cout<<"No";
    cout<<endl;
   }




}


Measured memory_bytes: 3628
#include <stdio.h>
#include <cctype>
#include <limits.h>
#include <math.h>
#include <complex>
#include <bitset>
#include <vector>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <cstring>
#include <string>
#include <sstream>
#include <algorithm>
#include <iomanip>
#include <iostream>

#define VARIABLE(x) cerr << #x << "=" << x << endl
#define BINARY(x) static_cast<bitset<16> >(x)
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define REP(i,m,n) for (int i=m;i<(int)(n);i++)
#define if_range(x, y, w, h) if (0<=(int)(x) && (int)(x)<(int)(w) && 0<=(int)(y) && (int)(y)<(int)(h))

const int INF = 1e9;
const double EPS = 1e-8;
const double PI = 3.14159;
int dx[4]={0, 1, 0, -1}, dy[4]={-1, 0, 1, 0};
using namespace std;
typedef long long ll;
typedef pair<int, int> P;

/* struct P {
	int x, y, n;
	P(int n, int x, int y):n(n), x(x), y(y){}
	P(){}
}; */


/** Problem1345 : Bit String Reordering**/
int main()
{
	int N, M;
	cin>>N>>M;
	vector<int> target(N), r(M);
	rep(i, N) cin>>target[i];
	rep(i, M) cin>>r[i];

	int tZero = 0;
	for (int i=0; i<N; i++)
		if (target[i]==0) tZero++;
	
	int ans=INF;
	for (int k=0; k<2; k++) {
		vector<int> R(N);
		
		int idx=0, nZero=0;
		bool tone=k;
		for (int i=0; i<M; i++) {
			for (int j=0; j<r[i]; j++) {
				R[idx++] = tone;
				if (!tone) nZero++;
			}
			tone = !tone;
		}
		
		if (tZero != nZero) continue;
		
		int tans = 0;
		for (int i=0; i<N; i++) {
			if (target[i] != R[i]) {
				for (int j=i+1; j<N; j++) {
					if (target[i] == R[j]) {
						for (int jj=j; jj>=i+1; jj--) {
							swap(R[jj-1], R[jj]);
							tans++;
						}
						break;
					}
				}
			}
		}
		ans = min(ans, tans);
	}
	
	cout << ans << endl;
}

Measured memory_bytes: 1196
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>

using namespace std;

long long cnt;

struct SSS
{
	string str;
	int val;
	SSS(string s = "", int v = 0) :str(s), val(v){};
};

void print(vector<SSS> &data){
	for (int i = 0; i < data.size(); ++i){
		cout << data[i].str << " " << data[i].val << endl;
	}
}

void print(vector<int> &data){
	for (int i = 0; i < data.size(); ++i) {
		cout << data[i];
		if (i == data.size() - 1) cout << endl;
		else cout << " ";
	}
}

void print_endl(vector<int> &data){
	for (int i = 0; i < data.size(); ++i) {
		cout << data[i] << endl;
	}
}

vector<int> tmp;
void mer(vector<int> &data, int l, int m, int r){
	for (int i = l; i < r; ++i) tmp[i] = data[i];
	cnt += (r - l);

	int p1(l), p2(m);
	while (p1 < m && p2 < r) {
		if (tmp[p1] <= tmp[p2]) data[l++] = tmp[p1++];
		else data[l++] = tmp[p2++];
	}
	while (p1 < m) data[l++] = tmp[p1++];
	while (p2 < r) data[l++] = tmp[p2++];
}

void merS(vector<int> &data, int l, int r){
	if (l + 1 < r){
		int m = l + (r - l) / 2;
		merS(data, l, m);
		merS(data, m, r);
		mer(data, l, m, r);
	}
}

int part(vector<int> &data, int l, int r){
	int v = data[r];

	int p1 = l - 1;
	int p2 = l;
	while (p2 < r) {
		if (data[p2] <= v) swap(data[++p1], data[p2]);
		p2++;
	}
	swap(data[++p1], data[r]);
	return p1;
}

int main()
{
	int n; cin >> n;
	vector<int> data(n, 0);
	for (int i = 0; i < n; ++i) cin >> data[i];

	vector<int> d1(data), d2(data);
	tmp.resize(n);
	merS(d1, 0, n);
	//print(data);
	//cout << cnt << endl;

	int piv = part(d2, 0, n - 1);

	for (int i = 0; i < n; ++i) {
		if (i == piv) cout << "[";
		cout << d2[i];
		if (i == piv) cout << "]";
		if (i == n - 1) cout << endl;
		else cout << " ";
	}

	return 0;
}

Measured memory_bytes: 4268
from math import factorial
input_ = input().split(' ')
M = int(input_[0])
N = int(input_[1])
P = 10**9 + 7
if M == N-1:
    print((factorial(N) * factorial(N-1)) % P)
elif M == N:
    print((factorial(N) * 2 * factorial(N)) % P)
elif M == N+1:
    print((factorial(N) * factorial(N+1)) % P)
else:
    print(0)

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

#define REP(i,s,n) for(int i=s;i<n;++i)
#define rep(i,n) REP(i,0,n)
#define fst first
#define snd second
#define pb push_back
#define ALL(x) x.begin(),x.end()
#define EPS (1e-9)
#define equals(a,b) (fabs((a)-(b))<EPS)

using namespace std;

bool LT(double a,double b) { return !equals(a,b) && a < b; }
bool LTE(double a,double b) { return equals(a,b) || a < b; }

const string YES = "";
const string NO  = "";

typedef long long ll;

void solve() {

}

int main() {
  int n;
  cin >> n;
  int ans = n / 2;
  if( n % 2 ) ++ans;
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 256
#pragma GCC optimize("O3")
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <string>
#include <cstring>
#include <deque>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <cfloat>
#include <climits>
#include <ctime>
#include <cassert>
#include <numeric>
#include <fstream>
#include <functional>
#include <bitset>
using namespace std;

using ll = long long;
using P = pair<ll, ll>;
using T = tuple<int, int, int>;

template <class T> inline T chmax(T &a, const T b) {return a = (a < b) ? b : a;}
template <class T> inline T chmin(T &a, const T b) {return a = (a > b) ? b : a;}

constexpr int MOD = 1e9 + 7;
constexpr int inf = 1e9;
constexpr long long INF = 1e18;

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

int dx[] = {1, 0, -1, 0};
int dy[] = {0, 1, 0, -1};

ll modpow(ll a, ll b){
    if(b == 0) return 1;
    else if(b % 2 == 0){
        ll d = modpow(a, b / 2) % MOD;
        return (d * d) % MOD;
    }
    else{
        return (a * modpow(a, b - 1)) % MOD;
    }
}

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

    int n; cin>>n;
    ll abzero = 0, azero = 0, bzero = 0;
    map<P, ll> cnt;
    for(int i=0; i<n; i++){
        ll a, b; cin>>a>>b;

        if(a == 0 && b == 0){
            abzero++;
        }
        else if(a == 0){
            azero++;
        }
        else if(b == 0){
            bzero++;
        }
        else{
            ll g = __gcd(abs(a), abs(b));
            a /= g, b /= g;

            if(0 > b) a *= -1, b *= -1;

            cnt[P(a, b)]++;
        }
    }

    set<P> used;
    ll ans = modpow(2, azero) + modpow(2, bzero) - 1;
    ans %= MOD;
    for(auto i : cnt){
        ll a = i.first.first, b = i.first.second;
        ll c = i.second;

        used.emplace(a, b);

        if(a < 0) a = -a;
        else b = -b;

        ll sum = 0;
        if(!used.count(P(b, a))){
            used.emplace(b, a);
            sum += modpow(2, c) + modpow(2, cnt[P(b, a)]) - 1;
            sum %= MOD;
            ans *= sum;
            ans %= MOD;
        }
    }

    ans += abzero;
    ans %= MOD;
    ans = (ans - 1 + MOD) % MOD;

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 53632
#include <iostream>
#include <string>
#include <vector>
#include <utility>
#include <functional>
#include <numeric>
#include <list>
#include <set>
#include <map>
#include <algorithm>
#include <cmath>
#include <limits>
#include <iomanip>
#include <bitset>
#include <queue>
#include <unordered_set>

using namespace std;
typedef long long ll;

template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
#define rep(i, n) for(int i = 0;i < n;i++)
const int INF = 1LL << 30;

int MOD = 1000000007;

struct UnionFind {
  vector<int> data;
  UnionFind(int size) : data(size, -1) { }
  bool unionSet(int x, int y) {
    x = root(x); y = root(y);
    if (x != y) {
      if (data[y] < data[x]) swap(x, y);
      data[x] += data[y]; data[y] = x;
    }
    return x != y;
  }
  bool findSet(int x, int y) {
    return root(x) == root(y);
  }
  int root(int x) {
    return data[x] < 0 ? x : data[x] = root(data[x]);
  }
  int size(int x) {
    return -data[root(x)];
  }
};

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

    int n; cin >> n;

    std::vector<pair<ll, int>> x_vec;
    std::vector<pair<ll, int>> y_vec;

    rep(i,n){
        ll x,y; cin >> x >> y;
        x_vec.push_back(make_pair(x, i));
        y_vec.push_back(make_pair(y, i));
    }

    sort(x_vec.begin(), x_vec.end());
    sort(y_vec.begin(), y_vec.end());

    std::vector<pair<ll, pair<int, int>>> dist;
    
    rep(i,n-1){
        dist.push_back(make_pair(x_vec[i+1].first-x_vec[i].first, make_pair(x_vec[i].second, x_vec[i+1].second)));
        dist.push_back(make_pair(y_vec[i+1].first-y_vec[i].first, make_pair(y_vec[i].second, y_vec[i+1].second)));
    }

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

    UnionFind uf(n);
    int root = dist[0].second.first;
    ll ans = 0LL;

    rep(i,2*n-2){
        //cout << dist[i].first << " " <<dist[i].second.first << " " << dist[i].second.second << endl;
        if(uf.findSet(dist[i].second.first, dist[i].second.second)) continue;
        if(uf.size(root) == n) break;
        uf.unionSet(dist[i].second.first, dist[i].second.second);
        ans+=dist[i].first;
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 9572
#include<iostream>
#include<iomanip>
#include<cmath>
#include <bits/stdc++.h>
using namespace std;

int main(){
    double a,b,c,C,Cr,S,L,h;
    cin >> a >> b >> C;

    //CrはCのラジアン表記
    Cr = C/180 * M_PI;
    S = 0.5 * a * b * sin(Cr);
    //cは残りの辺
    c = sqrt(a * a + b * b - 2 * a * b * cos(Cr));
    L = a + b + c;
    h = b * sin(Cr);

    cout << fixed << setprecision(8) << S << endl;
    cout << fixed << setprecision(8) << L << endl;
    cout << fixed << setprecision(8) << h << endl;
}








Measured memory_bytes: 3568
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
int main(){
    int n;
    cin >> n;
    vector<long long> a(n);
    for(int i = 0; i < n; i++) cin >> a[i];
    sort(a.begin(), a.end());
    int s, t;
    long long ans = 0;
    int ind = lower_bound(a.begin(), a.end(), a[n - 1] / 2) - a.begin();
    if(abs(a[n - 1] / 2 - a[ind]) > abs(a[n - 1] /2 - a[ind - 1])) ind--;
    if(ind == n - 1){
        ind--;
    }
    cout << a[n - 1] << ' ' << a[ind] << endl;
}

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

namespace ConsoleApplication1 {
    class Program {

        static void Main(string[] args) {

            string line = Console.ReadLine();
            string[] lines = line.Split(' ');
            int sum = 0;
            for (int i = 0; i < 4; i++) {
                int n = int.Parse(lines[i]);
                sum += n;
            }


            Console.WriteLine(sum);


//            Console.Read();

        }




    }
}



Measured memory_bytes: 15964
#include<iostream>
#include<queue>
#include<cstdio>
#include<cstdlib>
#include<vector>
using namespace std;

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

int R, C;
const int inf = 987564321;
int sr, sc, gr, gc;

struct Edge {int dst, cost;};
int memo[5010];

int dag_dp(int s, int t, int start, vector<int>X[5], vector<int> Y[5]) {
  REP(i, 5010) memo[i] = inf;
  priority_queue< pair<int,int> > up;
  up.push( make_pair(0, s) );
  memo[s] = 0;
  while( !up.empty() ) {
    int pos = up.top().second;
    int cost = -up.top().first;
    up.pop();
    if( pos == t ) return cost;

    if( pos == s ) {
      int n_color = (start + 1) % 5;
      for(int i = 0; i < (int)X[n_color].size(); i++) {
        int next = n_color * 1000 + i;
        int n_cost = cost + abs(sr - X[n_color][i]) + abs(sc - Y[n_color][i]);
        if( memo[next] > n_cost ) {
          memo[next] = n_cost; up.push( make_pair(-n_cost, next) );
        }
      }
    }
    else
    {
      int color = pos / 1000;
      int n_color = (color + 1) % 5;
      if( n_color == start ) {
        int next = t;
        int n_cost = cost + abs(gr - X[color][pos % 1000]) + abs(gc - Y[color][pos % 1000]);
        if( memo[next] > n_cost ) {
          memo[next] = n_cost; up.push( make_pair(-n_cost, next) );
        }
      } else {
        for(int i = 0; i < (int)X[n_color].size(); i++) {
          int next = n_color * 1000 + i;
          int n_cost = cost + abs(X[color][pos % 1000] - X[n_color][i]) + abs(Y[color][pos % 1000] - Y[n_color][i]);
          if( memo[next] > n_cost ) {
            memo[next] = n_cost; up.push( make_pair(-n_cost, next) );
          }
        }
      }
    }
  }
  return inf;
}

int main() {
  for(;;) {
    scanf("%d%d", &C, &R);
    if( R == 0 && C == 0 ) break;

    vector<int> X[5], Y[5];

    REP(r, R) REP(c, C) {
      char ch; scanf(" %c", &ch);
      if( ch == 'S' ) {
        sr = r;
        sc = c;
      }
      else if( ch == 'G' ) {
        gr = r;
        gc = c;
      }
      else if( ch != '.' ) {
        int n = ch - '1';
        X[n].push_back(r);
        Y[n].push_back(c);
      }
    }

    pair<int,int> res(inf, -1); // à, ÅÌ®«
    REP(start, 5) {
      int s = 5000;
      int t = 5001;

      /*
        int n = (start + 1) % 5;
        REP(i, X[n].size())
        graph[s].push_back( (Edge){n * 1000 + i, abs(sr - X[n][i]) + abs(sc - Y[n][i]) } );

        REP(step, 3) {
        int m = (n + 1) % 5;
        REP(i, X[n].size()) REP(j, X[m].size())
        graph[n * 1000 + i].push_back( (Edge) {m * 1000 + j, abs(X[n][i] - X[m][j]) + abs(Y[n][i] - Y[m][j]) } );
        n = m;
        }

        REP(i, X[n].size())
        graph[n * 1000 + i].push_back( (Edge){t, abs(gr - X[n][i]) + abs(gc - Y[n][i]) } );
      */
      int temp = dag_dp(s, t, start, X, Y);
      res = min( res, make_pair(temp, start) );
    }
    if( res.second == -1 ) cout << "NA" << endl;
    else cout << res.second + 1 << ' ' << res.first << endl;
  }
  return 0;
}

Measured memory_bytes: 1224
#include<iostream>
#include <cstdio>
#include<cstring>
#include <cstdlib>  
#include<cmath>   
#include <cctype>
#include<string>
#include<set>
#include <iomanip>
#include <map>
#include<algorithm>
#include <functional>
#include<vector>
#include<climits>
#include<stack>
#include<queue>
#include <deque>
#include <climits>
#include <typeinfo>
#include <utility> 
using namespace std;
using ll = long long;
double pi() { return 3.14; }
int sum(int a, int b) { return a + b; }
int mul(int a, int b) { return a * b; }
ll LGCD(ll x, ll y) {if (x % y == 0) return y;else return LGCD(y, x % y);}
ll LLCM(ll x, ll y) {return x * y / LGCD(x, y);}

int GCD(int x, int y) {if (x % y == 0) return y;else return GCD(y, x % y);}
int LCM(int x, int y) {return x * y / GCD(x, y);}
ll dp[10000][10000];
ll combination(ll n, ll r) {

	if (n == r)
	{
		dp[n][n] = 1;
		
	}
	else if (r == 0) {
		return dp[n][0] = 1;
		
	}
	else if (r == 1) {
		
		return dp[n][1]=n;
	}
	else {
		dp[n][r]=dp[n - 1][r - 1] % 1000000007 + dp[n - 1][r] % 1000000007;
		return dp[n][r]=combination(n - 1, r - 1) % 1000000007 + combination(n - 1, r) % 1000000007;
	}
}

int main() {
	int N,A,B;
	cin >> N >> A >> B;
	if (A*N < B) { cout <<N * A<< endl; }
	else cout << B<< endl;










//	cout<<""<<endl;
	return 0;
}

Measured memory_bytes: 256
#!/usr/bin/env python3
import sys
import numpy as np

def solve(N: int, K: int, h: "List[int]"):

    # print((np.array(h) >= K).sum())
    p = 0
    for x in h:
        if x >= K: p+=1
    print(p)
    return


# Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    K = int(next(tokens))  # type: int
    h = [int(next(tokens)) for _ in range(N)]  # type: "List[int]"
    solve(N, K, h)

if __name__ == '__main__':
    main()


Measured memory_bytes: 21324
#include<iostream>
using namespace std;
int main(void)
{
    int mo,fite,hund,fiten,ten,go,one;
    while(1){
    cin>>mo;
    if(mo==0)break;
    mo=1000-mo;
    fite=mo/500;
    hund=mo%500/100;
    fiten=mo%500%100/50;
    ten=mo%500%100%50/10;
    go=mo%500%100%50%10/5;
    one=mo%500%100%50%10%5;
    //cout<<fite<<" "<<hund<<" "<<fiten<<" "<<ten<<" "<<go<<" "<<one<<"\n";
    cout<<fite+hund+fiten+ten+go+one<<"\n";
}
}

Measured memory_bytes: 1160
#include <bits/stdc++.h>
using namespace std;
#define LL long long 
#define LLU long long unsigned
#define rarr(arr, n) for(int aab = 0; aab < n; aab++){cin >> arr[aab];}
#define parr(arr, n) for(int aab = 0; aab < n; aab++){cout << arr[aab] << " ";}
#define pb push_back
#define f first
#define s second
#define all(x) x.begin(), x.end()
#define debug(x) cout << #x << " = " << x << "\n";

#define freopen freopen("in.txt", "r", stdin);freopen("out.txt", "w", stdout);ios_base::sync_with_stdio(0);cin.tie(0);

int main(){
	long long int x, y = 100, ans = 0;
	cin >> x;
	while(y < x){
		y += y / 100;
		ans++;
	}
	cout << ans;
} 

Measured memory_bytes: 3648
#include<iostream>
#include<map>
#include<vector>
#include<algorithm>
#include<cmath>
#include<climits>
#include<ctime>
#include<cstring>
#include<stack>
#include<queue>
#include<sstream>
#include<string>
#include<set>
#include<array>

#define ALL(v) (v).begin(),(v).end()
#define REP(i,p,n) for(int i=p;i<(int)(n);++i)
#define rep(i,n) REP(i,0,n)
#define DUMP(list) cout << "{ "; for(auto nth : list){ cout << nth << " "; } cout << "}" << endl
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i);
#define UNIQUE(a) a.erase(unique(ALL(a)), a.end())

using namespace std;

int main(){
  
  int A,B,N;
  string S;
  cin >> N >> A >> B;
  cin >> S;

  int ac=0,bc=0;

  rep(i,S.size()){
    if(S[i] == 'a' && ac+bc<A+B){
      cout << "Yes" << endl;
      ac++;
    }else if(S[i] == 'b' && bc<B && ac+bc<A+B){
      cout << "Yes" << endl;
      bc++;
    }else{
      cout << "No" << endl;
    }
  }


}




Measured memory_bytes: 896
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		Scanner stdIn = new Scanner(System.in);
		
		String s = stdIn.next();
		StringBuilder sb = new StringBuilder(s);
		sb.setCharAt(3,'8');
		System.out.println(sb.toString());

	}

}


Measured memory_bytes: 35524
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ull unsigned ll
#define PI acos(-1)
#define vi vector<int>
#define pi pair<int, int>
#define pl pair<ll, ll>
template<typename T> using v2 = vector<vector<T>>;
template<typename T> using v3 = vector<vector<vector<T>>>;
template<class T> istream &operator>>(istream&is,vector<T>&v){for(auto &elemnt:v)is>>elemnt;return is;}
template<class T,class U> istream &operator>>(istream&is,pair<T,U>&p){is>>p.first>>p.second;return is;}
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; }
const int MOD = 1e9 + 7;
const int INF = 1e9 + 200;
const ll INFLL = 2e18 + 200;

int main() {
    int N;
    cin >> N;
    for (int i = 0; i <= 10; i++) {
        if (N <= 1000 * i) {
            cout << 1000 * i - N << endl;
            return 0;
        }
    }
}


Measured memory_bytes: 3620
#include <cstdio>
#define MAXN 15
char s1[MAXN], s2[MAXN], s3[MAXN];
int main() {
	scanf("%s%s%s", s1, s2, s3);
	printf("%c%c%c", s1[0]-32, s2[0]-32, s3[0]-32);
	return 0;
} 


Measured memory_bytes: 128
#include <iostream>
#include <vector>
#include <array>
#include <set>
#include <cmath>
#include <string>
#include <sstream>
#include <queue> 
#include <list>
#include <stack>
#include <unordered_map>
#include <algorithm> 
#include <numeric>  
#include <functional>
#include <cassert>
#include <bitset>
#include <cctype>  
#include <iomanip> 
#include <limits>  
#include <regex>
// std::numeric_limits<int>::max(), min()
// std::setprecision(X)
// std::islower(), std::isupper(), std::tolower, std::toupper
// std::accumulate(m.begin(), m.end(), 0LL);
// std::sort(begin(),end()) // 0, 1, 2, 3 ,4 (default, less);
// std::priority_queue<int, vector<int>, less<int>> que; // 4, 3, 2, 1 (defualt, less) : 
// if ( std::regex_match(S, std::regex("(dream|dreamer|erase|eraser)*")) ) std::cout << "YES" << std::endl;

#define rep(i,n)  for(int i = 0; i < (int)(n);    i++)
#define sz(x)     ((int)(x).size())
#define all(x)    (x).begin(),(x).end()

using ll = long long;

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

ll check(ll x) {
  ll l = -1000, r = 1000;
  while( r - l > 1 ) {
    ll mid = (l+r)/2;
    ll c = std::pow(mid,5);
    if ( c < x ) l = mid;
    else r = mid;
  }
  return r;
}

int main (void) {
  std::cin.tie(0);  std::ios::sync_with_stdio(false);
  ll X; std::cin >> X;

  for(ll b=-1000; b<=1000; b++) {
    ll a5 = b*b*b*b*b + X;
    ll a = check(a5);
    if ( a5 == a*a*a*a*a ) {
      std::cout << a << " " << b << std::endl;
      return 0;
    }
  }
  assert(0);
  return 0;
}



Measured memory_bytes: 4028
#include <bits/stdc++.h>
namespace Numeric {
    template<typename T, typename N> 
    T pow(T a, N n) {
        T r(1);
        while (n > 0) {
            if (n & 1) { r *= a; }
            a *= a; n >>= 1;
        }
        return r;
    }
    template<int mod>
    struct IntMod {
        int value;
        IntMod(int value_ = 0) : value(value_) {
            if (value >= mod) value -= mod;
            if (value < 0) value += mod;
        }
        IntMod& operator+=(IntMod num) {
            value += num.value;
            if (value >= mod) value -= mod;
            return *this;
        }
        IntMod& operator-=(IntMod num) {
            value -= num.value;
            if (value < 0) value += mod;
            return *this;
        }
        IntMod operator+(IntMod num) const { return IntMod(*this) += num; }
        IntMod operator-(IntMod num) const { return IntMod(*this) -= num; }
        IntMod operator*(IntMod num) const { return IntMod(int(value * 1LL * num.value % mod)); }
        IntMod& operator*=(IntMod num) { return *this = *this * num; }
        IntMod operator/(IntMod num) const { return *this * pow(num, mod-2); }
        IntMod& operator/=(IntMod num) { return *this = *this / num; }
    };
    template<int mod> bool operator<(IntMod<mod> a,IntMod<mod> b) { return a.value < b.value; }
    template<int mod>
    std::ostream& operator<<(std::ostream& os, const IntMod<mod>& num) {
        return os << num.value;
    }
}
// -----------------------------------------------------
const int mod = (int)1e9+7, NMAX = 500500;
using Int = Numeric::IntMod<mod>;
const auto fact = [](){
    std::vector<Int> answ(NMAX,1);
    for (int i = 1; i < NMAX; i++) answ[i] = answ[i-1] * i;
    return answ;
}();
Int C(int n, int k) {
    if (k < 0 || k > n) return 0;
    return fact[n] / (fact[k] * fact[n-k]);
}
int main() {
    int n, m; std::cin >> n >> m;
    Int a = C(m,n) * fact[n];
    Int b = 0;
    for (int i = 0; i <= n; i++) {
        // at least i equal positions
        Int curr = C(n,i)*C(m-i,n-i)*fact[n-i];
        if (i % 2 == 0) b+=curr;
        else b -= curr;
    }
    std::cout << a * b << std::endl;
}

Measured memory_bytes: 4920
fun main(args: Array<String>) {
    val (n, a, b) = readLine()!!.split(" ").subList(0, 3).map { it.toInt() }
    var total = 0
    for (x in 1..n) {
        val s = x.toString().map(Character::getNumericValue).sum()
        if (s in a..b)   {
            total += x
        }
    }
    print(total)
}


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

using namespace std;

#define M 1000000007
#define pb push_back
#define f first
#define s second
#define rep(i, st, ed) for(int i=st; i<ed; i++)
#define repn(i, st, ed) for(int i=st; i<=ed; i++)
#define repb(i, ed, st) for(int i=ed; i>=st; i--)

typedef long long ll;
typedef unsigned long long int llt;
typedef long double ld;

const long double PI  =3.141592653589793238463;
const int N = 5e5 + 10;
const ll INF = 1LL << 60;

template<class T> void chmax(T &a,T b) { if (a<b) a=b;}
template<class T> void chmin(T &a,T b) { if (a>b) a=b;}


vector<int> g[N];
bool viss[N];
int vis[N];

// Normal DFS
void dfs(int curr, int par)
{
  for(auto x: g[curr])
    if(x != par)
      dfs(x, curr);
}

// DFS with visiting status
void dfs1(int curr, int par)
{
  viss[curr] = 1;
  for(auto x: g[curr])
    if(!viss[x])
      dfs1(x, curr);
}

// DFS with strongly connected component
void dfs2(int curr, int par, int num)
{
  vis[curr] = num;
  for(auto x: g[curr])
    if(vis[x] == 0)
      dfs2(x, curr, num);
}

// XOR from 0 to n
ll fxor(ll n)
{
  if(n < 0) return 0;
  if(n % 4 == 3) return 0;
  else if(n % 4 == 0) return n;
  else if(n % 4 == 1) return n^(n-1);
  else if(n%4 == 2) return n^(n-1)^(n-2);
}

// Power in logn with mod 1000000007
llt ppow(llt x, llt y)
{
  llt res = 1;
  while(y > 0){
    if(y&1)
      res = (res * x)%M;
    y = y >> 1;
    x = (x * x)%M;
  }
  return res;
}

// Factorial with dp
llt factdp[N];
llt fact(llt x)
{
  if(x == 0) return 1;
  if(x == 1) return 1;
  if(factdp[x] != 0) return factdp[x];
  return factdp[x] = (x*fact(x-1))%M;
}
// Combination
ll modcomb(ll n, ll r)
{
  if(n < r) return 0;
  ll res = fact(n);
  (res *= ppow(fact(r), M-2)) %= M;
  (res *= ppow(fact(n-r), M-2)) %= M;
  return res;
}

// String return to base b
string ansConv ="";
void convert10tob(llt N, int b)
{
     if (N == 0)
        return;
     int x = N % b;
     N /= b;
     if (x < 0)
        N += 1;
     convert10tob(N, b);
     ansConv += to_string(x);
     return;
}

// Convert string to num wiht base b
llt convertstrtob(string a, int b)
{
  llt aa = 0;
  llt mul = 1;
  for(int i=a.length()-1; i>=0; i--)
  {
    int curr = a[i] - '0';
    aa += (curr * mul);
    mul *= b;
  }
  return aa;
}

// Union Find
// Find()
int parent[N], ran[N];
int find(int x)
{
    if(parent[x]==x)return x;
    else return parent[x]=find(parent[x]);
}
// Union()
void unite(int x,int y){
    x=find(x);
    y=find(y);
    if(x==y)return;

    if(ran[x]<ran[y])
        parent[x]=y;
    else{
        parent[y]=x;
        if(ran[x]==ran[y])ran[x]++;
    }
}

// Main Code

int main()
{
 int n, k;
 cin>>n>>k;
 int arr[n];
 rep(i, 0, n) cin>>arr[i];
 sort(arr, arr+n, greater<int>());
 int ans = 0;
 rep(i, 0, k) ans += arr[i];
 cout<<ans<<endl;
}


Measured memory_bytes: 14080
#include<stdio.h>
#include<vector>
#include<algorithm>
#include<string>
#include<iostream>
using namespace std;
int dp[310][310];
int cst[310][310];
int get(string a, string b)
{
	//cout << a << endl << b << endl;
	for (int i = 0; i <= a.size(); i++)for (int j = 0; j <= b.size(); j++)dp[i][j] = 1000000000, cst[i][j] = 0;
	for (int i = 0; i < a.size(); i++)
	{
		for (int j = 0; j < b.size(); j++)
		{
			if (a[i] == b[j])
			{
				cst[a.size() - i][b.size() - j]++;
			}
		}
	}
	for (int i = 1; i <= a.size(); i++)for (int j = 1; j <= b.size(); j++)cst[i][j] += cst[i - 1][j - 1];
	dp[a.size()][b.size()] = 0;
	for (int i = a.size(); i >= 0; i--)
	{
		for (int j = b.size(); j >= 0; j--)
		{
			if (i != 0)dp[i - 1][j] = min(dp[i - 1][j], dp[i][j] + cst[i][j]);
			if (j != 0)dp[i][j - 1] = min(dp[i][j - 1], dp[i][j] + cst[i][j]);
		}
	}
	return dp[0][0];
}
string d[310];
int main()
{
	int mx, my;
	scanf("%d%d", &mx, &my);
	for (int i = 0; i < mx; i++)cin >> d[i];
	int ans = 0;
	for (int i = 0; i < my - 1; i++)
	{
		string s, t;
		for (int j = mx - 1; j >= 0; j--)s.push_back(d[j][i]), t.push_back(d[j][i + 1]);
		ans += get(s, t);
	}
	printf("%d\n", ans);
}

Measured memory_bytes: 1152
#define _CRT_SECURE_NO_WARNINGS
#include<cstdio>
#include<cmath>
#include<cstring>
#include<iostream>
#include<algorithm>
#include<utility>
#include<iomanip>
#include<vector>
#include<string>
#include<queue>
#include<stack>
#include<map>
#include<list>
#define rep(i,n) for(int i=0;i<(int)n;i++)
#define repp(i,k,n) for(int i=k;i<(int)n;i++)
#define F first
#define S second
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 };
struct XY
{
	int x;
	int y;
};
int in()
{
	int x;
	cin >> x;
	return x;
}

/*
(char)'1' - (int)48 = (int)1;
　1111181
*/
////////////////////////////////////////////////////
int a[200];
int n;
bool se(int now,int m,int j)
{
	
	if (now == m)return true;
	if (j == n)return false;
	if (se(now + a[j], m, j + 1) || se(now, m, j + 1))return true;
}


int main()
{
	
	cin >> n;
	rep(i, n)cin >> a[i];
	int q;
	cin >> q;
	rep(i, q)
	{
		int m;
		cin >> m;
		if (se(0, m, 0))cout << "yes" << endl;
		else cout << "no" << endl;
	}
}

Measured memory_bytes: 1152
#include <stdio.h>
#include <string.h>
typedef struct {int d,f;}Time;
Time S[101];
int Adj[101][101],n,tokei=0;
void DFS();
void N(int);
int main(){
  int v,i,j,u,k;
  memset(Adj, 0, 101*101*sizeof(int));
  memset(S, 0, 101*sizeof(Time));
  scanf("%d",&n);
  for(i=1;i<=n;i++){
    scanf("%d%d",&u,&k);
    for(j=0;j<k;j++){
      scanf("%d",&v);
      Adj[u][v]=1;
    }
  }

  DFS();

  for(i=1;i<=n;i++){
    printf("%d %d %d\n",i,S[i].d,S[i].f);
  }
  return 0;
}
void DFS(){
  int i;
  for(i=1;i<=n;i++){
    N(i);
  }
}
void N (int i){
  int k;
  if(S[i].d!=0)return;
  tokei++;
  S[i].d=tokei;
  for(k=1;k<=n;k++){
    if(Adj[i][k]==1)
      N(k);
  }
  tokei++;
  S[i].f=tokei;
}
	   



Measured memory_bytes: 2112
def get_i() #空白区切の入力を数値(整数)の配列で返す
  return gets.chomp.split(" ").map(&:to_i)
end
def get_f() #空白区切の入力を数値(実数)の配列で返す
  return gets.chomp.split(" ").map(&:to_f)
end
def get() #空白区切の入力を文字列の配列で返す
  return gets.chomp.split(" ")
end
def get_nsp() #入力されたものを一文字ずつに区切った文字列の配列で返す
  return gets.chomp.split("")
end
def yn_judge(bool,y="Yes",n="No") #boolに真偽を投げることで、trueならy、falseならnの値を出力する
  return bool ? y : n 
end
def array(size1,init=nil,size2=-1) #size2に二次元配列時の最初の要素数、size1に次の配列の大きさ、initに初期値を投げることでその配列を返す
  if size2==-1
    return Array.new(size1){init}
  else
    return Array.new(size2){Array.new(size1){init}}
  end
end

N=gets.to_i
L=get_i
sum=L.inject(:+)
sum-=L.max
if sum>L.max
    puts "Yes"
else
    puts "No"
end

Measured memory_bytes: 1788
#include <bits/stdc++.h>
#define F first
#define S second
#define PB push_back
#define MP make_pair

using namespace std;

typedef vector<int> vi;
typedef pair<int,int> pi;
typedef long long ll;


void solve(){
    int n; cin >> n;
    vi v(n);
    for(int i = 0; i < n; i++) cin >> v[i];

    int ans = 10000000;
    for(int i=0; i<100; i++){
        int op = 0;
        for(int j = 0; j < n; j++){
            op += (v[j] - i)*(v[j] - i);
        }
        ans = min(ans,op);
    }
    cout << ans << endl;
}

int main(){
    /*
    int t; cin >> t;
    while(t--) solve();
    */
    solve();
    return 0;
}


Measured memory_bytes: 256