akhauriyash/Code-Regression huggingface dataset:
import java.io.*;
import java.util.*;

public class Main {
	
	public void solve(){
		long N = nextLong();
		long X = nextLong();
		
		long ans = N;
		long w = X;
		long h = N - X;
		while(w != 0){
			ans += (h / w) * 2 * w;
			if(h % w == 0){
				ans -= w;
				break;
			}
			
			long ww = h % w;
			long hh = w;
			w = ww;
			h = hh;
		}
		out.println(ans);
	}
	
	
	private static PrintWriter out;

	public static void main(String[] args) {
		out = new PrintWriter(System.out);
		new Main().solve();
		out.flush();
	}

	public static int nextInt() {
		int num = 0;
		String str = next();
		boolean minus = false;
		int i = 0;
		if (str.charAt(0) == '-') {
			minus = true;
			i++;
		}
		int len = str.length();
		for (; i < len; i++) {
			char c = str.charAt(i);
			if (!('0' <= c && c <= '9'))
				throw new RuntimeException();
			num = num * 10 + (c - '0');
		}
		return minus ? -num : num;
	}

	public static long nextLong() {
		long num = 0;
		String str = next();
		boolean minus = false;
		int i = 0;
		if (str.charAt(0) == '-') {
			minus = true;
			i++;
		}
		int len = str.length();
		for (; i < len; i++) {
			char c = str.charAt(i);
			if (!('0' <= c && c <= '9'))
				throw new RuntimeException();
			num = num * 10l + (c - '0');
		}
		return minus ? -num : num;
	}

	public static String next() {
		int c;
		while (!isAlNum(c = read())) {
		}
		StringBuilder build = new StringBuilder();
		build.append((char) c);
		while (isAlNum(c = read())) {
			build.append((char) c);
		}
		return build.toString();
	}

	private static byte[] inputBuffer = new byte[1024];
	private static int bufferLength = 0;
	private static int bufferIndex = 0;

	private static int read() {
		if (bufferLength < 0)
			throw new RuntimeException();
		if (bufferIndex >= bufferLength) {
			try {
				bufferLength = System.in.read(inputBuffer);
				bufferIndex = 0;
			} catch (IOException e) {
				throw new RuntimeException(e);
			}
			if (bufferLength <= 0)
				return (bufferLength = -1);
		}
		return inputBuffer[bufferIndex++];
	}

	private static boolean isAlNum(int c) {
		return '!' <= c && c <= '~';
	}
}

Measured memory_bytes: 7892
#include <iostream>
using namespace std;
int main(){
  int n, k, q;
  cin >> n >> k >> q;
  int a[q];
  int count[n];
  for(int A = 0; A < q; A++)cin >> a[A];
  for(int C = 0; C < n; C++)count[C] = 0;
  for(int i = 0; i < q; i++)count[a[i]-1]++;
  for(int j = 0; j < n; j++){
    if(count[j] > q-k)cout << "Yes" << endl;
    else cout << "No" << endl;
  }
  return 0;
}

Measured memory_bytes: 1408
#abc168a
n=int(input())
s1=[2,4,5,7,9]
s2=[0,1,6,8]
s3=[3]
n=n%10
if n in s1:
 print('hon')
elif n in s2:
 print('pon')
elif n in s3:
 print('bon')
else:
 print('')


Measured memory_bytes: 9180
#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define repp(i, n) for(int i = 1; i <= (int)(n); i++)
#define co(x) cout<<x<<endl
typedef long long int lint;
 
int main() {
  lint H,W,ans = 0;
  cin >> H >> W;
  ans = H*W;
  if(H == 1 || W == 1){ans = 1;}
  else if(ans%2 == 0){ans /= 2;}
  else{ans /= 2; ans++;}
  co(ans);
}

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

//#pragma GCC optimize("O3", "no-stack-protector")
//#pragma GCC target("sse4", "avx", "popcnt", "lzcnt", "sse3", "sse4.1", "sse4.2", "sse2", "tune=native")
//#pragma GCC optimize ("unroll-loops")

using namespace std;

using ll = long long;

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    string s;
    ll ans = 0;
    ll cnt = 0;
    cin >> s;
    for (char c : s) {
        if (c == 'B') {
            ++cnt;
        } else {
            ans += cnt;
        }
    }
    cout << ans;
    return 0;
}

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

int main(){
  int n;

  cin >> n;
  int X[n];

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

  int sum = 0;
  int min = 1001001001;
  int i = 1;

  while (i <= 1000){
    for (int j = 0; j < n; j++){
      int a = i - X[j];
      a = pow(a, 2);
      sum += a;
    }

    if (sum < min){
      min = sum;
    }
    i++;
    sum = 0;
  }

  cout << min << endl;

  return 0;
}


Measured memory_bytes: 256
#![allow(non_snake_case)]

use std::io::{stdin, Read};
use std::str::FromStr;
fn read_option<T: FromStr>() -> Option<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()
}
fn read<T: FromStr>() -> T {
    let opt = read_option();
    opt.expect("failed to parse token")
}

fn main() {
    let s: String = read();
    let mut K: usize = read();
    let mut ans: String = "".to_owned();
    for c in s.chars() {
        let point = c as u8 - b'a';
        if c == 'a' {
            ans.push('a');
            continue;
        }
        if 26 - point as usize <= K {
            K -= 26 - point as usize;
            ans.push('a');
        } else {
            ans.push(c);
        }
    }
    if K != 0 {
        let last = ans.pop().unwrap();
        ans.push(((((last as usize - b'a' as usize) + K) % 26) as u8 + b'a') as char)
    }
    println!("{}", ans)
}


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

using namespace std;
using ll = long long;

template <typename K,typename V>
using umap = unordered_map<K,V>;
template <typename V>
using uset = unordered_set<V>;
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; }
#define REP(i,n) for(int i=0;i<n;i++)
#define REPD(i,n) for(int i=n-1;i>=0;i--)
#define FOR(i,a,b) for(int i=a;i<b;i++)
#define FORD(i,a,b) for(int i=a;i>=b;i--)
#define ALL(v) v.begin(),v.end()

#define endl "\n"
#define INF 1'000'000'000'000 //10^12
#define MOD 1'000'000'007
//グリッドグラフの範囲チェック
bool range_validation(int y,int x,int h,int w){
    return y>=0 && y<h && x>=0 && x < w;
}
//ビットカウント
int popcount(long bits){
    bits = (bits & 0x55555555) + (bits >> 1 & 0x55555555);
    bits = (bits & 0x33333333) + (bits >> 2 & 0x33333333);
    bits = (bits & 0x0f0f0f0f) + (bits >> 4 & 0x0f0f0f0f);
    bits = (bits & 0x00ff00ff) + (bits >> 8 & 0x00ff00ff);
    return (bits & 0x0000ffff) + (bits >>16 & 0x0000ffff);
}

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

vector<ll> sieve(ll n){
  vector<bool> is_prime(n+1,true);
  vector<ll> res;
  for(int i=2;i<=n;i++){
    if(is_prime[i]){
      res.push_back(i);
      for(int j=2*i;j<=n;j+=i){
        is_prime[j] = false;
      }
    }
  }
  return res;
}

vector<ll> divisor(ll n){
  vector<ll> list;
  for(int i=1;i*i<=n;i++){
    if(n%i==0){
      list.push_back(i);
      if(n/i != i){
        list.push_back(n/i);
      }
    }
  }
  return list;
}

umap<int,int> prime_factor(ll n){
  umap<int,int> fac;
  for(int i=2;i*i<=n;i+=2){
    if(n%i == 0){
      int count = 0;
      while(n%i == 0){
        count++;
        n /= i;
      }
      fac[i] = count;
    }
  }
  if(n!=1)fac[n] = 1;
  return fac;
}

int main(){
  cin.tie(nullptr);
  ios_base::sync_with_stdio(false);
  cout << fixed << setprecision(15);
  int n;
  cin >> n;
  FOR(i,1,50001){
	int amount = i * 27 / 25;
    if(amount == n){
      cout << i<< endl;
      return 0;
    }
  }
  cout << ":(" << endl;
  return 0;
}


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



void solve(std::string S){

    int ans = 0,rain=0;;
    for(auto &&e : S) {
        if( e == 'R'){
            rain++;
            ans = max(rain,ans);
        }
        else{
            rain=0;
        }
            
    }
cout << ans << endl;

}

signed main(){
    std::string S;
    std::cin >> S;
    solve(S);
    return 0;
}


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

using namespace std;

#define int long long
#define all(v) (v).begin(), (v).end()
#define resz(v, ...) (v).clear(), (v).resize(__VA_ARGS__)
#define reps(i, m, n) for(int i = (int)(m); i < (int)(n); i++)
#define rep(i, n) reps(i, 0, n)

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

typedef pair<int, int> Pi;
typedef tuple<int, int, int> Ti;
typedef vector<int> vint;

const int inf = 1LL << 55;
const int mod = 1e9 + 7;

signed main()
{
  cin.tie(0);
  ios_base::sync_with_stdio(0);
  cout << fixed << setprecision(12);

  int N;
  cin >> N;
  int lb = 0, ub = N+1;
  while(lb+1 < ub) {
    int mb = (lb+ub)/2;
    if(mb*(mb+1)/2 >= N) ub = mb;
    else lb = mb;
  }
  vector<int> ans;
  for(int i = ub; i >= 1; i--) {
    if(N >= i) {
      N -= i;
      ans.push_back(i);
    }
  }
  reverse(all(ans));
  for(int a : ans) cout << a << endl;

  return 0;
}


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

int main() {
    double a, b, c, d, e, f;
    while (cin >> a >> b >> c >> d >> e >> f) {
        double x = 0.0;
        if (c*e - b*f != 0)
            x = static_cast<double>(c*e - b*f) / (a*e - b*d);
        double y = 0.0;
        if (a*f - c*d != 0)
            y = static_cast<double>(a*f - c*d) / (a*e - b*d);
        cout << fixed << setprecision(3);
        cout << x << " " << y << endl;
    }
}

Measured memory_bytes: 0
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<iostream>
#include<string>
#include<vector>
#include<map>
#include<set>
#include<stack>
#include<list>
#include<queue>
#include<deque>
#include<algorithm>
#include<numeric>
#include<utility>
#include<complex>
#include<functional>

using namespace std;

int main(){
//int W,H,x,y,r;
    double r;
    cin>>r;
  double area=r*r*3.141592653589;
  double length=2*r*3.141592653589;
   // cout<<a/b<<" "<<a%b<<" ";   
  printf("%.6lf %.6lf\n" ,area,length);
  
  return 0;
}


Measured memory_bytes: 3208
#include <bits/stdc++.h>
#define MOD 1000000007
#define inv3 333333336

using namespace std;

typedef long long ll;

ll inv[1000005];

void pre(int n) {
  inv[1]=1;
  for(int i=2;i<=n;i++) inv[i]=(MOD-MOD/i)*inv[MOD%i]%MOD;
}

int main() {
  int n;
  scanf("%d",&n);
  pre(n);
  ll ans=0,s=1;
  for(int i=1;i<=n;i++) {
  	s=s*inv3%MOD;
  	ans=(ans+s*inv[n]%MOD*inv[n-i+1])%MOD;
  }
  printf("%lld\n",ans);
  return 0;
}

Measured memory_bytes: 8064
#include <iostream>
#include <algorithm>
#include <vector>
 
using namespace std;
 
int main() 
{
	long long n,w,sum(0);
	cin >> n >> w;
	
	vector<long long>cost(n),weight(n);
	for(int i = 0;i<n;++i){
		cin >> weight[i] >> cost[i];
		sum += cost[i];
	}
	
	vector<vector<long long>>v(n+1);
	for(int i = 0;i<=n;++i)v[i].resize(sum+1,1e9);
	
	for(int i = 0;i<=n;++i)v[i][0] = 0;
	
	for(int i = 1;i<=n;++i){
		for(long long j = 1;j<=sum;++j){
			
			v[i][j] = v[i-1][j];
			if(cost[i-1] <= j)v[i][j] = min(v[i][j],v[i-1][j-cost[i-1]] + weight[i-1]);
			
		}
	}
	
	long long ma = 0;
	
	for(int i = 1;i<=n;++i){
	//	for(int j = 1;j<=sum;++j)cout << v[i][j] << ' ';
	//	cout << "\n\n";
	}
	
	//cout << "\n\n\n\n\n\n";
	
	
	for(int i = 1;i<=n;++i){
		for(long long j = 1;j<=sum;++j)if(v[i][j] <= w)ma = max(ma,j);
//		cout << "\n";
	}
	
	cout << ma;
	
	return 0;
}


Measured memory_bytes: 79488
<?php
    fscanf(STDIN, "%s", $s);
    $length = strlen($s)-2;
    while ($length > 1) {
        $head = substr($s, 0, $length/2);
        $rear = substr($s, $length/2, $length/2);
        if ($head == $rear) { break; }
        $length = $length - 2;
    }
    echo $length . "\n";
?>


Measured memory_bytes: 3576
#include<iostream>
#include<stdio.h>
//#include <bits/stdc++.h>
#include<vector>
#include<float.h>
#include<iomanip>
#include<algorithm>
#include<string>
#include<cstring>
#include<math.h>
#include<cmath>
#include<sstream>
#include<set>
#include<map>
#include<queue>
#include <cassert>
#include <cmath>
#include<cstdint>

#define INF 1e9
#define rep(i,n)for(int i=0;(i)<(int)(n);i++)
#define REP(i,a,b)for(int i=(int)(a);(i)<=(int)(b);i++)
#define VEC(type, c, n) std::vector<type> c(n);for(auto& i:c)std::cin>>i;
#define vec(type,n) vector<type>(n)
#define vvec(m,n) vector<vector<int>> (int(m),vector<int>(n))
#define ALL(a)  (a).begin(),(a).end()

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

vector<int>bitSearch(int bit,int n){
    vector<int>S;
    rep(i,n)if(bit&(1<<i))S.push_back(i);
    return S;
}



int main(){
    double a,b;cin>>a>>b;
    cout<<a/b;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0; i<(int)(n); i++)

using namespace std;
using LL = long long;
using P = pair<int,int>;
const LL mod = 1e9+7;

LL modpow(LL x, LL n){
	LL r=1;
	while(n){
		if(n&1) r=r*x%mod;
		x=x*x%mod;
		n>>=1;
	}
	return r;
}

int main(){
	LL N;
	cin >> N;
	LL ans=0;
	ans+=modpow(10,N);
	ans-=modpow(9,N)*2;
	ans+=modpow(8,N);
	while(ans<0) ans+=mod;
	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 3632
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <queue>
#include <set>
#include <map>
#include <functional>
#include <numeric>

#define ALL(a)  (a).begin(),(a).end()

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

int main() {
    ll n;
    ll ans = 0;

    string s;

    cin >> n >> s;

    ans++;

    for (int i = 1; i < n; i++) {
        if (s[i] != s[i-1]) ans++;
    }

    cout << ans << endl;
    
}


Measured memory_bytes: 512
#include "bits/stdc++.h"
#include <sys/timeb.h>
#include <fstream>

using namespace std;

#define repl(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define rep(i,n) repl(i,0,n)
#define replrev(i,a,b) for(int i=(int)(b)-1;i>=(int)(a);i--)
#define reprev(i,n) replrev(i,0,n)
#define repi(itr,ds) for(auto itr = ds.begin(); itr != ds.end(); ++itr)
#define all(a) a.begin(),a.end()
#define mp make_pair
#define mt make_tuple
#define INF 2000000000
#define INFL 2000000000000000000LL
#define EPS 1e-9
#define MOD 1000000007
#define PI 3.1415926536
#define RMAX 4294967295

typedef unsigned int uint;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> P;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<ull> vull;
typedef vector<bool> vb;
typedef vector<char> vc;
typedef vector<string> vs;
typedef vector<double> vd;
typedef vector<P> vP;
typedef vector<vector<int> > vvi;
typedef vector<vector<bool> > vvb;
typedef vector<vector<ll> > vvll;
typedef vector<vector<char> > vvc;
typedef vector<vector<double> > vvd;
typedef vector<vector<P> > vvP;
typedef priority_queue<int, vector<int>, greater<int> > pqli;
typedef priority_queue<ll, vector<ll>, greater<ll> > pqlll;
typedef priority_queue<P, vector<P>, greater<P> > pqlP;
typedef pair<int, pair<int, int> > Edge;
typedef vector<Edge> vE;
typedef priority_queue<Edge, vector<Edge>, greater<Edge> > pqlE;

int N, M;
vvi dp;
vi a;

int solve(int asked, int ans, vi nums) {
	if (dp[asked][ans] != -1)return dp[asked][ans];
	if (nums.size() < 2) return 0;
	int ret = INF;
	rep(i, M) {
		if ((asked & (1 << i)) != 0)continue;
		vi yes, no;
		rep(j, nums.size()) {
			if ((nums[j] & (1 << i)) != 0) {
				yes.push_back(nums[j]);
			}
			else {
				no.push_back(nums[j]);
			}
		}
		ret = min(ret, max(solve(asked | (1 << i), ans | (1 << i), yes), solve(asked | (1 << i), ans, no)) + 1);
	}
	return dp[asked][ans] = ret;
}

int main() {
	while (true) {
		cin >> M >> N;
		if (M == 0)break;
		dp = vvi(1 << M, vi(1 << M, -1));
		a = vi(N, 0);
		rep(i, N) {
			ll n;
			cin >> n;
			rep(j, M) {
				if (n % 10 == 1) {
					a[i] += 1LL << j;
				}
				n /= 10;
			}
		}
		cout << solve(0, 0, a) << endl;
	}

	return 0;
}

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

using namespace std;

typedef long long ll;

// modint
const ll mod = 1e9+7;
template< int mod >
struct ModInt {
  int x;
  ModInt() : x(0) {}
  ModInt(int64_t y) : x(y >= 0 ? y % mod : (mod - (-y) % mod) % mod) {}
  ModInt &operator+=(const ModInt &p) {
    if((x += p.x) >= mod) x -= mod;
    return *this;
  }
  ModInt &operator-=(const ModInt &p) {
    if((x += mod - p.x) >= mod) x -= mod;
    return *this;
  }
  ModInt &operator*=(const ModInt &p) {
    x = (int) (1LL * x * p.x % mod);
      return *this;
  }
  ModInt &operator/=(const ModInt &p) {
    *this *= p.inv();
    return *this;
  }
  ModInt operator-() const { return ModInt(-x); }
  ModInt operator+(const ModInt &p) const { return ModInt(*this) += p; }
  ModInt operator-(const ModInt &p) const { return ModInt(*this) -= p; }
  ModInt operator*(const ModInt &p) const { return ModInt(*this) *= p; }
  ModInt operator/(const ModInt &p) const { return ModInt(*this) /= p; }
  bool operator==(const ModInt &p) const { return x == p.x; }
  bool operator!=(const ModInt &p) const { return x != p.x; }
    
  ModInt inv() const {
    int a = x, b = mod, u = 1, v = 0, t;
    while(b > 0) {
      t = a / b;
      swap(a -= t * b, b);
      swap(u -= t * v, v);
    }
    return ModInt(u);
  }
  
  ModInt pow(int64_t n) const {
    ModInt ret(1), mul(x);
    while(n > 0) {
      if(n & 1) ret *= mul;
      mul *= mul;
      n >>= 1;
    }
    return ret;
  }
  
  friend ostream &operator<<(ostream &os, const ModInt &p) {
    return os << p.x;
  }
  
  friend istream &operator>>(istream &is, ModInt &a) {
    int64_t t;
    is >> t;
    a = ModInt< mod >(t);
    return (is);
  }
  
  static int get_mod() { return mod; }
};
 
using mint = ModInt<mod>;

int main(){
  long long S; cin >> S;
  
  vector<mint> fact(2000, 1);
  
  for(ll i = 1; i < 2000; i++){
    fact[i] = fact[i-1] * i;
  }
  
  auto comb = [&fact](ll a, ll b){
    mint ret = 1;
    ret *= fact[a];
    ret *= fact[b].inv();
    ret *= fact[a-b].inv();
    return ret;
  };
    
  ll max_num = S / 3; // 整数の最大個数
  
  mint ans = 0;
  
  for(ll i = 1; i <= max_num; i++){
    // i個の時の場合の数
    
    ll target = S - i * 3;
    
    ans += comb(target + i - 1, target);
  }
  
  cout << ans << endl;
}


Measured memory_bytes: 3560
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
int main(){
  vector<string> v(3);
  rep(i,3) cin>>v[i];
  rep(i,3) transform(v[i].begin(), v[i].end(), v[i].begin(), ::toupper);
  rep(i,3) cout<<v[i][0];
  cout<<endl;
}


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

using namespace std;

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

	vector<int> map;

	for(int i=1;i<=n;i++)
	{
		int a;
		cin >> a;
		for(int j=1;j<=a;j++)
			map.push_back(i);
	}

	for(int i=1;i<=h;i++)
	{
		for(int j=1;j<=w;j++)
		{
			cout << map[(i-1)*w+(i%2==1 ? j:w-j+1)-1];
			if(j!=w)
				cout << " ";
		}
		cout << endl;
	}
}

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

#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define int long long int
#define endl "\n"     
#define pb push_back
#define mp make_pair
#define ff first
#define ss second

const int N=305;

int n,c1,c2,c3;
int a[N];
bool vis[N][N][N];
double cache[N][N][N];

double dp(int i,int j,int k)
{
     if(i<0 || j<0 || k<0)
          return 0;
     if(i==0 && j==0 && k==0)
          return 0;
     double &ans=cache[i][j][k];
     if(vis[i][j][k])
          return ans;
     vis[i][j][k]=1;     
     ans=n+ i*dp(i-1,j,k)+ j*dp(i+1,j-1,k)+ k*dp(i,j+1,k-1);
     ans/=(double)(i+j+k);
     return ans;
}

int32_t main()
{
     IOS;
     cin>>n;
     for(int i=1;i<=n;i++)
     {
          cin>>a[i];
          if(a[i]==1)
               c1++;
          else if(a[i]==2)
               c2++;
          else
               c3++;
     }
     double ans=dp(c1,c2,c3);
     cout<<fixed<<setprecision(9)<<ans;
     return 0;
}

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

using namespace std;

int main()
{
    int n;

    cin >> n;

    int d = n % 10;

    string ans;
    
    if (d == 3)
        ans = "bon";
    else if (d == 0 || d == 1 || d == 6 || d == 8)
        ans = "pon";
    else
        ans = "hon";

    cout << ans << "\n";

    return 0;
}

Measured memory_bytes: 3596
#include<bits/stdc++.h>
typedef long long ll;
typedef long double ld;
using namespace std;
 
using Pii = pair<int, int>;
using Pll = pair<ll, ll>;
 
#define REP(i, l, n) for(ll i=(l), i##_len=(n); i<i##_len; ++i)
#define ALL(x) (x).begin(),(x).end()
#define pb push_back
 
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;}
 
char alpha[26] = {'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z'};
 
int dx[4] = {-1, 1, 0, 0};
int dy[4] = {0, 0, 1, -1};
 
 int main(){
     int a, b; cin >> a >> b;
     cout << a * b << endl;
 }

Measured memory_bytes: 3636
using System;
class main
{
    static void Main(String[] args)
    {
        int n = int.Parse(Console.ReadLine());
        int b = 100000;
        for (int i = 0; i < n; i++)
        {
            b = (int)((double)b * 1.05)+999;
            b = (b / 1000)*1000;
        }
        Console.WriteLine(b);
    }
}

Measured memory_bytes: 5604
#include<cstdio>
#include<bits/stdc++.h>
typedef long long int ll;
#define REP(i, n) for(int i = 0; i < (n); i++)
#define FOR_IN(i, a, b) for(int i = (a); i < (b); i++)
#define BETWEEN(x, a, b) ((x) >= (a) && (x) <= (b))

using namespace std;

/*
N 10^5
a,b,c 10^4

N
a1 b1 c1
...
aN bN cN
 */

int N;
ll dp[100001][3];
int h[3];

int main(){
  cin >> N;

  REP(i,N){
    REP(j,3)
      cin >> h[j];

    REP(j,3){
      REP(k,3){
        if(k==j) continue;
        dp[i+1][j] = max(dp[i+1][j], dp[i][k] + h[j]);
      }
    }
  }

  ll ans = 0;
  REP(j,3)
    ans = max(ans, dp[N][j]);

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 2560
#include<iostream>
#include<stdio.h>
#include<math.h>
using namespace std;
#define EPS (1e-10)
#define equals(a,b) (fabs((a) - (b)) < EPS)
class Point{
public:
  double x,y;
  Point(double x = 0, double y = 0):x(x), y(y) {}
  Point operator + (Point p){
    return Point(x+p.x,y+p.y);
  }
  Point operator - (Point p){
    return Point(x-p.x,y-p.y);
  }
  Point operator * (double k){
    return Point(x*k,y*k);
  }
  Point operator / (double k){
    return Point(x/k,y/k);
  }
  bool operator == (const Point &p) const{
    return fabs(x-p.x) < EPS && fabs(y-p.y) < EPS;
  }
};
typedef Point Vector;
double norm(Vector a){
  return pow(a.x,2.0)+pow(a.y,2.0);
}
double abs(Vector a){
  return sqrt(norm(a));
}
int main(){
  int n;
  cin >> n;
  for(int i=0;i<n;i++){
    Point a,b;
    double r1,r2;
    cin >> a.x >> a.y >> r1 >> b.x >> b.y >> r2;
    double d1 = abs(b-a);
    int res;
    if(d1+r2-r1<0) res=2;
    else if(d1+r1-r2<0) res=-2;
    else if(d1<=r1+r2) res= 1;
    else res= 0;
    cout << res << endl;
  }
  return 0;
}

Measured memory_bytes: 1232
#include<iostream>
using namespace std ;
int main()
{
	int pas[ 3 ] ;
	int juice ;
	int min = 2000 ;
	for( int i = 0 ; i < 3 ; i++ )
		cin >> pas[ i ] ;
	for( int i = 0 ; i < 2 ; i++ )
	{
		cin >> juice ;
		for( int j = 0 ; j < 3 ; j++ )
			min = min > pas[ j ] + juice - 50 ? pas[ j ] + juice - 50 : min ;
	}
	cout << min << endl ;
	return 0 ;
}

Measured memory_bytes: 3080
#include<bits/stdc++.h>
using namespace std;
bool isprime(long long n);
int main(){
    int x;
    cin>>x;
    bool flag=false;
    while(!flag){
        flag=isprime(x);
        if(flag){
            cout<<x<<"\n";
            return(0);
        }
        x++;
    }
    return(0);
}
bool isprime(long long n){
    if(n==2) return(true);
    if(n<=1||n%2==0) return(false);
    for(long long i=3;i*i<=n;i+=2){
        if(n%i==0) return(false);
    }
    return(true);
}

Measured memory_bytes: 3596
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String sa = sc.nextLine();
		sc.close();
		char one = sa.charAt(0);
		char two = sa.charAt(1);
		char three = sa.charAt(2);
		char four = sa.charAt(3);
		if((one == two) ||(two == three) || (three == four)) {
			System.out.println("Bad");
		}else {
			System.out.println("Good");
		}
	}

}

Measured memory_bytes: 21972
#include <bits/stdc++.h>
using namespace std;
#define rep(i,ini,n) for(int i=ini;i<n;i++)
#define _rep(i,ini,n) for(int i=ini;i>=n;i--)
#define ToEnd(a) a.begin(),a.end()
uint64_t MOD=1000000007;

int main(){
    int N; cin>>N;
    vector<int> A(N);
    rep(n,0,N) cin>>A.at(n);

    deque<int> dque;
    bool pushFront=true;
    rep(n,0,N){
        if(pushFront) dque.push_front(A.at(n));
        else dque.push_back(A.at(n));

        pushFront=!pushFront;
    }

    if(A.size()%2==0) reverse(ToEnd(dque));
    for(auto dq:dque) cout<<dq<<" ";
    cout<<endl;
}

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

class Program
{
    public static void Main()
    {
        var line = Console.ReadLine().Split(' ').Select(p => int.Parse(p)).ToArray();
        double A = line[0];
        double P = line[1];
        double sumPeace = (A * 3) + P;
        int ans = (int)(sumPeace / 2);


        Console.WriteLine(ans);


    }

}

Measured memory_bytes: 13268
#include <iostream>
#include <cstdio>
#include <string>
#include <cstring>
#include <deque>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <cfloat>
#include <climits>
#include <ctime>
#include <cassert>
#include <numeric>
#include <functional>
#include <bitset>

using namespace std;
#define int long long int
const int INF = 1001001001001001LL;
const int MOD = 1000000007;

int di[] = {-1, 0, 1, 0, -1, 1, 1, -1};
int dj[] = {0, 1, 0, -1, 1, 1, -1, -1};

signed main(){
  
    int n, d; cin >> n >> d;
    int a = n;
    int b = (2 * d + 1);
    cout << (a + b - 1) / b << endl;
    return 0;
}


Measured memory_bytes: 256
from heapq import *
n, m = map(int,input().split())
a = map(int,input().split())
q = []
for i in a:
  heappush(q,-i)
#print(q)
for j in range(m):
  temp = -heappop(q)
  temp //= 2
  heappush(q,-temp)
  #print(q)
print(-(sum(q)))

Measured memory_bytes: 64112
#include <iostream>
#include <vector>
#include <algorithm>
#include <functional>
#include <cmath>
#include <map>
#include <queue>
#include <string>

#define reps(i,s,n) for(int (i) = (s); (i) < (n); (i)++)
#define rep(i,n) reps(i,0,n)
using namespace std;
using ll = long long;
using pii = pair<int,int>;
using vi = vector<int> ;
using vl = vector<ll>;

ll item[3010][3010];
ll dp[4][3010][3010];
ll ans[3010][3010];

int main(){
    int R,C,K;
    cin >> R >> C >> K;

    rep(i,3010){
        rep(j,3010){
            item[i][j] = 0;
            ans[i][j] = 0;
            rep(k,4){
                dp[k][i][j] = 0;
            }
        }
    }

    rep(i,K){
        ll r,c,v;
        cin >> r >>c >> v;
        item[r][c] = v;
    }


    reps(i,1,R+1){
        reps(j,1,C+1){
            dp[0][i][j] = max(dp[0][i][j-1],ans[i-1][j]);
            reps(k,1,4){
                dp[k][i][j] = max(dp[k][i][j-1],
                                max(dp[k-1][i][j-1], ans[i-1][j]) + item[i][j]);
                                
            }
            rep(k,4) ans[i][j] = max(ans[i][j], dp[k][i][j]);
        }
    }

    cout << ans[R][C] << endl;
    return 0;
}


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

const int MOD =1000000007;
//

signed main() {
 int a,b;
 cin>>a>>b;
 for(int i=1;i<=3;i++){
     if(i!=a&&i!=b)cout<<i;
 }
 return 0;
}


Measured memory_bytes: 256
n,k=map(int,input().split())
ls,lm,rs,rm=[0],[[0 for i in range(k+1)]for i in range(n+1)],[0],[[0 for i in range(k+1)]for i in range(n+1)]
v=list(map(int,input().split()))
ld=[]
rd=[]
for i in range(n):
    ls.append(ls[-1]+v[i])
    if v[i]<0:
        ld.append(v[i])
        ld=sorted(ld)
    for j in range(1,k+1):
        if j-1<len(ld):
            lm[i+1][j]=lm[i+1][j-1]+ld[j-1]
        else:
            lm[i+1][j]=lm[i+1][j-1]
    ii=n-i-1
    rs.append(rs[-1]+v[ii])
    if v[ii]<0:
        rd.append(v[ii])
        rd=sorted(rd)
    for j in range(1,k+1):
        if j-1<len(rd):
            rm[i+1][j]=rm[i+1][j-1]+rd[j-1]
        else:
            rm[i+1][j]=rm[i+1][j-1]


mx=-999999999
for w in range(k+1):
    for x in range(w+1):
        for y in range(x,w+1):
            for z in range(y,w+1):
                    a,b,c,d=x,y-x,z-y,w-z
                    if a+c<=n and len(ls)>a>=b and len(rs)>c>=d and ls[a]-lm[a][b]+rs[c]-rm[c][d]>mx:
                        # print(a,b,c,d,ls[a],lm[a][b],rs[c],rm[c][d],ls[a]-lm[a][b]+rs[c]-rm[c][d])
                        mx=ls[a]-lm[a][b]+rs[c]-rm[c][d]
print(mx)


Measured memory_bytes: 43628
#include <bits/stdc++.h>
 
using namespace std;
 
#define f0r(a, b) for (long long a = 0; a < (b); a++)
#define f1r(a, b, c) for (long long a = (b); a < (c); a++)
#define f0rd(a, b) for (long long a = (b); a >= 0; a--)
#define f1rd(a, b, c) for (long long a = (b); a >= (c); a--)
#define ms(arr, v) memset(arr, v, sizeof(arr))
#define pb push_back
#define mp make_pair
#define f first
#define s second
using ll = long long;
using pll = pair<ll, ll>;
using vl = vector<ll>;
using vpl = vector<pll>;
 
void fio() {
  ios_base::sync_with_stdio(0);
  cin.tie(0); 
  cout.tie(0);
}
 
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
 
const long double pi = 3.14159265358979323846;



void solve() {
  ll n; cin >> n;

  ll sum[n + 1]; ms(sum, 0);
  for (ll i = 1; i <= n; i++) {
    for (ll j = i; j <= n; j += i) {
      ++sum[j];
    }
  }

  ll ans = 0;
  f1r(i, 1, n + 1) ans += i * sum[i];
  cout << ans << '\n';
}
 
int main() {
  fio();
  
  int T = 1;
  // cin >> T;
  while (T--) solve();
} 

Measured memory_bytes: 81780
#include<iostream>
#include<cstdio>
using namespace std;
#define MOD 1000000007
#define MAX 305
void add(int &x,int y){x+=y;if(x>=MOD)x-=MOD;}
int n,m,ans,a[MAX<<1];
int cnt1,cnt2,f[MAX<<1][MAX][MAX];
int S[MAX<<1];
bool vis[MAX<<1],book[MAX<<1];
int main()
{
    cin>>n;
    for(int i=1;i<=n+n;++i) cin>>a[i];
    for(int i=1;i<=n+n;i+=2)
        if(a[i]==-1&&a[i+1]==-1)++cnt1;
        else if(a[i]>0&&a[i+1]>0)vis[a[i]]=vis[a[i+1]]=true;
        else ++cnt2,book[(~a[i])?a[i]:a[i+1]]=true;
    for(int i=n+n;i;--i)if(!vis[i])S[++m]=i;
    f[0][0][0]=1;
    for(int i=1;i<=m;++i)
        for(int j=0;j<=cnt1+cnt2;++j)
            for(int k=0;k<=cnt2;++k)
            {
                if(!f[i-1][j][k])continue;
                if(!book[S[i]])
                {
                    add(f[i][j+1][k],f[i-1][j][k]);
                    if(j)add(f[i][j-1][k],f[i-1][j][k]);
                    if(k)add(f[i][j][k-1],1ll*k*f[i-1][j][k]%MOD);
                }
                else
                {
                    add(f[i][j][k+1],f[i-1][j][k]);
                    if(j)add(f[i][j-1][k],f[i-1][j][k]);
                }
            }
    ans=f[m][0][0];for(int i=1;i<=cnt1;++i)ans=1ll*ans*i%MOD;
    printf("%d\n",ans);
    return 0;
}

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

using namespace std;

#define INF 1000000000
#define INFLL 0x3f3f3f3f3f3f3f3fLL 
#define EPS 10e-9
#define MOD 1000000007
#define mp make_pair
#define mt make_tuple
#define pb push_back
#define st first
#define nd second
#define sz(v) int(v.size())
#define all(X) (X).begin(), (X).end()
#define FOR(I, A, B) for(int I = A; I < B; I++)
#define RFOR(I, A, B) for(int I = A; I >= B; I--)

typedef long long ll;
typedef pair<int,int> ii;
typedef pair<int,ii> iii;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ii> vii;
typedef vector<vii> vvii;
typedef vector<iii> viii;
typedef vector<ll> vll;

int main(){
	int n, k;
	scanf("%d %d", &n, &k);
	vector<bool> mark(n+1, false);
	while(k--){
		int d;
		scanf("%d", &d);
		for(int i = 0;i<d; i++){
			int aux;
			scanf("%d", &aux);
			mark[aux] = true;
		}
	}
	int ans = 0;
	for(int i = 1; i <= n; ++i){
		if(!mark[i]) ans++;
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 3644
#include <bits/stdc++.h>
#include <iostream>
#include <climits>
const double PI = acos(-1);
using namespace std;
int main() {
  int a, b, h, m; cin >> a >> b >> h >> m;
  double arg = 30*h + (double) m/2.0 - 6*m;
  double ans = sqrt(a*a + b*b - 2*a*b*cos((double)PI*arg/180));
  printf("%.12f\n",ans);
  
  return 0;
}

Measured memory_bytes: 4140
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
using namespace std;
typedef long long unsigned int ll;

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))

int main() {
    int n,k; cin>>n>>k;
    ll res = 0;
    for(int b = 1; b <= n; ++b) {

        if(k >= b) {
            continue;
        }

        if(k == 0) {
            res += (b - k) * (n/b);
            if(n % b != 0) {
                res -= 1;
            }
        }
        else {
            res += (b - k) * (n/b);
        }

        if(n % b == 0) {
            continue;
        }

        res += max(0, n%b - k + 1);
    }
    cout << res << endl;
    return 0;
}


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

int main(){
    int n;
    cin>>n;
    vector<int>a(n);
    rep(i,n)cin>>a[i];
    sort(a.begin(),a.end());
    int total=0;
    rep(i,n-1)total+=a[i];
    total+=a[n-1]/2;
    cout<<total<<endl;
}

Measured memory_bytes: 256
// #include<iostream>
// #include<vector>
// #include<algorithm>
// #include<map>
// #include<cstring>
// #include<math.h>
// #include<bitset>
// #include<queue>
// #include<set>
// #include<iomanip>
// #include<math.h>
// #include<assert.h>
// #include<string>
// #include<cstdlib>
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
constexpr ll INF = 1LL << 40;
const double INFD = 1e100;
const ll mod = 1000000007;
const double PI = 3.1415926535897932384626433832795028841971;
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
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;
}
// ----------------------------------------------------------------------------

int main(){
  int N,Q;
  cin >> N >> Q;
  string s;
  cin >> s;
  vector<int> S(N+1,0);
  for(int i=0; i<N; i++){
    S[i+1] = S[i] + (s[i]=='A' && s[i+1]=='C');
  }
  for(int i=0; i<Q; i++){
    int l,r;
    cin >> l >> r;
    l--;
    r--;
    cout << S[r]-S[l] << endl;
  }
  return 0;
}


Measured memory_bytes: 1408
s = input()
qn = int(input())
left = ''
right = s
for i in range(qn):
    q = input()
    if q[0] == '1':
        left, right = right, left
    else:
        _, f, c = q.split()
        if f == '1':
            left += c
        else:
            right += c
print(left[::-1] + right)


Measured memory_bytes: 4596
K = int(input())
L = list([1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51])
print(L[K-1])

Measured memory_bytes: 3060
//Name: Magical Tiles
//Level: 2
//Category: 文字列,メモ化
//Note:

/**
 * 一度通った場所を覚えておきながら移動をシミュレーションする。
 * 同じ場所に2回来た場合、ループしている。
 *
 * オーダーは O(HW)。
 */
#include <iostream>
#include <string>
#include <vector>

using namespace std;

bool solve() {
    int H, W;
    cin >> H >> W;
    if(!H && !W) return false;

    vector<string> field(H);
    for(int i = 0; i < H; ++i) {
        cin >> field[i];
    }
    vector<vector<bool>> visited(H, vector<bool>(W, false));
    int r = 0, c = 0;
    bool looped = false;
    while(true) {
        visited[r][c] = true;
        switch(field[r][c]) {
        case '>':
            c++;
            break;
        case '<':
            c--;
            break;
        case '^':
            r--;
            break;
        case 'v':
            r++;
            break;
        default:
            goto end;
        }
        if(visited[r][c]) {
            looped = true;
            break;
        }
    }
end:
    if(looped) cout << "LOOP" << endl;
    else cout << c << ' ' << r << endl;
    return true;
}

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

    while(solve()) ;
    return 0;
}

Measured memory_bytes: 1252
import bisect, collections, copy, heapq, itertools, math, string
import sys
def I(): return int(sys.stdin.readline().rstrip())
def MI(): return map(int, sys.stdin.readline().rstrip().split())
def LI(): return list(map(int, sys.stdin.readline().rstrip().split()))
def S(): return sys.stdin.readline().rstrip()
def LS(): return list(sys.stdin.readline().rstrip().split())

from  collections import defaultdict
from collections import Counter
import bisect
from functools import reduce

def main():
    mod = 10 ** 9 + 7
    def comb(n, r):
        numerator = reduce(lambda x, y: x * y % mod, [n - r + k + 1 for k in range(r)])
        denominator = reduce(lambda x, y: x * y % mod, [k + 1 for k in range(r)])
        return numerator * pow(denominator, mod - 2, mod) % mod
    r_1, c_1, r_2, c_2 = MI()
    #0<=i<=r, o<=j<=cなる全ての(i,j)についてのf(i,j)の和をg(i,j)とする。これをg_rcと表記する。mはマイナス。
    g_r2c2 = (comb(r_2 + c_2 + 2, c_2 + 1) - 1) % mod
    g_r2c1m1 = (comb(r_2 + c_1 + 1, c_1) - 1) % mod
    g_r1m1c2 = (comb(r_1 + c_2 + 1, c_2 + 1) - 1) % mod
    g_r1m1c1m1 = (comb(r_1 + c_1, c_1) - 1) % mod
    ans = (((((g_r2c2 - g_r2c1m1) % mod) - g_r1m1c2) % mod) + g_r1m1c1m1) % mod

    print(ans)


if __name__ == "__main__":
    main()


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

int main() {
  string S;
  cin >> S;
  int ans = 0;
  for (int i = 0; i < 4; i++) {
    if (S[i] == '+') {
      ans++;
    }
    else {
      ans--;
    }
  }
  cout << ans << endl;
}

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

int x,y,ex,ey,m,n,mi;
int vx[4]={1,0,-1,0},vy[4]={0,-1,0,1};
int s[20][20][101];
int t[20][20][4];

void getxy(char *a) {
	y=a[0]-'a';
	if (strlen(a)==3) x=a[2]-'0'; else { x=(a[2]-'0')*10+a[3]-'0';}
	x--;
	}
void search(int v,int x,int y,int ta) {
	int i; 
	s[y][x][ta] |= (1 << v);
	if (x==ex && y==ey) { if (ta<mi) mi=ta; return;}
	for (i=0;i<4;i++) {
	 if (x+vx[i]>n-1 || x+vx[i]<0 || y+vy[i]>m-1 || y+vy[i]<0 || ta+t[y][x][i]>100 ) continue;
	 if ((s[y+vy[i]][x+vx[i]][ta+t[y][x][i]] & (1 << i))!=0 || (i-v)*(i-v)==4) continue;
	 search(i,x+vx[i],y+vy[i],ta+t[y][x][i]);
 }
}  	
	
int main()
{
	char ch[5];
	int d,i,j,k,g,e,x1,y1,v;
	while(cin >> m >> n) {
		if (m+n==0) break;
	    cin >> v; mi=100;
	    for (i=0;i<20;i++) for (j=0;j<20;j++)
	        { for (k=0;k<4;k++) t[i][j][k]=v; for (k=0;k<101;k++) s[i][j][k]=0; }
	    cin >> d;
	    for (i=0; i<d; i++) {
	      cin >> ch; getxy(ch); cin >> g; e=10;
	        for (j=0;j<101;j++) {
			if ((j % g)==0) {if (e==10) e=5; else e=10;}
			s[y][x][j]=e; }
		}
        cin >> d;
        for (i=0 ;i<d; i++) {
			cin >> ch; getxy(ch); x1=x; y1=y; cin >> ch; getxy(ch); 
			for (j=0;j<101;j++) {
				s[y1][x1][j]|=((x1<x)*4+(x1>x)+(y1<y)*2+(y1>y)*8);
				  s[y][x][j]|=((x<x1)*4+(x>x1)+(y<y1)*2+(y>y1)*8);
				}
		}
		cin >> d;
		for (i=0; i<d; i++) {
			cin >> ch; getxy(ch); x1=x; y1=y; cin >> ch; getxy(ch); cin >> g;
			    t[y1][x1][(x1>x)*2+(y1<y)*3+(y1>y)]=t[y][x][(x>x1)*2+(y<y1)*3+(y>y1)]=v+g;
				}
		cin >> ch; getxy(ch); x1=x;y1=y; cin >> ch; getxy(ch); ex=x;ey=y;
		search(0,x1,y1,0);
		cout << mi << endl;		
		}
	return 0;
}

Measured memory_bytes: 1336
#include <iostream>

using namespace std;

int main()
{
    string s;
    int n,len,k;

    scanf("%d",&n);
    cin >> s;

    len = s.size();
    for(int i =0; i<len;i++){
        if(s[i]+n > 90){
            k = (s[i]+n)%90;
            s[i] = k+64;
        }
        else{
            s[i]= s[i]+n;
        }
    }
    cout << s;

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep1(i, n) for (int i = 1; i <= (int)(n); i++)
constexpr int INF = 1e9 + 10;
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};

int main(){
  int H, W, K; cin >> H >> W >> K;
  int y1, x1, y2, x2; cin >> y1 >> x1 >> y2 >> x2;
  y1--; x1--; y2--; x2--;
  vector<vector<bool>> pond(H, vector<bool>(W, true));
  rep(y, H) rep(x, W) {
    char c; cin >> c;
    if (c == '@') pond[y][x] = false;
  }

  vector<vector<int>> bfs(H, vector<int>(W, INF));
  bfs[y1][x1] = 0;
  queue<pair<int, int>> q;
  q.emplace(y1, x1);
  auto inside = [&] (int y, int x) { return 0 <= y && y < H && 0 <= x && x < W; };
  while (!q.empty()) {
    int y, x; tie(y, x) = q.front(); q.pop();
    rep(d, 4) rep1(k, K) {
      int ny = y + dy[d] * k, nx = x + dx[d] * k;
      if (!inside(ny, nx)) break;
      if (!pond[ny][nx]) break;
      if (bfs[ny][nx] <= bfs[y][x]) break;
      if (bfs[ny][nx] != INF) continue;
      bfs[ny][nx] = bfs[y][x] + 1;
      q.emplace(ny, nx);
    }
  }

  if (bfs[y2][x2] == INF) cout << -1 << endl;
  else cout << bfs[y2][x2] << endl;
}

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

template <typename _tp> inline void read(_tp&x){
	char ch=getchar(),ob=0;x=0;
	while(ch!='-'&&!isdigit(ch))ch=getchar();if(ch=='-')ob=1,ch=getchar();
	while(isdigit(ch))x=x*10+ch-'0',ch=getchar();if(ob)x=-x;
}

const int N = 307, p = 1e9+7;
int f[N][N][N];
int n, m;

inline void pls(int&x, const int y) {x = x+y < p ? x+y : x+y-p;}

struct node {int l, x;};
vector <node> vec[N];
vector <node> :: iterator itr;

inline bool ill(int i, int j, int k) {
	int r = max(max(i, j), k);
	for(itr = vec[r].begin(); itr != vec[r].end(); ++ itr)
		if(itr->x != (i >= itr->l) + (j >= itr->l) + (k >= itr->l)) return true;
	return false;
}

int main() {
	read(n), read(m);
	for(int i=1,l,r,x;i<=m;++i) {
		read(l), read(r), read(x);
		vec[r].push_back((node) {l, x});
	}
	int Ans = 0;
	f[0][0][0] = 1;
	for(int i=0;i<=n;++i)
	for(int j=0;j<=n;++j)
	for(int k=0;k<=n;++k) if(f[i][j][k]) {
		if(ill(i, j, k)) {f[i][j][k] = 0; continue;}
		const int r = max(max(i, j), k), v = f[i][j][k];
		if(i != n) pls(f[r+1][j][k], v);
		if(j != n) pls(f[i][r+1][k], v);
		if(k != n) pls(f[i][j][r+1], v);
		if(r == n) pls(Ans, v);
	}
	printf("%d\n", Ans);
	return 0;
}

Measured memory_bytes: 112896
import Foundation
#if os(OSX) || os(iOS)
    import Darwin
#elseif os(Linux)
    import Glibc
#endif
var H = 0, W = 0, N = 0
withUnsafeMutablePointer(&H){withVaList([COpaquePointer($0)]){vscanf("%d",$0)}}
withUnsafeMutablePointer(&W){withVaList([COpaquePointer($0)]){vscanf("%d",$0)}}
withUnsafeMutablePointer(&N){withVaList([COpaquePointer($0)]){vscanf("%d",$0)}}
var a = [Int].init(count: N+1, repeatedValue: 0)
for i in 1...N {
    withUnsafeMutablePointer(&a[i]){withVaList([COpaquePointer($0)]){vscanf("%d",$0)}}
}
var reverse = false
var p = 1
var line = [String].init(count: W, repeatedValue: "")
for _ in 0..<H {
    var s = ""
    for j in 0..<W {
        if a[p] == 0 {
            p += 1
        }
        let lineCur: Int
        if reverse {
            lineCur = W-j-1
        } else {
            lineCur = j
        }
        line[lineCur] = p.description
        a[p] -= 1
    }
    print(line.joinWithSeparator(" "))
    reverse = !reverse
}

Measured memory_bytes: 1152
N = int(input())
c_list = list(map(int, input().split()))

minus_count = 0
rember_number = 0
for i, x in enumerate(c_list):
    if i == 0:
        rember_number = x
        continue
    else:
        if x < rember_number:
            rember_number = x
        if x > rember_number:
            minus_count += 1

print(len(c_list) - minus_count)

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

int main(void)
{
    ll a,b,ans;
    string tb;
    cin >> a >> tb;
    
    tb.replace(1, 1, "");
    b=atoll(tb.c_str());;
    
    ans=a*b;
    
    if(ans<100){
    cout << 0 << endl;
    }else{
    
    string str=to_string(ans);

    cout << str.replace(str.size()-2,2,"") << endl;
    }
    return 0;
}


Measured memory_bytes: 3696
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
 
int main() {
  	int n;	cin >> n;
	vector<int> a(n), b(n), c(n-1);
  	rep(i,n){
      	cin >> a.at(i);
    	a.at(i)--;}
    rep(i,n) cin >> b.at(i);
    rep(i,n-1) cin >> c.at(i);
  	
  	int sm = 0;	rep(i,n) sm += b.at(i);
  	rep(i,n-1){
    	if(a.at(i+1) - a.at(i) == 1) sm += c.at(a.at(i));
    }
  	cout << sm << endl;
}

Measured memory_bytes: 256
N=int(input())
S=input()
ans1=0
maxans=0
def split(word): 
    return [char for char in word]  
def convert(s): 
  
    # initialization of string to "" 
    new = "" 
  
    # traverse in the string  
    for x in s: 
        new += x  
  
    # return string  
    return new 
for i in range(N):
  if S[i]=='(':
    ans1-=1
  else:
    ans1+=1
    if ans1>maxans:
      maxans=ans1
ans2=0
minans=0
for i in range(N):
  if S[N-1-i]==')':
    ans2-=1
  else:
    ans2+=1
    if ans2>minans:
      minans=ans2
r=split(S)
for i in range(minans):
  r.append(')')
r.reverse()
for i in range(maxans):
  r.append('(')
r.reverse()
print(convert(r))

Measured memory_bytes: 3064
#include <iostream>
#include <cstring>
#include <algorithm>
#include <vector>
#include <string>
#include <math.h>
#include <iomanip>
#include <limits>
#include <list>
#include <queue>
#include <tuple>
#include <map>
#include <stack>
#include <set>
#include <bitset>
#include <functional>
#include <cassert>
#include <atcoder/all>
using namespace std;
#define fast_io ios_base::sync_with_stdio (false) ; cin.tie(0) ; cout.tie(0) ;
#define ll long long int
#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define reps(i,n) for(int i=1; i<=(int)(n); i++)
#define REP(i,n) for(int i=n-1; i>=0; i--)
#define REPS(i,n) for(int i=n; i>0; i--)
#define MOD (long long int)(1e9+7)
#define INF (int)(1e9)
#define LINF (long long int)(1e18)
#define chmax(a, b) a = (((a)<(b)) ? (b) : (a))
#define chmin(a, b) a = (((a)>(b)) ? (b) : (a))
#define all(v) v.begin(), v.end()
typedef pair<int, int> Pii;
typedef pair<ll, ll> Pll;

ll mpow(ll a, ll b){
  if(b==0) return 1;
  else if(b%2==0){ll memo = mpow(a,b/2); return memo*memo%MOD;}
  else return mpow(a,b-1) * a % MOD;
}
ll lpow(ll a, ll b){
  if(b==0) return 1;
  else if(b%2==0){ll memo = lpow(a,b/2); return memo*memo;}
  else return lpow(a,b-1) * a;
}
ll gcd(ll a, ll b){
  if(b==0) return a;
  else return gcd(b, a%b);
}
vector<ll> kaijo_memo;
ll kaijo(ll n){
  if(kaijo_memo.size() > n) return kaijo_memo[n];
  if(kaijo_memo.size() == 0) kaijo_memo.push_back(1);
  while(kaijo_memo.size() <= n) kaijo_memo.push_back(kaijo_memo[kaijo_memo.size()-1] * kaijo_memo.size() % MOD);
  return kaijo_memo[n];
}
vector<ll> gyaku_kaijo_memo;
ll gyaku_kaijo(ll n){
  if(gyaku_kaijo_memo.size() > n) return gyaku_kaijo_memo[n];
  if(gyaku_kaijo_memo.size() == 0) gyaku_kaijo_memo.push_back(1);
  while(gyaku_kaijo_memo.size() <= n) gyaku_kaijo_memo.push_back(gyaku_kaijo_memo[gyaku_kaijo_memo.size()-1] * mpow(gyaku_kaijo_memo.size(), MOD-2) % MOD);
  return gyaku_kaijo_memo[n];
}

ll nCr(ll n, ll r){
  if(n == r) return 1;//0個の丸と-1個の棒みたいな時に時に効く？不安.
  if(n < r || r < 0) return 0;
  ll ret = 1;
  if(n <= 1e7){
    ret *= kaijo(n); ret %= MOD;
    ret *= gyaku_kaijo(r); ret %= MOD;
    ret *= gyaku_kaijo(n-r); ret %= MOD;
  }else{
    rep(i,r){
      ret *= n-i; ret %= MOD;
      ret *= mpow(r-i, MOD-2); ret %= MOD;
    }
  }
  return ret;
}

vector<ll> yakusu(ll n){
  vector<ll> ret;
  for(ll p = 1; p*p <= n; p++){
    if(n%p == 0){
      ret.push_back(p);
      if(p*p != n){
        ret.push_back(n/p);
      }
    }
  }
  sort(all(ret));
  return ret;
}

int main(void){
  fast_io
  cout<<fixed<<setprecision(15);

  int n,q;cin>>n>>q;
  atcoder::dsu d(n);
  rep(i,q){
    int t,u,v;cin>>t>>u>>v;
    if(t==0){
      d.merge(u,v);
    }else{
      cout<<(d.same(u,v)?1:0)<<endl;
    }
  }
  return 0;
}

Measured memory_bytes: 3932
n, m, x, y = map(int, input().split())
xs = sorted(list(map(int, input().split())))
ys = sorted(list(map(int, input().split())))

if x < ys[0] and xs[n - 1] < y and xs[n - 1] < ys[0]:
    print("No ", end = "")

print("War")

Measured memory_bytes: 3060