akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cstdio>

using namespace std;

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

    int ans = 1;
    for (int i = 0; i < n; i++) {
        if (ans*2 <= ans+k) {
            ans *= 2;
        } else {
            ans += k;
        }
    }

    cout << ans << endl;
}


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

using namespace std;

int main(){
    int n;
    cin >> n;
    vector<int> cs(n-1), ss(n-1), fs(n-1);
    for(int i=0; i<n-1; ++i){
        cin >> cs[i] >> ss[i] >> fs[i];
    }
    for(int i=0; i<n-1; ++i){
        int res=0;
        for(int j=i; j<n-1; ++j){
            if(res<ss[j]){
                res=ss[j];
            } else{
                res=(res+fs[j]-1)/fs[j]*fs[j];
            }
            res+=cs[j];
        }
        cout << res << endl;
    }
    cout << 0 << endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <stack>
#include <queue>
#include <list>
#include <string>
#include <numeric>
#include <math.h>
#include <set>
#include <map>
#include <fstream>
using namespace std;

int main()
{
	long long N;
	cin>>N;
	vector<long long> cap(5);
	for(int i=0; i<5; i++)
	{
		cin>>cap[i];
	}
	//最小律を考える
	long long min = *min_element(cap.begin(),cap.end());
	long long ans = 4 + (N+min-1)/min;
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 256
n, m = list(map(int, input().split()))
ab = list(list(map(int, input().split())) for i in range(m))
ab = sorted(ab, key=lambda x: x[1])
bridge = 0
count = 0
for i in range(m):
    if ab[i][0] < bridge:
        continue
    else:
        bridge = ab[i][1]
        count = count + 1
    if count == n-1:
        break
    else:
        continue
print(count)

Measured memory_bytes: 29848
#include <bits/stdc++.h>
using namespace std;
#define long int64_t
int main()
{
   int n, count{0};
   cin >> n;
   vector<int> v(n);
   for (int i = 0; i < n; ++i)
      cin >> v[i];

   for (int j = 1; j < n-1; ++j)
   {
      if((v[j] > v[j+1]) && (v[j] < v[j-1]))
         count++;

      if((v[j] < v[j+1]) && (v[j] > v[j-1]))
         count++;
   }

   cout << count;
   return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <queue>
#include <vector>
#include <set>
#include <map>
#include <algorithm>
#include <utility>
#include <iomanip>

#define ll long long int
#define pb push_back
#define mk make_pair
#define pq priority_queue

using namespace std;
typedef pair<int, int> P;
typedef pair<ll, int> Pl;
const int inf = 1e9;
const ll linf = 1LL << 50;

map<string, int> mp;
int dx[4] = {-1, 1, -4, 4};

void bfs(){
		queue<string> q;
		q.push("01234567");
		mp["01234567"] = 0;
		while(!q.empty()){
				string s = q.front(); q.pop();
				int zero = -1;
				for(int i = 0; i < 8; i++){
						if(s[i] == '0')zero = i;
				}
				for(int i = 0; i < 4; i++){
						int ni = zero + dx[i];
						if(ni < 0 || ni > 7)continue;
						if(ni == 4 && zero == 3)continue;
						if(ni == 3 && zero == 4)continue;
						string stt = s;
						stt[zero] = stt[ni];
						stt[ni] = '0';
						if(mp.find(stt) != mp.end())continue;
						mp[stt] = mp[s] + 1;
						q.push(stt);
				}
		}
}

int main(int argc, char const* argv[])
{
	string s = "01234556";
	int a;
	bfs();
	while(cin >> a){
			s[0] = a + '0';
			for(int i = 1; i < 8; i++){
					cin >> a;
					s[i] = a + '0';
			}
			cout << mp[s] << endl;
	}
	return 0;
}



Measured memory_bytes: 5304
#include <bits/stdc++.h>
using namespace std;
#define REP(i, init, n) for(int i = (int)(init); i < (int)(n); i++)

#define vi vector<int>
#define vl vector<long>
#define vvi vector<vector<int>>
#define vvl vector<vector<long>>
#define pint pair<int, int>
#define plong pair<long, long>

int main() {
    int N;
    cin>>N;
    vector<bool> erats(300001, true);
    vector<long> primes;
    REP(i, 2, 300000){
        if(erats[i]){
            primes.push_back(i);
            long j = i * 2;
            while(j <= 300000){
                erats[j] = false;
                j += i;
            }
        }    
    }
    vi p_five;
    for(auto p: primes){
        if(p % 5 == 1) p_five.push_back(p);
    }
    
    REP(i, 0, N) cout << p_five[i] << " ";
    cout << endl;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
#pragma GCC target ("avx2")
#pragma GCC optimization ("O3")
#pragma GCC optimization ("unroll-loops")
#define db "knapsack"
#define fi first
#define se second
#define endl '\n'
const int INF = 1e9 + 1;
const int maxN = 1e5 + 2;
const int mod = 1e9 + 7;
typedef long long ll;
typedef int Array[maxN];
typedef ll LLArray[maxN];
typedef pair<int, int> PII;
typedef PII PIIArray[maxN];

void docfile()
{
    if (ifstream("FORM.inp"))
    {
        freopen("FORM.inp", "r", stdin);
        freopen("FORM.out", "w", stdout);
    }
    else if (ifstream(db".inp"))
    {
        freopen(db".inp", "r", stdin);
        freopen(db".out", "w", stdout);
    }
}

//-----------------------------------------------------------------------------
ll n, cnt; ll ans;
string a[maxN];

void solve()
{
    sort(a+1, a+n+1);
    for(int i = 1; i <= n; i++)
    {
        if(a[i] == a[i-1]) cnt++;
        else
        {
            ans += (cnt * (cnt - 1) / 2);
            cnt = 1;
        }
    }
    if(cnt != 1) ans += (cnt * (cnt - 1) / 2);
    cout << ans;
}

void input()
{
    cin >> n;
    for(int i = 1; i <= n; i++)
    {
        cin >> a[i];
        sort(a[i].begin(), a[i].end());
    }
    solve();
}

int main()
{
    docfile();
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);

    input();
}


//-----------------------------------------------------------------------------
/*
template <typename T>
void write (T a)
{
    if (a < 0)
    {
        putchar ('-');
        write (-a);
        return;
    }
    if (a < 10)
    {
        putchar ('0' + a);
        return;
    }
    write (a / 10);
    putchar ((char)('0' + (a % 10)));
}

void read(long long& x)
{
    x = 0;
    int f = 1;
    char ch = getchar();
    while (!isdigit(ch))
        f = ch == '-' ? - f : f, ch = getchar();
    while (isdigit(ch))
        x = x * 10 + ch - '0', ch = getchar();
    x *= f;
}
*/




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

int main(){
  long long int N,m,sum=0;
  long long int i,max;

  scanf("%lld",&N);
  max = (long long int)sqrtl(N);
  for(i = 1;i <=max;i++){
    if(N%i==0){
      if(N/i-1 > i){sum+=N/i-1;}
      if(N/i < i-1){sum += i-1;}
     }
  }
  printf("%lld\n",sum);
  return 0;
}

Measured memory_bytes: 128
#include<iostream>
#include <stdlib.h>
#include <algorithm>
#include <string>
typedef long long int ll;
using namespace std;
int main(){
int x;
cin >> x;
if(x<1200){
	cout<<"ABC"<<endl;
}else if(x<2800){
	cout<<"ARC"<<endl;
}else{
	cout<<"AGC"<<endl;
}
}


Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<cmath>
#include<cstdlib>
#include<algorithm>
using namespace std;
int main()
{
	int n,k,d,snuke[105]={0},a,ans=0;
	cin >> n >> k;
	for(int i=1;i<=k;i++){
		cin >> d;
		for(int j=1;j<=d;j++){
			cin >> a;
			snuke[a]++;
		}
	}
	for(int i=1;i<=n;i++)
		if(snuke[i]==0)
			ans++;
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 3632
// {{{
#include <iostream>
#include <iomanip>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <climits>
#include <complex>
#include <vector>
#include <list>
#include <set>
#include <queue>
#include <stack>
#include <map>
#include <string>
#include <algorithm>
#include <numeric>
using namespace std;

#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define FOR(i, a, b) for(ll i = static_cast<ll>(a); i < static_cast<ll>(b); i++)
#define FORR(i, a, b) for(ll i = static_cast<ll>(a); i >= static_cast<ll>(b); i--)
#define REP(i, n) for(ll i = 0ll; i < static_cast<ll>(n); i++)
#define REPR(i, n) for(ll i = static_cast<ll>(n); i >= 0ll; i--)
#define ALL(x) (x).begin(), (x).end()

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> P;
typedef pair<ll, ll> LP;
typedef pair<int, P> IP;
typedef pair<ll, LP> LLP;

const int dx[] = {1, -1, 0, 0};
const int dy[] = {0, 0, 1, -1};

constexpr int INF = 100000000;
constexpr ll LINF = 10000000000000000ll;
constexpr int MOD = static_cast<int>(1e9 + 7);
constexpr double EPS = 1e-9;
// }}}

ll N, M;

void init()
{
}

void solve()
{
    ll ans;
    if(N > 2 && M > 2) ans = (N-2) * (M-2);
    else if(N == 2 || M == 2) ans = 0;
    else if(N == 1 && M > 1) ans = M-2;
    else if(N > 1 && M == 1) ans = N-2;
    else ans = 1;
    cout << ans << endl;
}

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    cin >> N >> M;
    solve();
    return 0;
}

// vim:set foldmethod=marker:


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


ll dp[20005];

int main() {
	int h, n;
	cin >> h >> n;
	vector<P> m(n);
	int amax = 0;
	rep(i, n) {
		cin >> m[i].first >> m[i].second;
		amax = max(amax, m[i].first);
	}

	ll ans = INF;
	rep(i, 20005) dp[i] = INF;
	dp[0] = 0;

	int aa = h + amax;
	rep(hi, aa) {
		rep(ai,n){
			if (hi > m[ai].first) {
				dp[hi] = min(dp[hi], dp[hi - m[ai].first] + m[ai].second); 
			}
			else {
				if (dp[hi] > m[ai].second) dp[hi] = m[ai].second;
			}
		}
	}
	
	for (int i = h; i < h + amax; i++) ans = min(ans, dp[i]);
	cout << ans << endl;
}


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

int main() {
  int num = 0;
  int N; cin >> N;
  string S; cin >> S;

  for(int i = 1; i < N; i++){
    string sub1 = S.substr(0, i);
    string sub2 = S.substr(i, S.size() - i);
    // cout << sub1 << ':' << sub2 << endl;
    int cnt = 0;
    string past_char = "";

    for(char c : sub1){
      if(sub2.find(c) != -1 && past_char.find(c) == -1) cnt++;
      past_char += c;
      // cout << c << ':' << cnt << ':' << past_char <<endl;
    }

    num = max(num, cnt);
  }
  cout << num << endl;

  return 0;
}


Measured memory_bytes: 256
// aarsh01rsh@gmail.com
// Aarsh Sharma
#include<bits/stdc++.h>
using namespace std;

string to_string(string s) {
  return '"' + s + '"';
}
string to_string(char ch) {
  string s(1, ch);
  return '\'' + s + '\'';
}
string to_string(const char *s) {
  return to_string((string)s);
}
string to_string(bool b) {
  return (b ? "true" : "false");
}
template <typename A, typename B>
string to_string(pair<A, B> p) {
return "(" + to_string(p.first) + ", " + to_string(p.second) + ")";
}
template <typename A>
string to_string(A v) {
  bool first = true;
  string res = "{";
  for (const auto &x : v) {
    if (!first) {
      res += ", ";
    }
    first = false;
    res += to_string(x);
  }
  res += "}";
  return res;
}
void debug_out() { cerr << endl; }
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
  cerr << " " << to_string(H);
  debug_out(T...);
}

#ifndef ONLINE_JUDGE
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#else
#define debug(...) 42
#endif

#define f(i, x, n) for (int i = x; i < n; i++)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define F first
#define S second
#define pb push_back
#define endl "\n"
#define unique(v) v.erase(unique(v.begin(), v.end()), v.end());
#define fast_io() ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)

typedef long long int ll;
#define int ll
typedef pair<ll, ll> pll;
typedef vector<vector<ll>> matrix;
typedef vector<ll> vll;

const ll mod = 1e9 + 7;
const ll inf = LLONG_MAX;
const ll N = 1e5 + 10;

int32_t main() {
  fast_io();

  int n; cin >> n;
  vll a(n); f (i, 0, n) cin >> a[i];
  double tot = 1;
  double sum = 0;
  f (i, 0, n) {
    tot *= a[i];
  }
  f (i, 0, n) {
    sum += tot/a[i];
  }
  cout << fixed << setprecision(5) << tot/sum;

  return 0;
}

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

using namespace std;

typedef long long ll;
const ll INF = 1LL<<60;

ll gcd(ll a, ll b) {
  if(b == 0) return a;
  return gcd(b, a % b);
}

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

ll modpow(ll a, ll n, ll mod) {
  ll res = 1;
  while (n > 0) {
    if (n & 1) res = res * a % mod;
    a = a * a % mod;
    n >>= 1;
  }
  return res;
}

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

  int X, Y, Z;
  cin >> X >> Y >> Z;

  X -= Z;
  int ans;
  ans = X / (Z + Y);
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS
#define _USE_MATH_DEFINES
#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <numeric>
#include <set>
#include <unordered_set>
#include <map>
#include <unordered_map>
#include <string>
#include <iterator>
#include <cmath>
#include <deque>
#include <stack>
#include <functional>
using namespace std;

signed main()
{
    {
        if (fopen("input.txt", "r")) {
            freopen("input.txt", "r", stdin);
            freopen("output.txt", "w", stdout);
        }
        ios_base::sync_with_stdio(false);
        cin.tie(NULL);
        cout.tie(NULL);
    }

    int n;
    cin >> n;
    string s, t;
    cin >> s >> t;
    for (int i = 0; i != n; ++i)
        cout << s[i] << t[i];
    return 0;
}

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

using namespace std;

int gcd(int a, int b) {
  if (a < b) return gcd(b, a);
  if (b == 0)
    return a;
  else
    return gcd(b, a % b);
}

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int N;
  cin >> N;
  vector<int> A(N);
  for (int i = 0; i < N; i++)
    cin >> A[i];

  vector<int> L(N + 2, 0);
  for (int i = 0; i < N; i++)
    L[i + 1] = gcd(L[i], A[i]);
  vector<int> R(N + 2, 0);
  for (int i = N; i > 0; i--)
    R[i] = gcd(R[i + 1], A[i - 1]);

  int res = 0;
  for (int i = 1; i <= N; i++)
    res = max(res, gcd(L[i - 1], R[i + 1]));

  cout << res << '\n';
  return 0;
}


Measured memory_bytes: 1408
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <queue>
#include <map>
#define ll long long
using namespace std;
int main(){
    int n;
    cin>>n;
    vector<int> a(n);
    vector<int> b(n);
    vector<int> c(n);
    for(int i=0;i<n;i++){
        cin>>a[i]>>b[i]>>c[i];
    }
    vector<vector<int>> dp(100005,vector<int>(3));
    dp[0][0]=a[0];
    dp[0][1]=b[0];
    dp[0][2]=c[0];
    for(int i=1;i<n;i++){
        dp[i][0]=a[i]+max(dp[i-1][1],dp[i-1][2]);
        dp[i][1]=b[i]+max(dp[i-1][0],dp[i-1][2]);
        dp[i][2]=c[i]+max(dp[i-1][1],dp[i-1][0]);
    }
    int ans=-1;
    for(int i=0;i<3;i++){
        if(ans<dp[n-1][i]){
            ans=dp[n-1][i];
        }
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 6912
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <cmath>
#include <queue>
#include <set>
#include <map>
#include <iomanip>
#include <fstream>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
const int mod = 1000000007;

int main() {
    ios::sync_with_stdio(false);
    int x, z = 0;
    cin >> x;
    z += (x / 500) * 1000;
    x %= 500;
    z += x / 5 * 5;
    cout << z;
}


Measured memory_bytes: 3660
# 初期入力
import sys
input = sys.stdin.readline
N,M = (int(i) for i in input().split())
K =[0]*N
A=[]
for i in range(N):
    a,*b = list(map(int, input().split()))
    K[i] =a
    A.append(set(b))
ans =set(list(A[0]))
for i in A:
    ans &=i
print(len(ans))

Measured memory_bytes: 9200
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<map>
#include<set>
#include<cstdio>
#include<cmath>
#define repp(i,a,b) for(int i=(int)a;i<(int)b;++i)
#define repm(i,a,b) for(int i=(int)a;i>(int)b;--i)
using ll=long long;
static const ll mod = 1e9;
static const ll INF = 1LL << 50;
using namespace std;

double sum = 0;

void dp(int i,int n,int k) {
	if (i>n)return;
	int x = 0;
	int l = i;
	while (l<k) {
		l *= 2;
		++x;
	}
	sum+=pow(0.5,x);
	i++;
	dp(i, n, k);
}

int main() {
	int n, k;
	cin >> n >> k;
	dp(1, n, k);
	printf("%1.12lf", (1.0 / (double)n) * sum);
	return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;
import java.util.stream.LongStream;
class Main{
    public static void main(String[] args){
        Scanner scan = new Scanner(System.in);
        int N = scan.nextInt();
        long P = scan.nextLong();
        long[] w = new long[N];
        long[] b = new long[N];
        for(int i=0;i<N;++i){
            w[i] = scan.nextLong();
            b[i] = scan.nextLong();
        }
        long[] wb = LongStream.range(0,N).map(i -> (100-P)*w[(int)i] + P*b[(int)i]).sorted().toArray();
        long sum = 0;
        long X = LongStream.range(0,N).map(i -> b[(int)i]).sum();
        for(int i=1;i<=N;++i){
            sum += wb[N-i];
            if(sum >= P*X){
                System.out.println(i);
                break;
            }
        }

    }
}

Measured memory_bytes: 90764
#include<iostream>
#include<vector>
#include<algorithm>
#include<cctype>
#define REP(i,s,n) for(int i=s;i<n;i++)
#define rep(i,n) REP(i,0,n)
#define inf (1<<29)

using namespace std;
bool counted;

void add(int &sum,char c)
{
  if(isdigit(c))sum += c-'0';
  else 
    {
      if(c == 'A')
	{
	  if(sum+11 > 21)sum += 1;
	  else           sum += 11,counted = true;
	}
      else 
	{
	  sum += 10;
	}
    }
}

int main()
{
  int T;
  while(cin >> T)
    {
      while(T--)
	{
	  counted = false;
	  int sum = 0;
	  rep(i,2)
	    {
	      char c;
	      cin >> c;
	      add(sum,c);
	    }

	  bool blackjack = (sum==21);
	  bool bust = false;
	  vector<char> vec(8);
	  rep(i,8)cin >> vec[i];

	  rep(i,8)
	    {
	      int value = 0;
	      if(sum <= 16 || (sum == 17 && counted))
		{
		  int nsum = sum;
		  add(nsum,vec[i]);
		  if(nsum > 21 && counted)
		    {
		      sum = nsum - 10;
		      counted = false;
		    }
		  else sum = nsum;
		}
	      if(sum > 21)bust = true;
	    }
	  if(blackjack)cout << "blackjack" << endl;
	  else if(bust)cout << "bust" << endl;
	  else cout << sum << endl;
	}
    }
  return 0;
}

Measured memory_bytes: 1208
import java.util.*;
import java.io.*;

public class Main {

    public static void main(String[] args) {
        MyScanner scn = new MyScanner();
        out = new PrintWriter(new BufferedOutputStream(System.out));

        // Start writing your solution here. -------------------------------------

        /*
         * int n = sc.nextInt(); // read input as integer long k = sc.nextLong(); //
         * read input as long double d = sc.nextDouble(); // read input as double String
         * str = sc.next(); // read input as String String s = sc.nextLine(); // read
         * whole line as String
         * 
         * int result = 3*n; out.println(result); // print via PrintWriter
         */

        // Stop writing your solution here. -------------------------------------

        int n = scn.nextInt();
        long[] arr = new long[n];
        for (int i = 0; i < n; i++)
            arr[i] = scn.nextLong();

        long[] check = new long[n];
        check[0] = arr[0];

        long stool = 0;
        for (int i = 1; i < arr.length; i++) {
            if (arr[i] >= check[i - 1]) {
                check[i] = arr[i];

            } else {
                check[i] = check[i - 1];
                stool += check[i] - arr[i];
            }
        }
        out.println(stool);
        out.close();
    }

    public static PrintWriter out;

    public static class MyScanner {
        BufferedReader br;
        StringTokenizer st;

        public MyScanner() {
            br = new BufferedReader(new InputStreamReader(System.in));
        }

        String next() {
            while (st == null || !st.hasMoreElements()) {
                try {
                    st = new StringTokenizer(br.readLine());
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }

        int nextInt() {
            return Integer.parseInt(next());
        }

        long nextLong() {
            return Long.parseLong(next());
        }

        double nextDouble() {
            return Double.parseDouble(next());
        }

        String nextLine() {
            String str = "";
            try {
                str = br.readLine();
            } catch (IOException e) {
                e.printStackTrace();
            }
            return str;
        }

    }

}

Measured memory_bytes: 56060
#include<iostream>
#include<string>
#include<cstdio>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<ciso646>
#include<random>
#include<map>
#include<set>
#include<complex>
#include<bitset>
using namespace std;
typedef long long ll;
typedef unsigned int ui;
const ll MOD = (1e+9)+7;
const ll INF = (ll)1000000007 * 1000000007;
typedef pair<int, int> P;
#define stop char nyaa;cin>>nyaa;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
typedef long double ld;
typedef complex<ld> Point;
const ld eps = 1e-11;
const ld pi = acos(-1.0);
typedef pair<ll, ll> LP;
typedef pair<ld, ld> LDP;
typedef pair<ll,P> PP;
int main() {
	string s; cin >> s;
	int len = s.length();
	cout << s[0] << len-2 << s[len - 1] << endl;
	return 0;
}

Measured memory_bytes: 256
using System;
class abc164_b{
  public static void Main(){
    String[] str = Console.ReadLine().Split(' ');
    int battle = (int.Parse(str[2])+int.Parse(str[1])-1)/int.Parse(str[1]);
    if(int.Parse(str[0]) - int.Parse(str[3])*(battle-1) > 0)
      Console.WriteLine("Yes");
    else
      Console.WriteLine("No");
  }
}


Measured memory_bytes: 17880
#include <bits/stdc++.h>
 
#define rep(i,n) for(ll i=0;i<n;++i)
#define ALL(a) (a).begin(),(a).end()
 
using namespace std;
using ll  = long long;
using pll = pair<ll, ll>;
using pdd = pair<double, double>;
 
const ll MOD  = 1e9+7;
const ll LINF = 1LL << 60;
const int INF = 1e9 + 7;

ll a, b, n;

ll form(ll x){

    return (a*x)/b - (a* (x/b));
}
int main(){
    cin >> a >> b >> n;

    cout << form(min(b-1, n)) << endl;
}

Measured memory_bytes: 3620
#include<bits/stdc++.h>
constexpr long long INFL = 1LL << 60;
constexpr int INF = 1e9;

using namespace std;

int main()
{
    int A,B,C,X;
    cin >> A >> B >> C >> X;
    int cnt = 0;

    for(int i = 0; i <= A; ++i){
        for(int j = 0; j <= B; ++j){
            for(int k = 0; k <= C; ++k){
                if(500*i + 100*j + 50*k == X)
                    cnt++;
            }
        }
    }
    cout << cnt << endl;
    return 0;
}

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

#define rep(i,n) for(i = 0;i < n;++i)
#define all(v) v.begin(), v.end()
using ll = long long;

int main()
{
    ll i,j;
    ll n,m;
    cin >> n >> m;
    ll tmp = (n-1)/2;
    ll nextt = tmp-1;
    ll times = 0;
    ll l = 1;
    ll r = l + tmp;
    ll nl = r+1;
    ll nr = nl + nextt;
    while(times < m){
        cout << l << " " << r << endl;
        ++l;    --r;
        ++times;
        if(r <= l) break;
    }
    while(times < m){
        cout << nl << " " << nr << endl;
        ++nl;    --nr;
        ++times;
    }
    return 0;
}

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


int LCSLength(char x[], char y[]) {
  int i, j;
  int xLen, yLen;
  int** c;  

  xLen = strlen(x);
  yLen = strlen(y);

  c = (int**)malloc( sizeof(int*) * (xLen+1) );
  for( i=0; i<=xLen; i++) {
    c[i] = (int*)malloc( sizeof(int) * (yLen+1) );
  }

  for( i=1; i<=xLen; i++) {
    c[i][0] = 0;
  }
  for( j=0; j<=yLen; j++) {
    c[0][j] = 0;
  }

  for( i=1; i<=xLen; i++) {
    for( j=1; j<=yLen; j++) {
      if( x[i-1] == y[j-1] ) {
	c[i][j] = c[i-1][j-1] + 1;
      }
      else if( c[i-1][j] >= c[i][j-1] ) {
	c[i][j] = c[i-1][j];
      }
      else {
	c[i][j] = c[i][j-1];
      }

    }
  }

  j = c[xLen][yLen];

  for( i=0; i<=xLen; i++) {
    free(c[i]);
  }
  free(c);

  return j;

}

main() {
  
  int n, i;
  char x[1001], y[1001];

  scanf("%d", &n);

  for( i=0; i<n; i++) { 
    scanf("%s%s", x, y);
    
    printf("%d\n", LCSLength( x, y) );
	   
  }

  return 0;
  
}

Measured memory_bytes: 4420
def gcd(a, b):
    if b == 0:
        return a
    return gcd(b, a % b)


def submit():
    n, s = map(int, input().split())
    xlist = list(map(int, input().split()))

    if n == 1:
        print(abs(xlist[0] - s))
    else:
        dist_list = [abs(x - s) for x in xlist]
        curr = gcd(dist_list[0], dist_list[1])
        for d in dist_list[2:]:
            curr = gcd(curr, d)
        print(curr)


if __name__ == "__main__":
    submit()

Measured memory_bytes: 15020
#include <iostream>
#include <vector>
#include <list>
#include <unordered_set>
#include <set>
#include <unordered_map>
#include <map>
#include <stack>
#include <queue>
#include <cassert>
#include <cmath>
#include <algorithm>
#include <stdlib.h>
#include <stdio.h>
#include <fstream>
#include <tuple>

//....................................................................................................................//

using std::cin;
using std::cout;
using std::vector;
using std::list;
using std::unordered_set;
using std::set;
using std::map;
using std::unordered_map;
using std::multimap;
using std::unordered_multimap;
using std::pair;
using std::make_pair;
using std::min;
using std::max;
using std::swap;
using std::stack;
using std::deque;
using std::queue;
using std::ios_base;
using std::ifstream;
using std::ofstream;
using std::string;
using std::tuple;
using std::make_tuple;
using std::get;
using std::upper_bound;
using std::lower_bound;
using std::max_element;
using std::min_element;

//....................................................................................................................//

typedef long long ll;
typedef unsigned long long ull;
typedef unsigned long ul;

[[maybe_unused]] const string endl = "\n";
[[maybe_unused]] const string sep = " ";
[[maybe_unused]] const string yes = "YES\n";
[[maybe_unused]] const string no = "NO\n";
[[maybe_unused]] const string ng = "NG\n";
[[maybe_unused]] const string ok = "OK\n";
[[maybe_unused]] const double pi = acos(-1);

//....................................................................................................................//



int main() {
    cin.tie(nullptr);
    cout.tie(nullptr);
    std::ios_base::sync_with_stdio(false);
    cout.precision(10);
    int n;
    cin >> n;
    int m;
    cin >> m;
    set<int> S;
    for (int i = 1; i <= n; ++i) {
        S.insert(i);
    }
    vector<int> H(n);
    for (int i = 0; i < n; ++i) {
        cin >> H[i];
    }
    for (int i = 0; i < m; ++i) {
        int a, b;
        cin >> a >> b;
        if (H[a - 1] <= H[b - 1]) {
            S.erase(a);
        }
        if (H[b - 1] <= H[a - 1]) {
            S.erase(b);
        }
    }
    cout << S.size();
    return 0;
}


Measured memory_bytes: 7900
import java.util.*;

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

        int n = sc.nextInt();
        int w = sc.nextInt();

        int[] weight = new int[n];
        int[] value = new int[n];

        for(int i = 0; i < n; i++){
            value[i] = sc.nextInt();
            weight[i] = sc.nextInt();
        }

        int[][] dp = new int[n + 1][w + 1];

        for(int i = 0; i < n; i++){
            for(int j = 0; j <= w; j++){
                if(j >= weight[i]){
                    dp[i + 1][j] = Math.max(dp[i][j], dp[i][j - weight[i]] + value[i]);
                }else{
                    dp[i + 1][j] = dp[i][j];
                }
            }
        }

        System.out.println(dp[n][w]);
    }
}



Measured memory_bytes: 31192
def main2(s,x,q):
    res = s
    rev = 1 #-1なら反転中
    lstA = []
    lstB = []
    for op in q:
        if int(op[0]) == 1:
            rev = rev * -1
        elif int(op[1])*rev == 1 or int(op[1])*rev == -2:
            lstA.append(op[2])
        elif int(op[1])*rev == -1 or int(op[1])*rev == 2:
            lstB.append(op[2])
    if rev == 1:
        res = "".join(lstA[::-1])+res+"".join(lstB)
    else :
        res = "".join(lstB[::-1])+res[::-1]+"".join(lstA)
    return res
 
s = input()
x = int(input())
q = [input().split() for _ in range(x)]
print(main2(s,x,q))

Measured memory_bytes: 42396
#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
#define loop(i, a, b) for(li i=a; i<=b; i++)
#define stuff ios::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define pb push_back
#define mp make_pair
#define fi first
#define se second
using namespace std;
typedef long long li;
typedef long double ld;
typedef pair<int, int> ii;
typedef pair<li, li> lii;
typedef vector<int> vi;
typedef vector<li> vli;
typedef vector<ii> vii;
typedef vector<lii> vlii;
li mod = 1e9+7;
li expo(li base, li exponent)
{
	li ans=1;
	while(exponent)
	{
		if(exponent&1) ans = (ans*base)%mod;
		base = (base*base)%mod;
		exponent >>= 1;
	}
	return ans;
}
li gcd(li x, li y)
{
	if(y==0) return x;
	return gcd(y, x%y);
}


typedef tree<li, null_type, less<li>,
rb_tree_tag, tree_order_statistics_node_update> ordered_set;

int main()
{
	stuff;
	// #ifndef ONLINE_JUDGE 
	// freopen("input.txt", "r", stdin);
	// freopen("output.txt", "w", stdout);
	// freopen("error.txt", "w", stderr);
	// #endif

	li n;
	cin >> n;
	vector<li> ar(n+1, 0);
	for(li i=2; i<=n; i++)
	{
		li x;
		cin >> x;
		ar[x]++;
	}
	loop(i, 1, n)
	{
		cout << ar[i] << "\n";
	}
	return 0;
}


Measured memory_bytes: 4784
package main

import (
	"fmt"
)

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

	N := []byte(n)
	for i := 0; i < len(N); i++ {
		if N[i] == '1' {
			N[i] = '9'
		} else if N[i] == '9' {
			N[i] = '1'
		}
	}
	fmt.Println(string(N))
}


Measured memory_bytes: 512
n = int(input())

value1 = int(input())
value2 = int(input())
maxDiff = value2 - value1
minValue = min(value1, value2)
for i in range(n - 2):
  value = int(input())
  diff = value - minValue
  maxDiff = max(diff, maxDiff)
  minValue = min(value, minValue)
print(maxDiff)



Measured memory_bytes: 5612
#include <stdio.h>
#include <string.h>
#include <algorithm>
#include <iostream>
#include <string>
#include <vector>
#include <functional>
#include <map>
#include <iomanip>
#include <math.h> 
#include <stack>
#include <queue>
#include <bitset>
#include <cstdlib>
#include <tuple>
#include <cctype>
#include <ctype.h>
#include <set>
#include <sstream>
#include <time.h>
#include <numeric>
using namespace std;
//#define int long long
#define rep(i,s,n) for(int i = s;i<n;i++)
#define repe(i,s,n) for(int i = s;i<=n;i++)
#define rrep(i,s,n) for(int i = (n)-1;i>=(s);i--)
#define all(v) (v).begin(),(v).end()
#define pb push_back
#define fi first
#define se second
#define chmin(a,b) a=min((a),(b))
#define chmax(a,b) a=max((a),(b))
#define l1 list[index]
#define l2 list[index - 1]
#define l3 list[index + 1]
#define iif(i,j) ((i<0 && j<0) || (i>0 && j>0)) ? true : false 
typedef long long ll;
typedef pair<int, int>pint;
typedef vector<int>vint;
typedef vector<pint>vpint;
typedef pair<pint, int> P1;
typedef pair<int, pint> P2;
typedef pair<pint, pint> PP;
static const ll maxLL = (ll)1 << 62;
const ll MOD = 1000000007;
const ll INF = 1e18;
const double PI = 3.14159265359;
int ca[12] = { 31,28,31,30,31,30,31,31,30,31,30,31 };




signed main() {
	string s;

	cin >> s;

	ll sum = 0;

	for (int i = 0; i < s.length(); i++) {
		sum += (s[i] - '0');
	}

	if (stol(s) % sum == 0) {
		cout << "Yes" << endl;
	}
	else {
		cout << "No" << endl;
	}

	return 0;
}

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

int main(){
  int N;
  cin >> N;
  vector<int> P(N);
  for(int i=0; i<N; i++) cin >> P.at(i);
  int ans=0;
  int minn=200001;
  for(int i=0; i<N; i++){
    if(minn>=P.at(i)){
      ans++;
    }
    minn=min(minn, P.at(i));
  }
  cout << ans << endl;
}

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

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

  p += 3*a;
  int count = p/2;
  cout << count << endl;
}


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

long task_C (long range_min, long range_max, long val_divisor)
{
	// return value of this function
	long val_mod_minimum;
	long val_mod_buffer;

	// STEP.01
	// initialize the return value of this function
	val_mod_minimum = LONG_MAX;

	// STEP.02
	// search the minimum possible value of mod
	for (long itr_sml = range_min;    itr_sml <  range_max; itr_sml++) {
	for (long itr_lrg = itr_sml + 1L; itr_lrg <= range_max; itr_lrg++) {

		val_mod_buffer = (itr_sml * itr_lrg) % val_divisor;

		if (val_mod_buffer == 0L)
		{
			return 0L;
		}
		else if (val_mod_buffer < val_mod_minimum)
		{
			val_mod_minimum = val_mod_buffer;
		}
		else
		{
			continue;
		}
		
	} }

	// STEP.END
	return val_mod_minimum;
}

long main (void)
{
	// variables for main process
	long L, R;
	long rtvl_scanf;
	long val_divisor;

	// STEP.01
	// set the parameter
	val_divisor = 2019;

	// STEP.02
	// read out the given data
	rtvl_scanf = scanf("%ld %ld", &L, &R);

	// STEP.03
	// output the answer of this task
	printf("%ld\n", task_C(L, R, val_divisor));

	// STEP.END
	return EXIT_SUCCESS;
}

Measured memory_bytes: 128
a=[list(map(int,input().split()))for i in range(int(input()))]
b=[[[0 for i in range(10)] for j in range(3)] for k in range(4)]
for i in a:
  b[i[0]-1][i[1]-1][i[2]-1] += i[3]
f=0
for i in b:
  if f:print('#'*20)
  else:f=1
  for j in i:
    print('',*j)

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


int main() {
    ll n;
    cin >> n;
    ll ans = 0;
    REP(i,n){
        ans += (i+n/i*i)*(n/i)/2;
    }
    cout << ans << endl;
}

Measured memory_bytes: 3580
#include <algorithm>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>
#include <cfloat>

using std::cerr;
using std::cin;
using std::cout;
using std::endl;

typedef std::pair<int,int> P;

struct State{
  int depth;
  int r,c;
  State(int pr,int pc,int d):r(pr),c(pc),depth(d){}
};

int main(){
  cout << std::fixed << std::setprecision(16);
  cin.tie(nullptr);
  std::ios::sync_with_stdio(false);

  int h,w;
  cin>>h>>w;
  char map[202][202]={};

  P princess;
  P goal;
  std::vector<P> soldier;

  for(int c=0;c<=w+1;c++){
    map[0][c]='#';
    map[h+1][c]='#';
  }



  for(int r=1;r<=h;r++){
    std::string s;
    cin>>s;
    map[r][0]='#';
    for(int c=1;c<=w;c++){
      map[r][c]=s[c-1];
      if(map[r][c]=='@'){
        princess=std::make_pair(r,c);
      }else if(map[r][c]=='$'){
        soldier.push_back(std::make_pair(r,c));
      }else if(map[r][c]=='%'){
        goal = std::make_pair(r, c);
      }
    }
    map[r][w+1]='#';
  }

  bool p_visited[202][202]={};
  p_visited[princess.first][princess.second]=true;

  int princess_turn=0;
  std::queue<State> q;
  q.push(State(princess.first,princess.second,0));
  while(!q.empty()){
    State curr=q.front();
    q.pop();
    if(map[curr.r][curr.c]=='%'){
      princess_turn=curr.depth;
      break;
    }
    for(int vr=-1;vr<=1;vr++){
      for(int vc=-1;vc<=1;vc++){

        if(!((vr==0&&vc!=0)||(vc==0&&vr!=0))){
          continue;
        }

        if(map[curr.r+vr][curr.c+vc]!='#'&&!p_visited[curr.r+vr][curr.c+vc]){
          p_visited[curr.r+vr][curr.c+vc]=true;
          q.push(State(curr.r+vr,curr.c+vc,curr.depth+1));
        }

      }
    }
  }

  int min_turn=INT32_MAX/3;



    std::queue<State> sq;

    bool visited[202][202]={};
    visited[goal.first][goal.second]=true;

    int turn=INT32_MAX/3;
    sq.push(State(goal.first,goal.second,0));
    while(!sq.empty()){
      State curr=sq.front();
      sq.pop();
      if(map[curr.r][curr.c]=='$'){
        turn=curr.depth;
        break;
      }
      for(int vr=-1;vr<=1;vr++){
        for(int vc=-1;vc<=1;vc++){

          if(!((vr==0&&vc!=0)||(vc==0&&vr!=0))){
            continue;
          }

          if(map[curr.r+vr][curr.c+vc]!='#'&&!visited[curr.r+vr][curr.c+vc]){
            visited[curr.r+vr][curr.c+vc]=true;
            sq.push(State(curr.r+vr,curr.c+vc,curr.depth+1));
          }

        }
      }
    }

    min_turn=std::min(min_turn,turn);


  cout<<((princess_turn<min_turn)?"Yes":"No")<<endl;








  return 0;
}


Measured memory_bytes: 3656
#include <iostream>
#include <string>
#include <vector>

using namespace std;

#define SIZE 100000

int main(){
    int n;
    cin >> n;
    int in;
    vector<int> num(SIZE);
    for(int i = 0; i < SIZE; i++) num[i] = 0;

    for(int i = 0; i < n; i++){
        cin >> in;
        if(in != 0) num[in-1]++;
        num[in]++;
        if(in != SIZE-1)num[in+1]++;
    }

    int max = 0;
    for(int n : num){
        if(max < n) max = n;
    }
    cout << max << endl;


}

Measured memory_bytes: 640
#include <bits/stdc++.h>
#define rep(i, a) for(int i = 0; i < a; i++)
#define all(v) v.begin(), v.end()
#define dcout cout << fixed << setprecision(15)
#define arep(i, a) for(auto i : a)
#define F first
#define S second
#define VE vector<int>
#define pb(x) push_back(x)
#define MOD 1000000007
#define INF 10000000000
#define int long long
#define KETA(n) floor(log10(n) + 1)
using namespace std;
signed main() {
    string s, t;
    cin >> s >> t;
    map<string, int> m;
    int a, b;
    cin >> a >> b;
    m[s] = a;
    m[t] = b;
    string u;
    cin >> u;
    m[u]--;
    cout << m[s] << " " << m[t];
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define all(vec) vec.begin(), vec.end()
using namespace std;
using ll = long long;
using P = pair<ll, ll>;
constexpr ll INF = (1LL << 30) - 1;
constexpr ll LINF = (1LL << 60) - 1LL;
constexpr double eps = 1e-9;
constexpr ll MOD = 1000000007LL;
template <typename T>
bool chmin(T& a, T b) {
    if(a > b) {
        a = b;
        return true;
    }
    return false;
};
template <typename T>
bool chmax(T& a, T b) {
    if(a < b) {
        a = b;
        return true;
    }
    return false;
};
template <typename T>
ostream& operator<<(ostream& os, vector<T> v) {
    for(int i = 0; i < v.size(); i++) {
        os << v[i] << (i + 1 == v.size() ? "\n" : " ");
    }
    return os;
}
template <typename T>
vector<T> make_v(size_t a) {
    return vector<T>(a);
}
template <typename T, typename... Ts>
auto make_v(size_t a, Ts... ts) {
    return vector<decltype(make_v<T>(ts...))>(a, make_v<T>(ts...));
}
template <typename T, typename V>
typename enable_if<is_class<T>::value == 0>::type fill_v(T& t, const V& v) {
    t = v;
}
template <typename T, typename V>
typename enable_if<is_class<T>::value != 0>::type fill_v(T& t, const V& v) {
    for(auto& e : t) {
        fill_v(e, v);
    }
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n, m;
    cin >> n >> m;
    vector<ll> a(n);
    for(int i = 0; i < n; i++) {
        cin >> a[i];
    }
    sort(all(a));
    vector<P> v;
    for(int i = 0; i < m; i++) {
        int b, c;
        cin >> b >> c;
        v.push_back(P(c, b));
    }
    sort(all(v));
    reverse(all(v));
    int id = 0;
    ll ans = 0;
    for(int i = 0; i < n; i++) {
        if(id < m && v[id].first > a[i]) {
            ans += v[id].first;
            v[id].second--;
        } else {
            ans += a[i];
        }
        if(id < m && v[id].second == 0) {
            id++;
        }
    }
    cout << ans << endl;
}


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

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

        int n;
        map<string, int> mp;
        cin >> n;
        while(n--) {
                string s;
                cin >> s;
                ++mp[s];
        }

        cout << "AC x " << mp["AC"] << "\n";
        cout << "WA x " << mp["WA"] << "\n";
        cout << "TLE x " << mp["TLE"] << "\n";
        cout << "RE x " << mp["RE"];

        return 0;
}


Measured memory_bytes: 3648
#include<cstdio>
#include<cstdlib>
#include<iostream>
#include<algorithm>
#include<map>
#include<cstring>
#include<string>
#include<cmath>
using namespace std;

int main()
{
	int n, a, b;
	cin >> n >> a >> b;
	int sum = 0, k;
	for(int i = 1;i <= n;i++){
		k = i;
		int s = 0;
		while(k){
			s += k % 10;
			k /= 10;
		}
		if(s >= a && s <= b) sum += i;
	}
	cout << sum << endl;
	return 0;
}

Measured memory_bytes: 256
import java.util.*;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    long N = sc.nextLong();
    sc.close();

    long x = (long) Math.sqrt((double)N);
    for (; x > 1; x--) {
      if (N%x==0) break;
    }

    System.out.println(x+N/x-2);
    return;
  }
}


Measured memory_bytes: 23892
import java.util.Scanner;
public class Main{
    public static void main(String[] args){
        Scanner scan = new Scanner(System.in);
        String str,num,code;
        int a,b,i,j,x,y;
        str = scan.nextLine();
        num = scan.nextLine();
        a = Integer.valueOf(num);
        x = 0;
        y = 0;
        for(i=0;i<a;i++){
            code = scan.nextLine();
            String[] words = code.split(" ", 0);
            if(words[0].equals("replace")){
                str = replace(words,str);
            }else if(words[0].equals(("print"))){
                print(words,str);
            }else{
                str = reverse(words,str);
            }
        }

        scan.close();

    }
    public static String replace(String words[],String str){
        int a,b;
        a = Integer.valueOf(words[1]);
        b = Integer.valueOf(words[2]);
        return str.substring(0,a) + words[3] + str.substring(b+1);
    }
    public static void print(String words[],String str){
        int a,b;
        a = Integer.valueOf(words[1]);
        b = Integer.valueOf(words[2]);
        System.out.println(str.substring(a,b+1));
    }
    public static String reverse(String words[],String str){
        int a,b,i;
        a = Integer.valueOf(words[1]);
        b = Integer.valueOf(words[2]);
        StringBuffer sb = new StringBuffer(str.substring(a,b+1));
        return str.substring(0,a)+sb.reverse().toString()+str.substring(b+1);
    }
}




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

#define ll long long
#define mod 100000000000007
#define ffor(i,a,b) for(int i=a;i<b;i++)
#define bfor(i,a,b) for(int i=a-1;i>=b;i--)
#define mp make_pair
#define pb push_back
#define ff first
#define ss second
#define mem(x,y) memset(x,y,sizeof(x))
#define all(x) x.begin(),x.end()
#define SP(x) setprecision(x)
#define sz(x) (int)x.size()
#define fast  ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL)
#define PI 3.1415926535
#define lb lower_bound
#define ub upper_bound
#define bs binary_search

int main()
{
    int n;
    cin>>n;
    cout<<n*n*n;
    return 0;
}



Measured memory_bytes: 256
#include<iostream>

int main(){
  int A[3];
  for(int i=0;i<3;i++){
    std::cin>>A[i];
  }
  
  int cost[3]={std::abs(A[0]-A[1]),std::abs(A[1]-A[2]),std::abs(A[2]-A[0])};
  int max=cost[0];
  for(int i=1;i<3;i++){
    if(max<cost[i]){
      max=cost[i];
    }
  }
  
  std::cout<<cost[0]+cost[1]+cost[2]-max<<std::endl;
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rng(i, a, b) for (int i = int(a); i < int(b); i++)
#define rep(i, b) rng(i, 0, b)
#define gnr(i, a, b) for (int i = int(b) - 1; i >= int(a); i--)
#define per(i, b) gnr(i, 0, b)
#define bg begin()
#define ed end()
#define all(x) x.bg, x.ed
#define vi vector<int>
template <class t, class u>
bool chmax(t &a, u b)
{
    if (a < b)
    {
        a = b;
        return true;
    }
    return false;
}
template <class t, class u>
bool chmin(t &a, u b)
{
    if (b < a)
    {
        a = b;
        return true;
    }
    return false;
}

signed main()
{
    string a,b;
    cin>>a>>b;
    int ans = 0;
    rep(i, a.length())
    {
        if(a[i]!=b[i]){
            ans++;
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3916
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
#define INF 100000000
using namespace std;

int main() {
 
int64_t N,M,ans=0;
cin >>N>>M;
// vector<int> A(N);
// for(int i=0; i<N; i++){cin>>A[i];}
// vector<vector<int>> A(N,vector<int>(M));
// for(int i=0; i<N; i++){for(int j=0; j<M; j++){cin>>A[i][j];}}
while(N<=M){
  N*=2;
  ans++;
}
  cout<<ans<<endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
#define mp make_pair
#define pb push_back
#define INF 1000 * 1000 * 1000
using namespace std;
int n , a[100000];
int main()
{
	scanf("%d" , &n);
	for(int i = 0; i < n; i++)
	{
		scanf("%d" , &a[i]);
	}
	reverse(a , a + n);
	if(a[0] != 2)
	{
		cout << "-1";
		return 0;
	}
	ll l = 2 , r = 3;
	for(int i = 1; i < n; i++)
	{
		ll newL = ((l + a[i] - 1) / a[i]) * a[i] , newR = (r / a[i]) * a[i] + a[i] - 1;
		if(newL > newR)
		{
			cout << -1;
			return 0;
		}
		l = newL , r = newR;
	}
	cout << l << " " << r << endl;
}



Measured memory_bytes: 640
import collections

while True:
    w, h = map(int, input().split())
    if not w and not h:
        break
    graph = [list(map(int, input().split())) for _ in range(h)]
    seen = [[False] * w for i in range(h)]

    dy = [0, 1, 0, -1, 1, 1, -1, -1]
    dx = [1, 0, -1, 0, 1, -1, 1, -1]

    def dfs(v):
        stack = collections.deque()
        stack.append(v)
        while stack:
            y, x = stack.pop()
            for i in range(8):
                ny = y + dy[i]
                nx = x + dx[i]
                if not (-1 < ny < h and -1 < nx < w):
                    continue
                if not graph[ny][nx]:
                    continue
                if seen[ny][nx]:
                    continue
                seen[ny][nx] = True
                stack.append([ny, nx])

    count = 0
    for i in range(h):
        for j in range(w):
            if graph[i][j] and not seen[i][j]:
                dfs([i, j])
                count += 1

    print(count)



Measured memory_bytes: 6040
/* ex 7_1
   terakura */

#include <stdio.h>

typedef struct point{
    int x_elem;
    int y_elem;
}point;


//頂点を移動させる関数
point shift_point(point p, int x_diff, int y_diff){
    p.x_elem -= y_diff;
    p.y_elem += x_diff;

    return p;
}


int main(void){
    int x_diff, y_diff;
    point a, b, c, d;
    scanf("%d %d %d %d", &a.x_elem, &a.y_elem, &b.x_elem, &b.y_elem);

    //x座標の差とy座標の差を計算
    x_diff = b.x_elem - a.x_elem;
    y_diff = b.y_elem - a.y_elem;

    c = shift_point(b, x_diff, y_diff);
    d = shift_point(a, x_diff, y_diff);

    printf("%d %d %d %d\n", c.x_elem, c.y_elem, d.x_elem, d.y_elem);

    return 0;

}


Measured memory_bytes: 1724
n = int(input())
b = list(map(int, input().split()))
n = [0] * n
count = 0
for i in range(len(b)):
    if count == 0:
        n[0] = b[0]
        n[1] = b[0]
    if n[count] >= b[i] and count >= 1:
        n[count] = b[i]
        n[count + 1] = b[i]
    if n[count] < b[i] and count >= 1:
        n[count + 1] = b[i]
    count += 1
print(sum(n))


Measured memory_bytes: 3064
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>	
#include<map>
#include<set>
#include<utility>
#include<cmath>
#include<cstring>
#include<queue>
#include<cstdio>
#include<sstream>
#include<iomanip>
#define loop(i,a,b) for(int i=a;i<b;i++) 
#define rep(i,a) loop(i,0,a)
#define pb push_back
#define mp make_pair
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)
using namespace std;
//kaewasuretyuui
typedef long long ll;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<pii> vp;
typedef vector<vp> vvp;
typedef pair<int,pii> pip;
typedef vector<pip>vip	;
const double PI=acos(-1);
const double EPS=1e-8;
const int inf=1<<30;
int main(){
	int n,m;
	cin>>n>>m;
	vi out(n);
	out[0]=true;
	vi co(n,1);
	while(m--){
		int a,b;
		cin>>a>>b;
		a--;b--;
		co[a]--;
		co[b]++;
		if(out[a])out[b]=true;
		if(co[a]==0)out[a]=false;
	}
	int c=0;
	rep(i,n)if(out[i])c++;
	cout<<c<<endl;
}







Measured memory_bytes: 1024