akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <algorithm>
#include <vector>
#include <stack>
#include <queue>
#include <map>
#include <cmath>
#include <string>
#include <cstring>
#include <sstream>
#include <iomanip>//小数精度 	cout << fixed << setprecision(5) << tmp << endl;
using namespace std;

#define ll long long
#define vvi vector< vector<int> >
#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 All(X)      (X).begin(),(X).end()
const ll int INF =1000000001;
int v,e,r;


struct edge {ll int from,to,cost; };

vector<edge> es(e);
vector<ll int> d(v);

bool SearchMinCost(int s){
	REP(i,v) d[i] = INF;
	d[s] = 0;
	int cnt = 0;
	while(true){
		cnt++;
		bool update = false;
		REP(i,e){
			edge e = es[i];
			if(d[e.from]!=INF && d[e.to] > d[e.from] + e.cost ){
				d[e.to] = d[e.from] + e.cost;
				update = true;
			}
		}
		if(!update) break;
		if(cnt == v) return true;
	}
	return false;
}
int main(){
	cin >> v >> e >> r;
	es.resize(e);
	REP(i,e) {
		cin >> es[i].from >> es[i].to >> es[i].cost;
	}
	d.resize(v);

	int flag = 1;

	if(SearchMinCost(r)==true) flag=0;
	if(flag==0){
		cout <<"NEGATIVE CYCLE"<<endl;
	}else{
		SearchMinCost(r);
		REP(i,v) {
			if(d[i]>=INF) cout << "INF" <<endl;
			else cout << d[i] <<endl;
		}
	}
	return 0;
}

Measured memory_bytes: 1256
#include <bits/stdc++.h>
using namespace std;
#define REP(i,a) for(int i = 0; i < (a); i++)
#define ALL(a) (a).begin(),(a).end()
typedef long long ll;
typedef pair<int, int> P;
const int INF = 1e9;
const int MOD = 1e9 + 7;

signed main(){
    int n;
    cin >> n;
    ll a[n];
    REP(i,n){
        cin >> a[i];
    }
    sort(a, a + n);
    int ans = 0;
    ll sum = 0;
    REP(i,n){
        if(sum * 2 < a[i]){
            ans = 0;
        }
        sum += a[i];
        ans++;
    }
    cout << ans << endl;
}

Measured memory_bytes: 1024
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <vector>
#include <utility>
#include <cstring>
#include <set>
#include <map>
#include <queue>
#include <stack>
#define rep(i, s, g) for (i = s; i < g; i++)
using namespace std;
using ll = long long;
using P = pair<int, int>;
const ll MOD = 1e9 + 7;
const ll INF = 1e18;

map<string, int> m;

int main(void)
{
    int n;
    string s;
    // map<string, int> m;
    int i;
    int maxv = 0;

    cin >> n;

    rep(i, 0, n)
    {
        cin >> s;

        m[s] += 1;
    }

    for (auto &x : m)
    {
        maxv = max(maxv, x.second);
    }

    for (auto &x : m)
    {
        if (maxv == x.second)
        {
            cout << x.first << endl;
        }
    }
}

Measured memory_bytes: 25216
using System;

class Program
{
    static void Main(string[] args)
    {
        var ab = Console.ReadLine().Split();
        var a = int.Parse(ab[0]);
        var b = int.Parse(ab[1]);

        if (a < 6) Console.WriteLine(0);
        else if (a < 13) Console.WriteLine(b / 2);
        else Console.WriteLine(b);
    }
}


Measured memory_bytes: 11092
#include <iostream>
    using ll = long long;
    using namespace std;
    int main(){
    	ll x;
    	scanf("%lld", &x);
    	ll ans = x/11*2;
    	x %= 11;
    	if (x >= 7) ans += 2;
    	else if (x != 0) ans++;
    	printf("%lld\n", ans);
    	return 0;
    }

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

using namespace std;


int main(){
    int n;
    string s;
    cin >> n;
    cin >> s;
    int slist[256];
    for(int i=0;i<256;i++){
        slist[i]=0;
    }
    int ans=0;
    for(int i=1;i<n;i++){
        int cnt=0;
        string x = s.substr(0,i);
        string y = s.substr(i,n-i);
        bool flag=false;
        for(int k=0;k<x.length();k++){
            slist[x[k]]=1;
        }
        for(int j=0;j<y.length();j++){
            if(slist[y[j]]==1){
                slist[y[j]]=2;
                cnt++;
            }
        }
        ans=max(ans,cnt);
    }
    cout << ans <<endl;
    return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int num = sc.nextInt();
        int count500 = 0;
        int count5 = 0;
        while (num >= 500) {
            num = num - 500;
            count500++;
        }
        while (num >= 5){
            num = num - 5;
            count5++;
        }
        System.out.println(count500 * 1000 + count5 * 5);
    }
}


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

int main(){
  int n,m;
  int count=0,answer=0;
  string str;
  
  cin >> n;
  vector<string> vec1(n);
  
  for(int i=0; i<n; i++){
    cin >> vec1.at(i);
  }
  
  cin >> m;
  vector<string> vec2(m);
  
  for(int i=0; i<m; i++){
    cin >> vec2.at(i);
  }
  
  for(int i=0; i<n; i++){
    count = 0;
    for(int j=0; j<n; j++){
      if(vec1.at(i)==vec1.at(j)){
        count++;
      }
    }
    
    for(int j=0; j<m; j++){
      if(vec1.at(i)==vec2.at(j)){
		count--;
      }
    }
    
    if(count > answer){
      answer = count;
    }
  }
  
  cout << answer << endl;
}

Measured memory_bytes: 256
#http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=0094
N = input().split()
a = N[0]
b = N[-1]
a = int(a)
b = int(b)
c = a * b
c = float(c)
d = c / 3.305785
print(d)

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

using namespace std;

#define FORE(i, a) for (auto i = a.begin(); i != a.end(); ++i)
#define REPU(i, a, b) for (int i = (a); i < (b); ++i)
#define REPD(i, a, b) for (int i = (a); i > (b); --i)
#define MEM(a, x) memset(a, x, sizeof(a))
#define ALL(a) a.begin(), a.end()
#define UNIQUE(a) a.erase(unique(ALL(a)), a.end())

vector<string> split(const string &s, char c) {
	vector<string> v; stringstream ss(s); string x;
	while (getline(ss, x, c)) v.push_back(x);
	return v;
}
#define DEBUG(args...) { vector<string> _v = split(#args, ','); err(_v.begin(), args); }
void err(vector<string>::iterator it) {}
template<typename T, typename... Args>
void err(vector<string>::iterator it, T a, Args... args) {
	cerr << "[DEBUG] " << it -> substr((*it)[0] == ' ', it -> length()) << " = " << a << '\n';
	err(++it, args...);
}

typedef long long ll;
const int MOD = 1000000007;

template<class T, class U> inline T tmin(T a, U b) { return (a < b) ? a : b; }
template<class T, class U> inline T tmax(T a, U b) { return (a > b) ? a : b; }
template<class T, class U> inline void amax(T &a, U b) { if (b > a) a = b; }
template<class T, class U> inline void amin(T &a, U b) { if (b < a) a = b; }
template<class T> T gcd(T a, T b) { while (b != 0) { T c = a; a = b; b = c % b; } return a; }

int main(int argc, char *argv[]) {
	ios_base::sync_with_stdio(false);

	int n; cin >> n;
	vector<int> a(n);
	REPU(i, 0, n) {
		cin >> a[i];
		a[i] -= i + 1;
	}

	sort(ALL(a));

	vector<ll> dp(n + 1, 0);
	REPU(i, 0, n) dp[i + 1] = dp[i] + a[i];

	ll ans = (ll) 1e18;
	REPU(i, 0, n) {
		int rb = upper_bound(ALL(a), a[i]) - a.begin();
		int lb = lower_bound(ALL(a), a[i]) - a.begin();
		ll res = 0;
		if (rb < n) res += dp[n] - dp[rb] - (n - rb) * 1LL * a[i];
		if (lb >= 0) res += a[i] * 1LL * lb - dp[lb];
		amin(ans, res);
	}
	cout << ans << endl;


	return 0;
}


Measured memory_bytes: 2560
import math

prime = [2,3,5,7,11]
for i in range(13,53,2):
    for j in [3,5,7]:
        if i%j == 0:
            break
    else:
        prime.append(i)

num75 = [2**74]
for i in [2,3,5]:
    tmp = i**24
    for j in prime:
        if i==j:
            continue
        num75.append(tmp*j*j)

for i in [2,3,5,7]:
    tmp = i**14
    for j in prime:
        if i==j:
            continue
        num75.append(tmp*(j**4))

for i in [2,3,5,7,11,13,17,19,23]:
    for j in [2,3,5,7,11,13,17,19,23]:
        if j<=i:
            continue
        for k in prime:
            if (i==k)or(j==k):
                continue
            num75.append((i**4)*(j**4)*(k**2))


N = int(input())
f = math.factorial(N)
ans = 0
for i in num75:
    if f%i == 0:
        ans += 1
print(ans)


Measured memory_bytes: 3064
// atcoder/abc132/B/main.cpp
// author: @___Johniel
// github: https://github.com/johniel/

#include <bits/stdc++.h>

#define each(i, c) for (auto& i : c)
#define unless(cond) if (!(cond))

using namespace std;

typedef long long int lli;
typedef unsigned long long ull;
typedef complex<double> point;

template<typename P, typename Q> ostream& operator << (ostream& os, pair<P, Q> p) { os << "(" << p.first << "," << p.second << ")"; return os; }
template<typename P, typename Q> istream& operator >> (istream& is, pair<P, Q>& p) { is >> p.first >> p.second; return is; }
template<typename T> ostream& operator << (ostream& os, vector<T> v) { os << "("; each (i, v) os << i << ","; os << ")"; return os; }
template<typename T> istream& operator >> (istream& is, vector<T>& v) { each (i, v) is >> i; return is; }

template<typename T> inline T setmax(T& a, T b) { return a = std::max(a, b); }
template<typename T> inline T setmin(T& a, T b) { return a = std::min(a, b); }

int main(int argc, char *argv[])
{
  ios_base::sync_with_stdio(0);
  cin.tie(0);

  int n;
  while (cin >> n) {
    vector<int> v(n);
    cin >> v;

    int cnt = 0;
    for (int i = 1; i + 1 < v.size(); ++i) {
      vector<int> u({v[i - 1], v[i], v[i + 1]});
      sort(u.begin(), u.end());
      cnt += (u[1] == v[i]);
    }
    cout << cnt << endl;
  }

  return 0;
}


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

#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define endl "\n"
#define PI 3.14159265358979
#define MOD 1000000007 // = 10^9 + 7

using namespace std;
using ll = long long;


void solve()
{
	string s;
	cin >> s;
	if (s == "Sunny") cout << "Cloudy";
	if (s == "Cloudy") cout << "Rainy";
	if (s == "Rainy") cout << "Sunny";
}

int main()
{
	//fastio;
	solve();

	return 0;
}

Measured memory_bytes: 3580
#include<cstdio>
#include<cstring>
#define clz 1000000007
#define ll long long
char s[5010];
int f[5010][5010];
int n;
long long ans;
int Max(int p,int q){
	return p>q?p:q;
}
ll qsm(ll x,int k){
	ll ans=1ll;
	while(k){
		if(k&1) ans=ans*x%clz;
		x=x*x%clz;
		k>>=1;
	}
	return ans;
}
int main(){
	//freopen("keyboard.in","r",stdin);
	//freopen("keyboard.out","w",stdout);
	scanf("%d%s",&n,s);
	f[0][0]=1;
	for(int i=0;i<=n;i++){
		for(int j=0;j<=i;j++){
			f[i+1][j+1]+=f[i][j]*2;
			f[i+1][j+1]%=clz;
			f[i+1][Max(j-1,0)]+=f[i][j];
			f[i+1][Max(j-1,0)]%=clz;
		}
	}
	int m=strlen(s);
		ans+=1ll*qsm(qsm(2,m),clz-2)*f[n][m]%clz;
		ans%=clz;
	printf("%lld",ans);
	return 0;
}

Measured memory_bytes: 96512
#include<stdio.h>
#include<string.h>
int main(void)
{
  char s[20];
  scanf("%s",s);
  int len=strlen(s);
  int count=0;
  for(int i=0;i<len;i++){
    if(s[i]=='x')count++;
  }

  if(count<=7){
    puts("YES");
  }else{
    puts("NO");
  }
  return 0;
}


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


int main(){
    int N;
    cin >> N;
    int tmp = N,cnt=0;
    while(tmp!=0){
        cnt += tmp%10;
        tmp /= 10;
    }
    if(N%cnt==0) cout << "Yes" << endl;
    else cout << "No" << endl;
}



Measured memory_bytes: 256
b=True
while b:
  n,m=map(int,input().split())
  if n==0 and m==0:
    b=False
    exit
  else:
    l=[]
    for i in range(n):
      l1=list(map(int,input().split()))
      l1=l1[::-1]
      l.append(l1)
    l=sorted(l)
    l=l[::-1]
    s=0
    for i in range(n):
      s+=l[i][0]*l[i][1]
    for i in range(n):
      if m-l[i][1]>=0:
          s-=l[i][0]*l[i][1]
          m-=l[i][1]
      else:
          s-=l[i][0]*m
          break
    print(s)


Measured memory_bytes: 6884
<?php
$D=[];
$D[0]=trim(fgets(STDIN));

for($i=1;$i<10;$i++){
  $d=trim(fgets(STDIN));
  if($D[0]<$d){$D[$i]=$D[0];$D[0]=$d;}
  else{$D[$i]=$d;}
}
for($j=1;$j<3;$j++){
  for($i=$j+1;$i<10;$i++){
    if($D[$j]<$D[$i]){$d=$D[$i];$D[$i]=$D[$j];$D[$j]=$d;}
  }
}

echo $D[0],PHP_EOL,$D[1],PHP_EOL,$D[2];
?>

Measured memory_bytes: 15340
#include <bits/stdc++.h>
 using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
 int main(){
   string s,t;
   int a,ans;
   ans=0;
   cin>>s;
   a=s.size();
   t=s;
   reverse(t.begin(),t.end());
   rep(i,a/2){
    if(s.at(i)!=t.at(i))ans++;
   }
   cout<<ans<<endl;

}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
template <class A, class B> inline bool chmax(A &a, const B &b) { return b > a && (a = b, true); }
template <class A, class B> inline bool chmin(A &a, const B &b) { return b < a && (a = b, true); }
typedef long long ll;
typedef vector<int> vint;
typedef pair<int, int> pint;
typedef vector<long long> vlong;
#define _GLIBCXX_DEBUG
#define vpush(a,x) a.push_back(x);
#define rep(i, n) REP(i, 0, n)
#define all(v) v.begin(), v.end()
#define REP(i, x, n) for(int i = x; i < n; i++)
const int INF = 1 << 30;
const int dx[] = {1,0,-1,0,1,1,-1,-1};
const int dy[] = {0,-1,0,1,1,-1,-1,1};
#define stp(x)  setprecision(x)
int main(){
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  int n;
  cin>>n;
  vector<int> x(n);
  rep(i,n){
    cin>>x[i];
  }
  int count,min=9999999;
  REP(i,1,101){
    count=0;
    rep(j,n){
      count+=pow(x[j]-i,2.0);
    }
    chmin(min,count);
  }

  cout<<min<<'\n';
  return(0);
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using i64 = long long;

std::vector<std::deque<int>> g, pre, suf;
std::vector<i64> q, r;
i64 mod;

i64 dfs(int v, int p) {
    i64 ret = 1;
    pre[v].push_back(1);
    suf[v].push_back(1);
    std::vector<i64> cs;
    for (int c : g[v]) {
        if (c == p) continue;
        i64 cf = dfs(c, v) + 1;
        ret = ret * cf % mod;
        cs.push_back(cf);
    }
    int len = cs.size();
    for (int i = 0; i < len; i++) {
        pre[v].push_back(pre[v].back() * cs[i] % mod);
        suf[v].push_front(suf[v].front() * cs[len - 1 - i] % mod);
    }
    return q[v] = ret;
}

void dfs2(int v, int p, i64 ot) {
    r[v] = ot * q[v] % mod;
    int j = 0;
    for (int i = 0; i < g[v].size(); i++) {
        int c = g[v][i];
        if (c == p) continue;
        dfs2(c, v, (ot * pre[v][j] % mod * suf[v][j + 1] % mod + 1) % mod);
        j++;
    }
}

int main() {
    int n;
    std::cin >> n >> mod;
    g.resize(n); pre.resize(n); suf.resize(n);
    q.resize(n); r.resize(n);
    for (int i = 1; i < n; i++) {
        int u, v;
        std::cin >> u >> v;
        u--; v--;
        g[u].push_back(v);
        g[v].push_back(u);
    }

    dfs(0, -1);
    dfs2(0, -1, 1);
    for (int i = 0; i < n; i++) std::cout << r[i] << '\n';
    std::cout << std::flush;

    return 0;
}


Measured memory_bytes: 264064
#include <iostream>
#include <iomanip>
#include <cstdio>
using namespace std;

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

}

Measured memory_bytes: 3088
#include <bits/stdc++.h>
 
#define loop(n, i) for(int i=0;i<n;i++)
#define all(v) v.begin(),v.end()
#define HERE cout << "HERE: " << __LINE__ << endl;
#define INSP(v) cout << v << " at " << __LINE__ << endl;

using namespace std;
typedef long long ll;

int main()
{
    int a, b, c; cin >> a >> b >> c;
    int t = 0;
    int vis[60] = {};
    while (1) {
        int mt = t % 60;
        if (mt <= c && mt + a >= c) {
            cout << t - mt + c << endl;
            break;
        }
        if (vis[mt]) {
            cout << -1 << endl;
            break;
        }
        vis[mt] = 1;
        t += a + b;
    }
    return 0;
}

Measured memory_bytes: 3116
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

var sc = bufio.NewScanner(os.Stdin)

func nextInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}

func solve(n int, as []int, bs []int) int {
	sum := 0
	for i := len(bs) - 1; i >= 0; i-- {
		if as[i+1] >= bs[i] {
			sum += bs[i]
			as[i+1], bs[i] = as[i+1] - bs[i], 0
		} else {
			sum += as[i+1]
			as[i+1], bs[i] = 0, bs[i] - as[i+1]
			if as[i] >= bs[i] {
				sum += bs[i]
				as[i] = as[i] - bs[i]
			} else {
				sum += as[i]
				as[i] = 0
			}
		}
	}
	return sum
}

func main() {
	sc.Split(bufio.ScanWords)
	n := nextInt()
	as := make([]int, n+1)
	for i := 0; i < n+1; i++ {
		as[i] = nextInt()
	}
	bs := make([]int, n)
	for i := 0; i < n; i++ {
		bs[i] = nextInt()
	}

	fmt.Println(solve(n, as, bs))
}

Measured memory_bytes: 5120
import java.util.Arrays;
import java.util.Scanner;
public class Main{

	public static void main(String[] args) {
		Scanner stdIn = new Scanner(System.in);
		int [] array = new int[3];
		array[0] = stdIn.nextInt();
		array[1] = stdIn.nextInt();
		array[2] = stdIn.nextInt(); 
		int cnt = 0;
		
		while(true) {
			
			Arrays.sort(array);
			
			if(array[0] == array[1] && array[1] == array[2]) {
				break;
			}
			
			if(array[0]<array[1]) {
				cnt++;
				array[0] += 2;
				continue;
			}
			if(array[0] == array[1]) {
				cnt++;
				array[0]++;
				array[1]++;
			}
		
		}
		System.out.println(cnt);
		
	}

}


Measured memory_bytes: 21972
f=lambda:map(int,input().split())
n,st,sa=f()
st-=1
sa-=1
g=[[] for _ in range(n)]
for _ in range(n-1):
  a,b=f()
  g[a-1].append(b-1)
  g[b-1].append(a-1)
def bfs(s):
  l=[-1]*n; l[s]=0; q=[s]
  while q:
    v=q.pop(); d=l[v]+1
    for c in g[v]:
      if l[c]<0: l[c]=d; q+=[c]
  return l
lt=bfs(st)
la=bfs(sa)
m=0
for i in range(n):
  if lt[i]<la[i]: m=max(m,la[i])
print(m-1)

Measured memory_bytes: 28464
import sys
f = sys.stdin

teams = {}
scores = set()
while True:
    team, score = map(int, f.readline().split(','))
    if team == score == 0:
        break
    teams[team] = score
    scores.update([score])
scores = sorted(list(scores))[::-1]
for line in f:
    print(scores.index(teams[int(line)]) + 1)

Measured memory_bytes: 6724
n,y=gets.chomp.split(' ').map(&:to_i)
a,b,c=-1,-1,-1;
(0..n).each do |i|
  (0..(n-i)).each do |j|
    k=n-i-j
    if 10000*i+5000*j+1000*k==y then
      a=i
      b=j
      c=k
    end
  end
end
puts "#{a} #{b} #{c}"

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

int main()
{
	ios::sync_with_stdio(false);
	cin.tie(0); cout.tie(0);
	int n, a, b; cin >> n >> a >> b;
	int c1 = 0, c2 = 0, c3 = 0;
	for (int i = 0; i < n; i++) {
		int p; cin >> p;
		if (p <= a) c1++;
		else if (p <= b) c2++;
		else c3++;
	}
	cout << min(c1, min(c2, c3)) << '\n';
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main(){
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	int x, y;
	cin >> x >> y;
	if(y%2 != 0|| y < 2*x || y > 4*x) cout << "No\n";
	else cout << "Yes\n";
}

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

int a,b;

int main(){
	cin>>a>>b;
	//a*=10;
	//b*=10;
	for(int i = 0; i <= 1250; i++){
		int Out = i;
		if(Out / 10 == b && Out * 2 / 25 == a){
			cout<<Out<<endl;
			return 0;
		}
	}
	cout<<-1<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <iostream>
using namespace std;
typedef long long ll;
const int maxn=405;
const ll mod=1000000007;

ll dp[maxn][maxn],pre[maxn][maxn];
int a[maxn],b[maxn];
int n,c,mx;

template<typename T>
inline void read(T &x)
{
    char c;int f=1;
    while(!isdigit(c=getchar())) if(c=='-') f=-1;
    x=c^48;
    while(isdigit(c=getchar())) x=(x<<1)+(x<<3)+(c^48);
    x*=f;
}

int main(void)
{
    read(n),read(c);
    for(int i=1;i<=n;i++) read(a[i]);
    for(int i=1;i<=n;i++) read(b[i]),mx=max(mx,b[i]);
    mx++;
    for(int i=1;i<=mx;i++) pre[i][0]=1;
    for(int i=1;i<=mx;i++)
        for(int j=1;j<=c;j++)
            pre[i][j]=pre[i][j-1]*i%mod;
    for(int i=1;i<=mx;i++)
        for(int j=0;j<=c;j++)
            pre[i][j]=(pre[i][j]+pre[i-1][j])%mod;
    dp[0][0]=1;
    for(int i=1;i<=n;i++)
        for(int j=0;j<=c;j++)
            for(int k=0;k<=j;k++)
                dp[i][j]=(dp[i][j]+dp[i-1][j-k]*((pre[b[i]][k]-pre[a[i]-1][k]+mod)%mod))%mod;
    printf("%lld\n",dp[n][c]);
    return 0;
}

Measured memory_bytes: 2816
import java.util.*;
 
public class Main {
  public static void main(String[] args)  {
    Scanner sc = new Scanner(System.in);
    int H = sc.nextInt();
    int W = sc.nextInt();
    
    for (int i = 0; i < W + 2; i++) {
      System.out.print("#");
    }
    System.out.println();
 
    for (int i = 0; i < H; i++) {
      String s = sc.next();
      System.out.print("#");
      System.out.print(s);
      System.out.print("#");
      System.out.println();
    }
    
    for (int i = 0; i <  W + 2; i++) {
      System.out.print("#");
    }
  }
}
 

Measured memory_bytes: 37256
#include <bits/stdc++.h>
#define fi first
#define se second
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define rng(a) a.begin(),a.end()
#define rrng(a) a.rbegin(),a.rend()
#define maxs(x,y) (x = max(x,y))
#define mins(x,y) (x = min(x,y))
#define limit(x,l,r) max(l,min(x,r))
#define lims(x,l,r) (x = max(l,min(x,r)))
#define isin(x,l,r) ((l) <= (x) && (x) < (r))
#define pb push_back
#define eb emplace_back
#define sz(x) (int)(x).size()
#define pcnt __builtin_popcountll
#define uni(x) x.erase(unique(rng(x)),x.end())
#define snuke srand((unsigned)clock()+(unsigned)time(NULL));
#define show(x) cout<<#x<<" = "<<x<<endl;
#define PQ(T) priority_queue<T,v(T),greater<T> >
#define bn(x) ((1<<x)-1)
#define dup(x,y) (((x)+(y)-1)/(y))
#define newline puts("")
#define v(T) vector<T>
#define vv(T) v(v(T))
using namespace std;
typedef long long int ll;
typedef unsigned uint;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef tuple<int,int,int> T;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
typedef vector<T> vt;
//inline int in() { int x; scanf("%d",&x); return x;}
inline ll in() { ll x; cin >> x; return x; }
template<typename T>inline istream& operator>>(istream&i,v(T)&v)
{rep(j,sz(v))i>>v[j];return i;}
template<typename T>string join(const v(T)&v)
{stringstream s;rep(i,sz(v))s<<' '<<v[i];return s.str().substr(1);}
template<typename T>inline ostream& operator<<(ostream&o,const v(T)&v)
{if(sz(v))o<<join(v);return o;}
template<typename T1,typename T2>inline istream& operator>>(istream&i,pair<T1,T2>&v)
{return i>>v.fi>>v.se;}
template<typename T1,typename T2>inline ostream& operator<<(ostream&o,const pair<T1,T2>&v)
{return o<<v.fi<<","<<v.se;}
template<typename T>inline ll suma(const v(T)& a) { ll res(0); for (auto&& x : a) res += x; return res;}
const double eps = 1e-10;
const ll LINF = 1001002003004005006ll;
const int INF = 1001001001;
#define dame { puts("-1"); return 0;}
#define yn {puts("YES");}else{puts("NO");}
const int MX = 200005;

vector<int> to[2505];
vector<int> rto[2505];
bool reachablefrom1[2505];
bool reachableToN[2505];
bool ok[2505];

void dfs(int v) {
  if (reachablefrom1[v]) return;
  reachablefrom1[v] = true;
  for (int u : to[v]) {
    dfs(u);
  }
}
void rdfs(int v) {
  if (reachableToN[v]) return;
  reachableToN[v] = true;
  for (int u : rto[v]) {
    rdfs(u);
  }
}

int main() {
  int n = in();
  vector<pair<int, int>> a(n);
  rep(i,n) {
    int temp; cin >> temp;
    a[i] = make_pair(temp,i+1);
  }
  sort(a.begin(), a.end());
  rep(i,n) {
    cout << a[i].second;
    if (i == n-1) cout << endl;
    else cout << " ";
  }
  return 0;
}


Measured memory_bytes: 1664
h,w = map(int,input().split())

if h%3 == 0 or w%3 == 0:
    print(0)
else:
    temp1 = 100000000000000000
    temp2 = 100000000000000000
    for i in range(w):
        bs = [h*i,(w-i)*(h//2),(w-i)*(h//2+h%2)]
        d = max(bs)-min(bs)
        if temp1 > d :
            temp1 = d
    for i in range(h):
        bs = [w * i, (h - i) * (w // 2), (h - i) * (w // 2 + w % 2)]
        d = max(bs)-min(bs)
        if temp2 > d:
            temp2 = d
    # print(temp1,temp2)
    print(min(temp1,temp2,min(w,h)))

Measured memory_bytes: 3064
#include<bits/stdc++.h>
#define lli long long int
#define MOD 1000000007
#define FOR(i,n) for(int i=0;i<(int)N;i++)
#define ALL(x) (x).begin(),(x).end()
using namespace std;

inline int getint(){
    int n;
    scanf("%d",&n);
    return n;
}

inline vector<int> getints(int n){
    vector<int> a(n);
    for(int i=0;i<n;i++)scanf("%d",&a[i]);
    return a;
}

void dumpints(vector<int> a){
  cout<<"[";
  for(int i=0;i<a.size()-1;i++){
    cout<<a[i]<<",";
  }
  cout<<a[a.size()-1]<<"]"<<endl;
}

template<class T> bool ifinclude(vector<T> a,T x){
    auto itr=find(a.begin(),a.end(),x);
    return distance(a.begin(),itr)!=a.size();
}

int main(void){
  int N=getint();
  int P=getint();
  vector<int> A=getints(N);
  bool flag=false;
  FOR(i,N){
    if(A[i]%2==1)flag=true;
  }
  lli ans=(flag?pow(2,N-1):(P==0?pow(2,N):0));
  cout<<ans<<endl;
  return 0;
}


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

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

long long MOD = 10000000000 + 7;

int main(){
  cout << setprecision(10);
  ll now = 1000;
  int N; cin >> N;

  vector<ll> v;
  v.push_back(210);

  ll prev;
  for(int i = 0; i < N; i++){
    ll tmp; cin >> tmp;
    if(i == 0){
      v.push_back(tmp);
      prev = tmp;
    } else {
      if(tmp == prev){
        continue;
      } else {
        v.push_back(tmp);
        prev = tmp;
      }
    }
  }

  v.push_back(99);
  N = v.size();
  bool flg = false; 
  for(int i = 1; i < N; i++){
    if(v[i-1] < v[i]){
      flg = true;
      break;
    }
  }
  if(!flg){
    cout << now << endl;
    return 0;
  }

  flg = true; // 買いたい

  ll stock = 0;
  for(int i = 1; i < N; i++){
    if(flg && (v[i-1] >= v[i])){

    } else if(flg && (v[i-1] < v[i])){
      // v[i-1]で買う
      ll num = now / v[i-1];
      stock += num;
      now -= v[i-1] * num;
      flg = false;
    } else if(!flg && (v[i-1] <= v[i])){

    } else if(!flg && (v[i-1] > v[i])){
      // 全部売る
      now += stock * v[i-1];
      stock = 0;
      flg = true;
    }
    // cerr << "now: " << now << " stock: " << stock << endl;
  }
  cout << now << endl;

}


Measured memory_bytes: 3584
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
enum { M = 1000000007, N = 1100 };
vector<bool> p(N + 5, true);

void init() {
	p[0] = false;
	p[1] = false;
	for (ll i = 2; i <= N; i++) {
		if (p[i]) {
			for (ll k = 2; k*i <= N; k++) {
				p[k*i] = false;
			}
		}
	}
}

int main() {
	ios::sync_with_stdio(false); cin.tie(0);
	init();
	ll n, ans = 1; cin >> n;
	for (ll i = 1; i <= n; i++) {
		if (p[i]) {
			ll temp = 0, check = i;
			while (n/check > 0) {
				temp += n/check;
				check = check * i;
			}
			ans = (ans * (temp + 1)) % M;
		}
	}
	cout << ans << "\n";
	return 0;
}

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

int main()
{
	ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    int n,count=0;
    double m,sum=0;
    cin>>n>>m;
    int a[n];
    for(int i=0;i<n;i++){
    	cin>>a[i];
    	sum+=a[i];
	}
	
	for(int i=0;i<n;i++){
		if((sum/(4.0*m))<=a[i])
		count++;
	}

if(count>=m)
cout<<"Yes";
else 
cout<<"No";
    return 0;
}


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

#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORTASC(c) sort((c).begin(),(c).end())
#define SORTDESC(c,t) sort((c).begin(),(c).end(), std::greater<t>());
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define VMAX(a) *max_element(ALL(a))
#define VMIN(a) *min_element(ALL(a))
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

const double PI  = acos(-1.0);

using ll = long long;
using namespace std;

int main() {
    ll k, x;

    cin >> k >> x;

    if(500*k >= x){
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }

    return 0;
}

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

int main() {
  int A,B;
  cin >> A >> B;
  
  if(A==B)
    cout << "Draw" << endl;
  else if(A == 1 && B != 1)
    cout << "Alice" << endl;
  else if(A != 1 && B == 1)
    cout << "Bob" << endl;
  else if(A<B)
    cout << "Bob" << endl;
  else 
    cout << "Alice" << endl;    
  }

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

using namespace std;

int main()
{
	while(true) {
		int a, d, n;
		cin >> a >> d >> n;

		if(a == 0 && d == 0 && n == 0) break;

		vector<int> primes;
		vector<bool> is_prime(1000000, true);

		is_prime[0] = false;
		is_prime[1] = false;

		for(int i = 2; i < is_prime.size(); ++i) {
			if(!is_prime[i]) continue;

			for(int j = i * 2; j < is_prime.size(); j+=i) {
				is_prime[j] = false;
			}
		}

		int cnt = 0;
		for(int i = a; i < is_prime.size(); i+=d) {
			if(!is_prime[i]) continue;

			++cnt;
			if(cnt == n) {
				cout << i << endl;
				break;
			}
		}
	}

	return 0;
}

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

int main() {
  char name[12], nextname[12];
  scanf("%s",name);
  scanf("%s",nextname);

  int flag = 0;
  for(int i = 0; i < 11; i++){
    if(name[i] != '\0'){
      if(name[i] != nextname[i]){
        goto skip;
      }
    }
    else{
      flag++;
      goto skip;
    }
  }
  skip:

  if(flag != 0){
    cout << "Yes" << endl;
  }
  else{
    cout << "No" << endl;
  }
}

Measured memory_bytes: 3688
X = []
X.append(("+", 0, 1, 3))
X.append(("<", 4, 3, 100)) # 1
X.append(("+", 0, 100, 0))
X.append(("+", 1, 100, 1))
for i in range(32):
    X.append(("+", i+100, i+100, i+101))

for t in range(2):
    tt = t * 5000
    for i in range(32):
        s = 31 - i
        X.append(("+", tt + (i+2) * 100 - 1, s + 100, tt + (i+2) * 100))
        X.append(("+", tt + (i+2) * 100 - 1, s + 100, tt + (i+2) * 100 + 1))
        X.append(("<", tt + (i+2) * 100 + 1, t, tt + (i+2) * 100 + s + 2))
        for j in range(s)[::-1]:
            X.append(("+", tt + (i+2) * 100 + j + 3, tt + (i+2) * 100 + j + 3, tt + (i+2) * 100 + j + 2))
        X.append(("+", tt + (i+2) * 100 - 1, tt + (i+2) * 100 + 2, tt + (i+2) * 100 + 99))
        X.append(("+", tt + (i+2) * 100 + s + 2, 90, tt + (i+2) * 100 + 98))
        X.append(("+", tt + (i+2) * 100 + s + 2, 90, 10000 + t * 100 + s))

for i in range(32):
    for j in range(32):
        X.append(("+", 10000 + i, 10100 + j, 95))
        X.append(("<", 100, 95, 95))
        for k in range(i+j):
            X.append(("+", 95, 95, 95))
        X.append(("+", 2, 95, 2))

print(len(X))
for x in X:
    print(*x)

Measured memory_bytes: 9528
#include<bits/stdc++.h>
using namespace std;
int main(){
    int a,b,c,k;
    cin >> a >> b >> c >> k;
    int ans = 0;
    ans = min(a,k);
    k -= a;
    if(k>0){
        k-=b;
    }
    
    if(k>0){
        ans -= k;
    }
    cout << ans << endl;
}


Measured memory_bytes: 3648
#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#include <utility>
#include <cmath>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#define rep(i, n) for(int i = 0; i < n; i++)
using namespace std;
typedef long long ll;
const ll mod = 1000000007;

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

    int h[n];
    rep(i, n) {
        cin >> h[i];
    }

    vector<int> dp(n+1);

    dp[2] = abs(h[0] - h[1]);
    for(int i = 2; i < n; i++) {
        dp[i+1] = min(dp[i] + abs(h[i-1] - h[i]), dp[i-1] + abs(h[i-2] - h[i]));
    }

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

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

int main(){
	int n;
	cin >> n;
	vector<ll> a(n);
	rep(i,n) cin >> a[i];
	ll s(0);
	rep(i,n-1){
		if(i%2==0) s -= a[i];
		else s += a[i];
	}
	ll x = a[n-1]-s;
	cout << x << endl;
	for(int i(0);i<n-1;++i){
		x = a[i]*2 - x;
		cout << x << endl;
	}
	return 0;
}

Measured memory_bytes: 2048
require 'set'
n = gets.to_i
g = {}
g_inv = {}
gets.split.map(&:to_i).each_with_index do |k , i|
    j = (i + k) % n
    g[i] = j
    (g_inv[j] ||= Set.new) << i
end
queue = (0..n-1).select {|i| !g_inv[i]}
until queue.empty?
    n -= 1
    i = queue.shift
    j = g[i]
    g_inv[j].delete(i)
    if g_inv[j].empty?
        queue << j
    end
end
p n


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

int main() {
  int H, W;
  cin >> H >> W;
  vector<string> p(H);
  for(int i = 0; i < H; i++)
    cin >> p.at(i);
  for(int i = 0; i < W+2; i++)
    cout << '#';
  cout << endl;
  for(int i = 0; i < H; i++)
    cout << '#' << p.at(i) << '#' << endl;
  for(int i = 0; i < W+2; i++)
    cout << '#';
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll INF = 1e18;
const ll mod = 1e9+7;
#define rep(i,n) for(int i = 0;i<n;i++)

int main(){
	int h,w,k;
	cin >> h >> w >> k;

	vector<vector<char>> c(h,vector<char>(w));
	vector<vector<char>> c_sub(h,vector<char>(w));
	rep(i,h){
		rep(j,w){
			cin >> c[i][j];
		}
	}

	int ans = 0;
	for(int i = 0; i< (1<<h); i++){
		for(int j = 0; j< (1 << w); j++){
			rep(x,h){
				rep(y,w){
					c_sub[x][y] = c[x][y];
				}
			}			
			int count = 0;


			rep(x,h){
				if( i &(1<<x)){
					rep(y,w) c_sub[x][y] = 'x';
				}
			}
			rep(y,w){
				if(j & (1 << y)){
					rep(x,h) c_sub[x][y] = 'x';
				}
			}

			rep(x,h){
				rep(y,w){
					if(c_sub[x][y] == '#')count++;
				}
			}
			//printf("i:%d,j:%d,count%d\n",i,j,count);
			if(count == k) ans++;
		}
	}
	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 3604
#include <iostream>
#include <string>
#include<algorithm>
#include <cstdlib>
#include <cmath>

using namespace std;
int main()
{
	char c;
	int x, y;
	cin >> x >> c >> y;
	if (c == '+') cout << x + y << endl;
	else cout << x - y << endl;
	return 0;
}

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

using namespace std;
using int64 = long long;

constexpr int DEBUG = 0;

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

  int n;
  cin >> n;
  vector<int> xs(n);
  int sum = 0;
  for (int i = 0; i < n; i++) {
    cin >> xs[i];
    sum += xs[i];
  }
  int a = static_cast<int>(round(static_cast<double>(sum) / n));
  int c = 0;
  for (int i = 0; i < n; i++) {
    c += (xs[i] - a) * (xs[i] - a);
  }
  cout << c << endl;
}

Measured memory_bytes: 256
n,W = map(int, input().split())
wv = [list(map(int, input().split())) for i in range(n)]
dp = [[10 ** 18] * (10 ** 5 + 1) for i in range(n+1)]
dp[0][0] = 0
for i,(w,v) in enumerate(wv):
  for j in range(1000 * i + 1):
    dp[i+1][j+v] = min(dp[i+1][j+v],dp[i][j]+w)
    dp[i+1][j] = min(dp[i+1][j],dp[i][j])
ans = 0
for k,w in enumerate(dp[n]):
  if w <= W:
    ans = k
print(ans)

Measured memory_bytes: 120684
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <string>
#include <vector>
#include <queue>
#include <map>
#include <set>
#include <functional>
#include <cmath>
#include <complex>
#include <cctype>
#include <cassert>
#include <sstream>
#include <ctime>
#include <cstdlib>
#include <cstring>
#include <deque>

using namespace std;

#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) (v).begin(),(v).end()
#define fi first
#define se second

template<typename A, typename B> inline bool chmax(A &a, B b) { if (a<b) { a=b; return 1; } return 0; }
template<typename A, typename B> inline bool chmin(A &a, B b) { if (a>b) { a=b; return 1; } return 0; }

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<int, pii> pip;

const ll INF = 1ll<<29;
const ll MOD = 1000000007;
const double EPS = 1e-10;

int n, m;
int p[1000];

int main() {
	while (cin >> n >> m, n || m) {
		REP(i, n) scanf("%d", p + i);
		sort(p, p + n, greater<int>());
		
		int ans = 0;
		REP(i, n) ans += p[i];
		
		for (int i = m - 1; i < n; i += m)
			ans -= p[i];
		
		cout << ans << endl;
	}
	return 0;
}

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

int main(){
  int n,k,ans=0;
  cin>>n>>k;
  
  rep(i,0,n){
    int tmp;
    cin>>tmp;
    ans+=min(tmp*2,(k-tmp)*2);
  }
  
  cout<<ans<<endl;

  return 0;
}


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

#define froop1(a,n) for(int i = a;i < n;i++)
#define froop2(a,n) for(int i = a;i > n;i--)

#define ll long long

#define pq(name,type) priority_queue<type> name
#define vec(name,type,length,value) vector<type> name(length,value)
#define vec2(name,type,length,width,value) vector<vector<type>> name(length,vector<type>(width,value));

int main(){
	int N,M;
  cin >> N >> M;
  if(N == M){
cout << "Yes" << endl;
  }else{
cout << "No" << endl;
  }

return 0;
}

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

int main() {
    long long n, a, b;
    cin >> n >> a >> b;
    long long ans = 0;
    if (n == 1) {
        if (a == b) ans = 1;
        else ans = 0;
    }
    else if (a > b) ans = 0;
    else {
        ans = (a + b*(n-1)) - (a*(n-1) + b) + 1;
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <climits>

using namespace std;


template<typename T>
void show(T a){
  for(auto i : a){
    cout << i << " ";
  }
  cout << endl;
}
//learnt from http://judge.u-aizu.ac.jp/onlinejudge/review.jsp?rid=1058947#1

int main(int argc, char *argv[]){
  int n, tmp;
  vector<int> list;
  cin >> n;
  for(int i = 0; i < n; i++) {
    cin >> tmp;
    list.push_back(tmp);
  }
  vector<int> dp (n+1, INT_MAX);

  //O(nlogn)
  for(int i = 0; i < n; i++){
    auto j = lower_bound(dp.begin(), dp.end(), list[i]);
    *j = list[i];
  }

  auto j = lower_bound(dp.begin(), dp.end(), INT_MAX);
  cout << j - dp.begin() << endl;

/*
  //O(n^2)
  for(int i = 0; i < n; i++){
    for(int j = i; j >= 0; j--){
      if(list[i] > list[j]){
        dp[i]= max(dp[i], dp[j]+1);
      }
    }
  }
  cout << *(max_element(dp.begin(), dp.end())) << endl;
*/
  return 0;
}


Measured memory_bytes: 3844
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

func nextStr() string {
	sc.Scan()
	return sc.Text()
}

func nextInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}

const M = 1046527

var sc = bufio.NewScanner(os.Stdin)

func main() {
	sc.Split(bufio.ScanWords)
	n, k := nextInt(), nextInt()
	T := make([]int, n)
	for i := 0; i < n; i++ {
		T[i] = nextInt()
	}

	left := 0
	right := 100000 * 100000
	for right-left > 1 {
		mid := (left + right) / 2
		v := check(T, mid, k)
		if v < n {
			left = mid
		} else {
			right = mid
		}
	}
	fmt.Println(right)

}

func check(T []int, P int, k int) int {
	n := len(T)
	i := 0
	for j := 0; j < k; j++ {
		s := 0
		for s+T[i] <= P {
			s += T[i]
			i++
			if i == n {
				return n
			}
		}
	}
	return i
}



Measured memory_bytes: 2344
import math
A, B, H, M = map(int, input().split())

L = (60 * H + M) / 2
S = M * 6
dig = L - S

#print(dig, L, S)
print(math.sqrt(A**2 + B**2 - 2 * A * B * math.cos(math.radians(dig))))


Measured memory_bytes: 9432
N, M = map(int, input().split())
A = list(map(int, input().split()))

s = sum(A)
t = s / 4 / M
A = sorted(A, reverse=True)

flag = True
for i in range(M):
    if A[i] < t:
        flag = False
        break

print('Yes' if flag else 'No')


Measured memory_bytes: 3060
#include <cassert>
#include <cctype>
#include <cerrno>
#include <cfloat>
#include <climits>
#include <clocale>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <iostream>
#include <fstream>
#include <sstream>
#include <iomanip>
#include <algorithm>
#include <string>
#include <vector>
#include <list>
#include <deque>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <bitset>
#include <valarray>
#include <utility>
#include <numeric>
#include <memory>
#include <functional>
#include <stdexcept>
#include <typeinfo>
#include <limits>
#include <complex>
#include <locale>
#if __cplusplus >= 201103L
#include <ccomplex>
#include <cfenv>
#include <cinttypes>
#include <cstdalign>
#include <cstdbool>
#include <cstdint>
#include <ctgmath>
#include <cwchar>
#include <cwctype>
#include <array>
#include <atomic>
#include <chrono>
#include <condition_variable>
#include <forward_list>
#include <future>
#include <initializer_list>
#include <mutex>
#include <random>
#include <ratio>
#include <regex>
#include <scoped_allocator>
#include <system_error>
#include <thread>
#include <tuple>
#include <typeindex>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>
#endif
using namespace std;
#define Debug(x) cerr << #x << " = " << x << endl
#define Debug22(x,y) cerr<<#x<<" = "<<x<<" , "<<#y<<" = "<<y<<endl;
#define Debug2(x, y) cerr << "(" << #x << ", " << #y << ") = (" << x << ", " << y << ")\n";
#define Debug3(x,y,z) cerr<<"("<<#x<<", "<<#y<<", "<<#z<<") = ("<<x<<", "<<y<<", "<<z<<")\n";
#define Debug_arr(v,n) for(int i=0;i<n;++i) cerr<<#v<<"["<<i<<"]"<<" = "<<v[i]<<endl;
#define SET(p,v) fill((__typeof(**p)*)p,(__typeof(**p)*)p+sizeof(p),v);
#define eprintf(...) fprintf(stderr, __VA_ARGS__),fflush(stderr)
#define prl cerr << "called: " << __LINE__ << endl
#define all(s) s.begin(),s.end()
//#define FILE_JUDGE
//#define TIMES
//#define LINES
//#define home
//#define multitests
//#define not_only_test
int n;
int p[100005];
int main()
{
	scanf("%d",&n);
	for (int i=1;i<=n;++i)
	{
		int x;
		scanf("%d",&x);
		p[i]=x;
	}
	int ans=0;
	for (int i=1;i<=n;++i)
	{
		if (p[i]==i)
		{
			if (i==1 || p[i+1]==i+1)
			{
				swap(p[i],p[i+1]);
			}
			else
			{
				swap(p[i-1],p[i]);
			}
			ans++;
		}
	}
	printf("%d\n",ans);
	return 0;
}


Measured memory_bytes: 640
#include <iostream>                                             
#include <cstdio>                                               
#include <cmath>                                                
#define _USE_MATH_DEFINES                                       
using namespace std;                                            
                                                                
int main(void){                                                 
  int a, b, C;                                                  
  double S, L, h;                                               
  cin >> a >> b >> C;                                           
  S = a*b*sin(C*M_PI/180)/2;                                    
  L = sqrt(a*a+b*b-2*a*b*cos(C*M_PI/180))+a+b;                  
  h = b*sin(C*M_PI/180);                                        
  printf("%.8f\n%.8f\n%.8f\n", S, L, h);                        
  return 0;                                                     
}                                                               
                                           

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

int main() {
	string s;
	cin >> s;
	int a[3];
	a[0] = count(s.begin(), s.end(), 'a');
	a[1] = count(s.begin(), s.end(), 'b');
	a[2] = count(s.begin(), s.end(), 'c');
	auto ok = [](int a, int b, int c) -> bool {
		while (a || b || c) {
			if (a-- == 0) return false;
			if (a == 0 && b == 0 && c == 0) return true;
			if (b-- == 0) return false;
			if (a == 0 && b == 0 && c == 0) return true;
			if (c-- == 0) return false;
		}
		return true;
	};
	sort(a, a + 3);
	cout << (ok(a[2], a[1], a[0]) ? "YES\n" : "NO\n");
	return 0;
}

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

using namespace std;

typedef long long ll;

/// The definitions in this library are as below.
#define rI readInt
#define rL readLong
#define rC readChar
#define rC2 readChar2
#define rS readString

#define pb push_back

#define acc accumulate
namespace __library_79brue{
    /// This is a C++ library which improves the programming speed by \
        defining frequently used data structures or algorithms.       \
        This library can be freely used without any copyrights,       \
        but I recommend not to change the name of this library.       \
        Made by 79brue                                                \
        2019

    /// The functions or structures in this library are as below.
    /// quit()
    /// readInt() readLong() readChar() readChar2() readString()

    /// terminates the program
    inline void quit(){
        exit(0);
    }

    /// reads an integer
    inline void readInt(int& _x){
        scanf("%d", &_x);
    }

    /// reads a long-long integer
    inline void readLong(ll& _x){
        scanf("%lld", &_x);
    }

    /// reads a character
    inline void readChar(char& _x){
        scanf(" %c", &_x);
    }

    /// reads a character, the character may be space or line-break, etc...
    inline void readChar2(char &_x){
        scanf("%c", &_x);
    }

    inline void readString(char* _x){
        scanf("%s", _x);
    }
}
using namespace __library_79brue;

int n;
string s;
string s2;
int k;

ll ans;
int tmp;
char minC, maxC;
bool chk[102];

int main(){
    cin>>s>>k;
    n=(int)s.size();
    minC = *min_element(s.begin(), s.end());
    maxC = *max_element(s.begin(), s.end());
    if(minC == maxC){
        printf("%lld", (ll)n*k/2);
        return 0;
    }

    for(int i=0; i<n-1; i++){
        if(s[i] == s[i+1]) ans++, chk[++i]=1;
    }
    ans*=k;

    for(int i=0; i<n-1; i++){
        if(s[i] != s[0]){
            tmp = i-1;
            break;
        }
    }

    if(s.front() == s.back()){
        if(!chk[n-1] && tmp%2==0) ans+=k-1;
    }

    printf("%lld", ans);
}


Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<math.h>
using namespace std;
#define rep(i,n) for (int i = 0;i < (int)(n);i++)
int main() {
	int n, r;
	cin >> n >> r;
	if (n >= 10) {
		cout << r << endl;
	}
	else {
		cout << r + 100 * (10 - n) << endl;
	}
	return 0;
}

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

int main() {
  int a;
  string s;
  cin >> a; 
  cin >> s;
  
  if (a > 3199 || a == 3200){
    cout << s << endl;
  }
  else {
    cout << "red" << endl;
  }
}

Measured memory_bytes: 256
#include <stdio.h>
int main()
{
    char ch;
    int x,c[26]= {0};
 
    while(scanf("%c",&ch)!=EOF)
    {
        if(ch>='A' && ch<='Z')
        {
            x=ch-'A';
            c[x]+=1;
        }
        else if(ch>='a' && ch<='z')
        {
            x=ch-'a';
            c[x]+=1;
        }
    }
 
    for(x=0,ch='a'; x<26; x++,ch++)
    {
        printf("%c : %d\n",ch,c[x]);
    }
    return 0;
}


Measured memory_bytes: 2048
#include <algorithm>
#include <cstdint>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>
#include <cfloat>

using namespace std;

using lint=int64_t;
using uint=uint32_t;
using ulint=uint64_t;

template<class T>
using vector2d=vector<vector<T>>;

template<class T>
bool UpdateMax(T &a, const T &b){
  if(a<b){
    a=b;
    return true;
  }else{
    return false;
  }
}

template<class T>
bool UpdateMin(T &a, const T &b){
  if(a>b){
    a=b;
    return true;
  }else{
    return false;
  }
}

template <class T>
void OutVec(const vector<T>& vec){
  for(int i = 0; i < vec.size() - 1; ++i){
    cout<<vec[i]<<" ";
  }
  cout<<vec.back()<<endl;
}

template <class T>
void OutVec2d(const vector2d<T>& vec){
  for(auto v:vec){
    OutVec(v);
  }
}

int main(){
  cout << std::fixed << std::setprecision(16);
  cin.tie(nullptr);
  std::ios::sync_with_stdio(false);

  int h,a;
  cin>>h>>a;
  cout<<(int)ceil((double)h/a)<<endl;

  return 0;
}




Measured memory_bytes: 256