akhauriyash/Code-Regression huggingface dataset:
#include "bits/stdc++.h"
 
using namespace std;
typedef long long ll;
typedef vector<ll> vll;
#define int ll
#define fi first
#define se second
#define SORT(a) sort(a.begin(),a.end())
#define rep(i,n) for(int i = 0;i < (n) ; i++) 
#define REP(i,n) for(int i = 0;i < (n) ; i++) 
#define MP(a,b) make_pair(a,b)
#define pb(a) push_back(a)
#define INF LLONG_MAX/2
#define all(x) (x).begin(),(x).end()
#define debug(x) cerr<<#x<<": "<<x<<endl
#define debug_vec(v) cerr<<#v<<":";rep(i,v.size())cerr<<" "<<v[i];cerr<<endl
//----------------------------------------------------------------

// int MOD = 998244353;
int MOD = 1000000007;
char m[300][300];
int ans[300][300] = {0};

//----------------------------------------------------------------
signed main(){
   
    int h,w,k;
	cin >> h >> w >> k;
	vector<pair<int,int>> p;
	rep(i,h)rep(j,w){
		cin >> m[i][j];
		if(m[i][j] == '#')p.pb(MP(i,j));
	}

	for(int i = 1;i <= k;i++){
		int H = p[i-1].fi;
		int W = p[i-1].se;
		int x = W-1;
		ans[H][W] = i;
		while(x >= 0 && ans[H][x] == 0 && m[H][x] == '.'){
			ans[H][x] = i;
			x--;
		}
		x = W+1;
		while(x < w && ans[H][x] == 0 && m[H][x] == '.'){
			ans[H][x] = i;
			x++;
		}
	}

	for(int i = 0;i <= h-2;i++){
		if(ans[i][0] != 0 && ans[i+1][0] == 0){
			rep(j,w)ans[i+1][j] = ans[i][j];
		}
	}

	for(int i = h-1;i >= 1;i--){
		if(ans[i][0] != 0 && ans[i-1][0] == 0){
			rep(j,w)ans[i-1][j] = ans[i][j];
		}
	}

	rep(i,h){
		rep(j,w){
			cout << ans[i][j] << " ";
		}cout << endl;
	}




	

	
	return 0;
}

//----------------------------------------------------------------

// g++ -std=c++14 code1.cpp
// sudo pip3 install --upgrade online-judge-tools
// rm -r -f test;oj dl https://code-festival-2018-quala.contest.atcoder.jp/tasks/code_festival_2018_quala_c
// rm -r -f test;oj dl https://ddcc2020-qual.contest.atcoder.jp/tasks/ddcc2020_qual_b
// rm -r -f test;oj dl https://abc145.contest.atcoder.jp/tasks/abc145_b

Measured memory_bytes: 3056
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.Arrays;
import java.util.Comparator;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner in = new Scanner(new BufferedReader(new InputStreamReader(System.in)));
		String s = in.next();
		System.out.println(solve(s));
		in.close();
	}

	private static String solve(String s) {
		for (int i = 1; i < s.length(); i++)
			if (s.charAt(i - 1) == s.charAt(i))
				return "Bad";
		return "Good";
	}

}


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

using ll = long long;
using Vi = vector<int>;
using Vl = vector<ll>;
using Pii = pair<int, int>;
using Pll = pair<ll, ll>;

constexpr int I_INF = numeric_limits<int>::max();
constexpr ll L_INF = numeric_limits<ll>::max();

//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

void solve() {
    ll N, M;
    cin >> N >> M;
    vector<Pll> items(N);
    for (ll i = 0; i < N; i++) {
        cin >> items[i].first >> items[i].second;
    }
    sort(items.begin(), items.end());
    ll ans = 0;
    for (ll i = 0; i < N; i++) {
        if (M > items[i].second) {
            ans += items[i].first * items[i].second;
            M -= items[i].second;
        }
        else {
            ans += items[i].first * M;
            break;
        }
    }
    cout << ans << "\n";
}

//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

int main() {
#ifdef FASTIO
    cin.tie(0), cout.tie(0);
    ios::sync_with_stdio(false);
#endif
#ifdef FILEINPUT
    ifstream ifs("./in_out/input.txt");
    cin.rdbuf(ifs.rdbuf());
#endif
#ifdef FILEOUTPUT
    ofstream ofs("./in_out/output.txt");
    cout.rdbuf(ofs.rdbuf());
#endif
    solve();
    cout << flush;
    return 0;
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
using int64 = long long;
#define int int64
#define rep(i, n) for(int i=0; i<n; i++)
#define FOR(i, a, b) for(int i=a; i<b; i++)
#define SORT(x) sort(x.begin(), x.end())
#define GSORT(x) sort(x.begin(), x.end(), greater<int>())
#define mk make_pair
#define fi first
#define se second
#define pb push_back
#define ALL(x) x.begin(), x.end()
#define V(T) vector<T>
typedef pair<int, int> P;
typedef pair<P, P> PP;
typedef vector<int> vi;
typedef vector<vi> vvi;
int max(int a, int b) {if(b>a) return b; else return a;}
int min(int a, int b) {if(b<a) return b; else return a;}

const int MOD = 1e9+7;

signed main() {
    int N;
    cin >> N;
    vi A(N);
    rep(i, N) cin >> A[i];
    SORT(A);
    int res = 1;

    bool ok = true;
    if(N%2) {
        if(!A[0]==0) ok = false;
        rep(i, N-1) {
            if(i%2) {res *= 2;
            res %= MOD;}
            if(A[i+1]!=((i/2)+1)*2) ok = false;
        }
    } else {
        rep(i, N) {
            if(i%2) {res *= 2;
            res %= MOD;}
            if(A[i]!=(i/2)*2+1) ok = false;
        }
    }

    if(!ok) res = 0;

    cout << res << endl;
 
    return 0;
}

Measured memory_bytes: 1024
import java.util.*;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();
    HashMap<String, Long> map = new HashMap<String, Long>();
    long ans = 0;
    for(int i = 0; i < n; i++) {
      String s = sc.next();
      String[] st = new String[10];
      for(int j = 0; j < 10; j++) {
        String t = String.valueOf(s.charAt(j));
        st[j] = t;
      }
      Arrays.sort(st);
      String m = "";
      for(int j = 0; j < 10; j++) {
        m += st[j];
      }
      if(map.containsKey(m)) {
        ans += (map.get(m));
        map.put(m, map.get(m) + 1);
      } else {
        map.put(m, (long)1);
      }
    }
    System.out.println(ans);
  }
}

Measured memory_bytes: 101076
#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=int(a);i<int(b);++i)
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
typedef pair<int, P> PP;
ll INF = (1LL << 50) - 1;
int MOD = 1e9+7;
template< typename T >
struct edge {
  int src, to;
  T cost;

  edge(int to, T cost) : src(-1), to(to), cost(cost) {}

  edge(int src, int to, T cost) : src(src), to(to), cost(cost) {}

  edge &operator=(const int &x) {
    to = x;
    return *this;
  }

  operator int() const { return to; }
};

template< typename T >
using Edges = vector< edge< T > >;
template< typename T >
using WeightedGraph = vector< Edges< T > >;

template< typename T > vector< T > dijkstra(WeightedGraph< T > &g, int s) {
  const auto INF = numeric_limits< T >::max();
  vector< T > dist(g.size(), INF);

  using Pi = pair< T, int >;
  priority_queue< Pi, vector< Pi >, greater< Pi > > que;
  dist[s] = 0;
  que.emplace(dist[s], s);
  while(!que.empty()) {
    T cost;
    int idx;
    tie(cost, idx) = que.top();
    que.pop();
    if(dist[idx] < cost) continue;
    for(auto &e : g[idx]) {
      auto next_cost = cost + e.cost;
      if(dist[e.to] <= next_cost) continue;
      dist[e.to] = next_cost;
      que.emplace(dist[e.to], e.to);
    }
  }
  return dist;
}
main(){
    int N,M,S,T;
    cin >> N >> M >> S >> T;
    S--;T--;
    WeightedGraph<ll> g1(N),g2(N);
    rep(i,0,M){
        ll a,b,c,d;
        cin >> a >> b >> c >> d;
        a--;b--;
        g1[a].emplace_back(b,c);
        g1[b].emplace_back(a,c);
        g2[a].emplace_back(b,d);
        g2[b].emplace_back(a,d);
    }
    auto dist1 = dijkstra(g1, S);
    auto dist2 = dijkstra(g2, T);

    vector<ll> ans;
    ll mini = INF;
    //rep(i,0,N)cout << dist1[i] << endl;
    //cout << endl;
    for(int i = N-1;i >= 0;i--){
        ll d = dist1[i] + dist2[i];
        mini = min(mini, d);
        ans.push_back(mini);
    }
    ll cost = 1e15;
    rep(i,0,N){
        cout << cost - ans[N-i-1] << endl;
    }
}


Measured memory_bytes: 19964
#include<bits/stdc++.h>
using namespace std;
#define INF 1e9
#define MOD 1000000007 

int main(){

    int n, t; cin >> n >> t;
    vector<long long> a(n);
    for(int i = 0; i < n; i++){
        cin >> a[i];
    }

    sort(a.begin(), a.end());
    long long ans = 1;
    for(int i = 1; i < n; i++){
        int lb = -1;
        int ub = i;
        //ubが答え
        long long now = a[i] - t;
        while(ub - lb > 1){
            int mid = (ub + lb) / 2;
            if(now > a[mid]) lb = mid;
            else ub = mid;
        }

        ans *= (i - ub + 1);
        ans %= MOD;
        //cout << ans << endl;
    }

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


Measured memory_bytes: 3596
#include <bits/stdc++.h>
#define fuck 2000000000
#define hell 2000000000000000000
#define ff first
#define ss second 
#define forn(i,n) for (int i=0;i<int(n);i++)
#define nfor(i,n) for (int i=int(n)-1;i>=0;i--)
#define N 100010
#define M 1000010
using namespace std;
const int MOD = 1000000007;
const double PI = acos(-1.0);
int gcd(int a,int b){return (b==0) ? a : gcd(b,a%b);}
int n;
char s[100010];

int main(){
	
	scanf(" %s",&s);
	n=strlen(s);
	for (int i=1;i<=n;i+=2)
		printf("%c",s[i-1]);
	return 0;
}

Measured memory_bytes: 384
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <sstream>
#include <queue>
#include <deque>
#include <bitset>
#include <iterator>
#include <list>
#include <stack>
#include <map>
#include <set>
#include <functional>
#include <numeric>
#include <utility>
#include <limits>
#include <time.h>
#include <math.h>
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <assert.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> ii;
typedef vector<ii> vii;
typedef vector<int> vi;
#define INF 1000000000 // 1 billion, safer than 2B for Floyd Warshall’s
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define pcont(x) for(auto i: x){cout << i << " ";} cout << "\n";

int main(){
    IOS;
    int n, m, k;
    cin >> n >> m >> k;
    vector<ll> a(n), b(m), asum(n+1), bsum(m+1);
    for(int i = 0; i<n; i++){
        cin >> a[i];
    }
    for(int i = 0; i<m; i++){
        cin >> b[i];
    }

    asum[0] = bsum[0] = 0;
    for(int i = 1; i<n+1; i++){
        asum[i] = asum[i-1] + a[i-1];
    }
    for(int i = 1; i<m+1; i++){
        bsum[i] = bsum[i-1] + b[i-1];
    }

    int ans = 0, j = m;
    
    for(int i = 0; i<n+1; i++){
        if(asum[i] > k)break;
        while(bsum[j] > k - asum[i]){
            j--;
        }
        ans = max(ans, (i+j));
    }

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

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

void solve(int TestCase) {
    int a;
    cin >> a;
    auto ret = a + a * a + a * a * a;
    cout << ret << endl;
}

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
 
    int t = 1;
    //cin >> t;
    for(auto i = 1; i <= t; ++i) {
        //cout << "Case #"<< i << ": ";
        solve(i);
    }
}

Measured memory_bytes: 3608
#include <bits/stdc++.h>
using namespace std;
using lint = long long int;
#define ARRAY_LENGTH(array) (sizeof(array) / sizeof(array[0]))
#define REP(i,n) for (lint i = 0; i < (n); i++)
#define REP1(i,n) for (lint i = 1; i < (n); i++)
#define REPRE(i,n) for (lint i = N-1; i < 0; i--)
#define REP1RE(i,n) for (lint i = N-1; i < 1; i--)

lint N;
lint sub_num = 100;
lint D;
lint top_num;

int main(void){
    cin >> D >> N;
    top_num = pow(sub_num, D);
    if (N <= 99) cout << top_num * N << endl;
    else if (N == 100) cout << top_num * (N+1) << endl;
    return 0;
}

Measured memory_bytes: 384
let rec count2 n =
  if n mod 2 = 0 then 1 + count2 (n / 2) else 0

let () = Scanf.scanf "%d\n" @@ fun n ->
  Array.init n (fun _ -> Scanf.scanf "%d " @@ fun a -> count2 a)
  |> Array.fold_left ( + ) 0
  |> Printf.printf "%d\n"


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

#include "bits/stdc++.h"
using namespace std;
#define int long long
#define FOR(i,a,b) for(int i=(int)(a);i<(int)(b);++i)
#define REP(i,n)  FOR(i,0,(n))


class ARainySeason {
public:
	void solve(std::istream& in, std::ostream& out) {
	  string s;
    in >> s;
    int r = 0;
    int m = 0;
    REP(i, s.length()){
      if(s[i] == 'S'){
        if(r > m) m = r;
        r = 0;
      }
      else{
        r++;
      }
    }
    if(r > m) m = r;
    out << m << endl;
	}
};


signed main() {
  ios::sync_with_stdio(false);
  cout.tie(0);
  cout << fixed;
	ARainySeason solver;
	std::istream& in(std::cin);
	std::ostream& out(std::cout);
	solver.solve(in, out);
	return 0;
}


Measured memory_bytes: 3620
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <list>
#include <algorithm>
#include <functional>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>
#include <numeric>
#include <deque>

#define dump(x) cerr << #x << "=" << (x) << endl;
using namespace std;
using ll = long long;

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define IN(x) int (x); cin >> x
#define VINT(a,n) vector<int> a(n)
#define VIN(a,n) VINT(a,n); REP(i,n){cin >> a[i];}
#define ALL(x) (x).begin(),(x).end()

int main () {
  IN(n);
  VIN(h,n);
  int maxH=0;
  int c=0;
  REP(i,n){
    maxH=max(maxH, h[i]);
    if (maxH==h[i]) c++;
  }
  cout<<c<<endl;
}


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

int main(){
	
	int a[3],i;
	
	for(i=0;i<3;i++){
		
		scanf("%d",&a[i]) ;
	}
	sort(a,a+3) ;
	
	if(a[1]-a[0]==a[2]-a[1]) {
		printf("YES\n") ;
	}
	
	else {
		printf("NO\n") ;
	}
	
}

Measured memory_bytes: 256
A, B = map(int, input().split())


def gcd(a, b):
  x = max(a, b)
  y = min(a, b)
  while x%y != 0:
    z = x%y
    x = y
    y = z
  return y

def lcm(a, b):
  return int(a*b/gcd(a,b))

print(lcm(A, B))

Measured memory_bytes: 3060
#include <iostream>
#include <vector>

using namespace std;
using ll = long long;

int main() {
  ll N, ans{};
  cin >> N;
  vector<ll> A(N), B(N);
  for (int i = 0; i < N; i++) {
    cin >> A[i] >> B[i];
  }
  for (int i = N - 1; i >= 0; --i) {
    A[i] += ans;
    if (!A[i]) continue;
    ans += B[i] - (A[i] - 1) % B[i] - 1;
  }
  cout << ans << endl;
}


Measured memory_bytes: 4848
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <functional>
#include <numeric>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <utility>
#include <sstream>
#include <complex>
#include <fstream>
#include <bitset>
#include <time.h>

using namespace std;

typedef long long ll;
typedef pair<ll, ll> P;
typedef vector<ll> V;
typedef complex<double> Point;

#define PI acos(-1.0)
#define EPS 1e-10
const ll INF = (1LL << 31) - 1;
const ll MOD = 1e9 + 7;

#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,N) for(int i=0;i<(N);i++)
#define ALL(s) (s).begin(),(s).end()
#define EQ(a,b) (abs((a)-(b))<EPS)
#define EQV(a,b) ( EQ((a).real(), (b).real()) && EQ((a).imag(), (b).imag()) )
#define fi first
#define se second
#define N_SIZE (1LL << 20)
#define NIL -1
#define MAX_N 100100 * 3

int n;

vector<ll> table, table2;

ll dp[2][2][1001000];

int main() {
	for (int i = 1; i*(i + 1)*(i + 2) / 6 <= 1000000; i++) {
		table.push_back(i*(i + 1)*(i + 2) / 6);
		if ((i*(i + 1)*(i + 2) / 6) % 2 == 1)table2.push_back(i*(i + 1)*(i + 2) / 6);
	}
	//cout << table.size() << endl;
	REP(i, 2) {
		REP(j, 2) {
			REP(k, 1001000)dp[i][j][k] = INF;
		}
	}
	dp[0][0][0] = 0;
	dp[1][0][0] = 0;

	REP(i, table.size()) {
		int num = table[i];
		REP(j, 1000000) {
			if (j - num >= 0) {
				dp[0][(i + 1) % 2][j] = min(dp[0][(i + 1) % 2][j - num] + 1, dp[0][i % 2][j]);
			}
			else dp[0][(i + 1) % 2][j] = dp[0][i % 2][j];
		}
	}

	for (int i = 0; i < table2.size(); i++) {
		int num = table2[i];
		//cout << num << endl;
		REP(j, 1000000) {
			if (j - num >= 0) {
				dp[1][(i + 1) % 2][j] = min(dp[1][(i + 1) % 2][j - num] + 1, dp[1][i % 2][j]);
			}
			else dp[1][(i + 1) % 2][j] = dp[1][i % 2][j];
		}
	}
	
	while (cin >> n&&n) {
		cout << dp[0][table.size() % 2][n] << " "
			<< dp[1][table2.size() % 2][n] << endl;
	}
}

Measured memory_bytes: 34276
import java.util.*;

public class Main {

    public static void main(String[] args) {
        // write your code here
        Scanner sc = new Scanner(System.in);

        int n = sc.nextInt();
        int k = sc.nextInt();
        long[] list = new long[n];

        for (int i = 0; i < n; i++) {
            list[i] = sc.nextLong();
        }

        Arrays.sort(list);

        long[] comb = new long[n];
        long[] rf = new long[n];
        long[] f = new long[n];
        f[0] = 1;

        final int mod = 1000000007;

        for (int i = 1; i < n; i++) {
            f[i] = (f[i - 1] * i) % mod;
        }
        rf[n - 1] = pow(f[n - 1], mod - 2, mod);
        for (int i = n - 2; i >= 0 ; i--) {
            rf[i] = (rf[i + 1] * (i + 1)) % mod;
        }

        for (int i = k - 1; i < comb.length ; i++) {
            long a = f[i]; // n!
            long b = rf[i - (k - 1)]; // (n-k)!
            long c = rf[k - 1]; // k!
            long bc = (b * c) % mod;

            comb[i] = (a * bc % mod);
        }

        long ans = 0;

        for (int i = 0; i < n; i++) {
            long min = comb[n - i - 1];
            long max = comb[i];
            long gap = max - min;
            ans += list[i] * gap % mod;
            ans %= mod;
        }

        System.out.println(ans);
    }

    //return a^b mod M O(logB)
    private static long pow(long a,long b,int M) {
        long ret = 1;
        long tmp = a;
        while(b>0) {
            if((b&1)==1) ret = (ret * tmp) % M;
            tmp = (tmp * tmp) % M;
            b = b>>1;
        }
        return ret;
    }
}

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

// #undef DEBUG  // Uncomment this line to forcefully disable debug print.
#if DEBUG
template <typename T>
void debug(const T& value) {
  std::cerr << value;
}
template <typename T, typename... Ts>
void debug(const T& value, const Ts&... args) {
  std::cerr << value << ", ";
  debug(args...);
}
#define dbg(...)                        \
  do {                                  \
    cerr << #__VA_ARGS__ << ": ";       \
    debug(__VA_ARGS__);                 \
    cerr << " (L" << __LINE__ << ")\n"; \
  } while (0)
#else
#define dbg(...)
#endif

void read_from_cin() {}
template <typename T, typename... Ts>
void read_from_cin(T& value, Ts&... args) {
  std::cin >> value;
  read_from_cin(args...);
}
#define in(type, ...) \
  type __VA_ARGS__;   \
  read_from_cin(__VA_ARGS__);

template <typename T>
void write_to_cout(const T& value) {
  std::cout << value << '\n';
}
template <typename T, typename... Ts>
void write_to_cout(const T& value, const Ts&... args) {
  std::cout << value << ' ';
  write_to_cout(args...);
}
#define out(...) write_to_cout(__VA_ARGS__);

#define all(x) (x).begin(), (x).end()
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)

using ll = long long;

template <typename T>
using V = std::vector<T>;
template <typename T>
using VV = V<V<T>>;

using namespace std;

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

  in(int, n);
  V<int> a(n);
  rep(i, n) cin >> a[i];
  ll ans = 0;
  ll l = 0;
  ll x = 0;
  for (ll r = 0; r < n; ++r) {
    while (x & a[r]) {
      x ^= a[l];
      ++l;
    }
    x ^= a[r];
    ans += r - l + 1;
  }
  out(ans);
  /*
  for (ll l = 0; l < n;) {
    ll r = l;
    int x = a[l];

    while (r + 1 < n && !(a[r + 1] & x)) {
      x |= a[r + 1];
      ++r;
    }
    ll d = r - l + 1;
    ans += d * (d + 1) / 2;
    l = r + 1;
  }
  out(ans);
  */
  /*
  for (int l = 0; l < n; ++l) {
    for (int r = l; r < n; ++r) {
      int s = 0;
      int x = 0;
      bool colide = false;
      for (int i = l; i <= r; ++i) {
        if (x & a[i]) colide = true;
        s += a[i];
        x ^= a[i];
      }
      dbg(s, x, colide);
      if (colide && s == x) {
        dbg(l, r, s);
      }
    }
  }
  */
}


Measured memory_bytes: 3984
#include<iostream>
#include<algorithm>
#include<cmath>
#include<string>
#include<vector>
#include<set>
using namespace std;

int main(void){
    int n[1010];
    int D,N;
    cin>>D>>N;
    if(D==0){
    for(int i=1;i<100;i++){
        n[i]=i;
    }
    n[100]=101;
    }
    else if(D==1){
    for(int i=1;i<100;i++){
        n[i]=i*100;
    }
    n[100]=10100;
    }
    else{
    for(int i=1;i<100;i++){
        n[i]=i*10000;
    }
    n[100]=1010000;
    }
    cout<<n[N];
}

Measured memory_bytes: 256
// C < Dなら、ふぬけ君を先に目的地Dまで移動させ、その後すぬけ君を目的地Cまで移動させる。
// その場合、岩が連続していない限りは目的地にたどり着けそう
// C > Dなら、ふぬけ君の目的地の隣に岩があるなら、先にすぬけ君を目的地に移動させ、
// 最後にふぬけ君を移動させる
// (この条件がわからなかった、、、)
// →すぬけ君がふぬけ君を追い抜かす(またぐ)必要があり、
// そのためにはふぬけ君が移動するBとDの間で、3マス以上のスペースが必要
#include <bits/stdc++.h>
using namespace std;

int main() {
    int N, A, B, C, D;
    cin >> N >> A >> B >> C >> D;
    string S(N, '.');
    cin >> S;

    if (C < D)
    {
        for(int i = A-1; i < min(D,N-1); ++i) {
            if(S[i] == '#' && S[i+1] == '#'){
                cout << "No" << endl;
                return 0;
            }
        }
        cout << "Yes" << endl;
    }
    else
    {
        for(int i = B-1; i < min(D,N-1); ++i) {
            if(S[i-1] == '.' && S[i] == '.' && S[i+1] == '.') {
                cout << "Yes" << endl;
                return 0;
            }
        }
        cout << "No" << endl;
    }
    
    
    return 0;
}

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

const int MAXN = 100010;
const int INF = MAXN;

#define eb emplace_back

struct EDGE {
	int v, cap, rev;
	EDGE(int v, int cap, int rev) : v(v), cap(cap), rev(rev) {}
};

int P[MAXN], Q[MAXN];
int X[MAXN], Y[MAXN];
bool chk[MAXN];
vector<EDGE> ed[2 * MAXN];
int work[2 * MAXN], lvl[MAXN];
int S, E;

void addedge(int a, int b, int c, int d) {
	//printf("addedge(%d, %d, %d, %d)\n", a, b, c, d);
	ed[a].eb(b, c, ed[b].size());
	ed[b].eb(a, d, ed[a].size() - 1);
}

bool bfs() {
	memset(lvl, 0, sizeof(lvl));
	lvl[S] = 1;
	queue<int> q;
	q.push(S);
	while(!q.empty()) {
		int t = q.front();
		q.pop();
		for(auto &a : ed[t]) if(!lvl[a.v] && a.cap) {
			lvl[a.v] = lvl[t] + 1;
			q.push(a.v);
		}
	}
	return lvl[E];
}

int dfs(int x, int fl) {
	if(x == E) return fl;
	for(; work[x] < ed[x].size(); work[x]++) {
		EDGE &e = ed[x][work[x]];
		if(!e.cap || lvl[e.v] != lvl[x] + 1) continue;
		int c = dfs(e.v, min(fl, e.cap));
		if(c) {
			e.cap -= c;
			ed[e.v][e.rev].cap += c;
			return c;
		}
	}
	return 0;
}

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

	cin >> N;
	for(int i = 0; i < N; i++) cin >> P[i];
	for(int i = 0; i < N; i++) cin >> Q[i];

	for(int i = 0; i < N; i++) if(!chk[i]) {
		//printf("i = %d\n", i);
		for(int t = i; !chk[t]; t = P[t]) {
			chk[t] = true;
			X[t] = S;
		}
		S++;
	}
	memset(chk, 0, sizeof(chk));
	for(int i = 0; i < N; i++) if(!chk[i]) {
		//printf("i = %d\n", i);
		for(int t = i; !chk[t]; t = Q[t]) {
			chk[t] = true;
			Y[t] = S;
		}
		S++;
	}

	E = S + 1;
	int ans = 0;
	for(int i = 0; i < N; i++) {
		if(P[i] == i && Q[i] == i) ans++;
		else if(P[i] == i) addedge(Y[i], E, 1, 0);
		else if(Q[i] == i) addedge(S, X[i], 1, 0);
		else if(P[i] != Q[i]) addedge(Y[i], X[i], 1, 0);
		else addedge(X[i], Y[i], 1, 1);
	}

	while(bfs()) {
		memset(work, 0, sizeof(work));
		while(1) {
			int c = dfs(S, INF);
			if(!c) break;
			ans += c;
		}
	}
	cout << N - ans << "\n";
	return 0;
}


Measured memory_bytes: 15360
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int maxn=100010;
const int inf=2147483647;
int n,m,cnt;
int f[maxn];
int find(int x){
	if(x==f[x])return x;
	else return f[x]=find(f[x]);
} 
int main(){
	cin>>n>> m;
	for(int i=1;i<=n;i++)f[i]=i;
	while(m--){
		int x,y,z;
		cin>>x>>y>>z;
		int fatherx=find(x);
		int fathery=find(y);
		if(fatherx!=fathery){
			f[fatherx]=fathery;
			cnt++;
		}
	}
	cout<<n-cnt<<endl;
	return 0;
}

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

const int N = 1e5+10;
ll a[N],b[N],primes[N];
int n,vis[N],k;
map<ll,int>mp;

void init(){
    k = 0;
    for(ll i = 2; i*i*i <= 1e10; i ++){
        int flag = 0;
       for(int j = 2; j <= i/2; j ++) if(i%j==0){flag=1;break;}
       if(flag==0) primes[k++] = i;
    }
}

ll sqr(ll x){
    return x*x;
}

int main(){
    init();
    scanf("%d",&n);
    for(int i = 1; i <= n; i ++){
        ll x; scanf("%lld",&x);
        for(int j = 0; j < k; j ++){
            ll tmp = primes[j]*primes[j]*primes[j];
            if(tmp > x) break;
            while(x % tmp == 0) x /= tmp;
        }
        mp[x] ++; a[i] = x;
        ll y = 1;
        for(int j = 0; j < k; j ++){
            ll tmp = primes[j]*primes[j]*primes[j];
            if(tmp > x) break;
            if(x % primes[j] == 0){
                y *= (x % (primes[j]*primes[j]) == 0) ? primes[j] : primes[j]*primes[j];
                while(x % primes[j] == 0) x /= primes[j];
            }
        }
        if(sqr((ll)sqrt(x)) == x) y *= (ll)sqrt(x);
        else y *= x*x;
        b[i] = y;
    }
    int ans = 0;
    if(mp[1]) ans ++, mp[1] = 0;
    for(int i = 1; i <= n; i ++){
        ans += max(mp[a[i]],mp[b[i]]); mp[a[i]] = mp[b[i]] = 0;
    }
    printf("%d\n",ans);
    return 0;
}


Measured memory_bytes: 14336
#
#　　　　　　　　　　　　　　,. -─────────‐- .、
#　　　　　　　　　　　　 ／／￣￣＼　　　　　　／￣￣＼＼
#　　　　　　　　　　　／　　　　　　　　　　　　　　　　　　　　 ＼
#　　　　　　　　　 ／　　　　　　　　::::::::::::::::::::::::::::::::　　　　　　　＼
#　　　　　　　　／ 　　／ ／￣＼＼::::;;;;;;;;;;;;;;;;;:::::／／￣＼＼　　＼
#　　　　　　 ／　　　　|　 |.　┃　.|　| ::::;;;;;;;;;;;;;::::｜ |.　┃　.|　|　　　 ＼　　　　　　　　　　　　　　　　　　　　　
#　　　　　／ 　　　　　＼ ＼＿／／　::::::::::::::::::　＼＼＿／／　　　　　 ＼　　　　
#　　　 ／　　　　　..／￣￣＼　／　　　::｜::　　　＼　／￣￣＼..　　　　　＼
#　　 / 　 　 　 　 :::::　　　　　　|　　　　　 |　　　　　 |　　　　　　 :::::　　　　　 ヽ.　　　
#　　| 　　　　　　　　　　　　　　|　　　　　 |　　　　　 |　　　　　　　　　　　　　　|.
#　　| 　　　　　　　　　　　　　　＼＿＿／＼＿＿／ 　　　　　　　　　　　　　　|　　　　　　　　　　　　　　　　　
#　　| 　　　　　　　　　　　　　　　｜　　　　　　　｜　　　　　　　　　　　　　　　|
#　　| 　　　　　　　　　　　　　　　｜r─‐┬──､|　　　　　　　　　　　　　　　 |
#　　ヽ　　　　　　　　　　　　　　　 |/　　　|　　 　｜　　　　　　　　　　　　　　/
#　　　 ＼　　　　　　　　　　　　　 ＼　　　　　　／　　　　　　　　　　　　　／
#　　　　　＼ 　　　　　　　　　　　　　￣￣￣￣　　　　　　　　　　　　　／
#
#
import sys
input=sys.stdin.readline
inf=float('inf')
mod = 10**9+7
def INT_(n): return int(n)-1
def MI(): return map(int,input().split())
def MF(): return map(float, input().split())
def MI_(): return map(INT_,input().split())
def LI(): return list(MI())
def LI_(): return [int(x) - 1 for x in input().split()]
def LF(): return list(MF())
def LIN(n:int): return [input() for _ in range(n)]
def LLIN(n: int): return [LI() for _ in range(n)]
def LLIN_(n: int): return [LI_() for _ in range(n)]
def LLI(): return [list(map(int, l.split() )) for l in input()]
def I(): return int(input())
def F(): return float(input())
def ST(): return input().replace('\n', '')
def main():
    N = I()
    A = LI()
    A_copy = []
    for i, a in enumerate(A,start=1):
        A_copy.append((a,i))

    A_copy.sort()
    if A_copy[-1][0] <= 0:
        print(N-1)
        #逆順cumsum
        for i in range(1,N)[::-1]:
            print(i+1,i)
            #A[i-1]+=A[i]
    elif A_copy[0][0] >= 0:
        print(N-1)
        #正順cumsum
        for i in range(1,N):
            print(i, i + 1)
            #A[i+1]+=A[i]
    elif abs(A_copy[0][0]) > abs(A_copy[-1][0]):
        print(2*N-1)
        min_index = A_copy[0][1]
        for i in range(N):
            print(min_index, i + 1)
            #A[i]+=A[min_index-1]
        for i in range(1,N)[::-1]:
            print(i + 1, i)
            #A[i-1]+=A[i]
    else:
        print(2*N-1)
        max_index = A_copy[-1][1]
        for i in range(N):
            print(max_index, i + 1)
            #A[i]+=A[max_index-1]
        for i in range(1,N):
            print(i, i + 1)
            #A[i]+=A[i-1]
    
    #print(A)

    """A_copy = []
    for i, a in enumerate(A,start=1):
        A_copy.append((a,i))

    A_copy.sort()
    A_indexes = [i for (a, i) in A_copy]
    print(2*N)
    for i,j in enumerate(A_indexes,start=1):
        print(i,j)
        print(i, j)
        A[i-1] += 2 * A[j-1]
    print(A)"""
if __name__ == '__main__':
    main()


Measured memory_bytes: 38384
#include <iostream>
using namespace std;
typedef long long ll;
ll N;
ll A[6] = {};

int main(){
    cin >> N;
    for(int i=1;i<=5;i++) cin >> A[i];
    ll ans = 0;
    for(int i=1;i<=5;i++){
        ans = max(ans,5-1+(N+A[i]-1)/A[i]);
    }
    cout << ans << endl;
}

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

using pe = pair<int, int>;

int main(void)
{
    int N;
    cin >> N;
    vector<ll> A(N);
    for (int i = 0; i < N; i++)
    {
        cin >> A[i];
    }
    ll mon = 1000;
    ll stock = 0;

    A.push_back(0);

    for(int i = 1; i < N+1; i++){
        if(A[i-1] < A[i]){
            stock += mon / A[i-1];
            mon = mon % A[i-1];
        } else if(A[i-1] > A[i]){
            mon += stock * A[i-1];
            stock = 0;
        }
    }

    cout << mon << endl;
    
    return 0;
}


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

using namespace std;
#define For(i, a, b)    for(int i = (a) ; i < (b) ; ++i)
#define rep(i, n)       For(i, 0, n)


int main()
{
	int h, w;
	cin >> h >> w;
	vector<int> count(26,0);
	rep(i,h){
		string s;
		cin >> s;
		rep(j,w){
			int c = s[j] - 'a';
			count[c] += 1;
		}
	}

	int need4, need2;
	need4 = (h / 2) * (w / 2) ;
	need2 = (h/2) * (w%2) + (w/2) * (h%2);

	rep(i,26){
		while(count[i] >= 4){
			if(need4 == 0) break;
			count[i] -= 4;
			need4 --;
		}
	}
	rep(i,26){
		while(count[i] >= 2){
			if(need2 == 0) break;
			count[i] -= 2;
			need2 --;
		}
	}
	if(need4 + need2){
		puts("No");
	} else {
		puts("Yes");
	}

}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using vl = vector<ll>;
using vll = vector<vl>;
using Pll = pair<ll, ll>;
#define rep(i,n) for(ll i=0;i<(ll)(n);i++)
#define all(v) v.begin(), v.end()
#define sz(x) ((int) x.size())
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define F first
#define S second
const int MOD = 1e9+7;
const ll INF = 2e15;
template<class T> void print(const T& t){ cout << t << endl; }
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; }
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}

int main(){
  ll n,c,k;
  cin >> n >> c >> k;
  vl t(n);
  rep(i,n){
    cin >> t[i];
  }
  sort(all(t));
  ll bus = 0;
  ll passenger = 1;
  ll limit = t[0] + k;
  for (ll i = 1; i < n; i++){
    if(t[i]<=limit&&passenger<c){
      passenger++;
    }
    else{
      bus++;
      passenger = 1;
      limit = t[i] + k;
    }
  }
  bus++;
  print(bus);
}

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

using namespace std;

int main()
{
    int n,m;
    cin >> n >> m;
    bool graph[n + 1][n + 1];
    for(int i = 0;i < n;i++){
    for(int j = 0;j < n;j++){
        graph[i][j] = false;
    }
    }
    for(int i = 1;i <= m;i++){
        int a,b;
        cin >> a >> b;
        graph[a - 1][b - 1] = graph[b - 1][a - 1] = true;
    }
    int dp[1 << n][n];
    for(int i = 0;i < (1 << n);i++)
        for(int j = 0;j < n;j++)
            dp[i][j] = 0;

    dp[1][0] = 1;
    for(int i = 1;i < (1 << n);i++){
        for(int last = 0;last < n;last++){
            //cout << dp[i][last] << " " << i << " " << last << endl;
            for(int j = 0;j < n;j++){
            if(((1 << j) & i) > 0 || !graph[last][j])continue;
            dp[i | (1 << j)][j] += dp[i][last];
        }
    }
    }
    int ans = 0;
    for(int i = 0;i < n;i++){
        ans += dp[(1 << n) - 1][i];
        //cout << ans << " " << dp[1 << n][i] << " " << (1 << n) << " " << i << endl;
    }
        cout << ans;
        return 0;
    }


Measured memory_bytes: 256
#include<stdio.h>

int main(){
  int n;
  scanf("%d", &n);
  if(n%7 == 0){
    printf("Yes\n");
  } else {
    while(n > 3){
      n = n - 4;
      if(n%7 == 0){
        printf("Yes\n");
        break;
      }
    }
    if(n <= 3 && n != 0){
      printf("No\n");
    }
  }                                                                                          
  return 0;
}


Measured memory_bytes: 128
n = int(input())
ans = [0] * (10**5)
for i in range(1,101):
    for j in range(1,101):
        for k in range(1,101):
            ans[i ** 2 + j ** 2 + k ** 2 + i * j + j * k + k * i-1] += 1
for i in range(n):
    print(ans[i])

Measured memory_bytes: 9892
main :: IO ()
main = interact $ unlines . map (ball . map (read::String->Int) . words) . read' . lines
 where
  read' [] = []
  read' (n:xs) = take (read n) xs

ball :: [Int] -> String
ball bs = case ball' 0 0 bs of {True -> "YES"; False -> "NO"}
 where
  ball' l r bs'
   | null bs' = True
   | l < head bs' && r < head bs' = ball' (head bs') r (tail bs') || ball' l (head bs') (tail bs')
   | l < head bs' = ball' (head bs') r (tail bs')
   | r < head bs' = ball' l (head bs') (tail bs')
   | otherwise = False

Measured memory_bytes: 4044
import java.util.Scanner;

public class Main {
    public static void debug(String str) {
        boolean debug = false;
        if (debug != false) {
            return;
        }
        System.out.println(str);
    }

    public static void main(String[] args) {

        int N;
        long A[];
        long B[];

        try (Scanner sc = new Scanner(System.in)) {
            N = sc.nextInt();
            A = new long[N+1];
            B = new long[N];
            for(int i =0;i < N+1;i++){
                A[i] = sc.nextLong();
            }
            for(int i =0;i < N;i++){
                B[i] = sc.nextLong();
            }
        }
        long result = 0;
        for(int i =0;i < N;i++){
            if(B[i] > A[i]){
                result += A[i];
                long temp = A[i];
                A[i]-=temp;
                B[i] -=temp;
            }else{
                result += B[i];
                long temp = B[i];
                B[i]-=temp;
                A[i] -=temp;
            }
            if(B[i] > A[i+1]){
                result += A[i+1];
                long temp = A[i+1];
                A[i+1]-=temp;
                B[i] -=temp;
            }else{
                result += B[i];
                long temp = B[i];
                B[i]-=temp;
                A[i+1] -=temp;
            }
        }
        System.out.println(result);




        return;
    }
}


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

#define MAX 100000
#define INF (INT32_MAX/2)

int N;
int h[MAX];

int dp[MAX];

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

	for( int i = 0; i < N; i++ ) {
		dp[i] = INF;
	}
	dp[0] = 0;
	for( int i = 0; i < N; i++ ) {
		dp[i + 1] = min( dp[i + 1], dp[i] + abs( h[i] - h[i + 1] ) );
		dp[i + 2] = min( dp[i + 2], dp[i] + abs( h[i] - h[i + 2] ) );
	}
	int ans = dp[N - 1];

	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 1024
a,b =map(int,input().split())
#print(a,b)
c=0
if a>=b:
    i=1
    while a*i%b!=0:
        i+=1
    else:
        c=a*i
else:
    j=1
    while b*j%a!=0:
        j+=1
    else:
        c=b*j
    
print(c)

Measured memory_bytes: 2940
//#include <bits/stdc++.h>
//#include <stdlib.h>
//using namespace std;
//
//typedef long long ll;
//typedef unsigned long long ull;
//
//#define CHECK_BIT(var,pos) ((var) & (1<<(pos)))
//
//struct node {
//    node(int w, int s, int idx) {
//        this->w = w;
//        this->s = s;
//        this->idx = idx;
//    }
//    node() { }
//    int w, s, idx;
//    bool operator < (node a) {
//        if (this->w == a.w) {
//            return this->s > a.s;
//        }
//        return this->w < a.w;
//    }
//};
//
//vector<pair<int, int> > v;
//vector<node> res, res_final;
//
//int dp[1500];
//
//bool valid(vector<node> v) {
//    for (int i = 1; i < v.size(); i++) {
//        if (v[i].w > v[i-1].w && v[i].s < v[i-1].s)
//            continue;
//        else return 0;
//    }
//    return 1;
//}
//
//ll solve(int idx) {
//    if (idx == v.size()) {
//        if (!valid(res))
//            return 0;
//        if (res.size() >= res_final.size())
//            res_final = res;
//        return 1;
//    }
//
//    res.push_back(node(v[idx].first, v[idx].second, idx));
//    bool a = solve(idx+1);
//    res.pop_back();
//    bool b = solve(idx+1);
//    return (a || b);
//}
//
//int main() {
//#ifndef ONLINE_JUDGE
//    freopen("file.in", "r", stdin);
//#endif
//    int x, y;
//    while (cin >> x >> y) {
//        v.push_back({x, y});
//    }
//    memset(dp, -1, sizeof(dp));
//    solve(0);
//    cout << res_final.size() << endl;
//    for (int i = 0; i < res_final.size(); i++) {
//        cout << res_final[i].idx + 1 << endl;
//    }
//}

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

int main() {
    int n, x;
    cin >> n >> x;
    vector<int> v(n);
    for (int i = 0; i < n; i++) {
        cin >> v[i];
        x -= v[i];
    }
    int res = n;
    bool f = 1;
    sort(v.begin(), v.end());
    
    while (f) {
        if (x-v[0] >= 0) {
            x -= v[0];
            res++;
        } else {
            f = 0;
        }
    }
    cout << res << endl;
}


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

using namespace std;

#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define all(x) (x).begin(), (x).end() 
#define MOD 1000000007

typedef long long ll;
typedef pair <int, int> ii;
typedef pair <ll, ll> pll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef long double ld;

ll INF=LLONG_MAX;

int main()
{
    ios_base::sync_with_stdio(0); cin.tie(0);
    //freopen("input.txt","r",stdin); freopen("output.txt","w",stdout);
	int n,m; cin >> n >> m;
	int ans = (n)*(n-1)/2 +(m)*(m-1)/2;
	cout << ans << endl;
}	
/* Benq's
	stuff you should look for
	* ll, int overflow, array bounds
	* special cases (n=1?)
	* do smth instead of nothing and stay organized
	* WRITE STUFF DOWN
*/


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

int main (){

	int count=0;
	int input;
	int max=0;

	int result=0;
	int prime[1000000]= {};
	int sq_num=0;
	int deli=0;
	int i=0;

	//??\???
	while(1){
		scanf("%d",&input);
		if(input == 0 ){
			break;
		}
		count = 0;

		prime[2]=1;
		i=3;
		while(1){
			prime[i]=1;
			i++;
			prime[i]=0;
			i++;
			if( i > 1000000){
				break;
			}
		}

		i=input;
		sq_num = (int)sqrt(2*i);
		i=2;	
		while(1){
			
			if(prime[i]==1){
				deli=i;
				
				while( input*2 > deli ){
					deli += i;
					//printf("deli:%d\n",deli );
					prime[deli] = 0;

				}

			}
			i++;

			if(sq_num < i){
				break;
			}

		}

		i=input;
		i++;
		while(1){
			if(prime[i] == 1){
				result++;
			}
			i++;
			
			if (2*input < i){
				break;
			}
		}
		
		
		if(input == 0 ){
		//printf("input finish\n");
			break;
		}
		printf("%d\n",result);

		result = 0;




	}
	

	return 0;
}

Measured memory_bytes: 4512
import java.util.Scanner;
import java.util.function.BiConsumer;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);

		int a = sc.nextInt();
		int b = sc.nextInt();

		BiConsumer<Integer, Integer> consumer = (i, j) -> {
			if (i <= 2 * j) {
				System.out.println(0);
			} else {
				System.out.println(i - 2 * j);
			}
		};
		consumer.accept(a, b);

	}

}


Measured memory_bytes: 28368
#include <bits/stdc++.h>
using namespace std;
using pint = pair<int, int>;
using ll = long long;
using ull = unsigned long long;
using vll = vector<long long>;
using pll = pair<ll, ll>;
#define FOR(i, begin, end) \
    for (int i = (begin), i##_end_ = (end); i < i##_end_; i++)
#define IFOR(i, begin, end) \
    for (int i = (end)-1, i##_begin_ = (begin); i >= i##_begin_; i--)
#define REP(i, n) FOR(i, 0, n)
#define IREP(i, n) IFOR(i, 0, n)
#define VREP(s, ite) for (auto ite = s.begin(); ite != s.end(); ++ite)
#define FI first
#define SE second
#define ALL(v) v.begin(), v.end()
//#define endl "\n"
#define ciosup  \
    cin.tie(0); \
    ios::sync_with_stdio(false);
#define eb emplace_back
#define vint vector<int>
constexpr ll INF = 1e15 + 7LL;
constexpr ll MOD = 1e9 + 7LL;
template <typename T>
istream &operator>>(istream &is, vector<T> &v) {
    for (int i = 0; i < v.size(); ++i) {
        is >> v[i];
    }
    return is;
}
template <typename T>
ostream &operator<<(ostream &os, const vector<T> &v) {
    for (int i = 0; i < v.size() - 1; ++i) {
        os << v[i] << " ";
    }
    if (v.size() > 0) {
        os << v[v.size() - 1] << endl;
    }
    return os;
}

int main() {
  ll n,k;
  cin >> n >> k;
  vll a(n);
  cin >> a;
  REP(i, k){
      vll up(n, 0), down(n, 0);
      REP(j, n){
        int minidx = max(0LL, j - a[j]), maxidx = min(j + a[j], ll(n - 1));
        up[minidx]++;
        down[maxidx]++;
      }
      ll nowadd = 0;
      REP(j,n){
          nowadd += up[j];
          a[j] = nowadd;
          nowadd -= down[j];
      }

      bool flag = true;
      REP(j, n) {
          if (a[j] != n) {
              flag = false;
          }
      }
    if (flag) break;
  }
  cout << a;
}

Measured memory_bytes: 8008
#include <iostream>
using namespace std;
int main() {
int r,c,rs[101],cs;
cin >> r >> c;
int h[101][101];
for (int i = 0; i<r; i++) {
for (int j = 0; j<c; j++) {
cin >> h[i][j];
}
}
for (int i = 0; i < 101; i++) {
rs[i] = 0;
}
for (int i = 0; i <= r; i++) {
cs = 0;
for (int j = 0; j <= c; j++) {
if (i != r) {
if(j!=c)cs += h[i][j];
if (j != c)rs[j] += h[i][j];
if (j == c) cout << cs << endl;
else cout << h[i][j] << " ";
}
else {
if (j != c)cs += rs[j];
if (j == c) cout << cs << endl;
else cout << rs[j] << " ";
}
}
}
}



Measured memory_bytes: 3128
fn main() {
    let stdin = std::io::stdin();
    let mut buf = String::new();
    stdin.read_line(&mut buf).ok();
    let vec: Vec<&str> = buf.split_whitespace().collect();
    let mut a: Vec<u32> = vec.iter().map(|&x| x.parse().unwrap_or(0)).collect();
    let mut gcd = 1;
    let mut d = 2;
    loop {
        if a[0] == 1 || a[1] == 1 {
            break;
        } else if a[0] % d == 0 && a[1] % d == 0 {
            a[0] /= d;
            a[1] /= d;
            gcd *= d;
            d = 2;
        } else if a[0] == d || a[1] == d {
            break;
        } else {
            d += 1;
        }
    }
    println!("{}", gcd);
}



Measured memory_bytes: 5024
#include <bits/stdc++.h>
#define int long long
using namespace std;

int n;

class BIT{
	vector<int> bit;
public:
	BIT() : bit(n + 2){}
	void add(int i,int x){
		while(i < bit.size()){
			bit[i] += x;
			i += i & -i;
		}
	}
	int get(int i){
		int s = 0;
		while(i){
			s += bit[i];
			i -= i & -i;
		}
		return s;
	}
};

signed main(){
	int q,x[200000],d[200000],l[200000];
	cin >> n >> q;
	vector<BIT> ps(2);
	ps[1].add(1,n - 1);
	for(int i = 1;i < n;i++){
		ps[0].add(i + 1,1);
		ps[1].add(i + 1,-1);
	}
	for(int i = 0;i < q;i++) cin >> x[i] >> d[i] >> l[i];
	for(int i = q - 1;i >= 0;i--){
		int low = -1,up = n;
		while(up - low > 1){
			int mid = (up + low) / 2;
			if(d[i] == 1){
				if(ps[0].get(mid + 1) < x[i]) low = mid;
				else up = mid;
			}else{
				if(ps[1].get(mid + 1) < n - x[i]) up = mid;
				else low = mid;
			}
		}
		if(d[i] == 1){
			ps[1].add(1,l[i] * 2);
			ps[1].add(up + 1,-l[i] * 2);
		}
		else ps[0].add(up + 1,l[i] * 2);
	}
	for(int i = 0;i < n;i++) cout << (ps[0].get(i + 1) + ps[1].get(i + 1) - n + 1) / 2 << endl;
	return 0;
}


Measured memory_bytes: 10640
#define _USE_MATH_DEFINES
#include <cstdio>
#include <iostream>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <complex>
#include <string>
#include <vector>
#include <array>
#include <list>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <bitset>
#include <numeric>
#include <limits>
#include <climits>
#include <cfloat>
#include <functional>
#include <iterator>
#include <memory>
#include <regex>
using namespace std;

int main()
{
    long long t1, t2, a1, a2, b1, b2;
    cin >> t1 >> t2 >> a1 >> a2 >> b1 >> b2;

    long long d2 = (b1 * t1 + b2 * t2) - (a1 * t1 + a2 * t2);
    if(d2 == 0){
        cout << "infinity" << endl;
        return 0;
    }
    else if(d2 < 0){
        swap(a1, b1);
        swap(a2, b2);
        d2 *= -1;
    }

    long long d1 = a1 * t1 - b1 * t1;
    if(d1 < 0){
        cout << 0 << endl;
        return 0;
    }

    long long ans = d1 / d2 * 2 + 1;
    if(d1 % d2 == 0)
        -- ans;
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<cmath>
#include<string>
#include<map>
#include<list>
#include<cctype>
using namespace std;

vector<int> split(string s,char c){
	vector<int> v;string tmp;
	for(int i=0;i<s.size();i++){
		if(s[i]==c){
			v.push_back(stoi(tmp));
			tmp ="";
		}
		else tmp += s[i];
	}
	if(tmp!="")v.push_back(stoi(tmp));
	return v;
}

int main(void){
	string s;
	getline(cin,s);
	for(int i=0;i<s.size();i++){
		if(isupper(s[i]))
			printf("%c",tolower(s[i]));
		else
			printf("%c",toupper(s[i]));
	}
	cout << endl;
	return 0;
}

Measured memory_bytes: 1184
#define _GLIBCXX_DEBUG
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define rep(i,N) for(int i = 0;i < (int)(N);i++)
int main(){
int a,b;
  cin>>a>>b;
  if(a*b==2) cout<<3<<endl;
    if(a*b==3) cout<<2<<endl;
    if(a*b==6) cout<<1<<endl;
}
  


Measured memory_bytes: 256
#include "iostream"
#include "algorithm"
#include "string"
#include "vector"
#include "cmath"
using namespace std;
int main() {
	string n;
	cin >> n;
	if (!(n[0] == n[1] && n[1] == n[2]) && (!(n[1] == n[2] && n[2] == n[3])))
		cout << "No" << endl;
	else cout << "Yes" << endl;

	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
using namespace std;

#define Max 			1e6
#define ff              first
#define ss              second
#define ll             long long
#define pb              push_back
#define ppb				pop_back
#define pf				push_front
#define ppf				pop_front
#define mp              make_pair
#define pii             pair<ll,ll>
#define vi              vector<ll>
#define v 				vector
#define mii             map<ll,ll>
#define umap			unordered_map
#define pq              priority_queue<ll>
#define pqm             priority_queue<ll,vi,greater<ll> >
#define setbits(x)      __builtin_popcountll(x)
#define zrobits(x)      __builtin_ctzll(x)
#define mod             1000000007
#define inf             1e18
#define ps(x,y)         fixed<<setprecision(y)<<x
#define mk(arr,n,type)  type *arr=new type[n];
#define w(x)            ll x; cin>>x; while(x--)
#define all(x)			x.begin(),x.end()
#define sp 				' '
#define pi 				3.14159265359
#define intmax 			INT32_MAX
#define intmin			INT32_MIN
#define conti           continue
mt19937                 rng(chrono::steady_clock::now().time_since_epoch().count());
// ll d8[8][2] = {{ -1, -1}, { -1, 0}, { -1, 1}, {0, -1}, {0, 1}, {1, -1}, {1, 0}, {1, 1}};
// ll d4[4][2] = {{ -1, 0}, {0, -1}, {0, 1}, {1, 0}};
typedef tree<ll, null_type, less<ll>, rb_tree_tag, tree_order_statistics_node_update> pbds;
/* ordered set:
tree<T, null_type,less<T>, rb_tree_tag,tree_order_statistics_node_update>
member functions :
1. order_of_key(k) : number of elements strictly lesser than k
2. find_by_order(k) : k-th element in the set
*/
void IO()
{
#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
	freopen("error.txt", "w", stderr);
#endif
}
void fastIO()
{
	ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
}




int main()
{
	fastIO();
	IO();
	ll n;
	cin >> n;
	ll ans = 0;
	ll temp = 0;
	for (ll i = 1; i <= n; i++)
	{
		temp = (10 * temp + 7) % n;
		if (temp == 0)
		{
			ans = i;
			break;
		}
	}
	if (ans == 0)
		cout << -1 << endl;
	else
	{
		cout << ans << endl;
	}
	return 0;
}

Measured memory_bytes: 3660
#include <iostream>
#include <vector>
#include <map>
#include <cmath>
#include <algorithm>
#define endl "\n"
using namespace std;

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

    string str[h];
    for(int i = 0; i < h; i ++)
    	cin >> str[i];

    for(int i = 0; i < w + 2; i ++)
    	cout << "#";
    cout << endl;
    for(int i = 0; i < h; i ++)
    {
    	cout << "#";
    	cout << str[i];
    	cout << "#";
    	cout << endl;
    }
    for(int i = 0; i < w + 2; i ++)
    	cout << "#";
    cout << endl;
}

Measured memory_bytes: 256