akhauriyash/Code-Regression huggingface dataset:
import sys
import math  # noqa
import bisect  # noqa
import queue  # noqa


def input():
    return sys.stdin.readline().rstrip()


def main():
    N, A, B = map(int, input().split())

    MOD = 10 ** 9 + 7
    factinv = [1, 1]  # factinv[n] = ((n!)^(-1) mod p)
    inv = [0, 1]  # for factinv calcuration
    for i in range(2, B + 1):
        inv.append((-inv[MOD % i] * (MOD // i)) % MOD)
        factinv.append((factinv[-1] * inv[-1]) % MOD)

    res = 2 ** N - 1
    res %= MOD

    a = 1
    r = min(N - A, A)
    for i in range(N, N - r, -1):
        a *= i
        a %= MOD
    a = a * factinv[r] % MOD

    b = 1
    r = min(N - B, B)
    for i in range(N, N - r, -1):
        b *= i
        b %= MOD
    b = b * factinv[r] % MOD

    res -= a
    res -= b
    res %= MOD
    print(res)


if __name__ == '__main__':
    main()


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

int main(){
    int n; cin >> n;
    vector<int> a(n+1),b(n+1),c(n);
    rep(i,n) cin >> a[i];
    rep(i,n) cin >> b[i+1];
    rep(i,n-1) cin >> c[i+1];
    int ans = b[a[0]];
    rep(i,n-1){
        ans += b[a[i+1]];
        if(a[i]+1 == a[i+1]) ans += c[a[i]];
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<bool> vb;
typedef vector<string> vs;
typedef vector<ll> vl;
typedef vector<vector<int, int> > vvi;
#define pb push_back
#define mp make_pair
#define f first
#define s second
#define in insert
#define FOR(i,a,b) for (int i = a; i < b; i++)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define speed ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
const int INF = 1e9 + 5;
int main(){
    int a, b, h;
    cin >> a >> b >> h;
    cout << ((a+b)*h)/2;
}   

Measured memory_bytes: 256
import java.util.*

fun main(args: Array<String>) {
    val scan = Scanner(System.`in`)
    var arr = scan.nextLine().split(" ").map{ it.trim().toInt() }.toTypedArray()
    var a =arr[0]
    var b =arr[1]
    var c =arr[2]
    var d =arr[3]
    var vari = 1
    while(a>0 && c>0)
    {
        if(vari==1)
        {
            c-=b
            vari=2
        }
        else
        {
            a-=d
            vari=1
        }
    }
   // println("$a $c ")
    if(c<1)
        println("Yes")
    else
        println("No")
}


Measured memory_bytes: 38260
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String next = sc.next();
        if(next.charAt(next.length() - 1) == 's'){
            System.out.println(next + "es");
        }else {
            System.out.println(next + "s");
        }
    }
}


Measured memory_bytes: 38444
#include <stdio.h>
   
int main()
{
    int n;
   
    scanf("%d", &n);
    int i;
    for (i = 3; i <= n; i++) {
        int tmp = i;
        if (tmp % 3 == 0) {
            printf(" %d", i);
        } else {
            while (tmp > 0) {
                if (tmp % 10 == 3) {
                    printf(" %d", i);
                    break;
                }
                tmp /= 10;
            }
        }
    }
    putchar('\n');
   
    return 0;
}

Measured memory_bytes: 600
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <utility>
#include <tuple>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <cmath>
#include <iomanip>
#include <cassert>
#define REP(i, n) for (int i = 0; i < (n); ++i)
#define ALL(x) (x).begin(), (x).end()
#define SZ(x) (int)(x).size()
using namespace std;
using ll = long long;
constexpr ll INF = 3000000000000000000;

int main() {
    int N;
    cin >> N;
    cout << (N + 999) / 1000 * 1000 - N << "\n";
    return 0;
}


Measured memory_bytes: 3628
# include <bits/stdc++.h>
# define ll long long
using namespace std;
const ll oo = 1e15, N = 2e5 + 10;
int f[N];
int main(){
	ios::sync_with_stdio(0);
	cin.tie(0); cout.tie(0);
	int n, k;
	cin >> n >> k;
	for(int i = 1; i <= k; ++i){
		int d;
		cin >> d;
		while(d--){
			int x;
			cin >> x;
			if(f[x] == 0)n--;
			f[x] = 1;
		}
	}
	cout << n << '\n';
}

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

ll N;
vector<vector<int>> v(200010);
int vis[200010] = {};

ll dfs(int n,set<int>& sx,set<int>& sy){
    ll cnt = 0;
    vis[n] = 1;
    if(n<=100000) sx.insert(n);
    else sy.insert(n);
    for(auto x:v[n]){
        cnt++;
        if(vis[x]==0) cnt += dfs(x,sx,sy);
    }
    return cnt;
}

int main(){
    cin >> N;
    int x,y;
    for(int i=0;i<N;i++){
        cin >> x >> y;
        v[x].push_back(y+100000);
        v[y+100000].push_back(x);
    }
    ll ans = 0;
    for(int i=1;i<=100000;i++){
        if((int) v[i].size()!=0 && vis[i]==0){
            set<int> sx,sy;
            ll n = dfs(i,sx,sy)/2;
            ll cx = sx.size(),cy = sy.size();
            ans += cx*cy-n;
        }
    }
    cout << ans << endl;
}

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

int main(void){
    int v[3];
    rep(i,3) cin >> v[i];
    sort(v,v+3);
    cout<<((v[0] == 5 && v[1] == 5 && v[2] == 7) ? "YES" : "NO")<<endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include<cmath>
using namespace std;
int main(void){
    int N,T,A;
    cin>>N>>T>>A;
    int H[N];
    int I;
    
    double O,P,Q;
    P=100000;
    for(int i=0;i<N;i++){
        cin>>H[i];
        Q=T-H[i]*0.006;
        O=abs(Q-A);
       
        if(O<P){
            P=O;
            I=i+1;
        }
        
    }
    cout<<I<<endl;
    
    
    return 0;
    
}

Measured memory_bytes: 256
#include <stdio.h>

int main(void) {
  FILE *fp;
  fp = stdin;
  char line[10];
  if(!fgets(line, 10, fp)) return 0;
  int num;
  sscanf(line, "%d", &num);
  int flag = num>28;
  num %= 28;
  int map[] = {
    1, 0, 0, 0, 1, // 4
       0, 0, 1, 1, // 8
       0, 0, 1, 1, // 12
       0, 1, 1, 1, // 16
       0, 1, 1, 1, // 20
       1, 1, 1, 1, // 24
       1, 1, 1
  };
  printf("%s\n", (map[num] || flag) ? "Yes" : "No");
  return 0;
}

Measured memory_bytes: 128
/**
     *    author:  shashank_hire
    **/
#include <bits/stdc++.h>
using namespace std;
#define IOS                  \
    ios::sync_with_stdio(0); \
    cin.tie(0);              \
    cout.tie(0);
#define ll long long
#define ld long double
#define MOD 1000000007

// A C++ program for Dijkstra's single source shortest path algorithm. 
// The program is for adjacency matrix representation of the graph 
 
// #include <limits.h> 
// #include <stdio.h>

// Number of vertices in the graph 
ll V;

// A utility function to find the vertex with minimum distance value, from 
// the set of vertices not yet included in shortest path tree 
int minDistance(int dist[], bool sptSet[]) 
{ 
	// Initialize min value 
	int min = INT_MAX, min_index; 

	for (int v = 0; v < V; v++) 
		if (sptSet[v] == false && dist[v] <= min) 
			min = dist[v], min_index = v; 

	return min_index; 
} 

// A utility function to print the constructed distance array 
int printSolution(int dist[]) 
{ 
	// printf("Vertex \t\t Distance from Source\n"); 
	// for (int i = 0; i < V; i++) 
	// 	printf("%d \t\t %d\n", i, dist[i]); 
    if(dist[V-1]==2147483647)
        cout<<"-1\n";
    else
    cout<<dist[V-1]<<"\n";
} 

// Function that implements Dijkstra's single source shortest path algorithm 
// for a graph represented using adjacency matrix representation 
void dijkstra(int graph[1001][1001], int src) 
{ 
	int dist[V]; // The output array. dist[i] will hold the shortest 
	// distance from src to i 

	bool sptSet[V]; // sptSet[i] will be true if vertex i is included in shortest 
	// path tree or shortest distance from src to i is finalized 

	// Initialize all distances as INFINITE and stpSet[] as false 
	for (int i = 0; i < V; i++) 
		dist[i] = INT_MAX, sptSet[i] = false; 

	// Distance of source vertex from itself is always 0 
	dist[src] = 0; 

	// Find shortest path for all vertices 
	for (int count = 0; count < V - 1; count++) { 
		// Pick the minimum distance vertex from the set of vertices not 
		// yet processed. u is always equal to src in the first iteration. 
		int u = minDistance(dist, sptSet); 

		// Mark the picked vertex as processed 
		sptSet[u] = true; 

		// Update dist value of the adjacent vertices of the picked vertex. 
		for (int v = 0; v < V; v++) 

			// Update dist[v] only if is not in sptSet, there is an edge from 
			// u to v, and total weight of path from src to v through u is 
			// smaller than current value of dist[v] 
			if (!sptSet[v] && graph[u][v] && dist[u] != INT_MAX 
				&& dist[u] + graph[u][v] < dist[v]) 
				dist[v] = dist[u] + graph[u][v]; 
	} 

	// print the constructed distance array 
	printSolution(dist); 
}

int main()
{
	ll n, k, i;
	cin>>n>>k;
	vector<ll> h(n);
	for(i=0;i<n;i++)
		cin>>h[i];
	sort(h.begin(), h.end());
	cout<<accumulate(h.begin(), h.begin() + (ll)max(0LL, n - k), 0LL)<<"\n";
    return 0;
}

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

using namespace std;

typedef long long ll;
typedef unsigned long long ull; 
typedef vector<int> vi;
typedef pair<int,int> pi;

#define F first
#define S second
#define PB push_back
#define MP make_pair
#define FOR(i,a,b) for (int i = a; i < b; i++)
#define SQ(a) (a)*(a)

template <class T, class U> ostream& operator<< (ostream &out, pair<T,U> c) { out << "(" << c.first << " "; out << c.second << ")"; return out; }
template <class T> ostream& operator<< (ostream &out, vector<T> c) { for (auto it = c.begin(); it != c.end(); ++it) { if (it != c.begin()) out << " "; out << *it; } return out; }
template <class T> ostream& operator<< (ostream &out, set<T> c) { for (auto it = c.begin(); it != c.end(); ++it) { if (it != c.begin()) out << " "; out << *it; } return out; }
const double PI  = 3.141592653589793238463;


int main() {
    ios::sync_with_stdio(0);
    cin.tie(0);
    int t, a = 0, b = 0;
    cin >> t;
    vi v(t);
    FOR(i,0,t){
        cin >> v[i];
    }
    sort(v.begin(),v.end(),greater<int>());
    FOR(i,0,t){
        if(i%2 == 0){
            a += v[i];
        }
        else
        {
            b += v[i];
        }
    }
    cout << a - b << endl;
}

Measured memory_bytes: 256
#include <algorithm>
#include <array>
#include <bitset>
#include <complex>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <set>
#include <stack>
#include <unordered_map>
#include <unordered_set>
#include <queue>

using namespace std;

struct BoolName : numpunct<char> {
  string t, f;
  BoolName (string t = "Yes", string f = "No") : t(t), f(f) {}
  string do_truename() const {return t;}
  string do_falsename() const {return f;}
};

struct Initializer {
  Initializer() {
    cin.tie(0);
    ios::sync_with_stdio(0);
    cout << fixed << setprecision(15) << boolalpha;
    cout.imbue(locale(cout.getloc(), new BoolName));
  }
} initializer;

template<typename T> istream& operator>>(istream &s, vector<T> &v) {
  for (T &t : v) s >> t;
  return s;
}

template<typename T> ostream& operator<<(ostream &s, const vector<T> &v) {
  for (const T &t : v) s << t << endl;
  return s;
}

void set_bool_name(string t, string f) {
  cout.imbue(locale(cout.getloc(), new BoolName(t, f)));
}

int main() {
  int n, m;
  cin >> n >> m;
  cout << (n - 1) * (m - 1) << endl;
}



Measured memory_bytes: 256
#include<cstdio>  
#include<iostream>  
#include<algorithm>  
#include<cstdlib>  
#include<cstring>
#include<string>
#include<climits>
#include<vector>
#include<cmath>
#include<map>
#include<set>
#include<queue>
#include<ctime>
#define LL long long
#define inf 0x3f3f3f3f

using namespace std;
  
inline char nc(){
    /* 
  static char buf[100000],*p1=buf,*p2=buf;
  if (p1==p2) { p2=(p1=buf)+fread(buf,1,100000,stdin); if (p1==p2) return EOF; }
  return *p1++;
    */return getchar();
}
  
inline void read(int &x){
  char c=nc();int b=1;
  for (;!(c>='0' && c<='9');c=nc()) if (c=='-') b=-1;
  for (x=0;c>='0' && c<='9';x=x*10+c-'0',c=nc()); x*=b;
}
  
inline void read(LL &x){
  char c=nc();LL b=1;
  for (;!(c>='0' && c<='9');c=nc()) if (c=='-') b=-1;
  for (x=0;c>='0' && c<='9';x=x*10+c-'0',c=nc()); x*=b;
}
 
inline int read(char *s)
{
    char c=nc();int len=1;
    for(;!(c=='.'||c=='#');c=nc()) if (c==EOF) return 0;
    for(;(c=='.'||c=='#');s[len++]=c,c=nc());
    s[len++]='\0';
    return len-2;
}
 
inline void read(char &x){
  for (x=nc();!(x>='0' && x<='1');x=nc());
}
 
int wt,ss[19];
inline void print(int x){
    if (x<0) x=-x,putchar('-'); 
    if (!x) putchar(48); else {
    for (wt=0;x;ss[++wt]=x%10,x/=10);
    for (;wt;putchar(ss[wt]+48),wt--);}
}
inline void print(LL x){
    if (x<0) x=-x,putchar('-');
    if (!x) putchar(48); else {for (wt=0;x;ss[++wt]=x%10,x/=10);for (;wt;putchar(ss[wt]+48),wt--);}
}

int n,a[20010],b[20010];

int main()
{
    read(n);
    int x=1;
    for (int i=1;i<=n;i++)
        a[i]=x,x+=n;
    x=1;
    for (int i=n;i>=1;i--)
        b[i]=x,x+=n;
    for (int i=1;i<=n;i++)
        read(x),b[x]+=i-1;
    for (int i=1;i<n;i++)
        print(a[i]),putchar(' ');
    print(a[n]),puts("");
    for (int i=1;i<n;i++)
        print(b[i]),putchar(' ');
    print(b[n]),puts("");
    return 0;
}

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

typedef long long ll;
typedef pair<int, int> P;
typedef pair<int, P> P1;
typedef pair<P, P> P2;
#define pu push
#define pb push_back
#define mp make_pair
#define eps 1e-7
#define INF 1000000000
#define fi first
#define sc second
#define rep(i, x) for (long long i = 0; i < x; i++)
#define repn(i, x) for (long long i = 1; i <= x; i++)
#define SORT(x) sort(x.begin(), x.end())
#define ERASE(x) x.erase(unique(x.begin(), x.end()), x.end())
#define POSL(x, v) (lower_bound(x.begin(), x.end(), v) - x.begin())
#define POSU(x, v) (upper_bound(x.begin(), x.end(), v) - x.begin())
vector<pair<string, P> > vec;
// vector<vector<int>> data(3, vector<int>(4));

long long N;
ll res = 0;

void dfs(ll A) {
    if (A > N) return;
    dfs(A * 10 + 3);
    dfs(A * 10 + 5);
    dfs(A * 10 + 7);
    map<ll, ll> m;
    while (A > 0) {
        m[A % 10]++;
        A /= 10;
    }
    if (m[3] > 0 && m[5] > 0 && m[7] > 0) res++;
}

int main() {
    scanf("%lld", &N);
    dfs(0);
    cout << res << endl;
    return 0;
}


Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Runtime.CompilerServices;
using System.Text;
using static System.Console;
using static System.Math;

namespace Atcoder
{
    class Program
    {
        static StreamWriter sw = new StreamWriter(OpenStandardOutput()) { AutoFlush = false };
        static void Main(string[] args)
        {
            try
            {
                SetOut(sw);
                Solve.Answer();
                Out.Flush();
            }
            catch (Exception ex)
            {
                WriteLine(ex.ToString());
            }
        }
    }

    public class Solve
    {
        public static void Answer()
        {
            var xy = IO.RSLong;

            long now = xy[0];
            int cnt = 0;
            while (now <= xy[1])
            {
                now *= 2;
                cnt++;
            }
            WriteLine(cnt);
        }
    }

    public class IO
    {
        #region Input
        public static int RInt => int.Parse(ReadLine());
        public static long RLong => long.Parse(ReadLine());
        public static double RDouble => double.Parse(ReadLine());

        public static string[] RSString => ReadLine().Split();
        public static int[] RSInt => ReadLine().Split().Select(s => int.Parse(s)).ToArray();
        public static long[] RSLong => ReadLine().Split().Select(s => long.Parse(s)).ToArray();
        public static double[] RSDouble => ReadLine().Split().Select(s => double.Parse(s)).ToArray();
        #endregion

        #region Output
        public static void OutJoinSpace<T>(IEnumerable<T> list) => WriteLine(string.Join(" ", list));
        public static void WriteLineYes_or_No(bool flag) => WriteLine(flag ? "Yes" : "No");
        public static void WriteLineYES_or_NO(bool flag) => WriteLine(flag ? "YES" : "NO");
        #endregion
    }

    public class Mod
    {
        #region
        private readonly static long M = 1000000007;

        public static long Add(long a, long b) => (a * b) % M;
        public static long Sub(long a, long b) => (a - b) % M >= 0 ? (a - b) % M : (a - b) % M + M;
        public static long Multi(long a, long b) => (a * b) % M;
        #endregion
    }
}

Measured memory_bytes: 13396
c1 = list(input())
c2 = list(input())
c2_alta = [0 for i in range(3)]
c2_alta[0] = c2[-1]
c2_alta[1] = c2[1]
c2_alta[-1] = c2[0]
if c1 == c2_alta:
  print("YES")
else:
  print("NO")

Measured memory_bytes: 3060
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<queue>
#include<cmath>
#include<iostream>
#include<cstring>
using namespace std;
long double a,b;

int main()
{
    scanf("%Lf %Lf",&a,&b);
    long long ans=(long long)floor(a*b);
    printf("%lld",ans);
    return 0;
}

Measured memory_bytes: 3824
n, m, x = map(int, input().split())
c = []
a = []
for _ in range(n):
    price, *ary = list(map(int, input().split()))
    c.append(price)
    a.append(ary)


def solve(flags):
    global m, c, a
    points = [0] * m
    price = 0
    for i, f in enumerate(flags):
        if f == 1:
            price += c[i]
            for j in range(m):
                points[j] += a[i][j]
    cleared = list(filter(lambda p: p >= x, points))
    return price if len(cleared) == m else -1

answer = -1
for i in range(2 ** n):
    flags = list(map(int, list(bin(i)[2:].zfill(n))))
    result = solve(flags)
    if result > 0:
        if answer == -1:
            answer = result
        else:
            answer = min(result, answer)

print(answer)


Measured memory_bytes: 9232
import scala.io.StdIn._
object Main {
	def main(args :Array[String]) = {
		var mtrl = readf("{0} {1} {2}")
		val Buff =  mtrl.map(_.toString.toInt)
		if (Buff(0) < Buff(1)){
			if (Buff(1) < Buff(2)) println("Yes")
			else println("No")
		}
		else println("No")
	}
}

Measured memory_bytes: 43524
/*** author: yuji9511 ***/
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using lpair = pair<ll, ll>;
const ll MOD = 1e9+7;
const ll INF = 1e18;
#define rep(i,m,n) for(ll i=(m);i<(n);i++)
#define rrep(i,m,n) for(ll i=(m);i>=(n);i--)
#define printa(x,n) for(ll i=0;i<n;i++){cout<<(x[i])<<" \n"[i==n-1];};
void print() {}
template <class H,class... T>
void print(H&& h, T&&... t){cout<<h<<" \n"[sizeof...(t)==0];print(forward<T>(t)...);}

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll N,K,S;
    cin >> N >> K >> S;
    ll ans[100010] = {};
    rep(i,0,K) ans[i] = S;
    rep(i,K,N){
        if(S == 1000000000){
            ans[i] = 1;
        }else{
            ans[i] = 1000000000;
        }
    }
    printa(ans, N);


    

}

Measured memory_bytes: 2176
#include<bits/stdc++.h>
#define fastIO ios::sync_with_stdio(false);cin.tie(0);
#define ll long long
#define f(i, l, r) for(i = l; i < r; i++)
#define fd(i, l, r) for(i = l; i > r; i--)
#define mod 1000000007
#define pb push_back
using namespace std;
typedef pair <int, int> pi;

int main(){
	fastIO
    int test = 1;
    // cin >> test;
    while(test--){
        int n,k; cin >> n >> k;
        int i, j, arr_h[n];
        f(i,0,n) cin >> arr_h[i];
        int cost[n];
        f(i,0,n) cost[i] = INT_MAX;
        cost[0] = 0;
        f(i,1,min(k+1, n)){
            cost[i] = abs(arr_h[i] - arr_h[0]);
        }
        int mini, temp;
        f(i,2,n){
            // cout << "HI";
            mini = INT_MAX;
            f(j,1,k+1){
                if(i-j < 1) break;
                temp = cost[i-j] + abs(arr_h[i] - arr_h[i-j]);
                if(mini > temp) mini = temp;
            }
            cost[i] = min(cost[i], mini);
        }
        cout << cost[n-1];
    }
    return 0;
}


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

 int main()
 {
    int n;
    scanf("%d",&n);
    int t[n];
    for (int i=0;i<n;i++)
    {
        int a;
        scanf("%d",&a);
        t[a-1]=i+1;
    }
    for (int i=0;i<n;i++)
        printf("%d ",t[i]);

 }


Measured memory_bytes: 1152
#pragma GCC optimize("O3")
#include<bits/stdc++.h>

using namespace std;
typedef long long ll;

#define REP(i,n) for(ll i=0;i<ll(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=a;i<ll(b);i++)
#define FORD(i,a,b) for(ll i=a;i>ll(b);i--)
#define ALL(x) x.begin(),x.end() 
#define SIZE(x) ll(x.size()) 
#define INF 1000000000000 
#define MOD 1000000007 
#define MAXR 100000 
#define PB push_back 
#define MP make_pair 
#define F first 
#define S second 
#define Umap unordered_map
#define Uset unordered_set


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

    ll N, D;
    cin >> N >> D;

    int ans = 0;
    REP(i, N) {
        ll X, Y;
        cin >> X >> Y;

        if (X*X + Y*Y <= D*D) {
            ans++;
        } 
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 3640
import java.util.*;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int N = sc.nextInt();
    long ans = 1;
    for(int i = 2; i <= N; i++) {
      if(isPrime(i)) {
        long power = 0;
        for(int j = 1; j < 10; j++) {
          if(N >= Math.pow(i, j)) {
            power += (long)(N / Math.pow(i, j));
          } else {
            break;
          }
        }
        ans = (ans * (power + 1)) % 1000000007;
      }
    }
    System.out.println(ans);
  }

  public static boolean isPrime(int n) {
    boolean flg = true;
    for(int i = 2; i * i <= n; i++) {
      if(n % i == 0) flg = false;
    }
    return flg;
  }
}

Measured memory_bytes: 21844
# coding: utf-8
# Your code here!
h=int(input())
w=int(input())
N=int(input())
m=max(h,w)
n=min(h,w)
cnt=0
for i in range(n):
    cnt+=1
    N-=m
    if N<=0:
        break
if N>0:
    for i in range(m):
        cnt+=1
        M-=n
        if N<=0:
            break
print(cnt)

Measured memory_bytes: 38736
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <iomanip>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)   FOR(i,0,n)
#define ALL(obj) (obj).begin(), (obj).end()

#define PI 3.14159265359

using namespace std;
typedef long long unsigned int ll;

int main() {
	int n,m;
	cin >> n >> m;
	if (n == m)cout << "Yes";
	else cout << "No";
}

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

using namespace std;

typedef pair<int,int>P;

const int DAT_SIZE = (1 << 18) - 1;	//10^5?¨????

const int MAX_N = 100000;
const int MAX_Q = 100000;

int n,q;

//data??????????????????????§??????????????????????,datb????????????????????????
ll data[DAT_SIZE],datb[DAT_SIZE];

void add(int a,int b,int x,int k,int l,int r)
{
	if(a <= l && r <= b){
		data[k] += x;
	}
	else if(l < b && a < r){
		datb[k] += (min(b,r) - max(a,l)) * x;
		add(a,b,x,k*2+1,l,(l+r)/2);
		add(a,b,x,k*2+2,(l+r)/2,r);
	}
}

ll sum(int a,int b,int k,int l,int r)
{
	if(r <= a || b <= l){
		return 0;
	}
	else if(a <= l && r <= b){
		return data[k]*(r-l) + datb[k];
	}else{
		ll res = (min(b,r) - max(a,l))*data[k];	//??????data[k]??????????????£???????????????
		res += sum(a,b,k*2+1,l,(l+r)/2);
		res += sum(a,b,k*2+2,(l+r)/2,r);
		return res;
	}
}

int main()
{
	scanf("%d%d",&n,&q);
	rep(i,q){
		int x;
		scanf("%d",&x);
		if(x==0){
			int s,t,u;
			scanf("%d%d%d",&s,&t,&u);
			add(s-1,t,u,0,0,n);
		}else{
			int s,t;
			scanf("%d%d",&s,&t);
			printf("%lld\n",sum(s-1,t,0,0,n));
		}
	}
	return 0;
}

Measured memory_bytes: 6228
package main

import (
	"fmt"
)

func main() {
	var N, K int
	fmt.Scanf("%d %d", &N, &K)

	m := map[int]float64{}
	nums := make([]int, N)
	for i := 0; i < N; i++ {
		var n int
		fmt.Scanf("%d", &n)
		nums[i] = n

		if _, ok := m[n]; !ok {
			f := float64(sumOneToN(n)) / float64(n)
			m[n] = f
		}
	}

	var tmp, result float64
	for i := 0; i < N; i++ {
		n := nums[i]
		if i < K {
			tmp += m[n]
		} else {
			o := nums[i-K]
			tmp -= m[o]
			tmp += m[n]
		}

		if tmp > result {
			result = tmp
		}
	}

	fmt.Printf("%F\n", result)
}

func sumOneToN(n int) int {
	var result int
	if n % 2 == 0 {
		h := n / 2
		result = (n+1)*h
	} else {
		h := n / 2
		result = (n+1)*h + (h+1)
	}
	return result
}


Measured memory_bytes: 6016
import java.util.Scanner;
class Main{
  public static void main(String[] args){
    Scanner scan= new Scanner(System.in);
    int N=scan.nextInt();
    int M=scan.nextInt();
    
    if(N==M){
      System.out.println("Yes");
    }else{
      System.out.println("No");
    }
  }
}

Measured memory_bytes: 23892
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n,m,x,a,count=0,pount=0;
    cin>>n>>m>>x;
    for(int i=0;i<m;i++)
    {
        cin>>a;
        if(a>x && a<n+1)
        {
            count++;
        }
        if(a<x)
        {
            pount++;
        }
    }
    
    if(count>pount)
    cout<<pount<<"\n";
    else
    cout<<count<<"\n";
    
    return 0;
}

Measured memory_bytes: 3556
#include <stdio.h>

/*
 * jyjfÅ é©Ì»èÖ
 *
 * ßèl
 *   - 1 : jyjfÅ é
 *   - 0 : jyjfÅÈ¢
 */
int isMSPrime(int x){
	int i = 6;

	while(i < x){
		if(x % i == 0) return 0;
		if(i % 7 == 1){
			i += 5;
		} else{
			i += 2;
		}
	}
	return 1;
}

int main(void){
	int i;
	int x; //üÍl

	while(1){
		scanf("%d",&x);
		if(x == 1) break;

		printf("%d:",x);

		i = 6; //êÔÅÌjyjf
		while(i <= x){
			if(x % i == 0 && isMSPrime(i)){
				printf(" %d",i);
			}

			if(i % 7 == 1){
				i += 5;
			} else{
				i += 2;
			}
		}
		printf("\n");
	}

	return 0;
}

Measured memory_bytes: 408
#include <bits/stdc++.h>
#define ll long long
#define lsb(x) (x & (-x))


using namespace std;


int v[2001];

int main() {
    //fstream cin("A.in");
    //ofstream cout("A.out");
    int i, n, a, b;
    ios::sync_with_stdio(false);
    cin >> n >> a >> b;
    for(i = 1; i <= n; i++)
        cin >> v[i];
    v[0] = v[n];
    cout << max(abs(v[n] - b), abs(v[n] - v[n - 1]));
    //cin.close();
    //cout.close();
    return 0;
}


Measured memory_bytes: 256
#include<stdio.h>

int main(void){
	int r,g,b,total;
	
	scanf("%d",&r);
	scanf("%d",&g);
	scanf("%d",&b);
	total=100*r+10*g+b;
	if(total%4==0){
		printf("YES\n");
		}
	else{
		printf("NO\n");
		}
}

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

int main(){
  bool a[100000];

  a[0]=a[1]=false;
  for(int i=2;i<100000;i++){
    a[i]=true;
  }

  for(int i=2;i*i<100000;i++){
    if(a[i]){
      for(int j=i*i;j<100000;j+=i){
        a[j]=false;
      }
    }
  }

  while(true){
    int m;
    cin>>m;
    int count=0;

    if(m==0){
      break;
    }

    for(int i=2;i<=m/2;i++){
      if(a[i]){
        if(a[m-i]){
          count++;
        }
      }
    }

    cout<<count<<endl;

  }

  return 0;
}



Measured memory_bytes: 3076
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.io.UncheckedIOException;
import java.util.StringTokenizer;
import java.io.IOException;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 *
 * @author mikit
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        LightScanner in = new LightScanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        CFlipFlipAndFlip solver = new CFlipFlipAndFlip();
        solver.solve(1, in, out);
        out.close();
    }

    static class CFlipFlipAndFlip {
        public void solve(int testNumber, LightScanner in, PrintWriter out) {
            out.println(Math.abs((in.longs() - 2) * (in.longs() - 2)));
        }

    }

    static class LightScanner {
        private BufferedReader reader = null;
        private StringTokenizer tokenizer = null;

        public LightScanner(InputStream in) {
            reader = new BufferedReader(new InputStreamReader(in));
        }

        public String string() {
            if (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    tokenizer = new StringTokenizer(reader.readLine());
                } catch (IOException e) {
                    throw new UncheckedIOException(e);
                }
            }
            return tokenizer.nextToken();
        }

        public long longs() {
            return Long.parseLong(string());
        }

    }
}



Measured memory_bytes: 22868
#define _CRT_SECURE_NO_WARNINGS
#include <stdio.h>
#include <stdlib.h>
#include <math.h>


int main(void)
{
	int i = 0;
	char O[50] = { 0 }, E[50] = { 0 };

	scanf("%s", O);
	scanf("%s", E);

	for (i = 0; i < 50; i++) {
		if (O[i] != 0)	printf("%c", O[i]);
		if (E[i] != 0)	printf("%c", E[i]);
	}
	printf("\n");

	return 0;
}


Measured memory_bytes: 128
// いっしょ
#include <iostream>
#include <algorithm>
using namespace std;
int main(){
    int n;
    cin>>n;
    int ans=1000000000;
    int a[100],MAX_A=-1000,MIN_A=1000;
    for(int i=0;i<n;i++){
        cin>>a[i];
        MAX_A=max(MAX_A,a[i]);
        MIN_A=min(MIN_A,a[i]);
    }
    for(int i=MIN_A;i<=MAX_A;i++){
        int num=0;
        for(int j=0;j<n;j++){
            num+=(a[j]-i)*(a[j]-i);
        }
        ans=min(ans,num);
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<stdlib.h>
#include<string>
using namespace std;
int cnt[30],ans[30],alpha_cnt;//alphabetの個数をカウント
int check_s[300010],check_t[300010];
int main(){
    string s,t;
    cin>>s>>t;
    for(int i=0;i<s.length();i++){
        ans[t[i]-'a']++;
        cnt[s[i]-'a']++;
    }
    for(int i=0;i<26;i++){
        if(cnt[i]!=0)alpha_cnt++;
        check_s[cnt[i]]++;
        check_t[ans[i]]++;
    }
    bool flag=true;
    for(int i=1;i<300001;i++){
        if(check_s[i]!=check_t[i]){
            flag=false;
            break;
        }
    }
   if(flag)cout<<"Yes"<<endl;
   else cout<<"No"<<endl;

    return 0;
}



Measured memory_bytes: 776
#include <iostream>
#include <algorithm>
#include <vector>
#include <map>

using namespace std;

const int INF = 1000000000;

int n, m;
vector<pair<int, int> > data[150];
int dp[150][10][80];

main(){
  while(cin >> n >> m && (n || m)){
    for(int i=0;i<n;i++) data[i].clear();
    for(int i=0;i<n;i++){
      int a;
      cin >> a;
      for(int j=0;j<a;j++){
        int b, c;
        cin >> b >> c;
        data[i].push_back(pair<int, int>(b, c));
      }
    }
    fill(dp[0][0], dp[150][0], INF);
    for(int j=0;j<=1;j++){
      if(m-j<0) continue;
      for(int i=0;i<data[j].size();i++){
        dp[j][i][m-j] = 0;
      }
    }
    for(int i=0;i<n-1;i++){
      for(int j=0;j<data[i].size();j++){
        for(int i1=0;i1<=m;i1++){
          if(dp[i][j][i1] != INF){
            for(int l=0;l<=1;l++){
              if(i1-l<0) continue;
              int next = i+1+l;
              if(next >= n) continue;

              for(int k=0;k<data[next].size();k++){
                dp[next][k][i1-l] = min(dp[next][k][i1-l],
                                   dp[i][j][i1] + (data[i][j].second + data[next][k].second) *
                                   (abs(data[i][j].first - data[next][k].first)));
              }
            }
          }
        }
      }
    }
    int ans = INF;
    for(int j=0;j<=1;j++){
      if(m-j<0) continue;
      for(int i=0;i<data[n-1-j].size();i++){
        for(int k=j;k<=m;k++){
          ans = min(ans, dp[n-1-j][i][k]);
        }
      }
    }
    cout << ans << endl;
  }
  
  return 0;
}

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

typedef long long ll;
 
using tpl = tuple<int, int, int>;
typedef pair<int,int> pii;

void fastStream(){cin.tie(0);std::ios_base::sync_with_stdio(0);}


int dp[100010];
int H[100010];
int N;

int main(){

    cin >> N;
    for(int i = 0; i < N; i++) cin >> H[i];
    for(int i = 1; i < N; i++){
        dp[i] = 2000000000;
        if(i - 1 >= 0)
            dp[i] = min(dp[i], dp[i-1] + abs(H[i-1] - H[i]));
        if(i - 2 >= 0)
            dp[i] = min(dp[i], dp[i-2] + abs(H[i-2] - H[i]));
    }
    cout << dp[N-1] << endl;

    return 0;
}


Measured memory_bytes: 1024
#include <cstdio>
#include <string>
#include <iostream>
#include <algorithm>

using namespace std;

int main() {
  int n;
  scanf("%d", &n);
  int a[n];
  for (int i = 0; i < n; i++)
    scanf("%d", a+i);
  
  for (int i = 0;  ; i++) {
    for (int j = 0; j < n; j++) {
      if (a[j] % 2 == 0)
        a[j] /=2;
      else {
        printf("%d", i);
        return 0;
      }
    }
  }
}

Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#include <iostream>
#include <string>
#include <math.h>
#include <vector>

using namespace std;

int main() {

	int K;
	double R;

	cin >> K;

	R = (2 * K) * M_PI;

	cout << R;

	return 0;
}

Measured memory_bytes: 3260
#include <iostream>
#include <cmath>

#define OPEN 0
using namespace std;
long long N;
bool cf(long long f) {
	if (f <= 1)return false;
	else if (N / f == N % f)return true;
	else return false;
}
int main() {
#if OPEN
	freopen("input.txt", "r", stdin);
#endif 
	
	while (cin >> N) {
		if (N >= 3) {
			long long sum = 0;
			for (int i = 1; i <= sqrt(N); i++) {
				if (N%i == 0) {
					if (N / i == i) {
						long long f = i-1;
						if (cf(f))sum += f;
					}
					else
					{
						//sum += i - 1 + N/i-1;
						long long f1 = i-1; long long f2 = N / i-1;
						if (cf(f1))sum += f1;
						if (cf(f2))sum += f2;
					}
				
				}
			}
			cout << sum << '\n';
		}
		else cout << 0 << '\n';
	}
	return 0;
}

Measured memory_bytes: 256
from collections import deque

h, w = map(int, input().split())
S = [input() for _ in range(h)]
inf = float("inf")
ans = 0

for i in range(h):
  for j in range(w):
    if S[i][j] == "#":
      continue
    D = [[inf for _ in range(w)] for _ in range(h)]
    D[i][j] = 0
    que = deque([(i, j)])
    while que:
      si, sj = que.popleft()
      for ni, nj in [(si+1, sj), (si-1, sj), (si, sj+1), (si, sj-1)]:
        if 0 <= ni < h and 0 <= nj < w and S[ni][nj] != "#":
          if D[ni][nj] > D[si][sj]+1:
            D[ni][nj] = D[si][sj]+1
            ans = max(ans, D[si][sj]+1)
            que.append((ni, nj))
            
print(ans)
      

Measured memory_bytes: 3316
//#define __USE_MINGW_ANSI_STDIO 0
#include <bits/stdc++.h>

using namespace std;
typedef long long ll;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<ll> VL;
typedef vector<VL> VVL;
typedef pair<int, int> PII;

#define FOR(i, a, n) for (ll i = (ll)a; i < (ll)n; ++i)
#define REP(i, n) FOR(i, 0, n)
#define ALL(x) x.begin(), x.end()
#define IN(a, b, x) (a<=x&&x<b)
#define MP make_pair
#define PB push_back
#define MOD 1000000007
#define INF (1LL<<30)
#define LLINF (1LL<<60)
#define PI 3.14159265359
#define EPS 1e-12
//#define int ll

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

int s[35][35], d[35][35][4], c[4];
signed main(void)
{
  while(true) {
    int w, h;
    cin >> w >> h;
    if(!w && !h) break;
    REP(i, h) REP(j, w) cin >> s[i][j];
    REP(i, 4) cin >> c[i];

    priority_queue<VI, VVI, greater<VI>> q;
    q.push({0, 0, 0, 0});
    REP(i, h) REP(j, w) REP(k, 4) d[i][j][k] = INF;
    d[0][0][0] = 0;
    while(q.size()) {
      VI v = q.top(); q.pop();
      int x = v[1], y = v[2], dir = v[3];
      //cout << x << " " << y << " " << dir << " " << d[y][x][dir] << endl;
      if(x == w-1 && y == h-1) continue;
      REP(i, 4) {
        int ndir = (dir+i)%4, nx = x + dx[ndir], ny = y+dy[ndir];
        int tmp;
        if(s[y][x] == i) tmp = d[y][x][dir];
        else tmp = d[y][x][dir] + c[i];
        if(IN(0, w, nx) && IN(0, h, ny) && d[ny][nx][ndir] > tmp) {
          d[ny][nx][ndir] = min(d[ny][nx][ndir], tmp);
          q.push({d[ny][nx][ndir], nx, ny, ndir});
        }
      }
    }

    int ret = INF;
    REP(i, 4) ret = min(ret, d[h-1][w-1][i]);
    cout << ret << endl;
  }

  return 0;
}

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

int main(){
    long long n,h,w;cin>>n>>h>>w;
    long long a, b;
    int acc = 0;
    for (int i=0;i<n;i++){
        cin >> a >> b;
        if (h <= a && w <= b){
            acc++;
        }
    }
    cout << acc << endl;
    return 0;

}

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

using namespace std;
typedef long long ll;
typedef pair<ll, ll> p_ll;

template<class T>
void debug(T itr1, T itr2) { auto now = itr1; while(now<itr2) { cout << *now << " "; now++; } cout << endl; }
#define repr(i,from,to) for (int i=(int)from; i<(int)to; i++)
#define all(vec) vec.begin(), vec.end()
#define rep(i,N) repr(i,0,N)
#define per(i,N) for (int i=(int)N-1; i>=0; i--)

const ll MOD = pow(10,9)+7;
const ll LLINF = pow(2,61)-1;
const int INF = pow(2,30)-1;

struct val { int i; int v; };

int main() {
  int N; cin >> N;
  int l = pow(2,N);
  int A[l]; rep(i,l) cin >> A[i];
  vector<val> num[l];
  rep(i,l) {
    num[i].push_back({i,A[i]});
    num[i].push_back({l,0});
    rep(dig,N) {
      if (i&(1<<dig)) {
        int now = i^(1<<dig);
        num[i].push_back(num[now][0]);
        num[i].push_back(num[now][1]);
      }
    }
    sort(all(num[i]),[](const val &x, const val &y){return x.i<y.i;});
    sort(all(num[i]),[](const val &x, const val &y){return x.v>y.v;});
    num[i].erase(unique(all(num[i]),[](const val &x, const val &y){return x.i==y.i;}),num[i].end());
  }

  // rep(i,l) cout << num[i][0].v << " " << num[i][1].v << endl;
  int result[l] = {}; repr(i,1,l) result[i] = max(result[i-1],num[i][0].v+num[i][1].v);
  repr(i,1,l) cout << result[i] << endl;
  return 0;
}

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

int main() {
  int n,k,q;
  cin >>n >>k >>q;
  vector <int> a(n,k-q); //持ち点
  vector <int> b(q);
  for (int i=0;i<q;i++)
    cin >> b.at(i); //正解者の番号
  
 
  for(int i=0;i<q;i++)
  a.at(b.at(i)-1)++;
  for (int i=0;i<n;i++){
    if(a.at(i)<=0)
      cout << "No" <<endl;
  if(a.at(i)>0)
    cout<<"Yes"<<endl;
  }
  
}


Measured memory_bytes: 1408
// template version 1.7

// varibable settings {{{
using namespace std;
#include <iostream>
#include <bits/stdc++.h>

#define int long long
#define INF 1e18
// #define INF 2147483647
#define MOD 1e9+7
#define infile "../test/sample-1.in"
int dx[]={1, -1, 0, 0};
int dy[]={0, 0, 1, -1};
#define fi first
#define se second

// }}}

// define basic macro {{{
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=(int)(a);i<(int)(b);++i)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define _rrep(i,n) rrepi(i,0,n)
#define rrepi(i,a,b) for(int i=(int)(b-1);i>=(int)(a);--i)
#define rrep(...) _overload3(__VA_ARGS__,rrepi,_rrep,)(__VA_ARGS__)
#define all(x) (x).begin(),(x).end()
#define sz(x) ((int)(x).size())
#define pb(a) push_back(a)
#define mp(a, b) make_pair(a, b)
#define uni(x) sort(all(x));x.erase(unique(all(x)),x.end())
template<class T> inline void chmax(T &a, const T &b) { if(a < b) a = b; }
template<class T> inline void chmin(T &a, const T &b) { if(a > b) a = b; }

typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef long double ld;
typedef pair<int,int> pii;
typedef tuple<int,int,int> iii;
template<typename T> using PQ = priority_queue<T, vector<T>, greater<T>>;

// dump macro
#ifdef PCM
  #include "dump.hpp"
#else
  #define dump(...) 42
  #define dump_1d(...) 42
  #define dump_2d(...) 42
#endif
struct Fast { Fast(){ std::cin.tie(0); ios::sync_with_stdio(false); } } fast;
// }}}

int solve(){
  string s;cin>>s;
  int res = INF;

  char c = '1';
  int tmp = 0;
  rep(i, sz(s)){
    if (s[i]!=c) tmp++;
    if (c=='1') c='0';
    else if (c=='0') c='1';
  }
  dump(tmp);
  chmin(res, tmp);

  c = '0';
  tmp = 0;
  rep(i, sz(s)){
    if (s[i]!=c) tmp++;
    if (c=='1') c='0';
    else if (c=='0') c='1';
  }
  dump(tmp);
  chmin(res, tmp);

  cout << res << endl;

  return 0;
}

signed main() { //{{{
#ifdef INPUT_FROM_FILE
  std::ifstream in(infile);
  std::cin.rdbuf(in.rdbuf());
#endif
  solve();
  return 0;
} //}}}


Measured memory_bytes: 512
#include<stdio.h>
#include<string.h>

int main(void){
    char moji[1001], tmp[1001], order[8];
    int q, a, b;
    scanf("%s", moji);
    scanf("%d", &q);
    for(int i=0; i<q; i++){
        scanf("%s %d %d", order, &a, &b);
        if(!strcmp(order, "print")){
            for(int j=a; j<=b; j++) printf("%c", moji[j]);
            printf("\n");
        }else if(!strcmp(order, "reverse")){
            for(int j=0; j<=b-a; j++) tmp[b-j] = moji[a+j];
            for(int j=a; j<=b; j++) moji[j] = tmp[j];
        }else if(!strcmp(order, "replace")){
            scanf("%s", tmp);
            for(int j=a; j<=b; j++) moji[j] = tmp[j-a];
        }
    }
    return 0;
}


Measured memory_bytes: 2080
#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

int main(void){

  int n;  //??????????????°????¨????
  double a;  //?????°?????????
  double b;  //??????????????°?????????
  double price; //?????¶?????????
  double kizi_cal;
  double pizza_cal;
  double cal_rate;
  
  cin >> n;
  cin >> a >> b;
  cin >> kizi_cal;

  vector<double> calorie(n); //??????????????°????????????????????\??????

   for(int i=0;i<n;i++){
    cin >> calorie[i];
    }

  sort(calorie.begin(), calorie.end(),std::greater<int>());

  price=a;
  pizza_cal=kizi_cal;
  cal_rate=pizza_cal/price;

  double r;
  
  for(int i=0;i<n;i++){
    
    r=(pizza_cal+calorie[i])/(price+b);

      if(r>=cal_rate){
	cal_rate=r;
	pizza_cal+=calorie[i];
	price+=b;
      }
      else if(r<cal_rate){
	break;
      }
      
  }    
  cout << (int)cal_rate<<endl;

  return 0;

  }

Measured memory_bytes: 3204
h, w = (int(x) for x in input().split())
A = [list(input()) for _ in range(h)]
R = [["."] * w for _ in range(h)]
B = [["."] * w for _ in range(h)]

# ベースとして Red: へび, Blue: Red以外
for i in range(h):
    for j in range(w):
        if 0 < i < h - 1 and 0 < j < w - 1:
            if i % 2 == 1 or (i % 4 == 2 and j == w - 2) or (i % 4 == 0 and j == 1):
                R[i][j] = "#"
        if R[i][j] != "#":
            B[i][j] = "#"

for i in range(h):
    for j in range(w):
        if A[i][j] == "#":
            R[i][j] = "#"
            B[i][j] = "#"

for r in R:
    print("".join(r))
print()
for b in B:
    print("".join(b))


Measured memory_bytes: 82376
#include <iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<map>
#include<set>
#include<stack>
#include<queue>
#include<math.h>
using namespace std;
typedef long long ll;
#define int long long
#define double long double
typedef vector<int> VI;
typedef pair<int, int> pii;
typedef vector<pii> VP;
typedef vector<string> VS;
typedef priority_queue<int> PQ;
template<class T>bool chmax(T &a, const T &b) { if (a < b) { a = b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b < a) { a = b; return 1; } return 0; }
#define fore(i,a) for(auto &i:a)
#define REP(i,n) for(int i=0;i<n;i++)
#define eREP(i,n) for(int i=0;i<=n;i++)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define eFOR(i,a,b) for(int i=(a);i<=(b);++i)
#define SORT(c) sort((c).begin(),(c).end())
#define rSORT(c) sort((c).rbegin(),(c).rend())
#define LB(x,a) lower_bound((x).begin(),(x).end(),(a))
#define UB(x,a) upper_bound((x).begin(),(x).end(),(a))
#define INF 1000000000000
#define LLINF 9223372036854775807
#define mod 1000000007
#define eps 1e-12 
//priority_queue<int,vector<int>, greater<int> > q2;

struct segtree {
public:
	const int SIZE = 1 << 18;
	VI seg, lazy;
	//seg:区間の合計値 lazy:区間に対して、加える値でまだ遅延しているもの

	segtree() :seg(SIZE * 2), lazy(SIZE * 2) {}
	void lazy_evaluate(int k, int l, int r) {
		if (lazy[k] != 0) {
			seg[k] += lazy[k];
			//区間[l,r)にすべて同じ値を追加することになっていて、
			//segには合計値が入っているので、加える値を足す
			if (r - l > 1) {
				lazy[k * 2 + 1] += lazy[k];
				lazy[k * 2 + 2] += lazy[k];
			}
			lazy[k] = 0;
		}
	}

	void update(int a, int b, int k, int l, int r, int x) {
		lazy_evaluate(k, l, r);
		if (r <= a || b <= l)return;
		if (a <= l && r <= b) {
			lazy[k] += x;
			lazy_evaluate(k, l, r);
		}
		else {
			update(a, b, k * 2 + 1, l, (l + r) / 2, x);
			update(a, b, k * 2 + 2, (l + r) / 2, r, x);
			seg[k] = seg[k * 2 + 1] + seg[k * 2 + 2];
		}
	}
	int query(int a, int b, int k, int l, int r) {
		lazy_evaluate(k, l, r);
		if (r <= a || b <= l)return 0;
		if (a <= l && r <= b)return seg[k];
		int x = query(a, b, k * 2 + 1, l, (l + r) / 2);
		int y = query(a, b, k * 2 + 2, (l + r) / 2, r);
		return x + y;
	}

	void update(int a, int b, int x) { update(a, b, 0, 0, SIZE, x); }
	//update(a,b,x) := [a,b)を全てxを加える
	int query(int a, int b) { return query(a, b, 0, 0, SIZE); }
	//query(a,b) := [a,b)に対する合計値を求める

};

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

	int N, M; cin >> N >> M;
	VI A(N);
	REP(i, N) {
		cin >> A[i];
		A[i]--;
	}
	segtree seg1, seg2;

	REP(i, N - 1) {
		int s = A[i], t = A[i + 1];
		if (s < t) {
			seg1.update(0, s + 1, t - s);
			seg1.update(t + 1, M, t - s);
			seg2.update(s + 1, s + 2, t - s);
			seg2.update(s + 2, t + 2, -1);
		}
		else{
			int r = M - s + t;
			seg1.update(t + 1, s + 1, r);
			t += M;
			seg2.update(s + 1, s + 2, r);
			seg2.update(s + 2, t + 2, -1);
		}
	}

	int ans = INF;
	VI sum(M * 2);
	REP(i,2 * M) {
		sum[i] = seg2.query(i, i + 1);
		if (i != 0)sum[i] += sum[i - 1];
		
	}
	REP(i, M) {
		chmin(ans, sum[i] + sum[i + M] + seg1.query(i, i + 1));
		//cout << sum[i] + sum[i + M] << " " <<  seg1.query(i, i + 1) << endl;
	}

	cout << ans << endl;

	return 0;
}



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

template<typename T>
void out(T x) { cout << x << endl; exit(0); }
#define watch(x) cout << (#x) << " is " << (x) << endl




typedef long long ll;
const ll mod = 1e9+7;
const int maxn = 1e6 + 5;



int n;
ll a[maxn];

int main() {
    ios_base::sync_with_stdio(false); cin.tie(0);  cout.tie(0);
    cin>>n;

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

    vector<int> stk;

    for (int i=n; i>=0; i--) {
	while (!stk.empty() && a[stk.back()] <= a[i]) stk.pop_back();
	stk.push_back(i);
    }



    vector<ll> ans(n+1, 0);



    priority_queue<ll> right;
    ll same = 0;
    int j=n;
    int len = stk.size();

    
    for (int i=0; i<len-1; i++) {
	int idx = stk[i];
	ll target = a[stk[i+1]];

	    
	while (j>=idx) {
	    right.push(a[j]); j--;
	}

	ll &cur = ans[idx];
	cur += same*(a[idx]-a[stk[i+1]]);

	    
	while (!right.empty() && right.top() >= target) {
	    ll x = right.top(); right.pop();
	    cur += x-target;
	    same++;
	}
    }	
    
    for (int i=1; i<=n; i++) {
	cout<<ans[i]<<"\n";
    }
    return 0;
}


Measured memory_bytes: 3192
#include<iostream>
#include<math.h>
using namespace std;
int main(){
    int a;
    cin>>a;
    for(;;){
       char b;
       cin>>b;
       if(b=='+'){
         int c;
         cin>>c;
         a+=c;
       }
       if(b=='-'){
         int c;
         cin>>c;
         a-=c;
       }
       if(b=='*'){
         int c;
         cin>>c;
         a*=c;
       }
       if(b=='/'){
         int c;
         cin>>c;
         a/=c;
       }
       if(b=='='){
         cout<<a<<endl;
         break;
       }
    }
    return 0;
}


Measured memory_bytes: 3084
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <cmath>
#include <climits>
#include <iomanip>

using namespace std;

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

	int n;
	cin >> n;
	vector<double> v(n);
	for (int i = 0; i < n; i++) {
		cin >> v[i];
	}

	sort(v.begin(), v.end(), [](double& a, double& b) {return a < b; });
	for (int i = 0; i < n - 1; i++) {
		v[i + 1] += v[i];
		v[i+1] /= 2;
	}
	cout << std::setprecision(16) << v[n - 1] << endl;

	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
 int n;
 cin>>n;

 int a[100];
 for(int i=0;i < n;i++) cin>>a[i];
 

 for(int i=0;i < n-1-i;i++) swap(a[i], a[n-1-i]);


 for(int i=0;i<n;i++){
  if(i) cout<<" ";
  cout<<a[i];
 }
 cout<<endl;

 return 0;
}


Measured memory_bytes: 3072