akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <algorithm>
using namespace std;

int DP[1000][128];

int solve(int N, int D){
    fill(DP[0],DP[1000],0);
    DP[0][D]=D;
    for(int i=1;i<N;i++){
        int X=0;
        for(int x=0;x<128;x++){
            if(DP[i-1][X]<DP[i-1][x])X=x;
        }
        for(int y=0;y<128;y++){
            if(DP[i-1][X])
                DP[i][min(y,X^y)]=max(DP[i][min(y,X^y)],DP[i-1][X]-X+y+(X^y));
        }
    }
    int ans=0;
    for(int i=0;i<128;i++){
        ans=max(ans,DP[N-1][i]);
    }
    return ans;
}

int main(){
    int T;
    cin>>T;
    for(int i=0;i<T;i++){
        int N,D;
        cin>>N>>D;
        cout<<solve(N,D)<<endl;
    }
}

Measured memory_bytes: 768
import scala.io.StdIn

object Main extends App {
  val n = StdIn.readLine
  val ans = StdIn.readLine.split(" ").map(_.toInt)
    .sortWith(_>_)
    .zipWithIndex
    .foldLeft(0){ (acc,e) =>
      acc + ( if((e._2 & 1) == 0) e._1 else -e._1 )
    }

  println(ans)
}


Measured memory_bytes: 27328
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <utility>

#define rep(i,j,k) for(int i=j;i<k;i++)
#define INF 2000000000



using namespace std;
int main(void){
    int n,m;
    vector<int> v;
    cin>>n>>m;
    rep(i,0,n){
        v.push_back(i+1);
    }
    
    rep(i,0,m){
        int x,y;
        char c;
        cin>>x>>c>>y;
        x--; y--;
        int swap;
        swap=v[x];
        v[x]=v[y];
        v[y]=swap;
        
    }
    
    rep(i,0,n) cout<<v[i]<<endl;
    return 0;
}

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

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
typedef long long ll;
using namespace std;

int main() {
    ll n, k;
    cin >> n >> k;
    vector<ll> h(n);
    rep(i, n) cin >> h[i];

    sort(h.rbegin(), h.rend());
    ll ans = 0;
    for (int i = k; i < n; i++) {
        ans += h[i];
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 1792
package main

import (
	"bufio"
	"fmt"
	"os"
	"sort"
)

func main() {
	N := ReadInt()
	a := ReadInts(N)
	sort.Sort(sort.Reverse(sort.IntSlice(a)))
	ans := 0
	for i := 0; i < N; i++ {
		if i%2 == 0 {
			ans += a[i]
		} else {
			ans -= a[i]
		}
	}
	fmt.Println(ans)
}

var reader = bufio.NewReader(os.Stdin)

func Scan(a ...interface{}) {
	if _, err := fmt.Fscan(reader, a...); err != nil {
		panic(err)
	}
}
func ReadInt() (i int)       { Scan(&i); return }
func ReadString() (s string) { Scan(&s); return }
func ReadInts(n int) []int {
	v := make([]int, n)
	for i := 0; i < n; i++ {
		Scan(&v[i])
	}
	return v
}


Measured memory_bytes: 1848
n = int(input())
a_li = list(map(int, input().split()))
b_li = list(map(int, input().split()))

ans = 0
for i in range(1, n+1):
  if a_li[-i] < b_li[-i]:
    ans += a_li[-i]
    b_li[-i] -= a_li[-i]
  else:
    ans += b_li[-i]
    b_li[-i] = 0
    
  if a_li[-(i+1)] < b_li[-i]:
    ans += a_li[-(i+1)]
    a_li[-(i+1)] = 0
  else:
    ans += b_li[-i]
    a_li[-(i+1)] -= b_li[-i]
    
print(ans)

Measured memory_bytes: 18752
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <vector>
#define SIZE 100005

using namespace std;

int cnt[SIZE];

int main()
{
	int n;
	scanf("%d",&n);
	for(int i=0;i<n;i++)
	{
		int a;
		scanf("%d",&a);
		cnt[a]++;
	}
	int ret=0;
	for(int i=0;i+2<SIZE;i++)
	{
		ret=max(ret,cnt[i]+cnt[i+1]+cnt[i+2]);
	}
	printf("%d\n",ret);
	return 0;
}


Measured memory_bytes: 512
N = int(input())
b = N.bit_length()
if 2 ** (b - 1) == N:
    print('No')
    exit()

ans = [(N + 2, N + 1), (N + 2, 3), (3, 1), (1, 2), (2, 3 + N)]
for i in range(4, N, 2):
    ans.append((1, i))
    ans.append((1, i + 1))
    ans.append((i, N + i + 1))
    ans.append((i + 1, N + i))

if N % 2 == 0:
    for i in range(30, -1, -1):
        if N > 2 ** i:
            a = 2 ** i
            break
    b = N - a + 1
    ans.append((N, a))
    ans.append((b, 2 * N))
    

print('Yes')
for a, b in ans:
    print(a, b)

Measured memory_bytes: 57712
#include<bits/stdc++.h>
using namespace std;
int memo[64],n;
int f(int n){
  if(~memo[n])return memo[n];
  if(n<=1)return 1;
  return memo[n]=f(n-1)+f(n-2);
}
int main(){
  cin>>n;
  memset(memo,-1,sizeof(memo));
  cout<<f(n)<<endl;
  return 0;
}



Measured memory_bytes: 3096
#include <bits/stdc++.h>
#include <iostream>
#include <string>
#include <string.h>

using namespace std;

int main() 
{
  int n, y; 
  cin >> n >> y;
  for(int i = 0; i <= n; i++) 
  {
    for(int j = 0; j <= n; j++)
    {
      int k = (y - (10000*i + 5000*j)) / 1000;
      if(i+j+k == n && k >= 0)
      {
        cout << i << " " << j << " "
        << k << endl;
        goto Exit;
      }
    }
  }
  cout << "-1" << " " << "-1" << " "
  << "-1" << endl;
  Exit: ;
  return 0;
}

Measured memory_bytes: 3632
#include <iostream>
#include <vector>
#include <array>
#include <list>
#include <queue>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <string>
#include <sstream>
#include <algorithm>
#include <random>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <cmath>
#include <cassert>
#include <climits>
#include <bitset>
#include <functional>
#include <iomanip>

#define FOR_LT(i, beg, end) for (int i = beg; i < end; i++)
#define FOR_LE(i, beg, end) for (int i = beg; i <= end; i++)
#define FOR_DW(i, beg, end) for (int i = beg; end <= i; i--)

using namespace std;

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout << fixed << setprecision(20);


	int n; cin >> n;
	string s; cin >> s;

	int ans = 0;
	FOR_LT(i, 0, n) {
		if (s.substr(i, 3) == "ABC") ans++;
	}
	cout << ans << endl;

	return 0;
}

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

using namespace std;

int main()
{
    int W, H, x, y, r;
    cin >> W >> H >> x >> y >> r;

    if(x-r < 0 || W < x+r) 
    {
        cout << "No" << endl;
        return 0;
    }
    if(y-r < 0 || H < y+r) 
    {
        cout << "No" << endl;
        return 0;
    }

    cout << "Yes" << endl;    
    return 0;
}


Measured memory_bytes: 3096
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#define ll long long
#define rep(i,l,r)for(ll i=(l);i<(r);i++)
#define repp(i,l,r,k)for(ll i=(l);i<(r);i+=(k))
#define INF ((1LL<<62)-(1LL<<31))
#define max(p,q)((p)>(q)?(p):(q))
#define min(p,q)((p)<(q)?(p):(q))
#define bit(n,m)(((n)>>(m))&1)
int upll(const void*a, const void*b){return*(ll*)a<*(ll*)b?-1:*(ll*)a>*(ll*)b?1:0;}
int downll(const void*a, const void*b){return*(ll*)a<*(ll*)b?1:*(ll*)a>*(ll*)b?-1:0;}
void sortup(ll*a,int n){qsort(a,n,sizeof(ll),upll);}
void sortdown(ll*a,int n){qsort(a,n,sizeof(ll),downll);}
ll pom(ll a,ll n,int m){ll x=1;for(a%=m;n;n/=2)n&1?x=x*a%m:0,a=a*a%m;return x;}
//#define MOD 998244353
#define MOD 1000000007
#define invp(a,p)pom(a,p-2,p)



//辺の情報を個別に持つタイプ
typedef struct edge{ll s,g,c;}E;
typedef struct graph{
	int vcnt,ecnt;
	E  e[200010];//適宜変える
	int id[100010];//適宜変える
}G;

int esort(const void*a,const void*b){
	E*p=(E*)a,*q=(E*)b;
	if((*p).s<(*q).s)return -1;
	if((*p).s>(*q).s)return  1;
	if((*p).g<(*q).g)return -1;
	return 1;
}

G g;
void readgraph(){
	//適宜変える
	ll n;
	scanf("%lld",&n);
	rep(i,0,n-1){
		ll x,y,c;
		scanf("%lld%lld%lld",&x,&y,&c);
		x--,y--;
		g.e[2*i].s=x;
		g.e[2*i].g=y;
		g.e[2*i].c=c;
		g.e[2*i+1].s=y;
		g.e[2*i+1].g=x;
		g.e[2*i+1].c=c;
	}
	g.vcnt=n;
	g.ecnt=2*(n-1);
	qsort(g.e,g.ecnt,sizeof(E),esort);

	int p=0;
	rep(i,0,g.vcnt){
		while(p<g.ecnt&&g.e[p].s<i)p++;
		g.id[i]=p;
	}
	g.id[g.vcnt]=g.ecnt;//番兵
}

ll ans[100010];
void dfs(ll k,ll co){
	ans[k]=co;
	rep(i,g.id[k],g.id[k+1]){
		ll v=g.e[i].g;
		ll s=g.e[i].c;
		if(!ans[v])dfs(v,(co+s-1)%2+1);
	}
}

int main(){
	readgraph();
	dfs(0,1);
	rep(i,0,g.vcnt)printf("%lld\n",ans[i]%2);
}

Measured memory_bytes: 9596
#include <bits/stdc++.h>
using namespace std;
#define repd(i,a,b) for (int i=(a);i<(b);i++)
#define rep(i,n) repd(i,0,n)
typedef long long ll;
typedef long double lb;
typedef pair<int,int> P;
const int MOD = 1000000007;
const ll INF = 1e16;
const double EPS = 1e-10;
const double PI = 3.141592653589793;
template<class T> inline bool chmin(T& a, T b){if(a>b){a = b;return 1;}return 0;}
template<class T> inline bool chmax(T& a, T b){if(a<b){a = b;return 1;}return 0;}
const pair<int,int> fd[] = {make_pair(1,0),make_pair(-1,0),make_pair(0,1),make_pair(0,-1)}; 
#define int long long
#define double long double

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

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

signed main(){
  string s,t;cin>>s>>t;
  rep(i,s.length())t += s[i];
  cout << t << endl;
}

Measured memory_bytes: 256
#!/usr/bin/env python3
import sys

input = sys.stdin.readline
mod = 1000000007


def ST():
    return input().rstrip()


def I():
    return int(input())


def MI():
    return map(int, input().split())


def LI():
    return list(MI())


N, K = MI()
MAX = sum(range(N - K + 2, N + 1))
MIN = sum(range(0, K - 1))

ans = 0

for k in range(K, N + 2):
    MAX += N - k + 1
    MIN += k - 1
    ans += (MAX - MIN + 1) % mod

print(ans % mod)


Measured memory_bytes: 9144
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <vector>

#define FILL(a, n, x) memset((a), (x), sizeof ((a)[0]) * (n))
#define COPY(a, n, b) memcpy((b), (a), sizeof ((a)[0]) * (n))
#define FILLA(a, x) memset((a), (x), sizeof (a))
#define COPYA(a, b) memcpy((b), (a), sizeof (a))

using namespace std;

typedef long long li;
typedef unsigned long long lu;
const li infl = ~0LLU >> 2;

template <class T>
inline void Min(T &x, T y) {
  if (y < x) x = y;
}
template <class T>
inline void Max(T &x, T y) {
  if (y > x) x = y;
}

const int mod = 998244353;
inline int Add(int x) { return x >= mod ? x - mod : x; }
inline void Add(int &x, int y) { x += y; if (x >= mod) x -= mod; }
inline int Sub(int x) { return x < 0 ? x + mod : x; }
inline void Sub(int &x, int y) { x -= y; if (x < 0) x += mod; }
inline int Mul(int x, int y) { return (int)((li)x * y % mod); }
inline int Mul(int x, int y, int z) { return Mul(x, Mul(y, z)); }
int Pow(int x, int y) {
  int z = 1;
  for (; y; y >>= 1) {
    if (y & 1) z = Mul(z, x);
    x = Mul(x, x);
  }
  return z;
}
int Inv(int x) {
  return Pow(x, mod - 2);
}

// ----------------------------------------

typedef vector<int> Poly;

const int maxn = 18;

Poly Fwt(Poly f) {
  int n = f.size();
  for (int x = 1; x < n; x <<= 1) {
    for (int s = 0; s < n; ++s) {
      if (s & x) continue;
      int t = f[s | x];
      f[s | x] = Sub(f[s] - t);
      Add(f[s], t);
    }
  }
  return f;
}

Poly Ifwt(Poly f) {
  int n = f.size();
  int inv = Inv(n);
  f = Fwt(f);
  for (int i = 0; i < n; ++i) {
    f[i] = Mul(f[i], inv);
  }
  return f;
}

int main(void) {
  int n, sum = 0;
  scanf("%d", &n);
  n = 1 << n;
  Poly p(n);
  for (int i = 0; i < n; ++i) {
    scanf("%d", &p[i]);
    Add(sum, p[i]);
  }
  for (int i = 0; i < n; ++i) {
    p[i] = Mul(p[i], Inv(sum));
  }

  Poly p_hat = Fwt(p);
  Poly f(n), f_der(n);
  for (int i = 0; i < n; ++i) {
    int k = p_hat[i];
    if (k == 1) {
      f[i] = 1;
      f_der[i] = 0;
    } else {
      f[i] = 0;
      f_der[i] = Inv(Sub(k - 1));
    }
  }
  f = Ifwt(f);
  f_der = Ifwt(f_der);

  Poly ans(n);
  for (int i = 0; i < n; ++i) {
    ans[i] = Mul(Sub(Mul(f_der[i], f[0]) - Mul(f_der[0], f[i])),
                 Inv(Mul(f[0], f[0])));
    printf("%d\n", ans[i]);
  }
  return 0;
}


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

#define rep(i, a) for (int i = 0; i < (a); ++i)
#define REP(i, a, b) for (int i = a; i < (b); ++i)

#define vi vector<int>

#define CHOOSE(a) CHOOSE2 a
#define CHOOSE2(a0, a1, a2, a3, a4, x, ...) x
#define debug_1(x1) cerr << #x1 << ": " << x1 << endl
#define debug_2(x1, x2) cerr << #x1 << ": " << x1 << ", " #x2 << ": " << x2 << endl
#define debug_3(x1, x2, x3) cerr << #x1 << ": " << x1 << ", " #x2 << ": " << x2 << ", " #x3 << ": " << x3 << endl
#define debug_4(x1, x2, x3, x4) cerr << #x1 << ": " << x1 << ", " #x2 << ": " << x2 << ", " #x3 << ": " << x3 << ", " #x4 << ": " << x4 << endl
#define debug_5(x1, x2, x3, x4, x5) cerr << #x1 << ": " << x1 << ", " #x2 << ": " << x2 << ", " #x3 << ": " << x3 << ", " #x4 << ": " << x4 << ", " #x5 << ": " << x5 << endl
#define debug(...) CHOOSE((__VA_ARGS__, debug_5, debug_4, debug_3, debug_2, debug_1, ~)) (__VA_ARGS__)

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

void Main() {
  int n;
  cin>>n;
  vector<ll> a(n);
  rep(i, n) cin>>a[i];
  vector<ll> sum(n+1, 0), dp(n+1, 0);
  rep(i, n) {
    if(i&1) sum[i+1]=sum[i];
    else sum[i+1]=sum[i]+a[i];
  }
  REP(i, 1, n) {
    if(i&1) dp[i+1]=max(dp[i-1]+a[i],sum[i]);
    else dp[i+1]=max(dp[i-1]+a[i],dp[i]);
  }
  cout<<dp[n]<<endl;
}

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


Measured memory_bytes: 7936
#define _USE_MATH_DEFINES
#include <iostream>
#include <fstream>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cstring>
#include <cassert>
#include <string>
#include <vector>
#include <utility>
#include <complex>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <deque>
#include <tuple>
#include <bitset>
#include <limits>
#include <algorithm>
#include <array>
#include <random>
#include <complex>
#include <regex>
using namespace std;
typedef long double ld;
typedef long long ll;
typedef vector<int> vint;
typedef vector<ll> vll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<double, double> pdd;
typedef complex<ld> compd;
#define quickIO()	{cin.tie(0);	cout.sync_with_stdio(false);}
#define reach(i,a)	for(auto i:a)
#define rep(i,n)	for(int i=0;i<(int)n;i++)
#define REP(i,n)	for(int i=0;i<=(int)n;i++)
#define srep(i,a,n)	for(int i=a;i<(int)n;i++)
#define SREP(i,a,n)	for(int i=a;i<=(int)n;i++)
#define rrep(i,n)	for(int i=n-1;i>=0;i--)
#define RREP(i,n)	for(int i=n;i>=0;i--)
#define all(a)	(a).begin(),(a).end()
#define mp(a,b)	make_pair(a,b)
#define mt	make_tuple
#define pb	push_back
int bitcnt(ll x) {
	x = ((x & 0xAAAAAAAAAAAAAAAA) >> 1) + (x & 0x5555555555555555);
	x = ((x & 0xCCCCCCCCCCCCCCCC) >> 2) + (x & 0x3333333333333333);
	x = ((x & 0xF0F0F0F0F0F0F0F0) >> 4) + (x & 0x0F0F0F0F0F0F0F0F);
	x = ((x & 0xFF00FF00FF00FF00) >> 8) + (x & 0x00FF00FF00FF00FF);
	x = ((x & 0xFFFF0000FFFF0000) >> 16) + (x & 0x0000FFFF0000FFFF);
	x = ((x & 0xFFFFFFFF00000000) >> 32) + (x & 0x00000000FFFFFFFF);
	return x;
}
int bitcnt(int x) {
	x = ((x & 0xAAAAAAAA) >> 1) + (x & 0x55555555);
	x = ((x & 0xCCCCCCCC) >> 2) + (x & 0x33333333);
	x = ((x & 0xF0F0F0F0) >> 4) + (x & 0x0F0F0F0F);
	x = ((x & 0xFF00FF00) >> 8) + (x & 0x00FF00FF);
	x = ((x & 0xFFFF0000) >> 16) + (x & 0x0000FFFF);
	return x;
}
ll sqrtll(ll x) {
	ll left = 0, right = x;
	rep(i, 100) {
		ll mid = (left + right) >> 1;
		if (mid*mid <= x)	left = mid;
		else	right = mid;
	}
	return left;
}
ll gcd(ll a, ll b) {
	return a%b == 0 ? b : gcd(b, a%b);
}
#define debug(x)	printf("Case #%d: ", x)
#define DEBUG 0
const ll inf = 1e18;
const ll mod = 1e9 + 7;
const ld eps = 1e-9;
const int dx[] = { 1,0,-1,0,0 };
const int dy[] = { 0,1,0,-1,0 };

// modを法としたa^bを返す
ll modpow(ll a, ll b) {
	ll ret = 1;
	while (b > 0) {
		if (b & 1)	ret = (a*ret) % mod;
		a = (a*a) % mod;
		b >>= 1;
	}
	return ret;
}

// i!
ll fact[500010];
// 1/(i!)
ll invfact[500010];
// nCm
ll nCm(ll n, ll m) {
	return (fact[n] * ((invfact[m] * invfact[n - m]) % mod)) % mod;
}

int main() {
	ll w, h, a, b;	cin >> h >> w >> a >> b;
	// fact,invfactの設定
	fact[0] = fact[1] = invfact[0] = invfact[1] = 1;
	srep(i, 2, 500000) {
		fact[i] = (i*fact[i - 1]) % mod;
		// フェルマーの小定理を利用
		invfact[i] = (modpow(i, mod - 2)*invfact[i - 1]) % mod;
	}
	ll ret = 0;
	// (0,0)->(w-1,h-1)へ移動するものとして、
	// (0,0)->(i,h-a-1)->(i,h-a)->(w-1,h-1)への移動を考える
	srep(i, b, w) {
		// 前半*後半を足してくだけ
		// 前半は右にi、下にh-a-1回移動
		ll first = nCm(i + h - a - 1, i);
		// 後半は右にw-i-1、下にa-1回移動
		ll second = nCm(w - i + a - 2, a - 1);
		(ret += first * second%mod) %= mod;
	}
	cout << ret << endl;
	return 0;
}

Measured memory_bytes: 8064
#include <vector> 
#include <list> 
#include <map> 
#include <set> 
#include <deque> 
#include <queue> 
#include <stack> 
#include <bitset> 
#include <algorithm> 
#include <functional> 
#include <numeric> 
#include <utility> 
#include <sstream> 
#include <iostream> 
#include <iomanip> 
#include <cstdio> 
#include <cmath> 
#include <cstdlib> 
#include <cctype> 
#include <string> 
#include <cstring> 
#include <ctime> 

using namespace std;

#define _int64 long long

char s[1000];

int main()
{
  int i,l;
  scanf("%s",s);
  l=strlen(s);
  for (i=0;i+1<l;i++)
    if ((s[i]=='A')&&(s[i+1]=='C'))
    {
      printf("Yes\n");return 0;
    }
  printf("No\n");
  return 0;
}

Measured memory_bytes: 256
import itertools

N, K = map(int, input().split())
# dic = {}
# count = 0
# for a in range(K, N+2):
#     for i in itertools.combinations(range(1, N+2), a):
#         length = len(i)
#         sum_ = sum(i)
#         if sum_ in dic.keys():
#             if length == dic[sum_]:
#                 continue
#             else:
#                 count += 1
#                 count %= 10000000007
#         else:
#             dic[sum_] = length
#             count += 1
#             count %= 10000000007
#
# print(count)
result = 0
for i in range(K, N+2):
    a = (i-1) * i/2
    b = (2*N-i+1) * i/2
    result += b - a + 1
    result %= 1000000007

print(int(result))

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

int main() 
{
    int m, n, o, i;

    cin >> m;
    cin >> n;
    cin >> o;
    i = (n/m);
    if (i >= o){
        cout << o;
    }
    else{
        cout << i;
    }
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<map>
#include<set>
#include<stack>
#include<queue>
#include<math.h>
using namespace std;
typedef long long ll;
typedef vector<int> VI;
#define REP(i,n) for(int i=0;i<n;i++)
#define eREP(i,n) for(int i=0;i<=n;i++)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define eFOR(i,a,b) for(int i=(a);i<=(b);++i)
#define SORT(c) sort((c).begin(),(c).end())
#define rSORT(c) sort((c).rbegin(),(c).rend())
#define LB(x,a) lower_bound((x).begin(),(x).end(),(a))
#define UB(x,a) upper_bound((x).begin(),(x).end(),(a))
#define INF 1000000000
#define LLINF 9223372036854775807
#define mod 1000000007
//vector<vector<int> > dp;
//vector<vector<vector<int> > > vvvi;
//dp=vector<vector<int> >(N, vector<int>(M,0));
//vector<pair<int,int> > v;
//v.push_back(make_pair(x,y));
int main(){
cin.tie(0);
ios::sync_with_stdio(false);
	
	int N;
	cin>>N;
	VI X(N);
	VI Y(N);
	VI H(N);
	REP(i,N)
		cin>>X[i]>>Y[i]>>H[i];
	REP(x,101){
		REP(y,101){
			ll ans;
			REP(i,N){
				if(H[i]!=0 && H[i]+abs(X[i]-x)+abs(Y[i]-y)>=1){
					ans=H[i]+abs(X[i]-x)+abs(Y[i]-y);
					break;
				}
			}
			bool F=true;
			REP(i,N){
				if(H[i]==0) continue;
				if(ans!=H[i]+abs(X[i]-x)+abs(Y[i]-y)){
					F=false;
					break;
				}
			}
			bool FF=true;
			if(F){
				REP(i,N){
					if(ans-abs(X[i]-x)-abs(Y[i]-y)>0 && H[i]==0)
						FF=false;
				}
				if(FF)
				cout<<x<<" "<<y<<" "<<ans<<endl;
			}
		}
	}
	return 0;
}

Measured memory_bytes: 256
//49
#include<iostream>
#include<utility>
#include<functional>
#include<queue>
#include<vector>

using namespace std;

struct P{
  int x,y,d;
  bool operator<(P a)const{
    return false;
  }
};

typedef pair<int,P> CP;

int main(){
  for(int h,w;cin>>w>>h,h|w;){
    int g[30][30];
    for(int y=0;y<h;y++){
      for(int x=0;x<w;x++){
	cin>>g[y][x];
      }
    }
    int c[4];
    for(int i=0;i<4;i++){
      cin>>c[i];
    }
    bool p[30][30][4]={{{}}};
    priority_queue<CP,vector<CP>,greater<CP> > que;
    P ip={0,0,0};
    que.push(make_pair(0,ip));
    for(;;){
      P cs=que.top().second;
      int ct=que.top().first;
      if(cs.x==w-1&&cs.y==h-1)break;
      que.pop();
      if(p[cs.y][cs.x][cs.d]++)continue;
      for(int i=0;i<4;i++){
	int dy[]={0,1,0,-1};
	int dx[]={1,0,-1,0};
	int ny=cs.y+dy[i];
	int nx=cs.x+dx[i];
	if(0<=nx&&nx<w&&0<=ny&&ny<h){
	  P np={nx,ny,i};
	  int o=(i-cs.d+4)%4;
	  que.push(make_pair(ct+((o==g[cs.y][cs.x])?0:c[o]),np));
	}
      }
    }
    cout<<que.top().first<<endl;
  }
  return 0;
}

Measured memory_bytes: 1332
n = int(input())
s = list(map(int,input().split()))

num = 0
for i in range(len(s)-2):
    if ((s[i] < s[i+1] <s[i+2] ) or (s[i] > s[i+1] > s[i+2] )) == True:
        num +=1
print(num)

Measured memory_bytes: 3060
//できるだけ単純に実装する
//c++での文字列の扱い方も難しい．
//c++でも文字列を扱うときはchar[]を使った方がなにをやってるか
//明確になるのでバグも減るかも
#include <stdio.h>
#include <iostream>
#include <stdlib.h>
#include <vector>
#include <string>
#define LEN 100005
using namespace std;

//new演算子の役割は動的確保を行うこと

/*通常のキュー
class Queue{
private:
	vector<string> s_v;
	vector<int> t_v;
public:
	//void enqueue(string s,int t);
	//string dequeue_name();
	//int dequeue_time();
	//bool isEmpty();
	//bool isFull();


	void enqueue(string s,int t){
	s_v.push_back(s);
	t_v.push_back(t);
	}

	string dequeue_name(){
		string tmp;
		tmp = *s_v.begin();
		s_v.erase(s_v.begin());
		return tmp;
	}

	int dequeue_time(){
		int tmp;
		tmp = *t_v.begin();
		t_v.erase(t_v.begin());
		return tmp;
	}

	bool isEmpty(){
		return s_v.empty();
	}
};
*/
class process{
public:
	string name;
	int time_wanted;

	process(string s,int t){
		name = s;
		time_wanted = t;
	}
};
/*リングバッファ*/
class Queue{
private:
	process *prcsQ[LEN];
	int top;
	int tail;
public:

	Queue(){
		this->top=0;
		this->tail=1;
	}

	void first_enqueue(process *p){
		prcsQ[0] = p;
	}
	
	void enqueue(process *p){
		prcsQ[tail] = p;
		tail = (tail + 1) % LEN;
		//cout <<tail <<endl;
	}

	process * dequeue(){
		int oldtop = top;
		top = (top + 1) % LEN;
		//cout <<top <<endl;
		return prcsQ[oldtop];
	}

	bool isEmpty(){
		if(top == tail)
			return true;
		return false;
	}
};

int main(){
	int process_num;
	int qwantum;
	string tmp_name;
	int tmp_time;
	int current_time = 0;
	char tmp_charsq[100];


	scanf("%d%d",&process_num,&qwantum);//scanfの用法

	Queue queue;

	for(int i=0;i<process_num;i++){
		scanf("%s%d",tmp_charsq,&tmp_time);
		//まずCでサポートされているchar[]に代入し，char[]をstringに代入するという形式にする
		tmp_name = tmp_charsq;
		process *p = new process(tmp_name,tmp_time);
		if(i==0)
			queue.first_enqueue(p);
		else
			queue.enqueue(p);
	}
	
	while(true){
		process *alt;
		alt = queue.dequeue();
		if(alt->time_wanted <= qwantum){
			current_time = current_time + alt->time_wanted;
			cout <<alt->name <<" " <<current_time << endl;
			delete alt;
			if(queue.isEmpty())
				return 0;
		}else{
			current_time = current_time + qwantum;
			alt->time_wanted = alt->time_wanted - qwantum;
			queue.enqueue(alt);
		}
	}

	return 0;
}

Measured memory_bytes: 5916
n,m,x = map(int, input().split())
a = list(map(int, input().split()))
X = x
Y = x
A,B = 0, 0
while X != n:
  X += 1
  if X in a: A += 1

while Y != 0:
  Y -= 1
  if Y in a: B += 1
print(min(A,B))

Measured memory_bytes: 3064
#include <iostream>
#include <fstream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <string>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <deque>
#include <bitset>
#include <algorithm>
#include <complex>
#include <array>
#include <functional>
#include <atcoder/all>
using namespace std;

#define REP(i,n) for(int i=0; i<n; ++i)
#define FOR(i,a,b) for(int i=a; i<=b; ++i)
#define FORR(i,a,b) for (int i=a; i>=b; --i)
#define ALL(c) (c).begin(), (c).end()

typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<double> VD;
typedef vector<VI> VVI;
typedef vector<VL> VVL;
typedef vector<VD> VVD;
typedef pair<int,int> P;
typedef pair<ll,ll> PL;

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

int in() { int x; scanf("%d", &x); return x; }
ll lin() { ll x; scanf("%lld", &x); return x; }

const int INF = 1e6;

int main(void){
    int n, m;
    cin >> n >> m;
    vector<string> s(n);
    REP(i,n) cin >> s[i];
    VVI id(n, VI(m, -1));
    int x = 0;
    REP(i,n) REP(j,m){
        if (s[i][j] == 'o') id[i][j] = x++;
    }
    int all = x + n * m + 2;
    atcoder::mcf_graph<int, int> graph(all);
    REP(i,x) graph.add_edge(0, i + 1, 1, 0);
    REP(i,n) REP(j,m){
        if (s[i][j] != 'o') continue;
        int from = id[i][j] + 1;
        VVI dist(n, VI(m, INF));
        dist[i][j] = 0;
        REP(i,n) REP(j,m){
            if (s[i][j] == '#') continue;
            if (i > 0) chmin(dist[i][j], dist[i - 1][j] + 1);
            if (j > 0) chmin(dist[i][j], dist[i][j - 1] + 1);
            if (dist[i][j] != INF){
                graph.add_edge(from, i * m + j + x + 1, 1, INF - dist[i][j]);
            }
        }
    }
    REP(i,n) REP(j,m){
        graph.add_edge(i * m + j + x + 1, all - 1, 1, 0);
    }
    P p = graph.flow(0, all - 1);
    int ans = x * INF - p.second;
    cout << ans << endl;
    return 0;
}


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

int main() {
    int n;
    std::cin >> n;
    int p[n];
    for (int i = 0; i < n; ++i) {
        std::cin >> p[i];
    }

    int cnt = 0;
    for (int i = 1; i < n - 1; ++i) {
        if ((p[i-1] < p[i] && p[i] < p[i + 1]) || (p[i + 1] < p[i] && p[i] < p[i - 1])) {
            ++cnt;
        }
    }

    std::cout << cnt << std::endl;

    return 0;
}


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


using namespace std;

#define REP(i, n) for(ll i = 0;i < n;i++)
#define REPR(i, n) for(ll i = n;i >= 0;i--)
#define FOR(i, m, n) for(ll i = m;i < n;i++)
#define FORR(i, m, n) for(ll i = m;i >= n;i--)
#define REPO(i, n) for(ll i = 1;i <= n;i++)
#define ll long long
#define INF (ll)1 << 60
#define MINF (-1 * INF)
#define ALL(n) n.begin(),n.end()
#define MOD (ll)1000000007
#define P pair<ll, ll>



ll a, b, c;
int main() {
	cin >> a >> b >> c;
	cout << max(b + c - a, 0ll) << endl;
}
	


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <map>
#include <cstdio>
#include <cstring>
#include <math.h>
#include <bitset>
#include <time.h>
#include <set>
#include <algorithm>
#define Inf 10000000000ll
#define ll long long
using namespace std;
int N,M,Q;

bool can[10001];
bool ncan[10001];

int S[111];

int main() {
    int N;
    cin>>N;
    for(int i=1;i<=N;i++)
        cin>>S[i];
    
    for(int i=0;i<=10000;i++)
        can[i]=false;
    
    
    can[0]=true;
    
    for(int i=1;i<=N;i++) {
        int x=S[i];
        
        for(int i=0;i<=10000;i++)
            ncan[i]=can[i];
        
        for(int i=0;i<=10000;i++) {
            if (can[i] && i+x <= 10000)
                ncan[i+x] |= can[i];
        }
        
        for(int i=0;i<=10000;i++)
            can[i]=ncan[i];
    }
    
    int maxx = 0;
    for(int i=0;i<=10000;i++)
        if(i%10 != 0 && can[i])
            maxx=i;
    
    cout << maxx << endl;
    
    
}

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

template<typename T, typename U> void cmax(T &a, U b) { if (a < b) a = b; }
template<typename T, typename U> void cmin(T &a, U b) { if (a > b) a = b; }

signed main() {
  cin.tie(nullptr);
  ios_base::sync_with_stdio(false);

  long N;
  cin >> N;
  vector<long> X(N), Y(N);
  for (long i = 0; i < N; i++) cin >> X.at(i) >> Y.at(i);

  long xmx = LONG_MIN, xmi = LONG_MAX, ymx = LONG_MIN, ymi = LONG_MAX;
  for (auto x : X) {
    cmax(xmx, x);
    cmin(xmi, x);
  }
  for (auto y : Y) {
    cmax(ymx, y);
    cmin(ymi, y);
  }

  long NX = (xmx + xmi) / 2;
  long NY = (ymx + ymi) / 2;

  long mx = LONG_MIN, I = -1;
  for (long i = 0; i < N; i++) {
    long tmp = abs(NX - X.at(i)) + abs(NY - Y.at(i));
    if (tmp > mx) mx = tmp, I = i; 
  }

  long ans = 0;
  for (long i = 0; i < N; i++) {
    long tmp = abs(X.at(I) - X.at(i)) + abs(Y.at(I) - Y.at(i));
    cmax(ans, tmp);
  }

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

Measured memory_bytes: 6368
#include <cstdio>
#include <iostream>

using namespace std;

int main()
{
    int n;
    cin >> n;
    int sum = 0, max1 = 0, h;
    for (int i = 1; i <= n; i++) {
        int k = i;
        while (k % 2 == 0) {
            k /= 2;
            sum++;
        }
        if (sum >= max1) {
            max1 = sum;
            h = i;
        }
        sum = 0;
    }
    cout << h << endl;
    return 0;
}


Measured memory_bytes: 256
inpl = lambda: list(map(int,input().split()))
MOD = 10**9+7
N = int(input())
A = inpl()
K = len(bin(max(A)))-2
unit = 1
ans = 0
for k in range(K):
    c = 0
    for n in range(N):
        c += A[n] % 2
        A[n] //= 2
    ans += c*(N-c)*unit
    ans %= MOD
    unit = unit * 2 % MOD
print(ans)

Measured memory_bytes: 122808
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;

int main(){
  ll N;
  cin >> N;
  vector<ll> A(N);
  vector<ll> B(N);
  
  for(int i = 0; i < N; i++){
    cin >> A[i] >> B[i];
  }
  sort(A.begin(),A.end());
  sort(B.begin(),B.end());
  ll high,low;
  if(N%2 == 0){
    
    high = B[N/2]+B[-1+N/2];
    low =  A[N/2]+A[-1+N/2];
  }
  else{
    high = B[N/2];
    low =  A[N/2];
  }
  cout << high - low + 1 << endl;
  
}


Measured memory_bytes: 6428
#include "bits/stdc++.h"
using namespace std;

long long gcd(long long a, long long b){
	if(a==0)return b;
	return gcd(b%a, a);
}
long long lcm(long long a, long long b){
	return ((a*b)/(gcd(a,b)));
}

int main(){
	long long A,B = 0;
	cin >> A >> B;
	cout << lcm(min(A,B), max(A,B)); 

}


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

#define REP(i,n) for(int i=0;i<(int)(n);i++)
#define ALL(x) (x).begin(),(x).end()

using namespace std;

using ll = long long;
using ld = long double;

template <typename T> T &chmin(T &a, const T &b) { return a = min(a, b); }
template <typename T> T &chmax(T &a, const T &b) { return a = max(a, b); }

ll S(ll n) {
  ll res = 0;
  while (n > 0) {
    res += n % 10;
    n /= 10;
  }
  return res;
}

int main() {
  vector<pair<ll,ll>> vec;
  ll ten = 1;
  for (int i = 0; i < 15; ++i) {
    for (int j = 1; j <= 300; ++j) {
      ll val = (j + 1) * ten - 1;
      vec.emplace_back(val, S(val));
    }
    ten *= 10;
  }
  sort(ALL(vec));
  auto it = unique(ALL(vec));
  vec.erase(it, end(vec));

  vector<ll> vec2;
  for (int i = 0; i < int(vec.size()); ++i) {
    bool ok = true;
    for (int j = i + 1; j < int(vec.size()); ++j) {
      if (vec[i].first * vec[j].second > vec[j].first * vec[i].second)
        ok = false;
    }
    if (ok) vec2.push_back(vec[i].first);
  }
  int K;
  cin >> K;
  REP(i,K) cout << vec2[i] << endl;
  return 0;
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
int main() {
    int N;
    cin >> N;
    int a[100001], initial[100001];
    for (int i = 1; i <= N; i++) {
        cin >> a[i];
    }
    
    bool can = false;
    int cur = 1;
    for (int i = 1; i <= N; i++) {
        cur = a[cur];
        if (cur == 2) {
            cout << i << endl;
            can = true;
          	break;
        }
    }
    if (!can) cout << -1 << endl;
}

Measured memory_bytes: 640
#include <iostream>
#include <vector>
#include <numeric>
#include <cmath>
#include <algorithm>

using namespace std;

int main()
{
    int N, i, j;
    cin >> N;
    vector<int> cnt(N+1);
    cnt[0] = -1;
    
    for (i=1; i<N+1; i++) {
        j = i;
        while (j % 2 == 0) {
            cnt[i]++;
            j = j / 2;
        }
    }
    int max_idx = max_element(cnt.begin(),cnt.end()) - cnt.begin();
    cout << max_idx << endl;
    
    //getline(cin, str);
    //vector < vector < int > > A(x, vector<int>(y, 0));
    //int avg = round((float)accumulate(X.begin(), X.end(), 0.0) / N);
    //int c = stoi(a+b) *a and b are strings
    //int a[N]; --> sort(a, a + N, greater<int>());
    return 0;
}

Measured memory_bytes: 256
import java.util.*;
import java.math.*;
import java.io.*;
import java.util.regex.*;
import static java.lang.Math.*;
import static java.util.Arrays.*;
import static java.lang.System.*;

public class Main {
	Scanner cin;
	class State{
		int time,x,y;
		State(int time,int x,int y){
			this.time=time;
			this.x=x;
			this.y=y;
		}
	}
	void run(){
		cin=new Scanner(System.in);
		int H=cin.nextInt(),W=cin.nextInt(),N=cin.nextInt();
		String[] MAP=new String[H];
		int []dx={1,0,-1,0},dy={0,1,0,-1};
		int result=0;
		for(int i=0;i<H;i++)MAP[i]=cin.next().replaceAll("S","0");
		for(int i=0;i<N;i++){
			int sx=-1,sy=-1;
			Queue<State> que=new LinkedList<State>();
			Boolean[][] visited=new Boolean[H][W];
			for(int p=0;p<H;p++){
				for(int q=0;q<W;q++){
					visited[p][q]=false;
					if(MAP[p].charAt(q)==i+'0'){
						sx=q;sy=p;
					}	
				}	
			}	
			que.add(new State(0,sx,sy));
			while(!que.isEmpty()){
				State now=que.poll();
				if(MAP[now.y].charAt(now.x)==i+1+'0'){
					result+=now.time;
					break;
				}
				for(int k=0;k<4;k++){
					int nx=now.x+dx[k],ny=now.y+dy[k];
					if(nx>=0&&nx<W&&ny>=0&&ny<H){
						if(visited[ny][nx]==false&&MAP[ny].charAt(nx)!='X'){
							visited[ny][nx]=true;
							que.add(new State(now.time+1,nx,ny));
						}
					}
				}
			}
		}
		printf("%d\n",result);
	}

	void printf(String format,Object... args){
		System.out.printf(format, args);
	}

	public static void main(String[] args) {
		new Main().run();
	}

}

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


int lastdigit(long long int n){
return n%10;
}

void solve(){
long long int n;
cin >> n;
int x = lastdigit(n);

if(x == 2 || x == 4 || x==5 || x==7 || x==9) { cout << "hon";}
else if (x == 0 || x == 1 || x==6 || x==8) { cout << "pon";}
else if (x == 3) { cout << "bon";}
 
}


int main(){

solve();
return 0;


}

Measured memory_bytes: 3600
x, k, d = map(int,input().split())
if x == 0:
    if k%2 == 0:
        print(0)
    else:
        print(d)
else:
    if k * d <= abs(x):
        print(abs(x) - k*d)
    else:
        resK = k - abs(x) // d
        if resK%2 == 0:
            if x > 0:
                print(x - d * (abs(x) // d))
            else:
                print(abs(x + d * (abs(x) // d)))
        else:
            if x > 0:
                print(abs(x - d * (abs(x) // d) - d))
            else:
                print(x + d * (abs(x) // d) + d)

Measured memory_bytes: 9220
use std::io::{stdin, Read};
use std::str::FromStr;
use std::string::ToString;
use std::cmp::Ordering;

fn read<T: FromStr>() -> Option<T> {
    let stdin = stdin();
    let s = stdin
        .bytes()
        .map(|c| c.unwrap() as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect::<String>();
    s.parse::<T>().ok()
}

fn main() {
    let a: usize = read().unwrap();
    let b: usize = read().unwrap();

    let a_btimes: String = a.to_string().repeat(b);
    let b_atimes: String = b.to_string().repeat(a);

    let smaller = match &a_btimes.cmp(&b_atimes) {
      Ordering::Less => a_btimes,
        Ordering::Greater | Ordering::Equal => b_atimes,
    };
    println!("{}", smaller);
}


Measured memory_bytes: 2060
// http://kmjp.hatenablog.jp/entry/2018/09/30/0900

package main

import (
	"bufio"
	"fmt"
	"math"
	"os"
	"strconv"
)

func main() {
	sc := bufio.NewScanner(os.Stdin)
	sc.Split(bufio.ScanWords)

	n := scanInt(sc)
	xs := make([]int64, n)
	ys := make([]int64, n)
	ps := make([]int, n)
	maxDist := int64(0)

	for i := 0; i < n; i++ {
		xs[i] = int64(scanInt(sc))
		ys[i] = int64(scanInt(sc))
		absSum := abs(xs[i]) + abs(ys[i])
		ps[i] = int(absSum % 2)
		if ps[i] != ps[0] {
			fmt.Println("-1")
			return
		}
		if maxDist < absSum {
			maxDist = absSum
		}
	}

	m := int(math.Ceil(math.Log2(float64(maxDist))))
	ds := make([]int64, m, m+1)
	for i := uint(0); i < uint(m); i++ {
		ds[i] = int64(1 << (uint(m-1) - i))
	}
	if ps[0] == 0 {
		ds = append(ds, 1)
	}

	fmt.Println(len(ds))
	for _, d := range ds {
		fmt.Printf("%d ", d)
	}
	fmt.Println()

	for a := 0; a < n; a++ {
		s := ""
		for b := 0; b < len(ds); b++ {
			if abs(xs[a]) >= abs(ys[a]) {
				if xs[a] >= 0 {
					s += "R"
					xs[a] -= ds[b]
				} else {
					s += "L"
					xs[a] += ds[b]
				}
			} else {
				if ys[a] >= 0 {
					s += "U"
					ys[a] -= ds[b]
				} else {
					s += "D"
					ys[a] += ds[b]
				}
			}
		}
		fmt.Println(s)
	}
}

func abs(n int64) int64 {
	return int64(math.Abs(float64(n)))
}

func scanInt(sc *bufio.Scanner) int {
	sc.Scan()
	v, _ := strconv.Atoi(sc.Text())
	return v
}


Measured memory_bytes: 1408
#include<iostream>
#include<deque>
using namespace std;
main()
{
	int t;cin>>t;
	for(;t--;)
	{
		string s;cin>>s;
		deque<char>a;
		a.push_back(s[0]);
		int d=0;
		for(int i=1;i<s.size();i+=3)
		{
			if(s.substr(i,2)=="->")
			{
				if(d+1>=a.size())
				{
					a.push_back(s[i+2]);
				}
				d+=1;
			}
			else
			{
				if(d==0)a.push_front(s[i+2]);
				else d-=1;
			}
		}
		for(int i=0;i<a.size();i++)cout<<a[i];
		cout<<endl;
	}
}



Measured memory_bytes: 3056
#include <bits/stdc++.h>
using namespace std;
#define rep(i, s, n) for (int i = (s); i < (int)(n); i++)
#define all(v) v.begin(), v.end()
using ll = long long;
const ll MOD = 1e9+7; ll LLINF = 1LL << 60; int INF = INT_MAX;

//

int main(){
    ll x,y; cin>>x>>y;
    cout<<floor(log2((long double)y/x))+1<<endl;
}

Measured memory_bytes: 256
N = int(input())
L = list(map(int,input().split()))
#print(L)
ans = 0
for i in range(N):
    for j in range(i+1,N):
        for k in range(j+1,N):
            if L[i] < L[j] + L[k] and L[j] < L[i] + L[k] and L[k] < L[i] + L[j]:
                if L[i] != L[j] and L[j] != L[k] and L[k] != L[i]:
                    ans += 1
print(ans)


Measured memory_bytes: 73856
#include<iostream>
#include<vector>
#include<string>
using namespace std;
int main()
{
    string s, p = "";
    cin >> s;
    for(int i = 0; i < s.size(); i++)
    {
        if(s[i] == '1' || s[i] == '0')
        {
            p = p + s[i];
        }
        else if(p.size() != 0)
                p.erase(p.size() - 1, 1);

    }

    cout << p;

    return 0;
}


Measured memory_bytes: 256
#include<cmath>
#include<algorithm>
#include<iostream>
#include<vector>
#include<cstdio>
#include<climits>
#include<cfloat>
#define curr(P, i) P[(i) % P.size()]
#define next(P, i) P[(i+1) % P.size()]
#define prev(P, i) P[(i+P.size()-1) % P.size()]

using namespace std;

double EPS = 1e-10;
const double PI = acos(-1);

double add(double a, double b){
  if(abs(a+b) < EPS * (abs(a)+abs(b)))return 0;
  return a+b;
}

struct point{
  double x, y;
  point(){}
  point(double x,double y) : x(x) , y(y){}

  point operator + (point p){
    return point(add(x,p.x), add(y,p.y));
  }

  point operator - (point p){
    return point(add(x,-p.x), add(y,-p.y));
  }

  point operator * (double d){
    return point(x*d,y*d);
  }
};

point symmetry(point p1, point p2, point Q){
  double xa,ya,xb,yb,t1,t2;
  point R;

  xa=Q.x-p1.x,ya=Q.y-p1.y;
  xb=p2.x-p1.x,yb=p2.y-p1.y;

  t1=xa*xb+ya*yb,t2=xb*xb+yb*yb;

  R.x=2*(p1.x+xb*t1/t2)-Q.x;
  R.y=2*(p1.y+yb*t1/t2)-Q.y;
  return R;
}

int main(void){

  point a,b;
  cin >> a.x >> a.y >> b.x >> b.y;

  int q;
  cin >> q;

  while(q--){
    point in;
    cin >> in.x >> in.y;
    point res=symmetry(a,b,in);
    printf("%.10f %.10f\n",res.x,res.y);
  }

  return 0;
}

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

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

using std::cin;
using std::cout;
using std::endl;
using std::string;
using std::vector;

int main()
{
  string T;
  cin >> T;

  rep(i, T.size())
  {
    if (T[i] == '?')
      cout << 'D';
    else
    {
      cout << T[i];
    }
  }
  cout << endl;

  return 0;
}


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

char dic[64][2]={""};

int main(){
	int n,i,tail;
	char s;
	while(1){
		tail=0;
		cin>>n;
		if(!n) return 0;
		while(n--){
			cin>>dic[tail][0];
			cin>>dic[tail++][1];
		}
		cin>>n;
		while(n--){
			for(cin>>s,i=0;i<tail;i++) if(s == dic[i][0]){ cout<<dic[i][1]; break;}
      if(i==tail) cout<<s;
		}
	cout<<endl;
	}
}

Measured memory_bytes: 852
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <math.h>
#include <cstdlib>
#include <cmath>

using namespace std;

int main(){
  int N;
  cin >> N;
  cout << N*800 - (N/15)*200 << endl;
  
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
long long n,a,ans[2],i,ch;
map<long long,long long> m;
int main()
{
    scanf("%lld",&n);
    for(i=0;i<n;i++)
    {
        scanf("%lld",&a);
        m[a]++;
        if(m[a]%2==0 && a>ans[ch])
        {
            ans[ch]=a;
            if(ans[0]>ans[1]) ch=1;
            else ch=0;
        }
    }
    printf("%lld",ans[0]*ans[1]);
}


Measured memory_bytes: 6528
#include<iostream>
#include<string>
#include<set>
#define loop(i,a,b) for(int i=a;i<b;i++)
#define rep(i,a) loop(i,0,a)
using namespace std;

bool bo(char ch){
	if(ch=='a' || ch=='i' || ch=='u' || ch=='e' || ch=='o')return true;
	else return false;
}

int max(int a,int b){
	return ((a<b)?b:a);
}

int main(){
	int n;
	while(cin>>n,n){
		string s[n],alt;
		int m=0;
		rep(i,n){
			cin>>alt;
			s[i]="";
			rep(j,alt.size()){
				if(j==0)s[i]+=alt[j];
				if(bo(alt[j]))s[i]+=alt[j+1];
			}
			m=max(m,s[i].size());
		}
		set<string> st;
		int ans=0;
		loop(k,1,m+1){
			st.clear();
			bool check=true;
			rep(i,n){
				if(st.find(s[i].substr(0,k))==st.end())st.insert(s[i].substr(0,k));
				else{
					check=false;
					break;
				}
			}
			if(check){
				ans=k;
				break;
			}
		}
		cout<<((ans==0)?-1:ans)<<endl;
	}
	return 0;
}

Measured memory_bytes: 3108
nums = input().split()
a = int(nums[0])
b = int(nums[1])
c = int(nums[2])
if a <= b <= c:
    print(a, b, c)
elif a <= c <= b:
    print(a, c, b)
elif b <= a <= c:
    print(b, a, c)
elif b <= c <= a:
    print(b, c, a)
elif c <= a <= b:
    print(c, a, b)
else:
    print(c, b, a)

Measured memory_bytes: 6724
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.List;

public class Main {

    public static void main(String[] args) throws Exception {

        InputStreamReader is = new InputStreamReader(System.in);
        BufferedReader reader = new BufferedReader(is);

        List<String> mylist = new ArrayList<>();

        // 標準入力からの値を変数strinputに代入
        String strinput = reader.readLine();

        while (strinput != null) {

            mylist.add(strinput);
            strinput = reader.readLine();

        }

        String arr01[] = mylist.get(0).split(" ");

        long k = Long.valueOf(arr01[0]);
        long x = Long.valueOf(arr01[1]);

        System.out.println(k * 500 >= x ? "Yes" : "No");

    }

}

Measured memory_bytes: 21076
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <chrono>

    #pragma GCC optimize("O3")
    #pragma GCC optimize("Ofast")
    #pragma GCC optimize("unroll-loops")
    /*#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
    #pragma GCC target ("avx2")*/

using namespace std;
using namespace __gnu_pbds;

typedef long long ll;

ll MAX = 1e15;
double PI = 3.141592653589793238463;
//double PI = acos(-1);
typedef tree<ll, null_type, less<ll>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;


void solve(){
    ll k;
    cin >> k;
    string s;
    cin >> s;
    ll n = s.size();
    for(ll i=0; i<min(n,k); i++){
        cout << s[i];
    }
    if(n>k){
        cout << "...";
    }
}

int main() {
    ios_base::sync_with_stdio(0); cin.tie(0);
    #ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
    #endif


    ll t=1;
    //cin >> t;
    while(t--){
        solve();
    }


    return 0;
}


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

int main() {
	int h,w;
	cin>>h>>w;
	int c[15][15], d[15][15];;
	for(int i=0;i<10;++i) {
		for(int j=0;j<10;++j) {
			cin>>c[i][j];
			d[i][j] = c[i][j];
		}
	}
	for(int k=0;k<10;++k) {
		for(int i=0;i<10;++i) {
			for(int j=0;j<10;++j) {
				if(d[i][k]+d[k][j] < d[i][j])
				d[i][j] = d[i][k]+d[k][j];
			}
		}
	}
	int ans = 0;
	for(int i=0;i<h;++i) {
		for(int j=0;j<w;++j) {
			int x;
			cin>>x;
			if(x!=-1 && x!=1) {
				ans += d[x][1];
			}
		}
	}
	cout<<ans;
	return 0;
}

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

#define endl '\n'

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

    long long n,k; cin >> n >> k;
    int a[n];

    vector<int> cycle;
    for(int i=0; i<n; i++){
        cin >> a[i];
        a[i]--;
    }
    set<int> used;
    int p = 0;
    while(!used.count(p)){
        used.insert(p);
        cycle.push_back(p);
        p = a[p];
    }
    if (k < cycle.size()){
        cout << cycle[k] + 1 << endl;
        return 0;
    }

    int first = 0;
    for (int i=0; i<cycle.size(); i++){
        if (cycle[i] == p){
            first = i;
            break;
        }
    }
    k -= cycle.size();
    k %= (long long)(cycle.size() - first);
    cout << cycle[first + k] + 1<< endl;
}

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

int main(){
  int n, x, z, s = 0;
  int S[100000] ={};

  for( int h = 0; 1; h++) {
    cin >> n >> x;
    if( n == 0 && x == 0) break;
    
    for( int i = 1; i <= n - 2; i++){
      for( int j = 1 + i; j <= n - 1; j++){
        for( int k = 1 + j; k <= n; k++){
          if( i + j + k == x) s++;
        }
      }
    }
    S[h] = s;
    s = 0;
    z = h;
  }

  for( int h = 0; h <= z; h++) {
    cout << S[h] << endl;
  }

  return 0;
}

Measured memory_bytes: 3488
import java.util.Scanner;

public class Main {

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

		String s1 = sc.next();
		String s2 = sc.next();
		String s3 = sc.next();

		String S1 = s1.toUpperCase();
		String S2 = s2.toUpperCase();
		String S3 = s3.toUpperCase();

		System.out.print(S1.charAt(0));
		System.out.print(S2.charAt(0));
		System.out.print(S3.charAt(0));
	}

}


Measured memory_bytes: 21844
/*
.   Bismillahir Rahmanir Rahim
.   Author - Marajul islam
.   created- Sun May 31 18:10:29 2020

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


 
int sc1() {int x; scanf("%d", &x); return x;}
long long sc2() {long long x; scanf("%lld", &x); return x;}

const int mod= 1e9 + 7;
inline int add(int a, int b) {a += b; return a >= mod ? a - mod : a;}
inline int sub(int a, int b) {a -= b; return a < 0 ? a + mod : a;}
inline int mul(int a, int b) {return (long long)a * b % mod;}
 
#define F               first
#define S               second 
#define mp              make_pair
#define pb              push_back
#define pf              push_front
#define speed_up        ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0)
#define sz(x)           (int)x.size()
#define all(x)          x.begin(), x.end()
#define debug           cerr << "OK\n";
#define ub              upper_bound
#define lb              lower_bound
#define gcd(a,b)        __gcd(a,b)
#define lcm(a,b)        (a*b)/gcd(a,b)
#define Int             sc1()
#define LL              sc2()
#define For(n)          for(int i=0;i<n;i++)
#define Forj(n)         for(int j=0;j<n;j++)
#define Fork(n)         for(int k=0;k<n;k++)
#define For1(n)         for(int i=1;i<=n;i++)

typedef long long       ll;
typedef vector<int>     vi;
typedef vector<ll>      vll;
typedef pair<int, int>  pii;
typedef pair<ll, ll>    pll;
typedef vector<pii>     vpii;
typedef set <int>       si;
typedef set <ll>        sll;
typedef multiset <int>  msi;
typedef multiset <ll>   msll;
typedef map <int, int>  mi;
typedef map <ll, ll>    mll;

#define error(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args); }
void err(istream_iterator<string> it) {cout << endl;}
template<typename T, typename... Args> void err(istream_iterator<string> it, T a, Args... args) {
    cerr << *it << " = " << a << ", ";
    err(++it, args...);
}
  
const int inf           = (int)2e9 + 5;
const ll  Inf           = (ll)1e18 + 5;
const int N             = 5e6 + 5;
 
 
 
int solve() {
 

 	int n=Int;
 	long double arr[n+1];
 	int f=0;
 	for(int i=0;i<n;i++){
 		cin>>arr[i];
 		if(arr[i]==0) {f=1;}
 	}
 	if(f==1) cout<<0<<endl;
 	else{
 		long double ans=1.0;
 		for(int i=0;i<n;i++){
 			long double pk=1000000000000000000.0/ans;
 			// cout<<fixed<<pk<<endl;
 			if(arr[i]>pk) {cout<<-1<<endl;return 0;}
 			ans*=arr[i];
 		}
 		cout<<(ll)ans<<endl;
 	}
	return 0;
}
 
 
 
 
int main()
{
	//speed_up;
	//freopen("input.txt", "r", stdin);
	//freopen("output.txt", "w", stdout);
 
	int test = 1, tc = 0;
	//scanf("%d", &test);
	//cin >> test;
	while (test--) {
		//printf("Case %d: ", ++tc);
		solve();
	}
 
	return 0;
 
 
 
 
}




Measured memory_bytes: 5360