akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<cstdio>
#include<vector>
#include<map>
#include<string>
#include<algorithm>
#include<math.h>
#include<numeric>
#include<iomanip>

using namespace std;

typedef vector<int> vi;
typedef pair<int, int> pii;
typedef long long ll;
typedef vector<long long> vll;
typedef pair<long long, long long> pll;

const ll INF = 1e9;
const ll MOD = 1e9 + 7;

int dp[11][100000];
vector<vll> E;

void func(ll d, ll v, ll x){
	dp[d][v] = x;
	if (d == 0){
		return;
	}
	vll v_list = E[v];
	v_list.push_back(v);
	for (ll i = 0; i < v_list.size(); i++){
		if (dp[d - 1][v_list[i]] == 0){
			func(d - 1, v_list[i], x);
		}
	}
}

int main(){
	ll N, M, Q;
	vll A, B, C, D, V;
	cin >> N >> M;
	ll i, j, k;
	for (i = 0; i < M; i++){
		ll a, b;
		cin >> a >> b;
		A.push_back(a - 1);
		B.push_back(b - 1);
	}
	cin >> Q;
	for (i = 0; i < Q; i++){
		ll v, d, c;
		cin >> v >> d >> c;
		V.push_back(v - 1);
		D.push_back(d);
		C.push_back(c);
	}

	E.resize(N);
	for (i = 0; i < M; i++){
		E[A[i]].push_back(B[i]);
		E[B[i]].push_back(A[i]);
	}

	for (i = 0; i <= 10; i++){
		for (j = 0; j < N; j++){
			dp[i][j] = 0;
		}
	}

	for (i = Q - 1; i >= 0; i--){
		if (dp[D[i]][V[i]] == 0){
			func(D[i], V[i], i + 1);
		}
	}

	for (i = 0; i < N; i++){
		if (dp[0][i] == 0){
			cout << 0 << endl;
		}
		else{
			cout << C[dp[0][i] - 1] << endl;
		}
	}
}

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

typedef long long int64;

const int MAX_N = 110;

int n, k, m, len[MAX_N];
char s[MAX_N], t[MAX_N];

int main() {
	scanf("%s%d", s + 1, &k);
	n = strlen(s + 1);

	int64 ans = 0LL;
	for (int i = 1; i <= n; ++i) {
		if (s[i] == t[m]) {
			++len[m];
		} else {
			t[++m] = s[i];
			len[m] = 1;
		}
	}
	
	if (m == 1)
		ans = 1LL * n * k / 2;
	else if (t[m] == t[1]) {
		ans = len[1] / 2 + len[m] / 2;
		ans += 1LL * (len[1] + len[m]) / 2 * (k - 1);
		for (int i = 2; i < m; ++i) {
			ans += 1LL * len[i] / 2 * k;
		}
	} else {
		for (int i = 1; i <= m; ++i) {
			ans += 1LL * len[i] / 2 * k;
		}
	}
	
	std::cout << ans << std::endl;
}

Measured memory_bytes: 3776
#include<cstdio>
#include<cstring>
#include<cstdlib>
#include<vector>
using namespace std;
int main(void){
	long long a[100000];
	int b[100000];
	int n;
	int m;
	int x;
	int y;
	int z;
	long long c;
	int s;
	int k;

	scanf("%d %d", &n,&x);
	for (int i = 0; i < n; i++){
		scanf("%lld", &a[i]);
	}
	for (int i = 0; i < n-1; i++){
		if (a[i] > x){
			c = c + a[i] - x;
			a[i] = x;
		}
		if (a[i] + a[i + 1]>x){
			c = c + a[i]+a[i + 1] - x;
			a[i + 1] = x - a[i];
		}
	}

	printf("%lld\n", c);

	return 0;
}

Measured memory_bytes: 896
#include <bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define rrep(i, n) for(int i = 1; i <= (int)(n); i++)
#define drep(i, n) for(int i = (n)-1; i >= 0; i--)
#define ALL(x) (x).begin(), (x).end()
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
const ll LINF = 1001002003004005006ll;
const int INF = 1001001001;
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; }

// Mod int
const int mod = 1000000007;
// const int mod = 998244353;
struct mint {
  ll x;
  mint():x(0){}
  mint(ll x):x((x%mod+mod)%mod){}
  // mint(ll x):x(x){}
  mint& fix() { x = (x%mod+mod)%mod; return *this;}
  mint operator-() const { return mint(0) - *this;}
  mint& operator+=(const mint& a){ if((x+=a.x)>=mod) x-=mod; return *this;}
  mint& operator-=(const mint& a){ if((x+=mod-a.x)>=mod) x-=mod; return *this;}
  mint& operator*=(const mint& a){ (x*=a.x)%=mod; return *this;}
  mint operator+(const mint& a)const{ return mint(*this) += a;}
  mint operator-(const mint& a)const{ return mint(*this) -= a;}
  mint operator*(const mint& a)const{ return mint(*this) *= a;}
  bool operator<(const mint& a)const{ return x < a.x;}
  bool operator==(const mint& a)const{ return x == a.x;}
};
istream& operator>>(istream&i,mint&a){i>>a.x;return i;}
ostream& operator<<(ostream&o,const mint&a){o<<a.x;return o;}
//



int main() {
  int h, w, a, b;
  cin >> h >> w >> a >> b;
  rep(i, h) {
    rep(j, w) {
      if ((i<b && j<a) || (i>=b && j>=a)) cout << 1;
      else cout << 0;
    }
    cout << endl;
  }
}

Measured memory_bytes: 3584
/**
*    created: 17.05.2020 12:32:42
**/

#include <bits/stdc++.h>
using namespace std;
using ll=long long;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
const int inf =1000000000;
//ダブリング？
//漸化式的な感じか,dp?むずそう
//RL隣り合っているところ見つけていって逆算か
int main() {
    string s;
    cin >> s;
    int n = s.size();
    vector<int> a;
    //a[i]=j:(s[j],s[j+1])=(L,R),(R,L)
    //i%2==1:(L,R),else:(R,L)
    rep(i,n){
        if(i==n-1){
            break;
        }
        if(s[i]!=s[i+1])
            a.push_back(i);
    }
    //rep(i,n)cout << s[i] ;
    //cout  << endl;
    //rep(i,a.size())cout <<"a:"<< a[i] << endl;
    //s[k]の子が何番目のL,Rloopに入るか
    int j = 0;
    vector<int> ans(n,0);
    rep(i,n){
        //cout << a[j] << endl;
        if(s[i]=='R'){
            //to a[j]loop
            int x = a[j] - i; //times of step to loop
            if(x%2)
                ans[a[j] + 1]++; //s[i]の子はL
            else
                ans[a[j]]++;
        }
        if(s[i]=='L'){
            //to a[j-1]loop
            int x = i - a[j - 1]; //times of step to loop
            if(x%2)
                ans[a[j-1] + 1]++; //s[i]の子はL
            else
                ans[a[j-1]]++;
        }
        if(i>=a[j]){
            if(j==a.size()){
                continue;
            }
            j++;
        }
    }
    rep(i, n){
        cout << ans[i];
        if(i!=n-1)cout<< " ";
        if(i==n-1)cout << endl;
    }
}

Measured memory_bytes: 1528
#include <stdio.h>
#include <cstdio>
#include <iostream>
#include <iomanip>
#include <queue>
#include <set>
#include <vector>
#include <string>
#include <cstring>
#include <algorithm>
#include <cmath>

int main(){
  std::string S;
  std::cin >> S;
  
  long long int L = S.length();
  long long int ans = 0;
  
  for(long long int i = 0; i < L/2; i++){
    if(S[i] != S[L-1-i]){
      ans++;
    }
  }
  
  std::cerr << "Answer:" << std::endl;
  std::cout << ans << std::endl;
  
  return 0;
}


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

#include <iostream>
#include <fstream>

#include <bits/stdc++.h>

#define int long long
#define REP(i, n) for (int i = 0, i##_len = (n); i < i##_len; ++i)
#define FOR(i, a, b) for (int i = (a), i##_len = (b); i <= i##_len; ++i)
#define REV(i, a, b) for (int i = (a); i >= (b); --i)
#define CLR(a, b) memset((a), (b), sizeof(a))
#define DUMP(x) cout << #x << " = " << (x) << endl;
#define INF 1001001001001001001ll
#define fcout cout << fixed << setprecision(12)

using namespace std;

typedef pair<int, int> P;

class FIntervalsOnTree {
public:
    void solve(std::istream& cin, std::ostream& cout) {
        int N;
        cin >> N;
        vector<pair<int, int>> e(N-1);
        REP(i, N - 1) {
            int u, v;
            cin >> u >> v;
            if (u > v) swap(u, v);
            e[i] = {u, v};
        }

        int num = 0;
        FOR(i, 1, N) {
            num += i * (N - i + 1);
        }

        int sub = 0;
        REP(i, e.size()) {
            sub += e[i].first * (N - e[i].second + 1);
        }
        cout << num - sub << endl;
    }
};


signed main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);
    std::istream& in(std::cin);
    std::ostream& out(std::cout);

    FIntervalsOnTree solver;
    solver.solve(in, out);
    return 0;
}


Measured memory_bytes: 6368
import java.util.Scanner;
 
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int Hanako_Point = 0;
		int Taro_Point = 0;
		int n = sc.nextInt();

		for(int i = 0; i< n; i++){
			String Taro_Card = sc.next();
			String Hanako_Card = sc.next();

			if(Taro_Card.compareToIgnoreCase(Hanako_Card) < 0){
				Hanako_Point += 3;
			}else if(Taro_Card.compareToIgnoreCase(Hanako_Card) == 0){
				Taro_Point ++;
				Hanako_Point++;
			}else{
				Taro_Point += 3;
			}
		}
		System.out.println(Taro_Point + " " + Hanako_Point);
	}
}


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

const ll mod = 1e9+7;
const ll INF = 1e18;
const double pi = acos(-1.0);

int main(void)
{
    ll k,n; cin>>k>>n;
    vector<ll> a(n),b(n);
    rep(i,n) cin >> a[i];
    rep(i,n-1){
        b[i] = a[i+1] - a[i];
    }
    b[n-1] = a[0]+k-a[n-1];
    sort(all(b));
    ll sum=0;
    rep(i,n-1) sum+=b[i];
    cout<<sum<<endl; 
    return 0;
}

Measured memory_bytes: 6412
#include <iostream>
#include <cstdio>
//#include <cstring>

using namespace std;

int main()
{
	//freopen("mine.in","r",stdin);
	//freopen("mine.out","w",stdout);
	
	int n, m;
	cin >> n >> m;
	char mine[105][105];
	for (int i = 0; i < 105; ++i)
	    for (int j = 0; j < 105;++j)
	        mine[i][j] = 0;
	for (int i = 1; i <= n; ++i)
		for (int j = 1; j <= m; ++j)
			cin >> mine[i][j];
	for (int i = 1; i <= n; ++i)
	{
		for (int j = 1; j <= m; ++j)
		{
			if (mine[i][j] == '.')
			{
				int tmp = 0;
				if (mine[i+1][j-1] == '#') ++ tmp;
				if (mine[i+1][j+1] == '#') ++ tmp;
				if (mine[i+1][j+0] == '#') ++ tmp;
				if (mine[i-1][j+1] == '#') ++ tmp;
				if (mine[i-1][j-1] == '#') ++ tmp;
				if (mine[i-1][j+0] == '#') ++ tmp;
				if (mine[i+0][j+1] == '#') ++ tmp;
				if (mine[i+0][j-1] == '#') ++ tmp;
				mine[i][j] = tmp;
				cout.put(mine[i][j] + 48);
			}
			else cout << '#';
		}
		cout << endl;
	}
	return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
#include<string.h>
#include<math.h>
int main(void)
{
	int a,s[1001][4],d,f,g,h,i,j,k;
	scanf("%d",&a);
	for(i=0;i<a;i++){
		for(j=0;j<3;j++) scanf("%d",&s[i][j]);
		for(j=0;j<2;j++){
			for(k=j+1;k<3;k++){
				if(s[i][j]>s[i][k]){
					d=s[i][j];
					s[i][j]=s[i][k];
					s[i][k]=d;
				}
			}
		}
	}
	/*printf("\n");
	for(i=0;i<a;i++){
		for(j=0;j<3;j++) printf("%d ",s[i][j]);
		printf("\n");
	}*/
	f=0;
	for(i=0;i<a-1;i++){
		for(j=i+1;j<a;j++){
			if(s[i][0]==s[j][0]&&s[i][1]==s[j][1]&&s[i][2]==s[j][2]&&s[i][0]!=-1){
				f++;
				s[i][0]=-1;
			}
		}
	}
	printf("%d\n",f);
	return 0;
}

Measured memory_bytes: 2740
#include<bits/stdc++.h>
using namespace std;
int main()
{
	string arr;
	cin >> arr;
	int count = 0;
	int counting[26] = {0};
	for(int i=0; i<4; i++)
		counting[arr[i] - 'A']++;
	for(int i=0; i<26; i++)
	{
		if(counting[i] == 2) count++;
	}
	if(count == 2) printf("Yes");
	else           printf("No");
	printf("\n");
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <sstream>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <ctime>
#include <vector>
#include <string>
#include <map>
#include <set>
#include <deque>
#include <queue>
#include <stack>
#include <functional>
#include <algorithm>

using namespace std;

#define rep(i,j) REP((i), 0, (j))
#define REP(i,j,k) for(int i=(j);(i)<(k);++i)
#define BW(a,x,b) ((a)<=(x)&&(x)<=(b))
#define ALL(v) (v).begin(), (v).end()
#define LENGTHOF(x) (sizeof(x) / sizeof(*(x)))
#define AFILL(a, b) fill((int*)a, (int*)(a + LENGTHOF(a)), b)
#define SQ(x) ((x)*(x))
#define Mod(x, mod) (((x)+(mod)%(mod))
#define MP make_pair
#define PB push_back
#define Fi first
#define Se second
#define INF (1<<29)
#define EPS 1e-10
#define MOD 1000000007

typedef pair<int, int> pi;
typedef pair<int, pi> pii;
typedef vector<int> vi;
typedef queue<int> qi;
typedef long long ll;

struct Edge{
  int to,d,c;
  Edge(int to, int d, int c):to(to),d(d),c(c){}
  bool operator>(const Edge& a)const{
    if(d!=a.d) return d > a.d;
    else return c > a.c;
  }
  bool operator<(const Edge& a)const{
    if(d!=a.d) return d < a.d;
    else return c < a.c;
  }
};

int N,M;
vector<Edge>G[10005];
int dist[10005];
int vis[10005];

int dijkstra(int s){
  fill(dist, dist+N, INF);
  fill(vis, vis+N, 0);
  priority_queue<Edge, vector<Edge>, greater<Edge> >q;
  dist[s] = 0;
  q.push(Edge(s, 0, 0));
  int res = 0;
  while(!q.empty()){
    int v = q.top().to;
    int d = q.top().d, c = q.top().c;
    q.pop();
    if(vis[v]) continue;
    vis[v] = 1;
    res += c;
    rep(i,G[v].size()){
	q.push(Edge(G[v][i].to, d + G[v][i].d, G[v][i].c));
    }
  }
  return res;
}

int main(){
  while(scanf("%d%d",&N,&M) && N||M){
    rep(i,10005) G[i].clear();
    rep(i,M){
      int u,v,d,c;
      scanf("%d%d%d%d",&u,&v,&d,&c); u--; v--;
      G[u].push_back(Edge(v,d,c));
      G[v].push_back(Edge(u,d,c));
    }

    printf("%d\n", dijkstra(0));
  }
  return 0;
}

Measured memory_bytes: 3700
#include <bits/stdc++.h>
#define rep3(i, s, n, a) for (int i = (s); i < (int)(n); i += a)
#define rep2(i, s, n) rep3(i, s, n, 1)
#define rep(i, n) rep2(i, 0, n)

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

int main(){
    int n;
    cin >> n;
    int pre=0, cnt=0, res=0;
    rep(i, n){
        int h;
        cin >> h;
        if(pre>=h){
            cnt++;
        }else{
            res = max(res, cnt);
            cnt = 0;
        }
        pre = h;
    }
    res = max(res, cnt);
    cout << res << endl;
    return 0;
}

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

struct edge{
  int x;
  int y;
};

int main(){
  int N;
  cin>>N;
  vector<edge> edges;
  for(int i=0;i<N-1;i++){
    edge c;
    int a,b;
    cin>>a>>b;
    c.x=min(a,b);
    c.y=max(a,b);
    edges.push_back(c);
  }
  long long nodes=0;
  long long numedges=0;
  for(int i=1;i<=N;i++){
    nodes=nodes+(long long)i*(i+1)/2;
  }
  for(int i=0;i<N-1;i++){
    numedges=numedges+ (long long)edges[i].x * (N-edges[i].y+1);
  }
  cout<<nodes-numedges<<endl;
}


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

int main() {
	int k, s; cin >> k >> s;

	int ans = 0;
	for (int x = 0; x <= k; x++) {
		for (int y = 0; y <= k; y++) {
			int z = s - x - y;
			if (z <= k && 0 <= z) ans++;
		}
	}
	cout << ans << endl;

	return 0;
}

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

public class Main {

	public static void main(String[] args) throws IOException {
		new Main().run();
	}
	
	private void run() throws IOException {
		BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
		int n = Integer.parseInt(reader.readLine());
		for (int i = 0; i < n; i++) {
			String s1 = reader.readLine();
			String s2 = reader.readLine();
			System.out.println(LCS(s1.toCharArray(), s2.toCharArray()));
		}
		reader.close();
	}

	private int LCS(char[] s1, char[] s2) {
		int n1 = s1.length;
		int n2 = s2.length;
		int[][] dp = new int[n1+1][n2+1];
		for (int i = 1; i <= n1; i++) {
			for (int j = 1; j <= n2; j++) {
				char c1 = s1[i-1];
				char c2 = s2[j-1];
				if (c1 == c2) {
					dp[i][j] = dp[i-1][j-1] + 1;
				} else {
					dp[i][j] = Math.max(dp[i-1][j], dp[i][j-1]);
				}
			}			
		}
		return dp[n1][n2];
	}
}


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

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)   FOR(i,0,n)
#define ALL(a)     (a).begin(),(a).end()
#define PRINT(a)   cout << (a) << endl
#define RALL(v) rbegin(v), rend(v)

#define pb push_back
#define eb emplace_back
#define mp make_pair
#define Fi first
#define Se second

#define debug(x) cerr << x << " " << "(L:" << __LINE__ << ")" << '\n';

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

template <typename T> using PQ = priority_queue<T>;
template <typename T> using minPQ = priority_queue<T, vector<T>, greater<T>>;

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

const int INF = 1001001001;
const ll LINF = 1001001001001001001ll;
const int MOD = 1e9 + 7;

ll mpow(ll x, ll n){
  if(n==0)return 1;

  ll y = mpow(x, n/2);
  y *= y;

  if(n%2==1) y *=x;
  return y;
}

int main(){
  ll N;
  cin >> N;
  ll ans=N*(N+1)/2;

  for(ll i = 2; i < N+1; i++){
    ll n = N / i * i;

    ans += (N/i) * (i + n) / 2; 
  }
  PRINT(ans);
}



Measured memory_bytes: 3644
#include<stdio.h>
#define min(a,b) (((a)<(b))?(a):(b))
#define max(a,b) (((a)>(b))?(a):(b))
int main(int argc, char const *argv[]){
	char s[101],t;
	int ans=100,i=0,j,m,r,f;
	scanf("%s",s);
	while(s[i]!='\0'){
		t=s[i];
		m=0;
		j=0;
		f=0;
		while(s[j]!='\0'){
			if(s[j]==t && f==1) m=max(m,r);
			else if(s[j]!=t){
				if(f==1) r++;
				else{
					r=1;
					f=1;
				}
			}
			if(s[j]==t) f=0;
			j++;
		}
		if(f==1) m=max(m,r);
		ans=min(ans,m);
		i++;
	}
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
#define int long long
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using namespace std;
int MOD = 1000000007;
int INF = numeric_limits<int>::max() / 2;

int ans = 0;
int N;

void dfs(string S){
  if(stol(S) > N) return;
  bool ans3{}, ans5{}, ans7{};
  for(int i=0;i<S.size();i++){
    if(S[i] == '3') ans3 = true;
    if(S[i] == '5') ans5 = true;
    if(S[i] == '7') ans7 = true;
  }
  if(ans3 && ans5 && ans7) ans++;
  string T = S + "3";
  string U = S + "5";
  string W = S + "7";
  dfs(T);
  dfs(U);
  dfs(W);
}
 
signed main(){
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
 
  cin >> N;
  dfs("3");
  dfs("5");
  dfs("7");

  cout << ans << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define pb push_back
#define mp make_pair
#define deb(a,b,c) cout<<#a<<" = "<<(a)<<", "<<#b<<" = "<<(b)<<", "<<#c<<" = "<<(c)<<endl;
 
typedef long long int ll;
typedef string str;
 
ll power(ll x, ll y, ll p) 
{ 
    ll res = 1;     
  
    x = x % p;   
    while (y) 
    { 
        if (y & 1) 
            res = (res*x) % p; 
        y = y>>1;  
        x = (x*x) % p; 
    } 
    return res; 
} 
 
ll nCrModP(ll n, ll r, ll p) 
{ 
    if (!r) 
      return 1; 
  
	ll fac[n+1]; 
   	fac[0] = 1; 
    for (ll i=1 ; i<=n; i++) 
        fac[i] = fac[i-1]*i%p; 
  
    return (fac[n]* power(fac[r], p-2,p) % p * power(fac[n-r], p-2,p) % p) % p; 
}
 
ll gcd(ll a, ll b){ 
    if (a == 0) 
        return b;  
    return gcd(b % a, a);
}
 
void fast(){
	ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
}
ll r[300004],c[300004];
int main ()
{
	
	ll t,n,m,k,i,j,a,b;
	// cin >> t;
    str st,s;
    cin >> n >> m >> k;
    ll p=0,q=0;
    ll arr[k+3][2];
    for(i=0;i<k;i++)
    {
        cin >> a >> b;
        arr[i][0]=a,arr[i][1]=b;
        r[a]++;
        p=max(r[a],p);
        c[b]++;
        q=max(c[b],q);
        // ma.insert(mp(a,b));
    }
    a=0,b=0;
    for(i=1;i<=n;i++)
    {
        if(r[i]==p)
            a++;
    }
    for(i=1;i<=m;i++)
    {
        if(c[i]==q)
            b++;
    }
    a*=b;
    // deb(a,b,k)
    ll cnt=0;
    for(i=0;i<k;i++)
    {
        if(r[arr[i][0]]==p && c[arr[i][1]]==q)
            cnt++;
        // deb(arr[i][0],arr[i][1],cnt)
    }
    if(cnt>=a)
        p--;
    cout << p+q << "\n";
    return 0;
}

Measured memory_bytes: 12936
m,d = map(int,input().split())
count = 0
for i in range(1,m+1):
    for j in range(12,d+1):
        if j%10 != 1 and j //10 != 1 and i == ((j % 10) * (j //10)) :
            count += 1
            #print(i,j)
print(count)


Measured memory_bytes: 38768
K,N = map(int,input().split())
A = list(map(int,input().split()))
max = 0
index = 0
for i in range(len(A)-1):
    if(max < A[i+1] - A[i]):
        max = A[i+1] - A[i]
if(max < K - A[-1] + A[0]):
    max = K - A[-1] + A[0]
print(K-max)


Measured memory_bytes: 26444
#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;
inline int mul(int a, int b, int mod){ return (long long)a*b%mod; }
int power(int a, int b, int mod){
	int ret = 1;
	for (int t = a; b; b >>= 1){
		if (b & 1)ret = mul(ret, t, mod);
		t = mul(t, t, mod);
	}
	return ret;
}
int cal_root(int mod)
{
	int factor[20], num = 0, m = mod - 1, s = m;
	for (int i = 2; i * i <= s; i++){
		if (s % i == 0){
			factor[num++] = i;
			while (s % i == 0)s /= i;
		}
	}
	if (s != 1)factor[num++] = s;
	for (int i = 2;; i++){
		int j = 0;
		for (; j < num && power(i, m / factor[j], mod) != 1; j++);
		if (j == num)return i;
	}
}
template<int MOD, int ROOT>
void fft_main(int a[], int len, bool reverse)
{
	for (int i = 1, j = len / 2; i < len - 1; i++) {
		if (i < j) swap(a[i], a[j]);
		for (int k = len; j < k; k >>= 1, j ^= k);
	}
	for (int s = 1; s < len; s <<= 1){
		int t = (MOD - 1) / (s * 2);
		int step = power(ROOT, reverse ? MOD - 1 - t : t, MOD);
		for (int j = 0; j < len; j += 2 * s){
			int cur = 1;
			for (int k = j; k < j + s; k++){
				int u = a[k], t = mul(cur, a[k + s], MOD);
				a[k] = (unsigned int)(u + t) % MOD;
				a[k + s] = (unsigned int)(u - t + MOD) % MOD;
				cur = mul(cur, step, MOD);
			}
		}
	}
	if (reverse){
		int t = power(len, MOD - 2, MOD);
		for (int i = 0; i < len; i++)
			a[i] = mul(a[i], t, MOD);
	}
}
//确保数组中的数小于mod(mod<2^30)，数组需留足2^(logn向上取整+1)的空间
//并且mod为形如m*2^k+1的素数，2^k>=2*n
template<int MOD, int ROOT>
void fft(int a[], int b[], int n)
{
	int len = 1;
	while (len < 2 * n)len <<= 1;
	memset(a + n, 0, sizeof(int)*(len - n));
	memset(b + n, 0, sizeof(int)*(len - n));
	fft_main<MOD, ROOT>(a, len, 0);
	fft_main<MOD, ROOT>(b, len, 0);
	for (int i = 0; i < len; i++)
		a[i] = mul(a[i], b[i], MOD);
	fft_main<MOD, ROOT>(a, len, 1);
}
template<int MOD, int ROOT>
void fft(int a[], int n)
{
	int len = 1;
	while (len < 2 * n)len <<= 1;
	memset(a + n, 0, sizeof(int)*(len - n));
	fft_main<MOD, ROOT>(a, len, 0);
	for (int i = 0; i < len; i++)
		a[i] = mul(a[i], a[i], MOD);
	fft_main<MOD, ROOT>(a, len, 1);
}
//附满足条件大整数：167772161, 469762049, 754974721, 2146959361, 2130706433
//原根：3 3 11 19 3
//
//
int a[6][262145],ans[262145],tmp[262145];
const int mod=754974721;
int main()
{
	int n;
	while(scanf("%d",&n)==1){
		memset(a[0],0,sizeof(int)*n);
		for(int j=1%n;!a[0][j];j=mul(j,10,n))
			a[0][j]=1;
		a[0][0]++;
		for(int i=1;i<=5;i++){
			memcpy(a[i],a[i-1],sizeof(int)*n);
			fft<mod,11>(a[i],n);
			a[i][0]=a[i][0]+a[i][n]>1?2:1;
			for(int j=1;j<n;j++)
				a[i][j]=a[i][j]+a[i][j+n]?1:0;
		}
		int res=0;
		memset(ans,0,sizeof(int)*n);
		ans[0]=1;
		for(int i=5;i>=0;i--){
			memcpy(tmp,ans,sizeof(int)*n);
			fft<mod,11>(tmp,a[i],n);
			if(tmp[0]+tmp[n]==1){
				res+=1<<i;
				for(int j=0;j<n;j++)
					ans[j]=tmp[j]+tmp[j+n]?1:0;
			}
		}
		printf("%d\n",res+1);
	}
}


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

int main(){
  int r,g,b;
  cin >> r >> g >> b;
  int ans=100*r+10*g+b;
  if(ans%4==0){
    cout<< "YES" <<endl;
  }else{
    cout << "NO" <<endl;
  }
  return 0;
}

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

int main(){
    int A[4];
    for(int k=0; k<4; k++) cin >> A[k];
    sort(A, A+4);
    cout << min(abs(A[0]+A[2]-A[1]-A[3]), abs(A[0]+A[3]-A[1]-A[2])) << endl;
    return 0;
}



Measured memory_bytes: 3164
while True:
    a, b, c = input().split()
    a, b, c = int(a), str(b), int(c)
    if b == '?':
        break
    elif b == '+':
        print(f"{a + c}")
    elif b == '-':
        print(f"{a - c}")
    elif b == '*':
        print(f"{a * c}")
    else:
        print(f"{a // c}")


Measured memory_bytes: 5604
#include <algorithm>
#include <cassert>
#include <climits>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <list>
#include <map>
#include <memory>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
//#include <regex>

/* g++ -g -std=c++0x */
/* g++ -g -std=c++11 */

using namespace std;

// std::ios::sync_with_stdio(false);

// freopen("input.txt", "rt", stdin);
// freopen("output.txt", "wt", stdout);

#define ALL(c)          (c).begin(), (c).end()
#define ALLR(c)         (c).rbegin(), (c).rend()
#define FOR(i,a,b)      for (int i=(a); i < (b); ++i)
#define FORR(i,a,b)     for (int i=(a); i > (b); --i)
#define FOR_ALL(i,c)    for (__typeof((c).begin()) i=(c).begin();   \
                             i != (c).end(); ++i)
#define FOR_ALLR(i,c)   for (__typeof((c).rbegin()) i=(c).rbegin(); \
                             i != (c).rend(); ++i)
#define SZ(array)       (sizeof(array)/sizeof(array[0]))
#define lc(x)           (x<<1)     /* 2*x */
#define rc(x)           (x<<1 | 1) /* 2*x+1 */
#define lowbit(x)       (x & (-x)) /* 0b10100 -> 0b100 */

typedef long long       LL;
typedef map<int,int>    MII;
typedef pair<int,int>   PII;
typedef set<int>        SI;
typedef vector<bool>    VB;
typedef vector<double>  VD;
typedef vector<int>     VI;
typedef vector<string>  VS;

/* check if a key is in container C */
template <class C>
inline bool in_(const typename C::key_type& k, const C& A)
{ return A.find(k) != A.end(); }
inline bool in_(const string& s, const string& S)
{ return S.find(s) != string::npos; }

int main()
{
/* #ifndef ONLINE_JUDGE */
/*     freopen("foo", "rt", stdin); */
/* #endif */
    int N;
    while (cin >> N) {
        VI lft,rht;
        FOR(i,0,N) {
            int a; cin >> a;
            if (i%2)
                rht.push_back(a);
            else
                lft.push_back(a);
        }
        VI ans;
        FOR_ALLR(i,lft)
            ans.push_back(*i);
        FOR_ALL(i,rht)
            ans.push_back(*i);
        if (N%2 == 0)
            reverse(ALL(ans));
        const int n = ans.size();
        FOR(i,0,n) {
            cout << ans[i];
            if (i == n-1)
                cout << endl;
            else
                cout << ' ';
        }
    }
    return 0;
}


Measured memory_bytes: 3824
#include<bits/stdc++.h>
using namespace std;
using lint = long long;
template<class T>
using vec = vector<T>;

#define FOR(i,a,b) for(int i=((int)(a));i<((int)(b));i++)
#define REP(i,x) for(int i=0;i<(int)(x);i++)
#define all(x) (x).begin(),(x).end()

int main(){
  int n;
  cin >>n;
  vec<int> a(n);
  REP(i,n) cin >>a[i];

  sort(all(a));
  reverse(all(a));
  int ans=0;
  for(int i=0;i<n/2;i++){
    ans += a[i*2]-a[i*2+1];
  }
  if(n%2 == 1) ans += a[n-1];

  cout <<ans <<endl;
}


Measured memory_bytes: 256
import sys, math
from collections import defaultdict
from copy import deepcopy
import itertools
input = sys.stdin.readline
# 文字列の場合は普通のinput()を使うか下を使う
# input = sys.stdin.readline().rstrip()

a, b, c = map(int, input().split())
s = a + b + c
if s >= 22:
    print('bust')
else:
    print('win')

Measured memory_bytes: 38384
def main():
    import sys
    input = sys.stdin.readline

    H, N = map(int, input().split())
    A = []
    B = []
    for _ in range(N):
        a, b = map(int, input().split())
        A.append(a)
        B.append(b)

    inf = 10**10
    dp = [[inf] * (H+1) for _ in range(N+1)]
    dp[0][0] = 0
    for i in range(N):
        a = A[i]
        b = B[i]
        for h in range(H+1):
            dp[i+1][h] = min(dp[i+1][h], dp[i][h])
            dp[i+1][min(h+a, H)] = min(dp[i+1][min(h+a, H)], dp[i+1][h] + b)
    print(dp[-1][-1])


if __name__ == '__main__':
    main()


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

#define mod 1000000007

#define rep(i, n) for(int i=0; i<n; ++i)

using namespace std;
typedef long long ll;
const long long INF = 1LL << 60;
 
int main(void){
	
	int N, ans = 0;
	map<int, int> a;
	
	cin >> N;
	
	rep(i, N){
		ll j;
		cin >> j;
		a[j]++;
	}

	for(auto i: a){
		int x = i.first;
		int n = i.second;
		if(n < x)
			ans += n;
		else
			ans += n - x;
	}	
	
	cout << ans << endl;
	
	return 0;
}

Measured memory_bytes: 4736
import java.util.*;
public class Main
{
    public static void main(String [] args)
    {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt(); HashMap<Integer, Integer> map = new HashMap<>();
        for (int i = 0; i < n - 1; i++) {
            int p = sc.nextInt();
            map.put(p, map.getOrDefault(p, 0) + 1);
        }
        for (int i = 1; i <= n; i++) System.out.println(map.getOrDefault(i, 0));
    }


}

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

int main(void){
    int n,l;
    cin >> n >> l;
    int a = 0,b[500];
    for(int i = 0;i < n;i++){
        b[i] = l+i;
        a += b[i];
    }
    int max = 100000000,ans = 0;
    for(int i = 0;i < n;i++){
        if(abs(a-(a-b[i])) < max){
            max = abs(a-(a-b[i]));
            ans = a-b[i];
        }
    }
    cout << ans;
}

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

typedef long long ll;
typedef pair<ll, ll> pll;

#define m0(x) memset(x, 0, sizeof(x))
#define all(x) x.begin(), x.end()
#define rep(i, n) for(int i = 0; i < (n); i++)
#define asort(x) sort(all(x));
#define dsort(x, t) sort(x.begin(), x.end(), greater<t>());
#define dump(x)  cout << #x << " = " << (x) << endl
#define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end());
#define MINS(m, s) m.insert(make_pair(s, 1));
#define MFIN(m, s) m.find(s) != m.end()
#define YES(n) cout << ((n) ? "YES" : "NO" ) << endl
#define Yes(n) cout << ((n) ? "Yes" : "No" ) << endl

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

int main(){
    int a;
    string s;
    cin >> a >> s;
    if(a >= 3200){
        cout << s << endl;
    }else{
        cout << "red" << endl;
    }
    return 0;
}

Measured memory_bytes: 3596
N = int(input())

ans = []

while N != 0:
    rem = N%(-2)
    if rem == -1:
        ans.append('1')
        N = N//(-2) + 1
    else:
        ans.append('0')
        N = N//(-2)

if len(ans)==0:
    ans.append('0')
ans.reverse()
ans = ''.join(ans)
print(ans)


Measured memory_bytes: 38256
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>

int main(){
    int n, k;
    std::cin >> n >> k;
    std::vector<int> h(n);
    for(int i = 0; i < n; i++) std::cin >> h[i];
    std::sort(h.begin(), h.end());

    int ans = 2000000000;
    for(int i = 0; i + k - 1 < n; i++){
        int minH = h[i];
        int maxH = h[i + k - 1];
        ans = std::min(ans, maxH - minH);
    }
    std::cout << ans << std::endl;
    return 0;
}


Measured memory_bytes: 640
#include <iostream>
#include <cstdio>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <iomanip>
#include <stdlib.h>
#include <string.h>
#include <cstring>
#include <cmath>
#include <map>
#include <queue>
#include <deque>
#include <stack>
#include <set>
#include <stdio.h>
#include <tuple>
#include <bitset>
#include <cfloat>
#include <fstream>
#include <limits.h>
#include <list>
#include <math.h>
#include <random>
#include <unordered_map>
#include <unordered_set>
#include <bitset>
#include <numeric>
#include <utility>
#include <sstream>

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

using namespace std;
#define int long long
#define ll long long
#define rep(i, n) for (ll i = 0; i < (n); i++)
#define FOR(i,a,b) for(ll i=(a);i<(b);i++)
#define FORR(i,a,b)for(ll i=(a);i<=(b);i++)
#define repr(i,n) for(ll i=n;i>=0;i--)
#define P pair<ll, ll>
#define sz(x) (ll)x.size()
#define ALL(x) (x).begin(),(x).end()
#define ALLR(x) (x).rbegin(),(x).rend()
#define VE vector<ll>
#define COUT(x) cout<<(x)<<endl
#define MA map<ll,ll>
#define SE set<ll>
#define PQ priority_queue<ll>
#define PQR priority_queue<ll,VE,greater<ll>>
#define COUT(x) cout<<(x)<<endl
#define YES(n) cout << ((n) ? "YES" : "NO"  ) << endl
#define Yes(n) cout << ((n) ? "Yes" : "No"  ) << endl
#define EPS (1e-10)


const long long MOD = 1000000007;
//const long long MOD = 998244353;
const long long INF = 1LL << 60;


long long modinv(long long a, long long m) {
	long long b = m, u = 1, v = 0;
	while (b) {
		long long t = a / b;
		a -= t * b; swap(a, b);
		u -= t * v; swap(u, v);
	}
	u %= m;
	if (u < 0) u += m;
	return u;
}
ll gcd(ll a, ll b) {
	if (a < b)swap(a, b);
	if (b == 0) return a;
	unsigned r;
	while ((r = a % b)) {
		a = b;
		b = r;
	}
	return b;
}
ll lcm(ll a, ll b) {
	ll g = gcd(a, b);
	return a * g / b;
}
bool prime(ll n) {
	for (ll i = 2; i <= sqrt(n); i++) {
		if (n%i == 0)return false;
	}
	return n != 1;
}




const long double PI = 3.14159265359;
const int MAX_N = 100010;


signed main() {
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	int n; cin >> n;
	vector<VE> f(n, VE(10)), p(n, VE(11));
	rep(i, n)rep(j, 10)cin >> f[i][j];
	rep(i, n)rep(j, 11)cin >> p[i][j];
	int ans = -INF;
	rep(bit, 1 << 10) {
		if (!bit)continue;
		int now = 0;
		rep(i, n) {
			int tmp = 0;
			rep(j, 10) {
				if (bit & (1 << j) && f[i][j])tmp++;
			}
			now += p[i][tmp];
		}
		chmax(ans, now);
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
def solve(a):
    n = len(a)
    cost = [[0 for i in range(n)] for j in range(n)]
 
    for length in range(2, n+1):
        for i in range(0, n-length+1):
            k = i+length-1
            def f(i,j,k):
                return cost[i][j-1]+cost[j][k]+M[i][0]*M[j-1][1]*M[k][1]
            cost[i][k] = min([f(i,j,k) for j in range(i+1,k+1)])
    return cost[0][n-1]
n = input()
M = []
for i in range(n):
    M.append(map(int, raw_input().split()))
print solve(M)

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

int main(){
  int Ainfo,Amath,Ascien,Aeng,Atotal;
  int Binfo,Bmath,Bscien,Beng,Btotal;
  cin>>Ainfo>>Amath>>Ascien>>Aeng;
  cin>>Binfo>>Bmath>>Bscien>>Beng;
  Atotal=Ainfo+Amath+Ascien+Aeng;
  Btotal=Binfo+Bmath+Bscien+Beng;
  if(Atotal>=Btotal){
    cout<<Atotal<<'\n';
  }else{
    cout<<Btotal<<'\n';
  }
  return 0;
}

Measured memory_bytes: 1160
#include <bits/stdc++.h> 
using namespace std;
#define rep(i, N) for (int i = 0; i < (N); i++)  

int main() {
    int n;
    scanf("%d", &n);
    map<pair<int,int>, int> cnt;
    rep (i,n){
        double x;
        cin >> x;
        long long xl = llround(x * 1e9);
        int two = 0, five = 0;
        while(xl % 2 == 0) {
            two++;
            xl /= 2;
        }
        while(xl % 5 == 0) {
            five++;
            xl /= 5;
        }
        ++cnt[{two,five}];
    }
    long long answer = 0;
    for(auto p1 : cnt) {
        for(auto p2 : cnt) {
            if(p1.first.first+p2.first.first >= 18 && p1.first.second+p2.first.second >= 18) {
                if(p1 < p2) {
                    answer += (long long) p1.second * p2.second;
                }
                else if(p1 == p2) {
                    answer += (long long) p1.second * (p1.second - 1) / 2;
                }
            }
        }
    }
    cout << answer << endl;
}


Measured memory_bytes: 3832
#include <iostream>

using namespace std;

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


}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <queue>
#include <stack>
#include <algorithm>
#include <list>
#include <vector>
#include <complex>
#include <utility>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <climits>
#include <bitset>
#include <ctime>
#include <map>
#include <unordered_map>
#include <set>
#include <unordered_set>
#include <cassert>
#include <cstddef>
#include <iomanip>
#include <numeric>
#include <tuple>
#include <sstream>
#include <fstream>

using namespace std;
#define REP(i, n) for (int (i) = 0; (i) < (n); (i)++)
#define FOR(i, a, b) for (int (i) = (a); (i) < (b); (i)++)
#define RREP(i, a) for(int (i) = (a) - 1; (i) >= 0; (i)--)
#define FORR(i, a, b) for(int (i) = (a) - 1; (i) >= (b); (i)--)
#define DEBUG(C) cerr << #C << " = " << C << endl;
using LL = long long;
using VI = vector<int>;
using VVI = vector<VI>;
using VL = vector<LL>;
using VVL = vector<VL>;
using VD = vector<double>;
using VVD = vector<VD>;
using PII = pair<int, int>;
using PDD = pair<double, double>;
using PLL = pair<LL, LL>;
using VPII = vector<PII>;
template<typename T> using VT = vector<T>;
#define ALL(a) begin((a)), end((a))
#define RALL(a) rbegin((a)), rend((a))
#define SORT(a) sort(ALL((a)))
#define RSORT(a) sort(RALL((a)))
#define REVERSE(a) reverse(ALL((a)))
#define MP make_pair
#define FORE(a, b) for (auto &&a : (b))
#define FIND(s, e) ((s).find(e) != (s).end())
#define EB emplace_back
template<typename T> inline bool chmax(T &a, T b){if (a < b){a = b;return true;}return false;}
template<typename T> inline bool chmin(T &a, T b){if (a > b){a = b;return true;}return false;}

const int INF = 1e9;
const int MOD = INF + 7;
const LL LLINF = 1e18;

int main(void) {
    int n, a, b;
    cin >> n >> a >> b;
    string ans;
    if (n == 2) ans = "Borys";
    else {
        if (abs(a - b) % 2 == 0) ans = "Alice";
        else ans = "Borys";
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
const int MAXN=100010,P=998244353;
int n,ans,d[MAXN],cnt[MAXN];
int main () {
	scanf("%d",&n);
	for (int i=1;i<=n;i++) {
		scanf("%d",&d[i]);
		cnt[d[i]]++;
	}
	ans=1;
	for (int i=1;i<=n;i++) {
		if (i==1&&d[i]>0) {printf("0\n");return 0;}
		if (i>1&&d[i]==0) {printf("0\n");return 0;}
		if (i==1) {continue;}
		ans=(1ll*ans*cnt[d[i]-1])%P;
	}
	printf("%d\n",ans);
	return 0;
}

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


map< pair<int,int> , int> memo;

void solve(long long N, vector<long long> A){
	for(int i = 0 ; i < N ; i++){	
		A[i]--;
		int a = A[i];
		int b = i;
		if( a < b ) swap(a,b);
		memo[{a,b}]++;
	}
	int ans = 0;
	for( auto p : memo ){
		if( p.second == 2 ) ans++;
	}	
	cout << ans << endl;
}



int main(){	
	ios::sync_with_stdio(false);
	long long N;
	cin >> N;
	vector<long long> a(N-1+1);
	for(int i = 0 ; i <= N-1 ; i++){
		cin >> a[i];
	}
	solve(N, a);
	return 0;
}


Measured memory_bytes: 8064
package main

import "fmt"

func main() {
	var h, w int
	fmt.Scan(&h, &w)

	status := make([]string, h)
	for i := 0; i < h; i++ {
		var s string
		fmt.Scan(&s)
		status[i] = s
	}

	count := make([][]int, h)
	for i := 0; i < h; i++ {
		count[i] = make([]int, w)
	}
	x := []int{-1, 0, 1}
	y := []int{-1, 0, 1}
	for i := 0; i < h; i++ {
		for j := 0; j < w; j++ {
			if status[i][j] == '#' {
				continue
			}

			cnt := 0
			for _, dx := range x {
				for _, dy := range y {
					if dx == 0 && dy == 0 {
						continue
					}
					if i+dx >= 0 && i+dx < h &&
						j+dy >= 0 && j+dy < w &&
						status[i+dx][j+dy] == '#' {
						cnt++
					}
				}
			}
			count[i][j] = cnt
		}
	}

	for i := 0; i < h; i++ {
		for j := 0; j < w; j++ {
			if status[i][j] == '#' {
				fmt.Printf("#")
			} else {
				fmt.Printf("%d", count[i][j])
			}
		}
		fmt.Println()
	}
}


Measured memory_bytes: 512
package main

import (
	"fmt"
	"math"
)

func main() {
	var n float64
	fmt.Scan(&n)

	sqrt := int(math.Ceil(math.Sqrt(n)))

	ans := int(n)
	for i := 1; i <= sqrt; i++ {
		if int(n) % i == 0 {
			if ans > i + int(n)/i - 2 {
				ans = i + int(n)/i - 2
			}
		}
	}
	fmt.Println(ans)
}


Measured memory_bytes: 512
#pragma region Macros
#include <bits/stdc++.h>

using namespace std;
using ll = long long;
using Graph = vector<vector<int>>;
using WGraph = vector<vector<pair<int, ll>>>;

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

constexpr int dx[4] = {-1, 0, 0, 1}, dy[4] = {0, -1, 1, 0};
constexpr int INF = 1e9;
constexpr long long LINF = 1e18;
constexpr long long MOD = 1e9 + 7;
constexpr double EPS = 1e-10;
#pragma endregion

std::map<long long, int> primeFact(long long n) {
    std::map<long long, int> res;
    for (long long i=2; i*i<=n; i++) {
        while (n%i == 0) {
            res[i]++;
            n /= i;
        }
    }
    if (n != 1) {
        res[n] = 1;
    }
    return res;
}

long long inv(long long n) {
    long long res = 1;
    while (n > 1) {
        res *= (MOD - MOD / n);
        res %= MOD;
        n = MOD % n;
    }
    return res;
}

void solve() {
    int n;
    cin >> n;
    vector<ll> a(n);
    for (int i=0; i<n; i++) {
        cin >> a.at(i);
    }
    map<ll, int> primelcm;
    for (int i=0; i<n; i++) {
        auto tmp = primeFact(a.at(i));
        for (auto iter=tmp.begin(); iter!=tmp.end(); iter++) {
            if (primelcm[iter->first] < iter->second) {
                primelcm[iter->first] = iter->second;
            }
        }
    }
    ll lcm = 1;
    for (auto iter=primelcm.begin(); iter!=primelcm.end(); iter++) {
        for (int i=0; i<iter->second; i++) {
            lcm *= iter->first % MOD;
            lcm %= MOD;
        }
    }
    ll res = 0;
    for (int i=0; i<n; i++) {
        res += lcm * inv(a.at(i));
        res %= MOD;
    }
    if (res < 0) res += MOD;
    cout << res << "\n";
}

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

    solve();

    return 0;
}


Measured memory_bytes: 1024
#include <iostream>

using namespace std;

int main()
{
  int n;
  int *a;
  long int total_a = 0;
  long int e = 1;
  long int ans = 0;
  
  cin >> n;
  a = (int*)malloc(( n + 1 ) * sizeof( int ));
  if ( NULL == a ) { return -1; }
  for ( int i = 0 ; i <= n ; ++i ) { cin >> a[i]; total_a += a[i]; }
  
  for ( int i = 0 ; i <= n ; ++ i ) {
    ans += e;
    if ( e < a[i] ) { cout << -1 << endl; return 0; }
    e = 2 * ( e - a[i] );
    total_a -= a[i];
    e = min( e, total_a );
  }
  
  cout << ans << endl;
}

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

int main(){
    int N; cin >> N;
    map<int,int> memo;
    ll sankaku = 1, cnt = 2;
    while(sankaku < 1e5 + 1){
        memo[sankaku] = cnt - 1;
        sankaku += cnt;
        cnt++;
    }

    if(memo[N] == 0){
        puts("No");
        return 0;
    }else{
        puts("Yes");
    }
    int k = memo[N] + 1;
    int SIZE = memo[N];
    cout << k << endl;
    queue<int>  tans[k];
    vector<int> ans[k];

    int t = 1;
    rep(i, k){
        rep(j, i){
            int tmp = tans[j].front(); tans[j].pop();
            ans[i].push_back(tmp);
            //tans[i].push(tmp);
        }
        //cout << ans[i].size() << endl;
        int count  = SIZE - (int)ans[i].size();
        rep(j, count){
            ans[i].push_back(t);
            tans[i].push(t);
            //cout << t << "=  t ";
            t++;
        }
        //cout << endl;
    }
    rep(i, k){
        cout << SIZE;
        rep(j, SIZE){
            cout <<  " " << ans[i][j];
        }
        cout << endl;
    }
}

Measured memory_bytes: 2944
#include <cstdio>
#include <algorithm>

using namespace std;

int main() {
    int n, k, i;
    long long ans = 0;
    
    scanf("%d %d", &n, &k);
    
    if (k == 0) {
        printf("%lld\n", (long long)n * n);
        return 0;
    }
    
    for (i = k + 1; i <= n; i++) {
        ans += n / i * (i - k);
        ans += max(n % i - k + 1, 0);
    }
    
    printf("%lld\n", ans);
    
    return 0;
}


Measured memory_bytes: 128
if __name__ == '__main__':
    N = input()
    odd_count = 0
    even_count = 0

    for i in range(1, (int(N)+1)):
        remainder = i % 2
        if remainder == 0:
            even_count = even_count + 1
        else:
            odd_count = odd_count + 1

    print(odd_count / int(N))


Measured memory_bytes: 2940
using System;
using System.Collections.Generic;
class Program
{
	static void Main(string[] args)
	{
		string[] str = Console.ReadLine().Split();
		long A = long.Parse(str[0]);
		long B = long.Parse(str[1]);
		long C = long.Parse(str[2]);
		long D = long.Parse(str[3]);
		string ans = "Yes";
		while(true){
			C -= B;
			if(C<=0){
				break;
			}
			A -= D;
			if(A<=0){
				ans = "No";
				break;
			}
		}
		Console.WriteLine(ans);
	}
}

Measured memory_bytes: 17876
def amida():
    line = list(map(int, input().split()))[1:]
    res = [0, 1, 2]
    for i in line:
        if i:
            res[1], res[2] = res[2], res[1]
        else:
            res[0], res[1] = res[1], res[0]
    return res


def func(x, line, flag):
    if line == [0, 1, 2] and flag:
        return True
    for i in range(27):
        if x[i] == 0:
            continue
        swaps = tolist(i)
        x[i] -= 1
        res = func(x, [line[swaps[0]], line[swaps[1]], line[swaps[2]]], True)
        x[i] += 1
        if res:
            return True
    return False


n = int(input())
if n >= 7:
    print("yes")
    exit()
amidas = [amida() for _ in range(n)]
toint = lambda x: x[0] * 9 + x[1] * 3 + x[2]
tolist = lambda x: [x // 9, x % 9 // 3, x % 3]
aa = [0 for _ in range(27)]
for i in amidas:
    aa[toint(i)] += 1

flag = False
for i in range(27):
    if aa[i] == 0:
        continue
    line = [0, 1, 2]
    for j in range(aa[i]):
        swaps = tolist(i)
        line = [line[swaps[0]], line[swaps[1]], line[swaps[2]]]
        if line == [0, 1, 2]:
            flag = True
            break
if flag:
    print("yes")
    exit()
if func(aa, [0, 1, 2], False):
    print("yes")
    exit()
print("no")



Measured memory_bytes: 5620
import java.util.*;

public class Main{
	private static final Scanner scan = new Scanner(System.in);

	public static void main(String[] args){
		int[] counts = new int[100];
		int max = 0;
		while(scan.hasNext()){
			int a = scan.nextInt();
			counts[a-1]++;
			if(max < counts[a-1]){
				max = counts[a-1];
			}
		}

		for(int i = 0; i < 100; i++){
			if(max == counts[i]){
				System.out.printf("%d\n", i+1);
			}
		}
	}
}

Measured memory_bytes: 26132
n=int(input())
 
t = list(map(int,input().split()))
t.sort()
a1 = max(t)
 
ans = 100000000000000
 
memo = 0

for i in t:
    if ans > abs(a1/2-i):
        ans = abs(a1/2-i)
        memo = i
print(a1, memo)


Measured memory_bytes: 62704
import java.util.*;

public class Main{
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        long total = 0;
        for (int i = 1; i <= n; i++) {
            if (i % 3 != 0 && i % 5 != 0) {
                total += i;
            }
        }
        System.out.println(total);
    }
}

Measured memory_bytes: 35772
import sys
sys.setrecursionlimit(4100000)
N,M = [int(x) for x in input().split()]
E ={i: [] for i in range(1, N+1)}
for _ in range(M):
  u,v = [int(x) for x in input().split()]
  E[u].append(v)
#print(E)
dp =[-1]*(N+1)
def memo(v):
  if dp[v]!= -1:
    return dp[v]
  res = 0
  for nv in E[v]:
    res = max(res,memo(nv)+1)
  dp[v] =res
  return dp[v]
res = 0
for v in range(1,N+1):
  res = max(res,memo(v))
print(res)

Measured memory_bytes: 167312
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <algorithm>

using namespace std;
using llong = long long;
using ullong = unsigned long long;

int main() {
    int r , D , x2000;
    cin >> r >> D >> x2000;
    int x = x2000;
    for( int i = 2001; i <= 2010 ; ++i ){
      x = r * x - D;
      std::cout << x << std::endl;
    }
}

Measured memory_bytes: 256
#include<stdio.h>
#include<math.h>
void mergeSort(int*,int,int);
void merge(int*,int,int,int);
int l=0;

int main(){
    int n,i;
    scanf("%d",&n);
    int S[n];
    for(i=0;i<n;i++) scanf("%d",&S[i]);
    int left=0,right=n;
    mergeSort(S,left,right);
    for(i=0;i<n;i++){
        if(i==n-1) printf("%d",S[i]);
        else printf("%d ",S[i]);
    }
    printf("\n");
    printf("%d\n",l);
    return 0;
}

void mergeSort(int *S,int left,int right){
    int mid=0;
    if(left+1<right){
        mid=(left+right)/2;
        mergeSort(S,left,mid);
        mergeSort(S,mid,right);
        merge(S,left,mid,right);
    }
}

void merge(int *S,int left,int mid,int right){
    int n1,n2,i,j,k;
    n1=mid-left;
    n2=right-mid;
    int L[n1+1],R[n2+1];
    for(i=0;i<=n1-1;i++) L[i]=S[left+i];
    for(i=0;i<=n2-1;i++) R[i]=S[mid+i];
    L[n1]=1e9+1;
    R[n2]=1e9+1;
    i=0;
    j=0;
    for(k=left;k<=right-1;k++){
        l++;
        if(L[i]<=R[j]){
            S[k]=L[i];
            i=i+1;
        }
        else{
            S[k]=R[j];
            j=j+1;
        }
    }
}


Measured memory_bytes: 5600