akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std ;
typedef long long ll ;
#define rep(i, a, b) for (int i = a; i <= b; ++i)

const int N = 1e5 + 7;

int n, m, a[N << 1], b[N << 1];

inline bool check(int mid) {
	rep(i, 1, m) b[i] = (a[i] >= mid);
	rep(i, 1, n - 1) {
		if (!(b[n + i] ^ b[n + i - 1])) return b[n + i];
		if (!(b[n - i] ^ b[n - i + 1])) return b[n - i];
	}
	return b[1];
}

int main() {
	scanf("%d", &n); m = (n << 1) - 1;
	rep(i, 1, m) scanf("%d", &a[i]);
	int l = 1, r = m + 1, ans;
	while (l <= r) {
		int mid = (l + r) >> 1;
		if (check(mid)) ans = mid, l = mid + 1; else r = mid - 1;
	}
	printf("%d\n", ans);
	return 0;
}

Measured memory_bytes: 1792
#include <stdio.h>

const int MAX = 10000;

int main(){
  int A[MAX];
  int length,work;
  length = 0;

  for(int i=0;i<MAX;i++){
    scanf("%d",&work);
    if(work != 0){
      A[i] = work;
      length++;
    } else {
      break;
    }
  }

  for(int i=0;i<length;i++){
    printf("Case %d: %d\n",i+1,A[i]);
  }

  return 0;
}


Measured memory_bytes: 2740
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rrep(i,n) for(int i=(int)(n)-1;i>=0;i--)
#define each(a,x) for(auto a : (x))
#define all(a) (a).begin(),(a).end()
#define chmin(a,b) ((a) = min((a),(b)))
#define chmax(a,b) ((a) = max((a),(b)))
#define in_range(x,l,r) ((l)<=(x) && (x)<(r))
#define fs first
#define sc second
#define pb push_back
#define sz size() 
#define MP make_pair
using namespace std;
typedef long long ll;
typedef double D;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<string> vs;

const static int INF = 1e8;
const static D EPS = 1e-8;

int main(){
  int a,b,h;
  cin >> a >> b >> h;
  cout << (a+b)*h/2 << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <stdio.h>
#include <sstream>
#include <math.h>
#include <queue>
#include <map>
#include <set>
#include <ios>     // std::left, std::right
#include <iomanip> // std::setw(int), std::setfill(char)
using namespace std;

int ctoi(char c) {
	switch (c) {
		case '0': return 0;
		case '1': return 1;
		case '2': return 2;
		case '3': return 3;
		case '4': return 4;
		case '5': return 5;
		case '6': return 6;
		case '7': return 7;
		case '8': return 8;
		case '9': return 9;
		default: return 0;
	}
}

int main(){
  std::string S;
  cin>>S;
  long long N;
  char target;
  int num;
  long long dp[13]={};
  long long dp2[13]={};
  dp[0]=1;
  long long mod=1000000007;
  N=S.length();
  for(int i=0;i<N;++i){
    target=S[i];
    if(target=='?'){
      for(int j=0;j<13;++j){
        dp2[(j*10%13)]+=dp[j];
        dp2[((j*10+1)%13)]+=dp[j];
        dp2[((j*10+2)%13)]+=dp[j];
        dp2[((j*10+3)%13)]+=dp[j];
        dp2[((j*10+4)%13)]+=dp[j];
        dp2[((j*10+5)%13)]+=dp[j];
        dp2[((j*10+6)%13)]+=dp[j];
        dp2[((j*10+7)%13)]+=dp[j];
        dp2[((j*10+8)%13)]+=dp[j];
        dp2[((j*10+9)%13)]+=dp[j];
      }
    }
    else{
      num=ctoi(target);
      for(int j=0;j<13;++j){
      dp2[((j*10+num)%13)]+=dp[j];}
    }
    for(int j=0;j<13;++j){
      dp[j]=dp2[j]%mod;
      dp2[j]=0;
    }
  }
  cout<<dp[5]<<"\n";
return 0;
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const double pi = acos(-1);
#define FOR(i,a,b) for (ll i=(a),__last_##i=(b);i<__last_##i;i++)
#define RFOR(i,a,b) for (ll i=(b)-1,__last_##i=(a);i>=__last_##i;i--)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n)
#define __GET_MACRO3(_1, _2, _3, NAME, ...) NAME
#define rep(...) __GET_MACRO3(__VA_ARGS__, FOR, REP)(__VA_ARGS__)
#define rrep(...) __GET_MACRO3(__VA_ARGS__, RFOR, RREP)(__VA_ARGS__)
template<typename T> ostream& operator<<(ostream& os, const vector<T>& v) {
    REP(i,v.size()){if(i)os<<" ";os<<v[i];}return os;}
template<typename T> ostream& operator<<(ostream& os, const vector<vector<T>>& v) {
    REP(i,v.size()){if(i)os<<endl;os<<v[i];}return os;}

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

const int dx4[4] = {1, 0, -1, 0};
const int dy4[4] = {0, 1, 0, -1};

const int dx8[8] = {1,1,0,-1,-1,-1,0,1};
const int dy8[8] = {0,1,1,1,0,-1,-1,-1};

vector< vector<int> > Graph;
vector< int > value;





int main(int argc, const char * argv[]) {
    
    // remove the bottom 3 lines when you submit this code.
    std::ifstream in("sample.txt");
    std::cin.rdbuf(in.rdbuf());

    cin.tie(0);
    ios::sync_with_stdio(false);
    
    
    int x; cin >> x;
    int now = 0;
    int time = 0;
    
   
    while(now<x){
        time++;
        now += time;
    }
    cout << time << endl;
    
    
    
}



Measured memory_bytes: 256
#include <cstdint>
#include <cstdio>
#include <vector>

#include <atcoder/scc>

int main() {
  int n, m;
  scanf("%d %d", &n, &m);

  atcoder::scc_graph g(n);

  for (int i = 0; i < m; ++i) {
    int a, b;
    scanf("%d %d", &a, &b);
    g.add_edge(a, b);
  }

  auto res = g.scc();
  printf("%zu\n", res.size());
  for (auto const& ri: res) {
    printf("%zu", ri.size());
    for (auto rij: ri) printf(" %d", rij);
    printf("\n");
  }
}


Measured memory_bytes: 40084
use std::cmp;
use std::collections::BTreeMap;

fn main() {
    let (r, w) = (std::io::stdin(), std::io::stdout());
    let mut sc = IO::new(r.lock(), w.lock());

    let n: usize = sc.read();
    let k: usize = sc.read();
    let c: usize = sc.read();
    let s = sc.chars();

    let mut left_max = vec![0; n];

    let mut pos = 0;
    let mut cur = 0;
    while pos < n {
        if s[pos] == 'o' {
            pos += c;
            cur += 1;
            if pos < n {
                left_max[pos] = cur;
            }
        }
        pos += 1;
    }
    for i in 1..n {
        left_max[i] = cmp::max(left_max[i - 1], left_max[i]);
    }

    let mut right_max = vec![0; n];
    let mut pos = n - 1;
    let mut cur = 0;
    loop {
        if s[pos] == 'o' {
            cur += 1;
            right_max[pos] = cur;
            if pos >= c {
                pos -= c;
            } else {
                break;
            }
        }
        if pos > 0 {
            pos -= 1;
        } else {
            break;
        }
    }
    for i in (1..n).rev() {
        right_max[i - 1] = cmp::max(right_max[i - 1], right_max[i]);
    }

    let mut map = BTreeMap::new();
    for i in 0..n {
        if s[i] == 'x' {
            continue;
        }

        let prev = if i > 0 { left_max[i - 1] } else { 0 };
        let next = if i + c + 1 < n {
            right_max[i + c + 1]
        } else {
            0
        };
        if prev + next + 1 == k {
            map.entry((prev, next)).or_insert_with(Vec::new).push(i);
        }
    }

    let mut ans: Vec<_> = map
        .values()
        .filter(|t| t.len() == 1)
        .map(|t| t[0])
        .collect();

    ans.sort();
    // println!("{:?}", left_max);
    // println!("{:?}", right_max);
    // println!("{:?}", ans);
    for ans in ans.into_iter() {
        sc.write(ans + 1);
        sc.write("\n");
    }
}

//o oxxox oxxx oxoxx o
//3 33322 2222 21111 1
pub struct IO<R, W: std::io::Write>(R, std::io::BufWriter<W>);

impl<R: std::io::Read, W: std::io::Write> IO<R, W> {
    pub fn new(r: R, w: W) -> IO<R, W> {
        IO(r, std::io::BufWriter::new(w))
    }
    pub fn write<S: ToString>(&mut self, s: S) {
        use std::io::Write;
        self.1.write(s.to_string().as_bytes()).unwrap();
    }
    pub fn read<T: std::str::FromStr>(&mut self) -> T {
        use std::io::Read;
        let buf = self
            .0
            .by_ref()
            .bytes()
            .map(|b| b.unwrap())
            .skip_while(|&b| b == b' ' || b == b'\n' || b == b'\r' || b == b'\t')
            .take_while(|&b| b != b' ' && b != b'\n' && b != b'\r' && b != b'\t')
            .collect::<Vec<_>>();
        unsafe { std::str::from_utf8_unchecked(&buf) }
            .parse()
            .ok()
            .expect("Parse error.")
    }
    pub fn vec<T: std::str::FromStr>(&mut self, n: usize) -> Vec<T> {
        (0..n).map(|_| self.read()).collect()
    }
    pub fn chars(&mut self) -> Vec<char> {
        self.read::<String>().chars().collect()
    }
}


Measured memory_bytes: 36348
N,K = [int(i) for i in input().split()]
X = [int(i) for i in input().split()]

ans = 10**9
for i in range(N-K+1):
    l = X[i]
    r = X[i+K-1]
    if l < 0 and r <= 0:
        tmp = -l
    elif l >= 0 and r > 0:
        tmp = r
    else:
        tmp = min(abs(l),r)*2 + max(abs(l),r)
    ans = min(ans,tmp)
print(ans)


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

int main(void){
    string S;
    int Q;
    cin >> S >> Q;
    deque<string> ans;
    ans.push_back(S);
    bool has_reverse = false;
    for (int i = 0; i < Q; i++) {
        int T;
        cin >> T;
        if (T == 1)
            has_reverse = !has_reverse;
        else {
            int F;
            string C;
            cin >> F >> C;
            
            if ((!has_reverse && F == 1) || (has_reverse && F == 2))
                ans.push_front(C);
            else
                ans.push_back(C);
        }
    }
    
    if (has_reverse) {
        for (int i = ans.size()-1; i >= 0; i--) {
            string c = ans[i];
            reverse(c.begin(), c.end());
            cout << c;
        }
    }
    else
        for (int i = 0; i < ans.size(); i++)
            cout << ans[i];
}

Measured memory_bytes: 11648
#include <iostream>
#include <algorithm>
#include <cstdio>
#include <cmath>
#include <math.h>
#include <string>
#include <string.h>
#include <stack>
#include <queue>
#include <vector>
#include <utility>
#include <set>
#include <map>
#include <stdlib.h>
#include <iomanip>

using namespace std;

#define ll long long
#define vvi vector< vector<int> >
#define vi vector<int>
#define All(X) X.begin(),X.end()
#define FOR(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define REP(i,n) for(int i=0;i<(int)(n);i++)
#define pb push_back
#define pii pair<int,int>
#define mp make_pair
#define pi 3.14159265359
#define shosu(X) fixed << setprecision(X)
ll gcd(ll a, ll b) { return b ? gcd(b, a%b) : a; }
ll lcm(ll a, ll b) { return a / gcd(a, b)*b; }


int main() {
	ll N;
	ll ans = 0;
	ll sum = 0;
	cin >> N;
	FOR(i,1, 100000) {
		if (N%i==0) {
			sum = i;
			if(N/i>=sum){
				ans = (int)log10(N / i) + 1;
			}
		}
	}
	cout << ans;
	return 0;
}

Measured memory_bytes: 640
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author
 */

#include <iostream>
#include <fstream>

#include <iostream>
#include <string>
#include <vector>
#include <math.h>
#include <map>
#include <set>
#include <algorithm>
using namespace std;
using ll = long long;
constexpr ll INF = 1010000000000000017LL;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(v) v.begin(), v.end()

class AIrreversibleOperation {
public:
	void solve(std::istream& in, std::ostream& out) {
        string s;
        in>>s;
        ll ans=0;
        ll cnt=0;
        for(ll i=s.size()-1; i>=0; --i){
            if(s.at(i)=='B'){
                ans+=(s.size()-1-i)-cnt;
                ++cnt;

            }
        }
        out<<ans<<endl;
	}
};


int main() {
	AIrreversibleOperation solver;
	std::istream& in(std::cin);
	std::ostream& out(std::cout);
	solver.solve(in, out);
	return 0;
}


Measured memory_bytes: 1336
def d_xor_sum_2(N, A):
    r = 0  # 尺取の右端
    total, xor_sum = 0, 0  # [l,r) における数列の和とxor
    ans = 0

    for l in range(N):  # 尺取の左端
        while r < N and (total + A[r] == xor_sum ^ A[r]):
            # 尺取の右端が末尾に到達せず、条件を満たしているなら
            total += A[r]
            xor_sum ^= A[r]
            r += 1  # 尺取を1つ伸ばす
        ans += r - l  # 区間長の分だけ足す
        # 尺取の左端を1つ右へやるので、その分を除く
        total -= A[l]
        xor_sum ^= A[l]  # 2回xorを取るとxorを取らなかったのと同じ
        # 区間長の分だけ足すフェイズで足されなかった分は、
        # lをいくつか増やしたときの足すフェイズで必ず足されるため、数え損ねはない
    return ans

N = int(input())
A = [int(i) for i in input().split()]
print(d_xor_sum_2(N, A))

Measured memory_bytes: 25684
n, m = map(int, input().split())
x = list(map(int, input().split()))
y = list(map(int, input().split()))
MOD = 10 ** 9 + 7
# 縦軸の和、横軸の和を求めて、掛け合わせる。

# listから、和を求める


def calc(lis):
    num = len(lis)
    sum = 0
    for i in range(num):
        #sum += x[i] * (num - i - 1) - x[i] * (i)
        sum += lis[i] * i - (lis[i] * (num - i - 1))

    return sum
    '''
          lisSum = 0
          before = 0
          for i, val in enumerate(lis):
              lisSum += val
              if (i != 0):
                  temp = before + val
                  lisSum = temp
              before = val

          return int(lisSum)

      '''


xSum = calc(x)
ySum = calc(y)

ans = (xSum * ySum) % MOD
print(ans)


'''
def calc(list):

sum = 0
for i in range(n):
  temp = n - i
  for j in range(i+1, n):
    sum += list[i] - list[j]

二重ループにせずとも、
for i in range(n):
  sum += x[i]*(n-i-1) - x[1]*(i)

でOK
'''


Measured memory_bytes: 18624
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		StringBuilder sb = new StringBuilder();
		int n = sc.nextInt();
		int min = Integer.MAX_VALUE;
		int max = Integer.MIN_VALUE;
		for (int i = 0; i < n; i++) {
			int t = sc.nextInt();
			min = Math.min(min, t);
			max = Math.max(max, t);
		}
		System.out.println(max - min);
	}
}


Measured memory_bytes: 22612
def cc
    n = gets.chomp.to_i
    bn = gets.chomp.split(/\s/).map{|x| x.to_i}

    an = [bn[0]]
    for i in 1..(n-2)
        l = bn[i-1]
        r = bn[i]
        an.push([l, r].min)
    end
    an.push(bn[-1])

    puts an.inject(0){|sum,x| sum + x }
end

cc



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

#define Max 100001
int a[Max];
int b[Max];
int c[Max];
int dp[Max][3];

int main(){
	int n;
	memset(dp,0,sizeof(dp));
	cin>>n;
	for(int i=1;i<=n;i++){
		cin>>a[i]>>b[i]>>c[i];
		dp[i][0]=max(dp[i-1][1],dp[i-1][2])+a[i];
		dp[i][1]=max(dp[i-1][0],dp[i-1][2])+b[i];
		dp[i][2]=max(dp[i-1][1],dp[i-1][0])+c[i];
	}
	int ans=max(max(dp[n][0],dp[n][1]),dp[n][2]);
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 2560
s = input()
if (int(s[0]+s[1]) > 0 and int(s[0]+s[1])<=12) and (int(s[2]+s[3]) > 0 and int(s[2]+s[3])<=12):
    print("AMBIGUOUS")
elif int(s[0]+s[1]) > 0 and int(s[0]+s[1])<=12:
    print("MMYY")
elif int(s[2]+s[3]) > 0 and int(s[2]+s[3])<=12:
    print("YYMM")
else:
    print("NA")
        


Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define rep(i, n) for (ll i = 0; i < n; i++)
#define FOR(i, a, b) for (ll i = a; i < b; i++)
#define len(v) ll(v.size())
#define fi first
#define se second

template <class T>
void cout_vec(const vector<T> &vec){
  for(auto itr:vec) cout<<itr<<' ';
  cout<<endl;
}

typedef pair<ll,ll> P;
const ll mod=1e9+7;
const ll inf=1e15;

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  ll n;
  cin>>n;
  ll ans=(n-1)*n/2;
  cout<<ans<<endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <string.h>

#define REP(i,k,n) for(int i=k;i<n;i++)
#define rep(i,n) for(int i=0;i<n;i++)

using namespace std;

int dp[10][330];
int flag[10];

void dfs(int i,int a)
{
	if(a > 330 || i > 10)
	{
		return;
	}
	else
	{
		rep(k,10)
		{
			if(flag[k] == 0)
			{
				flag[k] = 1;
				int temp = i*k;
				dp[i][a+temp]++;
				dfs(i+1,a+temp);
				flag[k] = 0;
			}
		}
	}
}


int main()
{
	int n,s;
	memset(flag,0,sizeof(flag));
	dfs(1,0);
	while(cin >> n >> s)
	{
		if(s > 330)
		{
			cout << 0 << endl;
		}
		else
		{
			cout << dp[n][s] << endl;
		}
	}
	return 0;
}

Measured memory_bytes: 1172
#include <iostream>
#include <algorithm>
using namespace std ;
const int N = 8e5+5,M = N<<1,mod = 924844033,GG = 5,IG = 554906420 ;
inline int add(int a,int b){ return a+b >= mod ? a+b-mod : a+b ; }
inline int sub(int a,int b){ return a >= b ? a-b : a-b+mod ; }
inline int mul(int a,int b){ return 1ll*a*b%mod ; }
inline int power(int a,int b){
	int res = 1 ;
	for( ; b ; b >>= 1){
		if(b&1) res = mul(res,a) ;
		a = mul(a,a) ; 
	}
	return res ; 
} 
int rev[M] ;
inline void calrev(int limit){
	for(int i = 0 ; i < limit ; i++)
	    rev[i] = (rev[i>>1]>>1)|((i&1)?(limit>>1):0) ; 
}
inline void NTT(int *A,int limit,int flg){
	for(int i = 0 ; i < limit ; i++)
	    if(i > rev[i])
		   swap(A[i],A[rev[i]]) ;
	for(int mid = 1 ; mid < limit ; mid <<= 1){
		int Wn = power(flg == 1 ? GG : IG,(mod-1)/(mid<<1)) ; 
		for(int j = 0 ; j < limit ; j += (mid<<1)){
			int w = 1 ;
			for(int k = 0 ; k < mid ; k++,w = mul(w,Wn)){
				int x = A[j+k],y = mul(w,A[j+mid+k]) ;
				A[j+k] = add(x,y) ;
				A[j+mid+k] = sub(x,y) ; 
			}
		}
	}
	if(flg == -1){
		int Inv = power(limit,mod-2) ;
		for(int i = 0 ; i < limit ; i++)
		    A[i] = mul(A[i],Inv) ;
	}
}
int fac[N],inv[N] ;
inline int C(int n,int m){ return mul(fac[n],mul(inv[m],inv[n-m])) ; }
inline void prework(int n){
	fac[0] = inv[0] = inv[1] = 1 ;
	for(int i = 1 ; i <= n ; i++) fac[i] = mul(fac[i-1],i) ;
	for(int i = 2 ; i <= n ; i++) inv[i] = mul(sub(mod,mod/i),inv[mod%i]) ; 
	for(int i = 1 ; i <= n ; i++) inv[i] = mul(inv[i],inv[i-1]) ;
}
int n,head[N],Next[N],ver[N],cnt[N],Size[N],tot ;
inline void adde(int x,int y){ ver[++tot] = y ; Next[tot] = head[x] ; head[x] = tot ;} 
inline void dfs(int x,int fa){
	Size[x] = 1 ; 
	for(int i = head[x] ; i ; i = Next[i]){
		int y = ver[i] ;
		if(y == fa) continue ;
		dfs(y,x) ;
		Size[x] += Size[y] ;
		cnt[Size[y]]++ ;
	}
	cnt[n-Size[x]]++ ; 
}
int f[N],g[N] ; 
int main(){
	//freopen("in.txt","r",stdin) ; 
	cin >> n ;
	prework(n) ;
	for(int i = 1 ; i < n ; i++){ int x,y ; scanf("%d%d",&x,&y) ; adde(x,y) ; adde(y,x) ; }
	dfs(1,0) ; 
	for(int i = 1 ; i <= n ; i++) f[i] = mul(cnt[i],fac[i]),g[i] = inv[i] ; g[0] = 1 ; 
    reverse(f,f+n+1) ; 
	int limit = 1 ;	while(limit <= n*2) limit <<= 1 ; calrev(limit) ;
	NTT(f,limit,1) ; NTT(g,limit,1) ;
	for(int i = 0 ; i < limit ; i++) f[i] = mul(f[i],g[i]) ;
	NTT(f,limit,-1) ; reverse(f,f+n+1) ; 
	for(int i = 1 ; i <= n ; i++) printf("%d\n",sub(mul(n,C(n,i)),mul(inv[i],f[i]))) ;  
	return 0 ; 
}

Measured memory_bytes: 30244
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int a = sc.nextInt();
		int b = sc.nextInt();

		if ((a+b)>(a-b)) {
			if((a+b)>(a*b)) {
				System.out.println(a+b);
			}else {
				System.out.println(a*b);
			}
		}else {
			if((a-b)>(a*b)) {
				System.out.println(a-b);
			}else {
				System.out.println(a*b);
			}
		}
	}
}

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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

#define REP(i, n) for(int i=0; i<(n); ++i)
#define FOR(i, a, b) for(int i=(a); i<(b); ++i)
#define FORR(i, a, b) for(int i=(b)-1; i>=(a); --i)

#define DEBUG(x) cout<<#x<<": "<<x<<'\n'
#define DEBUG_VEC(v) cout<<#v<<":";REP(i, v.size())cout<<' '<<v[i];cout<<'\n'
#define ALL(a) (a).begin(), (a).end()

#define CHMIN(a, b) a=min((a), (b))
#define CHMAX(a, b) a=min((a), (b))

const int MOD=1000000007;
#define FIX(a) ((a)%MOD+MOD)%MOD

const double EPS=1e-11;
#define EQ0(x) (abs((x))<EPS)
#define EQ(a, b) (abs((a)-(b))<EPS)

int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	int n, f[114][20], p[114][20];
	cin>>n;
	REP(i, n){
		REP(j, 10) cin>>f[i][j];
	}
	REP(i, n){
		REP(j, 11) cin>>p[i][j];
	}
	int ans=-(1<<30);
	for(int i=1; i<1<<10; ++i){
		int tmp=0;
		REP(j, n){
			int tmp1=0;
			REP(k, 10) if((i>>k&1) && f[j][k]) ++tmp1;
			tmp+=p[j][tmp1];
		}
		ans=max(ans, tmp);
	}
	cout<<ans<<'\n';
	return 0;
}


Measured memory_bytes: 256
package main

import (
	"fmt"
)

func main() {
	var n int
	fmt.Scan(&n)

	sum := 0
	ws := make([]int, n)
	for i := 0; i < n; i++ {
		fmt.Scan(&ws[i])
		sum += ws[i]
	}

	ret := 0
	tmp := 0
	for i := 0; i < n; i++ {
		tmp += ws[i]
		if tmp >= (sum / 2) {
			calc1 := getAbs(tmp, sum-tmp)
			calc2 := getAbs(tmp-ws[i], sum-(tmp-ws[i]))
			if calc1 > calc2 {
				ret = calc2
			} else {
				ret = calc1
			}
			break
		}
	}

	fmt.Println(ret)
}

func getAbs(a, b int) int {
	tmp := a - b
	if tmp > 0 {
		return tmp
	} else {
		return -tmp
	}
}


Measured memory_bytes: 512
def main():
    n = int(input())
    a=[int(i) for i in input().split()]
    b=[int(i) for i in input().split()]

    ind = 0
    res = 0

    for i in range(n):
        if a[i] <= b[i]:
            res += a[i]
            k = b[i]-a[i]
            res += min(k,a[i+1])

            a[i+1]=max(a[i+1]-k,0)

        else:
            res += b[i]
    print(res)



if __name__ == '__main__':
    main()


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

#define rep(i, a, b) for(int i = a; i < (b); ++i)
#define trav(a, x) for (auto& a : (x))
#define all(x) x.begin(), x.end() // sort(all(x))
#define sz(x) (int)(x).size()
#define mp(x, y) make_pair((x), (y))

typedef long long ll;

typedef double T;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef tuple<int, int, int> tiii;

typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vi> vvi;
typedef vector<vl> vvl;
typedef vector<T> vt;
typedef vector<vt> vvt;
typedef vector<pii> vpi;
typedef vector<pii> vpl;
typedef vector<vpi> graph;
typedef complex<T> Pt;
typedef pair<Pt, Pt> Line;

const ll MOD = 1000; // 998244353;
const T EPS = 1e-10;
const int INF = 1e9 + 1;

/* Mod Library */

struct Mod {
    ll x;
    Mod (ll x = 0) : x(x) {}
    Mod operator+(Mod b) { return Mod((x + b.x)%MOD); }
    Mod operator-(Mod b) { return Mod((x - b.x + MOD)%MOD); }
    Mod operator*(Mod b) { return Mod((x * b.x)%MOD); }
    Mod operator/(Mod b) { return *this * inverse(b); }
    Mod operator%(Mod b) { return Mod(x % b.x); }

    ll euclid(ll a, ll b, ll &x, ll &y) {
        if (b) {
            ll d = euclid(b, a%b, y, x);
            y -= a/b*x;
            return d;
        }
        x = 1; 
        y = 0;
        return a;
    }
    
    Mod inverse(Mod a) {
        ll x, y, g = euclid(a.x, MOD, x, y);
        assert(g == 1);
        return Mod((x + MOD)%MOD);
    }

    Mod operator^(ll e) {
        if (!e) return Mod(1);
        Mod r = *this^(e/2);
        r = r*r;
        return e&1 ? *this*r : r;
    }
};

/* Input Library */
template <typename A, typename B>
istream& operator>>(istream &in, pair<A, B> &p) {
    in >> p.first >> p.second;
    return in;
}

template <typename A, typename B>
ostream& operator<<(ostream &out, pair<A, B> &p) {
    out << p.first << " " << p.second;
    return out;
}

template <typename I>
istream& operator>>(istream &in, vector<I> &a) {
    trav(i, a) in >> i;
    return in;
}

template <typename I>
ostream& operator<<(ostream &out, vector<I> &a) {
    rep(i, 0, sz(a)) {
        if (i) out << " ";
        out << a[i];
    }
    return out;
}

void fast_io() {
    cin.sync_with_stdio(0);
    cin.tie(0);
    //cout.tie(0);
    cin.exceptions(cin.failbit);
}

/* Solution */

void solve_test() {
    ll n; 
    cin >> n; 
    cout << n*(n-1)/2L << endl;
}

void setup() {

}

int main() {
    setup();
    srand(time(0));
    fast_io();
    int t = 1;
    // cin >> t;
    while (t--) {
        solve_test();
    }
}


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

using namespace std;
const long MOD = 1000000007;

int main(){
    int N;
    cin >> N; 

    int A[N];
    int cnt = 0;
    for(int i=0; i<N; i++){
        cin >> A[i];
        if(A[i] == 0) cnt++;
    }

    long ans = 1;
    int pre = 3;
    map<int, int> m;
    for(int i=0; i<N; i++){
        if(m.count(A[i]) == 0){
            m[A[i]] = 1;
        }else{
            m[A[i]]++;
        }
        if(A[i] != 0){
            ans = ans * m[A[i]-1] % MOD;
            m[A[i]-1]--;
        }
    }

    int s = 3;
    while(cnt != 0){
        ans = ans * s % MOD;
        cnt--;
        s--;
    }

    printf("%ld\n", ans);

    return 0;
}

Measured memory_bytes: 5376
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define REP(i,a,n) for(int i = (a); i < (n); ++i)
#define ALL(a) (a).begin(), (a).end()
#define debug_v(v,N) for(int i=0;i<N;i++) { cout << v[i] << " "; } cout << endl;
#define debug_vv(v,H,W) for(int i=0;i<H;i++) { for(int j=0;j<W;j++) { cout << v[i][j] << " "; } cout << endl; }

using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef pair<int, int> pii;

void Main()
{
	int N; cin >> N;
	vi A(N);
	vi B(N);
	vi C(N);
	ll res = 0;
	rep(i,N) {
		cin >> A[i];
	}
	rep(i,N) {
		cin >> B[i];
		res += B[i];
	}
	rep(i,N - 1) {
		cin >> C[i];
	}
	rep(i,N - 1) {
		if (A[i] + 1 == A[i + 1]) {
			res += C[A[i] - 1];
		}
	}
	cout << res << endl;
}

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


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

int n, t;
std::vector<int> a;

int calc_best();

int main()
{
	scanf("%d%d", &n, &t);
	a.resize(n);
	for (int i = 0; i < n; i++) scanf("%d", &a[i]);
	t /= 2;
	
	int min{a[0]}, best{-(1 << 30)};
	for (int i = 1; i < n; i++)
	{
		best = std::max(best, a[i] - min);
		min = std::min(min, a[i]);
	}

	min = a[0];
	int answer{};
	for (int i = 1; i < n; i++)
	{
		if (a[i] - min == best)
			answer++;
		min = std::min(min, a[i]);
	}
	printf("%d\n", answer);

	return 0;
}

Measured memory_bytes: 640
#include<bits/stdc++.h>
const int N=505,mo=1e9+7;
int n,X,i,j,k,l,aa[N],C[N][N],ans,nw,f[2][N][N],mi[N][N];
int main(){
	for(i=0;i<N;++i)for(j=*mi[i]=1;j<N;++j)mi[i][j]=1ll*mi[i][j-1]*i%mo;
	for(i=**C=1;i<N;++i)for(j=*C[i]=1;j<=i;++j)C[i][j]=(C[i-1][j-1]+C[i-1][j])%mo;
	scanf("%d%d",&n,&X);
	for(i=1;i<=n;++i)scanf("%d",&l),++aa[l];
	f[0][0][0]=1;
	for(i=X;i;--i){
		nw^=1;memset(f[nw],0,sizeof f[nw]);
		for(j=0;i*j<=X;++j)for(k=i*j;k<=X;++k)if(f[!nw][j][k])for(l=0;k+l*i<=X;++l)
			f[nw][j+l][k+l*i]=(f[nw][j+l][k+l*i]+1ll*f[!nw][j][k]*C[j+l][j]%mo*mi[k-j*(i-1)+l][aa[i]])%mo;
	}
	ans=X&1?mo-f[nw][0][0]:f[nw][0][0];
	for(i=1;i<=X;++i)for(j=1;j+i-1<=X;++j)
		ans=(ans+1ll*(X-j&1?mo-1:1)*C[X-(j+i-1)+i][i]%mo*f[nw][i][j])%mo;
	printf("%d\n",ans);
	return 0;
}

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

int main(void)
{
    string A,B;
    cin>>A>>B;
    if(A.length()>B.length())
    {
        cout <<"GREATER"<<endl;
        return 0;
    }
    if(A.length()<B.length())
    {
        cout <<"LESS"<<endl;
        return 0;
    }

    for(int i=0;i<A.length();++i)
    {
        if(A[i]<B[i])
        {
            cout <<"LESS"<<endl;
            return 0;
        }
        else if(A[i]>B[i])
        {
            cout <<"GREATER"<<endl;
            return 0;
        }
    }
    cout <<"EQUAL"<<endl;
    return 0;
}


Measured memory_bytes: 256
ndInp = input().split()
N = int(ndInp[0])
D = int(ndInp[1])

ans = 0
D2 = D*D

for i in range(N):
    inp = input().split()
    X = int(inp[0])
    Y = int(inp[1])

    dist2 = X*X + Y*Y

    if dist2 <= D2:
        ans+=1

print(ans)

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

using namespace std;

#define int long long
const int mod=(int)1e9+7;

void test_case(){
    int n,sum=0;
    cin>>n;
    for(int i=1;i<=n;i++){
        if(i%3==0||i%5==0)continue;
        sum+=i;
    }
    cout<<sum;
}

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


Measured memory_bytes: 3652
N,K= map(int,(input().split()))
p = list(map(int,input().split()))
rui_p=[]
rui_p.append(0)
sum_p=[]
for i in range(N):
  rui_p.append(rui_p[i]+p[i])
for j in range(K,N+1):
  sum_p.append(rui_p[j]-rui_p[j-K])

msp=max(sum_p)
ans=(msp/2)+(0.5*K)
print(ans)

Measured memory_bytes: 25060
s=input()
K=int(input())
abc=list("abcdefghijklmnopqrstuvwxyz")

N=len(s)
L=[]
flag=False
for a in abc:
    for i in range(N):
        if s[i]==a:
            L.append(s[i:])
            
    if flag:
        break
L=sorted(L)
#print(L)
ans=[]
for l in L:
    n=len(l)
    for i in range(n):
        t=l[:i+1]
        if t not in ans:
            ans.append(l[:i+1])
    if len(ans)>=K:
        break
#print(ans)
print(ans[K-1])




Measured memory_bytes: 24688
#include <bits/stdc++.h>
#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 equals(a, b) (fabs((a) - (b)) < EPS)
using namespace std;
typedef long long ll;
const ll mod = 1000000007;
const ll mod2 = 998244353;
const ll INF = 1e18;
const long double EPS = 1e-10;

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

  cout << (n - 1) * (m - 1) << endl;



  
  return 0;
}

Measured memory_bytes: 256
/*
title:

url:
*/

#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <functional>
#include <queue>
#include <limits>
#include <string>
#include <utility>
#include <cstring>
#include <map>
#include <cmath>
#include <iterator>

using namespace std;

#define rep(i, n) for (int i = 0; i < (n); i++)
#define INF 1000000007

typedef pair<int, int> pint;
typedef long long ll;

int main()
{
    int N, M;
    cin >> N >> M;
    vector<vector<pint>> data(N, vector<pint>(0, pint(0, 0)));
    vector<string> ans(M, "");
    rep(i, M)
    {
        int city, year;
        cin >> city >> year;
        data[city - 1].push_back(pint(year, i));
    }
    rep(i, N)
    {
        sort(data[i].begin(), data[i].end());
    }
    rep(i, N)
    {
        string city_string = to_string(i + 1);
        while (city_string.size() != 6)
        {
            city_string = "0" + city_string;
        }
        rep(j, data[i].size())
        {
            string tmp = to_string(j + 1);
            while (tmp.size() != 6)
            {
                tmp = "0" + tmp;
            }
            ans[data[i][j].second] = city_string + tmp;
        }
    }
    rep(i, ans.size())
    {
        cout << ans[i] << endl;
    }
}

Measured memory_bytes: 12416
from collections import defaultdict


def submit():
    n = int(input())
    modp = 10 ** 9 + 7
    chars = ["A", "C", "G", "T"]
    modp = 10 ** 9 + 7
    # ACGTの4通りの遷移
    # 禁止は次の通り
    # AG -> C
    # A*G -> C
    # GA -> C
    # AC -> G
    # AG* -> C

    # このため,直前の三文字を覚えるようなdpをする
    dp = [defaultdict(int) for _ in range(n + 1)]

    for c1 in chars:
        for c2 in chars:
            for c3 in chars:
                k = c1 + c2 + c3
                if k == "AGC":
                    continue
                if k == "ACG":
                    continue
                if k == "GAC":
                    continue

                dp[3][k] = 1

    for i in range(4, n + 1):
        for k, v in dp[i - 1].items():
            for c in chars:
                # *AG -> C
                if k[1] == "A" and k[2] == "G" and c == "C":
                    continue
                # A*G -> C
                if k[0] == "A" and k[2] == "G" and c == "C":
                    continue
                # *GA -> C
                if k[1] == "G" and k[2] == "A" and c == "C":
                    continue
                # *AC -> G
                if k[1] == "A" and k[2] == "C" and c == "G":
                    continue
                # AG* -> C
                if k[0] == "A" and k[1] == "G" and c == "C":
                    continue

                new_k = k[1:] + c
                dp[i][new_k] += dp[i - 1][k]
                dp[i][new_k] %= modp

    ans = sum(v % modp for v in dp[n].values())
    print(ans % modp)
    

submit()

Measured memory_bytes: 4084
#include <iostream>
#include <cstdio>

using namespace std;

struct Node {
    int key;
    Node *prev, *next;
};

Node *nil;

void insert(int k) {
    Node* first = nil->next;
    Node* no = (Node *)malloc(sizeof(Node));
    no->key = k;
    no->next = first;
    no->prev = nil;
    first->prev = no;
    nil->next = no;
}

void deleteNode(Node *no) {
    if (no == nil) {
        return;
    }
    no->next->prev = no->prev;
    no->prev->next = no->next;
    free(no);
}

void deleteKey(int k) {
    Node* no = nil->next;
    while (true) {
        if (no == nil) {
            break;
        }
        if (no->key == k) {
            deleteNode(no);
            return;
        }
        no = no->next;
    }
}

void deleteFirst() {
    deleteNode(nil->next);
}

void deleteLast() {
    deleteNode(nil->prev);
}

int main() {
    int n;
    scanf("%d", &n);
    nil = (Node *)malloc(sizeof(Node));
    nil->prev = nil;
    nil->next = nil;

    while(n--) {
        char tmp[15];
        scanf("%s", tmp);
        string o = tmp;
        int k;
        if (o == "insert") {
            scanf("%d", &k);
            insert(k);
        } else if (o == "delete") {
            scanf("%d", &k);
            deleteKey(k);
        } else if (o == "deleteFirst") {
            deleteFirst();
        } else if (o == "deleteLast") {
            deleteLast();
        }
    }

    Node* no = nil->next;
    bool first = true;
    while (true) {
        if (no == nil) {
            break;
        }
        if (!first) {
            printf(" ");
        }
        printf("%d", no->key);
        first = false;
        no = no->next;
    }
    printf("\n");

    return 0;
}


Measured memory_bytes: 34440
import java.io.*;
import java.util.*;


public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		Printer pr = new Printer(System.out);

		long n = sc.nextLong();
		long x = sc.nextLong();

		long ret = 0;
		long a = Math.min(x, n - x);
		long b = Math.max(x, n - x);
		while (a > 0) {
			ret += 3 * a * (b / a);
			long tmp = b % a;
			b = Math.max(a, tmp);
			a = Math.min(a, tmp);
		}

		pr.println(ret);

		pr.close();
		sc.close();
	}

	@SuppressWarnings("unused")
	private static class Scanner {
		BufferedReader br;
		Iterator<String> it;

		Scanner (InputStream in) {
			br = new BufferedReader(new InputStreamReader(in));
		}

		String next() throws RuntimeException  {
			try {
				if (it == null || !it.hasNext()) {
//					it = Arrays.asList(br.readLine().split(" ")).iterator();
					it = Arrays.asList(br.readLine().split("\\p{javaWhitespace}+")).iterator();
				}
				return it.next();
			} catch (IOException e) {
				throw new IllegalStateException();
			}
		}

		int nextInt() throws RuntimeException {
			return Integer.parseInt(next());
		}

		long nextLong() throws RuntimeException {
			return Long.parseLong(next());
		}

		float nextFloat() throws RuntimeException {
			return Float.parseFloat(next());
		}

		double nextDouble() throws RuntimeException {
			return Double.parseDouble(next());
		}

		void close() {
			try {
				br.close();
			} catch (IOException e) {
//				throw new IllegalStateException();
			}
		}
	}

	private static class Printer extends PrintWriter {
		Printer(PrintStream out) {
			super(out);
		}
	}
}


Measured memory_bytes: 8404
#k = int(input())
#s = input()
#a, b = map(int, input().split())
#s, t = map(str, input().split())
#l = list(map(int, input().split()))
#l = [list(map(int,input().split())) for i in range(n)]
#a = [list(input()) for _ in range(n)]
#a = [int(input()) for _ in range(n)]


n = int(input())

ans = 0

for i in range(n):
    l, r = map(int, input().split())
    ans += r - l + 1
print(ans)


Measured memory_bytes: 9000
/*こちらの方のブログを読んで納得できました
https://t.co/5ulfEGOPff
*/
#include<stdio.h>
#include<stdlib.h>
int compUp(const void*a, const void*b){
    return *(int*)a - *(int*)b;
}

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

    qsort(a, n, sizeof(int), compUp);
    
    int median = a[n/2];
    long long int ans = 0;
    for(int i = 0; i < n; i++){
        ans += (long long int)abs(a[i] - median);
    }
    printf("%lld\n", ans);
    return 0;
}

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

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


Measured memory_bytes: 1024
/*#pragma GCC target("avx512f,avx512dq,avx512cd,avx512bw,avx512vl")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")*/
#include<bits/stdc++.h>
using namespace std;

int INF=1000000000;
int dp[1000001],dp_odd[1000001],n,ans1,ans2;

int main(){
    int i,j;
    //dpテーブルの初期化
    for(i=0;i<1000001;i++){
        dp[i]=INF;
        dp_odd[i]=INF;
    }
    dp[0]=0;
    dp_odd[0]=0;

    //前計算
    for(i=1;i<=181;i++){
        n=(i*(i+1)*(i+2))/6;
        for(j=0;j<1000001;j++){
            if(dp[j]!=INF && j+n<=1000000){
                dp[j+n]=min(dp[j+n],dp[j]+1);
            }
        }
        if(n%2==1){
            for(j=0;j<1000001;j++){
                if(dp_odd[j]!=INF && j+n<=1000000){
                    dp_odd[j+n]=min(dp_odd[j+n],dp_odd[j]+1);
                }
            }   
        }
    }

    while(cin>>n,n!=0)cout<<dp[n]<<" "<<dp_odd[n]<<"\n";
}


Measured memory_bytes: 10884
fun main(args: Array<String>) {
  val N = readString()
  if (N[0] == N[1] && N[1] == N[2] || N[1] == N[2] && N[2] == N[3]) {
    println("Yes")
  } else {
    println("No")
  }
}

fun readString() = readLine()!!
fun readStrings() = readString().split(" ")
fun readInt() = readString().toInt()
fun readInts() = readStrings().map { it.toInt() }


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

int main() {
  int s;
  int count = 0;
  cin >> s;
  if(s - 100 >= 0){
    count++;
    s -= 100;
  }
  if(s - 10 >= 0){
    count++;
    s -= 10;
  }
  if(s - 1 >= 0){
    count++;
  }
  cout << count << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
#define mod 1000000000
#define ll long long
#define ull unsigned long long
#define vi vector<ll>
#define vs vector<string>
#define psi pair<string,ll>
#define pii pair<ll,ll>
#define vsi vector<psi>
#define vii vector<pii>
#define mp make_pair
#define pb push_back
#define rep(n) for(long i=0;i<n;i++)
#define repr(n) for(long i=(n-1);i>=0;i--)
#define fori(i,a,b) for(auto i=a;i<=b;i++)
#define ford(i,b,a) for(auto i=b;i>=a;i--)
#define mset(a,i) memset(a,i,sizeof(a))
#define minv(a) min_element(a.begin(),a.end())
#define maxv(a) max_element(a.begin(),a.end())
#define min3(a,b,c) min(a,min(b,c))
#define max3(a,b,c) max(a,max(b,c))
#define sotit(a) sort(a.begin(),a.end());
#define sot(a) sort(a,a+n);
#define ff first
#define maxheap(v) priority_queue<v>
#define minheap(v) priority_queue<v, vector<v>, greater<v>>
#define ss second
#define endl "\n"
#define NL cout<<endl;
#define printmat(a,m,n) for(int i=0;i<m;i++){       \
                            for(int j=0;j<n;j++){   \
                                cout<<a[i][j]<<" "; \
                            }                       \
                            cout<<endl;             \
                        }
#define dbgn(x) cout<<" $ "<<x<<" $ "<<endl;
#define dbg(x) cout<<" $ "<<x<<" $ ";
#define all(v) v.begin(),v.end()
#define show(a,n) for(int i=0;i<n;i++){ cout<<a[i]<<" "; } NL
#define fast_io() cin.sync_with_stdio(false);cout.sync_with_stdio(false);cin.tie(NULL);
 
// lower_bound - which does not compare less than val
// upper_bound - which compares greater than val
int main() {
    fast_io()
 
    double a,b,x;
    cin>>a>>b>>x;
    double pi = 3.14159265358979;
    if(x>=(a*a*b)/2){
        double theta = atan((a*a*a)/(2*b*a*a-2*x));
        cout<<fixed<<setprecision(12)<<90 - (theta*180)/pi;
    }
    else{
        double theta = atan((b*b*a)/(2*x));
        cout<<fixed<<setprecision(12)<<(theta*180)/pi;
    }
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main()
{
  int n ;
  cin >> n ;
 for(int i=3;i<=n;i++){
     int x=i ;
     if((x%3)==0){
        cout << " " << i ;
        continue ;
     }
    while(x){
        if(x%10==3){
            cout << " " << i ;
            break;
        }
        x/=10;
    }
 }
  cout << endl;
 return 0;  

}




Measured memory_bytes: 3096
object Main extends App {
  def insertionSort(x: Int, list: List[Int]): List[Int] = list match {
    case Nil =>
      List(x)
    case (y :: ys) =>
      if (x < y) x :: y :: ys else y :: insertionSort(x, ys)
  }

  val num: Int = scala.io.StdIn.readLine().toInt
  var unsorted: List[Int] = scala.io.StdIn.readLine().split(" ").toList.map(_.toInt)
  var sorted: List[Int] = List()
  for (i <- 0 to (num - 1)) {
    val x = unsorted.head
    unsorted = unsorted.tail
    sorted = insertionSort(x, sorted)
    if (unsorted.isEmpty) println(sorted.mkString(" "))
    else println(sorted.mkString(" ") + " " + unsorted.mkString(" "))
  }
}

Measured memory_bytes: 46296
N, K, *A = [int(_) for _ in open(0).read().split()]
A.sort()

class Factorial:
    def __init__(self, max_fact, mod):
        #mod should be prime number
        #using homogeneous_product(n,r), max_fact ≧ max(n+r-1)
        f = [1] * (max_fact + 1)
        for idx in range(2, max_fact + 1):
            f[idx] = f[idx - 1] * idx
            f[idx] %= mod
        if mod > max_fact:
            fi = [pow(f[-1], mod - 2, mod)]
            for idx in range(max_fact, 0, -1):
                fi += [fi[-1] * idx % mod]
            fi = fi[::-1]
        else:
            fi = [pow(n, mod - 2, mod) for n in f]
        self.mod = mod
        self.f = f
        self.fi = fi

    def factorial(self, n):
        return self.f[n]

    def factorial_inverse(self, n):
        return self.fi[n]

    def combination(self, n, r):
        f = self.f
        fi = self.fi
        return f[n] * fi[r] * fi[n - r] % self.mod

    def permutation(self, n, r):
        return self.f[n] * self.fi[n - r] % self.mod

    def homogeneous_product(self, n, r):
        f = self.f
        fi = self.fi
        return f[n + r - 1] * fi[r] * fi[n - 1] % self.mod


max_fact = 10**6
mod = 10**9 + 7
fact_instance = Factorial(max_fact, mod)
comb = fact_instance.combination
perm = fact_instance.permutation
combrep = fact_instance.homogeneous_product

ans = 0
for i, a in enumerate(A):
    if i + 1 >= K:
        ans += A[i] * comb(i, K - 1)
    if N - i >= K:
        ans -= A[i] * comb(N - 1 - i, K - 1)
    ans %= mod
print(ans)


Measured memory_bytes: 101436
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
using namespace std;
typedef long long ll;
const int MOD = (int)1e9 + 7;
const double PI = 3.14159265358979323846;
template <class T, class U>
void chmin(T& t, const U& u) {
  if (t > u) t = u;
}
template <class T, class U>
void chmax(T& t, const U& u) {
  if (t < u) t = u;
}

int main(void) {
  int n, x, t;
  cin >> n >> x >> t;
  int ans = n / x * t;
  if (n % x != 0) ans += t;
  cout <<ans<< endl;
  return 0;
}

Measured memory_bytes: 3628
#include <bits/stdc++.h>
#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=a;i<=(ll)(b);i++)
#define FORD(i,a,b) for(ll i=a;i>=(ll)(b);i--)
#define ALL(x) (x).begin(),(x).end() 
#define SIZE(x) ((ll)(x).size())
#define MAX(x) *max_element(ALL(x))
#define MIN(x) *min_element(ALL(x))
#define INF 1000000000
using namespace std;
typedef long long ll;

int main() {
    int A, B;
    cin >> A >> B;

    int ans = 0;
    ans = max(A+B, A-B);
    ans = max(ans, A*B);

    cout << ans << endl;
}

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

typedef long long int ll;
typedef pair<ll, ll> p_ll;
typedef vector<pair<ll, ll>> vec_p; //vector<pair<ll, ll>> pairs(n) ,pairs.at(i) = make_pair(i*i, i)

#define ture ture
#define flase false
#define falg flag

#define REP(i, x) for (ll i = 0; i < (ll)(x); i++)
#define REPS(i, x) for (ll i = 1; i <= (ll)(x); i++)
#define RREP(i, x) for (ll i = ((ll)(x)-1); i >= 0; i--)
#define RREPS(i, x) for (ll i = ((ll)(x)); i > 0; i--)
#define all(x) (x).begin(), (x).end()

const ll MOD = pow(10, 9) + 7;
const ll LLINF = pow(2, 61) - 1;//llの最大9*10^18
const int INF = pow(2, 30) - 1;

ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }

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

    ll N;
    string S;
    cin >> N;

    vector<ll> a(N+10);

    REP(i,N+1){
        a.at(i) = 0;
    }

    REPS(x,100){
        REPS(y,100){
            REPS(z,100){
                ll tmp = x * x + y * y + z * z + x * y + y * z + z * x;
                if(tmp<=N){
                    a.at(tmp)++;
                }
            }
        }
    }

    REPS(i,N){
        cout << a.at(i) << endl;
    }
}


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

using ll = long long;
using namespace std;

int main(){
    
    string S;
    cin >> S;
    string ans;
    
    for(int i = 0; i < S.size()/2; i++){
        ans += "hi";
    }   
    if(S == ans){
        cout << "Yes" << endl;
    }else{
        cout << "No" << 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;
typedef long long ll;

const int mod = 1000000007;

ll func(ll a){
    if(a%2==0){
        if((a/2)%2==0){
            return 0 ^ a;
        }else{
            return 1 ^ a;
        }
    }else{
        if(((a+1)/2)%2==0){
            return 0;
        }else{
            return 1;
        }
    }
}
int main(){
    ll a, b;
    cin >> a >> b;
    ll ans = func(a - 1) ^ func(b);
    cout << ans << endl;
}

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

typedef struct{
  double x;
  double y;
} XY;

int n;

void kock(int, XY, XY);

int main(){
  int n;
  XY p1 = {0, 0}, p2 = {100, 0};

  scanf("%d", &n);
  

  printf("%f %f\n", p1.x, p1.y);

  kock(n, p1, p2);

  printf("%f %f\n", p2.x, p2.y);


  return 0;
}

void kock(int n, XY p1, XY p2){
  XY s, t, u;

  if(n != 0){
    
    s.x = (2*p1.x + 1*p2.x) / 3;
    s.y = (2*p1.y + 1*p2.y) / 3;
    t.x = (1*p1.x + 2*p2.x) / 3;
    t.y = (1*p1.y + 2*p2.y) / 3;
    
    u.x = (t.x - s.x)*cos(M_PI/3) - (t.y - s.y)*sin(M_PI/3) + s.x;
    u.y = (t.x - s.x)*sin(M_PI/3) + (t.y - s.y)*cos(M_PI/3) + s.y;
   

    kock(n - 1, p1, s);
    printf("%f %f\n", s.x, s.y);
    
    kock(n - 1, s, u);
    printf("%f %f\n", u.x, u.y);

    kock(n - 1, u, t);
    printf("%f %f\n", t.x, t.y);

    kock(n - 1, t, p2);
  }
}



Measured memory_bytes: 2108
import java.util.*;

public class Main {
	public static void main(String[] args) {
		int i,j;
		Scanner sc = new Scanner(System.in);
		int r = Integer.parseInt(sc.next());
		int g = Integer.parseInt(sc.next());
		int b = Integer.parseInt(sc.next());
		int n = Integer.parseInt(sc.next());
		sc.close();
		sc = null;
		int cnt=0;
		int imax=n/r;
		int jmax=n/g;
		int ir,jg;
		for(i=0;i<=imax;i++) {
			ir=i*r;
			for(j=0;j<=jmax;j++) {
				jg=j*g;
				if(ir+jg>n)break;
				if((n-(ir+jg))%b==0)cnt++;
			}
		}
		System.out.println(cnt);
	}
}


Measured memory_bytes: 23252
//c.c C-Christmas Eve
#include<stdio.h>
#include<stdlib.h>
typedef long long lld;

int cmp(const void *a,const void *b){
    if(*(lld*)a<*(lld*)b){
        return -1;
    }else{
        return 1;
    }
    return 0;
}

int main(void){
    lld n,k;
    scanf("%lld %lld",&n,&k);
    lld h[n];
    for(int i=0;i<n;++i){
        scanf("%lld",&h[i]);
    }

    qsort(h,n,sizeof(lld),cmp);

    lld diff = h[n-1] - h[0];

    for(int i=0;i<=n-k;++i){
        if(diff>h[i+k-1]-h[i]){
            diff = h[i+k-1] - h[i];
        }
    }
    printf("%lld\n",diff);
    return 0;
}

Measured memory_bytes: 1788
#include <stdio.h>
int main(void) {
    int l1,l2,l3,rec=0,loz=0;
    while(scanf("%d,%d,%d",&l1,&l2,&l3)!=EOF) {
        if(l1*l1+l2*l2==l3*l3) rec++;
        if(l1==l2) loz++;
    }
    printf("%d\n%d\n",rec,loz);
    return 0;
}

Measured memory_bytes: 596