akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <string>
#include <utility>
#include <algorithm>
#include <vector>
using namespace std;

int main() {
	vector<int> s;
	int N, M;
	cin >> N >> M;
	for(int i = 0; i < N; i++) {
		int tmp;
		cin >> tmp;
		s.push_back(tmp + '0');
	}
	vector<int> p[2];
	int fill = 0;
	for(int i = 0; i < M; i++) {
		int tmp;
		cin >> tmp;
		for(int j = 0; j < tmp; j++) {
			p[0].push_back(!!fill+'0');
			p[1].push_back(!fill+'0');
		}
		fill = !fill;
	}

	int ans = 10000;
	for(int i = 0; i < 2; i++) {
		int tmp = 0;
		for(int j = 0; j < s.size(); j++) {
			if(s[j] != p[i][j]) {
				int sw = -1;
				for(int k = 1; k + j < s.size(); k++) {
					if(s[j] == p[i][j+k]) {
						sw = k;
						break;
					}
				}
				if(sw<0) {
				//	cout << i << "," << j << endl;
					tmp = 10000;
				}

				else {
					for(int k = j+sw-1; k >= j; k--)
						swap(p[i][k], p[i][k+1]);
					tmp += sw;
				}
			}
		}
		ans = min(ans, tmp);
	}
	cout << ans << endl;
}

Measured memory_bytes: 1216
#include <stdio.h>

typedef struct {
	int key, id;
} data;

typedef struct {
	data obj[400001];
	int size;
} min_heap;

void push(data x, min_heap* h)
{
	int i = ++(h->size);
	data tmp;
	h->obj[i] = x;
	while (i > 1) {
		if (h->obj[i].key < h->obj[i>>1].key) {
			tmp = h->obj[i>>1];
			h->obj[i>>1] = h->obj[i];
			h->obj[i] = tmp;
			i >>= 1;
		} else break;
	}
}

data pop(min_heap* h)
{
	int i = 1, j = 2;
	data output = h->obj[1], tmp;
	h->obj[1] = h->obj[(h->size)--];
	while (j <= h->size) {
		if (j < h->size && h->obj[j^1].key < h->obj[j].key) j ^= 1;
		if (h->obj[j].key < h->obj[i].key) {
			tmp = h->obj[j];
			h->obj[j] = h->obj[i];
			h->obj[i] = tmp;
			i = j;
			j = i << 1;
		} else break;
	}
	return output;
}

int main()
{
	int i, H, W, A, B;
	scanf("%d %d", &H, &W);
	
	int j, k, l[200002], r[200002], left[200002], right[200002], L, R, M;
	data d;
	min_heap h;
	h.size = 0;
	for (i = 0; i <= W + 1; i++) {
		l[i] = i;
		r[i] = i + 1;
		left[i] = i - 1;
		right[i] = i + 1;
	}
	for (i = 1, d.key = 0; i <= W; i++) {
		d.id = i;
		push(d, &h);
	}
	for (i = 1; i <= H; i++) {
		scanf("%d %d", &A, &B);
		L = 0;
		R = W;
		while (L < R) {
			M = (L + R + 1) / 2;
			if (l[M] < A) L = M;
			else R = M - 1;
		}
		for (; l[L] == r[L] || l[L] >= A; L = left[L]);
		// for (L = 0; l[right[L]] < A; L = right[L]);
		if (r[L] < B + 1) r[L] = B + 1;
		for (j = right[L]; r[j] <= r[L]; j = right[j]) l[j] = r[j];
		right[L] = j;
		left[j] = L;
		if (l[j] <= B) {
			l[j] = r[L];
			d.key = l[j] - j;
			d.id = j;
			push(d, &h);
		}
		
		while (h.size > 0 && l[h.obj[1].id] > h.obj[1].key + h.obj[1].id) pop(&h);
		if (h.size > 0) printf("%d\n", h.obj[1].key + i);
		else printf("-1\n");
	}
	
	fflush(stdout);
	return 0;
}

Measured memory_bytes: 6500
#include <iostream>
#include <string>
#include <algorithm>
#include <cstdio>
#include <cmath>
#include <iomanip>
#include <cstdlib>
using namespace std;
 
bool isprime(int a){
	if(a==2) return true;
	if(a%2==0) return false;
	for(int i=3;i*i<=a;i+=2){
		if(a%i==0) return false;
	}
	return true;
}

int main () {
	int n,j,b,sum=0;
	cin >> n;
	for(j=0;j<n;j++){
		cin >> b;
		if(isprime(b)) sum+=1;
	}
	cout << sum << endl;
}

Measured memory_bytes: 1160
#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 fi first
#define se second
#define mp make_pair
typedef long long ll;
typedef vector<ll> vec;
typedef vector<vec> mat;

ll N,M,H,W,K,Q,A,B,L,R;
string S,T;
const ll MOD = (1e+9) + 7;
const ll INF = 1LL << 60;
typedef pair<ll,ll> P;

typedef vector<P> vp;
typedef vector<vp> matP;

int main(){
    vector<string> p(3);
    rep(i,3) cin>>p[i];
    rep(i,3) cout<<p[i][i];
    cout<<endl;
}

Measured memory_bytes: 256
#pragma GCC Optimize("Ofast")
#pragma GCC Optimize "trapv"
#define _GLIBCXX_DEBUG

#include <bits/stdc++.h>
using namespace std;

#define FAST ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
#define TC int t; cin >> t; while(t--)
#define li long int
#define ll long long
#define ull unsigned long long 
#define Vec(x) vector <x>
#define Pai(x,y) pair <x,y>
#define Map(x,y) map <x,y>
#define UMap(x,y) unordered_map <x,y>
#define Set(x) set <x>
#define Sta(x) stack <x>
#define Qu(x) queue <x>
#define DQ(x) deque(x)
#define PriorQ(x)	priority_queue <x>
#define bg begin()
#define ed end()
#define sz size()
#define ct(x) count(x)
#define len length()
#define F first
#define S second
#define Makep make_pair
#define ins(x) insert(x)
#define ers(x) erase(x)
#define endl "\n";
#define MOD 1000000007
#define PI 2*acos(0.0)
#define clr() clear()
#define fori0(n) for(int i=0;i<n;i++)
#define foriab(a,b) for(int i=a;i<b;i++)
#define mem0(x) memset(x,0,sizeof(x))
#define mem1(x) memset(x,1,sizeof(x))
#define autoit(x) for(auto it=x.beg;it!=x.ed;it++)
#define count0(x) __builtin_popcount(x)
#define ret return 
mt19937_64 rang(chrono::high_resolution_clock::now().time_since_epoch().count());

ll a[100005][4],dp[100005][3],n,k;

ll ans(ll i, ll j){	
	if(i==n)
		return 0;
	ll maxi=INT_MIN;
	if(dp[i][j]!=-1)	
		return dp[i][j];
	if(j==0){
		maxi=max(maxi, a[i][1]+ans(i+1,1));
		maxi=max(maxi, a[i][2]+ans(i+1,2));
		maxi=max(maxi, a[i][3]+ans(i+1,3));
	}
	else if(j==1){
		maxi=max(maxi, a[i][2]+ans(i+1,2));
		maxi=max(maxi, a[i][3]+ans(i+1,3));
	}
	else if(j==2){
		maxi=max(maxi, a[i][1]+ans(i+1,1));
		maxi=max(maxi, a[i][3]+ans(i+1,3));
	}
	else{
		maxi=max(maxi, a[i][1]+ans(i+1,1));
		maxi=max(maxi, a[i][2]+ans(i+1,2));	
	}
	return dp[i][j]=maxi;
}

void solve(){
	memset(dp,-1,sizeof(dp));
	cin >> n;
	for(ll i=0;i<n;i++)
		for(ll j=1;j<=3;j++)
				cin >> a[i][j];
	cout << ans(0,0) << endl;
}

int main(){
	#ifndef ONLINE_JUDGE
		freopen("input.txt", "r", stdin);
		freopen("output.txt", "w", stdout);
	#endif	
	FAST
	srand(chrono::high_resolution_clock::now().time_since_epoch().count());
	solve();
	ret 0;
}

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

using namespace std;

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

	int a,b,c;

	cin >> a >> b >> c;

	for(int i=1;i<=b;i++)
	{
		if((a*i)%b==c)
		{
			cout << "YES" << '\n';
			return 0;
		}
	}

	cout << "NO" << '\n';
	return 0;
}

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

int abs( int a ) { return a < 0 ? -a : a; }

int main() {
	string s;
	cin >> s;
	cout << ( ( s[0] == s[1] || s[1] == s[2] || s[2] == s[3] ) ? "Bad" : "Good" ) << endl;
	return 0;
}

Measured memory_bytes: 256
loop do 
    x = gets.chomp.split
     a = x[0].to_i
     y = x[1]
     b = x[2].to_i
    break if x.include?("?")
    if y == "+"
        puts a+b
    elsif y == "-"
        puts a-b
    elsif y == "/"
        puts a/b
    elsif y == "*"
        puts a*b
    end
end



Measured memory_bytes: 6868
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define rep(i,n) for (int i = 0; i < (n); ++i)
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
const ll INF=1LL<<60;
const int inf=(1<<30)-1;
const int mod=998244353;
int dx[8]={1,0,-1,0,-1,-1,1,1};
int dy[8]={0,1,0,-1,-1,1,-1,1};
ll pow_mod(ll n,ll k,ll m){
  ll res=1;
  for(;k>0;k>>=1){
    if(k&1){
      res=(res*n)%m;
    }
    n=(n*n)%m;  
  }
  return res;
}
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll n,s;cin >> n >> s;
    vector<ll> a(n);
    rep(i,n){
        cin >> a[i];
    }
    vector<vector<ll>> dp(n+1,vector<ll>(s+1));
    rep(i,n){
        if(a[i]<=s){
            (dp[i+1][a[i]]+=pow_mod(2,i,mod))%=mod;
        }
        rep(j,s+1){
            (dp[i+1][j]+=2*dp[i][j]%mod)%=mod;
            if(j+a[i]<=s){
                (dp[i+1][j+a[i]]+=dp[i][j])%=mod;
            }
        }
    }
    cout << dp[n][s] << endl;
}

Measured memory_bytes: 73680
import Control.Applicative ((<$>))
import qualified Control.Monad as Monad (when)

main = do
    nx <- (getLine' $ map read . words)
    Monad.when (any (/= 0) nx) $ do
        print $ length $ combination nx
        main

getLine' :: (String -> a) -> IO a
getLine' f = f <$> getLine

combination :: [Int] -> [[Int]]
combination [n,x] = [[a,b,c] | a <- [1..n], b <- [a..n], c <- [b..n],
                        a + b + c == x, a /= b, a/= c, b /= c]

Measured memory_bytes: 4812
#include <iostream>

using namespace std;

int main() {

     int a, b, valor1, valor2, resultado;
     cin >> a >> b;

     if(a > b) {

         valor1 = a;

        if(a-1 >= b) {

            valor2 = a - 1;

        }

     }

     if(b > a) {

         valor1 = b;

         if(b-1 >= a) {

             valor2 = b - 1;

         }

     }  

     if(b == a) {

         valor1 = b;
         valor2 = a;

     }  


    resultado = valor1 + valor2;

    cout << resultado << endl;

}



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

int main()
{
    ll a, b;
    char c;
    cin >> a >> c >> b;
    if (c == '+')
    {
        cout << a + b << endl;
    }
    else
    {
        cout << a - b << endl;
    }
}

Measured memory_bytes: 256
#include <climits>
#include <cmath>
#include <algorithm>
#include <array>
#include <iostream>
#include <vector>
using namespace std;
int main(int, char**)
{
	int N;
	cin >> N;
	vector<double> A(N);
	double mul = 1.0;
	for (int i = 0; i < N; ++i)
	{
		cin >> A[i];
		mul *= A[i];
	}
	double tmp = 0;
	for (int i = 0; i < N; ++i)
	{
		tmp += mul / A[i];
	}
	printf("%.6f\n", mul / tmp);
	return 0;
}


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

int main(){
	int H,W;
	while(cin>>H>>W){
      
		if((H==0)&(W==0)){
			return 0;
        }
      
		for(int i=0;i<H;i++){
          if(i%2==0){
            for(int j=0;j<W;j++){
              if(j%2==0){
                cout<<"#";
              }
              else{cout <<".";
              }
            }
            cout<<endl;
          }
          else{
            for(int j=0;j<W;j++){
              if(j%2==0){
                cout<<".";
              }
              else{
                cout <<"#";
              }
            }
          cout<<endl;
          }
        }
    cout<<endl;
    }
}


Measured memory_bytes: 3092
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <cmath>
#include <stdio.h>
#include <queue>
#include <deque>
#include <cstdio>
#include <set>
#include <map>
#include <bitset>
#include <stack>
using namespace std;
int a[100000], b[100000];
long long ans[100000] = {0}, ans1 = 0;
int main() {
	int h, w;
	int co = 0, co1 = 0, h1 = 0, w1 = 0;
	cin >> h >> w;
	char a[8][8];
	for (int i = 0; i < h; i++) {
		for (int j = 0; j < w; j++) {
			cin >> a[i][j];
			if (a[i][j] == '#') {
				co++;
			}
		}
	}
	for (;;) {
		if (h1 == h - 1 && w1 == w - 1) {
			break;
		}
		if (a[h1][w1 + 1] == '#') {
			co1++;
			w1++;
			continue;
		}
		else if (a[h1 + 1][w1] == '#') {
			co1++;
			h1++;
			continue;
		}
		else {
			cout << "Impossible" << endl;
			return 0;
		}
	}
	if (co1 + 1 == co) {
		cout << "Possible" << endl;
	}
	else {
		cout << "Impossible" << endl;
	}
	return 0;
}

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

int main(){
 int n, k, a;
 int q = 0;
 cin >> n >> k;
 
 for(int i = 0; i<n; i++){
  cin >> a;
  if(a >= k){
   ++q;
  }
 }
 cout << q << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main()
{
	int n;
	ll d;
	cin>>n>>d;
	d=d*d;
	int cnt=0;
	for(int i=0; i<n; i++)
	{
		ll x,y;
		cin>>x>>y;
		if(x*x+y*y<=d)
		 cnt++;
	}
	cout<<cnt;
	return 0;
	
}

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

int N;
vector<vector<int>> G;
vector<vector<int>> W;
vector<int> res;

void dfs(int u) {
    for (int i = 0; i < G[u].size(); i++) {
        int v = G[u][i];
        if (res[v] != -1) continue;
        res[v] = (res[u] + W[u][i]) % 2;
        dfs(v);
    }
}

int main() {
    cin >> N;
    G.resize(N);
    W.resize(N);
    for (int i = 0; i < N - 1; i++) {
        int u, v, w;
        cin >> u >> v >> w;
        u--; v--;
        G[u].push_back(v); G[v].push_back(u);
        W[u].push_back(w); W[v].push_back(w);
    }

    res.resize(N, -1);
    res[0] = 0;
    dfs(0);

    for (int i = 0; i < N; i++) {
        cout << res[i] << endl;
    }

    return 0;
}

Measured memory_bytes: 12544
use proconio::{fastout, input};
// use proconio::marker::*;

#[fastout]
fn main() {
   input! {
      a: f64,
      b: f64,
      h: f64,
      m: f64,
   }
   let tm = m / 60.0;
   let th = (h + tm) / 12.0;
   let rs = a * a + b * b - 2.0 * a * b * ((th - tm) * 360.0).to_radians().cos();
   println!("{0:.10}", rs.sqrt());
}


Measured memory_bytes: 3064
from itertools import accumulate
mod = 10**9 +7

def main():
    n = int(input())
    a = list(map(int,input().split()))
    ans =0
    ac = list(accumulate(a))

    for i in range(n):
        ans += a[i]* (ac[-1]-ac[i])
        ans %=mod
    print(ans)

if __name__ == '__main__':
    main()

Measured memory_bytes: 31624
#include <iostream>

using namespace std;

int f( int d ){
	return d * d;
}

int main(int argc, char const* argv[])
{
	int d;

	while( cin >> d ){
		int n = 600 / d;
		int sum = 0;

		for( int i = 1;i < n;i++ ){
			sum += f( i * d ) * d;
		}

		cout << sum << endl;
	}
	
	return 0;
}

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

int main() {
	ios_base :: sync_with_stdio(0); cin.tie(0); cout.tie(0);
	vector <int> f(2e5, 0);
	int n; cin >> n;
	set <int> st;
	for(int i = 1; i <= n; i++) {
		int x; cin >> x;
		f[x] ^= 1;
		st.insert(x);
	}

	int cnt = 0;
	for(int x: st) {
		cnt += f[x] == 0;
	}

	if(cnt & 1) {
		cout << (int)st.size() - 1 << endl;
	} else {
		cout << (int)st.size() << endl;
	}
}

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

class RMQ {
  static const int MAXN=1<<17;
private:
  int n;
  int dat[2*MAXN-1];
public:
  RMQ (int N) {
    init(N);
  }
  void init(int N) {
    n=1;
    while (n<N) {
      n*=2;
    }
    for (int i=0; i<2*n-1; i++) {
      dat[i]=INT_MAX;
    }
  }
  void update(int i,int x) {
    i+=n-1;
    dat[i]=x;
    while (i) {
      i=(i-1)/2;
      dat[i]=min(dat[2*i+1],dat[2*i+2]);
    }
  }
  int find (int s,int t,int k,int l,int r) {
    if (r<=s || t<=l) {
      return INT_MAX;
    }
    if (s<=l && r<=t) {
      return dat[k];
    } else {
      int m=(l+r)/2;
      int vl=find(s,t,k*2+1,l,m);
      int vr=find(s,t,k*2+2,m,r);
      return min(vl,vr);
    }
  }
  int find(int s,int t) {
   return find(s,t,0,0,n);
   }
};
int main() {
  int n, q;
  cin >> n >> q;
  RMQ rmq(n);
  while (q--) {
    int com, x, y;
    cin >> com >> x >> y;
    if (com) {
      printf("%d\n",rmq.find(x,y+1));
    } else {
      rmq.update(x,y);
    }
  }
  return 0;
}

Measured memory_bytes: 4160
# import sys
# from collections import defaultdict
# sys.setrecursionlimit(10000)
# MOD = 10 ** 9 + 7
# N = int(input())
# A = [int(x) for x in input().split()]
# V = [[0] * 100 for _ in range(100)]

S = [int(x) for x in list(input())]
max_bits = 2 ** (len(S) - 1)

l = []
for n in range(max_bits):
    tmp = S[0]
    s = 0
    for i in range(len(S) - 1):
        if n & (1 << (len(S) - 2 - i)):
            tmp = 10 * tmp + S[i + 1]
        else:
            s += tmp
            tmp = S[i + 1]
    s += tmp

    l.append(s)

print(sum(l))


Measured memory_bytes: 3060
//怎么表示连接问题？？？ 
//#include<bits/stdc++.h>
#include<iostream>
using namespace std;
//bool arr[100005];
typedef long long ll;
ll x; 
int main(){
	cin>>x;
	for(ll i=-200;i<=200;i++){
		for(ll j=-200;j<=200;j++){
			if(i*i*i*i*i-j*j*j*j*j==x){
				cout<<i<<" "<<j;
				return 0;
			}
		}
	}
	
	return 0;
}

Measured memory_bytes: 3176
#include <stdio.h>

int main(void)
{
	float a, b, c;
	int z;
	
	while (scanf("%f", &a) != EOF){
		if (a <= 48) {
			printf("light fly\n");
		}
		else if (a <= 51) {
			printf("fly\n");
		}
		else if (a <= 54) {
			printf("bantam\n");
		}
		else if (a <= 57) {
			printf("feather\n");
		}
		else if (a <= 60) {
			printf("light\n");
		}
		else if (a <= 64) {
			printf("light welter\n");
		}
		else if (a <= 69) {
			printf("welter\n");
		}
		else if (a <= 75) {
			printf("light middle\n");
		}
		else if (a <= 81) {
			printf("middle\n");
		}
		else if (a <= 91) {
			printf("light heavy\n");
		}
		else {
			printf("heavy\n");
		}
	}
	
	return (0);
}	

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

std::string s, t;

bool check(std::string::iterator);

int main()
{
    std::cin >> s >> t;
    std::string min = "###";
    for (int i = 0; i + t.size() <= s.size(); i++)
    {
        if (!check(s.begin() + i)) continue;
        std::string tmp = s;
        for (int j = 0; j < t.size(); j++)
            tmp[i + j] = t[j];
        for (auto & e : tmp)
            if (e == '?') e = 'a';
        if (min[0] == '#' || tmp < min)
            min = std::move(tmp);
    }
    if (min == "###") printf("UNRESTORABLE\n");
    else std::cout << min << std::endl;

    return 0;
}

bool check(std::string::iterator it)
{
    for (int i = 0; i < t.size(); i++)
    {
        if (*it != '?' && *it != t[i])
            return false;
        it++;
    }
    return true;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define fastIO (cin.tie(0), cout.tie(0), ios::sync_with_stdio(false))
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define precise(i) fixed << setprecision(i)
using namespace std;

int main() {
    fastIO;
    int a, b;
    cin >> a >> b;
    cout << max(a + b, max(a - b, a * b));
}

Measured memory_bytes: 3588
#include <bits/stdc++.h>
#define HAIRETU(N,A) for(int i=0;i<N;i++) cin >>A[i]
using namespace std;

int main() {
    int A, B, C;
    cin >> A >> B >> C;
    
    int sum = A + B + C;
    int cnt = 0;
    
    int MM = max(A, B);
    int M = max(MM, C);
    
    if (sum % 2 == M % 2) {
        cnt = (3 * M - sum) / 2;
    } else cnt = (3 * (M + 1) - sum) / 2;
    
    
    cout << cnt << endl;
    // 下一桁は最後の一文字が表す数
//    cout << (a & b & 1 ? "Odd" : "Even") << endl;
    return 0;
}


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

#if __has_include(<local.h>)
#include <local.h>
#endif

using namespace std;

typedef long long int LL;
typedef long long int LLint;

//Faster Program
#define endl "\n"

//Faster Coding
#define ED return
#define GET(a) int a;cin >> a
#define DGET(a) double a;cin >> a
#define SGET(a) string a;cin >> a
#define CGET(a) char a;cin >> a
#define PRINT(a) cout << a << "\n"
#define ANS(a,b) int a;cin >> a;cout << b << "\n"
#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define SORT(vec) sort(vec.begin(),vec.end())
#define REV(vec) reverse(vec.begin(),vec.end())
#define ALL(x) (x).begin(),(x).end()

//As Function
#define UP(a,b) ((a+(b-1))/b)
#define IPOW(x,y) LL(pow(x,y))

//Debug
#ifdef LOCAL_H
#define TEST cout << "OK\n"
#define DEBUG(a) a
#else
#define TEST
#define DEBUG(a)
#endif

#ifdef LOCAL_H
[[maybe_unused]]
#endif
const double PI = M_PI;
#ifdef LOCAL_H
[[maybe_unused]]
#endif
const int INF = int(999999999);
#ifdef LOCAL_H
[[maybe_unused]]
#endif
const long long MOD = int(1000000007);

//Settings
#ifdef LOCAL_H
const bool DO_BENCHMARK = true;
#endif
const int DOUBLE_ACCURACY = 15;

#ifndef LOCAL_H
    const bool DO_BENCHMARK = false;
#endif

int main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(DOUBLE_ACCURACY);
    void solve();
    if(DO_BENCHMARK){
        clock_t clock_start = clock();
        solve();
        clock_t clock_end = clock();
        const double time = static_cast<double>(clock_end-clock_start)/CLOCKS_PER_SEC*1000.0;
        cout << "\n" << time << "[ms]\n";
    }
    else solve();
}

/************************************************************************************************************************************************/

void solve(){
    int H, N;
    cin >> H >> N;
    vector<pair<int,int>> M (N);
    for(int i =0;i < N;i++){
        cin >> M[i].first >> M[i].second;
    }
    vector<vector<int>> dp (N,vector<int>(H+1,INF));//N個目までの技で体力Hを削る最小MP
    for(int i = 0;i < N;i++){
        dp[i][0] = 0;
    }
    for(int i = 0;i < H+1;i++){
        dp[0][i] = UP(i,M[0].first)*M[0].second;
  //      cout << "dp[0][" << i << "] = " << dp[0][i] << endl;
    }
    for(int i = 1;i < N;i++){
        for(int j = 0;j < H;j++){
            dp[i][j+1] = min(dp[i][max(j+1-M[i].first,0)]+M[i].second,dp[i-1][j+1]);
 //           cout << "dp[" << i << "][" << j << "] = " << dp[i][j] << endl;
        }
    }
    cout << dp[N-1][H] << endl;
}


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

public class Main {
	public static void main(String args[]) throws IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

		String str[] = br.readLine().split(" ");

		int a = Integer.parseInt(str[0]);
		int b = Integer.parseInt(str[1]);

		if (a >= 10 || b >= 10) {
			System.out.println("-1");
		} else {
			System.out.println(a * b);
		}
	}
}


Measured memory_bytes: 32724
#include <cstdio>
#include <algorithm>
#include <vector>
const int MOD = 1000000007;
int N, a[100001], v[100001], bel[100001], dep[100001], pure[100001], O = 1;
std::vector < int > V[100001];
std::vector < std::vector < int > > cirs;
int main()
{
	scanf("%d", &N);
	for (int i = 1; i <= N; i++)
		scanf("%d", a + i);
	for (int i = 1; i <= N; i++)
		if (!v[i])
		{
			static int way[100001];
			int L = 1;
			v[way[L] = i] = 1;
			while (!v[a[way[L]]])
			{
				v[way[L + 1] = a[way[L]]] = 1;
				L++;
			}
			way[L + 1] = a[way[L]];
			if (v[a[way[L]]] == 2)
				for (int i = L; i; i--)
				{
					bel[way[i]] = bel[way[i + 1]];
					dep[way[i]] = dep[way[i + 1]] + 1;
				}
			else
			{
				int S = std::find(way + 1, way + L + 1, way[L + 1]) - way;
				for (int i = S; i <= L; i++)
				{
					bel[way[i]] = way[i];
					dep[way[i]] = 0;
				}
				for (int i = S - 1; i; i--)
				{
					bel[way[i]] = bel[way[i + 1]];
					dep[way[i]] = dep[way[i + 1]] + 1;
				}
				cirs.push_back({ way + S, way + L + 1 });
			}
			for (int i = 1; i <= L; i++)
				v[way[i]] = 2;
		}
	for (int i = 1; i <= N; i++)
		V[bel[i]].push_back(dep[i]);
	for (int i = 1; i <= N; i++)
	{
		std::sort(V[i].begin(), V[i].end());
		int S = V[i].size();
		for (int j = 0; j < S; j++)
			if (V[i][j] != j)
			{
				puts("0");
				return 0;
			}
	}
	for (auto &cir : cirs)
	{
		for (int &i : cir)
			i = V[i].size() - 1;
		if (int(std::count(cir.begin(), cir.end(), 0)) == int(cir.size()))
			pure[cir.size()]++;
		else
		{
			int *A = cir.data(), L = cir.size();
			for (int i = 0; i < L; i++)
				if (A[i])
				{
					for (int j = 1; j < A[i]; j++)
						if (A[(i - j % L + L) % L])
						{
							puts("0");
							return 0;
						}
					if (!A[(i - A[i] % L + L) % L])
						O = (O + O) % MOD;
				}
		}
	}
	for (int i = 1; i <= N; i++)
	{
		static int f[100001];
		f[0] = 1;
		for (int j = 1; j <= pure[i]; j++)
			f[j] = (f[j - 1] * (i > 1 && (i & 1) ? 2 : 1) + (long long)f[j - 2] * (j - 1) * i) % MOD;
		O = (long long)O * f[pure[i]] % MOD;
	}
	printf("%d\n", O);
	return 0;
}


Measured memory_bytes: 13616
#include<stdio.h>
#include<string.h>
#include<stdlib.h>

typedef struct node *Node;

struct node{
  int key;
  Node right, left, parent;
};

Node root, NIL;

void insert(int k){
  Node y = NIL;
  Node x = root;
  Node z;

  z = (Node)malloc(sizeof(struct node));
  z->key = k;
  z->left = NIL;
  z->right = NIL;

  while(x != NIL){
    y = x;
    if(z->key < x->key){
      x = x->left;
    }
    else{
      x = x->right;
    }
  }
  z->parent = y;
  if(y == NIL){
    root = z;
  }
  else{
    if(z->key < y->key){
      y->left = z;
    }
    else{
      y->right = z;
    }
  }
}

void inorder(Node u){
  if(u == NIL) return;
  inorder(u->left);
  printf(" %d",u->key);
  inorder(u->right);
}
void preorder(Node u){
  if(u == NIL)return;
  printf(" %d",u->key);
  preorder(u->left);
  preorder(u->right);
}

Node find(Node u, int k){
  while(u != NIL && k != u->key){
    if(k < u->key)
      u = u->left;
    else
      u = u->right;
  }
  return u;
}

int main(){
  int n, i, x;
  char com[20];

  scanf("%d", &n);

  for(i = 0; i < n; i++){
    scanf("%s",com);
    if(strcmp(com,"insert") == 0){
      scanf("%d",&x);
      insert(x);
    }
    else if(strcmp(com,"print") == 0){
      inorder(root);
      printf("\n");
      preorder(root);
      printf("\n");
    }
    else if(strcmp(com,"find") == 0){
      scanf("%d",&x);
      Node t = find(root,x);
      if(t != NIL)
	printf("yes\n");
      else
	printf("no\n");
    }
  }

  return 0;
}



Measured memory_bytes: 20440
#include <stdio.h>
#include <algorithm>
#include <string>
#include <vector>
#include <numeric>



const int mod = 1000000007;

int main() {
	int A, B, c;
	scanf("%d %d %d", &A, &B, &c);
	if (c <= A + B + 1) {
		printf("%d", c + B);
	}
	else {
		printf("%d", A + 2 * B + 1);
	}
}





Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll INF=1LL<<60;
const int maxn=500010;
ll ans=0,a[maxn];
int n,m,fa[maxn];
pair<ll,pair<int,int> >e[maxn];
int find(int x) {
	if (fa[x]==x) return x;
	return (fa[x]=find(fa[x]));
}
int nxt(int x) {
	if (x<n) return x+1; else return 1;
}
int main() {
	//freopen("1.txt","r",stdin);
	scanf("%d %d",&n,&m);
	for (int i=1;i<=n;i++) a[i]=INF;
	for (int i=1;i<=m;i++) {
		int x,y,z; scanf("%d %d %d",&x,&y,&z); x++; y++;
		e[i]=make_pair(z,make_pair(x,y));
		a[x]=min(a[x],z+1LL);
		a[y]=min(a[y],z+2LL);
	}
	for (int ii=1;ii<=5;ii++)
	for (int i=1;i<=n;i++)
		a[nxt(i)]=min(a[nxt(i)],a[i]+2);
	for (int i=1;i<=n;i++)
		e[m+i]=make_pair(a[i],make_pair(i,nxt(i)));
	sort(e+1,e+(n+m+1));
	for (int i=1;i<=n;i++) fa[i]=i;
	for (int i=1;i<=m+n;i++) {
		int x=e[i].second.first,y=e[i].second.second;
		x=find(x); y=find(y);
		if (x==y) continue;
		ans+=e[i].first; fa[x]=y;
	}
	printf("%lld\n",ans);
	return 0;
}

Measured memory_bytes: 15616
#include <bits/stdc++.h>
#define fi first
#define se second
#define pii pair<int,int>
#define mp make_pair
#define pb push_back
#define space putchar(' ')
#define enter putchar('\n')
#define MAXN 100005
#define eps 1e-12
//#define ivorysi
using namespace std;
typedef long long int64;
typedef unsigned int u32;
typedef double db;
template<class T>
void read(T &res) {
    res = 0;T f = 1;char c = getchar();
    while(c < '0' || c > '9') {
        if(c == '-') f = -1;
        c = getchar();
    }
    while(c >= '0' && c <= '9') {
        res = res * 10 + c - '0';
        c = getchar();
    }
    res *= f;
}
template<class T>
void out(T x) {
    if(x < 0) {x = -x;putchar('-');}
    if(x >= 10) {
        out(x / 10);
    }
    putchar('0' + x % 10);
}
struct node {
    int to,next;
}E[MAXN * 2];
int head[MAXN],sumE,N;
int dep[MAXN],fa[MAXN],siz[MAXN];
void add(int u,int v) {
    E[++sumE].to = v;
    E[sumE].next = head[u];
    head[u] = sumE;
}
void dfs(int u) {
    dep[u] = dep[fa[u]] + 1;
    siz[u] = 1;
    for(int i = head[u] ; i ; i = E[i].next) {
        int v = E[i].to;
        if(v != fa[u]) {
            fa[v] = u;

            dfs(v);
            siz[u] += siz[v];
        }
    }
}
void Solve() {
    read(N);
    int u,v;
    for(int i = 1 ; i < N ; ++i) {
        read(u);read(v);
        add(u,v);add(v,u);
    }
    dfs(1);
    int t = dep[N] / 2 - 1;
    u = N;
    while(t--) {u = fa[u];}
    if(N - siz[u] > siz[u]) puts("Fennec");
    else puts("Snuke");
}
int main() {
#ifdef ivorysi
	freopen("f1.in","r",stdin);
#endif
    Solve();
}


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

UL E[9][9]={
 {0,1,0,1,0,0,0,0,0},
 {1,0,1,0,1,0,0,0,0},
 {0,1,0,0,0,1,0,0,0},
 {1,0,0,0,1,0,1,0,0},
 {0,1,0,1,0,1,0,1,0},
 {0,0,1,0,1,0,0,0,1},
 {0,0,0,1,0,0,0,1,0},
 {0,0,0,0,1,0,1,0,1},
 {0,0,0,0,0,1,0,1,0}
};

int main() {
 set<string> G;
 string S(9,' '); rep(i,9) scanf(" %c",&S[i]);
 queue<pair<string,UL>> Q; Q.push({S,0});
 while(Q.size()){
  string P=move(Q.front().first);
  UL d=Q.front().second;
  UL p=P.find('0');
  Q.pop();
  if(P=="123456780"){cout<<d<<endl; break;}
  if(G.count(P)) continue;
  G.insert(P);
  rep(j,9) {
   if(!E[p][j]) continue;
   swap(P[p],P[j]);
   Q.push({P,d+1});
   swap(P[p],P[j]);
  }
 }
 return 0;
}



Measured memory_bytes: 21372
#include<algorithm>
#include<complex>
#include<ctype.h>
#include<iomanip>
#include<iostream>
#include<map>
#include<math.h>
#include<numeric>
#include<queue>
#include<set>
#include<stack>
#include<stdio.h>
#include<string>
#include<string>
#include<vector>

using namespace std;
typedef long long ll;

#define FOR(i,a,b) for(ll i=(a);i<(b);++i)
#define ALL(v) (v).begin(), (v).end()
#define p(s) cout<<(s)<<endl
#define p2(s, t) cout << (s) << " " << (t) << endl
#define br() p("")
#define pn(s) cout << (#s) << " " << (s) << endl
#define p_yes() p("Yes")
#define p_no() p("No")

template < typename T >
void vprint(T &V){
	for(auto v : V){
    	cout << v << " ";
	}
	cout << endl;
}

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

const ll mod = 1e9 + 7;
const ll inf = 1e18;

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

    // input
    string s;
    cin >> s;
    sort(ALL(s));

    if(s=="abc"){
        p_yes();
    }else{
        p_no();
    }
    
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    int N, K;
    cin >> N >> K;
    vector<int> V(N);
    for (auto& v:V) {
        cin >> v;
    }
    int ans = INT32_MIN, remain;
    for (int l = 0; l<=min(K, N); l++) {
        for (int r = 0; l+r<=min(K, N); r++) {
            vector<int> Tmp;
            for (int i = 0; i<l; i++) {
                Tmp.push_back(V[i]);
            }
            for (int i = 1; i<=r; i++) {
                Tmp.push_back(V[N-i]);
            }
            sort(Tmp.rbegin(), Tmp.rend());
            remain = K-l-r;
            while (remain-- && !Tmp.empty() && Tmp.back() < 0) {
                Tmp.pop_back();
            }
            ans = max(ans, accumulate(Tmp.begin(), Tmp.end(), 0));
        }
    }
    printf("%d\n", ans);
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>

using namespace  std;

int main(void){
  int n, q;
  string s;

  cin >> n >> q;

  cin >> s;

  int acc[100000];
  acc[0] = 0;
  for (int i = 1; i < s.size(); i++){
    if (s[i-1] == 'A' && s[i] == 'C'){
      acc[i] = acc[i-1] + 1;
    }
    else
      acc[i] = acc[i-1];
  }


  for (int i = 0; i < s.size(); i++){
    cerr << acc[i] << endl;
  }


  int l, r;

  for (int i = 0; i < q; i++){
    cin >> l >> r;
    l--; r--;

    if (l == 0){
      cout << acc[r] << endl;
    }
    else {
      cout << acc[r] - acc[l] << endl;
    }
  }

}


Measured memory_bytes: 1408
n=gets.to_i
a=gets.split.map(&:to_i)
INF=10**9+7
result=0
a_sum=a.inject(&:+)

s=[]
s[0]=a_sum
for i in 0..a.length-1
    s[i+1]=s[i]-a[i]
end

result=0
for i in 0..a.length-1
    result+=a[i]*s[i+1]
    result%=INF
end
p result

Measured memory_bytes: 35268
#pragma region Header
#ifdef DEBUG
#include "debug.hpp"
#else
#define debug(...)
#define IFD(...)
#ifndef NDEBUG
#define NDEBUG
#endif
#endif
#include <utility>
#include <cstdint>
#include <cmath>
#include <cassert>
#include <vector>
#include <array>
#include <deque>
#include <queue>
#include <stack>
#include <tuple>
#include <set>
#include <map>
#include <unordered_map>
#include <bitset>
#include <string>
#include <functional>
#include <algorithm>
#include <numeric>
#include <stdexcept>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <boost/hana/functional/fix.hpp>
using boost::hana::fix;
using namespace std;
using i32 = int32_t;
using i64 = int64_t;
using u32 = uint32_t;
using u64 = uint64_t;
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define repd(i, n) for (int i = (n)-1; i >= 0; --i)
#define FOR(i, a, b) for (int i = (a); i <= (b); ++i)
#define FORD(i, b, a) for (int i = (b); i >= (a); --i)
template <typename T>
int SZ(T const &x)
{
    return static_cast<int>(x.size());
}
template <class T>
bool chmax(T &a, T const &b)
{
    if (a < b)
    {
        a = b;
        return true;
    }
    return false;
}
template <class T>
bool chmin(T &a, T const &b)
{
    if (b < a)
    {
        a = b;
        return true;
    }
    return false;
}
#pragma endregion

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    cout << fixed << setprecision(15);

    int n;
    cin >> n;
    int tak, aok;
    cin >> tak >> aok;
    --tak;
    --aok;
    vector adjs(n, vector<int>());
    rep(i, n - 1)
    {
        int a, b;
        cin >> a >> b;
        --a;
        --b;
        adjs[a].push_back(b);
        adjs[b].push_back(a);
    }

    vector ht(n, 0);
    vector parent(n, -1);
    auto dfs = fix([&](auto self, int u, int pa) -> int {
        parent[u] = pa;
        for (auto ch : adjs[u])
        {
            if (ch == pa) {
                continue;
            }
            int h = self(ch, u);
            chmax(ht[u], h + 1);
        }
        return ht[u];
    });
    dfs(aok, -1);
    debug(ht);

    int dist = 0;
    {
        int u = tak;
        while (u != aok)
        {
            u = parent[u];
            ++dist;
        }
    }
    debug(dist);

    // 距離d, takから端点までl のとき tak先行の答え
    auto calc = [&](int d, int l) -> int {
        if (d == 0) { return 0; }
        return l + d - 1;
    };

    int ans = -1;
    int u = tak;
    int offset = 0;
    while (dist >= 0)
    {
        debug(u, calc(dist, ht[u]) + offset);
        chmax(ans, calc(dist, ht[u]) + offset);

        u = parent[u];
        dist -= 2;
        ++offset;
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 21100
#include <stdio.h>
#include <math.h>

int main(void){
  int k, n;
  scanf("%d %d", &n, &k);
  int a[n+1];
  a[0]=0;
  int i, j;
  for(i=1; i<n+1; i++){
    scanf("%d", &a[i]);
  }
  for(i=1; i<n-k+1; i++){
    if(a[i] < a[k+i]){
      printf("Yes\n");
    }else{
      printf("No\n");
    }
  }
  return 0;
}

Measured memory_bytes: 2428
#include <iostream>
#include <string>

using namespace std;
int main() {
	int n;
	string s;

	int right_count = 0;
	cin >> n;
	cin >> s;
	int short_count = 0;

	for(char c : s) {
		if (c == '(') {
			right_count++;
			continue;
		}
		if (c == ')') {
			if (right_count > 0) {
				right_count--;
				continue;
			}
			short_count++;

		}
	}

	string left = string(short_count,'('); 
	string right = string(right_count,')');


	cout << left << s << right << endl;


	return 0;
}

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

int main() {
    int x, y, z;
    cin >> x >> y >> z;
    cout << z << " " << x << " " << y << endl;
}

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

int main() {
    int n;
    cin >> n;
    int a[n];
    for (int &i : a) cin >> i;
    int T;
    cin >> T;
    while (T--) {
        int t;
        cin >> t;
        cout << (lower_bound(a, a + n, t) - a) << endl;
    }
    return 0;
}


Measured memory_bytes: 3492
use std::io::*;
use std::str::FromStr;

struct Scanner<R: Read> {
    reader: R,
}

#[allow(dead_code)]
impl<R: Read> Scanner<R> {
    fn new(reader: R) -> Scanner<R> {
        Scanner { reader: reader }
    }

    fn safe_read<T: FromStr>(&mut self) -> Option<T> {
        let token = self.reader.by_ref().bytes().map(|c| c.unwrap() as char)
            .skip_while(|c| c.is_whitespace())
            .take_while(|c| !c.is_whitespace())
            .collect::<String>();
        if token.is_empty() {
            None
        } else {
            token.parse::<T>().ok()
        }
    }

    fn read<T: FromStr>(&mut self) -> T {
        if let Some(s) = self.safe_read() {
            s
        } else {
            writeln!(stderr(), "Terminated with EOF").unwrap();
            std::process::exit(0);
        }
    }
}

fn main() {
    let cin = stdin();
    let cin = cin.lock();
    let mut sc = Scanner::new(cin);

    let mut cnt = [0; 256];
    while let Some(s) = sc.safe_read::<String>() {
        for c in s.bytes().map(|c| c as usize) {
            cnt[c] += 1;
        }
    }
    for c in b'a'..b'z'+1 {
        println!("{} : {}", c as char, cnt[c as usize] + cnt[c as usize ^ 32]);
    }
}



Measured memory_bytes: 5024
#include <iostream>
#include <cstdio>
#include <vector>
#include <string>
#include <numeric>
#include <algorithm>
#include <cmath>
#include <functional>
#include <map>
#include <set>

#define INF 1000000000;
#define MOD 1000000007;
typedef long long ll;
using namespace std;

int main()
{
    int N; cin >> N;
    map<int, int> dict;
    for (int i = 0; i < N; i++) {
        int a; cin >> a;
        dict[a - 1]++;
        dict[a]++;
        dict[a + 1]++;
    }

    int ans = 1;
    for (auto d : dict) {
        ans = max(ans, d.second);
    }
    cout << ans << endl;
}



Measured memory_bytes: 4736
using Yorukatsu039.Questions;
using Yorukatsu039.Extensions;
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;

namespace Yorukatsu039.Questions
{
    /// <summary>
    /// ARC100 C
    /// </summary>
    public class QuestionD : AtCoderQuestionBase
    {
        public override IEnumerable<object> Solve(TextReader inputStream)
        {
            var n = inputStream.ReadInt();
            var a = inputStream.ReadLongArray();
            for (int i = 0; i < a.Length; i++)
            {
                a[i] -= i;
            }
            Array.Sort(a);
            yield return a.Sum(i => Math.Abs(i - a[a.Length / 2]));
        }
    }
}


namespace Yorukatsu039
{
    class Program
    {
        static void Main(string[] args)
        {
            IAtCoderQuestion question = new QuestionD();    // 問題に合わせて書き換え
            var answers = question.Solve(Console.In);
            foreach (var answer in answers)
            {
                Console.WriteLine(answer);
            }
        }
    }
}

#region Base Classes

namespace Yorukatsu039.Questions
{

    public interface IAtCoderQuestion
    {
        IEnumerable<object> Solve(string input);
        IEnumerable<object> Solve(TextReader inputStream);
    }

    public abstract class AtCoderQuestionBase : IAtCoderQuestion
    {
        public IEnumerable<object> Solve(string input)
        {
            var stream = new MemoryStream(Encoding.Unicode.GetBytes(input));
            var reader = new StreamReader(stream, Encoding.Unicode);

            return Solve(reader);
        }

        public abstract IEnumerable<object> Solve(TextReader inputStream);
    }

}

#endregion

#region Extensions

namespace Yorukatsu039.Extensions
{
    internal static class TextReaderExtensions
    {
        internal static int ReadInt(this TextReader reader) => int.Parse(ReadString(reader));
        internal static long ReadLong(this TextReader reader) => long.Parse(ReadString(reader));
        internal static double ReadDouble(this TextReader reader) => double.Parse(ReadString(reader));
        internal static string ReadString(this TextReader reader) => reader.ReadLine();

        internal static int[] ReadIntArray(this TextReader reader, char separator = ' ') => ReadStringArray(reader, separator).Select(int.Parse).ToArray();
        internal static long[] ReadLongArray(this TextReader reader, char separator = ' ') => ReadStringArray(reader, separator).Select(long.Parse).ToArray();
        internal static double[] ReadDoubleArray(this TextReader reader, char separator = ' ') => ReadStringArray(reader, separator).Select(double.Parse).ToArray();
        internal static string[] ReadStringArray(this TextReader reader, char separator = ' ') => reader.ReadLine().Split(separator);
    }
}

#endregion

Measured memory_bytes: 30940
import java.util.Scanner;

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


Measured memory_bytes: 28252
#include <stdio.h>
#include <string.h>
#define N 100005

int s[N];
char a[N];

int read()
{
	char c;
	while((c = getchar()) < 48 || c > 57);
	int x = c - 48;
	while((c = getchar()) > 47 && c < 58) x = x * 10 + c - 48;
	return x;
}

void write(int x)
{
	if(x < 10){
		putchar(x + 48);
		return;
	}
	write(x / 10);
	putchar(x % 10 + 48);
}

int main()
{		
	int i, j, n, x, q, y;
	
	n = read(), q = read();
	scanf("%s", a + 1);	
	for(s[j = 1] = 0, i = 2; i <= n; j = i++){
		s[i] = s[j] + (a[i] == 'C' && a[j] == 'A');
	}
	while(q--){
		x = read(), y = read();
		write(s[y] - s[x]), puts("");
	}
		
	return 0;
}

Measured memory_bytes: 1280
#include<stdio.h>
#include<algorithm>
#include<string.h>
using namespace std;
int main()
{
	int i;
	char a[10],s[4][10]={"Sunny","Cloudy","Rainy","Sunny"};
	scanf("%s",a);
	for(i=0;i<3;i++){
		if(strcmp(a,s[i])==0){
			printf("%s\n",s[i+1]);
		}
	}
	return 0;
}

Measured memory_bytes: 1604
#include "bits/stdc++.h"
#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##_len=(b);i<i##_len;++i)
#define BUGAVOID(x) x
#define rep(...) BUGAVOID(_overload3(__VA_ARGS__,repi,_rep,_rep)(__VA_ARGS__))
#define all(c) c.begin(),c.end()
#define mp make_pair
#define write(x) cout<<(x)<<"\n"
using namespace std; typedef long long ll;
typedef vector<int> vi; typedef vector<ll> vll; template<class T>using vv = vector<vector<T>>;
template<class T>vv<T> vvec(size_t n, size_t m, T v) { return vv<T>(n, vector<T>(m, v)); }
template<class T>bool chmax(T& a, const T& b) { return a < b ? a = b, 1 : 0; }
template<class T>bool chmin(T& a, const T& b) { return b < a ? a = b, 1 : 0; }
constexpr int INF = 1 << 28, MOD = 1e9 + 7; constexpr ll LINF = 1ll << 60; constexpr double EPS = 1e-6;
struct aaa { aaa() { cin.tie(0); ios::sync_with_stdio(0); }; }aaaa;

struct CombinationNumber {
    vector<vector<ll>> dat;
    CombinationNumber() {}
    CombinationNumber(int n) {
        dat.resize(n + 1, vector<ll>(n + 1, 0));
        dat[0][0] = 1;
        for (int i = 1; i <= n; ++i) {
            dat[i][0] = dat[i][i] = 1;
            for (int j = 1; j <= i / 2; ++j) {
                dat[i][j] = dat[i][i - j] = (dat[i - 1][j - 1] + dat[i - 1][j]);
            }
        }
    }
    vector<ll> & operator [](int i) { return dat[i]; }
};

int N, A, B;
vll v;
CombinationNumber c(50);

int main() {
    cin >> N >> A >> B;
    v.resize(N);
    rep(i, N) cin >> v[i];

    sort(all(v));
    reverse(all(v));

    double avg = accumulate(v.begin(), v.begin() + A, (ll)0) * 1.0 / A;
    printf("%.9f\n", avg);

    if (abs(v[0] - avg) < EPS) {
        // v[0] == v[A-1]
        int cnt_avg = 0;
        rep(i, N) {
            if (abs(v[i] - avg) < EPS) cnt_avg++;
        }

        ll ans = 0;
        rep(i, A, B + 1) {
            ans += c[cnt_avg][i];
        }

        printf("%ld\n", ans);
    }
    else {
        int cnt_vA = count(v.begin(), v.begin() + A, v[A - 1]);
        int total_cnt_vA = count(all(v), v[A - 1]);

        printf("%ld\n", c[total_cnt_vA][cnt_vA]);
    }
}

Measured memory_bytes: 384
#include <cstdio>
#include <vector>
#include <functional>
#include <algorithm>
using namespace std;

#define MAX 100100
#define FOR(i, a, b) for(int i = (a); i < (b); i++)

int main() {
	int n; scanf("%d", &n);
	int E[MAX] = { 0 }, O[MAX] = { 0 };

	FOR(i, 0, n / 2) { 
		int s, t; scanf("%d %d", &s, &t); E[s]++; O[t]++;
	}

	vector<pair<int, int>> even, odd;
	FOR(i, 0, MAX) { 
		even.push_back(make_pair(E[i], i)); 
		odd.push_back(make_pair(O[i], i));
	}

	sort(even.begin(), even.end(), greater<pair<int, int>>());
	sort(odd.begin(), odd.end(), greater<pair<int, int>>());

	if (even[0].second == odd[0].second) {
		int ans2 = n - (even[0].first + odd[1].first), ans3 = n - (even[1].first + odd[0].first);
		printf("%d\n", ans2 < ans3 ? ans2 : ans3);
	}
	else {
		printf("%d\n", n - (even[0].first + odd[0].first));
	}

	return 0;
}

Measured memory_bytes: 2804
#include<iostream>
int h,w,a,r,P,Q,i,p,mp[26];
main(){
	std::cin>>h>>w;
	for(i=0;i<h;i++){std::string s;std::cin>>s;for(auto c:s)mp[c-'a']++;}
	for(p:mp){if(p%2)P++;p-=p%2;if(p%4==2)Q++;}
	a=h*w%2,r=h%2*(w/2)+w%2*(h/2);puts((P!=a||Q>r||(r-Q)%2)?"No":"Yes");
}

Measured memory_bytes: 256
#include <stdio.h>
#define ll long long
#define rep(i,l,r)for(ll i=(l);i<(r);i++)
#define INF ((1LL<<62)-(1LL<<31))
#define min(p,q)((p)<(q)?(p):(q))

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#define ll long long
#define rep(i,l,r)for(ll i=(l);i<(r);i++)
#define repp(i,l,r,k)for(ll i=(l);i<(r);i+=(k))
#define INF ((1LL<<62)-(1LL<<31))
#define max(p,q)((p)>(q)?(p):(q))
#define min(p,q)((p)<(q)?(p):(q))
#define bit(n,m)(((n)>>(m))&1)
int upll(const void*a, const void*b){return*(ll*)a<*(ll*)b?-1:*(ll*)a>*(ll*)b?1:0;}
int downll(const void*a, const void*b){return*(ll*)a<*(ll*)b?1:*(ll*)a>*(ll*)b?-1:0;}
void sortup(ll*a,int n){qsort(a,n,sizeof(ll),upll);}
void sortdown(ll*a,int n){qsort(a,n,sizeof(ll),downll);}
ll pom(ll a,ll n,int m){ll x=1;for(a%=m;n;n/=2)n&1?x=x*a%m:0,a=a*a%m;return x;}
//#define MOD 998244353
#define MOD 1000000007
#define invp(a,p)pom(a,p-2,p)


//sからtへの最大流 O(E flow)を横着してO(VV flow)
//辺のコストはcapa
#define VMAX 110
int vcnt;
int foodoflag[VMAX];
int resflow[VMAX][VMAX];

int foododfs(int s,int t){
	if(s==t)return 1;
	foodoflag[s]=1;
	rep(i,0,vcnt)if(!foodoflag[i]&&resflow[s][i]>0){
		if(foododfs(i,t)){
			resflow[s][i]--;
			resflow[i][s]++;
			return 1;
		}
	}
	return 0;
}
int foodo(int s,int t){
	int ans=0;
	while(foododfs(s,t)){
		ans++;
		rep(i,0,vcnt)foodoflag[i]=0;
	}
	return ans;
}
#undef VMAX

int main(){
    ll ecnt;
    scanf("%lld%lld",&vcnt,&ecnt);
    rep(i,0,ecnt){
        ll a,b,c;
        scanf("%lld%lld%lld",&a,&b,&c);
        resflow[a][b]=c;
    }
	//maxflowは(max c)|E|/2≒5e6なのでTLEするはず
    printf("%lld\n",foodo(0,vcnt-1));
}


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

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

	int a, b, c;
	cin >> a >> b >> c;

	if (a > b) swap(a, b);
	if (a > c) swap(a, c);
	if (b > c) swap(b, c);

	cout << (b - a) / 2 + ((b - a) % 2 == 1 ? 2 : 0) + (c - b) << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <map>

int main(){
	std::map<char, char> substitute_s, substitute_t;
	std::string s,t;

	std::cin >> s >> t;

	std::map<char,char>::const_iterator itr_s, itr_t;
	for( int len=s.length(), i=0; i<len; ++i ){
		itr_s = substitute_s.find(s[i]);
		if( itr_s != substitute_s.end() ){
			if( itr_s -> second != t[i] ){
				std::cout << "No" << std::endl;
				return 0;
			}
		}
		substitute_s.insert( std::make_pair( s[i], t[i] ));

		itr_t = substitute_t.find(t[i]);
		if( itr_t != substitute_t.end() ){
			if( itr_t -> second != s[i] ){
				std::cout << "No" << std::endl;
				return 0;
			}
		}
		substitute_t.insert( std::make_pair( t[i], s[i] ));
	}

	std::cout << "Yes" << std::endl;
}


Measured memory_bytes: 1020
use proconio::{input, fastout};
use num_traits::pow;

#[fastout]
fn main() {
  input!{
    A: i32,
    B: i32,
    C: i32,
    K: i32
  }
  let mut ans: bool = false;
  for i in 0..(K+1){
    for j in 0..(K+1){
      for k in 0..(K+1){
        if i+j+k <= K && A*pow(2,i as usize) < B*pow(2,j as usize) && B*pow(2,j as usize) < C*pow(2,k as usize) {
            ans = true; 
        }          
      }  
    }
  }
  println!("{}",if ans {"Yes"} else {"No"} );
}


Measured memory_bytes: 2180
import java.io.IOException;
import java.math.BigInteger;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.LinkedList;
import java.util.List;
import java.util.PriorityQueue;
import java.util.Scanner;

public class Main {
	
	final static int SIZE = 1501;
	
	public static void main(String[] args) {
		final Scanner sc = new Scanner(System.in);
		
		BigInteger[] fact = new BigInteger[SIZE + 1];
		
		for(int i = 0; i <= SIZE; i++){
			if(i == 0){
				fact[i] = new BigInteger(1 + "");
			}else{
				fact[i] = fact[i-1].multiply(new BigInteger(i + ""));
			}
		}
		
		final int n = sc.nextInt();
		
		final BigInteger ans = fact[n+1].add(new BigInteger("2"));
		System.out.println(ans);
		
		for(int i = 0; i < n; i++){
			System.out.println(i + 2);
		}
		
	}

}

Measured memory_bytes: 26548