akhauriyash/Code-Regression huggingface dataset:
#include <stdio.h>
int main(void){
    // Your code here!
    
    int entry_point,entry_num;
    int entry[100]={0};
    int i,flg;
    int abs_num=0,answer;
    
    //入力
    scanf("%d",&entry_point); //整数X
    scanf("%d",&entry_num); //入力個数
    
    for(i=0; i<entry_num; i++){
        scanf("%d",&entry[i]);
    }
    

    while(1){
        flg=0;
        answer = entry_point - abs_num;
        for(i=0; i<entry_num; i++){
            if(answer == entry[i]){
                flg = 1;
                break;
            }
        }
        if(flg == 0){
            //発見
            break;
        }
        flg=0;
        answer = entry_point + abs_num;
        for(i=0; i<entry_num; i++){
            if(answer == entry[i]){
                flg = 1;
                break;
            }
        }
        if(flg == 0){
            //発見
            break;
        }
        abs_num++;
    }
        
        
    printf("%d\n",answer);
    
}


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

const int N = 500001, inf = 1000000009;
int n, m, Par[N], d[N];
map<int, int> Fake[N];
vector<pair<int, int> > child[N];
vector<pair<int, pair<int, int> > > edges;

int main(){
	scanf("%d%d", &n, &m);
	for(int i = 1; i <= m; ++i){
		int u, v, c; scanf("%d%d%d", &u, &v, &c);
		child[u].push_back({c, v});
		child[v].push_back({c, u});
		edges.push_back({c, {u, v}});
	}

	int node = 0;
	for(int i = 1; i <= n; ++i){
		child[i].push_back({0, 0});
		sort(child[i].begin(), child[i].end());

		Fake[i][0] = ++node;
		Par[node] = i;

		int k = child[i].size();
		for(int j = 1; j < k; ++j)
			if(child[i][j].first != child[i][j - 1].first)
				Fake[i][child[i][j].first] = ++node, Par[node] = i;

		child[i].clear();
	}

	for(int i = 0; i < m; ++i){
		int c = edges[i].first, u = edges[i].second.first, v = edges[i].second.second;
		child[Fake[u][c]].push_back(make_pair(Fake[v][c], 0));
		child[Fake[u][c]].push_back(make_pair(Fake[v][0], 1));
		child[Fake[v][0]].push_back(make_pair(Fake[u][c], 1));


		child[Fake[v][c]].push_back(make_pair(Fake[u][c], 0));
		child[Fake[v][c]].push_back(make_pair(Fake[u][0], 1));	
		child[Fake[u][0]].push_back(make_pair(Fake[v][c], 1));	
	}

	for(int i = 1; i <= node; ++i)
		d[i] = inf;
	priority_queue<pair<int, int>, vector<pair<int, int> >, greater<pair<int, int> > > q;
	for(auto it = Fake[1].begin(); it != Fake[1].end(); ++it)
		q.push(make_pair(1, it->second)), d[it->second] = 1;
	
	while(!q.empty()){
		pair<int, int> u = q.top(); q.pop();
		if(u.first != d[u.second]) continue;
		if(Par[u.second] == n) return printf("%d\n", u.first + 1 >> 1), 0;

		for(pair<int, int> v:child[u.second])
			if(d[v.first] > u.first + v.second)
				d[v.first] = u.first + v.second, q.push(make_pair(d[v.first], v.first));
	}

	puts("-1");
}

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

// 基本テンプレート
#pragma region MACRO
#define P(x) cout << (x) << endl
#define p(x) cout << (x)
#define PED cout << "\n"
#define rep(i,n) for(int i=0; i<(int)n; ++i)
#define REP(i,x,n) for(int i=x; i<(int)n; ++i)
#define repi(i,n) for(int i=0; i<=(int)n; ++i)
#define REPI(i,x,n) for(int i=x; i<=(int)n; ++i)
#define ILP while(true)
#define FOR(i,c) for(__typeof((c).begin())!=(c).begin(); i!=(c).end(); ++i)
#define ALL(c) (c).begin(), (c).end()
#define mp make_pair
#pragma endregion

// 型
#pragma region TYPE_DEF
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<string, string> pss;
typedef pair<string, int> psi;
typedef pair<int, string> pis;
typedef vector<int> vi;
typedef vector<double> vd;
typedef vector<long double> vld;
typedef vector<long> vl;
typedef vector<long long> vll;
typedef vector<string> vs;
#pragma endregion

// Effective std
#pragma region ESTD
template<typename C, typename T> int count(C& c, T t) { return count(ALL(c), t); }
template<typename C, typename F> int count_if(C& c, F f) { return count_if(ALL(c), f); }
template<typename C, typename T> void erase(C& c, T t) { remove(ALL(c), t), c.end(); }
template<typename C> void remove(vector<C>& c, unsigned int index) { c.erase(c.begin()+index); }
template<typename C, typename T, typename U> void replace(C& c, T t, U u) { replace(ALL(c), t, u); }
template<typename C, typename F, typename U> void replace_if(C& c, F f, U u) { (ALL(c), f, u); }
template<typename C> void reverse(C& c) { reverse(ALL(c)); }
template<typename C> void sort(C& c) { sort(ALL(c)); }
template<typename C, typename Pred> void sort(C& c, Pred p) { sort(ALL(c), p); }
#pragma endregion

// 定数
#pragma region CONST_VAL
constexpr int PI = (2*acos(0.0));
constexpr int EPS = (1e-9);
constexpr int MOD = (int)(1e9+7);
constexpr int INF = 100000000;
#pragma endregion


int main()
{
    int a, b;
    cin >> a >> b;
    cout << (a+b)%24 << endl;
    return 0;
}



Measured memory_bytes: 256
def main():
	N = int(input())
	dp = [1]*(N+1)
	ans = 0
	for i in range(2, N+1):
		div = 1
		while i * div <= N:
			dp[i*div] += 1
			div += 1
		if dp[i] == 8 and i%2==1:
			ans += 1
	print(ans)

if __name__ == '__main__':
    main()

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

int main(){
	int n, a;
	cin >> n;
	a = n % 10;	
	if (a == 3) cout << "bon" << endl;
	else if (a == 0 || a == 1 ||  a == 6 ||  a == 8) cout << "pon" << endl;
	else cout << "hon" << endl;
	return 0;
}

Measured memory_bytes: 3568
#include <cstdio>
#include <cstdlib>
#include <iostream>
#include <fstream>
#include <sstream>
#include <set>
#include <map>
#include <vector>
#include <list>
#include <algorithm>
#include <cstring>
#include <cmath>
#include <string>
#include <stack>
#include <queue>
#include <bitset>     //UWAGA - w czasie kompilacji musi byc znany rozmiar wektora - nie mozna go zmienic
#include <cassert>
#include <iomanip>        //do setprecision
#include <ctime>
#include <complex>
using namespace std;

#define FOR(i,b,e) for(int i=(b);i<(e);++i)
#define FORQ(i,b,e) for(int i=(b);i<=(e);++i)
#define FORD(i,b,e) for(int i=(b)-1;i>=(e);--i)
#define REP(x, n) for(int x = 0; x < (n); ++x)

#define ST first
#define ND second
#define PB push_back
#define PF push_front
#define MP make_pair
#define LL long long
#define ULL unsigned LL
#define LD long double
#define pii pair<int,int>
#define pll pair<LL,LL>
#define vi vector<int>
#define vii vector<vi>

const double pi = 3.14159265358979323846264;
const int mod=1000000007;

int main(){
	 //cin.tie(0);
	//ios::sync_with_stdio(false);
	//std::cout << std::fixed;
	//std::cout << std::setprecision(12);
	//std::cout << std::defaultfloat;
	int n;
	cin>>n;
	vector<int> a(n);
	vector<int> b(n);
	priority_queue<int> pq;
	FOR(i,0,n){
		cin>>a[i];
		b[i]=a[i]-1;
		if(b[i]==0){
			pq.push(i);
			b[i]--;
		}
	}
	vector<int> ans;
	while(pq.size()){
		int t=pq.top();
		cerr<<" "<<t<<endl;
		pq.pop();
		ans.PB(a[t]);
		FOR(i,t+1,n){
			b[i]--;
			if(b[i]==0){
				pq.push(i);
				b[i]--;
			}
		}

	}
	if(ans.size()!=n){
		cout<<-1<<endl;
	}else{
		FOR(i,0,n){
			cout<<ans[i]<<endl;
		}
	}


	return 0;
}


Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
const int INF = 1e9;
const ll LINF = 1e18;
template<class S,class T> ostream& operator << (ostream& out,const pair<S,T>& o){ out << "(" << o.first << "," << o.second << ")"; return out; }
template<class T> ostream& operator << (ostream& out,const vector<T> V){ for(int i = 0; i < V.size(); i++){ out << V[i]; if(i!=V.size()-1) out << " ";} return out; }
template<class T> ostream& operator << (ostream& out,const vector<vector<T> > Mat){ for(int i = 0; i < Mat.size(); i++) { if(i != 0) out << endl; out << Mat[i];} return out; }
template<class S,class T> ostream& operator << (ostream& out,const map<S,T> mp){ out << "{ "; for(auto it = mp.begin(); it != mp.end(); it++){ out << it->first << ":" << it->second; if(mp.size()-1 != distance(mp.begin(),it)) out << ", "; } out << " }"; return out; }


/*
<url:https://onlinejudge.u-aizu.ac.jp/services/room.html#RitsCamp18Day1/problems/A>
問題文============================================================
 N  個の相違なる自然数 ai が与えられる。与えられた自然数から相違なる自然数を選び、ペアを作ることにした。
 作ることができるペアのうち、値の差が N−1 の倍数であるペアを一つ出力せよ。
 
 なお、そのようなペアは必ず存在する。
=================================================================

解説=============================================================

================================================================
*/
void solve(){
    ll N; cin >> N;
    vector<ll> a(N); for(auto& in:a) cin >> in;
    [&]{
        for(int i = 0; i < N;i++){
            for(int j = i+1; j < N;j++){
                if(a[i] == a[j]) continue;
                if(abs(a[i] - a[j])%(N-1) == 0){
                    cout << a[i] << " " << a[j] << endl;
                    return;
                }
            }
        }
        return;
    }();
}
int main(void) {
	cin.tie(0); ios::sync_with_stdio(false);
    solve();
	return 0;
}



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

using namespace std;

#define DIM 200009
#define INF 1e11+9
#define amen exit(0)
#define fast ios_base::sync_with_stdio(false),cin.tie(0),cout.tie(0)
#define pairll pair<long long,long long>
#define fi first
#define se second

long long i,j,k,l,n,m;

long long dp[DIM][2],a[DIM];

int main()
{
    cin>>n;
    for(i=1;i<=n;i++){
        cin>>a[i];
    }

    dp[2][1]=INF;
    dp[2][0]=abs(a[2]-a[1]);
    for(i=3;i<=n;i++){
        dp[i][0]=abs(a[i]-a[i-1])+min(dp[i-1][0],dp[i-1][1]);
        dp[i][1]=abs(a[i]-a[i-2])+min(dp[i-2][0],dp[i-2][1]);
    }

    cout<<min(dp[n][0],dp[n][1])<<endl;

    return 0;
}


Measured memory_bytes: 3584
import java.util.Scanner;

public class Main{
    public static void main(String[] args){
        try(Scanner sc = new Scanner(System.in)){
            String line = sc.nextLine();
            String answer = "";
            int length = line.length();
            for(int i=0;i<length;i++){
                char ch = line.charAt(i);
                if(Character.isLowerCase(ch))ch = Character.toUpperCase(ch);
                else ch = Character.toLowerCase(ch);
                answer += ch;
            }
            System.out.println(answer);
        }
    }
}


Measured memory_bytes: 31536
#include<bits/stdc++.h>
using namespace std;
int main(){
  int N;
  cin>>N;
  int M=1000;
  for(int i=0;i<N;i++){
    int A;
    cin>>A;
    int j=0;
    while(A%2==0){
      A=A/2;
      j=j+1;
    }
    M=min(M,j);
  }
  cout<<M<<endl;
}
    

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<map>
#define _USE_MATH_DEFINES
#include<math.h>
#include<queue>
#include<deque>
#include<stack>
#include<cstdio>
#include<utility>
#include<set>
#include<list>
#include<cmath>
#include<stdio.h>
#include<string.h>
#include<iomanip>
#include<cstdio>
#include<cstdlib>
#include<cstring>
using namespace std;
#define FOR(i, a, b) for (ll i = (a); i <= (b); i++)
#define REP(i, n) FOR(i, 0, n - 1)
#define NREP(i, n) FOR(i, 1, n)
using ll = long long;
using pii = pair<int, int>;
using piii = pair<pii, pii>;
const ll dx[4] = { 0,1,0,-1 };
const ll dy[4] = { -1, 0, 1,0 };
const int INF = 1e9 + 7;
int gcd(int x, int y) {
	if (x < y)swap(x, y);
	if (y == 0)return x;
	return gcd(y, x%y);
}
void mul(ll a, ll b) {
	a = a * b % INF;
}
double mysqrt(double x) {
	double l = 0, r = x;
	for (int i = 0; i < 64; ++i) {
		double m = (l + r) / 2.0;
		if (m*m < x)l = m;
		else r = m;
	}
	return l;
}
///////////////////////////////////////

ll dp[2010][2010];
ll sum[2010][2010];
int main() {
	int n, m; cin >> n >> m;
	int s[2010], t[2010];
	for (int i = 0; i < n; ++i)cin >> s[i];
	for (int i = 0; i < m; ++i)cin >> t[i];
	memset(dp, 0, sizeof(dp));
	memset(sum, 0, sizeof(sum));
	for (int i = 0; i < n; ++i) {
		for (int j = 0; j < m; ++j) {
			if (s[i] == t[j]) {
				dp[i + 1][j + 1] = sum[i][j] + 1;
			}
			else {
				dp[i + 1][j + 1] = 0;
			}
			sum[i + 1][j + 1] = sum[i + 1][j] + sum[i][j + 1] - sum[i][j] + dp[i + 1][j + 1];
			sum[i + 1][j + 1] += INF;
			sum[i + 1][j + 1] %= INF;
			dp[i + 1][j + 1] %= INF;
		}
	}
	ll ans = 1;
	for (int i = 0; i < n + 1; ++i) {
		for (int j = 0; j < m + 1; ++j) {
			ans += dp[i][j];
			ans %= INF;
		}
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 63488
import sys

def gcd(a, b):
    a, b = max(a, b), min(a, b)
    while a % b > 0:
        a, b = b, a % b
    return b

def solve():
    input = sys.stdin.readline
    K = int(input())
  
    N = 0
    for i in range(1, K + 1):
        N = (N * 10 + 7) % K
        if N == 0:
            print(i)
            break
    else:
        print(-1)
   
    return 0

if __name__ == "__main__":
    solve()

Measured memory_bytes: 9108
mod = 1000000007

def cnt(i,j):
  if (0 <= i-1 < H):
    dp[i][j] += dp[i-1][j]
  if (0 <= j-1 < W):
    dp[i][j] += dp[i][j-1]

H,W = list(map(int,input().split()))
grid = [[i for i in input()] for j in range(H)]

dp = [[0]*W for i in range(H)]
dp[0][0] = 1

for h in range(H):
  for w in range(W):
    if grid[h][w] == ".":
      cnt(h,w)

print(dp[H-1][W-1]%mod)

Measured memory_bytes: 253532
n,m=gets.split.map &:to_i
a=[]
b=[]
n.times do
  a<< gets.chomp
end
m.times do
  b<< gets.chomp
end
u=true
(n-m+1).times do |i|
  (n-m+1).times do |j|
    u=true
    m.times do |k|
      m.times do |l|
        if a[i+k][j+l]!=b[k][l]
          u=false
          break
        end
      end
      break if !u
    end
    break if u
  end
  break if u
end
puts u ? :Yes : :No

Measured memory_bytes: 1788
import java.util.Arrays;
import java.util.Scanner;
public class Main {
public static void main(String[]srgs) {
	Scanner scan=new Scanner(System.in);
	int a=scan.nextInt();
	int b[]=new int[a];
	for(int i=0;i<a;i++) {
		b[i]=scan.nextInt();
	}
	Arrays.sort(b);
	System.out.println(b[a-1]-b[0]);
}
}

Measured memory_bytes: 22868
#include <algorithm>
#include <climits>
#include <cstdio>
#include <cstdlib>
#include <cstring>

using namespace std;

int main()
{
  int a, b;
  scanf("%d%d", &a, &b);
  printf("%d\n", max(a+b, max(a-b, a*b)));
  return 0;
}


Measured memory_bytes: 760
package main

import (
	"fmt"
)

func main() {
	var N int
	fmt.Scan(&N)
	h := make([]int, N)

	for i := range h {
		fmt.Scan(&h[i])
	}

	dp := make([]int, N)

	dp[1] = abs(h[1] - h[0])

	for i := 2; i < N; i++ {
		dp[i] = min(dp[i-1]+abs(h[i]-h[i-1]), dp[i-2]+abs(h[i]-h[i-2]))
		//fmt.Printf("dp[i]=%d", dp[i])
	}
	fmt.Print(dp[N-1])

}

func abs(a int) int {
	if a < 0 {
		return -a
	}
	return a
}

func min(a, b int) int {
	if a < b {
		return a
	}
	return b
}


Measured memory_bytes: 5504
from itertools import combinations
A = ["A","C","G","T"]
S = input().strip()
lmax = 0
for x in combinations(range(len(S)+1),2):
    l,r = x
    flag = 0
    for i in range(l,r):
        if S[i] not in A:
            flag = 1
            break
    if flag==0:
        lmax = max(lmax,r-l)
print(lmax)

Measured memory_bytes: 38384
// Sky's the limit :)
#include<bits/stdc++.h>
using namespace std;
#define int long long

signed main() 
{
    //int t; cin >> t; while(t--) 
    {
        int n, k;
        cin >> n >> k;
        
        int ans = 0, mod = 1e9 + 7;
        for (int i = k; i <= n + 1; i++) {
            int mn = (i - 1) * i / 2;
            int mx = (n - i + 1 + n) * i / 2;
            ans = (ans + mx - mn + 1) % mod;
        }
        
        cout << ans << '\n';
    }
    
    return 0;
}


Measured memory_bytes: 3640
#include <iostream>
#include <vector>
#include <map>
using namespace std;
const int MAX = 300005;

struct P
{
	int val, idx;
};

bool comp(P a, P b) {
	return a.val > b.val;
}

int main() {
	int h, w, m;
	cin >> h >> w >> m;
	map<pair<int, int>, bool> mp;
	vector<P> X(MAX), Y(MAX);
	for (int i = 0; i < MAX; i++) {
		X[i].idx = i, X[i].val = 0;
		Y[i].idx = i, Y[i].val = 0;
	}
	for (int i = 0; i < m; i++) {
		int h, w;
		scanf("%d%d", &h, &w);
		X[h].val++;
		Y[w].val++;
		mp[{h, w}] = true;
	}
	sort(X.begin(), X.end(), comp);
	sort(Y.begin(), Y.end(), comp);
	int nx = 1, ny = 1;
	for (int i = 1; i < X.size(); i++) {
		if (X[i].val == X[i-1].val) nx++;
		else break;
	}
	for (int i = 1; i < Y.size(); i++) {
		if (Y[i].val == Y[i-1].val) ny++;
		else break;
	}
	if (nx * ny > m) {
		int ans = X[0].val + Y[0].val;
		cout << ans << endl;
		return 0;
	}
	bool minus = true;
	for (int i = 0; i < nx; i++) {
		for (int j = 0; j < ny; j++) {
			if (mp[{X[i].idx, Y[j].idx}] == false) {
				minus = false;
				break;
			}
		}
	}
	int ans = X[0].val + Y[0].val;
	if (minus) ans--;
	cout << ans << endl;
	return 0;
}

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

using namespace std;
typedef long long int ll;
typedef pair<int, int> ii;
#define DEBUG freopen("in.txt", "r", stdin);

struct fastio {
    fastio() {
        ios::sync_with_stdio(false);
        cout << setprecision(10) << fixed;
        cin.tie(0);
    }
};

fastio _fast_io;

const int N = 1e5 + 5;
int n, k;
ll ans;

int main() {
    cin >> n >> k;
    if (k == 0) {
        cout << 1LL * n * n << endl;
        exit(0);
    }

    for (int b = k + 1; b <= n; ++b) {
        // r = (k, b - 1);
        int a = b - k;
        int cnt = n / b;
        ans += cnt * a;
        // cnt * b + (k, b - 1)
        int r = n % b;
        if (r >= k)
            ans += r - k + 1;
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 3612
#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 <iomanip>
using namespace std;
typedef long double ld;
typedef long long int ll;
typedef unsigned long long int ull;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
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 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) << endl
#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 Sort(a) sort(a.begin(), a.end())
#define Rort(a) sort(a.rbegin(), a.rend())
#define MATHPI acos(-1)
int dx8[8] = {1, 0, -1, 0, 1, -1, -1, 1};
int dy8[8] = {0, 1, 0, -1, 1, 1, -1, -1};
int dx4[4] = {1, 0, -1, 0};
int dy4[4] = {0, 1, 0, -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;}
template<typename A, size_t N, typename T> void Fill(A (&array)[N], const T &val){ fill((T*)array, (T*)(array+N), val); }
struct io{io(){ios::sync_with_stdio(false);cin.tie(0);}};
const int INF = INT_MAX;
const ll LLINF = 1LL<<60;
const ll MOD = 1000000007;
const double EPS = 1e-9;
template < typename T > inline string toString( const T &a ) { ostringstream oss; oss << a; return oss.str(); };




int main()
{
  int N,K;
  cin >> N >> K;
  vi v(N);
  rep(i,N) cin >> v[i];
  int ans = 0;

  rep(a,N+1){
      rep(b,N+1){
          if(N<a+b) continue;
          int rest = K -(a+b);
          if(rest < 0) continue;

          vi has;
          rep(i,a) has.push_back(v[i]);//左からとっていく
          rep(j,b) has.push_back(v[N-1-j]);//右からとっていく

          sort(has.begin(),has.end());
          //小さい順に詰めていく
          int sum = 0;
          int size = has.size();
          for(auto h:has){
              sum += h;
          }
          rep(k,min(rest,size)){
              //hasが+しかなかった場合詰めない方が得なのでそこで終わり
              if(has[k]>0) break;
              sum-=has[k];
          }

          ans = max(ans,sum);
      }
  }

  fin(ans);
  
  
}



Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main()
{
  int A,B;
  cin>>A>>B;
  if(A>=13)
  {
    cout<<B;
  }
  else if(A<=12 && A>=6)
  {
    cout<<B/2;
  }
  else
  {
    cout<<'0';
  }
  
  return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
using namespace std;
typedef long long ll;
ll ans[2005]={0};
int main(){
  ll n,x,y;
  cin>>n>>x>>y;
  for(ll i=1;i<n;i++){
    for(ll j=i+1;j<=n;j++){
      ll dist=min(j-i,abs(j-y)+abs(i-x)+1);
      ans[dist]++;
    }
  }
  for(int i=1;i<n;i++) cout<<ans[i]<<endl;
}


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

typedef long long ll;

const int maxn = 1e5 + 5;

int main(int argc, const char * argv[])
{
    ll n, h[maxn], dp[maxn];
    cin >> n;
    for (int i = 1; i <= n; i++)
        scanf("%lld", &h[i]);
    
    dp[0] = 0; dp[1] = 0; dp[2] = abs(h[2] - h[1]);
    for (int i = 3; i <= n; i++)
        dp[i] = min(dp[i-2] + abs(h[i] - h[i-2]), dp[i-1] + abs(h[i] - h[i-1]));

    cout << dp[n] << endl;
    return 0;
}

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

int main() {
    int a, b; cin >> a >> b;
    if ((a + b) % 2) {
        cout << "IMPOSSIBLE" << endl;
    } else {
        cout << (a + b) / 2 << endl;
    }
    return 0;
}

Measured memory_bytes: 256
using System;

namespace Biscuit_Generator
{
    class Program
    {
        static void Main(string[] args)
        {
            int a, b,t;
            string[] str = Console.ReadLine().Split(' ');
            a = int.Parse(str[0]);
            b = int.Parse(str[1]);
            t = int.Parse(str[2]);
            double tPlus = t + 0.5;
            int passTime = Convert.ToInt32(Math.Floor((double)tPlus / a));
            int totalBiscuits = passTime * b;
            Console.WriteLine(totalBiscuits);
        }
    }
}

Measured memory_bytes: 11220
#include <bits/stdc++.h>
#define range(i, a, b) for(int i = (a); i < (b); i++)
#define rep(i, a) range(i, 0, a)
using namespace std;

int n, z, w, a[2010], memo[2010][2];
const int INF = 1000000000;

int solve (int k = 0, int x = z, int y = w, bool turn = true) {
	if (k == n) {
		return abs(x - y);
	}
	if (memo[k][turn] != -1) {
		return memo[k][turn];
	}
	int res;
	if (turn) {
		res = -INF;
		for (int i = k; i < n; i++) {
			res = max(res, solve(i + 1, a[i], y, false));
		}
	} else {
		res = INF;
		for (int i = k; i < n; i++) {
			res = min(res, solve(i + 1, x, a[i], true));
		}
	}
	return memo[k][turn] = res;
}

int main() {
	cin >> n >> z >> w;
	rep (i, n) cin >> a[i];
	memset(memo, -1, sizeof(memo));
	cout << solve() << endl;
	return 0;
}

Measured memory_bytes: 384
# ビット演算を使おう

D, G = map(int, input().split())
pc = [tuple(map(int,input().split())) for i in range(D)]
import math
ans = 10**5
for i in range(2**D):
    # 使い切る部分が１、選ばない部分が０
    b = str(bin(i))[2:].zfill(D)
    

    cnt = 0
    point = 0
    first_zero_idx = 0
    flag = False
    #print(b)
    for j in range(len(b)):
        # 解ききる問題の点とボーナスの和
        if b[j] == "1":
            point += (D-j)*100*pc[D-1-j][0] + pc[D-1-j][1]
            cnt += pc[D-1-j][0]
        else:
            if not flag:
                first_zero_idx = j
                flag = True
    if flag:
        # 残りのうち最も得点の高い問題を解いたときにボーダーを超えるかどうか
        if point < G and G - point <= (pc[D-1-first_zero_idx][0]-1)*100*(D-first_zero_idx):
            #print(b, point, cnt)
            tmp = math.ceil((G - point) / (100*(D-first_zero_idx)))
            cnt += tmp
            point += tmp*100*(D-first_zero_idx)
    if point >= G:
        ans = min(ans, cnt)
        #print("---",b, point, cnt, tmp, first_zero_idx)
        
print(ans)


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

typedef struct{
    char suit;
    int value;
} Card;

void scanCard(int N, Card* A){
    for(int i = 0; i < N; i++){
        cin >> A[i].suit;
        cin >> A[i].value;
    }
}

int* scanArrayInt(int N){
    int* A = new int[100];
    for(int i = 0; i < N; i++){
        cin >> A[i];
    }
    return A;
}

//配列AをBにコピー
void copyCard(int N, Card* A, Card* B){
    for(int i = 0; i < N; i++){
        B[i].suit = A[i].suit;
        B[i].value = A[i].value;
    }
}

//長さNの配列Aを，行末の空白はなし，改行ありで出力．
void printCard(int N, Card* A){
    for(int i = 0; i < N - 1; i++){
        cout << A[i].suit << A[i].value << " ";
    }
    cout << A[N - 1].suit << A[N-1].value << endl;
}

void bubbleSort(int N, Card* A){
    bool flag = 1;
    for(int i = 0; flag; i++){
        flag = 0;
        for(int j = N-1; j >= i + 1; j--){
            if(A[j].value < A[j - 1].value){
                swap(A[j], A[j - 1]);
                flag = 1;
            }
        }
    }
}

void selectionSort(int N, Card* A){
    int i, j;
    for(i = 0; i < N - 1; i++){
        int minj = i;
        for(j = i; j < N; j++){
            if(A[j].value < A[minj].value){
                minj = j;
            }
        }
        if(A[minj].value < A[i].value){
            swap(A[i], A[minj]); 
        }
    }
}

int judgeStability(int N, Card* A, Card* B){
    for(int i = 0; i < N; i++){
        if(A[i].suit != B[i].suit){
            return 1; 
        }
    }
    return 0;
}

int main(){
    int N;
    cin >> N;
    Card* A = new Card[100];
    scanCard(N, A);
    Card* B = new Card[100];
    copyCard(N, A, B);
    bubbleSort(N, A);
    selectionSort(N, B);
    int a = judgeStability(N, A, B);

    printCard(N, A);
    cout << "Stable" << endl;
    printCard(N, B);
    if(a == 0){
        cout << "Stable" << endl;
    }else{
        cout << "Not stable" << endl;
    }
    return 0;
}


Measured memory_bytes: 3108
#include <iostream>
#include <map>

int main() {
  int N;
  std::cin >> N;

  std::map<int ,int> m;

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

  int answer = 0;

  for (auto p : m) {
    if (p.second >= p.first) {
      answer += p.second - p.first;
    } else {
      answer += p.second;
    }
  }

  std::cout << answer << std::endl;
}


Measured memory_bytes: 4736
#include <iostream>
#include <stdlib.h>
#include <stdio.h>
#include <math.h>

using namespace std;

typedef long long LL;

LL Q, A, B;

LL work()
{
	LL sq = LL(sqrt(A * B));
	LL ans = sq * 2 - 1;
	if (A == B)
		ans -= 1;
	else if (sq * sq == A * B)
		ans -= 2;
	else if (sq * (sq + 1) >= A * B)
		ans -= 1;
	return ans;
}

int main()
{
	ios::sync_with_stdio(false);
	cin.tie(0); cout.tie(0);
	cin >> Q;
	for (int i = 0; i < Q; i++) {
		cin >> A >> B;
		LL res = work();
		cout << res << endl;
	}
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); i++)
using namespace std;
int main()
{
    int n;
    cin >> n;
    int h[n];
    rep(i, n) cin >> h[i];
    int cnt = 0;
    vector<int> ans;
    rep(now,n){
        if (h[now] >= h[now + 1] && now != n-1)
            cnt++;
        else{
        ans.push_back(cnt);
        cnt = 0;
        }
    }
    sort(ans.begin(), ans.end(), greater<int>());
    cout << ans[0] << endl;
}

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

int main() {
	int n;
	cin >> n;
	for (int i = 0; i < n/4+1; i++) {
		for (int j = 0; j < (n - 4 * i) / 7+1; j++) {
			if (4 * i + 7 * j == n) {
				std::cout << "Yes" << endl;
				return 0;
			}
		}
	}
	std::cout << "No" << endl;
}

Measured memory_bytes: 256
#include<cstdio>
#include<cstring>
#include<iostream>
#include<queue>
#include<string>
using namespace std;
struct Eng {
  string str;
  int count;
};
int main(){
  Eng data[3333],temp;
  string str,box="\0";
  int f=0,num=0,flag;
  getline(cin , str);
  int str_size = str.size();
  for(int i=0;i<str_size;i++){
    if(str[i] == ' '){
      data[num].str = str.substr( f , i - f );
      for(int j=0;j<num;j++){
	if(data[num].str == data[j].str){
	  data[j].count++;	
	}
      }
      f = i + 1;
      num++;
    }
    else if(i == str_size-1){
      data[num].str = str.substr( f , i - f + 1  );
      for(int j=0;j<num;j++){
	if(data[num].str == data[j].str)data[j].count++;
      }
      num++;
    }
  }
  for(int i=0;i<num-1;i++){
    for(int j=num-1;j>i;j--){
      if(data[j].count>data[j-1].count){
	temp = data[j];
	data[j] = data[j-1];
	data[j-1] = temp;
      }
    }
  }
  for(int i=0;i<num;i++)
    if(box.size()<data[i].str.size())box = data[i].str; // 長さ確保
  cout << data[0].str << ' ' << box << endl;
}

Measured memory_bytes: 1240
// Created by sz
#include <bits/stdc++.h>
using namespace std;

const int maxn = 105;
int n;
int h[maxn];

bool all_zero(){
    for(int i = 0; i< n; i++){
        if(h[i] != 0)return false;
    }
    return true;
}

int main(){
#ifdef LOCAL
    freopen("./input.txt", "r", stdin);
#endif
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    
    cin>>n;
    for(int i = 0; i<n; i++) cin>>h[i];
    
    int cnt = 0;
    while (!all_zero()) {
        int j = 0;
        while (j<n&&h[j] == 0) j++;
        while (j<n&&h[j]!= 0) {
            h[j]--;
            j++;
        }
        cnt++;
    }
    cout<<cnt<<endl;
    
    
    
}


Measured memory_bytes: 256
// #1140935 Solution for 0515: School Road by ryogo 
#include<iostream>
using namespace std;
int dp[20][20];
int main(){
	int a,b;
	while(cin>>a>>b){
		if(a == 0 && b == 0) { break; }
		int n;
		cin>>n;
		for(int i=0;i<20;i++)for(int j=0;j<20;j++)dp[i][j]=0;
		for(int i=0;i<n;i++){
			int x,y;
			cin>>x>>y;
			dp[y][x]=-1;
		}
		dp[1][1]=1;
		for(int i=1;i<=b;i++){
			for(int j=1;j<=a;j++){
				if(i==1 && j==1)continue;
				if(dp[i][j]!=-1){
					dp[i][j]=dp[i][j-1]+dp[i-1][j];
				}
				else dp[i][j]=0;
			}
		}
 
		cout<<dp[b][a]<<endl;
	}
}


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

int main() {
  int h, w, k; cin >> h >> w >> k;
  vector<string> c(h);
  int ans = 0;
  rep(i, h) cin >> c[i];

  for (int bi = 0; bi < (1<<h); bi++) {
    for (int bj = 0; bj < (1<<w); bj++) {
      vector<int> R, C;
      rep(i, h) {
        if (bi & (1<<i)) {
          R.push_back(i);
        }
      }
      rep(j, w) {
        if (bj & (1<<j)) {
          C.push_back(j);
        }
      }
      int sum = 0;

      for (auto ri : R) {
        for (auto ci : C) {
          if (c[ri][ci] == '#') sum++;
        }
      }
      if (sum == k) ans++;
    }
  }
  cout << ans << endl;
  return 0;
}

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

int main() {
  int a, b;
  1 <= a <= 10000;
  1 <= b <= 10000;
  cin >> a >> b;
  int c = a * b;
  if ( c % 2 == 0 ) {
    cout << "Even" << endl;
  }
  else { cout << "Odd" << endl ; 
       }
}


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

int main() {

    //入力
    int n;
    cin >> n;

    int ans = 0;
    for (int i=1;i<=n;i+=2) {
        int cnt = 0;
        for (int j = 1;j <= n;++j) {
            if (i % j == 0) {
                ++cnt;
            }
        }
        if (cnt == 8) {
            ++ans;
        }
     }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 3580
#include <bits/stdc++.h>
using namespace std;
typedef bool boolean;

template <typename T>
boolean vmin(T& a, T b) {
	return (a > b) ? (a = b, true) : (false);
}
template <typename T>
boolean vmax(T& a, T b) {
	return (a < b) ? (a = b, true) : (false);
}

template <typename T>
T smax(T x) {
	return x;
}
template <typename T, typename ...K>
T smax(T a, const K &...args) {
	return max(a, smax(args...));
}

template <typename T>
T smin(T x) {
	return x;
}
template <typename T, typename ...K>
T smin(T a, const K &...args) {
	return min(a, smin(args...));
}

// debugging lib

#define VN(x) #x
#define Vmsg(x) VN(x) << " = " << (x)
#define printv(x) cerr << VN(x) << " = " << (x);
#define debug(...) fprintf(stderr, __VA_ARGS__);

template <typename A, typename B>
ostream& operator << (ostream& os, const pair<A, B>& z) {
	os << "(" << z.first << ", " << z.second << ')';
	return os;
}
template <typename T>
ostream& operator << (ostream& os, const vector<T>& a) {
	boolean isfirst = true;
	os << "{";
	for (auto z : a) {
		if (!isfirst) {
			os << ", ";
		}
		os << z;
		isfirst = false;
	}
	os << '}';
	return os;
}

#define pii pair<int, int>
#define pil pair<int, ll>
#define pli pair<ll, int>
#define ll long long
#define ull unsigned long long

const int inf = (signed) (~0u >> 2);
const ll llf = (signed ll) (~0ull >> 2);

#define pb push_back
#define eb emplace_back
#define fi first
#define sc second

template <typename T>
int vsize(vector<T>& x) {
	return (signed) x.size(); 
}

template <typename T>
int discrete(T* a, int* b, int n) {
    vector<T> v(a + 1, a + n + 1);
    sort(v.begin(), v.end());
    v.erase(unique(v.begin(), v.end()), v.end());
	for (int i = 1; i <= n; i++) b[i] = lower_bound(v.begin(), v.end(), a[i]) - v.begin() + 1;
	return v.size();
}

mt19937 rng (time(NULL));

int randint(int l, int r) {
	return rng() % (r - l + 1) + l;
}

int X;

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0), cout.tie(0);
	cin >> X;
	cout << 360 / __gcd(X, 360) << '\n';
	return 0;
}


Measured memory_bytes: 3620
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
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; }

/* attention
    long longのシフト演算には気をつけよう
    タイポした時のデバッグが死ぬほどきつくなるので変数名は最低3字くらい使った方がいいかも
    sizeは(int)とキャストしよう
    ごちゃごちゃ場合分けを考える前に全探索は考えましたか？
*/

const ll mod = 1e9+7;

void chmod(ll &M){
    if(M >= mod) M %= mod;
    else if(M < 0){
        M += (abs(M)/mod + 1)*mod;
        M %= mod;
    }
}

ll modpow(ll x, ll n){
    if(n == 0) return 1;

    ll res = modpow(x, n/2);
    if(n%2 == 0) return res*res%mod;
    else return res*res%mod*x%mod;
}

ll power(ll x, ll n){
    if(n == 0) return 1;

    ll res = power(x, n/2);
    if(n%2 == 0) return res*res;
    else return res*res*x;
}

int getl(int i, int N) { return i==0? N-1:i-1; };
int getr(int i, int N) { return i==N-1? 0:i+1; };

/* <--------------------------------------------> */

ll dp[110][4][4][4] = {};

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

    int n; cin >> n;
    for(int i=0; i<4; ++i) for(int j=0; j<4; ++j) for(int k=0; k<4; ++k){
        if(i==0 && j==1 && k==2) continue;
        if(i==1 && j==0 && k==2) continue;
        if(i==0 && j==2 && k==1) continue;
        dp[3][i][j][k] += 1;
    }

    for(int len=3; len<n; ++len){
        for(int i=0; i<4; ++i) for(int j=0; j<4; ++j) for(int k=0; k<4; ++k){
            for(int a=0; a<4; ++a){
                if(j==0 && k==1 && a==2) continue;
                if(j==0 && k==2 && a==1) continue;
                if(j==1 && k==0 && a==2) continue;
                if(i==0 && k==1 && a==2) continue;
                if(i==0 && j==1 && a==2) continue;
                dp[len+1][j][k][a] += dp[len][i][j][k];
                chmod(dp[len+1][j][k][a]);
            }
        }
    }

    ll ans = 0;
    for(int i=0; i<4; ++i) for(int j=0; j<4; ++j) for(int k=0; k<4; ++k){
        ans += dp[n][i][j][k];
        chmod(ans);
    }
    printf("%lld\n", ans);
    
	return 0;
}


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

// エイリアス
using  ll = long signed long;
using ull = long unsigned long;
using  ld = long double;
using   P = pair<int, int>;
using llP = pair<ll, ll>;
using DoP = pair<double, double>;

// 汎用マクロ
#define ALL(a) (a).begin(), (a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define rep(i, n) for (int i = 0; i < n; ++i)
#define FOREACH(i,q) for (auto &i : q)
#define UNIQUE(v) do { sort((v).begin(), (v).end()); (v).erase(unique((v).begin(), (v).end()), (v).end()); } while (false)
#define SZ(x) ((int)(x).size())
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;}
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 << 28;
const ll INF64 = 1ll << 60;
const int mod = 1000000007;
//const int mod = 998244353;
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 n; cin >> n;
  auto f = [&](string a, string b) {
    return (int)max(a.size(), b.size());
  };

  int ans = INF;
  for(ll a = 1; a <= sqrt(n); ++a) {
    if(n%a == 0) {
      ll b = n/a;
      chmin(ans, f(to_string(a), to_string(b)));
    }
  }
  cout << ans << endl;
}


Measured memory_bytes: 3724
#include<iostream>
#include<vector>
#include<unordered_map>
using namespace std;

int main(){
  int n;
  cin >> n;
  
  vector<long long> a(n);
  for(int i = 0 ; i < n ; ++i){
    cin >> a[i];
  }
  
  vector<long long> sum(n + 1);
  for(int i = 1 ; i <= n ; ++i){
    sum[i] = sum[i - 1] + a[i - 1];
  }
  
  // sum[i] = sum[j](j < i)となる個数を足していくと、問題の答えになる
  // そこで、(ハッシュ)連想配列クラスを用いる
  // https://cpprefjp.github.io/reference/map/map.html
  // https://cpprefjp.github.io/reference/unordered_map/unordered_map.html
  // いずれかを用いて、今までに何個その数があったのかを記録していく
  // それを足していくと、問題の答えになる
  // sum[i] = 0の場合は、sum[j] = 0となる場合の他に
  // 最初からiまで全部を持ってきても部分列の和が0となる
  // そこで、sum[0] = 0を仕込んでおくことで、0以外の場合と同じように計算できる
  unordered_map<long long, long long> mp;
  long long ans = 0;
  for(int i = 0 ; i <= n ; ++i){
    ans += mp[sum[i]];
    ++mp[sum[i]];
  }
  
  cout << ans << endl;
  
  return 0;
}

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

int main()
{
    cin>>s;
    int len=s.size();
    for(int i=0;i<len;i++)
      if(s[i]=='C')
        for(int j=i+1;j<len;j++)
          if(s[j]=='F')  {printf("Yes\n");return 0;}
    printf("No\n");
    return 0;
}


Measured memory_bytes: 256
#include<cstdio>
#include<iostream>
using namespace std;
#define LL long long

const int N = 1e5+7;
int A[N];

int main() {
    int n, x;
    scanf( "%d%d", &n, &x );
    for( int i = 0; i < n; ++i ) {
        scanf( "%d", A+i );
    }
    LL ans = 0;
    for( int i = 0; i < n-1; ++i ) {
        if( A[i]+A[i+1] > x ) {
            int tmp = A[i]+A[i+1] - x;
            ans += tmp;
            A[i+1] -= tmp;
            A[i+1] = max( A[i+1], 0 );
        }
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll inf=9223372036854775807ll;

struct line{
	ll k,b;
	line(ll k=0,ll b=0):k(k),b(b){}
	ll get(ll x){return k*x+b;}
}st[300010],u;

int tp;

double its(line a,line b){
	return (b.b-a.b)/double(a.k-b.k);
}

int t[300010],n;
ll s[300010],f[300010],g[300010];
void dp(ll*f){
	int i;
	for(int i=1;i<=n;i++) s[i]=s[i-1]+t[i];
	tp=1;
	st[1]=line(0,0);
	for(int i=1;i<=n;i++){
		while(tp>1&&st[tp].get(i)<=st[tp-1].get(i)) tp--;
		f[i]=max(st[tp].get(i)+((ll)i*i+i)/2-s[i],f[i-1]);
		u=line(-i,f[i]+((ll)i*i-i)/2+s[i]);
		while(tp>1&&its(u,st[tp-1])>=its(st[tp],st[tp-1])) tp--;
		st[++tp]=u;
	}
}
ll h[300010];
void solve(int l,int r){
	if(l==r){
		h[l]=1ll-t[l];
		return;
	}
	int mid,i,now;
	ll mx;
	mid=(l+r)>>1;
	solve(l,mid);
	solve(mid+1,r);
	tp=0;
	for(int i=l-1;i<mid;i++){
		u=line(-i,f[i]+((ll)i*i-i)/2+s[i]);
		while(tp>1&&its(u,st[tp-1])>=its(st[tp],st[tp-1])) tp--;
		st[++tp]=u;
	}
	now=1;
	mx=-inf;
	for(i=r;i>mid;i--){
		while(now<tp&&its(st[now],st[now+1])>=i)now++;
        mx=max(mx,st[now].get(i)+((ll)i*i+i)/2-s[i]+g[i+1]);
        h[i]=max(h[i],mx);
	}
	tp=0;
	for(i=mid+1;i<=r;i++){
        u=line(-i,g[i+1]+((ll)i*i+i)/2-s[i]);
        while(tp>1&&its(u,st[tp-1])>=its(st[tp],st[tp-1]))tp--;
        st[++tp]=u;
    }
    now=tp;
    mx=-inf;
    for(i=l-1;i<mid;i++){
        while(now>1&&its(st[now],st[now-1])<=i)now--;
        mx=max(mx,st[now].get(i)+((ll)i*i-i)/2+s[i]+f[i]);
        h[i+1]=max(h[i+1],mx);
    }
}
int main(){

	int i,m,x,y;
	cin>>n;
	for(i=1;i<=n;i++) scanf("%d",t+i);
	dp(f);
	reverse(t+1,t+n+1);
	dp(g);
	reverse(t+1,t+n+1);
	reverse(g+1,g+n+1);
	for(i=1;i<=n;i++)s[i]=s[i-1]+t[i];
    solve(1,n);
    scanf("%d",&m);
    while(m--){
        scanf("%d%d",&x,&y);
        printf("%lld\n",max(f[x-1]+g[x+1],h[x]+t[x]-y));
    }
}

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

using namespace std;

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

    int sum = 0;
    int loc = 0;
    for(int i = 0; i < N; i++){
        sum += abs(loc - A[i]);
        loc = A[i];
    }
    sum += abs(A[N-1]);

    for(int i = 0; i < N; i++){
        if(i == 0){
            cout<<sum - abs(A[0]) -abs(A[1]- A[0]) + abs(A[1])<<endl;
        }else if(i == N-1){
            cout<<sum - abs(A[N-1]) -abs(A[N-1]-A[N-2])+ abs(A[i-1])<<endl;
        }else{
            cout<<sum - abs(A[i]-A[i-1]) -abs(A[i+1]-A[i])+abs(A[i+1]-A[i-1])<<endl;;
        }
    }

    return 0;
}

Measured memory_bytes: 1664
#include<iostream>
#include<string>
using namespace std;
int main(){
  string s;
  cin >> s;
  if(s == "Sunny"){
    cout << "Cloudy" << endl;
  }
  else if(s == "Rainy"){
    cout << "Sunny" << endl;
  }
  else {
    cout << "Rainy" << endl;
  }
  return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
int main(void){
    // Your code here!
    int n,m,x,y,i,max=-101,min=100;
    scanf("%d%d%d%d",&n,&m,&x,&y);
    int a[n],b[m];
    for(i=0;i<n;i++){
        scanf("%d",&a[i]);
        if(max<a[i]) max=a[i];
    }
    for(i=0;i<m;i++){
        scanf("%d",&b[i]);
        if(min>b[i]) min=b[i];
    }
    for(i=max+1;i<=min;i++){
        if(x<i && i<=y){
            printf("No War");
            return 0;
        }
    }
    printf("War");
    return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
int main()
{
	long long  a,b,x,n;
	scanf("%lld %lld %lld" ,&a,&b,&x);
	n=(b/x) - (a/x);
    if(a%x == 0)
    ++n;
    printf("%lld\n",n);
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define sz(x) (int) x.size()
#define cat(x) cerr << #x << " = " << x << endl
#define all(x) x.begin(), x.end()
#define rep(i, j, n) for (int i = j; i <= n; ++i)
#define per(i, j, n) for (int i = n; j <= i; --i)
 
using ll = long long;
using ld = long double;
using namespace std;
 
const int N = 5005;
const ll INF = 1e18;

int n, h[N], p[N], ord[N];	
ll dp[N][N];
 
int main() {
	scanf ("%d", &n);
	rep(i, 1, n) {
		scanf ("%d%d", h + i, p + i);
		ord[i] = i;
	}
	sort(ord + 1, ord + n + 1, [&](int a, int b) {
		return p[a] + h[a] < p[b] + h[b];
	});
	
	rep(i, 0, n)
		rep(j, 0, n)
			dp[i][j] = INF;
	dp[0][0] = 0;
	rep(i, 0, n - 1) {
		int x = ord[i + 1];
		rep(j, 0, i) {
			if (dp[i][j] == INF) continue;
			dp[i + 1][j] = min(dp[i + 1][j], dp[i][j]);
			if (dp[i][j] <= h[x])
				dp[i + 1][j + 1] = min(dp[i + 1][j + 1], dp[i][j] + p[x]);
		}
	}
	per(i, 0, n)
		if (dp[n][i] != INF)
			return !printf ("%d\n", i);
	return 0;
}


Measured memory_bytes: 199352
program main

  implicit none
  integer :: i,j,n
  character(100) :: s, t
  character(200) :: st


  read(*,*) n
  read(*,*) s, t


  j = -1
  do i = 1, n
    j = j + 1
    st(j:j) = s(i:i)
    j = j + 1
    st(j:j) = t(i:i)
  end do

  write(6,"(1p,A)") st(0:2*n-1)

end program main

Measured memory_bytes: 256
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

fn main() {
    input! {
        N: u32,
        K: u32,
    }
    
    let mut  num : u32 = K;
    for i in 1..N {
        num = num * (K - 1);
    }

    println!("{}",num)
}


Measured memory_bytes: 4352
#!/usr/bin/perl
#= CPAN mocules =====================================================#
use strict;				# strictモード
use warnings;			# 警告有効

#= Global values ====================================================#
#= Local routines ===================================================#
sub main(){
	my $in = <>;chomp $in;
	my ($n, $k) = split(/ /, $in);

	my $remain = $n % $k;
	my $min;
	if ($remain == 0){
		$min = 0;
	}else{
		my $diff = $remain - $k;
		if ($diff < 0){$diff *= -1;}
		if ($remain > $diff){$remain = $diff;}
		
		$min = $remain;
	}

	print $min, "\n";

	return 0;
}

#----- 実行 -----#
exit( main() );




Measured memory_bytes: 640
#include <iostream>

using namespace std;

int main(){
    int h,w;
    int i,j;
    
    while(1){
    
        cin >> h >> w;
        
        if(h == 0 && w == 0){
            break;
        }
    
        for(i = 0;i < h;i++){
            if(i % 2 ==0){
                for(j = 0;j < w;j++){
                    if(j % 2 == 0){
                        cout << '#';
                    }else{
                        cout << '.';
                    }
                }
            }else{
                for(j = 0;j < w;j++){
                    if(j % 2 == 0){
                        cout << '.';
                    }else{
                        cout << '#';
                    }
                }
            }
            
            cout << endl;
        }
        
        cout << endl;
    }
    
    return 0;
}


Measured memory_bytes: 3084
function Main(input) {
  	W = parseInt(input.split(" ")[0]);
	H = parseInt(input.split(" ")[1]);
    x = parseInt(input.split(" ")[2]);
  	y = parseInt(input.split(" ")[3]);	
  
  	WH = ((W*H/2).toFixed(6));
  	if(x+x==W && y+y==H){
        console.log(WH + " " + 1);
    }else{
    	console.log(WH + " " + 0);
	}
}
Main(require("fs").readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 7372