akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>

#define M_PI       3.14159265358979323846   // pi

using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef vector<ll> VI;
typedef pair<ll, ll> P;
typedef tuple<ll, ll, ll> t3;
typedef tuple<ll, ll, ll, ll> t4;

#define rep(a,n) for(ll a = 0;a < n;a++)
#define repi(a,b,n) for(ll a = b;a < n;a++)

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

template<typename T>
void cmpmax(T& reference, T value) {
	reference = max(reference, value);
}

template<typename T>
void cmpmin(T& reference, T value) {
	reference = min(reference, value);
}

const ll mod = 1000000007;

static const ll INF = 1e15;

int main() {
	int n;
	cin >> n;
	vector<int> order(n*n);
	rep(i, n*n) {
		int o;
		cin >> o;
		o--;
		order[i] = o;
	}
	vector<vector<int>> grid(n, vector<int>(n));
	rep(y, n) {
		ll dy = min(y, n - 1 - y);
		rep(x, n) {
			ll dx = min(x, n - 1 - x);
			grid[y][x] = min(dy, dx);
		}
	}
	ll sum = 0;
	vector<vector<bool>> exists(n, vector<bool>(n, true));
	for (int i = 0; i < n * n; i++) {
		auto id = order[i];
		int sy = id / n;
		int sx = id % n;
		auto c = grid[sy][sx];
		sum += c;
		exists[sy][sx] = false;
		queue<P> q;
		q.emplace(sy, sx);
		while (!q.empty()) {
			auto f = q.front(); q.pop();
			P shifts[] = { {1,0},{-1,0},{0,1},{0,-1} };
			for (auto s : shifts) {
				auto nx = s.second + f.second;
				auto ny = s.first + f.first;
				if (nx < 0 || nx >= n) continue;
				if (ny < 0 || ny >= n) continue;
				auto current = grid[ny][nx];
				auto update = grid[f.first][f.second];
				if (exists[f.first][f.second]) {
					update++;
				}
				if (current > update) {
					grid[ny][nx] = update;
					q.emplace(ny, nx);
				}
			}
		}
	}
	cout << sum << endl;
	return 0;
}



Measured memory_bytes: 5252
//by yjz
#include<bits/stdc++.h>
using namespace std;
#define FF first
#define SS second
#define PB push_back
#define MP make_pair
#define bged(v) (v).begin(),(v).end()
#define foreach(it,s) for(__typeof((s).begin()) it=(s).begin();it!=(s).end();it++)
typedef long long ll;
const int Imx=2147483647;
const ll Lbig=2e18;
const int mod=1e9+7;
//My i/o stream
struct fastio
{
	char s[100000];
	int it,len;
	fastio(){it=len=0;}
	inline char get()
	{
		if(it<len)return s[it++];it=0;
		len=fread(s,1,100000,stdin);
		if(len==0)return EOF;else return s[it++];
	}
	bool notend()
	{
		char c=get();
		while(c==' '||c=='\n')c=get();
		if(it>0)it--;
		return c!=EOF;
	}
}_buff;
#define geti(x) x=getnum()
#define getii(x,y) geti(x),geti(y)
#define getiii(x,y,z) getii(x,y),geti(z)
#define puti(x) putnum(x),putchar(' ')
#define putii(x,y) puti(x),puti(y)
#define putiii(x,y,z) putii(x,y),puti(z)
#define putsi(x) putnum(x),putchar('\n')
#define putsii(x,y) puti(x),putsi(y)
#define putsiii(x,y,z) putii(x,y),putsi(z)
inline ll getnum()
{
	ll r=0;bool ng=0;char c;c=_buff.get();
	while(c!='-'&&(c<'0'||c>'9'))c=_buff.get();
	if(c=='-')ng=1,c=_buff.get();
	while(c>='0'&&c<='9')r=r*10+c-'0',c=_buff.get();
	return ng?-r:r;
}
template<class T> inline void putnum(T x)
{
	if(x<0)putchar('-'),x=-x;
	register short a[20]={},sz=0;
	while(x)a[sz++]=x%10,x/=10;
	if(sz==0)putchar('0');
	for(int i=sz-1;i>=0;i--)putchar('0'+a[i]);
}
inline char getreal(){char c=_buff.get();while(c==' '||c=='\n')c=_buff.get();return c;}
int n,m,px[200111],py[200111];
int col[200111],cnt[4];
vector<int>con[200111];
bool bi;
void dfs(int x,int c)
{
//	cerr<<"dfs:"<<x<<" "<<c<<endl;
	col[x]=c;cnt[c]++;
	for(int i=0;i<con[x].size();i++)
	{
		int u=con[x][i];
		if(!col[u])dfs(u,c^1);
		else if(col[u]!=(c^1))
		{
			bi=0;
		}
	}
}
int main()
{
	getii(n,m);
	for(int i=1;i<=m;i++)
	{
		int x,y;
		getii(x,y);
		con[x].PB(y);
		con[y].PB(x);
		px[i]=x,py[i]=y;
	}
	bi=1;
	dfs(1,2);
	ll ans=0;
	if(!bi)
	{
		ans=1ll*n*(n-1)/2-m;
	}
	else
	{
		ans=1ll*cnt[2]*cnt[3]-m;
	}
	cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 10880
#include<stdio.h>
#include<stdlib.h>
#define ll long long
#define rep(i,l,r) for((i)=(l);(i)<(r);(i)++)
typedef struct Data{
    ll a,b;
}data;
int cmp(const void *c,const void *d){
  ll A = ((data *)c)->b;
  ll B = ((data *)d)->b;
  ll C = ((data *)c)->a;
  ll D = ((data *)d)->a;
  ll sub;
    sub=A-B;
    if(sub!=0)return sub;
    sub=D-C;
  return sub;
}
int main(){
    ll n,i,t=0;
    scanf("%lld",&n);
    data s[n];
    rep(i,0,n)scanf("%lld %lld",&s[i].a,&s[i].b);
    qsort(s,n,sizeof(data),cmp);
    rep(i,0,n){
        t+=s[i].a;
        if(t>s[i].b){
            printf("No\n");
            return 0;
        }
    }
    printf("Yes\n");
}

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

int main() {
  int a, b, c, x;
  cin >> a;
  cin >> b;
  cin >> c;
  cin >> x;
  int ans = 0;
  for (int i=0; i<a+1; i++) {
    for (int j=0; j<b+1; j++) {
      if ((x - (500 * i) - (100 * j)) >= 0 && (x - (500 * i) - (100 * j)) / 50 <= c) {
        ans ++;
      }
    }
  }
  cout << ans << endl;
}

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

#define INF 2140000000
#define MaxN 100005

using namespace std;

int N,M;
string out[MaxN];
struct spec
{
    int year,pref,pos;
}v[MaxN];

bool cond(spec a,spec b)
{
    return a.pref<b.pref||(a.pref==b.pref&&a.year<b.year);
}

int main()
{
    cin>>N>>M;

    for(int i=1;i<=M;i++)
    {
        cin>>v[i].pref>>v[i].year;
        v[i].pos=i;
    }
    sort(v+1,v+1+M,cond);

    int P=0,X=0;

    for(int i=1;i<=M;i++)
    {
        if(v[i].pref!=P)
        {
            X=1,P=v[i].pref;
        }
        else X++;
        string S;
        int Pow;
        Pow=100000;
        while(Pow)
        {
            char c='0'+P/Pow%10;
            S+=c;
            Pow/=10;
        }
        Pow=100000;
        while(Pow)
        {
            char c='0'+X/Pow%10;
            S+=c;
            Pow/=10;
        }
        out[v[i].pos]=S;
    }

    for(int i=0;i<=M;i++)
        cout<<out[i]<<'\n';

    return 0;
}


Measured memory_bytes: 9728
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <cstring>
#include <string>
#include <vector>
#include <random>
#include <bitset>
#include <queue>
#include <cmath>
#include <unordered_map>
#define rep(i,n) for (int i=0; i<n;++i)
#define rep_down(i,n) for (int i=n-1; i>=0;--i)
#define ALL(a)  (a).begin(),(a).end()
typedef long long ll;
using namespace std;
const ll MOD = 1000000007LL;
const int INF = 1000000007;
int N;
ll X;
ll P[53], S[53];


ll dfs(int n, ll x){ // レベルnバーガーの下からx番目の層にあるぱてぃの個数
  if (x==1) return n==0?1ll:0ll;
  else if (x<= 1+S[n-1]) return dfs(n-1, x-1);
  else if (x==2+S[n-1]) return P[n-1] + 1ll;
  else if (x<=2+2*S[n-1]) return P[n-1] + 1ll + dfs(n-1, x-2ll-S[n-1]);
  else return 2*P[n-1]+1ll;
}


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

  cin >> N >> X;
  P[0] = 1ll;
  S[0] = 1ll;
  rep(i, N-1){
    P[i+1] = 2*P[i]+1ll;
    S[i+1] = 2*S[i]+3ll; 
  }

  cout << dfs(N, X) << "\n";
  return 0;
}


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

const ll INF = 1LL << 60;

ll N, M;

struct Rerooting {
    /* TODO: start 問題ごとに書き換え */
    struct DP {  // DP の型
        ll dp;
        DP(ll dp_) : dp(dp_) {}
    };

    // 単位元はしっかり定義する(末端でもadd_rootされるので注意)
    const DP identity = DP(1);

    // d:辺eに対応する部分木のdpの値  cost:eのコスト
    function<DP(DP, DP, long long)> merge = [](DP dp_cum, DP d, long long cost) -> DP {
        return DP((dp_cum.dp * d.dp) % M);
    };

    // まとめたDPを用いて、新たな部分木のDPを計算する
    function<DP(DP)> add_root = [](DP d) -> DP {
        // ※ 最後に1回、余分な + 1 がかかる
        return DP(d.dp + 1);
    };
    /* TODO: end 問題ごとに書き換え */

    // グラフの定義
    struct Edge {
        int from;
        int to;
        long long cost;
    };
    using Graph = vector<vector<Edge>>;

    // dp[v][i]: vから出るi番目の有向辺に対応する部分木のDP
    vector<vector<DP>> dp;

    // ans[v]: 頂点vを根とする木の答え
    vector<DP> ans;
    Graph G;

    Rerooting(int N) : G(N) {
        dp.resize(N);
        ans.assign(N, identity);
    }

    void add_edge(int a, int b, long long c = 1) {
        G[a].push_back({a, b, c});
    }
    void build() {
        dfs(0);            // 普通に木DP
        bfs(0, identity);  // 残りの部分木に対応するDPを計算
    }

    DP dfs(int v, int p = -1) {  // 頂点v, 親p
        DP dp_cum = identity;
        int deg = G[v].size();
        dp[v] = vector<DP>(deg, identity);
        for (int i = 0; i < deg; i++) {
            int u = G[v][i].to;
            if (u == p) continue;
            dp[v][i] = dfs(u, v);
            dp_cum = merge(dp_cum, dp[v][i], G[v][i].cost);
        }
        return add_root(dp_cum);
    }
    void bfs(int v, const DP &dp_p, int p = -1) {
        int deg = G[v].size();
        for (int i = 0; i < deg; i++) {  // 前のbfsで計算した有向辺に対応する部分木のDPを保存
            if (G[v][i].to == p) dp[v][i] = dp_p;
        }

        vector<DP> dp_l(deg + 1, identity), dp_r(deg + 1, identity);  // 累積的なDP
        for (int i = 0; i < deg; i++) {
            dp_l[i + 1] = merge(dp_l[i], dp[v][i], G[v][i].cost);
        }
        for (int i = deg - 1; i >= 0; i--) {
            dp_r[i] = merge(dp_r[i + 1], dp[v][i], G[v][i].cost);
        }
        ans[v] = add_root(dp_l[deg]);
        for (int i = 0; i < deg; i++) {
            int u = G[v][i].to;
            if (u == p) continue;

            // 累積同士のmergeなので、edgeは適当に
            bfs(u, add_root(merge(dp_l[i], dp_r[i + 1], 0)), v);
        }
    }
};

int main() {
    // ll a = 3;
    // a *= 3 + 1;
    // cout << a << endl;
    // return 0;
    cin >> N >> M;
    Rerooting reroot(N);
    rep(i, N - 1) {
        ll x, y;
        cin >> x >> y;
        x--;
        y--;
        reroot.add_edge(x, y);
        reroot.add_edge(y, x);
    }
    reroot.build();

    rep(i, N) {
        cout << (reroot.ans[i].dp - 1 + M) % M << endl;
    }
}

Measured memory_bytes: 37156
//#pragma GCC optimize("Ofast")
//#pragma GCC optimize("unroll-loops")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using db = double;
using ld = long double;
template<typename T> using V = vector<T>;
template<typename T> using VV = vector<vector<T>>;
#define fs first
#define sc second
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define eb emplace_back
#define lb lower_bound
#define ub upper_bound
#define all(v) (v).begin(),(v).end()
#define siz(v) (ll)(v).size()
#define rep(i,a,n) for(ll i=a;i<(ll)(n);++i)
#define repr(i,a,n) for(ll i=n-1;(ll)a<=i;--i)
#define ENDL '\n'
typedef pair<int,int> Pi;
typedef pair<ll,ll> PL;
constexpr ll mod = 1000000007;
constexpr ll INF = 1000000099;
constexpr ll LINF = (ll)(1e18 +99);
const vector<ll> dx={-1,1,0,0},dy={0,0,-1,1};
template<typename T,typename U> inline bool chmin(T& t, const U& u){if(t>u){t=u;return 1;}return 0;}
template<typename T,typename U> inline bool chmax(T& t, const U& u){if(t<u){t=u;return 1;}return 0;}
template<typename T> inline T gcd(T a,T b){return b?gcd(b,a%b):a;}

template<typename T,typename Y> inline T mpow(T a, Y n) {
  T res = 1;
  for(;n;n>>=1) {
    if (n & 1) res = res * a;
    a = a * a;
  }
  return res;
}

template<typename T,typename Y>
ostream& operator<<(ostream& os,const pair<T,Y>& p){
   return os<<"{"<<p.fs<<","<<p.sc<<"}";
}
template<typename T> ostream& operator<<(ostream& os,const V<T>& v){
   os<<"{";
  for(auto e:v)os<<e<<",";
  return os<<"}";
}
template<typename ...Args>
void debug(Args&... args){
  for(auto const& x:{args...}){
    cerr<<x<<' ';
  }
  cerr<<ENDL;
}



signed main(){
  cin.tie(0);cerr.tie(0);ios::sync_with_stdio(false);
  cout<<fixed<<setprecision(20);
  ll a,v,b,w,t;cin>>a>>v>>b>>w>>t;
  if(abs(a-b)<=t*(v-w))cout<<"YES"<<ENDL;
  else cout<<"NO"<<ENDL;
}
//! ( . _ . ) ! 
//CHECK overflow,vector_size,what to output?

Measured memory_bytes: 3616
import java.util.*;
import java.lang.*;
import java.math.*;
import java.io.*;

import static java.lang.Math.*;
import static java.util.Arrays.*;

public class Main{

	Scanner sc=new Scanner(System.in);

	int INF=1<<28;
	double EPS=1e-9;

	void run(){
		for(;;){
			int n=sc.nextInt();
			if(n==0){
				break;
			}
			StringBuffer s=new StringBuffer(sc.next());
			for(int j=0; j<n; j++){
				StringBuffer t=new StringBuffer();
				int c=0;
				for(int i=0; i<s.length(); i++){
					c++;
					if(i==s.length()-1||s.charAt(i)!=s.charAt(i+1)){
						t.append(c);
						t.append(s.charAt(i));
						c=0;
					}
				}
				s=t;
			}
			println(s.toString());
		}
		System.out.flush();
	}

	void debug(Object... os){
		System.err.println(Arrays.deepToString(os));
	}

	void print(String s){
		System.out.print(s);
	}

	void println(String s){
		System.out.println(s);
	}

	public static void main(String[] args){
		System.setOut(new PrintStream(new BufferedOutputStream(System.out)));
		new Main().run();
	}
}

Measured memory_bytes: 12000
#include<stdio.h>

int main(void){
    int N;
    int H[100000];
    int i = 0;
    int cnt = 0;
    int mx = 0;

    scanf("%d", &N);

    for(i = 0; i < N; i++){
        scanf("%d", &H[i]);
    }

    for(i = 0; i < N-1; i++){
        if(H[i] >= H[i+1]){
            cnt++;
        }else{
            if(cnt > mx){
                mx = cnt;
            }
            cnt = 0;
        }
    }
    if(cnt > mx){
        mx = cnt;
    }

    printf("%d", mx);

    return 0;

}

Measured memory_bytes: 512
#include <set>
#include <map>
#include <queue>
#include <ctime>
#include <cmath>
#include <cstdio>
#include <vector>
#include <string>
#include <cctype>
#include <bitset>
#include <cstring>
#include <cstdlib>
#include <utility>
#include <iostream>
#include <algorithm>
#define REP(i,a,b) for(int i=(a);i<=(b);i++)
#define PER(i,a,b) for(int i=(a);i>=(b);i--)
#define RVC(i,S) for(int i=0;i<(S).size();i++)
#define RAL(i,u) for(int i=fr[u];i!=-1;i=e[i].next)
using namespace std;
typedef long long LL;
typedef pair<int,int> pii;
     
template<class T> inline
void read(T& num) {
    bool start=false,neg=false;
    char c;
    num=0;
    while((c=getchar())!=EOF) {
        if(c=='-') start=neg=true;
        else if(c>='0' && c<='9') {
            start=true;
            num=num*10+c-'0';
        } else if(start) break;
    }
    if(neg) num=-num;
}
/*============ Header Template ============*/

int main() {
    int n,cnt=0;
    read(n);
    REP(i,1,n) {
        int x;
        read(x);
        if(x&1) cnt^=1;
    }
    if(cnt&1) printf("NO\n");
    else printf("YES\n");
    return 0;
}

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

#define rep(i, N) for (ll i = 0; i < N; i++)

#define MOD 1000000007

using ll = long long;
using namespace std;

typedef pair<int,int> P;
typedef vector<int> vi;
typedef vector<P> vpi;
typedef pair<ll,ll> Pl;
typedef vector<ll> vl;
typedef vector<Pl> vpl;


int main() {
    int N, ans = 0;
    cin >> N;

    map<P,int> mp;
    rep(i, N) {
        int x = i+1;
        int low = x%10;
        while(x >= 10) x /= 10;
        int upp = x;

        mp[make_pair(upp,low)]++;
    }

    rep(i, 9) {
        rep(j, 9) {
            int u = i+1,l = j+1;
            ans += (mp[make_pair(u,l)])*(mp[make_pair(l,u)]);
        }
    }

    cout << ans << "\n";
    return 0;
}


Measured memory_bytes: 256
#include <cstdio>

char a[5],b[5];

int main()
{
	scanf("%s%s",a,b);
	int cnt=0;
	for(int i=0;i<3;i++)
	{
		if(a[i]==b[i])
			cnt++;
	}
	printf("%d\n", cnt);
	return 0;
}

Measured memory_bytes: 128
//↓template↓

#include "bits/stdc++.h"
using namespace std;
#define Would
#define you
#define all(n)  n.begin(),n.end()
const long long INF = 1e18;
const long long MOD = 1e9 + 7;
const double pi = acos(-1);
const int SIZE = 1 << 17;
int dx[] = { 1,0,-1,0 }, dy[] = { 0,1,0,-1 }, alp[30];
long long fac[200005], finv[200005], inv[200005];
vector<long long>dij;
struct edge { long long to, cost; };
vector<vector<edge> >G;

long long mod_pow(long long a, long long b) {
	long long res = 1;
	while (b) {
		if (b & 1) { res = res * a%MOD; }
		a = a * a%MOD;
		b >>= 1;
	}
	return res;
}

void addedge(int from, int to, int cost) {
	G[from].push_back({ to,cost });
	G[to].push_back({ from,cost });
}

//↑template↑

int n, k[100005], dp[100005];
int main() {
	cin >> n;
	for (int i = 0; i < n; ++i) { cin >> k[i]; }
	dp[0] = 0;
	for (int i = 1; i < n; ++i) {
		dp[i] = abs(k[i] - k[i - 1]) + dp[i - 1];
		if (i == 1) { continue; }
		dp[i] = min(dp[i], dp[i - 2] + abs(k[i] - k[i - 2]));
	}

	cout << dp[n - 1] << endl;
}

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

int d[100010];

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

	int N;
	cin >> N;
	for(int i = 0; i < N; i++) {
		int a, b;
		cin >> a >> b;
		d[a]++;
		d[b + 1]--;
	}

	int ans = 0, s = 1;
	for(int i = 1; i <= N + 1; i++) {
		s += d[i];
		if(s >= i) {
			ans = i - 1;
		}
	}
	cout << ans << endl;
}

Measured memory_bytes: 3532
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define ii pair <int, int>
#define app push_back
#define all(a) a.begin(), a.end()
#define bp __builtin_popcountll
#define ll long long
#define mp make_pair
#define f first
#define s second
#define Time (double)clock()/CLOCKS_PER_SEC

const int MOD = 1000 * 1000 * 1000 + 7, N = 1e6 + 7;
int mod(int n) {
    n %= MOD;
    if (n < 0) return n + MOD;
    else return n;
}   
int fp(int a, int p) {
    int ans = 1, c = a;
    for (int i = 0; (1ll << i) <= p; ++i) {
        if ((p >> i) & 1) ans = mod(ans * c);
        c = mod(c * c);
    }   
    return ans;
}   
int dv(int a, int b) { return mod(a * fp(b, MOD - 2)); }

int f[N], inv[N];
int C(int n, int k) {
    return mod(f[n] * mod(inv[k] * inv[n - k]));
}   
int comp(int n, int k) {
    //number of swquences with k elemeths and sum = n

    return C(n + k - 1, k - 1);
}
int get(int sum, int n) {
    //number of sequences with n elemeths and sum <= sum

    if (sum < 0)
        return 0;

    return comp(sum, n + 1);
}   

int n, m;

int get_bad(int l, int r, int R, int bad) {
    int ans = C(n, m);
    ans = mod(ans * C(n - m, bad));
    int have = m * r + bad * (l + 1);
    return mod(ans * get(R - have, n));
}

int cut(int l, int r, int R) {
    // m elemeths >= r, n - m elemenths <= l

    if (l < 0)
        return 0;
    int ans = 0;
    for (int bad = 0; bad <= n - m && bad * (l + 1) + m * r <= R; ++bad) {
        if (bad & 1) {
            ans = mod(ans - get_bad(l, r, R, bad));
        }   
        else {
            ans = mod(ans + get_bad(l, r, R, bad));
        }   
    }   
    return ans;
}   
int solve(int r) {
    int ans = 0;
    for (int i = 0; i < r; ++i) {
        ans += cut(i, i + 1, r) - cut(i - 1, i + 1, r);
    }       
    return ans;
}   

signed main() {
    #ifdef HOME
    freopen("input.txt", "r", stdin);
    #else
    #define endl '\n'
    ios_base::sync_with_stdio(0); cin.tie(0);
    #endif

    f[0] = 1;
    for (int i = 1; i < N; ++i)
        f[i] = mod(f[i - 1] * i);
    inv[N - 1] = fp(f[N - 1], MOD - 2);
    for (int i = N - 2; i >= 0; --i)
        inv[i] = mod(inv[i + 1] * (i + 1));

    int l, r;
    cin >> n >> m >> l >> r;
    int bad = mod(solve(r) - solve(l - 1));
    int all = get(r, n) - get(l - 1, n);
    cout << mod(all - bad) << endl;
}

Measured memory_bytes: 15872
#include <iostream>
#include <string>
#include <vector>
#include <deque>
#include <queue>
#include <algorithm>
#include <set>
#include <map>
#include <bitset>
#include <cmath>
#include <functional>
#define vv(a, b, c, d) vector<vector<d> >(a, vector<d>(b, c))
#define vvi vector<vector<int> >
#define vvl vector<vector<ll> >
#define vll vector<ll>
#define rep(c, a, b) for(ll c=a;c<b;c++)
#define re(c, b) for(ll c=0;c<b;c++)
#define all(obj) (obj).begin(), (obj).end()
typedef long long int ll;
typedef long double ld;
using namespace std;

int main(int argc, char const *argv[]) {
  string a, b;
  std::cin >> a;
  std::cin >> b;
  std::cout << (a.size()==b.size()?a<b?"LESS":a==b?"EQUAL":"GREATER":a.size()<b.size()?"LESS":"GREATER") << '\n';
  return 0;
}


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

int main()
{
    int n;
    cin >> n;
    vector<string> s(n);
    rep(i,n) cin >> s[i];

    int longest = 0;
    map<string, int> ansMap;
    for(string str : s)
    {
        ansMap[str] += 1;
    }
    vector <string> ans;
    for(auto data : ansMap)
    {
        if(longest < data.second) longest = data.second;
    }

    for(auto data : ansMap) if(data.second == longest) ans.emplace_back(data.first);

    rep(i,ans.size()) cout << ans[i] << endl;
}

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

using namespace std;

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

	int n;
	cin>>n;
	vector<long long>nums(n);
	map<int,int>mapp;
	long long mx=0;
	for(int i=0;i<n;++i)
	{
		cin>>nums[i];
		mx=max(nums[i],mx);
		mapp[nums[i]]++;
	}
	vector<long long>chk(mx+1);
	sort(nums.begin(),nums.end());
	long long ans=0;
	for(long long i=0;i<n;++i)
	{
		if(mapp[nums[i]]==1 && !chk[nums[i]])
			ans++;
		for(int j=nums[i];j<=mx;j+=nums[i])
		{
			chk[j]++;
		}
	}
	cout<<ans;
}


Measured memory_bytes: 21924
N = int(input())
h = list(map(int, input().split()))
f = [0] * N

ans = 0
mh = max(h)
for i in range(1, mh+1):
    f = False
    for j in range(N):
        if i <= h[j]:
            if f is True:
                continue
            else:
                f = True
                ans += 1
        else:
            f = False

print(ans)

Measured memory_bytes: 3064
from bisect import bisect_left as bl

n, m, q = map(int, input().split())
lst = [i for i in range(n)]
alst = list(map(int, input().split()))
ind = 0
for a in alst:
  if a % 2 == 0:
    ind += a
  else:
    ind -= a
  ind = ind % len(lst)
  lst.pop(ind)
  ind = ind % len(lst)

qlst = list(map(int, input().split()))
for q in qlst:
  qi = bl(lst, q)
  if qi >= len(lst):
    print(0)
  else:
    print(int(lst[qi] == q))


Measured memory_bytes: 29024
using System;
using static System.Console;
using static System.Math;

public class Hello{
    public static void Main(){
        string[] word = ReadLine().Split(' ');
        int moto = int.Parse(word[0]);
        int waru = int.Parse(word[1]);
        int amari = int.Parse(word[2]);
        int a = 0;
        for(int i=1;i<=100;i++){
            int motoi = moto*i;
            if(motoi%waru == amari){
                a++;
            }
        }
        if(a>0){
            WriteLine("YES");
        }else{
            WriteLine("NO");
        }
    }
}

Measured memory_bytes: 11092
import sys
input = lambda : sys.stdin.readline().rstrip()
sys.setrecursionlimit(max(1000, 10**9))
write = lambda x: sys.stdout.write(x+"\n")


l = list(map(int, input().split()))
l.sort()
a,b,c = l
ans = 0
while True:
    if a%2 or b%2 or c%2:
        break
    if a==b==c:
        ans = -1
        break
    a,b,c = b//2+c//2, a//2+c//2, a//2+b//2
    ans += 1
print(ans)

Measured memory_bytes: 61916
H,W,M = gets.chomp.split(" ").map(&:to_i)
hash = Hash.new(0)
tate = Array.new(W+1,0)
yoko = Array.new(H+1,0)
h = Array.new(M+1)
w = Array.new(M+1)
M.times do |i|
  h[i],w[i] = gets.chomp.split(" ").map(&:to_i)
  hash[[h[i],w[i]]] = 1
  tate[w[i]] += 1
  yoko[h[i]] += 1
end
max_tate = tate.max
max_yoko = yoko.max
tate_h = Hash.new(0)
yoko_h = Hash.new(0)
(W+1).times do |i|
  if tate[i] == max_tate
    tate_h[i] = max_tate
  end
end
(H+1).times do |i|
  if yoko[i] == max_yoko
    yoko_h[i] = max_yoko
  end
end
tate_h.each_key do |k|
  yoko_h.each_key do |k2|
    if hash[[k2,k]] == 0
      puts max_tate + max_yoko
      exit
    end
  end
end
puts max_tate + max_yoko - 1

Measured memory_bytes: 89968
import scala.io.StdIn._
object Main {
  def main(args:Array[String]) {
    val X = readLine().toLong

    var ansA = 0
    var ansB = 0
    for(A <- -118 to 119; B <- -119 to 118) {
      if(Math.pow(A, 5) - Math.pow(B, 5) == X) {
        ansA = A
        ansB = B
      }
    }
    println(ansA + " " + ansB)
  }
}


Measured memory_bytes: 54732
#include<bits/stdc++.h>
#include<iostream>
#include<cstdio>
#include<vector>
#include<string>
#include<algorithm>
#include<map>
using namespace std;
#define rep(i,x) for(ll i = 0; i < (ll)(x); i++)
#define pb push_back
#define eb emplace_back
#define debug(x) cerr << #x << ": " << (x) << "\n";
#define all(x) (x).begin(), (x).end()
typedef long long ll;
typedef long double ld;
typedef pair<int,int> P;
typedef pair<ll,ll> Pll;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
typedef vector<vector<vector<ll>>> vvvl;
const ll INF = numeric_limits<ll>::max()/4;
const ll MOD = 1e9+7;
const int n_max = 1e5+10;

int main(){
    ll n; cin >> n;
    string s;cin >> s;
    reverse(s.begin(), s.begin() + n);
    // debug(s);
    using Ps = pair<string,string>;
    map<Ps, ll> mp;
    rep(i,(1LL << n)){
        string temp, rest;
        rep(j,n){
            if((i >> j) & 1){
                temp += s[j];
            }
            else{
                rest += s[j];
            }
        }
        // debug(temp);debug(rest);
        mp[{temp, rest}]++;
    }
    ll ans = 0;
    rep(i, 1LL << n){
        string temp, rest;
        rep(j,n){
            if((i >> j) & 1)temp += s[n+j];
            else rest += s[n+j];
        }
        if(mp.find({temp, rest}) != mp.end()){
            ans += mp[{temp, rest}];
            // debug(temp);debug(rest);
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 46080
//----------BHAVIK DIWANI(PICT_COMP)---------------
#include<bits/stdc++.h>
#include<stdlib.h>
#include<stdio.h>
#define test ll t; cin>>t; while(t--)
#define FOR(p,n) for(ll i=p;i<(ll)n;i++)
#define fastio ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define mod 1000000007
#define ll long long
#define int long long
#define ull unsigned long long
#define MAX 1000005
#define pb push_back
#define mkp make_pair
#define vi vector<int>
#define pii pair<int,int>
#define endl '\n'
#define vs vector<string>
#define mii map<int,int>
#define msi map<string,int>
#define vpii vector< pair<int, int > >
#define vpsi vector< pair< string ,int > >
#define forci(p,q) for(int i=p;i<q;i++)
ll gcd(ll a,ll b){ if(b==0) return a;    return gcd(b,a%b);}
ll lcm(ll a,ll b) { return (a/gcd(a,b)*b);}
ull power(ull a, ull b) {a %= mod;  ull res = 1;  while (b > 0) { if (b & 1) res = res * a % mod;  a = a * a % mod;  b >>= 1; }  return res%mod; }
ll modmul(ll x, ll y){return (x*y)%mod;}
ll modadd(ll x, ll y){return (x+y)%mod;}
ll modsub(ll x, ll y){return (x-y+mod)%mod;}
ll fact[1000007]={0};
void facto() {fact[0]=1;fact[1]=1;for(int i=2;i<100007;i++)fact[i]=(fact[i-1]*i)%mod;}
ll ncr(ll n,ll r) {ll res=1; res=fact[n]; res=(res*(power(fact[r],mod-2)))%mod; res=(res*(power(fact[n-r],mod-2)))%mod; return res;}
ll npr(ll n,ll r) {ll res=1; res=fact[n]; res=(res*(power(fact[n-r],mod-2)))%mod; return res;}
inline long long toint(const std::string &s) {std::stringstream ss; ss << s; long long x; ss >> x; return x;}
inline std::string tostring(long long number) {std::stringstream ss; ss << number; return ss.str();}
inline std::string tobin(long long x) {return std::bitset<63>(x).to_string();}
/*bool prime[MAX];
ull sieve(){memset(prime,true,sizeof(prime));for(ull p=2;p*p<MAX;p++){if(prime[p]==true){for(ull i=2*p;i<MAX;i+=p){prime[i]=false;}}}prime[0]=0;prime[1]=0;
}
int inv[1000001]={0};
void findinverse(){inv[1] = 1;for(int i = 2; i <=1e6 ; ++i)	inv[i] = (mod - (mod/i) * inv[mod%i] % mod) % mod;}
*/
using namespace std;
int solve()
{
	int n;
	cin>>n;
	for(int i=1;i<=9;i++){
		for(int j=1;j<=9;j++)
		{
			if(i*j==n)
			{
				cout<<"Yes";
				return 0;
			}
		}
	}
	cout<<"No";

}
signed main()
{
	fastio;
//	test
		solve();
}

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

typedef long long ll;
const int N_MAX = 50;
ll X[N_MAX];
ll Y[N_MAX];

int count_point(ll x1, ll y1, ll x2, ll y2, int n) {
  int count = 0;
  for (int i = 0; i < n; i++) {
    if (x1 <= X[i] && x2 >= X[i] &&
	y1 <= Y[i] && y2 >= Y[i]) {
      count++;
    }
  }
  return count;
}

ll solve(int N, int K) {
  ll ans = LLONG_MAX;
  for (int i = 0; i < N; i++) {
    for (int j = i+1; j < N; j++) {
      ll x1 = min(X[i], X[j]);
      ll x2 = max(X[i], X[j]);

      for (int k = 0; k < N; k++) {
	for (int l = k+1; l < N; l++) {
	  ll y1 = min(Y[k], Y[l]);
	  ll y2 = max(Y[k], Y[l]);

	  int c = count_point(x1, y1, x2, y2, N);
	  if (c >= K) {
	    ans = min(ans, (x2-x1)*(y2-y1));
	  }
	}
      }
    }
  }
  return ans;
}

int main() {
  int N, K;
  cin >> N >> K;
  for (int i = 0; i < N; i++) {
    cin >> X[i] >> Y[i];
  }
  cout << solve(N, K) << endl;
}

Measured memory_bytes: 888
#include<bits/stdc++.h>
#define endl '\n'
#define INF (1 << 21)
const int MOD = 1000000009;
using namespace std;
int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  int n;
  int p[25];
  int ans = 0;

  cin >> n;

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

  for(int i = 0;i < n - 2;i++){
    if(p[i] > p[i + 1] && p[i + 1] > p[i + 2] || p[i] < p[i + 1] && p[i + 1] < p[i + 2]){
      ans ++;
    }
  }

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




Measured memory_bytes: 256
import java.util.InputMismatchException;
import java.util.Scanner;

public class Main{


	public static void main(String[] args){

    	Scanner scan = new Scanner(System.in);

			while(true){
				try{
            int H=scan.nextInt();
			int W=scan.nextInt();
			if(H==0&&W==0)break;

			for(int i=0;i<H;i++){
				for(int j=0;j<W;j++){
					System.out.print('#');
				}System.out.print('\n');
			  }System.out.print('\n');

				}catch(InputMismatchException e){
					System.out.println("??¨??????:"+e);

				}

			}
        	scan.close();


	}

}

Measured memory_bytes: 39216
import java.util.Scanner;
public class Main {
	public static void main(String args[]) {
		Scanner n = new Scanner(System.in);

		int K = n.nextInt();
		int N = n.nextInt();

		int[] intArray;
		intArray = new int[N];
		for(int i=0 ; i<N ; i++) {
			int A = n.nextInt();
			intArray[i] = A;
		}

		int dis = 0;
		int longDis = intArray[0] + (K - intArray[N-1]) ;

		for(int i=0 ; i<N-1 ; i++) {
			dis = intArray[i+1] - intArray[i];

			if(dis >= longDis) {
				longDis = dis;
			}
		}

		System.out.println(K - longDis);
	}
}


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

priority_queue<int, vector<int>, greater<int>> coletado;
multiset<int> valores; 
int N, M, impossivel;

int main(){

	scanf("%d", &M);
	N = (1 << M);
	for(int i = 1;i<=N;i++){
		int x;
		scanf("%d", &x);
		valores.insert(x);
	}

	coletado.push(*prev(valores.end()));
	valores.erase(prev(valores.end()));


	while(!valores.empty()){

		queue<int> fila;

		while(!coletado.empty()){
			int v = coletado.top();
			coletado.pop();
			multiset<int>::iterator it = valores.lower_bound(v);
			if(it == valores.begin()){
				impossivel = 1;
				break;
			}
			it = prev(it);
			fila.push(*it);
			valores.erase(it);
			fila.push(v);
		}

		if(impossivel) break;

		while(!fila.empty()){
			int v = fila.front();
			fila.pop();
			coletado.push(v);
		}

	}

	if(impossivel) printf("No\n");
	else printf("Yes\n");

	return 0;

}

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

public class Main {

  Scanner sc;

  Main() {
    sc = new Scanner(System.in);
  }

  int ni() {
    return sc.nextInt();
  }

  public static void main(String[] args) {
    new Main().run();
  }

  void run() {
    for(;;) {
      int n = ni();
      if(n ==0) {
        break;
      }
      int cnt = 0;
      for (int i = n + 1; i <= n * 2; ++i) {
        boolean flag = true;
        for (int j = 2; flag && j * j <= i; ++j) {
          flag &= i % j != 0;
        }
        if (flag) {
          ++cnt;
        }
      }
      System.out.println(cnt);
    }
  }

  void debug(Object... os) {
    System.err.println(Arrays.deepToString(os));
  }
}

Measured memory_bytes: 27228
S = input()
N = len(S)
A = (N-1) //2
B = (N+3) //2
S1 = S[0:A]
S2 = S[B-1:]
if S == S[::-1] and S1 == S1[::-1] and S2 == S2[::-1]:
  print("Yes")
else:
  print("No")

Measured memory_bytes: 3064
#include <iostream>
#include <vector>
#include <string>
//#include "./libb/lib.hpp"

using namespace std;

int main()
{
    uint32_t kk;
    uint32_t aa;
    uint32_t bb;
    cin >> kk >> aa >> bb;

    for(uint32_t i = aa; i <= bb; i++){
        if((i % kk) == 0){
            cout << "OK" << endl;
            return 0;
        }
    }

    cout << "NG" << endl;
    return 0;
}

Measured memory_bytes: 3636
#include <stdio.h>
struct dice{
    int d[6], tmp[6];
};
struct dice dice1;
void init(int n[6]){
	int i;
    for (i=0;i<6;i++){
        dice1.d[i]=n[i];
    }
}
void throwdice(char c){
	int i;
    for(i=0;i<6;i++){
        dice1.tmp[i]=dice1.d[i];
    }
    if(c=='N'){
        dice1.d[0]=dice1.tmp[1];
        dice1.d[1]=dice1.tmp[5];
        dice1.d[2]=dice1.tmp[2];
        dice1.d[3]=dice1.tmp[3];
        dice1.d[4]=dice1.tmp[0];
        dice1.d[5]=dice1.tmp[4];
    }
    else if(c=='E'){
        dice1.d[0]=dice1.tmp[3];
        dice1.d[1]=dice1.tmp[1];
        dice1.d[2]=dice1.tmp[0];
        dice1.d[3]=dice1.tmp[5];
        dice1.d[4]=dice1.tmp[4];
        dice1.d[5]=dice1.tmp[2];
    }
    else if(c=='W'){
        dice1.d[0]=dice1.tmp[2];
        dice1.d[1]=dice1.tmp[1];
        dice1.d[2]=dice1.tmp[5];
        dice1.d[3]=dice1.tmp[0];
        dice1.d[4]=dice1.tmp[4];
        dice1.d[5]=dice1.tmp[3];
    }
    else if(c=='S'){
        dice1.d[0]=dice1.tmp[4];
        dice1.d[1]=dice1.tmp[0];
        dice1.d[2]=dice1.tmp[2];
        dice1.d[3]=dice1.tmp[3];
        dice1.d[4]=dice1.tmp[5];
        dice1.d[5]=dice1.tmp[1];
    }
    else if(c=='R'){
        dice1.d[0]=dice1.tmp[0];
        dice1.d[1]=dice1.tmp[3];
        dice1.d[2]=dice1.tmp[1];
        dice1.d[3]=dice1.tmp[4];
        dice1.d[4]=dice1.tmp[2];
        dice1.d[5]=dice1.tmp[5];
    }
}
int main()
{
    int q;
    int n[6];
    int i,j;
    char t[110];
    int ts;
    for(i=0;i<6;i++){
       	scanf("%d",&n[i]);
    }
    init(n);
    scanf("%s",&t);
    ts=strlen(t);
    for(i=0;i<ts;i++){
    	throwdice(t[i]);	
    }
    printf("%d\n",dice1.d[0]);
    return 0;
}

Measured memory_bytes: 596
sx,sy,tx,ty=map(int,input().split())
ts_x=tx-sx
ts_y=ty-sy

answer_list=[]
#s->t
for i in range(ts_y):
  answer_list.append("U")
for i in range(ts_x):
  answer_list.append("R")
  
#t->s
for i in range(ts_y):
  answer_list.append("D")
for i in range(ts_x):
  answer_list.append("L")
  
#s->t
answer_list.append("L")
for i in range(ts_y+1):
  answer_list.append("U")
for i in range(ts_x+1):
  answer_list.append("R")
answer_list.append("D")

#t->s
answer_list.append("R")
for i in range(ts_y+1):
  answer_list.append("D")
for i in range(ts_x+1):
  answer_list.append("L")
answer_list.append("U")

print("".join(answer_list))

Measured memory_bytes: 3188
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <cmath>
#include <queue>
#include <stack>
#include <cstdlib>
#include <map>
#include <iomanip>
#include <set>
using namespace std;
#define pie 3.141592653589793238462643383279
#define mod 1000000007
#define INF 1145141919364364
#define int long long
#define all(vec) vec.begin(),vec.end()
#define P pair<int,int>
#define S second
#define F first
int gcd(int x, int y) {
	if (y == 0)return x;
	return gcd(y, x%y);
}
int lcm(int x, int y) {
	return x / gcd(x, y)*y;
}
bool prime(int x) {
	for (int i = 2; i <= sqrt(x); i++) {
		if (x%i == 0)return false;
	}
	return true;
}
int kai(int x, int y) {
	int res = 1;
	for (int i = x - y + 1; i <= x; i++) {
		res *= i; res %= mod;
	}
	return res;
}
int mod_pow(int x, int y, int m) {
	int res = 1;
	while (y > 0) {
		if (y & 1) {
			res = res * x % m;
		}
		x = x * x % m;
		y >>= 1;
	}
	return res;
}
int comb(int x, int y) {
	if (y > x)return 0;
	return kai(x, y) * mod_pow(kai(y, y), mod - 2, mod) % mod;
}

int n;
string s;

signed main() {
	cin >> n >> s;
	for (int i = 0; i < (int)s.size(); i++) {
		s[i] = s[i] + n;
		if ('Z' < s[i])s[i] -= 26;
	}
	cout << s << endl;
}

Measured memory_bytes: 256
/******************************************
* NICK : nikhilsinghh59 *
******************************************/
#include<bits/stdc++.h>
using namespace std;
#define ll long long int 
#define watch(x) cout << (#x) << " is " << (x) << endl
#define endl "\n"

#define PB push_back
#define F first
#define S second
#define all(c) (c).begin(),(c).end()
const int M = 1e9+7;

ll ans=INT_MAX;

bool check(vector<ll>v , ll x) {
    for(ll i=1;i<v.size();i++){
        if(v[i] < x) {
            return false;
        }
    }
    return true;
}

void rec(vector<vector<ll>>&arr , vector<ll>v , ll ind , ll x , ll cost) {
    if(check(v , x)) {
        ans = min(ans , cost);
        return;
    }
    if(ind == arr.size()) {
        return ;
    }

    rec(arr , v,  ind+1 , x , cost);
    for(ll i=1;i<arr[0].size() ; i++) {
        v[i]+=arr[ind][i];
    }
    rec(arr , v , ind+1 , x , cost+arr[ind][0]);
}

int main()
{   
    

    ll n , m , x;
    cin >> n >> m >> x;

    //ll ar[n][m+1];
    vector<vector<ll> >ar(n , vector<ll>(m+1));
    for(ll i=0;i<n;i++){
        for(ll j=0;j<=m;j++){
            cin >> ar[i][j];
        }
    }

    vector<ll>v(m+1 , 0);

    rec(ar , v , 0 , x , 0);

    ans = ((ans==INT_MAX)? -1 : ans);
    cout << ans;
    
    return 0;
}

Measured memory_bytes: 3632
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
ll x, y, a, b, c, res, w, q, t;
int main()
{
	cin >> a >> b >> c >> x >> y;
	c *= 2;
	w = (min(x, y));
	q = (y - w)*b + (x - w)*a + w*c;
	w = x*a + y*b;
	t = max(x , y)*c;
	w = min(w, t);
	//cout << q << " " << w << endl;
	res = min(w, q);
	cout << res << endl;
	return 0;
}

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

using namespace std;
using lli = int_fast64_t;
using ulli = uint_fast64_t;
#define debug(x) cerr << #x << " : " << x << endl
#define debugv(x) cerr << #x << " : {";for(auto value_of_x:x){ cerr << value_of_x << ", ";}cerr << endl
#define debugst(x) auto xt = x;cerr << #x << " : {";for(int i=0;i<x.size();i++){ cerr << xt.top() << ", ";xt.pop();}cerr << endl
#define debugvp(x) cerr << #x << " : {";for(auto value_of_x:x){ cerr << value_of_x.first << " : " << value_of_x.second << ", ";}cerr << endl

constexpr lli MOD = (lli)1e9 + 7;
constexpr lli LIMIT = 1000000000000000000 * 5;
constexpr int tenfive = 100000;

int main() {
	string s,r;
	cin >> s;
	r = s;
	reverse(r.begin(), r.end());
	int ans = 0;
	for (int i = 0; i < s.size()/2; i++) {
		if (s[i] != r[i]) {
			ans++;
		}
	}

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


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main() {
  //入力
  int h, w;
  cin >> h >> w;
  //一つの文字列に
  string s; 
  for(int i = 0; i < h; i++) {
    string f;
    cin >> f;
    s += f;
  }
  //数えて出力 s.at(i*w+j)が基本
  for(int i = 0; i < h; i++) {
    for(int j = 0; j < w; j++) {
      int count = 0;
      if(s.at(i*w+j) == '#') {
        cout << '#';
        if(j == w-1) cout << endl;
        continue;
      }
      if(i!=0   && j!=0   && s.at((i-1)*w+j-1)=='#') count++;
      if(i!=0   &&           s.at((i-1)*w+j)  =='#') count++;
      if(i!=0   && j!=w-1 && s.at((i-1)*w+j+1)=='#') count++;
      if(          j!=0   && s.at( i   *w+j-1)=='#') count++;
      if(          j!=w-1 && s.at( i   *w+j+1)=='#') count++;
      if(i!=h-1 && j!=0   && s.at((i+1)*w+j-1)=='#') count++;
      if(i!=h-1 &&           s.at((i+1)*w+j)  =='#') count++;
      if(i!=h-1 && j!=w-1 && s.at((i+1)*w+j+1)=='#') count++;
      cout << count;
      if(j == w-1) cout << endl;
    }
  }
}

Measured memory_bytes: 256
{-# OPTIONS_GHC -O2 -optc-O2 #-}
module Main where

import Control.Applicative
import Data.Int
import Data.List
import qualified Data.ByteString.Lazy.Char8 as L

data Test = Test Int [Int64]

slidingSums :: Int -> [Int64] -> [Int64]
slidingSums k as = zipWith (-) (drop k ps) ps
    where ps = scanl (+) 0 as

prefixPositiveSums, suffixPositiveSums :: [Int64] -> [Int64]
prefixPositiveSums = scanl (\x y -> if y >= 0 then x + y else x) 0
suffixPositiveSums = scanr (\x y -> if x >= 0 then x + y else y) 0

solve :: Test -> Int64
solve (Test k as) = maximum $ zipWith3 add ss pps (drop k sps)
    where ss = map (max 0) $ slidingSums k as
          pps = prefixPositiveSums as
          sps = suffixPositiveSums as
          add x y z = x + y + z

test0 = Test 3 [-10, 10, -10, 10, -10]
test1 = Test 2 [10, -10, -10, 10]
test2 = Test 1 [-10]
test3 = Test 5 [5, -4, -5, -8, -4, 7, 2, -4, 0, 7]
runTests = map solve [test0, test1, test2, test3]

readInt :: L.ByteString -> Int
readInt s = case L.readInt s of
              Just (x, _) -> x
              _           -> error $ "Can't parse: " ++ (show s)

main :: IO ()
main = do
  (_:k:as) <- map readInt . L.words <$> L.getContents
  print . solve $ Test k (map fromIntegral as)


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

int main(){
	int n, m; cin >> n >> m;
	vector<pair<int, int>> ab;
	multiset<int> t;
	for (int i = 0; i < n; i++) {
		int a, b; cin >> a >> b;
		ab.push_back(make_pair(a, b));
	}
	sort(ab.rbegin(), ab.rend());
	int ans = 0;
	for (int i = m; i >= 0; i--) {
		while (ab.size() != 0) {
			if (i + ab.back().first > m) break;
			t.insert(ab.back().second);
			ab.pop_back();
		}
		if (t.size() != 0) {
			ans += *t.rbegin();
			t.erase(--t.end());
		}
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 5620
N = int(input())
A = []
for _ in range(N):
    A.append(int(input()))

visited = set([])
cur = 0
ok = False

while True:
    if not (cur in visited):
        visited.add(cur)
    else:
        break
    cur = A[cur] - 1
    if cur == 1:
        ok = True
        break
if ok:
    print(len(visited))
else:
    print(-1)

Measured memory_bytes: 93744
#include <iostream>
#include <stdlib.h>
#include <utility>
#include <math.h>
#include <stdexcept>
#include <algorithm>
#include <vector>
#include <stdio.h>
#define   FOR(i,n) for(int i=0;i<n;i++)

using namespace std;
int int_sort(const void*a,const void *b) {
	return *(  int *) b - *(int *) a;
	//qsort(b, a, sizeof(long long int), int_sort);
}

int main() {
	int a,b;
	vector<int>A(1000000,0);
	cin>>a;

		cout<<48-a;
		return 0;
	


}


Measured memory_bytes: 4096
// This amazing code is by Eric Sunli Chen.
#include <algorithm>
#include <bitset>
#include <cmath>
#include <cstring>
#include <cstdio>
#include <cstdlib>
#include <ctime>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <utility>
#include <vector>
using namespace std;
template<typename T> void get_int(T &x)
{
	char t=getchar();
	bool neg=false;
	x=0;
	for(; (t>'9'||t<'0')&&t!='-'; t=getchar());
	if(t=='-')neg=true,t=getchar();
	for(; t<='9'&&t>='0'; t=getchar())x=x*10+t-'0';
	if(neg)x=-x;
}
template<typename T> void print_int(T x)
{
	if(x<0)putchar('-'),x=-x;
	short a[20]= {},sz=0;
	while(x>0)a[sz++]=x%10,x/=10;
	if(sz==0)putchar('0');
	for(int i=sz-1; i>=0; i--)putchar('0'+a[i]);
}
#define ff first
#define ss second
#define pb push_back
#define mp make_pair
#define get1(a) get_int(a)
#define get2(a,b) get1(a),get1(b)
#define get3(a,b,c) get1(a),get2(b,c)
#define printendl(a) print_int(a),puts("")
typedef long long LL;
typedef unsigned long long uLL;
typedef pair<int,int> pii;
const int inf=0x3f3f3f3f;
const LL Linf=1ll<<61;
const double pi=acos(-1.0);

int n,len[1111],ok[1111],mn[1111][1111];
map<int,int> tt[1111][1111];
char tmp[5];
int dfs(int l,int r,int up)
{
	if(l>r)return 0;
	if(tt[l][r].find(up)!=tt[l][r].end())return tt[l][r][up];
	int mx=0,tot=0,cnt=0;
	for(int i=l;i<=r;i++)
	{
		if(!ok[i])
		{
			if(mx==0||len[mx]<len[i])mx=i;
			if(cnt)
			{
				tot++;
				cnt=0;
			}
		}
		else if(ok[i]&&len[i]<=up)cnt++;
	}
	if(cnt)tot++;
	if(tot==0)return tt[l][r][up]=0;
	if(mx==0)return tt[l][r][up]=tot;
//	printf("%d %d %d tot= %d mx= %d\n",l,r,up,tot);
	return tt[l][r][up]=min(dfs(l,mx-1,len[mx])+dfs(mx+1,r,len[mx])+1,min(dfs(l,mx-1,up)+dfs(mx+1,r,up),tot));
}
int main()
{
	get1(n);
	for(int i=1;i<=n;i++)
	{
		scanf("%s%d",tmp,len+i);
		if(tmp[0]=='y')ok[i]=1;
	}
	printendl(dfs(1,n,inf));
	return 0;
}

Measured memory_bytes: 61408
#include <iostream>
#include <stdint.h>
#include <limits.h>
#include <utility>
#include <map>

using namespace std;
 
int main()
{
  unsigned N, M;
  cin >> N >> M;
 
  multimap<unsigned,unsigned> A;
 
  for (unsigned n=0; n<N; ++n) {
    unsigned a;
    cin >> a;
    A.emplace(make_pair(a,1));
  }

  for (unsigned m=0; m<M; ++m) {
    unsigned B, C;
    cin >> B >> C;
    A.emplace(make_pair(C,B));
  }
 
  uint64_t sum = 0;
  unsigned count = 0;
  for (auto itr=A.rbegin(); itr!=A.rend() && count<N; ++itr) {
    sum += (uint64_t)itr->first * min(N-count, itr->second);
    count += itr->second;
  }
 
  cout << sum << endl;
  
  return 0;
}

Measured memory_bytes: 9600
K = int(input())
if K % 2 == 0:
    print(-1)
elif K % 5 == 0:
    print(-1)
else:
    S = 7
    for i in range(K+1):
        if S % K == 0:
            print(i+1)
            break
        else:
            S = S % K
            S = S * 10 + 7
    else:
        print(-1)


Measured memory_bytes: 9044
#include<iostream>
#include<cstdio>
#include<ctime>


//math
//------------------------
template<class T>inline T sqr(T x){ return x*x; };



int x;


int solve(int x){
	return sqr(x)*x;
}






int main(){
	std::clock_t start = clock();
	std::cin >> x;
	printf("%d\n",solve(x));
	//printf("time is %d",(clock()-static_cast<double>(start)/CLOCKS_PER_SEC));
}

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

#define REP(i, n) for(int (i)=0;(i)<(n);++(i))
#define REPV(iter, v) for(auto (iter)=(v).begin(); (iter)!=(v).end();++(iter))
#define ALL(v) (v).begin(),(v).end()

#define MOD 1000000007

using namespace std;

typedef long long ll;

int main()
{
    ll N;
    cin >> N;
    vector<ll> A(N), B(N);
    REP(i, N)
    {
        cin >> A[i] >> B[i];
    }
    sort(ALL(A));
    sort(ALL(B));

    ll ans;
    if (N % 2 == 1)
    {
        ll medianA, medianB;
        medianA = A[N / 2];
        medianB = B[N / 2];
        ans = medianB - medianA + 1;
    }
    else
    {
        ll doubleMedianA, doubleMedianB;
        doubleMedianA = A[N / 2 - 1] + A[N / 2];
        doubleMedianB = B[N / 2 - 1] + B[N / 2];
        ans = doubleMedianB - doubleMedianA + 1;
    }

    cout << ans << endl;
}


Measured memory_bytes: 6424
import math

A, B, N = map(int, input().split())

# if A % B == 0:
#     print(  min ( (A//B - 1) *B,A//B * N )

cands = []
temp = math.floor(A * N // B) - A * math.floor(N // B)
cands.append(temp)
if B <= N + 1 and B - 1 > 0:
    temp = math.floor(A * (B - 1) // B) - A * math.floor((B - 1) // B)
    cands.append(temp)
print(max(cands))

#
# cand = A * N //B
# cand2 = cand - 1
# ma = 0
# for x in range(1,N + 1):
#     temp = math.floor(A * x / B) - A * math.floor(x / B)
#     ma = max(temp,ma)
#     # print(math.floor(A * x / B),A * math.floor(x / B),x,temp)
# print(ma)

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

int main(){
	int dif,check=0;
	int array[3][3];
	for(int i=0;i<3;i++){
		for(int j=0;j<3;j++)cin >>array[i][j];
		if(i>=1){
			dif=array[i][0]-array[0][0];
			for(int k=0;k<3;k++){
				if(dif!=array[i][k]-array[0][k])check=1;
			}
		}
	}
	if(check==1)cout<<"No"<<endl;
	else cout<<"Yes"<<endl;
	return 0;

}

Measured memory_bytes: 256