akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
 
#define EPS 1e-9
#define INF 1070000000LL
#define MOD 1000000007LL
#define all(x) (x).begin(),(x).end()
#define fir first
#define foreach(it,X) for(auto it=(X).begin();it!=(X).end();it++)
#define ite iterator
#define mp make_pair
#define mt make_tuple
#define rep(i,m,n) for(int i=m;i<(n);i++)
#define rep1(i,m,n) for(int i=m;i<=(n);++i)
#define pb push_back
#define sec second
#define sz(x) ((int)(x).size())
 
using namespace std;
 
typedef istringstream iss;
typedef long long ll;
typedef pair<int,int> pi;
typedef stringstream sst;
typedef vector<int> vi;
typedef vector<ll>vii;
vector<int>a;
int n,k;

bool good(double x)
{
    int s=0;
    for(int i=0;i<n;++i)
    s+=floor(a[i]/x);
    return s>=k;
}
 
 
 
int main(){
	cin.tie(0);
	ios_base::sync_with_stdio(0);
	ll a,b,c,d;
	cin>>a>>b>>c>>d;
	cout<<max(max(a*c,a*d),max(b*c,b*d));
	

}



Measured memory_bytes: 3640
#include <algorithm>
#include <bitset>
#include <cassert>
#include <climits>
#include <cmath>
#include <ctime>
#include <deque>
#include <iostream>
#include <list>
#include <map>
#include <memory.h>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <vector>
#include <unordered_map>
#include <unordered_set>
using namespace std;
typedef long double LD;
typedef long long LL;
typedef pair<LL, LL> pll;
typedef pair<int, int> pii;
typedef vector<int> vi;
#ifdef LOCAL
    #define DEBUG(x) { cerr << "# " << #x << ": " << x << endl;}
#else
    #define DEBUG(x)
#endif
mt19937_64 mt(time(0));
/*---------------------------------------------------------------------------------------------------
　　　　　　　　　　　 ∧＿∧  
　　　　　 ∧＿∧ 　（´<_｀ ）　 Welcome to My Coding Space!
　　　　 （ ´_ゝ`）　/　 ⌒i     
　　　　／　　　＼　 　  |　|     
　　　 /　　 /￣￣￣￣/　　|  
　 ＿_(__ﾆつ/　    ＿/ .| .|＿＿＿＿  
　 　　　＼/＿＿＿＿/　（u　⊃  
---------------------------------------------------------------------------------------------------*/






int main() {
    ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
    cout.precision(10); cout << fixed;
#ifdef LOCAL
    freopen("../test.txt", "r", stdin);
    // freopen("../output.txt", "w", stdout);
#endif
    string s;
    cin >> s;
    int n = s.size();
    LL ret = 0, cnt = 0;
    for (int i = 0; i < n; i++) {
        if (s[i] == 'B') {
            ret += n-1 - i;
            cnt++;
        }
    }
    ret -= cnt*(cnt-1)/2;
    cout << ret << endl;






/*---------------------------------------Coding Space End------------------------------------------*/
#ifdef LOCAL
    cerr << "Time elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " s." << endl;
#endif
    return 0;
}
/* author:  txingml */
/* picture is from hamayanhamayan(CF handle) */


Measured memory_bytes: 1356
//close stdin
//https://codeforces.com/problemset?order=BY_RATING_ASC&tags=binary+search%2C1300-
#include <bits/stdc++.h>
using namespace std;
long long  gcd(long long  a, long long b){ 
	if (a == 0) 
		return b;  
	return gcd(b % a, a);  
	} 
long long lcmm(long long a,long long b){
	
return (a*b)/gcd(a, b);
}
	
int mod=998244353;
long long summ(long long x){
	long long ans=0;
	while(x!=0){
		ans+=(x%10);
		x=x/10;
	}
	return ans;
	
}
bool prime[1000003]; 
void SieveOfEratosthenes() 
{ 
	int n=1000002;
    // Create a boolean array "prime[0..n]" and initialize 
    // all entries it as true. A value in prime[i] will 
    // finally be false if i is Not a prime, else true. 
    
    memset(prime, true, sizeof(prime)); 
  
    for (int p=2; p*p<=n; p++) 
    { 
        // If prime[p] is not changed, then it is a prime 
        if (prime[p] == true) 
        { 
            // Update all multiples of p greater than or  
            // equal to the square of it 
            // numbers which are multiple of p and are 
            // less than p^2 are already been marked.  
            for (int i=p*p; i<=n; i += p) 
                prime[i] = false; 
        } 
    } 
  
    // Print all prime numbers 

} 
long long INF=1000000000000;
//long long INF=1000;
int main(){
	//freopen ("t.txt","r",stdin);
	int n,w;
	scanf("%d %d",&n,&w);
	//vector<vector<long long >> cost(n+1,vector<long long >(w+1,0));
	vector<long long > val(n),weight(n);
	long long tval=0;
	for(int i=0;i<n;i++){
		cin>>weight[i]>>val[i];
		tval+=val[i];
	}
	//cout<<tval<<" ";
	vector<vector<long long >> cost(n+1,vector<long long >(tval+1,INF));

	for(int i=0;i<n+1;i++){
		for(int j=0;j<tval+1;j++){
	
			if( j==0){
				cost[i][j]=0;
			//	cout<<cost[i][j]<<" ";
				continue;
			}
			if(i==0){
				cost[i][j]=INF;
			//	cout<<cost[i][j]<<" ";
				continue;
			}
				

			 if(j>=val[i-1]){
				if(cost[i-1][j-val[i-1]]!=INF)
				cost[i][j]=weight[i-1]+cost[i-1][j-val[i-1]];
				cost[i][j]=min(cost[i][j],cost[i-1][j]);
			}
			
			else
			{
					cost[i][j]=cost[i-1][j];
			}
			//cout<<i<<" "<<j<<" "<<cost[i][j]<<" "<<val[i-1]<<" "<<j-weight[i-1]<<"\n";
			//cout<<cost[i][j]<<" ";
			
		}
	//	cout<<"\n";
	}
	int ans=0;
	for(int i=tval;i>=0;i--){
		if(cost[n][i]>=0 && cost[n][i]<=w){
			ans=max(ans,i);
			break;
		}
	}
	cout<<ans;


	

	



return 0;
}


Measured memory_bytes: 80256
N = int(input())
A = list(map(int, input().split()))
Q = int(input())

num_A = [0 for i in range(10**5+1)]
first = 0

for a in A:
    num_A[a] += 1
    first += a

for i in range(Q):
    b, c = map(int, input().split())
    first += c*num_A[b]
    first -= b*num_A[b]
    num_A[c] += num_A[b]
    num_A[b] = 0
    print(first)

Measured memory_bytes: 20728
def main():
    N = int(input())
    S = input()

    for s in S:
        if (ord(s)+N) > ord("Z"):
            print(chr(ord(s)-26+N), end="")
        else:
            print(chr(ord(s)+N), end="")
    return 0
if __name__ == '__main__':
    main()

Measured memory_bytes: 4468
#include <ios>
#include <iomanip>
#include <iostream>
#include <functional>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <climits>

using namespace std;
typedef long long int ll;
typedef long double ld;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
#define MOD 1000000007
#define INF (1e9)
#define PI (acos(-1))
#define print(x) cout << x << endl
#define yes cout << "Yes" << endl
#define YES cout << "YES" << endl
#define no cout << "No" << endl
#define NO cout << "NO" << endl

ll gcd(ll a, ll b) { return b ? gcd(b,a%b) : a;}
ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }
typedef pair <ll,ll> P;

int main()
{
    ll N;
    cin >> N;
    vector<ll> C(N-1);
    vector<ll> S(N-1);
    vector<ll> F(N-1);
    rep(i, N-1) {
        cin >> C[i] >> S[i] >> F[i];
    }
    rep(i, N-1) {
        ll st = i;
        ll t = S[i];
        while(st != N-1) {
            while(t % F[st] != 0 | t < S[st]) {
                t++;
            }
            t += C[st];
            st++;
        }
        print(t);
    }
    print(0);
    return 0;
}


Measured memory_bytes: 256
import numpy as np
import scipy.sparse as sps
import scipy.misc as spm
import collections as col
import functools as func
import itertools as ite
import fractions as frac
import math as ma
from math import cos,sin,tan,sqrt
import cmath as cma
import copy as cp
import sys
import re
import bisect as bs
sys.setrecursionlimit(10**7)
EPS = sys.float_info.epsilon
PI = np.pi; EXP = np.e; INF = np.inf
MOD = 10**9 + 7

def sinput(): return sys.stdin.readline().strip()
def iinput(): return int(sinput())
def imap(): return map(int, sinput().split())
def fmap(): return map(float, sinput().split())
def iarr(n=0):
    if n: return [0 for _ in range(n)]
    else: return list(imap())
def farr(): return list(fmap())
def sarr(n=0):
    if n: return ["" for _ in range(n)]
    else: return sinput().split()
def adj(n): return [[] for _ in range(n)]

#整数問題セット
def gcd(numbers): return func.reduce(frac.gcd, numbers)
def lcm(numbers): return func.reduce(LCM, numbers)
def inv(a): return pow(a, MOD-2, MOD) #逆元
def comb(n,r):
    ans = 1
    for i in range(r): ans *= n-i; ans *= inv(r-i); ans %= MOD
    return ans

n,a,b = imap()
div,mod = divmod(n,10000)
allEvents = (2**10000%MOD)**div%MOD * 2**mod%MOD
ans = allEvents - comb(n,a) - comb(n,b) - 1
ans %= MOD
print(ans)


Measured memory_bytes: 38880
import sys
import heapq, math
from itertools import zip_longest, permutations, combinations, combinations_with_replacement
from itertools import accumulate, dropwhile, takewhile, groupby
from functools import lru_cache
from copy import deepcopy

# 多次元配列
# dp = [[0] * 3 for _ in range(5)]

# 入力を受け取る
S = input()
l = len(S)

def ok(S):
    for i in range(l):
        if S[i] != S[l - i - 1]:
            return False

    for i in range((l - 1) // 2):
        if S[i] != S[l // 2 - i - 1]:
            return False
        if S[l // 2 + 1 + i] != S[l - i - 1]:
            return False

    return True

print("Yes" if ok(S) else "No")




Measured memory_bytes: 3828
/*奇数文字目がすべて R, U, D のいずれか。
偶数文字目がすべて L, U, D のいずれか。*/
#include<iostream>
#include<cstring>
using namespace std ;

int main()
{
  string S ;
  cin>>S ;
  int size=S.length() ;
  
  for(int i=0;i<size;i++){
    if(i%2!=0&&S[i]=='R'){
      cout<<"No"<<endl ;
      return 0 ;
    }else if(i%2==0&&S[i]=='L'){
      cout<<"No"<<endl ;
      return 0 ;
    }
  }
  cout<<"Yes"<<endl ;

  return 0 ;
}


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

int main(){
	long long N; cin >> N; ++N; vector < int > F , T; int cnt = 100;
	while(N != 1) if(N & 1){F.push_back(cnt--); --N;} else{T.push_back(cnt--); N >>= 1;}
	reverse(T.begin() , T.end()); cout << F.size() + T.size() + 100 << endl;
	for(auto t : F) cout << t << ' ';
	for(auto t : T) cout << t << ' ';
	for(int i = 1 ; i <= 100 ; ++i) cout << i << ' ';
	return 0;
}


Measured memory_bytes: 256
use std::vec::Vec;
use std::cmp::*;

fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}

fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    read::<String>().split_whitespace().map(|e| e.parse().ok().unwrap()).collect()
}

fn main() {
  let mut s: Vec<char> = read::<String>().chars().collect();
  let t: Vec<char> = read::<String>().chars().collect();

  match check(&s, &t) {
    None => println!("UNRESTORABLE"),
    Some(start) => {
      for i in start..start + t.len() {
        s[i] = t[i - start];
      }
      for i in 0..s.len() {
        if s[i] == '?' {
          s[i] = 'a';
        }
      }
      println!("{}", s.into_iter().collect::<String>());
    }
  }
}

fn check(s: &Vec<char>, t: &Vec<char>) -> Option<usize> {
  let n: usize = s.len();
  let m: usize = t.len();
  let mut res = None;
'outer:  for i in 0..n {
    if i + m > n {
      break;
    }

    for j in 0..m {
      if s[i+j] != t[j] && s[i+j] != '?' {
        continue 'outer;
      }
    }
    res = Some(i);
  }
  return res;
}


Measured memory_bytes: 4352
x1,y1,x2,y2 = list(map(int,input().split()))
x3=y3=x4=y4=0
a = x2-x1
b = y2-y1
x3 = x2 - b
y3 = y2 + a
x4 = x3 - a
y4 = y3 - b
print(x3,y3,x4,y4)

Measured memory_bytes: 3060
package main

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

var sc = bufio.NewScanner(os.Stdin)

func Scan() string {
	sc.Scan()
	return sc.Text()
}
func rScan() []rune {
	return []rune(Scan())
}
func iScan() int {
	n, _ := strconv.Atoi(Scan())
	return n
}
func fScan() float64 {
	n, _ := strconv.ParseFloat(Scan(), 64)
	return n
}
func stringToInt(s string) int {
	n, _ := strconv.Atoi(s)
	return n
}
func SScan(n int) []string {
	a := make([]string, n)
	for i := 0; i < n; i++ {
		a[i] = Scan()
	}
	return a
}
func iSScan(n int) []int {
	a := make([]int, n)
	for i := 0; i < n; i++ {
		a[i] = iScan()
	}
	return a
}
func abs(x int) int {
	if x < 0 {
		x = -x
	}
	return x
}
func larger(a, b int) int {
	if a < b {
		return b
	} else {
		return a
	}
}
func smaller(a, b int) int {
	if a > b {
		return b
	} else {
		return a
	}
}
func max(a []int) int {
	x := a[0]
	for i := 0; i < len(a); i++ {
		if x < a[i] {
			x = a[i]
		}
	}
	return x
}
func min(a []int) int {
	x := a[0]
	for i := 0; i < len(a); i++ {
		if x > a[i] {
			x = a[i]
		}
	}
	return x
}
func sum(a []int) int {
	x := 0
	for _, v := range a {
		x += v
	}
	return x
}
func fSum(a []float64) float64 {
	x := 0.
	for _, v := range a {
		x += v
	}
	return x
}
func bOut(f bool, x string, y string) {
	if f {
		fmt.Println(x)
	} else {
		fmt.Println(y)
	}
}
func mod(x, d int) int {
	x %= d
	if x < 0 {
		x += d
	}
	return d
}
func iSSPrint(x []int) {
	fmt.Println(strings.Trim(fmt.Sprint(x), "[]"))
}

var lp int = 1000000007

func main() {
	buf := make([]byte, 0)
	sc.Buffer(buf, lp)
	sc.Split(bufio.ScanWords)
	s, t := rScan(), rScan()
	a := make([][]int, 26)
	for i, v := range s {
		a[int(v)-97] = append(a[int(v)-97], i)
	}
	ans := 0
	tmp := -1
	for _, v := range t {
		if len(a[int(v)-97]) == 0 {
			ans = -1
			break
		}
		idx := sort.Search(len(a[int(v)-97]), func(j int) bool { return a[int(v)-97][j] > tmp })
		if idx == len(a[int(v)-97]) {
			tmp = a[int(v)-97][0]
			ans++
		} else {
			tmp = a[int(v)-97][idx]
		}
	}
	if ans == -1 {
		fmt.Println(-1)
	} else {
		fmt.Println(ans*len(s) + tmp + 1)
	}
}


Measured memory_bytes: 6372
#include<bits/stdc++.h>
using namespace std;
char a[100],b[100];
int main()
{
  long long u=0,i,j,m;
  cin>>a>>b;
  for(i=0;i<3;i++)
  {
    if(a[i]==b[i])
      u++;
  }
  cout<<u<<endl;
}

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

int main() {
    int a, b;
    cin >> a >> b;
    
    if (a < b) {
        cout << "a < b" << endl;
    }
    else if (a > b) {
        cout << "a > b" << endl;
    }
    else {
        cout << "a == b" << endl;
    }
    
    return 0;
}



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

using namespace std;

int main() {
  int n, d;
  cin >> n >> d;
  vector<vector<int>> x(n, vector<int>(d));
  for (int i = 0; i < n; ++i) {
    for (int j = 0; j < d; ++j) {
      cin >> x[i][j];
    }
  }
  int cnt = 0;
  for (int i = 0; i < n; ++i) {
    for (int j = 0; j < i; ++j) {
      int norm = 0;
      for (int k = 0; k < d; ++k) {
        int diff = x[i][k] - x[j][k];
        norm += diff * diff;
      }
      int s = sqrt(norm) + 0.5;
      if (s * s == norm) cnt++;
    }
  }
  cout << cnt << endl;
}

Measured memory_bytes: 256
MOD = 10**9+7

kaijo_memo = []
def kaijo(n):
  if(len(kaijo_memo) > n): return kaijo_memo[n]
  if(len(kaijo_memo) == 0): kaijo_memo.append(1)
  while(len(kaijo_memo) <= n): kaijo_memo.append(kaijo_memo[-1] * len(kaijo_memo) % MOD)
  return kaijo_memo[n]

gyaku_kaijo_memo = []
def gyaku_kaijo(n):
  if(len(gyaku_kaijo_memo) > n): return gyaku_kaijo_memo[n]
  if(len(gyaku_kaijo_memo) == 0): gyaku_kaijo_memo.append(1)
  while(len(gyaku_kaijo_memo) <= n): gyaku_kaijo_memo.append(gyaku_kaijo_memo[-1] * pow(len(gyaku_kaijo_memo),MOD-2,MOD) % MOD)
  return gyaku_kaijo_memo[n]

def nCr(n,r):
  if n == r: return 1
  if n < r or r < 0: return 0
  ret = 1
  ret = ret * kaijo(n) % MOD
  ret = ret * gyaku_kaijo(r) % MOD
  ret = ret * gyaku_kaijo(n-r) % MOD
  return ret

N,M,L,R = map(int,input().split())

P = [0 for i in range(R+1)]
Q = [0 for i in range(R+1)]
Z = [0 for i in range(R+1)]
for k in range(1,R+1):
  u = (R-M*k)//k
  for j in range(u+1):
    P[k*j+M*k] += nCr(N-M,j)*(-1)**(j%2)
    P[k*j+M*k] %= MOD
for k in range(R+1):
  Q[k] += nCr(k+N,N)
  Q[k] %= MOD
  Z[k] += nCr(k+N,N)
  Z[k] %= MOD
for k in range(R-M+1):
  Q[k+M] -= nCr(k+N,N)
  Q[k+M] %= MOD

def f(MAX):
  ans = 0
  for t in range(MAX+1):
    ans += P[t]*Q[MAX-t]
    ans %= MOD
  return ans

def F(x):
  return (Z[x]-nCr(N,M)*f(x))%MOD

print((F(R)-F(L-1))%MOD)

Measured memory_bytes: 143652
#python3
a,b,k = map(int, input().split())

if a-k>=0:
  print(str(a-k) + ' ' + str(b))
else:
  if b - abs(a-k) >= 0:
    print('0 ' + str(b-abs(a-k)))
  else:
    print('0 0')


Measured memory_bytes: 2940
N = int(input())

def factorization(n):
    arr = []
    temp = n
    for i in range(2, int(-(-n**0.5//1))+1):
        if temp%i==0:
            cnt=0
            while temp%i==0:
                cnt+=1
                temp //= i
            arr.append([i, cnt])

    if temp!=1:
        arr.append([temp, 1])

    if arr==[]:
        arr.append([n, 1])

    return arr

if N == 1:
    print(0)
    exit()
else:
    x =  factorization(N)
    #print(x)


res = 0

for i,j in x:
    cnt = 1
    while  1:
        j -=cnt
        if j < 0: cnt-=1
        if j < 1:
            break
        cnt+=1
    res+=cnt
    cnt = 1

print(res)

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

int h, w;
vector<vector<int> > field, visited;
bool out_field(int i, int j) { return i < 0 || i >= h || j < 0 || j >= w; }

void dfs(int i, int j) {
    if (i < 0 || i >= h || j < 0 || j >= w) return;
    if (visited[i][j] == true) return;
    visited[i][j] = true;
    if (field[i][j] == 0) return;
    for (int di = -1; di < 2; di++) {
        for (int dj = -1; dj < 2; dj++) {
            int ni = i + di, nj = j + dj;
            dfs(ni, nj);
        }
    }
}

int main() {
    while (cin >> w >> h) {
        if (w == 0) break;
        field.assign(h, vector<int>(w));
        visited.assign(h, vector<int>(w));
        for (int i = 0; i < h; i++) {
            for (int j = 0; j < w; j++) {
                cin >> field[i][j];
            }
        }
        int cnt = 0;
        for (int si = 0; si < h; si++) {
            for (int sj = 0; sj < w; sj++) {
                if (field[si][sj] == 1 && visited[si][sj] != 1) {
                    dfs(si, sj);
                    cnt++;
                }
            }
        }
        cout << cnt << endl;
    }
    return 0;
}



Measured memory_bytes: 3160
#include <iostream>

using namespace std;

int main() {

	int n;
	int num[4];
	int count;

	while (cin >> n) {
		count = 0;
		for (int a = 0; a < 10; a++) {
			for (int b = 0; b < 10; b++) {
				for (int c = 0; c < 10; c++) {
					for (int d = 0; d < 10; d++) {

						if (a + b + c + d == n) {
							count++;
						}
					}
				}
			}
		}
		cout << count <<endl;
	}

	return 0;

}

Measured memory_bytes: 3020
"use strict";
function Main(input) {
    let nums = input.split(/\s/).map((v) => v - 0);
    const N = nums[0];
    const K = nums[1];

    let t = (N + 1) / 2;

    console.log(t >= K ? "YES" : "NO");
}

Main(require("fs").readFileSync("/dev/stdin", "utf8"));


Measured memory_bytes: 21064
ans=["Monday","Tuesday","Wednesday","Thursday","Friday","Saturday","Sunday"]
c=[31,29,31,30,31,30,31,31,30,31,30,31]
while 1:
    a,b=map(int,raw_input().split())
    if a==0:
        break
    t=3
    for i in range(a-1):
        t+=c[i]
    t+=b
    print ans[(t-1)%7]

Measured memory_bytes: 6408
import java.util.HashSet;
import java.util.Scanner;
import java.util.Set;

public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		Set keihin = new HashSet();
		for (int i = 0; i < n; i++) {
			keihin.add(sc.next());
		}
		System.out.println(keihin.size());


	}

}


Measured memory_bytes: 66372
#include<iostream>
#include<vector>
#include<algorithm>
#include<stdlib.h>
#include<utility>
#include<functional>
#include<cfenv>
#include<cmath>
#include<string>
#include<queue>
#include<stack>
#include<map>
#include<set>

#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define vint vector<int>
#define vvint vector<vint>
#define P pair<ll,ll>
#define INT_MAX 2147483647
#define MOD 998244353
#define PI 3.14159265358979323846
#define all(a) (a).begin(),(a).end()
using namespace std;
typedef long long ll;

#define MAX 1000000000000


int main(void) {
	int a; cin >> a;
	int x = a + a * a + a * a*a;
	cout << x << endl;
	return 0;
}

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

int main(){
  char c;
  cin >> c;

  if (c == 'a' || c == 'i' || c == 'u' || c == 'e' || c == 'o'){
    cout << "vowel" << endl;  
  }

  else cout << "consonant" <<endl;
}

Measured memory_bytes: 256
# -*- coding: utf-8 -*-
import math
import itertools

def main():
# 整数の入力
    k = int(input())
    
    l = list(itertools.combinations_with_replacement(range(1, k+1), 3))
    l = set(l)
    
    result = []
    for t in l:
        tmp = math.gcd(t[0], t[1])
        ans = math.gcd(tmp, t[2])

        ab = 1 if t[0] == t[1] else 0 
        ac = 1 if t[0] == t[2] else 0
        bc = 1 if t[1] == t[2] else 0

        num = ab + ac + bc

        if num == 0:
            result.append(ans * 6)
        elif num == 1:
            result.append(ans * 3)
        elif num == 2:
            result.append(ans * 3)
        else:
            result.append(ans)
        
                
    print(sum(result))

if __name__ == '__main__':
    main()

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

unsigned long long myPow(unsigned long long a,unsigned long long n)
{
    unsigned long long result = 1;
    for(unsigned long long i = 0;i < n;i++)
    {
        result *= a;
    }
    return result;
}

#define OVERNUMBER (static_cast<unsigned long long>(myPow(10,9) + 7))

unsigned long long overCheck(unsigned long long number)
{
    if(number >= OVERNUMBER)
    {
        return number % OVERNUMBER;
    }
    return number;
}

unsigned long long kaizyou(unsigned long long n)
{
    
    unsigned long long result = 1;
    for(unsigned long long i = 1;i <= n;i++)
    {
        result *= i;
        result = overCheck(result);
    }
    return result;
}


int main()
{
    long dog;
    long mon;
    cin >> dog;
    cin >> mon;
    unsigned long long result = 0;
    if(abs(dog - mon) < 2) result = kaizyou(dog) * kaizyou(mon);
    if(dog == mon) result *= 2;
    cout << overCheck(result);
    return 0;
}

Measured memory_bytes: 256
// This is the template example file for programming//
#include<bits/stdc++.h>
//macros
using namespace std;
typedef long long ll;
typedef pair<int, int > Pii;
typedef pair<ll, ll> Pll;
typedef vector<int> Vi;
typedef vector<ll> Vll;
#define pb push_back
#define rs resize 
#define rep(i, a, b) for(int i=(a); i<(b); i++)
#define repll(i, a, b) for(ll i=(a); i<(b); i++)
#define Yes cout << "Yes" << endl
#define No cout << "No" << endl
#define YES cout << "YES" << endl
#define NO cout << "NO" << endl
#define COUT(a) cout << a << endl
#define ALL(a) (a).begin(),(a).end()
const long long int mod = 1e9 + 7;


int main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false); 
    ll N ;
    cin >> N;
    ll res=0;
    ll j=0;
    repll(i,0,N){
        j = i+1;
        if(j%3!=0 && j%5!=0) res+=j;
    }
    cout << res << endl;
}


Measured memory_bytes: 3656
#include <bits/stdc++.h>
using namespace std;
int main(){
  	int n;
  	cin >>n;
  	long long int a[n],b[n],e[n],suma=0,sumb=0,suba=0,count=0;
  for (int i=0;i<n;i++){
    cin >> a[i];
    suma+=a[i];
  }
  for (int i=0;i<n;i++){
    cin >> b[i];
    sumb+=b[i];
    e[i]=a[i]-b[i];
  }
  if(suma < sumb)cout << -1 <<endl;
  else {
    for (int i=0;i<n;i++){
    	if(a[i]<b[i]){
        	count++;
          	suba-=e[i];
        }
    }
    sort(e,e+n);
    reverse(e,e+n);
    for (int i=0;i<n;i++){
    	if (suba>0){
          count++;
          suba-=e[i];
        }
      	else break;
    }
    cout << count <<endl;
  }
  
  
}


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

int main(){
    int h, w; cin >> h >> w;
    vector<string> s(h);
    rep(i,h){
        cin >> s.at(i);
    }
    //基準tなる座標からの周りの座標位置
    //右、上、左、下、右上、左上、左下、右下
    int dx[8] = {1,0,-1,0,1,-1,-1,1};
    int dy[8] = {0,1,0,-1,1,1,-1,-1};

    rep(i,h){
        rep(j,w){
            if(s[i][j] == '.'){
                int num=0;
                rep(d,8){
                    int ni = i + dx[d]; //基準座標の周りのx座標
                    int nj = j + dy[d]; //基準座標の周りのy座標

                    if(ni < 0 || h <= ni) continue; //座標の外なら無視
                    if(nj < 0 || w <= nj) continue; //座標の外なら無視
                    if(s[ni][nj] == '#') num++;
                }
                s[i][j] = num+'0'; //数値に文字列を足すと文字の数値に変換される
            }
        }
    }
    rep(i,h){
        cout << s[i] << endl;
    }



}

Measured memory_bytes: 3632
import sys
stdin = sys.stdin

sys.setrecursionlimit(10 ** 7)

def li(): return map(int, stdin.readline().split())
def li_(): return map(lambda x: int(x) - 1, stdin.readline().split())
def lf(): return map(float, stdin.readline().split())
def ls(): return stdin.readline().split()
def ns(): return stdin.readline().rstrip()
def lc(): return list(ns())
def ni(): return int(stdin.readline())
def nf(): return float(stdin.readline())

n = ni()
print(n**3)

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

const int maxn=400010;
int n, v, m;
int a[maxn];
int f[1<<20], g[1<<20];
int Next[maxn][30], pre[maxn][30];

void chkmax(int& x,int y){ if(x<y) x=y; }
void chkmin(int& x,int y){ if(x>y) x=y; }

int Log[maxn];
void init(){
	for(int i=2;i<maxn;i++) Log[i]=Log[i>>1]+1;
}

int fa[maxn];
int find(int x){ return x==fa[x] ? x : fa[x]=find(fa[x]); }

int ans[maxn], b[maxn];

int main(){

	init();
	scanf("%d%d", &n, &v);
	int t=v; b[++m]=t;
	while(t){
		b[++m]=t/2;
		t/=2;
	}
	// printf("m = %d\n", m);
	// for(int i=1;i<=m;i++) printf("%d ", b[i]); puts("");
	for(int i=1;i<=n;i++) scanf("%d", &a[i]);
	for(int j=1;j<=m;j++){
		for(int i=1;i<=n;i++) fa[i]=i;
		for(int i=1;i<n;i++) if(a[i+1]-a[i]<=b[j]) fa[find(i)]=find(i+1);
		for(int i=1;i<=n;i++) Next[i][j]=find(i);
		
		for(int i=1;i<=n;i++) fa[i]=i;
		for(int i=1;i<n;i++) if(a[i+1]-a[i]<=b[j]) fa[find(i+1)]=find(i);
		for(int i=1;i<=n;i++) pre[i][j]=find(i);
		// for(int i=1;i<=n;i++) printf("%d ", Next[i][j]); puts("");
	}
	for(int i=0;i<(1<<m);i++) for(int j=1;j<=m;j++) if(!(i & (1<<(j-1)))){
		chkmax(f[i | (1<<(j-1))], Next[ f[i]+1 ][j]);
	}

	for(int i=0;i<(1<<m);i++) g[i]=n+1;
	for(int i=0;i<(1<<m);i++) for(int j=1;j<=m;j++) if(!(i & (1<<(j-1))))
		chkmin(g[i | (1<<(j-1))], pre[ g[i]-1 ][j]);
	for(int i=0;i<(1<<m);i++){ 
		if((i & 1)) continue;
		int j=((1<<m)-1) ^ i ^ 1;
		int l=1, r=Next[l][1];
		while(l<=n){
			if(f[i]>=l-1 && g[j]<=r+1) for(int k=l;k<=r;k++) ans[k]=1;
			l=r+1, r=Next[l][1];
		}
	}
	for(int i=1;i<=n;i++) printf("%s\n", ans[i] ? "Possible" : "Impossible");
	return 0;
}

Measured memory_bytes: 71168
import java.util.*;
 
public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    String s1 = sc.next();
    String s2 = sc.next();
    String s3 = sc.next();
    
    s1=s1.toUpperCase();
    s2=s2.toUpperCase();
    s3=s3.toUpperCase();
    
    System.out.println(s1.charAt(0) + "" +  s2.charAt(0) + "" +  s3.charAt(0));
  }
}

Measured memory_bytes: 39616
#include <bits/stdc++.h>
using namespace std;
#define mp       make_pair
#define pb       push_back
#define all(x)   (x).begin(),(x).end()
#define YES() printf("YES\n")
#define NO() printf("NO\n")
#define Yes() printf("Yes\n")
#define No() printf("No\n")
#define in(x,y,h,w) x >= 0 && x < h && y >= 0 && y < w

#define int long long
//typedef    long long          ll;
typedef    vector<bool>       vb;
typedef    vector<int>        vi;
typedef    vector<vb>         vvb;
typedef    vector<vi>         vvi;
typedef    pair<int,int>      P;

template <typename T> T &chmin(T &a, const T &b) { return a = min(a, b); }
template <typename T> T &chmax(T &a, const T &b) { return a = max(a, b); }
 
const int INF=1e+18;
const double EPS=1e-9;
const int MOD=1000000007;

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

signed main(){
	int r,g,b,n,ans = 0;
	cin >> r >> g >> b >> n;
	for(int i = 0;i <= 3000;i++){
		for(int j = 0;j <= 3000;j++){
			if(n - (i * r) - (j * g) >= 0 && (n - i * r - j * g) % b == 0) ans++;
		}
	}
	cout << ans << endl;
}


Measured memory_bytes: 256
#include <vector>
#include <iostream>
#include <assert.h>

using namespace std;

int all_price(vector<int>& points)
{
  int sum = 0;
  int prev = 0;
  for (int k = 0; k < points.size(); k++) {
    sum += abs(points[k] - prev);
    prev = points[k];
  }
  sum += abs(0 - prev);
  return sum;
}

int price(int all, int i, vector<int>& points)
{
  int len = points.size();
  assert(0 <= i && i < len);

  int left = 0;
  int right = 0;

  if (0 < i) {
    left = points[i - 1];
  }

  if (i < len - 1) {
    right = points[i + 1];
  }

  return all - (abs(right - points[i]) + abs(points[i] - left) - abs(right - left));
}

void calc_all_prices()
{
  int n = 0;
  cin >> n;
  assert(n >= 0);

  vector<int> points;
  for (int i = 0; i < n; i++) {
    int p = 0;
    cin >> p;
    points.push_back(p);
  }
  int all = all_price(points);
  for (int i = 0; i < n; i++) {
    cout << price(all, i, points) << endl;
  }
}


int main(int argc, char* argv[])
{
  calc_all_prices();
  return 0;
}


Measured memory_bytes: 1912
#include<iostream>
#include<queue>
#include<algorithm>
#include<vector>
using namespace std;
int N,M,H,K;
struct edge{
	int to,cost,hour,c;
};
main()
{
	while(cin>>N>>M>>H>>K,N)
	{
		vector<vector<edge> >G(N);
		for(int i=0;i<M;i++)
		{
			int a,b,c,h,r;
			cin>>a>>b>>c>>h>>r;
			a--,b--;
			r--;
			G[a].push_back((edge){b,c,h,r});
			G[b].push_back((edge){a,c,h,r});
		}
		vector<int>D(1<<K);
		int s,t;cin>>s>>t;s--,t--;
		for(int muryo=0;muryo<1<<K;muryo++)
		{
			vector<vector<int> >d(H+1,vector<int>(N,1e9));
			d[0][s]=0;
			priority_queue<pair<int,pair<int,int> > >P;
			P.push({0,{0,s}});
			while(!P.empty())
			{
				int cost=-P.top().first;
				int ho=P.top().second.first;
				int u=P.top().second.second;
				P.pop();
				if(d[ho][u]<cost)continue;
				for(edge e:G[u])
				{
					int v=e.to;
					int nextho=ho+e.hour;
					int nextcost=cost+((muryo>>e.c)&1?0:e.cost);
					if(nextho>H||d[nextho][v]<=nextcost)continue;
					d[nextho][v]=nextcost;
					P.push({-nextcost,{nextho,v}});
				}
			}
			int ret=1e9;
			for(int i=0;i<=H;i++)ret=min(ret,d[i][t]);
			D[muryo]=ret;
		}
		int P;cin>>P;
		vector<pair<int,int> >pas(P);
		for(int i=0;i<P;i++)
		{
			int l,d;cin>>l>>d;
			int now=0;
			for(int j=0;j<l;j++)
			{
				int k;cin>>k;k--;
				now|=1<<k;
			}
			pas[i]=make_pair(d,now);
		}
		vector<int>dp(1<<K,1e9);
		dp[0]=0;
		for(int i=0;i<1<<K;i++)
		{
			for(int j=0;j<P;j++)
			{
				int nxt=i|pas[j].second;
				dp[nxt]=min(dp[nxt],dp[i]+pas[j].first);
			}
		}
		int ans=2e9;
		for(int i=0;i<1<<K;i++)ans=min(ans,dp[i]+D[i]);
		cout<<(ans<1e9?ans:-1)<<endl;
	}
}




Measured memory_bytes: 3260
#include <stdio.h>
 
using namespace std;
 
int main(){
    int a,b;
    scanf("%d %d",&a,&b);
    if(a > b){
        printf("a > b\n");
    }else if(a < b){
        printf("a < b\n");
    }else{
        printf("a == b\n");
    }
}


Measured memory_bytes: 2624
import java.util.*;

class Main{
  public static void main(String[] args){
    try(Scanner sc = new Scanner(System.in)){
      String n = sc.next();
      if(n.contains("9")){
        System.out.println("Yes");
      }else{
        System.out.println("No");
      }
    }
  }
}
      

Measured memory_bytes: 23636
#include "bits/stdc++.h"

using namespace std;

using ll = long long;
using ld = long double;

const double PI = 3.1415926535897932384626433832795;

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

int gcd(int x, int y) { return y ? gcd(y, x % y) : abs(x); }
ll gcd(ll x, ll y) { return y ? gcd(y, x % y) : abs(x); }
int lcm(int x, int y) { return x / gcd(x, y) * y; }
ll lcm(ll x, ll y) { return x / gcd(x, y) * y; }

vector<string> split(const string &s, char delim) {
	vector<string> elems;
	stringstream ss(s);
	string item;
	while (getline(ss, item, delim)) {
		if (!item.empty()) {
			elems.push_back(item);
		}
	}
	return elems;
}

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

	string s;
	cin >> s;

	vector<string> strTime = split(s, '/');
	int year = stoi(strTime[0]);
	int month = stoi(strTime[1]);
	int day = stoi(strTime[2]);

	if (month > 4) {
		cout << "TBD" << endl;
	} else if (month == 4 && day <= 30) {
		cout << "Heisei" << endl;
	} else {
		cout << "Heisei" << endl;
	}
	return 0;
}


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

int main() {

    ll n, m; cin >> n >> m;
    ll ans = 0;
    if (n <= m) swap(n, m); // m <= n とする

    if (2 < m) {
        ans = (n - 2) * (m - 2);
    }
    else if (m == 1 && 2 <= n ) {
        ans = n - 2;
    }
    else if(m == 1 && n == 1){
        ans = 1;
    }
    else {
        ans = 0;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
import java.util.*;

class Main {
  public static void main (String[] args) {
    Scanner scanner = new Scanner(System.in);
    String out = "";
    String[] ws = {"512", "256", "128", "64", "32", "16", "8", "4", "2", "1"};
    while (scanner.hasNext()) {
      int w10 = scanner.nextInt();
      String work = "000000000" + Integer.toBinaryString(w10);
      work = work.substring(work.length() - 10);
      String temp = "";
      for (int ii = work.length() - 1; ii >= 0; ii--) {
        if (work.charAt(ii) == '0') {
          continue;
        }
        temp += ws[ii] + " ";
      }
      out += temp.trim() + "\n";
    }
    System.out.print(out);
  }
}

Measured memory_bytes: 17252
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define FOR(i,a,b) for(int i=(a),i##Len_=(b);i<i##Len_;i++)
const char* LF = "\n";
namespace{struct _{_(){
    cin.tie(0);
    ios::sync_with_stdio(false);
}}a;}

signed main() {
    ll N, Y;
    cin >> N >> Y;
    FOR(i, 0, N + 1) {
        FOR(j, 0, N + 1 - i) {
            ll k = N - i - j;
            if (i * 10000LL + j * 5000LL + k * 1000LL == Y) {
                cout << i << " " << j << " " << k << LF;
                return 0;
            }
        }
    }
    cout << "-1 -1 -1\n";
    return 0;
}


Measured memory_bytes: 256
#include<cstdio>
#include<iostream>
#include<algorithm>
#include<vector>
using namespace std;
int main(){
    int n;
    while(cin>>n,n){
        int num[10000]={0},cnt=0;
        num[n]=11000000;
        for(int i=0;i<n;i++)cin>>num[i];
        for(int i=0;i<n;i++){
            for(int j=0;j<n;j++){
                if(num[j]>num[j+1]){
                    swap(num[j],num[j+1]);
                    cnt++;
                }
            }
        }
        cout<<cnt<<endl;
    }
    return 0;
}

Measured memory_bytes: 1204
def main():
    N = int(input())
    h = {}

    for i in range(N):
        a, b, c = map(int, input().split())
        if i == 0:
            h['a', i] = a
            h['b', i] = b
            h['c', i] = c
        else:
            h['a', i] = a + max(h['b', i-1], h['c', i-1])
            h['b', i] = b + max(h['c', i-1], h['a', i-1])
            h['c', i] = c + max(h['a', i-1], h['b', i-1])

    print(max(h['a', N-1], h['b', N-1], h['c', N-1]))


##########
if __name__ == "__main__":
    main()


Measured memory_bytes: 47104
#include <iostream>
#include <cstdio>
#include <cstring>
#include <climits>

using namespace std;

#define MN 105
#define INF INT_MIN

int n;
int F[MN][MN];
int L[MN][MN][MN];

void debug() {
    for (int i = 0; i < n; i++) {
        for (int j = 0; j < n; j++) {
            for (int k = 0; k <= n; k++) {
                printf("%3d ", L[i][j][k]);
            }
            printf("\n");
        }
        printf("\n\n");
    }
}

int calc(int sy, int sx, int gy, int gx) {
    int ret = 0;
    for (int i = sy; i < gy; i++) {
        ret += L[i][sx][gx];
    }
    return ret;
}

int main() {
    while (cin >> n) {
        memset(F, 0, sizeof(F));
        for (int i = 0; i < n; i++) {
            for (int j = 0; j < n; j++) {
                cin >> F[i][j];
            }
        }
        //debug();
        memset(L, 0, sizeof(L));
        for (int i = 0; i < n; i++) {
            for (int j = 0; j < n; j++) {
                for (int k = j+1; k <= n; k++) {
                    L[i][j][k] = L[i][j][k-1] + F[i][k-1];
                }
            }
        }
        int ans = INF;
        for (int i = 0; i < n; i++) {
            for (int j = 0; j < n; j++) {
                for (int k = i+1; k <= n; k++) {
                    for (int l = j+1; l <= n; l++) {
                        //printf("\t %d %d %d %d -> %d\n", i, j, k, l, calc(i, j, k, l));
                        ans = max(ans, calc(i, j, k, l));
                    }
                }
            }
        }
        cout << ans << endl;
        //debug();
    }
    return 0;
}

Measured memory_bytes: 5736
#!/usr/bin/env python3
import sys
#sys.setrecursionlimit(150000)


def solve(N: int, M: int):
    print(N*(N-1)//2+M*(M-1)//2)
    return


# Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    M = int(next(tokens))  # type: int
    solve(N, M)

if __name__ == '__main__':
    main()


Measured memory_bytes: 3060
// Kannondou
// http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=0168
#include <bits/stdc++.h>
using namespace std;
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; }
const long long INF = 1LL << 60;
// DP table.
long long dp[31];

int main() {
    
    int N;
    while(true){
    
        cin >> N;
        // 1. input end check.
        if(N == 0) break;
        
        // 2. initialize.
        for(int i = 0; i < 31; ++i) dp[i] = 0;
        dp[0] = 1; // 0段は, 1通り.
        dp[1] = 1; // 1段は, 1通り.
        dp[2] = 2; // 2段は, 1 + 1, 2 の 2通り.
        
        // 3. update DP table.
        for(int i = 3; i < N + 1; ++i) dp[i] = dp[i - 1] + dp[i - 2] + dp[i - 3];
        
        // 4. output answer.
        long long ans = ceil(dp[N] / 10.0 / 365.0);
        cout << ans << endl;
    
    }
    
    return 0;
    
}


Measured memory_bytes: 2972
N, K = gets.split.map(&:to_i)

ans = 0

(K + 1).upto(N) do |k|
  d = (k - K)
  m = N % k

  ans += (N / k) * d
  if m > 0
    if K == 0
      ans += m
    else
      ans += [m - K + 1, 0].max
    end
  end
end

puts ans


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

#define int long long
struct Fast {Fast(){cin.tie(0);ios::sync_with_stdio(0);}} fast;
const int MOD = 1e9 + 7;
using intpair = pair<int, int>;

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define reps(i, n, m) for (int i = (int)(n); i <= (int)(m); i++)
#define ALL(obj) (obj).begin(), (obj).end()
#define rALL(obj) (obj).rbegin(), (obj).rend()
#define ceiv(a, b) ((int)((a) + (b) - 1)/(int)(b))

signed main() {
    int sx, sy, tx, ty;
    cin >> sx >> sy >> tx >> ty;
    int h = ty - sy, w = tx - sx;
    
    rep(i,h)   cout << 'U';
    rep(i,w)   cout << 'R';
    rep(i,h)   cout << 'D';
    rep(i,w+1) cout << 'L';
    rep(i,h+1) cout << 'U';
    rep(i,w+1) cout << 'R';
    cout << 'D' << 'R';
    rep(i,h+1) cout << 'D';
    rep(i,w+1) cout << 'L';
    cout << 'U' << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
using ll = long long;
using ull = unsigned long long;
using ld = long double;
#define REP(NAME, NUM) for (int NAME = 0; NAME < (NUM); ++NAME)
#define BREP(NAME, NUM) for (int NAME = (NUM)-1; NAME >= 0; --NAME)
#define ALL(NAME) (NAME).begin(), (NAME).end()
 
#define cMOD 1000000007ULL
#define cINF ((1ull<<62)-1)
#define cINFINT ((1<<30)-1)
 
int main()
{
    ll h,w; cin>>h>>w;
    vector<vector<ll>> rock( h, vector<ll>( w, 0 ) );
    REP( i, h )
    {
        string s;cin>>s;
        REP(j,w) if( s[j] == '#' ) rock[i][j] = 1;
    }

    vector<vector<ll>> l( h, vector<ll>( w, 0 ) );
    vector<vector<ll>> r( h, vector<ll>( w, 0 ) );
    vector<vector<ll>> d( h, vector<ll>( w, 0 ) );
    vector<vector<ll>> u( h, vector<ll>( w, 0 ) );
    REP(i,h) REP(j,w) if( rock[i][j] == 0 )
        l[i][j] = (j==0 ? 0 : l[i][j-1])+1;
    REP(i,h) BREP(j,w) if( rock[i][j] == 0 ) 
        r[i][j] = (j==w-1 ? 0 : r[i][j+1])+1;
    REP(j,w) REP(i,h) if( rock[i][j] == 0 )
        u[i][j] = (i==0 ? 0 : u[i-1][j])+1;
    REP(j,w) BREP(i,h) if( rock[i][j] == 0 )
        d[i][j] = (i==h-1 ? 0 : d[i+1][j])+1;

    ll maxx = 0;
    REP(i,h)REP(j,w)
        maxx = max( maxx, l[i][j]+r[i][j]+u[i][j]+d[i][j]+-3 );
 
    cout << maxx << endl;
 
    return 0;
}

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

typedef long long ll;
typedef pair<ll,ll> P;
typedef pair<P,ll> PLL;
typedef pair<P,P> PP;
typedef vector<ll> llVEC;
typedef vector<P> PVEC;
typedef priority_queue<P,PVEC,greater<P> > PPQ;
typedef priority_queue<ll, llVEC, greater<ll> > llPQ;

#define rep(i,a,n) for(ll i = a;i < n;i++)
#define rrep(i,a,n) for(ll i = n-1; i >= a;i--)
#define LINF (ll)1e18
#define INF (int)1e9
#define fs first
#define sc second

template<typename T>
ll sz(vector<T> &vec){ return (ll)vec.size(); }
template<typename T>
ll sz(priority_queue<T, vector<T>> &pq) {return (ll)pq.size(); }
template<typename T>
ll sz(priority_queue<T, vector<T>, greater<T>> &pq) {return (ll)pq.size(); }
ll sz(string &s) {return (ll)s.size(); } 
ll gcd(ll a,ll b){ return ((!b) ?a :gcd(b, a%b)); }
ll lcm(ll a,ll b){ return a / gcd(a,b) * b; }
bool checkindex(ll i,ll n){ return (i < n && i >= 0); }

int main(){
    ll n,k;
    cin >> n >> k;
    cout << 1+(ll)ceil((double)(n-k)/(k-1)) << endl;
    return 0;
}



Measured memory_bytes: 3712
while True :
	n,x=map(int,raw_input().split())
	if not( n==0 and x==0) :
		p_count = 0
		i,j,k = [1,2,3]
		while i <= n-2 :
			j = i+1
			while j <= n-1:
				k = j+1
				while k <= n:
					if (i+j+k)==x :
						p_count += 1
						k += 1
						break
					else :
						k += 1
				j += 1
			i += 1
		print(p_count)
 	else :
 		break

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

using namespace std;

typedef long long ll;
typedef pair<ll,ll> pii;
typedef double ld;
typedef pair<ld, ld> pdd;

#define fi first
#define se second
#define mp make_pair
#define fastIO ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

const int N = 302;
const ll inf = (ll)1e14;
ll dp[2][N][N];
ll a[N];
int id[N];

void upd(ll &a, ll b){  
  a = min(a, b);
}

int main(){
  fastIO;
  int n, k;
  cin >> n >> k;
  vector<ll> vv = {0ll};
  for(int i = 1 ; i <= n; i ++ ){
    cin >> a[i];
    vv.push_back(a[i]);
  }
  sort(vv.begin(), vv.end());
  vv.resize(unique(vv.begin(),vv.end()) - vv.begin());
  int m = vv.size();
  for(int i = 1; i <= n; i ++ ){
    id[i] = lower_bound(vv.begin(), vv.end(), a[i]) - vv.begin();
  }
  for(int i = 0 ; i <= n; i ++ ){
    for(int j = 0 ; j <= n; j ++ )
      dp[0][i][j] = dp[1][i][j] = inf;
  }
  dp[0][0][0] = 0;
  ll res;
  for(int i = 0 ; i < n; i ++ ){
    for(int j = 0 ; j <= k ; j ++ ){
      for(int x = 0; x < m ; x ++ ){
        upd(dp[1][j][id[i + 1]], dp[0][j][x] + max(0ll,a[i + 1] - vv[x]));
      }
    }
    for(int j = 0 ; j < k ; j ++ ){
      res = inf;
      for(int x = m-1 ;x >= 0 ; x -- ){
        upd(res, dp[0][j][x]);
        if(j<k)upd(dp[1][j+1][x],res);
      }
      res = inf;
      for(int x = 0 ; x < m ; x ++ ){
        upd(res, dp[0][j][x]-vv[x]);
        upd(dp[1][j+1][x],res+vv[x]);
      }
    }
    for(int j = 0 ; j <= k ; j ++ ){
      for(int x = 0 ;x < m ; x ++ ){
        swap(dp[0][j][x],dp[1][j][x]);
        dp[1][j][x] = inf;
      }
    }
  }
  ll ans = inf;
  for(int j = 0; j <= k ; j ++ ){
    for(int x = 0; x < m ; x ++ ) ans = min(ans, dp[0][j][x]);
  }
  cout << ans << "\n";
  return 0;
}

Measured memory_bytes: 1792
n = int(input())
S = list(map(int, input().split()))
q = int(input())
T = list(map(int, input().split()))
c = 0


def BinarySearch(A, key):
    left = 0
    right = n
    while left < right:
        mid = (left+right)//2
        if A[mid] == key:
            return 1
        elif key < A[mid]:
            right = mid
        else:
            left = mid+1
    return 0


for i in T:
    if (BinarySearch(S, i)):
        c += 1

print(c)



Measured memory_bytes: 16708
#include<bits/stdc++.h>
#define For(a,b,c) for(int a=b;a<=c;++a)
#define Dor(a,b,c) for(int a=b;a>=c;--a)
using namespace std;
int main() {
	string S;
	cin>>S;
	puts((S[0]==S[1]&&S[2]==S[3]&&S[0]!=S[2])||(S[0]==S[2]&&S[1]==S[3]&&S[0]!=S[1])||(S[0]==S[3]&&S[1]==S[2]&&S[0]!=S[1])?"Yes":"No");
	return 0;
}

Measured memory_bytes: 256
/**
 *    author  : 𝒌𝒚𝒐𝒎𝒖𝒌𝒚𝒐𝒎𝒖𝒑𝒖𝒓𝒊𝒏
 *    created : 2020-04-12 17:32:57
 **/

#include <algorithm>
#include <bitset>
#include <cassert>
#include <cctype>
#include <chrono>
#include <cmath>
#include <complex>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <utility>
#include <vector>

using namespace std;

using int64 = long long;

template <class T>
using binary_heap = std::priority_queue<T, std::vector<T>, std::greater<T>>;
template <class T>
std::ostream& operator<<(std::ostream& os, const std::vector<T>& vec) {
  os << '{';
  size_t n = vec.size();
  for (size_t i = 0; i < n; ++i) {
    os << vec[i];
    if (i != n - 1) os << ',';
  }
  os << '}';
  return os;
}
template <class T, class U>
std::ostream& operator<<(std::ostream& os, const std::pair<T, U>& p) {
  return os << '{' << p.first << " " << p.second << '}';
}
template <class T, class U>
std::ostream& operator<<(std::ostream& os, const std::map<T, U>& mp) {
  os << '{';
  for (auto it = mp.begin(); it != mp.end(); ++it) {
    os << '{' << it->first << ':' << it->second << '}';
    if (it != --mp.end()) os << ',';
  }
  os << '}';
  return os;
}
template <class T>
std::ostream& operator<<(std::ostream& os, const std::set<T>& st) {
  os << '{';
  for (auto it = st.begin(); it != st.end(); ++it) {
    os << *it;
    if (it != --st.end()) os << ',';
  }
  os << '}';
  return os;
}
template <class T>
std::istream& operator>>(std::istream& is, std::vector<T>& vec) {
  size_t n = vec.size();
  for (size_t i = 0; i < n; ++i) is >> vec[i];
  return is;
}

#define all(_) begin(_), end(_)
#define rall(_) rbegin(_), rend(_)

#ifdef LOCAL
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]: ", debug_out(__VA_ARGS__)
#else
#define debug(...)
#endif

void debug_out() { std::cerr << '\n'; }

template <class Head, class... Tail>
void debug_out(Head&& head, Tail&&... tail) {
  std::cerr << head;
  if (sizeof...(Tail) != 0) std::cerr << ", ";
  debug_out(std::forward<Tail>(tail)...);
}

std::vector<int> Zalgorithm(const std::string s) {
  int n = s.size();
  std::vector<int> res(n);
  res[0] = n;
  int i = 1, j = 0;
  while (i < n) {
    while (i + j < n && s[j] == s[i + j]) ++j;
    res[i] = j;
    if (j == 0) {
      ++i;
      continue;
    }
    int k = 1;
    while (i + k < n && k + res[k] < j) res[i + k] = res[k], ++k;
    i += k;
    j -= k;
  }
  return res;
};

void ABC141_D() {
  int n;
  string s;
  cin >> n >> s;
  int ans = 0;

  for (int i = 0; i < n; ++i) {
    string t = s.substr(i, n - i);
    vector<int> v = Zalgorithm(t);

    for (int j = 0; j < n - i; ++j) {
      ans = max(ans, min(j, v[j]));
    }
  }
  cout << ans << endl;
}

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

  ABC141_D();

  return 0;
}

Measured memory_bytes: 256
program name
    use,intrinsic :: iso_fortran_env
    implicit none
    integer(int32):: n,i,ans
    integer(int32), allocatable:: a(:), ind(:)
    read*, n
    allocate(a(n))
    read*, a(:)
    allocate(ind(n),source=0)
    ans=0
    do i = 1, n
        if (a(i) <= n) then
            ind(a(i))=ind(a(i))+1
        else
            ans=ans+1
        end if
    end do

    do i=1,n
        if (ind(i) >= i) then
            ans=ans+ind(i)-i
        else
            ans=ans+ind(i)
        end if
    end do
    print'(i0)', ans
end program name

Measured memory_bytes: 1536