akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>

int n;
std::vector<int> vec;

int main() {
    std::cin >> n;
    vec.assign(n+1, 0);
    for (int i = 1; i <= n; i++) {
        std::cin >> vec[i];
    }
    
    for (int i = 1; i <= n; i++) {
        vec[i] = vec[i] + vec[i-1];
    }
    std::vector<int> res;
    for (int i = 1; i < n; i++) {
        res.push_back(std::abs(vec[i] - (vec[n] - vec[i])));
    }
    
    std::cout << *std::min_element(res.begin(), res.end()) << std::endl;
}


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

#define REP(i, n) for(int64_t i = 0; i < n; i++)
#define REPR(i, n) for(int64_t i = n; i >= 0; i--)
#define FOR(i, m, n) for(int64_t i = m; i < n; i++)
#define FORR(i, m, n) for(int64_t i = m; i >= n; i--)
#define ALL(v) v.begin(), v.end()
typedef long long ll;
template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
    fill( (T*)array, (T*)(array+N), val );
}
template<class T>
inline bool chmax(T &a, T b) {if(a < b) {a = b;return true;}return false;}
template<class T>
inline bool chmin(T &a, T b) {if(a > b) {a = b;return true;}return false;}
const ll INF= 1ll << 60;
const ll MOD = 1000000007;
double EPS = 1e-10;
//----------------------------------------------------------

int n, m;
int d[4];
bool db[4];

int main(){
    cin >> n >> m;
    int ans = 0;
    REP(i,m)
    {
        int s, c;
        cin >> s >> c;
        if(n!=1 && s==1 && c==0)
        {
            cout << -1 << endl;
            return 0;
        }
        if(!db[s])
        {
            d[s]=c;
            db[s]=true;
        }
        else
        {
            if(d[s]!=c)
            {
                cout << -1 << endl;
                return 0;
            }
        }
    }
    if(n!=1 && d[1]==0)
    {
        d[1]=1;
    }
    if(n==2){ans=d[1]*10+d[2];}
    else if(n==3){ans=d[1]*100+d[2]*10+d[3];}
    else ans=d[1];
    cout << ans << endl;
    return 0;
}

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

using namespace std;

int main(void) {
	int n, d, x;
	cin >> n >> d >> x;
	vector<int>a(n);
	vector<int>copy(n);
	for (int i = 0; i < n; i++) {
		cin >> a[i];
		copy[i] = a[i];
	}
	int ans = x;
	for (int i = 0; i < d; i++) {
		if (i == 0) {
			ans += n;
		}
		for (int j = 0; j < n; j++) {
			while (a[j] + 1 <= d) {
				ans++;
				a[j] += copy[j];
			}
		}
	}
	cout << ans;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
const int N = 3001;
string s, t;

int dp[N][N];

int calc(int i, int j)
{
	if(i == s.length() || j == t.length())	
		return 0;
	if(dp[i][j] != -1)
		return dp[i][j];
	
	if(s[i] == t[j])
	{
		return dp[i][j] = calc(i+1, j+1) + 1;
	}
	
	int val1 = calc(i+1, j);
	int val2 = calc(i, j+1);
	return dp[i][j] = max(val1, val2);
	
}


void print(int i, int j)
{
	if(i == s.length() || j == t.length())	
		return;
	if( calc(i, j) == calc(i+1, j)  )
	{
		print(i+1, j);
		return;
	}
	if( calc(i, j) == calc(i, j+1) )
	{
		print(i, j+1);
		return;
	}
	if(calc(i, j) == calc(i+1, j+1) + 1)
	{
		cout << s[i];
		print(i+1, j+1);
		return;
	}
}
int main() {
	cin >> s >> t;
	memset(dp, -1, sizeof dp);
	//cout << calc(0, 0) << endl;
	print(0, 0);
	
	return 0;
}

Measured memory_bytes: 39068
#include <iostream>
#include <queue>
#include <stdio.h>
using namespace std;


void shuffle(char* array){
    std::queue<char> card;
    for(int i=0; array[i]!='\0'; i++)
        card.push(array[i]);
    
    int m,n;
    cin >> m;
    
    while(m--){
        cin >> n;
        for(int i=0;i<n;i++){
            int a=card.front();
            card.pop();
            card.push(a);
        }
    }
    while(!card.empty()){
        cout << card.front();
        card.pop();
    }
    cout << endl;
}


int main() {
    // your code goes here
    char array[201];
    while(1){
        cin >> array;
        if(array[0]=='-')break;
        shuffle(array);
    }
    return 0;
}


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

int main(){
	int n,d,h[200],w[200],a;
	h[0]=0;
	w[0]=0;
	while(1){
		cin >> n;
		if(n==0){
			return 0;
		}
		for(int i=1;i<n;i++){
			cin >> a >> d ;
			h[i]=h[a];
			w[i]=w[a];
			if(d==0){
				w[i]++;
			}
			if(d==1){
				h[i]--;
			}
			if(d==2){
				w[i]--;
			}
			if(d==3){
				h[i]++;
			}
		}
		for(int i=1;i<n;i++){
			for(int j=0;j<n-i;j++){
				if(w[j]<w[j+1]){
					a=w[j];
					w[j]=w[j+1];
					w[j+1]=a;
				}
				if(h[j]<h[j+1]){
					a=h[j];
					h[j]=h[j+1];
					h[j+1]=a;
				}
			}
		}
		cout << w[0]-w[n-1]+1 << " " << h[0]-h[n-1]+1 << "\n";
	}
return 0;
}

Measured memory_bytes: 1160
def query(x):
    print("? " + " ".join(map(lambda x: str(x+1), x)), flush = True)
    return input()[0]
    
n = int(input())
A, B, l, r = [], [], [], []
chg1 = [i   for i in range(n)]
chg2 = [i+n for i in range(n)]

opt = ['Z' for i in range(n * 2)]

a, b = query(chg1), -1
if a == 'B': b = 'R'
else: b = 'B'

while len(chg1) > 1:
    H = len(chg1) // 2
    l = chg1[:H] + chg2[H:]
    r = chg2[:H] + chg1[H:]
    if query(A + l) == a:
        A += chg2[H:]
        B += chg1[H:]
        chg1 = chg1[:H]
        chg2 = chg2[:H]
    else:
        A += chg1[:H]
        B += chg2[:H]
        chg1 = chg1[H:]
        chg2 = chg2[H:]

opt[chg1[0]] = a
opt[chg2[0]] = b
for x in A:
    opt[x] = query(B + [x])
for x in B:
    opt[x] = query(A + [x])
print("! " + "".join(opt), flush = True)

Measured memory_bytes: 3532
"""
N = list(map(int,input().split()))
S = [str(input()) for _ in range(N)]
S = [list(map(int,list(input()))) for _ in range(h)] 
print(*S,sep="")
"""

import sys
sys.setrecursionlimit(10**6)
input = lambda: sys.stdin.readline().rstrip()
inf = float("inf") # 無限

n = int(input())
s = input()
ans=""
for _ in s:
    num = ord(_)+n
    if 90 < num:
        num -= 26
    ans+=chr(num)
print(ans)
# print(ord("A"))
# print(ord("Z"))

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

typedef unsigned long long int ULLI;

int n;
int ans;
ULLI used;
int bs[114514];
int cs[114514];
ULLI es[114514];
char buf[11451419];
string as[114514];
vector<string> ds[114514];
map<string, int> rev;

ULLI popcount(ULLI x) { 
  x = ((x & 0xaaaaaaaaaaaaaaaaUL) >> 1) 
    +  (x & 0x5555555555555555UL); 
  x = ((x & 0xccccccccccccccccUL) >> 2) 
    +  (x & 0x3333333333333333UL); 
  x = ((x & 0xf0f0f0f0f0f0f0f0UL) >> 4) 
    +  (x & 0x0f0f0f0f0f0f0f0fUL); 
  x = ((x & 0xff00ff00ff00ff00UL) >> 8) 
    +  (x & 0x00ff00ff00ff00ffUL); 
  x = ((x & 0xffff0000ffff0000UL) >> 16) 
    +  (x & 0x0000ffff0000ffffUL); 
  x = ((x & 0xffffffff00000000UL) >> 32) 
    +  (x & 0x00000000ffffffffUL); 
  return x; 
} 

void calc(int v, int sum) {
  if (v >= n || used == (1ULL << n)-1) {
    ans = max(ans, sum);
    return;
  }

  if (!(used >> v & 1)) {
    ULLI used_reserve = used;
    used |= 1ULL << v;
    used |= es[v];
    calc(v+1, sum+bs[v]);
    used = used_reserve;

    ULLI bits = es[v]&~used;
    int cnt = popcount(bits);
    if (cnt == 0) return;
    int idx = ffsll(bits)-1;
    if (cnt == 1 && bs[v] >= bs[idx]) return;
  }
  calc(v+1, sum);
}

int main() {
  while (1) {
    scanf("%d", &n);
    if (n == 0) return 0;

    rev.clear();
    for (int i=0; i<n; i++) {
      scanf(" %s %d %d", buf, &bs[i], &cs[i]);
      as[i] = string(buf);
      rev[as[i]] = i;
      ds[i].resize(cs[i]);
      for (int j=0; j<cs[i]; j++) {
        scanf(" %s", buf);
        ds[i][j] = buf;
      }
    }
  
    for (int i=0; i<n; i++) {
      es[i] = 0;
      for (int j=0; j<cs[i]; j++) {
        es[i] |= 1ULL << rev[ds[i][j]];
      }
    }

    int pre = bs[0];
    used = 1;
    used |= es[0]; 
    for (int i=1; i<n; i++) {
      if (used >> i & 1) continue;
      if (cs[i] == 0 || (cs[i] == 1 && bs[i] >= bs[rev[ds[i][0]]])) {
        pre += bs[i];
        used |= 1ULL << i;
        used |= es[i];
      }
    }
  
    //printf("%llx\n", used);
    ans = 0;
    calc(1, pre);
    printf("%d\n", ans);
  }
}

Measured memory_bytes: 6984
s = input()
text = 'abcdefghijklmnopqrstuvwxyz'
if len(s) < 26:
  for c in text:
    if c not in s:
      print(s + c)
      break
else:
  cand = {s[-1]}
  for i in range(1, len(s)):
    j = len(s) - i - 1
    if max(cand) > s[j]:
      print(s[:j] + min(c for c in cand if c > s[j]))
      break
    cand.add(s[j])
  else:
    print(-1)

Measured memory_bytes: 9148
points = [map(int, raw_input().split(' ')) for _ in range(int(raw_input()))]
def distance(u,v):
	return ((u[1] - v[1]) ** 2 + (u[0] - v[0]) ** 2) ** 0.5
c = [0,0]
def permut(i, points, c):
	if i == len(points):
		tot = 0
		for u,v in zip(points, points[1:]): tot += distance(u,v)
		c[0] +=  tot
		c[1] += 1
		return 
	for j in range(i,len(points)):
		points[i], points[j] = points[j], points[i]
		permut(i+1, points,c)
		points[i], points[j] = points[j], points[i]

permut(0, points,c)

print c[0] / float(c[1])

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

int main(){
    int a, b, c;
    cin >> a >> b >> c;
    
    vector<bool> isexist1(b, false);
    {
        int cur = a % b;
        while(!isexist1[cur]){
            isexist1[cur] = true;
            cur += a;
            cur %= b;
        }
    }

    vector<int> plusnum;
    for(int i = 1; i < b; i++){
        if(isexist1[i]) plusnum.push_back(i);
    }

    vector<bool> memo(b*100, false);
    memo[0] = true;
    for(int i = 1; i < b*100; i++){
        for(auto p : plusnum){
            if(i-p >= 0 && memo[i-p]){
                memo[i] = true;
                break;
            }
        }
    }

    string ans = "NO";
    for(int i = c; i < b*100; i += b){
        if(memo[i]){
            ans = "YES";
        }
    }
    cout << ans << endl;
    return 0;
}

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

int main() {
  int N, K, s=0;
  cin >> N >> K;
  int l[55];
  for (int i = 0; i < N; i++) cin >> l[i];
  
  sort(l, l+N, greater<int>());
  
  for (int j = 0; j < K; j++) s += l[j];
  
  cout << s << endl;
}

Measured memory_bytes: 256
import collections
n = int(input())
v = list(map(int,input().split()))
a = []
b = []
for i in range(n):
    if i % 2 == 1:
        a.append(v[i])
    elif i % 2 == 0:
        b.append(v[i])
ac = collections.Counter(a)
bc = collections.Counter(b)
p = ac.most_common()[0]
q = bc.most_common()[0]
if p[0] != q[0]:
    print(n - p[1] - q[1])
else:
    x = len(ac)
    y = len(bc)
    if x >= 2 and y >= 2: 
        r = ac.most_common()[1]
        s = bc.most_common()[1]
        if r[1] > s[1]:
            print(n - r[1] - q[1])
        elif r[1] <= s[1]:
            print(n - p[1] - s[1])
    elif x == 1 and y == 1:
        print(n//2)
    elif x == 1:
        s = bc.most_common()[1]
        print(n - p[1] - s[1])
    elif y == 1:
        r = ac.most_common()[1]
        print(n - r[1] - q[1])

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

using namespace std;

const int inf = 1e9;
int n,k,s;

template <typename T>
inline T
read()
{
  T sum = 0, fl = 1;
  int ch = getchar();
  for (; !isdigit(ch); ch = getchar())
    if (ch == '-') fl = -1;
  for (; isdigit(ch); ch = getchar()) sum = sum * 10 + ch - '0';
  return sum * fl;
}

inline void write(int x)
{
  static int sta[35];
  int top = 0;
  do {
    sta[top++] = x % 10, x /= 10;
  } while (x);
  while (top) putchar(sta[--top] + 48);
}

void blank()
{
    printf(" ");
}

int main()
{
	n = read<int>();
    k = read<int>();
    s = read<int>();
	for(int i = 1; i <= k; i ++) write(s), blank();
	if(s < inf) {
		for(int i = k + 1; i <= n; i ++) write(inf), blank();
	}
	else for(int i = k + 1; i <= n; i ++) write(1), blank();
	putchar(10);
	return 0;
}

Measured memory_bytes: 1280
/*
これを入れて実行
g++ code.cpp
./a.out
 */
 
#include <iostream>
#include <vector>
#include <string>
#include <queue>
#include <deque>
#include <algorithm>
#include <utility>
#include <set>
#include <map>
#include <cmath>
#include <math.h>
#include <tuple>
#include <iomanip>
 
using namespace std;
typedef long long ll;
typedef long double ld;
 
int dy4[4] = {-1, 0, +1, 0};
int dx4[4] = {0, +1, 0, -1};
int dy8[8] = {-1, -1, 0, 1, 1, 1, 0, -1};
int dx8[8] = {0, 1, 1, 1, 0, -1, -1, -1};
 
const long long INF = 1LL << 60;
const ll MOD = 1e9 + 7;
 
bool greaterSecond(const pair<int, int>& f, const pair<int, int>& s){
    return f.second > s.second;
}
 
ll gcd(ll a, ll b){
	if (b == 0)return a;
	return gcd(b, a % b);
}
 
ll lcm(ll a, ll b){
    return a / gcd(a, b) * b;
}
 
ll nCr(ll n, ll r){
    if(r == 0 || r == n){
        return 1;
    } else if(r == 1){
        return n;
    }
    return (nCr(n - 1, r) + nCr(n - 1, r - 1));
}
 
ll nPr(ll n, ll r){
    r = n - r;
    ll ret = 1;
    for (ll i = n; i >= r + 1; i--) ret *= i;
    return ret;
}
 
//-----------------------ここから-----------

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

    vector<int> l(n);

    for(int i = 0; i < n; i++) cin >> l[i];

    sort(l.begin(), l.end());

    int ans = 0;

    for(int i = 0; i < n; i++){
        for(int j = i + 1; j < n; j++){
            for(int k = j + 1; l[k] < l[i] + l[j]; k++){
                if(l[i] < l[k] + l[j] && l[j] < l[k] + l[i]){
                    ans++;
                }
            }
        }
    }

    cout << ans << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define Tp template<typename Ty>
#define Ts template<typename Ty,typename... Ar>
#define Reg register
#define RI Reg int
#define Con const
#define CI Con int&
#define I inline
#define W while
using namespace std;
int A,B,C;
int main()
{
	return scanf("%d%d%d",&A,&B,&C),printf("%d\n",B+min(C,A+B+1)),0;
}

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

int main(){

  int n;
  set<int> s;
  cin >> n;
  for(int i=0;i<n;i++){
    int x;
    cin >> x;
    s.insert(x);
  }
  cout << s.size() << endl;

  return 0;
}

Measured memory_bytes: 256
using System;
using System.Collections;
using System.Collections.Generic;
using System.IO;
using System.Linq;

namespace C
{
    public class Program
    {
        static void Main(string[] args)
        {
            var sw = new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
            Console.SetOut(sw);
            Solve();
            Console.Out.Flush();
        }

        public static void Solve()
        {
            var n = int.Parse(Console.ReadLine());
            var ai = Console.ReadLine().Trim().Split(' ').Select(int.Parse).ToArray();
            var order = ai.Select((a, index) => new { A = a, Index = (index + 1) }).OrderBy(x => x.A);
            Console.WriteLine(string.Join(" ", order.Select(x => x.Index).ToArray()));
        }
    }
}


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

def Check(x, y):
    flag = True
    for i in range(m):
        for j in range(m):
            if a[i + y][j + x] != b[i][j]: flag = False
    return flag

ans=False
for i in range(n - m + 1):
    for j in range(n - m + 1):
        if Check(i, j): ans = True
print('Yes' if ans else 'No')

Measured memory_bytes: 3064
#include <iostream>
#include <iomanip>
#include <vector>
#include <set>
#include <string>
#include <queue>
#include <algorithm>
#include <map>
#include <cmath>
#include <numeric>
#include <list>
#include <stack>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <tuple>
#include <deque>
#include <complex>

using namespace std;

/*
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int, int> pii;
typedef vector<pii> vpii;
*/

typedef long long ll;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef pair<long long, long long> pll;
typedef vector<pll> vpll;

typedef long double ld;
typedef vector<ld> vld;

typedef vector<bool> vb;

#define rep(i, n) for (ll i = 0; i < (n); i++)
#define reps(i, n) for (ll i = 1; i <= (n); i++)
#define rrep(i, n) for (ll i = (n) - 1; i >= 0; i--)
#define rreps(i, n) for (ll i = (n); i >= 1; i--)
#define all(v) (v).begin(), (v).end()

template <class T> void chmin(T& a, T b) { a = min(a, b);}
template <class T> void chmax(T& a, T b) { a = max(a, b);}

constexpr int INF = 1 << 30;
constexpr ll INFL = 1LL << 60;
constexpr ll MOD = 1000000007;
constexpr ld EPS = 1e-12;
ld PI = acos(-1.0);

void solve() {
    ll n;
    cin >> n;
    if(n == 1) {
        cout << "Hello World" << endl;
    }
    else {
        ll a, b;
        cin >> a >> b;
        cout << a + b << endl;
    }
    return;
}

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

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

using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vl = vector<ll>;
using vvl = vector<vl>;
using vb = vector<bool>;
using vvb = vector<vb>;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
#define rep(i, s, n) for(int i = (int)(s); i < (int)(n); i++)

ll INF = 1ll << 60;

int tate[4] = {0, 1, -1, 0};
int yoko[4] = {1, 0, 0, -1};

int main(){
  int H, W;
  cin >> H >> W;
  int sh, sw, gh, gw;
  cin >> sh >> sw >> gh >> gw;
  sh--;sw--;gh--;gw--;
  vector<string> S(H);
  rep(i, 0, H)
    cin >> S[i];
  
  vvi dist(H, vi(W, -1));
  rep(i, 0, H){
    rep(j, 0, W){
      if(S[i][j] == '#')
        dist[i][j] = -2;
    }
  }
  
  deque<pii> que;
  que.push_front(make_pair(sh,sw));
  
  while(que.size()){
    pii p = que.front();
    que.pop_front();
    int h = p.first, w = p.second;
    
    rep(i, 0, 4){
      int next_h = h + tate[i], next_w = w + yoko[i];
      if(next_h < 0 || next_h >= H || next_w < 0 || next_w >= W)
        continue;
      if(dist[next_h][next_w] == -2)
        continue;
      if(dist[next_h][next_w] == dist[h][w])
        continue;
      dist[next_h][next_w] = dist[h][w];
      que.push_front(make_pair(next_h, next_w));
    }
    
    rep(i, 0, 5){
      rep(j, 0, 5){
        int next_h = h + i -2, next_w = w + j -2;
        if(next_h < 0 || next_h >= H || next_w < 0 || next_w >= W)
          continue;
        if(dist[next_h][next_w] == -2)
          continue;
        if(dist[next_h][next_w] >= 0 && dist[next_h][next_w] <= dist[h][w])
          continue;
        
        dist[next_h][next_w] = dist[h][w] +1;
        que.push_back(make_pair(next_h, next_w));
      }
    }
  
  }
  
  cout << dist[gh][gw] << endl;
  
  return 0;
  
}

Measured memory_bytes: 10224
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cctype>
#include <climits>
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <string>
#include <sstream>
#include <vector>
#include <map>
#include <set>
#include <complex>
#include <functional>
#include <utility>
#include <iterator>

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

#ifdef LOCAL
  #define dprintf(...) fprintf(stdout, __VA_ARGS__)
#else
  #define dprintf(...) 0
#endif

using namespace std;

typedef long long LL;
typedef unsigned long long ULL;
typedef unsigned int uint;

//const double PI = 3.1415926535897932384626433832795;

int main() {
  string n;
  cin >> n;
  if(n.find("7") != string::npos) {
    cout << "Yes" << endl;
  }
  else {
    cout << "No" << endl;
  }
  return 0;
}


Measured memory_bytes: 3532
def modinv(a, mod=10**9+7):
    return pow(a, mod-2, mod)


def combination(n, r, mod=10**9+7):
    """
    nCr mod m
    """
    r = min(r, n-r)
    res = 1
    for i in range(r):
        res = res * (n - i) * modinv(i+1, mod) % mod
    return res


x, y = map(int, input().split())
if (x + y) % 3 != 0:
    print(0)
    exit()

n = (x + y) // 3
a = y - n

if a < 0 or a > n:
    print(0)
else:
    print(combination(n, a))

Measured memory_bytes: 40172
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        @SuppressWarnings("resource")
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        int b = sc.nextInt();
        System.out.println((b - 1 + a - 2) / (a - 1));
    }

}


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

using namespace std;

int main(){
  int A,B,X;
  cin >> A >> B >> X;
  if(A<=X && A+B>=X)  cout << "YES" << endl;
  else  cout << "NO" << endl;

  return 0;
}


Measured memory_bytes: 256
using System;
using static System.Console;
using static System.Int32;
using static System.Math;
using System.Linq;
using System.Collections.Generic;

class Solution
{
    static void Main()
    {
        ReadLine();
        char c = '_';
        int num = 0;
        foreach(char a in ReadLine())
        {
            if (a != c) ++num;
            c = a;
        }
        WriteLine(num);
    }
}


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

int main() {
	
	int n; cin >> n;
	vector<vector<int> > abc(n,vector<int>(3));//幸福度入れとく
	for (int i = 0; i < n; i++) { 
		for (int j = 0; j < 3; j++) {
			cin >> abc[i][j];
		}
	}
	
	vector<vector<int> > dp(n ,vector<int>(3, 0));
	dp[0][0] = abc[0][0]; dp[0][1] = abc[0][1]; dp[0][2] = abc[0][2];

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

			if (j != 0) { dp[i][j] = max(dp[i][j], abc[i][j] + dp[i - 1][0]); }
			if (j != 1) { dp[i][j] = max(dp[i][j], abc[i][j] + dp[i - 1][1]); }
			if (j != 2) { dp[i][j] = max(dp[i][j], abc[i][j] + dp[i - 1 ][2]); }
		
		}
	
	}

	/*for (int i = 0; i < n; i++) {
		for (int j = 0; j < 3; j++) {
			cout << dp[i][j] << " ";
		}
		cout << endl;
	}*/
	

	cout << max(max(dp[n - 1][0], dp[n - 1][1]),dp[n - 1][2]) << endl;

	return 0;
}

Measured memory_bytes: 11136
n,q = map(int,input().split())
ans = [0]*(n+1)
s = input()
for i in range(n):
    ans[i+1] = ans[i] + (1 if s[i:i+2]=='AC' else 0)
        
for i in range(q):
    l,r = map(int,input().split())
    print(ans[r-1]-ans[l-1])

Measured memory_bytes: 50776
#include<stdio.h>
int main(void) {
	int a, b, c, d;
	scanf("%d%d%d", &a, &b, &c);
	d = 0;
	if (a + b + c == 17) {
		if (a == 5 || a == 7) {
			if (b == 5 || b == 7) {
				if (c == 5 || c == 7) {
					d = 1;
				}
			}
		}
	}
	if (d == 1) {
		printf("YES\n");
	}
	else printf("NO\n");
	return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>

using namespace std;

int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(nullptr);
	const double PI  =3.141592653589793238463;
	double R;
	cin >> R;
	cout << 2 * PI * R << '\n';
	return 0;
}

Measured memory_bytes: 3792
#include<stdio.h>
int main(void)
{
	int a, b, c, d,flg = 0;
	scanf("%d%d%d%d", &a, &b, &c, &d);

	while (a > 0 && c > 0) {
		// 0なら高橋が攻撃
		if (flg == 0) {
			c -= b;

			flg++;
		}
		else {
			a -= d;

			flg--;
		}
	}

	if (a <= 0) {
		printf("No\n");
	}
	else {
		printf("Yes\n");
	}

	return 0;
}

Measured memory_bytes: 1660
# frozen_string_literal: true

# https://github.com/universato/ac-library-rb/blob/master/src/segtree.rb
# Segment Tree
class Segtree
  def initialize(arg, e, &block)
    case arg
    when Integer
      v = Array.new(arg) { e }
    when Array
      v = arg
    end

    @e  = e
    @op = block

    @n = v.size
    @log = ceil_pow2(@n)
    @leaf_size = 1 << @log
    @d = Array.new(@leaf_size * 2) { e }
    v.each_with_index { |v_i, i| @d[@leaf_size + i] = v_i }
    (@leaf_size - 1).downto(1) { |i| update(i) }
  end

  def set(q, x)
    q += @leaf_size
    @d[q] = x
    1.upto(@log) { |i| update(q >> i) }
  end

  def get(q)
    d[@leaf_size + q]
  end

  def prod(l, r)
    sml = @e
    smr = @e
    l += @leaf_size
    r += @leaf_size

    while l < r
      if l[0] == 1
        sml = @op.call(sml, @d[l])
        l += 1
      end
      if r[0] == 1
        r -= 1
        smr = @op.call(@d[r], smr)
      end
      l /= 2
      r /= 2
    end

    @op.call(sml, smr)
  end

  def all_prod
    d[1]
  end

  def max_right(l, &block)
    return @n if l == @n

    f = proc(&block)

    l += @leaf_size
    sm = @e
    loop do
      l /= 2 while l.even?
      unless f.call(@op.call(sm, @d[l]))
        while l < @leaf_size
          l *= 2
          if f.call(@op.call(sm, @d[l]))
            sm = @op.call(sm, @d[l])
            l += 1
          end
        end
        return l - @leaf_size
      end
      sm = @op.call(sm, @d[l])
      l += 1
      break if (l & -l) == l
    end

    @n
  end

  def update(k)
    @d[k] = @op.call(@d[2 * k], @d[2 * k + 1])
  end

  def inspect
    t = 0
    res = "SegmentTree\n  "
    a = @d[1, @d.size - 1]
    a.each_with_index do |e, i|
      res << e.to_s << ' '
      if t == i && i < @leaf_size
        res << "\n  "
        t = t * 2 + 2
      end
    end
    res
  end
end

SegTree     = Segtree
SegmentTree = Segtree

def ceil_pow2(n)
  x = 0
  x += 1 while (1 << x) < n
  x
end

INF = (1 << 60) - 1
_, q = gets.to_s.split.map{ |t| t.to_i }
a    = gets.to_s.split.map{ |t| t.to_i }
st = Segtree.new(a, -INF) { [_1, _2].max }
ans = []
q.times do
  query = gets.to_s.split.map{ |t| t.to_i }
  if query[0] == 1
    _, x, v = query
    st.set(x - 1, v)
  elsif query[0] == 2
    _, l, r = query
    ans << st.prod(l - 1, r)
  else
    _, x, v = query
    ans << st.max_right(x - 1) { _1 < v } + 1
  end
end
puts ans


Measured memory_bytes: 39928
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <math.h>
#include <vector>
#include <queue>
#include <algorithm>
#include <iostream>
#include <unordered_map>
#define maxn 100005
#define mod 998244353
using namespace std;
typedef long long LL;
LL a[maxn*10];
int pos=0;
void dfs(LL x)
{
    if(x>1e10) return ;
    pos++;
    a[pos]=x;
    int t=x%10;
    if(t==0) {dfs(x*10+0);dfs(x*10+1);}
    else if(t==9) {dfs(x*10+8);dfs(x*10+9);}
    else {dfs(x*10+t-1);dfs(x*10+t);dfs(x*10+t+1);}
}
int main()
{
    for(LL i=1;i<=9;i+=1)
        dfs(i);
    sort(a+1,a+pos+1);
    int k;
    scanf("%d",&k);
    printf("%lld",a[k]);
    return 0;
}


Measured memory_bytes: 1792
#include<stdio.h>
#include<iostream>
#include<vector>
#include<math.h>
#include<queue>
#include<map>
#include<algorithm>
#include<string.h>
#include<functional>
#include<limits.h>
#include<stdlib.h>
#include<string>
#include<unordered_map>
using namespace std;
 
#define intmax INT_MAX
#define lmax LONG_MAX
#define uintmax UINT_MAX
#define ulmax ULONG_MAX
#define llmax LLONG_MAX
#define ll long long
#define rep(i,a,N) for((i)=(a);(i)<(N);(i)++)
#define rrp(i,N,a) for((i)=(N)-1;(i)>=(a);(i)--)
#define llfor ll i,j,k
#define sc(a) cin>>a
#define pr(a) cout<<a<<endl
#define pY puts("YES")
#define pN puts("NO")
#define py puts("Yes")
#define pn puts("No")
#define pnn printf("\n")
#define sort(a) sort(a.begin(),a.end())
#define push(a,b) (a).push_back(b)
#define llvec vector<vector<ll>>
#define charvec vector<vector<char>>
#define sizeoof(a,b) (a,vector<ll>(b))
#define llpvec vector<pair<ll,ll>>
/*繰り上げ除算*/ll cei(ll x,ll y){ll ans=x/y;if(x%y!=0)ans++;return ans;}
/*最大公約数*/ll gcd(ll x,ll y){return y?gcd(y,x%y):x;}
/*最小公倍数*/ll lcm(ll x,ll y){return x/gcd(x,y)*y;}
/*n乗*/ll llpow(ll x,ll n){ll i,ans=1;rep(i,0,n)ans*=x;return ans;}
/*階乗*/ll fact(ll x){ll i,ans=1;rep(i,0,x)ans*=(x-i);return ans;}
/*nCr*/ll ncr(ll n,ll r){return fact(n)/fact(r)/fact(n-r);}
/*nPr*/ll npr(ll n,ll r){return fact(n)/fact(n-r);}
/*primejudge*/bool prime(ll a){if(a<=1)return false;ll i;for(i=2;i*i<=a;i++){if(a%i==0)return false;}return true;}
ll ans=0;llfor;///////////////////////////////////////////////////////////
int main(){
  int N;
  string S="Yes";
  cin>>N;
  if(N<30) S="No";
  cout<<S;
return 0;}


Measured memory_bytes: 3588
N,M = map(int,input().split())
S = list(map(int,input().split()))
T = list(map(int,input().split()))
MOD = 10**9+7

dp = [[1]*(M+1) for i in range(N+1)]

for i,s in enumerate(S):
    for j,t in enumerate(T):
        if s==t:
            dp[i+1][j+1] = dp[i+1][j] + dp[i][j+1]
        else:
            dp[i+1][j+1] = dp[i+1][j] + dp[i][j+1] - dp[i][j]
        dp[i+1][j+1] %= MOD
print(dp[-1][-1])

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

#define mp make_pair
#define fst first
#define snd second
#define forn(i,n) for (int i = 0; i < int(n); i++)
#define forn1(i,n) for (int i = 1; i <= int(n); i++)
#define popcnt __builtin_popcount
#define ffs __builtin_ffs

using namespace std;

typedef unsigned int uint;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef pair<ll,int> pli;
typedef pair<int,ll> pil;
typedef pair<ll,ll> pll;
template <typename T> using vec = vector<T>;
typedef vec<int> vi;
typedef vec<ll> vl;


template <typename T> T id(T b) {return b;};
template <class It> bool all(It f,It l){return std::all_of(f,l,id<bool>);}
template <class It> bool any(It f,It l){return std::any_of(f,l,id<bool>);}
template <typename T> void chmax(T &x, T y) {if (x < y) x = y;}
template <typename T> void chmin(T &x, T y) {if (x > y) x = y;}
void fastio() { ios_base::sync_with_stdio(false); cin.tie(nullptr); }
constexpr ll TEN(int n) { if (n == 0) return 1LL; else return 10LL*TEN(n-1); }

const int MAX_N = 1000;
int n;
int a[MAX_N][MAX_N];
int idx[MAX_N];
int cnt[MAX_N][MAX_N];

void inc(int i) {
  int j = a[i][idx[i]];
  if (i > j) swap(i,j);
  cnt[i][j]++;
}

bool ready(int i) {
  int j = a[i][idx[i]];
  if (i > j) swap(i,j);
  return cnt[i][j] == 2;
}

int main()
{
  cin >> n;
  forn(i,n) forn(j,n-1) {
    cin >> a[i][j];
    a[i][j]--;
  }

  deque<pii> q;
  forn(i,n) {
    inc(i);
    if (ready(i)) q.emplace_back(i,a[i][idx[i]]);
  }

  int c = 0;
  int done = 0;
  while (done < n*(n-1)/2) {
    if (q.empty()) {
      cout << -1 << endl;
      return 0;
    }

    deque<pii> temp;
    while (!q.empty()) {
      done++;
      int i,j;
      tie(i,j) = q.front(); q.pop_front();
      idx[i]++;
      idx[j]++;
      inc(i);
      inc(j);
      if (ready(i)) temp.emplace_back(i,a[i][idx[i]]);
      if (ready(j)) temp.emplace_back(j,a[j][idx[j]]);
    }

    q = temp;

    c++;
  }

  cout << c << endl;

  return 0;
}


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

int main()
{
    ll Ncoins, Y;
    cin >> Ncoins >> Y;

    ll A, B, C;

    for (ll i = 0; i <= Ncoins; i++) {

        A = i;

        for (ll j = i+1, q = 0; j <= Ncoins+1; j++, q++) {

            B = q;
            C = Ncoins - i - q;

            ll sum = (A*10*1000) + (B*5000) + (C*1000);

            if (sum == Y) {
                cout << A << ' ' << B << ' ' << C << endl;
                return 0;
            }
        }
    }

    cout << -1 << ' ' << -1 << ' ' << -1 << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
pair<pair<string,int>,int> t[110];//なぜint mainよりも前に宣言？
int main(){
  int N;
  cin>>N;
  
  for(int i=0;i<N;i++){
    int score;
    string name;
    cin>>name>>score;
    t[i]=make_pair(make_pair(name,score*(-1)),i+1);
  }
  
  //sort(t.begin(),t.end());　　なぜこれじゃダメ？
  std::sort(t,t+N);
  for(int i=0;i<N;i++){
    cout<<t[i].second<<endl;
  }
}
  
 
/*ここから駄目だったやつ
tuple<string,int,int> t[110];　　tuple型でやろうとした
 for(int i=0;i<N;i++){
    int score;
    string name;
    cin>>name>>score;
    t[i]=make_tuple(name,score*(-1),i+1);
  }
  std::sort(t,t+N);
  for(int i=0;i<N;i++){
    cout<<t[i].third<<endl;　tupleはこういう風に参照できない？
  }
}
  */

Measured memory_bytes: 3596
#86

#入力（1次元）
N = int(input())
#入力（２次元）
X = []
for i in range(N):
    X.append(list(map(int, input().split())))

ans = 'Yes'

for i in range(N):
    t = X[i][0] - X[i][1]- X[i][2]
    if t < 0 or X[i][0] % 2 != (X[i][1] + X[i][2]) % 2 :
        ans = 'No'

print(ans)


Measured memory_bytes: 27300
import java.util.Scanner;

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

	out();
    }

    void in()
    {
	Scanner sc = new Scanner(System.in);
	str = sc.next();
    }

    void out()
    {
	System.out.println(str.substring(0, 1)
			   + (str.length() - 2)
			   + str.charAt(str.length() - 1));
    }
}


Measured memory_bytes: 21716
n,k=gets.split(" ").map(&:to_i)
p=0
c=0
ans=0
(1..n).each do |x|
    p=x
    while p<=k-1 do
        p*=2
        c+=1
    end
    ans=ans + (0.5**c)*(1/n.to_f)
    c=0
end
p ans

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

int main() {
  int x;
  cin >> x;
  if(x%10==2||x%10==4||x%10==5||x%10==7||x%10==9) cout << "hon" << endl;
  else if(x%10==3) cout << "bon" << endl;
  else cout << "pon" << endl;

}

Measured memory_bytes: 3620
#include <iostream>
#include <string>
#include <numeric>
#include <vector>
#include <algorithm>


int main()
{
	using namespace std;
	int N, X;
	cin >> N;
	cin >> X;
	vector<int> m;
	m.resize(N);
	for (int i = 0; i < N; i++) {
		cin >> m[i];
	}
	int min = *min_element(m.begin(), m.end());
	int sum = accumulate(m.begin(), m.end(), 0);
	//cout << "min=" << min << endl;
	//cout << "sum=" << sum << endl;
	X = X - sum;
	cout << N + (X / min) << endl;
    return 0;
}


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

int main(void){
    int n;
    cin >> n;
    int a[n],b[n];
    int num[n],num2[n];
    
    for(int i = 0;i < n;i++)cin >> a[i];
    for(int i = 0;i < n;i++)cin >> b[i];
    
    num[0] = a[0],num2[0] = b[0];
    
    for(int i = 1;i < n;i++){
        num[i] = num[i-1] + a[i];
        num2[i] = num2[i-1] + b[i];
    }
    
    int ans = 0;
    for(int i = 0;i < n;i++){
        ans = max(ans , num[i] + (num2[n-1] - num2[i-1]));
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include<bits//stdc++.h>
using namespace std;
typedef long long ll;
typedef long long ld;
int main() {
	int a,b,c;
	cin>>a>>b>>c;
	if(c>=a&&c<=b){
		cout<<"Yes"<<endl;
	}
	else{
		cout<<"No"<<endl;
	}
}

Measured memory_bytes: 256
N=int(input())
A=[int(input()) for i in range(N)]
AT=[(A[i],i) for i in range(N)]
AT.sort()
B=[AT[i][1] for i in range(N)]
X=[[0,0],[0,0]]
for i in range(N):
    X[i%2][B[i]%2]+=1
Y=[X[0][1],X[1][0]]
print(min(Y))


Measured memory_bytes: 18400
#include <iostream>

using namespace std;

int main()
{
    string s;
    cin>>s;
    for(int i=0;i< s.size();i++){
        if(i==5 || i==13){
            s[i]=' ';
        }
        else continue;
    }
        cout<<s<<endl;
    return 0;
}


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

#define rep(i, n) for (int i = 0; i < n; ++i)
#define ALL(a) (a).begin(), (a).end()
#define rALL(a) (a).rbegin(), (a).rend()
#define SZ(x) ((int)(x).size())
using ll = long long;
using P = pair<int, int>;
using llP = pair<ll, ll>;
using DoP = pair<double, double>;
const int di[] = {0, 1, 0, -1, 1, 1, -1, -1};
const int dj[] = {1, 0, -1, 0, 1, -1, 1, -1};
const int INF = 1 << 29;
const ll INF64 = 1ll << 55;
const int mod = 1000000007;
//const int mod = 998244353;

template <class T>inline bool chmin(T &a, const T b)
{
  if (a > b)
  {
    a = b;
    return true;
  }
  return false;
}
template <class T>inline bool chmax(T &a, const T b)
{
  if (a < b)
  {
    a = b;
    return true;
  }
  return false;
}
template <class T>inline void line_out(const vector<T> vec) {
  int n = SZ(vec);
  rep(i, n) {
    cout << vec[i];
    if(i < n-1) cout << " ";
  }
  cout << endl;
  return;
}

struct mint
{
  ll x; // typedef long long ll;
  mint(ll x = 0) : x((x % mod + mod) % mod) {}
  mint operator-() const { return mint(-x); }
  mint &operator+=(const mint a)
  {
    if ((x += a.x) >= mod)
      x -= mod;
    return *this;
  }
  mint &operator-=(const mint a)
  {
    if ((x += mod - a.x) >= mod)
      x -= mod;
    return *this;
  }
  mint &operator*=(const mint a)
  {
    (x *= a.x) %= mod;
    return *this;
  }
  mint operator+(const mint a) const
  {
    mint res(*this);
    return res += a;
  }
  mint operator-(const mint a) const
  {
    mint res(*this);
    return res -= a;
  }
  mint &operator++()
  {
    if ((x += 1) >= mod)
      x -= mod;
    return *this;
  }
  mint &operator--()
  {
    if ((x += mod - 1) >= mod)
      x -= mod;
    return *this;
  }
  mint operator*(const mint a) const
  {
    mint res(*this);
    return res *= a;
  }
  mint pow(ll t) const
  {
    if (!t)
      return 1;
    mint a = pow(t >> 1);
    a *= a;
    if (t & 1)
      a *= *this;
    return a;
  }

  // for prime mod
  mint inv() const
  {
    return pow(mod - 2);
  }
  mint &operator/=(const mint a)
  {
    return (*this) *= a.inv();
  }
  mint operator/(const mint a) const
  {
    mint res(*this);
    return res /= a;
  }
};

int main()
{
  ll x; cin >> x;
  for(int i = 0; i <= 200; ++i) {
    for(int j = 0; j <= 200; ++j) {
      if((ll)pow(i, 5) - (ll)pow(j, 5) == x) {
        cout << i << " " << j << endl;
        return 0;
      }

      if((ll)pow(i, 5) + (ll)pow(j, 5) == x) {
        cout << i << " " << -j << endl;
        return 0;
      }
    }
  }
}

Measured memory_bytes: 4096
#include <algorithm>
#include<stdio.h>
#include <cstdio>
#include <iostream>
#include <iomanip>
#include <string>
#include <algorithm>
#include <vector>
#include <math.h>
#include<stack>
#include <queue>
#include<map>
#include <set>
#include<math.h>
using namespace std;
#define int long long
#define ll long long
#define rep(i,n) for(ll i=0;i<n;++i)
#define Rep(i,n) for(ll i=1;i<=n;++i)
#define loop(i,m,n) for(ll i=m;i<n;++i)
#define ggr getchar(); getchar();return 0;
#define pie 3.141592653589793238462643383279
#define elif else if
#define P pair<ll,ll>
#define prique priority_queue<ll>
const int mod = 1000000007;
const int mod2 = 998244353;
int bin(int bina) {
	int ans = 0;
	for (int i = 0; bina > 0; i++)
	{
		ans = ans + (bina % 2) * pow(10, i);
		bina = bina / 2;
	}
	return ans;
}
bool prime(int n) {
	for (ll i = 2; i <= sqrt(n); i++) {
		if (n % i == 0)return false;
	}
	return n != 1;
}
int gcd(int x, int y) {
	if (y == 0)return x;
	return gcd(y, x % y);
}
int lcm(int x, int y) {
	return x * y / gcd(x, y);
}
int kai(int x) {
	if (x == 0)return 1;
	return kai(x - 1) * x % mod;
}
int mod_pow(int x, int y, int mod) {
	int res = 1;
	while (y > 0) {
		if (y & 1) {
			res = res * x % mod;
		}
		x = x * x % mod;
		y >>= 1;
	}
	return res;
}
long nCr(int n, int r) {
	int ans = 1;
	for (ll i = n; i > n - r; --i) {
		ans = ans * i;
	}
	for (ll i = 1; i < r + 1; ++i) {
		ans = ans / i;
	}
	return ans;
}
struct union_find {
	int par[200010], size_[200010];
	void init(int x) {
		rep(i, x) { par[i] = i; size_[i] = 1; }
	}
	int find(int x) {
		if (par[x] == x)return x;
		return par[x] = find(par[x]);
	}
	void unite(int x, int y) {
		x = find(x); y = find(y);
		if (x == y)return;
		if (size_[x] < size_[y]) {
			par[x] = y;
			size_[y] += size_[x];
		}
		else {
			par[y] = x;
			size_[x] += size_[y];
		}
	}
};
int n, ans = 1, a[100010], b[100010];
signed main() {
	cin >> n;
	rep(i, n) cin >> a[i];
	rep(i, n)cin >> b[i];
	if (n == 1 && a[0] != b[0]) {
		cout << 0 << endl;ggr
	}
	loop(i, 1, n - 1) {
		if (a[i] != b[i] && a[i] != a[i-1] && b[i] != b[i+1]) {
			cout << 0 << endl;ggr
		}
		if (b[i] > a[i]&&a[i] == a[i - 1] && b[i] != b[i + 1] ) {
			cout << 0 << endl;ggr
		}
		if (b[i] < a[i] && a[i] != a[i - 1] && b[i] == b[i + 1]) {
			cout << 0 << endl; ggr
		}
		if (a[i] == a[i - 1] && b[i] == b[i + 1]) {
			ans *= min(a[i], b[i]);
			ans %= mod;
		}
	}
	cout << ans << endl;ggr
}

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

int main() {

  int N;
  cin >> N;

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

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

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

  sort(A.begin(), A.end());
  sort(C.begin(), C.end());

  long long answer = 0;

  for (int i = 0; i < N; i++) {
    long long a = lower_bound(A.begin(), A.end(), B[i]) - A.begin();
    long long c = N - (upper_bound(C.begin(), C.end(), B[i]) - C.begin());
    answer += a * c;
  }

  cout << answer << endl;

  return 0;

}

Measured memory_bytes: 1536
#include<iostream>
#include<algorithm>
using namespace std;
int main() {
	int N, K, h[100000], dist = 2147483647;
	cin >> N >> K;
	for (int i = 0;i < N;++ i) cin >> h[i];
	sort(h, h+N); // 先にソートするよ！
	for (int i = K - 1;i < N;dist = min(dist, h[i] - h[++i - K]));
	cout << dist;
	return 0;
}

Measured memory_bytes: 640
t = list(input())

def count(t,start):
     ans = 0
     for i in range(len(t)):
          if (i%2 == 0) and (t[i] != start):
               ans += 1
          if (i%2 == 1) and (t[i] == start):
               ans += 1
     return ans
     
ans = min(count(t,'0'), count(t,'1'))
print(ans)

Measured memory_bytes: 3956
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(int (i) = (a);(i) < (b);i++)
#define REP(i,n) FOR(i,0,n)
typedef long long ll;
const ll M = 1000000007;

vector<ll> fac(2000001); //n!(mod M)
vector<ll> ifac(2000001); //k!^{M-2} (mod M)
//a,bの範囲的にこれだけ配列を用意していけば十分

ll mpow(ll x, ll n){ //x^n(mod M) ←普通にpow(x,n)では溢れてしまうため，随時mod計算
    ll ans = 1;
    while(n != 0){
        if(n&1) ans = ans*x % M;
        x = x*x % M;
        n = n >> 1;
    }
    return ans;
}

ll comb(ll a, ll b){ //aCbをmod計算
    if(a == 0 && b == 0)return 1;
    if(a < b || a < 0)return 0;
    ll tmp = ifac[a-b]* ifac[b] % M;
    return tmp * fac[a] % M;
}


int main(){
    fac[0] = 1;
    ifac[0] = 1;
    for(ll i = 0;i < 1000050;i++){
        fac[i+1] = fac[i]*(i+1) % M; // n!(mod M)
        ifac[i+1] = ifac[i]*mpow(i+1, M-2) % M; // k!^{M-2} (mod M) ←累乗にmpowを採用
    }
    int x,y,n,m;
    cin >> x >> y;
    if(y > 2*x || 2*y < x || (x + y) % 3 != 0){
        cout << 0 << endl;
        return 0;
    }else{
        n = (2*x-y)/3;
        m = (2*y-x)/3;
    }
    ll ans = comb(n+m,n);
    cout << ans << endl;  
    //cin >> n;  
}

Measured memory_bytes: 31488
#include <iostream>
#include <vector>
#include <string>
#include <map>
#include <queue>
#include <stack>
#include <set>
#include <algorithm>
#include <cmath>
#include <iterator>
#include <numeric>
#include <iomanip>
#define FI first
#define SE second
#define EB emplace_back
#define REP(i, n) for (ll i = 0; i < n; i++)
#define INF 1100000000
#define LLINF 1100000000000000000LL
#define Decimal fixed << setprecision(20)
#define ALL(c) c.begin(),c.end()
#define SHOWVEC(v, sz) for(int i = 0; i < sz; i++) cerr << v[i] << ' '; cerr << endl;
#define SHOWX(x) cerr << #x << ": " << x << endl;
#define SHOWP(p) cerr << "[" << p.first << ',' << p.second << "]";

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

int main()
{
  int N;
  cin >> N;
  if (N % 2) cout << Decimal << (double)(N/2 + 1)/N << endl;
  else cout << Decimal << (double)(N/2)/N << endl;
  return 0;
}


Measured memory_bytes: 256
import java.io.*
import java.util.*

fun solve(N: Long, M: Long, X: Long, A: LongArray){
    val a = A.count{ it > X }
    println(Math.min(a, M.toInt()-a))
    return
}


fun main(args: Array<String>) {
    fun StringArray(size: Int, init: (Int) -> String = { "\u0000" }): Array<String> {
        return Array<String>(size, init)
    }
    class Scanner(stream: InputStream) {
        private val reader = BufferedInputStream(stream).bufferedReader()
        private var st: StringTokenizer? = null
        fun next(): String {
            while (!(st?.hasMoreTokens() ?: false)) st = StringTokenizer(reader.readLine())
            return st!!.nextToken()
        }
    }
    val sc = Scanner(System.`in`)
    val N = sc.next().toLong()
    val M = sc.next().toLong()
    val X = sc.next().toLong()
    val A = LongArray(M.toInt())
    for (i in 0 until M.toInt()) {
        A[i] = sc.next().toLong()
    }
    solve(N, M, X, A)
}



Measured memory_bytes: 31384
#include<bits/stdc++.h>
using namespace std;
long long l,a,b,s,c;
int main(){
    cin>>l>>a>>b;
    s=l-a;
    c=s/b;
    if(!(s%b))cout<<"0"<<endl;
    else cout<<l-a-b*c<<endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <numeric>
#include <cstdlib>
#include <cmath>
#include <algorithm>
#include <string>
#include <cstring>
#include <queue>
#define myfor(i,N) for(i=0;i<N;i++)
#define myforFL(i,f,l) for(i=f;i<l;i++)
#define myforInv(i,N) for(i=N;i>=0;i--)
#define myforFLInv(i,f,l) for(i=f;i>l;i--)
using namespace std;


float distance(long x1,long y1,long x2,long y2){
	return pow((y2 - y1)*(y2 - y1) + (x2 - x1)*(x2 - x1),1./2.);
}

int main(){
	string S;
	long ans=0,i,j;
	cin >> S;
	long separation = S.size()-1;
	myfor(i,S.size()){
		myfor(j,separation-i){
			ans += (S[i] - '0')*pow(10,j)*pow(2,separation-j-1);
		}
		ans += (S[i] - '0')*pow(10,j)*pow(2,separation-j);
	}
	cout << ans << endl;
	return 0;
}

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

string v[11111];

int main(){
  int H,W,i,j,count=0,fail=0;

  std::cin >> H;
  std::cin >> W;

  for(i=1;i<=H;i++){
    std::cin >> v[i];
  }

  for(i=1;i<=H;i++){
    for(j=1;j<=W;j++){
      if(v[i][j]=='#'){

          if(v[i-1][j]=='#') count++;

          if(v[i][j-1]=='#') count++;

          if(v[i+1][j]=='#') count++;

          if(v[i][j+1]=='#') count++;

          if(count==0) fail++;
      }
      count=0;
    }
  }


  if(fail==0) std::cout << "Yes" << '\n';
  else std::cout << "No" << '\n';

  return 0;



}


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

using namespace std;

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

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

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

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

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

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

int main(){
  map<string,int> mp;
  int n; cin >> n;
  int max_c = 0;;
  for(int i = 0; i < n; ++i){
    string s; cin >> s;
    mp[s]++;
    ChangeMax(max_c, mp[s]);
  }
  for(auto e:mp){
    if(e.second == max_c)cout << e.first << endl;
  }
  return 0;
}


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

int main(void){
	int m,a,b;
	while(cin >> m >> a >> b,m){
		int p[210];
		for(int i = 0; i < m;++i) cin >> p[i];
		
		int gap = 0, idx = -1;
		for(int i = a;i <= b; ++ i){
			int cur = p[i-1] - p[i];
			if(gap <= cur) gap = cur,idx = i;
		}

		cout << idx << endl;
	}
	return 0;
}

Measured memory_bytes: 3088
N, X, Y=map(int,input().split())
List=[]
i=1
for j in range(2,N+1):
  for i in range(1,j):
    List.append(min([abs(j-i), abs(X-i)+abs(Y-j)+1]))

List.sort()

import collections
C=collections.Counter(List)

for p in range(1,N):
  if p in C.keys():
    print(C[p])
  else:
    print(0)

Measured memory_bytes: 72068
#include<algorithm>
#include<iostream>
#include<functional>
#include<cmath>
#include<iomanip>
#define mins(a,b) a=min(a,b)
#define maxs(a,b) a=max(a,b)
using namespace std;
const long long int INF=100100100100;
int main(){
  int n,k;
  cin>>n>>k;
  long long int dp[100010];
  long long int h[100010];
  for(int i=0;i<n+10;i++){
    dp[i]=INF;
  }
  for(int i=0;i<n;i++){
    cin>>h[i];
  }
  dp[0]=0;
  for(int i=0;i<n;i++){
    for(int j=1;j<k+1;j++){
    mins(dp[i+j],dp[i]+abs(h[i]-h[i+j]));
   }
  }
  cout<<dp[n-1]<<endl;
}

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

int A, B;

int main() {
  cin.tie(0);
  ios_base::sync_with_stdio(false);
  cout << fixed << setprecision(10);
  
  cin >> A >> B;
  cout << (A > 8 || B > 8 ? ":(" : "Yay!") << endl;  

  return 0;
}

Measured memory_bytes: 256
package main

import "fmt"

func main() {
	var n int
	var count int

	fmt.Scan(&n)

	a := make([]int, n)

	for i := 0; i < n; i++ {
		fmt.Scan(&a[i])
	}

	for j := 0; j < n; j++ {
		if a[j]%2 == 0 {
			if !(a[j]%3 == 0) && !(a[j]%5 == 0) {
				count++
			}
		}
	}

	if count == 0 {
		fmt.Println("APPROVED")
	} else {
		fmt.Println("DENIED")
	}
}


Measured memory_bytes: 512