akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<vector>
#include<algorithm>
#include<iomanip>
#include<utility>
#include<iomanip>
#include<map>
#include<cmath>
#include<cstdio>
#define rep(i,n) for(int i=0; i<(n); ++i)
using namespace std;
using ll =long long;
using P = pair<int,int>;

int main(){
    cin.tie(0);
    int n,k,x,y;
    cin >> n >> k >> x >> y;
    if(n<k)
        k=n;
    cout << x*k+(n-k)*y;

    return 0;
}

Measured memory_bytes: 256
program decrease
  implicit none
  integer :: n, i
  integer(8) :: a(50), m, t
  a = 0_8
  read(*,*) n
  read(*,*) a(1:n)
  t = 0_8
  do
    m = maxval(a(1:n))
    if (m.lt.int(n,8)) exit
    m = 0_8
    do i = 1, n
      m = m + a(i)/int(n,8)
    end do
    do i = 1, n
      a(i) = a(i) + m - (a(i)/int(n,8))*int(n+1,8)
    end do
    t = t + m
  end do
  write(*,'(i0)') t
  stop
end program decrease

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

using namespace std;

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

ll N, M, P, Q, R, K, A, B, C, X, Y, Z, arr[100005];

string s;

int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cin >> N >> K;
	for (int i = 1; i <= N; ++i){
		cin >> arr[i];
	}
	for (int i = 1; i <= N; ++i){
		for (int j = i-1; j <= N; ++j){
			Z = 0;
			if (i-1+N-j > K) continue;
			int left = K-(i-1+N-j);
			priority_queue<ll,vector<ll>,greater<ll> > pq;
			for (int k = 1; k < i; ++k){
				pq.push(arr[k]);
				Z += arr[k];
			}
			for (int k = j+1; k <= N; ++k){
				pq.push(arr[k]);
				Z += arr[k];
			}
			while (pq.size() && left && pq.top() < 0){
				Z -= pq.top();
				pq.pop();
				left--;
			}
			Y = max(Z,Y);
		}
	}
	cout << Y << '\n';
}

Measured memory_bytes: 256
#include <cstdio>
#include <algorithm>
using namespace std;

int main()
{
    int a[3];
    int i;
    for(i = 0; i < 3; i++)
    {
        scanf("%d",&a[i]);
    }
    sort(a,a+3);
    printf("%d %d %d\n",a[0],a[1],a[2]);
    return 0;
}

Measured memory_bytes: 2736
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
typedef int64_t llong;
char moji[26]={'a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z'};
char moji2[26]={'A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z'};
char moji3[10]={'0','1','2','3','4','5','6','7','8','9'};
#define Sort(a) sort(a.begin(),a.end());
#define Reverse(a) reverse(a.begin(),a.end());
#define ld PRId64
#define n_max 200000
#define INF 500000000000

int main(){
    int n;
    cin >> n;
    llong sum=0;
    llong A[n_max+5]={};
    REP(i,n){
        scanf("%ld",&A[i]);
        sum+= A[i];
    }
    llong tmp=0;
    llong ans=INF;
    int i=0;
    while(1){
        tmp+=A[i];
        if( abs( (sum - tmp) -tmp ) < ans) ans=abs( (sum - tmp) -tmp );
        i+=1;
        if(i==n-1) break;
    }

    cout << ans << endl;
}

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

typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;
typedef pair<LL, LL> PLL;

#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())

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

#define FF first
#define SS second
template<class S, class T>
istream& operator>>(istream& is, pair<S,T>& p){
  return is >> p.FF >> p.SS;
}

const double EPS = 1e-10;
const double PI  = acos(-1.0);
const LL MOD = 1e9+7;

int D;
int S;
LL dp[300+1][300*300+1][2];
int xs[300];
LL powm(LL x, LL y){
  if(y == 0) return 1;
  return powm(x*x%MOD, y/2) * (y%2?x:1) % MOD;
}

LL dfs(int i, int l, int b){
  if(l <= 0)
	return 0;
  if(dp[i][l][b])
	return dp[i][l][b];
  if(i == D){
	if(l == S) return 0;
	return dp[i][l][b] = (MOD + (b?1:-1) * powm(l,D)) % MOD;
  }

  return dp[i][l][b] = (dfs(i+1, l, b) + dfs(i+1, l-xs[i], b^1)) % MOD;
}

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

  cin >> D;
  REP(i,D) cin >> xs[i];
  cin >> S;

  /*
  LL ans = 0;
  for(int b=1;b<1<<D;++b){
	int num = 0, sum = 0;
	REP(i,D)
	  if(b>>i&1){
		++num;
		sum += xs[i];
	  }
	if(S <= sum) continue;
	if(num%2)
	  (ans += powm(S-sum, D)) %= MOD;
	else
	  (ans += MOD - powm(S-sum, D)) %= MOD;
  }
  cout << (MOD+powm(S,D) - ans)%MOD << endl;
  */
  cout << (MOD+powm(S,D) - dfs(0,S,0)) % MOD << endl;

  return 0;
}

Measured memory_bytes: 184968
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> // Common file 
#include <ext/pb_ds/tree_policy.hpp> 
#include <functional> // for less 
#define pb push_back
#define For(i,s,e) for (ll i=(s); i<(e); i++)
#define Debug_array(a,n) for (ll i=(0); i<(n); i++) cout<<a[i]<<" "
#define Foe(i,s,e) for (ll i=(s); i<=(e); i++)
#define Fod(i,s,e) for (ll i=(s)-1; i>=(e); i--)
#define pii pair<ll,ll>
#define fi first
#define se second
#define endl "\n"
#define mp make_pair
#define big_prime 15486277
#define bigger_prime 179424697
#define biggest_prime 32416188691
//#define random_shuffle(indices.begin(), indices.end());
//std::random_device rd;
//std::mt19937 g(rd());
//std::shuffle(v.begin(), v.end(), g);
using namespace __gnu_pbds; 
using namespace std;
template <class T> ostream& operator << (ostream &os, const vector<T> &v) { for (T i : v) os << i << ' '; return os; }
template <class T> ostream& operator << (ostream &os, const set<T> &v) { for (T i : v) os << i << ' '; return os; }
template <class T, class S> ostream& operator << (ostream &os, const pair<T, S> &v) { os << v.first << ' ' << v.second; return os; }
// template <class T, class S> ostream& operator << (ostream &os, const unordered_map<T, S> &v) { for (auto i : v) os << '(' << i.first << "=>" << i.second << ')' << ' '; return os; }
 
#ifndef ONLINE_JUDGE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
    template <class Arg1> void __f(const char* name, Arg1&& arg1) { cerr << name << " : " << arg1 << endl; }
    template <class Arg1, class... Args>
    void __f(const char* names, Arg1&& arg1, Args&&... args) {
        const char* sep = strchr(names + 1, ',');
        cerr.write(names, sep - names) << " : " << arg1 << "  ";
        __f(sep + 1, args...);
    }
#else
#define trace(...) 0
#define _CRT_SECURE_NO_WARNINGS
#endif // ifndef ONLINE_JUDGE


typedef long long ll;
typedef tree<ll, null_type, less<ll>, rb_tree_tag,tree_order_statistics_node_update> ordered_set; 

#define Mod 1000000007
#define MAX 5002

vector<ll> d;
ll ans, n;
int main(){
	ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
		
	cin>>n; 
	ll a[n];
	For(i,0,n) cin>>a[i];
	reverse(a,a+n);

    for (ll i = 0; i < n; i++) {
        ll x;x=a[i];
        vector<ll>::iterator it = upper_bound(d.begin(), d.end(), x);
        if (it == d.end()) d.push_back(x);
        else *it = x;
    }
    cout<<d.size()<<endl;
    return 0;





























	
}

Measured memory_bytes: 2168
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <stack>
#include <queue>
#include <iomanip>
#include <cmath>

typedef long long ll;

using namespace std;

struct dim2 {
    int x;
    int y;
};

long kaijo(int n) {
    int ret = 1;
    for(int i = 1; i <= n; i++) {
        ret *= i;
    }
    return ret;
}

int main() {
    int n;
    cin >> n;
    
    vector<dim2> v(n);
    for(int i = 0; i < n; i++) {
        cin >> v[i].x >> v[i].y;
    }
    
    vector<vector<long double>> dist = vector<vector<long double>>(n, vector<long double>(n, 0));
    for(int i = 0; i < n; i++) {
        for(int j = 0; j < n; j++) {
            if(i != j) {
                dist[i][j] = sqrt((v[i].x - v[j].x) * (v[i].x - v[j].x) + (v[i].y - v[j].y) * (v[i].y - v[j].y));
            }
        }
    }
    
    long cons = kaijo(n - 1);
    long double sum = 0.0;
    for(int i = 0; i < n; i++) {
        for(int j = 0; j < n; j++) {
            if(i != j) {
                sum += cons * dist[i][j];
            }
        }
    }
    
    sum /= (long double)kaijo(n);
    
    cout << setprecision(10) << sum << endl;
    
    return 0;
}



Measured memory_bytes: 256
n = int(input())
a = [int(i) for i in input().split()]
b = [int(i) for i in input().split()]

ans = 10 ** 18
for i in range(1 << n):
    c = []
    for j in range(n):
        if i >> j & 1 == 0:
            c.append(a[j])
        else:
            c.append(b[j])
    d = sorted(c)

    ind = {}
    for j, k in enumerate(d):
        if (j % 2, k) not in ind:
            ind[(j % 2, k)] = j

    e = []
    ok = True
    for j, k in enumerate(c):
        j = ((i >> j & 1) + j) % 2
        if (j, k) not in ind:
            ok = False
            break
        l = ind[(j, k)]
        if l >= n or d[l] != k:
            ok = False
            break
        e.append(l)
        ind[(j, k)] += 2

    if ok:
        count = 0
        for k in range(n):
            for j in range(n - 1 - k):
                if e[j] > e[j + 1]:
                    count += 1
                    e[j], e[j + 1] = e[j + 1], e[j]
        ans = min(ans, count)
if ans == 10 ** 18:
    print(-1)
else:
    print(ans)


Measured memory_bytes: 50652
#include<bits/stdc++.h>
using namespace std;
int main(void)
{
  string s,t;
  int cnt=0;
  cin>>s>>t;
  for(int i=0;i<s.size();i++)
  {
    if(s[i]!=t[i])
    cnt++;
  }
  cout<<cnt;
}

Measured memory_bytes: 3912
from scipy.misc import comb

N = int(input())
A = input().split()

B = {}
for i in range(0, N):
    if not(A[i] in B.keys()):
        B[A[i]] = 1
    else:
        B[A[i]] += 1 

S = 0
for value2 in B.values():
    S = S + comb(int(value2), 2, exact=True)

S0 = 0
for i in range(0, N):
    S0 = S - (comb(int(B[A[i]]), 2, exact=True) - comb(int(B[A[i]])-1, 2, exact=True))
    print(S0)

Measured memory_bytes: 36560
h,n = map(int,input().split())
L = []
for i in range(n):
  l = list(map(int,input().split()))
  L.append(l)
dp = [10**8]*10001
dp[0] = 0
for i in range(n):
  dp[L[i][0]] = L[i][1]
for i in range(10001):
  for j in range(n):
    if i-L[j][0] >= 0:
      dp[i] = min(dp[i],dp[i-L[j][0]]+L[j][1])
for i in range(9999,-1,-1):
  if dp[i] > dp[i+1]:
    dp[i] = dp[i+1]
print(dp[h])

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

#define F first
#define S second
#define MP make_pair
#define pb push_back
#define all(a) a.begin(), a.end()
#define lcm( a, b ) (a)/__gcd((a),(b))*(b)
#define endl '\n'

using namespace std;

typedef long long LL;
typedef pair< int, int > P;
typedef pair< LL, LL > LP;

static const int INF = INT_MAX;
static const LL LINF = LLONG_MAX;
static const int MIN = INT_MIN;
static const LL LMIN = LLONG_MIN;
static const int MOD = 1000000007;
static const int SIZE = 200005;

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

LL fac[SIZE], finv[SIZE], inv[SIZE];
void combInit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for( int i = 2; i < SIZE; ++i ) {
        fac[i] = (fac[i - 1] * i) % MOD;
        inv[i] = MOD - inv[MOD % i] * (MOD / i) % MOD;
        finv[i] = (finv[i - 1] * inv[i]) % MOD;

    }
}

LL comb(int n, int k) {
    if( n < k ) return 0;
    if( n < 0 || k < 0 ) return 0;
    return (fac[n] * (finv[k] * finv[n - k] % MOD)) % MOD;

}

vector< int > Div( int n ) {
    vector< int > ret;
    for( int i = 1; i * i <= n; ++i ) {
        if( n % i == 0 ) {
            ret.pb( i );

            if( i * i != n ) ret.pb( n / i );
        }
    }
    sort( all( ret ) );
    return ret;
}

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

    int n;
    cin >> n;
    int sum = 0;
    vector< int > v;
    v.pb(0);
    for( int i = 0; i < n; ++i ) {
        int a;
        cin >> a;
        v.pb(a);

    }
    v.pb(0);

    int npos = 0;
    for( int i = 1; i <= n + 1; ++i ) {
        sum += abs(npos - v[i]);
        npos = v[i];

    }

    for( int i = 1; i <= n; ++i ) {
        int asum = abs(v[i - 1] - v[i]) + abs(v[i] - v[i + 1]);
        int bsum = abs(v[i - 1] - v[i + 1]);
        cout << sum - (asum - bsum) << endl;

    }
    return 0;
}



Measured memory_bytes: 1784
import java.util.*;
public class Main {
	public static void main(String[] args){
      Scanner sc = new Scanner(System.in);
	  String s = sc.next(); 
      int a = Character.getNumericValue(s.charAt(0));
      int b = Character.getNumericValue(s.charAt(1));
      int c = Character.getNumericValue(s.charAt(2));
      int d = Character.getNumericValue(s.charAt(3));
     
      if(a+b+c+d==7){
        System.out.println(a+"+"+b+"+"+c+"+"+d+"=7");
      }else if(a-b+c+d==7){
        System.out.println(a+"-"+b+"+"+c+"+"+d+"=7");
      }else if(a+b-c+d==7){
        System.out.println(a+"+"+b+"-"+c+"+"+d+"=7");
      }else if(a+b+c-d==7){
        System.out.println(a+"+"+b+"+"+c+"-"+d+"=7");
      }else if(a-b-c+d==7){
        System.out.println(a+"-"+b+"-"+c+"+"+d+"=7");
      }else if(a+b-c-d==7){
        System.out.println(a+"+"+b+"-"+c+"-"+d+"=7");
      }else if(a-b+c-d==7){
        System.out.println(a+"-"+b+"+"+c+"-"+d+"=7");
      }else if(a-b-c-d==7){
        System.out.println(a+"-"+b+"-"+c+"-"+d+"=7");
      }
    }
}

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

using namespace std;

vector<int> p, r;


void makeSet(int x){
  p[x] = x;
  r[x] = 0;
}

int findSet(int x){
  if(x != p[x])p[x] = findSet(p[x]);
  return p[x];
}

void link(int x, int y){
  if(r[x] > r[y]) p[y] = x;
  else {
    p[x] = y;
    if(r[x] == r[y]) r[y] = r[y] + 1;
  }
}



void unite(int a, int b){
  link(findSet(a), findSet(b));
}


struct Edge{
  int a,b,cost;

  bool operator<(const Edge& o) const{
    return cost < o.cost;
  }
};


struct Graph{
  int n;
  vector<Edge> es;

  int kruskal(){
    sort(es.begin(), es.end());

    int min = 0;

    for(int i=0; i<es.size(); i++){
      Edge& e = es[i];
      if(!(findSet(e.a)==findSet(e.b))){
	min += e.cost;
	unite(e.a, e.b);
      }
    }

    return min;
  }
};

Edge e;


int main(){

  int V, E, i;
  Graph g;

  cin >> V >> E;

  p.resize(V);
  r.resize(V);

  for(i=0; i<V; i++)makeSet(i);

  for(i=0; i<E; i++){
    cin >> e.a >> e.b >>e.cost;
    g.es.push_back(e);
  }


  cout << g.kruskal() << endl;

  return 0;
}



Measured memory_bytes: 4576
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <cmath>
#include <numeric>
#include <queue>
#include <sstream>
#include <unordered_map>
#include <cstring>
#include <iomanip>

using namespace std;

typedef long long ll;

const ll INF=1e9+7;

template<class T> inline bool chmin(T& a, T b) {if (a > b) {a = b;return true;}return false;}
template<class T> inline bool chmax(T& a, T b) {if (a < b) {a = b;return true;}return false;}

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

int main(){
    int N,min=10000;
    cin>>N;
    string S(3,'1');
    rep(i,10){
        int check=stoi(S);
        if(check>=N){
            cout<<check<<endl;
            return 0;
        }
        S[0]++;
        S[1]++;
        S[2]++;
    }
    return 0;
}

//a=97,z=122

Measured memory_bytes: 256
//#include<iostream>
//
//#include<string.h>
//
//#define LEN 100005
//
//typedef struct pp {
//	char name[100];
//	int t;
//}P;
//
//P Q[LEN];
//int head, tail, n;
//
//void enqueue(P x) {
//	Q[tail] = x;
//	tail = (tail + 1) % LEN;
//}
//
//P dequeue() {
//	P x = Q[head];
//	head = (head + 1) % LEN;
//	return x;
//}
//
//int min(int a, int b) {
//	return a < b ? a : b;
//}
//int main() {
//	int elaps = 0, c;
//	int i, q;
//	P u;
//	scanf("%d %d", &n, &q);
//
//	for (i = 1; i <= n; i++) {
//		scanf("%s", Q[i].name);
//		scanf("%d", &Q[i].t);
//	}
//	head = 1; tail = n + 1;
//	while (head != tail) {
//		u = dequeue();
//		c = min(q, u.t);
//		u.t -= c;
//		elaps += c;
//		if (u.t > 0)enqueue(u);
//		else {
//			printf("%s %d\n", u.name, elaps);
//		}
//	}
//
//	return 0;
//}

//#include<iostream>
//#include<string>
//#include<queue>
//#include<algorithm>
//using namespace std;
//
//int main() {
//	int n, q, t;
//	string name;
//	queue<pair<string, int>> Q;
//
//	cin >> n >> q;
//
//	for (int i = 0; i < n; i++) {
//		cin >> name >> t;
//		Q.push(make_pair(name, t));
//
//	}
//
//	pair<string, int>u;
//	int elaps = 0, a;
//
//	while (!Q.empty()) {
//		u = Q.front(); Q.pop();
//		a = min(u.second, q);
//		u.second -= a;
//		elaps += a;
//		if (u.second > 0) {
//			Q.push(u);
//
//		}
//		else {
//			cout << u.first <<" "<< elaps << endl;
//		}
//	}
//	return 0;
//}

//round 2
#include<iostream>
#include<string>

#define LEN 100005

typedef struct pp {
	char name[100];
	int t;
} P;

using namespace std;



P Q[LEN + 1];

int head, tail, n;

void initialize() {
	head = tail = 0;
}

bool isEmpty() {
	return head == tail;
}

bool isFull() {
	return head == (tail + 1) % LEN;
}

void enqueue(P x) {
	if (isFull()) {
		cout << "error" << endl;
	}
	Q[tail] = x;
	if (tail + 1 == LEN) {
		tail = 0;
	}
	else {
		tail++;
	}
}
P dequeue() {
	if (isEmpty()) {
		cout << "error" << endl;
	}
	P x = Q[head];

	if (head + 1 == LEN) {
		head = 0;
	}
	else {
		head++;
	}
	return x;

}
int main() {
	int n,q;
	int elaps = 0;

	cin >> n>>q;
	for (int i = 0; i < n; i++) {
		cin >> Q[i].name;
		cin >> Q[i].t;
		
	}
	tail = n;
	while (!isEmpty()) {
		P x = dequeue();
		if (x.t <= q) {
			elaps += x.t;
			cout << x.name << " " << elaps << endl;
		}
		else {
			elaps += q;
			x.t -= q;
			enqueue(x);
		}
	}

	

}





Measured memory_bytes: 13248
#include <bits/stdc++.h>
        using namespace std;
        #define ll long long
        int u_b(vector<int>&v,int key){
          int s=0,e=v.size()-1;
          while(s<=e){
            int mid=(ll)(s+e)/2;
            if(v[mid]==key) return mid;
            if(v[mid]>key) e=mid-1;
            else s=mid+1;
          }
          return s;
        }
        int l_b(vector<int>&v,int key){
          int s=0,e=v.size()-1;
          while(s<=e){
            int mid=(ll)(s+e)/2;
            if(v[mid]==key) return mid;
            if(v[mid]>key) e=mid-1;
            else s=mid+1;
          }
          return e;
        }
        int main()
        {
          ll n;
          cin>>n;
          string s;
          cin>>s;
          int c_r=0,c_w=0;
          for(char c: s){
            if(c=='R') c_r++;
            else c_w++;
          }
          string resStr;
          while(c_r){
            resStr+="R";
            c_r--;
          }
          while(c_w){
            resStr+="W";
            c_w--;
          }
          int r=0,w=0;
          for(int i=0;i<s.length();i++){
              if(s[i]=='R'){
                if(s[i]!=resStr[i])
                   r++;
              }else{
                if(s[i]!=resStr[i])
                   w++;
              }
          }
          cout<<min(r,w);
            return 0;
        }

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

res = 0
for i in range(1, N + 1):
    if i % 2 == 1:
        cnt = 0
        for j in range(1, i + 1):
            if i % j == 0:
                cnt += 1
        if cnt == 8:
            res += 1
print(res)

Measured memory_bytes: 2940
#include <bits/stdc++.h>
#define rep(i,n) for(int64_t i=0;i < (int64_t)(n);i++)
#define invrep(i,n) for(int64_t i=n-1;i >= 0;i--)
using namespace std;

//////全探索したいときに開けよ////////
vector<vector<int>> fspattern;
vector<int> fspattern_draft;
int fspcnt = 0;

void setfspattern_core(int floor,int number,int degree){
  if(floor==degree){
    fspattern.at(fspcnt) = fspattern_draft;
    fspcnt++;
  }else{
    rep(i,number){
      fspattern_draft.at(floor) = i;
      setfspattern_core(floor+1,number,degree);
    }
  }
}

void setfspattern(int number,int degree){
  fspcnt = 0;
  int64_t array_num = 1;
  rep(i,degree){
    array_num *= number;
  }
  fspattern = vector<vector<int>>(array_num,vector<int>(degree));
  fspattern_draft = vector<int>(degree);
  setfspattern_core(0,number,degree);
}

//////nCrのmodを求めたいときに開けよ/////////
//int64_t univMod = 1000000007;
//int64_t factnum = 100000
//vector<int64_t> modfact(factnum);
//vector<int64_t> modinvfact(factnum);

/*void setmodfact(){
  for(int i=0;i<factnum;i++){
    if(i == 0){
      modfact.at(i) = 1;
    }else{
      modfact.at(i) = (modfact.at(i-1)*i)%univMod;
    }
  }
}

int64_t calcmodpower(int64_t a,int64_t n){
  int64_t res = 1;
  while(n != 0){
    if(n & 1){
      res = (res * a) % univMod;
    }
    a = (a*a) % univMod;
    n = n >> 1;
  }
  return res;
}

int64_t calcinverse(int64_t n){
	return calcmodpower(n,univMod-2);
}

void setmodinvfact(){
  for(int i=0;i<factnum;i++){
    if(i==0){
      modinvfact.at(i) = 1;
    }else{
      modinvfact.at(i) = calcmodpower(modfact.at(i),univMod-2);
    }
  }
}*/


/*
int64_t calcGCD(int64_t a,int64_t b){
	int64_t p = a;
	int64_t q = b;
	int64_t c = a%b;
	while(c != 0){
		p = q;
		q = c;
		c = p%q;
	}
	return q;
}
*/

int main(){
  int64_t n,a,b;
  cin >> n >> a >> b;
  if((b-a)%2 == 0){
    cout << "Alice" <<endl;
  }else{
    cout << "Borys" << endl;
  }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repr(i, a, b) for(int i = a; i < b; i++)
#define  all(x) (x).begin(),(x).end()     // 昇順ソート
#define  rall(v) (v).rbegin(), (v).rend() // 降順ソート
#define  FastIO ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0)
typedef long long ll;
typedef long long int lli;
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return true; } return false; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return true; } return false; }

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

int main(){
    int n;
    cin >> n;
    vector<int> a(n+1);
    vector<int> b(n+1, 0);
    for(int i = 1; i <= n; i++) cin >> a[i];
    int ans = 0;
    for(int i = n; i >= 1; i--){
        int sum = 0;
        for(int j = i * 2; j <= n; j += i){
            sum += b[j];
        }
        if (sum % 2 != a[i]){
            b[i] = 1;
            ans++;
        } 
    }
    cout << ans << endl;
    for(int i = 1; i <= n; i++){
        if (b[i] == 1) cout << i << " ";
    }
    cout << endl;
}

Measured memory_bytes: 4760
use proconio::{fastout, input};
use rand::Rng;

#[fastout]
fn main() {
  input! {
    d: usize,
    c: [usize; 26],
    s: [[i64; 26]; d],
  }
  
  let mut rng = rand::thread_rng();
  
  let mut lc = Vec::with_capacity(26);

  for _ in 0..26 {
    lc.push(0);
  }

  
  for i in 0..d {
    let mut t:usize = 0;
    let mut ts = -10000000;
    let mut t2:usize = 0;
    let mut ts2 = -10000000;
    for ti in 0..26 {
      let tc = s[i][ti] + c[ti] as i64 * (i + 1 - lc[ti]) as i64;
      if ts < tc  {
        t2 = t;
        ts2 = ts;
        ts = tc;
        t = ti as usize;
      }
    }
    let j: usize = rng.gen(); 
    if i < j%d {
      t = t2;
    }
    lc[t] = i + 1;
    println!("{}",t+1);
  }
}


Measured memory_bytes: 2752
import sys
import math
import functools

def resolve(in_):
    N = int(next(in_))
    A = tuple(map(int, next(in_).split()))

    max_a = max(A)
    temp = [0] * (max_a + 1)
    temp[1] = 1

    for i in range(2, max_a + 1):
        if temp[i]:
            continue

        j = i
        while j < max_a + 1:
            if not temp[j]:
                temp[j] = i
            j += i

    B = set()
    for a in A:
        s = set()
        while a > 1:
            s.add(temp[a])
            a = a // temp[a]
        for v in s:
            if v in B:
                if functools.reduce(math.gcd, A) == 1:
                    return 'setwise coprime'
                else:
                    return 'not coprime'
            B.add(v)
    
    return 'pairwise coprime'
    

def main():
    answer = resolve(sys.stdin.buffer)
    print(answer)


if __name__ == '__main__':
    main()


Measured memory_bytes: 208388
#include<bits/stdc++.h>
using namespace std;
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define lli long long int
#define ulli unsigned lli
#define ld long double
#define pb push_back
#define mp make_pair
#define bp pop_back
#define vi vector<int>
#define vvi vector< vector<int> >
#define vli vector<lli>
#define vvli vector< vector<lli> >
#define pii pair <int, int>
#define pli pair <lli, lli>
#define vpi vector<pii>
#define ppi pair<pii,int>
#define pip pair<int,pii>
#define forn(i,n) for(i=0;i<n;i++)
#define rof(i,k,n) for(i=k;i>=n;i--)
#define wh(k) while(k--)
#define mod 1000000007
#define all(i,m) auto i=m.begin();i!=m.end();i++
#define mii map<int,int>
#define F first
#define S second

const int MAX=1000000;

int main()
{
    fast;
    lli n,i,a,b;
    cin>>n;
    vli x,y;
    forn(i,n)
    {
    	cin>>a>>b;
    	x.pb(a+b);
    	y.pb(a-b);
    }
    sort(x.begin(),x.end());
    sort(y.begin(),y.end());
    lli ans=x[x.size()-1]-x[0];
    ans=max(ans,y[y.size()-1]-y[0]);
    cout<<ans<<'\n';
    return 0;
}

Measured memory_bytes: 6672
#include<cstdio>
#include<cmath>
#include<random>
#include<vector>
#include<algorithm>
#include<cstdlib>
#include<cstring>
#include<string>
#include<utility>
#include<queue>
using namespace std;
typedef long long ll;
typedef pair<int, int> ii; 
typedef pair<ii,int> iii;
typedef vector<ii> vii;
typedef vector<int> vi;
#define INF 1000000000
const int N=100010;
int a[N];
int main(){
    vii z;
    int n,m,b,c;
    scanf("%d %d",&n,&m);
    for(int i=0;i<n;i++)
    	scanf("%d",&a[i]);
    for(int i=0;i<m;i++)
    {
    	scanf("%d %d",&b,&c);
    	z.push_back(ii(c,b));
    }
    sort(z.begin(),z.end());
    reverse(z.begin(),z.end());
    sort(a,a+n);
    reverse(a,a+n);
    ll summ=0;
    int r=n;
    int i=0,j=0;
    while(r)
    {
         if(j==z.size()|| a[i]>z[j].first){
         	summ+=a[i];
         	i++;
         	r--;
         }
         else {
         	summ+=(ll)min(r,z[j].second)*z[j].first;
         	r-=min(r,z[j].second);
      		j++;
         }
    }
	printf("%lld\n",summ);
    }


Measured memory_bytes: 1784
# frozen_string_literal: true

h, w = gets.split.map(&:to_i)
s = []

h.times do |i|
  s[i] = gets.chomp.chars
  s[i] << nil
end
s << Array.new(w) { nil }

move = [[1, 0], [0, 1], [-1, 0], [0, -1]]
max = 0

h.times do |i|
  w.times do |j|
    next if s[i][j] == '#'

    dist = Array.new(h) { Array.new(w) { -1 } }
    dist[i][j] = 0
    queue = [[i, j]]

    while queue.any?
      pt = queue.shift
      pred_x = pt[0]
      pred_y = pt[1]

      move.each do |m|
        x = pred_x + m[0]
        y = pred_y + m[1]
        succ = s[x][y]

        next if succ == '#' || succ.nil?
        next if dist[x][y] != -1

        dist[x][y] = dist[pred_x][pred_y] + 1

        max = dist[x][y] if max < dist[x][y]
        queue << [x, y]
      end
    end
  end
end

puts max

Measured memory_bytes: 2172
n,t = map(int,input().split())

ct = [0]*n

for i in range(0,n):
  ct[i] = input().split()
  
s = []
for i in range(0,n):
  if(int(ct[i][1]) <= t):
    s.append(int(ct[i][0]))
if(len(s) != 0):
  print(min(s))
else:
  print("TLE")

Measured memory_bytes: 38384
#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;
long long longpow(long long n, long long a, long long mod) {
  if (a == 0) return 1;
  if (a == 1) return n % mod;
  if (a % 2 == 1) return (n * longpow(n, a - 1, mod)) % mod;
  ll t = longpow(n, a / 2, mod) % mod;
  return (t * t) % mod;
}
int main() {
  ll N, X, M;
  cin >> N >> X >> M;
  unordered_map<ll, ll> uo;
  vector<ll> mod(M, -1);
  ll ans = 0;
  bool b = false;
  ll tmp = X;
  if (M == 1) {
    cout << 0 << endl;
    return 0;
  }
  for (ll i = 1; i <= N; i++) {
    if (mod[tmp] != -1 && !b) {
      ll t = i - mod[tmp];
      ll num = 0;
      for (ll j = mod[tmp]; j < i; j++) {
        num += uo[j];
      }
      ll d = N - (mod[tmp] );
      ans += (d / t - 1) * num;
      // i = N - d % t - mod[tmp];
      /*i = N;
      i -= d % t;
      i -= mod[tmp];*/
      i += (d / t - 1) * t;
      b = true;
    }
    ans += tmp;
    uo[i] = tmp;
    mod[tmp] = i;
    tmp *= tmp;
    tmp %= M;
    if (tmp == 0) break;
  }
  cout << ans << endl;
}

Measured memory_bytes: 7816
import java.util.ArrayDeque;
import java.util.Queue;
import java.util.Random;
import java.util.Scanner;
 


public class Main {
	private static Scanner sc = new Scanner(System.in);
	//result = Math.pow(num1, num3)
	//StringBuffer str = new StringBuffer(hoge1);
	//String hoge2 = str.reverse().toString();
	//map.containsKey(A)

	//Map<String, Integer> map = new HashMap<String, Integer>(n);
	/*for ( キーのデータ型 key : マップの名前.keySet() ) {
		データのデータ型 data = マップの名前.get( key );
		
		// keyやdataを使った処理;
	}*/
	//int i = Integer.parseInt(s);
	//Queue<String> qq=new ArrayDeque<>(); //add,poll,peek
	//Deque<String> qq=new ArrayDeque<>();//push,pop,peek
	//ArrayList<String> cc = new ArrayList<>(n);
	//Collections.sort(list);
	//Array.sort(list);   cc.contains(tmp)
	//Arrays.asList(c).contains("a")
	//list.set(1,"walk");//1 1 2 3 5
	//static long mod =1000000007;
	//static 	ArrayList<Integer> cc = new ArrayList<>(100);
	
	
	
	public static void main(String[] args) {
		//int N=sc.nextInt();for(int i=0;i<N;i++) {}
		//int a[]=new int[N];
		Long N=sc.nextLong();
		
		long min=0;
		for(int i=0;i<5;i++) {
			
			if(i==0)min=sc.nextLong();
			else min=Math.min(min, sc.nextLong());
		}
		p((long)Math.ceil((double)N/min)+4);
		
		
		
		
		
	}
	
	
	

	


	
	static void p(String ans) {System.out.println(ans);};
	static void p(int ans) {System.out.println(ans);};
	static void p() {System.out.println();};
	static void p(long ans) {System.out.println(ans);};
	static void p(double ans) {System.out.println(ans);};
	
}
	


Measured memory_bytes: 21844
#include<cstdio>
#include<vector>
#include<algorithm>
#include<utility>
#include<numeric>
#include<iostream>
#include<array>
#include<string>
#include<sstream>
#include<stack>
#include<queue>
#define _USE_MATH_DEFINES

#include<math.h>
#include<unordered_map>

#define min(a,b) (a)>(b)?(b):(a)
#define max(a,b) (a)>(b)?(a):(b)

using namespace std;

class Process
{
public:
	string name;
	int time;
};

int main()
{
	queue<Process> a;
	vector<Process> result;
	int n, q, timer = 0;
	cin >> n >> q;
	for (int i = 0; i < n; i++)
	{
		Process p;
		cin >> p.name >> p.time;
		a.push(p);
	}

	while (true)
	{
		if (a.size() == 0)
		{
			break;
		}

		Process p;
		p = a.front();
		a.pop();
		if (p.time <= q)
		{
			timer += p.time;
			p.time = timer;
			result.push_back(p);
		}
		else
		{
			timer += q;
			p.time -= q;
			a.push(p);
		}
	}

	for (auto& p : result)
	{
		cout << p.name << " " << p.time << endl;
	}
	return 0;
}

Measured memory_bytes: 6984
N,T = map(int, input().split())
l = []
for i in range(N):
  c, t = map(int, input().split())
  if not t > T:
    l.append([i+1, c])
if l == []:
    print('TLE'); exit()
l.sort(key=lambda x: x[1])
print(l[0][1])

Measured memory_bytes: 3060
# input the number
x = int(input())

# show how many times 500¥ and 5¥ can divide
div_500 = x // 500
div_5 = (x - div_500 * 500) // 5

# pleasure of Mr TAKAHASHI
pleasure = 1000 * div_500 + 5 * div_5
print(pleasure)


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

#define FOR(i, a, b) for(int i = a; i < b; ++i)
#define REP(i, n) FOR(i, 0, n)
#define _ << " " <<
#define sz(x) ((int) x.size())
#define pb(x) push_back(x)
#define TRACE(x) cerr << #x << " = " << x << endl

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

const int mod = 1e9 + 7;

int add(int x, int y) {x += y; if(x >= mod) return x - mod; return x;}
int sub(int x, int y) {x -= y; if(x < 0) return x + mod; return x;}
int mul(int x, int y) {return (ll) x * y % mod;}

const int MAXN = 1e5 + 5;

int n, m, d[MAXN], color[MAXN], dist[MAXN];
vector <int> E[MAXN];
vector <point> edges;
map<point, int> sol;

void done(){
  cout << -1;
  exit(0);
}

void assign_different(int x, int y){
  if(color[x] == -1 && color[y] == -1){
    color[x] = 0;
    color[y] = 1;
  }
  else if(color[x] == -1 || color[y] == -1){
    int mx = max(color[x], color[y]);
    if(color[x] == -1)
      color[x] = !mx;
    else
      color[y] = !mx;
  }
}

void assign_same(int x, int y){
  if(color[x] == -1 && color[y] == -1){
    color[x] = color[y] = 0;
  }
  else if(color[x] == -1 || color[y] == -1){
    int mx = max(color[x], color[y]);
    color[x] = color[y] = mx;
  }
}

int main(){
  ios_base::sync_with_stdio(false); cin.tie(0);
  memset(color, -1, sizeof(color));

  vector <point> v;
  cin >> n >> m;
  REP(i, n){
    cin >> d[i];
    v.pb(point(d[i], i));
  }
  REP(i, m){
    int a, b; cin >> a >> b;
    a --; b --;
    edges.pb(point(a, b));
    E[a].pb(b); E[b].pb(a);
  }

  sort(v.begin(), v.end());
  for(auto it : v){
    int id = it.second;

    bool stop = true;
    for(auto e : E[it.second]){
      if(d[id] >= d[e] && color[id] != -1 && color[e] != -1 && !sol[ point(id, e) ]){
        sol[ point(id, e) ] = sol[ point(e, id) ] = 1e9;
        stop = false;
      }
      else if(d[id] == d[e]){
        sol[ point(id, e) ] = sol[ point(e, id) ] = d[id];
        assign_different(id, e);
        stop = false;
      }
      else if(d[id] > d[e] ){
        sol[ point(id, e) ] = sol[ point(e, id) ] = d[id] - d[e];
        assign_same(id, e);
        stop = false;
      }
    }
    if(stop){
      done();
    }

  }

  REP(i, n){
    if(color[i] == 0)
      cout << 'B';
    else
      cout << 'W';
  }
  cout << "\n";
  for(auto it : edges){
    cout << sol[ it ] << "\n";
  }
}


Measured memory_bytes: 36592
def gcd(x, y): 
  
   while(y): 
       x, y = y, x % y 
  
   return x 
[a,b,c,d]=[int(x) for x in input().split()]
k=(c*d)//gcd(c,d)
count=(b-a+1)-((b//c-(a-1)//c)+(b//d-(a-1)//d)-(b//k-(a-1)//k))
print(count)
    

Measured memory_bytes: 3060
#define _USE_MATH_DEFINES
#include "bits/stdc++.h"
#define rep(i,a,b) for (int i = (a); i < (b); i++)
using namespace std;
typedef long long int ll;
typedef pair<ll,ll> P;
typedef complex<double> com;
const int mod = 1e9 + 7;
const int MOD = 998244353;
const int inf = 2e9;



int main() {
	int x1,y1,x2,y2,x3,y3;
	cin>>x1>>y1>>x2>>y2>>x3>>y3;
	double a=sqrt((x1-x2)*(x1-x2)+(y1-y2)*(y1-y2));
	double b=sqrt((x2-x3)*(x2-x3)+(y2-y3)*(y2-y3));
	double c=sqrt((x3-x1)*(x3-x1)+(y3-y1)*(y3-y1));
	double t=(a+b+c)/2.0;
	double s=sqrt(1.0*t*(t-a)*(t-b)*(t-c));
	double r=s*2.0/(a+b+c);
	double maxx=max(a,max(b,c));
	double ans=r*maxx*1.0/(2.0*r+maxx);
	printf("%.10f",ans);
  	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
  int a, b, c;
  cin >> a >> b >> c;
  if ((a==5&&b==5&&c==7)||(a==5&&b==7&&c==5)||(a==7&&b==5&&c==5)){
    cout << "YES" << endl;
  }
  else {
    cout << "NO" << endl;
  }
}

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

using namespace std;

int main()
{
    int N;
    cin >> N;
    if(N <= 111) puts("111");
    else if(N <= 222) puts("222");
    else if(N <= 333) puts("333");
    else if(N <= 444) puts("444");
    else if(N <= 555) puts("555");
    else if(N <= 666) puts("666");
    else if(N <= 777) puts("777");
    else if(N <= 888) puts("888");
    else if(N <= 999) puts("999");
    return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Main main = new Main();
		main.run();
	}

	int r;
	public void run() {
		Scanner sc = new Scanner(System.in);
		r = sc.nextInt();
		System.out.println(r*r);
		sc.close();
	}
}

Measured memory_bytes: 22608
def inv(A,l,m,r):
    global c
    L,R=A[l:m]+[1e9],A[m:r]+[1e9]
    i=j=0
    for k in range(l,r):
        if L[i]<R[j]:
            A[k]=L[i];i+=1;c+=j
        else:
            A[k]=R[j];j+=1
def s(A,l,r):
 if l+1<r:
    m=(l+r)//2;s(A,l,m);s(A,m,r);inv(A,l,m,r)
c=0
n=int(input())
A=[int(i) for i in input().rstrip().split(" ")]
s(A,0,n)
print(c)


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

#define ll long long

int main() {
    std::ios::sync_with_stdio(false);
    using namespace std;
    const ll mod = 1'000'000'000 + 7;
    ll n, k;
    cin >> n >> k;
    array< vector<ll>, 2 > A;
    for(int i : {0, 1})
        A[i].resize(k + 1, 0);

    A[0][0] = A[1][0] = 1;

    for(int i = 0; i < n; i++) {
        int a;
        cin >> a; 
        ll c = 0;
        for(int j = 0; j <= k; j++) {
            c = (c + A[(i + 1) % 2][j]) % mod;
            if(j - a > 0)
                c = (c - A[(i + 1) % 2][j - a - 1] + mod) % mod;
            A[i % 2][j] = c;
        }
    }
    cout << A[(n + 1) % 2][k] << "\n";

    return 0;
}


Measured memory_bytes: 1792
#include <iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<map>
#include<set>
#include<stack>
#include<queue>
#include<math.h>
using namespace std;
typedef long long ll;
#define int long long
typedef vector<int> VI;
typedef pair<int, int> pii;
typedef priority_queue<int> PQ;
template<class T>bool chmax(T &a, const T &b) { if (a < b) { a = b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b < a) { a = b; return 1; } return 0; }
#define fore(i,a) for(auto &i:a)
#define REP(i,n) for(int i=0;i<n;i++)
#define eREP(i,n) for(int i=0;i<=n;i++)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define eFOR(i,a,b) for(int i=(a);i<=(b);++i)
#define SORT(c) sort((c).begin(),(c).end())
#define rSORT(c) sort((c).rbegin(),(c).rend())
#define LB(x,a) lower_bound((x).begin(),(x).end(),(a))
#define UB(x,a) upper_bound((x).begin(),(x).end(),(a))
#define INF 1000000000
#define LLINF 9223372036854775807
#define mod 1000000007
//vector<vector<int> > dp;
//vector<vector<vector<int> > > vvvi;
//dp=vector<vector<int> >(N, vector<int>(M,0));
//vector<pair<int,int> > v;
//v.push_back(make_pair(x,y));
//priority_queue<int,vector<int>, greater<int> > q2;



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

	int H, N;
	cin >> H >> N;
	vector<pii>A(N);
	REP(i, N)cin >> A[i].first >> A[i].second;
	SORT(A);
	VI dp(H + 10, INF);
	dp[0] = 0;

	eFOR(i, 0, H) {
		REP(j, N) {

			int a = A[j].first, b = A[j].second;
			//if (i - a < 0)break;


			int tmp = i + a;
			tmp = min(H, tmp);

			chmin(dp[tmp], dp[i] + b);

			//cout << i << " " << i - a << endl;

		}
	}
	//eREP(i, H)cout << dp[i] << " ";
	cout << dp[H] << endl;







	return 0;
}



Measured memory_bytes: 384
N, M = map(int, input().split())
a = [int(input()) for _ in range(M)]
a_s = set(a)
mod = 1000000007

dp = [0] * (N + 1)
dp[0] = 1

for i in range(1, N + 1):
    if i in a_s:
        continue
    elif i >= 2:
        dp[i] = (dp[i - 1] + dp[i - 2]) % mod
    else:
        dp[i] = (dp[i - 1]) % mod
print(dp[-1])


Measured memory_bytes: 13192
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define d double
#define INF INT_MAX
#define output for(int i=0;i<sizex;i++) { for(int j=0;j<sizey;j++) { cout << moveChart[i][j] << " "; }cout<<endl; }cout<<endl;

string a, b;
int dp[3001][3001];
int bt[3001][3001];
string S;

int solve( int idxA, int idxB ){

    if( idxA >= a.length() || idxB >= b.length() ) return 0;

    if( dp[idxA][idxB] != -1 ) return dp[idxA][idxB];

    if( a[idxA] == b[idxB] ){

        int res = solve( idxA+1, idxB+1 ) + 1;
        bt[idxA][idxB] = 0;
        return dp[idxA][idxB] = res;

    }

    int res1 = solve( idxA+1, idxB );
    int res2 = solve( idxA, idxB+1 );
    if( res1 >= res2 ){

        bt[idxA][idxB] = 1;
        return dp[idxA][idxB] = res1;

    }else{

        bt[idxA][idxB] = 2;
        return dp[idxA][idxB] = res2;

    }

}

void backtrack(){

    int idxA, idxB;
    idxA = idxB = 0;

    while( bt[idxA][idxB] != -1 ){

        if( bt[idxA][idxB] == 0 ){
            cout << a[idxA];
            idxA++; idxB++;
        }else if( bt[idxA][idxB] == 1 ){
            idxA++;
        }else{
            idxB++;
        }

    }

}

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

    memset( dp, -1, sizeof dp );
    memset( bt, -1, sizeof bt );

    cin >> a >> b;

    solve( 0, 0 );

    // cout << res << endl;
    
    backtrack();
    cout << endl;

}

Measured memory_bytes: 70912
#include<bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < n ; i++)
#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define whole(f, x, ...) ([&](decltype((x)) whole) { return (f)(begin(whole), end(whole), ## __VA_ARGS__); })(x) // decltypeで型取得、引数があればva_argsのところに入れる
using namespace std;
typedef long long ll; // long longをllでかけるようにした
const int INF = 1e9;

int main(void){
    while(true){
        int n; cin >> n;
        if(n == 0) return 0;
        else if(n == 1) cout << 1 << endl;
        else{
            int count = 0;
            FOR(i, n + 1, 2 * n + 1){
                bool flag = true;
                FOR(j, 2, sqrt(i) + 1){
                    if(i % j == 0){
                        flag = false;
                        break;
                    }
                }
                if(flag) count++;
            }
            cout << count << endl;
        }
    }
}


Measured memory_bytes: 3040
N, K, Q = gets.split.map(&:to_i)
a = []
correct = []
correct = correct.fill(0,0..N-1)
Q.times do |i|
  a[i] = gets.to_i
  # 正解数を保存しておく
  correct[a[i]-1] += 1
end

# 持ち点 > 問題数 のとき 持ち点が0になることはない
if K > Q
  N.times do
    puts "Yes"
  end
  exit
end

# 間違っていい回数はK-1回
# 正解しないといけないのはQ-(K-1)=Q-K+1回
correct.each do |c|
  if c >= Q-K+1
    puts "Yes"
  else
    puts "No"
  end
end

Measured memory_bytes: 4168
use std::io::*;
use std::str::FromStr;

fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}

fn s(mut n: i64) -> i64 {
    let mut ret = 0;
    while n > 0 {
        ret += n % 10;
        n /= 10;
    }
    return ret;
}

fn score(n: i64) -> f64 {
    (n as f64)  / s(n) as f64
}

fn better(x: i64, y: i64) -> bool {
    return x * s(y) <= y * s(x);
}

fn solve_naive(k: usize) -> Vec<i64> {
    let n: i64 = 1000000;

    let mut a: Vec<(i64)> = vec![];
    let mut mi: f64 = 1e20;
    for x in (1..n).rev() {
        let t = (x as f64) / (s(x) as f64);

        if t <= mi {
            mi = t;
            a.push(x);
        }
    }

    a.reverse();
    return a[..k].to_vec();
}

/*
fn hoge(b: i64) -> (i64, i64) {
    if b <= 1000 {
        return (10, 1);
    } else {
        return (100, 10);
    }
}

fn solve(k: usize) -> Vec<i64> {
    let mut ans: Vec<i64> = vec![];

    let mut b: i64 = 10;
    while ans.len() <= k {
        let (hb, hstart)  = hoge(b);
        let bb = b / hb;

        for head in hstart..hb {
            let x = (head * bb) + (bb - 1);
            ans.push(x);
        }

        b *= 10;
    }
    return ans[0..k].to_vec();
}*/

/*
fn solve(k: usize) -> Vec<i64> {
    let mut ans: Vec<i64> = vec![];

    let mut x: i64 = 1;
    while ans.len() < k {
        let mut b = 1;
        while x >= b && x / b % 10 == 9 {
            b *= 10;
        }

        println!("{} {}", x, b);

        if x < b {  // 9..99
            ans.push(x);
            x += 1;
            continue;
        }

        let y = x + b;
        if better(x, y) {
            ans.push(x);
            x = y;
        } else {
            x = ((x / b / 10) * 10 + 9) * b + x % b;
        }
    }

    return ans;
}
*/
fn solve(k: usize) -> Vec<i64> {
    let mut ans: Vec<i64> = vec![];

    let mut x: i64 = 1;
    let mut b = 1;
    while ans.len() < k {
        if better(x, x + b) {
            ans.push(x);
        }

        let sx = score(x);
        while ((b * 10) as f64) < sx {
            b *= 10;
        }

        let y= x / b * b + (b - 1);
        if x < y {
            x = y;
        } else {
            x += b;
        }
        // println!("{} {} {}", x, b, ans.len());
    }

    return ans;
}

fn main() {
    let k: usize = read();

    // assert_eq!(solve(k), solve_naive(k));
    // println!("{:?}", solve(k));

    for x in solve(k).iter() {
        println!("{}", x);
    }

    // println!("{}", ans);
}


Measured memory_bytes: 4352
fun main(args: Array<String>) {
  val (S, T) = readStrings()
  var (A, B) = readInts()
  val U = readString()

  if (S == U) {
    A--
  }
  if (T == U) {
    B--
  }
  println("$A $B")
}

fun readString() = readLine()!!
fun readStrings() = readString().split(" ")
fun readInt() = readString().toInt()
fun readInts() = readStrings().map { it.toInt() }
fun readLong() = readString().toLong()
fun readLongs() = readStrings().map { it.toLong() }


Measured memory_bytes: 37872
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
#define pb push_back
#define mp make_pair
#define rep(i,n) for(int i=0;i<(n);++i)

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	string s;cin >> s;
	int cnt=0;
	rep(i,s.size()) cnt+=s.at(i)-'0';
	cout << cnt << endl;
}

Measured memory_bytes: 384
import java.util.*;
public class Main {
    public static void main(String[] args) {
        Scanner sc=new Scanner(System.in);
        int n=sc.nextInt();
        int a[]=new int[2*n];
        for(int i=0;i<2*n;i++)
        {
            a[i]=sc.nextInt();
        }
        Arrays.sort(a);
        int t=0;
        for(int i=0;i<2*n;i+=2)
        {
            t+=Math.min(a[i],a[i+1]);
        }
        System.out.println(t);
    }
    
}


Measured memory_bytes: 21972
#include<bits/stdc++.h>
using namespace std;
int main()
{
	char str[300005];
	scanf("%s",str);
	int t=strlen(str);
	//printf("%d\n",t );
	for (int i = 0; i < t; ++i)
	{
		/* code */
		//if(i==0 && str[i]=='?') str[i]='D';
		if(str[i]=='?' )
		{

			 str[i]='D';
		}
	}
	printf("%s\n",str );
}

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



int main(){
  ios::sync_with_stdio(0); cin.tie(NULL); cout.tie(NULL);
  ll i,n,k,x,j,t;
  cin>>n;
  ll ans[10001];
  memset(ans,0,sizeof(ans));
  for(i=1;i<=100;i++)
   for(j=1;j<=100;j++)
    for(k=1;k<=100;k++){
      x=i*i +j*j +k*k +i*j +i*k+ j*k;
      if(x<=n)ans[x]++;
    }
  for(i=1;i<=n;i++)
   cout<<ans[i]<<"\n";
  
}

Measured memory_bytes: 3724
s = int(input())

def f(n):
  if n%2==0:
    return n/2
  else:
    return 3*n + 1
  
m=1
a=s
_set=set([a])

while True:
  m +=1
  a = f(a)
  if a in _set:
    print(m)
    break
  else:
    _set.add(a)
    continue


Measured memory_bytes: 3060
#include <bits/stdc++.h>
#define mk make_pair
using namespace std;
typedef long long ll;
int n;
ll mem[200010];
const ll mod=1e9+7;
vector <int> a[200010];
int c[200010];
ll dp(int x){
    if(x==n)
        return 1;
    if(mem[x]!=-1)
        return mem[x];
    ll res=0;
    int tmp;
    tmp=lower_bound(a[c[x]].begin(), a[c[x]].end(), x)-a[c[x]].begin();
    ++tmp;
    if(tmp<a[c[x]].size())
        res=dp(a[c[x]][tmp]);
    if(x!=n-1){
        if(c[x]!=c[x+1]){
            res+=dp(x+1);
        }
    }
    else{
        res=1;
    }

            while(res>=mod)
                res-=mod;
    mem[x]=res;
    return res;
}

int main(){
    cin>>n;
    for(int i=0; i<n; ++i){
        scanf("%d",c+i);
        a[c[i]].push_back(i);
    }
    memset(mem, -1, sizeof mem);
    ll ans=dp(0);
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 19840
"use strict"
function main(arg) {
    let [K, S] = arg.trim().split("\n").slice(0, 2)
    K = Number(K)
    if (S.length > K) {
        console.log(S.slice(0,K) + '...')
    } else {
        console.log(S)
    }
}
main(require('fs').readFileSync('/dev/stdin', 'utf8'));

Measured memory_bytes: 29680
# encoding:utf-8
import copy
import numpy as np
import random

n,q = map(int,input().split())
s = list(str(input()))
L = []
for i in range(q):
    l,r = map(int,input().split())
    L.append([l,r])

# count_ac = np.zeros([n])
count_ac = []
count = 0
i = 0
while i < n-1:
    if s[i] == "A" and s[i+1] == "C":
        count_ac.append(count)
        count += 1
        count_ac.append(count)
        i += 2
    else:
        count_ac.append(count)
        i += 1

count_ac.append(count)


# print(count_ac)
for i in range(q):
    ans = count_ac[L[i][1]-1]-count_ac[L[i][0]-1]
    print(int(ans))


Measured memory_bytes: 33448