akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
#define ALL(c) begin(c), end(c)
using namespace std;
using ll = long long;
using ld = long double;

const int N = 1e6+6;


int main(){
	//freopen("input.txt","r",stdin); //freopen("output.txt","w",stdout);
	ios::sync_with_stdio(0);cin.tie(0);//cout.precision(12);cout<<fixed;
	
	int H,W;
	
	cin>>H>>W;
	
	set<pair<int,int>> q;
	set<pair<int,int>> qi;
	
	for(int i=1;i<=W;++i){
		q.insert({i,0});
		qi.insert({0,i});
	}
	
	auto add = [&](int l, int r){
		for(;;){
			auto it = q.lower_bound({l,-1});
			if(it==end(q) || it->first > r) break;
			
			auto [i,f] = *it;
			++it;
			int j = it==end(q) ? W : it->first - 1;
			
			q.erase({i,f});
			qi.erase({f,i});
			
			if(j>r){
				int ff = r+1-i + f;
				q.insert({r+1,ff});
				qi.insert({ff,r+1});
				break;
			}
		}
	};
	
	
	int all = 0;
	for(int k=1;k<=H;++k){
		int l,r;
		cin>>l>>r;
		
		add(l,r);
		++all;
		
		int res = -1;
		if(!empty(q)){
			res = begin(qi)->first + all;
		}
		
		cout<<res<<'\n';
	}
	
	
	return 0;
}


Measured memory_bytes: 22332
#include <iostream>
#include <vector>
#include <utility>
#include <algorithm>
#include <tuple>
using namespace std;

int main()
{
	int M, T, P, R, m, t, p, j;
	while (cin >> M >> T >> P >> R, M || T || P || R) {
		vector< vector< pair<int, int> > > data(T + 1, vector< pair<int, int> >(P + 1, pair<int, int>(0,0)));
		vector< tuple<int, int, int> > score(T + 1);
		for (int i = 0; i < R; i++) {
			cin >> m >> t >> p >> j;
			if (j == 0) {
				data[t][p].first = m + data[t][p].second * 20;
				get<0>(score[t])--;
			}
			else {
				data[t][p].second++;
			}
		}
		for (int i = 1; i <= T; i++) {
			int sco = 0,pena = 0;
			for (int j = 0; j <= P; j++) {
				if (data[i][j].first) {
					sco--;
					pena += data[i][j].first;
				}
			}
			score[i] = tuple<int, int, int>(get<0>(score[i]),pena,-i);
		}
		sort(score.begin() + 1, score.end());
		tuple<int, int, int> temp = score[1];
		cout << -get<2>(score[1]);
		for (int i = 2; i <= T; i++) {
			if (get<0>(temp) == get<0>(score[i]) && get<1>(temp) == get<1>(score[i])) {
				cout << "=";
			}
			else {
				cout << ",";
			}
			cout << -get<2>(score[i]);
			temp = score[i];
		}
		cout << endl;
	}
	return 0;
}

Measured memory_bytes: 3120
#include <bits/stdc++.h>
#include<algorithm>
#define int long long
using namespace std;
typedef pair<int,int> P;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define INF 1000000000000

template<int MOD> struct Fp {
    long long val;
    constexpr Fp(long long v = 0) noexcept : val(v % MOD) {
        if (val < 0) val += MOD;
    }
    constexpr int getmod() { return MOD; }
    constexpr Fp operator - () const noexcept {
        return val ? MOD - val : 0;
    }
    constexpr Fp operator + (const Fp& r) const noexcept { return Fp(*this) += r; }
    constexpr Fp operator - (const Fp& r) const noexcept { return Fp(*this) -= r; }
    constexpr Fp operator * (const Fp& r) const noexcept { return Fp(*this) *= r; }
    constexpr Fp operator / (const Fp& r) const noexcept { return Fp(*this) /= r; }
    constexpr Fp& operator += (const Fp& r) noexcept {
        val += r.val;
        if (val >= MOD) val -= MOD;
        return *this;
    }
    constexpr Fp& operator -= (const Fp& r) noexcept {
        val -= r.val;
        if (val < 0) val += MOD;
        return *this;
    }
    constexpr Fp& operator *= (const Fp& r) noexcept {
        val = val * r.val % MOD;
        return *this;
    }
    constexpr Fp& operator /= (const Fp& r) noexcept {
        long long a = r.val, b = MOD, u = 1, v = 0;
        while (b) {
            long long t = a / b;
            a -= t * b; swap(a, b);
            u -= t * v; swap(u, v);
        }
        val = val * u % MOD;
        if (val < 0) val += MOD;
        return *this;
    }
    constexpr bool operator == (const Fp& r) const noexcept {
        return this->val == r.val;
    }
    constexpr bool operator != (const Fp& r) const noexcept {
        return this->val != r.val;
    }
    friend constexpr ostream& operator << (ostream &os, const Fp<MOD>& x) noexcept {
        return os << x.val;
    }
    friend constexpr Fp<MOD> modpow(const Fp<MOD> &a, long long n) noexcept {
        if (n == 0) return 1;
        auto t = modpow(a, n / 2);
        t = t * t;
        if (n & 1) t = t * a;
        return t;
    }
};


const int MOD = 1000000007;
using mint = Fp<MOD>;


int modpow(int a,int x){
  if(a<0)a+=MOD;
  int ans=1;
  while(x>0){
    if(x&1) ans=ans*a%MOD;
      a=a*a%MOD;
      x>>=1;
  }
  return ans;
}
int gyaku(int n){
    return modpow(n,MOD-2);
}

////////////////////////////////////////////////////////////////////////
signed main() {
  int n,k;
  cin>>n>>k;
  vector<int>a(n);
  rep(i,n)cin>>a[i];
  sort(a.begin(),a.end());
  //combmaekeisan
  vector<int>kai(100002);
  kai[0]=1;
  rep(i,100001){
    kai[i+1]=(i+1)*kai[i]%MOD;
  }
  //suuretunowa
  vector<mint>s(n-k+2);
  for(int i=k;i<=n;i++){
    s[i+1-k]=(s[i-k]+((mint)kai[i-2]*(mint)gyaku(kai[k-2]))*(mint)gyaku(kai[i-k]));
  }
  mint ans=0;
  //tasu
  for(int i=n-1;i>=k-1;i--){
    ans=ans+s[i-k+2]*(mint)a[i];
  }
  //hiku
  for(int i=0;i<=n-k;i++){
    ans=ans-s[n-k-i+1]*(mint)a[i];
  }

  cout<<ans<<endl;
}


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

#define fi first
#define se second
#define repl(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define rep(i,n) repl(i,0,n)
#define each(itr,v) for(auto itr:v)
#define pb(s) push_back(s)
#define mp(a,b) make_pair(a,b)
#define all(x) (x).begin(),(x).end()
#define dbg(x) cout<<#x"="<<x<<endl
#define maxch(x,y) x=max(x,y)
#define minch(x,y) x=min(x,y)
#define uni(x) x.erase(unique(all(x)),x.end())
#define exist(x,y) (find(all(x),y)!=x.end())
#define bcnt(x) bitset<32>(x).count()

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> P;
typedef pair<P, int> PPI;
typedef pair<ll, ll> PL;
typedef pair<P, ll> PPL;

#define INF INT_MAX/3

#define MAX_N 1000

#define mod 1000000007

int n;
ll a[111111];
ll fac[111111];

ll dfs(int s,int rem){
	int l=s;
	while(l<n&&2*(l-rem)+1<=a[l])l++; // [s,l]=removable
	//dbg(l);
	if(l==n)return fac[n-rem]%mod;
	else return (l+1-rem)*(dfs(l+1,rem+1)%mod)%mod;
}

int main(){
	cin.sync_with_stdio(false);
	fac[0]=fac[1]=1;
	repl(i,1,111111)fac[i+1]=fac[i]*(i+1)%mod;
	cin>>n;
	rep(i,n)cin>>a[i];
	cout<<dfs(0,0)%mod<<endl;
	return 0;
}


Measured memory_bytes: 3456
#include <iostream>
#include <string>
using namespace std;
int main()
{
  int n;
  cin>>n;
  int a=0,b=0;
  for(int i=0;i<n;i++)
  {
    string s,t;
    cin>>s>>t;
    if(s>t)
      a+=3;
    else if(s<t)
      b+=3;
    else
    {a++;b++;}
  }
  cout<<a<<' '<<b<<endl;
}

Measured memory_bytes: 3124
use std::collections;
use std::error::Error;
use std::io;
use std::process;

fn main() {
    if let Err(_) = run() {
        process::exit(1);
    }
}

fn run() -> Result<(), Box<Error>> {
    let mut nm = String::new();
    io::stdin().read_line(&mut nm)?;
    let nm: Vec<&str> = nm.trim().split(" ").collect();
    let n: i32 = nm[0].parse()?;
    let m: i32 = nm[1].parse()?;
    let mut adjs1 = collections::HashSet::new();
    let mut adjsn = collections::HashSet::new();
    for _ in 0..m {
        let mut ab = String::new();
        io::stdin().read_line(&mut ab)?;
        let ab: Vec<&str> = ab.trim().split(" ").collect();
        let a: i32 = ab[0].parse()?;
        let b: i32 = ab[1].parse()?;
        if a == 1 {
            adjs1.insert(b);
        }
        if a == n {
            adjsn.insert(b);
        }
        if b == 1 {
            adjs1.insert(a);
        }
        if b == n {
            adjsn.insert(a);
        }
    }
    for x in adjs1 {
        if adjsn.contains(&x) {
            println!("POSSIBLE");
            return Ok(());
        }
    }
    println!("IMPOSSIBLE");
    Ok(())
}


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

#define int long long

#define ii pair<int,int>
#define fi first
#define sc second

#define all(x) (x).begin(),(x).end()

void solve() {
  int n;
  cin >> n;
  cout << "ABC" << n << '\n';
}

signed main() {
#ifdef _DEBUG
  // freopen("in" , "r", stdin );
  // freopen("out", "w", stdout);
#endif
  ios::sync_with_stdio(0); cin.tie(0);
  int T = 1;
  // cin >> T;
  while (T--) solve();
}


Measured memory_bytes: 3656
#include <bits/stdc++.h>
#define boost ios_base::sync_with_stdio(false), cin.tie(NULL);

using namespace std;
const int N = 5e3 + 44;
const int X[] = {1,0,-1,0,1,-1,1,-1};
const int Y[] = {0,1,0,-1,1,1,-1,-1};
const int mod = 1e9 + 7;
const long long INF = 1e18;
const int inf = 1e9;

vector <int> g[N], f[N];

bool u[N];

int a, b;

bool ok = 0;

int finish;

int p[N];

void dfs (int v, int start) {
	u[v] = 1;
	bool kk = 1;
	for (int to : g[v]) {
		if (u[to] && to != start) {
			kk = 0;
		}
	}
	for (int to : f[v]) {
		if (u[to] && to != start && to != p[v]) {
			kk = 0;
		}
	}
	if (!kk) {
		u[v] = 0;
		return;
	}
	for (int to : g[v]) {
		if (to == start) {
			ok = 1;
			finish = v;
			return;
		}
	}
	for (int to : g[v]) {
		if (!u[to]) {
			p[to] = v;
			dfs (to, start);
		}
		if (ok)
			return;
	}
}

int main () {
	boost;
	int n, m;
	cin >> n >> m;
	for (int i = 0 ; i < m ; ++ i) {
		cin >> a >> b;
		--a, --b;
		g[a].push_back (b);
		f[b].push_back (a);
	}
	for (int i = 0 ; i < n ; ++ i) {
		for (int j = 0 ; j < n ; ++ j) {
			u[j] = 0;
			p[j] = 0;
		}
		ok = 0;
		p[i] = -1;
		dfs(i, i);
		if (ok) {
			vector <int> ans;
			while (finish != -1) {
				ans.push_back (finish);
				finish = p[finish];
			}
			reverse (ans.begin(), ans.end());
			cout << ans.size() << "\n";
			for (int i : ans)
				cout << i + 1 << "\n";
			return 0;
		}
	}
	cout << -1;
}

Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
const int mod=1000000007,N=100100;
char s[N];
int a[N],g[N],ans,f[N],h[3],cnt[3],n;
int main(){
	ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
	cin>>(s+1);n=strlen(s+1);
	f[0]=1;
	for(int i=n;i;--i){a[i]=s[i]-'`';g[i]=(g[i+1]+a[i])%3;}
	h[0]=h[1]=h[2]=2;++n;
	for(int i=1;i<=n;++i){
		if(a[i]==a[i-1])--cnt[0],--cnt[1],--cnt[2];
		for(int j=0;j<3;++j)
			for(;h[j]<=n&&(!cnt[j]||g[h[j]]!=j);++h[j])
				cnt[j]+=a[h[j]-1]==a[h[j]];
		if(i==1&&h[0]>n&&h[1]>n&&h[2]>n){cout<<1<<'\n';return 0;}
		f[i]=(f[i]+f[i-1])%mod;int t=(g[i]+a[i])%3;
		if(h[t]<=n)f[h[t]-1]=(f[h[t]-1]+f[i-1])%mod;
		if(i>1&&!g[i])ans=(ans+f[i-1])%mod;
	}
	cout<<ans<<'\n';	
	return 0;
}



Measured memory_bytes: 1536
import java.util.*;

public class Main {

	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int[] num = new int[N+1];
		for (int i = 1; i <= N; i++) {
			num[i] = sc.nextInt();
		}
		int number = 1;
		int count = 0;
		boolean key = false;
		for (int i = 1; i <= N; i++) {
			int tmp = num[number];
			if (tmp == -1) {
				System.out.println(-1);
				System.exit(0);
			}
			num[number] = -1;
			number = tmp;
			count++;
			if (number == 2) {
				key = true;
				break;
			}
		}
		System.out.println(true?count:-1);
	}
}

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

int main(){
    int n,k;cin>>n>>k;
    int a,b,c,d,e;
    for(int i=1;i<=n;i++){
        int t;cin>>t;
        if(t==1)a=i;break;
    }
    if(k==n){
        cout<<1<<endl;
        return 0;
    } 
    b=a/(k-1);c=n-b*(k-1);d=(c-1)/(k-1)+1;
    e=(n-1-1)/(k-1)+1;
    cout<<e<<endl;
}

Measured memory_bytes: 256
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef map<int, int> mii;
typedef map<char,int> mci;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vll;
typedef vector<pair<int,int>> vii;
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define in insert
#define sz(v) v.size()
#define mina(a,b) (a)=min((a),(b));
#define maxa(a,b) (a)=max((a),(b));
const int INF = 1e9 + 5;
void solve(){
    int a;
    string s;
    cin>>a>>s;
    if(a>=3200) cout<<s;
    else cout<<"red";
}
int main(){
    int T=1;
    //cin>>T;
    for(int i = 0; i < T; i++) solve(); 
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
long long sm,n,q,numtms[100003],a,b,c;
int main(void)
{
	cin>>n;
	for(int i=0;i<n;++i)
	{
		cin>>a;
		++numtms[a];
		sm+=a;
	}
	cin>>q;
	for(int i=0;i<q;++i)
	{
		cin>>b>>c;
		sm+=numtms[b]*(c-b);
		cout<<sm<<endl;
		numtms[c]+=numtms[b];
		numtms[b]=0;
	}
}

Measured memory_bytes: 4376
#include<bits/stdc++.h>
#define INF 1e9
#define llINF 1e18
#define MOD 1000000007
#define pb push_back
#define mp make_pair 
#define F first
#define S second
#define ll long long
#define vi vector<ll>
#define vvi vector<vi>
#define BITLE(n) (1LL<<((ll)n))
#define SHIFT_LEFT(n) (1LL<<((ll)n))
#define SUBS(s,f,t) ((s).substr((f),(t)-(f)))
#define ALL(a) (a).begin(),(a).end()
using namespace std;

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  ll n;cin>>n;
  ll ans = 1;
  while(ans <= n){
    ans *= 2;
  }
  cout<<ans/2<<endl;
  return 0;
}


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

void dfs(vector<vector<int> > &adj, vector<bool> &used, int node, set<int> dame, int &ans){

    //cout << node << endl;
    used[node] = true;
    if(dame.find(node) == dame.end()) ans++;

    for(auto x : adj[node]){

        if(!used[x]){
            dfs(adj, used, x, dame, ans);
        }
    }

}

//みつよし作
vector<string> split(string s){
    vector<string> ret;
    int idx = 0;
    for(int i = 0; i < s.size(); i++){
        if(s[i] == ':' || s[i] == ',' || s[i] == '.'){
            ret.push_back(s.substr(idx, i - idx));
            idx = i + 1;
        }
    }
    return ret;
}
 
int main(){


    while(1){
        int n; cin >> n;
        if(!n) break;

        int V = 0;
        map<string, int> str_to_i;
        set<int> dame;
        vector<vector<int> > adj(10000);
        for(int i = 0; i < n; i++){
            string s; cin >> s;
            vector<string> vec = split(s);
            //cout << "V = " << V << endl;
            int u;
            if(str_to_i.find(vec[0]) == str_to_i.end()){
                u = V;
                str_to_i[vec[0]] = V;
                V++;
            }else{
                u = str_to_i[vec[0]];
            }
            //cout << "u = " << u << endl;
            dame.insert(u);

            for(int i = 1; i < (int)vec.size(); i++){
                int v;
                //cout << "hoge" << endl;
                if(str_to_i.find(vec[i]) == str_to_i.end()){
                    v = V;
                    str_to_i[vec[i]] = V;
                    V++;
                }else{
                    v = str_to_i[vec[i]];
                }

                //cout << "huga" << endl;
                //cout << "u = " << u << ", v =  " << v << endl;
                adj[u].push_back(v);
                
            }
        }
        
        //cout << " V = " <<  V << endl;
        vector<bool> used(V, false);
        int ans = 0;
        dfs(adj, used, 0, dame, ans);
        cout << ans << endl;
        
    }

    return 0;
}


Measured memory_bytes: 3640
N, X = map(int, input().split())
A = list(map(int, input().split()))

count = 0
for i in range(N-1):
	diff = (A[i] + A[i + 1]) - X
	if 0 < diff:
		count += diff
		if diff <= A[i + 1]:
			A[i + 1] -= diff
		else:
			diff -= A[i + 1]
			A[i + 1] = 0
			A[i] -= diff
print(count)


Measured memory_bytes: 14588
#include <bits/stdc++.h>
#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(v) v.begin(), v.end()
using namespace std;
typedef long long ll;

int D;
int C[30];
int S[400][30];
int last[400][30];

unsigned int xor128()
{
  static unsigned int x=123456789,y=362436069,z=521288629,w=88675123;
  unsigned int t;
  t=(x^(x<<11)); x=y; y=z; z=w; 
  return( w=(w^(w>>19))^(t^(t>>8)) );
}

ll score(vector<int>& t)
{
  ll s = 0LL;
  REP(i,t.size()){
    s += S[i][t[i]];
    REP(j,26) last[i+1][j] = last[i][j];
    last[i+1][t[i]] = i+1;
    REP(j,26){
      s -= C[j] * (i+1-last[i+1][j]);
    } 
  }
  return s;
}

ll score_2(vector<int>& t, ll before, int d, int old, int q)
{
  ll s = before;
  s += S[d][q] - S[d][old];
  FOR(i,d,D){
    if(t[i]==old) break;
    s += C[old] * ((i+1) - last[i+1][old]);
    s -= C[old] * ((i+1) - last[d][old]);
  }
  FOR(i,d,D){
    if(i!=d && t[i]==q) break;
    s += C[q] * ((i+1) - last[i+1][q]);
    s -= C[q] * ((i+1) - (d+1));
  }

  return s;
}

vector<int> init(void)
{
  vector<int> t;
  REP(d, D){
    ll max_sc = LLONG_MIN;
    int ind = 0;
    REP(i,26){
      t.push_back(i);
      ll sc = score(t);
      if(max_sc<sc){
        max_sc = sc;
        ind = i;
      }
      t.pop_back();
    }
    t.push_back(ind);
  }
  return t;
}

int main()
{
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  cin >> D;
  REP(i,26) cin >> C[i];
  REP(i,D) REP(j,26) cin >> S[i][j];

  auto T = init();
  ll max_score = score(T);
  
  int ti = clock();
  while(clock() - ti < 190 * CLOCKS_PER_SEC / 100){ 
    REP(loop,100){
      int d = xor128() % 365;
      int q = xor128() % 26;
      int old = T[d];
      T[d] = q;
      ll tmp = score_2(T, max_score, d, old, q);
      if(max_score<tmp){
        max_score = tmp;
        FOR(i,d,D){
          if(T[i]==old) break;
          last[i+1][old] = last[d][old];
        }
        FOR(i,d,D){
          if(i!=d && T[i]==q) break;
          last[i+1][q] = (d+1);
        }
      }else{
        T[d] = old;
      }
    }
  }
  REP(i,D) cout << T[i]+1 << '\n';
  return 0;
}


Measured memory_bytes: 3760
def solve():
    N, K, Q = map(int, input().split())

    num_of_ans = [0 for _ in range(N)]
    for _ in range(Q):
        num_of_ans[int(input())-1] += 1
    
    for i in range(N):
        points = K - (Q - num_of_ans[i])
        if points <= 0:
            print("No")
        else:
            print("Yes")

solve()

Measured memory_bytes: 53048
base = 2000003
mask = (1 << 32) - 1

while True:
    n = int(input())
    if not n:
        break
    m = int(input())
    s = [int(c == 'I') for c in input().strip()]
    l = 2 * n + 1

    key, i, t = 0, 0, 1
    while i < l:
        key = (key + t) & mask
        t = (t * base ** 2) & mask
        i += 2

    cnt = 0
    t1 = 1
    for _ in range(l):
        t1 = (t1 * base) & mask
    e = 0
    for i in range(l):
        e = e * base + s[i]
    for i in range(m - l):
        if e == key:
            cnt += 1
        e = (e * base - t1 * s[i] + s[i + l]) & mask
    if e == key:
        cnt += 1

    print(cnt)

Measured memory_bytes: 18212
n, m = map(int, input().split())

mod = 1000000007
fact = [1] * (m + 1)
ifact = [1] * (m + 1)

for i in range(m):
    fact[i + 1] = fact[i] * (i + 1) % mod
    ifact[i + 1] = pow(fact[i + 1], mod - 2, mod)


def comb(x, y):
    if y < 0 or y > x:
        return 0
    return (fact[x] * ifact[x - y] * ifact[y]) % mod


def perm(x, y):
    if y < 0 or y > x:
        return 0
    return (fact[x] * ifact[x - y]) % mod


ans = 0
for i in range(n + 1):
    ans += (-1) ** i * comb(n, i) % mod * perm(m, i) * (perm(m - i, n - i) % mod) ** 2
    ans %= mod
print(ans)


Measured memory_bytes: 95828
#include<iostream>
#include<iomanip>
#include<vector>
#include<string>
#include<algorithm>
#include<cmath>
#include<functional>
#include<map>
#include<cstdlib>
#include<complex>
#include<numeric>
#include<set>
#include<deque>
#include<queue>

using namespace std;
using Int = long long;
Int INF = 1LL << 60;
const Int MOD = 1000000000 + 7;

int main() {

	cin.tie(nullptr);
	ios::sync_with_stdio(false);

	string s;
	cin >> s;

	Int len = s.size();
	Int ans = INF;

	Int temp;
	for (Int i = 0; i < len-2; i++) {
		temp = (s[i] - '0') * 100 + (s[i + 1] - '0') * 10 + (s[i + 2] - '0');
		ans = min(ans, abs(temp - 753));
	}
	cout << ans << "\n";
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdint>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <cctype>
#include <cassert>
#include <climits>
#include <string>
#include <bitset>
#include <cfloat>
#include <unordered_set>
#pragma GCC optimize("Ofast")
using namespace std;
typedef long double ld;
typedef long long int ll;
typedef unsigned long long int ull;
typedef vector<int> vi;
typedef vector<char> vc;
typedef vector<bool> vb;
typedef vector<double> vd;
typedef vector<string> vs;
typedef vector<ll> vll;
typedef vector<pair<int, int> > vpii;
typedef vector<vector<int> > vvi;
typedef vector<vector<char> > vvc;
typedef vector<vector<string> > vvs;
typedef vector<vector<ll> > vvll;

#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rrep(i, n) for (int i = 1; i <= (n); ++i)
#define irep(it, stl) for (auto it = stl.begin(); it != stl.end(); it++)
#define drep(i, n) for (int i = (n)-1; i >= 0; --i)
#define mes(a) cout << (a) << endl
#define dmes(a, b) cout << (a) << " " << (b) << endl
#define re0 return 0
#define mp(p, q) make_pair(p, q)
#define pb(n) push_back(n)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define Sort(a) sort(a.begin(), a.end())
#define rSort(a) sort(a.rbegin(), a.rend())
#define MATHPI acos(-1)
#define itn int;
int dx[8] = { 1, 0, -1, 0, 1, -1, -1, 1 };
int dy[8] = { 0, 1, 0, -1, 1, 1, -1, -1 };
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; }
struct io { io() { ios::sync_with_stdio(false); cin.tie(0); } };
const int INF = INT_MAX;
const ll LLINF = 1LL << 60;
const ll MOD = 1000000007;
const double EPS = 1e-9;

signed main(void)
{    
    ll h, w;
    cin >> h >> w;
	vs a(h);
	rep(i, h) {
		cin >> a[i];
	}
 
	vb row(h, false);
	vb col(w, false);
    
	rep(i, h) {
		rep(j, w) {
			if (a[i][j] == '#') {
				row[i] = true;
				col[j] = true;
			}
		}
	}
 
	rep(i, h) {
		if (row[i]) {
			rep(j, w) {
				if (col[j]) {
					cout << a[i][j];
				}
			}
			cout << endl;
		}
	}
    
    
    
    
    
    
    
    
    
    
}

Measured memory_bytes: 3588
#include <iostream>
#include <vector>
#include <map>
#include <algorithm>

using myPair = std::pair<int, int>;

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

	std::vector<int> v( n );
	for ( int i = 0; i < n; i++ )
	{
		std::cin >> v[i];
	}

	std::map<int, int> m1, m2;
	std::vector<myPair> vv1;
	std::vector<myPair> vv2;
	for ( int i = 0; i < n; i++ )
	{
		if ( i % 2 )
		{
			m1[v[i]]++;
		}
		else
		{
			m2[v[i]]++;
		}
	}

	// 出現頻度の方をキーにし直す
	for ( auto it = m1.begin(); it != m1.end(); it++ )
	{
		vv1.emplace_back( std::make_pair( (*it).second, (*it).first ) );
	}
	for ( auto it = m2.begin(); it != m2.end(); it++ )
	{
		vv2.emplace_back( std::make_pair( (*it).second, (*it).first ) );
	}

	// 降順ソートする
	std::sort( vv1.begin(), vv1.end(), []( myPair a, myPair b ) {
			return ( a.first > b.first );
		} );
	std::sort( vv2.begin(), vv2.end(), []( myPair a, myPair b ) {
			return ( a.first > b.first );
		} );

	int counter = 0;
	if ( vv1[0].second == vv2[0].second )
	{
		//	最頻出の値がダブった
		// 例： 1 1 1 1 1 2 など
		// →vvX[0]が小さい方を、vvX[1]の値に書き換える
		if ( vv1[0].first > vv2[0].first )
		{
			counter += ( ( n / 2 ) - vv2[1].first ); // 書き換えないのはvv2[1]の値
			counter += ( ( n / 2 ) - vv1[0].first ); // 書き換えないのはvv1[0]の値
		}
		else if ( vv1[0].first < vv2[0].first )
		{
			counter += ( ( n / 2 ) - vv1[1].first );
			counter += ( ( n / 2 ) - vv2[0].first );
		}
		else
		{
			// 頻度も一緒の場合
			if ( vv1[1].first > vv2[1].first )
			{
				counter += ( ( n / 2 ) - vv1[1].first );
				counter += ( ( n / 2 ) - vv2[0].first );
			}
			else
			{
				counter += ( ( n / 2 ) - vv2[1].first );
				counter += ( ( n / 2 ) - vv1[0].first );
			}
		}
	}
	else
	{
		// vv1とvv2の上位要素以外をすべて書き換える
		counter += n - ( vv1[0].first + vv2[0].first );
	}

	std::cout << counter << std::endl;

	return ( 0 );
}


Measured memory_bytes: 6524
//Dragon_warrior7(IITK)
#pragma GCC optimize ("Ofast")
#pragma GCC target ("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#pragma GCC optimize ("-ffloat-store")
#include <bits/stdc++.h>
// #include <ext/pb_ds/assoc_container.hpp>
// #include <ext/pb_ds/tree_policy.hpp>
using namespace std;
//using namespace __gnu_pbds;
#define umap unordered_map
#define ll long long
#define pb push_back
#define nl cout << '\n'
#define sor(x) sort(x.begin(), x.end())
#define rev(v) reverse(v.begin(), v.end())
#define lb(v, temp) lower_bound(v.begin(), v.end(), temp)
#define ub(v, temp) upper_bound(v.begin(), v.end(), temp)
#define fi first
#define se second
#define llmax 1000000000000000000
#define pll pair<ll, ll> 
#define ull unsigned ll
#define vll vector<ll> 
#define rub cout << "\n------------------------------------\n"
#define deb(x) cout<<#x<<' '<<'='<<' '<<x<<'\n'
//typedef  tree < int ,  null_type ,  greater<int> ,  rb_tree_tag ,  tree_order_statistics_node_update > oset;
void read(vector<ll> &v)
{
	for (int i = 0; i < v.size(); i++)
		cin >> v[i];
}
// const int mod=1e9+7;
// ll power(ll a,ll b) {ll res=1;a%=mod; assert(b>=0); for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}
// ll modInverse(ll a){return power(a,mod-2);}
ll n,m,a,b,c,k,temp,x,y;
void solveforthiscase(const int & test)
{//deb(test);
cin>>n>>m;
if(m==1 && n!=1)
{
    swap(n,m);
}
if(n==1 && m==1)
{
    cout<<1;
    return ;
}
if(n==1 && m==2)
{
    cout<<0;
    return ;
}
if(n==1)
{
    cout<<m-2;
    return ;
}
cout<<(n*m-2*m-2*(n-2));






return ;
}
int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	int test=1;
// 	cin>>test;
    for(int i=1;i<=test;i++)
    {
        solveforthiscase(i);
    }
}

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

using namespace std;

int n;
int a[2000];
int sum = 0;

const int SUM_MAX = 2000 * 2000 + 1;
bitset<SUM_MAX> dp;

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

    dp = bitset<SUM_MAX>("1");

    for (int i = 0; i < n; ++i) {
        dp = dp | (dp << a[i]);
    }

    int i = (sum + 1) / 2;
    while(!dp[i]) i++;

    cout << i << endl;

}


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

#define rep(i, n) for (int i = 0; i < n; i++)
#define repr(i, n) for (int i = n-1; i >= 0; i--)
#define ALL(x) x.begin(),x.end()

using ll = long long;
using pii = pair<int, int>;
using vi = vector<int>;

const int mod = 1e9+7;
const ll INF = 1e18;
const int MAX = 1e6;

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

struct edge {int to, cost;}; // 辺
// vector<edge> graph[MAX]; // 隣接リスト
// bool visit[MAX]; // 訪問の有無

int n, m; // 変数
string s, t;
int dp[3001][3001];
string ans;

void res(int i, int j) { // LCSの復元
    if (i == 0 || j == 0) return;
    if (s[i] == t[j]) {
        ans.push_back(s[i]);
        res(i-1, j-1);
    } else if (dp[i][j] == dp[i-1][j]) {
        res(i-1, j);
    } else if (dp[i][j] == dp[i][j-1]) {
        res(i, j-1);
    }
}

void dp_solve() { // DP
    rep(i, n) {
        rep(j, m) {
            if (i == 0 || j == 0) {
                dp[i][j] = 0;
            } else {
                if (s[i] == t[j]) {
                    dp[i][j] = dp[i-1][j-1] + 1;
                } else {
                    int x = dp[i-1][j];
                    int y = dp[i][j-1];
                    dp[i][j] = max(x, y);
                }
            }
        }
    }
}

int rec(int i, int j) { // メモ化再帰
    if (dp[i][j] != -1) return dp[i][j];
    if (i == 0 || j == 0) return dp[i][j] = 0;
    if (s[i] == t[j]) return dp[i][j] = rec(i-1, j-1) + 1;
    int x = rec(i-1, j);
    int y = rec(i, j-1);
    return dp[i][j] = max(x, y);
}

int main() {
// input
    cin >> s;
    cin >> t;
    s = ' ' + s;
    t = ' ' + t;
    n = s.size();
    m = t.size();
// solve
    // dp_solve();
    rep(i, n) {
        rep(j, m) {
            dp[i][j] = -1;
        }
    }
    rec(n-1, m-1);
    res(n-1, m-1);
    reverse(ALL(ans));
// output
    cout << ans << "\n";
}

Measured memory_bytes: 38928
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int a = n / 1000;
        int b = n % 1000;
        int r = 0;
        if(b != 0){
            r = 1000 * (a + 1) - n;
        }
        System.out.println(r);
    }
}

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

using namespace std;

int main()
{
	int n;
	cin >> n;
	int ops = INT_MAX;
	for (int i = 0; i < n; i++)
	{
		int a;
		cin >> a;
		int count = 0;
		for (; (a & 1) == 0; a = a >> 1) count++;
		ops = min(ops, count);
	}
	cout << ops << endl;
	return 0;
}


Measured memory_bytes: 256
#![allow(unused, non_snake_case, dead_code, non_upper_case_globals)]
use {
    proconio::{marker::*, *},
    std::{cmp::*, collections::*, mem::*},
};

#[fastout]
fn main() {
    input! {//
           n:usize,
    mut       a:[usize;n],
       }
    // let mut st = BTreeSet::new();
    // // if a.contains(&1) {
    // //     println!("{}", "pairwise coprime");
    // //     return;
    // // }
    // for &x in a.iter() {
    //     st.insert(x);
    // }
    let mut allgcd = gcd_list(&a);
    let mut st = BTreeSet::new();
    let mut all = true;
    for &x in a.iter() {
        if x != 1 {
            let mut pf = prime_factor(x as i64);
            for (k, _) in pf {
                let kk = k;
                if st.contains(&k) {
                    all = false;
                    break;
                } else {
                    st.insert(kk);
                }
            }
            if !all {
                break;
            }
        }
    }
    if all {
        println!("{}", "pairwise coprime");
    } else {
        if allgcd == 1 {
            println!("{}", "setwise coprime");
        } else {
            println!("{}", "not coprime");
        }
    }
}
fn prime_factor(mut n: i64) -> std::collections::HashMap<i64, i64> {
    let mut res: std::collections::HashMap<i64, i64> = std::collections::HashMap::new();
    let mut i = 2;
    while i * i <= n {
        while n % i == 0 {
            let v = match res.get(&i) {
                Some(v) => *v + 1,
                None => 1,
            };
            res.insert(i, v);
            n /= i;
        }
        i += 1;
    }
    if n != 1 {
        res.insert(n, 1);
    }
    res
}
pub fn prime_sieve(n: usize) -> (Vec<usize>, Vec<bool>) {
    let mut prime = Vec::new();
    let mut is_prime = Vec::with_capacity(n + 1);
    is_prime.resize(n + 1, true);
    is_prime[0] = false;
    is_prime[1] = false;
    for i in 2..n + 1 {
        if is_prime[i] {
            prime.push(i);
            {
                let mut j = 2 * i;
                while j <= n {
                    is_prime[j] = false;
                    j += i;
                }
            }
        }
    }
    (prime, is_prime)
}
pub fn gcd(a: usize, b: usize) -> usize {
    if b == 0 {
        a
    } else {
        gcd(b, a % b)
    }
}
pub fn gcd_list(list: &[usize]) -> usize {
    list.iter().fold(list[0], |a, &b| gcd(a, b))
}


Measured memory_bytes: 17476
#include <bits/stdc++.h>
using namespace std;
#define int long long
int arr[100005];
int32_t main(){
    int n;
    cin >> n;
    int sum = 0;
    int minn = 100000000;
    int cnt = 0;
    for(int i = 0; i < n; i++){
        cin >> arr[i];
        if(arr[i] < 0){
            cnt++;
        }
        sum += abs(arr[i]);
        minn = min(abs(arr[i]), minn);
    }
    // cout << sum << endl;
    if(cnt % 2 != 0){
        sum -= 2 * abs(minn);
    }
    cout << sum << endl;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
 
class DisjointSet {
public:
  vector<int> p, rank, size;
  DisjointSet(int n) {
    p.assign(n, 0);
    rank.assign(n, 0);
    size.assign(n, 0);
    for (int i = 0; i < n; i++) {
      make_set(i);
    }
  }
 
  void make_set(int x) {
    p[x] = x;
    rank[x] = 0;
    size[x] = 1;
  }
 
  int find_set(int x) {
    if (x != p[x]) {
      p[x] = find_set(p[x]);
    }
    return p[x];
  }
 
  bool same(int x, int y) {
    return find_set(x) == find_set(y);;
  }
 
  int union_size(int x) {
    if (x != p[x]) {
      size[x] = union_size(find_set(x));
    }
    return size[x];
  }
 
  void link(int x, int y) {
    if(rank[x]  > rank[y]) {
        p[y] = x;
        size[x] = size[x] + size[y];
    }else if(rank[x] < rank[y]){
        p[x] = y;
        size[y] = size[x] + size[y];
    }else if(x != y) {
      p[y] = x;
      rank[x]++;
      size[x] = size[x] + size[y];
    }
  }
 
  void unite(int x, int y) {
      link(find_set(x), find_set(y));
  }
};
 
int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int H, W;
  cin >> H >> W;
  char c[H][W];
  for (int i = 0; i < H; i++) {
    string s;
    cin >> s;
    for (int j = 0; j < W; j++) {
      c[i][j] = s[j];
    }
  }
  int n = H * W;
  DisjointSet ds1(n);
  DisjointSet ds2(n);
 
  for (int i = 0; i < H; i++) {
    for (int j = 0; j < W - 1; j++) {
      int k = W * i + j;
      if (c[i][j] == '.' && c[i][j + 1] == '.') {
        ds1.unite(k, k + 1);
      }
    }
  }
 
  for (int i = 0; i < W; i++) {
    for (int j = 0; j < H - 1; j++) {
      int k = W * j + i;
      if (c[j][i] == '.' && c[j + 1][i] == '.') {
        ds2.unite(k, k + W);
      }
    }
  }
  int ans = 0;
  for (int i = 0; i < n; i++) {
    ans = max(ans, ds1.union_size(i) + ds2.union_size(i));
  }
  cout << ans - 1 << "\n";
  return 0;
}

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

#define int long long
#define For(i, a, b) for (int i = (a); i <= static_cast<int>(b); i++)
#define Forr(i, a, b) for (int i = (a); i >= static_cast<int>(b); i--)
#define rep(i, n) For(i, 0, n - 1)
#define repall(i, arr) for (auto& i : (arr))
#define all(x) (x).begin(), (x).end()
#define pb push_back
#define dump(x) cerr << #x << " = " << (x) << '\n'

template <typename T>
using pq = priority_queue<T>;
template <typename T>
using pqr = priority_queue<T, vector<T>, greater<T>>;
const int INF = INT_MAX / 2;
constexpr int MOD = 1e9 + 7;
using P = pair<int, int>;
using vec = vector<int>;
using mat = vector<vec>;

template <typename T1, typename T2>
ostream& operator<<(ostream& stream, const pair<T1, T2>& p) {
    return stream << p.first << " " << p.second;
}
template <typename T>
void print(const vector<vector<T>> matrix) {
    repall (vec, matrix)
        print(vec);
}
template <typename T>
void print(const vector<T> vec) {
    unsigned int len = vec.size();
    rep (i, len - 1)
        cout << vec[i] << ' ';
    cout << vec[len - 1] << '\n';
}
template <typename Arg>
void print(const Arg arg) {
    cout << arg << '\n';
}
template <typename Head, typename... Args>
void print(const Head head, const Args... args) {
    cout << head << " ";
    print(args...);
}
template <typename T>
T sum_(vector<T> vec, T init = 0) {
    return std::accumulate(all(vec), T(init));
}

void yn(bool tf) { print(tf ? "Yes" : "No"); }
void YN(bool tf) { print(tf ? "YES" : "NO"); }

template <typename T>
void init(vector<vector<T>> m) {
    repall (v, m)
        init(v);
}

template <typename T>
void init(vector<T>& v) {
    rep (i, v.size())
        cin >> v[i];
}

int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }
// -------------------------------------------------------------------

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

    vec req = {INF, 2, 5, 5, 4, 5, 6, 3, 7, 6};
    int n, m;
    cin >> n >> m;
    vec a(m);
    init(a);
    sort(all(a), greater<int>());

    vec dp(n + 1, -INF);
    dp[0] = 0;
    vector<string> ans(n + 1);
    For(i, 1, n) {
        int t = -INF, num = -1;
        repall (j, a) {
            if (i - req[j] < 0) continue;
            int ne = dp[i - req[j]] + 1;
            if (t < ne) {
                t = ne;
                num = j;
            }
            dp[i] = t;
        }

        if (num != -1) ans[i] = ans[i - req[num]] + to_string(num);
    }

    reverse(all(ans[n]));
    print(ans[n]);

    return 0;
}


Measured memory_bytes: 32000
#include<stdio.h>
#include <stdbool.h>

#define N 8
#define FREE -1
#define NOT_FREE 1

int row[N], col[N],dpos[2*N-1] , dneg[2*N-1];
bool X[N][N];

void initialize() {
  int i;
  for(i = 0;i<N;i++) {row[i] = FREE, col[i] = FREE;}
  for(i=0;i<2*N-1;i++) {dpos[i] = FREE; dneg[i] = FREE;}
}

void printBoard() {
  int i,j;
  for(i = 0;i<N;i++) {
    for(j = 0;j<N;j++) {
      if(X[i][j]) {
        if(row[i] != j) return;
      }
    }
  }
  for(i = 0;i<N;i++) {
    for(j = 0;j<N;j++) {
      printf("%s", (row[i] == j) ? "Q":"." );
    }
    printf("\n");
  }
}

void recursive(int i) {
  if(i == N) {
    printBoard();
    return;
}

int j;
for(j=0;j<N;j++) {
  if(NOT_FREE == col[j] ||
     NOT_FREE == dpos[i+j] ||
     NOT_FREE  == dneg[i-j+N-1]) continue;

     row[i] = j; col[j] = dpos[i+j] = dneg[i-j+N-1] = NOT_FREE;

     recursive(i+1);
     row[i] = col[j]=dpos[i+j] = dneg[i-j+N-1] = FREE;

}
}

int main() {
  initialize();
  int i,j;
  for(i = 0;i<N;i++) {
    for(j=0;j<N;j++) {
      X[i][j] = false;
    }
  }
  int k; scanf("%d\n", &k);
  for(i = 0;i<N;i++) {
    int r,c; scanf("%d%d\n", &r,&c );
    X[r][c] = true;
  }

  recursive(0);

  return 0;
}

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

int main() {
  vector<int>num(3);
  cin >> num.at(0) >> num.at(1) >> num.at(2);
  
  sort(num.begin(),num.end());
  int k = num.at(2) - num.at(0);
  int l = num.at(2) - num.at(1);
  
  if ((k+l) % 2 == 0) {
    cout << (k+l) / 2 << endl;
  }
  else {
    cout << (k+l+3) / 2 << endl;
  }
}

Measured memory_bytes: 256
#!usr/bin/env python3
from collections import defaultdict,deque
from heapq import heappush, heappop
import sys
import math
import bisect
import random
def LI(): return [int(x) for x in sys.stdin.readline().split()]
def I(): return int(sys.stdin.readline())
def LS():return [list(x) for x in sys.stdin.readline().split()]
def S(): return list(sys.stdin.readline())[:-1]
def IR(n):
    return [I() for i in range(n)]
def LIR(n):
    return [LI() for i in range(n)]
def SR(n):
    return [S() for i in range(n)]
def LSR(n):
    return [LS() for i in range(n)]

sys.setrecursionlimit(1000000)
mod = 1000000007

#A
def A():
    n = I()
    print(3*n**2)
    return

#B
def B():
    n,d = LI()
    f = [1]*(n+2*d+2)
    ans = 0
    for i in range(n):
        if f[i]:
            for j in range(i,i+2*d+1):
                f[j] = 0
            ans += 1
    print(ans)
    return

#C
def C():
    n = I()
    a = IR(n)
    mi = max(a)
    if a.count(mi) > 1:
        for i in range(n):
            print(mi)
    else:
        b = [a[i] for i in range(n)]
        b.sort()
        b = b[::-1]
        for i in range(n):
            if mi != a[i]:
                print(mi)
            else:
                print(b[1])

    return

#D
def D():
    n = I()
    a = LI()
    b = [0]*(n+1)
    for i in range(1,n+1)[::-1]:
        j = 2*i
        k = 0
        while j <= n:
            k ^= b[j]
            j += i
        if a[i-1]^k:
            b[i] = 1
    ans = []
    for i in range(n+1):
        if b[i]:
            ans.append(i)
    print(len(ans))
    if ans:
        print(*ans)
    return

#E
def E():
    n = I()
    a = IR(n)
    mi = [float("inf")]*(n+1)
    ans = 0
    for i in range(n):
        mi[bisect.bisect_right(mi,-a[i])] = -a[i]
    for i in range(n+1):
        if mi[i] == float("inf"):
            break
    print(i)
    return

#F
def F():
    n = I()

    return

#Solve
if __name__ == "__main__":
    E()


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

int main() {
  
  int H, W; cin >> H >> W; string table[H + 2][W + 2];
  
  for (int i = 0; i < H + 2; i++) {
    for (int j = 0; j < W + 2; j++) {
      table[i][j] = ".";
    }
  }
  
  for (int i = 1; i < H + 1; i++) {
    string square; cin >> square;
      for (int j = 1; j < W + 1; j++) {
        table[i][j] = square.at(j - 1);
    }
  }
  
  for (int i = 1; i < H + 1; i++) {
    for (int j = 1; j < W + 1; j++) {
      int tmp = 0;
      if (table[i][j] == "#") continue;
      for (int k = -1; k <= 1; k++) {
        for (int l = -1; l <= 1; l++) {
          if (table[i + k][j + l] == "#") tmp++;
        }
      }
      table[i][j] = to_string(tmp);
    }
  }
  
  for (int i = 1; i < H + 1; i++) {
    for (int j = 1; j < W + 1; j++) {
      cout << table[i][j];
    }
    cout << endl;
  }
  
}

Measured memory_bytes: 384
A=int(input())
B=int(input())
C=int(input())
X=int(input())
out=0
for i in range(A+1):
    for j in range(B+1):
        for k in range(C+1):
            sum = i*500 + j*100 + k*50
            if sum==X:
                out+=1
print(out)

Measured memory_bytes: 3060
/// 11:57 AM 03/05/20
/// Author: t_bone_289 (An Immature Programmer.... I'm still developing !!)
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/trie_policy.hpp>

using namespace std;
using namespace __gnu_pbds;
#define pll pair<ll,ll>
#define fi first
#define se second
#define mp make_pair
#define pb emplace_back
#define endl '\n'
#define M 1000000007
#define error(x) cout << #x << " = " << x << endl;
#define pi 3.14159265358979323846
typedef long long ll;
typedef long double ld;
typedef tree<ll, null_type, less<ll>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;

template<typename T>
void ContainerError(T &v);

ll powmod(ll base, ll exp, ll MOD);

ll mpow(ll base, ll exp);

ll gcd(ll a, ll b);

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);
    ll n,k;
    cin>>n>>k;
    vector<ll > v(n+1, 0);
    for(ll i=0;i<k;i++) {
        ll d;
        cin >> d;
        while(d--) {
            ll x;
            cin >> x;
            v[x]++;
        }
    }
    ll ans = 0;
    for(ll i=1;i<=n;i++) {
        ans += !v[i];
    }
    cout<<ans;
    return 0;
}

template<typename T>
void ContainerError(T &v) {
    cout << "{";
    for (auto &x:v) { cout << x << ','; }
    cout << "}" << endl;
    return;
}

ll powmod(ll base, ll exp, ll MOD) {
    ll res = 1;
    while (exp > 0) {
        if (exp % 2 == 1) res = (res * base) % MOD;
        base = (base * base) % MOD;
        exp /= 2;
    }
    return (res % MOD);
}

ll mpow(ll base, ll exp) {
    ll res = 1;
    while (exp > 0) {
        if (exp % 2 == 1) res = (res * base);
        base = (base * base);
        exp /= 2;
    }
    return (res);
}

ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }



Measured memory_bytes: 3644
import java.util.*;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		// // 整数の入力
		// int a = sc.nextInt();
		// // スペース区切りの整数の入力
		// int b = sc.nextInt();
		// int c = sc.nextInt();
		// // 文字列の入力
		// String s = sc.next();
		// // 出力
    // System.out.println((a+b+c) + " " + s);
		int N = sc.nextInt();
		Set<String> se = new HashSet<>();
		for (int i=0; i<N; i++) {
			String S = sc.next();
			se.add(S);
		}
		System.out.println(se.size() == 3 ? "Three" : "Four");
	}
}

Measured memory_bytes: 21844
N,K=map(int,input().split())
A=list(map(int,input().split()))
B=[0]*(N+1)
B[0]=1
if B[0] in A:c=B[0]
for i in range(1,N+1):
  B[i]=A[B[i-1]-1]

d=B.index(B[-1])+1
if K<=N:print(B[K]);exit()
print(B[d-1+(K+1-d)%(N+1-d)])


Measured memory_bytes: 32288
lst = []
for _ in range(3):
    lst += [list(map(int,input().split()))]

total = 0
for i in range(3):
    for j in range(3):
        total += lst[i][j]

total = total//3

flag = True
for i in range(3):
    a = lst[0][i%3]+lst[1][(i+1)%3]+lst[2][(i+2)%3]
    if a != total:
        flag = False

a = lst[0][0] + lst[1][2] + lst[2][1]
if a != total:
    flag = False

a = lst[1][1] + lst[0][2] + lst[2][0]
if a != total:
    flag = False

a = lst[2][2] + lst[1][0] + lst[0][1]
if a != total:
    flag = False

if flag:
    print ('Yes')
else:
    print ('No')


Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define ll long long
int in() {int x; cin>>x; return x;}
ll lin() {ll x; cin>>x; return x;}
string sin() {string x;cin>>x;return x;}
using graph = vector<vector<int>>;
using graph2 = vector<vector<pair<int, int>>>;

int main() {
    int N;
    cin>>N;
    int a;
    int p=pow(10, 5);
    int b[p]={0};
    rep(i, N){
        cin>>a;
        b[a]++;
    }
    int ans=0;
    rep(i, p){
        if(i==0){
            ans=max(ans, b[i]+b[i+1]);
        }
        else if (i==p-1){
            ans=max(ans, b[i]+b[i-1]);
        }
        else{
            ans=max(ans, b[i]+b[i-1]+b[i+1]);
        }
    }
    cout<<ans<<endl;
}

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

using namespace std;
int func(int N)
{
    int x=N;
        int y=(x+N/x)/2;
        while(y<x)
        {
               x=y;
               y=(x+N/x)/2;
        }
        return x*x;
}
int main()
{
    int n;
    cin>>n;
    cout<<func(n)<<endl;
}

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

int main()
{
    int input;
    int s1, s2, s3;

    cin >> input;
    s1 = input / 100;
    s2 = (input - s1 * 100) / 10;
    s3 = input % 10;

    cout << s1 + s2 + s3 << endl;
  
  return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <cmath>
#include <iostream>
#include <iterator>
#include <map>
#include <set>
#include <string>
#include <vector>

using namespace std;
using ull = unsigned long long;

int main() {
    int N;
    cin >> N;
    vector<ull> A;
    for (int i = 0; i < N; ++i) {
        ull tmp;
        cin >> tmp;
        A.push_back(tmp);
    }
    int ans = 0;
    while (true) {
        for (int i = 0; i < N; ++i) {
            if (A[i] % 2 != 0) {
                cout << ans << endl;
                return 0;
            } else {
                A[i] /= 2;
            }
        }
        ++ans;
    }
    cout << ans << endl;
}


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


int main() {
  int N;
  cin >> N;
  
  vector<int> joushi(N-1);
  for (int i=0; i<N-1 ;i++){
    cin >> joushi.at(i);
  }
  
   vector<int> buka(N);
   for (int i=0; i<N-1 ;i++){
     buka.at(joushi.at(i)-1) += 1;
   }
    
  for (int j=0; j<N ;j++){  
  cout << buka.at(j) << endl;
  }
  
  
  return 0;
}



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

using namespace std;
typedef long long ll;
const int N = 100010;
ll a[N];
bool b[N];
int main()
{
	ll n;
	cin>>n;
	a[0]=0;
	ll ans=0;
	ll res=0;
	for(ll i=1;i<=n;i++)
	{
		cin>>a[i];
		if(a[i]>a[i-1])
			b[i]=0;
		else
			b[i]=1;	
	}
	ll flag=0;
	for(ll i=1;i<=n;i++)
	{
		if(b[i]) 
		{
			res++;
			flag=res;
		}
		else
		{
			ans=max(ans,res);
			res=0;
		}
	}
	cout<<max(ans,flag)<<endl;
	return 0;
}

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

#define forn(i, n)          for(int i = 0; i < n; ++i)
#define MEMSET_INF          127 // ~2B
#define MEMSET_HALF_INF     63  // ~1B

using namespace std;

typedef long long           ll;
typedef vector<int>         vi;
typedef vector<vi>          vvi;
typedef pair<int, int>      ii;
typedef vector<ii>          vii;
typedef set<int>            si;
typedef map<string, int>    msi;

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

    int a; cin >> a;
    printf("%d\n", a+a*a+a*a*a);

}

Measured memory_bytes: 3724
#include <iostream>
#include <algorithm>
#include <vector>
#include <cstdio>
#define rep(i,n) for(int i=0;i<n;++i)
#define rep1(i,n) for(int i=1;i<=n;++i)
using namespace std;
int main()
{
  int n;
  cin >> n;
  if(n%2==0){
    int x = n/2;
    double res = (double)x/n;    
    printf("%.7f\n", res);
  }
  else{
    int x = n/2 + 1;
    double res = (double)x/n;
    printf("%.7f\n", res);
  }
  return 0;
}


Measured memory_bytes: 256
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define pp pair<int,int>
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define ld long double
#define al(a) (a).begin(),(a).end()
#define mk make_pair
#define check cout<<"?"<<endl;

ll MOD=1000000007;
ll mod=998244353;
int inf=1000001000;
ll INF=1e18+5;

int main(){
    int a,b,h; cin>>a>>b>>h;
    cout<<(a+b)*h/2<<endl;
}

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

ll dp[51][2];

int main(){
	dp[0][0] = 1ll;
	int n, p;
	scanf("%d%d", &n, &p);
	f(i, 1, n + 1){
		int t;
		scanf("%d", &t);
		if (t & 1)dp[i][0] += dp[i - 1][1] + dp[i - 1][0], dp[i][1] += dp[i - 1][0] + dp[i - 1][1];
		else dp[i][0] = dp[i - 1][0] << 1, dp[i][1] = dp[i - 1][1] << 1;
	}
	printf("%lld\n", dp[n][p]);
}

Measured memory_bytes: 256