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

int main() {
	int A, B, C, X;
	cin >> A >> B >> C >> X;
	int pat = 0;
	for (int i = 0;i <= A;i ++) {
		for (int j = 0;j <= B;j ++) {
			if (X - 500 * i - 100 * j >= 0 && X - 500 * i - 100 * j <= C * 50) pat ++;
		}
	}
	cout << pat;
	return 0;
}
/*
31536000のコメント解説欄
ここテンプレで用意してるから、A問題とかだとこの先空欄の危険あり

まず、AとBの枚数を決め打ちする
この時、Cの枚数は(X-500A-100B)/50と確定できるので、0以上C以下なら大丈夫
後は全てのA,Bについて0以上C以下か調べれば良い
計算量はO(AB)、数学的工夫すればもっと速いけど別にそういうことをする必要はないよ
*/

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

using namespace std;
using ll =long long;

#define SORT(a) sort((a).begin(),(a).end())
#define rSORT(a) reverse((a).begin(),(a).end())
#define For(i, a, b)    for(int i = (a) ; i < (b) ; ++i)
#define rep(i, n)       For(i, 0, n)
#define debug(x)  cerr << #x << " = " << (x) << endl;
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
void coY() {cout <<"Yes"<<endl;}
void coN(){cout <<"No"<<endl;}

const ll INF = 1LL << 60;

//Write From this Line

const int mod = 1e9+7;
int main()
{
	int k , s ;
	cin >> k >> s ;
	//二重ループ

	int ans = 0; 
	rep(i,k+1){
		rep(j,k+1){
			int now = i + j ;
			if( 0 <= s-  now && s - now <= k ){
				ans ++ ;
			}
		}
	}
	cout << ans << endl;
}


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

using namespace std;
typedef pair <int, int> pii;
#define pb push_back
#define mp make_pair
#define ll long long
#define PI acos(-1)

int main() {
    int n, x;
    cin >> n;
    int a[200001] = {0};
    for(int i = 2; i <= n; i++){
        cin >> x;
        a[x]++;
    }
    for(int i = 1; i <= n; i++)
        cout << a[i] << endl;
    return 0;
}


Measured memory_bytes: 4404
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<math.h>
#include<iomanip>
#include<set>
#include<numeric>
#include<cstring>
#include<cstdio>
#include<functional>
#include<bitset>
#include<limits.h>
#include<cassert>
#include <fstream>
#include <time.h>
#include <iterator>
#include<random>



#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define REVERSE(v,n) reverse(v,v+n);
#define VREVERSE(v) reverse(v.begin(), v.end());
#define ll long long
#define pb(a) push_back(a)
#define m0(x) memset(x,0,sizeof(x))
#define print(x) cout<<x<<endl;
#define pe(x) cout<<x<<" ";
#define lb(v,n) lower_bound(v.begin(), v.end(), n);
#define ub(v,n) upper_bound(v.begin(), v.end(), n);
#define int long long
#define all(x) (x).begin(), (x).end()
using namespace std;

int MOD = (ll)1000000000 + 7;
const ll INF = 1e17;
const double pi = acos(-1);
const double EPS = 1e-10;
typedef pair<int, int>P;
const int MAX = 500050;


string S;
bool check(string S) {
	int n = S.size();

	if (S[1] == '0' || S[n - 2] == '0')return false;
	REP(i, n) {
		if (S[i] != S[n - i-1]) {
			return false;
		}
	}
	return true;
}
vector<int>G[100010];
vector<int>v;
signed main() {
	cin.tie(0);
	ios::sync_with_stdio(false);

	cin >> S;
	S = "0" + S;

	int N = S.size();
	if (!check(S)) {
		print(-1); return 0;
	}
	
	REP(i, N) {
		if (S[i] == '1') {
			v.pb(i);
		}
	}
	int M = v.size();
	REP(i, M) {
		G[i].pb(i + 1);
	}
	int cnt = 1, nx = M + 1;
	REP(i, M) {
		int cnt2 = 0;
		REP(j, v[i] - cnt) {
			G[i].pb(nx);
			nx++, cnt2++;
		}
		cnt += cnt2;
		cnt++;
	}
	REP(i, N + 1) {
		for (auto x : G[i]) {
			pe(i + 1)print(x + 1);
		}
	}
}

Measured memory_bytes: 7780
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
#define all(x) (x).begin(),(x).end()
#define pb push_back
#define str to_string
#define endl "\n"
#define PI 3.141592653589
using namespace std;
using lint = long long;
template <class T>ostream &operator<<(ostream &o,const vector<T>&v)
{o<<"{";for(int i=0;i<(int)v.size();i++)o<<(i>0?", ":"")<<v[i];o<<"}";return o;}

//AC(*'ω'*)AC(*'ω'*)AC(*'ω'*)AC(*'ω'*)AC(*'ω'*)AC(*'ω'*)AC
int main(){
    int a,b,c;cin>>a>>b>>c;
    cout<<(a-b+1)*(a-c+1)<<endl;
}


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

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

int main() {
  int n, ans = 1;
  cin >> n;
  for (int i = 1; pow(2, i) <= n; ++i) ans = pow(2, i);

  cout << ans << endl;
  return 0;
}


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

using namespace std;

using ll = long long;

int main() {
   ll N, M, K;
   cin >> N >> K;
   M = N / K;
   ll ans = M * M * M;
   if (K % 2 == 0) {
      M = (N + (K / 2)) / K;
      ans += (M * M * M);
   }
   cout << ans << "\n";
   return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
#define all(x) (x).begin(),(x).end()
#define pll pair<ll,ll>
#define rep(i,n) for(int i=0;i<n;i++) 
const ll INF = 1LL<<60;
const ll mod = (int)1e9 + 7;

int main() {
    //ll N; cin >> N;
    //ll N,M; cin >> N >> M;
    //string S; cin >> S;
    //ll H,W; cin >> H >> W;
    int N; cin >> N;
    ll H[N];
    int mx=0;
    rep(i,N){
        cin >> H[i];
    }
    int tmp=0;
    rep(i,N){
        if(H[i+1]<=H[i] && i!=N-1){
          tmp++;
          cerr << i;
        }
        else{
            chmax(mx,tmp);
            tmp=0;
        }
      cerr << tmp;
    }
    cout << mx;

}

/*



 */



Measured memory_bytes: 1024
var input = require('fs').readFileSync('/dev/stdin', 'utf8');
var str = input.trim();
var ans = "";
for(var j=0;j<=9;j++){
   var arr = str.replace(/\?/,j).split("").map(Number).reverse();
   var sum = 0;
   for(var i=1;i<=6;i++) sum+=arr[i]*(i+1);
   for(var i=7;i<=11;i++)sum+=arr[i]*(i-5);
   var p =11-(sum%11);
   if(sum%11<=1)p=0;
   ans += (p==arr[0])? j : "";
}
if(ans.length==1)console.log(ans[0]);
else console.log("MULTIPLE");


Measured memory_bytes: 15204
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <cmath>
#include <queue>
#define ll long long
#define mod 1000000007
#define pii pair<int, int>
#define fr(n) for (int i = 0; i < n; i++)
#define fr1(n) for (int i = 1; i <= n; i++)
using namespace std;

int main() {
    string s, t, v = "}";
    cin >> s >> t;
    fr(s.length() - t.length() + 1) {
        bool y = 0;
        string u = s;
        for (int j = i; j < i + t.length(); j++) {
            if (s[j] == '?') u[j] = t[j - i];
            else if (s[j] != t[j - i]) y = 1;
        }
        if (!y) {
            for (int j = 0; j < u.length(); j++) if (u[j] == '?') u[j] = 'a';
            v = min(v, u);
        }
    }
    if (v == "}") cout << "UNRESTORABLE";
    else cout << v;
}


Measured memory_bytes: 256
#!python3

# input
N, K = list(map(int, input().split()))
A = list(map(int, input().split()))


def main():
    d = {}
    for a in A:
        if a in d:
            d[a] += 1
        else:
            d[a] = 1
    
    l = sorted(d.values())
    k = max(0, len(l) - K)
    ans = 0
    for x in l[:k]:
        ans += x
    print(ans)


if __name__ == "__main__":
    main()


Measured memory_bytes: 32184
N,K = map(int,input().split())
def Base_10_to_n(X, n):
    X_dumy = X
    out = ''
    while X_dumy>0:
        out = str(X_dumy%n)+out
        X_dumy = int(X_dumy/n)
    return out
print(len(Base_10_to_n(N,K)))

Measured memory_bytes: 2940
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
int main(){
    int n,q;
    string s;
    cin >> n >> q >> s;
    vector<pair<char,char>> v(q);//呪文を格納
    int l=-1,r=s.size();//lbは左に落ちるゴレムのうち最も右にあるやつ(left border)
    for(int i=0;i < v.size();i++){
        cin >> v.at(i).first >> v.at(i).second;
    }

    reverse(v.begin(),v.end());//逆から実行して、どこまで行くか調べればok(追い越さないので)

    //何回も書くvの要素は置換しておく

    for(int j=0;j < v.size();j++){ 
        
        if(v.at(j).second == 'R'){
            if(r-1 >= 0 && v.at(j).first==s.at(r-1)){
                r--;
            }
            if(l-1>=-1 && v.at(j).first==s.at(l)){
                l--;//すでにいなかったら一つ戻る
            }
        }else{//Lの時
            if(r+1 <= s.size() && v.at(j).first==s.at(r)){
                r++;//既にいない場合
            }
            if(l+1<s.size() && v.at(j).first==s.at(l+1)){
                l++;
            }   
        }
    }
    
        cout << r-l-1 << endl;

}

Measured memory_bytes: 900
#include<bits/stdc++.h>
#define ll long long
#define loop(n) for(ll i = 0; i<n; i++)
#define sort(a) sort(a.begin(), a.end())
using namespace std;

int main(){
    ios::sync_with_stdio(0);
    cin.tie(0);
    
    int s, w;
    cin>>s>>w;
    cout<<(w>=s?"unsafe\n":"safe\n");
    return 0;
}

Measured memory_bytes: 3652
#include<stdio.h>

int main(int argc,char **argv)
{
	double a,b,c,d,e,f;
	double x,y;
	
	while (scanf("%lf %lf %lf %lf %lf %lf",&a,&b,&c,&d,&e,&f) != EOF) {
		y = (c * d - a * f) / (b * d - e * a);
		x = (c - (b * y)) / a;
		
		printf("%.3lf %.3lf\n",x,y);
	}	
	return 0;
}

Measured memory_bytes: 0
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner scanner = null;
		try {
			scanner = new Scanner(System.in);
			String s = scanner.next();
			if (s.contains("AC")) {
				System.out.println("Yes");
				return ;
			}
			System.out.println("No");

		} finally {
			if (scanner != null) {
				scanner.close();
			}
		}
	}
}


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

int main(void){
  int x, h;
  while(cin >> x >> h && x != 0 && h != 0){
    double S = x * sqrt(4 * h * h + x * x) + x * x;
    printf("%.6lf\n", S);
  }
  return 0;
}

Measured memory_bytes: 1192
macro_rules! read_line_to_tuple {
    ( $( $t:ty ),* ) => {{
        let mut input = String::new();
        std::io::stdin().read_line(&mut input).unwrap();
        let mut iter = input.split_whitespace();
        ( $( iter.next().unwrap().parse::<$t>().unwrap() ),* )
    }};
}

fn main() {
    let n = read_line_to_tuple!(usize);
    let d: Vec<(u8, u8)> = {
        (0..n)
            .map(|_| read_line_to_tuple!(u8, u8))
            .collect()
    };

    let mut i = 0;
    while i < n {
        if d[i].0 != d[i].1  {
            i += 1;
            continue;
        }
        let mut j = i + 1;
        while j < n && d[j].0 == d[j].1 {
            j += 1;
        }
        if j - i >= 3 {
            return println!("Yes");
        }
        i = j;
    }
    println!("No");
}

Measured memory_bytes: 2132
n = int(input())
h = list(map(int, input().split()))

count = 0
for i in range(1, 101):
  flag = False
  for j in range(n):
    if h[j] >= i:
      if not flag:
        flag = True
        count += 1
    else:
      if flag:
        flag = False
print(count)

Measured memory_bytes: 3060
import math

a, b = map(int, input().split())

p8min = math.ceil(a * 100 / 8)
p8max = math.ceil((a+1)*100 / 8) - 1

p10min = b * 10
p10max = (b + 1) * 10 - 1

p = max(p8min, p10min)

if p <= p8max and p <= p10max:
    print(p)
else:
    print(-1)


Measured memory_bytes: 3060
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <string>
#include <cstring>
#include <deque>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <cfloat>
#include <climits>
#include <ctime>
#include <cassert>
#include <numeric>
#include <fstream>
#include <functional>
#include <bitset>

using namespace std;
#define int long long int
const int INF = 1001001001001001LL;
const int MOD = 1000000007;

signed main(){
    
    int n; cin >> n;
    map<int, int> m;
    for(int a = 1; a <= n; a++){
        int b = a;
        for(int j = 2; j * j <= b; j++){
            while(b % j == 0){
                m[j]++;
                b /= j;       
            }
        }
        if(b != 1) m[b]++;
    }

    int ans = 1;
    for(auto x : m){
        ans *= (x.second + 1);
        ans %= MOD;
    }
    cout << ans << endl;
    return 0;
}



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

long long int tonum(string str){
  int s=0,e=0;
  for(; e<(int)str.length(); e++){
    if(str[e]=='(') s=e+1;
    if(str[e]==')') break;
  }
  return stoll(str.substr(s,e-s));
}

long long int binop(long long int a, long long int b, char op){
  if(op=='+') return a+b;
  if(op=='-') return a-b;
  if(op=='*') return a*b;
  return -1;
}

long long int calc(string str, int i, int j, int k){
  vector<long long int> nums;
  int s=0;
  int depth=0;
  bool onlynum=true;
  for(int d=0; d<(int)str.length(); d++){
    if(str[d]=='+' || str[d]=='-' || str[d]=='*'){
      onlynum=false;
      if(depth==0){
        if(str[s]=='('){
          nums.push_back( calc(str.substr(s+1, d-s-2), i,j,k));
        }else{
          nums.push_back( calc(str.substr(s,d-s), i,j,k) );
        }
        nums.push_back( str[d] );
        s = d+1;
      }
    }
    if(str[d]=='(') depth++;
    if(str[d]==')') depth--;
  }

  if(onlynum) return tonum(str);
  if(str[s]=='('){
    nums.push_back( calc(str.substr(s+1,(int)str.length()-s-2), i,j,k));
  }else{
    nums.push_back( calc(str.substr(s,(int)str.length()-s), i,j,k) );
  }

  map<char,int> oppr;
  oppr['+']=i;
  oppr['-']=j;
  oppr['*']=k;
  for(int i=0; i<3; i++){
    int nowop=1;
    while(nowop<(int)nums.size()){
      if(oppr[nums[nowop]] == i){
        nums[nowop-1] = binop(nums[nowop-1], nums[nowop+1], (char)nums[nowop]);
        nums.erase(nums.begin()+nowop);
        nums.erase(nums.begin()+nowop);
      }else{
        nowop+=2;
      }
    }
  }

  return nums[0];
}

int main(){
  string str;
  cin >> str;

  long long int ans = -9223372036854775807;
  for(int i=0; i<3; i++){
    for(int j=0; j<3; j++){
      for(int k=0; k<3; k++){
        ans = max(ans, calc(str,i,j,k));
      }
    }
  }
  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 3240
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  vector<int64_t> data(100);  



  data.at(0) = 2;
  data.at(1) = 1;
  for(int i = 2; i <=86 ; i++) {
  data.at(i) = data.at(i-1) + data.at(i-2);
  }
  
   int num = 0;
  
  cin >> num;
  
  cout << data.at(num) << endl;
  
}

Measured memory_bytes: 3580
#define watch5(a,b,c,d,e) cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d << " | "<<#e<<": "<<e<<endl;
#define watch4(a,b,c,d) cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<endl;
#define watch3(a,b,c) cerr <<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<endl;
#define printclock cerr<<"Time : "<<1000*(ld)clock()/(ld)CLOCKS_PER_SEC<<"ms\n";
#define sharingan cerr << "\n-------------------------------------------\n\n";
#define watch2(a,b) cerr <<#a<<": "<<a<<" | "<<#b<<": "<<b<< endl;
#define Yup ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define watch(a) cerr <<#a<<": "<<a<<endl;
#define __gcd(a, b) __algo_gcd(a, b)
#define PI 3.14159265358979323846
#define mod 1000000007
#include<set>
#include<map>
#include<cmath>
#include<stack>
#include<queue>
#include<array>
#include<cstdio>
#include<bitset>
#include<vector>
#include<utility>
#include<sstream>
#include<cstring>
#include <climits>
#include <fstream>
#include<iostream>
#include<iomanip>
#include<algorithm>
#include <unordered_map>
using namespace std;

#define endl "\n"
#define int long long

string s1, s2;
int dp[3001][3001];

int go( int i, int j ){
    if( i == s1.size() || j == s2.size() ) return 0;
    if( dp[i][j] != -1 )return dp[i][j];
    int ans = 0;
    if( s1[i] == s2[j] )ans = 1 + go(i+1, j+1);
    ans = max(ans, go(i+1, j));
    ans = max(ans, go(i, j+1));
    return dp[i][j] = ans;
}

void print(int i, int j, int left ){
    if( i == s1.size() || j == s2.size() || left == 0 ) return;
    if( s1[i] == s2[j] && go(i, j) == left ){
        cout << s1[i];
        print(i+1, j+1, left-1);
    }
    else if( go(i+1, j) == left ){
        print(i+1, j, left);
    }
    else{
        print(i, j+1, left);
    }
}

int32_t main(){
    Yup;
    cin >> s1 >> s2;
    int n = s1.size();
    int m = s2.size();
    for( int i = 0; i <= n; i++ ){
        for( int j = 0; j <= m; j++ ){
            dp[i][j] = -1;
        }
    }
    int l = go(0, 0);
    print(0, 0, l);
}

Measured memory_bytes: 70912
N, Y = map(int, input().split())
find_flag = 0
for i in range(N+1):
    for j in range(N+1-i):
        rest_money = Y - (i*10000 + j*5000)
        k = rest_money // 1000
        if k == (N-i-j):
            find_flag = 1
            print("{} {} {}".format(i, j, k))
            break
    if find_flag == 1:
        break

if find_flag == 0:
    print("-1 -1 -1")

Measured memory_bytes: 3060
#include<cstdio>
#include<vector>
using namespace std;

int Max(int a,int b){
    if(a<b)return b;
    return a;
}

int main(void){
    int n,ans=-1,max;
    scanf("%d",&n);
    for(int i=1;i<=n;i++){
        int cnt=0;
        int m=i;
        while(m>0){
            if(m%2==0){
                m/=2;
                cnt++;
            }else break;
        }
        if(ans<cnt){
            ans=cnt;
            max=i;
        }
    }
    printf("%d\n",max);
    return 0;
}


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

int main()
{
    int a,b,c;
    cin>>a>>b>>c;
    cout<<max(a,max(b,c))-min(a,min(b,c))<<endl;
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<string>
#include<vector>
#include<cstdlib>
#include<queue>
#include<set>
#include<cstdio>

using namespace std;

#define ll long long
#define rep(i, n) for(int i = 0; i < n; i++)
#define P pair<int, int>

typedef vector<int> vec;
typedef vector<vec> mat;

int main(){
    ll r, d, x;
    cin >> r >> d >> x;
    rep(i, 10){
        x = r * x - d;
        cout << x << endl;
    }
}

Measured memory_bytes: 3584
#include <cstdio>
#include <iostream>
#include <string>
#include <vector>
#include <array>
#include <algorithm>
#include <utility>
#include <numeric>
#include <deque>
#include <stack>
#include <queue>
#include <map>
#include <unordered_map>
#include <set>
#include <unordered_set>
#include <cmath>
#include <limits>
#include <cassert>
#include <bitset>
#include <list>
#include <iomanip>
#include <cctype>
#include<chrono>
#include<random>

#define for0(i, N)    for (long long i = 0  ; i <  (N); ++i)
#define for1n(i, N)   for (long long i = 1  ; i <= (N); ++i)
#define for1(i, N)    for (long long i = 1  ; i <  (N); ++i)
#define forn(i, N)    for (long long i = 0  ; i <= (N); ++i)
#define forx(i, N, x) for (long long i = (x); i <  (N); ++i)
#define forl(i, N, x, a) for (long long i = (x), a = 0; a < (N);    \
                              i = (i + 1) % (N), ++a)
#define int long long

template<size_t i>
std::bitset<i> operator++(std::bitset<i> b, signed){
    static_assert(i <= 64, "Cannot cast 64bit int.");
    return b = (unsigned long long)b + 1;
}

template<size_t i>
std::bitset<i> operator++(std::bitset<i> b){
    static_assert(i <= 64, "Cannot cast 64bit int.");
    auto temp = b;
    b++;
    return temp;
}

template<size_t i>
std::bitset<i> operator--(std::bitset<i> b, signed){
    static_assert(i <= 64, "Cannot cast 64bit int.");
    return b = (unsigned long long)b - 1;
}

template<size_t i>
std::bitset<i> operator--(std::bitset<i> b){
    static_assert(i <= 64, "Cannot cast 64bit int.");
    auto temp = b;
    b--;
    return temp;
}

long long constexpr inf = std::numeric_limits<long long>::max();

using namespace std;

typedef long long ll;
typedef long double ld;
typedef priority_queue<ll> pq;
typedef priority_queue<ll,vector<ll>, greater<ll>> pql;
typedef stack<ll> stk;
typedef queue<ll> qu;
typedef pair<ll, ll> pll;
typedef map<ll, ll> mll;
typedef unordered_map<ll, ll> umll;
typedef set<ll> sll;
typedef unordered_set<ll> usll;
typedef vector<ll> vll;
typedef vector<ld> vld;
typedef vector<vector<ll>> vvll;


signed main(void){
    cin.tie(0); ios::sync_with_stdio(false);cout<<fixed<<setprecision(10);
    ll r;

    cin >> r;

    cout << r * 2 * 3.1415 << "\n";

    return 0;
}


Measured memory_bytes: 3800
import Data.List
import qualified Data.ByteString.Char8 as B
import Data.Maybe

main = do
  n <- readLn
  as <- sort . map (fst . fromJust . B.readInteger) . B.words <$> B.getLine
  print (liningUp n as)

liningUp n as
  | odd n && as == lodd = 2 ^ (div n 2) `mod` (10^9+7)
  | even n && as == leven = 2 ^ (div n 2) `mod` (10^9+7)
  | otherwise = 0
  where
    lodd  = take n $ concat $ transpose [[0,2..],[2,4..]]
    leven = take n $ concat $ transpose [[1,3..],[1,3..]]

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

using namespace std;
typedef long long ll;
typedef long double ld;

const int N = 50;

int grid[N+2][N+2];
bool vis[N+2][N+2];

bool checkSides(int i, int j){
	bool ans = false;
	for(int x = -1; x <= 1; x++){
		for(int y = -1; y <= 1; y++){
			if (abs(x-y)==1){
				if (grid[i+x][j+y] == 1){
					ans = true;
					break;
				}
			}
		}
		if (ans) break;
	}
	return ans;
}

int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	int h, w; cin >> h >> w;
	
	memset(grid,0, sizeof(grid));
	memset(vis,false,sizeof(vis));
	
	for(int i = 1; i <= h; i++){
		for (int j = 1; j <= w; j++){
			char ch; cin >> ch;
			grid[i][j] =  ch == '#';
		}
	}
	
	bool ans = true;

	for(int i = 1; i <= h; i++){
		for (int j = 1; j <= w; j++){
			bool temp = true;
			if (grid[i][j] == 1) temp = checkSides(i,j);

			if (!temp) {
				//cout << i << " " << j << " Yes" << endl;
				ans = false;
				break;
			}
		}
		if (!ans) break;
	}
	
	cout << ((ans) ? "Yes" : "No") << endl;
}


Measured memory_bytes: 256
from operator import itemgetter
N=int(input())
arms=[]
for _ in range(N):
    x,l=map(int,input().split())
    a,b=x-l,x+l
    arms.append([a,b])

arms.sort(key=itemgetter(1))

cnt=1
tmp=arms[0][1]
for arm in arms:
    if arm[0]<tmp: continue
    cnt+=1
    tmp=arm[1]

print(cnt)

Measured memory_bytes: 25648
#include <bits/stdc++.h>
#define int long long
#define ld long double
#define fio() ios_base::sync_with_stdio(false); cin.tie(NULL)
#define MOD 1000000007
#define nl '\n'
#define pb push_back
#define mp make_pair

using namespace std;
const int N = 10;
int32_t main()
{
	fio();
	int n,k;
	cin>>n>>k;
	int val[n];
	int dp[n];
	for(int i=0;i<n;i++)
	{
		cin>>val[i];
		dp[i]=100000000000;
	}
	dp[0]=0;
	//dp[1]=abs(val[1]-val[0]);
	for(int i=1;i<n;i++)
		for(int j=1;j<=k && i-j>=0;j++)
			dp[i]=min(dp[i-j]+abs(val[i]-val[i-j]),dp[i]);
	cout<<dp[n-1];
}



Measured memory_bytes: 1920
//http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=DSL_1_A&lang=ja
//互いに素な集合
#include <bits/stdc++.h>
#if LOCAL
#include "dump.hpp"
#else
#define dump(...)
#endif
using namespace std;
using ll=long long;
const ll LINF = 0x1fffffffffffffff;
#define FOR(i,a,b) for(ll i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)
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;}

struct uf_tree {
    std::vector<int> parent;
    int __size;
    uf_tree(int size_) : parent(size_, -1), __size(size_) {}
    void unite(int x, int y) {
        if ((x = find(x)) != (y = find(y))) {
            if (parent[y] < parent[x]) std::swap(x, y);
            parent[x] += parent[y];
            parent[y] = x;
            __size--;
        }
    }
    bool is_same(int x, int y) { return find(x) == find(y); }
    int find(int x) { return parent[x] < 0 ? x : parent[x] = find(parent[x]); }
    int size(int x) { return -parent[find(x)]; }
    int size() { return __size; }
};

int main() {
  ll n,q; cin>>n>>q;
  uf_tree uft(n);
  REP(i,q){
    ll c,x,y; cin>>c>>x>>y;
    if(c==0) uft.unite(x,y);
    else {
      auto ans=uft.is_same(x,y);
      cout<<ans<<endl;
    }
  }
  return 0;
}


Measured memory_bytes: 3156
using namespace std;

using uint = unsigned int;
using ll = long long;
using ull = unsigned long long;
#include <iostream>
#include <string>
#include <cstdio>
#include <algorithm>
#include <vector>
#include <cmath>
#include <climits>
#define all(x) (x).begin(),(x).end()

void solve(){

}
int main(){
    int h,w;

    cin >> h >> w;
    //string s[55];
    vector<string> s(h);
    for (int i = 0; i < h; i++){
        cin >> s[i];
    }

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

    bool can = true;
    for (int i = 0; i < h; i++){
        for (int k = 0; k < w; k++){
            if (s[i][k] != '#'){
                continue;
            }
            int cnt = 0;
            bool found = false;
            for (int p = 0; p < 4; p++){
                const int x = k + dx[p];
                const int y = i + dy[p];
                if (x >= 0 && x < w && y >= 0 && y < h){
                    if (s[y][x] == '#'){
                        found = true;
                    }
                }
            }
            if (found != true){
                cout << "No" << endl;
                exit(0);
            }
        }
    }

    cout << "Yes" << endl;
    /*if (can) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
    */
}


Measured memory_bytes: 256
/*|In The Name Of Allah|*/

#include <bits/stdc++.h>

using namespace std;

const int N = 1e6+5;
const int M = 555;

int main() {
    int a , b;
    cin >> a >> b;
    if(a <= 2*b){
        cout << 0 << endl;
    } else {
        cout << a - 2*b << endl;
    }
}


Measured memory_bytes: 256
#include <stdio.h>
#include <iostream>
#include <iomanip>
#include <limits>
#include <string>
#include <vector>
#include <algorithm>
#include <queue>
#include <stack>
#include <set>
#include <cmath>
#include <map>
#include <tuple>

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


 

int main(){
    
    int n,a,b; cin >> n >> a >> b;
    
    cout <<  min(n*a, b)<< endl;
    



}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(ll (i)=0;(i)<(n);(i)++)
#define repi(i,a,b) for(ll (i)=(a);(i)<(b);(i)++)
#define SIZE_OF_ARRAY(array)    (sizeof(array)/sizeof(array[0]))
typedef long long ll;
using namespace std;
int main(){
  ll n;
  cin >> n;
  ll p[n];
  for(int i=1;i<=n;i++){
  cin >> p[i];
  }
  ll mi = min(p[1],p[2]);
  ll ans = 1;
  for(int i=2;i<=n;i++){
    if(p[i]<=mi){
	ans++;
    }
    mi = min(p[i],mi);
  }
  cout << ans << endl;
  return 0;
  
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
#define N 100005
using namespace std;
string s;
int x[N],n;
int main(){
	cin>>s;
	n=s.size();
	fill(x,x+n,1);
	for(int i=1;i<n;i++){
		if(s[i]=='R'&&s[i-1]=='R'){
			x[i]+=x[i-1];
			x[i-1]=0;
		}
	}
	for(int i=n-2;i>=0;i--){
		if(s[i]=='L'&&s[i+1]=='L'){
			x[i]+=x[i+1];
			x[i+1]=0;
		}
	}
	for(int i=1;i<n;i++){
		if(s[i]=='L'&&s[i-1]=='R'){
			if((x[i]+x[i-1])%2==0)x[i]=x[i-1]=(x[i]+x[i-1])/2;
			else if(x[i]>=x[i-1]){
				if(x[i]%2)x[i]=(x[i]+x[i-1])/2+1,x[i-1]=x[i]-1;
				else x[i]=(x[i]+x[i-1])/2,x[i-1]=x[i]+1;
			}else if(x[i-1]>x[i]){
				if(x[i-1]%2)x[i-1]=(x[i]+x[i-1])/2+1,x[i]=x[i-1]-1;
				else x[i-1]=(x[i]+x[i-1])/2,x[i]=x[i-1]+1;
			}
		}
	}
	for(int i=0;i<n;i++){
		if(i<n-1)cout<<x[i]<<" ";
		else cout<<x[i]<<endl;
	}
	return 0;
}

Measured memory_bytes: 1024
#include<iostream>
using namespace std;
int main(void){
	int N;
    cin >> N;
    int A_i;
    int flag=0;
  	for(int i=0;i<N;i++){
      cin >> A_i;
        if(A_i%2==0){
        	if(A_i%3==0||A_i%5==0){}
          	else {
              cout <<"DENIED" << endl;
              flag =1;
              break;
            }
        }
    }
  	if(flag==0) cout<< "APPROVED"<< endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <assert.h>
#include <algorithm>
#include <vector>
//#include <functional>
//#include <cmath>


int main(){
    int32_t N;
    std::cin >> N;
    std::vector<int32_t> L(N);
    for(auto& i : L){
        std::cin >> i;
    }

    //NlogN
    std::sort(L.begin(), L.end());

    int32_t i,j,k;
    int64_t res = 0;
    for(k = N-1; k > 1; k--){
        int32_t start = 0;
        i = start;
        for(j = k-1; j > i; j--){
            i = start;
            for(i = start; i < j; i++){
                if(L[i] + L[j] > L[k]){ //cond met
                    //[i:j],j,k is ok
                    res += (int64_t)(j - i);
                    //std::cout << "[i,j,k] = "  << i << "(" << L[i] << "),"  << j << "(" << L[j] << ")," << k << "(" << L[k] << ")" << std::endl;
                    start = i;
                    break;
                }
            }
        }
    }

    
    std::cout << res;

    return 0;
}


Measured memory_bytes: 256
/**
  * http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=ITP1_11_A&lang=jp
  * Structure and Class - Dice I
  */
object Main {

  class Dice(numbers: IndexedSeq[Int]) {
    def rotateTo(direction: Char): Dice = {
      direction match {
        case 'N' => new Dice(IndexedSeq(numbers(1), numbers(5), numbers(2), numbers(3), numbers(0), numbers(4)))
        case 'S' => new Dice(IndexedSeq(numbers(4), numbers(0), numbers(2), numbers(3), numbers(5), numbers(1)))
        case 'W' => new Dice(IndexedSeq(numbers(2), numbers(1), numbers(5), numbers(0), numbers(4), numbers(3)))
        case 'E' => new Dice(IndexedSeq(numbers(3), numbers(1), numbers(0), numbers(5), numbers(4), numbers(2)))
      }
    }

    def apply(number: Int): Int = {
      numbers(number)
    }
  }

  def main(args: Array[String]): Unit = {
    val dice = new Dice(io.StdIn.readLine().split(" ").map(_.toInt))
    val operations = io.StdIn.readLine()
    val operatedDice = operations.foldLeft(dice)(_.rotateTo(_))
    println(operatedDice(0))
  }
}

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

int main()
{
  int A, B, K;
  cin >> A >> B >> K;
  set<int> st;
  for (int i = 0; i < K; i++)
  {
    if (A + i <= B)
    {
      st.insert(A + i);
    }
    if (B - i >= A)
    {
      st.insert(B - i);
    }
  }

  for (auto itr = st.begin(); itr != st.end(); itr++)
  {
    cout << *itr << endl;
  }
}


Measured memory_bytes: 256
/*
AuThOr Gwj
*/
#include<bits/stdc++.h>
#define rb(a,b,c) for(int a=b;a<=c;++a)
#define rl(a,b,c) for(int a=b;a>=c;--a)
#define LL long long
#define IT iterator
#define PB push_back
#define II(a,b) make_pair(a,b)
#define FIR first
#define SEC second
#define FREO freopen("check.out","w",stdout)
#define rep(a,b) for(int a=0;a<b;++a)
#define KEEP while(1)
#define SRAND mt19937 rng(chrono::steady_clock::now().time_since_epoch().count())
#define random(a) rng()%a
#define ALL(a) a.begin(),a.end()
#define POB pop_back
#define ff fflush(stdout)
#define fastio ios::sync_with_stdio(false)
#define debug_pair(A) cerr<<A.FIR<<" "<<A.SEC<<endl;
#define biggest(A,B) A=max(A,B)
#define smallest(A,B) A=min(A,B)
using namespace std;
const int INF=0x3f3f3f3f;
typedef pair<int,int> mp;
typedef pair<mp,mp> superpair;
int n,k;
vector<LL> pos,neg,a1,a2;
const int MOD=1e9+7;
int main(){
	fastio;
	cin>>n>>k;
	if(n==k){
		LL tmp=1;
		rb(i,1,n){
			LL ai;
			cin>>ai;
			tmp*=ai;
			tmp%=MOD;
			tmp+=MOD;
			tmp%=MOD;
		}
		cout<<tmp<<endl;
		return 0;
	}
	rb(i,1,n){
		int ai;
		cin>>ai;
		if(ai<0)
			neg.PB(-ai);
		else{
			pos.PB(ai);
		}
	}	
	sort(ALL(pos));
	sort(ALL(neg));
	reverse(ALL(pos));
	reverse(ALL(neg));
	a1=pos;
	a2=neg;
	LL tmp=1;
	rep(i,pos.size()){
		pos[i]*=tmp;
		pos[i]%=MOD;
		tmp=pos[i];
	}
	tmp=1;
	rep(i,neg.size()){
		neg[i]*=tmp;
		neg[i]%=MOD;
		tmp=neg[i];
	}
	if((k&1)&&pos.empty()){
		
	reverse(ALL(a2));
	neg=a2;
	tmp=1;
	rep(i,neg.size()){
		neg[i]*=tmp;
		neg[i]%=MOD;
		tmp=neg[i];
	}
		cout<<MOD-neg[k-1]<<endl;
		return 0;//负数 
	}
	else{
		//正数
		LL res;
		bool ok=0;
		rb(i,0,neg.size()){
			if(i&1) continue;
			if(k-i<=pos.size()){
			if(i&&ok)
			if(a2[i-1]*a2[i-2]<a1[k-i]*a1[k-i+1]) break;
			if(i==0){
				res=pos[k-1];
			}
			else
			if(k-i-1>=0){
				res=pos[k-i-1]*neg[i-1]%MOD;
			}
			else{
				res=neg[i-1];
			}
				ok=1;
			} 
		} cout<<res<<endl;
	}
	return 0;
}


Measured memory_bytes: 6376
a, b, c = map(int, input().split())
max_num = max(a, b, c)
if max_num == a:
    X = int(str(a) + str(b))
    print(X + c)
elif max_num == b:
    X = int(str(b) + str(a))
    print(X + c)
elif max_num == c:
    X = int(str(c) + str(a))
    print(X + b)


Measured memory_bytes: 61932
using System;
using System.Linq;
using System.Text.RegularExpressions;
using System.Collections.Generic;
using static program.Input;
using static program.MyMath;
using static System.Console;

namespace program {
  class Program {
    static string Alp = "abcdefghijklmnopqrstuvwxyz";
    static void Main()
    {
      var res = ScanStr()
        		.RegaxReplace("[ACGT]","!")
        		.RegaxReplace("[A-Z]"," ")
        		.Split()
        		.Select(_=>_.Length)
        		.Max();
      WriteLine($"{res}");
    }
    
  }
  
  static class Input {
    static public int ScanInt() { return int.Parse(Console.ReadLine()); }
    static public uint ScanUint() { return uint.Parse(Console.ReadLine()); }
    static public double ScanDouble() { return double.Parse(Console.ReadLine()); }
    static public long ScanLong() { return long.Parse(Console.ReadLine()); }
    static public ulong ScanUlong() { return ulong.Parse(Console.ReadLine()); }
    static public int[] ScanIntArray() { return Console.ReadLine().Split().Select(x => int.Parse(x)).ToArray(); }
    static public uint[] ScanUintArray() { return Console.ReadLine().Split().Select(x => uint.Parse(x)).ToArray(); }
    static public double[] ScanDoubleArray() { return Console.ReadLine().Split().Select(x => double.Parse(x)).ToArray(); }
    static public long[] ScanLongArray() { return Console.ReadLine().Split().Select(x => long.Parse(x)).ToArray(); }
    static public ulong[] ScanUlongArray() { return Console.ReadLine().Split().Select(x => ulong.Parse(x)).ToArray(); }

    static public string ScanStr() { return Console.ReadLine(); }
    static public string[] ScanStrArray() { return ScanStr().Split(); }
    static public string RegaxReplace(this string arg1, string pattern, string replacement)
    {
      return Regex.Replace(arg1, pattern, replacement);
    }
  }
  
  static class MyMath {
    public static int GCD(int a, int b) {
        Func<int, int, int> gcd = null;
        gcd = (x, y) => y == 0 ? x : gcd(y, x % y);
        return a > b ? gcd(a, b) : gcd(b, a);
    }
    public static long GCD(long a, long b) {
        Func<long, long, long> gcd = null;
        gcd = (x, y) => y == 0 ? x : gcd(y, x % y);
        return a > b ? gcd(a, b) : gcd(b, a);
    }
    public static ulong extGCD(ulong a, ulong b, ref ulong x, ref ulong y) {
      if(b==0) {
        x=1; 
        y=0;
        return a;
      }
      var d = extGCD(b, a%b, ref y, ref x);
      y -= a/b *x;
      return d;
    }
    public static int LCM(int a, int b) { return a * b / GCD(a, b); }
    public static long LCM(long a, long b) { return a * b / GCD(a, b); }
  }
}


Measured memory_bytes: 15960
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <queue>
#include <cmath>
#include <climits>
#include <iomanip>
#include <set>
#include <map>
using namespace std;
typedef long long ll;
int main(){
  int n = 0;
  string s;
  cin >> n >> s;
  int now = 0;
  int res = 0;
  for(int i = 0;i < s.size();i++){
    if(s[i] == 'I')now++;
    else now--;
    res = max(res,now);
  }
  cout << res << endl;
}

Measured memory_bytes: 256
import heapq
from collections import deque, Counter
N, K = map(int, input().split())
P = list(map(int, input().split()))
#ans = []
q = deque()
q_idx = []
L = []
for i, p in enumerate(P):
    while q and p <= q[-1][1]:
        idx, _ = q.pop()
        heapq.heappush(q_idx, idx)
    q.append((i, p))
    #print(q, q_idx)
    L.append(q_idx[0] if q_idx else -1)
    #ans.append(q[0][1])
    if q and q[0][0] <= i+1-K:
        idx, _ = q.popleft()
    if q_idx and q_idx[0] <= i+1-K:
        heapq.heappop(q_idx)
L = L[K-1:]

P = [-p for p in P]
P.reverse()
q = deque()
q_idx = []
R = []
for i, p in enumerate(P):
    while q and p <= q[-1][1]:
        idx, _ = q.pop()
        heapq.heappush(q_idx, idx)
    q.append((i, p))
    #print(q, q_idx)
    R.append(N - 1 - q_idx[0] if q_idx else -1)
    #ans.append(q[0][1])
    if q and q[0][0] <= i+1-K:
        idx, _ = q.popleft()
    if q_idx and q_idx[0] <= i+1-K:
        heapq.heappop(q_idx)
R = R[K-1:]
R.reverse()

#for l, r in zip(L, R):
print(len(Counter(zip(L, R))))


Measured memory_bytes: 121552
from math import sin,cos
x,y,t = 0,0,90
while(True):
    d,a = map(int,input().split(","))
    if d==0 and a==0:
        print(int(x))
        print(int(y))
        break
    x += d*cos(t/180*3.141592)
    y += d*sin(t/180*3.141592)
    t -= a



Measured memory_bytes: 5712
#include<bits/stdc++.h>
#include<iostream>
#include<string>
#include<cmath>
#include<cstdio>
#include<cctype>
#include<cstring>
#include<iomanip>
#include<cstdlib>
#include<ctime>
#include<set>
#include<map>
#include<utility>
#include<queue>
#include<vector>
#include<stack>
#include<sstream>
#include<algorithm>
/************************************************/
#define rep(i,n) for(int i=0;i<n;i++)
#define m_p make_pair
#define pb push_back
#define fr first
#define se second
#define forn(i,a,n) for(int i=a;i<n;i++)
#define foreach(i,c) for(__typeof(c.begin())i=(c.begin());i!=(c).end();i++)
#define pii pair<int,int>
#define vi vector<int>
#define ll long long
#define sz(s) s.size()
#define all(s) s.begin(),s.end()
#define zero(x) memset(x,0,sizeof(x))
#define vii vector<pair<int,int> >
#define mpis map<int,string>
#define mpii map<int,int>
#define mpsi map<string,int>
#define re return
#define mod 1000000007
/************************************************/
using namespace std;

long long get(){
	char c=getchar();
	long long x=0LL;
	while(c<'0'||c>'9')
	c=getchar();
	while(c>='0'&&c<='9'){
		x*=10LL;
		x+=(c-'0');
		c=getchar();
	}
	return x;
}
int n,m;
ll ans=0;
ll a[100001];
pii p[100001];
int main(){
	ios::sync_with_stdio(0);
	cin>>n>>m;
	rep(i,n)
	cin>>a[i];
	rep(i,m)
	cin>>p[i].se>>p[i].fr;
	sort(p,p+m);
	reverse(p,p+m);
	sort(a,a+n);
	int now=0;
	rep(i,m){
		while(now<n&&p[i].se&&p[i].fr>a[now]){
			a[now]=p[i].fr;
			now++;
			p[i].se--;
		}
		if(now==n||p[i].se)
		break;
	}
	
	rep(i,n)
	ans+=a[i];
	cout<<ans;
	re 0;
}


Measured memory_bytes: 5176
#include<bits/stdc++.h>
typedef long long i64;
const int P=1e9+7,N=1e6+7;
int n;
i64 ans=0,a[N],b[N];
int main(){
	scanf("%d",&n);
	a[0]=a[1]=a[2]=1,a[3]=2;
	i64 s=5;
	for(int i=4;i<=n;++i){
		a[i]=(s-a[i-2])%P;
		s=(s+a[i])%P;
	}
	b[0]=1,b[1]=n-1,b[2]=i64(n-1)*n%P;
	for(int i=3;i<=n;++i)b[i]=b[i-1]-1;
	for(int i=0;i<=n;++i)ans=(ans+a[i]*b[n-i])%P;
	printf("%lld\n",(ans+P)%P);
	return 0;
}

Measured memory_bytes: 15872
#include <iostream>
#include <algorithm>
#include <cmath>
#include <vector>
#include <queue>
#define rep(i,n) for(int i=0;i<n;i++)
#define ll long long int
#define MAX 1000000007
using namespace std;

int main(void){
	ll n,m;
	cin>>n>>m;

	ll ans;
	for(ll i=m/n;i>0;i--){
		if(m%i==0){
			ans=i;
			break;
		}
	}
	cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 256
import Control.Applicative
import Control.Monad
import Control.Monad.ST
import Data.Functor
import Data.Function
import Data.Monoid
import Data.Maybe
import Data.List
import qualified Data.Foldable as Foldable
import qualified Data.Set as Set
import Data.List.Split
import Data.Bits
import Data.Char
import Data.Ix
import Data.Ratio
import Data.Ord
import Data.Tuple
import Data.Array
--import Data.Array.Unboxed
import Data.Array.IO
import Data.Array.ST
import Data.IORef
import Data.STRef
-- import System.IO.Unsafe
 
readInt = read :: String -> Int
readDouble = read :: String -> Double
getInt = readLn :: IO Int
getInts = map readInt . words <$> getLine
getDouble = readLn :: IO Double
sjoin :: (Show a) => [a] -> String
sjoin = unwords . map show
cond :: a -> a -> Bool -> a
cond t f c = if c then t else f
apply2 :: (a -> a -> b) -> [a] -> b
apply2 f [x,y] = f x y
apply3 :: (a -> a -> a -> b) -> [a] -> b
apply3 f [x,y,z] = f x y z
apply4 :: (a -> a -> a -> a -> b) -> [a] -> b
apply4 f [x,y,z,w] = f x y z w
fnBin :: (b -> c -> d) -> (a -> b) -> (a -> c) -> a -> d
fnBin op f g x = op (f x) $ g x
fnTuple :: (a -> b, a -> c) -> a -> (b, c)
fnTuple (f,g) a = (f a, g a)
replace :: (Eq a) => a -> a -> [a] -> [a]
replace x y = map (\z -> if z==x then y else z)
modifyArray :: (Ix i, MArray a e m) => a i e -> i -> (e -> e) -> m ()
modifyArray arr ix f = readArray arr ix >>= writeArray arr ix . f
-- end of templete

f n
  | n>=500 = 1 + f (n - 500)
  | n>=100 = div n 100 + f (mod n 100)
  | n>=50 = 1 + f (n - 50)
  | n>=10 = div n 10 + f (mod n 10)
  | n>=5 = 1 + f (n - 5)
  | otherwise = n

main = getContents >>= mapM_ print . map (f . (1000-)) . takeWhile (/=0) . map readInt . lines

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

#define int long long
#define pb push_back 
#define mp make_pair
#define fr first
#define sc second
#define Rep(i, n) for( int i = 0; i < (n); i++ )
#define Rrep(i, a, n) for( int i = (a); i < (n); i++ )
#define All(v) v.begin(), v.end()

typedef pair<int, int> Pii; 
typedef pair<int, Pii> Pip;
const int INF = 1107110711071107;

signed main() {
  int N, M;
  map<int, int> m;
  cin >> N;
  Rep(i, N) {
    int a; cin >> a;
    m[a]++;
  }
  cin >> M;
  bool flag = true;
  Rep(i, M) {
    int a; cin >> a;
    if ( !m[a] ) {
      flag = false;
    }
    m[a]--;
  }

  if ( flag ) cout << "YES" << endl;
  else cout << "NO" << endl;
  return 0;
}


Measured memory_bytes: 12800
#!/usr/bin/env ruby

require 'set'

class Hash
  def push(key, value)
    self[key] = [] if self[key] == nil
    self[key].push(value)
  end
end

class Array
  def lower_bound(value)
    left = -1;
    right = self.length;
    while left + 1 < right
      mid = left + (right - left) / 2;
      if self[mid] >= value
        right = mid
      else
        left = mid
      end
    end
    right
  end

  def unique
    res = [self.first]
    each_cons(2) do |a, b|
      if a != b
        res.push(b)
      end
    end
    res
  end
end

def get_ints
  gets.chomp.split.map(&:to_i)
end

def get_ints_minus_one
  get_ints.map { |x| x - 1 }
end

def get_int
  gets.chomp.to_i
end

N = get_int
A = get_ints

ax = A.sort.reverse

sum = 0
ax[0...(N/2)].each do |a|
  sum += 2 * a
end

sum -= ax[0] # 最大は1回だけ

if N % 2 == 1
  sum += ax[N/2]
end

puts sum


Measured memory_bytes: 33284
#include<iostream>
using namespace std;
int main(){
    int n;
    cin>>n;
    ++n;
    for(int i=1;i<n;++i){
        int d=i;
        bool flag=false;
        if(i%3==0){
            flag=true;
        }
        else{
            while(d!=0){
                if(d%10==3){
                    flag=true;
                    break;
                }
                d/=10;
                }
        }
        if(flag){
            cout<< ' ' <<i;
        }
    }
    cout<<endl;
    return 0;
}

Measured memory_bytes: 3084
#include <bits/stdc++.h>
using namespace std;
using Int = long long;
const Int MOD = 1000000007;
Int dp[401][401], X[401][401];
int main() {
    ios::sync_with_stdio(false); cin.tie(nullptr);
    int N, C; cin >> N >> C;
    vector<Int> A(N), B(N);
    for (auto &a : A) cin >> a;
    for (auto &b : B) cin >> b;
    for (int i = 0; i < N; i++) {
        for (int a = A[i]; a <= B[i]; a++) {
            Int t = 1;
            for (int j = 0; j <= C; j++) {
                X[i][j] = (X[i][j] + t) % MOD;
                t = (t * a) % MOD;
            }
        }
    }
    dp[0][0] = 1;
    for (int i = 1; i <= N; i++) {
        for (int c = 0; c <= C; c++) {
            for (int k = 0; k <= c; k++) {
                dp[i][c] = (dp[i][c] + dp[i - 1][c - k] * X[i - 1][k]) % MOD;
            }
        }
    }
    cout << dp[N][C] << endl;
    return 0;
}


Measured memory_bytes: 2816
#include <iostream>
#include <vector>
#include <string>
#include <cmath>
#include <set>
#include <algorithm>
#include <array>
#include <complex>
#include <string>
#include <utility>
#include <map>
#include <queue>
#include <list>
#include <functional>
#include <numeric>
#include <stack>
#include <tuple>

using namespace std;
int dx[4] = { -1,0,1,0 };
int dy[4] = { 0,1,0,-1 };
const int INF = 100000000;
const long long LINF = 1000000000000000000;
const int MOD = (int)1e9 + 7;
using pii = std::pair<int, int>;
#define SORT(v) std::sort(v.begin(), v.end())

int main(void) {
	int n;
	long long sum = 0, sum_i = 0, ans = LINF;
	cin >> n;
	vector<long long> a(n);
	for (int i = 0; i < n;++i) {
		cin >> a[i];
		sum += a[i];
	}
	
	for (int i = 0; i < n; ++i) {
		sum_i += a[i];
		if(i+1<n)ans = min(ans,abs(2 * sum_i - sum));
		
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 1792
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int H = sc.nextInt();
		int W = sc.nextInt();
		
		String board [][] = new String [H+1][W+1];
		
		for (int i=0; i<H; i++) {
			String S = sc.next();
			board [i] = S.split("");
		}
		
		
		
		int dx [] = new int [] {1, 0, -1, 0, 1, -1, -1, 1};
		int dy [] = new int [] {0, 1, 0, -1, 1, 1, -1, -1};
		
		char ans [][] = new char [H+1][W+1];
		
		for (int i = 0; i < H; i++) {
			
			for (int j = 0; j < W; j++) {
				if (board[i][j].equals("#")){
					System.out.print('#');
					continue;
				}
			
				int num = 0;
				for (int d = 0; d < 8; d++) {
					int ni = i + dx[d];
					int nj = j + dy[d];
			
					if (ni<0 || H<=ni)
						continue;
					
					if (nj<0 || W<=nj)
						continue;
					
					if (board[ni][nj].equals("#"))
						num++;
				}
				
				//System.out.println(i+ " : " + j+ " : " + num);
				System.out.print(num);
			
			}
			System.out.println();
		}
		
		sc.close();
	}
}


Measured memory_bytes: 23608
#include<iostream>
#include<iomanip>
#include<vector>
#include<map>
#include<stack>
#include<queue>
#include<string>
#include<utility>
#include<numeric>
#include<algorithm>
#include<cmath>
#include<climits>
using namespace std;

using ll = long long;

class Stream{
public:
    Stream(){

    }
    //配列以外の入力を受け取る
    void read(){

    }
    template<typename First, typename... Rest>
    void read(First& first, Rest&... rest){
        cin >> first;
        read(rest...);
    }
    //配列を区切って出力する
    template<typename T>
    void write_vec(vector<T>& v, char divider){
        for(size_t i = 0; i < v.size(); i++){
            cout << v[i] << divider;
        }
    }
};

int main(){
    Stream io;
    
    int N;
    io.read(N);
    vector<ll> A(N);
    for(int i = 0; i < N; i++){
        io.read(A[i]);
    }
    sort(A.begin(), A.end());
    ll ans = 1;
    for(int i = 0; i < N; i++){
        ll x = ans * A[i];
        if(A[i] <= 1000000000000000000 / ans) {
            ans *= A[i];
            if(ans == 0) break;
        }
        else {
            ans = -1;
            break;
        }
    }
    cout << ans;
    return 0;
}

Measured memory_bytes: 4052
#include <stdio.h>
int main(void){
    int a,b,i;
    for(i=0;i<3000;i++){
    scanf("%d %d",&a,&b);
    if(a<b){
        printf("%d %d\n",a,b);
    }
    else if(a>b){
        printf("%d %d\n",b,a);
    }
    else if ( a == 0 && b == 0 ) break; 
    else if(a==b){
        printf("%d %d\n",a,b);
    }
    }
return 0;
}


Measured memory_bytes: 2044