akhauriyash/Code-Regression huggingface dataset:
#pragma GCC optimize ("Ofast")
#include<bits/stdc++.h>
using namespace std;
inline void rd(long long &x){
  int k;
  int m=0;
  x=0;
  for(;;){
    k = getchar_unlocked();
    if(k=='-'){
      m=1;
      break;
    }
    if('0'<=k&&k<='9'){
      x=k-'0';
      break;
    }
  }
  for(;;){
    k = getchar_unlocked();
    if(k<'0'||k>'9'){
      break;
    }
    x=x*10+k-'0';
  }
  if(m){
    x=-x;
  }
}
inline void wt_L(char a){
  putchar_unlocked(a);
}
inline void wt_L(const char c[]){
  int i=0;
  for(i=0;c[i]!='\0';i++){
    putchar_unlocked(c[i]);
  }
}
int main(){
  long long X;
  long long Y;
  rd(X);
  rd(Y);
  if(abs(X-Y)<=1){
    wt_L("Brown");
    wt_L('\n');
  }
  else{
    wt_L("Alice");
    wt_L('\n');
  }
  return 0;
}
// cLay varsion 20190921-1

// --- original code ---
// {
//   ll X, Y;
//   rd(X,Y);
//   wt( if[abs(X-Y)<=1, "Brown", "Alice"] );
// }

Measured memory_bytes: 256
#include<cstdio>
    typedef long long ll;
    ll min(ll a,ll b) {return a>b?b:a;}
    int main()
    {
    	int n;
    	ll T,x,pre,ans=0;
    	scanf("%d%lld",&n,&T);
    	for(int i=1;i<=n;i++)
    	{
    		scanf("%lld",&x);
    		if(i==1) {pre=x;continue;}
    		ans+=min(x-pre,T);
    		pre=x;
    	}
    	printf("%lld\n",ans+T);
    	return 0;
    }

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, srt, end) for (long long i = (srt); i < (long long)(end); i++)
#define VL vector<ll>
#define VS vector<string>
#define VB vector<bool>
#define VP vector<pair<ll,ll>>
#define VVL vector<vector<ll>>
#define VVP vector<vector<pair<ll,ll>>>
#define PL pair<ll,ll>
#define ALL(v) (v).begin(), (v).end()
ll d1[4] = {1, -1, 0, 0};
ll d2[4] = {0, 0, 1, -1};

int main(){
    ll n;
    cin >> n;
    VL a(n);
    rep(i, 0, n) cin >> a[i];
    sort(ALL(a), greater<ll>());
    ll ans = a[0];
    ll i = 1;
    rep(j, 0, n-2){
        ans += a[i];
        if(j % 2 == 1) i++;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 4836
#include<iostream>
#include<algorithm>
#include<string>
#include<cctype>
#include<map>

using namespace std;

int now;
string str;
map<string,int>mp;

int Number(void){
	int res=0;
	while('0'<=str[now] && str[now]<='9'){
		res*=10;
		res+=str[now++]-'0';
	}
	return res;
}

char CapitalLetter(void){
	char res=str[now++];
	return res;
}

char SmallLetter(void){
	char res=str[now++];
	return res;
}

int Atom(void){

	string s;
	s+=CapitalLetter();
	if(islower(str[now]))s+=SmallLetter();
	if(mp.count(s))return mp[s];
	return -1;
}

int Molecule(void){
	
	int res=0;
	if(isupper(str[now])){
		res+=Atom();
		if(res<0)return -1;
		if('0'<=str[now] && str[now]<='9')res*=Number();
	}
	else if(str[now]=='('){
		now++;
		int tmp=Molecule();
		if(tmp<0)return -1;
		res+=tmp;
		now++;
		res*=Number();
	}
	
	
	if(now<str.size() && str[now]!=')'){
		int tmp=Molecule();
		if(tmp<0)return -1;
		res+=tmp;
	}
	return res;
}

int main(void){
	
	int n;
	string s;
	
	while(true){
		cin >> s;
		if(s=="END_OF_FIRST_PART")break;
		cin >> n;
		mp[s]=n;
	}
	
	while(true){
		cin >> str;
		if(str=="0")break;
		now=0;
		int res=Molecule();
		if(res<0)cout << "UNKNOWN" << endl;
		else cout << res << endl;
	}
	
return 0;
}

Measured memory_bytes: 1236
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < n; i++)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define ALL(v) (v).begin(), (v).end()
#define coutd(n) cout << fixed << setprecision(n)
#define ll long long int
#define vl vector<ll>
#define vi vector<int>
const int INF = 2147483647;
const ll MOD = 1000000007;

using namespace std;

ll dp[1000000][2] = {};
int main() {
  string n;
  cin >> n;
  dp[0][0] = n[0] - '0';
  dp[0][1] = 1 + (10 - (n[0] - '0'));
  int size = n.length();
  FOR(i, 1, size) {
    char cur = n[i];
    dp[i][0] = min(dp[i - 1][0], dp[i - 1][1]) + (cur - '0');
    dp[i][1] = min(dp[i - 1][0], dp[i - 1][1] - 2) + 11 - (cur - '0');
  }
  cout << min(dp[size - 1][0], dp[size - 1][1]) << endl;
  return 0;
}


Measured memory_bytes: 17028
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#include<math.h>
 
#define sl(x) scanf("%ld", &x)
#define ss(x) scanf("%s", x)
#define pl(x) printf("%ld\n", x)
#define ps(x) printf("%s\n", x)
 
#define INF 100000000000
#define MOD 1000000007
 
#define MIN(a,b) (((a)<(b))?(a):(b))
#define MAX(a,b) (((a)>(b))?(a):(b))

int main() {
	long N, A, B;
	long X[100001];
	long i, j;
	long table[1001] = {0};
	long ans = 0;
	long tmp;
	
	sl(N); sl(A); sl(B);
	for(i=1;i<=N;i++) {
		sl(X[i]);
	}
	
	for(i=2;i<=N;i++) {
		ans += MIN(A*(X[i]-X[i-1]), B);
	}
	
	pl(ans);
	
	return 0;
}

Measured memory_bytes: 896
N = int(input())
scores = []
for i in range(N):
  scores.append(list(map(int, input().split())))
D = scores[0]
for day in range(1, N):
  D = [max(D[:i] + D[i+1:]) + scores[day][i] for i in range(len(D))]

print(max(D))

Measured memory_bytes: 61784
n = int(input())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
c = list(map(int, input().split()))

before = a[0]
ans = b[a[0]-1]
for i in range(1,n):    
    ans += b[a[i]-1]
    if before+1 == a[i]:
        ans += c[before-1]
    before = a[i]
print(ans)

Measured memory_bytes: 3064
import math

N, M = list(map(int, input().split()))

if N in [M, M+1, M-1]:
    n = math.factorial(N) * math.factorial(M)
    if N == M:
        print(n*2 % (10**9+7))
    else:
        print(n % (10**9+7))
else:
    print(0)

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

int main(){
    int k,n;
    cin>>k>>n;
    vector<int> a(n);
    int distance=0;
    cin>>a.at(0);
    for(int i=1;i<n;++i){
        cin>>a.at(i);
        distance=max(distance,a.at(i)-a.at(i-1));
    }
    distance=max(distance,k-a.at(n-1)+a.at(0));
    cout<<k-distance<<endl;
    return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
#define ll int64_t
#include <cstdlib> 
#include <math.h>
#include<cstdio>
#include<cstring>
#define dbg(x) cout << #x << " = " << x << endl
#define dbg2(x,y) cout << #x << " = " << x << ", " << #y << " = " << y << endl
#define dbg3(x,y,z) cout << #x << " = " << x << ", " << #y << " = " << y << ", " << #z << " = " << z << endl
#define dbg4(x,y,z,q) cout << #x << " = " << x << ", " << #y << " = " << y << ", " << #z << " = " << z << ", " << #q << " = " << q << endl
#define FOR(I, A, B) for (int I = (A); I <= (B); I++)
typedef vector< int > vi;
typedef vector< vi > vvi;
typedef pair< int,int > ii;
#define gap cout<<endl;
#define IOS ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define fo(i,n) for(int i=0;i<n;i++)
#define sz(a) ll((a).size())
#define pb push_back
#define all(c) (c).begin(),(c).end()
#define tr(c,i) for(typeof((c)).begin() i = (c).begin(); i != (c).end(); i++)
#define present(c,x) ((c).find(x) != (c).end())
#define cpresent(c,x) (find(all(c),x) != (c).end())

int main(){
    int n;
    cin>>n;
    vector<int> a(n);
    fo(i,n) cin>>a[i];
    int avg=accumulate(all(a),0)/n;
    vector<int> nn{avg,avg+1};
    
    int maax=INT_MAX;
    for(auto j:nn){
        int tmp=0;
        fo(i,n){
            tmp=tmp+(a[i]-j)*(a[i]-j);
            
            
        }
        maax=min(maax,tmp);
    }
    cout<<maax<<endl;
    
}


Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
using namespace std;
const int N=2005;
const int MOD=1000000007;
int n,k;
int a[N];
int main()
{
	scanf("%d%d",&n,&k);
	for(int i=1;i<=n;i++)
		scanf("%d",&a[i]);
	long long ans=0;
	for(int i=1;i<=n;i++)
		for(int j=i+1;j<=n;j++)
			if(a[i]>a[j]) ans++;
	ans=ans*k%MOD;
	long long sn=0;
	for(int i=1;i<=n;i++)
	{
		int num=0;
		for(int j=1;j<=n;j++)
			if(a[j]>a[i]) num++;
		sn+=num;
	}
	sn%=MOD;
	long long sk=1LL*(k-1)*k/2%MOD;
	ans=(ans+sn*sk%MOD)%MOD;
	printf("%lld",ans);
	return 0;
}


Measured memory_bytes: 3736
import collections,sys
def LI(): return list(map(int,sys.stdin.readline().split()))
N,Q = LI()
ab = [LI() for _ in range(N-1)]
px = [LI() for _ in range(Q)]
ans = [0]*(N+1) #1_index
graph = [collections.deque() for _ in range(N+1)] #1_index
for a,b in ab:
        graph[a].append(b)
        graph[b].append(a)
for p,x in px:
    ans[p] += x
seen = [0]*(N+1) #1_index
stack = []
def dfs():
    seen[1] = 1
    stack.append(1)
    while stack:
        s = stack.pop()
        if not graph[s]:
            continue
        for j in range(len(graph[s])):
            g_NO = graph[s].popleft()
            if seen[g_NO]:
                continue
            seen[g_NO] = 1
            stack.append(g_NO)
            ans[g_NO] += ans[s]
dfs()
print(*ans[1:])


Measured memory_bytes: 241824
package main

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

type square struct {
	h int64
	w int64
}

const (
	white = '#'
	black = '.'
)

func main() {

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

	var in []*square
	for {
		s := &square{
			nextInt(sc),
			nextInt(sc),
		}

		if s.h == 0 && s.w == 0 {
			break
		}
		in = append(in, s)
	}

	var boards [][]string
	for _, s := range in {
		boards = append(boards, s.getBoard())
	}

	var results []string
	for _, b := range boards {
		results = append(results, strings.Join(b, "\n")+"\n")
	}

	fmt.Println(strings.Join(results, "\n"))
}

func nextString(sc *bufio.Scanner) string {
	sc.Scan()
	return sc.Text()
}

func nextInt(sc *bufio.Scanner) int64 {
	i, err := strconv.ParseInt(nextString(sc), 10, 64)
	if err != nil {
		panic(err)
	}
	return i
}

func (sq *square) getBoard() []string {
	l := make([]string, sq.h)
	for y := int64(0); y < sq.h; y++ {
		l[y] = getLine(y, sq.w)
	}
	return l
}

func getLine(y, w int64) string {
	r := make([]rune, w)
	for x := int64(0); x < w; x++ {
		r[x] = getDot(x, y)
	}
	return string(r)
}

func getDot(x, y int64) rune {
	if (x+y)%2 == 0 {
		return white
	}
	return black
}



Measured memory_bytes: 1792
from itertools import permutations


cook_times = [int(input()) for _ in range(5)]
ans = float('inf')
for ts in permutations(cook_times):
    total = 0
    for t in ts[:-1]:
        if t % 10 == 0:
            total += t
        else:
            total += (t + 9) // 10 * 10
    ans = min(ans, total + ts[-1])
print(ans)

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

typedef long long int ll;
typedef pair<ll, ll> p_ll;
typedef vector<pair<ll, ll>> vec_p; //vector<pair<ll, ll>> pairs(n) ,pairs.at(i) = make_pair(i*i, i)

#define ture ture
#define flase false
#define falg flag

#define REP(i, x) for (ll i = 0; i < (ll)(x); i++)
#define REPS(i, x) for (ll i = 1; i <= (ll)(x); i++)
#define RREP(i, x) for (ll i = ((ll)(x)-1); i >= 0; i--)
#define RREPS(i, x) for (ll i = ((ll)(x)); i > 0; i--)
#define all(x) (x).begin(), (x).end()

const ll MOD = pow(10, 9) + 7;
const ll LLINF = pow(2, 61) - 1;//llの最大9*10^18
const int INF = pow(2, 30) - 1;

ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }

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

    ll N;
    string S,T;
    cin >> S>>T;

    /*ll count_S = 0, count_T = 0;

    REP(i,S.size()-1){
        if(S.at(i)==S.at(i+1)){
        }
        else{
            count_S++;
        }
    }
    REP(i, T.size() - 1)
    {
        if (T.at(i) == T.at(i + 1))
        {
        }
        else
        {
            count_T++;
        }
    }*/

    vector<ll> c_s(26),c_t(26);


    REP(i,S.size()){
        for (ll j = 0; j  <= ('z' - 'a'); j++)
        {
            if (S.at(i) == (char)('a' + j)){
                c_s.at(j)++;
                break;
            }
        }
    }

    REP(i, T.size())
    {
        for (ll j = 0; j <= ('z' - 'a'); j++)
        {
            if (T.at(i) == (char)('a' + j))
            {
                c_t.at(j)++;
                break;
            }
        }
    }

    sort(c_s.begin(), c_s.end());
    sort(c_t.begin(), c_t.end());

    if(c_s==c_t){
        cout << "Yes" << endl;
    }
    else{
        cout << "No" << endl;
    }
}


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

#define int long long
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()
#define rep(i,n) for(int i=0;i<n;++i)
#define rep1(i,n) for(int i=1;i<n;++i)
#define exrep(i, a, b) for(ll i = a; i < b; i++)
#define out(x) cout << x << endl
#define EPS (1e-7)
#define gearup ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);

typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<char> vc;
typedef vector<bool> vb;
typedef vector<double> vd;
typedef vector<string> vs;
typedef vector<pair<int,int> > vpii;
typedef vector<vector<int> > vvi;
typedef vector<vector<char> > vvc;
typedef vector<vector<bool> > vvb;
typedef vector<vector<double> > vvd;
typedef vector<vector<string> > vvs;
typedef vector<ll> vl;
typedef vector<vector<ll> > vvl;
typedef vector<vector<vector<ll> > > vvvl;
ll MOD = 1000000007;
const long long L_INF = 1LL << 60;
const int INF = 2147483647; // 2^31-1
const double PI = acos(-1);
//cout<<fixed<<setprecision(10);

template<class T> inline bool chmin(T& a, T b) {if (a > b) {a = b;return true;}return false;}
template<class T> inline bool chmax(T& a, T b) {if (a < b) {a = b;return true;}return false;}
template<class T> void debug(T v){rep(i,v.size()) cout<<v[i]<<" ";cout<<endl;}
const ll dx[8] = {1, 1, 0, -1, -1, -1, 0, 1};
const ll dy[8] = {0, 1, 1, 1, 0, -1, -1, -1};
//以降 cin の入力元が 'input.txt' になる
//std::ifstream in("input.txt");
//std::cin.rdbuf(in.rdbuf());
 
signed main()
{
    gearup;
    ll n,m,d; cin >> n >> m >> d;
    if(d == 0){
        // 1/n * m-1となる
        double res = 1.0*(m-1)/n;
        cout<<fixed<<setprecision(10);
        out(res);
    }
    else {
        // 2(n-d)/n^2 * m-1となる
        double res = 2.0*(n-d)*(m-1)/(n*n);
        cout<<fixed<<setprecision(10);
        out(res);
    }
}


Measured memory_bytes: 3756
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <cmath>
#include <numeric>
#include <set>
#include <list>
#include <map>
#include<queue>

const int INF = 1 << 28;
const long long MOD = 1000000007;
using namespace std;
using Graph = vector<vector<int>>;

template<class T> bool chmin(T &a, T &b) { if (a > b) { a = b; return 1; }return 0; }
template<class T> bool chmax(T &a, T &b) { if (a < b) { a = b; return 1; }return 0; }
template<class T, class U> using P = pair<T, U>;

vector<int> seen(50,-1);
int counter_for_dfs = 0;
void dfs(Graph &G, int v) {
	seen[v] = counter_for_dfs;
	counter_for_dfs++;
	for (auto v_next : G[v]) {
		if (seen[v_next]>=0)continue;

		dfs(G, v_next);
	}
}

void bfs(Graph &G) {
	vector<int> dist(G.size(), -1);
	queue<int> que;
	
	dist[0] = 0;
	que.push(0);
	while (!que.empty()) {
		int v = que.front();
		que.pop();

		for (int g : G[v]) {
			if (dist[g] != -1)continue;
			dist[g] = dist[v] + 1;
			que.push(g);
		}
	}
	for (auto i : dist) {
		cout << i << " ";
	}
}

int counter[200005] = {};
void bfs2(Graph &G,int p,int x) {
	vector<int> dist(G.size() , -1);
	queue<int> que;
	
	dist[p] = 0;
	que.push(p);
	while (!que.empty()) {
		int v = que.front();
		que.pop();

		for (int g : G[v]) {
			if (dist[g] != -1)continue;
			dist[g] = dist[v] + 1;
			que.push(g);
			counter[g] += x;
		}
	}
}
int main()
{
	int n;
	std::cin >> n;
	int rslt;
	rslt = std::pow(n, 3);

	std::cout << rslt;

	return 0;
}

Measured memory_bytes: 512
#include<bits/stdc++.h>
using namespace std;
#define itn int
#define int long long
#define mod 1000000007
#define fi first
#define se second
#define be begin()
#define en end()
#define re reverse
#define Set setprecision 
const int INFi=2147483647;
const long long INFl=9223372036854775807LL;
template<typename T> T abs(T a,T b){
    return max(a,b)-min(a,b);
}
template<typename T> T lcm(T a,T b){//最小公倍数
  return (a*b)/gcd(a,b);
}
int  gcd(int a,int b){//最大公約数
  int c=a%b;
  while(true){
    if(c==0) break;
    a=b;
    b=c;
    c=a%b;
  }
  return b;
}
double p[3000000],sum=0,m=0;
signed main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n,k;    
    cin>>n>>k;
    for(int i=0;i<n;i++){
	cin>>p[i];
    }
    for(int i=0;i<k;i++){
	sum+=(((p[i]+1)*p[i]/2)/p[i]);
    }
    m=sum;
     for(int i=k;i<n;i++){
	 //cout<<((p[i]+1)*p[i]/2)/p[i]<<"\n";
	 sum+=(((p[i]+1)*p[i]/2)/p[i]);
	 sum-=(((p[i-k]+1)*p[i-k]/2)/p[i-k]);
	 m=max(m,sum);
	 //cout<<sum<<"\n";
     }
    cout<<fixed<<m<<"\n";
}


Measured memory_bytes: 1792
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(n);i++)
#define all(v) v.begin(),v.end()
#define len(x) (ll)(x).length()
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
ll gcd(int a,int b){if(a%b==0){return b;}else{return(gcd(b,a%b));}}
ll lcm(int a,int b){return a*b/gcd(a,b);}
const int INF=1e9;
const ll INFS=1e18;
const int MOD=INF+7;
const int di[] = {-1,0,1,0};
const int dj[] = {0,-1,0,1};
const double PI=acos(-1);

int main() {
  int n;
  cin>>n;
  map<int,int> mp;
  rep(i,n){
    int a;
    cin>>a;
    mp[a]++;
  }
  if(mp.size()==n){
    cout<<"YES"<<endl;
    return 0;
  }
  cout<<"NO"<<endl;
}

Measured memory_bytes: 12984
N, K = gets.chomp.split(" ").map(&:to_i)
A = gets.chomp.split(" ").map(&:to_i)

C = Hash.new
C[0] = [0]
s, ans = [0, 0]
A.map.with_index(1){|a, idx|
  s += a
  tmp = (s - idx) % K
  if C.key?(tmp) then
    i = C[tmp].bsearch_index{|c| idx - c < K}
    ans += (C[tmp].size - i) if !i.nil?
    C[tmp] << idx
  else
    C[tmp] = [idx]
  end
}

puts ans


Measured memory_bytes: 40844
using System;
using System.Collections.Generic;
using System.Linq;
 
static class MainClass {
  public static void Main (string[] args) {
    var C = Convert.ToChar(Console.ReadLine());
    if(C == 'z'){
       Console.WriteLine("z");
       return;
    }
    var ans = (int)C + 1;

    Console.WriteLine(Convert.ToChar(ans));
  }

  static long ModPow (long a, long n, long p) {
    if(n == 1) return a % p;

    if (n % 2 == 1) return (a * ModPow(a, n - 1, p)) % p;

    var t = ModPow(a, n / 2, p);
    return (t * t) % p;
  }

  static long Combination(long n, long a){
    var ary1 = Enumerable.Range((int)n - (int)a + 1, (int)a);
    var ary2 = Enumerable.Range(1, (int)a);
    return ary1.Aggregate((e, next) => e * next) / ary2.Aggregate((e, next) => e * next);
  }

}


Measured memory_bytes: 13268
def main():
    N,K = map(int, input().split())
    S = input()
    if K == 1:
        print(S[0].lower() + S[1:])
    elif K == N:
        print(S[:N-1] + S[N-1].lower())
    else:
        print(S[0:K-1] + S[K-1].lower() + S[K:])

if __name__ == '__main__':
    main()


Measured memory_bytes: 3060
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#define REP0(i,n) for((i)=0;(i)<(int)(n);(i)++)
#define REP1(i,n) for((i)=1;(i)<=(long long)(n);(i)++)
#define ll long long
using namespace std;

ll i,j,k;
const ll MOD = 1000000000 + 7;

int main(){
    ll n;
    string s;
    string ans="";
    cin>>n>>s;
    if(s.size()>n){
        REP0(i,n){
            ans+=s[i];
        }
        ans+="...";
    }   
    else{
        ans=s;
    } 

    cout<<ans<<'\n';
    
    return 0;
}

Measured memory_bytes: 3636
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        // Your code here!
        Scanner sc = new Scanner(System.in);
        int n = 3;
        int[][] board = new int[3][3];
        for (int i = 0; i < n; i++) {
            for (int j = 0; j < n; j++) {
                board[i][j] = sc.nextInt();
            }
        }
        
        int k = sc.nextInt();
        while (k-- > 0) {
            int num = sc.nextInt();
            for (int i = 0; i < n; i++) {
                for (int j = 0; j < n; j++) {
                    if (board[i][j] == num) {
                        board[i][j] = -1;
                    }
                }
            }
        }
        
        for (int i = 0; i < n; i++) {
            if (board[i][0] == -1 && board[i][1] == -1 && board[i][2] == -1) {
                System.out.println("Yes");
                return;
            }
            if (board[0][i] == -1 && board[1][i] == -1 && board[2][i] == -1) {
                System.out.println("Yes");
                return;
            }
        }
        
        if (board[0][0] == -1 && board[1][1] == -1 && board[2][2] == -1) {
            System.out.println("Yes");
            return;
        }
        
        if (board[0][2] == -1 && board[1][1] == -1 && board[2][0] == -1) {
            System.out.println("Yes");
            return;
        }
        
        System.out.println("No");
        
    }
}


Measured memory_bytes: 23764
#include <stdio.h>

#define N 1000

#define swap(a,b) {int tmp;tmp=a;a=b;b=tmp;}

void sort(int a[],int n){
    int i,j;
    for(i=0;i<n;i++){
        for(j=1;j<n-i;j++){
            if(a[j-1]>a[j])
                swap(a[j-1],a[j])
        }
    }
}

int main(){
    int p[N],n,k,i,ans=0;
    scanf("%d%d",&n,&k);
    for(i=0;i<n;i++)
        scanf("%d",&p[i]);
    sort(p,n);
    for(i=0;i<k;i++){
        ans+=p[i];
    }
    printf("%d\n",ans);
}


Measured memory_bytes: 1736
#include <bits/stdc++.h>
using namespace std;
#define FIN ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);

typedef long long ll;
typedef vector<ll> vll;
typedef vector<int> vi;
typedef vector<string> vs;

const int INF = 1000000000;
const int MOD = 1000000007;

int main() {FIN
    
    int n, i, j, k, sw = 0;
    cin >> n;
    vi ar(n);
    for (i = 0; i < n; i++)
		cin >> ar[i];
		
	for (i = 0; i < n - 1; i++) {
		k = i;
		for (j = i + 1; j < n; j++) {
			if (ar[j] < ar[k])
				k = j;
		}
		if (k != i) {
			swap(ar[i], ar[k]);
			sw++;
		}
	}
	
	for (i = 0; i < n; i++) {
		if (i > 0) cout << " ";
		cout << ar[i];
	}
	cout << "\n" << sw << "\n";
    
    return 0;
}



Measured memory_bytes: 3164
N = int(input())
T, A = map(int, input().split())
H = list(input().split())
a = []
b = 0
c = 0
for i in range(N):
        a.append(abs(A - (T - int(H[i]) * 0.006)))
b = min(a)
for i in range(N):
    if b == a[i]:
        c += i
print(c + 1)

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

int main()
{
	int n, a, b, c, d;
	string s;
	cin >> n >> a >> b >> c >> d >> s;
	s = '.' + s;
	bool ans = true, jump = false, over = false, blocked = false;
	for(auto i = a; i < max(c, d); ++i){
		if(s[i] == '#'){
			if(jump){
				ans = false;
				break;
			}
			jump = true;
		}else{
			jump = false;
			if(!over && i == d && (s[i + 1] == '#' || s[i - 1] == '#')) blocked = true;
			if(i >= b - 1 && i + 1 <= c && s[i + 1] == '.' && i + 2 <= c && s[i + 2] == '.') over = true;
		}
	}
	cout << (ans && (c < d || (!blocked && over)) ? "Yes" : "No") << endl;
	return 0;
}

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

using namespace std;

int main(void) {
	int n;
	cin >> n;
	vector< pair<int,int> > mat(n);
	for (int i = 0; i < n; ++i) {
		cin >> mat[i].first >> mat[i].second;
	}
	vector< vector<int> > dp(n,vector<int>(n,(1 << 28)));
	for (int i = 0; i < n; ++i) {
		dp[i][i] = 0;
	}
	for (int k = 1; k < n; ++k) {
		for (int i = 0; i < n-k; ++i) {
			for (int j = 0; j < k; ++j) {
				dp[i][i+k] = min(dp[i][i+j]+dp[i+j+1][i+k]+(mat[i].first*mat[i+j+1].first*mat[i+k].second),dp[i][i+k]);
			}
		}
	}
	cout << dp[0][n-1] << endl;
	return 0;
}



Measured memory_bytes: 3176
#![allow(unused_imports)]
#![allow(dead_code)]
use datastructure::*;
use grapth::*;
use math::*;
use string_algorithm::*;
use util::*;
use input_scanner::*;

use std::cmp;
use std::collections::{BTreeMap, BTreeSet, BinaryHeap, HashMap, HashSet, LinkedList, VecDeque};

fn main() {
    let mut scan = Scanner::new();
    let n: usize = scan.next();

    if vec![2,4,5,7,9].contains(&(n%10)) {
        println!("hon");
    }
    if vec![0,1,6,8].contains(&(n%10)) {
        println!("pon");
    }
    if vec![3].contains(&(n%10)) {
        println!("bon");
    }
}

mod datastructure {}
mod grapth {}
mod math {}
mod string_algorithm {}
mod util {}
mod input_scanner {
    pub struct Scanner {
        bytes: Vec<u8>,
        begin: usize,
        end: usize,
    }
    
    impl Scanner {
        pub fn new() -> Self {
            use std::io::Read;
            let mut buffer: Vec<u8> = Vec::new();
            std::io::stdin().read_to_end(&mut buffer).unwrap();
            let end = (0..buffer.len())
                .find(|i| buffer[*i].is_ascii_whitespace())
                .unwrap_or(buffer.len());
            Scanner {
                bytes: buffer,
                begin: 0,
                end: end,
            }
        }
        pub fn next<T: std::str::FromStr>(&mut self) -> T {
            let s: &str = unsafe { std::str::from_utf8_unchecked(&self.bytes[self.begin..self.end]) };
            let ret: T = s.parse::<T>().ok().expect("Parse error.");
            self.skip();
            ret
        }
        pub fn next_vec<T: std::str::FromStr>(&mut self, n: usize) -> Vec<T> {
            (0..n).map(|_| self.next()).collect()
        }
        pub fn next_word(&mut self) -> Vec<u8> {
            let r = Vec::from(&self.bytes[self.begin..self.end]);
            self.skip();
            r
        }
        fn skip(&mut self) {
            self.begin = (self.end..self.bytes.len())
                .find(|i| !self.bytes[*i].is_ascii_whitespace())
                .unwrap_or(self.bytes.len());
            self.end = (self.begin..self.bytes.len())
                .find(|i| self.bytes[*i].is_ascii_whitespace())
                .unwrap_or(self.bytes.len());
        }
    }
}


Measured memory_bytes: 2132
mod stdin_reader {
  use std::io::stdin;
  use std::io::Read;

  pub struct StdinReader {
    pub buf: Vec<String>,
    pub cursor: usize,
  }

  pub fn new() -> StdinReader {
    StdinReader::new()
  }

  impl StdinReader {
    pub fn new() -> Self {
      let mut s = String::new();
      let stdin = stdin();
      stdin.lock().read_to_string(&mut s).unwrap();
      let buf = s.split_whitespace().map(|s| s.to_string()).collect();
      return StdinReader { buf: buf, cursor: 0 }
    }

    pub fn read_all(&self) -> Vec<String> {
      return self.buf.clone()
    }

    pub fn next(&mut self) -> Option<String> {
      let val = self.buf.get(self.cursor).cloned();
      self.cursor += 1;
      return val
    }

    pub fn as_i64(&mut self) -> Option<i64> {
      self.next().and_then(|s| s.parse::<i64>().ok())
    }

    pub fn as_f64(&mut self) -> Option<f64> {
      self.next().and_then(|s| s.parse::<f64>().ok())
    }

    pub fn as_usize(&mut self) -> Option<usize> {
      self.next().and_then(|s| s.parse::<usize>().ok())
    }
  }
}

mod utils {
  pub fn is_int(n: f64) -> bool {
    let trunc = (n.trunc() as i64) as f64;
    return (n - trunc) < 0.0001
  }
}

fn main() {
  // stdout
  use std::io::{stdout, Write, BufWriter};
  let stdout = stdout();
  let mut writer = BufWriter::new(stdout.lock());

  // stdin
  let mut reader = stdin_reader::new();

  let n = reader.as_f64().unwrap();
  let d = reader.as_f64().unwrap();
  println!("{}", (n / (1.0+2.0*d)).ceil() as i64)
}

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

int main() {
  int N,M;
  cin >> N;
  vector<string> s(N);
  
  for(int i = 0; i < s.size(); i++){
    cin >> s.at(i);
  }
  
  cin >> M;
  vector<string> t(M);
  for(int i = 0; i < t.size(); i++){
    cin >> t.at(i);
  }
  
  vector<int> cnt(N);
  for(int i = 0; i < s.size(); i++){
    for(int j = 0; j < s.size(); j++){
      if(i == j){
        break;
      }
      
      if(s.at(i) == s.at(j)){
        cnt.at(i)++;
      }
    }
    
    for(int j = 0; j < t.size(); j++){
      if(s.at(i) == t.at(j)){
        cnt.at(i)--;
      }
    }
  }
  
  int ans = cnt.at(0);
  for(int i = 1; i < cnt.size(); i++){
    if(ans < cnt.at(i)){
      ans = cnt.at(i);
    }
  }
  
  if(ans < 0){
    cout << 0 << endl;
  }else{
    cout << ans + 1 << endl;
  }
}


Measured memory_bytes: 256
import scala.annotation.tailrec

object Main {
  def main(args: Array[String]): Unit = {
    val sc = new java.util.Scanner(System.in)

    val m = sc.nextLine().split(" ").map(_.toLong).last
    val a = sc.nextLine().split(" ").map(_.toLong)

    println(QDAns.solve(m, a))
  }
}

object QDAns {

  def solve(m: Long, a: Array[Long]): Long = {
    val v = a.foldLeft(1L)((acc, cur) => lcm(acc, cur/ 2))
    a.find(v % _ == 0) match {
      case Some(_) => 0L
      case _ => Math.ceil((m/v)/2.0).toLong
    }
  }

  private def lcm(a: Long, b: Long): Long = {
    if(b > a) {
      lcm(b, a)
    } else {
      a / gcd(a, b) * b
    }
  }

  private def gcd(a: Long, b: Long): Long = {
    @tailrec
    def gcdLoop(c: Long, d: Long):Long = {
      if(d == 0) {
        c
      } else {
        gcdLoop(d, c % d)
      }
    }

    if(b > a) {
      gcd(b, a)
    } else if(a == b) {
      a
    } else {
      gcdLoop(a, b)
    }
  }
}

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

int main() {
  long long a,b,c;
  cin>>a>>b>>c;
  long long x=4*a*b;
  long long z=c-a-b;
  long long y=z*z;
  if(z>0 && x<y) cout<<"Yes"<<endl;
  else cout<<"No"<<endl;
  
}


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

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    int A, B, C, D, t;
    cin >> A >> B >> C >> D;
    t = min(B, D) - max(A, C);
    cout << (t < 0 ? 0 : t) << endl;
    
    return 0;
}

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

using ll = long long;
#define debug(x) cerr << #x << ": " << x << endl;
#define line() cerr << "---------------" << endl;

int main() {
   string s;
   cin >> s;
   int a = 0;
   for (char c:s) {
      a += c - '0';
   }

   if ( stoi(s) % a == 0 ) {
      puts("Yes");
   } else {
      puts("No");
   }

   return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define max(xx,yy) (xx > yy ? xx : yy)
#define min(xx,yy) (xx > yy ? yy : xx)
#define all(x) x.begin(), x.end()
using namespace std;

#ifdef LOCAL
	#define dbg(...) cout << "[ "  << #__VA_ARGS__ << " ] : "; debug(__VA_ARGS__); cout << endl;
#else
	#define dbg(...) (void)32 
#endif

template<typename... T> void debug(T... args){ ((cout << args << ", "), ...); };
template<class T> T input(){ T in; cin >> in; return in; }

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

	int n = input<int>();
	vector<int> v;
	map<int, int> m;
	for(int i = 0;i < n;++i){
		int e = input<int>();
		if(m[e]){
			m[e]++;
			continue;
		}
		m[e]++;
		v.push_back(e);
	}
	n = v.size();
	sort(all(v));
	long long ans = 0;
	for(int i = 0;i < n;++i)
		for(int j = i+1;j < n;++j)
			for(int k = j+1;k < n;++k)
				ans += (v[i] + v[j] > v[k] ? m[v[i]] * m[v[j]] * m[v[k]] : 0);
	cout << ans;
}


Measured memory_bytes: 3656
//#include <cstdio>
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <map>
#include <set>
//#include <queue>
//#include <stack>
#include <cstring>
#include <cassert>

using namespace std;

#ifdef LOCAL_DEBUG
#include <local_debug.h>
#define DEBUG(x...) cerr << __LINE__ << ": " << #x << " = "; DBG::_print(x)
#else
#define DEBUG(x...)
#endif

#define SZ(a) int((a).size())
#define REP(i,n) for(int i=0,_n=(n);i<_n;++i)
#define FOR(i,a,b) for(int i=(a),_b=(b);i<=_b;++i)

typedef long long llong;
typedef vector<int> VI;
typedef vector<VI> VVI;

typedef pair<int,int> II;

#define MAXN 2004
int N;
int A[MAXN];
II P[MAXN];

llong memo[MAXN][MAXN];
llong go(int n, int L, int R) {
   if (n >= N)
      return 0;
   llong& res = memo[L][R];
   if (res < 0) {
      llong curL = go(n+1, L+1, R) + abs(P[n].second-L)*1LL*P[n].first;
      llong curR = go(n+1, L, R-1) + abs(P[n].second-R)*1LL*P[n].first;
      res = max(curL, curR);
   }
   return res;
}

int main(int argc, char* argv[]) {
   ios_base::sync_with_stdio(false); 
   cin.tie(nullptr);

   cin >> N;
   REP(i, N)
      cin >> A[i];

   REP(i, N)
      P[i] = {A[i], i+1};

   sort(P, P+N);
   reverse(P, P+N);

   memset(memo, -1, sizeof(memo));
   llong res = go(0, 1, N);
   cout << res << '\n';

   return 0;
}


Measured memory_bytes: 35200
s = input()
q = int(input())
insts = [input().split() for _ in range(q)]

for inst in insts:
    a, b = int(inst[1]), int(inst[2]) + 1
    if inst[0] == "replace":
        p = inst[3]
        s = s[:a] + p + s[b:]
    elif inst[0] == "reverse":
        s = s[:a] + s[a:b][::-1] + s[b:]
    elif inst[0] == "print":
        print(s[a:b])


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

int main() {
	string s[3];
	string ans = "";
	for (int i  = 0; i < 3; i++) {
		cin >> s[i];
		ans += s[i].at(0) - 'a' + 'A';
	}
	cout << ans << endl;
	return 0;
}

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

const int N = 100100;

int n, h[N], dp[N];

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

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

		if (i == 1) dp[i] = 0;
		else if (i == 2) dp[i] = abs(h[2] - h[1]);
		else dp[i] = min(dp[i - 2] + abs(h[i] - h[i - 2]), dp[i - 1] + abs(h[i] - h[i - 1]));
	}
	cout << dp[n] << "\n";
	return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
int main(){
  int n; cin >> n;
  double a[n];
  for(int i=0; i < n; ++i){
    cin >> a[i];
  }
  double pans;
  for(int i=0; i < n; i++){
    pans += 1/a[i];
  }
  cout << 1/pans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const float pi = 3.1415926535;
unsigned GetDigit(unsigned num){
    return to_string(num).length();
}

int main() {
  int n;
  cin >> n;
  vector<int>a(n);
  vector<int>a_copy(n);
  for (int i = 0; i < n; i++) {
    cin >> a.at(i);
    a_copy.at(i) = a.at(i);
  }
  sort(a_copy.begin(),a_copy.end());
  reverse(a_copy.begin(),a_copy.end());
  
  for (int i = 0; i < n; i++) {
    if (a.at(i) == a_copy.at(0)) cout << a_copy.at(1) << endl;
    else cout << a_copy.at(0) << endl;
  }
}

Measured memory_bytes: 4784
#include <iostream>
using namespace std;
int main()
{
  int a[101] = {0};
  a[0] = 1;
  for (int i = 4; i < 101; ++i)
    if ( i >= 4 && a[i-4] )
      a[i] = 1;
    else if (i >= 7 && a[i-7])
      a[i] = 1;
  
  int N;
  cin >> N;
  cout << ((a[N])?"Yes":"No") << endl;
}

Measured memory_bytes: 256
N, K = list(map(int, input().split()))

if K == 0:
  print(N * N)
  exit()
  
Ans = 0
for i in range(K + 1, N + 1):
  Ans += (i - K) * ((N + 1) // i) + max(((N + 1) %  i) - K, 0)
  
print(Ans)

Measured memory_bytes: 38896
#include <iostream>
#include <cstdlib>
#include <vector>
#include <algorithm>
#include <cstring>
#include <queue>
using namespace std;
typedef pair<int,int> pii;
int table[1100][1100];
int map[1100][1100];
int main()
{
	int height,width,n;
	cin>>height>>width>>n;
	int dx[4]={1,0,-1,0},dy[4]={0,-1,0,1};
	int ans=0;
	pii f;
	memset(map,-1,sizeof(map));
	for(int y=1;y<=height;y++)
	{
		for(int x=1;x<=width;x++)
		{
			char m;cin>>m;
			int temp;
			if(m=='S')
			{
				f.first=x;
				f.second=y;
				temp=0;
			}
			else if(m=='X')
			{
				temp=-1;
			}
			else if(m=='.')
			{
				temp=0;
			}
			else 
			{
				temp=m-'0';
			}
			map[y][x]=temp;
		}
	}
	
	
	
	
	for(int u=1;u<=n;u++)
	{
		queue< pii > que;
		memset(table,-1,sizeof(table));
		que.push(f);
		table[f.second][f.first]=0;
		while(!que.empty())
		{
			pii now=que.front();que.pop();
			if(map[now.second][now.first]==u)
			{
				ans+=table[now.second][now.first];
				f=now;
				break;
			}
			for(int i=0;i<4;i++)
			{
				int x,y;
				x=now.first+dx[i];
				y=now.second+dy[i];
				
				if(map[y][x]!=-1&&table[y][x]==-1)
				{
					table[y][x]=table[now.second][now.first]+1;
					pii next;
					next.first = x;
					next.second = y;
					que.push(next);
				}
			}
			/*
			for(int y=1;y<=height;y++)
			{
				for(int x=1;x<=width;x++)
				{
					cout<<table[y][x];
				}
				cout<<endl;
			}
			*/
		}
	}
	
	cout<<ans<<endl;
}

Measured memory_bytes: 10676
#include<bits/stdc++.h>
const int N=3100;
int P,a[N];

int po[N]={1},Inv[N]={1,1};
int b[N];
int C(int n,int m){
    if(n<0||m<0||n<m) return 0;
    return po[n]*Inv[m]%P*Inv[n-m]%P;
}

int fl=0;
int main(){
    scanf("%d",&P);
    for(int i=1;i<=P+1;i++) po[i]=po[i-1]*i%P;
    for(int i=2;i<=P-1;i++) Inv[i]=(P-P/i)*Inv[P%i]%P;
    for(int i=2;i<=P+1;i++) Inv[i]=Inv[i]*Inv[i-1]%P;
    for(int i=0;i<=P-1;i++)
    {
        int x;scanf("%d",&x);
        if(x)
        {
            fl=1;
            int t=1;
            for(int j=P-1;j>=0;j--)
            b[j]+=C(P-1,j)*t%P,t=t*(P-i)%P;
        }
        else b[0]++;
    }
    for(int i=0;i<=P-1;i++)
    {
        int x=(P-b[i])%P;
        x=(x%P+P)%P;
        printf("%d%c",x,(i==P-1)?'\n':' ');
    }
}


Measured memory_bytes: 256
from sys import stdin, stdout


def solve():
    n = int(input())
    A = [float(i) for i in stdin.readline().split()]
    dp = [[0 for _ in range(n+1)] for _ in range(n+1)]
    dp[0][0] = 1
    for i in range(1, n+1):
        for j in range(0, i+1):
            if j == 0: dp[i][j] = (1 - A[i-1]) * dp[i-1][j]
            else: dp[i][j] = (A[i-1] * dp[i-1][j-1]) + ((1 - A[i-1]) * dp[i-1][j])
    ans = 0
    for i in range((n+1)//2, n+1):
        ans += dp[-1][i]
    return ans

print(solve())



Measured memory_bytes: 275976
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<functional>
int n,m,a[200010];
signed main(){memset(a,0,sizeof(a));scanf("%d%d",&n,&m);int t,maxn(1),ans(0);while(n--){scanf("%d",&t),a[t]++,maxn=(maxn>t?maxn:t);}sort(a,a+maxn+1,std::greater<int>());while(a[m]){ans+=a[m++];}return printf("%d\n",ans),0;}

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

int main()
{
    int ca, cb, cc, k;
    cin>>ca>>cb>>cc>>k;

    vector<long long> a(ca), b(cb), c(cc);
    for (int i=0; i<ca; i++) cin>>a[i];
    for (int i=0; i<cb; i++) cin>>b[i];
    for (int i=0; i<cc; i++) cin>>c[i];

    vector<long long> ab;
    for (int i = 0; i < ca; i++) {
        for (int j = 0; j < cb; j++) {
            ab.push_back(a[i] + b[j]);
        }
    }
    sort(ab.begin(), ab.end());
    reverse(ab.begin(), ab.end());

    vector<long long> abc;
    for (int i = 0; i < min(k, (int)ab.size()); i++) {
        for (int j = 0; j < cc; j++) {
            abc.push_back(ab[i] + c[j]);
        }
    }
    sort(abc.begin(), abc.end());
    reverse(abc.begin(), abc.end());

    for (int i = 0; i < k; i++) {
        cout << abc[i] << endl;
    }
    return 0;
}


Measured memory_bytes: 43112
#include<iostream>
#include<iomanip>
#include<vector>
#include<queue>
#include<list>
#include<stack>
#include<algorithm>
#include<cmath>
#include<memory>
#include<array>

using namespace std;

int main()
{
  array<array<int,8>,8> tbl;
  char c;
  
  while(true)
    {
      for ( auto i = 0; i < 8; ++i )
        for ( auto j = 0; j < 8; ++j )
          {
            if ( cin >> c )
              tbl[i][j] = c - '0';
            else
              return 0;
          }

      for ( auto i = 0; i < 8; ++i )
        for ( auto j = 0; j < 8; ++j )
          {
            if ( tbl[i][j] == 1 )
              {
                if ( tbl[i][j+1] == 1 && tbl[i+1][j] == 1 && tbl[i+1][j+1] == 1 )
                  cout << "A" <<endl;
                else if ( tbl[i+1][j] == 1 && tbl[i+2][j] == 1 && tbl[i+3][j] == 1)
                  cout << "B" << endl;
                else if ( tbl[i][j+1] == 1 && tbl[i][j+2] == 1 && tbl[i][j+3] == 1)
                  cout << "C" << endl;
                else if ( tbl[i+1][j] == 1 && tbl[i+1][j-1] == 1 && tbl[i+2][j-1] == 1)
                  cout << "D" << endl;
                else if ( tbl[i][j+1] == 1 && tbl[i+1][j+1] == 1 && tbl[i+1][j+2] == 1)
                  cout << "E" << endl;
                else if ( tbl[i+1][j] == 1 && tbl[i+1][j+1] == 1 && tbl[i+2][j+1] == 1)
                  cout << "F" << endl;
                else if ( tbl[i][j+1] == 1 && tbl[i+1][j-1] == 1 && tbl[i+1][j] == 1)
                  cout << "G" << endl;

                i = j = 8;
              }
          }
    }
  
  return 0;
}

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

using namespace std;

void __print(int x) {cerr << x;}
void __print(long x) {cerr << x;}
void __print(long long x) {cerr << x;}
void __print(unsigned x) {cerr << x;}
void __print(unsigned long x) {cerr << x;}
void __print(unsigned long long x) {cerr << x;}
void __print(float x) {cerr << x;}
void __print(double x) {cerr << x;}
void __print(long double x) {cerr << x;}
void __print(char x) {cerr << '\'' << x << '\'';}
void __print(const char *x) {cerr << '\"' << x << '\"';}
void __print(const string &x) {cerr << '\"' << x << '\"';}
void __print(bool x) {cerr << (x ? "true" : "false");}

template<typename T, typename V>
void __print(const pair<T, V> &x) {cerr << '{'; __print(x.first); cerr << ','; __print(x.second); cerr << '}';}
template<typename T>
void __print(const T &x) {int f = 0; cerr << '{'; for (auto &i: x) cerr << (f++ ? "," : ""), __print(i); cerr << "}";}
void _print() {cerr << "]\n";}
template <typename T, typename... V>
void _print(T t, V... v) {__print(t); if (sizeof...(v)) cerr << ", "; _print(v...);}
#ifndef ONLINE_JUDGE
#define debug(x...) cerr << "[" << #x << "] = ["; _print(x)
#else
#define debug(x...)
#endif

typedef long long ll;
typedef pair<int, int> pi;

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    
    int a, b;
    cin>>a>>b;

    int x = (b-1)/(a-1);

    if (x*(a-1) < (b-1)) x++;
    cout<<x<<endl;

    return 0;
}

Measured memory_bytes: 256
def binary_search(arr, n, key)
  left = 0
  right = n
  while left < right do
    mid = (left + right) / 2
    if arr[mid] == key
      return true
    elsif arr[mid] < key
      left = mid + 1
    elsif arr[mid] > key
      right = mid
    end
  end
  return false
end

n = gets.to_i
s = gets.split.map(&:to_i)
q = gets.to_i
t = gets.split.map(&:to_i)
cnt = 0
t.each do |key|
  cnt += 1 if binary_search(s, n, key)
end
puts cnt


Measured memory_bytes: 15332
#include <iostream>
using namespace std;
#define NIL -1
const int maxn = 30;
struct Node{int p,l,r;};
Node T[maxn];
int n,D[maxn],H[maxn];
void setD(int u,int d){
	if(u==NIL) return; 
	D[u] = d;
	setD(T[u].l,d+1);
	setD(T[u].r,d+1);
}
int setH(int u){
	int h1=0,h2=0;
	if(T[u].l != NIL)
		h1=setH(T[u].l)+1;
	if(T[u].r != NIL)
		h2=setH(T[u].r)+1;
	return H[u] = (h1>h2?h1:h2);
}
int getSib(int u){
	int n0 = T[u].p;
	if(n0==NIL) return NIL;
	int n1 = T[n0].l,n2 = T[n0].r;
	if(n1!=NIL&&n1!=u)
		return n1;
	if(n2!=NIL&&n2!=u)
		return n2;
	return NIL;
}
void print(int i){
    int d = 0;
    if(T[i].l!=NIL) d++;
    if(T[i].r!=NIL) d++;
	printf("node %d: parent = %d, sibling = %d, degree = %d, depth = %d, height = %d, ",i,T[i].p,getSib(i),d,D[i],H[i]);
    if(T[i].p==NIL) printf("root");
    else if(T[i].l==NIL&&T[i].r==NIL) printf("leaf");
    else printf("internal node");
    printf("\n");
}
void init(){
	for(int i=0;i<n;i++)
		T[i].p=T[i].l=T[i].r=NIL;
}
int main() {
	int m,k,c,i,prt,left,right;
	scanf("%d",&n);
	m = n;
	init();
	while(n--){
		scanf("%d %d %d",&prt,&left,&right);
		T[prt].l = left;
		T[prt].r = right;
		if(left!=NIL) T[left].p = prt;
		if(right!=NIL) T[right].p = prt;
	}
	i=0;
	while(T[i].p!=NIL)
		i++;
	setD(i,0);
	setH(i);
    for(i=0;i<m;i++)
        print(i);
	return 0;
}


Measured memory_bytes: 3204
#include <iostream>

using namespace std;

void ceil(int* money){
        if(int r = *money%1000){
                *money += 1000-r;
        }   
}
void interest(int* money){
        *money += *money*5/100;
}

int main(){
        int n;
        cin >> n;
        int money = 100000;
        for(int i = 0 ; i < n ; i++){
                interest(&money);
                ceil(&money);
        }   
        cout << money << endl;
}

Measured memory_bytes: 0
#include <stdio.h>
#define min(p,q)((p)<(q)?(p):(q))

long long a,b,k;
int main(){
	scanf("%lld%lld%lld",&a,&b,&k);
	long long d=min(a,k);
	a-=d;
	k-=d;
	b-=min(b,k);
	printf("%lld %lld",a,b);
}


Measured memory_bytes: 128
#include <iostream>
#include <vector>
#include <cmath>
#include <string>
#include <climits>
#include <iomanip>
#include <algorithm>
#include <queue>
#include <map>
#include <tuple>
#include <iostream>
#include <deque>
#include <array>
#include <set>


int main() {
	std::string state;
	std::cin >> state;
	int lose = 0;
	for (const auto& c : state) {
		if (c == 'x') {
			lose++;
		}
	}
	if (lose > 7) {
		std::cout << "NO\n";
	}
	else {
		std::cout << "YES\n";
	}
}

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

void print(int curr, int depth, vector<vector<int> >& list, vector<string>& res){
    string dots = "";
    for(int i=0; i<depth; i++){
        dots += ".";
    }
    cout << dots << res[curr] << endl;

    for(int i=0; i<(int)list[curr].size(); i++){
        print(list[curr][i], depth+1, list, res);
    }
}

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

    vector<vector<int> > list(n+1);
    vector<string> res(n+1);
    for(int i=1; i<=n; i++){
        int k;
        cin >> k >> res[i];
        list[k].push_back(i);
    }

    print(1, 0, list, res);
    return 0;
}

Measured memory_bytes: 3972
n = int(input())
i = 0
card = []
cards = []
while i < n:
    card = list(map(str, input().split()))
    cards.append(card)
    i += 1

#print(cards)

s = [i for i in range(1, 14)]
h = [i for i in range(1, 14)]
c = [i for i in range(1, 14)]
d = [i for i in range(1, 14)]

for i in range(n):
    card = cards[i]
    m = card[0]
    num = int(card[1])
    if m == "S":
        s.remove(num)
    elif m == "H":
        h.remove(num)
    elif m == "C":
        c.remove(num)
    else:
        d.remove(num)

for i in range(len(s)):
    (print("S {}" .format(s[i])))
for i in range(len(h)):
    (print("H {}" .format(h[i])))
for i in range(len(c)):
    (print("C {}" .format(c[i])))
for i in range(len(d)):
    (print("D {}" .format(d[i])))


Measured memory_bytes: 5612
//#include "stdafx.h"
#include <iostream>
#include <set>
#include <queue>
#include <vector>
#include <algorithm>
#include <math.h>
#include <cmath>
#include <string>
#include <cstring>
#include <functional>
#include <climits>
#include <sstream>
#include <iomanip>
#include <map>
#include <stack>
#include <tuple>
#include <numeric>
#include <assert.h>
#include <functional>
#include <unordered_map>

using namespace std;

/*-----------------------------------------------------------------------------
　定義
 -------------------------------------------------------------------------------*/
#define REP(i, n)				for (int (i) = 0 ; (i) < (int)(n) ; ++(i))
#define REPN(i, m, n)			for (int (i) = m ; (i) < (int)(n) ; ++(i))
#define INF						2e9
#define MOD						(1000 * 1000 * 1000 + 7)
#define Ceil(x, n)				(((((x))+((n)-1))/n))		/* Nの倍数に切り上げ割り算 */
#define CeilN(x, n)				(((((x))+((n)-1))/n)*n)		/* Nの倍数に切り上げ */
#define FloorN(x, n)			((x)-(x)%(n))				/* Nの倍数に切り下げ */
#define IsOdd(x)				(((x)&0x01UL) == 0x01UL)			
#define IsEven(x)				(!IsOdd((x)))						
#define	BitSetV(Val,Bit)		((Val) |= (Bit))			
#define	BitTstV(Val,Bit)		((Val) & (Bit))				
#define ArrayLength(x)			(sizeof( x ) / sizeof( x[ 0 ]))
#define	MAX_QWORD				((QWORD)0xFFFFFFFFFFFFFFFF)
#define	MIN_QWORD				((QWORD)0x0000000000000000)
#define	MAX_SQWORD				((SQWORD)0x7FFFFFFFFFFFFFFF)
#define	MIN_SQWORD				((SQWORD)0x8000000000000000)
#define M_PI					3.14159265358979323846
typedef long long				ll;
typedef unsigned long			DWORD;
typedef unsigned long long int	QWORD;
typedef pair<ll, ll>			P;

/*-----------------------------------------------------------------------------
　処理
 -------------------------------------------------------------------------------*/
// メイン
int main()
{
	// 入力
	string N;
	cin >> N;

	if (N[0] == N[2]) {
		cout << "Yes" << endl;
	} else {
		cout << "No" << endl;
	}
	return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
const long long INF = 100000000000;
typedef pair<int,int> P;
typedef long long ll;
using Graph = vector<vector<ll>>;

#define PI 3.14159265359
//2の累乗数かどうか
bool hantei(int N) {
	bool flag = false;
	while (1) {
		if (N % 2 == 0) N /= 2;
	}
	if (N == 1) flag = true;

	return flag;
}
vector<ll> divisor(ll n){
	vector<ll> res;//約数を格納する列
	for(ll i= 1;i*i <= n;i++){
		if(n % i == 0){
		   res.push_back(i);
		   if(i != n/i) res.push_back(n/i);
		 }
	}
	return res;
}
int main() {
	int N;
	cin >> N;

	vector<ll> A(N + 1);
	for (int i = 1; i <= N; i++) {
		cin >> A[i];
	}
	map<ll, ll> ma;//
	vector<ll> L(N + 1);
	vector<ll> R(N + 1);

	for (int i = 1; i <= N; i++) {
		L[i] = A[i] + i;
		R[i] = i - A[i];
	}
	for (int i = 1; i <= N; i++) {
		ma[L[i]]++;
	}
	ll ans = 0;
	for (int i = 1; i <= N; i++) {
		if (ma[R[i]] != 0) ans += ma[R[i]];
	}
	cout << ans << endl;
}

Measured memory_bytes: 30704