akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
#define ll long long int
using namespace std;
const ll mod = 1e9+7;
const int N = 2e5+7;
int n,a,b;
vector<int> g[N];
ll dp[N],sub[N],ans[N],inv[N],f[N];


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

ll mi(ll a){return power(a,mod-2);}

void dfs(int s = 1, int p = -1){
    dp[s] = 1;
    sub[s] = 0;
    for(auto &i : g[s]){
        if(i == p)continue;
        dfs(i,s);
        sub[s]+=sub[i];
    }
    dp[s] = dp[s]*f[sub[s]]%mod;
    for(auto &i: g[s]){
        if(i == p)continue;
        dp[s] = dp[s]*dp[i]%mod;
        dp[s] = dp[s]*inv[sub[i]]%mod;
    }
    sub[s]++;
}

void dfs2(int s = 1, int p = -1){
    ans[s] = dp[s];
    for(auto &i:g[s]){
        if(i == p)continue;
        dp[s] = dp[s]*mi(dp[i])%mod;
        dp[s] = dp[s]*f[sub[i]]%mod;
        dp[s] = dp[s]*inv[sub[s]-1]%mod;
        dp[s] = dp[s]*f[sub[s]-sub[i]-1]%mod;
        sub[s]-=sub[i];
        dp[i] = dp[i]*dp[s]%mod;
        dp[i] = dp[i]*inv[sub[s]]%mod;
        dp[i] = dp[i]*inv[sub[i]-1]%mod;
        sub[i] += sub[s];
        dp[i] = dp[i]*f[sub[i]-1]%mod;
        dfs2(i,s);
         dp[i] = dp[i]*inv[sub[i]-1]%mod;
        sub[i]-=sub[s];
         dp[i] = dp[i]*f[sub[i]-1]%mod;
         dp[i] = dp[i]*f[sub[s]]%mod;
         dp[i] = dp[i]*mi(dp[s])%mod;
        sub[s] += sub[i];
         dp[s] = dp[s]*inv[sub[s]-sub[i]-1]%mod;
         dp[s] = dp[s]*f[sub[s]-1]%mod;
         dp[s] = dp[s]*inv[sub[i]]%mod;
         dp[s] = dp[s]*dp[i]%mod;
        //  dp[i] = dp[i]*f[sub[i]-sub[s]-1]%mod;
    }
}

int main(){
    inv[0] = 1;
    inv[1] = 1;
    f[0] = 1;
    f[1] = 1;
    for(int i=2; i<N; ++i)inv[i]=mod-mod/i*inv[mod%i]%mod,f[i]=i;
    for(int i=2; i<N; ++i)inv[i]=inv[i-1]*inv[i]%mod,f[i]=f[i]*f[i-1]%mod;
    scanf("%d",&n);
    for(int i = 1; i < n; ++i){
        scanf("%d%d",&a,&b);
        g[a].emplace_back(b);
        g[b].emplace_back(a);
    }
    dfs();
    // for(int i = 1; i <= n; ++i)printf("FOR i = %d, dp[i] = %lld\n",i,dp[i]);
    // for(int i = 1; i <= n; ++i){
    //     dfs(i,-1);
    //     printf("FOR NODE = %d, dp[i] = %lld\n",i,dp[i]);
    // }
    dfs2();
    for(int i = 1; i <= n; ++i)printf("%lld\n",ans[i]);
    return 0;
}

Measured memory_bytes: 21876
#pragma region header
#pragma GCC target("avx2")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep1(i, n) for (int i = 1; i <= (int)(n); i++)
#define rev(i, n) for(int i = (int)(n - 1); i >= 0; i--)
#define rev1(i, n) for(int i = (int)(n); i > 0; i--)
#define pb push_back
#define all(v) (v).begin(), (v).end()
#define resort(v) sort((v).rbegin(), (v).rend())
#define vi vector<int>
#define vvi vector<vector<int>>
#define vc vector<char>
#define vvc vector<vector<char>>
#define vb vector<bool>
#define vvb vector<vector<bool>>
using ll = long long;
using P = pair<int, int>;
/* ----------------よく使う数字や配列----------------- */
int dx[] = {1,0,-1,0};
int dy[] = {0,1,0,-1};
constexpr ll mod = 1e9+7;
constexpr ll inf = INT32_MAX/2;
constexpr ll INF = LLONG_MAX/2;
constexpr long double eps = DBL_EPSILON;
constexpr long double pi = 3.141592653589793238462643383279;
/* ----------------------end----------------------- */

/* --------------------テンプレート------------------ */
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;
}
/* ----------------------end----------------------- */

/* --------------------ライブラリ-------------------- */
ll fact(int i) {       //階乗
    if (i == 0) return 1;
    return (fact(i - 1)) * i % mod;
}
ll gcd(ll a, ll b) {        //最大公約数
    if(b == 0) return a;
    return gcd(b, a % b); 
}
ll lcm(ll a, ll b) {      //最小公倍数
    return a * b / gcd(a, b);
}
int keta(ll n) {        //桁数を求める
    if(n == 0) return 1;
    int count = 0;
    while(n != 0) {
        n /= 10;
        count++;
    }
    return count;
}
ll ketasum(ll n) {    //各桁の和
    ll sum = 0;
    while(n != 0) {
        sum += n % 10;
        n /= 10;
    }
    return sum;
}
bool isprime(int n) { //素数判定
    if(n==1)return false;
    if(n==2)return true;
    for(int i = 2;i<=sqrt(n);i++) {
        if(n%i==0) return false;
    }
    return true;
}
/* ----------------------end----------------------- */
#pragma endregion
signed main() {
    int a,b,c,d;cin >> a >> b >> c >> d;
    cout << max({a*c,a*d,b*c,b*d}) << endl;
    return 0;
}

Measured memory_bytes: 3676
#include <bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < (n); i++)
using namespace std;
using ll = long long;
using P = pair<int, int>;
const ll mod = 1e9 + 7;

int main() {
  string S;
  cin >> S;
  int n = S.size();
  vector<vector<ll>> dp(n + 1, vector<ll>(13, 0));
  dp.at(0).at(0) = 1;
  rep(i, n) {
    char c = S.at(i);

    if (c == '?') {
      rep(j, 13) {
        rep(k, 10) {
          dp.at(i + 1).at((j * 10 + k) % 13) += dp.at(i).at(j);
          dp.at(i + 1).at((j * 10 + k) % 13) %= mod;
        }
      }
    } else {
      int x = c - '0';
      rep(j, 13) {
        dp.at(i + 1).at((j * 10 + x) % 13) += dp.at(i).at(j);
        dp.at(i + 1).at((j * 10 + x) % 13) %= mod;
      }
    }
  }
  cout << dp.at(n).at(5) << endl;
  return 0;
}

Measured memory_bytes: 13696
n,k = map(int,input().split())
MOD = 10**9 + 7

memo = [-1 for i in range(k+1)]
memo[0] = 1
now = 1
for i in range(1,k+1):
    now = now*(n-k-i)//i
    memo[i] = now%MOD

memo2 = [-1 for i in range(k)]
memo2[0] = 1
now = 1
for i in range(1,k):
    now = now*(k-i)//i
    memo2[i] = now%MOD

for i in range(k):
    ans = 0
    if i == 0:
        print(n-k+1)
    else:
        p = memo2[i]
        r = memo[i-1] + memo[i]*2 + memo[i+1]
        r %=MOD
        ans +=p*r
        ans %=MOD
        print(ans)

Measured memory_bytes: 44912
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i,n) for(ll i = 0; i<n; i++)
int main()
{
	ll K,x;
	cin >> K;
	x = 7%K;
	ll num = 0;

	vector<int> A(K,0);
	int judge = 0;

	while(judge == 0){
		num++;
		if(x==0){
			cout << num;
			judge++;
		}
		
		if(A[x] == 0)
			A[x]++;
		else
			break;
		x = (x*10 + 7)%K;

	}

	if(judge == 0)
		cout << "-1";

	cin >> K;
	
	return 0;	
}


Measured memory_bytes: 7212
#include<bits/stdc++.h>
#include<bitset>
#include<random>
#include<time.h>

using namespace std;

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

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

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

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



// Main Code


int main()
{
  ll n;
  cin>>n;
  ll z = sqrt(n);
  cout<<(z*z)<<endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
      
#define FOR(i,a,b) for( ll i = (a); i < (ll)(b); i++ )
#define REP(i,n) FOR(i,0,n)
#define YYS(x,arr) for(auto& x:arr)
#define ALL(x) (x).begin(),(x).end()
#define SORT(x) sort( (x).begin(),(x).end() )
#define REVERSE(x) reverse( (x).begin(),(x).end() )
#define UNIQUE(x) (x).erase( unique( ALL( (x) ) ) , (x).end() )
#define PW(x) (1LL<<(x))
#define SZ(x) ((ll)(x).size())
#define SHOW(x) cout << #x << " = " << x << endl
#define SHOWA(x,n) for( int yui = 0; yui < n; yui++ ){ cout << x[yui] << " "; } cout << endl

#define pb emplace_back
#define fi first
#define se second

using namespace std;

typedef long double ld;
typedef long long int ll;
typedef pair<int,int> pi;
typedef pair<ll,ll> pl;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<bool> vb;
typedef vector<ld> vd;
typedef vector<pi> vpi;
typedef vector<pl> vpl;
typedef vector<vpl> gr;
typedef vector<vl> ml;
typedef vector<vd> md;
typedef vector<vi> mi;
     
const ll INF = (ll)1e9 + 10;
const ll INFLL = (ll)1e18 + 10;
const ld EPS = 1e-12;
const ll MOD = 1e9+7;
     
template<class T> T &chmin( T &a , const T &b ){ return a = min(a,b); }
template<class T> T &chmax( T &a , const T &b ){ return a = max(a,b); }
template<class T> inline T sq( T a ){ return a * a; }

ll in(){ long long int x; scanf( "%lld" , &x ); return x; }
char yuyushiki[1000010]; string stin(){ scanf( "%s" , yuyushiki ); return yuyushiki; }

// head

int n;
ll a[100010];

vi G[100010];

bool ans = true;

ll dfs( int x , int p ){
  ll cnt = 0;
  vl v(0);
  YYS( w , G[x] ){
    if( w != p ){
      ll res = dfs( w , x );
      v.pb( res );
      cnt += res;
    }
  }
  if( SZ(v) == 0 ){
    return a[x];
  }
  ll ma = *max_element( ALL(v) );
  ll able = cnt - ma;
  ll del = cnt - a[x];
  if( a[x] - del < 0 or del < 0 or able < del ){
    ans = false;
    return 0;
  }
  // cout << x+1 << " " << a[x] - del << endl;
  return a[x] - del;
}

int main(){

  n = in();
  REP( i , n ){
    a[i] = in();
  }

  REP( i , n-1 ){
    int a = in() - 1;
    int b = in() - 1;
    G[a].pb( b );
    G[b].pb( a );
  }

  if( n == 2 ){
    if( a[0] == a[1] ){
      puts( "YES" );
    } else {
      puts( "NO" );
    }
    return 0;
  }

  int root = -1;
  REP( i , n ){
    if( SZ(G[i]) >= 2 ){
      root = i;
      break;
    }
  }

  assert( root != -1 );

  ll res = dfs( root , -1 );
  if( res != 0 ){
    ans = false;
  }

  if( ans ){
    puts( "YES" );
  } else {
    puts( "NO" );
  }
  
  return 0;
}


Measured memory_bytes: 16768
import java.io.*;
import java.util.*;
class Main{
	static final long MOD = 1_000_000_007; // 10^9+7
    static final int MAX = 2_147_483_646; // intMax 
    static final int INF = 1_000_000_000; // 10^9  
    public static void main(String[] args) throws Exception {
		hayami saori = new hayami();
		long h = saori.saorihayami();
		System.out.println(defeat(h));

		saori.close();
	}
	
	public static long defeat(long h){
		if(h == 1)return 1;
		return defeat(h/2)*2 + 1;
	}
}

class hayami implements Closeable {
	private final InputStream in = System.in;
	private final byte[] hayami = new byte[1024];
	private int Hayami = 0;
	private int saori = 0;
	private boolean HayamiSaori() {
		if (Hayami < saori) {
			return true;
		}else{
			Hayami = 0;
			try {
				saori = in.read(hayami);
			} catch (IOException e) {
				e.printStackTrace();
			}
			if (saori <= 0) {
				return false;
			}
		}
		return true;
	}
	private int SaoriHayami() { 
		if (HayamiSaori()) {
            return hayami[Hayami++];
         }else{
             return -1;
         }
	}
	private static boolean hayami_saori(int hayami) { 
		return 33 <= hayami && hayami <= 126;
	}
	public boolean hayamisaori() { 
		while(HayamiSaori() && !hayami_saori(hayami[Hayami])) Hayami++; return HayamiSaori();
	}
	public String nextHayami() {
		if (!hayamisaori()) throw new NoSuchElementException();
		StringBuilder hayamin = new StringBuilder();
		int saori = SaoriHayami();
		while(hayami_saori(saori)) {
			hayamin.appendCodePoint(saori);
			saori = SaoriHayami();
		}
		return hayamin.toString();
	}
	public long saorihayami() {//nextLong
		if (!hayamisaori()) throw new NoSuchElementException();
		long hayami = 0;
		boolean misao = false;
		int saori = SaoriHayami();
		if (saori == '-') {
			misao = true;
			saori = SaoriHayami();
		}
		if (saori < '0' || '9' < saori) {
			throw new NumberFormatException();
		}
		while(true){
			if ('0' <= saori && saori <= '9') {
				hayami *= 10;
				hayami += saori - '0';
			}else if(saori == -1 || !hayami_saori(saori)){
				return misao ? -hayami : hayami;
			}else{
				throw new NumberFormatException();
			}
			saori = SaoriHayami();
		}
	}
	public int saori_hayami() {//nextInt
		long hayami = saorihayami();
		if (hayami < Integer.MIN_VALUE || hayami > Integer.MAX_VALUE) throw new NumberFormatException();
		return (int) hayami;
	}
	public double Hayamin() { //nextDouble
		return Double.parseDouble(nextHayami());
	}
	public void close() {
		try {
			in.close();
		} catch (IOException e) {
		}
    }
    
}

Measured memory_bytes: 22996
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define For(i,n,k) for(ll i=(n);i<(k);i++)
ll n,m,ans=0;
// 素集合データ構造
struct UnionFind
{
  // par[i]：データiが属する木の親の番号。i == par[i]のとき、データiは木の根ノードである
  vector<int> par;
  // sizes[i]：根ノードiの木に含まれるデータの数。iが根ノードでない場合は無意味な値となる
  vector<int> sizes;
  UnionFind(int n) : par(n), sizes(n, 1) {
    // 最初は全てのデータiがグループiに存在するものとして初期化
    for(int i=0;i<n;i++) par[i] = i;
  }

  // データxが属する木の根を得る
  int find(int x) {
    if (x == par[x]) return x;
    return par[x] = find(par[x]);  // 根を張り替えながら再帰的に根ノードを探す
  }
  // 2つのデータx, yが属する木をマージする
  void unite(int x, int y) {
    // データの根ノードを得る
    x = find(x);
    y = find(y);

    // 既に同じ木に属しているならマージしない
    if (x == y) return;

    // xの木がyの木より大きくなるようにする
    if (sizes[x] < sizes[y]) swap(x, y);

    // xがyの親になるように連結する
    par[y] = x;
    sizes[x] += sizes[y];
    // sizes[y] = 0;  // sizes[y]は無意味な値となるので0を入れておいてもよい
  }
  // 2つのデータx, yが属する木が同じならtrueを返す
  bool same(int x, int y) {
    return find(x) == find(y);
  }

  // データxが含まれる木の大きさを返す
  int size(int x) {
    return sizes[find(x)];
  }
};
void Main(){   
    cin>>n>>m;
    UnionFind Tree(n);
    vector<int> a(n);
    For(i,0,n){
      cin>>a.at(i);
    }
    For(i,0,m){
        int x,y;cin>>x>>y;
        Tree.unite(x,y);
    }
    if(n<2*(n-m-1)){
        cout<<"Impossible"<<endl;
        return;
    }
    if(n==m+1){
        cout<<0<<endl;
        return;
    }
    vector<priority_queue<int,vector<int>,greater<int>>> p(n);
    For(i,0,n){
      p.at(Tree.find(i)).push(a.at(i));
    }
    priority_queue<int,vector<int>,greater<int>> all;
    int cnt=0;
    For(i,0,n){
      int t=0;
      while(!p.at(i).empty()){
        int k=p.at(i).top();
        p.at(i).pop();
        if(t==0){
          ans+=k;
          cnt++;
        }
        else{
          all.push(k);
        }
        t++;
      }
    }
    for(;cnt<2*(n-m-1);cnt++){
      ans+=all.top();
      all.pop();
    }
    cout<<ans<<endl;
}
int main(){
    Main();
    return 0;
}

Measured memory_bytes: 6656
import java.util.*;
public class Main {
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
    	int N = sc.nextInt();

      	int a = N % 10;
        if(a == 3){
            System.out.println("bon");
        }else if(a == 0 || a == 1 || a == 6 || a == 8){
            System.out.println("pon");
        }else {
            System.out.println("hon");
        }
    }
}

Measured memory_bytes: 26964
result_all = []
counter = 0
while True:
    N,M,P = map(int, input().split())
    if(N == 0 and M == 0 and P == 0): break
    X = [int(input()) for i in range(N)]
    X_sum = sum(X)
    if(X[M-1] == 0):
        result_all.append(0)
        continue
    result = ((X_sum * 100) - ((X_sum * 100) * (P / 100))) / X[M-1]
    result_all.append(result)

for i in range(len(result_all)):
    print(int(result_all[i]))


Measured memory_bytes: 5628
using System;

namespace atcoderA
{
    class MainClass
    {
        public static void Main(string[] args)
        {
            int[] input = Array.ConvertAll(Console.ReadLine().Split(' '), int.Parse);
            Array.Sort(input);
            Array.Reverse(input);
            int A = input[0];
            int B = input[1];
            int C = input[2];
            Console.WriteLine((10 * A) + B + C);
        }
    }
}


Measured memory_bytes: 11604
/*
    Author:zeke
    
    pass System Test!
    GET AC!!
*/
#include <iostream>
#include <queue>
#include <vector>
#include <iostream>
#include <vector>
#include <string>
#include <cassert>
#include <algorithm>
#include <functional>
#include <cmath>
#include <queue>
#include <set>
#include <stack>
#include <deque>
#include <map>
#include <iomanip>
#include <math.h>
#include <utility>
#include <stack>
#include <bitset>
using ll = long long;
using ld = long double;
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(), (x).end()
#define rep3(var, min, max) for (ll(var) = (min); (var) < (max); ++(var))
#define repi3(var, min, max) for (ll(var) = (max)-1; (var) + 1 > (min); --(var))
#define Mp(a, b) make_pair((a), (b))
#define F first
#define S second
#define Icin(s) \
    ll(s);      \
    cin >> (s);
#define Scin(s) \
    ll(s);      \
    cin >> (s);
template <class T>
bool chmax(T &a, const T &b)
{
    if (a < b)
    {
        a = b;
        return 1;
    }
    return 0;
}
template <class T>
bool chmin(T &a, const T &b)
{
    if (b < a)
    {
        a = b;
        return 1;
    }
    return 0;
}
typedef pair<ll, ll> P;
typedef vector<ll> V;
typedef vector<V> VV;
typedef vector<P> VP;
ll mod = 1e9 + 7;
unsigned long long MOD = 1e9 + 7;
ll INF = 1e18;

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

    int n; // 頂点数
    cin >> n;
    ll m;
    cin >> m;
    m = n - 1 + m; // 辺数

    vector<pair<int, int>> edge(n); // first -> second
 //   cout << "hello" << endl;
    vector<vector<int>> eList(n); // 隣接リスト
    vector<int> inDeg(n, 0);   // 入次数
    rep(i,m)
    {
        ll A,B;
        cin >> A >> B;
        A--;
        B--;
        eList[A].push_back(B);
        inDeg[B]++;
    }
    queue<int> zeroQue; // 入次数 0 の頂点でまだ取られていないものを入れる
    for (int i = 0; i < n; i++)
    {
        if (inDeg[i] == 0){
            zeroQue.push(i);
        }
    }
 //   cout << "hello" << endl;
    V Result(n);
    vector<int> result; // トポロジカルソートの結果を入れる
    while (!zeroQue.empty())
    {
        int u = zeroQue.front(); // 入次数 0 の頂点 u を 1 つ取る
        zeroQue.pop();

        result.push_back(u);
        for (int v : eList[u])
        {               // u を始点とする辺すべてについて、
            inDeg[v]--; // 終点の入次数を減らす
            if (inDeg[v] == 0){
                zeroQue.push(v); // 入次数が 0 になったら取ることができる
                Result[v] = u+1;
             //   cout<<u<<endl;
            }
        }
    }
  //  cout << "hello" << endl;
    rep(i, n)
    {
        cout << Result[i] << endl;
    }
}


Measured memory_bytes: 8824
#include <cstdio>
#include <cstring>
#include <ctime>
#include <cstdlib>
#include <cmath>
#include <iostream>
#include <string>
#include <queue>
#include <map>
#include <stack>
#include <vector>
#include <algorithm>
#include <set>
#include <deque>
#include <utility>
#include <chrono>
#include <sstream>
#include <iomanip>
#define INF 1 << 30
#define MOD 1000000007;
#define pi 3.14159265358979
#define rep(i, n) for (int (i) = 0; (i) < (int)(n); (i)++)
#define rer(i, l, r) for (int (i) = (int)(l); (i) <= (int)(r); (i)++)
#define reu(i, l, r) for (int (i) = (int)(l); (i) < (int)(r); (i)++)
#define D(x) cout << x << endl
#define d(x) cout << x
#define all(x) (x).begin(), (x).end()
#define pub(x) push_back(x)
#define pob() pop_back()
#define puf(x) push_front(x)
#define pof() pop_front()
#define mp(x, y) make_pair((x), (y))
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<double> vd;
typedef vector<long long> vll;
typedef vector<string> vs;
typedef pair<int, int> pii;
typedef pair<long, long> pll;
template<typename T, typename U> inline void amin(T &x, U y) { if (y < x) x = y; }
template<typename T, typename U> inline void amax(T &x, U y) { if (x < y) x = y; }
static const int dx[] = {0, 0, 1, -1};
static const int dy[] = {-1, 1, 0, 0};

int main() { 
  int a, b, c;
  cin >> a >> b  >> c;
  if (a == b && b == c) {
    D(1);
  } else if (a == b || b == c || c == a) {
    D(2);
  } else {
    D(3);
  }
  return 0;
}



Measured memory_bytes: 256
n = int(input())
h = list(map(int, input().split()))

ans = [0]
#右端から順番に見ていき、リストに記録する
for i in range(n-2,-1,-1):
    if h[i] >= h[i+1]:
        ans.append(ans[len(ans)-1]+1)
    else:
        ans.append(0)

ans.reverse()
#この反転は問題を解くうえでは不要
#ansの並びがhの並びと一致するようにした

print(max(ans)) 

    

Measured memory_bytes: 20444
S=input()
T=input()
if len(S)==1:
	if S[0]==T[0]:
		print("Yes")
	else:
		print("No")
elif len(S)>=2:
	if S in T:
		if S[0]==T[0] and S[1]==T[1]:
			print("Yes")
		else:
			print("No")
	else:
		print("No")

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

using namespace std;

#define DUMP(x) std::cerr << (#x) << " = " << (x) << "\n"
#define REP(i, a, b) for (int i = (int)(a); i < (int)(b); ++i)
#define EREP(i, a, b) for (int i = (int)(a); i <= (int)(b); ++i)
#define RREP(i, a, b) for (int i = (int)(a)-1; i >= (int)(b); --i)
#define rep(i, n) REP(i, 0, n)
#define erep(i, n) EREP(i, 0, n)
#define rrep(i, n) for (int i = (int)(n)-1; i >= 0; --i)
#define ALL(r) r.begin(), r.end()
#define YES cout << "YES\n"
#define Yes cout << "Yes\n"
#define NO cout << "NO\n"
#define No cout << "No\n"
#define IMP cout << "IMPOSSIBLE\n"
#define Imp cout << "Impossible\n"
#define imp cout << "impossible\n"
#define M1 cout << "-1\n"
#define pb push_back
#define eb emplace_back
#define fi first
#define se second

template <typename T>
ostream &operator<<(ostream &os, vector<T> &v)
{
    os << "{";
    rep(i, v.size()) os << v[i] << (i == (int)v.size() - 1 ? "" : ", ");
    os << "}";
    return os;
}
template <typename T, typename U>
ostream &operator<<(ostream &os, pair<T, U> &p) { return (os << "(" << p.first << ", " << p.second << ")"); }
template <typename T, typename U>
ostream &operator<<(ostream &os, map<T, U> &m)
{
    bool first = true;
    os << "{";
    for (auto e : m)
    {
        if (!first)
            os << ", ";
        os << "{" << e.first << ": " << e.second << "}";
        first = false;
    }
    os << "}";
    return os;
}
template <typename T>
T dup(T x, T y) { return (x + y - 1) / y; };
template <typename A, size_t N, typename T>
inline void arrayFill(A (&array)[N], const T &val) { std::fill((T *)array, (T *)(array + N), val); }
struct in
{
    const size_t n = 0;
    in() = default;
    in(size_t n) : n(n){};
    template <typename T>
    operator T()
    {
        T ret;
        cin >> ret;
        return ret;
    }
    template <typename T>
    operator vector<T>()
    {
        assert(n != 0);
        vector<T> ret(n);
        for (auto &x : ret)
            x = in();
        return ret;
    }
    template <typename T, typename U>
    operator pair<T, U>()
    {
        pair<T, U> ret;
        ret.first = in();
        ret.second = in();
        return ret;
    }
};

using ll = int64_t;
using vint = vector<int32_t>;
using vvint = vector<vint>;
using vll = vector<ll>;
using vvll = vector<vll>;
using vstr = vector<string>;
using pint = pair<int32_t, int32_t>;
using vpint = vector<pint>;
using pll = pair<ll, ll>;
using vpll = vector<pll>;
using setint = set<int32_t>;
using setstr = set<string>;
using qint = queue<int32_t>;
using qpint = queue<pint>;

constexpr std::int32_t INF = 1001001001;
constexpr std::int64_t LINF = 1001001001001001001;

void Main()
{
    ll n = in(), m = in();
    vll a = in(n);

    vll sum(n + 1, 0);
    rep(i, n) sum[i + 1] = sum[i] + a[i];

    map<ll, ll> mp;
    rep(i, n + 1) mp[sum[i] % m]++;

    ll ans = 0;
    for (auto e : mp)
        ans += e.se * (e.se - 1) / 2;

    cout << ans << endl;
}

signed main()
{
    std::cin.tie(nullptr);
    std::ios_base::sync_with_stdio(false);
    std::cout << std::fixed << std::setprecision(15);
    Main();
    return 0;
}


Measured memory_bytes: 5760
#include<iostream>
#include<cstdio>
#include<string>
#include<cstring>
#include<cmath>
using namespace std;
int main()
{
    int n,m;
    cin>>n>>m;
    int num=n-m;
    cout << (m*1900+num*100)*pow(2,m) << endl;
    return 0;
}


Measured memory_bytes: 256
M=10**9+7
r=[[(j-k)*9%13 for j in range(10)]for k in range(13)]
d=[1]+[0]*12
for c in input():
    d = [sum(d[j]for j in k)%M for k in r] if c>'9' else [d[(int(c)-k)*9%13]for k in range(13)]
print(d[5])

Measured memory_bytes: 3188
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
#define INF 1<<30
#define LINF 1LL<<60

/*
 <url:http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=2595>
 ?????????============================================================
 D??\??§N??????????????????????£????????????????????£???????????????°????±??????????
 ?????????????????\????£????????????°???X???????????§???????????°????????????
 =================================================================
 ?§£??¬=============================================================
 dp[i][j] := i??\??§j????£?????????´????????°
 
 ================================================================
 */

const ll MOD = 1e9+7;
ll powmod(ll a,ll b) {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;}
vector<ll> inv(2001,0);
void init_inv(){
    inv[0] = inv[1] = 1;
    for(int i = 2; i <= 2000;i++){
        inv[i] = powmod(i,MOD-2)%MOD;
    }
}

int main(void) {
    cin.tie(0); ios::sync_with_stdio(false);
    init_inv();
    ll N,D,X;
    vector<vector<ll>> dp;
    while(cin >> N >> D >> X){
        if(N == 0 && D == 0 && X == 0)break;
        dp.assign(N+1,vector<ll>(N+1,0));
        dp[0][0] = 1;
        for(int i = 0; i < N;i++){
            for(int j = i; j < N;j++){
                dp[i+1][j+1] = (dp[i+1][j] + dp[i][j])%MOD;
                if(j + 1 >= X){
                    dp[i+1][j+1] = (dp[i+1][j+1] - dp[i][j - X + 1] + MOD)%MOD;
                }
            }
        }
        
        ll res = 0;
        for(int i = 1; i <= min(N,D);i++){
            ll T = dp[i][N];
            for(int j = 0; j < i;j++){
                (T = (D - j)%MOD * T%MOD)%=MOD;
                (T = T*inv[i-j])%=MOD;
            }
            (res+=T)%=MOD;
        }
        cout << res << endl;
    }
    return 0;
}

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

#define INF INT_MAX

using namespace std;

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

int main(void){
 	cin.tie(0);
    ios::sync_with_stdio(false);
    int n,k;
    cin >> n >> k;

    cout << n - k  + 1<< endl;

	return 0;
}

Measured memory_bytes: 256
//#include <bits/stdc++.h>
#include <iostream>
#include <vector>
#include <string>
using namespace std;
typedef long long ll;
const double EPS = 1e-9;
typedef vector<int> vint;
typedef pair<int, int> pint;
#define inf 1e+9
#define rep(i, n) REP(i, 0, n)
#define all(v) v.begin(), v.end()
#define msg(a) cout << #a << " " << a << endl;
#define REP(i, x, n) for(int i = x; i < n; i++)
#define pri(a) cout << a << endl;

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

  ll n,ans=0,sum=0;
  cin >> n;
  //ll n,k,ans=0;
  //cin >> n >> k;
  // string s;
  // cin >> s;

  vint v(n);
	rep(i,n){
		cin >> v[i];
    sum += v[i];
	}

  rep(i,n){
    ans += v[i];
    if(ans+v[i+1]>sum/2){
        cout << min(sum-ans-ans,sum-2*(sum-(ans+v[i+1]))) << endl;
        //cout << sum-ans-ans << endl;
        //cout << (sum-(ans+v[i+1]));
        return 0;
    }
    //cout << ans+v[i+1] << sum << endl;
  }
}


Measured memory_bytes: 1024
N,M = map(int,input().split())
if N==1:
    nmax=M
else:
    nmax = 1
    for i in range(2,int(M**0.5)+1):
        if M%i==0 and M//i>=N:
            nmax = max(nmax,i)
        if M%i==0 and i>=N:
            nmax = max(nmax,M//i)
print(nmax)

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

#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4")

#define ll long long
#define f first
#define s second
#define pb push_back
#define mp make_pair
#define o cout<<"BUG"<<endl;
#define	IOS ios_base::sync_with_stdio(0);
#define en "\n"
#define FOR(i, j, n) for(int j = i; j < n; ++j)
#define forn(i, j, n) for(int j = i; j <= n; ++j)
#define nfor(i, j, n) for(int j = n; j >= i; --j)
#define sortv(vv) sort(vv.begin(), vv.end())
#define all(v) v.begin(), v.end()
#define ld long double
#define ull unsigned long long

//mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
using namespace std;
const ll maxn=2e5+100,inf=1e9,LOG=23,mod=1e9+7;
ll block = 300, timer = 0;
const ld EPS = 1e-7;

#define bt(i) (1 << (i))
#define int ll
#define y1 yy
#define pii pair <int, int>

int n, pu[4*maxn], t[4*maxn], ans;
vector <int> edge[maxn];

void upd(int v, int tl, int tr, int l, int r, int val)
{
	if(l <= tl && tr <= r)
	{
		t[v] += val * (tr - tl + 1);
		pu[v] += val;
		return;
	}
	if(l > tr || r < tl) return;
	int mid = (tl + tr) / 2;
	t[v * 2] += pu[v] * (mid - tl + 1);
	pu[v * 2] += pu[v];
	t[1 + v * 2] += pu[v] * (tr - mid);
	pu[1 + v * 2] += pu[v];
	pu[v] = 0;
	upd(v * 2, tl, (tl + tr) / 2, l, r, val);
	upd(v * 2 + 1, (tl + tr) / 2 + 1, tr, l, r, val);
	t[v] = t[v * 2] + t[v * 2 + 1];
}

main()
{
	IOS
	cin >> n;
	forn(1, i, n - 1)
	{
		int l, r;
		cin >> l >> r;
		if(l > r) swap(l, r);
		edge[r].pb(l);
	}
	forn(1, i, n)
	{
		edge[i].pb(0);
		sort(all(edge[i]));
		reverse(all(edge[i]));
		int cur = 1;
		int last = i;
		for(auto to : edge[i])
		{
			upd(1, 1, n, to + 1, last, cur);
//			cout << to + 1 << " " << last << " " << cur << " " << t[1] << endl;
			cur--;
			last = to;
		}
		ans += t[1];
	}
	cout << ans;
}

Measured memory_bytes: 24660
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(int)(n);i++)

int main(){
    int n; cin >> n;
    vector<pair<int,int>> p(n);
    rep(i,n){
        int x,l;
        cin >> x >> l;
        p.at(i)=make_pair(x+l,x-l);
    }
    sort(p.begin(),p.end());
    int ans=0;
    int t=p.at(0).second;
    rep(i,n){
        if(t<=p.at(i).second){
            ans++;
            t=p.at(i).first;
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 3988
// The Last Ant
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		while (true) {
			int n = sc.nextInt();
			int l = sc.nextInt();
			if ((n | l) == 0) {
				break;
			}
			char[] d = new char[n];
			int[] p = new int[n];
			for (int i = 0; i < n; i++) {
				d[i] = sc.next().charAt(0);
				p[i] = sc.nextInt();
			}
			int time = 0;
			int last = -1;
			while (n > 0) {
				time++;
				for (int i = 0; i < d.length; i++) {
					if (p[i] == -1)
						continue;
					if (d[i] == 'L' && p[i] > 0)
						p[i]--;
					if (d[i] == 'R' && p[i] < l)
						p[i]++;
				}
				for (int i = 0; i < p.length; i++) {
					if (p[i] == l) {
						last = i;
						p[i] = -1;
						n--;
					}
				}
				for (int i = 0; i < p.length; i++) {
					if (p[i] == 0) {
						last = i;
						p[i] = -1;
						n--;
					}
				}
				for (int i = 0; i < p.length; i++) {
					if (p[i] == -1)
						continue;
					for (int j = i + 1; j < p.length; j++) {
						if (p[i] == p[j]) {
							char temp = d[i];
							d[i] = d[j];
							d[j] = temp;
						}
					}
				}
			}
			System.out.println(time + " " + (last + 1));
		}
		sc.close();
	}
}

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

class Program
{
    static void Main()
    {
        var N = int.Parse(ReadLine());
        var d = ReadLine().Split().Select(int.Parse).ToArray();
        Array.Sort(d);
        WriteLine(d[N / 2] - d[N / 2 - 1]);
    }
}


Measured memory_bytes: 20064
using System;
using System.Linq;

class C
{
	static void Main() => Console.WriteLine(Enumerable.Range(int.Parse(Console.ReadLine()), 99).First(IsPrime));

	static bool IsPrime(int n)
	{
		for (int x = 2; x < n; ++x) if (n % x == 0) return false;
		return n > 1;
	}
}


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

#define IL __inline__ __attribute__((always_inline))

#define For(i, a, b) for (int i = a, i##end = b; i <= i##end; ++ i)
#define FOR(i, a, b) for (int i = a, i##end = b; i < i##end; ++ i)
#define Rep(i, a, b) for (int i = a, i##end = b; i >= i##end; -- i)
#define REP(i, a, b) for (int i = (a) - 1, i##end = b; i >= i##end; -- i)

typedef long long LL;

template <class T>
IL bool chkmax(T &a, const T &b) {
  return a < b ? ((a = b), 1) : 0;
}

template <class T>
IL bool chkmin(T &a, const T &b) {
  return a > b ? ((a = b), 1) : 0;
}

template <class T>
IL T mymax(const T &a, const T &b) {
  return a > b ? a : b;
}

template <class T>
IL T mymin(const T &a, const T &b) {
  return a < b ? a : b;
}

template <class T>
IL T myabs(const T &a) {
  return a > 0 ? a : -a;
}

const int INF = 0X3F3F3F3F;
const double EPS = 1E-10, PI = acos(-1.0);

#define DEBUG(...) fprintf(stderr, __VA_ARGS__)
#define OK DEBUG("Passing [%s] in LINE %d...\n", __FUNCTION__, __LINE__)
/*------------------------------header------------------------------*/

const int MAXN = 2000 + 5, MAXM = 4000000 + 5, MOD = 1000000007;

IL int add(int a, int b) {
  a += b;
  return a >= MOD ? a - MOD : a;
}

template<class ...Args>
IL int add(int a, const Args &...args) {
  a += add(args...);
  return a >= MOD ? a - MOD : a;
}

IL int sub(int a, int b) {
  a -= b;
  return a < 0 ? a + MOD : a;
}

IL int mul(int a, int b) {
  return (LL)a * b % MOD;
}

template<class ...Args>
IL int mul(int a, const Args &...args) {
  return (LL)a * mul(args...) % MOD;
}

IL int quickPow(int a, int p) {
  int result = 1;
  for (int base = a; p; p >>= 1, base = mul(base, base)) {
    if (p & 1) {
      result = mul(result, base);
    }
  }
  return result;
}

int fac[MAXM], ifac[MAXM], f[MAXN][MAXN];

IL void init(int n) {
  fac[0] = 1;
  For(i, 1, n) {
    fac[i] = mul(fac[i - 1], i);
  }
  ifac[n] = quickPow(fac[n], MOD - 2);
  REP(i, n, 0) {
    ifac[i] = mul(ifac[i + 1], i + 1);
  }
}

IL int binom(int n, int m) {
  return mul(fac[n], ifac[m], ifac[n - m]);
}

int main() {
  int n, k;
  scanf("%d%d", &n, &k);
  if (k == 1) {
    printf("%d\n", 1);
    exit(0);
  }
  init(n * k);
  f[0][0] = 1;
  For(j, 1, n) {
    f[0][j] = mul(f[0][j - 1], binom(j * (k - 1) - 1, k - 2));
  }
  For(i, 1, n) {
    For(j, i, n) {
      f[i][j] = add(f[i - 1][j], mul(f[i][j - 1], binom(j * (k - 1) + i - 1, k - 2)));
    }
  }
  printf("%d\n", mul(f[n][n], fac[n]));
  return 0;
}

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

namespace 競プロ_Csharp {
    class Program {
        static void Main(string[] args) {

            int[,] ar1 = new int[3, 10];
            int[,] ar2 = new int[3, 10];
            int[,] ar3 = new int[3, 10];
            int[,] ar4 = new int[3, 10];

            int n = NextInt();
            for (int i = 0; i < n; i++) {

                int[] temp = NextInts();
                int b = temp[0], f = temp[1], r = temp[2], v = temp[3];

                switch (b) {
                    case 1:
                        ar1[f - 1, r - 1] += v;
                        break;
                    case 2:
                        ar2[f - 1, r - 1] += v;
                        break;
                    case 3:
                        ar3[f - 1, r - 1] += v;
                        break;
                    case 4:
                        ar4[f - 1, r - 1] += v;
                        break;
                }

            }

            PrintIntMap(ar1);
            Println("####################");
            PrintIntMap(ar2);
            Println("####################");
            PrintIntMap(ar3);
            Println("####################");
            PrintIntMap(ar4);

        }

        public static void PrintIntMap (int[,] ar) {
            for (int i = 0; i < ar.GetLength(0); i++) {
                for (int j = 0; j < ar.GetLength(1); j++) {
                    Print(" " + ar[i, j]);
                }
                Println("");
            }
        }

        public static void Print (Object o) {
            Console.Write(o);
        }

        public static void Println (Object o) {
            Console.WriteLine(o);
        }

        public static string NextString() {
            return Console.ReadLine();
        }

        public static string[] NextStrings () {
            return Console.ReadLine().Split();
        }

        public static int NextInt () {
            return int.Parse(Console.ReadLine());
        }

        public static int[] NextInts () {
            string[] a = Console.ReadLine().Split();
            int[] b = new int[a.Length];
            for (int i = 0; i < a.Length; i++) {
                b[i] = int.Parse(a[i]);
            }
            return b;
        }

        public static double NextDouble () {
            return double.Parse(Console.ReadLine());
        }

    }
}



Measured memory_bytes: 17900
using System;
using System.Collections;
using System.Collections.Generic;
using System.Text;


public class Atk
{
	public int Type { get; private set; }  // 0:A, 1:B
	public long Damage { get; private set; }

	public Atk(int type, long damage)
	{
		Type = type;
		Damage = damage;
	}
}


public class D
{
	public static void Main()
	{
		string[] args;
		
		args = Console.ReadLine().Split(' ');
		int N = Int32.Parse(args[0]);
		long H = Int64.Parse(args[1]);

		List<Atk> atks = new List<Atk>(N);
		for(int i = 0; i < N; i++)
		{
			args = Console.ReadLine().Split(' ');
			long a = Int32.Parse(args[0]);
			long b = Int32.Parse(args[1]);
			atks.Add(new Atk(0, a));
			atks.Add(new Atk(1, b));
		}
		atks.Sort((x,y) => (int)(y.Damage - x.Damage));

		long rest = H;
		long ans = 0;
		for(int i = 0; i < 2 * N; i++)
		{
			Atk atk = atks[i];
			if(atk.Type == 1)
			{
				rest -= atk.Damage;
				ans++;
				if(rest <= 0)
					break;
			}
			else
			{
				ans += (rest + atk.Damage - 1)/atk.Damage;
				break;
			}
		}

		Console.WriteLine(ans);
	}
}





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

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

  int n = s.size() ;
  //vector<int> a(n) ;
  int ans = 0 ;
  for (int i = 0; i < n; i++) {
    int d = s.at(i) - '0' ;
    ans += d ;
    ans %= 9 ;
  }

  if ( ans == 0 ) {
    cout << "Yes" << endl ;
  }else {
    cout << "No" << endl ;
  }
  
  return 0 ;
}

Measured memory_bytes: 3668
use proconio::input;
#[allow(unused_imports)]
use proconio::marker::*;
#[allow(unused_imports)]
use std::cmp::*;
#[allow(unused_imports)]
use std::collections::*;
#[allow(unused_imports)]
use std::f64::consts::*;

#[allow(unused)]
const INF: usize = std::usize::MAX / 4;
#[allow(unused)]
const M: usize = 1000000007;

fn main() {
    input! {
        n: usize,
        k: usize,
    }

    let mut factors = vec![];
    for d in 1.. {
        if d * d > n {
            break;
        }
        factors.push(d);
        factors.push(n / d);
    }
    factors.sort();
    factors.dedup();
    let m = factors.len();

    let mut dp = vec![vec![0; m]; k];
    dp[0][0] = 1;
    for f in 1..m {
        dp[0][f] = factors[f] - factors[f - 1];
    }
    for i in 1..k {
        for j in 0..m {
            dp[i][j] = dp[i - 1][m - j - 1];
        }
        for j in (1..m).rev() {
            dp[i][j - 1] = (dp[i][j - 1] + dp[i][j]) % M;
        }
        for j in 1..m {
            dp[i][j] = dp[i][j] * (factors[j] - factors[j - 1]) % M
        }
    }

    let mut result = 0usize;
    for j in 0..m {
        result = (result + dp[k - 1][j]) % M;
    }
    println!("{}", result);
}


Measured memory_bytes: 52080
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Arrays;

public class Main {
    public static void main(String[] args) throws IOException {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        String in[] = br.readLine().split(" ");
        int n = Integer.parseInt(in[0]);
        int k = Integer.parseInt(in[1]);
        in = br.readLine().split(" ");
        int arr[]=new int[n];
        int dp[] = new int[n];
        for(int i=0;i<n;i++){
            arr[i]=Integer.parseInt(in[i]);
        }
        Arrays.fill(dp,Integer.MAX_VALUE);
        dp[0]=0;
        for(int i=0;i<n;i++){
            for(int j=i+1;j<=Math.min(i+k,n-1);j++){
                dp[j]=Math.min(Math.abs(arr[i]-arr[j])+dp[i], dp[j]);
            }
        }
        System.out.println(dp[n-1]);
    }
}


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

int main() {
    int n;
    cin >> n;
    vector<int> l(n);
    for (auto& e : l) cin >> e;
    sort(begin(l), end(l));

    int ans = 0;
    for (int i = 0; i + 2 < n; i++) {
        for (int j = i + 1; j + 1 < n; j++) {
            auto itr = lower_bound(begin(l) + j + 1, end(l), l[i] + l[j]);
            ans += itr - (begin(l) + j + 1);
        }
    }

    cout << ans << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <vector>
#include <string>
#include <map>
#include <queue>
#include <stack>
#include <algorithm>

#define rep(i,j) REP((i), 0, (j))
#define REP(i,j,k) for(int i=(j);(i)<(k);++i)
#define between(a,x,b) ((a)<=(x)&&(x)<=(b))
using namespace std;

int main(){
  int a, b;
  while(scanf("%d%d", &a, &b) && (a||b)){
    int change = b - a;
    int res[] = {0,0,0};
    while(change){
      if(change >= 1000){ change-=1000; res[2]++;}
      else if(change >= 500){ change-=500; res[1]++;}
      else {change-=100; res[0]++;}
    }

    printf("%d %d %d\n", res[0], res[1], res[2]);
  }
  return 0;
}

Measured memory_bytes: 1188
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rep1(i, n) for(int i = 1; i <= (n); i++)
#define co(x) cout << (x) << "\n"
#define cosp(x) cout << (x) << " "
#define ce(x) cerr << (x) << "\n"
#define cesp(x) cerr << (x) << " "
#define pb push_back
#define mp make_pair
#define Would
#define you
#define please

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


	int N;
	cin >> N;
	int A[100001];
	rep1(i, N) {
		int a;
		cin >> a;
		A[a] = i + 1;
	}
	int daishou[100004] = {};
	daishou[0] = 2;
	daishou[N + 3] = N + 1;

	ll kotae = 0;
	rep1(i, N) {
		int a = A[i];
		int l = daishou[a - 1];
		if (!l) l = a;
		int r = daishou[a + 1];
		if (!r) r = a;
		int l2 = daishou[l - 2];
		if (!l2) l2 = l - 1;
		int r2 = daishou[r + 2];
		if (!r2) r2 = r + 1;

		kotae += ((ll)(r2 - r) * (a - l + 1) + (ll)(l - l2) * (r - a + 1)) * i;

		daishou[l] = r;
		daishou[r] = l;
	}

	co(kotae);

	Would you please return 0;
}

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

int main() {
  // 入力
  int N;
  cin >> N;
  vector<int> A;
  for (int i=0; i<N; i++) {
    int A_tmp;
    cin >> A_tmp;
    A.push_back(A_tmp);
  }
  
  sort(A.begin(), A.end());

  string result = "YES";
  for (int i=0; i<N-1; i++) {
    if (A.at(i)==A.at(i+1)) {
      result = "NO";
      break;
    }
  }

  // 出力
  cout << result << endl;
  return 0;
}

Measured memory_bytes: 1400
import java.util.Scanner;


public class Main{

	public static void main(String args[]){

		Scanner sc = new Scanner(System.in);

		int n =sc.nextInt();
		int h[]=new int[n];

		int count=0;
		boolean start=false;


		for(int i=0;i<n;++i){
			h[i]=sc.nextInt();
		}

		for(int num=1;num<=100;++num){
			start=false;
			for(int i=0;i<n;++i){
				if(h[i]!=0){
					if(start==false){
						start =true;
						++count;
					}
					h[i]=h[i]-1;
				}
				else start=false;
			}
		}

		System.out.println(count);


	}
}

Measured memory_bytes: 21844
#include <iostream>
#include <iomanip>
#include <fstream>
#include <sstream>
#include <vector>
#include <algorithm>
#include <math.h>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <stack>
#include <bitset>

#define _GLIBCXX_DEBUG
#define rep(i, n) for (int64_t i = 0; i < (int64_t)(n); i++)
using namespace std;
using vi = vector<int64_t>;
using vvi = vector<vi>;

int main(int argc, const char * argv[]) {
    // fasten cin
    cin.tie(0);
    ios::sync_with_stdio(false);
    // implement
    int64_t n,r;
    cin >> n >> r;
    if(n<=10){
        r +=  (10 - n ) * 100;
    }
    cout << r << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
/*
    s.find_by_order(k) ---> returns iterator to the element at index(from 0) k
    s.order_of_key(val) ---> number of elements that are strictly smaller than the given value
*/
typedef long long int ll;
typedef unsigned long long ull;
typedef long double ld;
typedef vector<int> vi;
typedef vector<long long int> vl;
typedef vector<vector<int>> vvi;
typedef vector<vector<long long int>> vvl;
typedef pair<int, int> pii;
typedef pair<long long int, long long int> pll;
typedef vector<pair<int, int>> vii;
typedef vector<pair<long long int, long long int>> vll;
#define fast() ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define test() long long int tc; cin >> tc; cin.ignore(); while(tc--) 
#define ff first
#define ss second
#define pb push_back
#define pf push_front
#define mp make_pair
#define MOD 1000000007
#define SMOD 998244353
#define pq priority_queue
#define all(x) x.begin(),x.end()
#define SP(x) setprecision(x)
#define sp " "
#define inp(a) ll a;cin>>a;cin.ignore()
#define inps(a,b) ll a,b;cin>>a>>b;cin.ignore()
#define out(a) cout<<SP(20)<<a<<'\n'
#define outs(a,b) cout<<SP(20)<<a<<" "<<b<<'\n'
#define ins insert
#define er erase
#define lb lower_bound
#define ub upper_bound
#define printclock cerr<<"Time : "<<1000*(ld)clock()/(ld)CLOCKS_PER_SEC<<"ms\n";
#define inpa(a,n) ll a[n]; for(int i=0; i<n; i++){cin>>a[i];}
#define inpv(a,n) vl a; for(int i=0; i<n; i++){inp(x);a.pb(x);}
#define outa(a,n) for(int i=0;i<n;i++){cout<<a[i]<<" ";}cout<<'\n';
#define outv(v) for(auto i:v){cout<<i<<" ";}cout<<'\n';
set<char> vow = {'a','e','i','o','u','A','E','I','O','U'};
ll xpow(ll n, ll m){if(m==0){return 1;}else{ll x = xpow(n, m/2);if(m&1){return x*x*n;}else{return x*x;}}}
ll xmod(ll a, ll m){return (((a%m)+m)%m);}
ll xmodpow(ll n, ll m, ll y){if(m==0){return 1;}else{ll x = xmodpow(n, m/2, y);if(m&1){return xmod((xmod((xmod(x,y)*xmod(x,y)),y)*xmod(n,y)),y);}else{return xmod((xmod(x,y)*xmod(x,y)),y);}}}

int main() {
	fast();

    /*NA – JEONG – MO – SA – JI – MI – DA – CHAE – TZU*/
    
    inps(n, m);
    if(n==m){
        cout << "Yes";
    }
    else{
        cout << "No";
    }
}

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

int main() {
    string arr[7] = {"MON","TUE","WED","THU","FRI","SAT","SUN"};
    string s;
    cin >> s;
    if (s == "SUN") {
        cout << 7;
        return 0;
    }
    for (int i = 0; i < 7; i++) {
        if (arr[i] == s) {
            cout << 7 - i - 1;
            break;
        }
    }
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for (ll i = 0; i < (n); i++)
#define all(x) (x).begin(), (x).end()
using ll = long long;
using namespace std;
template <typename T> using vec = std::vector<T>;

struct Sieve {
    int n;
    vector<int> f, primes;
    Sieve(int n = 1) : n(n), f(n + 1) {
        f[0] = f[1] = -1;
        for (ll i = 2; i <= n; ++i) {
            if (f[i]) continue;
            primes.push_back(i);
            f[i] = i;
            for (ll j = i * i; j <= n; j += i) {
                if (!f[j]) f[j] = i;
            }
        }
    }
    bool isPrime(int x) {
        return f[x] == x;
    }
    vector<int> factorList(int x) {
        vector<int> res;
        while (x != 1) {
            res.push_back(f[x]);
            x /= f[x];
        }
        return res;
    }
    vector<pair<int, int>> factor(int x) {
        vector<int> fl = factorList(x);
        if (fl.size() == 0) return {};
        vector<pair<int, int>> res(1, pair<int, int>(fl[0], 0));
        for (int p : fl) {
            if (res.back().first == p) {
                res.back().second++;
            } else {
                res.emplace_back(p, 1);
            }
        }
        return res;
    }
};


int main() {
    int N;
    cin >> N;
    Sieve sieve(N);
    map<int,ll> mp;

    for(int i=2;i<=N;++i){
        for(auto e:sieve.factor(i)){
           mp[e.first]+=e.second;
        }
    }

    ll ans = 1;
    for(auto [f,e]:mp){
        // cout << f <<" " <<e << endl;
        ans*=(e+1);
        ans%=(ll)(1e9+7);
    }
    cout << ans << '\n';
}


Measured memory_bytes: 3632