akhauriyash/Code-Regression huggingface dataset:
using System;
using System.Linq;
using System.Collections.Generic;
using static System.Console;
using System.Text;
using System.IO;
using static System.Math;
using System.Numerics;

namespace AtCoder
{
    public class Program
    {
        public static void Main(string[] args)
        {
            //SetOut(new StreamWriter(OpenStandardOutput()) { AutoFlush = false });
            Solve();
            //Out.Flush();
            Read();
        }

        static void Solve()
        {
            var (a, b) = Slice2<long>();
            WriteLine(a - 1 + (a <= b ? 1 : 0));
        }

        static long Mod = 998244353;
        static public long[] Sarray() { return ReadLine().Split().Select(long.Parse).ToArray(); }
        static public List<long> Slist() { return ReadLine().Split().Select(long.Parse).ToList(); }
        static public (T1 a, T2 b) Slice<T1, T2>()
        {
            var t = ReadLine().Split();
            return (
            (T1)Convert.ChangeType(t[0], typeof(T1)),
            (T2)Convert.ChangeType(t[1], typeof(T2)));
        }
        static public (T a, T b) Slice2<T>()
        {
            var t = ReadLine().Split();
            return (
            (T)Convert.ChangeType(t[0], typeof(T)),
            (T)Convert.ChangeType(t[1], typeof(T)));
        }
        static public (T a, T b, T c) Slice3<T>()
        {
            var t = ReadLine().Split();
            return (
            (T)Convert.ChangeType(t[0], typeof(T)),
            (T)Convert.ChangeType(t[1], typeof(T)),
            (T)Convert.ChangeType(t[2], typeof(T)));
        }
    }
}

Measured memory_bytes: 27300
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using vb=vector<bool>;
using vvb=vector<vb>;
using vd=vector<double>;
using vvd=vector<vd>;
using vi=vector<int>;
using vvi=vector<vi>;
using vl=vector<ll>;
using vvl=vector<vl>;
using pll=pair<ll,ll>;
using tll=tuple<ll,ll>;
using tlll=tuple<ll,ll,ll>;
using vs=vector<string>;
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define rep(i,n) range(i,0,n)
#define rrep(i,n) for(ll i=((ll)n)-1;i>=0;i--)
#define range(i,a,n) for(ll i=((ll)a);i<((ll)n);i++)
#define LINF ((ll)1ll<<60)
#define INF ((int)1<<30)
#define EPS (1e-9)
#define MOD (1000000007ll)
#define fcout(a) cout<<setprecision(a)<<fixed
#define fs first
#define sc second
#define PI (3.1415926535897932384)

int dx[]={1,0,-1,0,1,-1,-1,1},dy[]={0,1,0,-1,1,1,-1,-1};
template<class T>bool chmax(T&a,T b){if(a<b){a=b; return true;}return false;}
template<class T>bool chmin(T&a,T b){if(a>b){a=b; return true;}return false;}
template<class S>S sum(vector<S>&a){return accumulate(all(a),S());}
template<class S>S max(vector<S>&a){return *max_element(all(a));}
template<class S>S min(vector<S>&a){return *min_element(all(a));}
ll max(int a,ll b){return max((ll)a,b);} ll max(ll a,int b){return max(a,(ll)b);}
int sgn(const double&r){return (r>EPS)-(r<-EPS);} // a>0  : sgn(a)>0
int sgn(const double&a,const double&b){return sgn(a-b);} // b<=c : sgn(b,c)<=0

template<class T>void puta(T&&t){cout<<t<<"\n";}
template<class H,class...T>void puta(H&&h,T&&...t){cout<<h<<' ';puta(t...);}
template<class S,class T>void tf(bool b,S t,T f){if(b)puta(t);else puta(f);}
void YN(bool b){tf(b,"YES","NO");}
void Yn(bool b){tf(b,"Yes","No");}
void yn(bool b){tf(b,"yes","no");}
template<class S,class T>ostream&operator<<(ostream&os,pair<S,T>p){os<<"["<<p.first<<", "<<p.second<<"]";return os;};
template<class S>auto&operator<<(ostream&os,vector<S>t){bool a=1;for(auto s:t){os<<(a?"":" ")<<s;a=0;}return os;}
template<class S>auto&operator>>(istream&is,vector<S>&t){for(S&a:t)cin>>a;return is;}

/*他のライブラリを入れる場所*/
struct UnionFind{
    vl par,dist;
    UnionFind(int x){par.assign(x,-1); dist.assign(x,0);}
    ll find(ll x){return par[x]<0?x:find(par[x]);}
    ll depth(ll x){return par[x]<0?0:depth(par[x])+dist[x];}
    bool same(ll x,ll y){return find(x)==find(y);}
    ll size(ll x){return -par[find(x)];}
    ll diff(ll x,ll y){return same(x,y)?depth(x)-depth(y):LINF;}
    void unite(ll x,ll y,ll k=0){
        k+=depth(y); k-=depth(x); k=-k;
        x=find(x); y=find(y);
        if(x==y)return;
        if(size(x)<size(y)){swap(x,y);k=-k;}
        par[x]+=par[y]; par[y]=x; dist[y]=k;
    }
};

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll n,q;
    cin>>n>>q;
    UnionFind uf(n);
    rep(i,q){
        ll l,r,d;
        cin>>l>>r>>d;
        l--;r--;
        if(uf.same(l,r) and uf.diff(l,r)!=d){
            Yn(0);
            return 0;
        }else{
            uf.unite(l,r,d);
        }
    }
    Yn(1);
    return 0;
}

Measured memory_bytes: 1792
#include <iostream>
using namespace std;
int main() {
	int n;
	int h[1000000];
	int a[1000000];
	a[0] = 0;
	cin >> n;
	for (int i = 0; i < n; i++)
		cin >> h[i];
	 

	for (int i=0;i<n;i++)
	{

		a[i + 1] = abs(h[i] - h[i + 1]) + a[i];

		if (i > 0)
		{
			if (a[i + 1] > abs(h[i - 1] - h[i + 1]) + a[i - 1])
				a[i + 1] = abs(h[i - 1] - h[i + 1]) + a[i - 1];
		}
	}

	cout << a[n - 1];
}

Measured memory_bytes: 4736
#include <iostream>
#include <string>
#include <algorithm>
#include <functional>
#include <vector>
#include <utility>
#include <cstring>
#include <iomanip>
#include <numeric>
#include <limits>
#include <cmath>
using namespace std;
using ll = long long;
const int INF = 1<<30;
const int MOD = (int)1e9 + 7;
const int MAX_N = (int)1e5 + 5;
#define debug(x) cout << #x << ": " << x << endl

signed main(void)
{
    int n; cin >> n;
    vector<int> v(n);
    for(int i = 0; i < n; i++) cin >> v[i];
    int ans = n;
    int target = 1;
    for(int i = 0; i < n; i++)
    {
        if(target == v[i])
        {
            target++;
            ans--;
        }
    }
    if(ans == n) cout << -1 << endl;
    else cout << ans << endl;
    return 0;
}


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

int main() {
    int p, q, r;
    cin >> p >> q >> r;
    cout << min(p + q, min(q + r, r + p)) << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <math.h>
#include <string>
#include <algorithm>
#include <ctype.h>
#include <vector>
using namespace std;

#define ll long long int
#define rep(i, a, n) for (int i = a; i < n; i++)
#define INF 1e9
#define LINF 1e17
#define MOD (int)(1e9 + 7)
#define pi 3.141592653589
#define pii pair<int, int>

int main()
{
    int a, b, c, x, y;

    cin >> a >> b >> c >> x >> y;
    if (a + b <= 2 * c)
    {
        cout << a * x + b * y << endl;
    }
    else
    {
        int ans = 2 * c * min(x, y);
        if (x > y)
            ans += a * (x - y);
        else
            ans += b * (y - x);
        cout << min(ans, 2 * c * max(x, y)) << endl;
    }
}


Measured memory_bytes: 256
//panasonic2020_c.cpp
//Sat Mar 14 20:55:54 2020

#include <iostream>
#include <string>
#include <queue>
#include <map>
#include <unordered_map>
#include <vector>
#include <algorithm>
#include <math.h>
#include <set>
#define INTINF 2147483647
#define LLINF 9223372036854775807
#define MOD 1000000007

using namespace std;
using ll=long long;
typedef pair<int,int> P;

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

	ll x = c-a-b;
	if (x<0){
		cout << "No" << endl;
		return 0;
	}
	ll z = x*x;
	ll y = 4*a*b;

	if (y<z){
		cout << "Yes" << endl;
	}else {
		cout << "No" << endl;
	}

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

Measured memory_bytes: 256
Q=int(input())
import math 
for i in range(Q):
  a,b=map(int, input().split())
  if a==b:
    print(2*(a-1))
  else:
    d=math.isqrt(a*b-1)
    if d*(d+1)<a*b:
      print(2*d-1)
    else:
      print(2*d-2)

Measured memory_bytes: 9128
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Scanner;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 *
 * @author Eric
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        Scanner in = new Scanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        TaskB_147 solver = new TaskB_147();
        solver.solve(1, in, out);
        out.close();
    }

    static class TaskB_147 {
        public void solve(int testNumber, Scanner in, PrintWriter out) {
            String s = in.next();
            int res = 0;
            for (int i = 0; i < s.length(); i++) {
                char c1 = s.charAt(i);
                char c2 = s.charAt(s.length() - 1 - i);
                if (c1 != c2)
                    res++;
            }

            out.println(res / 2);
        }

    }
}



Measured memory_bytes: 23248
#include <bits/stdc++.h>
using ll = long long;
using namespace std;
#define rep(i,n) for(int i=0, i##_len=(int)(n); i<i##_len; i++)
#define reps(i,n) for(int i=1 , i##_len=(int)(n);i<=i##_len;i++)
#define rrep(i,n) for(int i=((int)(n)-1);i>=0;i--)
#define rreps(i,n) for(int i=((int)(n));i>0;i--)
#define repi(i,x) for(auto i=(x).begin(),i##_fin=(x).end();i!=i##_fin;i++)
#define all(x) (x).begin(), (x).end()
#define F first
#define S second
#define mp make_pair
#define mt make_tuple
#define pb push_back
#define eb emplace_back
string solve(bool a) { return ((a) ? "Yes" : "No"); }
typedef vector<int> Vi;
typedef vector<Vi> VVi;
typedef pair<int , int> Pi;
typedef vector<Pi> VPi;
typedef vector<long long> V;
typedef vector<V> VV;
typedef pair<long long , long long> P;
typedef vector<P> VP;
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;}
template <class T, class U>ostream& operator<<(ostream& os, const pair<T, U>& p) {
	os << "(" << p.first << "," << p.second << ")";
	return os;
}
template <class T>ostream& operator<<(ostream& os, const vector<T>& v) {
	os << "{";
	rep(i, v.size()) {
		if (i) os << ",";
		os << v[i];
	}
	os << "}";
	return os;
}
template <class T, class U>istream& operator>>(istream& is, pair<T, U>& p) {
	is >> p.first >>p.second ;
	return is;
}
template <class T>istream& operator>>(istream& is,  vector<T>& v) {
	rep(i, v.size()) {
		is >> v[i];
	}
	return is;
}
const long long INFLL = 1LL<<60;
const int INF = 1<<30;
const double PI=acos(-1);
int main(){
	int n;
	int ans=0;
	cin >>n;
	cout<<not(n)<<endl;
}

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

using namespace std;

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

typedef int _loop_int;
#define REP(i,n) for(_loop_int i=0;i<(_loop_int)(n);++i)
#define FOR(i,a,b) for(_loop_int i=(_loop_int)(a);i<(_loop_int)(b);++i)
#define FORR(i,a,b) for(_loop_int i=(_loop_int)(b)-1;i>=(_loop_int)(a);--i)

#define DEBUG(x) cout<<#x<<": "<<x<<endl
#define DEBUG_VEC(v) cout<<#v<<":";REP(i,v.size())cout<<" "<<v[i];cout<<endl
#define ALL(a) (a).begin(),(a).end()

#define CHMIN(a,b) a=min((a),(b))
#define CHMAX(a,b) a=max((a),(b))

// mod
const ll MOD = 1000000007ll;
#define FIX(a) ((a)%MOD+MOD)%MOD

// floating
typedef double Real;
const Real EPS = 1e-11;
#define EQ0(x) (abs(x)<EPS)
#define EQ(a,b) (abs(a-b)<EPS)
typedef complex<Real> P;

int main(){
  int n,d;
  scanf("%d%d",&n,&d);
  if(d==1){
    ll ans = (ll)n*(n-1)/2;
    printf("%lld\n",ans);
    return 0;
  }
  // s,t
  ll k = n-(d-2);
  ll ans = k*(k-1)/2 - 1 + (d-2);
  printf("%lld\n",ans);
  return 0;
}

Measured memory_bytes: 1188
program main
Implicit None
integer(8)::n,i,j,u,xa,ya,ha,hb,k,m
integer(8),allocatable::x(:),y(:),h(:)
	
	read *,n
	allocate(x(n),y(n),h(n))
	
	do i = 1,n
		read *,x(i),y(i),h(i)
	enddo
	
	i = 1
	do while(h(i) == 0)
		i = i +1
	enddo
	
	u = h(i);xa = x(i);ya = y(i)
	
	do k = 0,100
		do j = 0,100
			ha = abs(k - xa)+abs(j - ya) + u
			do m = 1,n
				hb = ha - abs(x(m) - k) - abs(y(m) - j)
				if(hb < 0) hb = 0
				if(hb /= h(m)) exit
				if(m == n)then
					print 101,k,j,ha
					stop
				endif
			enddo
		enddo
	enddo
	
101 format(i0,1xi0,1xi0)
end program main

Measured memory_bytes: 384
while 1:

    s1 = input().split('"')
    if s1 == ['.']:  # 強制終了
        break

    s2 = input().split('"')
    if len(s1) != len(s2):  # 長さが違う場合
        print("DIFFERENT")
        continue

    cnt = 0
    for i in range(len(s1)):
        if s1[i] != s2[i]:
            cnt += 1
            if i%2==0:
                cnt += 2
        else:
            i+=1

    if cnt == 0:
        print("IDENTICAL")  # 完全一致
    elif cnt == 1:
        print("CLOSE")  # 一つ違い
    else:
        print("DIFFERENT")  # それ以外


Measured memory_bytes: 5580
#include<stdio.h>
int main()
{
  int a,b=1,c;
  while(1){
    scanf("%d%d\n",&a,&b);
    if(a==0 && b==0){break;}
    else if(a>b)printf("%d %d\n",b,a);
    else printf("%d %d\n",a,b);
     
  }
  return 0;
}


Measured memory_bytes: 2032
n = int(input())
m2 = []
 
if n == 0:
    print(0)
    
while n != 0:
    if n % -2 != 0:
        m2.append('1')
        n = n // -2 + 1
    else:
        m2.append('0')
        n = n // -2
        
m2.reverse()
print(''.join(map(str, m2)))

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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;

#define Abs(x)((x) < 0 ? (x) * -1 : (x))

#define rep(x, y) for ((x) = 0; (x) < (y); (x)++)
#define repin(x, y) for ((x) = 0; (x) <= (y); (x)++)
#define nep(x, y) for ((x) = (y) - 1; 0 <= (x); (x)--)
#define nepi(x, y, z) for ((x) = (y) - 1; (z) <= (x); (x)--)
#define repi(x, y, z) for ((x) = (z); (x) < (y); (x)++)
#define repiin(x, y, z) for ((x) = (z); (x) <= (y); (x)++)
#define reps(x, y, z) for ((x) = 0; (x) < (y); (x) += (z))
#define repis(x, y, z, s) for ((x) = (z); (x) < (y); (x) += (s))
#define repit(x) for (__typeof((x).begin()) it = (x).begin(); it != (x).end(); it++)
#define nepit(x) for (__typeof((x).rbegin()) it = (x).rbegin(); it != (x).rend(); it++)

#define All(x) (x).begin(),(x).end()

#define Mem0(x) memset(x, 0, sizeof(x))
#define Mem1(x) memset(x, -1, sizeof(x))

#define Unique(v) v.resize(unique(All(v)) - v.begin())

#define peq(p0, p1)(p0.first == p1.first && p0.second == p1.second)

#define End '\n'
#define Out(x) cout<<(x)<<End
#define OutP(p, sep, end) cout<<p.first<<sep<<p.second<<end

template<typename T> inline bool Max(T &x, const T &y) { return x < y ? x = y, 1 : 0; }
template<typename T> inline bool Min(T &x, const T &y) { return x > y ? x = y, 1 : 0; }
template<typename T> using V = vector<T>;
template<typename T> using VV = V<V<T> >;

#define pb push_back
#define mp make_pair
#define X first
#define Y second
#define lb std::lower_bound
#define ub std::upper_bound

#define lbi(v, x) lb(All(v), (x))-v.begin()
#define ubi(v, x) ub(All(v), (x))-v.begin()

static const ll MOD = 1e9 + 7;
static const double PI = 3.141592653589793;

#define LOCAL 0

int main()
{
#if LOCAL
    freopen("in.txt", "r", stdin);
    freopen("out.txt", "w", stdout);
    freopen("debug.txt", "w", stderr);
#endif

    cin.tie(0);
    ios::sync_with_stdio(false);
	//std::cout.precision(18);

	string s;

	cin >> s;

	int n = 0;
  
  	int i;

	rep(i, 4) {
		if (s[i] == '+') n++;
		else n--;
	}

	Out(n);
	
	return 0;
}


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

int n, k;
int w[100000];

bool isCapable(int max) {
  int kk = k;
  int sum = 0;
  for (int i = 0; i < n; i++) {
    if (sum + w[i] > max) {
      kk--;
      if (kk == 0) return false;
      sum = w[i];
    } else {
      sum += w[i];
    }
  }
  return true;
}
int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);

  int max = 0;
  int sum = 0;

  cin >> n >> k;

  for (int i = 0; i < n; i++) {
    cin >> w[i];
    if (w[i] > max) max = w[i];
    sum += w[i];
  }

  int left = max;
  int right = sum;
  int mid;
  bool prev_result;
  while (true) {
    mid = (left + right) / 2;
    if (isCapable(mid)) {
      if (right - left <= 1) {
        if (prev_result) {
          cout << right << endl;
        } else {
          cout << left << endl;
        }
        break;
      }
      right = mid;
    } else {
      if (right - left <= 1) {
        if (prev_result) {
          cout << left << endl;
        } else {
          cout << right << endl;
        }
        break;
      }
      left = mid + 1;
    }
  }

  return 0;
}

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

long long Y[100005];
long long a, h;

long long getCount(long long sm)
{
    return max(0LL, (long long)ceil((0LL + h - sm) / (double)a));
}

int main()
{
    int n;
    long long x;
    long long bsum = 0, ans;
    cin>>n>>h;
    for(int i = 0; i < n; i++)
    {
        scanf("%lld %lld", &x , &Y[i]);
        a = max(a, x);
    }
    sort(Y, Y + n);
    bsum = 0;
    ans = getCount(bsum);
    for(int i = n - 1; i >= 0; i--)
    {
        bsum += Y[i];
        ans = min(ans, getCount(bsum) + (n - i));
    }
    cout<<ans;
    return 0;
}


Measured memory_bytes: 1024
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
const int INF = 1e9;
const ll LINF = 1e18;
inline ll gcd(ll a, ll b) { return b ? gcd(b, a%b) : a; }
inline ll lcm(ll a, ll b) { return a / gcd(a, b)*b; }
template<class S,class T> ostream& operator << (ostream& out,const pair<S,T>& o){ out << "(" << o.first << "," << o.second << ")"; return out; }
template<class T> ostream& operator << (ostream& out,const vector<T>& V){ for(int i = 0; i < V.size(); i++){ out << V[i]; if(i!=V.size()-1) out << " ";} return out; }
template<class T> ostream& operator << (ostream& out,const vector<vector<T> >& Mat){ for(int i = 0; i < Mat.size(); i++) { if(i != 0) out << endl; out << Mat[i];} return out; }
template<class S,class T> ostream& operator << (ostream& out,const map<S,T>& mp){ out << "{ "; for(auto it = mp.begin(); it != mp.end(); it++){ out << it->first << ":" << it->second; if(mp.size()-1 != distance(mp.begin(),it)) out << ", "; } out << " }"; return out; }
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);}
/*
 <url:https://atcoder.jp/contests/abc128/tasks/abc128_c>
 問題文============================================================
 =================================================================
 解説=============================================================
 全スイッチの状態を2^Nで全探索する。
 ================================================================
 */

template<class Type>
Type solve(Type res = Type()){
    int N,M; cin >> N >> M;
    vector<vector<int>> L(M);
    for(int i = 0; i < M;i++){
        int k; cin >> k;
        L[i] = vector<int>(k);
        for(int j = 0; j < k;j++){
            cin >> L[i][j];
            L[i][j]--;
        }
    }
    vector<int> p(M);
    for(auto& in:p) cin >> in;

    for(int s = 0; s < (1<<N);s++){
        bool ok = true;
        for(int i = 0; i < M;i++){
            int cnt = 0;
            for(auto v:L[i]){
                cnt += (s>>v)&1?1:0;
            }
            cnt %= 2;
            ok &= cnt == p[i];
        }
        res += ok;
    }

    return res;
}
int main(void) {
    cin.tie(0); ios_base::sync_with_stdio(false);
    // solve(0);
    cout << fixed << setprecision(15) << solve<ll>() << endl;
    return 0;
}


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

#define i64 long long int
#define ran 202202

int n;
int a[ran];

int cmp(int a, int b){
	return a>b;
}

int main() {
	scanf("%d", &n);
	
	i64 ans = 0LL;
	for(int i=0;i<n;i++) scanf("%d", &a[i]);
	sort(a, a+n, cmp);
	for(int i=1;i<n;i++)
		ans += a[i/2];
	printf("%lld\n", ans);
	
	return 0;
}

Measured memory_bytes: 4608
#include <cstdio>
int main(){
    int n,m;
    while(1){
        scanf("%d %d",&n,&m);
        if(n==0 && m == 0) break;
        for(int i=0;i<n;i++){
            for(int j=0;j<m;j++){
                printf("#");
            }
            printf("\n");
        }
        printf("\n");
        
    }
    return 0;
}


Measured memory_bytes: 2684
#include <stdio.h>
#include <string.h>
int equal(char *t,char *p,int i,int plen){
  int j;
  for(j=0;j<plen;j++){
    if(t[i+j]!=p[j]) return 0;
  }
   
  return 1;
}
int main(){
  char t[1000];
  char p[1000];
  int i,j;
  int tlen;
  int plen;
  scanf("%s",t);
  scanf("%s",p);
  tlen=strlen(t);
  plen=strlen(p);
  for(i=0;i<tlen;i++){
    if(equal(t,p,i,plen))printf("%d\n",i);
     
  }
  return 0;
}


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

#define DUMP(x) cerr << #x << "=" << x << endl
#define DUMP2(x, y) cerr<<"("<<#x<<", "<<#y<<") = ("<<x<<", "<<y<<")"<< endl
#define BINARY(x) static_cast<bitset<16> >(x)

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

#define in_range(x, y, w, h) (0<=(int)(x) && (int)(x)<(int)(w) && 0<=(int)(y) && (int)(y)<(int)(h))
#define ALL(a) (a).begin(),(a).end()

typedef long long ll;
const int INF   = 1e9;
const ll  INFLL = 1e18;
typedef pair<int, int> PII;
int dx[4]={0, -1, 1, 0}, dy[4]={-1, 0, 0, 1};

int main()
{
    ios::sync_with_stdio(false);
    int N; cin >> N;
    map<int, int> cnt_D;
    rep(i, N) {
        int D; cin >> D;
        cnt_D[D]++;
    }

    int M; cin >> M;
    map<int, int> cnt_T;
    rep(i, M) {
        int T; cin >> T;
        cnt_T[T]++;
    }

    bool ok = true;
    for (auto tmp : cnt_T) {
        if (tmp.second > cnt_D[tmp.first]) ok = false;
    }
    cout << (ok ? "YES" : "NO") << endl;
}

Measured memory_bytes: 19072
/*
    Problem 16
    https://atcoder.jp/contests/abc150/tasks/abc150_c
*/
#include <bits/stdc++.h>
using namespace std;
/* typedef */
typedef long long ll;
typedef pair<int, int> pii;
/* constant */
const int INF = 1 << 30;
const ll LINF = 1LL << 50;
const int NIL = -1;
const int MAX = 10000;
const int mod = 1000000007;
const double pi = 3.141592653589;
/* global variables */
/* function */
/* main */
int main(){
    int N;
    cin >> N;
    vector<int> p(N), q(N);
    for (int i = 0; i < N; i++) cin >> p[i];
    for (int i = 0; i < N; i++) cin >> q[i];

    vector<int> v(N);
    int a, b;
    iota(v.begin(), v.end(), 1);
    int cnt = 0;
    do {
        cnt++;
        if (v == p) a = cnt;
        if (v == q) b = cnt;
    } while (next_permutation(v.begin(), v.end()));
    cout << abs(a - b) << '\n';
}

Measured memory_bytes: 3620
//ITP 1_10_D

#include<iostream>
#include<cmath>
using namespace std;

int main(){
    int i,n;
    cin >> n;
    int x[n],y[n];
    for(i=0; i<n; i++) cin >> x[i]; 
    for(i=0; i<n; i++) cin >> y[i];
    double mnht=0,eucli2=0,eucli3=0,chbyshv=0;
    
    for(i=0; i<n; i++){
        mnht += abs(x[i]-y[i]);
        if(chbyshv<abs(x[i]-y[i]))chbyshv = abs(x[i]-y[i]);
    }
    
    for(i=0; i<n; i++)eucli2 += pow(abs(x[i]-y[i]),2);
    for(i=0; i<n; i++)eucli3 += pow(abs(x[i]-y[i]),3);
    
    printf("%.5f\n%.5f\n%.5f\n%.5f\n",mnht,sqrt(eucli2),cbrt(eucli3),chbyshv);
    return 0;
}


Measured memory_bytes: 3400
#include<iostream>
using namespace std;
int main() {
	int N;
	cin >> N;
	unsigned long long T[N], A[N];
	unsigned long long maxT = 0, maxA = 0;
	int idxT, idxA;
	for (int i = 0; i < N; i++) {
		cin >> T[i];
		if (T[i] > maxT) {
			idxT = i;
		}
		maxT = max(maxT, T[i]);
	}
	for (int i = 0; i < N; i++) {
		cin >> A[i];
		maxA = A[0];
		if (A[i] == maxA) {
			idxA = i;
		}
	}
	if (maxA != maxT || idxT > idxA) {
		cout << 0;
		return 0;
	}
	unsigned long long result = 1;
	unsigned long long pre = 0;
	int idx = 0;
	while (true) {
		if (pre == T[idx]) {
			result = T[idx] * result % 1000000007;
		} else {
			pre = T[idx];
		}
		if (maxT == T[idx]) {
			break;
		}
		idx++;
	}
	pre = 0;
	for (int i = N - 1; i > idx; i--) {
		if (pre == A[i]) {
			result = A[i] * result % 1000000007;
		} else {
			pre = A[i];
		}
	}
	cout << result;
	return 0;
}

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

int main() {
    long long X,Y;
    cin >> X;
    Y=X;
    int a=0,b=0;
    while (Y>=500){
        a++;
        Y-=500;
    }
    while (Y>=5){
        b++;
        Y-=5;
    }
    cout << 1000*a+5*b << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<string>
#include<climits>
#include<algorithm>
#include<cmath>

int main(){
	int n, k;
	std::string s;
	std::cin>>n>>k;
	std::cin>>s;

	if(s[k-1]=='A')
		s[k-1]='a';

	if(s[k-1]=='B')
		s[k-1]='b';

	if(s[k-1]=='C')
		s[k-1]='c';

	std::cout<<s<<std::endl;

	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
template<class T> inline bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template<class T> inline bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
const long long INF = 1LL << 60;
bool mem[100010];
int memo[100010];
int N;
int h[100010];
int DFS(int i) {
  ll ans;
    if(mem[i]==true){
        ans= memo[i];
    }
    else if(i==0){
      	ans=0;
      	mem[0]=true;
    }
  else if(i==1){
    	ans=abs(h[1]-h[0]);
   		 memo[1]=ans;
    	mem[1]=true;
  }
    else{
        ans=min(memo[i-2]+abs(h[i]-h[i-2]),memo[i-1]+abs(h[i]-h[i-1]));
        memo[i]=ans;
		mem[i]=true;
    }
  return ans;
}
int main(void) {
  	cin>>N;
    mem[0]=true;
    rep(i, N) {
        cin >> h[i];
        }
  	vector<int>ans(N);
  		rep(i,N){
          ans[i]=DFS(i);
         if(i==N-1){
			cout<<ans[i]<<endl;
         }
        }
}


Measured memory_bytes: 4496
import sys
def input():
    return sys.stdin.readline()[:-1]
H,W=map(int,input().split())
S=[input() for i in range(H)]
y=[[0]*W for i in range(H)]
t=[[0]*W for i in range(H)]
for i,s in enumerate(S):
    n=0
    c=0
    for j in range(W):
        if s[j]==".":
            c+=1
        else:
            for k in range(n,j):
                y[i][k]=c
            c=0
            n=j+1
    for k in range(n,W):
        y[i][k]=c
for i in range(W):
    n=0
    c=0
    for j in range(H):
        if S[j][i]==".":
            c+=1
        else:
            for k in range(n,j):
                t[k][i]=c
            c=0
            n=j+1
    for k in range(n,H):
        t[k][i]=c
a=0
for i in range(H):
    for j in range(W):
        if a<y[i][j]+t[i][j]:
            a=y[i][j]+t[i][j]
print(a-1)

Measured memory_bytes: 119772
H, W = map(int, raw_input().split())
N = int(raw_input())
A = map(int, raw_input().split())

X = []
for i, a in enumerate(A):
    X += [str(i+1)] * a

for h in range(H):
    if h % 2 == 0:
        print " ".join(X[W*h:W*(h+1)])
    else:
        print " ".join(X[W*h:W*(h+1)][::-1])


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

#define FOR(i, a, b) for (int i = (a); i < (b); i++)

typedef long long ll;

char GetOffset(const char& c, const int& offset) {
  if (c + offset > 'Z') {
    return c + offset - 26;
  }
  return c + offset;
}

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

  char chars[10001];
  str.copy(chars, 2, 1);
  FOR(i, 0, str.size()) {
    char c = GetOffset(str[i], n);
    cout << c;
  }
  cout << endl;

  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 a = sc.nextInt();
    int b = sc.nextInt();
    int c = sc.nextInt();
    int d = c - (a - b);
    if(d < 0){
      System.out.println(0);
    }else{
      System.out.println(d);
    }
  }
}

Measured memory_bytes: 21844
N = int(input())
A = list(map(int,input().split()))
import numpy as np 
A.sort()

a1 = A[-1]
ref = a1/2
cmp = np.abs(ref - A[0])
a2 = A[0]
for a in A[1:-1]:
    if cmp > np.abs(ref - a):
        a2 = a
        cmp = np.abs(ref-a)
print(a1,a2)


Measured memory_bytes: 17612
#include<iostream>
#include<algorithm>
#include<math.h>

using namespace std;

int main(void){
    int x;
    cin >> x;

    int ans = 1;

    for(int i = 1; i <= x; i++){
        for(int p = 2; p <= 10; p++){
            int square = pow(i, p);
            if(square >= ans && square <= x){
                ans = square;
            }
        }
    }
    cout << ans << endl;

}

Measured memory_bytes: 384
#include <iostream>
#include <vector>
#include <string>
#include <cmath>
#include <algorithm>

using namespace std;
#define inf 99999999999;
int root1[200001];
int root2[200001];
int root3[200001];
int ans[200001];
int find(int x){
	if(x!=root1[x]){
		root1[x] = find(root1[x]);
	}
	return root1[x];
}
void union_set(int x,int y){
	x = find(x);
	y = find(y);
	if(x!=y){
		root1[x]=y;
	}
	return ;
}
int find2(int x){
	if(x!=root2[x]){
		root2[x] = find2(root2[x]);
	}
	return root2[x];
}
void union_set2(int x,int y){
	x = find2(x);
	y = find2(y);
	if(x!=y){
		root2[x]=y;
	}
	return ;
}
int find3(int x){
	if(x!=root3[x]){
		root3[x] = find3(root3[x]);
	}
	return root3[x];
}
void union_set3(int x,int y){
	x = find3(x);
	y = find3(y);
	if(x!=y){
		ans[y]= ans[x]+ans[y];
		ans[x]= ans[y];
		root3[x]=y;
	}
	return ;
}
int main(){
	for(int i=0;i<=200000;i++){
		root1[i]=i;
		root2[i]=i;
		root3[i]=i;
	}
	for(int i=0;i<=200000;i++){
		ans[i]=1;
	}
	int n,k,l,p,q;
	cin >> n >> k >> l;
	for(int i=0;i<k;i++){
		cin >> p >> q;
		union_set(p,q);
	}
	for(int i=0;i<l;i++){
		cin >> p >> q;
		union_set2(p,q);
	}
	vector<pair<pair<int,int>,int> > v;
	for(int i=1;i<=n;i++){
		v.push_back(make_pair(make_pair(find(i),find2(i)),i));
	}
	sort(v.begin(),v.end());
	for(int i=0;i<n-1;i++){
		if(v[i].first.first==v[i+1].first.first&&v[i].first.second==v[i+1].first.second){
			union_set3(v[i].second,v[i+1].second);
		}
	}
	for(int i=1;i<=n-1;i++){
		cout << ans[find3(i)] << " ";
	}
	cout << ans[find3(n)] << endl;
	return 0;
}

Measured memory_bytes: 6768
#include<bits/stdc++.h>
#define fasterthanlight ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL)
#define test int T; cin>>T; while(T--)
#define endl "\n"
#define int long long
#define vi vector<int>
#define pb push_back
#define mod 1000000007
#define MAX 1e9
#define MIN -1e9
#define hi "visited\n" //sasta debugging
using namespace std;

//author::@whohet-->Het Patel
//anscii A-65 Z-90   a-97 z-112
//vector<int>v;
//vector<char>v;
//char arr[100005];
//int a[26];
//a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,t,
signed main()
{
    fasterthanlight;
    int n; cin >> n; 
    cout<<n+(n*n)+(n*n*n);

    //cout << "\n\n"<<"Time elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " seconds.\n";
    return 0;
}


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

int main(){
    int N, K;
    cin >> N >> K;
    vector<int> A(N);

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

    for(int i = K; i < A.size(); i++){
        if((double) A[i] / A[i - K] > 1){
            cout << "Yes" << endl;
        }
        else{
            cout << "No" << endl;
        }
    }
}

Measured memory_bytes: 3984
#include <stdio.h>

int main()
{
	int N,M,A,homework = 0;
	scanf("%d %d",&N,&M);
	for (int i = 0;i < M;i++){
		scanf("%d",&A);
		homework += A;
	}

	if (homework <= N){
		printf("%d\n",N - homework);
	}else{
		printf("-1\n");
	}
	return 0;
}


Measured memory_bytes: 1724
using System;

namespace ITP1_10_A {
    class Program {
        static void Main(string[] args) {
            string[] s = Console.ReadLine().Split(' ');
            double x1 = double.Parse(s[0]), y1 = double.Parse(s[1]),
                   x2 = double.Parse(s[2]), y2 = double.Parse(s[3]);
            double distance = Math.Sqrt((x2 - x1)*(x2 - x1) + (y2 - y1)*(y2 - y1));
            Console.WriteLine(distance);
        }
    }
}

Measured memory_bytes: 9228
#include<bits/stdc++.h>
using namespace std;
//#define int long long
#define fo(a,b) for(int a=0;a<b;a++)
#define Sort(a) sort(a.begin(),a.end())
#define rev(a) reverse(a.begin(),a.end())
#define fi first
#define se second
#define co(a) cout<<a<<endl
#define sz size()
#define bgn begin()
#define en end()
#define pb(a) push_back(a)
#define pop pop_back
#define V vector
#define P pair
#define V2(a,b,c) V<V<int>> a(b,V<int>(c))
#define V2a(a,b,c,d) V<V<int>> a(b,V<int>(c,d))
#define incin(a) int a; cin>>a
//#define min min<int>
//#define max max<int>
template<class T>
 void cou(vector<vector<T>> a){
  int b=a.size();
  int c=a[0].size();
  fo(i,b){
    fo(j,c){
      cout<<a[i][j];
      if(j==c-1)
        cout<<endl;
      else
        cout<<' ';
    }
  }
}
/*template<>
 void cou(vector<vector<char>> a){
  int b=a.size();
  int c=a[0].size();
  fo(i,b){
    fo(j,c){
      cout<<a[i][j];
      if(j==c-1)
        cout<<endl;
      else
        cout<<' ';
    }
  }
}*/
 int wari(int a,int b) {
   if(a%b==0)
     return a/b;
   else
     return a/b+1;
 }
 int keta(int a){
  double b=a;
  b=log10(b);
  int c=b;
  return c+1;
 }
 int souwa(int a){
  return a*(a+1)/2;
 }
 int lcm(int a,int b){
  int d=a,e=b,f;
  if(a<b)
    swap(a,b);
  int c,m=1;
  while(m){
    c=a%b;
    if(c==0){
       f=b;
      m--;
    }
    else{
      a=b;
      b=c;
 }
  }
  return d*e/f;
    }
  int gcm(int a,int b){
      int d=a,e=b,f;
  if(a<b)
    swap(a,b);
  int c,m=1;
  while(m){
    c=a%b;
    if(c==0){
       f=b;
      m--;
    }
    else{
      a=b;
      b=c;
 }
  }
  return f;
  }
 bool prime(int a){
   if(a<2)
     return false;
   else if(a==2)
     return true;
   else if(a%2==0)
     return false;
   double b=sqrt(a);
    for(int i=3;i<=b;i+=2){
      if(a%i==0){
        return false;
      }
    }
   return true;
 }
struct Union{
  vector<int> par;
  Union(int n){
	par= vector<int>(n, -1);
  }
  int find(int x){
    if(par[x]<0)
      return x;
    else
      return par[x]=find(par[x]);
  }
  bool same(int a,int b){
    return find(a)==find(b);
  }
  int Size(int a){
    return -par[find(a)];
  }
  void unite(int a,int b){
    a=find(a);
    b=find(b);
    if(a==b)
      return;
    if(Size(b)>Size(a))
      swap<int>(a,b);
    par[a]+=par[b];
    par[b]=a;
  }
};
int ketas(int a){
  string b=to_string(a);
  int c=0;
  fo(i,keta(a)){
    c+=b[i]-'0';
  }
  return c;
}
/*struct aa{
	vector<int> gt;
  aa(int n){
	gt= vector<int>(n, 1);
  }
	void c(V<int> d,int b){
	if(d[b]==0){
		gt[d[b]-1]++;
		gt[gt.sz-1]++;
	}
	else{
		gt[d[b]-1]++;
		c(d,d[d[b]]-1);
	}
}
void cok(int a){
	cout<<gt[a-1]<<endl;
	fo(i,a-1)
	cout<<gt[i]<<endl;
}
};
*/
signed main(){
	int a;
	cin>>a;
	cout<<1110-a<<endl;
}

Measured memory_bytes: 256
N=int(input())
A=list(map(int,input().split()))
ans=1
OK=True
for i in range(0,N):
    ans*=A[i]
    if ans>10**18:
        OK=False
        break
if 0 in A:
    OK=True
    ans=0
if OK:
    print(ans)
else:
    print(-1)

Measured memory_bytes: 84752
import java.util.*;

class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        long[] A = new long[N+1];
        for(int i=1;i<=N;i++) A[i]=sc.nextLong();
        long[] sum = new long[N+1];
        for(int i=1;i<=N;i++) sum[i] = sum[i-1]+A[i];
        HashMap<Long,Integer> dic = new HashMap<>();
        for(int i=0;i<=N;i++){
            if(dic.containsKey(sum[i])) dic.put(sum[i],dic.get(sum[i])+1);
            else dic.put(sum[i],1);
        }
        long ans = 0;
        for(int i=0;i<=N;i++){
            if(dic.get(sum[i])==1) continue;
            ans += dic.get(sum[i])-1;
            dic.put(sum[i],dic.get(sum[i])-1);
        }
        System.out.println(ans);
    }
}


Measured memory_bytes: 95304
N=gets.to_i
h=gets.chomp.split.map(&:to_i)
if N==1
  puts "Yes"
  exit
end

(N-1).downto(1) do |i|
  if h[i]+1 < h[i-1]
    puts "No"
    exit
  elsif h[i]+1 == h[i-1]
    h[i-1] -= 1
  end
end
puts "Yes"

Measured memory_bytes: 9732
#define _USE_MATH_DEFINES
#include <iostream>
#include <complex>
#include <algorithm>
#include <vector>
#include <stack>
#include <string>
#include <queue>
#include <cmath>
#include <math.h>
#include <numeric>
#include <list>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <climits>
#include <set>
#include <memory.h>
#include <memory>
#include <cstdio>
#include <cstdlib>
#include <cctype>
#include <cassert>
#include <map>
#include <cassert>
#include <time.h>
#include <ctime>

using namespace std;

typedef complex<double> xy_t;
typedef pair<xy_t, xy_t> line;
typedef vector<xy_t> polygon;
typedef long long ll;
typedef pair<int, int> P;
typedef pair<int , P> PP;
typedef pair<int, string> Ps;
typedef vector<int> vec;
typedef vector<vec> mat;
const int INF = 1 << 29;
const double EPS = 1e-10;
const double PI = 3.1415926535897932384626433832795;
const int CLK = CLOCKS_PER_SEC;

#define rep(i, n) for(int i = 0; i < n; i++)
#define rep2(i, m, n) for(int i = m; i < n; i++)
#define repD(i, n) for(int i = n; i >= 0; i--)

bool fail[1000];
int nxt[1000];

bool check(string s, int n){
	if(n % 3 == 0 && n % 5 == 0) return s == "FizzBuzz";
	if(n % 3 == 0) return s == "Fizz";
	if(n % 5 == 0) return s == "Buzz";
	if(!isdigit(s[0])) return false;
	return n == atoi(s.c_str());
}

int main(){
	int m, n;
	int rest;
	string s;
	while(cin >> m >> n && (m || n)){
		getline(cin, s);
		memset(fail, false, sizeof(fail));
		rep(i, m){
			nxt[i] = (i+1)%m;
		}
		int pos = m-1;
		rest = m;
		rep(i, n){
			getline(cin, s);
			
			if(rest == 1) continue;
			if(!check(s, i+1)){
				int tmp = nxt[pos];
				nxt[pos] = nxt[tmp];
				fail[tmp] = true;
				rest--;
			}else{
				pos = nxt[pos];
			}
		}
		
		vector<int> res;
		rep(i, m) if(!fail[i]) res.push_back(i+1);
		rep(i, (int)res.size()){
			if(i != 0) cout << " ";
			cout << res[i];
		}
		cout << endl;
	}
	return 0;
}

Measured memory_bytes: 0
#include<bits/stdc++.h>
int fuck;
std::string str,value;

int main(){
    std::cin >> value;
    transform(value.begin(), value.end(), value.begin(), tolower);
    while(1){
        std::cin >> str;
        if(str == "END_OF_TEXT") break;
        transform(str.begin(), str.end(), str.begin(), tolower);
        if(str == value)fuck++;
    }

    std::cout << fuck << std::endl;
    return 0;
}

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

public class Main{
    public static void main(String[] args) {
        FastReader fs=new FastReader();
        PrintWriter out=new PrintWriter(System.out);
        int t=1;
        //t=fs.nextInt();
        while(t-->0){
            solve(out,fs);
        }
        out.close();
    }
    public static void solve(PrintWriter out,FastReader fs){
        int n=fs.nextInt();
        long a[]=fs.nextLongArray(n);
        long ans=0;
        for(int i=0;i<n;i++){
            for(int j=i+1;j<n;j++){
                for(int k=j+1;k<n;k++){
                    long l1=a[i],l2=a[j],l3=a[k];
                    if(l1==l2||l2==l3||l1==l3)continue;
                    if(l1+l2<=l3||l1+l3<=l2||l2+l3<=l1)continue;
                    //System.out.println(i+" "+j+" "+k);
                    ans++;
                }
            }
        }
        out.println(ans);
    }
}
class FastReader{
    BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
    StringTokenizer st=new StringTokenizer("");
    String next(){
        while(!st.hasMoreTokens()){
            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());
    }
    int[] nextIntArray(int n){
        int a[]=new int[n];
        for(int i=0;i<n;i++)a[i]=nextInt();
        return a;
    }
    long[] nextLongArray(int n){
        long a[]=new long[n];
        for(int i=0;i<n;i++)a[i]=nextInt();
        return a;
    }
    char[] nextCharArray(){
        char a[]=next().toCharArray();
        return a;
    }
}

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

int main(){
  int n,k;
  cin >>n >>k;
  int v = 1;
  for(int i = 1; i<=n;i++){
    if(v>k) v += k;
    else v *= 2;
  }
  cout << v << endl;
  return 0;
}

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

int main() {
  int N;
  cin >> N;
  vector<int>a(N);
  for(int i=0; i<N; i++)cin >> a.at(i);
  
  sort(a.begin(), a.end());
  
  int ans =0;
  for(int i=0; i<N; i++)ans += a.at(i)-1;
  
  cout << ans << endl;
}


Measured memory_bytes: 3644
a, b, c, d = map(int, input().split())
if b >= 0 and c >= 0:
    print(b*d)
elif b <= 0 and c >= 0:
    print(b*c)
elif a >= 0 and d >= 0:
    print(b*d)
elif b <= 0 and d >= 0:
    print(a*c)
elif a >= 0 and d <= 0:
    print(a*d)
elif a <= 0 and d <= 0:
    print(a*c)
else:
    print(max(a*c, b*d ))

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

using namespace std;

#define debug(n) cerr << #n << ':' << n << endl;
#define dline    cerr << __LINE__ << endl;

using ll = long long;
template<class T, class U> using P = pair<T,U>;
template<class T> using Heap = priority_queue<T>;
template<class T> using heaP = priority_queue<T,vector<T>,greater<T>>;
template<class T,class U> using umap = unordered_map<T,U>;
template<class T> using uset = unordered_set<T>;

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

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

template<class T, size_t N, class U>
void Fill(T (&a)[N], const U&v){
    fill((U*)a,(U*)(a+N),v);
}

template<class T>
istream& operator >> (istream&is, vector<T>&v){
  for(auto&e:v)is >> e;
  return is;
}

int main(){
  int a,b;cin >> a >> b;
  cout << a*b<< endl;
  return 0;
}


Measured memory_bytes: 3636
N, C, K = map(int, input().split())
T = [int(input()) for _ in range(N)]
T.sort()

ans = 0
tmp = 0 #現在バス内で待っている人
time = 0 #次のバスの発車時間
for i in range(N):
    if tmp == 0: #バスの車内で待っている人がいないとき
        tmp += 1
        time = T[i] + K #次のバスの発車時間
        continue
    if tmp == C: #もう乗れないとき
        ans += 1
        tmp = 1
        time = T[i] + K
        continue
    if tmp < C: #まだ乗れるとき
        if T[i] > time: #次に来た乗客の時間が発車時刻より遅い時
            ans += 1
            tmp = 1
            time = T[i] + K
            continue
        else: #時間に間に合っている時
            tmp += 1

if tmp > 0:
    ans += 1

print (ans)




Measured memory_bytes: 7384
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.StringTokenizer;




public class Main{

	public static void main(String[] args) throws IOException, InterruptedException {
		
		Scanner sc = new Scanner(System.in);
		PrintWriter out = new PrintWriter(System.out);
		
		int n = sc.nextInt();
		int[] a = new int[n];
		for (int i = 0; i < n; i++) {
			a[i]= sc.nextInt(); 
		}
		
		Arrays.sort(a);
		int mid = a[(n-1)/2];
		int midone = a[((n-1)/2)+1];
		
		out.println(midone-mid);
		
		out.flush();

	}
	

	
	

	
}
class Scanner {
	StringTokenizer st;
	BufferedReader br;

	public Scanner(InputStream system) {
		br = new BufferedReader(new InputStreamReader(system));
	}

	public String next() throws IOException {
		while (st == null || !st.hasMoreTokens())
			st = new StringTokenizer(br.readLine());
		return st.nextToken();
	}

	public String nextLine() throws IOException {
		return br.readLine();
	}

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

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

	public char nextChar() throws IOException {
		return next().charAt(0);
	}

	public Long nextLong() throws IOException {
		return Long.parseLong(next());
	}

	public boolean ready() throws IOException {
		return br.ready();
	}

	public void waitForInput() throws InterruptedException {
		Thread.sleep(3000);
	}


}

Measured memory_bytes: 35564
FHY = int(input())
OHY = int(input())
FTY = int(input())
X = int(input())
a = X // 500
b = X // 100
c = X // 50
l1 = min(FHY,a)
l2 = min(OHY,b)
l3 = min(FTY,c)

count = 0

for i in range(l1+1):
    for j in range(l2+1):
        for k in range(l3+1):
            temp = (i * 500) + (j * 100) + (k *50)
            if temp == X:
                count += 1
            
print(count)

Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
using Int = long long;
//BEGIN CUT HERE
struct PersistentUnionFind{
  using T = pair<int, int>;
  int n;
  vector<int> r,p;
  stack<T> st;
  PersistentUnionFind(){}
  PersistentUnionFind(int sz):n(sz),r(sz,1),p(sz,0){iota(p.begin(),p.end(),0);}
  int find(int x){
    return x==p[x]?p[x]:find(p[x]);
  }
  bool same(int x,int y){
    return find(x)==find(y);
  }
  void unite(int x,int y){
    x=find(x);y=find(y);
    st.emplace(-1,-1);
    if(x==y) return;
    if(r[x]<r[y]) swap(x,y);
    r[x]+=r[y];
    p[y]=x;
    st.top()=T(x,y);
  }
  void undo(int t=1){
    for(int i=0;i<t;i++){
      int x,y;
      tie(x,y)=st.top();st.pop();
      if(x<0) continue;
      r[x]-=r[y];
      p[y]=y;
    }
  }
};

struct DynamicConnectivity{
  using edge = pair<int, int>;
  using range = edge;
  
  int n,q;
  PersistentUnionFind puf;
  vector<vector<edge> > edges;
  vector<pair<range, edge> > prc;
  map<edge, int> cnt,app;
  
  DynamicConnectivity(){}
  DynamicConnectivity(int n,int q_):n(n),q(1),puf(n){
    while(q<q_) q<<=1;
    edges.resize(q*2-1);
  }
  
  void insert(int t,int u,int v){
    edge e=minmax(u,v);
    if(cnt[e]++==0) app[e]=t;
  }
  
  void erase(int t,int u,int v){
    edge e=minmax(u,v);
    if(--cnt[e]==0) prc.emplace_back(range(app[e],t),e);
  }
  
  void add(int a,int b,const edge &e,int k,int l,int r){
    if(r<=a||b<=l) return;
    if(a<=l&&r<=b){
      edges[k].emplace_back(e);
      return;
    }
    int m=(l+r)>>1;
    add(a,b,e,k*2+1,l,m);
    add(a,b,e,k*2+2,m,r);
  }
  
  void add(range &r,const edge &e){
    add(r.first,r.second,e,0,0,q);
  }
  
  void build(){
    for(auto &e:cnt){
      if(!e.second) continue;
      prc.emplace_back(range(app[e.first],q),e.first);
    }
    for(auto &s:prc)
      add(s.first,s.second);
  }

  void exec(function<void(int)> &f,int k=0){
    for(auto &e:edges[k])
      puf.unite(e.first,e.second);

    if(k<q-1){
      exec(f,k*2+1);
      exec(f,k*2+2);
    }else{
      int x=k-(q-1);
      f(x);
    }
    
    puf.undo(edges[k].size()); 
  }
};
//END CUT HERE

signed main(){
  int n,q;
  cin>>n>>q;
  DynamicConnectivity dc(n,q);
  vector<int> t(q),u(q),v(q);
  for(int i=0;i<q;i++){
    cin>>t[i]>>u[i]>>v[i];
    if(t[i]==1) dc.insert(i,u[i],v[i]);
    if(t[i]==2) dc.erase(i,u[i],v[i]);
  }
  dc.build();
  function<void(int)> f=[&](int x){
    if(x>=q||t[x]!=3) return;
    cout<<(dc.puf.same(u[x],v[x])?"YES":"NO")<<endl;
  };
  dc.exec(f);
  return 0;
}
/*
  verified on 2018/01/07
  http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=2235
*/



Measured memory_bytes: 14956
program main
    implicit none
    integer N, X, i, counter, m, m_min
    counter = 0
    m_min = 1001
    read *, N, X
    do i = 1,N
        read *, m
        X = X - m
        counter = counter + 1
        if(m_min > m) then
            m_min = m
        endif
    enddo
    do while (X >= m_min)
        X = X - m_min
        counter = counter + 1
    enddo
    print *, counter
end program main


Measured memory_bytes: 384
// inputに入力データ全体が入る
function Main(input) {
	// 1行目がinput[0], 2行目がinput[1], …に入る
    input = input.split("\n");
    // 数値の配列を作る
    const numList0 = input[0].split(' ').map(x => parseInt(x, 10));
    const N = numList0[0];
    const AList = input[1].split(' ').map(x => parseInt(x, 10));
    const BList = input[2].split(' ').map(x => parseInt(x, 10));

    var left = AList[0];
    var total = 0;
    for (var i = 0; i < N; i++) {
        var nextA = AList[i + 1];
        var B = BList[i];

        if (left >= B) {
            total += B;
          	left = nextA;
            continue;
        } 
        
        var sum = left + nextA;
        if (sum <= B) {
            total += sum;
            left = 0;
        } else {
            var sub = sum - B;
            total += B;
            left = sub;
        }
    }

    console.log(total);
}
 
Main(require("fs").readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 30764