akhauriyash/Code-Regression huggingface dataset:
/*
If you want to aim high, aim high
Don't let that studying and grades consume you
Just live life young
******************************
What do you think? What do you think?
1st on Billboard, what do you think of it
Next is a Grammy, what do you think of it
However you think, I’m sorry, but shit, I have no fcking interest
*******************************
I'm standing on top of my Monopoly board
That means I'm on top of my game and it don't stop
til my hip don't hop anymore
https://www.a2oj.com/Ladder16.html
*******************************
300IQ as writer = Sad!
*/
import java.util.*;
import java.io.*;
import java.math.*;

   public class Main
   {
      public static void main(String hi[]) throws Exception
      {
         BufferedReader infile = new BufferedReader(new InputStreamReader(System.in));  
         StringTokenizer st = new StringTokenizer(infile.readLine());
         int N = Integer.parseInt(st.nextToken());
         int M = Integer.parseInt(st.nextToken());
         int T = Integer.parseInt(st.nextToken());
         int[] arr = readArr(N, infile, st);
         int[] brr = readArr(M, infile, st);
         long[] pref = new long[N];
         pref[0] = arr[0];
         for(int i=1; i < N; i++)
            pref[i] = pref[i-1]+arr[i];
         long sumb = 0L;
         int res = 0;
         for(int i=0; i < M; i++)
         {
            sumb += brr[i];
            if(sumb > T)
               break;
            int leftover = (int)(T-sumb);   
            int temp = i+1;
            if(arr[0] <= leftover)
            {
               int low = 0;
               int high = N-1;
               while(low != high)
               {
                  int mid = (low+high+1)/2;
                  if(pref[mid] <= leftover)
                     low = mid;
                  else
                     high = mid-1;
               }
               temp += low+1;
            }
            res = Math.max(res, temp);
         }
         int leftover = T;
         int temp = 0;
         if(arr[0] <= leftover)
         {
            int low = 0;
            int high = N-1;
            while(low != high)
            {
               int mid = (low+high+1)/2;
               if(pref[mid] <= leftover)
                  low = mid;
               else
                  high = mid-1;
            }
            temp += low+1;
         }
         res = Math.max(res, temp);
         System.out.println(res);
      }
      public static int[] readArr(int N, BufferedReader infile, StringTokenizer st) throws Exception
      {
         int[] arr = new int[N];
         st = new StringTokenizer(infile.readLine());
         for(int i=0; i < N; i++)
            arr[i] = Integer.parseInt(st.nextToken());
         return arr;
      }
   }

Measured memory_bytes: 60340
#include <math.h> 
#include <iostream>
#include <stdio.h>
using namespace std;

bool IsPrime(int num)
{
    if (num < 2) return false;
    else if (num == 2) return true;
    else if (num % 2 == 0) return false; // 偶数はあらかじめ除く

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

    // 素数である
    return true;
}

int main(){
    int X,buf;
    cin >> X;
    while(IsPrime(X)==false){
        X++;
    }
    cout << X << endl;
    return 0;
    
}

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

struct data {
  int p, bf;
  long long sum;
};

struct Unionfind {
  vector<int> par;
  vector<int> treerank;
  Unionfind(int n = 1) { stree(n + 1); }
  void stree(int n = 1) {
    par.assign(n, -1);
    treerank.assign(n, 0);
  }
  int root(int x) {
    if(par[x] < 0) return x;
    return par[x] = root(par[x]);
  }
  bool issame(int x, int y) { return root(x) == root(y); }
  bool uni(int x, int y) {
    x = root(x);
    y = root(y);
    if(x == y) return 0;
    if(treerank[x] > treerank[y]) swap(x, y);
    if(treerank[x] == treerank[y]) ++treerank[y];
    par[y] -= size(x);
    par[x] = y;
    return 1;
  }
  int size(int x) { return -par[root(x)]; }
};

long long n, m, sum = 0;
vector<long long> w, edge[100005], memo;
vector<bool> used, passed;
Unionfind uf;
queue<data> qu;

long long solve();
bool dfs(int now, int bf);

int main() {
  cin >> n >> m;
  w.resize(n);
  for(int i = 0; i < n; ++i) cin >> w[i];
  for(int i = 0; i < m; ++i) {
    int x, y;
    cin >> x >> y;
    edge[--x].push_back(--y);
    edge[y].push_back(x);
  }
  cout << solve() << endl;
  return 0;
}

long long solve() {
  long long ans = 0;
  uf = Unionfind(n);
  sum = w[0];
  passed.assign(n, 0);
  used.assign(n, 0);
  dfs(0, -1);
  memo.assign(n, 0);
  for(int i = 0; i < n; ++i)
    if(uf.issame(i, 0)) {
      bool ch = 0;
      for(int j = 0; j < edge[i].size(); ++j)
        if(!uf.issame(0, edge[i][j])) {
          ch = 1;
          break;
        }
      if(ch) qu.push({i, -1, 0});
    }
  while(!qu.empty()) {
    data now = qu.front();
    qu.pop();
    if(memo[now.p] != now.sum) continue;
    for(int i = 0; i < edge[now.p].size(); ++i)
      if(edge[now.p][i] != now.bf &&
         !uf.issame(0, edge[now.p][i])) {
        data nextp = now;
        nextp.p = edge[now.p][i];
        nextp.bf = now.p;
        nextp.sum += w[nextp.p];
        ans = max(ans, nextp.sum);
        if(memo[nextp.p] < nextp.sum) {
          memo[nextp.p] = nextp.sum;
          qu.push(nextp);
        }
      }
  }

  return ans + sum;
}

bool dfs(int now, int bf) {
  if(used[now]) return 1;
  if(passed[now]) return 0;
  used[now] = 1;
  passed[now] = 1;
  bool ans = 0;
  for(int i = 0; i < edge[now].size(); ++i)
    if(bf != edge[now][i]) ans |= dfs(edge[now][i], now);
  used[now] = 0;
  if(ans) {
    uf.uni(0, now);
    if(now != 0) sum += w[now];
  }
  return ans;
}


Measured memory_bytes: 24796
#include <iostream>
using namespace std;
int main()
{
int a,b;
cin>>a>>b;
if (a == b){
 cout<<"Draw";}
else if (a == 1){
 cout<<"Alice";}
else if (b == 1){
cout<<"Bob";}
else if (a > b){
 cout<<"Alice";}
else{
 cout<<"Bob";}
}


Measured memory_bytes: 256
#include <stdio.h>

int main()
{
    int i;
    int temp;
    int a,b,c;

    scanf("%d %d",&a,&b);

    if(a<b)
    {
        temp = a;
        a = b;
        b = temp;
    }
while(1)
{
    c = a%b;
    if(c == 0) break;
    a = b;
    b = c;
}

printf("%d\n",b);

return 0;

}


Measured memory_bytes: 2108
import java.util.Scanner;

class Main{
	
	public static void main(String[] args) {
		Scanner in = new Scanner(System.in);
		int n ;
		int count = 0;
		n = in.nextInt();
		int[] a = new int[n];
		for(int i = 0;i<n;i++){
			a[i] = in.nextInt();
		}
		
		for(int i=0;i<n-1;i++){
			for(int j = n-1;j>i;j--){
				if(a[j] <a[j-1]){
					int temp = a[j];
					a[j] = a[j-1];
					a[j-1] = temp;
					count++;
				}
			}
			
		}
		
		for(int i = 0;i<n;i++){
			if(i>0)System.out.print(" ");
			System.out.print(a[i]);
		}
		System.out.println("");
		System.out.println(count);
	}
}

Measured memory_bytes: 26380
#include<stdio.h>
#define N 100000


int Search(int *, int, int);

int main(){
  int loop1,loop2;
  int retu1[N],retu2[N];
  int i,count=0;
 
  scanf("%d",&loop1);
  for(i=0;i<loop1;i++){
    scanf(" %d",&retu1[i]);
  }

  scanf("%d",&loop2);
  for(i=0;i<loop2;i++){
    scanf(" %d",&retu2[i]);
  }

  for(i=0;i<loop2;i++){
    count+=Search(retu1,retu2[i],loop1);
  }
    
  printf("%d\n",count);
  
  return 0;
}


int Search(int *x,int y,int length){
  int i;

  for(i=0;i<length;i++){
    if(x[i]==y) return 1;
  }
  
  return 0; 
}



Measured memory_bytes: 2084
#include<cstdio>
#include<algorithm>
#include<vector>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
const int MAXN = 2e5 + 5;

struct Edge
{
	int next,to;
}e[MAXN];
int head[MAXN],etot=0;
inline void add(int u,int v)
{
	e[++etot]=(Edge){ head[u],v};
	head[u]=etot;
}

int pre[MAXN];

vector<int> cir;
bool vis[MAXN], ins[MAXN];
int dfs_cir(int u)
{
	vis[u] = 1; ins[u] = 1;
	for(int i=head[u]; i; i=e[i].next)
	{
		int v = e[i].to;
		if(ins[v]){ cir.push_back(u); ins[u]=0; return v;}
		
		int res = dfs_cir(v);
		if(res){ cir.push_back(u); ins[u]=0; return res==u? 0: res;}
	}
	ins[u] = 0;
	return 0;
}

bool incir[MAXN];

inline int get_mex(vector<int> &vec,int need)
{
	for(int i=0; i<(int)vec.size(); ++i)
	{
		if(vec[i] > need) return need;
		if(vec[i] == need) ++need;
 	}
 	return need;
}

int val[MAXN];
vector<int> nxt[MAXN];
void get_val(int u)
{
	for(int i=head[u]; i; i=e[i].next)
	{
		int v = e[i].to;
		if(incir[v]) continue;
		get_val(v);
		
		nxt[u].push_back(val[v]);
	}
	
	sort(nxt[u].begin(),nxt[u].end());
	
	val[u] = get_mex(nxt[u], 0);
}

bool check(int val_lst)
{
	int lst = val_lst;
	
	for(int k=0; k<(int)cir.size(); ++k)
	{
		int u = cir[k];
		if(val[u] == lst) lst = get_mex(nxt[u], val[u]+1);
		else lst = val[u];
	}
	return lst == val_lst;
}

int main(void)
{
	int n;
	scanf("%d",&n);
	for(int i=1; i<=n; ++i) scanf("%d",&pre[i]);
	
	for(int i=1; i<=n; ++i) add(pre[i], i);
	
	for(int i=1; i<=n; ++i)
		if(!vis[i]) dfs_cir(i);
	for(int i=0; i<(int)cir.size(); ++i)
		incir[cir[i]] = 1;
	
	if((int)cir.size() <= 1) return printf("IMPOSSIBLE"), 0;
	
	for(int i=0; i<(int)cir.size(); ++i)
		get_val(cir[i]);
	
	int u = cir.back();
	if(check(val[u]))
		printf("POSSIBLE");
	else if(check(get_mex(nxt[u], val[u]+1)))
		printf("POSSIBLE");
	else
		printf("IMPOSSIBLE");
	return 0;
}

Measured memory_bytes: 23572
import scala.io.StdIn.{readInt,readLine}

object Main {
  def scan(s:Array[Int],cnt:Int):(Array[Int],Int) = {
    val m = s.groupBy(_.self).map(i=>i._1->i._2.length)
    val mapped = s.map{ m(_) }
    if(mapped.sameElements(s)) (mapped,cnt)
    else
      scan(mapped,cnt+1)
  }
  def main(args:Array[String]) = {
    var n = 0
    while({n=readInt;n}!=0) {
      val s = readLine.split(" ").map(_.toInt)
      val r = scan(s,0)
      println(r._2)
      println(r._1.mkString(" "))
    }
  }
}

Measured memory_bytes: 46764
#include <iostream>

int main(int argc, char **argv)
{
	int n, m;
	int score[100] = {};
	int target[100];
	std::cin >> n >> m;
	for(int i = 0; i < m; i++){
		std::cin >> target[i];
	}
	for(int i = 0; i < m; i++){
		for(int j = 0; j < n; j++){
			int input;
			std::cin >> input;
			if(input == target[i]){
				score[j]++;
			}else{
				score[target[i] - 1]++;
			}
		}
	}
	for(int i = 0; i < n; i++){
		std::cout << score[i] << std::endl;
	}
	return 0;
}

Measured memory_bytes: 3056
// D - Banned K
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vl = vector<ll>;
#define rp(i,s,e) for(int i=(s);i<(e);++i)

int N;
vl A;

vl solve(){
	map<int,int> m;//<ai,count>
	rp(i,0,N) m[A[i]]++;

	vl ruiseki(N+1);
	for(auto x:m){
		ll a,c; tie(a,c) = x;
		if(c>=2) ruiseki[a] = c*(c-1)/2;//組み合わせ
	}

	rp(i,1,ruiseki.size()) ruiseki[i] += ruiseki[i-1];//Cumulative sum: 累積和

	vl del(N+1);
	for(auto x:m){
		ll a,c; tie(a,c) = x;
		c--;
		if(c>=2) del[a] = c*(c-1)/2;//１減の組み合わせ
	}

	vl ans(N, 0);
	rp(k,0,N){
		int ak = A[k];
		ll m = del[ak];// k の組み合わせ
		ll f = 0 <= ak-1? ruiseki[ak-1]: 0;// k より前の組み合わせの和
		ll b = ruiseki[ruiseki.size()-1] - ruiseki[ak];// k より後の組み合わせの和
		ans[k] = f + m + b;
	}

	return ans;
}

int main(){
	cin>>N;
	A.resize(N);
	rp(i,0,N){cin>>A[i]; A[i]--;}// ai 補正
	for(auto x:solve()) cout<<x<<endl;
}

Measured memory_bytes: 12416
#include <bits/stdc++.h>
using namespace std;
#define INF 2000000000
typedef long long int ll;
typedef pair<ll,ll> ii;
typedef vector<ll> vi;
typedef vector<ii> vii;
#define getbit(n,i) (((n)&(1<<(i)))!=0)
#define setbit0(n,i) ((n)&(~(1<<(i))))
#define setbit1(n,i) ((n)|(1<<(i)))
#define togglebit(n,i) ((n)^(1<<(i)))
#define lastone(n) ((n)&(-(n)))
#define read freopen("debug\\in.txt","r",stdin)
#define write freopen("debug\\out.txt","w",stdout)
#define fi first
#define se second
#define getI(a) scanf("%d",&a)
#define getII(a,b) scanf("%d%d",&a,&b)
#define PI (acos(-1))
#define fastread ios_base::sync_with_stdio(false);cin.tie(NULL)
#define mod (1000000007)
#define asz 500005
int main()
{
    fastread;
    int T=1;
//    cin>>T;
    for(int qq=1;qq<=T;qq++)
    {
        ll a,b,x;
        cin>>x>>a>>b;
        if(abs(x-a)>abs(x-b))cout<<"B"<<endl;
        else cout<<"A"<<endl;
    }
    return 0;
}



Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include<math.h>
#include<list>
#include <algorithm>
#include<set>
#include<vector>
#include<math.h>
#include<map>
#include<string>
#include <numeric>
#include <queue>
#include <sstream>
#include <bitset>

using namespace std;
using ll = long long;
using vll = vector<long long>;
using sll = set<long long>;

template<typename T>
T gcd(T a, T b) { return b ? gcd(b, a % b) : a; }
template<typename T>
T lcm(T a, T b) { return a / gcd(a, b) * b; }

template<typename T>
map<T, T> primeFactor(T n) {
	map<T, T> res;
	for (T i = 2; i * i <= n; ++i) {
		while (n % i == 0) {
			res[i] ++;
			n /= i;
		}
	}
	if (n != 1) res[n] = 1;
	return res;
}

template<typename T>
bool IsPrimeNumber(T num)
{
	if (num <= 2) return true;
	else if (num % 2 == 0) return false;

	double sqrtNum = sqrt(num);
	for (int i = 3; i <= sqrtNum; i += 2)
	{
		if (num % i == 0)
		{
			return false;
		}
	}

	return true;
}

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 in(x) cin >> x
#define out(x) cout << x
#define outn(x) cout << x << '\n'
#define outs(x) cout << x << ' '
#define rep(i,s,e) for(ll i=s;i<e;i++)
#define repeq(i,s,e) for(ll i=s;i<=e;i++)


int main() {
	ll n,ans=0;
	string s;

	cin >> n;
	cin >> s;
	rep(i, 0, n-2) {
		if (s.substr(i,3)=="ABC")  {
			ans++;
		}
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using ll = long long;
using namespace std;
#define rep(i,n) for(int i=0, i##_len=(int)(n); i<i##_len; i++)
#define reps(i,n) for(int i=1 , i##_len=(int)(n);i<=i##_len;i++)
#define rrep(i,n) for(int i=((int)(n)-1);i>=0;i--)
#define rreps(i,n) for(int i=((int)(n));i>0;i--)
#define repi(i,x) for(auto i=(x).begin(),i##_fin=(x).end();i!=i##_fin;i++)
#define all(x) (x).begin(), (x).end()
#define F first
#define S second
#define mp make_pair
#define pb push_back
#define solve(a) ((a)?"Yes":"No")
typedef vector<int> Vi;
typedef vector<Vi> VVi;
typedef pair<int , int> Pi;
typedef vector<Pi> VPi;
typedef vector<long long> V;
typedef vector<V> VV;
typedef pair<long long , long long> P;
typedef vector<P> VP;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1;} return 0;}
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1;} return 0;}
const long long INFLL = 1LL<<60;
const int INF = 1<<30;
const double PI=acos(-1);
int main(){
	int h1,h2,m1,m2,k;
	int ans=0;
	cin >>h1>>m1>>h2>>m2>>k;
	int dis=(h2-h1)*60+(m2-m1)-k;
	ans=min(dis,k);
	cout<<dis<<endl;
}

Measured memory_bytes: 3632
#include<iostream>
#include<cmath>
#include<algorithm>
#include<vector>
#include<queue>

using namespace std;

int main(){

  int h1,m1,h2,m2,k;
  cin >> h1 >> m1>> h2>>m2>>k;


  cout << 60*h2+m2-60*h1-m1-k << endl;

}

Measured memory_bytes: 3604
import java.util.*;
public class Main {
    static Scanner sc = new Scanner(System.in);
    static ArrayList<String> list = new ArrayList<String>();
    static String line;
    static int n;
    public static void main(String[] args) {

        while(read()){

        }
    }
    static boolean read(){
        if(!sc.hasNext())
            return false;
        n = sc.nextInt();sc.nextLine();
        for(int i = 0; i < n; i++){
            line = sc.nextLine().replace("Hoshino", "Hoshina");
            slove();
        }
        return true;
    }
    static void slove(){
        System.out.println(line);
    }

}

Measured memory_bytes: 12000
#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-1; i >= 0; i--)
#define ALL(x) x.begin(), x.end()
using ll = long long;
using pii = pair<int, int>;
using vi = vector<int>;
const int mod = 1e9+7;
const int INF = 1e9;
const int MAX = 1e6;

int main() {
    int x;
    cin >> x;
    int s = 0;
    for (int i = 0; i <= x; i++) {
        s += i;
        if (s >= x) {
            cout << i << endl;
            break;
        }
    }
}

Measured memory_bytes: 3632
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cmath>
#include<vector>
#include<map>
#include<set>
#include<string>
#include<queue>
#include<stack>
#include<complex>
#include<numeric>
using namespace std;
#define MOD 1000000007
#define MOD2 998244353
#define PRIM 3
#define INF (1<<29)
#define LINF (1LL<<60)
#define EPS (1e-10)
#define PI 3.1415926535897932384626433832795028
typedef long long Int;
typedef pair<Int, Int> P;
typedef long double Real;
typedef complex<Real> CP;

Int n;
Real a[440000];
Real b[440000];
Real e[440000];
Real c[440000];

Real bi_sum[440000];
Real b_sum[440000];

vector<P> highs;
set<int> done;

int main(){
    cin >> n;
    int mxa = 0;
    for(int i = 0;i < n;i++){
        cin >> a[i];
        a[i+n] = a[i];
        if(a[mxa] < a[i])mxa = i;
    }
    for(int i = 0;i < n;i++){
        cin >> b[i];
        b[i+n] = b[i];
    }
    e[mxa] = e[mxa + n] = a[mxa];
    for(int i = 1;i < n;i++){
        c[mxa + i+1] = - 2 * b[mxa + i] + 2*c[mxa + i] - c[mxa + i-1];
//        cout << c[mxa + i + 1] << endl;
    }

    using RP = pair<Real, Real>;
    vector<RP> ch = {{mxa, a[mxa] + c[mxa]}};

    for(int i = 1;i <= n;i++){
        RP p = {mxa + i, a[mxa + i] + c[mxa + i]};
        while(ch.size() >= 2){
            RP bb = ch[ch.size() - 2];
            RP b = ch.back();
            bb.first -= p.first;bb.second -= p.second;
            b.first -= p.first;b.second -= p.second;
            if(b.first * bb.second - b.second * bb.first <= 0)ch.pop_back();
            else break;
        }
        ch.push_back(p);
    }
    for(auto p:ch){
//        cout << p.first << " " << p.second << endl;
    }
    Real ans = a[mxa];
    for(int i = 1;i < n;i++){
        int ind = mxa + i;
        auto r = lower_bound(ch.begin(), ch.end(), RP(ind, -INF));
        auto l = prev(r);
        auto l_dist = ind - l->first;
        auto r_dist = r->first - ind;
//        cout << ind << " "  << (l_dist * r->second + r_dist * l->second) /(l_dist + r_dist) - c[ind] << endl;
        ans += (l_dist * r->second + r_dist * l->second) /(l_dist + r_dist) - c[ind]; 
    }
    printf("%.10lf\n", double(ans / n));    
    
    return 0;
}

Measured memory_bytes: 26724
def n_sum(n):
  x = 1
  ans_sum = 0
  while x <= n:
    ans_sum += x
    x += 1

  return ans_sum


n, m = map(int, input().split())

new_n = n - 1
new_m = m - 1
print(n_sum(new_n) + n_sum(new_m))


Measured memory_bytes: 2940
import java.util.Scanner;

public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		String s = sc.nextLine();
		char x = s.charAt(0);
		char y = s.charAt(2);
		if(x > y){
			System.out.println(">");
		}else if(x == y){
			System.out.println("=");
		}else{
			System.out.println("<");
		}
	}
}


Measured memory_bytes: 22228
#include "bits/stdc++.h"
using namespace std;
#define REP(i, n) for(ll i = 0;i < n;i++)
#define ll long long
#define MOD 1000000007
#define llMAX 9223372036854775807
#define llMIN -9223372036854775808
using vi = vector<ll>; // intの1次元の型に vi という別名をつける
using vvi = vector<vi>; // intの2次元の型に vvi という別名をつける

ll n,k,x,y;

int main(){
  string s;
  cin>>s;
  REP(i,s.length()){
    s[i]='x';
  }
  cout<<s<<endl;

  return 0;
}

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

int main(){
  int N;
  cin >> N;

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

  if(all_of(a.begin(), a.end(), [](auto x){return (x % 2 == 0);})){
    cout << "second" << endl;
  }else{
    cout << "first" << endl;
  }
}



Measured memory_bytes: 888
s = input()
k = int(input())
substrings = set()
s_list = []
for i in range(len(s)):
    for j in range(i+1, i+6):
        substrings.add(s[i:j])
s_list = list(substrings)
s_list.sort()
print(s_list[k-1])


Measured memory_bytes: 4464
#include <cstdio>

using namespace std;

int a[100010];

int main()
{
	int n,l;scanf("%d%d",&n,&l);
	for (int i=1;i<=n;i++) scanf("%d",&a[i]);
	int j=0;
	for (int i=1;i<n;i++) if (a[i]+a[i+1]>=l) j=i;
	if (!j) {puts("Impossible");return 0;}
	puts("Possible");
	for (int i=1;i<j;i++) printf("%d\n",i);
	for (int i=n-1;i>j;i--) printf("%d\n",i);
	printf("%d\n",j);
	return 0;
}


Measured memory_bytes: 1152
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <vector>
#include <list>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <tuple>
using namespace std;
typedef long long ll;

int main(){

    int n; cin >> n;

    ll t[n+1], x[n+1], y[n+1];
    t[0] = 0; x[0] = 0; y[0] = 0;

    for(int i=1; i<=n; i++){
        cin >> t[i] >> x[i] >> y[i];
    }

    bool flag = true;
    for(int i=1; i<=n; i++){
        ll md = abs(x[i] - x[i-1]) + abs(y[i] - y[i-1]);
        ll dt = t[i] - t[i-1];

        if(md > dt || (dt - md)%2 == 1){
            flag = false;
            break;
        }
    }

    cout << (flag ? "Yes" : "No") << endl;

    return 0;
}

Measured memory_bytes: 2560
#include <iostream>
#include <stack>
#include <cstring>
#include <utility>

typedef std::pair<int, int> ii;

const int ms = 2020;

int n, m;
std::string board[ms];
int a[ms][ms];
int match[ms][ms][2];

int getMatch(int row, int pos, int change)
{
	int &ans = match[row][pos][change];
	if(ans != -1)
	{

		return ans;
	}
	ans = 0;
	if(pos == m)
		ans = 0;
	else if(row == 0)
		ans = 1 + getMatch(row, pos + 1, change);
	else if(a[row][pos] ^ change == a[row - 1][pos])
		ans = 1 + getMatch(row, pos + 1, change);
	else
		ans = 0;
	//std::cout << "on (" << row << ", " << pos << ", " << change << ") got " << ans << "\n";
	return ans;
}

int histo[ms];

int main()
{
	std::cin >> n >> m;
	for(int i = 0; i < n; i++)
	{
		std::cin >> board[i];
		for(int j = 0; j < m; j++)
		{
			a[i][j] = board[i][j] == '#' ? 1 : 0;
		}
	}
	int ans = std::max(n, m);
	memset(match, -1, sizeof match);
	for(int j = 0; j < m; j++)
	{
		std::stack<ii> s;
		//std::cout << "on col " << j << "\n";
		for(int i = 1; i < n; i++)
		{
			histo[i] = std::max(getMatch(i, j, 0), getMatch(i, j, 1));
			//std::cout << "histo[" << i << "] == " << histo[i] << "\n";
			ans = std::max(ans, histo[i] * 2);
			int last = i;
			while(!s.empty() && s.top().second >= histo[i])
			{
				ii p = s.top();
				last = p.first;
				ans = std::max(ans, (i - last + 1) * p.second);
				//std::cout << "got height " << p.second << ", length " << i - last + 1 << "\n";
				s.pop();
			}
			s.push(ii(last, histo[i]));
		}
		//std::cout << "ok\n";
		while(!s.empty())
		{
			ii p = s.top();
			ans = std::max(ans, (n - p.first + 1) * p.second);
			//std::cout << "got height " << p.second << ", length " << n - p.first + 1 << "\n";
			s.pop();
		}
	}
	std::cout << ans << "\n";
}

Measured memory_bytes: 52096
#include<iostream>
#include<vector>
#include<algorithm>
#include<utility>
#include<string>
#include<cmath>
#include<cstring>
#include<queue>
#include<map>
#include<climits>
#include<set>

#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++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define llong long long
#define pb(a) push_back(a)
using namespace std;
typedef pair<int, int> pii;
typedef long long int ll;
typedef pair<ll,ll> pll;
int dx[4] = {1,0,0,-1};
int dy[4] = {0,1,-1,0};
#define MOD 1000000007
#define ARRAY_MAX 100005

const int INF = 1e9+7;


int main(){

    int n;
    cin >> n;
    double ans = 0;
    for(int i = 0;i < n;i++){
        double x;
        string s;
        cin >> x >> s;
        if(s == "JPY"){
            ans += x;
        }else{
            ans += x*380000;
        }
    }
    printf("%.8f\n",ans);

    return 0;
}


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

using namespace std;
typedef long long ll;

int main() {
	int n;
	cin >> n;
	vector <ll> l(1003, 0);

	for (int i = 0; i < n; i++) {
		ll tmp;
		cin >> tmp;
		l[tmp]++;
	}

	ll ans = 0;

	for (ll a = 1; a < 1001; a++) {
		if (l[a] <= 0) continue;
		ll a_count = l[a];
		for (ll b = a; b < 1001; b++) {
			ll b_count = (a == b) ? l[b] - 1 : l[b];
			if (b_count <= 0) continue;
			for (ll c = b; c < 1001; c++) {
				if (!(c < a + b)) continue;
				if (!(c > b - a)) continue;
				if (!(c > a - b)) continue;

				ll c_count = l[c];
				if (a == c) {
					c_count--;
				}
				if (b == c) {
					c_count--;
				}
				if (c_count <= 0) continue;
				ll cur = a_count * b_count * c_count;
				if (a == b && b ==c) {
					cur /= 6;
				} else {
					if (a == b) {
						cur /= 2;
					} else if (b == c) {
						cur /= 2;
					}
				}
				ans += cur; 
			}
		}
	}
	cout << ans << endl;


	return 0;
}

Measured memory_bytes: 256
N,A,B=map(int,input().split())                            # 1行2列

#N 合計
#A 先
#B 後

SUM = A + B

LOOP_SUM = int(N / SUM) * A
REST = N % SUM

if REST > A:
	LOOP_SUM += A
else:
	LOOP_SUM += REST

print(LOOP_SUM)


Measured memory_bytes: 3316
main::IO()
main = do
  nc<-getLine
  let n = read nc ::Int
  dat<-(get_n n)
  print (solver 1 dat)

--入出力処理

solver :: Int -> [Int] -> Int
solver x [] = 0
solver x (b:rest)= if b<x then solver x rest
                          else if b==x then solver (x+1) rest
                                       else if (mod b x==0) then ((div b x)-1)+(solver (max (1+1) x) rest)
                                                            else (div b x)+(solver (max (1+1) x) rest)
--第一引数は、販売可能最低価格：これは既に購入しきった先客の所有額より1大きいことが保証される。
--第二引数は、これから購入する可能性がある客の所持金リスト。
--先頭客所持金が販売可能最低価格を下回る場合:この金額では先頭客は購入出来ないので、最低価格が後続客へ引き継がれる。
--先頭客所持金と販売可能最低価格と等しい場合：この場合では先頭客は購入出来るが、所持金がゼロになるのを避けるため、
--                                      この客へ販売することなく、販売可能最低価格を引き上げて後続客へ渡す。
--先頭客所持金が販売可能最低価格を上回る場合：この場合、購入ができる。但し所持金がゼロにならないように、あまりを１以上にする。
--                                      少なくともこの顧客はxによる商、または割り切れる場合はそれより1つ少なく購入出来るが、
--                                      後続客への販売可能最低価格を引き上げない為に、この顧客の残り所持金は出来る限り減らしたい。
--                                      これは可能である。この客は1つ以上は購入するので、その内任意の機会で価格を引き上げられる。
--                                      このとき、購入可能数を減らすことなく、この客の残り所持金を１まで落とせるので、
--                                      後続客の販売可能最低価格への追加制約は、1+1=2以上である。


get_n::Int -> IO [Int]
get_n 0 = return []
get_n n = do
          c<-getLine
          let m = read c ::Int
          rest<- (get_n (n-1))
          return (m:rest)

Measured memory_bytes: 64892
S = input()

L = ['maerd', 'remaerd', 'esare', 'resare']
T = ''
for i in range(len(S) - 1, -1, -1):
    T += S[i]
    if T not in L and len(T) > 7:
        print('NO')
        exit()
    elif T in L:
        T = ''

print('YES')


Measured memory_bytes: 9088
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

fn main() {
    input! {
        k: isize,
        x: isize,
    }
    for i in (-1000000)..1000000 {
        if i > x - k && i < x + k {
            print!("{} ", i);
        }
    }
}


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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

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

#define DEBUG(x) cout<<#x<<": "<<(x)<<'\n'
#define DEBUG_VEC(v) cout<<#v<<":";REP(i, v.size())cout<<' '<<v[i];cout<<'\n'
#define ALL(a) (a).begin(), (a).end()

template<typename T> inline void CHMAX(T& a, const T b) {if(a<b) a=b;}
template<typename T> inline void CHMIN(T& a, const T b) {if(a>b) a=b;}

constexpr ll MOD=1000000007ll;
// constexpr ll MOD=998244353ll;
#define FIX(a) ((a)%MOD+MOD)%MOD

const double EPS=1e-11;
#define EQ0(x) (abs((x))<EPS)
#define EQ(a, b) (abs((a)-(b))<EPS)

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

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

int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	// cout<<setprecision(10)<<fixed;
	ll a, b, c, d;
	cin>>a>>b>>c>>d;
	ll tmp=lcm(c, d);
	--a;
	cout<<b-a-(b/c-a/c)-(b/d-a/d)+(b/tmp-a/tmp)<<'\n';
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(void){
    int h,w;cin>>h>>w;
    if(w<100){
        cout<<int(pow(100,h)*w)<<endl;
    }
    else if(w==100){
        cout<<int(pow(100,h)*(1+w))<<endl;
    }
}


Measured memory_bytes: 512
#!/usr/bin/env python3

import sys
import math
from bisect import bisect_right as br
from bisect import bisect_left as bl
sys.setrecursionlimit(2147483647)
from heapq import heappush, heappop,heappushpop
from collections import defaultdict
from itertools import accumulate
from collections import Counter
from collections import deque
from operator import itemgetter
from itertools import permutations
mod = 10**9 + 7
inf = float('inf')
def I(): return int(sys.stdin.readline())
def LI(): return list(map(int,sys.stdin.readline().split()))

a,b,c = LI()
print(min(c,b//a))

Measured memory_bytes: 38384
import java.util.*;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		long a = sc.nextLong();
		long b = (long)Math.pow(a, 2);
		long c = (long)Math.pow(a, 3);
		System.out.println(a + b + c);
	}
}

Measured memory_bytes: 35852
# -*- coding: utf-8 -*-

n = int(input())

lengths = list(map(int, input().split()))

l_max = max(lengths)
i_l_max = lengths.index(l_max)

ans = 0
_max = lengths[0]

for i in range(len(lengths)):
    if i < i_l_max:
        if _max > lengths[i]:
            ans += _max - lengths[i]
        else:
            _max = lengths[i]
    else:
        ans += l_max - lengths[i]

print(ans)


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

using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef complex<double> P;
typedef pair<int,int> pii;
#define REP(i,n) for(ll i=0;i<n;++i)
#define REPR(i,n) for(ll i=1;i<n;++i)
#define FOR(i,a,b) for(ll i=a;i<b;++i)

#define DEBUG(x) cout<<#x<<": "<<x<<endl
#define DEBUG_VEC(v) cout<<#v<<":";REP(i,v.size())cout<<" "<<v[i];cout<<endl
#define ALL(a) (a).begin(),(a).end()

#define MOD (ll)(1e9+7)
#define ADD(a,b) a=((a)+(b))%MOD
#define FIX(a) ((a)%MOD+MOD)%MOD

int main(){
  int n;
  cin >> n;
  int r[n];
  REP(i,n)cin>>r[i];
  double pos[n];
  REP(i,n){
    pos[i]=r[i];
    REP(j,i){
      pos[i] = max(pos[i],pos[j]+sqrt( (double)(4*r[i]*r[j]) ));
    }
  }
  double mx = 0;
  REP(i,n) mx = max(mx,pos[i]+r[i]);
  cout.precision(15);
  cout << fixed << mx << endl;
  return 0;
}

Measured memory_bytes: 1244
n=int(input())
xyh=[list(map(int,input().split())) for i in range(n)]
xyh.sort(key=lambda x:x[2],reverse=True)
for X in range(0,101):
    for Y in range(0,101):
        H=xyh[0][2]+abs(xyh[0][0]-X)+abs(xyh[0][1]-Y)
        for i in range(1,n):
            x,y,h=xyh[i]
            if h!=max(H-abs(x-X)-abs(y-Y),0):
                break
        else:
            print(X,Y,H)
            break

Measured memory_bytes: 3064
import sys
input = sys.stdin.readline
from collections import deque
from functools import lru_cache


def solve():
    n = int(input())
    h = list(map(int, input().split(' ')))
    dp = [0 for i in range(n)]
    dp[1] = abs(h[1] - h[0])
    for i in range(2, n):
        dp[i] = min(abs(h[i] - h[i - 1]) + dp[i-1], abs(h[i] - h[i - 2]) + dp[i - 2])
    print(dp[-1])
    


if __name__ == '__main__':
    solve()

Measured memory_bytes: 14328
package main

import (
	"fmt"
	"math"
)

func min(x, y int) int {
	if x < y {
		return x
	}
	return y
}

func main() {
	var x, y int
	fmt.Scan(&x, &y)

	ans := math.MaxInt64
	if x <= y {
		ans = min(ans, y-x)
	}
	if a := -x; a <= y {
		ans = min(ans, y-a+1)
	}
	if b := -y; x <= b {
		ans = min(ans, b-x+1)
	}
	if a, b := -x, -y; a <= b {
		ans = min(ans, b-a+2)
	}
	fmt.Println(ans)
}


Measured memory_bytes: 512
#include<bits/stdc++.h>
#define ll long long 
#define MM(arr,x) memset(arr,x,sizeof(arr))
#define INF 0x3f3f3f3f
#define Maxn 1e5+10;
using namespace std;
int a[205];
int main()
{
	ios::sync_with_stdio(0);
	int n;
	cin>>n;
	for(int i=0;i<n;i++)
		cin>>a[i];
	int cnt = 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(a[i]!=a[j]&&a[i]!=a[k]&&a[j]!=a[k])
				{
					int min1 = min(a[i],min(a[j],a[k]));
					int min2 = a[i]+a[j]+a[k]-min1-max(a[i],max(a[j],a[k]));
					int max1 = max(a[i],max(a[j],a[k]));
					if(min1+min2>max1&&min2-min1<max1) cnt++;
				}
			}
		}
	}
	cout<<cnt;
	return 0;
} 

Measured memory_bytes: 3648
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n;
  cin>>n;
  int m=n%10;
  if(m==3)cout<<"bon"<<endl;
  else if(m==0||m==1||m==6||m==8)cout<<"pon"<<endl;
  else cout<<"hon"<<endl;
  return 0;
}


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

#define REP(i,n) for(int i=0,len=(n); i<len; i++)
#define all(x) (x).begin(),(x).end()

using namespace std;

int main(){
	int p,q,r;
	int ans;
	
	cin >> p >> q >> r;
	
	ans=1000;
	ans=min(ans,p+q);
	ans=min(ans,p+r);
	ans=min(ans,q+r);
	
	cout << ans << endl;
	
	return 0;
}

Measured memory_bytes: 256
N = int(input())
A = list(map(int,input().split()))
minabs = 10**9
i = 0
j = N-1
sum = 0
while i < j:
    while A[i] > 0 and i < j:
        if A[i] < minabs:
            minabs = A[i]
        sum += A[i]
        i += 1
        #print(sum)

    if i == j:
        break

    
    #print(sum)

    while A[j] > 0 and i < j:
        if A[j] < minabs:
            minabs = A[j]
        sum += A[j]
        j -= 1
        #print(sum)
    if i == j:
        break


    if -A[i]< minabs:
        minabs = -A[i]
    
    sum -= A[i]
    i += 1
    
    if -A[j] < minabs:
        minabs = -A[j]
    sum -= A[j]
    j -= 1
    #print(sum)
if i == j:
    if A[i] < 0:
        sum -= A[i]
        #print(sum)
        sum -= minabs*2
        #print(sum)
    else:
        sum += A[i]
        #print(sum)
print(sum)
        

    
    
        

Measured memory_bytes: 14480
# ABC 104: B – AcCepted
s = input()

lowers = 'abcdefghijklmnopqrstuvwxyz'
is_satisfied = 'AC'

if s[0] == 'A' and s[2:-1].count('C') == 1:
    for letter in s:
        if letter != 'A' and letter != 'C':
            if letter not in lowers:
                is_satisfied = 'WA'
                break
else:
    is_satisfied = 'WA'

print(is_satisfied)

Measured memory_bytes: 2940
#include <iostream>

using namespace std;

struct Item
{
  long long w;
  int v;
};

const long long PINF = 1000LL*1000LL*1000LL*1000LL;

int main()
{
  int n;
  long long W;
  cin >> n >> W;
  Item items[n];
  for (int i = 0; i < n; ++i)
    cin >> items[i].w >> items[i].v;
  int nbV = n*1000;
  long long dp[n+1][nbV+1];
  for (int i = 0; i < nbV + 1; ++i)
    dp[0][i] = PINF;
  dp[0][0] = 0;
  for (int i = 1; i < n + 1; ++i)
    for (int j = 0; j < nbV + 1; ++j)
      dp[i][j] = min(dp[i-1][j], (j >= items[i-1].v) ? dp[i-1][j-items[i-1].v] + items[i-1].w : dp[i-1][j]);
  for (int i = nbV; i >= 0; --i)
    if (dp[n][i] <= W)
    {
      cout << i << '\n';
      return 0;
    }
}

Measured memory_bytes: 79104
N, W = map(int, input().split())
value = []
weight = []
for i in range(N):
    v, w = map(int, input().split())
    value.append(v)
    weight.append(w)
dp = [[0] * (W + 1) for _ in range(N + 1)]
for i in range(N):
    for max_w in range(W + 1):
        if max_w >= weight[i]:
            dp[i + 1][max_w] = max(dp[i][max_w],
                                   dp[i][max_w - weight[i]] + value[i])
        else:
            dp[i + 1][max_w] = dp[i][max_w]
print(dp[N][W])



Measured memory_bytes: 25496
#include<bits/stdc++.h>
#define int             long long
using namespace std;

typedef pair<int, int> ii;

const int N = 2e5 + 4;
int n, x[N], res, a[N];

void sol() {
    int Prev = -1;
    for (int i = n; i >= 1; --i) {
        int pos = i - a[i];
        if (pos <= 0) { cout << -1; exit(0); }
        if (pos > Prev && Prev != -1) { cout << -1; exit(0); }
        if (pos == Prev) res += 0;
        else res += a[i];
        Prev = pos;
    }
    cout << res;
}

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

    cin >> n;
    for (int i = 1; i <= n; ++i) cin >> a[i];

    if (a[1] != 0) { cout << -1; exit(0); }

    sol();

    return 0;
}


Measured memory_bytes: 1792
#include<stdio.h>
#include<math.h>
#include<string.h>
#include<ctype.h>
int main(void)
{
  int a[4];
  int b[4];
  while(scanf("%d %d %d %d %d %d %d %d",
  &a[0],&a[1],&a[2],&a[3],&b[0],&b[1],&b[2],&b[3])!=EOF){
    int hc=0;
	int bc=0;
	int i,j;
	for(i=0;i<4;i++){
	  for(j=0;j<4;j++){
	    if(a[i]==b[j] && i==j)
		  hc++;
		else if(a[i]==b[j] && i!=j)
		  bc++;
	    //printf("%d %d\n",hc,bc);
	  }
	}
	printf("%d %d\n",hc,bc);
  }

  return 0;
}

Measured memory_bytes: 592
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <string>
#include <stack>
#include <queue>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <cmath>

using namespace std;
#define PI 3.1415926535897932384626433832795
#define MOD (1000000007)
#define rep(i, n) for (int i = 0; i < (n); i++)
#define repc(i, s, n) for (int i = (s); i <= (n); i++)
#define rrep(i, n) for (int i = (n) - 1; i >= 0; i--)
#define rrepc(i, s, n) for (int i = (s); i >= (n); i--)
typedef long long ll;
typedef unsigned long long ull;

#define p(a, b) make_pair(a, b)
vector<pair<int, int> > T[100001];
int ans[100001];
bool visited[100001] = { false };

int main()
{
	int N, a, b, color = 0;
	queue<int> Q;

	cin >> N;
	rep(i, N - 1) {
		cin >> a >> b;
		T[a].push_back(p(i + 1, b));
		T[b].push_back(p(i + 1, a));
	}

	repc(i, 1, N) ans[i] = -1;

	Q.push(1);
	visited[1] = true;

	while (!Q.empty()) {
		int paint = 1;
		int node = Q.front(); Q.pop();
		int size = T[node].size();
		map<int, bool> USED;

		rep(i, size) {
			int edge = T[node][i].first;
			if (ans[edge] != -1) USED[ans[edge]] = true;
		}

		rep(i, size) {
			int edge = T[node][i].first;
			int next = T[node][i].second;

			if (!visited[next]) {
				Q.push(next);
				visited[next] = true;
			}

			while (true) {
				if (ans[edge] != -1) break;

				if (USED.count(paint) >= 1) {
					paint++;
					continue;
				}

				ans[edge] = paint;
				color = max(color, paint);
				paint++;
				break;
			}
		}
	}

	cout << color << endl;
	repc(i, 1, N - 1) cout << ans[i] << endl;

	return 0;
}


Measured memory_bytes: 7040
#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
 
using namespace __gnu_pbds;
using namespace std;

template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

#define all(a) a.begin(),a.end()
#define F first
#define S second
#define pb push_back
#define ll long long
#define vi vector<int>
#define pi pair<int,int>
#define mp make_pair

#ifdef LOCAL
#include "debug.h"
#else
#define debug(...) 42
#endif

const int mod=1e9+7;
 
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
template<typename A,typename B> istream& operator>>(istream&,pair<A,B>&);
template<typename A> istream& operator>>(istream&,vector<A>&);
void add(int&,int);
int mul(int,int);
int powz(int,int);
template<typename A> ostream& operator<<(ostream&,vector<A>&);
int d;
const int N=500001;

inline int checkmod(int num){
	if(num>=d)return num%d;
	return num;
}

void solve(){
	string k;
	cin>>k;
	//~ int d;
	cin>>d;
	vector<array<int,2>>dp(d,array<int,2>());
	dp[0][0]=1;
	for(int i=0;i<k.length();i++){
		vector<array<int,2>>new_dp(d,array<int,2>());
		for(int j=0;j<d;j++){
			for(int _=0;_<10;_++){
				if(_<(k[i]-'0')){
					add(new_dp[checkmod(j+_)][1],dp[j][0]);
					add(new_dp[checkmod(j+_)][1],dp[j][1]);
				}
				else if(_==(k[i]-'0')){
					add(new_dp[checkmod(j+_)][0],dp[j][0]);
					add(new_dp[checkmod(j+_)][1],dp[j][1]);
				}
				else{
					add(new_dp[checkmod(j+_)][1],dp[j][1]);
					
				}
			}
			
		}
		dp=new_dp;
	}
	cout<<(dp[0][0]+dp[0][1]-1+mod)%mod;
		
		

	
}
	
signed main(){
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	int tc=1;
	//~ cin>>tc;
	for(int _=0;_<tc;_++){
		//~ cout<<"Case #"<<_+1<<": ";
		solve();
		if(_!=tc-1)
		cout<<"\n";
	}
}
 
int mul(int a,int b)
{
	return ((a)*1ll*(b))%mod;
}
 
void add(int &a,int b)
{
	a+=b;
	if(a>=mod)a-=mod;
}
 
int powz(int a,int b)
{
	int res=1;
	while(b)
	{
		if(b&1)res=mul(res,a);
		b/=2;
		a=mul(a,a);
	}
	return res;
}
 
template <typename A, typename B>
istream& operator>>(istream& input,pair<A,B>& x) {
	input>>x.F>>x.S;
	return input;
}
 
template <typename A>
istream& operator>>(istream& input,vector<A>& x) {
	for(auto& i:x)
		input>>i;
	return input;
}
 
template<typename A>
ostream& operator<<(ostream& output,vector<A>& x) {
	for(auto& i:x)
	    output<<i<<' ';
	return output;	
}


Measured memory_bytes: 384
using System;

public class Dice
{

	public static void Main(String[] args)
	{
		//?????????????????°????????????
		int diceCount=int.Parse(Console.ReadLine());
		//diceCount????????????????????????
		string[][] diceA=new string[diceCount][];
		
		for(int d=0;d<diceCount;d++)
		{   
			string data=Console.ReadLine();
			diceA[d]=data.Split();

		}
		string yesNo = "Yes";
		//??\??????????????????????????????????????°????????´??? "Yes"??????????????????????????\?????????????????´???
		//"No" ??¨???????????????
     	
		//???????????????????????????.??????????????????????????????
		
		for(int i=0;i<diceCount-1;i++)
		{
			for(int j=i+1;j<diceCount;j++)
			{
			    		
				yesNo=diceComparer(diceA[i] ,diceA[j]);
		       if(yesNo=="No")
		       {
		       
		       	break;
		       }
		       
			}
			if(yesNo=="No")
			{
				break;
			}
		}
		Console.WriteLine(yesNo);
	}
	//????????????????????¢??????????????±?\??????????90??????????????????

	public static void turn(int a, int b, int c, int d, string[] dice)
	{
		string temp = dice[a];
		dice[a] = dice[b];
		dice[b] = dice[c];
		dice[c] = dice[d];
		dice[d] = temp;
            
	}
	
	public static string diceComparer(string[] dice1,string[] dice2)
	{
		int i = 0;
		int j = 0;
		string yn="Yes";//????????????????????´??????????????§"No"????????????"No"????????´???????????????
		do {
			do {
                  
				for (int k = 0; k < dice1.Length; k++) {
					if (!dice1[k].Equals(dice2[k])) {
						yn = "Yes";
						break;
					}
					if (k == dice1.Length - 1) {
						yn = "No";//?????????????????´
					}
				}
				if (yn == "No") {
					break;
				}
				turn(3, 5, 2, 0, dice2); //??±??¨???                  
				j++;
			} while (j < 4);

			if (yn == "No") {
				break;
			}
				
			j = 0;
				
		
			
			 if (i == 3) {
                   
				turn(4, 5, 1, 0, dice2);//????????§?????????
				turn(2, 5, 3, 0, dice2);//?\???¨???
				
					
			} else if (i == 4)
			{
				//??????????????§diceB[1]=east
				//west ???south????????????????????????                   
				turn(4, 5, 1, 0, dice2);  
			
			}
			
			turn(4, 5, 1, 0, dice2);//?????¨???
			//?????????????????????????????????????????????????????????????????????????????¨??¨????????¢??????????????????????????????
			i++;
		} while (i < 6);
		return yn;
		//Console.WriteLine(yesNo);
	}
}

Measured memory_bytes: 9136
n = int(input())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
ans = 0
r = a[0]
for i in range(n):
    if b[i] <= r:
        ans += b[i]
        r = a[i + 1]
    else:
        p = b[i] - r
        if p < a[i + 1]:
            ans += b[i]
            r = a[i + 1] - p
        else:
            ans += r + a[i + 1]
            r = 0
print(ans)

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

int main(){
    int a,b,c,x;

    cin >> a >> b >> c >> x;

    int aloop = x / 500;
    int bloop = x / 100;
    int cloop = x / 50;
    int count = 0;
    int temp1, temp2, temp3;
   /* cout<<"a = "<<a<<endl;
    cout << "b = " << b << endl;
    cout << "c = " << c << endl;
    cout << "x = " << x << endl;*/
    for(int i = 0; i <= a; i++){
        temp1 = x - 500 * i;
        for(int j = 0; j <= b; j++){
            temp2 = temp1 - 100 * j;
            for(int k = 0; k <= c; k++){
                temp3 = temp2 - 50 * k;
                if(temp3 == 0){
                    count++;
                }
            }
        }
    }
    cout<<count<<endl;

}

Measured memory_bytes: 256
import collections

N,K,Q = map(int,input().split())
li = [int(input()) for i in range(Q)]
ans = [0]*N
lis = collections.Counter(li)
for w in lis:
    ans[w-1] = K-(Q-lis[w])
for i in range(N):
    if i+1 not in lis:
        ans[i] = K-Q
for i in range(N):
    if ans[i] <= 0:
        ans[i] = 'No'
    else:
        ans[i] = 'Yes'
    print(ans[i])


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

int main(){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    
    char a, b;
    cin >> a >> b;
    
    string s = "";
    string t = "";
    for(int i = 0; i < (b - '0'); ++i){
        s += a;
    }
    for(int i = 0; i < (a - '0'); ++i){
        t += b;
    }
    cout << min(s, t) << endl;
}

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

#define name ""
#define ini freopen(name".inp","r",stdin); freopen(name".out","w",stdout)
#define foe(it,c) for (__typeof(c.begin()) it = c.begin(); it != c.end(); it++)
#define long long long 
#define db double 
#define pii pair <int, int>
#define pll pair <long, long>
#define all(c) c.begin(), c.end()
#define fastio ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0)

const int INF = 1e9+7;
const int MOD = 1e9+7;
const int dx[4] = {0,0,-1,1};
const int dy[4] = {-1,1,0,0};

const int N = 1e5+1;
string s[N];
int cnt[3], n;
vector <int> res;

bool Try(int u){
  if (cnt[0] < 0 || cnt[1] < 0 || cnt[2] < 0) return false;
  if (u == n + 1) return true;
  int x = s[u][0] - 'A';
  int y = s[u][1] - 'A';
  if (cnt[x] <= cnt[y]){
    cnt[x]++; cnt[y]--;
    res.push_back(x);
    if (Try(u + 1)) return true;
    res.pop_back();
    cnt[x] -= 2; cnt[y] += 2;
    res.push_back(y);
    if (Try(u + 1)) return true;
    res.pop_back();
    cnt[x]++; cnt[y]--;
  }
  else{
    cnt[x]--; cnt[y]++;
    res.push_back(y);
    if (Try(u + 1)) return true;
    res.pop_back();
    cnt[x] += 2; cnt[y] -= 2;
    res.push_back(x);
    if (Try(u + 1)) return true;
    res.pop_back();
    cnt[x]--; cnt[y]++;  
  }
  return false;
}

int main()
{
  fastio;
  cin >> n >> cnt[0] >> cnt[1] >> cnt[2];
  for (int i = 1; i <= n; i++) cin >> s[i];
  if (Try(1)) {
    cout << "Yes\n";
    for (int x : res) cout << (char)(x + 'A') << '\n';
  }
  else cout << "No";
  return 0;
}

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

typedef long long ll;
const ll INF = 1010000000000000017LL;
const ll MOD = 1000000007LL;

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

//#define DEBUG(fmt, ...)
#define DEBUG(fmt, ...) fprintf(stderr, fmt "\n", ##__VA_ARGS__)

int main(){
    std::cout<<std::fixed<<std::setprecision(10);

    ll N, M;
    cin >> N >> M;


    ll l=-1;
    ll r=N;
    REP(i, M){
        ll L, R;
        cin >> L >> R;
        l = max(l, L);
        r = min(r, R);
    }

    cout << max(0, (int)(r-l+1)) << endl;
}


Measured memory_bytes: 256