akhauriyash/Code-Regression huggingface dataset:
package main
 
import (
    "bufio"
    "fmt"
    "os"
    "strconv"
)

func main(){
    
    a := nextInt()
    b := nextInt()
    c := nextInt()
    
    set := make(map[int]struct{})
    
    set[a] = struct{}{}
    set[b] = struct{}{}
    set[c] = struct{}{}
    
    fmt.Println(len(set))
    
}

/* templates */


func Max(a []int) int {
    r := a[0]
    for i := 0; i < len(a); i++ {
        if r < a[i] {
            r = a[i]
        }
    }
    return r
}
 
func Min(a []int) int {
    r := a[0]
    for i := 0; i < len(a); i++ {
        if r > a[i] {
            r = a[i]
        }
    }
    return r
}
 
func Sum(a []int) (r int) {
    for i := range a {
        r += a[i]
    }
    return r
}
 
func Abs(a float64) float64 {
    if a < 0 {
        return -a
    }
    return a
}
 
type Pair struct {
    first, second int
}
 
type Pairs []Pair
  
func (p Pairs) Swap(i, j int) {
    p[i], p[j] = p[j], p[i]
}
 
var nextReader func() string
 
func init() {
    nextReader = NewScanner()
}
 
func NewScanner() func() string {
    r := bufio.NewScanner(os.Stdin)
    r.Buffer(make([]byte, 1024), int(1e+11))
    r.Split(bufio.ScanWords)
    return func() string {
        r.Scan()
        return r.Text()
    }
}

func nextString() string {
    return nextReader()
}
 
func nextInt64() int64 {
    v, _ := strconv.ParseInt(nextReader(), 10, 64)
    return v
}
 
func nextInt() int {
    v, _ := strconv.Atoi(nextReader())
    return v
}
 
func nextInts(n int) []int {
    r := make([]int, n)
    for i := 0; i < n; i++ {
        r[i] = nextInt()
    }
    return r
}

func nextStrings(n int) []string {
    r := make([]string, n)
    for i := 0; i < n; i++ {
        r[i] = nextString()
    }
    return r
}

func nextFloat64() float64 {
    f, _ := strconv.ParseFloat(nextReader(), 64)
    return f
}


Measured memory_bytes: 640
#include<bits/stdc++.h>
#define hell (int)(1e9+7)
#define int long long int
#define inf 1000000000000

using namespace std;

int dp[1001][10001];

int helper(vector <int> &a,vector <int> &b,int st,int h){
    if(h<=0)
        return 0;
    if(st>=a.size())
        return inf;
    if(dp[st][h]!=-1)
        return dp[st][h];
    int ans;
    ans=helper(a,b,st,h-a[st])+b[st];
    ans=min(ans,helper(a,b,st+1,h));
    return dp[st][h]=ans;
}

void solve(){
    int h,n;
    cin>>h>>n;
    vector <int> a(n),b(n);
    for(int i=0;i<n;i++)
        cin>>a[i]>>b[i];
    memset(dp,-1,sizeof dp);
    cout<<helper(a,b,0,h);
}

signed main()
{
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	int t,c;
	//cin>>t;
	t=1;
	while(t--){
		solve();
	}
	return 0;
}


Measured memory_bytes: 79232
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.*;
import java.math.BigInteger;
 
public class Main implements Runnable {
	
	static int mod = 1000000007;
	
    public static void main(String[] args) {
    	new Thread(null, new Main(), "", 1024 * 1024 * 1024).start();
    }
    
    public void run() {
       	PrintWriter out = new PrintWriter(System.out);
        FastScanner sc = new FastScanner();

        char[] s = sc.next().toCharArray();

        int start = s.length;
        int goal;
        
        if(s[0] == s[s.length-1]){
        	goal = 1;
        }
        else{
        	goal = 0;
        }
        
        if((start-goal)%2==0){	//偶数回操作
        	out.println("Second");
        }
        else{
        	out.println("First");
        }
        
        out.flush();
    }

}



class FastScanner {
	private final InputStream in = System.in;
	private final byte[] buffer = new byte[1024];
	private int ptr = 0;
	private int buflen = 0;
	private boolean hasNextByte() {
		if (ptr < buflen) {
			return true;
		} else {
			ptr = 0;
			try {
				buflen = in.read(buffer);
			} catch (IOException e) {
				e.printStackTrace();
			}
			if (buflen <= 0) {
				return false;
			}
		}
		return true;
	}
	private int readByte() {
		if (hasNextByte())
			return buffer[ptr++];
		else
			return -1;
	}
	private static boolean isPrintableChar(int c) {
		return 33 <= c && c <= 126;
	}
	public boolean hasNext() {
		while (hasNextByte() && !isPrintableChar(buffer[ptr]))
			ptr++;
		return hasNextByte();
	}
	public String next() {
		if (!hasNext())
			throw new NoSuchElementException();
		StringBuilder sb = new StringBuilder();
		int b = readByte();
		while (isPrintableChar(b)) {
			sb.appendCodePoint(b);
			b = readByte();
		}
		return sb.toString();
	}
	public long nextLong() {
		if (!hasNext())
			throw new NoSuchElementException();
		long n = 0;
		boolean minus = false;
		int b = readByte();
		if (b == '-') {
			minus = true;
			b = readByte();
		}
		if (b < '0' || '9' < b) {
			throw new NumberFormatException();
		}
		while (true) {
			if ('0' <= b && b <= '9') {
				n *= 10;
				n += b - '0';
			} else if (b == -1 || !isPrintableChar(b)) {
				return minus ? -n : n;
			} else {
				throw new NumberFormatException();
			}
			b = readByte();
		}
	}
	public int nextInt() {
		long nl = nextLong();
		if (nl < Integer.MIN_VALUE || nl > Integer.MAX_VALUE)
			throw new NumberFormatException();
		return (int) nl;
	}
	public int[] nextintArray(int n){
		int[] a = new int[n];
		for(int i=0;i<n;i++){
			a[i] = nextInt();
		}
		return a;
	}
	public long[] nextlongArray(int n){
		long[] a = new long[n];
		for(int i=0;i<n;i++){
			a[i] = nextLong();
		}
		return a;
	}
	public Integer[] nextIntegerArray(int n){
		Integer[] a = new Integer[n];
		for(int i=0;i<n;i++){
			a[i] = nextInt();
		}
		return a;
	}
	public int[][] nextintMatrix(int h, int w){
		int[][] mat = new int[h][w];
		for(int i=0;i<h;i++){
			for(int j=0;j<w;j++){
				mat[i][j] = nextInt();
			}
		}
		return mat;
	}
	public double nextDouble() {
		return Double.parseDouble(next());
	}
}

Measured memory_bytes: 26708
#include "bits/stdc++.h"
using namespace std;

#define FAST ios_base::sync_with_stdio(false); cin.tie(0);
#define pb push_back
#define eb emplace_back
#define ins insert
#define f first
#define s second
#define cbr cerr<<"hi\n"
#define mmst(x, v) memset((x), v, sizeof ((x)))
#define siz(x) ll(x.size())
#define all(x) (x).begin(), (x).end()
#define lbd(x,y) (lower_bound(all(x),y)-x.begin())
#define ubd(x,y) (upper_bound(all(x),y)-x.begin())
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());    //can be used by calling rng() or shuffle(A, A+n, rng)
inline long long rand(long long x, long long y) { return rng() % (y+1-x) + x; } //inclusivesss
string inline to_string(char c) {string s(1,c);return s;} template<typename T> inline T gcd(T a,T b){ return a==0?llabs(b):gcd(b%a,a); }

using ll=long long; 
using ld=long double;
#define FOR(i,s,e) for(ll i=s;i<=ll(e);++i)
#define DEC(i,s,e) for(ll i=s;i>=ll(e);--i)
using pi=pair<ll,ll>; using spi=pair<ll,pi>; using dpi=pair<pi,pi>; 

#define LLINF ((long long)1e18)
#define INF int(1e9+1e6)
#define MAXN (300006)
int main(){
	FAST
	ll n;
	cin>>n;
	ll ans=0;
	FOR(i,1,n){
		ll mx = n / i;
		ans += mx * (mx+1) / 2 * i;
	}
	cout<<ans<<'\n';
}


Measured memory_bytes: 3656
#include<bits/stdc++.h>                   // below comment for pbds
#include<ext/pb_ds/assoc_container.hpp>   // to use it make ordered_set
#include<ext/pb_ds/tree_policy.hpp>       // all set fnct + = 1. order_of_key(x); // number of 
#define ll long long                      //element strictly smaller than it;
#define ld long double                    // 2. find_by_order(x),pointer el at x pos after sort  use as s.f();
#define ordered_set tree<ll, null_type,less<ll>, rb_tree_tag,tree_order_statistics_node_update>
using namespace std; // assert(a[i]<n ) // if we want to check for special cond , used for debug                     
using namespace __gnu_pbds; // make less_equal in order to make a multiset pbds
#define INF (ll)1e18 
const ll Mod = (ll)1e9+7;
ll CaseN=1;
const ld PI = 22/7.0;

ll tst()
{
ll ans=0;

return ans;
}


ll fast_power(ll a,ll b,ll mod){
	ll ans=1;
	while(b>0){
	if(b&1){
	ans=(a*ans)%mod;
	}
	b=b>>1;
	a=(a*a)%mod;
	}
	return ans;
	}


void solve()
{	
	//cout<<fast_power(2,11,Mod);
		ll ans=0;
		
		ll n;
		cin>>n;
		
		ll p1 = fast_power(9ll,n,Mod);
			//p1 = (p1*n)%Mod;
			p1 = (p1*2ll)%Mod;
		ll p2 = fast_power(8ll,n,Mod); //few common		
		ll p3 = fast_power(10ll,n,Mod);
		ll p5 = (p1-p2)%Mod; //p3-p5
		ans = (p3-p5+Mod)%Mod;
		
		if(n<=1)
		{
		ans = 0;	
		}
		
		cout<<ans<<endl;
		//cout<<"Case #"<<CaseN<<": ";
		CaseN++;
		// print your ans below;
	
return ;

}


signed main() {
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	ll t=1;
	//cin>>t;
	while(t--)
	{
	solve();
	}
	
}


Measured memory_bytes: 3652
#include "bits/stdc++.h"
using namespace std;
#ifdef _DEBUG
#define dlog(str) cout << "====" << str << endl;
#else
#define dlog(str)
#endif
#define INF 999999999
#define MOD 1000000007
#define REP(i, n) for(int i = 0, i##_l = (n); i < i##_l; i++)
#define FOR(i, s, e) for(int i = s, i##_l = (e); i < i##_l; i++)
#define LLI long long int
#define _min(a,b) ((a<b)?a:b)
#define _max(a,b) ((a<b)?b:a)
#define chmax(a, b) a = _max(a, b)
#define chmin(a, b) a = _min(a, b)
#define bit(a, shift) ((a>>shift)&1))
#define pm(a) ((a)?1:-1)
#define SORT(v) sort(v.begin(),v.end())
#define RSORT(v) sort((v).rbegin(), (v).rend())
// int 2.14E±9    lli 9.2E±18    double 1.7E±380


int main()
{
	cout << fixed << setprecision(10);
	string s, t;
	cin >> s >> t;
	int ans = INF;
	REP(i, s.size() - t.size() + 1)
	{
		int cnt = 0;
		REP(j, t.size())
		{
			if (s[i + j] != t[j])
			{
				cnt++;
			}
		}
		chmin(ans, cnt);
	}
	cout << ans;

	return 0;
}

Measured memory_bytes: 3552
#include <cstdio>

using namespace std;

const long long mod = 1000000007;

int main()
{
    int N, n = 0;
    char s1[60], s2[60];
    long long dp[60];
    scanf("%d%s%s", &N, s1, s2);
    for(int i = 0; i < N; n++) {
        if(s1[i] == s2[i]) { dp[n] = 1; i++; }
        else { dp[n] = 2; i+=2; }
    }
    dp[n] = dp[0] == 1 ? 3 : 6;
    for(int i = 1; i < n; i++) {
        if(dp[i-1] == 1) dp[n] = dp[n] * 2 % mod;
        else if(dp[i] == 2) dp[n] = dp[n] * 3 % mod;
    }
    printf("%lld\n", dp[n]);
    return 0;
}


Measured memory_bytes: 128
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <cstdio>
#include <cstring>
#include <cmath>
using namespace std;
using ll = long long;

int main() {
    int a, b;
    cin >> a >> b;

    int c = b - a;
    int d = c * (c - 1) / 2;

    cout << d - a << endl;

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef unsigned long long ull;
typedef long long ll;
#define fastio() ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
int main()
{
    fastio();
    string s,t;
    cin>>s>>t;
    int len1 = s.length();
    int len2 = t.length();
    int dp[len1+1][len2+1]={};
    for(int i=0;i<len1;i++)
    {
        for(int j=0;j<len2;j++)
        {
            if(s[i]==t[j])
                dp[i+1][j+1]=1+dp[i][j];
            else
            {
                dp[i+1][j+1]=max(dp[i][j+1],dp[i+1][j]);
            }
            // cout<<dp[i+1][j+1]<<" ";
        }
        // cout<<endl;
    }
    int lcs=dp[len1][len2];
    string ans="";
    int i=len1,j=len2;
    while(lcs!=0)
    {
        if(dp[i][j]>max(dp[i-1][j],dp[i][j-1]))
        {
            ans+=s[i-1];
            // cout<<s[i-1]<<" ";
            // cout<<ans<<" ";
            i--;
            j--;
            lcs--;
        }
        else
        {
            if(dp[i][j]==dp[i-1][j])
            {
                i--;
            }
            else
            {
                j--;
            }
        }
    }
    reverse(ans.begin(),ans.end());
    cout<<ans<<endl;
    return 0;
 }    

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

int main() {
    ll n, a, b, c, d, e;
    cin >> n >> a >> b >> c >> d >> e;
    ll x = min(a, min(b, min(c, min(d, e))));
    ll len = n / x + (n % x ? 1 : 0);
    cout << 5LL + len - 1;
    
    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
#include <stdio.h>
#include <stdlib.h>
#define ll long long

int slcompare(const void *a,const void *b){
    if(*(long long *)a>*(long long  *)b)return 1;
    return -1;
}
int lscompare(const void *a,const void *b){
    if(*(long long *)a>*(long long  *)b)return -1;
    return 1;
}
long long MAX(long long a,long long  b){
    return a>b?a:b;
}

int main(){
  ll n,k,i,j,tmp,l=-1,r=1000000000000,s;
  scanf("%lld %lld",&n,&k);
  long long a[n],f[n];
  for(i=0;i<n;i++){
    scanf("%lld",&a[i]);
  }

  for(i=0;i<n;i++){
    scanf("%lld",&f[i]);
  }

    qsort(a,n,sizeof(long long),slcompare);
    qsort(f,n,sizeof(long long),lscompare);

  while (l+1<r) {
    ll sum=0;
    s=(l+r)/2;
    for(i=0;i<n;i++){
      sum+=MAX(0,a[i]-s/f[i]);
    }
    if(sum<=k)r=s;
    else l=s;
  }
  printf("%lld",r);
  return 0;
}


Measured memory_bytes: 4988
N = int(input())
A = list(map(lambda x:int(x),input().split(" ")))

sum_ = 0
max_ = 0
for i in range(N-1):
    max_ = max(max_,A[i])
    if max_ > A[i+1]:
        sum_+=max_-A[i+1]

print(sum_)

Measured memory_bytes: 32184
N = int(input())
F=[]
P=[]
k=[0]*10
for i in range(N):
    F.append(list(map(int, input().strip().split())))
for i in range(N):
    P.append(list(map(int, input().strip().split())))


ans=-10**10
for i in range(1,2**11-1):
    tmp=0
    s='{0:010b}'.format(i)
    for k in range(N):
        c=0
        for j in range(10):
            if (int(s[j])+F[k][j])==2:
                c+=1
        tmp+=P[k][c]
    ans=max(ans,tmp)
    
print(ans)

Measured memory_bytes: 3064
def diff(a, b):
	cnt = 0
	for i in range(len(a)):
		if a[i] == b[i]:
			cnt += 1
	return cnt

def solve(a, b):
	l = len(b)
	maxx = -1
	for i in range(len(a)-l+1):
		val = diff(b, a[i:i+len(b)])
		maxx = max(maxx, val)
	return l - maxx

a = input()
b = input()
print(solve(a, b))


Measured memory_bytes: 8848
#include<cstdio>
#include<algorithm>
#include<functional>
using namespace std;
char a[1000][1001];
int main(void)
{
	int i,j,k,l,m,n,ii,jj,cnt1,cnt2,sum,mx,flg,i1,j1,iii,jjj;
	char b[4],buf[3],c[4]="JOI",d;
	int dx1[4]={-1,0,-1,0},dy1[4]={-1,-1,0,0};
	int dx2[4]={0,1,0,1},dy2[4]={0,0,1,1};
	scanf("%d %d",&m,&n);
	for(i=0;i<m;i++)	scanf("%s",a[i]);
	scanf("%s",buf);
	b[0]=buf[0];	b[1]=buf[1];
	scanf("%s",buf);
	b[2]=buf[0];	b[3]=buf[1];
	sum=0;
	for(i=0;i<m-1;i++)	{
		for(j=0;j<n-1;j++)	{
			flg=1;
			for(k=0;k<4;k++)	{
				ii=i+dy2[k];	jj=j+dx2[k];
				if(a[ii][jj]!=b[k])	{
					flg=0;	break;
				}
			}
			sum+=flg;
//			if(flg==1)	printf("i=%d j=%d\n",i,j);
		}
	}
//	printf("sum=%d\n",sum);
	mx=0;
	for(i=0;i<m;i++)	{
		for(j=0;j<n;j++)	{
			cnt1=0;
			for(i1=0;i1<4;i1++)	{
				ii=i+dy1[i1];	jj=j+dx1[i1];
				if(ii>=0 && jj>=0)	{
					flg=1;
					for(j1=0;j1<4;j1++)	{
						iii=ii+dy2[j1];	jjj=jj+dx2[j1];
//						printf("i=%d j=%d ii=%d jj=%d iii=%d jjj=%d\n",i,j,ii,jj,iii,jjj);
						if(iii>=m || jjj>=n || a[iii][jjj]!=b[j1])	{
							flg=0;	break;
						}
					}
					cnt1+=flg;
		
				}
			}
			d=a[i][j];
			for(k=0;k<3;k++)	{
				cnt2=0;			
				if(a[i][j]!=c[k])	{
					a[i][j]=c[k];
					for(i1=0;i1<4;i1++)	{
						ii=i+dy1[i1];	jj=j+dx1[i1];
						if(ii>=0 && jj>=0)	{
							flg=1;
							for(j1=0;j1<4;j1++)	{
								iii=ii+dy2[j1];	jjj=jj+dx2[j1];
								if(iii>=m || jjj>=n || a[iii][jjj]!=b[j1])	{
									flg=0;	break;
								}
							}
							cnt2+=flg;
//							if(flg==1)	printf("i=%d j=%d ii=%d jj=%d\n",i,j,ii,jj);
//							printf("cnt2=%d\n",cnt2);
						}
					}
					mx=max(mx,cnt2-cnt1);
					a[i][j]=d;
				}
			}
		}
	}
	printf("%d\n",sum+mx);
	return 0;
}



Measured memory_bytes: 3736
// inputに入力データ全体が入る
function Main(input) {
	var N = input.split('\n')[0];
	var p = input.split('\n');
	p.shift();
	p = p.map(v => parseInt(v));
	if (Number.isNaN(p[p.length - 1])) {
		p.pop();
	}
	var max = Math.max(...p);
	p.splice(p.indexOf(max), 1);
	var sum = 0;
	p.forEach(v => sum += v);
	sum += max / 2;
	console.log(sum);
}

// ※この行以降は編集しない (標準入力から一度に読み込みMainを呼び出します)
Main(require("fs").readFileSync("/dev/stdin", "utf8"));

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

#define rep(i, n) for (int i = 0; i < (n); i++)
using namespace std;
typedef long long ll;

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; }

int main(int argc, char **argv)
{
    // int a,b;
    // cin >> a >> b;
    // cout << boost::format("lcm(%d,%d)=%d\n") % a % b % lcm(a,b);
    // cout << boost::format("gcd(%d,%d)=%d\n") % a % b % gcd(a,b);
    string a, b;
    cin >> a >> b;
    cout << b << a << endl;

    return 0;
}


Measured memory_bytes: 256
// AOJ 2961 Doubling
// 2019.8.8 bal4u

#include <stdio.h>

#if 1
#define gc() getchar_unlocked()
#define pc(c) putchar_unlocked(c)
#else
#define gc() getchar()
#define pc(c) putchar(c)
#endif

int in() { // 非負整数の入力
	int n = 0, c = gc();
	do n = 10 * n + (c & 0xf); while ((c = gc()) >= '0');
	return n;
}

void out(int n) { // 非負整数の表示（出力）
	int i;
	char b[20];

	if (!n) pc('0');
	else {
		i = 0; while (n) b[i++] = n % 10 + '0', n /= 10;
		while (i--) pc(b[i]);
	}
	pc('\n');
}

#define MAX 100000
int cnt[MAX+2];
int a[MAX+2];

void num_of_divisors(int max) {
	int i, j, m;
	cnt[1] = 1;
	for(i = 2; i <= max; i++) cnt[i] = 2;
	m = max >> 1;
	for(i = 2; i <= m; i++) for (j = i << 1; j <= max; j += i) cnt[j]++;
}

int main()
{
	int i, Q;
	
	num_of_divisors(MAX);
	for (i = 1; i <= MAX; i++) a[i] = a[i-1] + (cnt[i] > 4);
	Q = in(); while (Q--) out(a[in()]);
	return 0;
}


Measured memory_bytes: 2444
from collections import Counter
s,t = [],[]

N = int(input())
for i in range(N):
    s.append(input())

M = int(input())
for i in range(M):
    t.append(input())

sd = Counter(s)
td = Counter(t)
sd.subtract(td)

print(max(sd.most_common(1)[0][1],0))


Measured memory_bytes: 3316
#include <algorithm>
#include <cmath>
#include <vector>
#include <functional>
#include <cstdlib>
#include <map>
#include <set>
#include <iostream>
#include <string>
#include <ctype.h>
#include <climits>
#include <queue>
using namespace std;
#define REP(i, n) for(ll i = 0; i < (ll)(n); i++)
typedef long long ll;

int main(){
	string n;
	cin >> n;
	
	if(n[0]==n[2]) cout << "Yes\n";
	else cout << "No\n";
	
	return 0;
}

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

using namespace std;

#define int long long
#define FOR(i, a, b) for(ll i = (a); i < (b); ++i)
#define FORR(i, a, b) for(ll i = (a); i > (b); --i)
#define REP(i, n) for(ll i = 0; i < (n); ++i)
#define REPR(i, n) for(ll i = n; i >= 0; i--)
#define FOREACH(x, a) for(auto &(x) : (a))
#define VECCIN(x)                                                              \
    for(auto &youso_ : (x)) cin >> youso_
#define mp make_pair
#define bitcnt __builtin_popcount
#define SZ(x) ((ll)(x).size())
#define All(a) (a).begin(), (a).end()
template <typename T = long long> inline T IN() {
    T x;
    cin >> x;
    return (x);
}
inline void CIN() {}
template <class Head, class... Tail>
inline void CIN(Head &&head, Tail &&... tail) {
    cin >> head;
    CIN(move(tail)...);
}
#define CINT(...)                                                              \
    int __VA_ARGS__;                                                           \
    CIN(__VA_ARGS__)
#define LCIN(...)                                                              \
    ll __VA_ARGS__;                                                            \
    CIN(__VA_ARGS__)
#define SCIN(...)                                                              \
    string __VA_ARGS__;                                                        \
    CIN(__VA_ARGS__)
#define Yes(a) cout << (a ? "Yes" : "No") << "\n"
#define YES(a) cout << (a ? "YES" : "NO") << "\n"
#define Printv(v)                                                              \
    {                                                                          \
        FOREACH(x, v) { cout << x << " "; }                                    \
        cout << "\n";                                                          \
    }
template <typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val) {
    std::fill((T *)array, (T *)(array + N), val);
}

typedef long long ll;
typedef unsigned long long ul;
typedef vector<ll> VL;
typedef pair<ll, ll> PL;
typedef priority_queue<ll> PQ;
typedef priority_queue<ll, VL, greater<ll>> PQG;

const int INF = 1e9;
const int MOD = 1e9 + 7;
// const int MOD = 998244353;
const ll LINF = 1e18 + 1;
const ll dx[] = {1, -1, 0, 0};
const ll dy[] = {0, 0, 1, -1};

string s;
map<char, ll> cnt;

signed main() {
    cin >> s;
    ll N = s.length(), cnt = 0;
    REP(i, s.length()) {
        string tmp = s.substr(i, 3);
        if(tmp == "ABC") cnt++;
    }
    if(cnt == 0) {
        cout << 0 << "\n";
        return 0;
    }
    ll a = 0, ans = 0;
    bool abc = false;
    REP(i, N) {
        if(!abc) {
            string tmp = s.substr(i, 3);
            if(tmp == "ABC") {
                abc = true;
                a++;
            } else if(s[i] == 'A') {
                a++;
            } else {
                a = 0;
            }
        } else {
            string tmp = s.substr(i, 2);
            if(tmp == "BC") {
                ans += a;
                i++;
            } else {
                abc = false;
                i--;
            }
        }
    }
    cout << ans << "\n";
}


Measured memory_bytes: 640
#input of int(split by space)
def get_i()
  return gets.chomp.split(" ").map(&:to_i)
end
#input of float(split by space)
def get_f()
  return gets.chomp.split(" ").map(&:to_f)
end
#input of string(split by space)
def get()
  return gets.chomp.split(" ")
end
#input of string(split per one character)
def get_nsp()
  return gets.chomp.split("")
end
#yes or no decision
def yn_judge(bool,y="Yes",n="No")
  return bool ? y : n 
end
#create of array
def array(size1,init=nil,size2=-1)
  if size2==-1
      return Array.new(size1){init}
  else
      return Array.new(size2){Array.new(size1){init}}
  end
end

def max(a,b)
    return a>b ? a : b
end

def min(a,b)
    return a>b ? b : a
end

INF=Float::INFINITY

puts (gets.to_i+1)%2

Measured memory_bytes: 14392
import GHC.Integer.GMP.Internals
main=interact$show.f.map read.words
m=1000000007
f[n,a,b]=mod(powModInteger 2 n m-1-n%a-n%b)m
n%r=foldl(\x y->rem(x*y)m)1[(n+1-i)*recipModInteger i m|i<-[1..r]]

Measured memory_bytes: 5268
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;

public class Main {

    private static Scanner sc;

    public static void main(String[] args) {
        Main instance = new Main();
        sc = instance.new Scanner();
        instance.solve();
    }

    private void solve() {
        try {
          int n = sc.nextInt();
          int k = sc.nextInt();

          int tmp = 1;
          int l = k - 1;
          for (int i = 0; i < n - 1; i++) {
            tmp *= l;
          }
          int answer = k * tmp;
          System.out.println(answer); 
        } catch (Exception e) {
            e.printStackTrace();
        }
    }

    private class Scanner {
        String[] s;
        int i;
        BufferedReader br;
        String regex = " ";

        public Scanner() {
            s = new String[0];
            i = 0;
            br = new BufferedReader(new InputStreamReader(System.in));
        }

        @Override
        protected void finalize() throws Throwable {
            try {
                super.finalize();
            } finally {
                destruction();
            }
        }

        private void destruction() throws IOException {
            if (br != null) br.close();
        }

        public String next() throws IOException {
            if (i < s.length) return s[i++];
            String st = br.readLine();
            while (st == "") st = br.readLine();
            s = st.split(regex, 0);
            i = 0;
            return s[i++];
        }

        public int nextInt() throws NumberFormatException, IOException {
            return Integer.parseInt(next());
        }

        public Long nextLong() throws NumberFormatException, IOException {
            return Long.parseLong(next());
        }

        public Double nextDouble() throws NumberFormatException, IOException {
            return Double.parseDouble(next());
        }
    }
}



Measured memory_bytes: 8276
#include "bits/stdc++.h"
using namespace std;
#define Long long long;
#define fastIO ios::sync_with_stdio(0) , cin.tie(0)


int dp[ 100005];
int arr[ 100005];
const int INF = 1e9 + 10;

int solve( int pos , const int kesimo ){
    if( pos == 1 ) return 0;

    if( dp[pos] != -1 ) return dp[pos];

    dp[pos] = INF;

    for( int npos = max( 1 , pos - kesimo) ;  npos < pos ; npos++ ){
        dp[pos] = min ( dp[pos] , solve( npos , kesimo ) + abs( arr[pos]-arr[npos] ) );
    }
    return dp[pos];
}

int main(){

    fastIO;

    int n, k;
    cin >> n >> k;

    for(int i=1; i<=n; ++i) cin >> arr[i];
    memset( dp , -1 , sizeof dp);

    cout << solve( n , k ) ;
    return 0;
}


Measured memory_bytes: 5760
#include <bits/stdc++.h>
//#define int long long

using namespace std;
using LL = long long;
using P = pair<int, int>;
using Tapris = tuple<int, int, int>;

#define FOR(i, a, n) for(int i = (int)(a); i < (int)(n); ++i)
#define REP(i, n) FOR(i, 0, n)

#define pb(a) push_back(a)
#define all(x) (x).begin(),(x).end()

const int INF = (int)1e9;
const LL INFL = (LL)1e15;
const int MOD = 1e9 + 7;

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

/*************** using variables ***************/
string s, t;
/**********************************************/

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

    cin >> s >> t;

    for(int i = s.size()-t.size(); i >= 0; i--){
        for(int j = 0; j < t.size(); j++){
            if(s[i+j] != t[j] && s[i+j] != '?') break;
            if(j == t.size()-1){
                for(int k = 0; k < s.size(); k++){
                    
                    if(k >= i && k < i + t.size()){
                        cout << t[k-i];
                    }else{
                        cout << (s[k] == '?' ? 'a' : s[k]);
                    }
                }
                cout << endl;
                return 0;
            }
        }
    }

    cout << "UNRESTORABLE" << endl;
}


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

int main() {
    string s;
    cin >> s;
    rep(i, s.size()-1) {
        for(int j = i+1; j < s.size(); j++) {
            if(s[i] == s[j]) {
                cout << "no" << endl;
                return 0;
            }
        }
    }

    cout << "yes" << endl;

    return 0;
}


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

int main(void)
{
    string s1,s2,s3;
    cin >> s1 >> s2 >> s3;
    char a = s1[0] - 0x20;
    char b = s2[0] - 0x20;
    char c = s3[0] - 0x20;
    cout << a << b << c <<endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define endl "\n"
#define debug(x) cerr << #x " = " << (x) << endl;
#define P(x) cerr << #x << endl;    
typedef long long ll;
//#define int long long
const int mod = 1000000007;

const int maxn = 1e5 + 100;
int a[maxn];

int32_t main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout << fixed << setprecision(9);
    
    
    int n;
    cin >> n;
    
    for(int i = 0; i < n; ++ i)
    {
        cin >> a[i];
    }
    
    int ans = 0;
    int cur = a[0];
    int count = 0;
    for(int i = 1; i < n; ++ i)
    {
        if(cur >= a[i])
        {
            ++ count;
            cur = a[i];
//            debug(cur);
//            debug(a[i]);
        }
        else
        {
//            P(out);
//            debug(cur);
//            debug(a[i]);
            count = 0;
            cur = a[i];
            
        }
        ans = max(ans, count);
    }
    
    cout << ans << endl;
    
    return 0;
}






Measured memory_bytes: 640
#include "bits/stdc++.h"
using namespace std;
static const int MAX=100;
static const int INFTY=(1<<21);
static const int WHITE=0;
static const int GRAY=1;
static const int BLACK=2;

int n,M[MAX][MAX];

int prim(){
	int u,minv;
	int d[MAX],p[MAX],color[MAX];
	for (int i = 0; i < n; ++i) {
		d[i]=INFTY;
		p[i]=-1;
		color[i]=WHITE;
	}
	d[0]=0;
	while(1){
		minv=INFTY;
		u=-1;
		for (int i = 0; i < n; ++i) {
			if (minv>d[i]&&color[i]!=BLACK) {
				u=i;
				minv=d[i];
			}
		}
		if(u==-1)break;
		color[u]=BLACK;
		for (int v = 0; v < n; ++v) {
			if(color[v]!=BLACK&&M[u][v]!=INFTY){
				if(d[v]>M[u][v]){
					d[v]=M[u][v];
					p[v]=u;
					color[v]=GRAY;
				}
			}
		}
	}
	int sum=0;
	for (int i = 0; i < n; ++i) {
		if(p[i]!=-1)sum+=M[i][p[i]];
	}
	return sum;
}



int main(){
	cin>>n;
	for (int i = 0; i < n; ++i) {
		for (int j = 0; j < n; ++j) {
			int e;cin>>e;
			M[i][j]=(e==-1)?INFTY:e;
		}
	}
	cout<<prim()<<endl;
	return 0;
}

Measured memory_bytes: 2996
#include <bits/stdc++.h>
  
using namespace std;
  
template<class T> void ckmin(T &a, T b) { a = min(a, b); }
template<class T> void ckmax(T &a, T b) { a = max(a, b); }
  
#define pb push_back
#define mp make_pair
#define cotu cout
#define itn int
#define Red ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define F first
#define S second
#define sz(x) (int)x.size()
#define all(x) (x).begin(), (x).end()
#define rep(i, n) for(int i = 0; i < n; ++i)
#define repr(i,n) for(int i = n - 1; i >= 0; --i)
#define Rep(i, a, n) for(int i = (a); i <=(n); ++i)
#define repst(i, n) for(auto it = n.begin(); it != n.end(); ++it)
#define Repr(i, a, n) for(int i = (n); i >= (a); --i)
  
#define ordered_set tree<int , null_type,less<int >, rb_tree_tag,tree_order_statistics_node_update> 
  
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
using namespace __gnu_pbds; 
  
typedef long long ll;
typedef pair<ll, ll> pll;
typedef pair<int, int> pii;
  
const int inf = int(1e9);
const int mod = inf + 7;
const int N = 1e6 + 555; // TL MB
const double PI = acos(-1.0);
 
void mul(ll &x, ll y){
	x *= y;
	if(x >= mod) x %= mod;
}
 
void add(ll &x, ll y){
	x += y;
	if(x >= mod) x -= mod;
	if(x < 0) x += mod;
}
ll bp(ll a, ll n){
	ll r = 1;
	while(n){
		if(n & 1) mul(r, a);
		mul(a, a);
		n >>= 1;
	}
	return r;
}

void solve()
{
	int n;
	double m;
	cin >> n >> m;
	double a[n];
	int sum = 0;
	int mx = 0;
	int cnt = 0;
	rep(i, n) cin >> a[i], sum += a[i];
	rep(i, n){
		if(a[i] >= sum / (4.0 * m)){
			cnt++;
		}
	}
	cout << (cnt >= m ? "Yes" : "No");
}


 
 
int main()
{
    Red;
	int T = 1;
	//cin >> T; 
	for(int i = 1; i <= T; ++i){
		solve();
	}
    return 0;
}

Measured memory_bytes: 256
fun main(args: Array<String>) {

    val n = readLine()!!.toInt()

    val a = readLine()!!.split(" ").map { it.toInt() }.toTypedArray()

    val lcs = Array(n + 1) { 0 }
    for (i in 1..n) {
        lcs[i] = gcd(lcs[i - 1], a[i - 1])
    }

    val rcs = Array(n + 2) { 0 }
    for (i in n downTo 1) {
        rcs[i] = gcd(rcs[i + 1], a[i - 1])
    }

    val ans = (1..n).map { gcd(lcs[it - 1], rcs[it + 1]) }.max()
    println(ans)
}

fun gcd(a: Int, b: Int): Int {

    if (b == 0) {
        return a
    }

    return gcd(b, a % b)
}


Measured memory_bytes: 59624
import * as fs from 'fs';

namespace AtCoder.abc119 {

    /**
     * Program
     */
    export class Program {
        /**
         * in
         *  2019/04/30
         * out
         *  Heisei
         */
        static main(inp: string): string {
            if (inp <= '2019/04/30') {
                return 'Heisei';
            } else {
                return 'TBD';
            }
        };
    }
}

console.log(AtCoder.abc119.Program.main(fs.readFileSync('/dev/stdin', 'utf8').trim()));


Measured memory_bytes: 7372
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ConsoleApp61 {
    class Program {
        static void Main(string[] args) {
            var st = Console.ReadLine().Split().Select(int.Parse).ToArray();
            int N = st[0];
            int M = st[1];
            int X = st[2];
            int Y = st[3];

            var x = Console.ReadLine().Split().Select(int.Parse).ToArray();
            var y = Console.ReadLine().Split().Select(int.Parse).ToArray();

            int x_max = x.Max();
            int y_min = y.Min();


            if (x_max + 1 > y_min || Y < x_max + 1 || y_min < X + 1) {
                Console.WriteLine("War");
            } else {
                Console.WriteLine("No War");
            }

        }
    }
}


Measured memory_bytes: 13396
import heapq
from operator import itemgetter

n, m = map(int, input().split())
a = list(map(int, input().split()))
heapq.heapify(a)
bc = [list(map(int, input().split())) for _ in range(m)]
bc.sort(key=itemgetter(1), reverse=True)

for b, c in bc:
    for _ in range(b):
        mn = heapq.heappop(a)
        if mn < c:
            heapq.heappush(a, c)
        else:
            heapq.heappush(a, mn)
            break

print(sum(a))

Measured memory_bytes: 33092
#include<cstdio>
#include<algorithm>
#include<cstdlib>
#include<iostream>
using namespace std;
int main() {
    int n;
    while(scanf("%d",&n),n) {
        int b[16];
        for(int i = 0; i < 16; i++) {
            b[i] = 0;
        }
        int stage = 0;
        string str;
        cin >> str;
        for(int i = 0; i < str.size(); i++) {
            int index = i % n;
            if(str[i] == 'M') {
                b[index]++;
            }
            else if(str[i] == 'S') {
                stage += b[index] + 1;
                b[index] = 0;
            }
            else {
                b[index] += stage + 1;
                stage = 0;
            }
        }
        sort(b,b+n);
        for(int i = 0; i < n - 1; i++) {
            printf("%d ",b[i]);
        }
        printf("%d %d\n",b[n-1],stage);
    }
    return 0;
}

Measured memory_bytes: 1248
N = int(input())
Q = [tuple(map(int, input().split())) for _ in range(N)]
vote = Q[0]  # 初期値はそのまま得票(互いに素)

for p, q in Q[1:]:
    if p == q:
        g = max(vote)
        vote = (g, g)
    # p基準: 現在の得票以上の最小のpの倍数
    p_v0 = ((vote[0] + p - 1) // p) * p
    p_v1 = q * p_v0 // p
    # q基準
    q_v1 = ((vote[1] + q - 1) // q) * q
    q_v0 = p * q_v1 // q
    # 減っていたら除外
    if p_v1 < vote[1]:
        vote = (q_v0, q_v1)
    elif q_v0 < vote[0]:
        vote = (p_v0, p_v1)
    else:
        # どっちもありえるなら小さいほう
        if p_v0 + p_v1 <= q_v0 + q_v1:
            vote = (p_v0, p_v1)
        else:
            vote = (q_v0, q_v1)

ans = sum(vote)
print(ans)

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

#[allow(unused_macros)]
macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

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

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

#[allow(unused_macros)]
macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

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

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

    ($next:expr, bytes) => {
        read_value!($next, String).into_bytes()
    };

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

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

fn main() {
    input! {
        n: usize,
        mut v: [usize; n],
    }
    v.sort();
    let mut sum = v[0] as f64;
    for i in 1..v.len() {
        sum += v[i] as f64;
        sum /= 2f64;
    }
    println!("{}", sum);
}


Measured memory_bytes: 4352
#include <cassert>
#include <cctype>
#include <cstdio>
#include <cstdlib>
#include <ctime>
#include <algorithm>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <vector>
using namespace std;
#define REP(i, n) for(int i = 0; i < (int)(n); ++i)
typedef long long ll;

int n;
ll vs[200000+10];
vector<ll> ps, zs, ns;

ll calc(ll x) {
  ll res = 0;
  for(int neg : ns) {
    if(x > 0) {
      // 0と正は全部OKで、負は絶対値が小さいところまで
      res += zs.size();
      res += ps.size();
      res += lower_bound(ns.begin(), ns.end(), (x+neg-1) / neg) - ns.begin();
      if(neg < (x+neg-1) / neg) {
        --res;
      }
    } else if(x == 0) {
      // 正だけ全部OK
      res += ps.size();
    } else {
      // 正の、絶対値が大きいところだけ
      res += (ll)ps.size() - (upper_bound(ps.begin(), ps.end(), -x / neg) - ps.begin());
    }
  }
  if(x > 0) {
    res += zs.size() * ll(n-1);
  }
  for(int pos : ps) {
    if(x > 0) {
      // 0と負は全部OKで、正は絶対値が小さいところまで
      res += zs.size();
      res += ns.size();
      res += lower_bound(ps.begin(), ps.end(), (x+pos-1) / pos) - ps.begin();
      if(pos < (x+pos-1) / pos) {
        --res;
      }
    } else if(x == 0) {
      // 負だけ全部OK
      res += ns.size();
    } else {
      // 負の、絶対値が大きいところだけ
      res += (ll)ns.size() - (upper_bound(ns.begin(), ns.end(), -x / pos) - ns.begin());
    }
  }
  return res / 2;
}

int main(void) {
  ll k;
  scanf("%d%lld", &n, &k);
  REP(i, n) {
    scanf("%lld", &vs[i]);
    if(vs[i] < 0) {
      ns.push_back(-vs[i]);
    } else if(vs[i] == 0) {
      zs.push_back(vs[i]);
    } else {
      ps.push_back(vs[i]);
    }
  }
  sort(ps.begin(), ps.end());
  sort(ns.begin(), ns.end());
  ll right = 1000000000000000000LL + 1;
  ll left = -right;
  while(left + 1 < right) {
    ll mid = (left + right) / 2;
    ll count = calc(mid);
    // cerr << "> " << left << " " << right << " " << mid << " " << count << endl;
    if(count < k) {
      left = mid;
    } else {
      right = mid;
    }
  }
  cout << left << endl;
  return 0;
}


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

int main()
{
	long long a, v, b, w, t;
	cin >> a >> v >> b >> w >> t;

	if (a <= b) {
		long long aa = a + v * t;
		long long bb = b + w * t;
		if (aa < bb) {
			cout << "NO" << endl;
		}
		else {
			cout << "YES" << endl;
		}
	}
	else {
		long long aa = a - v * t;
		long long bb = b - w * t;
		if (aa <= bb) {
			cout << "YES" << endl;
		}
		else {
			cout << "NO" << endl;
		}
	}

	return 0;
}

Measured memory_bytes: 3624
tmp = input()
A = int(tmp.split()[0])
B = int(tmp.split()[1])
 
res = 0
if A%2 == 0:
	if B%2 == 0:
		res = B^(int((B-A)/2)%2)
	else :
		res = int((B-A+1)/2)%2
else :
	if B%2 == 0:
		res = A^B^(int((B-A-1)/2)%2)
	else :
		res = A^(int((B-A)/2)%2)
print(res)

Measured memory_bytes: 3064
import sys, math
from functools import lru_cache
import numpy as np
import heapq
from collections import defaultdict
sys.setrecursionlimit(10**9)
MOD = 10**9+7

def input():
    return sys.stdin.readline()[:-1]

def mi():
    return map(int, input().split())

def ii():
    return int(input())

def i2(n):
    tmp = [list(mi()) for i in range(n)]
    return [list(i) for i in zip(*tmp)]


def lcm(a, b):
    return a*b//math.gcd(a, b)


def main():
    N = ii()
    s = input()
    if s.count('R') > N/2:
        print('Yes')
    else:
        print('No')

if __name__ == '__main__':
    main()


Measured memory_bytes: 26664
#include <bits/stdc++.h> 
#define ll long long int 
using namespace std; 
  
int main() 
{  
    ios_base::sync_with_stdio(false) ;
    cin.tie(NULL);   
    ll a;  
    string s; 
    cin>>a>>s;
if(a<3200) cout<<"red"<<endl; 
else cout<<s<<endl;
    return 0; 
} 


Measured memory_bytes: 3656
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<iomanip>
#include<math.h>
#include<complex>
#include<queue>
#include<deque>
#include<stack>
#include<map>
#include<set>
#include<bitset>
#include<functional>
#include<assert.h>
#include<numeric>
using namespace std;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
using ll = long long;
const int inf=1e9+7;
const ll longinf=1LL<<60 ;
const ll mod=1e9+7 ;

const int B = 10;

int query(vector<int>& idx,vector<int>& a){
    cout<<"?";
    for(auto e:idx)cout<<" "<<a[e];
    cout<<endl;
    string s;
    cin>>s;
    return s == "Red";
}

int main(){
    int n;
    cin>>n;
    int m = 2*n;
    vector<int> a(m);
    rep(i,m)a[i]=i+1;
    rep(_,10)random_shuffle(a.begin(), a.end());
    vector<int> idx(n);
    rep(i,n)idx[i]=2*i;
    int ret = query(idx,a);
    int  L=0, R = n;
    int s = -1;
    while(R-L>1){
        int M = (L+R)/2;
        REP(j,L,M){
            idx[j]++;
        }
        int res = query(idx,a);
        if(res!=ret){
            REP(j,L,M){
                idx[j]--;
            }
            R=M;
        }
        else L = M;
    }
    vector<int> ans(m+1);
    int b = L;
    ans[a[idx[b]]]=1;ans[a[idx[b]^1]]=-1;
    int r = 0,l = 0;
    rep(i,n){
        if(i==b)continue;
        if(r==n/2){
            ans[a[idx[i]^1]]=1;
            continue;
        }
        if(l==n/2){
            ans[a[idx[i]^1]]=-1;
            continue;
        }
        idx[b]=idx[i]^1;
        int res = query(idx,a);
        if(res!=ret)ans[a[idx[b]]]=-1,r++;
        else ans[a[idx[b]]]=1,l++;
    }
    rep(i,n){
        idx[i]^=1;
    }
    r = 0; l = 0;
    rep(i,n){
        if(i==b)continue;
        if(r==n/2){
            ans[a[idx[i]^1]]=1;
            continue;
        }
        if(l==n/2){
            ans[a[idx[i]^1]]=-1;
            continue;
        }
        idx[b]=idx[i]^1;
        int res = query(idx,a);
        if(res!=ret)ans[a[idx[b]]]=-1,r++;
        else ans[a[idx[b]]]=1,l++;
    }
    string ANS = "";
    rep(i,m){
        if(ans[i+1]==1){
            if(ret==1)ANS += 'R';
            else ANS += 'B';
        }
        else {
            if(ret==1)ANS += 'B';
            else ANS += 'R';
        }
    }
    cout<<"! "<<ANS<<endl;
    return 0;
}

Measured memory_bytes: 724
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        double r = sc.nextDouble();
        double pi = Math.PI;
        double menseki = r*r*pi;
        double ensyuu = 2*r*pi;
        System.out.printf("%f %f",menseki,ensyuu);
    }
}


Measured memory_bytes: 28256
N, x = map(int, input().split())
a = [int(c) for c in input().split()]

ans = 0
for i in range(N-1):
  if a[i]+a[i+1]>x:
    if a[i]>x:
      ans += a[i]-x
      a[i] = x
    
    ans += a[i]+a[i+1]-x
    a[i+1] = x-a[i]
print(ans)

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

using ll = long long;

int n, m;

ll f(int x, int y){
	if(x % 3 == 0) return 0;
	ll ret = y;
	for(int i = 1; i < x; i++){
		vector<ll> v({1LL * i * y, 1LL * y / 2 * (x - i), 1LL * (y - y / 2) * (x - i)});
		sort(v.begin(), v.end());
		ret = min(ret, v[2] - v[0]);
	}
	return ret;
}

int main(){
	ios_base::sync_with_stdio(false); cin.tie(NULL);
	cin >> n >> m;
	cout << min(f(n, m), f(m, n));
}

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

#define REP(i, s, e) for(int i = (int)(s); i < (int)(e); ++i)
#define rep(i, n) REP(i, 0, n)
#define repr(i, n) for(int i = (n-1); i >= 0; --i)

int x[10][10];

using arr4 = array<int, 4>;
using arr5 = array<int, 5>;

arr4 conv(int n) {
  arr4 ret;
  repr(i, 4) {
    ret[i] = n%10;
    n /= 10;
  }
  return ret;
}

arr5 calc1(const arr4& a) {
  arr5 ret;
  rep(i, 4) ret[i] = a[i];
  int tmp = 0;
  rep(i, 4) {
    tmp = x[tmp][a[i]];
  }
  ret[4] = tmp;
  return ret;
}

using v5 = vector<arr5>;

v5 calc2(arr5& a) {
  v5 ret;
  rep(i, 5) {
    rep(j, 10) {
      if(j != a[i]) {
	swap(j, a[i]);
	ret.push_back(a);
	swap(j, a[i]);
      }
    }
  }
  return ret;
}
v5 calc3(arr5& a) {
  v5 ret;
  rep(i, 4) {
    if(a[i] == a[i+1]) continue;
    swap(a[i], a[i+1]);
    ret.push_back(a);
    swap(a[i], a[i+1]);
  }
  return ret;
}

int calc4(const arr5& a) {
  int ret = 0;
  rep(i, 5) ret = x[ret][a[i]];
  return ret;
}

int main() {
  rep(i, 10) rep(j, 10) cin >> x[i][j];
  int ans = 0;
  rep(i, 1e4) {
    auto a = conv(i);
    auto b = calc1(a);
    auto u = calc2(b);
    auto v = calc3(b);
    bool f = false;
    for(auto&& x : u) f |= calc4(x) == 0;
    for(auto&& x : v) f |= calc4(x) == 0;
    if(f) ++ans;
  }
  cout << ans << endl;
  return 0;
}



Measured memory_bytes: 3160
N=int(input())
H=[int(x) for x in input().split()]
INF=10**15

dp=[INF for x in range(N)]
dp[0]=0
dp[1]=abs(H[0]-H[1])
for i in range(2,N):
    dp[i]=min(abs(H[i]-H[i-2])+dp[i-2],abs(H[i]-H[i-1])+dp[i-1])

print(dp[N-1])

Measured memory_bytes: 13924
#include <bits/stdc++.h>
#define MOD 1000000007
#define int long long int
#define FF first
#define pb push_back
#define SS second
#define double long double
using namespace std;

typedef long long ll;

int power(int a,int b)
{
  int res=1LL;
  while(b>0)
  {
    if(b&1)
      res=res*a;
    b/=2;
    a*=a;
  }
  return res;
}
signed main()
{

   // freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
  int n,p;
  
   
    cin>>n>>p;//n= no. of stones
    int k=sqrt(p);
    int req=1;
    for(int x=2;x<k;x++)
    {int count=0;
      while(p%x==0){
        count++;
        p=p/x;
      }

      req*=power(x,ll(count/n));
    }
    req*=power(p,ll(1/n));
   cout<<req;


        
}

Measured memory_bytes: 256