akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <string>
#include <algorithm>
#include <functional>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <cstdio>
#include <cmath>
#include <tuple>
#define rep(i, n) for(i = 0; i < n; i++)
using namespace std;


int main() {
	string s;
	cin >> s;
	if (s[0] == '7' || s[1] == '7' || s[2] == '7') cout << "Yes" << endl;
	else cout << "No" << endl;
	return 0;
}

Measured memory_bytes: 3624
#include <iostream>
#include <cstdio>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <string>
#include <vector>
#include <set>
#include <map>
#include <algorithm>

#define CH(N,A,B) (A<=N&&N<B)
#define REP(i,a,b) for(int i=a;i<b;i++)
#define RREP(i,a,b) for(int i=(b-1);a<=i;i--)

using namespace std;

map< char, int > m;
map< int, string > mm;

int sToi(string s){
  int ret = 0;
  REP(i,0,s.size()){
    int tmp = 1;
    if(isdigit(s[i])){
      ret += (s[i] - '0') * m[s[i+1]];
      i++;
    }else{
      ret += m[s[i]];
    }
  }
  return ret;
}

string iTos(int num){
  string s = "";
  int tmp = 1000;
  REP(i,0,4){
    if(num / tmp > 1) s += to_string(num / tmp) + mm[tmp];
    else if(num / tmp == 1) s += mm[tmp];
    num %= tmp;
    tmp /= 10;
  }
  return s;
}

int main() {

  int n;
  cin>>n;

  m['i'] = 1;
  m['x'] = 10;
  m['c'] = 100;
  m['m'] = 1000;

  mm[1] = "i";
  mm[10] = "x";
  mm[100] = "c";
  mm[1000] = "m";

  REP(i,0,n){
    string s1, s2;
    cin>>s1>>s2;
    cout<<iTos(sToi(s1) + sToi(s2))<<endl;
  }

  return 0;
}

Measured memory_bytes: 3208
fun main(args: Array<String>) {
    val (N, K, Q) = readLine()!!.split(" ").map(String::toLong)
    val A = Array(Q.toInt()) { readLine()!!.toInt() - 1 }
    val B = A.groupBy { it }
    repeat(N.toInt()) { n ->
        val survived = B[n]?.count() ?: 0 > Q - K
        println(if (survived) "Yes" else "No")
    }
}

Measured memory_bytes: 51144
#include <iostream>
#include <stdio.h>

#include <vector>
#include <cctype>
#include <cstring>
#include <algorithm>
#include <cmath>
#include <string>

#include <climits>

using namespace std;

int main(){
	int a, b;
	cin >> a >> b;

	int count = 0;

	for (int j = a; j <= b;j++) {
		int i = 0;
		int num = j;
		int arr[5] = { 0 };
		while (i<5) {
			arr[i] = num % 10;
			num = num / 10;
			i++;
		}

		if (arr[0] == arr[4] && arr[1] == arr[3]) {
			count++;
		}
	}

	cout << count << endl;

	return 0;

}

Measured memory_bytes: 3616
#include <stdio.h>

#define M 100000
#define SEN 2000000000

struct Card {
  char suit;
  int value;
};
struct Card L[M/2+2],R[M/2+2];

void merge(struct Card*,int,int,int,int);
void mergesort(struct Card*,int,int,int);
int partition(struct Card*,int,int,int);
void quicksort(struct Card*,int,int,int);

int main(){

  int n,i,v;
  struct Card S[M],T[M];
  char C[10];
  int stable = 1;

  scanf("%d",&n);

  for(i=0;i<n;i++){
    scanf("%s %d",C,&v);
    S[i].suit=T[i].suit=C[0];
    S[i].value=T[i].value=v;
  }
  mergesort(S,n,0,n);
  quicksort(T,n,0,n-1);


  for(i=0;i<n;i++)
    if(S[i].suit!=T[i].suit)stable=0;

  if(stable==1)
    printf("Stable\n");
  else printf("Not stable\n");
  for(i=0;i<n;i++)
    printf("%c %d\n",T[i].suit,T[i].value);

return 0;
}
void merge(struct Card* S,int n,int l,int m,int r){
  int i,j,k,n1,n2;
  n1=m-l;
  n2=r-m;
  for(i=0;i<n1;i++)
    L[i]=S[l+i];
  for(i=0;i<n2;i++)
    R[i]=S[m+i];
  L[n1].value=R[n2].value=SEN;
  i=j=0;
  for(k=l;k<r;k++){
    if(L[i].value<=R[j].value){
      S[k]=L[i++];
    }
    else S[k]=R[j++];
  }
}
void mergesort(struct Card*S,int n,int l,int r){
  int m;
  if(l+1<r){
    m=(l+r)/2;
    mergesort(S,n,l,m);
    mergesort(S,n,m,r);
    merge(S,n,l,m,r);
  }
}
int partition(struct Card* S,int n,int p,int r){
  int i,j;
  struct Card t,x;
  x=S[r];
  i=p-1;
  for(j=p;j<r;j++){
    if(S[j].value<=x.value){
      i++;
      t=S[i];
      S[i]=S[j];
      S[j]=t;
    }
  }
  t=S[i+1];
  S[i+1]=S[r];
  S[r]=t;
  return i+1;
}
void quicksort(struct Card* S,int n,int p,int r){
  int q;
  if(p<r){
    q=partition(S,n,p,r);
    quicksort(S,n,p,q-1);
    quicksort(S,n,q+1,r);
  }
}



Measured memory_bytes: 4080
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
bool solve(ll n,ll m,ll i,vector<vector<ll>> &v,vector<ll> &itr,vector<vector<ll>> &s){
    bool nop[m]={};
  while(1){
    bool ok=1;
    vector<ll> te;
    rep(l,m){
      if(s[l].size()>i){
        for(auto w:s[l])te.push_back(w);
        s[l].clear();
        nop[l]=1;
      }
    }
    for(auto w:te){
      ok=0;
      while(1){
        itr[w]++;
        if(itr[w]==m)return 0;
        if(nop[v[w][itr[w]]]==0)break;
      }
      s[v[w][itr[w]]].push_back(w);
    }
    if(ok)break;
  }
  return 1;
}

int main()
{
ll n , m ;
cin >> n >> m ;
vector<vector<ll>> v(n, vector<ll>(m,0) );
rep(i,n)rep(j,m){
  cin >> v[i][j];
  v[i][j]--;
}
rep(i,n){
  vector<vector<ll>> s(m);
  vector<ll> itr(n);
  rep(j,n){
    s[v[j][0]].push_back(j);
  }
  if(solve(n,m,i+1,v,itr,s)){
    cout << i+1 << endl;
    return 0;
  }
}
return 0;
}

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

constexpr long long mod{1000000007};

int n, c;
long long dp[400][401];
int a[400], b[400];
long long fact[401][401]{};

long long rc(int, int);

int main()
{
	std::fill(dp[0], dp[0] + 400 * 401, -1);
	scanf("%d%d", &n, &c);
	for (int i = 0; i < n; i++)
		scanf("%d", a + i);
	for (int i = 0; i < n; i++)
		scanf("%d", b + i);
	
	for (int i = 1; i <= 400; i++)
	{
		fact[i][0] = 1;
		for (int j = 1; j <= c; j++)
			fact[i][j] = i * fact[i][j - 1] % mod;
		for (int j = 0; j <= c; j++)
			fact[i][j] = (fact[i][j] + fact[i - 1][j]) % mod;
	}
	dp[n - 1][0] = b[n - 1] - a[n - 1] + 1;
	for (int i = 1; i <= c; i++)
		dp[n - 1][i] = (fact[b[n - 1]][i] + mod - fact[a[n - 1] - 1][i]) % mod;
	printf("%lld\n", rc(0, c));

	return 0;
}

long long rc(int index, int rest)
{
	if (dp[index][rest] > 0) return dp[index][rest];
	long long sum{};
	for (int i = 0; i <= rest; i++)
	{
		sum += (fact[b[index]][i] - fact[a[index] - 1][i] + mod) % mod * rc(index + 1, rest - i);
		sum %= mod;
	}
	dp[index][rest] = sum;
	return dp[index][rest];
}

Measured memory_bytes: 3324
#include <cstdio>
#include <algorithm>
#include <utility>
#include <vector>

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

#define pow CHANGETHENAMESTUPID

using namespace std;

typedef pair<int,int> pii;
typedef long long ll;

const int N = 1e5 + 100;

int n;
int a[N], b[N];

void load() {
	scanf("%d", &n);
	FOR(i, n) scanf("%d", a + i);
	FOR(i, n) scanf("%d", b + i);
}

bool solve() {
	vector<pii> bs;
	FOR(i, n) bs.push_back({b[i], i});
	sort(bs.begin(), bs.end());
	vector<int> as(n);
	FOR(i, n) as[i] = a[bs[i].second];
	sort(a, a + n);
	FOR(i, n) if (a[i] > bs[i].first) return false;
	for (int i = 1; i < n; i++) if (a[i] == a[i-1]) return true;
	vector<pii> ass;
	FOR(i, n) ass.push_back({as[i], bs[i].second});
	sort(ass.begin(), ass.end());
	vector<pii> cyc;
	cyc.push_back({0, ass[0].second});
	vector<int> has(n);
	FOR(i, n) has[ass[i].second] = i;
	while (true) {
		pii p = cyc.back();
		int kuda = bs[p.first].second;
		int kudass = has[kuda];
		if (kudass == 0) break;
		cyc.push_back({kudass, ass[kudass].second});
	}
	//for (auto x : cyc) printf("%d %d\n", x.first, x.second);
	if ((int)cyc.size() < n) return true;
	for (int i = 1; i < n; i++) if (ass[i].first <= bs[i-1].first) return true;
	return false;
}

int main() {
	load();
	printf("%s\n", (solve()) ? "Yes" : "No");
	return 0;
}



Measured memory_bytes: 4852
#include <iostream>
#include <iomanip>
#include <vector>
#include <set>
#include <string>
#include <queue>
#include <algorithm>
#include <map>
#include <cmath>
#include <numeric>
#include <list>
#include <stack>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <tuple>
#include <deque>

using namespace std;

/*
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int, int> pii;
typedef vector<pii> vpii;
*/

typedef long long ll;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef pair<long long, long long> pll;
typedef vector<pll> vpll;

typedef long double ld;
typedef vector<ld> vld;

typedef vector<bool> vb;

#define rep(i, n) for (ll i = 0; i < (n); i++)
#define reps(i, n) for (ll i = 1; i <= (n); i++)
#define rrep(i, n) for (ll i = (n) - 1; i >= 0; i--)
#define rreps(i, n) for (ll i = (n); i >= 1; i--)
#define all(v) (v).begin(), (v).end()

template <class T> void chmin(T& a, T b) { a = min(a, b);}
template <class T> void chmax(T& a, T b) { a = max(a, b);}

constexpr int INF = 1 << 30;
constexpr ll INFL = 1LL << 60;
constexpr ll MOD = 1000000007;
constexpr ld EPS = 1e-12;
constexpr ld PI = 3.14159265358979323846;

void solve() {
    ll n, m;
    cin >> n >> m;

    vvll g(n);
    for(ll i = 0; i < m; i++) {
        ll a, b;
        cin >> a >> b;
        a--, b--;
        g[a].push_back(b);
    }

    ll len = n + 1;
    vll ans;
    for(ll s = 0; s < n; s++) {
        vll dist(n, -1);
        vll prev(n, -1);
        queue<ll> q;
        q.push(s); dist[s] = 0;
        while(!q.empty()) {
            ll v = q.front(); q.pop();
            for(auto nv : g[v]) {
                if(dist[nv] != -1) continue;
                dist[nv] = dist[v] + 1;
                prev[nv] = v;
                q.push(nv);
            }
        }
        for(ll t = 0; t < n; t++) {
            if(s == t || dist[t] == -1) continue;
            for(auto nt : g[t]) {
                if(nt != s) continue;
                ll cur = t;
                vll tmp{(cur)};
                while(cur != s) {
                    cur = prev[cur];
                    tmp.push_back(cur);
                }
                if(tmp.size() < len) {
                    len = tmp.size();
                    ans = tmp;
                }
            }
        }
    }
    if(len == n + 1) {
        cout << -1 << endl;
    }
    else {
        cout << len << endl;
        for(auto i : ans) cout << i + 1 << endl;
    }
    return;
}

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

Measured memory_bytes: 384
using System;
 
namespace Application
{
	class Solution
	{
		static void Main(string[] args)
		{
			var coin500 = int.Parse(Console.ReadLine());
			var coin100 = int.Parse(Console.ReadLine());
			var coin50 = int.Parse(Console.ReadLine());
 
			var sum = int.Parse(Console.ReadLine());
 
			var result = 0;
			for(var i500= 0; i500 <= coin500; i500++)
			{
				for(var i100 = 0; i100 <= coin100; i100++)
				{
					for(var i50 = 0; i50 <= coin50; i50++)
					{
						if (sum == i500 * 500 + i100 * 100 + i50 * 50)
						{
							result++;
						}
					}
				}
			}
 
			Console.WriteLine(result);
		}
	}
}

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

int main(){
    int X, Y, turu, kame;
    cin >> X >> Y;
    if (Y % 2 == 1) {
        cout << "No" << endl;
        return 0;
    }
    turu = 2 * X - Y / 2;
    kame =  Y / 2 - X;
    if ((turu < 0) || (kame < 0)) {
        cout << "No" << endl;
        return 0;
    }
    cout << "Yes" << endl;
    return 0;
}

Measured memory_bytes: 3628
#include <bits/stdc++.h>
using namespace std;
/*int dp(int n,int[] &given)
{
  if(n==1)
    return 0 ;
  if(n==2)
    return given
  if(arr[n]!=-1)
    return arr[n] ;
  
}*/
int solve (int n , vector<int>a) 
{
    int dp[n+1] ;
    dp[1]=0;
    for(int i = 2 ; i<=n;i++)
    {
        int option = (i==2) ? 1e9 : (abs(a[i-2]-a[i])+dp[i-2]) ;
        dp[i] = min((abs(a[i-1]-a[i])+dp[i-1]),option);
    }
    return dp[n] ;
}
int main ()
{
 int n  ;
 cin >> n ; 
 vector<int>a(n+1) ;
 for(int i = 1;i<=n;i++)
 cin >> a[i];
 cout <<solve(n,a)<<endl;
}


Measured memory_bytes: 1408
eval"N,K,C="+gets.split*?,
S=?x+gets
x=-y=1e9
N.downto(1){|i|?o==S[i]&&i+C<y&&$*<<y=i}
$*[K]or puts (1..N).select{|i|?o==S[i]&&x+C<i&&x=i}&$*

Measured memory_bytes: 18424
#include<map>
#include<cstdio>
using namespace std;
const int MOD = int(1E9) + 7;
map<long long, long long>dp;
long long solve(long long n) {
	if( dp.count(n) ) return dp[n];
	else {
		if( n&1 ) {	
			return dp[n] = (solve(n>>1) + solve(n>>1) + solve((n>>1)-1)) % MOD;
		}
		else {
			return dp[n] = (solve(n>>1) + solve((n>>1)-1) + solve((n>>1)-1)) % MOD;
		}
	}
}
int main() {
	long long N;
	scanf("%lld", &N);
	dp[0] = 1, dp[1] = 2;
	printf("%lld\n", solve(N));
}
/*
u ^ v = ( u + v ) - ( u & v )
u^v <= u+v
*/

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <sstream>

#include <string>
#include <vector>
#include <map>
#include <set>
#include <list>
#include <deque>
#include <queue>
#include <stack>

#include <algorithm>
#include <utility>
#include <numeric>
#include <functional>

#include <chrono>
#include <random>

using namespace std;
using i64 = int_fast64_t;
using ui64 = uint_fast64_t;
using vi = vector<int>;
using vvi = vector<vi>;
using vl = vector<i64>;
using vvl = vector<vl>;
using vd = vector<double>;
using vvd = vector<vd>;
using vb = vector<bool>;
using vvb = vector<vb>;
using pii = pair<int, int>;
using pll = pair<i64, i64>;

//////////////////////////////////////////////////

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


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <ctime>
#include <sstream>
#define weewoo ios::sync_with_stdio(false);cin.tie(0)
#define pii pair<int,int>
#define pll pair<ll,ll>
#define ld long double
#define ll long long
#define se second
#define fi first
#define ctoi(x) (x-'0')
#define pi (acos(-1))
#define llputin(a,n) for(int i=0;i<n;i++){ll x;cin >> x;a.push_back(x);}
#define iputin(a,n) for(int i=0;i<n;i++){int x;cin >> x;a.push_back(x);}

#define MOD ((ll) 1e9 + (ll) 7)
using namespace std;

ll pw(ll x,ll a){
    if(a==0)
        return 1;
    ll t = pw(x,a/2);
    if(a%2==0)
        return (t*t);
    else
        return (t*t*x);
}

bool prime(int x)
{
    if(x < 2) return false;
        for(int i=2; i<= sqrt(x); i++) {
            if ((x%i) == 0) return false;
        }
    return true;
}



int main()
{
    weewoo;
    ll a,b,c;
    cin >> a >> b >> c;
    if(a+b+c>=22)
        cout << "bust" << endl;
    else
        cout << "win" << endl;
    return 0;
}


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

int main() {
  // 普通に小さい順に並び替えればいいでしょ
  int n,k; cin>>n>>k;
  vector<int> p(n);
  for(int i=0; i<n; i++) cin>>p[i];
  sort(p.begin(),p.end());

  int ans=0;
  for(int i=0; i<k; i++) {
    ans+=p[i];
  }
  cout << ans << endl;
}


Measured memory_bytes: 3632
#include<stdio.h>
int main(void)
{
	int a,b,c,i,divisor=0;
	scanf("%d%d%d",&a,&b,&c);
	for(i=a;i<=b;i++)
	{
		if(c%i==0)
		{
			divisor++;
		}
	}
	printf("%d\n",divisor);

	return 0;
}



Measured memory_bytes: 2044
#include <iostream>
using namespace std;
int n,m,c;
string a[55],b[55];
int main() {
	int i,j,k,l;
	cin>>n>>m;
	for(i=0; i<n; i++) cin>>a[i];
	for(i=0; i<m; i++) cin>>b[i];
	for(i=0; i<=n-m; i++)
		for(j=0; j<=n-m; j++) {
			c = 0;
			for(k=0; k<m; k++) for(l=0; l<m; l++)
				if(a[i+k][j+l] == b[k][l]) c++;
			if(c == m*m) {cout<<"Yes"; return 0;}
		}
	cout<<"No";
    return 0;
}

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

int main() {
  ll x;
  cin >> x;
  ll ans = 0;
  ll tmp = x / 500;
  ans += tmp * 1000;
  x %= 500;
  tmp = x / 5;
  ans += tmp * 5;
  cout << ans << endl;
}

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

int main() {
	long long h,x=0,p=1;
	cin>>h;
	while(h>1)
	{
		x+=p;
		h=h/2;
		p=p*2;
	}
	x+=p;
	cout<<x;
	return 0;
}

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

int main() {
  int n, m;
  cin >> n >> m;
  vector<P> a(n);
  rep(i,n) {
    ll x;
    int y;
    cin >> x >> y;
    a.at(i)=make_pair(x,y);
  }
  sort(a.begin(),a.end());
  int i=0;
  ll ans=0;
  ll z;
  int w;
  while(m>0) {
    tie(z,w)=a.at(i);
    ans+=z*(ll)(min(w,m));
    m -= w;
    i++;
  }
  cout << ans << endl;
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
ll MOD = 1000000007;
const long long INF = 1LL << 60;

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;}

int N,M;
int dp[100010];

int main()
{   
    cin >> N >> M;
    vector<vector<ll> > G(N,vector<ll>()); //ノード数Nの二次元配列
    vector<int> deg(N,0); //入次数
    
    for(int i=0;i<M;i++){
        int x,y; cin >> x >> y;
        x--;y--;
        G[x].push_back(y);
        deg[y]++;
    }

    //BFSで処理するのでqueueを生成,キューに突っ込むのは入次数が0
    queue<int> q;
    for(int i=0;i<N;i++) if(deg[i] == 0) q.push(i);

    //BFSの実行
    while(!q.empty()){
        int v = q.front(); q.pop();
        for(auto nv:G[v]){
            deg[nv]--;
            if(deg[nv] == 0){
                q.push(nv);
                chmax(dp[nv],dp[v] + 1);
            }
        }
    }
    int res;
    for(int i=0;i<N;i++)res = max(res,dp[i]);
    cout << res << endl;
}
    

Measured memory_bytes: 6528
n, q = map(int, input().split())
l = []
for i in range(n):
    v = input().split()
    l.append([v[0], int(v[1])])

ans = []
t = 0
while len(l) > 0:
    v = l.pop(0)
    v[1] -= q
    if v[1] <= 0:
        t += q+v[1]
        ans.append([v[0], str(t)])
    else:
        t += q
        l.append(v)

for v in ans:
    print(" ".join(v))


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

constexpr int inf = 0x3f3f3f3f;
constexpr ll linf = 0x3f3f3f3f3f3f3f3fLL;

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

    int sx, sy, tx, ty; cin >> sx >> sy >> tx >> ty;
    for (int i = 0; i < tx - sx; i++) cout << 'R';
    for (int i = 0; i < ty - sy; i++) cout << 'U';
    for (int i = 0; i < tx - sx; i++) cout << 'L';
    for (int i = 0; i < ty - sy; i++) cout << 'D';
    cout << 'D';
    for (int i = 0; i < tx - sx + 1; i++) cout << 'R';
    for (int i = 0; i < ty - sy + 1; i++) cout << 'U';
    cout << 'L';
    cout << 'U';
    for (int i = 0; i < tx - sx + 1; i++) cout << 'L';
    for (int i = 0; i < ty - sy + 1; i++) cout << 'D';
    cout << 'R' << '\n';
    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <ctype.h>
#define max(a, b)	(((a) > (b)) ? (a) : (b))		/* ２個の値の最大値 */
#define min(a, b)	(((a) < (b)) ? (a) : (b))		/* ２個の値の最小値 */
#define ENTER		printf("\n")					/* 改行プリント */
int DBG = 1;										/* デバッグプリント 提出時は0 */
/* main *************************************************************/
int main()
{
	int		a,b,c,i,j,k,n,m,x,y,ans = 0;
	
	scanf("%d", &a);

	printf("%d\n",3*a*a);


	return 0;
}


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

int main() {
  ll n;
  cin >> n;
  ll ans = 0;
  if (n % 2 == 0) {
    while (n) {
      ans += n / 10;
      n /= 5;
    }
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 3644
#include <algorithm>
#include <cctype>
#include <climits>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <functional>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <string>
#include <vector>

using namespace std;

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

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

int main()
{
	ll q1, b, c1, c2, q2;
	while(scanf("%lld", &q1), q1){
		scanf("%lld%lld%lld%lld", &b, &c1, &c2, &q2);
		ll ans[2] = {0ll};
		rep(i, q1+1){
			ll cost = i*c1 + (q1-i)*c2;
			if(cost <= b){
				ans[0] = i + (b-cost)/c1;
				ans[1] = q1-i + ((b-cost)%c1)/c2;
			}
		}
		if(ans[0] > q2){
			ans[0] = q2;
			ans[1] = (b-q2*c1)/c2;
		}
		
		if(ans[0] >= 1 && ans[0]+ans[1] >= q1)
			printf("%lld %lld\n", ans[0], ans[1]);
		else
			puts("NA");
	}
	return 0;
}

Measured memory_bytes: 1040
#ifdef LOCAL
#include <cstdio>
#include <vector>
#include <algorithm>
#include <iostream>
#include <cstring>
#else
#include <bits/stdc++.h>
#endif
using namespace std ;

typedef long long ll ;
#define rep(i , n ) for ( int i =0; i < n ; i++)
#define _sort(arg) sort(begin(arg), end(arg))
#define MOD 1000000007
#define INF 1e18
#define pb push_back
#define DEBUG(x) cout << #x << ": " << x << endl;

/*
__attribute__((constructor))
void initial()
{
	cin.tie(NULL);
	ios::sync_with_stdio(false);
}
*/

#if 0
// TLE && MLE
int main()
{
	cin.tie(NULL);
	ios::sync_with_stdio(false);

	int N;
	
	cin >> N;

	ll dist[N][N];
	
	for(size_t i = 0; i < N; i++)
	{
		for(size_t j = 0; j < N; j++)
		{
			dist[i][j] = INF;
		}
	}

	rep(i, N-1)
	{
		int a, b, c;
		cin >> a >> b >> c;
		
		dist[--a][--b] = c;
		dist[b][a] = c;
	}	

	for(size_t k = 0; k < N; k++)
	{
		for(size_t i = 0; i < N; i++)
		{
			/* code */
			for(size_t j = 0; j < N; j++)
			{
				/* code */
				if (dist[i][k] + dist[k][j] < dist[i][j])
				{
					dist[i][j] = dist[i][k] + dist[k][j];
				}
			}
		}
	}

	int Q, K;
	cin >> Q >> K;

	K--;
	
	rep(i, Q)
	{
		int x, y;
		cin >> x >> y;
		//cout << x-1 << " " << dist[x-1][K] << endl;
		//cout << y-1 << " " << dist[K][y-1] << endl;
		cout << dist[--x][K] + dist[K][--y] << endl;
	}
	
	return 0;
}
#endif

class edge
{
public:
	ll cost;
	int to;
	edge(int to, ll cost)
	{
		this->to = to;
		this->cost = cost;
	}
};

ll depth[100010];
vector<edge> tree[100010];
void dfs(int v, int p, ll d)
{
	//cout << v << "; " << p << "; " << d << endl;
	depth[v] = d;
	
	for (auto &e : tree[v])
	{
		if (e.to == p)
		{
			continue;
		}

		dfs(e.to, v, d + e.cost);
	}
}

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

	int N;
	
	cin >> N;

	rep(i, N-1)
	{
		int a , b , c;
		cin >> a >> b >> c;
		a--;
		b--;
		tree[a].push_back(edge(b, c));
		tree[b].push_back(edge(a, c));
	}

	int Q, K;
	cin >> Q >> K;
	K--;

	dfs(K, -1, 0);

	rep(i, Q)
	{
		int x, y;
		cin >> x >> y;

		cout << depth[x-1] + depth[y-1] << endl;
	}


	
	
	return 0;
}



Measured memory_bytes: 14336
#include <bits/stdc++.h>
#include <math.h>
#include <cmath>
using namespace std;
 
#define ll long long

 
int main() {
  
  	ll N;
  	cin >> N;
  
  	set<string> sp;
  	string S;
  
  	 for(ll i=0; i<N; i++){
       	cin >> S;
       	sp.insert(S);
		
    }
  	  	
  	cout << sp.size() << endl;
}

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

#define max(a,b) (((a) < (b)) ? (b) : (a))
int main(void) {
    int a,b,c;

    cin >> a >> b >> c;
    cout << a + b + c - max(a,max(b,c)) << endl;
    return 0;
}


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

char maze[21][21];
int dxdy[4][2]={{1,0},{-1,0},{0,1},{0,-1}};
int maxi=0;
int main(){
    int h,w;
    cin >> h >> w;
    rp(i,h){
        rp(j,w){
            cin >> maze[i+1][j+1];
        }
    }
    
    rp(i,h){
        rp(j,w){
            if(maze[i+1][j+1]=='#') continue;
            else{
                queue<P> point;
                vector<vector<int>> dist(21,vector<int>(21,0));
                point.push(make_pair(i+1,j+1));
                dist[i+1][j+1]=1;
                while(!point.empty()){
                    for(auto d : dxdy){
                        /*cout << "a" <<endl;*/
                        if(point.front().first+d[1]<1||point.front().first+d[1]>h||point.front().second+d[0]<1||point.front().second+d[0]>w) continue;
                        if(maze[point.front().first+d[1]][point.front().second+d[0]]=='.'){
                            if(dist[point.front().first+d[1]][point.front().second+d[0]]==0){
                                dist[point.front().first+d[1]][point.front().second+d[0]]
                                = dist[point.front().first][point.front().second] + 1;
                                /*cout << "b" << endl;*/
                                if(maxi<dist[point.front().first+d[1]][point.front().second+d[0]]){
                                maxi=dist[point.front().first+d[1]][point.front().second+d[0]];
                                /*cout << maxi << endl;*/}
                                point.push(make_pair(point.front().first+d[1],point.front().second+d[0]));
                            }
                        }
                    }
                    point.pop();
                }
            }
        }
    }
    cout << maxi-1 << endl;
    return 0;
}

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

void swap(int *n1, int *n2)
{
  int temp = *n1;
  *n1 = *n2;
  *n2 = temp;
}

int main()
{
  int w, n;
  int a, b;
  int i;
  int *ptr;

  scanf("%d", &w);
  scanf("%d", &n);

  ptr = calloc(n, sizeof(int));

  for (i = 0; i < w; i++) {
    ptr[i] = i + 1;
  }

  for (i = 0; i < n; i++) {
    scanf("%d,%d", &a, &b);
    swap(&ptr[a - 1], &ptr[b - 1]);
  }

  for (i = 0; i < w; i++) {
    printf("%d\n", ptr[i]);
  }

  return 0;
}

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

int main() {
  int R;
  cin >> R;

  if (R < 1200) {
    cout << "ABC" << endl;
  } else if (R < 2800) {
    cout << "ARC" << endl;
  } else {
    cout << "AGC" << endl;
  }
}

Measured memory_bytes: 256
//package Beg_167;
import java.util.*;

public class Main{
	public static void main(String[] args) {
		Scanner a = new Scanner(System.in);
		String s1 = a.nextLine();
		String s2=a.nextLine();
		if ((s1.substring(0,s1.length()-1).equals(s2)) || (s2.substring(0,s2.length()-1).equals(s1))) {
			System.out.println("Yes");
		}
		else {
			System.out.println("No");
		}
		
a.close();
	}
}

Measured memory_bytes: 35576
#include<bits/stdc++.h>
using namespace std;
inline int read()
{
    int x=0,f=1;char ch=getchar();
    while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}
    while(ch>='0'&&ch<='9'){x=x*10+ch-'0';ch=getchar();}
    return x*f;
}
typedef long long ll;
const int maxn = 1e5 +7;
ll a[maxn];
int main()
{
    int n = read();
    for(int i=1;i<=n;i++) a[i] = read();
    ll ans = 1, flag = 0;
    sort(a+1,a+n+1);
    for(int i=n;i>=1;i--)
    {
        if(a[i]==a[i-1])
            ans *= a[i], flag++,i--;
        if(flag==2) break;
    }
    return !printf("%lld\n",flag==2?ans:0);
}

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

public class Main {

    public static void main(String[] args) throws Exception {
        try (Scanner sc = new Scanner(System.in)) {
            int N = sc.nextInt();
            int M = sc.nextInt();

            int[] A = new int[M];
            int[] B = new int[M];
            int[] C = new int[M];
            for (int i = 0; i < M; i++) {
                A[i] = sc.nextInt();
                B[i] = sc.nextInt();
                int c = 0;
                for (int j = 0; j < B[i]; j++) {
                    c += 1 << (sc.nextInt() - 1);
                }
                C[i] = c;
            }

            long[][] dp = new long[M + 1][1 << N];
            Arrays.fill(dp[0], Long.MAX_VALUE);
            dp[0][0] = 0;

            for (int i = 1; i <= M; i++) {
                System.arraycopy(dp[i - 1], 0, dp[i], 0, dp[i].length);

                for (int j = 0; j < (1 << N); j++) {
                    if (dp[i - 1][j] != Long.MAX_VALUE) {
                        int k = (j | C[i - 1]);
                        dp[i][k] = Math.min(dp[i][k], dp[i - 1][j] + A[i - 1]);
                    }
                }
            }

            long ans = dp[M][(1 << N) - 1];

            System.out.println(ans == Long.MAX_VALUE ? -1 : ans);
        }
    }

}


Measured memory_bytes: 65276
import java.util.*;
public class Main 
{
	public static void main(String[] args) 
	{
		Scanner stdIn = new Scanner(System.in);
		while(stdIn.hasNext())
		{
			int n = stdIn.nextInt();
			if(n == -1)
			{
				break;
			}
			double x = 0;
			double y = 0;
			double angle = 0;
			while(n-- != 0)
			{
				x += Math.cos(angle);
				y += Math.sin(angle);
				angle = Math.PI / 2 + Math.atan2(y, x);
			}
			System.out.println(x);
			System.out.println(y);
		}
	}
}

Measured memory_bytes: 12000
import java.io.PrintStream;
import java.util.Scanner;

public class Main {
	static final PrintStream out = System.out;
	static final Scanner sc = new Scanner(System.in);
	static final long Mod = 1000_000_007L;
	public static void main(String[] args) {
		Main main = new Main();
		main.solve();
		System.exit(0);
	}

	void solve() {
		int N = nextInt();
		int odd = 0;
		if(N % 2 == 0) {
			odd += N / 2;
		}else {
			odd += N / 2 + 1;
		}
		int even = N / 2;

		double res = (double)odd / N;
		out.println(res);
	}

	public int nextInt() {
		return Integer.parseInt(next());
	}
	public long nextLong() {
		return Long.parseLong(next());
	}
	public String next() {
		return sc.next();
	}

}

Measured memory_bytes: 22996
(defun divide (demands)
  (let ((l 1)
        (cnt 0))
    (loop
      for (a . b) in (sort demands (lambda (c1 c2) (< (cdr c1) (cdr c2))))
      do (when (<= l a)
           (setf l b)
           (incf cnt)))
    cnt))

(defun main ()
  (let* ((n (read))
         (m (read))
         (d (loop repeat m collect (cons (read) (read)))))
    (format t "~a~%" (divide d))))

(main)

Measured memory_bytes: 61928
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.*;

public class Main {
	static final long MOD=1000000007;//998244353;
	public static void main(String[] args) {
		PrintWriter out = new PrintWriter(System.out);
		InputReader sc=new InputReader(System.in);
		long N=sc.nextLong();
		long ans=0;
		for (long i = 1; i <= N; i++) {
			ans+=i*(N-i+1);
		}
		for (int i = 0; i < N-1; i++) {
			long a=sc.nextLong();
			long b=sc.nextLong();
			if (a>b) {
				long c=a;
				a=b;
				b=c;
			}
			ans-=a*(N-b+1);
		}
		System.out.println(ans);
 	}
	static class InputReader { 
		private InputStream in;
		private byte[] buffer = new byte[1024];
		private int curbuf;
		private int lenbuf;
		public InputReader(InputStream in) {
			this.in = in;
			this.curbuf = this.lenbuf = 0;
		}
 
		public boolean hasNextByte() {
			if (curbuf >= lenbuf) {
				curbuf = 0;
				try {
					lenbuf = in.read(buffer);
				} catch (IOException e) {
					throw new InputMismatchException();
				}
				if (lenbuf <= 0)
					return false;
			}
			return true;
		}
 
		private int readByte() {
			if (hasNextByte())
				return buffer[curbuf++];
			else
				return -1;
		}
 
		private boolean isSpaceChar(int c) {
			return !(c >= 33 && c <= 126);
		}
 
		private void skip() {
			while (hasNextByte() && isSpaceChar(buffer[curbuf]))
				curbuf++;
		}
 
		public boolean hasNext() {
			skip();
			return hasNextByte();
		}
 
		public String next() {
			if (!hasNext())
				throw new NoSuchElementException();
			StringBuilder sb = new StringBuilder();
			int b = readByte();
			while (!isSpaceChar(b)) {
				sb.appendCodePoint(b);
				b = readByte();
			}
			return sb.toString();
		}
 
		public int nextInt() {
			if (!hasNext())
				throw new NoSuchElementException();
			int c = readByte();
			while (isSpaceChar(c))
				c = readByte();
			boolean minus = false;
			if (c == '-') {
				minus = true;
				c = readByte();
			}
			int res = 0;
			do {
				if (c < '0' || c > '9')
					throw new InputMismatchException();
				res = res * 10 + c - '0';
				c = readByte();
			} while (!isSpaceChar(c));
			return (minus) ? -res : res;
		}
 
		public long nextLong() {
			if (!hasNext())
				throw new NoSuchElementException();
			int c = readByte();
			while (isSpaceChar(c))
				c = readByte();
			boolean minus = false;
			if (c == '-') {
				minus = true;
				c = readByte();
			}
			long res = 0;
			do {
				if (c < '0' || c > '9')
					throw new InputMismatchException();
				res = res * 10 + c - '0';
				c = readByte();
			} while (!isSpaceChar(c));
			return (minus) ? -res : res;
		}
 
		public double nextDouble() {
			return Double.parseDouble(next());
		}
 
		public int[] nextIntArray(int n) {
			int[] a = new int[n];
			for (int i = 0; i < n; i++)
				a[i] = nextInt();
			return a;
		}
 
		public long[] nextLongArray(int n) {
			long[] a = new long[n];
			for (int i = 0; i < n; i++)
				a[i] = nextLong();
			return a;
		}
 
		public char[][] nextCharMap(int n, int m) {
			char[][] map = new char[n][m];
			for (int i = 0; i < n; i++)
				map[i] = next().toCharArray();
			return map;
		}
	}
}


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

B = [(0, 0)] * (N + 1)
B[N] = (2, 2)

for i in range(N - 1, -1, -1):
  min_next, max_next = B[i + 1]
  
  min_left = -1
  min_right = 10 ** 15
  
  while min_left + 1 < min_right:
    min_mid = (min_left + min_right) // 2
    mid_next = min_mid // A[i] * A[i]
    if mid_next >= min_next:
      min_right = min_mid
    else:
      min_left = min_mid
  
  max_left = 0
  max_right = 10 ** 15
  
  while max_left + 1 < max_right:
    max_mid = (max_left + max_right) // 2
    mid_next = max_mid // A[i] * A[i]
    if mid_next >= max_next + 1:
      max_right = max_mid
    else:
      max_left = max_mid
  
  if  min_right == 0 or max_left == 0 or max_left < min_right:
    print(-1)
    exit()
  else:
    B[i] = (min_right, max_left)

print(*B[0])

Measured memory_bytes: 63984
import java.util.Scanner;
 
public class Main {
    public static void main(String args[]){
        Scanner stdIn = new Scanner(System.in);
 
        int a = stdIn.nextInt();
        int b = stdIn.nextInt();
        //int c = stdIn.nextInt();
        //int x = stdIn.nextInt();
        //int num[] = new int[];
        //String s = stdIn.next();
        //String t = stdIn.next();
        //char c[] = s.toCharArray();
        
        //c[0] += 1;
        //int sum = 0;
        //boolean flag = true;
        //for(int i = 0; i < s.length(); i++){
        //}
        
        if(a == b){
            System.out.println("Yes");
        }else{
            System.out.println("No");
        }
        
 
        //System.out.println();
        //System.out.print();
 
        stdIn.close();
    }
}

Measured memory_bytes: 23124
#include<cstdio>
#include<cstring>
#include<iostream>
using namespace std;
char c[30],d[30];
int vc[30],vt[30];
int main()
{
    memset(vc,0,sizeof(vc));
    memset(vt,0,sizeof(vt));
    string s,t;
    cin>>s>>t;
    bool flag=1;
    for(int i=0; i<s.size(); i++)
    {
        int x=s[i]-'a', y=t[i]-'a';;
        if(!vc[x])
            vc[x]=1,c[x]=t[i];
        else if(c[x]!=t[i])
        {
            flag=0;
            break;
        }
        if(!vt[y])
            vt[y]=1,d[y]=s[i];
        else if(d[y]!=s[i])
        {
            flag=0;
            break;
        }
    }
    if(flag)
        cout<<"Yes"<<endl;
    else
        cout<<"No"<<endl;
}


Measured memory_bytes: 776
#include<iostream>
#include<algorithm>

using namespace std;

int main(){

	int n,c[4];
	int sum;
	int data[]={10,50,100,500};
	bool f=false;

	while(1){

		cin>>n;
		if(n==0) break;
		if(f) cout<<endl;
		f=true;

		sum=0;
		for(int i=0;i<4;i++){
			cin>>c[i];
			sum+=c[i]*data[i];
		}
		
		sum-=n;

		for(int i=3;i>=0;i--){
			c[i]-=min(c[i],sum/data[i]);
			sum%=data[i];
		}

		for(int i=0;i<4;i++){
			if(c[i]!=0) cout<<data[i]<<" "<<c[i]<<endl;
		}
	}

}

Measured memory_bytes: 1160
#include <iostream>
#include <string>
#include <vector>
#include <math.h>
#include <algorithm> // swap
#include <map>
#include <utility> // pair

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

using namespace std;

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

	int a[2][100];
	int N;
	int result[100];
	REP(i, 100) result[i] = 0;

	cin >> N;
	REP(i, N) cin >> a[0][i];
	REP(i, N) cin >> a[1][i];

	REP(i, N) {
		for (int j = 0; j < N; ++j) {
			if (j < i) {
				result[i] += a[0][j];
			}
			else if (j == i) {
				result[i] += a[0][i];
				result[i] += a[1][i];
			}
			else {
				result[i] += a[1][j];
			}
//			cout << result[i] << " ";
		}
	//	cout << endl;
	}

	int max = 0;
	REP(i, N) {
		if (max < result[i]) max = result[i];
	}

	cout << max;

	system("pause");
	return 0;
}

Measured memory_bytes: 504
import math
from functools import reduce
n, m = map(int, input().split())
A = list(map(int, input().split()))

a0 = A[0]
cnt = 0
while a0%2 == 0:
    a0 //= 2
    cnt += 1

a = []
for aa in A:
    if cnt == 1:
        if aa%4 == 0:
            print(0)
            exit()
    else:
        if aa%(2**(cnt-1)) != 0 or aa%(2**cnt) != 0 or aa%(2**(cnt+1)) == 0:
            print(0)
            exit()
    a.append(aa//2)


def lcm_base(p, q):
    return (p * q) // math.gcd(p, q)


def lcm_list(numbers):
    return reduce(lcm_base, numbers, 1)


lcm = lcm_list(a)
print(m//lcm - m//(lcm*2))

Measured memory_bytes: 21304
#include <bits/stdc++.h>
using namespace std;
    
#define int long long int
#define vi vector<int>
#define vvi vector<vi>
#define read(a)  for(int i = 0; i < n; i++) cin >> a[i];
#define print(a)  for(int i = 0; i < n; i++) cout << a[i] << " ";
#define pb push_back
#define pql priority_queue<int>
#define pqs priority_queue<int, vi, greater<int>>
#define pqlv priority_queue<vi>
#define pqsv priority_queue<vi, vvi, greater<vi>>
#define endl '\n'
#define N 10000002
#define MOD 1000000007

signed main() {
    int n;
    cin >> n;
    vi a(n);
    for(int i = 0; i < n; i++) {
        cin >> a[i];
    }
    vi p(n), s(n);
    p[0] = a[0];
    for(int i = 1; i < n; i++) {
        p[i] = __gcd(p[i - 1], a[i]);
    }
    s[n - 1] = a[n - 1];
    for(int i = n - 2; i >= 0; i--) {
        s[i] = __gcd(s[i + 1], a[i]);
    }
    int ans = max(p[n - 2], s[1]);
    for(int i = 1; i < n - 1; i++) {
        ans = max(ans, __gcd(p[i - 1], s[i + 1]));
    }
    cout << ans << endl;
}

Measured memory_bytes: 2560
#include<bits/stdc++.h>
using namespace std;
int main(){
    int N;
    cin>>N;
    string S;
    cin>>S;
    int count=1;
    if(N==0){
        cout<<0<<endl;
        return 0;
    }
    for(int i=1;i<N;i++){
        if(S[i]!=S[i-1]){
            count++;
        }
    }
    cout<<count<<endl;
}

Measured memory_bytes: 512
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <math.h>
#include <iomanip>
#include <map>
using namespace std;

#define INF 1e9
#define LLINF 1e18
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
typedef long long ll;


int main() {
    int x, a, b;
    cin >> x >> a >> b;
    if (b - a <= 0) {
        cout << "delicious" << endl;
    }
    else if (b - a > x) {
        cout << "dangerous" << endl;
    }
    else cout << "safe" << endl;
}

Measured memory_bytes: 256
import java.text.DecimalFormat;
import java.util.Scanner;

public class Main{
	private static Scanner scan;
	public static void main(String[] args) {
		scan = new Scanner(System.in);
		 DecimalFormat df=new DecimalFormat();
		 df.applyPattern("0");
		 df.setMaximumFractionDigits(3);
	     df.setMinimumFractionDigits(3);
		while(scan.hasNext()){
			double a[] = new double[6];
			for(int i=0;i <=5;i++){
				 a[i] = Double.parseDouble(scan.next());
			}
			double ans1,ans2;
			String result1,result2;
			ans1 = (a[1]*a[5] - a[2]*a[4]) / (a[1]*a[3] - a[0]*a[4]);
			ans2 = (a[0]*a[5] - a[2]*a[3]) / (a[0]*a[4] - a[1]*a[3]);
			if(ans1==0)ans1=0;
			if(ans2==0)ans2=0;
			Double objnum1=new Double(ans1);
			Double objnum2=new Double(ans2);
			result1=df.format(objnum1);
			result2=df.format(objnum2);
			System.out.println(result1+" "+result2);
		}
		System.exit(0);
	}
}

Measured memory_bytes: 12000
/** author: __nishad__ **/
//#pragma GCC optimize(2)
//#pragma GCC optimize(3, "Ofast", "inline")
#include<bits/stdc++.h>
using namespace std;


typedef long long ll ;
typedef vector<ll> vll ;

#define IOS ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define all(v) (v).begin(),(v).end()
#define precision(k) cout<<setprecision(k)<<fixed;
#define loop(i,a,b) for(int i=(a);i<(b);++i)
#define minv(v) *min_element(all(v))
#define maxv(v) *max_element(all(v))
#define getpos(v,x) (lower_bound(v.begin(),v.end(),x)-v.begin())
#define unq(v) sort(all(v)),(v).erase(unique((v).begin(),(v).end()),(v).end())
#define pb push_back
#define mp make_pair
#define pi 3.14159265358979323
#define endl "\n"

int main()
{
    IOS;

    int o, p;
    char ch;
    cin>>o>>p;

    int arr[o][p];

    loop(i, 0, o){
        loop(j, 0, p){
            cin>>ch;
            if(ch == '.')
                arr[i][j] = 1;
            else if(ch == '#')
                arr[i][j] = 11;
        }
    }

    loop(i, 0, o){
        loop(j, 0, p){
            if(arr[i][j] == 1){
            int count = 0;
                for(int m = i-1; m <=i+1; m++){
                    for(int n = j-1; n <= j+1; n++){
                        if(m>-1 && n>-1 && m<o && n<p){
                            if(arr[m][n] == 11)
                                count++;
                            else
                                count = count;
                        }
                    }
                }
                arr[i][j] = count;
            }

        }
    }

    loop(i, 0, o){
        loop(j, 0, p){
            if(arr[i][j] == 11)
                cout<<"#";
            else
                cout<<arr[i][j];
        }
        cout<<endl;
    }


}





























Measured memory_bytes: 3520
#include <stdio.h>
#define N 100

int main(){
  int i,j,k,A[N],n,v;
  
  scanf("%d",&n);
  
  for(i=0;i<n;i++) scanf("%d",&A[i]);
  for(k=0;k<n;k++) {
    if(k<n-1)printf("%d ",A[k]);
    else printf("%d",A[k]);
  }
  printf("\n");
  for(i=1;i<n;i++){
    v=A[i];
    j = i-1;
    
    while(j>=0 &&A[j]>v){
      A[j+1]=A[j];
      j--;
      A[j+1]=v;
    }
    for(k=0;k<n;k++){
      if(k<n-1)printf("%d ",A[k]);
      else printf("%d",A[k]);
    }
    printf("\n");
    
  }
  return 0;
}

Measured memory_bytes: 604
#include "bits/stdc++.h"
using namespace std;
#define ll long long int
#define rep(i,n) for( int i = 0; i < n; i++ )
#define rrep(i,n) for( int i = n; i >= 0; i-- )
#define REP(i,s,t) for( int i = s; i <= t; i++ )
#define RREP(i,s,t) for( int i = s; i >= t; i-- )
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define INF 2000000000
#define mod 1000000007
#define INF2 1000000000000000000


int main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int X; cin >> X;
    int x = 0;
    int t = 0;
    while(x < X) {
        t++;
        x += t; 
    }
    cout << t << endl;

    return 0;
}


Measured memory_bytes: 256
n = int(input())
data = list(map(int, input().split(" ")))
count = [0]*(n+1)
for i in range(n):
    count[data[i]] = count[data[i]]+1

val = [0]*(n+1)
sumval = 0
for i in range(n+1):
    if(count[i] >= 2):
        val[i] = count[i]-1
        sumval = sumval + int(count[i]*(count[i]-1)/2)

for i in range(n):
    print(sumval - val[data[i]])

Measured memory_bytes: 26140
#include <iostream>
#include <fstream>
#include <string>
#include <cmath>
#include <cstdio>
#include <algorithm>
#include <iomanip>
#include <vector>
#include <utility>
#include <numeric>
#include <stack>
#include <queue>
#define INF 1000000007
using namespace std;
using P = pair<int, int>;
using ll = long long;
int main(){
    int n,d;
    cin>>n>>d;
    int o=d*2+1;
    if(n%o==0)cout<<n/o;
    else cout<<n/o+1<<endl;
    return 0;
}


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

const int MOD = 998244353;

int main(){
    int N, K;
    cin >> N >> K;

    set<long long> s;
    vector<long long> l(K);
    vector<long long> r(K);

    for(long long i=0; i<K; ++i){
        cin >> l[i] >> r[i];
    }

    vector<long long> dp(N+10);
    vector<long long> dp_sum(N+10);

    dp[1] = 1;
    dp_sum[1] = 1;

    for(int i=2; i < N+10; ++i){
        for(int j=0; j<K; ++j){
            int li = i - r[j];
            int ri = i - l[j];
            if(ri < 0) continue;
            li = max(1, li);
            long long tmp = dp_sum[ri] - dp_sum[li-1];
            if(tmp < 0) tmp += MOD;
            dp[i] += tmp;
            dp[i] %= MOD;
        }
        dp_sum[i] += dp_sum[i-1] + dp[i];
        dp_sum[i] %= MOD;
    }

    cout << dp[N] << endl;
}

Measured memory_bytes: 6436
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define rep(i,n) for(ll i=0;i<n;i++)
#define P pair<ll,ll>
#define Graph vector<vector<ll>>
#define INF (1ll<<60)
#define mod 1000000007
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;}

int main(){
    string s;cin>>s;
    s.push_back('#');//sentinel

    ll g=0,p=0;
    ll num=1;
    rep(i,s.size()-1){
        if(s[i]==s[i+1]){
            num++;
        }else{
            if(s[i]=='g') g+=num;
            else p+=num;
            num=1;
        }
    }

    cout<<(g-p)/2<<endl;

    return 0;
}

Measured memory_bytes: 512
#include <iostream>
#include <cstdio>
#include <string>
#include <vector>
#include <array>
#include <algorithm>
#include <list>
#include <iomanip>
#include <queue>
#include <functional>
#include <cassert>
#include <cmath>
#include <set>
#include <map>
#include <numeric>

#define rep(i, n) for(int i = 0; i < (n); i++)
#define repe(i, n) for(int i = 0; i <= (n); i++)
#define fo(i, a, b) for(int i = (a); i < (b); i++)
#define foe(i, a, b) for(int i = (a); i <= (b); i++)
#define NL << endl

using namespace std;
using ll = long long;
const int INTMAX = numeric_limits<int>::max();
const int INTMIN = numeric_limits<int>::min();
const ll LLMAX = numeric_limits<long long>::max();
const ll LLMIN = numeric_limits<long long>::min();
const int MOD = 1000000007;
int gcd(int a, int b) { return b ? gcd(b, a%b) : a; }

using namespace std;

int main() {

	string s;

	cin >> s;

	rep(i, s.size()) {
		cout << ((s[i] == '1') ? '9' : '1');
	}
	cout NL;


	return 0;

}


Measured memory_bytes: 256
#include <array>
#include <cstdlib>
#include <iostream>
#include <unordered_map>
#include <vector>
using namespace std;

template<typename T> inline void chmin(T& a, const T& b) { if(a > b) a = b; }

inline int update(const unordered_multimap<int, int>& idx, vector<int>& cnt, int card, int size) {
	int res = 0;
	auto range = idx.equal_range(card);
	while(range.first != range.second) {
		if(++cnt[range.first->second] == size) ++res;
		++range.first;
	}

	return res;
}

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

	constexpr int RABBIT = 0;
	constexpr int CAT = 1;

	int n, m;
	array<int, 2> win;
	cin >> n >> win[RABBIT] >> win[CAT] >> m;

	unordered_multimap<int, int> row[2], col[2], dia[2];
	vector<vector<int>> row_cnt(2, vector<int>(n, 0)), col_cnt(2, vector<int>(n, 0)), dia_cnt(2, vector<int>(2, 0));

	for(int k = 0; k < 2; ++k) {
		for(int i = 0; i < n; ++i) {
			for(int j = 0; j < n; ++j) {
				int number;
				cin >> number;
				row[k].insert(make_pair(number, i));
				col[k].insert(make_pair(number, j));
				if(i == j) dia[k].insert(make_pair(number, 0));
				if(i + j == n - 1) dia[k].insert(make_pair(number, 1));
			}
		}
	}

	int result = 0;
	array<int, 2> num;
	num.fill(0);

	while(m--) {
		int card;
		cin >> card;

		for(int k = 0; k < 2; ++k) {
			num[k] += update(row[k], row_cnt[k], card, n);
			num[k] += update(col[k], col_cnt[k], card, n);
			num[k] += update(dia[k], dia_cnt[k], card, n);
			if(n == 1) chmin(num[k], 1);
			if(num[k] >= win[k]) result |= (1 << k);
		}

		if(result) break;
	}

	switch(result) {
	case (1 << RABBIT): cout << "USAGI" << endl; break;
	case (1 << CAT):    cout << "NEKO"  << endl; break;
	default:            cout << "DRAW"  << endl; break;
	}

	return EXIT_SUCCESS;
}

Measured memory_bytes: 27884