akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
/*
#include<algorithm>
#include<array>
#include<cassert>
#include<cmath>
#include<cstdlib>
#include<functional>
#include<iomanip>
#include<iostream>
#include<map>
#include<numeric>
#include<queue>
#include<set>
#include<stack>
#include<string>
#include<typeinfo>
#include<utility>
#include<vector>
*/
#define int long long int
#define double long double
using namespace std;
#define MOD 1000000007
#define INF 1000000000000000007
const int MAX_N = 1 << 17;
#define rep(i, n) for (int(i) = 0, i##_len = (n); (i) < i##_len; (i)++)
#define reps(i, x) for (int(i) = 1; (i) <= (int)(x); (i)++)
#define rrep(i, x) for (int(i) = ((int)(x)-1); (i) >= 0; (i)--)
#define rreps(i, x) for (int(i) = ((int)(x)); (i) > 0; (i)--)
#define FOR(i, a, b) for (int(i) = (a); (i) < (b); (i)++)
#define pb push_back
#define mp make_pair
#define bit(n) ((int)(1) << (n))
#define all(x) (x).begin(), (x).end()
#define debug(x) std::cout << #x << ": " << (x) << std::endl
#define nint int
using namespace std;

int dy[] = {0, 0, 1, -1, 0};
int dx[] = {1, -1, 0, 0, 0};
typedef pair<int, int> pii;
typedef pair<double, double> dop;
template <class T>
bool chmax(T& a, const T& b)
{
    if (a < b) {
        a = b;
        return 1;
    }
    return 0;
}
template <class T>
bool chmin(T& a, const T& b)
{
    if (b < a) {
        a = b;
        return 1;
    }
    return 0;
}
int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }
struct aaa {
    aaa()
    {
        cin.tie(0);
        ios::sync_with_stdio(0);
        cout << fixed << setprecision(20);
    };
} aaaaaaa;


int checker(std::vector<int>& a, int n, int m, int v, int p, int mid)
{
    if (mid >= n - p) {
        return 1;
    } else if (a[mid] + m < a[n - p]) {
        return 0;
    }
    int sum = m * (v - 1);
    sum -= (mid + (p - 1)) * m;
    if (sum <= 0) {
        return 1;
    } else {
        for (int i = mid + 1; i <= n - p; i++) {
            sum -= min((int)m, a[mid] + m - a[i]);
        }
        if (sum <= 0) {
            return 1;
        } else {
            return 0;
        }
    }
}


signed main()
{
    int n, m, v, p;
    cin >> n >> m >> v >> p;
    std::vector<int> a(n);
    for (int i = 0; i < n; i++) {
        cin >> a[i];
    }
    std::sort(a.begin(), a.end());
    int ng = -1;
    int ok = (int)a.size();
    while (abs(ok - ng) > 1) {
        int mid = (ok + ng) / 2;
        if (checker(a, n, m, v, p, mid)) {
            ok = mid;
        } else {
            ng = mid;
        }
    }
    cout << n - ok << endl;
    return 0;
}

Measured memory_bytes: 1024
#![allow(unused, non_snake_case, dead_code, non_upper_case_globals)]
use {
    proconio::{marker::*, *},
    std::{cmp::*, collections::*, mem::*},
};

#[fastout]
fn main() {
    input! {
        n:usize,
        vu:[(Usize1,Usize1);n-1],
    }
    let mut ans = 0;
    for i in 0..n {
        ans += (i + 1) * (n - i);
    }
    for (x, y) in vu.iter() {
        let mut x = x;
        let mut y = y;
        if x > y {
            swap(&mut x, &mut y);
        }
        ans -= (x + 1) * (n - y);
    }
    println!("{}", ans);
}


Measured memory_bytes: 7684
n, m = map(int, input().split())
AB, CD = [], []
for _ in range(n):
    a, b = map(int, input().split())
    AB.append((a,b))
for _ in range(m):
    c, d = map(int, input().split())
    CD.append((c,d))

for ab in AB:
    num = 0
    dist = 10**10
    for i in range(len(CD)):
        dist_can = abs(ab[0]-CD[i][0]) + abs(ab[1]-CD[i][1])
        if dist_can < dist:
            dist = dist_can
            ans = i+1
    print(ans)

Measured memory_bytes: 3064
#include<stdio.h>
#include<stdlib.h>
#define PI 3.141592653589

int main()
{
  int h,w,i,j;
  while(1)
    {
      scanf("%d %d",&h,&w);
      if(h == 0 && w == 0) break;
      for(i = 0; i < h; i++)
	{
	  for(j = 0; j < w; j++)
	    {
	      if(i < h-1 && i > 0 && j < w-1 && j > 0) printf(".");
	      else printf("#");
	    }
	  printf("\n");
	}
      printf("\n");
    }
  return 0;
}

Measured memory_bytes: 572
// Last Change: 09/10/2019 13:49:29.
#include <algorithm>
#include <array>
#include <bitset>
#include <cmath>
#include <cstdlib>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <memory>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>

using namespace std;
using ll = long long;

int main() {
  ll N, K;
  cin >> N >> K;
  vector<ll> V(N);
  for (auto &&e : V) {
    cin >> e;
  }
  
  ll ans = 0;
  for (int x = 0; x <= min(N, K); ++x) {
    for (int y = 0; y <= min(N, K) - x; ++y) {
      ll sum = 0;
      priority_queue<ll, vector<ll>, greater<ll>> pq;
      for (int i = 0; i < x; ++i) {
        sum += V[i];
        if (V[i] < 0)
          pq.push(V[i]);
      }
      for (int i = 0; i < y; ++i) {
        sum += V[N - 1 - i];
        if (V[N - 1 - i] < 0)
          pq.push(V[N - 1 - i]);
      }

      for (int i = 0; i < K - x - y and !pq.empty(); ++i) {
        sum -= pq.top();
        pq.pop();
      }

      ans = max(ans, sum);
    }
  }

  cout << ans << endl;
}


Measured memory_bytes: 256
'use strict';
const main = input => {
  let n = parseInt(input[0]), a = input[1].split(' ').map(val => parseInt(val));
  // console.log(n, a);
  let id = 0, count = 0;
  a.map(val => {
    if (val-1 == id) {
      id++;
    } else {
      count++;
    }
  })
  if (!id) return console.log(-1);
  console.log(count);
  
}
main(require("fs").readFileSync("/dev/stdin", "utf8").split('\n'));

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

int main(){
	int n,m,q,a[200000],b[200000],qs[200000],d[100000];
	bool used[200000] = {},connect[100000] = {};
	vector<int> g[100000],G[100000],res;
	connect[0] = true;
	cin >> n >> m >> q;
	for(int i = 0;i < n;i++) d[i] = -1;
	queue<int> que;
	que.push(0);
	for(int i = 0;i < m;i++){
		cin >> a[i] >> b[i]; a[i]--;b[i]--;
		g[a[i]].push_back(b[i]);
		g[b[i]].push_back(a[i]);
	}
	d[0] = 0;
	for(int i = 0;;i++){
		int siz = que.size();
		if(siz == 0) break;
		for(int j = 0;j < siz;j++){
			int v = que.front();que.pop();
			for(int k = 0;k < g[v].size();k++){
				if(d[g[v][k]] == -1){
					d[g[v][k]] = i + 1;
					que.push(g[v][k]);
				}
			}
		}
	}
	for(int i = 0;i < q;i++) {
		cin >> qs[i]; qs[i]--;
		used[qs[i]] = true;
	}
	for(int i = 0;i < m;i++){
		if(used[i]) continue;
		G[b[i]].push_back(a[i]);
		G[a[i]].push_back(b[i]);
	}
	int cnt = n - 1;
	que.push(0);
	for(int j = 0;;j++){
		int siz = que.size();
		if(!siz) break;
		for(int k = 0;k < siz;k++){
			int v = que.front();que.pop();
			for(int i = 0;i < G[v].size();i++){
				if(!connect[G[v][i]] && d[G[v][i]] == j + 1){
					connect[G[v][i]] = true;
					cnt--;
					que.push(G[v][i]);
				}
			}
		}
	}
	res.push_back(cnt);
	for(int i = q - 1;i >= 1;i--){
		int A = a[qs[i]],B = b[qs[i]];
		G[A].push_back(B);
		G[B].push_back(A);
		if(connect[A] && connect[B]){
			res.push_back(cnt);
			continue;
		}
		if(connect[B]){
			int t = A;
			A = B;
			B = t;
		}
		if(!connect[A] || d[B] - d[A] < 1){
			res.push_back(cnt);
			continue;
		}
		connect[B] = true;
		cnt--;
		que.push(B);
		for(int k = 0;;k++){
			int siz = que.size();
			if(!siz) break;
			for(int l = 0;l < siz;l++){
				int v = que.front();que.pop();
				for(int j = 0;j < G[v].size();j++){
					int vv = G[v][j];
					if(!connect[vv] && d[A] + k + 2 == d[vv]){
						connect[vv] = true;
						cnt--;
						que.push(vv);
					}
				}
			}
		}
		res.push_back(cnt);
	}
	for(int i = q - 1;i >= 0;i--) cout << res[i] << endl;
	return 0;
}

Measured memory_bytes: 19300
#include <cstdio>
#include <cstring>
#include <cmath>
#include <string>
#include <algorithm>
#define INF 0x3f3f3f3f;

using namespace std;

int main() {
    int n,m;
    scanf("%d%d",&n,&m);
    if(n<10)
        m+=100*(10-n);
    printf("%d\n",m);
}


Measured memory_bytes: 128
#define _USE_MATH_DEFINES
#include<iostream>
#include<cstdlib>
#include<algorithm>
#include<cmath>
#include<string>
#include<set>
#include<map>
#include<stdbool.h>
#include<math.h>
#include<sstream>
#include<math.h>
#include<vector>
#include<functional>
#include<queue>
#include<utility>
#include<bitset>
typedef long long ll;
#define N (1000000000+7)
#define INF 1e10
#define Length 80000
using namespace std;
typedef pair<ll, ll> P;
int dx[4] = { 1,0,-1,0 };
int dy[4] = { 0,1,0,-1 };

bool used[110];

bool cmp(const pair<int,int> &a,const pair<int,int> &b) {
	return a.first * a.first + a.second * a.second > b.first*b.first + b.second * b.second;
}

void solve(int n) {
	vector<pair<int, int>>p(n), q(n);
	for (int i = 0;i < n;i++) {
		cin >> p[i].first >> p[i].second;
	}
	for (int i = 0;i < n;i++) {
		cin >> q[i].first >> q[i].second;
	}
	int dist = Length, flag = 0;
	int ans = 0;
	sort(p.begin(), p.end());
	for (int i = 0;i < n;i++) {
		dist = Length;
		flag = 0;
		for (int j = 0;j < n;j++) {
			if (!used[j]) {
				int x = q[j].first - p[i].first;
				int y = q[j].second - p[i].second;
				if ((x > 0) && (y > 0) && y < dist) {
					dist = y;
					flag = j;
				}
			}
		}
		if (dist < Length) {
			ans++;
			used[flag] = true;
		}
	}
	cout << ans << endl;
}

ll dp[1010][1010];
char board[1010][1010];
int main(void){
	ll h, w;
	cin >> h >> w;
	for (int i = 1;i <= h;i++) {
		for (int j = 1;j <= w;j++) {
			cin >> board[i][j];
		}
	}
	if (board[1][1] == '#')return 0;
	dp[1][1] = 1;
	for (int i = 1;i <= h;i++) {
		for (int j = 1;j <= w;j++) {
			if ((i == 1) && (j == 1))continue;
			if (board[i][j] != '#') {
				if ((i > 1)&&(board[i-1][j]!='#'))dp[i][j] = (dp[i][j] + dp[i - 1][j] % N) % N;
				if ((j > 1) && (board[i][j-1] != '#'))dp[i][j] = (dp[i][j] + dp[i][j - 1] % N) % N;
			}
		}
	}
	cout << dp[h][w] << endl;
	return 0;
}

Measured memory_bytes: 9088
#include<bits/stdc++.h>
#define FOR0(i,n) for(i=0;i<n;i++)
#define FOR(i,j,n) for(i=j;i<n;i++)
#define FORD(i,j,k) for(i=j;i>=k;i--)
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define inf 1000000000
#define ninf -1000000000
#define endl '\n' 
#define she_told_me_dont_worry ios_base::sync_with_stdio (false) ; cin.tie(0) ; cout.tie(0) ;
// Use cout.flush() for interactive problems.
// Use this for increased stack size: g++ -o a.exe -Wl,--stack=256000000 -O2 source.cpp
inline long long  MAX2(long long  a, long long int b){return (a)>(b)?(a):(b);}
inline long long  MAX3(long long  a, long long  b,long long  c){return (a)>(b)?((a)>(c)?(a):(c)):((b)>(c)?(b):(c));}
inline long long  MIN2(long long  a, long long  b){return (a)<(b)?(a):(b);}
inline long long  MIN3(long long  a, long long b,long long c){return (a)<(b)?((a)<(c)?(a):(c)):((b)<(c)?(b):(c));}
using namespace std;
typedef long long ll;
typedef pair<int,int> ii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector< ii > vii;
int main()
{
    she_told_me_dont_worry
    int n, k;
    cin>>n>>k;
    if (k > (n-1)*(n-2)/2)
    {
        cout<<-1;
        return 0;
    }
    vii ed;
    int i;
    int ans = 0;
    FOR(i, 2, n+1)
    {
        ed.push_back(ii(1, i));
        ans++;
    }
    int j;
    int cur = (n-1)*(n-2)/2;
    FOR(i, 2, n+1)
    {
        FOR(j, i+1, n+1)
        {
            if( k == cur) break;
            ed.push_back(ii(i, j));
            ans++;
            cur--;
        }
        if( k == cur) break;
    }
    cout<<ans<<endl;
    FOR0(i, ans)
    {
        cout<<ed[i].ff<<" "<<ed[i].ss<<endl;
    }
    cerr <<endl<< "Time elapsed : " << clock() * 1000.0 / CLOCKS_PER_SEC << " ms" << '\n';
}

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

#define rep(i, n) for (int i = 0; i < int(n); i++)
#define rrep(i, n) for (int i = int(n) - 1; i >= 0; i--)
#define reps(i, n) for (int i = 1; i <= int(n); i++)
#define rreps(i, n) for (int i = int(n); i >= 1; i--)
#define repc(i, n) for (int i = 0; i <= int(n); i++)
#define rrepc(i, n) for (int i = int(n); i >= 0; i--)
#define repi(i, a, b) for (int i = int(a); i < int(b); i++)
#define repic(i, a, b) for (int i = int(a); i <= int(b); i++)
#define each(x, y) for (auto &x : y)
#define all(a) (a).begin(), (a).end()
#define bit32(x) (1 << (x))
#define bit64(x) (1ll << (x))
#define sz(v) ((int) v.size())

using namespace std;

using i64 = long long;
using f80 = long double;
using vi32 = vector<int>;
using vi64 = vector<i64>;
using vf80 = vector<f80>;
using vstr = vector<string>;

inline void yes() { cout << "Yes" << endl; exit(0); }
inline void no() { cout << "No" << endl; exit(0); }
template <typename T> class pqasc : public priority_queue<T, vector<T>, greater<T>> {};
template <typename T> class pqdesc : public priority_queue<T, vector<T>, less<T>> {};
template <typename T> inline void amax(T &x, T y) { x = max(x, y); }
template <typename T> inline void amin(T &x, T y) { x = min(x, y); }
template <typename T> inline T exp(T x, i64 n, T e = 1) { T r = e; while (n > 0) { if (n & 1) r *= x; x *= x; n >>= 1; } return r; }
template <typename T> istream& operator>>(istream &is, vector<T> &v) { each(x, v) is >> x; return is; }
template <typename T> ostream& operator<<(ostream &os, vector<T> &v) { rep(i, v.size()) { if (i) os << ' '; os << v[i]; } return os; }
void solve(); int main() { ios::sync_with_stdio(0); cin.tie(0); cout << fixed << setprecision(16); solve(); return 0; }

void solve() {
  int n, k, c;
  cin >> n >> k >> c;
  string s;
  cin >> s;
  vi32 lft(n), rgt(n);
  {
    int now = 0;
    for (int i = 0; i < n; ) {
      if (s[i] == 'x') {
        i += 1;
        continue;
      }
      lft[i] = ++now;
      i += c + 1;
    }
    if (now > k) {
      return;
    }
    for (int i = n - 1; i >= 0; ) {
      if (s[i] == 'x') {
        i -= 1;
        continue;
      }
      rgt[i] = now--;
      i -= c + 1;
    }
  }
  rep(i, n) {
    if (lft[i] != 0 && lft[i] == rgt[i]) {
      cout << i + 1 << ' ';
    }
  }
}

Measured memory_bytes: 3348
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
#define rep2(x,from,to) for(int x=(from); x<(to); (x)++)
#define rep(x,to) rep2(x,0,to)
vector<int> s, t;
int main() {
	int n, q;
	cin >> n;
	rep(i,n) {
		int a;
		cin >> a;
		s.push_back(a);
	}
	cin >> q;
	rep(i,q) {
		int b;
		cin >> b;
		t.push_back(b);
	}
	sort(s.begin(), s.end());
	int cnt = 0;
	rep(i,q) {
		int lo = -1, hi = n;
		while(hi - lo > 1) {
			int j = (hi + lo) / 2;
			if(s[j] == t[i]) {
				cnt++;
				break;
			}
			else if(s[j] < t[i]) lo = j;
			else hi = j;
		}
	}
	cout << cnt << endl;
	return 0;
}

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

int main(){
	string card;
	string right;
	string left;
	int n;
	int m;

	while(cin >> card, card != "-"){
		cin >> n;
		for(int i=0; i<n; i++){
			cin >> m;
			right = card.substr(0,m);
			left = card.substr(m);
			card = left + right;
		}
		cout << card << endl;
	}
	return 0;
}

Measured memory_bytes: 3144
#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
#define pii pair<int,int>
#define fi first
#define se second
#define int long long
#define pb push_back
#define mod 1000000007
#define pll pair<long long,long long>
using namespace std;
template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
long long power(long long a,long long b){
    long long ans=1;
    while(b>0){
        if(b&1){ans=(ans*a)%mod;}
                a=(a*a)%mod;
                b>>=1;
        }
    return ans;
        
}
//find_by_order() ->  iterator to the k-th largest element (counting from zero)
//order_of_key() ->    the number  items in a set that are strictly smaller than our item aka index in set
//upper bound : strictly greater than x
//lower bound : greater equal to x
int32_t main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    int n;
    cin>>n;
    for(int i=0;i<n;i++){
        cout<<"ACL";
    }
    return 0;
}

Measured memory_bytes: 3644
#include <bits/stdc++.h>
using namespace std;
#define mp       make_pair
#define pb       push_back
#define all(x)   (x).begin(),(x).end()
#define YES() printf("YES\n")
#define NO() printf("NO\n")
#define Yes() printf("Yes\n")
#define No() printf("No\n")
#define in(x,y,h,w) x >= 0 && x < h && y >= 0 && y < w

#define int long long
//typedef    long long          ll;
typedef    vector<bool>       vb;
typedef    vector<int>        vi;
typedef    vector<vb>         vvb;
typedef    vector<vi>         vvi;
typedef    pair<int,int>      P;

template <typename T> T &chmin(T &a, const T &b) { return a = min(a, b); }
template <typename T> T &chmax(T &a, const T &b) { return a = max(a, b); }
 
const int INF=1e+18;
const double EPS=1e-9;
const int MOD=1000000007;
 
const int dx[]={1,0,-1,0},dy[]={0,-1,0,1};

signed main(){
	int n,a[200000],ans[200010] = {},ma = 0;
	cin >> n;
	for(int i = 0;i < n;i++) cin >> a[i];
	for(int i = 0;i < n;i++){
		ans[a[i]] = max(1ll,ans[a[i] - 1] + 1);
	}
	for(int i = 0;i <= n;i++) chmax(ma,ans[i]);
	cout << n - ma << endl;
	return 0;
}

Measured memory_bytes: 3328
package main
 
import(
  "fmt"
	"bufio"
	"os"
	"strings"
)
 
var sc = bufio.NewScanner(os.Stdin)
 
func Rr() []string {
  sc.Scan()
  slice := strings.Split(sc.Text(), " ")
  return slice
}
 
func abc140c(N int){
	sum := 0
	now := 0
	bef := 0
	for i := 0; i < N; i++{
		if i != N-1 {
		fmt.Scan(&now)
		}
		if i == 0{
			sum += now
		}else if i == N-1{
			sum+=bef
		}else{
			if now < bef{
				sum+=now
			}else{
				sum+=bef
			}
		}
		bef = now
	}
	fmt.Println(sum)
}	
 
func main(){
	x := 0
	fmt.Scan(&x)
	abc140c(x)
}

Measured memory_bytes: 640
#include<iostream>
#include<string>
int main()
{
  std::string S,T;
  std::cin >> S >> T;
  int lenS = S.size();
  int lenT = T.size();
  int n = 1000;
  int ST = lenS - lenT;
  int a = 0;
  int X[1000] = {0};
  for(; a <= ST; a++)
  {
    for(int b = 0; b < lenT; b++)
    {
      if(S[a+b] != T[b])
      {
        X[a] = X[a] + 1;
      }
    }
  }
  for(int b = 0; b < a; b++)
  {
    if(n > X[b])
      n = X[b];
  }
  printf("%d",n);
}

Measured memory_bytes: 3264
#include <bits/stdc++.h>
using namespace std;
 
// in-short-use macros
 
#define all(c) (c).begin(),(c).end()
#define ll long long int
#define ld long double
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define mod 1000000007
#define PI 3.14159265
#define sizes 1000010
 
//main function here
 
int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	// #ifndef ONLINE_JUDGE
	// freopen("C:/Users/saura/Desktop/cp/input.txt", "r", stdin);
	// freopen("C:/Users/saura/Desktop/cp/output.txt", "w", stdout);
	// #endif
	int n,x,t;
	cin>>n>>x>>t;
	cout<< (ll)ceil((ld)(n)/(ld)(x))*t<<"\n";

	return 0;
}

Measured memory_bytes: 3640
local n, m, p = io.read("*n", "*n", "*n")
local edge = {}
local srcs, dsts, cs = {}, {}, {}
for i = 1, m do
  local a, b, c = io.read("*n", "*n", "*n")
  srcs[i] = a
  dsts[i] = b
  cs[i] = c - p
end
local len = {}
local inf = 10000000000
for i = 1, n do len[i] = -inf end
len[1] = 0
local lim = n + 4
for i = 1, lim do
  for j = 1, m do
    local src, dst, c = srcs[j], dsts[j], cs[j]
    if len[src] ~= -inf and len[dst] < len[src] + c then
      len[dst] = len[src] + c
      if i == lim then
        len[dst] = inf
      end
    end
  end
end
for i = 1, lim do
  for j = 1, m do
    local src, dst, c = srcs[j], dsts[j], cs[j]
    if len[src] == inf then
      len[dst] = inf
    end
  end
end
print(inf <= len[n] and -1 or math.max(0, len[n]))


Measured memory_bytes: 3152
/*#pragma GCC optimize("Ofast,no-stack-protector")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#pragma GCC optimize("unroll-loops")
#pragma GCC optimize("fast-math")*/
#include <iostream>
#include <complex>
#include <vector>
#include <string>
#include <algorithm>
#include <cstdio>
#include <numeric>
#include <cstring>
#include <ctime>
#include <cstdlib>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <list>
#include <cmath>
#include <bitset>
#include <cassert>
#include <queue>
#include <stack>
#include <deque>
#include <random>

using namespace std;

#define pb push_back
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define Str(x) to_string(x)
#define len(s) (int)s.size()

typedef long long ll;
typedef long double lld;
typedef string str;
typedef unsigned long long ull;

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
#ifdef LOCAL
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif
    int n;
    cin >> n;
    for (int i = 0; i < 1e5; i++) {
        int x = (double)i * 1.08;
        if (x == n) {
            cout << i;
            return 0;
        }
    }
    cout << ":(";

    return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;
class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int k = sc.nextInt();
    int x = sc.nextInt();
    if(500 * k >= x){
      System.out.println("Yes");
    }else{
      System.out.println("No");
    }
  }
}


Measured memory_bytes: 21844
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>

#define LINE_BUF_SIZE 256

int main(){

    int i,j,k;
    char line[256];
    long long int N,M;

    fgets(line,sizeof(line),stdin);
    sscanf(line,"%lld %lld",&N,&M);

    if(N == 1 && M == 1){
        printf("1");
        return 0;
    }

    if(N == 1 && M != 1){
        printf("%lld",M-2);
        return 0;
    }

    if(M == 1 && N != 1){
        printf("%lld",N-2);
        return 0;
    }

    else{
        printf("%lld",(M-2)*(N-2));
    }

    return 0;

}

Measured memory_bytes: 128
#include<iostream>
#include<map>
#include<string.h>
#include<queue>
#include<algorithm>
#include<vector>
#include<string>
#include<utility>
#include<cstdlib>
#include<math.h>
#include<set>
#include<array>
using namespace std;

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



#define rep(n) for(int i=0;i<(n);i++)
typedef pair<int, int> pii;

typedef long long ll;
typedef pair<ll, ll>pll;
typedef vector<int> vi;
typedef vector<vi> vii;
typedef vector<ll> vl;
typedef vector<vl> vll;
const int MOD = 1000000007;
const int INF = 1 << 29;
const long long LINF = 1LL << 60;

int main() {
	
	int n;
	cin >> n;
	vl a(n),sum(n,0);
	rep(n) { 
		cin >> a[i];
		if(i>=1)sum[i] = a[i]+sum[i-1];
		else sum[i] = a[i];
	}
	ll mi = abs(sum[n - 1] - sum[0]*2);

	rep(n-1) {
		if (mi > abs(sum[n - 1] - sum[i]*2))mi = abs(sum[n - 1] - sum[i]*2);
	}
	cout << mi << endl;
	return 0;
}

Measured memory_bytes: 3328
n, m = map(int, input().split())
lr = []

for i in range(m):
    lr.append(list(map(int, input().split())))

lmax = 0
mmin = 10**5

for i in range(m):
    lmax = max(lmax, lr[i][0])
    mmin = min(mmin, lr[i][1])

print(max(0, mmin - lmax + 1))

Measured memory_bytes: 60248
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <algorithm>
#include <vector>
#include <stack>
using namespace std;
#define REP(i, n) for(int (i)=0; (i)<(n); (i)++)
#define OUT(a) cout << (a) << "\n"
#define ll long long
ll MOD = 10e9 + 7;

int main() {
    int a, b;
    cin >> a >> b;
    b--;
    string s;
    cin >> s;
    if(s[b] == 'A') s[b] = 'a';
    else if(s[b] == 'B') s[b] = 'b';
    else if(s[b] == 'C') s[b] = 'c';
    OUT(s);
    return 0;
}

Measured memory_bytes: 256
#pragma GCC optimize("Ofast,no-stack-protector")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#pragma GCC optimize("unroll-loops")
#pragma GCC optimize("fast-math")

#include <bits/stdc++.h>
using namespace std;
 
#define len(x) (int)((x).size())
#define endl '\n'
#define int long long
#define x first 
#define y second

#ifdef LOCAL
    #define dbg(x) cout << #x << " = " << x << endl;
#else 
    #define dbg(x)
#endif 
 
void solve(); signed main() {
#ifdef LOCAL
    freopen("input.txt", "r", stdin);
#endif
    srand(time(0));
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    cout.setf(ios::fixed); cout.precision(9);
    solve();
    return 0;
}
 
const int MOD = 1e9 + 7, MAXN = 3e5 + 10, INF = 1e18 + 10;
int n;
vector<int> g[MAXN];
int f1[MAXN], f2[MAXN], fact[MAXN], rfact[MAXN], sz[MAXN];

int bin_pow(int num, int n) {
    if (n == 0) {
        return 1;
    }
    if (n & 1) {
        return num * bin_pow(num, n - 1) % MOD;
    }   
    else {
        int tmp = bin_pow(num, n / 2);
        return tmp * tmp % MOD;
    }
}

int C(int n, int k) {
    return (fact[n] * rfact[n - k] % MOD) * rfact[k] % MOD;
}

void dfs1(int v, int p = 0) {
    sz[v] = 1;
    for (auto u : g[v]) {
        if (u != p) {
            dfs1(u, v);
            sz[v] += sz[u];
        }
    }

    f1[v] = 1;
    int tmp = sz[v] - 1;

    for (auto u : g[v]) {
        if (u != p) {
            f1[v] = f1[v] * (C(tmp, sz[u]) * f1[u] % MOD) % MOD;  
            tmp -= sz[u];  
        }
    }   
}

void dfs2(int v, int p = 0) {
    if (v == 1) {
        f2[v] = 1;
    }
    else {
        f2[v] = (((((((fact[n - sz[v] - 1] * fact[sz[v]] % MOD) * f2[p] % MOD) * rfact[n - sz[p]] % MOD) * rfact[sz[p] - 1] % MOD) * bin_pow(f1[v], MOD - 2) % MOD) % MOD) * f1[p] % MOD) % MOD; 
    }

    for (auto u : g[v]) {
        if (u != p) {
            dfs2(u, v);
        }
    }
}

void solve() {
    fact[0] = 1, rfact[0] = 1;
    for (int i = 1; i < MAXN; ++i) {
        fact[i] = fact[i - 1] * i % MOD;
        rfact[i] = bin_pow(fact[i], MOD - 2);
    }

    cin >> n;
    for (int i = 0; i < n - 1; ++i) {
        int u, v;
        cin >> u >> v;
        g[u].push_back(v);
        g[v].push_back(u);
    }

    f1[0] = 1, f2[0] = 1;

    dfs1(1);
    dfs2(1);


    for (int v = 1; v <= n; ++v) {
        cout << (f1[v] * f2[v] % MOD) * C(n - 1, sz[v] - 1) % MOD << endl;        
    }
}	



Measured memory_bytes: 28272
import sys
stdin = sys.stdin
mod = 10**9 + 7

ns = lambda: stdin.readline().rstrip()
ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))
sa = lambda h: [list(map(int, stdin.readline().split())) for i in range(h)]

x1, y1, x2, y2 = na()

x3 = x2 - (y2 - y1)
y3 = y2 + (x2 - x1)
x4 = x1 - (y2 - y1)
y4 = y1 + (x2 - x1)

print(x3, y3, x4, y4)


Measured memory_bytes: 3060
#include <iostream>
#include <vector>
/* run this program using the console pauser or add your own getch, system("pause") or input loop */
using namespace std;
int main() {
	string s;
	cin>>s;
	vector <int> ve;
	for(int i=0;i<s.size();i++)
	{
		if (s[i]=='0')
		{
			ve.push_back(0);
		}
		else if (s[i]=='1')
		{
			ve.push_back(1);
		}
		else {
		if(ve.size()!=0)
		{
            ve.pop_back();             
		}
	}

	}
			for(int j=0;j<ve.size();j++)
			{
			   cout<<ve[j];
			}

	return 0;
}

Measured memory_bytes: 3192
class UnionFind():
    def __init__(self, n):
        self.n = n
        self.parents = [-1] * n

    def find(self, x):
        if self.parents[x] < 0:
            return x
        else:
            self.parents[x] = self.find(self.parents[x])
            return self.parents[x]

    def union(self, x, y):
        x = self.find(x)
        y = self.find(y)

        if x == y:
            return

        if self.parents[x] > self.parents[y]:
            x, y = y, x

        self.parents[x] += self.parents[y]
        self.parents[y] = x

    def size(self, x):
        return -self.parents[self.find(x)]

    def same(self, x, y):
        return self.find(x) == self.find(y)

    def members(self, x):
        root = self.find(x)
        return [i for i in range(self.n) if self.find(i) == root]

    def roots(self):
        return [i for i, x in enumerate(self.parents) if x < 0]

    def group_count(self):
        return len(self.roots())

    def all_group_members(self):
        return {r: self.members(r) for r in self.roots()}

    def __str__(self):
        return '\n'.join('{}: {}'.format(r, self.members(r)) for r in self.roots())

n,q = map(int,input().split())
uf = UnionFind(n)
for _ in range(q):
    a,x,y = map(int,input().split())
    if a:
        print(int(uf.same(x,y)))
    else:
        uf.union(x,y)


Measured memory_bytes: 5792
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < (int)(n); i++)
#define REPLL(i, n) for (ll i = 0; i < (ll)(n); i++)
using namespace std;
template<class T>inline bool chmax(T &a, const T &b){if(a < b){a = b; return 1;}return 0;}
template<class T>inline bool chmin(T &a, const T &b){if(a > b){a = b; return 1;}return 0;}
typedef long long ll;

int main(){
  ios::sync_with_stdio(false);
  cin.tie(0);
  int L, R, d; cin >> L >> R >> d;
  int l = (L-1)/d;
  int r = R/d;
  int ans = r - l;
  cout << ans << endl;
}

Measured memory_bytes: 3580
#include <iostream> 
#include <string> 
#include <vector> 
#include <cmath> 
#include <algorithm> 
#include <cstdlib> 
#include <ctime> 
#include <cstdio> 
#include <functional> 
#include <set> 
#include <sstream> 
#include <cctype>
#include <stack>
#include <queue>
#include <cstring>
#include <map>
#include <list>
#include <cassert>
 
using namespace std; 


int main(){

	string s;
	cin>>s;

	stack<char> st;
	for(int i=0;i<s.size();i++){
		if(s[i]=='S') st.push('S');
		else{
			if(st.empty() || st.top()=='T') st.push('T');
			else st.pop();
		}
	}

	cout<<st.size()<<endl;



}

Measured memory_bytes: 644
#include <iostream>

using namespace std;

const int MAX_N = 1e2+10;

int main(int argc, char const *argv[])
{
    int n, l[MAX_N], max_l=0, l_sum=0;

    cin >> n;
    for (int i = 0; i < n; ++i) {
        cin >> l[i];
        max_l = max(l[i], max_l);
        l_sum += l[i];
    }
    l_sum -= max_l;
    if (max_l < l_sum) cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0;
}

Measured memory_bytes: 256
import sys
sys.setrecursionlimit(10**6)


def dfs(curr_num, e753, list753, n):
    if curr_num > n: return
    if e753 == 7:
        list753.append(curr_num)
    dfs(curr_num*10+7, e753|4, list753, n)
    dfs(curr_num*10+5, e753|2, list753, n)
    dfs(curr_num*10+3, e753|1, list753, n)


def main():
    n = int(input())
    list753 = []
    dfs(0,0,list753,n)
    print(len(list753))


if __name__ == "__main__":
    main()

Measured memory_bytes: 3956
import fractions

n = int(input())
a = list(map(int, input().split()))

l = [a[0]]
for i in range(n - 1):
    l.append(fractions.gcd(l[i], a[i + 1]))

r = [a[-1]]
for i in range(2, n + 1):
    r.append(fractions.gcd(r[i - 2], a[-i]))
r.reverse()

ans = r[1]
for i in range(n - 2):
    ans = max(ans, fractions.gcd(l[i], r[i + 2]))
ans = max(ans, l[-2])
print(ans)

Measured memory_bytes: 16124
using System;
using System.Linq;
using System.Collections.Generic;

using E = System.Linq.Enumerable;

public class Program
{
    const int Mod = (int)1e9 + 7;
    const int A = 0;
    const int C = 1;
    const int G = 2;
    const int T = 3;
    
    public static void Main()
    {
        var n = int.Parse(Console.ReadLine());

        var dp = new long[2][];
        dp[0] = E.Repeat(1L, 1 << 6).ToArray();
        dp[1] = new long[dp[0].Length];
        dp[0][A << 4 | G << 2 | C] = 0;
        dp[0][A << 4 | C << 2 | G] = 0;
        dp[0][G << 4 | A << 2 | C] = 0;
        for (int i = 3; i < n; i++)
        {
            for (int s = 0; s < dp[(i + 1) % 2].Length; s++)
            {
                int c3 = s >> 4 & 3;
                int c2 = s >> 2 & 3;
                int c1 = s >> 0 & 3;
                var skipC = c2 == A && c1 == G || c2 == G && c1 == A || c3 == A && (c2 == G || c1 == G);
                var skipG = c2 == A && c1 == C;
                var k = dp[(i + 1) % 2][s];
                dp[(i + 1) % 2][s] = 0;
                for (int c0 = A; c0 < 4; c0++)
                {
                    if (c0 == C && skipC || c0 == G && skipG)
                    {
                        continue;
                    }

                    dp[i % 2][c2 << 4 | c1 << 2 | c0] += k;
                    dp[i % 2][c2 << 4 | c1 << 2 | c0] %= Mod;
                }
            }
        }

        var sum = dp[(n + 1) % 2].Aggregate((x, y) => (x + y) % Mod);
        Console.WriteLine(sum);
    }
}


Measured memory_bytes: 11348
#include<stdio.h>
#define MAX 500000
#define SEN 2000000000

long long c=0;

void merge(int A[], int n, int left, int mid, int right){
	int n1=mid-left;
	int n2=right-mid;
	int L[MAX/2+2],R[MAX/2+2];
	
	for(int i=0;i<n1;i++){
		L[i]=A[left+i];
	}
	for(int i=0;i<n2;i++){
		R[i]=A[mid+i];
	}
	L[n1]=SEN;
	R[n2]=SEN;
	
	int i=0,j=0;
	
	for(int k=left;k<right;k++){
		if(L[i]<=R[j]){
			A[k]=L[i];
			i++;
		}else{
			A[k]=R[j];
			j++;
			c+=n1-i;
		}
	}
}

void mergesort(int A[], int n, int left, int right){
	int mid;
	
	if(left+1<right){
		mid=(left+right)/2;
		mergesort(A,n,left,mid);
		mergesort(A,n,mid,right);
		merge(A,n,left,mid,right);
	}
}

int main(void){
	int A[MAX];
	int n;
	
	scanf("%d",&n);
	for(int i;i<n;i++){
		scanf("%d",&A[i]);
	}
	
	mergesort(A,n,0,n);
	
	printf("%lld\n",c);
	
	
	return 0;
}


Measured memory_bytes: 3432
//#include <bits/stdc++.h>
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cstdlib>
#include <string>
#include <vector>
#include <map>
#include <queue>

using namespace std;

typedef long long ll;
typedef vector<int> vint;
typedef vector<vector<int> > vvint;
typedef vector<long long> vll, vLL;
typedef vector<vector<long long> > vvll, vvLL;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) for(int i=0;i<n;++i)
#define mod (ll)(1e9+7)
#define FIX(a) ((a)%mod+mod)%mod
#define ALL(obj) (obj).begin(), (obj).end()
#define rALL(obj) (obj).rbegin(), (obj).rend()
#define INF 1000000000 //1e9
#define LLINF 2000000000000000000LL //2e18
#define fi first
#define se second
#define pb push_back
int dy[]={0, 0, 1, -1};
int dx[]={1, -1, 0, 0};

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll k;
    cin >> k;
    vint ans(20,0);
    int cnt = 1;
    ans[0]=1;
    REP(i,k-1){
        int cng;
        REP(j,20){
            if(j==cnt-1){
                if(ans[j]==9){
                    ans[j+1]=1;
                    cng=j+1;
                    cnt++;
                }else{
                    ans[j]++;
                    cng=j;
                }
                break;
            }else{
                if(ans[j]==9){
                    continue;
                }else if(ans[j]+1<=ans[j+1]+1){
                    ans[j]++;
                    cng=j;
                    break;
                }else{
                    continue;
                }
            }
        }
        for(int j=cng-1;j>=0;--j){
            ans[j] = max(0,ans[j+1]-1);
        }
    }
    REP(i,cnt){
        cout << ans[cnt-i-1];
    }
    cout << endl;

    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <cmath>
#include <climits>
using namespace std;

const int mod = 1e9 + 7;

void self_add(int &a, int b) {
  a += b;
  if (a >= mod) {
    a -= mod;
  }
}

int main() {
  int n;
  string s;
  cin >> n >> s;

  vector<vector<int>> dp(n + 1, vector<int>(n + 1));
  dp[1][1] = 1;
  for (int i = 0; i < n - 1; ++i) {
    int j = i + 2;
    if (s[i] == '<') {
      dp[j][1] = 0;
      for (int k = 2; k <= j; ++k) {
        dp[j][k] = dp[j][k-1];
        self_add(dp[j][k], dp[j-1][k-1]);
      }
    } else {
      dp[j][j] = 0;
      for (int k = j-1; k >= 1; --k) {
        dp[j][k] = dp[j][k+1];
        self_add(dp[j][k], dp[j-1][k]);
      }
    }
  }

  int ans = 0;
  for (int i = 1; i <= n; ++i) {
    self_add(ans, dp[n][i]);
  }
  cout << ans << '\n';

  return 0;
}


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

using ll = long long;
using ld = long double;
using vi = vector<int>;
using vll = vector<ll>;
using P = pair<int, int>;

const int INF = 1e9;
const ll INFLL = 1e18;
const int MOD = 1e9 + 7;
const int NIL = -1;
const ld PI = acosl(-1);

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

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

int main()
{
	ios::sync_with_stdio(false); cin.tie(nullptr);
	//cout << fixed << setprecision(6);
	int n; cin >> n;
	vi l(n);
	rep(i, n) cin >> l[i];
	sort(all(l));
	reverse(all(l));

	rep(i, n) cerr << l[i] << ' ';
	cerr << endl;
	ll sum = 0;
	for(int i = 1; i < n; i++) sum += l[i];

	cout << (sum > l[0] ? "Yes" : "No") << endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
string n;
cin>>n;
  for(int i=0;i<3;i++){
    if(n.at(i)=='1'){
      n.at(i)='9';
    }
    else{
      n.at(i)='1';
    }
  }
    cout<<n<<endl;
  }


Measured memory_bytes: 256
def main():
    s = input()
    n = len(s)

    one = [0] * n
    two = [0] * n
    three = [0] * n

    one[0] = 1
    if n > 1:
        two[1] = 1
    if n > 2:
        three[2] = 1

    for i in range(n):
        # 1
        if i > 0:
            one[i] = max(two[i - 1], three[i - 1]) + 1
            if s[i - 1] != s[i]:
                one[i] = max(one[i], one[i - 1] + 1)
        
        if i > 1:
            two[i] = max(one[i - 2], three[i - 2]) + 1
        if i > 2 and s[i - 3:i - 1] != s[i - 1:i + 1]:
            two[i] = max(two[i], two[i - 2] + 1)

        if i > 2:
            three[i] = max(one[i - 3], two[i - 3]) + 1
        if i > 4 and s[i - 5:i - 2] != s[i - 2: i + 1]:
            three[i] = max(three[i], three[i - 3] + 1)

    print(max(one[-1], two[-1], three[-1]))


if __name__ == '__main__':
    main()


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

using namespace std;
typedef long long int ll;
typedef pair<ll, ll > pi;  
typedef pair<pair<ll, ll >, ll > pii;  
vector<ll > vec;
vector<vector<ll > > vec2;
ll MOD = 1000000007;
ll INF = 1145141919454519;

int main() {

    string s; cin >> s;

    string d1 = "maerd";
    string d2 = "remaerd";
    string e1 = "esare";
    string e2 = "resare";

    reverse(s.begin(), s.end());

    //cout << s << endl;

    ll cn = 0;
    while(cn < s.length()){
        if(s.substr(cn, 5) == d1 || s.substr(cn, 5) == e1){
            cn += 5;
        }else if(s.substr(cn, 6) == e2){
            cn += 6;
        }else if(s.substr(cn, 7) == d2){
            cn += 7;
        }else{
            cout << "NO" << endl;
            return 0;
        }
    }

    cout << "YES" << endl;

}

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

typedef pair<int, int> pii;

const int mod = 1e9 + 7;
const int MN = 302;

int N, M;
vector<pii> C[MN];
int dp[2][3][MN][MN], p[3];

int main() {
    scanf("%d %d", &N, &M);

    for(int i = 0; i < M; i++) {
        int l, r, x; scanf("%d %d %d", &l, &r, &x);
        l--; r--;
        C[r].push_back({l, x});
    }

    for(int i = 0; i <= N + 1; i++) for(int j = 0; j <= N + 1; j++) dp[N & 1][0][i][j] = 1;
    for(int i = N - 1; i >= 0; i--) {
        for(int j = 0; j < 3; j++) {
            for(int k = 1; k <= i + 1; k++) {
                for(int l = 1; l <= i + 1; l++) {
                    int &ret = dp[i & 1][j][k][l] = 0;
                    p[j] = 0;
                    p[(j + 1) % 3] = k;
                    p[(j + 2) % 3] = l;

                    bool ok = true;
                    for(int a = 0; a < C[i].size(); a++) {
                        int l = C[i][a].first;
                        int x = C[i][a].second;

                        int cnt = 0;
                        for(int b = 0; b < 3; b++) {
                            if(l <= i - p[b]) cnt++;
                        }
                        if(cnt != x) {
                            ok = false;
                            break;
                        }
                    }
                    if(!ok) {
                        ret = 0;
                        continue;
                    }

                    for(int a = 0; a < 3; a++) {
                        ret += dp[ (i ^ 1) & 1 ][a][ p[ (a + 1) % 3 ] + 1 ][ p[ (a + 2) % 3 ] + 1 ];
                        ret %= mod;
                    }

                    //cout << i << ' ' << j << ' ' << k << ' ' << l << ' ' << ret << endl;
                }
            }
        }
    }

    int ans = 0;
    for(int i = 0; i < 3; i++) {
        ans += dp[0][i][1][1];
        ans %= mod;
    }
    printf("%d", ans);
}


Measured memory_bytes: 2432
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <stdio.h>
#include <queue>
#include <stack>
#include <climits>
#include <map>
#include <set>

#define N_MAX 10000005

using namespace std;

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

const ll mod = 1e9 + 7;
const int inf = 1e9;
const long long INF = 1LL << 60;

int main()
{
    int n,k;
    cin >> n >> k;
    int cnt = 0;
    while(n){
        cnt++;
        n /= k;
    }
    cout << cnt;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int N;
    cin >> N;
    vector<pair<int, int>> A(N);
    for(int i=0; i<N; i++){
        int t;
        cin >> t;
        A.at(i)=make_pair(t,i);
    }
    sort(A.begin(),A.end());
    reverse(A.begin(),A.end());
    for(int i=0; i<N; i++){
        for(int j=0; j<N; j++){
            if(i!=A.at(j).second){
                cout << A.at(j).first << endl;
                break;
            }
        }
    }
}

Measured memory_bytes: 3200
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<vector>
#include<queue>
#include<string>
#include<cmath>
#include<cstring>
using namespace std;

int main(){
  int w,sum=0;
  while(1){
    scanf("%d",&w);
    if(w==-1) break;
    if(w>30){
      sum+=(w-30)*160;
      w=30;
    }
    if(w>20){
      sum+=(w-20)*140;
      w=20;
    }
    if(w>10){
      sum+=(w-10)*125;
    }
    printf("%d\n",4280-(sum+1150));
    sum=0;
  }   
  return 0;
}



Measured memory_bytes: 3208
import math

def is_integer_num(n):
    if isinstance(n, int):
        return True
    if isinstance(n, float):
        return n.is_integer()
    return False

ND = list(map(int,input().split()))
N=ND[0]
D=ND[1]
X = [list(map(int,input().split())) for l in range(N)]
cnt=0
for i in range(N-1):
     for j in range(i+1,N):
         summary=0
         for k in range(D):
             summary=summary+(X[i][k]-X[j][k])*(X[i][k]-X[j][k])
         distance=math.sqrt(summary)
         if is_integer_num(distance):
             cnt=cnt+1

print(cnt)

Measured memory_bytes: 3064
// 提出時に消す
// package app;

import java.util.Scanner;

// 提出時にMainに変更する
//public class ABC177B {
public class Main {
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);

        String s = sc.next();
        String t = sc.next();

        int ans = t.length();

        for (int i = 0; i < s.length() - t.length() + 1; i++) {
            // 入れ替える必要のある数
            int cnt = t.length();
            for (int j = 0; j < t.length(); j++) {
                if (s.substring(i + j, i + j + 1).equals(t.substring(j, j + 1))) {
                    cnt--;
                }
            }
            if (ans > cnt) {
                ans = cnt;
            }
        }

        System.out.println(ans);

        sc.close();
    }
}

Measured memory_bytes: 53488
s = list(input())

ss = set(s)

if len(s) < 26:
    for c in "abcdefghijklmnopqrstuvwxyz":
        if c not in ss:
            print("".join(s) + c)
            exit()
else:
    suc = s[-1]
    while suc in ss and s:
        suco = ord(suc) + 1
        if suco > ord("z"):
            ss.remove(s.pop())
            if not ss:
                break
            suc = s[-1]
        else:
            suc = chr(suco)
    
    if not ss:
        print(-1)
    else:
        s[-1] = suc
        print("".join(s))


Measured memory_bytes: 3064
#include <stdio.h>

int main(void)
{
	int a,b[10]={0},i,p,s,d,f,g;
	while(1){
	scanf("%d",&a);
	if(a==0)break;
	for(i=0;i<10;i++){
		b[i]=0;}
	for(i=0;i<a;i++){
		scanf("%d",&d);
		b[d]++;
	}
	for(i=0;i<=9;i++){
		if(0<b[i]){
			for(f=1;f<=b[i];f++){
				printf("*");
			}
		}
		else printf("-");
		printf("\n");
	}
	}
	return 0;
}


Measured memory_bytes: 2036
#include <bits/stdc++.h>
using namespace std;
vector<int> graph[100001];
int dp[100001];   // dp[i] denotes the longest path starting at node i
int solve(int src){
    if(dp[src]!=-1){
        return dp[src];
    }
   int ans=0; bool f=false;
   for(int child: graph[src]){
       f=true;
       ans= max(ans, solve(child) );
   } 
return dp[src]= f? 1+ans: 0;
}

int32_t main() {
      int n,m;
       memset(dp,-1,sizeof dp);
      cin>>n>>m;
      for(int i=0;i<m;++i){
          int u,v;
          cin>>u>>v;
          graph[u].push_back(v);
      }
      int ans=0;
      //solve(1);
      for(int i=1;i<=n;++i){
          ans=max(ans, solve(i));
      }
    cout<<ans;
    return 0;
}


Measured memory_bytes: 11356
#include<stdio.h>

int A[100][100];

int main(void){
  int n,m,l,i,j,k;

  scanf("%d",&n);
  
  for(i=0;i<n;i++){
    for(j=0;j<n;j++){
      A[i][j]=0;
    }
  }
  for(i=0;i<n;i++){
    scanf("%d%d",&m,&l);
    for(j=0;j<l;j++){
      scanf("%d",&k);
      A[i][k-1]=1;
    }
  }
  
  for(i=0;i<n;i++){
    for(j=0;j<n-1;j++){
      printf("%d ",A[i][j]);
    }
      printf("%d\n",A[i][j]);

  }
  return 0;
}

Measured memory_bytes: 632
// C++ 14
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define loop(__x, __start, __end) for(ll __x = __start; __x < __end; __x++)

typedef pair<ll, int> P;

int main() {
  int x, y, a, b, c; cin >> x >> y >> a >> b >> c;
  ll s;
  vector<P> A;
  loop(i,0,a) {
    cin >> s;
    A.emplace_back(s, 1);
  }
  loop(i,0,b) {
    cin >> s;
    A.emplace_back(s, 2);
  }
  loop(i,0,c) {
    cin >> s;
    A.emplace_back(s, 0);
  }
  sort(A.rbegin(), A.rend());
  ll score = 0;
  int idx = 0;
  vector<int> B(3);
  while (B[0]+B[1]+B[2]<x+y) {
    auto p = A[idx++];
    if (B[1]==x and p.second == 1) continue;
    if (B[2]==y and p.second == 2) continue;
    score += p.first;
    // cout << p.first << " " << p.second << endl;
    B[p.second]++;
  }
  cout << score << endl;
  return 0;
}


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

long long kaijou(long long N, long long P){
  long long p = 1;
  for(long long i=0;i<P;i++){
    p *= N - i;
    p %= 1000000007;
  }
  return p;
}
  
long long RepeatSquaring(long long N, long long P, long long M){
    if(P==0) return 1;
    if(P%2==0){
        long long t = RepeatSquaring(N, P/2, M);
        return t*t % M;
    }
    return N * RepeatSquaring(N, P-1, M) % M;
}
int main(void){
  
  long long n,a,b;
  cin >> n >> a >> b;
  
  long long np = RepeatSquaring(2,n,1000000007) - 1;
  
  long long ap = (kaijou(n,a) * RepeatSquaring(kaijou(a,a),1000000005,1000000007)) % 1000000007;
  long long bp = (kaijou(n,b) * RepeatSquaring(kaijou(b,b),1000000005,1000000007)) % 1000000007;
  
  cout << (np + 3000000021 - ap - bp) % 1000000007 << endl;
  
  return 0;
}

  


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

using namespace std;

typedef long long ll;

int main()
{
  ll sum = 0;
  int n = 0;
  scanf("%d", &n);
  vector<ll> A(n, 0);
  for (int i = 0; i < n; ++i) {
    scanf("%lld", &A[i]);
  }
  int r = 0;
  ll ans = 0;
  for (int l = 0; l < n; ++l) {
    while ((r < n) && ((sum & A[r]) == 0)) {
      sum ^= A[r];
      ++r;
    }
    sum ^= A[l];
    ans += r - l;
  }
  printf("%lld\n", ans);
  return 0;
}


Measured memory_bytes: 1792
#include <iostream>
#include <iomanip>
#include <cstring>
#include <algorithm> 
#include <math.h>
#include <queue>
#include <functional>
#include <map>
#include <vector>
#include <string>
using namespace std;
typedef long long ll;
const ll MOD = 1000000007;

int n;
int a[100005];
int main(void){
    cin >> n;
    for (int i = 0; i < n; i++) cin >> a[i];
    sort(a, a + n);

    int st = 0;
    int ans = 0;
    for (int i = 0; i < n; i++){
        if (a[i] != a[i + 1]){
            int cnt = i + 1 - st;
            if (a[i] <= cnt) ans += cnt - a[i];
            else ans += cnt;
            st = i + 1;
        }
    }
    
    cout << ans << endl;
}

Measured memory_bytes: 640