akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>

using namespace std;

#define fRead(x)  freopen(x,"r",stdin)
#define fWrite(x) freopen (x,"w",stdout)

#define LL long long
#define ULL unsigned long long
#define ff first
#define ss second
#define pb push_back
#define INF 2e16
#define PI acos(-1.0)
#define mk make_pair

#define min3(a,b,c) min(a,min(b,c))
#define max3(a,b,c) max(a,max(b,c))
#define min4(a,b,c,d) min(a,min(b,min(c,d)))
#define max4(a,b,c,d) max(a,max(b,max(c,d)))
#define SQR(a) ((a)*(a))
#define FOR(i,a,b) for(int i=a;i<=b;i++)
#define ROF(i,a,b) for(int i=a;i>=b;i--)
#define REP(i,b) for(int i=0;i<b;i++)
#define MEM(a,x) memset(a,x,sizeof(a))
#define ABS(x) ((x)<0?-(x):(x))

#define scanI(a) scanf("%d",&a)
#define scanI2(a,b) scanI(a) , scanI(b)
#define scanI3(a,b,c) scanI(a), scanI(b), scanI(c)
#define scanI4(a,b,c,d) scanI(a), scanI(b), scanI(c), scanI(d)

#define scanL(a) scanf("%I64d",&a)
#define scanL2(a,b) scanL(a) , scanL(b)
#define scanL3(a,b,c) scanL(a), scanL(b), scanL(c)
#define scanL4(a,b,c,d) scanL(a), scanL(b), scanL(c), scanL(d)

#define SORT(v) sort(v.begin(),v.end())
#define REV(v) reverse(v.begin(),v.end())

#define FastRead ios_base::sync_with_stdio(0);cin.tie(nullptr);

const int N = 1000005;
bool stat[N];
vector<pair<int,int>>fac[N];

void siv()
{
    for(int i = 4;i < N;i += 2)stat[i] = 1;
    int sq = sqrt(N);
    for(int i = 3;i <= sq;i += 2){
        if(stat[i])continue;
        for(int j = i * i;j < N;j += 2 * i)stat[j] = 1;
    }
    stat[1] = 1;

    for(int i = 2;i < N;i++){
        if(stat[i])continue;
        for(int j = i;j < N;j += i){
            int temp = j;
            int cnt = 0;
            while(temp % i == 0){
                temp/=i;
                cnt++;
            }
            fac[j].push_back(mk(i,cnt));
        }
    }
}
int n , ara[N],pw[N];
const LL MOD = 1e9 + 7;

LL bigmod(LL b,LL p,LL m)
{
    LL ret = 1;
    while(p > 0){
        if(p % 2 == 1)ret = (ret * b) % m;
        p = p >> 1;
        b = (b * b) % m;
    }
    return ret;
}
int main()
{
    siv();
    cin >> n;
    FOR(i,1,n)
    {
        cin >> ara[i];
        for(int j = 0;j < fac[ara[i]].size();j++){
            int base = fac[ara[i]][j].first;
            int cnt = fac[ara[i]][j].second;
            pw[base] = max(pw[base],cnt);
        }
    }
    LL ret = 1;
    for(int i = 2;i < N;i++){
        if(stat[i])continue;
        ret = ret * bigmod(i,pw[i],MOD);
        ret %= MOD;
    }
    LL ans = 0;
    for(int i = 1;i <= n;i++){
        LL g = ret * bigmod(ara[i],MOD-2,MOD);
        g %= MOD;
        ans = (ans + g) % MOD;
    }
    ans = (ans + MOD) % MOD;
    cout << ans << "\n";

}



Measured memory_bytes: 76544
#include <bits/stdc++.h>
#include <cstring>
#include <limits>
using namespace std;
#define ll long long int
#define X first
#define Y second
#define fw(i, start, end) for (ll i = start; i < end; ++i)
#define fe(i, start, end) for (ll i = start; i <= end; ++i)
#define L(T)  \
    ll T;     \
    cin >> T; \
    while (T--)
#define FASTIO                   \
    ios::sync_with_stdio(false); \
    cin.tie(nullptr);            \
    cout.tie(nullptr);
#define endl '\n'

ll a[108];
ll dp[100004];
ll n, k;
int solve(ll k)
{
    if (k <= 0)
        return 0;
    if (dp[k] != -1)
        return dp[k];
    dp[k] = 0;

    int ans = 0;
    fw(i, 1, n + 1)
    {
        if (a[i] > k)
        {
            continue;
        }
        if (solve(k - a[i]) == 0)
        {
            ans = 1;
            break;
        }
    }
    dp[k] = ans;
    return dp[k];
}
int main()
{
    FASTIO

    cin >> n >> k;
    fe(i, 1, n)
    {
        cin >> a[i];
    }
    memset(dp, -1, sizeof dp);
    solve(k);
    if (!solve(k))
    {
        cout << "Second\n";
        return 0;
    }
    cout << "First" << endl;
    return 0;
}

Measured memory_bytes: 7536
#include "bits/stdc++.h"
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#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 all(s) s.begin(), s.end()
using namespace std;
typedef long long int ll;
typedef pair<int,int> P;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
typedef vector<string> vs;
const int MX = 100005, INF = 1001001001;
const ll LINF = 1e18;
const double eps = 1e-10;
const int DIV = 1e9+7;

int n;
double dp[3000][3000];
vector<double> p;

double rec(int ptr, int omote) {
    if (omote > ptr) return 0.0;
    if (dp[ptr][omote] == -1.0) {
        dp[ptr][omote] = (1 - p[ptr]) * rec(ptr + 1, omote) + p[ptr] * rec(ptr + 1, omote + 1);
    }
    return dp[ptr][omote];
}

int main() {
    cin >> n;
    p.resize(n);
    rep(i, n) cin >> p[i];

    rep(i, n) rep(j, n) dp[i][j] = -1.0;
    rep(i, n) {
        if (i == n / 2) dp[n - 1][i] = p[n - 1];
        else if (i > n / 2) dp[n - 1][i] = 1.0;
        else dp[n - 1][i] = 0.0;
    }

    cout << setprecision(10) << rec(0, 0) << endl;
}

Measured memory_bytes: 70784
a,b,c,d = list(map(int,input().split()))
A = max(a,b)*max(c,d)
B = min(a,b)*max(c,d)
C = min(a,b)*min(c,d)
D = max(a,b)*min(c,d)
print(max(A,B,C,D))

Measured memory_bytes: 9188
#include<bits/stdc++.h>
using namespace std;
int mod=1e9+7;
int main(){
  int64_t n,sum=0,ans=0;
  cin >> n;
  int a[n];
  vector<int64_t> b(n+1,0);
  for(int i=0;i<n;i++){
    cin >> a[i];
    b[i+1]=b[i]+a[i];
  }
  for(int i=0;i<n;i++){
    sum=(b[n]-b[i+1])%mod;
    ans+=a[i]*sum;
    ans%=mod;
  }
  cout << ans << endl;
}

Measured memory_bytes: 5624
#include <iostream>

int main() {
    int a, b, c, x;
    std::string res = "NO";
    std::cin >> a >> b >> c;
    for (int i=1; i<=b; ++i) {
        x = a * i;
        if ( x % b == c ) res = "YES";
    }
    std::cout << res << std::endl;
    return 0;
}

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

using namespace std;

typedef long long LL;
typedef unsigned long long ULL;
typedef pair<int, int> PII;

const int N = 60, mod = 1e9 + 7;

LL x;

int main()
{
    cin >> x;
    if(x % 11 == 0) cout << x / 11 * 2 << endl;
    else
    {
        LL res = x / 11 * 2;
        x %= 11;
        if(x <= 6) res += 1;
        else res += 2;
        cout << res << endl;
    }
    return 0;
}


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

template<class T> inline bool chmax(T& a,T b){if(a<b){a=b;return 1;}return 0;}
template<class T> inline bool chmin(T& a,T b){if(a>b){a=b;return 1;}return 0;}
template<class T> inline T gcd(T a,T b){T c;while(b!=0){c=a%b;a=b;b=c;}return a;}
template<class T> inline T lcm(T a,T b){return a*b/gcd(a,b);}

const ll INF = 1LL << 60;

int main(){
  int n;
  cin >> n;
  int h[100];
  FOR(i,n){
    cin >> h[i];
  }
  int maxi=h[0];
  int ans=1;
  for(int i=1;i<n;i++){
    if(h[i]>=maxi){
      ans++;
      maxi=h[i];
    }
  }
  cout << ans << endl;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <unistd.h>
#include <stdlib.h>
#include <string.h>
#include <stdarg.h>
#include <fcntl.h>

int main()
{
	char str[1000];
	int len;

	scanf("%s", str);
	len = strlen(str);
	if (str[len-1] == 's')
		printf("%ses\n", str);
	else
		printf("%ss\n", str);
	return (0);
}

Measured memory_bytes: 1732
#include<iostream>
#include<vector>
#include<climits>
using namespace std;

// F : T x T -> T
// G : T x E -> T
// H : E x E -> E
template<typename T, typename E, typename F, typename G, typename H>
struct SegL{
private:
    vector<T> node;
    vector<E> lazy;
    int n;
    T defVal;
    E defOp;
    F f;    // merge elements(T)
    G g;    // update element(T) 
    H h;    // merge operators(E)

public:
    SegL(int siz, T defVal, E defOp, F f, G g, H h) : defVal(defVal), defOp(defOp), f(f), g(g), h(h){
        n = 1;
        while(n < siz)  n *= 2;
        node.resize(2*n-1, defVal);
        lazy.resize(2*n-1, defOp);
    }
    SegL(vector<T> v, T defVal, E defOp, F f, G g, H h) : defVal(defVal), defOp(defOp), f(f), g(g), h(h){
        n = 1;
        while(n < v.size())  n *= 2;
        node.resize(2*n-1, defVal);
        for(int i = 0; i < v.size(); i++)   node[n-1+i] = v[i];
        for(int i = n-2; i >= 0; i--)   node[i] = f(node[2*i+1], node[2*i+2]);
    }

    void eval(int k){
        if(lazy[k] == defOp)    return;
        if(k < n-1){
            lazy[2*k+1] = h(lazy[2*k+1], lazy[k]);
            lazy[2*k+2] = h(lazy[2*k+2], lazy[k]);
        }
        node[k] = g(node[k], lazy[k]);
        lazy[k] = defOp;
    }

    void update(int a, int b, E x, int k=0, int l=0, int r=-1){
        if(r < 0)   r = n;
        eval(k);
        if(b <= l || r <= a){
            return;
        }else if(a <= l && r <= b){
            lazy[k] = h(lazy[k], x);
            //eval(k);    // needless?
        }else{
            update(a, b, x, 2*k+1, l, (l+r)/2);
            update(a, b, x, 2*k+2, (l+r)/2, r);
            node[k] = f(node[2*k+1], node[2*k+2]);
        }
    }

    T query(int a, int b, int k=0, int l=0, int r=-1){
        if(r < 0)   r = n;
        eval(k);
        if(b <= l || r <= a)    return defVal;
        if(a <= l && r <= b)    return node[k];
        T lx = query(a, b, 2*k+1, l, (l+r)/2);
        T rx = query(a, b, 2*k+2, (l+r)/2, r);
        return f(lx, rx);
    }
};

int main(){
    int n, q;
    cin >> n >> q;
    auto f = [](int x, int y)->int{return min(x, y);};
    auto g = [](int x, int y)->int{return y==-1 ? x : y;};
    auto h = [](int x, int y)->int{return y==-1 ? x : y;};
    int defv = INT_MAX;
    int defop = -1;
    SegL<int, int, decltype(f), decltype(g), decltype(h)> seg(n, defv, defop, f, g, h);
    while(q--){
        int op;
        cin >> op;
        if(op == 0){
            int s, t, x;
            cin >> s >> t >> x;
            seg.update(s, t+1, x);
        }else{
            int i;
            cin >> i;
            cout << seg.query(i, i+1) << endl;
        }
    }
    return 0;
}


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

#define FOR(i,b,e) for (int i = (b); i <= (e); i++)
#define FORD(i,b,e) for (int i = (b); i >= (e); i--)
#define SIZE(c) ((int) (c).size())

#define pb push_back
#define st first
#define nd second

using namespace std;


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

typedef vector <int> VI;
typedef vector <ll> VL;
typedef vector <bool> VB;
typedef vector <pii> VP;

typedef vector <VI> VVI;
typedef vector <VL> VVL;
typedef vector <VB> VVB;
typedef vector <VP> VVP;

const int MOD = 1000000007;
const int INF = 1000000001;
const ll LINF = 1000000000000000001LL;


int main() {
    ios_base::sync_with_stdio(false);

    string s;
    cin >> s;

    int n = SIZE(s) + 1;

    VVI g(n);
    FOR(i,0,n-2) {
        int u = i, v = i + 1;

        if (s[i] == '>') {
            swap(u, v);
        }

        g[u].push_back(v);
    }

    VI indeg(n, 0);
    FOR(u,0,n-1) for (int v : g[u]) {
        indeg[v]++;
    }

    queue <int> q;
    VI val(n, 0);

    FOR(u,0,n-1) if (!indeg[u]) {
        q.push(u);
    }

    while (!q.empty()) {
        int v = q.front(); q.pop();

        for (int u : g[v]) {
            val[u] = max(val[u], val[v] + 1);
            indeg[u]--;

            if (!indeg[u]) {
                q.push(u);
            }
        }
    }

    ll ans = 0;
    for (int x : val) {
        ans += x;
    }

    cout << ans;

    return 0;
}

Measured memory_bytes: 32028
package main

import "fmt"

func main() {
	var N int
	fmt.Scanf("%d", &N)
	h := make([]int, N)
	for i := 0; i < N; i++ {
		fmt.Scanf("%d", &h[i])
	}
	c := make([]int, N)
	c[0] = 0
	c[1] = abs(h[1] - h[0])
	for i := 0; i < N-2; i++ {
		c[i+2] = c[i] + abs(h[i+2]-h[i])
		chmin(&c[i+2], c[i+1]+abs(h[i+2]-h[i+1]))
	}
	fmt.Println(c[N-1])
}

func abs(v int) int {
	if v < 0 {
		return -v
	}
	return v
}

func chmin(v1 *int, v2 int) {
	if *v1 > v2 {
		*v1 = v2
	}
}


Measured memory_bytes: 5504
#include<bits/stdc++.h>
int main()
{
  int r,d;
  long long a;
  std::cin>>r>>d>>a;
  for(int i=0;i<10;i++)
  {
    a=(r*a) - d;
    std::cout<<a;
    if(i!=9)
    {
      std::cout<<"\n";
    }
  }

  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<map>
#include<set>
#include<stack>
#include<queue>
#include<math.h>
using namespace std;
typedef long long ll;
#define int long long
typedef vector<int> VI;
typedef pair<int, int> pii;
typedef priority_queue<int> PQ;
#define fore(i,a) for(auto &i:a)
#define REP(i,n) for(int i=0;i<n;i++)
#define eREP(i,n) for(int i=0;i<=n;i++)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define eFOR(i,a,b) for(int i=(a);i<=(b);++i)
#define SORT(c) sort((c).begin(),(c).end())
#define rSORT(c) sort((c).rbegin(),(c).rend())
#define LB(x,a) lower_bound((x).begin(),(x).end(),(a))
#define UB(x,a) upper_bound((x).begin(),(x).end(),(a))
#define INF 1000000000
#define LLINF 2147483647
#define mod 1000000007
//vector<vector<int> > dp;
//vector<vector<vector<int> > > vvvi;
//dp=vector<vector<int> >(N, vector<int>(M,0));
//vector<pair<int,int> > v;
//v.push_back(make_pair(x,y));
//priority_queue<int,vector<int>, greater<int> > q2;

vector<int> value;
int N;

void update(int i, int x) {
	i += N - 1;
	value[i] = x;
	while (i > 0) {
		i = (i - 1) / 2;
		value[i] = min(value[i * 2 + 1], value[i * 2 + 2]);
	}
}

int query(int a, int b, int k, int l, int r) {
	if (r <= a || b <= l)return LLINF;
	if (a <= l && r <= b)return value[k];
	else {
		int c1 = query(a, b, 2 * k + 1, l, (l + r) / 2);
		int c2 = query(a, b, 2 * k + 2, (l + r) / 2,r);
		return min(c1, c2);
	}
}


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

	int n, q;
	cin >> n >> q;
	N = 1;
	while (N < n)N *= 2;
	value = vector<int>(2 * N - 1);
	REP(i, value.size())value[i] = LLINF;
	REP(i, q) {
		int c;
		cin >> c;
		int s, t;
		cin >> s >> t;
		if (!c) update(s, t);
		else cout << query(s, t + 1, 0, 0, N) << endl;
	}
	
	return 0;
}




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

int digit(int n) {
  int d = 0;
  while(n > 0) {
    d++;
    n /= 10;
  }
  return d;
}

int main(){
  int n; 
  cin >> n;
  int ans = 0;
  rep(i,n+1) {
    if(digit(i) % 2) ans++;
  }
  cout << ans << endl;
  return 0;
}

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

using namespace std;
using ll = long long;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)	
#define max (ll)1e18

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

	vector<ll> t(n);
	rep(i, n) {
		cin >> t[i];
		if (t[i] == 0) {
			cout << 0 << endl;
			return 0;
		}
	}
	ll a = 1;
	rep(i, n) {
		if (a > max / t[i]) {
			a = -1;
			break;
		}
		a *= t[i];
	}
	cout << a << endl;

	return 0;
}

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

#define FIN ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define ll long long
#define pb push_back
#define fore(i,a,b) for(int i = a; i < b; i++)
#define rfor(i, a, b) for(int i = a - 1; i >= b; i--)

ll dp[3010][3010];
string s,t;

void solve(){ 
    for (int i = 0; i <= s.size(); i++) { 
        for (int j = 0; j <= t.size(); j++){ 
            if (i == 0 || j == 0){
                dp[i][j] = 0; 
            }else if (s[i - 1] == t[j - 1]){
                dp[i][j] =  dp[i - 1][j - 1] + 1;
            }else{
                max(dp[i-1][j],dp[i][j-1]);
            }
        } 
    }  
    for (int i = 0; i <= s.size(); i++) { 
        for (int j = 0; j <= t.size(); j++){ 
            if (i == 0 || j == 0){
                dp[i][j] = 0; 
            }else if (s[i - 1] == t[j - 1]){
                dp[i][j] =  dp[i - 1][j - 1] + 1;
            }else{
              dp[i][j] = max(dp[i-1][j],dp[i][j-1]);
            }
        } 
    }     
    
    string ans = "";
    int i = s.size(),j = t.size();
    while(i >= 1 && j >= 1){
        if(s[i-1] == t[j-1]){
            ans = ans + s[i-1];
            i--;j--;
        }else if(i >= 1 && j > 1 &&dp[i-1][j] < dp[i][j-1]){
            j--;
        }else if(i > 1 && j >= 1 &&dp[i-1][j] >= dp[i][j-1]){
            i--;
        }else if(i == 1 && j > 1){
            j--;
        }else if(j == 1 && i > 1){
            i--;
        }
        if(s[i-1] != t[j-1] && i == 1 && j == 1){
            break;
        }
    }
    reverse(ans.begin(),ans.end());
    cout<<ans<<endl;
} 
int main(){ 
    cin>>s;
    cin>>t;
    solve();
    return 0; 
} 

Measured memory_bytes: 70784
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  string str;
  long k,nagasa,cou,count,i,ans;
  cin>>str>>k;
  cou=0;
  count=0;
  nagasa=str.size();
  for(i=0; i<nagasa-1; i++){
    if(str.at(i)==str.at(i+1)){
      i=i+1;
      cou=cou+1;
    }
  }
  if(i==nagasa || str.at(0) != str.at(nagasa-1)){
    ans=cou*k;
  }
  else{
    for(i=1; i<nagasa-1; i++){
      if(str.at(i)==str.at(i+1)){
        i=i+1;
        count=count+1;
      }
    }
    if(i==nagasa-1){
      ans=k-1+cou+count*(k-1);
    }
    else{
      if(k%2==0){
        ans=(cou+count+1)*k/2;
      }
      else{
        ans=(cou+count+1)*(k-1)/2+cou;
      }
    }
  }
  cout<<ans;
}

Measured memory_bytes: 256
#include "iostream"
#include "vector"
#include "string"
#include "algorithm"
#include "math.h"
#include "cstring"

using namespace std;
typedef long long ll;

int main()
{
  int n;
  cin >> n;
  int h[110];
  for (int i = 0; i < n; i++)
  {
    cin >> h[i];
  }
  int ans = h[0];
  for (int i = 1; i < n; i++)
  {
    ans += max(h[i] - h[i - 1], 0);
  }
  cout << ans << "\n";
}


Measured memory_bytes: 256
import java.util.*;
public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		Scanner sc = new Scanner(System.in);
		int k = sc.nextInt();
		int s = sc.nextInt();
		int ans = 0;
		for(int x=0;x<=k;x++) {
			for(int y=0;y<=k;y++) {
				int z = s-x-y;
				if(z>=0 && z<=k) {
					ans++;
				}
			}
		}
		System.out.println(ans);
	}

}

Measured memory_bytes: 23124
import sys
sys.setrecursionlimit(10**6)
def main(N, c2, c3, c5, c):
    m = dict()
    m[0] = 0
    m[1] = c

    def f(n):
        if n in m: return m[n]
        res = c * n
        e5 = n % 5
        e3 = n % 3
        e2 = n % 2
        if e5 != 0:
            res = min(res, (5 - e5) * c + f(n // 5 + 1) + c5)
        if e3 != 0:
            res = min(res, (3 - e3) * c + f(n // 3 + 1) + c3)
        if e2 != 0:
            res = min(res, (2 - e2) * c + f(n // 2 + 1) + c2)
        if n >= 5:
            res = min(res, e5 * c + f(n // 5) + c5)
        if n >= 3:
            res = min(res, e3 * c + f(n // 3) + c3)
        if n >= 2:
            res = min(res, e2 * c + f(n // 2) + c2)
        m[n] = res
        return res

    return f(N)

if __name__ == '__main__':
    input = sys.stdin.readline
    T = int(input())
    for t in range(T):
        n, a, b, c, d = map(int, input().split())
        ans = main(n, a, b, c, d)
        print(ans)


Measured memory_bytes: 20044
#include<iostream>
#include<stdio.h>
using namespace std;
int main(){
    int n,A[100];
    cin>>n;
    for(int i=0;i<n;i++){
        cin>>A[i];
    }
    for(int j=n-1;j>=0;j--){
        if(j!=n-1){
            cout<<" "<<A[j];
        }else{
            cout<<A[j];
        }
    }cout<<endl;
    return 0;
}


Measured memory_bytes: 3088
N = int(input())
H = list(map(int, input().split()))

C = [None] * N
C[0] = 0
C[1] = abs(H[1] - H[0])

for i in range(2, N):
    # 二つ先にジャンプ
    c1 = C[i-2] + abs(H[i] - H[i-2])
    
    # 一つ先にジャンプ
    c2 = C[i-1] + abs(H[i] - H[i-1])

    C[i] = min(c1, c2)

# print(C)
print(C[N-1])

Measured memory_bytes: 13928
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Scanner;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 *
 * @author silviase
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        Scanner in = new Scanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        EWhoSaysAPun solver = new EWhoSaysAPun();
        solver.solve(1, in, out);
        out.close();
    }

    static class EWhoSaysAPun {
        public void solve(int testNumber, Scanner in, PrintWriter out) {

            int n = in.nextInt();
            String s = in.next();
            int[][] dp = new int[n + 1][n + 1];

            int max = 0;

            for (int i = n - 1; i >= 0; i--) {
                for (int j = n - 1; j >= 0; j--) {
                    dp[i][j] = s.charAt(i) == s.charAt(j) ? dp[i + 1][j + 1] + 1 : 0;
                    max = Math.max(max, Math.min(dp[i][j], Math.abs(i - j)));
                }
            }

            out.println(max);

        }

    }
}



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

int main(){
	int N;
  	int a[110];
  	cin >> N;
  	for (int i = 0; i < N; i++) cin >> a[i];
  	
  	sort(a,a+N,greater<int>());
  	int Alice = 0;
  	int Bob = 0;
  	for(int i = 0; i<N;++i){
    	if(i%2==0){
        	Alice += a[i];
        }else{
        	Bob += a[i];
        }
    }
  cout << Alice -Bob << endl;
}

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

#include <boost/algorithm/string/classification.hpp>  // is_any_of
#include <boost/algorithm/string/join.hpp>
#include <boost/algorithm/string/replace.hpp>
#include <boost/algorithm/string/split.hpp>
#include <boost/math/tools/minima.hpp>
#include <boost/multi_array.hpp>
#include <boost/multiprecision/cpp_int.hpp>
#include <boost/optional.hpp>
#include <boost/range/adaptors.hpp>
#include <boost/range/algorithm.hpp>
#include <boost/range/irange.hpp>

const int MOD = 1e9 + 7;
#define rep(i, n) for (int i = 0; i < (n); ++i)

namespace adaptor = boost::adaptors;
using namespace std;
using boost::irange;
using boost::algorithm::join;
using boost::algorithm::replace_all;
using boost::algorithm::split;
using boost::math::tools::brent_find_minima;
using boost::multiprecision::cpp_int;
using ll = long long;
using P = pair<int, int>;

// TOP
void Main()
{
	int n;
	cin >> n;
	vector<int> V(n);
	rep(i, n)
	{
		int x;
		cin >> x;
		x--;
		V.at(i) = x;
	}
	int count;
	count = 0;
	rep(i, n)
	{
		if (V.at(V.at(i)) == i)
			count++;
	}
	cout << count / 2 << endl;
}
// END

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


Measured memory_bytes: 640
#include <iostream>
#include <numeric>
#include <vector>
using namespace std;

int main() {
  int n;
  cin >> n;
  vector<int> a(n);
  for (int i = 0; i < n; ++i) cin >> a[i];
  int sum = accumulate(a.begin(), a.end(), 0);
  int best = 0;
  for (int i = 1; i < n; ++i) {
    if (abs(a[i] * n - sum) < abs(a[best] * n - sum)) {
      best = i;
    }
  }
  cout << best << endl;
  return 0;
}


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

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

  int elem, ind_sort = 0;
  int c_max = 100, c_val, dupl;
  vector<int> bucket(c_max), sort(N);
  for (int i = 0; i < N; i++) { 
    cin >> elem;
    bucket.at(elem - 1)++;
  }
  for (int ind = 0; ind < c_max; ind++) {
    c_val = ind + 1;
    dupl = bucket.at(ind);
    if (dupl != 0) {
      for (int i = 0; i < dupl; i++) {
        sort.at(ind_sort++) = c_val;
      }
    }
  }
  int suma = 0, sumb = 0;
  for (int i = 0; i < N; i+=2) {
		suma += sort.at(N - i - 1);
    sumb += (N - i - 2 >= 0) ? sort.at(N - i - 2) : 0;
  }
	cout << (suma - sumb) << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
    string a;
    cin>>a;
    int cnt=0;
    for(int i=0;i<a.size();i++){
        if(a[i]=='C'){
            cnt=1;
        }
        if(a[i]=='F'&&cnt==1){
            cout<<"Yes";
            return 0;
        }
    }
    cout<<"No";
    return 0;
}

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

int main() {
  string s,t;
  cin>>s>>t;
  if(s.size()<t.size()) {
    cout<<"UNRESTORABLE"<<endl;
    return 0;
  }
  bool check=false;
  for(int i=s.size()-t.size();i>=0;i--){
    bool flag=true;
    for(int j=0;j<t.size();j++){
      if(s.at(i+j)==t.at(j) || s.at(i+j)=='?') continue;
      else flag=false;
      if(!flag) break;
    }
    if(flag){
      for(int j=0;j<t.size();j++){
        if(s.at(i+j)=='?') s.at(i+j)=t.at(j) ;
      }
      check=true;
      break;      
    }
  }
  if(!check) cout<<"UNRESTORABLE"<<endl;
  else{
    for(int i=0;i<s.size();i++){
      if(s.at(i)=='?') cout<<'a';
      else cout<<s.at(i);
    }
  } 
  cout<<endl;
  return 0;
}

Measured memory_bytes: 256
//54
#include<iostream>
#include<string>
#include<set>
#include<map>
#include<sstream>

using namespace std;

map<string,string> m;
set<string> ms;
set<string> ch;

void dfs(string g){
  if(ch.count(g))return;
  ch.insert(g);
  string mg=m[g];
  for(int i=0;i<mg.size();i++){
    if(mg[i]=='.'||mg[i]==','){
      mg[i]=' ';
    }
  }
  stringstream ss(mg);
  for(string mg;ss>>mg;){
    if(m.count(mg)){
      dfs(mg);
    }else{
      ms.insert(mg);
    }
  }
}

int main(){
  for(int n;cin>>n,n;){
    string g1;
    cin.ignore();
    m.clear();
    ms.clear();
    ch.clear();
    for(int i=0;i<n;i++){
      string s;
      getline(cin,s);
      string g=s.substr(0,s.find(':'));
      if(i==0){
	g1=g;
      }
      m[g]=s.substr(s.find(':')+1);
    }
    dfs(g1);
    cout<<ms.size()<<endl;
  }
  return 0;
}
      

Measured memory_bytes: 1412
#include <cstdio>
char ss[]="SHCD";
void outputcard(int c){
 printf("%c %d\n",ss[c/13],c%13+1);
};
int inputcard(){
 char suit[3];
 int num,base;
 scanf("%s %d",suit,&num);
 if (suit[0]=='S') base=0;
 if (suit[0]=='H') base=13;
 if (suit[0]=='C') base=26;
 if (suit[0]=='D') base=39;
 return base+num-1;
};
int main(){
 int i,n,found[52];

 for(i=0;i<52;i++) found[i]=0;
 scanf("%d",&n);
 for(i=0;i<n;i++) found[inputcard()]=1;
 for(i=0;i<52;i++)
  if (found[i]==0) outputcard(i);
};

Measured memory_bytes: 1028
/**
 *   author: AK Tiwari
 *   created: 30 January 2019  12:02:38
**/
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define rep(i,a,b) for(ll i=a;i<=b;i++)
#define rrep(i,b,a) for(ll i=b;i>=a;i--)
struct vars { ll a,b; };
ll i,j,k;
vector<ll> cost(100005,1e9);
vector<ll> a(100005);

void solve(){
	ll n;cin>>n;cin>>j;
	rep(i,0,n-1)cin>>a[i];
	rrep(i,n-1,0){
		if(i==(n-1))
			cost[i] = 0;
		rep(k,1,j){
			if((i+k)<n){
				cost[i] = min(cost[i],cost[i+k]+abs(a[i]-a[i+k]));
			}
		}
	}
	cout<<cost[0];
}

int main(){
    ios_base::sync_with_stdio(false); 
    cin.tie(NULL);
    // ll t;cin>>t;
    // while(t--)
    	solve();
return 0;
}

Measured memory_bytes: 1792
#include<bits/stdc++.h>
#define ll long long
#define fast_io ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);

using namespace std;

int main()
{
    fast_io
    ll i,j,a,b,c,x,xx,y,yy,direct=0,bya=0,byb=0;
    cin>>a>>b>>c>>x>>y;
    xx=x;
    yy=y;
    direct=x*a+y*b;
    bya=2*x*c;
    y-=x;
    if(y>0)
        bya+=(y*b);


    byb=2*yy*c;
    xx-=yy;
    if(xx>0)
        byb+=(xx*a);
    //cout<<direct<<" "<<bya<<" "<<byb<<endl;
    cout<<min(direct,min(bya,byb))<<endl;

    return 0;
}





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

typedef long long LL;

#define REP(i, n) for(int i = 0; i < (int)(n); i++)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define ALL(x) (x).begin(),(x).end()
const int IINF = 1e9;
const LL LINF = 1e18;
const LL mod = 1e9+7;

int main() {
    int H, W;
    cin >> H >> W;
    vector<vector<int>> A(H, vector<int>(W));
    vector<vector<int>> B(H, vector<int>(W));
    REP(h, H) {
        REP(w, W) {
            cin >> A[h][w];
        }
    }
    REP(h, H) {
        REP(w, W) {
            cin >> B[h][w];
        }
    }
    vector<vector<int>> C(H, vector<int>(W));
    REP(h, H) {
        REP(w, W) {
            C[h][w] = abs(A[h][w] - B[h][w]);
        }
    }

    int M = 159*80;
    vector<vector<vector<bool>>> dp(H, vector<vector<bool>>(W, vector<bool>(M, 0)));
    dp[0][0][C[0][0]] = 1;
    FOR(w, 1, W) {
        REP(i, M) {
            if(dp[0][w - 1][i] && i + C[0][w] < M) {
                dp[0][w][i + C[0][w]] = 1;
            }
            if(dp[0][w - 1][i] && 0 <= i - C[0][w]) {
                dp[0][w][i - C[0][w]] = 1;
            }
            if(dp[0][w - 1][i] && 0 <= -i + C[0][w]) {
                dp[0][w][-i + C[0][w]] = 1;
            }
        }
    }
    FOR(h, 1, H) {
        REP(i, M) {
            if(dp[h - 1][0][i] && i + C[h][0] < M) {
                dp[h][0][i + C[h][0]] = 1;
            }
            if(dp[h - 1][0][i] && 0 <= i - C[h][0]) {
                dp[h][0][i - C[h][0]] = 1;
            }
            if(dp[h - 1][0][i] && 0 <= -i + C[h][0]) {
                dp[h][0][-i + C[h][0]] = 1;
            }
        }
    }
    FOR(h, 1, H) {
        FOR(w, 1, W) {
            REP(i, M) {
                if(dp[h][w - 1][i] && i + C[h][w] < M) {
                    dp[h][w][i + C[h][w]] = 1;
                }
                if(dp[h][w - 1][i] && 0 <= i - C[h][w]) {
                    dp[h][w][i - C[h][w]] = 1;
                }
                if(dp[h][w - 1][i] && 0 <= -i + C[h][w]) {
                    dp[h][w][-i + C[h][w]] = 1;
                }

                if(dp[h - 1][w][i] && i + C[h][w] < M) {
                    dp[h][w][i + C[h][w]] = 1;
                }
                if(dp[h - 1][w][i] && 0 <= i - C[h][w]) {
                    dp[h][w][i - C[h][w]] = 1;
                }
                if(dp[h - 1][w][i] && 0 <= -i + C[h][w]) {
                    dp[h][w][-i + C[h][w]] = 1;
                }
            }
        }
    }
    REP(i, M) {
        if(dp[H - 1][W - 1][i]) {
            cout << i << endl;
            return 0;
        }
    }
    return 0;
}



Measured memory_bytes: 10752
def main():
    import sys
    input = sys.stdin.readline
    
    N = int(input())
    A = set(map(int,input().split()))
    A = sorted(list(A))

    import bisect

    ans = A[-1]/2
    b = bisect.bisect_left(A,ans)

    if abs(ans-A[b])<abs(ans-A[max(0,b-1)]):
        print(A[-1],A[b])
    else:
        print(A[-1],A[b-1])

if __name__=='__main__':
    main()

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

int main()
{
	int week, n = 100000;
	cin >> week;
	for (int i = 0; i < week; i++)
	{
		n += n * 0.05;
		//cout << n << endl;
		if (n % 1000 != 0) n = ((n + 1000) / 1000) * 1000;
	}
	cout << n << endl;
	return 0;
}


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

#define rep(i,s,n) for (int i = (int)s; i < (int)n; i++)
#define ll long long
#define pb push_back
#define All(x) x.begin(), x.end()
#define Range(x, i, j) x.begin() + i, x.begin() + j
#define lbidx(x, y) lower_bound(x.begin(), x.end(), y) - x.begin()
#define ubidx(x, y) upper_bound(x.begin(), x.end(), y) - x.begin()
#define BiSearchRangeNum(x, y, z) lower_bound(x.begin(), x.end(), z) - lower_bound(x.begin(), x.end(), y)turn idx;

#define EPS (1e-10)
#define equals(a, b) (fabs((a) - (b)) < EPS)

class Point {
  public:
  double x, y;

  Point(double x = 0, double y = 0): 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(a * x, a * y); }
  Point operator / (double a) { return Point(x / a, y / a); }

  double abs() { return sqrt(norm()); }
  double norm() { return x * x + y * y; }

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

struct Segment {
  Point p1, p2;
};

typedef Point Vector;

// 内積
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;
};

// 直交判定
bool isOrthogonal(Vector a, Vector b) {
  return equals(dot(a, b), 0.0);
};

// 並行判定
bool isParallel(Vector a, Vector b) {
  return equals(cross(a, b), 0.0);
};

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

// 反射
Point reflect(Segment s, Point p) {
  return p + (project(s, p) - p) * 2.0;
};

int main() {
  int sx1, sy1, sx2, sy2;
  int q;
  cin >> sx1 >> sy1 >> sx2 >> sy2 >> q;
  int x0, y0;
  Segment seg = { Point(sx1, sy1), Point(sx2, sy2) };
  Point p;
  rep(i, 0, q) {
    cin >> x0 >> y0;
    p = Point(x0, y0);
    Point ansp = reflect(seg, p);
    printf("%.10f %.10f\n", ansp.x, ansp.y);
  }
};



Measured memory_bytes: 3212
#include <bits/stdc++.h>
using namespace std;
int main(){
	int z;
	cin>>z;
	long long ma=0;
	long long sum=0;
	while(z--){
		long long s;
		cin>>s;
		ma=max(ma,s);
		sum+=s;
	}
	string x=(sum-ma>ma)?"Yes":"No";
	cout<<x<<endl;
}

Measured memory_bytes: 256
import java.io.BufferedReader;
//import java.io.FileInputStream;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Arrays;

public class Main {

	public static void main(String[] args) throws NumberFormatException, IOException {
		//System.setIn(new FileInputStream("./input.txt"));
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		StringBuilder sb = new StringBuilder();
		
		int n = Integer.parseInt(br.readLine());
		boolean[] dict = new boolean[(int) Math.pow(5, 12)];
		char[] c;
		for(int i = 0; i < n; ++i) {
			c = br.readLine().toCharArray();
			if(c[0] == 'i'){
				// insert
				dict[hash(Arrays.copyOfRange(c, 7, c.length))] = true;
			}else{
				// find
				if(dict[hash(Arrays.copyOfRange(c, 5, c.length))] == true){
					sb.append("yes\n");
				}else{
					sb.append("no\n");
				}
			}
		}
		System.out.print(sb);
	}
	public static int hash(char[] c){
		int a;
		int n = c.length;
		int hash = 0;
		for(int i = 0; i < n; ++i) {
			switch(c[n - i - 1]){
			case 'A':
				a = 1;
				break;
			case 'C':
				a = 2;
				break;
			case 'G':
				a = 3;
				break;
			default:
				a = 4;
				break;				
			}
			hash = hash*5 + a;
		}
		
		return hash;
		
	}
}

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

int main(){
  	int N, A, B, tmp, s, result=0;
  	cin >> N >> A >> B;
  	for(int i=1; i<=N; i++){
      	tmp=0; s=i;
    	while(i!=0) {tmp+=i%10; i/=10;}
      	i=s;
      	if(A<=tmp && tmp<=B) result+=i;
    }
  	cout << result << endl;
  	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
char s[100009];
int main()
{
    scanf("%s",&s);
    int n=strlen(s);
    if(s[0]==s[n-1])
    {
        n--;
    }
    if(n%2==1)
    {
        cout<<"First"<<endl;
    }
    else
    {
        cout<<"Second"<<endl;
    }
}


Measured memory_bytes: 384
M1, D1 = map(int, input().split())
M2, D2 = map(int, input().split())

if M1 in [1, 3, 5, 7, 8, 10, 12]:
	if D1 == 31:
		print("1")
	else:
		print("0")
elif M1 == 2:
	if D1 == 28:
		print("1")
	else:
		print("0")
else:
	if D1 == 30:
		print("1")
	else:
		print("0")

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

int main() {
  int N;
  string S, ans;
  ans = "Three";
  cin >> N;
  
  for (int i = 0; i < N; i++) {
    cin >> S;
    if (S == "Y") {
      ans = "Four";
    }
  }
  
  cout << ans << endl;

}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
#define FOR(i,l,r) for(i=l;i<r;i++)
#define REP(i,n) FOR(i,0,n)
#define ALL(x) x.begin(),x.end()
#define P pair<ll,ll>
#define F first
#define S second
signed main(){
  ll N,i,j=0;cin>>N;ll A[N],B[N],X[N],Y[N];
  REP(i,N)cin>>A[i];REP(i,N)cin>>B[i];
  REP(i,N){
    X[i]=upper_bound(A,A+N,i+1)-lower_bound(A,A+N,i+1);
    Y[i]=upper_bound(B,B+N,i+1)-lower_bound(B,B+N,i+1);
    if(X[j]+Y[j]<X[i]+Y[i])j=i;
  }
  if(X[j]+Y[j]>N)cout<<"No"<<endl;
  else{
    cout<<"Yes"<<endl;ll x=0;
    while(1){
      REP(i,N)if(A[i]==B[(i+x)%N])break;
      if(i==N)break;x++;
    }
    REP(i,N-1)cout<<B[(i+x)%N]<<" ";
    cout<<B[(N-1+x)%N]<<endl;
  }
  return 0;
}

Measured memory_bytes: 9892
#!/usr/bin/env python3
import sys


def solve(N: int, S: "List[str]"):
    ret = 'Three'
    for c in S:
        if c == 'Y':
            ret = 'Four'
    print(ret)
    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
    S = [ next(tokens) for _ in range(N) ]  # type: "List[str]"
    solve(N, S)

if __name__ == '__main__':
    main()


Measured memory_bytes: 3060
#include <iostream>
#include <cstdlib>
using namespace std;
int main()
{
   int a, b, c;
   for(int i=0;i<3000;i++) {
   cin>>a>>b;
   if(a==0&&b==0) break;
   if(a>b){
       c=a;
       a=b;
       b=c;
       }
   cout << a <<" "<< b << endl;
   }
}



Measured memory_bytes: 2996
#include <bits/stdc++.h>
using intl = long long;
using itnl = long long;
using itn = int;
using ld = long double;
using namespace std;
#define rep(i, n) for(intl i = 0; i < (intl)(n); i++)
#define rrep(i, n) for(intl i = (intl)(n) - 1; i >= 0; i--)
#define repi(i, a, b) for(intl i = (intl)(a); i < (intl)(b); i++)
#define rrepi(i, a, b) for(intl i = (intl)(a); i > (intl)(b); i--)
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define m0(x) memset(x,0,sizeof(x))
#define m1(x) memset(x,1,sizeof(x))
#define fill(x,y) memset(x,y,sizeof(x))
#define alength(a) (sizeof(a) / sizeof(a[0]))
#define cin(i, a) rep(i, alength(a))cin >> a[i]
#define ccin(i, j, a) rep(i, alength(a))rep(j, alength(a[i]))cin >> a[i][j]
#define debug(x) cout << #x << ":" << x << endl
#define rdebug(i,x) rep(i, alength(x))cout << #x << "[" << i << "]:" << x[i] << endl
#define rrdebug(i, j, x) rep(i, alength(x))rep(j, alength(x[i]))cout << #x << "[" << i << "][" << j << "]:" << x[i][j] << endl
#define sqrt sqrtl
#define itn int
#define double ld
#define pb push_back
#define mp make_pair
#define pii pair<intl,intl>
const intl INF = 1e9;
const intl MOD = 1e9+7;
const ld EPS = 1.0e-14;//-9
const ld PI = acos(-1);
void fp(bool f){cout << (f ? "Yes" : "No") << endl;}
void fp(bool f, string s, string t){cout << (f ? s : t) << endl;}
template<class T> inline bool chmin(T& a, T b) { if (a > b) {a = b; return true;} return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) {a = b; return true;} return false; }
intl kai(intl k){
    intl a = 1;
    for(int i = 2; i <= k; i++){
        a *= i;
    }
    return a;
}
intl gcd(intl a, intl b){ if(!b)return a; return gcd(b, a % b); }
intl lcm(intl a,intl b){ return a / gcd(a, b) * b; }
intl digit10(intl a){
    intl b = 0;
    do{
        a /= 10;
        b++;
    }while(a);
    return b;
}
//-------------------------------------------------------------------------------

ld a,b,x;

void input_var(){
    cin >> a >> b >> x;
}
//-------------------------------------------------------------------------------

signed main(){
    cout << fixed << setprecision(10);
    input_var();
    if(x / a >= a * b / 2)cout << atan2((2 * a * a * b - 2 * x)/(a * a),a) / (2 * PI) * 360 << endl;
    else cout << atan2(b, 2 * x / (a * b)) / (2 * PI) * 360 << endl;
    return 0;
}

Measured memory_bytes: 256
N = int(input())
F = []
for i in range(N):
    F.append(list(map(int, input().split())))
P = []
for i in range(N):
    P.append(list(map(int, input().split())))

result = -float("inf")
    
for i in range(2 ** 10):
    if i != 0:
        op = list(bin(i)[2:].zfill(10))
        profit = 0
        for n in range(N):
            num = 0
            for j in range(10):
                if str(F[n][j]) == op[j] == "1":
                    num += 1
            profit += P[n][num]
        if i == 2 or result < profit:
            result = profit
print(result)

Measured memory_bytes: 3064
#include<stdio.h>
int main(void){
int a[3],i,j,t;
scanf("%d %d %d",&a[0],&a[1],&a[2]);
for(i=0;i<3;i++){
for(j=i+1;j<3;j++){
if(a[i]>a[j]){
t=a[i];
a[i]=a[j];
a[j]=t;
}
}
}
printf("%d %d %d\n",a[0],a[1],a[2]);
return 0;
}

Measured memory_bytes: 596
#include<iostream>

using namespace std;

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

Measured memory_bytes: 256
import queue

def main():
    n, m = map(int, input().split())
    graph = [[]for i in range(n + 1)]
    a = None
    b = None
    for _ in range(m):
        a, b = map(int, input().split())
        graph[a].append(b)
        graph[b].append(a)
    sign = [0 for i in range(n + 1)]
    vis = [False for i in range(n + 1)]
    q = queue.Queue(0)
    q.put(1)
    vis[1] = True
    while q.empty() == False:
        u = q.get()
        for val in graph[u]:
            if vis[val] == False:
                vis[val] = True
                q.put(val)
                sign[val] = u
    for i in range(2, n + 1):
        if sign[i] == 0:
            print("No")
            return
    print("Yes")
    for i in range(2, n + 1):
        print(sign[i])



if __name__ == "__main__":
    main()


Measured memory_bytes: 35316
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
using namespace std;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define REP(i,m,n) for(int i=m;i<(int)(n);i++)
template<class T>bool chmax(T& a, const T& b) { if (a < b) { a = b; return 1; } return 0; }
template<class T>bool chmin(T& a, const T& b) { if (b < a) { a = b; return 1; } return 0; }
typedef long long ll;
typedef pair<ll,ll> pint;
const long long INF = 1LL<<60;
ll gcd(ll a,ll b){
    if(b==0){
        return a;
    }
    else{
        return gcd(b,a%b);
    }
}

int main(){
    vector<pint> E[50];
    ll dist[50][3010];
    int a[101],b[101],c[50],d[50];
    using Edge = pair<ll,pair<ll,ll>>; //行先，お金,時間
    using Graph = vector<vector<Edge>>;
    using vertex = vector<pair<ll,ll>>;//枚数，時間
    Graph G(50);
    vertex V(50);
    priority_queue<pair<ll,pint>,vector<pair<ll,pint>>,greater<pair<ll,pint>>> que;
    bool visited[50][3010];
    ll ans[50];
    ll n,m,s;cin>>n>>m>>s;
    s = min(s,3000LL);
    //cout<<s<<endl;
    rep(i,m){
        ll u,v,a,b;
        cin>>u>>v>>a>>b;
        G[u-1].push_back(Edge(v-1,{a,b}));
        G[v-1].push_back(Edge(u-1,{a,b}));
    }
    rep(i,n){
        ll c,d;
        cin>>c>>d;
        V[i]={c,d};
    }
    rep(i,n)rep(j,3010) dist[i][j]=INF;
    rep(i,n)rep(j,3010) visited[i][j]=false;
    dist[0][s]=0;
    visited[0][s]=true;
    que.push({0LL,{0,s}});
    while(! que.empty()){
        auto p = que.top();que.pop();
        int v = p.second.first;
        //cout<<v<<endl;
        ll costt = p.first;
        ll costm = p.second.second;
        if(dist[v][costm]<costt)continue;
        dist[v][costm]=costt;
        //cout<<dist[v][costm]<<endl;
        auto ver = V[v];
        auto e = G[v];
        //cout<<v<<endl;
        for(int i=0;i<e.size();i++){
            int to = e[i].first;
            ll money = e[i].second.first;
            ll time = e[i].second.second;
            if(money<=costm&&(time+costt)<dist[to][costm-money]){
                que.push({time+costt,{to,costm-money}});
                dist[to][costm-money]=time+costt;
            }
        }
        if (costm+ver.first<3010&&costt+ver.second<dist[v][costm+ver.first]){
            que.push({costt+ver.second,{v,costm+ver.first}});
            dist[v][costm+ver.first]=ver.second+costt;
        }
    }
    REP(i,1,n){
        ll res = INF;
        rep(j,3010){
            res = min(res,dist[i][j]);
        }
        cout<<res<<endl;
    }
}

Measured memory_bytes: 7540
#include<iostream>
#include<algorithm>
#include<cmath>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<set>
#include<queue>
#include<ctime>
#include<vector>
using namespace std;
inline int rd(){
  register char ch=getchar();
  register bool flag=false;
  register int res=0;
  while(ch<'0'||ch>'9'){flag=(ch=='-');ch=getchar();}
  while(ch>='0'&&ch<='9'){
    res=(res<<3)+(res<<1)+ch-'0';ch=getchar();}
  if(flag)res=-res;
  return res;
}
int n;
#define N 1000010
#define mod 1000000007
int f[N],sf[N];
inline int upd(int &x,int y){x+=y;if(x>=mod)x-=mod;}
void work(){
  n=rd();
  int i,j;
  //n^2 dp 很好想，发现可以前缀和优化一下
  f[0]=1;sf[0]=1;
  for(i=1;i<=n;i++)
    {if(i>=3)
	f[i]=sf[i-3];//恰好在f结尾的
      //add more then 1
      upd(f[i],f[i-1]);
      sf[i]=sf[i-1];
      upd(sf[i],f[i]);
      //printf("%d ",f[i]);
    }
  int ans=0,n2=1LL*(n-1)*(n-1)%mod;
  for(i=0;i<=n-2;i++)
    upd(ans,1LL*f[i]*(n2+(i+1))%mod);//可以乱选择,限制必须超过n
  upd(ans,1LL*f[n-1]*(n-1)%mod);//必须限制超过n
  upd(ans,f[n]);//必须一样
  printf("%d\n",ans);
}
int main(){
  work();
  return 0;
}


Measured memory_bytes: 8064
INTEGER N,B,ANSWER
INTEGER,ALLOCATABLE,DIMENSION(:)::X
READ*,N
ALLOCATE(X(N))
READ*,X
Y=0
B=1
ANSWER=0
DO I=1,N
  ANSWER = ANSWER+1
  IF(X(B)==2) THEN
   PRINT"(I0)",ANSWER
   STOP
  ENDIF
  B=X(B)
END DO
PRINT"(I0)",-1
END

Measured memory_bytes: 1536
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.NoSuchElementException;
import java.util.*;
public class Main {
	static int INF = (int)1e9 + 7;
	int N,W;
	int[] v,w;
	int[] dp;
	
	public void solve() {
		N = nextInt();
		W = nextInt();
		v = new int[N];
		w = new int[N];
		dp = new int[W + 1];
		for(int i = 0;i < N;i++){
			v[i] = nextInt();
			w[i] = nextInt();
		}
		int ans = 0;
		for(int i = 1;i <= N;i++){
			for(int j = 0;j <= W;j++){
				if(j + w[i - 1] <= W){
					dp[j + w[i - 1]] = Math.max(dp[j + w[i - 1]],dp[j] + v[i - 1]);
				}
				ans = Math.max(ans,dp[j]);
			}
		}
		out.println(ans);
	}
 
	public static void main(String[] args) {
		out.flush();
		new Main().solve();
		out.close();
	}
 
	/* Input */
	private static final InputStream in = System.in;
	private static final PrintWriter out = new PrintWriter(System.out);
	private final byte[] buffer = new byte[2048];
	private int p = 0;
	private int buflen = 0;
 
	private boolean hasNextByte() {
		if (p < buflen)
			return true;
		p = 0;
		try {
			buflen = in.read(buffer);
		} catch (IOException e) {
			e.printStackTrace();
		}
		if (buflen <= 0)
			return false;
		return true;
	}
 
	public boolean hasNext() {
		while (hasNextByte() && !isPrint(buffer[p])) {
			p++;
		}
		return hasNextByte();
	}
 
	private boolean isPrint(int ch) {
		if (ch >= '!' && ch <= '~')
			return true;
		return false;
	}
 
	private int nextByte() {
		if (!hasNextByte())
			return -1;
		return buffer[p++];
	}
 
	public String next() {
		if (!hasNext())
			throw new NoSuchElementException();
		StringBuilder sb = new StringBuilder();
		int b = -1;
		while (isPrint((b = nextByte()))) {
			sb.appendCodePoint(b);
		}
		return sb.toString();
	}
 
	public int nextInt() {
		return Integer.parseInt(next());
	}
 
	public long nextLong() {
		return Long.parseLong(next());
	}
 
	public double nextDouble() {
		return Double.parseDouble(next());
	}
}

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

int main(){
    int a, b, r = 0;
    cin >> a >> b;
    for(int i = a; i <= b; i++){
        int s = i % 10, t = i / 10000 % 10;
        int u = i / 10 % 10, v = i / 1000 % 10;
        if ( s == t && u == v) r++; 
    }
    cout << r << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main() {
    ll n;
    cin>>n;
    ll arr[n];
    for(int i=0;i<n;i++)
        cin>>arr[i];
    ll x=0;
    for(int i=0;i<n;i++)
    {
        x=x^arr[i];
    }
    for(int i=0;i<n;i++)
    {
        ll y=arr[i]^x;
        cout<<y<<" ";
    }
    cout<<"\n";
}


Measured memory_bytes: 5160
from functools import reduce
from fractions import gcd

def lcm(a,b):
    return a*b//gcd(a,b)

n,m = map(int, input().split())
a = list(map(int, input().split()))
b = [n//2 for n in a]

l = reduce(lcm,b)

for i in range(n):
    if l//b[i]%2 == 0:
        print(0)
        break
else:
    print(m//l//2+m//l%2)


Measured memory_bytes: 89580
import sys
from collections import deque
readline = sys.stdin.readline


K = int(readline())

q = deque()

for i in range(1, 10):
    q.append([i])

count = 0
while True:
    a = q.popleft()
    count += 1
    if count == K:
        ans = a
        break
    tail = a[-1]
    if tail >= 1:
        q.append(a + [tail - 1])
    q.append(a + [tail])
    if tail <= 8:
        q.append(a + [tail + 1])

print(''.join(map(str, ans)))

Measured memory_bytes: 97884