akhauriyash/Code-Regression huggingface dataset:
package main

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

const (
	defaultBufferSize = 1024
	maxBufferSize     = 1e6
	Mod               = 1e9 + 7
)

var sc = bufio.NewScanner(os.Stdin)

// sc.Buffer(make([]byte, defaultBufferSize), maxBufferSize)

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

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

func readInt64() int64 {
	sc.Scan()
	i, err := strconv.ParseInt(sc.Text(), 10, 64)
	if err != nil {
		panic(err)
	}
	return int64(i)
}

func readfloat64() float64 {
	sc.Scan()
	f, err := strconv.ParseFloat(sc.Text(), 64)
	if err != nil {
		panic(err)
	}
	return f
}

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

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

func max(a, b int) int {
	if a > b {
		return a
	}
	return b
}

func gcd(x, y int) int {
	if y == 0 {
		return x
	}
	return gcd(y, x%y)
}

func ModComb(n, k int) int {
	if k == 0 {
		return 1
	}
	x, y := n, k
	for i := 1; i < k; i++ {
		x = x * (n - i) % Mod
		y = y * (k - i) % Mod
	}
	inv := ModInv(y)
	return x * inv % Mod
}

func ModFact(x int) int {
	fact := 1
	for i := 1; i <= x; i++ {
		fact = fact * i % Mod
	}
	return fact
}

func ModInv(x int) int {
	return ModPow(x, Mod-2)
}

func ModPow(a, n int) int {
	res := 1
	for n > 0 {
		if n%2 != 0 {
			res = res * a % Mod
		}
		a = a * a % Mod
		n /= 2
	}
	return res
}

func pow(a, n int) int {
	if n == 0 {
		return 1
	}

	ans := 0
	if n%2 == 0 {
		ans = pow(a*a, n/2)
	} else {
		ans = a * pow(a*a, (n-1)/2)
	}
	return ans
}

func intSliceReverse(slice []int) []int {
	for i, j := 0, len(slice)-1; i < j; i, j = i+1, j-1 {
		slice[i], slice[j] = slice[j], slice[i]
	}
	return slice
}

func stringReverse(str string) string {
	runes := []rune(str)
	for i, j := 0, len(runes)-1; i < j; i, j = i+1, j-1 {
		runes[i], runes[j] = runes[j], runes[i]
	}
	return string(runes)
}

func primeFactorization(x int) map[int]int {
	result := make(map[int]int, 0)
	for i := 2; i*i <= x; i++ {
		for x%i == 0 {
			result[i]++
			x /= i
		}
	}
	if x != 1 {
		result[x]++
	}
	return result
}

func isPrime(x int) bool {
	if x == 1 {
		return false
	}
	for i := 2; i*i <= x; i++ {
		if i == x {
			continue
		}
		if x%i == 0 {
			return false
		}
	}
	return true
}

func main() {
	sc.Split(bufio.ScanWords)
	x, n := readInt(), readInt()
	num := make(map[int]bool, 100)
	for i := 1; i < 100; i++ {
		num[i] = false
	}
	for i := 0; i < n; i++ {
		p := readInt()
		num[p] = true
	}

	ans := 101
	min := 101
	for i := 0; i <= 101; i++ {
		if num[i] == false && abs(x-i) < min {
			min = abs(x - i)
			ans = i
		}
	}
	fmt.Println(ans)
}


Measured memory_bytes: 1760
#include<bits/stdc++.h>
#define ll long long 
#define inf 0x7fffffff
#define infll 0x7fffffffffffffff
#define clr(c) memset(c,0,sizeof(c))
using namespace std;
int mod=998244353;
const int M=1e6+10;
const int N=2e5+10;
inline ll read(){
    ll b=1,sum=0; char c=getchar();
    while(!isdigit(c)){if(c=='-') b=-1; c=getchar();}
    while(isdigit(c)){sum=sum*10+c-'0'; c=getchar();}
    return b*sum;
}
int T,n,m,k;
int ans;
int a[N];
struct node{
	char c[12];
}s[N];
bool cmp(node x,node y){
	if(strlen(x.c+1)==strlen(y.c+1)) {
		for(int i=1;i<=strlen(x.c+1);i++) {
			if(x.c[i]!=y.c[i]) return x.c[i]<y.c[i];
		}
	}
	return strlen(x.c+1)<strlen(y.c+1);
}
bool check(char *x,char *y) {
	if(strlen(x+1)!=strlen(y+1)) return 1;
	int len=strlen(x+1);
	for(int i=1;i<=len;i++) {
		if(x[i]!=y[i]) return 1;
	}
	return 0;
}
int main()
{
    int i,j;
	ans=0;
	n=read();
	for(i=1;i<=n;i++) {
		scanf("%s",s[i].c+1);
	}
	sort(s+1,s+1+n,cmp);
	for(i=1;i<=n;i++) {
		if(i==1) ans++;
		else {
			if(check(s[i].c,s[i-1].c)) ans++;
		}
	}	
	printf("%d",ans);
	printf("\n");
    return 0;
}


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

int main(){
    int N;
    cin >> N;
    vector<int> a(N);
    for (int i=0; i<N; i++){
        cin >> a.at(i);
    }
    bool all_taken = false;
    int alice = 0, bob = 0;
    while( !all_taken ){
        int max = 0;
        int max_idx = 0;
        for (int i=0; i<N; i++){
            if ( max < a.at(i) ){
                max = a.at(i);
                max_idx = i;
            }
        }
        if (max == 0){
            break;
        }else{
            alice += max;
            a.at(max_idx) = 0;
        }
        max = 0;
        max_idx = 0;
        for (int i=0; i<N; i++){
            if ( max < a.at(i) ){
                max = a.at(i);
                max_idx = i;
            }
        }
        if (max == 0){
            break;
        }else{
            bob += max;
            a.at(max_idx) = 0;
        }
    }
    cout << alice - bob << endl;
}

Measured memory_bytes: 256
#include<stdio.h>
int main(void){
	
	int x,y,tmp;
	
	while(1){
		scanf("%d %d",&x,&y);
		
		if(x==0 && y==0){
			break;
		}
		if(x>y){	//??????
			tmp=y;
			y=x;
			x=tmp;
		}
		printf("%d %d\n",x,y);
	}
	
	return 0;
}

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

int main() { 
    ios_base::sync_with_stdio(0); 
    cin.tie(0);
    string s;
    cin >> s;
    s = '.' + s;
    if ((s[3] == s[4]) and (s[5] == s[6])) cout << "Yes" << '\n';
    else cout << "No" << '\n';
}

Measured memory_bytes: 256
n,m=map(int,input().split())
a=[]
b=[]
c=[]
d=[]
for i in range(n):
  tmp_a,tmp_b=map(int,input().split())
  a.append(tmp_a)
  b.append(tmp_b)
for i in range(m):
  tmp_c,tmp_d=map(int,input().split())
  c.append(tmp_c)
  d.append(tmp_d)

import numpy as np
c=np.array(c)
d=np.array(d)

for i in range(n):
    tmp_x=a[i]
    tmp_y=b[i]
    dis_arr=(abs(c - tmp_x)+abs(d - tmp_y)).tolist()
    print(dis_arr.index(min(dis_arr))+1)
    

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

int main(){
  int k, a, b;
  bool flag = false;
  cin >> k;
  cin >> a >> b;
  for(int i = a; i<=b; i++){
    if(i % k == 0){
      flag = true;
      break;
    }
  }
  
  if(flag){
    cout<<"OK"<<endl;
  } else {
    cout<<"NG"<<endl;
  }
  
  return 0;
}

Measured memory_bytes: 3548
#include <bits/stdc++.h>
using namespace std;
using ll = int64_t;

bool isGu(const string& s) {
  if (s.length() % 2 != 0) return false;

  int half = s.length() / 2;
  string a = s.substr(0, half);
  string b = s.substr(half);
  return a == b;
}

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

  for (int i = 1; i < s.length(); i++) {
    int len = s.length() - i;
    string sub = s.substr(0, len);
    if (isGu(sub)) {
      cout << len << endl;
      return 0;
    }
  }
}


Measured memory_bytes: 3580
#![allow(unused_imports)]

use text_io::*;
use proconio::*;
use std::collections::*;
use std::process::exit;
use std::cmp::*;
use itertools::Itertools;

fn main() {
    input! {
    a:usize,
    }
    println!("{}",if a==3||a==5||a==7 {"YES"}else{"NO"})
}

Measured memory_bytes: 2108
#include <iostream>
#include <string>
#include <math.h>
#include <iomanip>
#include <stdio.h>
#include <algorithm>
#include <ctime>
#include <vector>
#include <set>
#include <queue>
using namespace std;

#define PI 3.14159265358979323846264338327950L

int res;

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

    int N, M, C;
    cin >> N >> M >> C;
    int B[25];
    int A[25][25];
    for(int i = 0; i < M; i++ )
    {
        cin >> B[i];
    }
    for(int i = 0; i < N; i++ )
    {
        for(int j = 0; j < M; j++ )
        {
            cin >> A[i][j];
        }
    }
    int cnt = 0;
    for (int i = 0; i < N; i++)
    {
    int tmp=0;
        for(int j = 0; j < M; j++ )
        {
            tmp += A[i][j] * B[j];
        }
        //cout << tmp+C << endl;
        if(tmp+C>0){
            cnt++;
        }
    }
    cout << cnt << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#ifdef dbg
#include "./printer.hpp"
#else
#define dump(x) void(0)
#endif

#define MOD 1000000007
using namespace std;
#define ll long long
inline long  toInt(string s) {long  v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}

int main(){
  ll n,m;
  while(cin >> n >> m && (n+m)){
    vector<ll> w (m);
    vector<ll> h (n);
    for(ll i = 0; i < n; i++){
      cin >> h[i];
    }
    for(ll i = 0; i < m; i++){
      cin >> w[i];
    }

    unordered_map<ll,ll> hmp, wmp;
    for(ll i = 0; i < n; i++){
      ll cur = h[i];
      hmp[cur]++;
      for(ll k = i + 1; k < n; k++){
	cur += h[k];
	hmp[cur]++;
      }
    }

    for(ll i = 0; i < m; i++){
      ll cur = w[i];
      wmp[cur]++;
      for(ll k = i + 1; k < m; k++){
	cur += w[k];
	wmp[cur]++;
      }
    }
    ll ans = 0;

    for(auto i : hmp){
      ans += i.second * wmp[i.first];
    }
    cout << ans << endl;
    

    
    
  }


  
}

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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<ll, ll> P;

#define EACH(i,a) for (auto& i : a)
#define FOR(i,a,b) for (ll i=(a);i<(b);i++)
#define RFOR(i,a,b) for (ll i=(b)-1;i>=(a);i--)
#define REP(i,n) for (ll i=0;i<(n);i++)
#define RREP(i,n) for (ll i=(n)-1;i>=0;i--)
#define debug(x) cout<<#x<<": "<<x<<endl
#define pb push_back
#define ALL(a) (a).begin(),(a).end()

const ll linf = 1e18;
const int inf = 1e9;
const double eps = 1e-12;
const double pi = acos(-1);

template<typename T>
istream& operator>>(istream& is, vector<T>& vec) {
    EACH(x,vec) is >> x;
    return is;
}
template<typename T>
ostream& operator<<(ostream& os, vector<T>& vec) {
    REP(i,vec.size()) {
        if (i) os << " ";
        os << vec[i];
    }
    return os;
}
template<typename T>
ostream& operator<<(ostream& os, vector< vector<T> >& vec) {
    REP(i,vec.size()) {
        if (i) os << endl;
        os << vec[i];
    }
    return os;
}

int main() {
    std::ios::sync_with_stdio(false);
    std::cin.tie(0);
    ll H, W, n; cin >> H >> W >> n;
    map<P, int> m;
    REP(i, n) {
        int y, x; cin >> y >> x; --y, --x;
        FOR(dx, -1, 2) FOR(dy, -1, 2) {
            m[P(x+dx,y+dy)]++;
        }
    }
    ll cnt = 0;
    vector<ll> ans(10);
    EACH(p, m) {
        ll x, y; tie(x, y) = p.first;
        if (1 <= x && x < W-1 && 1 <= y && y < H-1) {
            ans[p.second]++;
            ++cnt;
        }
    }
    ans[0] = (W-2)*(H-2)-cnt;
    REP(i, ans.size()) cout << ans[i] << endl;
}


Measured memory_bytes: 56576
#include <iostream>
#include <stdio.h>
#include <math.h>
using namespace std;


int main(){
    
	double a, b, c, d, e, f;
    double x, y;
    
	while(cin>> a>> b>> c >> d>> e>> f){
        
        x = 0.0;
        y = 0.0;
        
                
        y = (c*d-f*a)/(b*d-a*e);
        
        x = (c-b*y) / a;

        if (x == 0) {
            x = 0;
        }
        else if (y == 0) {
            y = 0;
        }
        
        printf("%.3f %.3f\n", x, y);
        
        
	}
    
    
	return 0;
}

Measured memory_bytes: 1236
#include "bits/stdc++.h"
#include <set>

using namespace std;
#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define RFOR(i, a, b) for (int i = (b)-1; i >= (a); i--)
#define rep(i, n) for (int i = 0; i < (n); i++)
#define rep1(i, n) for (int i = 1; i < (n); i++)
#define rrep(i, n) for (int i = (n)-1; i >= 0; i--)
#define all(i) (i).begin(), (i).end()
#define rall(i) (i).begin(), (i).end(), greater<int>()
#define int long long
#define elif else if
#define eb emplace_back
#define pb push_back
#define mp make_pair
#define fst first
#define sec second
#define mod 1000000007
#define INF 10e10
template <typename T>

void print(T x)
{
	std::cout << x << " ";
}
template <typename T>

void println(T x)
{
	std::cout << x << "\n";
}

int cnt[1001];

void decompositPrime(int n)
{
	// 割る数の初期値
	int a = 2;
	// √n ≧ a ( n ≧ a * a ) の間ループ処理
	while (n >= a * a) {
		// a で割り切れたら、a は素因数
		// そして、割られる数を a で割る
		// a で割り切れなかったら、 a を 1 増加させる
		if (n % a == 0) {
			cnt[a]++;
			n /= a;
		}
		else {
			a++;
		}
	}
	// 最後に残った n は素因数
	cnt[n]++;
}

signed main(void) {
	int n;
	cin >> n;
	int fact = 1;
	rep(i, n+1) {
		cnt[i] = 1;
	}
	FOR(i,2,n + 1) {
		decompositPrime(i);
	}
	int ans = 1;
	FOR(i, 2, n+1) {
		ans *= cnt[i] % mod;
		ans %= mod;
	}
	print(ans);
}

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

#define SIZE_OF_ARRAY(array) sizeof(array)/sizeof(array[0])

int main() {
    int N;
    cin >> N;
    int A[N];
    for(int i = 0; i < N; i++){
        A[i] = 0;
    }
    for(int i = 1; i < N; i++){
        int a;
        cin >> a;
        A[a-1] += 1;
    }
    for(int i = 0; i < N; i++){
        cout << A[i] << endl;
    }
}

Measured memory_bytes: 4384
#include <iostream>

int main(){
    int Input, h, m, s;
    std::cin >> Input;
    h = Input / 3600;
    m = Input % 3600;
    s = Input % 60;
    m = m / 60;
    std::cout << h << ":" << m << ":" << s << std::endl;
    return 0;
}


Measured memory_bytes: 3100
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define endl "\n"
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
int main()
{
    //IOS;
    //ll t;cin>>t;while(t--)
    {
        ll a,b,c,d,i,j,k,l,m,n,sum=0,temp=0,f=0,cnt=0;
        cin>>a;
        cout<<int(a^1)<<endl;


    }
}


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

int p[1000][1000];
int main(){
	int c,n;scanf("%d%d",&c,&n);
	rep(i,n)rep(j,n)scanf("%1d",&p[i][j]);
	int cnt=0,ans=0;
	rep(i,n)rep(j,n/2){
		if(p[i][j]!=p[i][n-j-1])cnt++;
		if(p[j][i]!=p[n-j-1][i])cnt++;
	}
	if(cnt==0)ans++;
	rep(i,c-1){
		int D;scanf("%d",&D);
		rep(i,D){
			int x,y;scanf("%d%d",&x,&y);x--;y--;
			if(p[x][y]!=p[x][n-y-1])cnt--;
			else cnt++;
			if(p[x][y]!=p[n-x-1][y])cnt--;
			else cnt++;
			p[x][y]^=1;
		}
		if(cnt==0)ans++;
	}
	cout<<ans<<endl;
}

Measured memory_bytes: 7052
n = int(input())
hoge = []
for i in range(1, n+1):
    tmp = input().split()
    name = tmp[0]
    score = int(tmp[1])
    hoge.append((i, name, score))

for i, _, _ in sorted(hoge, key=lambda x: (x[1], -x[2])):
    print(i)


Measured memory_bytes: 3060
'''
最大値 : n - k
最小値 : 1
8 1 7 3 9
興味あるのは最大値だけ。
'''

class Allocator(object):

    def __init__(self):
        self.N, self.K = map(int, input().split())
        self.ws = []

        for _ in range(self.N):
            self.ws.append(int(input()))

    def check(self, max_p):
        track, now = 0, 0
        for w in self.ws:
            if w > max_p:
                # wの値がmax_pを超えていた場合は、想定max値が小さすぎるのでFalse
                return False
            elif w + now > max_p:
                # nowの値にwを加えてmax_pを超えた場合は、それ以前までの値までしか積載出来なので、次のトラックを用意する。
                now = w
                track += 1
            else:
                # トラックに積荷をする。
                now += w

        if now > 0:
            # 全ての積荷を行ったのちにまだnowに残っていれば、trackを一つ用意する。
            track += 1

        if int(self.K) < track :
            return False

        return True


amin, amax = 0, int(10E10)
allocate = Allocator()

while amin + 1 != amax:
    amid = (amin + amax) // 2
    if allocate.check(amid):
        amax = amid
    else:
        amin = amid

print(amax)





Measured memory_bytes: 9580
#include<bits/stdc++.h>
using namespace std;
const int W = 29, N = 2e5 + 87;
int mem[3][N], k, n;
void ct_sort(int *& a, int *& v)
{
    int c[2] = {};
    for (int i = 0; i < n; ++i)
        ++c[a[i]>>k&1];
    c[1] += c[0];
    for (int i = n - 1; i >= 0; --i)
        v[--c[a[i]>>k&1]] = a[i];
    swap(a, v);
}
int * a = mem[0], * b = mem[1], * v = mem[2];
int g(int x) {return x & ((1 << (k + 1)) - 1);}
int cal(int vl,int vr)
{
    int l=n,r=n,c=0;
    for (int i = 0; i < n; ++i) {
        while (l - 1 >= 0 && g(a[l-1]) >= vl - g(b[i]))
            --l;
        while (r - 1 >= 0 && g(a[r-1]) >= vr - g(b[i]))
            --r;
        c = (r - l + c) & 1;
    }
    return c;
}
int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    cin >> n;
    for (int i = 0; i < n; ++i)
        cin >> a[i];
    for (int i = 0; i < n; ++i)
        cin >> b[i];
    int ans = 0;
    for (k = 0; k < W; ++k) {
        ct_sort(a,v);
        ct_sort(b,v);
        ans |= (cal(1<<k,2<<k) ^ cal(3<<k,4<<k)) << k;
    }
    cout << ans << endl;
}


Measured memory_bytes: 2560
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
using namespace std;
char ma[50][50];
queue<pair<int,int>> que;
pair <int,int> p;
int lon[50][50];
int loa;
int h,w;

int main(){
	cin>>h>>w;
	for(int i=0;i<h;i++){
		for(int j=0;j<w;j++){
			cin>>ma[i][j];
			if(ma[i][j]=='.'){
				loa++;
			}
			lon[i][j]=10000;
		}
	}
	que.push(pair<int,int>(0,0));
	lon[0][0]=0;
	while(que.size()){
		p=que.front();
		que.pop();
		if(p.first==h-1&&p.second==w-1){
			break;
		}
		for(int i=-1;i<2;i++){
			for(int j=-1;j<2;j++){
				if(i+j!=-2&&i+j!=0&&i+j!=2){
					if(0<=p.first+i&&p.first+i<=h-1&&0<=p.second+j&&p.second+j<=w-1&&ma[p.first+i][p.second+j]!='#'&&lon[p.first+i][p.second+j]==10000){
						que.push(pair<int,int>(p.first+i,p.second+j));
						lon[p.first+i][p.second+j]=lon[p.first][p.second]+1;
					}
				}
			}
		}
	}
	if(lon[h-1][w-1]==10000){
		cout<<-1<<endl;
	}else{
		cout<<loa-lon[h-1][w-1]-1<<endl;
	}
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <stdio.h>
using namespace std;
int main(void){
    // Your code here!
    int W=0,H=0,x=0,y=0,r=0;
    std::cin >> W>>H>>x>>y>>r;
    int circleTop,circleUnder,circleLeft,circleRight;
    
    circleTop=y+r;
    circleUnder=y-r;
    circleRight=x+r;
    circleLeft=x-r;
    
    if(circleLeft>=0&&circleRight<=W)
    {
        if(circleUnder>=0&&circleTop<=H){
            std::cout << "Yes" << std::endl;
        }
        else printf("No\n");
    }
    else printf("No\n");
}


Measured memory_bytes: 3100
n=input()
x=len(n)
if x==1:
    print(int(n))

elif x<3:
    print(9)
elif x==3:
    print(9+int(n)-100+1)
elif x<5:
    print(909)
elif x==5:
    print(9+900+int(n)-10000+1)
else:
    print(90909)


Measured memory_bytes: 3064
// abc113_b
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<map>
#include<set>
#include<unordered_map>
#include<utility>
#include<cmath>
#include<random>
#include<cstring>
#include<queue>
#include<stack>
#include<bitset>
#include<cstdio>
#include<sstream>
#include<iomanip>
#include<assert.h>
#include<typeinfo>
#define loop(i,a,b) for(int i=a;i<b;i++)
#define rep(i,a) loop(i,0,a)
#define FOR(i,a) for(auto i:a)
#define pb push_back
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)
#define show1d(v) rep(i,v.size())cout<<" "<<v[i];cout<<endl<<endl;
#define show2d(v) rep(i,v.size()){rep(j,v[i].size())cout<<" "<<v[i][j];cout<<endl;}cout<<endl;
using namespace std;
typedef long long ll;
typedef int Def;
typedef pair<Def,Def> pii;
typedef vector<Def> vi;
typedef vector<vi> vvi;
typedef vector<pii> vp;
typedef vector<vp> vvp;
typedef vector<string> vs;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef pair<Def,pii> pip;
typedef vector<pip>vip;
template<typename A,typename B>bool cmin(A &a,const B &b){return a>b?(a=b,true):false;}
template<typename A,typename B>bool cmax(A &a,const B &b){return a<b?(a=b,true):false;}
const double PI=acos(-1);
const double EPS=1e-9;
Def inf = sizeof(Def) == sizeof(long long) ? 2e18 : 1e9+10;
int dx[]={0,1,0,-1};
int dy[]={1,0,-1,0};
int main(int argc, char *argv[])
{
  int n,t,a,h,minH=10000000,ans=0;
  cin>>n>>t>>a;
  rep(i,n) {
    cin>>h;
    if(minH>abs(t*1000-h*6-a*1000)) {
      minH=abs(t*1000-h*6-a*1000);
      ans=i+1;
      // cout<<ans<<endl;
      // cout<<minH<<endl;
    }
  }
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 256
//0;27
#include <string.h>
#include <stdio.h>
#define MAX_A 100000
int cnt_a[MAX_A+2];
int main(){
        int N;
        scanf("%d",&N);
        memset(cnt_a,0,sizeof(cnt_a));
        int a;
        for(int i = 0; i < N; i++){
                scanf("%d", &a);
                cnt_a[a-1]++;
                cnt_a[a]++;
                cnt_a[a+1]++;
        }
        int max_cnt = 0;
        int max_ind = 0;
        for(int i = 0; i <= MAX_A+1; i++){
                if(max_cnt < cnt_a[i]){
                        max_cnt = cnt_a[i];
                        max_ind = i;
                }
        }
        printf("%d\n",max_cnt);
}

Measured memory_bytes: 512
n = int(input())

a = []
b = []

import math

for i in range(1, math.floor(n**0.5) + 1):
    if n%i == 0:
        a.append(i)
        b.append(int(n/i))

a = list(map(str, a))
b = list(map(str, b))


result = []
for i in range(len(a)):
    result.append(max(len(a[i]), len(b[i])))

print(min(result))


Measured memory_bytes: 3188
def main(condition, number_of_trials):
    while True:
        min_value = min(condition)
        condition = list(map(lambda x: x - min_value, condition))
        condition = remove_neighboring_zeros(condition)
        number_of_trials += min_value
        if condition == []:
            break
        if 0 not in condition:
            continue
        divided_list = divide_list_by_specified_value(condition, 0)
        for each_part_condition in divided_list:
            number_of_trials = main(each_part_condition, number_of_trials)
        break
    return number_of_trials


def divide_list_by_specified_value(list_to_be_divided, divider):
    before_idx = 0
    divided_list = []
    for idx, each_elem in enumerate(list_to_be_divided):
        if each_elem == divider:
            if list_to_be_divided[before_idx:idx] != []:
                divided_list.append(list_to_be_divided[before_idx:idx])
            before_idx = idx + 1
    if list_to_be_divided[before_idx:] != []:
        divided_list.append(list_to_be_divided[before_idx:])
    return divided_list


def remove_neighboring_zeros(array):
    while len(array) > 0 and array[-1] == 0:
        array.pop(len(array) - 1)
    while len(array) > 0 and array[0] == 0:
        array.pop(0)
    return [each_elem for idx, each_elem in enumerate(array) if
            idx == 0 or each_elem != array[idx - 1] or each_elem != 0]


if __name__ == '__main__':
    n = int(input())
    condition = list(map(int, input().split()))
    print(main(condition, 0))


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

int main(){
  while(1){
    int n, m1 = 0;
    double s1 = 0;
    int b[1001] = {};

    cin >> n;
    if( n == 0 ) break;
 
    for( int i = 0; i < n; i++ ){
      int s;
      cin >> s;
      b[i] = s;
      m1 += s;
    }
 
    double m2 = (double)m1 / n;

    for( int i = 0; i < n; i++ ){
      s1 += pow(b[i] - m2,2);
    }

    double a = sqrt( s1 / n );
    
    printf("%f\n", a);
  }

  return 0;
}

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

typedef pair<int, int> pii;
typedef long long ll;
typedef vector<int> vi;

#define pb push_back
#define eb emplace_back
#define mp make_pair
#define fi first
#define se second
#define rep(i,n) rep2(i,0,n)
#define rep2(i,m,n) for(int i=m;i<(n);i++)
#define ALL(c) (c).begin(),(c).end()

int main() {
	vi ans;
	int N;
	cin >> N;
	int num = N;

	if (N == 3) {
		puts("2 5 63");
		return 0;
	}

	int c = 3;

	while (N >= 4 && c + 6 <= 30000) {
		ans.pb(c);
		ans.pb(c + 6);
		c += 12;
		N -= 2;
	}

	c = 0;
	while (N >= 3) {
		ans.pb(c + 2);
		ans.pb(c + 4);
		ans.pb(c + 6);
		c += 6;
		N -= 3;
	}

	if (N == 1) {
		ans.pb(c + 6);
	} else if (N == 2) {
		ans.pb(c + 2);
		ans.pb(c + 4);
	}

	rep(i, num) printf("%d%c", ans[i], i == num - 1 ? '\n' : ' ');
	return 0;
}

Measured memory_bytes: 512
class WeightedUnionFind:
    def __init__(self, n):
        self.par = [i for i in range(n+1)]
        self.rank = [0] * (n+1)
        # 根への距離を管理
        self.weight = [0] * (n+1)

    # 検索
    def find(self, x):
        if self.par[x] == x:
            return x
        else:
            y = self.find(self.par[x])
            # 親への重みを追加しながら根まで走査
            self.weight[x] += self.weight[self.par[x]]
            self.par[x] = y
            return y

    # 併合
    def union(self, x, y, w):
        rx = self.find(x)
        ry = self.find(y)
        # xの木の高さ < yの木の高さ
        if self.rank[rx] < self.rank[ry]:
            self.par[rx] = ry
            self.weight[rx] = w - self.weight[x] + self.weight[y]
        # xの木の高さ ≧ yの木の高さ
        else:
            self.par[ry] = rx
            self.weight[ry] = -w - self.weight[y] + self.weight[x]
            # 木の高さが同じだった場合の処理
            if self.rank[rx] == self.rank[ry]:
                self.rank[rx] += 1

    # 同じ集合に属するか
    def same(self, x, y):
        return self.find(x) == self.find(y)

    # xからyへのコスト
    def diff(self, x, y):
        return self.weight[x] - self.weight[y]

def main():
    n, m = map(int, input().split())
    wuf = WeightedUnionFind(n)
    for _ in range(m):
        l, r, d = map(int, input().split())
        if not wuf.same(l, r):
            wuf.union(l, r, d)
        else:
            if wuf.diff(l, r) != d:
                print('No')
                return
    print('Yes')

if __name__ == '__main__':
    main()

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

int main(){
  int N,K;
  cin >> N >> K;
  if(K%2!=0){
    int64_t x=N/K;
    cout << x*x*x << endl;
  }else{
    int64_t x=N/K;
    int64_t ans=x*x*x;
    if(N%K>=K/2){
      x++;
    }
    ans+=x*x*x;
    cout << ans << endl;
  }
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <math.h>
#include <iomanip>
#include <limits>
#include <list>
#include <queue>
using namespace std;
#define MOD (long long int)(1e9+7)
#define ll long long int
#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define reps(i,n) for(int i=1; i<=(int)(n); i++)
//#define ARRAY(type,n) (type *)malloc(sizeof(type)*n)
template<typename T>
T* ARRAY(int n){
	(T*)malloc(sizeof(T)*n);
}
template<typename T>
T** ARRAY2(int m,int n){
	T** type = (T**)malloc(sizeof(T*)*m);
	for(int i=0;i<m;i++){
		type[i]=(T*)malloc(sizeof(T)*n);
	}
	return type;
}
 
 
int main(void){
	int n,m,i,j,k;
	double x;
	char u[100];
	cin>>n;
	ll sumj = 0;
	double sumb = 0;
	rep(i,n){
		cin >> x >> u;
		if(u[0] == 'J'){
			sumj += x;
		}else{
			sumb += x * 380000;
		}
	}

	
	cout<<std::setprecision(10) << sumj+sumb<<endl;
 
	return 0;
}

Measured memory_bytes: 256
def main():
    X, Y = map(int, input().split())

    if((4 * X) < Y):
        print("No")
    else:
        turuNum = (Y - 2 * X) / 2
        kameNum = X - turuNum

        if(turuNum.is_integer() and kameNum >= 0 and turuNum >= 0):
            print("Yes")
        else:
            print("No")

if __name__ == "__main__":
    main()

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


int main() {
    ll n;
    cin >> n;
    vector<ll> a(n);
    rep(i,n) cin >> a[i];
    sort(all(a));
    if(n%3!=0){
        if(a[n-1]==0) cout << "Yes" << endl; 
        else cout << "No" << endl;
        return 0;
    }
    int t = n/3;
    if(a[0]==a[t-1] && a[t]==a[2*t-1]&&a[2*t]==a[n-1]) {
        int b = a[0];
        int c = a[t];
        int d = a[2*t];
        int e = b^c;
        if(d==e) cout << "Yes" << endl;
        else cout << "No" << endl;
    }
    else cout << "No" << endl;
    return 0;
}

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

int main(){
    int h1,h2,m1,m2,k;
    cin>>h1>>m1>>h2>>m2>>k;
    cout<<max(0,(h2-h1)*60+m2-m1-k)<<endl;
    return 0;
}


Measured memory_bytes: 3612
#include <bits/stdc++.h>
using namespace std;
using pint = pair<int,int>;

const long long INFLL = 1LL << 60;
const int INFI = 1000000000;


int main() {
    int N; cin >> N;
    vector<int> v(100010);
    for(int i=0;i<N;i++){
        int a; cin >> a; a++;
        v[a-1]++; v[a]++; v[a+1]++;
    }
    int ans = *max_element(v.begin(), v.end());
    cout << ans << endl;
}


Measured memory_bytes: 3720
#include <stdio.h>
#include <iostream>

using namespace std;

int main() {
    string s1, s2, s3;
    cin >> s1 >> s2 >> s3;
    
     char diff = 'A' - 'a';
    printf("%c%c%c\n", s1[0] + diff, s2[0] + diff, s3[0] + diff);
    return 0;
}

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

int main()
{
	while ( true )
	{
		int N, K;
		cin >> N >> K;
		if ( N == 0  &&  K == 0 )
			break;

		vector<int> S(K);
		for ( int i=0; i<K; i++ )
			cin >> S[i];
		for ( int i=0; i<N; i++ )
		for ( int j=0; j<K; j++ )
		{
			int t;  cin >> t;
			S[j] -= t;
		}

		if ( *min_element( S.begin(), S.end() ) >= 0 )
			cout << "Yes" << endl;
		else
			cout << "No" << endl;
	}
}

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

using namespace std;

int main(){
	int n;
	cin >> n;
	vector<long long int> t(n);
	vector<long long int> a(n);
	
	vector<long long int> c(n,-1);
	vector<long long int> num(n);

	for(int i=0;i<n;i++){
		cin >> t[i];
	}
	for(int i=0;i<n;i++){
		cin >> a[i];
	}
	
	long long int maxi = 0;
	long long int p=-1;
	for(int i=0;i<n;i++){
		if(p != t[i]){
			c[i] = 1;
			num[i] = t[i];
		}
		p=t[i];
		maxi = max(maxi,t[i]);
	}
	
	long long int maxi2 = 0;
	p=-1;
	for(int i=n-1;i>=0;i--){
		if(p != a[i]){
			if(c[i] != -1 && a[i] != num[i]){
				cout << 0 << endl;
				return 0;
			}
			c[i] = 1;
			num[i] = a[i];
		}
		p=a[i];
		maxi2 = max(maxi2,a[i]);
	}
	
	if(maxi != maxi2){
		cout << 0 << endl;
		return 0;
	}
	
	for(int i=0;i<n;i++){
		if(c[i] != -1) continue;
		c[i] = min(t[i], a[i])%1000000007;
	}
	
	for(int i=0;i<n;i++){
		if(num[i] > t[i]){
			cout << 0 << endl;
			return 0;
		}
	}
	
	for(int i=n-1;i>=0;i--){
		if(num[i] > a[i]){
			cout << 0 << endl;
			return 0;
		}
	}
	
	
	unsigned long long int ans = 1;
	for(int i=0;i<n;i++){
		ans%=1000000007;
		ans*=c[i];
		ans%=1000000007;
	}
	
	cout << ans << endl;
	
	return 0;
}

Measured memory_bytes: 3328
// Clockwork is still ticking.

#include <bits/stdc++.h>

using namespace std;

typedef long long LL;
typedef unsigned int UI;
typedef pair<int, int> pii;

#define DEBUG(...) fprintf(stderr, __VA_ARGS__)
#define mp make_pair
#define fst first
#define snd second
#define SZ(u) ((int) (u).size())
#define ALL(u) (u).begin(), (u).end()

inline void proc_status()
{
	ifstream t("/proc/self/status");
	cerr << string(istreambuf_iterator<char>(t), istreambuf_iterator<char>()) << endl;
}

namespace fastIO
{
	const UI BUFFER_SIZE = (UI) 1 << 15;
	char buffer[BUFFER_SIZE], *cur, *ed;

	inline char getc() { return *(cur == ed ? ed = buffer + fread(buffer, 1, BUFFER_SIZE, stdin), cur = buffer : cur)++; }
}
using fastIO::getc;

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

template<typename T> inline T sqr(const T &val) { return val * val; }
template<typename T> inline int chkmin(T &a, const T &b) { return b < a ? a = b, 1 : 0; }
template<typename T> inline int chkmax(T &a, const T &b) { return b > a ? a = b, 1 : 0; }

// END tpl.

const int MAXN = (int) 2e3;

int n;

int a[MAXN + 5];

vector<int> adj[MAXN + 5];

inline void input()
{
	auto safe_getc = [] ()
	{
		register char ch(getc());
		while(!isgraph(ch)) ch = getc();
		return ch;
	};

	n = read<int>();
	for(int i = 1; i <= n; ++i) a[i] = safe_getc() == '1';
	for(int i = 1; i < n; ++i)
	{
		int u = read<int>(), v = read<int>();
		adj[u].push_back(v);
		adj[v].push_back(u);
	}
}

int f[MAXN + 5], g[MAXN + 5], size[MAXN + 5];

inline void dfs(int u, int fa)
{
	size[u] = a[u];
	f[u] = g[u] = 0;
	int p = 0;
	for(auto v : adj[u]) if(v != fa)
	{
		dfs(v, u);
		size[u] += size[v];
		g[u] += g[v] + size[v];
		if(f[v] + size[v] > f[p] + size[p]) p = v;
	}
	f[u] = max(0, f[p] + size[p] - (g[u] - g[p] - size[p]));
}

inline void solve()
{
	int ans = INT_MAX;
	for(int i = 1; i <= n; ++i)
	{
		dfs(i, 0);
		if(g[i] % 2 == 0 && f[i] == 0) chkmin(ans, g[i] / 2);
	}
	printf("%d\n", ans == INT_MAX ? -1 : ans);
}

int main()
{
#ifdef K_ON // K-ON!
	freopen("E.in", "r", stdin);
	freopen("E.out", "w", stdout);
#endif

	input();
	solve();

	return 0;
}



Measured memory_bytes: 512
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <climits>
#include <vector>
#include <string>
#include <queue>
#include <deque>
#include <list>
#include <stack>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <algorithm>

#define int long long
#define MOD7 1000000007
#define MOD9 1000000009

#define rep(i, n) for (int i = 0; i < (n); i++)
#define itrep(i, a) for (auto i = (a).begin(); i != (a).end(); i++)
#define REP(i, a, n) for (int i = (a); i <= (n); i++)
#define all(a) (a).begin(), (a).end()
#define mp(a, b) make_pair((a), (b))

using namespace std;

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

template<class T> void inputVector(vector<T>& v, int n) {
    v.resize(n);
    for (int i = 0; i < v.size(); i++) cin >> v[i];
}

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

	int pt2 = 0;

	int ret = 0;
	int xsum = 0;
	int sum = 0;
	rep(pt, N) {
		while (pt2 <= pt) {
			xsum ^= A[pt2];
			sum += A[pt2];
			pt2++;
		}

		//cerr << "pt:" << pt << " pt2:" << pt2 << " xsum:" << xsum << " sum:" << sum << endl;
		while (pt2 < N && (xsum ^ A[pt2]) == (sum + A[pt2])) {
			xsum ^= A[pt2];
			sum += A[pt2];
			pt2++;
		}

		//cerr << " -> pt:" << pt << " pt2:" << pt2 << endl;

		ret += pt2 - pt;

		xsum ^= A[pt];
		sum -= A[pt];
	}

	cout << ret << endl;

    return 0;
}


Measured memory_bytes: 1792
#pragma GCC optimize(2)
#include<bits/stdc++.h>
using namespace std;
const int maxn=1e5+10;
typedef long long ll;
int main()
{
	int n,m;
	cin>>n>>m;
	int t=n;
	for(int i=1;i<=2*n-1;i++)
	{
		cout<<m-t+1<<" ";
		t--;
	}
	return 0;
}

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


public class Main {
    private static int MOD = 1000000007;

    public static void main(String[] args) throws IOException {
        InputStreamReader isr = new InputStreamReader(System.in);
        BufferedReader br = new BufferedReader(isr);
        String s = br.readLine();
        int q = Integer.parseInt(br.readLine());

        StringBuilder h = new StringBuilder();
        StringBuilder t = new StringBuilder();

        boolean v = true;
        for (int i = 0; i < q; i++) {
            String line = br.readLine();
            if (line.startsWith("1")) {
                v = !v;
            } else {
                String[] split = line.split(" ");
                String c = split[2];
                if (split[1].equals("1")) { // add C to head
                    if (v) {
                        h.append(c);
//                        heads.add(c);
                    } else {
                        t.append(c);
//                        tails.add(c);
                    }
                } else {  // add C to tail
                    if (v) {
                        t.append(c);
//                        tails.add(c);
                    } else {
                        h.append(c);
//                        heads.add(c);
                    }
                }
            }
        }

        if (v) {
//            StringBuilder out = new StringBuilder();
//            for (String head : heads) {
//                out.insert(0, head);
//            }
//            StringBuilder outt = new StringBuilder();
//            for (String tail : tails) {
//                outt.append(tail);
//            }
//            System.out.println(out.toString() + s + outt.toString());
            System.out.println(h.reverse().toString() + s + t.toString());
        } else {
//            StringBuilder out = new StringBuilder();
//            for (String head : heads) {
//                out.append(head);
//            }
//            StringBuilder outt = new StringBuilder();
//            for (String tail : tails) {
//                outt.insert(0, tail);
//            }
//            System.out.println(outt.toString()
//                    + new StringBuffer(s).reverse().toString() + out.toString());
            System.out.println(t.reverse().toString() + new StringBuilder(s).reverse().toString() + h.toString());
        }
    }
}


Measured memory_bytes: 48300
#include <stdio.h>
#include <cmath>
#include <algorithm>
#include <stack>
#include <queue>
#include <vector>
typedef long long int ll;

#define BIG_NUM 2000000000

using namespace std;

struct Info{
	Info(){
		L = a = b = 0.0;
	}
	double L,a,b;
};


int main(){

	int N,M,limit;

	scanf("%d %d",&N,&M);

	int work[M],work_index;
	limit = pow(2,N);
	Info info[N];

	double maximum = 0.0,tmp_sum;

	for(int i = 0; i < N; i++){
		scanf("%lf %lf %lf",&info[i].L,&info[i].a,&info[i].b);
	}

	for(int i = 0; i < limit; i++){
		work_index = 0;
		for(int k = 0; k < N; k++){
			if(i & (1 << k)){
				work[work_index++] = k;
			}
		}
		if(work_index != M)continue;

		tmp_sum = 0;

		for(int a = 0; a < work_index-1;a++){
			for(int b = a+1; b < work_index;b++){
				tmp_sum += (info[work[a]].L-info[work[b]].L)*(info[work[a]].L-info[work[b]].L)+(info[work[a]].a-info[work[b]].a)*(info[work[a]].a-info[work[b]].a)
						+(info[work[a]].b-info[work[b]].b)*(info[work[a]].b-info[work[b]].b);
			}
		}

		maximum = max(maximum,tmp_sum);
	}

	printf("%.10lf\n",maximum);

	return 0;
}

Measured memory_bytes: 2940
S = input()
T = input()
s_let = [0]*26
t_let = [0]*26
ans = "Yes"

for i in range(len(S)):
  s_let[ord(S[i])-ord("a")] += 1
for j in range(len(T)):
  t_let[ord(T[j])-ord("a")] += 1

s_let.sort()
t_let.sort()

for k in range(26):
  if s_let[k] != t_let[k]:
    ans = "No"

print(ans)

Measured memory_bytes: 9432
import java.util.*;
public class Main{
	private static String board = "CODEFESTIVAL2016";
    public static void main(String args[]) {
        Scanner cin = new Scanner(System.in);

        while(cin.hasNext()){
            String a = cin.next();
            System.out.println(count(a));
        }
    }
    public static int count(String s){
    	int count = 0;
    	for(int i=0;i<16;i++){
    		if(s.charAt(i)!=board.charAt(i)) count++;
    	}
    	return count;
    }
}

Measured memory_bytes: 10064
#include <bits/stdc++.h>
#define FAST ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
typedef long long ll;
typedef long double ld;
#define pb push_back
#define mp make_pair

using namespace std;

int main()
{
   FAST/**/
   
   ll n;
   cin>>n;
   
   ll arr[n];
   for(ll i=0;i<n;i++)
        cin>>arr[i];
   
   ll ans = 1000000000000000;
   ll sum = 0;
   ll tot = 0;
   for(ll i=0;i<n;i++)
        tot+=arr[i];
   
   for(ll i=0;i<n;i++)
   {
       sum+=arr[i];
       ans = min(ans, abs(tot - 2*sum));
   }
   
   cout<<ans;
   
   return 0;
}  
   

Measured memory_bytes: 1792
#include<cstdio>
#include<iostream>
#include<fstream>
#include<cmath>
#include<cstring>
#include<algorithm>
using namespace std;
#define Set(a) memset(a,0,sizeof(a))
#define F(i,a,b) for(register int i=a,i##end=b;i<=i##end;++i)
#define UF(i,a,b) for(register int i=a,i##end=b;i>=i##end;--i)
#define openf(a) freopen(#a".in","r",stdin);freopen(#a".out","w",stdout)
#define re register
#define ri re int
#define il inline
typedef long long ll;
typedef unsigned long long ull;
template<typename T> inline T rd(T& x)
{
	T f=1;x=0;char c=getchar();
	for(;!isdigit(c);c=getchar()) if(c=='-') f=-1;
	for(; isdigit(c);c=getchar()) x=(x<<3)+(x<<1)+(T)(c-'0');
	x*=f;
	return x;
}
ll rd(){ll x;rd(x);return x;}
inline int max(int a,int b){return a>b?a:b;}
inline int min(int a,int b){return a<b?a:b;}
const int inf=1<<30;

int n;char s[4005];
ll ans=0,r,g,b;
int main()
{
	cin>>n;
	scanf("%s",s+1);
	F(i,1,n) {if(s[i]=='R')++r;if(s[i]=='G')++g;if(s[i]=='B')++b;}
	ans=r*g*b;
	F(i,1,n) F(j,1,(n-i)/2) if(s[i]!=s[i+j]&&s[i+j]!=s[i+j+j]&&s[i+j+j]!=s[i]) --ans;
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 3692
/*
 * written by Yaqi Zhang
 * University of Wisconsin-Madison
 * 2020
 */

#include<algorithm>
#include<cstring>
#include<climits>
#include<iostream>
#include<map>
#include<set>
#include<stdio.h>
#include<vector>

#define INF 0x3f3f3f3f
typedef long long ll;

using namespace std;

int dp[100005];

int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n;
    cin >> n;
    vector<int> hs(n);
    for(int i = 0; i < n; ++i) cin >> hs[i];
    dp[0] = 0;
    for(int i = 1; i < n; ++i) {
        dp[i] = INF;
        if(i - 1 >= 0) dp[i] = min(dp[i], dp[i - 1] + abs(hs[i] - hs[i - 1]));
        if(i - 2 >= 0) dp[i] = min(dp[i], dp[i - 2] + abs(hs[i] - hs[i - 2]));
    }
    cout << dp[n - 1] << endl;
    return 0;
}



Measured memory_bytes: 1024
def main():
    n = int(input())
    residents = [[[0 for _ in range(10)] for _ in range(3)] for _ in range(4)]
    for _ in range(n):
        b, f, r, v = map(int, input().split())
        residents[b-1][f-1][r-1] += v
    for i in range(4):
        for j in range(3):
            for k in range(10):
                print(f" {residents[i][j][k]}", end="")
            print()
        if i != 3:
            print("####################")
    return 0


if __name__ == "__main__":
    main()



Measured memory_bytes: 5640
/* ex3_2
   moka223711 */

#include <stdio.h>

int main(void){
	int N;
	// 入力Nを受け取る
	scanf("%d", &N);

	// N % 10で1の位を取得する
	// switch文で各値に対してN本の本の読み方を出力する
	switch(N % 10){
		case 2: case 4: case 5: case 7: case 9:
			printf("hon");
			break;
		case 0: case 1: case 6: case 8:
			printf("pon");
			break;
		default:
			printf("bon");
	}

	return 0;
}


Measured memory_bytes: 1724
import java.util.Scanner;

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

        int n = sc.nextInt();
        int m = sc.nextInt();

        int l = 0;
        int r = 0;

        int lmax = 0;
        int rmin = n;

        for (int i = 0; i < m; i++) {
            l = sc.nextInt();
            if (lmax < l) {
                lmax = l;
            }

            r = sc.nextInt();
            if (rmin > r) {
                rmin = r;
            }
        }

        if(rmin-lmax+1 >= 0){
            System.out.println(rmin-lmax+1);

        }else{
            System.out.println(0);
        }


        sc.close();
    }
}


Measured memory_bytes: 63440
#define DEBUG 0
#include <bits/stdc++.h>
#define all(v) (v).begin(), (v).end()
#define pb push_back
#define rep(i,n) for(int i=0; i<(n); i++)
#define REP2(i,x,n) for(int i=x; i<(n); i++)
using namespace std;
using ll = long long;
using ld = long double;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
template<class T>using numr=std::numeric_limits<T>;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
const int INF = 1e9;
const ll LLINF = 1e16;
const int mod = 1000000007;
const int mod2 = 998244353;
void debug_impl() { std::cerr << std::endl; }
template <typename Head, typename... Tail>
void debug_impl(Head head, Tail... tail) { std::cerr << " " << head; debug_impl(tail...); }
#if DEBUG
#define debug(...)\
    do {\
        std::cerr << std::boolalpha << "[" << #__VA_ARGS__ << "]:";\
        debug_impl(__VA_ARGS__);\
        std::cerr << std::noboolalpha;\
    } while (false)
#else
#define debug(...) {}
#endif

template < typename Container, typename Value = typename Container::value_type, std::enable_if_t<!std::is_same< Container, std::string >::value, std::nullptr_t> = nullptr>
std::istream& operator>> (std::istream& is, Container& v)
    { for (auto & x : v) { is >> x; } return is; }

template < typename Container, typename Value = typename Container::value_type, std::enable_if_t<!std::is_same< Container, std::string >::value, std::nullptr_t> = nullptr >
std::ostream& operator<< (std::ostream& os, Container const& v) {
os << "{";
    for (auto it = v.begin(); it != v.end(); it++)
        {os << (it != v.begin() ? "," : "") << *it;}
    return os << "}";
}

int H,W;
vector<string> fi;
int Left[2100][2100],Right[2100][2100],Up[2100][2100],Down[2100][2100];

int main() {
    std::cin.tie(nullptr);
    std::ios::sync_with_stdio(false);
    cin >> H >> W;
    fi.resize(H);
    rep(i,H) cin >> fi[i];
    
    // 前処理
    for (int i = 0; i < H; ++i) {
        int cur = 0;
        for (int j = 0; j < W; ++j) {
            if (fi[i][j] == '#') cur = 0;
            else ++cur;
            Left[i][j] = cur;
        }
    }
    for (int i = 0; i < H; ++i) {
        int cur = 0;
        for (int j = W-1; j >= 0; --j) {
            if (fi[i][j] == '#') cur = 0;
            else ++cur;
            Right[i][j] = cur;
        }
    }
    for (int j = 0; j < W; ++j) {
        int cur = 0;
        for (int i = 0; i < H; ++i) {
            if (fi[i][j] == '#') cur = 0;
            else ++cur;
            Up[i][j] = cur;
        }
    }
    for (int j = 0; j < W; ++j) {
        int cur = 0;
        for (int i = H-1; i >= 0; --i) {
            if (fi[i][j] == '#') cur = 0;
            else ++cur;
            Down[i][j] = cur;
        }
    }

    int res = 0;
    for (int i = 0; i < H; ++i) {
        for (int j = 0; j < W; ++j) {
            if (fi[i][j] == '#') continue;
            res = max(res, Left[i][j] + Right[i][j] + Up[i][j] + Down[i][j] - 3);
        }
    }
    cout << res << endl;

}

Measured memory_bytes: 73124
#include <bits/stdc++.h>
using namespace std;
#define mod 1000000007
#define ll long long
#define ld long double
#define pb push_back
#define mp make_pair
#define endl '\n'
#define pii pair<int,int>
#define min3(a,b,c) min(a,min(b,c))
#define max3(a,b,c) max(a,max(b,c))
#define all(x) x.begin(),x.end()
#define fill(a,b) memset(a,b,sizeof(a))
#define sz(x) (int)x.size()
#define sp(x) setprecision(x)
#define ff first
#define ss second
#define lb lower_bound
#define ub upper_bound
#define bs binary_search
#define inf 1000000000000000005LL

inline ll solve1(vector<ll> arr,int n,ll pro)
{
    ll ans=0;
    for(int i=0;i<n;i++){
        ll x=pro/arr[i],idx;
        if((pro%arr[i])==0) idx=lb(all(arr),x)-arr.begin()-1;
        else idx=ub(all(arr),x)-arr.begin()-1;
        if(idx>i) ans+=(idx-i);
    }
    return ans;
}

inline ll solve2(vector<ll> a,int n,vector<ll> b,int m,ll pro)
{
    ll ans=0;
    for(int i=0;i<n;i++){
        ll x=pro/a[i],idx;
        if((pro%a[i])==0) idx=lb(all(b),x)-b.begin()-1;
        else idx=ub(all(b),x)-b.begin()-1;
        ans+=(idx+1);
    }
    return ans;
}

inline ll solve3(vector<ll> a,vector<ll> b,ll k)
{
    ll s=0,e=inf;
    while(s<e){
        ll m=(s+e)/2;
        ll x=solve1(a,sz(a),m),y=solve1(b,sz(b),m);
        if((x+y)<=(k-1)) s=m+1;
        else e=m;
    }
    return s-1;
}

inline ll solve4(vector<ll> a,vector<ll> b,ll k)
{
    ll s=0,e=inf;
    while(s<e){
        ll m=(s+e)/2;
        ll x=solve2(a,sz(a),b,sz(b),m);
        if(x<=k-1) s=m+1;
        else e=m;
    }
    return s-1;
}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL); cout.tie(NULL);
    ll n,k; cin>>n>>k;
    vector<ll> a,b;
    ll zer=0;
    for(int i=0;i<n;i++){
        ll x; cin>>x;
        if(x==0) zer++;
        else if(x>0) a.pb(x);
        else b.pb(abs(x));
    }
    ll as=sz(a),bs=sz(b);
    ll neg=as*bs,pos=as*(as-1)+bs*(bs-1);
    zer=((zer*(zer-1))/2)+zer*(as+bs);
    sort(all(a)); sort(all(b));
    if(k<=neg) cout<<-solve4(a,b,neg-k+1)<<endl;
    else if(k<=neg+zer) cout<<0<<endl;
    else cout<<solve3(a,b,k-zer-neg)<<endl;
}

Measured memory_bytes: 4716
x, n = map(int, input().split())
if n == 0:
    print(x)
    exit()

p_list = list(map(int, input().split()))
counter = 1

if x in p_list:
    while 1:
        if (x - counter) not in p_list:
            print(x - counter)
            break
        elif (x + counter) not in p_list:
            print(x + counter)
            break
        counter += 1
else:
    print(x)


Measured memory_bytes: 9188
N,A,B = map(int,input().split())
S=input()

passa = 0
passb = 0
for c in S:
    if c == 'a':
        if passa+ passb < A+B:
            print('Yes')
            passa+=1
        else:
            print('No')
    elif c == 'b':
        if passa + passb < A+B and passb < B:
            print('Yes')
            passb+=1
        else:
            print('No')
    else:
        print('No')



Measured memory_bytes: 9168