akhauriyash/Code-Regression huggingface dataset:
#define _USE_MATH_DEFINES
#include<iostream>
#include<string>
#include<queue>
#include<cmath>
#include<map>
#include<set>
#include<list>
#include<iomanip>
#include<vector>
#include<random>
#include<functional>
#include<algorithm>
#include<stack>
#include<cstdio>
#include<cstring>
#include<bitset>
#include<unordered_map>
#include<climits>
#include<fstream>
#include<time.h>
#include<cassert>

using namespace std;
typedef long long ll;
typedef long double ld;
#define all(a) (a).begin(),(a).end()
#define EPS (1e-13)
#define bit(n,k) ((n>>k)&1)
const ll Mod = 1e9 + 7;
const ll mod = 998244353;
struct H {
	ll x, y;
	bool operator<(const H& b) const {
		if (x != b.x) return x < b.x;
		return y < b.y;
	}
	bool operator>(const H& b) const {
		if (x != b.x) return x > b.x;
		return y > b.y;
	}
	bool operator==(const H& b) const { return x == b.x && y == b.y; }
	bool operator!=(const H& b) const { return (*this) != b; }
};
struct P {
	ll pos, cost;
	bool operator<(const P& b) const { return cost < b.cost; }
	bool operator>(const P& b) const { return cost > b.cost; }
};
struct B {
	ll to, cost;
};
struct E {
	ll from, to, cost;
	bool operator<(const E& b) const { return cost < b.cost; }
	bool operator>(const E& b) const { return cost > b.cost; }
};
template<typename T, typename U>
void chmin(T& a, U b) {
	if (a > b) a = b;
}
template<typename T, typename U>
void chmax(T& a, U b) {
	if (a < b) a = b;
}
template<typename T>
T max_0(T a) {
	if (a < 0) return 0;
	return a;
}
template<typename T>
T min_0(T a) {
	if (a > 0) return 0;
	return a;
}
ll read() {
	ll u;
	ll k = scanf("%lld", &u);
	return u;
}
ll gcd(ll i, ll j) {
	if (i > j) swap(i, j);
	if (i == 0) return j;
	return gcd(j % i, i);
}
ll mod_pow(ll x, ll n, ll p) {
	ll res = 1;
	while (n > 0) {
		if (n & 1) res = res * x % p;
		x = x * x % p;
		n >>= 1;
	}
	return res;
}//x^n%p
ll bitcount(ll x) {
	int sum = 0;
	for (int i = 0; i < 20; i++)
		if ((1ll << i) & x) sum++;
	return sum;
}
/*ll fact_[200000];
ll comb(ll x, ll y, ll mod = Mod) {
	if (!fact_[0]) {
		fact_[0] = 1;
		for (int i = 1; i < 200000; i++) {
			fact_[i] = fact_[i - 1] * i % mod;
		}
	}
	if (x < y) return 0;
	return mod_pow(fact_[x], mod, mod) *
		mod_pow(fact_[x - y], mod - 2, mod) % mod *
		mod_pow(fact_[y], mod - 2, mod) % mod;
}//xCy*/
const ll Inf = 3023372036854775807;
const int inf = 1500000000;
#define int long long
//----------------------------------------------------
int n;
vector<H>a[20];
int b[20];
signed main() {
	cin >> n;
	for (int i = 0; i < n; i++) {
		int u = read();
		for (int j = 0; j < u; j++) {
			int u, v;
			cin >> u >> v;
			u--; 
			a[i].push_back(H{ u,v });
		}
	}
	int ans = 0;
	for (int i = 0; i < (1ll << n); i++) {
		for (int j = 0; j < n; j++) {
			if ((1ll << j) & i) {
				for (int z = 0; z < a[j].size(); z++) {
					if (a[j][z].y != (((1ll << a[j][z].x) & i) > 0)) {
						goto loop;
					}
				}
			}
		}
		ans = max(ans, bitcount(i));
	loop:;
	}
	cout << ans << endl;
}

Measured memory_bytes: 256
from collections import defaultdict
n = int(input())
S = list(input())

d = [defaultdict(int) for i in range(3)]
for s in S:
    for x in d[1]:
        d[2][x+s]+=1
    for x in d[0]:
        d[1][x+s]+=1
    d[0][s]+=1
print(len(d[2]))

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

using namespace std;

int main(){
  int n, m, x=0;
  cin >> n >> m;
  vector<int> l(m, 0);
  
  for(int i=0; i<n; i++){
    int k;
    cin >> k;
    for(int j=0; j<k; j++){
      int t;
      cin >> t;
      l[t-1] += 1;
    }
  }
  
  for(int i=0; i<m; i++){
    if(l[i] == n){
      x += 1;
    }
  }
  cout << x << endl;
}

Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {
	public static void main(String[] args) throws IOException {
		int[] rank = new int[3];
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		for (int i = 0; i < 10; i++) {
			String s = br.readLine();
			int v = Integer.parseInt(s, 10);
			for (int j = 0; j < rank.length; j++) {
				if (v > rank[j]) {
					int pre = rank[j];
					rank[j] = v;
					v = pre;
				}
			}

		}
		for (int i = 0; i < 3; i++) {
			System.out.println(rank[i]);
		}

	}
}

Measured memory_bytes: 9332
#include <iostream>
#define min(i, j) (i > j) ? j : i
using namespace std;
using ll = long long;

int main() {
	ll a, b, n, x, ans;
	cin >> a >> b >> n;

	x = min(b - 1, n);

	ans = a*(x%b)/b;
	
	cout << ans << endl;
}

Measured memory_bytes: 3588
#include <iostream>
#include <string>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <vector>
#include <cmath>
#include <cstdlib>
#include <queue>
#include <stack>
#include <iomanip>

using namespace std;

#define REP(i, n) for(ll i = 0;i < n;i++)
#define REPR(i, n) for(ll i = n;i >= 0;i--)
#define FOR(i, m, n) for(ll i = m;i < n;i++)
#define FORR(i, m, n) for(ll i = m;i >= n;i--)
#define REPO(i, n) for(ll i = 1;i <= n;i++)
#define ll long long
#define INF (ll)1 << 60
#define MINF (-1 * INF)
#define ALL(n) n.begin(),n.end()
#define MOD (ll)1000000007
#define P pair<ll, ll>


bool c[110000], used[110000];
ll n;
vector<P> g[110000];

void dfs(ll a, ll b) {
	used[a] = true;
	if (b % 2 == 1)c[a] = true;
	REP(i, g[a].size()) {
		if (!used[g[a][i].first])dfs(g[a][i].first, b + g[a][i].second);
	}
}
int main() {
	cin >> n;
	REP(i, n - 1) {
		ll a, b, c;
		cin >> a >> b >> c;
		a--;
		b--;
		g[a].push_back(P(b, c));
		g[b].push_back(P(a, c));
	}
	dfs(0, 0);
	REP(i, n) {
		cout << c[i] << endl;
	}
}

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

int main(){
    int n, taro_point=0, hanako_point=0;;
    cin >> n;

    for(int i=0; i<n; i++){
       
        string taro_str, hanako_str;
        cin >> taro_str >> hanako_str;

        if(taro_str > hanako_str) taro_point += 3;
        else if(taro_str < hanako_str) hanako_point += 3;
        else {taro_point++; hanako_point++;}  
    }  
    cout << taro_point << " " << hanako_point << endl;

    return 0;
}


Measured memory_bytes: 3152
#include <algorithm>
#include <bitset>
#include <cmath>
#include <ctime>
#include <iostream>
#include <list>
#include <map>
#include <math.h>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <stdio.h>
#include <string>
#include <tuple>
#include <vector>
using namespace std;
#define rep(i,n) for(int i = 0; i < (n); i++)
#define all(a) begin(a),end(a)
typedef long long ll;
typedef pair<int,int> P;
const int inf=1e+9;
const ll mod=1000000007;
const double PI=3.14159265358979323846;
int dx[] = {1,-1,0,0};
int dy[] = {0,0,1,-1};
ll gcd(ll a, ll b){
  if (b==0) return a;
  else return gcd(b,a%b);
}
int cans(bool f){
  if(f) cout << "Yes" << endl;
  else cout << "No" << endl;
  return 0;
}



int rate[10];
int main() {
  int N;cin >> N;
  rep(i,N) {
    int a;
    cin >> a;
    for(int j=1;j<=9;j++) {
      if(a >= 3200){
	rate[9]++;
	break;
      }
      if(a < 400*j){
	rate[j]++;
	break;
       }
    }
  }
  int M=0,m=0;

  if(rate[9] == N) cout << 1 << " " << rate[9] << endl;
  else {
    rep(i,10) {
      if(i == 9) {
        M+=rate[9];
      }
      else {
	if(rate[i]) M++,m++;
      }
    }
    cout << m << " " << M << endl;
  }

  // rep(i,10) cout << rate[i] << endl;
  
  return 0;
}


Measured memory_bytes: 888
#include<bits/stdc++.h>
using namespace std;
int main()
{
  int count=0;
  string s;
  cin>>s;
  int n=s.length();
  for(int i=0;i<n/2;i++)
  {
    if(s[i]!=s[n-i-1])
      count++;
  }
    cout<<count<<endl;
}

Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
typedef unsigned long long ULL;

template <typename T1, typename T2>
string print_iterable(T1 begin_iter, T2 end_iter, int counter) {
    bool done_something = false;
    stringstream res;
    res << "[";
    for (; begin_iter != end_iter and counter; ++begin_iter) {
        done_something = true;
        counter--;
        res << *begin_iter << ", ";
    }
    string str = res.str();
    if (done_something) {
        str.pop_back();
        str.pop_back();
    }
    str += "]";
    return str;
}

vector<int> SortIndex(int size, std::function<bool(int, int)> compare) {
    vector<int> ord(size);
    for (int i = 0; i < size; i++) ord[i] = i;
    sort(ord.begin(), ord.end(), compare);
    return ord;
}

template <typename T>
bool MinPlace(T& a, const T& b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}

template <typename T>
bool MaxPlace(T& a, const T& b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}

template <typename Container>
int SZ(const Container& S) { return S.size(); }

template <typename S, typename T>
ostream& operator <<(ostream& out, const pair<S, T>& p) {
    out << "{" << p.first << ", " << p.second << "}";
    return out;
}

template <typename T>
ostream& operator <<(ostream& out, const vector<T>& v) {
    out << "[";
    for (int i = 0; i < (int)v.size(); i++) {
        out << v[i];
        if (i != (int)v.size()-1) out << ", ";
    }
    out << "]";
    return out;
}

#if DEBUG && !ONLINE_JUDGE
    ifstream input_from_file("input.txt");
    #define cin input_from_file

    #define dbg_var(x) clog << #x  << ": " << x << endl;
    #define dbg_array(x, len) clog << #x << ": " << print_iterable(x, x+len, -1) << endl;
#else
    #define dbg_var(x)
    #define dbg_array(x, len)
#endif

///////////////////////////////////////////////////////////////////////////
//////////////////// DO NOT TOUCH BEFORE THIS LINE ////////////////////////
///////////////////////////////////////////////////////////////////////////

const int MAXN = -1; 

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0); // Remove in problems with online queries!

    LL A, B, C, K;
    cin >> A >> B >> C >> K;
    if (K%2 == 0) cout << A-B << "\n";
    else cout << B-A << "\n";
}



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

int main() {
    int w, h, x, y, r;
    cin >> w >> h >> x >> y >> r;
    if (x - r < 0 || x + r > w || y - r < 0 || y + r > h) cout << "No" << endl;
    else if (x - r >= 0 && x + r <= w && y - r >= 0 && y + r <= h) cout << "Yes" << endl;
}


Measured memory_bytes: 3104
#include <bits/stdc++.h>
#include <boost/range/adaptors.hpp>
#include <boost/range/irange.hpp>

using namespace std;
using namespace boost;
using namespace boost::adaptors;

main() {
    int64_t n, a, b;
    cin >> n >> a >> b;

    cout << min(a * n, b) << endl;
}


Measured memory_bytes: 256
#include <stdio.h>
	int main(void)
{
	int n,k,x,y;
	scanf("%d %d %d %d",&n,&k,&x,&y);
	
	if(n<k || n==k){
		printf("%d\n",n*x);
	} else{
		printf("%d\n",k*x+(n-k)*y);
	}
	return 0;
}


Measured memory_bytes: 128
import sys

n, *H = map(int, sys.stdin.read().split())

def main():
    cur = 0
    for h in H:
        if h > cur:
            cur = h - 1
        elif h < cur:
            return 'No'
    return 'Yes'

if __name__ == '__main__':
    ans = main()
    print(ans)

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

ll f(ll x) {
	if (x < 0) return 0;
	if (x % 4 == 0) return x;
	if (x % 4 == 1) return 1;
	if (x % 4 == 2) return x + 1;
	return 0;
}

int main()
{
	ll A, B;
	cin >> A >> B;
	cout << (f(A - 1) ^ f(B)) << endl;
	return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <string.h>

#define N 100000

int main() {
	static char s[N + 1];
	int n, i;

	scanf("%s", s);
	n = strlen(s);
	for (i = 0; i + 1 < n; i++)
		if (s[i] == s[i + 1]) {
			printf("%d %d\n", i + 1, i + 2);
			return 0;
		} else if (i + 2 < n && s[i] == s[i + 2]) {
	 		printf("%d %d\n", i + 1, i + 3);
			return 0;
		}
	printf("-1 -1\n");
	return 0;
}


Measured memory_bytes: 256
/*
Character Drawing Adapted from FAKEUPDATE.NET
		   _    _____         _
		   \`,""   ,'7"r-..__/ \
		  ,'\ `, ,',','    _/   \
		 /   \, 7 / /     (   \ |
		J     \/ j  L______\  / |
		L   __JF"""/""\"\_,    /
		L,-"| O|  f O |  L_  _/
		F   \_ /  \__/   `-  j|
			.-'    `"""    ,' |          _..====.._
			\__/         r"_  A        ,' _..---.._`,
			 `-.______,,-L// / \  ___,' ,'_..:::.. `,`,
					  j   / / / 7"    `-<""=:'  '':. \ \
					 /   <,' /  F  . i , \   `,    :T W I
					 |    \,'  /    >X<  |     \   :| | L
					 |     `._/    ' ! ` |      I  :| |  G
					  \           \     /       |  :H T  |
					 __>-.__   __,-\   |        |  S P   |
					/     /|   | \  \  \_       | 'A R   |
				   /   __/ |   |  L  L   \      K./ /    L
				  /   |    |   4  I  I    |    E./ /   ,'
				 J    \    I    L F  I    |    // / _,'
		_________|     |   F    |J   F    |   //_/-'
		\   __   |    /   J     |/  J     |  /="
		\\  \_\  \__,' \  F     |   F     |
		\\\_____________\/      F__/      F
		 \\| 计算机编程 |_____/  (______/
		  \/从入门到入土/
*/
#include <iostream>
#include <cstdlib>
#include <iomanip>
#include <cmath>
#include <string>
#include <cstring>
#include <algorithm>
#include <vector>
#include <sstream>
#include <set>
#include <queue>
#include <stack>
#include <cctype>
#include <map>
#include <climits>
#include <bitset>
#include <functional>
using namespace std;
#define MATH_PI 3.14159265358979323846
int main(){
	ios::sync_with_stdio(false);
	int iIndex;
	cin >> iIndex;
	cout << "ABC" << iIndex << endl;
endapp:
	//system("pause > nul");
	return 0;
}

Measured memory_bytes: 256
data = [1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51]
print(data[int(input())-1])

Measured memory_bytes: 3060
#include <iostream>
#include <cstdio>
#include <iomanip>

#include <vector>
#include <map>
#include <set>
#include <queue>
#include <bitset>
#include <stack>
#include <utility>

#include <numeric>
#include <algorithm>
#include <functional>

#include <cctype>

#include <complex>
#include <string>
#include <sstream>

using namespace std;

#define all(c) c.begin(),c.end()
#define rall(c) c.rbegin(),c.rend()
#define rep(i,n) for(unsigned int i=0;i<(n);i++)
#define tr(it,container) for(typeof(container.begin()) it = container.begin(); \
                                                  it != container.end(); ++it)

typedef long long ll;
typedef complex<double> P;
const int dx[] = {1,0,-1,0};
const int dy[] = {0,-1,0,1};
const double EPS = 1e-9;
const int days[] = {31,28,31,30,31,30,31,31,30,31,30,31};
const int daysleap[] = {31,29,31,30,31,30,31,31,30,31,30,31};

int main(){
    while(true){
        int N,M,P;
        cin >> N >> M >> P;
        if(N==0) break;
        vector<int> X(N);
        rep(i,N) cin >> X[i];
        int total = accumulate(all(X),0);
        int rest = total * (100-P);

        int ret;
        if(X[M-1] == 0) ret = 0;
        else ret = rest / X[M-1];
        if(X[M-1] == 0) ret = 0;
        cout << ret << endl;
    }
    return 0;
}

Measured memory_bytes: 1196
#include <iostream>
using namespace std;
int main()
{
    int m, d, k, d1d10, ans = 0;
    cin >> m >> d;
    for(int i = 4; i <= m; i++){
        for(int j = 22; j <= d; j++){
            d1d10 = 1;
            k = j;
            while(k != 0){
                if(k % 10 < 2) k = 0;
                d1d10 *= (k % 10);
                k /= 10;
            }
            if(i == d1d10) ans++;
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
#define REP(var,start,stop,step) for(long long var=start;var<stop;var+=step)
#define fori(a,n) for(long long i=a;i<n;i++)
#define forj(a,n) for(long long j=a;j<n;j++)
#define fork(a,n) for(long long k=a;k<n;k++)
#define ee 1000000007
#define pb push_back
#define fio ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
using namespace std;
int main() {
	fio;
	ll t = 1;
	//cin >> t;
	while(t--) {
		ll k, a, b, c;
		cin >> a >> b >> c >> k;
		ll ans = 0;
		if(k >= a) {
			ans += a;
			k -= a;
		}
		else {
			cout << k << "\n";
			return 0;
		}
		if(k >= b)
			k -= b;
		else {
			cout << ans << "\n";
			return 0;
		}
		if(k < c) ans -= k;
		else ans -= c;
		cout << ans <<"\n";
	}
}

Measured memory_bytes: 3636
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < (int)n; i++)
#define all(x) (x).begin(),(x).end()
typedef long long int ll;
using namespace std;
int main()
{
  int h, w, H, W;
  cin >> h >> w >> H >> W;
  int ans = (H - h)*(W -w) ;
  cout << ans << endl;

}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> // Common file
#include <ext/pb_ds/tree_policy.hpp>
#define ll long long
#define pb push_back
#define vi vector<long long>
#include <ext/pb_ds/assoc_container.hpp> // Common file  
#include <ext/pb_ds/tree_policy.hpp>  
#include <functional> // for less   
using namespace __gnu_pbds;  
using namespace std;  
typedef tree<ll, null_type, less<ll>, rb_tree_tag, tree_order_statistics_node_update> set1;
ll mod=1000000007;
ll large=1e18;
ll neg=-1e18;
ll N=500000;
ll mod1=998244353;
struct pii
{
   ll x;
   ll y;
};
struct edge
{
   ll from;
   ll to;
   ll w;
   ll id;
};
ll find(ll a,ll p[])
{
   //cout<<"find "<<a<<endl;
   if(a==p[a])
   return a;
   else return p[a]=find(p[a],p);

}
void join(ll a,ll b,ll p[],ll sz[])
{
   a=find(a,p);
   b=find(b,p);
   if(a!=b)
   {
      if(sz[a]<sz[b])
      swap(a,b);
      sz[a]+=sz[b];
      p[b]=a;
   }
}
ll power(ll a,ll b,ll mod)
{
   ll res=1;
   while(b>0)
   {
      if(b&1)
      res=(res*a)%mod;
      b=b/2;
      a=(a*a)%mod;
   }
   return res;
}
ll inverse(ll x, ll p)
{
   return power(x,p-2,p);
}
ll hash1(ll x,ll y)
{
   return x+y+x*y;
}
/*ll f[200000]={0};

void ini()
{
   f[0]=1;
   for(ll i=1;i<=200000;i++)
   f[i]=(i*f[i-1])%mod;
}*/
void build(ll tree[],ll v,ll l,ll r,ll dp[])
{
   if(l==r)
      tree[v]=dp[l];
   else
   {
      ll m=(l+r)/2;
      build(tree,2*v,l,m,dp);
      build(tree,2*v+1,m+1,r,dp);
      tree[v]=max(tree[2*v],tree[2*v+1]);
   }
}
ll query(ll tree[],ll v,ll l,ll r,ll tl,ll tr)
{
   if(l==tl && tr==r)
   {
    //  cout<<"max of "<<tl<<" "<<tr<<" "<<tree[v]<<endl;
      return tree[v];
   }
   else
   {
      ll m=(l+r)/2;
      if(tr<=m)
      {
         ll z1= query(tree,2*v,l,m,tl,tr);
     //    cout<<"max of "<<tl<<" "<<tr<<" "<<z1<<endl;
         return z1;
      }
      else if(tl>m)
      {
         ll z2= query(tree,2*v+1,m+1,r,tl,tr);
      //   cout<<"max of "<<tl<<" "<<tr<<" "<<z2<<endl;
         return z2;
      }
      else 
      {
         ll z=query(tree,2*v,l,m,tl,m);
         ll z1=query(tree,2*v+1,m+1,r,m+1,tr);
       //  cout<<"max of "<<tl<<" "<<tr<<" "<<max(z1,z)<<endl;
         return max(z1,z);
      }
      
      
   }
}
void update(ll tree[],ll v,ll l,ll r,ll pos,ll element)
{
   if(l==r && l==pos)
   tree[v]=element;
   else
   {
      ll m=(l+r)/2;
      if(pos<=m)
      update(tree,2*v,l,m,pos,element);
      else
      update(tree,2*v+1,m+1,r,pos,element);
      tree[v]=max(tree[2*v],tree[2*v+1]);
   }
}

/*ll ncr(ll n,ll r)
{
   ll res=1;
   ll k=f[n];
   ll v=inverse(f[n-r],mod);
   ll u=inverse(f[r],mod);
   ll x=(u*v)%mod;
   k=(k*x)%mod;
   return k;
}*/
int main()
{
   ios_base::sync_with_stdio(false);
   cin.tie(NULL);
   ll x,y;
   cin>>x>>y;
   ll ans=0;
   for(ll i=0;i<=x;i++)
   {
      if(2*i+4*(x-i)==y)
      {
         ans=1;
         break;
      }
   }
   if(ans==1)
   cout<<"Yes"<<endl;
   else
   cout<<"No"<<endl;
   return 0;
}

Measured memory_bytes: 3624
#include <bits/stdc++.h>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>

using namespace std;
using namespace __gnu_pbds;
 
typedef long long ll;
typedef long double ld;
typedef complex<ld> cd;

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

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

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

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

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

const int MOD = 1000000007;
const ll INF = 1e18;
const int MX = 100001;

template<class T, int SZ> struct Seg {
    T seg[2*SZ], MN = 0;
    
    Seg() {
        memset(seg,0,sizeof seg);
    }
    
    T comb(T a, T b) { return (a+b)%MOD; } // easily change this to min or max
    
    void upd(int p, T value) {  // set value at position p
        for (seg[p += SZ] = value; p > 1; p >>= 1)
            seg[p>>1] = comb(seg[(p|1)^1],seg[p|1]); // non-commutative operations
    }
    
    void build() {
        F0Rd(i,SZ) seg[i] = comb(seg[2*i],seg[2*i+1]);
    }
    
    T query(int l, int r) {  // sum on interval [l, r]
        T res1 = MN, res2 = MN; r++;
        for (l += SZ, r += SZ; l < r; l >>= 1, r >>= 1) {
            if (l&1) res1 = comb(res1,seg[l++]);
            if (r&1) res2 = comb(seg[--r],res2);
        }
        return comb(res1,res2);
    }
    
    int lo = -1;
    void clear(int x) {
        while (lo < x) upd(++lo,0);
    }
};

Seg<ll,1<<17> B[2];

ll N,a,b;
vl S;

int answer() {
    return (B[0].query(0,(1<<17)-1)+B[1].query(0,(1<<17)-1))%MOD;
}

int main() {
    ios_base::sync_with_stdio(0); cin.tie(0);
    cin >> N >> a >> b;
    S.resize(N+1);
    S[0] = -2*INF;
    FOR(i,1,N+1) cin >> S[i];
    
    int l0 = 0, l1 = 0;
    FOR(i,1,sz(S)) {
        while (S[i]-S[l0] >= a) l0 ++;
        while (S[i]-S[l1] >= b) l1 ++;
        
        if (i == 1) {
            B[0].upd(0,1);
            B[1].upd(0,1);
        } else {
            // ?, S[i-1] --> S[i], S[i-1]
            B[0].upd(i-1,B[1].query(0,min(l0,i-1)-1));
            B[1].upd(i-1,B[0].query(0,min(l1,i-1)-1));
            
            // ?, S[i-1] --> ?, S[i]
            if (l0 != i) B[0].clear(i-2);
            if (l1 != i) B[1].clear(i-2);
        }
        // cout << i << " " << S[i] << " | " << l0 << " " << l1 << " " << B[0].lo << " " << B[1].lo << " " << answer() << "\n";
    }
    cout << answer();
}

// read the question correctly (is y a vowel? what are the exact constraints?)
// look out for SPECIAL CASES (n=1?) and overflow (ll vs int?) ARRAY OUT OF BOUNDSS

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

int main(){
    string s;
    ll k;
    cin>>s>>k;
    map<string,ll> mp;
    for(ll i=1;i<=min(k,(ll)s.size());i++){
        rep(j,s.size()-i+1){
            mp[s.substr(j,i)]++;
        }
    }
    ll cnt=0;
    for(auto x:mp){
        cnt++;
        if(cnt==k){
            cout<<x.first<<endl;
            break;
        }
    }
    return 0;
}

Measured memory_bytes: 1920
import java.util.Arrays;
import java.util.Scanner;

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

        int n = sc.nextInt();
        long[] a = new long[n];
        long[] s = new long[n];

        for(int i = 0; i < n; i++) {
            a[i] = sc.nextLong();
        }
        Arrays.sort(a);

        for(int i = 0; i < n; i++) {
            s[i] = a[i];
            if(i > 0) s[i] += s[i - 1];
        }
        int count = 1;

        for(int i = n - 2; i >= 0; i--) {
            if(s[i] * 2 >= a[i + 1]) count++;
            else break;
        }

        System.out.println(count);
    }
}

Measured memory_bytes: 57292
#include<bits/stdc++.h>
using namespace std;
using ll=long long;
int main()
{
int n;
cin>>n;int k;
cin>>k;
int a[n+1];
for(int i=0;i<n;i++)
{cin>>a[i];}
  
  vector<ll> dp(n+1,INT_MAX);
  dp[0]=0;dp[1]=abs(a[1]-a[0]);
  for(int i=2;i<n;i++)
  {
  for(int j=i-1,jump=0;j>=0&&jump<k;j--,jump++)
  {
  
    dp[i]=min(dp[i],abs(a[i]-a[j])+dp[j]);
  
  }
      
  }
         
              cout<<dp[n-1]<<endl;
              
return 0;}


Measured memory_bytes: 1408
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <string>
#include <cstring>
#include <deque>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <cfloat>
#include <climits>
#include <ctime>
#include <cassert>
#include <numeric>
#include <fstream>
#include <functional>
#include <bitset>
#define chmin(a, b) ((a)=min((a), (b)))
#define chmax(a, b) ((a)=max((a), (b)))
#define fs first
#define sc second
#define eb emplace_back
using namespace std;

typedef long long ll;
typedef pair<int, int> P;
typedef tuple<int, int, int> T;

const ll MOD=1e9+7;
const ll INF=1e18;
const double pi=acos(-1);
const double eps=1e-10;

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

int main(){
    int t, d; cin>>t>>d;
    int ta, tb, da, db; cin>>ta>>tb>>da>>db;

    double ans = 1e18;
    for(int i=0; i<=1000; i++){
        for(int j=0; j<=1000; j++){
            int va = i * da;
            int vb = j * db;
            if(!(1 <= va + vb)) continue;
            if(!(va + vb <= d)) continue;

            double tmp = 1. * (ta * va + tb * vb) / (va + vb);

            chmin(ans, abs(t - tmp));
        }
    }

    cout << fixed << setprecision(10) << ans << endl;
}


Measured memory_bytes: 3276
import java.util.Scanner;
  
public class Main {
	public static void main(String[] args) {
    	Scanner s = new Scanner(System.in);
      	int n = s.nextInt();
		int[] a = new int[n];
		int[] b = new int[n];
		int[] c = new int[n - 1];
      
      	int score = 0;
      
      	for (int i = 0; i < n; i++) {
        	a[i] = s.nextInt();
        }
      
      	for (int i = 0; i < n; i++) {
        	b[i] = s.nextInt();
        }
      
      	for (int i = 0; i < n - 1; i++) {
        	c[i] = s.nextInt();
        }
      
      	int index = 0;
      	for (int i = 0; i < n; i++) {
			if (i > 0 && index == a[i] - 1) score += c[a[i] - 2];
        	score += b[a[i] - 1];
			index = a[i];
        }
      	System.out.println(score);
    }
}

Measured memory_bytes: 21844
use whiteread::parse_line;

fn main() {
    let (k, s): (i32, i32) = parse_line().unwrap();
    let (mut a, mut b, mut c): (i32, i32, i32) = (0, 0, 0);
    let mut t: i32 = 0;

    while a <= k {
        while b <= k {
            c = s - a - b;
            if c <= k && c >= 0 {
                t = t + 1;
            }
            b = b + 1;
        }
        a = a + 1;
        b = 0;
    }
    println!("{}", t);
}


Measured memory_bytes: 2116
P = 998244353

N, K = [int(x) for x in input().split()]
intervals = []
for _ in range(K):
    L, R = [int(x) for x in input().split()]
    intervals.append([L, R])

dp = [0]*(N + 1)
csum = [0]*(N + 1)
dp[1] = 1
csum[1] = 1
for i in range(2, N + 1):
    for j in range(K):
        L, R = intervals[j]
        dp[i] = (dp[i] +  csum[max(0, i - L)] - csum[max(0, i - R - 1)]) % P
    csum[i] = (csum[i - 1] + dp[i]) % P

ans = dp[N]
print(ans)

Measured memory_bytes: 24580
import math
A, B, N = map(int, input().split())

if B > N:
  ret = math.floor(A * N / B) - (A * math.floor(N / B))
elif B <= N:
  ret = math.floor(A * (B - 1) / B) - (A * math.floor((B - 1) / B))

print(ret)

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

int MAX = 1e9+7;

vector<vector<int> > records;
int num;
vector<vector<int> > compatibilities;

int go(int unmatched_man, int matched_women){

    if(records[unmatched_man][matched_women] != -1)
        return records[unmatched_man][matched_women];

    if(unmatched_man == num){
        if(matched_women == ((1 << num)-1))
            return 1;
        return 0;
    }

    records[unmatched_man][matched_women] = 0;

    for(int woman = 0; woman < num; woman++){
        if(compatibilities[unmatched_man][woman])
        {
            if((matched_women & (1 << woman)) == 0){
                int new_matched = matched_women | (1 << woman);
                (records[unmatched_man][matched_women] += go(unmatched_man + 1, new_matched)) %= MAX;
            }
        }

    }

    return records[unmatched_man][matched_women];
}


int match(){
    num = compatibilities.size();
    
    records = vector<vector<int> >(num+1, vector<int>((1 << num), -1));

    return go(0, 0);
}

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

    compatibilities = vector<vector<int> >(n, vector<int>(n, 0));

    for(int i = 0; i < n; i++)
        for(int j = 0; j < n; j++)
            cin >> compatibilities[i][j];

    int result = match();
 
    cout << result << "\n";

    return 0;
}


Measured memory_bytes: 188800
#include <cstdio>
#include <algorithm>
#include <iostream>
#include <vector>

using namespace std;
int n, x;
char c;
int mx;

int main() {
    scanf("%d", &n);
    for(int i=0; i<n; i++) {
        scanf(" %c", &c);
        if(c == 'I') x ++;
        else x--;
        mx = max(x, mx);
    }

    cout << mx;
}

Measured memory_bytes: 256
def q(a,h):
 d[a]=str(h)
 for b in t[a]:q(b,h+1)
t,p,d={},{},{}
for _ in[0]*int(input()):
 e=input().split()
 t[e[0]]=e[2:]
 for i in e[2:]:p[i]=e[0]
r=(set(t)-set(p)).pop()
p[r]='-1'
q(r,0)
for i in sorted(map(int,t)):i=str(i);print('node',i+':','parent =',p[i]+',','depth =',d[i]+',','root,'if'-1'==p[i]else'internal node,'if t[i]else'leaf,',list(map(int,t[i])))


Measured memory_bytes: 55840
n, m = map(int, input().split())
MOD = m
list_size = n+2

f_list = [1] * list_size
f_r_list = [1] * list_size

for i in range(list_size - 1):
	f_list[i + 1] = int((f_list[i] * (i + 1)) % MOD)

f_r_list = [pow(x, MOD-2, MOD) for x in f_list]

def comb(N, r):
	if N < r or r < 0:
		return 0
	else:
		return (((f_list[N] * f_r_list[N - r]) % MOD) * f_r_list[r]) % MOD 

st = [[0 for _ in range(n+1)] for _ in range(n+1)]
st[0][0] = 1
for i in range(1, n+1):
	st[i][0] = 1
	for j in range(1, i+1):
		st[i][j] = (st[i-1][j-1] + (j+1) * st[i-1][j]) % MOD

ans = 0
for i in range(n+1):
	res = (comb(n, i) * pow(2, pow(2, n-i, MOD-1), MOD)) % MOD
	tmp = 0
	for j in range(i+1):
		tmp += st[i][j] * pow(2, (n-i) * j, MOD)
		tmp %= MOD
	res *= tmp
	res %= MOD

	if i%2 == 0:
		ans += res
	else:
		ans -= res
	ans %= MOD

print(ans)

Measured memory_bytes: 120156
#include<iostream>
#include<vector>
#include<cmath>
#include<algorithm>
#include<string>
#include<climits>
#include<stack>
#include<queue>
#include<unordered_map>
#include<map>
#include<set>
#include<fstream>
#include<list>
#include<sstream>

#define loopi(x,y) for(int i = x;i<(y);i++)
#define loopj(x,y) for(int j = x;j<(y);j++)
#define rloopi(x,y) for(int i = x;i>=(y);i--)
#define rloopj(x,y) for(int j = x;j>=(y);j--)


#define nl cout<<"\n";
#define ll long long int
#define mod  1000000007

using namespace std;

ll power(int n, int a)
{
	if (n == 1)
		return a;
	if (n == 0)
		return 1;

	ll t = power(n / 2, a) % mod;

	if (n % 2)
		return (((t * t) % mod) * a) % mod;
	return (t * t) % mod;
}

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

#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif

	int n;
	cin >> n;

	vector<int> xplusy(n);
	vector<int> xminusy(n);
	int max1 = INT_MIN, max2 = INT_MIN;
	int min1 = INT_MAX, min2 = INT_MAX;
	for (int i = 0; i < n; i++)
	{
		int a, b;
		cin >> a >> b;
		if (a + b > max1)
			max1 = a + b;
		if (a - b > max2)
			max2 = a - b;
		if (a + b < min1)
			min1 = a + b;
		if (a - b < min2)
			min2 = a - b;
	}

	cout << max(max1 - min1, max2 - min2);

	return 0;
}



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

int main() {
  int a = 1, N, K;
  cin >> N >> K;
  
  for (int i = 0; i < N; i++){
    if (a < K) a *= 2;
    else a += K;
  }
  
  cout << a << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
const long long OO = (long long) 1e9+7;
#define lp(i,a,n) for(long long i = a ; i < n ; ++i)
#define rep(i,vec) for(ll i = 0 ; i < vec.size() ; ++i)
#define reprv(i,vec) for(ll i = vec.size()-1; i >=0 ; --i)
#define eps (1e-5)
#define pb(i) push_back(i)
#define PI acos(-1.0)
#define vec(a,b)                ((b)-(a))
#define length(a)               (hypot((a).imag(), (a).real()))
#define EPS 1e-9
#define INF 1e9
#define cp(a,b)                 ( (conj(a)*(b)).imag() )	// a*b sin(T), if zero -> parllel
#define ff first
#define ss second
typedef vector<int> vi ;
typedef   long long ll;
typedef vector<ll> vll ;
typedef pair<int,int> pii ;
typedef vector< pair<int,int> >  vpii;
typedef vector<vector<int> > vvi ;
typedef complex<double> point;
typedef pair<int,int> pii;


using namespace std;
ll  inv(ll a, ll b) {return 1 < a ? b - inv(b % a, a) * b / a : 1;}
ll  Pow(ll  B,ll  P){ll  R=1; while(P>0)  {if(P&1) R=(R*B);P/=2;B=(B*B);}return R;} //compute b^p
ll  GCD(ll  a,ll  b){ while(b){b ^= a ^=b ^= a %=b;}  return a;}
ll  LCM(ll  a,ll  b) { return (a / GCD(a,b)*b); }
ll  BigMod(ll  B,ll  P,ll  M){ ll  R=1; while(P>0)  {if(P&1){R=(R*B)%M;}P/=2;B=(B*B)%M;} return (ll )R;} //compute b^p%m


map<int,int> pfs;
map<int,int>mxPfs;
void getPFs(ll x) {
	for (ll i = 2; i * i <= x; ++i)
		while (x % i == 0)
			pfs[i]++, x /= i;
	if (x > 1)
		pfs[x]++;
}

int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
  //    freopen( "output.txt" , "w" , stdout ) ;
  //  freopen( "input.txt" , "r" , stdin ) ;
   int n;
   cin>>n;
   vi numbers(n);
   lp(i,0,n) {
    cin>>numbers[i];
    pfs.clear();
    getPFs(numbers[i]);
    for(auto&p:pfs){
        mxPfs[p.ff] = max(mxPfs[p.ff],p.ss);
    }
   }
   ll lcm=1;
   for(auto&p:mxPfs){
     lp(i,0,p.ss) lcm = (lcm*p.ff)%OO;
   }

   ll ans=0;
   for(auto&nm:numbers){
        ans += lcm * inv(nm,OO) %OO;
        ans %= OO;
   }
   cout<<ans;

    return 0;
}


Measured memory_bytes: 768
#include<algorithm>
#include<bitset>
#include<cmath>
#include<complex>
#include<cstdlib>
#include<iomanip>
#include<iostream>
#include<map>
#include<queue>
#include<set>
#include<string>
#include<utility>
#include<vector>

using namespace std;

#define ll long long
#define pal pair<ll,ll>
#define pad pair<double,double>
#define PB push_back
#define MP make_pair
#define F first
#define S second

const ll MOD = 1e9+7;
const ll INF = 1e18;
const double EPS = 1e-8;

long long pow(long long x, long long n) {
    long long ret = 1;
    while (n > 0) {
        if (n & 1) ret = ret * x % MOD;
        x = x * x % MOD;
        n >>= 1;
    }
    return ret;
}

template<typename T,typename U>
bool chmax(T& max, const U& x){
	if(max<x){
		max = x;
		return true;
	}
	return false;
}

template<typename T,typename U>
bool chmin(T& min, const U& x){
	if(min>x){
		min = x;
		return true;
	}
	return false;
}


int main(){
	ll n,k,ans=0;
	cin >> n >> k;
	vector<ll> p(n);
	for(ll i=0;i<n;i++){
		cin >> p[i];
	}
	sort(p.begin(),p.end());
	for(ll i=0;i<k;i++){
		ans+= p[i];
	}
	cout << ans << endl;
}

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

int main(){
  int N;
  vector<int64_t> A(100010), B(100010);

  cin >> N;
  for (int i=0; i<N+1; i++) cin >> A[i];
  for (int i=0; i<N; i++) cin >> B[i];

  //左端から貪欲に倒していく
  int64_t ans = 0;
  for (int i=0; i<N-1; i++){  
    if (A[i] + A[i+1] <= B[i]){
      ans += A[i] + A[i+1];
      A[i] = 0; A[i+1] = 0;
    } else  if (A[i] <= B[i]){
      ans += B[i];
      A[i+1] -= (B[i] - A[i]); A[i] = 0; 
    } else {
      ans += B[i];
      A[i] -= B[i];
    }
  }


  if (A[N-1] + A[N] <= B[N-1]){
    ans += A[N-1] + A[N];
  } else {
    ans += B[N-1];
  }


  cout << ans << endl;
}

Measured memory_bytes: 1920
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define F(i,a) for(ll i=0;i<a;i++)
#define R(i,n,m) for(ll i=(ll) n ; i  < (ll) m ; i++ )

int main (){

    int k,x;
    cin>>k>>x;
    if(x<=500*k) cout<<"Yes";
    else cout<<"No";
    return 0;
}

Measured memory_bytes: 256
//   _/                _/                 _/_/_/   _/
//_/_/_/_/   _/_/   _/_/_/_/   _/_/    _/       _/_/
// _/     _/    _/   _/     _/    _/  _/_/_/     _/
//_/     _/    _/   _/     _/    _/  _/    _/   _/
// _/_/   _/_/       _/_/   _/_/      _/_/     _/
#include<iostream>
#include<algorithm>
#include<cmath>
#include<iomanip>
#include<set>
#include<map>
#include<queue>
#include<vector>
using namespace std;
typedef long long ll;
const int MOD=1e9+7;
const double pi=acos(-1);
int main() {
  cin.tie(0),cout.tie(0);
  ios::sync_with_stdio(false);
  int n,a[3]={},ans=0;
  string s;
  cin >> n >> s;
  for(int i=0; i<=999; i++) {
    a[0]=i/100,a[1]=(i%100)/10,a[2]=i%10;
    int x=0;
    for(int j=0; j<n; j++) {
      if(s[j]-'0'==a[x]) {
        x++;
      }
      if(x==3) {
        ans++;
        break;
      }
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 384
#include <iostream>
#include <fstream>
#include <stdio.h>
#include <algorithm>
#include <vector>
#include <stack>
#include <queue>
#include <string>
#include <map>
#include <set>
#include <list>
#include <math.h>
#define rep(i, n) for(int i=0; i<(n); ++i)
#define rep2(i, s, n) for(int i=s; i<(n); ++i)
#define sz(x) int(x.size())

typedef long long ll;

using namespace std;

/*******-c++14 don't include-*******/
template<typename T>
T gcd(T a, T b){if( b == 0)return a; return gcd(b, a%b); }
template<typename T>
T lcm(T a, T b){return a*b/gcd(a,b); }
void printArr(int *a, int len){for(int i=0; i<len; i++){if(i)cout << " ";cout << a[i];}cout << endl;}
/*******---------------------*******/

static const int INTINF = (2147483647);
static const ll LLINF = (1ll<<32);
static const int MAX = 100001;

int arr[MAX];

int main(int argc, const char * argv[]) {
    // input from txt
    
    /////////
    //write//
    /////////
    
    ll n;
    cin >> n;
    ll ma;
    rep2(i, 1, sqrt(n)+2){
        if(n%i == 0){
            ma = i;
        }
    }
    ll res = ma -1 + n/ma -1;
    cout << res  << endl;
    
    
    
    return 0;
}


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

#define S 128

char O[S], E[S], pw[S];

int run(){
	std::cin >> O;
	std::cin >> E;
	for( int i = 0; i < S; i++ ){ pw[i] = '\0'; }
	for( int i = 0; O[i] != '\0'; i++ ){ pw[2*i] = O[i]; }
	for( int i = 0; E[i] != '\0'; i++ ){ pw[2*i+1] = E[i]; }
	std::cout << pw << std::endl;
	return 0;
}

int main(){
	run();
	return 0;
}


Measured memory_bytes: 256
#[allow(unused_imports)]
use std::cmp::{max, min};
#[allow(unused_imports)]
use std::collections::{HashMap, HashSet};

mod util {
    use std::io::stdin;
    use std::str::FromStr;
    use std::fmt::Debug;

    #[allow(dead_code)]
    pub fn line() -> String {
        let mut line: String = String::new();
        stdin().read_line(&mut line).unwrap();
        line.trim().to_string()
    }

    #[allow(dead_code)]
    pub fn get<T: FromStr>() -> T
        where <T as FromStr>::Err: Debug
    {
        let mut line: String = String::new();
        stdin().read_line(&mut line).unwrap();
        line.trim().parse().unwrap()
    }

    #[allow(dead_code)]
    pub fn gets<T: FromStr>() -> Vec<T>
        where <T as FromStr>::Err: Debug
    {
        let mut line: String = String::new();
        stdin().read_line(&mut line).unwrap();
        line.split_whitespace()
            .map(|t| t.parse().unwrap())
            .collect()
    }
}

fn main() {
    let nm: Vec<usize> = util::gets();
    let n = nm[0];
    let m = nm[1];

    let edges = (0..m)
        .map(|_| {
                 let abc: Vec<i64> = util::gets();
                 (abc[0] as usize - 1, abc[1] as usize - 1, abc[2])
             })
        .collect::<Vec<_>>();

    let mut d = vec![None; n];
    d[0] = Some(0);

    for count in 1.. {
        let mut update = false;
        let mut update_n = false;

        for &(a, b, c) in &edges {
            if let Some(cost_from) = d[a] {
                let cost_new = cost_from + c;
                let tmp = d[b].clone();
                d[b] = Some(d[b].map_or(cost_new, |old| max(old, cost_new)));

                if tmp != d[b] {
                    update = true;
                    if b == n - 1 {
                        update_n = true;
                    }
                }
            }
        }

        if !update {
            println!("{}", d[n - 1].unwrap());
            break;
        }

        if count >= n && update_n {
            println!("inf");
            break;
        }

        if count >= 2 * n {
            println!("{}", d[n - 1].unwrap());
            break;
        }
    }
}


Measured memory_bytes: 4352
#include <cstdio>
#include <iostream>

using namespace std;

const int mod = 1'000'000'007;

void add(int &a, int b) {
  a += b;
  if (a >= mod) {
    a -= mod;
  }
}

int mul(int a, int b) {
  return (int)((long long)a * b % mod);
}

int pw(int a, int b) {
  int res = 1;
  while (b > 0) {
    if (b % 2 == 1) {
      res = mul(res, a);
    }
    a = mul(a, a);
    b /= 2;
  }
  return res;
}

int get(int b) {
  int res = pw(10, b);
  add(res, mod - pw(10, b - 1));
  return res;
}

int main() {
  int s;
  scanf("%d", &s);
  int ans = 0;
  for (int i = 1; i * i <= s; ++i) {
    if (s % i == 0) {
      {
        int cnt = get(i);
        if (i >= 9 || cnt >= s / i) {
          add(ans, cnt);
          add(ans, mod - s / i + 1);
        }
      }
      if (s / i != i) {
        int cnt = get(s / i);
        if (s / i >= 9 || cnt >= i) {
          add(ans, cnt);
          add(ans, mod - i + 1);
        }
      }
    }
  }
  for (int i = 1; i <= 8; ++i) {
    int cnt_i = get(i);
    long long v = 0;
    for (int j = i + 1; j <= 9; ++j) {
      int cnt_j = get(j);
      for (int k = 1; k <= cnt_i; ++k) {
        if (v + i * k >= s) {
          break;
        }
        if ((s - v - i * k) % j == 0 && (s - v - i * k) / j <= cnt_j) {
          add(ans, 1);
        }
      }
      v += j * cnt_j;
      if (v >= s) {
        break;
      }
    }
  }
  for (int i = 9; i < s; ++i) {
    int v = s / (i + 1);
    if (s % (i + 1) == 0) {
      --v;
    }
    int r = s % i;
    if (v >= r) {
      add(ans, (v - r) / i + (r != 0));
    }
  }
  printf("%d\n", ans);
}


Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;

namespace ABC
{
    class Program
    {
        static void Main(string[] args)
        {
            ABC112_B();
        }

        static void ABC112_B()
        {
            var NT = Console.ReadLine().Split(' ').Select(int.Parse).ToList();
            var N = NT[0];
            var T = NT[1];

            var CT = new List<List<int>>();
            for(var n = 1; n <= N; n++)
                CT.Add(Console.ReadLine().Split(' ').Select(int.Parse).ToList());

            var count = CT.Where(x => x[1] <= T).Count();
            Console.WriteLine(count == 0 ? "TLE" : CT.Where(x => x[1] <= T).Min(x => x[0]).ToString());
        }
    }
}
    

Measured memory_bytes: 13524
#include"bits/stdc++.h"
using namespace std;

//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>
//using namespace __gnu_pbds;

struct _ { ios_base::Init i; _() { cin.sync_with_stdio(0); cin.tie(0); cout << fixed << setprecision(10); } } ___;
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1) {
	cerr << name << " : " << arg1 << endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args) {
	const char* comma = strchr(names + 1, ',');
	cerr.write(names, comma - names) << " : " << arg1 << " | ";
	__f(comma + 1, args...);
}

#define oset tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>
#define pii pair<int,int>
#define ff first
#define ss second
#define endll '\n'
#define rep(i,n) for(int i=0;i++<n;)
#define scl(i) scanf("%lld",&i);
#define int long long int

signed main()
{

// #ifndef ONLINE_JUDGE
// 	freopen("input.txt", "r", stdin);
// 	freopen("output.txt", "w", stdout);
// #endif

	int a; cin >> a;
	string s; cin >> s;
	int x, y;
	string temp = "";
	int i = 0;
	for (; i < s.size(); i++)
	{
		if (s[i] == '.') break;
		temp += s[i];
	}
	x = stoi(temp);
	temp = "";
	for (++i; i < s.size(); i++)
	{
		temp += s[i];
	}
	int siz = temp.size();
	y = stoi(temp);


	int xx = x * a;

	int zz = y * a;
	int dd = 1;

	for (int i = 0; i < siz; i++)
	{
		dd *= 10;
	}

	zz /= dd;

	cout << xx + zz;



}

Measured memory_bytes: 3656
#include <bits/stdc++.h>
#define fi first
#define se second
#define pb(x) push_back(x)
#define mp make_pair
#define sz(x) ((int)(x).size())
#define endl "\n"
#define fastio ios_base::sync_with_stdio(false); cin.tie(nullptr);
#define all(x) x.begin(),x.end()
#define y1 omg
#define INF 1000000010
#define FOR(x, n) for(int x=0; x<n; x++)
#define ini(x, n) memset(x, n, sizeof(x));
#define ctoi(x) (x - '0')
using namespace std;
typedef long long ll;
typedef pair<int, int> ii;
typedef pair<int, ii> iii;
typedef vector<int> vi;
typedef vector<ii> vii;
typedef vector<vi> vvi;

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

int x, y;

int main() {
	cin >> x >> y;
	if (2 * x <= y && y <= 4 * x && y % 2 == 0) cout << "Yes";
	else cout << "No";
}

Measured memory_bytes: 3628
#include<bits/stdc++.h>
#define rep(i, l, r) for(int i = (l), i##end = (r);i <= i##end;++i)
using std::cin; using std::cout;
const int maxn = 200200;
typedef long long ll;
const int mod = 998244353;
inline ll pow(ll a,int b,int ans = 1) {
	for(;b;b >>= 1,a = a * a % mod) if(b & 1)
		ans = ans * a % mod;
	return ans;
}
inline ll inverse(int x){ return pow(x, mod - 2); }
int n, q;
int max[maxn << 2];
inline void upt(int pos,int v,int cur = 1,int l = 0,int r = n) {
	if(l == r) return void(max[cur] = v);
	int mid = l + r >> 1;
	pos <= mid ? upt(pos, v, cur << 1, l, mid) : upt(pos, v, cur << 1 | 1, mid + 1, r);
	max[cur] = std::max(max[cur << 1], max[cur << 1 | 1]);
}
inline int qry(int ql,int qr,int cur = 1,int l = 0,int r = n) {
	if(ql <= l && r <= qr) return max[cur];
	int mid = l + r >> 1, ans = -1e9;
	if(ql <= mid) ans = std::max(ans, qry(ql, qr, cur << 1, l, mid));
	if(mid < qr) ans = std::max(ans, qry(ql, qr, cur << 1 | 1, mid + 1, r));
	return ans;
}
std::vector<int> v[maxn];
int b[maxn];
int dp[maxn];
int main() {
	std::ios::sync_with_stdio(false), cin.tie(0), cout.tie(0);
	cin >> n;
	rep(i, 1, n) {
		cin >> b[i];
		b[i] += b[i - 1];
	}
	cin >> q;
	rep(i, 1, q) {
		int l, r;
		cin >> l >> r;
		v[l].push_back(r);
	}
	rep(i, 1, n) dp[i] = -1e9, upt(i, -1e9);
	rep(i, 1, n) {
		for(int x : v[i]) {
			int v = std::max(dp[i - 1], qry(i - 1, x));
			if(v > dp[x]) {
				dp[x] = v;
				upt(x, v);
			}
		}
		dp[i] = std::max(dp[i], dp[i - 1] + (b[i] == b[i - 1] ? 1 : -1));
	}
	cout << n - b[n] - dp[n] << '\n';
}


Measured memory_bytes: 12544
#define _GLIBCXX_DEBUG
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <cmath>

using namespace std;

#define REP(i,n) for(int i=0;i<(int)n;++i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)
#define ALL(c) (c).begin(), (c).end()

int main() {
    long long n;
    cin >> n;

    int r = 100;
    REP(i, (int)ceil(sqrt(n))+1) {
        if(i==0) continue;
        if(n%i != 0) continue;

        string s = to_string(i), t = to_string(n/i);
        r = min(r, (int)max(s.size(), t.size()));
    }

    cout << r << endl;
}


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

/*alias*/
#define REP(i,n) for (int i = 0; i < (n); i++)
#define ALL(obj) (obj).begin(), (obj).end()
using ll=long long;

using namespace std;

/*funcs*/

/*input*/
int n;
string s;
int k;

/*main*/
int main(){
    cin>>n>>s>>k;
    string ans=s;
    for(int i=0;i<s.size();i++){
        if(s[i]!=s[k-1]){
            ans[i]='*';
        }
    }
    cout<<ans;
}

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

int main() {
    int N;
    while (cin >> N, N) {
        vector<int> v(N);
        for (auto& i : v) cin >> i;

        int count = 0;
        while (1) {
            bool flag = false;
            for (int i = 0; i < v.size()-1; i++) {
                if (v[i] > v[i+1]) {
                    count++;
                    swap(v[i], v[i+1]);
                    flag = true;
                }
            }
            if (!flag) break;
        }
        cout << count << endl;
    }

    return 0;
}

Measured memory_bytes: 3088