akhauriyash/Code-Regression huggingface dataset:
x=int(input())
if x<600:
    print(8)
elif x<800:
    print(7)
elif x<1000:
    print(6)
elif x<1200:
    print(5)
elif x<1400:
    print(4)
elif x<1600:
    print(3)
elif x<1800:
    print(2)
elif x<2000:
    print(1)


Measured memory_bytes: 9112
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<ll,ll> P;
typedef pair<int,int> Pi;
#define rep(i,n) for(ll i=0;i<n;i++)
#define FOR(i,a,b) for(ll i=a;i<b;i++)
#define fi first
#define se second
#define endl "\n"

template<typename T> inline bool chmax(T &a, T b){if(a<b){a=b;return true;}return false;}
template<typename T> inline bool chmin(T &a, T b){if(a>b){a=b;return true;}return false;}
template<typename T> ostream& operator<<(ostream& s,const complex<T>& d) {return s<<"("<<d.real()<<", "<<d.imag()<< ")";}
template<typename T1, typename T2> ostream& operator<<(ostream& s,const pair<T1,T2>& d) {return s<<"("<<d.first<<", "<<d.second<<")";}
template<typename T> ostream& operator<<(ostream& s, const vector<T>& d){int len=d.size();rep(i,len){s<<d[i];if(i<len-1) s<<" ";}return s;}
template<typename T> ostream& operator<<(ostream& s,const vector<vector<T>>& d){int len=d.size();rep(i,len){s<<d[i]<<endl;}return s;}
template<typename T> ostream& operator<<(ostream& s,const set<T>& v){s<<"{ ";for(auto itr=v.begin();itr!=v.end();++itr) {if (itr!=v.begin()) {s<< ", ";}s<<(*itr);}s<<" }";return s;}
template<typename T> ostream& operator<<(ostream& s,const multiset<T>& v){s<<"{ ";for(auto itr=v.begin();itr!=v.end();++itr) {if (itr!=v.begin()) {s<< ", ";}s<<(*itr);}s<<" }";return s;}
template<typename T1, typename T2> ostream& operator<<(ostream& s,const map<T1,T2>& m){s<<"{"<<endl;for(auto itr=m.begin();itr!=m.end();++itr){s<<" "<<(*itr).first<<" : "<<(*itr).second<<endl;}s<<"}"<<endl;return s;}

const ll mod=1e9+7;
const ll inf=1e17;
const int INF=1e9;
const double EPS=1e-10;
const double PI=acos(-1);

int main(){
    cin.tie(0);ios::sync_with_stdio(false);
    int a,b;
    cin>>a>>b;
    cout<<a*b<<endl;
}

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

int n,ans;
vector<int> p,te;

int main(){
    scanf ("%d",&n);
    p.resize(n); te.resize(3);
    ans = 0;
    for (int i = 0; n > i ;i++){
        if (i) scanf (" ");
        else scanf ("\n");
        scanf ("%d",&p[i]);
    }
    for (int i = 1; n-1 > i; i++){
        te[0] = p[i-1];
        te[1] = p[i];
        te[2] = p[i+1];
        //printf ("%d %d %d\n",te[0],te[1],te[2]);
        sort(te.begin(),te.end());
        if (te[1] == p[i]) ans++;
    }
    printf ("%d\n",ans);
}


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

 const int N=1000000000;
int main() {
  ll n,ans=1;
  cin>>n;
  vector<ll> a(n);
  rep(i,n){
    cin>>a[i];
  }
  sort(a.begin(),a.end());
  if(a[0]==0){
    cout<<0<<endl;
    return 0;
  }
  rep(i,n){
    ll p=ans,q=a[i];
    if(p>N){
      p/=N;
    }
    if(q>N){
      q/=N;
    }
    if(((p!=ans||q!=a[i])&&p*q>=N)||(p!=ans&&q!=a[i])){
      ans=-1;
      break;
    }
    ans=ans*a[i];
  }
  if(ans>1000000000000000000){
    cout<<-1<<endl;
    return 0;
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 3988
import java.util.*;

public class Main{
	void solve(){
		Scanner scan = new Scanner(System.in);
		int n = scan.nextInt();
		int[] h = new int[n];
		for(int i = 0; i < n; i++) h[i] = scan.nextInt();
		int[] dp = new int[n];
		dp[0] = 0;
		dp[1] = Math.abs(h[1] - h[0]);
		for(int i = 2; i < n; i++) {
			dp[i] = Math.min(dp[i - 1] + Math.abs(h[i] - h[i - 1]), dp[i - 2] + Math.abs(h[i] - h[i - 2]));
		}
		System.out.println(dp[n - 1]);
		scan.close();
	}

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


Measured memory_bytes: 59816
import java.io.BufferedReader; 
import java.io.*;
import java.io.InputStreamReader; 
import java.util.Scanner; 
import java.util.StringTokenizer; 
import java.util.*;
import java.math.*;
public class Main 
{ 
    static class FastReader 
    { 
        BufferedReader br; 
        StringTokenizer st; 
  
        public FastReader()
        { 
            br = new BufferedReader(new
                     InputStreamReader(System.in)); 
        } 
  
        String next()
        { 
            while (st == null || !st.hasMoreElements()) 
            { 
                try
                { 
                    st = new StringTokenizer(br.readLine()); 
                } 
                catch (IOException  e) 
                { 
                    e.printStackTrace(); 
                } 
            } 
            return st.nextToken(); 
        } 
  
        int nextInt() 
        { 
            return Integer.parseInt(next()); 
        } 
  
        long nextLong() 
        { 
            return Long.parseLong(next()); 
        } 
  
        double nextDouble() 
        { 
            return Double.parseDouble(next()); 
        } 
  
        String nextLine() 
        { 
            String str = ""; 
            try
            { 
                str = br.readLine();
            } 
            catch (IOException e) 
            { 
                e.printStackTrace(); 
            } 
            return str; 
        } 
    } 
   public static void main(String args[])
    {
        FastReader sc=new FastReader();
        PrintWriter pw=new PrintWriter(System.out);
        int t=1;//sc.nextInt(),k=0;
        long ans=0,mod=1000000007;
        while(t-->0)
        {
         String s = sc.next();
            String f = s.substring(0,s.length()/2);
            String st = s.substring(s.length()/2 +1);

            if(new StringBuffer(s).reverse().toString().equals(s) && new StringBuffer(f).reverse().toString().equals(f) &&new StringBuffer(st).reverse().toString().equals(st))
                pw.println("Yes");
            else
                pw.println("No");
        }
           pw.close();
    }
}
  

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

int main(){
	int A, B, sum=0;
	cin >> A >> B;
  for(int i = A; i <= B; i++){
  
    if(i/10000==i%10 and i/1000%10==i/10%10){
    sum += 1;
    }
  }
cout << sum << endl;
}

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


const long mod=1000000007;

long modinv(long a, long m) {
    long b = m, u = 1, v = 0;
    while (b) {
        long t = a / b;
        a -= t * b; swap(a, b);
        u -= t * v; swap(u, v);
    }
    u %= m;
    if (u < 0) u += m;
    return u;
}

long modcombi(long n, long r){
    long tmp = 1;
    for(long i=1;i<=r;i++){
        tmp = ( (tmp % mod) * (((n-r)+i) % mod) ) % mod;
    }
    for(long i=1;i<=r;i++){
        tmp = ( (tmp % mod) * modinv( i % mod, mod) ) % mod;
    }
    return tmp;
}


int main(){
    long S;
    cin >> S;

    if(S<3){ cout << 0 << endl; return 0;}
    if(S==3){ cout << 1 << endl; return 0;}

    long max_num = S / 3;
    
    
    long res = 0;
    // 数列の長さで分けて考える
    for(long n=max_num;n>=1;n--){
        // 最初に2こずつ分け与える
        long s = S - n*2;

        // 仕切り入れられる箇所 s-1 仕切り入れる個数 n-1
        long tmp = modcombi(s-1,n-1);
        //cout << "length : "<< n << ", space : " << s-1 << ", shikiri : " << n-1 << ", result : " << tmp << endl;
        res = ( (res % mod) + ( tmp % mod) ) % mod;
    }
    
    cout << res << endl;



    return 0;
}


Measured memory_bytes: 3612
object Main extends App {
	// your code goes here
	val num = io.StdIn.readLine().toInt
	val order = io.StdIn.readLine().split(" ").map(_.toInt)
	val manzoku = io.StdIn.readLine().split(" ").map(_.toInt)
	val up = io.StdIn.readLine().split(" ").map(_.toInt)
	val (t, _) = order.foldLeft((0, num))((t, o) => { 
		val u = if(t._2 + 1 == o){up(t._2 - 1)}else{0}
		(t._1 + manzoku(o -1 ) + u, o) })
	println(t)
}

Measured memory_bytes: 25528
#C

N = int(input())
S = []

for _ in range(N):
  S += [input()]

import collections
c = collections.Counter(S)
m = max(c.values())

words = []

for k,v in c.most_common():
  if v == m:
    words += [k]
  else:
    break

for w in sorted(words):
  print(w)

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

int main(){
        int N,K;scanf("%d%d",&N,&K);
        long long ans=0;

        for(int i=K+1;i<=N;++i){
                for(int j=0;j<=N;j+=i){
                        ans+=max(min(N,j+i-1)-max(1,j+K)+1,0);
                }   
        }   
        cout<<ans<<endl;
}


Measured memory_bytes: 256
def resolve():
    n=int(input())
    lv=list(map(int, input().split()))
    lc=list(map(int, input().split()))
    ans=0
    for i in range(n):
        if lv[i]>lc[i]:
            ans+=lv[i]-lc[i]
    print(ans)
resolve()

Measured memory_bytes: 3060
#pragma GCC optimize("O3")
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
using namespace std;
using lli = long long;

int N, arr[2010];
lli ans;

int main()
{
	ios_base::sync_with_stdio(0);
	cin.tie(0); cout.tie(0);
	cin >> N;
	for (int i = 0; i < N; ++i)
		cin >> arr[i];
	sort(arr, arr + N);
	for (int i = 0; i < N; ++i)
	{
		for (int j = i + 1; j < N; ++j)
		{
			ans += lower_bound(arr + j + 1, arr + N, arr[i] + arr[j]) - arr - 1 - j;
		}
	}
	cout << ans;
}

Measured memory_bytes: 256
#include <algorithm>
#include <iostream>
#include <math.h>
#include <stdio.h>
#include <string>
#include <sstream>
#include <vector>
#include <set>
#include <map>
#include <cmath>
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
using namespace std;

int main()
{
	int a,b;
	cin>>a>>b;
	int num = 0;
	if( b >= 100){
		num = 1000 * a + b;
	}else if( b >= 10){
		num = 100 * a + b;
	}else{
		num = 10*a + b;
	}
	bool ans = false;
	for(int i = 1; i < 10000; i++){
		if( i * i == num){
			ans = true;
			break;
		}
	}
	if( ans == true){
		cout<<"Yes"<<endl;
	}else{
		cout<<"No"<<endl;
	}
	return 0;
}



Measured memory_bytes: 3060
#include <iostream>
#include <vector>
typedef long long ll;
using namespace std;

int main(void) {
    
    int N;
    cin >> N;
    vector<ll> ary(N);
    for (int i = 0; i < N; i++) {
        cin >> ary[i];
    }
    ll max = ary[0];
    ll res = 0;
    for (int i = 1; i < N; i++) {
        if (ary[i] > max)
            max = ary[i];
        else
            res += max - ary[i];
    }
    cout << res << endl;
    
    return 0;
}

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

const int MAX = 1e5 + 5;

#define dbg(a) cout << "-> " << __LINE__ << ": " << #a << " = " << a << endl

int main() {
    int n;
	string s;
	cin >> n >> s;
	for (char &c : s) {
		int x = c - 'A';
		x = (x + n) % 26;
		c = char(x + 'A');
	}
	cout << s << endl;
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<iomanip>
#include<map>
#include<unordered_map>
#include<set>
#include<unordered_set>
#include<vector>
#include<array>
#include<string>
#include<stack>
#include<queue>
#include<algorithm>
#include<cassert>
#include<functional>
#include<random>
#include<complex>
#include<bitset>
#include<chrono>
//#include<boost/multiprecision/cpp_int.hpp>
#define int int64_t
#define uint uint64_t
#define REP(i, a, b) for (int64_t i = (int64_t)(a); i < (int64_t)(b); i++)
#define rep(i, a) REP(i, 0, a)
#define SZ(X) ((int64_t)((X).size()))
#define ITR(x, a) for (auto x = a.begin(); x != a.end(); x++)
#define ALL(a) (a.begin()), (a.end())
#define HAS(a, x) (a.find(x) != a.end())
#define Min(x) *min_element(ALL(x))
#define Max(x) *max_element(ALL(x))
#define Unique(L) (L.erase(unique(ALL(L)), L.end()))
#define intmax (std::numeric_limits<int64_t>::max() / 4)
#define doublemax (std::numeric_limits<double>::max() / 4)
using namespace std;
//typedef boost::multiprecision::cpp_int bigint;
//const double EPS = 1e-9;
//const double PI = acos(-1.0);


vector<vector<int>>tree;
int dfs(int now, int prev) {
    if(prev!=-1&&tree[now].size()==1){//leaf
        return 2;
    }
    int count = 0;
    for (int i : tree[now])if (i != prev) {
        int c = dfs(i, now);
        if (c == -2)return -2;
        if(c == 2){
            if(count==0)count=1;
            else return -2;
        }
    }
    if(count==0)return 2;
    return 1;
}

signed main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    int N;
    cin >> N;
    if (N == 1) {
        cout << "First" << endl;
        return 0;
    }
    if (N == 2) {
        cout << "Second" << endl;
        return 0;
    }
    tree = vector<vector<int>>(N);
    rep(i, N - 1) {
        int a, b;
        cin >> a >> b;
        a--; b--;
        tree[a].push_back(b);
        tree[b].push_back(a);
    }
    
    int ans = dfs(0,-1);
    if(ans==-2||ans==2){
        cout<<"First"<<endl;
    }
    else cout<<"Second"<<endl;
    
    
    return 0;
}










Measured memory_bytes: 6400
n, y = list(map(int,input().split()))
flag = 0
for i in range(n+1):
    for j in range(n-i+1):
        if 10000*i + 5000*j + 1000*(n - i - j )==y:
            print(i, j, n-i-j)
            flag = 1
            break
    if flag == 1:
        break
        
if flag == 0:
    print(-1,-1,-1)

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

class Dijkstra{ //O((N+M)logN)
    private:
        vector<vector<pair<int,long long>>> graph; //pair<next_path,cost>
        vector<long long> total_cost;
    
    public:
        Dijkstra(vector<vector<pair<int,long long>>> graph,int start,int size,bool path_check = false){
            priority_queue<
                pair<int,long long>,
                vector<pair<int,long long>>,
                greater<pair<int,long long>>> q;
            vector<long long> cost(size,1e18+7);
            cost[start] = 0;
            q.push(make_pair(start,0ll));
            while (!q.empty()){
                auto now = q.top();
                q.pop();
                int prev = now.first;
                if( cost[prev] < now.second) continue;
                for (auto next : graph[prev]){
                    if (cost[next.first] <= cost[now.first] + next.second) continue;
                    cost[next.first] = cost[now.first] + next.second;
                    q.push(next);
                }
            }
            total_cost = cost;
        }
        long long get_cost(int goal){ return total_cost[goal]; }
};
#define ll long long
#define rep(i,x,y) for(int i=x;i<y;i++)
#define rel(i,x,y) for(int i=x-1;i>=y;i--)
#define all(x) x.begin(),x.end()

int main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    int n,m; cin >> n >> m;
    vector<vector<pair<int,ll>>> graph(n+1); //graph[i].first  i:現在地,first:次の場所,second:コスト
    rep(i,0,m){
        int b1,b2; cin >> b1 >> b2;
        graph[b2].push_back(make_pair(b1,1));
        graph[b1].push_back(make_pair(b2,1));
    }
    Dijkstra G(graph,1,n+1);
    if( G.get_cost(n) == 2)cout << "POSSIBLE" << endl;
    else cout << "IMPOSSIBLE" << endl;
}

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

int main()
{
	int n,k;
	cin>>n>>k;
	
	int v=1;
	for(int i=0;i<n;i++){
		int a=v*2;
		int b=v+k;
		v=min(a,b);
	}
	
	cout<<v<<endl;
	
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <fstream>
#include <queue>
#include <map>
#include <set>
#include <algorithm>

using namespace std;

typedef long long ll;
typedef __int128 lll;
constexpr ll mod = 1000000007;

int n, k, a[100000];

int main() {
    cin >> n >> k;
    for (int i = 0; i < n; i++) cin >> a[i];
    ll r = 0, c = 0, d = 0;
    for (int i = 0; i < k; i++) c += a[i];
    for (int i = k; i < n; i++) d += max(0, a[i]);
    r = max(c + d, d);
    for (int i = 0; i < n - k; i++) {
        d += max(0, a[i]) - max(0, a[i + k]);
        c += a[i + k] - a[i];
        r = max(r, max(c + d, d));
    }
    cout << r << endl;
}

Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
bool cmp(pair<int,int> o,pair<int,int> t)
{
	if(o.second<t.second) return true;
	else return false;
}
int main()
{
	int n;cin>>n;
	vector< pair<int,int> > v(n);
	for(int i=0;i<n;i++)
	{	
		cin>>v[i].first>>v[i].second;
	}
	sort(v.begin(),v.end(),cmp);
	long long tsum=0;
	bool flag=false;
	for(int i=0;i<n;i++)
	{
		if(tsum+v[i].first<=v[i].second)
		{
			tsum+=v[i].first;
		}
		else
		{
			flag=true;
			break;
		}
	}
	if(flag)
	{
		cout<<"No"<<endl;
	}
	else
	{
		cout<<"Yes"<<endl;
	}
}

Measured memory_bytes: 1792
using static System.Math;
using System;


public class hello
{
    public static void Main()
    {
        while (true)
        {
            var z = int.Parse(Console.ReadLine().Trim());
            if (z == 0) break;
            getAns(z);
        }
    }
    static int pow3(int x, int y, int z) => z * z * z - x * x * x - y * y * y;
    static void getAns (int z)
    {
        var x = 1;
        var y = z - 1;
        var ans = pow3(x, y, z);
        while (true)
        {
            x++;
            if (x > y) break;
            while (true)
            {
                var t = pow3(x, y, z);
                if (t < 0) y--;
                else { ans = Min(ans, t); break; }
            }
        }
        Console.WriteLine(ans);
    }
}


Measured memory_bytes: 15936
import sys, re
from math import ceil, floor, sqrt, pi, factorial, gcd
from copy import deepcopy
from collections import Counter, deque
from heapq import heapify, heappop, heappush
from itertools import accumulate, product, combinations, combinations_with_replacement
from bisect import bisect, bisect_left
from functools import reduce
from decimal import Decimal, getcontext
# input = sys.stdin.readline 
def i_input(): return int(input())
def i_map(): return map(int, input().split())
def i_list(): return list(i_map())
def i_row(N): return [i_input() for _ in range(N)]
def i_row_list(N): return [i_list() for _ in range(N)]
def s_input(): return input()
def s_map(): return input().split()
def s_list(): return list(s_map())
def s_row(N): return [s_input for _ in range(N)]
def s_row_list(N): return [s_list() for _ in range(N)]
def Yes(): print('Yes')
def No(): print('No')
def YES(): print('YES')
def NO(): print('NO')
def lcm(a, b): return a * b // gcd(a, b)
sys.setrecursionlimit(10 ** 6)
INF = float('inf')
MOD = 10 ** 9 + 7
num_list = []
str_list = []

def main():
    x = i_input()

    for i in range(1,1000):
        if 360 * i % x == 0:
            print(360*i//x)
            exit()
    
if __name__ == '__main__':
    main()


Measured memory_bytes: 72716
#include <bits/stdc++.h>
using namespace std;
int main()
{   /// Standing in the hall of fame
    ios_base::sync_with_stdio() , cin.tie(NULL) , cout.tie(NULL);
    int n , a[100005] , x = 0 , mx = 0;
    cin >> n;
    for(int i = 0 ; i < n ; i++)
        cin >> a[i];
    for(int i = 1 ; i < n ; i++){
        if(a[i-1] >= a[i])x++;
        else              x = 0;
        mx = max(mx , x);
    }
    cout << mx << "\n";
    return 0;
}

Measured memory_bytes: 640
#include<iostream>
#include<iomanip>
#include<math.h>
#include<algorithm>
#include<utility>
#include<queue>
#include<string.h>
#include<string>
#include<set>
#include<map>
#include<unordered_map>
#include<functional>
#include<vector>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
const ll INF=2e18;
const ll MOD=1e9+7;

ll H,W;
ll d[10][10];
ll A[210][210];
int main(){
    cin>>H>>W;
    for(ll i=0;i<10;i++){
        for(ll j=0;j<10;j++){
            cin>>d[i][j];
        }
    }
    for(ll i=0;i<H;i++){
        for(ll j=0;j<W;j++){
            cin>>A[i][j];
        }
    }
    for(ll k=0;k<10;k++){
        for(ll i=0;i<10;i++){
            for(ll j=0;j<10;j++){
                d[i][j]=min(d[i][j],d[i][k]+d[k][j]);
            }
        }
    }
    ll ans=0;
    for(ll i=0;i<H;i++){
        for(ll j=0;j<W;j++){
            if(A[i][j]==-1)continue;
            ll miCost=INF;
            for(ll k=0;k<10;k++){
                miCost=min(miCost,d[A[i][j]][k]+d[k][1]);
            }
            ans+=miCost;
        }
    }
    cout<<ans<<endl;
    return 0;
}

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

long n, k;
long a[100000];

long sub(long x) {
  long cnt = 0;
  for (int i = 0; i < n; ++i) {
    auto it = lower_bound(a, a + n, x - a[i]);
    cnt += a + n - it;
  }
  return cnt >= k;
}

// (cnt, sum)
long p[100001];
pair<long, long> cat(long x) {
  for (int i = 0; i < n; ++i) {
    p[i + 1] = p[i] + a[i];
  }
  
  long cnt = 0;
  long sum = 0;
  for (int i = 0; i < n; ++i) {
    auto it = lower_bound(a, a + n, x - a[i] + 1);
    long num = a + n - it;
    cnt += num;
    long pos = it - a;
    sum += p[n] - p[pos] + a[i] * num;
  }
  return make_pair(cnt, sum);
}

int main() {
  cin >> n >> k;
  for (int i = 0; i < n; ++i) cin >> a[i];
  sort(a, a + n);
  
  long lo = 0;
  long hi = 1e6;
  while (hi - lo > 1) {
    long mid = (lo + hi) / 2;
    if (sub(mid)) {
      lo = mid;
    } else {
      hi = mid;
    }
  }
  
  auto p = cat(lo);
  long ans = p.second + (k - p.first) * lo;
  cout << ans << endl;
}

Measured memory_bytes: 1920
#include <iostream>

using namespace std;

char mat[102][102];
int direct[5] = {-1, 0, 1, 0, -1};
int m, n;
int ans;


void dfs(int x, int y) {
    if (mat[x][y] == '.') return;
    char t = mat[x][y];
    mat[x][y] = '.';
    for (int i = 0; i < 4; ++i) {
        int xx = x + direct[i];
        int yy = y + direct[i + 1];
        if (0 <= xx and xx < m and 0 <= yy and yy < n and mat[xx][yy] == t) {
            dfs(xx, yy);
        }
    }
}

void solve() {
    ans = 0;
    for (int i = 0; i < m; ++i) {
        cin >> mat[i];
    }
    for (int i = 0; i < m; ++i) {
        for (int j = 0; j < n; ++j) {
            if (mat[i][j] != '.') {
                ++ans;
                dfs(i, j);
            }
        }
    }
}

int main() {
    while (cin >> m >> n and n > 0 and m > 0) {
        solve();
        cout << ans << endl;
    }
}


Measured memory_bytes: 3540
#include <stdio.h>

int main(){

	int x,i;
	
	
	for(i=0;i<10000;i++){
		scanf("%d",&x);
		if(x==0){
			break;
		}else{printf("Case %d: %d\n",i+1,x);}
	}
	
	return 0;

}

Measured memory_bytes: 596
#include <bits/stdc++.h>
#define rep0(i, n) for (int i = 0; i < (n); ++i)
#define rep1(i, n) for (int i = 1; i <= (n); ++i)
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
typedef tuple<string, int, int> TU;

int main()
{
    int A,B;
    cin >> A >> B;
    if(B%A==0){
        cout << A+B << endl;
    }else{
        cout << B-A << endl;
    }
}


Measured memory_bytes: 3604
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(), (x).end()
typedef long long ll;
const int INF (1<<30);

vector<set<int>> G;
vector<vector<int>> F, B;
vector<int> group;
int N, M, K;

void dfs(int v, int c) {
  rep(i, F[v].size()) {
    int nextV = F[v][i];
    if (group[nextV] == INF) {
      group[nextV] = c;
      G[c].insert(nextV);
      dfs(nextV, c);
    }
  }
}

int main() {
  cin >> N >> M >> K;
  G.resize(N);
  F.resize(N);
  B.resize(N);
  group.assign(N, INF);
  rep(i, M) {
    int a, b;
    cin >> a >> b;
    a--; b--;
    F[a].push_back(b);
    F[b].push_back(a);
  }
  rep(i, K) {
    int a, b;
    cin >> a >> b;
    a--; b--;
    B[a].push_back(b);
    B[b].push_back(a);
  }

  int color = 0;
  rep(i, N) {
    if (group[i] == INF) {
      group[i] = color;
      G[color].insert(i);
      dfs(i, color);
      color++;
    }
  }


  rep(i, N) {
    int gId = group[i];
    int remove = 1;
    rep(j, F[i].size()) {
      if (G[gId].count(F[i][j])) remove++;
    }
    rep(j, B[i].size()) {
      if (G[gId].count(B[i][j])) remove++;
    }

    if (i < N-1) cout << max(0, (int)G[gId].size()-remove) << " ";
    else cout << max(0, (int)G[gId].size()-remove) << endl;
  }



  return 0;
}


Measured memory_bytes: 22400
#include<iostream>
using namespace std;
int main(){
	int a, b;

	while (1){
		cin >> a >> b;
		if (a == 0 && b == 0){ break; }
		for (int i = 0; i < a; i++){
			for (int j = 0; j < b; j++){
				if (i % 2 == 0){
					if (j % 2 == 0){
						cout << "#";
					}
					else if (j % 2 == 1){
						cout << ".";
					}
					if (j == b - 1){
						cout << endl;
					}
				}
				else if (i % 2 == 1){
					if (j % 2 == 0){
						cout << ".";
					}
					else if (j % 2 == 1){
						cout << "#";
					}
					if (j == b - 1){
						cout << endl;
					}
				}
			}
		}
		cout << endl;
	}
	return 0;
}

Measured memory_bytes: 3072
fun main(args:Array<String>?) {
    readLine()!!.toInt()
    val cell = Array(2019) {false}
    val x = readLine()!!.split(" ").map { it.toInt() - 1 }.toMutableList()
    x.forEach { it -> cell[it] = true }
    readLine()!!.toInt()

    for (a in readLine()!!.split(" ").map { it.toInt() - 1 })
        if (x[a] != 2018 && !cell[x[a]+1]) {
            cell[x[a]] = false
            cell[++x[a]] = true
        }
    println(x.joinToString("\n"){ (it+1).toString() })
}


Measured memory_bytes: 27120
#include <stdio.h>

int tomatu(int iguti) {
	iguti = ((iguti >> 1) & 0x55555555) + (iguti & 0x55555555);
	iguti = ((iguti >> 2) & 0x33333333) + (iguti & 0x33333333);
	iguti = ((iguti >> 4) & 0x0F0F0F0F) + (iguti & 0x0F0F0F0F);
	iguti = ((iguti >> 8) & 0x00FF00FF) + (iguti & 0x00FF00FF);
	iguti = ((iguti >> 16) & 0x0000FFFF) + (iguti & 0x0000FFFF);
	return iguti;
}

int N;
int efu[128];
int P[128][11];

int main(void) {
	int i, j;
	int aoisyouta = 0;
	if (scanf("%d", &N) != 1) return 1;
	for (i = 0; i < N; i++) {
		int sumipe = 0;
		for (j = 0; j < 10; j++) {
			int F;
			if (scanf("%d", &F) != 1) return 1;
			if (F) sumipe |= (1 << j);
		}
		efu[i] = sumipe;
	}
	for (i = 0; i < N; i++) {
		for (j = 0; j <= 10; j++) {
			if (scanf("%d", &P[i][j]) != 1) return 1;
		}
	}
	for (i = 1; i < (1 << 10); i++) {
		int asumikana = 0;
		for (j = 0; j < N; j++) {
			asumikana += P[j][tomatu(i & efu[j])];
		}
		if (i == 1 || aoisyouta < asumikana) aoisyouta = asumikana;
	}
	printf("%d\n", aoisyouta);
	return 0;
}


Measured memory_bytes: 128
use std::f64;
use std::io::stdin;

fn main() {
    let mut s = String::new();
    stdin().read_line(&mut s).ok();
    let mut itr = s.split_whitespace().map(|e| e.parse().unwrap());
    let a: usize = itr.next().unwrap();
    let b = itr.next().unwrap();
    let h = itr.next().unwrap();
    let m = itr.next().unwrap();
    let mr = m as f64 * 2.0 * f64::consts::PI / 60.0;
    let hr = h as f64 * 2.0 * f64::consts::PI / 12.0 + m as f64 * f64::consts::PI / 360.0;
    let rad = (mr - hr).abs();
    let a = a as f64;
    let b = b as f64;

    println!(
        "{}",
        (a.powf(2.0) + b.powf(2.0) - 2.0 * a * b * rad.cos()).sqrt()
    );
}


Measured memory_bytes: 2988
#include<bits/stdc++.h>
#define ll long long
#define db long double
#define fi first
#define se second
#define  pb push_back
#define  pob pop_back
#define W while
#define fn(i,x) for(int i=0;i<x;i++)
#define fs(i,s,x) for(int i=s;i<x;i++)
#define fr(i,x) for(int i=x;i>=0;i--)
#define fit(it,s) for(auto it=s.begin();it!=s.end();it++)
#define mp make_pair
#define pii pair<int,int>
#define pll pair<ll,ll>
#define vii vector<int>
#define vll vector<ll>
#define mod 1000000007
#define MAX 1005
using namespace std;
int main()
{
   ios_base::sync_with_stdio(false);
   cin.tie(NULL);

    // freopen("in.txt","r",stdin);
    // freopen("out.txt","w",stdout);
    
    ll n,m;
    cin >> n >> m;
    vll a(n);
    fn(i,n) cin >> a[i];
    sort(a.begin(),a.end());

    pll g[m];
    fn(i,m) cin >> g[i].se >> g[i].fi;
    sort(g,g+m,greater<>());
    
    ll ch = 0;

    ll k = 0;
    fn(i,m){
       if(k>=n) break;
       if(a[k] > g[i].fi) break;
       ll cur = 0;
       while(k<n and a[k]<g[i].fi and cur<g[i].se){
           cur++;
           a[k] = g[i].fi;
           k++;
       }
    }
    fn(i,n){
      ch += a[i];
    }
    cout << ch;
    return 0;

}

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

#define REP(i, e) for(int (i) = 0; (i) < (e); ++(i))
#define FOR(i, b, e) for(int (i) = (b); (i) < (e); ++(i))
#define ALL(c) (c).begin(), (c).end()
#define ACC(c) (accumulate(ALL(c), 0LL))
#define PRINT(x) cout << (x) << "\n"

using namespace std;
using ll = long long;
using pint = pair<int, int>;
using pll = pair<ll, ll>;

inline int std_in(int& a) {return scanf("%d", &a);}
auto pint_compare = [](pint x, pint y) -> bool{return (x.first < y.first);};
const int MOD = 1000000007;


signed main(){
    int a;
    string s;
    cin >> a >> s;
    if(a >= 3200) PRINT(s);
    else PRINT("red");
    return 0;
}

Measured memory_bytes: 256
mod io{
    use std::io::*;
    pub fn read<T: ::std::str::FromStr>()->T{
        let stdin=stdin();
        let ret=stdin.lock().bytes().map(|c|c.unwrap()as char)
        .skip_while(|c|c.is_whitespace())
        .take_while(|c|!c.is_whitespace())
        .collect::<String>().parse().ok().unwrap();
        ret
    }
}
use io::read;
fn main(){
    let a=read::<i32>();
    println!("{}",a*800-a/15*200)
}

Measured memory_bytes: 4352
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
double ar[500009],br[500009];
map<ll,ll>mp;
vector<ll>v;
int main()
{
    ll a,b,c,i,j,k=0;
    double x,y,z,f,g,h;
    string s,d,e;
    cin>>a>>b;
    cout<<fixed<<setprecision(8);
    for(i=1; i<=a; i++)
    {
        cin>>h;
        ar[i]=(h+1)/2;
        br[i]=br[i-1]+ar[i];
    }
    f=0.0;
    for(i=1; i<=a; i++)
    {
        if(i+b-1<=a)
        {
            z=br[i+b-1]-br[i-1];
            if(z>f)
            {
                f=z;
                g=i;
            }
        }
    }
    cout<<f<<endl;
}


Measured memory_bytes: 5888
#include <bits/stdc++.h>
//#include "atcoder/all"
typedef long long int ll;
using namespace std;
// using namespace atcoder;
int main() {
    int n;
    cin >> n;
    ll a[n + 1], b[n + 1];
    ll suma = 0;
    ll sumb = 0;
    for (int i = 1; i <= n; i++) {
        cin >> a[i];
        suma += a[i];
    }
    for (int i = 1; i <= n; i++) {
        cin >> b[i];
        sumb += b[i];
    }
    ll k = sumb - suma;
    for (int i = 1; i <= n; i++) {
        if (b[i] - a[i] > 0) {
            k -= (b[i] - a[i] + 1) / 2;
        }
    }
    if (k < 0) {
        cout << "No" << endl;
    }
    else {
        cout << "Yes" << endl;
    }
    return 0;
}

Measured memory_bytes: 3792
#include <iostream>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cassert>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <fstream>

using namespace std;
#define TOSTRING(x) #x
#define SZ(x) (int)(x).size()
#define REP(i,n) for(int i=0;i<(n);i++)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define ALL(s) (s).begin(), (s).end()
#define so(V) sort(ALL(V))
#define rev(V) reverse(ALL(V))
#define uni(v) v.erase( unique(ALL(v)) , v.end());
#define PAU system("pause")

typedef long long unsigned int llu;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<vector <int> > vvi;
const int EPS = 1e-9;
const int MOD = 1e9 + 7;
const int INF = (1 << 30);
const double PI = acos(-1);

int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	int n,k;
	cin >> n >> k;
	if (n%k == 0)cout << 0 << endl;
	else cout << 1 << endl;
	PAU;
	return 0;
}


Measured memory_bytes: 892
#include <bits/stdc++.h>
#define rep(i, n) for(int i=0; i<n; ++i)
using namespace std;
int main() {
  int N; cin >> N;
  vector<int> p(N), r(N);
  rep(i,N) { cin>>p[i]; r[i] = p[i]; }
  sort(r.begin(), r.end());
  int cnt=0;
  rep(i,N-1) {
    if(p[i]!=r[i]) ++cnt;
  }
  if(cnt<=2) cout << "YES" << endl;
  else cout << "NO" << endl;
  return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
#define MAX 100
void Graph(int **);
void Clear();
void Jugde(int);

int A[MAX][MAX],JDGE[MAX],DWN[MAX],FLT[MAX];
int *B[MAX];
int N;
int time = 0;
int i,j;


//Aの初期化、出力
int main(){

  scanf("%d",&N);

  for(i = 0; i < N; i++){
    for(j = 0; j < N; j++){
      A[i][j] = 0;
    }
  }

  for(i = 0; i < N; i++){
    B[i] = A[i];
  }

  Graph(B);
  Clear();

  for(i = 0; i < N; i++){
    printf("%d %d %d\n",i+1,DWN[i],FLT[i]);
  }

  return 0;
}


//グラフ構築
void Graph(int **A){
  int u,k,v;

  for(i = 0; i < N; i++){
    scanf("%d%d",&u,&k);
    u--;
    for(j = 0; j< k; j++){
      scanf("%d",&v);
      v--;
      A[u][v] = 1;
    }
  }
}


//訪問判定配列の初期化
void Clear(){
  int a;
  for(a = 0; a < N; a++){
    JDGE[a] = 0;
  }

  for(a = 0; a < N; a++){
    if(JDGE[a] == 0) Judge(a);
  }

}


//探索、再帰
void Judge(int a){
  int b;
  JDGE[a] = 1;
  DWN[a] = ++time;
  for(b = 0; b < N; b++){
    if(A[a][b] == 0) continue;
    if(JDGE[b] == 0) Judge(b);
  }
  //JDGE[a] = 2;
  FLT[a] = ++time;
}

Measured memory_bytes: 636
#include <bits/stdc++.h>
using namespace std;
int main(){
  string s; cin >> s;
  int cntx = 0;
  for(int i = 0; i < s.length(); i++)if(s[i]=='x')cntx++;
  cout << (((15 - cntx)>=8) ? "YES" : "NO") << endl;
  return 0;
}

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

int main() {
    int k;
    cin >> k;
    vector<int> amari(k+1,0);
    ll now=7;
    ll cnt = 0;
    bool ans = false;
    REP(i,k){
        cnt++;
        now%=k;
        if(now==0){
            ans = true;
            break;
        }
        if(amari[now]!=0){
            break;
        }else{
            amari[now]++;
        }
        now = now * 10+7;
    }
    if(ans){
        cout << cnt << endl;
    }else{
        cout << "-1" << endl;
    }
}

Measured memory_bytes: 7216
#include <unistd.h>

char ibuf[(11<<18)+5];
char *ibufe = ibuf-1;

extern inline void readall(){
  int k, t = 0;
  while((k=read(STDIN_FILENO, ibuf+t, sizeof(ibuf)-t))>0) t += k;
}

int read_uint(){
  int x=0;
  while(*(++ibufe) <'0');
  do {
    x *= 10;
    x += *ibufe-'0';
  } while(*(++ibufe) >='0');

  return x;
}

char buf[40];
char *bufe = buf;

void write_uintln(int x){
  int i;
  static char tmp[13];
  if(x==0){
    *bufe++ = '0';
    *bufe++ = '\n';
    return;
  }

  for(i=0; x; i++){
    tmp[i] = '0' + x % 10;
    x /= 10;
  }
  for(i--; i >= 0; i--){
    *bufe++ = tmp[i];
  }
  *bufe++ = '\n';
}

extern inline void writeall(){
  int k, t = 0;
  while((k=write(STDOUT_FILENO, buf+t, bufe-buf-t))>0) t += k;
}


#define MAX(x, y) ((x) > (y) ? (x) : (y))

int n;
int A[2][1<<18];
int B[2][1<<18];

void zeta(int n){
  int i, j, b;
  const int m = 1 << (n-1);
  b = 0;
  for(i=0;i<n;i++){
    for(j=0;j<m;j++){
      A[b^1][(j<<1)] = A[b][j];
      B[b^1][(j<<1)] = B[b][j];
      A[b^1][(j<<1)^1] = MAX(A[b][j], A[b][j^m]);
      B[b^1][(j<<1)^1] = MAX(A[b^1][(j<<1)^1]^A[b][j]^A[b][j^m], MAX(B[b][j], B[b][j^m]));
    }
    b ^= 1;
  }
}


int main(){
  int i, max;
  readall();
  n = read_uint();
  for(i=0;i<(1<<n);i++){
    A[0][i] = read_uint();
  }
  zeta(n);
  max = 0;
  for(i=1;i<(1<<n);i++){
    max = MAX(max, A[n&1][i]+B[n&1][i]);
    write_uintln(max);
  }
  writeall();
  return 0;
}


Measured memory_bytes: 9856
#include <iostream>
#include <string>
#define llint long long
#define mod 1000000007

using namespace std;

string a, b, c;
llint next[505][10];
llint dp[2][505][3];
llint cnt[10000][505][3];

void count(string s)
{
	for(int i = 0; i <= s.size(); i++){
		for(int j = 0; j < c.size(); j++){
			for(int k = 0; k < 3; k++){
				cnt[i][j][k] = 0;
			}
		}
	}
	cnt[0][0][0] = 1;
	
	for(int i = 0; i < s.size(); i++){
		for(int j = 0; j < c.size(); j++){
			for(int k = 0; k < 3; k++){
				for(int l = 0; l < 10; l++){
					if(i == 0 && l == 0) continue;
					if(k == 0){
						int nk = 0;
						if(l > s[i] - '0') nk = 2;
						if(l < s[i] - '0') nk = 1;
						cnt[i+1][next[j][l]][nk] += cnt[i][j][0];
						cnt[i+1][next[j][l]][nk] %= mod;
					}
					else{
						cnt[i+1][next[j][l]][k] += cnt[i][j][k];
						cnt[i+1][next[j][l]][k] %= mod;
					}
				}
				
			}
		}
	}
}

llint calc(string s)
{
	if(s == "0") return c == "0";
	count(s);
	
	for(int i = 0; i < 2; i++){
		for(int j = 0; j < c.size(); j++){
			for(int k = 0; k < 3; k++){
				dp[i][j][k] = 0;
			}
		}
	}
	
	llint ret = 0;
	for(int i = 0; i < s.size(); i++){
		for(int j = 0; j < c.size(); j++){
			for(int k = 0; k < 3; k++){
				dp[(i+1)%2][j][k] = 0;
			}
		}
		for(int j = 0; j < c.size(); j++){
			for(int k = 0; k < 3; k++){
				for(int l = 0; l < 10; l++){
					if(i == 0 && l == 0) continue;
					int ac = 0;
					if(j == c.size()-1 && l == c[c.size()-1] - '0') ac = 1;
					if(k == 0){
						int nk = 0;
						if(l > s[i] - '0') nk = 2;
						if(l < s[i] - '0'){
							nk = 1;
						}
						dp[(i+1)%2][next[j][l]][nk] += dp[i%2][j][0] + ac * cnt[i][j][0];
						dp[(i+1)%2][next[j][l]][nk] %= mod;
					}
					else{
						dp[(i+1)%2][next[j][l]][k] += dp[i%2][j][k] + ac * cnt[i][j][k];
						dp[(i+1)%2][next[j][l]][k] %= mod;
					}
				}
			}
		}
		if(i != 0){
			for(int j = 0; j < c.size(); j++){
				for(int k = 0; k < 3; k++){
					ret += dp[i%2][j][k];
					ret %= mod;
				}
			}
		}
	}
	for(int j = 0; j < c.size(); j++){
		for(int k = 0; k < 2; k++){
			ret += dp[s.size()%2][j][k];
			ret %= mod;
		}
	}
	if(c == "0") ret++, ret %= mod;
	return ret;
}

int main(void)
{
	cin >> a >> b >> c;
	
	for(int i = 0; i < c.size(); i++){
		for(int j = 0; j < 10; j++){
			string s = c.substr(0, i) + (char)('0' + j);
			if(s.size() >= c.size()) s = s.substr(1);
			while(s != c.substr(0, s.size())) s = s.substr(1);
			next[i][j] = s.size();
		}
	}
	
	llint ans = calc(b);
	ans += mod - calc(a);
	ans %= mod;
	for(int i = 0; i <= (int)a.size() - (int)c.size(); i++){
		if(a.substr(i, c.size()) == c) ans++, ans %= mod;
	}
	cout << ans << endl;
	
	return 0;
}


Measured memory_bytes: 118552
const main = (input: void) => {
  const A: number = input.split(' ')[0];
  const B: number = input.split(' ')[1];

  if (A > 8 || B > 8 ) {
    console.log(":(");
  } else {
    console.log("Yay!");
  }
}

main(require('fs').readFileSync('/dev/stdin', 'utf8'));

Measured memory_bytes: 7372
#include <bits/stdc++.h>
using namespace std;
#define REP(i,a) for(int i = 0; i < (a); i++)
#define ALL(a) (a).begin(),(a).end()
typedef long long ll;
typedef pair<int, int> P;
const int INF = 1e9;
const int MOD = 1e9 + 7;

map<long long,int> prime_factor(long long n){
    map<long long,int> mp;
    for(int i = 2; (long long)i * i <= n; i++){
        while(n % i == 0){
            mp[i]++;
            n /= i;
        }
    }
    if(n != 1) mp[n]++;
    return mp;
}

signed main(){
    int n;
    cin >> n;
    map<ll, int> sum;
    for(int i = 1; i <= n; i++){
        map<ll, int> mp = prime_factor(i);
        for(auto i : mp){
            sum[i.first] += i.second;
        }
    }
    int cnt_2 = 0, cnt_4 = 0, cnt_14 = 0, cnt_24 = 0, cnt_74 = 0;
    for(auto i : sum){
        if(i.second >= 2){
            cnt_2++;
        }
        if(i.second >= 4){
            cnt_4++;
        }
        if(i.second >= 14){
            cnt_14++;
        }
        if(i.second >= 24){
            cnt_24++;
        }
        if(i.second >= 74){
            cnt_74++;
        }
    }
    int ans = 0;
    ans += max(0, cnt_4 * (cnt_4 - 1) / 2 * (cnt_2 - 2));
    ans += max(0, cnt_24 * (cnt_2 - 1));
    ans += max(0, cnt_14 * (cnt_4 - 1));
    ans += max(0, cnt_74);
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define mx 1000000
using namespace std;
typedef long long LL;
int arr[mx];

int main()
{
    int i, j, t, x, c = 0 , n;
    string a,b;
    cin>>a>>b;
    for(i = 0 ; i < a.size() ; i++)
    {
        if(a[i]!=b[i]) c++;
    }
    cout<<c<<endl;
    return 0;
}



Measured memory_bytes: 3856
import java.util.Scanner;

public class Main {
	
	public static void printArray(int[] A){
		for(int i=0; i<A.length-1; i++){
			System.out.print(A[i]+" ");
		}
		System.out.println(A[A.length-1]);
	}

    public static void insertionSort(int[] A){
        for(int i=1; i<A.length; i++){
            int key = A[i];
            int j = i-1;
            while(j>-1 && A[j]>key){
                A[j+1]=A[j];
                j--;
            }
            A[j+1]=key;
            printArray(A);
        }
        
    }

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

		int n = scan.nextInt();
		int[] A = new int[n];
		for(int i=0; i<n; i++){
			A[i] = scan.nextInt();
		}

		scan.close();
		
		printArray(A);
		insertionSort(A);

	}
}


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

const int maxn = 1e5+5;
long long x;
inline long long f(long long p){
	long long g = p*p;
	return g*g*p;	
}
int main(){
	cin >> x;
	for (long long a=1;a*a*a*a<=x;a++){
		for (long long b=(-1)*a;b<a;b++){
			if (f(a)-f(b)==x){
				cout << a << ' ' << b;
				return 0;
			}
		}
	}
	return 0;
}

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

using namespace std;

const int maxn = 1e6 + 5;

typedef long long ll;
vector <int> v;
bool vis[maxn];

int main() {
	int k;
	cin >> k;
	int cnt = 0;
	int i , flag = 0;
	for(i = 0 ; !flag ; i++) {
		if(vis[cnt]) {
			flag = 1;
			break;
		}
		vis[cnt] = 1;
		cnt = cnt * 10 + 7;
		cnt %= k;
	}
	
	if(!cnt)cout << i << "\n";
	else cout << -1 << "\n";
	return 0;
}

Measured memory_bytes: 4528
using System;
using System.Text;
using System.Collections.Generic;
using System.Linq;
class Solve{
    public Solve(){}
    StringBuilder sb;
    public static int Main(){
        new Solve().Run();
        return 0;
    }
    void Run(){
        sb = new StringBuilder();
        Calc();
        Console.Write(sb.ToString());
    }
    void Calc(){
        string s = Console.ReadLine();
        int count = 0;
        while(true){
            for(int i=0;i<26;i++){
                bool c = true;
                for(int j=0;j<s.Length-count;j++){
                    bool b = false;
                    for(int k=0;k<=count;k++){
                        b |= (s[k+j]-'a') == i;
                    }
                    c &= b;
                }
                if(c){
                    sb.Append(count+"\n");
                    return;
                }
            }
            count++;
        }
    }
}

Measured memory_bytes: 11092
#include <bits/stdc++.h>
#include <iomanip>
using namespace std;
#define reps(i,s,n) for(int i = s; i < n; i++)
#define rep(i,n) reps(i,0,n)
#define Rreps(i,n,e) for(int i = n - 1; i >= e; --i)
#define Rrep(i,n) Rreps(i,n,0)
#define ALL(a) a.begin(), a.end()
#define fi first
#define se second
typedef long long ll;
typedef vector<ll> vec;
typedef vector<vec> mat;

ll N,M,H,W,K,Q,A,B;
string S;
//const ll MOD = 998244353;
const ll MOD = (1e+9) + 7;
const ll INF = 2e+9 + 10;
typedef pair<ll, ll> P;

int main() {
    cin>>N>>K>>A>>B;
    if(N >= K) M = K * A + (N - K) * B;
    else M = N * A;
    cout<<M<<endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <string>
#include <cmath>
#include <stack>
#include <vector>
#include <queue>
#include <random>
#include <cstdint>
#include <bitset>
#include <iomanip>
#include <utility>
#include<map>
#include<functional>
using namespace std;
using ll = long long;
const int mod = 10000007;

int main() {
	ll n, p,ans=1;
	cin >> n >> p;
	ll memo = p;
	if (n == 1) {
		cout << p << endl;
		return 0;
	}
	for (ll i = 2; i <= sqrt(memo); i++) {
		ll count = 0;
		while (p%i == 0) {
			p /= i;
			count++;
		}

		for (ll j = 0; j < (count / n); j++) {
			ans *= i;
		}
	}
	cout << ans << endl;
}


Measured memory_bytes: 256
from collections import Counter
    
n = int(input())
v = list(map(int, input().split()))

a = Counter(v[0::2]).most_common()
b = Counter(v[1::2]).most_common()
a.append([0,0])
b.append([0,0])
if a[0][0] != b[0][0]:
    print(n - (a[0][1] + b[0][1]))
else:
    print(min(n-(a[1][1]+b[0][1]), n-(a[0][1]+b[1][1])))


Measured memory_bytes: 20572
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using ll = long long;
ll GetDigit(ll num){ return log10(num)+1; } //numの桁数を求める

int main()
{
    int n;
    string s;
    cin >> n;
    cin >> s;
    int ans;
    int r = 0,w = 0;
    rep(i,n){
        if(s[i] == 'W') w++;
        else r++;
    }
    if(w == 0 || r == 0){
        cout << 0 << endl;
        return 0;
    }
    int ansr = 0;
    rep(i,r){
        if(s[i] == 'W') ansr++;
    }
    rep(i,n-1){
        if(s[i] == 'W' && s[i+1] == 'R'){
            s[i+1] = 'W';
            ans++;
        }
    }

    cout << min(ans,ansr) << endl;
    return 0;
}

Measured memory_bytes: 3716
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define FOR(i, a, n) for (ll i = (ll)a; i < (ll)n; i++)
#define RFOR(i, a, n) for (ll i = (ll)n - 1; i >= (ll)a; i--)
#define rep(i, n) FOR(i, 0, n)
#define rrep(i, n) RFOR(i, 0, n)
#define ALL(v) v.begin(), v.end()
#define bra(first, second) '(' << first << ',' << second << ')'
constexpr ll MOD = 1000000007;
//constexpr ll MOD = 998244353;
ll INF = 1001001001001001001;
long double EPS = 1e-9;
long double PI = 3.141592653589793238;
template <typename T>
void remove(std::vector<T> &vector, unsigned int index)
{
   vector.erase(vector.begin() + index);
}

using Graph = vector<vector<tuple<ll, ll, ll>>>;

// MOD確認

ll N;
string X;

ll A[200010];
ll B[200010];

int main(){
   cin >> N >> X;
   ll cnt = 0;
   rep(i,N) if(X[i] == '1') cnt++;
   ll MODA = cnt + 1,MODB = cnt - 1;
   if(cnt == 0){
      rep(i,N) cout << 1 << endl;
      return 0;
   }
   if(MODB == 0){
      rep(i,N){
         if(X[i] == '1') cout << 0 << endl;
         else{
            if(X.back() == '0' && i != N-1) cout << 1 << endl;
            else cout << 2 << endl;
         }
      }

      return 0;

   }
   if(MODA != 1) A[0] = 1;
   if(MODB != 1) B[0] = 1;
   ll sumA = 0,sumB = 0;
   rep(i,N){
      A[i+1] = A[i] * 2;
      A[i+1] %= MODA;
   }
   rep(i,N){
      B[i+1] = B[i] * 2;
      B[i+1] %= MODB;
   }

   rep(i,N) if(X[i] == '1') sumA += A[N-i-1];
   rep(i,N) if(X[i] == '1') sumB += B[N-i-1];
   sumA %= MODA;
   sumB %= MODB;

   /*rep(i,N) cout << A[i] << ' ';
   cout << endl;
   rep(i,N) cout << B[i] << ' ';
   cout << endl;
   cout << MODA << ' ' << MODB << endl;
   cout << sumA << ' ' << sumB << endl;*/
   rep(i,N){
      ll n = 0;
      ll num = 0;
      if(X[i] == '0'){
         num = MODA;
         n = sumA + A[N-i-1];
      }else{
         num = MODB;
         n = sumB - B[N-i-1];
         while(n < 0) n += num * 10000000LL;
      }
      n %= num;
      ll ans = 1;
      while(n){
         ans++;
         n %= __builtin_popcount(n);
      }
      cout << ans << endl;
   }

}

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

d = {}
for a in A:
    if a not in d:
        d[a] = 1
    else:
        d[a] += 1
tmp_sum = sum(A)


for _ in range(Q):
    b, c = list(map(int, input().split()))
    if b in d:
        b_cnt = d[b]
    else:
        b_cnt = 0

    d[b] = 0
    if c in d:
        d[c] += b_cnt
    else:
        d[c] = b_cnt

    sum_diff = (c - b) * b_cnt
    tmp_sum += sum_diff
    print(tmp_sum)


Measured memory_bytes: 88480
def main():
    n = input()
    S = input()
    cnt_r = 0
    cnt_b = 0
    for s in S:
        if s == 'R':
            cnt_r += 1
        elif s == 'B':
            cnt_b += 1
    if cnt_r > cnt_b:
        print('Yes')
    else:
        print('No')

main()

Measured memory_bytes: 2940
x,y=map(int,input().split())
if x+y==0:print(1)
elif x*y>0:
  if x<y:print(y-x)
  else:print(x-y+2)
elif x*y==0:
  if x>y:print(abs(x+y)+1)
  else:print(abs(x+y))
else:print(abs(x+y)+1)

Measured memory_bytes: 3064
#include <vector>
#include <queue>
#include <algorithm>
#include <iostream>
#include <string>
#include <tuple>
#include <set>
#include <map>
#include <complex>
#include <iomanip>
#include <cmath>
using namespace std;
typedef long long ll;

ll extraFactorial(ll n, ll a)
{
  if (n == 1) return 1;
  ll ans;
  ans = n * extraFactorial(n - 1, a) % a;
  return ans;
}

int main()
{
  ll n, m;
  cin >> n >> m;
  ll a = 1000000007, ans;
  if (n == m) ans = (extraFactorial(n, a) * extraFactorial(m, a)) % a * 2 % a;
  else if (abs(n - m) == 1) ans = (extraFactorial(n, a) * extraFactorial(m, a)) % a;
  else ans = 0;
  cout << ans << endl;
}


Measured memory_bytes: 3328
#include <iostream>

using namespace std;

int main() {
	int h[100000];
	int n;
	
	cin >> n;
	for(int i = 0; i < n; i++) cin >> h[i];
	
	int high = 0;
	int cur = 0;
	for(int i = n - 1;i > 0; --i)
	{
		if (h[i] <= h[i-1]) {
			cur++;
		} else {
			high = max(high, cur);
			cur = 0;
		}
	}
	high = max(high, cur);
	
	cout << high << endl;
}

Measured memory_bytes: 640