akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ln "\n"
#define pb push_back
#define pll pair<ll,ll>
#define ppll pair<ll,pll>
#define vll vector<ll>
#define vpll vector<pll>
#define vvll vector<vector<ll>>
#define sll stack<ll>
#define qll queue<ll>
#define mp make_pair
#define f first
#define s second
#define bs binary_search
#define lb lower_bound
#define ub upper_bound
#define Test ll t;cin>>t; while(t--)
#define fast_io ios_base::sync_with_stdio(false);cin.tie(NULL);
#define init(x,n,v) for(ll i=0;i<=n;i++) x[i]=v;
#define all(x) x.begin(),x.end()
ll MOD = 1e9+7 , MAX = 1e18;
int main() 
{
	fast_io;
	string a,b,c="";
	ll n,m,i,j;
	cin>>a>>b;
	n=a.size();
	m=b.size();
	ll dp[n+1][m+1];
	for(i=0;i<=n;i++)
	{
	    for(j=0;j<=m;j++)
	    {
	        if(!i || !j) dp[i][j]=0;
	        else if(a[i-1]==b[j-1]) dp[i][j]=dp[i-1][j-1]+1;
	        else dp[i][j] = max(dp[i][j-1],dp[i-1][j]);
	    }
	}
	i=n,j=m;
	while(i && j)
	{
	    if(a[i-1]==b[j-1]) c.pb(a[i-1]) , i-- , j--;
	    else
        {
            if(dp[i][j]==dp[i-1][j]) i--;
            else j--;
        }
	}
	reverse(all(c));
	cout<<c;
	return 0;
}

Measured memory_bytes: 70656
#include<bits/stdc++.h>
using namespace std;
#define ll long long
int main()
{
    ll r,ck=0;
    string s;

    cin>>r>>s;
    if(r%2!=0)
    {
        cout<<"No"<<endl;
    }
    else
    {
        for(ll i=0; i<r/2; i++)
        {
            if(s[i]!=s[(r/2)+i])
            {
                ck=1;
            }

        }
        if(ck==0)
            cout<<"Yes"<<endl;
        else
            cout<<"No"<<endl;


    }
    return 0;
}



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

int main(){
int K,S,c=0;
  cin >> K >> S;
  
  rep(i,K+1){
    rep(j,K+1){
      if(S-i-j<=K  && S-i-j>=0)
        c++;
    }
  }
  cout << c << endl;
}



Measured memory_bytes: 256
using System;
class p
{
  static void Main()
  {
    int N = int.Parse(Console.ReadLine());
    string S = Console.ReadLine();
    
    int sum = 0;
    char l = 'A';
    for (int i = 0; i < S.Length; i++) {
      if (l != S[i]) {
        sum++;
        l = S[i];
      }
    }
    Console.WriteLine(sum);
  }
}

Measured memory_bytes: 11232
#include <iostream>
#include <vector>
#include <queue>
#include <cstring>
using namespace std;

typedef unsigned long long ll;

struct Rail {
  int from, to;
  int yen, sunuke;
  ll cost;

  bool operator<(const Rail &r) const {
    return this->cost>r.cost;
  }
};

const int N = 100001;
vector<Rail> adj_list[N];

vector<ll> dijkstra(int start, bool changed) {
  vector<ll> res(N);
  bool visited[N] = { 0 };

  priority_queue<Rail> q;
  Rail s = { start, start, 0, 0, 0 };
  q.push(s);
  while (!q.empty()) {
    Rail run_rail = q.top();
    q.pop();

    int c = run_rail.to;
    if (visited[c])
      continue;
    visited[c] = true;
    res[c] = run_rail.cost;

    //cout << now_city+1 << ' ' << cost << endl;

    for (auto r : adj_list[c]) {
      r.cost = run_rail.cost + (changed ? r.sunuke : r.yen);
      q.push(r);
    }
  }

  return res;
}

int main() {
  int n, m, start, goal;
  cin >> n >> m >> start >> goal;
  start--, goal--;
  for (int i=0; i<m; i++) {
    int u, v, yen, sunuke;
    scanf("%d %d %d %d", &u, &v, &yen, &sunuke);
    u--, v--;

    Rail r = { u, v, yen, sunuke, 0 };
    adj_list[u].push_back(r);
    Rail r2 = { v, u, yen, sunuke, 0 };
    adj_list[v].push_back(r2);
  }
  vector<ll> yen_min = dijkstra(start, false);
  vector<ll> sunuke_min = dijkstra(goal, true);

  vector<ll> res(n);
  ll max = 0;
  for (int i=n-1; i>=0; i--) {
    ll s = 1000000000000000 - yen_min[i] - sunuke_min[i];
    if (s>max) {
      max = s;
    }
    res[i] = max;
  }
  for (auto r : res) {
    cout << r << endl;
  }
  return 0;
}



Measured memory_bytes: 23996
#include <bits/stdc++.h>
using namespace std;
#define endl "\n"
#define faster ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
typedef long long ll;
 
typedef vector<int> vi;;
typedef vector<ll> vll;

#define l() length()
#define sz() size()
 
#define b() begin()
#define e() end()
#define all(x) x.begin(), x.end()
 
#define pb(i) push_back(i)
#define PB() pop_back()
 
 
typedef pair<int, int> pii;
typedef pair<ll,ll> pll;
#define mp make_pair
#define Fi first
#define Se second
 
const int maxx=1e6+9;
 
// Happy Coding!

// 1 way is to find compute all the sorted permutations and find the 
// positions of the current permutation.

ll _find(ll n){
    if(n==0){return 0;}
    if(n==1){return 1;}
    return 1+2*_find(n/2);
}
void solve(){
    ll n;
    cin>>n;
    cout<<_find(n)<<endl;
}

int main() {
    faster;
    int t=1;
    // cin>>t;
    while(t-->0){
        solve();
    }
	return 0;
}

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

using namespace std;

int main(){
  int n;
  cin>>n;
  string s = to_string(n);
  int div(0);
  for(int i=0;i<s.size();i++){
    div += s[i]-'0';
  }
  n%div==0?cout<<"Yes":cout<<"No";
  return 0;
}


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

#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define ALL(obj) (obj).begin(), (obj).end()
#define INF 1e9
#define LINF 1e18
typedef long long ll;


int main() {
    int N; cin >> N;
    vector<pair<ll,ll>> P(N);
    ll max_X = -LINF;
    ll min_X = LINF;
    ll max_Y = -LINF;
    ll min_Y = LINF;
    REP(i,N){
        ll x,y; cin >> x >> y;
        //P[i] = {x-y, x+y};
        max_X = max(max_X, x-y);
        min_X = min(min_X, x-y);

        max_Y = max(max_Y, x+y);
        min_Y = min(min_Y, x+y);
    }

    cout << max(max_X-min_X, max_Y-min_Y) << endl; 

    return 0;
}

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

int dp[50][3001];
int main(){
  while(1){
    memset(dp, 0, sizeof(dp));
    dp[0][0] = 1;
    int n, m, s, i, j, k, ans = 0;
    scanf("%d%d%d", &n, &m, &s);
    if(n == 0 && m == 0 && s == 0)return 0;
    n *= n;
    for(i = 1;i <= m;i++){
      for(j = n;j > 0;j--){
	for(k = i;k <= s;k++){
	  dp[j][k] += dp[j - 1][k - i];
	  dp[j][k] %= 100000;
	}
      }
    }
    printf("%d\n", dp[n][s]);
  }
}

Measured memory_bytes: 1192
#include <bits/stdc++.h>
#define LOCAL
using namespace std;
template <typename A, typename B>
ostream& operator <<(ostream& out, const pair<A, B>& a) {
out << "(" << a.first << "," << a.second << ")";
return out;
}
template <typename T, size_t N>
ostream& operator <<(ostream& out, const array<T, N>& a) {
out << "["; bool first = true;
for (auto& v : a) { out << (first ? "" : ", "); out << v; first = 0;} out << "]";
return out;
}
template <typename T>
ostream& operator <<(ostream& out, const vector<T>& a) {
out << "["; bool first = true;
for (auto& v : a) { out << (first ? "" : ", "); out << v; first = 0;} out << "]";
return out;
}
template <typename T, class Cmp>
ostream& operator <<(ostream& out, const set<T, Cmp>& a) {
out << "{"; bool first = true;
for (auto& v : a) { out << (first ? "" : ", "); out << v; first = 0;} out << "}";
return out;
}
template <typename U, typename T, class Cmp>
ostream& operator <<(ostream& out, const map<U, T, Cmp>& a) {
out << "{"; bool first = true;
for (auto& p : a) { out << (first ? "" : ", "); out << p.first << ":" << p.second; first = 0;} out << "}";
return out;
}
#ifdef LOCAL
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
#else
#define trace(...) 42
#endif
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 rep(i,n) for(int i=0; i<(n); i++)
using ll = long long;
#define int long long
using P = pair<int,int>;
//#########################################
signed main(){
    int n;cin >> n;
    string ret;
    int now = 0;
    int m = 1;
    int f = 1;
    auto md = [](int x,int y){
        return (x%y+y)%y;
    };
    rep(_,35){
        if(md(n,m*2) == md(now+m*f,m*2)){
            ret += '1';
            now += m*f;
        }
        else ret += '0';
        m*= 2;
        f = f*(-1);
        // trace(now,f,m);
    }
    // trace(ret);
    string ans;
    int i = 0;
    reverse(ret.begin(),ret.end());
    for(;i < ret.size() && ret[i] == '0';i++);
    if(i == (int)ret.size()){
        cout << 0 << endl;
        return 0;
    }
    for(;i < ret.size();i++){
        ans += ret[i];
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3604
from sys import stdin


def main():
    lines = stdin.readlines()
    S = lines[1]
    lr = [[int(j) - 1 for j in i.split()] for i in lines[2:]]
    AC = []
    pre = None
    cnt = 0
    for c in S:
        if c == "A":
            pre = "A"
        elif pre == "A" and c == "C":
            cnt += 1
            pre = None
        elif pre == "A":
            pre = None
        AC.append(cnt)
    for l, r in lr:
        print(AC[r] - AC[l])
    return


main()


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

int main() {
	int N;
	int ac=0;
	int wa=0;
	int tle=0;
	int re=0;
	cin >> N;

	string x;
	for(int i=0; i<N; i++){
		cin >> x;
		if(x=="AC") {ac++;}
		if(x=="WA") {wa++;}
		if(x=="TLE") {tle++;}
		if(x=="RE") {re++;}
	}	
	cout << "AC x " << ac << endl;
	cout << "WA x " << wa << endl;
	cout << "TLE x " << tle << endl;
	cout << "RE x " << re << endl;
}

Measured memory_bytes: 3628
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <queue>
#include <iomanip>
using namespace std;
const double eps = 1e-9;
const double inf = 1e9;

int main(){
	while(1){
		int n;
		cin >> n;
		if(n==0) break;
		
		vector<double> x(n), y(n), z(n), r(n);
		for(int i=0; i<n; i++){
			cin >> x[i] >> y[i] >> z[i] >> r[i];
		}
		
		vector<vector<double> > dist(n, vector<double>(n, inf));
		for(int i=0; i<n; i++){
			for(int j=i+1; j<n; j++){
				double d = sqrt( (x[i]-x[j])*(x[i]-x[j]) 
					+(y[i]-y[j])*(y[i]-y[j]) +(z[i]-z[j])*(z[i]-z[j]) );
				if(d-r[i]-r[j] < eps){
					dist[i][j] = dist[j][i] = 0.0;
				}else{
					dist[i][j] = dist[j][i] = d -r[i]-r[j];
				}
			}
		}
		
		vector<int> used(n, false);
		double total=0.0;
		priority_queue<pair<double, int> > pq;
		pq.push(make_pair(0.0, 0));
		while(!pq.empty()){
			double cost = -pq.top().first;
			int v = pq.top().second;
			pq.pop();
			if(used[v]) continue;
			used[v]=true;
			total+=cost;
			for(int i=0; i<n; i++){
				pq.push(make_pair(-dist[v][i], i));
			}
		}
		cout << fixed;
		cout << setprecision(3);
		cout << total << endl;
	}
	return 0;
}

Measured memory_bytes: 3496
def main():
    n = int(input())
    s = input()
    for t in ["SS", "SW", "WS", "WW"]:
        for i in s[1:-1]:
            if t[-1] == "S":
                if i == "o":
                    t += t[-2]
                else:
                    t += "S" if t[-2] == "W" else "W"
            else:
                if i == "x":
                    t += t[-2]
                else:
                    t += "S" if t[-2] == "W" else "W"
        # check1
        if t[0] == "S":
            if s[0] == "o":
                f = t[-1] == t[1]
            else:
                f = t[-1] != t[1]
        else:
            if s[0] == "x":
                f = t[-1] == t[1]
            else:
                f = t[-1] != t[1]

        # check2
        if t[-1] == "S":
            if s[-1] == "o":
                g = t[-2] == t[0]
            else:
                g = t[-2] != t[0]
        else:
            if s[-1] == "x":
                g = t[-2] == t[0]
            else:
                g = t[-2] != t[0]

        if f and g:
            print(t)
            break

    else:
        print(-1)


if __name__ == '__main__':
    main()


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

int main(){
    int N, X;
    cin >> N >> X;
    int m[N];

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

    int min = 0;
    int minm = 114514;
    for(int i = 0; i < N; i++){
        min += m[i];
        if(minm > m[i]) minm = m[i];
    }

    int ans = (X-min) / minm;

    cout << N + ans << endl;
}

Measured memory_bytes: 256
//ProblemC

#ifdef _MYPC
#include "mypc.h"
#endif // _MYPC

#include <iostream>
#include <string>
#include <vector>
#include <bitset>
#include <list>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <queue>
#include <stack>
#include <algorithm>
#include <numeric>
#include <functional>
#include <memory>
#include <complex>
#include <cstdio>
#include <cstring>
#include <cmath>

using namespace std;

//ProblemC

class Solve {
private:

	void solve() {
		string s;
		int k;
		cin >> s >> k;

		auto t = s;
		std::partial_sort(t.begin(), t.begin() + min(5, (int)s.length()), t.end());
		t.resize(5, ' ');
		unordered_set<char> okc(t.begin(), t.end());

		set<string> ss;
		for (size_t i = 0; i < s.length(); i++) {
			if (okc.find(s[i]) != okc.end()) {
				for (size_t j = 1; i + j <= s.length() && j <= 5; j++) {
					ss.insert(s.substr(i, j));
				}
			}
		}
		auto it = ss.begin();
		for (int i = 1; i < k; i++) ++it;
		cout << *it << endl;
	}

public:
	Solve() { solve(); }
};

int main(int argc, char* argv[]) {
	unique_ptr<Solve> solve = make_unique<Solve>();
	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long 
using namespace std;
	
const ll siz = 1e5;	
const ll mod = 1e9 + 7;
const ll MAXX = 1e18;	

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	//freopen("INP.txt", "r", stdin);
	//freopen("OUT.txt", "w", stdout);
	string s;
	cin >> s;
	if (s == "SUN") {
		cout << 7 << '\n';
	}
	if (s == "MON") {
		cout << 6 << '\n';
	}
	if (s == "TUE") {
		cout << 5 << '\n';
	}
	if (s == "WED") {
		cout << 4 << '\n';
	}
	if (s == "THU") {
		cout << 3 << '\n';
	}
	if (s == "FRI") {
		cout << 2 << '\n';
	}
	if (s == "SAT") {
		cout << 1 << '\n';
	}
	return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<cmath>
#include<cstdio>
#include<algorithm>
#include<vector>
#include<cstring>
#include<queue>

using namespace std;

#define INF 999999999
#define REP(i,n) for(int i=0; i<(int)(n); i++)

struct pac{
	int t, s, d;
	bool operator<(const pac& a) const{
		if(a.t != t) return t < a.t;
	}
};

int main(){
	int n, m, v[20001], t,s,d;
	int ans;
	vector<pac> rec;
	pac in;
	while(1){
		cin >> n >> m;
		if(!n) break;
		REP(i,n+1) v[i] = 0;
		v[1] = 1;
		rec.clear();
		REP(i,m){
			cin >> in.t >> in.s >> in.d;
			rec.push_back(in);
		}
		sort(rec.begin(), rec.begin()+m);
		REP(i,m){
			if(v[rec[i].s]) v[rec[i].d] = 1;
		}
		ans =0;
		REP(i,n+1){
			if(v[i]) ans++;
		}
		cout << ans << endl;
	}
	return 0;
}

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


int main (){
    int N;
    cin>>N;
    vector<int> A(N), B(N-1);
    for(int i= 0; i<N-1; i++){
        cin>>B.at(i);
      //cout<<B.at(i)<<endl;
    }
    B.push_back(1000000);
    A.at(0)=B.at(0);
    for(int i=1;i<N; i++){
        A.at(i)=min(B.at(i-1), B.at(i));
    }
    int sum=0;
    for(int i=0; i<N; i++){
        sum += A.at(i);
      //cout<<A.at(i)<<endl;
    }
    cout<<sum<<endl;
}
    

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

const long long MOD=1000000007;

int main(){
  int N,M; cin >> N >> M;
  int suki[31]={};
  for(int i=0; i<N; i++){
    int K; cin >> K;
    for(int j=0; j<K; j++){
      int a; cin >> a;
      suki[a]++;
    }
  }
  int result=0;
  for(int i=1; i<=M; i++){
    if(suki[i]==N)  result++;
  }
  cout << result << endl;
}

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

using lnt = long long;
using Real = long double;

#define ALL(obj) (obj).begin(),(obj).end()
#define RALL(obj) (obj).rbegin(),(obj).rend()
#define REP(i, n) for(lnt i=0;i<(n);++i)
#define RANGE(i, a, b) for(lnt i=(a);i<(b);++i)
#define RREP(i, n) for(lnt i=(n)-1;i>= 0;--i)

#define ln '\n'
#define pb push_back
#define eb emplace_back
#define pque priority_queue
#define umap unordered_map
#define uset unordered_set
#define dcout cout<<fixed<<setprecision(20)
#define summon_tourist cin.tie(0);ios::sync_with_stdio(false)

constexpr int dx[]={1,0,-1,0,1,1,-1,-1}, dy[]={0,-1,0,1,1,-1,1,-1};
constexpr Real eps = 1e-9; const Real pi = acosl(-1);
constexpr lnt BIG = INT_MAX/10, BBIG = LLONG_MAX/10;

template<class T> inline T GCD(T a,T b){T c;while(b!=0){c=a%b;a=b;b=c;}return a;}
template<class T> inline T LCM(T a,T b){T c=GCD(a,b);a/=c;return a*b;}
template<class T> inline T nCr(T a,T b){T i,r=1;for(i=1;i<=b;i++){r*=(a+1-i);r/=i;}return r;}
template<class T> inline T nHr(T a,T b){return nCr(a+b-1,b);}
template<class T> inline bool chmax(T& a,T b){if(a<b){a=b;return 1;}return 0;}
template<class T> inline bool chmin(T& a,T b){if(a>b){a=b;return 1;}return 0;}

using pint = pair<int, int>; using plnt = pair<lnt, lnt>;
using vint = vector<int>; using vlnt = vector<lnt>;
constexpr lnt MOD = 1e9+7;

int main(){
	summon_tourist;

	int N; cin >> N;
	string S;
	map<string, int> mp;
	REP(i, N){
		cin >> S;
		mp[S]++;
	}
	cout << "AC x " << mp["AC"] << ln;
	cout << "WA x " << mp["WA"] << ln;
	cout << "TLE x " << mp["TLE"] << ln;
	cout << "RE x " << mp["RE"] << ln;
}

Measured memory_bytes: 3664
import std.stdio, std.string, std.conv, std.range;
import std.algorithm, std.array, std.typecons, std.container;
import std.math, std.numeric, std.random, core.bitop;

enum inf = 1_001_001_001;
enum infl = 1_001_001_001_001_001_001L;
enum mod = 1_000_000_007L;

void main() {
    int N; long K;
    scan(N, K);
    auto a = readln.split.to!(int[]).sort();

    bool check(long x) {
        long cnt;
        foreach (i ; 0 .. N) {
            auto ai = a[i];
            if (ai < 0) {
                auto y = x / ai;
                if (x < 0 && x % ai != 0) y++;
                cnt += a[i + 1 .. $].upperBound(y - 1).length.to!long;
            }
            else if (ai > 0) {
                auto y = x / ai;
                if (x < 0 && x % ai != 0) y--;
                cnt += a[i + 1 .. $].lowerBound(y + 1).length.to!long;
            }
            else { // ai == 0
                cnt += (x >= 0 ? N - 1 - i : 0);
            }
        }
        debug {
            writefln("x: %s, cnt: %s", x, cnt);
        }
        return cnt >= K;
    }

    long ng = -infl, ok = infl;

    while (abs(ok - ng) > 1) {
        long mid = (ok + ng) / 2;
        (check(mid) ? ok : ng) = mid;
    }

    auto ans = ok;
    writeln(ans);
}









void scan(T...)(ref T args) {
    import std.stdio : readln;
    import std.algorithm : splitter;
    import std.conv : to;
    import std.range.primitives;

    auto line = readln().splitter();
    foreach (ref arg; args) {
        arg = line.front.to!(typeof(arg));
        line.popFront();
    }
    assert(line.empty);
}

void fillAll(R, T)(ref R arr, T value) {
    static if (is(typeof(arr[] = value))) {
        arr[] = value;
    }
    else {
        foreach (ref e; arr) {
            fillAll(e, value);
        }
    }
}

bool chmin(T, U...)(ref T x, U args) {
    bool isChanged;

    foreach (arg; args) {
        if (x > arg) {
            x = arg;
            isChanged = true;
        }
    }

    return isChanged;
}

bool chmax(T, U...)(ref T x, U args) {
    bool isChanged;

    foreach (arg; args) {
        if (x < arg) {
            x = arg;
            isChanged = true;
        }
    }

    return isChanged;
}


Measured memory_bytes: 10416
#include <stdio.h>
#include <stack>
#include <math.h>

using namespace std;

struct Point{
	double x,y;
};


int main(){

	int n;
	scanf("%d",&n);
	double gaiseki,sum = 0;

	Point points[n];

	for(int i=0; i < n; i++){
		scanf("%lf %lf",&points[i].x,&points[i].y);
	}
	sum = points[n-1].x*points[0].y - points[n-1].y*points[0].x;
	for(int i=0; i < n-1; i++){
		gaiseki = points[i].x*points[i+1].y - points[i].y*points[i+1].x;
		sum += gaiseki;
	}

	printf("%.1lf\n",fabs(sum)/2);

    return 0;
}

Measured memory_bytes: 2740
#include<iostream>
#include<cstdio>
#include<string> 

using namespace std;

int n;

int main()
{
    cin>>n;
    for(int i=n;;i++){
    	bool f=1;
    	int t=i;
		int tt=t%10;
    	while(t){
    		if(t%10!=tt) f=0;
			t/=10; 
		}
		if(f){
			cout<<i<<endl;
			return 0;
		}
	}
    return 0;
}

Measured memory_bytes: 256
import numpy as np

n, k = map(int, input().split())
MOD = 10 ** 9 + 7
ref = np.array(list(range(n + 1)), dtype='int64')

max_sum = np.sum(ref[-k + 1:])
min_sum = np.sum(ref[:k - 1])
if k == 1:
    max_sum = min_sum = 0
ans = 0

for i in range(k, n + 2):
    min_sum += ref[i - 1]
    max_sum += ref[-i]
    ans += max_sum - min_sum + 1
    ans %= MOD

print(ans)


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

#define double      	long double
#define int         	long long
#define pb          	push_back
#define pii         	pair<int,int>
#define vi          	vector<int>
#define vii         	vector<pii>
#define mi          	map<int,int>
#define mii         	map<pii,int>
#define all(a)      	(a).begin(),(a).end()
#define sz(x)       	(int)x.size()
#define endl        	"\n"
#define repp(i,a,b) 	for(int i=a;i<b;i++)
#define rep(i,a,b) 		for(int i=a;i<=b;i++)
#define brep(i,a,b)     for(int i=a;i>=b;i--)
#define deb1(x)      	cout << #x << "=" << x << endl
#define deb2(x, y)  	cout << #x << "=" << x << "," << #y << "=" << y << endl
#define deb3(x, y, z)  	cout << #x << "=" << x << "," << #y << "=" << y << "," << #z << "=" << z << endl
#define trace(v) 		for(auto it=v.begin();it!=v.end();it++)cout<<*it<<" ";cout<<endl;
#define tracearr(a,l,r) for(int iii=l;iii<=r;iii++)cout << a[iii] << " ";cout << endl;
#define PI          	3.1415926535897932384626
#define F 				first
#define S 				second
#define clr(x) 			memset(x, 0, sizeof(x))
#define IOS         	ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);


typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update> ordered_set;
// *s.find_by_order(1) - gives the 2nd samllest element in set
// s.order_of_key(x)   - gives the number of elements in the set which are strictly smaller than x


const int N=1e6 + 5;
const int MOD=1e9 + 7;

int mp[N];

int find_factors(int f)
{
	int i;
	for(i=1;i*i<=f;i++)
	{
		if(f%i==0)
		{
			if(i*i==f)
			{
				if(mp[i]>0)
					return 0;
			}
			else
			{
				if(mp[i]>0)
					return 0;
				if(mp[f/i]>0)
					return 0;
			}
		}
	}
	return 1;
}

int32_t main()
{
	IOS;
	int T=1;
	// int numOfSetBits = __builtin_popcountll(n);
	std::cout << std::fixed << std::setprecision(12);
	while(T--)
	{
		int n;
		cin >> n;
		int a[n+5];
		rep(i,1,n)
		{
			cin >> a[i];
			mp[a[i]]++;
		}
		int ans = 0;
		rep(i,1,n)
		{
			mp[a[i]]--;
			int flag = find_factors(a[i]);
			if(flag==1)
				ans++;
			mp[a[i]]++;
		}
		cout << ans;
	}
}



Measured memory_bytes: 12964
#include<iostream>
using namespace std;
 
int main(){
  int n,x1,y1,z1,w1,x2,y2,z2,w2;
  while(cin >> n,n){
    for(int i=0;i<n;i++){
      cin >> x1 >> y1 >> z1 >> w1 >> x2 >> y2 >> z2 >> w2;
      cout << x1*x2 - y1*y2 - z1*z2 - w1*w2 << " ";
      cout << y1*x2 + x1*y2 - w1*z2 + z1*w2 << " ";
      cout << z1*x2 + x1*z2 + w1*y2 - y1*w2 << " ";
      cout << w1*x2 - z1*y2 + y1*z2 + x1*w2 << endl;
    }
  }
}

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

int main() {
	int n; cin >> n;
	int a[n][n];
	for(int i = 0; i < n; ++i) {
		for(int j = i + 1; j < n; ++j) {
			for(int k = 0; k < 30; ++k) {
				if((i >> k & 1) ^ (j >> k & 1)) {
					a[i][j] = k;
					break;
				}
			}
		}
	}
	for(int i = 0; i < n; ++i) {
		for(int j = i + 1; j < n; ++j) {
			cout << a[i][j] + 1 << (j == n - 1 ? "\n" : " ");
		}
	}
	return 0;
}


Measured memory_bytes: 1408
#include<iostream>
#include<string>
using namespace std;
int main()
{
    string s,t;
    cin>>s>>t;
    int k=0;
    if(s.at(0)==t.at(0))
        k++;
    if(s.at(1)==t.at(1))
        k++;
    if(s.at(2)==t.at(2))
        k++;
        cout<<k;
    
    
    
    return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
    int main()
    {
        int A,p[51],B=0, i, k[51];
        scanf("%d",&A);
        for(i=1;i<=A;i++){
            scanf("%d",&p[i]);
        }
        for(i=1;i<=A;i++){
            if(p[i]!=i){
                B++;
            }
        }
		if(B==2||B==0){
            printf("YES\n");
        }else{
            printf("NO\n");
        }
     
    return 0;
    }

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

using namespace std;
using int64 = long long;

constexpr int DEBUG = 0;

template<typename T> ostream& operator<<(ostream& s, const deque<T>& v) {
  int len = v.size();
  s << "[";
  for (int i = 0; i < len; i++) {
    if (i > 0) s << ", ";
    s << v[i];
  }
  s << "]";
  return s;
}

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

  int n;
  int64 r, a;
  cin >> n >> r >> a;
  map<int64, int64> map;
  for (int i = 0; i < n; i++) {
    int64 x, h;
    cin >> x >> h;
    map.insert({x, (h + a - 1) / a});
  }

  int64 ans = 0;
  int64 c = 0;
  deque<pair<int64, int64>> xds;
  for (const auto& xv : map) {
    while (!xds.empty() && xds.front().first < xv.first) {
      c += xds.front().second;
      xds.pop_front();
    }
    // cout << "c: " << c << endl;
    if (c < xv.second) {
      int64 delta = xv.second - c;
      ans += delta;
      c += delta;
      xds.push_back({xv.first + 2 * r, -delta});
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 14464
import numpy as np
from collections import Counter
H, W = map(int, input().split())
c = [list(map(int, input().split())) for i in range(10)]
A = np.array([list(map(int, input().split())) for i in range(H)])
for k in range(10):
	for i in range(10):
		for j in range(10):
			tmp_dist = c[i][k] + c[k][j]
			if c[i][j] > tmp_dist:
				c[i][j] = tmp_dist
print(sum(c[k][1] * v for k, v in Counter(A[A != -1]).items()))


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

using namespace std;
using ll = long long;
using ld = long double;

void solve() {
  int n;
  string s;
  cin >> n >> s;

  int l = 0, r = n - 1;
  int cnt = 0;
  while (1) {
    while (l < n && s[l] != 'W') ++l;
    while (r >= 0 && s[r] != 'R') --r;
    if (l >= r) break;
    ++l;
    --r;
    ++cnt;
  }

  cout << cnt << endl;
}

int main() {
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  std::cout << std::fixed << std::setprecision(15);

  solve();
  return 0;
}


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

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

    string s;
    cin >> s;
    vector<string> d = {"SUN", "MON", "TUE", "WED", "THU", "FRI", "SAT"};
    rep(i, 7) if (d[i] == s)
    {
        cout << 7 - i << endl;
        return 0;
    }
}

Measured memory_bytes: 256
import java.io.*;
import java.util.*;
public class Main{
	static class node implements Comparable<node>{
		private int deg;
		private int id;
		public node(int deg, int id) {
			this.deg = deg;
			this.id = id;
		}
		public int compareTo(node node) {
			Integer a = this.deg;
			Integer b = node.deg;
			return a.compareTo(b);
		}
	}
	public static int n, m;
	public static List<Integer> adj[];
	public static int dist[];
	public static int ord[];
	public static node nodes[];
	public static List<Integer> rpar[];
	public static int dp[];
    public static void main(String[] args) throws IOException{
    	FastScanner sc = new FastScanner();
    	PrintWriter out = new PrintWriter(System.out);
    	n = sc.nextInt();
    	m = sc.nextInt();
    	dist = new int[n];
    	rpar = new ArrayList[n];
    	dp = new int[n];
    	adj = new ArrayList[n];
    	nodes = new node[n];
    	ord = new int[n];
    	for(int i=0; i<n; i++) {
    		nodes[i] = new node(0,i);
    		rpar[i] = new ArrayList<>();
    		adj[i] = new ArrayList<>();
    	}
    	for(int i=0; i<m; i++) {
    		int a = sc.nextInt()-1;
    		int b = sc.nextInt()-1;
    		adj[a].add(b);
    		rpar[b].add(a);
    		nodes[b].deg++;
    	}
    	int ans = 0;
    	topsort();
    	for(int i=0; i<n; i++) {
    		if(rpar[ord[i]].size()==0) {
    			dp[ord[i]]=0;
    		}else {
    			int max = 0;
    			for(int j:rpar[ord[i]]) {
    				max = Math.max(dp[j]+1, max);
    			}
    			dp[ord[i]] = max;
    		}
    		ans = Math.max(dp[ord[i]], ans);
    	}
    	out.println(ans);
    	out.close();
    }
    public static void topsort() {
    	int idx = 0;
    	PriorityQueue<node> pq = new PriorityQueue<>();
    	for(int i=0; i<n; i++) {
    		if(nodes[i].deg==0) {
    			pq.add(nodes[i]);
    		}
    	}
    	while(!pq.isEmpty()) {
    		node curr = pq.poll();
    		ord[idx] = curr.id;
    		for(int i:adj[curr.id]) {
    			nodes[i].deg--;
    			if(nodes[i].deg==0) pq.add(nodes[i]);
    		}
    		idx++;
    	}
    }
    public static class FastScanner {
    	BufferedReader br;
    	StringTokenizer st;

    	public FastScanner(String s) {
    		try {
    			br = new BufferedReader(new FileReader(s));
    		} catch (FileNotFoundException e) {
    			e.printStackTrace();
    		}
    	}

    	public FastScanner() {
    		br = new BufferedReader(new InputStreamReader(System.in));
    	}
    	
    	String nextToken() {
    		while (st == null || !st.hasMoreElements()) {
    			try {
    				st = new StringTokenizer(br.readLine());
    			} catch (IOException e) {
    				e.printStackTrace();
    			}
    		}
    		return st.nextToken();
    	}

    	String nextLine() {
    		st = null;
    		try {
    			return br.readLine();
    		} catch (IOException e) {
    			e.printStackTrace();
    		}
    		return null;
    	}

    	int nextInt() {
    		return Integer.parseInt(nextToken());
    	}

    	long nextLong() {
    		return Long.parseLong(nextToken());
    	}

    	double nextDouble() {
    		return Double.parseDouble(nextToken());
    	}
    }
}


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

vector<int> to[200005];
vector<int> ans;

void dfs(int v,int p = -1){
  for (int u : to[v]){
    if(u == p) continue;
    ans[u] += ans[v];
    dfs(u,v);
  }
}

int main(){
  int n,q;
  cin >>n>>q;
  rep(i,n-1){
    int a,b;
    cin >>a>>b;
    a--; b--;
    to[a].push_back(b);
    to[b].push_back(a);
  }
  ans.resize(n);
  rep(i,q){
    int p,x;
    cin >>p>>x;
    --p;
    ans[p] += x;
  }
  dfs(0);
  rep(i,n) cout << ans[i] << " ";
  cout << endl;
}

Measured memory_bytes: 23552
def funcF(n):
  if n % 2 == 0:
    return n//2
  else:
    return 3*n+1

s = int(input())
a=[0,s]
i=1
while True:
  newS = funcF(a[i])
  if newS in a:
    print(i+1)
    break
  a.append(newS)
  i += 1



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

int n, u, k, v;
int g[101][101];

int main() {
    cin >> n;

    for (int i = 0; i < n; ++i) {
        cin >> u >> k;
        u--;
        for (int j = 0; j < k; ++j) {
            cin >> v;
            v--;
            g[u][v] = 1;
        }
    }

    for (int i = 0; i < n; ++i) {
        for (int j = 0; j < n; ++j) {
            cout << g[i][j] << (j == n - 1 ? "\n" : " ");
        }
    }

    return 0;
}

Measured memory_bytes: 3112
import math
import numpy as np

x = int(input())
x_sqrt = math.sqrt(x)
maxlist = []

def hoge(x, x_sqrt):
    for b in range(2, x_sqrt+1):
        i = 1
        while b ** i <= x:
            i += 1
        maxlist.append(b **(i-1))
    return np.max(np.array(maxlist))

if x - x_sqrt == 0:
    print(x)
else:
    print(hoge(x, int(x_sqrt)))

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

using namespace std;

typedef long long ll;
typedef pair<ll, ll> P;
typedef pair<int, int> Pi;
typedef vector<ll> Vec;
typedef vector<int> Vi;
typedef vector<string> Vs;
typedef vector<vector<ll>> VV;
typedef vector<vector<int>> VVi;

#define REP(i, a, b) for(ll i=(a); i<(b); i++)
#define PER(i, a, b) for(ll i=(a); i>=(b); i--)
#define rep(i, n) REP(i, 0, n)
#define per(i, n) PER(i, n, 0)
const ll INF=1e18+18;
const ll MAX=100005;
const ll MOD=1000000007;
#define Yes(n) cout << ((n) ? "Yes" : "No") << endl;
#define YES(n) cout << ((n) ? "YES" : "NO") << endl;
#define ALL(v) v.begin(), v.end()
#define rALL(v) v.rbegin(), v.rend()
#define pb(x) push_back(x)
#define mp(a, b) make_pair(a,b)
#define Each(a,b) for(auto &a :b)
#define REPM(i, mp) for (auto i = mp.begin(); i != mp.end(); ++i)
#define dbg(x_) cerr << #x_ << ":" << x_ << endl;
#define dbgmap(mp) cerr << #mp << ":"<<endl; for (auto i = mp.begin(); i != mp.end(); ++i) { cerr << i->first <<":"<<i->second << endl;}
#define dbgarr(n,m,arr) rep(i,n){rep(j,m){cerr<<arr[i][j]<<" ";}cerr<<endl;}
#define dbgdp(n,arr) rep(i,n){cerr<<arr[i]<<" ";}cerr<<endl;
#define sum(v) accumulate(ALL(v),0)
#define fi first
#define se second

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

template<typename T1, typename T2>
ostream &operator<<(ostream &s, const pair<T1, T2> &p) { return s<<"("<<p.first<<", "<<p.second<<")"; }

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

// 2 dimentional vector
template<typename T>
ostream &operator<<(ostream &s, const vector<vector<T> > &vv) {
    int len=vv.size();
    for(int i=0; i<len; ++i) {
        s<<vv[i]<<endl;
    }
    return s;
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout<<std::setprecision(10);

    ll n;
    cin>>n;
    Vec a(n);
    rep(i,n)cin>>a[i];
    rep(i,n){
        a[i] -= (i+1);
    }
    sort(ALL(a));

    ll x = a[n/2];

    ll ans=0;
    rep(i,n){
        ans += abs(a[i]-x);
    }
    
    cout<<ans<<endl;
    return  0;
}


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

int main(){
  int n,m,l;
  cin >> n >> m >> l;

  int a[n][m],b[m][l];

  for(int i=0;i<n;i++){
    for(int j=0;j<m;j++){
      cin >> a[i][j];
    }
  }

  for(int i=0;i<m;i++){
    for(int j=0;j<l;j++){
      cin >> b[i][j];
    }
  }

  long long int c[n][l];

  for(int i=0;i<n;i++){
    for(int j=0;j<l;j++){
      c[i][j] = 0;
    }
  }

  for(int i=0;i<n;i++){
    for(int j=0;j<l;j++){
      for(int k=0;k<m;k++){
        c[i][j] += a[i][k]*b[k][j];
      }
    }
  }

  for(int i=0;i<n;i++){
    for(int j=0;j<l;j++){
      if(j!=l-1){
        cout << c[i][j] << " ";
      }else{
        cout << c[i][j] << endl;
      }
    }
  }

  return 0;
}



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

int main(void){
    
    string S, command, changeStr;      //変数：各命令を「 command 」と置き換え文字「 changeStr 」置く
    int q, a, b;
    
    cin >> S;
    cin >> q;
    
    for(int i = 0; i < q; i++){
        cin >> command >> a >> b;
        
        //　判定：置き換え( replace(始点、置き換えたい長さ、置き換え文字) )
        if(command == "replace") {
            cin >> changeStr;
            S.replace(a, b - a + 1, changeStr);
        }
        
        // 判定：反転( reverse(始点、終点) )        
        if(command == "reverse") {
            reverse(S.begin() + a, S.begin() + (b + 1));
        }
        
        // 判定：表示 ( substr(始点、置き換えたい長さ )      
        if(command == "print") {
            cout << S.substr(a, b - a + 1) << endl;
        }    
    }
}



Measured memory_bytes: 3200
#include<bits/stdc++.h>
using namespace std;
int main()
{
    long long a, b, c, d, x, y;
    cin>>a>>b>>c>>d;
    x=max(a*c, a*d);
    y=max(b*c, b*d);
    cout<<max(x, y)<<endl;
    return 0;
}


Measured memory_bytes: 3528
using System;
using System.Collections.Generic;

class main
{
    static void Main(string[] args)
    {
        string[] read = Console.ReadLine().Split(' ');
        long a = long.Parse(read[0]);
		long b = long.Parse(read[1]);
		long c = long.Parse(read[2]);
		long d = long.Parse(read[3]);

		long max;
		max = a * c;
		if(max < a * d)
		{
			max = a * d;
		}
		if(max < b * c)
		{
			max = b * c;
		}
		if (max < b * d)
		{
			max = b * d;
		}
		Console.WriteLine(max);
	}
}



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

int main() {
	int n;
	cin >> n;
	int a[n];
	for (int i = 0; i < n; i++) {
		cin >> a[i];
	}
	bool color[8];
	fill(color, color + 8, false);
	int pro = 0;
	for (int i = 0; i < n; i++) {
		if (a[i] < 400) color[0] = true;
		else if (a[i] < 800) color[1] = true;
		else if (a[i] < 1200) color[2] = true;
		else if (a[i] < 1600) color[3] = true;
		else if (a[i] < 2000) color[4] = true;
		else if (a[i] < 2400) color[5] = true;
		else if (a[i] < 2800) color[6] = true;
		else if (a[i] < 3200) color[7] = true;
		else pro++;
	}

	int count = 0;
	for (int i = 0; i < 8; i++) {
		if (color[i]) count++;
	}
	cout << max(1, count) << ' ' << count + pro << endl;
	return 0;
}


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

int main()
{
	// x = rx - d
	int r,d,x;	cin>>r>>d>>x;
	int res = r * x - d;
	for (int i = 0;i<10;i++)
	{
		cout<<res<<endl;
		res = r * res - d;
	}
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <queue>
#include <string>
#include <set>
#include <cstdint>
#include <numeric>
#define INF 1000000000
#define LLINF 2000000000000000000
#define MOD 1000000007
using namespace std;
#define FOR(i,a,b) for(int i=a;i<b;i++)
#define LOOP(i,N) for(int i=0;i<N;i++)
#define LOOP1(i,N) for(int i=1;i<=N;i++)
typedef pair<int,int> P;
typedef pair<int,pair<int,int> > PP;
#define int long long

signed main(){
  int n;
  cin >> n;
  int a[n], b[n];
  int xt,yt,xb,yb;
  LOOP(i,n){
    cin >> a[i] >> b[i];

    if(i==0){
      xt = xb = a[i]+b[i];
      yt = yb = b[i]-a[i];
    }else{
      int x = a[i] + b[i];
      int y = b[i] - a[i];

      if(xt < x){
        xt = x;
      }
      if(xb > x){
        xb = x;
      }
      if(yt < y){
        yt = y;
      }if(yb > y){
        yb = y;
      }
    }
  }
  int ans = xt-xb;
  if(ans < yt-yb){
    cout << yt-yb << endl;
  }else{
    cout << ans << endl;
  }
  // printf("%lld,%lld,%lld,%lld\n", xt,xb,yt,yb);
}


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

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

  int n;
  cin >> n;

  vector<int> x;
  vector<int> xv;

  for (int i = 0; i < n; i++) {
    int v;
    cin >> v;

    x.push_back(v);

    xv.push_back(v);
  }

  sort(x.begin(), x.end());

  int l = x[n / 2 - 1];
  int r = x[n / 2];

  for (int i = 0; i < n; i++) {
    if (xv[i] < r) {
      cout << r;
    } else {
      cout << l;
    }

    cout << endl;
  }

  return 0;
}

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

int main(){

    int i,j,n;
    int out=0;
    char s[10];
    scanf("%d", &n);
    if(n!=0){
      int base[4]={};
      while(n>0){
	if(out<3){
	  scanf("%s", s);
	  if(strcmp(s, "HIT") ==0)
	    {base[3]+=base[2];base[2]=base[1];base[1]=base[0];base[0]=1;}
	  if(strcmp(s, "HOMERUN") ==0)
	    {base[3]=base[3]+base[2]+base[1]+base[0]+1;base[0]=0;base[1]=0;base[2]=0;}
	  if(strcmp(s, "OUT") ==0)
	    out++;
	  //printf("%d %d %d %d\n", base[0], base[1], base[2], base[3]);
	}
	else
	  {out=0;printf("%d\n", base[3]);n--;base[0]=0;base[1]=0;base[2]=0;base[3]=0;}
      }
    }
  return 0;
}

Measured memory_bytes: 2664
#include "bits/stdc++.h"
using namespace std;
#define rep(i,n) for(int (i)=0;(i)<(int)(n);++(i))
#define rer(i,l,u) for(int (i)=(int)(l);(i)<=(int)(u);++(i))
#define reu(i,l,u) for(int (i)=(int)(l);(i)<(int)(u);++(i))
static const int INF = 0x3f3f3f3f; static const long long INFL = 0x3f3f3f3f3f3f3f3fLL;
typedef vector<int> vi; typedef pair<int, int> pii; typedef vector<pair<int, int> > vpii; typedef long long ll;
template<typename T, typename U> static void amin(T &x, U y) { if(y < x) x = y; }
template<typename T, typename U> static void amax(T &x, U y) { if(x < y) x = y; }

template<int MOD>
struct ModInt {
	static const int Mod = MOD;
	unsigned x;
	ModInt() : x(0) {}
	ModInt(signed sig) { int sigt = sig % MOD; if(sigt < 0) sigt += MOD; x = sigt; }
	ModInt(signed long long sig) { int sigt = sig % MOD; if(sigt < 0) sigt += MOD; x = sigt; }
	int get() const { return (int)x; }

	ModInt &operator+=(ModInt that) { if((x += that.x) >= MOD) x -= MOD; return *this; }
	ModInt &operator-=(ModInt that) { if((x += MOD - that.x) >= MOD) x -= MOD; return *this; }
	ModInt &operator*=(ModInt that) { x = (unsigned long long)x * that.x % MOD; return *this; }

	ModInt operator+(ModInt that) const { return ModInt(*this) += that; }
	ModInt operator-(ModInt that) const { return ModInt(*this) -= that; }
	ModInt operator*(ModInt that) const { return ModInt(*this) *= that; }
};
typedef ModInt<1000000007> mint;

int main() {
	int N; int C;
	while(~scanf("%d%d", &N, &C)) {
		vector<int> A(N);
		for(int i = 0; i < N; ++ i)
			scanf("%d", &A[i]);
		vector<int> B(N);
		for(int i = 0; i < N; ++ i)
			scanf("%d", &B[i]);
		const int X = 400;
		vector<vector<mint>> sumPows(X + 1, vector<mint>(X + 1));
		rer(x, 1, X) {
			mint xx = x;
			sumPows[x][0] = 1;
			rer(y, 1, X)
				sumPows[x][y] = sumPows[x][y - 1] * xx;
			rer(y, 0, X)
				sumPows[x][y] += sumPows[x - 1][y];
		}
		vector<vector<mint>> dp(N + 1, vector<mint>(C + 1));
		dp[0][0] = 1;
		rep(i, N) {
			rer(j, 0, C) {
				mint x = dp[i][j];
				if(x.x == 0) continue;
				rer(k, 0, C - j) {
					mint sum = sumPows[B[i]][k] - sumPows[A[i] - 1][k];
					dp[i + 1][j + k] += x * sum;
				}
			}
		}
		mint ans = dp[N][C];
		printf("%d\n", ans.get());
	}
	return 0;
}


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

int main(){
  long long N,K;
  long long i;
  cin >> N >> K;
  vector<long long> h(N);
  for(i=0;i<N;i++){
    cin >> h[i];
  }
  sort(h.begin(),h.end());
  vector<long long> dif(N-K+1);
  for(i=0;i<N-K+1;i++){
    dif[i] = h[i+K-1] - h[i];
  }
  
  cout << *min_element(dif.begin(),dif.end()) << "\n";
}


Measured memory_bytes: 1792
#include<bits/stdc++.h>
#define rep(i,n) for(int i = 0;i<n;i++)
using namespace std;
typedef pair<int,int> P;
typedef long long ll;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0;}
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0;}



int main() {
    string s;
    cin >> s;
    if(s=="SUN") cout << 7 << endl;
    else if(s=="MON") cout << 6 << endl;
    else if(s=="TUE") cout << 5 << endl;
    else if(s=="WED") cout << 4 << endl;
    else if(s=="THU") cout << 3 << endl;
    else if(s=="FRI") cout << 2 << endl;
    else cout << 1 << endl;
}

Measured memory_bytes: 3556
#include <bits/stdc++.h>
#define l_ength size
const int inf = (1<<30);
const int mod = 1000000007; // 998244353
using ll = long long;
using namespace std;

const ll m = 26;

int main(){
	ll n; cin >> n;
	string ans = "";
	while( n > 0 ){
		--n;
		ll k = n%m;
		n /= m;
		char c = 'a' + k;
		ans += c;
	}
	reverse( ans.begin(), ans.end() );
	cout << ans << endl;
}


Measured memory_bytes: 3600
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main () {
  int N;
  ll K;
  cin >> N >> K;
  vector<ll>A(N);
  for (int i = 0; i < N; i ++) cin >> A[i];
  ll num[44];
  for (int i = 0; i < 44; i ++) num[i] = 0;
  for (int i = 0; i < N; i ++) {
    ll a = A[i];
    for (int j = 0; j < 44; j ++) {
      num[j] += a % 2;
      a /= 2;
    }
  }
  int kbit[44];
  ll k_ = K;
  for (int i = 0; i < 44; i ++) {
    kbit[i] = (int)k_ % 2;
    k_ /= 2;
  }
  //for (int i = 0; i < 40; i ++) cout << num[i] << endl;
  //cout << endl;
  //for (int i = 0; i < 40; i ++) cout << kbit[i] << endl;
  //cout << endl;
  ll dp[45][2];
  for (int i = 0; i < 45; i ++) dp[i][0] = dp[i][1] = -1;
  dp[44][0] = 0;
  ll bi[44];
  bi[0] = 1;
  for (int i = 1; i < 44; i ++) bi[i] = bi[i - 1] * 2;
  for (int i = 43; i >= 0; i --) {
    ll kj = num[i];
    ll kj_ = (ll)N - kj;
    if (dp[i + 1][0] != -1) {
      if (kbit[i] == 0) {
        dp[i][0] = max(dp[i][0], dp[i + 1][0] + (kj * bi[i]));
      }
      else {
        dp[i][0] = max(dp[i][0], dp[i + 1][0] + (kj_ * bi[i]));
        dp[i][1] = max(dp[i][1], dp[i + 1][0] + (kj * bi[i]));
      }
    }
    if (dp[i + 1][1] != -1) {
      dp[i][1] = max(dp[i][1], dp[i + 1][1] + (max(kj, kj_) * bi[i]));
    }
    //cout << dp[i + 1][0] << ' ' << dp[i + 1][1] << endl;
  }
  //cout << endl;
  cout << max(dp[0][0], dp[0][1]) << endl;
}


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

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


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

int main(){
  int A, B, C;
  cin >> A >> B >> C;

  if(A == B){
    cout << C << endl;
  }
  if(A == C){
    cout << B << endl;
  }
  if(B == C){
    cout << A << endl;
  }
}


Measured memory_bytes: 256
N = int(input())
S = str(input())

ord_list = []

for i in range(len(S)):
	tmp = ord(S[i])
	ord_list.append(tmp)

ans_num_list = []

for i in range(len(S)):
	if ord_list[i] + N <= 91:
		ans_num_list.append(ord_list[i] + N)
	else:
		ans_num_list.append(ord_list[i] + N - 26)

ans_list = [chr(i) for i in ans_num_list]

ans_list2 = []

for i in range(len(ans_list)):
	if ans_list[i] == "[":
		ans_list2.append("A")
	else:
		ans_list2.append(ans_list[i])

print("".join(ans_list2))

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

int main() {
 int N,A,B;
  cin >> N >> A >> B;
 
 int sum=0;
 int resum=0;
  
 for(int i=0;i<=N;i++){
   sum=(i-i%10000)/10000+(i%10000-i%1000)/1000+(i%1000-i%100)/100+(i%100-i%10)/10+i%10;
   
   if(A<=sum&&sum<=B){
     resum=resum+i;
   }
 }
  cout<<resum<<endl;
}


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

int main(){
	char group[13];
	for(int i=1;i<13;i++){
		if(i==2)group[i]='c';
		else if(i<8){
			if(i%2==0)group[i]='b';
			else group[i]='a';
		}else{
			if(i%2==0)group[i]='a';
			else group[i]='b';
		}
	}

	int x,y;	cin>>x>>y;
	if(group[x]==group[y])cout<<"Yes"<<endl;
	else cout<<"No"<<endl;

	return 0;
}


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

using int64 = long long;

int64 Solve(int64 k, const int64 a, const int64 b) {
  if (a + 1 >= b)
    return k + 1;

  int64 n = k - a + 1;
  return n / 2 * (b - a) + a + n % 2;
}

int main() {
  int64 k, a, b;
  cin >> k >> a >> b;
  cout << Solve(k, a, b) << "\n";
  return 0;
}


Measured memory_bytes: 256
package main

import "fmt"

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

	ans := x
	for i := 0; i < n; i++ {
		var a int
		fmt.Scan(&a)
		ans += (d-1)/a + 1
	}

	fmt.Println(ans)
}


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

import sys
from collections import defaultdict

def input(): return sys.stdin.readline().strip()
def list2d(a, b, c): return [[c] * b for i in range(a)]
def list3d(a, b, c, d): return [[[d] * c for j in range(b)] for i in range(a)]
def list4d(a, b, c, d, e): return [[[[e] * d for j in range(c)] for j in range(b)] for i in range(a)]
def ceil(x, y=1): return int(-(-x // y))
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(N=None): return list(MAP()) if N is None else [INT() for i in range(N)]
def Yes(): print('Yes')
def No(): print('No')
def YES(): print('YES')
def NO(): print('NO')
sys.setrecursionlimit(10 ** 9)
INF = 10 ** 18
MOD = 10 ** 9 + 7

N, W = MAP()
WV = []
for i in range(N):
    w, v = MAP()
    WV.append((w, v))

dp = [defaultdict(int) for i in range(N+1)]
dp[0][0] = 0
for i in range(N):
    w, v = WV[i]
    for k in dp[i].keys():
        dp[i+1][k] = max(dp[i+1][k], dp[i][k])
        if k+w <= W:
            dp[i+1][k+w] = max(dp[i+1][k+w], dp[i][k] + v)
print(max(dp[N].values()))


Measured memory_bytes: 12308
#include <stdio.h>

int main(){
    int num;
    scanf("%d", &num);
    
    bool cekNum = false;
    for(int i=1;i<=9;i++){
        for(int j=1;j<=9;j++){
            if(num == (i*j)){
                cekNum = true;
            }
        }
    }
    
    if(cekNum){
        puts ("Yes");
    }else{
        puts ("No");
    }
    
    return 0;
}

Measured memory_bytes: 1660