akhauriyash/Code-Regression huggingface dataset:
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Main main = new Main();
        main.solve();
    }
    public void solve() {
        Scanner scan = new Scanner(new BufferedReader(new InputStreamReader(System.in)));
        long L = scan.nextLong();
        long R = scan.nextLong();
        if (2018 < R - L) {
            System.out.println(0);
            return;
        }
        long answer = Integer.MAX_VALUE;
        for (long i = L; i < R; i++) {
            for (long j = i + 1; j <= R; j++) {
                answer = Math.min(answer, (i * j) % 2019);
            }
        }
        System.out.println(answer);
    }
}


Measured memory_bytes: 21844
#include <bits/stdc++.h>
#define fin ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define ii pair<int,int>
#define F first
#define S second
#define pb push_back
#define pf push_front
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define fore(i,a,b) for(int i = a;i < b; i+= 1)
#define forr(i,a) for(int i = a; i >= 0; i--)
#define fori(i,m) for(auto i = m.begin(); i != m.end(); i++) 
#define w(t) while(t--)
#define sz(s) int(s.size())
#define cls(a,car) memset(a,car,sizeof (a))
#define ff(x) cerr << #x << " is " << x << '\n'
#define FL freopen("in", "r", stdin),freopen("out", "w", stdout);
#define time cerr << "Time elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " s.\n"
using namespace std;
typedef unsigned long long ll;
typedef vector<int> vi;
typedef vector<ii> vii;
const int N = 1 * 1e5 + 5;
const ll mod = 1e9 + 7;
const int INF = INT_MAX;
const ll INFCAD  = ll(INT_MAX) * 2 + 1;
const double E = 1e-9;
int dx[] = {1, 0, -1, 0}, dy[] = {0, 1, 0, -1};
// fflush(stdout)
// cout << flush
// a + b = a ^ b + 2 * (a & b) 
int main(){
    //FL;
    fin;
    int a, b, c, d;
    cin >> a >> b >> c >> d;
    if(abs(a - b) <= d && abs(b - c) <= d)
        cout << "Yes\n";
    else{
        if(abs(a - c) <= d)
            cout << "Yes\n";
        else
        cout << "No\n";
    } 
    time;
    return 0;
}   

Measured memory_bytes: 256
#include <cstdio>
#include <iostream>
#include <string>
#include <algorithm>
#include <cstring>
#include <queue>
#include <utility>
#include <vector>
#include <map>
#include <set>
#include <cmath>
#include <deque>

using namespace std;
typedef long long LL;
typedef pair<int, int> pii;
const int MAXN = 878;
int G[MAXN][MAXN];
int tag[MAXN], cnt[2];
bool visit[MAXN], now[MAXN], pre[MAXN];

bool dfs(int N, int cur, int tg) {
     visit[cur] = 1;
     tag[cur] = tg;
     cnt[tg]++;
     bool OK = true;
     for (int i = 1; i <= N; i++) {
         if (cur == i || G[cur][i]) continue;
         if (visit[i] && tg == tag[i]) OK = false;
         else if (!visit[i] && !dfs(N, i, tg ^ 1)) OK = false;
     }
     return OK;
}

int main() {
    int N, M;
    scanf("%d %d", &N, &M);
    for (int i = 0; i < M; i++) {
        int x, y;
        scanf("%d %d", &x, &y);
        G[x][y] = 1;
        G[y][x] = 1;
    }
    int sum = 0, ans = M;
    now[0] = 1;
    for (int i = 1; i <= N; i++) {
        if (!visit[i]) {
           sum++;
           cnt[1] = cnt[0] = 0;
           memset(pre, 0, sizeof(pre));
           if (!dfs(N, i, 0)) ans = -1;
           for (int j = 0; j <= N; j++) {
               pre[j + cnt[0]] |= now[j];
               pre[j + cnt[1]] |= now[j];
           }
           for (int j = 0; j <= N; j++) now[j] = pre[j];
        }
    }
    for (int i = 0; i <= N; i++) {
        if (now[i]) {
           ans = min(ans, (i * (i - 1) + (N - i) * (N - i - 1)) / 2);
        }
    }
    printf("%d\n", ans);
    return 0;
}


Measured memory_bytes: 2688
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0; i<n; i++)
#define PI 3.14159265359
#define INF 1000100100
#define all(x) (x).begin(),(x).end()
typedef long long ll;
#define P pair<ll, ll>
#define PP pair<P,P>
using namespace std;

int main(){
    int n; cin >> n;
    string s; cin >> s;
    int Q; cin >> Q;
    vector<vector<int> > ap(26);
    rep(i,n) ap[s[i]-'a'].push_back(i);
    rep(i,Q){
        int a; cin >> a;
        if(a==1){
            int it; char next; cin >> it >> next;
            it--;
            auto whe=lower_bound(all(ap[s[it]-'a']),it);
            ap[s[it]-'a'].erase(whe);
            //if(ap[next-'a'].empty()) ap[next-'a'].push_back(it);
            //else{
            whe=lower_bound(all(ap[next-'a']),it);
            whe=ap[next-'a'].insert(whe,it);
            //}
          	s[it]=next;
        }
        else{
            int l,r; cin>> l >> r;
         	l--; r--;
            int ans=0;
            rep(j,26){
                if(ap[j].empty()) continue;
                auto whe2 = lower_bound(all(ap[j]),l);
                if(ap[j][whe2-ap[j].begin()]<=r && whe2-ap[j].begin()!=ap[j].size()) ans++;
            }
            cout << ans << endl;
        }
    }
return 0;
}


Measured memory_bytes: 3844
package main

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

var sc *bufio.Scanner

func nextInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}

type p struct {
	x int
	y int
	z int
}

func answer(reader io.Reader, writer io.Writer) {
	sc = bufio.NewScanner(reader)
	sc.Split(bufio.ScanWords)
	x := nextInt()
	y := nextInt()
	z := nextInt()
	k := nextInt()
	a := make([]int, x)
	b := make([]int, y)
	c := make([]int, z)
	for i := 0; i < x; i++ {
		a[i] = nextInt()
	}
	for i := 0; i < y; i++ {
		b[i] = nextInt()
	}
	for i := 0; i < z; i++ {
		c[i] = nextInt()
	}
	sort.Ints(a)
	sort.Ints(b)
	sort.Ints(c)
	s := p{x: x - 1, y: y - 1, z: z - 1}
	ca := make(map[p]struct{})
	cb := make(map[p]struct{})
	ca[s] = struct{}{}

	for k > 0 && len(ca) > 0 {
		maxv := 0
		var maxe p
		for aa := range ca {
			v := a[aa.x] + b[aa.y] + c[aa.z]
			if v > maxv {
				maxe = aa
				maxv = v
			}
		}
		delete(ca, maxe)
		cb[maxe] = struct{}{}
		if maxe.x > 0 {
			s := p{x: maxe.x - 1, y: maxe.y, z: maxe.z}
			if _, ok := cb[s]; !ok {
				ca[s] = struct{}{}
			}
		}
		if maxe.y > 0 {
			s := p{x: maxe.x, y: maxe.y - 1, z: maxe.z}
			if _, ok := cb[s]; !ok {
				ca[s] = struct{}{}
			}
		}
		if maxe.z > 0 {
			s := p{x: maxe.x, y: maxe.y, z: maxe.z - 1}
			if _, ok := cb[s]; !ok {
				ca[s] = struct{}{}
			}
		}
		fmt.Fprintf(writer, "%d\n", a[maxe.x]+b[maxe.y]+c[maxe.z])
		k--
	}
}

func main() {
	answer(os.Stdin, os.Stdout)
}


Measured memory_bytes: 1536
def resolve():
    N = int(input())
    S = input()
    rc = S.count('R')
    bc = S.count('B')
    gc = S.count('G')

    cnt = rc * bc * gc

    for i in range(0, N):
        for d in range(0, N):
            j = i + d
            k = j + d
            if N < k+1:
                break
            if S[i] != S[j] and S[j] != S[k] and S[k] != S[i]:
                cnt -= 1
    print(cnt)

if __name__ == '__main__':
    resolve()


Measured memory_bytes: 9208
#include <iostream>
#include <iomanip>
#include <vector>
#include <algorithm>
#include <numeric>
#include <functional>
#include <cmath>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <sstream>
#include <string>

#define repd(i,a,b) for (int i=(a);i<(b);i++)
#define rep(i,n) repd(i,0,n)
#define var auto
#define mod 1000000007
#define inf 2147483647
typedef long long ll;

using namespace std;

int inputValue(){
    int a;
    cin >> a;
    return a;
}

template <typename T>
void output(T a, int precision) {
    if(precision > 0){
        cout << fixed << setprecision(precision)  << a << "\n";
    }
    else{
        cout << a << "\n";
    }
}

// end of template
class rmq {
private:
    int n;
    int sz;
public:
    vector<ll> v;
    rmq(int a){
        n = 1;
        for(; n * 2 < a;){
            n *= 2;
        }
        sz = n * 2;
        v.resize(4 * n - 1, 0); // sum: assign 0 for all elements
    }
    
    void update(int i, ll x){
        i += sz - 1;
        v[i] += x; // sum
        while(i > 0){
            i = (i - 1) / 2;
            // v[i] = min(v[2 * i + 1], v[2 * i + 2]);
            v[i] = v[2 * i + 1] + v[2 * i + 2]; // sum
        }
    }
    
    ll query_(int a, int b, int k, int l, int r){
        if(r <= a || b <= l) return 0; // sum
        if(a <= l && r <= b) return v[k];
        else{
            ll vl = query_(a, b, k * 2 + 1, l, (l + r) / 2);
            ll vr = query_(a, b, k * 2 + 2, (l + r) / 2, r);
            return vl + vr; // sum
        }
    }
    
    ll query(int a, int b){
        return query_(a, b, 0, 0, sz);
    }
};

int main() {
    // source code
    int N = inputValue();
    int Q = inputValue();
    rmq r(N);
    
    rep(i, Q){
        int com = inputValue();
        if (com) { // add
            int x = inputValue();
            int y = inputValue();
            output(r.query(x - 1, y), 0);
        }
        else{ // getSum
            int x = inputValue();
            ll y = inputValue();
            r.update(x - 1, y);
            
            
        }
    }
    
    return 0;
}

Measured memory_bytes: 3108
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define ll long long
#define FOR(i,a,b) for(int i=(a); i<=(b); i++)
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define chmin(a,b) if((a)>(b)) (a)=(b);
#define chmax(a,b) if((a)<(b)) (a)=(b);
#define vi vector<int>
#define pii pair<int,int>
#define all(v) (v).begin(),(v).end()
#define allr(v) (v).rbegin(),(v).rend()
#define pb push_back
#define pf push_front
int gcd(int a,int b){/*a>=0,b>=0,￢(a=b=0)*/
  while(min(a,b)>0){if(a<b)swap(a,b);a%=b;}return max(a,b);
}
int dx[]={1,0,-1,0,1,-1,-1,1};
int dy[]={0,1,0,-1,1,1,-1,-1};
const int MOD = 1e9+7;
const long long INF = 1e18+10;

/*--------------------------------------------------------------------*/
vi d(11,0);

bool check(int n){
	while(n>0){
		if(d[n%10]==1){
			return false;
		}
		n/=10;
	}
	return true;
}
signed main(){
	int n,k;
	cin>>n>>k;
	rep(i,k){
		int z;cin>>z;
		d[z]=1;
	}
	while(!check(n)){
		n++;
	}
	cout<<n<<endl;


	return 0;
}

Measured memory_bytes: 3632
#include <iostream>
using namespace std;
int main() {
    while (true) {
        int a, b ;
        char op ;
        cin >> a >> op >> b ;
        if (op == '?')break;
        if (op == '+'){
            cout << a + b << endl;
        }else if (op == '-'){
            cout << a - b << endl ;
        }else if (op == '*'){
            cout << a * b << endl;
        }else {
            cout << a/b << endl;
        }

    }
    

}


Measured memory_bytes: 3068
N = int(input())
A = list(map(int, input().split()))

flag = True   # Continue while loop if flag == True
i = 0         # Last index of unsorted rows
count = 0     # Counts of swapping

while flag:
  flag = False
  for j in range(N-1, i, -1):
    if (A[j-1] > A[j]):
      A[j-1], A[j] = A[j], A[j-1]
      flag = True
      count += 1
  i += 1

print(str(A).replace('[', '').replace(']', '').replace(',', ''))
print(count)



Measured memory_bytes: 5600
#include <bits/stdc++.h>
#define sz(v)   ((int)(v).size())
#define  all(v)    ((v).begin()),((v).end())
#define  allr(v)    ((v).rbegin()),((v).rend())
#define   pb         push_back
#define   mp         make_pair
#define   mt         make_tuple
#define   Y            imag()
#define   X            real()
#define    clr(v,d)      memset( v, d ,sizeof(v))
#define   angle(n)      atan2((n.imag()),(n.real()))
#define   vec(a,b)       ((b)-(a))
//#define   length(a)      hypot( (a.imag()),(a.real()) )
#define   normalize(a)      (a)/(length(a))
#define    dp(a,b)          (((conj(a))*(b)).real())
//#define    cp(a,b)          (((conj(a))*(b)).imag())
#define    lengthsqrt(a)       dp(a,a)
#define    rotate0( a,ang)    ((a)*exp( point(0,ang) ))
#define    rotateA(about,p,ang)   (rotate0(vec(about,p),ang)+about)
#define    reflection0(m,v)         (conj((v)/(m))*(m))
#define     reflectionA(m,v,p0)     (conj( (vec(p0,v))/(vec(p0,m)) ) * (vec(p0,m)) ) + p0
//#define     same(p1,p2)               ( dp(  vec(p1,p2),vec(p1,p2)) < eps )
#define     point                    complex<double>
#define outfile freopen("out.out", "w", stdout);
#define infile  freopen("in.in", "r", stdin);
#define PI acos(-1)
typedef  long long     ll ;
typedef  unsigned long long ull;
const double eps= (1e-9);
using namespace std;
int dcmp(double a,double b){   return fabs(a-b)<=eps ? 0: (a>b)? 1:-1  ;}
int getBit(int num, int idx) {return ((num >> idx) & 1) == 1;}
ll setBit1(ll num, int idx) {return num | (1ll<<idx);}
ll setBit0(ll num, int idx) {return num & ~(1ll<<idx);}
ll flipBit(int num, int idx) {return num ^ (1<<idx);}
void FS(){ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);}
const int N=100009;
int  v[N],k;
int main()
{
    cin>>k;
	for(int i=0;i<k;i++)
        cin>>v[i];

    ll mx=2,mi=2;

	for(int i=k-1;i>=0;i--)
    {
       ll tmi= ((mi+v[i]-1)/v[i])*v[i];
       if(tmi>mx)
       {
           cout<<"-1"<<endl;
           return 0;
       }
       ll tmx= (mx+(v[i]-mx%v[i]-1));
       mx=tmx;
       mi=tmi;
    }

	cout<<mi<<" "<<mx<<endl;
}


Measured memory_bytes: 640
#pragma GCC optimize ("O3")
#pragma GCC target ("sse4")

#include <bits/stdc++.h>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>

using namespace std;
using namespace __gnu_pbds;

typedef long long ll;
typedef long double ld;
typedef complex<ld> cd;

typedef pair<int, int> pi;
typedef pair<ll, ll> pl;
typedef pair<ld, ld> pd;

typedef vector<int> vi;
typedef vector<ld> vd;
typedef vector<ll> vl;
typedef vector<pi> vpi;
typedef vector<pl> vpl;
typedef vector<cd> vcd;

template <class T> using Tree = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

#define FOR(i, a, b) for (int i=a; i<(b); i++)
#define F0R(i, a) for (int i=0; i<(a); i++)
#define FORd(i,a,b) for (int i = (b)-1; i >= a; i--)
#define F0Rd(i,a) for (int i = (a)-1; i >= 0; i--)

#define sz(x) (int)(x).size()
#define mp make_pair
#define pb push_back
#define f first
#define s second
#define lb lower_bound
#define ub upper_bound
#define all(x) x.begin(), x.end()

mt19937 rng (chrono::steady_clock::now().time_since_epoch().count() );

const int MOD = 1000000007;
const ll INF = 1e18;
const int MX = 200001; //check the limits, dummy



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

    string s;
    cin >> s;

    stack<char>o, z;
    ll ans = 0;
    FOR (i, 0, sz (s) ) {
        if (s[i] == '0') {
            if (o.size() > 0) ans += 2, o.pop();
            else z.push (s[i]);
        } else {
            if (z.size() > 0) ans += 2, z.pop();
            else o.push (s[i]);
        }
    }

    cout << ans << '\n';

    return 0;
}


Measured memory_bytes: 512
#include<iostream>
#include<string>
#include<algorithm>

using namespace std;

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

    int res=0;

    int cnt=0;
    for(int i=0; i<s.size();i++) {
        if (s[i] == '.') cnt++;
    }

    res = cnt;

    for(int i=0; i<s.size();i++) {
        if(s[i] == '.') cnt--; 
        else cnt++;
        res = min(res, cnt);
    }

    cout <<res<<endl;
}


Measured memory_bytes: 640
#include <iostream>
using namespace std;
int main()
{
    int five=0,seven=0;
    int a,b,c;
    cin>>a>>b>>c;
    five=(a==5)+(b==5)+(c==5);
    seven=(a==7)+(b==7)+(c==7);
    if(five==2&&seven==1)
        cout<<"YES"<<endl;
    else
        cout<<"NO"<<endl;
    return 0;
}


Measured memory_bytes: 256
N = int(input())
A = map(int,input().split(" "))

d = {}
for a in A:
    if not(a in d.keys()):
        d[a] = 0
    d[a] += 1

e = [x for x in d.items() if x[1] >= 2]
if len(e) <= 1:
    print(0)
    exit()
e = sorted(e,key=lambda x:x[0],reverse=True)
if e[0][1] >= 4:
    print(e[0][0]**2)
else:
    print(e[0][0]*e[1][0])

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

int main()
{
	int N;
	cin >> N;
	if (N == 0) {
		cout << 2 << endl;
		return 0;
	}
	else if (N == 1) {
		cout << 1 << endl;
		return 0;
	}
	vector<ll> res(N + 1);
	res[0] = 2;
	res[1] = 1;
	for (int i = 2; i <= N; i++) {
		res[i] = res[i - 1] + res[i - 2];
	}
	cout << res[N] << endl;
	return 0;
}


Measured memory_bytes: 256
A=()
B=()
C=()
D=()
game=True
 
A, B, C, D = map(int, input().split())

while game==True:   
      C=C-B
      if C<=0:
           print('Yes')
           game=False
      else:
            A=A-D
            if A<=0:
                  print('No')
                  game=False
            else:
                  game=True

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

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

#define FOR(i, n, m) for (ll(i) = (m); (i) < (n); ++(i))
#define REP(i, n) FOR(i, n, 0)
#define OF64 std::setprecision(10)

const ll MOD = 1000000007;
const ll INF = (ll)1e15;

ll A[205];

int main()
{
    int N;
    cin >> N;
    REP(i, N)
    {
        cin >> A[i];
    }

    int a = 0;
    bool div = true;
    while (div)
    {
        REP(i, N)
        {
            if (A[i] % 2 != 0)
                div = false;
            A[i] /= 2;
        }
        if (div)
            a++;
    }
    cout << a << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <iomanip>
using namespace std;
#define reps(i,s,n) for(int i = s; i < n; i++)
#define rep(i,n) reps(i,0,n)
#define Rreps(i,n,e) for(int i = n - 1; i >= e; --i)
#define Rrep(i,n) Rreps(i,n,0)
#define ALL(a) a.begin(), a.end()
#define fi first
#define se second
typedef long long ll;
typedef vector<ll> vec;
typedef vector<vec> mat;

ll N,M,H,W,Q,K,A,B;
string S;
const ll MOD = 998244353;
//const ll MOD = (1e+9) + 7;
typedef pair<ll, ll> P;
const ll INF = (1LL<<58);

ll encode(ll x, ll y){
    return x * W + y;
}
P decode(ll en){
    return make_pair(en / W, en % W);
}
template<class T> bool chmin(T &a, const T &b){
    if(a > b) {a = b; return true;}
    else return false;
}
template<class T> bool chmax(T &a, const T &b){
    if(a < b) {a = b; return true;}
    else return false;
}

int main() {
    cin>>H>>W>>K;
    vec x(2), y(2);
    rep(i,2) cin>>x[i]>>y[i];
    string hasu(W + 1, '@');
    vector<string> G(H + 2, "@");
    rep(i,H){
        cin>>S;
        S.push_back('@');
        G[i+1].append(S);
    }
    G[0].append(hasu);
    G[H + 1].append(hasu);
    H += 2; W += 2;
    vec dh = {-1, 0, 1, 0}, dw = {0, -1, 0, 1};
    vec dist(H * W, INF);
    deque<P> deq;
    ll hw = H * W;
    deq.emplace_back(0, encode(x[0], y[0]) + hw * 0 + hw * K * 0);
    dist[encode(x[0], y[0])] = 0;
    mat dist_dir(hw, vec(4, -1));
    while(!deq.empty()){
        P p = deq.front();
        deq.pop_front();
        int dir = p.se / (hw * K);  p.se %= hw * K;
        ll rest = p.se / hw;  p.se %= hw;
        P v = decode(p.se);
        if(dist[p.se] < p.fi) continue;
        if(rest != 0 && dist_dir[p.se][dir] > rest) continue;
        //cout<<v.fi<<' '<<v.se<<' '<<p.fi<<endl;
        rep(i,4){
            if(G[v.fi + dh[i]][v.se + dw[i]] == '@') continue;
            if(chmin(dist[encode(v.fi + dh[i], v.se + dw[i])], dist[p.se] + (rest == 0 || dir != i))){
                rep(j,4) dist_dir[encode(v.fi + dh[i], v.se + dw[i])][j] = -1;
                dist_dir[encode(v.fi + dh[i], v.se + dw[i])][i] = (dir == i && rest > 0 ? rest - 1 : K - 1);
                ll next = encode(v.fi + dh[i], v.se + dw[i]) + (dir == i && rest > 0 ? hw * (rest - 1) + hw * K * dir : hw * (K - 1) + hw * K * i);
                if((rest == 0 || dir != i)) deq.emplace_back(dist[p.se] + 1, next);
                else  deq.emplace_front(dist[p.se], next);
            }else if(dist[encode(v.fi + dh[i], v.se + dw[i])] == dist[p.se] + (rest == 0 || dir != i)
                &&   chmax(dist_dir[encode(v.fi + dh[i], v.se + dw[i])][i], (dir == i && rest > 0 ? rest - 1 : K - 1))){
                ll next = encode(v.fi + dh[i], v.se + dw[i]) + (dir == i && rest > 0 ? hw * (rest - 1) + hw * K * dir : hw * (K - 1) + hw * K * i);
                if((rest == 0 || dir != i)) deq.emplace_back(dist[p.se] + 1, next);
                else  deq.emplace_front(dist[p.se], next);
            }
        }
    }
    cout<<(dist[encode(x[1], y[1])] == INF ? -1 : dist[encode(x[1], y[1])])<<endl;
}

Measured memory_bytes: 242452
# include <bits/stdc++.h>
#include <iostream>
using namespace std;
const int mod = 1e9+7;
typedef long long LL;
const int maxn = 23000000;
short dig[maxn+1];
inline void add(int &x, int y)
{
    x+=y;
    if(x>=mod) x-=mod;
}
int qmod(LL a, int b)
{
    LL res = 1;
    for(;b;b>>=1)
    {
        if(b&1) res=res*a%mod;
        a=a*a%mod;
    }
    return (int)res;
}
int main()
{
    for(int i=1; i<=maxn; ++i) dig[i] = dig[i/10]+1;
    int n, ans=0;
    scanf("%d",&n);
    for(int i=1, j=1, s=0; i<1e7; ++i)
    {
        while(s<n) s+=dig[j],++j;
        if(s==n) add(ans, 1);
        s -= dig[i];
    }
    for(int i=1; i<=n/8; ++i)
    {
        if(n%i==0) add(ans, ((qmod(10,n/i)-qmod(10,n/i-1)-i+1)%mod+mod)%mod);
        else add(ans, 1);
    }
    printf("%d\n",ans);
    return 0;
}
//....

Measured memory_bytes: 45312
#include <iostream>
#include <algorithm>
#include <complex>
#include <utility>
#include <vector>
#include <string>
#include <queue>
#include <tuple>
#include <cmath>
#include <bitset>
#include <cctype>
#include <set>
#include <map>
#include <numeric>
#include <functional>
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(ll i=ll(a);i<ll(b);++i)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define all(x) (x).begin(),(x).end()
#define PRINT(V) cout << V << "\n"
#define SORT(V) sort((V).begin(),(V).end())
#define RSORT(V) sort((V).rbegin(), (V).rend())
using namespace std;
using ll = long long;
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; }
inline void Yes(bool condition){ if(condition) PRINT("Yes"); else PRINT("No"); }
template<class itr> void cins(itr first,itr last){
    for (auto i = first;i != last;i++){
        cin >> (*i);
    }
}
template<class itr> void array_output(itr start,itr goal){
    string ans = "",k = " ";
    for (auto i = start;i != goal;i++) ans += to_string(*i)+k;
    if (!ans.empty()) ans.pop_back();
    PRINT(ans);
}
ll gcd(ll a, ll b) {
    return a ? gcd(b%a,a) : b;
}
const ll INF = 1e18;
const ll MOD = 1000000007;
typedef pair<ll,ll> P;
const ll MAX = 20000;
constexpr ll nx[8] = {1,0,-1,0,-1,-1,1,1};
constexpr ll ny[8] = {0,1,0,-1,-1,1,-1,1};
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n,k;
    cin >> n >> k;
    vector<ll> a(n);
    cins(all(a));
    RSORT(a);
    ll ans = 0;
    rep(i,k) ans += a[i];
    PRINT(ans);
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main() {
	string s; cin >> s;
	int ans1 = 0;
	int ans2 = 0;
	if(s[0]=='0'){
		if(s[1]!='0'){
			ans1++;
		}
	}
	else if(s[0]=='1'){
		if(s[1]=='0' || s[1]=='1'|| s[1]=='2') ans1++;
	}
	if(s[2]=='0'){
		if(s[3]!='0'){
			ans2++;
		}
	}
	else if(s[2]=='1'){
		if(s[3]=='0' || s[3]=='1'|| s[3]=='2') ans2++;
	}
	if(ans1==0 && ans2==0){
		cout << "NA" << endl;
		return 0;
	}
	if(ans1==1 && ans2==1){
		cout << "AMBIGUOUS" << endl;
		return 0;
	}
	if(ans1==0 && ans2==1){
		cout << "YYMM" << endl;
		return 0;
	}
	if(ans1==1 && ans2==0){
		cout << "MMYY" << endl;
		return 0;
	}
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define show(x) cout<<#x" = "<<x<<endl;
#define INF 0x3f3f3f3f
using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<int,int> iipair;
typedef pair<unsigned,unsigned> uupair;
typedef vector<int> vec;
typedef vector<unsigned> uvec;
typedef vector<ll> llvec;
typedef map<int,int> iimap;

const unsigned LIMIT=1e6;
const ll M=1e9+7;

llvec sp(LIMIT+1,0);

void preComputation()
{
    sp[1]=1;
    for(unsigned i=4;i<=LIMIT;i+=2)
    {
        sp[i]=2;
    }
    for(ull i=3;i*i<=LIMIT;i+=2)
    {
        if(!sp[i])
        {
            for(ull j=i*i;j<=LIMIT;j+=i)
            {
                if(!sp[j])
                {
                    sp[j]=i;
                }
            } 
        }
    }
    for(unsigned i=1;i<=LIMIT;++i)
    {
        if(!sp[i])
        {
            sp[i]=i;
        }
    }

}

iimap getPFactors(unsigned n)
{
    iimap pf;
    while(n!=1)
    {
        pf[sp[n]]++;
        n/=sp[n];
    }
    return pf;
}

ll gcd(ll a,ll b,ll &x,ll &y)
{
    if(!a)
    {
        x=0;
        y=1;
        return b;
    }
    ll x1,y1,g;
    g=gcd(b%a,a,x1,y1);
    y=x1;
    x=y1-(b/a)*x1;
    return g;
}

ll getModInverse(ll a,ll m)
{
    ll x,y;
    if(gcd(a,m,x,y) == 1)
    {
        return (x%m+m)%m;
    }
    else return 0;
}

int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    preComputation();
    unsigned n;
    cin>>n;
    vec a(n);
    iimap temp,res;
    ll result,k;
    for(unsigned i=0;i<n;++i)
    {
        cin>>a[i];
        temp=getPFactors(a[i]);
        for(auto item : temp)
            res[item.first]=max(res[item.first],item.second);
    }
    k=1;
    result=0;
    for(auto item : res) k=(k*static_cast<ll>(pow(item.first,item.second)))%M;
    for(auto item : a)
    {
        result=(result+k*getModInverse(item,M))%M;
    }
    cout<<result;

}

Measured memory_bytes: 8576
#include<cstdio>
#include<algorithm>

using namespace std;

long long solve(long long a, long long b){
	if(a > b) swap(a, b);
	if(b % a == 0){
		return 2 * b - a;
	}else{
		return 2 * (b / a) * a + solve(a, b % a);
	}
}

int main(){
	long long n, x, ans = 0;
	scanf("%lld%lld", &n, &x);
	ans += n + solve(x, n - x);
	printf("%lld\n", ans);
	return 0;
}

Measured memory_bytes: 128
/*
このコード、と～おれ!
Be accepted!
∧＿∧　
（｡･ω･｡)つ━☆・*。
⊂　　 ノ 　　　・゜+.
　しーＪ　　　°。+ *´¨)
 　　　　　　　　　.· ´¸.·*´¨) ¸.·*¨)
		  　　　　　　　　　　(¸.·´ (¸.·'* ☆
*/

#include <cstdio>
#include <algorithm>
#include <string>
#include <cmath>
#include <cstring>
#include <vector>
#include <numeric>
#include <iostream>
#include <random>
#include <map>
#include <unordered_map>
#include <queue>
#include <regex>
#include <functional>
#include <complex>
#include <list>
#include <cassert>
#include <iomanip>
#include <set>
#include <stack>
#include <bitset>

////多倍長整数, cpp_intで宣言
//#include <boost/multiprecision/cpp_int.hpp>
//using namespace boost::multiprecision;

#pragma gcc target ("avx2")
#pragma gcc optimization ("Ofast")
#pragma gcc optimization ("unroll-loops")
#define rep(i, n) for(int i = 0; i < (n); ++i)
#define rep1(i, n) for(int i = 1; i <= (n); ++i)
#define rep2(i, n) for(int i = 2; i < (n); ++i)
#define repr(i, n) for(int i = n; i >= 0; --i)
#define reprm(i, n) for(int i = n - 1; i >= 0; --i)
#define printynl(a) printf(a ? "yes\n" : "no\n")
#define printyn(a) printf(a ? "Yes\n" : "No\n")
#define printYN(a) printf(a ? "YES\n" : "NO\n")
#define printim(a) printf(a ? "possible\n" : "imposible\n")
#define printdb(a) printf("%.50lf\n", a) //少数出力
#define printLdb(a) printf("%.50Lf\n", a) //少数出力
#define printdbd(a) printf("%.16lf\n", a) //少数出力(桁少なめ)
#define prints(s) printf("%s\n", s.c_str()) //string出力
#define all(x) (x).begin(), (x).end()
#define allsum(a, b, c) ((a + b) * c / 2LL) //等差数列の和、初項,末項,項数
#define pb push_back
#define rpriq priq<int, vector<int>, greater<int>>
#define deg_to_rad(deg) (((deg)/360.0L)*2.0L*PI)
#define rad_to_deg(rad) (((rad)/2.0L/PI)*360.0L)
#define Please return
#define AC 0
#define manhattan_dist(a, b, c, d) (abs(a - c) + abs(b - d)) /*(a, b) から (c, d) のマンハッタン距離 */
#define inf numeric_limits<double>::infinity();
#define linf numeric_limits<long double>::infinity()

using ll = long long;

constexpr int INF = 1073741823;
constexpr int MINF = -1073741823;
constexpr ll LINF = ll(4661686018427387903);
constexpr ll MOD = 1e9 + 7;
constexpr long double eps = 1e-6;
const long double PI = acosl(-1.0L);

using namespace std;

void scans(string& str) {
	char c;
	str = "";
	scanf("%c", &c);
	if (c == '\n')scanf("%c", &c);
	while (c != '\n' && c != -1 && c != ' ') {
		str += c;
		scanf("%c", &c);
	}
}

void scanc(char& str) {
	char c;
	scanf("%c", &c);
	if (c == -1)return;
	while (c == '\n') {
		scanf("%c", &c);
	}
	str = c;
}

double acot(double x) {
	return PI / 2 - atan(x);
}

ll LSB(ll n) { return (n & (-n)); }

/*-----------------------------------------ここからコード-----------------------------------------*/



int main() {

	int d;
	scanf("%d", &d);
	vector<ll> c(26);
	rep(i, 26)scanf("%lld", &c[i]);
	vector<vector<ll>> s(d, vector<ll>(26));
	rep(i, d)rep(j, 26)scanf("%lld", &s[i][j]);
	vector<ll> last(26);
	ll ans = 0;
	random_device rnd;
	mt19937 mt(rnd());
	uniform_int_distribution<> rand26(1, 26);
	rep(i, d) {
		int t = 1;
		ans += s[i][t - 1];
		last[t - 1] = i + 1;
		rep(j, 26)ans -= (c[j] * (i + 1 - last[j]));
	}
	rep(i, d)printf("%d\n", rand26(mt));

	Please AC;
}

Measured memory_bytes: 3912
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for (int i = 0; i < (int)(n); i++)
typedef long long ll;
typedef pair<int, int> P;
const int INF = 1e9;
const ll MOD = 1000000007;
int dp[100000 + 200];
template <class T>
inline bool chmin(T& a, T b) {
  if (a > b) {
    a = b;
    return 1;
  }
  return 0;
}
int main() {
  ll N, K;
  cin >> N >> K;
  vector<int> h(N);
  REP(i, N) cin >> h[i];
  REP(i, 100000 + 200) dp[i] = INF;
  dp[0] = 0;

  REP(i, N) {
    REP(j, K) chmin(dp[i + j + 1], dp[i] + abs(h[i] - h[i + j + 1]));
  }
  cout << dp[N - 1] << endl;
}

Measured memory_bytes: 4064
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <set>
#include <map>
using namespace std;

int main()
{
	int n, p = 2019, a[200010], pow10[200010] = { 1 };
	string s;
	cin >> s;
	n = s.length();
	for (int i = 0; i < n; i++) a[i] = s[i] - '0';
	for (int i = 1; i <= n; i++) pow10[i] = pow10[i - 1] * 10 % p;
	map<int, int> cnt;
	cnt[0]++;
	int ans = 0, sum = 0;
	for (int i = 0; i < n; i++) {
		sum = (sum * 10 + a[i]) % p;
		int tmp = sum * pow10[n - i - 1] % p;
		if ((p != 2 && p != 5) || a[i] % p == 0) ans += cnt[tmp];
		cnt[tmp]++;
	}
	cout << ans << endl;
}


Measured memory_bytes: 5284
Q = int(input())
lr = [list(map(int, input().split())) for _ in range(Q)]
n = 10 ** 5

is_prime = [True for _ in range(n+1)]
is_prime[0] = is_prime[1] = False
for i in range(2, n + 1):
    if is_prime[i]:
        for j in range(2 * i, n + 1, i):
            is_prime[j] = False

L = [0, 0]
c = 0
for i in range(2, n + 1):
    if is_prime[i] and is_prime[(i + 1) // 2]:
        c += 1
    L.append(c)

ans = 0

for l, r in lr:
    print(L[r] - L[l -1])


Measured memory_bytes: 29804
import java.util.Scanner;
public class Main {
    public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int t = sc.nextInt();
		int[] c = new int[n];
		int[] ct = new int[n];
		int tleflg = 1;
		
        for(int i = 0; i < n; i++){
        	c[i] = sc.nextInt();
          	ct[i] = sc.nextInt();
        }
      	int ans = c[0];

        for(int i=0; i<n; i++){
        	if(ct[i]<=t){
        	    if(ans>c[i]){
        	        ans = c[i];
        	    }
              tleflg =0;
            }
        }
      if(tleflg==1){
        System.out.println("TLE");
      }else{
      	System.out.println(ans);
      }
    }
}

Measured memory_bytes: 35788
//Think simple yet elegant.
#include <bits/stdc++.h>
using namespace std;
#define fast ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define ll  long long
#define all(v) v.begin(),v.end()
#define ff first
#define ss second
#define pb push_back
#define mp make_pair
#define pi pair<int,int>
const ll maxn=105;
const ll mod=1e9+7;

int main(){
	fast;
	int n,i,j,k;
	cin>>n;
	vector<int> a(n),st;
	for(i=0;i<n;i++)
		cin>>a[i];
	for(i=1;i<n;i++){
		if(a[i-1]>a[i]){
			st.push_back(a[i-1]-a[i]);
			a[i]=a[i-1];
		}
	}
	ll sum=0;
	for(int x : st)
		sum+=x;
	cout<<sum;
	
}

Measured memory_bytes: 5064
#include<iostream>
using namespace std;
int main() {
	int n;
	cin>>n;
	int a[n][3];
	for(int i = 0; i < n; i++){
		for(int j = 0; j < 3; j++){
			cin>>a[i][j];
		}
	}
	int dp[n+1][3];
	dp[n][0] = 0;
	dp[n][1] = 0;
	dp[n][2] = 0;

	for(int i = n-1; i >= 0; i--){
		for(int j = 0; j < 3; j++){
			if(j == 0){
				dp[i][j] = max(a[i][j] + dp[i+1][j+1], a[i][j] + dp[i+1][j+2]);
			}
			if(j == 1){
				dp[i][j] = max(a[i][j] + dp[i+1][j-1], a[i][j] + dp[i+1][j+1]);
			}
			if(j == 2){
				dp[i][j] = max(a[i][j] + dp[i+1][j-2], a[i][j] + dp[i+1][j-1]);
			}
		}
	}
	cout<<max(max(dp[0][0], dp[0][1]), dp[0][2])<<endl;
}

Measured memory_bytes: 2560
#include <iostream>

using namespace std;

typedef unsigned long long ull;

int main()
{
	int v[32] = { 1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51 };

	int k;

	cin >> k;

	cout << v[k - 1] << endl;
}

Measured memory_bytes: 256
import copy
H,W=map(int,input().split())

maze=[]
maze.append(["#"]*(W+2))
for h in range(H):
    line=list(input())

    maze.append(["#"]+line+["#"])

maze.append(["#"]*(W+2))


maze_ori=copy.deepcopy(maze)

maxd=0

for h in range(1,H+1):
    for w in range(1,W+1):
        maze=copy.deepcopy(maze_ori)
        if maze[h][w]=="#":
            continue
        else:
            next_flag=True


        direction=[[-1,0],[0,-1],[1,0],[0,1]]
        distance=0
        maze[h][w]=distance

        next_list=[]
        next_list.append([h,w])
        while next_flag is True:
            p_list=next_list
            next_list=[]
            distance+=1
            next_flag=False
            for p in p_list:
                for d in direction:
                    i=p[0]+d[0]
                    j=p[1]+d[1]

                    if maze[i][j]==".":
                        maze[i][j]=distance
                        next_list.append([i,j])
                        next_flag=True
            
        maxd=max(maxd,distance-1)

print(maxd)


Measured memory_bytes: 3444
#include<stdio.h>
#include<stdlib.h>
#include<math.h>
#include<algorithm>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
ll v[55];
typedef struct Node {
	ll val = 0;
	int sum = 0;
}node;
node s[55];
ll dp[55][55];
ll C(int n, int m);
int main(void)
{
	int n = 0, N, a, b;
	scanf("%d %d %d", &N, &a, &b);
	for (int i = 0; i < N; i++)// 5 5 5 4 4 3 2 1
		scanf("%lld", &v[i]);
	sort(v, v + N);
	reverse(v, v + N);
	s[n].val = v[0], s[n].sum++;
	for (int i = 1; i < N; i++)
		if (s[n].val == v[i])
			s[n].sum++;
		else
			s[++n].val = v[i], s[n].sum++;
	n++;
	ll ans = 0;
	double ave;
	ll t = 0;
	for (int i = 0; i < a; i++)
		t += v[i];
	ave = (double)t / a;
	if (a <= s[0].sum)
	{
		if (b > s[0].sum)b = s[0].sum;
		for (int i = a; i <= b;i++)
			ans += C(s[0].sum, i);
	}
	else
	{
		int k = s[0].sum, m;
		for (m = 1; m < n; m++)
			if (k + s[m].sum >= a)
				break;
			else
				k += s[m].sum;
		a -= k;
		ans = C(s[m].sum, a);
	}
	printf("%.12lf\n", ave);
	printf("%lld\n", ans);
	return 0;
}
ll C(int n, int m)
{
	if (n == m || !m)return 1;
	for (int i = 0; i <= 50; i++)
		dp[i][0] = 1;
	for (int i = 1; i <= n; i++)
		for (int j = 1; j <= m; j++)
			dp[i][j] = dp[i - 1][j - 1] + dp[i - 1][j];
	return dp[n][m];
}

Measured memory_bytes: 128
#include <algorithm>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>
#include <cfloat>

using std::cerr;
using std::cin;
using std::cout;
using std::endl;

template<typename CostType>
/// \brief 辺の情報
struct Edge{
  int      to;
  CostType cost;

  Edge(int t, CostType c): to(t), cost(c){
  }
};

template<typename CostType>
class Graph{

private:

  /// \brief adjacent_list_[n]=ノードnの隣接リストを表すvector<Edge>
  std::vector<std::vector<Edge<CostType>>> adjacent_list_;

public:

  /// \brief 頂点数
  const int NODE_SIZE_;

  /// \brief コンストラクタ
  /// \param node_size 頂点数
  explicit Graph(const int node_size): NODE_SIZE_(node_size),
                                       adjacent_list_(node_size){
  }

  /// \brief 有向グラフの辺を生やす
  /// \param from 辺の根本の頂点の番号
  /// \param to 辺の先の頂点の番号
  /// \param cost 辺のコスト
  void SetDirectedEdge(const int from, const int to, const CostType cost){
    adjacent_list_[from].push_back(Edge<CostType>(to, cost));
  }

  /// \brief 無向グラフの辺を生やす
  /// \param node_a 一方の頂点の番号
  /// \param node_b もう一方の頂点の番号
  /// \param cost 辺のコスト
  void
  SetUndirectedEdge(const int node_a, const int node_b, const CostType cost){
    SetDirectedEdge(node_a, node_b, cost);
    SetDirectedEdge(node_b, node_a, cost);
  }

  /// \brief ある頂点の隣接リストを取得
  /// \param node_num 頂点の番号
  /// \return 隣接リスト
  std::vector<Edge<CostType>> GetAdjacentList(int node_num) const{
    return adjacent_list_[node_num];
  }
};

using namespace std;

int main(){
  cout << std::fixed << std::setprecision(16);
  cin.tie(nullptr);
  std::ios::sync_with_stdio(false);
  string s;
  cin>>s;
  if(s.back()=='1'){
    cout << -1 << endl;
    return 0;
  }
  if(s.front()=='0'){
    cout<<-1<<endl;
    return 0;
  }
  for(int i=0;i<s.size()-2-i;i++){
    if(s[i]!=s[s.size()-2-i]){
      cout<<-1<<endl;
      return 0;
    }
  }
  vector<pair<int,int>> e;
  int pos=s.size()-1;
  for(int i=s.size()-2;i>=0;i--){
    if(s[i]=='1'){
      if(i!=pos)e.push_back(make_pair(i,pos));
      pos=i;
    }
    else{
      e.push_back(make_pair(i,pos));
    }
  }
  for(auto ed:e){
    cout<<ed.first+1<<" "<<ed.second+1<<endl;
  }






  return 0;
}

Measured memory_bytes: 2484
X = int(input())
if 400 <= X <= 599:
    print(8)
elif 600 <= X <= 799:
    print(7)
elif 800 <= X <= 999:
    print(6)
elif 1000 <= X <= 1199:
    print(5)
elif 1200 <= X <= 1399:
    print(4)
elif 1400 <= X <= 1599:
    print(3)
elif 1600 <= X <= 1799:
    print(2)
else:
    print(1)

Measured memory_bytes: 9180
#include<bits/stdc++.h>
using namespace std;
#define inf 0x3f3f3f3f
#define ll long long
#define fo freopen("in.txt","r",stdin)
#define fc fclose(stdin)
#define fu0(i,n) for(i=0;i<n;i++)
#define fu1(i,n) for(i=1;i<=n;i++)
#define fd0(i,n) for(i=n-1;i>=0;i--)
#define fd1(i,n) for(i=n;i>0;i--)
#define mst(a,b) memset(a,b,sizeof(a))
#define sd(n) scanf("%d",&n)
#define sdd(n,m) scanf("%d %d",&n,&m)
#define ss(s) scanf("%s",s)
#define sddd(n,m,k) scanf("%d %d %d",&n,&m,&k)
#define pans() printf("%d\n",ans)
#define all(a) a.begin(),a.end()
#define sc(c) scanf("%c",&c)
#define we(a) while(scanf("%d",&a)!=EOF)
const int maxn=200005;
const double eps=1e-8;

int main()
{
    ll n,x;
    while(cin>>n>>x)
    {
        ll a[100005],num=0,now=0;
        for(int i=0; i<n; i++)
        {
            cin>>a[i];
        }
        for(int i=0; i<n; i++)
        {
            if(now+a[i]<=x)//可能一个盒子的糖果数就超过了x。。
            {
                now=a[i];
            }
            else
            {
                num+=(now+a[i]-x);
                now=a[i]-(a[i]+now-x);

            }
        }
        cout<<num<<endl;
    }
    return 0;
}


Measured memory_bytes: 1024
def solve(N, A, B, C):
    ans = 0
    for a, b, c in zip(A, B, C):
        if a == b and b == c and a == c:
            pass
        elif a == b or b == c or a == c:
            ans += 1
        else:
            ans += 2
    return ans


if __name__ == "__main__":
    N = int(input())
    A = input()
    B = input()
    C = input()
    print(solve(N, A, B, C))


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

int main(){
	int A=700;
string S;
cin >> S;



         if (S[0] == 'o') {
	A += 100;
}
        if (S[1] == 'o') {
	A += 100;
}
        if (S[2] == 'o') {
	A += 100;
}

       cout << A << endl;
return 0;
 }

Measured memory_bytes: 256
#include <atcoder/math>
#include <bits/stdc++.h>
using namespace std;
#define ll long long

int main() {
    int T;
    scanf("%d", &T);
    for (int z = 0; z < T; z++) {
        ll N, M, A, B;
        scanf("%lld %lld %lld %lld", &N, &M, &A, &B);
        ll ans = atcoder::floor_sum(N, M, A, B);
        printf("%lld\n", ans);
    }
}

Measured memory_bytes: 3744
from sys import stdin

def calc(N, Y):
    for i in range(N+1):
        for j in range(N+1-i):
            if 10000*i + 5000*j + 1000*(N-i-j) == Y:
                return '%s %s %s' % (i, j, (N-i-j))
    return '-1 -1 -1'

if __name__ == '__main__':
    flag = True
    N, Y = [int(x) for x in stdin.readline().rstrip().split()]
    print(calc(N, Y))


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

int main() {
  string S;
  int i, x = 0, sum = 0;
  
  cin >> S;
  
  int len = S.size();
  int n[len];
  
  for(i = 0; i < len; i++)
  {    
    if(S[i] == S[len - i - 1])
      continue;
    
    else
    {
      x ++;
      break;
    }
  }
  
  for(i = 0; i < (len - 1) / 2; i++)
  {    
    if(S[i] == S[(len - 1) / 2 - i - 1])
      continue;
    
    else
    {
      x ++;
      break;
    }
  }
  
  for(i = 0; i < len; i++)
  {    
    if(S[i] == S[len - i - 1])
      continue;
    
    else
    {
      x ++;
      break;
    }
  }
  
  for(i = (len + 3) / 2 - 1; i < len; i++)
  {    
    if(S[i] == S[len - sum - 1])
    {
      sum++;
      continue;
    }
    else
    {
      x ++;
      break;
    }
  }
  
  if(x == 0)
    cout << "Yes" << endl;
  else
    cout << "No" << endl;
}

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

#define sz(x) (int)x.size() 
#define pb push_back 
#define mp make_pair 
#define fi(a, b) for(int i=a; i<=b; i++) 
#define fj(a, b) for(int j=a; j<=b; j++) 
#define fo(a, b) for(int o=a; o<=b; o++) 
#define fdi(a, b) for(int i=a; i>=b; i--) 
#define fdj(a, b) for(int j=a; j>=b; j--) 
#define fdo(a, b) for(int o=a; o>=b; o--) 

#ifdef LOCAL
#define err(...) fprintf(stderr, __VA_ARGS__)
#else
#define err(...) while(false) {}
#endif

typedef long long ll; 
typedef pair<int, int> pii; 
typedef pair<ll, ll> pll; 
typedef vector<int> vi; 
typedef vector<pii> vpii; 
typedef vector<pll> vpll; 
typedef long double ld;
typedef unsigned long long ull;

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

int const MAX = 1e5 + 41;

vi e[MAX];
int p[MAX];
int n, m;
int u[MAX];
int ans;
vi a, b;

void dfs(int x) {
	u[x] = 1;
	a.pb(x);
	b.pb(p[x]);
	for (int y : e[x]) {
		if (u[y]) continue;
		dfs(y);
	}
}

void solve() {
	fi(1, n) {
		if (!u[i]) {
			a.clear();
			b.clear();
			dfs(i);
			sort(a.begin(), a.end());
			sort(b.begin(), b.end());
			for (int x : a) {
				auto it = lower_bound(b.begin(), b.end(), x);
				if (it != b.end()) {
					if ( (*it) == x) {
						ans++;
					}
				}
			}
		}
	}
	printf("%d\n", ans);	
}

int main() {
#ifdef LOCAL
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif

	scanf("%d %d", &n, &m);
	fi(1, n) {
		scanf("%d", &p[i]);
	}  
	fi(1, m) {
		int x, y;
		scanf("%d %d", &x, &y);
		e[x].pb(y);
		e[y].pb(x);
	}
	solve();		

	
#ifdef LOCAL
	err("ELAPSED TIME: %.3Lf\n", (ld) clock() / CLOCKS_PER_SEC);
#endif	
	
	return 0;
}

Measured memory_bytes: 10412
#include <bits/stdc++.h>
 
using namespace std;
 
const int MOD=1e9+7;

//const int MOD=998244353;



int main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    
    vector<int> ct(4);
    
    for(int i=0; i<3; i++){
        int x,y;
        cin>>x>>y;
        ct[x]++;
        ct[y]++;
    }
    for(int i=1; i<=4; i++){
        if(ct[i]>2){
            cout<<"NO";
            return 0;
        }
    }
    cout<<"YES";
        
    
    return 0;
}

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

using namespace std;

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

#define FOR(i, n, m) for(ll (i)=(m);(i)<(n);++(i))
#define REP(i, n) FOR(i,n,0)
#define OF64 std::setprecision(10)

const ll MOD = 1000000007;
const ll INF = (ll) 1e15;

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll N;
    cin >> N;
    cout << N * (N + 1) / 2 << endl;
    return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;
import java.util.Set;
import java.util.TreeSet;

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

		int a = sc.nextInt();
		int b = sc.nextInt();
		int k = sc.nextInt();
		
		Set<Integer> anss = new TreeSet<>();
		
		for (int i = 0; i < k; i++){
			if (a + i <= b)
			anss.add(a + i);
		}
		
		for (int i = 0; i < k; i++){
			if (b - i >= a)
			anss.add(b - i);
		}
		
		for (int ans : anss){
			System.out.println(ans);
		}
	}
}

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

int main(){
    int N;
    cin >> N;
    vector<int> A(N+1);
    vector<int> B(N);
    for (int i = 0; i < N+1; i++){
        int a;
        cin >> a;
        A.at(i) = a;
    }
    for (int i = 0; i < N; i++){
        int b;
        cin >> b;
        B.at(i) = b;
    }
    int64_t ans = 0;
    
    /* int next = 0;
    for (int i = 0; i < N; i++){
        int before = min(next,A.at(i));
        ans += min(next + B.at(i), A.at(i));
        next = max(0, B.at(i) - (A.at(i) - before));       
    }
    ans += min(A.at(N), next);
    */

   int same = min(A.at(0), B.at(0));
   ans += same;
   for (int i = 0; i < N-1; i++){
       int other;
       other = min(A.at(i+1), B.at(i) - same);
       same = min(A.at(i+1) - other, B.at(i+1));
       ans += other + same;
   }
   ans += min(A.at(N), B.at(N-1) - same);
    cout << ans << endl;
}

Measured memory_bytes: 1024
#include <stdio.h>

int main(void) {
  int A,B;
 scanf("%d%d", &A, &B);
  int K;
  
   if((A+B)%2 == 0){
   K = (A + B) / 2;
   printf("%d",K);
   }

   else
   printf("IMPOSSIBLE\n");


  return 0;
}


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

const int N = 500000;
const int INFTY = 1000000001;
int cnt;

void merge(int left, int mid, int right, int S[]) {
  int i, j, k, n1, n2;  
  n1 = mid - left;
  n2 = right - mid;
  
  int L[n1+1], R[n2+1];
  for (i = 0; i < n1; i++) L[i] = S[left+i];
  for (i = 0; i < n2; i++) R[i] = S[mid+i];
  L[n1] = R[n2] = INFTY;

  j = k = 0;
  for (i = 0; i < n1 + n2; i++) {
    if (L[j] <= R[k]) S[left+i] = L[j++];
    else S[left+i] = R[k++];
    cnt++;
  }
}

void merge_sort(int left, int right, int S[]) {
  if (left + 1 < right) {
    int mid = (left + right) / 2;
    merge_sort(left, mid, S);
    merge_sort(mid, right, S);
    merge(left, mid, right, S);
  }
}

int main() {
  int i, n;
  int S[N];

  cin >> n;
  for (i = 0; i < n; i++) cin >> S[i];

  cnt = 0;
  merge_sort(0, n, S);

  for (i = 0; i < n; i++) {
    if (i > 0) cout << " ";
    cout << S[i];
  }
  cout << endl << cnt << endl;

  return 0;
}


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

using namespace std;

using ll =  long long;
using Pll = pair<ll, ll>;
using Pii = pair<int, int>;

constexpr ll MOD = 1000000007;
constexpr ll INF = 1LL << 60;
constexpr long double EPS = 1e-10;
constexpr int dyx[4][2] = {
    { 0, 1}, {-1, 0}, {0,-1}, {1, 0}
};

int main() {
    ios::sync_with_stdio(false); cin.tie(nullptr);
    double a, b, x;
    cin >> a >> b >> x;
    double volume = a*a*b;

    double low = 0.0, high = 90.0;
    for(int i=0;i<1000;++i){
        double mid = (low+high) / 2.0;
        double rest_height = a * tan(mid / 180.0 * M_PI);
        if(rest_height <= b) {
            double rest_volume = a * a * rest_height / 2.0;
            if(volume-rest_volume < x) {
                high = mid;
            } else {
                low = mid;
            }
        } else {
            double limit = b / tan(mid / 180.0 * M_PI) * a * b / 2.0;
            if(limit < x) {
                high = mid;
            } else {
                low = mid;
            }
        }
    }

    cout << fixed << setprecision(12) << low << endl;
}


Measured memory_bytes: 256