akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
int dx[]={-1,1,0,0};
int dy[]={0,0,-1,1};
#define ull unsigned long long int
#define ll long long int
#define MAX 1000000007
//1e9+7
#define pll pair<ll,ll>
#define pii pair<int,int>
#define IO ios_base::sync_with_stdio(false); cin.tie(NULL);
#define TEST ll t;cin>>t;while(t--)
ll sizes[100001];
ll arr[100001];

bool ok=true;
ll A[100001];
pll B[100001];

ll root(ll i){
    while(i!=arr[i]) i=arr[i];
    return(i);
}
void Union(ll i,ll j){
    ll root_i=root(i),root_j=root(j);
    if(root_i==root_j) return;
    if(sizes[root_i]>sizes[root_j]) swap(root_i,root_j);
    sizes[root_j]+=sizes[root_i];
    arr[root_i]=arr[root_j];
    return;
}
ll Arr[100001];
bool solve(ll n){
    if(n==1) return(true);
    set<ll> st;
    for(ll i=0;i<n;i++){
        ll m=(Arr[i]+i)%n;
        if(m<0) m+=n;
        if(st.count(m)) return(false);
        st.insert(m);
    }
    return(true);
}
#define p4l pair<pll,pll>
int main(){
    IO
    ll N;
    cin>>N;
    ll dig[]={0,2,5,5,4,5,6,3,7,6};
    ll g,p;
    cin>>g;
    for(ll i=1;i<=N-1;i++) {cin>>p;g=__gcd(g,p);}
    cout<<g;
    return(0);
}


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

using namespace std;

int main()
{
    int n,a[100009],b[100009];
    cin >> n;
    int ans=0;
    a[0]=a[n+1]=0;
    for(int i=1;i<=n;i++)
    {
        scanf("%d",&a[i]);
        ans+=abs(a[i]-a[i-1]);
    }
    ans+=abs(a[n]);
    for(int i=1;i<=n;i++)
    {
        b[i]=abs(a[i]-a[i+1])+abs(a[i]-a[i-1])-abs(a[i+1]-a[i-1]);
    }
    for(int i=1;i<=n;i++)
    {
        printf("%d\n",ans-b[i]);
    }
    return 0;
}


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

using namespace std;

typedef pair<int, int> P;

P f(P a, P b)
{
	return make_pair(b.first - a.first, b.second - a.second);
}

int main()
{
	int m, n;

	while (true) {
		cin >> m;
		if (m == 0) break;

		vector<P> seiza(m);

		for (int i = 0; i < m; ++i) cin >> seiza[i].first >> seiza[i].second;

		cin >> n;

		vector<P> image(n);

		for (int i = 0; i < n; ++i) cin >> image[i].first >> image[i].second;

		P s0 = seiza[0];

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

			P amount_of_change = f(s0, image[i]);
			for (int j = 1; j < m; ++j) {
				P sj = seiza[j];
				for (int k = 0; k < n; ++k) {
					if (sj.first + amount_of_change.first == image[k].first && sj.second + amount_of_change.second == image[k].second) {
						cnt++;
					}
				}
				if (cnt == m) {
					printf("%d %d\n", amount_of_change.first, amount_of_change.second);
					goto end;
				}
			}
		}
end:;
	}
}

Measured memory_bytes: 1184
#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; 
  
#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update> 
 
#define FS              ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define ll              long long int
#define ld              long double
#define pb              push_back
#define bp              __builtin_popcount
#define sz              size()
#define ff              first
#define ss              second
#define vll             vector<ll>
#define vbool           vector<bool>
#define vpll            vector<pair<ll,ll>>
#define pll             pair<ll,ll>
#define vllv            vector<vector<ll>>
#define setpri(x)       cout<<setprecision(x)<<fixed;
#define all(v)          v.begin(),v.end()
#define allr(v)         v.rbegin(),v.rend()
#define yesr {cout<<"YES"<<endl;return;}
#define nor {cout<<"NO"<<endl;return;}
// getline (std::cin,name);
ll MOD=1e9+7;
ll ceil1(ll n,ll x){return (n-1)/x+(n>0);}

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

ll pow1(ll n,ll m ,ll mod=MOD );
ll pow2(ll n,ll k);

ll modinv(ll n,ll mod=MOD){  return pow1(n,mod-2,mod);}

bool func(pair<ll,ll> &a,pair<ll,ll> &b ){
        if(a.ff != b.ff)return a.ff < b.ff;
        return a.ss > b.ss;
}
ll const N=(ll)1e5+111;
ll const LG=(ll)log2(N)+1;


void solve(){
        ll i,j,k,l,n,m,x,y,z,r;
        cin>>n;

        vll a(n+11,1);
        a[1]=1;
        vbool vis(n+11);
        for(i=2;i<=n;i++){
                for(j=1;j*i<=n;j++){
                        a[i*j]++;
                }
        }
        ll sum=0;
        for(i=1;i<=n;i++){
                sum+=i*a[i];
        }
        cout<<sum<<endl;
        
        
}       
int main(){
        FS;
        
        ll i,j,k,n,m,x,y,z,q;
        q=1;
        // cin>>q;
        while(q--){
                solve();
        }
        return 0;
}


ll pow1(ll n,ll m,ll mod){
        if(m==0)return 1;
        
        if(m%2==0)return pow1((n*n)%mod,m/2,mod);
    	
    	return (pow1((n*n)%mod,m/2,mod)*n)%mod;
}

ll pow2(ll n,ll k){
        ll ans=1;
            while(k>0){
                if(k%2==1)ans=ans*n;
                n=n*n;
                k/=2;
            }
            return ans;
}


Measured memory_bytes: 82656
#include <iostream>
#include <string>

int main()
{
	int a, b, c;
	std::cin >> a >> b >> c;

	std::string ans = "";
	if( a <= c and c <= b ) {
		ans = "Yes";
	}
	else {
		ans = "No";
	}

	std::cout << ans << std::endl;
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i, m, n) for(int (i) = (m); (i) < (n); ++i)
#define rep(i, n) REP(i, 0, n)
#define all(x) (x).begin(), (x).end()
using namespace std;
using Graph = vector<vector<int>>;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
typedef long long ll;
typedef pair<ll, ll> P;
const int INF = 1e9+7;
const ll LINF = 1LL<<60;

int main()
{
    int n, m, q;
    cin >> n >> m >> q;
    int p[509][509];
    memset(p, 0, sizeof(p));

    REP(i, 1, m + 1) {
        int l, r;
        cin >> l >> r;
        p[l][r] += 1;
    }

    REP(i, 1, n + 1) {
        REP(j, 1, n+1) {
            p[i][j] += p[i][j-1];
        }
    }
    REP(i, 1, n + 1) {
        REP(j, 1, n+1) {
            p[i][j] += p[i-1][j];
        }
    }

    REP(i, 1, q+1) {
        int l, r;
        cin >> l >> r;
        cout << p[r][r] + p[l-1][l-1] - p[l-1][r] - p[r][l-1] << endl;
    }

    return 0;
}

Measured memory_bytes: 1920
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<iomanip>
#include<math.h>
#include<complex>
#include<queue>
#include<deque>
#include<stack>
#include<map>
#include<set>
#include<bitset>
#include<functional>
#include<assert.h>
#include<numeric>
#include<stdio.h>
#include <cstdint>
#include <stdlib.h> 
#include <time.h>
using namespace std;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
#define all(a) a.begin(), a.end()
#define fi first
#define se second
#define RNG(x, a, n) &((x)[a]), &((x)[n])
long long gcd(long long a, long long b) { return b == 0 ? a : gcd(b, a % b); }
long long lcm(long long a, long long b) { return a / gcd(a, b) * b; }
typedef long long ll;
typedef pair<ll, ll> Pll;
typedef vector<ll> Vl;
template<typename T> bool chmax(T& a, const T& b) { if (a < b) { a = b; return true; } return false; }
template<typename T> bool chmin(T& a, const T& b) { if (a > b) { a = b; return true; } return false; }
const int inf = 1e9 + 7;
const ll longinf = 1LL << 60;
const ll mod = 1e9 + 7;
const long double PI = (acos(-1));
const long double EPS = 0.0000000001;


int n, x, y;
int g[2005][2005];
int k[2005];

int main() {

	cin >> n >> x >> y;

	REP(i, 1, n + 1) {
		REP(j, i + 1, n + 1) {
			if (i != j) {
				g[i][j] = j - i;
			}
		}
	}

	REP(i, 1, n + 1) {
		REP(j, i + 1, n + 1) {
			if (i != j) {
				if (abs(x - i) < abs(y - i)) {
					g[i][j] = min(g[i][j], abs(x - i) + abs(y - j) + 1);
				}
				else {
					g[i][j] = min(g[i][j], abs(y - i) + abs(x - j) + 1);
				}
			}
		}
	}

	REP(i, 1, n + 1) {
		REP(j, i + 1, n + 1) {
			k[g[i][j]]++;
		}
	}

	REP(i, 1, n)cout << k[i] << endl;

	return 0;
}

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

int main(){
    int n;
    cin>>n;
    vector<int>d(3*n);

    for(int i=0;i<3*n;i++){
        cin>>d.at(i);
        }
    sort(d.begin(),d.end());
    long long ans=0;
    for(int i=n;i<3*n;i+=2){
        ans+=d.at(i);
        }
    cout<<ans<<endl;
    }


Measured memory_bytes: 1408
#include <bits/stdc++.h>
#ifdef JLOCAL
#include "stress.h"
#endif
using namespace std;

#define rep(i, z, n) for (int i = (z); i < int(n); ++i)
#define repr(i, n, z) for (int i = int(n) - 1; i >= (z); --i)
#define shl(n) (1 << (n))
#define hbit(n, i) (((n) >> (i)) & 1)

#define STRESS 1
using lint = long long;

void solve(istream& cin, ostream& cout) {
    int n;
    cin >> n;
    if (n == 2) {
        cout << "Yes";
        return;
    }
    vector<int> a(n);
    rep(i, 0, n) {
        cin >> a[i];
    }
    sort(a.begin(), a.end());
    if (a.back() - a.front() > 1) {
        cout << "No";
        return;
    }
    if (a.back() == a.front()) {
        if (a[0] == n - 1 || 2 * a[0] <= n) {
            cout << "Yes";
        } else {
            cout << "No";
        }
        return;
    }
    int c1 = 1;
    for (int i = 1; i < a.size(); i++) {
        if (a[i] == a[0]) {
            c1++;
        }
    }
    if (a[0] == a[1]) {
        if (a[0] >= c1 && 2 * (a[0] - (c1 - 1)) <= n - c1) {
            cout << "Yes";
        } else {
            cout << "No";
        }
        return;
    }
//    if (a[0] == a[1] || (a.back() == n - 1 && n > 3)) {
//        cout << "No";
//        return;
//    }
    if (2 * a.front() + 1 <= n) {
        cout << "Yes";
        return;
    }
    cout << "No";
}

int main() {
#if !defined(JLOCAL) || !STRESS
#ifdef JLOCAL
    freopen("input.txt", "r", stdin);
#endif
    ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
    solve(cin, cout);
#else
    srand(32237357);
    for (int ti = 0; ti < 1000; ti++) {
        stress::gen();
        stress::stupid();
        ifstream in("input.txt");
        ofstream out("output.txt");
        solve(in, out);
        out.flush();
        stress::check();
    }
    cout << "ok" << endl;
#endif
    return 0;
}


Measured memory_bytes: 640
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author
 */

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

class ACirclePond {
 public:
  void solve(std::istream &in, std::ostream &out) {
      int r;
      in >> r;
      out << setprecision(15) << fixed << 2.0 * r * M_PI << '\n';
  }
};

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ACirclePond solver;
    std::istream &in(std::cin);
    std::ostream &out(std::cout);
    solver.solve(in, out);
    return 0;
}

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

int main() {
  vector<int> vec(3);
  cin >> vec[0] >> vec[1] >> vec[2];
  sort(vec.begin(),vec.end());
  if(vec[0]==5 && vec[1]==5 && vec[2]==7)
    cout << "YES" << endl;
  else
    cout << "NO" << endl;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int m = sc.nextInt();
		int[][] s = new int[m][];
		for(int i = 0; i < m; i++){
			int k = sc.nextInt();
			s[i] = new int[k];
			for(int i2 = 0; i2 < k; i2++){
				s[i][i2] = sc.nextInt();
			}
		}
		int[] p = new int[m];
		for(int i = 0; i < m; i++){
			p[i] = sc.nextInt();
		}
		SwPattern.setsNum(n);
		for(int i = 0; i < SwPattern.pNum; i++){
			new SwPattern(i);
		}
		LightBulb.setbNum(m);
		for(int i = 0; i < m; i++){
			new LightBulb(s[i], p[i], i);
		}
		int count = 0;
		for(SwPattern sp : SwPattern.patterns){
			if(sp.checkPattern()){
				count++;
			}
		}
		System.out.println(count);
	}
}
class SwPattern {
	static int sNum;
	static int pNum;
	static SwPattern[] patterns;
	static void setsNum(int n){
		sNum = n;
		pNum = (int) Math.pow(2, sNum);
		patterns = new SwPattern[pNum];
	}
	int[] sPattern;
	SwPattern(int p){
		sPattern = new int[sNum];
		for(int i = 0; i < sNum; i++){
			sPattern[i] = p / (int)Math.pow(2, i) % 2;
		}
		patterns[p] = this;
	}
	boolean checkPattern(LightBulb lb){
		int on = 0;
		for(int i : lb.s){
			on += this.sPattern[i - 1];
		}
		return on % 2 == lb.p;
	}
	boolean checkPattern(){
		for(LightBulb lb : LightBulb.bulbs){
			if(! checkPattern(lb)){
				return false;
			}
		}
		return true;
	}
}
class LightBulb{
	static int bNum;
	static LightBulb[] bulbs;
	static void setbNum(int m){
		bNum = m;
		bulbs = new LightBulb[bNum];
	}
	int[] s;
	int p;
	LightBulb(int[] s, int p, int n){
		this.s = s;
		this.p = p;
		bulbs[n] = this;
	}
	
//	boolean checkLight(SwPattern sp){
//		int on = 0;
//		for(int i : this.s){
//			on += sp.sPattern[i - 1];
//		}
//		return on % 2 == this.p;
//	}
}


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

int f[46]={0};

int fib(int n){
    if(n==0)    f[0] = 1;
    else if(n==1)   f[1] = 1;
    if(f[n]==0)    f[n] = fib(n-1)+fib(n-2);

    return f[n];
}

int main(void){
    int x;
    cin >> x;
    cout << fib(x) << endl;
    return 0;
}



Measured memory_bytes: 3100
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int maxn=1e6+5;

struct node
{
    ll a,b;
}p[maxn];
ll n,m;
ll cmp(node x,node y)
{
    return x.a<y.a;
}
int main()
{
    ll n,m;
    scanf("%lld%lld",&n,&m);
    for(int i=1;i<=n;i++)scanf("%lld%lld",&p[i].a,&p[i].b);
    sort(p+1,p+n+1,cmp);
    ll ans=0;
    for(int i=1;i<=n;i++)
    {
        if(m>=p[i].b){m-=p[i].b;ans+=p[i].b*p[i].a;}
        else {ans+=m*p[i].a;break;}
    }
    printf("%lld\n",ans);
    return 0;
}
/*
int b[maxn];
int a[maxn][maxn];
int main()
{
    int n,m,c;
    scanf("%d%d%d",&n,&m,&c);
    for(int i=1;i<=m;i++)scanf("%d",&b[i]);
    for(int i=1;i<=n;i++)for(int j=1;j<=m;j++)scanf("%d",&a[i][j]);
    int cnt=0;
    for(int i=1;i<=n;i++)
    {
        int ans=0;
        for(int j=1;j<=m;j++)
        {
            ans+=a[i][j]*b[j];
        }
        if(ans+c>0)cnt++;
    }
    printf("%d\n",cnt);
    return 0;
}
/*
int a[maxn];
int main()
{
    int H,W;
    int h,w;
    scanf("%d%d",&H,&W);
    scanf("%d%d",&h,&w);
    int ans=(H-h)*(W-w);
    printf("%d\n",ans);
    return 0;
}
*/


Measured memory_bytes: 1792
#pragma GCC optimize("O3")
#pragma GCC optimize ("unroll-loops")
#pragma GCC target ("avx")
#include <bits/stdc++.h>
constexpr int INF = 2147483647;
constexpr long long int INF_LL = 9223372036854775807;
constexpr int MOD = 1000000007;
constexpr double PI = 3.14159265358979323846;
using namespace std;
typedef long long int ll;
typedef unsigned long long int ull;

//modint
template<typename T> T modinv(T a, T m) {
	T b = m, u = 1, v = 0;
	while (b) {
		T t = a / b;
		a -= t * b; swap(a, b);
		u -= t * v; swap(u, v);
	}
	u %= m;
	if (u < 0) u += m;
	return u;
}
template<typename T> T modpow(T x, int k) {
	if (k == 0)return 1;
	if (k % 2 == 0) return modpow(x * x, k / 2);
	else return x * modpow(x, k - 1);
}

template<int mod> class modint {
public:
	ll val;
	modint(ll a) {
		val = a % mod;
	}
	modint operator+(const modint& r) {
		return modint((this->val + r.val) % mod);
	}
	modint operator-(const modint& r) {
		return modint((this->val - r.val) % mod + ((this->val - r.val) % mod < 0) * mod);
	}
	modint operator*(const modint& r) {
		return modint((((this->val % mod) * (r.val % mod))) % mod);
	}
	modint operator/(const modint& r) {
		return modint(this->val * modinv<ll>(r.val, mod) % mod);
	}
	modint& operator+=(const modint& r) {
		*this = *this + r;
		return *this;
	}
	modint& operator-=(const modint& r) {
		*this = *this - r;
		return *this;
	}
	modint& operator*=(const modint& r) {
		*this = *this * r;
		return *this;
	}
	modint& operator/=(const modint& r) {
		*this = *this / r;
		return *this;
	}

};
modint<MOD> ans = 0;


int main() {
	string L;
	cin >> L;
	
	modint<MOD> mul = 1;
	for (int i = 0; i < L.size(); i++){
		if (i == 0 && L[i] == '1')mul *= 2;
		else if (L[i] == '1') {
			ans += mul * modpow(modint<MOD>(3), L.size() - i - 1);
			mul *= 2;
		}
		if (i == L.size() - 1)ans += mul;
	}
	for (int i = 1; i < L.size(); i++) {
		ans += modint<MOD>(2) * modpow(modint<MOD>(3), i - 1);
	}
	cout << ans.val + 1 << endl;
}

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

int main(){
    vector<int> vec(3);
    for(int i = 0;i < 3;i++)
        cin >> vec.at(i);
    sort(vec.begin(), vec.end());
    int K; cin >> K;

    for(int i = 0;i < K;i++)
        vec.at(2) *= 2;

    cout << vec.at(0) + vec.at(1) + vec.at(2) << endl;

}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> pi;
typedef vector<ll> vi;
typedef vector<pi> vpi;
typedef long double ld;
const int inf = 1e9 + 7;
const int mod = 1e9 + 7;
const int maxn = 1e6 + 3;
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define rep(i, a, b) for(int i = a; i < b; i++)
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(),v.rend()
#define lb lower_bound
#define ub upper_bound
#define fact(n) rep(i, 1, n+1)ft.pb((ft[i-1]*i)%mod);
#define mod_in(a) exp(a, mod-2)
#define ncr(n, r) ((ft[n]*mod_in((ft[r]*ft[(n)-(r)])%mod))%mod)
#define deb(x) cout << #x << " " << x << endl;
#define flash ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); 
#define endl '\n'
ll prime[100000];
ll exp(ll a,ll b);
void sieve(ll n);
ll gcd(ll a ,ll b);
ll countdigit(ll n);
int main()
{

	flash
	char s;
	cin>>s;
	cout<<(char)(s+1);
}
//
//
//
//
//
// IMPORTANT FUNCTIONS
ll exp(ll a, ll b) {
	int res=1;
	while(b) {
		if(b&1)
			res=(res*a)%mod;
		a=(a*a)%mod;
		b>>=1;
	}
	return res;
}
ll gcd(ll a,ll b){
    if(a==0)return b;
    return gcd(b%a,a);
}
void sieve(ll n) {
    for(ll i=0;i<=n;i++) {
        prime[i]=1;
    }
    prime[0]=0;prime[1]=0;
    for(ll i=2;i<=n;i++) {
        if(prime[i]==1) {
            for(ll j=2;i*j<=n;j++) {
                prime[i*j]=0;
            }
        }
    }
}
ll countdigit(ll  n) 
{ 
    return floor(log10(n) + 1); 
}


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

using namespace std;

// 別解（始点を変えて、考える）
int main() {
    int K, N;  // 円周と家の軒数
    cin >> K >> N;

    vector<int> A;  // 家の位置の配列
    for (int i = 0; i < N; i++) {
        int tmp;
        cin >> tmp;
        A.push_back(tmp);
    }

    // 考え方メモ
    // 家と家の間にN個、区間ができる。湖の周り（円周）を回るので、一区間だけ回らない区間ができる。
    // 回らない区間が最長の場合、最短移動距離となる
    // ※この解法なら向きを考える必要はない

    int maxLength = 0;
    for (int i = 0; i < N; i++) {
        if (i + 1 == N) {  // 終点が始点と同じ
            maxLength = max(maxLength, K - A[i] + A[0]);
        } else {  // 通常
            maxLength = max(maxLength, A[i + 1] - A[i]);
        }
    }

    cout << K - maxLength << endl;

    return 0;
}

Measured memory_bytes: 1400
n=int(input())
A=list(map(int,input().split()))
count=[0,0,0,0,0,0,0,0]
change =0
for a in A:
    if a<400:
        count[0] =1
    elif a<800:
        count[1] =1
    elif a<1200:
        count[2] =1
    elif a<1600:
        count[3] =1
    elif a<2000:
        count[4] =1
    elif a<2400:
        count[5] =1
    elif a<2800:
        count[6] =1
    elif a<3200:
        count[7] =1
    else:
        change +=1
Min=max(sum(count),1)
Max=sum(count) + change
print(Min,Max)

Measured memory_bytes: 3064
WV = $<.read.split.map(&:to_i).each_slice(2).to_a
N,W = WV.shift
WV.sort_by! {|w,v| [w,-v]}
I = {}
WV.each.with_index { |(w,*),i| break if w > W; I[w] ||= i}
I[0] = N
K = I.keys
A = Array.new W+1
A[0] = [0,0]
l = [-1]
A.each_with_index {|(c,b),n|
  if (c||0) <= l[0] then next A[n]=l else l=A[n] end
  K.each_cons(2) {|w,x|
    i,j = I[w],I[x]
    break  if W < w+=n
    m = 1 << j
    next  if m <= (b&(m-1))+(1<<i)
	i += 1  while b[i] > 0
    m = (A[w]||l)[0]
    v = WV[i][1] + c
    A[w] = [v,b+(1<<i)]  if m < v
  }
}
p A[W][0]

Measured memory_bytes: 4344
package main

import (
	"bufio"
	"fmt"
	"io"
	"os"
	"strconv"
)

var (
	readString func() string
	stdout     *bufio.Writer
)

func init() {
	readString = newReadString(os.Stdin)
	stdout = bufio.NewWriter(os.Stdout)
}

func newReadString(ior io.Reader) func() string {
	r := bufio.NewScanner(ior)
	r.Buffer(make([]byte, 1024), int(1e+11))
	r.Split(bufio.ScanWords)

	return func() string {
		if !r.Scan() {
			panic("Scan failed")
		}
		return r.Text()
	}
}

func readInt() int {
	return int(readInt64())
}

func readInt64() int64 {
	i, err := strconv.ParseInt(readString(), 0, 64)
	if err != nil {
		panic(err.Error())
	}
	return i
}

func readIntSlice(n int) []int {
	b := make([]int, n)
	for i := 0; i < n; i++ {
		b[i] = readInt()
	}
	return b
}

func readLengthAndSlice() []int {
	n := readInt()
	return readIntSlice(n)
}

func printf(f string, args ...interface{}) (int, error) {
	return fmt.Fprintf(stdout, f, args...)
}

func println(args ...interface{}) (int, error) {
	return fmt.Fprintln(stdout, args...)
}

func minInt(a, b int) int {
	if a < b {
		return a
	}
	return b
}

func minUint(a, b uint) uint {
	if a < b {
		return a
	}
	return b
}

func minInt64(a, b int64) int64 {
	if a < b {
		return a
	}
	return b
}

func minUint64(a, b uint64) uint64 {
	if a < b {
		return a
	}
	return b
}

func maxInt(a, b int) int {
	if a < b {
		return b
	}
	return a
}

func maxUint(a, b uint) uint {
	if a < b {
		return b
	}
	return a
}
func maxInt64(a, b int64) int64 {
	if a < b {
		return b
	}
	return a
}

func maxUint64(a, b uint64) uint64 {
	if a < b {
		return b
	}
	return a
}

func absInt(a int) int {
	if a < 0 {
		return -a
	}
	return a
}

func absInt64(a int64) int64 {
	if a < 0 {
		return -a
	}
	return a
}

// readString() string
// readInt() int
// readIntSlice(n int) []int
// readLengthAndSlice() []int
func main() {
	defer stdout.Flush()

	x := readInt()
	a := readInt()
	b := readInt()

	if absInt(a-x) > absInt(b-x) {
		println("B")
	} else {
		println("A")
	}
}


Measured memory_bytes: 640
[h,w]=[int(i) for i in input().split()]
s=[]
a=-1
al="ABCDEFGHIJKLMNOPQRSTUVWXYZ"
for j in range(h):
    #s[0]には1行目のリスト,...
    s.append([k for k in input().split()])
    if s[j].count("snuke")==1:
        for l in s[j]:
            a=a+1
            if l=="snuke":
                break

        print(al[a]+str(j+1))
        break


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

int lcs(string a,string b){
    if(a.size()==0 || b.size()==0) return 0;
    int alen = a.size();
    int blen = b.size();
    vector<vector<int>> dp(alen,vector<int>(blen,0));
    dp[0][0] = a[0] == b[0]? 1:0;
    for(int j = 1; j<blen;j++) dp[0][j] = a[0]==b[j]? 1:dp[0][j-1];
    for(int i = 1; i<alen;i++) dp[i][0] = a[i]==b[0]? 1:dp[i-1][0];
    for(int i = 1;i<alen;i++){
        for(int j=1;j<blen;j++){
            dp[i][j] = dp[i-1][j-1];
            if(a[i]==b[j]) dp[i][j]++;
            dp[i][j] = max(dp[i][j],max(dp[i-1][j],dp[i][j-1]));
        }
    }
    return dp[alen-1][blen-1];
}

int main(){
    //string a = "a";
    //string b = "c";
    int p;
    cin >> p;
    for(int i = 0;i<p;i++){
        string a,b;
        cin >> a >> b;
        cout << lcs(a,b) << endl;
    }
    return 0;
}




Measured memory_bytes: 6816
#include <bits/stdc++.h>
          
#define pb push_back
#define ll long long
#define F first
#define S second
#define ld long double
#define fa fflush(stdout); 
#define mp make_pair
using namespace std;
void data() {
    #ifdef NURS
        freopen("main.in", "r", stdin);
        freopen("main.out", "w", stdout);
    #endif
    ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0);;                                                      
} 
int dx[5] = {-1, 0, 0, 1};
int dy[5] = {0, -1, 1, 0};
  
const int N = 1e6 + 100;
const ll mod = 1e6 + 3;
const ll big = 1e9;
const ll p = 27;
 
int was[N];
void sieve()
{
	for (int i = 2; i <= 1e6; i++)
	{
		for (int j = i; j <= 1e6; j += i)
		{
			was[j]++;		
		}
	}
}
int main() 
{
	data();
   	// freopen("substr3.in","r",stdin);
   	// freopen("substr3.out","w",stdout);
	sieve();
	int n;
	cin >> n;   
	ll ans = 0;
	for (int i = 1; i <= n - 1; i++)
	{
		if (n - i == 1)
		{
			ans += 1;
			continue;
		}
		ans += was[n - i] + 1;
	}
	cout << ans;
}   	                                   



Measured memory_bytes: 7552
#include <string.h>
#include <iostream>
using namespace std;
int main() {
	int N, T[100], M, P[100], X[100];
	int Answer;
	cin >> N;
	for (int i = 0; i < N; i++) {
		cin >> T[i];
	}
	cin >> M;
	for (int i = 0; i < M; i++) {
		cin >> P[i] >> X[i];
	}


	for (int i = 0; i < M; i++) {
		Answer = 0;
		for (int j = 0; j < N; j++) {
			if (P[i] - 1 == j) {
				Answer += X[i];
			}
			else {
				Answer += T[j];
			}
		}
		cout << Answer << endl;
	}
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cmath>
#include <unordered_map>

using namespace std;

int main() {
    int n;
    cin >> n;
    unordered_map<int, int> as;
    for(int i = 0; i < n; i++) {
        int a;
        cin >> a;
        auto res = as.find(a);
        if (res != as.end()) {
            int current_var = res->second;
            as[a] = current_var + 1;
        } else {
            as[a] = 1;
        }
    }
    int pattern = 1;
    for(int i = 1; i <= n; i++) {
        int y = abs((i - 1) - (n - i));
        auto res = as.find(y);
        if (res != as.end()) {
            pattern = (pattern * res->second) % 1000000007;
            as[y] -= 1;
        } else {
            cout << 0 << endl;
            return 0;
        }
    }
    cout << pattern << endl;
    return 0;
}

Measured memory_bytes: 3104
n = int(input())
A= list(map(int, input().split()))

mod = int(1e9+7)
def powermod(a, n, mod):
    r = 1
    while n>=1:
        if n%2:
            r = (r*a)%mod
        a = (a*a)%mod
        n = n//2
    return r
  
memo={}
for i, a in enumerate(A):
  if a in memo:
    L = memo[a]
    C = i - memo[a] -1
    R = len(A) - i-1
    break
  else:
    memo[a] = i
    
#print(L,C,R)
_LR = [0]*(n+3)
_LCR = [0] * (n+3) # _LCR[k] = (L+C+R)C(k)
_k = [0] * (n+3)
_LR[0] = _LCR[0] = _k[0] = 1

LR = [0]*(n+2) #LR[k] = (L+R)C(k)
LR[0] = 1
#LDR = [0]*(n+2)
#LDDR = [0]*(n+2)

LCR = [0] * (n+2) # LCR[k] = _LCR[k] - LR[k]
#LDCR = [0] * (n+2) #最後に*2を忘れないこと
#LDCDR = [0] * (n+2)

for k in range(1,n+2):
  _LR[k] = (_LR[k-1] * (L+R+1-k)) %mod
  _LCR[k] = (_LCR[k-1] * (L+C+R+1-k))% mod
  _k[k] = (_k[k-1] * powermod(k, mod-2, mod)) %mod
  
  LR[k] = (_LR[k] * _k[k])%mod
#  LDR[k] = LR[k-1]
#  LDDR[k] = LDR[k-1]
  
  LCR[k] = (_LCR[k] * _k[k])%mod - LR[k]
#  LDCR[k] = LCR[k-1]
#  LDCDR[k] = LDCR[k-1]
  #print(LR, LCR)
  print((LR[k] + LR[k-1] + LR[k-2] + LCR[k] + 2*LCR[k-1] + LCR[k-2])%mod)
  
#print(LR)
#print(LDR)
#print(LDDR)
#print(_LCR)
#print(LCR)
#print(LDCR)
#print(LDCDR)


Measured memory_bytes: 31316
import java.util.Scanner;
public class Main {

    public static void main(String[] args) {
        Scanner s =new Scanner(System.in);
        int k = s.nextInt();
        int a = s.nextInt();
        int b = s.nextInt();
        boolean v =true;
        for(int i=a;i<=b;i++){
            if(i%k==0){
                System.out.println("OK");
                v = false;
                break;
            }

        }
        if(v==true){
            System.out.println("NG");
        }
    }
}


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

 using namespace std;
 int main() {
   string S;
   int i;
   cin >> S;
   i = 0;
   if (S.at(0) == 'o') i += 100;
   if (S.at(1) == 'o') i += 100;
   if (S.at(2) == 'o') i += 100;
   cout << 700 + i << endl;
 }


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


 int main (){
     int a,b,c,d,e,k;
     cin >> a >> b >> c >> d >> e >> k;
     bool t=false;
     if(b-a>k){t=true;}
     if(c-b>k){t=true;}
     if(d-c>k){t=true;}
     if(e-d>k){t=true;}
     if(c-a>k){t=true;}
     if(d-b>k){t=true;}
     if(e-c>k){t=true;}
     if(d-a>k){t=true;}
     if(e-b>k){t=true;}
     if(e-a>k){t=true;}
     if(t==true){cout << ":("<<endl;}
     else {cout << "Yay!"<<endl;}
 }

Measured memory_bytes: 3560
//circle in the rectangle

#include <stdio.h>

int main(void)
{
    int W, H, x, y, r, a, b, c;

    scanf("%d%d%d%d%d", &W, &H, &x, &y, &r);

    if (x <= 0 || y <= 0)
        printf("No\n");
    else
    {
        a = (W / 2 >= x) ? x : W - x;
        b = (H / 2 >= y) ? y : H - y;
        c = (a >= b) ? b : a;

        if(r<=c) printf("Yes\n");
        else printf("No\n");
    }

    return 0;
}


Measured memory_bytes: 2044
n,m,k=map(int,input().split())
 
def find(x):
    if par[x] < 0:
        return x
    else:
        par[x] = find(par[x])
        return par[x]
 
def unite(x,y):
    x = find(x)
    y = find(y)
    
    if x == y:
        return False
    else:
        if par[x] > par[y]:
            x,y = y,x
        par[x] += par[y]
        par[y] = x
        return True
 
def same(x,y):
    return find(x) == find(y)
 
def size(x):
    return -par[find(x)]
 
par = [-1]*n
 
ans=[0]*n
nxt=[0]*n
block=[[] for _ in range(n)]
 
for _ in range(m):
    a,b=map(int,input().split())
    unite(a-1,b-1)
    nxt[a-1]+=1
    nxt[b-1]+=1
 
for _ in range(k):
    c,d=map(int,input().split())
    block[c-1].append(d-1)
    block[d-1].append(c-1)
 
for i in range(n):
    ans[i]=size(i)-nxt[i]-1
    for j in block[i]:
        if same(j,i):
            ans[i]-=1
print(*ans)

Measured memory_bytes: 31876
// clang-format off
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i,n) for(ll i=0, i##_len=(n); i<i##_len; ++i)
#define rep1(i,n) for(ll i=1, i##_len=(n); i<=i##_len; ++i)
#define rrep(i,n) for(ll i=n-1; i>=0; --i)
#define rrep1(i,n) for(ll i=n; i>0; --i)
#define all(x) (x).begin(),(x).end()
#define SORT(x) sort(all(x))
#define SORT_DESC(x) sort(all(x), greater<>())
#define pb push_back
#define mp make_pair
#define coutl cout<<fixed<<setprecision(10)
#define ANS(ans) cout<<ans<<endl;
const ll LINF = (1LL << 62) - 1;
const int INF = (1 << 30) - 1;
template<class T>bool chmax(T &a, const T &b){if (a<b){a=b;return 1;}return 0;}
template<class T>bool chmin(T &a, const T &b){if (b<a){a=b;return 1;}return 0;}
// clang-format on

int main() {
  ll N;
  cin >> N;
  vector<ll> A(N);
  rep(i, N) cin >> A[i];
  rep(i, N) {
    if (A[i] % 2 != 0)
      continue;
    if (A[i] % 3 != 0 && A[i] % 5 != 0) {
      ANS("DENIED");
      return 0;
    }
  }
  ANS("APPROVED");
  return 0;
}


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

namespace abc142_c
{
    class Program
    {
        static void Main(string[] args)
        {
            var N = int.Parse(Console.ReadLine());
            var AL = Console.ReadLine().Split(' ').Select(x => int.Parse(x)).ToList();
            var AD = new Dictionary<int, int>();

            for (int i = 0; i < N; i++)
                AD.Add(AL[i], i + 1);

            var r = new List<int>();
            for (int i = 0; i < N; i++)
                r.Add(AD[i + 1]);

            Console.WriteLine(string.Join(" ", r));
        }
    }
}


Measured memory_bytes: 32732
#include <iostream>
#include <cstdlib>
#include <fstream>
#include <set>
#include <vector>
#include <algorithm>
#include <cmath>
#include <cstring>
#include <map>
#include <iomanip>
#include <numeric>

using namespace std;

typedef long long ll;

#define forn(i, n) for(int i = 0; i < int(n);++i)
#define pb push_back
#define vi vector<int>
#define vb vector<bool>
#define vll vector<ll>
#define sz(x) (int)x.size()

void solve() {

}

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll n;
    cin >> n;
    bool d = false;
    ll ans = ll(1e12) + 1;
    for (ll i = 2; i <= ll(sqrt(n)) + 1; i++) {
        if (n % i == 0) {
            d = true;
            ans = min(ans, (i - 1) + (n / i - 1));
        }
    }
    if (d) {
        cout << ans;
    } else {

        cout << n - 1;
    }
    return 0;
}

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

int main(int argc, char *argv[]){
	char *p,eng[1002];
	int n;
	scanf("%d ",&n);
	while(n--){
	      	fgets(eng,1002,stdin);
		while(1){
			p=strstr(eng,"Hoshino");
			if(p != NULL) *(p+6)='a';
			else break;
		}
		printf("%s",eng);
	}
	return 0;
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
#define ll long long
#define uint unsigned long long
#define db double
#define ls x << 1
#define rs x << 1 | 1
#define pb push_back
#define mp make_pair
#define pii pair<int, int>
#define X first
#define Y second
#define pcc pair<char, char>
#define vi vector<int>
#define vl vector<ll>
#define rep(i, x, y) for(int i = x; i <= y; i ++)
#define rrep(i, x, y) for(int i = x; i >= y; i --)
#define eps 1e-9
using namespace std;
inline int read()
{
	int x = 0, f = 1; char ch = getchar();
	while (ch < '0' || ch > '9') { if (ch == '-') f = -1; ch = getchar(); }
	while (ch >= '0' && ch <= '9') { x = x * 10 + ch - '0'; ch = getchar(); }
	return x * f;
}
ll n, s;
ll f(ll b, ll n)
{
    if(n < b) return n;
    else return f(b, n / b) + n % b;
}

int main()
{
    scanf("%lld%lld", &n, &s);
    ll gh = sqrt(1.0 * n) + 1;
    rep(i, 2, gh)
        if(f(i, n) == s)
        {
            printf("%d", i);
            return 0;
        }

    ll t = n - s;
    if(t < 0)
    {
        puts("-1");
        return 0;
    }
    if(t == 0)
    {
        printf("%lld", n + 1);
        return 0;
    }
    ll b = -1;
    rep(i, 1, gh)
        if(t % i == 0)
        {
            ll x = t / i + 1;
            ll p = i;
            ll q = s - p;
            if(q >= x)continue;
            if(p >= x)continue;
            if(q < 0)continue;
            if(p * x + q == n) b = x;
        }
    printf("%lld",b);
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <stdio.h>
#include <string>
#include <cstdlib>
#include <cmath>
#include <math.h>
#include <vector>
#include <algorithm>
using namespace std;

int main(){
	int n;
	cin >> n;
	int ans = 0;
	for(int i=0; i<n; i++){
		int l, r;
		cin >> l >> r;
		ans += r-l+1;
	}

	cout << ans << endl;

	return 0;
}

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

namespace Competitive
{
    internal class Solution
    {
        public int N;
        public List<int> direct;

        public void Run()
        {
            N = Input.ReadInt();

            direct = new List<int>();

            // 最後はN=1かN=2とする
            while (N >= 3)
            {
                int m = N % 3;
                direct.Add(m);
                N /= 3;
            }

            direct.Reverse();

            // 作成
            var ret = new List<Tuple<int, int, int>>(); // from, to, len
            int mul = 1;
            int to = 2;

            // 最初の辺
            for (int j = 0; j < N; j++)
            {
                ret.Add(Tuple.Create(to-1, to, j));
            }
            mul *= N;

            // ２個目以降
            for (int i = 0; i < direct.Count; i++)
            {
                int dir = direct[i];
                for (int j = 0; j < 3; j++)
                {
                    ret.Add(Tuple.Create(i + 2, i + 3, mul * j));
                }
                mul *= 3;

                for (int j = 0; j < dir; j++)
                {
                    ret.Add(Tuple.Create(1, i + 3, mul));
                    mul++;
                }
            }

            // Console.Error.WriteLine("-------------" + string.Join(", ", direct) + "-" + N);
            Console.WriteLine("{0} {1}", direct.Count + 2, ret.Count);
            for (int n = 0; n < ret.Count; n++)
            {
                Console.WriteLine("{0} {1} {2}", ret[n].Item1, ret[n].Item2, ret[n].Item3);
            }
        }
    }

    // libs ----------
    

    // common ----------

    internal static class Input
    {
        public static string ReadString()
        {
            string line = Console.ReadLine();
            return line;
        }

        public static int ReadInt()
        {
            string line = Console.ReadLine();
            return int.Parse(line);
        }

        public static int[] ReadIntArray()
        {
            string line = Console.ReadLine();
            return line.Split(' ').Select(int.Parse).ToArray();            
        }

        public static long ReadLong()
        {
            string line = Console.ReadLine();
            return long.Parse(line);
        }

        public static long[] ReadLongArray()
        {
            string line = Console.ReadLine();
            return line.Split(' ').Select(long.Parse).ToArray();
        }

        public static double[] ReadDoubleArray()
        {
            string line = Console.ReadLine();
            return line.Split(' ').Select(double.Parse).ToArray();
        }
    }
    
    internal class Program
    {
        public static void Main(string[] args)
        {
            var s = new Solution();
            s.Run();
        }
    }
}

Measured memory_bytes: 13268
#include<bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i) 
#define PI acos(-1)

using namespace std;
using ll = long long;
using P = pair<int, int>;

vector<P> direc = {P(-1, -1), P(-1, 0), P(-1, 1), P(0, -1), P(0, 1), P(1, -1), P(1, 0), P(1, 1)};

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

    int i, j, H, W;
    cin>>H>>W;
    vector<string> grid(H);
    rep(i, H) cin>>grid[i];
    rep(i, H) {
        rep(j, W) {
            char cur = grid[i][j];
            if (cur == '#') {
                cout<<'#';
                continue;
            }
            int cnt = 0;
            for (auto d: direc) {
                if (i + d.first >= 0 && i + d.first < H && j + d.second >= 0 && j + d.second < W) {
                    if (grid[i + d.first][j + d.second] == '#') cnt++;
                }
            }
            cout<<cnt;
        }
        cout<<endl;
    }
}

Measured memory_bytes: 256
import java.io.IOException;
import java.io.InputStream;
import java.util.NoSuchElementException;

public class Main {

	public static void main(String[] args) {

		FastScanner sc = new FastScanner();
		double a = sc.nextDouble();
		double b = sc.nextDouble();
System.out.println((int)Math.ceil((a+b)/2.0));
	}
	//以下、自作ライブラリ

	//最大公約数
	public static long gcd(long a, long b) {
		if (a < b)
			return gcd(b, a);
		long c = 0;
		c = a % b;
		if (c == 0)
			return b;
		return gcd(b, c);
	}

	//最小公倍数
	public static long lcm(long m, long n) {
		return m * n / gcd(m, n);
	}

	//素数判定
	public static boolean isPrime(int n) {
		if (n < 2)
			return false;
		if (n == 2)
			return true;
		if (n % 2 == 0)
			return false;

		for (int i = 3; i * i <= n; i += 2) {
			if (n % i == 0)
				return false;
		}
		return true;
	}
}

//以下、高速スキャナークラス
class FastScanner {
	private final InputStream in = System.in;
	private final byte[] buffer = new byte[1024];
	private int ptr = 0;
	private int buflen = 0;

	private boolean hasNextByte() {
		if (ptr < buflen) {
			return true;
		} else {
			ptr = 0;
			try {
				buflen = in.read(buffer);
			} catch (IOException e) {
				e.printStackTrace();
			}
			if (buflen <= 0) {
				return false;
			}
		}
		return true;
	}

	private int readByte() {
		if (hasNextByte())
			return buffer[ptr++];
		else
			return -1;
	}

	private static boolean isPrintableChar(int c) {
		return 33 <= c && c <= 126;
	}

	public boolean hasNext() {
		while (hasNextByte() && !isPrintableChar(buffer[ptr]))
			ptr++;
		return hasNextByte();
	}

	public String next() {
		if (!hasNext())
			throw new NoSuchElementException();
		StringBuilder sb = new StringBuilder();
		int b = readByte();
		while (isPrintableChar(b)) {
			sb.appendCodePoint(b);
			b = readByte();
		}
		return sb.toString();
	}

	public long nextLong() {
		if (!hasNext())
			throw new NoSuchElementException();
		long n = 0;
		boolean minus = false;
		int b = readByte();
		if (b == '-') {
			minus = true;
			b = readByte();
		}
		if (b < '0' || '9' < b) {
			throw new NumberFormatException();
		}
		while (true) {
			if ('0' <= b && b <= '9') {
				n *= 10;
				n += b - '0';
			} else if (b == -1 || !isPrintableChar(b)) {
				return minus ? -n : n;
			} else {
				throw new NumberFormatException();
			}
			b = readByte();
		}
	}

	public int nextInt() {
		long nl = nextLong();
		if (nl < Integer.MIN_VALUE || nl > Integer.MAX_VALUE)
			throw new NumberFormatException();
		return (int) nl;
	}

	public double nextDouble() {
		return Double.parseDouble(next());
	}
}


Measured memory_bytes: 20692
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef long double ld;
typedef map <ll,ll> mm;
typedef vector <ll> mv;
typedef pair <ll,ll> mp;
typedef set <ll> ms;
typedef queue <ll> mq;
typedef deque <ll> mdq;
typedef stack <ll> mst;
typedef priority_queue <ll> mpq;
typedef priority_queue <ll, vector<ll>, greater<ll> > mmh;
typedef complex<double> cd; 
#define fastio ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define flush cout.flush();
#define all(v) v.begin(),v.end()
#define pb(v) push_back(v)
#define cn continue
#define forl(i,n) for(ll i=0;i<n;i++)
#define forlr(i,n) for(ll i=n-1;i>=0;i--)
#define rev(s) reverse(s.begin(),s.end())
void swap(ll &a,ll &b)
{
	ll tmp=a;
	a=b;
	b=tmp;
}
ll atoistring(string s)
{
	stringstream lol(s);
	ll x;
	lol>>x;
	return x;
}
void pv(mv v)
{
	forl(i,v.size())
	{
		cout<<v[i]<<" ";
	}
	cout<<"\n";
}
void pa(ll *v,ll size)
{
	forl(i,size)
	{
		cout<<v[i]<<" ";
	}
	cout<<"\n";
}
// ll nck(ll N,ll K,ll mod)
// {
// 	if(N<K)
// 	{
// 		return 0;
// 	}
// 	return (((facs[N]*facsinv[N-K])%mod)*facsinv[K])%mod;
// }
ll power(ll x,ll y,ll p)
{
	ll res=1;
	x=x%p;
	while(y>0)
	{
		if(y&1)
		{
			res=(res*x)%p;
		}
		y=y>>1;
		x=(x*x)%p;
	}
	return res;
}
void checkmod(ll &x,ll mod)
{
	if(x>=mod)
	{
		x%=mod;
	}
}
ll sumofgp(ll a,ll n,ll m)
{
	// n = number of terms - 1
	if(n<0)
	{
		return 0;
	}
	if(n==0)
	{
		return 1;
	}
	if(n==1)
	{
		return (1+a)%m;
	}
	ll ans;
	if(n%2)
	{
        ans=(1+a)*sumofgp((a*a)%m,(n-1)/2,m);
	}
    else
    {
        ans=1+((a*(1+a))%m)*sumofgp((a*a)%m,n/2-1,m);
    }
    return ans%m;
}
// void checktime()
// {
// 	struct timespec ts;
// 	printf("Running Program\n");
// 	clock_gettime(CLOCK_MONOTONIC_RAW,&ts);
// 	long double st=ts.tv_nsec/(1e9)+ts.tv_sec;
// 	// Call Funcn Here
// 	clock_gettime(CLOCK_MONOTONIC_RAW,&ts);
// 	long double en=ts.tv_nsec/(1e9)+ts.tv_sec;
// 	printf("Program ended\nTime = %Lf\n",en-st);
// }
int main(void)
{
	fastio
	ll h;
	cin>>h;
	ll ans = 0, l = 1;
	while(h>=1)
	{
		ans += l;
		l*=2;
		h/=2;
	}
	cout<<ans<<"\n";
	return 0;
}

Measured memory_bytes: 256
import sys, math
input = sys.stdin.readline
rs = lambda: input().strip()
ri = lambda: int(input())
rl = lambda: list(map(int, input().split()))
mod = 10**9 + 7

T = rs()

A = list(T)
l = len(A)

for i, c in enumerate(A):
	if c == '?':
		A[i] = 'D'
print(''.join(A))


Measured memory_bytes: 73836
#include <bits/stdc++.h>
using namespace std;
using vi = vector<int>;
using vb = vector<bool>;
using vl = vector<long>;
using vs = vector<string>;
using vvi = vector<vector<int>>;
using vvb = vector<vector<bool>>;
using vvc = vector<vector<char>>;
using pii = pair<int, int>;
using pll = pair<long, long>;
#define fix20 cout << fixed << setprecision(20);
#define rep(i,n) for(int i=0; i<(int)(n);i++)
#define rrep(i,n) for(int i=(n)-1;i>=0;i--)
#define MOD 1000000007
#define all(vec) vec.begin(), vec.end()

vector<vector<pii>> Graph(3000);
vector<long> dist(3000,-1e17);
set<int> st;



int main(){
    int n,m,p;
    cin >> n >> m >> p;
    rep(i,m){
        int a,b,c;
        cin >> a >> b >> c;
        a--;b--;c-=p;
        Graph.at(a).push_back(pii(b,c));
    }
    dist.at(0) = 0;
    rep(i,n){
        rep(v,n){
            if(dist.at(v) == -1e17) continue;
            for(pii nP : Graph.at(v)){
                int nv = nP.first;
                long cost = nP.second;
                if(dist.at(nv) < dist.at(v) + cost){
                    dist.at(nv) = dist.at(v) + cost;
                    if(i == n-1){
                        st.insert(v);
                        //cout << -1 << endl;
                        //return 0;
                    }
                }
            }
        }
    }
    rep(i,n){
    rep(v,n){
        for(pii nP : Graph.at(v)){
            if(st.count(v)) st.insert(nP.first);
        }
    }
    }
    if(st.count(n-1)) cout << -1 << endl;
    else cout << max(dist.at(n-1),long(0)) << endl;
}

Measured memory_bytes: 640
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower

using namespace std;

#define rep(i, a, b) for (int i = a; i < b; i++)
#define all(A) A.begin(), A.end()
typedef long long ll;
const ll mod = 1e9 + 7;
const ll inf = 1e18;

int main() {
    ll N, M, L;
    cin >> N >> M >> L;

    ll ad[N][N];
    rep(i, 0, N) rep(j, 0, N) ad[i][j] = inf;

    rep(i, 0, M) {
        ll A, B, C;
        cin >> A >> B >> C;
        A -= 1;
        B -= 1;
        ad[A][B] = C;
        ad[B][A] = C;
    }

    rep(k, 0, N) {
        rep(i, 0, N) {
            rep(j, 0, N) {
                if (i == j) {
                    ad[i][j] = inf;
                }
                if (ad[i][k] + ad[k][j] < ad[i][j]) {
                    ad[i][j] = ad[i][k] + ad[k][j];
                }
            }
        }
    }

    rep(i, 0, N) {
        rep(j, 0, N) {
            if (ad[i][j] <= L) {
                ad[i][j] = 1ll;
            }
            else {
                ad[i][j] = inf;
            }
        }
    }

    rep(k, 0, N) {
        rep(i, 0, N) {
            rep(j, 0, N) {
                if (i == j) {
                    ad[i][j] = inf;
                }
                if (ad[i][k] + ad[k][j] < ad[i][j]) {
                    ad[i][j] = ad[i][k] + ad[k][j];
                }
            }
        }
    }
    
    ll Q;
    cin >> Q;
    rep(i, 0, Q) {
        ll s, t;
        cin >> s >> t;
        s -= 1;
        t -= 1;
        int ans;
        if (ad[s][t] == inf) {
            ans = -1;
        }
        else {
            ans = ad[s][t] - 1;
        }
        cout << ans << endl;
    }
}

Measured memory_bytes: 1280
#include<bits/stdc++.h>
using namespace std;
int main(){
  int s;
  int N;cin>>N;
  vector<int> p(N);
  s=0;
  for(int i=0;i<N;++i){
    cin>>p[i];
  }
  for(int i=0;i<N;++i){
    if(p[i]!=i+1){
      ++s;
    }
  }
  if(s<=2){
    cout<<"YES";
  }
  else{
    cout<<"NO";
  }
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define _GLIBCXX_DEBUG
#define rep(i, n) for(int i = 0; i < (n); ++i)
using namespace std;
typedef long long ll;
template<class T> istream& operator >> (istream& s, vector<T>& v)
{ for (T& x: v) { s >> x; } return s;}
void yes(){ cout << "Yes" << endl; }
void no(){ cout << "No" << endl; }
int SIZE(string s){ return (int)s.size(); }

int main(){
    cout << setprecision(16);
    int h,w; cin >> h >> w;
    int n; cin >> n;
    vector<int> a(n);
    rep(i,n) cin >> a[i];
    vector<vector<int>> ans(h,vector<int>(w));
    int x = 0;
    rep(i,h){
        if(i % 2 == 0) rep(j,w){
            if(a[x] == 0) x++;
            ans[i][j] = x+1;
            a[x]--;
        } else {
            for(int j = w-1; j >= 0; j--){
                if(a[x] == 0) x++;
                ans[i][j] = x+1;
                a[x]--;
            }
        }
    }
    rep(i,h){
        rep(j,w) cout << ans[i][j] << " ";
        cout << endl;
    }
    return 0;
}


Measured memory_bytes: 384
n,T=map(int,input().split())
arr=[]
for i in range(n):
	c,t=map(int,input().split())
	arr.append((c,t))
arr.sort()
flag=0
minval=10**19
for i in range(n):
	if(arr[i][1]<=T):
		minval=min(minval,arr[i][0])
if(minval==10**19):
	print('TLE')
else:
	print(minval)

Measured memory_bytes: 3064