akhauriyash/Code-Regression huggingface dataset:
#[allow(unused_imports)]
use std::cmp::max;
#[allow(unused_imports)]
use std::cmp::min;
#[allow(unused_imports)]
use std::fmt;
#[allow(unused_imports)]
use std::fmt::Debug;
#[allow(unused_imports)]
use std::io;
#[allow(unused_imports)]
use std::str::FromStr;

fn main() {
    let input = get_vec_input();
    let target: i64 = input[0];
    let _n: i64 = input[1];
    let p: Vec<i64> = get_vec_input();
    let q = -100..=200;
    let mut result: i64 = 0;
    q.filter(|x| !p.contains(x)).for_each(|x| {
        if (target - result).abs() > (target - x).abs() {
            result = x;
        }
    });
    println!("{}", result);
}

#[allow(dead_code)]
fn get_digit(value: i64) -> i64 {
    let mut digit = 0i64;
    let mut value = value;
    while value != 0 {
        value /= 10;
        digit += 1;
    }
    digit
}

#[allow(dead_code)]
fn sum_digit2(value: String) -> u32 {
    return value.chars().fold(0u32, |a, b| a + b.to_digit(10).unwrap());
}

#[allow(dead_code)]
fn sum_digit(value: i64) -> i64 {
    if value < 10 {
        return value;
    }
    return sum_digit(value / 10) + value % 10;
}

#[allow(dead_code)]
fn update_max<T>(left: &mut T, right: T)
where
    T: std::cmp::Ord + std::clone::Clone,
{
    if *left < right {
        *left = right.clone();
    }
}

#[allow(dead_code)]
fn update_min<T>(left: &mut T, right: T)
where
    T: std::cmp::Ord + std::clone::Clone,
{
    if *left > right {
        *left = right.clone();
    }
}

#[allow(dead_code)]
fn get_vec_input<T>() -> Vec<T>
where
    T: FromStr,
    T::Err: Debug,
{
    let mut input = String::new();
    io::stdin()
        .read_line(&mut input)
        .expect("Failed to read line");
    let vec: Vec<T> = input
        .split_whitespace()
        .map(|x| x.parse().unwrap())
        .collect();
    vec
}

#[allow(dead_code)]
fn get_tuple_input() -> (u64, f32) {
    let mut s = String::new();
    io::stdin().read_line(&mut s).expect("");
    let mut iter = s.trim().split_whitespace();
    let c: u64 = iter.next().unwrap().parse().unwrap();
    let n: f32 = iter.next().unwrap().parse().unwrap();
    (c, n)
}

#[allow(dead_code)]
fn get_string_input() -> String {
    let mut s = String::new();
    io::stdin().read_line(&mut s).expect("");
    s.trim().to_string()
}


Measured memory_bytes: 2164
def int_multiple():
    return  [int(c) for c in input().split()]

def int_single():
    return int(input())

def str_multiple():
    return [c for c in input().split()]

def str_single():
    return input()

# start
a, b, c = int_multiple()

rest = c-(a-b)

if rest > 0:
    print(rest)
else:
    print(0)


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

using namespace std;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep2(i,s,n) for(int i=(int)(s);i<(int)(n);i++)

typedef long long ll;

const ll MOD = 1e+9+7;


int main(){
    int H,W,K,weight;
    cin >> H >> W >> K;
    vector<vector<ll>> dp(W+2,vector<ll>(H+1,0));
    dp[1][0]=1;
    if(W==1){
        cout << 1 << endl;
        return 0;
    }

    rep(h,H){
        rep2(j,1,W+1){
            ll X,Y,Z;
            X=0;
            Y=0;
            Z=0;
            for(int bit=0;bit<(1<<W-1);bit++){
                bool flag=true;
                rep(k,W-2){
                       if(((bit>>k)&1)&&((bit>>(k+1))&1)) flag=false;
                }
                if(flag){
                    if(j==1){
                        if((bit>>(j-1))&1) Z++;
                        else Y++;
                    }else if(j==W){
                        if((bit>>(j-2))&1) X++;
                        else Y++;
                    }else{
                        if((bit>>(j-1))&1) Z++;
                        else if((bit>>(j-2))&1) X++;
                        else Y++;
                    }
                }
            }
                                
            
            dp[j][h+1]=(((Y*dp[j][h])%MOD+(X*dp[j-1][h])%MOD)%MOD+(Z*dp[j+1][h])%MOD)%MOD;
        }
        
        
    }
    cout << dp[K][H] << endl;
}


Measured memory_bytes: 256
import math,itertools,fractions,heapq,collections,bisect,sys,queue,copy

sys.setrecursionlimit(10**7)
inf=10**20
mod=10**9+7
dd=[(-1,0),(0,1),(1,0),(0,-1)]
ddn=[(-1,0),(-1,1),(0,1),(1,1),(1,0),(1,-1),(0,-1),(-1,-1)]

def LI(): return [int(x) for x in sys.stdin.readline().split()]
# def LF(): return [float(x) for x in sys.stdin.readline().split()]
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def LS(): return sys.stdin.readline().split()
def S(): return input()

def main():
  n=I()
  l=LI()

  l.sort(reverse=True)

  ans=l[0]
  cnt=2
  for i in range(1,n):
    for j in range(2):
      cnt+=1

      if cnt>n:
        return ans

      ans+=l[i]

# main()
print(main())


Measured memory_bytes: 33300
# 2019/10/04

n=int(input())
a=[0]+list(map(int,input().split()))
b=[0]+[0]*n

for i in range(n):
    idx=n-i
    j=2
    cnt=0
    while idx*j<=n:
        cnt+=b[idx*j]
        j+=1
    cnt%=2
    if cnt==a[idx]:continue
    b[idx]=1
    
smb=sum(b)
print(smb)
for i in range(1,n+1):
    if b[i]:print(i,end=' ')
if smb:print()

Measured memory_bytes: 9260
void main(){
	if(inelm() >= 30){
		writeln("Yes");
	}else{
		writeln("No");
	}
}
     
import std.stdio, std.conv, std.algorithm, std.numeric, std.string, std.math, std.range;
     
// 1要素のみの入力
T inelm(T= int)(){
	return to!(T)( readln().chomp() );
}
     
// 1行に同一型の複数入力
T[] inln(T = int)(){
	T[] ln;
	foreach(string elm; readln().chomp().split())ln ~= elm.to!T();
	return ln;
}


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

int gcd(int i, int j){
  int lar,sma,tmp;
  lar = max(i,j);
  sma = min(i,j);
  while(lar%sma){
    tmp = lar % sma;
    lar = sma;
    sma = tmp;
  }
  return sma;
}

int main(){
  int K;
  uint64_t ans=0;
  cin >> K;
  for(int i=1; i<=K; i++){
    for(int j=1; j<=K; j++){
      for(int k=1; k<=K; k++){
        int num;
        num = gcd(i,j);
        ans += gcd(num,k);
      }
    }
  }
  cout  << ans << endl;
  return 0;
}


Measured memory_bytes: 3636
#include<iostream>
#include<string>
#include<vector>
#include<utility>
#include<queue>
#include<algorithm>
#include<cmath>
#include<cstdio>
#include<cstring>
#define INF 2147483647
#define llINF 9223372036854775807
#define pb push_back
#define mp make_pair 
#define F first
#define S second
#define ll long long

using namespace std;
typedef struct E{
  int to,cost;
}edge;
const int MAX_V=200100;
const int Inf=1e9;
vector<vector<edge> >E(MAX_V);
int d[MAX_V];
void dijkstra(int s){
  priority_queue<pair<int,int>,vector<pair<int,int> >,greater<pair<int,int> > >que;
  fill_n(d,MAX_V,Inf);
  d[s] = 0;
  que.push(pair<int,int>(0,s));
  while(!que.empty()){
    pair<int,int> p=que.top();que.pop();
    int v = p.second;
    if(d[v]<p.first)continue;
    for(int j=0;j<E[v].size();j++){
      edge t = E[v][j];
      if(d[t.to]>d[v]+t.cost){
	d[t.to]=d[v]+t.cost;
	que.push(pair<int,int>(d[t.to],t.to));
      }
    }
  }
}
int main(){
  int n,m;cin>>n>>m;
  for(int i=0;i<m;i++){
    int a,b;cin>>a>>b;
    edge e;
    e.to=b;e.cost=1;
    E[a].pb(e);
    e.to=a;
    E[b].pb(e);
  }
  dijkstra(1);
  if(d[n]==2)
    cout<<"POSSIBLE"<<endl;
  else
    cout<<"IMPOSSIBLE"<<endl;
  return 0;
}


Measured memory_bytes: 15080
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <climits>
#include <vector>
#include <string>
#include <queue>
#include <deque>
#include <list>
#include <stack>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <algorithm>

#define int long long
#define MOD 1000000007

#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 mp(a, b) make_pair((a), (b))

using namespace std;

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


signed main() {
	int D, G;
	cin >> D >> G;

	vector<int> p(D), c(D);
	rep(i, D) cin >> p[i] >> c[i];

	vector<int> perm;
	rep(i, D) perm.push_back(i);

	int ret = INT_MAX;
	do {
		int tmp = 0;
		int left = G;
		rep(i, D) {
			if (left <= 0) break;
			int idx = perm[i];
			int pt = 100 * (idx + 1);
			if (left <= pt * p[idx]) {
				int tmp2 = (left + pt - 1) / pt;
				tmp += tmp2;
				left -= tmp2 * pt;
			} else {
				int tmp2 = p[idx];
				tmp += tmp2;
				left -= tmp2 * pt + c[idx];
			}
		}
		ret = min(ret, tmp);
	} while (next_permutation(all(perm)));

	cout << ret << endl;
}


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

const int RLEN=1<<18|1;
inline char nc() {
	static char ibuf[RLEN],*ib,*ob;
	(ib==ob) && (ob=(ib=ibuf)+fread(ibuf,1,RLEN,stdin));
	return (ib==ob) ? -1 : *ib++;
}
inline int rd() {
	char ch=nc(); int i=0,f=1;
	while(!isdigit(ch)) {if(ch=='-')f=-1; ch=nc();}
	while(isdigit(ch)) {i=(i<<1)+(i<<3)+ch-'0'; ch=nc();}
	return i*f;
}

const int N=3e3+50;
int n,a[N],b[N],p[N];
vector <int> edge[N];
inline bool cmp(const int &x,const int &y) {return a[x]<a[y];}
int main() {
	n=rd();
	for(int i=1;i<=n;i++) a[i]=rd();
	for(int i=1;i<=n;i++) p[i]=i;
	sort(p+1,p+n+1,cmp);
	for(int i=1;i<n;++i) {
		int x=rd(), y=rd();
		edge[x].push_back(y);
		edge[y].push_back(x); 
	}
	for(int i=1;i<=n;i++) {
		int u=p[i];
		for(int e=edge[u].size()-1;e>=0;e--) {
			int v=edge[u][e];
			if(a[u]>a[v] && !b[v]) b[u]=1;
		}
	}
	
	for(int i=1;i<=n;i++) if(b[i]) cout<<i<<' ';
}

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

int main() {
  string S, T;
  int count = 0;
  cin >> S >> T;
  for (int i = 0; i < S.size(); i++)
  {
    if (S.at(i) != T.at(i))
    {
      count++;
    }
  }
  cout << count << endl;
}

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

using namespace std;

int main() {
    int N; cin >> N;
    double sum = 0;

    for (int i = 0; i < N; i++) {
        double x; cin >> x;
        string u; cin >> u;
        if (u == "JPY") sum += x;
        else sum += 380000.0*x;
    }

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

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

int main() {
  string s;
  cin >> s;
  
  if ((s[0] == s[1] && s[1] == s[2])
      || (s[1] == s[2] && s[2] == s[3])) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }
}

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

int main() {
	int n;
	cin >> n;
	int n1 = n % 10;
	int n2 = ((n - n1) / 10) % 10;
	int n3 = ((((n - n1) / 10) - n2) / 10) % 10;
	int n4 = ((((((n - n1) / 10) - n2) / 10) - n3) / 10) % 10;
	if (n1 == n2 && n2 == n3) {
		cout << "Yes" << endl;
	}
	else {
		if (n2 == n3 && n3 == n4) {
			cout << "Yes" << endl;
		}
		else {
			cout << "No" << endl;
		}
	}

	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define f0(i, n) for(int i=(0); i<n; i++)
#define f1(i, n) for(int i=(1); i<=n; i++)
#define Val(x) (((x)))

using namespace std;
typedef long long ll;
const int N = 2002;

int m, n, a[N][N], f[N][N], q, f2[N][N], d1[N][N], d2[N][N];

void enter(){
    cin >> m >> n >> q;
    f1(i, m){
        string s; cin >> s;
        f0(j, n) a[i][j + 1] = (s[j]=='1');
    }
    f1(i, m){
        f1(j, n){
            f[i][j] = f[i - 1][j] + f[i][j - 1] - f[i - 1][j - 1];
            if(a[i][j]){
                int dem = a[i][j - 1] + a[i - 1][j];
                f[i][j] += dem;
            }
            f2[i][j] = f2[i - 1][j] + f2[i][j - 1] - f2[i - 1][j - 1] + a[i][j];
        }
    }
    /// d1 ngang
    /// d2 doc
    f1(i, m){
        f1(j, n){
            d1[i][j] = d1[i][j - 1];
            if(a[i - 1][j] && a[i][j]) d1[i][j] += 1;
            d2[i][j] = d2[i - 1][j];
            if(a[i][j] && a[i][j - 1]) d2[i][j] += 1;
        }
    }
}

main(){
    ios_base::sync_with_stdio(0);
    
    enter();
    while(q--){
        int x1, y1, x2, y2;
        cin >> x1 >> y1 >> x2 >> y2;
        int ver = f2[x2][y2] - f2[x1 - 1][y2] - f2[x2][y1 - 1] + f2[x1 - 1][y1 - 1];
        int ed = f[x2][y2] - f[x1 - 1][y2] - f[x2][y1 - 1] + f[x1 - 1][y1 - 1];
        ed = ed - (d1[x1][y2] - d1[x1][y1 - 1]);
        ed = ed - (d2[x2][y1] - d2[x1 - 1][y1]);
        cout << ver - ed << endl;
    }
}


Measured memory_bytes: 80128
#include <bits/stdc++.h>
#define INF 2000000000000000000
#define ll long long
#define pll pair<ll, ll>
using namespace std;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  string S;
  cin >> S;
  ll N = S.size();
  ll ans = N;
  for (ll i = 0; i < N - 1; ++i) {
    if (S.at(i) != S.at(i + 1)) {
      ans = min(ans, max(i + 1, N - i - 1));
    }
  }
  cout << ans << "\n";
}


Measured memory_bytes: 3780
i,j,v,c[11],r;P(){printf("%5d",j?v:r);r+=v;c[j--]+=v;}main(n){for(;~scanf("%d",&n);memset(c,0,44))for(i=n;n&&~i--;P(),puts(""))for(r=0,j=n;j;P())!~i?v=c[j]:scanf("%d",&v);}

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

using ll = long long;
using namespace std;
const int INFint = 2e9+1;
const ll INFll = 2e18+1;
ll MOD=1e9+7;

int main(){
  int N,K;
  cin>>N>>K;
  vector<int> h(N);
  for(int i(0);i<N;i++){
    cin>>h[i];
  }
  sort(h.begin(),h.end());
  int ans(1e9+1);
  for(int i(0);i<=N-K;i++){
    ans = min(ans,h[i+K-1]-h[i]);
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 640
#!/usr/bin/env python3
import sys
from itertools import accumulate
from collections import Counter
from math import factorial
def comb(n, k):
    if n < k:
        return 0  
    k = min(n-k,k)
    ans = 1
    for i in range(1, k + 1):
        ans = (ans * (n + 1 - i) // i)
    return ans

def solve(N: int, A: "List[int]"):
    accum = accumulate(A)
    counter = dict(Counter(accum))

    answer = 0
    for key,value in counter.items():
        if key == 0:
            answer += value + comb(value,2)
        else:
            answer += comb(value,2)
    print(answer)
    return


def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    A = [int(next(tokens)) for _ in range(N)]  # type: "List[int]"
    solve(N, A)

if __name__ == '__main__':
    main()


Measured memory_bytes: 59668
#include <stdio.h>

int main()
{
int a[1000];
int m,n,x,cnt=0,cntt=0,i;
scanf("%d %d %d",&m,&n,&x);

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

for(i=0;i<n;i++)
{
if(a[i]<x)
{
cnt++;
}
else
cntt++;
}

if(cnt>=cntt)
{
printf("%d\n",cntt);
}
else
printf("%d\n",cnt);;

return 0;
}   

Measured memory_bytes: 1712
import scala.math._

object Main extends App {

  val YES = "YES"
  val Yes = "Yes"
  val NO = "NO"
  val No = "No"
  ///////////////////////////////////////////

  val sc = new java.util.Scanner(System.in)
  val r = sc.nextInt
//  val list = List.fill(3)(sc.nextInt)

  val ans = 3 * pow(r, 2)

  println(ans.toInt)


  ///////////////////////////////////////////

  def bigIterator(start: BigInt, end: BigInt, step: BigInt = 1) =
    Iterator.iterate(start)(_ + step).takeWhile(_ <= end)

  def lcm(a :Int, b :Int): Int =
    a / gcd(a, b) * b

  def lcm(a :Long, b :Long): Long =
    a / gcd(a, b) * b

  def gcd(a: Int, b: Int): Int =
    if (b == 0) a else gcd(b, a % b)

  def gcd(a: Long, b: Long): Long =
    if (b == 0) a else gcd(b, a % b)

  def setOrUpdated[A, B](a: Map[A, B], key: A, value: B, f: (B, B) => B) =
    a.get(key) match {
      case Some(v) => a.updated(key, f(value, v))
      case _ => a + (key -> value)
    }
}

Measured memory_bytes: 25424
#include<stdio.h>

int main()
{
	int a, b;
	char op;
	scanf("%d %c %d", &a, &op, &b);
	if(op == '+')
		printf("%d\n", a+b);
	else if(op == '-')
		printf("%d\n", a-b);
	
	return 0;
}

Measured memory_bytes: 128
n = int(input())
a = list(map(int, input().split()))
d = {}
total = 0

for i in a:
    if i not in d:
        d[i] = 1
    else:
        total += d[i]
        d[i] += 1

for i in a:
    ans = total - (d[i] - 1)
    print(ans)

Measured memory_bytes: 26268
#include <iostream>
#include <math.h>
#include <algorithm>
using namespace std;
int main(){
  int K,T;
  cin>>K>>T;
  int answer=0;
  for(int i=0;i<T;i++){
    int a;
    cin>>a;
    answer=max(answer,a*2-K-1);
  }
  cout<<answer<<endl;
  
  return 0;
}

Measured memory_bytes: 3108
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
//#include<cctype>
#include<climits>
#include<iostream>
#include<string>
#include<vector>
#include<map>
//#include<list>
#include<queue>
#include<deque>
#include<algorithm>
//#include<numeric>
#include<utility>
#include<complex>
//#include<memory>
#include<functional>
#include<cassert>
#include<set>
#include<stack>

const int dx[] = {1, 0, -1, 0};
const int dy[] = {0, 1, 0, -1};
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef pair<int, int> pii;

const int MAXN = 300010;
bool A[MAXN];
int T[MAXN];

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N, Q, ma;
    cin >> N >> Q;
    for (int i = 0; i < N; i++) {
        int c;
        cin >> c;
        A[c] = true;
        ma = max(ma, c);
    }
    int cur = 0;
    for (int i = 0; i < MAXN; i++) {
        T[i] = cur;
        if (A[i]) cur = i;
    }
    while (Q--) {
        int q;
        cin >> q;
        cur = ma;
        int ans = 0;
        while (cur) {
            int amari = cur%q;
            ans = max(ans, amari);
            cur = T[cur-amari];
        }
        cout << ans << endl;
    }
    return 0;
}

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

int main() {
  int age, pay, defo;

  cin >> age >> defo;

  if (age < 6) {
    pay = 0;
  }
  else if (age >= 6 && age < 13) {
    pay = defo / 2;
  }
  else {
    pay = defo;
  }

  cout << pay;

  return 0;
}

Measured memory_bytes: 256
#include <cstdlib>
#include <cstdint>
#include <iostream>
#include <limits>


template<
  typename T,
  typename F
>
static inline void
divisorPair(T n, const F& f)
{
  for (T i = 1; i * i <= n; i++) {
    if (n % i == 0) {
      f(i, n / i);
    }
  }
}


template<typename T>
static inline int
digits(T n, int base = 10)
{
  int cnt = 0;
  for (; n != 0; n /= base) {
    cnt++;
  }
  return cnt;
}


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

  std::uint64_t n;
  std::cin >> n;

  auto f = std::numeric_limits<int>::max();
  divisorPair(n, [&f](const auto&, const auto& b){
    f = std::min(f, digits(b));
  });
  std::cout << f << std::endl;

  return EXIT_SUCCESS;
}


Measured memory_bytes: 256
#include<cstdio>
#include<iostream>
#include<string>
#include<cmath>
#include<cstring>
#include<algorithm>
using namespace std;
int main()
{
	long long a,b,n;
	long long ans;
	scanf("%lld%lld%lld",&a,&b,&n);
	if(n>=b)
		{
			ans=b-1;
			ans*=a;
			ans/=b;
		}
	else
		{
			ans=n;
			ans*=a;
			ans/=b;
		}
	printf("%lld\n",ans);
	return 0;
}

Measured memory_bytes: 3724
// skip until line 65
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <deque>
#include <fstream>
#include <functional>
#include <iostream>
#include <istream>
#include <iterator>
#include <sstream>
#include <list>
#include <map>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <utility>
#include <vector>
#include <iomanip>
using namespace std;

#define BR "\n"
#define REP(i, n) for(int (i)=0;(i)<(n);++(i))
#define ALL(cont) begin(cont),end(cont)
#define AS_MOD(a, b) ((((a) % (b) ) + (b)) % (b))
#define MO(a) AS_MOD(a,mod)
#define FEACH(it, cont) for(auto (it) = begin(cont); it!=end(cont);++it)
#define FEACHR(it, cont) for(auto (it) = rbegin(cont); it!=rend(cont);++it)
#define pb push_back
#define pob pop_back
#define fi first
#define se second
#define getll() ([](){ll s;scanf("%lld", &s);return s;})()
#define getld() ([](){ld s;scanf("%Lf", &s);return s;})()
#define prl(P) printf("%lld", P)
#define prd(P) printf("%.10Lf", P)
#define pr(P) printf(P)
#define MAX(V, T) V=max(V,T)
#define MIN(V, T) V=min(V,T)

#define DumpArray(cont, from, to) for(int __i=from;__i<to;++__i) {cout<<"(" <<__i<<": " << cont[__i]<<")";} cout<<endl;

/*
 * ***_bound(6)
 * 5 6 6 6 6 6 7 7 7
 *   ^lower    ^upper
 * void reverse(c.begin(), c.end())
 *
 * graph
 * seg tree
 * dp
 * brute force
 */
struct Comparator{
    int operator()(int l, int r) const {
        return r<l;
    }
};
struct Vec;
//set<int, Comparator> S;

// solution below
typedef long long ll;
typedef long double ld;
typedef pair<ll,ll> P;
int main() {
    cout.precision(15);
    cout << fixed;
    ll A = 1;
    string B;
    cin >> A >>B;
    ll v;
    v=(B[0]-'0')*100;
    v+=(B[2]-'0')*10;
    v+=(B[3]-'0')*1;
    ll ans=A*(ll)(v);
    cout<<ans/100<<endl;

}


Measured memory_bytes: 3624
#include <iostream>
#include <set>
#include <map>
#include <string>
#include <math.h>
#include <algorithm>
#include <vector>
#include <stack>
#include <queue>
#include <bitset>
#include <string.h>

using namespace std;

// #define for(i,a,b) for (int i=(a);i<(b);++i)
typedef long long ll;
typedef pair<ll,ll> P;
#define REP(i,n) for(long long i = 0; i < (long long)(n); i++)
#define pb push_back // vectorに要素追加
#define INF (ll)1e18

ll mod = 1e9+7;
  
int main() {
	// 入力
	ll N;cin>>N;
    ll B[N];REP(i,N-1){
        cin>>B[i];
    }
	// 解法
    ll A[N];
    REP(i,N){
        if (i==0){
            A[i] = B[i];
        }
        if (i==N-1){
            A[i] = B[N-2];
        }
        else A[i] = min(B[i-1], B[i]);
    }
    ll ans = 0;
    REP(i,N) ans += A[i];
    
	//出力
	cout << ans << endl;
}


Measured memory_bytes: 256
import heapq
N,M=map(int,input().split())
A=tuple(map(int,input().split()))
l=[(-i,i) for i in A]
heapq.heapify(l)
for _ in range(M):
    m=heapq.heappop(l)
    heapq.heappush(l,(-(m[1]//2),m[1]//2))
a=0
for i in l:
    a+=i[1]
print(a)

Measured memory_bytes: 20676
#include<bits/stdc++.h>
using namespace std;
int n,a[50005],b[50005],flag;
signed main()
{
	cin>>n;
	for(int i=1;i<=n;i++)
	{
		cin>>a[i]>>b[i];
	}
	for(int i=1;i<=n-2;i++)
	{
	    if(a[i]==b[i] && a[i+1]==b[i+1] && a[i+2]==b[i+2])
	    {
	    	flag=1;
	    	cout<<"Yes"<<endl;
	    	break;
		}
		else
		{
			flag=0;
		}
	} 
	if(flag==0)
	{
		cout<<"No"<<endl;
	}
}

Measured memory_bytes: 3632
// ABC171 A
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  
  // 初期値
  char a;
  cin >> a;
  
  //Main loop
  if (a >= 'a' && a <= 'z'){
    cout << "a" << endl;
  } else if (a >= 'A' && a <= 'Z'){
    cout << "A" << endl;
  }
  return 0;
}

Measured memory_bytes: 3640
#include <iostream>
#include <sstream>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <string>
#include <vector>
#include <list>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <bitset>
#include <numeric>
#include <climits>
#include <cfloat>
using namespace std;

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

    while(--n >= 0){
         vector<int> x(10);
         for(int i=0; i<10; ++i){
             int a = 1;
             for(int j=0; j<10; ++j){
                 int b;
                 cin >> b;
                 if(b)
                     x[i] |= a;
                 a <<= 1;
             }
         }

         vector<vector<int> > dp(11, vector<int>(1<<10, 0));
         for(int i=0; i<10; ++i){
             for(int j=0; j<(1<<10); ++j){
                 int tmp = x[i];
                 tmp ^= dp[i][j];
                 tmp ^= j;
                 tmp ^= (j<<1) & ((1<<10)-1);
                 tmp ^= (j>>1);
                 dp[i+1][tmp] = j;
             }
         }

         vector<int> ret(10);
         int j = 0;
         for(int i=9; i>=0; --i)
             j = ret[i] = dp[i+1][j];

         for(int i=0; i<10; ++i){
             bitset<10> bs(ret[i]);
             cout << bs[0];
             for(int j=1; j<10; ++j)
                 cout << ' ' << bs[j];
             cout << endl;
         }
    }
}

Measured memory_bytes: 0
N = int(input())

gifts = []
for _ in range(N):
    x, u = map(str, input().split())
    gifts.append([float(x), u])
    
ans = 0.0
for g in gifts:
    x = g[0]
    u = g[1]
    
    if u == 'JPY':
        ans += x
    
    if u == 'BTC':
        ans += x * 380000.0

print(ans)

Measured memory_bytes: 3060
#include<bits/stdc++.h>
#define ll long long
#define rep(i,n) for(ll i=0;i<n;i++)
using namespace std;
const double pi = acos(-1);
const double eps = 1e-10;


template<class T>
bool equals(T a,T b){ return fabs((a)-(b)) < eps; }

struct Point{
    double x, y;
    Point(){}
    Point(double x, double y) : x(x), y(y){}
    Point operator + (Point p) { return Point(x+p.x, y+p.y); }
    Point operator - (Point p) { return Point(x-p.x, y-p.y); }
    Point operator * (double a) { return Point(x*a, y*a); }
    Point operator / (double a) { return Point(x/a, y/a); }
    double norm() {return x*x+y*y;}
    double abs() {return sqrt(norm());}

    bool operator < (const Point &p) const {
        return x!=p.x ? x<p.x : y<p.y;
    }
    bool operator == (const Point &p) const {
        return fabs(x-p.x) < eps && fabs(y-p.y) < eps;
    }
};

bool sort_x(Point a, Point b){ return !equals(a.x,b.x)?a.x<b.x:a.y<b.y; }
bool sort_y(Point a, Point b){ return !equals(a.y,b.y)?a.y<b.y:a.x<b.x; }

typedef Point Vector;
typedef vector<Point> Polygon;
double norm(Vector a) { return a.x*a.x+a.y*a.y; }
double abs(Vector a) { return sqrt(norm(a)); }
double dot(Vector a, Vector b) { return a.x*b.x+a.y*b.y; }
double cross(Vector a, Vector b) { return a.x*b.y-a.y*b.x; }

struct Segment {
    Point p1, p2;
    Segment(){}
    Segment(Point p1, Point p2):p1(p1),p2(p2){}
};
typedef Segment Line;

struct Circle{
    Point c;
    double r;
    Circle(){}
    Circle(Point c, double r) : c(c),r(r) {}
};

bool isOrthogonal(Vector a, Vector b){
    return equals(dot(a,b), 0.0);
}
bool isOrthogonal(Point a1, Point a2, Point b1, Point b2){
    return isOrthogonal(a1-a2, b1-b2);
}
bool isOrthogonal(Segment s1, Segment s2){
    return equals(dot(s1.p2-s1.p1, s2.p2-s2.p1),0.0);
}

bool isParallel(Vector a, Vector b){
    return equals(cross(a,b), 0.0);
}
bool isParallel(Point a1, Point a2, Point b1, Point b2){
    return isParallel(a1-a2, b1-b2);
}
bool isParallel(Segment s1, Segment s2){
    return equals(cross(s1.p2-s1.p1, s2.p2-s2.p1),0.0);
}

Point project(Segment s, Point p){
    Vector base=s.p2-s.p1;
    double r=dot(p-s.p1,base)/norm(base);
    return s.p1+base*r;
}

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    double x1,y1,x2,y2;
    cin>>x1>>y1>>x2>>y2;
    Segment s(Point(x1,y1),Point(x2,y2));
    ll q;cin>>q;
    rep(Q,q){
        double x0,y0;
        cin>>x0>>y0;
        Point x=project(s,Point(x0,y0));
        cout<<x.x<<" "<<x.y<<endl;
    }
    return 0;
}



Measured memory_bytes: 3308
#include <iostream>
#include <stdio.h>
#include <cstring>
#include <algorithm>
#include <cmath>
#include <vector>
#include <cstdlib>
using namespace std;
#define REP(i,n) for(int i = 0;i < (int)(n);i++)

int main() {
char a,b;
cin >> a >>b;
if(a<b)
cout<< "<";
else if(a==b)cout <<"=";
else cout <<">";
return(0);
}


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

const int INF = 1001001;

int main(){
    int n,m;
    cin >> n >> m;
    vector<int> c(m);
    rep(i,m) cin>>c[i];

    vector<vector<int>> dp(m+1,vector<int>(n+1,INF));
    dp[0][0]=0;
    rep(i,m){
        rep(j,n+1){
            if(j-c[i]>=0) dp[i+1][j]=min(dp[i][j],dp[i+1][j-c[i]]+1);
            else dp[i+1][j] = dp[i][j];
        }
    }
    cout << dp[m][n] << endl;
    /*
    cout << "dp" << endl;
    rep(i,dp.size()){
        rep(j,dp[i].size()){
            cout << dp[i][j] << " ";
        }
        cout << endl;
    }*/
}


Measured memory_bytes: 7148
import math
N = int(input())
num_list = []
for an in range(1,N+1):
    for bn in range(1,N+1):
        for cn in range(1,N+1):
            
            a = [an,bn,cn]
            ans = a[0]
            for i in range(1,3):
                ans = math.gcd(ans, a[i])
            num_list.append(ans)
print(sum(num_list))          

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

using namespace std;

int main()
{
    long long int n, k;
    
    cin >> n  >> k;
    
    long long int h[n];
    
    for(int i=0;i<n;i++)
    {
        cin >> h[i];
    }
    
    sort(h,h+n);
    
    int mini = 1000000000, o = 0, mini1;
    
    
    for(int i=k-1;i<n;i++)
    {
        mini1 = h[i] - h[o];
        o++;
        if(mini1 < mini) mini = mini1;
    }
    cout << mini << endl;
    
    return 0;
}

Measured memory_bytes: 1024
from itertools import product

x = int(input())

'''
 x = a^5 - b^5
   = (a - b)(a^4 + a^3 b + a^2 b^2 + a b^3 + b^4)

∵   (a - b)(a^4 + a^3 b + a^2 b^2 + a b^3 + b^4)
   = a^5 + a^4 b + a^3 b^2 + a^2 b^3 + a b^4
         - a^4 b - a^3 b^2 - a^2 b^3 - a b^4 - b^5
   = a^5 - b^5

a - b = ±1 となる解が存在する

このとき、

|x| = |a^4 + a^3 (a ± 1) + a^2 (a ± 1)^2 + a (a ± 1)^3 + (a ± 1)^4|
   ~= |a^4 + a^4 + a^4 + a^4 + a^4|
    = 5 a^4

であるから、1 <= x <= 10^9 に対して |a| <= (x / 5)^(1 / 4) となる

式の対象性より b についても同様な評価ができるので、

∴ -119 <= a, b <= 119 の範囲で解を探索すれば良い
'''

ab_s = product(range(-119, 120), range(-119, 120))

for a, b in ab_s:
    if x == (a ** 5 - b ** 5):
        print(a, b)
        exit(0)

Measured memory_bytes: 9188
#include <iostream>
#include <numeric>
#include <vector>

using namespace std;

using Int = int64_t;
using Uint = uint64_t;

int main() {
  Int N, K, R, S, P;
  cin >> N >> K;
  cin >> R >> S >> P;
  string t;
  cin >> t;
  const char* T = t.c_str();

  vector<Int> scores;
  for (size_t i = 0; i < t.size(); i++) {
    if (T[i] == 'r') {
      scores.emplace_back(P);
    } else if (T[i] == 's') {
      scores.emplace_back(R);
    } else {
      scores.emplace_back(S);
    }
  }

  vector<Int> gots(t.size());

  for (size_t i = 0; i < t.size(); i++) {
    if (i < K) {
      gots[i] = scores[i];
    } else {
      if (T[i - K] != T[i]) {
        gots[i] = scores[i];
      } else {
        if (gots[i - K] == 0) {
          gots[i] = scores[i];
        } else {
          gots[i] = 0;
        }
      }
    }
  }

  cout << accumulate(gots.begin(), gots.end(), 0) << endl;
  return 0;
}


Measured memory_bytes: 2164
H, W = map(int, input().split())
cost = [list(map(int, input().split())) for _ in range(10)]

for i in range(10):
    for j in range(10):
        for k in range(10):
            cost[j][k] = min(cost[j][k], cost[j][i] + cost[i][k])


sum_cost = 0
for i in range(H):
    num = [int(i) for i in input().split()]
    for n in num:
        if n != -1:
            sum_cost += cost[n][1]

print(sum_cost)

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

#define WIDTH 3001
#define HEIGHT 51

int dp[HEIGHT * WIDTH];

int main(void)
{
	int i, j, k;
	int n, m, s;
	while(scanf("%d%d%d", &n, &m, &s), n){
		n *= n;
		dp[0] = 1;
		for(i=1; i<WIDTH*HEIGHT; ++i)
			dp[i] = 0;

		for(i=1; i<=m; ++i){
			for(j=n; j>=0; --j){
				for(k=s; k>=0; --k){
					if(j && i <= k){
						dp[j*WIDTH + k] = (dp[j*WIDTH + k] + dp[(j-1)*WIDTH + k-i]) % 100000;
					}
				}
			}
		}

		printf("%d\n", dp[n*WIDTH + s]);
	}

	return 0;
}

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

int main()
{
    int N,K;
    int *p;
    int total=0;
    cin>>N>>K;

    p=new int[N];
    for(int i=0;i<N;i++)
        cin>>p[i];

    sort(p,p+N);
    for(int i=0;i<K;i++)
        total+=p[i];
    cout<<total;

}

Measured memory_bytes: 3184
#include <iostream>
#include <algorithm>
#include <utility>
#include <vector>
#include <string>
#include <map>
#include <queue>

using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
#define REP(i, n) for (int i = 0; i < (n); i++)
#define RREP(i, n) for (int i = (n) - 1; i >= 0; i--)
#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define RFOR(i, a, b) for (int i = (a); i > (b); i--)
#define ALL(a) (a).begin(), (a).end()

int main() {
    ll S;
    cin >> S;
    cout << "0 0 1000000000 1 ";
    if (S % 1000000000 == 0) {
        cout << "0 " << S / 1000000000 << endl;
    } else {
        cout << 1000000000 - S % 1000000000 << " " << S / 1000000000 + 1 << endl;
    }
    return 0;
}

Measured memory_bytes: 256
import sys, os
import bisect

f = lambda:list(map(int,input().split()))
if 'local' in os.environ :
    sys.stdin = open('./input.txt', 'r')

def solve():
    n = f()[0]
    a = f()
    b = f()
    c = f()

    a = sorted(a)
    b = sorted(b)
    c = sorted(c)

    ans = 0
    for i in range(n):
        mid = b[i]
        ans += bisect.bisect_left(a, mid) *(n- bisect.bisect_right(c, mid))
    
    print(ans)


    

solve()


Measured memory_bytes: 22720
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <cmath>
#include <cstring>
#include <vector>
#include <string>
#include <set>
#include <queue>
#include <stack>
#include <cctype>
#include <map>
using namespace std;

#define LL long long
#define ULL unsigned long long
#define LD long double
#define sqr(x) (x)*(x) 
#define M(a,b) (a)>(b)?(a):(b)
const int MAXN = 100010;
const int MAXM = 300010;
const int INF = 0x7fffffff;
const int MOD = 1e9+7;
const double eps = 1e-5;
const double pi=acos(-1.0); 

LL a[100010];
bool cmp(LL x, LL y) {return x < y;};
int main() {
	int n;
	scanf("%d", &n);
	for (int i=1; i<=n; ++i) scanf("%lld", &a[i]);
	sort(a+1, a+1+n, cmp);
	LL ans = 0;
	for (int i=1; i<=n; ++i) {
		if (a[i] <= ans+1) {
			ans += a[i];
		} else break;
	}
	printf("%lld\n", ans+1);
}

Measured memory_bytes: 1280
#![allow(non_snake_case, unused)]
use std::cmp::*;
use std::collections::*;
use std::f64::consts::*;

macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };

    ($next:expr, mut $var:ident : $t:tt $($r:tt)*) => {
        let mut $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

fn main() {
    input!{
        w: i64,
        h: i64,
        n: i64,
        arr: [(i64, i64, usize); n],
    }
    let mut x_min = 0i64;
    let mut x_max = w;
    let mut y_min = 0i64;
    let mut y_max = h;

    for &(x, y, a) in arr.iter() {
        match a {
            1 => x_min = max(x_min, x),
            2 => x_max = min(x_max, x),
            3 => y_min = max(y_min, y),
            4 => y_max = min(y_max, y),
            _ => print!("hoge"),
        }
    }
    println!("{}", max(0, (x_max - x_min)) * max(0, (y_max - y_min)))
}


Measured memory_bytes: 4352
import math
n = math.factorial(int(input()))
i = 2
ans = 1
M = 10**9+7
while i*i <= n:
  cnt = 1
  while n%i == 0:
    cnt += 1
    n //= i
  ans *= cnt
  i += 1
if n != 1:
  ans *= 2
print(int(ans%M))


Measured memory_bytes: 3060
x = int(input())

def fanc(s, x):
    for i in range(x + x, len(s), x):
        s[i] = False

def furui(n):
    s = [True] * n
    for x in range(2, int(n**0.5) + 1):
        if s[x]:
        	fanc(s, x)
    return [i for i in range(0,n) if s[i] and i > 1]

list = furui(10**6)
for i in range(len(list)):
	if list[i] >= x:
		print(list[i])
		exit(0)


Measured memory_bytes: 51312
### subroutines

def area(p0, p1, p2)
  v1x = p1[0] - p0[0]
  v1y = p1[1] - p0[1]
  v2x = p2[0] - p0[0]
  v2y = p2[1] - p0[1]
  (v1y * v2x - v1x * v2y) / 2
end

### main

id = 0

loop do
  line = ''
  line = gets.strip while line.empty?
  n = line.to_i
  break if n == 0

  pts = n.times.map{gets.split.map(&:to_f)}
  p0 = pts.shift
  #p [p0, pts]

  sum = 0.0

  for i in (0...(n - 2))
    pi = pts[i]
    pj = pts[i + 1]
    sum += area(p0, pi, pj)
  end

  id += 1
  puts [id, "%.1f" % sum].join(' ')
end

Measured memory_bytes: 6168
#include <iostream>

using namespace std;

const int MAX_X = 100, MAX_Y = 100;
char field[MAX_X+5][MAX_Y+5];

int size_x, size_y;

int dfs(int x, int y, char fruit) {
    // check size_x and size_y
    if(x < 0 || x >= size_x || y < 0 || y >= size_y) return 0;

    // check whether the first visit or not
    if(field[x][y] == '.') return 0;

    // check whether same fruit or not
    if(field[x][y] == fruit) {
        field[x][y] = '.';
        dfs(x+1, y, fruit);
        dfs(x, y+1, fruit);
        dfs(x-1, y, fruit);
        dfs(x, y-1, fruit);
    }

    return 0;
}

int solve(int size_x, int size_y) {
    // input
    for(int i = 0; i < size_x; i++) {
        cin >> field[i];
    }

    // Depth-First Search
    int ans = 0;
    for(int i = 0; i < size_x; i++) {
        for(int j = 0; j < size_y; j++) {
            char fruit = field[i][j];
            if(fruit != '.') {
                dfs(i, j, fruit);
                ans++;
            }
        }
    }

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

int main() {
    while(true) {
        // solve for each data set
        cin >> size_x >> size_y;
        if(size_x == 0 && size_y == 0) break;
        solve(size_x, size_y);
    }
    return 0;
}

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

using namespace std;


int main(){
	string s;
  	bool may_be_yymm = true;
	bool may_be_mmyy = true;
  	cin >> s;
	may_be_yymm &= (s[2]== '1' &&  '3' > s[3] && s[3] >= '0')||(s[2]== '0' &&  '9' >= s[3] && s[3] >= '1');
	may_be_mmyy &= (s[0]== '1' &&  '3' > s[1] && s[1] >= '0')||(s[0]== '0' &&  '9' >= s[1] && s[1] >= '1');
  	if( may_be_yymm && may_be_mmyy)
      cout <<"AMBIGUOUS" << endl;
  	else if(may_be_yymm)
      cout << "YYMM" << endl;
  	else if(may_be_mmyy)
      cout << "MMYY" << endl;
    else
      cout << "NA" <<endl;
  	
  	return 0;
}

Measured memory_bytes: 256
// 2011/08/16 Tazoe

#include <iostream>
using namespace std;

int main()
{
	for(int i=0; i<3; i++){
		int h1, m1, s1, h2, m2, s2;
		cin >> h1 >> m1 >> s1 >> h2 >> m2 >> s2;

		int t1 = h1*3600+m1*60+s1;
		int t2 = h2*3600+m2*60+s2;

		int t3 = t2-t1;

		int h3 = t3/3600;
		int m3 = t3%3600/60;
		int s3 = t3%60;

		cout << h3 << ' ' << m3 << ' ' << s3 << endl;
	}

	return 0;
}

Measured memory_bytes: 0
#include<stdio.h>
#include<stdlib.h>
int main(){
    int a,b=1;
    char s[4];
    // 整数の入力
  fgets(s,4,stdin);
  for(a=0;a<3;a++){
   if(s[a]=='7')b=0; 
  }
  if(b==0){printf("Yes");}
    else printf("No");
    return 0;
}

Measured memory_bytes: 1644
#include<stdio.h>
int main()
{
	int n;
	scanf("%d", &n);
	int i;
	long long int min = 1000006, max = -1000006, sum = 0, a;
	for (i = 0; i < n; i++)
	{
		scanf("%lld", &a);
		sum += a;
		if (min > a)
			min = a;
		if (max < a)
			max = a;
	}
	printf("%lld %lld %lld\n", min, max, sum);
	return 0;
}


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

#define L 20
#define Gard NULL

struct Tree{
  int nodekey;
  struct Tree *parent;
  struct Tree *leftch;
  struct Tree *rightch;
};

typedef struct Tree  *Search;
Search road;

void Insert(int );
void Pre(Search );
void In(Search );
Search Find(int ,Search);

int main(){
  int loop,numnode;
  char order[L];
  int i;
    
  scanf("%d",&loop);
  
  for(i=0;i<loop;i++){
    scanf("%s",order);
   
    if(order[0]=='i'){
      scanf("%d",&numnode);
      Insert(numnode);
    }
    
    else if(order[0]=='p'){
      In(road);
      printf("\n");
      Pre(road);
      printf("\n");
    }
    
    else if(order[0]=='f'){
      scanf("%d",&numnode);
    
      if(Find(numnode,road)!=Gard){
	printf("yes\n");
      }

      else{
	printf("no\n");
      }
    }
    
  }
  
  return 0;
}

void Insert(int numnode){
  Search xnode,ynode,znode;
  
  xnode=road;
  ynode=Gard;
  znode=malloc(sizeof(struct Tree));
  znode->nodekey=numnode;
  znode->leftch=Gard;
  znode->rightch=Gard;
  
  while(1){
    if(xnode==Gard)break;
    ynode=xnode;
    
    if(znode->nodekey<xnode->nodekey){
      xnode=xnode->leftch;
    }
    
    else{
      xnode=xnode->rightch;
    }
  }
  
  znode->parent=ynode;
  
  if(ynode==Gard){
    road=znode;
  }
  
  else if(znode->nodekey<ynode->nodekey){
    ynode->leftch=znode;
  }
  
  else{
    ynode->rightch=znode;
  }
  
}

void Pre(Search road){
  
  if(road==Gard){
    return;
  }
  
  printf(" %d",road->nodekey);
  
  Pre(road->leftch);
  Pre(road->rightch);
  
}

void In(Search road){
  
  if(road==Gard){
    return;
  }
  
  In(road->leftch);
  
  printf(" %d",road->nodekey);
  
  In(road->rightch);
}

Search Find(int numnode, Search road){
  
  if((road==Gard) || (numnode==road->nodekey)){
    return road;
  }
  
  else if(numnode<road->nodekey){
    return Find(numnode,road->leftch);
  }
  
  else{
    return Find(numnode,road->rightch);
  }
}



Measured memory_bytes: 20596
N = int(input())
a = 10**9 +7
A = [0]*(N+3)
A[0] =0
A[1] =0
A[2] =0
A[3]= 1
for i in range(4,N+1):
	A[i] = A[i-1]+ A[i-3]
print(A[N]%a)
#print(A)

Measured memory_bytes: 9224
import java.util.*;

class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String s = sc.next();
        if (s.contains("7"))
        {
            System.out.println("Yes");
        }
      	else {
          	System.out.println("No");
        }
    }
}

Measured memory_bytes: 35672
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(k,i,n) for(ll i=k;i<n;++i)
int main(void){
    ll h1,m1,h2,m2,k;
    cin>>h1>>m1>>h2>>m2>>k;
    cout<<(h2-h1)*60+(m2-m1)-k;
    
}


Measured memory_bytes: 3636
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cmath>
#include<vector>
#include<map>
#include<set>
#include<string>
#include<queue>
#include<stack>
using namespace std;
#define MOD 1000000007
#define INF (1LL<<60)
#define EPS (1e-10)
typedef long long Int;
typedef pair<Int, Int> P;

#define max(x, y) ((x)>(y)?(x):(y))
#define min(x, y) ((x)<(y)?(x):(y))

Int n;
Int a[20][20];

Int cost[1 << 16];
Int dp[1 << 16];

int main(){
  fill(dp, dp + (1<<16), -INF);
  cin >> n;
  for(int i = 0;i < n;i++)
    for(int j = 0;j < n;j++)
      cin >> a[i][j];

  for(int i = 1;i < (1<<n);i++){
    int last = 0;
    while((i&-i) != (1<<last))last++;
    cost[i] = cost[i - (1<<last)];
    for(int j = 0;j < n;j++){
      if((i >> j) % 2 == 0)continue;
      cost[i] += a[last][j];
    }
  }

  Int mask = (1 << n) - 1;
  dp[0] = 0;
  for(int i = 0; i < (1 << n);i++){
    int rem = mask ^ i;
    for(int j = rem;j > 0;j = (j-1) &rem){
      dp[i | j] = max(dp[i | j], dp[i] + cost[j]);
    }
  }

  cout << dp[mask] << endl;
  return 0;
}

Measured memory_bytes: 1280
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define pb push_back
#define fi first
#define se second
typedef pair<ll, ll> P;
using VP = vector<P>;
using VVP = vector<VP>;
using VI = vector<ll>;
using VVI = vector<VI>;
using VVVI = vector<VVI>;
const int inf = 1e9 + 7;
const ll INF = 1LL << 61;
const ll mod = 1e9 + 7;

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

vector<ll> inv, fact, invfact;
void Mod_build(int n = 2010101) {
    fact.resize(n + 1);
    inv.resize(n + 1);
    invfact.resize(n + 1);
    fact[0] = inv[0] = invfact[0] = 1;
    inv[1] = 1;
    for (ll i = 0; i < n; i++) {
        fact[i + 1] = fact[i] * (i + 1) % mod;
        if (i > 0) inv[i + 1] = mod - inv[mod % (i + 1)] * (mod / (i + 1)) % mod;
        invfact[i + 1] = invfact[i] * inv[i + 1] % mod;
    }
}
ll perm(int n, int k) {
    if (n < 0 || k < 0 || k > n) return 0;
    return fact[n] * invfact[n - k] % mod;
}
ll comb(int n, int k) {
    if (n < 0 || k < 0 || k > n) return 0;
    return (fact[n] * invfact[n - k] % mod) * invfact[k] % mod;
}
ll powmod(ll n, ll k) {
    k %= mod - 1;
    if (k < 0) k += mod - 1;
    ll ret = 1;
    while (k) {
        if (k & 1) ret = ret * n % mod;
        n = n * n % mod;
        k >>= 1;
    }
    return ret;
}

int main() {
    Mod_build();
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int i, j;
    ll k;
    cin >> k;
    string s;
    cin >> s;
    ll n = s.size();
    ll m = n + k;
    ll ans = 0;
    for (i = 0; i <= m; i++) {
        ll sum = comb(m - i - 1, n - 1) * powmod(25, k - i);
        sum %= mod;
        sum *= powmod(26, i);
        sum %= mod;
        ans += sum;
        ans %= mod;
    }
    cout << ans << endl;
}

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

class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int N = Integer.parseInt(sc.next());
    int[] H = new int[N];
    
    for (int i = 0; i < N; i++) {
      H[i] = Integer.parseInt(sc.next());
    }
    
    int max = 0;
    int count = 0;
    for (int i = 1; i < N; i++) {
      if (H[i-1] - H[i] >= 0) {
        count++;
      } else {
        if (count > max) {
          max = count;
        }
        count = 0;
      }
    }
    if (count > max) {
      max = count;
    }
    
    System.out.println(max);
  }
}

Measured memory_bytes: 50632
#include<bits/stdc++.h>
#define ll long long
using namespace std;
signed main(){
  ll a[1000],b[1000],c=0;
  for(ll i=0;i<5;i++){
    cin>>a[i];
    if(a[i] % 10 == 0){
      b[i] = 0;
    }else{
      b[i] = abs(a[i] % 10 - 10);
    }
  }
  sort(b,b+5);
  for(ll i=0;i<5;i++){
    c += a[i] + b[i];
  }
  cout<<c-b[4]<<"\n";
  return 0;
}

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

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

	int n;
	cin >> n;
	int d[n];
	for(int i = 0; i < n; i++){
		cin >> d[i];
	}
	sort(d,d+n);
	int kazu = n/2-1;
	int cou = 0;
	for(int i = d[kazu]; i < d[kazu+1]; i++){
		cou++;
	}
	cout << cou;
}


Measured memory_bytes: 640
#include<iostream>
#include<cmath>
#include<algorithm>
#include<string>
using namespace std;
int n;
int t[101][10001];//表示总价值
int w1,w[101],v[101];
const int inf=1<<21;//尽量小写
struct item
{
	int value;
	int weight;
};
int main()
{	item item1[101];
	int n;
	cin>>n;
	int w;
	cin>>w;
	for(int i=1;i<=n;i++)
		cin>>item1[i].value>>item1[i].weight;
	for(int i=0;i<=w;i++)
		t[0][i]=0;
	for(int i=0;i<=n;i++)
		t[i][0]=0;
	for(int i=1;i<=n;i++)
	{
		for(int j=1;j<=w;j++)
		{	t[i][j]=t[i-1][j];
		if(item1[i].weight>j)
			continue;
		if(t[i-1][j]<t[i-1][j-item1[i].weight]+item1[i].value)
			t[i][j]=t[i-1][j-item1[i].weight]+item1[i].value;//小细节，，，坑死
		}
	}

	cout<<t[n][w]<<endl;
	return 0;
}


Measured memory_bytes: 7056
loop do
	h, w = gets.split.map(&:to_i)

	break if (h == 0 && w == 0)

	h.times do |y|
		if y % 2 == 0 then
			i = 1
		else
			i = 2
		end

		w.times do
			if i % 2 == 0 then
				print '.'
			else
				print '#'
			end

			i += 1
		end

		print "\n" 
	end

	print "\n"
end

Measured memory_bytes: 6104