akhauriyash/Code-Regression huggingface dataset:
N, K = map(int, input().split())
H = list(map(int, input().split()))

dp = [0 for _ in range(N)]
for i, hi in enumerate(H):
    if i == 0:
        continue
    r = max(0, i - K)
    dp[i] = min(d + abs(hi - h) for d, h in zip(dp[r:i], H[r:i]))
print(dp[N-1])

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

int main(){
 int N;
 cin >> N;
 vector<int> H(0);
 for(int i=0;i<N;i++){
   int a;
   cin >>a;
   H.push_back(a);
 }
 H.push_back(1000000001);
 int count = 0;
 int maximum = 0;
 for(int i=0;i<N;i++){
   if(H.at(i)>=H.at(i+1)){
     count ++;
     continue;
   }else{
    maximum = max(maximum,count);
    count = 0;
   }
 }
 cout << maximum;
}

Measured memory_bytes: 892
#include <stdio.h>

int main (void)
{
    long long N, A, B;
    scanf("%lld%lld%lld", &N, &A, &B);

    if (A == 0) {
        printf("%lld", 0);
    } else {
        long long rem = (N % (A+B));
        if (rem > A) {
            printf("%lld", (N / (A+B))*A + A);
        } else {
            printf("%lld", (N / (A+B))*A + rem);
        }
        
    }

    return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <cstdio>
#include <cmath>
#include <string>
#include <algorithm>
#include <map>
using namespace std;
typedef long long ll;

int main(){
  int a,b,c;cin>>a>>b>>c;
  if(a==b&&a!=c){
    cout<<"Yes"<<endl;
  }else if(a!=b&&a==c){
    cout<<"Yes"<<endl;
  }else if(a!=b&&b==c){
    cout<<"Yes"<<endl;
  }else{
    cout<<"No"<<endl;
  }
}

Measured memory_bytes: 256
/**
 *      purpose : 
 *      author  : kyomukyomupurin
 *      created : 
**/
#pragma GCC optimize("Ofast")
#pragma GCC target("avx")
// input/output
#include <iostream>
#include <fstream>
#include <sstream>
// container class
#include <array>
#include <deque>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <vector>
// math, algorithm
#include <algorithm>
#include <cmath>
#include <complex>
#include <numeric>
// etc
#include <bitset>
#include <cassert>
#include <cctype>
#include <cstring>
#include <chrono>
#include <functional>
#include <iomanip>
#include <random>
#include <utility>
// using-directive
using namespace std;
// alias template
using int64 = long long;
using uint64 = unsigned long long;
using vi = vector<int>;
using vl = vector<int64>;
using pii = pair<int, int>;
using pll = pair<int64, int64>;
// text macro replacement
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()
#define print(x) cout << (x) << '\n'
#define debug(x) cerr << #x << ": " << (x) << '\n'
#define dbg(v) for (size_t _ = 0; _ < v.size(); ++_){cerr << #v << "[" << _ << "] : " << v[_] << '\n';}
// variadic template
template<typename T> inline void chmin(T &a, T b) {if (a > b) a = b; return;}
template<typename T> inline void chmax(T &a, T b) {if (a < b) a = b; return;}
// constant
const int INF = (1<<30) - 1;
const int64 INF64 = (1LL<<62) - 1;
const int MOD = 1000000007;
constexpr int cm = 1<<17;
char buff[cm], *ci = buff + cm, ct;

inline char readchar() {
  if (ci - buff == cm) {
    fread(buff, 1, cm, stdin);
    ci = buff;
  }
  return *ci++;
}

inline int readint() {
  int num = 0;
  if (ci - buff + 16 > cm) {
    while ((ct = readchar()) >= '0') {
      num = (num << 3) + (num << 1) + ct - '0';
    }
  } else {
    while ((ct = *ci++) >= '0') {
      num = (num << 3) + (num << 1) + ct - '0';
    }
  }
  return num;
}
template<typename T> void fastout(T &n) {
  T N = n, rev, count = 0;
  rev = N;
  if (N == 0) {
    putchar_unlocked('0');
    putchar_unlocked('\n');
    return;
  }
  while ((rev % 10) == 0) { 
    ++count; rev /= 10;
  }
  rev = 0;
  while (N != 0) { 
    rev = (rev << 3) + (rev << 1) + N % 10;
    N /= 10;
  }
  while (rev != 0) { 
    putchar_unlocked(rev % 10 + '0');
    rev /= 10;
  }
  while (count--) putchar_unlocked('0');
  putchar_unlocked('\n');
}
vector<int> graph[202020];
vector<int> score(202020, 0);

void dfs(int cur, int prev) {
  score[cur] += score[prev];
  for (int next : graph[cur]) {
    if (next == prev) continue;
    dfs(next, cur);
  }
}

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

  int n = readint(), q = readint();
  for (int i = 0; i < n - 1; ++i) {
    int a = readint(), b = readint();
    graph[a].emplace_back(b);
    graph[b].emplace_back(a);
  }

  for (int i = 0; i < q; ++i) {
    int p = readint(), x = readint();
    score[p] += x;
  }

  dfs(1, 0);

  for (int i = 1; i <= n; ++i) {
    fastout(score[i]);
  }

  return 0;
}


Measured memory_bytes: 20224
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N;
  int j;
  j = 0;
  cin >> N;
  for (int i = 0; i < N; i++) {
    string C;
    cin >> C;
      if(C == "Y"){
        j = 1;
        break;
      }
  }
    if(j == 0) {
      cout << "Three" << endl;
    }
    else if(j == 1) {
      cout << "Four" << endl;
  }
}
  
  

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
  long mod = 1000000007;
long sigma(long n){
  return (n+1)*n/2%mod;
}

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

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

  for(int i=0;i<N;i++){
    long inloop =0;
    for(int j=0;j<N;j++){
      if(i!=j){
        if(A[i]>A[j]) inloop++;
      }
    }
    ans+=inloop*sigma(K-1);
    ans %= mod;
  }
  //cout<<ans<<endl;

  for(int i=0;i<N;i++){
    for(int j=i+1;j<N;j++){
      if(i!=j){
        if(A[i]>A[j]) ans+=K;
      }
    }
    ans %= mod;
  }

  cout<<ans<<endl;


}


Measured memory_bytes: 256
def bubble(A):
    flag = 1
    n = len(A)
    cnt = 0
    while flag:
        flag = 0
        for j in range(n-1, 0, -1):
          if A[j][1] < A[j-1][1]:
            A[j], A[j-1] = A[j-1], A[j]
            flag = 1
        cnt += 1
  
   
            
def selection(A):
    n = len(A)
    
    for i in range(n):
      minj = i
      for j in range(i,n):
        if A[j][1] < A[minj][1]:
          minj = j
      A[i], A[minj] = A[minj], A[i]
    
  
    
  
n = int(input())
ss = [x for x in input().split()]
ss2 = ss.copy()

bubble(ss)
for i in range(len(ss)-1):
  print(ss[i], end=" ")
print(ss[-1])
print('Stable')

selection(ss2)
for i in range(len(ss2) - 1):
  print(ss2[i], end=" ")
print(ss2[-1])
if ss == ss2:
  print('Stable')
else:
  print('Not stable')
  



Measured memory_bytes: 5616
#include<iostream>
#include<vector>
using namespace std;
int main(){
	int n;
	cin >> n;
	vector<long long> a(n+1,0);
	for(int i=1;i<=n;i++){
		cin >> a[i];
		a[i]+=a[i-1];
	}
	long long ans=abs((a[n]-a[1])-a[1]);
	for(int i=2;i<n;i++){
		ans=min(ans,abs((a[n]-a[i])-a[i]));
	}
	cout << ans << endl;
}


Measured memory_bytes: 1792
#include<bits/stdc++.h>
//#include<atcoder/all>
// Begin Header {{{
//using namespace atcoder;
using namespace std;
using ll = long long;
using P = pair<ll, ll>;
using Graph = vector<vector<ll>>;
#define rep(i,n) for(ll i=0; i<n; i++)
#define loop(i, j, n) for(ll i=j; i<n; i++)
#define all(x) (x).begin(), (x).end()
#define UNIQUE(v) v.erase(unique(all(v)), v.end());
#define Sp(p) cout<<setprecision(25)<< fixed<<p<<endl;
constexpr int INF  = 0x3f3f3f3f;
const long long mod=1e9+7;
const long double PI = acos(-1);
template<class T, class S> inline bool chmax(T &a, const S &b) { if (a<b) { a = b; return 1; } return 0; }
template<class T, class S> inline bool chmin(T &a, const S &b) { if (a>b) { a = b; return 1; } return 0; }
template<class T> void scan(T &a) { cin >> a; }
void IN() {}
template<class Head, class... Tail> void IN(Head &head, Tail &... tail){ scan(head); IN(tail...); }
// }}} End Header
int main() {
	int dx[9] = {1, 1, 1, 0, 0, -1, -1, -1};
	int dy[9] = {0, 1, -1, 1, -1, 1, 0, -1};
	ll h, w;
	cin >> h >> w;
	vector<string> s(h);
	rep(i,h) cin >> s[i];

	rep(i,h){
		rep(j,w){
			if(s[i][j] == '#') continue;
			int cnt=0;
			rep(t, 9){
				if(i+dx[t] < 0 || i+dx[t] >=h || j+dy[t] < 0 || j+dy[t]>=w) continue;
				if(s[i+dx[t]][j+dy[t]] == '#') cnt++;
			}
			s[i][j] = char('0'+cnt);
		}
	}
	rep(i,h) cout << s[i] << endl;
	return 0;
}


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

int main()
{
  int n;
  while (cin >> n) {
    if (n == 0)
      break;

    vector<vector<int> > c(2, vector<int>(n));
    for (int i = 0; i < n; ++i)
      cin >> c[0][i];
    sort(c[0].begin(), c[0].end());

    for (int i = 1, j = 0; i <= 2*n; ++i) {
      if (!binary_search(c[0].begin(), c[0].end(), i))
	c[1][j++] = i;
    }

    int t = 0;
    while (!c[0].empty() && !c[1].empty()) {
      int num = 0;
      for ( ; ;++t) {
	vector<int>::iterator it = upper_bound(c[t&1].begin(), c[t&1].end(), num);
	if (it == c[t&1].end())
	  break;
	num = *it;
	c[t&1].erase(it);
	if (c[t&1].empty())
	  break;
      }
      ++t;
    }

    cout << c[1].size() << endl << c[0].size() << endl;
  }
  return 0;
}

Measured memory_bytes: 0
#!/usr/bin/env python
#pyrival orz
import os
import sys
from io import BytesIO, IOBase

"""
    for _ in range(int(input())):
    n,m=map(int,input().split())
    n=int(input())
    a = [int(x) for x in input().split()]
"""

def main():
    l,r,n=map(int,input().split())
    ans=0
    for i in range(l,r+1):
        ans+=(i%n==0)
    print(ans)
# region fastio

BUFSIZE = 8192


class FastIO(IOBase):
    newlines = 0

    def __init__(self, file):
        self._fd = file.fileno()
        self.buffer = BytesIO()
        self.writable = "x" in file.mode or "r" not in file.mode
        self.write = self.buffer.write if self.writable else None

    def read(self):
        while True:
            b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
            if not b:
                break
            ptr = self.buffer.tell()
            self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)
        self.newlines = 0
        return self.buffer.read()

    def readline(self):
        while self.newlines == 0:
            b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
            self.newlines = b.count(b"\n") + (not b)
            ptr = self.buffer.tell()
            self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)
        self.newlines -= 1
        return self.buffer.readline()

    def flush(self):
        if self.writable:
            os.write(self._fd, self.buffer.getvalue())
            self.buffer.truncate(0), self.buffer.seek(0)


class IOWrapper(IOBase):
    def __init__(self, file):
        self.buffer = FastIO(file)
        self.flush = self.buffer.flush
        self.writable = self.buffer.writable
        self.write = lambda s: self.buffer.write(s.encode("ascii"))
        self.read = lambda: self.buffer.read().decode("ascii")
        self.readline = lambda: self.buffer.readline().decode("ascii")


sys.stdin, sys.stdout = IOWrapper(sys.stdin), IOWrapper(sys.stdout)
input = lambda: sys.stdin.readline().rstrip("\r\n")

# endregion

if __name__ == "__main__":
    main()

Measured memory_bytes: 62788
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <cctype>
#include <cassert>
#include <climits>
#include <string>
#include <bitset>
#include <cfloat>
#include <unordered_set>
#include <unordered_map>
#include <iomanip>
//#pragma GCC optimize("Ofast")
//#define _GLIBCXX_DEBUG
using namespace std;
typedef long double ld;
typedef long long int ll;
typedef unsigned long long int ull;
//#define int ll
typedef vector<int> vi;
typedef vector<char> vc;
typedef vector<bool> vb;
typedef vector<double> vd;
typedef vector<string> vs;
typedef vector<ll> vll;
typedef pair<int,int> pii;
typedef vector<pair<int,int> > vpii;
typedef vector<vector<int> > vvi;
typedef vector<vector<char> > vvc;
typedef vector<vector<string> > vvs;
typedef vector<vector<ll> > vvll;
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define irep(it, stl) for(auto it = stl.begin(); it != stl.end(); it++)
#define drep(i,n) for(int i = (n) - 1; i >= 0; --i)
#define fin(ans) cout << (ans) << '\n'
#define mp(p,q) make_pair(p, q)
#define pb(n) push_back(n)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define floatprec(dig) fixed << setprecision(dig)
#define Sort(a) sort(a.begin(), a.end())
#define Rort(a) sort(a.rbegin(), a.rend())
#define MATHPI acos(-1)
#define itn int;
#define invar(typ, var) typ var; cin >> var;
int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
template <class T> inline bool chmax(T& a,T b){if(a<b){a=b;return 1;} return 0;}
template <class T> inline bool chmin(T& a,T b){if(a>b){a=b;return 1;} return 0;}
struct io{io(){ios::sync_with_stdio(false);cin.tie(0);}};
const int INF = INT_MAX / 2;
const ll LLINF = 1LL<<60;
constexpr ll MOD = 1000000007;
const double EPS = 1e-9;

signed main(void) {
  cin.tie(0); ios::sync_with_stdio(false);
  
  int H, W;
  cin >> H >> W;
  vector<string> grid(H);
  rep(i, H) {
    cin >> grid[i];
  }
  
  vvi grid2(H, vi(W));
  
  queue<pair<int, int>> q;
  q.push(mp(0, 0));
  grid2[0][0] = -1;
  
  while(!q.empty()) {
    auto p = q.front();
    q.pop();
    int x = p.first;
    int y = p.second;
    if(x == W - 1 && y == H - 1) {
      grid[y][x] = 'x';
      break;  
    }
    
    if(grid[y][x] != 'x') {
      grid[y][x] = 'x';
      rep(i, 4) {
        int tx = x + dx[i];
        int ty = y + dy[i];
        if(tx >= 0 && tx < W && ty >= 0 && ty < H && grid[ty][tx] == '.') {
          grid2[ty][tx] = i;
          q.push(mp(tx, ty));
        }
      }
    }
  }
  
  if(grid[H - 1][W - 1] != 'x') {
    fin(-1);
    return 0;
  }
  
  int ddx = W - 1, ddy = H - 1;
  while(grid2[ddy][ddx] != -1) {
    grid[ddy][ddx] = 'y';
    int tx = ddx - dx[grid2[ddy][ddx]];
    int ty = ddy - dy[grid2[ddy][ddx]];
    ddx = tx;
    ddy = ty;
  }
  grid[0][0] = 'y';
  
  int ct = 0;
  rep(i, H) {
    rep(j, W) {
      if(grid[i][j] == 'x' || grid[i][j] == '.') {
        ct++;
      }
    }
  }
  
  fin(ct);
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
  int N;
  cin >> N;
  string S;
  cin >> S;
  string front="";
  string back="";
  for(int i=0;i<N/2;i++){
    front+=S[i];
    back+=S[i+N/2];
  }
  if (front==back && N%2==0) cout << "Yes";
  else cout << "No";
}


Measured memory_bytes: 256
#include<stdio.h>
#include<algorithm>
using namespace std;
int p[110000];
int sum[20][110000];
int sz[20];
int dp[1<<20];
int main(){
	int a,b;scanf("%d%d",&a,&b);
	for(int i=0;i<a;i++){
		scanf("%d",p+i);
		p[i]--;
		sum[p[i]][i+1]++;
		sz[p[i]]++;
	}
	for(int i=0;i<b;i++)for(int j=0;j<a;j++){
		sum[i][j+1]+=sum[i][j];
	}
	for(int i=0;i<(1<<b);i++)dp[i]=999999999;
	dp[0]=0;
	for(int i=0;i<(1<<b);i++){
		int pos=0;
		for(int j=0;j<b;j++)if(i&(1<<j))pos+=sz[j];
		for(int j=0;j<b;j++){
			if(i&(1<<j))continue;
			dp[i+(1<<j)]=min(dp[i+(1<<j)],dp[i]+sz[j]-sum[j][pos+sz[j]]+sum[j][pos]);
		}
	}
	printf("%d\n",dp[(1<<b)-1]);
}

Measured memory_bytes: 15100
package main

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

const (
	initialBufSize = 100000
	maxBufSize     = 10000000
)

var (
	sc = bufio.NewScanner(os.Stdin)
	wt = bufio.NewWriter(os.Stdout)
)

func next() string {
	sc.Scan()
	return sc.Text()
}

func nextInt() int {
	i, _ := strconv.Atoi(next())
	return i
}

func nextInt2() (int, int) {
	return nextInt(), nextInt()
}

func nextInt3() (int, int, int) {
	return nextInt(), nextInt(), nextInt()
}

func nextInt4() (int, int, int, int) {
	return nextInt(), nextInt(), nextInt(), nextInt()
}

func nextInts(n int) []int {
	slice := make([]int, n)
	for i := 0; i < n; i++ {
		slice[i] = nextInt()
	}
	return slice
}

func puts(a ...interface{}) {
	fmt.Fprintln(wt, a...)
}

func max(nums ...int) int {
	ret := nums[0]
	for _, v := range nums {
		if v > ret {
			ret = v
		}
	}
	return ret
}

func main() {
	sc.Split(bufio.ScanWords)
	sc.Buffer(make([]byte, initialBufSize), maxBufSize)
	defer wt.Flush()

	n := nextInt()
	p, idx := make([]int, n), make([]int, n)
	for i := range p {
		p[i] = nextInt() - 1
		idx[p[i]] = i
	}

	// 公差1の単調増加部分列の最長の長さを求める
	len, maxLen := 1, 1
	for i := 1; i < n; i++ {
		if idx[i-1] < idx[i] {
			len++
		} else {
			maxLen = max(maxLen, len)
			len = 1
		}
	}

	ans := n - max(maxLen, len)
	puts(ans)
}


Measured memory_bytes: 6096
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<algorithm>
using namespace std;

const int N=100005;

int n,m,cnt,last[N],dep[N],len,sx,sy,a[N],odd,even,s[N],k[N];
bool vis[N];
struct edge{int to,next;}e[N*2];

int read()
{
    int x=0,f=1;char ch=getchar();
    while (ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}
    while (ch>='0'&&ch<='9'){x=x*10+ch-'0';ch=getchar();}
    return x*f;
}

void addedge(int u,int v)
{
    e[++cnt].to=v;e[cnt].next=last[u];last[u]=cnt;
    e[++cnt].to=u;e[cnt].next=last[v];last[v]=cnt;
}

void dfs1(int x,int fa)
{
    vis[x]=1;
    if (dep[x]&1) even++;
    else odd++;
    for (int i=last[x];i;i=e[i].next)
    {
        if (e[i].to==fa) continue;
        if (vis[e[i].to]&&dep[e[i].to]<dep[x]) len=dep[x]-dep[e[i].to]+1,sx=x,sy=e[i].to;
        else if (!vis[e[i].to]) dep[e[i].to]=dep[x]+1,dfs1(e[i].to,x);
    }
}

void dfs2(int x)
{
    vis[x]=1;
    for (int i=last[x];i;i=e[i].next)
        if (!vis[e[i].to]) dfs2(e[i].to),s[x]+=s[e[i].to],k[x]+=k[e[i].to];
}

int main()
{
    n=read();m=read();
    for (int i=1;i<=m;i++)
    {
        int x=read(),y=read();
        addedge(x,y);
    }
    dfs1(1,0);
    if (odd!=even&&!(len&1)||(abs(odd-even)&1)&&(len&1)) {puts("-1");return 0;}
    for (int i=1;i<=n;i++) s[i]=(dep[i]&1)?1:-1;
    int ans=0;
    if (len&1) s[sx]+=(odd-even)/2,s[sy]+=(odd-even)/2,ans+=abs(odd-even)/2;
    else k[sx]=1,k[sy]=-1;
    memset(vis,0,sizeof(vis));
    dfs2(1);
    int tot=1;
    for (int i=1;i<=n;i++)
        if (!k[i]) ans+=abs(s[i]);
        else if (k[i]==1) a[++tot]=-s[i];
        else a[++tot]=s[i];
    sort(a+1,a+tot+1);
    int mid=a[(tot+1)/2];
    ans+=abs(mid);
    for (int i=1;i<=n;i++) if (k[i]) ans+=abs(k[i]*mid+s[i]);
    printf("%d",ans);
    return 0;
}

Measured memory_bytes: 8576
#include <stdio.h>
#include <cmath>
#include <algorithm>
#include <cfloat>
#include <stack>
#include <queue>
#include <vector>
#include <string>
#include <iostream>
#include <set>
#include <map>
#include <time.h>
typedef long long int ll;
typedef unsigned long long int ull;
#define BIG_NUM 2000000000
#define MOD 1000000007
#define EPS 0.000000001
using namespace std;


struct Info{
	char ch;
	bool FLG;
};
Info info[3];

char buf[501];

void func(){

	int index = 0,info_index;
	bool is_same,Found;

	while(buf[index] != '\0'){

		info_index = 0;

		is_same = true;

		for(;buf[index] != '|' && buf[index] != '\0'; ){
			switch(buf[index]){
			case '(':
				index++;
				break;
			case ')':
				index++;
				break;
			case '~':
				Found = false;

				for(int i = 0; i < info_index; i++){
					if(info[i].ch == buf[index+1]){
						if(info[i].FLG == true){
							is_same = false;
						}
						Found = true;
						break;
					}
				}
				if(!Found){
					info[info_index].ch = buf[index+1];
					info[info_index].FLG = false;
					info_index++;
				}
				index += 2;
				break;
			case '&':
				index++;
				break;
			default:
				Found = false;
				for(int i = 0; i < info_index; i++){
					if(info[i].ch == buf[index]){
						if(info[i].FLG == false){
							is_same = false;
						}
						Found = true;
						break;
					}
				}
				if(!Found){
					info[info_index].ch = buf[index];
					info[info_index].FLG = true;
					info_index++;
				}
				index += 1;
				break;
			}
		}
		if(buf[index] == '|')index++;

		if(is_same){
			printf("yes\n");
			return;
		}
	}

	printf("no\n");
}

int main(){

	while(true){
		scanf("%s",buf);
		if(buf[0] == '#')break;

		func();
	}

	return 0;
}

Measured memory_bytes: 3128
import java.util.Scanner;

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

	void solve() {
		Scanner sc = new Scanner(System.in);
		char[] C = sc.next().toCharArray();
		sc.close();

		if(C[0]!=C[1]&&C[0]!=C[2]&&C[1]!=C[2])System.out.println("Yes");
		else System.out.println("No");
	}
}


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

int main() {
	long t,h,m;
	std::cin >> t;
	h = t / 3600;
	t %= 3600;
	m = t/ 60;
	t %= 60;
	
	std::cout << h << ':' << m << ':' << t << std::endl;
}


Measured memory_bytes: 3096
#include <algorithm>
#include <array>
#include <bitset>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <vector>

#define REP(X, Y, Z) for (ll(X) = (Y); (X) < (Z); (X)++)
#define REV(X, Y, Z) for (ll(X) = (Y); (X) > (Z); (X)--)

using namespace std;
using ld = long double;
using ll = long long;
using dll = deque<ll>;
using pll = pair<ll, ll>;
using qll = queue<ll>;
using usll = unordered_set<ll>;
using umll = unordered_map<ll, ll>;
using sll = stack<int>;
using vll = vector<ll>;
using vvll = vector<vll>;

constexpr ll kMax = 1e12 + 1;
constexpr ll kMod = 1e9 + 7;
constexpr long double kPI = 3.14159265358979323846;

ll gcd(ll a, ll b) {
  if (a < b) {
    return gcd(b, a);
  }
  ll c = a % b;
  while (c != 0) {
    a = b;
    b = c;
    c = a % b;
  }
  return b;
}

ll lcm(ll a, ll b) {
  return a / gcd(a, b) * b;
}

void init() {
  cin.tie(nullptr);
  ios_base::sync_with_stdio(false);
  cout << fixed << setprecision(15);
}

int main() {
  init();

  ll H, W, K;
  cin >> H >> W >> K;
  vector<string> C(H);
  REP(i, 0, H) {
    cin >> C[i];
  }

  ll ans = 0;
  REP(h, 0, pow(2, H)) {
    REP(w, 0, pow(2, W)) {
      ll cnt = 0;
      REP(i, 1, H + 1) {
        REP(j, 1, W + 1) {
          if ((h & ll(pow(2, i - 1))) == ll(pow(2, i - 1))) {
            // nop
          } else {
            if ((w & ll(pow(2, j - 1))) == ll(pow(2, j - 1))) {
              // nop
            } else {
              if (C[i - 1][j - 1] == '#') {
                cnt++;
              }
            }
          }
        }
      }
      if (cnt == K) {
        ans++;
      }
    }
  }
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 4084
package main

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

var sc *bufio.Scanner

const bufferSize = 1024

func nextInt() int {
	if !sc.Scan() {
		panic(nil)
	}
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}

var production bool

func debugf(format string, v ...interface{}) {
	if !production {
		fmt.Printf(format, v...)
	}
}

func mpow(x, n, M uint64) uint64 {
	ans := uint64(1)
	for n != 0 {
		if n&1 == 1 {
			ans = ans * x % M
		}
		x = x * x % M
		n = n >> 1
	}
	return ans
}

func max(x, y int) int {
	if x > y {
		return x
	}
	return y
}

func min(x, y int) int {
	if x < y {
		return x
	}
	return y
}

func answer(reader io.Reader, writer io.Writer) {
	sc = bufio.NewScanner(reader)
	buf := make([]byte, bufferSize)
	sc.Buffer(buf, 1e+7)
	sc.Split(bufio.ScanWords)
	n := nextInt()
	a := nextInt()
	b := nextInt()

	mod := int(1e9) + 7
	ans := int(mpow(uint64(2), uint64(n), uint64(mod))) - 1

	debugf("%v\n", ans)
	nume := 1
	deno := 1
	for i := 0; i < min(a, b); i++ {
		nume *= n - i
		nume %= mod
		deno *= (i + 1)
		deno %= mod
	}
	ans -= int(uint64(nume) * mpow(uint64(deno), uint64(mod-2), uint64(mod)) % uint64(mod))
	debugf("%v\n", ans)
	if ans < 0 {
		ans += mod
	}
	for i := min(a, b); i < max(a, b); i++ {
		nume *= n - i
		nume %= mod
		deno *= (i + 1)
		deno %= mod
	}
	ans -= int(uint64(nume) * mpow(uint64(deno), uint64(mod-2), uint64(mod)) % uint64(mod))
	debugf("%v\n", ans)
	if ans < 0 {
		ans += mod
	}

	_, _ = fmt.Fprintf(writer, "%d", ans)
}

func main() {
	production = true
	answer(os.Stdin, os.Stdout)
}


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

int main()
{
	int d;
	while (cin >> d)
	{
		int ans = 0;
		for (int x = d; x < 600; x += d)
		{
			ans += x * x * d;
		}
		cout << ans << endl;
	}

	return 0;
}

Measured memory_bytes: 1160
#include <iostream>
using namespace std;
string s;
int mn=99, a[30], m[30];
int main() {
	int i, t;
	cin>>s;
	s = '.'+s;
	for(i=1; s[i]; i++) {
		t = s[i]-'a';
		m[t] = max(m[t], i-a[t]-1);
		a[t] = i;
	}
	for(i=0; i<26; i++) mn = min(mn, max(m[i], (int)s.size()-a[i]-1));
	cout<<mn;
	return 0;
}

Measured memory_bytes: 256
#include<cstdio>
#include<iostream>
#include<cstdlib>
#include<cmath>
#include<vector>
#include<map>
#include<algorithm>

using namespace std;

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

    vector<int> v1(100001, 0), v2(100001, 0);
    for (int i = 0; i < n; i++) {
        int vi;
        cin >> vi;
        if (i % 2 == 1) {
            v1[vi]++;
        } else {
            v2[vi]++;
        }
    }

    vector< pair<int, int> > v1_pair, v2_pair;
    for (int i = 0; i < 100001; i++) {
        v1_pair.push_back(make_pair(v1[i], i));
        v2_pair.push_back(make_pair(v2[i], i));
    }

    sort(v1_pair.begin(), v1_pair.end(), greater< pair<int, int> >());
    sort(v2_pair.begin(), v2_pair.end(), greater< pair<int, int> >());

    if (v1_pair[0].second != v2_pair[0].second) {
        cout << n - v1_pair[0].first - v2_pair[0].first << endl;
    } else {
        cout << min(n - v1_pair[0].first - v2_pair[1].first, n - v1_pair[1].first - v2_pair[0].first);
    }

    return 0;
}


Measured memory_bytes: 2804
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<cmath>
#include<functional>
#include<map>
#include<cstdlib>
#include<complex>
#include<numeric>
#include<set>
#include<deque>
#include<queue>

using namespace std;
using Int = long long;
Int INF = 1LL << 60;
const Int MOD = 1000000000 + 7;

int main() {

	cin.tie(nullptr);
	ios::sync_with_stdio(false);

	Int N, M, Q;
	cin >> N >> M >> Q;

	vector<vector<Int>> range(N);
	Int L, R;
	for (Int i = 0; i < M; i++) {
		cin >> L >> R;
		L--;
		R--;
		range[L].push_back(R);
	}

	for (Int i = 0; i < N; i++) {
		sort(range[i].begin(), range[i].end());
	}

	//クエリ
	Int p, q;
	for (Int i = 0; i < Q; i++) {
		cin >> p >> q;
		p--;
		q--;

		Int ans = 0;
		for (Int j = p; j <=q; j++) {
			ans += lower_bound(range[j].begin(), range[j].end(), q + 1) - range[j].begin();
		}

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

}


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


int main() {
    int n,k,sum(0);
    cin>>n>>k;
    int x[n];
    for (int i=0;i<n;i++) cin>>x[i];
    sort(x, x+n);
    for (int i=0;i<k;i++) sum+=x[i];
    cout<<sum;
}

Measured memory_bytes: 3632
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define M (2019)
ll l,r,ans=1e9;

int main(){
	scanf("%lld%lld",&l,&r);
	if (r-l>=2019){
		printf("0"); return 0;
	}
	for (int i=l;i<r;i++)
		for (int j=i+1;j<=r;j++)
			ans=min(ans,1ll*i%M*j%M);
	printf("%lld",ans);
}


Measured memory_bytes: 256
#include <iostream>
#include <cmath>
#include <string>
#include <algorithm>
#include <set>
#include <bits/stdc++.h>
using namespace std;

int main(){
    int N, D;
    int X[10][10];
    cin >> N >> D;
    for(int i=0;i<N;i++){
        for(int j=0;j<D;j++){
            cin >> X[i][j]; 
        }
    }
    double sum = 0;
    int cnt = 0;
    for(int i=0;i<N;i++){
        for(int j=i+1;j<N;j++){
            sum = 0;
            for(int k=0;k<D;k++){
                sum += double(double(double(X[i][k]) - double(X[j][k]))*double(double(X[i][k]) - double(X[j][k])));
            }
            //cout << sum <<" "<< i <<" "<< j <<endl;
            if (ceil(sqrt(sum)) == floor(sqrt(sum))) {
                cnt++;
            }
        }
    }
    cout << cnt << endl;


     
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define pb push_back
#define ll long long
#define mp make_pair
#define inf 1000000007
using namespace std;
set<double> lms[40009]; //idx*0.5sec 
void setadd(int lef, int rig, int lim, int n,int sum){
	double dlef = 1.0 * lef;
	double drig = 1.0 * rig;
	for(int i=0;i<=2*sum;i++){
		double ct = 0.5 * i;
		if(ct < dlef){
			lms[i].insert(lim+(dlef-ct));
		}
		else if(drig<ct){
			lms[i].insert(lim+(ct-drig));
		}
		else{
			lms[i].insert(lim);
		}
	}
}
signed main(){
	int n;
	cin>>n;
	vector<int> t,x;
	int sum = 0;
	for(int i=0;i<n;i++){
		int tt;
		cin>>tt;
		t.pb(tt);
		sum+=tt;
	}
	for(int i=0;i<n;i++){
		int tx;
		cin>>tx;
		x.pb(tx);
	}
	int cur = 0;
	setadd(0,0,0,n,sum);
	for(int i=0;i<n;i++){
		setadd(cur,cur+t[i],x[i],n,sum);
		cur += t[i];
	}
	setadd(cur,cur,0,n,sum);
	vector<double> flim;
	for(int i=0;i<=2*sum;i++){
		flim.pb(  *(lms[i].upper_bound(-1)) );
	}
	double ans=0;
	for(int i=0;i<2*sum;i++){
		ans += 0.25*(flim[i]+flim[i+1]);
	}
	cout<<setprecision(12)<<ans<<endl;
	return 0;
}

Measured memory_bytes: 193792
// clang-format off
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define main signed main()
#define loop(i, a, n) for (int i = (a); i < (n); i++)
#define rep(i, n) loop(i, 0, n)
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()
#define prec(n) fixed << setprecision(n)
constexpr int INF = sizeof(int) == sizeof(long long) ? 1000000000000000000LL : 1000000000;
constexpr int MOD = 1000000007;
constexpr double PI = 3.14159265358979;
template<typename A, typename B> bool cmin(A &a, const B &b) { return a > b ? (a = b, true) : false; }
template<typename A, typename B> bool cmax(A &a, const B &b) { return a < b ? (a = b, true) : false; }
bool odd(const int &n) { return n & 1; }
bool even(const int &n) { return ~n & 1; }
template<typename T> int len(const T &v) { return v.size(); }
template<typename T = int> T in() { T x; cin >> x; return x; }
template<typename T = int> T in(T &&x) { T z(forward<T>(x)); cin >> z; return z; }
template<typename T> istream &operator>>(istream &is, vector<T> &v) { for (T &x : v) is >> x; return is; }
template<typename A, typename B> istream &operator>>(istream &is, pair<A, B> &p) { return is >> p.first >> p.second; }
template<typename T> ostream &operator<<(ostream &os, const vector<vector<T>> &v) { int n = v.size(); rep(i, n) os << v[i] << (i == n - 1 ? "" : "\n"); return os; }
template<typename T> ostream &operator<<(ostream &os, const vector<T> &v) { int n = v.size(); rep(i, n) os << v[i] << (i == n - 1 ? "" : " "); return os; }
template<typename A, typename B> ostream &operator<<(ostream &os, const pair<A, B> &p) { return os << p.first << ' ' << p.second; }
template<typename Head, typename Value> auto vectors(const Head &head, const Value &v) { return vector<Value>(head, v); }
template<typename Head, typename... Tail> auto vectors(Head x, Tail... tail) { auto inner = vectors(tail...); return vector<decltype(inner)>(x, inner); }
// clang-format on

main {
  int q;
  cin >> q;
  vector<int> v;
  while (q--) {
    int t;
    cin >> t;
    if (t == 0) v.emplace_back(in());
    if (t == 1) cout << v[in()] << endl;
    if (t == 2) v.pop_back();
  }
}



Measured memory_bytes: 4948
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {

    public static void main(String[] args) {
        BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
        try {
//            char[] alphabet = "ABCDEFGHIJKLMNOPQRSTUVWXYZ".toCharArray();
            char[] alphabet = new char[26];
            char word = 'a';
            for (int x = 0; x <= ('z') - ('a'); x++) {
                alphabet[x] = word++;
            }

            int[] sum = new int[26];
            String line = null;
            while ((line = reader.readLine()) != null) {
                char[] chaAryLine = line.toLowerCase().toCharArray();

                for (int i = 0; i < line.length(); i++) {
                    for (int j = 0; j < sum.length; j++) {
                        if (alphabet[j] == chaAryLine[i]) {
                            sum[j]++;
                            break;
                        }
                    }
                }
            }
            for (int i = 0; i < 26; i++) {
                System.out.println(alphabet[i] + " : " + sum[i]);
            }
        } catch (IOException e) {
            System.out.println(e);
        }
    }
}

Measured memory_bytes: 24240
#include <vector>
#include <stack>
#include <queue>
#include <list>
#include <bitset>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <algorithm>
#include <numeric>
#include <iostream>
#include <iomanip>
#include <string>
#include <chrono>
#include <random>
#include <cmath>
#include <cassert>
#include <climits>
#include <cstring>
#include <cstdlib>
#include <functional>
#include <sstream>

using namespace std;

class Solution {
public:
    int solve(int x, int y) {
        const long long MOD = 1e9 + 7;
        auto norm = [&](long long a){
            a %= MOD;
            if (a < 0) {
                a += MOD;
            }
            return a;
        };

        auto inverse = [&](long long a) {
            long long b = MOD;
            long long u = 0, v = 1;
            a = norm(a);
            while (a != 0) {
                long long d = b / a;
                b -= d * a;
                u -= d * v;
                swap(a, b);
                swap(u, v);
            }
            u = norm(u);
            return u;
        };

        int N = x + y + 123;
        vector<long long> F(N + 1, 1);
        vector<long long> IF(N + 1, 1);
        for (int i = 1; i <= N; ++i) {
            F[i] = F[i - 1] * i % MOD;
        }
        IF[N] = inverse(F[N]);
        for (int i = N - 1; i > 0; --i) {
            IF[i] = IF[i + 1] * (i + 1) % MOD;
        }
        auto nCr = [&](int n, int r) {
            if (n < r || r < 0) {
                return 0LL;
            } 
            return F[n] * IF[r] % MOD * IF[n - r] % MOD;
        };

        if (x == 0) {
            if (y == 0) {
                return 1;
            }
            return 0;
        } 
        if (y == 0) {
            if (x == 0) {
                return 1;
            }
            return 0;
        }
        long long s = x + y;
        if (s % 3) {
            return 0;
        }
        long long a = y - s / 3;
        long long b = x - s / 3;

        auto res = nCr(a + b, a);
        return res;
    }
};

int main(int argc, char** argv) {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int x, y;
    cin >> x >> y;
    Solution sol;
    cout << sol.solve(x, y) << "\n";

    return 0;
}

Measured memory_bytes: 31488
#include <stdio.h>

void trace(int A[],int N){
  int i;
  for( i = 0; i < N; i++){
    if(i > 0){
      printf(" ");
    }
    printf("%d",A[i]);
  }
  printf("\n");
}

void insetionSort(int A[],int N){
  int j,i,v;
  for( i = 1; i < N; i++){
    v = A[i];
    j = i - 1;
    while( j >= 0 && A[j] > v){
      A[j + 1] = A[j];
      j--;
    }
    A[j + 1] = v;
    trace(A,N);
  }
}

int main(){
  int N,i,j;
  int A[100];

  scanf("%d",&N);
  for( i = 0; i < N; i++)scanf("%d",&A[i]);

  trace(A,N);
  insetionSort(A,N);

  return 0;
}



Measured memory_bytes: 2048
/*
String[]の初期化、整数の型がlongになっているか
関数（splitとかcontainsとか）内では"+"とかは正規表現となされるので"\\+"とする
配列のコピーはarr1=arr.clone()
HashSet<>[]はおのおの初期化した？？？？？
負の数の割り算は絶対値が小さいほうに切り捨てられるex.-1/2=0ので、ある値>kみたいな式だとバグらせやすいので注意
ある値>=kとして、切り上げた値をとるべき
toLowerCase()はアルファベット以外に対して行ってもエラーにはならない
ArrayDequeではpopとpushはStackと同じ操作になる
 */
//入力終了→Ctrl+D
//https://onlinejudge.u-aizu.ac.jp/#/problems/1257
import java.util.*;
import java.awt.*;
import java.awt.geom.Point2D;
import static java.lang.System.*;
import static java.lang.Math.*;
public class Main {
    public static void main(String[] $) {
        Scanner sc = new Scanner(in);
        int[] prime=Generate_prime(1000000);
        int m=prime.length;
        while (sc.hasNext()) {
            int n = sc.nextInt();
            if(n==0)exit(0);
            int ans = 0, sum = 0, right = 0;
            for (int left = 1; left < m + 1; left++) {
                while (right<m&&sum+prime[right]<n){
                    sum+=prime[right];
                    right++;
                }
                if(right<m&&sum+prime[right]==n){
                    ans++;
                }
                if(right==left)right++;
                else sum-=prime[left];
            }
            out.println(ans);
        }
    }
    static int[] Generate_prime(int n) {
        ArrayList<Integer> prime = new ArrayList<>();
        prime.add(2);
        prime.add(3);
        for (int i = 6; i <= n; i += 6) {
            int p1 = i - 1, p2 = i + 1;
            if (isPrime(p1)) prime.add(p1);
            if (isPrime(p2)) prime.add(p2);
        }
        int t=prime.size();
        int[] Generated_prime=new int[t+1];
        //Iteratorでもよい
        for (int i=1;i<=t;i++){
            Generated_prime[i]=prime.get(i-1);
        }
        return Generated_prime;
    }
    static boolean isPrime(int p){
        if(p==1)return false;
        int t= (int) (sqrt(p)+1);
        boolean f=true;
        for (int i = 5; i <= t && f; i++) if(p%i==0) f=false;
        return f;
    }
}


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

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

typedef long long ll;
using namespace std;
int mod = 1000000007;

int main(void){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int N; cin >> N;
    string S; cin >> S;
    int cnt[26] = {};
    rep(i, N) cnt[S[i]-'a']++;
    ll ans = 1;
    rep(i, 26){
        ans = (ans*(cnt[i]+1)) % mod;
    }
    ans--;
    cout << ans << endl;
    return 0;
}

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

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

    if(s=="RRR")
        cout << 3 << endl;
    else if(s=="RRS" || s=="SRR")
        cout << 2 << endl;
    else if(s=="SSS")
        cout << 0 << endl;
    else
        cout << 1 << endl;
}

Measured memory_bytes: 3616
N,K=map(int, input().split())
L=[0]*(10**5+1)

for i in range(N):
    a,b=map(int, input().split())
    L[a]+=b


res=K
for i,l in enumerate(L):
    if l>0:
        res-=l
        if res<=0:
            print(i)
            break
#print(L)

Measured memory_bytes: 5748
# from fractions import gcd
# mod = 10 ** 9 + 7
# N = int(input())
# a = list(map(int,input().split()))
# a,b,c = map(int,input().split())
# ans = [0] * N
# math.ceilで切り上げ
# dp = [[0] * 4 for i in range(3)] #2次元配列初期化
# dp = [[[0] * 2 for i in range(3)] for j in range(5)]
# (ord('A'))でASCII出力 Aは65
import math
import statistics
import string


def intinput():
    return int(input())
def listintinput():
    return list(map(int, input().split()))
def splitintinput():
    return map(int, input().split())
def factorialsurplus(x, y, z):  # xからyまでの階乗をzで割ったあまりを求める
    ret = 1
    for i in range(x, y + 1):
        ret = (ret * i) % z
    return (ret)
def isprime(x):
    if x == 1:
        return False
    if x == 2:
        return True
    sq = int(math.sqrt(x))
    for i in range(2,sq+1):
        if x % i == 0:
            return False
    return True
def hcfnaive(a,b):#最大公約数 math.gcdが使えない時の手段として入れとく。pythonが更新されたらいらなくなるはず
    if(b==0):
        return a
    else:
        return hcfnaive(b,a%b)

card = [[0] * 3 for i in range(3)]
bingo = [[0] * 3 for i in range(3)]
flag = 0
for i in range(3):
    card[i][0],  card[i][1], card[i][2] = splitintinput()

N = intinput()
for i in range(N):
    b = intinput()
    for j in range(3):
        for k in range(3):
            if card[j][k] == b:
                bingo[j][k] = 1

for i in range(3):
    for j in range(3):
        if bingo[i][j] == 0:
            break
    else:
        flag = 1

for i in range(3):
    for j in range(3):
        if bingo[j][i] == 0:
            break
    else:
        flag = 1

for i in range(3):
    if bingo[i][i] == 0:
        break
else:
    flag = 1

for i in range(3):
    if bingo[i][2-i] == 0:
        break
else:
    flag = 1

if flag == 0:
    print('No')
else:
    print('Yes')

Measured memory_bytes: 6044
#include <bits/stdc++.h>
using namespace std;
using ll = long long int;
using str = string;
using P = pair<int, int>;
using Pll = pair<ll, ll>;
const double PI = 3.141592653589793238;
const ll mod = 1000000007;
#define rep(i, n) for (int i = 0; i < (int)n; i++)
#define REP(i, m, n) for (int i = m; i < (int)n; i++)
#define all(a) (a).begin(), (a).end()
#define allg(a) (a).begin(), (a).end(), greator<>()
#define d20 std::setprecision(20)
#define veci vector<int>
#define vecll vector<long long int>
#define vecd vector<double>
template <typename T>
T lcm(T a, T b)
{
	return a / __gcd(a, b) * b;
}
void comb(vector<vector<long long int>> &v)
{
	for (int i = 0; i < v.size(); i++)
	{
		v[i][0] = 1;
		v[i][i] = 1;
	}
	for (int k = 1; k < v.size(); k++)
	{
		for (int j = 1; j < k; j++)
		{
			v[k][j] = (v[k - 1][j - 1] + v[k - 1][j]);
		}
	}
}
bool is_not_out_of_range(size_t now, size_t max_num)
{
	return !(now < 0 || max_num <= now);
}
ll repeat_squaring(ll n, ll p, ll m)
{
	if (p == 0)
		return 1;
	if (p % 2 == 0)
	{
		ll t = repeat_squaring(n, p / 2, m);
		return t * t % m;
	}
	return n * repeat_squaring(n, p - 1, m);
}

int main()
{
	int n, k;
	cin >> n >> k;
	int x, y;
	cin >> x >> y;
	int ans = 0;
	ans += min(n, k) * x;
	ans += (max(n, k) - k) * y;
	cout << ans << endl;
	return 0;
}

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

int main(){
    
    string S;
    cin >> S;
    string a = S.substr(5,2);
    int A;
    if(S.at(5) == '0'){
         A = stoi(a) % 10;
    }
    else A = stoi(a);
    
    if(A <= 4) cout << "Heisei" << endl;
    else cout << "TBD" << endl;
    
}


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

#define MAX 100000
int dp[MAX];
int minsteps(int h[], int n, int k, int i)
{
    if (i < 0)
    {
        return INT_MAX;
    }
    if (i == 0)
    {
        return dp[0];
    }
    if (dp[i] != -1)
    {
        return dp[i];
    }
    dp[i] = minsteps(h, n, k, i - 1) + abs(h[i] - h[i - 1]);
    for (int j = 1; j < k + 1; j++)
    {
        if ((i - j) >= 0)
            dp[i] = min(dp[i], minsteps(h, n, k, i - j) + abs(h[i] - h[i - j]));
    }
  	return dp[i];
}

int main()
{
    int n, k;
    cin >> n >> k;
    int h[n];
    for (int i = 0; i < n; i++)
    {
        cin >> h[i];
    }
    memset(dp, -1, sizeof(dp));
    dp[0] = 0;
    dp[1] = abs(h[1] - h[0]);
    cout << minsteps(h, n, k, n - 1) << endl;
}

Measured memory_bytes: 8832
#include<iostream>
#include<cstdio>
#include<cmath>
#include<cstdlib>
#include<climits>
#include<string>
#include<algorithm>
#include<vector>
#include<queue>
#include<stack>
#include<numeric>
#include<map>
#include<set>
#include<bitset>
using namespace std;
#define REP(i,m,n) for(int i = m; i < n; i++)
#define rep(i,n) REP(i,0,n)
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a)  (a).rbegin(),(a).rend()
#define PI 3.14159265359
typedef long long LL;

template<class T> inline void chmax(T& a, T b) { if (a < b) { a = b; } }
template<class T> inline void chmin(T& a, T b) { if (a > b) { a = b; } }
template<class T> void print_vector(vector<T> vec) {
	cout << "[ ";
	for (int i = 0; i < vec.size(); i++) {
		cout << vec[i] << " ";
	}
	cout << "]" << endl;
}
template<class T> void print_pair_vector(vector<pair<T, T> > vec) {
	cout << "[ ";
	for (int i = 0; i < vec.size(); i++) {
		cout << "(" << vec[i].first << "," << vec[i].second << ") ";
	}
	cout << "]" << endl;
}

const int INF = 1 << 30;

int main(void) {
	int X, A, B;
	cin >> X >> A >> B;

	if (A - B >= 0) {
		cout << "delicious" << endl;
	}
	else if (abs(A-B) <= X) {
		cout << "safe" << endl;
	}
	else {
		cout << "dangerous" << endl;
	}

	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, a, b) for (int i = a; i < b; i++)
#define all(v) v.begin(), v.end()
const int MOD = 1e9 + 7;
const int INF = 2e9;
//'A' = 65, 'Z' = 90, 'a' = 97, 'z' = 122

int main() {
    int n;
    cin >> n;
    int ans = pow(3, n);
    int x = 1;
    rep(i, 0, n) {
        int a;
        cin >> a;
        if (a % 2 == 0)  x *= 2;
    }
    ans -= x;
    cout << ans << endl;
    return 0;
}


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

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

    string ans="";

    while(n>0){
        n-=1;
        char tmp = ('a' + n % 26);
        ans=tmp+ans;
        n/=26;
    }

    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 3588
// This file is a "Hello, world!" in C++ language by GCC for wandbox.
#include <bits/stdc++.h>
using namespace std;

int main(){
    int n; cin >> n;
    vector<int> pos(n);
    
    for(int i = 0; i < n; i++){
        cin >> pos.at(i);
    }
    sort(pos.begin(), pos.end());

    
    cout << pos.at(n-1) - pos.at(0) << endl;
        
}



Measured memory_bytes: 256
from collections import deque
n=int(input())
l=[0]*n
d={}
for i in range(n-1):
    a,b,c=map(int,input().split())
    a-=1
    b-=1
    if a in d:
        d[a].add((b,c))
    else:
        d[a]={(b,c)}
    if b in d:
        d[b].add((a,c))
    else:
        d[b]={(a,c)}
q,k=map(int,input().split())
k-=1
p=deque([k])
while len(p):
    w=p.popleft()
    for i in d[w]:
        if (l[i[0]]==0 and i[0]!=k) or (l[i[0]]!=0 and l[i[0]]>l[w]+i[1]):
            l[i[0]]=l[w]+i[1]
            p.append(i[0])

for i in range(q):
    x,y=map(int,input().split())
    print(l[x-1]+l[y-1])


Measured memory_bytes: 61184
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
//#include <math.h>
//#include <queue>
//#include <stack>
//#include <iomanip>

// sometimes used
//#include <set>
//#include <map>
//#include <numeric>
//#include <list>
//#include <deque>
//#include <unordered_map>

typedef long long LL;
//typedef long double LD;
using namespace std;
 
//#define MOD 1000000007
//#define MAX 100100
//#define NIL -1
//#define INFTY 1000000000000000000

int main(){
    LL n;
    string s;
    cin >> n;
    cin >> s;

    vector<LL> num_s(n+1);
    vector<LL> num_d(n+1);
    num_s[0]=0;
    for(LL i=1; i<=n; i++){
        if(s[i-1]=='#'){
            num_s[i]=num_s[i-1]+1;
        }else{
            num_s[i]=num_s[i-1];
        }
    }

    num_d[n]=0;
    for(LL i=n-1; i>=0; i--){
        if(s[i]=='.'){
            num_d[i]=num_d[i+1]+1;
        }else{
            num_d[i]=num_d[i+1];
        }
    }

    LL ans=n;
    for(LL i=0; i<=n; i++){
        //cout << num_s[i] << " " << num_d[i] << endl;
        ans=min(ans, num_s[i]+num_d[i]);
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 6776
#include <algorithm>
#include <cstdio>
#include <iostream>
#include <map>
#include <cmath>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
#include <stdlib.h>
#include <stdio.h>
#include <bitset>
#include <cstring>
#include <deque>
#include <iomanip>
#include <limits>
#include <fstream>
using namespace std;
#define FOR(I,A,B) for(int I = (A); I < (B); ++I)
#define CLR(mat) memset(mat, 0, sizeof(mat))
typedef long long ll;

int main()
{
  ios::sync_with_stdio(false);
  cin.tie(0);
  int N, L;
  cin >> N >> L;
  int m = 100000000;
  FOR(i,L,L+N){
    if(abs(i)<abs(m)){
      m=i;
    }
  }
  cout << N*(L-1)+N*(N+1)/2-m << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define llong long long
#define pb(a) push_back(a)
#define INF 999999999
using namespace std;
typedef pair<int, int> P;
typedef pair<llong, llong> LP;
typedef pair<int, P> PP;
typedef pair<llong, LP> LPP;

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



int main() {
int a,b,c;
cin>>a>>b>>c;
int x;
cin>>x;
int ans=0;
for(int i=0; i<=a; i++){
    for(int j=0; j<=b; j++){
        for(int k=0; k<=c; k++)
        {
        if(500*i+100*j+50*k==x) ++ans;
        }
    }
}
cout<<ans<<endl;
}

Measured memory_bytes: 256