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

int main(){
	string a, b;
	cin >> a >> b;
	string c = a+b;
	istringstream tmp(c);
	int d;
	tmp >> d;
	//cout << fmod(sqrt(d), 1) << endl;

	if( !fmod(sqrt(d), 1) )
		cout << "Yes" << endl;
	else
		cout << "No" << endl;
	return 0;
}

Measured memory_bytes: 384
fun solv(idx: Int, ab: Array<Int>): Array<Int>{
    val from = idx % 2
    val to = (idx + 1) % 2
    ab[to] += ab[from] / 2
    ab[from] /= 2
    return ab
}

fun main(args: Array<String>) {
    val (a,b,k) = readLine()!!.split(" ").map(String::toInt)
    var ab = arrayOf(a,b)
    for (i in 0 until k) {
        ab = solv(i,ab)
    }
    println(ab[0].toString() + " " + ab[1].toString())
}

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

int main(){
    int A,B,C,D;
    cin >> A >> B >> C >> D;

    if(A+B > C+D) {
        cout << "Left" << endl;
    }

    else if(A+B == C+D){
        cout << "Balanced" << endl;
    }
    
    else{
        cout << "Right" << endl;
    }
}

Measured memory_bytes: 3636
#include <iostream>
using namespace std;
int main()
{
    int k,gcd,x,y,s,x1,y1,s1,s2;
    cin >> k;
    int p[k+2][k+2];
    int q[k+2][k+2][k+2];
    long long count;
    count=0;
    

    for (int a=1;a<=k+1;a++){
        for(int b=1;b<=k+1;b++){
            x=b;
            y=a;

            while(x%y!=0){
                s=x%y;
                x=y;
                y=s;
            }
            p[a][b]=y;
        }
    }
    for (int a=1;a<=k;a++){
        for (int b=1;b<=k;b++){
            for(int c=1;c<=k;c++){
                x1=c;
                y1=p[a][b];
                if(x1>=y1){
                    while(x1%y1!=0){
                        s1=x1%y1;
                        x1=y1;
                        y1=s1;

                    }
                    q[a][b][c]=y1;
                }else if(x1<=y1){
                    while(y1%x1!=0){
                        s2=y1%x1;
                        y1=x1;
                        x1=s2;
                    }
                    q[a][b][c]=x1;
                }
                count=count+q[a][b][c];
            }

        }
    }
    

    cout <<""<<count;
    return 0;


}



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

using namespace std;

const int MAX = 1e5 + 10;

int main()
{
	int n,m; cin>>n>>m;
	int a[MAX],can[MAX]={0};
	for(int i=1;i<=n;i++) a[i]=1;
	can[1]=1;
	for(int i=0;i<m;i++) {
		int x,y; cin>>x>>y;

		if(can[x] and a[x] > 0) can[y]=1;

		a[x]--; a[y]++; 

		if(a[x]==0) can[x]=0;
	}	

	int ans=0;

	for(int i=1;i<=n;i++) ans += (can[i]==1);

	cout<<ans<<endl;	

}

Measured memory_bytes: 1024
#include<bits/stdc++.h> 
using namespace std; 
 
#define fast ios_base::sync_with_stdio(false); cin.tie(NULL);
#define lli long long int
#define ld long double
#define pb push_back
#define pf push_front
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define pll pair<lli,lli>
#define ve vector<lli>
#define vep vector<pair<lli,lli> >
#define fr(i,a,n) for(lli i=a;i<(n);i++)
#define frj(j,a,n) for(lli j=a;j<(n);j++)
#define frx(i,a,n) for(lli i=a;i>(n);i--)
#define frxj(j,a,n) for(lli j=a;j>(n);j--)
#define lb lower_bound
#define ub upper_bound
#define F first
#define S second
#define db(x) cout << "[ " << x << " ]" << endl;
#define dbarr(arr,a,n) {fr(i,0,n) cout<<arr[i]<<" "; cout<<endl;}


int main() {
    lli n;
    cin>>n;
    ve a,b;
    fr(i,0,n){
        lli x,y;
        cin>>x>>y;
        a.pb(x+y);
        b.pb(x-y);
    }
    sort(all(a));
    sort(all(b));
    lli ans=max(a[n-1]-a[0],b[n-1]-b[0]);
    cout<<ans;
}

Measured memory_bytes: 6620
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner in = new Scanner(new BufferedReader(new InputStreamReader(System.in)));
		int n = in.nextInt();
		int k = in.nextInt();
		int[] h = getIntArr(in, n);
		int r = solve(n, k, h);
		System.out.println(r);
		in.close();
	}

	private static int solve(int n, int k, int[] h) {
		int[] state = new int[h.length];
		Arrays.fill(state, Integer.MAX_VALUE);
		state[0] = 0;
		for (int i = 0; i < h.length; i++) {
			for (int j = 1; j <= k && i + j < n; j++) {
				state[i + j] = Math.min(state[i + j], state[i] + Math.abs(h[i] - h[i + j]));
			}
		}
		return state[state.length - 1];
	}

	static int[] getIntArr(Scanner in, int size) {
		int[] arr = new int[size];
		for (int i = 0; i < size; i++) {
			arr[i] = in.nextInt();
		}
		return arr;
	}

	static int[][] getIntArr(Scanner in, int row, int col) {
		int[][] arr = new int[row][];
		for (int i = 0; i < row; i++) {
			arr[i] = getIntArr(in, col);
		}
		return arr;
	}

	static char[] getCharArr(Scanner in, int size) {
		char[] arr = in.next().toCharArray();
		return arr;
	}

	static String[] getStringArr(Scanner in, int size) {
		String[] arr = new String[size];
		for (int i = 0; i < size; i++) {
			arr[i] = in.next();
		}
		return arr;
	}

	static Map<Integer, List<Integer>> getEdges(Scanner in, int size, boolean directed) {
		Map<Integer, List<Integer>> edges = new HashMap<>();
		for (int i = 0; i < size; i++) {
			int from = in.nextInt();
			int to = in.nextInt();
			if (!edges.containsKey(from)) {
				edges.put(from, new ArrayList<Integer>());
			}
			edges.get(from).add(to);
			if (!directed) {
				if (!edges.containsKey(to)) {
					edges.put(to, new ArrayList<Integer>());
				}
				edges.get(to).add(from);
			}

		}
		return edges;
	}
}


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

int main(){
    int N, i, j, k;
    char s[210000];
    char ss[210000];
    int len, lenss;
    long long tmpa, ans;

    scanf("%s", &s);
    len = strlen(s);
    j=0;
    for(i=1; i<len; i++){
        if(s[i-1]=='B'&& s[i]=='C'){
            ss[j]='D';
            i++;
        }else{
            ss[j]=s[i-1];
        }
        j++;
    }
    lenss = j;
    tmpa=0;
    ans =0;

    for(i=0; i<lenss; i++){
        if(ss[i]=='A'){
            tmpa++;
        }else if(ss[i]=='D' && tmpa>0){
            ans+= tmpa;
            //tmpa=1;
        }else{
            tmpa=0;
        }
        //printf("%d", ans);
    }

    //printf("\n%s\n", ss);
    printf("%lld", ans);

    return 0;
}

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

using namespace std;

int main()
{
	while(true)
	{
		int x = 0, y = 0, count = 0;;

		cin >> x >> y;

		if(x == 0 && y == 0)
		{
			return false;
		}

		if(x < y)
		{
			swap(x, y);
		}

		for(count = 0; y != 0; count++)
		{
			x = x % y;

			swap(x, y);
		}

		cout << x << ' ' << count << endl;
	}
}

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

int main(){
   int A,B,C,K;
   cin>>A>>B>>C>>K;
   int count=0;
   int sum=0;
   rep(i,K){
       if(A>0){
           sum++;
           A--;
       }else if(B>0){
           B--;
       }else if(C>0){
           sum--;
           C--;
       }
   }
   cout<<sum<<endl;
    return 0;
}

Measured memory_bytes: 3496
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define LLMAX (1ll << 60) - 1
#define INTMAX (1 << 30) - 1
#define MOD 1000000007 
#define NMAX 1000*100+1

#define numberOfSetBits(S) __builtin_popcount(S) // __builtin_popcountl(S) __builtin_popcountll(S)
#define MSET(x,y) memset(x,y,sizeof(x))
#define gcd(a,b) __gcd(a,b)
#define all(x)  x.begin(),x.end()
#define isOn(S, j) (S & (1 << j))
#define setBit(S, j) (S |= (1 << j))
#define clearBit(S, j) (S &= ~(1 << j))
#define toggleBit(S, j) (S ^= (1 << j))
#define print(x)    for(auto it=x.begin();it!=x.end();it++) cout<<*it<<' '; cout<<endl;
#define printii(x)  for(auto it=x.begin();it!=x.end();it++) cout<<*it.F<<' '<<*it.S<<'\t';  cout<<endl;
#define in(x,n)   for(int e=0;e<n;e++){ll y;cin>>y;x.pb(y);}

#define vi vector<ll>
#define vvi vector<vi>
#define ii pair<ll,ll>
#define pll pair<ll,ll>
#define vii vector<ii>
#define viii vector<pair<ii,ll>>
#define pb push_back
#define F first
#define S second
#define mp make_pair
#define mc(a,b,c) mp(mp(a,b),c)
vi a;
ll dp[103][4][2];

ll func(int x, int k, int m){
	if(k<0){
		return 0;
	}

	if(x==a.size()){
		if(!k){
			return 1;
		}
		else{
			return 0;
		}
	}
	
	if(dp[x][k][m]!=-1){
		return dp[x][k][m];
	}
	ll ans = 0;
	if(m==1){
		for(int i=0;i<10;i++){
		    ans+=func(x+1,k-(i!=0),1);
		}
	}
	else{
		for(int i=0;i<=a[x];i++){
		    ans+=func(x+1,k-(i!=0),(i!=a[x]));
		}
	}
	return dp[x][k][m] = ans;
}

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	ll n,x,t,m,k;
	string s;
	cin>>s;
	for(int i=0;i<s.size();i++){
		a.pb(s[i]-'0');
	}
	MSET(dp,-1);
	cin>>k;
	cout<<func(0,k,0);
	return 0;
}






Measured memory_bytes: 256
n = int(input())
A = [int(i) for i in input().split()]

even = [A[i] for i in range(n) if i % 2 == 0]

odd = [A[i] for i in range(n) if i % 2 != 0]


if n % 2 == 0:
    odd.reverse()
    c = odd+even
else:
    even.reverse()
    c = even+odd
    
print(' '.join([str(i) for i in c]))

Measured memory_bytes: 31300
# -*- coding: utf-8 -*-
class FactMod():
    '''
    modの値が素数の時のfactと組み合わせを求める
    フェルマーの小定理を用いているため、modが素数以外の時は使えない
    '''

    def __init__(self, n, mod):
        '''
        コンストラクタ
        f:nまでの i!の値を　配列に入れる
        inv: (i!)^-1　の値を配列に入れる
        '''
        self.mod = mod
        self.f = [1]*(n+1)
        for i in range(1, n+1):
            self.f[i] = self.f[i-1]*i % mod

        self.inv = [pow(self.f[-1], mod-2, mod)]
        for i in range(1, n+1)[::-1]:
            self.inv.append(self.inv[-1]*i % mod)
        self.inv.reverse()

    def fact(self, n):
        '''
        n!の値を返す
        '''
        return self.f[n]

    def comb(self, n, r):
        '''
        nCrの値を返す
        '''
        ret = self.f[n] * self.inv[n-r]*self.inv[r]
        ret %= self.mod
        return ret

    def perm(self, n, r):
        """
        nPrの値を返す
        """
        ret = self.f[n] * self.inv[n-r]
        ret %= self.mod
        return ret


N, K = map(int, input().split())
L = list(map(int, input().split()))
L = sorted(L)
MOD = 10**9+7
F = FactMod(N+1, MOD)

print(sum([(L[i]-L[N-i-1]+MOD)*F.comb(i, K-1) % MOD
           for i in reversed(range(K-1, N))]) % MOD)


Measured memory_bytes: 17016
use std::vec::Vec;
use std::collections::HashMap;

fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}

fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    read::<String>().split_whitespace().map(|e| e.parse().ok().unwrap()).collect()
}

fn read_touple<T: std::str::FromStr + Copy>() -> (T, T) {
  let v: Vec<T> = read_vec();
  assert_eq!(v.len(), 2);
  (v[0], v[1])
}

fn main() {
    let n: usize = read();
    let mut primes = HashMap::new();
    for i in 2..n+1 {
      trial_division(i, &mut primes);
    }

    let num = |x: usize| -> usize {
        primes.iter()
              .fold(
                0, 
                |acc, (&key, &val)| if val >= x-1 { acc + 1 } else { acc }
              )
    };
    let ans: usize = num(75) 
                      + num(25) * (num(3) - 1) 
                      + num(15) * (num(5) - 1)
                      + num(5) * ((num(5) - 1) * (num(3) - 2)) / 2;
    println!("{}", ans);
}

// 試し割り
// O(√N)
fn trial_division(n :usize, primes: &mut HashMap<usize, usize>) {
    let mut i = 2;
    let mut n = n;

    //  n を root n 以下の整数で割り切れるまで割っていく
    while i * i <= n {
        while n % i == 0 {
            n /= i;
            // match primes.get_mut(&i) {
            //   None => { primes.insert(i, 1); },
            //   Some(x) => {
            //       *x += 1;
            //   },
            // }

            match primes.get(&i) {
              Some(&val) => {
                primes.insert(i, val + 1);
              },
              _  => { primes.insert(i, 1); },
            }
        }
        i+=1;
    }

    // 最後にnが素数になっている場合はそれ自身も素因数に含めて終了
    // match primes.get_mut(&n) {
    //   None => { primes.insert(n, 1); },
    //   Some(x) => {
    //     *x += 1;
    //   },
    // }
     if n != 1 {
      match primes.get(&n) {
            Some(&val) => {
              primes.insert(n, val + 1);
            },
            _  => { primes.insert(n, 1); },
        }
     }

}

Measured memory_bytes: 4352
#include<iostream>
#include<cmath>

using namespace std;

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

  double ans = 0;

  for(int i=1; i<=N; i++){
    long double p = 1;
    int j = i;
    while(j<K){
      p *= 0.5;
      j *= 2;
    }
    ans += p;
  }

  printf("%.9f\n", ans/N);
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define fi first
#define se second
#define pb push_back
#define mp make_pair
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; }
const int INF = 1<<30;
const ll LINF = 1LL<<58;
const ll mod = 1000000007;

int main(){
    int n;
    cin >> n;
    vector<int> A(n);
    for(int i = 0; i < n; i++) cin >> A[i];
    sort(rall(A));
    int ma = A[0], t = A[1];
    int a, b = ma/2;
    if(ma%2 == 0) a = ma/2;
    else a = ma/2 + 1;

    for(auto x:A){
        if(abs(t-a) > abs(x-a) || abs(t-b) > abs(t-b)) t = x;
    }

    cout << ma << " " << t << endl;
    return 0;
}

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

int main(){
	int n;

	cin >> n;

	vector<int> a(n);
	for(auto& x : a){
		cin >> x;
	}
	int max = *max_element(a.begin(),a.end());
	int min = *min_element(a.begin(),a.end());


	cout << max-min << endl;


	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
using namespace std;
const int inf = 1012345678;
int n, ma, mb, a[44], b[44], c[44], dp[44][409][409]; bool vis[44][409][409];
int solve(int pos, int sa, int sb) {
	if (pos == n) return (sa != 0 && sa * mb == sb * ma ? 0 : 1012345678);
	if (vis[pos][sa][sb]) return dp[pos][sa][sb];
	int ret = min(solve(pos + 1, sa, sb), solve(pos + 1, sa + a[pos], sb + b[pos]) + c[pos]);
	vis[pos][sa][sb] = true;
	dp[pos][sa][sb] = ret;
	return ret;
}
int main() {
	cin >> n >> ma >> mb;
	for (int i = 0; i < n; i++) cin >> a[i] >> b[i] >> c[i];
	int ret = solve(0, 0, 0);
	cout << (ret >= inf ? -1 : ret) << endl;
	return 0;
}

Measured memory_bytes: 33280
#include <cstdio>
#include <cstdlib>
#include <iostream>
#include <fstream>
#include <sstream>
#include <set>
#include <map>
#include <vector>
#include <list>
#include <algorithm>
#include <cstring>
#include <cmath>
#include <string>
#include <stack>
#include <queue>
#include <bitset>     //UWAGA - w czasie kompilacji musi byc znany rozmiar wektora - nie mozna go zmienic
#include <cassert>
#include <iomanip>        //do setprecision
#include <ctime>
#include <complex>
using namespace std;

#define FOR(i,b,e) for(int i=(b);i<(e);++i)
#define FORQ(i,b,e) for(int i=(b);i<=(e);++i)
#define FORD(i,b,e) for(int i=(b)-1;i>=(e);--i)
#define REP(x, n) for(int x = 0; x < (n); ++x)

#define ST first
#define ND second
#define PB push_back
#define PF push_front
#define MP make_pair
#define LL long long
#define ULL unsigned LL
#define LD long double
#define pii pair<int,int>
#define pll pair<LL,LL>
#define vi vector<int>
#define vl vector<LL>
#define vii vector<vi>
#define vll vector<vl>

const double pi = 3.14159265358979323846264;
const int mod=1000000007;
int dx[4]={-1,0,1,0};
int dy[4]={0,1,0,-1};

int main(){
	int h,w,ch,cw,dh,dw;
    cin>>h>>w>>ch>>cw>>dh>>dw;
    ch+=9;
    cw+=9;
    dh+=9;
    dw+=9;
    vii b(h+100,vi(w+100,1));
    vii ans(h+100,vi(w+100,mod));
    FOR(i,0,h){
        string s;
        cin>>s;
        FOR(j,0,w){
            if(s[j]=='.'){
                b[i+10][j+10]=0;
            }
        }
    }
    cerr<<"t"<<endl;
    priority_queue<array<int,3>> pq;
    pq.push({0,ch,cw});
    while (pq.size())
    {
        auto tpl=pq.top();
        pq.pop();
        int sc=-tpl[0];
        int nh=tpl[1];
        int nw=tpl[2];
        if(sc>=ans[nh][nw])continue;
        ans[nh][nw]=sc;
        //cerr<<nh<<" "<<nw<<" "<<sc<<endl;
        FOR(di,0,4){
            int nxsc=sc;
            int nxw=nw+dx[di];
            int nxh=nh+dy[di];
            if(b[nxh][nxw])continue;
            if(nxsc>=ans[nxh][nxw])continue;
            pq.push({-nxsc,nxh,nxw});
        }
        FOR(nxh,nh-2,nh+3){
            FOR(nxw,nw-2,nw+3){
                int nxsc=sc+1;
                if(b[nxh][nxw])continue;
                if(nxsc>=ans[nxh][nxw])continue;
                pq.push({-nxsc,nxh,nxw});
            }
        }
    }
    if(ans[dh][dw]!=mod){
        cout<<ans[dh][dw]<<endl;
    }else{
        cout<<-1<<endl;
    }


}


Measured memory_bytes: 14432
#include <bits/stdc++.h>
#define err(args...) {}
#ifdef DEBUG
#include "_debug.cpp"
#endif
using namespace std;
using ll = long long;
using ld = long double;
template <typename T> using lim = numeric_limits<T>;
template <typename T> istream& operator>>(istream& is, vector<T>& a) { for(T& x : a) { is >> x; } return is; }
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    ll n;
    cin >> n;
    ll ans = n - 1;
    for(ll d = 1; d * d <= n; d++) {
        if(n % d == 0) {
            ans = min(ans, d - 1 + n / d - 1);
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
  string s,t;
  cin >> s >> t;
  vector<char> S,T;
  for(int i = 0;i < s.size();i++)S.push_back(s[i]);
  for(int i = 0;i < t.size();i++)T.push_back(t[i]);
  sort(S.begin(),S.end());
  sort(T.begin(),T.end(),greater<int>());
  if(S < T)cout << "Yes" << endl;
  else cout << "No" << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define int long long
#define double long double
#define vi vector<int>
#define vpi vector<pair<int,int> >
#define mii map<int,int>
#define mpi map<pair<int,int>,int>
#define msi map<string,int>
#define set set<int>
#define u_set unordered_set<int>
#define pb push_back
#define endl "\n"
#define ll long long int
#define vll vector<long long int>
#define vi vector<int>
#define vvi vector<vector<int>>
#define io ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define umap unordered_map 
#define mod 1000000007
#define fori(a,n) for(int i=a;i<n;i++)
#define forj(a,n) for(int j=a;j<n;j++)
#define MAX 300303
#define V vector
using namespace std;
int k,d;
int dig = 0;
vector<int> knum(10001);
V<vvi> dp(10001,vvi(101,vi(2,-1)));
int rec(int place, int sum, int tt){
    if(place == dig) return sum==0;
    if(dp[place][sum][tt] != -1)return dp[place][sum][tt];
    dp[place][sum][tt] = 0;
    if(tt){
        for(int digit=0;digit<knum[place];++digit){
            // if((sum+digit)%d==0)dp[place][sum][tt] += 1;
            dp[place][sum][tt] += (rec(place+1,(sum+digit)%d,0)+mod)%mod;
        }
        // ==knum[place]
        // if((sum+knum[place])%d==0)dp[place][sum][tt] += 1;
        dp[place][sum][tt] += (rec(place+1,(sum+knum[place])%d,1)+mod)%mod;
    }
    else{
        for(int digit=0;digit<10;++digit){
            // if((sum+digit)%d==0)dp[place][sum][tt] += 1;
            dp[place][sum][tt] += (rec(place+1,(sum+digit)%d,0)+mod)%mod;
        }
    }
    return (dp[place][sum][tt]+2*mod)%mod;
}
signed main()
{
    io
    // cin >> k >> d;
    int tt = 1;
    string kstr;
    cin >> kstr;
    cin >> d;
    for(int i=0;i<kstr.size();++i){
        knum[i] = kstr[i] - '0';
    }
    // int kk = k;
    // while(kk>0){
    //     knum.pb(kk%10);
    //     kk  /= 10;
    //     dig++;
    // }
    // reverse(knum.begin(),knum.end());
    // for(int i=0;i<knum.size();++i)cout << knum[i] << endl;
    dig = kstr.size();
    cout << (rec(0,0,1)-1+mod)%mod << endl;

} 

Measured memory_bytes: 58752
h,w = gets.split.map(&:to_i)
arr = []
h.times do
  arr << gets.chomp.split("")
end

arr.map do |i|
  i.push('.')
  i.unshift('.')
end

arr.push(Array.new(w+2,'.'))
arr.unshift(Array.new(w+2,'.'))

(1..h).each do |i|
  a_ar = []
  (1..w).each do |j|
    cnt = 0
      cnt+=1 if arr[i-1][j-1] == '#'
      cnt+=1 if arr[i-1][j] == '#'
      cnt+=1 if arr[i-1][j+1] == '#'
      cnt+=1 if arr[i][j-1] == '#'
      cnt+=1 if arr[i][j+1] == '#'
      cnt+=1 if arr[i+1][j-1] == '#'
      cnt+=1 if arr[i+1][j] == '#'
      cnt+=1 if arr[i+1][j+1] == '#'
      if arr[i][j] == '#'
        a_ar << '#'
      else
        a_ar << cnt
      end
  end
  puts a_ar.join
end



Measured memory_bytes: 4220
#include "bits/stdc++.h"

#define ALL(g) (g).begin(),(g).end()
#define REP(i, x, n) for(int i = x; i < n; i++)
#define rep(i,n) REP(i,0,n)
#define RREP(i, x, n) for(int i = x; i >= n; i--)
#define rrep(i, n) RREP(i,n,0)
#define pb push_back

using namespace std;

using ll = long long;
using P = pair<int,int>;
using Pl = pair<ll,int>;

const int mod=1e9+7,INF=1<<30;
const double EPS=1e-12,PI=3.1415926535897932384626;
const ll lmod = 1e9+7,LINF=1LL<<60;
const int MAX_N = 200005;

template <typename T>
class FenwickTree {
  const int n;
  vector<T> data;
public:
  FenwickTree(int n) : n(n), data(n, 0) {}
  void add(int i, T value) {
    for (; i < n; i |= i + 1) data[i] += value;
  }
  T sum(int i) const {
    // sum of [0,i]
    T res = 0;
    for (; i >= 0; i = (i & (i + 1)) - 1) res += data[i];
    return res;
  }
  T sum(int l, int r) const { return sum(r - 1) - sum(l - 1); }
};

ll a[MAX_N],s[MAX_N];

int main(){
  int N; ll K; cin >> N >> K;
  rep(i,N) scanf("%lld",a+i);
  ll _sum = 0LL;
  rep(i,N+1){
    s[i] = _sum - ll(i) * K;
    _sum += a[i];
  }
  vector<ll> s_cp(N+1);
  rep(i,N+1) s_cp[i] = s[i];
  sort(ALL(s_cp));
  s_cp.erase(unique(ALL(s_cp)),s_cp.end());
  FenwickTree<int> tree(N+1);
  ll ans = 0LL;
  rep(i,N+1){
    int index = int(lower_bound(s_cp.begin(),s_cp.end(),s[i])-s_cp.begin());
    ans += ll(tree.sum(index));
    tree.add(index,1);
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 5760
#include<cstdio>
#include<cstring>
#define MAXN 1000
int A,B,C,D;char s[MAXN+5];
int main()
{
	A=B=C=D=1;
	scanf("%s",s+1);
	for(int i=1;i<=strlen(s+1);i++)
	A&=(s[i]!='N'),B&=(s[i]!='S'),C&=(s[i]!='W'),D&=(s[i]!='E');
	if((A^B)||(C^D))printf("No\n");
	else printf("Yes\n");
}

Measured memory_bytes: 128
#include <iostream>
using namespace std;
int main(void){
    // Your code here!
  
  int lodge;
  int day;
  
  int feeconst;
  int fee;
  
  
  int sums=0;
  int& sum=sums;
  
  cin>>lodge>>day>>feeconst>>fee;
  
 for(int i=0;i<lodge;i++)
 {
 if(i<day)
 sum=sum+feeconst;
 else
 sum=sum+fee;
 }
  cout<<sum<<endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i,n) for(long long i=0; i<(n); i++)
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(){
    ll w,h,n; cin>>w>>h>>n;
    ll x1=0, x2=w, y1=0, y2=h;
    rep(i,n){
        ll x,y,a; cin>>x>>y>>a;
        if(a==1) chmax(x1, x);
        else if(a==2) chmin(x2, x);
        else if(a==3) chmax(y1, y);
        else chmin(y2, y);
    }
    cout<< max(0ll, x2-x1) * max(0ll, y2-y1) <<endl;
    return 0;
}

Measured memory_bytes: 256
def second(s):
    return int(s[0:2])*3600 + int(s[3:5])*60 + int(s[6:8])
while(1):
    n = int(input())
    if not n:
        break
    a = [0] * 86500
    b = [0] * 86500
    for i in range(n):
        l, r = map(second, input().split())
        a[l+1] += 1
        b[r] += 1

    ans = a[0]
    cur = a[0]

    for i in range(86499):
        cur += a[i+1]-b[i]
        ans = max(ans, cur)

    print(ans)


Measured memory_bytes: 8272
#include<iostream>

#include <vector>
#include <list>
#include<stack>
#include<queue>
#include<array>

#include <set>
#include<map>

#include<string>
#include<stdlib.h>

#include<algorithm>
#include <functional>
#include<math.h>

#include<fstream>
#include<iomanip>

using namespace std;
using ll = long long;
using ld = long double;
using pii = pair<int,int>;

#define FOR(k,m,n) for(ll (k)=(m);(k)<(n);(k)++)
#define REP(i,n) FOR((i),0,(n))
#define WAITING(str) int str;std::cin>>str;
#define DEBUGING(str) cout<<str<<endl

constexpr int INF = (1 << 30);
constexpr ll INFL = (1ll << 60);
constexpr ll MOD = 1000000007;// 10^9+7
constexpr ll nil = -1;

//変数
int N;
vector<ll> xs, ys, hs;





//サブ関数
//入力
void input()
{
	cin >> N;
	xs.resize(N);
	ys.resize(N);
	hs.resize(N);
	REP(i, N) {
		cin >> xs[i] >> ys[i] >> hs[i];
	}
}

bool judge(ll cx, ll cy, ll h) {
	REP(i, N) {
		if (max(h - abs(xs[i] - cx) - abs(ys[i]- cy), 0ll) != hs[i]) {
			return false;
		}
	}
	return true;
}

//計算
void calc()
{
	ll minh = *max_element(hs.begin(), hs.end());

	while (true) {

		REP(x, 101)REP(y, 101) {
			if (judge(x, y, minh)) {
				cout << x << " " << y << " " << minh << endl;
				return;
			}
		}
		minh++;
	}
}


//出力
void output()
{

}


//デバッグ
void debug()
{
	int N;
	cin>>N;
}


//メイン関数
int main()
{
	input();
	calc();
	output();
	debug();
	
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
typedef long long ll;
using namespace std;
#define fastio ios_base::sync_with_stdio(false);cin.tie(0);
#define all(x) x.begin(),x.end()
#define pb push_back
#define pf push_front
#define ff first
#define ss second
#define vll vector<ll>
#define sll set<ll>
#define pll pair<ll, ll>
#define vpll vector<pll>
#define endl "\n"
const ll maxn = 2e5+2;  

int main()
{
    fastio; //remove for interactive
    ll i, j, k, n, m, t;

        cin>>i>>j>>k;
        float f=(float)i/j,f2=k;
        if(f<=f2)
            cout<<"Yes"<<endl;
        else 
            cout<<"No"<<endl;
        
        
    return 0;
}

Measured memory_bytes: 3648
#include <bits/stdc++.h>
 
#define loop(n, i) for(int i=0;i<n;i++)
#define all(v) v.begin(),v.end()
#define HERE cout << "HERE: " << __LINE__ << endl;
#define INSP(v) cout << v << " at " << __LINE__ << endl;

using namespace std;
typedef long long ll;

const double INF = 1<<29;
const double EPS = 1e-8;

struct Vec { double x, y, z; };
Vec operator+(const Vec& a, const Vec& b) {
    return { a.x + b.x, a.y + b.y, a.z + b.z };
}
Vec operator-(const Vec& a, const Vec& b) {
    return { a.x - b.x, a.y - b.y, a.z - b.z };
}
Vec operator*(const Vec& v, double n) {
    return { v.x * n, v.y * n, v.z * n };
}
double operator*(const Vec& a, const Vec& b) {
    return a.x * b.x + a.y * b.y + a.z * b.z;
}
double abs(const Vec& v) {
    return pow(v * v, 0.5);
}

double dist_l2p(Vec a, Vec b, Vec p) {
    Vec l = (b - a) * (1.0 / abs(b - a));
    double len = l * (p - a);
    if (len < 0) return abs(a - p);
    if (len > abs(b - a)) return abs(b - p);
    return abs((l * len) - (p - a));
}

double dist_l2l(Vec a1, Vec a2, Vec b1, Vec b2) {
    double l = 0, r = 1;
    while (l + EPS < r) {
        double m = (l + r) / 2;
        double v1 = dist_l2p(a1, a2, b1 + ((b2 - b1) * m));
        double v2 = dist_l2p(a1, a2, b1 + ((b2 - b1) * (m + EPS)));
        if (v1 < v2) r = m;
        else l = m;
    }
    return dist_l2p(a1, a2, b1 + ((b2 - b1) * l));
}

double dist(Vec s, Vec t, Vec a, Vec b, double h) {
    double d = dist_l2l(s, t, a, b);
    if (d < h) return d;
    a.z = h, b.z = h;
    double l = d, r = 2000;
    while (l + EPS < r) {
        double m = (l + r) / 2;
        s.z = m, t.z = m;
        if (m < dist_l2l(s, t, a, b)) l = m;
        else r = m;
    }
    return l;
}

int main()
{
    while (1) {
        int n; cin >> n;
        if (!n) break;
        Vec s, t;
        cin >> s.x >> s.y >> t.x >> t.y;
        s.z = 0, t.z = 0;
        double ans = INF;
        while (n--) {
            Vec a, b, c, d;
            double h;
            cin >> a.x >> a.y >> c.x >> c.y >> h;
            b.x = a.x, b.y = c.y, d.x = c.x, d.y = a.y;
            a.z = b.z = c.z = d.z = 0;
            if (a.x < min(s.x, t.x) && a.y < min(s.y, t.y) && c.x > max(s.x, t.x) && c.y > max(s.y, t.y)) ans = 0;
            ans = min(ans, dist(s, t, a, b, h));
            ans = min(ans, dist(s, t, b, c, h));
            ans = min(ans, dist(s, t, c, d, h));
            ans = min(ans, dist(s, t, d, a, h));
        }
        cout << setprecision(8) << fixed << ans << endl;
    }
    return 0;
}

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

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

  vector<int> nums(N);
  for (int i = 0; i < N; i++) {
    cin >> nums.at(i);
  }

  int cnt = 0;
  bool is_odd = true;
  for (;;) {
    for (int i = 0; i < N; i++) {
      if (nums.at(i) % 2 == 0) {
        nums.at(i) /= 2;
      }
      else {
        is_odd = false;
      }
    }

    if (is_odd) {
      cnt++;
    }
    else {
      break;
    }
  }

  cout << cnt << endl;
}

Measured memory_bytes: 256
/*
  GOOD is not Enough
  You've got to be GREAT.
*/
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
// #include<boost/multiprecision/cpp_int.hpp>
// using namespace boost::multiprecision;
using namespace __gnu_pbds;
using namespace std;
#define int long long
#define mod 1000000007
#define FAST ios::sync_with_stdio(0),cin.tie(0),cout.tie(0);
#define f(i,n) for(int i=0;i<n;i++)
#define fp(i,k,n) for(int i=k;i<=n;i++)
#define fr(i,k,n) for(int i=k;i>=n;i--)
#define pb push_back
#define pii pair<int,int>
#define dbg(x) cout << (#x) << " is " << (x) << '\n' 
#define F first
#define S second
#define all(a) a.begin(),a.end()
typedef tree<int,null_type,less_equal<int>,rb_tree_tag,tree_order_statistics_node_update>ordered_set;

void solve()
{ 
  int a,b,c,k;
  cin >> a >> b >> c >> k;
  if(k>a)
  {
      if(k>a+b)
      {
          cout << a-(k-(a+b)) << '\n';
      }
      else
      {
          cout << a << '\n';
      }
  }
  else
    cout << k << '\n';
  return;
}

signed main()
{
  FAST
  int T=1;
  // cin >> T;
  while(T--)
  {
    solve();
  }
  return 0;
}

Measured memory_bytes: 3660
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<utility>
#include<algorithm> // sort
#include<map> // pair
#include<cmath>
using namespace std;
using ll = long long;
const ll mod = 1e9+7;
ll a[2010][2010];
void func(){
  for(int i=0;i<=2000;i++){
    a[i][0] = 1;
    a[i][i] = 1;
  }
  for(int i=2;i<=2000;i++){
    for(int j=1;j<i;j++){
      a[i][j] = (a[i-1][j-1] + a[i-1][j])%mod;
    }
  }
}
int main(){
  ll n,k;
  ll mul=1;
  cin >> n >> k;
  func();
  for(ll i=1;i<=k;i++){
    //cout << a[n-k+1][i] << " " << a[k-1][i-1] % mod << endl;
    cout << a[n-k+1][i] * a[k-1][i-1] % mod << endl;
  }
}


Measured memory_bytes: 30208
a = int(input())#500
b = int(input())#100
c = int(input())#50
x = int(int(input())/50)

cnt = 0

for i in range(a + 1):
  for j in range(b + 1):
    for k in range(c + 1):
      s = int(i*10 + j*2 + k)
      if s == x:
        cnt += 1

print(cnt)

Measured memory_bytes: 9184
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int A = sc.nextInt();
		int B = sc.nextInt();
		int C = sc.nextInt();
		int a = A*10+B+C;
		int b = A+B*10+C;
		int c = A+B+C*10;
		sc.close();
		if(a>=b && a>=c) {
			System.out.println(a);
		}else if(b>=a && b>=c) {
			System.out.println(b);
		}else {
			System.out.println(c);
		}

	}

}

Measured memory_bytes: 35820
import sys
import math
from collections import deque
import heapq
import itertools
MAX_INT = int(10e25)
MIN_INT = -MAX_INT
mod = 998244353
sys.setrecursionlimit(1000000)
def IL(): return list(map(int,input().split()))
def SL(): return input().split()
def I(): return int(sys.stdin.readline())
def S(): return input()

N = I()
a = IL()

num = sum(a)
ans = 0
ko = 1
for i in range(N):
  ans += ko
  ko -= a[i]
  num -= a[i]
  ko = min(ko*2, num)

  if ko <= 0:
    print(-1)
    break
else:
  ans += ko
  ko -= a[-1]
  if ko < 0:
    print(-1)
  else:
    print(ans)

Measured memory_bytes: 82744
#editorial参照
#答えは(i < jかつAi̸=Ajであるような組(i; j)の個数) +1
#上記のi～jの反転はi+1～j-1の反転と同等
#回文や接尾辞とかの厄介なアルゴリズムは不要
a = input()
n = len(a)
chrs = set(a)
dic = {k:0 for k in chrs}

for i in range(n):
    dic[a[i]] += 1

ans = n*(n-1)//2+1

for k in dic:
    ans -= dic[k]*(dic[k]-1)//2

print(ans)

Measured memory_bytes: 53744
#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <utility>
#include <functional>
#include <climits>
#include <cstring>

using namespace std;

#define int long long
#define rep(i, n) for (int i=0;i<(int)n;++i)
#define rep1(i, n) for (int i=1;i<=(int)n;++i)
#define unless(a) if(!(a))
#define all(a) begin(a),end(a)
#define fst first
#define scd second
#define PB emplace_back
#define PPB pop_back

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

constexpr ll TEN(int n) { return (n == 0) ? 1 : 10 * TEN(n - 1); }
bool chmin(int&a,int b){return a>b?(a=b,true):false;}
bool chmax(int&a,int b){return a<b?(a=b,true):false;}
ll read(){ll a;scanf("%lld",&a);return a;}

const int inf = 3 * TEN(18) + 10;
const int mod = 998244353;

int N, P;
string S;
int rui[200010];
int counter[10010];

signed main()
{
	cin >> N >> P;
	cin >> S;

	int ans = 0;

	if (P == 2) {
		rep(i, N) {
			if ((S[i] - '0') % 2 == 0) {
				ans += i + 1;
			}
		}
	} else if (P == 5) {
		rep(i, N) {
			if ((S[i] - '0') % 5 == 0) {
				ans += i + 1;
			}
		}
	} else {
		S = ' ' + S;

		counter[0]++;
		int ten = 1;
		for (int i = N; i >= 1; --i) {
			rui[i] += rui[i + 1];
			rui[i] += (S[i] - '0') * ten;
			rui[i] %= P;

			ans += counter[rui[i]];
			counter[rui[i]]++;

			ten *= 10;
			ten %= P;
		}
	}

	cout << ans << endl;
}





Measured memory_bytes: 2240
fun QQ() {
    for (i in 1 .. 9) {
        for (j in 1 .. 9) {
            println("${i}x${j}=${i*j}")
        }
    }
}

// fun gcd(a: Int, b: Int) : Int = if (b == 0) a else gcd(b, a % b)

fun main(args: Array<String>) {
    QQ()
    // println(gcd(10, 2))
    // println(gcd(1071, 1029))

    // var top3 = readLine()?.split(" ")?.map { n -> n.toInt() }?.sorted()?.filterIndexed { i, _ -> i < 3 }
    // println(top3)
}


Measured memory_bytes: 24344
#include <iostream>
#include <algorithm>
#include <vector>
#include <cstring>
#include <map>
#include <set>
#include <cmath>
#include <iomanip>
#include <stack>
#include <queue>
#include <fstream>
#include <numeric>
#define ll long long 
#define pb push_back
#define FASTIO ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);   
#define F first 
#define S second
const ll INF = std::numeric_limits<long long>::max(); 
const int IINF = std::numeric_limits<int>::max(); 
const int MOD = 1e9 + 7; 
/*rrrohan*/ 
using namespace std; 
 
/*less than or equal to -> l + r + 1*/
/*upper_bound -> greater than x 
lower_bound -> greater than or equal to x*/
ll gcd(ll a, ll b) //O(log(a+b))
{ 
    if (b == 0) 
        return a; 
    return gcd(b, a % b);  
      
}  
/*class dsu{
private: 
	vector <int> r,p; 
public: 
	dsu(int n){
		p.resize(n+1);
		r.resize(n+1);  
		for(int i = 0; i < n+1; i++){
			p[i] = i; 
			r[i] = 0; 
		}
	}
	int findset(int i){
		return (p[i] == i) ? i : (p[i] = findset(p[i])); 
	}
	bool issameset(int a, int b){
		return findset(a) == findset(b); 
	}
	void unionset(int i, int j){
		if(!issameset(i,j)){
			int x = findset(i), y = findset(j); 
			if(r[x] > r[y]){
				p[y]  = x; 
			}else{
				p[x] = y; 
				if(r[x] == r[y]){
					r[y]++; 
				}
			}
		}
	}
};
*/ 

int main(){
	int n,k;  
	cin >> n >> k; 
	string s; 
	cin >> s;  
	k--;  
	s[k] = s[k] - 'A' + 'a';  
	cout << s; 
}

Measured memory_bytes: 256
/*  
    Shiny, shiny, shiny boots of leather
    Whiplash girlchild in the dark
    Comes in bells, your servant, don't forsake him
    Strike, dear mistress, and cure his heart
    _________________________
    _________________________
    168 Hours of Solitude
    Quarantine_Day : 7
*/

#include<bits/stdc++.h>

using namespace std;

typedef long long int       LL;
typedef vector<int>         VI;
typedef vector<LL>          VL;

#define pb(n)           push_back(n)
#define GSORT(v)        sort(v.begin(), v.end(), greater<lint>())
#define SORT(v)         sort(v.begin(), v.end());
#define REV(v)          reverse(v.begin(), v.end());
#define db(a)           cout<<#a<<" = "<<a<<endl;
#define FIN             freopen("in.txt","r",stdin);
#define FOUT            freopen("out.txt","w",stdout);
#define REP(i,a,b)      for(int i = int(a); i <= int(b); i++)
#define fastIO()        ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);

int main()
{
    LL a, b, x;
    cin>>a>>b>>x;
    
    if(a == 0) cout<<(LL)(b / x) + 1<<endl;
    else{
        a--;
        cout<<(LL)(b / x) - (LL)(a / x)<<endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int a[110];
int head=100;

inline void change()
{
	int j=101;
	for (int k=j-1;k>=head+1;k--)
	{
		if (a[k]!=a[k-1]+1 && a[k]!=9)
		{
			j=k;
			break;
		}
	}
	if (j!=101)
	{
		a[j]++;
		for (int k=j+1;k<=100;k++)
		{
			if (a[k-1]-1>=0)  a[k]=a[k-1]-1;
			else a[k]=a[k-1];
		}
		return;
	}
	if (j==101 && a[head]!=9)
	{
		a[head]++;
		for (int k=head+1;k<=100;k++)
		{
			if (a[k-1]-1>=0)  a[k]=a[k-1]-1;
			else a[k]=a[k-1];
		}
		return;
	}
	else if (a[head]==9 && j==101)
	{
		head--;
		a[head]=1;
		for (int k=head+1;k<=100;k++)  a[k]=0;
	}
}

int main(){
    int K;
    cin>>K;
    
    for(int i=1;i<=K;i++){
        change();
    }
    
    for(int i=head;i<=100;i++){
        cout<<a[i];
    }
    
    return 0;
}

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

using uint = unsigned int;
using ll = long long;
using ull = unsigned long long;
#include <string>
#include <cstdio>
#include <algorithm>
#include <vector>
#include <cmath>
#include <climits>
#include <bitset>
#include <array>
#include <deque>
#include <queue>
#include <map>
#define all(x) (x).begin(),(x).end()

const int MOD = 1e9 + 7;

void solve(){

}
int main(){
    int N;
    cin >> N;
    vector<int> h(N+1);
    for (int i = 1; i < N+1; i++){
        cin >> h[i];
    }

    int t = h[0];
    ll ans = 0;
    for (int i = 1; i < N+1; i++){
        if (h[i] > t){
            ans+= h[i] - t;
        }
        swap(t,h[i]);
    }
    cout << ans << endl;


        

    

    return 0;
}


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

#define ll long long int 
unordered_map<ll,vector<ll>> path;


ll dfs(vector<ll>& visit,ll node)
{
    visit[node]=1;
    ll count=0;
    for(auto curr:path[node])
    {
        if(visit[curr]==1)continue;
       count+=1+dfs(visit,curr);
    }
    return count;
}
int main() {
	ll n,m;
	cin>>n>>m;
	
	for(int i=0;i<m;i++)
	{
	    ll first,second;
	    cin>>first>>second;
	    path[first].push_back(second);
	    path[second].push_back(first);
	}
	
	vector<ll> visit(n+1,-1);
	ll maxi=0;
	for(int i=1;i<=n;i++)
	{
	    if(visit[i]!=-1)continue;
	    
	    maxi=max(maxi,1+dfs(visit,i));
	}
	
	cout<<maxi;
	return 0;
}


Measured memory_bytes: 35004
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <algorithm>
#include <numeric>
#include <utility>
#include <unordered_map>
#include <unordered_set>
#include <cstring>

using namespace std;

#ifndef debug_on
#define debug_on 0
#endif

#define dbg \
    if(debug_on) cerr << "DEBUG:"

const int MAX_N = 52;
int N, M;
char PATH[MAX_N][MAX_N];
char VISITED[MAX_N];

int DFS(int cur)
{
    if(VISITED[cur]) return 0;
    //dbg << "Cur" << cur << endl;
    ++VISITED[cur];
    int sum = 1;
    for(int i = 1; i < MAX_N; ++i)
        if(PATH[cur][i])
            sum += DFS(i);

    return sum;
}

int main(int, char *[])
{
    cin >> N >> M;
    vector<pair<int, int>> idx2path;
    for(int i = 1; i <= M; ++i)
    {
        int a, b;
        cin >> a >> b;
        PATH[a][b] = 1;
        PATH[b][a] = 1;
        idx2path.emplace_back(a, b);
    }

    int sum = 0;

    for(auto p : idx2path)
    {
        PATH[p.first][p.second] = 0;
        PATH[p.second][p.first] = 0;
        memset(VISITED, 0, sizeof(VISITED));
        const int num_visited =  DFS(1);
        //dbg << "Visited " << num_visited << " after deleting " << p.first << "-" << p.second << endl;
        if(num_visited < N)
            ++sum;
        PATH[p.first][p.second] = 1;
        PATH[p.second][p.first] = 1;
    }

    cout << sum << endl;
    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<int,int>;


int main() {
  ll X;
  cin >> X;
  ll ans = 0;

  ll tmp = 100;
  while(tmp < X) {
    tmp += (ll)(tmp * 0.01);
    ans++; 
  }

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


Measured memory_bytes: 3648
#include <iostream>
#include <algorithm>
#define rep(i,s,n)for(int i = s;i<n;i++)
#define repe(i,s,n)for(int i = s;i<=n;i++)
using namespace std;
typedef long long ll;
static const ll MOD = 1e9 + 7;

ll a, b, q;
ll s[100002], t[100002];// , x[100001];

int main() {
	cin >> a >> b >> q;
	s[0] = -1e10;
	t[0] = -1e10;
	s[a + 1] = 1e10;
	t[b + 1] = 1e10;
	repe(i, 1, a)cin >> s[i];
	repe(i, 1, b)cin >> t[i];

	rep(i, 0, q) {
		ll x;
		cin >> x;
		ll* A = lower_bound(s, s + a, x);
		ll* B = lower_bound(t, t + b, x);
		ll s1 = *(A - 1);
		ll s2 = *A;
		ll t1 = *(B - 1);
		ll t2 = *B;

		ll ans = 0;
		ans = min(abs(t2 - s2) + abs(s2 - x), abs(s2 - t2) + abs(t2 - x));
		ans = min(ans, abs(x - s1) + abs(s1 - t1));
		ans = min(ans, abs(x - t1) + abs(t1 - s1));
		ans = min(ans, abs(x - s1) + abs(t2 - s1));
		ans = min(ans, abs(t2 - x) + abs(t2 - s1));
		ans = min(ans, abs(s2 - x) + abs(s2 - t1));
		ans = min(ans, abs(x - t1) + abs(s2 - t1));

		cout << ans << endl;
	}

	return 0;
}

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

int main() {
  long long n;
  cin >> n;
  n--;
  vector<int> ans;
  while(n>25){
    int tmp = n%26;
    ans.push_back(tmp);
    n /= 26;
    n--;
  }
  ans.push_back(n);
  for(int i = ans.size()-1;i>=0;i--)cout << (char)('a'+ans[i]);
  cout << endl;
}


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

using namespace std;

#define sim template <class c
#define ris return *this
#define dor > debug &operator<<
#define eni(x)                                                                        \
	sim > typename enable_if<sizeof dud<c>(0) x 1, debug &>::type operator<<(c i) \
	{
sim > struct rge
{
	c b, e;
};
sim > rge<c> range(c i, c j) { return rge<c>{i, j}; }
sim > auto dud(c *x) -> decltype(cerr << *x, 0);
sim > char dud(...);
struct debug
{
#ifdef LOCAL
	~debug()
	{
		cerr << endl;
	}
	eni(!=) cerr << boolalpha << i;
	ris;
} eni(==) ris << range(begin(i), end(i));
}
sim, class b dor(pair<b, c> d)
{
	ris << "(" << d.first << ", " << d.second << ")";
}
sim dor(rge<c> d)
{
	*this << "[";
	for (auto it = d.b; it != d.e; ++it)
		*this << ", " + 2 * (it == d.b) << *it;
	ris << "]";
}
#else
	sim dor(const c &)
	{
		ris;
	}
#endif
}
;
#define imie(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "

#define forn(i, n) for (int i = 0; i < int(n); i++)
#define rfor(n, i) for (ll i = (n - 1); i >= 0; --i)
#define all(V) V.begin(), V.end()
#define rall(V) V.rbegin(), V.rend()
#define len(V) (int)V.size()
#define ll long long
#define ld long double
#define ff first
#define ss second
#define pb push_back
#define mp make_pair
#define endl '\n'
#define M_PI 3.14159265358979323846
#define EPS 1e-7

void solve()
{
        int a, b, c, x; cin >> a >> b >> c >> x;
        ll res = 0;
        for (int i = 0; i <= a; ++i)
        {
                for (int j = 0; j <= b; ++j)
                {
                        for (int k = 0; k <= c; ++k)
                        {
                                ll cnt = (i * 500 + j * 100 + k * 50);
                                if (cnt == x) res++;
                        }
                }
        }
        cout << res;
}

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


Measured memory_bytes: 3612
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <array>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <sstream>
#include <stdio.h>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <list>
#include <numeric>
#include <stack>
#include <iomanip>

using namespace std;

#define Rep(i,a,b) for(int i = a; i < b; i++)
#define rep(i,b) Rep(i,0,b)
#define rrep(i,a) for(int i = a; i >= 0; i--)
#define allof(a) (a).begin(), (a).end()

typedef long long ll;
const int inf = 1e9 + 7;
const ll infll = 1ll << 60ll;
const ll mod = 1e9 + 7;
// 0~3までは右攜下昴 4~7までは斜め
constexpr int dx[] = { 1, 0, -1, 0, 1, 1, -1, -1 };
constexpr int dy[] = { 0, -1, 0, 1, 1, -1, -1, 1 };

/*
// 敘大公約摧
ll gcd(ll a, ll b) {
	if (b == 0) return a;
	return gcd(b, a % b);
}

// 敘擣公倍摧
ll lcm(ll a, ll b) {
	return a / gcd(a, b) * b;
}*/


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

	int n, l;
	cin >> n >> l;

	vector<int> taste(n, 0);

	// なるべく0に近いものを食べる
	rep(i, n) {
		taste[i] = l + i;
	}

	sort(allof(taste), [&](int x, int y) {
		return abs(x) < abs(y);
	});

	int sum = 0;
	Rep(i,1, n) {
		sum += taste[i];
	}

	cout << sum << endl;

	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main() {
    int n;
    cin >> n;
    if (n == 1){
        cout << "Hello World" << endl;
    }else {
        int a,b;
        cin >> a >> b;
        cout << a + b << endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
const int MAX = 1000000000;
vector<int> get(int n, int t){
    vector<int> ret;
    for(int i = 0; i < n; i++){
        if(i % t == 0) ret.push_back(MAX - 1);
        else if(i % t == (t - 1)) ret.push_back(-MAX);
        else ret.push_back(0);
    }
    return ret;
}
int main(){
    int H, W, h, w;
    cin >> H >> W >> h >> w;
    if(H % h == 0 && W % w == 0) cout << "No" << endl;
    else {
        cout << "Yes" << endl;
        if(H % h == 0){
            vector<int> row  = get(W, w);
            for(int i = 0; i < H; i++){
                for(int j = 0; j < W; j++)
                    printf("%d ", row[j]);
                printf("\n");
            }
        } else {
            vector<int> col = get(H, h);
            for(int i = 0; i < H; i++){
                for(int j = 0; j < W; j++)
                    printf("%d ", col[i]);
                printf("\n");
            }
        }
    }
    return 0;
}


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

int main() {
  int h, w, n;
  cin >> h >> w >> n;

  

  if(h>=w){
      if(n%h==0) cout << n/h << endl;
      else cout << 1+n/h << endl; 
  }else{
      if(n%w==0) cout << n/w << endl;
      else cout << 1+n/w << endl;
  }
  
}


Measured memory_bytes: 256
def merge(A, left, mid, right, cnt):
    n1 = mid - left
    n2 = right - mid
    L = [A[left+i] for i in range(n1)]
    R = [A[mid+i] for i in range(n2)]

    L.append(1e10)
    R.append(1e10)

    i = 0 
    j = 0
    c = 0
    for k in range(left, right):
        c += 1
        if L[i] <= R[j]:
            A[k] = L[i]
            i += 1 
        else:
            A[k] = R[j]
            j += 1

    else:
        cnt.append(c)


def mergeSort(A, left, right, cnt):
    if left+1 < right:
        mid = (left+right) // 2
        mergeSort(A, left, mid, cnt)
        mergeSort(A, mid, right, cnt)
        merge(A, left, mid, right, cnt)


def main():
    cnt = []
    _ = int(input())
    S = list(map(int, input().split()))
    mergeSort(S, 0, len(S), cnt)
    print(*S)
    print(sum(cnt))


if __name__ == "__main__":
    main()



Measured memory_bytes: 63448