akhauriyash/Code-Regression huggingface dataset:
let () = Scanf.scanf "%d\n" @@ fun n ->
  let as_ = Array.init n @@ fun _ -> Scanf.scanf "%d " @@ fun a -> a in
  let acc = Array.make (n + 1) 0 in
  for i = 0 to n - 1 do
    acc.(i + 1) <- as_.(i) + acc.(i)
  done;
  Printf.printf "%d\n" @@
  Array.fold_left min max_int @@
  Array.init n @@ fun i ->
    let sum = acc.(n) in
    let l = acc.(i) in
    let r = sum - l in
    abs (r - l)



Measured memory_bytes: 8448
n = gets.strip.to_i
a = gets.strip.split.map(&:to_i)
b = gets.strip.split.map(&:to_i)
c = gets.strip.split.map(&:to_i)

ans = 0
previous_one = -1

a.each do |i|
  ans += b[i-1]
  ans += c[i-2] if previous_one == i - 1
  previous_one = i
end

p ans


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

using namespace std;

int main() {

  

  int N;

  

  cin >> N;

  

  if ( N%1000 == 0 )

    

    cout << "Yes" << endl;

  

  if ( (N%1000)%111 == 0 && N%1000 != 0)

    

    cout << "Yes" << endl;

  

  if ( N%1111 != 0 && N%1110 <= 9 )

    

    cout << "Yes" << endl;

  

  if (!( N%1000 == 0 || (N%1000)%111 == 0 ||  (N%1111 != 0 && N%1110 <= 9)  ))

    

    cout << "No" << endl;

  

}



Measured memory_bytes: 3612
// AOJ 2498 Cube of Two
// 2018.4.17 bal4u

#include <stdio.h>

char s[103];

char p[6][9] = {
"..rr....",
"..rr....",
"ggyybbww",
"ggyybbww",
"..oo....",
"..oo...."
};
  
void uu()
{
	int i;
	char c, d;
	
	c = p[0][2], p[0][2] = p[1][2], p[1][2] = p[1][3], p[1][3]=p[0][3], p[0][3] = c;
	c = p[2][0], d = p[2][1];
	for (i = 0; i < 6; i++) p[2][i] = p[2][(i+2) & 7];
	p[2][6] = c, p[2][7] = d;
}

void ff()
{
	char c, d;

	c = p[2][2], p[2][2] = p[3][2], p[3][2] = p[3][3], p[3][3] = p[2][3], p[2][3] = c;
	c = p[1][2], d = p[1][3];
	p[1][2] = p[3][1], p[1][3] = p[2][1], p[3][1] = p[4][3], p[2][1] = p[4][2];
	p[4][3] = p[2][4], p[4][2] = p[3][4], p[2][4] = c, p[3][4] = d;
}

void rr()
{
	char c, d;

	c = p[2][4], p[2][4] = p[3][4], p[3][4] = p[3][5], p[3][5] = p[2][5], p[2][5] = c;
	c = p[1][3], d = p[0][3];
	p[1][3] = p[3][3], p[0][3] = p[2][3], p[3][3] = p[5][3], p[2][3] = p[4][3];
	p[5][3] = p[2][6], p[4][3] = p[3][6], p[2][6] = c, p[3][6] = d;
}

void dd()
{
	int i;
	char c, d;

	c = p[4][2], p[4][2] = p[5][2], p[5][2] = p[5][3], p[5][3] = p[4][3], p[4][3] = c;
	c = p[3][5], d = p[3][4];
	for (i = 5; i >= 0; i--) p[3][i] = p[3][(i+6) & 7];
	p[3][6] = d; p[3][7] = c;
}

void bb()
{
	char c, d;
	
	c = p[2][6], p[2][6] = p[3][6], p[3][6] = p[3][7], p[3][7] = p[2][7], p[2][7] = c;
	c = p[0][2], d = p[0][3];
	p[0][2] = p[2][5], p[0][3] = p[3][5], p[2][5] = p[5][3], p[3][5] = p[5][2];
	p[5][3] = p[3][0], p[5][2] = p[2][0], p[3][0] = c, p[2][0] = d;
}

void ll()
{
	char c, d;

	c = p[2][0], p[2][0] = p[3][0], p[3][0] = p[3][1], p[3][1] = p[2][1], p[2][1] = c;
	c = p[4][2], d = p[5][2];
	p[4][2] = p[2][2], p[5][2] = p[3][2], p[2][2] = p[0][2], p[3][2] = p[1][2];
	p[0][2] = p[3][7], p[1][2] = p[2][7], p[3][7] = c, p[2][7] = d;
}
 
int main()
{
	int r;
	char *q;

	scanf("%s", q=s);
	while (*q) {
		if      (*q == 'U') uu();
		else if (*q == 'F') ff();
		else if (*q == 'R') rr();
		else if (*q == 'D') dd();
		else if (*q == 'B') bb();
		else                ll();
		q++;
	}
	for (r = 0; r < 6; r++) puts(p[r]);
	return 0;
}


Measured memory_bytes: 2100
#include <cstdio>
#include <iostream>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <cmath>
#include <queue>
using namespace std;
int a[200010];
int main(){
    int n,i,x;
    long long ans=0;
    scanf("%d",&n);
    for(i=1;i<=n;i++) scanf("%d",&a[i]),a[i]-=i;
    sort(a+1,a+n+1);
    x=a[n+1>>1];
    for(i=1;i<=n;i++) ans+=max(a[i]-x,x-a[i]);
    printf("%lld\n",ans);
    return 0;
}


Measured memory_bytes: 1024
#include<stdio.h>
int main()
{
    int m,mi;
    int a[40],b[40],c[40],d[40];
    char ac[40],bc[40],t;
    while(scanf("%d",&m)!=EOF)
    {
        int i,j,x;
        int r=1,flag=1;
        getchar();
        for(i=0; i<m; i++)
        {
            c[i]=i;
            d[i]=i;
            scanf("%c%d",&ac[i],&a[i]);
            getchar();
            b[i]=a[i];
            bc[i]=ac[i];
        }
        for(i=0; i<m; i++)
        {
            for(j=m-1; j>=i+1; j--)
                if(a[j]<a[j-1])
                {
                    x=a[j-1];
                    a[j-1]=a[j];
                    a[j]=x;
                    x=c[j-1];
                    c[j-1]=c[j];
                    c[j]=x;
                    t=ac[j-1];
                    ac[j-1]=ac[j];
                    ac[j]=t;
                }
        }
        for(i=0; i<m-1; i++)
        {
            printf("%c%d ",ac[i],a[i]);
            if(a[i]==a[i+1]&&c[i]>c[i+1])
                r=0;
        }
        printf("%c%d\n",ac[i],a[i]);
        if(flag)
            printf("Stable\n");
        else
            printf("Not stable\n");
        for(i=0; i<m; i++)
        {
            mi=i;
            for(j=i; j<m; j++)
                if(b[j]<b[mi])
                {
                    mi=j;
                }
            if(b[i]>b[mi])
            {
                x=b[i];
                b[i]=b[mi];
                b[mi]=x;
                x=d[i];
                d[i]=d[mi];
                d[mi]=x;
                t=bc[i];
                bc[i]=bc[mi];
                bc[mi]=t;
            }
        }
        for(i=0; i<m-1; i++)
        {
            printf("%c%d ",bc[i],b[i]);
            if(b[i]==b[i+1]&&d[i]>d[i+1])
                flag=0;
        }
        printf("%c%d\n",bc[i],b[i]);
        if(flag)
            printf("Stable\n");
        else
            printf("Not stable\n");
    }
}



Measured memory_bytes: 2052
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll,ll>pi;
const int MAXN=3*100005;
const int MOD=1000000007;
#define FOR(i,a,b) for(int i=(a);i<=(b);i++)
#define DEC(i,a,b) for(int i=(a);i>=(b);i--)
#define fst first
#define snd second
#define pb push_back
#define all(v) (v).begin(),(v).end()
#define sz(v) ((int)(v).size())
#define db(x) cerr<<#x<<" = "<<x<<"\n"
#define LOW(v,x) (lower_bound(all(v),(x))-(v).begin())

int N,M,S,T;
vector<int>adj[MAXN];
int dist[MAXN];
int bfs(int st){
	memset(dist,-1,sizeof dist);
	queue<int>q;
	q.push(st);
	dist[st]=0;
	while(sz(q)){
		int v=q.front();q.pop();
		for(auto i:adj[v]){
			if(dist[i]!=-1)continue;
			dist[i]=dist[v]+1;
			q.push(i);
		}
	}
	//~ cout<<dist[3*T]<<' '<<dist[3*T+1]<<' '<<dist[3*T+2]<<"\n";
	//~ return min({dist[3*T],dist[3*T+1],dist[3*T+2]});
	if(dist[3*T]==-1)return -1;
	else return dist[3*T]/3;
}
int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	
	cin>>N>>M;
	FOR(i,1,M){
		int a,b;cin>>a>>b;
		--a;--b;
		FOR(i,0,2){
			adj[3*a+i].pb(3*b+(i+1)%3);
		}
	}
	cin>>S>>T;
	--S;--T;
	cout<<bfs(3*S)<<"\n";
	//~ cout<<min({bfs(3*S),bfs(3*S+1),bfs(3*S+2)})<<"\n";
}
/*
*/


Measured memory_bytes: 17792
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(ll i=0;i<n;i++)
#define repl(i,l,r) for(ll i=(l);i<(r);i++)
#define per(i,n) for(ll i=n-1;i>=0;i--)
#define perl(i,r,l) for(ll i=r-1;i>=l;i--)
#define fi first
#define se second
#define pb push_back
#define ins insert
#define pqueue(x) priority_queue<x,vector<x>,greater<x>>
#define all(x) (x).begin(),(x).end()
#define CST(x) cout<<fixed<<setprecision(x)
#define rev(x) reverse(x);
using ll=long long;
using vl=vector<ll>;
using vvl=vector<vector<ll>>;
using pl=pair<ll,ll>;
using vpl=vector<pl>;
using vvpl=vector<vpl>;
const ll MOD=1000000007;
const ll MOD9=998244353;
const int inf=1e9+10;
const ll INF=4e18;
const ll dy[8]={1,0,-1,0,1,1,-1,-1};
const ll dx[8]={0,-1,0,1,1,-1,1,-1};
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;
}
int main(){
    ll n,m;cin >> n >>m;
    vl v(n);
    rep(i,m){
        ll a,b;cin >> a >> b;a--;b--;
        v[a]++;v[b]++;
    }
    bool ok=true;
    rep(i,n)if(v[i]%2)ok=false;
    cout << (ok? "YES":"NO") <<endl;
}

Measured memory_bytes: 4052
#include<bits/stdc++.h>
#define ll long long
#define all(v) v.begin(),v.end()
#define PB push_back
#define PI 3.1415926535897932384626433832795
#define what(x) cout<<#x<<" is "<<x<<endl;
using namespace std;


template <typename A, typename B>
string to_string(pair<A, B> p);

template <typename A, typename B, typename C>
string to_string(tuple<A, B, C> p);

template <typename A, typename B, typename C, typename D>
string to_string(tuple<A, B, C, D> p);

string to_string(const string& s) {
  return '"' + s + '"';
}

string to_string(const char* s) {
  return to_string((string) s);
}

string to_string(bool b) {
  return (b ? "true" : "false");
}

string to_string(vector<bool> v) {
  bool first = true;
  string res = "{";
  for (int i = 0; i < static_cast<int>(v.size()); i++) {
    if (!first) {
      res += ", ";
    }
    first = false;
    res += to_string(v[i]);
  }
  res += "}";
  return res;
}

template <size_t N>
string to_string(bitset<N> v) {
  string res = "";
  for (size_t i = 0; i < N; i++) {
    res += static_cast<char>('0' + v[i]);
  }
  return res;
}

template <typename A>
string to_string(A v) {
  bool first = true;
  string res = "{";
  for (const auto &x : v) {
    if (!first) {
      res += ", ";
    }
    first = false;
    res += to_string(x);
  }
  res += "}";
  return res;
}

template <typename A, typename B>
string to_string(pair<A, B> p) {
  return "(" + to_string(p.first) + ", " + to_string(p.second) + ")";
}

template <typename A, typename B, typename C>
string to_string(tuple<A, B, C> p) {
  return "(" + to_string(get<0>(p)) + ", " + to_string(get<1>(p)) + ", " + to_string(get<2>(p)) + ")";
}

template <typename A, typename B, typename C, typename D>
string to_string(tuple<A, B, C, D> p) {
  return "(" + to_string(get<0>(p)) + ", " + to_string(get<1>(p)) + ", " + to_string(get<2>(p)) + ", " + to_string(get<3>(p)) + ")";
}

void debug_out() { cerr << endl; }

template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
  cerr << " " << to_string(H);
  debug_out(T...);
}
#ifndef ONLINE_JUDGE
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#else
#define debug(...) 42
#endif

ll powmod(ll a,ll b,ll mod) {
    ll res=1;a%=mod;
    //assert(b>=0);
    for(;b;b>>=1){
        if(b&1)res=res*a%mod;a=a*a%mod;
    }
    return res;
}

void solve(){
	ll k;
	cin>>k;
	ll sum=7;
	for(int i=0;i<1e6;i++){
		if(sum%k==0){
			cout<<i+1<<endl;
			return;
		}
		sum=(sum*10+7)%k;
	}
	cout<<-1<<endl;
}


int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    int tc=1;
	#ifndef ONLINE_JUDGE
	freopen("input.txt","r",stdin);
	#endif
	// cin>>tc;
    while(tc--)solve();
}


Measured memory_bytes: 3616
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const ll INF = ll(1e12);
const ll mod = ll(1e9) + 1;
#define rep0(i,n) for(ll (i) = 0; (i) < (n); ++(i))
#define rrep0(i,n) for(ll (i) = (n) - 1; (i) >= 0; --(i))
#define rep1(i,n) for(ll (i) = 1; (i) <= (n); ++(i))
#define rrep1(i,n) for(ll (i) = (n); (i) >= 1; --(i))
#define nfor(i,a,b) for(ll (i) = (a); (i) < (b); ++(i))
#define pf(x) cout << (x) << endl
#define all(x) (x).begin(),(x).end()

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

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

ll factorial(ll n){
    ll t = 1;
    rep1(i, n){
        t *= i;
        t %= mod;
    }
    return t;
}

ll power(ll a, ll b){
    a %= mod;
    if(b == 0){
        return 1;
    }
    ll ans = power(a, b / 2);
    ans = ans * ans % mod;
    if(b % 2 == 1){
        ans = ans * a % mod;
    }
    return ans;
}

ll combination(ll a, ll b){
    if((a == b) || (b == 0)){
        return 1;
    }
    if(a < b) return 0;
    ll ans = 1;
    for(ll i = 0; i < b; i++) {
        ans *= (a - i);
        ans %= mod;
        ans *= power(i + 1, mod - 2);
        ans %= mod;
    }
    return ans;
}

bool c(string s){
    bool f = true;
    rep0(i, s.size() / 2)if(s[i] != s[s.size() - i - 1])f = false;
    return f;
}

int main(){
    double l;
    cin >> l;
    printf("%.12lf",l * l * l / (double)27);
    return 0;
}


Measured memory_bytes: 256
n = int(input())
f = [0] * (n + 1)
t = int(n ** .5) + 3
for i in range(1, t):
    for j in range(1, t):
        for k in range(1, t):
            res = i ** 2 + j ** 2 + k ** 2 + i * j + j * k + k * i
            if res <= n:
                f[res] += 1
print('\n'.join(map(str, f[1:])))


Measured memory_bytes: 68120
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#define MAX 100010
#define x first
#define y second

using namespace std;

int n,m,l,r,d,p[MAX],ac;
bool acc[MAX];
vector<pair<int,int>> v[MAX];
queue<int> q;

int main()
{
    cin>>n>>m;
    for(int i=1;i<=m;i++){
      cin>>l>>r>>d;
      v[l].push_back(make_pair(r,-d));
      v[r].push_back(make_pair(l,d));
    }
    for(int i=1;i<=n;i++){
      if(not acc[i]){
        q.push(i);acc[i]=true;p[i]=0;
        while(not q.empty()){
          ac=q.front();q.pop();
          for(auto j:v[ac]){
            if(not acc[j.x]){
              acc[j.x]=true;
              p[j.x]=p[ac]+j.y;
              q.push(j.x);
            } else if(p[j.x]!=p[ac]+j.y){
              cout<<"No";
              return 0;
            }
          }
        }
      }
    }
    cout<<"Yes";
    return 0;
}


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

int main(){
	int N;
	cin >> N;
	double p;
	int ans;
	bool pro =false;
	for(int i=1;i<50000;i++){
		p=1.08*i;
		if(floor(p)==N){
			pro=true;
			ans=i;
			break;
		}
		if(p>N+1){
			break;
		}
		
	}
	if(pro){
		cout<<ans<<endl;
	}
	else{
		cout<<":("<<endl;
	}
	


}






Measured memory_bytes: 256
[A, B, C] = [int(i) for i in input().split()]
K = int(input())


def cal():
    global A, B, C, K
    count = 0
    while A >= B:
        B *= 2
        count += 1
        if K < count:
            return "No"
    while B >= C:
        C *= 2
        count += 1
        if K < count:
            return "No"
    return "Yes"


print(cal())


Measured memory_bytes: 9192
#include <iostream>
#include <algorithm>
#include <string>
#include <cmath>
#include <ctype.h>
#include <map>
#include <vector>
#include <stdlib.h>
#include <stdio.h>
#include <cctype>
#include <queue>
#include <set>
#include <list>
#define PI 3.141592653
#define rep(i,a,n) for(int i=a;i<(int)n;++i)
#define SZ(x) ((int)(x).size())	//size() unsigned -> int
#define DescSort(a) sort(a.begin(),a.end(),std::greater<int>())

using namespace std;
typedef long long ll;
const ll INF=1e9+7;

int main(void) {
	int n;
	cin >> n;
	vector<int> p(n), q(n), perm(n);
	rep(i, 0, n) cin >> p[i];
	rep(i, 0, n) cin >> q[i];
	rep(i, 0, n) perm[i] = i + 1;
	map<vector<int>, int> mp;
	do {
		mp[perm] = mp.size();
	} while (next_permutation(perm.begin(), perm.end()));
	cout << abs(mp[p] - mp[q]) << endl;
	return 0;
}


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

#define rep(X,N) for(ll X = 0; X < (N); X++)
#define PI (acos(-1.0))
#define pback push_back
#define mpair make_pair
#define MODN 1000000007
#define ALL(V) (V).begin(),(V).end()
#define INT_MAX_HALF (INT_MAX / 2)
#define EPS (1e-10)

using namespace std;
typedef long long ll;

int main(){

    int n;
    cin >> n;

    vector<string> v(n);
    map<string, int> m;

    rep(i, n){
        cin >> v[i];
        m[v[i]]++;
    }

    bool suc = true;

    rep(i, n - 1){

        char end = v[i][v[i].size() - 1];
        char start = v[i + 1][0];

        //cerr << end << " " << start << endl;

        if(end != start){
            suc = false;
            break;
        }
    }

    if(suc && m.size() == n){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }

    return 0;
}


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

using Int = int;
using namespace std;

#define ARC(i, a, b) for(Int i = (a); i < (b); ++i)
#define RC(i, n) ARC(i, 0, n)
#define ARCH(i, a, b) for(Int i = (a) - 1; i >= (b); --i)
#define RCH(i, n) ARCH(i, n, 0)
template<class T> T ant(const T &a, const T &b){ return a > b ? a : b; };
template<class T> T ont(const T &a, const T &b){ return a < b ? a : b; };
template<class T> void th(T &a, const T &b, T (*f)(const T &, const T &)){ a = f(a, b); }
#define anth(a, b) th(a, b, ant)
#define onth(a, b) th(a, b, ont)

int main(){
	int a, b;
	cin >> a >> b;
	int ao, aa;
	ao = (a * 25 + 1) / 2;
	aa = (a * 25 + 24) / 2;
	anth(ao, b * 10);
	onth(aa, b * 10 + 9);
	if(ao <= aa){
		cout << ao << endl;
	}else{
		cout << -1 << 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 ll long long

int main(){
  vector<vector<int>> A(3, vector<int>(3));
  rep(i, 3){
    rep(j, 3){
      cin >> A.at(i).at(j);
    }
  }
  
  int N; 
  cin >> N;
  rep(i, N){
    int b;
    cin >> b;
    rep(i, 3){
      rep(j, 3){
      if (A.at(i).at(j) == b) A.at(i).at(j) = 0;
      if (A.at(i).at(j) == b) A.at(i).at(j) = 0;
      if (A.at(i).at(j) == b) A.at(i).at(j) = 0;
      }
    }
  }
  
  bool judge = 0;
  
  rep(i, 3){
      if (A.at(i).at(0) == 0 && A.at(i).at(1) == 0 && A.at(i).at(2) == 0) judge = 1;
      else if (A.at(0).at(i) == 0 && A.at(1).at(i) == 0 && A.at(2).at(i) == 0) judge = 1;
      else if (A.at(0).at(0) == 0 && A.at(1).at(1) == 0 && A.at(2).at(2) == 0) judge = 1;
      else if (A.at(0).at(2) == 0 && A.at(1).at(1) == 0 && A.at(2).at(0) == 0) judge = 1;
  }
  
  if (judge == 1) {
    cout << "Yes" << endl;
  }
  else if (judge == 0){
    cout << "No" << endl;
  }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int a, b;
  cin >> a >> b;

  int cakes = abs(a - b);
  int margin = 16 - (a + b);

  if (cakes <= margin) {
    cout << "Yay!" << endl;
  }else {
    cout << ":(" << endl;
  }
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef  long long ll;
using vll=vector<ll>;
using vvll=vector<vll>;
using vi=vector<int>;
using vvi=vector<vector<int>>;
using vb=vector<bool>;
using pii=pair<int,int>;
using vpii=vector<pair<int,int>>;

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;}

//pow(llpow,modpow)
template<class T> ll llpow(ll x,T n){ll ans=1;if(x==0)ans=0;while(n){if(n&1)ans*=x;x*=x;n>>=1;}return ans;}
long long modpow(long long a, long long n, long long mod) {long long res = 1;while (n > 0) {if (n & 1) res = res * a % mod;a = a * a % mod;n >>= 1;}return res;}
//最大公約数
template<class T> inline T gcd(T x,T y){if(y==0)return x; else {return gcd(y,x%y);}}
//最小公倍数
template<class T> inline T lcm(T x,T y){return x/gcd(x,y)*y;}
//逆元
long long modinv(long long a, long long m) {long long b = m, u = 1, v = 0;while (b) {long long t = a / b;a -= t * b; swap(a, b);u -= t * v; swap(u, v);}u %= m;if (u < 0) u += m;return u;}

#define rep(i, begin_i, end_i) for (ll i = (ll)begin_i; i < (ll)end_i; i++)
//試験導入
#define irep(i, end_i, begin_i) for (ll i = (ll)begin_i-1; i >= (ll)end_i; i--)

template<class T> inline T C(T x,T y){
    if(x<y)return 0;
    T div=min(x-y,y);
    T v=max(x-y,y);
    ll bunbo=1,bunshi=1;
    irep(i,x-div+1,x+1){
        bunshi*=i;
    }
    rep(j,1,div+1){
        bunbo*=j;
    }
    return bunshi/bunbo;
}
template<class T> inline T modC(T x,T y,ll mod){
    if(x<y)return 0;
    T div=min(x-y,y);
    ll bunbo=1,bunshi=1;
    irep(i,x-div+1,x+1){
        bunshi*=i;
        bunshi%=mod;
        if(bunshi<0)bunshi+=mod;
    }
    rep(j,1,div+1){
        bunbo*=j;
        bunbo%=mod;
        if(bunbo<0)bunbo+=mod;
    }
    T ans=bunshi*modinv(bunbo,mod)%mod;
    if(ans<0)ans+=mod;
    return ans;
}
long long INF = 1LL<<60;
int main( ){
    ll N,K;
    cin>>N>>K;
    ll mod=1e9+7;
    vll gcdres(K+1,0);
    irep(i,1,K+1){
        ll quem=K/i;
        gcdres[i]=modpow(quem,N,mod)%mod;
        if(gcdres[i]<0)gcdres[i]+=mod;
        if(quem>=2){
            rep(j,2,quem+1){
                gcdres[i]-=gcdres[i*j];
                gcdres[i]%=mod;
                if(gcdres[i]<0)gcdres[i]+=mod;
            }
        }
    }
    ll ans=0;
    rep(i,1,K+1){
        ans+=gcdres[i]*i%mod;
        ans%=mod;
        if(ans<0)ans+=mod;
    }
    cout<<ans<<endl;
    return 0;
}




Measured memory_bytes: 4048
#include<iostream>

using namespace std;

int main() {
	int N;
	int x=0;
	int max = 0;
	string S;

	//入力
	cin >> N;
	cin >> S;

	for (int i = 0; i < N; i++) {
		if (S[i] == 'I') {
			x++;
		}
		else if (S[i]=='D') {
			x--;
		}
		//最大値をとったとき
		if (max < x) {
			max = x;
		}
	}

	//出力
	cout << max << endl;

}

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

#define rep(i,n) for(int i=0;i<(int)n;i++)
#define all(c) (c).begin(),(c).end()
#define mp make_pair
#define pb push_back
#define each(i,c) for(__typeof((c).begin()) i=(c).begin();i!=(c).end();i++)
#define dbg(x) cerr<<__LINE__<<": "<<#x<<" = "<<(x)<<endl

using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef pair<int,int> pi;
const int inf = (int)1e9;
const double INF = 1e12, EPS = 1e-9;

int n, m, a, b, c;
bool can[101][50][50];
int dp[50];

int main(){
	cin >> n >> m >> a >> b >> c;
	rep(i, m){
		int x, y; cin >> x >> y; x--; y--;
		can[0][x][y] = 1;
	}
	rep(it, 100) rep(k, n) rep(i, n) rep(j, n){
		if(can[it][i][k] && can[0][k][j]) can[it + 1][i][j] = 1;
	}
	
	rep(it, 101){
		rep(i, n - 1){
			int x = inf, y = inf, z = inf;
			rep(j, n){
				if(can[a - 1][i][j]) x = min(x, dp[j] + 1);
				if(can[b - 1][i][j]) y = min(y, dp[j] + 1);
				if(can[c - 1][i][j]) z = min(z, dp[j] + 1);
			}
			dp[i] = max({dp[i], x, y, z});
		}
	}
	if(dp[0] >= n) cout << "IMPOSSIBLE" << endl; 
	else cout << dp[0] << endl;
	
	return 0;
}

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

using namespace std;

int GCD(int a, int b){
	if(a < b){
		swap(a, b);
	}
	while(b){
		a %= b;
		swap(a, b);
	}
	return a;
}

int LCM(int a, int b){
	return a / GCD(a, b) * b;
}

int main(){
	int a, b;
	while(cin >> a >> b){
		cout << GCD(a, b) << ' ' << LCM(a, b) << endl;
	}
	return 0;
}

Measured memory_bytes: 1160
//  cout << char(i+48) << endl;//なぜかaは47と得る時がある。+48で出力もaにできる。
//  cout << char(97) << endl;//アスキーコードでaを出力
// sort(b.begin(), b.end());//bという配列を小さい方からソート
// reverse(b.begin(), b.end());//bという配列をリターン
// 10桁でdouble出力するパターン１ 
// printf("%.10f\n", ma);
// 10桁でdouble出力するパターン２
//cout << fixed << setprecision(10);
//  cout << ma << endl;

/*01 02 03 12 13 23　と６回見ていくパターン 
for(int i=0;i<n-1;i++){
  for(int j=i+1;j<n;j++){
    }
  }
*///vector<vector<int>> data(3, vector<int>(4));//int型の2次元配列(3×4要素の)の宣言
//int64_t a;
//10のi乗pow(10, i);
/*string s; stringでの文字列を数字型に変える方法
  cin >> s;
  rep(i,s.size()-2) {
  int a= (s.at(i)-'0')*100 + (s.at(i+1)-'0')*10+ s.at(i+2) -'0';
    */
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
int main() {
  int n,k;
  cin >> n >> k;
  vector<int>a(n);
  vector<int>b(200010);
  rep(i,n)cin >> a.at(i);
  rep(i,n) b.at(a.at(i))++;
  sort(b.begin(), b.end());//bという配列を小さい方からソート
  reverse(b.begin(), b.end());//bという配列をリターン
  int i =0;
  int count = 0;
  for(;;){
   if(i == k)break;
    count += b.at(i);
//    cout << b.at(i) <<endl;
    i++;
  }
  cout << n - count << endl;
}

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

using namespace std;
using ll = long long;

#define INF (1LL << 60)
#define MOD 1000000007

#define REP(i,m,n) for(ll (i)=(m),i##_len=(n);(i)<(i##_len);++(i))
#define FORR(i,v) for(auto (i):v)
#define ALL(x) (x).begin(), (x).end()
#define _PR(x) cout << (x) << endl
#define _PS(x) cout << (x) << " "
#define SZ(x) ((int)(x).size())
#define MAX(a,b) (((a)>(b))?(a):(b))
#define MIN(a,b) (((a)<(b))?(a):(b))
#define pb push_back



int main()
{
    ll N;
    cin >> N;
    vector<ll> C(N);
    REP(i,0,N) cin >> C[i];    

    ll ans = 0;
    sort(ALL(C), greater<ll>());
    REP(i,0,N) ans = (ans + (i + 2) * (C[i] % MOD)) % MOD;
    REP(i,0,N-1) ans = ans * 4 % MOD;
    _PR(ans);

    return 0;
}

/*

    001010
    100111

    001010 -> 101010 -> 100010 -> 100110 -> 100111
    p1, p2, ..., pk
    k * C_p1 + (k-1) * C_p2 + ... + 1 * C_pk


*/

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

static const int dx[4] = {0, 1, 0, -1};
static const int dy[4] = {1, 0, -1, 0};
static const char dir[4] = {'u', 'r', 'd', 'l'};
static const ll INF = 1ll << 60;
static const ll MOD = 1e9 + 7;
int N, M;
signed main() {
  cin >> N >> M;
  if (N <= M) {
    puts("Yes");
  } else {
    puts("No");
  }
  return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
 
#define INIT_CAP 10
#define INF 1000000000
 
inline int nextInt(void) {
    int ch;
    int sign, x;
 
    do {
        ch = getchar();
    } while (ch < '-');
 
    if (ch == '-') {
        sign = -1;
        ch = getchar();
    } else
        sign = 1;
 
    x = 0;
    while (ch >= '0' && ch <= '9') {
        x = x * 10 + ch - '0';
        ch = getchar();
    }
 
    return sign * x;
}
 
inline void printInt(int x) {
    char ch[10];
    int cnt;
 
    if (x < 0) {
        putchar('-');
        x = -x;
    }
 
    cnt = 0;
    do {
        ch[cnt++] = '0' + x % 10;
        x /= 10;
    } while (x);
 
    while (cnt--)
        putchar(ch[cnt]);
}
 
typedef struct {
    int to, w;
} Edge;
 
typedef struct {
    Edge *elem;
    int cap, size;
} VecEdge;
 
typedef struct {
    int num, d;
} PNumDis;
 
VecEdge adj[10000];
PNumDis heap[500000];
int hsize;
int d[10000];
 
void init(int n) {
    while (n--)
        adj[n] = (VecEdge){malloc(sizeof(Edge) * INIT_CAP), INIT_CAP, 0};
}
 
inline void add(int from, int to, int w) {
    if (adj[from].size == adj[from].cap) {
        adj[from].cap <<= 1;
        adj[from].elem = realloc(adj[from].elem, sizeof(Edge) * adj[from].cap);
    }
    adj[from].elem[adj[from].size++] = (Edge){to, w};
}
 
inline void insert(int num, int d) {
    int i;
    for (i = hsize++; i > 0 && d < heap[i - 1 >> 1].d; i = i - 1 >> 1)
        heap[i] = heap[i - 1 >> 1];
    heap[i] = (PNumDis){num, d};
}
 
inline int calcNextIdx(int i) {
    return i * 2 + 1 + (i * 2 + 2 < hsize && heap[i * 2 + 1].d > heap[i * 2 + 2].d);
}
 
inline PNumDis delete(void) {
    int i;
    int nextIdx;
    const PNumDis root = heap[0], last = heap[--hsize];
 
    for (i = 0; i * 2 + 1 < hsize && last.d > heap[nextIdx = calcNextIdx(i)].d; i = nextIdx)
        heap[i] = heap[nextIdx];
    heap[i] = last;
 
    return root;
}
 
void dijkstra(int n, int s) {
    int i;
 
    for (i = 0; i < n; i++)
        d[i] = INF;
 
    d[s] = 0;
    insert(s, 0);
    while (hsize > 0) {
        const PNumDis fromP = delete();
 
        if (fromP.d > d[fromP.num])
            continue;
 
        for (i = 0; i < adj[fromP.num].size; i++) {
            const Edge e = adj[fromP.num].elem[i];
            if (fromP.d + e.w < d[e.to]) {
                d[e.to] = fromP.d + e.w;
                insert(e.to, d[e.to]);
            }
        }
    }
}
 
int main(void) {
    int i;
    int n;
 
    scanf("%d", &n);
 
    init(n);
    for (i = 0; i < n; i++) {
        int u = nextInt(), k = nextInt();
        while (k--) {
            int v = nextInt(), c = nextInt();
            add(u, v, c);
        }
    }
 
    dijkstra(n, 0);
 
    for (i = 0; i < n; i++) {
        printInt(i);
        putchar(' ');
        printInt(d[i]);
        putchar('\n');
    }
 
    return 0;
}

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

const ll MOD = 1e9+7;
const ll INF = 1e18+7;

signed main(){
	int h, w;
	cin >> h >> w;
	vector<int> a(h), b(w);
	for(auto& x : a)
		cin >> x;
	for(auto& x : b)
		cin >> x;

	vector<int> t = {h + 1, w + 1};
	vector<pair<int,int>> p;
	for(int i = 0; i < h; ++i)
		p.emplace_back(a[i], 0);
	for(int i = 0; i < w; ++i)
		p.emplace_back(b[i], 1);
	sort(p.begin(), p.end());

	ll ans = 0;

	for(auto& q : p){
		int x, y;
		tie(x, y) = q;
		ans += 1LL * t[!y] * x;
		--t[y];
	}
	cout << ans << endl;
}


Measured memory_bytes: 3188
#include <cstdlib>
#include <cstring>
#include <iostream>
#include <string>
#include <vector>
using namespace std;

int w, h;
bool visited[20][20];
vector<string> field;
const int dx[4] = {0, 0, 1, -1};
const int dy[4] = {1, -1, 0, 0};

int dfs(const int x, const int y) {
	visited[y][x] = true;
	int res = 1;
	for(int i = 0; i < 4; ++i) {
		const int nx = x + dx[i], ny = y + dy[i];

		if(nx < 0 || ny < 0 || nx >= w || ny >= h)
			continue;

		if(!visited[ny][nx] && field[ny][nx] != '#')
			res += dfs(nx, ny);
	}

	return res;
}

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

	while(cin >> w >> h, w) {
		field.clear();
		field.resize(h);
		for(int i = 0; i < h; ++i)
			cin >> field[i];

		int sx, sy;
		for(int i = 0; i < h; ++i)
			for(int j = 0; j < w; ++j)
				if(field[i][j] == '@')
					sx = j, sy = i;

		memset(visited, false, sizeof(visited));
		cout << dfs(sx, sy) << endl;
	}

	return EXIT_SUCCESS;
}

Measured memory_bytes: 1232
#include <iostream>
#include <stdio.h>

using namespace std;


int main() {
  int A, B;

  scanf("%d", &A);
  scanf("%d", &B);

  if(A > 8 || B > 8){
    printf(":(");
  }else{
    printf("Yay!");
  }

  return 0;
}


Measured memory_bytes: 256
n, m, p = map(int, input().split())
a = [list(map(int, input().split())) for i in range(n)]
b = [list(map(int, input().split())) for i in range(m)]
c = [[0] * p for i in range(n)]

for i in range(n):
    for j in range(p):
        for k in range(m):
            c[i][j] += a[i][k] * b[k][j]

for i in range(n):
    for j in range(p):
        if j != p - 1:
            print((c[i][j]), end=" ")
        else:
            print((c[i][j]), end="")
    print("")



Measured memory_bytes: 7048
#include <iostream>
#include <sstream>
#include <algorithm>
#include <string>
#include <vector>
#include <stack>
#include <set>
#include <queue>
#include <map>
#include <numeric>
#include <functional>
#include <math.h>

using namespace std;

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

#define INF ((int)1e9)
#define INFLL ((ll)1e18)
#define MOD (1000000007LL)


int main(int argc, const char * argv[]) {
    ios_base::sync_with_stdio(false);
    ll A, B, N;
    cin >> A >> B >> N;
    
    ll x = 0;
    if (N < B) {
        x = N;
    } else {
        x = B-1;
    }
    cout << A*x/B - A*(x/B) << endl;

    return 0;
}


Measured memory_bytes: 3648
# import bisect
# from collections import Counter, deque
# import copy
# from heapq import heappush, heappop, heapify
# from fractions import gcd
# import itertools
# from operator import attrgetter, itemgetter
# import math

import sys

# import numpy as np

ipti = sys.stdin.readline
MOD = 10 ** 9 + 7
INF = float('INF')
sys.setrecursionlimit(10 ** 5)

def main():
    l = input()
    l_len = len(l)

    if l == "1":
        print(3)
        sys.exit()

    #n-1桁まで
    a1 = pow(3 ,l_len-1, MOD)

    #1桁目を1で固定

    a2 = 0
    count = 1

    for i in range(1, l_len-1):
        if l[i] == "1":
            temp1 = pow(2,count,MOD)
            temp2 = pow(3,(l_len-i)-1,MOD)
            a2 += temp1 * temp2
            a2 %= MOD
            count += 1

    if l_len > 1:
        temp1 = pow(2,count,MOD)
        a2 += temp1
        a2 = a2 % MOD
        if l[-1] == "1":
            temp1 *= 2
            temp1 %= MOD
            a2 += temp1
            a2 %= MOD

    ans = (a1+a2) % MOD

    print(ans)

if __name__ == '__main__':
    main()


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

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

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

    int a, b;
    cin >> a >> b;
    int ans = (a * b) / gcd(a, b);
    cout << ans << endl;
}


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

class Cube{
public:
  int f[6]; //??????????????°???
  Cube(){} //?????????????????????
  void roll_z(){ roll(1, 2, 4, 3);} //????????????????????§??????????????????????????°???????????¨????????????
  void roll_y(){ roll(0, 2, 5, 3);}
  void roll_x(){ roll(0, 1, 5, 4);}
  void roll(int i, int j, int k, int l){
    int t = f[i]; f[i] = f[j]; f[j] = f[k]; f[k] = f[l]; f[l] = t;
  }
};

//getRight??¢??°?????????????????¢??°??§????????????

  string cmp( Cube c1, Cube c2){
    for (int i = 0; i < 6; i++) {
      for (int j = 0; j < 4; j++) {
        if ( c1.f[0] == c2.f[0] && c1.f[1] == c2.f[1] && c1.f[2] == c2.f[2] &&
           c1.f[3] == c2.f[3] && c1.f[4] == c2.f[4] && c1.f[5] == c2.f[5]) return "Yes";
        c1.roll_z();
      }
      if (i % 2 == 0) c1.roll_y();
      else c1.roll_x();
      /*i?????¶?\?????????????x, y??????????????¢???????????°?????¨????????°??????????????¢????????????????????¶?????§z??????????????¢???????????????????????????????????????????????????*/
    }
    return "No";
  }



int main(){
  Cube c1, c2;

  for ( int i = 0; i < 6; i++) cin >> c1.f[i];
  for ( int i = 0; i < 6; i++) cin >> c2.f[i];

  cout << cmp(c1, c2) << endl;


return 0;
}

Measured memory_bytes: 3204
#include<stdio.h>
int main(void){
int n,m;
  scanf("%d%d",&n,&m);
  int k[m],s[m][n];
  for(int i=0;i<m;i++){
	scanf("%d",&k[i]);
    for(int j=0;j<k[i];j++){
      scanf("%d",&s[i][j]);
    }
  }
  int p[m],pattern[n],oncount[m],ok,c=0,ans=0;
  for(int i=0;i<m;i++){
    	scanf("%d",&p[i]);
    oncount[i]=0;
  }
for(int i=0;i<(1<<n);i++){
  ok=0;
  c=0;
  //printf("%dパターン目\n",i);
  for(int l=0;l<n;l++){
    pattern[l]=0;
  }
    
	for(int j=0;j<n;j++){
	if(i&(1<<j)){
pattern[c++]=j+1;		//onのスイッチを格納
 // printf("%dがon ",j+1);
    }
    }
//printf("\n");
  for(int l=0;l<c;l++){
    for(int q=0;q<m;q++){
      for(int r=0;r<k[q];r++){
        if(s[q][r]==pattern[l])oncount[q]++;
      }
    }
  }
  
 	for(int q=0;q<m;q++){
    //  printf("%dこめの電球は%dこスイッチがon\n",q+1,
           //  oncount[q]);
    if(oncount[q]%2==p[q])ok++;  
      oncount[q]=0;
    }
  	
	if(ok==m){
    //  printf("条件をクリア\n");
      ans++;
             }
  }
  printf("%d",ans);
  return 0;
}
  

Measured memory_bytes: 128
#include<bits/stdc++.h>
#define ll long long

using namespace std;

int main()
{
  ll a, b, c;
  cin >> a >> b >> c;
  ll ans_a = 0, ans_b = 0;
  ll tem = c - a;
  if(tem <= 0)
  {
    cout << abs(tem) << " " << b << '\n';
  }
  else
  {
    c = (b - (c - a));
    if(c < 0)
     c = 0;
    cout << "0 " << c << '\n';
  }
return 0;
}



Measured memory_bytes: 256
fn main() {
    let (r, w) = (std::io::stdin(), std::io::stdout());
    let mut sc = IO::new(r.lock(), w.lock());

    let k: usize = sc.read();
    let x: usize = sc.read();
    if k * 500 >= x {
        println!("Yes");
    } else {
        println!("No");
    }
}

pub struct IO<R, W: std::io::Write>(R, std::io::BufWriter<W>);

impl<R: std::io::Read, W: std::io::Write> IO<R, W> {
    pub fn new(r: R, w: W) -> IO<R, W> {
        IO(r, std::io::BufWriter::new(w))
    }
    pub fn write<S: std::ops::Deref<Target = str>>(&mut self, s: S) {
        use std::io::Write;
        self.1.write(s.as_bytes()).unwrap();
    }
    pub fn read<T: std::str::FromStr>(&mut self) -> T {
        use std::io::Read;
        let buf = self
            .0
            .by_ref()
            .bytes()
            .map(|b| b.unwrap())
            .skip_while(|&b| b == b' ' || b == b'\n' || b == b'\r' || b == b'\t')
            .take_while(|&b| b != b' ' && b != b'\n' && b != b'\r' && b != b'\t')
            .collect::<Vec<_>>();
        unsafe { std::str::from_utf8_unchecked(&buf) }
            .parse()
            .ok()
            .expect("Parse error.")
    }
    pub fn vec<T: std::str::FromStr>(&mut self, n: usize) -> Vec<T> {
        (0..n).map(|_| self.read()).collect()
    }
    pub fn chars(&mut self) -> Vec<char> {
        self.read::<String>().chars().collect()
    }
}


Measured memory_bytes: 4352
#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 ALL(v) (v).begin(),(v).end()
#define fi first
#define se second
template<typename A, typename B> inline bool chmax(A &a, B b) { if (a<b) { a=b; return 1; } return 0; }
template<typename A, typename B> inline bool chmin(A &a, B b) { if (a>b) { a=b; return 1; } return 0; }
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<int, pii> pip;
const ll INF = 1ll<<29;
const ll MOD = 1000000007;
const double EPS = 1e-10;
const bool debug = 0;
//------------------------------//

int main() {
	string s, ans;
	cin >> s;
	REP(i, s.size()) if (i % 2 == 0) ans += s[i];
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 512
N = int(input());
#prime number
P = [0]*N;
#divisor
D = 1;
if N>=2:
    for i in range(2,N+1):
        for j in range(2,i+1):
            while i%j ==0:
                P[j-1] = P[j-1]+1;
                i = i/j
for i in range(N):
    D = D*(P[i]+1)
print(D%1000000007);

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

using namespace std;

const int kN = 1e1+7;

string str, last, now;
int res;

int main()
{
    cin >> str;
    res = 1;
    last = str[0];
    for (int i = 1; i < str.length(); ++i) {
        now += str[i];
        if (now == last) continue;
        else {
            last = now;
            now = "";
            ++res;
        }
    }
    cout << res << endl;
    return 0;
}


Measured memory_bytes: 640
#include <iostream>
#include <algorithm>
#include <stdio.h>

using namespace std;

int main(){
	int ary[100];
	int hikaku[100];
	int n;
	int a = 0;
	
	for(int i = 1; i <= 100; i++){
		ary[i] = i;
		hikaku[i] = 0;
	}
//scanf("%d",&n) != EOF

	while(cin >> n){

		for(int i = 1; i <= 100; i++){

			if(ary[i] == n){
				hikaku[i]++;
				a = max(a,hikaku[i]);
			}
		}

	}

	for(int i = 1; i <= 100; i++){
		
		if(a == hikaku[i]){
			cout << i << endl;
		}
	}

	return 0;
}

Measured memory_bytes: 1160
#include<cstdio>
#include<cstdlib>
#include<cmath>
#include<climits>
#include<algorithm>
#include<sstream>
#include<iostream>
#include<string>
#include<vector>
#include<queue>
#include<stack>
#include<unordered_set>
#include<unordered_map>
#include<set>
#include<map>
#include<list>

using namespace std;

#define in(s) cin >> s
#define out(s) cout << s << endl
#define rep(i,n) for(int i=0; i<n; i++)
#define rept(i,a,b) for(int i=a; i<b; i++)
#define ll long long
#define MOD 1000000007

#define IMIN INT_MIN;
#define IMAX INT_MAX;


bool checklun(ll val) {
    ll prev = val % 10;
    while (val >= 10) {
        val /= 10;
        if (abs( val % 10 - prev ) > 1) return false;
        prev = val % 10;
    }
    return true;
}

ll nextlun(ll val) {
    if (checklun(val+1)) return val+1;
    for (int i=1; i<10; i++) {
        val /= 10;
        val++;
        ll tmp = val % 10;
        if (checklun(val)) {
            rep(j, i) {
                val *= 10;
                tmp = max(tmp-1, 0LL);
                val += tmp;
            }
            return val;
        }
        else val--;
    }
    return val;
}

int main(){
    ll k;
    in(k);
    vector<ll> dp(100001, 0);
    rep(i, 10) dp[i] = i;
    rept(i, 10, 100001) {
        //out(i << ' ' << nextlun(dp[i-1]));
        dp[i] = nextlun(dp[i-1]);
    }
    //rept(i, 1, k) cout << dp[i] << ' '; cout << endl;
    out(dp[k]);

	return 0;
}


Measured memory_bytes: 1024
#include <iostream>
#include <vector>

#define REP(_i,_len) for(int _i=0;_i<_len;++_i)
#define REP2(_i,_len,N) for(int _i=0,_len=N;_i<_len;++_i)
#define VREP(v,_itr,_end) for(auto _itr=v.begin(),_end=v.end();_itr!=_end;++_itr)
#define VCREP(v,_itr,_end) for(auto _itr=v.cbegin(),_end=v.cend();_itr!=_end;++_itr)

using namespace std;

typedef vector<int> vi;
typedef vector<vi > vvi;
typedef long long ll;
typedef vector<ll> vll;
typedef vector<vll > vvll;

int main(int argc, const char * argv[]) {
    int N,W;
    cin>>N>>W;
    
    vi w(N),v(N);
    REP(i,N){
        cin>>w[i]>>v[i];
    }
    
    vvll dps(N);
    REP(i,N){
        dps[i].resize(W+1);
        REP(j,W+1){
            if(i==0){
                if(w[0]<=j){
                    dps[0][j]=v[0];
                }else{
                    dps[0][j]=0;
                }
                continue;
            }
            if(w[i]<=j){
                dps[i][j]=max(dps[i-1][j-w[i]]+v[i],dps[i-1][j]);
            }else{
                dps[i][j]=dps[i-1][j];
            }
        }
    }
    cout<<dps[N-1][W]<<endl;
    
    
    return 0;
}

Measured memory_bytes: 81208
using System;
using System.Text;
using System.Linq;
using System.Collections;
using System.Collections.Generic;
using static System.Console;
using static System.Math;

class Program{
    public static void Main(){
        int N = int.Parse(ReadLine());
        if(N >= 1000){
            WriteLine("ABD");
        }
        else{
            WriteLine("ABC");
        }
    } 
}

Measured memory_bytes: 13140
///   ***   ---   |||		 In the name of ALLAH		|||   ---   ***   ///



#include<bits/stdc++.h>
using namespace std;


typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vi> vvi;
typedef vector<vl> vvl;
typedef pair<int,int> pii;
typedef pair<double, double> pdd;
typedef pair<ll, ll> pll;
typedef vector<pii> vii;
typedef vector<pll> vll;
typedef double dl;

#define endl '\n'
#define PB push_back
#define F first
#define S second
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define sz(x) (int)x.size()

const double PI = acos(-1);
const double eps = 1e-9;
const int inf = 2000000000;
const ll infLL = 9000000000000000000;
#define MOD 1000000007

#define mem(a,b) memset(a, b, sizeof(a) )
#define sqr(a) ((a) * (a))

#define optimize() ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define fraction() cout.unsetf(ios::floatfield); cout.precision(10); cout.setf(ios::fixed,ios::floatfield);
#define file() freopen("input.txt","r",stdin);freopen("output.txt","w",stdout);
//
//debug
template<typename F,typename S>ostream&operator<<(ostream&os,const pair<F,S>&p){return os<<"("<<p.first<<", "<<p.second<<")";}
template<typename T>ostream&operator<<(ostream&os,const vector<T>&v){os<<"{";for(auto it=v.begin();it!=v.end();++it){if(it!=v.begin())os<<", ";os<<*it;}return os<<"}";}
template<typename T>ostream&operator<<(ostream&os,const set<T>&v){os<<"[";for(auto it=v.begin();it!=v.end();++it){if(it!=v.begin())os<<",";os<<*it;}return os<<"]";}
template<typename T>ostream&operator<<(ostream&os,const multiset<T>&v) {os<<"[";for(auto it=v.begin();it!=v.end();++it){if(it!=v.begin())os<<", ";os<<*it;}return os<<"]";}
template<typename F,typename S>ostream&operator<<(ostream&os,const map<F,S>&v){os<<"[";for(auto it=v.begin();it!=v.end();++it){if(it!=v.begin())os<<", ";os<<it->first<<" = "<<it->second;}return os<<"]";}
#define dbg(args...) do {cerr << #args << " : "; faltu(args); } while(0)
void faltu(){cerr << endl;}
template<typename T>void faltu(T a[],int n){for(int i=0;i<n;++i)cerr<<a[i]<<' ';cerr<<endl;}
template<typename T,typename...hello>void faltu(T arg,const hello&...rest){cerr<<arg<<' ';faltu(rest...);}
//#else
//#define dbg(args...)
 
ll gcd ( ll a, ll b ) { return __gcd ( a, b ); }
ll lcm ( ll a, ll b ) { return a * ( b / gcd ( a, b ) ); }


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

int main()
{
	optimize();

    int n;
    cin >> n;
    vi l(n);
    for ( int i = 0; i < n; i++ ) cin >> l[i];

    int ans = 0;
    for ( int i = 0; i < n; i++ ) {
        for ( int j = i + 1; j < n; j++ ) {
            for ( int k = j + 1; k < n; k++ ) {
                if ( l[i] != l[j] && l[i] != l[k] && l[j] != l[k] ) {
                    if ( l[i] + l[j] > l[k] && l[i] + l[k] > l[j] && l[k] + l[j] > l[i] ) {
                        ans++;
                    }
                }
            }
        }
    }

    cout << ans << endl;

	return 0;
}


















Measured memory_bytes: 3664
#include<iostream>
#include<cstring>
#include<cstdio>
#include<cstdlib>
#include<map>
#include<ctime>
#include<algorithm>
#include<cmath>
#include<queue>
#include<set>
#include<stack>
#include<vector>
#include<bitset>
#define ll long long 
#define ull unsigned long long 
#define mem(a) memset(a,0,sizeof(a))
#define rint register int 
#define rll register long long 
#define rull register unsigned long long 
#define rchar register char
#define rstring register string 
#define rfloat register float
#define rdouble register double 
#define fio ios::sync_with_stdio(false),cin.tie(0),cout.tie(0)
#define For(i,a,b) for(int i=(a);i<(b);i++)
#define FOR(i,a,b) for(int i=(a);i<=(b);i++)
#define cFor(i,a,b) for(int i=(a);i>(b);i--)
#define cFOR(i,a,b) for(int i=(a);i>=(b);i--)
#define lFor(i,a,b) for(ll i=(a);i<(b);i++)
#define lFOR(i,a,b) for(ll i=(a);i<=(b);i++)
#define lcFor(i,a,b) for(ll i=(a);i>(b);i--)
#define lcFOR(i,a,b) for(ll i=(a);i>=(b);i--)
#define watch(a) cout<<#a<<"="<<a<<endl
#define mkp(a,b) make_pair(a,b)
#define inthis cout<<"--------this\n"
#define pr pair
#define iset(a) set<a>::iterator 
#define imap(a,b) map<a,b>::iterator 
#define vec vector
#define fi first
#define se second
#define _For(i,a,b) for(i=a;i<b;i++)
#define _FOR(i,a,b) for(i=a;i<=b;i++)
#define _cFor(i,a,b) for(i=a;i>b;i--)
#define _cFOR(i,a,b) for(i=a;i>=b;i--)
#define _vec vector<int>
#define __vec vector<vector<int>>
#define pb push_back
#define mp map
#define ins insert
#define era erase
#define fin find
#define EXIT exit(0)
#define all(a) a.begin(),a.end()
using namespace std;
mp<string,int> cnt;
int main(){
	//fio;
	int n;
	cin>>n;
	For(i,0,n){
		string x;
		cin>>x;
		if(cnt.fin(x)==cnt.end())
			cnt.ins(mkp(x,1));
		else
			cnt.fin(x)->se+=1;	
	}
	int mx=-1;
	vec<string> ans;
	for(mp<string,int>::iterator i=cnt.begin();i!=cnt.end();i++)
		mx=max(mx,i->se);
	for(mp<string,int>::iterator i=cnt.begin();i!=cnt.end();i++)
		if(mx==i->se)
			ans.pb(i->fi);
	For(i,0,ans.size())
		cout<<ans[i]<<endl;
}

Measured memory_bytes: 26868
#include <cstring>
#include <sstream>
#include <cstdio>
#include <algorithm>
#include <iostream>
#include <vector>
#include <map>
#include <unordered_map>
#include <cmath>
#include <queue>
#include <set>
#include <stack>
#include <numeric>

using namespace std;
typedef long long ll;
#define rep(i, n) for(ll i = 0; i < (ll)(n); i++)
#define repr(i, n) for(ll i = n - 1; i >= 0; i--)
#define repone(i, n) for(ll i = 1; i <= (ll)(n); i++)
#define each(i, mp) for(auto i:mp)
const int dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};
const ll mod = 1000000007;
const ll inf = ll(1e9);
const ll half_inf = ll(1e5);
const ll ll_inf = ll(1e9) * ll(1e9);
typedef unordered_map<ll, ll> ump;
typedef pair<ll, ll> P;

ump mp;

void solve() {
}

int main() {
#ifdef MY_DEBUG
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wmissing-noreturn"
    while (true) {
        mp = ump();
#pragma clang diagnostic pop
#endif
        ll n, ma, mb;
        cin >> n >> ma >> mb;
        vector<ll> a(n), b(n), c(n);
        rep(i, n) cin >> a[i] >> b[i] >> c[i];
        ll suma = accumulate(a.begin(), a.end(), 0);
        ll sumb = accumulate(b.begin(), b.end(), 0);
        ll dp[n + 1][suma + 100][sumb + 100];
        rep(k, n + 1) rep(i, suma + 100)rep(j, sumb + 100) dp[k][i][j] = ll_inf;
        dp[0][0][0] = 0;
        rep(k, n) {
            rep(i, suma + 1) {
                rep(j, sumb + 1) {
                    dp[k + 1][i][j] = min(dp[k + 1][i][j], dp[k][i][j]);
                    if (i >= a[k] && j >= b[k]) {
                        if (dp[k][i - a[k]][j - b[k]] != ll_inf) {
                            dp[k + 1][i][j] = min(dp[k + 1][i][j],
                                                  dp[k][i - a[k]][j - b[k]] + c[k]);
                        }
                    }
                }
            }
        }
        ll ans = ll_inf;
        repone(i, suma) {
            repone(j, sumb) {
                if (i * mb == j * ma) ans = min(ans, dp[n][i][j]);
            }
        }
        if (ans == ll_inf)cout << -1 << endl;
        else cout << ans << endl;

        solve();

#ifdef MY_DEBUG
    }
#endif
    return 0;
}

Measured memory_bytes: 36992