akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<iomanip>
#include<cmath>
#include<string>
#include<cstring>
#include<vector>
#include<list>
#include<algorithm>
#include<map>
#include<set>
#include<queue>
#include<stack>
using namespace std;
typedef long long ll;
#define fi first
#define se second
#define mp make_pair
#define rep(i, n) for(int i=0;i<n;++i)
#define rrep(i, n) for(int i=n;i>=0;--i)
const int inf=1e9+7;
const ll mod=1e9+7;
const ll mod1=998244353;
const ll big=1e18;
const double PI=2*asin(1);

int main() {
  ll N;
  cin>>N;
  ll A[N], B[N];
  ll sum = 0;
  for(ll i=0;i<N;++i) {
    cin>>A[i]>>B[i];
    sum += A[i];
  }
  ll ans = inf;
  for(ll i=0;i<N;++i) {
    if(A[i]<=B[i]) continue;
    ans = min(ans, B[i]);
  }
  if(ans==inf) cout<<0<<endl;
  else cout<<sum-ans<<endl;
}



Measured memory_bytes: 3920
#include <unistd.h>

void get_nums(int *array, int count)
{
    char c;
    int num;

    c = 0;
    while (c != 10)
    {
        if (read(0, &c, 1) == -1)
            return ;
        if (c != 32)
        {
            num = 0;
            while ('0' <= c && c <= '9')
            {
                num = num * 10 + c - '0';
                if (read(0, &c, 1) == 0)
                {
                    array[count++] = num;
                    return ;                    
                }
            }
            array[count++] = num;
        }
    }  
}

void get_stirngs(char *s, int i)
{
    char c;

    c = 0;
    while (c != 10)
    {
        if (read(0, &c, 1) == -1)
            return ;
        while (31 < c && c < 127)
        {
            s[i++] = c;
            if (read(0, &c, 1) == 0)
            {
                s[i] = 0;
                return ;                    
            }
        }
        s[i] = 0;
    }  
}

void get_ans(int x, int y, int i, int j)
{
    char s[x + 1];
    
    while (++j < y + 2)
    {
        if (0 < j  && j <= y)
            get_stirngs(s, 0);
        i = -1;
        while (++i < x + 2)
        {
            if (0 < j  && j <= y && 0 < i && i <= x)
                write(1, &s[i - 1], 1);
            else
                write(1, "#", 1);
        }
        write(1, "\n", 1);
    }
}

int main(void){
    int num[2];
    
    get_nums(num, 0);
    get_ans(num[1],num[0], -1, -1);
    return (0);
}


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

using namespace std;

/* macro */
#define rep(i,a,b) for(int i=a;i<b;i++)
#define revrep(i,a,b) for(int i = a; i > b; i--)
#define int long long
#define exist(s,e) ((s).find(e)!=(s).end())
#define all(v) (v).begin(), (v).end()
#define each(s,itr) for(auto (itr) = s.begin(); (itr) != s.end(); (itr)++)
#define sum(v) accumulate(all(v), (0LL))
#define isin(a, b, c) (b <= a && a <= c)
#define println cout << "\n";
#define sz(v) (int)v.size()
#define bin(x) static_cast<bitset<16> >(x)



/* alias */
template<class T> using vec = vector<T>;
typedef vector<int> vi;
typedef pair<int, int> pi;
typedef tuple<int, int, int> ti;
typedef map<int, int> mi;
typedef set<int> si;


/* constant */
const int inf = 1LL << 62;
const int mod = 1e9 + 7;
const int dx[8]={1,0,-1,0,-1,1,-1,1};
const int dy[8]={0,1,0,-1,-1,-1,1,1};
const string alphabet = "abcdefghijklmnopqrstuvwxyz";

/* io_method */
int input(){int tmp;cin >> tmp;return tmp;}
string raw_input(){string tmp;cin >> tmp;return tmp;}
template<class T> void printx(T n){cout << n;}
template<class T, class U> void printx(pair<T, U> p){cout << "(" << p.first << "," << p.second << ")";}
template<class T, class U, class V> void printx(tuple<T, U, V> t){cout << "{" << get<0>(t) << "," << get<1>(t) <<"," << get<2>(t) << "}" << endl;}
template<class T> void printx(vector<T> v){cout << "{";rep(i,0,v.size()){printx(v[i]);if(i != v.size()-1)printx(",");}cout << "}";}
template<class T> void print(T n){printx(n);cout << endl;}
template<class T> void print(set<T> s){cout << "{";each(s, e){if(e != s.begin()) printx(",");printx(*e);}cout << "}" << endl;}
template<class T, class U> void print(map<T, U> mp){cout << "{";each(mp, e){cout << "(" << e -> first << "," << e -> second << ")";}cout << "}" << endl;}
template<class T> void printans(vec<T> v){rep(i,0,sz(v)){cout << v[i] << (i == sz(v) - 1 ? "" : " ");}cout << endl;}


/* general_method */
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
template<class T>T cut(T &a, int l, int r){return T(a.begin()+l, a.begin()+r);}

/* main */


int n;
vector<int> height;

void in(){
	cin >> n;
	for(int i = 0; i < n; i++ ) {
		int t;
		cin >> t;
		height.push_back(t);
	}
}


int memo[101010];

int dfs(int i) { //足場iにいるときの、N-1に到達するまでのそれ以降の最小コスト
	
	if(i == n - 1) {
		return 0;
	}

	if(memo[i] != -1) return memo[i];

	int ans = inf;

	chmin(ans, abs(height[i] - height[i + 1]) + dfs(i + 1));//次の足場に行くときのコスト

	if(i <= n - 1 - 2) { //次の次の足場に行くコスト
		chmin(ans, abs(height[i] - height[i + 2]) + dfs(i + 2));
	}

	return memo[i] = ans;

}

void solve(){
	memset(memo, -1, sizeof(memo));
	print(dfs(0));


}

signed main(){

	cin.tie(0);
	ios::sync_with_stdio(false);
	in();
	solve();

}

Measured memory_bytes: 7904
#include<bits/stdc++.h>
#define int long long
using namespace std;
int dx[]={0,1,0,-1};
int dy[]={1,0,-1,0};
signed main(){
  int H,W,sx=0,sy=0,gx=0,gy=0;
  cin>>H>>W>>sx>>sy>>gx>>gy;
  sx--,sy--,gx--,gy--;
  vector<string> A(H);
  for(string &S:A)cin>>S;
  vector<vector<int>> B(H,vector<int>(W,H*W));
  deque<pair<pair<int,int>,int>> Q;
  Q.push_back({{sx,sy},0});
  while(!Q.empty()){
    pair<pair<int,int>,int> P=Q.front();
    Q.pop_front();
    pair<int,int> p=P.first;
    if(B[p.first][p.second]!=H*W)continue;
    B[p.first][p.second]=P.second;
    for(int i=0;i<4;i++){
      int x=p.first+dx[i],y=p.second+dy[i];
      if(0<=x && x<H && 0<=y && y<W && A[x][y]=='.'){
        Q.push_front({{x,y},B[p.first][p.second]});
      }
    }
    for(int i=-2;i<=2;i++){
      int x=p.first+i;
      for(int j=-2;j<=2;j++){
        int y=p.second+j;
        if(0<=x && x<H && 0<=y && y<W && A[x][y]=='.' &&
           (abs(i)+abs(j)>1)){
          Q.push_back({{x,y},B[p.first][p.second]+1});
        }
      }
    }
  }
  if(B[gx][gy]==H*W)puts("-1");
  else cout<<B[gx][gy]<<endl;
}

Measured memory_bytes: 15708
#include<iostream>
#include<cstdlib>
#include<cstdio>
template<int BUFSIZE>
struct ans_buf {
  char buf[BUFSIZE];
  int i;
  ans_buf(): i(0) {}
  void putZ(unsigned int v, char delim='\n') {
    unsigned int k = 1;
    while(k <= v/10) k*=10;
    for(; k>0; v%=k, k/=10) buf[i++] = (v/k)+'0';
    buf[i++] = delim;
  }
  void out() { std::fwrite(buf, 1, i, stdout); }
};

int const MAXN = 3e5;
int const MAXA = 6.4e5;
int N, m[MAXN], d[MAXN+1];

int main() {
  std::cin >> N;
 // std::fill_n(m, N, 0);
  for(int i = 0; i < N; ++i) { int A; std::cin >> A; ++m[A-1]; }
  //std::fill_n(d, N+1, 0);
  for(int i = 0; i < N; ++i) ++d[m[i]];
 
  ans_buf<MAXA> buf;
  int sum_D = 0, sum_iD = N, k = 1;
  for(int ans = N; ans >= 1; --ans) {
    sum_D += d[ans];
    sum_iD -= d[ans]*ans;
    int next_k = sum_iD/ans + sum_D + 1;
    for(int i = k; i < next_k; ++i) buf.putZ(ans);
    k = next_k;
  }
  while(k <= N) { buf.putZ(0); ++k; }
  buf.out();
  return 0;
}



Measured memory_bytes: 2688
#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<b;i++)
#define rrep(i,a,b) for(int i=a;i>=b;i--)
#define fore(i,a) for(auto &i:a)
#define all(x) (x).begin(),(x).end()
//#pragma GCC optimize ("-O3")
using namespace std; void _main(); int main() { cin.tie(0); ios::sync_with_stdio(false); _main(); }
typedef long long ll; const int inf = INT_MAX / 2; const ll infl = 1LL << 60;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a = b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a = b; return 1; } return 0; }
//------------------------------------------------------------------------------
//------------------------------------------------------------------------------
void _main()
{
    int N, K;
    cin >> N >> K;
    vector<ll> A(N);
    rep(i, 0, N) cin >> A[i];

    const ll sum = accumulate(all(A), 0);

    deque<int> divisors;
  for (int i = 1; i * i <= sum; ++i) {
    if (sum % i != 0)continue;
    divisors.push_back(i);
    if (i * i != sum)divisors.push_back(sum / i);
  }
  sort(rbegin(divisors), rend(divisors));
  for (auto& v : divisors) {
    deque<int> rs;
    for (int i = 0; i < N; ++i) {
      if (A[i] % v == 0)continue;
      rs.push_back(A[i] % v);
    }
    if (rs.empty()) {
      cout << v << endl;
      return;
    }

        sort(all(rs));
        int n = rs.size();
        vector<int64_t> csum(n + 1, 0);
        for (int i = 0; i < n; ++i)
        csum[i + 1] = csum[i] + rs[i];
        bool ans = false;
        for (int i = 1; i <= n - 1; ++i) {
        if (v * (int64_t)(n-i) - (csum[n] - csum[i]) != csum[i])continue;
        if (csum[i] <= K)ans = true;
        break;
        }
        if (!ans)continue;
        cout << v << endl;
        return;
    }
}


Measured memory_bytes: 256
#include<iostream>
#include<map>
#include<string>
#include<vector>
#include<algorithm>
#include<queue>
#include<set>
#include<map>
using namespace std;

int dx[2] = { 1,-1 }, dy[2] = { -1,1 };
int main() {
	int a,sum=0;
	while (cin >> a,sum++, a) {
		printf("Case %d:\n", sum);
		int b[10][10]{};
		b[0][0] = 1;
		int x = 0, y = 1;
		int s = 0;
		for (int c = 2; c <= (a+1)*a/2; c++) {
			b[x][y] = c;
			x += dx[s & 1]; y += dy[s & 1];
			if (y == -1) {
				y = 0; s++;
			}
			else if (x == -1) {
				x = 0; s++;
			}
		}
		if (a & 1) {
			x = 1; y = a - 1;
			s = 0;
		}
		else {
			x = a - 1; y = 1;
			s = 1;
		}
		for (int i = (a + 1)*a / 2+1; i <= a*a; i++) {
			b[x][y] = i;
			x += dx[s & 1]; y += dy[s & 1];
			if (y == a) {
				y = a - 1; x+=2; s++;
			}
			else if (x == a) {
				x = a - 1; y+=2; s++;
			}
		}
		for (int i = 0; i < a; i++) {
			for (int j = 0; j < a; j++) {
				printf("%3d", b[i][j]);
			}
			cout << endl;
		}
	}
}

Measured memory_bytes: 3180
/*
ID: alec3
LANG: C++14
PROG:
*/


#include <bits/stdc++.h>

#define check(x) cout<<(#x)<<": "<<x<<" ";
#define io ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define ss second
#define ff first
#define pb push_back
#define lb lower_bound
#define ub upper_bound
#define ld long double
#define all(c) (c).begin(), (c).end()
#define FOR(i, a, b) for (int i = a; i < b; i++)

typedef long long ll;
typedef unsigned long long ull;

int pct(int x) { return __builtin_popcount(x); }

using namespace std;

string s, t;
ll ans = 0;
ll n, m;
bool mat[1005][1005];
bool vis[1005][1005];

ll dr[4] = {0, 0, -1, 1};
ll dc[4] = {1, -1, 0, 0};

bool valid(ll r, ll c){
    return r >= 0 && r < n && c >= 0 && c < m;
}


void solve(){
    cin >> n >> m;
    ll a, b, c, d;
    cin >> a >> b >> c >> d;
    a--; b--; c--; d--;

    for (ll i = 0; i < n; i++){
        cin >> s;
        for (ll j = 0; j < m; j++){
            mat[i][j] = (s[j] == '.');
        }
    }

    deque<pair<pair<ll, ll>, ll>> dq;
    dq.push_front(make_pair(make_pair(a, b), 0));

    while (!dq.empty()){
        pair<pair<ll, ll>, ll> x = dq.front();
        dq.pop_front();

        pair<ll, ll> pos = x.ff;

        if (vis[pos.ff][pos.ss]) continue;
        vis[pos.ff][pos.ss] = 1;

        if (pos.ff == c && pos.ss == d){
            cout << x.ss << endl;
            return;
        }

        for (ll d = 0; d < 4; d++){
            ll nr = pos.ff + dr[d];
            ll nc = pos.ss + dc[d];

            if (valid(nr, nc) && mat[nr][nc] && !vis[nr][nc])
                dq.push_front(make_pair(make_pair(nr, nc), x.ss));
        }

        for (ll dr = -2; dr <= 2; dr++){
            for (ll dc = -2; dc <= 2; dc++){
                ll nr = pos.ff + dr;
                ll nc = pos.ss + dc;

                if (valid(nr, nc) && mat[nr][nc] && !vis[nr][nc])
                    dq.push_back(make_pair(make_pair(nr, nc), x.ss + 1));
            }
        }
    }
    cout << -1 << endl;
    return;

}



int main()
{
    io;
    solve();

    return 0;

}


Measured memory_bytes: 6996
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<ll, ll>;
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define ve vector
#define chmin(x,y) x = min(x,y)

const int INF = 1e8;

int main(){
    int n;
    cin >> n;
    ve<int> dp(n+10,INF);
    dp[0] = 0;
    rep(i,n)dp[i+1] = dp[i] + 1;
    int k = 6;
    while(k<=n){
        rep(i,n-k+5){
            dp[i+k] = min(dp[i+k], dp[i]+1);
        }
        k*= 6;
    }
    k = 9;
    while(k<=n){
        rep(i,n-k+5){
            dp[i+k] = min(dp[i+k], dp[i]+1);
        }
        k*= 9;
    }
    cout << dp[n] << endl;
    return 0;
}


Measured memory_bytes: 3768
#include <bits/stdc++.h>
#define meow(args...) fprintf(stderr, args)
typedef unsigned u32;
typedef long long s64;
typedef unsigned long long u64;
template<class T1, class T2> inline bool cmin(T1 &a, const T2 &b) {return b<a?(a=b, true):false;}
template<class T1, class T2> inline bool cmax(T1 &a, const T2 &b) {return a<b?(a=b, true):false;}

const u32 P=998244353;
inline u32 &inc(u32 &a, u32 b) {return (a+=b)<P?a:(a-=P);}
inline u32 &dec(u32 &a, u32 b) {return (a-=b)&0x80000000?(a+=P):a;}
inline u32 sum(u32 a, u32 b) {return (a+=b)<P?a:a-P;}
inline u32 dif(u32 a, u32 b) {return (a-=b)&0x80000000?a+P:a;}
u64 power(u64 a, int b) {
	u64 ans=1;
	for(; b; a=a*a%P, b/=2) if(b&1) ans=ans*a%P;
	return ans;
}

typedef std::bitset<101> Set;
std::unordered_map<Set, u32> f;
Set fs[101];
u32 sol(int n, Set s) {
	if(n==0) return 1;
	Set t=s;
	t.set(n);
	auto it=f.find(t);
	if(it!=f.end()) return it->second;
	u32 ans=sol(n-1, s>>1);
	if(s.test(0)) ans=ans*2%P;
	for(int i=1; i<=n; ++i) {
		Set t=fs[i]&s;
		for(int j=2; i*j<=n; ++j) {
			t&=s>>(i*(j-1));
			ans=(ans+(u64)sol(n-i*j, s>>(i*j))*sol(i, t))%P;
		}
	}
	f.emplace(t, ans);
	return ans;
}
int main() {
	int n;
	char s[101];
	assert(scanf("%s", s)==1);
	n=strlen(s);
	for(int i=1; i<=n; ++i) fs[i]=fs[i-1], fs[i].set(i-1);
	printf("%u\n", sol(n, Set(s)));
	return 0;
}


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

int main() {
    vector<int> vec(3);
    rep(i, 3) cin >> vec[i];
    sort(vec.begin(), vec.end());
    cout << vec[2]*10 + vec[1] + vec[0] << endl;
    return 0;
}

Measured memory_bytes: 256
n,m=map(int, input().split())
a=[int(input()) for i in range(m)]
 
dp=['inf']*(n+1)
dp[0]=1
dp[1]=1
for i in range(m):
    dp[a[i]]=0

for i in range(2,n+1):
    if dp[i]==0:
        if dp[i+1]==0:
            print(0)
            exit()
        else:
            pass
    else:
        dp[i]=dp[i-1]+dp[i-2]
print(dp[n]%(10**9+7))

Measured memory_bytes: 460020
import java.util.Arrays;
import java.util.Scanner;

public class Main{
	private static Scanner scan;
	public static void main(String[] args) {
		scan = new Scanner(System.in);
		scan.useDelimiter(",|\\s+");
		int a[][] = new int[10][10];
		for(int i = 0;i < 10;i++)Arrays.fill(a[i],0);
		while(scan.hasNext()){
			int x = scan.nextInt();
			int y = scan.nextInt();
			int size = scan.nextInt();
			switch(size){
			case 3:
				if(x - 2 >= 0)a[x-2][y]++;
				if(y - 2 >= 0)a[x][y-2]++;
				if(x + 2 <= 9)a[x+2][y]++;
				if(y + 2 <= 9)a[x][y+2]++;
			case 2:
				if(x - 1 >= 0&&y - 1 >=0)a[x-1][y-1]++;
				if(x - 1 >= 0&&y + 1 <=9)a[x-1][y+1]++;
				if(x + 1 <= 9&&y - 1 >=0)a[x+1][y-1]++;
				if(x + 1 <= 9&&y + 1 <=9)a[x+1][y+1]++;
			case 1:
				if(x - 1 >= 0)a[x-1][y]++;
				if(y - 1 >= 0)a[x][y-1]++;
				if(x + 1 <= 9)a[x+1][y]++;
				if(y + 1 <= 9)a[x][y+1]++;
				a[x][y]++;
				break;
			}
		}
		int n = 0,m = 0;
		for(int i = 0;i < 10;i++){
			for(int j = 0;j < 10;j++){
				if(a[i][j] == 0)n++;
				m = Math.max(a[i][j], m);
			}
		}
		System.out.println(n);
		System.out.println(m);
		System.exit(0);
	}

}

Measured memory_bytes: 12000
/**
 * Maximum Profit
 * http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=ALDS1_1_D&lang=ja
 */

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

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

  // R = その時点の価格
  // min = 最低価格
  // profit = 利益
  int R, min_price = numeric_limits<int>::max(), profit = numeric_limits<int>::min();
  for (int i = 0; i < n; i++) {
    cin >> R;

    // 最大収益を更新する
    profit = max(profit, R - min_price);
    // 最低価格を更新する
    min_price = min(min_price, R);
  }

  cout << profit << endl;

  /**
  // R = その時点の価格
  // min = 最低価格
  // profit = 利益
  int R, min = -1, profit  = -200_000;

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

    // 1回目は最低価格を更新するだけで良い
    if (i == 0) {
      min = R;
      continue;
    }

    // 2回目以降は利益計算を実施する
    if (i == 1 || R - min > profit) {
      profit = R - min;
    }

    // 最低価格を更新しているかどうか
    if (R < min) {
      min = R;
    }
  }
  cout << profit << endl;
  return 0;
  */

}



Measured memory_bytes: 3120
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, j, n) for (ll i = j; i < n; i++)
#define all(x) (x).begin(),(x).end()
#define INF (1000000000)
#define MOD (1000000007)
#define MAX (100000)
#define pii pair<int, int>

/////////////////////////////////////////////////////////

class XY{
public:
  ll x, y;
  XY() {x = y = 0;}
  XY(ll u, ll v) {x = u; y = v;}
};

template<typename T1, typename T2>
void chmin(T1 &a, T2 b) {if(a > b) a = b;}
template<typename T1, typename T2>
void chmax(T1 &a, T2 b) {if(a < b) a = b;}

template<typename T1, typename T2>
ll mypow(T1 a, T2 n){
  if(n == 0) return 1;
  if(n == 1) return a;
  if(n % 2) return a * mypow(a, n - 1);
  ll tmp = mypow(a, n / 2);
  return tmp * tmp;
}

template<typename T>
int BS(vector<T> V, int left, int right, T key){
  int mid = (left + right) / 2;
  if(V[mid] <= key) left = mid;
  else right = mid;
  if(right - mid == 1) return left;
  else return BS(V, left, right, key);
}

ll comb(ll n, ll r){
	ll res = 1;
  rep(i, 0, r){
    res *= n - i;
    res /= i + 1;
  }
  return res;
}

/////////////////////////////////////////////////////////

void Main() {
  ll A, B, C; cin >> A >> B >> C;
  ll cnt = 0;
  while(true){
    bool ok = true;
    if(A % 2) ok = false;
    if(B % 2) ok = false;
    if(C % 2) ok = false;
    if(!ok) break;
    if(A == B && B == C){
      cout << -1 << endl;
      return;
    }
    ll a, b, c;
    a = A; b = B; c = C;
    A = b / 2 + c / 2;
    B = a / 2 + c / 2;
    C = a / 2 + b / 2;
    cnt++;
  }
  cout << cnt << endl;
}

/////////////////////////////////////////////////////////

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

  Main();
}


Measured memory_bytes: 256
#include<stdio.h>

int main(){
  int k,i,j=0;
  scanf("%d",&k);

  if(k%2 ==1){
    k =k/2;
    printf("%d",k*(k+1));
  }
  
  else{
    k =k/2;
    printf("%d",k*k);
  }
}

Measured memory_bytes: 128
import math,itertools,fractions,heapq,collections,bisect,sys,queue,copy

sys.setrecursionlimit(10**7)
inf=10**20
mod=10**9+7
dd=[(-1,0),(0,1),(1,0),(0,-1)]
ddn=[(-1,0),(-1,1),(0,1),(1,1),(1,0),(1,-1),(0,-1),(-1,-1)]

def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def LS(): return sys.stdin.readline().split()
def S(): return input()

def main():
  a=[2,4,5,7,9]
  b=[0,1,6,8]
  c=[3]

  n=S()
  x=int(n[-1])

  if x in a:
    return 'hon'
  elif x in b:
    return 'pon'
  return 'bon'

# main()
print(main())


Measured memory_bytes: 10676
/* AOJ0558 Cheese */

 

#include <iostream>

#include <cctype>

#include <queue>

#include <string.h>

 

using namespace std;

 

const int DIRECTSIZE = 4;

struct _direct {

    int drow;

    int dcol;

} direct[DIRECTSIZE] = {{0, -1}, {0, 1}, {-1, 0}, {1, 0}};

 

const int N = 1000;

const int N2 = 10;

char grid[N][N], visited[N][N];

int h, w, n;

struct _factory {

    int row, col;

} factory[N2];

 

struct _node {

    int row, col, level;

};

 

int bfs(int n, char goal)

{

    memset(visited, 0, sizeof(visited));

 

    _node start={factory[n-1].row, factory[n-1].col, 0}, temp;

 

    visited[start.row][start.col] = 1;

 

    queue<_node> q;

    q.push(start);

 

    while(!q.empty()) {

        _node front = q.front();

        q.pop();

 

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

            int nextrow = front.row + direct[i].drow;

            int nextcol = front.col + direct[i].dcol;

            if( 0 <= nextrow && nextrow < h && 0 <= nextcol && nextcol < w) {

                if(grid[nextrow][nextcol] == goal) {

                    return front.level + 1;

                } else if(visited[nextrow][nextcol] == 0 && grid[nextrow][nextcol] != 'X') {

                    visited[nextrow][nextcol] = 1;

                    temp.row = nextrow;

                    temp.col = nextcol;

                    temp.level = front.level + 1;

                    q.push(temp);

                }

            }

        }

    }

 

    return 0;

}

 

int main()

{

    while(cin >> h >> w >> n) {

        for(int i=0; i<h; i++)

            for(int j=0; j<w; j++) {

                cin >> grid[i][j];

 

                if(grid[i][j] == 'S') {

                    factory[0].row = i;

                    factory[0].col = j;

                } else if(isdigit(grid[i][j])) {

                    factory[grid[i][j] - '0'].row = i;

                    factory[grid[i][j] - '0'].col = j;

                }

            }

 

        int minstep = 0;

        char goal = '1';

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

            minstep += bfs(i, goal);

            goal++;

        }

 

        cout << minstep << endl;

    }

 

    return 0;

}



Measured memory_bytes: 4984
#include <iostream>
#include <algorithm>
#include <cmath>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <string>
using namespace std;
typedef long long int ll;
typedef vector<int> vi;
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define Sort(a) sort(a.begin(), a.end())
const int INF = 1<<30;
const ll MOD = 1000000007;

int main(void) {
    ll a, b, c, d;
    cin >> a >> b >> c >> d;
    vector<ll> A(4);
    A[0] = a * c; A[1] = a * d; A[2] = b * c; A[3] = b * d;
    sort(A.begin(), A.end());
    cout << A[3] << endl;

    return 0;
}

Measured memory_bytes: 3624
#include<iostream>
#include<algorithm>
#include<string>
#include<cmath>
#include<map>
#include<queue>
#include<set>
#include<vector>
#include<cstdio>

using namespace std;
/*
int find(int x, vector<int> &p) {
if (p[x] == x)return x;
return p[x] = find(p[x], p);
}

void uni(int x, int y, vector<int> &p) {
x = find(x, p);
y = find(y, p);
p[x] = y;
}

int same(int x, int y, vector<int> p) {
if (find(x, p) == find(y, p))return 1;
return 0;
}
*/

int main()
{
	bool flag = false;
	int N, ans = 0, tmp;
	vector<int> a;
	cin >> N;

	for (int i = 0; i < N; i++) {
		cin >> tmp;
		a.push_back(tmp);
	}

	vector<int> ch(N);

	for (int i = 0; i < N; i++) {
		ch[i] = 0;
		int res = a[i];
		while (res%2 == 0) {
			res /= 2;
			ch[i]++;
		}
	}

	int sum = 0;
	for (int i = 0; i < N; i++) {
		sum += ch[i];
	}

	if (sum == 0) {
		cout << 0;
	}
	else {
		cout << sum;
	}

	char qq;
	cin >> qq;
	return 0;
}

Measured memory_bytes: 384
import bisect

s=input()
t=input()

#index=list()
#for a in range(len(t)):
# index.append([i for i, x in enumerate(s) if x == t[a]])

char_appear = {ch: [] for ch in 'abcdefghijklmnopqrstuvwxyz'}
for i, ch in enumerate(s):
    char_appear[ch].append(i)
#print(char_appear['a'])
      
b=0
loop=0
condition=0

for j in range(len(t)):
  if len(char_appear[t[j]])<1:
    print(-1)
    condition=1
    break
  c=bisect.bisect(char_appear[t[j]],b)
 # print(j,char_appear[t[j]],b,c,loop)
  if j<1:
    b=char_appear[t[0]][0]    
  elif c == len(char_appear[t[j]]): #or c==char_appear[t[j]][len(char_appear[t[j]])-1]: 
     loop +=1
     b=char_appear[t[j]][0]
     if loop==10**100:
        print(-1)
        condition=1
        break
  else:
     b=char_appear[t[j]][c]
     #print(j,b,loop)


if condition==0:
 print(b+loop*len(s)+1)


        



Measured memory_bytes: 7668
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n)  for(int i = 0; i < n; i++)
#define all(cont) cont.begin(), cont.end()
#define rall(cont) cont.rbegin(), cont.rend()
#define unique(a)  (a).erase(unique((a).begin(), (a).end()),(a).end())
#define fastio          ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define PB push_back
#define endl "\n"
#define mod 1000000007
typedef long long LL;
typedef long double LD;
typedef vector<int> VI;
inline LL add(LL x, LL y) { x += y; if (x >= mod) x -= mod; return x; }
inline LL moduloMultiplication(LL x, LL y) {
	return (x%mod * 1LL * y%mod) %

		mod;
}
inline LL power(LL a, LL b) {
	LL x = 1 % mod;
	while (b) {
		if (b & 1) x = moduloMultiplication(x, a);
		a = moduloMultiplication(a, a);
		b >>= 1;
	}
	return x % mod;
}
inline LL inv(LL a) { return power(a, mod - 2) % mod; }
LL gcd(LL a, LL b)
{
	if (!a)
		return b % mod;
	return gcd(b%a, a) % mod;
}
int main()
{
	
	int n, k;
	cin >> n >> k;
	LL dig = (LL)(floor(log(n) /
		log(k)) + 1);
	cout << dig << endl;

}




Measured memory_bytes: 512
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cmath>
#include <ctime>
#include <cstring>
#include <functional>
#include <iostream>
#include <iomanip>
#include <limits>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <regex>
#include <vector>

#define fix(n)          cout<<fixed<<setprecision(n)
#define rep(i,n)        for (int i = 0; i < (n); ++i)
#define all(a)          (a).begin(), (a).end()
#define sort(a)         sort(all(a))
#define uniq(a)         sort(a);(a).erase(unique(all(a), (a).end())
#define reverse(a)      reverse(all(a))
#define ctos(c)         string(1, (c))
#define out(d)          cout << (d)
#define outl(d)         std::cout<<(d)<<"\n"
#define YES()           cout << "YES" << endl
#define NO()            cout << "NO" << endl
#define Yes()           cout << "Yes" << endl
#define No()            cout << "No" << endl
#define ceil(x, y)      ((x + y - 1) / (y))
#define debug(x)        cerr << #x << ": " << (x) << '\n'
#define debug2(x, y)    cerr << #x << ": " << (x) << ", " << #y << ": " << (y) << '\n'
#define debug3(x, y, z) cerr << #x << ": " << (x) << ", " << #y << ": " << (y) << ", " << #z << ": " << (z) << '\n'
#define dbg(v)          for (size_t _ = 0; _ < v.size(); ++_){ cerr << #v << "[" << _ << "] : " << v[_] << '\n'; }

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

const ll MOD = 1000000007; // 10^9 + 7
const int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
const int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};

vector<char> stocvec(string s) {
  int n = s.size();
  vector<char> ret(n);
  for (int i = 0; i < n; i++) ret[i] = s[i];
  return ret;
}

void solve() {
  string s; cin >> s;

  if (s == "zyxwvutsrqponmlkjihgfedcba") {
    outl(-1);
    return;
  }

  vector<int> alp(26, 0);
  for (char c : s) alp[c-'a']++;
  rep(i, 26) {
    if (alp[i] == 0) {
      outl(s + (char)('a' + i));
      return;
    }
  }

  string t = s;
  next_permutation(all(s));
  string ans = "";
  for (int i = 0; i < s.size(); i++) {
    ans += s[i];
    if (s[i] > t[i]) break;
  }
  outl(ans);
}

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  srand((unsigned)time(NULL));
  fix(12);

  solve();
}


Measured memory_bytes: 632
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cctype>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <time.h>
#include <tuple>
#include <utility>
#include <vector>
#define ll long long
#define itn int
#define endl '\n'
#define co(ans) cout<<ans<<endl
#define COYE cout<<"YES"<<endl
#define COYe cout<<"Yes"<<endl
#define COye cout<<"yes"<<endl
#define CONO cout<<"NO"<<endl
#define CONo cout<<"No"<<endl
#define COno cout<<"no"<<endl
#define FORE(i,a) for(auto &i:a)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define FFOR(i,a,b) for(int i=(a);i<=(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define RREP(i,n)  FFOR(i,1,n)
#define PB push_back
#define MP make_pair
#define ALL(V) (V).begin(),(V).end()
#define SORT(V) sort((V).begin(),(V).end())
#define REVERSE(V) reverse((V).begin(),(V).end())
#define EACH(V,i) for(typeof((V).begin()) i=(V).begin();i!=(V).end();++i)
#define equals(a,b) (fabs((a)-(b))<EPS)
#define INF ((1LL<<62)-(1LL<<31))
#define EPS 1e-10
#define PI 3.141592653589793238
#define MOD 1000000007
#define MAX 5100000
using namespace std;
using Graph=vector<vector<int>>;
inline int toInt(string s){int v;istringstream sin(s);sin>>v;return v;}
template<class T>inline string toString(T x){ostringstream sout;sout<<x;return sout.str();}
template<class T>bool chmax(T &a,const T &b){if(a<b){a=b;return 1;}return 0;}
template<class T>bool chmin(T &a,const T &b){if(b<a){a=b;return 1;}return 0;}
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;
const int dx[4]={0,1,0,-1},dy[4]={1,0,-1,0};
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b){return a/gcd(a,b)*b;}

int main(){
  string S;
  cin>>S;
  
  REP(i,S.size()){
    if(S.at(i)=='?') S.at(i)='D';
  }
  
  co(S);
  return 0;
}

Measured memory_bytes: 3748
import sys

N,K = list(map(int,input().split()))
S = input()

count = 0

if N==1:
    print(0)
    sys.exit()

for i in range(N-1):
    if (S[i]!=S[i+1]):
        count += 1

ans = min(N-1-count+2*K,N-1)
print(ans)

Measured memory_bytes: 3316
n,m,c = map(int,input().split())
b = list(map(int,input().split()))
a = [list(map(int,input().split())) for i in range(n)]

cnt = 0

for i in range(n):
    source = 0
    for j in range(m):
        source += a[i][j] * b[j]
    else:
        if source + c > 0:
            cnt += 1
else:
    ans = cnt
    print(ans)


Measured memory_bytes: 3060
#include <stdio.h>
#include <stdlib.h>

int *Marge(int N,int *B){
	if (N==1){
		int *C=malloc(sizeof(int));
		C=B;
		return C;
	}

	if (N>1){
		int N1=N/2;
		int N2=N-N1;
		int *B1=malloc(N1*sizeof(int));
		int *B2=malloc(N2*sizeof(int));
		int i;
		for (i=0;i<N1;i++){
			B1[i]=B[i];
		}
		for (i=N1;i<N;i++){
			B2[i-N1]=B[i];
		}
		int *BB1=Marge(N1,B1);
		int *BB2=Marge(N2,B2);
		int *C=malloc(N*sizeof(int));
		int k=0;
		int l=0;
		int m=0;
		while(1){
			if (k>=N1){
				for (m;m<N;m++){
					C[m]=BB2[l];
					l++;
				}
				break;
			}
			if (l>=N2){
				for (m;m<N;m++){
					C[m]=BB1[k];
					k++;
				}
				break;
			}
			else{
				if (BB1[k]<BB2[l]){
					C[m]=BB1[k];
					m++;
					k++;
				}
				if (BB1[k]>=BB2[l]){
					C[m]=BB2[l];
					m++;
					l++;
				}
			}
		}
		return C;
	}
}

int main(){
	int N;
	int i,j;
	scanf("%d",&N);
	int *A=(int*)malloc(N*sizeof(int));
	int new_N=3*N;
	int *B=(int*)malloc(new_N*sizeof(int));
	int *C=(int*)malloc(new_N*sizeof(int));
	for (i=0;i<N;i++){
		scanf("%d",&A[i]);
		B[3*i]=A[i]-1;
		B[3*i+1]=A[i];
		B[3*i+2]=A[i]+1;
	}
	C=Marge(new_N,B);
	int last_ans=0;
	i=0;
	while(i<new_N){
		int ans=0;
		int num=C[i];
		while(i<new_N&&C[i]==num){
			ans++;
			i++;
		}
		if (last_ans<ans){
			last_ans=ans;
		}
	}
	printf("%d\n",last_ans);
	return 0;
}

Measured memory_bytes: 63616
//list index out of rangeエラー表示用
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define rep1(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)


int main(){
  double l;
  cin >> l;
  cout << fixed << setprecision(15) << pow(l/3.0, 3);
}

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

using namespace std;

char s[200002];
int lf[200001], rg[200001];

int main()
{
  int N, K, C;
  scanf("%d %d %d", &N, &K, &C);
  scanf("%s", &s[1]);
  
  int ma_lf = 0, ma_lf_2 = 0, ma_rg = 0, ma_rg_2 = 0;
  for (int i = 1; i <= N; i++) {
    if (i - C - 1 >= 1) ma_lf = max(ma_lf, lf[i - C - 1]);
    lf[i] = max(ma_lf_2, (s[i] == 'o') + ma_lf);
    ma_lf_2 = max(ma_lf_2, lf[i]);
    
    if ((N - i + 1) + C + 1 <= N) ma_rg = max(ma_rg, rg[(N - i + 1) + (C + 1)]);
    rg[N - i + 1] = max(ma_rg_2, (s[N - i + 1] == 'o') + ma_rg);
    ma_rg_2 = max(ma_rg_2, rg[N - i + 1]);
  }
      
  for (int i = 1; i <= N; i++) {
    if (s[i] == 'o' && lf[i - 1] + rg[i + 1] < K) printf("%d\n", i);
  }
  
  return 0;
}

Measured memory_bytes: 3200
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  string S;
  cin >> S;
  
  if (S.at(2) == S.at(3) && S.at(4) == S.at(5)) {
    cout << "Yes" << endl;
  }
  
  else {
    cout << "No" << endl;
  }
}



Measured memory_bytes: 256
#include<iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <cmath>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
int Max = 1000000;


int main(){
  int N;
  cin >> N;
  int a[N];

  bool flag = false;
  for(int i=0;i<N;i++){
    cin >> a[i];
    if(a[i]==1) flag = true;
  }
  if(!flag){
    cout << -1 <<endl;
    return 0;
  }

  int cnt = 0;
  int i=0;
  int check = 1;

  
  while(i<N){
    while(i<N && a[i]!=check){
      cnt++;
      i++;
    }
    i++;
    check++;
  }
  
  cout << cnt <<endl;
  return 0;
}


Measured memory_bytes: 1024
#include <cmath>
#include <iostream>
#include <string>
#include <vector> 
#include <algorithm>
#include <numeric>
#include <map>   
#include <stdio.h>

#define FOR(i,a,b) for(i=(a);i<(b);++i) 
#define FORR(i,a,b) for(i=(a);i>(b);--i)
#define REP(i,n) for(i=0;i<(n);++i)
#define REPR(i,n) for(i=(n);i>0;--i)
#define PB push_back
#define ll long long
#define INT_MAX 2147483647
#define LL_MAX 9223372036854775807
#define sortR(a,b) sort(a, b, greater<int>())

using namespace std;

	long long GCD(long long a, long long b) {
		if (a < b)
			swap(a, b);
		if (b == 0) return a;
		else return GCD(b, a % b);
	}
	bool sosuu_check(int num) {
		int i;
		for (i = 2; i <= sqrt(num); ++i) {
			if (num%i == 0)
				return false;
		}
		return (num < 2) ? false : true;
	}



int main() {
	ll gcd, N,i,Ai;
	cin >> N;
	cin >> gcd;
	REP(i, N-1) {
		cin >> Ai;
		gcd = GCD(gcd, Ai);
	}
	cout << gcd << endl;

}

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

int main() {
    int w, h, x, y, r;
    cin >> w >> h >> x >> y >> r;
    if ((r <= x) && (x <= w-r) && (r <= y) && (y <= h-r)) {
        cout << "Yes" << endl;
    }
    else {
        cout << "No" << endl;
    }
    return 0;
}



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

#define mod 1000000007

ll bigmod( ll a, ll b, ll m)
{
    if( b==0LL )
        return 1LL%m;

    ll x = bigmod( a, b/2LL, m);
    x = ( x * x ) % m;

    if( b%2LL == 1LL ) x = (x*a)%m;

    return x;
}

int main()
{
    int x;
    cin >> x;
    if( x<1200)
        puts("ABC");
    else
        puts("ARC");

    return 0;
}


Measured memory_bytes: 256
use std::io::*;
use std::str::FromStr;

fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}

fn main() {
    let h: usize = read();
    let a: usize = read();
    println!("{}", (a + (h - 1)) / a);
}


Measured memory_bytes: 4352
#include<stdio.h>
#include<string.h>
int main(){
	int n,d[5],ans,out;
	char s[9];
	scanf("%d",&n);
	while(n--){
		ans=out=d[1]=d[2]=d[3]=0;
		while(out!=3){
			scanf("%s",s);
			if(strcmp(s,"HIT")==0){
				if(d[3]==1)ans++,d[3]=0;
				if(d[2]==1)d[3]=1,d[2]=0;
				if(d[1]==1)d[2]=1,d[1]=0;
				d[1]=1;
			}else if(strcmp(s,"HOMERUN")==0){
				if(d[3]==1)ans++;
				if(d[2]==1)ans++;
				if(d[1]==1)ans++;
				d[1]=d[2]=d[3]=0;ans++;
			}else if(strcmp(s,"OUT")==0){
				out++;
			}
		}
		printf("%d\n",ans);
	}
	return 0;
}

Measured memory_bytes: 0
import java.util.Arrays;
import java.util.Scanner;

public class Main {

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

		while(true){
			final int n = sc.nextInt();
			final int p = sc.nextInt();
			final int q = sc.nextInt();
			
			if(n == 0 && p == 0 && q == 0){
				break;
			}
			
			final int start_min = p / 100 * 60 + p % 100;
			final int end_min = q / 100 * 60 + q % 100;
			
			final int size = end_min - start_min;
			
			int[] interval = new int[size];
			
			for(int i = 0; i < n; i++){
				final int k = sc.nextInt();
				
				for(int j = 0; j < k; j++){
					final int c_p = sc.nextInt();
					final int c_e = sc.nextInt();
					
					final int c_start = (c_p / 100 * 60 + c_p % 100) - start_min;
					final int c_end = (c_e / 100 * 60 + c_e % 100) - start_min;
					
					interval[c_start]++;
					if(c_end < size){
						interval[c_end]--;
					}
				}
			}
			
			for(int t = 1; t < size; t++){
				interval[t] += interval[t-1];
			}
			//System.out.println(Arrays.toString(interval));
			
			int cur = 0;
			int max = 0;
			for(int i = 0; i < size; i++){
				if(interval[i] != n){
					cur++;
				}else{
					max = Math.max(max, cur);
					cur = 0;
				}
			}
			max = Math.max(max, cur);
			
			System.out.println(max);
		}

	}

}

Measured memory_bytes: 19388
import sys

def main():
  input = sys.stdin.readline
  N, K = map(int, input().split())
  X = list(map(int, input().split()))
  
  ans = float('inf')
  for i in range(N-K+1):
    L = X[i]
    R = X[i+K-1]
    if L * R < 0:
      t = min(abs(L) + (R - L), R + (R - L))
    else:
      t = max(abs(L), abs(R))
    ans = min(ans, t)
  
  print(ans)


if __name__ == '__main__':
  main()

Measured memory_bytes: 14168
# -*- coding: utf-8 -*-

import math

n = int(raw_input())

i = 1
# sqn = math.ceil(math.sqrt(n))

while i * i <= n:
    if n % i == 0:
        ans = n / i
        #ans = int(math.log10(n / i)) + 1
    i += 1
print len(str(ans))#(ans)

Measured memory_bytes: 2692
var input = require('fs').readFileSync('/dev/stdin', 'utf8');
var Arr=(input.trim()).split("\n").map(Number);
for(var i=0;i<Arr.length;i++){
   if(Arr[i]==0)break;
   var cnt=0;
   for(var j=1;j<=Arr[i];j++){
      var a=j;
      while(a%5==0){
      a/=5;
      cnt++;
   }
}
console.log(cnt);
}

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

int main() {
    int n; cin >> n;
    map<int, int> p;
    for (int i = 0; i < n; i++) {
        int x; cin >> x;
        p[x] += 1;
    }

    int ans = 0;

    int m; cin >> m;
    for (int j = 0; j < m; j++) {
        int y; cin >> y;
        if (p[y]) ans++;
    }

    cout << ans << endl;

}


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

using namespace std;

int main(){
 int n;
 cin >> n;
 vector<int> t(n);
 int sum = 0;
 for(int i = 0;i < n;i++){
  cin >> t[i];
  sum += t[i];
 }
 int m;
 cin >> m;
 for(int i = 0;i < m;i++){
  int x, a;
  cin >> x >> a;
  cout << sum + (a - t[x-1]) << endl;
 }

 return 0;
}

Measured memory_bytes: 256
import java.util.Arrays;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		int[] n = new int[3];
		for (int i = 0; i < 3; i++) {
			n[i] = scan.nextInt();
		}
		int k = scan.nextInt();
		Arrays.sort(n);
		for (int i = 0; i < k; i++) {
			n[2] *= 2;
		}
		int a = 0;
		for (int i = 0; i < 3; i++) {
			a += n[i];
		}
		System.out.println(a);
	}
}


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

int main()
{
  std::vector<ll> v;
  int n;
  cin >> n;
  for(int i=0; i<n; i++)
  {
    ll tmp;
    cin >> tmp;
    v.push_back(tmp);
  }
  ll max,submax;

  max = -200000;
  submax = max;
  std::vector<ll>::iterator itr,itr1,itr2;
  for(itr=v.begin(); itr!=v.end(); itr++)
  {
    if ( *itr > max){
      max = *itr;
      itr1 = itr;
    } else if ( *itr > submax){
      submax = *itr;
      itr2 = itr;
    }
  }
  for(itr=v.begin(); itr!=v.end(); itr++)
  {
    if(itr==itr1){
      cout << submax << endl;
    } else {
      cout << max << endl;
    }
  }
  return 0;
}


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

using std::cin;

constexpr double PI = 3.1415926535;

class Point {
public:
    double x;
    double y;

    Point(double xx = 0.0, double yy = 0.0)
        : x(xx), y(yy) {}
};

void calcKochCurvePoint(int n, Point& p1, Point& p2);
void printPoint(Point& p);

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

    Point p1(0.0, 0.0);
    Point p2(100.0, 0.0);

    printPoint(p1);
    calcKochCurvePoint(n, p1, p2);
    printPoint(p2);

    return 0;
}

void calcKochCurvePoint(int n, Point& p1, Point& p2)
{
    if (n == 0) {
        return ;
    }

    Point s, t, u;
    s.x = (2 * p1.x + p2.x) / 3;
    s.y = (2 * p1.y + p2.y) / 3;
    t.x = (p1.x + 2 * p2.x) / 3;
    t.y = (p1.y + 2 * p2.y) / 3;
    u.x = s.x + (t.x - s.x) * cos(PI / 3) - (t.y - s.y) * sin(PI / 3);
    u.y = s.y + (t.x - s.x) * sin(PI / 3) + (t.y - s.y) * cos(PI / 3);

    calcKochCurvePoint(n - 1, p1, s);
    printPoint(s);
    calcKochCurvePoint(n - 1, s, u);
    printPoint(u);
    calcKochCurvePoint(n - 1, u, t);
    printPoint(t);
    calcKochCurvePoint(n - 1, t, p2);
}

void printPoint(Point& p)
{
    std::cout << std::fixed << p.x << " " << p.y << std::endl;
}

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

int main() {
    int a = 0, b = 0;
    char a_, b_;
    cin >> a_ >> b_;
    if (a_ == 'H') a = 1;
    if (b_ == 'H') b = 1;

    if ((a + b) % 2 == 0) cout << "H" << endl;
    else
        cout << "D" << endl;

    return 0;
}

Measured memory_bytes: 3640
#include<stdio.h>
#include<string.h>
int main(){
  char s[200],p[100];
  int i,ssize,j,psize,ok=0;

  scanf("%s %s",s,p);
  ssize = strlen(s);
  psize = strlen(p);

  for(i=0;i<ssize;i++){
    s[i+ssize] = s[i];
  }

  for(i=0;i<2*ssize;i++){
    if(p[0] == s[i]){
      for(j=0;j<=psize;j++){
        if(j==psize) ok = 1;
        else if(p[j] == s[i+j]) continue;
        else break;
      }
    }
    if(ok == 1) break;
  }
  if(ok == 1) printf("Yes\n");
  else printf("No\n");
  return 0;
}



Measured memory_bytes: 2144
#define _CRT_NO_SECURE_WARNINGS
#pragma warning(disable:4996)

#include <iostream>
#include <vector>
#include <cmath>
#include <algorithm>
#include <cstdio>
#include <string>
#include <iomanip>
#include <set>
#include <map>
#include <ctime>
#include <cstdlib>

using namespace std;

#define imie(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "

using namespace std;

int INF = 1e6;

typedef long long ll;
typedef double d;


void solve() {
	int n;
	cin >> n;
	cout << (n + 1) / 2 << endl;
}
int main() {
	clock_t start = clock();

	ios_base::sync_with_stdio(false);
	cin.tie(0);
	solve();
	start = clock() - start;
	//cout << setprecision(10) <<"Program executed in: " <<  (float)start / CLOCKS_PER_SEC << endl;
}




Measured memory_bytes: 256
#include <stdio.h>
#define N 1000
#define INFINITY 1000000

int n,R[N][N];
int col[N],sub[N];
int tail=0,head=0;
int check[N];
void bfs(int);
int main(){
  int s,t,k;
  int i,j;
  scanf("%d",&n);
  for(i=0;i<n;i++){
    check[i]=0;
    for(j=0;j<n;j++){
      R[i][j]=0;
    }
  }
  for(i=0;i<n;i++){
    scanf("%d",&s);
    scanf("%d",&t);
    s--;
    for(j=0;j<t;j++){
      scanf("%d",&k);
      k--;
      R[s][k]=1;
    }
  }
  // for(i=0;i<n;i++){
  //for(j=0;j<n;j++){
  // printf("%d ",R[i][j]);
  //}
  //printf("\n");
  //}
  bfs(0);
  return 0;
}
void push(int x){
  sub[tail]=x;
  if(tail+1==N)
    tail = 0;
  else
    tail++;
}
int pop(void){
  int x;
  
  x = sub[head];
  if(head+1==N)
    head=0;
  else
    head++;
  return x;
}
void bfs(int d){
  int u;
  int i,j;
  push(d);
  for(i=0;i<n;i++){
    col[i]=INFINITY;
  }
  col[d]=0;
  while(head!=tail){
    u=pop();
    //check[d]=1;
    /*
    for(i=0;i<n;i++){
      printf("%d %d\n",i+1,col[i]);
    }
    //*/
    for(j=0;j<n;j++){
      if(R[u][j]==0)
	continue;
      if(col[j]!=INFINITY && col[j]<col[u]+1)
	continue;
      if(check[j]==1)
	continue;
      col[j]=col[u]+1;
      push(j);
      check[j]=1;
    }
  }
  for(i=0;i<n;i++){
    printf("%d",i+1);
    printf(" ");
    if(col[i]==INFINITY)
      printf("-1\n");
    else printf("%d\n",col[i]);
  }
}



Measured memory_bytes: 2120
A,B,C = map(int,input().split())
ans = 0
Aj = 0
Bj = 0
Cj = 0
if(A % 2 == 1):
  Aj = 1
if(B % 2 == 1):
  Bj = 1
if(C % 2 == 1):
  Cj = 1
if(Aj == Bj and Bj == Cj):
  pass
else:
  if(Aj == Bj):
    A += 1
    B += 1
    ans += 1
  if(Bj == Cj):
    B += 1
    C += 1
    ans += 1
  if(Aj == Cj):
    A += 1
    C += 1
    ans += 1
mokuhyo = max(A,B,C)
while(A != mokuhyo):
  A += 2
  ans += 1
while(B != mokuhyo):
  B += 2
  ans += 1
while(C != mokuhyo):
  C += 2
  ans += 1
print(str(ans))

Measured memory_bytes: 9172
import std.stdio, std.string, std.conv, std.algorithm, std.numeric;
import std.range, std.array, std.math, std.typecons, std.container, core.bitop;

void main() {
    while (true) {
        int n, p;
        scan(n, p);

        if (n == 0 && p == 0) return;

        auto m = new int[](n);
        int pos;
        int wan = p;

        while (true) {
            if (wan == 0) {
                wan += m[pos];
                m[pos] = 0;
            }
            else {
                wan--;
                m[pos]++;
            }

            if (m[pos] == p) break;
            (++pos) %= n;
        }

        writeln(pos);
    }
}



void scan(T...)(ref T args) {
    string[] line = readln.split;
    foreach (ref arg; args) {
        arg = line.front.to!(typeof(arg));
        line.popFront();
    }
    assert(line.empty);
}



void fillAll(R, T)(ref R arr, T value) {
    static if (is(typeof(arr[] = value))) {
        arr[] = value;
    }
    else {
        foreach (ref e; arr) {
            fillAll(e, value);
        }
    }
}

Measured memory_bytes: 2412
#include <iostream>
#include <iomanip>
#include <cmath>
#include <algorithm>
using namespace std;

double dis(double x1, double y1, double x2, double y2) {
	return sqrt(pow(x1 - x2, 2) + pow(y1 - y2, 2));
}

double ldis(double x1, double y1, double x2, double y2, double x3, double y3) {

	if ((x1 - x2) * (x3 - x2) + (y1 - y2) * (y3 - y2) > 0 &&
		(x1 - x3) * (x2 - x3) + (y1 - y3) * (y2 - y3) > 0)
		return abs((y3 - y1) * (x2 - x1) - (x3 - x1) * (y2 - y1)) / dis(x2, y2, x3, y3);
	else
		return min(dis(x1, y1, x2, y2), dis(x1, y1, x3, y3));
}

int main()
{
	int q = 0;

	cin >> q;

	for (int i = 0; i < q; i++) {
		double p0x = 0, p0y = 0, p1x = 0, p1y = 0, p2x = 0, p2y = 0, p3x = 0, p3y = 0,
			u = 0, s = 0, t = 0, d = 0;

		cin >> p0x >> p0y >> p1x >> p1y >> p2x >> p2y >> p3x >> p3y;

		u = (p3y - p0y) * (p2x - p0x) - (p3x - p0x) * (p2y - p0y);
		d = min({ ldis(p0x, p0y, p2x, p2y, p3x, p3y), ldis(p1x, p1y, p2x, p2y, p3x, p3y),
			ldis(p2x, p2y, p0x, p0y, p1x, p1y), ldis(p3x, p3y, p0x, p0y, p1x, p1y) });

		if (u != 0) {
			s = ((p3y - p0y) * (p1x - p0x) - (p3x - p0x) * (p1y - p0y)) / u;
			t = -((p2y - p0y) * (p1x - p0x) - (p2x - p0x) * (p1y - p0y)) / u;

			if (s >= 0 && t >= 0) {
				if (s + t >= 1)
					d = 0;
			}
		}
		else {
			double t0 = (p2x - p0x) * (p3x - p0x) + (p2y - p0y) * (p3y - p0y),
				t1 = (p2x - p1x) * (p3x - p1x) + (p2y - p1y) * (p3y - p1y),
				t2 = (p0x - p2x) * (p1x - p2x) + (p0y - p2y) * (p1y - p2y);

			if ((p1y - p0y) * (p2x - p0x) - (p1x - p0x) * (p2y - p0y) != 0) {
				if (t0 <= 0)
					d = 0;
			}
			else if ((t0 <= 0) || (t1 <= 0) || (t2 <= 0))
				d = 0;
		}

		cout << setiosflags(ios::showpoint | ios::fixed) << setprecision(10)
			<< d << endl;
	}

	return 0;
}



Measured memory_bytes: 3276
a,b = map(int,input().split())


x = []
y = []
ans = []
for i in range(a):
    x.append(str(b))
for j in range(b):
    y.append(str(a))

if b < a:
    ans = ''.join(x)
    print(ans)
elif a < b:
    ans = ''.join(y)
    print(ans)
elif b == a:
    ans = ''.join(y)
    print(ans)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll N = 1e6 + 5;
const ll MOD = 1e9 + 7;
#define all(x) x.begin(),x.end()
#define pii pair<int,int>
#define pis pair<ll,string>
#define F first
#define S second
#define LCM(a,b) ((a*b)/__gcd(a,b))
#define inf 1e15
#define test ll cse;cin>>cse;for(ll _i=1;_i<=cse;_i++)
#define PI 3.14159265
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
const double EPS = 1E-9;
typedef vector< vector<double> > matrix;
typedef vector<int> vi;



int main() {
    fast;

    long double a, b;

    cin >> a >> b;
    ll ans = a * b;

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

Measured memory_bytes: 3812